Skip to content

[T-082a] API: failure modes (list/detail/patch label & status) and importance endpoint #151

Closed

Description

@CodewithJha

Task T-082a · Milestone M7 — API · Size S · Priority P0 · Epic #7

Implements 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; DTOs ModeSummaryDTO, ModeDetailDTO (ranges in physical units, characteristic params, rules, interaction verdict, medoid/minimal run ids, status, label, label_is_user, version) and ImportanceDTO (mirrors ImportanceReport).
  • PATCH /modes/{mode_id} body {label?: str (1..80 chars, stripped, no control chars), status?: open|accepted|fixed|duplicate, duplicate_of?: code}; requires If-Match; sets label_is_user=True when a label is provided; emits outbox campaign.updated.
  • POST /modes/{mode_id}:confirm-interaction → ConfirmationService.request (T-074b) → 202 {run_ids}.
  • GET /campaigns/{id}/importance reads 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).
  • duplicate status requires duplicate_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 Unreleased updated 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.py
  • backend/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)

Activity

  1. added this to the M7 — API milestone on Nov 19, 2026
  2. added
    area:analysisFailure clustering, SHAP, rules, interactions
    area:apiREST + SSE API (FastAPI)
    priority:P0Critical path / blocks others
    taskChild task of a milestone epic
    on Nov 19, 2026
  3. CodewithJha commented on Nov 22, 2026

    @CodewithJha
    OwnerAuthor

    Shipped on main (merged PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:analysisFailure clustering, SHAP, rules, interactionsarea:apiREST + SSE API (FastAPI)milestone:M7M7 — APIpriority:P0Critical path / blocks otherssize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions