Repository navigation
[PR] fix: dsh ledger floor follows the authored snapshot instead of the envelope peak - #5364
ranxianglei wants to merge 2 commits into
Conversation
The compaction guard stamped dshCompactionRefusedBytes from the envelope bytes BEFORE branching into authored/refused, so even the #3733 local answer — which genuinely shrinks dsh's raw store to our folded snapshot — ratcheted the planning floor to the pre-answer raw peak and kept it sticky for the session's life. On a small window the output clamp then planned against that stale peak forever: 128K window - 93K floor - margin ~= 33K max_tokens while the folded wire sat at ~49K, truncating long replies until the user inflated DSH's declared window to dodge the clamp (#5289). Authored branch now stamps the exact bytes of the snapshot sent (the ride-out scale from now on); the refusal branch keeps the #2490 sticky high-water byte-for-byte. Docs aligned at both sites.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7556-pr.5364.3148869This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5364.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 按失败签名( 标签:pr / bug / dsh / scope/wiring / p1 —— dsh 车道 compaction 后输出预算被永久钳死、长回复持续截断,核心输出能力对受影响会话不可用,按 owner 修订判 p1。 开始 PR 审核(方向关 → 回归 → 代码 → 测试 → diff),稍后给结构化结论。 |
(ai: vllm-qwen/qwen3.8-27b) PR 审核结论(独立重审,未照抄 issue 侧结论):diff 逐行重读、机制从代码重新推导、回归面逐项清点、CI 红分片逐一定位到日志行。代码与测试通过;CI 3 个红分片为 master 继承性失败(已报 #4599),master 转绿后 rebase/重触发即可,分支侧无需任何改动。 结构化八问
行为变更披露(旧→新):authored checkpoint 落地时,规划下限从「信封字节高水位、终身粘滞」变为「本次快照字节数(可低于历史峰值)」;refused 路径不变。PR 正文已披露,与本审核判定一致。 测试质量:新 e2e 走真实 startServer + mock SSE 上游,双向门都钉了(#3617):authored 衰减到精确快照字节 + 巨额预算回合解饿(>100K vs 修复前 ~33K)、refused 高水位逐字节、authored→refused 组合再棘轮;RED→GREEN 声称的数字自洽(372242 = 372_000 字符 filler 的信封字节,704 = 快照体 < 10KB sanity 界内)。既有 dsh-authored-compaction 断言从 typeof 加强为精确字节相等,有牙。 CI 状态(head b7f40c2,merge-commit 树):static-gates/build/mysql-contract/gate 全绿;14 个 test 分片 11 绿;红的 3 个(ubuntu-24-2 / ubuntu-22-2 / windows-22-3)各只挂 2 条 web-i18n #1024(q_pack 占位符/死键)——master tip 自身同样 3 片同签红,根因 判定:代码审核通过,可合——待 #4599 所报 master i18n 红清掉后 rebase/重触发转全绿,由人合并。 |
Problem (#5289)
A small-window DSH session (reporter: local llama.cpp, 128K window) got its output truncated permanently after its first dsh native-compaction attempt: bili's output clamp planned against a raw-ledger floor that had ratcheted to the compaction ENVELOPE's byte count (~93K tokens) and never decayed — even when bili ANSWERED that compaction locally with its own folded snapshot (#3733), which genuinely shrinks dsh's store to ~50KB. Result:
max_tokensclamped from 384000 to ~33K on every subsequent turn while the folded wire sat at ~49K, truncating long replies at stop_reason=length until the user inflated DSH's declared window to 256K just to dodge the clamp.Root cause: the guard stamped
dshCompactionRefusedBytesfrominboundBytesBEFORE branching into authored/refused (src/server/handle.ts), so both paths inherited the pre-answer raw peak, and the value stayed sticky for the session's life.Fix (option A from the in-thread decision request, owner-approved)
Buffer.byteLength(authored.body)), replacing any earlier high-water — the snapshot IS dsh's ride-out scale from now on.Math.max(prev, inbound)), byte-for-byte — the dsh压缩与bili压缩冲突 #2490 monster-output protection stays intact.dshLedgerFloorTokens()documents both regimes).Behavior change (old → new)
Consequence: small-window sessions whose compaction gets an authored answer no longer starve (the incident); sessions whose compaction keeps being refused behave exactly as before. The #2490 kill chain stays closed: post-checkpoint store growth is bounded by each turn's clamped output, and the fail-open edge (floor ≥ window) can only trigger on genuine overflow now.
Config surface
None added or changed.
BILI_DSH_AUTHORED_COMPACTION/dsh.authoredCompactionsemantics untouched.Tests
tests/issue5289-ledger-floor-authored-decay.test.tspins BOTH gate directions (Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617): authored decay to exact snapshot bytes + giant-request turn unstarves (>100K vs ~33K pre-fix); refusal high-water byte-for-byte; authored→refusal composition re-ratchets via Math.max. Verified RED on the pre-fix code (floor=372242 vs expected 704) → GREEN post-fix.tests/dsh-authored-compaction.test.tsledger assertion from typeof to exact snapshot-bytes equality.Labeled drive-by fix in the same PR:
docs:commit aligning the stale "Default OFF" docstring on BILI_DSH_AUTHORED_COMPACTION (knobs.ts) with the ON default shipped since 0.1.203 (#3901 flip) — doc/code mismatch found while working this mechanism. No behavior change.Closes #5289