Repository navigation
[PR] feat(compress): defer fold materialization through compress bursts — one seam per burst (#3003) - #3742
[PR] feat(compress): defer fold materialization through compress bursts — one seam per burst (#3003)#3742ranxianglei wants to merge 12 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4575-pr.3742.d902d46This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3742.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 检索 open+closed 的 issue/PR(按 "defer materialization"、fold seam、burst 等失败签名):
开始按 PR Review 规范审:① 原 issue 方向 → ② 回归 → ③ 代码主关 → ④ 测试有效性 → ⑤/⑤b diff 与代码整洁。初扫已发现一处 diff 整洁问题(仓库根目录提交了 |
…ve committed debug probe (#3742 review) Review cleanup for the #3003 fold-hold PR: - PrepareHoldDecision is only used inside this module - drop the leading export (unused-exports gate INTERNAL_ONLY finding). - delete _resetFoldHoldsForTests: a no-op with zero references (gate DEAD finding); tests construct fresh sessions per case. - remove tmp-debug-3003.mts: committed root-level debug probe, not part of the change. No behavior change.
(ai: vllm-qwen/qwen3.8-27b) 标签: pr / scope/kernel / p2 — 核心压缩逻辑的功能 PR(压缩引擎/上下文管理),非缺陷;不打 bug。未打客户端标签:改动在共享的 proxy/loop 宿主代码,不涉及任何特定客户端接入层。p2 依据:若 hold 门控失准最坏是成本上升(多付 seam),可用性不受影响,且设计上「永不劣于现状」。 审核结论(独立重做,非复读 PR 描述):方向正确、机制成立、测试有牙。发现 2 处 CI 红 + 1 处 diff 卫生问题,已按小问题直接修纪律修掉并推到 PR 分支( 结构化八问:
关键正确性点(逐个独立验证过,不依赖 PR 描述):
已顺手修掉(独立标注 commit
小提醒(不阻塞):PR 正文缺字面的「config surface」小节标题(本仓规范要求配置类 PR 在此标题下报告新增字段)——knob 已在正文机制表里写明、文档与 guard 齐全,判为格式瑕疵;合并前补一行即可。 收工判定:审核完成,修复已推。代码级结论为可合入;最终判定等 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI 状态更正 + 全量矩阵已在跑,先别合。 上一条回复说「等 23509a0 的 CI 绿」——复查后需要更正:当时 PR 上显示的绿只是 guard 车道全绿,单元测试矩阵一行都没跑过。原因(已逐 run 核实):
处置:已给 PR 加上 请在结果出来前不要合并。 全量跑完我在这里贴最终确认(预计 20–40 分钟)。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 全量 CI 已在 23509a0 上跑完(ci:full 波次,13 个工作流)。结论:不可合并——主矩阵 12/12 test 腿全红(约 164 个独立测试),外加 OC-WS 车道一条已对照 master 基线确认的回归。机制全部查清,等你拍板方向。 一、CI 全景(head 23509a0,ci:full)
二、主矩阵红:单一机制,不是 164 个 bug抽样断言实锤:
作者本地只验证了新文件 + storage goldens + 29 文件批次,没跑存量 pin 套件——典型「首遍不完整」(§7.5)。注意:这些测试不是可以随手改掉的摆设,它们是生产 cache 承诺的守卫;迁移时每个 case 必须在新 seam 位置重新证明稳定性,不能只把断言后移一行了事。 三、OC-WS 回归(已钉死归因)基线对照:我手动 dispatch 了 master(6f2b113)的同车道 workflow——两个 job 真实执行且全绿;PR head 同车道红。归因 = 本 PR。 失败断言 机制(代码级): 实质危害:hold 窗口内上游链累积着未被折叠的字节,而 bili 的窗口压力核算已按 folded 态走——burst 越长盲区越大;materialization 时才 full reset 恢复一致(有界,不是永久失同步)。附带说明:这条 lane 历史上一律 hollow(PR 无 ci:full 标签时 gate 跳过真实 job,schedule 智能 cron 在 master HEAD 不变时也跳过)——本次是它第一次真跑,所以此前从未暴露。 修法方向(建议,属本 PR 正确性范围,不依赖下面的 A/B 决策):fold commit 时失效 WS checkpoint——例如 四、八问
五、选项对比
判定:拦下,不合。 等你拍 A/B;拍完我可以在本 PR 分支上先把 WS checkpoint 失效做掉(无决策依赖部分),测试迁移按你的决定推进。 |
…one seam per burst (#3003) Consecutive compress rounds currently pay one cache seam each: every committed fold rewrites the outbound prefix immediately, so the next re-request inside the burst re-pays the whole cache. #3670 already made the commit itself all-or-nothing for length-class failures; this closes the success-path seam. Design (fold-hold): - The fold still commits to session state immediately (ledger, refs, consumed classification, block contents persisted — restart-safe). - The outbound VIEW defers while the burst continues: any request that carries a NEW successful compress result renders held blocks raw (prefix byte-identical → full cache hit on the raw tail), the first request WITHOUT a new fold result materializes all held blocks — exactly one seam for the whole burst. - Window pressure (tokenCount >= 90% of the effective window, below the 95% emergency band) materializes immediately; preflight/emergency folds pass holdFold:false and render folded on the rescue view. - Loop lane: refresh condition now skips the settle re-request refresh while folds are held (raw re-request view is prefix-stable with the request that triggered it — better than today, where the settle round itself pays a seam); relay refreshFolded callback materializes. - Hold view is a clone with held blocks {active:false, expanded:true} (the kernel's sanctioned render-raw channel, sync.ts deliberately leaves expanded blocks inactive; fork-adoption precedent). Active flags are restored before state adoption; a genuine user decompress mid-burst is never resurrected (keyed on pre-clone activity). - Nudge ranges fully covered by held blocks are filtered from the injected nudge during hold legs (the view cannot fold them; kernel already-covered refusals would spin #156). - Knob: BILI_DEFER_MATERIALIZATION / compress.deferMaterialization, default on; =0 restores the eager contract everywhere. Worst case (gap-separated folds) is byte-identical to today's behavior. Eager-vs-hold full-state dump: persisted state identical, only the settle-round and next-request bodies stay raw; goldens regenerated with the semantic assert updated (carrier by materialization body, foldAt+2). Tests: unit fold-hold (10), loop raw-hold + pressure materialize (#3003a/b), proxy seam e2e (K consecutive folds → exactly ONE raw→folded transition; escape hatch pins eager), storage goldens regen, 29-file regression batch green.
…ve committed debug probe (#3742 review) Review cleanup for the #3003 fold-hold PR: - PrepareHoldDecision is only used inside this module - drop the leading export (unused-exports gate INTERNAL_ONLY finding). - delete _resetFoldHoldsForTests: a no-op with zero references (gate DEAD finding); tests construct fresh sessions per case. - remove tmp-debug-3003.mts: committed root-level debug probe, not part of the change. No behavior change.
23509a0 to
6b24241
Compare
…3003 review) The #3003 hold renders committed folds raw through a compress burst and materializes on the first request without a new fold result — by design. ~30 suites assert fold VISIBILITY mechanics (rebuild byte-stability, carrier anchoring, spill refs, decompress, lane scoping, usage verbatim, cross-wire carry) whose premise is 'the fold is visible on the first post-fold request'. Pin those suites to the eager contract via BILI_DEFER_MATERIALIZATION=0 (config file in the opencode WS e2e, whose harness sanitizes BILI_* from the child env). The hold semantics themselves are pinned by fold-hold.test.ts, fold-hold-seam.test.ts, loop-compress #3003a/b, and the regenerated storage-render goldens (which drive all four prepare wires under the DEFAULT config — carrier appears at foldAt+2, state digests unchanged).
dda93d0 to
a6b66e6
Compare
…uite The D lane reads the unified transcript (unifiedTailViewRows); the CI scheduler's tests/preload-storage-baseline.mjs pins the broad corpus to legacy, leaving the sidecar off — the D tests then degrade to the legacy render and the observability latch never counts (master run 39191418594 is red on exactly these three tests, reproduced locally via CI_TEST_SHARD=2/3 run-ci-tests.mjs). Assign (not ??=) so the suite overrides the preload: it is ABOUT the unified store. No product change.
(ai: vllm-qwen/qwen3.8-27b) 冲突已解决并推回分支( 做了什么:master 在「release-train sync 4」之后又前进了(#3770 google lane 接入 snapshot render + #3778 ws-shed-gate-narrow)。其中 #3770 恰好落在本 PR 改动的同一行(google prepare 的 processTurn 调用点)→ 唯一一处文本冲突。我沿用该分支既有的 merge(非 rebase)惯例把 master 合进来,冲突行取两侧并集:保留本 PR 的 本地验证(§7.2 gate):typecheck(kernel + pi-subagents 重建 + 重要提醒(不改结论):floor 6 已判定拦下、不合——~164 个存量 pin 绑死旧时序 + OC-WS chain-reset 回归,等你拍 A/B。本次冲突解决只是让分支回到可审 / 可合并态,不修复那些红;CI test 矩阵预期仍会红(直到 pin 迁移 / WS checkpoint 失效落地)。请勿据此认为 PR 已可合入。 结构化八问:
收工判定:冲突已解、分支回绿态(可审 / 可合),typecheck + build 本地过、待 CI 全量确认。实质审核结论维持 floor 6 的「拦下」,等 owner 拍 A/B。 |
(ai: vllm-qwen/qwen3.8-27b) 第二次冲突已解决并推回( 这次的原因:master 又前进了( 本地验证(§7.2 gate):typecheck(kernel + pi-subagents 重建 + 重要提醒(不改结论):floor 6 仍判定拦下、不合(~164 存量 pin 绑死旧时序 + OC-WS chain-reset 回归,等 owner 拍 A/B)。本次只是让分支回到可审/可合并态,不修复那些红,CI test 矩阵预期仍会红。另外注意:master 的 snapshot-render 产线还在快速落地(#3771/#3774),本分支若继续挂着,可能还会反复撞同一区域的冲突——要么尽快推进 A/B 决策合掉,要么等 master 那边的 snapshot-render 工作收敛。 结构化八问:
收工判定:第二次冲突已解、分支回绿态(可审/可合),typecheck + build 本地过、待 CI 全量确认。实质审核结论维持 floor 6 的「拦下」,等 owner 拍 A/B。 |
|
冲突 重新 review 看是否有类似修复 |
…nc 7) Regenerated tests/golden/storage-render/* from merged source via scripts/update-storage-render-goldens.ts (both sides deliberately rewrote these goldens; only a fresh regen reflects the fully-merged render contract). summaryFrom=foldAt+2 preserved across all four wires.
(ai: vllm-qwen/qwen3.8-27b) 冲突已解决并推送(第 3 次 release-train sync,sync 7)。 分支现对 八问
过程备注:本轮本地 git 代理一度返回 502(瞬时故障),重试后恢复;merge 更新了 lockfile(版本 0.1.201→0.1.202 + 新依赖),故先 收工判定:分支已干净并对齐 |
(ai: vllm-qwen/qwen3.8-27b) 已按你的要求对同步后的分支重新 review,重点排查 master 这批变更里有没有「类似修复」。 直接结论:没有与本 PR 两个已知阻塞项同机制的重复修复;最接近的是 #3812(snapshot render「seam hardening」),但它说的是另一种 seam。复查还顺带发现一个 sync 引入的潜在交互面(在 0% rollout 旗标后面,非现行回归)。 一、逐项排查(独立重查,非复读 floor 6)
二、#3812 是最近的邻居,但 seam 不是一回事#3812(
三、sync 引入的新增面(floor 6 审时还没有):#3812 × fold-hold 组合四产线现在都是同一顺序:
四、结论与下一步sync 只把分支对齐到当前 master,未消解任何已知阻塞项:~164 pin 绑旧时序 + OC-WS chain-reset 依旧待办,A/B 仍是合入门槛。
结构化八问
收工判定:review 完成——无类似/重复修复,#3812 默认组合安全、旗标开有一处潜在交互待核,floor 6 两项阻塞不变。等你决定:(1) 是否让我先把 WS checkpoint 失效落进本分支(无决策依赖);(2) A/B 方向。 |
|
(ai: zhipuai-lb/glm-5.3) 陈旧票清理(第三批动作①):目标 issue #3003 已关。为避免重复劳动关闭本 PR;如判断有误请直接 reopen 并留言。 |
Closes #3003 (supersedes the deferred-materialization half of the eork discussion; builds on #3670 for the failure half).
What this does
Consecutive compress rounds currently pay one cache seam each: every successful fold rewrites the outbound prefix immediately, so the re-request inside the burst re-pays the whole cache prefix. #3670 made the failure path seam-free (all-or-nothing length pre-check, zero-replacement on rejection). This PR makes the success path pay exactly one seam per burst.
The fold-hold rules
holdFold:false— rescue must shrink the CURRENT request)BILI_DEFER_MATERIALIZATION=0/compress.deferMaterialization=falseLoop lane (plugin/native/dsh)
The settle re-request after a successful compress no longer refreshes to the folded view while folds are held — the raw re-request is prefix-stable with the request that triggered it. This is strictly better than today even for a single fold: the settle round currently pays a seam of its own. The next round (or relay refreshFolded) materializes.
The 5 obstacles from the eork thread, resolved
effectiveTokenCounttracks real pressure).holdFold:false; emergency folds always render folded.Mechanics worth reviewing
{active:false, expanded:true}— the kernel's sanctioned render-raw channel (kernel/src/sync.tsdeliberately leaves expanded blocks inactive; same pair as fork-adoptionsrc/plugin.ts:1280and decompress). Active flags restored before state adoption; a genuine mid-burst user decompress is never resurrected (keyed on pre-clone activity map).applyjudges.Goldens regenerated (justification)
tests/golden/storage-render/*— deliberate render contract change: the settle-round body and the next request stay raw; the carrier appears on the materialization body (summaryFrom = foldAt+2). Structural assert updated knob-aware (legacyfoldAt+1under the escape hatch). Eager-vs-hold full-state dump: persisted state identical, only those two bodies differ;blockContentsdigests unchanged.Known acceptable quirks (documented, follow-up candidates)
FOLD_CLAIM_COLD_ROUNDSexpiry cannot strand held folds (0-claim folds stay pending regardless of elapsed samples).Tests
tests/fold-hold.test.ts(10): commit tracking, hold legs, materialize, pressure override at exactly 0.9×, knob off,hold:false, clone/restore identity, per-session isolation.tests/loop-compress.test.ts#3003a/b: raw re-request during hold (receipt rides raw tail, no refresh, block committed, held set size 1) + pressure materialize same-round.tests/fold-hold-seam.test.ts: proxy-level anonymous stateless client, scripted fold demands — K consecutive folds → exactly ONE raw→folded transition across the whole client sequence;pfas===1; escape-hatch test pins eager.