Skip to content

refactor(#1714): retire all BILI_*/ACP_* behavior env vars to config.json - #1716

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-09-30_env-surface-retirement-p1
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-09-30_env-surface-retirement-p1

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Closes #1714

Full-scope delivery of the config-surface convergence: every behavior-class BILI_*/ACP_* environment variable is retired — config.json is now the single input channel for proxy behavior. One PR per owner instruction (thread 2026-09-30).

What changed

Retirement (69 names, canonical registry in src/retired-env.ts)

  • Class A (~25 names, had file+env dual support): env layer deleted, file field kept — pure subtraction.
  • Class B (~34 names, env-only): new top-level config.json fields added + env read removed (src/config.ts, knobs across fetch-util.ts, persist.ts, server.ts, mitm.ts, tunnel-guard.ts, error-dump.ts, decompress-shared.ts, fake-completion.ts, image-tokens.ts, upstream-proxy.ts, store.ts, session-gc.ts).
  • BILI_MITM_DOMAINS user knob retired: the launcher→child pipe is renamed to internal BILI_LAUNCHER_MITM_DOMAINS so no user-facing name re-opens the pollution vector (Opencode failed to send message with error: upstream stream ended before a completion event; this turn may be incomplete #1706 failure mode: stale shell export silently changing behavior).
  • CLI flags (--debug/--no-auto-update/--auto-restart-on-update/--passthrough) now set ProxyOptions directly instead of routing through process.env.
  • Web passthrough state source converged to "file"|null; dead env-source 409 branch removed; clear button always enabled (en/zh copy synced).

P4 — RETIRED startup scan

P5 — docs

Base moved to v0.1.174. My earlier P1 commit (file-only streamStallMs + 5s floor) was superseded by owner-merged #1715, which removed the stall guard entirely — this branch drops P1 and follows master's design. To avoid double-warning, BILI_STREAM_STALL_MS is therefore NOT in the RETIRED map (master's own boot warning covers it).

Behavior change disclosure (old → new)

Per reporting rule 4, every semantic shift:

  1. Input channel: env → config.json for ~69 behavior knobs. Old: export BILI_X=... took effect on next start (and some live-reloaded). New: env values are IGNORED; the config.json field is authoritative. Stale exports are inert and produce a one-time boot warning naming the replacement field. Migration = move value from env to file.
  2. ~24 config.json fields that were previously DEAD CODE now take effect. Before this PR, several file fields existed in FileConfig but nothing forwarded them into the runtime (only tests called the setters) — users who set them got silently ignored values. startServer() + both hot-reload paths in src/server.ts now apply all of them (persist enabled/zstd/tailTokens/debounce/epermAlert×2, maxSessions, imageTokenCap, fakeCompletionRetries/fakeBufCap, dump4xx/maxBytes, decompressTmpCap, ccrRetrievalTtlMs, tunnel allowedHosts, mitm handshakeTimeoutMs, sessionGc{enabled,maxAgeDays,maxTokens,intervalMs}, upstreamTimeoutMs, replayRetryMax/baseMs, maxShrinkPerCompress, proxyKeepAliveMaxMs, streamKeepaliveMs, requestWatchdog, preflightHoldMs, preflightDeadEndCooldownMs, sessionsDir). Old behavior: file value ignored, default used. New: file value honored. This is intended (the whole point of file-only), flagged because it changes what existing config files do.
  3. sessionsDir wiring added (startup + reloads); previously the env var was the only channel and the file field was unwired.
  4. -F/--forward-proxy fix: the flag previously wrote overrides.BILI_UPSTREAM_PROXY; after env retirement that became a silent no-op. Now it sets a local marker applied directly after loadOptions() in all three paths (doctor/update/start). Old: broken (post-retirement); new: works again.
  5. GC sub-knobs (maxAgeDays/maxTokens/intervalMs) now honored from file (part of item 2).
  6. Attach/chain code knobs (attachEvidenceGraceMs, attachHealthDeadlineMs, chain maxFutureSkewMs/recentWindowMs): env fallbacks removed; programmatic module setters remain (tests/internal callers); no new config fields added — these post-date the issue inventory and are not user-facing product knobs; if you want them file-configurable, say so and I'll add them deliberately.
  7. Defaults unchanged everywhere: every knob's unset/default value is identical to before; only the input channel moved.

Kept seams (documented, not retired)

  • Class C/D kept: transport/system-proxy conventions, inter-process pipes (BILI_LAUNCHER_MITM_DOMAINS), secret inputs, test seams (ACP_TEST_*, BILI_FAKE_HOOK_CMD, BILI_EPIPE_LOG_FILE, BILI_TEST_MARKER), ACP_RENDER_NONE D-seam, ACP_PORT/HOST, BILI_CONFIG_FILE.
  • Class E gray zone untouched pending owner decision: BILI_ENCRYPTION_KEY, ACP_UPSTREAM, ACP_PROVIDERS, ACP_DUMP_* (listed here for the ruling, not migrated).

Findings while working

  • ACP_REASONING_KEEP is owned by acp-kernel (behavioral probe: unset→reasoning preserved, none→dropped; bili passes it through). Out of scope — cross-repo; deferred, noted here rather than filed per loop-guard.
  • tests/fix-437-idle-timeout.test.ts "healthy stream longer than timeout" failed 1× in local full-suite runs; solo A/B: fails 1/10 on pristine master too → pre-existing event-loop timing race (>500ms between 100ms chunks under load), not this PR (the diff touches none of its timer logic). CI is arbiter.

Pre-flight

  • npm run typecheck ✅ · npm run build ✅
  • Full suite: 3326 pass / 1 fail (the pre-existing fix-437 flake above) / 17 gated skips
  • E2E zero-token preflight (E2E_CHECK=1) ✅; full local codex e2e fails identically on pristine master in this sandbox (environment limitation, verified A/B) → relying on ci-e2e.yml, which auto-runs (touches pipeline hot files).
  • Diff vs origin/master: 100 files, +1804/−1148 — src/, tests/, CONFIGURATION.md (+zh) only. No version bump, no lockfile churn.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-30_env-surface-retirement-p1 (9da722b)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1670-pr.1716.4669049

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(#1714): retire BILI_STREAM_STALL_MS env knob — file-only streamStallMs config + 5s floor clamp refactor(#1714): retire all BILI_*/ACP_* behavior env vars to config.json Sep 30, 2026
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.

配置面收敛:移除全部 BILI_*/ACP_* 行为类环境变量,统一迁入 config.json

1 participant