Repository navigation
fix(claude): keep Crew tools when a project owns settings.local.json - #14981
Conversation
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The PR's own 0.84.0 fixture shows the adapter still reading the excluded project file. Nothing yet shows that file's Watch
[DESIGN-REVIEWED] 2cd4367 Description read[DESCRIPTION-READ] cabf7bf6e14940834fdfad99eab6572c28209725fa39231c9fce372cdfe23324 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 |
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: |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The startup re-read, which can kill the session, closes a window the spec admits stays open, and the adapter-version reader is a second copy of an existing manifest walk. Not justified as shipped
What this change shipsInventory (10 items) — 7 justifiedIntent: a Claude session in a project with its own
[FIRST-PRINCIPLES-REVIEWED] 2cd4367 Description read[DESCRIPTION-READ] 765fb3e2f409b2386315f1eb0229be152e188e7c371717b69ac5b506d6920f0a That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings that block the merge. FINDING — src/kiro_crew/acp/client.py:5655 — before the handshake, [OPUS-REVIEWED] 2cd4367 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
1f83f7d to
ad728de
Compare
ad728de to
056431f
Compare
4f98cf9 to
273e979
Compare
|
/ai-review override gpt 273e979: The user-tier permissions.allow bypass is the pre-existing documented Known gap (claude-code-provider.md); this path loads strictly fewer sources, pins the mode, disables allowDangerouslySkipPermissions, and needs the operator's own global ~/.claude to pre-approve, so excluding the user tier would break Claude auth. |
Human judgment recorded@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
273e979 to
f895eb2
Compare
f895eb2 to
147198e
Compare
|
The GPT 5.6 run on
With this, the exclusion path drops project allows, carries project denies, and withholds the array whenever a project restriction cannot be carried. Both changes are mutation-checked. Local: 1474 passed; lint, mypy, harness-parity, comment-history and docs-lint clean. |
050b68f to
6e98b3b
Compare
|
On
|
6e98b3b to
b0cb647
Compare
|
Both blockers on
Both guards fail their tests when removed (mutation-checked). Local: 1477 passed; lint, mypy, harness-parity, comment-history and docs-lint clean. |
b0cb647 to
8ecc43c
Compare
|
First Principles BLOCK on
Local: 1522 passed (frame-replay suite included). Lint, mypy, harness-parity, comment-history, docs-lint and frame host-data gates are clean. |
Leave a project-owned .claude/settings.local.json out of the session's setting sources and carry Crew's settings inline, so no project permissions.allow loads and the mcpServers array can ship. The deny and ask rules of both project files are carried inline, so leaving the tiers out drops their allows but not their restrictions; they are re-read before the first prompt, and a file that gained one stops the session. The path is taken only on claude-agent-acp 0.84.0 or newer, the release verified to honour settingSources, read from the installed package before the array is resolved and checked again against the handshake. The array is withheld for an older or unversioned adapter, a link, a project file that cannot be examined or sets hooks or sandbox, or a requested permission mode. On this path a bypassPermissions or auto starting mode is pinned to default before the first prompt, or the harness is stopped.
8ecc43c to
2cd4367
Compare
|
On
Local: 1604 passed across the ACP, harness-parity and frame-replay suites. Lint, mypy, harness-parity, comment-history and docs-lint are clean. |
buluoray
left a comment
There was a problem hiding this comment.
Re-review at head 2cd4367cbbdbc63e0b9e8e423e840f8d2aa880d3. The prior review was at 147198efa3.
Summary
All three prior blockers are fixed in the code and spec at this head. The exclusion path now leaves the project tiers out and carries their permissions.deny and permissions.ask rules inline. It refuses the path (array withheld, tiers loaded, same as before this PR) when a project file sets hooks or sandbox, cannot be examined, the adapter is below 0.84.0 or unversioned, or Crew requested a mode. Before the first prompt it re-reads both files and kills the session if either gained a restriction. A bypassPermissions, auto or unreported starting mode is pinned to default, or the harness is stopped.
The project's own settings.local.json is never written, merged, moved or deleted. It is opened only read-only, with O_NOFOLLOW | O_NONBLOCK, to collect deny/ask rules. Every new error path fails closed. I found no code-logic defect.
Verified
- The project file is never overwritten or lost.
- The foreign-file branch of
_write_claude_local_settings(client.py:6098-6106) returns right after_exclude_foreign_local_settings. It does no write, claim, snapshot or unlink. _project_settings_restrictions(client.py:2386-2469) only reads:os.open(O_RDONLY|O_NOFOLLOW|O_NONBLOCK), thenfstat, which requires a regular file of at most 1 MiB, then a bounded read andclose.- Nothing restores or removes the file on reset, because Crew never authored it.
- The foreign-file branch of
- Harness parity.
HARNESS_BASE_REF=<merge-base> scripts/check_harness_parity.pypasses.- H13: every new step is behind
self._is_claude. That covers the pin on new atclient.py:9861and on load at:9801, the envelope at:9524and:9745, and the version read inside the existing claude spawn arm at:7734-7765. - The shared handshake gains only an attribute write (
_agent_version_read = True,:9653). It adds no await, no conditional and no failure point. - The two recording lines in
_resolve_session_mcp_servers(:4156-4163) sit aftermirror is None: return [], so Kiro never reaches them. - The moved argv resolution is still inside the claude branch.
- Adapter premise (
npm pack @agentclientprotocol/claude-agent-acp@0.84.0):SettingsManageris consulted only fordefaultMode/disableBypassPermissionsMode(acp-agent.js:6487-6489),availableModels/modelOverrides(:6814-6819,session-model.js:336) and effort (:6116,:6889).canUseTool(:5734ff.) reads no allow rules. Allow evaluation is the CLI's, and the CLI is whatsettingSourcesgoverns.allowBypassis gated onallowDangerouslySkipPermissions !== false.
- Load-bearing ordering.
_reseed_after_captureruns before the pin and re-runs the writer. That can clear the live flag, for example when the handshake reports a version below the floor. The pin still runs, because_claude_session_excludes_localORs the live flag with the projection record (_session_mcp_excludes_local), and_invalidate_session_mcp_projection(:5308) never clears that record. The deny re-check compares against_claude_shipped_restrictions, which is frozen when the envelope is built (:5693-5701), not against the re-seeded live settings. - Mutations. I applied each one alone, ran only
test/test_acp_session_mcp.py+test/test_acp_client.pywith-x, then restored the file.git statuswas clean afterwards.
| Mutation | Test that fails |
|---|---|
| Deny/ask merge removed | test_the_project_tiers_deny_rules_ride_inline |
ask not carried |
test_the_project_tiers_ask_rules_ride_inline |
| Startup re-read made a no-op | test_an_ask_rule_gained_before_the_first_prompt_stops_the_session |
| Floor always passes | test_an_installed_adapter_below_the_floor_gets_no_tools[0.83.0] |
| Unparseable version passes the floor | …[] (same test) |
| Handshake floor check in the pin removed | test_a_handshake_below_the_floor_stops_an_excluded_session[0.83.0] |
hooks/sandbox guard removed |
test_unexaminable_project_denies_withhold_the_array[hooks] |
| Non-regular/oversized file read as empty | …[directory] (same test) |
| Symlinked project file read as empty | test_a_linked_checked_in_settings_file_withholds_the_array |
| Per-run flag reset removed | test_each_write_redecides_the_exclusion |
Projection-record fallback in _claude_session_meta removed |
test_the_envelope_follows_the_array_it_shipped_with |
- CI on
2cd4367cbb: 85 success, 12 skipped, 0 failing or pending. - PR state: auto-merge is off. The review decision is still CHANGES_REQUESTED from the prior round. Whoever requested changes must re-review to clear it.
- Tests were not run locally beyond the two targeted files above (152 tests in
test_acp_session_mcp.py, all passing unmutated). I did not run the full suite.
Error paths
| Path | Behaviour | Fail-closed? |
|---|---|---|
Unexaminable project file, RecursionError, hooks/sandbox |
Array withheld | Fail-closed |
| Version below floor, unparseable or missing, before spawn | Array withheld | Fail-closed |
| Version below floor at the handshake | Kill | Fail-closed |
| Startup re-read finds a gained rule or an unreadable file | Kill | Fail-closed |
| Pin fails | Kill | Fail-closed |
| Unreported mode | Pinned | Fail-closed |
| Non-UTF-8 or non-JSON content | Contributes no rules | Fail-open only in theory; see follow-ups. Not exploitable by the repository, since only its own restrictions are dropped |
Bot claims disposition
- Design Review CONCERNS: the adapter still reads the excluded file, so its allow rules might approve Crew tools. Not real. The adapter reads every tier only for the starting mode, the model list and effort.
canUseTooltakes no allow rules fromSettingsManager(see above). Theplanfixture shows the mode channel, and that channel is exactly what the pin covers. - Design Review / First Principles: project env, plugins and
CLAUDE.mdsilently stop loading, with no opt-out. Real, but a product trade, not a defect. The runtime warning (client.py:5636-5642) and the spec section name it. It is non-blocking. A maintainer override or a "Breaking:" line in the body would settle it. - Design Review: the PR body lists
test_a_crew_authored_session_is_pinned_against_a_user_bypass_mode. Real. That test does not exist. The code hastest_a_crew_authored_session_is_not_pinned(test_acp_session_mcp.py:1617) and returns early with no exclusion. Body is stale; non-blocking. - First Principles:
_claude_adapter_installed_versionduplicates_pi_installed_version(client.py:1359). Real duplication. It is non-blocking cleanup. - First Principles:
_verify_claude_project_denies_unchangedis oversized. Not a defect. It is fail-closed, and it closes the read-to-session/newwindow that the prior review's preferred fix depended on. Keeping it is defensible. - Opus FINDING: the below-floor warning logs
_agent_versioninstead of the disk version that was measured (client.py:5655). Real, log-only. It prints''or a stale version before the handshake. Non-blocking. - GPT 6.1: no findings at this head.
Prior findings
- Project denies and hooks dropped. Fixed.
- Deny and ask rules are carried at
client.py:5620-5631. hooks/sandboxrefuse the path at:2461-2464(_CLAUDE_PROJECT_UNCARRIED_GUARD_KEYS).- The startup re-read is at
:5712-5745. - "never a widening" is now scoped to the non-exclusion path (
claude-code-provider.md:403-405), and the new section names what is carried.
- Deny and ask rules are carried at
- Commit message described behaviour the code lacks. Fixed. The message now lists exactly these cases: older or unversioned adapter, link, unexaminable file or
hooks/sandbox, requested mode, and the bypass/auto pin. Each matches the code. - Spec contradictions. Fixed.
- The
settingSourcesparagraph (claude-code-provider.md:137-148) names 0.84.0 and the floor, and says forwarding is not read back. - The "keeps the array withheld" bullet is replaced by the exclusion section.
- The prior follow-up on the
agent-host-contract.mdAuto-mode cell is also fixed: it now says create-or-decline.
- The
Follow-ups (non-blocking)
-
Update the PR body's Tests list: remove
test_a_crew_authored_session_is_pinned_against_a_user_bypass_modeand addtest_a_crew_authored_session_is_not_pinned. Get the env/plugins/CLAUDE.mdtrade recorded, either as a maintainer override or a Breaking line. -
Log the version the floor actually judged, from disk or from the handshake, in
_log_claude_adapter_below_floor(client.py:5652-5664). -
Fold
_claude_adapter_installed_versioninto the existing pi manifest walker. -
_project_settings_restrictionstreats aUnicodeDecodeErroror a BOM-prefixed file as "no rules". Claude's JS reader may still parse such a file and enforce its denies. Treating it asNone(withhold) would remove the ambiguity. -
Possible spurious kill:
- The first write refuses the exclusion (for example,
hooksare present). _reseed_after_capturethen takes it.- The pin runs with an empty shipped set and kills the session if the project has any deny.
This is a rare race and fails closed. Consider gating the pin on the record from the array actually shipped, rather than OR-ing in the live flag, for the deny re-check only.
- The first write refuses the exclusion (for example,
Problem / Motivation
Goal: A Claude Code session keeps Crew's tools when the project has its own
.claude/settings.local.json.Some projects ship their own
.claude/settings.local.json. Crew does not touch that file. So the Claude session got an emptymcpServersarray. It had nosend_message, nocron_add, nospawn_run, and none of the agent spec's servers. A cron job that reports throughsend_messagesent nothing, and nothing said why.Why it matters
Any project that owns its own Claude settings file lost every Crew tool. Cron jobs on those projects failed silently.
Not a goal
~/.claudeand checked-in.claude/settings.jsonallow rules (W2-1). Those still load, exactly as they do in a session where Crew writes the file.CLAUDE_CONFIG_DIR. It moves only the user folder. The project's local file would still load.What changed (motivation → approach → change)
The array was held back for a good reason. A repository's
permissions.allowcould approve a Crew tool before Crew's gate ever saw the call.The fix leaves every project tier out of the session. Crew already sends
_meta.claudeCode.optionsonsession/newandsession/load. claude-agent-acp spreads those options over its defaults.settingSourcesmcpServers["user"]settingsdefaulthooks/sandbox, or mode requestedThe pin runs only on the project-owned path; a user
~/.claudemode reaching a Crew-written session is the W2-1 residual.This path is floored on claude-agent-acp 0.84.0, the release verified to honour
settingSources(agentInfo.versionatinitialize). The CLI then loads neither the project's local file nor a checked-in.claude/settings.json. No repository allow rule can approve anything. Crew's deny rules and model list go in the inlinesettings, and so do thepermissions.denyrules of both project files. Leaving the tiers out drops their allows, never their denies. Both files are re-read aftersession/newand before the first prompt; one that gained a deny stops the session. That read is bounded and never follows a link; a file whose bytes cannot be examined withholds the array.This path loads less than today's normal path. A Crew-written session loads
user,projectandlocal. This one loadsuseralone. Theusertier (~/.claude) is the W2-1 residual, and it already loads in every Crew-written session.One thing a file still decides. claude-agent-acp picks the starting permission mode from every settings file itself. A file can change between any check and
session/new. So Crew never trusts the file's mode. Instead:allowDangerouslySkipPermissions: falsestopsbypassPermissionsbeing a starting mode.session/neworsession/loadresponse names the mode the session really started in (modes.currentModeId).bypassPermissionsorauto, or not reported, Crew sendssession/set_modedefaultand waits for success, before the first prompt. Both approve Crew's tools without asking. Every other mode stays as it started:planis stricter,acceptEditsapproves only file edits, anddontAskrefuses anything not pre-approved.Project
hooksandsandboxrestrict a session but cannot be carried inline (aPreToolUsehook can answerallow;sandboxhasautoAllowBashIfSandboxed). So a project file that sets either keeps today's behaviour: tiers loaded, array withheld. The remaining cost of this path: project env, plugins andCLAUDE.mddo not load. The warning and the spec name them.Where it lives:
src/kiro_crew/acp/client.py:_exclude_foreign_local_settingstakes the path from the writer's foreign-file branch and carries the project files' deny rules inline (_project_settings_denies)._claude_session_metabuilds the envelope forsession/new, its substitution retry, andsession/load._pin_claude_starting_modereads back and pins the mode after both._permission_surface_governedcounts the exclusion.src/kiro_crew/providers/mirrors/claude_code.py: the ruling, docstring and warning name the new shape. The withhold logic is unchanged.docs/system-specs/modules/agent-host-contract.md: the claude Auto-mode row names thesession/set_modepin. The inherited-config row no longer saysdontAskauto-approves; the SDK defines it as "deny if not pre-approved".docs/system-specs/modules/acp-client.mdand theclient.pycomments:session/set_modeis skipped on claude only for agent activation. Its modes are permission modes, which the pin uses.docs/system-specs/modules/claude-code-provider.md: a new "A project-owned settings file" section, plus updated notes on the known gap.Backwards compatibility
Compatible: a session where Crew writes the file sends the same empty options and is not pinned, exactly as before. A project-owned file is still never written, merged or removed. A link or a requested mode still gets an empty array.
Tests
test/test_acp_session_mcp.py::test_a_project_owned_settings_file_still_gets_crews_toolsdrives the realsession/new. The project holds an allow rule insettings.local.jsonand another in a checked-insettings.json. The session getsfoo,settingSourcesis["user"], bypass is off, neither allow rule appears in the params, and the spec's deny rule rides inline.test_a_file_swapped_after_the_check_cannot_keep_an_approving_mode: a safe file at check time,bypassPermissionsafter. The reportedautois pinned todefault, and a failed pin stops the harness.test_a_session_started_in_a_gate_escaping_mode_is_pinned(bypassPermissions,auto,dontAsk, missing).test_a_mode_that_still_asks_about_crew_tools_is_kept(default,plan,acceptEdits) sends nothing.test_a_pin_that_fails_stops_the_session,test_both_session_establishment_paths_reach_the_pin.test_a_crew_authored_session_is_pinned_against_a_user_bypass_mode: a Crew-written seed with nodefaultMode, and a user~/.claudeset tobypassPermissions. The session starts, carriesfoo, and is pinned todefault.test_a_crew_opt_in_mode_is_not_overriddenkeepsauto.test_a_session_without_crews_array_gains_no_pinsends nothing.test_a_claude_session_actually_starts_under_the_pindrives the whole_initialize_sessionhandshake onsession/newandsession/load. claude-agent-acp handlessession/set_mode(dist/acp-agent.jswires it tosetSessionMode). A session started inbypassPermissionsgets one pin and keeps running; one indefaultorplansends none.test_the_project_file_is_never_read_to_decide: any regular file, even unparsable orbypassPermissions, is left out the same way.test_the_project_tiers_deny_rules_ride_inline: both project files' denies ride the inline settings, deduplicated, and no allow does.test_unexaminable_project_denies_withhold_the_array(directory, oversized, FIFO) andtest_a_linked_checked_in_settings_file_withholds_the_arraywithhold the array.test_a_file_claude_takes_no_denies_from_adds_nonecovers unparsable or mistyped content.test_each_write_redecides_the_exclusionandtest_the_envelope_follows_the_array_it_shipped_withpin the per-run flag reset and the projection-record fallback; each fails when its guard is removed.test_the_substitution_retry_rebuilds_the_envelope,test_a_crew_authored_seed_keeps_every_setting_source,test_a_requested_mode_still_withholds_the_array,test_a_symlinked_project_file_still_withholds_the_array.test/test_acp_client.py::test_substitution_retry_withholds_mcp_when_surface_lostnow loses the surface through a link, the shape that still withholds.assert 'foo' in {}). Twelve mutants each fail a test. Both directions: widening every non-defaultmode, and keepingbypassPermissionsorauto. Also: trusting an unreported mode, the pin gated on the exclusion only, the roster flag always set, the opt-in overridden, a pin that always kills, a pin sent when alreadydefault, trusting the reported mode, each pin call site dropped,projectback in the sources, and bypass allowed.Manual verification
Live capture: claude-agent-acp 0.84.0 driven over stdio with this path's envelope, no prompt sent (
test/fixtures/claude_mode_pin/). A projectplanstarted inplan; a projectautowas filtered and started indefault;session/set_modedefaultfromautoanswered{};session/loadreported the mode back. The pin tests replay these answers.I checked claude-agent-acp 0.84.0 from
npm pack.dist/acp-agent.jsspreads_meta.claudeCode.optionsafter its defaultsettingSourcesand usesoptions.settings.dist/settings.jsreads the local file by project path, anddist/permissions/modes.jsresolves the starting mode. I did not run a live Claude session.Related Issues
Parity audit item W1-2 in
docs/acp-provider-parity-audit.md. The residual is W2-1.Pattern harvest
Not generalizable: this is one harness's settings-source channel, and the fix uses that harness's own option.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)