Skip to content

[T-026] Regression scenario files: export/import (schemas/scenario.schema.json) #39

Closed

Description

@CodewithJha

Task T-026 · Milestone M2 — Scenario + kinematic2d · Size S · Priority P1 · Epic #2

Implements FR-SCN-008 · PR-08

Branch feat/t-026-regression-scenario-files-export-import — one task = one branch = one PR (doc 32 §6)

Summary

Implement scenario/regression.py: build a standalone regression YAML from a scenario + provenance (doc 06 §6) and load it back into a Scenario with expect block.

Context / motivation

UC-07 / journey J2: developers turn discovered failures into regression tests for their robot's CI (doc 14 §9).

Scope

In scope

  • export_regression(scenario, seed, provenance, expect) -> str and load_regression(path) -> RegressionScenario.
  • Space-version mismatch → explicit error suggesting space upgrade.

Out of scope

  • CLI scenario export / run --scenario (T-045c)
  • API scenario.yaml endpoint (T-082c)

Implementation guidance

  • Validate against scenario.schema.json; preserve key order for readability (export uses a fixed key order).
  • 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

  • Round-trip export → load gives equal Scenario (hash equal).
  • File validates against the schema.
  • 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/unit/scenario/test_regression.py.

Dependencies

Blocked by: #37 (T-024), #32 (T-020a)

Blocks: #96 (T-045c), #153 (T-082c)

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/scenario/regression.py

Independent module.

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-026 (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 06 §6 · doc 14 §9 · doc 03 §UC-07 · doc 02 §3.1

Requirements: FR-SCN-008 · PR-08 (traceability: doc 28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:scenarioScenario space, sampling, scenario filesmilestone:M2M2 — Scenario + kinematic2dpriority:P1Required for milestone exitsize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions