Skip to content

[PR] feat: show nudge-recommended vs actually-folded tokens (recovery rate) in web chart + session report | Closes #6729 - #6745

Merged
ranxianglei merged 18 commits into
masterfrom
2026-11-14_recovery-visibility
Nov 16, 2026
Merged

ranxianglei merged 18 commits into
masterfrom
2026-11-14_recovery-visibility

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

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 把两者画出来:

  • web 会话详情的上下文曲线上:每个 nudge 一个空心轮廓(推荐量),每次压缩一个填充条(实际压缩量)——轮廓没被填满的部分就是漏网的棘轮;颜色按回收率:绿 ≥80%、黄 40–80%、红 <40%、蓝 = 主动压缩;左上角一行给出全会话平均回收率(Σ实际/Σ推荐)+ nudge/主动次数。
  • 可下载的 session report(svg + md)新增「压缩回收」一节:汇总行 + 最近事件表(时间/类型/推荐/实际折叠/回收率),从未折叠的 nudge 标「未折叠」。

归因规则(owner 2026-11-14 定)

  • 注入当轮或下一轮的 compress,以及其后连续 burst(相邻 fold ≤10min)→ 归 nudge;
  • 上一条没有注入且不在 burst 链 → 主动压缩;
  • 陈旧 nudge(>30min)不再归因,且其推荐量不标注更晚的 fold。

度量口径说明(审计第 3 点,已在图例/报告标注)

改动

  1. src/cache-ledger.ts
    • recordNudgeInject(session, nudge):仅在 4 个 prepare 协议的真实注入点(nudgeOutcome === "injected")调用,veto/skipped 分支不算。
    • fold 记录走既有 pushFold 唯一收口,追加 recovery 事件(含归因、推荐量、pct)。
    • CacheLedger.recovery? 随 metadata_json 落 sqlite,零迁移、零 schema 变更;pre-upgrade ledger 无此字段 → 报告显示旧行为(无该节)。
    • buildSessionCacheReport 输出 recovery: { events, summary }:per-nudge 配对 + 会话平均回收率。
  2. src/server/prepare-{openai,anthropic,google,responses}.ts:各 1 行 hook + import(最终 return 前;早期错误 return 均在注入点之前,不受影响)。
  3. src/web/client.ts:trajectorySvg 新增 recovery 条(token 轴同比例尺);makeChartZoom 的 state/visible/render 通道透传 recovery,zoom 窗口按时间过滤事件,summary 保持全会话值(窗口内不谎报)。
  4. src/web/report.ts + src/web/i18n.ts:svg/md 两版报告新节 + en/zh 词条。
  5. tests/issue6720-nudge-recovery.test.ts:6 用例 hermetic(同轮+burst 归因、无注入=主动、burst>10min 断链、>30min stale 不标注、never-folded arm 全额计入 pending、空 ledger 无 recovery 节、非 T1 层级 zero-pending 不产生 NaN)。

不做的事

Preflight

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
@ranxianglei ranxianglei changed the title feat: show nudge-recommended vs actually-folded tokens (recovery rate) in web chart + session report | Closes #6729 [PR] feat: show nudge-recommended vs actually-folded tokens (recovery rate) in web chart + session report | Closes #6729 Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-14_recovery-visibility (a4d9f2e)

Latest build — install this exact version

npm install -g billion-context@0.0.10327-pr.6745.368151d

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
a4d9f2e billion-context@0.0.10327-pr.6745.368151d build
aff1543 billion-context@0.0.10326-pr.6745.c250476 build
72f5c2e billion-context@0.0.10325-pr.6745.db6d599 build
47e59a9 billion-context@0.0.10320-pr.6745.8e1445d build
fe4b75b billion-context@0.0.10226-pr.6745.8614a52 build
9a30dee billion-context@0.0.10216-pr.6745.c618104 build
c5f573f billion-context@0.0.10212-pr.6745.0444eed build
6279145 billion-context@0.0.10197-pr.6745.1cc8c3e build
9929279 billion-context@0.0.10094-pr.6745.f0b04fe build
d643f0f billion-context@0.0.10092-pr.6745.569a254 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

独立代码审计(对照 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
@ranxianglei

Copy link
Copy Markdown
Owner Author

追加提交 c3a0333:按用户要求补了独立的回收率折线图(面板会话详情 + 下载的 svg/md 报告)。

  • 一个点 = 一次 nudge 回合(nudge 注入 → 下一次 nudge 前的全部折叠):同一回合里连续补刀的多条折叠合并成一个真实回收率点(demo 的 4×25% 折叠 → 一个 100% 点;报告者那种每次只压一半的棘轮 → 52%、43%、… 的下坠走势)
  • 虚线 = 累计平均;蓝点 = 主动压缩(无 nudge,只标记不进入回收率分子);点色 绿 ≥80% / 黄 40–80% / 红 <40%
  • 数据层:RecoveryReport 新增 episodes[](每回合 pending/folded/pct/activeFolds)+ activesBefore;非 T1 回合 pct 为 null(无 NaN)
  • 测试:新增 5 个回合聚合用例(合并 100% 回合、分回合比例+窗口内主动、activesBefore、非 T1 null、纯主动会话),11/11 通过;全量 12057 测试 11 个失败均为基线环境 flake(同 [PR] feat: show nudge-recommended vs actually-folded tokens (recovery rate) in web chart + session report | Closes #6729 #6745 首版验证清单),零新增失败;typecheck / build / 面板实测(demo 会话 50K→50K 单点 100%)均通过。

ci-check added 2 commits November 15, 2026 00:26
…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.
@ranxianglei ranxianglei added enhancement New feature or request p3 scope/ui labels Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复 —— open [PR] 列表里只有一条指向本线程(#6729 可见性),无并列第二 PR。

初审进行中,先报状态:

PR 原无标签,已按 diff 本身打标: enhancement + scope/ui + p3(web 面板可观测性功能,非用户缺陷)。

CI 跑完后给结构化八问结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI 已全绿(head c522dda,54/54:39 success + 15 skipped 门控 e2e,0 failure),以下为完整 review 结论。

结构化八问

  1. 是什么问题: Every compression only trims a little: the post-fold floor ratchets up and a 1M-window session ends at 212K without recovering | 每次压缩只降一点:压缩后的地板越压越高,1M 窗口会话涨到 212K 不回落 #6720 暴露的棘轮——每轮 nudge 推荐 ~50K 可压段,模型往往只折一小部分,压完的地板逐轮爬高;而「推荐了多少 vs 实际压了多少」此前没有任何地方可见,当时查了 30+ 行日志才定位。本 PR 是 Feature: show nudge-recommended vs actually-folded tokens per fold (recovery rate) in the web panel chart and session report | 功能:web 折线图与 session 报告显示每次压缩「推荐 vs 实际折叠」回收率 #6729 的可见性半边:把两个数画出来。
  2. 什么原因导致的: 不是 bug,是观测缺失。ledger 只记实际折叠(pushFold 收口),nudge 的推荐量(pendingT1)渲染进 prompt 后即丢弃,注入点不落账——两个数从未在任何地方共存,自然无法配对。
  3. 影响范围与严重程度: 纯增量展示功能,合入前对任何用户零影响;合入后 web 会话详情多一组回收条 + 一条平均回收率,session report(svg/md)多「压缩回收」一节。体验增强类,无缺陷面。
  4. 怎么修复的: 4 个 prepare 协议的真实注入点(nudgeOutcome === "injected" 才记账,gated/vetoed/skipped 均不算)落推荐量;pushFold 唯一收口落实际折叠量,按 owner 2026-11-14 裁定配对(注入当轮/下一轮 + ≤10min 连续 burst 归 nudge,>30min 陈旧不归因且其推荐量不标注更晚 fold,其余 = 主动压缩);report 侧做 per-nudge 配对(一次 fold 只答一个 arm,never-folded arm 全额计入 pending)+ 按回合 episodes(同轮多次部分折叠合成一个真实回收点,4×25% → 一个 100% 点)+ 会话平均回收率;图上 token 轴同比例尺(轮廓=推荐、填充=实际、绿≥80/黄40–80/红<40/蓝=主动、未折叠空心红虚线)。
  5. 是否有回归问题: 逐项审过既有行为——
    • pushFold 既有记账不变:非注入会话 recordFoldRecovery 直接早退,golden-storage-render 钉死 metadata_json 字节级不变(本地 45/45 PASS);
    • buildSessionCacheReport 纯增量字段,三个消费方(web detail / context-view / session-report)全部兼容,既有字段语义零改动;
    • 4× prepare 各 1 行 + import,不碰 wire body——plugin/proxy 两种压缩模式均不受影响(纯 ledger 副作用);
    • makeChartZoom state 增 recovery 通道,render 回调 3→4 参,两处调用点都更新(hit chart 忽略第 4 参);zoom 窗口按时间过滤事件、summary 保持全会话值(窗口内不谎报);
    • report 既有各节字节不变,新节以 rec 非空为门;i18n 28 个新键 en/zh 对齐(parity 测试过);
    • tests/text-safe.test.ts 1 行 = 新代码的数组 slice 进 family-gate 白名单,属本 PR 自身。
      一处有意行为变更(披露): 有 fold 的旧会话(升级前 ledger 无 recovery 字段)现在会在面板/报告里显示「压缩回收」节——内容是全主动压缩(0 nudge、无比率,buildSessionCacheReport 在 led.recovery 缺失时从 led.folds 合成 active 事件)。PR 正文「pre-upgrade ledger → 报告显示旧行为(无该节)」的措辞与代码不符(代码为准:仅空会话无该节)。无数据伪造(p=0、pct=null),不违反 Feature: show nudge-recommended vs actually-folded tokens per fold (recovery rate) in the web panel chart and session report | 功能:web 折线图与 session 报告显示每次压缩「推荐 vs 实际折叠」回收率 #6729「不回填历史会话」约束(不发明推荐量)。
  6. 是否破坏缓存: 否。不碰 prefix cache/cache key/重试/增量游标;新字段是 ledger blob 的可选字段,非注入会话持久化字节不变(golden 验证)。
  7. 是否改了设计方向: 否。纯可观测性增量;kernel/ 零改动、无新配置、无新 HTTP 端点;Every compression only trims a little: the post-fold floor ratchets up and a 1M-window session ends at 212K without recovering | 每次压缩只降一点:压缩后的地板越压越高,1M 窗口会话涨到 212K 不回落 #6720 的修复方向(re-arm/升级策略)明确留给后续 PR,本 PR 不越界。
  8. 是否引入了新的配置: 无。

代码与测试审查

  • 归因逻辑逐行核对(src/cache-ledger.ts recordFoldRecovery): lastN 取 at≤fold.at 的最近 nudge;gapArmed(nudge 晚于上一条 fold)或 chainArmed(距上条 fold ≤10min)且 nudgeFresh(≤30min)才归 nudge;陈旧 nudge 的 pending 不标注更晚 fold;非 T1 层级(pending=0)仍 arm 归因但 pct 保持 null(无 NaN);RECOVERY_CAP=500 封顶。与 Feature: show nudge-recommended vs actually-folded tokens per fold (recovery rate) in the web panel chart and session report | 功能:web 折线图与 session 报告显示每次压缩「推荐 vs 实际折叠」回收率 #6729 的 owner 裁定逐条对上。
  • backfill 设计: 首次真实注入时把此前所有 fold 回填为 active——刻意让「从未收到 nudge 的会话」持久化 metadata 字节不变(golden parity),设计合理。
  • 测试有效性: 11 个 hermetic 用例(确定性时钟桩),断言有牙——同轮+burst 归因、无注入=主动、10min 断链、30min stale、never-folded arm 全额 pending、非 T1 zero-pending 无 NaN、空 ledger 无 recovery、episodes 合并(4×25%→100% 点)、窗口内 active 只作标记不进分子、activesBefore。归因函数每个分支都被具体断言钉住,回归即翻红。本地定向复跑:recovery+report+i18n 30/30、cache-ledger+golden 45/45 全过。
  • diff 整洁度: 10 文件 +714/-10,每一行都与本 PR 目的相关;无空行/重排/锁文件/版本号改动。
  • 小瑕疵(不拦): ①PR 正文「6 用例」已过时(实际 11,正文写于 episodes 跟进 commit c3a0333 之前);②recEvents 携带一个只为最后剥掉的 i 索引字段(({ i: _i, ...ev })),略绕但无害;③RECOVERY_CAP 修剪无专门用例(琐碎)。

判定

方向正确(与 #6729 需求逐条对应)、归因实现与 owner 裁定一致、测试钉住全部分支、diff 干净、CI 54/54 绿。feat: 类按 §7.4 留人工合并。可合。

PR 原无标签,已按 diff 本身补: enhancement + scope/ui + p3。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

收到同步。说明两点:

  1. c3a0333(独立回收率折线图)已在我上一轮完整 review 的范围内——我审的 head c522dda 已包含该 commit:episodes 数据层、面板 recoveryLineSvg、svg/md 报告的回合折线、5 个回合聚合用例(11/11)都逐行核对过,结论(可合)已覆盖它,无需重审。
  2. 分支上又多了 0df852d(docs: 测量口径 caveat),这是新 head,已补审:

增量八问(仅针对 0df852d,3 文件 +13/-2)

  1. 是什么问题: 回收率有两个测量口径限制(owner 标记的非阻塞点)——非 T1 nudge 推荐量记 0 会抬高平均、burst 多次折叠可 >100%——此前面板/报告没说明,读者可能误读。
  2. 什么原因导致的: 首版只画了数,没把口径边界写进 UI 文案。
  3. 影响范围与严重程度: 纯文案增量,面板回收图卡片多一行 hint、md/svg 报告多两行 note(+窗口截断提示),无行为变化。
  4. 怎么修复的: 3 个新 i18n 键(det.rec_note_t1 / rec_note_burst / rec_note_window,en/zh 成对)分别落到面板图例、md 汇总、svg noteLine;{n} 占位符走既有 translate() 替换(已核对实现)。
  5. 是否有回归问题: 无——只增不改,既有节/键零改动;i18n parity 测试本地过;session-report 渲染测试本地 30/30 过。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 不涉及。
  8. 是否引入新配置: 无。

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 类,人工合并)。标签不变(enhancement + scope/ui + p3)。

ework-agent added 2 commits November 15, 2026 10:27
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%).
@ranxianglei

Copy link
Copy Markdown
Owner Author

回收视图重做(按 owner 反馈)

上一版两个问题(owner 在面板 session 01a1daef… 实测指出):

  1. 轨迹图上的恢复红柱与原有折叠虚线重合,无法分辨,且新增图标没有图例
  2. 回合折线图信息量太少,标题「回收 201.9%(nudge 2 · 主动 0)」是混合百分比,看不出 nudge 后压缩和主动压缩各多少次

重做(51411796d,client + 下载报告同构):

  • 轨迹图不再画任何恢复标记,只保留原有折叠线/天花板/地板
  • 一张自包含的时间轴图 recoveryRoundSvg:
    • 顶部橙色 ▼ = 每次 nudge 注入(tier + 推荐量)
    • 每根柱 = 一次 compress() 调用(高度 ∝ 折叠量,同秒连发自动错开),颜色 = 该次所属回合的回收率(绿 ≥80 / 黄 40–80 / 红 <40),蓝色 = 主动压缩——nudge 后 vs 主动一眼可辨
    • 每个回合一个点,标真实值(310% 的回合显示 "310%",不再静默钳在顶部)
    • 下方括号 = 回合明细:跨度、调用次数、Σ折叠/推荐、%
    • 标题行 = 诚实拆分:nudge 2 次 · 压缩 16 次(nudge 后 16 · 主动 0)· 推荐 125.1K / 折叠 252.6K · 折叠含老存量,不再有裸的混合百分比
  • 报告 svg/md 同步同一布局;md 摘要行改为诚实拆分开头,折叠 > 推荐时标注「含老存量」

验证:typecheck 0、web-i18n/issue6720/session-report 30/30、bundle vm-parse OK、面板渲染 + session-report svg/md 对线上 demo 会话实测(16 次调用、回合 100% / 310%)。

注:本分支远端已有 0df852db2(测量口径注记)与 master 合并提交,本次已合并进来(冲突在 md 摘要行,两边内容都保留)。

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.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

第 3 轮 review:回收视图重做(51411796d)+ 收尾合并(e75a2a00)+ 审核顺手清理(c2f0b5c4)

审核范围与验证

重做本身(51411796d,3 个 web 文件,数据层零改动):

  • 轨迹图恢复原样:recoveryMarkLines 整体删除,trajectorySvg 签名回到 5 参,只保留原有折叠线/天花板/地板——与 owner 实测反馈的两条(红柱与折叠虚线重合、无图例)逐条对上。
  • 新 recoveryRoundSvg 自包含时间轴图:橙色 ▼ nudge 旗标(tier+推荐量)→ 每根柱 = 一次 compress() 调用(高度 ∝ 折叠量,同秒 burst 用 xShift 错开,颜色 = 所属回合回收率,蓝 = 主动)→ 每回合一个点,标真值(pct.toFixed(pct >= 100 ? 0 : 1),310% 就显示 "310%",y 轴钳 0–100 但标签不撒谎)→ 回合括号(跨度/调用次数/Σ折叠/推荐/%,双行交错防重叠)→ 诚实标题行 det.rec_head2(nudge N 次 · 压缩 M 次(nudge 后 X · 主动 Y)· 推荐 Σ / 折叠 Σ)+ 折叠 > 推荐时追加「折叠含老存量」。混合百分比彻底消失,nudge 后 vs 主动一眼可辨。
  • 报告 svg/md 同构镜像同一布局;md 摘要行 = 诚实拆分开头 + 平均回收率殿后。
  • 面板卡片门控从 episodes.length || activesBefore || activeFolds 简化为 events.length——等价(events 非空 ⟺ 旧三条件之一成立)。
  • i18n:删 6 个旧键(rec_head/rec_fold_n_tip/rec_fold_a_tip/rec_line_tip/rec_line_cum/rec_line_act),新增 10 键(rec_bar_n_tip/rec_bar_a_tip/rec_point_tip/rec_bracket/rec_head2/rec_over_stock/rec_leg_nudge/rec_leg_active/rec_leg_cum/rec_leg_pt)+ 改 rec_line_title/rec_line_sub。en/zh 成对,web-i18n 平价测试过;已删键在 src/ 全树零残留引用(grep 验证)。

收尾合并(e75a2a00)冲突解决:md 摘要行两边都保留——report.ts:252 新 head2 拆分行 + :253–254 测量口径注记(rec_note_t1/rec_note_burst);svg 侧 :441 + :448–449 同样齐全。与注释描述一致 ✓。

本地验证(最终头 e75a2a00 + 我的清理提交):typecheck 0;issue6720-nudge-recovery + session-report + web-i18n + text-safe + cache-ledger = 88/88 PASS。

审核顺手修掉的小问题(已推 c2f0b5c4)

  1. 死代码:zoom 的 recovery 通道——重做后 makeChartZoom 的 visible() 仍在过滤/透传 z.state.recovery、bindTrajectoryBrush 仍在绑定它,但 render 回调已不消费(重做把轨迹图上的恢复标记删了)。整条通道(state 字段 + zoom 过滤 + bind 参数 + render 第 4 参)删除。
  2. client.ts:2201 丢行——if (!lines.length) return ""; const W = TRAJ_W, ... 挤成一行(语法合法但脏),恢复换行。
  3. 悬空注释——recoveryRoundSvg 上方还留着 6 行描述已删除的 recoveryMarkLines 空心轮廓行为的旧注释(注释与代码事实不符 = 缺陷),删除。

清理后复验:typecheck 0,88/88 PASS。

留一个不修的注记:activesBefore 在 src/cache-ledger.ts(2218/2457/2479/2486)仍在计算、src/web/report.ts:56 仍有类型,但不再被渲染(新图用蓝色柱按时间位置展示主动压缩,严格更好)。它是数据层字段、有测试覆盖、属报告 JSON 形状,移除属数据面变更、超出本次 web 重做范围——保留为数据字段,不作为缺陷。

PR 描述时效性注记:PR body「改动」第 3、4 条描述的是第一版视图(轨迹图空心轮廓 + 回合折线),重做后已过时;当前行为以 51411796d commit message 和本线程此条为准。按规则我不改 PR body,合并前 owner 可酌情更新。

八问(delta:重做 + 合并 + 清理)

  1. 是什么问题:第一版把恢复红柱画在轨迹图上与既有折叠虚线重合无法分辨、无图例;回合折线图标题是混合百分比,看不出 nudge 后压缩与主动压缩各多少次(owner 面板实测反馈)。
  2. 什么原因导致的:第一版的设计选择——在已经很忙的轨迹图上叠恢复标记、把逐回合百分比聚合成一个混合数字;不是代码 bug。
  3. 影响范围与严重程度:仅 web 面板会话详情 + 可下载报告,纯展示层;数据层/线协议/持久化本次 delta 零改动。
  4. 怎么修复的:轨迹图还原;一张自包含时间轴图分层呈现(旗标/柱/点/括号/诚实标题),报告同构;>100% 回合标真值不静默钳顶。
  5. 是否有回归问题:审过的既有行为——轨迹图原渲染(折叠线/天花板/地板/zoom/brush)与 Feature: show nudge-recommended vs actually-folded tokens per fold (recovery rate) in the web panel chart and session report | 功能:web 折线图与 session 报告显示每次压缩「推荐 vs 实际折叠」回收率 #6729 之前字节级一致(recovery 参数从签名移除,zoom 行为回到原样);i18n 目录平价干净;报告 md/svg 为超集(旧 statRow 的「平均回收率」统计项移入标题行,有意变更、已披露);数据层未动。无回归。
  6. 是否破坏缓存:不涉及(纯展示层,无缓存/重试/游标/去重)。
  7. 是否改了设计方向:不涉及——仍是 Feature: show nudge-recommended vs actually-folded tokens per fold (recovery rate) in the web panel chart and session report | 功能:web 折线图与 session 报告显示每次压缩「推荐 vs 实际折叠」回收率 #6729 同一功能,只换可视化形态。
  8. 是否引入了新的配置:不涉及。

判定

可合(feat 类 → 按 §7.4 人工合并)。CI:新头 c2f0b5c4 的运行已触发、结果待出(上一头 e75a2a00 的 run 在推送时仍在排队/进行中,会被新头取代);本地定向 88/88 + typecheck 0 已过。标签维持 enhancement / scope/ui / p3(重做未改变 PR 的性质与严重度)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

CI 更新:新头 c2f0b5c4(重做 + 合并 + 审核清理)30/30 完成——15 success + 15 skipped(门控 e2e),0 失败。判定维持可合,等 owner 合并。

…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%.
@ranxianglei

Copy link
Copy Markdown
Owner Author

新提交 d643f0f8d:回收率图改成 以 100% 为中间基准的折线图(针对「311% 看不懂 / 看不出多压缩少压缩」的反馈):

  • 100% 基准线画出来并标注(= 恰好折完推荐量)。点在线下 = 少压缩(Every compression only trims a little: the post-fold floor ratchets up and a 1M-window session ends at 212K without recovering | 每次压缩只降一点:压缩后的地板越压越高,1M 窗口会话涨到 212K 不回落 #6720 棘轮),点在线上 = 多压缩(顺手清了老存量)——两个方向都直接可见,不再钳在图顶
  • y 轴随数据伸展(25/50 步长,上限 400%):311% 的回合就画在 311% 处,蓝色光晕 + 真值标签;悬停注明「多压缩(含老存量)/ 少压缩」
  • 实线连接各回合点(主线),紫色虚线仍是累计平均
  • 老存量记账:每轮 nudge 把推荐量计入池子,折叠按池子消耗,超出部分在回合括号里标「+N 老存量」——真值保留,但「折得比推荐多」不再被误读成回收率虚高
  • 顺带落盘了之前只在磁盘上的 tests/web-recovery-card.test.ts(8 个用例,含老存量池、窗口重算、基线/光晕/坐标轴断言)
  • 下载的 SVG 报告里同一张图同步(动态轴 + 基准线 + 主线 + 光晕 + 老存量括号)

验证: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.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

第 4 轮 review:100% 基准折线图重做(d643f0f8)+ 审核顺手修两处缺陷(99292792)

审核范围与验证

重做本身(d643f0f8,4 文件 +330/-43,数据层零改动),与 owner 反馈(「311% 看不懂 / 看不出多压缩少压缩」)逐条对上:

  • 100% 基准线画出并标注(det.rec_line_base):线下 = 少压缩(Every compression only trims a little: the post-fold floor ratchets up and a 1M-window session ends at 212K without recovering | 每次压缩只降一点:压缩后的地板越压越高,1M 窗口会话涨到 212K 不回落 #6720 棘轮),线上 = 多压缩,两个方向都直接可见,不再钳在图顶。
  • 动态轴:axisMax = maxPct <= 100 ? 150 : min(400, ceil(maxPct*1.1/50)*50),步长 25/50——311% 的回合就画在 311% 处(轴到 350%),蓝色光晕 + 真值标签;>100% 点悬停注明「多压缩(含老存量)/ 少压缩」。
  • 实线主线连接各回合点,紫色虚线累计平均保留。
  • 老存量池:每轮 nudge 把 pending 计入池子,nudge 模式折叠按池消耗(floor 0),超出 = 模型自己清的老存量,回合括号标「+N 老存量」——真值 pct 保留,「折得比推荐多」不再被误读成回收率虚高。
  • zoom 通道复活且真被消费:recZoom 加入 detailChartLink 三成员联动;visible() 按窗口过滤 recovery 事件,render 回调对窗口重推逐回合聚合(窗口起点在中途的折叠归入合成 open round,pending 0 → pct null → 灰色「?」,不造假百分比);会话级 summary 原样透传,标题行不谎报窗口。上一轮我删的那条死通道(c2f0b5c4)这次有真实消费者,删对了又加回来是对的。
  • 诚实标题移出 SVG 进 card-b 的 HTML div(与第一个 nudge 旗标标签的碰撞,11-15 10:45 反馈),PT 46→30 让位。
  • 报告 SVG 同构镜像(动态轴/基准线/主线/光晕/老存量括号);md 摘要行不变。
  • 测试是真测试:tests/web-recovery-card.test.ts 8 用例从真实 WEB_CLIENT 模板提取函数执行,断言有牙(池账 100/10/150/160 逐值、轴 350%、光晕、基准线、open round 编号「round 0, call 1/2」、brush 接线、空窗口契约)。

本地验证(最终头 + 我的清理提交):tsc 0;web-recovery-card + session-report + web-i18n + issue6720-nudge-recovery + text-safe = 57/57 PASS。

审核发现并顺手修掉的两处缺陷(已推 99292792)

  1. 回合点 tooltip 的 tier 恒为「?」——recoveryEpisodesFromEvents 里 tier: nv.tier != null ? null : nv.tier 三元写反,两个分支都出 null:旗标(直接用 nv.tier)显示真 tier,点 tip 却显示「?」,同图自相矛盾,且相对第 3 轮(服务端 episodes 带真 tier)是回归。修为 nv.tier ?? null,web-recovery-card 补 tier 断言钉住。
  2. 报告 SVG 的「+N 老存量」括号是死代码——report.ts 读 ep.credited 渲染括号后缀,但 cache-ledger.ts 的 episodes 从不带 credited/extra(本 PR 数据层零改动),后缀永远不渲染:面板有老存量拆分、报告没有,与 commit message「报告镜像老存量括号」不符。改为渲染期用与面板相同的池逻辑从 pending/folded 推导,删掉 ReportData 接口里这两个死字段;session-report.test.ts 新增用例,用服务端真实形状的 payload(无 credited/extra)钉住括号输出(+10/+210 老存量、基准线、350% 轴、光晕)。

两个已知边界(非缺陷,记录在案):① 面板客户端重推 vs 报告服务端 episodes 在「折叠与下一 nudge 同毫秒」的理论边界上归属可能不同(实际 nudge 在请求 N、折叠在请求 N+1,跨网络往返,同毫秒不可达);② zoom 窗口内紫色累计平均线是窗口内累计(非全会话),标题行 summary 仍为全会话值——窗口语义,有意为之。

PR 描述时效性:body「改动」一节描述的是更早版本视图,当前行为以 d643f0f8 + 本条为准(按规则我不改 PR body,合并前 owner 可酌情更新)。

八问(delta:基准折线重做 + 审核清理)

  1. 是什么问题:上一版把 >100% 回合钳在图顶、无参照系——「311%」看不出是多压缩还是少压缩,回收率高低失去方向感(owner 反馈)。
  2. 什么原因导致的:第一版 y 轴固定 0–100 + 钳顶的设计选择,>100% 没有表达空间;不是数据 bug。
  3. 影响范围与严重程度:仅 web 面板会话详情 + 可下载报告,纯展示层;数据层/线协议/持久化零改动。
  4. 怎么修复的:100% 作中间基准线 + 轴随数据伸展(上限 400%)+ 实线主线 + 光晕真值标签 + 老存量池把「多折的部分」从回收率里分账出来。
  5. 是否有回归问题:审过的既有行为——轨迹图/命中率图渲染与 zoom 行为未动(recovery 只是加入联动的第三成员,前两成员 render 回调不变);i18n 平价干净(4 新键 en/zh 成对);md 报告不变;数据层未动。发现并修掉 2 处新缺陷(tier 三元写反、报告括号死代码),均补测试钉住。无遗留回归。
  6. 是否破坏缓存:不涉及(纯展示层)。
  7. 是否改了设计方向:不涉及——仍是 Feature: show nudge-recommended vs actually-folded tokens per fold (recovery rate) in the web panel chart and session report | 功能:web 折线图与 session 报告显示每次压缩「推荐 vs 实际折叠」回收率 #6729 同一功能,可视化形态再次按反馈调整。
  8. 是否引入了新的配置:不涉及。

判定

可合(feat 类 → 按 §7.4 人工合并)。CI:新头 99292792 的运行已触发、结果待出;本地 tsc 0 + 定向 57/57 已过。标签维持 enhancement / scope/ui / p3。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

CI 更新:新头 99292792 全绿——54/54 完成(39 success + 15 skipped 门控 e2e,0 失败)。镜像缓存当时停在 13:41 的中间态(10 项 in_progress),此结果取自对精确 head 的单次 check-runs 拉取,非轮询。

第 4 轮判定维持可合,等 owner 合并。

# Conflicts:
#	src/server/prepare-anthropic.ts
#	src/server/prepare-google.ts
#	src/server/prepare-openai.ts
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

冲突已解决,master 已合入 PR 分支并推送(99292792 → 627914511a,普通 push,无 force-push)。

七问

  1. 是什么问题:PR 分支落后 master 87 个提交,merge state 变 dirty(冲突)。冲突源是 master 侧 PR [PR] fix: un-show a nudge whose request the upstream rejected #6531(上游拒绝后 nudge 重新武装,nudgeStampsBefore 快照/恢复机制)与本 PR 改了同样 5 个文件。

  2. 什么原因导致的:两边都在 4 个 prepare 协议的同一段收尾区动刀——本 PR 在最终 return 前插一行 recordNudgeInject 钩子,[PR] fix: un-show a nudge whose request the upstream rejected #6531 改写了 return 行本身(加 nudgeStampsBefore 字段)——相邻行修改撞车,3 个文件出冲突标记(anthropic/google/openai);cache-ledger.ts 与 prepare-responses.ts 自动合并成功。

  3. 影响范围与严重程度:仅本 PR 分支与 master 的合并关系,不影响任何已发布行为;不解决则 PR 无法合并,阻塞 Feature: show nudge-recommended vs actually-folded tokens per fold (recovery rate) in the web panel chart and session report | 功能:web 折线图与 session 报告显示每次压缩「推荐 vs 实际折叠」回收率 #6729 可见性功能合入。

  4. 怎么处理的:merge(非 rebase,避免 force-push,且分支历史本就是 merge 风格)。3 处冲突全部按「两边意图取并集」解:保留本 PR 的 if (nudgeOutcome === "injected") recordNudgeInject(session, nudge); 钩子行 + 采用 master 带 nudgeStampsBefore: nudgeOutcome === "injected" ? nudgeStampsBefore : undefined 的 return 行。两个自动合并文件逐一核验两边改动都在:prepare-responses.ts(钩子 :759 + nudgeStampsBefore :116/:379/:383/:778)、cache-ledger.ts([PR] fix: un-show a nudge whose request the upstream rejected #6531 的 nudgeHeldAfterReject 清理 :1943 + 本 PR 全部 recovery 账本代码);4 个 prepare 文件均确认 nudgeStampsOf/restoreNudgeStamps×3、recordNudgeInject×2、!nudgeHeldAfterReject 门控×1 齐全。

  5. 是否有回归问题:无。冲突解法不改变任何一侧的语义——[PR] fix: un-show a nudge whose request the upstream rejected #6531 的拒绝回滚机制原样保留,本 PR 的注入记账钩子原样保留(仍只在 nudgeOutcome === "injected" 触发)。本地验证:typecheck 0 错误、build 通过(tsup + dist-import-annotations + dist-external OK)、定向测试 101/101 PASS(rejected-nudge-rearm + issue6720-nudge-recovery + session-report + web-recovery-card + web-i18n + text-safe + cache-ledger,覆盖两边触碰面)。全量回归交远程 CI。

  6. 是否破坏缓存:不涉及——纯合并冲突解决,零逻辑改动,不碰 prefix cache/重试/游标/去重。

  7. 判定:merge state 结构性恢复干净——已验证 origin/master(2e3cfc973b)是分支新头 627914511a 的祖先,冲突不复存在。新头 CI 运行已触发(单次拉取确认:36 项 check,11 success + 11 skipped 门控 e2e + 1 in_progress + 13 queued,0 失败)。注:镜像 check 缓存本次停在旧头(fetched_at 06:15Z / sha 9929279),新头结果出来前以上述单次拉取为准,CI 全绿后本线程再报。

#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)
@ranxianglei

Copy link
Copy Markdown
Owner Author

v6:按用户要求把柱子换成真正的折线图(commit c5f573f7e)

回收率图现在是一条线,不是柱状图:

  • 柱全部移除:每次 compress 调用变成时间轴底部一根 2px 细刻度(蓝 = 主动压缩,其余按所属回合回收率着色),悬停提示不变;SVG 里已无 <rect>
  • 主角是线:100% 基准线(粗,标注「基准 100%=恰好折完推荐量」)+ 实线折线连接各回合真实回收率点 + 紫色累计平均虚线;>100% 的回合在基准线上方(蓝圈标记,真值标签),棘轮会话在下方
  • 下载的 svg/md 报告镜像同一渲染
  • 顺带:服务端 episodes 补了 credited/extra(推荐池结算),报告里的「老存量」数字与服务端一致,不再全量误标

Preflight(rebase 到分支最新 6279145 之后):typecheck 对本提交 0 错误(tests/dsh-tool-registration-lifetime.test.ts 有 2 个 TS7006 为 master 合并带入的既有问题,本提交未触碰该文件);WEB_CLIENT vm parse OK;定向 129/129 + golden 重建 kernel 后 5/5;npm run build OK。

面板已重启(: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 ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 前的主动折叠不进任何回合;纯折叠会话无回合)。

结构化八问

  1. 是什么问题:#6729 要把「nudge 推荐折叠量 vs 模型实际折叠量(回收率)」可视化到 web 图表 + 会话报告;v6 按用户要求把柱状图改成真折线图。
  2. 什么原因导致的:nudge 推荐折叠一定量 token,但模型实际折叠量会偏离推荐量(棘轮会话折得少、激进会话折得多);用户需要看到偏差(回收率)来评估 nudge 有效性。
  3. 影响范围与严重程度:纯新增可视化,影响所有有 nudge 注入的会话的 web 面板 + 报告下载;无 nudge 注入的会话不受影响(recovery 段缺失、metadata 字节对齐)。体验增强,非缺陷修复。
  4. 怎么修复的:数据层在 4 个 prepare-* 钩子的 nudgeOutcome === "injected" 点记录 nudge 事件、在折叠单点(pushFold→recordFoldRecovery)把每次折叠配对到触发它的 nudge(10min 突发窗 + 30min 新鲜度门);报告层聚合回合级回收率;视图层用自包含时间轴折线图渲染(100% 基准线 + 实线回合点 + 紫色累计平均虚线 + 2px 调用刻度)。
  5. 是否有回归问题:无。recovery 段是纯新增字段(无 nudge 注入的会话该段缺失、字节对齐);4 个钩子只在 injected 时记录(早退错误路径在钩子之前);视图层是新增图表、不触碰既有轨迹图。顺手修是纯死代码删除、无行为变更。高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。
  6. 是否破坏缓存:不涉及。recovery 数据来自内部 cache ledger(非用户输入),不触碰缓存失效/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及。纯新增可视化,不改变压缩引擎/上下文管理/会话核心的架构、边界、数据流。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

已审完 v6(head c5f573f7ed)。折线图改造正确:柱→2px 细刻度(SVG 无 <rect>)、100% 基准线 + 实线回合点 + 紫色累计平均虚线、>100% 回合蓝圈 + 真值标签;报告镜像同一渲染;服务端 episodes 补 credited/extra 后「老存量」数字与服务端一致。

已顺手修:移除死字段 activesBefore(round-3 视图重构后无 UI 消费者——面板客户端侧重算回合、报告读 rec.episodes/rec.events,该字段只被计算从不被读)+ commit 9a30dee80b。定向 5 测试文件 86/86 + typecheck 0 错误。

完整 review + 八问见 comment review:#pullrequestreview-5911529457。结论:可合入(APPROVE 等效)——作者=审核账号,GitHub 不允许 approve 自己的 PR,故以 comment review 给出等效结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 已审完 PR #6745(v6 head c5f573f7ed + 顺手修 9a30dee80b)。

结论:可合入(APPROVE 等效)——作者=审核账号,GitHub 不允许 approve 自己的 PR,故以 comment review 给出等效结论(review id 5911529457)。

做了什么:

  • 端到端审完 v6 折线图改造(柱→2px 刻度、100% 基准线 + 实线回合点 + 紫色累计平均虚线、>100% 蓝圈标记)+ 数据层 nudge/折叠配对逻辑(4 个 prepare-* 钩子 injected 点记录 + pushFold 单点配对,10min 突发窗 + 30min 新鲜度门)+ 报告镜像渲染。
  • 已顺手修:移除死字段 activesBefore(round-3 视图重构后无 UI 消费者——面板客户端侧重算回合、报告读 rec.episodes/rec.events,该字段只被计算从不被读)+ commit 9a30dee80b,已推送到 PR 分支。

验证:定向 5 测试文件 86/86 通过;typecheck 0 错误;CI 30/30 全绿(0 failed)。

八问:见 comment review(#pullrequestreview-5911529457)。

协调 issue:任务要求「在协调 issue 报一行」,但 dispatch 未给协调 issue 编号、上下文里也查不到(搜索结果里该词被脱敏、无编号)——标记此缺口,不瞎猜。

ework-agent added 2 commits November 16, 2026 00:05
)

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
@ranxianglei

Copy link
Copy Markdown
Owner Author

新增「增长回收线」(47e59a9)——回答 #6720 的台阶问题:每轮压缩到底有没有把新长出来的上下文压回去。

压缩回收图里多了一条蓝色粗线,每个 nudge 回合一个点,纵轴 = 本轮压缩量 ÷ 本轮上下文净增长(上一轮压完后的地板 → 本轮峰值):

两个关键语义:

  1. 地板取「上一轮最后一次压缩之后、本轮 nudge 之前」的最低输入——不能取轮内最小值,因为压缩本身就是一次下跌,轮内最小值会卡在上一轮压完之后,把增长虚增 ~10 倍(真实数据上量出过 16119% 的假点)。
  2. 同一个 session UUID 可能混着两条对话(dsh-client 报过),低于窗口峰值 25% 的用量样本视为另一条流,从地板/峰值里剔除。

本地真模型 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 ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(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。

八问:

  1. 是什么问题:#6720 报告的「上下文台阶上涨、压不回去」缺一个直接读数——每轮压缩到底有没有把新长出来的部分压回去。
  2. 什么原因导致的:原回收图只画「折叠÷推荐量」(有没有照单折完),没有「折叠÷净增长」(上下文有没有真的降下来)这条线;台阶问题需要后者。
  3. 影响范围与严重程度:纯新增可视化(web 面板 + 下载报告),不影响压缩行为/数据/缓存;无增长采样时增长线静默关闭并给图例提示,其余照常渲染。体验增强,无破坏面。
  4. 怎么修复的:在 web 层(client.ts 面板 + report.ts 报告)从请求用量采样推导每轮地板→峰值的净增长,画一条蓝色粗线(每轮一点);地板严格取上轮末次折叠之后、本轮 nudge 之前的最低输入,避免折叠自身下跌造成的虚增;同 UUID 双流用 25% 峰值阈值剔除。
  5. 是否有回归问题:审过既有行为——回收图原有元素(100% 基线、累计平均虚线、回合括号、nudge 标记、主动刻度)全部保留且测试钉住;activesBefore 死字段已在上轮移除;本次仅新增增长线 + 每压缩点,未改既有语义。无回归。
  6. 是否破坏缓存:不涉及——纯读侧可视化,不触碰缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及——在既有回收图内加一条线,不改架构/边界/数据流。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。

判定:可合入,等人工合并(feat: 类,§7.4 人工合并)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 已审完新增两笔提交(fe4b75b3a8 每次压缩都上折线 + 47e59a9deb 增长回收线)+ 我顺手修的一笔(72f5c2e388)。

结论:可合入(APPROVE 等效)——作者=审核账号,GitHub 不允许 approve 自己的 PR,故以 comment review 给出等效结论(review id 5916124729)。

做了什么:

验证:定向 31/31 测试通过;typecheck 0 错误;CI 30/30 全绿。

八问:见 comment review(#pullrequestreview-5916124729)。

等人工合并(feat: 类,§7.4)。

ework-agent added 2 commits November 16, 2026 15:07
…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.
@ranxianglei
ranxianglei merged commit 0821a81 into master Nov 16, 2026
54 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1218-master.0821a81 (rolling master tag).

npm install -g billion-context@0.0.1218-master.0821a81  # 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

Projects

None yet

1 participant