Skip to content

[PR] feat: surface unbounded dump retention at boot and in bili doctor (#3851) - #3869

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-10-20_dump-unbounded-warning
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-10-20_dump-unbounded-warning

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

What & why

#3851: with diagnostics.dumpBody/dump4xx (or SSE capture) enabled and neither diagnostics.maxTotalBytes nor maxAgeDays set, the dump directories grow unbounded with zero visibility — one user's system disk went from ~55 GB free to 2.9 GB after 10 days of ordinary DSH use (51.9 GB / 126,712 files). The cap knobs exist (#2412/#2575) but are opt-in, and nothing tells the user their capture is unbounded or how big it has already gotten. This PR adds the missing signposts (issue options 1+2). No new config keys; no behavior change to any existing path.

Changes

  • One-shot startup WARN (src/server.ts): when any capture channel is on and both bounds are unset, the server logs a warn at boot naming each active dump dir and its current size, plus how to bound or turn off capture. Size measurement runs async in the background so a huge dir (the reporter had 126k files) never delays ready.
  • bili doctor dump section (src/doctor.ts): new "dump dirs" section showing retention state (UNBOUNDED marker / configured caps / off) and every dump dir's current size + file count — including leftover data from capture that was since disabled. Additive dumps field in --json.
  • Shared read-only audit helpers (src/state-gc.ts): dumpRetentionState(), activeDumpDirs(), measureDumpDir(), fmtBytes(), formatUnboundedDumpWarning() — same knob resolution as the GC itself, so what is reported is exactly what runs.
  • New sseDumpDir() accessor in src/knobs.ts (ACP_DUMP_SSE > top-level dumpSse).
  • Docs: CONFIGURATION.md en/zh diagnostics section notes the new visibility.
  • Tests: new tests/dump-retention-warning.test.ts (row-driven gate matrix with positive+negative rows per Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617 discipline, measurement, wording, doctor render variants); tests/doctor.test.ts fixture gains the report field.

config surface

None — no keys added/renamed/re-semantics'd. Reuses the existing diagnostics.maxTotalBytes / maxAgeDays (#2412) and the pre-existing capture toggles.

Behavior changes (disclosure)

Additive only:

kernel-change: n/a (no kernel/ changes)

Pre-flight (rebased head): typecheck clean; build OK; targeted suites green locally (dump-retention-warning / doctor / state-gc / knobs-config-precedence = 62/62). Full-suite verdict comes from CI.

Closes #3851

CI note (pre-existing master gate reds, owned by #3871)

The unused-exports and docs-sync gates fail on pristine master @ 39fb841 itself (orphaned maskUrlForPublish export since a4f2730/#3811; stale duplicate rows left inside the generated param-ref block by a bad merge resolution) — verified locally by running both checks on an unmodified checkout. This PR originally carried an identical one-line export fix as a labeled commit; outbound dedup found #3871 (Closes #3870, the master gate red-storm tracker) already fixing BOTH gates, so this branch now contains only the #3851 feature commit and lets #3871 own the fixes (one red master, one owner). All other lanes pass on this head; once #3871 merges, a rebase turns the remaining two gates green.

@ranxianglei ranxianglei changed the title feat: surface unbounded dump retention at boot and in bili doctor (#3851) [PR] feat: surface unbounded dump retention at boot and in bili doctor (#3851) Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-20_dump-unbounded-warning (b2b334f)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4579-pr.3869.6d912de

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

Option B — Download artifact

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

Install instructions are refreshed on each push.

)

Capture enabled without maxTotalBytes/maxAgeDays grew silently (51.9 GB in
10 days for one user). Add the signposts: one-shot boot WARN naming each dump
dir + current size (async, never delays ready), and a 'dump dirs' section in
bili doctor with retention state (UNBOUNDED marker / caps / off) and per-dir
sizes incl. leftover data. Read-only audit helpers in state-gc.ts share the
GC's knob resolution. No new config keys; no write/GC path touched.
@ranxianglei
ranxianglei force-pushed the 2026-10-20_dump-unbounded-warning branch from 9ee999f to b2b334f Compare October 19, 2026 18:31
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。 本 PR 是 #3851(dump capture 无保留上限时零可见性)的实现项,无其他在途条目做同一件事。审查中发现本分支 CI 有两个红门(unused-exports / docs-sync),已查重:两者均为 master 既有红(2026-10-19 起),已由 #3870 跟踪、#3871 修复在途(恰好就是这两处),按红风暴防线不在此分支重复修。

标签: dsh, scope/storage, p2(事故客户端为 DSH;改动面是磁盘 dump 目录的诊断可见性;属增强而非缺陷,不打 bug;能用且有绕行=设上限,故 p2)。

独立核验结论(非转述 PR 描述):代码通过,可合入;当前唯一阻塞是 master 既有红门,与本 PR 无关。

验证过程:

  • 在 master @ 39fb841(= 本 PR base) 本地复跑 scripts/check-unused-exports.mjs 与 node tools/gen-config-docs.mjs generate + diff:两个 job 的错误逐一复现(INTERNAL_ONLY src/log-mask.ts: maskUrlForPublish;CONFIGURATION.md/zh-CN 生成表里两行陈旧 storage 条目)→ 红门是 master 存量问题,不是本 PR 引入;
  • PR head 本地:typecheck clean、build OK、定向套件 62/62(dump-retention-warning / doctor / state-gc / knobs-config-precedence);CI 上全部 e2e lane(opencode/dsh/pi/codex-fake/local-registry/image/Windows overlay 等)全绿;
  • 代码审查:state-gc 新增 helper 为只读审计、与 GC 共用同一 knob 解析(报告的就是实际运行的);启动测量异步不拖 ready;doctor 恒测三个默认目录 → 已关闭 capture 的残留数据仍可见;flat-file 计量与 writer(error-dump.ts 平铺 err-*.json)及 GC 模型一致;sseDumpDir() 与既有 ACP_DUMP_SSE>dumpSse 解析(src/config.ts:1433)对齐,"无新配置键"属实;
  • 测试是真测试:Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617 纪律的行驱动正负行、精确措辞断言、fmtBytes 边界、缺目录不抛错、doctor 三种渲染变体;
  • diff 干净:8 个文件全部与本 PR 目的相关,无跑题改动。

八问:

  1. 是什么问题:开了 dumpBody/dump4xx/SSE capture 又没设任何保留上限时,dump 目录无限增长且零可见性——[Enhancement] No warning when dump capture is enabled without a retention limit: 51.9 GB silently written over 10 days ( | [Enhancement] 开启 dump 捕获但未设保留上限时无任何提示:10 天静默写入 51.9 GB(#2412 后续) #3851 报告者 10 天普通 DSH 用量吃掉 51.9 GB / 126,712 个文件,系统盘从 55GB free 掉到 2.9GB。本 PR 补路标:启动一次性 WARN + bili doctor dump 段。
  2. 什么原因导致的:cap 旋钮(Diagnostic dumps have no rotation or size cap — 70 GB written in 26 hours #2412)按设计 opt-in、默认关,但开了 capture 后没有任何东西告诉用户「你是无界的」以及「已经涨到多大」——可见性缺口,不是机制 bug。
  3. 影响范围与严重程度:开了任一 capture 通道且未设 maxTotalBytes/maxAgeDays 的用户——静默吃盘直到故障;p2(可用、有绕行=设上限;本 PR 本身只加可见性,不改任何默认值)。
  4. 怎么修复的:共享只读审计 helper(与 GC 同一 knob 解析)+ 启动异步测量 + doctor 常驻 dump 段;不新增配置键,不动任何写/GC 路径。
  5. 是否有回归问题:无。逐项审过既有行为:boot log(特定条件下多一条 warn,已披露)、doctor 输出/--json(additive 段/字段,已披露)、GC 写删路径(未触碰)、knob 优先级(新 accessor 与既有 env>file 一致)、测量失败优雅降级(size 省略、注释写明意图)——无语义漂移、无 fail-fast 变吞错。
  6. 是否破坏缓存:不涉及(未触碰缓存/重试/游标/去重路径)。
  7. 是否改了设计方向:无——纯增量可观测性,Diagnostic dumps have no rotation or size cap — 70 GB written in 26 hours #2412 的 default-off 保留语义原样保持。
  8. 是否引入新配置:无(复用 diagnostics.maxTotalBytes/maxAgeDays 与既有 capture 开关)。

CI 状态与合并判定:

@ranxianglei

Copy link
Copy Markdown
Owner Author

Stale: 39 cancelled runs / 4 failing checks against current master, and the boot/doctor surface it touches has moved under #3911's runtime-status changes. The underlying p1 (#3851 — unbounded dump capture with no retention warning) stays open; the fix is small to redo cleanly on current master (cap + warn-once at boot + doctor line). Closing this branch rather than force-rebasing a bot-queued implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment