Skip to content

fix(control-plane): give the snapshot schema version one owner - #782

Merged
zzylol merged 1 commit into
mainfrom
fix/single-snapshot-version
Sep 28, 2026
Merged

zzylol merged 1 commit into
mainfrom
fix/single-snapshot-version

Conversation

@zzylol

@zzylol zzylol commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

The drift

The workload-snapshot schema version was restated at every site that produces or consumes a snapshot: the backend's check, discover_snapshot.py, calibrate.py, planned_run.py, two shipped example snapshots, and their tests. Nothing tied those declarations together.

They drifted. On the #728 stack, two tools still overwrote the version with a stale literal 2 while the backend had moved to 3, so a snapshot built from a current template was relabelled to an old version and then rejected by the very backend that ships that template:

Snapshot("unsupported workload snapshot version 2; only version 3 is supported")

Nothing failed at the point the wrong version was written. It failed later, in an unrelated test, with a message about the version rather than about the producer that wrote it.

The change

WORKLOAD_SNAPSHOT_VERSION is declared once, beside the field it governs, and used for both the check and its message.

Producers are written in Rust, Python and JSON and cannot share a constant, so a test ties them together instead (control_plane/tests/snapshot_version.rs):

  • every shipped example snapshot declares that version;
  • every listed tool rejects anything else;
  • no tool writes snapshot_version. A tool changes a snapshot's content, not its schema, so restating the version is exactly how the literal went stale.

Bumping the schema is now one edit plus whatever the test reports.

Validation

Mutation-checked rather than merely green:

Mutation Result
Constant raised to 4 both tests FAIL
snapshot["snapshot_version"] = reintroduced into a tool FAILS, naming that tool
Reverted 2 passed

cargo test -p control_plane --lib: 433 passed. cargo fmt --check clean, cargo clippy --all-targets with -D warnings clean.

Related

Third instance this week of an input contract moving while a hand-written producer of that input stayed behind, after the two dataset_identity sites. The first two had a compiler backstop; a version number is a plain integer and had none, which is how this one reached CI.

🤖 Generated with Claude Code

The workload-snapshot version was restated at every site that produced or
consumed a snapshot: the backend's check, two o11y tools, a shared-workload
tool, the shipped example snapshots and their tests. Nothing tied them
together, so they drifted. On the #728 stack two tools still overwrote the
version with a stale literal of 2 while the backend had moved to 3, which meant
a snapshot built from a current template was relabelled to an old version and
then rejected by the very backend that had produced the template.

Name it once, as WORKLOAD_SNAPSHOT_VERSION beside the field it governs, and use
it for both the check and its message. Producers are written in Rust, Python
and JSON and cannot share a constant, so tie them together with a test instead:
the shipped snapshots must declare that version, and each tool must reject
anything else and must not relabel what it is handed. A tool changes a
snapshot's content, not its schema, so it has no business restating the
version; that is precisely how the literal went stale.

Bumping the schema is now one edit plus whatever the test reports, rather than
a literal that some producers follow and others quietly do not.

Verified by mutation: raising the constant to 4 fails both tests, and
reintroducing a `snapshot["snapshot_version"] =` write into a tool fails with
the message naming that tool.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit b08690b into main Sep 28, 2026
1 check 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.

1 participant