Repository navigation
feat(web): configurable dsh native compaction switch (allowDshCompaction) - #2034
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2198-pr.2034.b03c3d8This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2034.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Reviewing this PR now — pulling the branch, walking the diff against current master, running targeted local tests, and checking CI. Full structured verdict (七问) in a follow-up comment. |
The #2028 change referenced bare `cfg` inside hydrateQuickConfig(), but cfg is local to loadConfig() — a ReferenceError on every config-page load, swallowed by loadConfig's catch into the failure toast, leaving the quick-settings card half-built (dsh checkbox and all later rows never rendered) and skipping the passthrough badge + upstream-state updates. Pass cfg as a parameter, same pattern as loadUpstream(cfg). Invisible to tsc because the browser bundle is a template-literal string.
[bot] 🏷 Review of PR #2034 complete — found and fixed one blocking UI regression in the process. Verdict at the bottom. Review work performed
Blocking defect found while reviewing (fixed, pushed as commit
|
[bot] 🏷 CI update — the one red cell is a pre-existing flake, now resolved The I re-ran only that job — it passed on the same commit, so CI is now fully green on Root cause of the flake (verified in code, unrelated to this PR's surface): the title-persona test in Since the fix belongs on master (the test file doesn't exist on this branch — adding it here would dump ~760 unrelated lines into this diff), I filed #2040 with the full analysis and opened one-line follow-up PR #2041 ( Nothing blocks merging this PR right now — #2041 just prevents the recurrence. Verdict from my previous comment stands: mergeable once you're ready. |
… flush (ranxianglei#2040) The title-persona test was the last reader in this file still using a raw synchronous fs.readFileSync right after turn completion. On loaded runners the tee-logger write lags the wire completion, so the snapshot misses a line that was logically already emitted — observed as a red windows-latest/Node 22 cell in PR ranxianglei#2034's CI (run 37179443315), green on re-run, green on the other three matrix cells. Use the established readLogUntil() polling helper (added by 97ff781 for exactly this race class, ranxianglei#1968). Both original assertions are unchanged and now vet the settled snapshot.
|
解决冲突 |
531a143 to
7073280
Compare
The #2028 change referenced bare `cfg` inside hydrateQuickConfig(), but cfg is local to loadConfig() — a ReferenceError on every config-page load, swallowed by loadConfig's catch into the failure toast, leaving the quick-settings card half-built (dsh checkbox and all later rows never rendered) and skipping the passthrough badge + upstream-state updates. Pass cfg as a parameter, same pattern as loadUpstream(cfg). Invisible to tsc because the browser bundle is a template-literal string.
[bot] 🏷 冲突已解决,分支已 rebase 到当前 master( 冲突点与解法(共两轮,master 在期间又进了 #2135/#2133):
验证(本地定向,全量交 CI):typecheck 干净;定向套件 64/64 通过——issue2028、issue1815、dsh-compaction-guard、web-routing、web-i18n、named-provider-bind、config-file-cache(#2078 缓存行为)、knobs-config-precedence、preflight-stream-summary-config(#2133,确认 rebase 未伤及)。对 master 的最终 diff 恰好是本 PR 自己的 11 个文件(+454/−17),无夹带。 CI 跑完前结论不变:可合并。 |
[bot] 🏷 Rebase 后首轮 CI 里新发现一个失败: 原因:该门禁不读 markdown,而是把 src/ 实际读取的 env 变量名和 修复(已推,新 head 等这轮 CI 结果。 |
…ion) (#2028) The #1729 wire guard refuses dsh native compaction envelopes unconditionally; users who deliberately want dsh's built-in auto-compaction to run through bili had no control over that refusal (and on web profiles no patch layer reaches the preset-nested compaction-basic instance at all, #1772). Add the owner-requested web-config toggle: - config field allowDshCompaction (default false = guard stays active, current behavior unchanged) + env BILI_ALLOW_DSH_COMPACTION (env wins); - web UI quick-settings checkbox with an irreversibility warning note and an env-forced disabled state (mirrors the passthrough row); - GET /__bili/config exposes {enabled, source}; PUT accepts partial {allowDshCompaction: true|false|null} and whole-file saves, with a 409 when the write contradicts the env-forced value (symmetric, stricter than the passthrough precedent); hot-reload via the existing onChanged path logs the flip; - refusal message now points at the real opt-in instead of the nonexistent 'standard-bili-auto-off' preset (stale reference fixed in passing); - docs: CONFIGURATION.md en/zh; regression suite pins the resolution matrix, the API contract, and the live refuse->forward->refuse flip.
The #2028 change referenced bare `cfg` inside hydrateQuickConfig(), but cfg is local to loadConfig() — a ReferenceError on every config-page load, swallowed by loadConfig's catch into the failure toast, leaving the quick-settings card half-built (dsh checkbox and all later rows never rendered) and skipping the passthrough badge + upstream-state updates. Pass cfg as a parameter, same pattern as loadUpstream(cfg). Invisible to tsc because the browser bundle is a template-literal string.
…ion (#2028) The switch field never shipped in any release, so both surfaces move cleanly: - file key: top-level "allowDshCompaction" -> "dsh": { "allowDshCompaction": true } (DshFileSettings section for future dsh keys); bare legacy values are auto-relocated on load AND on whole-file save instead of being dropped silently (normalizeLegacyAllowDshCompaction); non-boolean values stay in place so the unknown-top-level-key warning still names them. - structured PUT now takes { dsh: { allowDshCompaction: true|null } }; the GET resolved view ({ enabled, source }) and env BILI_ALLOW_DSH_COMPACTION semantics are unchanged.
4692790 to
10a1c46
Compare
[bot] 🏷 收工:CI 全绿,PR 已可合并。
合并动作留给你(规则上我不能合 PR)。之前 review 结论不变:功能实现正确、测试有牙、行为变更已在 PR 描述里披露,可以合并。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.38-master.25d358c # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2028 (context: #1772, mechanism: #1729)
What
The owner-requested web-config toggle for dsh's built-in auto-compaction: a checkbox on the bili config page that lifts/restores the #1729 wire-level refusal of dsh native compaction envelopes, hot, per proxy instance.
Default OFF = today's behavior (guard active). Enabled = dsh native compaction calls are forwarded and may land.
Config surface (owner-gated discipline)
Explicit owner sign-off in the issue threads: #2028 OP and #2001 floor 10 ("我要的是 一个在bili配置界面允许点击关闭dsh压缩的功能").
New surface:
allowDshCompaction(top-level boolean)BILI_ALLOW_DSH_COMPACTION"0"forces off, any other value forces on; wins over the fileWhy the existing surface cannot express it: the refusal lives in bili's request pipeline (
src/server/dsh-compaction-guard.ts, wired unconditionally insrc/server.ts) and no existing switch touches it. The dsh-side alternative (restating the wholepreset-standardplugins block in the profilecordis.patch.ymlwithauto:false, ~140 lines, #1772) is a drifting snapshot, needs a dsh restart, covers one profile at a time, and still would not lift the bili-side refusal — it cannot serve as this control. Considered and rejected: reusingpassthrough(whole-request scope, different failure modes); a providers-table entry (compaction-basic is not a provider).Compat/migration: purely additive, opt-in. Existing configs behave identically (default OFF = current refusal).
GET /__bili/configgainsallowDshCompaction: {enabled, source};PUTaccepts partial{allowDshCompaction: true|false|null}or whole-file saves. Hot-reload through the existingonChangedpath (no restart); flips log warn/info.Behavior changes (old -> new)
Disable dsh auto-compaction (bili preset 'standard-bili-auto-off') or remove the co-resident dsh compaction plugin.-> newTo run dsh native compaction on this lane anyway, opt in explicitly: "allowDshCompaction": true in the bili config (web UI) or env BILI_ALLOW_DSH_COMPACTION=1 (#2028).Reason: the referenced preset does not exist anywhere in the codebase — stale reference found while wiring the real control.auto:falsestill suppresses AUTO-triggering — only manual /compact benefits there; on web profiles auto-triggering works as-is (no patch layer reaches the preset-nested instance,dsh.bundle.patch.yml禁用自动压缩在 web profile 下静默失效 #1772). A landed checkpoint durably shadows the raw history (irreversible) and destroys bili's compression substrate for that session — hence opt-in with a warning, not a silent flip.Passing fix (separate labeled commit)
KNOWN_TOP_LEVEL_KEYSwas missing three real FileConfig fields —releaseNotesCheck/releaseNotesUrl(#1870) andimageTokenCap(#1843) — so config files carrying them logged a false "ignoring unknown top-level config key(s)" warning. Added to the mirror set and to the documented-surface test.Tests
tests/issue2028-dsh-compaction-toggle.test.ts(new): resolution matrix (file/env/default OFF), state-source triad, refusal-message pin, and a full integration flip through a real server + mock upstream — default 403 -> live PUT enable -> forwarded byte-exact (200, observed at the upstream) -> clear -> 403 again — plus 400 validation and env-forced 409s in both directions.tests/issue1815-unknown-top-level-keys.test.ts: documented surface extended with the four keys.