Skip to content

fix(diagnostics): resolve kiro-cli before probing its version - #7692

Closed
dwu96 wants to merge 2 commits into
mainfrom
fix/diagnostics-resolve-kiro-cli-7674
Closed

dwu96 wants to merge 2 commits into
mainfrom
fix/diagnostics-resolve-kiro-cli-7674

Conversation

@dwu96

@dwu96 dwu96 commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #7674

Symptom

A diagnostics bundle from a host with a working Kiro CLI reports kiro_cli_version: unavailable in versions.txt, and the prefilled bug-report footer shows kiro-cli: unavailable — indistinguishable from "not installed". The motivating evidence is a bundle that contradicts itself: its versions.txt says unavailable while its own gateway.log, same host and same collection, logs the gateway spawning the binary from the reporter's home .local/bin — the FIRST fixed entry in known_kiro_cli_dirs().

The triage cost is concrete: the false unavailable was named "the strongest remaining signal" in two separate re-triage passes on #3084, and supplied the sole evidence for #7233's "cause 2".

Root cause

_kiro_cli_version() spawned the bare command name, so it resolved only through the collector process's inherited PATH. When that PATH lacks the install directory, the spawn raises FileNotFoundError and the except (OSError, SubprocessError) handler returns "unavailable". The resolution METHOD is the defect: the repo already owns correct resolution in kiro_cli.resolve_kiro_cli(), which searches fixed install directories ahead of the inherited PATH — — and the collector bypassed it. (A second bare-name version probe exists at slack/gateway.py:2380, _warn_if_kiro_cli_outdated; its silent-suppress symptom is tracked with the other siblings in #7704 and is out of this PR's scope.) (No claim is made about the specific PATH contents on the reporter's host; what is proven is that the bare-name spawn failed while the binary sat in a fixed resolver directory.)

Fix (smallest change, _kiro_cli_version() only)

  • Resolve the binary via resolve_kiro_cli() — the same resolver the agent-runtime spawn already uses (acp/client.py:297) — and spawn the absolute path it returns, with the capture/text/timeout/no-check arguments unchanged.
  • resolve_kiro_cli() -> None is now the ONLY producer of "unavailable", so that string means genuinely not installed.
  • A resolved binary that fails to spawn, times out, or exits non-zero reports the DISTINCT "present but not runnable" instead of collapsing onto "unavailable". The existing exception tuple stays as the containment boundary — the probe degrades to a string, never raises.
  • Tests pin the host layout by rebinding the module's resolve_kiro_cli to the REAL resolver with fixed home/environ/platform_name kwargs — the resolution logic stays under test with no shipped parameter surface (First Principles round-1 subtraction, adopted in the review commit).
  • The resolved path is deliberately NOT embedded in the reported string: it flows verbatim into the public GitHub issue prefill footer, and a home-directory path would leak the username there (the spec offered this as optional; skipped on that ground).
  • test/test_spawn_audit.py BENIGN_SPAWNS rationale for this probe updated in the same commit ("binary name is a module constant" would otherwise be stale); the probe now trusts exactly what the runtime spawn already trusts.
  • No docs/system-specs/modules/*.md documents the versions.txt field values (checked by grep), so no spec-doc update is required.

Verification

Red before green — all four new tests fail on unmodified main (run in a git worktree at origin/main): the decisive case plants a fake executable reachable ONLY through a fixed known_kiro_cli_dirs() entry (a fake home's .local/bin, layout pinned through the real resolver) with a pinned PATH that excludes it — a bare-name spawn cannot see it. Green on this branch (4/4).

Mutation checks — each direction executed with sed, test run captured, then reverted:

  • (a) restore the bare-name spawn → test_binary_absent_from_path_is_still_found red ('kiro-cli 2.20.2' == 'kiro-cli 9.9.9' — the mutant resolved the test host's REAL install through PATH, which is precisely the misreport class under fix).
  • (b) map the None branch onto the found-binary path → test_nothing_resolved_is_exactly_unavailable red ('kiro-cli 2.20.2' == 'unavailable').
  • (c) collapse "present but not runnable" onto "unavailable" → both not-runnable tests red.
  • Restored tree: 4/4 pass.

Gates — scripts/local-gate.py --base origin/main (backend-only diff plan: full backend + 194 frontend guard specs):

  • Backend full suite: 78,925 passed, 221 failed + 2 errors — all pre-existing environmental (see zero-regression proof).
  • Frontend cross-surface guards: 196 files / 5,347 tests, all passed (node 22 toolchain).
  • Repo black gate (scripts/check_black_formatting.py): passed. isort/flake8/mypy on touched files: clean.

Zero-regression proof (both directions) — full backend suite on this branch vs a git worktree at origin/main, sorted failing-id sets diffed:

  • Branch-only failures: zero.
  • Main-only failures: 3 ids in test_release_macos_fail_closed.py, which re-run solo fail IDENTICALLY on both trees (order/environment-dependent, unrelated to this diff).
  • Remaining 221+2 ids byte-identical across both runs.

No frontend surface changes.

No screenshot evidence: this is a subprocess-resolution change in the diagnostics collector with no rendered surface; the behavioral delta is only provable by the focus of the regression tests above, not by a still frame.

Review-driven changes

  • Round 1 (First Principles CONCERNS, advisory): adopted the subtraction — dropped the three zero-consumer keyword-only test passthrough params from _kiro_cli_version(); tests now pin layout via a resolver rebind with identical decisive coverage. The watch item (two bare-name kiro-cli auto-update spawns in cli_server.py / slack/gateway.py, same cause / different symptom) is tracked in Bare-name kiro-cli spawns: auto-update checks and gateway boot version probe miss fixed-dir installs #7704; out of scope here per the task spec's no-opportunistic-widening constraint.

  • Rounds 2-4 (GPT 5.6 BLOCKING ×3 + Design CONCERNS, converged empirically): final probe shape is run_limited + scrub_env() child environment — no inherited credentials, kernel resource ceiling. The round-3 sandboxed_spawn_argv(mode="strict") route was tried and then REMOVED with evidence: GPT round-4 correctly found its preparation sat outside the containment, and reproducing on a real enterprise-profile install showed wrap_argv raising PlatformCompositionError outside a booted gateway context — a working kiro-cli 2.21.0 misreported as present but not runnable, the exact defect class this PR eliminates (Design round-4 concern, empirically confirmed, then fixed: the same real-binary check now returns the true version). The whole spawn incl. preparation sits in one broad containment logged at DEBUG; guards: raising-machinery regression test + env sentinel test, each mutation-checked red (narrowed containment / dropped scrub).

Pattern harvest

Rule candidate: a version/presence probe of an optional binary must resolve through the component's owning resolver (here the kiro_cli.resolve_kiro_cli() family) instead of spawning the bare name — a bare-name spawn conflates "not on this process's inherited PATH" with "not installed", and diagnostics surfaces then misreport working installs as absent. Sibling bare-name sites knowingly left out of scope (unrelated flows, per the task spec): the auto-update presence checks in cli_server.py and slack/gateway.py (shutil.which("kiro-cli") + bare spawn) share the shape and are candidates for the same rule.

@dwu96
dwu96 requested review from a team and cixuuz September 1, 2026 18:16
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Reuses the resolver the runtime spawn already trusts (acp/client.py:361), so diagnostics now reports the binary the gateway actually runs — root cause, right layer, tightly scoped.

[DESIGN-REVIEWED] c3ff8c5

@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] c3ff8c5

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

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

@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of c3ff8c5d02a506399ec207338184f732f26601b4 — 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 claims verified against the repo: resolve_kiro_cli exists with the pinning kwargs (kiro_cli.py:276), the runtime spawn uses it (acp/client.py:361), run_limited/scrub_env/UTF8_TEXT exist, the two consumers of the version string are diagnostics.py:394 and :450, and the two declared sibling bare-name spawns (cli_server.py:1375, slack/gateway.py:2755) are real and left in place as the description says. Final review:

First-Principles-Verdict: PASS

Verify #7704 actually tracks the two remaining bare-name spawns (cli_server.py:1375, slack/gateway.py:2755) — the deferred general fix has no other anchor.

Not justified as shipped

What this change ships

Intent: a support bundle from a host with a working off-PATH kiro-cli must stop reporting it as not installed — a FIX.

  1. versions.txt and the bug-report footer now report the real version for off-PATH installs — justified
  2. broken-but-present installs now read "present but not runnable" instead of "unavailable" — justified
  3. the probe child now gets a credential-scrubbed env and kernel resource ceiling — rides along
  4. any probe failure now degrades to a string instead of crashing collection — justified
  5. probe output now decoded as UTF-8; encoding-baseline entry deleted — rides along
  6. spawn-audit benign-list entry for the probe deleted (its "module constant" premise no longer holds) — justified

The fix sits at cause level (the resolution method, not the observed call site), uses the existing resolver rather than a second one (grepped resolve_kiro_cli: 6 production callers, this makes 7), and the point-patch scope is declared with siblings counted (2, tracked in #7704). The deleted spawn-audit pin's own predicate ("binary name is a module constant") is falsified by the diff itself.

[FIRST-PRINCIPLES-REVIEWED] c3ff8c5

@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging c3ff8c5d02a506399ec207338184f732f26601b4. 2 of 2 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/diagnostics.py:327 -- untrusted resolved binary runs without OS isolation (origin: validation)
out = run_limited([binary, "--version"], ...)
Agent plants ~/.local/bin/kiro-cli -> diagnostics resolves it -> unsandboxed code executes as the gateway user.
Anchor: residual/security
Fix: Sandbox or provenance-validate the resolved executable before running it.

BLOCKING -- src/kiro_crew/diagnostics.py:323 -- resolver exceptions bypass containment
binary = resolve_kiro_cli()
Unresolvable home -> bundle collection -> Path.home() raises RuntimeError -> dashboard returns 500 and CLI doctor aborts.
Anchor: residual/crash-data-loss-corruption
Fix: Move resolution and the None check inside the existing try.

[BLOCK-MERGE] c3ff8c5
[GPT-REVIEWED] c3ff8c5

Adjudication (Opus 4.8) — is blocking on each finding proportionate?

The adjudicable block is empty (0 findings). Two fenced findings, F1 and F2, remain — annotate-only.

F1 — diagnostics.py:327 runs the resolver-selected binary. ~/.local/bin is the FIRST fixed install candidate (kiro_cli.py:204), checked even with include_inherited_path=False; _kiro_cli_version calls resolve_kiro_cli() with defaults, so a binary planted there wins resolution and executes outside the OS sandbox as the gateway user (diagnostics.py:315-319 deliberately skips sandboxed_spawn_argv). scrub_env/run_limited bound the environment and resources but do not prevent arbitrary code execution. Harm rung: UNBOUNDED (code execution / sandbox escape). The precondition — an agent writing to ~/.local/bin, a non-HIDDEN path — is not extreme; I cannot complete a rarity record that a human would accept arbitrary out-of-sandbox execution. When torn on unbounded harm → UPHOLD-FENCED.

F2 — binary = resolve_kiro_cli() at diagnostics.py:323 sits OUTSIDE the try opening at 326; resolve_kiro_cli calls Path.home() (kiro_cli.py:297) which raises RuntimeError when HOME is unresolvable. A systemd-managed gateway started with KIROCREW_HOME set but no HOME env var — a plausible real deployment — reaches this on the doctor/status path and the docstring's "never raises" guarantee is violated. Consequence is a visible 500 / doctor abort, but the condition is not extreme enough to build the rarity record FLAG requires. When torn → UPHOLD-FENCED.

[ADJUDICATION] c3ff8c5d02a506399ec207338184f732f26601b4 total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] c3ff8c5d02a506399ec207338184f732f26601b4
[ADJUDICATION-FENCED] c3ff8c5d02a506399ec207338184f732f26601b4 fenced=2 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/diagnostics.py:327 -- Agent-plantable ~/.local/bin is the first fixed resolver candidate, so the resolved binary runs unsandboxed as the gateway user; unbounded, precondition not extreme.
UPHOLD-FENCED F2 src/kiro_crew/diagnostics.py:323 -- resolve_kiro_cli()'s Path.home() sits outside the try and can RuntimeError under a HOME-less/KIROCREW_HOME deployment, a plausible not-extreme condition.
[GPT-ADJUDICATED-FENCED] c3ff8c5d02a506399ec207338184f732f26601b4

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

@dwu96

dwu96 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Disposition of First Principles round-1 CONCERNS (verdict at 98b1bcb):

  1. Subtraction — drop the three zero-consumer keyword-only params: ADOPTED. The review commit (review: drop zero-consumer test passthrough params from _kiro_cli_version) removes them; tests now rebind the module's resolve_kiro_cli to the real resolver with pinned home/environ/platform_name kwargs, so the decisive resolution behavior stays under test with zero shipped surface. All three mutation checks re-executed against the reworked shape and still kill (bare-name restore, None-branch bypass, not-runnable collapse).

  2. Watch — two remaining bare-name kiro-cli spawns (cli_server.py auto-update, slack/gateway.py auto-update): ACKNOWLEDGED and tracked in Bare-name kiro-cli spawns: auto-update checks and gateway boot version probe miss fixed-dir installs #7704. Same root cause, different symptom (silent skip, not misreport); deliberately out of this PR's scope per the task spec's smallest-change constraint. The PR-body claim is scoped to version-probe callers, which the collector was the only one of.

New head: 4120fb7 (rebased onto current main; 2 commits).

@dwu96

dwu96 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Disposition of GPT 5.6 round-2 BLOCKING finding ("resolved user-bin candidate executes with gateway authority", at 4120fb7):

Adopted — the environment half. The probe child now gets sandbox.scrub_env() instead of the gateway's environment (new head d4307d3), following the in-tree tailnet-probe precedent (dashboard/tailnet.py:211), precisely because the resolver's first candidates live in user-writable install dirs. New sentinel regression test (test_probe_child_env_is_scrubbed) proves a planted binary sees no credential-bearing vars; mutation-checked — removing env=scrub_env() turns it red.

Declined — the revert. Reverting to the bare-name spawn reintroduces #7674 and does not remove the execution surface it names: on any host whose gateway PATH contains ~/.local/bin (the common case), the pre-change code already executed the same user-writable candidate. More decisively, kiro_cli.resolve_kiro_cli() is the repo's existing trust boundary for this binary — acp/client.py:297 spawns the IDENTICAL resolver output as the agent runtime, unsandboxed, with strictly more authority and on every kiro-cli session start. A --version probe of the same resolved path during operator-initiated diagnostics collection adds no capability an attacker with ~/.local/bin write access does not already have. The genuine underlying issue — trusting a same-user-writable launcher path at all — is the repo-wide launcher-trust problem tracked in #417, and per-call-site sandboxing of this probe would not close it. BENIGN_SPAWNS rationale updated in the same commit to record the scrub and this trust argument.

Declined — full sandbox routing. The audit's own posture for read-only probes (tailnet rationale in test_spawn_audit.py) applies: diagnostics collection is a never-raises, best-effort path; making it depend on sandbox availability trades a misreport bug for a collection failure.

New head: d4307d3 (rebased onto current main; 2 commits — round-2 hardening amended into the review commit to hold the PR Hygiene cap).

@dwu96
dwu96 force-pushed the fix/diagnostics-resolve-kiro-cli-7674 branch from d4307d3 to 62b3aa3 Compare September 1, 2026 21:39
@dwu96

dwu96 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Disposition of GPT 5.6 round-3 BLOCKING finding (at d4307d3): ADOPTED — the named fix, in full.

The probe now routes through the audited chokepoint exactly as requested: sandboxed_spawn_argv([binary, "--version"], mode="strict") + cgroup_scope_argv + run_limited, copied from the in-tree pptx_maker engine shape (apps/builtins/pptx_maker/backend/engine.py:207-227), with the launcher cleanup unlinked in finally. The child gets filesystem/credential isolation, the scrubbed environment, and a kernel resource ceiling; the wrapper FAILS OPEN on hosts with no sandbox, so diagnostics collection keeps its never-raises contract.

Audit machinery updated in the same commit: the BENIGN_SPAWNS allowlist entry for this spawn is REMOVED (a routed spawn with a stale exemption would mask a regression that put the spawn back inline).

Guard evidence (all executed): a second sentinel test pins the wrapper to its FAIL-OPEN shape — on a sandbox-capable host the OS launcher itself scrubs the env, which would mask a probe that forgot to pass the returned env, so the fail-open pin is what makes the guard deterministic across hosts. Mutants: (d) dropping env=env → fail-open sentinel red; (e) removing the wrapper route entirely → BOTH sentinel tests red (leak observed). Noted honestly: the spawn-audit AST tripwire treats any run_limited call as routed, so wrapper removal is caught by the sentinel tests, not the audit — recorded here so the guard provenance is clear.

New head: 62b3aa3 (rebased onto current main; 2 commits).

@dwu96
dwu96 force-pushed the fix/diagnostics-resolve-kiro-cli-7674 branch from 62b3aa3 to 3e8f87e Compare September 1, 2026 22:22
@dwu96

dwu96 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Round-4 dispositions (new head 3e8f87e):

GPT 5.6 BLOCKING (sandbox prep crashes diagnostics) — ADOPTED, and it went deeper than the named fix. Reproduced empirically on a real enterprise-profile install: wrap_argv → _governance_sandbox_floor() → current_context() raises PlatformCompositionError outside a booted gateway context — exactly the fail-closed crash the finding predicted (evidence: bisection script output in the PR work log; stage A of the round-3 pipeline throws before the spawn). Moving prep inside the containment was necessary but not sufficient (see Design below), so the round-3 wrapper stage is REMOVED: final shape is run_limited + scrub_env() inside one broad except Exception containment logged at DEBUG. New regression test (test_raising_spawn_machinery_degrades_to_not_runnable) + mutation check (narrowing the containment back to (OSError,) turns it red).

Design CONCERNS (strict confinement can itself produce the misreport class) — CONFIRMED EMPIRICALLY, then fixed. On this real install the round-3 probe reported a working kiro-cli as present but not runnable; after the round-4 change the identical check returns kiro-cli 2.21.0 through the exact production code path. The retained hardening (resource ceiling + credential-scrubbed child env, sentinel-tested) is the empirically safe subset. BENIGN_SPAWNS tombstone comment updated with the deliberate-no-wrapper rationale: diagnostics must work precisely when the rest of the system is broken.

First Principles CONCERNS (false "only caller" claim; slack/gateway.py:2380 sibling) — ADOPTED. Verified real: _warn_if_kiro_cli_outdated is a second bare-name --version probe whose silent except: return suppresses the outdated-CLI boot warning on off-PATH installs. PR body corrected (no longer claims sole-caller), and the sibling is now tracked in #7704 (scope comment + retitle) rather than widened into this PR, per the task spec's smallest-change constraint.

@dwu96

dwu96 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Opus 4.8 BLOCKING (at superseded head 62b3aa3) — same defect as GPT round-4, already fixed at current head 3e8f87e: the sandboxed_spawn_argv stage is REMOVED entirely (its preparation also crashes with PlatformCompositionError outside a booted context, reproduced empirically — see the round-4 disposition above), the final shape is run_limited + scrub_env(), and the whole spawn sits in one broad except Exception containment, so SandboxUnavailableError/any RuntimeError degrades to present but not runnable (regression test test_raising_spawn_machinery_degrades_to_not_runnable, mutation-checked). Awaiting the lane's re-review of 3e8f87e.

@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 1, 2026
@dwu96
dwu96 force-pushed the fix/diagnostics-resolve-kiro-cli-7674 branch from 3e8f87e to 0d13b4f Compare September 1, 2026 23:15
@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 1, 2026
@dwu96
dwu96 force-pushed the fix/diagnostics-resolve-kiro-cli-7674 branch from 0d13b4f to 5003e51 Compare September 2, 2026 00:02
@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 readiness: checking Automated validation is still running labels Sep 2, 2026
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Sep 2, 2026
@dwu96
dwu96 force-pushed the fix/diagnostics-resolve-kiro-cli-7674 branch from 5003e51 to 9a9a14c Compare September 2, 2026 01:06
@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 2, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Audit note — #7826 is being closed in favour of this PR

Two independent adjudicators both ruled this the surviving implementation.

What the two shared

(1) src/kiro_crew/diagnostics.py, same hunk both sides: #7826 binary = resolve_kiro_cli() / if not binary: return "unavailable" / [binary, "--version"] / except (OSError, subprocess.SubprocessError): return "present but not runnable"; #7692 binary = resolve_kiro_cli() / if binary is None: return "unavailable" / run_limited([binary, "--version"], ..., env=scrub_env()) / except Exception: ... return "present but not runnable". git grep 'present but not runnable' origin/main -- src test → no hits, and origin/main:src/kiro_crew/diagnostics.py:278-289 still spawns ["kiro-cli", "--version"]. (2) test/test_diagnostics.py: #7826 TestKiroCliVersionProbe::test_resolves_a_binary_absent_from_the_inherited_path and #7692 TestKiroCliVersionResolution::test_binary_absent_from_path_is_still_found both write #!/bin/sh\necho 'kiro-cli 9.9.9'\n into <tmp home>/.local/bin/kiro-cli, chmod 0o755, pin a PATH excluding it, and assert "kiro-cli 9.9.9". (3) #7692 additionally drops 1 src/kiro_crew/diagnostics.py from .github/subprocess-encoding-baseline.txt and removes the now-false "diagnostics.py::_kiro_cli_version" BENIGN_SPAWNS entry at test/test_spawn_audit.py:264; #7826 changes neither, so it leaves a spawn-audit exemption standing on the rationale "The binary name is a module constant", which its own edit makes untrue.

Why this one

Yes — #7692 is the right survivor. It is the strict superset in production behaviour (non-zero-exit handling, broad containment, scrub_env child environment, run_limited ceiling), it moves the two riders #7826 leaves stale, it carries 6 mutation-checked tests versus 4, and it is the reviewed branch (Design PASS, First Principles PASS, Opus 4.8 clean, four documented review rounds) against #7826's zero reviews and unmet PR-template gate. The apparent counter-argument — #7692's open GPT 5.6 [BLOCK-MERGE] demanding a revert of the resolver-based spawn — does not favour #7826, because #7826 makes the identical resolver-selected spawn with none of the mitigations, so it inherits the same finding in a weaker form. That block is a merge-readiness question about the shared design, not a reason to prefer the unreviewed subset.

What #7826 had that this PR does not

Please pick these up (or say they are not wanted):

One test, worth porting but not blocking: #7826's test/test_diagnostics.py::TestKiroCliVersionProbe::test_spawns_the_resolved_path_not_the_bare_name is the only direct assertion that the spawn argv is the resolved absolute path (seen["argv"] == ["/opt/kiro/kiro-cli", "--version"]); #7692 proves that property only indirectly, via the plant-in-a-fixed-dir functional test. Porting it to #7692 means spying diagnostics.run_limited, not diagnostics.subprocess.run, which #7692 removes. Nothing else: #7826's other three cases (resolver-finds-nothing → unavailable, resolved-but-broken → present but not runnable, absent-from-PATH still found) are all covered by #7692 with equal or stronger coverage, and its docstring content is a subset of #7692's.


From a repository-wide duplicate/overlap audit of every pull request open against main (2026-09-02, 330 PRs, one reviewer per PR). Each PR was read as its full merge-base diff plus its description and every comment and review, then compared against each candidate PR's own diff and against origin/main at 1a765b88ceb7. This PR is not being closed — the note is informational. If the reading is wrong, please correct the reasoning rather than just the conclusion.

The support-bundle version probe spawned the bare command name, so it
resolved only through the collector process inherited PATH; when that
PATH lacked the install directory the probe reported "unavailable" for
a working install, in both versions.txt and the prefilled bug-report
footer. Route the probe through kiro_cli.resolve_kiro_cli() (fixed
install directories first), the same resolver the agent runtime spawn
already uses, and spawn the absolute path it returns. "unavailable" now
has exactly one producer (resolver found nothing); a resolved binary
that fails to spawn or exits non-zero reports the distinct "present but
not runnable" instead of collapsing onto "unavailable".

Fixes #7674
Round 1 (First Principles, adopted subtraction): drop the three
zero-consumer keyword-only test passthrough params; tests pin host
layout by rebinding the module resolve_kiro_cli to the real resolver
with fixed kwargs.

Rounds 2-4 (GPT 5.6 + Design, converged empirically): the probe spawns
via run_limited with a scrub_env() child environment — the resolver
first candidates live in user-writable install dirs, so the child gets
no inherited credentials and a kernel resource ceiling. The round-3
sandboxed_spawn_argv(mode=strict) route was REMOVED after empirical
verification on a real install: wrap_argv resolves the governance
sandbox floor, which raises PlatformCompositionError outside a booted
gateway context (GPT round-4 crash finding, reproduced), and a working
kiro-cli 2.21.0 then misreported as "present but not runnable" — the
exact defect class this PR eliminates (Design round-4 concern,
confirmed). Diagnostics must work precisely when the rest of the
system is broken, so the whole spawn including preparation now sits in
one broad Exception containment logged at DEBUG, with a regression
test for raising spawn machinery.
@bolichen97
bolichen97 force-pushed the fix/diagnostics-resolve-kiro-cli-7674 branch from 9a9a14c to c3ff8c5 Compare September 8, 2026 14:34
@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 8, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Rebased onto main 53987e75 by a maintainer as part of the 2026-09-08 open-PR audit. The branch was 796 commits behind.

Conflicts: none. Clean rebase, both commits replayed, diff unchanged at +159/-14 across 4 files.

Gates run locally (changed files only):

  • isort and flake8 on the 3 touched Python files: pass.
  • black --check: diagnostics.py and test_diagnostics.py still report reformat, but both are listed in .github/black-baseline.txt, so this is pre-existing and not introduced by the rebase. test_spawn_audit.py is clean.
  • pytest test/test_diagnostics.py test/test_spawn_audit.py: 67 passed.
  • scripts/check_subprocess_encoding.py: pass, so the baseline line removal is still correct against current main.

Please review the rebase result. A maintainer push makes the maintainer the last pusher, so under the repo's last-push rule a second approver is needed. Reply if anything looks wrong.

@github-actions github-actions Bot added 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: checking Automated validation is still running labels Sep 8, 2026
@chenmingwei23 chenmingwei23 added needs-pr-triage PR scanner: awaiting automated triage and removed needs-pr-triage PR scanner: awaiting automated triage labels Sep 13, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor

Kiro Crew [operator: chenmingwei23#de330d0c]: This PR has been inactive for 7+ days. I reviewed the blockers but they require your input:

  • GPT 5.6 BLOCKING F1 (security posture -- design decision): the finding wants _kiro_cli_version routed through sandboxed_spawn_argv because ~/.local/bin is the first fixed resolver candidate, so an agent-plantable binary there would run unsandboxed as the gateway user. But the docstring at diagnostics.py states this is a deliberate choice -- the sandbox floor raises PlatformCompositionError outside a booted gateway, which is the exact Diagnostics reports "kiro-cli: unavailable" for a working install: the version probe spawns a bare name instead of resolve_kiro_cli() #7674 defect this PR exists to eliminate, and diagnostics must work when the system is broken. Adopting F1 reverses the PR's core approach. This is a security-posture ruling for a maintainer, not a mechanical fix.
  • GPT 5.6 BLOCKING F2 (resolve_kiro_cli() outside the try at diagnostics.py:323): resolve_kiro_cli calls Path.home(), which raises RuntimeError under a HOME-less / KIROCREW_HOME-only deployment, violating the docstring's "never raises" guarantee. This one is a bounded fix, but it is entangled with the F1 resolver-call design above -- resolve it together with the F1 ruling.
  • Merge conflict: the branch is dirty again after the 2026-09-08 maintainer rebase. Needs a re-rebase onto current main once the F1 direction is settled.

When you've addressed these, the pipeline will re-assess on its next cycle.

@chenmingwei23 chenmingwei23 added the needs-author-decision PR blocked on author input label Sep 13, 2026
@dwu96 dwu96 mentioned this pull request Sep 16, 2026
1 task done
@iamwhatever

Copy link
Copy Markdown
Contributor

Closing as superseded.

main already resolves the binary before probing it: _kiro_cli_version at src/kiro_crew/diagnostics.py:801 goes through the pinned-path resolver, landed by #11209 (merged 2026-09-16), which also closed the tracking issue #7674.

Nothing in this diff is still unique on main, and the branch has been in merge conflict and idle 8+ days.

Thanks for the diagnosis -- it is what the tracking issue was filed from. Reopen if you find a probe site still spawning kiro-cli by bare name.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 21, 2026
@bolichen97
bolichen97 deleted the fix/diagnostics-resolve-kiro-cli-7674 branch November 6, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge needs-author-decision PR blocked on author input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diagnostics reports "kiro-cli: unavailable" for a working install: the version probe spawns a bare name instead of resolve_kiro_cli()

4 participants