Skip to content

fix(diagnostics): resolve kiro-cli via resolve_kiro_cli() instead of bare PATH lookup - #7826

Closed
adiarora06 wants to merge 1 commit into
kirodotdev:mainfrom
adiarora06:fix/kiro-cli-diagnostics-path-resolve
Closed

adiarora06 wants to merge 1 commit into
kirodotdev:mainfrom
adiarora06:fix/kiro-cli-diagnostics-path-resolve

Conversation

@adiarora06

Copy link
Copy Markdown
Contributor

Closes #7674

Root cause

_kiro_cli_version() (src/kiro_crew/diagnostics.py) spawned the bare name ["kiro-cli", "--version"], which resolves only through the collector process's own inherited PATH. A desktop app launched from Finder/Dock on macOS inherits launchd's minimal PATH, not the login shell's, so ~/.local/bin (and similar install dirs) are absent from the collector's environment even when the CLI is installed there and the gateway is successfully spawning it through resolve_kiro_cli().

The result: a working install reported kiro-cli: unavailable in both places a maintainer reads first — versions.txt in the diagnostics bundle and the prefilled bug-report footer — indistinguishable from "not installed," and this false signal had already misdirected two triage passes on #3084 and spawned #7233.

Fix

_kiro_cli_version() now resolves the binary through resolve_kiro_cli() (src/kiro_crew/kiro_cli.py) — the same fixed-dir + PATH search the gateway and ACP launch paths already use — and spawns the absolute path it returns:

  • unavailable is now reported only when the resolver genuinely finds nothing.
  • A binary the resolver did find but that fails to execute now reports present but not runnable instead of collapsing onto the same "not installed" string.

Both user-visible call sites (_versions_text() and the issue-template footer in _issue_url()) share _kiro_cli_version(), so the one fix covers both.

Testing

Added TestKiroCliVersionProbe to test/test_diagnostics.py:

  • resolves a binary that lives only in a fixed known_kiro_cli_dirs() entry (~/.local/bin) while the inherited PATH excludes it entirely (the exact scenario from the bundle evidence in the issue)
  • still reports unavailable when the resolver finds nothing
  • reports present but not runnable (not unavailable) for a resolved-but-broken binary
  • asserts the probe spawns the resolved absolute path, never the bare command name

.venv/bin/python3 -m pytest test/test_diagnostics.py -q → 50 passed.
Also ran test/test_env.py, test/test_cli_doctor.py, test/test_kiro_prerequisite.py, test/test_acp_client.py — all pass except one pre-existing, unrelated failure (TestResolveKiroBinEnvOverride::test_spawn_passes_installed_path_through_exact_wrappers, a pass_fds/platform assertion that fails identically on a clean upstream/main checkout).

black/isort/flake8/mypy run on touched files: no new issues introduced by this change (the local venv's black disagrees with pre-existing formatting in both files unrelated to my edits — verified the diff black --diff proposes doesn't touch any of the lines I added).

No CHANGELOG.md changes, per this repo's fix-PR convention.

🤖 Generated with Claude Code

…bare PATH lookup

_kiro_cli_version() spawned the bare name ["kiro-cli", "--version"],
which only resolves through the collector process's own inherited
PATH. A desktop app launched from Finder/Dock on macOS inherits
launchd's minimal PATH (no ~/.local/bin), so a working install
reported 'unavailable' -- indistinguishable from 'not installed' --
in both versions.txt and the prefilled bug-report footer, even while
the gateway successfully ran the same binary via resolve_kiro_cli().

Resolve through resolve_kiro_cli() first (the same fixed-dir search
the gateway and ACP launch paths already use), spawn the absolute
path it returns, and reserve 'unavailable' for the resolver
genuinely finding nothing. A resolved binary that fails to run now
reports 'present but not runnable' instead of collapsing onto the
same string.

Closes kirodotdev#7674

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@adiarora06
adiarora06 requested review from a team and iamwhatever September 2, 2026 08:02
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 2, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed
  • ## Tests

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

3 similar comments
@dwu96

dwu96 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed
  • ## Tests

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

@dwu96

dwu96 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed
  • ## Tests

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

@iamwhatever

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed
  • ## Tests

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

@bolichen97

Copy link
Copy Markdown
Contributor

Closing — a duplicate of #7692, which is the more hardened version

Verified relationship: duplicate

Both PRs repair the same defect in the same function, _kiro_cli_version() in src/kiro_crew/diagnostics.py, against the same issue (#7674), with the same mechanism: add from kiro_crew.kiro_cli import resolve_kiro_cli, call resolve_kiro_cli(), early-return "unavailable" only when it resolves nothing, spawn [binary, "--version"] in place of the bare ["kiro-cli", "--version"], and report the brand-new sentinel "present but not runnable" for a resolved-but-broken binary — a literal that exists nowhere on origin/main. origin/main:src/kiro_crew/diagnostics.py:278-289 still holds the bare-name spawn, so nothing has landed and neither branch is stacked (7826 = 1 commit 68a58cf; 7692 = 2 commits 46b55cb + 9a9a14c, disjoint). Even the decisive regression test is the same test written twice: both plant #!/bin/sh + echo 'kiro-cli 9.9.9' at a fake home's .local/bin/kiro-cli chmod 0o755 (the first POSIX entry of known_kiro_cli_dirs, kiro_cli.py:195) with a PATH that excludes it. Only one can land, and #7826's tests break under #7692's shape because #7692 deletes import subprocess from diagnostics.py, so monkeypatch.setattr(diagnostics.subprocess, "run", ...) would AttributeError. #7826's production change is otherwise a strict subset: no returncode!=0 branch, narrow (OSError, SubprocessError) containment instead of except Exception, no scrub_env child environment, no run_limited ceiling, and it leaves both riders untouched — .github/subprocess-encoding-baseline.txt:50 and the test_spawn_audit.py:264 BENIGN_SPAWNS entry whose rationale ("The binary name is a module constant; a resource ceiling / sandbox adds nothing") its own change falsifies. The one fact that could have flipped the survivor is #7692's live GPT 5.6 [BLOCK-MERGE] telling it to revert the resolver-based spawn as a sandbox bypass, but that attacks the premise both PRs share, and #7826 performs the identical resolver-selected spawn of a user-writable binary with fewer mitigations — so swapping survivors would reintroduce the block in a weaker form. #7692 also holds Design PASS, First Principles PASS, Opus 4.8 no-blocking-findings and four documented review rounds, while #7826 has zero reviews (the review thread = [[]]) and four unanswered PR-template nags for a body still missing the required sections, so its workflows are not auto-approved.

This was adjudicated twice, independently; the second reviewer reached the same ruling (duplicate). Their strongest corroborating fact:

src/kiro_crew/diagnostics.py — both diffs start from the same blob (index f97e63b7a2..238c868730 on #7826, index f97e63b7a2..e5d5794f41 on #7692) and both replace ["kiro-cli", "--version"] with [binary, "--version"] after binary = resolve_kiro_cli() + an "unavailable" early return, and both replace the except … return "unavailable" tail with the identical new literal "present but not runnable" (absent from origin/main). test/test_diagnostics.py — same base blob ab7eff61c8; #7826's TestKiroCliVersionProbe::test_resolves_a_binary_absent_from_the_inherited_path and #7692's TestKiroCliVersionResolution::test_binary_absent_from_path_is_still_found both plant #!/bin/sh + echo 'kiro-cli 9.9.9' at <fake home>/.local/bin/kiro-cli, chmod 0o755, pin a PATH excluding it, and assert "kiro-cli 9.9.9". Only #7692 carries the riders: run_limited(..., env=scrub_env()) + **UTF8_TEXT, the out.returncode != 0 branch, deletion of 1 src/kiro_crew/diagnostics.py from .github/subprocess-encoding-baseline.txt, and removal of "diagnostics.py::_kiro_cli_version" from test/test_spawn_audit.py BENIGN_SPAWNS.

Evidence

(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 and not the other

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.

Carry this over first

This closure is about redundancy, and these items are the exception: they are not on main and not in the surviving PR, so they need a home before the topic is finished. Please don't let them go with the branch.

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. Findings that implied a closure were re-adjudicated independently, including an adversarial pass whose only job was to refute them; the reasoning above is what survived. If it is wrong, reopening costs nothing — please say so, and treat the reasoning rather than the outcome as the thing to correct.

@bolichen97 bolichen97 closed this Sep 2, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 2, 2026
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.

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

4 participants