Repository navigation
Description
Task
T-012· Milestone M3 — Oracles + runner + store · Size M · Priority P0 · Epic #3Implements FR-RUN-001 · FR-RUN-002 · NFR-REL-001
Branch
feat/t-012-runqueue-atomic-claim-with-skip— one task = one branch = one PR (doc 32 §6)
Summary
Implement PostgresRunQueue (doc 05 §13 port RunQueue) with the exact claim and reap statements of doc 11 §4: backend-filtered, priority-ordered, exactly-once claims and heartbeat-based re-queueing.
Context / motivation
This is the heart of FR-RUN-001's acceptance criterion: 4 workers × 100 runs, every run executes exactly once.
Scope
In scope
- Port
RunQueueinbackend/src/roboprobe/runner/queue.py(Protocol:claim(worker_id, backend) -> ClaimedRun | None,mark_running,mark_evaluating,complete(run_id, outcome),fail(run_id, infra_error),reap(now, heartbeat_timeout_s, max_attempts) -> int,depth(backend) -> int). - Adapter
backend/src/roboprobe/store/queue_pg.pywith the SQL from doc 11 §4 (claim joins campaignstatus='RUNNING'; reap uses worker heartbeat). - State transitions follow doc 11 §5 run state machine; illegal transitions raise
ConflictError. - Emits
run.started/run.finishedoutbox events (via T-011c).
Out of scope
- Reaper scheduling loop in orchestrator (T-042a)
- Worker process (T-040a)
Implementation guidance
- Use
text()SQL for claim/reap to keep the exact semantics; return a typedClaimedRun(run id, campaign id, scenario, seed, attempt, timeouts). Priority: lower = sooner (manual/confirm runs = 10). - 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).
runner.heartbeat_timeout_srunner.max_attempts
Acceptance criteria
- Integration test: 4 concurrent claimers × 100 runs → each run claimed exactly once, none lost.
- Priority ordering respected; only runs of RUNNING campaigns and matching backend are claimed.
- Reap: runs of a stale worker return to PENDING while
attempt < max_attempts, else ERROR + verdict INVALID (fake clock / explicitnow). - Queue contract tests (T-015) pass.
- 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
tests/integration/store/test_queue_exactly_once.py(threads/processes)tests/integration/store/test_reap.py.
Dependencies
Blocked by: #61 (T-011a), #62 (T-011b)
Blocks: #80 (T-040a), #82 (T-042a)
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/queue.pybackend/src/roboprobe/store/queue_pg.pybackend/tests/integration/store/test_queue_*.py
Owns queue modules only.
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-012 (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 11 §4 · doc 11 §5 · doc 05 §5.3 · doc 05 §13 · ADR-0007 · doc 02 §3.3
Requirements: FR-RUN-001 · FR-RUN-002 · NFR-REL-001 (traceability: doc 28)
External:
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity