Skip to content

[T-015] Contract test suites + in-memory fakes for UnitOfWork/repositories and RunQueue #65

Closed

Description

@CodewithJha

Task T-015 · Milestone M3 — Oracles + runner + store · Size M · Priority P1 · Epic #3

Implements NFR-EXT-001

Branch test/t-015-contract-test-suites-in-memory — one task = one branch = one PR (doc 32 §6)

Summary

Write the reusable repository/queue contract suites (doc 18 §4.3) and in-memory fake implementations in tests/fakes/ so application-layer code (runner, analysis, API) can be unit-tested without Postgres.

Context / motivation

Doc 34 §7: every port has a contract test suite and at least one fake. Fakes make the runner and API tests fast and deterministic, and let those tasks proceed before Postgres-specific details are final.

Scope

In scope

  • tests/contract/store/test_repository_contract.py parametrised over implementations (InMemoryUnitOfWork, SqlAlchemyUnitOfWork).
  • tests/contract/store/test_runqueue_contract.py (exactly-once, priority order, reaper semantics).
  • tests/fakes/store.py: InMemoryUnitOfWork, in-memory repos, InMemoryRunQueue (thread-safe).

Implementation guidance

  • Parametrise with a fixture uow_factory yielding each implementation; Postgres variant marked integration.
  • 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

  • Both implementations pass the same suites.
  • Fakes are used by at least one runner unit test (added later) — document usage in module docstring.
  • 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

  • The suites themselves.

Dependencies

Blocked by: #61 (T-011a)

Blocks: no other task (leaf)

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/tests/contract/store/**
  • backend/tests/fakes/store.py

Test-only files; parallel with T-011b/T-011c/T-012 (extend the suites when those merge).

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-015 (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 18 §4.3 · doc 34 §7

Requirements: NFR-EXT-001 (traceability: doc 28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:storagePostgres schema, repositories, artifactsmilestone:M3M3 — Oracles + runner + storepriority:P1Required for milestone exitsize:M1-3 daystaskChild task of a milestone epictype:testTest suites and test infrastructure

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions