feat(store)!: narrow pub mod wire to the minimal adapter surface (#210)#235
Merged
Conversation
Demote the wire-format internals to `pub(crate)` before the 1.0 freeze so the on-disk byte layout does not become a public SemVer commitment. The `frame_format_version` byte (#205) only keeps the frame evolvable if the offset constants and header types are NOT part of the public API (CLAUDE.md rule 4: internal wire-format helpers must be `pub(crate)`). Kept public (the adapter contract): encode_frame, decode_frame, EncodedFrame, DecodedFrame, FrameOffsets, WireError, DecodeError, PAYLOAD_ALIGN. Demoted to pub(crate): HEADER_FIXED_SIZE; all *_OFFSET consts (VERSION / GLOBAL_SEQ / SCHEMA_VERSION / EVENT_TYPE_LEN / META_LEN); META_LEN_ABSENT; FrameFormatVersion (+ CURRENT); FrameHeader (+ SIZE, the format_version / global_seq / schema_version fields, read_from). The unused FrameHeader::event_type_len / metadata_len accessors are deleted rather than carried as dead pub(crate) code (rule 4 / YAGNI) — internal code reads the private fields directly. fjall: the only cross-crate consumer was a #[cfg(test)] re-export `EVENT_VALUE_HEADER_SIZE = wire::HEADER_FIXED_SIZE`, used by one scan.rs white-box test. Rewrote that test to derive the event_type start offset from the public `decode_frame(..).offsets.event_type.start` and deleted the re-export. Reworded two fjall intra-doc links (`wire::HEADER_FIXED_SIZE`, `wire::META_LEN_ABSENT`) to plain text so cargo doc stays green. BREAKING CHANGE: several nexus_store::wire::* items (HEADER_FIXED_SIZE, the *_OFFSET constants, META_LEN_ABSENT, FrameFormatVersion, FrameHeader) are no longer reachable from downstream crates. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #210 — a Tier-1 1.0-API-freeze blocker (milestone "1 — Nexus: Pre-Freeze (1.0 blockers)"), sibling of #208 (which sealed
arrayvec). Same theme: shrink the public surface before the freeze makes it permanent.Why
nexus-store/src/lib.rsdoespub mod wire;, re-exporting everypubitem inwire.rs— including raw byte-offset constants and the internalFrameHeader/FrameFormatVersiontypes. Once 1.0 freezes, downstream code could hard-depend onHEADER_FIXED_SIZE == 19, the offset values, or theFrameHeaderfield set, turning the on-disk byte layout into a public SemVer commitment. That defeats the purpose of theframe_format_versionbyte (#205), whose whole point is that the frame stays evolvable. Also resolves a CLAUDE.md rule 4 violation ("internal wire-format helpers must bepub(crate), notpub"). An adapter only needsencode_frame/decode_frame+ the result/error types — fjall proves it.This is a visibility-only change. The on-disk bytes are identical before and after.
Keep public (the adapter contract)
encode_frame,decode_frame,EncodedFrame,DecodedFrame,FrameOffsets,WireError,DecodeError,PAYLOAD_ALIGN.Demoted to
pub(crate)HEADER_FIXED_SIZE*_OFFSETconsts:VERSION_OFFSET,GLOBAL_SEQ_OFFSET,SCHEMA_VERSION_OFFSET,EVENT_TYPE_LEN_OFFSET,META_LEN_OFFSETMETA_LEN_ABSENTFrameFormatVersion(+CURRENT)FrameHeader(+SIZE, theformat_version/global_seq/schema_versionfields,read_from)The unused
FrameHeader::event_type_len/metadata_lenaccessor methods are deleted rather than carried as deadpub(crate)code (rule 4 / YAGNI). They were exempt fromdead_codeonly because they werepub; internal code reads the private fields directly, so demotion would have made them dead.DecodedFrame/EncodedFramestay public and expose noFrameHeader/FrameFormatVersionin any field or method, so nothing public references a demoted type.fjall consumer fixes
#[cfg(test)]re-exportEVENT_VALUE_HEADER_SIZE = wire::HEADER_FIXED_SIZEinwire_key.rs, consumed by onescan.rswhite-box test (stream_decode_rejects_non_utf8_event_type). Rewrote that test to derive the event-type start offset from the publicdecode_frame(..).offsets.event_type.startand deleted the re-export. The test still forges invalid UTF-8 in the event-type bytes and asserts the exactFjallError::EnvelopeCorrupt { stream_id: "user-1", version: 7 }— same corruption path, still fails on regression.[\wire::HEADER_FIXED_SIZE`],[`wire::META_LEN_ABSENT`]) to plain text socargo doc(thenexus-doc` gate) stays green once the targets are private.Verification
nix flake check(pre-commit hook): all checks ✅ — clippy, doc, nextest, fmt, deny, audit, hakari, toml-fmt.cargo clippy --all-targets --all-features -p nexus-store -p nexus-fjall: clean apart from two pre-existingrange_plus_onelints inwire.rs's#[cfg(test)]module (lines 906, 1220 — untouched by this PR).nexus-storeitself names any demotedwireitem.Breaking change
Several
nexus_store::wire::*items (HEADER_FIXED_SIZE, the*_OFFSETconstants,META_LEN_ABSENT,FrameFormatVersion,FrameHeader) are no longer reachable from downstream crates.🤖 Generated with Claude Code