Skip to content

fix(quota): preserve original facts in context sharing - #7643

Merged
loopx-agent merged 1 commit into
mainfrom
codex/context-projection-lossless
Oct 29, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/context-projection-lossless

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Context sharing without diagnostic caps returned the entire TypeScript-decoded payload. That changed original facts such as 1.0, negative zero and adjacent large integers, including through the existing explicit-detail CLI path. Both reference sharing and diagnostic caps now return the existing edit plan, which Python applies to its original facts. TypeScript keeps ownership of reference decisions; this introduces no additional call or reader.

The regression tests cover original numeric spelling, nested facts, source immutability, repeat application, existing reference recovery and omission of untouched material from the transport response. Captured readback uses the existing source_decision_hash supplied by the signature owner and explicitly rejects a mutated capture; the runtime hash codec is unchanged.

On identical frozen synthetic inputs, with byte-identical requests and one call per case:

Untouched supporting material Owner response before Owner response after
8,000 bytes 31,853 bytes 388 bytes
64,000 bytes 87,853 bytes 388 bytes
256,000 bytes 279,853 bytes 388 bytes

The diagnostic control remains 7,659 bytes before/after. This measures local owner transport payloads. Model-visible content is retained; its nine-byte increase in the reference-only cases preserves the original numeric spelling. These measurements do not establish model-token savings or complete-cost improvement.

Validation on the final blobs in 0212a1f2ebb8f60649a7df3bab957501976e78a7:

  • Python: 176 passed, including existing isolated real File/SQLite CLI admission and staged captured-read paths. The added reproduction has 9 failures / 7 passes on the unchanged base, then passes after the repair.
  • TypeScript: 74 passed; control-plane typecheck and Ruff passed.
  • Configured mypy: 17 files passed. An extra check of the CLI projection file reproduces the same three pre-existing typing errors on base and head.
  • Standard premerge passed: four direct checks, changed-Python compilation, five catalog canaries and eight risk-profile smokes. Public-safe scan: all three candidate files, zero hits or unscanned files.
  • Diff-scoped semantic advisory found no supported new vocabulary carriers. No new production state/protocol vocabulary is introduced.

This is an independently reviewable source-preservation repair ahead of #7430. C1's acceptance-reference equality/composition gap and its original outcome/full-cost qualification remain open; #7633's numerical counterexamples remain relevant. No installed-client or model-run qualification is claimed.

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; reasoning_effort=max.

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

未发现当前 exact head 的阻塞问题。以下结论来自独立源码、冻结反例与本地验证;作者报告不作为通过依据。

动机 / Motivation

执行 quota should-run 并同时展开 Agent、User Todo 的 Agent,需要收到未经数值改写的原始事实。旧的纯上下文共享分支会把原始 compute: 1.0 变成整数 1;修复后仍共享重复正文,但从原输入应用字段编辑,保留数值类型、精度与符号。同一冻结 fixture 在 base 的两条真实 CLI 路径都触发数值断言失败,在当前 head 的 File、SQLite 路径都保留 float 1.0,任务选择和源状态不变。本 PR 只修复 reference_context 入口的原值保真;不解决 C1 验收引用或 #7627 文件差分数值缺口,不证明模型理解、长期净收益、安装推广或合并资格。剩余缺口:C1 验收引用与其他上下文差分路径仍须各自验收,不能由本修复的通过推断完成。

改动思路 / Approach

应复用已有 TypeScript 编辑计划和 Python 原值应用器:返回结构化变化即可修复数值保真,无需增加 reader、协议或权威来源。当前边界是纯 reference_context 分支统一使用既有编辑计划;原有诊断裁剪、完整详情、Turn 签名和恢复 owner 均保留。这里的正确性要求是保留完整事实及唯一决策owner,不能用传输尺寸下降替代语义证明。现有一次CLI调用已具备所需意图与权限,本修复不增加用户准备、导航、确认或重复配置。

Python继续保管原始JSON值,TypeScript仍决定哪些路径共享或裁剪。只是取消纯共享分支返回整份JS值的特殊处理,复用诊断分支已经使用的edit plan,回滚边界明确。

具体改动 / Changes

完整审查 head 0212a1f2ebb8f60649a7df3bab957501976e78a7,实际 merge base 5d7f0a61b0b79876801c05e1d26352687f270794。3文件+56/-6,其中生产+4/-3,测试+52/-3。 没有生成日志、private evidence、lockfile或新持久化权威。

关键代码讲解

_reference_context:Previously returned whole JS-normalized payload when diagnostics absent; now applies existing changes to Python source. No-source/all-details gate preserves old skip; source values remain exact.

evaluateTurnEnvelope:reference_context always returns source path edits, including diagnostics=None. Reference and optional diagnostic work precede one edit-plan return.

_apply_context_projection_changes:No rule added; same plan/paths restore original numbers and nested facts. Each move reads original source and independently copies it, never JS-normalized object.

规格依据为改动前 docs/reference/required-work-context.md,固定 revision 5d7f0a61b0b79876801c05e1d26352687f270794。新增RFC说明按披露审查,不能反过来作为自身正确性证明。适用判据如下:

  • without round-tripping the original JSON values through JavaScript.:implemented;The adapter edits paths selected by the typed owner without round-tripping the original JSON values through JavaScript. 验证:Frozen five-number/three-path oracle and File/SQLite actual CLI; base fails and head passes.
  • Context delivery off remains unchanged.:implemented;Context delivery off remains unchanged. 验证:Paired default/all+vision/agent-only/user-only real SQLite CLI; original control branches preserved.
  • Unknown outcome fields:implemented;Unknown outcome fields, unknown source read obligations, unsupported schemas, signed envelopes and unavailable planning retain their original full content. 验证:Unknown nested numbers, unchanged optional settlement attachment and invalid-reference rejection; 153 Python/44 TS.

对主干的风险 / Risks

本修复只把纯 reference_context 分支换成已有路径编辑计划,不新增调用、reader或持久化结构。原有无source/完整详情skip、诊断裁剪、非法引用拒绝、同一capture恢复及Turn签名仍在既有owner;完整literal指导文字没有删减。五种数值不是先归一化再断言,故能区分int/float、负零与大整数。

独立冻结探针 SHA-256 4375271acc25eb5a76eef2a41f9e01dc003b657a1800909c9952a1ee1b568d66:五种数值(1.0、-0.0、9007199254740993、更大整数、非整数小数)在 quota、未知嵌套字段和 settlement attachment 三条路径均保留原始 JSON 表示、源输入和幂等结果。base 在首个 1.0 就失败;真实 File、SQLite quota should-run --include-detail agent-todos --include-detail user-todos 在 base 都返回整数,当前 head 都保留 float,count/selected/source不变。

四组 SQLite 实际 CLI 控制(默认、all+vision、只展开Agent、只展开User)base/head 均通过,整包在明确排除 fixture私有路径、随机store实例、观察时间/事件ID及路径绑定basis后相同;basis的两个未改动owner也逐字比较一致。数值、建议、命令参数、原文和义务未被归一化。比较器初版误以为provider revision是sha256,随后又把不同fixture路径生成的basis当产品差异;两次均属私有比较器问题,未改产品断言或挑选绿色用例。

153 Python passed;44 TypeScript passed;完整 TS typecheck、changed Python Ruff、standard premerge(5项 catalog、8项 risk smoke 及 direct checks)全部通过。 未查询、轮询或等待GitHub CI。公开复跑可在exact checkout根目录运行本PR修改的测试模块,以及 uv run --extra test loopx canary premerge --from-git-diff --git-diff-base 5d7f0a61b0b79876801c05e1d26352687f270794;private探针只使用隔离合成fixture,不依赖私有Goal或作者运行产物。

语义与 CI 对齐

复用现有typed vocabulary;没有新增source schema、安装开关或权限推导。引用仍只共享完全一致的原文,非法owner/悬空/链式引用按原规则拒绝,机器义务与指导文字保持各自语义。 默认关闭/未启用功能不因文件或能力可用而自动启用。局部读取与fixture恢复通过,不能证明模型已经阅读、保留或按指令完成实际长期工作。

我的整体评价 / Verdict

APPROVE。应复用已有 TypeScript 编辑计划和 Python 原值应用器:返回结构化变化即可修复数值保真,无需增加 reader、协议或权威来源。当前边界是纯 reference_context 分支统一使用既有编辑计划;原有诊断裁剪、完整详情、Turn 签名和恢复 owner 均保留。这是有真实调用者、独立反例及回滚边界的完整局部修复;总体迁移、C1/C2或长期收益保持未验收。bounded refactor已体现在复用原owner并删除特殊回传/字段裁剪思路,不需要另建抽象或迁移无关调用者。

可视审查 not_applicable:已检查真实 quota CLI 与既有机器配置/上下文设置消费路径;本 diff 未修改 rendered UI、布局或组件,不要求新增画面。 未验证范围:没有 rendered presentation 变化;模型理解、长期收益和安装后行为未验证。 没有新增用户操作轮次。published review、native closeout、merge readiness与实际merge授权仍是独立门,本评审不授权合并、安装或推广。

English verdict: APPROVE — 0212a1f2ebb8f60649a7df3bab957501976e78a7 preserves original numeric JSON values in reference-only context sharing; real File/SQLite regressions and 153 Python/44 TS tests pass.

@loopx-agent

Copy link
Copy Markdown
Collaborator Author

Merge validation for 0212a1f2ebb8f60649a7df3bab957501976e78a7:

  • Re-ran the standard source-checkout premerge gate against fetched origin/main (2a2323756089aaaa8f414f6dc84a30fb6ed00556). All direct checks, 5 catalog canaries and 8 risk-profile smokes passed; no manual holds. The committed bilingual RFC check also passed.
  • Changed surfaces are the existing quota context-reference projection and its focused Python regression tests. The published exact-head independent approval covers numeric preservation through the real File and SQLite CLI paths, repeated application, source immutability and rejection of modified captured source.
  • The worktree remains clean at the reviewed head. The current merge-readiness check returned ready=true, with a valid author-owned COMMENTED approval, no unresolved review threads, and wait_for_ci=false; CI was not consulted.
  • This delivers the source-value preservation repair. It does not establish installed-host adoption, model comprehension or end-to-end cost savings. Progressive file delivery remains a separate change.

Merging within the maintainer-authorized context-efficiency delivery batch.

@loopx-agent
loopx-agent merged commit bcb1a87 into main Oct 29, 2026
12 of 34 checks passed
@loopx-agent
loopx-agent deleted the codex/context-projection-lossless branch October 29, 2026 08:16
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.

1 participant