Repository navigation
feat: force-update out of critical-defect versions via remote advisories - #1483
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1510-pr.1483.dc5ae88This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1483.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Reviewing this PR now — pulling branch |
[bot] 🏷 Review of PR #1483 (advisory-based force-update, Fixes #1481) Reviewed the full branch against current master ( ① Original issue (direction) — PASS. Matches the design ratified in #1481 (「同意 开搞」): remote advisory doc via a companion npm package, independent default-on watcher, force-install to the advisory target with rollback semantics, warning presentation carrying reason + manual instructions, fail-open. It addresses the root cause (no mechanism could reach installs with auto-update off or a broken updater), not a symptom. Trust domain unchanged: same npm registry as the tarballs bili already auto-installs; publishing requires ② Regression audit — existing behaviors on every touched path:
③ Code review — core design is sound (schema-pinned parsing, fail-open everywhere, reused single-writer guards, rollback semantics, restart double-fire guarded by
④ Test validity — the existing 14 tests have real teeth (real-tarball e2e through the full integrity chain, fail-open paths, throttle cadence, deferral). Gaps I closed: added a host-managed (pnpm-store) refusal test — the #991 single-writer contract on the new path had zero coverage — with a warns-once-per-process pin; extended the misconfigured-advisory test to pin dedupe across repeated cycles; strengthened the deferral test to assert the deferral decision itself is logged (its old fixture ⑤ Diff cleanliness — clean (+910/−8, every line purpose-related; README/CONFIGURATION en+zh in sync). Nits left unfixed (reported only):
Local verification on the pushed head: typecheck clean · full suite 2898 tests / 0 failures (12 pre-existing gated skips; +1 new test vs the PR body's count) · build OK with dist confirmed dependency-free. CI on Merge gate: this PR touches 修复了 review 中发现的三个问题:advisory 激活期间常规循环的 defer 会挂起托管安装(dsh profile 等)唯一的 #1196 自更新通道(回归,已恢复)、拒绝/失败警告未去重导致每 3 分钟重复刷屏且部分失败路径完全静默、advisory 发布 CI 不校验 semver 语法(拼错的 advisory 会静默失效)外加版本号字典序比较的潜在 bug;均已在 PR 分支直接补了带回归测试的修复,本地全量 2898 测试通过,等 CI 绿后建议先按 §5 发一个 no-op 版本再合并本 PR。 |
1c6b8a0 to
c52f399
Compare
[bot] 🏷 CI + rebase update While waiting on CI, master advanced 44 commits (incl. release v0.1.160), which put the PR in
The branch is ready. Two reminders before merge (both already in my review post): human-only merge, and per AGENTS.md §5 ship a no-op release first — this PR touches 已把分支 rebase 到最新 master(v0.1.160,零冲突)并在本地重跑全部门禁(typecheck + 2934 测试全过 + 构建),新 head |
|
深审收尾:F1/F2 已修(head F1 — 坏目标兜底零覆盖: F2 — 不可解析目标楔死自更新(reviewer 定性:#1196 frozen-forever 同类):
门禁:typecheck ✓ / 全量 2923 过 0 败(12 skip 为既有门控)/ advisory 16/16。非阻塞观察(F3-F10)见 reviewer 报告,F2a 已含在本修复。可合并。 |
[bot] 🏷 F1/F2 verification at Read the full diff and re-ran every gate locally on your head:
Design assessment — the layering is right. Source-side prevention (CI
One residual edge (non-blocking, same class as your parked F3–F10): deferral is only released for cannot-resolve failures. A permanently unreachable advisory source with a custom Branch state: master moved +3 commits since your base (cache-ledger #1489/#1490) → GitHub shows Standing reminders unchanged: human-only merge, and per AGENTS.md §5 ship the no-op release first — this PR rides 已独立复核 F1/F2(读全量 diff + 本地重跑全部门禁:typecheck ✓、advisory 16/16、全量 2935 测试 0 败、构建依赖面不变、CI 9/9 绿),分层方案(发布前拦截 + 客户端 fail-open + UI 诚实降级)语义全部核对无误,与最新 master 零冲突可合并;合并前记得按 §5 先发 no-op 版本验证升级链路。 |
|
深审完成(head 逐轴验证
测试/门禁:advisory 16/16、update+config 邻域 84/84、cli/auto-update 25/25,CI 12/12 全绿(含 hermetic registry e2e——advisory URL 没有破坏 verdaccio 套件,好信号)。本地 typecheck 一度红是 worktree 符号链接缺新 devDeps( 合并前两个流程要求(非代码)
非阻塞观察:重叠 advisory 按 |
[bot] 🏷 收尾确认 — 同意 ✅ 可合,两个校准点补充 两轮独立审查已收敛到同一结论(我这轮:全量 diff 重读 + 本地门禁重跑 2935/0 败 + CI 9/9 绿 + 对当前 master merge-tree 无冲突;你这轮:六轴 worktree 实测)。技术面无未决项;「typecheck 一度红」确认是 worktree 符号链接的环境假象——我从 lockfile 对你提的两条合并前流程要求——完全同意,各补一点:
非阻塞观察收到(重叠 advisory 最终状态:head 同意 ✅ 可合结论。两点校准:空跑 advisory 只覆盖读链路,写链路由 CI hermetic e2e 兜底,两者合起来才闭环;空跑范围务必用永不匹配真实版本的区间(如 >=999.0.0)并在验证后下线条目。合并顺序不变——no-op 先发、观察到真实升级日志后再合本 PR,需要我准备 no-op release 分支随时说。 |
… per process The advisory watcher retries forceInstallVersion every cycle while an entry matches. Without dedupe, a persistent refusal (source checkout #580, host-managed lane #991) logged a fresh warning every cycle forever, and the remaining failure paths (unresolvable target, missing install dir, lock contention, failed install) were silent — visible only via /__bili/status lastError. All refusal/failure sites now log once per process per advisory id + message; state.lastError strings are unchanged.
…during advisory deferral While an advisory is active the regular loop defers before it ever reaches the host-managed branch, so refreshDshProfileCopy (#1196) — the only live update path for dsh profile bundle installs without a global bili — was suspended indefinitely until a manual update. The deferral now detects host-managed lanes and still drives their owner-channel refresh; writable installs are untouched by the regular loop as before, and forced manual checks still bypass deferral entirely.
…phic version max The publish gate checked schema and required fields but not semver syntax, so a typo'd affected range or target would publish fine and fail open on every client — an ineffective advisory with no signal anywhere. The gate now runs npm ci and rejects invalid Range/target values before publishing. The version-max used string comparison (process.argv[1] > process.argv[2]), which breaks once the local placeholder passes 0.0.9 lexicographically; it is now semver.gt. Documented multi-match precedence (first listed entry applies) in the advisories README.
…p (F1/F2) F1: the 'cannot resolve <target> on the registry' fail-safe had zero regression coverage (mutation-verified) — tests/advisory.test.ts now pins install-untouched + once-per-process warn + lastError. F2: an advisory whose target doesn't exist (owner typo) set state.active forever and deferred the normal self-update loop indefinitely (#1196 wedge class), while the web banner offered an uninstallable escape hatch. - advisoryDeferring(): false while lastError is a cannot-resolve failure — cli passes it as the update loop's advisoryActive gate, so the normal loop keeps the install alive - /__bili/status exposes advisory.targetFailed; the web banner falls back to @latest when the target failed to resolve - CI publish gate (advisories.yml) now checks each target exists on npm before publishing the companion package
84dc8b9 to
1cc07c1
Compare
Revert "feat: force-update out of critical-defect versions via remote advisories" (#1483) — re-land after no-op v0.1.166
Re-land #1483: remote maintenance advisory + force-update (after no-op 0.1.166 validation)
…-27_advisory-force-update" This reverts commit 44171bf.
…ctor (#1577) In native/plugin lanes (bili pi, opencode/dsh plugin) the proxy child runs on an ephemeral port with stdio->log fd, so #1483's advisory loud channels -- stderr warn line, Web UI banner, /__bili/status -- are all unreachable by the user. The force-install still works; what was missing was visibility. Adds three human-facing surfaces for an active instance-level advisory: acp_status + the /acp panel gain an instance-level section (mirrors the #897 UNDECRYPTED TRAFFIC pattern; the /acp line is inserted before PANEL_BOX_FOOTER so the LLM-context stripper still matches, byte-exact when no advisory), and bili doctor gains one advisory line (active reason+manual cmd / none / check-failed unknown). Shared describeAdvisory() wording plus read-only evaluateAdvisories() used by doctor (it runs in its own process with no watcher, so it evaluates against the disk version). No wire/turn injection (visibility only, per non-goal); no new config fields.
Fixes #1481
What it does
Adds a critical-defect advisory mechanism that force-updates an install out of a known-broken version range — even when
autoUpdateis off (the core ask of #1481).Advisory source: a small companion npm package
billion-context-advisories, published by CI from this repo's newadvisories/directory (workflow.github/workflows/advisories.yml). It rides the same registry egress/proxy chain as the self-updater's tarball fetches, so it is reachable wherever bili can already update from, and sits in the same trust domain as the code we already auto-install. Escape hatch:"advisoryUrl"/BILI_ADVISORY_URL.Document shape (validated, schema-pinned):
{ "billionContextAdvisories": { "schema": 1, "updated": "...", "advisories": [ { "id": "...", "affected": ">=0.1.155 <0.1.158", "target": "0.1.157", "reason": "...", "publishedAt": "..." } ] } }targetis a concrete version and may be older than the running one — rollback semantics for when several consecutive releases are bad.How it works
src/advisory.ts: its own watcher loop on the existing 3-minute cadence (BILI_UPDATE_CHECK_INTERVAL_MS-aware), independent ofautoUpdate, default ON, opt-out"advisoryCheck": false/BILI_ADVISORY_CHECK=0.semver.satisfies(currentVersion, affected, {includePrerelease:true}).semveris added as an exact-pinned devDependency and bundled at build time —dist/index.jsstays dependency-free.forceInstallVersion()(new export insrc/update.ts) reuses the updater's full safety chain: cross-process lock, exact-version registry doc resolution, sha-integrity verification, staged extract, backup + verify + rollback,#580source-checkout refusal,#991host-managed-lane refusal (refuses in-place overwrite, warns with the owner's sanctioned channel instead), dsh profile bundle refresh, stale-install restart reminder (--auto-restart-on-update).[advisory] ⚠️ …log line per process/per advisory id; Web UI banner showing the reason plus the exact manual command;GET /__bili/statusgains anadvisoryfield (active entry ornull).bili updatestill proceeds.Behavior changes (intentional, flagged per policy)
/__bili/statusresponse gains anadvisoryfield (additive).advisoryCheck/advisoryUrland env varsBILI_ADVISORY_CHECK/BILI_ADVISORY_URL; defaults keep prior behavior for anyone who opts out.Pre-flight
npm run typecheck— cleannpm test— 2897 tests, 0 failures (12 pre-existing gated skips); newtests/advisory.test.ts14/14: parsing/validation, range matching (incl. prerelease + fail-open), URL resolution, unreachable/malformed-source fail-open, throttle cadence, real-tarball end-to-end force-install (forward + rollback), git-tree and misconfigured-target refusals, regular-loop deferral.npm run build— OK (dist-import-annotations: OK, semver fully inlined)This PR touches
src/update.ts(load-bearing updater infra). Per the no-op-release rule: ship a pure version-bump release FIRST, observe a real running install auto-updating OLD→NEW successfully, then merge this. The merge does not have to block on that if the owner prefers, but the feature should not be the first change riding the updated updater path without a proven healthy hop.Docs: README (en + zh) subsection under Self-update; CONFIGURATION env tables updated.