Repository navigation
SNIRF screening and generic HDF5 string scan (A4) - #2385
Merged
neuromechanist merged 20 commits intoNov 26, 2026
Merged
neuromechanist merged 20 commits into
neuromechanist merged 20 commits into
Conversation
…nce' into feature/issue-2186-snirf-screen
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2385Version: 🤖 Updated on each push. |
…nce' into feature/issue-2186-snirf-screen
…nce' into feature/issue-2186-snirf-screen # Conflicts: # scripts/dev/reader-fp-measure.ts # shared/identifier-readers.ts # shared/identifier-scan.ts # shared/identifier-screen-copy.ts # shared/identifier-screen-report.ts # test/identifier-coverage-contract.test.ts # test/identifier-screen-report.test.ts
Contributor
Author
|
Merge gate (lead): head d43a493; every remote check passes. Review: round 1 panel, 2 important findings (strings skipped for size came back complete; numeric identifier fields were ignored) and 5 more fixed; a seam fix gives one shared person-field rule for NIRx and HDF5; round 2 delta review resolved every item and found a behavior change, now fixed in d43a493 (describing-field exclusion, whole-token matching, the "-1" placeholder) and verified by the lead from the diff and 332 targeted tests. No third round. False-positive gate: 296 public SNIRF files; the identifier findings are all day-precision DateOfBirth true positives. |
neuromechanist
merged commit Nov 26, 2026
f6942e0
into
feature/issue-2182-epic-pq-evidence
31 checks passed
This was referenced Nov 27, 2026
Merged
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2186. Part of #2182.
Card A4 of the publication-queue plan:
.snirffiles are screened with SNIRF semantics and.h5/.hdf5with a generic string scan, both through A3's walker (shared/hdf5-meta.ts, unchanged) under A1's registry and page-cached source.What changed
shared/readers/snirf.ts: the SNIRF reader. Every/nirs{i}group is screened.SubjectIDfollowsreadSubjectId(exported as the one shared rule; card A5 applies it to the EEGLABsubjectfield): nothing for a placeholder, the BIDS subject label or a short code (at most 12 letters, digits,-or_that the slot name test does not flag);snirf-subject-name(identifier) when a token of letters only is name-like;snirf-subject-freetext(review) otherwise, including letters fused with digits (lead ruling B).MeasurementDateat day precision issnirf-measurement-date, a date kind (ADR 0090), never gating on its own.shared/readers/hdf5-generic.ts: the generic reader and the text rules both readers share.hdf5-identifier-fieldapplies the scanner's JSON identifier-key set to HDF5 field names (birth date at day precision is identifier, year or year-month is review, placeholders fire nothing; contacts are review).hdf5-freetext-name(identifier) only in person fields (PERSON_FIELDS: person words minus thing words, and a barename, which names its own object); letters fused with digits there arehdf5-freetext(review). Everywhere else, including probe, stimulus and aux labels, only the local-user-path rule applies (hdf5-freetext, review).shared/readers/hdf5-incomplete.ts: the one mapping fromHdf5Incompleteto the registry's reasons (A5 imports it), andwalkForReader: a source refusal past the limits ispartial(limit) with the findings so far, the reader's time is enforced at 80% oftimeMsaspartial(time) with the findings so far, and any other source failure is rethrown (a failed read, never partial or clean). The adapter uses A1'sRangeSourcedirectly (A3's local interface is structurally the same, so no wrapper) and imports only types from the registry, to avoid a module cycle.KIND_COPYentries;snirf-subject-name,hdf5-freetext-nameandhdf5-identifier-fieldare direct kinds;snirf-measurement-dateis a date kind.READERSis now EDF, SNIRF, HDF5..snirf,.h5and.hdf5stay inOTHER_RECORDING_EXTENSIONS, because the report's closedKNOWN_FORMATSlist is built from it and stored reports and ZIP members still name them.Limits (SNIRF and HDF5)
48 MiB fetched, 1,000 fetches, 180 s, and the walker's entry cap raised to 100,000. Measured over HTTP range reads: a typical file's metadata takes 1.7 MiB (p50) to 6.9 MiB (p90) in 27 to 104 fetches, because the page cache reads 64 KiB pages and large files spread object headers among their data. High-density files with thousands of
measurementListgroups need far more: 13 MiB in 203 fetches for 31,800 entries, 38 MiB in 573 fetches for 66,500 entries. The earlier 16 MiB cap left 49 of 296 filespartial(limit); these caps leave none.False-positive gate
scripts/dev/reader-fp-measure.tsover 296 public SNIRF files from 30 OpenNeuro fNIRS datasets (up to 10 per dataset, spread across each dataset's list), anonymous HTTP range reads through the registry's page cache; nothing is written to disk. The generic reader ran over the same 296 files (all HDF5) with--any-extension; OpenNeuro's fNIRS datasets hold only 8.h5files.Findings per 100 files (identifier / review):
hdf5-identifier-fieldsnirf-subject-freetexthdf5-freetextsnirf-measurement-date(date kind, never gates)DateOfBirthmetaDataTag at day precision, in 29 of the 296 sampled files (ds004514: 10, ds004541: 9, ds005963: 10). Those conversions will be blocked until the field is scrubbed; the copy's remedy says so.SubjectIDis a cohort word fused to digits.timepartials come from a home connection at 16 files in parallel; the screen reads from storage in the same region. The 403s are two datasets (ds008544, ds008892) whose objects are not anonymously readable.Deviations from the card (accepted by the lead)
nameis not a person field: it names its own object (a stimulus, an aux channel, a group). Without this, the generic reader made about 8 identifier findings per public SNIRF file.SubjectID.nameexemption their field names name no person, so the generic rules already give them the local-path rule only (a separate role became untestable dead code)..snirf,.h5and.hdf5stay inOTHER_RECORDING_EXTENSIONS, becauseKNOWN_FORMATSis built from it..hdf5/.h5as unscreened examples now use.nwb; the A1 contract tests that stub a.snirfreader run with EDF only.Byte budget at the file's size
A boundary test (
a byte budget of size - 1 serves every byte but the last; asking for the last is refused) pins A1's page cache atmaxBytes = size - 1and= size. My earlier note that a clipped page "never reports limited" was a misreading: re-measured onsnirf-two-groups.snirfat a budget of size - 1, the reader's highest byte asked is 277,647 of 277,802, so it iscompletewith nothing withheld; a read that needs a clipped byte is refused and marks the sourcelimited. Marking every budget-clipped page as limited would make every EDF/BDF file partial (its 256-byte budget clips the first page of every file), socachedSourceis unchanged; three mutations of its budget logic fail the boundary test.The
timepartials in the gate are not re-measured here; the lead records them as a risk, to be measured on the first production re-screen.Tests
test/readers-snirf.test.ts,test/readers-hdf5-generic.test.ts: real fixtures and h5py-written variants (README beside them): a two-group file built by copying/nirswith the oracle script's writer (both groups fire), a made-upSubjectIDname (firessnirf-subject-name), the real files' placeholders (fire no subject kind), no read range overlapping anydataTimeSeriesand at most 512 KiB asked per fixture (the page cache rounds that up: Homer3 asks 169 KB and fetches 633 KB), truncated filespartial, a failing source rethrown..snirf,.h5or.hdf5as unscreened examples now use.nwb, and the A1 contract tests that stub a.snirfreader run with EDF only.Gates:
bun run typecheckandbun run lintclean;bun test test/readers-snirf.test.ts test/readers-hdf5-generic.test.ts test/identifier-fleet.test.ts: 198 pass, 0 fail. Pure tier: 27,869 pass, 4 fail; the failures (website account-copy parity, which reads a sibling website checkout, and one git-annex UUID retry test) fail the same way on the base branch, and the fourth (the pinned date-kind list) is fixed in this PR.