Repository navigation
Log the active Issue context when the Runner is stopped - #193
Merged
Merged
Conversation
When systemd stops the Runner with SIGTERM, the journal now shows which Issue context was active BEFORE the generic Stopped line, and the live Pi child is shut down (no orphan Pi): - run_stopping issue=N title="..." signal=SIGTERM phase=... branch=... worktree=... session=... — before the stop, with the full scene (phase/session from the existing activity snapshot, the existing run_id prefix — no new id) - run_stopped issue=N result=interrupted — after the Pi child exits - run_stopped result=idle — a stop before the claim, no invented Issue fields The handler is installed in main() right after logging (covers pre-claim, claim, implement and delivery wait), the in-flight scene is bound at the claim and on resume, and stream_pi registers/clears the live Pi child so the handler signals exactly the child that is alive. The process exits 128+signum (143 for SIGTERM). The systemd unit description stays static. Fixes #48
This was referenced Sep 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #48
run_id=e56325e9
What
When systemd (or any caller) stops the Runner with SIGTERM, the journal
now shows which Issue context was active BEFORE the generic
Stoppedline, and the live Pi child is shut down — no orphan Pi:
A stop before claiming an Issue logs
run_stopped result=idlewithoutany invented Issue fields.
How (smallest complete change)
bootstrap_runner.py:_ACTIVE_RUNcontext bound at the claim (process_issue) and onresume (
main), cleared when the delivery ends; carriesissue/title/branch/worktree + the live Pi child. No new id: the run
id is the existing
_CURRENT_RUN_ID, phase/session come from theexisting activity snapshot of the worktree's
.pi-session(
-when absent)._handle_stop(SIGTERM) installed inmain()right after logging —covers pre-claim, claim, implement and delivery wait. Logs
run_stoppingwith the full scene, TERMs the live Pi child (onlyif alive) and waits for it, logs
run_stopped result=interrupted,exits 128+signum (143). Idle stop: one
run_stopped result=idleline.
stream_piregisters the PiPopenafter spawn and clears it afterthe child is reaped, so the handler never signals an already-exited
child.
tests/test_bootstrap_runner.py: 11 new tests, including theacceptance proof — a REAL subprocess SIGTERM test (real Runner
process, real long-running Pi-like child, real SIGTERM) asserting the
ordering (
run_stoppingbeforerun_stopped, both before theprocess is gone), every field, exit 143, no orphan child, and the
idle stop.
README.md: journal section documentsrun_stopping/run_stopped.The systemd unit description stays static (per the Issue). No timeout,
retry framework, tracing backend or second ID is added.
Verification
1239 passed(baseline 1228 + 11 new tests).TOTAL 15603 stmts, 0 miss, 2202 branches, 0 partial.test.log(run artifacts, gitignored bydesign).