Skip to content

feat: persist schemaVersion through the event translation pipeline - #390

Merged
Osuochasam merged 1 commit into
Open-audit-foundation:mainfrom
CollinsC1O:schemaVersion
Jul 27, 2026
Merged

feat: persist schemaVersion through the event translation pipeline#390
Osuochasam merged 1 commit into
Open-audit-foundation:mainfrom
CollinsC1O:schemaVersion

Conversation

@CollinsC1O

Copy link
Copy Markdown
Contributor

Summary

  • Add a nullable schemaVersion column (+ index) to the Event model so the blueprint version label computed by translateEvent() is no longer discarded before it reaches the database.
  • Persist schemaVersion in both the create and update branches of translateAndPersistEvent's upsert.
  • Surface schemaVersion in GET /api/v1/events responses and in the CSV/JSON/NDJSON event exports.

Why

Without a persisted schemaVersion, there's no way to query historical events by the schema version that translated them — e.g. to find events needing re-translation after a blueprint bug fix or contract upgrade.

Test plan

  • npx prisma validate / prisma generate succeed with the updated schema
  • New tests in persistence.schemaVersion.test.ts confirm schemaVersion reaches db.event.upsert for versioned and unversioned blueprints
  • Extended events/route.test.ts to assert schemaVersion is returned by the list API
  • Extended events/export/route.test.ts to assert schema_version appears in CSV, JSON, and NDJSON exports
  • Full suite run: no new failures introduced (pre-existing unrelated failures in sanitization.test.ts / stats/route.test.ts confirmed present on main too)

Closes #377

Adds schemaVersion to the Event model so operators can audit which
blueprint version translated each event, instead of it being
computed and silently discarded on every write.
@Osuochasam
Osuochasam merged commit 1ca83e5 into Open-audit-foundation:main Jul 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add schemaVersion field to Event Prisma model and persist it through the translation pipeline

2 participants