fix(mac): verify launchd stop releases gateway port#81732
Conversation
|
Codex review: found issues before merge. Summary Reproducibility: yes. The linked issue gives concrete macOS stop steps, current main lacks listener/port verification, and this PR’s remaining issue is source-reproducible because fallback success text is emitted before the new postcondition can throw. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Keep the postcondition and service-env resolution, but defer any stopped/degraded success output until the effective port is verified free and cover the busy fallback path in tests. Do we have a high-confidence way to reproduce the issue? Yes. The linked issue gives concrete macOS stop steps, current main lacks listener/port verification, and this PR’s remaining issue is source-reproducible because fallback success text is emitted before the new postcondition can throw. Is this the best way to solve the issue? No. The postcondition approach is the right fix shape, but the fallback output ordering should be changed so the user never sees stopped/degraded success when the resolved gateway port remains busy. Full review comments:
Overall correctness: patch is incorrect What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 66b98b72946f. |
|
Broad verification update:
|
|
Addressed the LaunchAgent service-environment resolver gap from #81732 (comment). Changes:
Verification on pushed head
I checked review-thread state after the fix; there are no open GitHub review threads on this PR to resolve. |
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: BunsDev <[email protected]>
Co-authored-by: BunsDev <[email protected]>
…ition' into meow/macos-launchd-stop-postcondition
Resolved. I rebased onto latest |
|
Addressed the degraded fallback output blocker from the updated ClawSweeper review. Changes:
Verification on pushed head
|
|
Latest exact-head verification after merging current
The earlier CI lint-suppression failure came from the rebased main baseline and is fixed by the newer |
Summary
gateway stopcleanup before reporting success.gateway stop/gateway restartstill check app-managed service ports.gateway restartbefore kickstart when the configured port is still busy after verified stale-listener cleanup.Stopped LaunchAgent.Fixes #73132.
Verification
PATH=/Users/buns/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH node scripts/run-vitest.mjs src/daemon/launchd.test.ts src/cli/daemon-cli/lifecycle.test.ts src/cli/daemon-cli/lifecycle-core.test.ts src/cli/daemon-cli/restart-health.test.tsPATH=/Users/buns/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH pnpm exec oxfmt --check --threads=1 src/daemon/launchd.ts src/daemon/launchd.test.ts CHANGELOG.mdgit diff --check(cd apps/macos && swift test --filter GatewayLaunchAgentManagerTests)(cd apps/macos && swift test --filter LaunchAgentManagerTests)tbx_01krjwwv9z9z3f5d06fqph6eta:(git -c remote.origin.tagOpt=--no-tags fetch --unshallow origin '+refs/heads/main:refs/remotes/origin/main' || git -c remote.origin.tagOpt=--no-tags fetch --depth=10000 origin '+refs/heads/main:refs/remotes/origin/main') && git merge-base origin/main HEAD && pnpm check:changedBehavior addressed: managed macOS LaunchAgent stop/restart no longer claims success when the resolved gateway port remains busy after cleanup, including the normal installed path where the port only exists in the persisted LaunchAgent service environment and fallback paths that report degraded stop success.
Real environment tested: local macOS SwiftPM package, focused TS/Vitest launchd/daemon CLI tests in the Codex worktree, and Testbox
pnpm check:changedon the pushed PR branch.Exact steps or command run after this patch: the six commands/listed proof items above were run after the patch and before this PR update.
Evidence after fix: TS focused tests passed with 4 files and 147 tests; SwiftPM
GatewayLaunchAgentManagerTestspassed 3 tests; SwiftPMLaunchAgentManagerTestsfilter passed the matching LaunchAgent/GatewayLaunchAgent suites with 4 tests total; formatting and whitespace checks were clean; Testboxtbx_01krjwwv9z9z3f5d06fqph6etaexited 0.Observed result after fix: stop verifies the configured port before writing
Stopped LaunchAgent, busy-port stop failures include listener diagnostics, restart aborts beforelaunchctl kickstartwhen the port remains busy, stored LaunchAgent env-file-only ports are covered by stop/restart regression tests, and degraded fallback success is emitted only after the port is verified free.What was not tested: signed app local-mode smoke was not run on this Mac because it would mutate the installed LaunchAgent/runtime state; that should be done on a dedicated macOS Testbox or smoke machine before landing.