Skip to content

perf(coordination): reuse normalized Todo records without a second copy - #6371

Merged
huangruiteng merged 1 commit into
mainfrom
codex/canonical-record-copy-20261013
Oct 13, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/canonical-record-copy-20261013

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Canonical Todo reads normalize each record into an independent strict-JSON tree, validate its schema, then rebuild and deep-copy the same fields. Reuse the validated tree for ordinary records, while preserving the generic contract’s inherited-field reconstruction path. Canonical bytes, error order, container isolation and authority/provider formats stay unchanged. This follows the existing TS migration RFC’s “Validate once at every trust boundary” boundary and addresses a measured shared-codec cost in the complete history-closeout path.

Add characterization for Unicode ordering, own/inherited prototype fields, alias isolation and strict-JSON/schema rejection order. The existing 20,000-history File/SQLite module remains unchanged, including replay, feature-off and oversize cases. The related simplification removes duplicate copying within the same owner; no cache, contract vocabulary, frontend operation or provider abstraction is added.

Validation:

  • 15 codec tests pass on the legacy implementation and final implementation; typecheck passes.
  • Original full five-case history module: alternating base/head/base/head on macOS, one worker, coverage disabled only for attribution, fresh fixtures per run. Base 74.44/75.05s; final 69.22/67.15s. Medians 74.74→68.18s (~8.8% lower elapsed time). This is local source evidence, not hosted CI, p95, CPU billing or runner-capacity qualification.
  • 49 real CLI/snapshot tests pass, zero skips; 349 integration tests pass against an isolated real PostgreSQL 16.15 server, zero skips.
  • Real-path sensitivity: after committing the original 20k File fixture, deliberate codec rejection breaks public closeout lease admission; restoring the exact committed source passes the same case. Earlier text-mutation probes on listing were nondiscriminating and are not counted as this proof.
  • Semantic advisory/full-tree drift check and public-boundary scan pass. Premerge executes three direct checks and all 15 selected canary commands successfully, with zero command failures or manual holds.
  • Hold: the complete TS suite has 4536 pass / 1 fail / 37 conditional skips. The same full command on clean baseline 4e994b11 has 4533 pass / the identical fail / 37 skips: content_digest_single_owner.test.ts reports the unchanged digest matcher in stride_policy.ts:137. Required validation remains failed and CQR records a failing receipt; the premerge quality gate is held. The 349 real PostgreSQL tests separately cover the external backend.

Do not relax the original four-shard/two-worker/60-minute CI, full collection union/disjointness, coverage/JUnit or release admission criteria. This is a formal source repair proposal; installed behavior and complete hosted qualification remain separate.

中文:Todo 记录原先在严格 JSON 复制和 schema 校验后又重建、深拷贝一次;普通记录现在复用已独立持有的规范化对象,泛用契约的继承字段行为保持兼容。补齐字节顺序、容器隔离和错误顺序反例,关联原 TS RFC 的 validate-once 边界。原 20,000 条历史模块及五项语义不变,最终实现四轮交替对照的本机耗时中位数下降约 8.8%;15 项 codec、49 项真实 CLI/snapshot、349 项真实隔离 PostgreSQL、类型、语义和 15 项风险 canary 均通过。全量 TS 仍有与干净基线完全相同的 Stride 摘要规则失败,CQR 保留失败及合并 hold;不宣称完整 CI、已安装行为、容量或发布优先资格已通过。

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 | model=gpt-6.1-sol | provider=OpenAI | runtime_reported | reasoning_effort=xhigh

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

精确评审 head:a00dea30a1769f4345d61d1d256d89bece9b9e27。无阻塞本 PR 改动语义的发现;既有必需检查失败与合并 hold 单独保留。

动机

处理累计 Todo 的 CLI 用户和自动化调用者。 完成已有任务时,旧实现把每条记录复制、校验后再次重建和深拷贝;现在普通记录复用第一次拥有的独立对象,合法任务继续完成,错误输入仍拒绝。 对累计任务反复读回和完成时,这项重复工作会持续付出成本,保持原状没有对应收益。本机原 20,000 条历史五项模块四轮交替测试全部通过,耗时中位数 74.74→68.18 秒,约下降 8.8%;规范化字节、容器隔离及错误顺序保持。

本 PR 不完成已安装版本升级、完整 hosted CI、runner 容量或发布优先验收。 全量 TS 的同一既有 Stride 摘要规则失败仍在,CQR 保留失败及合并 hold;完整 hosted 资格和安装后表现尚未证明。

改动思路

在既有 TS codec 内删去重复工作,同时保留泛用继承字段兼容分支,真实调用路径已有独立正负证据,无需新增缓存或状态 owner。 当前边界是源码 codec 修复、耐久反例及原 RFC checkpoint;provider、CLI 配置、权限和用户操作步骤保持原有归属。 先用原严格 JSON owner 建立一棵独立持有容器、按 Unicode 码点排序的对象树,再保留 allowed/required 校验及原错误先后。普通 Todo 字段不再重建和第二次复制;若泛用契约实际选择了继承字段,则走原重建路径。provider IO、CAS、租约和结果重试由原 owner 处理,codec 仍无副作用,也没有新的开关或投影状态。

缩成无条件 return 虽然更短,却会丢失缺失的 __proto__ 字段以及 constructor 的严格 JSON 拒绝,因而不是等价替代。新增分支对应已执行的兼容反例。普通用户仍通过现有 CLI 操作、纠正、重开及读回,不增加确认或配置步骤;这是已有内部路径成本的修复。

具体改动

关键代码讲解

  1. canonicalCoordinationRecord:输入保持 unknown,第一次 canonicalAuthorityObject 仍执行严格 JSON 和容器复制。未知 required 声明、非版本化字段、缺失 required 字段的检查次序不变。仅当契约选择了非 own 的实际继承字段时重建;其余记录返回已拥有的规范化树。
  2. canonicalTodoDomainRecord:它是同一 helper 的真实消费者,schema、role、status/done、text、archive 语义检查未变。领域记录仍在进入调用者前拒绝非法组合,数据格式与权限保持。
  3. 三项耐久 characterization:用独立字面期望检查补充码点、own/继承原型字段、嵌套容器隔离、重入独立性和叠加无效输入的错误顺序。15 项用例先在旧实现通过,再在最终实现通过;原 20,000 条历史模块、五项语义及夹具规模未改。

规范依据是 docs/architecture/rfcs/typescript-control-plane-migration-v0.md,固定 pre-change revision 4e994b11f83103b99342a3b0e589a93d6b526f5d(原文)。逐项映射:2.5 已实现,边界仍严格解码并保留 schema 语义,随后复用解码值;2.4 已实现,没有第二规则 owner 或生产双写。新增 RFC 段落说明这个既有原则的有界应用,并未重写原验收来适配实现。共有字段、生成 schema、digest 字节及 provider 版本都没有新词汇或迁移。

对主干的风险

主要风险是别名泄漏、规范化顺序变化,以及泛用继承字段的合法旧行为被更严格地拒绝或省略。characterization 保留所有这些独立反例。原完整模块的 File/SQLite 合法完成、缺 typed result 拒绝、stale result 拒绝、精确 replay 不推进 revision、feature-off 及 oversize 拒绝均保持。真实 SQLite CLI 修正/读回、缺 Markdown 重开、provider 缺失时无旧源回退,以及 File/SQLite 大分页全量等价均已有实际执行;349 项 PostgreSQL 16.15 集成在隔离真实服务通过,零跳过。

进一步反证在真实 20,000 条 File 夹具建好后故意令 codec 拒绝合法记录,公开 closeout 的租约入口产生 Controlled codec rejection,原成功断言确实失败;恢复同一已提交源码后用例通过。前面的列表内容篡改探针未检出问题,记录保留,未作为这项敏感度证据。它们不能替代实际命中的 closeout 反证。

类型、语义漂移和公共边界检查通过;premerge 的 3 项直接检查及全部 15 项选中命令通过,零命令失败、零 manual hold。但全量 TS 在干净基线与精确 head 上同样失败于未修改的 content_digest_single_owner.test.ts:607 / stride_policy.ts:137 摘要 matcher:基线 4533 通过 / 1 失败 / 37 条条件跳过,head 4536 通过 / 同一失败 / 37 跳过。已比较完整失败身份、断言值及未改的 scanner、Stride 源码和任务清单;这是独立基线归因,不是把红检查改成绿。CQR 的必需 full-suite 行仍失败,合并继续 hold。失败恢复归属现有 Stride owner;修复后须重跑全量 TS/CQR。没有放宽时间、历史量、coverage/JUnit 或发布标准。

我的整体评价

当前 head 的有界源码修复可批准,合并 hold 保留。长期有效工作的判断为 preserved:原累计状态、后续完成和重试语义保持,但不以四轮测试声称长周期资格;用户体验判断为 improved:实际本机耗时下降,原 CLI 的必要输入、确认和恢复步骤未增加。机制与实测收益相称;未来整理的最有价值部分已在本次落实,即把重复复制从原 owner 去掉,剩余兼容分支有真实反例支持,无需扩成新抽象。

最终源码四轮数据是 74.44/75.05 秒对 69.22/67.15 秒,中位约下降 8.8%。较早无兼容补偿候选约 21% 的结果不作为最终值。余下限制是既有全量 TS/CQR 失败、正式 merge 及安装后/完整 hosted 资格;APPROVE 不授权 merge,也不关闭原完整发布验收。应由原 owner 在固定检查与权限下解除 hold,再验完整链路。

English verdict: APPROVE - a00dea30a1769f4345d61d1d256d89bece9b9e27. Ordinary records reuse the first independent canonical tree; inherited-field compatibility, rejection order and real closeout/replay remain validated. Final local median elapsed time improves ~8.8%. Independent current checks cover changed invariants; the unchanged baseline Stride digest failure and required CQR/merge hold remain explicit.

@huangruiteng
huangruiteng merged commit eeabba9 into main Oct 13, 2026
18 of 30 checks passed
@huangruiteng
huangruiteng deleted the codex/canonical-record-copy-20261013 branch October 13, 2026 11:08
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