Skip to content

fix(acp): name the adapter that spawned, not the seam - #9135

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
Premshay:upstream/acp-spawn-label
Sep 13, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
Premshay:upstream/acp-spawn-label

Conversation

@Premshay

@Premshay Premshay commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

AcpClient._spawn reports fixed seam names in its spawn and adapter-stderr
logs even though Claude and Codex each resolve the program they launch. An
override can therefore make the diagnostics name a different program than the
one that ran.

Why it matters

Those labels are how an operator confirms which adapter a session used. A
resolved native binary or dispatch shim must be visible, while the shared Node
launcher used by vendored adapters must not collapse both seams into the
unhelpful index.js entry-script name.

What changed (motivation → approach → change)

The Claude and Codex branches derive their labels before sandbox or cgroup
wrappers can replace argv. A directly executable adapter adds its resolved path
to the stable seam label; an interpreter launch keeps the seam label alone.
Adapter labels stay local to those two branches. The kiro-cli spawn and stderr
paths remain unchanged.

Tests

test/test_acp_spawn_label.py covers native adapters, dispatch shims, Node and
Windows Node launchers (including a case-variant node.EXE), empty argv,
adapter stderr, and unchanged Kiro stderr.

pytest test/test_acp_spawn_label.py test/test_acp_client.py test/test_acp_client_more_coverage.py test/test_acp_auth_failure_on_stderr.py test/test_acp_spawn_offload.py — 767 passed. Black, Flake8, the comment-history
and subprocess-encoding gates, and the harness-parity gate all pass.

Manual verification

The implementation takes the label from the same resolved argv passed to the
subprocess, before any wrapper modifies it.

Related Issues

N/A — found while diagnosing a misreported adapter in a live deployment.

Pattern harvest

Rule candidate: semgrep

Pattern: a diagnostic label built from the constant that names a launch path's
default, while the program that path launches is selectable by an environment
override — the log then attributes work to a program that never ran. Derive the
label from the resolved argv at the launch site, before any wrapper prepends its
own program.

Pattern: a case-sensitive membership test against a fixed lowercase set misses
case variants that Windows shims report (e.g. node.EXE) — compare the name
with .casefold() against a lowercased set so platform case variance can't
defeat a fixed-allowlist check.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|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

N/A — template placeholder; no CLA wording is supplied.

@Premshay
Premshay requested review from a team and CrysisDeu September 6, 2026 22:03
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

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

Review details

FINDING -- src/kiro_crew/acp/client.py:343 -- For [node, entry.js], "program = argv[1]" appends the script path despite the stated seam-only behavior -> Fix: return seam for recognized interpreters and update expectations.
[GPT-REVIEWED] 4bb33dc

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

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

Design-Verdict: PASS

Label derived from the same resolved argv the spawn uses, pre-wrap, seam kept as a stable prefix — root-cause fix, no persisted or compared contract touched.

The helper's two shapes ([binary], [node, script]) exactly match what _resolve_claude_acp_bin actually returns, the label flows only into log/error strings (finish_suspended_spawn uses it for messages, nothing persists it), and the kiro/opencode branches reproduce their prior labels byte-identically, so the "unchanged" claim holds.

[DESIGN-REVIEWED] 4bb33dc

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 4bb33dc

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🟡 CONCERNS

Premise-level review of 4bb33dcf0d415b3e66dcc74408c48deeacaa620e via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All evidence gathered. The base confirms the defect is real (claude/codex binaries resolve through documented env overrides while the spawn label was a constant), no existing mechanism logs the resolved argv, but two sibling branches in the same function share the identical root cause and stay on constant labels: opencode (_ENV_OPENCODE_BIN override, argv = [opencode_bin, ...] at line 5945) and kiro (KIROCREW_KIRO_BIN override at line 6040).

First-Principles-Verdict: CONCERNS

The author's own harvest pattern names the root cause, then fixes 2 of 4 branches — opencode and kiro keep constant labels despite the same env overrides.

Not justified as shipped

  • Item 5 — point patch: opencode and kiro binaries also resolve through env overrides (_ENV_OPENCODE_BIN, client.py:721; KIROCREW_KIRO_BIN, client.py:485) into the spawned argv, yet their labels stay constants; the general fix is two more _adapter_spawn_label calls in the same function.
  • Item 6 — zero consumers: the label default = KIRO_CLI_BIN on _drain_stderr is never used — the sole production caller passes label= explicitly.

What this change ships

Inventory (6 items) — 4 justified

Intent: make spawn/stderr logs name the adapter program that actually ran when an env override redirects the seam — a FIX. Defect provenance is verifiable in base: _spawn_label is a constant (client.py:6296) while claude/codex argv is override-resolvable (client.py:653, 835).

  1. Claude spawn log now reads "claude-agent-acp via <resolved program>" — justified
  2. Claude adapter stderr lines carry the same resolved-program suffix — justified
  3. Codex spawn and stderr logs likewise name the resolved program — justified
  4. Node-launched adapters show the entry script, not "node" (case-insensitive on Windows) — justified
  5. Opencode and kiro logs stay on constant labels — symptom-level: same override root cause, 2 unfixed siblings counted (client.py:5945, 6040)
  6. _drain_stderr gains a label param defaulting to kiro-cli — zero consumers of the default; only caller passes it explicitly

Watch

  • Point patch with 2 counted unfixed siblings. Grepped env-override resolution per backend: 4 backends resolve a binary (CLAUDE_AGENT_ACP_BIN, CODEX_ACP_BIN, _ENV_OPENCODE_BIN, KIROCREW_KIRO_BIN); 2 get resolved labels. The description declares kiro unchanged but gives no reason, and never mentions opencode. The fix is in-scope: both branches already hold the resolved argv where the new labels are assigned.
    Clears when: opencode/kiro labels derive from their resolved argv, or a stated reason exempts those seams.

Subtractions

  • Drop the default on _drain_stderr's label parameter (= KIRO_CLI_BIN) — 1 production caller, and it passes label= explicitly; make it required so a future call site cannot silently mislabel as kiro-cli.

[FIRST-PRINCIPLES-REVIEWED] 4bb33dc

@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 6, 2026
@Premshay
Premshay force-pushed the upstream/acp-spawn-label branch from 761b37d to 43bad8c Compare September 7, 2026 07:51
@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 Sep 7, 2026
@Premshay
Premshay force-pushed the upstream/acp-spawn-label branch from 43bad8c to 1c90b7a Compare September 7, 2026 18:21
@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 Sep 7, 2026
@Premshay
Premshay force-pushed the upstream/acp-spawn-label branch from 1c90b7a to f86fc56 Compare September 8, 2026 09:22
@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 Sep 8, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

@Premshay Thanks for the detailed writeup. The defect is real and nothing on main covers it: _adapter_spawn_label and _ADAPTER_INTERPRETERS do not exist there, test/test_acp_spawn_label.py is absent, and both label sites in src/kiro_crew/acp/client.py (_spawn_label in _spawn, _bin_label in _drain_stderr) are still the hardcoded seam ternaries. So the remaining scope is the whole change, and the insertion point is intact, only line offsets moved.

Three things before it can land, audited at 1c90b7a:

  1. The blocking H13 finding stands: adapter_argv = tuple(argv) and self._spawn_label = ... else "" sit on the shared spawn path that the kiro-cli seam also runs. Compute and store the label inside the claude and codex branches only.
  2. Both advisory lanes agree the interpreter skip degrades the default install: _CLAUDE_ACP_PKG_ENTRY and _CODEX_ACP_PKG_ENTRY are both dist/index.js, so a vendored or mise resolution logs Spawned index.js for both seams, which is less identifying than the constant it replaces. Either drop the argv[1] branch and fall back to the seam constant, or log the seam plus the resolved path.
  3. The branch is 105 commits behind main, so it needs a rebase. It also rewrites the exact two ternaries that open feat(acp): register opencode ACP backend — known, gated until enforceable routing exists #9013 (the opencode seam), fix: read opencode models from its advertised catalog #6777 and feat: add Codex ACP backend #5349 touch. feat(acp): register opencode ACP backend — known, gated until enforceable routing exists #9013 is the live one, so a note there about who owns those two expressions would save a conflict later.

One thing worth declaring in the body: the claude stderr prefix changes from claude-acp to the resolved basename for every claude-seam user, not only when an override is set.

Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong.

@Premshay
Premshay force-pushed the upstream/acp-spawn-label branch 2 times, most recently from 153aede to 50d487c Compare September 8, 2026 20:20
@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 Sep 9, 2026
@Premshay
Premshay force-pushed the upstream/acp-spawn-label branch from 50590a0 to c97c203 Compare September 11, 2026 11:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 11, 2026
@Premshay
Premshay force-pushed the upstream/acp-spawn-label branch from c97c203 to 99b5e22 Compare September 12, 2026 21:09
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 12, 2026
Both ACP seams resolve their adapter through a documented environment override
(CLAUDE_AGENT_ACP_BIN, CODEX_ACP_BIN), and either may point at a dispatch shim
or a vendored build that is not the seam's own adapter. The spawn log line and
the adapter's forwarded stderr both named a fixed constant, so a session routed
through an override was attributed to a program that never ran -- and the two
seams collapsed onto one name whenever both resolved to the same Node launcher.

The label is now derived from the resolved argv, and derived before the sandbox
and cgroup wrappers prepend their own program, so it names the adapter rather
than env or systemd-run. A launcher that carries the adapter's entry script as
its next argument is skipped so the label is the script, not "node"; the match
is case-folded because a Windows shim can report node.EXE. The seam prefix is
kept, so existing log parsers still see which seam a line came from.

The kiro-cli path keeps its original control flow and labels: harness parity
holds that branch fixed, and nothing about it is resolved through an override.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Premshay
Premshay force-pushed the upstream/acp-spawn-label branch from 99b5e22 to 4bb33dc Compare September 13, 2026 21:08
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Sep 13, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) September 13, 2026 22:04

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: fix -- the ACP spawn and stderr log label was taken from argv[0], so every adapter resolved to a script logged as 'node' rather than as the adapter that actually ran; the fix names the resolved program alongside the seam, and the second file is its test. CodeQL is not applicable on this fork PR (default-setup emits no check-run); SAST coverage is Semgrep only, latest run success with 0 annotations.

@iamwhatever
iamwhatever merged commit 86ac043 into kirodotdev:main Sep 13, 2026
83 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 13, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
Both ACP seams resolve their adapter through a documented environment override
(CLAUDE_AGENT_ACP_BIN, CODEX_ACP_BIN), and either may point at a dispatch shim
or a vendored build that is not the seam's own adapter. The spawn log line and
the adapter's forwarded stderr both named a fixed constant, so a session routed
through an override was attributed to a program that never ran -- and the two
seams collapsed onto one name whenever both resolved to the same Node launcher.

The label is now derived from the resolved argv, and derived before the sandbox
and cgroup wrappers prepend their own program, so it names the adapter rather
than env or systemd-run. A launcher that carries the adapter's entry script as
its next argument is skipped so the label is the script, not "node"; the match
is case-folded because a Windows shim can report node.EXE. The seam prefix is
kept, so existing log parsers still see which seam a line came from.

The kiro-cli path keeps its original control flow and labels: harness parity
holds that branch fixed, and nothing about it is resolved through an override.

Co-authored-by: Premshay <28099628+Premshay@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants