Repository navigation
Description
Task
T-011a· Milestone M3 — Oracles + runner + store · Size M · Priority P0 · Epic #3Implements FR-STO-001 · NFR-EXT-001
Branch
feat/t-011a-unitofwork-repositories-spaces-sut-profiles— one task = one branch = one PR (doc 32 §6)
Summary
Implement the Repository + Unit-of-Work pattern of doc 05 §9 for the campaign-execution aggregates, returning core.types/DTO models (never ORM objects).
Context / motivation
The runner, API and analysis all persist through these interfaces. Defining them as Protocols (ports) with a SQLAlchemy implementation keeps the store swappable (doc 11 §1).
Scope
In scope
- Ports:
backend/src/roboprobe/store/ports.py—UnitOfWorkProtocol and repository Protocols (SpaceRepo,SutProfileRepo,CampaignRepo,RunRepo, …) with pre/post-condition docstrings. backend/src/roboprobe/store/uow.py:SqlAlchemyUnitOfWork(session_factory)context manager withcommit/rollback.store/repositories/{spaces,sut_profiles,campaigns,runs,oracle_results,strategy_states}.py.- Record models for persistence boundaries (
CampaignRecord,RunRecord, …) instore/records.py(frozen pydantic). - Keyset pagination helper
(limit, cursor) -> Page[T]used by list methods (doc 12 §1).
Out of scope
- Modes/risk/analyses/experiments/workers/artifacts repos (T-011b)
- Outbox events & NOTIFY (T-011c)
- Queue claim/reap (T-012)
Implementation guidance
RunRepo.insert_batch(runs)must rely on the unique(campaign_id, ordinal, repeat_index)constraint so orchestrator ticks are idempotent (doc 34 §8).RunRepo.history(campaign_id) -> list[Observation](non-INVALID first-class) is used by strategies — make it efficient (single query, ordered by ordinal).- Sessions are never shared across threads (doc 34 §8): UoW creates a session per
withblock. - Pool size/statement timeout from
DatabaseSettings. - 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).
database.urldatabase.pool_sizedatabase.statement_timeout_ms
Acceptance criteria
- Repositories return immutable records, never ORM instances (type-checked).
- UoW rolls back on exception and commits on success.
- Keyset pagination stable under concurrent inserts.
- Repository contract tests (T-015) pass against this implementation.
- 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/integration/store/test_repositories_campaign_run.py.
Dependencies
Blocked by: #60 (T-010b)
Blocks: #62 (T-011b), #63 (T-011c), #64 (T-012), #65 (T-015), #85 (T-041a), #93 (T-039b), #89 (T-045a), #104 (T-100a), #105 (T-100b), #126 (T-070a), #142 (T-080a)
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/store/ports.pybackend/src/roboprobe/store/uow.pybackend/src/roboprobe/store/records.pybackend/src/roboprobe/store/repositories/{spaces,sut_profiles,campaigns,runs,oracle_results,strategy_states}.py
T-011b adds sibling repository modules and appends attributes to the UoW; coordinate by merging T-011a first.
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-011a (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 05 §9 · doc 11 §1 · doc 11 §4 · doc 34 §4 · doc 34 §7 · doc 34 §8 · doc 12 §1
Requirements: FR-STO-001 · NFR-EXT-001 (traceability: doc 28)
External:
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity
0001_initialmigration with up/down/up test #60db upgradeandspace validate|register|list#89roboprobe oracle reevaluate <run_id>: offline re-judgement from stored traces #93/meta,/metrics, request logging #142