Skip to content

fix(coordination): preserve JSON types in prose write fencing - #5773

Merged
huangruiteng merged 2 commits into
mainfrom
codex/typed-shadow-comparison
Oct 6, 2026
Merged

huangruiteng merged 2 commits into
mainfrom
codex/typed-shadow-comparison

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Prose-only state maintenance currently compares Python objects. Python considers boolean and integer values equal (true == 1, false == 0), so a legal full-record adapter projection can change JSON types without the guard rejecting it. Outbox identity already distinguishes those bytes.

Use the existing canonical JSON codec on the stable partition view before authorizing source IO. Preserve the resume evaluation clock exclusion, maintenance fence, typed full-record assembly and fail-closed errors. No new runtime method, vocabulary, provider switch or Python decision owner is introduced.

Author Declaration

  • Written by: model_agent — gpt-6.1-sol (OpenAI).
  • Specification: accepted R5/T4 last-caller retirement and preservation boundaries in docs/architecture/rfcs/ledger/shared-goal-authority-state-provider-v0/2026-09-28-retirement-cadence.md, base 8251ec80e0c327d28d13a1fd64e3f343a2aa3c0e.
  • Observable exit: prose guard rejects JSON type changes in complete adapter projections; unchanged prose and read-clock movement remain allowed.
  • Scope: source adapter fencing only. This does not complete source-writer retirement or qualify a release default.

Validation

Evidence Result
Two bool/int counterexamples through real TS source assembly Fail on unchanged base; pass on head
Source writer/projection/outbox suites 66 passed
Existing TS shadow identity suites 28 passed with the repository Node strip-types runner
Fresh wheel, isolated installation outside checkout 8 passed; packaged guard path and code digest verified, real CLI/bootstrap/outbox plus maintenance/reward/failure cases
Native premerge 14 selected and 5 direct checks passed on byte-identical final diff; final-head change-quality receipt recorded
Semantic advisory, full semantic check, privacy and diff checks Passed; no new vocabulary

Counterexample result facts are injected at the complete-record adapter boundary; they do not establish that the current Markdown codec emits that shape. Existing real entrypoints and disposable File backend remain covered. First wheel build failed because this reused worktree held an obsolete generated Chat bundle; the documented frontend build repaired it. An initial unsupported tsx test invocation failed before tests; the repository-native runner passed. Result-schema validation rejections were corrected without relaxing checks.

Frontend/Lark/CLI options and defaults are unchanged; their existing prose paths inherit the shared guard. No PostgreSQL store code, migration, new capability, current installation update or sustained qualification is included. The future-facing pass removes the competing structural-equality decision rather than adding a transport round trip. Live source IO, outbox and historical recovery remain in their current owners. The larger normalization migration stays in the existing retirement program.

DCO signed; dedicated branch from the named latest fetched main; exact paths only; no private state or generated assets in the diff. Maintainer merge is required for this control-plane change.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent — gpt-6.1-sol (OpenAI), runtime_reported, xhigh.

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机

维护 Goal 状态叙述、追加 reward 摘要的既有调用方。

完整投影里的布尔值变成整数时,旧 Python 比较会把它们视为相同,可能让叙述维护越过 Todo 保护;修复后明确拒绝这种变化。

验证到完整 adapter 投影的 JSON 类型变化被拒绝,纯叙述和读取时间变化继续可用。

本 PR 不删除活跃 writer,不切换 provider,也不完成 SQLite 发布默认或整个退役计划。

最后真实调用族删除、安装采用及长期 SQLite/恢复资格仍由既有退役计划推进。

改动思路

精确 head 91e43e64338787ba84fc534245110d3a5efb8c99,base 8251ec80e0c327d28d13a1fd64e3f343a2aa3c0e。审查依据为 docs/architecture/rfcs/ledger/shared-goal-authority-state-provider-v0/2026-09-28-retirement-cadence.md 在该 base 的已接受边界:T4 的最后调用方删除/恢复验收仍未结束;R5 的长期资格和发布默认不属于本次修复。此增量先保住继续退役需要的安全保护。

最强反对理由是:目前反例注入完整 adapter 输出,并未证明当前 Markdown codec 会发出这类字段;同时精确序列化比 Python 相等更有开销。仍值得修复,因为两个值都由真实 TS assembler 接受,而该保护声明的是完整投影不能变更,不能依赖偶然的当前输入形状。直接复用既有 codec 是较小的解决方式,无新 RPC、状态、开关或决策层;不声称性能提升。

具体改动

  • require_prose_state_write_allowed 保留 maintenance fence、完整 source projector 和 partition_comparison_view,只把对象相等替换为 canonical_bytes 的字节相等;只有读取时的 resume_condition.evaluated_at 继续被忽略,准备/写入/提交顺序及错误 owner 不变。
  • 既有 test_shadow_writer_boundaries.py 加入两组嵌套 result facts,真实创建 Todo、调用 TS 完整记录 assembler,确认 true/1、false/0 类型变化被拒绝且源字节保留。注入边界在测试内注明,不夸大为真实输入漏洞。
  • provider-selection reference 尾部说明 exact JSON 比较、时钟例外和权限范围;首屏、App/Lark/CLI 设置、提示与默认均未改变。

普通叙述/读取时间变化通过原路径继续写入;reward 注入 Todo、maintenance hold、失败替换及 provider unavailable 仍在现有 owner 拒绝。并发新增 Todo 的既有 reward rebase 用例通过,证明不会因同容器独立工作丢掉该 Todo。

对主干的风险

66 项源码 writer/projection/outbox 回归通过;既有 TS shadow identity 28 项通过;fresh wheel 在源码目录外独立安装,package/guard 路径和代码 digest 校验后,8 项 packaged reward/CLI/bootstrap/outbox 与故障用例通过。原生 premerge 14 项选择检查和5项直接检查通过,最终 head 的 CQR 已记录;语义 advisory/full-tree check 和精确路径 privacy 检查通过。两个新增反例在未修改 base 上均稳定失败,修改后通过。

首次构建被该旧 worktree 的过期生成 Chat bundle 拒绝;按照仓库 build:chat 重建后 wheel 成功。初始 TS 命令误用了本仓库未声明的 tsx,测试尚未开始就失败;改用仓库 Node strip-types runner 后28项通过。结构化结果曾被长度/一致性检查拒绝,修正结果字段后通过,检查未放宽。CI 按原生策略没有读取或等待。

这是 source fencing 的完整有界修复。没有修改 PostgreSQL store、迁移或新能力;实际 App/Lark 交互、长期 SQLite 资格及所有旧 writer 缺席未测且不被此结论认证。两次本地线性编码增加一点比较成本,不新增跨运行时调用;回滚无持久化迁移。source Host IO、outbox、历史输入和恢复能力继续保留。

我的整体评价

APPROVE 此精确 head 的有界修复;未发现阻断项。前瞻整理已通过移除竞争的 Python 相等解释完成,较大的归一化迁移仍需按调用族单独验证。该结论不关闭 T4/R5、完整退役验收或 Goal,也不授予合并权限;control-plane PR 留给维护者合并。

English verdict: APPROVE — head 91e43e6; preserve JSON scalar identity through the existing canonical byte boundary. Two base counterexamples, 66 source, 28 TS and 8 isolated installed checks plus native premerge qualify this bounded source-fence repair. Live writer retirement and release-default qualification remain open.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent; model=gpt-6.1-sol; provider=OpenAI; declaration=runtime_reported; reasoning_effort=xhigh.

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机

维护 Goal 状态叙述、追加 reward 摘要的既有调用方。
完整投影里的布尔值变成整数时,旧 Python 比较会把它们视为相同,可能让叙述维护越过 Todo 保护;修复后明确拒绝这种变化。
完整 adapter 投影经真实 TS assembler 后,类型变化被拒绝且源文件、运行记录不变;合法叙述、键顺序变化和读取时钟例外继续可用。
本 PR 不删除活跃 writer,不切换 provider,也不完成 SQLite 发布默认或整个退役计划。
最后真实调用族删除、安装采用及长期 SQLite/恢复资格仍由既有退役计划推进。

改动思路

精确 head fda3093,base 75fb0e9。原生队列因 main 合入使旧 review 失效,本次重新判断完整三路径 PR;旧 head 至当前 head 的 guard 与测试正文未变,相关 main 与文档变化已重新检查,旧批准未继承。最强反对理由是反例在完整 adapter 输出注入,并未证明当前 Markdown codec 会发出这些字段;精确编码也有线性成本。既有 TS assembler 接受这个完整记录形状,而保护契约要求完整事实不变,因此复用既有 codec 比另造规则或 RPC 更小。源码调用与相关恢复真实运行,不声称性能提升。

具体改动

变更前规范 docs/architecture/rfcs/ledger/shared-goal-authority-state-provider-v0/2026-09-28-retirement-cadence.md,spec revision 75fb0e9。Shadow capture/drain:implemented,活跃 source writer/outbox 和维护 fence 保留;Backup and complete data:implemented,完整 JSON 类型在稳定视图中保留;Deletion proof:deferred,实际最后调用方退役和安装恢复仍由既有计划验收,未用改后的文档反证自身。

关键代码讲解

  1. require_prose_state_write_allowed(runtime_shadow_writer_adapter.py:25)先验证 maintenance/fence,再将 original/planned 完整投影送入同一个稳定视图,随后用既有 codec 字节比较;不新增 provider mutation 或决策源。
  2. canonical_bytes(local_authority_shadow_projection.py:67)现有 UTF-8 排序编码保留布尔值和整数差别,禁止不安全数字,复用 capture identity 的边界。
  3. partition_comparison_view(同文件:209)只排除 resume 读取评估时钟,不删除 canonical 字段。feedback.py:489 在真实 index/source 锁内先调用此保护,再追加和原子写入。

完整差异 +54/-2:生产 +4/-2、既有测试 +45、参考文档 +5。没有新模块、协议字段或自动加载 instruction。Future-facing pass 删除了竞争的 Python 相等解释;实际 source IO/outbox 历史兼容有现存调用,不作无证据删除。

对主干的风险

本次独立 87 base/89 head Python 回归和 56/56 TS 回归全部通过,包含真实 CLI、reward/rebase、失败替换、outbox/cursor 恢复。16 组同 fixture 的 source guard/真实 TS 完整 assembler 观察:shadow 配置开/关由现有 owner 读回确认,8 组合法观察完全一致,8 组 bool/int、反向及嵌套类型变化只在 head 拒绝,源文件与 index 无副作用。固定不变量 oracle 在 base exit1、head exit0。注入的是合法完整 adapter fact,不把它说成当前 Markdown parser 的已发生漏洞。读取时钟例外、键顺序和 Unicode 正常路径保持。

Ruff、diff/public scan、advisory 后 full semantic、premerge 5 direct+14 selected 全通过,无失败/跳过/manual hold。探针首稿把 capture 配置写到了非 owner namespace,开/关标签不能证明真实配置;原记录保留,v2 通过原配置 owner 设置并断言读回,只修 fixture,不改业务 oracle。未查询、轮询或等待 CI。无 PostgreSQL store/迁移重构,未资格化长期 SQLite、真实 App/Lark、当前安装或模型效果。类型修复有意应用于原本就强制的 prose 保护,无新 opt-in 默认;可回滚比较代码,无数据迁移。

语义与 CI 对齐

复用既有完整记录与 canonical codec;无新词表或 substring 判定。当前本地 full semantic 检查通过,advisory 的空候选不作为动态语义等价证明。机器保护仍是写入前强制拒绝,文档没有称其为可忽略指导。

我的整体评价

APPROVE 这个精确 head,未发现阻断项;delivery judgment 为 justified_increment。long_horizon 与 user_experience preserved:合法继续、恢复及独立同容器 Todo 更新仍可用,保护更准确且不增加操作步骤。最后调用族退役、安装与长期资格是保留的 remaining gap,此结论不关闭 R5/T4。作者与 reviewer 共用 loopx-agent,公开记录只能是 COMMENTED,GitHub REVIEW_REQUIRED 与代码批准需要分开。维护者另行验合并条件。

English verdict: APPROVE - fda3093. The existing prose guard now uses the accepted canonical JSON identity while retaining legal source writes, clock exclusion and recovery. Current base/head regression and paired real-boundary evidence qualify this bounded repair; installed adoption and sustained retirement qualification remain open.

@huangruiteng
huangruiteng merged commit 827c97b into main Oct 6, 2026
9 checks passed
@huangruiteng
huangruiteng deleted the codex/typed-shadow-comparison branch October 6, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants