close
Skip to content

fix(cli): match macOS framework Python in stop/restart gateway detection - #2523

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
mnaameh:fix/stop-macos-framework-python-detection
Aug 10, 2026
Merged

fix(cli): match macOS framework Python in stop/restart gateway detection#2523
iamwhatever merged 1 commit into
kirodotdev:mainfrom
mnaameh:fix/stop-macos-framework-python-detection

Conversation

@mnaameh

@mnaameh mnaameh commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

On macOS, kirocrew stop (and restart) print "No Kiro Crew gateway currently running on port

" even when the gateway is live and listening on that port — so neither command can stop the server.

Why it matters

Hits any macOS install whose interpreter is a framework build (Toolbox is the common one): stop is a no-op and restart can't kill the old gateway then fails to rebind, while status still reports "running" — the commands contradict each other. Users fall back to kill $(lsof -ti TCP:<port> -sTCP:LISTEN).

What changed (motivation → approach → change)

  • Symptom: kirocrew stop says no gateway while one is listening on the port.
  • Root cause: _stop/_restart locate the PID via lsof, then gate the kill on _is_kirocrew_process_args_look_like_kirocrew. The module-invocation branch requires a token before -m whose basename starts with "python", but the check was case-sensitive (_basename_stem(t).startswith("python")). A macOS framework build's interpreter basename is Python (capital P) — e.g. .../Python.app/Contents/MacOS/Python -m kiro_crew gateway — so the guard rejects the real gateway and the command no-ops.
  • Change: lower-case the interpreter basename before the prefix match (_basename_stem(t).lower().startswith("python")). One line; strictly widens to include Python/PYTHON, no effect on the negative cases (which fail for structural reasons, not interpreter case).

Tests

Added two launch forms to TestArgsLookLikeKirocrew.test_matches_server_launch_forms: a macOS framework path (/Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -m kiro_crew gateway --no-open) and a bare Python -m kiro_crew gateway. Both fail before the fix and pass after; existing negative cases (GATEWAY, grep -m, run gateway, editor) unchanged.

Manual verification

Reproduced on macOS: gateway live on the port (lsof shows Python … (LISTEN)), kirocrew stop printed "No Kiro Crew gateway currently running"; ps -o command= confirmed the process is .../Python.app/Contents/MacOS/Python -m kiro_crew gateway. With the fix, the classifier recognizes that command line.

Related Issues

None found in a search of open issues/PRs.

Checklist

  • Single commit with a Conventional Commits title (fix(cli): ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated — N/A
  • No secrets, credentials, or internal references in the diff

The _args_look_like_kirocrew module-invocation guard required a preceding token whose basename starts with "python", but the check was case-sensitive. The macOS framework build's interpreter basename is "Python" (capital P), so "Python -m kiro_crew gateway" failed the guard: kirocrew stop and restart reported "No Kiro Crew gateway currently running" and no-oped on macOS framework-build installs (Toolbox being the common one), even with the gateway live on the port.

Lower-case the interpreter basename before the prefix match, and add the framework-Python launch forms to the classifier tests.
@mnaameh
mnaameh requested a review from a team as a code owner August 10, 2026 10:41
@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 Aug 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

The change makes the Python-interpreter basename check case-insensitive (_basename_stem(t).lower().startswith("python")), correctly matching the macOS framework build's Python basename. It only broadens process matching for stop/restart on the operator's own processes — no security surface, no correctness regression, and the added case-fold cannot produce a wrong stop/restart target that the prior startswith("python") didn't already permit.

[OPUS-REVIEWED] d91c8cd

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Advisory design-level review of d91c8cdec4ebefb393d82eeabecc56d4737f61e5 via the fork AI-review pipeline — updated in place on each push; does not block merge.

Design-Verdict: PASS

A real macOS-only failure, fixed at the exact structural check that caused it, with regression tests pinning both spawn forms.

[DESIGN-REVIEWED] d91c8cd

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

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

Review details

No findings.
[GPT-REVIEWED] d91c8cd

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Aug 10, 2026
@iamwhatever
iamwhatever merged commit c491990 into kirodotdev:main Aug 10, 2026
59 of 60 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Aug 10, 2026
encomjp pushed a commit to encomjp/kirocrew-customapi that referenced this pull request Aug 22, 2026
…ion (kirodotdev#2523)

The _args_look_like_kirocrew module-invocation guard required a preceding token whose basename starts with "python", but the check was case-sensitive. The macOS framework build's interpreter basename is "Python" (capital P), so "Python -m kiro_crew gateway" failed the guard: kirocrew stop and restart reported "No Kiro Crew gateway currently running" and no-oped on macOS framework-build installs (Toolbox being the common one), even with the gateway live on the port.

Lower-case the interpreter basename before the prefix match, and add the framework-Python launch forms to the classifier tests.

Co-authored-by: Marc El Naameh <mnaameh@amazon.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.

2 participants