Skip to content

feat(acp): serve codex from the shared runtime - #11267

Merged
chenmingwei23 merged 1 commit into
mainfrom
feat/acp-codex-flip
Sep 19, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
feat/acp-codex-flip

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Codex chats start separate adapter processes although the adapter can host multiple sessions. Crew also carries a second codex launch path behind KIROCREW_CODEX_ACP_RUNTIME.

Why it matters

One process per chat wastes memory. Two launch paths can disagree on tool delivery, teardown and diagnostics.

What changed (motivation → approach → change)

Codex uses AcpRuntime. The preview switch and the codex AcpClient spawn arm are removed. Each session still has its own identity and tool roster. Codex remains outside shared-subagent session membership.

Area Change
agent_sdk/backends.py, acp/types.py, acp_backends.py Declare runtime routing, session eviction and off-array spec-server membership; preserve the other hosts' capability sets.
acp/harness/codex.py, acp/harness/base.py, acp/harness/__init__.py Resolve codex launch and sandbox masks through its harness. Teardown sends an awaited session/close request. Core RSS uses a 1024 MB ceiling and a launcher-adjusted depth; an INFO log names the substituted operator threshold.
acp/client.py, providers/acp.py Remove the duplicate codex arm. Keep overlay handling tied to its actual reader sets. Capture the selected backend before client replacement for startup metrics.
acp/runtime.py, acp/session_handle.py, acp/session_provider.py, session.py Use eviction membership for create-and-destroy paths. Share the final wire roster with reports and timeout diagnostics, including after KAS resume hoisting. Run the unresolved-ref diagnostic synchronously on a fail-soft snapshot from existing off-loop work.
agent_sdk/mcp_refs.py, providers/mirrors/codex.py, providers/mirrors/README.md Account for kiro/KAS spec servers delivered outside the session array. Describe the measured SSE outcomes by element shape.
agent_sdk/backend_cards.py Stop treating runtime membership as kiro-family membership. Classify transport details separately and remove the unused stand-in constant.
test/, including test/acp_launch_capture.py and test/fixtures/acp_launch_goldens.json Pin routing, teardown, roster identity and launch behavior. Capture codex through the runtime to the process factory. Compare environment deltas against the installed parent environment, preserving Windows key folding and POSIX case sensitivity.
.github/black-baseline.txt Remove the startup-metric test's entry because that file is Black-clean.
docs/system-specs/modules/ Align the provider, session, harness and agent-host contracts with these behaviors.

The scope follows the four-PR plan and #10292, with the flip and duplicate-arm removal together. The recorded probe measured the adapter plus app-server separately from its per-session MCP fleet. The constant core ceiling is intentional; it is not an operator-configurable subtree limit. Windows bounded RSS remains unknown, so age still governs.

Backwards compatibility

Breaking: KIROCREW_CODEX_ACP_RUNTIME, acp_runtime_backends() and codex_runs_on_acp_runtime() are removed; codex uses the shared runtime by default. The selected provider remains ACP. Codex is not granted shared-subagent continuation. session/close evicts in-memory adapter state rather than archiving the conversation with session/delete.

No credential-mask change is included in this verification repair. AWS_CONFIG_FILE remains a documented gap: the existing read-only .aws/config exposure does not support wrappers that need to rewrite that file.

Tests

  • Harness/runtime tests pin capability membership, close-as-request delivery, RSS scope, and final-roster reporting.
  • The KAS resume regression test fails when only the request parameter, rather than the shared roster binding, is updated.
  • Launch goldens drive the actual launch paths with external collaborators stubbed. Existing fixture values are unchanged by the environment-fold repair.
  • A Windows-like environment mapping reproduces the SystemRoot phantom-removal failure without changing the host platform. A separate test preserves real removals and POSIX case distinctions. Restoring the old comparison reproduces the CI failure.
  • The Black baseline gate fails if the graduated startup-metric entry is restored.
  • This verification: 532 focused tests passed, source mypy passed for 1629 files, the Black/import/flake8 checks passed for the repair, and documentation, comment-history, harness-parity and SDK-boundary gates passed.
  • Package wheel built successfully with installed packaging tools and no dependency downloads. Windows CI must confirm the native-platform result; the local host is Linux.

Manual verification

Earlier branch revisions passed four installed-adapter tests against codex-acp 1.11.0. They measured request-close eviction, notification-close non-eviction, idempotence and the two SSE shapes. They were not rerun for this test-only repair. A schema-complete SSE element with headers causes -32600 for the whole request; the bare shape is accepted without wiring that server.

The process-depth live pin and adapter observability follow-ups are tracked in #11512. This PR does not add an RSS configuration knob or an adapter-installing CI lane.

Screenshots / video

N/A — no new UI layout or visual interaction is introduced.

Related Issues

Closes #9976
Closes #10292

Overlap: #5349 concerns the codex client arm removed here; that PR is not modified.

Pattern harvest

Rule candidate: review-prompt
Pattern: transport membership does not imply a host's tool, overlay or teardown capabilities.

Checklist

  • One commit on the feature branch, with a Conventional Commits title
  • Scoped regression tests and wheel build passed
  • Current-head CI and local review fully passed
  • Documentation covers the changed behavior
  • No secrets or credentials added

@iamwhatever
iamwhatever requested review from a team and smeyffret September 16, 2026 09:36
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 16, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Intent: Make codex sessions run on the one shared adapter process Crew already knows how to drive, and delete the second spawn path once nothing routes to it — so there is one codex transport rather than two, and the harness that was written for it is the one actually used.

Not a goal: closing codex's session-eviction gap (session/cancel does not dispose a session, so the high-churn background path stays off this host), making ~/.aws writable for the adapter, or moving any other harness onto the shared runtime.

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 921b1a6ab2d013637176de6bb035e7bb4dbf9d23 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 921b1a6

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

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Verify Windows CI is green on this head — the env-fold repair and RSS abstention only run there, and the checklist's CI item is unchecked.

[DESIGN-REVIEWED] 921b1a6

@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 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 921b1a6ab2d013637176de6bb035e7bb4dbf9d23 — 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

Eviction membership rests on a live measurement whose pinned test skips without the adapter installed, and the author states it "was not rerun" on this head — run test_real_codex_acp_session_close_evicts against an installed codex-acp (and let Windows CI confirm the env-fold repair) before merge.

What this change ships

Inventory (10 items) — 10 justified

Intent: route codex sessions through the one shared AcpRuntime launch path so the duplicate AcpClient arm and its preview switch can be deleted — an ADDITION (membership flip) that is mostly subtraction.

  1. Codex chats start through the shared AcpRuntime instead of a per-chat AcpClient process — justified
  2. KIROCREW_CODEX_ACP_RUNTIME switch and acp_runtime_backends()/codex_runs_on_acp_runtime() removed; the switch's own comment recorded deletion as the flip — justified
  3. Codex teardown is an awaited session/close that frees the session, replacing the session/cancel notification; old pin reversed with measurement and a gated live test — justified
  4. Codex background helpers (titles, suggestions, folders, nav) and warm pooled reuse now share one codex process, via new ACP_BACKENDS_SESSION_EVICTION (2 counted consumers: _bg_runtime_backends, new_conversation) — justified
  5. A non-evicting backend is refused warm reuse before any session is created; hard-reset fallback stands — justified
  6. Codex RSS recycle measures adapter+app-server only against a fixed 1024 MB ceiling; operator's subtree number no longer applies to codex, substitution logged at INFO — justified
  7. Unresolved-@server diagnostics now run on runtime-served sessions; KAS judged against its spec via ACP_BACKENDS_SPEC_SERVERS_OFF_WIRE (1 consumer, form mandated by H5/H6) — justified
  8. Startup metric names the backend that actually started instead of always kiro — justified
  9. Refusal parsing and backend-card lines stop inferring kiro-family from runtime membership; the deleted subset pin's own text prescribed this exit — justified
  10. Launch goldens measure env deltas against the OS-folded parent (Windows SystemRoot phantom removal); codex captured through the runtime — justified

[FIRST-PRINCIPLES-REVIEWED] 921b1a6

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

I have enough to conclude. Let me verify my reasoning on the one candidate:

  • CANDIDATE 1 (H13 — guard runs on kiro path): The _guard_unresolved_mcp_refs call is genuinely new on the runtime path. But to be a reportable defect it needs an observable wrong outcome. For kiro/KAS (ACP_BACKENDS_SPEC_SERVERS_OFF_WIRE), unresolved_server_refs does satisfied |= _spec_server_names(spec), so refs are satisfied from the spec — no false diagnostic. The call is synchronous, in-memory, non-raising (try/except → logger.debug), and its spec snapshot is read in the same existing off-loop hop (_pooled_session_servers_and_ref_spec / _project_and_snapshot), adding no new scheduling point. ref_spec=None on the caller-supplied-array branch makes it silent. There is no concrete input producing a wrong array, failed session, or false warning on the kiro path — (c) never resolves to a wrong outcome. Self-scored "low" and correctly so. Dropped.

I also confirmed the surrounding refactor is sound: no dangling references to removed symbols (_is_codex, _codex_session_mcp_servers, _agent_mcp_capabilities, acp_runtime_backends, the deleted preview switch), and the codex RSS ceiling is actually wired — reclaim_policy() is applied to _max_rss_mb (runtime.py:2074-2078) and _max_rss_depth is set from plan.rss_depth (2091) before the process is judged. The session_handle refusal-parse gate and _bg_runtime_backends eviction intersection are both correct tightenings for codex's arrival on the shared runtime.

Nothing survives Step 1, and I found no grounded new defect in Step 2.

No findings.

[OPUS-REVIEWED] 921b1a6

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

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

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: ACP_BACKENDS_SESSION_EVICTION plus the rss_depth core scope, both added in this PR.

Accepted as stated. The lane has the mechanism right: before this PR teardown killed the
per-session process and its whole fleet, so non-eviction cost nothing observable; after it,
sessions share one process and a dropped session stays resident. And rss_depth=1 does
deliberately exclude the fleet term, so the RSS ceiling is not the instrument that collects it.

Deferred rather than fixed here because closing it is a decision this PR cannot make alone.
Codex is in ACP_BACKENDS_SESSION_SHARING precisely BECAUSE its session survives teardown --
that persistence is what spawn_continue needs -- so a blanket session/close on teardown
would strand a shared subagent session with conversation_gone, which is the same problem
that keeps KAS out of the sharing set pending keep-aware teardown. Sending the right verb per
session KIND is the real work, and it belongs with that question rather than inside a
transport flip.

What bounds the exposure in the meantime is the set this PR adds, not an accident:
ACP_BACKENDS_SESSION_EVICTION excludes codex, so session._bg_runtime_backends() keeps the
high-churn background path -- title generation, suggestions, folders, nav, each taking its own
ephemeral sessionId many times per conversation -- off this host entirely. Growth is therefore
bounded by the rate a person opens chats, with the age ceiling collecting the process, rather
than by a rate no user controls.

#11274 carries the four steps, including the shared-session decision and the membership
change that admits codex to the background path once eviction is real.

@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 16, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the launcher-generation offset, added in an earlier round of this PR to fix a bounded-RSS under-count.

  • Codex adds an adapter conditional to the Kiro construction path (span=60eee5df9fed) — fixed in 900e3f2074.

Upheld, not overridden. The pre-drafted override rationale in the fenced block is correct on its
facts -- reclaim_policy returns rss_depth=None for the kiro family, so the branch never fired
on the Kiro path and added no reaching failure mode -- and it is still the wrong disposition here.
H13 governs the SHAPE of that path, the acceptance conditions for this work name keeping the
parity gate green, and "the branch is a no-op for the host it burdens" is an argument for every
future adapter conditional too. The fix costs less than the residual.

This span is self-added: the offset exists because an earlier round of this PR was told the
bounded depth was measured from the wrong process. On Linux a forking sandbox backend leaves a
launcher resident as self._pid, so an unoffset depth counted the launcher as the adapter and
stopped one generation short of codex app-server -- the process that actually grows. So removal
was not available; a smaller replacement was.

The resolved, pid-relative depth now lives on SpawnPlan, and CodexHarness.resolve_spawn
computes it inside its own seam -- already async, already thread-hopping for its argv search and
its mask, so the probe costs the shared path nothing. _spawn_admitted reads plan.rss_depth
in one unconditional assignment beside argv = plan.argv: no branch, no added await, no adapter
name. _sandbox_wrapper_generations moved to harness/codex.py, so the runtime module carries
no adapter-specific helper either. rss_depth left ReclaimPolicy in the same change, so the
number has one home rather than two that can drift.

Two ratchets, both mutation-verified rather than asserted:
test_the_spawn_path_does_not_branch_on_rss_depth walks _spawn_admitted's AST and fails if any
conditional tests the depth -- the H13 property itself, not this instance -- and reintroducing the
conditional reds it. test_the_spawn_scope_includes_a_resident_launcher reds when the launcher
adjustment is dropped, so the under-count the offset exists for cannot come back silently.

@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 16, 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 Sep 16, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: codex's membership in ACP_BACKENDS_SESSION_SHARING, added in this PR and now removed.

  • Codex shared subagents lose resumability (span=b21964374a1f) — fixed in 9985388a0d, by removing the membership rather than repairing the label.

Upheld in full. The adjudication's chain is correct at every hop and I verified it:
the shared path is the DEFAULT for an ordinary subagent, it persists
PROVIDER_LABEL_DEFAULT, SessionMap reads that as kiro-cli and prunes on the
absent flat transcript, and spawn_continue answers conversation_gone. The
flag denial is right too -- it fires on the ordinary continuation flow, which is
precisely the capability the membership existed to grant.

Two remedies existed and the smaller one is not the local fix. Persisting the real
provider label means editing run.py, continuation.py and session_map.py
-- the subagent-lifecycle and session-map subsystems, none of them otherwise in this
PR -- to add a capability nothing yet asks for, on a change whose intent is the
shared TRANSPORT. Removing codex from the set instead costs one frozenset member and
leaves every session working: subagents get dedicated sessions, which is the
behaviour before this PR and is not degraded.

ACP_BACKENDS_ACP_RUNTIME keeps codex, so the transport flip is untouched. The
two sets were always in a proper-subset relation for exactly this reason, and KAS is
the standing precedent -- on the runtime, out of sharing until the missing piece
lands. Codex now follows it rather than re-arguing it, and #11274 is the single gate
for both sharing and eviction.

Pinned so the harness half cannot argue it back in:
test_it_does_not_share_sessions_though_the_harness_could records that the ADAPTER
would hold a shared session and that Crew's continuation is what cannot, and
test_running_on_the_shared_runtime_did_not_grant_sharing asserts the proper-subset
relation directly so runtime membership is never read as implying sharing.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: codex's membership in ACP_BACKENDS_SESSION_SHARING, added in this PR and now removed.

  • Item 4 — inherited: sharing granted on the reversed fact (span=fffecf688f3b) — fixed in 9985388a0d; the inference is withdrawn.

Accepted without qualification, and it is the most useful finding in this review. The
deleted pin said sharing is denied BECAUSE teardown does not evict -- "until that
membership is earned" -- and this PR granted it by reading the same fact the other way
round. That reversal was my inference. It was never established by the linked issues,
and a reviewer being unable to open those comments is exactly why an inference dressed
as a citation is the failure mode worth catching.

The reversal is now withdrawn rather than argued: codex is out of
ACP_BACKENDS_SESSION_SHARING and the original pin's reasoning stands as written.

Worth recording that the lane was right for a reason stronger than the symmetry it
spotted. The GPT lane independently found the reversal breaks the capability it
claimed to grant -- Crew's shared-subagent path persists a provider label
SessionMap resolves as kiro-cli, so a codex spawn_continue answers
conversation_gone. So the fact does not in fact support both readings, and the
pin was load-bearing rather than conservative.

Nothing in this PR now grants sharing to codex, so the clearance condition this item
names -- an evicting teardown verb, or a maintainer confirming the linked conditions
cover sharing-without-eviction -- no longer has to be met for this change to ship.
#11274 tracks both the eviction verb and the sharing membership that follows it.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: codex's membership in ACP_BACKENDS_SESSION_SHARING, added in this PR and now removed.

Accepted, and the specific escalation this names is gone. The item's mechanism is "a
chat that spawns several SHARED subagent sessions accumulates fleet RSS uncounted" --
several fleets on one process, at roughly 2.7 GB each. Codex is now out of
ACP_BACKENDS_SESSION_SHARING, so a codex subagent gets a dedicated session and its
fleet leaves with that process. One runtime carries one foreground session.

What remains is the single-session case, and it is bounded differently rather than
unbounded. Exposure grows at the rate a person opens chats, not at a rate a caller
multiplies: ACP_BACKENDS_SESSION_EVICTION keeps the high-churn background path --
title generation, suggestions, folders, nav, each taking its own ephemeral sessionId
many times per conversation -- off this host entirely, and the age ceiling collects
the process.

The core RSS ceiling still excludes the fleet term deliberately, and that reading is
unchanged: the fleet's size is set by the operator's own codex config, so no ceiling
Crew picks governs it, and a subtree ceiling that tried would recycle a healthy
process on its first prompt. The instrument for the fleet is eviction, not a
threshold.

#11274 is filed, labelled deferred-finding, assigned and dated, and carries the
eviction verb plus the sharing membership that follows from it -- so both halves of
this item have one gate rather than two.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • No live run of the default codex path this PR creates (span=aa1fcec6709b) — fixed in 9985388a0d: the evidence exists and the description now carries it.

Accepted as a real gap. The description did say "N/A -- unit coverage sufficient" while
the same commit deleted the only codex path that had ever been exercised, and a fake
peer cannot answer for an adapter.

Taking the second clearance path this item offers -- the gated live test passing on
this HEAD with codex-acp installed. Three of them do:

$ python3 -B -m pytest test/test_codex_session_mcp.py test/test_acp_codex_harness.py \
    -q -p no:randomly -k "real_codex or real_adapter or installed_adapter"
3 passed, 165 deselected in 67.97s

They are @pytest.mark.skipif(_ENTRY is None) and did NOT skip; the 68s runtime is a
real codex-acp being driven rather than a resolver returning early.
test_real_codex_acp_accepts_the_crew_stdio_element is the load-bearing one here --
it drives an actual session/new carrying Crew's own stdio element, and it is the
anti-drift guard for the transport narrowing this PR rewrites, so it exercises the
claim the refuted -32600 correction rests on.

The Manual verification section now records that run in place of the N/A, with the
command and the skip-versus-ran distinction stated, so a reader can re-run it rather
than taking the result on trust.

@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 16, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

CI triage for 9985388a0d → fixed in 39abcb0fa5 (also rebased onto 00e589b5c5bc).

Four checks went red. Two causes, one mine.

Mine — fixed. test/test_macos_process_table.py::test_linux_branch_spawns_nothing failed on
Backend Tests (3.12, 2) and Backend Tests (Windows) (4) with:

TypeError: test_linux_branch_spawns_nothing.<locals>.<lambda>() takes 1 positional argument but 2 were given

_iter_descendant_pids gained a max_depth bound in this PR and the Linux branch passes it
through; that test's fake was one-argument, so it raised instead of exercising the branch it
guards. Fake widened to lambda pid, max_depth=None: [pid].

Worth naming the miss: I updated the fakes in test_acp_runtime.py when I changed the
signature and did not grep the whole tree for others. Doing that now finds five more fakes of
these two functions — in test_session_memory.py, test_dashboard_sessions_memory.py and one
more in this file — all of which patch the dashboard.session_memory namespace, whose call
sites pass a single argument, so they are correct as written and are left alone.

Not mine — no action. test/metrics/test_process_gauges.py::test_peak_rss_at_least_current_rss
failed on Backend Tests (3.12, 1):

assert 1977626624 >= 1978023936

A 388 KB gap between the peak gauge and the live reading it bounds — the two are sampled at
different instants, so current RSS grew between them. This PR touches no file under
src/kiro_crew/metrics/, and #11213 is already open against exactly this assertion
("test: fold in peak RSS before gauge assertion"). Left to that PR rather than duplicated here.

Coverage Gate failed only on its "Require upstream coverage jobs to have succeeded" step,
so it is downstream of the two above rather than a finding of its own.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 16, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: a comment on the mirrored-path hop claimed two sequential reads of one file could not disagree.

  • "cannot read a different spec" contradicts two sequential file reads (span=081ce7af27e6) — accepted; fixed in f52176a6ab.

Accepted: same resolution order means the same FILE, not the same bytes, and a save
landing between the two reads gives the guard a spec the array was not built from.

The comment now says that, and says why the window is accepted rather than closed:
the snapshot's only consumer is a diagnostic, so a mismatch costs one possibly-wrong
warning and never the array, while threading the projection's own parse back through
every mirror's session_projection is a wider change than that warning is worth. The
projection's right to refuse a stale derived spec is unchanged; the snapshot still
resolves to None rather than raising.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the runtime guard now runs for every host on the shared runtime, and unresolved_server_refs exempted only kiro from wire-judging — KAS, whose spec servers travel off-wire in _meta.kiro.customAgents, was judged against a stub-only array.

  • Runtime guard reports KAS's spec servers as unresolved (span=705140069842) — accepted; fixed in f52176a6ab.

Accepted, and it is the guard's own false-positive failure mode landing on the second
host that mounts its spec off-wire. KAS was already on the shared runtime, so the
client guard never ran for it; the runtime guard does, and with the kiro-only
exemption a default KAS session would have logged every @kirocrew-* ref unresolved
for tools that are present.

Fix, by membership rather than by adding a second id to an if: new
ACP_BACKENDS_SPEC_SERVERS_OFF_WIRE = {kiro, kas} in agent_sdk/backends.py, with
the usual table row and re-exports, read by unresolved_server_refs in place of
backend == ACP_BACKEND_KIRO. kiro-cli loads the spec's servers itself from
--agent; KAS receives them as a projected agent definition; codex is deliberately
NOT a member, because the array Crew sends is the whole of what it mounts, so judging
its refs against that array is right. The module docstring and the client guard's
docstring now describe the exemption as the membership it is.

Pinned in test_acp_mcp_ref_guard.py: KAS resolves a declared ref against an empty
wire and still reports an undeclared one; codex reports the same ref on an empty wire
and resolves it once the server is on it; every member of the set resolves it. The
set's home, re-export identity and value are pinned in
test_acp_capability_sets_leaf.py alongside the others.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the core-scope recycle guard rests on codex app-server sitting one generation below the adapter, a structural fact of the adapter's process tree that no live assertion pins.

Accepted as a real structural dependency, and the failure it describes is the right
one to worry about: an adapter release that inserts a wrapper generation would leave
the probe summing a flat ~100 MB forever while the ceiling never trips.

What this head ships is the second of the two clearing paths from the previous round's
WATCH on the same subject: _should_recycle logs every bounded-scope probe at debug —
backend, pid, depth, captured RSS, ceiling — so that drift is attributable from an
operator's log on every install, including the ones the gated live tests skip on. That
is why the trace rather than the pin was chosen first.

The live pin the lane asks for — app-server observed at depth 1 below the spawned pid,
alongside test_real_codex_acp_session_close_evicts — is the right next step and is
not in this PR: it needs a process-tree probe against the running adapter that the
existing gated harness does not have, and adding it here would widen a PR already
carrying its measured facts. It is filed as #11512, with the probe it needs and the
mitigation this head ships. Resolving rss_depth from the
live tree instead of a constant is deliberately not taken: it would make the recycle
scope depend on a runtime observation of a third-party tree, which is the class of
dependency the constant-plus-trace avoids.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

CI triage for f52176a6ab — one red was mine and is fixed in 4f9fd85554; the other two are not this diff's.

Mine — test_provider_mirrors.py::TestEveryBackendIsAccountedFor::test_every_known_and_selectable_backend_resolves_to_one_declaration (Linux shard 3, Windows shard 6). The parity test cross-checks a backend's declared projection kind against agent_sdk.mcp_refs, and its rule was native ⇔ the resolver credits the spec's own servers. Adding KAS to ACP_BACKENDS_SPEC_SERVERS_OFF_WIRE (the Opus fix from the previous round) made the resolver credit KAS, whose kind is external, so the rule fired. The rule was narrower than the fact it checks: external is by definition a projection down a channel that is not this folder's array (KAS's _meta.kiro.customAgents), so its spec servers reach the session off the wire exactly as a native host's do. The cross-check now reads kind ∈ {native, external} ⇔ resolver credits the spec, with mirror / no-channel / broker-only held to the array. The negative test (a mirror-class backend declared native must fail) still passes. providers/mirrors/README.md and agent-host-contract.md state the same rule. My scoped run had not selected this file; the wider run I now use (every test naming mcp_refs, acp_backends or the capability sets — 42 files, 2484 tests) is green.

Not mine — test_pod_windows_run.py::test_public_up_prepares_home_only_after_start_reservation[False] (Linux shard 3): WindowsTaskError: the Task Scheduler pod backend is win32-only; this host is linux. A Windows-only backend test running on a Linux shard; nothing in this diff touches pod/.

Not mine — test_runloop_integration.py::test_throttle_parks_two_runs_on_one_scope_and_wakes_by_capacity (Windows shard 6): timing assertion (no park of 2 run(s) on 'provider:acp' within 30.0s); both runs completed before the throttle observed them. Nothing in this diff touches the run loop or throttle.

Also in 4f9fd85554: the ACP_BACKENDS_SESSION_SHARING decision comment in backends.py is rewritten to the post-flip state (GPT's advisory FINDING on f52176a6ab, disposition below), since a push was needed regardless.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the ACP_BACKENDS_SESSION_SHARING decision comment still described codex's teardown as session/cancel leaving a session resident, which the same PR's session/close teardown and eviction membership contradict.

  • session/cancel contradicts the changed session/close teardown and eviction membership (span=d02faec46615) — accepted; fixed in 4f9fd85554. Conclusion unchanged: codex stays out of the set.

Accepted: a decision record that states the opposite of shipped behaviour is the
defect the design lane already flagged once on session.py, and this was its twin.

The comment now gives the post-flip reasoning, and it is stronger for the change:
codex fails the sharing test on BOTH halves. Its teardown is a session/close
request that evicts (the ACP_BACKENDS_SESSION_EVICTION property), so a shared
subagent session would not survive the teardown of the conversation that spawned it
— exactly KAS's position, a disposing verb with no keep-aware variant. And on Crew's
side the provider-label rationale stands as before. The KAS precedent is followed:
out of the set until a keep-aware teardown and a readable provider label land.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

CI triage for 4f9fd85554 — the one red is main's, not this diff's; waiting on #11518.

Backend Tests (3.12, 3) fails on test/test_pod_windows_run.py::test_public_up_prepares_home_only_after_start_reservation[False] with WindowsTaskError: the Task Scheduler pod backend is win32-only; this host is linux.

A/B: the same test fails identically on a checkout of origin/main (65b08d3f96) with this branch's changes absent, and this diff touches nothing under src/kiro_crew/pod/ or that test. It is #11517 (a consequence of #10707), with the fix open as #11518. Coverage Gate fails closed behind any red shard, so PR Readiness cannot go green on this head until that lands; the next push will be a rebase onto it.

Everything else on this head is green: all four reviewers (GPT no blocking findings, Opus no findings, Design PASS, First-Principles PASS), every other test shard, lint, type check.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the codex harness test's module docstring still described codex as being IN ACP_BACKENDS_SESSION_SHARING and OUT of ACP_BACKENDS_SESSION_EVICTION, the pre-flip memberships, which this PR inverts.

  • "in ACP_BACKENDS_SESSION_SHARING" and "absent from ACP_BACKENDS_SESSION_EVICTION" contradict the assertions below (span=e7b02dbc6cb9) — accepted; fixed in 5067ee0b22.

Accepted, and it was the third instance of one class this round found — a decision
record left describing the pre-flip teardown. So the whole diff was swept for it
rather than just the line quoted.

Fixed in four places: the module docstring of test/test_acp_codex_harness.py (now:
codex is IN eviction because its teardown is a session/close request that disposes
the session, and OUT of sharing); the TestOneFactReadThreeWays class docstring and
its renamed test_it_does_not_share_sessions_though_it_multiplexes (was
…_though_the_harness_could, which named the pre-flip reason); providers.md's
sharing-set paragraph; and the H6 row of harness-parity.md. Each now gives the two
post-flip grounds for the exclusion — the evicting teardown would take a shared
subagent session down with its parent (KAS's position), and the shared-subagent path
persists a provider label SessionMap reads as kiro-cli, so spawn_continue answers
conversation_gone.

No assertion or membership changed; codex stays out of ACP_BACKENDS_SESSION_SHARING.
This head is also rebased onto #11518, which removes main's test_pod_windows_run
failure (#11517) that was the only red on the previous head.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: last round's fix replaced a named-hook check with pure discovery, so the hook set came from the code under test — a deleted splice removed its own name and the remaining hooks still passed.

  • Dynamic discovery weakens the MCP-splice ratchet (span=8b894329d8b5) — accepted; fixed in 120031fb55.

Accepted, and the reasoning is exactly right: discovery is one-sided. assert hooks
only caught deleting ALL of them, so dropping the goose splice left claude and
opencode passing their guard checks and nobody asserting the harness that lost its
servers. I over-corrected last round — the previous version's fault was being keyed
on one hook NAME, and the fix for that did not have to give up the declared set.

Now both directions are pinned. The spliced hook set is asserted equal to a declared
_MCP_SEAM_HOOKS = ["claude", "goose", "opencode"]: a missing name is a deleted seam,
an extra one is a new harness that must be declared here and then gated. Discovery is
kept only for WHERE each occurrence sits.

Reviewing my own guard check while there, I found it had the same one-sided flaw and
tightened it too: if self._is_{h} in source searched the whole function, so an
unrelated if self._is_claude elsewhere in it satisfied an ungated splice. Each
occurrence is now required to carry if self._is_<h> on that same element.

Mutation-verified three ways, all red: delete the goose splice; ungate the claude
splice (this one SURVIVED the previous version, which is how I found the second
hole); splice the claude hook behind the opencode guard.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the sse-disposition correction was applied to this document's table rows but not to its retrospective prose section, which still asserted the adapter refuses nothing at all.

  • "The adapter refuses none of it" contradicts the schema-complete SSE rejection with -32600 (span=b5747ce71ae6) — accepted; fixed in 120031fb55.

Accepted. The previous round corrected the two codex table rows in this file and the
mirror's own docs, and missed the "verify against the adapter" prose two hundred lines
further down — the section whose whole point is that a claim about an adapter must be
measured, stating an unmeasured absolute.

The paragraph now carries the shape-keyed fact: a schema-complete sse element (with
its headers array, the shape Crew's translation emits) IS refused, for the whole
session/new, with -32600; the same element bare, and a meaningless type alike,
are accepted and never wired. Its conclusion is corrected with it — the original cell
was wrong in its code and its scope and HALF-wrong in its direction, and the
client-side narrowing is therefore both the guard that the array sent is the array
honoured AND the defence that keeps one unsupported entry from costing the session.

Grep now finds no remaining site in the diff claiming the one-directional version.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: _sandbox_wrapper_generations imported detect_backend inside the function body with no circular-import reason, so the dependency was invisible at module scope.

  • function-local "from kiro_crew.sandbox import detect_backend" violates top-level-imports (span=0b9570ac81d0) — accepted; fixed in 120031fb55, and it found a real test defect.

Accepted: verified there is no cycle — kiro_crew.sandbox imports nothing from
kiro_crew.acp, and both modules import cleanly in either order — so the exception
did not apply. The import is now at module scope.

The rule's own stated reason earned its keep here: moving it broke three tests, and
they were broken BEFORE the move in a way that hid it. They patched
kiro_crew.sandbox.detect_backend, the definition site. With the call resolving
through the module that was correct; with the name bound at import it patches nothing,
and test_a_forking_sandbox_backend_adds_one_generation went red while its two
siblings kept passing by accident — the real probe returns 0 on this host, which is
what they assert. So one of the three had been asserting the case and two had been
asserting the host. All three now patch kiro_crew.acp.harness.codex.detect_backend,
with a docstring line saying why the patch target is the calling module.

The other two function-local imports in the same file (acp.client,
session_handle) are genuine cycles — acp/client.py imports the harness registry
this module belongs to — and now carry the # circular import comment the rule asks
for. The ~45 other kiro_crew.sandbox.detect_backend patch sites in the suite are
untouched: their callers resolve through the module, so the definition site is the
right target there.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: reclaim_policy discards the operator's max_rss_mb for a constant calibrated on one probe, and nothing in a running system said so.

  • The operator's configured ceiling is dropped for a code constant, silently (span=637f200386d8) — accepted; fixed in 120031fb55 via the first clearing path the lane names.

Accepted, and the lane separates the two halves correctly. The unit argument stands:
the operator's number counts a whole subtree, this policy measures two processes, so
passing it through would apply a subtree budget to a core scope. What did not stand is
that the substitution was invisible — an operator who raised the runtime ceiling and
saw codex unchanged had no way to learn why except by reading a docstring.

CodexHarness.reclaim_policy now logs at INFO whenever the incoming number differs
from the constant, naming both values and the scope that makes them different units,
pointing at the docstring that carries the measurement. It is the only place an
operator's configured value does not reach a host, so it is the one that says so out
loud. The debug line added last round on the RSS probe itself reports what the bounded
scope then captured against that ceiling, so the pair covers both "which number is in
force" and "what it is being compared to".

A core-unit operator override is deliberately NOT added: a second knob whose unit is
"two processes on this adapter's tree" is a configuration surface for a quantity that
changes with an adapter release, and #11512 already tracks pinning the scope's
structural premise. If a need appears, that issue is where it lands.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the core-only rss_depth=1 scope and the 1024 MB ceiling rest on a live probe table this review cannot re-run, since the gated tests skip wherever codex-acp is absent.

  • Item 5 — premise risk: the RSS scope and ceiling rest on an unverifiable probe (span=6ec52b4b5ad0) — confirmed by a maintainer run on this head; the numbers stand.

The lane's clearing condition is "confirmed green against an installed codex-acp
1.11.0 (CI or a maintainer's run)". Run on this head against the installed adapter:

$ python3 -B -m pytest test/test_codex_session_mcp.py test/test_acp_codex_harness.py \
    -q -p no:randomly -k "real_codex or real_adapter or installed_adapter"
4 passed, 169 deselected, 2 warnings in 99.93s

They are skipif(_ENTRY is None) and did NOT skip — the 100s runtime is the adapter
being driven. test_real_codex_acp_session_close_evicts is the teardown measurement
the eviction membership rests on: live before the close, gone after a request close,
still live after a notification close, idempotent, process unharmed.

On the RSS numbers specifically, two things bound the risk beyond the probe. The
ceiling is asserted GREATER than the measured 522 MB rather than equal to a copy of
the constant, so the test and the constant cannot drift into agreeing with each other
while disagreeing with the adapter. And the scope's structural premise — app-server
one generation below the adapter — is now observable at runtime: this head logs each
bounded probe (backend, pid, depth, captured RSS, ceiling), so a codex-acp release
that moves that process shows up in an operator's log as a captured value collapsing
to the launcher's footprint. #11512 tracks the live pin for that premise.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the eviction and sse facts are pinned only by gated live tests, which skip wherever codex-acp is absent — including CI — so a behaviour-changing adapter release is invisible to an operator's logs.

Agreed on the value, and this is the second round the lane has raised it, so it is
being recorded rather than left in a comment thread. The reasoning is right: every
measured fact this PR rests on (the session/close eviction, both sse dispositions,
the RSS scope) is pinned by a skipif(_ENTRY is None) test, and CI has no adapter, so
an operator hitting a regression after an upgrade has nothing in their log naming what
they upgraded to.

Not done here for one reason: the version is not in hand at the point that would log
it. resolve_spawn resolves the entry script through the client's own search, and the
adapter's version lives either in a package.json two directories up from that script
or in the initialize response — the first is a new blocking file read on the spawn
path, the second lands after the spawn and belongs to the runtime rather than the
harness. Both are real choices with a wrong answer available (an extra unbounded read
on a shared construction path is the H13 class), and this PR is already carrying its
measured facts.

Filed onto #11512 alongside the app-server depth pin, which is the same subject: making
the adapter's shape and version observable rather than assumed. What this head does add
is the runtime trace on the bounded RSS probe, so the drift that costs the most is
already attributable from an operator's log.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the KAS resume path re-assigned load_params["mcpServers"] after hoist_managed_servers changed the array, leaving wire_servers bound to the pre-hoist roster that the session report and the stall diagnostic read.

  • load_params["mcpServers"] = leaves wire_servers stale on KAS resume (span=081ce7af27e6) — accepted; fixed in 90f65b2c2d.

Accepted, and it is a real defect on a live backend. The hoist moves a managed server
out of the agent definition and onto the session array, so on KAS the array the resume
SENDS is not the one wire_servers was bound from. Both readers of that binding were
therefore wrong on resume: begin_session recorded a roster missing the hoisted
server, and a session/load timeout named it too. The session/new path does not have
this shape — it binds once, after its own hoist — which is why only resume drifted.

wire_servers is now rebound at the hoist and load_params["mcpServers"] assigned
from it, so one value reaches the wire, the report, the stall diagnostic and the
unresolved-ref guard.

Pinned by test_the_kas_resume_report_reads_the_hoisted_array: a stub hoist adds a
server the caller's roster never had, and the array handed to the report is asserted
equal to the array on the wire. Mutation-verified — restoring the plain
load_params[...] = reds it.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the Seam 9 ratchet reads CORE_RSS_DEPTH / CORE_RSS_CEILING_MB off the harness class, so the harness under test supplies the expectation it is judged against.

  • reclaim ratchet permits harness-defined opt-outs (span=8d3ca41764df) — not changed; the declaration is the property, and this is the third rewrite of one test in three rounds.

The observation is correct and the remedy is the one I already tried. Round 7 flagged
the opposite shape — a DECLARED_RECLAIM_OVERRIDES table keyed by backend id — as an
allowlist whose only row was this PR's own code, anchored a-ratchet-may-only-tighten,
and upheld. This round the same test is flagged for reading the declaration off the
harness instead. Those are the only two places the expectation can live: a table in the
test, or an attribute on the class. Moving it back reinstates the finding that was
upheld against it.

What the test actually pins is not "the harness may choose": it is that the pair
CORE_RSS_DEPTH + CORE_RSS_CEILING_MB must be declared TOGETHER, and that a harness
declaring them must then answer with that exact constant for two different operator
inputs, and that a harness declaring neither must pass the operator's number through
unchanged. A harness cannot opt OUT of anything — it can only declare a bounded scope,
which is a visible, reviewable class attribute, and is then held to a stricter rule
than pass-through: exact equality across probes. Mutation-verified last round on the
codex harness: pass-through despite a declared scope, max(input, ceiling), and
input * 2 all red.

The residual risk the lane names — a harness declaring a scope it should not have — is
real and is not a test problem: CORE_RSS_DEPTH on a new harness is a diff a reviewer
reads, and #11512 tracks pinning codex's own scope against the live process tree.

Not moving it again. Three rounds on one test file, each rewrite producing the next
round's finding, is the point at which the test stops being the risk.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebase onto 727503fdfb — three conflicts resolved, one main-side ratchet answered; head 3f74a836b0.

Conflicts (all additive, both sides kept where both apply):

  • src/kiro_crew/acp_backends.py — main added ACP_BACKENDS_SELF_SERVED_ACP / SelfServedLaunch (Forward SSH_AUTH_SOCK into the agent sandbox so ssh-agent-held keys can sign commits #8104); this PR adds ACP_BACKENDS_SESSION_EVICTION and deletes acp_runtime_backends. Kept main's additions, kept this PR's set, dropped the deleted symbol from the shim.
  • src/kiro_crew/acp/client.py _PROTOCOL_VERSION_BY_BACKEND — main moved opencode's row into its launch record; this PR moves codex's onto its harness. Neither row remains; the table now holds claude and pi plus the launch-record fold, and the comment counts two adapters rather than three.
  • docs/system-specs/modules/harness-onboarding.md Stage 3 — main's "does your harness serve ACP from its own binary" section is kept whole; this PR's "where the hand-written code lives follows the transport" paragraph is placed before its closing lead-in.

Main-side ratchet, answered rather than worked around: test_backend_cards.py (#11431) reads ACP_BACKENDS_ACP_RUNTIME as "the kiro family" on two card lines and asserts the runtime set never gains a member outside ACP_BACKENDS_KIRO_SLASH_COMMANDS. Codex is exactly the member its docstring predicts. Per the test's own instruction ("declare the capability positively instead of widening the stand-in"), the two lines now read the kiro-family marker set directly — the same membership, the set that already means it — and the stand-in constant is retired to that marker. Four sets are classified off-card with a reason each: ACP_RUNTIME (now that it no longer rides the stand-in), SESSION_EVICTION, SPEC_SERVERS_OFF_WIRE, and main's own SELF_SERVED_ACP, which the completeness test also flagged as unclassified.

Local: gates green, mypy clean, 3088 tests across every file naming a capability set or the launch table.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebase onto ad9fb82ae6 → head 13ca3ac090. Three conflicts, three main-side ratchets answered, one dead constant removed.

Conflicts, both sides kept: acp/types.py (main's ACP_BACKENDS_TOOL_SEARCH_OVERLAY re-export kept, the deleted acp_runtime_backends dropped); acp/runtime.py (main's session_token=stub_token argument to the mirror projection carried into this PR's one-hop _project_and_snapshot); harness-parity.md H6 (main's Tool Search sentences kept, this PR's eviction/sharing sentences spliced in).

Main-side ratchets this head satisfies:

  • test_backend_cards.py completeness — fix(acp): send MCP Tool Search to KAS over the wire, gated on the loader grant #11259 added ACP_BACKENDS_TOOL_SEARCH_OVERLAY and ACP_BACKENDS_CLIENT_META_SETTINGS without classifying them; the test is red on origin/main itself. Both are classified off-card here (channel details, the setting lands either way) so this PR is not blocked by it. Main's own SELF_SERVED_ACP entry landed meanwhile, so this PR's duplicate is dropped.
  • test_acp_launch_goldens.py — the golden drives AcpClient._spawn for every known id, and codex no longer has a client arm: on the previous head the codex case fell through to the kiro branch and recorded kiro-cli acp under codex's key. The capture now takes a runtime-only host (ACP_BACKENDS_ACP_RUNTIME − ACP_BACKENDS_KIRO_SLASH_COMMANDS) from its harness — resolve_spawn for the argv and rss_depth, apply_spawn_env for the env delta — and the codex golden is regenerated with the writer script: same node index.js argv, served_by: AcpRuntime, no client labels. The two goldens shards that were red on 3f74a836b0 were main's own (Forward SSH_AUTH_SOCK into the agent sandbox so ssh-agent-held keys can sign commits #8104's forward_ssh_auth_sock, fixed in 5edf08e7e2); this head is based past that fix.
  • First-Principles Item 10 — KIRO_FAMILY_STAND_IN_SET deleted; its test now reads the _LineSpec tuples (disposition below).

Local: gates green, mypy clean, 6664 tests across every file naming a capability set, the launch table, the cards or the goldens.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: after re-keying the two card lines onto the kiro-family marker, KIRO_FAMILY_STAND_IN_SET became byte-identical to KIRO_FAMILY_MARKER_SET, with no src consumer and one test that could no longer fail.

  • Item 10 — zero consumers: KIRO_FAMILY_STAND_IN_SET is a dead constant and its test is unfalsifiable (span=b0727269f15d) — accepted; fixed in 13ca3ac090.

Accepted. The constant is deleted. Its test is replaced by one that reads the
_LineSpec tuples themselves: crew_tools and model_switch must include the
marker set and must NOT include ACP_BACKENDS_ACP_RUNTIME. That is falsifiable —
substituting the runtime set back into either line reds it — and it pins the fact
the old pairing was trying to express, on the object that carries it.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the session/close-evicts and sse-shape facts are pinned only by gated live tests that skip where codex-acp is absent, and no CI lane installs it.

Agreed, and it is the fourth time a lane has raised this subject, which is why it
has an issue rather than another comment. A CI lane that installs codex-acp is a
workflow change with its own review surface (an npm install on the runner, an
adapter version pin, a fake CODEX_HOME with a non-credential auth.json), and this
PR is not the place to carry it. #11512 holds it with the app-server depth pin and
the version-at-spawn log — the same subject, making the adapter observable rather
than assumed.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the previous head captured a runtime-only host's golden from its harness alone, so the runtime's own environment additions were outside the ratchet.

  • Codex bypasses the full-launch golden ratchet (span=3f2b3ae2e365) — accepted; fixed in cbef6dfc57.

Accepted: the harness-only capture recorded the argv but not what AcpRuntime adds
around it, and the golden's contract is the whole launch.

The runtime-only capture now drives AcpRuntime._spawn_admitted itself, with the same
pass-through collaborators the client capture stubs (the env scrub, the pod remap, the
cgroup and sandbox wraps, the pod bundle wrap) plus the runtime's own (ssh-agent
forward, browser env, xdist cap, krb5, scratch), and the process factory stubbed to
record and stop — everything after it is the handshake, not the launch. The regenerated
codex golden now carries KIROCREW_RUNTIME_PYTHON, KIROCREW_SPAWNED and the
augmented PATH that the harness-only capture missed, under the runtime's served_by
rather than the client's two labels. The default data home is pinned to the run's temp
dir as the client capture does, so the conftest guard stays satisfied.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: _emit_kiro_startup_metric hardcoded backend="kiro" on the runtime cold-start path, which now serves codex as well as kiro and KAS.

  • Codex startup telemetry is recorded as Kiro (span=25513d154ea8) — accepted; fixed in cbef6dfc57.

Accepted, and this one is a real mislabel, unlike the earlier round's finding on the
runtime's own metric line (which reads the backend id and was right). This path's
attribute was a literal. KAS has been filed under kiro by it since it joined the
runtime; codex would have been the second host in the wrong bucket.

The backend id is captured into meta at the top of _start_kiro_runtime, beside the
session key and for the same reason (the impl swaps the client), and the metric reads
it; kiro-cli's id is the empty string and files as kiro as before. Pinned in
test_startup_channel_attrs.py: a codex start files as codex, the default host as
kiro, and an emit without the capture does not consult the swapped client.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: codex's eviction membership rests on a live measurement of codex-acp 1.11.0, and nothing at spawn or handshake checks the adapter version the measurement was taken on.

Agreed on the risk, and it is the same subject the lane has raised in four forms
(depth pin, version log, CI lane, and now a minimum-version gate), so it lives on
#11512 rather than in another comment. Of the three clearing paths, the one worth
building is the CI lane that installs the adapter and runs the four gated live tests —
it re-measures the fact rather than asserting a version number that the next adapter
release may or may not keep. A minimum-version check at handshake would be a
constant the same release invalidates, and a post-close liveness probe adds a wire
round-trip to every teardown to detect a regression the CI lane would catch before it
ships. Both are recorded there as the alternatives considered.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: reclaim_policy substitutes a core-scope constant for the operator's subtree ceiling and logs the substitution at INFO.

The second round the lane has suggested it, and the answer is unchanged: a second
knob whose unit is "two processes on this adapter's tree" is a configuration surface
for a quantity that changes with an adapter release, and scaling the constant by the
operator's ratio to the runtime default would apply a subtree ratio to a core scope,
which is the unit error the constant exists to avoid. The INFO log names both numbers
and the scope, so an operator who raised the runtime ceiling and saw codex unchanged
has the reason in their log. #11512 is where a demonstrated need would land.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Publication note for 3136f3a: the maintainer requested pushing the existing CI repairs for remote checks, with the incomplete local GPT review disclosed. No review override or merge is requested.

The scoped repairs remove the graduated Black-baseline entry and measure launch environment deltas against the parent environment as installed by the OS. The launch golden remains unchanged; regression coverage reproduces the Windows SystemRoot case-fold failure and preserves genuine removals and POSIX case sensitivity.

Verified locally on this commit: 532 focused tests, wheel build, mypy, Black baseline, targeted isort/flake8, documentation, harness parity, SDK boundary and comment-history checks. The complete local Opus contract review found no blockers. Local GPT discovery did not finish within its budget and authoritative falsification did not run; this is NOT a GPT pass. Served review models were not independently verified. Native Windows results remain for CI.

The prior Windows queue-wait failure (14.999999999986358 versus 15.0) matches #11617 and #11702. The test and queue-wait code are unchanged from the base; the exact test passes locally on Linux. No timing threshold was weakened.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: Codex uses a fixed core-scope RSS ceiling rather than the configured whole-subtree threshold.

  • Fixed core RSS ceiling has no operator override (span=4ee0d7d6443a) — unchanged in this scoped CI repair.

The current behavior remains a 1024 MB core ceiling, with an INFO log naming the substitution. A heavier core may require a code change; the log is not a configuration remedy.
The user explicitly limited this work to existing repairs rather than adding a new RSS configuration surface. No knob, version gate or teardown probe is added here.
This records the known limitation and the scope decision, not evidence that the ceiling suits every workload, and not a review override. No public maintainer acceptance or closure of the WATCH is claimed.
Issue #11512 covers adapter-depth and observability work; it is not cited as proof that an operator-ceiling knob is implemented or assigned.

Codex sessions each got their own adapter process. CodexHarness was already
written, registered and tested, but an env switch kept every session on the
per-session AcpClient path, so the repository carried two codex spawn paths
and used the worse one.

Add codex to ACP_BACKENDS_ACP_RUNTIME and ACP_BACKENDS_SESSION_SHARING, delete
the KIROCREW_CODEX_ACP_RUNTIME switch with acp_runtime_backends() and
codex_runs_on_acp_runtime(), and delete the AcpClient codex spawn arm along with
_is_codex, _codex_session_mcp_servers, the client-side protocol literal and its
table row, and the _agent_mcp_capabilities attribute nothing else read.

Two sets that transport membership used to stand in for now answer for
themselves. ACP_BACKENDS_KIRO_SLASH_COMMANDS gates the cli.json overlay at the
two sites that read and cleared it, because codex runs on the shared runtime and
reads no such file. A new ACP_BACKENDS_SESSION_EVICTION names the harnesses whose
teardown disposes a session; codex is absent, so _bg_runtime_backends keeps the
high-churn background path off it. The runtime handle's refusal-envelope read is
gated on ACP_BACKENDS_STRUCTURED_REFUSAL, as the client path already gates it.

ReclaimPolicy gains rss_depth, and CodexHarness declares a core-only ceiling of
1024 MB over the adapter and its app-server. The measured per-session MCP fleet
codex starts from its own config puts the whole subtree past the 500 MB default
on the first prompt, and its size is set by the operator's config rather than by
anything Crew did. Windows abstains from a bounded measurement rather than
judging a core ceiling against a subtree total.

Correct the refuted claim that codex-acp rejects an unadvertised mcpServers
transport with -32600. It accepts one and answers normally, so the client-side
narrowing is the only guard and its absence costs a silently unwired server
rather than a failed request.
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Pushed 921b1a6ab2 (rebased on 1ae8f6ee48). Rebase left OFF_CARD_SETS with main's and this branch's entries for ACP_BACKENDS_TOOL_SEARCH_OVERLAY / ACP_BACKENDS_CLIENT_META_SETTINGS side by side (flake8 F601); this branch's two are dropped, main's kept. The Python dependency audit ERROR in the same job is report-only (continue-on-error) and appears on every current PR: pip-audit emits a skip_reason entry for the local kirocrew package with no version. Not in this change's scope.

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.

codex-on-AcpRuntime: acceptance criteria the flip commit must carry Shared-process ACP host for non-kiro backends (CC, Codex, future providers)

2 participants