Skip to content

fix: advertise absorb/acp_rule in plugin manifest when globally enabled (#1278) - #1281

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-24_pi-manifest-absorb
Sep 25, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-24_pi-manifest-absorb

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Summary

GET /__bili/plugin/manifest advertised opt-in tools (absorb, acp_rule) from the raw kernel-default config instead of the user's global compress settings. The per-request path resolves opts.compress onto the kernel config via applyCompressSettings; the manifest route read config (= opts.kernelConfig) directly. So a user enabling compress.absorb.enabled: true in their config file got [ACP absorb] … call absorb(…) prompts on the wire, but hosts that register only the manifest's tools (the Pi native plugin, dist/agent/pi-native.js) never registered a callable absorb — the prompt could never be executed.

Root cause (verified): two config objects diverged on this one route.

  • Manifest route: handlePluginManifest(res, config) → absorbEnabled(config) / rulesEnabled(config) read off kernel defaults (absorb disabled).
  • Request path: resolveRequestConfig(config, opts.routes, url, model, native, opts.compress) → applyCompressSettings(base, limit, compress) sets absorb.enabled = s.absorb.enabled === true.

The existing test plugin manifest: absorb and acp_rule advertised when enabled in config masked the bug because its harness injected absorb through kernelConfig (the exact path the manifest reads), not through the real file-config path (opts.compress).

Fix

At the single /__bili/plugin/manifest call site in src/server.ts, resolve the global settings before building the manifest:

return handlePluginManifest(res, applyCompressSettings(config, opts.modelContextLimit, opts.compress));

Both config and opts are already in scope of the route handler. This makes the manifest agree with the request path for globally-enabled tools. Per-session / provider / model enablement stays execution-time-gated (the manifest is one static doc for all clients — same intent as #1192).

⚠️ Behavior change (flagged)

This corrects two tools at once, not just absorb:

  • absorb — now advertised when compress.absorb.enabled is globally true (was: always omitted). ← the reported bug.
  • acp_rule — now advertised when compress.rules.enabled is globally true (was: always omitted). Same latent bug, same root cause; fixed by the same line.

For users who have NOT enabled these features, the manifest is byte-for-byte unchanged (kernel defaults still disable both). No change to compression semantics, wire shape, or persistence — only which optional tools are advertised to manifest-driven hosts.

Tests

  • New plugin manifest: absorb advertised when enabled in the global compress block (enabled case, real file-config path).
  • New plugin manifest: absorb omitted when the global compress block disables it (disabled case).
  • Extended the startHarness helper with an optional compress param so tests can exercise the real opts.compress path (previously only kernelConfig was reachable).
  • Verified the new enabled-case test fails without the fix (reproduces Bug: Pi plugin manifest omits absorb in 0.1.147 #1278) and passes with it.

Pre-flight

  • npm run typecheck — clean
  • node --import tsx --test tests/plugin-protocol.test.ts — 16/16 pass
  • Full npm test — 2449 pass / 3 fail; the 3 failures are pre-existing environmental e2e (tests/claude-native.test.ts: live-ps-walk + real-process lifecycle) that fail identically on a clean tree, unrelated to this change.
  • npm run build — success

Fixes #1278

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-24_pi-manifest-absorb (081f05d)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1281

Each push to this PR publishes a new version under the pr-1281 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1281.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 — this is our own earlier work (opened from #1278), so per protocol I verified rather than redid it, and brought it current against master. Mergeable after the rebase below.

① Original issue (direction gate). Re-read #1278 and re-verified the diagnosis at source: the manifest route read the raw kernel-default config while the request path resolves opts.compress onto it via applyCompressSettings. The fix attacks the root cause (two divergent config sources on one route) by making the manifest use the same resolution the request path uses — not a symptom patch. Global-level-only scoping matches the #1192 conservative-advertise intent (per-session enablement stays execution-time-gated). Direction is right.

② Regression audit (existing behaviors on touched paths).

  • GET /__bili/plugin/manifest — the only behavior delta. For users who enabled neither feature: manifest is byte-for-byte unchanged (kernel defaults disable both; src/compress-settings.ts:289-292 leaves base.absorb/base.rules untouched when the user block is absent). With global compress.absorb.enabled: true → absorb now advertised (was: omitted) ← intended; with global compress.rules: true → acp_rule now advertised (was: omitted) ← same latent bug, flagged in the PR body. Old→new disclosed, no silent drift.
  • No side channels: applyCompressSettings returns a NEW Config ({...base} spread, src/compress-settings.ts:227-294) — the shared config object is never mutated, so no cross-route leakage. handlePluginManifest consumes the config ONLY through absorbEnabled()/rulesEnabled() (src/plugin.ts:541-542) — none of the other resolved fields (nudge/truncate/tiers/limit) reach the manifest payload, so blast radius is strictly tool advertisement. Wire shape, compression semantics, persistence: untouched. All other routes: untouched.

③ Code review. Single call site + one import addition; the comment block documents why the line must not be "simplified" back to config. Nothing else to flag.

④ Test validity. The two new tests drive the REAL file-config path (startHarness extended with an optional compress param feeding opts.compress) instead of the kernelConfig shortcut that masked the bug. Enabled case asserts the exact 6-tool set across all three wire shapes; disabled case guards against "advertise whenever the key is present". Both have teeth — the enabled case fails pre-fix by construction (the pre-fix manifest never sees opts.compress).

⑤ Diff cleanliness. 2 files, one commit, every line on-purpose. No churn.

Rebase (the one thing that needed doing): the branch was stale — cut from 088bb348 before master absorbed the #1257 output-side-compression merge, hence the dirty mergeable state. Cherry-picked onto current master 8e5eb582; the only conflict was the import line (master added resolveOutputSteeringConfig, we add applyCompressSettings) — resolved by union. Force-pushed: head is now 371f15bd, GitHub reports mergeable: true (state blocked = awaiting CI on the new head).

Pre-flight on the rebased head (local, full gate): typecheck clean · tests/plugin-protocol.test.ts 16/16 · full suite 2503 tests, 2494 pass, 0 fail, 9 skipped (this run had zero environmental e2e failures — cleaner than the original run's 3 claude-native env flakes) · build OK + dist-import-annotations OK.

⚠️ Hot-file interaction with open PR #1273 (CCR plugin lanes): #1273 edits the same /__bili/plugin/manifest call site (manual {...config, ccr: {...}} spread) and handlePluginManifest itself. Not a blocker for this PR, but if #1273 merges first this one needs a trivial rebase — and the union resolution is exactly THIS line, since applyCompressSettings already layers the global ccr block, subsuming #1273's manual spread. Left a coordination note on #1273.

中文一句话: 复核了我们自己从 #1278 开的这个 PR——修复方向正确(manifest 路由与请求路径共用同一份已解析的全局压缩配置,治本而非堵症状)、回归面严格限于工具广告(未启用者 manifest 逐字节不变、无共享对象变异)、测试走真实文件配置路径且有牙;唯一动作是把过期分支 rebase 到当前 master(仅 import 行冲突,按并集解决)并重跑全套预检全绿,现 mergeable: true(等 CI),与在途 PR #1273 有同一调用点的语义交互已双向标注,可以合并。

…ed (#1278)

The /__bili/plugin/manifest route read absorbEnabled(config)/rulesEnabled(config) off the raw kernel-default config (opts.kernelConfig), while the per-request path resolves opts.compress onto it via applyCompressSettings. A user enabling compress.absorb.enabled in their config file therefore got [ACP absorb] prompts on the wire but no callable absorb tool registered by hosts that register only manifest tools (Pi native plugin) — the prompts could never be executed.

Resolve the global compress settings at the manifest route so both paths agree; per-session/provider enablement stays execution-time-gated. Adds enabled + disabled regression tests exercising the real file-config path.

Fixes #1278
@ranxianglei
ranxianglei force-pushed the 2026-09-24_pi-manifest-absorb branch from 371f15b to 081f05d Compare September 25, 2026 03:48
@ranxianglei
ranxianglei merged commit 28a3796 into master Sep 25, 2026
9 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-24_pi-manifest-absorb 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.

Bug: Pi plugin manifest omits absorb in 0.1.147

1 participant