Skip to content

fix(claude): keep Crew tools when a project owns settings.local.json - #14981

Merged
iamwhatever merged 1 commit into
mainfrom
fix/claude-crew-owned-config-root
Oct 3, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/claude-crew-owned-config-root

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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 empty mcpServers array. It had no send_message, no cron_add, no spawn_run, and none of the agent spec's servers. A cron job that reports through send_message sent 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

  • Closing the inherited ~/.claude and checked-in .claude/settings.json allow rules (W2-1). Those still load, exactly as they do in a session where Crew writes the file.
  • Promoting the claude routing to a verified or enforced one.
  • Rewriting, merging or deleting the project's own file.
  • A Crew-owned 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.allow could 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.options on session/new and session/load. claude-agent-acp spreads those options over its defaults.

Case settingSources Crew settings Mode mcpServers
Crew wrote the file default (all) the file as today full
Project owns the file ["user"] inline settings bypass/auto → default full
Adapter below 0.84.0 or unversioned, link, unexaminable project file, project hooks/sandbox, or mode requested default (all) none as today empty

The pin runs only on the project-owned path; a user ~/.claude mode 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.version at initialize). 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 inline settings, and so do the permissions.deny rules of both project files. Leaving the tiers out drops their allows, never their denies. Both files are re-read after session/new and 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, project and local. This one loads user alone. The user tier (~/.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:

  1. allowDangerouslySkipPermissions: false stops bypassPermissions being a starting mode.
  2. The session/new or session/load response names the mode the session really started in (modes.currentModeId).
  3. When it is bypassPermissions or auto, or not reported, Crew sends session/set_mode default and waits for success, before the first prompt. Both approve Crew's tools without asking. Every other mode stays as it started: plan is stricter, acceptEdits approves only file edits, and dontAsk refuses anything not pre-approved.
  4. A pin that fails stops the harness. The session never runs with Crew's tools under a mode that approves on its own.

Project hooks and sandbox restrict a session but cannot be carried inline (a PreToolUse hook can answer allow; sandbox has autoAllowBashIfSandboxed). So a project file that sets either keeps today's behaviour: tiers loaded, array withheld. The remaining cost of this path: project env, plugins and CLAUDE.md do not load. The warning and the spec name them.

Where it lives:

  • src/kiro_crew/acp/client.py: _exclude_foreign_local_settings takes the path from the writer's foreign-file branch and carries the project files' deny rules inline (_project_settings_denies). _claude_session_meta builds the envelope for session/new, its substitution retry, and session/load. _pin_claude_starting_mode reads back and pins the mode after both. _permission_surface_governed counts 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 the session/set_mode pin. The inherited-config row no longer says dontAsk auto-approves; the SDK defines it as "deny if not pre-approved".
  • docs/system-specs/modules/acp-client.md and the client.py comments: session/set_mode is 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_tools drives the real session/new. The project holds an allow rule in settings.local.json and another in a checked-in settings.json. The session gets foo, settingSources is ["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, bypassPermissions after. The reported auto is pinned to default, 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 no defaultMode, and a user ~/.claude set to bypassPermissions. The session starts, carries foo, and is pinned to default. test_a_crew_opt_in_mode_is_not_overridden keeps auto. test_a_session_without_crews_array_gains_no_pin sends nothing.
  • test_a_claude_session_actually_starts_under_the_pin drives the whole _initialize_session handshake on session/new and session/load. claude-agent-acp handles session/set_mode (dist/acp-agent.js wires it to setSessionMode). A session started in bypassPermissions gets one pin and keeps running; one in default or plan sends none.
  • test_the_project_file_is_never_read_to_decide: any regular file, even unparsable or bypassPermissions, 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) and test_a_linked_checked_in_settings_file_withholds_the_array withhold the array. test_a_file_claude_takes_no_denies_from_adds_none covers unparsable or mistyped content.
  • test_each_write_redecides_the_exclusion and test_the_envelope_follows_the_array_it_shipped_with pin 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_lost now loses the surface through a link, the shape that still withholds.
  • On origin/main the new delivery and swap tests fail (assert 'foo' in {}). Twelve mutants each fail a test. Both directions: widening every non-default mode, and keeping bypassPermissions or auto. 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 already default, trusting the reported mode, each pin call site dropped, project back 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 project plan started in plan; a project auto was filtered and started in default; session/set_mode default from auto answered {}; session/load reported the mode back. The pin tests replay these answers.

I checked claude-agent-acp 0.84.0 from npm pack. dist/acp-agent.js spreads _meta.claudeCode.options after its default settingSources and uses options.settings. dist/settings.js reads the local file by project path, and dist/permissions/modes.js resolves 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

  • 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

@iamwhatever
iamwhatever requested a review from a team as a code owner September 29, 2026 08:11
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of 2cd4367cbbdbc63e0b9e8e423e840f8d2aa880d3 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 permissions.allow can't approve Crew tools.

Watch

  • Unproven security premise. The safety claim is "The CLI then loads neither the project's local file… No repository allow rule can approve anything." But in project-plan-then-auto-then-pin.jsonl, session/new was sent with settingSources:["user"] and the project's defaultMode=plan, and it still reported currentModeId: "plan". So claude-agent-acp reads .claude/settings.local.json on its own, whatever settingSources says. If its own permission check also reads that file's allow rules, a repository's allow entries approve spawn_run/cron_add/send_message without Crew's gate, which is exactly the hole the withheld array was closing. The mode pin doesn't cover this. The fixtures send no prompt, so no allow rule is ever tested.
    Clears when: a live 0.84.0 fixture where the project file allows an mcp__ Crew tool still produces session/request_permission, or a citation of the adapter source showing its permission check reads only the CLI's settingSources.
  • A cost the operator never chose. Projects that own settings.local.json now silently lose project env, plugins and CLAUDE.md (the description: "do not load"). They get Crew tools instead. The only signal is a log warning, and the Backwards-compatibility section doesn't list this.
    Clears when: the trade is listed as a Breaking: line, or made opt-in/visible to the operator.
  • The description doesn't match the diff. The description lists test_a_crew_authored_session_is_pinned_against_a_user_bypass_mode ("pinned to default"). The diff adds test_a_crew_authored_session_is_not_pinned, and the code returns early when there is no exclusion.
    Clears when: the Tests list matches the code's behaviour.

[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 .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 Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2cd4367

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 2cd4367cbbdbc63e0b9e8e423e840f8d2aa880d3: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 2cd4367cbbdbc63e0b9e8e423e840f8d2aa880d3 — 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/CONCERNS are advisory.

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

  • Item 2 — inherited: in projects that own their own settings.local.json, sessions now silently drop the project's CLAUDE.md, env, plugins and checked-in settings.json, and there is no opt-out. Before this change they loaded, just without Crew's tools. No RFC in the base list covers this trade.
    Clears when: a maintainer records /ai-review override first-principles 2cd4367cbbdbc63e0b9e8e423e840f8d2aa880d3: <decision> accepting the trade.
  • Item 5 — duplicate of src/kiro_crew/acp/client.py:1359 _pi_installed_version: there are 2 manifest walkers (grepped package\.json in acp/), and both do the same shim_roots / .bin / parents search.
    Subtraction: delete _claude_adapter_installed_version and call the pi walker with the package name passed in.
    Clears when: one walker remains.
  • Item 7 — oversized: _verify_claude_project_denies_unchanged only shrinks the window, since the spec says "A rule added after that is the stated residual". No report names anyone who added a deny during session startup.
    Subtraction: delete _verify_claude_project_denies_unchanged and its kill path.
    Clears when: the method is removed, or a reproduction shows a deny added during startup going unenforced.

What this change ships

Inventory (10 items) — 7 justified

Intent: a Claude session in a project with its own .claude/settings.local.json keeps Crew's tools (send_message, cron, spawn). FIX.

  1. Projects owning settings.local.json now get Crew's MCP tools — justified
  2. Those sessions no longer load project CLAUDE.md/env/plugins/settings.json — inherited: no opt-out or recorded decision
  3. Project deny/ask rules ride inline settings — justified
  4. A project file setting hooks/sandbox, or one that can't be read, keeps the old no-tools behaviour — justified
  5. Adapter version floor 0.84.0 read from package.json before spawn — duplicate of _pi_installed_version
  6. A bypass/auto/unreported starting mode is pinned to default; a failed pin stops the session — justified
  7. Project files re-read before first prompt; a new deny stops the session — oversized
  8. The claude binary is now found before the settings seed, so a "not found" error comes earlier — justified
  9. The warning no longer tells users to rename the project file — justified
  10. Spec no longer says dontAsk auto-approves — rides along

[FIRST-PRINCIPLES-REVIEWED] 2cd4367

Description read

[DESCRIPTION-READ] 765fb3e2f409b2386315f1eb0229be152e188e7c371717b69ac5b506d6920f0a

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 Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings that block the merge.

FINDING — src/kiro_crew/acp/client.py:5655 — before the handshake, _claude_adapter_below_setting_sources_floor judges the version read from disk (_claude_adapter_disk_version), but the warning prints _scrub_observed(getattr(self, "_agent_version", "")). That value is still "" on a first spawn, and on a respawn it holds the previous child's version, since it is only reset in __init__. So when an installed 0.80.0 is refused, the operator reads "reported version ''" or a stale version instead of the 0.80.0 that was actually measured → Fix: log the same version the floor check used, picked the same way from _agent_version_read, and say whether it came from disk or from the handshake.

[OPUS-REVIEWED] 2cd4367

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 2cd4367cbbdbc63e0b9e8e423e840f8d2aa880d3: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 29, 2026
@iamwhatever
iamwhatever force-pushed the fix/claude-crew-owned-config-root branch from 1f83f7d to ad728de Compare September 29, 2026 16:59
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 29, 2026
@iamwhatever
iamwhatever force-pushed the fix/claude-crew-owned-config-root branch from ad728de to 056431f Compare September 30, 2026 06:11
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@iamwhatever
iamwhatever force-pushed the fix/claude-crew-owned-config-root branch 3 times, most recently from 4f98cf9 to 273e979 Compare September 30, 2026 07:25
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

/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.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 273e979703104260bdfe4b20675cda5ed92bbfd8.

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.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@iamwhatever
iamwhatever force-pushed the fix/claude-crew-owned-config-root branch from 273e979 to f895eb2 Compare October 2, 2026 16:59
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 2, 2026
@iamwhatever
iamwhatever force-pushed the fix/claude-crew-owned-config-root branch from f895eb2 to 147198e Compare October 2, 2026 19:13
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 3, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

The GPT 5.6 run on db25fa5b finished its review but never published a verdict. Its log raised two blocking findings. Both are fixed in 050b68fb4f:

  • Project hooks and sandbox were dropped. They cannot be carried inline. A PreToolUse hook can also answer allow, and sandbox has autoAllowBashIfSandboxed, so either would reopen a pre-approval channel. A project file that sets hooks or sandbox therefore refuses the exclusion (_CLAUDE_PROJECT_UNCARRIED_GUARD_KEYS). Its tiers keep loading and the array stays withheld, as before this PR. The startup re-read stops a session whose file gained either key. Test: the hooks and sandbox cases of test_unexaminable_project_denies_withhold_the_array.
  • dontAsk was pinned to default. It is no longer pinned. It refuses everything not pre-approved, so it runs nothing default would not. The spec's "accepted trade" paragraph is replaced. Test: dontAsk moved into test_a_mode_that_still_asks_about_crew_tools_is_kept.

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.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 3, 2026
@iamwhatever
iamwhatever force-pushed the fix/claude-crew-owned-config-root branch from 050b68f to 6e98b3b Compare October 3, 2026 03:41
@iamwhatever

Copy link
Copy Markdown
Contributor Author

On 050b68fb, addressed in 6e98b3bbff:

  • Opus BLOCKING: a project defaultMode: plan is dropped. This does not happen. In claude-agent-acp 0.84.0 the starting mode does not come from settingSources. SettingsManager.loadAllSettings calls resolveSettings({ cwd }) across every tier, and getWatchedPaths lists <cwd>/.claude/settings.local.json (dist/settings.js). newSession then computes initialPermissionMode = resolvePermissionMode(creationOpts.permissionMode ?? settingsManager.getSettings().permissions?.defaultMode, …) and passes it to the SDK as an explicit permissionMode (dist/acp-agent.js around lines 6489 and 6617). So a project plan or dontAsk still starts the session in that mode, which is reported in currentModeId. The pin keeps it, since only bypassPermissions, auto and the unreported case are pinned. The spec now states this with the adapter evidence. No code change.
  • Opus FINDING: agent-host-contract.md row still says dontAsk is pinned. Reworded: it is kept, and the pin covers only bypassPermissions and auto.
  • GPT BLOCKING (H13): a claude-only branch in _initialize_session. The settle call is now unconditional, the same way _note_pi_adapter_version and _note_goose_version are called. It keys only on the exclusion flag, which only the claude settings writer sets, so there is no harness branch on the shared path. Harness-parity gate passes.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@iamwhatever
iamwhatever force-pushed the fix/claude-crew-owned-config-root branch from 6e98b3b to b0cb647 Compare October 3, 2026 04:17
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Both blockers on 6e98b3bb are fixed in b0cb6477e6:

  • Opus: project permissions.ask rules were dropped. _project_settings_restrictions now collects both deny and ask (_CLAUDE_CARRIED_PERMISSION_KEYS) and merges them inline beside Crew's own. Both can only narrow what runs. The startup re-read and the shipped record cover ask too, so a file that gains an ask rule before the first prompt stops the session. Tests: test_the_project_tiers_ask_rules_ride_inline and test_an_ask_rule_gained_before_the_first_prompt_stops_the_session.
  • GPT (H13): settle step awaited on the shared handshake. The settle call is gone from _initialize_session. It is now synchronous and runs from _claude_wire_mcp_servers, the claude-only array read inside the existing if self._is_claude splice at each session/new, session/load and retry site. The overridable _claude_session_mcp_servers seam is unchanged. Test: test_the_handshake_itself_awaits_no_claude_step, plus the existing floor tests, which drive the full handshake.

Both guards fail their tests when removed (mutation-checked). Local: 1477 passed; lint, mypy, harness-parity, comment-history and docs-lint clean.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 3, 2026
@iamwhatever
iamwhatever force-pushed the fix/claude-crew-owned-config-root branch from b0cb647 to 8ecc43c Compare October 3, 2026 04:34
@iamwhatever

Copy link
Copy Markdown
Contributor Author

First Principles BLOCK on b0cb6477 is fixed in 8ecc43cd30:

  • Pin scope. The _session_roster_sent branch and its attribute are removed. _pin_claude_starting_mode runs only on the exclusion path, so a Crew-written session is not pinned (the W2-1 residual, as the Goal says). Test: test_a_crew_authored_session_is_not_pinned, which fails if the gate is removed.

  • Adapter premise. Captured live frames of claude-agent-acp 0.84.0, driven over stdio with this path's envelope and no prompt, are in test/fixtures/claude_mode_pin/. Host data is pruned, as each file's _meta notes.

    • A project defaultMode: plan started the session in plan (currentModeId).
    • A project defaultMode: auto was filtered and started in default.
    • session/set_mode default from auto answered {}.
    • session/load reported the mode back.

    The pin tests answer initialize, session/new, session/load and session/set_mode from these frames. Three pure-replay tests use them with no edits. The harness only sets the session id, the floor version and, in the parametrized cases, the starting mode, and says so in its docstring.

Local: 1522 passed (frame-replay suite included). Lint, mypy, harness-parity, comment-history, docs-lint and frame host-data gates are clean.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 3, 2026
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.
@iamwhatever
iamwhatever force-pushed the fix/claude-crew-owned-config-root branch from 8ecc43c to 2cd4367 Compare October 3, 2026 05:04
@iamwhatever

Copy link
Copy Markdown
Contributor Author

On 8ecc43cd, fixed in 2cd4367cbb by reordering, without adding a rebuild step:

  • GPT 6.1 BLOCKING: below-floor projection rebuilt on the event loop. The floor is now decided before the array exists. The claude spawn arm resolves the adapter argv first. It then reads the installed package's own package.json version (_claude_adapter_installed_version, off the loop), and only after that runs the settings writer and warms the array off the loop. Below 0.84.0, or with no readable version, the writer never takes the exclusion, so there is nothing to drop or rebuild later. The settle step and the _claude_wire_mcp_servers accessor are gone. After initialize, a reported agentInfo.version below the floor on a session that took the exclusion stops that session in _pin_claude_starting_mode, which is claude-only and runs before the first prompt. Tests:

    • test_the_handshake_never_resolves_the_array_on_the_loop: any inline resolve during the handshake fails it, at 0.84.0, 0.83.0 and unversioned.
    • test_the_spawn_arm_reads_the_version_before_the_seed_and_the_warm
    • test_an_installed_adapter_below_the_floor_gets_no_tools
    • test_a_handshake_below_the_floor_stops_an_excluded_session
    • test_the_installed_version_is_read_from_the_adapters_own_manifest

    Each guard fails its test when removed (mutation-checked).

  • Backend Tests (Windows) (6) failed on test_harness_parity.py::test_each_mcp_seam_is_spliced_only_for_its_own_harness. That was caused by the _claude_wire_mcp_servers rename at the splice sites. Those sites are back to _claude_session_mcp_servers, and the test passes.

Local: 1604 passed across the ACP, harness-parity and frame-replay suites. Lint, mypy, harness-parity, comment-history and docs-lint are clean.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 3, 2026

@buluoray buluoray 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.

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), then fstat, which requires a regular file of at most 1 MiB, then a bounded read and close.
    • Nothing restores or removes the file on reset, because Crew never authored it.
  • Harness parity.
    • HARNESS_BASE_REF=<merge-base> scripts/check_harness_parity.py passes.
    • H13: every new step is behind self._is_claude. That covers the pin on new at client.py:9861 and on load at :9801, the envelope at :9524 and :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 after mirror 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):
    • SettingsManager is consulted only for defaultMode / disableBypassPermissionsMode (acp-agent.js:6487-6489), availableModels / modelOverrides (:6814-6819, session-model.js:336) and effort (:6116, :6889).
    • canUseTool (:5734 ff.) reads no allow rules. Allow evaluation is the CLI's, and the CLI is what settingSources governs.
    • allowBypass is gated on allowDangerouslySkipPermissions !== false.
  • Load-bearing ordering. _reseed_after_capture runs 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_local ORs 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.py with -x, then restored the file. git status was 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. canUseTool takes no allow rules from SettingsManager (see above). The plan fixture shows the mode channel, and that channel is exactly what the pin covers.
  • Design Review / First Principles: project env, plugins and CLAUDE.md silently 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 has test_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_version duplicates _pi_installed_version (client.py:1359). Real duplication. It is non-blocking cleanup.
  • First Principles: _verify_claude_project_denies_unchanged is oversized. Not a defect. It is fail-closed, and it closes the read-to-session/new window that the prior review's preferred fix depended on. Keeping it is defensible.
  • Opus FINDING: the below-floor warning logs _agent_version instead 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

  1. Project denies and hooks dropped. Fixed.
    • Deny and ask rules are carried at client.py:5620-5631.
    • hooks/sandbox refuse 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.
  2. 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.
  3. Spec contradictions. Fixed.
    • The settingSources paragraph (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.md Auto-mode cell is also fixed: it now says create-or-decline.

Follow-ups (non-blocking)

  • Update the PR body's Tests list: remove test_a_crew_authored_session_is_pinned_against_a_user_bypass_mode and add test_a_crew_authored_session_is_not_pinned. Get the env/plugins/CLAUDE.md trade 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_version into the existing pi manifest walker.

  • _project_settings_restrictions treats a UnicodeDecodeError or a BOM-prefixed file as "no rules". Claude's JS reader may still parse such a file and enforce its denies. Treating it as None (withhold) would remove the ambiguity.

  • Possible spurious kill:

    1. The first write refuses the exclusion (for example, hooks are present).
    2. _reseed_after_capture then takes it.
    3. 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.

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