Skip to content

fix(context): retain original numbers in delivery and recovery - #7661

Merged
loopx-agent merged 3 commits into
mainfrom
codex/context-source-number-fidelity
Oct 29, 2026
Merged

loopx-agent merged 3 commits into
mainfrom
codex/context-source-number-fidelity

Conversation

@loopx-agent

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

Copy link
Copy Markdown
Collaborator

Context delivery sent Python-origin numbers through JavaScript serialization. Cold input and full recovery could change 1.0 to 1, lose negative zero, or round large integers; warm equality could omit those changes altogether.

The existing TypeScript codec compares original-number identity and returns the existing source-edit format. Python applies those edits to original values, without a second diff or recovery policy. Full bodies, numeric literals, grouped values and reordered sources retain their origin. A damaged delta falls back to the same current capture. Direct JavaScript callers retain detached results. Historical digests, receipts, admission, settlement, source selection and native-hook policy are unchanged.

The revised transport sends additional identity only for integral floats (including signed zero) and integers outside JavaScript's safe range. Ordinary fractional doubles need no per-value path/token duplication; non-finite evidence is still rejected before RPC. This addresses the exact-head review's complete-cost regression without removing numeric fidelity.

Validation for 3435ef65854ede411ca494f73da18b168d404362, integrated with target main at 33d9ecd9fd29bce4986da6c9e9a6b758a24f91b3:

  • 127 Python source/delivery/real File/SQLite CLI tests, 163 lifecycle tests and 46 TypeScript tests passed. Fidelity covers negative zero, integral floats, unsafe integers, subnormals, floating-point boundaries, reordered/grouped values and lost-baseline recovery.
  • The same independent delta applicator reconstructs all 24 fixed numeric cases exactly. The new five-call regression measures complete request parameters plus response results against a matched safe-integer workload, allowing payload-size growth plus bounded structural headroom. Restoring the old all-float collector makes this regression fail.
  • Control-plane typecheck, Ruff, bilingual diff check, public-boundary scan and standard local premerge passed (6 direct checks, 5 catalog and 8 risk checks; no holds). Tests ran on the code subsequently committed unchanged. A test invocation naming a nonexistent file collected nothing; the corrected lifecycle command passed. No model or benchmark campaign was launched.

Matched synthetic numeric-dense workload: 1,000 ordinary fractional observations, one changed value; five codec calls comprising two full deliveries, one captured-file delta, normal recovery and missing-baseline recovery. Compact UTF-8 JSON totals, excluding RPC framing:

Revision Request parameters Response results Combined
Original baseline b201da8b 47,160 27,827 74,987
Reviewed 4bb530c0 410,041 5,793 415,834
Revised head 47,260 5,793 53,053

The revised combined component transport is 87.2% below the reviewed head and 29.2% below the original baseline for this fixture. Full and delta document sizes remain 6,313 and 1,480 bytes across those revisions; this is not a model-input or fee saving. The sparse-number synthetic fixture also retains exact source values and same-capture recovery. Earlier numeric failures and the all-float cost regression remain historical failures. Latency, complete Host/model cost and long-horizon outcome benefit are not qualified by these component tests.

This usable prerequisite remains separate from #7430 and the journal fix #7657. Bounded refactoring reuses one source-identity/edit owner for delivery and recovery; the refinement narrows the existing Python transport collector instead of adding a cache, hash codec or parallel diff policy. Canonical numeric hashes and historical-reader exit retain their own qualification. No rendered UI is changed. The designated review lane must review this new head before merge or installation.

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.

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

动机 / Motivation

使用 Python 产生 quota/Turn 上下文并跨调用复用或恢复的 Host 会遇到该问题。例如原值 1.0、负零和超出 JavaScript 安全整数范围的证据经过 codec 后可能改变,warm delta 还可能把数值差别当作未变化。当前 head 已恢复这些数字及独立 delta 重建的保真,但普通小数的额外身份元数据造成了可避免的传输回退。本切片不交付新的 hash codec、历史 receipt 迁移、原生 Host 采用或完整长程收益资格。剩余缺口是缩小数字元数据范围并补充完整请求与响应成本回归;统一上下文方案和 journal 数字修复仍各有原 owner。

改动思路 / Approach

复用现有 TS delta/source-edit owner 与 Python 原值应用器有合理边界;对每个普通小数重复发送路径和 token 则超出了保真所需。本 PR 应保留 source-edit 和必要的数字身份,只收敛会造成请求膨胀的 Python token 收集,不扩成新缓存、索引框架或第二套 diff。Python 沿用原值引用应用器;相等判断、relocation 和恢复继续由 TS 决定。完整基线与当前 capture 是事实来源,数字 token 只解决跨语言运输,不提供新的执行或保留上下文权限。借用历史审查经验检查了实际可用结果与总成本,没有继承历史 verdict,也未要求这个 prerequisite 先完成整个研究计划。

具体改动 / Changes

完整审查 4bb530c0f7b22950ba17300dacdc5a23debedf12 相对 b201da8bab305d053866aa0d4516b97ba4a4499e 的 5 文件 diff:生产 +188/-37,测试 +117/-1。

关键代码讲解

  • _source_number_tokens 在 Python 原值上收集路径与数字字面量;目前任何 float 都收集,问题位于第81–82行。
  • contextSourceIdentity 校验路径、重复项、有限数及 token 与 JS 值的一致性,把相对数字身份加入比较;原 source-edit owner 继续复用。
  • changeTree 为 literal、grouped values 和重排来源保留 lineage,解决同 JS 值却不同原数值的漏差异。
  • restoreContextDelivery 用同一身份比对 changes,损坏或缺 baseline 时仍恢复本次 current capture,不重跑 guard。

先读的规范为 docs/reference/protocols/turn-envelope-v0.md,版本 b201da8bab305d053866aa0d4516b97ba4a4499e。原文没有验收编号,以下是本次映射标签:CTX-1(保留完整源值)已由真实 File/SQLite CLI、24 个独立 delta 重建样例验证;CTX-2(同 capture 恢复且不重放 guard)由损坏/缺失恢复负例验证;CTX-3(activation、admission、结算分离)由 off/default/unsupported 入口验证。历史数值 hash codec 未在本 PR 改写。

对主干的风险

[P2] 只为确实需要保真的数字发送额外身份。 用纯合成 registry.values=[i+0.5 for i in range(1000)],只修改最后一个值,在相同五次真实 codec 调用(两次 full、一次 captured_file warm、正常和缺 baseline 恢复)中观察到:

UTF-8 JSON 字节 base head 仅测试进程收敛 collector
请求参数合计 47,268 410,149 47,368
响应结果合计 27,889 5,819 5,819
两者合计 75,157 415,968 53,187

这是参数与结果 JSON,排除 RPC framing,不是 token 或费用。普通 i+0.5 无需额外身份,当前收集方式却重复运输其路径/token,TS 比较还会逐子树筛选和排序。候选仅在测试进程收集整数型 float(含负零)及 unsafe int,拒绝非有限值,tracked 源码未改;同24个独立重建样例仍全通过。请在原 PR 收敛该收集范围,并加入五调用的合计成本回归;保留 1.0、负零、大整数、subnormal 和重排覆盖。

实际验证:PASS 83 Python、46 TS、typecheck、Ruff、标准 premerge(6 direct / 5 catalog / 8 risk,0 hold);同一独立 Python delta 应用器的24个固定样例在 base 全失败、head 全通过。off/default/unsupported 五项在 base 与 head 都通过。局部 timing 受运行条件影响,未作 latency 资格结论。

语义与 CI 对齐

本 PR 复用既有 source-edit/数字来源 owner;上述可避免成本回退与 whole-path cost 要求不符,需要同 owner 的有界修复。wait_for_ci=false,没有查询、轮询或等待 CI。

我的整体评价

数字保真修复有实际价值,源码边界也比新增第二套 diff 合理;当前可避免的合计传输回退阻止批准。long_horizon 的完整成本轴仍存在回退,数值可读回这一用户结果得到改善。已检查 context_delivery.ts、diagnostic_projection.ts 与 turn_envelope.py;本 PR 没有渲染页面、组件、布局或可见文档修改。无适用视觉变化;真实 Host 模型采用和费用收益未测试。修复后应保留原数值测试,并按同样工作量重测完整输入与输出。没有 merge 或安装动作。

English verdict: REQUEST_CHANGES at 4bb530c; numeric fidelity is verified, but avoidable all-float metadata increases matched request-plus-result JSON about 5.5x.

Comment thread loopx/control_plane/quota/turn_envelope.py Outdated
…r-fidelity-qualification

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent added a commit that referenced this pull request Oct 29, 2026
Adopt the collector and context regressions from PR #7661, commit 3435ef6. Version the changed experimental complete binding explicitly; old all-float bindings require their pinned reader. Add a complete composition/Host/recovery transport-cost regression.

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)

动机 / Motivation

使用 Python 生成 quota/Turn 上下文、跨调用复用内容或恢复原 capture 的 Host。 原值 1.0、负零及 unsafe integer 经过 JavaScript 往返可能改变,warm equality 还可能漏掉差别。新 head 保留原数字,并收窄旧修复对所有小数重复发送路径与 token 的做法。 同一独立 Python delta 重建器的 24 个固定样例从 base 全失败变为 head 全通过;相同五调用请求加响应 JSON 从 75,157 降为 53,187 字节。 本 PR 不替换历史 hash codec、receipt、准入或原生 Host 的 fallback 策略,也不交付统一上下文主线、journal 修复或模型收益资格。 实际安装态采用、完整 Host/model 成本、延迟及长程净收益仍未资格;既有 C1 主线和 journal 数字修复继续由各自 owner 承担。

改动思路 / Approach

沿用一个 TS delta/source-edit owner 和原 Python 原值应用器,并只为会失去类型或精度的数字附加身份,已解决保真与可避免传输膨胀两个问题;无须另建 diff、hash 版本或缓存。 本 PR 保留原 source-edit 格式和历史读取边界,新增的数字身份仅属于临时 RPC 输入;原生文件 caller 的保守 fallback 和 default-off 行为不变。 最强反例是:恢复器返回 current 会掩盖实际 delta 已丢失数字,或只量 response 而漏掉额外 token 的 request 膨胀。 因此本次验证直接到达实际读取/codec 边界,而不把作者通过数或元数据存在当作验收。借用当前 advisory 检查首个可用结果和完整适用成本,没有继承其历史 verdict,也未要求这个 prerequisite 先完成父级工程。

具体改动 / Changes

审查 head 3435ef6 相对 base 33d9ecd 的整个 diff,并核对真实 caller 与未改动的恢复 owner。

关键代码讲解

  • _source_number_tokens:仅数字身份 IO;所有 float→integral float/unsafe int;非有限数提前拒绝。关键约束是普通 fractional double 无逐项 token。
  • contextSourceIdentity:源值身份比较;validated relative path/token 区分 JS 归一化碰撞。关键约束是非字符串假装数字;重复/无效路径拒绝。
  • changeTree:唯一 delta/source relocation 决定;literal/grouped/original subtree 保留源 lineage。关键约束是独立 applicator 必须精确还原;不只看 restore 的 current。
  • restoreContextDelivery:验证并恢复同 capture;比对 source-aware edit identity;正常返回原 current 值。关键约束是损坏或缺 baseline 回原 full;无 guard/spend。

完整重审五个文件,生产 +195/-37、测试 +177/-1。相对旧评审 4bb530c0f7b22950ba17300dacdc5a23debedf12,生产只收敛 collector 并提前拒绝非有限数;原 TS source-identity/edit 机制未扩成另一套 diff。Python 用原值机械应用 TS edits;数字 token 仅解决语言运输的类型/精度差别,不是新的历史 hash、执行资格或持久状态。

同一 frozen 独立 Python applicator 直接应用 emitted delta,避免 restore 从 current 返回完整值而掩盖错误。24 个相同固定样例:base 0/24,head 24/24,覆盖负零、1.0、unsafe integer、subnormal、浮点边界、重排、grouped literal、完整输入和丢 baseline。正常与 fallback 均精确保留当前源值,输入不变。normalized-equivalent 数字的损坏变化树不能通过验证。

相同 fractional workload、一个变更值、五次真实 codec 调用,计算 request 参数与 response 结果两侧的紧凑 UTF-8 JSON:

修订 Request Result 合计字节
当前不可变 base 47,268 27,889 75,157
旧实审 4bb 410,149 5,819 415,968
当前 3435 head 47,368 5,819 53,187

旧 4bb 数据是同一冻结 fixture/脚本的实际记录;本次对 source/callers 做了失效核对,并在当前 base/head 重测。当前结果比 base 少约 29.2%,比旧修复少约 87.2%;排除 RPC framing,不是 token、费用或 latency 节省。旧成本失败和首次数字失败保留,没有改写成历史通过。

先读 docs/reference/required-work-context.md,版本 33d9ecd 的完整源值、current controls、重排和同 capture 恢复条款;同时检查 TurnEnvelope 原 capture/权限边界。原文无编号,本评审定位标签 NUM-1 为原值完整性,NUM-2 为完整 current 重建与同 capture fallback,NUM-3 为 presentation 不重准入/结算。三者由实际 codec、File/SQLite 和独立反例覆盖;没有将未来统一架构当作本切片门禁。

对主干的风险

未发现 blocking finding;旧 inline 4411975871 的 all-float 成本问题已由当前源及完整五调用对照验证解决。 它的历史正文保留,讨论收口与实际 GitHub 资格另行读回。非有限数在 RPC 前拒绝;token 的缺失/重复/畸形路径及错误数值由 TS 校验。直接 JS caller 仍取得 detached 结果,普通 default/off 不新增 token 或 native 设置。原生 saved-file caller 的 unsafe-number/changed-integral-float 保守 fallback 仍在 codex_context.py,本 PR 没有扩大其 activation 或重写历史摘要。

PASS 114 个 Python source/delivery/progressive/真实 File/SQLite 及共享投影检查、46 个 TS 检查、control-plane typecheck、Ruff、标准 premerge 6 direct / 5 catalog / 8 risk,无 hold。canonical Todo/provider revision、源文件、原 receipt/spend 与只读路径由实际 CLI 检查;损坏恢复使用同一 capture,没有业务重放。新完整成本测试同时计入 request/result,并以相同合法工作量作对照。wait_for_ci=false,没有查询、轮询或等待 CI。

必要数字身份仍会增加某些输入成本,当前合成结果不是所有数据分布的普遍收益;没有进行完整 Host/model/人工成本或延迟资格。旧 hash codec 的数值碰撞、安装态、journal 和 C1 整体交付仍各有边界,不能用本 PR 的通过结清。

我的整体评价

该切片已通过实际入口交付可独立使用、评审和回退的增量;相应 long_horizon 成本/保真轴和当前读取体验得到改善,但不是父级研究成果的完成证明。沿用一个 TS delta/source-edit owner 和原 Python 原值应用器,并只为会失去类型或精度的数字附加身份,已解决保真与可避免传输膨胀两个问题;无须另建 diff、hash 版本或缓存。 本 PR 保留原 source-edit 格式和历史读取边界,新增的数字身份仅属于临时 RPC 输入;原生文件 caller 的保守 fallback 和 default-off 行为不变。 已检查 loopx/control_plane/quota/turn_envelope.py、loopx/control_plane/quota/context_delivery.ts、loopx/control_plane/quota/diagnostic_projection.ts;本 PR 没有页面、组件、布局或首屏呈现修改,CLI/文档正文变化由实际读取及错误路径检查。 实际安装态的人机阅读、模型理解和长期使用未验证。 保留原权限和真实停止条件,后续采用与完整成本由已有 owner 继续资格。批准本次精确 head,不构成 merge 或安装动作。

English verdict: APPROVE at 3435ef6; the bounded caller outcome and current negative paths are verified, with model adoption and complete long-horizon benefit unqualified.

@loopx-agent
loopx-agent merged commit 7cdf887 into main Oct 29, 2026
29 of 39 checks passed
@loopx-agent
loopx-agent deleted the codex/context-source-number-fidelity branch October 29, 2026 15:31
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