Repository navigation
Description
Task
T-084a· Milestone M7 — API · Size S · Priority P1 · Epic #7Implements FR-API-001 · FR-EXP-002 · FR-DSH-006 · FR-DSH-007
Branch
feat/t-084a-api-experiments-comparison-reports-202— one task = one branch = one PR (doc 32 §6)
Summary
Implement routers/experiments.py (GET/POST /experiments, GET /experiments/{id}, /comparison per doc 12 §3.5), routers/reports.py (POST /reports {kind,id} → 202 job; GET /reports/{id}, /content HTML) and routers/workers.py (GET /workers with heartbeat age).
Context / motivation
Trials screen, report export and Workbench.
Scope
In scope
- Report jobs run in a background executor; status persisted (reuse
analyses-like table or artefact + status row).
Implementation guidance
api/routers/experiments.py:GET/POST /experiments(create validates via the experiment planner T-102a, returns 201; execution started through the experiment runner service),GET /experiments/{id}(design cells with per-cell campaign ids and progress),GET /experiments/{id}/comparisonreturningExperimentComparisonexactly per doc 12 §3.5, produced by the same service the HTML report uses (T-079).api/routers/reports.py:POST /reports {kind: campaign|experiment, id}→ 202{report_id, status_url}; background execution in a bounded executor (api.report_workers, new, default 1); status persisted in areport_jobstable (expand-only migration0003_report_jobs);GET /reports/{id}status;GET /reports/{id}/contentstreams the HTML withContent-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; img-src data:andX-Content-Type-Options: nosniff.api/routers/workers.py:GET /workers→[{id, backend, status, current_run_id, last_heartbeat, heartbeat_age_s, version, host_hash}](hostnames hashed, TM-15).- 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).
- api.report_workers (new)
Acceptance criteria
- Comparison JSON matches doc 12 §3.5 schema.
- Report job lifecycle tested.
- Report job survives API restart (status persisted; stale RUNNING jobs marked ERROR on startup).
- Comparison JSON equals the data embedded in the HTML report for the same experiment (test).
- Hostnames never returned in clear.
- 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/api/test_experiments_reports_workers.py.
Dependencies
Blocked by: #147 (T-081b), #109 (T-102b), #140 (T-078b), #141 (T-079)
Blocks: #158 (T-084b), #183 (T-113b)
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/api/routers/experiments.pybackend/src/roboprobe/api/routers/reports.pybackend/src/roboprobe/api/routers/workers.py
Independent files.
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-084a (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 12 §2 · doc 12 §3.5 · doc 13 §3.7 · doc 13 §3.8 · doc 31 §3 · doc 33 §5
Requirements: FR-API-001 · FR-EXP-002 · FR-DSH-006 · FR-DSH-007 (traceability: doc 28)
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity
CampaignCreatevalidation #147experiment run|report(concurrency-limited) #109roboprobe report <id> -o report.html#140api/openapi.json) + oasdiff breaking-change check + schemathesis nightly #158/reports/:idroute #183feat(api): version mode edits, serve risk slices and persist report j…
CodewithJha commentedon Nov 22, 2026
Shipped on main (merged PR).
feat(api): complete risk, replay and durable reports (T-082/T-084) (#318
fix(reporting): share the API comparison with offline reports (T-084a) (
fix(api): complete worker health and report executor limits (T-084a) (#…
feat(api): start planned experiments on request (T-084a) (#327)