Skip to content

fix(agent): keep an unreadable agent spec instead of resetting it - #15546

Closed
jeeshofone wants to merge 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/15515-agent-spec-unreadable-skip
Closed

jeeshofone wants to merge 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/15515-agent-spec-unreadable-skip

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A rebuild that cannot read an existing kirocrew.json keeps 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 becomes kiro_default.

_load_existing_config caught (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

What changed (motivation → approach → change)

A read error on a present kirocrew.json no longer resets it: the rebuild keeps the file and skips the cycle, and the main agent waits until a rebuild writes it again.

Part What it does
Keep the file Every rebuild read uses read_bytes_with_retry. Only FileNotFoundError means absent; any other OSError raises _AgentSpecUnreadable (also from the alias reconcile in mcp_aliases.py). _skip_unreadable_main_spec keeps the spec and its mirrors, still writing sibling specs (_install_sibling_specs).
Say so The skip reports wrote=False and a hold; cli_setup.py, _shared_config_followups.py and config_watch.py say the spec was left unchanged.
Start gate During the episode, require_fork_governance refuses 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).
Every start refused During an episode every start is refused, one SEL denial each, with no exemption for a project spec or a view's source: a bare name (no view, KAS, an app's launch copy) cannot be pinned to a file, a renamed main cannot be learned from an unreadable file, a link or retarget can put the kept file under any name, and kiro-cli keeps serving a spec it loaded after chmod 000. The skill projection refuses every view read across an episode.
After recovery Once a rebuild writes the spec every start is admitted again, a pre-episode view included; no process is ended. Only a spec read before it ended stays refused (a KAS payload, an agent the projection read during it); its message and SEL row say a new start reads it again.
Check at send Each session/new, session/load and kiro-cli set_mode is checked right before its send (_send_session_open, check_mode_frame). A switch reads its modeId through the pure mode_id: one SEL denial per refused switch.

New owner agent_parts/spec_unreadable.py holds the episode, composed onto the agent.py facade.

Not in-gate recovery: #18860 owns the trigger model. Not only sharing violations: a lasting EACCES would run the main agent as kiro_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 (winerror 32/33) holds an episode like EACCES until a retry reads the file. Probe (Linux, kiro-cli 2.31-2.33): a fresh process that cannot read the spec runs kiro_default (exit 0); a running one keeps its cached spec through chmod 000 and 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 kirocrew is ungated (#18646).
Removes: send_request, send_notification and send_request_for_answer raise on session/new and session/load, and the last on set_mode too. A missing or invalid spec still rebuilds from defaults, --clean still 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.
  • Ratchets (re-keyed): no raw session open, every set_mode gated, _conductor_spec_held read only via _spec_hold_open.
  • 16 mutations, each red: send-time checks, episode-only refusals, a view refused after the close, the KAS read's revision check, launch copy by name, the by-name clause, a process ended on a refusal.

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

  • Tests added; existing tests pass; self-review, docs, no secrets

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@jeeshofone
jeeshofone requested a review from a team as a code owner September 30, 2026 19:07
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of ea0fd687efaa71cf2cb30a5d49f32232cd3cf234 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of ea0fd687efaa71cf2cb30a5d49f32232cd3cf234 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 3 — inherited (partly): the Goal's support, "a fresh one silently becomes kiro_default", is already refused at session start by _verify_spawn_agent_active (src/kiro_crew/acp/runtime_mode_activation.py:206). The gate's remaining support is the reload-on-content-change premise, which was "probed on Linux" only. The gate fails closed during an episode only, so this is not an availability BLOCK.
  • Item 5 — oversized: the early-retry timer is a self-described "stopgap until recovery moves inside the gate (Fast recovery and admit-while-unreadable for the main agent spec #18860)". It adds its own module state plus the exit_path.py/service_boot.py hooks beside the existing hourly retry_held_conductor_specs. Subtraction: defer the timer and its two gateway hooks to Fast recovery and admit-while-unreadable for the main agent spec #18860, and keep the hourly wake as the retry.

What this change ships

Inventory (8 items) — 6 justified

Intent: stop a rebuild from erasing a user's agent spec it merely failed to read. This is a FIX.

  1. An unreadable kirocrew.json is kept and that rebuild is skipped, not reset to defaults — justified
  2. The alias reconcile treats an unreadable spec as present, not missing — justified
  3. During an episode the main, heartbeat and worker starts are refused — inherited premise (partly)
  4. During an episode every start is refused, including other agents, project agents and views — justified
  5. Early retry at 5/15/60 s, then every 60 s, cancelled at shutdown — oversized
  6. Setup, the dashboard and the config watcher say the spec was left unchanged — justified
  7. One SEL denial per refusal, plus a superseded-read cause after recovery — justified
  8. Every session open and set_mode is checked right before it is sent; raw opens are ratcheted — justified

[FIRST-PRINCIPLES-REVIEWED] ea0fd68

Description read

[DESCRIPTION-READ] 7d9f10507511489b787cf6964f415e8479741c9a15b61f27b6d78c02ab03c977

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed ea0fd687efaa71cf2cb30a5d49f32232cd3cf234 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ea0fd68

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed ea0fd687efaa71cf2cb30a5d49f32232cd3cf234 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] ea0fd68

@jeeshofone

Copy link
Copy Markdown
Contributor Author

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 src/kiro_crew/agent.py:3304 (stale governance grants): upheld as a fact. On this head the new arm returns without writing on any OSError other than FileNotFoundError, and reproject_for_ceiling_change then leaves its memo behind and returns, so a tightened ceiling is not projected into the main spec's allowedTools until a later rebuild can read the file. For a persistent EACCES/EPERM that later rebuild never comes. The base head avoided this only by writing defaults, which is the data loss #15515 reports. So the two goals conflict on exactly one case, a spec that stays unreadable, and I do not think the author should pick between them. Options I can implement once one is chosen:

  1. Keep the file and fail closed: while the main spec could not be re-projected, refuse to start sessions on it (the reviewer's fix), the same way require_fork_governance refuses an unrefreshed fork.
  2. Keep the file only while no ceiling change is pending, and fall back to the base behaviour (rebuild from defaults) when the unreadable read coincides with a moved ceiling generation.
  3. Narrow the keep-the-file arm to the retried Windows sharing violation (PermissionError after atomic_write.read_bytes_with_retry is exhausted) and let every other OSError keep the base behaviour.

Opus 5 Review, BLOCKING at src/kiro_crew/agent.py:3304 (fork refresh skipped): upheld. The early return skips fork_refresh.refresh_after_rebuild, so _fork_refresh_failed stays empty and require_fork_governance would admit forks that were not re-filtered this process. It also skips the sibling agent installs and repair_agent_configs(), which do not depend on the main spec. Whatever option is chosen above, the fix is to skip only the main spec write and let the rest of the rebuild run, or at minimum fail the fork pass closed with frozenset({"*"}) as fork_refresh.py already does on its own failure paths.

Opus 5 Review, FINDING at src/kiro_crew/agent.py:2378 (no retry): agreed. The read should go through atomic_write.read_bytes_with_retry so the millisecond replace window is survived, and raise only after it is exhausted. I left the retry out because #15506 adds it at this site; if that PR is not landing first, I will add it here.

Opus 5 Review, FINDING at src/kiro_crew/dashboard/server.py:5080 (_apply_background_model): agreed. It calls plain rebuild_agent_config and would log success on the new no-write return. The fix is to switch it to rebuild_agent_config_reporting and route wrote=False into its failure branch, as _apply_default_model does.

Design Review and First Principles Review passed. First Principles asked whether callers with no _wrote_out (gateway start) tolerate a skipped cycle with only the warning as signal; that is the same question as the governance finding above and depends on the chosen option.

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.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@jeeshofone jeeshofone changed the title fix(agent): keep an unreadable agent spec instead of resetting it fix(agent): keep an unreadable agent spec and refuse sessions on it Oct 2, 2026
@jeeshofone
jeeshofone force-pushed the fix/15515-agent-spec-unreadable-skip branch from 9cb6f4a to 152e52a Compare October 2, 2026 03:51
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Dispositions for head 152e52aca. This supersedes the three options in my previous comment: the decision is to keep the unreadable spec AND fail closed. I read each cited path on this head before replying.

GPT 5.6 Review, BLOCKING at src/kiro_crew/agent.py:3304 (stale governance grants usable): fixed. When kirocrew.json stays unreadable, rebuild_agent_config records the spec as unprojected (_main_spec_unprojected) and reports no write, so reproject_for_ceiling_change keeps its memo pending. require_fork_governance, which the kiro, KAS and ACP client spawn hosts all call before starting a session, now calls _require_main_spec_projected first: for the main spec it retries one rebuild, and if the spec is still unprojected it raises AgentSpecUnprojected. That is a subclass of ForkGovernanceUnresolved, so each host's existing handler turns it into a spawn error carrying the path and read error. The retry covers the persistent EACCES/EPERM case you raised: no session starts on the stale grants, and the first session start after the file becomes readable re-projects it and proceeds. Tests: test_unreadable_spec_refuses_main_agent_sessions, test_readable_spec_again_unblocks_sessions.

Opus 5 Review, BLOCKING at src/kiro_crew/agent.py:3304 (fork refresh and sibling installs skipped): fixed. The early return is gone. Only the main spec write is skipped. Everything after it moved into _install_sibling_specs, which both paths call: the sibling and conductor installs, _install_worker_agent, sync_aim_packages, fork_refresh.refresh_after_rebuild with the caller's refresh_forks, and repair_agent_configs(). I ran the fork refresh rather than forcing frozenset({"*"}): _refresh_forked_templates_locked re-filters each fork's own file and does not read kirocrew.json, so blocking every fork until the main spec is readable would refuse forks the pass could have re-filtered. Forks keep the refresh's own fail-closed accounting. test_forks_fail_closed_when_the_spec_is_unreadable drives the unreadable arm with refresh_forks="defer" and a pass that dies, then asserts "*" lands in _fork_refresh_failed and require_fork_governance refuses the fork. The heartbeat and worker installs mirror the main spec through the capped reader, which treats an unreadable file as absent, so they install from the template under the current ceiling (fewer tools, no stale grants) until the next rebuild that reads it.

Opus 5 Review, FINDING at src/kiro_crew/agent.py:2378 (no retry on the first PermissionError): fixed. _load_existing_config reads through atomic_write.read_bytes_with_retry, and _AgentSpecUnreadable is raised only after that retry is exhausted. Test: test_sharing_violation_is_retried_before_the_spec_counts_as_unreadable (one sharing violation, then the rebuild reads and writes, keeping the user's model and server).

Opus 5 Review, FINDING at src/kiro_crew/dashboard/server.py:5080 (_apply_background_model logs success on a no-write return): resolved by the restructure, so I left that applier as it is. The background role model lives in the lite and heartbeat specs, and _install_sibling_specs now rewrites both on the unreadable path too, so the change does apply and the "background agent specs rebuilt" line is accurate. The main-spec no-write case only affects agent.model, whose applier already routes wrote=False into its failure branch.

First Principles Review question (callers with no _wrote_out, such as gateway start, tolerating a skipped cycle with only the warning as signal): answered by the gate. Those callers do not need the verdict, because a stale main spec can no longer start a session. The refusal is the user-visible signal, and the WARNING says sessions are refused until a rebuild can re-project the spec.

Design Review: PASS, no action.

The PR description is updated to match. The local verification floor is listed there.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 2, 2026
@jeeshofone
jeeshofone force-pushed the fix/15515-agent-spec-unreadable-skip branch from 152e52a to 6a5d52a Compare October 2, 2026 05:24
@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Fixed: declared-name aliases bypass the unprojected-spec gate span=954823a62c41

Fixed in 6a5d52a92. The gate no longer matches a fixed name set. _runs_an_unprojected_spec admits a name only when it provably runs a spec other than the stale ones. The filename stems of kirocrew.json and its two mirrors (kirocrew-heartbeat, kirocrew-worker) are gated directly. Any other name is resolved through agent_spec_path, the same declared-name resolver require_fork_governance already uses, and is gated when it resolves to one of those files, resolves to nothing, or fails to resolve. An unreadable spec cannot be matched by its declared name, so an alias like personal declared only inside it resolves to nothing and is refused (fail closed). When the file is readable again, the alias resolves to kirocrew.json, is gated, and the gate's re-read and rebuild re-projects it before admitting. Test: test_a_declared_alias_of_the_unreadable_spec_is_refused (an alias declared in the unreadable spec is refused; an agent whose own readable spec resolves elsewhere is admitted). It fails on 152e52aca.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Fixed: governance.md documents only the shared-home refusal as a no-write cause span=5e86cd522128

Fixed in 6a5d52a92, same commit. The ceiling-projection memo passage in docs/system-specs/modules/governance.md now names both non-raising no-write rebuilds (shared home refused, and a present kirocrew.json whose read still fails after read_bytes_with_retry), both returning wrote=False and holding the memo. It also describes the spawn-side fail-closed behaviour: the spec is recorded as unprojected, its two mirrors are left untouched, the rest of the rebuild still runs, require_fork_governance raises AgentSpecUnprojected for the main spec, its mirrors and unresolvable names, and recovery happens on the first session start after the file reads again.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Fixed: the unreadable arm rewrites the heartbeat spec with zero MCP servers span=58ab3ac8329f

Fixed in 6a5d52a92, as suggested. _install_sibling_specs takes mirror_main, and the unreadable arm passes False, which skips both mirror installs (heartbeat and worker). Both derive from the spec whose read failed, so re-deriving them would drop the user's servers. Because the mirrors keep grants from the last good read, _require_main_spec_projected now refuses kirocrew-heartbeat and kirocrew-worker sessions as well as kirocrew, until a rebuild re-derives all three. The docstring sentence vouching for the template install is gone. Tests: test_unreadable_existing_spec_is_kept_not_reset asserts the heartbeat and worker installs are not called and the knowledge install, fork refresh and hook repair are. test_unreadable_spec_refuses_main_agent_sessions asserts both mirrors are refused.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Fixed: the retry-lock comment claims one rebuild per burst, but every start rebuilt span=58ab3ac8329f

Fixed in 6a5d52a92 by memoising on the read, not the comment. Under the lock, the gate now rebuilds only when _main_spec_read_succeeds() (a plain read_bytes_with_retry of kirocrew.json) succeeds. While the file stays unreadable each session start costs that one read and no rebuild. Once it reads, the first start rebuilds and clears the record, and starts queued on the lock see it cleared and skip. I used the read rather than an st_mtime_ns/size memo because a sharing violation clears with the file's stat unchanged, so a stat memo would never retry. The comment now says exactly this. test_unreadable_spec_refuses_main_agent_sessions asserts no rebuild runs while the file is unreadable, and test_readable_spec_again_unblocks_sessions asserts exactly one rebuild once it reads.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 2, 2026
@jeeshofone
jeeshofone force-pushed the fix/15515-agent-spec-unreadable-skip branch from 6a5d52a to ea8f919 Compare October 2, 2026 07:05
@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Fixed: unreadable alias can bypass the projection gate span=954823a62c41

Fixed in ea8f9199c, as the finding asks: no global name is admitted while kirocrew.json is unreadable. _runs_an_unprojected_spec no longer resolves the name through the global directory at all, because the unreadable file may declare any name and the backend matches declared names over an unordered listing, so a readable spec that claims the same name proves nothing. The only admitted case is positive proof that the stale file cannot be selected: a name a parsed project spec declares (project_agent_names), on a backend that resolves <cwd>/.kiro/agents before the global directory. The KAS harness reads only the global directory and passes project_resolves_first=False, so it gets no exemption. Tests: test_every_global_name_is_refused_while_the_spec_is_unreadable (your scenario: an agent with its own readable global spec is refused) and test_a_name_a_project_spec_claims_is_admitted. Both fail on 6a5d52a92.

@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

First Principles note, item 8 (refusing pre-episode views after the episode closes goes beyond "until a rebuild writes it again"). Kept on c2f5071636; scope corrected for f04a717f3a, which classifies no view's source.

The rebuild that closes the episode rewrites the spec file, never a view a process already runs. A process launched on a view of the main spec built before the episode keeps that view for its life, with the grants it had then: a ceiling change the failed rebuild could not apply is not in it, and the closing rebuild cannot put it there.
So for that process the harm is still there, which is the Goal's own reason: it refuses starts "because a running kiro-cli keeps the grants it loaded". After the close the refusal reaches only what was built or read before the episode ended (every pre-episode view, views prepared during the episode, a KAS payload read before the close), and each is replaced: the process is recycled, the views are prepared again by the next session, the payload is read again by a new start.
Pinned: test_agent_unreadable_main_spec_recovery.py::test_after_recovery_only_a_pre_episode_view_is_refused.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

span=11693c34a43d: GPT 6.1 BLOCK, both findings (F1 spec_unreadable.py:644: a Markdown project spec exempts a native launch; F2 :382: retargeting the kirocrew.json link between the read and the provenance check loses it). Fixed on f04a717f3a by deleting the code both live in.

Gone: the project-spec exemption (_project_declares_off_main_spec) and view provenance (main_spec_provenance, classify_spec_path, the reader's opened= record, main_spec_views, _launch_view_main_spec). While an episode is open every start is refused, one SEL denial each: a bare name, a view of any file, an app launch copy, KAS.
Nothing they guarded is lost. Both only ever admitted a start during an episode (a project-declared name, a view classified as another file), so removing them only refuses more, which the Goal asks for ("any start that cannot be shown not to load the kept file"). The probe adds that a running kiro-cli loads the kept file once its content changes, so a view's file vouches for nothing during the episode either. After the episode a pre-episode view is still refused and its process recycled, now whatever its source.
F1 pin: test_native_skill_projection_view_provenance.py::test_a_markdown_project_spec_does_not_admit_a_warm_unbound_open. F2 pin: test_acp_healthy_host_session_open.py::test_a_main_spec_link_retargeted_during_the_read_still_refuses_the_later_open, through the real preparation and spawn. Both fail on c2f5071.
The cost is availability during an episode only: other agents' views and project agents are refused too until the first good read, bounded by the 5/15/60 s early retry. The body's Breaking line says so.

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.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

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 01c560faff.

The rebuild that closes the episode rewrites the spec file, never a view a process already runs. A process launched on a view built before the episode keeps that view for its life, with the grants it had then: a ceiling change the failed rebuild could not apply is not in it, and the closing rebuild cannot put it there.
So for that process the harm is still there, which is the Goal's own reason: it refuses starts "because a running kiro-cli keeps the grants it loaded". After the close the refusal reaches only what was built or read before the episode ended (every pre-episode view, whatever file it was built from, since no source is classified; views prepared during the episode; a KAS payload read before the close), and each is replaced: the process is recycled, the views are prepared again by the next session, the payload is read again by a new start.
The cost is one failed open per such process, which the body's Breaking line now states.
Pinned: test_agent_unreadable_main_spec_recovery.py::test_after_recovery_only_a_pre_episode_view_is_refused.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

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 kiro_default hole). Kept on 01c560faff.

The narrower rules are the ones GPT 6.1 fenced as security findings: F1 and F2 on c2f5071 (a project-spec exemption, a view's recorded source) and its provenance finding on bd2a9d5. A fenced security BLOCK clears only through a writer's override, so this head deletes those rules instead of narrowing them a third time.
The F2 trigger is the user's own dotfiles sync, not an attacker. "Anything that can create such a link can already write an ungoverned spec" is true but beside the point: the refusal keeps Crew from starting a kiro-cli that may load grants no rebuild re-projected, whoever made the link.
The cost is availability: refused starts until the first good read, bounded by the 5/15/60 s early retry, and one replaced process per view built before the episode. The body's Breaking line states both.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

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 01c560faff; the measurement belongs to #18860.

The Breaking line now says it: "After an episode closes, a process launched on a view built before it fails its next open once and is replaced." That holds for a view of any file, since this head classifies no source.
What it takes: a sharing violation on kirocrew.json that outlasts read_bytes_with_retry (10 attempts 50 ms apart, about half a second) during a rebuild's read. Each warm view runtime then fails one open, during the episode or, if it had none then, after the close, and its holder relaunches a fresh view.
No Windows probe was run, as the body says. How often this happens is the measurement to take before #18860 removes the timer; its scope comment lists this recycle among what that removal takes out.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

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 01c560faff.

#18860's scope comment lists what its removal takes out with the retry timer: the launch-view bookkeeping and the recycle, the send-time checks (_send_session_open, AcpClient._send_request, check_mode_frame), the KAS bound read and the ratchets on those paths.
This head adds no check site. It deletes the bound's two early admissions (require_main_spec_launch_bound, which the send and launch sites call) and the source test in the projection's (unprojected_main_spec_source), so every site now asks one question: is an episode open, or was the view read before the current revision.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Opus 5.5 note 1 (agent.py grows from 1576 to 1635 lines, past keep-modules-small's 1,600). Kept on 01c560faff.

The episode's code lives in its own owner, agent_parts/spec_unreadable.py, not on the facade. Of the 60 lines agent.py gains, 38 are facade imports (34 of them the new owner's block) and 1 is that owner's _PARTS entry.
The other 21 are the two classes, _AgentSpecUnreadable and _EarlyRetryRunning, which stay on the facade because owners may not define them: test_agent_parts.py::test_every_module_level_value_an_owner_defines_is_the_object_the_facade_binds holds every value an owner defines to the object the facade binds.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Opus 5.5 note 2 (during an episode, retry_held_conductor_specs logs "retrying the conductor specs…" at INFO on every early retry). Kept on 01c560faff: the line is main's.

The INFO line is retry_held_conductor_specs's own on main (agent_parts/spec_rebuild.py), and this PR does not change it. What this PR adds is the early retry that calls that function while an episode is open: at 5, 20 and 80 s into the episode, then once a minute, stopping at the first good read.
So the line is bounded by the episode: at most one a minute after its first 80 s, and none once the spec reads. The episode's own warnings, for the failed read and a failed retry, are logged once per episode.

First-pass check: R1-R8 OK.

@cruisercohen

Copy link
Copy Markdown
Contributor

Re-checked 01c560faff. Our blocking point from the 10-15 review (a refused switch writing 2-3 SEL denials) is addressed: mode_id no longer audits, and test_a_switch_to_a_refused_main_spec_view_writes_one_denial plus test_the_projections_mode_lookup_audits_nothing pin one denial.

Two things before the final re-review:

  1. The branch conflicts with main again; please rebase.
  2. Backend Tests (3.12, 8) and (Windows, 8) fail on test_runtime_bindings.py::test_each_owner_names_the_fields_it_writes_and_reads[kiro_crew.acp.runtime_spawn_launch]: runtime_spawn_launch.py now lists _launch_copy_source under the fields it reads, but the module never reads it.

We'll re-review the rebased head. iamwhatever's change request and the split question are still for a maintainer.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

First Principles blocker on 01c560faff (the refusal and recycle after recovery are outside the Goal). Taken on 6fcbb33941.

A view is admitted whenever no episode is open: the bound's view branch refuses only while one is open (require_main_spec_launch_bound), so once a rebuild closes the episode a pre-episode view is admitted again, on the shared runtime, the direct client and a set_mode frame, and no process is ended.
Removed with it: the recycle (_recycle_superseded_launch, _require_launch_bound_before_setup, _launch_view_superseded, _session_open_checks_in_flight, the launch_view reason of _is_stale), the refusal kinds process and session, and the per-view episode reading that only the dropped arm read (NativeSkillProjection.episodes, view_episode, _launch_view_episode). About 175 source lines net.
Kept: the bare-name branch's revision check (KAS's read by name) and unprojected_main_spec_source in the preparation. Each refuses a read that overlapped an episode, not an old view, and after the close they are the only refusals left; their message and SEL row say a new start reads the spec again (cause=unreadable_main_spec_superseded_read).
A process launched on a view before an episode keeps that view's grants after the close. The body names it under Not a goal, and it is added to #14112.
Refusal matrix against 01c560faff, 10,199 calls through every refusing entry point, with the spec readable and denied, a renamed main, and symlinked and Windows-spelled view sources: 0 calls refused while the spec is unreadable are admitted now, and 0 are newly refused anywhere. Every flip is a view call: 1,440 after an episode closed, and 720 on a healthy host carrying an episode reading production never records (this head records none).
Pinned: test_agent_unreadable_main_spec_recovery.py::test_after_recovery_only_a_read_that_overlapped_the_episode_is_refused, test_acp_runtime_session_start.py::test_a_retained_view_built_before_an_episode_is_refused_only_while_it_is_open, test_acp_mode_frame_check.py::test_an_open_on_a_pre_episode_view_is_written_once_a_rebuild_closes_the_episode.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

First Principles note on 01c560faff, item 9 (the start gate's file-identity and declares-name check decides nothing during an episode; replace it with "refuse while _main_spec_unreadable"). Kept on 6fcbb33941.

On kiro-cli it decides nothing, as the note says: during an episode the launch bound refuses every start as well, so the classifier only picks which check writes the one denial.
A mid-session switch on another backend runs the start gate alone: AcpSessionHandle.set_mode calls only require_main_spec_projected when the backend is not kiro-cli (KAS). There the classifier is what decides: the main agent's file and names are refused, and a user agent whose own file declares its name is admitted. A blanket refusal would refuse every KAS switch during an episode. That widens a refusal rather than subtracting a mechanism, so it stays out of this PR.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design note on 01c560faff (a brief Windows lock clash becomes a host-wide outage, plus a recycle of every running process). The recycle half is removed on 6fcbb33941; the rest is stated, as on f04a717f3a.

No refused open ends or marks a process any more, and once a rebuild closes the episode every start is admitted again, a view built before the episode included (First Principles' subtraction). A lock clash on Windows therefore costs refused starts during the episode only, bounded by the 5/15/60 s early retry and the first good read.
The episode itself stays: a sharing violation that outlasts read_bytes_with_retry is a read the rebuild could not make, and refusing a start that cannot be shown not to load the kept file is the Goal. The body's Breaking line states the cost, and no Windows probe was run. How often it happens on a real Windows host is the measurement to take before #18860 removes the timer.

Design note on 01c560faff (big for one bug; landing the keep-the-file fix first would be safer to revert). Whether to split is with the maintainers, in the open change request. This head is smaller than 01c560faff: about 175 source lines net and one test module fewer.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

@cruisercohen, on your re-check of 01c560faff:

  1. Rebased: 6fcbb33941 is one commit on main b848377fe3.
  2. Shard 8: runtime_spawn_launch.py no longer lists _launch_copy_source among the fields it reads; the module never reads it. The method stays, because the start bracket's and a switch's frame checks call it to check an app launch copy by name. test_runtime_bindings.py passes locally.
  3. First Principles' blocker on 01c560faff is taken: a view is admitted whenever no episode is open. That removes the recycle (_recycle_superseded_launch, _require_launch_bound_before_setup, _launch_view_superseded, _session_open_checks_in_flight, the launch_view reason of _is_stale), the process and session refusal kinds, and the per-view episode reading (NativeSkillProjection.episodes, view_episode, _launch_view_episode): about 175 source lines net. Once an episode closes, only a spec read before it ended stays refused (a KAS payload, an agent the projection read during it).

Your two pins, test_a_switch_to_a_refused_main_spec_view_writes_one_denial and test_the_projections_mode_lookup_audits_nothing, pass unchanged. The case the subtraction leaves, a process launched on a view before an episode keeping that view's grants, is added to #14112.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design note 3 on 6fcbb33941 (the gate covers only this process; a kiro-cli --agent kirocrew started by another process is ungated). Known gap, stated on 26c5f0a86a.

The body's Backwards compatibility section names it as the Known gap. Binding every start in any process to the verdict is #18646, listed under Not a goal.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

First Principles note on 6fcbb33941, item 6 (the early retry is oversized: the governance spec has #18860 delete the timer, its delay table and both gateway hooks, and lists recovery inside the gate under Not a goal). Scoped to #18860 on 26c5f0a86a; nothing is removed here.

The retry is not recovery inside the gate. It runs the existing rebuild, retry_held_conductor_specs, and an episode still closes only when that rebuild writes the spec, so it admits nothing by itself. What it bounds is how long a cleared lock keeps every start refused: about a minute. Without it, the next rebuild after a cleared lock is the hourly maintenance wake or a gateway restart, the two other retries the refusal message names.
#18860's scope comment lists the early retry first for removal, and the body names #18860 as its follow-up.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design note 1 on 6fcbb33941 (during an episode the gate refuses every agent start; keying refusals on the spec file, and admitting any agent whose own readable file declares its name, would be narrower). Kept on 26c5f0a86a, as answered for the same point on f04a717f3a.

Admitting an agent on its own readable file is the project-spec exemption GPT 6.1 fenced as F1 on c2f5071636. A link or retarget can put the kept file under any name, so a readable file that declares a name does not show that the start will not load the kept spec. A fenced security BLOCK clears only through a writer's override, so the narrower rule stays out.
The cost is availability, not data: starts are refused until a rebuild writes the spec, and the early retry runs that rebuild within about a minute of the file reading again. The body's Breaking line states it.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design note 2 on 6fcbb33941 (the early retry is module-global threading.Timer state beside the hourly wake; keep #18860 as the issue that removes it). Scoped there on 26c5f0a86a.

#18860's scope comment lists the early retry first for removal: _schedule_main_spec_early_retry, its timer and delay table, and the gateway start and shutdown hooks. The body names #18860 as the follow-up for in-gate recovery and the timer's removal.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design note 1 on 26c5f0a86a (one bad permission on kirocrew.json stops every agent for the episode, so the refusal should tell the user to fix that file's read access). Already so on 9a3243779d.

While an episode is open, every refusal's message names the spec's path and says: "Restore read access to the file if it is still denied. The next rebuild picks it up (an early retry within about a minute of the lock clearing, the hourly maintenance retry, or a gateway restart), and the agent can start once that rebuild has written it" (refuse_unprojected_main_spec_start in agent_parts/spec_unreadable.py). The body's Breaking line states the host-wide cost.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design note 2 on 26c5f0a86a (the gate holds only inside this process, so the spec docs should not call it a guarantee until #18646 lands). Stated on 9a3243779d.

governance.md says the gate is process-local: a second process that starts kiro-cli --agent kirocrew on the same agents directory is not gated. The body's Known gap line says the same, and binding every start in any process to the verdict is #18646, under Not a goal.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design note 3 on 26c5f0a86a (the module's timer thread is interim code; #18860 should replace it outright, not add to it). Scoped there on 9a3243779d.

#18860 lists the early retry first for removal: _schedule_main_spec_early_retry, its timer and delay table, and the gateway start and shutdown hooks. A dated follow-up on #18860 lists what #15546 adds for that gap as of 9a3243779d. The body names #18860 as the follow-up for in-gate recovery and the timer's removal.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

First Principles note on 26c5f0a86a, item 9 (the launch bound refuses every start during an episode, so _governed_by_main_spec only picks the message; replace it with the bare _main_spec_unreadable check unless another harness depends on it). Kept on 9a3243779d, as answered on 01c560faff.

Another harness does depend on it. On kiro-cli the classifier decides nothing during an episode, as the note says. A mid-session switch on KAS runs the start gate alone: AcpSessionHandle.set_mode calls only require_main_spec_projected when the backend is not kiro-cli. There the classifier decides: the main agent's file and names are refused, and a user agent whose own file declares its name is admitted. The bare check would refuse every KAS switch during an episode, which widens a refusal rather than subtracting a mechanism.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

First Principles note on 26c5f0a86a, item 5 (require_main_spec_launch_bound's project_dir is unused, and its seven production callers pass a value nothing reads; delete the parameter). Held on 9a3243779d.

Deleting it changes no behaviour: the bound decides the same with or without it, and its docstring says the parameter is unused. It would touch the seven call sites and their tests in a round that takes only the independent review's fixes. A follow-up can drop it together with its callers.

First-pass check: R1-R8 OK.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at 9a32437 for a maintainer.

What holds it:

  1. Reserved for a human reviewer. The new start gate in spec_unreadable.py#L403-L427 decides which agent starts are admitted while kirocrew.json cannot be read, and each session open and mode switch is checked again right before it is sent. That is governance enforcement.
  2. Active change request. cruisercohen's review from 15 Oct is still open. Their 26 Oct comment says the blocking point is fixed and that they will re-review the rebased head.

One question for the human reviewer. _governed_by_main_spec admits a user agent whose own readable file declares its name. The author says a KAS mode switch runs only this gate (session_handle_model_selection.py#L335). The same declared-name exemption is the one cited as fenced by GPT for kiro-cli starts. Please confirm the KAS exemption is intended.

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
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — ✅ PASS

Which legitimate operations does ea0fd687efaa71cf2cb30a5d49f32232cd3cf234 newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

adjudicated, zero confirmed regressions

Scope-Verdict: PASS

Reason: The tightening is an in-process admission gate on agent launches, session opens and set_mode frames while an unreadable-main-spec episode is open. The patch does not touch the shell deny composite, so the shell rows only measure tiers this change doesn't modify. The gate itself is a guard the classifier cannot judge, so nothing confirms or clears whether it over-refuses; that gap is named under UNADJUDICATED.

TIGHTENING: a new launch/session-open bound, require_main_spec_launch_bound / require_main_spec_projected, wired into AcpClient._spawn, AcpClient._send_request, AcpRuntime._spawn_admitted, _send_session_open, _check_mode_frame and KasHarness.session_extras -- it refuses starting kiro-cli on a spec Crew could not re-project, i.e. grants the ceiling has since revoked: if not (unreadable or (before is not None and (before[1] or before[0] != revision))): return / raise ForkGovernanceUnresolved(refuse_unprojected_main_spec_start(agent)), and for views if view_source is not None: if not unreadable: return; raise ForkGovernanceUnresolved(...).

ADJUDICATED: 12 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix and windows. The diff adds one platform assumption: the main spec at kiro_agents_dir() / "kirocrew.json" (and <launch_agent>.json), with "unreadable" covering a Windows sharing violation as well as posix EACCES/EPERM/EIO. The posix rows (ls -l, chmod u+r, cat on ~/.kiro/agents/kirocrew.json, kiro-cli chat --agent kirocrew, kirocrew setup --agent-only, the pytest run) and the matching windows rows (icacls / type on %USERPROFILE%\.kiro\agents\kirocrew.json, kiro-cli.exe, kirocrew.exe, the backslash-path pytest run) probe each host's spelling of the inspect, restore, rebuild and test steps the refusal sends an operator to. No any rows were written, because every candidate carries a path or an executable name. No platform the diff assumes is left without a candidate.

UNADJUDICATED: The guard is the unreadable-main-spec episode gate. Call paths: AcpClient._spawn → require_main_spec_launch_bound(self._agent, self._work_dir) when no prepared view decides the agent; AcpClient._send_request for session/new, session/load, session/resume and set_mode → the same bound, with view_source for view launches; AcpRuntime._spawn_admitted → the bound for unbound launches and app launch copies; create_session / load_session / probe_advertised_models → _require_launch_bound_for_session_open and _send_session_open → _check_session_open; _activate_mode_bracketed → require_main_spec_projected and then _check_mode_frame for each attempt; KasHarness.session_extras._build → require_main_spec_launch_bound(agent, work_dir, before=episode); and _refuse_raw_session_open, which makes send_request, send_notification and send_request_for_answer raise ValueError for session/new / session/load. send_request_for_answer also raises for set_mode. Inputs I would have submitted but could not get a verdict for:

  • a session that names no agent (agent=None, as the code review pool passes) opened on a process launched on a prepared view before the episode;
  • the model-entitlement probe while an episode is open;
  • a user agent whose own readable file declares its name;
  • an agent declared by a readable project spec in <cwd>/.kiro/agents;
  • an app's launch copy under its reserved name;
  • a KAS session whose payload was built just before an episode closed;
  • any internal caller that still sends session/new, session/load or set_mode through send_request / send_request_for_answer (it now gets a hard ValueError).

Narrowing I can argue but not confirm: by its own docstring, require_main_spec_launch_bound refuses every start for the whole episode, "no name, project spec or view source is exempt". That includes agents whose specs are unrelated and readable, so heartbeats, workers and chats on other agents all stop until a rebuild reads kirocrew.json again (an early retry is scheduled). The author documents this as intended fail-closed behaviour, and nothing here measures it.

[SCOPE-REVIEWED] ea0fd68

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 7 classified, 0 newly refused, 7 still allowed.
  • ubuntu-latest (platform posix): 7 classified, 0 newly refused, 7 still allowed.
  • windows-latest (platform windows): 5 classified, 0 newly refused, 5 still allowed.

No candidate flipped from allowed to refused.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Moved to #27535: same commits, now on a branch of this repo so CI uses the CodeBuild fleet. Review history stays here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent: a Windows sharing violation while rebuild_agent_config reads kirocrew.json rebuilds it from defaults and writes that back, erasing user edits

4 participants