Skip to content
GitHub
Integration Issues

Direct-DB qa fixture world needs an explicit System Card projection row

Direct-DB qa fixture world needs an explicit System Card projection row

Problem

The qa customer fixture (tools/dev/qa_customer_seed.py) direct-seeds a world + enshrined rule and deploys it — it never runs the publication flow. The customer System Card read resolves via:

from platform.module_active_versions mav
left join platform.world_model_card_projection wmc
on wmc.world_id = mav.world_id and wmc.world_version = mav.active_world_model_version

and returns None (→ HTTP 404) when the LEFT JOIN finds no projection row. The projection is only ever written by the consumer of the worlds.world_model_card.published event, which fires at publication — so a deploy-only fixture can never satisfy the System Card surface, and the qa dashboard-reads System Card test fails with the active-version row present.

(The failure was invisible until now because the customer qa project was skipping wholesale under the pre-SPEC-595 claim gap.)

Solution

qa_customer_seed.py::_seed_card_projection upserts a deterministic projection row (fixed authority ref …e2, fixed published_at) keyed to the fixture world/version, mirroring the producer’s upsert (PsycopgWorldModelCardProjectionRepository._UPSERT_SQL) and the reader’s extraction contract:

  • rule_set_snapshot.methodology_disclosure{restatement_count, categories}
  • evolution_history entries are kind-tagged; the customer reader keeps only kind == "version_published"
  • provenance_summary.total drives the “Active rules” count

Per the contract-shape-drift rule: the fixture mirrors the producer’s emitted shape, not a speculative one — if the producer payload changes, this seed and the reader change together.

Prevention

  • A fixture that bypasses a flow must also seed every projection that flow’s events would have produced, or the read surfaces over those projections silently regress to their empty/404 states.
  • When adding a customer read surface fed by a worlds-event projection, add its row to qa_customer_seed.py in the same change.

References

  • Gate-repair commit 283b465 (SPEC-604 merge gate)
  • Reader: src/spectral/platform/infrastructure/db/system_card_reader.py
  • Producer upsert: src/spectral/platform/infrastructure/systemcard/repositories.py