Repository navigation
fix(config): refuse unknown keys on config set --local - #21794
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The PR moves the existing key check so both Notes
[DESIGN-REVIEWED] fcadeef Description read[DESCRIPTION-READ] f676ffd31113570c543a470a007360202e804fd227a434f961499c7cbc0b60a9 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix reuses the existing key check and Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: a user pinning a setting with
[FIRST-PRINCIPLES-REVIEWED] fcadeef Description read[DESCRIPTION-READ] 01315b7b475d1bf02ee0553d5aac782051357af4e084847b3418d31e4ae5f58d That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
c374cbc to
d3f8a98
Compare
d3f8a98 to
8ec4780
Compare
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
|
|
8ec4780 to
f4be1d8
Compare
|
|
self-added: yes
|
|
|
c58e5a0 to
9759851
Compare
9759851 to
b031427
Compare
b031427 to
5d1a6e7
Compare
|
|
|
/ai-review override gpt 5d1a6e7: agent: span 2057aee8f94a matches plain config set's refusal on main and is the owner-ruled option A tradeoff (registry fix deferred), not a defect in this PR's goal; rebuttal in issuecomment-6314941152. |
Human judgment recorded@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
Review-ready at
No merge, approval or auto-merge from this side. |
5d1a6e7 to
fcadeef
Compare
|
Review-ready at
No merge, approval or auto-merge from this side. |
buluoray
left a comment
There was a problem hiding this comment.
Reviewed at fcadeef.
Approve. On main, config set --local only warned about an unknown top-level section and wrote any leaf into config.local.json, which outranks config.json, so a key nothing reads looked pinned. The existing key check now runs for both destinations before any write (cli_config.py:306), after the enum, beacon and tailnet gates, with the same Unknown key text and exit 1 that plain config set already used.
Confirmed from the CLI against temporary homes: on the merge base, set --local memory.enabled false, bogus.x 2 and agents.nobody.model m all write; on this head all three exit 1 with Unknown key, while set --local agent.log_level debug still stores DEBUG. An overlay that already holds unknown keys still loads, and config get and set --local of a real key keep working; the loader is unchanged. The slack keys that to_dict writes from outside the section are accepted on --local and their values are checked: a wrong type and an activation outside the selectable values are both refused.
Ran test_config_overlay, test_cli_config_set_lists and test_cli_config_defaults (147 passed). Mutations: running the check only on plain set, dropping the overlay flag, skipping the value check, skipping the activation check, skipping the type check, and applying the exemption to plain set each turn a test red. There is no MCP config-set tool and the dashboard PATCH already refuses unknown keys, so there is no parity gap. The spec change is in the same commit.
Follow-up, not blocking: the loader keeps unknown keys on round-trip, so a key that is already stored counts as held. An overlay pinned with memory.enabled before this fix still accepts set --local memory.enabled true, and the same holds for any stale unknown key on plain set. A note in config.md, or a check against the schema rather than the loaded document for keys that only the round-trip preserves, would close it.
Problem / Motivation
Goal:
kirocrew config set --localrefuses a key nothing reads, the same way plainkirocrew config setalready does, so a pinned setting cannot silently do nothing.kirocrew config set --local memory.enabled falseprints✅ memory.enabled = false (saved to config.local.json)and exits 0. No code readsmemory.enabled, so the setting has no effect. The same command without--localanswers❌ Unknown key: memory.enabledand exits 1. The--localpath only warned when the top-level section was unknown (bogus.key), and wrote the key anyway.Why it matters
config.local.jsonis the overlay that wins overconfig.json, so a user reaches for--localexactly when they want a setting to stick. A typo or a guessed key there looks pinned, prints a success line, and changes nothing. The issue reporter hit this withmemory.enabledwhile trying to turn off memory injection; the real keys arememory.inject_memoryandmemory.inject_lessons.Not a goal
config setaccepts. Its key check is unchanged; this PR moves it so both paths run it.config.local.json.What changed (motivation → approach → change)
Symptom:
config set --localstores any dotted key. Cause: the key check (_dict_seton the loaded config, then_declared_entryplus the first-write type check) lived only in the non-local branch, after the local/base split. Change: that check moves unchanged into_refuse_unknown_keyincli_config.py, called once before the split, so--localrefuses the keys plainconfig setrefuses, with the same❌ Unknown key: <key>and exit 1, writing nothing. On--localonly, the check also accepts a keyto_dict()writes from outside its section (_SECTION_KEYS_EMITTED_ELSEWHEREinconfig/resolution.py, such asslack.dm_activation), because the loader reads it there even when the loaded document omits it. Its value is still checked: against the registry row for the field it comes from (slack_dm_activation,observe_max_messages,slack.trusted_bot_ids), and forslack.dm_activationagainst the activation modes, using the loader's own_validate_activation. The old section-only warning is removed, since the check covers it. Keys the loaded config already holds still work on--local, including an edition section stored only inconfig.jsonor only inconfig.local.json. The config and cli specs describe the check and that extra--localset.Backwards compatibility
Breaking:
config set --local <key>now exits 1 for any key plainconfig setrefuses (a key the loaded config does not hold and the schema does not declare); before, it wrote the key with at most a warning. That includes keys the loader does read but the check cannot see: a field of a map member that is not stored yet (agent.role_models.subagenton an empty map,agents.<new>.model) and per-channel keys underslack.channels.<id>. The slack keysto_dict()writes from outside the section (slack.dm_activation,slack.observe_max_messages, ...) stay accepted on--local. Plainconfig setis unchanged. Writer sweep on origin/main @ 7bc2f37: no code insrc/,scripts/,website/src/or.github/runskirocrew config set --local; the other"--local"argv hits aregit clone --localandgit config --local. The documented examples all name keys the check accepts:agent.log_level(docs/system-specs/modules/config.md),agent.model(src/kiro_crew/docs/configuration.md),dashboard.tailscale.enabled(cli_commands.pymessage),agents.<name>.modelfor an existing crewmate (crewmate_prune_migration.py,crew-mode.md), andregistries(cli_commands.pycomment).Known follow-up (not in this PR): the schema registry declares no member names for fixed-member maps (
agent.role_models) and spells the per-channel slack keys by dataclass field name (slack_channels.*), so the shared check refuses newagent.role_models.<role>andslack.channels.<id>.*leaves on both paths. Teaching the registry those names would let both paths accept them.Known gap (not in this PR): #22755.
config set --local <section> '<object>'replaces the whole overlay section and drops the keys it already held. That write behaviour is the same on main and is unchanged here.Reader: src/kiro_crew/config/loader_pipeline.py:load -- chat|cron|subagent|app|crew page|release -- it reads
config.local.jsonas before; unknown keys already on disk are still merged and preserved (_extra_keys/_extra_sections), only new CLI writes of unknown keys are refused.Reader: src/kiro_crew/crewmate_prune_migration.py:overlay agents check -- release -- reads
agents.<name>from the overlay;config set --local agents.<name>.modelstill writes for a crewmate that exists, andconfig set --local agents '{"<name>": {...}}'works for a new one.Reader: test/test_config_overlay.py::TestCliConfigSetLocal -- release -- the overlay tests now write
agent.streaming, a real key, in place of the unreadagent.yolo.Tests
test/test_config_overlay.py::TestCliConfigSetLocal:test_local_set_unknown_key_refused[bogus.key]and[memory.enabled]: an unknown section and an unknown leaf in a known section each exit 1 withUnknown key, and an existingconfig.local.jsonstays byte-for-byte unchanged.test_local_set_refuses_what_plain_set_refuses[...]:agent.role_models.subagent,agent.role_models.subagnet,agents.newname.model,telegram.accounts.b1.bot_token,agent.apps_trusted.fooandregistries.foo.nameexit 1 on--localwith nothing written, as they do on plainconfig set.test_local_set_emitted_elsewhere_key_keeps_overlay_siblings: with the overlay holdingslack.open_channels,config set --local slack.dm_activation mentionwrites the leaf, keepsopen_channels, and the loader readsdm_activationasmention.test_plain_set_emitted_elsewhere_key_still_refused: plainconfig set slack.dm_activation mentionstill exits 1 withUnknown key.test_local_set_emitted_elsewhere_bad_value_refused[...]:slack.dm_activation bogus,slack.dm_activation 5andslack.observe_max_messages lotsexit 1 on--localwith nothing written.test_local_set_real_memory_toggle_still_written:memory.inject_lessons falsestill lands inconfig.local.json.test_local_set_with_corrupt_base_writes_overlay_only: a malformedconfig.jsondoes not block--localand stays byte-for-byte unchanged.agent.streaming, becauseagent.yolois not a config key and is now refused.Determinism:
TestCliConfigSetLocalpassed 20/20 runs at-n0and 10/10 at-n 4 --dist loadgroupbesidetest/test_cli_config_set_lists.pyandtest/test_cli_config_defaults.py; all 64 ids oftest/test_config_overlay.pypassed in a shuffled order (seed 11483).prove.pyreports PROVEN: reverting the production change turns the new tests red.Manual verification
On a scratch
KIROCREW_HOME:kirocrew config set --local memory.enabled falseprints❌ Unknown key: memory.enabled, exits 1, and leavesconfig.local.jsonas it was.kirocrew config set --local agent.streaming falseover a corruptconfig.local.jsonstill resets it and writes{"agent": {"streaming": false}}.{"foo": {"bar": 1}}inconfig.json, or only inconfig.local.json(an edition section),config set --local foo.bar 3still writes.Related Issues
Part of #9909
Pattern harvest
Not generalizable: the one other
config setdestination (--file) installs a whole document rather than a dotted key, so there is no second per-key write path that could skip this check.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)