Repository navigation
Description
Task
T-081a· Milestone M7 — API · Size S · Priority P0 · Epic #7Implements 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/yamlsupport;api.max_upload_mblimit (TM-02, TM-13).
Implementation guidance
- Routers
api/routers/spaces.py,api/routers/sut_profiles.py; DTOsapi/schemas/spaces.py(SpaceSummary,SpaceVersion,SpaceValidationResult,SutProfileDTO). - Body parsing:
application/yamlread as bytes and size-checked againstapi.max_upload_mbbefore parsing (stream with a limit; 413 if exceeded), parsed withyaml.safe_load(no custom tags), then JSON Schema (T-020a) + semantic checks viaScenarioSpace.from_mapping(T-020b).application/jsonfollows the same path. - Registration is versioned: same
namewith different canonical content ⇒ newversion; identical content ⇒ 200 with the existing version (idempotent). POST /spaces/validatereturns{valid, errors:[{pointer, message}], dimension, enabled_params}with 200 even when invalid (it is a query), whereasPOST /spacesreturns 422SPACE_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_INVALIDwith 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
Unreleasedupdated 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.pybackend/src/roboprobe/api/routers/sut_profiles.pybackend/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)
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity
warehouse_v1.yaml#33configs/sut_profiles/(k2d default + TB4 Nav2 default) #42api/openapi.json) + oasdiff breaking-change check + schemathesis nightly #158feat(api): complete catalogue uploads and validation (T-081a)