Skip to content

refactor(acp): move the goose session code off AcpClient into GooseAcpClient - #37535

Merged
chenmingwei23 merged 1 commit into
mainfrom
refactor/goose-out-of-acpclient
Nov 15, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
refactor/goose-out-of-acpclient

Conversation

@chenmingwei23

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: AcpClient holds no goose-only code; a goose session runs exactly as before from a class of its own.

AcpClient is the per-session client every non-KAS backend shares, and it carried goose's session contract: reading back the permission mode goose reports when a session opens or is restored, stopping a session that reports leaving that mode, naming a goose release outside the verified range at the handshake, and building goose's MCP array. Those sat behind _is_goose branches in the shared start and permission code and a goose seam on the process adapter.

Why it matters

goose dashboard chats are next to share one ACP process, the way KAS and codex chats can. That needs goose's per-session checks to be a unit the shared runtime can run per session. This is the first of three PRs, done the way claude was split in #37484. Users see no change from this PR.

Not a goal

  • No behaviour change for any backend, goose included.
  • No goose chat sharing yet; that lands in the two follow-up PRs.
  • The goose steer request (_CLIENT_STEERING_REQUEST_METHODS) stays on AcpClient: it is a capability table keyed by backend, not an _is_goose branch.
  • No change to the ACP_BACKENDS_* capability sets or the tables keyed by backend (protocol version, tested range, steer floor).

What changed (motivation -> approach -> change)

goose code was spread across the shared client -> it now lives in GooseAcpClient(AcpClient) (acp/client_goose.py), bound from one owner module (acp/client_goose_session.py) -> AcpClient keeps one hook per step with what every other backend already did, and the subclass fills it.

  • The class. AcpClient(acp_backend="goose", ...) builds a GooseAcpClient through the __init_subclass__(serves=...) registry refactor(acp): move the claude-agent-acp session code off AcpClient into ClaudeAcpClient #37484 added, so no caller changes. A class that reads no mode back is refused the goose backend before any process exists (_SESSION_MODE_READ_BACK_BACKENDS), so an edition subclass cannot start goose without its read-back.
  • Hooks on AcpClient. _reads_back_session_mode (False), _verify_session_mode and _tripwire_session_mode (no-ops). The start path and _tripwire_permission_state read the flag before calling either, so kiro-cli and every other backend make no extra call. The version note uses the existing _note_harness_adapter_version hook, and the MCP array uses the existing _harness_session_mcp_servers hook in place of the goose seam on GooseLaunch, so the array order sent on session/new and session/load is unchanged.
  • Moved verbatim from client_permissions and client_mcp_array: _verify_goose_routing, _tripwire_goose_mode, _note_goose_version, _goose_session_mcp_servers, GOOSE_VERIFIED_VERSION_PREFIX and its once-per-process memo. Their if not self._is_goose: return guards are gone, because only a goose session builds the class. _is_goose is removed.
  • ProcessSession no longer lists _goose_session_mcp_servers. A doc line in agent-host-contract.md, the goose harness docstring and the ACP_BACKEND_GOOSE note in agent_sdk/backends.py name the new home.

Backwards compatibility

Compatible: AcpClient(acp_backend="goose") still builds a goose client, the facade still exports GOOSE_VERIFIED_VERSION_PREFIX, and the session start, read-back and tripwire run the same code in the same order.

Reader: src/kiro_crew/acp/harness/goose.py:GooseLaunch.session_mcp_servers -- removed; the array now comes from GooseAcpClient._harness_session_mcp_servers on the same two call sites -- test_goose_gets_its_own_mcp_array_at_both_session_call_sites
Reader: src/kiro_crew/acp/client_class.py:AcpClient._is_goose -- removed; its readers were the five moved members and two start-path branches, now _reads_back_session_mode -- test_the_read_back_is_scoped_to_goose
Reader: src/kiro_crew/acp/client_permissions.py:GOOSE_VERIFIED_VERSION_PREFIX -- moved to client_goose_session, still exported by kiro_crew.acp.client -- test_goose_tested_version_notice.py

Tests

  • test_client_bindings.py: a GooseAcpClient inventory, each member bound from client_goose_session; the three new hooks join the AcpClient inventory.
  • test_acp_goose_backend.py: the read-back, tripwire and version tests build the class the backend builds; new test_a_class_that_reads_no_mode_back_refuses_goose (an AcpClient subclass without the read-back is refused goose); the call-site tests now count the hook calls.
  • test_harness_parity.py: GooseAcpClient fills _harness_session_mcp_servers with its own array; GooseLaunch asks no MCP seam.
  • test_acp_mcp_startable.py, test_side_readonly_goose.py, test_goose_tested_version_notice.py: follow the members.
  • Run locally, one file at a time: the files above plus test_acp_harness_contract.py, test_acp_session_mcp.py, test_acp_session_mcp_client_seam.py, test_goose_steer_request.py, test_member_dispatch_mount.py, test_campaign_facades_base_public_names.py and the other goose-touching client tests, all pass. mypy over src/kiro_crew/ is clean.

Proof: not provable -- other: refactor with no behaviour change; tests follow the moved members

Manual verification

N/A -- no behaviour change; unit coverage of the moved members and the new refusal is sufficient. goose chat sharing, which these hooks prepare for, gets a real goose run in the PR that routes it.

Related Issues

Part of #5033

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)
  • No secrets, credentials, or internal references in the diff

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the goose-only branches move behind the existing per-backend subclass registry, and goose is refused to a class that skips the mode read-back, so it can't silently start without its permission check.

[DESIGN-REVIEWED] 3e3d072

Description read

[DESCRIPTION-READ] acc402c75de416e906b004cfaff26f603203c4637fb6f8fe023223bada7084c7

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 3e3d0725e69c9db7f4b085318009bce84e986d48 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Every item moves existing goose code or deletes a goose seam. The one new refusal is there because of the move: without it, a goose session could start without its permission-mode read-back.

What this change ships

Inventory (8 items) — 8 justified

Intent: separate goose's per-session checks from the shared client so a later PR can let goose chats share one ACP process. This is a refactor, which here means an ADDITION with no behaviour change.

  1. goose sessions are served by their own client class, which the existing serves= registry builds — justified
  2. A client class that does not read back the session mode is now refused the goose backend before any process starts — justified
  3. Three hooks on AcpClient (_reads_back_session_mode, _verify_session_mode, _tripwire_session_mode) replace the _is_goose branches in start and permissions — justified
  4. The goose MCP array goes through the existing _harness_session_mcp_servers hook; GooseLaunch.session_mcp_servers is deleted — justified
  5. ProcessSession protocol drops _goose_session_mcp_servers — justified
  6. The goose version note goes through the existing _note_harness_adapter_version hook; the separate start-path call is deleted — justified
  7. The _is_goose property is removed from AcpClient — justified
  8. The agent-host-contract doc and the docstrings name the new home — justified

[FIRST-PRINCIPLES-REVIEWED] 3e3d072

Description read

[DESCRIPTION-READ] 0c8bead0f6dbb4c734c771877cba6577aff7115b68c5d28855f1e901eaceb649

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 3e3d072

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

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

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 3e3d072

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

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 6) and Coverage Gate on ca32f2f are red for three TestOffOffer tests in test/metrics/test_kiro_export_destination.py. They fail the same way on main at 87b11b5, this PR's base: #37460 removed the default-home fake from the shared fixture while #37463 added tests that need it. This PR touches no metrics code. Fix for main: #37545. This PR will rebase once it lands.

@chenmingwei23
chenmingwei23 marked this pull request as ready for review November 15, 2026 07:17
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 729 lines, more than the 400 it may approve on its own.

A clean, behaviour-preserving refactor that moves goose-only session code into GooseAcpClient. I verified that the moved functions match the originals apart from the removed _is_goose guards, that no references to _is_goose or the old names are left in src, and that the MCP array order is unchanged (client-class servers, then the now-empty adapter part for goose, then pooled servers). The read-back still runs on session/new and on a successful session/load, and the tripwire still runs on every frame through _tripwire_permission_state. A new check in new refuses goose to any class that doesn't read the mode back, before a process starts, so it fails closed. The tests follow the moved members and add a refusal test. The CI failures are in unrelated metrics tests.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit ca32f2fbe1 · 729 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@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 Nov 15, 2026
…pClient

AcpClient carried goose's session contract: the read-back of the
permission mode goose reports on session/new and session/load, the
mid-session mode tripwire, the handshake note of a goose release outside
the verified range, and goose's MCP array, behind `_is_goose` branches in
the shared start and permission code and a goose seam on the process
adapter.

GooseAcpClient (acp/client_goose.py) now holds all of it, bound from the
new owner module client_goose_session. AcpClient keeps one hook per step
(`_reads_back_session_mode`, `_verify_session_mode`,
`_tripwire_session_mode`, plus the existing `_note_harness_adapter_version`
and `_harness_session_mcp_servers`) with the behaviour every other backend
already had, and the subclass fills it. AcpClient(acp_backend="goose")
builds GooseAcpClient, so no caller changes; a class that reads no mode
back refuses the goose backend.

Behaviour is unchanged. The tests follow the members to the new class.
@chenmingwei23
chenmingwei23 force-pushed the refactor/goose-out-of-acpclient branch from ca32f2f to 3e3d072 Compare November 15, 2026 08:36
@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 Nov 15, 2026
@chenmingwei23
chenmingwei23 enabled auto-merge (squash) November 15, 2026 09:06
@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 Nov 15, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving. On this head the review checked these points. The four goose functions moved to client_goose_session.py match their originals body for body, apart from the dropped _is_goose guards. The session/new and session/load read-backs and the tripwire dispatch now key on _reads_back_session_mode, and only GooseAcpClient sets it. The MCP array order is unchanged at both splice sites. The head merges cleanly with current main, and no _is_goose reader is left.

Done well: the new AcpClient.__new__ refusal fails closed. A class that does not read back the mode cannot start goose, and test_a_class_that_reads_no_mode_back_refuses_goose pins both sides.

Security: the goose permission-mode read-back and mid-session tripwire move behind new hooks, but their logic is not changed. The SEL audit, the forced kill and the AcpToolGateUnroutable translation are all preserved verbatim. The new __new__ refusal means a missing or unimported GooseAcpClient raises before any process exists, so the type-based dispatch cannot fail open. Nothing that main refuses is now allowed.

Optional:

  • No test drives _verify_session_mode or _tripwire_session_mode (or the dispatch in _tripwire_permission_state) on a goose client. The existing tests call the impl names directly. Two short tests would pin it: an auto response through _stub()._verify_session_mode(...) that raises, and an auto frame through _tripwire_permission_state that raises and kills.
  • docs/system-specs/modules/acp-client.md:74 still lists the goose-mode tripwire under client_permissions.py, and the goose cell at agent-host-contract.md:102 still cites client_permissions.py for the read-back. Both should point at client_goose_session.py.
  • The Backwards compatibility section could add a Breaking line for an edition subclass of AcpClient built for goose, which is now refused and must subclass GooseAcpClient. No in-tree class is affected.

@chenmingwei23
chenmingwei23 merged commit f031b77 into main Nov 15, 2026
99 checks passed
@chenmingwei23
chenmingwei23 deleted the refactor/goose-out-of-acpclient branch November 15, 2026 10:19
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 15, 2026
@LuisBrel LuisBrel mentioned this pull request Nov 15, 2026
5 tasks done
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