Repository navigation
fix(review): keep dotted output prefixes intact - #1026
Conversation
review used Path::with_extension, so --output out.v1 wrote out.consensus.bam etc. Outputs now append to the full prefix, matching fgbio (ReviewConsensusVariants.scala:186-187). review also now refuses an output (either BAM, its .bai, or the .txt) that is the same file as an input or an input BAM's index, before any writer opens; previously -o s -c s.consensus.bam truncated the input mid-read. The shared prefix helper moves from commands::group to commands::common::append_suffix. It drops trailing separators, so out/ yields out.* rather than hidden out/.* files, and it now errors on a prefix that names no file (., .., out/.., /). The serial simplex-/duplex-metrics paths share the inline collector's file names and writer and pass paths to R as OsStr, so they name files exactly as the --threads path does. Changes output for: review with a dotted --output prefix; metrics prefixes ending in a path separator (group/simplex/duplex/codec --metrics, runall --all-metrics and per-stage --metrics, simplex-/duplex-metrics --output). Prefixes naming no file are now an error for all of these.
|
Note Reviews pausedUse the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (14)
Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. WalkthroughMetrics and review outputs now append suffixes to full prefixes, preserve dotted names, and drop trailing separators. Shared path helpers reject prefixes that do not identify a file. Metrics writers use shared path and write helpers. Review checks output paths against inputs before opening writers. ChangesOutput path handling
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~40 minutes Change: Bug fix Suggested labels: Merge Risk: ⚪ Minimal · up to The change makes output naming preserve dotted prefixes and adds a guard against overwriting inputs. No concrete merge-blocking risk was identified in the supplied context. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Comment |
|
@coderabbitai pause |
✅ Action performedReviews paused. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1026 +/- ##
==========================================
- Coverage 96.47% 96.45% -0.03%
==========================================
Files 299 299
Lines 152214 152321 +107
==========================================
+ Hits 146854 146914 +60
- Misses 5360 5407 +47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
fgumi reviewbuilt its output paths withPath::with_extension, which replaces the last dotted component of--outputinstead of appending to it.--output out.v1wroteout.consensus.bam,out.grouped.bam,out.txt(and.bam.baisidecars) instead ofout.v1.*, so the outputs ofout.v1andout.v2overwrote each other. Every output now goes throughReview::output_path, which appends.{suffix}to the full prefix, as fgbio does.reviewalso had no output-vs-input guard:-o s -c s.consensus.bamtruncated the consensus BAM while it was still being read. Before any writer opens,reviewnow rejects any output (either BAM, its.bai, or the.txt) that is the same file as--input,--consensus-bam,--grouped-bam,--refor an input BAM's index. It uses the existingreject_writes_aliasing_inputs(dev+inode), so symlinks and hard links are caught too.The shared prefix helper moves from
commands::group::with_extensiontocommands::common::append_suffix, next to the other output-path guards. It drops trailing separators (and a trailing.component), soout/yieldsout.<suffix>beside the prefix, as fgbio'sPathnormalization does, instead of hiddenout/.<suffix>files. It now returns an error for a prefix that names no file (.,./,..,out/..,/, empty), which previously wrote dot-named files such as/.txt. Every caller propagates that error early, before any input is read:review,group --metrics,simplex/duplex/codec --metrics,runall --all-metricsand per-stage--metrics, andsimplex-/duplex-metrics --output.Each metrics file set is now named in one place.
group_metrics_pathscovers group, andSimplexMetricsPaths/DuplexMetricsPathsin the inline metrics collector cover simplex/duplex/codec. The serialsimplex-metrics/duplex-metricspaths use the collector's writer (write_simplex_metrics/write_duplex_metrics) instead of their own copy. They also keep paths asPathBuf:execute_r_scriptnow takesAsRef<OsStr>args, so a non-UTF-8 prefix gets the same names on the serial path as on--threads. The--output/--metrics/--all-metricshelp now states the append, separator-dropping and must-name-a-file rules.Changes output for:
reviewwhen the final component of--outputcontains a dot; metrics file names when the prefix ends in a path separator or.component (group --metrics,simplex/duplex/codec --metrics,runall --all-metricsand per-stage--metrics,simplex-/duplex-metrics --outputincluding the PDF). A prefix that names no file is now an error for all of these.fgbio parity (e51a661)
ReviewConsensusVariants.scala:186-187,212builds every output asoutput.getParent.resolve(s"${output.getFileName}${ext}"), which is the full file name plus the extension.ReviewConsensusVariantsTest.scala:188uses the dotted prefixreview_consensus.<n>.outand expects<outBase>.consensus.bam,.grouped.bamand.txt, all empty..bam.baisidecars are the documented REV3-12 divergence.Tests
review_output_prefix_with_dots_is_preservedports fgbio:188, plus a trailing-separator case. It checks the exact set of files written and that they are empty.test_review_output_path_extensionscovers plain, dotted and trailing-separator prefixes. The integration test runs the CLI with a dotted prefix and checks that none of the old names are written.test_review_rejects_an_output_that_aliases_an_inputchecks the exact error for each aliasing combination: consensus/grouped BAM (plain, dotted, trailing separator), the review.txtvs--input/--ref, each output.baivs--input, and an output.bailanding on an input BAM's.bai. The dotted cases collide only because the whole prefix is now kept. It also asserts that nothing is written.test_review_rejects_an_input_symlinked_to_an_outputcovers identity through a symlink.append_suffix_appends_to_the_full_prefixandappend_suffix_rejects_a_prefix_that_names_no_file(incommon.rs) assert exact strings and exact errors.test_review_rejects_a_prefix_that_names_no_fileandall_metrics_rejects_a_prefix_that_names_no_file(runall) check the same error through the commands.all_metrics_fills_only_group_metrics_prefixcovers--all-metrics all/→all.group.test_metrics_prefix_with_trailing_separator_collides_with_outputchecks that group's--outputcollision guard sees--metrics out/asout.*. The existing--metrics out/naming tests for group and simplex-/duplex-metrics (serial and--threads) still pass.Mutation-checked. Disabling the must-name-a-file check fails all 18 rejection cases. Disabling the review alias guard fails all 11 alias cases. Dropping the
.baioutputs and input-index entries from the guard fails exactly the three sidecar/index cases.Checks
cargo ci-fmt,cargo ci-lint,cargo ci-doc,cargo ci-tag-literals,cargo nextest run --workspace(10331 passed, 31 skipped).Risk: Output filenames change for review, grouping, consensus, and metrics;
append_suffixplus targeted naming and collision tests pin the change.unsafe: not established from the supplied summary; CLAUDE.md allowlist status is also not established. Memory bounds, queue capacity, and thread/backpressure policy: none reported.Fix: Append suffixes to the full output prefix and reject output paths that alias protected inputs before opening writers. The change also centralizes metrics paths and shares metric writers across serial and threaded paths.
Test results and current review findings were not supplied.