Skip to content

Hardening fast-follow (sort tie-break, @SQ check, BSD RSS, honesty pass) - #25

Merged
logannye merged 5 commits into
mainfrom
rosalind/hardening-fast-follow
Jun 2, 2026
Merged

Hardening fast-follow (sort tie-break, @SQ check, BSD RSS, honesty pass)#25
logannye merged 5 commits into
mainfrom
rosalind/hardening-fast-follow

Conversation

@logannye

@logannye logannye commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

The cross-cutting hardening items the keystone (PR #24) deferred — four independent fixes, each tested where it's code.

  • Sort tie-break (finding Phase A foundation: canonical core types + streaming pileup kernel #5)HeapItem::cmp now tie-breaks equal sort keys by source_idx, so equal-key records (duplicate-marked reads, primary+overlapping-split sharing qname/pos/strand) merge in input order regardless of the spill-chunk partition → the sorted BAM is byte-identical across --memory-mb budgets. PartialEq made consistent with the now-total Ord.
  • @SQ length cross-check (finding Phase A4: spec-valid VCFv4.2 writer + BLAKE3 provenance receipt #7)StreamingBamSource::new now validates each shared @SQ contig's LN against the index ContigSet and rejects a BAM aligned to a different-length reference (previously silently accepted → coordinate-shifted/truncated calls), matching samtools/bcftools.
  • BSD ru_maxrss unit fix (finding Phase A3: calibrated, abstention-aware genotype caller (call/) #6) — inverted the cfg to bytes iff Darwin, else KiB×1024, fixing a silent 1024× under-count on the BSDs (the dangerous direction for --enforce/verify) and making the unknown-target default the safe over-estimate. Magnitude test catches a dropped conversion on the run platform.
  • Front-door √t honesty passCargo.toml description + CLI --help about-string now lead with the memory contract (not "O(√t) space"); deleted the unreferenced root scale_test_results.txt (its "O(√t) Verification" measured the tautological SpaceTracker counter, not real RSS); fixed CONTRACT.md's false "byte-identical manifest" claim (the manifest embeds the machine-dependent realized peak_rss_bytes).

Spec: docs/superpowers/specs/2026-06-02-hardening-fast-follow-design.md.

Deferred (further follow-up, not this PR): cgroup-awareness + manifest os/arch provenance (the heavier container-correctness work).

Test plan

  • cargo test green (incl. new merge-tie-break, @SQ-mismatch, and RSS-magnitude tests)
  • cargo fmt --all -- --check clean; 0 warnings (debug + release)
  • No behavior change for distinct-key sort inputs or matching-length BAMs (existing tests green)

🤖 Generated with Claude Code

logannye and others added 5 commits June 2, 2026 09:06
…BSD RSS, honesty pass)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
HeapItem::cmp now tie-breaks equal sort keys by source_idx (reversed for the
max-heap, so the lower index pops first = input order). Equal-key records
(duplicate-marked reads, primary+overlapping-split sharing qname/pos/strand)
therefore merge in a deterministic order independent of how they were
partitioned into spill chunks — i.e. the sorted BAM is byte-identical across
--memory-mb budgets. PartialEq made consistent with the now-total Ord.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
record_to_aligned_read mapped the reference by NAME only, so a BAM aligned to a
different-length contig (a different assembly/patch) was silently accepted and
produced coordinate-shifted/truncated calls. validate_contig_lengths now checks
every shared @sq name's LN against the index ContigSet at open and errors on
mismatch (naming the contig + both lengths), matching samtools/bcftools.

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

The old not(linux) branch returned ru_maxrss raw, assuming macOS-style bytes —
a silent 1024x UNDER-count on the BSDs (which report KiB), the dangerous
direction: --enforce/verify would pass a job that breached its budget. Inverted
the cfg: bytes only on Darwin (macos/ios), KiB->bytes everywhere else, so the
unknown-target default is the safe over-estimate direction. Added a magnitude
test that catches a dropped conversion on the run platform.

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

The README/OPEN_PROBLEMS honestly demote √t to 'not yet load-bearing', but three
skimmable surfaces still sold it as shipped. Fixed: Cargo.toml description and the
CLI --help about-string now lead with the memory contract (not 'O(√t) space');
deleted scale_test_results.txt (an unreferenced root artifact whose 'O(√t) Space
Complexity Verification' measured the tautological SpaceTracker counter, not real
RSS); corrected CONTRACT.md's false 'byte-identical manifest' claim (the manifest
embeds the machine-dependent realized peak_rss_bytes).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@logannye
logannye merged commit 95c4ba8 into main Jun 2, 2026
2 of 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