Skip to content

[T-082c] API: :analyze, run :replay, scenario.yaml export, campaign bundle export #153

Closed

Description

@CodewithJha

Task T-082c · Milestone M7 — API · Size S · Priority P1 · Epic #7

Implements FR-ANA-006 · FR-REP-001 · FR-SCN-008 · FR-STO-003

Branch feat/t-082c-api-run-export-campaign-bundle — one task = one branch = one PR (doc 32 §6)

Summary

Implement action endpoints: POST /campaigns/{id}:analyze, POST /runs/{id}:replay {repeats, fresh_seeds}, GET /runs/{id}/scenario.yaml, and an export endpoint for bundles (202 + job) when T-014 is available.

Context / motivation

Every dashboard action must map to a service shared with the CLI (FR-CLI-001).

Scope

In scope

  • Thin routers calling existing services.

Implementation guidance

  • Router api/routers/actions.py hosting command-style endpoints that wrap existing services: POST /campaigns/{id}:analyze → AnalysisJobRunner.request(kind) (202 {analysis_id}); POST /runs/{id}:replay {repeats ≤ runner.max_manual_repeats, fresh_seeds: bool} → replay service (T-044) (202 {run_ids}); GET /runs/{id}/scenario.yaml → regression export (T-026) with Content-Type: application/yaml and Content-Disposition.
  • Bundle export (FR-STO-003): POST /campaigns/{id}:export → 202 job using T-014; status via the report-jobs mechanism from T-084a (reuse, don't duplicate).
  • Note: doc 05 §10 lists the minimum router set; splitting commands into actions.py / campaign_commands.py is deliberate so each file has a single owner for parallel work — record this as a one-line note in doc 05 §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.

Acceptance criteria

  • Replay creates runs with replay_of; scenario.yaml validates against schema.
  • Exported scenario.yaml validates against schemas/scenario.schema.json and re-imports to the same scenario hash.
  • Replay runs carry replay_of and deterministic seeds unless fresh_seeds.
  • 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_actions.py.

Dependencies

Blocked by: #149 (T-081d), #138 (T-075b), #92 (T-044), #39 (T-026)

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/actions.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-082c (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 14 §7 · doc 06 §6 · doc 05 §10

Requirements: FR-ANA-006 · FR-REP-001 · FR-SCN-008 · FR-STO-003 (traceability: doc 28)

Activity

  1. added this to the M7 — API milestone on Nov 19, 2026
  2. 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:apiREST + SSE API (FastAPI)milestone:M7M7 — APIpriority:P1Required for milestone exitsize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions