Skip to content

fix(crew): skip policy the worker base holds in the add preflight - #29392

Closed
buluoray wants to merge 1 commit into
mainfrom
crew/slack/fix-uncarried-without-held
Closed

buluoray wants to merge 1 commit into
mainfrom
crew/slack/fix-uncarried-without-held

Conversation

@buluoray

@buluoray buluoray commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Add abilities accepts a template whose hooks, permission rules or tool settings the crewmate's worker base already holds, instead of refusing it with template_restrictions_uncarried.

#28501 lets a crewmate take an agent's hooks, permission rules and tool settings. Its add preflight (uncarried_restrictions) layers the template's whole policy onto the worker base before anything removes what the base already holds. So a template that repeats the base's own fs_write allowedPaths / fallbackAction is refused, even when the user only wants its MCP server. Found by the GPT review lane on the 0.12 forward-port, #29378.

Why it matters

Users whose worker base carries tool limits cannot add a template that carries the same limits. The template stays refused until its settings change, with no workaround in the dashboard.

Not a goal

  • No change to what is carried onto the worker: the kit copy already drops held policy with without_held.
  • No change to which net-new settings are refused.
  • No change to the refusal when the worker base cannot be read.

What changed (motivation → approach → change)

Symptom: uncarried_restrictions names held toolsSettings entries as lost. Cause: it passes the template's full policy to merge_worker_spec, whose allowlist check judges entries the base already holds. The kit copy (mate_worker_kit._carry_policy) subtracts them first; the preflight did not.

Change: uncarried_restrictions in mate_config_migration.py now removes held policy with mate_spec_policy.without_held before the merge, the same step the kit copy takes. It still compares the full template's restrictions with the merged worker, so a held restriction the merge loses is still reported. crew-mode.md describes the preflight.

Backwards compatibility

Compatible: a template accepted before is still accepted; a template refused only for policy the base already holds is now accepted. Net-new unsupported settings are still refused.

Removes nothing: no key, record or guard is removed.

Tests

Proof: PROVEN test_mate_spec_policy.py::test_preflight_judges_only_policy_not_held_by_the_base[True], test_preflight_still_detects_a_held_restriction_lost_by_the_merge[hooks|permissions|toolsSettings], test_adding_a_server_with_policy_already_held_by_the_base_succeeds (head be2209c; production hunk reverted by hand, 5 of the 7 new cases fail)

New cases in test/test_mate_spec_policy.py:

  • A template whose policy equals the base's reports nothing lost; the same policy on a bare base is still reported.
  • An unreadable base still refuses every policy field.
  • A held restriction that the merge drops is still reported, per policy field.
  • End to end: adding a server from such a template succeeds and writes no policy into the crewmate's file.

Runs (-n0 -x): test_mate_spec_policy.py 69 passed; test_mate_worker_kit.py + test_mate_config_migration.py 131 passed. flake8, black (py310), isort, mypy on the touched file, check_comment_history, check_brand_name: pass.

Manual verification

N/A - the preflight is a pure function of the template and the worker base, covered end to end by test_adding_a_server_with_policy_already_held_by_the_base_succeeds.

Related Issues

Refs #28501
Part of #26881

Sibling sweep

Swept: git grep -n "worker_additions(base" -- src/
Sibling: src/kiro_crew/mate_worker_kit.py:_carry_policy -- not affected -- already applies without_held before layering
Sibling: src/kiro_crew/mate_worker_kit.py:436 -- not affected -- merges the planned crewmate file, written after without_held
Sibling: src/kiro_crew/mate_worker.py:653 -- not affected -- merges a crewmate file at session start, which the kit wrote without held policy
Sibling: src/kiro_crew/mate_config_migration.py:migration_file -- not affected -- copies no policy keys and does not merge
Sibling: src/kiro_crew/mate_config_migration.py:1127 -- not affected -- merges the migration's planned file, which carries no policy
Sibling: src/kiro_crew/mate_config_migration.py:1334 -- not affected -- merges the written crewmate file, which carries no held policy

Pattern harvest

Not generalizable: one preflight skipped a subtraction its sibling path already performs; the fix shares that step.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

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.

Refs #28501
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 3, 2026 23:53
@buluoray
buluoray requested a review from bolichen97 November 3, 2026 23:53
@buluoray
buluoray enabled auto-merge (squash) November 3, 2026 23:53
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision be2209c159d30d3c842532dddfceea4b0e7dd22f touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

buluoray added a commit that referenced this pull request Nov 3, 2026
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
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of be2209c159d30d3c842532dddfceea4b0e7dd22f — 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 fix reuses the existing without_held subtraction that the kit copy already applies, at the preflight that skipped it.

What this change ships

Inventory (3 items) — 3 justified

Intent: let a user add a template's MCP server when the template repeats tool limits the worker base already holds. FIX.

  1. Add abilities no longer refuses a template only because it repeats the worker base's hooks, rules or tool settings. — justified
  2. A held restriction that the merge drops is still reported as lost. — justified
  3. The crew-mode spec now describes how the preflight treats held policy. — justified

[FIRST-PRINCIPLES-REVIEWED] be2209c

Description read

[DESCRIPTION-READ] 3c2f1656f4c803aae9afa1bb527fa1eddfd73b877566c3cdc2abc4bf2e7de5ea

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 Nov 3, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of be2209c159d30d3c842532dddfceea4b0e7dd22f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level concerns. The preflight now runs the same without_held subtraction as the kit copy (_carry_policy), and it still checks the full template against the merged worker, so a held restriction the merge drops is still caught.

Notes

  • The subtraction is now written in two places, _carry_policy and uncarried_restrictions. A shared helper that returns "the policy this template adds" would keep a third caller from leaving the step out again. Not needed for this PR.

[DESIGN-REVIEWED] be2209c

Description read

[DESCRIPTION-READ] 042bb3e470525330fcd92e3892cf77e9225d4c6bd7aa311857a1ec7b732b0481

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 Nov 3, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of be2209c159d30d3c842532dddfceea4b0e7dd22f and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] be2209c

False positive or not applicable? A repository writer can comment:
/ai-review override gpt be2209c159d30d3c842532dddfceea4b0e7dd22f false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — 🔴 changes requested (blocking)

Reviewed be2209c159d30d3c842532dddfceea4b0e7dd22f — this comment is updated in place on each push.

The preflight now accepts a template's toolsSettings keys that are off the allowlist whenever the worker base holds the same entry. The recorded decision says those keys are refused by name, and this PR adds no entry that supersedes it.

BLOCKING — src/kiro_crew/mate_config_migration.py:980
policy = without_held(policy_of(source), base) / merged = merge_worker_spec(base, {**additions, **policy})
Trigger: a template whose toolsSettings (for example fs_write.allowedPaths/fallbackAction, which build_agent_config keeps when a user wrote them) equals an entry in kirocrew-mate-worker.json. mate_worker_kit._plan calls uncarried_restrictions(source), then without_held removes the entry. layer_policy never runs _outside_allowlist or tools_settings_unenforced on it, and the _restrictions diff is empty because the base still holds the entry.
Outcome: the add, or a create, used to be refused with template_restrictions_uncarried naming toolsSettings.fs_write.allowedPaths. Now it succeeds silently, but the template's write fence still never takes effect on the worker. The new test pins this (lost == [] if held). This contradicts docs/decisions/2026-11-02-a-crewmates-worker-carries-its-template-policy.md ("every other toolsSettings key, in any form, is refused with its name").
Anchor: recorded-decisions-are-not-regressions
Fix: before subtracting the held entries, run _outside_allowlist and tools_settings_unenforced over the full policy_of(source)["toolsSettings"], so a held entry skips only the layering conflict and not the refusal by name. Otherwise, add a superseding decision entry.

[BLOCK-MERGE] be2209c
[OPUS-REVIEWED] be2209c

Verdict parsed from the review's SHA-scoped output markers for commit be2209c159d30d3c842532dddfceea4b0e7dd22f.

False positive or not applicable? A repository writer can comment:
/ai-review override fable be2209c159d30d3c842532dddfceea4b0e7dd22f false-positive: <reason, 20 to 500 characters>

@buluoray
buluoray disabled auto-merge November 4, 2026 00:07
@buluoray

buluoray commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing: this change contradicts docs/decisions/2026-11-02-a-crewmates-worker-carries-its-template-policy.md, which refuses every toolsSettings key outside its allowlist by name. Skipping entries the worker base holds would accept such a template silently while the setting still does not apply on the worker (Opus review on this head). The current refusal is the decided behaviour.

@buluoray buluoray closed this Nov 4, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed be2209c. Two points before merge:

  1. A held tool setting now skips the refusal, not just the layering conflict (Opus, mate_config_migration.py:980). uncarried_restrictions now removes policy the worker base already holds (without_held) before merge_worker_spec. For a template whose toolsSettings entry, for example fs_write.allowedPaths/fallbackAction, equals one in kirocrew-mate-worker.json, layer_policy then never runs _outside_allowlist or tools_settings_unenforced on it. An add or create that used to be refused with template_restrictions_uncarried naming that field now succeeds, while the template's write fence still never takes effect on the worker. The new test pins that (lost == [] if held). That contradicts docs/decisions/2026-11-02-a-crewmates-worker-carries-its-template-policy.md. Fix direction, as the lane suggests: run _outside_allowlist and tools_settings_unenforced over the full policy_of(source)["toolsSettings"] before subtracting the held entries, so a held entry skips only the layering conflict and not the refusal by name. Or, if accepting it is intended, add a superseding decision entry.
  2. PR Hygiene is red: the diff removes behavior, so the description needs a ## Backwards compatibility section with one Reader: <path>:<symbol> -- <entry> -- <why> line per reader.

The test shards and E2E were still running when I checked.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants