Repository navigation
fix(agent): never rewrite a crew-bound spec Crew does not own - #25325
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. A recorded owner decision covers the stop on rewriting unowned specs and the fail-closed kiro-cli start check. The description is cut off inside its Backwards compatibility section, so its reader list was not judged in full. Notes
[DESIGN-REVIEWED] e778f71 Description read[DESCRIPTION-READ] 835063f958ea10b563a64f3f55a1f3fe5928195937a353e07febc4708def79a0 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 Nothing blocks. Two riders loosen what existing crewmates get, and their support is an owner decision entry rather than an RFC status. Notes
What this change shipsInventory (10 items) — 7 justifiedIntent: the user's own kiro-cli sessions keep the auto-approvals in their agent files, and Crew sessions still stay inside the ceiling. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] e778f71 Description read[DESCRIPTION-READ] b37932c851cfd651a54c23dc1ca9af68ab79707c83ee7f4c8c38096872f07a1f That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
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: |
b6aaae2 to
ebf34df
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: the scope of this PR changed at the owner's request, and the title, Goal and body now describe the new head The first head skipped the rewrite only when every configured harness arm was KAS and re-filtered the file before a kiro-cli start. The owner then ruled that Kiro Crew never writes a spec it does not own, and that the rows still bound to one move onto their own crewmate file. This head implements that: the pass writes no such spec, a kiro-cli start on one the ceiling would narrow is refused, and the migration moves the remaining rows (restrictions the crewmate file cannot carry move with it and are named in the notice). The superseding decision entry is #25332, which this PR depends on. |
ebf34df to
b4bb5de
Compare
b4bb5de to
b1d2ac4
Compare
b1d2ac4 to
6061958
Compare
6061958 to
396b761
Compare
81e3ae4 to
085e38d
Compare
085e38d to
46e0afd
Compare
46e0afd to
b221ad2
Compare
b221ad2 to
95f2036
Compare
The shared-template governance pass rewrote every crew-bound spec Crew does not own to filter its allowedTools/autoApprove, writing the user's own file in ~/.kiro/agents. kiro-cli loads that same file outside Crew, so the user's own sessions lost those grants, and a package manager reinstalling the spec fought the rewrite on every restart. Per the owner decision superseding the 2026-10-27 migration entry: - The pass never writes such a spec. KAS filters both lists against the live ceiling in its projection; a kiro-cli start on such a file is refused while the governance passes would narrow it (or it cannot be read), so no Crew session auto-approves a ceiling-denied tool. - The startup migration moves the rows that still reach such a file onto the conductor and their own crewmate file. A hooks/permissions/ toolsSettings restriction the file cannot carry no longer keeps a crewmate in place: it moves as is and its one notice names each dropped restriction. A gain is still only offered through the capability card. - A crewmate shadowed by its own private copy (a fork) moves after the copy is retired to ~/.kiro/mates/retired/; one shadowed by a spec Crew does not own stays, is told once, and that spec is never written. - A used row with no member_id (person- or package-written, DM thread holds a turn) is given an id and its own V2 store first, allocated as the upgrade allocates it so it keeps its slug. Closes #25289
95f2036 to
e778f71
Compare
Problem / Motivation
Goal: Kiro Crew stops rewriting crew-bound agent specs it does not own, so the user's own kiro-cli sessions keep their auto-approvals, while every Crew session still meets the governance ceiling.
When a crew row is bound to an agent spec Kiro Crew did not write (a user-written or package-installed file in
~/.kiro/agents), every gateway rebuild ran the shared-template governance pass and wrote the ceiling-filteredallowedTools/autoApproveback into that file. kiro-cli loads the same file outside Kiro Crew, so the user's own sessions lost those grants, and a package manager that reinstalls the spec fights the rewrite on every restart (observed: 46allowedToolsentries cut to 4 after a restart).Why it matters
The rewrite damages a file the user owns. On KAS it also protects nothing: the KAS projection already filters both grant lists against the live ceiling at session start.
Not a goal
kiro_agentalready names their own crewmate file (the feat(crew-mode): move every used crewmate to its conductor on upgrade #24954 migration's result), Kiro Crew's own specs, and the fork refresh: their writers are unchanged. The one fork the migration touches is a crewmate's own private copy that shadows its crewmate file, which it retires (owner ruling, item 3 below).What changed (motivation → approach → change)
Depends on #25332, the superseding decision entry (
docs/decisions/README.mdrule 3 ships it in its own pull request). The scope grew from the first head of this PR (a KAS-only skip) on the owner's rulings recorded there.Measured first. Since #24954 a migrated crewmate's
kiro_agentnames~/.kiro/mates/agents/<id>.json, which this pass never scans. On one live install (11 rows, 13 crewmate files, 65 specs in~/.kiro/agents): 9 migrated rows reached no~/.kiro/agentsfile; 1 row the migration had left in place sat on its own fork (governed by the fork refresh); 0 package-synced or legacy rows were bound to a~/.kiro/agentsspec; 0~/.kiro/agentsspecs claimed a crewmate's name; the default row is Crew-owned. So the pass reached no file there; the fix matters for rows the reporter's install has (a package spec bound to a crew) and for the name-collision case, which_claimsmatches by construction.Symptom → cause → change:
agent_materialization/fork_refresh.py). The rebuild's shared-template pass now runs only the capability reconcile and reads no template file, so its file-read holds, the held-path record and their probe are removed; the config-unreadable hold stays.require_shared_template_within_ceilingrefuses a kiro-cli start (from the kiro-cli harness and fromAcpClient) on a crew-bound spec Crew does not own while the two governance passes would remove a grant (an empty list is none) from any JSON file claiming the agent, or while such a file cannot be read or has a second hard link. A binding counts when it records the agent's name or the file stem kiro-cli is dispatched under its declared name (dispatch_kiro_agent), and the files claiming both spellings are checked. The same check runs when a shared runtime activates another agent's spec from disk atsession/set_mode(it ends the session first), when a config load could not read a file whole (the missing binding may be this one), and for an agent a crewmate ran on before the migration moved it (moved_from_agents, matched under the stem or the name its file declares), since a conversation from before the move keeps its old template. It reads only and names the file and the remedy. It runs only for hosts in a new capability set,ACP_BACKENDS_SPEC_FILE_GRANTS = {kiro}: the hosts that read the file's grants themselves. Every other host gets Crew's projection, which filters both lists (KAS) or forwards neither (the adapted harnesses). An unread markdown file never refuses a start, since kiro-cli does not load that form.mate_config_migration.py, reusing feat(crew-mode): move every used crewmate to its conductor on upgrade #24954's migration):hooks,permissionsortoolsSettingsrestriction the crewmate file cannot carry no longer keeps a crewmate in place. It moves as it is, no tool is withheld, and its one-time notice names each restriction that no longer applies (dropped_restrictions). A gain is still never written, only offered through the capability card; the ceiling still governs the merged worker spec.~/.kiro/mates/retired/and its lineage dropped, just before the repoint. That runs under the shared spec lock the fork refresh holds across its own rewrite, re-proves the copy is Crew's inside it, and rescans the agent snapshot after. One shadowed by a spec Crew does not own stays, is told once (the notice also says a kiro-cli session on it is refused while it exceeds the ceiling), and that spec is never written.member_id(written by a person or a package sync, on a user-level spec Crew does not own, DM thread holds a turn) is given an id and its own V2 store only once its crewmate file is written and proven, published in the same compare-and-set as its repoint (a failure before it retires the allocation), allocated as the upgrade allocates it (provision_member_memory(upgrade=True)) so it keeps its slug. A row that stays keeps its memory. Neverdefault, the default agent, a legacy built-in or an app's row; an unchatted row is left for the synced-crewmate prune. Its earlier conversation keeps its old template and store; its notice says a new chat starts on its conductor.governance.md(shared-template section),crew-mode.md(migration),harness-onboarding.md(the new set); the set is classified inscripts/check_harness_parity.py.Rejected: a config-only "on KAS" skip (the first head here). The kiro-cli floor is always reachable through a spawn override, so it needed a per-start rewrite, which the owner then ruled out: Crew never writes a spec it does not own. Rejected: withholding the tools a dropped restriction guarded; the owner ruled the row moves as is and is told.
Backwards compatibility
Breaking, by owner decision (#25332): a kiro-cli start on a crew-bound spec Kiro Crew does not own whose grants exceed the ceiling is now refused, where it used to run after the rebuild rewrote the file; a crewmate that used to stay for a hook,
permissionsortoolsSettingsrestriction now moves and that restriction does not apply on its worker, which its notice names; a used id-less row becomes a crewmate with its own memory; its earlier conversation keeps its old template and store, a kiro-cli start on that template is checked against the ceiling, and the notice says a new chat starts on its conductor. Writer sweep on origin/main: the only writer of such a file wasfork_refresh._govern_json_spec, removed here (test_governed_spec_tailallowlist now empty).Reader: src/kiro_crew/mate_config_migration.py:migrate_existing_crewmates -- release -- startup moves each row bound to a user-level spec;
test_an_unmigrated_row_on_a_package_spec_moves_and_leaves_that_spec_byte_identicalReader: src/kiro_crew/acp/harness/kiro.py:resolve_spawn -- chat -- a kiro-cli start on an over-ceiling unowned spec is refused with the file and remedy;
test_kiro_spawn_refuses_a_bound_unowned_spec_over_the_ceilingReader: src/kiro_crew/acp/client_start.py:_spawn -- subagent -- the
AcpClientroute runs the same check;test_a_kiro_cli_client_spawn_runs_the_check_firstReader: src/kiro_crew/mate_upgrade_notice.py:claim_kept_notice -- crew page -- a crewmate left behind is told once why;
test_a_crewmate_the_migration_left_behind_tells_its_user_why_onceReader: src/kiro_crew/memory_stores.py:provision_member_memory -- app --
upgradedefaults to False, so every create path allocates as before;test_a_used_synced_row_with_no_identity_gets_one_and_movesTests
test/test_shared_template_unowned_spec.py(11): a bound third-party spec is byte-identical after a rebuild; a KAS session from it cannot auto-approve a ceiling-denied tool; a kiro-cli start on it is refused and the file untouched; within-ceiling, KAS, unbound and Crew-owned starts are not refused; every claimant is checked; a hard-linked or unreadable binding refuses; theAcpClientroute runs the check.test/test_mate_config_migration.py: an unmigrated row on a package spec moves and leaves that spec byte-identical; a droppedtoolsSettings/permissions/ hook moves with no tool withheld and the notice names it; a gain is not written (existing); shadowed by its own fork moves and retires the copy; shadowed by a third-party spec stays and the spec is byte-identical; a used id-less synced row is minted (upgrade allocation) and moves, while unchatted, app, legacy and Crew-owned-spec rows are not.test/test_acp_harness_contract.py: the kiro-cli harness refuses on the check.test/test_conductor_allowed_tools_survive.py: the three tests that pinned the rewrite and its file-read holds are replaced by one: an over-ceiling bound template is left as written, holds nothing, the memo advances, and a kiro-cli start on it is refused.test/test_agent_refactor_fork_refresh.py;test/test_mate_upgrade_notice.pynow keeps its left-behind crewmate with a name clash instead of a restriction.Each mutation applied alone and reverted; the named tests go red (plus one copilot test that is red on unmodified
origin/mainon this host):test_a_crewmate_whose_template_denies_writes_moves_and_is_told[permissions/toolsSettings],test_a_hook_the_worker_base_lacks_moves_and_is_named,test_an_agent_whose_prompt_does_not_resolve_keeps_its_stated_limitstest_a_grant_the_worker_would_gain_is_withheld_for_the_cardtest_a_kiro_cli_start_on_it_is_refused_and_the_file_is_untouched,test_every_claimant_of_the_name_is_checkedtest_kiro_spawn_refuses_a_bound_unowned_spec_over_the_ceilingtest_a_crewmate_shadowed_by_its_own_private_copy_moves_and_the_copy_is_retiredtest_a_used_synced_row_with_no_identity_gets_one_and_moves,test_a_binding_without_a_member_id_is_left_alone_without_a_wordtest_a_used_synced_row_with_no_identity_gets_one_and_movestest_a_binding_on_the_file_stem_is_checked_under_its_declared_nametest_a_private_copy_that_changed_is_not_retiredtest_retirement_rescans_the_agent_snapshottest_a_used_row_that_cannot_move_is_not_given_an_identityset_modeactivation skips the checktest_activating_a_disk_spec_over_the_ceiling_ends_the_session_before_set_modetest_a_config_load_missing_a_file_still_checks_the_agenttest_the_spec_a_moved_crewmate_ran_on_is_still_checked,test_an_unreadable_ledger_checks_the_agent_rather_than_skipping_ittest_a_moved_stem_binding_is_checked_under_its_declared_nametest_a_refused_start_writes_no_withheld_recordtest_a_minted_row_whose_move_fails_before_publish_keeps_its_memorytest_a_refused_auto_approve_only_spec_writes_no_recordtest_a_private_copy_with_a_markdown_twin_is_not_retiredtest_a_retirement_whose_move_fails_puts_the_copy_back[lineage],[repoint]test_an_unreadable_ledger_checks_the_agent_rather_than_skipping_ittest_a_warm_session_that_inherits_the_spawn_agent_is_checked_before_the_request[create],[load]test_a_kas_runtime_is_not_refused_at_session_startautoApprovelist refusestest_empty_grant_lists_on_a_governed_server_are_not_refusedtest_a_hard_linked_markdown_file_does_not_refuse_a_json_starttest_only_a_host_that_reads_the_file_grants_is_refused[*]test_a_kas_session_from_that_spec_still_cannot_auto_approve_a_denied_toolRelated suites (392 files matching mate/memory_store/crewmate/member/fork/governance/kas/harness/capability/client): 15,989 passed; every failure left reproduces on unmodified
origin/mainon this Linux host (copilot launch goldens, a KAS config round-trip, an auto-improvement essential-source test, a sandbox mask test, a living-UI test).Manual verification
The measurement above was read from a live install's
config.json,~/.kiro/agents,~/.kiro/mates/agentsand fork lineage, read-only. No gateway was restarted against this branch, so the migration's live run, the retire step and the minting path were exercised only in tests. Not run on Windows or macOS: the retire step usesos.replacewithin one home, checked against source only.Screenshots / video
N/A: no UI change; the notice wording is server text.
Related Issues
Closes #25289. Depends on #25332.
Sibling sweep
Swept:
git grep -n "_atomic_json_write\|atomic_write" -- src/kiro_crew/agent_materialization src/kiro_crew/mate_config_migration.pySibling: src/kiro_crew/agent_materialization/fork_refresh.py -- changed here
Sibling: src/kiro_crew/agent_materialization/default_spec_commit.py -- not affected -- writes Crew's own primary spec only
Pattern harvest
Not generalizable: the defect was one pass treating a user-owned file as Crew's to govern;
test_governed_spec_tailalready pins the set of direct spec writers, now empty for user templates.Checklist
Contribution License Agreement
Contributed under the project's Apache-2.0 license (see CONTRIBUTING.md).