Skip to content

test(engine): gate on-disk state format (F1) + mixed-version no-clobber upload (F2)#922

Merged
hugocorreia90 merged 1 commit into
mainfrom
feat/engine/state-format-golden-upload-gate
Jun 18, 2026
Merged

test(engine): gate on-disk state format (F1) + mixed-version no-clobber upload (F2)#922
hugocorreia90 merged 1 commit into
mainfrom
feat/engine/state-format-golden-upload-gate

Conversation

@hugocorreia90

Copy link
Copy Markdown
Contributor

Two release-gate invariants for the consumed state surface — the buildable halves of F1 and F2 from the finite-work plan.

F1 — on-disk state-schema format golden

There was no test pinning the on-disk state layout. The state.redb file is persisted and shared across pods (state_sync), so its layout is a compatibility contract. New test on_disk_state_schema_format_is_pinned:

  • asserts CURRENT_SCHEMA_VERSION == 9, and
  • asserts the exact set of redb tables a fresh store materializes (18), read back from list_tables() so the golden is self-correcting and auto-detects any table add/remove/rename (init_db eagerly creates every table).

Any such change now fails CI until the golden — and, for a table change, the version + migration — is updated in the same PR.

Scoped to table-set + version on purpose: record values are deliberately not byte-pinned, because the *_forward_deserializes_* tests exist to allow field evolution.

F2 — mixed-version no-clobber upload

The open-time half of the mixed-version invariant was already gated: open_with_policy_* cover forward-incompat hard-fail/Fail/Recreate, backward auto-migrate, and same-version no-op, and run in engine-ci. This was not untested before — this PR adds the missing run-time half.

The catastrophic form of the 06-07 failure mode is a downgraded pod (recreated under on_schema_mismatch = recreate) uploading its state back and clobbering the newer shared state. The end-of-run skip decision was inline in the 3600-line run fn and untested. This PR:

  • extracts it into state_sync::upload_state_unless_recreated(recreated, cfg, path) (behavior-preserving — the run path keeps its warn!-on-error), and
  • tests it by pointing at a backend that hard-errors the moment dispatch is reached (S3 with no bucket, on_upload_failure = Fail): recreated=true → Ok (upload skipped), recreated=false → Err(MissingConfig "s3") (upload attempted). Deleting the guard turns the test red (verified).

Both upload sites honor the flag: the periodic mid-run uploader is gated at spawn time (not started when the store was recreated); the end-of-run upload goes through the new seam.

Verification

cargo test --all-features -p rocky-core -p rocky-cli green (the new F1/F2 tests + 1361 rocky-core); cargo fmt --check + clippy --all-targets --all-features clean.

🤖 Generated with Claude Code

…n no-clobber upload (F2)

Two release-gate invariants for the consumed state surface.

F1 — on-disk state-schema format golden. A new test pins
CURRENT_SCHEMA_VERSION plus the exact set of redb tables a fresh store
materializes (read back from `list_tables()`, so it's self-correcting and
auto-detects additions/removals). The `state.redb` file is persisted and
shared across pods, so any table add/remove/rename or version bump now
fails CI until the golden is updated in the same PR.

F2 — mixed-version no-clobber upload. The open-time half of the
mixed-version invariant was already gated (open_with_policy_* tests cover
forward-incompat hard-fail/recreate + backward auto-migrate). This adds
the missing run-time half: extract the end-of-run "skip upload when the
store was recreated for forward-incompat" decision into a named
`state_sync::upload_state_unless_recreated`, and test that a recreated
store skips the upload entirely (proven by pointing at a backend that
hard-errors the moment dispatch is reached — deleting the guard turns the
test red). Behavior-preserving: the run path keeps its warn-on-error.
The periodic mid-run uploader is gated by the same flag at spawn time.
@hugocorreia90 hugocorreia90 merged commit 1c71a41 into main Jun 18, 2026
13 checks passed
@hugocorreia90 hugocorreia90 deleted the feat/engine/state-format-golden-upload-gate branch June 18, 2026 02:12
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