feat(catalog): repair invalid preimages atomically - #269
Merged
Conversation
schickling
marked this pull request as ready for review
August 18, 2026 06:38
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Why
A clean Agent Spec format transition can leave a live catalog whose declaration bytes are structurally safe but no longer parse under the current schema. The existing
catalog snapshot/catalog applypath correctly requires a valid incumbent, so operators otherwise have to publish repaired declarations outside st2's catalog-wide lock, CAS, durable marker, and crash recovery.This became concrete after #262. Strict rejection is not a bug; the missing piece is an explicit, narrowly fenced upgrade path.
What
Add
st2 catalog snapshot --raw-preimageandst2 catalog apply --raw-preimage.--resume.How
The implementation reuses the existing catalog transaction: persistent authoring lock, retained no-follow projection, declaration-root CAS, content-addressed stage, durable apply marker, generation commit, fsync boundaries, and recovery. Wrong raw CAS is checked before writer-temporary cleanup, stage/marker publication, or declaration/workspace/state mutation.
The primitive owns no schema migration policy. It never interprets the invalid declaration bytes; callers prepare a complete valid postimage offline.
Rationale
Keeping this as an explicit flag on the existing snapshot/apply commands makes the authority boundary visible without adding a second publisher. Separate raw snapshot/apply/marker schemas and hash domains prevent raw and strict receipts from being confused. Refusing already-valid incumbents prevents the mode from becoming a general validation bypass.
Verification
cargo test --test catalog_apply --all-features: 46/46 passedcargo check --all-targets --all-features: passedgit diff --check: passedThe repository-wide suite is not globally green on current
main: an untouched catalog-diff admission test fails; with that skipped, an unrelated eval E2E route-freeze test timed out; one runtime-owner lock test flaked once and passed alone. Existing Clippy warnings also remain outside this diff.Related