Skip to content

[PR] feat(acp): keep pre-compaction history restorable across client-side compaction - #6217

Open
NewbieXvwu wants to merge 22 commits into
ranxianglei:masterfrom
NewbieXvwu:2026-11-11_codex-cloud-compaction-generations
Open

NewbieXvwu wants to merge 22 commits into
ranxianglei:masterfrom
NewbieXvwu:2026-11-11_codex-cloud-compaction-generations

Conversation

@NewbieXvwu

@NewbieXvwu NewbieXvwu commented Nov 11, 2026 •

Copy link
Copy Markdown

Fixes #6215 (companion: WSL043/dsh-codex-subscription#250).

Problem

A client-native or cloud compaction replaces history bili had folded, and today that history becomes unreachable: decompress refuses archived blocks, search_context only walks live state, and the retrieve tool cannot resolve the old mNNNNN refs. Long sessions lose exactly the tool output and decisions that mattered.

Change

  • History generations. At a real compaction boundary the current ACP state is closed into a read-only generation (blocks, block summaries, block originals, message refs, raw messages, frozen content-store slice) in an encrypted, fsynced sidecar <session-base>.history-generations.json, written before the small metadata index that advertises it. If the record write is lost, the index is rebuilt from the sidecar.
  • Ref / block-id continuity. The mNNNNN floor stays pinned through the reset and block ids are pinned above the archived maximum, so old ids are never re-issued onto new content.
  • Cross-generation reads. decompress (block and range), search_context and the retrieve tool resolve closed generations, read-only (no state mutation, no re-send of old history).
  • Compact navigation note. The model gets a short index of closed generations and is told to use the search/decompress/retrieve tools for detail.
  • Boundary is wire truth. src/codex-checkpoint.ts parses x-bili-codex-checkpoint* (lane accepts x-bili-plugin: dsh|codex) and dedupes by checkpoint identity, so retries/restarts cannot rebase twice. A failed archive aborts the rebase instead of destroying state.
  • Failure fallbacks. With persistence disabled the generation is kept in a bounded in-memory LRU, so ephemeral sessions still survive the reset.

Docs: docs/codex-cloud-compaction.md (+ zh-CN), architecture map rows, acp_status archive wording updated (legacy archives that predate generations still say so honestly).

Tests

  • tests/history-generations.test.ts — 7 tests: close + exact old-ref restore, consecutive generations with distinct block ids, restart from the sidecar alone, announced-boundary path, dedupe, mid-tool-call compaction, persistence-failure abort.
  • tests/codex-checkpoint-boundary.test.ts — in-process proxy + loopback SSE: header closes a generation, duplicate (id, seq) adds none, range and whole-block restores work, second checkpoint closes generation 2.
  • tests/compaction-archive.test.ts updated (restore from a generation instead of a blanket refusal).
  • 82 tests green in the affected batch; tsc --noEmit, check:unused-exports, architecture-docs and config-surface-guard clean; npm run build OK.
  • Manual real-credential e2e (tests/manual/real-cloud-compaction.e2e.mjs, gpt-6-luna): real server compaction captured, reused on the next turn, old block restored verbatim from generation 1, model answered from the compacted context, consecutive boundary handled, identical retry added no generation.

Risk

Additive: the live-state path is unchanged for sessions that never hit a boundary. The only behavior change is that archived content is now readable (read-only) instead of refused. No new config or env knobs; no kernel change.

Folded in (second commit): the response-side close and the aggregation work.

  • The boundary is now also closed on the turn that caused the compaction, from the compaction output item bili already sees (observeCodexCompactionItems + closeCodexResponseCompaction), so a conversation that ends right after compacting still keeps its history. The relay tees the SSE body only when the request carried context_management.compaction, and the post-response close is bounded by a 3 s race so a cancelled tee cannot hang a request.
  • Three channels share one ordinal (metadata.codexCloudCheckpoint.seq): the announcement header, replayed compaction input items (headerless clients), and the response item. Each closes at most one generation, and a later channel for the same checkpoint is a no-op.
  • Consecutive generations publish ONE consolidated summary (newest wins per topic, ~1.2k chars) instead of N disjoint ones.
  • bili announces the tokens it folded (x-bili-plugin-compressed) so the client does not ask the server to compact an already-smaller body on the next turn.
  • The archive-failure path now stays pendingRebase (reviewer's fix bcab9636b3), so the close retries on the next request instead of being stranded.

中文说明

修复 #6215(配套:WSL043/dsh-codex-subscription#250)。

问题:客户端自己压缩(Codex 云端压缩、DSH 客户端压缩,或未通告的历史重写)会把 bili 已经折叠的历史从线上替换掉,而这段历史目前会变得不可访问:decompress 拒绝已归档的块,search_context 只扫活动状态,retrieve 工具也解析不了旧的 mNNNNN。长会话里恰好是用户最想回看的工具输出和决策丢失了。

改动:

  • 历史代(history generation):在真正的压缩边界,把当前 ACP 状态封存成只读的一代(块、摘要、块原文、消息引用、原始消息、冻结的 content-store 切片),写进加密且 fsync 的旁路文件 <session-base>.history-generations.json;先写旁路文件,再写一个小的 metadata 索引来指向它。若会话记录写失败,索引会从旁路文件自动修复。
  • 引用/块号连续:mNNNNN 的下界在 reset 前后保持钉住,块号钉在归档最大值之上,旧 id 永远不会被新内容复用。
  • 跨代读取:decompress(整块与区间)、search_context、retrieve 工具都能解析已关闭的历史代,且严格只读(不改状态、不重发旧历史)。
  • 紧凑导航索引:模型只拿到已关闭历史代的简短索引,需要细节时再用检索工具。
  • 边界以线上事实为准:src/codex-checkpoint.ts 解析 x-bili-codex-checkpoint* 头(x-bili-plugin: dsh|codex 两条车道都接受),并按 checkpoint 身份去重,重试/重启不会二次 reset。归档失败会中止 reset,而不是把状态清掉。
  • 失败回退:关闭持久化时,这一代保存在有界内存 LRU 里,临时会话也能安全跨过 reset。

文档:新增 docs/codex-cloud-compaction.md(含中文版)、架构图条目;acp_status 的归档措辞同步更新(早于历史代的旧归档仍会如实说明不可恢复)。

测试:tests/history-generations.test.ts 7 项(关闭与旧引用精确恢复、连续多代且块号不冲突、仅凭旁路文件重启恢复、通告边界路径、去重、工具调用中途压缩、持久化失败中止);tests/codex-checkpoint-boundary.test.ts(进程内代理 + 回环 SSE:头部关闭历史代、重复 id+seq 不重复关闭、区间与整块恢复、第二个 checkpoint 关闭第 2 代);tests/compaction-archive.test.ts 更新为“从历史代恢复”而非一律拒绝。受影响批次 82 项全绿;tsc、unused-exports、architecture-docs、config-surface 均通过;npm run build 通过。真实凭据 e2e(tests/manual/real-cloud-compaction.e2e.mjs,gpt-6-luna):真实云端压缩被捕获、下一轮复用、旧块从第 1 代逐字恢复、模型基于压缩后上下文正确回答、连续两次边界、相同重试不再新增历史代。

风险:纯增量,未遇到边界的会话活动路径不变;唯一行为变化是归档内容从“拒绝”变成“只读可恢复”。没有新增配置或环境变量,没有 kernel 改动。

第二个提交(已并入本 PR):响应侧关闭与跨代聚合。

  • 在“造成压缩的那一轮响应”里,用 bili 本来就看到的 compaction 输出项关闭边界(observeCodexCompactionItems + closeCodexResponseCompaction),所以“压缩完立刻结束”的会话也能保住历史。只有请求带 context_management.compaction 时才 tee SSE body,响应后的关闭最多等 3 秒,取消的 tee 不会挂住请求。
  • 三条通道共用一个序号(metadata.codexCloudCheckpoint.seq):通告 header、回放的 compaction 输入项(无 header 客户端)、响应项。每个 checkpoint 最多关闭一代,后到的通道是 no-op。
  • 连续多代只发布一条合并摘要(同 topic 取最新,约 1.2k 字符封顶),不再并列堆 N 条。
  • bili 通告本轮折叠掉的 token 数(x-bili-plugin-compressed),客户端下一轮不会再去压缩一个已经变小的 body。
  • 归档失败路径保持 pendingRebase(维护者的修复 bcab9636b3),下一次请求重试,而不是被永久搁置。

…compaction

The Codex cloud compactor replaces the request history with an encrypted
checkpoint item, and the dsh-codex-subscription plugin now says so explicitly
on the wire (x-bili-codex-checkpoint*). Treat that header as the authoritative
boundary instead of guessing from message text, and close the replaced history
into a read-only generation before the local state resets.

- src/codex-checkpoint.ts: header contract, parse/validate, identity dedupe
  (id, or a higher seq for the same checkpoint), session record.
- src/history-generations.ts + a .history-generations.json sidecar: every
  closed generation keeps its blocks, block contents, ref map, raw messages
  and a frozen slice of the content store. Payload is written (fsync, atomic
  rename, same codec/encryption as the session) before the metadata index
  advertises it; a missing index is repaired from the sidecar.
- src/session.ts: close a generation on every rebase (header, announced
  compaction, unannounced rewrite) and pin nextBlockId above the closed max so
  old block ids are never re-issued. A failed snapshot leaves live state
  untouched instead of resetting it; with persistence off the archive lives in
  a bounded process-local LRU. The decoded archive is cached per session and
  keyed on the sidecar's size+mtime.
- decompress / search_context / the retrieve tool resolve old bN and mNNNNN
  across generations, read-only, without perturbing the live session.
- prepare-responses injects a compact generation index (no payload) so the
  model can find closed material on demand, and archives the pre-compaction
  history rather than the truncated request.
- acp-status / docs describe the new archive semantics.
@ranxianglei ranxianglei changed the title feat(acp): keep pre-compaction history restorable across client-side compaction [PR] feat(acp): keep pre-compaction history restorable across client-side compaction Nov 11, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Picked up the review. Status as of now (verified live):

Now doing the deep pass: reading the full diff file-by-file against master, checking the boundary semantics against the two compression modes, running the affected test batches locally, then a full structured review. Will follow up with the verdict here.

… fails

Review fix for ranxianglei#6217: when closeHistoryGeneration cannot persist, the abort
path set pendingRebase=false while its own comment (and docs/codex-cloud-
compaction.md) promised "the next request retries". With the boundary
consumed, no retry can ever happen for that checkpoint — the dedupe record
(id+seq) never re-fires, so the session would stay unrebased against
compacted wire history until a weaker text heuristic happened to re-detect
the boundary.

Keep pendingRebase true on failure: the next request retries the close, and
once persistence recovers the rebase completes normally. The failure is
still recorded via archiveFailedAt; live state stays untouched until the
archive is durable.

tests/history-generations.test.ts now asserts the pending state and proves
the retry completes the rebase after persistence recovers.
@NewbieXvwu

Copy link
Copy Markdown
Author

Thanks — the dedupe read matches the intent: #4931/#4937 fix the state-reset side, this PR only adds the retention/read side (closed generations + cross-generation decompress/search_context/retrieve).

Two composition notes while those PRs are open:

  1. This PR's detection path (src/codex-checkpoint.ts) accepts the plugin's x-bili-codex-checkpoint* header, and the follow-up adds replayed compaction items in the request input. If [PR] fix(codex): reconcile opaque native compaction checkpoints once #4931 or [PR] fix(codex): rebase ACP state when codex replays an opaque native compaction checkpoint #4937 lands first I'll rebase onto it and let its rebase function stay the single authority, so a boundary can never be reconciled twice — the retention hook just rides on whatever marks it.
  2. The companion codex-plugin PR (feat(codex): announce cloud checkpoints to the proxy on the wire WSL043/dsh-codex-subscription#251) was closed in favour of the plugin making the SSE proxy see the response (upstream 9f33187) and matching the checkpoint on the next request. The follow-up here closes the generation at response time from the compaction item bili already sees, which also covers the case that motivated closing release v0.1.55 #251 (conversation ends immediately after compaction, so no next request ever announces it).

Happy to fold the follow-up into this PR instead of keeping it stacked if you prefer one review, or to drop the header path entirely and rely only on the request/response item channels. Whatever keeps the boundary detection single-sourced.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Progress update — my process restarted mid-review; here is the verified current state:

Review of #6217 is complete. I read all 20 files against master dc041dd, ran typecheck plus 71 local tests (the three directly-touched suites plus nine adjacent compaction/rebase suites) — all green. One real defect found and fixed directly on this branch:

  • Archive-failure abort latched instead of retrying (src/session.ts, reconcileCompactionBoundary): when closing the generation could not be persisted, the code set pendingRebase=false even though its own comment and docs/codex-cloud-compaction.md both promise "the next request retries". With the boundary consumed and the checkpoint dedupe record written unconditionally in prepare-responses.ts, the same id/seq never fires again — the session would stay unrebased against compacted wire history until a weaker text heuristic happened to re-detect the boundary. Fixed in commit bcab9636b3, pushed to your branch just now (verified: PR head is now bcab9636b3): the boundary stays pending on failure, so the next request retries and completes the rebase once persistence recovers. The persistence-failure test now asserts the pending state and proves the retry completes the rebase after save recovers.

Minor observations (no change made, for the record): the memory LRU for persist-off sessions is bounded by session count, not bytes; the cold-start fallback archives the resent tail with the stale pre-reset ref map (harmless — those refs simply don't resolve in the generation); the single-entry generation cache thrashes if two sessions alternate archived reads; the navigation note is injected on the Responses lane only (other lanes can still restore via the tools, just without the standing index).

CI will re-run on bcab9636b3; my full structured review follows as soon as it's green.

Your two composition notes:

  1. Agree on single authority — and the retention hook is already decoupled from who marks the boundary: it rides on reconcileNativeCompactionBoundary / applyCompactionArchive, so rebasing onto [PR] fix(codex): reconcile opaque native compaction checkpoints once #4931/[PR] fix(codex): rebase ACP state when codex replays an opaque native compaction checkpoint #4937 keeps their marker as sole source with no change here beyond the call site. One thing to preserve on that rebase: whichever path marks the boundary must write the same codexCloudCheckpoint dedupe record, or a double-mark through two paths becomes two generation closes. The same-slot filter makes an identical re-close safe, but two distinct slots for one real compaction would duplicate the post-reset tail into a second generation (noisy, not lossy). The existing mutual exclusion (!hasCompactionTrigger(parsed.input) gating the header path) already handles the trigger-vs-header overlap; the new case is response-time marking from the follow-up.

  2. On fold vs split — my recommendation: keep the header path, and fold the follow-up into this PR if the response-time close is part of the same loop. The header channel is the only one covering a plugin restart announcing reuse before any item replay exists, and it is the one your real-credential e2e actually proved end-to-end — dropping it removes the most robust signal. If the follow-up writes the same dedupe record at response time, all three channels (header / replayed input item / response-time item) converge on one identity and isNewCodexBoundary guarantees exactly one rebase regardless of which arrives first — that is your single-sourcing, and it stays testable in this repo. If you prefer stacked, [PR] feat(acp): keep pre-compaction history restorable across client-side compaction #6217 as-is is independently mergeable (additive; the residual gap is only "conversation ends immediately after compaction"), so there is no forced coupling. Your call — either way I'd review the folded version in this thread rather than a second one.

…aused it

Add the response-side wire channel and the headerless input-item channel, unify
them with the header under one monotonic ordinal, merge closed-generation
summaries into a single consolidated note, and announce proxy folds so the
client's cloud budget is not spent twice on the same tokens.
@NewbieXvwu

Copy link
Copy Markdown
Author

Thanks — good catch on the latched abort, and thanks for pushing bcab9636b3 directly (I've kept it as-is; the pending retry is the right semantic and the new test covers recovery).

Took your recommendation: folded the follow-up into this PR (b87cc2a0d, second commit on the same branch), keeping the header path.

What the second commit contains:

  • response-side close from the compaction output item (observeCodexCompactionItems + closeCodexResponseCompaction), so the "conversation ends immediately after compaction" case is covered on the same turn;
  • replayed compaction input items as the headerless-client channel (real Codex CLI);
  • all three channels share metadata.codexCloudCheckpoint.seq and isNewCodexBoundary, so whichever arrives first wins and the rest are no-ops — including response-then-header;
  • closeCodexResponseCompaction writes the dedupe record only when the rebase actually happened, so a failed archive stays retryable through the same pending boundary your fix keeps;
  • aggregation: consecutive generations publish one consolidated summary (~1.2k chars, newest wins per topic);
  • x-bili-plugin-compressed so the client doesn't compact an already-folded body on the next turn.

On your list-item 1: agreed, whoever marks the boundary must write the same codexCloudCheckpoint record. Right now every path funnels through reconcileNativeCompactionBoundary/closeCodexResponseCompaction and writes it only on a successful rebase, so a rebase onto #4931/#4937 only needs the call site kept — I've noted that in the task list for if they land first.

Verification on b87cc2a0d: tsc 0; 74 tests green in the affected batch (history generations, response-side, checkpoint boundary, compaction archive, codex compact/responses-ws, dsh guard, #3477); check:unused-exports, architecture-docs, config-surface clean; npm run build OK. The zh doc now mirrors the three-channel/aggregation sections.

On the minor notes: the LRU is session-count bounded by design (bytes unknown at insert), the cold-start tail is recorded deliberately as "the history this checkpoint replaced" even when refs don't resolve, and the nav note is Responses-lane-only on purpose (other lanes still restore through the tools). Happy to fix any of those you'd rather see changed.

The navigation note made the developer/system prefix change on the turn a
generation closed, which breaks the append-stable wire contract (ranxianglei#2596) and
with it the provider cache. The note is now an ephemeral tail note with its own
bounded prefix, appended like the other bili notes and never persisted, so the
system layer stays byte-identical across turns. Contract harness learns the new
note kind.
@NewbieXvwu

Copy link
Copy Markdown
Author

CI caught a real contract break from the folded work, fixed in 04f1a642f:

cache-friendly plugin matrix: responses — dsh native-compaction rebase keeps the wire clean and append-stable (#2596/#2658) failed with system layer bytes changed at t5. Cause: my closed-history navigation index was appended to the developer message, so the cached system prefix changed on the turn a generation closed. That is exactly the invariant #2596 protects, and the note is session state, so it should never have been in that layer.

Fix: the index is now an ephemeral tail note ([billion-context] Closed history generations — …), appended next to the existing note slots and never persisted — the developer/system layer is byte-identical across turns again. The contract harness learns the new note kind (histnote) in its slot whitelist; the note is bounded (≤4 generations + one consolidated summary, ~1.2k chars) and only appears once a generation exists.

Local verification on 04f1a642f: tsc 0; tests/cache-friendly-plugin.test.ts 11/11; affected batch 85/85 (history generations, response-side, checkpoint boundary, compaction archive, #3477, codex compact/wss, dsh guard); check:unused-exports, architecture-docs clean; npm run build OK. Docs updated (en + zh) to state the note is tail-only and why.

Waiting on CI for the new head before asking for the final verdict.

@NewbieXvwu

Copy link
Copy Markdown
Author

CI is fully green on 04f1a642f: 40 checks passed, 0 failed (16 skipped as usual). The #2596 cache-friendly matrix now passes on all three wire shards. Ready for the verdict whenever you are.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Thanks for the explanation — it matches exactly what I verified in 04f1a642f: the nav index moved out of the developer layer into the ephemeral tail note slot (byte-identical cached prefix restored), histnote added to the #2596 harness whitelist, bounded to ≤4 generations + one consolidated summary. That fix is confirmed good on my side: 11/11 in the cache-friendly matrix locally and green on CI.

One thing so you don't wait: the final verdict is already posted above (my last comment). Summary of where things stand:

  • CI: fully green on 04f1a642f (verified live: 30 checks, 0 failed, 0 pending).
  • Verdict: not mergeable yet — one required fix: the x-bili-plugin-compressed header reads session.stats.tokensSaved, which has no incrementer anywhere in the codebase (dead per src/web/sessions-data.ts:844 and src/persist.ts:1840). The header is never emitted, no test covers it, yet both docs promise it. Two options: (a) wire it to a prepare-time-known signal (the archived generation's tokensCompressed + prepare-time fold deltas) with a test asserting emission, or (b) drop the header and both doc sections now. A naive swap to compressCreditTokens doesn't fully work because response headers are written before the body streams while tool-driven folds are only known mid-stream.
  • New since my last comment: the PR is now dirty against master (merge conflict — master moved). Please rebase onto current master as part of the next push; that plus the dead-header disposition is all that's left.

Everything else is verified and mergeable — no new findings in this round. Once the dead-header item is resolved (either option), I'll re-verify and confirm merge-ready.

…esponses.ts import conflict

Union of both sides' import additions:
- keep PR's historyGenerationsOf (session.js) + historyIndex (history-generations.js)
- keep master's getStore (persist.js)

No other conflicts; all other files auto-merged cleanly.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Conflict resolved and pushed. I merged the current master (9674cfafbc) into the PR head (04f1a642f3) and resolved the single merge conflict, then pushed the merge commit 69d0380f99 to the PR branch NewbieXvwu/billion-context:2026-11-11_codex-cloud-compaction-generations (fast-forward, no force-push). The PR is now mergeable: True (state blocked = waiting on CI checks / review, the normal post-conflict state).

What the conflict was: the only conflicted file was src/server/prepare-responses.ts, in its import block. Both sides had added different imports there — the PR side added historyGenerationsOf (from ../session.js) and historyIndex (from ../history-generations.js), while master added getStore (from ../persist.js). I resolved it as the union of both sides, keeping all three additions. Every other file auto-merged cleanly with no conflict.

I verified the merge is sound by confirming each referenced symbol exists in the merged tree and is actually used: historyGenerationsOf (src/session.ts:1896), historyIndex (src/history-generations.ts:61), historyNavNote (src/history-generations.ts, pre-existing), getStore (src/persist.ts:4547), and ingestRowsNow (src/persist.ts:3260). All four PR commits are preserved in the merge (no rebase, contributor authorship intact), and the master tip is an ancestor of the new head.


结构化八问

  1. 是什么问题:PR [PR] feat(acp): keep pre-compaction history restorable across client-side compaction #6217 的分支落后于 master 且与之存在合并冲突(GitHub merge state: dirty),导致 PR 无法合并。
  2. 什么原因导致的:PR 基于旧的 master(dc041dd1ab),此后 master 又前进了 18 个提交;双方都改了 src/server/prepare-responses.ts 的 import 区(PR 加 historyGenerationsOf/historyIndex,master 加 getStore),在同一 import 块产生文本冲突。
  3. 影响范围与严重程度:仅阻塞该 PR 的合并流程——冲突不解决就无法 merge;不触及任何运行时行为(纯 import 行冲突),无用户面影响。
  4. 怎么修复的:把当前 master(9674cfafbc)merge 进 PR head,对唯一冲突文件取两侧 import 的并集(同时保留 PR 的 historyGenerationsOf+historyIndex 与 master 的 getStore),其余文件由 git 自动合并;以 merge(非 rebase)方式保留贡献者全部 4 个原始提交,fast-forward 推送、无 force-push。
  5. 是否有回归问题:无。冲突仅为 import 行,取并集后两侧符号均存在且被使用(见上验证);其余自动合并文件未改动语义,无 fail-fast 变吞错、阈值/时序/输出格式漂移等高危模式。
  6. 是否破坏缓存:不涉及(纯 import 合并,不触及缓存、重试、增量游标、去重键等失效策略)。
  7. 是否改了设计方向:不涉及(无架构、边界、数据流变化)。
  8. 是否引入了新的配置:不涉及(无新增 env / config / 默认值)。

收工判定:冲突已解决并推送,PR 现可合并(待 CI 与 review);本次为机械性 import 冲突修复,未触及 kernel/ 或任何授权门禁,无需决策。

x-bili-plugin-compressed read session.stats.tokensSaved, which nothing
increments: the header never shipped and both docs promised it. It now carries
the sum of the active blocks' covered tokens — prepare-time known, stable across
retries, and absent when nothing is folded — with a test pinning emission and
absence.
@NewbieXvwu

Copy link
Copy Markdown
Author

Both items are addressed in c22d981b8 (on top of your merge 69d0380f9), and I took option (a) for the header.

x-bili-plugin-compressed is now real. You were right that session.stats.tokensSaved has no incrementer — the header was dead and the docs promised something that never shipped. It now carries the sum of the active blocks' compressedTokens: prepare-time known, stable across retries, and naturally zero (no header) once a rebase has emptied the live state or when nothing is folded. That is exactly the quantity the thrash comes from — the client measures its own unfolded history while the wire is already smaller by that much — so it does not need mid-stream knowledge of a tool-driven fold.

Test: a turn with an active fold announces the folded token count to the client in tests/codex-response-side-boundary.test.ts asserts the value equals the active blocks' covered tokens on a folded turn, and asserts the header is absent on a cold session. Docs (en + zh) reworded to "the tokens it currently folds", not "the tokens it just folded".

Rebase/conflict: thanks for merging master and resolving the import union — I kept your merge commit as the base and pushed on top of it (fast-forward, no force-push).

Verification on c22d981b8: tsc 0; affected batch 86/86 (history generations, response-side, checkpoint boundary, compaction archive, #3477, codex compact/wss, dsh guard, cache-friendly matrix 11/11); check:unused-exports clean; architecture-docs green; npm run build OK.

CI for the new head is running; I'll report if anything fails.

@NewbieXvwu

Copy link
Copy Markdown
Author

CI is green on c22d981b8: 40 checks passed, 0 failed (16 skipped). The new header test passes in all three wire shards. Ready for your re-verification.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

c22d981b8d reviewed — the required fix is resolved. I verified the new head locally (typecheck clean, 95/95 in the targeted batch with the test preload) and checked the merge commit.

The header fix is the right quantity, not just a live counter. I checked the semantics against the kernel: block.compressedTokens (kernel/src/types.ts:78) records the full input token count of the messages consumed into the block (kernel/src/compress.ts:1916-1956, kernel/src/report.ts:48-55) — so the sum over active blocks is exactly "how much smaller the wire is than the client's unfolded history", which is the quantity the double-compaction thrash comes from. It is prepare-time known, stable across retries, and absent when nothing is folded — the timing problem I flagged (headers written before the body streams) is sidestepped rather than fought. The new test pins both directions: header equals the active blocks' covered tokens on a folded turn, and is absent on a cold session. Docs (en + zh) now honestly say "the tokens it currently folds" instead of "just folded".

The merge commit 69d0380f9 is clean. The only PR-scope file it touched is src/server/prepare-responses.ts (+3 lines: the getStore import union and the #3397 ingestRowsNow durability call, matching the other four prepare lanes at prepare-anthropic.ts:618 / prepare-openai.ts:643 / prepare-google.ts:420 / incremental-lane.ts:1017). All of this PR's own changes survived the merge intact; the rest of the merge is master's already-tested work (#6326, #6260, #5432, webui).

One contract note for the companion: the dsh-codex-subscription side (#250) now has to implement the current-total semantics the docs state — credit the announced amount to the next request's threshold, once per request, never a permanent lowering. You own both sides and the docs are now the contract, so this is a reminder, not a blocker.

CI: running on c22d981b8d (verified live: 0 failed so far, 14 lanes still queued/in-progress). I'll confirm merge-ready the moment it's green.

Verdict: the one required fix is in and verified; pending CI green, this PR is merge-ready. Merge stays human-only.


结构化八问(本轮增量,中文)

  1. 是什么问题:上一轮唯一阻塞项——x-bili-plugin-compressed 读死计数器 tokensSaved,header 永不发出但文档在承诺。本轮提交 c22d981b8d 修复它,并合入 master(69d0380f9)。
  2. 什么原因导致的:实现选错了信号——tokensSaved 自 kernel 导入起就没有增量点(全仓零写入)。修法不是换一个"本轮增量"计数器(受响应头先于流写入的时序限制),而是改报当前折叠总量。
  3. 影响范围与严重程度:仅影响配合型客户端(dsh-codex-subscription)的压缩阈值协调;此前该协调从未生效(header 死代码),不存在旧行为回归。修复后每响应携带活跃块 covered tokens 之和,无折叠时不发出。
  4. 怎么修复的:header 值 = session.state.blocks 中 active 块的 compressedTokens 之和(prepare 时点已知、重试稳定、rebase 后自然归零);>0 才发出;测试钉住"发出且值正确"+"冷会话不发出"两个方向;en/zh 文档改为"此刻折叠的 token 数"。
  5. 是否有回归问题:逐项审过——compressedTokens 语义经 kernel 源码核实(块消费消息的完整输入 token 数,compress.ts:1916);merge commit 冲突解决正确(prepare-responses.ts 仅 +3 行:import 并集 + #3397 ingestRowsNow,与其余四个 prepare 车道一致),本 PR 自身改动完整保留;本地 95/95(含新测试)+ typecheck 干净。无回归。
  6. 是否破坏缓存:不涉及——该 header 是响应头(客户端方向),不进入任何被缓存的请求前缀。
  7. 是否改了设计方向:无转向。契约语义从"本轮折叠增量"(从未生效)明确为"当前折叠总量",文档即契约;配合端按每请求一次性抵扣实现。
  8. 是否引入了新的配置:无。

收工判定:阻塞项已解决并验证;CI 转绿后即可合(人工合并)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

CI confirmed green — this PR is merge-ready. I verified it live on the new head c22d981b8d (direct single upstream read, since the local mirror cache had gone stale at 09:06Z): 40 success / 16 skipped / 0 failed / 0 pending — matching your report exactly, including the new header test across all three wire shards.

Combined with the verdict posted above, the full state is:

  • Code review: complete across all four commits (original + my bcab9636b3 archive-failure fix + your fold b87cc2a0d + cache fix 04f1a642f3 + header fix c22d981b8d + master merge 69d0380f9). Every changed file read, three-channel dedupe traced by hand, merge resolution verified clean.
  • The one required fix (dead x-bili-plugin-compressed): resolved per option (a) — header now carries the sum of active blocks' compressedTokens, kernel-verified semantics, test pins emission + absence, docs (en/zh) honest.
  • Local: typecheck clean, 95/95 targeted batch (with test preload).
  • CI: green on the final head (above).

Verdict: mergeable. The only remaining step is yours — merge is human-only: #6217


收工判定(中文):全部阻塞项已解决并验证——死 header 修复(当前折叠总量语义,kernel 源码核实)、master 合并冲突解决正确、本地 95/95 + typecheck 干净、CI 在最终 head c22d981b8d 上全绿(40 过 / 0 败,直连上游单次核实)。本 PR 可合,等待人工合并。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Re-verification is already done — the merge-ready confirmation is posted above (my last comment). To summarize the verified state:

  • CI on c22d981b8d: green, verified live (40 success / 16 skipped / 0 failed / 0 pending) — your count matches exactly, header test included in all three wire shards.
  • Code: the header fix is the right quantity (active blocks' compressedTokens, kernel-verified), the master merge 69d0380f9 is clean, local 95/95 + typecheck clean.
  • PR head unchanged at c22d981b8d; state open, blocked only in the GitHub sense of "awaiting review approval" — nothing is red.

Nothing left on my side. The only remaining step is the human merge: #6217


收工判定(中文):复核已完成并确认——CI 全绿(直连上游核实 40 过 / 0 败)、代码与合并均验证干净、本地 95/95。本 PR 可合,等待人工合并,无遗留项。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

ci-check and others added 2 commits November 13, 2026 13:05
… docs index conflicts

Master added Japanese (ja) links to the 6 identity/protocol doc rows; the PR
added the codex-cloud-compaction row (en + zh-CN, no ja file yet). Resolution
keeps master's ja links on the existing rows and appends the PR's
codex-cloud-compaction row. prepare-responses.ts auto-merged cleanly (its
import conflict was already resolved in the prior merge commit).
…es the same epoch

master's ranxianglei#1638 path now hashes opaque compaction items into a native key and
rebases when fold coverage is gone. That is the same event our codex
checkpoint channels already closed on this request, so guard it: advance the
opaque-key bookmark and skip the second, empty generation.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Round 2 — conflict re-resolved and pushed. Since my first fix, master advanced 129 commits and the contributor added one commit (c22d981b8d — "announce the tokens the proxy actually folds") on top of the branch, so the PR went dirty again. I merged the current master (fcc2e84848) into the PR head (c22d981b8d) and resolved the new conflicts, then pushed merge commit 71d4cbae2d to NewbieXvwu/billion-context:2026-11-11_codex-cloud-compaction-generations (fast-forward, no force-push). The PR is now mergeable: True (state blocked = waiting on CI/review).

What conflicted this round (2 files, both doc index tables):

  • docs/index.md and docs/index.zh-CN.md — master added Japanese (日本語) links to the 6 existing identity/protocol rows, while the PR had added its codex-cloud-compaction row (en + zh-CN only, no ja file). I resolved as the union: kept master's ja links on the 6 existing rows and appended the PR's codex-cloud-compaction row (en + zh-CN, no ja link since codex-cloud-compaction.ja.md doesn't exist). I verified all 6 ja files exist and that the codex doc has no ja variant before writing the links.

src/server/prepare-responses.ts (the file that conflicted in round 1) auto-merged cleanly this time — its import conflict was already settled in the prior merge commit, and master didn't re-touch it in a conflicting way. I re-verified the key symbols the PR relies on still exist after the 129-commit master merge: historyGenerationsOf (src/session.ts:1896), historyIndex (src/history-generations.ts:61), getStore (src/persist.ts:4547), ingestRowsNow (src/persist.ts:3260), and the PR's new files (src/history-generations.ts, src/codex-checkpoint.ts) are intact.


结构化八问

  1. 是什么问题:PR [PR] feat(acp): keep pre-compaction history restorable across client-side compaction #6217 再次与 master 冲突(merge state: dirty)——第一轮修复后 master 又前进了 129 个提交,且贡献者在分支上加了一个新提交,导致 PR 重新无法合并。
  2. 什么原因导致的:master 侧为 6 个身份/协议文档行补了日本語链接,PR 侧新增了 codex-cloud-compaction 文档行,双方在 docs/index.md / docs/index.zh-CN.md 的同一表格区产生文本冲突;prepare-responses.ts 的 import 冲突已在第一轮解决,本轮自动合并干净。
  3. 影响范围与严重程度:仅阻塞该 PR 的合并流程;冲突为文档索引表格行,不触及任何运行时行为,无用户面影响。
  4. 怎么修复的:把当前 master(fcc2e84848)merge 进 PR head,对两个文档索引取两侧并集(保留 master 的 6 行 ja 链接 + 追加 PR 的 codex-cloud-compaction 行,该行因无 ja 文件只挂 en+zh-CN);以 merge(非 rebase)方式保留贡献者全部提交(含新增的 c22d981b8d),fast-forward 推送、无 force-push。
  5. 是否有回归问题:无。冲突仅为文档表格行,并集后两侧链接均有效(已核对 6 个 ja 文件存在、codex 文档无 ja 变体);prepare-responses.ts 自动合并干净,PR 依赖的关键符号在 129 提交合并后均存在且被使用,无 fail-fast 变吞错、阈值/时序/输出格式漂移等高危模式。
  6. 是否破坏缓存:不涉及(纯文档索引合并,不触及缓存、重试、增量游标、去重键等失效策略)。
  7. 是否改了设计方向:不涉及(无架构、边界、数据流变化)。
  8. 是否引入了新的配置:不涉及(无新增 env / config / 默认值)。

收工判定:本轮冲突已解决并推送,PR 现可合并(待 CI 与 review);本次为机械性文档索引冲突修复,未触及 kernel/ 或任何授权门禁,无需决策。

@NewbieXvwu

Copy link
Copy Markdown
Author

已在维护者的 round-2 merge 71d4cbae2 之上补了一个修复提交 c4a0f6c40(未改动维护者的提交,未 force-push)。

问题:master 新合入的 opaque checkpoint 路径(49c58359b,nativeCompactionKey)会把客户端回放的 compaction item 哈希成 native key,并在 fold 覆盖缺失时再 rebase 一次。对本 PR 的 "回放 item 也是边界" 通道来说,这是同一个事件,于是同一请求里开了两个历史代(第二个是空的)——tests/codex-response-side-boundary.test.ts 的 headerless 用例因此变成 2 代。

修法:同一请求内已由 codex checkpoint 通道(header / 回放 item)关闭的 epoch,只推进 codexNativeCompactionKey 书签,跳过第二次 rebase;没有经过新通道的旧客户端仍走原来的 coverage 判断。

验证:tsc 0;九个相关测试文件 86/86(含 headerless 回放、同轮关闭、去重、缓存契约);check:unused-exports、architecture-docs 干净。CI 已随新 head 重跑。

(另:master 的 ja 文档行与 codex-cloud-compaction 行的冲突,维护者的 round-2 merge 已按 "保留 ja 链接 + 追加本 PR 行" 解决,与本地一致。)

… import-block conflicts

Master (301 commits since fcc2e84) added nudge-stamp helpers
(nudgeStampsOf/restoreNudgeStamps/releaseNudgeHold/rejectNudge) to the
session.js imports; the PR added historyGenerationsOf (+ historyIndex from
history-generations.js) and closeCodexResponseCompaction. Resolved as the
union of both import lists in prepare-responses.ts and relay.ts; all symbols
verified present and used. No other conflicts (the rest auto-merged).
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Round 5 — conflict resolved, merge pushed, CI running.

Live-verified this run: the PR head was 70e524c0d but master had advanced 301 commits past the merge-base (fcc2e84848 → actual tip 2e3cfc973b), so the PR was dirty (mergeable: False). The earlier API base_sha (fcc2e84848) was stale — the real master tip is 2e3cfc973b.

What I did:

  1. Merged the current master (2e3cfc973b) into the PR head (merge, not rebase — preserves the contributor's authorship and allows a fast-forward push without force).
  2. 2 conflicts, both import blocks (the rest auto-merged clean):
    • src/server/prepare-responses.ts — the PR added historyGenerationsOf (+ historyIndex from history-generations.js) to the ../session.js import; master added nudgeStampsOf/restoreNudgeStamps. Resolved as the union (all symbols kept).
    • src/server/relay.ts — the PR added closeCodexResponseCompaction; master added releaseNudgeHold/rejectNudge. Resolved as the union.
  3. Verified all 7 union symbols exist in session.ts/history-generations.ts and are actually used (no unused imports).
  4. Merge commit 69d6e15dda (parents 70e524c0d + 2e3cfc973b); re-fetched the remote head before pushing (push discipline) and fast-forwarded it to the contributor fork.
  5. Verified live: mergeable: True, mergeable_state: blocked (no conflict — clean, awaiting CI + review). CI is running on the new head (16 queued, 0 failures so far).

八问

  1. 是什么问题: PR 与 master 产生合并冲突——master 自 merge-base fcc2e84848 前进了 301 个 commit,PR head(70e524c0d)落后,mergeable: False(dirty)。
  2. 什么原因导致的: master 这 301 个 commit 里给 ../session.js 的 import 块加了 nudge-stamp 系列符号(nudgeStampsOf/restoreNudgeStamps/releaseNudgeHold/rejectNudge),与 PR 在同一 import 块加的 historyGenerationsOf/historyIndex/closeCodexResponseCompaction 撞在一起,两个文件(prepare-responses.ts、relay.ts)各一处。
  3. 影响范围与严重程度: 仅合并冲突,不影响任何运行行为;不解决则 PR 无法合并。
  4. 怎么修复的: 把当前 master(2e3cfc973b)merge 进 PR head,两处 import 块冲突按并集解决(两边符号都保留),逐一验证 7 个符号都存在且被使用(无未使用 import),其余文件自动合并干净。
  5. 是否有回归问题: 无。只动了 import 块(并集),没动任何逻辑;PR 的关键符号(historyGenerationsOf/historyIndex/closeCodexResponseCompaction/getStore)和新增文件(codex-checkpoint.ts/history-generations.ts)合并后都完整存在。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 不涉及。
  8. 是否引入了新的配置: 不涉及。

判定: 冲突已解决并推送,PR 现在 mergeable:True / blocked(干净,等 CI + owner review)。CI 正在新 head(69d6e15dda)上跑(16 queued,目前 0 失败)。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

APPROVE — reviewed the full diff end-to-end (24 files, +2729/−46) against issue #6215.

Correctness. The history-generation mechanism does what it claims: at a real compaction boundary the live ACP state (blocks, ref map, raw messages, CCR slice) is closed into a read-only generation, persisted to an encrypted+fsynced sidecar before the metadata index (crash recovery verified by test), and the ref floor + nextBlockId pinning guarantee old bN/mNNNNN are never re-issued. Boundary detection runs on wire truth through three channels (checkpoint header / replayed compaction input / response compaction item) sharing one (id, seq) ordinal, so one compaction event closes exactly one generation — I traced the dedupe matrix and the consecutive-compaction case (header channel dedupes against the response-side record, so no double generation). The response-side close races only after the full pipe completes, so the 3s timeout is a stuck-stream safety net, not a model-latency cap. Failure paths are honest: persistence off → bounded in-memory LRU (32 sessions); persist fail → rebase aborted, boundary stays pending for retry (maintainer fix kept).

Tests. Real, not tautological: they pin the dedupe matrix, ref/block cursor pinning, cross-generation range+whole restore, restart-from-sidecar-alone index recovery, persist-fail abort+retry, the forged fc_bili_* carrier rejection, and the nav-note wire placement. All PR-added suites pass locally (history-generations 8/8, codex-checkpoint-boundary, codex-response-side-boundary, compaction-archive; typecheck clean). The cache-friendly-plugin matrix failures I saw locally reproduce identically on the PR base — environmental (ACP tags now carry a time= attribute the test's TAG_RE doesn't account for), not a regression from this PR. CI on the pushed head is the full-suite verdict.

Small findings fixed on the spot (pushed to the PR branch, fix: commits):

  • 已顺手修:nav note 的 ref span 起点硬编码 m00001,第 2 代及以后会显示错误区间 — 改用该代记录的 firstRef + commit bac5317
  • 已顺手修:search_context 两处 — (a) 仅 folded original 命中时 header 从 “but N folded original(s) match” 回退成 “Found 0 block(s)”,丢信息,已恢复旧措辞;(b) self-alias(canonical id)路径漏传 closed generations,与主路径不一致,已补齐 + commit e924d6b

Behavior changes (旧值→新值).

  • 归档(pre-compaction)内容:decompress 拒绝 / search_context 不可见 / retrieve 解析不了旧 ref → 只读可恢复(decompress / search_context / retrieve 均可跨代解析)。这是本 PR 的目的,属有意变更。
  • 新增响应头 x-bili-plugin-compressed(active blocks 的 compressedTokens 之和,为 0 时缺省)— additive,供客户端把折叠量计入云端 compaction 阈值。
  • acp_status 的 PRE-COMPACTION ARCHIVE 行措辞更新(从 “decompress is unavailable” 改为说明可只读恢复)。
  • 无新 config、无新 env、无新依赖、无 kernel/ 改动;5 个 checkpoint 头加入 UPSTREAM_HOP_HEADERS(转发上游前剥除,不泄漏内部协议)。

八问(供人工 reviewer 核对)

  1. 是什么问题:客户端/云端 compaction 后,被折叠的历史在 bili 侧不可达——decompress 拒绝、search_context 看不到、retrieve 解析不了旧 mNNNNN。
  2. 什么原因导致的:compaction 边界只留了一个 marker(preCompactionArchive),没有把 ACP 状态(blocks/refs/messages/CCR)固化成可恢复快照;rebase 后 ref 空间从低位重新分配,旧 ref 失去指向。
  3. 影响范围与严重程度:所有走客户端/云端 compaction 的 codex/dsh 会话;compaction 后旧历史不可恢复——体验受损,非数据损坏(ref 不复用,无错指)。
  4. 怎么修复的:在真实 compaction 边界把当前 ACP 状态闭包成只读“history generation”(加密 sidecar 持久化,ref floor + nextBlockId 钉住连续性),decompress/search/retrieve 跨代只读解析;三条 wire-truth 通道共享一个 (id,seq) 序号去重。
  5. 是否有回归问题:审过 live 路径——search_context header 措辞回退(已修)、nav note span 硬编码(已修)、self-alias 搜索漏 archives(已修);fold/nudge/preflight/缓存字节稳定性(nav note 走 ephemeral tail 而非 developer 层,#2596 纪律保持)未触碰。
  6. 是否破坏缓存:不破坏。nav note 是 ephemeral tail note 且触发轮为 null;x-bili-plugin-compressed 是响应头;prefix 字节不变。
  7. 是否改了设计方向:无架构转向——在既有 compaction-archive 机制上增加“可恢复”能力;边界判定仍走 wire truth,消息 id 不可变契约不变。
  8. 是否引入了新的配置:无新 config/env/依赖;仅新增响应头 x-bili-plugin-compressed(additive,0 时缺省)。

Verdict: clean — the mechanism is correct, the tests pin the real behaviors (dedupe, ref continuity, cross-generation restore, failure fallbacks), and the three small findings are already fixed on the branch. Ready for the human review tier.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

PR #6217 review complete — APPROVE posted (GitHub review id 5911303447).

Reviewed the full diff end-to-end (24 files, +2729/−46) against issue #6215 and posted an APPROVE review on the PR with full justification.

Small findings fixed on the PR branch (pushed to NewbieXvwu:2026-11-11_codex-cloud-compaction-generations; PR head now e924d6b):

  • bac5317 — nav-note ref span used a hardcoded m00001 start (wrong for generation ≥2) → now uses the generation's recorded firstRef.
  • e924d6b — search_context: (a) restored the "N folded original(s) match" header that had regressed to "Found 0 block(s)"; (b) the self-alias (canonical id) path now includes closed generations, consistent with the primary path.

Behavior changes (old→new): archived pre-compaction content is now read-only restorable (the feature's point); new response header x-bili-plugin-compressed (additive, absent when 0); acp_status archive line reworded. No kernel/ changes, no new config/env/deps → HARD RULE not triggered, no needs-decision label.

八问(供人工 reviewer 核对)

  1. 是什么问题:客户端/云端 compaction 后,被折叠的历史在 bili 侧不可达——decompress 拒绝、search_context 看不到、retrieve 解析不了旧 mNNNNN。
  2. 什么原因导致的:compaction 边界只留了 marker(preCompactionArchive),没把 ACP 状态(blocks/refs/messages/CCR)固化成可恢复快照;rebase 后 ref 空间从低位重新分配,旧 ref 失去指向。
  3. 影响范围与严重程度:所有走客户端/云端 compaction 的 codex/dsh 会话;compaction 后旧历史不可恢复——体验受损,非数据损坏(ref 不复用,无错指)。
  4. 怎么修复的:在真实 compaction 边界把当前 ACP 状态闭包成只读 "history generation"(加密 sidecar 持久化,ref floor + nextBlockId 钉住连续性),decompress/search/retrieve 跨代只读解析;三条 wire-truth 通道共享一个 (id,seq) 序号去重。
  5. 是否有回归问题:审过 live 路径——search_context header 措辞回退(已修)、nav note span 硬编码(已修)、self-alias 搜索漏 archives(已修);fold/nudge/preflight/缓存字节稳定性未触碰。
  6. 是否破坏缓存:不破坏。nav note 是 ephemeral tail note 且触发轮为 null;x-bili-plugin-compressed 是响应头;prefix 字节不变。
  7. 是否改了设计方向:无架构转向——在既有 compaction-archive 机制上增加"可恢复"能力;边界判定仍走 wire truth,消息 id 不可变契约不变。
  8. 是否引入了新的配置:无新 config/env/依赖;仅新增响应头 x-bili-plugin-compressed(additive,0 时缺省)。

Outcome: APPROVE. The mechanism is correct, the tests pin the real behaviors (dedupe, ref continuity, cross-generation restore, failure fallbacks), and the three small findings are already fixed on the branch. Ready for the human review tier. Note: the cache-friendly-plugin matrix failures I saw locally reproduce identically on the PR base — environmental (a time= attribute in ACP tags the test's TAG_RE doesn't account for), not a regression from this PR; the full-suite verdict is the CI test lanes on the pushed head.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

APPROVE (re-review on new head e924d6b)

The delta from the previously-reviewed head (69d6e15dd) is exactly the two small fix commits pushed during review — no other changes:

  • bac5317 — nav-note ref span: hardcoded m00001 start → the generation's recorded firstRef (correct for generation ≥2).
  • e924d6b — search_context: restored the "N folded original(s) match" header (it had regressed to "Found 0 block(s)") and included closed generations on the self-alias (canonical id) path.

Both fixes verified locally (typecheck clean; history-generations + compaction-archive suites 20/20 pass). CI on the new head: 0 failures (11 checks still pending — the full-suite verdict is the CI test lanes). The full correctness / test / risk analysis stands from the previous review (id 5911303447): the history-generation mechanism is correct, the tests pin the real behaviors (dedupe, ref continuity, cross-generation restore, failure fallbacks), no kernel/ changes, no new config/env/deps.

八问(与上一轮一致——PR 行为未变,仅新增上述两处小修)

  1. 是什么问题:客户端/云端 compaction 后,被折叠的历史在 bili 侧不可达——decompress 拒绝、search_context 看不到、retrieve 解析不了旧 mNNNNN。
  2. 什么原因导致的:compaction 边界只留了 marker(preCompactionArchive),没把 ACP 状态(blocks/refs/messages/CCR)固化成可恢复快照;rebase 后 ref 空间从低位重新分配,旧 ref 失去指向。
  3. 影响范围与严重程度:所有走客户端/云端 compaction 的 codex/dsh 会话;compaction 后旧历史不可恢复——体验受损,非数据损坏(ref 不复用,无错指)。
  4. 怎么修复的:在真实 compaction 边界把当前 ACP 状态闭包成只读 "history generation"(加密 sidecar 持久化,ref floor + nextBlockId 钉住连续性),decompress/search/retrieve 跨代只读解析;三条 wire-truth 通道共享一个 (id,seq) 序号去重。
  5. 是否有回归问题:审过 live 路径——search_context header 措辞回退(已修)、nav note span 硬编码(已修)、self-alias 搜索漏 archives(已修);fold/nudge/preflight/缓存字节稳定性未触碰。
  6. 是否破坏缓存:不破坏。nav note 是 ephemeral tail note 且触发轮为 null;x-bili-plugin-compressed 是响应头;prefix 字节不变。
  7. 是否改了设计方向:无架构转向——在既有 compaction-archive 机制上增加"可恢复"能力;边界判定仍走 wire truth,消息 id 不可变契约不变。
  8. 是否引入了新的配置:无新 config/env/依赖;仅新增响应头 x-bili-plugin-compressed(additive,0 时缺省)。

Verdict: APPROVE — clean. The new head is the previously-approved code plus two verified small fixes; ready for the human review tier.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

Re-review on new head e924d6b (re-triggered by my own fix push): APPROVE posted (id 5911407014). Delta from the previously-approved head 69d6e15dd is exactly the two small fix commits (bac5317 nav-note ref span, e924d6b search_context header + self-alias archives) — no other changes; both verified locally (typecheck clean, targeted suites 20/20). CI on the new head: 0 failures (11 checks still pending). No kernel/ changes, no new config/env/deps. Ready for the human review tier.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

@NewbieXvwu

Copy link
Copy Markdown
Author

(ai: deepseek/deepseek-v4.1-flash)

看了您 round-5 的合并与两个小修,已在本地把分支同步到 e924d6bbe 复核:

  • bac531718:导航索引的 ref 起点改用该代的 firstRef(第 2 代起不再误写 m00001)——正确,我原来的实现确实只记了 maxRefIndex 起点。
  • e924d6bbe:search_context 恢复 "N folded original(s) match" 头,且 canonical-id 自引用路径也带上已关闭的历史代——正确,属于我漏掉的旁路。

本地验证(e924d6bbe,补装 master 新增的 @deepseek-ai/cordis 后):tsc --noEmit 0;history-generations、codex-response-side-boundary、codex-checkpoint-boundary、codex-local-compaction、compaction-archive、cache-friendly-plugin 共 45/45 通过;CI 40 success / 0 failure。

没有其他待改项,等 owner 合并即可。谢谢这两处补丁。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

谢谢独立复核确认。两处小修(bac5317 nav-note ref span、e924d6b search_context header + self-alias archives)已在 PR 分支上,您本地 45/45 + CI 全绿与我的定向验证(typecheck 0、相关套件通过)一致。

PR 已就绪,等 owner 合并(合并为 human-only,我无权代合)。无其他待办项。

ci-check and others added 5 commits November 16, 2026 20:42
…ns {3,5,11,14}

The probe anchor PROXY_TOOL_AT=6 was calibrated on 2026-10-31 for ranxianglei#4521
(schedule {4,6,8,9}). The nudge scheduling has shifted again — nudge now
lands at {3,5,11,14}. Re-calibrate the anchor to the next nudge-carrying
request pair (5 → tool round, 6 → fold round). The fold/proxy-tool-round
mechanics under test are unchanged.

Closes: master-red on test (windows-latest, 22, 3) and (ubuntu-latest, 22, 1).
…ic wire shape

The probe's hardcoded request-index anchors (PROXY_TOOL_AT/FOLD_AT) broke
every time the nudge gate's schedule shifted. The last recalibration
(245ecb1) was measured on a direct local run (timestamps ON by default
since ranxianglei#4313), but CI runs the suite preload pin BILI_MESSAGE_TIMESTAMPS="0"
(timestamps OFF) — a different wire shape, a different schedule (no nudge at
index 5) — so it passed locally and failed on every CI shard.

Root-cause fix instead of another anchor whack-a-mole:
- Arm the fold on the first request carrying the ephemeral nudge with >=11
  tagged refs; fold on the re-request after the acp_status round. The probe
  now materializes the ranxianglei#2929 scenario wherever the schedule places it.
- Pin compress.messageTimestamps:false so the probe's wire shape is hermetic
  regardless of how the suite is launched (matches the CI preload pin).

Supersedes the 245ecb1 recalibration. Verified: passes with and without
the preload pin, same deterministic schedule (nudge at inputs[7], fold at
inputs[8]).
# Conflicts:
#	src/server/prepare-responses.ts
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Round 6 — conflict resolved, merge pushed, CI running on the new head.

Live-verified this run (not from memory): the PR head was e924d6bbe while master had advanced 68 commits past the merge-base (2e3cfc973b → tip 301e1a545), so the PR was dirty (mergeable: False).

What I did:

  1. Merged the current master (301e1a545) into the PR head — merge, not rebase, preserving the contributor's authorship and allowing a fast-forward push without force.
  2. 1 conflict, an import block (src/server/prepare-responses.ts): the PR side had added the ../codex-checkpoint.js import + historyNavNote (from ../history-generations.js); master had added joinResponsesSystemSections (from ../responses-system-sections.js, [PR] fix(responses): share developer segment concatenation between compressed re-request and steady state, fix prefix re-bill | fix(responses): 压缩重请求与稳态共用 developer 段拼接,修复每次折叠后的前缀重计费 (#6922) #6944/[Bug] Inconsistent system prompt separator in Responses internal re-request breaks cache prefix | [Bug] Responses 内部重请求的系统提示分隔符不一致,破坏缓存前缀 #6922). Resolved as the union — all three imports kept. Everything else auto-merged clean.
  3. Verified every union symbol exists in the merged tree and is actually used: the eight codex-checkpoint.js exports (src/codex-checkpoint.ts:19–132), historyNavNote (src/history-generations.ts:358), joinResponsesSystemSections (src/responses-system-sections.ts:24, four call sites in prepare-responses.ts).
  4. Verified the master-side auto-merged changes landed intact: the joinResponsesSystemSections swaps in prepare-responses.ts ([Bug] Inconsistent system prompt separator in Responses internal re-request breaks cache prefix | [Bug] Responses 内部重请求的系统提示分隔符不一致,破坏缓存前缀 #6922), the round-2 system-prompt builder in relay.ts, the recordNudgeInject hook, the plugin-purpose header in plugin.ts ([Design][dsh] Stop guessing dsh's auxiliary requests — the in-process plugin can declare each request's purpose explicitly #6880), the architecture-doc line.
  5. Local verification on the merged head: tsc --noEmit clean; targeted batch 43/43 green (history-generations, codex-response-side-boundary, codex-checkpoint-boundary, compaction-archive, cache-friendly-plugin, cache-friendly-proxy — with the test preload).
  6. Merge commit 7726f1559 (parents e924d6bbe + 301e1a545); re-fetched the fork's remote head before pushing (still e924d6bbe, no concurrent work) and fast-forwarded it — no force-push.
  7. Verified live after the push (single direct upstream read): PR head 7726f1559, mergeable: True, mergeable_state: blocked (clean — no conflict, awaiting CI + review). The mirror cache is stale for this PR (last poll 2026-11-16), so the new head's CI has not appeared there yet; this push carries no [ework:ci-held] marker, so it is the branch's single full CI pass.

七问

  1. 是什么问题:PR [PR] feat(acp): keep pre-compaction history restorable across client-side compaction #6217 与 master 冲突(merge state dirty,mergeable: False),无法合并。
  2. 什么原因导致的:master 自 merge-base(2e3cfc973b)前进了 68 个提交(至 301e1a545);[PR] fix(responses): share developer segment concatenation between compressed re-request and steady state, fix prefix re-bill | fix(responses): 压缩重请求与稳态共用 developer 段拼接,修复每次折叠后的前缀重计费 (#6922) #6944/[Bug] Inconsistent system prompt separator in Responses internal re-request breaks cache prefix | [Bug] Responses 内部重请求的系统提示分隔符不一致,破坏缓存前缀 #6922 在 src/server/prepare-responses.ts 的 import 块加了 joinResponsesSystemSections,与 PR 侧在同一 import 块加的 codex-checkpoint 系列 import 撞在一起,产生文本冲突。
  3. 影响范围与严重程度:仅阻塞本 PR 的合并流程;纯 import 行冲突,不触及任何运行行为,无用户面影响。
  4. 怎么修复的:把当前 master merge 进 PR head;唯一 import 块冲突按并集解决(两侧符号全保留);逐一验证符号存在且被使用;其余文件自动合并干净;fast-forward 推送到 PR 分支(无 force-push)。
  5. 是否有回归问题:无。只动了 import 块(并集);master 侧自身改动([Bug] Inconsistent system prompt separator in Responses internal re-request breaks cache prefix | [Bug] Responses 内部重请求的系统提示分隔符不一致,破坏缓存前缀 #6922 section joiner、[Design][dsh] Stop guessing dsh's auxiliary requests — the in-process plugin can declare each request's purpose explicitly #6880 purpose header、nudge-debug 文档行)自动合并完整且已在 master 上经 CI 验证;本地 typecheck 干净 + 定向批 43/43。无阈值/时序/输出格式漂移,无 fail-fast 变吞错。
  6. 是否破坏缓存:不涉及(纯 import 合并,未触及缓存/重试/增量游标/去重键逻辑)。
  7. 是否改了设计方向:不涉及(无架构、边界、数据流变化)。

判定:冲突已解决并推送,PR 现 mergeable:True / blocked(干净,等 CI + owner review)。未触及 kernel/ 或任何授权门禁,无需决策。若 7726f1559 的 CI 转红,由我(同一 bot)在下一次唤醒时修复。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

本轮无新冲突——dirty 信号是过期的,冲突已在上一次运行中解决。

本次运行 live 核实(非记忆):

  • PR head = 7726f1559(我上一轮推的 merge commit,parents e924d6bbe + 301e1a545)
  • 直接读上游 API:mergeable: True,mergeable_state: blocked(干净——无冲突,等 CI + review),state: open
  • master tip 未动(仍 301e1a545),fork 分支头也未动(无并发写入)
  • 镜像缓存仍是旧的(fetched_at 2026-11-16T01:23,还停在 push 前的 e924d6b / behind)——本次唤醒的 dirty 判定就来自这个过期轮询

冲突本身在上一轮已处理:master 前进 68 提交后在 src/server/prepare-responses.ts import 块产生的唯一文本冲突,按并集解决(保留 PR 的 codex-checkpoint 系列 import + master 的 joinResponsesSystemSections),本地 typecheck 干净 + 定向批 43/43,fast-forward 推送(无 force-push)。

七问(本轮)

  1. 是什么问题:无新问题——唤醒所报的 dirty 冲突已被上一轮修复。
  2. 什么原因导致的:镜像轮询缓存滞后(仍显示 push 前状态),系统据此重复触发了冲突修复。
  3. 影响范围与严重程度:无影响——PR 实际状态干净(mergeable: True / blocked)。
  4. 怎么修复的:本轮未改动任何东西;仅 live 核实状态并确认无需动作。
  5. 是否有回归问题:不涉及(无改动)。
  6. 是否破坏缓存:不涉及(无改动)。
  7. 是否改了设计方向:不涉及(无改动)。

判定:无需动作,等 7726f1559 的 CI 结果;若 CI 转红,由我(同一 bot)在下一次唤醒时修复。

… lane

The round-6 merge resolved prepare-responses.ts against our side and dropped
master's ranxianglei#4521 trailing status-line item, so the pre-fold request no longer
carried the ephemeral nudge (ranxianglei#2929 byte-stability probe failed on three CI
shards).

Restores the trailing user item; tests/issue2929-codex-fold-double-miss.test.ts
passes again locally.
@NewbieXvwu

Copy link
Copy Markdown
Author

(ai: deepseek/deepseek-v4.1-flash)

round-6 合并(7726f1559)后的 4 个 CI 失败已定位并修复,head 现在是 16de52894。

1)3 个 test shard(issue2929-codex-fold-double-miss 的 scenario miss: no ephemeral nudge)

不是压缩逻辑的问题,是第 6 轮合并的冲突解决把 master 侧 #4521 的「armed-but-silent」尾注带丢了:src/server/prepare-responses.ts 里 master 的 turn.statusLine 尾随 user item 被我们的版本覆盖掉了,于是折叠前的那次请求不再带临时 nudge,#2929 的探针前提不成立。

修复(b6c116f5a):原样恢复该分支的尾注注入(代码与注释均保持 master 原文),不改变任何本 PR 的语义。

2)architecture-docs

同样是合并产物:master 新增的 src/responses-system-sections.ts 没进 reference/architecture.md。修复(16de52894)是在顶层 src 段落补上 │ ├── responses-system-sections.ts # Shared developer-section joiner …(#6922)。

本地验证

  • npx tsc --noEmit --project tsconfig.json → 0
  • issue2929-codex-fold-double-miss、issue2929-fold-claim-window、history-generations、codex-response-side-boundary、codex-checkpoint-boundary、compaction-archive、cache-friendly-plugin、codex-local-compaction、issue3910-lane-nudge-wiring、anthropic-lane-nudge → 57/57
  • check-architecture-docs → all green;check:unused-exports → clean

另外 @ranxianglei 之前的两个修复意见(bac531718 的 firstRef 跨度、e924d6bbe 的 folded-original 头 + 自身别名跨代检索)我已在本地确认正确,验证结果见上一条评论;这次没有再改动它们的代码。

@NewbieXvwu

Copy link
Copy Markdown
Author

(ai: deepseek/deepseek-v4.1-flash)

更正上一条:我上一版把 turn.statusLine 加回去是错的,9d77de890 已 revert(kernel/src/types.ts 的 ProcessTurnResult 在 master 上没有 statusLine,那是 e0d63bf→#6928 删掉前的旧形态;加回去会 static-gates 类型检查红)。

真正的原因:master 本身现在是红的。 origin/master = 301e1a545 的 check-runs:

test (windows-latest, 22, 4)   failure
test (windows-latest, 24, 4)   failure
test (ubuntu-latest, 22, 3)    failure
test (ubuntu-latest, 24, 3)    failure
architecture-docs              failure

本 PR head 上失败的 issue2929-codex-fold-double-miss(shard 1)、static-gates(我上一版引入的,已 revert)是同一批现象:

  • #6928(4ccccab15 kernel+host: remove the #4521 armed-but-silent '[ACP status: …]' refresh line)删除了那条临时 nudge 载体,但 tests/issue2929-codex-fold-double-miss.test.ts:232 的「scenario materialization」前置断言仍然要求 pre-fold 请求里出现 Compressible ranges (,于是 master 自己就红。这不是本 PR 引入的:在同一份 origin/master 检出上单跑该测试同样 scenario miss。
  • master 的 architecture-docs 红是因为 reference/architecture.md 缺了 src/responses-system-sections.ts(#6922 的模块)。本 PR 的 16de52894 顺手补了这一行(小问题直接修),所以本分支这条 lane 应该是绿的。

当前 head 9d77de890:tsc 0;history-generations / codex-response-side-boundary / codex-checkpoint-boundary / compaction-archive / cache-friendly-plugin / codex-local-compaction 45/45;architecture-docs all green;check:unused-exports clean。

没动那个 stale 测试:它守的是 #6928 之前的形态,怎么改(删掉 nudge 前置断言 / 换成新的载体断言)属于 #6928 的后续决定,我不想在本 PR 里悄悄削弱一个门。如果希望本 PR 绿着等合并,我可以在这个分支上补一个「nudge 载体已移除」的最小更新(保留后面的 byte-stability 不变量),说一声即可;否则请先让 master 那条红修掉,本 PR 只保留 architecture-docs 这一处顺手修复。

ework-agent added 2 commits November 17, 2026 09:36
…es merge

The ci-fixes merge brought in 8ed56be which adds src/responses-system-sections.ts to the module map at its alphabetical position (after resolver-wedge.ts). The author's earlier 16de528 added the same row at a non-alphabetical position (after codex-checkpoint.ts). Keep the ci-fixes placement, drop the duplicate.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

你的更正后的诊断我独立核实了——master 本身是红的,本 PR 没有引入这些失败。按 CI 失败协调政策(owner policy 2026-10-24),继承性红由 merge origin/ci-fixes(哨兵分支,收敛全部 master 修复)解决。已合并并推送最终 head 699c9ed58。

独立验证(本地证据):

  1. codex 命中率问题分析 #2929 测试在 master 上自己就是红的:我在干净的 origin/master(301e1a545)检出上单跑 tests/issue2929-codex-fold-double-miss.test.ts,同样失败:scenario miss: no ephemeral nudge in the pre-fold request (inputs[6])(tests/issue2929-codex-fold-double-miss.test.ts:232)。机制:Per-turn '[ACP status: …]' line keeps ordering the model to fold leftover small ranges right after a big fold — the opposite of what the compress receipt says #6928(4ccccab15)删掉 Compression conflict banner (bili v0.1.205, node v24.19.0, win32-x64) #4521 的 statusLine nudge 载体后,nudge 排程漂移,测试的旧锚点(PROXY_TOOL_AT=6/FOLD_AT=7)不再命中。该测试文件在 master 与本分支逐字节相同,本 PR 完全没碰 nudge 路径。
  2. architecture-docs 红也在 master:reference/architecture.md 模块图缺 src/responses-system-sections.ts([Bug] Inconsistent system prompt separator in Responses internal re-request breaks cache prefix | [Bug] Responses 内部重请求的系统提示分隔符不一致,破坏缓存前缀 #6922 的模块)。
  3. 你的 revert 是干净的:9d77de890 恰好删掉 6 行(statusLine 块);turn.statusLine 在分支上已不存在([PR] kernel+host: remove the #4521 armed-but-silent '[ACP status: …]' refresh line (#6928) #6929 之后 ProcessTurnResult 没有该字段,加回去是死代码且 typecheck 红——你上一条的「tsc 0」不成立,已自行纠正,确认无误)。

我做了什么:

本地验证(merged head 699c9ed):

  • npm run typecheck:0 错误
  • tests/issue2929-codex-fold-double-miss.test.ts(ci-fixes 版):1/1 通过
  • 本 PR 定向套件(history-generations / codex-response-side-boundary / codex-checkpoint-boundary / compaction-archive / cache-friendly-plugin / codex-local-compaction):45/45
  • tools/check-architecture-docs.mjs:all green
  • 已推送 699c9ed58(无 [ework:ci-held] 标记——本分支最终 head,唯一一次全量 CI)

八问:

  1. 是什么问题:本 PR CI 红(3 个 test shard 的 codex 命中率问题分析 #2929 + architecture-docs),阻塞合并。
  2. 什么原因导致的:不是本 PR——master 自身红。Per-turn '[ACP status: …]' line keeps ordering the model to fold leftover small ranges right after a big fold — the opposite of what the compress receipt says #6928 删掉 Compression conflict banner (bili v0.1.205, node v24.19.0, win32-x64) #4521 的 statusLine nudge 载体,但 tests/issue2929-codex-fold-double-miss.test.ts:232 的前置断言仍要求 pre-fold 请求里有 nudge 标记,排程漂移后旧锚点 miss;architecture-docs 红是 master 模块图缺 responses-system-sections.ts 行。本地干净 master 检出复现了同一测试同一错误。
  3. 影响范围与严重程度:master 级——所有包含该测试 shard 的 PR 都红;对本 PR:4 条 lane 红,完全阻塞合并。
  4. 怎么修复的:按 CI 失败协调政策,继承性红 = merge origin/ci-fixes(哨兵收敛分支),不在本 PR 手改测试。ci-fixes 的探针修复是 schedule-independent,比锚点重校准更稳。
  5. 是否有回归问题:无。merge 只带入哨兵测试/文档修复;本 PR 自身代码未动;你的 revert 移除了死代码 statusLine(本来也编译不过)。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

结论:本分支现在等 CI 全量绿 + owner 审核,你这边不需要再动作。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

这是一条过期事件。本事件报告的 3 个失败 test shard(windows 22,4 / ubuntu 22,1 / ubuntu 24,1,run 43927005796)全部属于旧 head 7726f1559,不是当前 head。

实时复核(本 run 内验证):

  • 当前 PR head = 699c9ed58(上一轮推送的最终 head,无 [ework:ci-held] 标记,即本分支唯一一次全量 CI)
  • run 43927005796 的 head_sha = 7726f1559,已被 699c9ed58 取代
  • 699c9ed58 已包含 ci-fixes merge(724741097 schedule-independent codex 命中率问题分析 #2929 探针 + 8ed56be99 architecture-docs 行)——正是那 3 个 test shard + architecture-docs 的修复
  • 新 head 699c9ed58 的 CI 正在跑(7 项 in-progress,test shard 已排队);本地已验证:typecheck 0 错误、codex 命中率问题分析 #2929(ci-fixes 版)1/1、PR 定向套件 45/45、architecture-docs all green

本轮无需进一步动作——报告的失败是过期状态,已在推送的 head 中修复。若新 head 的 CI 出现新的失败,会在下一轮 wake 处理。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

APPROVE (re-review on new head 699c9ed)

The delta from my last reviewed head (e924d6b) is two things, both clean:

  1. Round-6 master sync — the branch was merged with current master, bringing in other already-merged PRs' changes to src/plugin.ts (#6880 purpose header), src/server/prepare-responses.ts (#6922 responses-system-sections joiner, #6928 status-line removal, nudge cache-ledger), and src/server/relay.ts (#6922 joiner). None of these touch the PR's feature code — codex-checkpoint.ts, history-generations.ts, decompress-shared.ts, persist.ts, session.ts, store.ts, server.ts, headers.ts, acp-status.ts are all byte-identical to my last review; no conflict with the history-generation logic.

  2. A #2929 test fix (tests/issue2929-codex-fold-double-miss.test.ts, +40/−26) — the fold probe's hardcoded request-index anchor (PROXY_TOOL_AT/FOLD_AT) is now schedule-independent: the fake upstream arms on the first nudge-carrying request with ≥11 refs and folds on the following re-request, and the probe pins compress.messageTimestamps:false so its wire shape is hermetic regardless of the suite's BILI_MESSAGE_TIMESTAMPS preload. This fixes an environment-dependent flake (the nudge token schedule shifts with #4521/#6928/#4313 and the timestamp-rendering default). The invariants under test (post-fold re-request carries the summary; next steady turn byte-identical to the re-request up to the summary anchor) are unchanged. Correct, and a genuine robustness improvement.

The PR's own diff vs base is 25 files, no kernel/ or pi-subagents/ → HARD RULE not triggered. No new config/env/deps. CI on the new head: 0 failures (2 checks still pending). The full correctness / test / risk analysis stands from the prior reviews (ids 5911303447, 5911407014).

八问(与上一轮一致——PR 行为未变;本轮新增仅 #2929 测试的 schedule-independent 加固)

  1. 是什么问题:客户端/云端 compaction 后,被折叠的历史在 bili 侧不可达——decompress 拒绝、search_context 看不到、retrieve 解析不了旧 mNNNNN。
  2. 什么原因导致的:compaction 边界只留了 marker(preCompactionArchive),没把 ACP 状态(blocks/refs/messages/CCR)固化成可恢复快照;rebase 后 ref 空间从低位重新分配,旧 ref 失去指向。
  3. 影响范围与严重程度:所有走客户端/云端 compaction 的 codex/dsh 会话;compaction 后旧历史不可恢复——体验受损,非数据损坏(ref 不复用,无错指)。
  4. 怎么修复的:在真实 compaction 边界把当前 ACP 状态闭包成只读 "history generation"(加密 sidecar 持久化,ref floor + nextBlockId 钉住连续性),decompress/search/retrieve 跨代只读解析;三条 wire-truth 通道共享一个 (id,seq) 序号去重。
  5. 是否有回归问题:审过 live 路径——search_context header 措辞回退(已修)、nav note span 硬编码(已修)、self-alias 搜索漏 archives(已修);本轮 master sync 带入的 #6880/#6922/#6928 改动不触碰本 PR 特性代码、无冲突;#2929 测试加固不改生产行为。
  6. 是否破坏缓存:不破坏。nav note 是 ephemeral tail note 且触发轮为 null;x-bili-plugin-compressed 是响应头;prefix 字节不变。
  7. 是否改了设计方向:无架构转向——在既有 compaction-archive 机制上增加"可恢复"能力;边界判定仍走 wire truth,消息 id 不可变契约不变。
  8. 是否引入了新的配置:无新 config/env/依赖;仅新增响应头 x-bili-plugin-compressed(additive,0 时缺省)。

Verdict: APPROVE — clean. The new head is the previously-approved feature (byte-identical) + a round-6 master sync (no conflict) + a hermetic #2929 test fix. Ready for the human review tier.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Re-review r3 (head 699c9ed):delta = round-6 master sync(#6880/#6922/#6928,不触碰本 PR 特性代码、无冲突)+ hermetic #2929 测试加固(fold probe 改为 schedule-independent,修 env 依赖 flake)。特性代码与上轮逐字节一致;无 kernel/,无新 config/env/依赖;CI 0 failed(2 pending)。重新 APPROVE(review id 5931690536),待人工 review tier 合并。

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client-side and cloud compaction leave folded history unreachable

2 participants