Skip to content

[PR] fix(codex): reconcile opaque native compaction checkpoints once - #4931

Closed
ReineLan wants to merge 6 commits into
ranxianglei:masterfrom
ReineLan:2026-10-27_codex-native-checkpoint
Closed

ReineLan wants to merge 6 commits into
ranxianglei:masterfrom
ReineLan:2026-10-27_codex-native-checkpoint

Conversation

@ReineLan

Copy link
Copy Markdown
Contributor

(ai: openai/gpt-6)

Opaque native compaction can replace history without the legacy text prefix and leave a small-coverage ACP fold epoch pending. Recognize the native carrier, persist its SHA-256 identity and use existing boundary reconciliation when old coverage is missing or empty. Fully intact folds, repeated checkpoint echoes and later folds after cold loading are preserved.

Fixes #4929. No decryption or native-fallback disablement. The checkpoint is still forwarded as supplied; non-Codex clients, bili-generated carriers and malformed inputs are controls. No kernel/configuration/version change.

Validation on head c002f30, synchronized with e4cc685: typecheck, build and 13 targeted native-compaction/epoch/persistence cases pass, zero skips. The focused unrepaired case fails. This is independent of the multipart and budget changes. Genuine provider opaque-checkpoint acceptance, full CI and production recovery remain unverified.

@ranxianglei ranxianglei changed the title fix(codex): reconcile opaque native compaction checkpoints once [PR] fix(codex): reconcile opaque native compaction checkpoints once Oct 27, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复。 检索 open+closed issues/PRs(同机制:native compaction checkpoint / fold epoch):#4929 是本 PR 的源 issue(同作者、同机制,本 PR 即其修复);其余在途条目均为不同机制——#4928(preflight 多轮收敛)、#4932/#4933(图像 preflight 预算 / 零折叠校准拟合;同作者但不同失败域)、#4260/#4261(快照保留)、#4486/#4487(异步摘要目标校验)——互补关系,与本 diff 无重叠。

标签:bug + codex + scope/wiring + p1(codex 车道请求管道的缺陷修复;触发条件下压缩核心承诺永久停摆 → p1)。

审查范围:PR head c002f30ee(已同步 master e4cc68575),3 文件 +153/-6:src/codex-compact.ts(+13,新增 nativeCompactionKey)、src/server/prepare-responses.ts(+23/-1,projection 后的 checkpoint 识别块)、tests/codex-local-compaction.test.ts(+121,4 个新测试)。

八问:

  1. 是什么问题:Codex 做原生(不透明)压缩时,用携带 encrypted_content 的 compaction item 替换历史。bili 只认旧文本模板载体 + ≥8 缺失 ID 启发式,小覆盖折叠永远等不到 rebase;总丢失漂移随即锁上 epoch 确认(Snapshot as session reconstruction: identity claim order takes priority, message hash demoted to reference signal (root- | 快照即会话重构:身份认领顺序优先,消息哈希降级为参考信号(根治 #3588/#3640 一类误判) #3641),挂起新折叠、暂停 preflight——会话卡死直至窗口溢出。
  2. 什么原因导致的:边界识别面没有不透明原生 item 的载体——检测依赖一种该形态下不存在的文本模板,外加小折叠够不到的最小缺失阈值。缺的是识别,不是重置机制(mark/reconcile/rebase 原语早已存在且对其他载体有效)。
  3. 影响范围与严重程度:Codex 会话在持有小覆盖活跃折叠(丢失 <8 个覆盖 ID)时发生原生压缩:压缩静默停摆(折叠挂起、preflight 暂停)且无法自愈(被替换的 ID 永不回归 → 锁自持)→ 会话最终死于窗口溢出。此前可用;触发条件窄但后果重 → p1。
  4. 怎么修复的:识别不透明载体本身——取最后一个非 bili compaction item 的 encrypted_content 的 sha256(不解码),作为会话元数据身份按 checkpoint 一次性持久化;新 checkpoint 出现且折叠覆盖已丢失(或无活跃折叠)时驱动既有 mark+reconcile rebase;覆盖完好则只记录身份。复用 [bug] Codex local auto-compaction can destroy existing bili fold substrate instead of rebasing #2372/[bug] DSH 桌面端 0.1.188:宿主原生压缩落地摧毁折叠基底 → 同一区间永久不可锚定、compress 连片失败并熔断(compaction-basic auto:false 仍无效) #2432/[Bug][Pi/Responses] plugin-announced native compaction boundary is never archived/consumed (v0.1.197) #3477 的同一套 rebase 原语,无新状态机。
  5. 是否有回归问题:触碰路径的既有行为逐项审过——非 Codex 客户端(isCodexHost 门控,不变,有测试);bili 自铸载体(isBiliCompactionItem 跳过,不变,有测试);畸形/空 encrypted_content(跳过,有测试);compaction_trigger 请求(门控排除,forge 路径不变);覆盖完好的 checkpoint(只记身份不动状态,有测试);旧文本启发式本地压缩路径(不变;同输入同判据 + 顺序保证无双重重置:rebase 后无活跃块供旧门槛命中);relay 终态标记(pass 模式观察到 trigger 完成时)——若已触发,顶层 reconcile 先消费,新块多做一次幂等冗余重置(无害:终态相同、ref floor 稳定、多一行日志);wire 保真(checkpoint item 逐字节转发,对上游 mock 断言);持久化(metadata key 经 SessionStore 往返,冷加载回显不二次 rebase,有测试)。无 fail-fast→吞错、无其他阈值/时序漂移。一处有意扩展见下方披露。
  6. 是否破坏缓存:缓存策略零变化。rebase 的 ref 重铸与既有 rebase 路径完全一致(一次性前缀失效,且只发生在原先永久漂移的场景);checkpoint 回显不动 ref map(测试 deepEqual)。
  7. 是否改了设计方向:否。responses 车道宿主侧增量识别;kernel/config/version 未动(kernel-guard、version-guard、config-surface-guard 全绿)。刻意限定 isCodexHost(证据许可清单纪律,KDD 9)——其他客户端若发 compaction item 仍走通用漂移机制。
  8. 是否引入了新的配置:无。新增持久化元数据字段 session.metadata.codexNativeCompactionKey(内部字段,无用户面)。

行为变更披露(旧→新):

  • 目标修复:新不透明 checkpoint + 折叠覆盖丢失 → 现在会 ACP rebase(原先:什么都不做——即本 bug)。
  • 次级扩展:新不透明 checkpoint + 零活跃折叠也会 rebase(covered.size === 0 分支;原先除 relay 终态标记已处理的情形外什么都不做)。理由:压缩后的 payload 谱系本就使压缩前的 usage/calibration 基线失效;代价有界(一次性 ref 重铸 + 重新校准,无活跃折叠故无数据丢失),频率受 codex 自身压缩节奏约束。

验证证据(独立复核,非转述作者):

  • 本地定向跑测试文件:9/9 通过、0 skip(含 4 个新测试)。
  • 负向对照:仅把 src/server/prepare-responses.ts 还原到 master,主新测试即在 “native replacement consumes the stale fold epoch” 断言失败——测试有牙,真实复现 [Codex] Opaque native checkpoints can leave an ACP fold epoch pending #4929。
  • 本地 typecheck 干净;本地 build 通过。
  • head c002f30ee 远程 CI:51 项检查全绿/跳过(test 分片 ubuntu/windows × node 22/24 全 success;static-gates、kernel-guard、version-guard、config-surface-guard、lock-sync 均 success;gated e2e 车道按文件触发规则跳过——常规)。
  • wire 形状佐证:{type:"compaction", encrypted_content} 与 bili 自己在 buildTriggerForgeBody(src/codex-compact.ts:257-261)铸造、codex 接受的契约同形——合成传输假设锚定在已被接受的既有契约上。

残留项(如实列出,不阻塞):真 provider 对真实 OpenAI 不透明 checkpoint 的接受度未验证(合成传输,作者已披露);与 D 车道快照渲染的交互未测(rebase 清块后快照渲染按设计优雅降级,KDD 13);pass 模式观察到 trigger 时的冗余双重置未单测但可证幂等。

质量门槛(外部提交从严):命名/注释/风格/测试均达仓库标准,无需对齐重构;diff 干净(3 文件全部切题,分支已同步 master)。

结论:可合入。方向对准根因(在决策点补识别,非症状遮蔽),回归面已审计且有测试钉住,CI 全绿,测试经负向对照证明有牙。剩人类动作一步:merge。

@ranxianglei ranxianglei added bug Something isn't working codex p1 scope/wiring labels Oct 27, 2026
@ranxianglei ranxianglei added the duplicate This issue or pull request already exists label Oct 29, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Merge-guard sync (round 7): master advanced to 44067a5bc (#5188 sidecar-recovery/fork-snapshot fixes, 12 commits) — merged into the branch with a clean auto-merge (6 files: persist/plugin/shadow + 3 fork-sidecar tests; zero overlap with this PR's files), pushed as 554e39e1e. Local validation on the merged head: targeted suite tests/codex-local-compaction.test.ts 9/9 pass, typecheck exit 0. State after push: open, mergeable_state=blocked (fresh CI run + human review pending), 0 commits behind master. Note: ci-fixes carries one extra test-pinning commit for the #5140 flake family not yet in master; I'll fold it in only if a shard hits that signature again.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Merge-guard sync (round 8): stale trigger — master still at 44067a5bc, branch already 0 behind (head 554e39e1e from the previous sync). No push. CI on 554e39e1e: 0 failed of 30, 14 still queued/running (test shards, static-gates, mysql-contract); state open, mergeable_state=blocked awaiting CI + human review. Will act immediately if master advances or a shard fails.

@ranxianglei

Copy link
Copy Markdown
Owner

Landed via batch PR #6464 (merged) — closing as superseded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codex duplicate This issue or pull request already exists p1 scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Codex] Opaque native checkpoints can leave an ACP fold epoch pending

2 participants