Repository navigation
fix(#2929): fold claim window covers the post-fold cold tail - #2934
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3312-pr.2934.27b87e8This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2934.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ly, never re-arm on foldSeq-stamped lines
7ffa5b1 to
c019591
Compare
[bot] 🏷 Review 完成,修复已作为增量 commit 推到分支( 审查结论(方向):根因修对了——#2929 的 seam 告警是「折叠后冷尾回显重计费无归因」掉进 审查中发现并已修复(独立标注 commit):
另:分支已 rebase 到当前 master(f8f7d40,#2923),无文件交集。本地定向测试全绿(host 42/0、kernel cache-report 25/0、web-i18n 10/0),全量矩阵交给 CI。 |
A degenerate head fold (81-100% coverage) rewrote the whole prefix, but the claim window only consumed the FIRST sample after it - the proxy re-request. The client's echo re-bill ~25-66s later carried no foldSeq, fell into the unattributed ttlRepay residual, and tripped cache-seam with "no fold attribution". Every one of #2929's seven seams was exactly this shape. Mirror the #1847 switch discipline for folds: - kernel buildCacheReport: a fold claims its first sample unconditionally, then COLD continuations (hit < FOLD_CLAIM_WARM_HIT_PCT=85) up to FOLD_CLAIM_COLD_ROUNDS=4; a warm line retires every open window. - cache-ledger recordCacheSample: same state machine on the sparse LedgerFold.claims/retired fields (legacy persisted ledgers keep the first-claim behavior). - web trajectory chart: cause heuristic mirrors the window (foldSeq-first, fold-between-times fallback for pre-#2929 ledgers). - i18n: the residual bucket is honestly "unattributed" (upstream TTL/eviction/unknown), not "TTL expiry"; seam tip mentions post-fold echo re-bills. kernel 0.0.119 -> 0.0.120.
…ly, never re-arm on foldSeq-stamped lines
The same comp bucket appeared as 压缩折损/压缩/压缩后重新建缓存/压缩复付/压缩回补 and the residual bucket as 未归因前缀失效/未归因/未归因回补 across the overview, session list, detail card, miss-split line, chart tooltips and economics copy. Canonical zh terms now: 新内容 / 压缩回补 / 未归因回补(上游TTL/淘汰/未知)/ 残差; en mirrors: new / comp repay / unattributed repay / residual. Also fixes the attribution-section note, which claimed the seam/provider/ rewind/prompt/projection partitions are "not counted in TOTAL above" — they are refinements OF the unattributed repay bucket and are already included in it (abort stays an overlay counted in no bucket).
…normal
The provider-side arm (byte-stable / append-shaped miss with no fold or
switch attribution) conflated two very different situations: a miss
seconds after the previous request (abnormal — upstream eviction or
relay rotation) and the same miss after a 20-minute idle (normal — the
upstream prefix cache simply aged out). The web page labeled both
"上游侧失效", which reads as a failure when it is expected cost.
- cache-ledger: bookProvider() splits by idle gap
(PROVIDER_TTL_GAP_MS = 10 min, mirroring the chart's GAP_MS) into
agg.providerTtlMissed (normal) vs agg.providerSideMissed (abnormal);
seam.providerTtl{count,missed} rides the ledger + /acp-cache report
(⏱ UPSTREAM TTL EXPIRY — NORMAL section).
- web: attribution card gains the ⏱ 上游 TTL 过期(正常) mini (green);
▲ 上游侧失效 re-labeled (异常) with a short-gap qualifier tip.
- web: the headline hit-rate subline is the three-bucket split only —
the seam/provider/rewind/abort/prompt/projection chips duplicated the
归因 · 未解释残差 card below and mixed taxonomy levels (#2929).
- taxonomy rename: 折叠后重读重建 → 折叠后重建 / post-fold re-read →
post-fold rebuild.
- tests: gap-split case (short-gap → providerSide, long-idle →
providerTtl) with a pinned Date.now (settleUsageReport stamps it
internally); dead chip keys removed from both locales.
…rries the providerTtl split
…s an inline breakdown The economics card and the separate attribution card read as two parallel grids, hiding that seam/provider/TTL/rewind/abort are subsets of the unattributed-repay bucket. Render them as an inline breakdown inside the 未归因回补 mini (zero rows skipped, residual row only when >8192) and keep the standalone card only for the seam event list. Rows use literal t() calls so the #1024 dead-key scan still sees every tip key.
bfc0289 to
41eeefa
Compare
…o duplicate grids The previous pass nested a line list inside the unattributed KPI tile and kept a second attribution grid with a duplicate seam mini + event list (the events table already lives under the trajectory chart). Now the four KPI tiles stay clean, the bucket composition renders as one subordinate strip directly beneath them (containment is the layout), the redundant attribution section and attr_title/attr_note keys are gone, and the stale en 'Post-fold re-read' label is renamed to 'Post-fold rebuild'.
…ution
The chart used to re-derive miss causes with its own gap heuristic, so the
paint and the economics card told two different stories, and the legend
asserted a guess ('likely upstream TTL/eviction'). detectSeam now stamps
each settled line with the arm it booked (prov: ttl | side | rewind; seam
already existed), the report exposes seam/prov per line, and the chart
paints those fields first — the gap heuristic remains only as the legacy
fallback for old ledgers. The unattributed family renders as one bordered
legend group (⊇) with only the sub-causes that actually occur, matching
the economics composition strip bucket-for-bucket.
… mini() Hand-rolled the tile with class="mini", which is not a CSS class in this page (the helper emits class="stat"), so the tile rendered as bare text between its boxed neighbours and the row looked broken. One-liner: call mini() like its three siblings, which also gives the tile the "?" qmark with the bucket tooltip.
…ion stamps detectSeam now stamps each settled line booked into a provider-side arm (prov: ttl | side | rewind); the golden fixture's 8 side-arm lines carry the new sparse field. A/B persisted-state dump (b896a09 vs this head) shows exactly those 8 fields and nothing else.
…ds bind to their bars Requested after visual review of the rendered page: - The 'of which' breakdown (seam / TTL / provider / rewind / rest) was a caption floating under the KPI row — it is now part of the unattributed-repay tile itself: label · value · then the parts, top to bottom. Containment is the layout, not an annotation beside it. The dead ce_ttl_tip qmark key goes away. - The trajectory chart only labelled samples 1/5/10 and each miss-cause band floated free of any bar, so band-to-bar mapping required detective work. Now every sample gets a seq label (thinned only when dense) and each band drops a thin same-colour spine from its floor to the baseline, tying it to the exact bar column it annotates.
[bot] 🏷 Review complete — PR #2934 ready to merge. CI fully green on head 结构化八问
Review 过程说明(diff 之外做了什么)
合并判定可合——但按 Kernel Boundary 规则 3, |
…loor `Math.ceil(24 / Math.max(barW, 1))` clamped sub-pixel bar widths UP to 1px, so sessions with thousands of samples (barW≈0.36) always got tStep=24 → 100+ overlapping vertical labels. The demo case (N=10, barW≈99 > 1) never exercised the clamp, which is how it shipped. Drop the inner max (the ternary guarantees barW>0 for N≥2, N=1 → 1): dense charts now hold the intended ~24px horizontal pitch (N=2494 → tStep=68 → 37 labels).
Show a one-line small-text hint on the 折叠后重建 tile whenever the value is non-zero: lowering compress.preserveRecentMessages (the protected recent-message count) reduces how much recent content each fold drags back into context — minimum recommended value 1. Bilingual zh/en, conditional so zero-rebuild sessions stay clean.
▲上游侧失效 reused #bf8700 (the 折叠后重建 amber) while 其余 rendered as #656d76 dim — two muddy earth tones that read as one color at chip size. Align the provider-side chip with its chart band (#f0883e) and lighten the rest-of-dust chip to neutral #9aa1a8, so every bucket now has a distinct hue: red seam / green TTL / orange provider-side / slate rewind / gold abort / light-gray rest.
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.339-master.aeb39a7 # this exact build
npm install -g billion-context@master # always the newest merged build
|
The chart legend's 'rest' swatch shared the parent group's purple (#8250df == det.cause_unattrib), so 其余 was indistinguishable from 未归因回补 itself. Point CAUSE_COLOR.rest and the two standalone legend swatches at #9aa1a8 — the same light gray the economics card chips already use (ranxianglei#2934/e76b35f9), keeping card<->chart consistent.
What
The fold claim window is the post-fold cold tail, not just the first sample. Mirrors the #1847 model-switch cold-window discipline, applied to folds.
Why (#2929)
Issue #2929's log showed 7 cache-seam warnings (~284K tokens re-billed on the chip), each landing 25–66s after a degenerate head fold (foldPoint=m00001/m00009, shrink 81–100%). Mechanism:
bilire-request view).ttlRepayresidual and tripped the cache-seam detector with "no fold/switch/restart attribution".bili's own observability already knew (degenerate-fold warn + "cache ceiling ≥0%" prediction) — the seam detector just didn't credit it.Change
buildCacheReport: a fold claims its first sample unconditionally, then COLD continuations (hit <FOLD_CLAIM_WARM_HIT_PCT= 85) up toFOLD_CLAIM_COLD_ROUNDS= 4; a warm line (≥85%) retires every open window. Constants exported for host parity. kernel 0.0.119 → 0.0.120.cache-ledger: same state machine via sparseclaims/retiredfields on the persistedLedgerFold(legacy ledgers without the fields keep first-claim semantics).line.foldSeqwhen present; fold-between-times fallback for pre-codex 命中率问题分析 #2929 ledgers), so the chart's comp-coloring matches the ledger's comp bucket.Effect on the #2929 numbers: the echo re-bills move from "unattributed TTL" (284K chip) into 压缩回补 (comp repay) where they belong; seams no longer fire for this shape (the a211 sessions had 10 folds but only 1 seam-shaped echo — now claimed).
Testing
cache-report.test.ts+3 (cold-tail full chain: re-request + echo + recovery all foldSeq=1, warm retire, later blip falls to unattributed; COLD_ROUNDS bound; warm-first single-claim) — kernel suite 1281/1281.tests/issue2929-fold-claim-window.test.ts5/5 (echo claimed + no seam + cr bucket; warm retire; bound; sparse-field legacy; constants parity) — ledger battery (cache-ledger + 4 switch families + seam-detector + 1547/1891/1843 + provenance + compress-observability + 2929) 122/122.tsc --noEmitclean,npm run buildOK.Refs #2929 (accounting/attribution half; the growth-threshold tuning it also surfaces is separate).
kernel-change: #2929 —
buildCacheReportmust apply the same post-fold COLD TAIL claim window as the host's incremental cache-ledger (first following sample claimed unconditionally, then cold continuations hit<85% up toFOLD_CLAIM_COLD_ROUNDS=4; any warm line ≥85% retires every open window — the #1847 model-switch discipline mirrored for folds). The batch report is built inside the kernel, so the host cannot express this without duplicating report logic;FOLD_CLAIM_WARM_HIT_PCT/FOLD_CLAIM_COLD_ROUNDSare exported from the kernel as the single source of truth for host parity.Storage-render golden regeneration (review follow-up)
tests/golden/storage-render/{anthropic,responses,google}.jsonregenerated vianode --import tsx scripts/update-storage-render-goldens.ts. The persistedLedgerFoldnow carries the sparseclaims/retiredfields this PR introduces, so the goldens'metadatasection digests drift BY DESIGN — only that section moved (state/blockContents/statsunchanged;chat.jsonuntouched, no cache ledger on that wire). A/B dump of the full persisted session (master f8f7d40 vs this head) confirms the only changed bytes are the cache-ledger subtree: the fold claims 4 samples and retires, the echo re-bill lines move from unattributedttlRepay(foldSeq: null) into comp repay (foldSeq: 1), andseamSuspectsdrops 2 → 0 in the fixed scenario. This is the intended #2929 attribution change pinned into the snapshot, not incidental drift.The follow-up commit
518ff78e1(provider-side miss split by idle gap) added the newproviderTtl{Misses,Missed}ledger fields and re-refreshed ALL four goldens (a59b9e2ec) so the snapshots pin both attribution changes; legacy ledgers migrate the new agg fields to 0 via the existing getCacheLedger guard.