Skip to content

fix(acp): share the Claude settings seed when only the model differs - #16782

Merged
iamwhatever merged 2 commits into
kirodotdev:mainfrom
ash663:fix/claude-settings-share-model
Oct 7, 2026
Merged

iamwhatever merged 2 commits into
kirodotdev:mainfrom
ash663:fix/claude-settings-share-model

Conversation

@ash663

@ash663 ash663 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A Claude session keeps Crew's MCP tools, and runs its own model, when it shares a project directory with a session pinned to another model or to none.

Every Claude session in one work_dir shares one Crew-authored .claude/settings.local.json. A later session may share that seed only when its own rendered payload is byte-identical to it. The payload carries a model key whenever the session pins a model, so a model-pinned session next to an unpinned owner is refused the share. A session pinned to a different model than the seed's is refused the same way. A session resumed after a gateway restart hits that case whenever its pin differs from the new owner's. With claude-agent-acp older than 0.84.0 the exclusion fallback is refused too, so the session is not governed and runs with its whole mcpServers array withheld, pooled stubs included: no Crew tools at all.

Why it matters

Whichever session seeds first owns the file. Any later session in that directory whose model key differs from the seed silently loses every Crew MCP tool, and nothing in the session says why.

Not a goal

  • Narrowing what the seed provenance digest covers. The share still validates the seed file's own bytes.
  • No change to the exclusion fallback or its 0.84.0 version floor.

What changed (motivation → approach → change)

Commit 1:

  • Symptom: a model-pinned Claude session sharing a work_dir with an unpinned session launches with no --mcp-config.
  • Cause: _share_settings_seed_if_identical compares whole payloads, and model is the only key that differs.
  • Fix: model grants no permission, and _apply_startup_model sets it live on the session anyway. The new _share_settings_seed_ignoring_model tries the exact share first, then retries it with the payload's model key dropped. Both share sites in src/kiro_crew/acp/client.py call it: the pre-existing-seed branch and the poll after losing the create race. The permission keys (permissions.defaultMode and the rest) still have to match byte for byte.

Commit 2, added after a live run. It covers the different-model case that "Not a goal" deferred when this PR opened, without narrowing the digest.

  • Symptom: a session resumed after a gateway restart came back with --resume and no --mcp-config. It keeps its own slot pin, while the first fresh session after the restart seeds the file under the crew's current pin. Siblings can also be advertised the same models in another order, so availableModels differs as well.
  • Cause: commit 1's retry only drops the payload's model. It matches nothing but a modelless seed with an identical list.
  • Fix: _share_sibling_settings_seed replaces that retry with one rule, taken from how a session's model already reaches the adapter.
    • A sibling's seed is shared when it carries this session's permission keys and still lets the session run its own model.
    • The model half (availableModels, model) grants no permission. _apply_startup_model pushes each session's model live over session/set_config_option, and claude-agent-acp accepts that push only for an availableModels entry.
    • So the seed must list the session's model. A session that pins none pushes nothing and would start on the owner's pin, so it shares only a seed that names no model either.
    • The share validates the seed's own bytes, so the provenance digest still covers the whole file.
  • The seed is read only when it matches the durable record. _settings_path_holds's bounded, no-follow, non-blocking read now hands back the verified bytes (_settings_path_bytes), so a FIFO or an oversized file at the path is refused, not read.
  • docs/system-specs/modules/claude-code-provider.md now describes the rule. It still said the model keys were part of the share boundary.

Backwards compatibility

Compatible: a seed that was shared before is still shared, since the byte-identical check runs first. The new shares are siblings whose seed differs only in the model half and still runs their model. Three cases stay refused, as they were before this PR:

  • a seed whose availableModels does not list the session's model
  • an unpinned session next to a pinned seed
  • any permission difference

Removes nothing: the change only widens when an existing share succeeds. No key, record, validator or path is removed or tightened.

Tests

All in test/test_acp_seed_provenance.py::TestSharedPermissionSurface. Each was run against the code it names and failed there:

Test Fails on
test_a_model_pinned_sibling_shares_a_modelless_seed client.py without commit 1, at assert sibling._claude_settings_shared is True
test_a_sibling_pinned_to_another_model_shares_the_seed commit 1 alone
test_a_sibling_offered_another_model_list_shares_the_seed commit 1 alone
test_an_auto_sibling_offered_another_model_list_shares_the_seed commit 1 alone
test_a_sibling_whose_model_the_seed_does_not_list_is_refused a variant that ignores the model half entirely
test_an_auto_sibling_is_refused_a_pinned_seed a variant that ignores the model half entirely
test_a_fifo_at_the_seed_path_is_refused_without_blocking a variant that reads the seed unbounded (the read blocks)

The rest of the module passes (171 tests), as do the ACP client, session-MCP, permission-seed, model-registry, provider-mirror and member-mount modules. flake8, isort, mypy, the black gate, the harness-parity gate and the docs lint are clean.

Manual verification

A live run on this head (1146248): an isolated gateway (python -m kiro_crew gateway --test-mode, throwaway data home) with the claude backend and claude-agent-acp 0.73.0. That adapter is below the 0.84.0 exclusion floor, so a refused share leaves the session with no Crew MCP tools. All slots share one project directory, and every turn asks the session to call kirocrew-core's list_sessions once.

  1. Slot A, pinned to claude-opus-5.5, runs first. It seeds the shared settings.local.json with "model": "global.anthropic.claude-opus-5-5[1m]" and an availableModels list that includes fable.
  2. Slot B, pinned to claude-fable-5 (Fable 5.0), runs next. Crew folds the pin onto the adapter's advertised fable.
  3. After a gateway restart, a new slot pinned to claude-opus-5.5 runs first and seeds the file again. Slot B then runs again, and the adapter resumes it (resume=<B's session id>, Claude Code --resume).

What slot B showed, read from the seed record, the adapter's own frames (recorded with KIROCREW_ACP_RECORD_FRAMES) and B's Claude Code transcript:

Fresh After restart (--resume)
B in the seed record sharer sharer
Adapter model option as B starts (session/new, session/load) global.anthropic.claude-opus-5-5[1m] (the seed's) global.anthropic.claude-opus-5-5[1m] (the seed's)
Adapter model option after Crew's set_config_option push fable fable
message.model of B's replies in its transcript claude-fable-5 claude-fable-5
B's mcp__kirocrew-core__list_sessions call succeeded succeeded

claude-agent-acp 0.73.0 reports the current model as the model config option's currentValue and sends no models.currentModelId. The adapter starts B on the seed's model, then Crew's push moves it to B's own, both fresh and on resume. Slot A and its post-restart replacement ran claude-opus-5-5 throughout.

Control: the same steps on the base commit (5786c77bc, without this PR). B still ran claude-fable-5, but the gateway refused it the share both times: the gateway logged withholding the whole mcpServers array, the seed record lists no sharer, and B answered that list_sessions is not available.

Related Issues

Surfaced while testing #16200's per-crew ACP backend pins. Those first put a model-pinned crew on Claude next to an unpinned session, and then a resumed session next to a re-pinned one.

Pattern harvest

Not generalizable: the byte-equality share rule is the one place where a non-permission key was compared as if it were a permission.

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

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 4, 2026
@dwu96

dwu96 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

3 similar comments
@dwu96

dwu96 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@ash663
ash663 marked this pull request as ready for review October 4, 2026 18:56
@ash663
ash663 requested a review from a team as a code owner October 4, 2026 18:56
@ash663
ash663 requested a review from iamwhatever October 4, 2026 18:56
@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 4, 2026
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 08c09ec5d454fcc14ec125f26e391804f3f42ed3 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Confirm the dropped rationale that sharing "would silently override the sibling's own pick" no longer holds. The base control run shows the sibling reads the owner's file either way.

[DESIGN-REVIEWED] 08c09ec

Description read

[DESCRIPTION-READ] bcdf8ff58a924743a5e966b34dfdbb696555331c1b35c38752ef02eb40bdec2a

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 Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 08c09ec5d454fcc14ec125f26e391804f3f42ed3 via the fork AI-review pipeline — 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: PASS

Check one thing: the live push-over-seed proof ran only on claude-agent-acp 0.73.0. Confirm a sibling still lands on its own model on an adapter at 0.84.0 or later.

What this change ships

Inventory (6 items) — 6 justified

Intent: a Claude session that shares a project directory with a session pinned to another model, or to none, keeps Crew's MCP tools and runs its own model. FIX.

  1. A model-pinned session next to an unpinned seed owner now gets Crew's MCP tools — justified
  2. A session pinned to a different model than the seed's now shares the seed and runs its own model — justified
  3. A seed with a differently ordered availableModels list no longer blocks the share — justified
  4. An unpinned session still refuses a pinned seed, and any difference in a permission key is still refused — justified
  5. The seed is read for the share check through the existing bounded, no-follow read (_settings_path_bytes), so a FIFO or oversized file is refused rather than read — justified
  6. The spec now drops the "model keys are part of the share boundary" sentence and states the permission-only boundary — justified

[FIRST-PRINCIPLES-REVIEWED] 08c09ec

Description read

[DESCRIPTION-READ] cfbfdeb3aa11575bc00d441d28d07e0c003cfc610d06f26314d7f8cf17a759a5

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 Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 08c09ec5d454fcc14ec125f26e391804f3f42ed3 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 08c09ec

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 08c09ec5d454fcc14ec125f26e391804f3f42ed3 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 08c09ec

@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 4, 2026
@ash663

ash663 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Updated the description: the Goal now includes sessions pinned to different models (Not a goal dropped that exclusion), and Manual verification records a live run.

On this head (claude-agent-acp 0.73.0), a sibling pinned to Fable 5.0 shares an Opus 5.5 seed, fresh and after a restart with --resume. Each time the adapter reports fable after Crew's push, the transcript shows claude-fable-5, and the sibling's Crew MCP call succeeds. On the base commit the same steps withhold the sibling's MCP servers both times.

@bolichen97
bolichen97 force-pushed the fix/claude-settings-share-model branch from 1146248 to 6c939ba Compare October 6, 2026 09:41

Copy link
Copy Markdown
Contributor

Rebased this branch onto current main (cc7e79894e). There were no conflicts.

  • Head moved from 1146248334 to 6c939bafc7. Pushed with --force-with-lease against the old head.
  • git range-diff shows both commits unchanged (=).
  • py_compile passes for src/kiro_crew/acp/client.py and test/test_acp_seed_provenance.py.
  • pytest test/test_acp_seed_provenance.py passes (171 tests).

This is an automated maintenance rebase: there had been no activity from anyone else on the PR in the last 6 hours. No code was changed.

@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 Oct 6, 2026
ash663 added 2 commits October 7, 2026 09:10
A claude session whose rendered settings payload differed from the shared
.claude/settings.local.json only in the "model" key was refused the share.
Below claude-agent-acp 0.84.0 the exclusion fallback is unavailable too, so
the session ran with its whole mcpServers array withheld.

"model" grants no permission and _apply_startup_model sets it live, so retry
the share with the payload's model key dropped.
A Claude session resumed after a gateway restart keeps its own slot
pin, while the first fresh session after the restart seeds the shared
settings file under another model. Siblings can also be advertised
the same models in another order. Either way the payload differed
from the seed outside every permission key, the share was refused,
and the session ran with its whole mcpServers array withheld.

Share a sibling's seed when it carries this session's permission keys
and still lets the session run its own model. The model half grants
no permission, and _apply_startup_model pushes each session's model
live, which the adapter accepts only for an availableModels entry. So
the seed must list the session's model, or name none when the session
pins none. This one rule replaces the model-key retry, and the share
still validates the seed's own bytes.

The seed is read only when it matches the durable record, through the
bounded, no-follow, non-blocking read the ownership check already
uses, so a FIFO or an oversized file at the path is refused unread.
@ash663
ash663 force-pushed the fix/claude-settings-share-model branch from 6c939ba to 08c09ec Compare October 7, 2026 13:10
@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 7, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 7, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Reviewed, not approving (crew-pr-reviewer). It changes when a Claude session reuses a sibling's settings seed, which decides that session's MCP tools and model. A maintainer should confirm the sharing rule.

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

Approving after a deeper pass (crew-pr-reviewer). This fixes a real loss: a model-pinned Claude session next to an unpinned owner was refused the shared seed and ran without Crew's MCP tools. The share now allows only the model half (availableModels, model) to differ. The sibling seed bytes are read without following links or waiting on FIFOs, and must match the expected size and hash. It is a one-file change with 7 tests, and Design and First Principles lanes PASS. CI is green and the base is main.

@iamwhatever
iamwhatever enabled auto-merge (squash) October 7, 2026 16:31
@iamwhatever
iamwhatever merged commit acc0809 into kirodotdev:main Oct 7, 2026
104 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 7, 2026
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.

4 participants