Repository navigation
fix(#1815): warn on unknown top-level config keys with compress-placement hint - #1817
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1798-pr.1817.a44db96This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1817.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review started — 方向审核通过(修复打在 Stale base → 误报回归:PR base 是 处理中:rebase 到当前 master + 把 |
4c0526d to
42fb56d
Compare
[bot] 🏷 Review 完成 — 已修好可直接合并。 分支已 rebase 到当前 master( 评审中发现并直接修掉的问题(2 处):
既有行为清点(回归审查结论:无回归):
测试有效性:4 个测试断言有牙——精确计数(两次加载恰好一条 warn)、消息内容逐字匹配、走真实 diff 整洁度:单 commit,仅 验证(rebased head 结构化七问:
行为变更披露(旧→新):旧 = 顶层未知/错位 key 零日志静默丢弃;新 = 每进程每个不同未知 key 集合一条 warn。仅日志层面,key 仍照旧被忽略,此前能正常工作的配置零影响。 小注:PR 描述里的「31-key」与 pre-flight 数字(3248 tests)是原 base 时的口径;rebase 后实际为 34-key 表面、3480 tests(以本条为准)。Scope note 维持原判:深层 silent-drop(compress 块内/provider route entry 内)同根因未拆 issue,是否下沉一级由你定。 判定:可合并(合并操作留给你)。 |
What & why
loadConfigFile()(src/config.ts) casts the parsed JSON straight toFileConfig— TypeScript types are erased at runtime, so any top-level key the loader does not consume was dropped with zero feedback. The issue's repro (root-level"promptPack") is exactly that: the user's intent vanished silently, violating the §7.3 "never silently clobber or drop user config" rule.The fix adds runtime key validation at the single chokepoint every file-based config read passes through (
loadConfigFile, used byloadOptions/loadRoutes/all resolvers):seenAbsorbDivergenceWarnings): repeated config reads within one startup don't spam; if the user fixes some keys while running, the new remainder re-warns.compressfield gets a targeted hint — this covers the whole misplaced-compress-key class named in the issue (promptPack,nudgeGrowthTokens, …), not justpromptPack.Example log line (the issue's exact repro):
Behavior change (explicit)
Config surface
None. No config field, env var, or CLI flag added/renamed/re-semantics'd — this change only adds a diagnostic log for existing invalid input.
Scope note
Top-level only, per the issue's suggested fix. Deeper levels (
compressblock typos, provider route-entry typos) have the same silent-drop class; left as-is here to keep the diff scoped. Same root cause, so no separate issue filed — owner decides whether a follow-up wants the same treatment one level down.Tests
New
tests/issue1815-unknown-top-level-keys.test.ts(4 tests):BILI_CONFIG_FILE+loadRoutes()): exactly one warn across two loads, known keys never flagged, routes parse identically;Pre-flight
npm run typecheck— cleannpm test— 3248 tests, 3236 pass, 0 fail, 12 skipped (all env-conditional pre-existing skips, e.g. live-E2E gates / non-loopback-address checks; the new file has none)npm run build— successFixes #1815