Repository navigation
refactor(#1714): retire all BILI_*/ACP_* behavior env vars to config.json - #1747
ranxianglei wants to merge 4 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1728-pr.1747.7c3a66eThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1747.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Every behavior-class BILI_*/ACP_* env var (~70 names) is removed from bili's read surface and now lives only in config.json (canonical mapping + one-time boot warning in src/retired-env.ts). Transport/identity overrides, launcher IPC channels, secret material, and default-invariant test seams stay env-based by design. Also fixed on the way (disclosed per #1714 rule 4): - 24+ config.json fields were dead code in production (configure* setters never called): startServer + both live-reload paths now forward every knob from ProxyOptions, so file values actually take effect. - sessionsDir config field wired at startup + reloads (was env-only before). - -F flag: overrides.cliUpstreamProxy applied post-loadOptions instead of the retired BILI_UPSTREAM_PROXY env name (old path silently no-op'd). - attach evidence-grace / health-deadline and chain skew/recent-window knobs: env fallbacks replaced by programmatic opts/configure* setters (no new config fields — code knobs, not user surface). - BILI_STREAM_STALL_MS left out of RETIRED_ENV: master's #1715 dedicated boot warning already names it (avoid double warn).
…ICT_PORT pipe Review finding on the env-surface retirement: #1714's Class B inventory lists BILI_STRICT_PORT, but it was left readable from process.env in every proxy (server.ts port-retry opt-out, #964). It is a claude SessionStart hook -> launcher -> child pipeline var, so like BILI_MITM_DOMAINS it moves to the internal BILI_LAUNCHER_* namespace and joins the RETIRED boot-scan map — a stale 'export BILI_STRICT_PORT=1' now warns instead of silently disabling port retry on all instances (#1706 failure class). Also rebased onto current master (no file overlap with #1741).
3296c8b to
87eaff4
Compare
[bot] 🏷 Review 完成 — 可以直接合并(需人工 merge)。按规范逐项过了一遍,过程中发现并直接修掉了一处真实缺口(BILI_STRICT_PORT 漏退役),已补在分支上。 ① 原 issue(#1714)方向关:对齐。owner 指令是全量收敛,PR 打到了决策点(loadOptions/configure* 单一来源),不是症状层过滤。我核对了 master 上全部 114 个 ② 回归审查(既有行为清单):
③ 代码审查主关 + 我的直接修复:通读 100 文件 diff。发现:#1714 Class B 列了 ④ 测试有效性:330+ 断言迁移到 file-based surface,module-state knob 都有 reset 函数;本地定向跑 292/292 全过(retired-env/port-zone/cli-parseargs/launcher/fix-config-session/zero-config-routing)+ typecheck clean + 功能冒烟(stale env 全部 warn 且 file 值胜出)。新 head CI:全部 e2e lane 绿(real pi/opencode/dsh/codex zero-token、hermetic registry verdaccio)+ build-artifact + version-guard 绿;unit test 矩阵(ubuntu/windows × 22/24)在我写这条时还在跑,结果出来我再补一条确认。已知 flake ⑤ diff 整洁度:仅 src/tests/docs,无 package.json/lockfile/version 变更,单一逻辑提交 + 我一条有标注的 fix 提交。 自动合并门:不适用(config schema 变更 + refactor,必须人工 merge)。遗留:Class E 灰区 4 个名字等你拍板; 中文摘要:审查了 #1714 环境面收敛 PR——方向对齐、约 70 个行为开关全部转为 file-only 且默认值不变、发现并直接修掉 BILI_STRICT_PORT 漏退役(重命名内部管道名并纳入退役扫描)、rebase 到最新 master 后 e2e 全绿,可以合并。 |
87eaff4 to
918e905
Compare
The env->file migration pointed claude.nativePort at $XDG_CONFIG_HOME/ billion-context.json, but the app reads $XDG_CONFIG_HOME/billion-context/ billion-context.json (src/paths.ts configDir()). Unresolved nativePort made every pinned-port hook e2e launch fall back to the shared zone base 18787: the strict-port test saw "proxy started at http://127.0.0.1:18787" instead of a loud bring-up failure, four more hook e2e tests timed out on their pinned ports, and the leaked 18787 daemons collided with the unchanged tests/port-zone-live.test.ts suite under concurrent node --test.
918e905 to
72b62c8
Compare
[bot] 🏷 补一条:unit test 矩阵红了——根因已定位并修好,新 head ① 红在哪:ubuntu/windows × node 22/24 四个 unit job 全挂(旧 head
② 根因(单个 bug):env→file 迁移把 live hook-e2e 沙箱配置写错了目录——4 处( ③ 修复 + 验证:已在分支直接修掉(commit ④ 分支协调说明(重要):我审查期间(15:27)分支被重写为 ⑤ 当前状态:新 head 中文摘要:unit 矩阵红是 PR 自己的 test harness bug(沙箱配置写高一层目录导致 pinned-port 启动全落到共享 18787 并级联打挂未改动的 port-zone-live 套件),已直接在分支修好并本地 55/55 复验,同时恢复了被并行重写丢掉的 BILI_STRICT_PORT 退役修复,rebase 到最新 master 后等新 head CI 转绿即可合并。 |
[bot] 🏷 CI 全绿,可以合并。 新 head
分支最终栈: 中文摘要:修复后新 head CI 全绿(unit 四格转绿 + e2e 全 lane),PR 已具备合并条件,请人工合并。 |
…g zonePort); preserve master's #1723 drift-warn; re-add configureMaxSessions/configureSessionsDir imports
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)src/config.ts, knobs acrossfetch-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_DOMAINSuser knob retired: the launcher→child pipe is renamed to internalBILI_LAUNCHER_MITM_DOMAINSso 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).--debug/--no-auto-update/--auto-restart-on-update/--passthrough) now set ProxyOptions directly instead of routing throughprocess.env."file"|null; dead env-source 409 branch removed; clear button always enabled (en/zh copy synced).P4 — RETIRED startup scan
src/retired-env.ts: at boot, one-time scan of the process env for all 69 retired names; each hit warns onceBILI_X is no longer read — use "<field>" in config.json. Wired intocli.ts main(). The Opencode failed to send message with error: upstream stream ended before a completion event; this turn may be incomplete #1706 incident class (staleexport BILI_STREAM_STALL_MS=400) becomes visible instead of silent.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_MSis 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:
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.FileConfigbut nothing forwarded them into the runtime (only tests called the setters) — users who set them got silently ignored values.startServer()+ both hot-reload paths insrc/server.tsnow 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.sessionsDirwiring added (startup + reloads); previously the env var was the only channel and the file field was unwired.-F/--forward-proxyfix: the flag previously wroteoverrides.BILI_UPSTREAM_PROXY; after env retirement that became a silent no-op. Now it sets a local marker applied directly afterloadOptions()in all three paths (doctor/update/start). Old: broken (post-retirement); new: works again.maxAgeDays/maxTokens/intervalMs) now honored from file (part of item 2).attachEvidenceGraceMs,attachHealthDeadlineMs, chainmaxFutureSkewMs/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.Kept seams (documented, not retired)
BILI_LAUNCHER_MITM_DOMAINS), secret inputs, test seams (ACP_TEST_*,BILI_FAKE_HOOK_CMD,BILI_EPIPE_LOG_FILE,BILI_TEST_MARKER),ACP_RENDER_NONED-seam,ACP_PORT/HOST,BILI_CONFIG_FILE.BILI_ENCRYPTION_KEY,ACP_UPSTREAM,ACP_PROVIDERS,ACP_DUMP_*(listed here for the ruling, not migrated).Findings while working
ACP_REASONING_KEEPis 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✅E2E_CHECK=1) ✅; full local codex e2e fails identically on pristine master in this sandbox (environment limitation, verified A/B) → relying onci-e2e.yml, which auto-runs (touches pipeline hot files).Replaces #1716 (closed): after rebasing onto v0.1.174, the force-push orphaned #1716's recorded head commit and GitHub refuses to reopen it (POST /pulls/1716/reopen → 404 despite the PR existing). Same branch, full scope.