Skip to content

feat: surface active advisories in acp_status, /acp panel and bili doctor (#1577) - #1585

Merged
ranxianglei merged 3 commits into
masterfrom
2026-09-28_advisory-native-lane-visibility
Oct 1, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-09-28_advisory-native-lane-visibility

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #1577

What & why

#1483's advisory mechanism (broken-version detection + force-install) works end-to-end in native/plugin lanes — the watcher lives in the spawned proxy child. But all of its loud channels are unreachable there: ensureProxyRunning (src/launcher.ts) spawns the child with stdio:["ignore",logFd,logFd] on an ephemeral port, so the stderr warn line, the Web UI banner and /__bili/status all land somewhere the user never looks. The /acp panel is the one surface a native-lane user actually sees, and it had no advisory section.

This adds human-facing visibility for an active instance-level advisory, without touching the wire:

  1. acp_status gains an instance-level CRITICAL ADVISORY section while one is active — same pattern as the existing UNDECRYPTED TRAFFIC (instance-level) (CodeBuddy 直接使用httpProxy 不能压缩上下文的问题 #897).
  2. The /acp panel gains a ⚠️ CRITICAL ADVISORY: line, inserted before PANEL_BOX_FOOTER so the LLM-context stripper (which anchors its whole-message match on that footer) still matches; byte-exact when no advisory is active.
  3. bili doctor reports one advisory line: active reason + manual command / none / check failed (…) — status unknown. Doctor runs in its own process with no watcher, so it performs a read-only evaluateAdvisories() against the disk version (no install side effects — doctor never writes).

Shared wording lives in a new describeAdvisory(); evaluateAdvisories() is a self-contained, fail-open, state-free variant so the load-bearing runAdvisoryCheck force-install path stays byte-stable.

Config surface

No new fields. This only reads the already-resolved advisoryUrl (BILI_ADVISORY_URL / advisory.advisoryUrl, both introduced by #1483) in the doctor path. Nothing is added, renamed, or re-semantics'd.

Behavior changes (flagged per policy)

All three are additive and gated on an active advisory; when none is active every output is byte-identical to before:

  • bili doctor: the global section gains one advisory line (previously absent). Unreachable/malformed source → check failed (…) — status unknown, exit 0 (fail-open). Old→new: no line → one line.
  • acp_status output: gains a CRITICAL ADVISORY (instance-level): … section only while active.
  • /acp panel: gains a ⚠️ CRITICAL ADVISORY: … line before the footer only while active.

No wire/turn injection (the stated non-goal): these are on-demand diagnostic surfaces for humans, not model context.

Design decision — optional item #3 skipped

The issue's optional bili advisory status subcommand was deliberately not added: bili doctor --json already exposes the advisory as scriptable structured output, and a dedicated subcommand would duplicate that without a distinct use case. Happy to add it if you'd prefer the explicit verb.

Pre-flight (rebased onto current master e258bc80 = v0.1.166 + relanded #1483)

  • npm run typecheck — clean
  • npm test — 3058 pass / 0 fail / 12 skip
  • npm run build (tsup) — success
  • New regression tests: tests/advisory-panel.test.ts (/acp panel before-footer insertion + byte-exact clean case), plus cases in tests/advisory.test.ts (evaluateAdvisories / describeAdvisory), tests/acp-status.test.ts (acp_status section), tests/doctor.test.ts (doctor line incl. fail-open).

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-28_advisory-native-lane-visibility (8c3bb96)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1858-pr.1585.c5ed5d8

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-pr1585.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review complete — verified against current master, one hardening commit added during review (head is now a84bb7eb).

Base freshness. merge-base of the PR head and master = e258bc80 = current master HEAD (v0.1.166 release + #1483 reland via #1582). Fully current, no rebase needed.

① Original issue (#1577) — direction correct. The diagnosis holds: native/plugin lanes spawn the proxy child with stdio→log fd on an ephemeral port, so the stderr warn, web banner and /__bili/status are genuinely unreachable there; the /acp panel + acp_status are the surfaces those users see. Fixing visibility at the decision point (read the shared advisory state, render into the human-facing surfaces) rather than filtering transport is the right layer. Skipping optional item #3 (bili advisory status) is agreed — bili doctor --json already exposes it scriptably.

② Regression audit — existing behaviors on touched paths, each verdict:

  • src/plugin.ts handlePluginStatus: Web UI deep-link insertion — preserved byte-exact. Analyzed all four state combinations (advisory ±, webUrl ±): without an advisory the replacement string is byte-identical to the old code, and with neither advisory nor webUrl no .replace() runs at all, exactly as before. Footer remains the box's last line in every case, so the LLM-context stripper anchor still holds. Other response phases (404 / idle / chain-advisory / pre-first-request) untouched.
  • src/acp-status.ts: all existing sections (nudge/ranges, CCR, block spans, archive, conflicts, CodeBuddy 直接使用httpProxy 不能压缩上下文的问题 #897 blind tunnels, dsh使用插件dsh-commandcode-provider反代go套餐的话,不进billion-context压缩 #1290 unrecognized paths) untouched; new section is purely additive and gated on adv.active.
  • src/advisory.ts: additions only (describeAdvisory, _setAdvisoryStateForTest, evaluateAdvisories, AdvisoryEvaluation) — the load-bearing runAdvisoryCheck force-install path is byte-stable, verified in diff.
  • src/cli.ts / src/doctor.ts: one option threaded through; doctor report gains an optional advisory field (additive for --json consumers).
  • Full suite confirms: 3058 pass / 0 fail / 12 skip — identical to the PR's own pre-flight.

③ Code review — found and fixed one defect (commit a84bb7eb). The /acp panel inserts the pre-footer block via String.replace(FOOTER, replacement); $ sequences in a replacement string are pattern syntax ($& = matched text, $` = text before match, $' = after). Advisory reason/id come from the remote advisory doc, so this PR introduced the first dynamic content flowing into that replacement string — a reason containing $& splices the footer text into the advisory sentence (reproduced locally), and $` would duplicate the whole panel head. Fixed by escaping each $ to $$ (.replace(/\$/g, "$$$$")) with a regression test pinning a $5M/$& reason rendering verbatim and the footer appearing exactly once. Byte-identical output for all inputs without $ (Web UI URLs never contain any).

④ Test validity. All four surfaces are pinned with teeth: panel test asserts the clean case stays advisory-free AND the active line sits before the footer (stripper invariant); evaluateAdvisories tests assert the read-only contract explicitly (getAdvisoryState() unmutated), clean/fail-open/malformed-schema paths; doctor tests cover active/none/check failed … status unknown rendering under sandboxed env with mocked fetch. A regression in any of these shapes would be caught.

⑤ Diff cleanliness. 9 files, +300/−3, every line serves the stated purpose; no whitespace churn, no generated/lockfile drift. My follow-up commit is +13/−1, clearly labeled.

Behavior changes — confirming the PR's disclosure, plus two honest addenda:

  1. As disclosed: bili doctor gains one advisory line always (was absent); acp_status and the /acp panel gain their advisory content only while active, byte-identical otherwise.
  2. Addendum A: doctor performs one extra network call per run (5 s timeout cap). If the advisory source is unreachable, bili doctor can take up to ~5 s longer than before. Fail-open, exit code unchanged.
  3. Addendum B: doctor evaluates advisories even when advisoryCheck is opted out — deliberate (documented in-code): doctor is on-demand diagnostics, and it already queries the npm registry unconditionally regardless of the auto-update opt-out. Same posture, flagged here for completeness.
  4. Precision note: for acp_status the section reaches the model as a tool result when the model calls acp_status while an advisory is active — same class as the existing CodeBuddy 直接使用httpProxy 不能压缩上下文的问题 #897/dsh使用插件dsh-commandcode-provider反代go套餐的话,不进billion-context压缩 #1290 instance-level sections (established precedent, one short line, active-only). For the /acp panel and doctor the "not model context" statement holds exactly.

Pre-flight on the new head (local): typecheck clean · full suite 3058 pass / 0 fail / 12 skip · tsup build success. CI was 12/12 green on the previous head; re-running on a84bb7eb.

Verdict: mergeable once CI is green on a84bb7eb.

中文摘要:审查了 advisory 可见性 PR(acp_status / /acp 面板 / bili doctor 三个表面),方向正确、既有行为全部保持;发现并直接修复了一个远程公告文本中 $ 字符会被 String.replace 模式语法误解释、导致 /acp 面板行损坏的潜在缺陷(补了转义与回归测试,commit a84bb7e),CI 转绿后可以合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI confirmed green on a84bb7eb — all 12/12 checks pass (build-artifact, version-guard, hermetic registry e2e, all four real-client lanes zero-token, codex MCP overlay, ubuntu/windows test matrix). Nothing further outstanding from my side; the PR is ready for a human merge whenever you are.

ework-agent and others added 3 commits October 1, 2026 21:48
…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.
…t renders verbatim (#1577)

The /acp panel inserts the pre-footer block through String.replace(FOOTER, replacement); $ sequences in the replacement are pattern syntax ($& = matched footer, \$\$ = text before match, $' = after). Advisory reason/id come from the remote advisory doc, so a $ sequence there would corrupt the rendered line (e.g. $& splices the footer text into the advisory sentence) — this is the first dynamic content flowing into that replacement string. Escape each $ to $$$. Byte-identical output for all inputs without $ (Web UI URLs never contain any). Regression test pins a $5M/$& reason rendering verbatim with the footer appearing exactly once.
…s import in the #1655 teardown sweep

Rebase onto master removed the old base's rmSync import; the two new
#1577 doctor tests called it bare (same class as #1707). rmrf(base)
matches every other cleanup in this file.
@ranxianglei
ranxianglei force-pushed the 2026-09-28_advisory-native-lane-visibility branch from a84bb7e to 8c3bb96 Compare October 1, 2026 13:49
@ranxianglei
ranxianglei merged commit f607078 into master Oct 1, 2026
12 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-28_advisory-native-lane-visibility branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[follow-up #1483] Advisory visibility in native/plugin lanes: all three surfaces are effectively invisible

1 participant