ci: add Miri job for vitaminc-protected's unsafe (#213 fallback)#214
Merged
Conversation
fallback) `vitaminc-protected` is the only crate with first-party `unsafe` — the move-out in `move_inner_out` (`ptr::read` + `mem::forget`) behind `risky_unwrap` / `flatten` / `transpose`. This runs its tests + doctests under Miri on every PR touching the crate, catching aliasing/provenance UB a normal run can't. It's the standing guardrail requested in review. Context: full `#![forbid(unsafe_code)]` was evaluated and is impractical here — it needs either an `Option<T>` field (~44 `.0` rewrites across the crate plus impossible `.expect()` panics and a layout cost) or a breaking change to `risky_unwrap`'s return type. Per #213 this Miri check is the agreed fallback for the one irreducible move-out unsafe. Tracked in #213. Claude-Session: https://claude.ai/code/session_015jJwUcMbyjuttxTLh4vh6q
This was referenced Jun 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a dedicated GitHub Actions workflow to run the vitaminc-protected crate’s test suite under Miri on relevant pull requests, providing CI coverage for the workspace’s only first-party unsafe code.
Changes:
- Introduces a new
.github/workflows/miri.ymlworkflow triggered on PRs that modifypackages/protected/**. - Sets up Rust nightly with the Miri component and runs
cargo +nightly miri test -p vitaminc-protected. - Adds CI ergonomics (caching + concurrency cancellation) for faster, less noisy runs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+62
to
+68
| - name: miri test (vitaminc-protected) | ||
| # Interprets the protected unit tests + doctests under Miri. The | ||
| # move-out regression tests (drop_zeroizes_inner / | ||
| # risky_unwrap_does_not_zeroize / flatten / transpose) exercise the one | ||
| # unsafe block; Miri proves it has no UB. The first run builds a Miri | ||
| # sysroot (a few minutes); subsequent cached runs are quick. | ||
| run: cargo +nightly miri test -p vitaminc-protected |
There was a problem hiding this comment.
Wrong, @copilot.
Look at the step immediately above.
It does exactly what is suggested.
Try harder.
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.
What
Adds a Miri CI job (
.github/workflows/miri.yml) that runscargo +nightly miri test -p vitaminc-protectedon every PR touching the crate.Why
vitaminc-protectedis the only crate in the workspace with first-partyunsafe: the move-out inmove_inner_out(ptr::read+mem::forget) introduced in #185, which is howrisky_unwrap/flatten/transposemove the inner secret out past the zeroizingDrop. Miri interprets the tests under the Stacked/Tree Borrows model, catching aliasing/provenance UB that a normal test run (and even ASan) can miss.This is the agreed #213 fallback: a full
#![forbid(unsafe_code)]on the crate proved impractical (it would require either anOption<T>field — ~44.0rewrites plus impossible-panic.expect()calls and a layout cost — or a breakingrisky_unwrapAPI change). Rather than force an ugly rewrite of a foundational primitive, we keep the single audited unsafe move-out and guard it with Miri in CI. It also closes the review ask James raised on #185.Note on history
This job was authored on the #185 branch but landed ~12 minutes after that PR merged, so it never reached
main. This PR re-lands it cleanly off currentmain— no code changes, CI only.Scope
Scoped to
vitaminc-protectedon purpose: Miri can't execute the aws-lc-rs FFI (vitaminc-encrypt) or the entropy syscalls in random/permutation/password, andprotectedis where the only unsafe lives. Expand the matrix if other crates grow pure-Rustunsafe.Refs #213.
https://claude.ai/code/session_015jJwUcMbyjuttxTLh4vh6q