Skip to content

fix(batch): workers outlive the watcher's systemd tick; ended workers are reaped - #593

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/watcher-workers-survive-systemd-tick
Nov 6, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/watcher-workers-survive-systemd-tick

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Summary

Pilot live shift 1 (2026-11-06, PyAutoLabs/PyAutoMind#542) lost all 3 workers about 30 seconds after spawn, with no transcripts and 0 tokens. Two bugs:

  1. systemd killed them. The watcher unit is Type=oneshot with the default KillMode=control-group. The first claude --bg starts the background-session daemon inside the tick's cgroup, so when the tick exits, systemd kills the daemon and every worker. Fixed with KillMode=process in the unit template.
  2. The watcher read failed as alive and held the dead workers' leases for 40 minutes. Now any claude agents state in _digest.ENDED_STATES (failed, killed, error, …) is a crash at once (no lease grace, since an ended session can never write a late .done): re-dispatched once, then abandoned. An ended close-out is refused. batch watch shows ended (failed, …).

Closes #592

API Changes

_digest.ENDED_STATES (_orchestrator.ENDED_STATES is the same object). The unit template changed: installed copies must be copied again (daemon-reload).

Witness

  • Real systemd check: a transient Type=oneshot unit spawning one claude --bg haiku probe:
    • KillMode=control-group (old default): killmode-probe-control-group failed immediately after the unit exits.
    • KillMode=process (fix): killmode-probe-process working, later done.
  • Control: with the old _orchestrator.py, the new reaping tests fail (5 failed); with the fix they pass.
  • New tests: an ended worker (failed/killed/error) is reaped at once inside its grace and re-dispatched, with tokens counted; an ended worker with its .done still counts as done; a failed close-out is refused; the unit template carries KillMode=process; batch watch shows ended.
  • Full Brain suite: 1633 passed, 1 skipped. Tenant firewall: OK.
  • Heart STALE, acknowledged by the human at ship.

Tier: glance — merge mode: auto-merge on green with Witness PASS, post-merge summary.

🤖 Generated with Claude Code

… are reaped (#592)

KillMode=process on the oneshot unit: under the default control-group,
systemd killed the claude --bg daemon (and every worker) when the tick
exited, as happened in pilot live shift 1. claude agents states in
_digest.ENDED_STATES (failed, killed, error, ...) are now a crash at once
(re-dispatched once) or a refused close-out, never read as alive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit a55960c into main Nov 6, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the feature/watcher-workers-survive-systemd-tick branch November 6, 2026 11:05
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.

fix(batch): live workers die with the watcher's systemd tick; failed workers never reaped

1 participant