worker: dump the stack when a dispatched kanban worker dies (#1387) #2788

Open
hermes wants to merge 2 commits from kb/NCFG-worker-faulthandler into main
Collaborator

Closes the diagnosability half of nix-config#1387.

Six dispatched workers were settled interrupted in one 22 s window on vpn 2026-11-20. The one examined (run 2113, pid 2565133) died of SIGABRT; systemd-coredump wrote a core (ANOM_ABEND sig=6) that held no parseable traceback, so the death could not be attributed at all.

The gateway enables faulthandler for itself (gateway/run_startup.py); a dispatched worker is a separate python -m hermes_cli.kanban_worker_client process and inherited none of it.

Change: main() installs faulthandler (fatal signals, all threads) and registers SIGTERM chained. The worker's stderr is the per-task log the dispatcher opened before spawn, so a dump lands beside the run.

chain=True is load-bearing — measured: an unchained handler dumps and returns, so the worker survives the SIGTERM the scope reaper and enforce_max_runtime send.

Why in the existing overlay: one PYTHONPATH entry per package; a separate derivation carrying hermes_cli would shadow the other five fixes.

Gate: .forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh, wired into nix-build-check.yml, four arms against the built package vpn loads:

  • patched/abort: SIGABRT → ≥1 Python frame + Fatal Python error: Aborted, still exits 134
  • patched/term: SIGTERM → dumps AND still dies of the signal (rc=-15)
  • mutant/term (chain=True removed): REQUIRED to survive
  • upstream/abort (entry dropped): no installer, no dump

Locally verified against a facsimile of the built package: green = PASS, unpatched module = 8 FAILs.

Closes the diagnosability half of nix-config#1387. Six dispatched workers were settled `interrupted` in one 22 s window on vpn 2026-11-20. The one examined (run 2113, pid 2565133) died of SIGABRT; systemd-coredump wrote a core (`ANOM_ABEND sig=6`) that held no parseable traceback, so the death could not be attributed at all. The gateway enables faulthandler for itself (`gateway/run_startup.py`); a dispatched worker is a separate `python -m hermes_cli.kanban_worker_client` process and inherited none of it. **Change**: `main()` installs faulthandler (fatal signals, all threads) and registers SIGTERM chained. The worker's stderr is the per-task log the dispatcher opened before spawn, so a dump lands beside the run. `chain=True` is load-bearing — measured: an unchained handler dumps and *returns*, so the worker survives the SIGTERM the scope reaper and `enforce_max_runtime` send. **Why in the existing overlay**: one PYTHONPATH entry per package; a separate derivation carrying `hermes_cli` would shadow the other five fixes. **Gate**: `.forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh`, wired into `nix-build-check.yml`, four arms against the built package vpn loads: - patched/abort: SIGABRT → ≥1 Python frame + `Fatal Python error: Aborted`, still exits 134 - patched/term: SIGTERM → dumps AND still dies of the signal (rc=-15) - mutant/term (chain=True removed): REQUIRED to survive - upstream/abort (entry dropped): no installer, no dump Locally verified against a facsimile of the built package: green = PASS, unpatched module = 8 FAILs.
worker: dump the stack when a dispatched kanban worker dies
Some checks failed
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 6s
PR base guard / Base drift / conflict check (pull_request) Successful in 8s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 11s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 8s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 5s
Secret Scan / gitleaks scan (pull_request) Successful in 13s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Failing after 19s
foremerge intent (advisory) 3 of 4 changed path(s) have no live foremerge intent: .forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh, patches/hermes-agent-kanban-worker-faulthandler.patch, overlays/hermes-agent-kanban-worktree-base.nix
Repo Gates / Repo gates (script-only battery) (pull_request) Has been cancelled
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m13s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 11s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Failing after 1m58s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 58s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 26s
NixOS Build Check / Gate summary (pull_request) Failing after 1s
050c8eb87e
A dispatched worker (`python -m hermes_cli.kanban_worker_client`) got none of
the gateway's faulthandler setup: gateway/run_startup.py enables it for the
gateway process only. Measured on vpn 2026-11-20 — six workers were settled
`interrupted` inside one 22 s window, and the one that was examined (run 2113,
pid 2565133) died of SIGABRT with a core that held no parseable traceback. The
crash loop was diagnosable only as "six workers vanished".

The worker's main() now installs faulthandler (SIGSEGV/SIGABRT/SIGBUS/SIGFPE/
SIGILL, every thread) and registers SIGTERM chained, so the scope reaper's and
enforce_max_runtime's kill also leaves a stack. stderr in a worker is the
per-task log the dispatcher opened before spawn, so the dump lands beside the
run it belongs to. chain=True is load-bearing: an unchained handler dumps and
returns, i.e. the worker would ignore the SIGTERM it was sent.

The patch rides the existing hermes_cli overlay (one PYTHONPATH entry per
package — a second derivation would shadow the other five fixes) and its gate
carries two mutation arms: the unpatched PYTHONPATH entry, and the shipped file
with chain=True removed, which is required to SURVIVE the kill.
Author
Collaborator

foremerge intent coverage (advisory) — 3 of 4 changed path(s) in ymrtech/nix-config#2788 have no live foremerge intent:

  • .forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh
  • patches/hermes-agent-kanban-worker-faulthandler.patch
  • overlays/hermes-agent-kanban-worktree-base.nix

Coverage was decided by reading the repo's foremerge ledger (9 in-flight intent(s) considered) against this PR's changed paths — no branch or session name is involved, so a force-push does not change the answer. Paths that legitimately need no claim (docs, .md, flake.lock) are excluded.

This is advisory and does not block the merge. To clear it, publish intent for the paths above (foremerge intent publish --agent <your agent id> --task <task> --summary <what and why> --scope file:<path>=modify), or ignore it if the work genuinely collides with nobody.

**foremerge intent coverage (advisory)** — 3 of 4 changed path(s) in ymrtech/nix-config#2788 have no live foremerge intent: - `.forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh` - `patches/hermes-agent-kanban-worker-faulthandler.patch` - `overlays/hermes-agent-kanban-worktree-base.nix` Coverage was decided by reading the repo's foremerge ledger (9 in-flight intent(s) considered) against this PR's changed paths — no branch or session name is involved, so a force-push does not change the answer. Paths that legitimately need no claim (docs, `.md`, `flake.lock`) are excluded. This is advisory and does **not** block the merge. To clear it, publish intent for the paths above (`foremerge intent publish --agent <your agent id> --task <task> --summary <what and why> --scope file:<path>=modify`), or ignore it if the work genuinely collides with nobody.
hermes force-pushed kb/NCFG-worker-faulthandler from 050c8eb87e
Some checks failed
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 6s
PR base guard / Base drift / conflict check (pull_request) Successful in 8s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 11s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 8s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 5s
Secret Scan / gitleaks scan (pull_request) Successful in 13s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Failing after 19s
foremerge intent (advisory) 3 of 4 changed path(s) have no live foremerge intent: .forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh, patches/hermes-agent-kanban-worker-faulthandler.patch, overlays/hermes-agent-kanban-worktree-base.nix
Repo Gates / Repo gates (script-only battery) (pull_request) Has been cancelled
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m13s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 11s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Failing after 1m58s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 58s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 26s
NixOS Build Check / Gate summary (pull_request) Failing after 1s
to adf5282597
Some checks failed
PR base guard / Base drift / conflict check (pull_request) Successful in 4s
Secret Scan / gitleaks scan (pull_request) Successful in 11s
Repo Gates / Repo gates (script-only battery) (pull_request) Has been cancelled
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 57s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 16s
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 6s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 2s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m34s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m14s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 3m20s
NixOS Build Check / Gate summary (pull_request) Successful in 1s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 1m4s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 24s
2026-11-20 15:16:39 -06:00
Compare
hermes force-pushed kb/NCFG-worker-faulthandler from adf5282597
Some checks failed
PR base guard / Base drift / conflict check (pull_request) Successful in 4s
Secret Scan / gitleaks scan (pull_request) Successful in 11s
Repo Gates / Repo gates (script-only battery) (pull_request) Has been cancelled
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 57s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 16s
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 6s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 2s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m34s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m14s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 3m20s
NixOS Build Check / Gate summary (pull_request) Successful in 1s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 1m4s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 24s
to 4827f8e6b3
Some checks failed
PR base guard / Base drift / conflict check (pull_request) Successful in 5s
Secret Scan / gitleaks scan (pull_request) Successful in 17s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 15s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 9s
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 5s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 3s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 3s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Failing after 1m21s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 4s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 4s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m13s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 3m8s
NixOS Build Check / Gate summary (pull_request) Failing after 2s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 55s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 26s
Repo Gates / Repo gates (script-only battery) (pull_request) Failing after 3m28s
foremerge intent (advisory) 3 of 4 changed path(s) have no live foremerge intent: .forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh, patches/hermes-agent-kanban-worker-faulthandler.patch, overlays/hermes-agent-kanban-worktree-base.nix
2026-11-20 15:17:17 -06:00
Compare
tests: make the worker faulthandler gate pass its own lints and its own cleanup
Some checks reported warnings
PR base guard / Base drift / conflict check (pull_request) Successful in 7s
Secret Scan / gitleaks scan (pull_request) Successful in 15s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 33s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 7s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m24s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 2m49s
NixOS Build Check / Gate summary (pull_request) Successful in 0s
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 7s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 4s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 3s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 4s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m14s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 6s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 54s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 24s
Repo Gates / Repo gates (script-only battery) (pull_request) Successful in 4m0s
foremerge intent (advisory) 4 of 5 changed path(s) have no live foremerge intent: .forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh, .forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh, patches/hermes-agent-kanban-worker-faulthandler.patch, overlays/hermes...
b46f65af4b
Two reds on the first real run, neither of them the patch:

* the repo's pipefail guard reds a pipeline into `grep -q` — capture the
  three lines after `def main():` and match them with `case` instead.
  Verified both ways: the patched module matches, the sealed venv's does not.
* the EXIT trap failed with `rm: cannot remove '/tmp/tmp.XXXX': Directory
  not empty` and, under `set -euo pipefail`, that exit 1 landed AFTER every
  assertion had already passed. A killed worker can still be writing into
  the temp home when the trap fires, so retry the removal and keep cleanup
  out of the verdict.
Some checks reported warnings
PR base guard / Base drift / conflict check (pull_request) Successful in 7s
Required
Details
Secret Scan / gitleaks scan (pull_request) Successful in 15s
Required
Details
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 33s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 7s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m24s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 2m49s
NixOS Build Check / Gate summary (pull_request) Successful in 0s
Required
Details
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 7s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 4s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 3s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 4s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m14s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 6s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 54s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 24s
Repo Gates / Repo gates (script-only battery) (pull_request) Successful in 4m0s
foremerge intent (advisory) 4 of 5 changed path(s) have no live foremerge intent: .forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh, .forgejo/tests/test-hermes-agent-kanban-worker-faulthandler.sh, patches/hermes-agent-kanban-worker-faulthandler.patch, overlays/hermes...
This pull request has changes conflicting with the target branch.
  • overlays/hermes-agent-kanban-worktree-base.nix
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin kb/NCFG-worker-faulthandler:kb/NCFG-worker-faulthandler
git switch kb/NCFG-worker-faulthandler
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ymrtech/nix-config!2788
No description provided.