Repository navigation
[PR] fix(persist): keep k̂ model provenance and the emergency-shrink marker across restarts - #6775
mariopasquali wants to merge 5 commits into
Conversation
(ai: opencode/qwen3.8-27b) 标签: bug + scope/storage + p2(持久化重载丢字段导致的 k̂ 模型门控静默失效,属存储域缺陷;非不可用/非缓存泄露,故 p2)。 查重: 不重复。#5915 修的是 #5914 的 context-estimate 三字段(contextEstimateTokens / contextEstimateCalibrated / lastUsagePayloadUpper),与本 PR 的四个字段不重叠,本 PR 已显式排除该部分;无其他在途 PR 触碰这四个字段。 Review (PR #6775, head 36b13ad, base f21b601 = current master, 0 behind)Claims verified against code:
Tests — real, with teeth (verified both directions):
CI (live, head 36b13ad): fully green — 11/11 Diff: 7 files, +146/−16, every line on-purpose; no lockfile/whitespace churn; no config surface, no version bump, no kernel/ touch. Validators match the surrounding restore discipline exactly (finite + band / non-empty string, corrupt → undefined, legacy files unchanged). Two notes for the owner (not blockers to the code):
结构化八问
结论:代码可合并(CI 全绿、测试有牙、diff 干净、base 最新);唯一待决项是缺 issue/ |
(ai: opencode/qwen3.8-27b) CI run report — PR #6775, attempt 1/6: no action needed — the reported conflict no longer exists (stale state). 七问 summary
结构化八问
判定:本次运行无需任何 push/修复;PR 当前 head CI 全绿(37 success + 13 skipped,0 失败)、merge 干净,owner 可直接合并。若后续自动唤醒仍看到同一陈旧 dirty 状态,可直接跳过。 |
[ework] CI fix verified green ✓ |
…6775 persisted fields) — wire shas unchanged, persisted digests only
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
Resolve the storage-render golden conflict by regenerating with scripts/update-storage-render-goldens.ts on the merged tree: stats section carries this PR's four restored fields, metadata section carries master's change; stateDigest/stateDigestAligned are the new union values.
(ai: opencode/qwen3.8-27b) CI run report — PR #6775, attempt 1/6: real conflict this time (master moved) — resolved and pushed. 七问 summary
结构化八问
判定:冲突已解决并推送(final head |
# Conflicts: # tests/golden/storage-render/anthropic.json # tests/golden/storage-render/chat.json # tests/golden/storage-render/google.json # tests/golden/storage-render/responses.json
…6775 persisted fields) — wire shas unchanged, persisted digests only
…6775 persisted fields) — wire shas unchanged
|
Your fix is merged — it landed via the wave-11 batch merge (#6827 → master GitHub did not auto-flip this PR to Merged because the head of the branch moved after the batch snapshot — the new tip ( Closing as merged-via-batch. Thanks for the fix and the golden coverage. |
Master advanced (548e396..a446a3c) after the previous conflict fix, re-breaking the merge. The only conflicts were the 4 storage-render goldens, which BOTH sides had regenerated (PR standing-rule reuse vs master ranxianglei#6775 persisted fields). Resolved by regenerating from the merged tree (scripts/update-storage-render-goldens.ts) — the resulting digests match neither side, confirming the true combined behavior. Verified: storage-render golden test 5/5, typecheck clean, PR host-nudge/prompt-cost/marker tests 74/74 green.
…eceipt reword + #6775 persisted fields) Master's compress success receipt change (497efc7, PR #7105) and the #6775 persisted-field work moved the persisted message shas and state digests. Regenerated all four storage-render goldens on the final rebased tree with scripts/update-storage-render-goldens.ts: wire shas are now byte-identical to master's pins; the only remaining delta vs master is this PR's own post-retire persist contract (retired-id anchor swap + digest fields).
…nder golden conflicts Both sides regenerated tests/golden/storage-render/*.json against their own trees: the PR side pins the image-rescale armed-state in session metadata (#4789 Ask #2), master side gained the #6775 persisted fields (75a4538, wire shas unchanged). Resolution: take the union tree, regenerate all four goldens with scripts/update-storage-render-goldens.ts on the merged code. Verified: only stateDigest/stateDigestAligned/sectionDigests.metadata move (3 fields per file); every per-turn wire sha is byte-identical to master — no wire contract change. Targeted suites green: golden-storage-render 5/5, fold-reconcile + issue3400-image-rescale 107/107, typecheck clean.
…ange Rebased onto master a446a3c (master moved the same digests via #6947 reply-stash-out-of-messages-table and #6775 persisted fields). Regenerated on the rebased code with the official script (node --import tsx scripts/update-storage-render-goldens.ts): only stateDigest/stateDigestAligned and the blockContents section digest moved on all four wires; state/stats/metadata keep master's values and wire turn digests are byte-identical.
…lict at 0.0.200 Master advanced past the PR base again (batch11 wave11 #6827, lean-compress receipt #7105, wire-client-sidecars #7083, p1 batch b2/b3, #7087, #7101 -> kernel 0.0.199, storage-render goldens regenerated for #6775 persisted fields, 400 files). Content hunks auto-merged (kernel/src/compress.ts, kernel/src/types.ts, all four storage-render goldens); the only conflicts were the three kernel version lines, resolved at 0.0.200 = master's 0.0.199 + this PR's kernel/src change, per the CI-enforced kernel version discipline. Targeted local verification: tests/golden-storage-render.test.ts 5/5, tests/storage-state-fields.test.ts 2/2, kernel issue6116/issue3769/ hide-consumed suites 27/27.
…eceipt reword + #6775 persisted fields) Master's compress success receipt change (497efc7, PR #7105) and the #6775 persisted-field work moved the persisted message shas and state digests. Regenerated all four storage-render goldens on the final rebased tree with scripts/update-storage-render-goldens.ts: wire shas are now byte-identical to master's pins; the only remaining delta vs master is this PR's own post-retire persist contract (retired-id anchor swap + digest fields).
…ange Rebased onto master a446a3c (master moved the same digests via #6947 reply-stash-out-of-messages-table and #6775 persisted fields). Regenerated on the rebased code with the official script (node --import tsx scripts/update-storage-render-goldens.ts): only stateDigest/stateDigestAligned and the blockContents section digest moved on all four wires; state/stats/metadata keep master's values and wire turn digests are byte-identical.
(ai: claude-opus-5-5)
Two more stats fields that buildRecord writes but buildSession drops on reload, in the same family as #2129 and #5914.
calibratedEstimateModelandcalibrationRing.model([Bug] 上下文展示估算 206K,usage 返回后为 98K:希望校准估算并区分安全上界 #2117) are not restored. After a restartcurrentCalibrationFactorsees no model, so a k̂ learned on one model is also applied after a switch to another model on the same route, which the model gate is meant to prevent. Now both are restored when they are a non-empty string, and anything else is dropped. Older files without a model keep today's behavior.emergencyShrinkAtandemergencyShrinkEstimate(set by armFailureShrink) are not restored, while the raised baseline they explain is. After a restart, acp_status shows the raised baseline without the "EMERGENCY SHRINK ARMED" line. Now both are restored when valid. A real usage settlement still clears them.Tests:
tests/persist-calibration-model.test.tsandtests/persist-emergency-marker.test.ts, in legacy and full storage modes. The storage-render goldens are regenerated with the repo script; only the stats digests change.Checked on this branch: typecheck and unused-export gate clean; full suite 12,252 tests, 12,177 pass, 1 fail, 74 skipped. The one failure is the flaky corrupt-index test noted below. Without the fix, 4 of the 12 new tests fail.
Not included: the context-estimate restore for #5914, because #5915 already has the same change. Our test build carries the same change, and its full suite passes.
Side note:
tests/storage-durability.test.ts(the two corrupt-index tests) is flaky on master too. It failed in 4 of 6 runs on f21b601 for me. It flips a fixed 4 KiB range at one third of the file, and sometimes quick_check doesn't catch that.