Skip to content

Phase 2 architectural decisions + core ID types - #11

Merged
nnunley merged 5 commits into
forest-rs:mainfrom
nnunley:phase2-decisions
Jul 15, 2026
Merged

Phase 2 architectural decisions + core ID types#11
nnunley merged 5 commits into
forest-rs:mainfrom
nnunley:phase2-decisions

Conversation

@nnunley

@nnunley nnunley commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds Phase 2 segment-format architectural decisions and the core segment-resident ID types they require.

  • BlockId, FilterExprId, SegmentOrd, and SegmentLocalDocId use stable 4-byte little-endian bytemuck POD representations.
  • IDs support validated zero-copy reads without an implicit Default sentinel.
  • Records DEC-01 through DEC-10 and their enforcement points.
  • Moves wind-tunnel test-only dependencies to dev-dependencies.

Verification

cargo test -p leit_core -p leit_wind_tunnel

cargo clippy -p leit_core -p leit_wind_tunnel --all-targets -- -D warnings

cargo fmt --all -- --check

@waywardmonkeys

Copy link
Copy Markdown
Contributor

This needs to be rebased on main cleanly and fix CI. (Then you can edit the description to not refer to the wind tunnel branch...)

@waywardmonkeys waywardmonkeys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase, fix CI, address these things and I think this is good to go.


**Grounding:** `docs/leit_kernel_handover.md` §"Segment Architecture" (the format
sketch, versioning bias, and Open Questions) and the ITER-0001 serialization choice
(bytemuck zero-copy, little-endian — see `docs/superpowers/iterations/requirements/EPIC-009.md`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file doesn't exist in-tree. (It doesn't need to, just don't link to it, I think.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the stale handover link and kept the grounding self-contained.

Comment thread crates/leit_core/src/segment_ids.rs Outdated
///
/// Fixed-width 4-byte little-endian value; viewable in place from mmap'd
/// segment bytes via `bytemuck` (`Pod`).
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, Pod, Zeroable)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it actually make sense for these to all impl Default? (I suspect not.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed Default from all four segment ID types; zero is no longer implicitly presented as a valid identifier.

nnunley added 5 commits July 15, 2026 07:46
… (STORY-0096)

ITER-0001 dependency hygiene per the usage-site rule: the leit_wind_tunnel
harness uses only rapidhash in its library surface; leit_core/leit_index/
leit_text are used solely by its #[cfg(test)] integration tests, so they
move to [dev-dependencies] and no longer appear in the harness's production
dependency graph. The bench crates were already correct (empty lib; all deps
dev). Library build, 17 unit tests, and both bench crates verified green.
… (STORY-0112)

ITER-0001: BlockId, FilterExprId, SegmentOrd, SegmentLocalDocId in leit_core,
each a #[repr(transparent)] newtype over a [u8; 4] little-endian inner deriving
bytemuck Pod/Zeroable. The on-disk form is the in-memory form: a &[u8] slice
from an mmap'd buffer casts in place to &[Id] with no allocation or
deserialization (zero-copy), stable across host endianness; ordering is numeric.

bytemuck chosen over zerocopy because zerocopy's derives emit internal
#[allow(non_ascii_idents)]/#[allow(non_local_definitions)] that conflict with the
workspace's forbid-level Linebender lints (E0453); bytemuck is no_std and
lint-clean under the same forbid set. Proven by SCENARIO-0005 (6 unit tests:
value + slice + unaligned round-trip, numeric ordering, LE byte layout).
Records the design-decidable decisions for the Phase 2 segment format
(DEC-01..10) with rationale, a Phase 3 forward-compatibility audit, and
decision->enforcement traceability. Human-confirmed key calls:

- DEC-01 segment offsets: u64 (no size cap; removes the only Phase 3
  format-migration risk)
- DEC-10 integrity: single footer checksum, verified in Full validation mode
- DEC-06 block-aware API: public dedicated BlockCursor trait (Phase 3 WAND
  consumes it without a format/API break)
- DEC-05 header: fixed-layout little-endian POD, absolute u64 section offsets,
  magic + version + format_flags, reserved stored-fields/columnar slots

Decision-documentation ACs of STORY-0078/0081-0084/0090/0043-0047 are satisfied
here (decided:ITER-0001); their code-enforcement ACs are deferred to
ITER-0003/0004. Forward constraint recorded for ITER-0005: block-metadata schema
must carry per-block max_score + doc-range for Phase 3 WAND/MaxScore.
…ORY-0112 AC-2)

ITER-0001 audit corrective: SCENARIO-0005 now also exercises try_from_bytes/
try_cast_slice (Ok on well-formed, Err on malformed) per AC-2's validated-read
obligation.
@nnunley
nnunley force-pushed the phase2-decisions branch from 338d664 to 1d204c5 Compare July 15, 2026 12:22
@nnunley
nnunley merged commit 6c13d3d into forest-rs:main Jul 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants