Repository navigation
MAT v5 walker; EEGLAB, Homer .nirs, .mat readers (A5) - #2395
Merged
neuromechanist merged 24 commits intoNov 26, 2026
Merged
neuromechanist merged 24 commits into
neuromechanist merged 24 commits into
Conversation
…nce' into feature/issue-2187-mat-eeglab
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2395Version: 🤖 Updated on each push. |
Contributor
Author
|
Merge gate (lead): head 0016124, every remote check green. Round 1 (two Sonnet reviewers): 1 critical (synchronous loop on a fieldless struct array with a huge count), 5 important and 5 suggestions, all fixed in e401e6a. Round 2 (delta): items resolved; 1 important (text() row-count loop) fixed in 0016124 and verified by the lead with the reviewer's repro (0 ms, corrupt) and a mutation removing the check (fails a test). Accepted deviations: a fieldless struct with count > 0 and a 1x0 char array are valid MATLAB and walk nothing. |
neuromechanist
merged commit Nov 26, 2026
098d30a
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 #2187. Part of #2182.
Card A5 of the publication-queue plan: EEGLAB
.set(classic and v7.3), Homer2.nirsand generic.matfiles are now screened by readers that never read signal arrays. All three are registered beside A6's ZIP reader. A.setinside a ZIP is read by the EEGLAB reader, and its.fdtis looked for in the archive.What changed
shared/mat-meta.ts: a bounded, dependency-free MAT-file Level 5 walker. It walks struct, cell and char arrays. A numeric array over 64 elements is skipped by its declared size: in an uncompressed element only its tag, flags, dimensions and name are read, and the entry records the unread range.miCOMPRESSEDis inflated as a stream throughDecompressionStream, with fetches starting at 4 KiB and growing to 64 KiB. A top-level compressed variable that turns out to be a large signal is left after its first bytes. Inflation is capped at 256 MiB per file (limit), with walk caps of 1,000,000 arrays and depth 32. Sparse, object, function-handle and opaque arrays are skipped after their flags asunsupported-datatype. A Level 4 file isunsupported-version; damage iscorrupt.shared/hdf5-meta.ts(A3): an opt-inmatlabCharsoption reads auint16dataset whoseMATLAB_classischaras text, one string per MATLAB row, under the 64 KiB string rule. It is off by default, so SNIRF and HDF5 walks are unchanged.walkForReaderpasses the option through.shared/readers/mat-generic.ts: the shared MATLAB layer. It dispatches on the header (v5, v7.3 to A3's walker throughwalkForReaderandHDF5_INCOMPLETE_REASON, v4, or another format). It converts v7.3 entries to the same arrays (MATLAB_class,MATLAB_empty,canonical empty,/#refs#). It applies the unscanned-text rule: a skipped char array, a line over 4 KiB, a skipped identifier-key numeric or an unsupported class makes the file partial.scanMatTextis A4'sscanEntryText(identifier keys,scanNumericIdentifier, person fields, home paths, A2'scontactInand the 4 KiB cap) under the MATLAB kinds. Findings are folded to one per kind and field per file, with the count inFinding.occurrences. The generic.matreader is in this file too.shared/readers/eeglab.ts: the EEGLAB rules. Thesubjectfield usesreadSubjectId(eeglab-subject-nameis identifier,eeglab-subject-freetextis review).historyandsetnameget the person-name rule only. In the event tables,typegets the person-name rule only and every other column is not scanned. Channel labels never fire,datfile/dataname the.fdt, andEEG.BIDSgets the free-text rules without the person-field rule. Everything else gets the free-text rules.shared/readers/homer-nirs.ts: every array goes through the free-text rules.shared/readers/person-fields.ts: the qualified-namerule,descriptionas a describing word, andisLocationField. All three are shared by every format.ReaderResult.needs: companions named by the file's content, as bare file names only, resolved in the recording's own directory.namedCompanionsMissingcounts them inreadRecordings, in A9's local screen and in A6's ZIP reader.KIND_COPYentries:eeglab-subject-name,eeglab-subject-freetext,eeglab-event-name,eeglab-history-name,eeglab-setname-name,mat-freetext,mat-freetext-nameandmat-identifier-field. The direct kinds areeeglab-subject-name,mat-freetext-nameandmat-identifier-field. The report's kind map cap is nowFINDING_KINDS.lengthinstead of 40.Deviations (lead rulings of 2026-11-25)
maxElementsis 1,000,000, not 20,000. At 20,000, 73 of 218 classic public files were partial: event tables hold one array per field per event (p50 46k and max 741k among those). The 741,517-array file (ds003825) took 3.4 s of CPU from a local copy and about 100 s over a home connection, fetching 45 MB in 686 reads. That is under the 180 s cap and its 80% walk share, and the timer test is kept.historyandsetnamefires on two capitalized name-like words in a row, after path-like text is removed. The scanner's single-word test flags almost every event word (141 of 246 files).isLocationField: a last name word of path, filepath, file, filename, dir or folder, or a name starting withoriginal_) are not scanned in any MATLAB reader. The ruling onfilepathcoverschaninfo.filename(home path in 38 of 246 files), spline, dipfit, HomersystemInfo.SDfilepathand FieldTrip-style*_dir.setnamegets the person-name rule and no path rule.ReaderResult.needsis a small additive contract change (registry, builder, ZIP kit), with a test that adatfilewith a separator is not followed and the file is partial.EEG.BIDS.*mirrors the BIDS sidecars, so it gets no person-field rule. In the shared person-field rule, anameafter a word that is neither a person word nor a describing word names a thing (LongName,DepartmentName), anddescriptionis a describing word. The SNIRF, HDF5, NIRx and BrainVision fixtures give identical findings before and after (25 files).typeis scanned; every other column is not, as withevents.tsv.occurrences.historyof short commands is not partial./#refs#without their field names, so they get the free-text rules (paths, contacts) rather than the person-name rule..setor.matas unscreened examples now use.nwbor.xdf.False-positive gate
scripts/dev/reader-fp-measure-remote.ts, anonymous HTTP range reads of OpenNeuro through the registry's page cache; nothing is written to disk..nirs)Findings per 100 files (identifier / review), before the rulings and after:
.setbefore.setafter.nirsbefore.nirsafter.mataftermat-freetext-namemat-freetextmat-identifier-fieldeeglab-subject-nameeeglab-subject-freetexteeglab-event-nameeeglab-setname-namesubjectis two capital letters, probably initials. This is an explained true positive.eeglab-event-name(3 datasets):ds003739,ds004295andds004588. Each hit is a pair of dictionary words in an event type, not a name (word classes checked, values not printed).eeglab-setname-name(4 datasets: ds004105, ds004106, ds004117, ds004119): task words in the set name, not names.mat-freetexton.set(5 datasets): home paths incomments(ds002158, ds003061, ds003670, ds004348) and in the BIDS README copy (ds003602). The path rule stays on both by ruling.mat-freetexton.mat: FieldTrip provenance (cfg.callinfo.pwd,cfg.version.name,cfg.toolbox.cleanup) in ds003702 and ds004475, plus ds004563.mat-identifier-field(review) is ds004563 only.timepartials on.matcome from a home connection with 6 files in parallel.Bounds
.setwith its signal inside (ds003800 fixture): no range the walker asks for overlaps thedatapayload (2.28 MB of the 2.33 MB file), and under 64 KiB is asked in all.limit; a cap set to exactly the bytes needed does not..setin the sample was compressed with its signal inside one variable; the two compressed single-variable files had an.fdt. So the stop condition did not arise.Fixtures
test/fixtures/mat/README.mdrecords source, commit or dataset, license, SHA-256 and the edits for each fixture: eegprep'seeglab_data.set(BSD-2), ds003800's embedded.set(CC0), Homer3'sSimple_Probe.nirs(BSD-2), ds003490'sONOFF_4Oddball.mat(CC0), and two edited copies with a made-upsubjectand a home path infilepath(classic, written by scipy; v7.3, edited with h5py). Each fixture is checked against a scipy or h5py oracle (scripts/dev/mat-oracle.py).Tests
test/mat-meta.test.ts: the walker against scipy for every Level 5 fixture, the v7.3 char arrays against h5py, bounds, caps in both directions, opaque and sparse classes built byte for byte, damaged input and source failures.test/readers-eeglab.test.ts,test/readers-homer-nirs.test.ts,test/readers-mat-generic.test.ts,test/readers-person-fields.test.ts: every rule with a twin; the companion throughreadRecordingsand through the local screen (screenLocalDataset, a.setwith and without its.fdt); a.setinside a ZIP intest/readers-zip.test.ts.Gates (head 2a0b7b2)
bun run typecheckandbun run lintclean;bunx biome checkon every touched file: no fixes. Targeted tests (the five the card names plus zip, coverage contract, scan, screen report, local screen, preflight and the other readers): 662 pass, 0 fail. Pure tier: 28,129 pass, 3 fail; the failures (website account-copy parity, which reads a sibling website checkout, and the git-annex UUID retry test) fail the same way on the base branch.Review round 1
corrupt. A struct with no fields walks nothing: MATLAB writesstruct()as 1 x 1 with no fields, so this is notcorrupt; failing it made 21 public files corrupt. A 1e9 x 1e9 struct returns at once ascorrupt.count * element size + 8bytes, otherwisecorrupt, and at most the numeric cap is converted.corruptand is not read.Directreads check for overflow.unscannedMatskips location fields and FieldTrip provenance, so a longfilepathdoes not make a file partial.pwdandcwdare location words, andpathjoins the run-together suffixes.nosedir,redirandprofileare not locations.cfg.version,cfg.callinfoandcfg.toolboxare provenance and are not read at any depth;cfg.previousis walked. Re-measured.matgate (254 files):mat-freetext0/1.97 andmat-identifier-field0/1.97, both ds004563; this was 0/7.09 format-freetext.Finding.count(reader-internal, not reported) is now the single count field for the ZIP and MATLAB readers, replacingentriesandoccurrences.nosedir). Each was applied and each fails the targeted tests..setgate re-measured after these fixes: unchanged (228 complete, 18 partial: limit 9, unsupported-datatype 9; no newcorrupt).