Repository navigation
[PR] feat: snapshot-lane — pin proxy-lane historical ids server-side (#3756) - #3758
ranxianglei wants to merge 1 commit into
Conversation
Proxy-mode clients resend their full history every turn, so message ids were re-derived from client bytes each turn. Any kernel identity-function change re-minted every historical id and mass-unfolded persisted sessions (#3752; the #3658 seed swap was the incident). This adds an opt-in snapshot lane that pins historical ids server-side: - src/snapshot-lane.ts: pinSnapshotIds() aligns the client resend against the unified-store snapshot (order-centric walk, dialect-neutral content fingerprints per #3642) and stamps stored msg_ids onto aligned prefix positions before the pipeline runs. Appends ride the existing rawTail ingest (#3007); registry state persists via session_ext (snap:reg / snap:head). Every unaligned shape bails to byte-identical passthrough — the lane can only change ids, never content or order. - src/server/prepare-{anthropic,openai,responses}.ts: hook after XToCore; plugin mode returns the same reference untouched. - src/rollout.ts: proxySnapshotLane feature entry (percent 0 = default off). - tests/snapshot-lane.test.ts: 9 tests incl. the #3752 identity-swap replay (pinned resend keeps coverage and byte-stable outbound; unpinned control drifts), dsh-style checkpoint absorption (observed, never forwarded), rewind/truncate clamping, and gate/bail directions. - reference/architecture.md: module map line. Closes #3756 Fixes part of #3752 (R2 root cause; R1 capacity cliff stays out of scope — non-D lanes still rely on the #3753 lite-anchor stopgap)
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4441-pr.3758.1824430This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3758.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 本条是 GitHub PR #3758 的镜像——#3756(快照渲染/D 车道设计)的实现 PR,不是另一项并行工作。相关条目:
标签: opencode + scope/kernel + p1 —— 两条真实车道(anthropic/responses)即 OpenCode 车道 + 最常见 openai 车道;失败域为上下文管理/渲染核心(scope/kernel);严重度继承 #3752 的 p1 性质(不根治则每次未来身份函数变更都会再触发一次 mass-unfold 成本爆炸)。 此 PR 为我早前在 #3756 线程完成的工作(floor 3 已汇报)。现按 PR review 规范做独立复审:拉分支核对代码、确认 CI 状态、既有行为回归清点、测试有效性审查。结论按八问体例随后回复。 |
|
(ai: vllm-qwen/qwen3.8-27b) 关闭说明:owner 已在 #3756 交付同一 issue 的实现 —— PR #3759(分支 2026-10-19_snapshot-render)。按「一个 issue 一个 PR」纪律,本 PR 与 #3759 是同一机制的两条并行实现,保留两个会让验收标准互相打架,故关闭本条;#3759 为唯一在途 PR。 本 PR 的测试套件(tests/snapshot-lane.test.ts,9 例,含身份函数翻盐后的出站逐字节不变对照)覆盖同样的四个验收场景、角度不同(id 盖章 + 快照注册表),审阅 #3759 时可作参照。如需保留本 PR,重新打开即可(分支 2026-10-19_snapshot-lane-id-pinning @ d781cb8 仍在)。 |
What & why
Closes #3756 — Fixes part of #3752 (R2 root cause).
In proxy mode (client resends its full history every turn), message ids were re-derived from client bytes each turn. When the kernel's identity function changed (#3658 seed swap → #3752 mass-unfold), every historical id was re-minted, block coverage was lost, and persisted sessions unfolded en masse (126K→998K tokens, cache hit 2%).
This adds an opt-in snapshot lane: the server-side snapshot becomes the authority for historical ids. The client resend is demoted to an observation that discovers the new tail; aligned prefix positions get stamped with the stored msg_id before the pipeline runs. Structurally, historical id re-minting no longer exists in this lane — a kernel upgrade or identity-function change can never touch existing sessions again. The incremental lane keeps serving independently; reconcile/anchor machinery is untouched for non-D lanes (it stays naturally dormant here).
How it works
src/snapshot-lane.ts—pinSnapshotIds()runs right after XToCore in each prepare lane:(session_id, seq)rows) with an order-centric walk: content-equality fast path + normalized comparison, bounded gap jumps accepted only on ≥3 consecutive resyncs (order-first discipline, 公告:release v0.1.193 修复dsh 切模型导致上下文暴涨问题,修复fork问题,修复claude codex dsh等自动压缩导致会话破坏问题 . 另外修复几十个bug. 我本地场景有限,未必都测全,麻烦大家小场景先测试下是否有问题.任何问题及时反馈. #2821/fix(dsh): model switch drops all folds — fold-reconcile #2396 detect-only cannot re-anchor rewritten tool-call ids → doom-probe 502 session death #2915);session_ext(snap:regrow-id list,snap:headabsorbed-checkpoint fingerprint); appended rows ride the existing rawTail ingest (Unified store holds the raw conversation tail (#2960 ⑤) #3007). No new storage tables, no block-bookkeeping migration (blocks stay id-keyed; snapshot ids never remint, so id-keying ≡ seq-keying stability).prepare-anthropic.ts/prepare-openai.ts/prepare-responses.ts(the v1 lanes named in the issue); plugin mode returns the same reference untouched.Config surface
One new rollout feature entry; no new config fields, no new named env var:
rollout.features.proxySnapshotLanepercent: 0(off)"proxySnapshotLane": truein config, or existing generic tierBILI_ROLLOUT_PROXY_SNAPSHOT_LANE=1(documented at CONFIGURATION.md:99 / :1765)Engages only when unified storage is available; legacy storage falls back to the current path with one info log per session.
Behavior-change flag
Default OFF ⇒ zero past-behavior change. When engaged, for proxy-lane sessions with unified storage: historical message ids come from the server snapshot instead of being re-derived from resent bytes each turn (the intended fix). Outbound content/order is byte-identical by construction (passthrough on any unaligned shape; asserted in tests). One visibility note: the Responses API carries bili-minted core ids as item
ids on the wire (already the case pre-change for derived ids); steady state is byte-identical, and after an identity-function change the stable frozen ids are what stay on the wire — which is the point. No threshold/timing/output-format changes elsewhere.Acceptance mapping (the issue's four zero-churn scenarios)
identity swap (acceptance 1+4)test: replays a [PR] protocol-stable core identity: same logical conversation, same ids in every dialect (#3642) #3658-style re-mint; the pinned resend keeps block coverage and its outbound deep-equals the steady-state rendering; the unpinned control drifts (proves the bug existed and the lane removes it).alignKeyOfunit test + dialect-stamped view construction cover it; zero snapshot migration, one upstream miss when the wire format itself changes (unavoidable), stable pure-function output afterwards.v1 scope & non-goals (per issue)
Lanes: anthropic/openai/responses v1. Non-goals: google lane (follow-up), legacy storage (info-once fallback), mid-history edits (bail passthrough), CCR storage of absorbed heads, #3771 image-fingerprint seeds. The R1 capacity cliff (MAX_ANCHORS) remains out of scope — non-D lanes still rely on the #3753 stopgap.
Verification
npm run typecheckclean;tests/snapshot-lane.test.ts9/9 green locally.kernel/untouched (host-side only); no version bump; plugin-mode path returns the same reference (no behavioral surface there).