Repository navigation
fix(cards): stop listing template grants a new bot does not get - #41716
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the card no longer claims template grants, and the create route now writes the Bot's own file before publishing it, so the card stays true. Only the patch's own files read the removed helpers. Notes
[DESIGN-REVIEWED] 4924f43 Description read[DESCRIPTION-READ] 837aaa46a5b0cf71b73407b65f9f62b145eb308a95cd61c666cd28c0bd019508 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 card fix works because the route now publishes each new Bot already bound to its own file, which is the create order in What this change shipsInventory (8 items) — 8 justifiedIntent: the owner sees only grants a new Bot really gets, and is asked to acknowledge a widening only when one happens. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 4924f43 Description read[DESCRIPTION-READ] f849b17a44dde2c50eaad118ac3d6996936c84779161b758dbb5969c361edb8c That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
bolichen97
left a comment
There was a problem hiding this comment.
Review bot check on head 5e6ac8e8a8. I read both GPT 6.1 findings against the code on this head. Both hold, so I am asking for changes. The goal itself is right: on the success path the press writes the Bot its own minimal file, and the card should not claim template grants there.
-
Saved Create and Import cards can no longer Apply (F2, upheld). Every Create or Import card saved by an earlier build has
before = {"exists": ..., "inherited_auto_approve": [...]}(main always wrote the key, even as[]; Import also wroteinherited_reach). This head reads{"exists": ...}. At Apply,handlers/change_cards.pycomparescomparable_state(kind, current)withcomparable_state(kind, rec["before"]), andcomparable_state(change_cards_readers.py:416) drops nothing for these two kinds. So every such card returns409 changed_since_previewuntil it is previewed again (cards live 24 h,CARD_TTL_SECONDS). That contradicts the Backwards compatibility section, which says a saved card still works.
Fix: incomparable_state, forcatalog.CREWMATE_CREATING_KINDS, dropinherited_auto_approveandinherited_reachbefore comparing (keepexists). Add a test that applies a card whose storedbeforecarriesinherited_auto_approveand expects it to pass the check. -
The fallback path still runs the template, and the card no longer says so (F1, security-class, fenced).
adopt_own_file(mate_config.py) raisesMateConfigErrorwhen a user-level agent already has the Bot's name, and whenwrite_mate_configfails._eager_copy_mate_config(dashboard/agent_admin/crew_records.py) catches that and leaveskiro_agenton the template ("kept source pointer").member_chat_agent(mate_worker.py) then runs that template, with its bare@servergrants. Before this PR the card listed those grants and asked for the widening acknowledgement. Now it shows none, so on that path the card understates what the Bot runs without asking. The PR's premise ("the press does not grant them") holds only when the copy succeeds.
Fix, either of these:- (preferred) make the create fail closed: when
adopt_own_fileraises, refuse the create (or roll the binding back) instead of keeping the template pointer. A Bot then never runs on the template, and the card stays true with no grant row; or - keep disclosing on the path you can predict: if
user_agent_named(<new key>)is true at read time, return the template's grants as before, and make the write-failure path refuse the create.
Please add a test for the name-clash case.
- (preferred) make the create fail closed: when
Because finding 2 is security-class, the GPT lane keeps its block until a new head clears it, so this needs a code change, not an override. I'll re-review the next head.
AI-assisted, sent by Bolin Review bot
fb5d218 to
7054791
Compare
|
Re-reviewed 7054791 against 5e6ac8e (
One thing left before I approve (real-machine-verify, Reviewing): the "Create route (this head)" subsection is still marked Pending. Please add the three AI-assisted, sent by Bolin Review bot |
|
Re-reviewed 7054791. Both findings from my last review are fixed:
I approved the held workflow runs on this head. One ask before I approve (real-machine-verify, Reviewing: this head changes what the create route runs): the "Create route (this head)" section is still pending. Please add the three runs it lists on a real gateway at 7054791: a normal create, a create with the own-file folder read-only, and a create whose name a user-level agent already has. AI-assisted, sent by Bolin Review bot |
0798c7e to
11572af
Compare
|
Re-reviewed 11572af. The concurrent-create guard reads right ( Backend Tests (3.12, 6) fails
Once that's green I'll approve with auto merge. AI-assisted, sent by Bolin Review bot |
11572af to
1410dec
Compare
f70befe to
71d1125
Compare
The Create a bot and Import cards read the default bot template's bare @server grants through template_auto_approved_servers and listed them as "Runs without asking" / "Your bots use these without asking", marking the press as a widening change that asks for an acknowledgement. But the press writes the new bot its own file with empty additions (write_mate_config), and no template's servers reach it. So the row named grants the bot never gets, and the acknowledgement asked about a widening that does not happen. The state read for both cards no longer reads the template, so a new card has no such row and no widening risk. template_auto_approved_servers and _server_reach, used only by that read, are removed. The plan builders still render a stored snapshot that carries inherited grants, so a card saved by an earlier build rebuilds to the plan it stored and keeps its history and Undo, and comparable_state drops the two old keys for both creating kinds, so pressing such a card no longer answers 409 changed_since_preview. The card can say "no template grants" only if a created bot can never be left on its template. The create route used to publish the binding on the template and adopt the bot's own file afterwards, best-effort; a failed adopt left the bot running the template's grants. The route now writes the bot's own file before publishing and publishes the binding on it, as the owned-config RFC describes. A write that fails refuses the create (409 bot_config_unwritable) with nothing published, and so does a user-level agent of the bot's name that appears after the first name check (409 template_name_in_use), since it would win over the bot's own file. Writing the file first means a create that loses the name race to another (the CLI publishes, then writes) could replace the winner's file, owner edits included. The pre-publish write now re-reads config.json under the same owner lock every Bot-file write takes, and refuses a name already bound there (409 agent_exists), leaving that file as it is. It reads config.json and config.local.json through read_config_for_update, so a file that cannot be read refuses the write too: it may bind the Bot. That refusal is the one memory provisioning gives the same roster (409 member_memory_unavailable). A create that fails after the name check puts the Bot's file back as it was. capture_mate_config reads, under the owner lock and before the write, the file's bytes (or that there is none), its owners.json entry and whether the dispatch snapshot names it; on any failure, restore_mate_config reconciles all three to that, rewriting only what differs, unless config.json binds the name by then. So a deleted Bot's retained file survives a failed re-create, a new Bot's file goes, and it holds whichever step failed: the file write, the owner entry, the snapshot publish, provisioning, or a shutdown cancelling the request. Closes kirodotdev#41634
|
@kellenji The one red on this head is not from your change. Backend Tests shard 7 fails Please rebase onto current AI-assisted, sent by Bolin Review bot |
71d1125 to
4924f43
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed head 4924f4347a, rebased onto current main (4 behind) as asked. The fresh merge includes the #45124 fix for the autonudge test that was red on the old merge, and the change itself (template grants a new bot does not get are no longer listed, with the async_wait_until rerun) is the one I reviewed. Approving, which replaces my earlier change request.
AI-assisted, sent by Bolin Review bot
Problem / Motivation
Goal: the Create a bot and Import cards show only what the new bot will really run without asking, and ask for the widening acknowledgement only when the press really widens something.
Both cards read the default bot template's bare
@<server>grants (template_auto_approved_serversinsrc/kiro_crew/dashboard/change_cards_readers.py). The Create card lists them as "Runs without asking", and the Import card lists them as "Your bots use these without asking". Either way the press is marked as a widening change and the owner must tick the acknowledgement.The press does not grant them. It writes the new bot its own file with
"allowedTools": []and"mcpServers": {}(write_mate_configinsrc/kiro_crew/mate_config.py), and no template's servers reach it.Why it matters
The owner is asked to accept grants that never happen. A card that claims a widening on every create teaches people to tick the box without reading it, which weakens the acknowledgement for the cards that really do widen something.
Not a goal
What changed (motivation → approach → change)
crewmate.createandcrewmate.importstill read the template'sallowedTools, from a time when a new bot was bound to the template. Today the press writes the bot its own minimal file._sync_read_stateno longer reads the template. Its creating-kind snapshot is{"exists": ...}, so a new card has no grant row and no widening risk.template_auto_approved_serversand_server_reachwere used only by that read, so they are removed, along with their re-exports fromkiro_crew.dashboard.change_cardsand its facade inventory entry.build_previewfor both kinds still rendersinherited_auto_approve/inherited_reachwhen a stored snapshot carries them, so a card saved by an earlier build rebuilds to the plan it stored.comparable_statedrops those two keys for both creating kinds. Without that, pressing a card saved by an earlier build compared its oldbeforewith today's read and answered409 changed_since_previewalthough nothing had changed.POST /api/agentspublished the bot bound to its template, then adopted the bot's own file best-effort (_eager_copy_mate_config→adopt_own_file). If that adopt failed (a write failure, or a user-level agent of that name appearing in between), the bot kept running on the template with the template's grants, which the card would no longer show.write_mate_config) BEFORE publishing, and publishes the binding already pointing at it (kiro_agent = <name>), as the owned-config RFC's create flow describes (docs/request-for-change/rfc-mate-owned-agent-config.md§5.4: write the file, then the binding withkiro_agent = <id>). A write that fails refuses the create with409 bot_config_unwritable, inside the block that already retires the new memory and workspace on any failure, so nothing is published.template_name_in_use). Right before the own-file write it now checksuser_agent_named(name)again, and a clash that appeared in between also answers409 template_name_in_usewith nothing published. Such an agent would otherwise win over the bot's own file.persist_member_configanswersagent_exists. The pre-publish write (write_mate_config(name, unbound=True)) therefore re-readsconfig.jsonunder the owner lock every Bot-file write already holds, and refuses a name already bound there with409 agent_exists, leaving that file as it is. It readsconfig.jsonandconfig.local.jsonthroughread_config_for_update, which fails closed: a file that cannot be parsed, or anagentssection that is not an object, may bind the Bot, so the write is refused and the file kept, with the refusal memory provisioning gives that roster (UnknownMemoryStore,409 member_memory_unavailable). Every other create writes its file after publishing and waits on that lock, so a file with another Bot's additions always has its binding on disk by then.capture_mate_configreads under the owner lock the file's bytes (or that there is none), itsowners.jsonentry (or none) and whether the dispatch snapshot names it. On any failure,restore_mate_configreconciles all three to that capture under the same lock, rewriting only what differs, so a step that never ran changes nothing. It does nothing whenconfig.jsonbinds the name by then (another create won it), cannot be read, or another instance owns the file. A deleted Bot's retained file (deleting keeps it) therefore survives a failed re-create, and a new Bot's file, owner entry and snapshot name (retract_mate_agent) go._eager_copy_mate_configstill runs afterwards and answersalready_owned, so its "kept source pointer" fallback cannot leave a created bot on the template. The mate-tools grant sees the bot on its own file, as before.Backwards compatibility
Compatible: a new card simply has no grant row, and a card saved by an earlier build still rebuilds and now applies. A create that succeeds ends in the same state as before (bound to its own file; the eager adopt used to repoint it a moment later). The one new refusal is a create whose own file cannot be written, which used to succeed with the bot left on its template.
Reader: src/kiro_crew/change_card_catalog_plans.py:build_preview (crewmate.create) -- crew page, chat, app -- still reads
inherited_auto_approvefrom the stored snapshot, so a saved card rebuilds unchanged (test_crewmate_create_shows_inherited_auto_approvals_and_asks_to_widen)Reader: src/kiro_crew/change_card_catalog_plans.py:_import_preview (crewmate.import) -- crew page, app -- still reads
inherited_auto_approveandinherited_reachfrom the stored snapshot (test_the_card_lists_every_part_and_creates_in_normal_with_no_grant)Reader: src/kiro_crew/dashboard/change_cards_records.py:rebuild_record -- crew page -- rebuilds a saved card from its saved
before, which still carries the keys, so the derived rows still matchReader: src/kiro_crew/dashboard/handlers/change_cards.py:_run_card_step conflict check -- crew page, chat, app -- compares through
comparable_state, which now ignores the two old keys (test_a_card_saved_with_template_grants_still_applies)Reader: website/src/cards/CardChanges.tsx:FIELD_LABELS / approval hint -- crew page -- renders
template_auto_approveandimport_approvalrows only when a card has them; a new card has noneReader: website/src/cards/ChangeCard.tsx:template_auto_approve row lookup -- crew page -- finds no row on a new card and falls through as for any card without one
Reader: src/kiro_crew/dashboard/change_cards.py:template_auto_approved_servers, _server_reach -- release -- removed from the facade;
git grepon main finds no other caller in src, apps, skills or packagesReader: src/kiro_crew/member_mate_tools.py:_grant -- crew page, chat -- reads the published binding; it now names the bot's own file from the start, the state it already required (
binding.kiro_agent == member)Tests
test_a_template_grant_the_new_bot_never_gets_is_not_shown_or_acknowledged[crewmate.create|crewmate.import]: with a default template that grants@slack-mcpand@builder-mcp, the state read is{"exists": False}, and the preview has noauto_approve,template_auto_approveorimport_approvalrow and is not a widening risk.test_a_card_saved_with_template_grants_still_applies[crewmate.create|crewmate.import]: a card stored withinherited_auto_approve/inherited_reachinbefore(and a widening risk) is pressed against today's{"exists": False}read, and the create runs (200) instead of409 changed_since_preview.test_an_own_file_that_cannot_be_written_refuses_the_create: whenwrite_mate_configraisesMateConfigError,POST /api/agentsanswers409 bot_config_unwritableand persists nothing.test_a_name_clash_that_appears_after_the_first_check_refuses_the_create:user_agent_namedis false at the first check and true at the write. The create answers409 template_name_in_use, writes no own file and persists nothing.test_a_bot_published_after_the_first_check_keeps_its_file:config.jsonalready binds the name and its own file holds the owner's edit. The create answers409 agent_exists, persists nothing and leaves the file byte-identical.test_a_create_that_lost_the_race_leaves_the_winners_file(test_mate_owned_config.py):write_mate_config(name, unbound=True)writes when the name is unbound, and raisesMemberAlreadyExistswithout touching an edited file onceconfig.jsonbinds it.test_a_roster_that_cannot_be_read_refuses_the_write[*]: with a truncatedconfig.json, or one whoseagentsis a list, the write raisesUnknownMemoryStore("configuration is unreadable") and the owner's edited file is kept.test_private_creation_refuses_degraded_config_but_allows_absent_memoryagain answers409 member_memory_unavailablefor those rosters.test_a_create_that_fails_at_any_step_leaves_the_bot_file_as_it_was[step-seed](14 cases): a failure is injected at each step (the Bot file write, theowners.jsonwrite, the snapshot publish,provision_member_workspace, and a cancel of the request while the write is in flight), each with the key's file absent, a deleted Bot's customised file with its owner entry, and the file without one. The file's bytes, the owner entry and the snapshot name end exactly as they were. (The owner write runs only when the entry is missing, so that step has no case with it seeded.) Againstf70befe404's source, the 5 owner-write and snapshot-publish cases fail;prove.py --base f70befe404reports PROVEN.test_builtin_kirocrew_is_a_legal_choice,test_unknown_template_warns_and_still_creates: now expect the persisted binding to name the bot's own file.test_import_shares_the_create_state_read_and_partial_line: the import and create kinds share one state read.test_template_auto_approved_servers_reads_bare_grants_onlyandtest_an_inherited_server_row_says_what_the_server_reacheswith the helpers they tested.Proof: PROVEN test/test_api_agents_create_template.py::TestExplicitTemplateStillWorks::test_builtin_kirocrew_is_a_legal_choice, test/test_api_agents_create_template.py::TestExplicitTemplateStillWorks::test_an_own_file_that_cannot_be_written_refuses_the_create, test/test_api_agents_create_template.py::TestExplicitTemplateStillWorks::test_a_name_clash_that_appears_after_the_first_check_refuses_the_create, test/test_api_agents_create_template.py::TestExplicitTemplateStillWorks::test_a_bot_published_after_the_first_check_keeps_its_file, test/test_api_agents_create_template.py::TestExplicitTemplateStillWorks::test_a_create_that_fails_at_any_step_leaves_the_bot_file_as_it_was[file-none] (head 4924f43)
prove.py names at most 5 tests.
test_a_card_saved_with_template_grants_still_applies[*]also fails with main'ssrc/(checked in a separate worktree: both cases answer409 changed_since_preview).Gate proof: tree 556d0f81fb2a; ran 26; skipped none
Related backend tests (
scripts/local-gate.py --base upstream/main): 139,777 passed, 38 failed. Every one of the 38 also fails onupstream/main(a00219d) on this host, run the same way: missingboto3and SageMaker credentials, the KAS bundle and engine pins, identity and xdist helpers. None touches this diff. Facade, mirror and member-memory suites (test_facade_mirror_guards,test_facade_mirror,test_facade_bindings,test_facade_shared_checks,test_member_memory_creation_capability,test_member_memory_publication,test_mate_worker_kit): 599 passed.test_wait_discipline_ratchet.pyandtest_flake_pattern_ratchet.pypass in full: the cancellation test waits withasync_wait_until(started.is_set)andasync_wait_until(handlers[0].done), so it has no fixed sleep and parks no pool thread, and its worker asserts the result of its oneEvent.wait. The frontend related set was not run on this host (no vitest installed); CI runs it. The diff touches no file underwebsite/.Manual verification
See Real-machine verification.
Real-machine verification
Cards (head
5e6ac8e8a8, before the create-route change)Machine: Linux 5.10 x86_64 (Amazon Linux 2), 2026-11-24 01:31 UTC, run by a person from a script. Before:
mainat724c07dfff. After:5e6ac8e8a8.For each commit, in a temporary worktree with its own
HOME,KIROCREW_HOMEandKIRO_HOME:KIROCREW_PROFILE=standalone KIROCREW_HOME=<data home> KIRO_HOME=<data home>/kiro KIROCREW_PORT=<free port> PYTHONPATH=<worktree>/src kirocrew gateway --no-crons --no-tunnel.ss -ltnshows it listening on loopback only.kirocrew token --port <port>.@rmv-demogrant to the default bot template,<data home>/kiro/agents/kirocrew.json, keeping what the gateway wrote.POST /api/members/importwith one minimal.crewmatefile (manifest, emptyagent.json, rules, goal, no crons), and print the card's risk and rows.POST /api/cards/<id>/cancel, HTTP 200 both times), so no bot is created. Afterwards the agents dir holds only the gateway's own specs.main724c07d)HTTP 200,crewmate.importcardHTTP 200,crewmate.importcardriskwidennormaltemplate_auto_approve/ "Your Bots use these without asking" /[{"name": "rmv-demo"}]import_approval/ "Approval" /normalapproval_mode/ "Approval" /normalThe approval row's key is expected to change.
_import_previewusesimport_approvalonly when an inherited-grant row follows it, andapproval_modeotherwise. That is main's own behaviour for an import with no inherited grants (test_the_card_lists_every_part_and_creates_in_normal_with_no_grant,barecase). The label ("Approval") and the value the create sends (normal) are the same. Only the hint changes: the import-specific hint written for the grant row is replaced by the standard hint fornormal.Real-machine verification (review round)
Create route,
POST /api/agents. Machine: Linux 5.10 x86_64 (Amazon Linux 2), 2026-11-25 03:17 UTC, run by a person from a script. Before:mainat8ce0c6ca2a. After: this head,0798c7ee73.For each commit, in a temporary worktree with its own
HOME,KIROCREW_HOMEandKIRO_HOME(KIROCREW_PROFILE=standalone), a gateway runs from that worktree's code on a free port, listening on loopback only. Each case sendsPOST /api/agents {"name": "<case>", "kiro_agent": "kirocrew"}, then prints the reply, the saved binding and whether the bot's own file<KIRO_HOME>/mates/agents/<name>.jsonexists:rmv-ok), thenDELETE /api/agents/rmv-ok.<KIRO_HOME>/mates/agentsischmod 555(dr-xr-xr-x), so the own file cannot be written (rmv-ro).<KIRO_HOME>/agents/rmv-clash.jsonalready has the bot's name (rmv-clash).Cleanup: the script stops the gateway by the PID it started and removes the worktree. It reported both clean.
main8ce0c6c)HTTP 200; bindingkiro_agent='rmv-ok'; own file existsHTTP 200; bindingkiro_agent='rmv-ok'; own file existsHTTP 200; bindingkiro_agent='kirocrew'(left on the template); own file missing; logBot rmv-ro: Bot config copy failed; kept source pointerHTTP 409 bot_config_unwritable(could not write Bot config for 'rmv-ro' at …/mates/agents/rmv-ro.json: [Errno 13] Permission denied); no bot published; own file missingHTTP 409 template_name_in_use; no bot publishedHTTP 409 template_name_in_use; no bot publishedrocase)On
main, a create whose own file cannot be written still publishes the bot, bound to the template, so it runs the template's grants. On this head that create is refused and nothing is published.The run predates the bound-name refusal and the clean-up of a create that fails after the write (both above). The refusal applies only to a name
config.jsonalready binds or a roster that cannot be read, and the clean-up only after a successful write followed by a failure; none of the three cases reaches either (inrothe write itself fails), so their replies and files are unchanged. Both are covered by the tests above.Related Issues
Closes #41634
Sibling sweep
Swept: git grep -n -e "allowedTools" -e "kiro_agents_dir" -- src/kiro_crew/dashboard/change_cards_readers.py src/kiro_crew/change_card_catalog_plans.py
Sibling: src/kiro_crew/dashboard/change_cards_readers.py -- not affected -- no other card state read takes grants from a template spec;
crewmate.updatereads the bot's own config.Swept: git grep -n "adopt_own_file" -- src
Sibling: src/kiro_crew/cli_commands_agent.py:333 -- not affected --
kirocrew agent createraises no card, and on a failed adopt it already prints that the bot keeps running as its template, so nothing is under-disclosed there.Pattern harvest
Not generalizable: one state read kept describing an older bot-creation model after creation moved to a minimal own file, and the create route kept a best-effort step whose failure brought that older model back. Both are fixed at their single site here.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commitsContribution License Agreement
Contributed under the project's Apache-2.0 license.