Skip to content

[PR] BILI_PLUGIN_BYPASS env force-switch for the plugin bypass wire lane (#6220) - #6359

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-11-12_bili-plugin-bypass-env
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-11-12_bili-plugin-bypass-env

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

Issue #6220 asks for a way to force the x-bili-plugin-bypass decision from the outside. Today that decision is made per-request, purely from the header the opencode-acp host plugin stamps for legacy sessions — an operator on a machine where opencode auto-disabled bili had no lever to force either side.

This PR adds the env-only knob BILI_PLUGIN_BYPASS at the proxy decision site (src/server/handle.ts):

Value Effect
unset / auto Per-request header decides — zero behavior change (today's default)
1 / on Force bypass for ALL inbound model traffic: raw passthrough, no compression, no session state. Escape valve when an in-process compressor is loaded but bili still manages those sessions. First hit logs a loud warn: if nothing in-process (e.g. opencode acp) is actually compressing, traffic reaches the model uncompressed.
0 / off Ignore any inbound bypass header, including opencode legacy ones: bili takes over those sessions. First hit logs a loud warn: their pre-existing ref space lives in the in-process acp store, so their history degrades to a read-only archive.
anything else Treated as unset (auto) + one warning about the typo

Each forced state emits exactly one warn-once log line (per state); later requests stay at debug level.

Why env-only, no config-file key

Owner ruling in the #6220 thread (plan A, "继续"): this is an explicit escape valve, not a per-machine tunable — env-only by design, per reference/env-vars.md hard rule 1 with owner sign-off in-thread. Generic name (not opencode-specific): the header is a generic wire contract, and the same auto-disable conflict can arise from other in-process compressors too.

Changes

  • src/knobs.ts — pure resolvePluginBypass() resolver (env: NodeJS.ProcessEnv injectable, returns "on" | "off" | "auto" | "invalid"), placed with the other resolvers per knob-placement discipline.
  • src/server/handle.ts — decision site consumes the resolver: force-on overrides the header; force-off silences it; invalid behaves as auto. Warn-once set pluginBypassForceWarned + test seam _resetPluginBypassForceWarnForTest (same pattern as _resetNoOutputCeilingWarningsForTest).
  • tests/plugin-bypass.test.ts — new BILI_PLUGIN_BYPASS force switch (#6220) suite: resolver unit test (tri-state + case/trim + invalid classification) and 4 end-to-end proxy cases against the existing harness (force-on with NO header, force-off WITH header, auto/invalid keep header semantics, warn-once loud lines incl. the exact risk wording). Harness switched to log: true, logFile: "off" (established pattern, e.g. tests/codex-responses-ws.test.ts) so the engine log — a no-op under log: false — is observable via setLogCapture. 7/7 pass.
  • Docs: website/config-reference/env-only.yaml entry (generated into docs/configuration.md + zh-CN), docs/lifecycle.md §2.9 line. tools/gen-config-docs.mjs generate + check-coverage clean.

Verification

  • node --import tsx --test tests/plugin-bypass.test.ts → 7/7
  • tests/knobs-config-precedence.test.ts → 16/16
  • scripts/check-test-import-graph.mjs, scripts/lifecycle-ledger-guard.mjs, scripts/config-surface-guard.mjs → all OK
  • npm run typecheck → clean

…s wire lane (#6220)

The plugin bypass decision (handle.ts) previously honored only the
per-request x-bili-plugin-bypass header that the opencode-acp host
plugin stamps for legacy sessions. There was no user-side override:
once opencode auto-disabled bili for those sessions, an operator
could not force one side or the other per machine.

BILI_PLUGIN_BYPASS (env-only, tri-state, owner ruling in the #6220
thread):
- unset/auto: per-request header decides (zero behavior change)
- 1/on: force bypass for ALL inbound traffic, raw passthrough, no
  compression, no session state — the escape valve; first hit warns
  that traffic reaches the model UNCOMPRESSED if nothing in-process
  is actually compressing
- 0/off: ignore any inbound bypass header, including opencode legacy
  ones; first hit warns that those sessions' pre-existing ref space
  lives in the in-process acp store, so their history degrades to a
  read-only archive
- unrecognized values: treated as unset (auto) + one warning

Each forced state logs one loud warn-once line (module-level
warn-once set, test seam _resetPluginBypassForceWarnForTest).

Knob resolver lives in src/knobs.ts (pure, env-injectable) per the
knob placement discipline; documented in env-only.yaml
(generated docs/configuration.md + zh), docs/lifecycle.md §2.9,
and covered by tests/plugin-bypass.test.ts (resolver unit + 4
end-to-end proxy cases incl. the warn-once assertions).
@ranxianglei ranxianglei changed the title BILI_PLUGIN_BYPASS env force-switch for the plugin bypass wire lane (#6220) [PR] BILI_PLUGIN_BYPASS env force-switch for the plugin bypass wire lane (#6220) Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-12_bili-plugin-bypass-env (1418e30)

Latest build — install this exact version

npm install -g billion-context@0.0.9289-pr.6359.2e57a45

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

Recent builds (commit → version)

commit version build
1418e30 billion-context@0.0.9289-pr.6359.2e57a45 build

Download artifact

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

Install instructions are refreshed on each push.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant