Repository navigation
fix: backport #27535 and #32804 to 0.12.1 (keep an unreadable agent spec) - #32758
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check: the change is backend-only. The only new text people see is one CLI line, and it says what happened and what to do next. Notes
[UX-REVIEWED] d134ab3 Description read[DESCRIPTION-READ] d02cf43f7b721db85169d4ee521c39b7926a10302627489f96fd6fcaec96d85f That sha256 names everything this verdict read: the PR description, plus the 6 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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a clean backport of two fixes already merged on main. A present spec that cannot be read is now kept and the rebuild cycle is skipped, which is the safer direction, and the only conflict was hand-resolved to match main byte for byte. Notes
[DESIGN-REVIEWED] d134ab3 Description read[DESCRIPTION-READ] 0bd532610aacee70beaec5ab5092bd4445f4458305b29a9e3039ea961370af81 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 This is a backport of two fixes already merged on What this change shipsInventory (10 items) — 10 justifiedIntent: stop a 0.12.x rebuild from writing defaults over a valid
[FIRST-PRINCIPLES-REVIEWED] d134ab3 Description read[DESCRIPTION-READ] 62ddb4a95b61b644b55d1125b56c42142a0a22f9b26e0651d51f0b29f5bd71e3 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 findings (all downgraded on adjudication)GPT 6.1 flagged blocking issues on This comment is updated in place on each push. Review detailsBLOCKING -- src/kiro_crew/agent_parts/spec_unreadable.py:166 -- Invalidate the sibling cache when configuration changes
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 is downgraded: it no longer blocks the merge. F1: Harm is LOW. The failure needs two things at once:
Recovery: while the episode is open, Remedy cost: the real fix makes the skip key track every config input the sibling installers read, not only the generation. That is a new invariant that every future installer input would have to keep, added to an episode cache that is already complex. That cost exceeds a stale cheap-model pin on a rare fault path that recovers by itself. False positive or not applicable? A repository writer can comment: |
…7535) * fix(agent): keep an unreadable agent spec instead of resetting it rebuild_agent_config read kirocrew.json with a plain read_text and treated every OSError like a corrupt file, so a transient read failure on a present, valid spec (a Windows sharing violation while another writer replaces it, a permission or I/O error) rewrote the user's spec with defaults. Every read of the main spec on the rebuild path goes through read_bytes_with_retry, and only FileNotFoundError means absent. Any other OSError raises _AgentSpecUnreadable, from the load or from the alias reconcile inside the write lock (mcp_aliases._durable_tool_aliases reports such a file as present). _skip_unreadable_main_spec then leaves kirocrew.json and the heartbeat and worker specs mirrored from it untouched, and still runs the steps that write other files (_install_sibling_specs), so the fork refresh and conductor specs follow a moved ceiling. That sibling pass runs on the first skip of an episode and again only when the governance generation moves since the last pass that held no write. The skip is reported as an unwritten, held rebuild, which the existing retry paths act on, and kirocrew setup, the dashboard and the config watcher say the spec was left unchanged. Until a rebuild writes the spec again, require_fork_governance refuses the main agent and its two mirrors, keyed on the spec FILE a start resolves to, with the remedy in the message, one SEL denial per refusal and an early retry at 5, 15 and 60 s (then every 60 s). Neither can run its projected spec during the episode: a fresh kiro-cli that cannot read the file starts its own default agent, and a running one keeps the copy it loaded, because kiro-cli reloads a spec only when its content changes (probed on Linux, kiro-cli 2.31 to 2.33). While the episode is open every start is refused, another agent's included, one SEL denial each, with no exemption for a project spec or a view's source: a start with no prepared view, or on KAS, hands kiro-cli (or Crew's own read by name) a bare name that cannot be pinned to a file, a rename of the main agent after the last rebuild write cannot be learned from an unreadable file, a link or a retarget can put the kept file under any name, and kiro-cli keeps serving a spec it loaded after the file turns unreadable, so a doubt refuses. The native skill projection refuses a view read across an episode, whatever file it was read from, and a launch on a view records its source: a session open or switch on a view is refused while an episode is open. An app agent's launch copy is checked as a bare name is, at its spawn and at every open and switch on it. Every session/new and session/load on the shared runtime goes through _send_session_open, and every set_mode frame on kiro-cli through check_mode_frame; each is checked right before its send, since the frame activates an agent the process already holds. create_session and load_session also check before their setup, so a refused create takes no start permit. A mid-session switch reads the modeId its send will carry with the projection's pure lookup, so a refused switch writes one SEL denial. Once a rebuild closes the episode every start is admitted again, a view built before it included, and no process is ended. Only a spec read before the episode ended stays refused: a KAS payload read by name across it, or an agent the projection read during it. refuse_unprojected_main_spec_start says so in the message and in the SEL row's cause and remedy: a new start reads it again. While an episode is open, a name other than the main spec's own that is refused by name is told it is resolved by name and the unreadable spec may declare it; a refused view is not. The episode lives in its own agent_parts owner, spec_unreadable; the rebuild's part stays in spec_rebuild, and the two classes owners may not define stay on the agent facade. A missing file, a read that returns invalid UTF-8 or JSON, and a clean rebuild still write defaults. Closes #15515 * fix(agent): drop the unreadable-spec start refusals per security sign-off Per the maintainer's security sign-off on #27535, this PR no longer raises security strictness. It keeps only the data-loss fix: an unreadable kirocrew.json, and the worker and heartbeat specs mirrored from it, are kept instead of being overwritten with defaults. Dropped, with their tests: - require_main_spec_projected in require_fork_governance - require_main_spec_launch_bound and every caller (direct-client spawn and _send_request, shared-runtime spawn, _require_launch_bound_for_session_open, the KAS by-name read and the pre-send payload check) - the set_mode checks in runtime_mode_activation.py and check_mode_frame - the projection's main_spec_refused path - the runtime_wire session/new and session/load ValueErrors - the early-retry timer and its gateway start and shutdown hooks The acp/ package and the gateway hooks are back to main. While the file is unreadable, starts are decided as on main; a test pins that the open episode changes no start decision. The skip stays a held rebuild, so the hourly maintenance wake still rewrites the kept spec once it reads. Main's enforcement of a tightened ceiling on the worker and heartbeat specs is kept: while the main spec cannot be read, their existing allowedTools and autoApprove are re-filtered through the current ceiling in place (_refilter_kept_mirrors), with no server copied in and no grant added. A re-filter that fails holds the memo. _install_sibling_specs and the re-filter live in the new agent_parts/spec_siblings.py, which brings spec_rebuild.py back under 1,600 lines. (cherry picked from commit 4883d3b) Original author: Will Laws (#27535). Hand-resolved for release: release already carries #31620's record_rebuild_drops block after write_default_spec, which git placed after the new early return. It is moved into the try, after write_default_spec, as on main.
9fc59ce to
67f9a56
Compare
With kirocrew.json unreadable, the rebuild skips and runs the sibling pass (service, conductor and fork specs) once per governance generation. A pass that held a sibling write (a second unreadable spec, a held conductor) never recorded its generation, so while a default model change was pending the config watcher's 2-second retry re-ran the whole pass on every tick, rewriting every sibling spec each time. A held pass now records its generation and the time it ran, and runs again under the same generation only after HELD_SIBLING_PASS_RETRY_SECS (30 min), which the hourly maintenance wake always reaches. A pass that raised, or a deferred boot refresh, still records nothing. (cherry picked from commit 217b335)
Problem / Motivation
Goal: Bring #27535 (a rebuild that cannot read an existing
kirocrew.jsonkeeps the user's spec instead of writing defaults over it) frommainontorelease/0.12.0, with itsmainfollow-up #32804, one commit each, in a PR of their own.Why it matters
Ray picked it for 0.12.1 (11-07). Reported by jeeshofone on the main PR. On 0.12.0 a valid spec whose read fails for a moment is rewritten with defaults, which silently and permanently erases its MCP servers, approvals, model pin and prompt (1 in 39 rebuilds in #15515's harness).
The faulty line is on
release/0.12.0@7ea28ed960:src/kiro_crew/agent_parts/spec_upgrades.py:83except (OSError, ValueError):returnsbuild_agent_config(...)as a fresh install for a read error as well as for corrupt JSON.Not a goal
main; nothing is changed only here.CHANGELOG.mdchange.What changed (motivation → approach → change)
Main squash commit
4883d3b5bfwas cherry-picked with-xontorelease/0.12.0@7ea28ed960as67f9a5639f, with no prerequisite. Thedocs/system-specs/modules/governance.mdupdate ships with it.One hunk is hand-resolved. Git applied the pick without a conflict, but release already carries #31620's
mcp_dropped_servers.record_rebuild_drops(...)block right afterwrite_default_spec(...)inagent_parts/spec_rebuild.py, and git left that block after the pick's new earlyreturn _skip_unreadable_main_spec(...), where it could never run. The block is moved into thetry, right afterwrite_default_spec(...), so the region fromunreadable: _AgentSpecUnreadable | None = Nonetologger.info("Installed agent config: ...")is byte-identical toorigin/main.test_mcp_dropped_servers.pyfails 2 of 6 without the move and passes 6 of 6 with it. Every other file has added and removed lines identical to the main commit.The hand-resolved commit is authored with the public identity and names its original author (Will Laws) in the message.
#32804 (
217b3350c3, release commitd134ab390b) is themainfix for the finding Opus 5.5 raised on this PR's earlier head (agent_parts/spec_unreadable.py:152): when the main spec and a sibling spec are both unreadable, the skip never recorded its generation, so a pending default-model change re-ran the whole sibling pass on every 2 s config-watcher tick. It picked cleanly and is identical tomain(+173/-23, 6 files, 126 of them intest_agent_unreadable_main_spec.py).After the pick no touched code file is over the line cap (
agent.py1,674,spec_rebuild.py1,282).builder-security checked:
dashboard/server_runtime/config_watch.pyand_shared_config_followups.pyonly handle the new "unreadable, skipped" result of a rebuild; no bind, listener, route, auth mechanism or storage grant changes.Backwards compatibility
Compatible: a missing or corrupt spec is rebuilt as before; only a present-but-unreadable spec now survives.
Removes nothing: no setting, key or caller is removed.
Tests
Proof: not provable -- other: a backport of a main commit whose proof ran on its own PR
release/*, so the related set was run here: every touched test file (includingtest/integration/test_boot_smoke.py) plus every test file that imports a touched module, 123 files includingtest_mcp_dropped_servers.py,-n 4 --dist loadgroup. 5021 passed, 26 skipped, 1 failed:test_acp_harness_contract.py::test_a_missing_self_served_binary_names_its_install_command[copilot], which fails the same way on a cleanrelease/0.12.0. The PR's owntest_agent_unreadable_main_spec.pyandtest_agent_spec_hold_ratchet.pypass.test_agent_unreadable_main_spec.pyandtest_mcp_dropped_servers.py, 111 files, 4792 passed, 9 skipped, 1 failed (the sametest_acp_harness_contract.py::...[copilot]release failure).Manual verification
N/A - verified on its own main PR. The 0.12.1 RC soak is the end-to-end check.
Screenshots / video
N/A - no frontend file changes.
Related Issues
Backport to the 0.12 line for 0.12.1 of #27535 and #32804.
Sibling sweep
Siblings: none -- the source PR carried its own sibling sweep; this PR only carries that fix.
Pattern harvest
Not generalizable: this PR only carries a fix already on
main. The source PR has its own harvest.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.