Skip to content

feat(catalog): repair invalid preimages atomically - #269

Merged
schickling merged 1 commit into
mainfrom
schickling/2026-08-18-catalog-raw-preimage
Aug 18, 2026
Merged

feat(catalog): repair invalid preimages atomically#269
schickling merged 1 commit into
mainfrom
schickling/2026-08-18-catalog-raw-preimage

Conversation

@schickling

Copy link
Copy Markdown
Contributor

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 apply path 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-preimage and st2 catalog apply --raw-preimage.

  • The current declaration plane is hashed structurally under a distinct raw hash domain.
  • Raw mode is allowed only when the current catalog fails normal strict admission.
  • The prepared, staged, and resulting catalogs remain fully parsed and validated.
  • The incumbent catalog envelope must parse and the effective external PTY root must remain unchanged.
  • A distinct durable marker preserves raw-preimage authority across source-free --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

  • Focused raw-preimage controls: 5/5 passed
  • cargo test --test catalog_apply --all-features: 46/46 passed
  • cargo check --all-targets --all-features: passed
  • Exact-commit independent contract review: passed
  • git diff --check: passed

The 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

@schickling schickling added area:agent-spec Agent Spec format, parsing, and the agent-spec crate · Set: manual area:catalog Catalog structure, declarations, transactions, and admission · Set: manual type:feature New user-visible or system capability · Set: manual labels Aug 18, 2026
@schickling
schickling marked this pull request as ready for review August 18, 2026 06:38
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@schickling
schickling requested a review from myobie August 18, 2026 06:46
@schickling
schickling merged commit 898ad13 into main Aug 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent-spec Agent Spec format, parsing, and the agent-spec crate · Set: manual area:catalog Catalog structure, declarations, transactions, and admission · Set: manual type:feature New user-visible or system capability · Set: manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant