Repository navigation
fix(agent): keep an unreadable agent spec instead of resetting it - #15546
jeeshofone wants to merge 1 commit into
Conversation
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No BLOCK trigger holds: the cause of the reset is fixed at the read site, the broad start refusal is listed as Breaking, the retry caps how long it lasts, and restoring read access ends it. Notes
[DESIGN-REVIEWED] ea0fd68 Description read[DESCRIPTION-READ] 9c0ba8d4bfbb937c0e83edadd8581d5d2fd946ed1a0c57ec92b1469505c8e2e3 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the keep-the-file fix sits at mechanism level for #15515, and the start gate follows from the ceiling the kept, unre-projected spec may exceed. Notes below. Notes
What this change shipsInventory (8 items) — 6 justifiedIntent: stop a rebuild from erasing a user's agent spec it merely failed to read. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] ea0fd68 Description read[DESCRIPTION-READ] 7d9f10507511489b787cf6964f415e8479741c9a15b61f27b6d78c02ab03c977 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
|
Dispositions for head 9cb6f4a. I read each cited path on this head before replying. Holding position on the two blocking findings because resolving them needs a maintainer decision, set out below. GPT 5.6 Review, BLOCKING at
Opus 5 Review, BLOCKING at Opus 5 Review, FINDING at Opus 5 Review, FINDING at Design Review and First Principles Review passed. First Principles asked whether callers with no This PR is not ready. @bolichen97 @iamwhatever @CrysisDeu, which option do you want for the persistently unreadable spec? I will not push again until one is picked. |
9cb6f4a to
152e52a
Compare
|
Dispositions for head GPT 5.6 Review, BLOCKING at Opus 5 Review, BLOCKING at Opus 5 Review, FINDING at Opus 5 Review, FINDING at First Principles Review question (callers with no Design Review: PASS, no action. The PR description is updated to match. The local verification floor is listed there. |
152e52a to
6a5d52a
Compare
|
|
|
|
6a5d52a to
ea8f919
Compare
|
|
First Principles note, item 8 (refusing pre-episode views after the episode closes goes beyond "until a rebuild writes it again"). Kept on
First-pass check: R1-R8 OK. |
|
span=11693c34a43d: GPT 6.1 BLOCK, both findings (F1
First-pass check: R1-R8 OK. AUTOSDE rules matched: feature-map-correctness, backend-security-controls, no-blocking-call-on-event-loop, no-new-work-on-gateway-boot-path, no-test-side-effects, tests-are-deterministic, top-level-imports, harness-parity, memory-store-seam, recorded-decisions-are-not-regressions, recurring-defect-patterns, no-new-builtin-apps, no-sync-store-call-from-a-coroutine, an-async-test-respects-the-on-loop-lock, persist-before-you-publish, a-ratchet-may-only-tighten, a-stopwatch-is-not-a-barrier, prefer-subtracting-a-duplicate-mechanism, a-refusal-is-not-a-commit, an-invariant-line-needs-a-mutation-pin, a-bound-bounds-every-field-it-retains, an-operator-facing-string-states-what-was-measured, keep-modules-small. |
|
First Principles note, item 7 (refusing pre-episode views after the episode closes goes beyond "until a rebuild writes it again"; the same note as item 8 on c2f5071). Kept on
First-pass check: R1-R8 OK. |
|
Design note 1 (refusing every start during an episode is too broad for the threat; refusing the main spec, its mirrors and bare-name launches would close the
First-pass check: R1-R8 OK. |
|
Design note 2 (on Windows, one sharing violation that outlasts the read retry means one refused open on every warm runtime after the episode). Stated on
First-pass check: R1-R8 OK. |
|
Design note 3 (the gate is threaded through about 15 send and launch sites; #18860 should first collapse them to one choke point and one table of rules). Deferred to #18860 on
First-pass check: R1-R8 OK. |
|
Opus 5.5 note 1 (
First-pass check: R1-R8 OK. |
|
Opus 5.5 note 2 (during an episode,
First-pass check: R1-R8 OK. |
|
Re-checked Two things before the final re-review:
We'll re-review the rebased head. iamwhatever's change request and the split question are still for a maintainer. |
|
First Principles blocker on
First-pass check: R1-R8 OK. |
|
First Principles note on
First-pass check: R1-R8 OK. |
|
Design note on
Design note on First-pass check: R1-R8 OK. |
|
@cruisercohen, on your re-check of
Your two pins, |
|
Design note 3 on
First-pass check: R1-R8 OK. |
|
First Principles note on
First-pass check: R1-R8 OK. |
|
Design note 1 on
First-pass check: R1-R8 OK. |
|
Design note 2 on
First-pass check: R1-R8 OK. |
|
Design note 1 on
First-pass check: R1-R8 OK. |
|
Design note 2 on
First-pass check: R1-R8 OK. |
|
Design note 3 on
First-pass check: R1-R8 OK. |
|
First Principles note on
First-pass check: R1-R8 OK. |
|
First Principles note on
First-pass check: R1-R8 OK. |
|
HOLD at 9a32437 for a maintainer. What holds it:
One question for the human reviewer. Every AI lane passes, and each Design and First Principles note on this head has a reasoned reply. CI is green. To clear: cruisercohen re-reviews this head, and a maintainer reviews the start gate. — crew-pr-reviewer (r133) |
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 kirodotdev#15515
Security Scope Review (fork) — ✅ PASSWhich legitimate operations does adjudicated, zero confirmed regressions Scope-Verdict: PASS Reason: The tightening is an in-process admission gate on agent launches, session opens and TIGHTENING: a new launch/session-open bound, ADJUDICATED: 12 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix and windows. The diff adds one platform assumption: the main spec at UNADJUDICATED: The guard is the unreadable-main-spec episode gate. Call paths:
Narrowing I can argue but not confirm: by its own docstring, [SCOPE-REVIEWED] ea0fd68Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. |
|
Moved to #27535: same commits, now on a branch of this repo so CI uses the CodeBuild fleet. Review history stays here. |
Problem / Motivation
Goal: A rebuild that cannot read an existing
kirocrew.jsonkeeps the user's spec and skips that cycle instead of writing defaults over it, and until a rebuild writes it again refuses main-agent starts, and any start that cannot be shown not to load the kept file, because a running kiro-cli keeps the grants it loaded; a fresh one silently becomeskiro_default._load_existing_configcaught(OSError, ValueError)together, so a valid spec whose read failed (EACCES,EIO, sharing violation) was rewritten with defaults, erasing its MCP servers, approvals and prompt.Why it matters
Silent, permanent loss: 1 in 39 rebuilds in #15515's harness.
Not a goal
set_mode, and binding every start in any process to the verdict: Bind the started agent spec to the governance-ceiling verdict #18646.What changed (motivation → approach → change)
A read error on a present
kirocrew.jsonno longer resets it: the rebuild keeps the file and skips the cycle, and the main agent waits until a rebuild writes it again.read_bytes_with_retry. OnlyFileNotFoundErrormeans absent; any otherOSErrorraises_AgentSpecUnreadable(also from the alias reconcile inmcp_aliases.py)._skip_unreadable_main_speckeeps the spec and its mirrors, still writing sibling specs (_install_sibling_specs).wrote=Falseand a hold;cli_setup.py,_shared_config_followups.pyandconfig_watch.pysay the spec was left unchanged.require_fork_governancerefuses the main agent, heartbeat and worker, keyed on the spec FILE a name resolves to, one SEL denial per refusal, an early retry at 5, 15, 60 s then every 60 s (stopgap, #18860). Gateway shutdown cancels a pending retry (exit_path.py); a restart re-allows them (service_boot.py).chmod 000. The skill projection refuses every view read across an episode.session/new,session/loadand kiro-cliset_modeis checked right before its send (_send_session_open,check_mode_frame). A switch reads itsmodeIdthrough the puremode_id: one SEL denial per refused switch.New owner
agent_parts/spec_unreadable.pyholds the episode, composed onto theagent.pyfacade.Not in-gate recovery: #18860 owns the trigger model. Not only sharing violations: a lasting
EACCESwould run the main agent askiro_default.Backwards compatibility
Breaking: a lasting read error on
kirocrew.json(EACCES,EIO) refuses the main agent, heartbeat and worker until read access returns; base rewrote the file with defaults. During an episode every start is refused too, other agents' and project agents' included, with or without a view (≤ a minute once it reads). A Windows sharing or lock violation (winerror32/33) holds an episode likeEACCESuntil a retry reads the file. Probe (Linux, kiro-cli 2.31-2.33): a fresh process that cannot read the spec runskiro_default(exit 0); a running one keeps its cached spec throughchmod 000and reloads only on a content change, which also loads it into one started while unreadable. No Windows or macOS probe was run; safety does not rest on it: the Goal refuses any start that cannot be shown not to load the kept file, and there the doubt is larger, not smaller, so the cost is availability, bounded by the 5/15/60 s early retry and the first good read.Writer sweep on origin/main @ 3ecd50f:
_load_existing_config←rebuild_agent_config(skips);_durable_tool_aliases←write_default_spec(unreadable reads as absent, then the reconcile raises unless--clean) and_reconcile_tool_aliases_from_disk(raises);require_fork_governance←client_start._spawn,harness/kiro.py,harness/kas.py;rebuild_agent_config_reporting←retry_held_conductor_specs,_reproject_holding_the_lock,rebuild_agent_spec,config_watch(say left unchanged), and the disconnect, OAuth-client and MCP-apply handlers (already report not rewritten; MCP apply: #18679).Known gap: the gate is process-local; another process's
kiro-cli --agent kirocrewis ungated (#18646).Removes:
send_request,send_notificationandsend_request_for_answerraise onsession/newandsession/load, and the last onset_modetoo. A missing or invalid spec still rebuilds from defaults,--cleanstill writes over an unreadable file; no error code or SEL event changes.Tests
test_agent_unreadable_main_spec.py: spec kept[eacces|eio], sibling pass, the agent: a Windows sharing violation while rebuild_agent_config reads kirocrew.json rebuilds it from defaults and writes that back, erasing user edits #15515 harness (20 rebuilds), the early retry, one SEL denial per refusal.test_agent_unreadable_main_spec_gate.py: file-keyed identity, no project spec exempt (JSON, Markdown, link), a view refused only while an episode is open.test_agent_unreadable_main_spec_launch_bound.py: the renamed-main trigger on runtime and client, every bare name and view refused.test_agent_unreadable_main_spec_recovery.py: after recovery only a read that overlapped the episode is refused, saying a new start reads it again; a healthy host refuses nothing.test_native_skill_projection_view_provenance.py: a view read through a link stays refused during the episode; a Markdown project spec admits nothing (GPT F1).test_acp_mode_frame_check.py: checks at send, one denial per refused switch, a pre-episode view's frame written after the close, a gate-admitted agent's frame refused.test_acp_runtime_session_start.py,test_acp_healthy_host_session_open.py: launch binding, healthy-host opens, a link retargeted during the read (GPT F2), launch copy by name, a pre-episode view admitted after the close.code_review_sage/tests/test_review_pool.py: an agentless session is refused once in an episode.set_modegated,_conductor_spec_heldread only via_spec_hold_open.Local, one commit on 3ecd50f: the PR's 30 test files, the backend
gates[]floor, mypy, Semgrep (0 new), flake-pattern ratchet. Refusal matrix vs the previous head (10,199 calls): 0 refused while unreadable now admitted, 0 newly refused.Manual verification
N/A beyond the harness.
Pattern harvest
Rule candidate: review-prompt (AUTOSDE
a-failed-read-is-not-a-corrupt-file)Pattern: a reader that falls back to defaults on every read error; it must keep the file on "could not read it" and rebuild only on "read it, damaged".
Related Issues
Closes #15515
Follow-up: #18860 (in-gate recovery, timer removal), #18646, #18679, #14112. Related: #17792, #17882
Checklist
Contribution License Agreement
Contributed under the project's Apache-2.0 license.