Skip to content

fix(crates): implement the documented behaviour behind four template crates - #511

Merged
d-oit merged 1 commit into
mainfrom
fix/gap-analysis-p0-behavioural
Nov 13, 2026
Merged

d-oit merged 1 commit into
mainfrom
fix/gap-analysis-p0-behavioural

Conversation

@d-oit

@d-oit d-oit commented Nov 13, 2026

Copy link
Copy Markdown
Owner

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() returned VersionMismatch without calling Storable::migrate, and migrate could not have worked regardless: storage is bincode, which is not self-describing, so decoding into serde_json::Value fails with AnyNotSupported (verified with a standalone probe). A real consumer crate printed FAILED: Version mismatch.

  • Storable::migrate now takes the raw bincode bytes and returns bytes.
  • Storable::supports_migration_from is an explicit opt-in; a type that does not opt in still fails closed with VersionMismatch.
  • MigrationRegistry gains path() and migrate_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.
  • The README now documents the real API with a working example.

This is a breaking API change to a published crate and needs a version bump beyond 0.1.0 before any republish.

hybrid-storage-template

  • on_page_synced fired before apply_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 like rec:x was truncated to x and never resolved during pagination. Replaced with strip_prefix.
  • get_record never compared the decoded payload id against the requested id, despite documenting a CorruptRecord for exactly that case.

actor-runtime-template

  • Init assigned state before validating it, so a rejected transition still replaced the actor's current state.

release.toml

  • Removed a lowercase unreleased replacement that matches zero times in a changelog containing only ## [Unreleased]; under min = 1 that aborts the first release run. Verified: 0 matching lines before, exactly 1 VERSION match after re-anchoring.

Verification

  • Every fix ships a regression test that was shown to fail when the fix is reverted.
  • The consumer-style probe that printed FAILED: Version mismatch now prints LOADED (migration ran).
  • ./scripts/quality-gates.sh: all checks pass, Overall Status SUCCESS.
  • cargo machete confirmed serde_json became genuinely unused in checkpoint-template rather than suppressing the warning.

Notes

  • Four of the twelve P0 items remain out of scope here: watermark enforcement, supervisor restarts, the MCP JSON-RPC/stdio protocol, and the egress/path/redaction validators.
  • SyncEngine and the migration tests moved into their own modules to respect the 500-line limit; the public SyncEngine path is preserved by a re-export.

…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.
@github-actions github-actions Bot added rust Pull requests that update rust code agents labels Nov 13, 2026
@codacy-production

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 28 complexity

Metric Results
Complexity 28

View in Codacy

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

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.82759% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.18%. Comparing base (bd22251) to head (3e1fac8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/checkpoint-template/src/lib.rs 64.70% 6 Missing ⚠️
crates/actor-runtime-template/src/actor.rs 89.47% 2 Missing ⚠️
crates/checkpoint-template/src/migration.rs 97.05% 2 Missing ⚠️
crates/hybrid-storage-template/src/lib.rs 88.88% 1 Missing ⚠️
crates/hybrid-storage-template/src/sync.rs 98.24% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
crates/checkpoint-template/src/tests_migration.rs 100.00% <100.00%> (ø)
crates/hybrid-storage-template/src/lib.rs 98.68% <88.88%> (-0.33%) ⬇️
crates/hybrid-storage-template/src/sync.rs 98.24% <98.24%> (ø)
crates/actor-runtime-template/src/actor.rs 87.32% <89.47%> (+0.14%) ⬆️
crates/checkpoint-template/src/migration.rs 94.62% <97.05%> (+6.74%) ⬆️
crates/checkpoint-template/src/lib.rs 92.25% <64.70%> (+0.52%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@d-oit
d-oit merged commit f29b3a7 into main Nov 13, 2026
28 checks passed
@d-oit
d-oit deleted the fix/gap-analysis-p0-behavioural branch November 13, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant