fix(control-plane): give the snapshot schema version one owner - #782
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
2while the backend had moved to3, 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: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_VERSIONis 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):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:
snapshot["snapshot_version"] =reintroduced into a toolcargo test -p control_plane --lib: 433 passed.cargo fmt --checkclean,cargo clippy --all-targetswith-D warningsclean.Related
Third instance this week of an input contract moving while a hand-written producer of that input stayed behind, after the two
dataset_identitysites. 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