Skip to content

feat(acp): GooseHarness, goose on the shared runtime with per-session checks (not routed) - #37562

Merged
chenmingwei23 merged 1 commit into
mainfrom
feat/goose-harness
Nov 15, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
feat/goose-harness

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: the shared runtime can drive goose with each session's own permission checks, while no session is routed to it yet.

The shared runtime (AcpRuntime) serves kiro-cli, KAS and codex from one process per runtime. goose still runs one process per chat (GooseAcpClient), because harness_for("goose") has no harness, and the checks that keep a goose session asking before every tool live on the per-chat client: the read-back of the mode goose resolved, the stop on a mid-session move to auto, and the two refusals of goose's _meta.goose.toolCall identity channel. On a per-chat client a refusal kills the session's own process. On a shared process each check must belong to one session.

Why it matters

goose 1.57.0 itself serves many sessions in one process and runs their turns in parallel (measured: one session ran a 60 s shell command while a second answered twice in 0.02 s, with no crosstalk, and a closed session loaded back on the same process). Sharing one goose process across dashboard chats needs a harness first, and it must be safe before any chat is routed to it: a session left in auto asks Crew about nothing, and one refusal that ended the process would end every other chat on it. Users see no change from this PR.

Not a goal

  • No routing: goose is not added to ACP_BACKENDS_ACP_RUNTIME, so every goose chat still runs on GooseAcpClient. The routing, the per-harness switch and the real-goose run land in the next PR.
  • No Side Chat on the shared runtime: its goose home is the child's GOOSE_PATH_ROOT, a process-wide setting, so side sessions keep a process of their own.
  • No goose steer request on the shared runtime: goose's handshake advertises no _session/steering, so the runtime queues a mid-turn message as the next turn, as it does for any host that does not advertise it.
  • No change to kiro-cli, KAS, codex or claude sessions.

What changed (motivation -> approach -> change)

goose's per-session checks had no home on the shared runtime -> the goose harness answers them per session, through the seams ClaudeHarness added plus two new ones -> the session handle runs them only on a host with per_session_state.

  • GooseHarness (acp/harness/goose.py), registered in _HARNESSES and not routed. Spawn: the self-served goose acp argv with --with-builtin developer, under the credential mask (resolve_spawn_masks), with GOOSE_MODE=approve seeded on the child and GOOSE_PATH_ROOT removed. Teardown: session/close as a request, which ends one session and keeps its record. Protocol version and client capabilities are the per-chat client's.
  • Mode read-back per session. after_session_start reads the mode off that session's own session/new or session/load answer; anything but approve (a missing modes block included) closes that session alone and raises the gate's refusal. The process and every other session keep running.
  • Two new seams on HarnessAdapter, inert by default: permission_refusal (a call goose's identity channel classified as nothing, or a trusted identity naming a server this session never placed and that is not goose's own extension) and session_update_issue (a current_mode_update off approve).
  • Session handle wiring. _refuse_by_harness runs in the permission chain beside the other identity refusals. _note_permission_state reads each update in the dispatch loop and in the pre-turn drain, and _refuse_moved_permission_state closes the session and fails the turn, before the frame is yielded or the next prompt goes out. Every call is behind host_checks_sessions(runtime), so kiro-cli, KAS and codex make none (harness-parity H13). AcpRuntimeProtocol names _harness and _session_harness_states.
  • One read for both drivers. session_mode_issue, mode_update_issue and refuse_routing move into acp/harness/goose.py, and GooseAcpClient (client_goose_session.py) uses them. The identity refusals' predicates move into _dispatch_parts/permission_requests.py (unclassified_call_refused, foreign_server_refused, with the two audit reasons as constants, exported from acp/_dispatch.py), and both client_permissions and GooseHarness.permission_refusal call them, so one function decides each refusal on both drivers.
  • goose's own mask. The spawn runs the same refuse-then-mask preflight as GooseLaunch, for goose's backend, and hands back goose's own read-only files (adapter_expose_files).

Backwards compatibility

Compatible: every new seam defaults to doing nothing, only GooseHarness and ClaudeHarness set per_session_state, no backend set routes goose to the runtime, and the per-chat goose client keeps the same checks and messages.

Reader: src/kiro_crew/acp/harness/goose.py:GooseLaunch.session_mcp_servers -- chat -- removed by #37535's commit; the array 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 -- chat -- removed by #37535's commit; its readers moved to GooseAcpClient behind _reads_back_session_mode -- test_the_read_back_is_scoped_to_goose
Reader: src/kiro_crew/acp/client_permissions.py:GOOSE_VERIFIED_VERSION_PREFIX -- chat -- moved to client_goose_session, still exported by kiro_crew.acp.client -- test_goose_tested_version_notice.py
Reader: src/kiro_crew/acp/client_goose_session.py:_verify_goose_routing -- chat -- its body now calls acp.harness.goose.session_mode_issue and refuse_routing, the same read and refusal -- test_acp_goose_backend.py read-back tests
Reader: src/kiro_crew/acp/client_goose_session.py:_tripwire_goose_mode -- chat -- its body now calls acp.harness.goose.mode_update_issue and refuse_routing -- test_a_mid_session_move_off_the_required_mode_stops_the_harness

Tests

  • test/test_goose_shared_runtime.py (new): the harness answers (registered, not routed, session/close teardown, the client's handshake); the spawn argv carries the developer builtin under goose's own mask, the preflight and the re-exposure both asked for goose's backend; both drivers call the same two identity-refusal predicates; the child gets GOOSE_MODE=approve and no GOOSE_PATH_ROOT; approve keeps the session and auto, smart_approve, an empty mode or no modes block each close only that session and refuse; the identity refusals (unclassified call, foreign server, goose's own developer and a placed server pass); the handle closes the session on a mode move, ignores a child session's frame and does nothing on a host without session state; the unclassified read needs the session's own tool_call frame; a real AcpRuntime start in approve records and ends the session's state, and one in auto sends session/close and keeps the process; the dispatch loop and the turn call both refusals.
  • test/test_acp_harness_contract.py: goose joins the harness checks and the registered-ahead-of-routing set.
  • test/test_session_handle_bindings.py: the four new handle members join the inventory.
  • Run locally one file at a time: the files above plus test_acp_goose_backend.py, test_side_readonly_goose.py, test_claude_shared_runtime.py, test_client_bindings.py, test_runtime_bindings.py, test_harness_parity.py, test_acp_session_mcp.py, and the test_acp_runtime_* and test_acp_session_handle_* dispatch, drain, load, start and turn files, all pass. mypy over src/kiro_crew/acp/ is clean.

Proof: not provable -- other: new harness, not routed; no shipped behaviour changes for prove.py to revert

Manual verification

Measured on goose 1.57.0 with a loopback model stub, outside Crew: one process, two sessions; session A's turn ran a 60 s shell command through goose's developer tool (60.2 s), session B was asked at 2 s and at 30 s and answered in 0.03 s and 0.02 s; after session/close of A, B answered in 0.02 s; session/load of A on the same process replayed its answer; neither session's text carried the other's tag. Crew's own run against a real goose is in the routing PR.

Related Issues

Part of #5033

This is step 2 of 3 for goose chat sharing. Step 1 (#37535) moved goose's per-session code onto GooseAcpClient. This step gives the shared runtime a goose harness with each session's own checks, routed to by nothing, so permission_refusal and session_update_issue have one override each until step 3. Step 3, stacked on the claude routing PR #37540 and reusing its routing rather than writing another: goose joins ACP_BACKENDS_CHAT_RUNTIME_SHARING and ACP_BACKENDS_SHARED_RUNTIME_ONLY_FOR_CHATS, so only a dashboard chat whose new "Goose chats" switch (off by default, 13 languages) is on takes the shared runtime; a goose account era from goose's stable provider identity (GOOSE_PROVIDER and its *_HOST keys, never a credential file that refreshes; unreadable means no sharing); and a run against a real goose in a pod, with process counts and memory measured with the switch on and off.

Stacked on #37521 (base feat/claude-harness, the per-session seams) and carries #37535's commit (the goose client move, which also touches docs/system-specs/modules/agent-host-contract.md and a note in src/kiro_crew/agent_sdk/backends.py). Rebased onto main once both land.

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 aa19163a0e3c881bcd77c691d5605b188c13596b 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 aa19163a0e3c881bcd77c691d5605b188c13596b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the harness is registered but no session is routed to it, every new seam does nothing by default, and the per-chat client's checks now call the same functions as the new harness.

Notes

  • The description doesn't match the code on GOOSE_PATH_ROOT. It says the child gets "GOOSE_PATH_ROOT removed" and that the tests check for "no GOOSE_PATH_ROOT". But GooseHarness.apply_spawn_env says "An operator's own GOOSE_PATH_ROOT is kept", and the test asserts env["GOOSE_PATH_ROOT"] == "/operator/goose". Fix the description so the routing PR builds on the behaviour the code actually has.

[DESIGN-REVIEWED] aa19163

Description read

[DESCRIPTION-READ] 5825319183a6d30692f98ff4391911c5976e1af43d9452bfa0dec8e798a4ba1d

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

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] aa19163

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

@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 aa19163a0e3c881bcd77c691d5605b188c13596b — 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 here locks anything in. The harness and its two new seams have no production caller until the routing PR, and all of it can be deleted without anyone noticing.

Notes

  • Item 1 — zero consumers: harness_for("goose") now returns GooseHarness, but goose is not in ACP_BACKENDS_ACP_RUNTIME, so for now only the tests call it ("No routing… land in the next PR"). It is internal and can be deleted, so this is a note, not a blocker. Subtraction: none needed if the routing PR follows.
  • Item 3 — one consumer, generalized: of the base-class seams HarnessAdapter.permission_refusal and session_update_issue, I grepped def permission_refusal|def session_update_issue under acp/ and found one override each, both in harness/goose.py. ClaudeHarness (the other harness with per_session_state = True) overrides neither. Subtraction: if no second harness adopts them in the routing PR, shrink both to goose-only.

What this change ships

Inventory (6 items) — 4 justified

Intent: let one shared goose process serve many chats safely, with each chat keeping its own ask-before-every-tool checks. This is an ADDITION, staged and not routed.

  1. A goose harness that the shared runtime can launch (registered, not routed) — zero consumers
  2. On the shared runtime, a goose session that starts outside approve mode is closed on its own and refused, while the process keeps running — justified
  3. Two new per-session refusal seams on the base harness — one consumer, generalized
  4. The session handle refuses a moved mode or an unvouched tool identity, and only on hosts that keep per-session state — justified
  5. The per-chat goose client and the shared harness now use one mode read and one refusal path — justified
  6. Both drivers share the identity-refusal predicates, and their audit-reason strings are now constants — justified

[FIRST-PRINCIPLES-REVIEWED] aa19163

Description read

[DESCRIPTION-READ] 6c4e6649f474f8d1d8caa5b27892cd9ead33f577177c4118af87bd2141de6d24

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 added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] aa19163

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

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

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Dispositions for f9e8a1d:

  • fixed target=gpt span=src/kiro_crew/acp/harness/goose.py:386 (goose's credential mask)

GooseHarness.resolve_spawn now runs launch._sandbox_preflight for self.backend and adapter_expose_files(self.backend, hidden), as GooseLaunch does; the codex helper is no longer called.
test_the_spawn_loads_the_developer_builtin_under_gooses_own_mask asserts both are asked for the goose backend.

  • fixed target=first-principles Blocker 1 (second spelling of the identity refusals)

unclassified_call_refused and foreign_server_refused now live in _dispatch_parts/permission_requests.py with the two audit reasons as constants; client_permissions._unclassified_tool_call / _foreign_mcp_identity and GooseHarness.permission_refusal both call them, and the client's copy of the predicate is gone.
test_both_drivers_decide_the_identity_refusals_with_one_function pins that both drivers call the same two functions.

  • rebutted target=first-principles Note item 3 (one consumer per new seam)

This PR is step 2 of 3: the seams get their routed consumer in step 3, which routes goose dashboard chats through #37540's routing. The body's Related Issues section states the plan.

@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
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
@chenmingwei23
chenmingwei23 marked this pull request as ready for review November 15, 2026 11:46
@chenmingwei23
chenmingwei23 requested review from bolichen97 and removed request for a team November 15, 2026 11:46
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Nov 15, 2026
@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

Copy link
Copy Markdown
Contributor Author

First Principles (8415923) blocker, second copy of the harness-string scrub: real, fixed in 12038a7.

  • goose.py no longer defines _scrub; session_mode_issue and mode_update_issue lazy-import and call client_permissions._scrub_observed, the scrub the other harness owners use.
  • With no redactor call left in goose.py, the security_posture.py row added in 8415923 is gone too, so this PR no longer touches that file and the Sensitive Change note above no longer applies.
  • Note, item 10: the unused session_key slot and constructor parameter on _GooseSession are removed.

Test: test_a_reported_mode_goes_through_the_shared_refusal_scrub patches _scrub_observed and asserts both reads return its output. With the source change reverted, it fails.

@chenmingwei23
chenmingwei23 force-pushed the feat/goose-harness branch 2 times, most recently from 12038a7 to 40d686d Compare November 15, 2026 15:24
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

GPT 6.1 F1 (test_acp_harness_contract.py:58, missing-binary test depends on goose not being installed): real, fixed in 40d686d.

test_a_missing_binary_aborts_the_spawn now also stubs launch._resolve_self_served_bin to a missing executable and isolates launch._self_served_bin_caches, as it already does for the claude resolver and cache.

Checked with a goose binary on PATH: before the fix the [goose] case fails (1 failed, 4 passed); after it, 5 passed. The whole file passes (156).

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Backend Tests red on 40d686d (3.12 shards 2/3/4/6/7/8, Windows 8): caused by this PR, fixed in dac9d9b (rebased onto main c4f432a).

  • Common cause, about 190 of the failures: host_checks_sessions read runtime._harness.per_session_state with bool(...), so a MagicMock stand-in runtime (the tool-silence, keepalive, watchdog and native-children suites) counted as a host with per-session checks and its turns awaited a non-awaitable terminate_session. It now counts only a literal True.
  • harness/goose.py logs under kiro_crew.acp.client like the other per-process hosts (test_the_owners_log_under_the_names_their_code_logged_under).
  • harness/goose.py imports launch_for from the agent_sdk.backends facade, not the owner (test_no_product_module_but_the_facade_imports_an_owner).
  • The new scrub test patches _scrub_observed through the acp.client facade (test_no_test_patches_a_shared_name_on_an_owner_directly).

All 12 files that failed in CI, plus the goose, harness-contract, security-posture and harness-parity suites, pass locally on the new head: 1423 passed.

@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
@chenmingwei23
chenmingwei23 enabled auto-merge (squash) November 15, 2026 17:16

@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. Goose is still outside ACP_BACKENDS_ACP_RUNTIME, and every harness_for caller gates on that set, so no session reaches GooseHarness yet. host_checks_sessions turns on only for a literal per_session_state is True, so Kiro, KAS, codex and mock runtimes skip the new paths. The client_permissions refactor keeps the same predicates and reasons. The per-chat goose client reads the same mode and raises the same refusal. The new tests use no sleeps, clocks or ports.

Security: the new per-session refusals deny by default and write SEL audit rows. The shared-process and spawn-mask changes do nothing until goose is routed, which is out of scope for this PR. A session refused at start closes only that session and keeps the process, and test_a_session_in_auto_is_closed_and_the_process_kept checks this against a real AcpRuntime.

Done well: each identity refusal now has one function (unclassified_call_refused, foreign_server_refused), and both drivers call it, which removes duplicated security logic.

Optional:

  • Before #37567 routes goose: the mid-turn mode tripwire (session_handle_permissions.py:967) relies on session/close, and terminate_session swallows a failed close. The per-chat driver kills the process instead. Consider failing closed when the close is unconfirmed, and pin that with a test in which the close raises.
  • The body says GOOSE_PATH_ROOT is removed and the spawn uses resolve_spawn_masks. The code (goose.py:388) keeps the operator's GOOSE_PATH_ROOT, the test asserts that, and the spawn runs goose's own preflight. The "Stacked on" paragraph also predates the merge of #37521 and #37535. A body edit fixes both.
  • _refuse_by_harness and the order of the update tripwire relative to the yield are pinned only by name checks. A handle-level test would cover the reject call and the order.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
… checks (not routed)

The shared runtime (AcpRuntime) had no harness for goose, and the checks
that make a goose session ask before every tool lived on AcpClient, where
a refusal kills the session's own process. On one process several
sessions share, each check has to be one session's.

GooseHarness (acp/harness/goose.py) is registered in _HARNESSES and not
routed. Spawn: the self-served `goose acp` argv with the developer
builtin, under the credential mask, GOOSE_MODE=approve seeded on the
child and GOOSE_PATH_ROOT removed (a Side Chat home is process-wide, so
side sessions keep a process of their own). Teardown: session/close as a
request, which ends one session and keeps its record.

Per session, through the seams ClaudeHarness added: after session/new
and session/load the mode goose resolved is read back off that answer,
and a session not in `approve` is closed alone and refused. Two new
seams, inert by default and read only where per_session_state is True:
permission_refusal (the unclassified-call and foreign-server refusals of
goose's _meta.goose.toolCall identity channel, against that session's
placed servers) and session_update_issue (a current_mode_update off
`approve`, read in the turn's dispatch loop and in the pre-turn drain;
the session is closed and its turn fails with the gate's reason).

The mode reads move into acp.harness.goose (session_mode_issue,
mode_update_issue, refuse_routing) and GooseAcpClient uses the same
ones, so both drivers judge goose's answers alike.
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision 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 confirmed four things. Goose is still outside ACP_BACKENDS_ACP_RUNTIME, so no session reaches GooseHarness yet. host_checks_sessions turns on only for a literal True, so Kiro, KAS and codex make none of the new calls. The per-chat GooseAcpClient refactor keeps the same predicates, the same audit reasons and the _kill_process(force=True) tripwire. The new tests use no sleeps, clocks, ports or real children. PR Readiness is green.

Done well: both drivers now decide each identity refusal with one function (unclassified_call_refused, foreign_server_refused), so the two paths cannot drift. A refused session is closed by itself against a real AcpRuntime, and the shared process keeps running.

Security: the new paths add tool-approval refusals, a mode tripwire, and a spawn path with a credential mask and a key strip. None of them runs today, because nothing routes goose to the shared runtime. The refusals deny by default and write audit rows. The spawn uses goose's own _sandbox_preflight and strips KIRO_API_KEY, as the codex and claude harnesses do.

Optional:

  • Before #37567 routes goose: if terminate_session fails or times out, _refuse_moved_permission_state (session_handle_permissions.py:967) still raises locally, but goose may keep the session in auto mode. Consider failing closed when the close is not confirmed, and pin that with a test where the close raises.
  • Tests check _refuse_by_harness and the "refuse before yield / before prompt" order only by method name. One handle-level test on a real AcpSessionHandle would pin reject_tool, the audit reason and the order.
  • Body drift (a body edit is enough): the code keeps the operator's GOOSE_PATH_ROOT, the spawn uses _sandbox_preflight and not resolve_spawn_masks, and the "Stacked on" paragraph and three Reader: lines describe work already on main.

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