Repository navigation
fix(context): reuse exact relocated structured evidence - #7467
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
7be2f56 to
e3323b9
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=max
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
启用差分上下文的 Codex 调用方在任务绑定或来源重排后,需要继续读取此前已读过的结构化证据。
相同记录移动到新路径时,旧实现只能逐字段编码或重发内容;新实现可引用不可变基线中的完整对象或数组,同时保留本轮控制字段。
同一组合成输入的完整重建及关闭态输出均通过对照,48 组 delta 总量从 1,053,456 降到 138,568 字节。
本 PR 不证明模型记忆、计费、端到端延迟或任务效果收益,也不交付安装或新增设置。
本次审阅完整 base 59c8bbf791bca9d3d1dd996629a1610c0679b23e 到 head e3323b9e1ce420051f8e46a5139cf10fbe1f97f0,没有继承作者的测试或旧 head 的 approval。判断对象是该可复现的小范围缺口,母目标的自然采用与效果验收继续保留。
改动思路 / Approach
完整子树引用留在现有 TypeScript codec;索引只筛选候选,精确比较和完整摘要继续决定能否使用,当前控制字段优先按原值发送。
本次边界是启用态结构化证据复用及同 capture 恢复;保留既有设置、生命周期和权限 owner。
不改动会继续重发已读结构;仅缩短单个字符串路径不能消除重复的容器包装。扩展已有 from 比新增 codec、配置或持久化索引更小。
引用继续使用 context_delivery_v1,但旧 string-only reader 不理解新值时必须恢复 full。我实际运行了该混合 reader 路径;没有把 reader 可用或摘要存在当成模型保留证据。新增的精确匹配仍可能增加本地计算,作者披露了这一成本,未把传输体积收益写成总成本收益。
具体改动 / Changes
changeTree:比较完整引用、递归修改与完整替换,强制当前字段先于复用。applyTree:只从不可变基线取完整值,并复制出独立返回对象。prepareContextDelivery:校验基线完整性、作用域与大小收益,选择 full 或 delta。restoreContextDelivery:重算预期补丁并验证当前完整摘要,错误时恢复同 capture。
先读取变更前接受合同 docs/reference/required-work-context.md,完整规范 revision 为 59c8bbf791bca9d3d1dd996629a1610c0679b23e。原段落没有独立编号,以下仅作为本次对应索引:
NR-EXACT:精确的不可变输入复用不得改变当前完整来源;由上述实际 caller 及 base/head、off、恢复对照验证。NR-CONTROLS:当前及未知控制始终保留当前字面值;由上述实际 caller 及 base/head、off、恢复对照验证。NR-RECOVERY:缺失、损坏或不兼容基线恢复同一完整 capture;由上述实际 caller 及 base/head、off、恢复对照验证。NR-OFF:默认关闭,cold/full 与权限、准入、结算保持原边界;由上述实际 caller 及 base/head、off、恢复对照验证。
正向路径:48 组重排/裁剪/Unicode/原型键数据,通过真实 TurnEnvelope operation 重建当前输入;8 项原生 exec/app-server 边界验证实际输入和 compaction 恢复。 负向路径:损坏 from、错误 session、改变 epoch、无完整 retained 基线及旧 string-only reader 都恢复同一完整当前输入;返回值修改不污染两份捕获。 两条路径都落到实际 codec operation、CLI 或原生 host 返回,没有让 mock 提供待证明的 postcondition。
对主干的风险 / Risks
主要风险是错误引用掩盖当前控制、共享可变对象或旧 reader 误收新补丁;当前反例均回到原始完整 capture。新增匹配仍有计算成本,未证明净延迟收益。
- PASS:context/Turn/lifecycle TypeScript 71 项;context CLI/capture/saved-project Python 99 项通过、5 项显式可选 native 用例跳过;另行启用真实 native binary 的边界选择 8 项通过。
- PASS:48 组相同输入的当前值、cold/full 输出、强制控制、对象脱离引用和旧 reader 恢复对照。完整子树收益 oracle 在基线 0/48 失败,在 head 48/48 通过。对象键的序列化顺序有变化,完整值、数组顺序和控制字段无变化;没有把这个差异藏进字节相等声明。
- PASS:Ruff、配置 mypy、TypeScript typecheck、diff/public 扫描、维护性 ratchet 与 diff semantic advisory。advisory 的空候选不是全语义覆盖证明。
- FAIL(既有、与此 diff 无关):完整
npm run -s test:control-plane在 base 为 5546 pass / 1 fail / 75 skip,head 为 5547 pass / 1 fail / 75 skip。唯一失败均为protocol_action_packet_compat.test.ts的release missing_packet:quota 投影含contract_capsule.execution_obligation.schema_version=execution_obligation_v0,冻结 envelope 没有该字段。fixture、测试、签名 owner 的源码及独立取得的完整实际/预期对象均一致,该失败的调用分支不调用所改 codec。 - PASS:标准 premerge 的 5 项 direct 和 17 项选中检查均实际通过;整体 gate 仍因下述严格质量回执失败而不通过。
- HOLD:必需的完整检查保持失败,严格质量回执
cqr_520bd730ccec0d63a348记录 fail;不会把基线归因当成该门禁通过。代码结论与合并资格分开。
没有查询、轮询或等待远端 CI。原生验证使用 Codex 0.163.0-alpha.11.1 与隔离的确定性本地 provider;公开说明只包含合成场景和聚合结果,未发布原始运行记录。既有设置开关、无效来源恢复和明确关闭路径继续可用,不新增人工确认轮次。
我的整体评价 / Verdict
本次结构化复用的局部结果成立,未发现需阻塞此 diff 的代码问题。既有完整套件失败有不可变 base/head 同命令及完整差异对照,按当前 review policy 保留 APPROVE;严格质量资格仍 HOLD,不能据此合并。
完整子树引用留在现有 TypeScript codec;索引只筛选候选,精确比较和完整摘要继续决定能否使用,当前控制字段优先按原值发送。 本次边界是启用态结构化证据复用及同 capture 恢复;保留既有设置、生命周期和权限 owner。
视觉审阅:已检查 loopx/control_plane/quota/context_delivery.ts 及既有 machine-configuration-settings.tsx;本次没有渲染页面或交互文案变化。 未验证范围:未新增 live App 安装、真实模型采用或跨平台实机资格。 历史经验建议用于追踪真实恢复结果,没有将 context delivery 声称为已验证的 memory utility。
English verdict: APPROVE e3323b9 — exact structured reuse and recovery verified; unchanged baseline signature-test failure remains a strict quality/merge hold.
Goal And Delivered Outcome
Task binding and source reordering can move already-read structured evidence to a different path. The optional context codec could reuse individual strings, but resent records as literals or many long references. A public 48-record fixture falls back to a 17,889-byte full packet on the baseline; this change produces a 7,071-byte delta and reconstructs the exact current input. These are transport bytes, not model fees or outcome gains.
Extend the existing
fromoperation to exact arrays and objects. Current controls, including forced descendants of otherwise reusable containers, remain literal. The producer compares reference, recursive edit and full replacement sizes; size/hash indices never replace exact equality. Lazy size buckets avoid eagerly hashing every baseline subtree. Restored values are detached from both immutable captures.Intended base:
loopx-project/loopx:main. This is separate from #7457's same-response composition and #7430's complete-decision migration.Author Declaration
docs/reference/required-work-context.md, “Opt-in native reuse,” at59c8bbf79; this PR proposes the bounded structured-reference extension within its existing eligibility and recovery rules.context_delivery.ts; reconstruction, source reorder, detached ownership, fresh-descendant and unknown-control testsScope And Continuation
Complete within this codec scope and reversible by reverting this commit. Existing settings/benchmark entrypoints remain unchanged; no new configuration, capability, admission, authority-store rule or execution grant.
The
context_delivery_v1operation vocabulary is retained, withfromextended beyond strings. An older string-only reader recovers the exact current full capture instead of accepting an unsupported patch. Current invalidation, capture digest and settlement bindings remain intact. No installation or active experiment upgrade is included.Validation
e3323b9e1ce420051f8e46a5139cf10fbe1f97f0, rebased on59c8bbf79. Premerge and TypeScript suites passed at this head. The 79-test CLI and 12-test native selections ran at7be2f565; all product code and the four authored files are byte-identical after this rebase. The only added upstream change is an unrelated registry test.0.163.0-alpha.11.1loopback selection: 12 passed, including relocated structured references, exact model-input bytes, compaction/failure recovery, code mode and benchmark cross-wake resume. Deterministic local inference; no paid model or benchmark job.off/inlinewrongly require absent evidence routes. #7461 addresses that separate test defect. Its exact test-only head66da4926was temporarily composed with this head: 8 passed, then the original file was restored. That external change is not included here.Coverage limits: not all native opt-in cases, full CI, provider billing or autonomous-model effectiveness are qualified. Controlled codec timings exposed added local matching work; lazy indexing reduces it, but prepare/restore remains slower than the original string-only codec. No end-to-end latency or net-cost claim. Private replay supports exactness and transport diagnosis only.
Additional immutable-capture replay at this unchanged head: another actual warm call shrinks from 163,155 to 148,581 codec bytes (8.93%). Six other warm calls have identical change trees and each adds 17 bytes from the extended reader instruction. Structured relocation reuse is selective; these checks establish neither universal packet savings nor complete-request or fee savings.
Current CI readback: real PostgreSQL integration, DCO, dependency review and the pages build passed. The Release Artifacts browser check failed in the unchanged
typed-actionsscenario: drawer header height 71px versus the required 84px, with top padding 12px versus 18px. Baseline browser reproduction is still pending; this remains a failed check and is not covered by the focused codec validation above.Bounded refactoring: applied within the existing codec, reusing its size cache and equality owner; no new serializer, module or persisted contract.
Frontend / Visual Evidence
UI impact: none. Internal presentation and protocol documentation only; the existing one-switch journey is unchanged. Screenshots/preview: N/A.
Type of Change / LoopX Area
Shared-authority fixture impact: N/A; no provider implementation, authority routing or promotion changes.
Boundary Checklist