Skip to content

fix: backport #31016 and #33057 to 0.12.1 (agent socket for enforced harnesses) - #33177

Merged
buluoray merged 5 commits into
release/0.12.0from
crew/slack/0.12.1-ipc
Nov 8, 2026
Merged

buluoray merged 5 commits into
release/0.12.0from
crew/slack/0.12.1-ipc

Conversation

@buluoray

@buluoray buluoray commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring #31016 (kirocrew-core reaches the gateway under an enforced harness, through a capability-bound agent socket) and its deadlock fix #33057 from main onto release/0.12.0, in one small batch.

Why it matters

On 0.12.0, an enforced harness withholds the gateway's internal secret from its child, so the Kiro Crew MCP server inside it cannot reach the gateway's internal routes and its tools fail. #31016 adds an agent socket that admits that server by a one-time pickup bound to the peer pid. #31016 was dropped from fast batch 1 (#32866) because Opus found that its capability store's weakref.finalize callback took a non-reentrant lock that garbage collection can re-enter on the same thread, hanging the gateway. #33057 fixes that on main, so the two ship together.

Not a goal

  • No fix that is not already merged on main; nothing is changed only here.
  • No version bump, no tag, no CHANGELOG.md change.

What changed (motivation → approach → change)

Five picks with -x onto release/0.12.0 @ c87b986e65 (the live head from git ls-remote at the start), one commit each, in this order:

Pick Main commit Why Resolution
#30788 docs(rfc) 30e1626165 Prerequisite: #31016's security.md text links to rfc-sandbox-ipc-capability.md, which release lacks docs/request-for-change/README.md hand-resolved: release has an older audit sentence, so #30788's sentence was appended to it and its row inserted
#31016 2f20f5b560 The agent-socket capability path Clean; added and removed lines identical to the main commit
#33057 1d9a632618 The finalizer no longer takes the store lock; the next locked call drains queued retires Clean; added and removed lines identical to the main commit
#33192 b4a564562d No pickup on a broker-stub kirocrew-core element, so no other same-uid process can read and redeem it; the e2e child runs with -B Clean; added and removed lines identical to the main commit
#33269 8e4486f613 A granted agent-socket session query writes its SEL grant row (_log_auth), like every other capability grant Clean; added and removed lines identical to the main commit

Every commit is authored with the public identity and names its original author.

builder-security checked: #31016 adds a unix listener (agent-ipc/agent-<port>.sock) in the gateway's data home, same uid only, no TCP, refusing X-Internal-Secret; it is taken exactly as merged on main, where it was reviewed. No other bind, route, auth or storage change.

Backwards compatibility

Compatible: the dashboard TCP path and the existing secret-based internal auth are untouched; the agent socket only adds a way in for enforced-harness children.

Removes nothing.

Tests

Proof: not provable -- other: a backport of main commits whose proof ran on their own PRs

  • CI does not run the backend suite on PRs into release/*, so the related set was run here: every test file the picks touch or that imports a changed module or reads the touched docs, 262 files, sequential batches of 20, -n0. 11101 passed, 0 failed, including test/test_agent_ipc.py (the new test_an_owner_collected_while_the_store_lock_is_held_does_not_hang and test_a_granted_session_query_writes_one_granted_sel_row), test/test_agent_ipc_client.py (the new test_a_broker_stub_for_kirocrew_core_gets_no_pickup) and test/test_agent_ipc_enforced_spawn_e2e.py.
  • black, flake8 and mypy (--platform linux) pass. scripts/docs-lint.sh reports one finding, docs/decisions/2026-11-07-a-registered-themes-overlays-can-be-turned-off.md not indexed, which a clean release/0.12.0 @ c87b986e65 reports the same way; this batch does not touch it.

Manual verification

N/A - verified on the main PRs. The 0.12.1 RC soak is the end-to-end check.

Screenshots / video

N/A - no frontend file changes.

Related Issues

Backport to the 0.12 line for 0.12.1 of #31016, #33057, #33192 and #33269 (prerequisite #30788). Refs #32866.

Sibling sweep

Siblings: none -- the source PRs carried their own sibling sweeps; this PR only carries those fixes.

Pattern harvest

Not generalizable: this PR only carries fixes already on main. The source PRs have their own harvest.

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

(cherry picked from commit 30e1626)

Original author: Bolin Chen (#30788). Prerequisite of #31016: the security.md text it ships links to this RFC. Hand-resolved: docs/request-for-change/README.md (release carries an older audit sentence; appended this RFC's sentence and inserted its row).
…ss (#31016)

* feat(dashboard): add the agent socket and its ipc capability

Phase 1a of rfc-sandbox-ipc-capability. A Kiro Crew server under an
enforced harness is withheld the internal secret by design, so every
gateway-backed tool it serves is refused (#11988). This adds a second
unix listener that authenticates by connection instead: a one-time
pickup is redeemed for a capability bound to the redeeming process,
admitted only from that process, on internal routes, for the session
its stub token names. token_auth routes an admitted request onto its
ordinary internal-grant arm; the listener takes no secret, cookie or
bypass. Nothing issues a pickup yet, so no session changes.

* fix(acp): let kirocrew-core reach the gateway under an enforced harness

Phase 1b of rfc-sandbox-ipc-capability. An enforced harness (codex,
opencode, goose, pi) masks the internal secret from kirocrew-core, so
every gateway-backed tool, memory included, was refused
internal_secret_missing. The session's array now carries a one-time
pickup on kirocrew-core's element for those harnesses only; the server
takes it out of its environment at startup, redeems it on the agent
socket, and sends every request there by capability, never over TCP.
Other harnesses keep today's array and path unchanged.

(cherry picked from commit 2f20f5b)

Original author: Ray Xu (#31016).
…ck (#33057)

The capability store's weakref.finalize callback took the store's
non-reentrant lock. The cyclic garbage collector can run that callback
on a thread that already holds the lock (inside issue, or redeem's
locked liveness check), and the thread then waits on itself forever,
hanging the event loop or the subprocess executor.

The finalizer now only queues the pickup's digest; the next issue,
redeem or verify drops every queued pickup and its capability under
the lock before it reads, so a retired pickup is never served.

Refs #31016, #32866

(cherry picked from commit 1d9a632)

Original author: Ray Xu (#33057).
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 8, 2026 13:03
@buluoray
buluoray requested review from tim-finnigan and removed request for a team November 8, 2026 13:04
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 903e0db549466d94945655a9714a7a8ae9b0fc7f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. This backport changes only backend IPC code, tests and docs, and adds or changes no user-visible control, so no screenshot is needed.

[UX-REVIEWED] 903e0db

Description read

[DESCRIPTION-READ] 4fccd4199c7ab2aa56f469d1612bd4ba25550a39770d891fbc81a310ccb63195

That sha256 names everything this verdict read: the PR description, plus the 3 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 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: this is a straight backport of reviewed main commits, and the agent socket is purely additive. Windows, macOS and any bind failure fall back to today's secret-over-TCP path.

Notes

  • CI does not run the backend suite on PRs into release/*, so the local -n0 related-set run and the 0.12.1 RC soak are the only proof here. Make sure the RC soak includes a run under an enforced harness, because that is the only path this batch changes.

[DESIGN-REVIEWED] 903e0db

Description read

[DESCRIPTION-READ] cd59ddaba9a8da461d72e1de5abd3b352a422367170c54d387d2406ca5e0ab19

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 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 903e0db549466d94945655a9714a7a8ae9b0fc7f — 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

This backports four reviewed fixes from main with nothing new added. The extra files in the patch come from the release branch moving forward since c87b986e65, not from this PR.

What this change ships

Inventory (5 items) — 4 justified

Intent: under an enforced harness on 0.12.x, Kiro Crew's own MCP tools should reach the gateway again, and the gateway should not hang. This is a FIX (backport).

  1. The draft RFC rfc-sandbox-ipc-capability.md and its README row now ship on the release line, only so a link in security.md resolves — rides along
  2. An MCP server inside an enforced harness reaches the gateway through a same-uid agent socket with a one-time, pid-bound pickup (fix(acp): let kirocrew-core reach the gateway under an enforced harness #31016) — justified
  3. The gateway no longer deadlocks when garbage collection runs the capability store's finalizer while the store lock is held (fix(agent-ipc): drop a collected owner's pickup without taking the lock #33057) — justified
  4. A broker-stub kirocrew-core entry gets no pickup, so no other same-uid process can redeem it (fix(agent-ipc): give no pickup to a broker-stub kirocrew-core element #33192) — justified
  5. A granted agent-socket session query now writes its SEL grant row (fix(agent-ipc): record a granted session query in the SEL #33269) — justified

[FIRST-PRINCIPLES-REVIEWED] 903e0db

Description read

[DESCRIPTION-READ] e0be54cdedbd56e28855a64719517724c77a73e5faba38634b081a8f3f48d410

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 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 903e0db

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

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 903e0db

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

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

@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 8, 2026
buluoray added a commit that referenced this pull request Nov 8, 2026
with_ipc_pickups matched the element name only, so when an operator
stubs kirocrew-core through the gateway broker the pickup landed on the
stub's environment. The stub never takes it out, so a same-uid shell in
the session could read it from /proc/<pid>/environ and redeem it for a
capability that reaches the internal routes.

A pickup now goes only on an element that launches the server
directly; an argv running the broker stub module, or one that cannot
be read, gets none. The enforced-spawn e2e child also runs with -B so
it writes no bytecode into the checkout it imports.

Refs #31016, #33177
chenmingwei23 pushed a commit that referenced this pull request Nov 8, 2026
…#33192)

with_ipc_pickups matched the element name only, so when an operator
stubs kirocrew-core through the gateway broker the pickup landed on the
stub's environment. The stub never takes it out, so a same-uid shell in
the session could read it from /proc/<pid>/environ and redeem it for a
capability that reaches the internal routes.

A pickup now goes only on an element that launches the server
directly; an argv running the broker stub module, or one that cannot
be read, gets none. The enforced-spawn e2e child also runs with -B so
it writes no bytecode into the checkout it imports.

Refs #31016, #33177
…#33192)

with_ipc_pickups matched the element name only, so when an operator
stubs kirocrew-core through the gateway broker the pickup landed on the
stub's environment. The stub never takes it out, so a same-uid shell in
the session could read it from /proc/<pid>/environ and redeem it for a
capability that reaches the internal routes.

A pickup now goes only on an element that launches the server
directly; an argv running the broker stub module, or one that cannot
be read, gets none. The enforced-spawn e2e child also runs with -B so
it writes no bytecode into the checkout it imports.

Refs #31016, #33177

(cherry picked from commit b4a5645)

Original author: Ray Xu (#33192).
@buluoray

buluoray commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

span=fc798caba597
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

  • pickup put on a broker-stub kirocrew-core element

fixed in 20a58a0: fixed on main first by #33192 (b4a5645) and picked here as the 4th commit. with_ipc_pickups gives a pickup only to an element that launches the server directly; an argv running -m STUB_MODULE, or one it cannot read, gets none. test_a_broker_stub_for_kirocrew_core_gets_no_pickup fails without the check (prove.py PROVEN on main).

@buluoray

buluoray commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

span=974bf9de500d
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

  • E2E child leaves bytecode in the checkout

fixed in 20a58a0: fixed on main first by #33192 (b4a5645) and picked here. The enforced-spawn e2e child runs sys.executable -B -c, so importing the checkout writes no bytecode into src/.

@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 Nov 8, 2026
KiroCrewCaptain pushed a commit that referenced this pull request Nov 8, 2026
GET /api/ipc/session answered a verified capability holder without
writing any audit row, so a granted capability decision never reached
the operator's SEL. Every other grant on the agent socket is recorded.

The session-query success path now writes the same granted
dashboard.token_auth row as the internal-route grant.

Refs #31016, #33177
GET /api/ipc/session answered a verified capability holder without
writing any audit row, so a granted capability decision never reached
the operator's SEL. Every other grant on the agent socket is recorded.

The session-query success path now writes the same granted
dashboard.token_auth row as the internal-route grant.

Refs #31016, #33177

(cherry picked from commit 8e4486f)

Original author: Ray Xu (#33269).
@buluoray

buluoray commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

span=78195fa567a8
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

  • Successful session-query authorization skips SEL auditing

fixed in 903e0db: fixed on main first by #33269 (8e4486f) and picked here as the 5th commit. The session-query success path in agent_socket_gate writes _log_auth(request, "agent-ipc", "granted", "session query <server>") before it answers, the same grant row the internal-route path writes. test_a_granted_session_query_writes_one_granted_sel_row fails without it (prove.py PROVEN on main).

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 8, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@buluoray
buluoray merged commit 4061ea1 into release/0.12.0 Nov 8, 2026
25 of 37 checks passed
@buluoray
buluoray deleted the crew/slack/0.12.1-ipc branch November 8, 2026 18:28
buluoray added a commit that referenced this pull request Nov 8, 2026
…#33192)

with_ipc_pickups matched the element name only, so when an operator
stubs kirocrew-core through the gateway broker the pickup landed on the
stub's environment. The stub never takes it out, so a same-uid shell in
the session could read it from /proc/<pid>/environ and redeem it for a
capability that reaches the internal routes.

A pickup now goes only on an element that launches the server
directly; an argv running the broker stub module, or one that cannot
be read, gets none. The enforced-spawn e2e child also runs with -B so
it writes no bytecode into the checkout it imports.

Refs #31016, #33177

(cherry picked from commit b4a5645)

Original author: Ray Xu (#33192).
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Nov 8, 2026
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.

1 participant