Repository navigation
[PR] feat: show nudge-recommended vs actually-folded tokens (recovery rate) in web chart + session report | Closes #6729 - #6745
Conversation
Show per-compression recovery rate (recommended vs actually folded tokens) on the web session chart and in the downloadable session report — the missing visibility behind the ratcheting post-fold floor diagnosed in #6720. - ledger: record real nudge injections (injected branches only; vetoes don't count) and attribute each fold to its nudge round (same/next round + burst <=10min) or to an active compression; stale nudges (>30min) never attribute and their pending amount never labels a newer fold. Stored in the existing sqlite metadata blob, zero schema change, pre-upgrade ledgers just lack the field. - web chart: hollow bar = recommended pending, filled bar = actually folded, green >=80% / yellow 40-80% / red <40% / blue = active; session-average recovery rate + nudge/active counts on the context chart; zoom window filters events by time but keeps the session-wide summary. - report (svg/md): new recovery section with a summary line and an event table; never-folded nudge arms are flagged so the ratchet is visible without any new configuration. - tests/issue6720-nudge-recovery.test.ts: 6 hermetic cases (burst expiry, stale nudge, never-folded arm, empty ledger, non-T1 zero-pending). Closes #6729 Refs #6720
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10327-pr.6745.368151dThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6745.tgz
npm install -g packageInstall instructions are refreshed on each push. |
ranxianglei
left a comment
There was a problem hiding this comment.
独立代码审计(对照 origin/master @ 8964c1f 静态复核,未跑构建)
实现本身核对过:归因规则(同轮/下一轮 + ≤10min burst + >30min 陈旧不标注)与 2026-11-14 裁定一致;recordNudgeInject 只挂在 4 个 prepare 的 nudgeOutcome === "injected" 真注入点,veto/skipped 不落账——正确;首注入时把既有 folds 回填为 active 以保 metadata golden 不变——思路干净;recovery 字段稀疏(无注入不落字段)对 pre-upgrade 库零迁移,符合范围约束。6/6 目标测试覆盖了归因全分支。
三点在合并前需要处理/确认:
1. CI 三个 test job 失败,"基线 flake"说法当前不可验证。
run 43602553780:test (ubuntu-latest, 22, 3) / test (ubuntu-latest, 24, 3) / test (windows-latest, 22, 1) 全部 fail,失败步骤均为 Run node scripts/run-ci-tests.mjs。PR body 声称剩余 12 个失败为干净 master 基线同样复现的 flake,但 master 的对比 run 还在排队、日志侧无法独立核对失败测试名。建议:重跑这 3 个 job,或把失败测试名列表贴出来与 master 基线 run 逐项对齐。
2. 本 PR 相对 master 已落后(base a8bbb8d → master 已到 3c8ad9d/8964c1fe2 之后),合并前需 rebase。
当前 mergeable=MERGEABLE 但 mergeStateStatus=BEHIND。
3. 度量口径的两处已知局限,建议在 PR body 或报告图例里写明白(不是阻塞):
- 非 T1 nudge 的推荐量记 0(
recordNudgeInject:p = nudge.breakdown?.["pendingT1"] ?? 0,higher tiers pass 0)。issue 范围确实只定义到 pendingT1,实现合规;但 #5698 的 stall 会把 T2/T3 蒸馏拉进低 usage 会话(虽然 75000 质量门槛使它们实际很少开火——见 #6729 补充审计 M6),这些 fold 会被标为 nudge-attributed 但 pct=null,totalFolded含其 S 而totalPending不含对应推荐量 → 会话平均回收率在这种事件里会虚高。建议图例注明"pct 仅 T1 可比"。 - burst 链内多 fold 共用同一 nudge 的 p:每个 fold 单独算 pct 没问题,但
summary.totalFolded = Σ(所有 nudge-attributed fold 的 S)而totalPending只按 nudge 记一次——同一 nudge 被 burst 折多次时(例如 13:31→13:42→13:43 那种三连折)Σfolded 可以 > Σrecommended,pct 会超过 100%。这与 #6720 日志里"折得比列表还多"的 4 行对应,属预期但会吓到人;建议 pct >100% 时在图上截断显示或加说明。 - 附带:report 表格 md 只列最近 30 条 / svg 只列 10 条事件(
… +N earlier events),长会话(69 次 nudge 那种)的"未折叠"信号可能被挤出窗口——棘轮信号恰恰常在早期。非阻塞,记一笔。
结论:实现与裁定口径一致、无越界(未触碰 kernel/、无新配置项),单测覆盖归因全分支。合并前请先解决第 1 点(CI 失败对齐基线证据)+ 第 2 点(rebase)。第 3 点是文档级建议。
One point per nudge round (a nudge plus every fold until the next nudge) so several partial folds in one round merge into a single true recovery % — the demo's 4×25% folds read as ONE 100% point, while a ratcheting session reads as 52%, 43%, … (the #6720 shape). Dashed purple = running average; blue ticks mark active (no-nudge) compressions; dot colors green ≥80 / yellow 40–80 / red <40. - cache-ledger: RecoveryReport gains episodes[] (per-round pending/folded/pct/activeFolds) + activesBefore; active folds in a round ride as markers, never in the numerator; non-T1 rounds keep pct null (no NaN) - web panel: new "recovery per nudge round" card in the session detail (recoveryLineSvg, static — rounds are few, no zoom) - session report: same line chart in the .svg image (closes the "report image has no icons" gap) + a numbered per-round list in the .md export - tests: 5 new episode cases (merged 100% round, per-round ratios with in-window actives, activesBefore, non-T1 null, folds-only session); text-safe gate allowlist extended for the recovery tables
|
追加提交 c3a0333:按用户要求补了独立的回收率折线图(面板会话详情 + 下载的 svg/md 报告)。
|
…indow truncation (#6729) Audit point 3 (non-blocking): document the two measurement limitations the owner flagged + the report-window truncation, in the web-panel recovery legend, the downloadable report (md + svg), and the chart legend: - recovery % is only comparable for T1 (non-T1 nudge records recommended mass 0, so its folds inflate the average); - recovery % can exceed 100% when one nudge is burst-folded several times (actual folded > recommended, #6720 'folded more than the list'); - the report table shows only the last N events (md 30 / svg 10) — early 'not-folded' ratchet signal in long sessions may fall out of the window.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— open [PR] 列表里只有一条指向本线程(#6729 可见性),无并列第二 PR。 初审进行中,先报状态:
PR 原无标签,已按 diff 本身打标: CI 跑完后给结构化八问结论。 |
(ai: vllm-qwen/qwen3.8-27b) CI 已全绿(head c522dda,54/54:39 success + 15 skipped 门控 e2e,0 failure),以下为完整 review 结论。 结构化八问
代码与测试审查
判定方向正确(与 #6729 需求逐条对应)、归因实现与 owner 裁定一致、测试钉住全部分支、diff 干净、CI 54/54 绿。 PR 原无标签,已按 diff 本身补: |
(ai: vllm-qwen/qwen3.8-27b) 收到同步。说明两点:
增量八问(仅针对 0df852d,3 文件 +13/-2)
CI(新 head 0df852d,实测): 100/100 check runs 完成——61 success + 33 skipped(门控 e2e)+ 6 cancelled(被新 push 取代的旧 run),0 failure。本地定向复跑(session-report + web-i18n + recovery)30/30 PASS。 判定维持: 可合(feat 类,人工合并)。标签不变( |
Owner review of the first iteration (panel session 01a1daef…): the
recovery bars drawn ON the context-trajectory chart overlapped the
existing red fold lines and could not be told apart; the round line
chart carried almost no information and its header read "recovery
201.9% (nudge 2 · active 0)" — a blended % that hides how many folds
followed a nudge vs happened on their own.
Redo (client + downloadable report, same data):
- The trajectory chart no longer draws any recovery marks — it keeps
only its original fold lines / ceiling / baseline.
- One self-contained time-based chart (recoveryRoundSvg):
* orange ▼ flag per nudge injection (tier + recommended amount)
* one bar per compress() call, height ∝ folded tokens, same-second
bursts spread apart; color = the call's ROUND recovery (green ≥80 /
yellow 40–80 / red <40), blue when the call was active
* one point per nudge round with the TRUE pct labeled (a 310% round
reads "310%", not a silently-clamped top point)
* per-round brackets: span, call count, Σfolded/pending, pct
* honest header: nudge N × · compress M × (post-nudge X · active Y) ·
recommended Σ / folded Σ — no blended percentage
- Report svg/md mirror the same layout; md summary line now leads with
the honest split and flags "folds include older stock" when folded >
recommended.
Verified: typecheck 0, web-i18n/issue6720/session-report 30/30,
client bundle vm-parse OK, panel render + session-report svg checked
against the live 50-doc demo session (16 calls, rounds 100% / 310%).
# Conflicts: # src/web/report.ts
回收视图重做(按 owner 反馈)上一版两个问题(owner 在面板 session
重做(
验证:typecheck 0、web-i18n/issue6720/session-report 30/30、bundle vm-parse OK、面板渲染 + session-report svg/md 对线上 demo 会话实测(16 次调用、回合 100% / 310%)。
|
Review cleanup after the self-contained-chart rework (5141179): - makeChartZoom no longer carries the recovery slice — the trajectory render callback stopped consuming it in the rework, so the state field, zoom filter and bind argument were dead code - trajectorySvg: restore the newline lost between the early return and the layout consts (client.ts:2201) - remove the dangling comment block that still described the deleted recoveryMarkLines hollow-outline behavior Verified: typecheck 0, issue6720-nudge-recovery/session-report/ web-i18n/text-safe/cache-ledger 88/88.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 第 3 轮 review:回收视图重做( 审核范围与验证重做本身(
收尾合并( 本地验证(最终头 审核顺手修掉的小问题(已推
|
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI 更新:新头 |
…unting (#6729) The recovery chart now reads as a line against a central 100% baseline ("the model folded exactly what the nudge recommended"): - 100% baseline drawn and labeled; rounds UNDER it = under-compression (the #6720 ratchet), rounds ABOVE it = over-compression — no more clamp-to-top that hid both directions - dynamic axis extends with the data (step 25/50, capped at 400%) so a 311% round renders at 311%, halo-marked in blue with the true label - solid main line connects round points; the dashed purple running average stays - old-stock accounting (outstanding pool): each nudge adds its pending, folds consume the pool to a floor of 0, the excess is labeled "+N 老 存量" in the bracket and "多压缩(含老存量)" in the point tip — the true pct is kept, but "folded more than recommended" is no longer misread as inflated recovery - the per-round aggregates are now derived client-side from whatever event window the linked brush zoom hands in (open synthetic round for folds whose nudge is off-screen; session-wide summary never lies about a zoomed window); the zoom channel that c2f0b5c removed as dead is back, this time actually consumed - the honest header moved out of the SVG into a card-b div — it collided with the first nudge flag's label (reported 11-15 10:45) - the downloadable SVG report mirrors the same chart (dynamic axis, baseline, main line, halo, old-stock bracket) - web-recovery-card.test.ts lands in git with 8 cases (it had existed only on disk): episode derivation, windowed re-derivation, active-only window, open round, empty window, brush wiring, outstanding-pool accounting, and the baseline/halo/axis rendering Verified: tsc 0; web-recovery-card 8/8; web-i18n+session-report+ issue6720-nudge-recovery+web-blog-route+web-sessions+web-handoff-roles+ golden-storage-render 89/89; full npm test 12259 with 11 failures — all in the known baseline-flake set (#1135, #2443, #3304 ×2, #5627 ×2, v2 setup ×2, out-of-order stamps, opencode-native module-eval), zero new; npm run build OK; scratch-render of a simulated 2-round/311% session shows baseline at 100, 311% point above it, axis to 350%.
|
新提交
验证:tsc 0;targeted 89/89;全量 12259 测试 11 失败全部是基线 flake 清单(#1135/#2443/#3304×2/#5627×2/v2 setup×2/out-of-order/opencode-native),零新增;build OK;用模拟的 2 回合 311% 会话 scratch 渲染确认布局(基准线在 100、311% 点在上方、轴到 350%)。 |
…er rendered (#6729) Review cleanup on d643f0f (two defects, both in the new recovery view): 1. Inverted ternary in recoveryEpisodesFromEvents: 'nv.tier != null ? null : nv.tier' nulls the tier in BOTH branches, so every round point tip showed tier '?' while the nudge flags (nv.tier direct) showed the real tier — a regression vs the round-3 server-side episodes. Fixed to 'nv.tier ?? null'; web-recovery-card now asserts the tier survives derivation. 2. The report SVG read ep.credited to render the '+N 老存量' bracket suffix, but cache-ledger episodes never carry credited/extra (the data layer is untouched by this PR), so the suffix was dead code and the report never showed the old-stock split the panel does. The split is now derived at render time with the same outstanding-pool logic as the panel (round adds pending, folds consume the pool to a floor of 0, excess = older stock); the dead credited/extra fields come off the ReportData interface. session-report.test.ts pins the bracket with a server-shaped payload (no credited/extra fields). Verified: tsc 0; web-recovery-card + session-report + web-i18n + issue6720-nudge-recovery + text-safe 57/57.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 第 4 轮 review:100% 基准折线图重做( 审核范围与验证重做本身(
本地验证(最终头 + 我的清理提交):tsc 0; 审核发现并顺手修掉的两处缺陷(已推
|
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI 更新:新头 第 4 轮判定维持可合,等 owner 合并。 |
# Conflicts: # src/server/prepare-anthropic.ts # src/server/prepare-google.ts # src/server/prepare-openai.ts
(ai: vllm-qwen/qwen3.8-27b) 冲突已解决,master 已合入 PR 分支并推送( 七问
|
#6729) Per reviewer/user feedback: the per-call bars collided with the fold marks on the context chart and the recovery view is about the per-round ratio, which is a line, not an area. - client.ts recoveryRoundSvg: per-call bars removed; each compress() call is now a thin tick on the time axis (blue = active, otherwise colored by its round's recovery) with the same tooltip; the 100% baseline line, the solid per-round recovery line, the cumulative average, round points with true-value labels and the detail brackets are unchanged - report.ts: the downloadable report image mirrors the same tick rendering - i18n: det.rec_bar_* renamed det.rec_tick_*, sub-caption + legend updated - cache-ledger.ts: server-side episodes now also carry credited/extra (the outstanding-recommended-pool split the client already computed) so the report's "older stock" bracket is honest instead of flagging the whole round as extra - tests/web-recovery-card.test.ts: key renames + assertions that no <rect> is rendered and the ticks are present Preflight: typecheck 0 errors; WEB_CLIENT vm parse OK; targeted cache-ledger/issue6720/session-report/web-i18n/web-recovery-card/ web-blog-route/web-sessions/web-handoff-roles/golden-storage-render 129/129; npm run build OK; live session 01a1dda4 (one nudge round, 8 folds, 67.3K recommended, 249K folded = 370% incl. 181.7K older stock) renders without bars, with baseline + true 370% label + 8 ticks. Closes: n/a (follow-up to #6729 on PR #6745)
|
v6:按用户要求把柱子换成真正的折线图(commit 回收率图现在是一条线,不是柱状图:
Preflight(rebase 到分支最新 6279145 之后):typecheck 对本提交 0 错误( 面板已重启(:38787);新的 50 文档演示会话(01a1dda4)本轮更极端:单轮 nudge 推荐 67.3K,模型 8 次折叠共 249K = 370%(其中 181.7K 老存量)——图上是一个基准线上方的蓝圈 370% 点 + 8 根刻度。 |
The activesBefore counter on the recovery report was orphaned by the round-3 view rework: the panel re-derives per-round episodes client-side and the report renders rec.episodes/rec.events, so no UI reads it. Drop the field, its computation, and its type declaration; keep the two behavioral assertions (pre-nudge actives stay out of any round; a folds-only session yields no episodes) on the surviving fields.
ranxianglei
left a comment
There was a problem hiding this comment.
✅ Review: 可合入(APPROVE 等效)
注:PR 作者与审核账号相同,GitHub 不允许 approve 自己的 PR,故以 comment review 形式给出等效结论。
PR 已审完(v6 head c5f573f7ed + 顺手修 9a30dee80b)。方向正确、实现干净、测试到位,可合入。
v6 折线图改造(c5f573f7ed,按用户要求):柱状图 → 真折线图。
- 每次 compress 调用 = 时间轴底部 2px 细刻度(
<line>;蓝=主动压缩,其余按所属回合回收率着色),SVG 已无<rect>。 - 主角是线:100% 基准线(粗,标注「基准 100%=恰好折完推荐量」)+ 实线连接各回合真实回收率点 + 紫色累计平均虚线;>100% 回合在基准线上方(蓝圈 + 真值标签),棘轮会话在下方。
- 下载的 svg/md 报告镜像同一渲染。
- 服务端 episodes 补了 credited/extra(推荐池结算),报告「老存量」数字与服务端一致。
定向验证:typecheck 0 错误;定向 5 测试文件 86/86 通过(issue6720-nudge-recovery / session-report / web-recovery-card / text-safe / cache-ledger)。
已顺手修:移除死字段 activesBefore(round-3 视图重构后无 UI 消费者——面板客户端侧重算回合、报告读 rec.episodes/rec.events,该字段只被计算从不被读)+ commit 9a30dee80b。保留两条行为断言(首个 nudge 前的主动折叠不进任何回合;纯折叠会话无回合)。
结构化八问
- 是什么问题:#6729 要把「nudge 推荐折叠量 vs 模型实际折叠量(回收率)」可视化到 web 图表 + 会话报告;v6 按用户要求把柱状图改成真折线图。
- 什么原因导致的:nudge 推荐折叠一定量 token,但模型实际折叠量会偏离推荐量(棘轮会话折得少、激进会话折得多);用户需要看到偏差(回收率)来评估 nudge 有效性。
- 影响范围与严重程度:纯新增可视化,影响所有有 nudge 注入的会话的 web 面板 + 报告下载;无 nudge 注入的会话不受影响(recovery 段缺失、metadata 字节对齐)。体验增强,非缺陷修复。
- 怎么修复的:数据层在 4 个 prepare-* 钩子的
nudgeOutcome === "injected"点记录 nudge 事件、在折叠单点(pushFold→recordFoldRecovery)把每次折叠配对到触发它的 nudge(10min 突发窗 + 30min 新鲜度门);报告层聚合回合级回收率;视图层用自包含时间轴折线图渲染(100% 基准线 + 实线回合点 + 紫色累计平均虚线 + 2px 调用刻度)。 - 是否有回归问题:无。recovery 段是纯新增字段(无 nudge 注入的会话该段缺失、字节对齐);4 个钩子只在
injected时记录(早退错误路径在钩子之前);视图层是新增图表、不触碰既有轨迹图。顺手修是纯死代码删除、无行为变更。高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。 - 是否破坏缓存:不涉及。recovery 数据来自内部 cache ledger(非用户输入),不触碰缓存失效/重试/增量游标/去重键。
- 是否改了设计方向:不涉及。纯新增可视化,不改变压缩引擎/上下文管理/会话核心的架构、边界、数据流。
- 是否引入了新的配置:不涉及。无新 env/config/默认值。
已审完 v6(head 已顺手修:移除死字段 完整 review + 八问见 comment review: |
[bot] 🏷 已审完 PR #6745(v6 head 结论:可合入(APPROVE 等效)——作者=审核账号,GitHub 不允许 approve 自己的 PR,故以 comment review 给出等效结论(review id 做了什么:
验证:定向 5 测试文件 86/86 通过;typecheck 0 错误;CI 30/30 全绿(0 failed)。 八问:见 comment review( 协调 issue:任务要求「在协调 issue 报一行」,但 dispatch 未给协调 issue 编号、上下文里也查不到(搜索结果里该词被脱敏、无编号)——标记此缺口,不瞎猜。 |
) One point per compress() call (x = time, y = folded / that nudge's recommendation), so no compression is ever hidden inside an aggregate: a round's points sit on the line and their sum equals the round recovery. Nudges demote to ▼ flags (tooltip: tier + amount + time); compressions without a measurable recommendation stay visible as colored axis ticks (blue = active, grey = non-T1). - dynamic axis: 100% baseline is the central reference (multi-fold rounds can push the axis to 400%); over-100% points get a blue halo and true labels; a cumulative mass-weighted dashed line shows where the running average stands - per-fold tooltips name the call (round i, call k/n), folded vs recommended and the rate; brackets keep the per-round totals with the old-stock split (+N 老存量) - report.ts mirrors the chart (server payloads may carry the per-fold pct without pending — stored pct wins, pending-derived is the fallback); i18n zh/en: new det.rec_flag_tip / det.rec_bracket_open, dead keys pruned (det.rec_leg_line, det.rec_line_under_note, det.rec_nudge_tip, det.rec_unfolded) - tests: 9 cases incl. "a round's points sum to its recovery", open-round (unclosed) brackets and no-recommendation ticks
…th per round (#6729) Second chart series answering #6720's ratchet question: does compression keep up with NEW context growth, or does the floor ratchet up? - per round: growth = round peak − pre-round floor; point y = folded ÷ growth - floor = lowest input after the previous round's last fold and before this round's nudge (window min for round one): a fold is itself a drop, so an in-round min would sit right after an earlier fold and inflate "growth" - two conversations can share one session UUID (dsh-client #5792): samples below 25% of the window max are a different stream and are dropped from the floor/peak sets - <100% each round = the ratchet (floor keeps rising); over-100 = the round re-took the floor or older stock; no new growth (pure older-stock cleanup) → hollow marker on the 0% axis, no fake percentage - thick blue line, own legend entry, axis scales with both series (cap 400%) - same series in the markdown report svg; i18n zh/en
|
新增「增长回收线」(47e59a9)——回答 #6720 的台阶问题:每轮压缩到底有没有把新长出来的上下文压回去。 压缩回收图里多了一条蓝色粗线,每个 nudge 回合一个点,纵轴 = 本轮压缩量 ÷ 本轮上下文净增长(上一轮压完后的地板 → 本轮峰值):
两个关键语义:
本地真模型 demo(50 篇文档、1 nudge、8 次压缩):增长 72K → 压掉 249K → 345%(过线 = 地板拿回来了 + 老存量)。markdown 报告同图同步。测试 +4。 老规矩:等人工合并。 |
The growth-line rework dropped the *1.1 headroom that both the panel (client.ts) and the pre-rework report used, so the report's y-axis sat tight on the max point while the panel left a gap. Restore the margin so the report mirrors the panel for the same data.
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
结论:可合入(APPROVE 等效)——审完新增两笔提交(fe4b75b3a8 每次压缩都上折线 + 47e59a9deb 增长回收线)+ 我顺手修的一笔(72f5c2e388)。作者=审核账号,GitHub 不允许 approve 自己的 PR,故以 comment review 给出等效结论。
正确性:
- 增长回收线回答 #6720 的台阶问题——每轮到底有没有把新长出来的上下文压回去。地板取「上轮最后一次折叠之后、本轮 nudge 之前」的最低输入(不是轮内最小值——折叠本身就是一次下跌,轮内最小值会卡在上轮压完之后把增长虚增 ~10 倍,真实数据量出过 16119% 假点);峰值取 [轮起点, 末次折叠+2min] 的最大输入,低于峰值 25% 的样本视为另一条流剔除(dsh-client #5792 同 UUID 混两条对话)。对照测试用例逐轮验证:R1 110%(过线)、R2 71.4%、R4 29%(台阶),地板/峰值/增长量都对。
- 数据源可靠:ledger 的
lines带at/input/cached(cache-ledger.ts:1651),面板走 brush 窗口的 lines、报告走led.lines,两侧增长线算法一致(同一套地板/峰值/增长计算)。 - 「每次压缩都上折线」:可测的压缩各一个点(折叠÷当时 nudge 推荐量)按时间连线,nudge 降为 ▼ 标记,无推荐量的压缩(主动/非 T1)保留为轴刻度不放过;纯清老存量(本轮无新增长)= 0% 轴空心点、不标假百分比。
测试:+4 新测试(增长线三轮地板/峰值、平轮空心标记、每次压缩上折线、无采样时增长线静默关闭+图例提示),更新开放回合编号(round 1 而非 0)+ 每压缩点 + 无推荐刻度。定向 31/31 通过、typecheck 0 错误、CI 30/30 全绿。
已顺手修:报告侧 y 轴上限丢了 *1.1 顶空(面板 client.ts 和改造前的报告都有,新报告改成了 ceil(maxPct/50)*50 紧贴最高点,同数据下面板留空报告贴顶)——已恢复 margin 让报告与面板一致 + commit 72f5c2e388。
八问:
- 是什么问题:#6720 报告的「上下文台阶上涨、压不回去」缺一个直接读数——每轮压缩到底有没有把新长出来的部分压回去。
- 什么原因导致的:原回收图只画「折叠÷推荐量」(有没有照单折完),没有「折叠÷净增长」(上下文有没有真的降下来)这条线;台阶问题需要后者。
- 影响范围与严重程度:纯新增可视化(web 面板 + 下载报告),不影响压缩行为/数据/缓存;无增长采样时增长线静默关闭并给图例提示,其余照常渲染。体验增强,无破坏面。
- 怎么修复的:在 web 层(client.ts 面板 + report.ts 报告)从请求用量采样推导每轮地板→峰值的净增长,画一条蓝色粗线(每轮一点);地板严格取上轮末次折叠之后、本轮 nudge 之前的最低输入,避免折叠自身下跌造成的虚增;同 UUID 双流用 25% 峰值阈值剔除。
- 是否有回归问题:审过既有行为——回收图原有元素(100% 基线、累计平均虚线、回合括号、nudge 标记、主动刻度)全部保留且测试钉住;
activesBefore死字段已在上轮移除;本次仅新增增长线 + 每压缩点,未改既有语义。无回归。 - 是否破坏缓存:不涉及——纯读侧可视化,不触碰缓存/重试/增量游标/去重键。
- 是否改了设计方向:不涉及——在既有回收图内加一条线,不改架构/边界/数据流。
- 是否引入了新的配置:不涉及——无新 env/config/默认值。
判定:可合入,等人工合并(feat: 类,§7.4 人工合并)。
[bot] 🏷 已审完新增两笔提交( 结论:可合入(APPROVE 等效)——作者=审核账号,GitHub 不允许 approve 自己的 PR,故以 comment review 给出等效结论(review id 做了什么:
验证:定向 31/31 测试通过;typecheck 0 错误;CI 30/30 全绿。 八问:见 comment review( 等人工合并(feat: 类,§7.4)。 |
…rkers (#6729) Blue #0969da belongs to the active-fold ticks and the over-100% fold dots; on a single-round session the lone blue growth dot read as an "active compression" (user report). The growth series is now teal #1b7c83 end-to-end (line, labels, halo, flat marker, legend swatch) with hollow dots, in both the web card and the markdown report svg.
…6729) "主动压缩(蓝色刻度)" / "active compression (blue tick)" named a color in the copy — after the growth line moved to teal, text color names just invite confusion (the swatch next to the label already shows the color). Legend now says 主动压缩(底部刻度) / active compression (axis tick); the chart subtitle no longer calls the ticks blue/grey.
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1218-master.0821a81 # this exact build
npm install -g billion-context@master # always the newest merged build
|
feat: web panel + session report show nudge-recommended vs actually-folded tokens per compression, with recovery rate
Closes #6729. Visibility half of the #6720 diagnosis.
人话
billion-context 每轮 nudge 会列出「推荐压缩这些段,共 ~50K token」,但模型经常只压其中一小部分——#6720 里 19 次提醒只换来 19 次单段折叠,每次压完的地板反而越压越高。问题是:以前没有任何地方能看到「推荐了多少 vs 实际压了多少」。本 PR 把两者画出来:
归因规则(owner 2026-11-14 定)
度量口径说明(审计第 3 点,已在图例/报告标注)
recordNudgeInject只取pendingT1,非 T1 nudge 的推荐量记 0。其折叠计入折叠合计但不计入推荐合计,会抬高平均回收率。图例已注明。改动
src/cache-ledger.tsrecordNudgeInject(session, nudge):仅在 4 个 prepare 协议的真实注入点(nudgeOutcome === "injected")调用,veto/skipped 分支不算。pushFold唯一收口,追加 recovery 事件(含归因、推荐量、pct)。CacheLedger.recovery?随 metadata_json 落 sqlite,零迁移、零 schema 变更;pre-upgrade ledger 无此字段 → 报告显示旧行为(无该节)。buildSessionCacheReport输出recovery: { events, summary }:per-nudge 配对 + 会话平均回收率。src/server/prepare-{openai,anthropic,google,responses}.ts:各 1 行 hook + import(最终 return 前;早期错误 return 均在注入点之前,不受影响)。src/web/client.ts:trajectorySvg新增 recovery 条(token 轴同比例尺);makeChartZoom的 state/visible/render 通道透传 recovery,zoom 窗口按时间过滤事件,summary 保持全会话值(窗口内不谎报)。src/web/report.ts+src/web/i18n.ts:svg/md 两版报告新节 + en/zh 词条。tests/issue6720-nudge-recovery.test.ts:6 用例 hermetic(同轮+burst 归因、无注入=主动、burst>10min 断链、>30min stale 不标注、never-folded arm 全额计入 pending、空 ledger 无 recovery 节、非 T1 层级 zero-pending 不产生 NaN)。不做的事
Preflight
npm run typecheck:PASS(exit 0,无输出)tests/issue6720-nudge-recovery.test.ts:6/6 PASStests/cache-ledger*.test.ts/tests/session-report.test.ts/tests/issue4649-conflict-report-client-coverage.test.ts:55/55 PASStests/golden-storage-render.test.ts(4 协议 wire bodies + persisted state 快照):5/5 PASS——metadata_json 在无 nudge 注入的会话中保持字节级不变(recovery 字段只在首次真实注入时落盘,更早的 fold 以 active 身份回填),golden 无需更新npm test:11973/12052 PASS;12 个失败全部在本机干净 master 基线 worktree(a8bbb8d23,零改动)上复现——live bili 实例干扰 storage golden 的泄漏守卫告警两边同时出现,与本次改动无关的既有环境 flake(native attach 模式(opencode 面)同样缺运行时 respawn:V2 route hook fail-closed + V1 launcher 插件 frozen origin #1135 attach、opencode lane never registers acp_retrieve — CCR placeholders advertise an unreachable tool (plugin mode) #2443、opencode-native ×2、out-of-order stamps、v2 setup ×2、When the proxy goes down, incremental rounds fall back to direct connection, sending the incremental payload as-is to upstream and causing a 400 (same mechanism across opencode/omp/dsh-native). | 代理挂掉时增量轮次降级直连会把增量载荷原样发给上游导致 400(opencode/omp/dsh-native 同一… #3304 ×2、Unified store auto-disabled after RangeError: Maximum call stack size exceeded #5627 ×2、family gate),本次改动零新增失败npm run build:PASS(exit 0,tsup + write-build-info + dist-import-annotations OK + dist-external OK)