Repository navigation
fix(config): render the adoption ledger and stop the degraded-load re-read - #11176
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the fix-without-restart path: the new degraded test simulates restart via Suggestions
[DESIGN-REVIEWED] 443b5cd |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
Opus 4.8 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: |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS
Not justified as shipped
What this change shipsInventory (10 items) — 8 justifiedIntent: give operators an on-demand answer to "what did the upgrade auto-remove from my config and how do I restore it", and stop degraded loads from defeating the config cache — a FIX (follow-ups recorded on linked issue #10082).
[FIRST-PRINCIPLES-REVIEWED] 443b5cd |
f3c50f4 to
1c656c5
Compare
1c656c5 to
4c1bcf9
Compare
…-read (#10082) The operator-visible WARNING for an auto-adopted superseded default landed in #10367; this closes the remaining follow-ups recorded on #10082: - `kirocrew doctor` and a bare `kirocrew config defaults` now render the sidecar's `adopted` map (key, removed value, exact restore command) through a shared `adoption_summary`, so `adopted_superseded()` has its non-test caller and the `doctor` line `record_adoptions` promises exists. - The degraded-sections branch no longer drops the validated-data cache: its retry condition is "fix the file", and fixing the file misses the cache by fingerprint, so the invalidation only re-read and re-parsed config.json on every load while a malformed section coexisted with a stale timeout. - Three comments describing the removed ledger-rollback scheme are rewritten to match `record_adoptions` (marker first, nothing rolled back). - config.md states the downgrade residual (a pre-ledger build's `--keep` / `--adopt` rewrites the sidecar without `adopted`, re-arming the one-shot). - Two duplicate tests deleted (one an unguarded copy of a POSIX-only symlink test), and the loader-source-text test rewritten to pin behaviour. Closes #10082
4c1bcf9 to
443b5cd
Compare
…-read (kirodotdev#10082) (kirodotdev#11176) The operator-visible WARNING for an auto-adopted superseded default landed in kirodotdev#10367; this closes the remaining follow-ups recorded on kirodotdev#10082: - `kirocrew doctor` and a bare `kirocrew config defaults` now render the sidecar's `adopted` map (key, removed value, exact restore command) through a shared `adoption_summary`, so `adopted_superseded()` has its non-test caller and the `doctor` line `record_adoptions` promises exists. - The degraded-sections branch no longer drops the validated-data cache: its retry condition is "fix the file", and fixing the file misses the cache by fingerprint, so the invalidation only re-read and re-parsed config.json on every load while a malformed section coexisted with a stale timeout. - Three comments describing the removed ledger-rollback scheme are rewritten to match `record_adoptions` (marker first, nothing rolled back). - config.md states the downgrade residual (a pre-ledger build's `--keep` / `--adopt` rewrites the sidecar without `adopted`, re-arming the one-shot). - Two duplicate tests deleted (one an unguarded copy of a POSIX-only symlink test), and the loader-source-text test rewritten to pin behaviour. Closes kirodotdev#10082
What
Closes the follow-ups recorded on #10082 after #9659 merged. The blocking-class item there (the adoption notice logged below the default level) was already fixed by #10367; this PR takes the rest:
kirocrew doctor(Stored Defaults) and a barekirocrew config defaultsnow list what auto-adoption removed: oneadopted:line per key with the removed value and the exactkirocrew config set <key> <old>restore command, rendered through a new sharedadoption_summary().adopted_superseded()gains its non-test caller and thedoctorlinerecord_adoptionspromises now exists._load_resolvedno longer drops the validated-data cache. Its retry condition is "the operator fixes the file", not "the next load", so the invalidation only forced a re-read and re-parse ofconfig.jsonon everyload()for as long as a malformed section coexisted with a stored stale timeout. Fixing the file changes its fingerprint, which misses the cache and retries the adoption on that load with no invalidation._apply_document_migrationsbullet 3,_persist_config_migration,adopted_supersededdocstring) are rewritten to match whatrecord_adoptionsactually does (marker first, nothing rolled back, only landed removals confirmed in memory).config.mdstates the downgrade residual: a pre-ledger build's--keep/--adoptserializes{"acked": ...}only, so a downgrade-then-write re-arms the one-shot on the next upgrade.test_a_non_plain_leaf_is_still_replaced_rather_than_refused(unguarded duplicate of the POSIX-only symlink test) andtest_every_adopting_key_clears_in_one_load(duplicate oftest_both_timeout_keys_adopt_in_one_load) are deleted.test_the_loader_has_no_second_spelling_of_the_stored_value_lookupno longer assertsinspect.getsourcetext or the absence of a retired name; it pins the behaviour (the ledger entry the loader records equals the exported lookup's answer).Why
An automatic rewrite of an operator-owned file was announced by one WARNING line in one gateway log and then nowhere else -- an operator asking "what did the upgrade change in my config" a week later had no surface to ask. The degraded-branch invalidation defeated the config cache for the whole life of a process on exactly the installs that already had a broken file. The stale comments contradicted
record_adoptionsandconfig.md, and the two duplicate tests cost a non-admin Windows dev box a red run.How
superseded_defaults.py:adoption_summary(dotted_key, removed)treats both fields as untrusted (the sidecar is a file the agent sandbox can write): every character is rendered terminal-safe (control characters escaped viastr.isprintable, same approach assnapshot._terminal_safe), and the pasteable restore command is built ONLY fromSUPERSEDED_DEFAULTSliterals after matching the entry by key and exact value -- no quoting scheme is portable across every shell an operator might paste into (POSIX quoting leavescmd.exemetacharacters live), so an entry the registry does not vouch for is shown escaped with no command. It says "removed from config.json", not "the default applies", because the overlay may still carry the key, and notes the marker-first window (a failed config write leaves the value stored and still listed as drift).render_doctor_sectionprints the ledger BEFORE openingconfig.json, so a missing or unreadable config does not hide it.adopted_supersededdocstring corrected.cli_config.py: on a bare listing (no--adopt,--keepor named keys)_print_adopted()runs BEFOREconfig.jsonis opened, so a missing or corrupt config cannot hide the ledger. Not folded into theknownset that--adopt/--keepvalidate against -- an adopted key has no stored value to act on.loader.py:finallycondition isadopt_keys and not adoption_landed and not cfg._degraded_sections; the comment names the real retry condition (fix the file AND restart -- degradation observations are sticky for the life of a process); the two stale comments rewritten.config.md: cache paragraph now names two skip paths and the deliberate exclusion; new paragraphs on the on-demand rendering and the downgrade residual.Tests
Red on the unmodified base, green after (
python -m pytest -n0 test/test_config_superseded_defaults.py test/test_cli_config_defaults.py, 104 passed):test_a_degraded_load_keeps_its_document_cached_instead_of_re_reading_forever-- reaches the branch deterministically viapublish.allowed_destinations: "not-a-list"(the one shape the schema layer keeps and the loader then degrades); asserts the cache entry survives, a second load performs zeroconfig.jsonreads, and a fixed file retries the adoption through the fingerprint miss. Base:a degraded load must stay cached.test_doctor_lists_what_auto_adoption_removed_and_how_to_restore_it-- base: noadopted:line.test_listing_shows_what_auto_adoption_already_removed(CLI) -- base: key absent from output.test_adoption_summary_cannot_drive_the_terminal_or_offer_a_hostile_command-- an OSC 52 sequence in the key and a& calc &value reach the output as visible\\x1b/\\x07escapes with NOconfig setcommand; a registered key with an unregistered value or type gets no command either; a registry-vouched entry gets the command spelled from registry literals.test_doctor_renders_the_ledger_even_when_config_json_is_gone,test_listing_renders_the_ledger_even_without_a_config_file,test_listing_renders_the_ledger_before_a_corrupt_config_is_refused-- ledger shown with a missing and with a corruptconfig.json, on both surfaces.test_doctor_says_nothing_about_adoption_when_none_happened,test_an_adopted_key_is_not_an_adopt_or_keep_targetpin the negative space.Gates run locally:
black --checkon all six files,flake8on the four smaller ones,scripts/check_black_formatting.py(diff-scoped, post-commit),scripts/check_comment_history.py,scripts/docs_lint.py, prepare-prpreflight.pyandpush_guard.py --max-ahead 2.Other
Backend-only (CLI/doctor text and a loader condition);
no-screenshotslabel applied. Single commit.Pattern harvest
Rule candidate: config cache invalidation
Pattern: invalidate a fingerprinted cache only where the retry condition is "next load"; when the retry condition is "the file changes", the fingerprint already misses and an invalidation is pure re-parse cost.
Closes #10082