Skip to content

Stamp a literal version in fromV3, not the moving constant - #53

Closed
jellologic wants to merge 1 commit into
mainfrom
fix/migrate-version-stamp
Closed

Stamp a literal version in fromV3, not the moving constant#53
jellologic wants to merge 1 commit into
mainfrom
fix/migrate-version-stamp

Conversation

@jellologic

Copy link
Copy Markdown
Owner

Closes #37.

fromV3 stamped version: SUPPORTED_VERSION. migrate() dispatches on that number, so a rung stamping the current version makes the ladder skip every step above it — the draft claims to be current while carrying the older shape.

fromV1 and fromV2 both stamp literals and both carry a comment warning about this. The v2 one says "the moment SUPPORTED_VERSION became 4 this was the bug it predicted." It then happened one rung further up.

Why the tests come in two kinds

While SUPPORTED_VERSION is 4, SUPPORTED_VERSION and 4 produce identical output, so no behavioural test can fail on this today. That is also why it survived review.

  • Per-rung assertions that each fromVN returns N+1, written against literals. Against the constant they would have passed while the bug was present. Future guards; cannot fail now.
  • A source-level guard, in the spirit of test/architecture.test.ts, asserting no rung stamps a non-literal. This one does fail on the unfixed code — verified by reintroducing the bug:
AssertionError: fromV3 must stamp a literal version, not SUPPORTED_VERSION —
migrate() dispatches on this number and a moving constant makes the ladder skip rungs

Each rung is fed its own minimal input rather than the previous rung's output, so the tests need no widening cast.

811 tests green.

`fromV3` stamped `version: SUPPORTED_VERSION`. `migrate()` dispatches on that
number, so a rung stamping the CURRENT version makes the ladder skip every step
above it: the draft claims to be current while still carrying the older shape.

`fromV1` and `fromV2` both stamp literals and both carry a comment warning about
exactly this, the second of which says "the moment SUPPORTED_VERSION became 4
this was the bug it predicted." It then happened one rung further up.

Latent today and invisible for a specific reason: while SUPPORTED_VERSION is 4,
`SUPPORTED_VERSION` and `4` produce identical output. It becomes wrong the moment
a v5 exists, at which point a v3 config is marked v5 while holding v4 shape — and
`fs-config-store` would write that back.

That same property means a behavioural test cannot fail on it today. The added
tests are therefore two kinds:

- Per-rung assertions that each `fromVN` returns N+1, written against literals
  rather than SUPPORTED_VERSION. Against the constant they would have passed
  while the bug was present, which is how it survived review. These are future
  guards and cannot fail now.
- A source-level guard, in the spirit of test/architecture.test.ts, asserting no
  rung stamps a non-literal. This one does fail on the unfixed code, verified by
  reintroducing the bug.

Each rung is fed its own minimal input rather than the previous rung's output, so
the tests need no widening cast.

Refs #37

Signed-off-by: jellologic <31935831+jellologic@users.noreply.github.com>
@jellologic jellologic closed this Sep 4, 2026
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.

Fix a latent version-stamp bug in the migration ladder

1 participant