Skip to content

[PR] kernel: fold coverage keyed on ledger seq intervals — churn-immune blocks (#4316 layer 3, PR 2/3) - #4552

Merged
ranxianglei merged 5 commits into
masterfrom
2026-10-24_seq-coverage-evidence
Oct 24, 2026
Merged

ranxianglei merged 5 commits into
masterfrom
2026-10-24_seq-coverage-evidence

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #4316 (layer 3, PR 2/3 — see the plan comment #4316 (comment)). Also unblocks master tsc (rides a one-line fix for the #4525 rename miss, see second commit).

问题

#4316 层 1/2(#4505 msgid pin + 服务端正史)让插件车道的消息行有了稳定身份,但折叠记账仍按 id 列表(effectiveMessageIds):任何 id 重铸(切模型重盖章/图片重编码/宿主改字节)都会让块覆盖失配,只能靠 fold-reconcile 的证据链救火(1057 失配救回 1038,救不回的变死 ref + churn 区膨胀重折)。这是 #4316 病族的最后一块。

改动(kernel 双轨 + lane 传输)

  • CompressionBlock 增可选 startSeq/endSeq:折叠范围内消息全部带 ledgerSeq 章且区间精确连续才记录(合并相邻/重叠覆盖段;任一无章、无界或有洞 = 不记录,never guess —— 桩 S10 钉死这个诚实降级)。
  • prune 区间覆盖:rebuildMessages 在 id 覆盖判定之后加 isCoveredBySeq —— 带章消息落任意活跃块区间即压制原件,与 id churn 彻底解耦;无章流量走 id 老路,行为字节等价(S8 对照组钉死)。
  • syncBlocks 活性第三析取项 blockSeqPresent:块有界 + 任一在场消息带章落区间 = 块仍活着,防止 id 重铸引发 deactivate 丢覆盖。
  • 章的传输(插件车道):canonical 行带 ledgerSeq(store 0 基→显示 1 基)以 biliLedgerSeqs 平行数组随 turn body 传输(与 biliMsgIds 同位;严格校验,拒绝即降级不猜;转发前剥离不上游泄漏);prepare-anthropic 在 msgid pin 同位重钉;lane assembly 对本 turn 未落库尾部按 maxSeq+1 递增投影;recordCanonicalPointers 每 wrap-up 回写行章。
  • 行身份免疫章:identityInputOf 剥除清单加 ledgerSeq —— 服务端晚加的位置章不参与行身份哈希(否则每轮带章重入库整段换血,调试中实打实测到 29 行三代)。

搭乘:master tsc 修复

#4525 把 sidScope 改名 dispatchScope 漏改 C10b fork-blind-spot 日志一处 → master tsc 红(TS2304,CI 40093629255 同因失败)。第二 commit 一行修复(读 dispatchScope.getStore() 按 {sid,msgIds} 形状取 .sid)。

桩(先红后绿)

  • kernel/tests/seq-interval-coverage.test.ts 4/4:S8 盖章折叠记区间 + id 全换(seq 不变)后按区间压制原件,对照组(无章 churn)丢覆盖=现状文档化;S9 syncBlocks 盖章 churn 视图保块活性,对照组 deactivate;S10 部分盖章=不记界;S11 相邻联合区间精确 + 空洞不记录。
  • tests/seq-interval-lane.test.ts 1/1 端到端:12 消息 lane → turn-2 fold(POST /__bili/plugin/tool)→ store blocks.start_seq/end_seq 落真值 + payload_json 带区间章 → 出站压制被覆盖原件(b2/b3/b4)+首用户钉存活(u1,#DESIGN §8.1)+摘要乘 plugin mode: in-place acp_summary never stripped when the client's own compress pair rides inbound — double summary carrier on every post-fold turn #1567 载体回显(客户端回显 tool_use 的 args 就是载体)+ biliMsgIds/biliLedgerSeqs 不泄漏上游。

验证

  • 定向:seq-interval-coverage 4/4、seq-interval-lane 1/1、msgid-lane-flow 5/5、incremental-lane 24/24、msgid-pin 9/9、msgid-algebra 14/14、plugin-render-endpoint 7/7、snapshot-render 12/12、snapshot-render-chain 6/6、judge-baseline 1/1、golden-storage-render 5/5、wire-contract 22/22、storage-engine-bootstrap 44/44、storage-unified 14(1 skip)、storage-review-p2s 6/6、issue3250 5/5、dsh recall+msgids 11/11。
  • npm run typecheck 0 错;check-unused-exports clean(6 waived);kernel 0.0.161→0.0.162 + lock-sync。
  • rebase 于 master 6d7c587([PR] merge: tier-1 consolidation train — 37 green PRs as one (conflicts resolved, #4294 reverted) #4525 后)。

Out of scope(PR 3/3)

fork cloneRows 保号 + 存量重铸窗口;D5-5 渲染分窗(区间落地后顺势变 SQL 查询,单独 PR)。

kernel-change: types/prune/sync/compress interval bookkeeping + kernel tests 4

…une blocks (#4316 PR2/3)

- CompressionBlock gains optional startSeq/endSeq, recorded only when the
  folded span is fully stamped and exactly contiguous (never guess).
- prune: positional coverage (isCoveredBySeq) runs after the id path —
  stamped messages inside any active block's interval are suppressed even
  after an id re-mint; unstamped behavior is byte-identical.
- syncBlocks: a bounded block stays alive while any in-view stamped message
  falls inside its interval (third disjunct), so model switches can no
  longer deactivate coverage through id churn alone.
- plugin lane: ledgerSeq stamps ride the turn body as biliLedgerSeqs
  (parallel array, strict validation, stripped before upstream), re-attached
  at prepare-anthropic next to the msgid pin; the lane assembly projects
  unstamped tails at maxSeq+1 and recordCanonicalPointers rewrites stamps
  each wrap-up; identityInputOf strips ledgerSeq so stamped re-ingest never
  re-keys rows.
- stakes: kernel seq-interval-coverage 4/4 (churn-immune prune + sync,
  honest unstamped fallback, exact interval merging), lane e2e
  seq-interval-lane 1/1 (store start_seq/end_seq + payload interval,
  outbound suppression, first-user pin, #1567 carrier).

kernel-change: types/prune/sync/compress interval bookkeeping + 4 tests
…the #4525 rename

The tier1 consolidation train renamed sidScope (AsyncLocalStorage<string>)
to dispatchScope (AsyncLocalStorage<{sid,msgIds}>) and updated the main
attribution path but missed the C10b fork-blind-spot logger, leaving master
tsc red (TS2304 sidScope, dsh-native.ts:1287; CI run 40093629255 failed on
the same break). Read dispatchScope.getStore() and test .sid — semantics
unchanged (scoped attribution active).
@ranxianglei ranxianglei changed the title kernel: fold coverage keyed on ledger seq intervals — churn-immune blocks (#4316 layer 3, PR 2/3) [PR] kernel: fold coverage keyed on ledger seq intervals — churn-immune blocks (#4316 layer 3, PR 2/3) Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-24_seq-coverage-evidence (08e60be)

Latest build — install this exact version

npm install -g billion-context@0.0.5505-pr.4552.c351630

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

Recent builds (commit → version)

commit version build
08e60be billion-context@0.0.5505-pr.4552.c351630 build
82578de billion-context@0.0.5498-pr.4552.0040b57 build
6932ab4 billion-context@0.0.5496-pr.4552.5d6b1f9 build
673bf55 billion-context@0.0.5494-pr.4552.11fcdab build

Download artifact

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

Install instructions are refreshed on each push.

…e ledger guard

Master-side gap: the #2222 escape hatch landed in src/launcher.ts without a
LIFECYCLE.md row, so the exact-match ledger guard fails every push that
runs it after that merge (including this branch's CI).
@ranxianglei
ranxianglei merged commit 0d9fdae into master Oct 24, 2026
24 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.820-master.0d9fdae (rolling master tag).

npm install -g billion-context@0.0.820-master.0d9fdae  # 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

None yet

Projects

None yet

1 participant