Repository navigation
[PR] fix(persist): keep the context estimate and usage anchor across restarts (#5914) - #5915
ranxianglei wants to merge 2 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8573-pr.5915.909738aThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5915.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复——本线程(#5915, GitHub PR)是 #5914 的唯一在途修复 PR;已核对镜像全部 open [PR] 行,无第二个 PR 针对同一线程/主题。 标签: 接下来:拉取分支核对 diff 与原 issue 的验收标准、本地跑定向测试(新套件 + 相邻持久化套件)、读镜像缓存确认 CI 状态,结论按八问回复。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) PR #5915 审核结论(对应 issue #5914)代码层面:可合并。 diff 最小、方向正确、红绿自证成立;当前唯一拦路的是 master 继承性 CI 红(与本 PR 无关,已定性并报到 #4599)。 结构化八问
验证记录(本地定向,非全量)
收工判定代码就绪,等 CI。 待 ci-fixes 哨兵收敛 golden 修复后,PR 分支一次普通 push/rebase 即可触发真实 core 矩阵重跑转绿,然后由人合并。在此之前不建议加 ci:full 标签(会在已知继承红上空烧一整轮矩阵)。 |
🔶 需要决策 背景一句话:平台把本线程的标签同步到上游 GitHub PR 时,会触发 ci.yml 的 待决问题:标签同步触发的 skip-scoped CI run 是否应当保留?它让「分支可见 check 状态」不再可信——任何评审者(人或 agent)看 branch status 都会被误导,只能靠翻 run 历史还原真相。 选项:
我的推荐:A(若上游侧确实不需要标签可见性);否则 C 作为底线 + 在 #4599 持续记录被遮蔽实例。不决定的默认行为:维持现状(C 的事实状态),我不做任何单方面的 CI/平台改动。 |
Closes #5914
What & why
buildSession's restore whitelist drops three persisted stats fields even thoughbuildRecordwrites them (via the...session.statsspread):contextEstimateTokens+contextEstimateCalibrated(the per-send billing-caliber estimate pair, #2117) andlastUsagePayloadUpper(the usage anchor's own payload snapshot, #4805). After a restart:staleSmallAnchorFallback([Bug] statusInputBaseline falls back to lastUsageGradeTokens instead of the calibrated local estimate — so one 4.7k side-request sample blocks folding for 4 hours | #1595 承诺的"改用本地估算"兜底在 statusInputBaseline 里没有实现,一次 4.7k 侧请求样本即可挡住折叠 4 小时 #4383, readscontextEstimateTokens) and theeffectiveTokenCountsize guard (requireslastUsagePayloadUpper > 0).The fix adds the three fields to the restore whitelist with the same validation discipline as their siblings (finite non-negative number / strict boolean; legal
0andfalsepreserved, corrupt values rejected). Single choke point: every loader funnels throughbuildSession, so legacy / shadow / full storage modes are all covered by this one change.Behavior change (intended — it IS the fix)
After a restart, sessions with persisted values now show the restored estimate immediately instead of the upper-bound fall-through, and the two guards above are armed from the first post-restart read. Old behavior (upper-bound display + disarmed guards until the first send/settle) was the bug. No change to live-session behavior, wire format, or persistence format.
Config surface
None — no config field added, renamed, or re-semantics'd.
Verification
tests/issue5914-restart-estimate-anchor.test.ts(7 tests): round-trip of the reporter's fixture values including display caliber; usage-grade reading still outranks the restored estimate; legal 0/false preserved; legacy records without the fields keep today's behavior; corrupt values rejected at restore; in-memory-only transients (pendingFoldUsage,lastLocalTextEstimate(+Origin)) still dropped; both decision guards armed from the first post-reload reading.issue2129-restart-measurement-state+persist-stats-roundtrip; typecheck clean. Full-suite verdict = remote CI.Note:
tests/issue3157-persist-durability.test.tsshows 2 local failures (a full-session deep-equal drift aroundccrReconcilePending) identically without this diff — pre-existing and unrelated to this fix; flagged for visibility, deliberately not touched here.