Repository navigation
Conversation
…n ref-ledger reset detectGenerationBoundary() already proves that the persisted ref ledger belongs to a previous generation: >=2 distinct above-frontier citations at request ranxianglei#1 (ranxianglei#4305). It only recorded a standing note, so the compression ledger was never repaired. Observed on 0.1.212 with a ZCode client (ranxianglei#6061, ranxianglei#5589): acp_status advertised the current generation (highest allocated ref m00314) while compress validated against the stale map (highest allocated ref m159141, 586 blocks) and rejected every live ref with "every ref is unknown to this session [cause: stale-ref]" — 20 consecutive failures, circuit breaker armed, and the nudge kept offering the same unreachable ranges. The detector's verdict is exactly the evidence the native-compaction rebase has always required, so arm it there: markNativeCompactionBoundary() sets pendingRebase, and the next request runs resetSessionCompression() + reserveRefsThrough(), re-anchoring the map onto the generation the client is actually minting. Also honour a pending boundary at the head of the anthropic lane. Its rebase call sits behind the dsh/codex client-side-compaction signature, which a plain model or upstream switch never produces, so an armed boundary would otherwise wait forever on that lane (openai/google/responses reach reconcile through their own branches; responses already reconciles unconditionally). Verified: npm run typecheck clean; tests/generation-boundary.test.ts 12/12.
|
Verified locally on 0.1.212 that the second hunk is load-bearing: stopping the daemon, setting \pendingRebase\ and restarting left the session untouched (blocks 586 -> 586, refs 2,994 -> 3,004 rows still in the old namespace, \compress\ diagnostics unchanged), because the anthropic lane had no consumer for the armed boundary. Evidence and the probe table are in #6061. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Duplicate screening (查重): not a duplicate. I searched open PRs and issues for the same fix — arming
This PR is the first to arm the rebase from Mechanism analysis (initial): I verified the two-file diff and the underlying repair mechanics:
Key mechanic I verified: the rebase ( Timing: on request #1 the detector latches + arms the boundary (after Main gap I've identified so far: the PR changes only the 2 source files — no new test asserts the new arming behavior (that I'll post the full structured 8-question review conclusion next. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Code review — PR #6362Verdict: mechanism is sound and consistent with the existing repair pattern; one gap — no regression test for the new arming behavior. I've written and verified the test locally (14/14 pass, typecheck clean) but cannot push it to your fork (no push permission). Recommend adding the test before merge. ① Direction (原 issue)The PR fixes a real, well-documented defect (#6061): a ref-ledger reset that arrives without a client-side compaction signature (plain model/upstream switch) leaves the session permanently split — The fix is the right shape: arm the rebase from the detector (whose verdict is precisely the evidence the rebase has always required), and add a head-of-lane reconcile on the anthropic lane (whose existing reconcile is buried in the dsh branch). This is the same repair, armed from a new, evidence-based site. ② Regression review (回归)I traced the call order in
This matches the existing pattern in I ran the existing rebase-floor suite ( One subtlety worth noting (not a bug): if both the head reconcile and the dsh branch could fire on the same request, the head reconcile fires first (it's earlier in the function) and sets ③ Code review (代码)Both changes are minimal and correct:
Minor phrasing note (not a functional issue): the PR says the rebase "re-anchors the map onto the generation the client is actually minting." The actual mechanic is more subtle: the rebase does not re-anchor onto ④ Test effectiveness (测试) — the gapThe PR changes only the 2 source files — no new test asserts the new arming behavior. The 12 existing tests in Per the review discipline (a gate/arming change needs both directions asserted: "triggers when it should" AND "does NOT trigger when it should not"), I wrote two tests and verified them locally: test("#6061: detection arms the native-compaction rebase (pendingRebase=true)", () => {
const s = sessionWithFrontier(10);
const messages = [
msg("a", "Compressed b7 covering m00042–m00051, summary attached."),
msg("b", "The earlier acp_status report listed range m00060–m00071 as compressible."),
];
const active = detectGenerationBoundary(s, messages);
assert.equal(active, true, "note rides the request that detected the residue");
const boundary = s.metadata?.nativeCompactionBoundary as Record<string, unknown> | undefined;
assert.ok(boundary, "rebase armed on detection");
assert.equal(boundary?.pendingRebase, true, "pendingRebase set so the next request's reconcile fires");
});
test("#6061: no detection → no rebase armed (negative)", () => {
const s = sessionWithFrontier(10);
const messages = [msg("a", "compress m00003–m00007 please")];
assert.equal(detectGenerationBoundary(s, messages), false);
assert.equal(s.metadata?.nativeCompactionBoundary, undefined, "no rebase armed without detection");
});Local verification (targeted):
I cannot push these to your fork (the token has ⑤ Diff cleanlinessClean: 2 files, +26/−6. Every line relates to the PR's purpose. No unrelated changes, no whitespace churn, no lock-file drift. ⑤b Code qualityPasses the bar: naming is clear, no dead code, no magic numbers, comments explain why (the #6061/#5589 provenance), style matches the surrounding code, no new dependencies. 结构化八问(中文)
合并判定:机制正确、无回归、diff 干净;唯一缺口是缺一条针对新武装行为的回归测试(我已写好并本地验证 14/14 + typecheck 干净,但无 fork push 权限推不上去)。建议把上面两条测试补进 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI status (verified live via mirror cache): green — 30 checks, 0 failed, 0 pending. All So the only outstanding item is the missing regression test (provided in my review above, verified locally 14/14 + typecheck clean). Once that's added, this is ready to merge. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Thanks — that local probe confirms exactly what the code analysis shows: the anthropic lane's only existing This matches the The only outstanding item remains the missing regression test for the arming behavior (provided in my review above, verified locally 14/14 + typecheck clean). Once that's added, this is ready to merge. |
|
Landed via batch PR #6482 (merged) — closing as superseded. |
Problem
A ref-ledger reset that arrives without a client-side compaction signature leaves the session permanently split:
acp_statusadvertises the live generation whilecompressvalidates against the stale map, so it rejects every live ref.Captured on 0.1.212 (ZCode client, single session id):
acp_status→ live ledger, highest allocated refm00314.compress→session highest allocated ref=m159141 … session history=586 compression(s), 586 block(s), replyingevery ref is unknown to this session [cause: stale-ref].refs2,994 rows spanningref_num134828..159141,blocks586 (78 active) in that namespace,messages23,031 rows overseq134550..159223, andsessions.metadata_json(52 keys) with nonativeCompactionBoundary.Why it never healed
detectGenerationBoundary()already proves the ledger belongs to a previous generation (≥2 distinct above-frontier citations at request #1, #4305), but by design it only records a note — no storage rewrite, no ref-space surgery.reconcileNativeCompactionBoundary()is the repair, and it returns early forever unless something armedpendingRebase:Every existing arming site sits behind a client-side compaction signature (dsh/codex branches), which a plain model or upstream switch never produces.
Change (2 files, +26/−6)
src/generation-boundary.ts— when the detector latches, alsomarkNativeCompactionBoundary(session). Its verdict is precisely the evidence the rebase has always required; the module header is updated so it no longer claims to be display-only.src/server/prepare-anthropic.ts— honour a pending boundary at the head of the lane. Without this, the armed boundary would wait forever here, because this lane'sreconcileNativeCompactionBoundary()call sits inside the dsh branch.Next request after arming runs
resetSessionCompression()+reserveRefsThrough(), re-anchoring the map onto the generation the client is actually minting. Cost: pre-reset archive blocks are dropped — they are already unreachable, since the client's refs restarted atm00001.Verification
npm run typecheck→ clean (kernel + pi-subagents rebuilt from this tree).node --import tsx --test tests/generation-boundary.test.ts→ 12/12 pass.Notes
reconcileNativeCompactionBoundary()through their own dsh/codex branches, and responses reconciles unconditionally; I left them untouched to keep the diff reviewable. If you'd rather have one uniform head-of-lane guard, say so and I'll widen it.{"nativeCompactionBoundary":{"at":<ms>,"pendingRebase":true}}intosessions.metadata_json→ start it. Patching the DB while the daemon runs is ineffective — it rewritesmetadata_jsonfrom memory on the next flush.