Skip to content

fix(packager): end the session command with exit "$status" - #61

Merged
twoimo merged 1 commit into
mainfrom
fix/session-command-exit-status
Nov 23, 2026
Merged

twoimo merged 1 commit into
mainfrom
fix/session-command-exit-status

Conversation

@twoimo

@twoimo twoimo commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Why

The goal is to leave twoimo/alden with no open PRs or issues, each one resolved on its merits. Reviewing the launchd runbook fix turned up a packager defect, and this PR fixes it.

scripts/prepare-auto-reply-session-runtime.py writes start-auto-reply-session.command, the file the session monitor's auto-reply-host --tick starts with /bin/sh. Commit 67f4176 ("fix: stop macOS permission prompts on every host restart") merged the "exit \"$status\"\n" string literal into the end of a # comment line, so Python dropped it. The generated command ended at status=$?, and a shell script that ends with an assignment exits 0. The launcher therefore reported success whatever the watchdog returned.

Impact

Today nothing reads that exit status: the tick spawns the command and does not wait. The fix stops the launcher from hiding a failed watchdog from anything that does read it later, such as a launchctl job status or a manual run. The change reaches the host only at the next bake, which writes a new command and a new digest-pinned manifest.

Verification

  • Red first: tests.test_auto_reply_session_packager.SessionRuntimePackagerTests.test_session_command_exits_with_the_watchdog_status stages a runtime with a stub Python that exits 7, runs the generated command with /bin/sh, and expects 7. Before the fix it fails with AssertionError: 0 != 7. After the fix it passes.
  • python3.11 -m unittest tests.test_auto_reply_session_packager passes all 12 tests.
  • tests.test_auto_reply_menubar errors with frozen_menubar_missing on main too. CI documents that it cannot run on a fresh checkout.

🤖 Generated with Claude Code

67f4176 folded the `exit "$status"` line into a comment, so the
generated start-auto-reply-session.command ended at `status=$?` and
always exited 0 whatever the watchdog returned. Put the line back and
pin the behavior with a test that runs the command against a stub
Python exiting 7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@twoimo

twoimo commented Nov 23, 2026

Copy link
Copy Markdown
Owner Author

Decision: merge.

Evidence:

  • Red then green. Against the pre-fix packager, the new test fails with AssertionError: 0 != 7. With the fix, python3.11 -m unittest tests.test_auto_reply_session_packager passes all 12 tests.
  • An independent reviewer (Opus) gave PASS+NOTES. It staged the launcher under four environment variants (OPENKAKAO_ATTEST_MANUAL, OPENKAKAO_GEEKNEWS_ONLY_ROOMS, both, neither) with stub exit codes 0, 7 and 143, and all 12 runs propagated the code. No test or script pins the command bytes. The digest is computed per bake and checked against that bake's manifest. run_tick drops the child without waiting, and the plist is a StartInterval one-shot with AbandonProcessGroup, so neither the tick nor launchd sees the new exit code. The deployed runtime keeps its old file until the next bake.
  • Reviewer note: someone who opens the .command by hand in Terminal now keeps the window open after a non-zero exit under Terminal's default "close if clean" setting. That is the more useful behavior. The CHANGELOG line about Terminal closing the window predates the move to /bin/sh.
  • GitHub-hosted Actions are blocked by billing, so the zero-step check failures are infra state.

@twoimo
twoimo merged commit a6fa8d2 into main Nov 23, 2026
4 checks passed
@twoimo
twoimo deleted the fix/session-command-exit-status branch November 23, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant