Event log schema versioning #4

Closed
opened 2026-04-19 16:26:48 -07:00 by nelsong6 · 1 comment
nelsong6 commented 2026-04-19 16:26:48 -07:00 (Migrated from github.com)

Why

Per-run files will contain both aggregated stats and a full event log (Option Z decision). Once a run file is written, its schema is frozen. Later schema changes need to remain readable.

Requirements

  • Every run file includes `"schema_version": N`
  • Loader handles N, N-1, N-2, ... back to oldest known
  • Breaking-change policy: bump version, write migration function, never break old files
  • Test fixture: checked-in sample run files at each schema version so we don't regress migration

Initial schema (draft)

```json
{
"schema_version": 1,
"run_id": "uuid",
"started_at": "iso8601",
"ended_at": "iso8601",
"character": "KIN",
"ascension": 0,
"floor_reached": 12,
"outcome": "win|loss|in_progress",
"aggregates": { ... per-card aggregated stats ... },
"events": [ ... per-play event log ... ]
}
```

Blocking

MVP (M1) — we need schema_version from day one.

## Why Per-run files will contain both aggregated stats and a full event log (Option Z decision). Once a run file is written, its schema is frozen. Later schema changes need to remain readable. ## Requirements - Every run file includes \`\"schema_version\": N\` - Loader handles N, N-1, N-2, ... back to oldest known - Breaking-change policy: bump version, write migration function, never break old files - Test fixture: checked-in sample run files at each schema version so we don't regress migration ## Initial schema (draft) \`\`\`json { \"schema_version\": 1, \"run_id\": \"uuid\", \"started_at\": \"iso8601\", \"ended_at\": \"iso8601\", \"character\": \"KIN\", \"ascension\": 0, \"floor_reached\": 12, \"outcome\": \"win|loss|in_progress\", \"aggregates\": { ... per-card aggregated stats ... }, \"events\": [ ... per-play event log ... ] } \`\`\` ## Blocking MVP (M1) — we need schema_version from day one.
nelsong6 commented 2026-04-20 19:49:33 -07:00 (Migrated from github.com)

Closing this as resolved.

This is now implemented in commit e48f29dcf6562c542f0765b4b2b633cedd720995 (Implement schema-aware run loading and tests).

What shipped:

  • run files now have an explicit current-schema constant and a version-aware load path instead of blindly deserializing whatever is on disk
  • hot-reload resume only accepts the current per-instance v2 shape
  • legacy v1 pooled files are still readable as historical data, but are explicitly rejected as live resume state
  • unknown future schemas are rejected loudly instead of half-loading
  • checked-in schema fixtures now pin v1, v2, and unknown-schema file shapes
  • automated tests cover historical-load vs resumable-load behavior across those fixtures

Verification:

  • dotnet test Tests/CardUtilityStats.Core.Tests/CardUtilityStats.Core.Tests.csproj -c Debug passes (6/6)
  • manual smoke test confirmed real run data persists across F5 between combats / between rooms

Deliberate non-change:

  • this does not restore _pendingCombat across mid-combat reloads. That is a separate problem from schema versioning.
Closing this as resolved. This is now implemented in commit `e48f29dcf6562c542f0765b4b2b633cedd720995` (`Implement schema-aware run loading and tests`). What shipped: - run files now have an explicit current-schema constant and a version-aware load path instead of blindly deserializing whatever is on disk - hot-reload resume only accepts the current per-instance `v2` shape - legacy `v1` pooled files are still readable as historical data, but are explicitly rejected as live resume state - unknown future schemas are rejected loudly instead of half-loading - checked-in schema fixtures now pin `v1`, `v2`, and unknown-schema file shapes - automated tests cover historical-load vs resumable-load behavior across those fixtures Verification: - `dotnet test Tests/CardUtilityStats.Core.Tests/CardUtilityStats.Core.Tests.csproj -c Debug` passes (`6/6`) - manual smoke test confirmed real run data persists across `F5` between combats / between rooms Deliberate non-change: - this does not restore `_pendingCombat` across mid-combat reloads. That is a separate problem from schema versioning.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/spirelens#4
No description provided.