Repository navigation
fix(#2202): condition ledger accrual on measured fold coverage - #2231
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2388-pr.2231.89306aaThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2231.tgz
npm install -g packageInstall instructions are refreshed on each push. |
90bb5d5 to
6fd6c25
Compare
Review 完成。七问结论如下。 1. 是什么问题:#2202 —— 宿主在 bili 之外移除已被覆盖的原文(dsh native compaction,#2193)时,cache ledger 仍对"覆盖字节已不在线上"的 fold 持续记账 netSaved,导致虚增(#2193 事故:1510 个被覆盖 id 已离线,账面仍记 355M)。 2. 什么原因导致的:记账与实测覆盖脱钩—— 3. 怎么修复的:把记账条件化到实测覆盖上。每轮 inbound pass 按 blockId 记录 4. 是否有回归问题:逐项审过既有行为,未发现无意回归:健康会话记账字节级不变(+1/sample,legacy-parity 测试钉住);#2202 之前持久化的无 bid 条目保持现状记账;never-present 类(view-folding 宿主,id 从未出现)自校准为现状、不会误冻; 5. 是否破坏缓存:不涉及——未触碰任何缓存键、重试策略、去重键或增量游标。 6. 是否改了设计方向:不涉及——按 owner 批准的方案原样实现。一处解释性偏差提请知悉:floor 2 措辞是冻结份额"不混入 netSaved",实现保留了 pre-loss 的真实节省在 headline 内(那些字节确实没被计费)并单独标注——判断物理上正确,若 owner 倾向完全剔除请指出。 7. 是否引入新配置:不涉及——只有内部 metadata key( 行为变更披露:ledger 每 sample 记账 无条件 +1 → 实测分数 (p+r)/t;健康会话字节级不变;coverage-lost fold 由"继续虚增"改为"冻结至恢复"。这正是本 PR 的目的。 验证与 CI 状态:
判定:PR 本身代码/测试/文档扎实、与批准设计一致、diff 干净;剩余 CI 红是 #2239 的既有问题,非本 PR 引入。#2239 修复后(或 owner 接受已知无关红)即可合并;合并动作按规矩留给人工。 |
|
冲突 rebase master |
6fd6c25 to
121dd7f
Compare
[bot] 🏷 冲突已解,rebase 完成并推送:
CI 会在 |
121dd7f to
a7197c3
Compare
|
解决冲突 |
a7197c3 to
3dc26e6
Compare
|
Rebased onto master (post-#1818/#1851/#2147) — head 3dc26e6. Single textual conflict in Verified locally on the rebased head:
Also confirming the earlier red CI lane ( |
[bot] 🏷 收到冲突唤醒,核查后无需再动——冲突已被解掉,本条告警是过渡态快照。七问摘要:
当前状态:head |
[bot] 🏷 刚核查过:冲突已不存在,无需再解。当前实况(刚刚拉取):
按政策不重复 rebase(冲突解完状态自动转干净)。现在万事俱备:等您合并即可——#2231 。若您 UI 里仍看到 conflict 标记,刷新一下即可,API 侧已是 clean。 |
[bot] 🏷 交叉核对一致,无新增动作。两个会话的独立验证互相印证:
状态维持不变:万事俱备,等合并。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.93-master.8f62fd4 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2202
What this does
The cache ledger books every usage sample against every elapsed fold (
requestsAfter += 1), and the panel turns that counter intonetSaved = Σ (S − σ) × requestsAfter. The booking is a claim that the request benefited from the fold — but when a host removes the covered originals outside bili's knowledge (dsh native compaction, #2193), the claim stops being true while the counter keeps climbing. That is exactly what the #2193 incident showed: netSaved at 355M with 1510 covered ids permanently off the wire.This conditions the claim on the evidence bili already collects per pass — a writer-side fix at the accrual site, not a display patch:
src/fold-reconcile.ts) —reconcileFoldCoveragealready classifies every covered id on every inbound pass (present / re-anchored / unmatched). It now also stores{p, r, t, e}per blockId undersession.metadata["foldCoverageByBlock"]: present verbatim / reclaimed via claim / total covered / ever-present latch.src/cache-ledger.ts) — sparseLedgerFold.bid, set once inrecordCacheFoldsFromBlocks, the single choke point for both the eager proxy path and the lazy plugin-mode path. Pre-[cache-ledger] netSaved 面板在 fold 覆盖坍缩后继续累计虚增——ledger 与实际重发行为无交叉校验 #2202 ledger entries lack it and keep status-quo booking.recordCacheSample) — the increment becomes the measured fraction(p + r) / t:1full coverage (byte-identical to today),fpartial,0verified coverage-lost (frozen until coverage returns). One warn/info log per flip (foldCoverageLostLoggeddedup key).sessions-data.ts/client.ts/i18n.ts) — coverage-lost folds render as separate labeled segments (row tooltip, overview sub-line, detail stat), never inside the headline number. Frozen pre-loss savings stay visible; post-loss growth stops.Behavior change (disclosed)
+1(p+r)/tThe last row is an adjacent fix found while working this issue: the reconcile path had no side-request guard (the sibling #1195 warn gates on
!isTitleGen && len >= 10). A short pass rolls the order backbone onto side-request ids, which breaks the next real pass's alignment and sends missing covered ids straight tounmatched— phantom total-loss feeding both #2193's drift escalation and these coverage records. Such passes now return early without touching anchors, backbone, streak, or records (and without resetting the drift episode — skip ≠ recovery).Tests
tests/fold-reconcile.test.ts— existing fixtures expanded to conversation-sized passes (real hosts resend full history; single-message passes no longer exist in production shape); new describe pins per-block records, the ever-latch, the never-present class, side-pass innocence, and the alignment-skip case.tests/issue2202-coverage-accrual.test.ts(new) — hermetic seam test: fold materialization → healthy accrual → shadowed freeze (exactly one transition warn) → recovery resume (exactly one info); legacy parity and never-present status quo pinned.Stacking note
Built on the tip of PR #2201 (
66a2cf0b9) because both work the same evidence path (fold-reconcile per-pass classification): #2201 is the alarm, this is the accounting fix. Will rebase onto master once #2201 merges.Config surface
None added. No new env vars, config fields, or CLI flags. Internal metadata keys only (
foldCoverageByBlock,foldCoverageLostLogged), sparseLedgerFold.bid, optional web summary fields.Docs: TECHNICAL-NOTES.md "Cache-ledger accrual is coverage-conditioned (#2202)".