Skip to content

[TEST] QPX: pin values against text references (#9864 Phase 0.1, phases 1-2) - #9879

Merged
timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:qpx-value-references
Aug 6, 2026
Merged

timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:qpx-value-references

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Note

Stacked on #9878 — its three commits appear in this diff too. The change under review here is the last commit. Rebases to develop cleanly once #9878 lands.

#9864 Phase 0.1, phases 1–2: the QPX views get value references.

#9878 gave them a schema check and a row-count floor. Those catch a table that collapsed or lost a column; they say nothing about what is in it.

Text references, not committed Parquet

ParquetDiff gains -out_tsv, which writes a table out as text sorted by primary key. The reference is that text, compared with FuzzyDiff.

This is the load-bearing design decision. A committed .parquet can only ever be regenerated wholesale — which is precisely the operation that hides unrelated drift, and something this project has been bitten by. A text reference is reviewable in the PR and patchable line by line, and it puts QPX on the same rails as every other reference in the suite rather than inventing a second kind of artefact.

Three properties that make it usable as a reference:

  • Rows come out in the comparator's own canonical key order, reusing canonicalKey_. The dump therefore cannot disagree with the comparison about what a primary key is, and the reference is not hostage to how the producer ordered its rows.
  • Tabs and newlines inside values are escaped, so one row is always one line — otherwise a stray value would silently break the line-based comparison.
  • An unkeyable file still dumps, in file order, with a warning saying exactly that, because a reference built from it would be order-sensitive.

Row order looks unsorted — TMT126, TMT127C, TMT131 — because the encoding length-prefixes each value. It is deterministic and byte-comparable, which is what matters; the CMake comment says so.

Tolerance: relative only, absolute zero

set(QPX_DIFF ${TOPP_BIN_PATH}/FuzzyDiff -test -ratio 1.01 -absdiff 0)

FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded quantities. The QPX views carry q-values and posterior error probabilities living in [0,1], where it deletes the assertion outright — in BSA_qpx's psm table, 68 of 104 PEPs are ≤ 0.01, so every one would compare equal to every other.

Verified rather than argued: perturbing a PEP by 0.005 — a change the shared absdiff would have absorbed silently — turns the psm reference red.

The references

reference rows what it pins
ProteinQuantifier_19_qpx_pg.tsv 48 4 fraction groups × 6 TMT labels × 2 anchors, 12-entry grouped_runs
ProteinQuantifier_18_qpx_pg.tsv 3 label-free, merged identification run
IsobaricWorkflow_qpx_pg.tsv 20 10 TMT channels, reporter intensities
IsobaricWorkflow_qpx_psm.tsv 4 psm view, string+int key

Chosen by float-path length, not table size. ProteinQuantifier reads a committed consensusXML — no mzML parsing, no feature finding, no alignment, no normalization. IsobaricWorkflow adds only reporter extraction. Both keys are float-free.

ProteinQuantifier_19's 48 rows are exactly the design melting, fraction-group keying and label assignment that #9869/#9874/#9876 touched — so it now verifies rather than assumes #9876's claim that nothing changes at the default fractions:aggregate sum.

Both references were shown to fail on purpose (a 5% intensity change, and the q-value change above) and restored afterwards.

Deliberately not pinned yet

The feature view and both ProteomicsLFQ producers. The feature key contains a float32 rt matched with zero tolerance, so a one-ULP cross-platform drift does not degrade gracefully — it becomes 2N "row only in one file" errors. And ProteomicsLFQ picks its median-normalization reference map by feature count, so one extra feature on one platform shifts every intensity by a finite factor. Those wait for the §A3 normalization fix, which will move them anyway.

Full local ctest, -E "BrukerTims|PASEF": 2826 tests, 9 failures, all pre-existing environmental (6 CometAdapter version-string, PercolatorAdapter numerics, Doxygen_Warning_test HAVE_DOT, ThermoRawFile_test .NET).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx

Summary by CodeRabbit

  • New Features

    • Added TSV export for Parquet tables with deterministic sorting, escaped values, null handling, and primary-key support.
    • Added an out_tsv option to ParquetDiff, allowing exports without a second input file.
    • Added exact value references for selected QPX protein-group and PSM views.
  • Bug Fixes

    • Improved TSV escaping to distinguish literal backslash sequences from tabs and newlines.
  • Tests

    • Added coverage for deterministic QPX comparisons, schema validation, and TSV output.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 79729e16-df65-454b-92a1-c523c4f254ca

📥 Commits

Reviewing files that changed from the base of the PR and between 809a425 and 61acbbe.

⛔ Files ignored due to path filters (4)
  • src/tests/topp/IsobaricWorkflow_qpx_pg.tsv is excluded by !**/*.tsv
  • src/tests/topp/IsobaricWorkflow_qpx_psm.tsv is excluded by !**/*.tsv
  • src/tests/topp/ProteinQuantifier_18_qpx_pg.tsv is excluded by !**/*.tsv
  • src/tests/topp/ProteinQuantifier_19_qpx_pg.tsv is excluded by !**/*.tsv
📒 Files selected for processing (6)
  • CHANGELOG
  • src/openms/include/OpenMS/FORMAT/ParquetTableComparator.h
  • src/openms/source/FORMAT/ParquetTableComparator.cpp
  • src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp
  • src/tests/topp/CMakeLists.txt
  • src/topp/ParquetDiff.cpp
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp
  • src/openms/include/OpenMS/FORMAT/ParquetTableComparator.h
  • CHANGELOG
  • src/tests/topp/CMakeLists.txt
  • src/topp/ParquetDiff.cpp
  • src/openms/source/FORMAT/ParquetTableComparator.cpp

📝 Walkthrough

Walkthrough

Changes

The PR adds deterministic, escaped TSV export for Parquet tables through ParquetTableComparator and ParquetDiff. QPX tests generate and compare TSV references for ProteinQuantifier and IsobaricWorkflow protein-group and PSM views.

QPX Parquet validation

Layer / File(s) Summary
Parquet TSV dump
src/openms/include/OpenMS/FORMAT/ParquetTableComparator.h, src/openms/source/FORMAT/ParquetTableComparator.cpp, src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp
Adds dumpToTsv, primary-key resolution, canonical sorting, value rendering, null handling, TSV escaping, write-status checks, and regression coverage.
ParquetDiff dump mode
src/topp/ParquetDiff.cpp
Adds the out_tsv option and standalone TSV export without requiring a second input file.
QPX reference validation
src/tests/topp/CMakeLists.txt, CHANGELOG
Adds relative-tolerance QPX comparisons, preserves schema and minimum-row checks, and adds TSV reference pipelines for selected protein-group and PSM outputs.

Sequence Diagram(s)

sequenceDiagram
  participant QPXTests
  participant ParquetDiff
  participant ParquetTableComparator
  participant ParquetFile
  participant QPXReference
  QPXTests->>ParquetDiff: request TSV output
  ParquetDiff->>ParquetTableComparator: dumpToTsv(input, output, settings)
  ParquetTableComparator->>ParquetFile: read and sort rows by canonical keys
  ParquetTableComparator-->>ParquetDiff: write escaped TSV
  QPXTests->>QPXReference: compare TSV output with reference
Loading

Possibly related PRs

Poem

A rabbit sorts each row by key,
And keeps raw tabs away.
Escaped values hop in line,
While QPX tests compare fine.
Protein groups and PSMs shine.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding QPX value pinning against text references.
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 unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 (1)
src/topp/ProSE.cpp (1)

658-679: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Delete omitted QPX .pg files before logging the skip.

Reusing -out_qpx leaves an older <basename>.pg.parquet behind when the current run skips it because no groups were inferred, and it also leaves an old quantms.pg.parquet when every merged source skips groups. Remove both <basename>.pg.parquet and quantms.pg.parquet before the existing “not writing” logs.

Also applies to: 801-803

🤖 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/topp/ProSE.cpp` around lines 658 - 679, In the no-protein-groups branches
near ProteinGroupArrowExport, delete any stale per-input <basename>.pg.parquet
and merged quantms.pg.parquet outputs before the existing “not writing” logs.
Apply the same cleanup to the corresponding logic around the additional
locations at lines 801-803, while preserving the current skip behavior and
messages.

Source: Coding guidelines

🧹 Nitpick comments (2)
src/topp/ParquetDiff.cpp (1)

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

Route new status messages through the TOPP logging interface.

The new TSV-success and row-floor messages write directly to std::cout. Use the TOPP logging interface so these messages follow the configured OpenMS log routing.

Also applies to: 193-197

🤖 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/topp/ParquetDiff.cpp` at line 175, Replace the direct std::cout writes
for the TSV-success message and row-floor messages in the ParquetDiff status
flow with the TOPP logging interface, preserving their existing message text and
verbosity conditions so output follows configured OpenMS routing.

Source: Coding guidelines

src/openms/source/FORMAT/ParquetTableComparator.cpp (1)

875-875: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use newline characters in the new log statements.

Replace std::endl with "\n" in these new log statements. As per coding guidelines, prefer \n over std::endl.

Also applies to: 889-891, 902-903, 951-951, 964-964

🤖 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/ParquetTableComparator.cpp` at line 875, Replace
std::endl with "\n" in the new ParquetDiff log statements, including the
messages in the error-reporting paths around OPENMS_LOG_ERROR and the additional
listed locations. Preserve the existing log content and behavior while removing
the flushing stream manipulator.

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 `@CHANGELOG`:
- Line 20: Update the CHANGELOG description of canonical key ordering to match
the implementation: document V6:TMT126, then V6:TMT131, then V7:TMT127C, rather
than placing TMT127C before TMT131.

In `@src/openms/source/FORMAT/ParquetTableComparator.cpp`:
- Around line 930-938: Update the escaping loop in the displayValue_ rendering
block to handle backslashes first, emitting them as escaped backslashes before
processing tabs, newlines, and carriage returns. Preserve the existing
control-character escapes and literal-character handling so distinct values
cannot produce the same comparison text.

In `@src/tests/topp/CMakeLists.txt`:
- Around line 250-256: Add the -schema_only option to the TOPP_ParquetDiff_8
test invocation while preserving its existing inputs, primary keys, and min_rows
value, so WILL_FAIL reflects validation of the second input’s four-row floor
rather than primary-key comparison.

---

Outside diff comments:
In `@src/topp/ProSE.cpp`:
- Around line 658-679: In the no-protein-groups branches near
ProteinGroupArrowExport, delete any stale per-input <basename>.pg.parquet and
merged quantms.pg.parquet outputs before the existing “not writing” logs. Apply
the same cleanup to the corresponding logic around the additional locations at
lines 801-803, while preserving the current skip behavior and messages.

---

Nitpick comments:
In `@src/openms/source/FORMAT/ParquetTableComparator.cpp`:
- Line 875: Replace std::endl with "\n" in the new ParquetDiff log statements,
including the messages in the error-reporting paths around OPENMS_LOG_ERROR and
the additional listed locations. Preserve the existing log content and behavior
while removing the flushing stream manipulator.

In `@src/topp/ParquetDiff.cpp`:
- Line 175: Replace the direct std::cout writes for the TSV-success message and
row-floor messages in the ParquetDiff status flow with the TOPP logging
interface, preserving their existing message text and verbosity conditions so
output follows configured OpenMS routing.
🪄 Autofix

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: 8b908fb0-41ae-4088-b7ea-17133c918a92

📥 Commits

Reviewing files that changed from the base of the PR and between 6ceeceb and 83a5490.

⛔ Files ignored due to path filters (4)
  • src/tests/topp/IsobaricWorkflow_qpx_pg.tsv is excluded by !**/*.tsv
  • src/tests/topp/IsobaricWorkflow_qpx_psm.tsv is excluded by !**/*.tsv
  • src/tests/topp/ProteinQuantifier_18_qpx_pg.tsv is excluded by !**/*.tsv
  • src/tests/topp/ProteinQuantifier_19_qpx_pg.tsv is excluded by !**/*.tsv
📒 Files selected for processing (6)
  • CHANGELOG
  • src/openms/include/OpenMS/FORMAT/ParquetTableComparator.h
  • src/openms/source/FORMAT/ParquetTableComparator.cpp
  • src/tests/topp/CMakeLists.txt
  • src/topp/ParquetDiff.cpp
  • src/topp/ProSE.cpp

Comment thread CHANGELOG Resolved
Comment thread src/tests/topp/CMakeLists.txt Resolved
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 6, 2026
…or test mean what it says

Three findings from CodeRabbit on OpenMS#9879, all valid.

1. dumpToTsv could forge an escape. A tab is rendered as the two characters '\'
   't' to keep one row on one line - but a value that ALREADY contained a
   backslash followed by 't' rendered to those same two characters. Two
   genuinely different tables therefore produced identical text and the
   reference comparison accepted them as equal, which is the exact failure a
   value reference exists to rule out. The backslash is now escaped first and
   unconditionally.

   Verified in both directions rather than assumed: two tables differing only in
   'literal backslash-t' versus 'a real tab' now render as X\\tY and X\tY, and
   with the fix reverted the new regression section fails on
   TEST_NOT_EQUAL(text_a, text_b) because both collapse to [X\tY]. The section
   also asserts that neither dump contains a raw tab, which would split a row.

   None of the four committed references contains a backslash, so none of them
   moves - checked, and all 51 QPX/ParquetDiff tests still pass against the
   unchanged files.

2. TOPP_ParquetDiff_8 passed for the wrong reason. It exists to show the row
   floor applies to the SECOND input, and it did fail - but its two fixtures have
   disjoint primary keys, so it would have failed on the key mismatch even if
   'min_rows' never looked at 'in2' at all. 'schema_only' now removes every other
   failure cause, leaving the floor as the only thing that can go red.

3. The documented canonical key order was backwards, in both the CHANGELOG and
   the CMake comment. Length-prefixing puts the six-character 'TMT126' and
   'TMT131' ahead of the seven-character 'TMT127C', not 'TMT127C' before
   'TMT131'.

Full local ctest unchanged at 2826 tests, 9 pre-existing environmental failures.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 6, 2026
…or test mean what it says

Three findings from CodeRabbit on OpenMS#9879, all valid.

1. dumpToTsv could forge an escape. A tab is rendered as the two characters '\'
   't' to keep one row on one line - but a value that ALREADY contained a
   backslash followed by 't' rendered to those same two characters. Two
   genuinely different tables therefore produced identical text and the
   reference comparison accepted them as equal, which is the exact failure a
   value reference exists to rule out. The backslash is now escaped first and
   unconditionally.

   Verified in both directions rather than assumed: two tables differing only in
   'literal backslash-t' versus 'a real tab' now render as X\\tY and X\tY, and
   with the fix reverted the new regression section fails on
   TEST_NOT_EQUAL(text_a, text_b) because both collapse to [X\tY]. The section
   also asserts that neither dump contains a raw tab, which would split a row.

   None of the four committed references contains a backslash, so none of them
   moves - checked, and all 51 QPX/ParquetDiff tests still pass against the
   unchanged files.

2. TOPP_ParquetDiff_8 passed for the wrong reason. It exists to show the row
   floor applies to the SECOND input, and it did fail - but its two fixtures have
   disjoint primary keys, so it would have failed on the key mismatch even if
   'min_rows' never looked at 'in2' at all. 'schema_only' now removes every other
   failure cause, leaving the floor as the only thing that can go red.

3. The documented canonical key order was backwards, in both the CHANGELOG and
   the CMake comment. Length-prefixing puts the six-character 'TMT126' and
   'TMT131' ahead of the seven-character 'TMT127C', not 'TMT127C' before
   'TMT131'.

Full local ctest unchanged at 2826 tests, 9 pre-existing environmental failures.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/openms/source/FORMAT/ParquetTableComparator.cpp (1)

875-875: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Apply the required C++ formatting and logging style.

Move braces in changed control blocks onto aligned lines. Replace std::endl with "\n" in the new log statements.

As per coding guidelines, **/*.{h,hpp,cpp,cc,cxx} requires braces on their own aligned lines, and src/**/*.cpp says to prefer \n over std::endl.

Also applies to: 886-886, 891-891, 903-903, 927-927, 938-942, 956-956, 965-965, 969-969

🤖 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/ParquetTableComparator.cpp` at line 875, Update the
changed control blocks around the Parquet dump/error-handling logic to place
opening and closing braces on their own aligned lines. In the affected logging
statements, including those using OPENMS_LOG_ERROR, replace std::endl with "\n"
while preserving the existing messages and 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/FORMAT/ParquetTableComparator.cpp`:
- Around line 959-964: Update the header-writing loop around
schema->field(c)->name() to pass each field name through the same TSV escaping
routine used for row cells before writing it to out. Preserve the existing tab
separators and newline while ensuring backslashes, tabs, and line breaks in
header names are escaped consistently.
- Around line 916-922: Update the primary-key loop in the surrounding
dump/comparison function to check both `ok` from `cellAt_` and `key_ok` from
`canonicalKey_`; immediately return `false` when either is false, before
appending or sorting the generated key. Preserve normal key construction for
successfully readable and canonicalized cells.

---

Nitpick comments:
In `@src/openms/source/FORMAT/ParquetTableComparator.cpp`:
- Line 875: Update the changed control blocks around the Parquet
dump/error-handling logic to place opening and closing braces on their own
aligned lines. In the affected logging statements, including those using
OPENMS_LOG_ERROR, replace std::endl with "\n" while preserving the existing
messages and behavior.
🪄 Autofix

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: 42ec1421-2ed2-4109-afdb-419fe6668308

📥 Commits

Reviewing files that changed from the base of the PR and between 6ceeceb and da16a98.

⛔ Files ignored due to path filters (4)
  • src/tests/topp/IsobaricWorkflow_qpx_pg.tsv is excluded by !**/*.tsv
  • src/tests/topp/IsobaricWorkflow_qpx_psm.tsv is excluded by !**/*.tsv
  • src/tests/topp/ProteinQuantifier_18_qpx_pg.tsv is excluded by !**/*.tsv
  • src/tests/topp/ProteinQuantifier_19_qpx_pg.tsv is excluded by !**/*.tsv
📒 Files selected for processing (9)
  • CHANGELOG
  • src/openms/include/OpenMS/FORMAT/ArrowIOHelpers.h
  • src/openms/include/OpenMS/FORMAT/ParquetTableComparator.h
  • src/openms/source/FORMAT/ArrowIOHelpers.cpp
  • src/openms/source/FORMAT/ParquetTableComparator.cpp
  • src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp
  • src/tests/topp/CMakeLists.txt
  • src/topp/ParquetDiff.cpp
  • src/topp/ProSE.cpp
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/openms/include/OpenMS/FORMAT/ParquetTableComparator.h
  • src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp
  • CHANGELOG
  • src/topp/ProSE.cpp
  • src/tests/topp/CMakeLists.txt
  • src/topp/ParquetDiff.cpp

Comment on lines +916 to +922
for (int i : key_idx)
{
bool ok = false;
auto scalar = cellAt_(table, i, r, ok);
bool key_ok = true;
sort_key += canonicalKey_(scalar, key_ok);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Fail the dump when a primary-key cell cannot be read.

Line 921 ignores both cellAt_ failure and canonicalKey_ failure. The code then sorts unreadable keys as "E;" and emits a reference instead of reporting an invalid input. Return false when either operation fails.

Proposed fix
-      for (int i : key_idx)
+      for (Size k = 0; k < key_idx.size(); ++k)
       {
+        const int i = key_idx[k];
         bool ok = false;
         auto scalar = cellAt_(table, i, r, ok);
+        if (!ok)
+        {
+          OPENMS_LOG_ERROR << "ParquetDiff: cannot read primary-key column '"
+                           << key_columns[k] << "' in row " << r << "\n";
+          return false;
+        }
         bool key_ok = true;
         sort_key += canonicalKey_(scalar, key_ok);
+        if (!key_ok)
+        {
+          OPENMS_LOG_ERROR << "ParquetDiff: cannot read nested primary-key value in column '"
+                           << key_columns[k] << "' in row " << r << "\n";
+          return false;
+        }
       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for (int i : key_idx)
{
bool ok = false;
auto scalar = cellAt_(table, i, r, ok);
bool key_ok = true;
sort_key += canonicalKey_(scalar, key_ok);
}
for (Size k = 0; k < key_idx.size(); ++k)
{
const int i = key_idx[k];
bool ok = false;
auto scalar = cellAt_(table, i, r, ok);
if (!ok)
{
OPENMS_LOG_ERROR << "ParquetDiff: cannot read primary-key column '"
<< key_columns[k] << "' in row " << r << "\n";
return false;
}
bool key_ok = true;
sort_key += canonicalKey_(scalar, key_ok);
if (!key_ok)
{
OPENMS_LOG_ERROR << "ParquetDiff: cannot read nested primary-key value in column '"
<< key_columns[k] << "' in row " << r << "\n";
return false;
}
}
🤖 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/ParquetTableComparator.cpp` around lines 916 - 922,
Update the primary-key loop in the surrounding dump/comparison function to check
both `ok` from `cellAt_` and `key_ok` from `canonicalKey_`; immediately return
`false` when either is false, before appending or sorting the generated key.
Preserve normal key construction for successfully readable and canonicalized
cells.

Comment on lines +959 to +964
for (int c = 0; c < schema->num_fields(); ++c)
{
if (c != 0) { out << "\t"; }
out << schema->field(c)->name();
}
out << "\n";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Escape TSV header field names.

Lines 961-963 write field names without the escaping applied to row cells. A schema field name containing a backslash, tab, or line break produces an invalid or ambiguous TSV header. Apply the same escaping routine to each header field name.

🤖 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/ParquetTableComparator.cpp` around lines 959 - 964,
Update the header-writing loop around schema->field(c)->name() to pass each
field name through the same TSV escaping routine used for row cells before
writing it to out. Preserve the existing tab separators and newline while
ensuring backslashes, tabs, and line breaks in header names are escaped
consistently.

timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 6, 2026
…or test mean what it says

Three findings from CodeRabbit on OpenMS#9879, all valid.

1. dumpToTsv could forge an escape. A tab is rendered as the two characters '\'
   't' to keep one row on one line - but a value that ALREADY contained a
   backslash followed by 't' rendered to those same two characters. Two
   genuinely different tables therefore produced identical text and the
   reference comparison accepted them as equal, which is the exact failure a
   value reference exists to rule out. The backslash is now escaped first and
   unconditionally.

   Verified in both directions rather than assumed: two tables differing only in
   'literal backslash-t' versus 'a real tab' now render as X\\tY and X\tY, and
   with the fix reverted the new regression section fails on
   TEST_NOT_EQUAL(text_a, text_b) because both collapse to [X\tY]. The section
   also asserts that neither dump contains a raw tab, which would split a row.

   None of the four committed references contains a backslash, so none of them
   moves - checked, and all 51 QPX/ParquetDiff tests still pass against the
   unchanged files.

2. TOPP_ParquetDiff_8 passed for the wrong reason. It exists to show the row
   floor applies to the SECOND input, and it did fail - but its two fixtures have
   disjoint primary keys, so it would have failed on the key mismatch even if
   'min_rows' never looked at 'in2' at all. 'schema_only' now removes every other
   failure cause, leaving the floor as the only thing that can go red.

3. The documented canonical key order was backwards, in both the CHANGELOG and
   the CMake comment. Length-prefixing puts the six-character 'TMT126' and
   'TMT131' ahead of the seven-character 'TMT127C', not 'TMT127C' before
   'TMT131'.

Full local ctest unchanged at 2826 tests, 9 pre-existing environmental failures.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

timosachsenberg and others added 2 commits August 6, 2026 21:21
…ow counts

Phase 0.1 gave the QPX views a schema check and a row-count floor. Those catch a
table that collapsed or lost a column; they say nothing about what is IN it.

ParquetDiff gains 'out_tsv', which writes a table out as text sorted by primary
key, and four references are pinned against that with FuzzyDiff: the pg view of
ProteinQuantifier_19 (48 rows) and _18 (3 rows), and the pg (20 rows) and psm
(4 rows) views of IsobaricWorkflow.

Text rather than committed Parquet is the whole point. A binary reference can
only ever be regenerated wholesale, which is exactly the operation that hides
unrelated drift; a text reference is reviewable in a pull request and patchable
line by line, and it puts QPX on the same footing as every other reference in the
suite rather than inventing a second kind of artefact.

The dump reuses the comparator's own canonical key encoding, so it cannot
disagree with the comparison about what a primary key is, and it escapes tabs and
newlines inside values so one row is always one line. Rows therefore come out in
length-prefixed key order - 'TMT126' before 'TMT127C' before 'TMT131' - which
looks unsorted but is deterministic and byte-comparable, which is what a
reference needs. A file with no derivable key still dumps, in file order, with a
warning saying so, because a reference built from it would be sensitive to how
the producer ordered its rows.

Comparison uses the shared relative tolerance with the absolute one set to ZERO.
FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded
quantities; the QPX views carry q-values and posterior error probabilities living
in [0,1], where it deletes the assertion outright - in one fixture 68 of 104 PEPs
are <= 0.01, so every one of them would compare equal to every other. Verified,
not argued: perturbing a PEP by 0.005 turns the psm reference red, and that is a
change the shared absdiff would have absorbed silently.

Both references were shown to fail on purpose - a 5% intensity change and the
q-value change above - and restored afterwards.

Fixtures were chosen by float-path length, not table size. ProteinQuantifier
reads a committed consensusXML and does no mzML parsing, feature finding,
alignment or normalization; IsobaricWorkflow adds only reporter extraction; both
keys are float-free. ProteinQuantifier_19's 48 rows are 4 fraction groups x 6 TMT
labels x 2 anchors with 12-entry grouped_runs lists - the design melting,
fraction-group keying and label assignment that OpenMS#9869/OpenMS#9874/OpenMS#9876 touched - so it
now VERIFIES rather than assumes OpenMS#9876's claim that nothing changes at the
default 'fractions:aggregate'.

The feature view and both ProteomicsLFQ producers are deliberately NOT pinned.
The feature key contains a float32 'rt' matched with zero tolerance, and
ProteomicsLFQ picks its median-normalization reference map by feature count, so
one extra feature on one platform shifts every intensity by a finite factor.
Those wait for the normalization fix that will move them anyway.

Part of OpenMS#9864 Phase 0.1.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
…or test mean what it says

Three findings from CodeRabbit on OpenMS#9879, all valid.

1. dumpToTsv could forge an escape. A tab is rendered as the two characters '\'
   't' to keep one row on one line - but a value that ALREADY contained a
   backslash followed by 't' rendered to those same two characters. Two
   genuinely different tables therefore produced identical text and the
   reference comparison accepted them as equal, which is the exact failure a
   value reference exists to rule out. The backslash is now escaped first and
   unconditionally.

   Verified in both directions rather than assumed: two tables differing only in
   'literal backslash-t' versus 'a real tab' now render as X\\tY and X\tY, and
   with the fix reverted the new regression section fails on
   TEST_NOT_EQUAL(text_a, text_b) because both collapse to [X\tY]. The section
   also asserts that neither dump contains a raw tab, which would split a row.

   None of the four committed references contains a backslash, so none of them
   moves - checked, and all 51 QPX/ParquetDiff tests still pass against the
   unchanged files.

2. TOPP_ParquetDiff_8 passed for the wrong reason. It exists to show the row
   floor applies to the SECOND input, and it did fail - but its two fixtures have
   disjoint primary keys, so it would have failed on the key mismatch even if
   'min_rows' never looked at 'in2' at all. 'schema_only' now removes every other
   failure cause, leaving the floor as the only thing that can go red.

3. The documented canonical key order was backwards, in both the CHANGELOG and
   the CMake comment. Length-prefixing puts the six-character 'TMT126' and
   'TMT131' ahead of the seven-character 'TMT127C', not 'TMT127C' before
   'TMT131'.

Full local ctest unchanged at 2826 tests, 9 pre-existing environmental failures.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@timosachsenberg
timosachsenberg merged commit af31c76 into OpenMS:develop Aug 6, 2026
timosachsenberg added a commit that referenced this pull request Aug 7, 2026
…reference feature<->PSM (#9864)

Every QPX view carries a mandatory int64 identity column that is its primary key --
feature_id, psm_id, pg_id. OpenMS emitted none of the three, so every -out_qpx file was
invalid against the current spec.

The ids are derived exactly as qpx.core.data.identity derives them: BLAKE2b truncated to
8 bytes over the canonical JSON of a footer-declared identity_composite, read as a signed
big-endian int64. Byte-exactness is not cosmetic. `qpxc convert openms` re-derives
feature_id for identified rows from that declared composite but never rewrites the
psm.feature_id pointing at it, so ids that were merely plausible would turn an OpenMS
collection into one with dangling cross-references the moment it was converted -- which
qpx's own dataset validation reports as dangling_feature_id.

The composites are the ones qpxc already hard-codes for OpenMS -out_qpx input, in that
order, so a conversion reproduces what OpenMS wrote.

Reproducing Python's float repr is the one genuinely fiddly part, because the feature
composite hashes rt and observed_mz as persisted. Verified against the reference
implementation on 399,325 float32 values (uniformly random bit patterns, the RT and m/z
ranges QPX actually stores, and exact powers of two either side of both fixed/exponential
boundaries) and on 60,000 random composites carrying control characters, astral-plane
unicode, JSON metacharacters, int64 extremes, nulls and set-valued lists. Zero
mismatches. Then end to end: every one of the 747 rows all four producers write
re-derives to the id OpenMS emitted.

Cross-references: psm.feature_id and feature.psm_ids. A consensus feature emits one row
per run, so its identifications are distributed to the row of their own run -- claiming a
PSM as evidence for a quantity measured in a different file would be wrong. An unassigned
identification keeps feature_id null, as does any psm-only producer. Both directions come
out of one pass over the feature rows, which is what makes them reciprocal: qpx validates
that a PSM pointing at a feature is listed back by that feature.

Measured on the shipped LFQ fixture: 39 consensus features with one identification each
produce 39 links, all resolving, while the other 65 identifications are unassigned and
correctly null; 23x1 + 11x2 + 5x3 = 60 feature rows confirms the per-run distribution.

The scan and run_file_name derivations the two views must agree on were verbatim copies
in both exporters. They are now one shared implementation, because the linkage depends on
that agreement -- two copies would be one edit away from a collection whose
cross-references silently stop resolving.

ParquetDiff leaves the identity and cross-reference columns out of both the comparison and
the TSV dump, with -with_ids to opt back in. The spec states identity is meaningful within
a file only, so comparing a file against a committed reference is a join it tells you not
to make; and feature_id hashes rt, so one ULP of platform drift would not shift a digit,
it would report every row as missing on both sides. Rows are still matched on the natural
key, which degrades gracefully. -schema mode asserts instead what actually matters: the id
is present, never null and never repeated. Consequence: zero churn in the references #9879
committed, verified.

Verification
- QPXIdentity_test pins the derivation against vectors taken from the reference
  implementation, not from this code's own output. It has failed for a real reason: it
  caught std::from_chars silently parsing nothing from a '+'-signed exponent.
- ConsensusMapArrowExport_test re-derives each row's feature_id from the columns as
  written, in the declared order, which is what would catch this exporter hashing the
  right values in the wrong slots.
- The cross-reference test asserts resolvability in both directions plus reciprocity, and
  guards against vacuity -- that guard fired twice on a fixture whose PSMs had no
  resolvable run, which is exactly what it is for.
- Both new ParquetDiff checks were shown to fail on purpose: a table with duplicated ids
  and one with a null id are each reported, and the unmodified file passes.
- Full suite: 8 failures, all in the known environmental baseline (6 CometAdapter
  version-string, PercolatorAdapter numerics, Doxygen HAVE_DOT).

Not in scope: feature.pg_ids. No upstream converter populates it, and the documented
semantic join (anchor_protein + run_file_name in grouped_runs + intensities[].label) is
already fully available in OpenMS output.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit that referenced this pull request Aug 11, 2026
Audited PRs merged since the last CHANGELOG update (#9881): most of
them (#9879, #9880, #9882, #9884, #9886, #9892, #9896, #9898, #9900,
#9901, #9888) already carried their own CHANGELOG entries. Only the
Docker library-stage fix (#9891) was missing one.


Claude-Session: https://claude.ai/code/session_01Jgrv6mFL3oawgLdYs1efPH

Co-authored-by: Claude <[email protected]>
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