Repository navigation
feat: web warning + generic diagnostics reporting when SQLite degrades to legacy-only (#3040) - #3041
Conversation
…s to legacy-only (#3040) Before the upcoming full-mode default flip, environments where the engine ladder lands on 'none' (or the corrupt-index.db guard trips) silently ran on legacy JSON and were never learned about. This makes the condition persistent and user-actionable in the web UI, per owner direction as a GENERIC reporting facility ('copy error to GitHub' for all future errors): - storage runtime status registry (src/storage/runtime-status.ts): records the requested mode (SessionStore ctor), sidecar open failure/instance (UnifiedShadow.maybeOpen), and the ensureSqliteEngine outcome (cli.ts); derives requested vs effective + degraded + intentionalOptOut (BILI_ENCRYPTION_KEY excluded by design) + human-readable reason. - one shared storageStatusWire() feeds BOTH /__bili/status and /__bili/overview (#2152 parity discipline). - generic GET /__bili/diagnostics?topic= (loopback-only): copyable blob (bili version/commit, node, platform/arch, OS, uptime, session count + topic section) and a prefilled github.com/ranxianglei/billion-context/issues/new URL whose body decodes back to the exact blob; unknown topics fall back to the base blob. First topic: storage-legacy-only (knob stack verbatim, ladder outcome, bootstrap failure payload w/ cooldown, [storage] log tail). - web banner (zh/en i18n, existing banner styles) shown iff requested != effective and not an intentional opt-out, with copy-diagnostics + report-on-GitHub buttons wired to the generic endpoint. - knobs.ts exports the file-tier readers (fileStorageUnified/fileStorageJsonWriter/fileStorageAutoDownload) so diagnostics reports raw values; persist.ts drops its private duplicates. - tests/web-storage-banner.test.ts: forced none-engine (banner wire contract + blob + encoded link + page/client markers), healthy shadow, explicit legacy, encryption opt-out, corrupt index.db (#2771).
…degraded-web-warning
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3454-pr.3041.cffee4fThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3041.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…follow-up to #3040) The reason string is error-derived text composed into innerHTML by the client; the template suite (web-update-banner) pins exactly this property for its banner — mirror it here.
StorageRuntimeStatus / getStorageRuntimeStatus / StorageStatusWire (runtime-status.ts) and DiagnosticsReport (diagnostics.ts) are consumed only within their own modules — the public surface is the exported functions (storageStatusWire / storageDiagnosticsLines / buildDiagnostics). The unused-exports gate flagged them, which under #2637 fail-fast tiering cascaded to SKIP the full test + typecheck + build legs in CI, so the PR head was never actually validated by the suite. Dropping the leading `export` resolves the gate so CI re-runs on the pushed head. Review fix for #3041.
(ai: vllm-qwen/qwen3.8-27b) Reviewed PR #3041 against issue #3040 (direction) + full diff + CI. One real blocker found and fixed+pushed; otherwise ready to merge once CI lands green on the new head. 先说结论:方向对、代码干净、测试有牙。唯一拦路的是 八问:
测试有效性(④): diff 整洁度(⑤):干净,每行都跟本 PR 目的相关;无空行/重排噪声;lockfile 未动。 顺带核到的两笔 follow-up(已在分支上,均合理): 一个非阻塞小观察(不拦、不立项): 判定:可合。 唯一拦截项(unused-exports)已修并推送( |
…er test
tests/web-storage-banner.test.ts built SessionStore({enabled:true}) instances
whose unified shadow sidecar opens index.db inside the per-test temp dir, but
only closed the HTTP server before rmrf(base). Windows cannot delete a
directory while index.db is open, so the leaked handle pinned the tree past
every retry window in tmp-rm.ts -> EPERM in teardown. The 'healthy sidecar'
case is the only one that acquires a live engine (the others force engines
unavailable / opt out via BILI_ENCRYPTION_KEY / fail to open a corrupt db).
Hoist each store and call closeQuietly() in the finally before rmrf.
Review fix for #3041.
(ai: vllm-qwen/qwen3.8-27b) 跟进:CI 跑完了,发现并修掉了一个真实缺陷(仅 Windows)。 上一轮我判「可合 pending CI 绿」,但 CI 回来发现 6771 例里 fail 1。根因(不是断言失败,是清理阶段):这条用例用 怎么修的:persist.ts 本来就有专门的 回归:不涉及——只动了这个新测试文件自己的 teardown,没碰任何 src/ 生产代码、wire、配置或既有行为; 判定:维持可合。 两个拦截项(unused-exports 门禁 + Windows 测试句柄泄漏)都已修并推送( |
(ai: vllm-qwen/qwen3.8-27b) CI 全绿,收工确认。 在推送的
两个审查拦截项都已修并验证:
最终判定:可合(ready to merge)。 无回归——两处改动一处是纯导出收敛、一处只动新测试自身的清理逻辑,均未触碰 src/ 生产路径、wire、配置或既有行为。合并留给你(系统规则禁止 agent 合并):#3041 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.398-master.25d2539 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3040
What
Before the upcoming full-mode default flip (#2960 roadmap), environments where the SQLite engine ladder lands on
none— or where a corruptindex.dbtrips the 3-strike guard (#2771) — silently ran on legacy JSON: one-time log lines, no persistent user-actionable surface, so we would never learn which environments fail before they become a support wave. Per owner direction in-thread (「最好这个复制错误到github反馈做成通用功能,以后错误都这样」), this ships a generic "copy diagnostics → prefilled GitHub issue" facility whose first consumer is the storage-degradation banner:src/storage/runtime-status.ts): records the requested mode (SessionStore ctor), sidecar open failure/instance (UnifiedShadow.maybeOpen), and theensureSqliteEngineoutcome (cli.ts). Derivesrequestedvseffective,degraded,intentionalOptOut(BILI_ENCRYPTION_KEY excluded by design), and a human-readable reason from the ladder outcome / bootstrap failure payload / 3-strike state.storageStatusWire()) feeds BOTH/__bili/statusand/__bili/overview— the [web] advisory banner 是死代码:/__bili/overview 不含 advisory 字段,web 客户端从不调用 /__bili/status #2152 parity discipline; the two surfaces can never drift apart.GET /__bili/diagnostics?topic=…(loopback-only, same gate as all/__bili/*): returns{blob, title, url}— a copyable blob (bili version+commit, node version, platform/arch, OS, uptime, session count + topic section) and a prefilledhttps://github.com/ranxianglei/billion-context/issues/new?title=&body=link whose body decodes back to the exact blob. Unknown topics fall back to the base blob, so any future warning only needs one entry in the topic table. First topic:storage-legacy-only(raw knob stack env+file verbatim, engine-ladder outcome+reason, bootstrap failure marker with cooldown remaining,[storage]log tail)..banner.warnstyle) shown iff requested ≠ effective and not an intentional opt-out, with copy-diagnostics + report-on-GitHub buttons wired to the generic endpoint. Copy per issue spec,{reason}interpolated.Config surface
None. No new config keys, env vars, or CLI flags — reuses the existing knobs (
BILI_STORAGE_UNIFIED/storage.unified,BILI_STORAGE_JSON_WRITER/storage.jsonWriter,BILI_SQLITE_AUTO_DOWNLOAD/storage.sqliteAutoDownload,BILI_ENCRYPTION_KEY) through the existing three-level resolution insrc/knobs.ts.knobs.tsnow exports the file-tier readers (fileStorageUnified/fileStorageJsonWriter/fileStorageAutoDownload) so diagnostics report raw values;persist.tsdrops its private duplicates (identical behavior — sameloadConfigFile()source, same guards).Behavior changes (disclosed)
/__bili/statusand/__bili/overviewgain astoragefield (new key; existing consumers unaffected).GET /__bili/diagnostics?topic=— loopback-only like every other/__bili/*route; never throws (all fs/session access guarded).#storage-degraded-bannerrenders only whendegraded=true; hidden for healthy shadow/full, explicitlegacy, and the encryption opt-out (reported asintentionalOptOut: true, never warned).Verification
Local targeted runs green on the rebased head (merged with current master incl. #3019): typecheck + build +
tests/web-storage-banner.test.ts(new: forced none-engine wire contract incl. status/overview parity, blob contents, URL body-decode round-trip, unknown-topic fallback, page/client markers; healthy shadow; explicit legacy; encryption opt-out; corrupt index.db #2771) +web-i18n(catalog parity/lint over the new keys) +web-update-banner+storage-engine-bootstrap+storage-json-writer-off+ merged-inissue3004-nudge-decide-selfheal. Full-suite verdict = remote CI on the pushed head.