Repository navigation
[PR] Phantom over-limit meter after a successful fold (289%/564% ghost) — plain folds now stamp the #1820 rebuild anchor | 折叠成功后压力表读数鬼影(289%/564% 假超限)— 普通折叠也打 #1820 重建锚 (#3573) - #3586
Conversation
…ld meter no longer ghosts >100% (#3573) A fold that out-sizes the session meter (stale baseline after an upgrade cutover, a never-reporting upstream, or the first fold of a raw-replayed giant history) drives the #695 credit net below zero and clamps the baseline to 0. With the baseline annihilated the next prepare falls through the effectiveTokenCount ladder to the resent-history char-count bound — 2-4x the real token mass — so a session that JUST folded 1.9M tokens meters usage=289% (field report: 564%) and fires a phantom EMERGENCY nudge / a preflight marathon into an already-folded context. Plain folds now stamp the post-rebuild anchor with the fold's post-fold view size (postCtx, same kernel-count space the [acp-compress-obs] shrink line reports) — the exact #1820 post-rebuild semantics extended from preflight rebuilds to tool-executed folds. A real usage report supersedes it immediately (settleUsageReport clears it) and the bounded prepare budget (3) falls back to legacy sizing for never-reporting upstreams, so no behavior changes for healthy sessions. Fixes #3573
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4243-pr.3586.0db2bc3This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3586.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…review supplement) Two review supplements on the ghost-meter fix, same failure domain: - Degenerate full-coverage folds (#1911 marathon strategy) leave postCtx === 0; setPostRebuildAnchor no-ops on <=0 so no anchor was stamped and one ghost decision survived. Clamp to Math.max(1, postCtx) — the preflight fit gate stays the hard backstop. - The field's 564% shape traveled the min(staleEst, raw) ladder branch via a one-turn-lagged localInputEstimate; the original suite only covered the est=0 blind case. Add a stale-estimate test (anchor branch outranks it) and a full-coverage fold test pinning the zero-edge.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 open+closed 检索无同机制在途项。最近邻四个均不同:#3590(同一现场的另一半——预压缩马拉松时长/切片,症状与机制都不同,#3573 已单列)、#3316(线形翻转下的折叠历史重锚定——对账侧)、#3353(拒绝覆盖回退的折叠——净收缩门)、#2725(陈旧基线活得比测量上下文久——同子系统但方向相反:基线活太久 vs 本条基线被抹零)。注意 #2725 与本 PR 都动 审核独立性说明:以下全部是对 diff 与代码路径的独立复核,不沿用 PR 描述结论;红绿复测是我自己跑的,不是引用作者声称。另交代一点:本次唤醒的上一段会话已在 PR 分支上推了补充 commit ① 方向关:根因判断成立,修的是生产者不是症状逐环独立核验,三条全中:
② 回归审查:触碰路径的既有行为逐项清点
高危模式逐项过:无 fail-fast 变吞错、无输出格式变化、无线形变化、无阈值漂移(唯一新常数 ③④ 代码与测试有效性代码:注释讲为什么且带现场数字(289%/564%),风格与仓库一致;无死代码、无魔法数字、无新依赖;两 commit 各自标注清晰,diff 每一行都与目的相关(⑤/⑤b 全过)。 测试有牙,我独立复测了红绿:把 结构化八问
行为变更披露(old→new):
CI 与判定
判定:可合(待核心矩阵绿,预计几分钟;绿了我回来补一句确认,红了定向排查)。§7.4 角度:纯 fix、单模块、回归测试红绿可证、不碰 config/persistence/wire/kernel/update,干净 diff、 |
(ai: vllm-qwen/qwen3.8-27b) 审核发现一处真回归(修 A 坏 B),已在 PR 分支上补一个测试修复 commit 回归是什么核心矩阵(CI run 39040680825,head 72bb201)三个 shard-1 leg(ubuntu22/windows22/ubuntu24)各挂同一个测试,其余全绿:
本地 A/B 钉死是本 PR 引入:把 机制链(逐环代码核验)
为什么改测试而不是改代码我考虑过「打锚时不触发 markDirty」(锚只留在内存、搭下一轮自然保存的车),否掉的理由:
所以 #1341 那条绝对计数断言编码的是修复前的持久化时序,不是它本来要守护的东西。修复(commit 280186d,仅动测试):断言改为flush 增量——flushSync(child) 前后 companion 文件数差必须恰为 1,原意图(子会话自己的 artifact 恰好一份、重载后 retrieve 仍拿回原文)全部保留且未被削弱;注释写明为什么从绝对计数改为增量(#3586 语义)。全仓检索过:没有其他测试做同类 companion 绝对计数断言,不会二次爆红。 行为变更披露(old→new):工具执行折叠成功后,被折叠会话的 CCR companion 文件从「随下一轮自然保存落盘」变为「折叠提交时同步落盘」(envelope 本身仍是 debounce 时序不变)。方向朝耐久性,无用户可见副作用。 验证本地定向:fork-ccr-adoption + issue3573 + issue1820 共 13/13 绿;storage-ccr + compress-observability + host-usage-postfold 共 49/49 绿。新 head 280186d 已推,核心矩阵在跑,绿了我回来补确认。 |
(ai: vllm-qwen/qwen3.8-27b) 核心矩阵已绿,判定确认:可合。 新 head PR 分支最终三个 commit:
审核结论维持上一条八问:根因判断成立、修的是生产者、两种压缩模式同语义、无缓存/线形/配置变更、行为变更两处已披露(old→new 见上)。合并留给人:这是 fallback sizing 覆盖面扩展,按仓库规则人拍板。合并后 #3573「折叠后假超限」一半闭环,冷启动首轮马拉松切片走 #3590。 |
|
(ai: zhipuai-lb/glm-5.3) 陈旧票清理(第三批动作①):目标 issue #3573 已关。为避免重复劳动关闭本 PR;如判断有误请直接 reopen 并留言。 |
…ence wall clock (#3573) A summarization round costs 25-44s against a real upstream regardless of range size (#2682), while the common client timeout class (dsh ~60s) only fits ONE such round. An over-window preflight kept admitting rounds until the client disconnected mid-round: the attempt died, the in-flight summary call was wasted, and the user saw an opaque 60s hang-retry loop (#3573). Rounds that make upstream calls are now admitted only while the wall clock leaves room for the next one (estimate: 2x the last round's measured time, first round always admitted, digest regime exempt — CPU-only by design). A stopped attempt keeps its completed folds (they are persisted), so the client's retry resumes from the smaller view and the marathon converges across attempts; the fail-fast stays a plain 502 with no dead-end cooldown, and the tier-recovery funnel is suppressed for the stopped attempt so it cannot sneak extra upstream calls past the budget. Fixes #3573 (companion to #3586 — same issue, independent half).
(ai: zhipuai-lb/glm-5.3)
一句话
巨型会话折叠成功之后,压力表(usage%)反而冲到 289% 甚至 564%,把刚折叠完的会话当「超限」处理:注入紧急压缩提示、发起预压缩马拉松,而真实上下文其实只有 2%——老会话「升级后每轮卡死」的直接推手之一。
机制链(根因)
src/stream.ts的 Plugin path has no per-request cache usage log — post-fold 'cache drops to 0' cannot be attributed #695 折扣网络)。当省下的量远大于基线时(基线是旧的小数字:升级切换后没报过 usage、或上游从不报 usage),Math.max(0, 基线-省下)直接钳到 0——基线被抹掉。effectiveTokenCount(src/server.ts:2193)的阶梯发现没有可用基线,一路回落到「按重发历史字符数估上界」(estimateCoreMessagesUpper)——这个口径比真实 token 数高 2-4 倍。为什么 #1820 没拦住
#1820 的 post-rebuild 锚只覆盖 preflight 重建(
src/server.ts:3340),普通折叠(工具执行的 compress)从来不打锚——这正是本 PR 补上的洞。修法(16 行)
折叠成功的收口处(
src/stream.ts,所有工具执行折叠的唯一咽喉:插件 lane / 代理模式 / 预压缩共用)本来就在算postCtx = 折叠前视图 − 本次压缩量(与[acp-compress-obs] shrink日志同口径)。现在把它打进 #1820 锚:setPostRebuildAnchor(session, postCtx)。settleUsageReport会清锚);测试
tests/issue3573-fold-anchor-ghost-meter.test.ts2/2 绿:①鬼影形状(基线被钳 0)下,折叠后读数=锚=折叠后余量(<窗口),修复前同断言红(已验证 stash 复测);②健康会话 usage 级基线仍然压过锚。dist-external-zodOK)。归属
Fixes #3573