Skip to content

fix(context): preserve complete recovery across native resume - #7414

Merged
huangruiteng merged 1 commit into
mainfrom
codex/context-recovery-resume-20261027
Oct 26, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/context-recovery-resume-20261027

Conversation

@loopx-agent

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

Copy link
Copy Markdown
Collaborator

After compaction, a complete original-capture recovery could still be followed by another full delivery on the next native process resume. Invalidation had cleared the pending read journal, so the first recovery page was missing from its replay checkpoint (including single-page recovery).

Record that first recovery read through the existing native IO adapter. The TypeScript lifecycle remains the owner of complete-byte baseline qualification; compaction still invalidates the old baseline, and incomplete, truncated or unknown replay still selects full recovery. No defaults, authority, model/provider configuration or benchmark scoring change.

Validation:

  • Regression reproduced on the base: all four intact recovery/resume cases selected full instead of delta; all four missing-page cases remained fail-closed.
  • Lifecycle/resume suites: 189 passed, covering ordinary tools and Code Mode, one/multiple recovery pages, and missing first outputs.
  • CLI/machine configuration suites: 80 passed; 5 environment-gated integration cases skipped.
  • Real native Codex 0.163.0-alpha.11.1 with isolated loopback inference: 2 passed (quota packet and TurnEnvelope), checking model-visible complete recovery across process exit/resume without a repeated full read. No paid model calls.
  • Scoped lint, whitespace, bilingual diff check and standard premerge passed. Initial semantic check lacked npm development dependencies; it passed after installation. Premerge retains its separately reported inherited architecture-ratchet advisory.

The same-source native test helper is extended instead of adding a second transport harness. Installed adoption and total token/cost savings remain unqualified; this proposal removes one demonstrated source-level cause of redundant recovery. Rebased onto current main; intervening main changes affect only workspace loading presentation.


压缩后应先完整恢复原始上下文。本次修复的是:全量已经读完,但下一次原生进程续接仍再次全量。失效操作清掉了 pending 记录,导致首个恢复页没有进入续接检查点;单页恢复也会受到影响。

补齐现有原生 IO 适配层的首个恢复页记录,继续由 TypeScript 生命周期判断完整覆盖。保留压缩失效、丢页/截断/未知历史时的全量恢复,以及既有默认行为与权限边界。验证通过不代表已经上线,也不据此宣称整体 token 或费用收益。

Prior-head CI limitations / 前一提交的 CI 限制

At the previous head 3dcb237802d097e591016a2c5fa40ea3b91cc833, DCO, dependency review, real PostgreSQL authority integration, and optional Ark/MemT contracts passed. The kernel static job failed the pinned top-level Python module budget (145 allowed,146 observed). Git tree inspection shows146 top-level Python files on both base 08e290fb5 and this head; this change adds no top-level module. This is disclosed as an inherited failure, not a pass.

Release Artifacts built the package but its installed-page browser smoke timed out in chat-recovery waiting for the “询问全局待办” button. Root cause has not been independently established; neither the browser check nor downstream skipped checks are claimed passed. These CI failures remain merge limitations.

当前提交的 DCO、依赖检查、真实 PostgreSQL 及 Ark/MemT 合约通过。静态门因顶层模块146超过预算145失败;base 与本提交均为146,本修改未增加顶层模块,保留为继承失败。发布流水线的安装页面浏览器烟测在 chat-recovery 等待按钮超时,根因尚未独立确认;失败及下游跳过项目均不算通过,仍是合并限制。

Rebased onto current main 798543b82, new head 007c3c1cc079cfe8e2051b9863a028b0add21a1f. The recovery patch is unchanged (stable patch-id matches);189 lifecycle/resume tests passed again. Prior-head CI failures above are retained as history; current-head CI is pending. 已rebase至最新main,修复补丁未变,189项定向检查再次通过;上面的CI失败保留为旧提交历史,本提交CI待核验。

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/context-recovery-resume-20261027 branch from 3dcb237 to 007c3c1 Compare October 26, 2026 17:24

@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)

Reviewed exact head: 007c3c1cc079cfe8e2051b9863a028b0add21a1f.

动机

已开启原生上下文复用的用户,在会话压缩后完整读回原始材料,再重新启动同一会话时,需要继续使用这份已恢复的完整上下文。

此前压缩会清空读取记录,恢复时的第一页没有被记入原生历史检查;即使材料已经完整读回,重启后仍再次要求全量读取。现在补记这一次读取,完整历史允许续接,丢失第一页时仍回退全量。

可观察改善是完整恢复后退出并续接原生进程,仍保留同一上下文候选与 epoch;缺页、原生输出被截断或不确定历史继续触发原始捕获的完整恢复。

该切片不扩大支持的模型、原生版本或权限,不改变默认关闭、任务准入和恢复材料的身份,也不证明实际模型记忆或长期效率。

改动思路

保留 typed lifecycle 对完整覆盖的唯一决定权;Python 只补记原生读取的内容无关 IO 事实,再沿用现有历史校验和 checkpoint,不把首个恢复页的元数据当作完整保留证明。

本 PR 的边界是压缩后原始完整捕获恢复的首次读取记录,以及同一候选经真实原生进程重启后的续接;不扩大可接受历史、配置或权限范围。

入口、IO 与决策分层沿用既有设计:来源字节/原生事实负责证明输入,typed lifecycle 负责候选资格,展示只输出当前结果和完整恢复引用。没有把安装或发现当作启用,也没有把 context 恢复当作重新准入;失败继续交给已有设置或恢复路径处理。

具体改动

实际审阅三个文件,+99/-3;生产变更只在既有历史 IO 模块,测试扩展既有物理历史矩阵和真实原生 harness。没有改 codec、开启条件、原生历史格式或权限策略。

关键代码讲解

  1. observe_native_read 在 pending 不存在时,仅对现有 recovery 的相同摘要、合法 call ID 和成功页开始同一 IO 记录;已有完整验证候选、错误摘要或非法对象不会借此刷新证明。记录只含调用身份、页摘要与读取起点,不复制完整上下文。
  2. checkpoint_native_read 仍在 typed lifecycle 确认完整覆盖后绑定原生历史。原有物理文件、范围、schema、模型、权限和输出比对没有放松,首个恢复页现在也进入这条检查链;同一 session ID 或 EOF 本身不能证明保留。
  3. test_native_compact_recovery_survives_process_resume 复用原生 harness,完成压缩后的原始捕获恢复后,再退出并续接一次进程,验证模型可见的完整字节、同一候选和 epoch 以及无需追加恢复读取。两个视图都实测,不以手填候选代替续接。

规范依据:docs/reference/required-work-context.md,spec_revision 798543b82ecbc4479531c98ad5c93274f9bd6ce9。以下描述性判据对应变更前已接受、没有编号的规范条款,不用本 PR 测试反向定义需求。

  • native-original-recovery:implemented。Knownloss uses complete recovery of the exact original captured decision, no newguard/admission. 验证:focused189;actualnative2。
  • native-full-replay:implemented。Only complete digest-bound baseline pages retained in selected qualified nativehistory may survive resume; missingfirstoutput staysfull. 验证:sameeightfixturebase4fail4pass/head8pass;189suite。
  • native-off-and-scope:implemented。Defaultoff remains ordinary; foreignscope/version/model/permission andunknownhistory cannotborrowcontinuity. 验证:off-parity-proof;189lifecycle/resume +66typedtests。

对主干的风险

最强反例是第一页只触发了 hook,实际原生或 CodeMode 父调用输出却被截断;如果此时也能增量续接,便会把缺失材料当成完整上下文。独立矩阵把单页/多页、普通/CodeMode 与首输出完整/丢失组合起来。相同八例在不可变基线上四个完整恢复场景失败、四个丢页场景通过;当前头八例全部正确:完整恢复可续接,丢失第一页仍回退 full。既有其他损坏、版本、模型、工作区及权限反例也保留。

生命周期/resume 套件189项通过;实际 Codex 0.163.0-alpha.11.1 的两个 recovery-resume 用例通过,来源为 source checkout 加本地 loopback Responses 夹具,并非自然模型或安装态 App 采用。TypeScript context/Turn 两模块66项、控制平面 typecheck 和所有改动 Python 路径 Ruff 通过;premerge 的6项直接与16项选中自动检查通过,总结果 exit0。

语义与 CI 对齐

复用现有 typed lifecycle、pending 和 checkpoint 词汇,不新增资格判断 owner。默认仍 off,启用后也只覆盖原有 Goal/Agent/session/工作区与原始 capture;错误摘要、外来范围、不受支持或不确定历史没有获得新权限。基线与两个当前头的三组公开 off/错误路径完整 stdout 和退出码相同,原始字节不变、registry/runtime 不创建。当前八例和真实进程证据覆盖本次新增分支,作者记录的旧头预算/安装态浏览器失败仍保留为历史,不能据本轮局部通过宣称已修复。依策略没有查询、轮询或等待 CI。

我的整体评价

APPROVE。 本次交付完整恢复后的真实续接这一有用切片;用已有读取注解补齐缺失的 IO 事实,比新增恢复模式、放松历史校验或让用户再跑 guard 更小。long_horizon 为 improved,依据压缩、完整恢复、退出、续接到再次使用的完整受测路径;user_experience 为 improved,用户无需重新录入材料或增加确认回合,缺失时仍有同一原始捕获可恢复。实验效率、完整费用和自然模型保留仍未证明。

检查了现有 CLI/native 配置与恢复入口;本次没有改变渲染页面、布局或可见设置表单,因此 visual_review 不适用。 未宣称安装态桌面页面、其他平台或实际模型理解的验证。

兼容性保留原始捕获与既有 native journal 义务,不新增旧请求解码器;在当前边界内继续抽象会增加维护面,未发现需要立即进一步简化的机制。以上是当前完整差异的独立结论,COMMENTED 承载作者账号下的批准意见,不是 GitHub 正式自批准、合并资格或维护者合并授权。

English verdict: APPROVE — reviewed 007c3c1cc079cfe8e2051b9863a028b0add21a1f. the first original-recovery read is now retained as IO evidence without weakening full-byte or native-replay qualification. Intact recovery survives actual native process resume; missing-first-output cases still fall back to full. Protected-runtime merge/readiness and installed-app/model limits remain separate.

@huangruiteng
huangruiteng merged commit fe2b8dc into main Oct 26, 2026
26 of 32 checks passed
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