Skip to content

Phase B4a — ReferenceView (self-contained reference access) - #18

Merged
logannye merged 3 commits into
mainfrom
rosalind/phase-b4a-reference-view
May 27, 2026
Merged

Phase B4a — ReferenceView (self-contained reference access)#18
logannye merged 3 commits into
mainfrom
rosalind/phase-b4a-reference-view

Conversation

@logannye

Copy link
Copy Markdown
Owner

Summary

First sub-stage of B4 (wire the consumers onto the persisted multi-contig index). B3b stored the 2-bit forward reference into the index (the Reference2bit section) but gave it no read path; B4a adds one.

  • ReferenceView<'a> — a borrowed, zero-copy view over the Reference2bit section. base_at(global) -> u8 decodes one ASCII base on demand (ambiguity bit → N, else 2-bit code → A/C/G/T), mirroring CompressedDNA::base_at; decode_window(start, end, &mut Vec<u8>) fills a bounded caller buffer (end clamped to len). Obtained via ReferenceIndex::reference_view() (checked align_to, little-endian host, section-extent validation — same discipline as FmIndexView).
  • On-demand zero-copy, not reconstruction: the view holds two borrowed &[u64] slices + a length (40 bytes), decoding only the windows a consumer asks for — no O(reference) Vec, preserving the persisted index's bounded-query guarantee.
  • This is the shared reference-access foundation that B4b (the aligner's banded-DP window) and B4c (variants' ref_base / pileup) consume — after B4a they read the reference from the .idx alone, no separate --reference FASTA.

Scope: the reader only. Deferred: wiring it into the aligner (B4b) and into variants/pileup (B4c).

Test plan

  • Equivalence gate: base_at(i) over the whole reference, and decode_window over several ranges (boundary-spanning, N-bearing, full, and an over-range clamp case), are byte-identical to the original index.reference() over an N-bearing multi-contig index.
  • Bounded: ReferenceView is a small borrow (size_of <= 64), not an owned copy.
  • Decode correctness: base_at reviewed byte-equivalent to CompressedDNA::base_at (ambiguity word/bit + 2-bit word/shift + 0/1/2/3 → A/C/G/T).
  • cargo test — full suite green (151 lib tests + integration), 0 warnings, cargo fmt --all -- --check clean, MSRV 1.72 (no div_ceil).

Design spec: docs/superpowers/specs/2026-05-27-phase-b4a-reference-view-design.md. Plan: docs/superpowers/plans/2026-05-27-phase-b4a-reference-view.md.

🤖 Generated with Claude Code

logannye and others added 3 commits May 27, 2026 14:30
…w) design

First sub-stage of B4 (wire consumers onto the persisted index). A borrowed zero-copy ReferenceView over the Reference2bit section (base_at + decode_window, on-demand decode, no full-reference Vec), via ReferenceIndex::reference_view(). The shared reference-access foundation B4b (aligner DP window) and B4c (variants ref_base/pileup) need. Gated by decode==original over an N-bearing multi-contig reference.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…s) plan

Single TDD task: a borrowed zero-copy ReferenceView over Reference2bit (base_at + decode_window) + ReferenceIndex::reference_view() + re-exports, gated by decode==original over an N-bearing multi-contig index. Reuses view.rs section/align_to helpers. Derived from spec 913b993.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… from the index

A borrowed ReferenceView over the persisted Reference2bit section (base_at + decode_window, on-demand 2-bit decode mirroring CompressedDNA::base_at, no full-reference Vec), via ReferenceIndex::reference_view(). Gated by base_at/decode_window == the original reference over an N-bearing multi-contig index. The shared reference-access foundation B4b (aligner DP window) and B4c (variants ref_base) consume.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@logannye
logannye merged commit 31c97c3 into main May 27, 2026
3 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.

1 participant