Repository navigation
Description
Task
T-040c· Milestone M3 — Oracles + runner + store · Size S · Priority P1 · Epic #3Implements FR-RUN-002 · NFR-REL-001
Branch
feat/t-040c-worker-graceful-drain-on-sigterm— one task = one branch = one PR (doc 32 §6)
Summary
Implement DRAINING on SIGTERM (finish current run within worker.drain_timeout_s, claim no more), cooperative cancellation of runs whose campaign was cancelled, and a chaos test that SIGKILLs a worker mid-run and verifies re-queue + completion by another worker.
Context / motivation
Doc 18 §4.5: worker kill → re-queue (chaos fixture sends SIGKILL). This proves NFR-REL-001.
Scope
In scope
- Signal handlers in
runner/worker.pymain loop;backend.cancel()on campaign cancel (poll run status during episode via progress callback). tests/integration/runner/test_chaos_worker_kill.pyusing subprocess workers.
Implementation guidance
- Use a fake/short heartbeat timeout in the chaos test via settings overrides.
- Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff
PLR2004); public APIs typed (mypy strict) and documented.
Configuration keys
From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).
worker.drain_timeout_s
Acceptance criteria
- SIGTERM: current run finishes, worker exits 0, no new claims.
- SIGKILL: run re-queued by reaper and completed by another worker; no duplicates.
- Cancelled campaign stops running episodes within 10 s.
- Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
- Docs, config reference and CHANGELOG
Unreleasedupdated where behaviour, keys or interfaces changed. - Definition of Done (doc 32 §3) satisfied.
Tests required
- Chaos integration test.
Dependencies
Blocked by: #81 (T-040b), #82 (T-042a)
Blocks: no other task (leaf)
Parallelization notes
Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:
- backend/src/roboprobe/runner/worker.py (signals)
backend/tests/integration/runner/test_chaos_worker_kill.py
After T-040b.
Definition of Done
Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-040c (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.
References
Design docs: doc 14 §5 · doc 18 §4.5 · doc 02 §5
Requirements: FR-RUN-002 · NFR-REL-001 (traceability: doc 28)
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity