Skip to content

[T-107] Seeded test datasets: fixtures/db/seed_small.sql and scripts/seed_demo.py (60 runs, 3 modes) #159

Closed

Description

@CodewithJha

Task T-107 · Milestone M7 — API · Size S · Priority P1 · Epic #7

Implements NFR-MNT-001

Branch test/t-107-seeded-test-datasets-and-60 — one task = one branch = one PR (doc 32 §6)

Summary

Produce a deterministic small dataset (1 campaign, 60 runs, 3 modes, risk map, experiment) used by API tests, MSW fixtures and Playwright E2E, plus a large synthetic generator (10 000 runs) for performance tests.

Context / motivation

Doc 18 §5: shared fixtures; prevents each UI/API task from inventing its own data.

Scope

In scope

  • scripts/seed_demo.py --size small|large (via services, not raw SQL) + exported seed_small.sql.
  • MSW JSON fixtures exported from the seeded API (web/src/test/fixtures/*.json).

Implementation guidance

  • scripts/seed_demo.py --size small|large --seed 20261119 --database-url ... creates data through application services (space register → campaign create → inline k2d campaign → analysis → tiny experiment) so seeds always respect invariants; large uses the benchmark backend to produce 10 000 runs quickly.
  • small: 1 campaign, 60 runs, 3 modes, 1 risk map, 1 analysis, 1 tiny experiment; export with pg_dump --data-only --column-inserts into backend/tests/fixtures/db/seed_small.sql (doc 18 §5) plus seed_small_artifacts.tar.zst (traces for 3 medoid runs only, ≤ 2 MB).
  • MSW fixtures: scripts/export_web_fixtures.py calls the seeded API and writes web/src/test/fixtures/*.json (campaigns, runs page, run detail, modes, importance, risk slice, comparison); regenerate whenever OpenAPI changes.
  • Loading helper tests/fixtures/db/load_seed.py, used by API tests, E2E global setup and the perf job.
  • 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

  • Seed loads in < 10 s; deterministic.
  • Fixtures validate against OpenAPI DTOs.
  • Fixtures regenerate deterministically (hash compare).
  • Artefact tarball ≤ 2 MB.
  • 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/integration/test_seed_data.py.

Dependencies

Blocked by: #137 (T-075a)

Blocks: #160 (T-106), #186 (T-117)

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:

  • scripts/seed_demo.py
  • backend/tests/fixtures/db/seed_small.sql
  • web/src/test/fixtures/**

Test data only.

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-107 (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 §5 · doc 18 §4.10 · doc 12 §3.3

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

Activity

  1. added this to the M7 — API milestone on Nov 19, 2026
  2. added
    type:testTest suites and test infrastructure
    area:storagePostgres schema, repositories, artifacts
    area:apiREST + SSE API (FastAPI)
    priority:P1Required for milestone exit
    taskChild task of a milestone epic
    on Nov 19, 2026
  3. added a commit that references this issue on Nov 22, 2026
    6ce7973
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:dashboardReact web dashboardarea:storagePostgres schema, repositories, artifactsmilestone:M7M7 — APIpriority:P1Required for milestone exitsize:S<= 1 daytaskChild task of a milestone epictype:testTest suites and test infrastructure

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions