Skip to content

Boot warm set off by default: sessions hydrate on first touch (#3050 R3 step 1) - #3194

Merged
ranxianglei merged 9 commits into
masterfrom
2026-10-15_r3-warm-gate
Oct 15, 2026
Merged

ranxianglei merged 9 commits into
masterfrom
2026-10-15_r3-warm-gate

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

sessions.warmMax default 8 → 0 (#3050 R3 step ②-0). Lanes no longer hydrate the eight most-recently-saved sessions before listening; every session loads on first touch (unified-first lookup under full, envelope read otherwise).

Why

Measured on a production data copy with GET /__bili/memory (#3051):

boot RSS heapUsed
warm=8 (old default) 623 MB 269 MB
warm=0 (new default) 432 MB 118 MB

-151 MB per lane at idle boot — and machines that run many lanes (15+ bili processes here) pay it per process. The warm set only bought faster first-touch for a guess about which sessions come back; an un-warmed session pays one on-demand load (milliseconds) instead. bounded-storage.test.ts already pins the lazy-reload path (boot({maxSessions:0}) → transparent loadSync).

Surface

  • src/knobs.ts sessionWarmMax() default 8 → 0 (knob + BILI_SESSION_WARM_MAX unchanged for opting back in)
  • docs seed + regenerated tables (en/zh)
  • tests/knobs-config-precedence.test.ts pins the new default in all three tiers

Tests

  • knobs-config-precedence 12/12, bounded-storage 14/14, memory-diagnostics 3/3
  • persist-tail + storage-unified + multi-instance-live regression green
  • tsc clean

Part of #3050 (R3 memory plane). Next steps on that issue: lastMessages turn-end tabling (②a), blockContents lazy load (②b).

prepared by an agent under the local git identity (ranxianglei), human merge required

…st touch (#3050 R3 step 1)

sessions.warmMax default 8 -> 0. Measured on a production data copy
(661 sessions / 117 MB index.db): warm=8 cost 151 MB RSS at idle boot
(623 MB vs 432 MB warm=0). First touch now pays one on-demand load
(unified-first lookup or envelope read) instead; bounded-storage already
pins the lazy-reload path, and the knob/env stay for opting back in.
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-15_r3-warm-gate (75c609a)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3752-pr.3194.43f8089

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3194.tgz
npm install -g package

Install instructions are refreshed on each push.

…ager opt-in leg

The boot-restore contract (restored flag, lastSeen=savedAt, freshness-keyed
truncation) now has two legs: the new default (boot warms nothing; the first
loadSync carries the same restored/lastSeen stamps) and the opted-in eager
warm set (BILI_SESSION_WARM_MAX=2 keeps the original truncation assertions).
_resetSessionsForTest also resets the initSessions flag so a test can boot
twice — a fresh process starts with it false either way.
…p the bounded view (#3050 R3 step 2)

writeNow/flushSync foldResidentTail: after a successful save of a session
with inFlight===0, session.lastMessages drops to boundedFoldedSnapshot()
and lastMessagesFolded=true — exactly the shape buildSession restores on
restart. Mid-turn saves (inFlight>0) keep the raw tail; snapshotMessages
re-arms the raw copy on the next request either way. Envelope re-saves are
idempotent (pinned), the shadow oracle snapshots the live tail it handed
the ingest before the fold, and the unified table keeps raw rows via the
⑤ rawTail override + #3166 watermark (append-only past the boundary).

tests/memory-tail-folding.test.ts: fold/idempotence/restart-parity/re-arm.
@ranxianglei

Copy link
Copy Markdown
Owner Author

R3 step ②a added (eac26ac): writeNow/flushSync now fold an idle session's resident raw tail to the bounded persisted view after the save captures it (envelope + unified table via the ⑤ rawTail override). Mid-turn saves keep the raw tail; snapshotMessages re-arms it on the next request. Envelope idempotence + shadow-oracle parity + restart-shape parity pinned in tests/memory-tail-folding.test.ts (3/3) and the storage-unified oracle update.

Resident effect: the raw tail's ceiling drops from 'whole resent history' to persist.tailTokens (default 16384 tokens ≈ 65 KB) — the fattest dogfood session carried 46.9 MB of raw tail.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Reviewed both heads of the branch. Summary: step 1 (c6e62d9) had one real regression — now fixed by 50288b5; step ②a (eac26ac) reviewed clean. No code pushed by me (I had prepared an equivalent #404 test fix locally, discarded it when I saw your commit landed — yours is better, it also pins the new lazy default).

The step-1 regression (fixed in-branch): under warmMax 0, tests/issue404-restore-timestamps.test.ts:93 failed deterministically — _resetSessionsForTest(2) + initSessions() hydrated min(2, 8)=2 sessions under the old default but min(2, 0)=0 under the new one, so the freshness-keyed truncation assertions saw an empty table. Reproduced locally and confirmed red on both ubuntu shards (node 22/24) in the c6e62d9 run. Your 50288b5 rewrites the test into two legs — new lazy default (boot warms nothing, loadSync hydrates with lastSeen=savedAt + restored flag) and eager opt-in (BILI_SESSION_WARM_MAX=2, original truncation assertions) — which is the right shape: the #404 semantics stay covered for opt-in users AND the new default gets pinned.

Step ②a review (eac26ac): verified the safety chain rather than trusting the tests alone:

  • Capture-before-fold ordering holds on all three save paths (writeNow async, writeNow writer-off sync, flushSync): guardedBuild(session) is evaluated and the store write completes before foldResidentTail runs, so the envelope, the shadow record and the unified messages table (⑤ rawTail override) all capture the raw tail pre-fold. The storage-unified oracle update (snapshotting liveTail before writeNow) is exactly right for that.
  • Re-arm is total: every wire path calls snapshotMessages with the request's own history (prepare-anthropic.ts:409, prepare-openai.ts:408, prepare-google.ts:322, prepare-responses.ts:583,680), so an idle-folded session always sees the full raw tail again on its next request. The inFlight > 0 guard keeps mid-turn saves unfolded.
  • boundedFoldedSnapshot is the pre-existing sessions 存储三重膨胀:叶块 blockContents 逐字节重复 50%、零 GC、每次启动两遍全量同步解析(实测 387MB/+60MB 每天/2s 起步) #401 bounded-view function — no new truncation logic, no disk-format change; RAM converges to the exact shape a restart restores (test 3 pins RAM==restart parity and idempotent re-save).
  • _resetSessionsForTest resetting initialized=false: test-only, the flag is read nowhere except inside initSessions() itself — no cross-test leakage.
  • New suite tests/memory-tail-folding.test.ts (3/3) has teeth: byte-level shrink assertion, envelope/RAM deep-equal, mid-turn keep + re-arm, idempotence, restart parity.

Local evidence at eac26ac: memory-tail-folding + issue404 + storage-unified + bounded-storage + knobs-config-precedence = 42 pass / 0 fail / 1 skip; persist-tail + multi-instance-live = 8/8; tsc clean. CI at eac26ac: 42 check-runs, zero failures so far (test shards still running).

Behavior changes to disclose (old → new):

  1. sessions.warmMax default 8 → 0: boot hydrates nothing; first touch pays one on-demand load. Opt-back: sessions.warmMax: 8 or BILI_SESSION_WARM_MAX=8. (Intended, measured -151 MB/lane.)
  2. New: after any idle save (turn-end flush, shutdown flush, eviction flush), the session's resident lastMessages drops from "whole resent history" to the persist.tailTokens-bounded view — RAM-only; disk format unchanged. Consequence: bili export of an idle session mid-process now returns the bounded view where it previously returned the full resident tail — identical to what export already returned post-restart, so no new loss class. Under BILI_PERSIST=false (throwaway mode) the same convergence applies with nothing on disk either side.

中文结构化八问:

  1. 是什么问题:多 lane 机器上每个 bili 进程空闲启动就预热 8 个最近会话,白占 ~151 MB RSS;顺带把 R3 第二步(idle 会话内存里的原始尾收敛到持久化的有界视图)一并纳入本 PR。
  2. 什么原因导致的:warm 集合是 Bound startup session loading and preserve historical recovery #2803 时代"猜哪些会话会回来"的启发式,收益(首次触达快几毫秒)远小于代价(每 lane 常驻内存);idle 会话的原始尾在内存里与磁盘/下一请求重复存放。
  3. 影响范围与严重程度:所有 lane 的启动内存(多 lane 机器按进程数放大);功能面无破坏——未预热会话首次触达按需加载(毫秒级),mid-turn 保存不折叠、下一请求必然重新武装原始尾。属性能优化,非缺陷修复。
  4. 怎么修复的:默认值改为 0(lazy-first);②a 在保存成功捕获原始尾之后把内存副本折叠成与重启恢复完全一致的有界视图,靠"每条请求路径都调用 snapshotMessages 重武装"保证无数据依赖风险。
  5. 是否有回归问题:审过——c6e62d9ac 确实打红了 重启伪造时间戳:buildSession 用 Date.now() 覆盖 lastSeen,面板"最后活动"全员开机时刻、fallback=latest 在 ~245 路平局里随机挂会话 #404 既有回归测试(确定性失败,本地+CI 双 shard 复现),已由 50288b5 修复且补钉新默认行为;折叠只在 inFlight==0 时发生、捕获先于折叠、四条 wire 路径全覆盖重武装;_resetSessionsForTest 改动仅测试侧。CI 上其余红项(port-zone-live / claude-native 固定端口 18787 EADDRINUSE)是并行 shard 端口碰撞 flake(无单实例守卫:多个 bili 代理进程并存共写 sessions 目录,伴随孤儿 ref、有注册表无 transcript、计数自相矛盾的污染簇 #394 已知噪声类),与本源无关,单独跑均绿。
  6. 是否破坏缓存:不涉及——prefix cache、压缩状态、message-ref 空间均未触碰;lastMessages 只是常驻副本,由客户端重发历史重建。
  7. 是否改了设计方向:是 Memory plane (R3): stop keeping compressed originals, CCR and snapshots fully in RAM now that the unified store has them — measure first, then lazy-load #3050 R3 内存平面的既定方向(常驻内存向"重启形状"收敛),未引入新机制,仅复用既有 sessions 存储三重膨胀:叶块 blockContents 逐字节重复 50%、零 GC、每次启动两遍全量同步解析(实测 387MB/+60MB 每天/2s 起步) #401 有界视图函数。
  8. 是否引入了新的配置:无新增。仅默认值变更:sessions.warmMax 8→0(knob 名与 BILI_SESSION_WARM_MAX 不变,设回 8 即恢复旧行为)。

判定:可合并 —— 等 eac26ac 的 CI test shard 全绿即可 merge(人工操作)。此前唯一的真回归已在分支内修复并有测试钉住。

…a re-materializable shell (#3050 R3 step 3)

LazyBlockContents (Map subclass, store-bound loader closure): after an
idle save, dropResidentBlockContents swaps the resident map for a dropped
shell; any read/write/iteration re-materializes the full set through
SessionStore.loadSync (one disk read per burst). deepSizeOf reports the
shell at ~0 without materializing (diagnostics stay non-invasive). An
unrecoverable drop THROWS on access — a save iterating a silently-empty
set would otherwise erase block contents from the persisted record.

plugin-fork deepEqual updated to content-level compare (constructor
changed by design).
@ranxianglei

Copy link
Copy Markdown
Owner Author

R3 step ②b added (c89e550): idle sessions fold their resident block-contents map to a LazyBlockContents shell after the save captures it. Any touch (decompress, fork inheritance, export, or the next save's record build) re-materializes the full set from the store — one disk read per burst. Safety: the loader is store-bound (multi-dir tests never cross-wire); a drop that cannot re-materialize throws on access instead of ever persisting a thinned set; deepSizeOf reports the shell at ~0 without materializing so diagnostics stay non-invasive.

Measured effect on the fattest dogfood session: blockContents 27.4 MB → ~0 while idle. Combined with ②a (raw tail 46.9 MB → bounded view), the three big resident fields of an idle session now all fold: ~75 MB off per idle fat session.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Correction to my previous review — I retract "step ②a reviewed clean". After my reply, CI went red on tests/storage-save-path.test.ts ("sampled verification … injected CAS drift is still caught") in every shard that runs it (ubuntu-22-1, ubuntu-24-1, windows-22-1). I bisected and reproduced it locally 3/3 — ②a has a real regression, and the oracle that caught it is working as designed.

Mechanism (verified by probe, not guessed):

  1. foldResidentTail re-derives the bounded view by running the kernel's prune() over session.lastMessages — even when that view is already a pruned/folded snapshot (lastMessagesFolded === true). That is exactly the idle-re-save path ②a targets (no request in between, so no snapshotMessages re-arm).
  2. Re-pruning an already-folded view is not order-stable. Probe on the golden corpus tests/golden/storage-corpus/folded (11 messages): persisted tail starts [acp_summary_b1, raw31, …]; after save 1's fold it becomes [raw31, acp_summary_b1, …] — same set, same length, swapped positions. Double-folding then stabilizes (F→F), so only the first idle fold diverges from what was just persisted.
  3. The 影子存储(默认开启)每次落盘把整个会话重新序列化+哈希,大会话明显变卡;jsonWriter=off 时连防抖合并都没了 #3133 watermark/delta ingest trusts a same-length prefix and skips the rewrite → the unified table keeps stale slots → the sampled read-back digest at n=21 reports DIGEST DRIFT (unified replay != legacy load view), which fails the test at tests/storage-save-path.test.ts:108 (verifyOk 1 !== 2).
  4. This also breaks ②a's own stated invariant ("the exact shape a restart restores") — resident view ≠ restart view after one idle fold. memory-tail-folding.test.ts missed it because its synthetic corpus carries no acp_summary block to reorder.

Bisect evidence: green at c6e62d9, red at eac26ac; deterministic locally on Linux (so the 4th OS×node combo will go red too when its shard finishes).

Suggested fix direction (your call — host-side, since prune is kernel-owned):

  • (a) skip the fold when session.lastMessagesFolded === true — an already-folded view is already canonical; idle re-saves don't change state between saves, so there is nothing to converge; or
  • (b) derive the resident folded view from the record that was just built (single source of truth), so resident == envelope == DB by construction regardless of what prune does;
  • plus a regression test using the real golden corpus (with acp_summary blocks) pinning resident == envelope == DB after an idle re-save. Optionally harden the watermark to content-hash the slots it vouches for — defense-in-depth, but the root fix belongs at the producer (don't emit a different view than you persisted).

The other five red shards are the known flake classes, unrelated to this PR: port-zone-live ×2 + performSelfRestart (fixed-port 18787 EADDRINUSE / live-process timing, #3044/#394 family) and hook e2e pinned-port ×2 (claude-native; passes standalone 50/50).

Step ②b review (c89e550): design checks out — drop only after a successful capture (control-flow guard; writerOff/full-mode sessions re-materialize from index.db via the store-bound loader); unrecoverable drop throws on access instead of persisting a thinned set (correct fail-fast); Map accessor override surface is complete (get/has/set/delete/clear/size/entries/keys/values/forEach/[Symbol.iterator], clear() correctly a real clear); deepSizeOf fast-paths a dropped shell without materializing. Local: memory-blockcontent-lazy + plugin-fork + storage-unified = 64 pass / 0 fail / 1 skip. One nit: src/persist.ts:1406 (async writeNow path) has the new dropResidentBlockContents line indented one level too deep — cosmetic; I'm holding a standalone whitespace commit while you're rewriting those exact lines for the ②a fix, will land it alongside or right after.

Updated verdict: NOT mergeable yet — blocked on the ②a reorder/drift regression above; once fixed, re-run full CI (expect the storage-save-path shard to flip green; the flake-class lanes may need a rerun regardless).

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Status check (no new branch activity since my correction above):

  • Branch head is still c89e55067 (step ②b) — no ②a fix commit landed yet.
  • Nothing else for me to do until then: the blocker is the ②a idle-fold reorder → unified-table digest drift regression reported in my previous comment (deterministic local repro + red in all three CI shards running tests/storage-save-path.test.ts).
  • When your fix lands I will: re-run the targeted suites locally (storage-save-path, memory-tail-folding, storage-unified, bounded-storage, issue404, memory-blockcontent-lazy, plugin-fork) + tsc, confirm the fix covers the golden-corpus case (an acp_summary block present in the folded tail), land the held one-line indentation nit at src/persist.ts:1406, check CI on the new head, and post the final confirmation with the merge verdict.

Verdict unchanged: not mergeable until the ②a regression is fixed and CI is green (human merge, as always).

…keeping to a re-materializable proxy (#3050 R3 step 4)

lazyMetadata(): transparent Proxy over the metadata record; after an idle
save the record folds away and any trap (get/has/ownKeys/set/delete/
defineProperty) re-materializes the PERSISTED shape through the
store-bound loader — the exact record a restart restores (buildRecord
stamps biliVersion/storageMode, so the materialized shape carries them).
Persisting walks the proxy and materializes the full set: no thinned
erase; an unrecoverable drop throws on access instead.

ResidentFieldBreakdown gains a metadata column (deepSizeOf reports the
dropped proxy at ~0 without materializing). Measured: metadata was
19.6 MB on the fattest dogfood session (foldAnchors/cacheLedger/
foldPositions dominate).
@ranxianglei

Copy link
Copy Markdown
Owner Author

R3 step ②c added (28ba72e): idle sessions fold their metadata record to a transparent lazy proxy (same pattern as ②a/②b). Any access re-materializes the persisted shape — the exact record a restart restores — with one store-bound disk read; persisting walks the proxy and materializes the full set (no thinned erase; unrecoverable drops throw). __bili/memory breakdown gains a metadata column, and deepSizeOf reports a dropped proxy at ~0 without materializing.

Measured on the fattest dogfood session: metadata was 19.6 MB (foldAnchors 1.9 MB JSON / cacheLedger 1.3 MB / foldPositions+order 0.8 MB — tiny-object overhead inflates them to 19.6 MB in RAM).

R3 ledger after ②-0+②a+②b+②c (same idle fat session): raw tail 46.9 MB → ~65 KB · blockContents 27.4 MB → ~0 · metadata 19.6 MB → ~0 · warm pool −151 MB at boot. All four steps in this PR.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Step ②c review (28ba72e): design checks out. Traps are complete for a record-shaped object (get/has/ownKeys/getOwnPropertyDescriptor/set/deleteProperty/defineProperty, all ensure()-first) — JSON.stringify/spread/Object.keys all walk trapped paths, so persistence materializes the full set as claimed; unrecoverable drop throws on access (same refusal semantics as ②b); loader is store-bound (this.loadSync); empty-record and already-dropped guards present; deepSizeOf fast-paths the folded proxy via the WeakSet without materializing; dropResidentMetadata sits after successful capture in all four save paths (writeNow ×2, flushSync ×2), consistent with ②a/②b. Local at 28ba72e: memory-metadata-lazy + memory-diagnostics + memory-tail-folding + memory-blockcontent-lazy + plugin-fork + storage-unified + bounded-storage + issue404 = 87 pass / 0 fail / 1 skip, tsc clean.

But the ②a regression from my correction comment is still unfixed at this head. Re-verified locally at 28ba72e: tests/storage-save-path.test.ts → not ok 2 - sampled verification: first ingest + every 20th read back; injected CAS drift is still caught (same digest-drift failure; the idle-fold reorder of an already-pruned tail still defeats the #3133 watermark's same-length-prefix trust). The master merge (17649eb) pulled in #3197's per-file zone-port bands — good, that should quiet the flake-class lanes in future runs — but no commit addresses the fold-reorder mechanism yet.

Reminder of the two suggested directions (either works, host-side): skip the fold when lastMessagesFolded === true (an idle re-save changes nothing between folds), or derive the resident view from the just-built record so resident == envelope == DB by construction; plus a golden-corpus regression test (needs an acp_summary block in the folded tail — the synthetic corpus in memory-tail-folding can't surface it).

Also still open: the one-line indentation nit at src/persist.ts async writeNow (the dropResidentBlockContents call sits one level too deep — now visibly inconsistent with the correctly-indented dropResidentMetadata line ②c added beneath it). I'll land it as a labeled whitespace commit once the ②a fix lands, to avoid churning lines you're about to rewrite.

Verdict unchanged: not mergeable until the ②a regression is fixed and CI is green. Everything else in the PR (①, ②b, ②c, the #404 test leg) is verified and sound.

…3194 CI)

Two defects surfaced by the storage-ext / sampled-verification CI legs:

1. dropResidentMetadata crashed on hand-built sessions with no meta
   (TypeError reading 'protocol') — guard with optional chaining, the
   lazy loader degrades to the id-only lookup.

2. After ②a's foldResidentTail folds an idle session's tail, subsequent
   saves still presented the folded re-render as the ⑤ rawTail override.
   The re-render reorders fold summaries (#2755: the summary yields to
   the leading user message on first re-render), but the equal-length
   watermark delta trusted the claimed rawness and skipped the
   tail-pointer rebuild — the unified table kept the pre-fold ordering
   while the record moved on, and the sampled digest correctly flagged
   drift on every 21st save. The override now requires
   lastMessagesFolded !== true: folded saves present the envelope render
   (no override), which planIngestDelta already routes to the full
   ingest, rebuilding tailSeqs in the render's order. Raw rows interned
   by earlier raw saves stay put (append-only).

storage-unified oracle updated: parity compares against the override
input when a live raw tail exists, else against the written record.

Tested: storage-ext 5/5, storage-save-path 3/3, storage-unified 13/13,
memory families + persist-tail + corpus + issue404 42/42.
@ranxianglei

Copy link
Copy Markdown
Owner Author

重新review 8问

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

重新 review 完成,基于当前 head 75c609a(含你的 ②a 修复 98206bb + 我落的 2 行缩进对齐 style commit)。本地定向验证全绿:storage-save-path / storage-unified(oracle 已按新契约更新)/ storage-ext / storage-corpus / storage-ingest-watermark / memory-tail-folding / memory-blockcontent-lazy / memory-metadata-lazy / memory-diagnostics / persist-tail / issue404 / bounded-storage / knobs-config-precedence / plugin-fork = 135 pass / 0 fail / 1 skip,tsc 干净。CI 在跑(写作时 21 queued / 3 in progress),绿了再补确认。

八问:

  1. 是什么问题:bili lane 的常驻内存被「存过盘但还留在内存里」的会话数据撑大——旧默认启动预水化最近 8 个会话(多 lane 机器每进程 ~151 MB RSS);且会话保存后,空闲会话仍常驻完整 raw tail(最肥 dogfood 会话 46.9 MB)、完整 blockContents 原文(27.4 MB)、完整 metadata 对账簿(19.6 MB)——三样磁盘/store 里都有权威副本。
  2. 什么原因导致的:持久化设计是「写穿 + 全部常驻」:boot 急切加载最近 N 个;保存路径只写盘、不折叠内存副本;blockContents/metadata 没有惰性物化层。内存随 会话大小 × 存活会话数 线性增长,无释放路径。
  3. 影响范围与严重程度:所有带多个已保存会话的长驻 lane,多 lane 机器(如本机 15+ 进程)逐进程叠加。严重度属资源耗尽类(RSS/heap 压力、GC 成本、受限机器 OOM 风险),不是数据丢失——每步都保持 store 权威、首触毫秒级重读。
  4. 怎么修复的:统一的「捕获 → 折叠 → 访问时重物化」模式铺到四个面:① warmMax 默认 8→0,boot 零水化,首触走既有 loadSync;②a 保存成功后把常驻 raw tail 折成有界视图——修复版的关键不变量:折叠过的 tail 不得再向 ⑤ rawTail override 声称 rawness,折叠态保存呈现 envelope render 走全量 ingest(tailSeqs 按 render 序重建),raw 行保持 append-only intern;②b blockContents → LazyBlockContents 壳(Map 子类,访问器经 store-bound loader 重物化,不可恢复时抛错而非落瘦集);③ metadata → 透明 Proxy(全 trap 先 ensure(),JSON.stringify/spread/Object.keys 都走 trap,持久化即物化全集,同样不可恢复抛错)。诊断面:deepSizeOf 对折叠壳快速返回 ~0 且不触发物化;/__bili/memory 增 metadata 列。重启伪造时间戳:buildSession 用 Date.now() 覆盖 lastSeen,面板"最后活动"全员开机时刻、fallback=latest 在 ~245 路平局里随机挂会话 #404 回归测试拆成两腿:新默认下的 lazy 语义 + 显式 BILI_SESSION_WARM_MAX=8 钉住 eager opt-in 腿。
  5. 是否有回归问题:审核中发现并跟到底了 1 处真实回归(②a 初版):对已折叠 tail 二次 prune 会重排 fold summary(fix(kernel): fold summaries may never precede the pinned first user message (#2733) #2755 首渲染让位规则),等长 watermark delta 信任了错误的 rawness 声明 → 跳过 tail 指针重建 → unified 表停在折叠前顺序 → 采样摘要每第 21 次保存报 drift(storage-save-path 三个 CI shard 红 + 本地确定性复现)。已在 98206bb 以产侧修复消除(不是掩盖):折叠态不再声称 raw,走全量 ingest;同 commit 修掉 dropResidentMetadata 在无 meta 手工会话上的 TypeError。修复后本地全绿(上述 135/135)。高危模式逐项过:fail-fast 未变弱(不可恢复一律抛错、无静默瘦身)、watermark 语义除修正该声明外未动、envelope 格式与 legacy 读端视图不变、message-ref/id 空间未碰、kernel 本 PR 零改动。早期 CI 红中的其余项均为已知 flake 类(固定端口 EADDRINUSE / live-process 时序;ci: per-file zone-port bands for live suites + bounded TOCTOU retries (#3182/#3184/#3188) #3197 端口分带已并入本分支)。
  6. 是否破坏缓存:上游前缀缓存不受影响——四步都不改线上内容,折叠只发生在内存面,envelope render 与 legacy 读端所见字节一致。内部:unified 表行 intern 保持 append-only;折叠态保存多做一次全量 ingest(正确性优先的代价);会话文件格式/版本、增量游标键均未变。
  7. 是否改了设计方向:无架构转向——在既有单写者持久化模型下加了一层惰性物化(store 仍是唯一权威,内存从「源」降级为「缓存」)。新增一条边界规则值得记住:凡向 delta 路径声称 rawness 的视图必须真是 raw(已固化进 ⑤ override 的门)。
  8. 是否引入了新的配置:无新 key/env。既有旋钮改默认值一处:sessions.warmMax / BILI_SESSION_WARM_MAX 8 → 0(设回 8 恢复旧行为;CONFIGURATION en/zh + website seed + CHANGELOG 已同步披露)。无迁移成本(不涉及持久化状态)。

判定:代码面已验证可合(head 75c609a,定向 135/135 + tsc 干净);剩余动作只有 CI 全局绿(test shards 在跑,flake 类 lane 若偶发红按已知类 rerun 即可)。合并照例由人来。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI 确认(head 75c609a,全部 check-runs 完结):41 success / 1 failure。

唯一红:test (windows-latest, node 22, shard 1) — tests/wire-exit-matrix.test.ts "error-delivery x proxy-openai-sse: preflight failure after the early commit arrives in-band",断言 headers committed before the slow summarization failed (1679ms)。判定为时序 flake,与本 PR 无关,证据:

处置建议:rerun 该 windows lane(或整组 test shards)即可;若再红且仍停在同一断言,那时才值得当作真问题立项。

其余 41 项全绿,含全部 storage/memory 相关 test shards(②a 修复后 storage-save-path 已转绿)、static-gates、各 guard、hermetic registry e2e、real-client lanes。

最终判定:可合。 代码面(本地定向 135/135 + tsc 干净 + 我独立走完的回归审计,见上一条八问)与 CI 均已过;唯一动作是 windows 时序 lane 的 rerun。合并照例由你来。

@ranxianglei
ranxianglei merged commit fc0f6c1 into master Oct 15, 2026
67 of 68 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.442-master.fc0f6c1 (rolling master tag).

npm install -g billion-context@0.0.442-master.fc0f6c1  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant