Repository navigation
feat: carry a crewmate's template policy onto its worker - #28501
Conversation
0cda84f to
81e945b
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Commenting at 81e945b, on one design point, not a blocker on the rest.
Carrying a template's restrictions onto the chat looks right to me. Its permissions deny and ask rules, its excludedTools and its servers' disabledTools should reach the conductor. The decision doc's reason holds: the conductor reads the crewmate's input first, so a limit that narrows only the worker does not hold where it matters.
The grants are the part I would not carry. The decision doc says:
Granting the conductor the template's auto-approvals is a deliberate widening the owner accepted: the user already approved those tools when they wrote the template.
The chat reads untrusted channel input before any human sees it. A template's grants (toolsSettings entries such as allowedCommands and allowedPaths, and permissions allow rules) were approved for the worker, which acts on a task the conductor has already checked. In the chat they would auto-approve on input no one has looked at yet. I would keep the chat's grants at its own level. In apply_conductor_overlay, the overlay would carry only the narrowing parts: deny and ask rules, and excludedTools. The allow rules and the toolsSettings grants would stay with the worker.
A test would pin it: a crewmate whose template grants a tool by allowedCommands or an allow rule, where the worker runs it without asking but the chat still asks.
81e945b to
e6bf8d6
Compare
UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)UX-level review of UX-Verdict: PASS cannot evaluate: missing screenshots of the new "Hooks, permissions and tool settings (worker)" preview group and the two new refusal sentences. The blind read was not performed because the PR attaches no image. Evidence gaps
Notes
[UX-REVIEWED] 9b2fc7c Description read[DESCRIPTION-READ] 4f2093a89ca49850f7c178734e39eaf95a54cc04d02fbbcb4951bc7008787b83 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)Design-level review of Design-Verdict: PASS cannot evaluate: missing screenshot of the Add abilities preview showing the new "Hooks, permissions and tool settings (worker)" group and the field-naming refusal sentence. The backend design itself raises nothing that blocks. BlockersThe reshaped worker-kit preview has no rendered evidence Notes
[DESIGN-REVIEWED] 9b2fc7c Description read[DESCRIPTION-READ] bbda010ba09d11002f33c84a98ed05dd9c9fd2868d7c0d347a66ee53f9032781 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: the main change gives back what #26881 reports was lost, and each refusal it adds comes from what KAS actually enforces. Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: a crewmate owner can add abilities from an agent that has hooks, permission rules or tool limits, and the worker keeps those limits. This is a FIX for #26881.
There are more items than these 10. The rest are small, such as [FIRST-PRINCIPLES-REVIEWED] 9b2fc7c Description read[DESCRIPTION-READ] 62d2fa17b4198712c178ad2a5319fa121e4f64893484e23df91c1591ab85f6d9 That sha256 names the PR description this verdict read. Recompute it with |
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: |
e6bf8d6 to
4e3a9ac
Compare
4e3a9ac to
cf6c726
Compare
|
Disposition for the Opus 5.5 review of BLOCKING -- BLOCKING -- decision entry's decider is not in MAINTAINERS.md (needs a maintainer). Not a code change: this needs a listed maintainer to restate the decision, including the conductor grant widening, on this PR. The entry's Evidence will then cite that comment. Since this review, Also from First Principles: the |
d4e789e to
9108c7a
Compare
|
Scope narrowed at the owner's request (@buluoray): this PR now carries a template's Removed: the conductor projection ( The owner asked for the |
|
@bolichen97 thanks for tracing it. All three findings on 1. Live workers keep the old KAS batch (your point 2, GPT): confirmed as you traced it. Fixed by reusing the existing worker-reload path, 2. Hooks the worker base already holds are copied (Opus): confirmed. On this host 3. An allow KAS drops beside |
bolichen97
left a comment
There was a problem hiding this comment.
Thanks, both points from my last review are fixed at 9bf878d, with tests:
_carry_policynow runswithout_held(carried, base)first, so hooks, rules and tool settings the worker base already holds are no longer copied or judged against the backend (test_hooks_the_worker_base_already_holds_are_not_copied,test_a_template_holding_only_the_bases_hooks_is_added_off_kas).apply_reportingreturns whether the file's policy changed, and the handler then callscrewmate_worker_reload.schedule_reload_workers, so a live worker is reloaded onto the new restriction (test_adding_a_deny_reloads_the_crewmates_idle_worker).
One new problem, flagged by both Opus and GPT (GPT's adjudicator upheld it), and it holds against the code. I'm still requesting changes:
The new derivable-allow refusal rejects ordinary templates.
_layer_permissions (mate_spec_policy.py:184-192) adds every allow that permission_allow_derivable matches to lost whenever the target has allowedTools. But agent._write_derived_permissions writes a permissions block on governed specs, and its rules come from allowed_tools_to_permissions: bare web_fetch/web_search/subagent/skill and literal-server mcp allows, exactly those shapes. _plan calls uncarried_restrictions(source) at line 326 on the whole template, before _carry_policy subtracts what the base holds. So adding abilities from a forked, published or default-derived template fails with template_restrictions_uncarried. Those allows are already carried through the template's allowedTools.
Suggested fix: when allowedTools is present, drop derivable allows (that list already carries them) instead of refusing. At minimum, skip the rules allowed_tools_to_permissions(source["allowedTools"]) produces, and apply without_held before uncarried_restrictions judges the source. A test that adds a template built through build_agent_config (with its derived permissions block) would pin it.
CI note: Frontend Tests (2) failed in i18nAllLanguagesEntry.test.ts ("'./integration/setup.ts' reaches no catalog beyond English", 19 s). That doesn't look tied to this diff.
9bf878d to
57baa14
Compare
|
Disposition for the GPT 6.1 and Opus 5.5 findings on
|
57baa14 to
6779c29
Compare
|
Disposition for the GPT 6.1 findings on
|
6779c29 to
f0ef57c
Compare
|
Owner decision (@buluoray, repo admin), reaffirmed for this PR:
Recorded in |
|
Checked at f0ef57c: the allow-rule regression from my last review is fixed, with tests. On the two lane findings for this head: GPT F2 (a rule the parser drops passes Opus (the decision record isn't backed by a maintainer). That's a fair process point under GPT F1 (glob-text coverage) was downgraded by its adjudicator. I'm not blocking on it. |
|
Maintainer decision: a crewmate's worker carries its template's policy (permissions, hooks, toolsSettings), net of what the worker already holds; the crewmate's chat stays on the stock conductor and gets none of it. Carrying limits to the chat is a possible follow-up, not part of this PR. |
|
/ai-review override fable f0ef57c owner-decision: agent: the maintainer recorded the policy-carry decision on this PR at #28501 (comment), so the decision entry is now backed by a maintainer statement. |
Human judgment recorded@bolichen97 recorded a owner-decision release (class
This decision applies only to this commit. A new push requires a new judgment. |
Adding an agent's abilities to a crewmate refused any agent that set hooks, permissions or toolsSettings, because the worker kept none of them. Crewmates the upgrade moved off such an agent could not get its tools back. The kit copy now layers the agent's hooks, permission rules and tool settings into the crewmate's file exactly, and the worker merge carries them, never wider than the agent declares. Crew fires the worker session's merged hooks on KAS. A field that cannot land exactly, or a crewmate whose worker is off KAS, is refused with an error naming the field. The crewmate's chat keeps running the stock conductor spec. Closes #26881
|
/ai-review override gpt f0ef57c false-positive: agent: F2 does not hold. parse_user_permissions returns None for the whole block when any rule has more than 64 patterns, so permissions_block_readable is False and layer_policy names permissions as uncarried: it fails closed. Code path: #28501 (comment) |
Human judgment recorded@bolichen97 recorded a false-positive release (class
This decision applies only to this commit. A new push requires a new judgment. |
f0ef57c to
9b2fc7c
Compare
|
Disposition for the GPT 6.1 findings on
|
bolichen97
left a comment
There was a problem hiding this comment.
Approving at 9b2fc7c. I re-read each round's delta, and the earlier fixes all hold:
- Carried hooks fire on chat, sub-agent and dedicated worker turns (
provider_session_key). - Restrictions KAS can't enforce are refused by name (
tools_settings_unenforced, theCARRIED_TOOLS_SETTINGSallowlist,availableAgentsin any form). - The shell alias and the hook cap are enforced.
- Only what the template adds is carried (
without_held). - A policy write reloads the crewmate's live workers (
schedule_reload_workers).
The allow-rule regression is fixed: test_adding_a_governed_template_with_its_generated_block_succeeds adds an ordinary template through preview and apply.
This head:
- Replaces glob-text matching with
_pattern_contains. That function proves coverage only for the same pattern or a whole-server grant, and refuses everything else. A parametrized test covers it. - Cites the maintainer decision comment in the decision record.
It stays worker-only: the crewmate's chat runs the stock conductor spec, per the decision.
CI at this head: 85 ok, and the only red is PR Readiness. Every AI lane passes, as do E2E, Integration, CodeQL and the other non-shard jobs.
Suggested follow-ups, not blockers:
- A test that a template whose
permissionsrule carries more than_MAX_PATTERNS_PER_RULEpatterns is refused aspermissionsbylayer_policy.test_governed_spec_tail.pycovers the cap forgovern_spec, but not this path. - Carrying limits (not grants) to the crewmate's chat.
Add abilities refused a template whose hooks, permission rules or tool settings equal ones the crewmate's worker base already holds, with template_restrictions_uncarried. The preflight layered the template's whole policy before anything removed what the base holds, so a held fs_write allowedPaths/fallbackAction entry hit the allowlist. The preflight now drops held policy with without_held before layering, as the kit copy already does, and still compares the full template's restrictions with the merged worker. An unreadable base still refuses. Mirrors #29392 on main (same diff). Refs #28501
…9378) Adding an agent's abilities to a crewmate refused any agent that set hooks, permissions or toolsSettings, because the worker kept none of them. Crewmates the upgrade moved off such an agent could not get its tools back. The kit copy now layers the agent's hooks, permission rules and tool settings into the crewmate's file exactly, and the worker merge carries them, never wider than the agent declares. Crew fires the worker session's merged hooks on KAS. A field that cannot land exactly, or a crewmate whose worker is off KAS, is refused with an error naming the field. The crewmate's chat keeps running the stock conductor spec. Closes #26881 (cherry picked from commit 0354d5f) Conflict: src/kiro_crew/docs/agent-spec-fields.md (hooks row). Kept the release text and added only this change's crewmate sentence.
Problem / Motivation
Goal: A crewmate can take abilities from an agent that sets hooks, permission rules or tool settings, and its worker then runs under exactly those fields on KAS; the crewmate's own chat keeps the stock conductor.
Since #23010 split each crewmate into a conductor (its chat) and a worker, Add abilities refuses any agent that sets
hooks,permissionsortoolsSettingswith "That agent sets permission rules, tool settings or hooks the worker can't keep. Choose another one." Crewmates the upgrade moved off such an agent lost its tools and cannot take them back (#26881).Why it matters
Every user whose crewmate was built on an agent with hooks, deny rules, path or command limits is stuck: they cannot pick that agent again, so the crewmate stays without the tools it had, and the worker that runs those tools has none of the agent's limits.
Not a goal
rfc-mate-owned-agent-config.md§5.1, unchanged).What changed (motivation → approach → change)
Symptom: the kit copy refuses a template through
uncarried_restrictions, becausemerge_worker_specdroppedhooks,permissionsandtoolsSettings.Change:
mate_spec_policy.py.layer_policyadds each hook beside the base's, each permission rule beside the base's rules, and copies atoolsSettingsentry whole for a tool the base sets nothing for. Anything that cannot land exactly (an entry for a tool the base sets differently, apermissionsblock KAS would refuse whole) raisesSpecPolicyUncarried, aWorkerKitUnreadable, naming the field. Nothing is widened past what the template declares.toolsSettingsis an allowlist (CARRIED_TOOLS_SETTINGS): onlydeniedCommandsandallowedCommandson the shell tool (execute_bash/shell),deniedPathson the read and write tools (fs_read/read/glob/grep,fs_write/write), andweb_fetch.blockedare carried, each only when KAS's own translation keeps every entry (kas_tool_view.tools_settings_unenforced). Every other key or tool, in any form (allowedPaths,fallbackAction,denyByDefault,trusted,subagent.availableAgentseven when empty), is refused by name. A second spelling of a tool the file already sets differently (shellbesideexecute_bash), or a hook past the 20 Crew fires, is refused too.worker_additionskeeps the file's policy andmerge_worker_speclayers it.mate_spec_policy.without_helddrops every hook, permission rule and tool setting the worker base already holds (Crew's own audit hook, the user'skiro_hooks) before the kit copy layers and judges the rest, so those are not frozen into the crewmate's file and do not trip the non-KAS refusal.allowrule the worker would silently lose is refused by name (permissions rule N (allow <capability>)). It is refused only when all four hold: (1) the check runs on the merged worker spec (layer_policy(..., worker=True)frommerge_worker_spec), never on the crewmate file alone; (2) the worker default does not already hold the rule; (3) KAS's projection would drop it, because anallowedToolslist could express it (kas_tool_view.permission_allow_derivable); (4) the worker's own grants do not already cover it: itsallowedToolsplus each governed serverautoApproveverb, the same input KAS's projection derives grants from (kas_tool_view.allow_granted_by_spec). Apermissionsblock whoserulesis not a list is refused aspermissions. So a governed template's generated block, which mirrors its ownallowedTools, is accepted, and scoped or excluded allows travel.crewmate_worker_reload.schedule_reload_workers(a busy one at its turn end), since a live KAS session keeps the permission batch it registered.spec_hooks._agent_specwith the session key, throughmate_worker.mate_service_scope_spec, the path skill scope already uses), so carried hooks actually run on the worker. For the conductor that path still returns the stock spec.resolve_worker_spec(refuse_spec_policy=True)(called fromacp/session_mcp_crewmate._crewmate_worker_specon the mirrored hosts) refuses a worker whose crewmate file sets these fields, naming them.mate_worker_kit._carry_policy): copies the fields into the file, previews each as ahooks/permissions/toolsSettingsrow (one per entry, labelled plus a digest so two entries sharing a label each get a row), and refuses with adetailnaming the field:template_restrictions_uncarried,template_policy_backend_unsupported. The dashboard sentence names the field (workerKitErrors.ts, 12 locales); the preview group reads "Hooks, permissions and tool settings (worker)"._crewmate_worker_specmoved toacp/session_mcp_crewmate.pyto keepsession_mcp.pyunder the line cap; the old import path still works.docs/decisions/2026-11-02-a-crewmates-worker-carries-its-template-policy.md. Specs updated:crew-mode.md,agent-spec-fields.md.Backwards compatibility
Compatible: every template that was accepted before is still accepted with the same file written; a template that was refused for hooks/permissions/tool settings is now accepted on KAS or refused with a narrower, named reason. Crewmate files with none of the three fields produce the same worker spec as before. The crewmate's chat is unchanged.
Behaviour that changes for existing crewmates: a crewmate whose file already holds
hooks,permissionsortoolsSettings(only possible by hand-editing it; the kit copy refused them and the migration never writes them) now has its worker run under them on KAS, and on a non-KAS worker backend the worker is refused at start, naming the fields, instead of running without them.mate_config_migration.pychanges how restrictions are compared (onetoolsSettingsentry per tool, and a policy field the worker now carries no longer counts as lost). Readers on origin/main:Reader: src/kiro_crew/mate_worker_kit.py:_plan -- crew page -- calls
uncarried_restrictions, which now returns only fields that cannot land exactly;test_mate_spec_policy.py::test_a_template_setting_the_worker_base_sets_differently_is_refused_by_nameReader: src/kiro_crew/mate_config_migration.py:plan_move -- release -- startup migration via
migrate_existing_crewmates; the file it writes carries no policy, sodifferencesreports the same losses as before;test_mate_config_migration.pyReader: src/kiro_crew/mate_config_migration.py:dry_run -- release -- default-template file path, same
differencescall;test_mate_config_migration.pyReader: src/kiro_crew/mate_config_migration.py:dropped_restrictions -- release -- iterates
toolsSettingskeys, which per-tool entries still yield one by one;test_mate_upgrade_notice.pyReader: src/kiro_crew/mate_config_migration.py:_fallback_keeping_limits -- release -- unreadable-agent fallback, same
differencescall;test_mate_migration_real_kirocrew.pyTests
test/test_mate_spec_policy.py: each allowedtoolsSettingskey is shown to take effect (the four denies become KAS deny rules throughtools_settings_to_permissions;allowedCommandsis answered by Crew's gate throughcrew_answered_commands), and every other key or tool is refused by name (allowedPaths,fallbackAction,denyByDefault,trusted,availableAgentsempty or not,trustedAgents, an unknown tool, a non-object entry), as are anallowedCommandsentry the gate cannot answer, a second spelling of a tool, and a hook past the cap; layering is otherwise exact or refused naming the field; the worker carries the fields and gains no allow the template lacks; an off-KAS worker is refused naming the fields; the kit copy previews and writes the fields and refuses off KAS and on a tool-setting conflict with the worker base; two entries sharing a label each get a preview row; KAS worker turns, sub-agent worker turns (shared and dedicatedspawn_run(keep=True)providers) and stale-session checks read the worker session's merged spec.New:
test_a_crewmates_chat_runs_the_stock_conductor_whatever_its_file_setsinstalls the real stock conductor (service_agents._install_mate_conductor_agent) beside a crewmate file with hooks, permissions and tool settings, and asserts thatmate_service_scope_spec,_crewmate_worker_spec(policy honoured or not) andspec_hooks._agent_specall return the stock conductor unchanged. Mutation check: removing the base-held subtraction, removing the dropped-allow check or any of its already-held, already-granted and worker-only conditions, never reloading, or always reloading each turns a test red; removing the allowlist, removing the KAS-translation check, dropping the sub-agent turn's session key, or reading it only from the provider and not its_clienteach turns a test red. Routing the conductor through the worker merge inmate_service_scope_spec, or through_crewmate_worker_spec, each turns it red; restored green.Blast radius: every test file that names a touched symbol plus
test_harness_parity.py,test_kas_agents.py,test_flake_pattern_ratchet.py,test_chat_runner_composition_contract.pyandtest_error_code_contract.py: 2923 passed, 14 skipped. Frontendsrc/components/crew/andsrc/i18n/: 1217 passed.Proof: not provable -- other: the change is a new carrying mechanism, not a reverted hunk; the mutation checks above stand in for it.
Manual verification
Still required: add an agent with a
preToolUsehook and adenyrule to a crewmate on KAS, then confirm the hook fires and the deny holds in a worker it opens, and that the crewmate's chat behaves as before.Screenshots / video
Captured from this PR's built SPA (head
d4e789e6, before the rebase onto main; no frontend change since), served on 127.0.0.1 with/api/**stubbed bywebsite/scripts/lib/stub-dashboard-api.mjs. The worker-kit payloads are this PR's ownmate_worker_kit.previewoutput for a sample template, not hand-written.Add abilities preview: the new "Hooks, permissions and tool settings (worker)" group, one row per hook, rule and tool setting.
The same template on a crewmate whose worker is off KAS is refused, and the message names the fields.
The images live on the separate branch
crew/slack/pr28501-screenshots, not on this PR's branch.Related Issues
Closes #26881
Follows #23010
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.