Delete schema version, detect on-disk shape structurally #157

Merged
romaine-life-app[bot] merged 14 commits from refactor/delete-schema-version into main 2026-04-28 20:20:08 -07:00
romaine-life-app[bot] commented 2026-04-28 20:09:31 -07:00 (Migrated from github.com)

Closes #156.

What changed

The RunData.CurrentSchemaVersion constant, the RunData.SchemaVersion property, the LoadedRunFile.SourceSchemaVersion field, and the ISpireLensApi.CurrentSchemaVersion API surface are all gone. The version-keyed switch in RunStorage.LoadKnownSchemaFile is replaced by a structural check: a file uses the per-instance shape iff its top-level JSON has instance_numbers_by_def or def_counters (the runtime always serializes both, even when empty); the historic pooled shape predates both fields and lacks them entirely.

LoadedRunFile.IsLegacy is now !HasPerInstanceIdentity — a structural fact, not a comparison to a moving constant.

Why

#156 surfaced this as a footgun: every persisted-field PR was bumping a sequential integer that three places had to agree on (the constant, the fixture filename, the test method), and parallel PRs would all pick the same next number off a stale main. The version was actually doing nothing load-bearing — RunData is additive, the JSON deserializer fills missing fields with safe defaults, and the only real shape divergence in the entire history is v1 (pooled) vs. v2+ (per-instance), which is detectable without an integer. Removing the version eliminates the contention class entirely; the next agent adding a relic stat doesn't need to pick a number, rename a fixture, or update an Assert.Equal(N, …) literal.

Tests

  • SchemaLoadingTests keeps every fixture-load test (one per checked-in shape). Per-test SourceSchemaVersion / SchemaVersion / IsLegacy / Assert.Contains("resumable", …) assertions are dropped — they were either tautological with the structural property or broken by the new compatibility-note semantics. Each test still pins its fixture's load-bearing data fields.
  • The v999-unknown-run.json fixture and its two tests are deleted: there's no concept of an "unknown schema" anymore.
  • Per-relic test files (BagOfMarbles, Pocketwatch, Orichalcum) drop their RunData_SchemaVersion_Is… tests; one inline-JSON test in each (proving missing-field deserialization defaults) is renamed away from V17/V16/… framing but otherwise unchanged.

Docs

  • AGENTS.md "When Changing Behavior" rewritten — no more "bump RunData.CurrentSchemaVersion" step.
  • docs/sts2-runtime-primer.md "Persistence And Schema" rewritten to describe structural detection.
  • Fixtures/RunSchema/README.md reframes the existing v*--prefixed fixtures as historical snapshots and notes that new fixtures don't need a prefix.

Policy cleanup (out-of-scope but bundled per request)

  • AGENTS.md: removed "GitHub Source Of Truth" and "Scratch Workspace Guard Rails" sections.
  • docs/pull-only-workflow.md: deleted.

Risk

Low. The on-disk JSON format is unchanged (the schema_version field is silently ignored on load and not written on new saves); old run files continue to load via the structural detector. ISpireLensApi.CurrentSchemaVersion had no in-tree consumers and zero references in spire-lens-mcp, so removing it doesn't break the loader/MCP surface.

Closes #156. ## What changed The `RunData.CurrentSchemaVersion` constant, the `RunData.SchemaVersion` property, the `LoadedRunFile.SourceSchemaVersion` field, and the `ISpireLensApi.CurrentSchemaVersion` API surface are all gone. The version-keyed switch in `RunStorage.LoadKnownSchemaFile` is replaced by a structural check: a file uses the per-instance shape iff its top-level JSON has `instance_numbers_by_def` or `def_counters` (the runtime always serializes both, even when empty); the historic pooled shape predates both fields and lacks them entirely. `LoadedRunFile.IsLegacy` is now `!HasPerInstanceIdentity` — a structural fact, not a comparison to a moving constant. ## Why #156 surfaced this as a footgun: every persisted-field PR was bumping a sequential integer that three places had to agree on (the constant, the fixture filename, the test method), and parallel PRs would all pick the same next number off a stale main. The version was actually doing nothing load-bearing — `RunData` is additive, the JSON deserializer fills missing fields with safe defaults, and the only real shape divergence in the entire history is v1 (pooled) vs. v2+ (per-instance), which is detectable without an integer. Removing the version eliminates the contention class entirely; the next agent adding a relic stat doesn't need to pick a number, rename a fixture, or update an `Assert.Equal(N, …)` literal. ## Tests - `SchemaLoadingTests` keeps every fixture-load test (one per checked-in shape). Per-test `SourceSchemaVersion` / `SchemaVersion` / `IsLegacy` / `Assert.Contains("resumable", …)` assertions are dropped — they were either tautological with the structural property or broken by the new compatibility-note semantics. Each test still pins its fixture's load-bearing data fields. - The `v999-unknown-run.json` fixture and its two tests are deleted: there's no concept of an "unknown schema" anymore. - Per-relic test files (`BagOfMarbles`, `Pocketwatch`, `Orichalcum`) drop their `RunData_SchemaVersion_Is…` tests; one inline-JSON test in each (proving missing-field deserialization defaults) is renamed away from `V17/V16/…` framing but otherwise unchanged. ## Docs - `AGENTS.md` "When Changing Behavior" rewritten — no more "bump `RunData.CurrentSchemaVersion`" step. - `docs/sts2-runtime-primer.md` "Persistence And Schema" rewritten to describe structural detection. - `Fixtures/RunSchema/README.md` reframes the existing `v*-`-prefixed fixtures as historical snapshots and notes that new fixtures don't need a prefix. ## Policy cleanup (out-of-scope but bundled per request) - `AGENTS.md`: removed "GitHub Source Of Truth" and "Scratch Workspace Guard Rails" sections. - `docs/pull-only-workflow.md`: deleted. ## Risk Low. The on-disk JSON format is unchanged (the `schema_version` field is silently ignored on load and not written on new saves); old run files continue to load via the structural detector. `ISpireLensApi.CurrentSchemaVersion` had no in-tree consumers and zero references in `spire-lens-mcp`, so removing it doesn't break the loader/MCP surface.
Sign in to join this conversation.
No reviewers
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!157
No description provided.