Skip to content

Phase B3c — rosalind index + locate (build-once → query CLI) - #17

Merged
logannye merged 6 commits into
mainfrom
rosalind/phase-b3c-index-cli
May 27, 2026
Merged

Phase B3c — rosalind index + locate (build-once → query CLI)#17
logannye merged 6 commits into
mainfrom
rosalind/phase-b3c-index-cli

Conversation

@logannye

Copy link
Copy Markdown
Owner

Summary

Surfaces B3b's persisted FM-index at the CLI — the build-once → query workflow — and lays the first record-only MemoryBudget hook.

  • rosalind index --reference <fa> --output <idx> [--memory-budget-mb M] — streams all FASTA contigs → GenomeIndex::from_named_sequencesIndexWriter::write_genome_index. Prints a deterministic build receipt (contigs, total bp, reference BLAKE3, on-disk size) to stdout and the realized build peak RSS to stderr.
  • rosalind locate --index <idx> --pattern <seq> [--max-hits N]IndexReader::openGenomeIndexView::locate_exact → prints contig<TAB>pos (sorted). Memory-mapped load, never rebuilds, exact-match only.
  • --memory-budget-mb — prints a record-only [OK|OVER] build plan line from a coarse working-set estimate and never refuses the build (enforcement + rosalind plan are Phase C).
  • Thin CLI handlers over the merged B3b/B2 library APIs; the testable logic (build estimate, receipt, plan line) lives in a pure, unit-tested genomics/index/report.rs.

Scope: library/CLI surface only. Deferred by design: wiring align/variants onto the persisted index + the seed/chain/extend aligner (B4); MemoryBudget enforcement + rosalind plan/verify (Phase C); sublinear-space construction — the build is still O(reference) RAM, which the receipt reports honestly (Phase D).

Spec gates — all met

  • Round-trip vs in-RAM: locate returns exactly the loci GenomeIndex::locate_exact returns, over a multi-contig + N-bearing + lowercase + cross-contig-straddle + invalid-base battery.
  • No rebuild on load: the locate path calls only open/genome_view/locate_exact (structural) and serves queries from the .idx alone after the source FASTA is deleted (behavioral).
  • Determinism: two rosalind index runs of the same reference produce byte-identical .idx files.
  • Budget record-only: --memory-budget-mb 0 prints [OVER] and the build still succeeds.
  • Bounded residency: locate adds no owned copy of the index (borrows the mmap'd FmIndexView).

Test plan

  • cargo test — full suite green (24 test binaries, 0 failures), incl. tests/index_cli.rs (5 CLI gates) + genomics::index::report unit tests
  • cargo build0 warnings
  • cargo fmt --all -- --check — clean
  • MSRV 1.72 preserved (no div_ceil)

Design spec: docs/superpowers/specs/2026-05-27-phase-b3c-index-cli-design.md. Plan: docs/superpowers/plans/2026-05-27-phase-b3c-index-cli.md.

🤖 Generated with Claude Code

logannye and others added 6 commits May 27, 2026 13:10
The CLI surface over B3b's persistence: a rosalind index subcommand (multi-contig FASTA -> GenomeIndex -> write_genome_index, deterministic build receipt) + a minimal rosalind locate (IndexReader::open -> GenomeIndexView::locate_exact, mmap, no rebuild), plus the first record-only MemoryBudget hook (--memory-budget-mb + working-set estimate + plan line; no enforcement). Aligner/--index wiring stays B4; enforcement + rosalind plan stay Phase C; sublinear-space build stays Phase D.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4-task plan: (1) pure report helpers (build estimate + receipt + plan line), (2) rosalind index build+persist+receipt+budget plan line, (3) rosalind locate load+query, (4) determinism/self-contained gates + README. Thin CLI handlers over library APIs; CARGO_BIN_EXE subprocess integration tests; record-only budget (no enforcement). Derived from the committed spec (caec338).

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

Pure, unit-tested helpers for rosalind index: a coarse record-only build working-set estimate, a deterministic IndexBuildReport receipt, and the [OK|OVER] budget plan line. No enforcement. Keeps the CLI handler thin and the logic process-free testable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Streams all FASTA contigs -> GenomeIndex::from_named_sequences -> write_genome_index, prints a deterministic build receipt (contigs, total bp, reference BLAKE3, on-disk size) to stdout and realized peak RSS to stderr. --memory-budget-mb prints a record-only [OK|OVER] plan line and never refuses the build. Thin handler over library APIs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
IndexReader::open -> GenomeIndexView::locate_exact -> prints contig<TAB>pos (sorted). Memory-mapped load, no rebuild, exact-match only (not the aligner — that's B4). Verified against an in-RAM GenomeIndex::locate_exact ground truth over a multi-contig + N-bearing battery.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d-once → query

CLI gates: two rosalind index builds are byte-identical, and rosalind locate serves queries from the .idx alone after the source FASTA is deleted (load never rebuilds). README documents the build-once -> query workflow and the record-only --memory-budget-mb plan line.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@logannye
logannye merged commit 48ecde9 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