Skip to content

fix/docs/test: additional correctness fixes, doc sweep, and expanded coverage (6/6) - #463

Merged
nh13 merged 5 commits into
feat-runallfrom
nh/runall-fix-6-review-docs-tests
Jul 1, 2026
Merged

fix/docs/test: additional correctness fixes, doc sweep, and expanded coverage (6/6)#463
nh13 merged 5 commits into
feat-runallfrom
nh/runall-fix-6-review-docs-tests

Conversation

@nh13

@nh13 nh13 commented Jun 24, 2026

Copy link
Copy Markdown
Member

Stack: 6 / 6 · base: nh/runall-fix-5-runall-consensus

Cross-cutting polish on top of the stack: additional correctness fixes surfaced during self-review, a documentation sweep, and expanded test coverage.

  • Correctness — reject non-finite codec/downsample fraction values; preserve MoleculeId::None for invalid UMIs in both the sequential and parallel adjacency assigners; bgzf buffer-pool cap; log aligner try_wait errors; mark the terminal extract chain tail as SerializedBytes.
  • Docs — campaign-wide doc/CHANGELOG/comment sweep; correct stale module comments and config/memory wording; drop stale pipeline literals.
  • Tests — un-ignore the order × spill sort-correctness matrix on in-process fixtures with an independent order oracle (samtools cross-check installed in CI); close runall parity/E2E gaps (stdin, FASTQ fusion, reject-discard, floors); strengthen oracles for dedup, coalesce, streaming, and the driver round-robin path.

Summary by CodeRabbit

  • New Features

    • Improved runall stage routing documentation and validation for --ref / --methylation-mode, including clearer consensus-start behavior and hazard warnings.
    • Updated simulation documentation for aligner replay and grouped-reads tag formatting/deterministic sorting.
  • Bug Fixes

    • Safer pipeline startup when deadlock monitoring is enabled (fails fast for unsupported output transports).
    • More reliable aligner shutdown and recovery during BGZF writing errors.
    • Stricter CLI validation for codec disagreement-rate, downsample fraction, and duplex error-rate ordering.
  • Tests

    • Expanded in-process sorting correctness (including spill scenarios) and hardened end-to-end pipeline parity for sorting, indexing, streaming input, and runall.
  • Documentation

    • Refreshed guidance on threading and memory (default: 768 MiB per thread) plus updated runall/simulation help text.

@nh13
nh13 temporarily deployed to github-actions June 24, 2026 18:30 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8486a22f-8923-42a0-b33b-1c00b6a2efd4

📥 Commits

Reviewing files that changed from the base of the PR and between 7765b9f and c13dc23.

📒 Files selected for processing (14)
  • benches/core_functions.rs
  • crates/fgumi-consensus/src/base_builder.rs
  • crates/fgumi-consensus/src/codec_caller.rs
  • crates/fgumi-pipeline-core/src/runtime/driver.rs
  • src/lib/aligner.rs
  • src/lib/commands/downsample.rs
  • src/lib/commands/runall.rs
  • src/lib/pipeline/chains/builder.rs
  • src/lib/pipeline/steps/coalesce.rs
  • src/lib/umi/parallel_assigner.rs
  • tests/integration/test_dedup_command.rs
  • tests/integration/test_runall_parity.rs
  • tests/integration/test_sort_correctness.rs
  • tests/integration/test_streaming_input.rs

Walkthrough

The PR updates CI, docs, runtime contracts, sort/index validation, comparator and validation behavior, and integration coverage to reflect typed-step pipeline semantics and stricter runtime/test assertions.

Changes

Typed-step pipeline and command surface

Layer / File(s) Summary
Docs and workflow surface
.github/workflows/check.yml, .gitignore, CHANGELOG.md, CLAUDE.md, docs/..., src/lib/commands/common.rs, src/lib/commands/correct.rs, src/lib/commands/filter.rs, src/lib/commands/simulate/mod.rs, src/lib/commands/zipper.rs, tests/integration/helpers/cli_runner.rs
CI now installs and verifies samtools; docs and help text describe the typed-step/runall flow, consensus feature split, simulate-aligner surface, and updated sort memory defaults.
Chain and runtime contracts
crates/fgumi-pipeline-core/src/*, src/lib/aligner.rs, src/lib/pipeline/chains/*, src/lib/commands/runall.rs, tests/integration/test_chain_build.rs, tests/integration/main.rs
Adds SerializedBytes, MonitorBlindTransport, derived-chain runall validation, aligner teardown hardening, and updated chain-build/runtime coverage.
Step behavior and pipeline I/O
src/lib/pipeline/steps/*
Tightens coalescing, rejects handling, extraction counts, pairing order, FASTQ/BAM framing, and header-merge behavior with new or updated tests.
Sort pipeline and BGZF/indexing
crates/fgumi-sort-cli/*, crates/fgumi-sort/src/worker_pool.rs, crates/fgumi-bgzf/src/writer.rs, crates/fgumi-pipeline-io/src/sort/*, tests/integration/test_sort_correctness.rs, tests/integration/test_sort_write_index.rs
Updates sort help text, BGZF recycling, spill decoding tests, and replaces fixture-based sort tests with in-process BAM generation plus explicit ordering oracles.
Comparator, UMI, and validation
crates/fgumi-raw-bam/src/sort.rs, crates/fgumi-raw-bam/src/tags.rs, crates/fgumi-umi/*, src/lib/commands/codec.rs, src/lib/commands/downsample.rs, src/lib/commands/filter.rs, src/lib/validation.rs, src/lib/fastq_parse.rs, src/lib/mi_group.rs, benches/core_functions.rs
Adds comparator equivalence checks, fixes invalid-UMI fallback, rejects non-finite validation inputs, enforces duplex ordering, and refactors benchmark setup and comments.
Integration build and parity harness
tests/integration/helpers/*, tests/integration/test_dedup_command.rs, tests/integration/test_runall_parity.rs, tests/integration/test_simulate_aligner.rs, tests/integration/test_streaming_input.rs, tests/integration/test_codec_command.rs
Adds non-empty/header-parity assertions, exact survivor checks, structured rejection testing, and stderr-capture coverage for simulate-aligner failures.

Estimated code review effort: 4 (Complex) | ~75 minutes

Possibly related PRs

Suggested labels: hygiene

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the PR’s main themes: correctness fixes, documentation cleanup, and expanded tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nh/runall-fix-6-review-docs-tests

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.60581% with 26 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feat-runall@f43bc2e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/lib/aligner.rs 56.25% 14 Missing ⚠️
src/lib/pipeline/steps/coalesce.rs 92.78% 7 Missing ⚠️
src/lib/mi_group.rs 0.00% 3 Missing ⚠️
src/lib/commands/runall.rs 99.39% 1 Missing ⚠️
src/lib/commands/zipper.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             feat-runall     #463   +/-   ##
==============================================
  Coverage               ?   94.25%           
==============================================
  Files                  ?      110           
  Lines                  ?    50089           
  Branches               ?        0           
==============================================
  Hits                   ?    47211           
  Misses                 ?     2878           
  Partials               ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nh13
nh13 force-pushed the nh/runall-fix-5-runall-consensus branch from c82d616 to ad680ab Compare June 25, 2026 04:22
@nh13
nh13 force-pushed the nh/runall-fix-6-review-docs-tests branch from 495f749 to 8a2456d Compare June 25, 2026 04:26
@nh13
nh13 temporarily deployed to github-actions June 25, 2026 04:26 — with GitHub Actions Inactive
@nh13
nh13 force-pushed the nh/runall-fix-5-runall-consensus branch from ad680ab to 71a68ca Compare June 25, 2026 05:32
@nh13
nh13 force-pushed the nh/runall-fix-6-review-docs-tests branch from 8a2456d to 347cac7 Compare June 25, 2026 05:32
@nh13
nh13 temporarily deployed to github-actions June 25, 2026 05:32 — with GitHub Actions Inactive
@nh13

nh13 commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Around line 25-31: The changelog entry for fgumi runall incorrectly suggests
it can start from extract, but runall’s documented stage range begins after
extraction. Update the wording in the runall bullet to describe it as the fused
post-extraction pipeline, and if mentioning end-to-end usage, reference the
composed fgumi extract | fgumi runall --start-from correct flow instead of
implying extract is part of runall.

In `@docs/src/guide/best-practices.md`:
- Around line 71-76: Clarify the `fgumi runall` tip so it does not read like an
end-to-end raw FASTQ pipeline: update the wording around `runall` in the
best-practices guide to state that it is post-extract only and starts after the
separate `extract` step, covering `correct`, `align`, `zipper`, `sort`, `group`,
and `consensus`. If helpful, mention the composed workflow explicitly or show
that `extract` must be run first, and keep the existing
`--start-from`/`--stop-after` guidance tied to `runall`.

In `@docs/src/index.md`:
- Around line 74-76: Update the `runall` entry in the command summary so it no
longer describes the pipeline as full FASTQ→consensus; revise the wording in the
table near `runall` to reflect that it starts post-extraction, such as
BAM→consensus, and keep the surrounding help text unchanged.

In `@tests/integration/test_runall_parity.rs`:
- Around line 902-939: `deterministic_simplex_fixture` is not actually
generating reads across multiple template-coordinate positions, so the
determinism test is weaker than intended. Update the fixture used by
`runall_simplex_record_stream_is_deterministic` to place each family at a
distinct position, using a positioned helper like `create_paired_umi_family_at`
or an equivalent single-end positioned builder instead of `create_umi_family`.
Keep the existing `Sort`/`run_standalone` flow, but ensure the generated BAM
spans many coordinates so `ByItemOrdinal` and worker-order nondeterminism are
exercised.

In `@tests/integration/test_sort_correctness.rs`:
- Around line 598-629: The test coordinate_sort_consistent_across_threads
currently only validates each thread count independently, so it does not enforce
the stated cross-thread consistency contract. Update this test to sort the same
input with threads set to 1, 2, and 4, then compare the resulting
coordinate-ordered record stream (or equivalent key sequence) across runs in
addition to keeping the existing sortedness and preservation checks. Use the
existing helpers fgumi_sort_in_process, verify_sorted,
assert_coordinate_ordered, and assert_records_preserved to keep the test focused
on comparing outputs rather than just self-validating each case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9a1914dc-e102-42b6-84a9-47db367af837

📥 Commits

Reviewing files that changed from the base of the PR and between 71a68ca and 347cac7.

📒 Files selected for processing (77)
  • .github/workflows/check.yml
  • .gitignore
  • CHANGELOG.md
  • CLAUDE.md
  • README.md
  • benches/core_functions.rs
  • crates/fgumi-bgzf/src/writer.rs
  • crates/fgumi-consensus/src/base_builder.rs
  • crates/fgumi-consensus/src/codec_caller.rs
  • crates/fgumi-consensus/src/duplex_caller.rs
  • crates/fgumi-pipeline-core/src/builder.rs
  • crates/fgumi-pipeline-core/src/handles.rs
  • crates/fgumi-pipeline-core/src/held.rs
  • crates/fgumi-pipeline-core/src/queues.rs
  • crates/fgumi-pipeline-core/src/reorder.rs
  • crates/fgumi-pipeline-core/src/runtime/driver.rs
  • crates/fgumi-pipeline-core/src/runtime/fused.rs
  • crates/fgumi-pipeline-core/src/runtime/pool.rs
  • crates/fgumi-pipeline-core/src/runtime/stats.rs
  • crates/fgumi-pipeline-core/src/runtime/worker_core.rs
  • crates/fgumi-pipeline-core/src/signal.rs
  • crates/fgumi-pipeline-core/src/step.rs
  • crates/fgumi-pipeline-io/src/sink/write_bgzf.rs
  • crates/fgumi-pipeline-io/src/sort/and_spill/tests.rs
  • crates/fgumi-pipeline-io/src/sort/merge.rs
  • crates/fgumi-pipeline-io/src/sort/protocol.rs
  • crates/fgumi-pipeline-io/src/source/read_bam.rs
  • crates/fgumi-raw-bam/src/sort.rs
  • crates/fgumi-raw-bam/src/tags.rs
  • crates/fgumi-sort-cli/Cargo.toml
  • crates/fgumi-sort-cli/src/sort.rs
  • crates/fgumi-sort/src/worker_pool.rs
  • crates/fgumi-umi/src/assigner.rs
  • docs/design/deterministic-mi-numbering.md
  • docs/simulate-cli.md
  • docs/src/guide/best-practices.md
  • docs/src/guide/performance-tuning.md
  • docs/src/index.md
  • src/lib/aligner.rs
  • src/lib/commands/codec.rs
  • src/lib/commands/common.rs
  • src/lib/commands/correct.rs
  • src/lib/commands/downsample.rs
  • src/lib/commands/filter.rs
  • src/lib/commands/runall.rs
  • src/lib/commands/simulate/mod.rs
  • src/lib/commands/zipper.rs
  • src/lib/fastq_parse.rs
  • src/lib/mi_group.rs
  • src/lib/pipeline/chains/build.rs
  • src/lib/pipeline/chains/builder.rs
  • src/lib/pipeline/chains/validate.rs
  • src/lib/pipeline/steps/align_and_merge.rs
  • src/lib/pipeline/steps/coalesce.rs
  • src/lib/pipeline/steps/correct/mod.rs
  • src/lib/pipeline/steps/correct/tests.rs
  • src/lib/pipeline/steps/extract.rs
  • src/lib/pipeline/steps/process.rs
  • src/lib/pipeline/steps/roundtrip.rs
  • src/lib/pipeline/steps/serialize_processed.rs
  • src/lib/pipeline/steps/source/pair_fastq.rs
  • src/lib/pipeline/steps/source/read_fastq.rs
  • src/lib/umi/parallel_assigner.rs
  • src/lib/validation.rs
  • tests/integration/helpers/assertions.rs
  • tests/integration/helpers/bam_generator.rs
  • tests/integration/helpers/cli_runner.rs
  • tests/integration/helpers/parity.rs
  • tests/integration/main.rs
  • tests/integration/test_chain_build.rs
  • tests/integration/test_codec_command.rs
  • tests/integration/test_dedup_command.rs
  • tests/integration/test_runall_parity.rs
  • tests/integration/test_simulate_aligner.rs
  • tests/integration/test_sort_correctness.rs
  • tests/integration/test_sort_write_index.rs
  • tests/integration/test_streaming_input.rs
💤 Files with no reviewable changes (2)
  • tests/integration/helpers/assertions.rs
  • crates/fgumi-sort-cli/Cargo.toml

Comment thread CHANGELOG.md Outdated
Comment thread docs/src/guide/best-practices.md Outdated
Comment thread docs/src/index.md Outdated
Comment thread tests/integration/test_runall_parity.rs
Comment thread tests/integration/test_sort_correctness.rs Outdated
@nh13
nh13 force-pushed the nh/runall-fix-5-runall-consensus branch from 71a68ca to a92836c Compare June 25, 2026 14:37
@nh13
nh13 force-pushed the nh/runall-fix-6-review-docs-tests branch from 347cac7 to e32c782 Compare June 25, 2026 14:37
@nh13
nh13 temporarily deployed to github-actions June 25, 2026 14:37 — with GitHub Actions Inactive
@nh13
nh13 force-pushed the nh/runall-fix-5-runall-consensus branch from a92836c to 46df46f Compare June 25, 2026 16:20
@nh13
nh13 force-pushed the nh/runall-fix-6-review-docs-tests branch from e32c782 to 4a150de Compare June 25, 2026 16:20
@nh13
nh13 temporarily deployed to github-actions June 25, 2026 16:20 — with GitHub Actions Inactive
@nh13
nh13 force-pushed the nh/runall-fix-5-runall-consensus branch from 46df46f to 6cf8aba Compare June 25, 2026 17:03
@nh13
nh13 force-pushed the nh/runall-fix-6-review-docs-tests branch from 4a150de to e7f4e25 Compare June 25, 2026 17:03
@nh13
nh13 temporarily deployed to github-actions June 25, 2026 17:03 — with GitHub Actions Inactive
@nh13
nh13 force-pushed the nh/runall-fix-5-runall-consensus branch from 6cf8aba to 1f4afc6 Compare June 25, 2026 17:57
@nh13
nh13 force-pushed the nh/runall-fix-6-review-docs-tests branch from e7f4e25 to e80bf2c Compare June 25, 2026 17:57
@nh13
nh13 temporarily deployed to github-actions June 25, 2026 17:57 — with GitHub Actions Inactive
@nh13
nh13 force-pushed the nh/runall-fix-5-runall-consensus branch from 1f4afc6 to 2d1a84e Compare June 25, 2026 18:45
@nh13
nh13 force-pushed the nh/runall-fix-6-review-docs-tests branch from e80bf2c to dcfc9a8 Compare June 25, 2026 18:45
Close runall parity/E2E gaps (stdin, FASTQ fusion, reject-discard, floors);
cover correct batch routing, header/desync invariants, methylation guards, and
coalesce flush; honest ChainTailKind variant, asserted MiKey invariant, testable
downsample bound; bench iter_batched.
@nh13

nh13 commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/pipeline/chains/builder.rs (1)

1504-1508: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Stale inline comments still claim add_align re-wires GroupByQueryname.

The rustdoc block above (1452-1456) was fixed per a prior review to state that add_align skips GroupByQueryname on an incoming BamTemplateBatch. These two inline comments inside add_correct still say the opposite ("add_align can wire GroupByQueryname → AlignAndMergeStep next"), which contradicts both the fixed doc and the actual add_align logic (line 1839: if chain_tail_kind == BamTemplateBatch { tail } else { append GroupByQueryname }).

🐛 Proposed fix
-        // `Intermediate` is used when correct feeds into align-and-merge
-        // (the `--start-from correct --stop-after ≥ zipper` fused chain).
-        // In that case we skip `SerializeBamRecords` and leave the tail at
-        // the correct step's `BamTemplateBatch` output (branch 0) so
-        // `add_align` can wire `GroupByQueryname → AlignAndMergeStep` next.
+        // `Intermediate` is used when correct feeds into align-and-merge
+        // (the `--start-from correct --stop-after ≥ zipper` fused chain).
+        // In that case we skip `SerializeBamRecords` and leave the tail at
+        // the correct step's `BamTemplateBatch` output (branch 0); `add_align`
+        // skips `GroupByQueryname` on an incoming `BamTemplateBatch` and wires
+        // `AlignAndMergeStep` directly.
-        } else {
-            // Intermediate: leave the tail as BamTemplateBatch so the next
-            // stage (add_align → GroupByQueryname → AlignAndMergeStep) can
-            // consume it directly.
+        } else {
+            // Intermediate: leave the tail as BamTemplateBatch so the next
+            // stage (add_align → AlignAndMergeStep, skipping GroupByQueryname)
+            // can consume it directly.

Also applies to: 1633-1635

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/pipeline/chains/builder.rs` around lines 1504 - 1508, Update the
stale inline comments in add_correct so they match the current add_align
behavior: when the chain tail is a BamTemplateBatch, add_align skips
GroupByQueryname instead of re-wiring it. Keep the wording consistent with the
corrected rustdoc above and the chain-tail logic in add_align, and revise the
comments near the Intermediate/SerializeBamRecords explanation as well as the
duplicate later comment block.
♻️ Duplicate comments (1)
tests/integration/test_sort_correctness.rs (1)

444-453: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Compare a per-record projection here, not just names.

Swapping R1/R2 inside an equal-name run still passes this oracle. Compare record_key(r) (or the full RecordBuf) against samtools so the natural-sort test pins exact output identity, not just qname grouping.

Suggested fix
 fn assert_name_order_matches(fgumi_out: &Path, samtools_out: &Path) {
-    let fgumi_names: Vec<Vec<u8>> =
-        read_records(fgumi_out).iter().map(|r| record_key(r).name).collect();
-    let samtools_names: Vec<Vec<u8>> =
-        read_records(samtools_out).iter().map(|r| record_key(r).name).collect();
-    assert_eq!(fgumi_names.len(), samtools_names.len(), "fgumi / samtools record count differs");
-    assert_eq!(
-        fgumi_names, samtools_names,
-        "fgumi read-name order disagrees with samtools (independent natural oracle)"
-    );
+    let fgumi_keys: Vec<RecordKey> = read_records(fgumi_out).iter().map(record_key).collect();
+    let samtools_keys: Vec<RecordKey> = read_records(samtools_out).iter().map(record_key).collect();
+    assert_eq!(fgumi_keys.len(), samtools_keys.len(), "fgumi / samtools record count differs");
+    assert_eq!(
+        fgumi_keys, samtools_keys,
+        "fgumi queryname-natural order disagrees with samtools on per-record identity"
+    );
 }

As per path instructions, "New correctness-critical behavior needs an INDEPENDENT oracle" and "Flag assertions weaker than the stated contract."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/test_sort_correctness.rs` around lines 444 - 453, The
oracle in assert_name_order_matches only compares record_key(r).name, so it can
miss per-record differences like swapped mates within the same name group.
Update the comparison to use a per-record projection that includes the full
identity you want to validate, such as record_key(r) itself or the full
RecordBuf, for both fgumi_out and samtools_out, and keep the count check plus
the direct equality assertion so the natural-sort test verifies exact output
identity rather than only qname order.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/commands/runall.rs`:
- Around line 563-567: The `sort` and `group` help text in `runall.rs` is too
absolute and implies fixed downstream stages even when `--stop-after` changes
the chain. Update the doc comments around the `sort`/`group` bullets to describe
only the input contract for each start point, and make the mention of following
stages conditional on `--stop-after` so the text aligns with the valid
`sort→sort` and `group→group` flows handled by the `runall` command logic.

In `@tests/integration/test_dedup_command.rs`:
- Around line 211-225: The test in test_dedup_command uses
alignment_start().unwrap().unwrap().get() and asserts 1-based coordinates, but
the inline projection comment still says 0-based positions 99/199. Update the
comment near the surviving/projection check to match the actual oracle values,
or adjust the projection/assertion to use a consistent coordinate system,
keeping the is_first_segment and is_reverse_complemented checks aligned with the
expected pair.

---

Outside diff comments:
In `@src/lib/pipeline/chains/builder.rs`:
- Around line 1504-1508: Update the stale inline comments in add_correct so they
match the current add_align behavior: when the chain tail is a BamTemplateBatch,
add_align skips GroupByQueryname instead of re-wiring it. Keep the wording
consistent with the corrected rustdoc above and the chain-tail logic in
add_align, and revise the comments near the Intermediate/SerializeBamRecords
explanation as well as the duplicate later comment block.

---

Duplicate comments:
In `@tests/integration/test_sort_correctness.rs`:
- Around line 444-453: The oracle in assert_name_order_matches only compares
record_key(r).name, so it can miss per-record differences like swapped mates
within the same name group. Update the comparison to use a per-record projection
that includes the full identity you want to validate, such as record_key(r)
itself or the full RecordBuf, for both fgumi_out and samtools_out, and keep the
count check plus the direct equality assertion so the natural-sort test verifies
exact output identity rather than only qname order.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bfbd8558-50df-42f9-b012-dd3b48808cf6

📥 Commits

Reviewing files that changed from the base of the PR and between 2360aa5 and 14bbc6f.

📒 Files selected for processing (75)
  • .github/workflows/check.yml
  • .gitignore
  • CHANGELOG.md
  • CLAUDE.md
  • benches/core_functions.rs
  • crates/fgumi-bgzf/src/writer.rs
  • crates/fgumi-consensus/src/base_builder.rs
  • crates/fgumi-consensus/src/codec_caller.rs
  • crates/fgumi-consensus/src/duplex_caller.rs
  • crates/fgumi-pipeline-core/src/builder.rs
  • crates/fgumi-pipeline-core/src/handles.rs
  • crates/fgumi-pipeline-core/src/held.rs
  • crates/fgumi-pipeline-core/src/queues.rs
  • crates/fgumi-pipeline-core/src/reorder.rs
  • crates/fgumi-pipeline-core/src/runtime/driver.rs
  • crates/fgumi-pipeline-core/src/runtime/fused.rs
  • crates/fgumi-pipeline-core/src/runtime/pool.rs
  • crates/fgumi-pipeline-core/src/runtime/stats.rs
  • crates/fgumi-pipeline-core/src/runtime/worker_core.rs
  • crates/fgumi-pipeline-core/src/signal.rs
  • crates/fgumi-pipeline-core/src/step.rs
  • crates/fgumi-pipeline-io/src/sink/write_bgzf.rs
  • crates/fgumi-pipeline-io/src/sort/and_spill/tests.rs
  • crates/fgumi-pipeline-io/src/sort/merge.rs
  • crates/fgumi-pipeline-io/src/sort/protocol.rs
  • crates/fgumi-pipeline-io/src/source/read_bam.rs
  • crates/fgumi-raw-bam/src/sort.rs
  • crates/fgumi-raw-bam/src/tags.rs
  • crates/fgumi-sort-cli/Cargo.toml
  • crates/fgumi-sort-cli/src/sort.rs
  • crates/fgumi-sort/src/worker_pool.rs
  • crates/fgumi-umi/src/assigner.rs
  • docs/design/deterministic-mi-numbering.md
  • docs/simulate-cli.md
  • docs/src/guide/best-practices.md
  • docs/src/guide/performance-tuning.md
  • src/lib/aligner.rs
  • src/lib/commands/codec.rs
  • src/lib/commands/common.rs
  • src/lib/commands/correct.rs
  • src/lib/commands/downsample.rs
  • src/lib/commands/filter.rs
  • src/lib/commands/runall.rs
  • src/lib/commands/simulate/mod.rs
  • src/lib/commands/zipper.rs
  • src/lib/fastq_parse.rs
  • src/lib/mi_group.rs
  • src/lib/pipeline/chains/build.rs
  • src/lib/pipeline/chains/builder.rs
  • src/lib/pipeline/chains/validate.rs
  • src/lib/pipeline/steps/align_and_merge.rs
  • src/lib/pipeline/steps/coalesce.rs
  • src/lib/pipeline/steps/correct/mod.rs
  • src/lib/pipeline/steps/correct/tests.rs
  • src/lib/pipeline/steps/extract.rs
  • src/lib/pipeline/steps/process.rs
  • src/lib/pipeline/steps/roundtrip.rs
  • src/lib/pipeline/steps/serialize_processed.rs
  • src/lib/pipeline/steps/source/pair_fastq.rs
  • src/lib/pipeline/steps/source/read_fastq.rs
  • src/lib/umi/parallel_assigner.rs
  • src/lib/validation.rs
  • tests/integration/helpers/assertions.rs
  • tests/integration/helpers/bam_generator.rs
  • tests/integration/helpers/cli_runner.rs
  • tests/integration/helpers/parity.rs
  • tests/integration/main.rs
  • tests/integration/test_chain_build.rs
  • tests/integration/test_codec_command.rs
  • tests/integration/test_dedup_command.rs
  • tests/integration/test_runall_parity.rs
  • tests/integration/test_simulate_aligner.rs
  • tests/integration/test_sort_correctness.rs
  • tests/integration/test_sort_write_index.rs
  • tests/integration/test_streaming_input.rs
💤 Files with no reviewable changes (2)
  • crates/fgumi-sort-cli/Cargo.toml
  • tests/integration/helpers/assertions.rs

Comment thread src/lib/commands/runall.rs Outdated
@nh13

nh13 commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/umi/parallel_assigner.rs`:
- Around line 1525-1561: The new invalid-UMI adjacency test only compares
AdjacencyUmiAssigner and ParallelAdjacencyAssigner against each other, so it can
miss a shared regression from fgbio. Update the adjacency invalid-UMI test
around adjacency_invalid_umi_maps_to_none_in_both_paths to include a
programmatic fgbio oracle for the mixed and all-invalid inputs, or reuse an
existing adjacency baseline that already covers these cases. Use the existing
assign() calls and MoleculeId assertions to verify both implementations still
match the expected fgbio behavior, especially that invalid UMIs map to
MoleculeId::None.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c428f68e-4797-4d49-b9d2-2dace5a5df35

📥 Commits

Reviewing files that changed from the base of the PR and between 14bbc6f and 0afd857.

📒 Files selected for processing (14)
  • benches/core_functions.rs
  • crates/fgumi-consensus/src/base_builder.rs
  • crates/fgumi-consensus/src/codec_caller.rs
  • crates/fgumi-pipeline-core/src/runtime/driver.rs
  • src/lib/aligner.rs
  • src/lib/commands/downsample.rs
  • src/lib/commands/runall.rs
  • src/lib/pipeline/chains/builder.rs
  • src/lib/pipeline/steps/coalesce.rs
  • src/lib/umi/parallel_assigner.rs
  • tests/integration/test_dedup_command.rs
  • tests/integration/test_runall_parity.rs
  • tests/integration/test_sort_correctness.rs
  • tests/integration/test_streaming_input.rs

Comment thread src/lib/umi/parallel_assigner.rs
@nh13

nh13 commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/pipeline/steps/coalesce.rs (1)

250-259: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Fixture can never exercise the "threshold + one block" overshoot the test claims to pin.

COALESCE_INPUT_BLOCK_BYTES (1000) evenly divides COALESCE_THRESHOLD_BYTES (8000). Step 3's threshold check fires only when pending.len() >= threshold_bytes, and since every increment is exactly 1000, pending can only ever land exactly on 8000 — never on 8001–8999. So every emitted block is exactly COALESCE_THRESHOLD_BYTES, and the sz <= per_block_ceiling check at line 437 never actually exercises the tighter "at most one input block past threshold" bound the comment at lines 376-381 describes; only a much grosser regression (a full MAX_BATCHES_PER_LOCK batch) would be caught here.

Use a block size that does not evenly divide the threshold (e.g. keep the block count/threshold ratio non-integral) so at least one flush genuinely overshoots COALESCE_THRESHOLD_BYTES by a partial block.

🐛 Proposed fix — make the last accumulation cycle overshoot by a partial block
-const COALESCE_INPUT_BLOCK_BYTES: usize = 1000;
-const COALESCE_THRESHOLD_BYTES: usize = 8 * COALESCE_INPUT_BLOCK_BYTES;
-const COALESCE_INPUT_BLOCKS: usize = 64 * 8;
+const COALESCE_INPUT_BLOCK_BYTES: usize = 1000;
+// Not a multiple of the block size: this forces `pending` to cross the
+// threshold mid-block on most flushes, so `sz` genuinely exceeds
+// `COALESCE_THRESHOLD_BYTES` and the `per_block_ceiling` bound is exercised
+// for real, not just trivially satisfied by an exact multiple.
+const COALESCE_THRESHOLD_BYTES: usize = 8 * COALESCE_INPUT_BLOCK_BYTES + 1;
+const COALESCE_INPUT_BLOCKS: usize = 64 * 8;

Also applies to: 364-451

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/pipeline/steps/coalesce.rs` around lines 250 - 259, The coalescing
fixture in coalesce.rs never hits the intended “threshold + one block” overshoot
because COALESCE_INPUT_BLOCK_BYTES divides COALESCE_THRESHOLD_BYTES exactly, so
the threshold check in the coalescing path only ever flushes at an exact
boundary. Adjust the test setup around COALESCE_INPUT_BLOCK_BYTES,
COALESCE_THRESHOLD_BYTES, and COALESCE_INPUT_BLOCKS so the input block size does
not evenly divide the threshold, ensuring at least one flush in the coalescer
overshoots by a partial block and the per-block ceiling assertion actually
verifies the intended bound.
♻️ Duplicate comments (1)
src/lib/commands/runall.rs (1)

429-439: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the stale ref_is_aligner_only help reference.

Line 438 names an internal exemption that no longer exists; reword this as “the derived-chain align/zipper exemption in execute”.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/commands/runall.rs` around lines 429 - 439, The help text for the
reference FASTA argument still mentions the stale internal `ref_is_aligner_only`
exemption. Update the documentation in `runall.rs` so it refers instead to the
derived-chain align/zipper exemption in `execute`, while keeping the rest of the
conditions described by the `validate_align_and_merge` and `Stage::Align` logic
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/integration/test_dedup_command.rs`:
- Around line 211-225: The surviving-pair assertion in the dedup integration
test is too weak because it only checks “not first” for the second mate, so a
malformed record could still pass. Update the projection and/or final assertion
in the test around surviving records to require flags.is_last_segment() for the
R2 mate (or explicitly assert one first and one last) alongside the existing
position and reverse-complement checks, using the rec.flags() projection in
test_dedup_command.rs.

---

Outside diff comments:
In `@src/lib/pipeline/steps/coalesce.rs`:
- Around line 250-259: The coalescing fixture in coalesce.rs never hits the
intended “threshold + one block” overshoot because COALESCE_INPUT_BLOCK_BYTES
divides COALESCE_THRESHOLD_BYTES exactly, so the threshold check in the
coalescing path only ever flushes at an exact boundary. Adjust the test setup
around COALESCE_INPUT_BLOCK_BYTES, COALESCE_THRESHOLD_BYTES, and
COALESCE_INPUT_BLOCKS so the input block size does not evenly divide the
threshold, ensuring at least one flush in the coalescer overshoots by a partial
block and the per-block ceiling assertion actually verifies the intended bound.

---

Duplicate comments:
In `@src/lib/commands/runall.rs`:
- Around line 429-439: The help text for the reference FASTA argument still
mentions the stale internal `ref_is_aligner_only` exemption. Update the
documentation in `runall.rs` so it refers instead to the derived-chain
align/zipper exemption in `execute`, while keeping the rest of the conditions
described by the `validate_align_and_merge` and `Stage::Align` logic unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9f7192c1-80dc-44c9-ace7-df5a975eb76e

📥 Commits

Reviewing files that changed from the base of the PR and between 0afd857 and 7765b9f.

📒 Files selected for processing (14)
  • benches/core_functions.rs
  • crates/fgumi-consensus/src/base_builder.rs
  • crates/fgumi-consensus/src/codec_caller.rs
  • crates/fgumi-pipeline-core/src/runtime/driver.rs
  • src/lib/aligner.rs
  • src/lib/commands/downsample.rs
  • src/lib/commands/runall.rs
  • src/lib/pipeline/chains/builder.rs
  • src/lib/pipeline/steps/coalesce.rs
  • src/lib/umi/parallel_assigner.rs
  • tests/integration/test_dedup_command.rs
  • tests/integration/test_runall_parity.rs
  • tests/integration/test_sort_correctness.rs
  • tests/integration/test_streaming_input.rs

Comment thread tests/integration/test_dedup_command.rs Outdated
Reject non-finite downsample fraction; fix parallel-assigner invalid-UMI parity
(invalid reads -> None in both paths); log aligner try_wait errors; mark the
terminal extract chain tail as SerializedBytes; strengthen oracles for dedup,
coalesce, sort, runall, streaming, and the driver round-robin path.
@nh13

nh13 commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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