Repository navigation
fix(crates): implement the documented behaviour behind four template crates - #511
Merged
Merged
Conversation
…crates
Close the P0 correctness defects from the template gap analysis: code paths
whose doc comments and README described behaviour that never ran.
checkpoint-template advertised automatic migration on crates.io, but load()
returned VersionMismatch without ever calling Storable::migrate, and migrate
could not have worked anyway: storage is bincode, which is not
self-describing, so decoding into serde_json::Value fails with
AnyNotSupported. A real consumer probe printed `FAILED: Version mismatch`.
migrate now takes the raw bytes, supports_migration_from is an explicit
opt-in, and a type that does not opt in still fails closed. MigrationRegistry
gains path() and migrate_with() so a registered chain applies each step
instead of returning its input.
hybrid-storage-template called on_page_synced before apply_transaction, so
the hook reported pages a failed commit could still discard. It also used
trim_start_matches("rec:"), which strips repeatedly and truncated ids like
rec:x to x, and get_record never compared the payload id against the
requested one despite documenting a CorruptRecord for that case.
actor-runtime-template assigned Init state before validating it, so a
rejected transition still replaced the actor's current state.
release.toml listed a lowercase `unreleased` replacement that matches zero
times in a changelog containing only `## [Unreleased]`, which aborts the
release under min = 1; the VERSION regex is now anchored so it cannot match
inside a link or prose.
Each fix carries a regression test that was shown to fail when the fix is
reverted. SyncEngine and the migration tests moved to their own modules to
respect the 500-line limit, with the public SyncEngine path preserved by a
re-export. serde_json became genuinely unused in checkpoint-template and is
removed rather than suppressed.
Contributor
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 28 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #511 +/- ##
==========================================
+ Coverage 93.90% 94.18% +0.28%
==========================================
Files 18 20 +2
Lines 1822 1979 +157
==========================================
+ Hits 1711 1864 +153
- Misses 111 115 +4
🚀 New features to boost your workflow:
|
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.
Summary
Closes the verified P0 correctness defects from the template gap analysis: code paths whose doc comments and README described behaviour that never ran.
checkpoint-template (published on crates.io)
load()returnedVersionMismatchwithout callingStorable::migrate, andmigratecould not have worked regardless: storage is bincode, which is not self-describing, so decoding intoserde_json::Valuefails withAnyNotSupported(verified with a standalone probe). A real consumer crate printedFAILED: Version mismatch.Storable::migratenow takes the raw bincode bytes and returns bytes.Storable::supports_migration_fromis an explicit opt-in; a type that does not opt in still fails closed withVersionMismatch.MigrationRegistrygainspath()andmigrate_with(), so a registered chain applies each step instead of returning its input. The walk is bounded by the edge count so a cycle cannot hang.This is a breaking API change to a published crate and needs a version bump beyond
0.1.0before any republish.hybrid-storage-template
on_page_syncedfired beforeapply_transaction, reporting pages a failed commit could still discard. It now fires after the commit, matching its documented contract.trim_start_matches("rec:")stripped the prefix repeatedly, so an id likerec:xwas truncated toxand never resolved during pagination. Replaced withstrip_prefix.get_recordnever compared the decoded payload id against the requested id, despite documenting aCorruptRecordfor exactly that case.actor-runtime-template
Initassigned state before validating it, so a rejected transition still replaced the actor's current state.release.toml
unreleasedreplacement that matches zero times in a changelog containing only## [Unreleased]; undermin = 1that aborts the first release run. Verified: 0 matching lines before, exactly 1VERSIONmatch after re-anchoring.Verification
FAILED: Version mismatchnow printsLOADED (migration ran)../scripts/quality-gates.sh: all checks pass, Overall Status SUCCESS.cargo macheteconfirmedserde_jsonbecame genuinely unused incheckpoint-templaterather than suppressing the warning.Notes
SyncEngineand the migration tests moved into their own modules to respect the 500-line limit; the publicSyncEnginepath is preserved by a re-export.