Skip to content

fix(sort): address CodeRabbit review + de-duplicate cli-common helpers (#446) - #449

Merged
nh13 merged 4 commits into
feat-runallfrom
446/nh/fix-coderabbit-findings
Jun 22, 2026
Merged

fix(sort): address CodeRabbit review + de-duplicate cli-common helpers (#446)#449
nh13 merged 4 commits into
feat-runallfrom
446/nh/fix-coderabbit-findings

Conversation

@nh13

@nh13 nh13 commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

Stacked on #447. Addresses the CodeRabbit review of the sort-CLI extraction, plus a duplication cleanup in the new fgumi-cli-common crate. Base this on #447, not feat-runall — review/merge #447 first.

All of CodeRabbit's 20 findings were pre-existing (in fgumi-pipeline-core from #440, or in the verbatim-moved sort steps), not introduced by the extraction — #447 is byte-identical to the prior binary. This PR fixes the still-valid ones and skips the two that need a larger framework change.

Commits (read in order)

  1. refactor(cli-common): single-source shared CLI helpers via umbrella shims — the extraction had copied FgumiError/Result, validate_file_exists, parse_memory_size, OperationTimer, format_*, and detect_total_memory/detect_cpu_count into fgumi-cli-common while the umbrella kept its originals. This makes fgumi-cli-common the single source and turns errors.rs/logging.rs/system.rs/validation.rs into re-export shims (the pattern common.rs/command.rs already use), so there is now one FgumiError and no duplicated bodies (net −385 lines). Also hardens detect_total_memory's 32-bit fallback and adds resolve_memory_budget Auto-path tests.
  2. fix(pipeline-core): address correctness and robustness review findingsfixes the ByteBoundedQueue byte-counter race (reserve-before-push, roll back on failure — it could underflow and wedge backpressure), bounds the reorder overflow stash, defers worker-panic re-raise until monitor/rebalancer threads join, adds topology wire bounds checks, caps the worker backoff, and corrects Step/Affinity docs.
  3. test(pipeline-core): cover sticky-owner assignment, affinity dispatch, and chain wiring.
  4. fix(pipeline-io): guard sort memory-chunk count against u32 overflowchecked_add for memory_chunk_count so it panics rather than silently wrapping and corrupting the AllAnnounced count.

Per-finding disposition (20 CodeRabbit findings)

  • Fixed (18): both criticals (queues.rs race, and_spill u32 overflow) + handles stash cap, builder panic-cleanup ordering, topology bounds checks, worker_core backoff cap, erased build_two_input_handles rejoin, the two step.rs doc fixes, and the four test-coverage additions (pool, storage, contexts, resolve_memory_budget), plus the two cli-common findings (detect_total_memory fallback, resolve_memory_budget tests).
  • Skipped (2) — the CountBounded → ByteBounded pair (and_spill.rs, spill_decompress.rs): both sort steps use Outputs = Single<T>, whose build path rejects ByteBounded ("requires byte-aware build path"), so the suggested change panics every fused sort pipeline. The intent (memory-bound rather than count-bound backpressure on large MemoryChunk events) is legitimate but needs migrating the steps to the OrderedBytesSingle output shape — non-trivial. Left as CountBounded; worth a follow-up issue. (The u32 overflow guard from the same finding is applied.)
  • Skipped (1, folded into the above) — erased.rs "preserve ByItemOrdinal for Serial/Exclusive": applying it kept a reorder stage alive on already-ordered output and deadlocked every extract run. The original collapse-to-None is correct; kept it.

Verification

cargo build --release, cargo ci-test (2130 passed, 0 failed, 33 skipped), cargo ci-lint (clippy pedantic), cargo ci-fmt, and cargo check --workspace --no-default-features --all-targets all green. Sort output is unaffected (the changes are memory-accounting / docs / tests); the 80 sort tests including the fused coordinate and template-coordinate paths pass.

Summary by CodeRabbit

  • New Features
    • Allow pipeline steps to take both inputs from the same upstream step when they come from different branches.
    • Apply a default overflow-byte cap to ordered queue branches.
  • Bug Fixes
    • Improve pipeline worker panic propagation so failures surface after background helpers stop and join.
    • Fix byte-budget accounting for queue pushes by reserving before enqueue and rolling back on failure.
    • Harden memory/boolean parsing and memory budgeting with safer bounds and stricter wiring validation.
  • Performance
    • Reduce maximum worker backoff to 50 ms.
  • Documentation
    • Clarify affinity behavior and step progress/finished semantics.
  • Refactor
    • Consolidate shared CLI utilities for consistent error handling and formatting.

@nh13
nh13 temporarily deployed to github-actions June 20, 2026 04:00 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Jun 20, 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: abd5e4a5-8887-4594-9616-beca28c828b4

📥 Commits

Reviewing files that changed from the base of the PR and between 5262951 and c8c116f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (12)
  • crates/fgumi-pipeline-core/Cargo.toml
  • crates/fgumi-pipeline-core/src/builder.rs
  • crates/fgumi-pipeline-core/src/erased.rs
  • crates/fgumi-pipeline-core/src/handles.rs
  • crates/fgumi-pipeline-core/src/queues.rs
  • crates/fgumi-pipeline-core/src/runtime/contexts.rs
  • crates/fgumi-pipeline-core/src/runtime/pool.rs
  • crates/fgumi-pipeline-core/src/runtime/storage.rs
  • crates/fgumi-pipeline-core/src/runtime/worker_core.rs
  • crates/fgumi-pipeline-core/src/step.rs
  • crates/fgumi-pipeline-core/src/topology.rs
  • crates/fgumi-pipeline-io/src/sort/and_spill.rs

Walkthrough

Consolidates error types, logging utilities, system detection, and validation parsers from the umbrella crate into fgumi-cli-common with re-exports. Fixes pipeline worker panic propagation ordering (defer re-raise until after helper-thread cleanup), ByteBoundedQueue byte-reservation race (reserve-before-push atomicity), same-producer dual-branch wiring, reorder overflow caps, and topology defensive bounds checks. Reduces worker backoff cap to 50 ms, adds sort chunk-count overflow detection, and expands pipeline/pool/storage test coverage.

Changes

fgumi-cli-common consolidation and umbrella re-exports

Layer / File(s) Summary
Result aliases, Command trait, parse helpers
crates/fgumi-cli-common/src/lib.rs
Removes use anyhow::Result import; adds pub type Result<T> and FgumiResult<T> aliases over FgumiError; updates Command::execute to explicit anyhow::Result<()>; rewrites parse_memory, parse_memory_reserve, parse_bool, parse_memory_bytes to fully-qualified std::result::Result paths; adds #[must_use] to format_count.
Memory detection fix and budget tests
crates/fgumi-cli-common/src/lib.rs
Changes detect_total_memory fallback from usize::MAX to usize::MAX / 2 to permit overflow detection; adds two resolve_memory_budget_with_total unit tests for Auto path (below MIN_MEMORY_PER_THREAD floor and reserve-exceeds-total saturation).
Umbrella re-exports: errors, system, logging, validation
src/lib/errors.rs, src/lib/system.rs, src/lib/validation.rs, src/lib/logging.rs
Replaces local FgumiError enum, Result alias, system detection implementations, validate_file_exists/parse_memory_size, OperationTimer/format_duration/format_rate with pub use fgumi_cli_common::{...}; removes local implementations; adjusts discard logging in log_umi_grouping_summary; adds std::time::Duration to test imports.

Pipeline correctness fixes, defensive bounds, and test coverage

Layer / File(s) Summary
Worker panic deferred re-raise
crates/fgumi-pipeline-core/src/builder.rs
Captures first worker panic into worker_panic: Option<Box<dyn Any + Send>> instead of immediate resume_unwind. Single-threaded and multi-worker paths wrap run_worker_loop in catch_unwind; re-raises only after deadlock monitor and queue rebalancer are stopped and joined. Adds PanickingSink helper and two tests asserting panic propagation for threads: 1 and threads > 1.
ByteBoundedQueue reserve-before-push
crates/fgumi-pipeline-core/src/queues.rs
try_push now fetch_add bytes before ArrayQueue::push; rolls back with fetch_sub on push failure before returning Err(item). Removes post-push counter increment, fixing race condition where bytes could be reserved twice or lost on rejection.
Same-producer dual-branch wiring
crates/fgumi-pipeline-core/src/erased.rs
build_two_input_handles now handles p0_idx == p1_idx by asserting distinct branches and taking both handles from the same OutputQueueSet, removing unconditional p0_idx != p1_idx rejection.
Reorder overflow cap on ordered branches
crates/fgumi-pipeline-core/src/handles.rs
build_branch and build_branch_ordered pass Some(DEFAULT_REORDER_OVERFLOW_BYTES) instead of None for ByOrdinal/ByItemOrdinal on CountBounded and Unbounded queue specs, applying a default memory cap to reorder stages.
Topology defensive bounds checks
crates/fgumi-pipeline-core/src/topology.rs
wire_to_slot asserts consumer_input_slot against input arity; consumer_slot_index asserts producer and branch indices are in-range. New regression tests verify zero-arity source wiring panic and out-of-range consumer step panic with informative messages.
Step docs, backoff cap, and sort overflow
crates/fgumi-pipeline-core/src/step.rs, crates/fgumi-pipeline-core/src/runtime/worker_core.rs, crates/fgumi-pipeline-io/src/sort/and_spill.rs
Affinity::Worker doc changed to always-on panic for out-of-range indices; Step::try_run doc adds Finished to possible outcomes; BACKOFF_MAX_US reduced 1,000,000 → 50,000 µs; memory_chunk_count increment changed to checked_add with expect to panic on u32 overflow.
Pipeline test infrastructure and runtime tests
crates/fgumi-pipeline-core/Cargo.toml, crates/fgumi-pipeline-core/src/runtime/contexts.rs, crates/fgumi-pipeline-core/src/runtime/pool.rs, crates/fgumi-pipeline-core/src/runtime/storage.rs
Adds proptest and rstest dev-dependencies. contexts.rs tests add bounded_queues assertions and typed-handle downcasts for two- and three-step linear chains via rstest and proptest. pool.rs adds exclusive/serial sticky assignment tests with precedence verification. storage.rs adds AffinitySerialStep helper and Serial affinity eligibility tests including out-of-range panic detection.

Sequence Diagram(s)

sequenceDiagram
  participant RunLoop as Pipeline::run
  participant WorkerJoin as worker join()
  participant HelperStop as helper stop+join
  participant Caller
  RunLoop->>WorkerJoin: join each worker thread
  WorkerJoin-->>RunLoop: Err(panic) → store in worker_panic
  RunLoop->>HelperStop: stop deadlock monitor + rebalancer
  HelperStop-->>RunLoop: helpers cleaned up
  RunLoop->>Caller: resume_unwind(worker_panic) if Some
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • fulcrumgenomics/fgumi#440: Both PRs modify crates/fgumi-pipeline-core/src/builder.rs's Pipeline::run implementation, changing end-of-run error handling (main PR defers worker panic re-raise; retrieved PR updates signal-to-result conversion), creating potential merge conflict in final error propagation.

Suggested labels

fgumi sort, 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 clearly identifies the main change as fixing CodeRabbit review findings and de-duplicating cli-common helpers, which aligns with the PR's core objective of eliminating duplication and addressing pre-existing issues.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 446/nh/fix-coderabbit-findings

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

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (feat-runall@b898078). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             feat-runall     #449   +/-   ##
==============================================
  Coverage               ?   93.97%           
==============================================
  Files                  ?      109           
  Lines                  ?    48483           
  Branches               ?        0           
==============================================
  Hits                   ?    45564           
  Misses                 ?     2919           
  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 446/nh/fix-coderabbit-findings branch from 5409934 to 146b50d Compare June 20, 2026 17:16
@nh13
nh13 temporarily deployed to github-actions June 20, 2026 17:16 — with GitHub Actions Inactive
@nh13
nh13 force-pushed the 446/nh/feat-sort-cli branch 2 times, most recently from 2ae025e to e382c96 Compare June 20, 2026 22:45
@nh13
nh13 force-pushed the 446/nh/fix-coderabbit-findings branch from 146b50d to 939bcbc Compare June 21, 2026 01:22
@nh13
nh13 temporarily deployed to github-actions June 21, 2026 01:22 — with GitHub Actions Inactive
@nh13

nh13 commented Jun 21, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai resume

@nh13

nh13 commented Jun 21, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@coderabbitai

coderabbitai Bot commented Jun 21, 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 21, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 21, 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 `@crates/fgumi-pipeline-core/src/builder.rs`:
- Around line 906-908: The worker panic handling needs to defer unwinding across
all worker execution paths to ensure helper thread cleanup completes and prevent
deadlocks. Wrap each worker execution (in the n_threads == 1 path and all
multi-worker paths referenced at lines 936-943, 977-983, 1021-1024) with
std::panic::catch_unwind to capture panics. When catch_unwind returns an Err,
immediately set the pipeline terminal/cancel signal, store the panic payload in
the worker_panic variable, and continue execution to reach the common
monitor/rebalancer shutdown code. After all cleanup completes, call
std::panic::resume_unwind with the stored panic payload if it exists, ensuring
deferred panics unwind only after helper threads are properly cleaned up.

In `@crates/fgumi-pipeline-core/src/runtime/pool.rs`:
- Around line 223-302: Consolidate the multiple test functions
(sticky_exclusive_sets_owner_slot,
sticky_exclusive_out_of_range_owner_is_skipped,
sticky_exclusive_occupied_slot_not_overwritten,
sticky_serial_reader_affinity_targets_worker_0,
sticky_serial_writer_affinity_targets_last_worker,
sticky_serial_worker_affinity_targets_specific_worker,
sticky_serial_worker_out_of_range_is_skipped,
sticky_serial_affinity_none_is_skipped, and
sticky_exclusive_beats_sticky_serial_on_same_slot) into parameterized rstest
tests. Create separate parameterized test cases for exclusive owner assignment
scenarios and for serial affinity variants (Reader, Writer, Worker with specific
indices, Worker out of range, and None), grouping each family of tests under a
single rstest function with appropriate case inputs rather than individual test
functions.

In `@crates/fgumi-pipeline-core/src/runtime/storage.rs`:
- Around line 292-334: Refactor the four affinity eligibility test functions
(serial_reader_affinity_eligible_only_for_worker_0,
serial_writer_affinity_eligible_only_for_last_worker,
serial_worker_idx_affinity_eligible_only_for_target, and
serial_out_of_range_worker_panics_in_storage) into a single parameterized test
using the rstest framework. Use #[rstest] with a table of test cases that define
the affinity type (Reader, Writer, Worker(index)), the expected number of
workers (3), and the expected WorkerStepEntry outcomes for each worker position
(Shared or Skip). For the panic scenario, add a separate parameterized case with
#[should_panic] that tests the out-of-range worker index.

In `@crates/fgumi-pipeline-core/src/topology.rs`:
- Around line 94-100: The assertion checking consumer_input_slot validity uses
consumer_arity.max(1) which incorrectly allows slot 0 to be valid even for
source steps that are registered with input_arity = 0 (since 0.max(1) evaluates
to 1). This causes invalid producer→source edges to bypass topology validation.
Remove the max(1) call and compare consumer_input_slot directly against
consumer_arity to properly reject wiring attempts into zero-arity source steps.

In `@src/lib/logging.rs`:
- Around line 5-10: The `format_count` function is missing from the re-export
statement in the `pub use` line. Add `format_count` to the list of imports being
re-exported from `fgumi_cli_common` alongside `OperationTimer`,
`format_duration`, and `format_rate`. Additionally, check if there is a local
definition or separate import of `format_count` elsewhere in the logging module
and remove it, since the re-export from `fgumi_cli_common` should serve as the
single source of truth for this function.
🪄 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: 3f22a036-81ee-45e1-be9a-d5ecf8689b35

📥 Commits

Reviewing files that changed from the base of the PR and between e382c96 and 939bcbc.

📒 Files selected for processing (16)
  • crates/fgumi-cli-common/src/lib.rs
  • crates/fgumi-pipeline-core/src/builder.rs
  • crates/fgumi-pipeline-core/src/erased.rs
  • crates/fgumi-pipeline-core/src/handles.rs
  • crates/fgumi-pipeline-core/src/queues.rs
  • crates/fgumi-pipeline-core/src/runtime/contexts.rs
  • crates/fgumi-pipeline-core/src/runtime/pool.rs
  • crates/fgumi-pipeline-core/src/runtime/storage.rs
  • crates/fgumi-pipeline-core/src/runtime/worker_core.rs
  • crates/fgumi-pipeline-core/src/step.rs
  • crates/fgumi-pipeline-core/src/topology.rs
  • crates/fgumi-pipeline-io/src/sort/and_spill.rs
  • src/lib/errors.rs
  • src/lib/logging.rs
  • src/lib/system.rs
  • src/lib/validation.rs

Comment thread crates/fgumi-pipeline-core/src/builder.rs
Comment thread crates/fgumi-pipeline-core/src/runtime/pool.rs Outdated
Comment thread crates/fgumi-pipeline-core/src/runtime/storage.rs Outdated
Comment thread crates/fgumi-pipeline-core/src/topology.rs
Comment thread src/lib/logging.rs Outdated
@nh13
nh13 force-pushed the 446/nh/feat-sort-cli branch from e382c96 to 4e34b85 Compare June 21, 2026 06:11
nh13 added a commit that referenced this pull request Jun 21, 2026
Add reviews.auto_review.base_branches: ['.*'] so CodeRabbit also runs
automatic reviews on PRs whose base is this branch (e.g. #449), which is
not the repository default branch. Mirrors the same change on main (#453).
@nh13

nh13 commented Jun 21, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 21, 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 force-pushed the 446/nh/feat-sort-cli branch 4 times, most recently from 6af43c3 to b2a13ae Compare June 21, 2026 21:09
Base automatically changed from 446/nh/feat-sort-cli to feat-runall June 22, 2026 01:20
@nh13
nh13 force-pushed the 446/nh/fix-coderabbit-findings branch from 939bcbc to 0657455 Compare June 22, 2026 01:29
@nh13
nh13 temporarily deployed to github-actions June 22, 2026 01:29 — with GitHub Actions Inactive
@nh13

nh13 commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 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)
crates/fgumi-pipeline-core/src/runtime/contexts.rs (1)

334-405: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Duplicate scenario tests increase drift risk; parameterize and add an invariant property test.

Line 334 and Line 362 are the same test family expressed as hand-written cases; convert these to a single #[rstest] table and add one proptest that varies linear chain length/shape and asserts typed input-handle/downcast invariants plus bounded_queues expectations.

As per coding guidelines, "Use rstest for parameterized tests in Rust test files" and "Use proptest for property-based testing in Rust test files."

🤖 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 `@crates/fgumi-pipeline-core/src/runtime/contexts.rs` around lines 334 - 405,
The test functions build_chain_contexts_for_two_step_chain and
build_chain_contexts_three_step_linear contain duplicate test scenarios that
test similar functionality. Consolidate these into a single parameterized test
using #[rstest] that provides different chain lengths as input parameters to
avoid code duplication. Additionally, add a property-based test using proptest
that generates linear chains of varying lengths and shapes, asserting invariants
such as correct typed input-handle downcasts and bounded_queues expectations.
This approach reduces drift risk and improves test coverage.

Source: Coding guidelines

♻️ Duplicate comments (2)
crates/fgumi-pipeline-core/src/topology.rs (1)

96-97: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Zero-arity consumers are still wireable via slot 0; compare against raw arity.

consumer_arity.max(1) admits invalid producer→source edges (input_arity = 0). Compare directly to consumer_arity.

Proposed fix
-        assert!(
-            consumer_input_slot < consumer_arity.max(1),
+        assert!(
+            consumer_input_slot < consumer_arity,
             "consumer_input_slot {consumer_input_slot} out of range for step '{}' \
              with input_arity {consumer_arity}",
             self.step_names[consumer.0]
         );
🤖 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 `@crates/fgumi-pipeline-core/src/topology.rs` around lines 96 - 97, The
assertion checking consumer_input_slot bounds incorrectly uses
consumer_arity.max(1), which allows invalid connections for zero-arity
consumers. Remove the .max(1) call and compare consumer_input_slot directly
against the raw consumer_arity value to properly reject slot 0 connections when
the consumer has zero arity.
crates/fgumi-cli-common/src/lib.rs (1)

398-398: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Same is_multiple_of stability issue.

Line 398, 400, 402 also use is_multiple_of on usize. Apply the same % K == 0 fix.

🤖 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 `@crates/fgumi-cli-common/src/lib.rs` at line 398, Replace all three instances
of the `is_multiple_of` method calls with the modulo operator pattern. On line
398, 400, and 402 where `is_multiple_of(G)`, `is_multiple_of(M)`, and
`is_multiple_of(K)` are used respectively, replace each occurrence with the
equivalent `% [divisor] == 0` check (e.g., `bytes % G == 0` instead of
`bytes.is_multiple_of(G)`).
🤖 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 `@crates/fgumi-pipeline-io/src/sort/and_spill.rs`:
- Line 170: The panic contract documentation at line 170 is incomplete. It
currently only documents panics for spill slot overflow but does not mention the
memory chunk count overflow condition. Update the `# Panics` section of the doc
comment to include both conditions: panics if the number of spill slots exceeds
`u32::MAX` AND panics if the memory chunk count exceeds `u32::MAX`. Apply the
same documentation update to the panic contract mentioned at lines 193-194.

---

Outside diff comments:
In `@crates/fgumi-pipeline-core/src/runtime/contexts.rs`:
- Around line 334-405: The test functions
build_chain_contexts_for_two_step_chain and
build_chain_contexts_three_step_linear contain duplicate test scenarios that
test similar functionality. Consolidate these into a single parameterized test
using #[rstest] that provides different chain lengths as input parameters to
avoid code duplication. Additionally, add a property-based test using proptest
that generates linear chains of varying lengths and shapes, asserting invariants
such as correct typed input-handle downcasts and bounded_queues expectations.
This approach reduces drift risk and improves test coverage.

---

Duplicate comments:
In `@crates/fgumi-cli-common/src/lib.rs`:
- Line 398: Replace all three instances of the `is_multiple_of` method calls
with the modulo operator pattern. On line 398, 400, and 402 where
`is_multiple_of(G)`, `is_multiple_of(M)`, and `is_multiple_of(K)` are used
respectively, replace each occurrence with the equivalent `% [divisor] == 0`
check (e.g., `bytes % G == 0` instead of `bytes.is_multiple_of(G)`).

In `@crates/fgumi-pipeline-core/src/topology.rs`:
- Around line 96-97: The assertion checking consumer_input_slot bounds
incorrectly uses consumer_arity.max(1), which allows invalid connections for
zero-arity consumers. Remove the .max(1) call and compare consumer_input_slot
directly against the raw consumer_arity value to properly reject slot 0
connections when the consumer has zero arity.
🪄 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: 8b928c58-3890-438c-938d-6abda930d493

📥 Commits

Reviewing files that changed from the base of the PR and between 939bcbc and 0657455.

📒 Files selected for processing (16)
  • crates/fgumi-cli-common/src/lib.rs
  • crates/fgumi-pipeline-core/src/builder.rs
  • crates/fgumi-pipeline-core/src/erased.rs
  • crates/fgumi-pipeline-core/src/handles.rs
  • crates/fgumi-pipeline-core/src/queues.rs
  • crates/fgumi-pipeline-core/src/runtime/contexts.rs
  • crates/fgumi-pipeline-core/src/runtime/pool.rs
  • crates/fgumi-pipeline-core/src/runtime/storage.rs
  • crates/fgumi-pipeline-core/src/runtime/worker_core.rs
  • crates/fgumi-pipeline-core/src/step.rs
  • crates/fgumi-pipeline-core/src/topology.rs
  • crates/fgumi-pipeline-io/src/sort/and_spill.rs
  • src/lib/errors.rs
  • src/lib/logging.rs
  • src/lib/system.rs
  • src/lib/validation.rs

@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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

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)
crates/fgumi-pipeline-core/src/runtime/contexts.rs (1)

334-405: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Duplicate scenario tests increase drift risk; parameterize and add an invariant property test.

Line 334 and Line 362 are the same test family expressed as hand-written cases; convert these to a single #[rstest] table and add one proptest that varies linear chain length/shape and asserts typed input-handle/downcast invariants plus bounded_queues expectations.

As per coding guidelines, "Use rstest for parameterized tests in Rust test files" and "Use proptest for property-based testing in Rust test files."

🤖 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 `@crates/fgumi-pipeline-core/src/runtime/contexts.rs` around lines 334 - 405,
The test functions build_chain_contexts_for_two_step_chain and
build_chain_contexts_three_step_linear contain duplicate test scenarios that
test similar functionality. Consolidate these into a single parameterized test
using #[rstest] that provides different chain lengths as input parameters to
avoid code duplication. Additionally, add a property-based test using proptest
that generates linear chains of varying lengths and shapes, asserting invariants
such as correct typed input-handle downcasts and bounded_queues expectations.
This approach reduces drift risk and improves test coverage.

Source: Coding guidelines

♻️ Duplicate comments (2)
crates/fgumi-pipeline-core/src/topology.rs (1)

96-97: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Zero-arity consumers are still wireable via slot 0; compare against raw arity.

consumer_arity.max(1) admits invalid producer→source edges (input_arity = 0). Compare directly to consumer_arity.

Proposed fix
-        assert!(
-            consumer_input_slot < consumer_arity.max(1),
+        assert!(
+            consumer_input_slot < consumer_arity,
             "consumer_input_slot {consumer_input_slot} out of range for step '{}' \
              with input_arity {consumer_arity}",
             self.step_names[consumer.0]
         );
🤖 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 `@crates/fgumi-pipeline-core/src/topology.rs` around lines 96 - 97, The
assertion checking consumer_input_slot bounds incorrectly uses
consumer_arity.max(1), which allows invalid connections for zero-arity
consumers. Remove the .max(1) call and compare consumer_input_slot directly
against the raw consumer_arity value to properly reject slot 0 connections when
the consumer has zero arity.
crates/fgumi-cli-common/src/lib.rs (1)

398-398: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Same is_multiple_of stability issue.

Line 398, 400, 402 also use is_multiple_of on usize. Apply the same % K == 0 fix.

🤖 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 `@crates/fgumi-cli-common/src/lib.rs` at line 398, Replace all three instances
of the `is_multiple_of` method calls with the modulo operator pattern. On line
398, 400, and 402 where `is_multiple_of(G)`, `is_multiple_of(M)`, and
`is_multiple_of(K)` are used respectively, replace each occurrence with the
equivalent `% [divisor] == 0` check (e.g., `bytes % G == 0` instead of
`bytes.is_multiple_of(G)`).
🤖 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 `@crates/fgumi-pipeline-io/src/sort/and_spill.rs`:
- Line 170: The panic contract documentation at line 170 is incomplete. It
currently only documents panics for spill slot overflow but does not mention the
memory chunk count overflow condition. Update the `# Panics` section of the doc
comment to include both conditions: panics if the number of spill slots exceeds
`u32::MAX` AND panics if the memory chunk count exceeds `u32::MAX`. Apply the
same documentation update to the panic contract mentioned at lines 193-194.

---

Outside diff comments:
In `@crates/fgumi-pipeline-core/src/runtime/contexts.rs`:
- Around line 334-405: The test functions
build_chain_contexts_for_two_step_chain and
build_chain_contexts_three_step_linear contain duplicate test scenarios that
test similar functionality. Consolidate these into a single parameterized test
using #[rstest] that provides different chain lengths as input parameters to
avoid code duplication. Additionally, add a property-based test using proptest
that generates linear chains of varying lengths and shapes, asserting invariants
such as correct typed input-handle downcasts and bounded_queues expectations.
This approach reduces drift risk and improves test coverage.

---

Duplicate comments:
In `@crates/fgumi-cli-common/src/lib.rs`:
- Line 398: Replace all three instances of the `is_multiple_of` method calls
with the modulo operator pattern. On line 398, 400, and 402 where
`is_multiple_of(G)`, `is_multiple_of(M)`, and `is_multiple_of(K)` are used
respectively, replace each occurrence with the equivalent `% [divisor] == 0`
check (e.g., `bytes % G == 0` instead of `bytes.is_multiple_of(G)`).

In `@crates/fgumi-pipeline-core/src/topology.rs`:
- Around line 96-97: The assertion checking consumer_input_slot bounds
incorrectly uses consumer_arity.max(1), which allows invalid connections for
zero-arity consumers. Remove the .max(1) call and compare consumer_input_slot
directly against the raw consumer_arity value to properly reject slot 0
connections when the consumer has zero arity.
🪄 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: 8b928c58-3890-438c-938d-6abda930d493

📥 Commits

Reviewing files that changed from the base of the PR and between 939bcbc and 0657455.

📒 Files selected for processing (16)
  • crates/fgumi-cli-common/src/lib.rs
  • crates/fgumi-pipeline-core/src/builder.rs
  • crates/fgumi-pipeline-core/src/erased.rs
  • crates/fgumi-pipeline-core/src/handles.rs
  • crates/fgumi-pipeline-core/src/queues.rs
  • crates/fgumi-pipeline-core/src/runtime/contexts.rs
  • crates/fgumi-pipeline-core/src/runtime/pool.rs
  • crates/fgumi-pipeline-core/src/runtime/storage.rs
  • crates/fgumi-pipeline-core/src/runtime/worker_core.rs
  • crates/fgumi-pipeline-core/src/step.rs
  • crates/fgumi-pipeline-core/src/topology.rs
  • crates/fgumi-pipeline-io/src/sort/and_spill.rs
  • src/lib/errors.rs
  • src/lib/logging.rs
  • src/lib/system.rs
  • src/lib/validation.rs
🛑 Comments failed to post (1)
crates/fgumi-pipeline-io/src/sort/and_spill.rs (1)

170-170: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Panic contract is incomplete after adding checked_add for memory_chunk_count.

Update the # Panics docs to include memory-chunk-count overflow (u32::MAX), not only spill-slot overflow.

Proposed doc fix
-    /// Panics if the number of spill slots exceeds `u32::MAX`.
+    /// Panics if the number of spill slots or non-empty memory chunks
+    /// exceeds `u32::MAX`.

Also applies to: 193-194

🤖 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 `@crates/fgumi-pipeline-io/src/sort/and_spill.rs` at line 170, The panic
contract documentation at line 170 is incomplete. It currently only documents
panics for spill slot overflow but does not mention the memory chunk count
overflow condition. Update the `# Panics` section of the doc comment to include
both conditions: panics if the number of spill slots exceeds `u32::MAX` AND
panics if the memory chunk count exceeds `u32::MAX`. Apply the same
documentation update to the panic contract mentioned at lines 193-194.

…hims

Make fgumi-cli-common the authoritative home for the helpers the sort
extraction had duplicated (FgumiError/Result, validate_file_exists,
parse_memory_size, OperationTimer, format_duration/rate/count,
detect_total_memory/detect_cpu_count). The umbrella errors.rs, logging.rs,
system.rs, and validation.rs become re-export shims so existing call-site
paths resolve unchanged, leaving one FgumiError type and no duplicated
helper bodies. Also harden detect_total_memory's 32-bit fallback and add
resolve_memory_budget Auto-path test coverage (CodeRabbit).
@nh13
nh13 force-pushed the 446/nh/fix-coderabbit-findings branch from 0657455 to 5262951 Compare June 22, 2026 03:59
@nh13

nh13 commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 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 `@crates/fgumi-pipeline-core/src/topology.rs`:
- Around line 87-100: The wire_to_slot method accesses
self.input_arities[consumer.0] without first validating that the consumer index
is within bounds, which can result in an opaque out-of-bounds panic. Add an
explicit assertion at the beginning of the method to validate that consumer.0 is
within the valid range (less than the length of self.input_arities and
self.step_names) before attempting to access these arrays. This ensures any
topology validation failure produces a clear, deterministic error message rather
than a panic.
🪄 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: 25f8197d-58e6-4381-af7f-f233c302feb7

📥 Commits

Reviewing files that changed from the base of the PR and between 0657455 and 5262951.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (17)
  • crates/fgumi-cli-common/src/lib.rs
  • crates/fgumi-pipeline-core/Cargo.toml
  • crates/fgumi-pipeline-core/src/builder.rs
  • crates/fgumi-pipeline-core/src/erased.rs
  • crates/fgumi-pipeline-core/src/handles.rs
  • crates/fgumi-pipeline-core/src/queues.rs
  • crates/fgumi-pipeline-core/src/runtime/contexts.rs
  • crates/fgumi-pipeline-core/src/runtime/pool.rs
  • crates/fgumi-pipeline-core/src/runtime/storage.rs
  • crates/fgumi-pipeline-core/src/runtime/worker_core.rs
  • crates/fgumi-pipeline-core/src/step.rs
  • crates/fgumi-pipeline-core/src/topology.rs
  • crates/fgumi-pipeline-io/src/sort/and_spill.rs
  • src/lib/errors.rs
  • src/lib/logging.rs
  • src/lib/system.rs
  • src/lib/validation.rs

Comment thread crates/fgumi-pipeline-core/src/topology.rs
nh13 added 3 commits June 21, 2026 21:58
CodeRabbit findings: fix the ByteBoundedQueue byte-counter race
(reserve-before-push, roll back on failure) that could underflow and wedge
backpressure; bound the reorder overflow stash; defer worker-panic re-raise
until monitor/rebalancer threads are joined; add topology wire bounds
checks; cap the worker backoff; and correct the Step/Affinity docs.
…, and chain wiring

Add unit coverage for assign_sticky_owners, the affinity-gated Serial
dispatch eligibility, and build_chain_contexts wiring (CodeRabbit).
Use checked_add for memory_chunk_count so an overflow panics rather than
silently wrapping and corrupting the AllAnnounced count (CodeRabbit).
@nh13
nh13 force-pushed the 446/nh/fix-coderabbit-findings branch from 5262951 to c8c116f Compare June 22, 2026 05:00
@nh13
nh13 temporarily deployed to github-actions June 22, 2026 05:00 — with GitHub Actions Inactive
@nh13

nh13 commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 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 merged commit 59d15ee into feat-runall Jun 22, 2026
10 checks passed
@nh13
nh13 deleted the 446/nh/fix-coderabbit-findings branch June 22, 2026 15:34
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