core: SanitizedMode newtype and non_exhaustive on growth-prone enums - #554
Merged
Conversation
bug-ops
enabled auto-merge (squash)
August 18, 2026 18:30
…_exhaustive Wrap sanitized permission modes in a SanitizedMode newtype so a caller can no longer pass an unsanitized u32 into create_file_with_mode or extract_file_with_permit; the invariant was previously enforced only by a doc-comment contract. SanitizedMode can only be constructed by sanitize_permissions, matching the SafePath/QuotaPermit sealed-type pattern already used in this crate. Mark ArchiveError, QuotaResource, ArchiveType, CompressionCodec, IssueCategory, and types::entry_type::EntryType as #[non_exhaustive] so adding a variant to any of them is no longer a semver break for downstream exhaustive matches, consistent with ValidatedEntryType. Closes #549 Closes #551
bug-ops
force-pushed
the
feat/549-core-mode-newtype-nonexhaustive
branch
from
August 18, 2026 18:34
20299e7 to
53fc488
Compare
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
SanitizedModenewtype wrapping sanitized permission modes, sealed so it can only be constructed bysanitize_permissions. Threaded throughValidatedEntry,create_file_with_mode, andextract_file_with_permit, replacing anOption<u32>whose "must be sanitized" invariant was previously enforced only by a doc comment.ArchiveError,QuotaResource,formats::detect::ArchiveType,formats::compression::CompressionCodec,inspection::report::IssueCategory, andtypes::entry_type::EntryTypeas#[non_exhaustive]so adding a variant to any of them is no longer a semver break for downstream exhaustive matches, consistent with the existingValidatedEntryTypeprecedent.creation::walker::EntryTypewas intentionally left unmarked — it ispub(crate)-only and never nameable outside this crate.exarch-cli,exarch-python, andexarch-node.SanitizedModecannot be forged from outsidesanitize_permissions, mirroring the existingQuotaPermitfixture.Test plan
cargo +nightly fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run --workspace --all-features --exclude exarch-python --exclude exarch-node(1229/1229 pass)cargo test --doc --workspace --all-features --exclude exarch-python --exclude exarch-nodeandcargo test --doc -p exarch-corewithout--all-features(119/119 pass both ways)RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --workspacecargo audit/cargo deny check --all-featuresclean, no newunsafeCloses #549
Closes #551