Skip to content

Make ADC header validation order deterministic - #860

Merged
tompollard merged 2 commits into
mainfrom
fix-adc-error-order
Dec 2, 2026
Merged

tompollard merged 2 commits into
mainfrom
fix-adc-error-order

Conversation

@tompollard

Copy link
Copy Markdown
Member

Summary

Validate signal header fields in specification order instead of iterating over a set. Records with multiple invalid ADC fields now report the same first error regardless of PYTHONHASHSEED.

The new test supplies invalid adc_res and adc_zero, checks the selected field order, and verifies that validation reports adc_res before writing a header. This addresses the case in #855.

Verification

  • Offline suite: 1,716 passed, 4 skipped, 23 deselected.
  • Ruff check and format pass.

Closes #855.

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This fixes #855. The changelog entry needs the same format fix as #858; otherwise it's ready to merge.

What I checked

  • The record from my original finding, n8_evoked_raw_95_F1_R9, now reports adc_res under all six PYTHONHASHSEED values I tried. On main it alternated between adc_res and adc_zero.
  • Iterating over signal_specs.index can't drop a field, because write_fields is built only from that index. Written headers can't change either, because wr_header_file already emits fields in SIGNAL_SPECS order.
  • The two other loops over a set in record.py are harmless. The unsupported-format list is sorted before it's reported, and the mismatched-field loop only deletes keys.
  • The offline suite (1,716 passed, 4 skipped), Ruff, the strict docs build and CI pass.

Changelog format

changelog.d/deterministic-adc-errors.rst uses a Fixed heading with a bullet rather than the bold heading and indented paragraph in changelog.d/README.rst. When I simulated the release (merging #858, #859 and this PR, then running towncrier build), this entry put a Fixed / ----- pair into docs/changes.rst, and the strict docs build failed with ERROR: Unexpected section title or transition. For example:

**Report invalid ADC fields in a stable order**
  Signal header fields are validated in specification order, so a record with
  several invalid ADC fields reports the same first error on every run.

@tompollard

Copy link
Copy Markdown
Member Author

Thanks for reproducing the original ADC case across hash seeds and for catching the changelog issue. I updated the fragment in 0272a1c to the required format. The Towncrier draft now renders and parses as reStructuredText. The corresponding fragments on #858 and #859 are fixed too.

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, 0272a1c fixes the changelog entry. I reran the release simulation with the current heads of this PR, #858 and #859: merged onto main, towncrier build, then the docs build with -W. The entry renders as a bold heading with its paragraph, and the strict build passes. The code is unchanged since my last review, and CI is green, so this is ready to merge.

@tompollard
tompollard merged commit 04ba39c into main Dec 2, 2026
19 checks passed
@tompollard
tompollard deleted the fix-adc-error-order branch December 2, 2026 16:20
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.

Make ADC field validation errors deterministic

1 participant