Skip to content

fix(acp): carry a kirocrew-core disabledTools toggle on the session gate instead of refusing - #17547

Closed
chenmingwei23 wants to merge 1 commit into
kirodotdev:mainfrom
chenmingwei23:fix/14125-core-tool-toggle
Closed

chenmingwei23 wants to merge 1 commit into
kirodotdev:mainfrom
chenmingwei23:fix/14125-core-tool-toggle

Conversation

@chenmingwei23

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Disabling one kirocrew-core tool from the dashboard lets the default agent's sessions keep running without that tool, instead of refusing every new session.

Disabling a single kirocrew-core tool in the dashboard's MCP tab writes disabledTools into the global mcp.json. On the kiro backend the default agent's control plane is mounted as a per-session element, and that element cannot express disabledTools (a kiro-cli-only key), so after #14078 every new session of that agent was refused with an error until the toggle was undone. The toggle's apparent promise (lose one tool) and its effect (lose the agent's sessions) diverged.

Why it matters

Turning off one tool should cost one tool, not the agent. Until the toggle was undone, skill_search and every other control-plane capability were unreachable on that backend, so the default agent could not start a session at all — a surprising, hard-to-diagnose outcome for a routine UI action.

Not a goal

  • The predicate's other arms stay as they are: a mute (disabled: true), a non-stdio transport, or any key a per-session element cannot carry still keeps the declaration native and withholds the element — none has a per-call form a gate could honour.
  • Opt-in identity-bound servers (e.g. kirocrew-dashboard) are not carried: their tools can be auto-approved by the harness without a permission request, so the per-call gate is not a complete channel for them.
  • No new dashboard warning at toggle time; the runtime now carries the restriction, which is the arm this issue asks for.

What changed (motivation → approach → change)

A disabledTools toggle on a control-plane server used to withhold the per-session element, and the runtime refused the session rather than mount an element that silently dropped the restriction. The faithful alternative already exists for mirrored backends: the restriction rides the session's per-call permission gate, where a switched-off tool is rejected at the permission request. Control-plane tools carry no annotations, so every call reaches Crew as a permission request — the gate is a complete channel for them.

So for a control-plane server a disabledTools restriction is now carried, not withheld: the element mounts (it only ever carried command/args/env), and the toggled (server, tool) pairs are fed into the session's spec_denied_tools. The session starts minus the toggled tool and keeps skill_search. The runtime refusal remains the fallback for the restrictions nothing can carry.

  • session_mcp.py: a carry_disabled_tools flag on _native_restriction / native_mount_withholding that turns off only the disabledTools arm; NativeControlPlaneMount gains a carried set and native_carried_disabled_tools() reads the pairs from the same declarations the withholding predicate reads; kiro_control_plane_servers passes the flag for CONTROL_PLANE_SERVERS and returns the carried pairs.
  • runtime.py: _unpooled_control_planes returns the carried pairs, and both the fresh (create_session) and resumed (load_session) kiro paths feed them into the session's spec_denied_tools.
  • skill_projection.py: a disabledTools toggle on kirocrew-core no longer refuses the skill view (the skill_search-disabled refusal above it is unchanged).

Backwards compatibility

Compatible: a session that was previously refused now starts with the toggled tool denied at the gate; no session that worked before changes behaviour, and the other withholding arms are untouched.

Removes nothing: no path, record, key, or public function is removed or hidden — the change replaces a refusal with a mounted element plus a per-call deny, and the refusal still stands for the restrictions nothing can carry.

Tests

test/test_native_skill_projection_sources.py:

  • A disabledTools toggle in the global settings, the project settings, or the spec entry now carries on the gate (element mounts, carried holds the pair) instead of refusing — new/rewritten tests assert the carried pair and the mounted element.
  • A toggle written or undone after the spawn, and a toggle behind a broker stub, carry the pair at the next session start.
  • Mute, non-stdio transport, uncarriable key, and skill_search-disabled still withhold / refuse (converted the former disabledTools-refuses cases to a mute to keep that coverage).
  • The one-read invariant and the "mount keeps no private copy of the predicate" structural pins still hold.

Manual verification

N/A — unit coverage sufficient: the behaviour is exercised end to end through AcpRuntime._unpooled_control_planes driving the real mount and the session handle's deny set in test_native_skill_projection_sources.py.

Screenshots / video

N/A — no user-visible frontend surface changes; the diff is backend ACP control-plane code under src/kiro_crew/acp/.

Related Issues

Fixes #14125

Pattern harvest

Not generalizable: a backend-specific gap between a native-only restriction key and a per-session element on one server family; the fix reuses the existing per-call deny gate rather than introducing a reusable pattern.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — module docstrings updated in-place
  • No secrets, credentials, or internal references in the diff

@chenmingwei23
chenmingwei23 requested a review from a team as a code owner October 6, 2026 22:19
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 7, 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.

[P0] kiro backend: a kirocrew-core disabledTools toggle stops being enforced (fail-open)

Class: Security guard turned fail-open (disabled tool runs on the kiro backend).

Mechanism: For control-plane servers the PR sets can_carry=True (session_mcp.py:1838) and skips the disabledTools withholding arm, moving enforcement to spec_denied_tools. That set is checked only on session/request_permission, but kiro-cli auto-approves @kirocrew-core via allowedTools and sends no permission request.

User impact: A kirocrew-core tool the operator switched off in the MCP tab can still run on the kiro backend; only an after-the-fact tripwire notices.

Location: src/kiro_crew/acp/session_mcp.py:1838 @ 2bd77f369e91283ee6a3b68ac9ff8187e0920440

Minimum fix: Carry a disabledTools pair to the gate only where the backend is proven to raise a permission request for it. On the kiro backend keep the old withholding (or remove the carried tools from the effective allowedTools so kiro-cli must prompt).

How to verify: A unit test with kirocrew-core disabledTools=[learn_add] in mcp.json and the default agent spec on the kiro backend: assert kirocrew-core is withheld, or that learn_add is not auto-approved in the spec handed to kiro-cli. Fails on this head.

Exploit details are left out on purpose. They are available to maintainers through the repo's private security reporting.

Independently re-verified on head 2bd77f369e with a focused local reproduction.

# auto-approved inside codex without asking), so it keeps the old
# withholding behaviour and the flag stays off for it -- the same split
# :func:`session_mcp_restricted_servers` draws, for the same reason.
can_carry = name in CONTROL_PLANE_SERVERS

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.

[P0] kiro backend: a kirocrew-core disabledTools toggle stops being enforced (fail-open) — see the review summary for mechanism, fix and test.

@chenmingwei23

chenmingwei23 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@bolichen97 Thanks — your point is correct and addressed. spec_denied_tools is consulted only on session/request_permission, and kiro-cli auto-approves @kirocrew-core through the agent spec's allowedTools (whole-server) and issues no request, so a carried deny on an auto-approved tool was never consulted.

The fix carries a disabledTools pair on the gate only where the backend provably prompts — i.e. the tool is not auto-approved by the spec's allowedTools (matched with kiro-cli's own @server / @server/tool / @server/<glob> semantics). When a disabled control-plane tool IS auto-approved, the element is withheld again rather than mounted with an unenforceable deny — withholding the session is the fail-safe answer, and nothing re-enables a disabled tool. A spec that does not auto-approve the toggled tool keeps #14125's win (session runs minus the tool, which prompts then is denied). The skill projection applies the same check so it never promises a view the mount withholds.

Your verification test is included: test_a_toggled_tool_that_allowedtools_auto_approves_is_withheld_not_carried asserts kirocrew-core is withheld and the pair is not carried — it fails on the carry-everything head and passes with the fix. I also fixed the _unpooled_control_planes tuple-return caller and the control-plane identity/retry tests in test_session_token_identity.py.

Superseded by the draft #17859 (against main). Closing this one in favour of it.

@chenmingwei23

chenmingwei23 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Superseded by #17859 (against main).

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.

Let a kirocrew session run with a kirocrew-core tool toggle expressed instead of refusing it (follow-up to #14078)

2 participants