Repository navigation
[FIX] 14 boundary/serialization/state-consistency fixes from the #9767 audit - #9790
Conversation
📝 WalkthroughWalkthroughThis PR fixes state initialization and reset behavior, empty-input handling, identification grouping, numeric parsing, iterator bounds, range calculations, equality checks, and format-specific edge cases. Regression tests and fixtures cover the corrected behaviors. ChangesOpenMS correctness fixes
Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/openms/source/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.cpp (1)
72-78: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winReset the map count when clearing
KDTreeFeatureMaps.
clear()removes feature state but preserves the oldnum_maps_, so a cleared object reports stale map-count information.
src/openms/source/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.cpp#L72-L78: assignnum_maps_ = 0inclear().src/tests/class_tests/openms/source/KDTreeFeatureMaps_test.cpp#L139-L152: assertnumMaps() == 0immediately afterclear().🤖 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/openms/source/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.cpp` around lines 72 - 78, Update KDTreeFeatureMaps::clear() to reset num_maps_ to zero alongside the other cleared state. In src/openms/source/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.cpp lines 72-78, add this reset; in src/tests/class_tests/openms/source/KDTreeFeatureMaps_test.cpp lines 139-152, assert numMaps() equals zero immediately after clear().src/openms/source/FORMAT/OMSSACSVFile.cpp (1)
68-78: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winReject unterminated quoted fields explicitly.
When no closing quote exists, the loop exits with
it == line.end(), but parsing continues andoffsetis still used. The column-count check can therefore accept malformed rows or parse shifted fields, contradicting the new regression test’s expectedException::ParseError.while (++it != line.end() && *it != '"') { if (*it == ',') { offset++; } } + if (it == line.end()) + { + throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, + line, "unterminated quoted field"); + }🤖 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/openms/source/FORMAT/OMSSACSVFile.cpp` around lines 68 - 78, Update the quoted-field scanning logic before StringUtils::split in the OMSSACSV parsing flow to detect when the iterator reaches line.end() without finding a closing quote and throw Exception::ParseError immediately. Only use offset for rows with properly terminated quoted fields, while preserving the existing column-count validation for valid input.src/openms/source/FORMAT/QcMLFile.cpp (1)
770-776: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winClear the set-member name accumulator at reparse boundaries.
names_is populated fromMS:1000577set members and copied intosetQualityQPs_members_byregisterSet(...), but it is not reset byload()or at thesetQualityboundary. Reusing the parser can carry over stale set members across reloads or multiple sets in one file. Addnames_.clear()with the other cleared per-load/per-set state.🤖 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/openms/source/FORMAT/QcMLFile.cpp` around lines 770 - 776, Update the parser reset logic in load() and at the setQuality boundary to clear names_ alongside runQualityQPs_, setQualityQPs_, and setQualityQPs_members_. Ensure each reload and new set starts with an empty set-member name accumulator before registerSet(...) populates it.
🧹 Nitpick comments (3)
src/tests/class_tests/openms/source/KDTreeFeatureMaps_test.cpp (1)
139-152: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert that
clear()resets the map count.Add
TEST_EQUAL(kd_data_3.numMaps(), 0)immediately afterclear()so this regression also detects stalenum_maps_state.🤖 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/tests/class_tests/openms/source/KDTreeFeatureMaps_test.cpp` around lines 139 - 152, Update the clear() test for kd_data_3 by adding an assertion immediately after kd_data_3.clear() that kd_data_3.numMaps() equals 0, while preserving the existing size, treeSize, and RT reset assertions.src/tests/class_tests/openms/source/QTClusterFinder_test.cpp (1)
226-241: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the single-partition empty-input path.
This test only exercises the default multi-partition branch. Add a case configured with
nr_partitions == 1; otherwise the remaining empty-input failure throughrun_internal_()is not detected.🤖 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/tests/class_tests/openms/source/QTClusterFinder_test.cpp` around lines 226 - 241, Add a second regression case in the QTClusterFinder run() tests using two empty FeatureMaps and configuring nr_partitions to 1 before invoking run(). Assert that the resulting ConsensusMap remains empty, ensuring the single-partition run_internal_() path is covered alongside the existing default multi-partition case.src/openms/source/FORMAT/ArrowIOHelpers.cpp (1)
234-235: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the required multiline brace style for the changed exception handling.
Proposed fix
- try { target.setMetaValue(name, static_cast<SignedSize>(std::stoll(value_str))); } - catch (...) { target.setMetaValue(name, value_str); } + try + { + target.setMetaValue(name, static_cast<SignedSize>(std::stoll(value_str))); + } + catch (...) + { + target.setMetaValue(name, value_str); + }As per coding guidelines, “Place opening and closing braces on their own lines, aligned with the surrounding code.”
🤖 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/openms/source/FORMAT/ArrowIOHelpers.cpp` around lines 234 - 235, Update the exception handling around the stoll conversion in the metadata assignment so the try and catch blocks use multiline braces, placing each opening and closing brace on its own line and aligning them with the surrounding code. Preserve the existing numeric conversion and string fallback behavior.Source: Coding guidelines
🤖 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/openms/source/ANALYSIS/ID/IDScoreGetterSetter.cpp`:
- Around line 71-74: Update the score replacement logic in the surrounding ID
score getter/setter flow so equal scores between target and decoy entries
deterministically retain the target label, matching getPickedProteinScores_.
Preserve the existing isFirstBetterScore_ behavior for unequal scores and update
the stored score/label only when the score is better or the tie-break favors
is_target.
In `@src/openms/source/ANALYSIS/MAPMATCHING/QTClusterFinder.cpp`:
- Around line 267-275: In
src/openms/source/ANALYSIS/MAPMATCHING/QTClusterFinder.cpp:267-275, make the
empty massrange check return before the nr_partitions_ == 1 branch, so
run_internal_ is never called with empty input; preserve the existing result_map
clearing behavior. In
src/tests/class_tests/openms/source/QTClusterFinder_test.cpp:226-241, add
coverage configuring nr_partitions to 1 and verifying empty input completes
without throwing.
In `@src/tests/class_tests/openms/source/OMSSACSVFile_test.cpp`:
- Around line 57-66: Replace tab indentation with two spaces in the added
regression test block for OMSSACSVFile, including its comments, declarations,
and TEST_EXCEPTION call; do not alter the test behavior or surrounding code.
---
Outside diff comments:
In `@src/openms/source/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.cpp`:
- Around line 72-78: Update KDTreeFeatureMaps::clear() to reset num_maps_ to
zero alongside the other cleared state. In
src/openms/source/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.cpp lines 72-78, add
this reset; in src/tests/class_tests/openms/source/KDTreeFeatureMaps_test.cpp
lines 139-152, assert numMaps() equals zero immediately after clear().
In `@src/openms/source/FORMAT/OMSSACSVFile.cpp`:
- Around line 68-78: Update the quoted-field scanning logic before
StringUtils::split in the OMSSACSV parsing flow to detect when the iterator
reaches line.end() without finding a closing quote and throw
Exception::ParseError immediately. Only use offset for rows with properly
terminated quoted fields, while preserving the existing column-count validation
for valid input.
In `@src/openms/source/FORMAT/QcMLFile.cpp`:
- Around line 770-776: Update the parser reset logic in load() and at the
setQuality boundary to clear names_ alongside runQualityQPs_, setQualityQPs_,
and setQualityQPs_members_. Ensure each reload and new set starts with an empty
set-member name accumulator before registerSet(...) populates it.
---
Nitpick comments:
In `@src/openms/source/FORMAT/ArrowIOHelpers.cpp`:
- Around line 234-235: Update the exception handling around the stoll conversion
in the metadata assignment so the try and catch blocks use multiline braces,
placing each opening and closing brace on its own line and aligning them with
the surrounding code. Preserve the existing numeric conversion and string
fallback behavior.
In `@src/tests/class_tests/openms/source/KDTreeFeatureMaps_test.cpp`:
- Around line 139-152: Update the clear() test for kd_data_3 by adding an
assertion immediately after kd_data_3.clear() that kd_data_3.numMaps() equals 0,
while preserving the existing size, treeSize, and RT reset assertions.
In `@src/tests/class_tests/openms/source/QTClusterFinder_test.cpp`:
- Around line 226-241: Add a second regression case in the QTClusterFinder run()
tests using two empty FeatureMaps and configuring nr_partitions to 1 before
invoking run(). Assert that the resulting ConsensusMap remains empty, ensuring
the single-partition run_internal_() path is covered alongside the existing
default multi-partition 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4755b1e3-bddb-48c9-8f5f-6e287edd7e49
⛔ Files ignored due to path filters (1)
src/tests/class_tests/openms/data/OMSSACSVFile_test_unbalanced_quote.csvis excluded by!**/*.csv
📒 Files selected for processing (32)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.hsrc/openms/source/ANALYSIS/ID/IDScoreGetterSetter.cppsrc/openms/source/ANALYSIS/MAPMATCHING/FeatureGroupingAlgorithmKD.cppsrc/openms/source/ANALYSIS/MAPMATCHING/QTClusterFinder.cppsrc/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFilter.cppsrc/openms/source/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.cppsrc/openms/source/CHEMISTRY/TheoreticalSpectrumGenerator.cppsrc/openms/source/DATASTRUCTURES/CalibrationData.cppsrc/openms/source/FORMAT/ArrowIOHelpers.cppsrc/openms/source/FORMAT/Base64.cppsrc/openms/source/FORMAT/FeatureMapArrowIO.cppsrc/openms/source/FORMAT/MzTab.cppsrc/openms/source/FORMAT/OMSSACSVFile.cppsrc/openms/source/FORMAT/QcMLFile.cppsrc/openms/source/KERNEL/ConsensusFeature.cppsrc/openms/source/QC/TIC.cppsrc/tests/class_tests/openms/data/QcMLFile_reload_A.qcMLsrc/tests/class_tests/openms/data/QcMLFile_reload_B.qcMLsrc/tests/class_tests/openms/source/Base64_test.cppsrc/tests/class_tests/openms/source/CalibrationData_test.cppsrc/tests/class_tests/openms/source/ConsensusFeature_test.cppsrc/tests/class_tests/openms/source/FalseDiscoveryRate_test.cppsrc/tests/class_tests/openms/source/FeatureGroupingAlgorithmKD_test.cppsrc/tests/class_tests/openms/source/FeatureMapArrowIO_test.cppsrc/tests/class_tests/openms/source/KDTreeFeatureMaps_test.cppsrc/tests/class_tests/openms/source/MRMFeatureFilter_test.cppsrc/tests/class_tests/openms/source/MzTab_test.cppsrc/tests/class_tests/openms/source/OMSSACSVFile_test.cppsrc/tests/class_tests/openms/source/QTClusterFinder_test.cppsrc/tests/class_tests/openms/source/QcMLFile_test.cppsrc/tests/class_tests/openms/source/TIC_test.cppsrc/tests/class_tests/openms/source/TheoreticalSpectrumGenerator_test.cpp
…audit Fixes 14 of the "no-doubt, easy" defects catalogued in the implementation- consistency audit #9767. Each fix is small and localized, ships with a focused regression test that fails (crash/hang/assert) before and passes after, and preserves behavior on valid inputs (only the buggy edge cases change). The set was reviewed with Codex and CodeRabbit; their findings are incorporated below. Boundary / crash / underflow: - #4 QTClusterFinder / FeatureGroupingAlgorithmKD: guard the empty mass range so feature-empty input maps don't dereference front()/back()/size()-1. The guards run before the linking work: KD calls postprocess_() first so per-map protein/unassigned-peptide IDs survive; QT returns before the single-partition branch, whose setParameters_() otherwise throws on the empty maps' invalid max m/z (the <2-maps case is validated by the caller). - #5 TheoreticalSpectrumGenerator: internal-fragment loop bound underflowed for peptides shorter than 4 (l < size-1-2) -> use additive l+3 < size. - #18 MzTab nextPSMRow (both streams): empty hit list underflowed size()-1 and looped forever with export_all_psms -> use current_psm_idx_+1 >= size(). - #30 OMSSACSVFile::load: bound the quote-skipping scan by line.end(). Correctness (wrong field / sentinel / flag): - #3 IDScoreGetterSetter::addToPeptideScoreMap_: the try_emplace "inserted" flag was misused, so a duplicated sequence never kept a later better score. Now updates BOTH the score and its target/decoy label, and resolves equal-score target/decoy ties to the target (matching getPickedProteinScores_), so the peptide-level representative is deterministic and input-order independent. - #6 MRMFeatureFilter: group retention_time_u %RSD read the _l mean/variance. - #12 ConsensusFeature range max sentinel minPositive() -> minNegative(). - #35 TIC::Result::operator== now includes relative_intensities. Serialization round-trip: - #17 Base64::decodeStrings: keep length-1 segments (dropped single-char strings). Also updates the malformed "====" corrupted-input expectation (now decodes to one placeholder byte instead of being silently dropped). - #19 ArrowIOHelpers: parse int meta with stoll -> SignedSize (was 32-bit). - #20 FeatureMapArrowIO::importPSMsFromArrow: group PSM rows by P_ID value, not by row adjacency (matches QPXFile/ConsensusMapArrowIO). Stale-state on reload / clear: - #27 QcMLFile::load: also clear derived run_/set_Name_ID_map_. - #32 CalibrationData::clear: also clear groups_. - #33 KDTreeFeatureMaps: init num_maps_{0}; clear() also clears rt_ cache. Not included: #1 (=#9488 PROC-23, already in open PR #9616); #2 (correct but the pooled split-charge FDR path has order-dependent side effects that preclude a clean regression test in isolation); #7 (percentile index -- verified NOT a bug: the "-1" is part of the double expression, so the negative value truncates to 0, no underflow); #38 (TOPP-tool aux-array desync, needs a CLI test). Remaining audit items need an API/deprecate decision. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
22a2fea to
4f3e0f5
Compare
|
Thanks for the review. Addressed all three inline findings in the latest push (
All 14 fix-tests still pass locally. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/openms/source/FORMAT/FeatureMapArrowIO.cpp (1)
1546-1550: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse OpenMS primitive types for the new lookup state.
The added
std::unordered_map<int32_t, size_t>,int64_t row,int32_t p_id, andsize_t gidxshould useInt32,Int64, andSizefromOpenMS/CONCEPT/Types.h.Proposed fix
- std::unordered_map<int32_t, size_t> p_id_to_idx; + std::unordered_map<Int32, Size> p_id_to_idx; - for (int64_t row = 0; row < num_rows; ++row) + for (Int64 row = 0; row < num_rows; ++row) ... - int32_t p_id = getInt32Value_(col_p_id, row, -1); + Int32 p_id = getInt32Value_(col_p_id, row, -1); ... - const size_t gidx = pid_it->second; + const Size gidx = pid_it->second;As per coding guidelines, use OpenMS primitive types from
OpenMS/CONCEPT/Types.hinstead of standard C++ types.Also applies to: 1621-1621
🤖 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/openms/source/FORMAT/FeatureMapArrowIO.cpp` around lines 1546 - 1550, Replace the new lookup-state types in the surrounding FeatureMapArrowIO logic with OpenMS aliases: use Int32 for p_id and the map key, Int64 for row, and Size for gidx and the map value. Ensure the relevant declarations consistently use these types from OpenMS/CONCEPT/Types.h.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@src/openms/source/FORMAT/FeatureMapArrowIO.cpp`:
- Around line 1546-1550: Replace the new lookup-state types in the surrounding
FeatureMapArrowIO logic with OpenMS aliases: use Int32 for p_id and the map key,
Int64 for row, and Size for gidx and the map value. Ensure the relevant
declarations consistently use these types from OpenMS/CONCEPT/Types.h.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 360301a9-4703-4223-8cac-c7682c3f2da4
⛔ Files ignored due to path filters (1)
src/tests/class_tests/openms/data/OMSSACSVFile_test_unbalanced_quote.csvis excluded by!**/*.csv
📒 Files selected for processing (32)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.hsrc/openms/source/ANALYSIS/ID/IDScoreGetterSetter.cppsrc/openms/source/ANALYSIS/MAPMATCHING/FeatureGroupingAlgorithmKD.cppsrc/openms/source/ANALYSIS/MAPMATCHING/QTClusterFinder.cppsrc/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFilter.cppsrc/openms/source/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.cppsrc/openms/source/CHEMISTRY/TheoreticalSpectrumGenerator.cppsrc/openms/source/DATASTRUCTURES/CalibrationData.cppsrc/openms/source/FORMAT/ArrowIOHelpers.cppsrc/openms/source/FORMAT/Base64.cppsrc/openms/source/FORMAT/FeatureMapArrowIO.cppsrc/openms/source/FORMAT/MzTab.cppsrc/openms/source/FORMAT/OMSSACSVFile.cppsrc/openms/source/FORMAT/QcMLFile.cppsrc/openms/source/KERNEL/ConsensusFeature.cppsrc/openms/source/QC/TIC.cppsrc/tests/class_tests/openms/data/QcMLFile_reload_A.qcMLsrc/tests/class_tests/openms/data/QcMLFile_reload_B.qcMLsrc/tests/class_tests/openms/source/Base64_test.cppsrc/tests/class_tests/openms/source/CalibrationData_test.cppsrc/tests/class_tests/openms/source/ConsensusFeature_test.cppsrc/tests/class_tests/openms/source/FalseDiscoveryRate_test.cppsrc/tests/class_tests/openms/source/FeatureGroupingAlgorithmKD_test.cppsrc/tests/class_tests/openms/source/FeatureMapArrowIO_test.cppsrc/tests/class_tests/openms/source/KDTreeFeatureMaps_test.cppsrc/tests/class_tests/openms/source/MRMFeatureFilter_test.cppsrc/tests/class_tests/openms/source/MzTab_test.cppsrc/tests/class_tests/openms/source/OMSSACSVFile_test.cppsrc/tests/class_tests/openms/source/QTClusterFinder_test.cppsrc/tests/class_tests/openms/source/QcMLFile_test.cppsrc/tests/class_tests/openms/source/TIC_test.cppsrc/tests/class_tests/openms/source/TheoreticalSpectrumGenerator_test.cpp
🚧 Files skipped from review as they are similar to previous changes (28)
- src/tests/class_tests/openms/source/TIC_test.cpp
- src/openms/source/DATASTRUCTURES/CalibrationData.cpp
- src/tests/class_tests/openms/source/ConsensusFeature_test.cpp
- src/openms/source/FORMAT/Base64.cpp
- src/openms/source/QC/TIC.cpp
- src/tests/class_tests/openms/source/OMSSACSVFile_test.cpp
- src/openms/source/CHEMISTRY/TheoreticalSpectrumGenerator.cpp
- src/tests/class_tests/openms/source/TheoreticalSpectrumGenerator_test.cpp
- src/openms/source/ANALYSIS/ID/IDScoreGetterSetter.cpp
- src/tests/class_tests/openms/source/QTClusterFinder_test.cpp
- src/tests/class_tests/openms/source/MzTab_test.cpp
- src/tests/class_tests/openms/source/KDTreeFeatureMaps_test.cpp
- src/openms/source/FORMAT/OMSSACSVFile.cpp
- src/openms/source/FORMAT/MzTab.cpp
- src/openms/source/FORMAT/ArrowIOHelpers.cpp
- src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFilter.cpp
- src/openms/include/OpenMS/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.h
- src/openms/source/ANALYSIS/QUANTITATION/KDTreeFeatureMaps.cpp
- src/openms/source/KERNEL/ConsensusFeature.cpp
- src/openms/source/FORMAT/QcMLFile.cpp
- src/tests/class_tests/openms/source/CalibrationData_test.cpp
- src/tests/class_tests/openms/source/FalseDiscoveryRate_test.cpp
- src/openms/source/ANALYSIS/MAPMATCHING/QTClusterFinder.cpp
- src/tests/class_tests/openms/data/QcMLFile_reload_A.qcML
- src/tests/class_tests/openms/source/Base64_test.cpp
- src/tests/class_tests/openms/source/QcMLFile_test.cpp
- src/tests/class_tests/openms/source/MRMFeatureFilter_test.cpp
- src/tests/class_tests/openms/source/FeatureMapArrowIO_test.cpp
… fix (#9791) #9790 (14 boundary/serialization/state-consistency fixes from the #9767 audit) had no changelog entry. The existing Arrow-abort entry cited only the tracking issue #9739; #9778 is the PR that actually implemented and merged that fix, so it's now credited alongside it. Claude-Session: https://claude.ai/code/session_01J7SjScz96yXHb7HnBuezhk Co-authored-by: Claude <[email protected]>
…hout features (#10310) (#10315) A fraction in which no run has a feature gives the linker only empty maps. That happens when no identification of the fraction's runs passes the upstream FDR filter, as in the quantms BSA test with Sage, where Percolator keeps no PSM in any run of fraction 1. Until #9790 this crashed QTClusterFinder::run_() (massrange.front() on an empty vector, the segfault reported in #10310; 3.5.0 has it too). Since then linking returns an empty consensus map, but ProteomicsLFQ still asserted that it is not empty, so Debug builds aborted on the same input. The fraction now contributes no quantities and a warning names it; the other fractions are quantified as before. FeatureGroupingAlgorithmQT_test covers the call ProteomicsLFQ makes (use_identifications=true) on empty maps; builds before #9790 segfault on it. TOPP_ProteomicsLFQ_empty_fraction runs ProteomicsLFQ with a fraction without identifications (the 2026-07-02 nightly segfaults on it, the Debug build of develop aborted on the assertion) and compares the MSstats output of the remaining fraction, which matches the 2026-09-27 Release nightly byte for byte. Claude-Session: https://claude.ai/code/session_01H8edsjvHPkbzHmRd7Foszp Co-authored-by: Claude <[email protected]>
Conflicts resolved to develop's side: OpenMS#9790 (066f27a) fixed the short- peptide underflow and the MRM %RSD on develop, and develop rewrote the OpenNuXL references since. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL
TheoreticalSpectrumGenerator stopped the internal-fragment loop one start position early (l + 3 < size): the internal fragment that ends next to the C-terminal residue was never generated, and 4-mers got none. The bound is l + 2 < size now. - The short-peptide underflow and the MRM %RSD fix are on develop (OpenMS#9790); the pooled split-charge FDR fix is dropped: applyBasic(run_info, ids) has no caller outside pyOpenMS and that path has further problems. - OpenNuXL annotates with internal fragments. In its 9 references only fragment_annotation lines change: the new fragments are added (e.g. VL, QL, DK-H3N1+), and at m/z 242.1496 QL replaces SSL-CO-H2O1+ (same mass). The other lines are kept; the test outputs match them within FuzzyDiff's tolerance. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL
…nt (#9600) * Fix boundary/math bugs from issue #9597 (TSG internal fragments, FDR charge range, MRM RT %RSD) Addresses three validated findings from #9597: * TheoreticalSpectrumGenerator::addInternalFragmentPeaks_: the internal-fragment loop bound `l < size - 1 - 2` dropped the C-terminal-adjacent interior dipeptide (off-by-one) and, being unsigned, wrapped to ~1.8e19 for peptides of length 1-2 (effectively infinite loop / OOM). Guard with `if (size < 4) return;` and use the underflow-safe bound `l + 2 < size`. * FalseDiscoveryRate::applyBasic(run_info, ids): the pooled split_charge_variants path computed the upper charge bound with getChargeRange().first instead of .second, collapsing e.g. 2..4 to only charge 2. * MRMFeatureFilter::calculateFilterValuesPercRSD: the component-group retention_time_u %RSD was computed from the retention_time_l fields (copy-paste); use the _u fields, mirroring the component-level block. Adds regression tests for all three (fail before the fix, pass after). The TSG fix emits the previously-missing internal fragments, so the nine OpenNuXL reference outputs are updated accordingly (fragment_annotation strings only; no identification/score/localization changes). The fourth finding (TransformationDescription::getStatistics percentile index) was validated as a non-bug: the index expression is floating-point and, for the default percentile set, never produces an out-of-range value. Co-Authored-By: Claude Opus 4.8 <[email protected]> * Keep only the internal-fragment fix; update the OpenNuXL references TheoreticalSpectrumGenerator stopped the internal-fragment loop one start position early (l + 3 < size): the internal fragment that ends next to the C-terminal residue was never generated, and 4-mers got none. The bound is l + 2 < size now. - The short-peptide underflow and the MRM %RSD fix are on develop (#9790); the pooled split-charge FDR fix is dropped: applyBasic(run_info, ids) has no caller outside pyOpenMS and that path has further problems. - OpenNuXL annotates with internal fragments. In its 9 references only fragment_annotation lines change: the new fragments are added (e.g. VL, QL, DK-H3N1+), and at m/z 242.1496 QL replaces SSL-CO-H2O1+ (same mass). The other lines are kept; the test outputs match them within FuzzyDiff's tolerance. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
Summary
This PR fixes 14 of the "no-doubt, easy" boundary/serialization/state-consistency defects catalogued in the implementation-consistency audit #9767. Each fix is small and localized, and ships with a focused regression test that fails (crashes / hangs / asserts) before the fix and passes after. Behavior on valid inputs is preserved; only the buggy edge cases change.
Line numbers in #9767 were pinned to an old commit and have drifted — every fix below was re-verified against current
develop. The change set was additionally reviewed with Codex, and its findings are incorporated (see the per-fix notes).Fixes (issue #9767 finding numbers)
Boundary / crash / underflow
QTClusterFinder/FeatureGroupingAlgorithmKD: two feature-empty input maps produced an empty mass range that was then dereferenced (front()/back()/size()-1). Added an empty-range guard. (Codex:) the KD path still runspostprocess_()before returning so per-map protein / unassigned-peptide IDs are preserved, and the QT guard is placed inside the partition branch so thenr_partitions==1/ two-map validation is unchanged.TheoreticalSpectrumGenerator::addInternalFragmentPeaks_:l < peptide.size() - 1 - 2(unsigned) underflows for peptides shorter than 4, giving an effectively infinite loop whenadd_internal_fragmentsis on. Rewritten to the additive, non-underflowingl + 3 < peptide.size()(identical iteration set for length ≥ 4).MzTabIDMzTabStream/CMMzTabStream::nextPSMRow:current_psm_idx_ == getHits().size()-1underflows for an empty hit list, so withexport_all_psmsthe caller looped forever -> usecurrent_psm_idx_ + 1 >= getHits().size().OMSSACSVFile::load: an unmatched quote let the quote-skipping loop run pastline.end()(OOB read). Loop is now bounded; malformed lines are rejected by the existing 14-column check with a cleanParseError.Correctness (wrong field / sentinel / flag)
IDScoreGetterSetter::addToPeptideScoreMap_: thetry_emplace"inserted" flag was misused, so a duplicated peptide sequence never had its stored score replaced by a later, better one. Now keeps the best score per sequence, independent of input order. (Codex:) it now updates both the score and its target/decoy label together, so a better target no longer inherits an earlier decoy label.MRMFeatureFilter::calculateFilterValuesPercRSD: the component-groupretention_time_u%RSD was computed from theretention_time_lmean/variance (copy-paste). Now reads its own_ufields.ConsensusFeature::getPositionRange/getIntensityRange: the running max was seeded withminPositive()(smallest positive value), so all-negative coordinates/intensities reported a bogus ~2.2e-308 max. Seeded withminNegative()(== lowest()).TIC::Result::operator==: omittedrelative_intensities; now included.Serialization round-trip
Base64::decodeStrings: the emit guard required length ≥ 2 and silently dropped single-character strings. Now accepts length ≥ 1. (This also flips the malformed"===="corrupted-input case from 0 to 1 string —"===="decodes to a single placeholder byte that was previously masked by the same over-strict guard; the test is updated with a root-cause comment.)ArrowIOHelpers::readMetaValues: integer meta values were parsed withstd::stoland cast to 32-bitint, truncating values aboveINT32_MAX(DataValuestoresSignedSize). Nowstd::stoll→SignedSize.FeatureMapArrowIO::importPSMsFromArrow: PSM rows were grouped intoPeptideIdentifications by row adjacency, so an externally sorted/filtered Parquet with interleaved rows split one logical ID. Now grouped byP_IDvalue (first-seen), matchingQPXFile/ConsensusMapArrowIO.Stale-state on reload / clear
QcMLFile::load: cleared the data maps but not the derivedrun_Name_ID_map_/set_Name_ID_map_, so a second load resolved stale names. Both are now cleared.CalibrationData::clear: leftgroups_populated (phantom groups drovegetNrOfGroups()); now cleared with the data.KDTreeFeatureMaps:num_maps_was uninitialized andclear()did not clear thert_cache. Nownum_maps_{0}andrt_is cleared.Deliberately NOT included
PROC-23, already fixed by the open PR [FIX] IDFilter typed peptide-score filter, MorphologicalFilter thread safety, random-scan noise sampling #9616; including it here would duplicate/conflict..first→.second) — the one-token fix is correct, but the surrounding pooled split-charge path has order-dependent side effects (setScores_removes decoys across charge iterations), so a robust failing-before/passing-after test can't be written without also addressing those unrelated issues. Deferred to a focused FDR cleanup.p / 100.0 * diffs.size() - 1is a double expression; for small N the negative value truncates toward zero to0(well-defined, since 0 is representable), so there is no unsigned underflow. Both the change and its test were reverted.FileFilter/AssayGeneratorMetabo) — real bug with a cleanselect()-based fix, but it touches two TOPP tools and warrants a CLI/round-trip test; deferred to keep this PR to self-contained library fixes.All remaining audit items were reviewed and left out because they require an API/behavior policy decision (wire-up vs deprecate) or a larger redesign.
Testing
14 focused regression tests added across the corresponding
*_test.cppfiles (plus 3 small data fixtures:QcMLFile_reload_{A,B}.qcML,OMSSACSVFile_test_unbalanced_quote.csv). Each was confirmed to exercise the corrected path; where a fix could otherwise pass trivially, the test's fail-before behavior was verified by reverting the fix. Verified no reference churn: the three fixes with any downstream reach (#3 peptide-level FDR, #6 %RSD, #12 ranges) are either unexercised by existing TOPP tests (FDR_type=PSM+peptideis not the default and no test sets it) or have no production callers.🤖 Generated with Claude Code
Summary by CodeRabbit