Repository navigation
Description
Task
T-082a· Milestone M7 — API · Size S · Priority P0 · Epic #7Implements FR-API-001 · FR-DSH-003
Branch
feat/t-082a-api-failure-modes-list-detail— one task = one branch = one PR (doc 32 §6)
Summary
Implement api/routers/modes.py: GET /campaigns/{id}/modes, GET/PATCH /modes/{mode_id} (label → label_is_user, status open/accepted/fixed/duplicate, If-Match), GET /campaigns/{id}/importance (SHAP, interactions, rules, CV quality).
Context / motivation
Casebook + Insights (UC-04).
Scope
In scope
POST /modes/{mode_id}:confirm-interaction→ schedules confirmations (T-074b).
Implementation guidance
- Router
api/routers/modes.py; DTOsModeSummaryDTO,ModeDetailDTO(ranges in physical units, characteristic params, rules, interaction verdict, medoid/minimal run ids, status, label,label_is_user,version) andImportanceDTO(mirrorsImportanceReport). PATCH /modes/{mode_id}body{label?: str (1..80 chars, stripped, no control chars), status?: open|accepted|fixed|duplicate, duplicate_of?: code}; requiresIf-Match; setslabel_is_user=Truewhen a label is provided; emits outboxcampaign.updated.POST /modes/{mode_id}:confirm-interaction→ConfirmationService.request(T-074b) → 202{run_ids}.GET /campaigns/{id}/importancereads the latest FULL analysis report (404 with helpful detail "Run analysis first" if none).- 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.
Acceptance criteria
- Patch with stale ETag → 412.
- Confirm-interaction returns 202 and created run ids.
- Label with HTML is stored verbatim and returned as JSON string; rendering safety is the client's (documented by test).
-
duplicatestatus requiresduplicate_of(422 otherwise). - Confirm endpoint idempotent.
- 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_modes.py.
Dependencies
Blocked by: #147 (T-081b), #137 (T-075a)
Blocks: #158 (T-084b)
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/modes.pybackend/src/roboprobe/api/schemas/modes.py
Independent file.
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-082a (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 09 §3.3 · doc 09 §4 · doc 03 §UC-04 · doc 31 §3
Requirements: FR-API-001 · FR-DSH-003 (traceability: doc 28)
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity
CampaignCreatevalidation #147report.jsonand analysis artefacts #137api/openapi.json) + oasdiff breaking-change check + schemathesis nightly #158feat(api): version mode edits, serve risk slices and persist report j…
fix(api): supply runtime Casebook and Insights data (T-110) (#311)
CodewithJha commentedon Nov 22, 2026
Shipped on main (merged PR).