Repository navigation
Bounded pure-TypeScript HDF5 metadata reader (A3) - #2378
Merged
neuromechanist merged 7 commits intoNov 25, 2026
Merged
neuromechanist merged 7 commits into
neuromechanist merged 7 commits into
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2378Version: 🤖 Updated on each push. |
Contributor
Author
|
Merge gate (lead): head df1a9eb. Every remote check passes after one rerun of unit-pure shard 2, which failed on the zarr-source-check stall-timeout flake (#2377), a file this diff does not touch. Review: round 1 panel (code+tests as an adversarial parser review; errors+comments+types), 2 important findings (the walker could throw; unshuffle could hang) and 4 more fixed; round 2 delta review resolved every item; its fuzz time-bound suggestion is fixed in df1a9eb, and the other two are accepted as designed. Lead ruling: the walker's logical read cap is 20,000, and the real bounds are at the source. |
neuromechanist
merged commit Nov 25, 2026
d767b62
into
feature/issue-2182-epic-pq-evidence
51 of 53 checks passed
neuromechanist
added a commit
that referenced
this pull request
Nov 26, 2026
* Add text-header kinds, copy and helpers * Register BrainVision and NIRx readers * Add the reader false-positive measure script * Bounded pure-TypeScript HDF5 metadata reader (A3) (#2378) * Add the h5py oracle for HDF5 metadata * Add HDF5 fixtures and their h5py oracle output * Add a bounded HDF5 metadata walker * Test the HDF5 walker against h5py * Count logical reads; default cap 20,000 * Review round 1: never throw, shuffle, zero sizes * Bound each fuzz walk at 200 ms * Add not-applicable and notes to readers * Apply lead rulings to text-header readers * Bound free text; decode UTF-16 headers * Scan unplaced text; narrow not-applicable * Require three signs for not-applicable
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 #2366
Part of #2182
Card A3 of the publication-queue plan: a dependency-free TypeScript walker that lists every group, dataset and attribute of an HDF5 file through random-access reads, returns strings and small numerics, and never reads a large numeric dataset. Cards A4 (SNIRF) and A5 (MATLAB v7.3) build on it.
What it does
shared/hdf5-meta.tsexportswalkHdf5(source, { limits }), returning{ entries, complete, incomplete?, tally }; the format decoding lives inshared/hdf5/(io.ts,messages.ts,structures.ts).read; the fetch cap that bounds the network is the source's, A1's page-cached source and the reader registry limits), 20,000 entries, depth 32; every read is checked against the file size before the source is asked; each object address is visited once. An unsupported construct is skipped and recorded; a limit, a failing source read, or any error no decoder foresaw (recorded ascorrupt) ends the walk with the entries found so far:walkHdf5never throws.scripts/dev/hdf5-oracle.py(run withuv run --with 'h5py==3.16.0') prints the same entry list from h5py; the tests compare against the committed oracle JSON, so CI needs no Python.Fixtures
Three real recordings (public-domain snirf-samples Simple_Probe written by EasyH5/JSNIRFY, a BSD-2 Homer3 export, and the BSD-2 EEGLAB tutorial
.setsaved as MATLAB v7.3 from sccn/eegprep) and four small h5py-written files (dense storage under libver latest, chunked deflate strings, two unsupported constructs). 6,128,873 bytes in total, committed as plain blobs; sources, commits, licenses and hashes are intest/fixtures/hdf5/README.md.Deviations from the card
RangeSourceis defined locally inshared/hdf5/io.ts(A1, Coverage contract and reader registry (A1) #2374, is not merged); A4 switches to A1's.Hdf5Incompletegainsread-failed: a source read that throws ends the walk with the entries so far instead of losing them.valuecan also bestring[](a non-scalar string dataset);skippedcan also betype(reference, compound and the like) anderror(the reason is inincomplete); dataset entries carrystorage(layout, data address and size), which the no-signal test uses.MATLAB_fields) is read as strings (vlen:string), and datatype version 5 (what libhdf5 2.x writes under libver latest) is accepted; references are listed withskipped: "type"and do not make a walk incomplete..set(1,558 object headers) takes about 2,060 exact reads, and its oracle test runs at the default; a separate test shows a 2,000 cap stopping it withlimit-readsand a partial list. Headers packed back to back are read one per read (the read carries the next header's 16-byte prefix only when that header starts exactly there), so no byte outside a known structure is fetched.Review round 1
Fixed:
walkHdf5never throws (unforeseen errors are recorded ascorrupt); the shuffle filter's element size must equal the datatype's and be nonzero, checked before any loop; a zero-byte datatype is corrupt, and the chunk path refuses an element size below 1 and bounds the per-chunk element count before any per-element loop; the fixture total is corrected; the module docblock states the chunk-cap andskipped: "type"rules.Tests
bun test test/hdf5-meta.test.ts: 26 tests; every fixture equals its oracle (the Fletcher-32 dataset's value is the one expected difference). Bounds: half-truncated file (corrupt, no throw, no read past the end), the end-of-file check alone, 4 KiB byte limit, default read limit, object and depth limits, a member patched to point at the root, a failing source, a source that breaks its contract (an unforeseen error, recorded as corrupt), a non-HDF5 file, 300 seeds of random bytes behind a valid signature and 200 seeds of random byte flips in a real SNIRF (always returns), a shuffle element size patched to 0xFFFFFFFF (corrupt within a 1 s bound), a datatype patched to zero bytes (corrupt). On the SNIRF fixture no read overlaps/nirs/data1/dataTimeSeriesand the walk reads 39,358 bytes in 319 reads. Every rule was reverted or widened one line at a time and each mutant fails a test (17 mutants, plus 3 for review round 1; the element-size floor and element-count bound in the chunk path are kept as defense in depth and cannot be reached once a zero-size datatype is refused, so their mutants are equivalent). The live tier was not run (phase-PR gate is local).