Skip to content

[T-081a] API: spaces and SUT-profiles routers (list, register YAML/JSON, validate, get version) #146

Closed

Description

@CodewithJha

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

Implements FR-API-001 · FR-SCN-001

Branch feat/t-081a-api-spaces-and-sut-profiles — one task = one branch = one PR (doc 32 §6)

Summary

Implement api/routers/spaces.py and api/routers/sut_profiles.py with DTOs in api/schemas/: GET/POST /spaces (YAML or JSON body, size-limited, safe-loaded), GET /spaces/{id}/versions/{version}, POST /spaces/validate, GET/POST /sut-profiles.

Context / motivation

UC-01 via API and the wizard's step 1.

Scope

In scope

  • Content-Type: application/yaml support; api.max_upload_mb limit (TM-02, TM-13).

Implementation guidance

  • Routers api/routers/spaces.py, api/routers/sut_profiles.py; DTOs api/schemas/spaces.py (SpaceSummary, SpaceVersion, SpaceValidationResult, SutProfileDTO).
  • Body parsing: application/yaml read as bytes and size-checked against api.max_upload_mb before parsing (stream with a limit; 413 if exceeded), parsed with yaml.safe_load (no custom tags), then JSON Schema (T-020a) + semantic checks via ScenarioSpace.from_mapping (T-020b). application/json follows the same path.
  • Registration is versioned: same name with different canonical content ⇒ new version; identical content ⇒ 200 with the existing version (idempotent).
  • POST /spaces/validate returns {valid, errors:[{pointer, message}], dimension, enabled_params} with 200 even when invalid (it is a query), whereas POST /spaces returns 422 SPACE_INVALID.
  • Services are shared with the CLI space validate|register|list (T-045a); the router only adapts HTTP.
  • 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.max_upload_mb

Acceptance criteria

  • Valid/invalid space upload tests (422 SPACE_INVALID with JSON-pointer errors).
  • Oversized body → 413.
  • Billion-laughs YAML rejected without memory blow-up (bounded test).
  • Re-registering identical content returns the same version.
  • OpenAPI documents both content types.
  • 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_spaces.py, test_sut_profiles.py.
  • Shared fixture fixtures/spaces/warehouse_v1.yaml.

Dependencies

Blocked by: #143 (T-080b), #33 (T-020b), #42 (T-016)

Blocks: #158 (T-084b), #161 (T-109)

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/spaces.py
  • backend/src/roboprobe/api/routers/sut_profiles.py
  • backend/src/roboprobe/api/schemas/spaces.py

One router per file — parallel with all other routers.

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-081a (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 §6 · doc 31 §3 · doc 03 §UC-01

Requirements: FR-API-001 · FR-SCN-001 (traceability: doc 28)

Activity

  1. added this to the M7 — API milestone on Nov 19, 2026
  2. added
    area:scenarioScenario space, sampling, scenario files
    area:apiREST + SSE API (FastAPI)
    priority:P0Critical path / blocks others
    taskChild task of a milestone epic
    on Nov 19, 2026
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)area:scenarioScenario space, sampling, scenario filesmilestone: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