Skip to content

Release 0.2.33 - #477

Merged
neuromechanist merged 7 commits into
mainfrom
staging
Oct 21, 2026
Merged

neuromechanist merged 7 commits into
mainfrom
staging

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Release 0.2.33

Promotes staging to main with a regular merge. The release is one feature, the browser BIDS check on the upload page (#473, ADR 0028), plus the changelog move (#476) and the version commits. The changelog entry is under ## [0.2.33] - 2026-10-21.

What ships

  • The upload page checks the dropped folder with the BIDS validator in the browser, before any file is sent. The validator is @bids/validator 3.0.2, the release nemar-cli pins. It runs in a Web Worker that is loaded only when a folder is validated.
  • An error stops the upload button, as the repository check does. A warning never does. Errors on git-annex pointer files are ignored, as the repository check ignores them.
  • A HED schema that could not be downloaded is listed and not counted. Every other HED schema error stops the upload.
  • If the check cannot run, the page says so and the upload stays possible, because the repository check remains the authority.
  • The worker's own policy (public/_headers) adds 'unsafe-eval' for the worker's path only. The page's policy does not change.

Pre-release checklist

  • Gate for the API service binding (ADR 0026): the release carries [[services]] binding API to nemar-api. The production API must run nemar-cli#1710. #1710 merged on 2026-10-12 and is in nemar-cli main, so the production API (0.10.22, live since this morning) runs it.
  • Staging tip green: CI and Deploy staging on the Prepare-release commit 680ccf8.
  • Staging verified (test.nemar.org): the worker is served at /vendor/bids-validator/3.0.2/bids-validator-worker.js with 200, application/javascript, the worker's own policy and Referrer-Policy: no-referrer; its bytes match SHA256SUMS.
  • No migration, no new secret. Config changes: the API service binding (already on staging).

Known limits (stated in the PR and ADR 0028)

Post-merge checks

  1. https://nemar.org/version.json reports 0.2.33, and x-nemar-version on https://nemar.org/ shows the same version.
  2. https://nemar.org/vendor/bids-validator/3.0.2/bids-validator-worker.js returns 200 with the worker's headers and the SHA256SUMS hash.
  3. https://nemar.org/upload redirects to sign-in without a session.

Rollback

  • Pages: redeploy the previous main deployment from the Cloudflare dashboard, or revert this merge on main and let the pipeline redeploy.
  • The new /vendor/... path is additive. Reverting it leaves the upload page with the instant structure check only.

nemar-bot and others added 7 commits October 16, 2026 04:38
## Summary

The upload page now validates the dropped folder with the real BIDS validator (`@bids/validator` 3.0.2, the release nemar-cli pins and the repository check runs) in the browser, before any file is sent.
The instant structure check is unchanged and runs first; the full check follows it, with a progress state and a panel of findings grouped by code, errors first, with file paths.
An error disables the upload button and a warning never does, which is the repository check's rule, including its exemption for git-annex pointer files.

The design and the alternatives are in ADR 0028.
A follow-up, #474, builds the validator from `npm.jsr.io` with Bun, so that it need not be committed.
This PR targets `staging`, so the issue is closed by hand after the merge.

## Where this differs from the issue text

- **The validator runs in a module Web Worker, not on the page.**
  The issue proposes importing it on the page.
  Measured in Chrome 155, that fails: the validator evaluates code with the `Function` constructor (the schema's expressions, and Ajv), and `/upload`'s Content-Security-Policy has no `'unsafe-eval'`, so the run throws `EvalError`.
  A worker takes its policy from its own response, so the worker script gets a header rule in `public/_headers` (`default-src 'none'; script-src 'self' 'unsafe-eval'; connect-src https://raw.githubusercontent.com`, with `Referrer-Policy: no-referrer`) and the page's policy is untouched.
  The alternative, `'unsafe-eval'` on `/upload` in the pattern of ADR 0009, is one line in `src/middleware.ts`; the rest of this PR does not depend on the choice.
- **`@bids/validator/web` does not exist in 3.0.2.**
  The worker imports `@bids/validator/files/browser` (`fileListToTree`) and `@bids/validator/validate` (`validate`).
- **The pin is 3.0.2, not 2.4.1** (nemar-cli `dev`).
- **The validator is vendored, built with Deno, and committed.**
  Bun cannot install a `jsr:` specifier, and Cloudflare's build has no Deno.
  JSR's npm registry (`npm.jsr.io`) does serve the package, and Bun can install it with a scope entry; `bun build` of the entry points gave a bundle that reported the same findings.
  That route was not built through Astro and Vite; ADR 0028 records it as the alternative a later change could take, with the protocol, gate, panel and tests unchanged, and #474 tracks it.
- **`/upload`'s initial payload is not unchanged: its own script grows by 11.2 KB (4.1 KB gzipped).**
  The issue asked to keep it unchanged.
  The 10 MB validator is still fetched only when a folder is validated, but the code that drives it (the client, gate, report, panel and wording modules) is part of the page's script, which goes from 13,783 to 25,031 bytes (4,841 to 8,927 gzipped), and the site's one stylesheet grows by 4,077 bytes (891 gzipped).

## What is in it

- `validator-version.json` (copy of nemar-cli's pin), `scripts/vendor-bids-validator.ts` (Deno; `--relock` after a pin move), `scripts/bids-validator-worker.ts` (the module it bundles), `scripts/bids-validator-worker.lock`.
- `public/vendor/bids-validator/3.0.2/`: the bundle, `SHA256SUMS`, `provenance.json`, `THIRD_PARTY_LICENSES.txt` (the 37 packages and the Node.js shims the bundler adds).
  The build is reproducible: the same bytes from a cold Deno cache and from another directory, given network access and the same Deno (2.9.7).
  `.gitattributes` marks `public/vendor/**` as generated, so GitHub folds it and `git diff` does not print the bundle; `provenance.json` and `SHA256SUMS` stay diffable.
- `src/lib/bids-validation/`: `protocol.ts` (shared with the worker, imports nothing), `gate.ts`, `report.ts`, `wording.ts`, `client.ts`, `panel.ts`; `src/components/BidsValidationPanel.astro`; the wiring in `src/pages/upload.astro`.
- `.bidsignore` now travels with a web upload (`src/lib/upload-client.ts`, `src/lib/bids-precheck.ts`): the dropzone skipped every dotfile, so a dataset that lists its non-BIDS files there could pass neither check from the browser.
  Other dotfiles are still skipped.
- Tests: vendored-asset integrity and the worker policy, the pin comparison with nemar-cli, the committed bytes run on real datasets, the panel and its markup, and unit tests of the helpers.
  Fixtures are real files; `test/fixtures/bids-validation/README.md` names the origins, including a pointer written by git-annex itself.
- ADR 0028, a CHANGELOG entry, AGENTS.md notes; `ci.yml` sparse-checks out nemar-cli's pin.

## Gating rule

| Finding | Upload |
|---|---|
| `warning` | allowed, listed collapsed |
| `error` | blocked |
| `error` whose `location` is a git-annex pointer file | not counted, noted on the panel; the headline says no errors need fixing |
| `HED_ERROR` with `SCHEMA_LOAD_FAILED`, where the browser's request for the schema got no answer at all | not counted, listed with the warnings; the verdict is amber and says "The HED annotations were not checked." |
| any other `SCHEMA_LOAD_FAILED`: HED columns and no `HEDVersion`, an invalid or unmergeable specification, a version GitHub answers 404 for, any other answer from GitHub (a 503 included) | blocked, as the repository check blocks it |
| the validator could not run (no worker, failed load, crash, a result that is not a report, a throw before it has an answer or while drawing one with no errors in it, no answer in 15 minutes) | allowed, in a state of its own that is never worded as a pass |
| a throw while the panel draws a verdict that has errors in it | blocked: the verdict is kept, and the line beside the button says so |

The pointer rule is the repository check's (`run-bids-validation.yml`): a file of fewer than 1024 bytes with a line that starts `/annex/objects/`, compared with the error's `location` as a whole string.
A browser is never told about symlinks, so the check's other half, symlinks, has no counterpart here.
The options are the check's (`maxRows` 1000), except that warnings are kept, because the page lists them.

The HED row is the one place the page is more lenient than the repository check, on purpose, and it is narrow.
`SCHEMA_LOAD_FAILED` is one sub-code for seven conditions of the HED validator; only a request that got no answer (offline, a failed lookup, a blocker) is the browser's failure and not the dataset's, and an answer from GitHub, of any status, is the answer the check would get.
The gate tells them apart by the validator's own wording, anchored at the start of the message because the validator quotes a dataset's `HEDVersion` into some of its other messages, and a wording it does not know stops the upload.
The cost is that a page that cannot reach GitHub lets through a HED dataset naming a version that does not exist, which only the repository check catches.

## Privacy

The panel says the check runs in the browser and nothing from the files is sent anywhere, with one stated exception: a HED schema version the validator does not ship is downloaded from `raw.githubusercontent.com`, in a request that carries only its name and version and no Referer.
Checked in Chrome with every request logged: no request at all for a dataset whose HED schema ships (and for datasets with none), one `GET` for one whose does not.
The worker's own policy allows that one host and nothing else; a same-origin `fetch`, another host, a WebSocket and `importScripts` were all refused, in Chrome 155 and in Firefox 158, under `wrangler pages dev`, which applies `_headers` as Pages does.

## Verification

- [x] `bun install`: no changes (`package.json` and `bun.lock` untouched, no version bump).
- [x] `bun run test`: 153 files, 4121 tests pass (the base had 144 files, 3917 tests), run as CI runs it: the five `NEMAR_CLI_*` variables against a snapshot of nemar-cli `dev`.
  A sibling `../nemar-cli` that is behind `origin/dev` fails the new pin test (a stale one pins 2.4.1); update it, or set `NEMAR_CLI_VALIDATOR_PIN`.
- [x] `bun run typecheck`: 0 errors, 0 warnings (the 13 hints are the base's).
- [x] `bun run lint`: clean.
- [x] `bun run build`: succeeds, with the same five warnings as the base; `dist/_routes.json` excludes `/vendor/*`, so the files are static assets, and `dist/_headers` carries the worker rule.
- [x] CI on this PR: lint, typecheck, test (153 files, with the strict drift tests against nemar-cli `dev`), build and the Cloudflare Pages deploy all pass.
- [x] Each of the 20 commits passes the suite, typecheck and lint on its own.
- [x] The bundle is byte for byte what was first committed: `sha256sum -c SHA256SUMS` passes, and its ETag on the preview deployment did not change between the first head and this one.
- [x] The HED cases, run on the committed bytes: the validator's wording for no `HEDVersion`, an invalid one, unmergeable library schemas and a 404 was captured in Chrome 155 (the worker served by a preview deployment) and Node 26 (the library schemas in Node only), and for a request with no answer in Chrome (aborted) and in Node 26 and Deno 2.9.7 (`HTTPS_PROXY` at a closed port).
  The wording is copied into `gate.test.ts`; the integration tests produce the ones that need no network again (a real local server that answers 404 or 503, a closed port for no answer), so a validator release that rewords one fails there.
  Against the old broad rule 18 of the new tests fail.
- [x] Mutation checks: an edited worker source, a hand-edited bundle, and a pin moved without a rebuild each fail the vendor test; ten mutants of the gate, protocol, report and wording code, nine are caught (the tenth changes nothing observable); and after review mutants of the HED rule (never exempt, no start anchor), of the dropzone rule for `.bidsignore`, of `panel.ts` using `innerHTML`, of the deadline parameter and of terminating the worker are all caught.
- [x] Real Chrome 155 against `astro dev` with the dev sign-in: valid, broken-sidecar, git-annex-pointer, HED (bundled; no `HEDVersion`; a version GitHub answers 404 for; a request that gets no answer), structure-error and larger datasets (1,204 files and 10,404 findings in 0.8 s from the click; 20,003 files and 135,003 findings in 24 s); a `.bidsignore` upload by the file input and by a real folder dropped through CDP, which runs the drag-and-drop walk (9 files kept with `.bidsignore`, `.DS_Store` left out); Cancel, a second drop while running, "Drop something else", Enter in a field while blocked; five ways for the worker to fail (offline, 404, a script that throws, the wrong content type, an answer of `failure`) and three more (a result that is not a report, a throw while the panel draws the result, with and without errors in it, no panel on the page); the 15-minute limit with a faked clock; Tab to a findings list and ArrowDown scrolling it; focus and the live-region announcements; light and dark; 390 px wide with no horizontal overflow.
  Firefox 158 ran the policy probe and the real validator through `wrangler pages dev` with the same results.
- [x] Smoke test with `bun run dev`: `/upload` without a session answers 302 to the sign-in page, and with the dev session 200 `text/html` with no reference to the vendor file, no preload and no `'unsafe-eval'` in its policy; the asset URL answers 200 `text/javascript`, 10,267,556 bytes.
- [x] On the Cloudflare Pages preview deployments of this PR: the worker asset answers 200 with the `content-security-policy` and `referrer-policy` of the `_headers` rule and `cache-control: public, max-age=0, must-revalidate`, `/upload`'s own policy is unchanged, and in Chrome 155 the module worker, started from that origin, validated the `bids-minimal` fixture (0 errors, 30 warnings, schema 1.2.7, about half a second with the download) with no request other than the asset.
- [x] `/upload`'s own load: its script grows from 13,783 to 25,031 bytes (4,841 to 8,927 gzipped); the site-wide stylesheet grows by 4,077 bytes (891 gzipped).
  Nothing imports the bundle (the page script holds the worker's URL as a string), the HTML names no vendor file, the worker file is requested only when a folder is validated, and the server bundle lists the files as static assets and does not carry them.

Asset: 10,267,556 bytes (1,456,230 with `gzip -9`, 872,874 with `brotli -q 9`).

## Known limits

- No browser run happens in CI: the worker, the policy and the page were exercised with scripted Chrome and Firefox runs that this PR does not add (there is no end-to-end harness here, website#435).
  A few of the tests read the page's and the panel's source as text (the guard around the bind, the fallback line, the single `try`, the `textContent` rule, the list's tab stop), because there is no DOM to run them in; they are named for what they are.
  Safari was not run.
- The drag-and-drop walk (`walkEntry`) needs a browser's `FileSystemEntry`, so its plumbing has no automated test.
  Its per-file decision, which `.bidsignore` depends on, is one function, `toDroppedFile`, shared with the file input and tested with real files, and the walk itself was run in Chrome on a real folder.
- The policy is enforced where `_headers` is served.
  It was checked on this PR's preview deployments (above), not on `test.nemar.org` or production.
  After the merge to `staging`, `curl -sI https://test.nemar.org/vendor/bids-validator/3.0.2/bids-validator-worker.js` should show the same `content-security-policy` and `referrer-policy`; without them the worker still runs, but the privacy sentence no longer holds.
- A re-vendor at the same version reuses the worker's URL and relies on revalidation by ETag (Pages sends `max-age=0, must-revalidate`); the path must never be given a longer lifetime.
- Symlinks are invisible to a browser (above).
- A page that cannot reach GitHub lets through a HED dataset naming a version that does not exist; the repository check catches it.
- "The same validator" holds for a release, not for what it resolves: the repository check runs the release without a lock, so a patch release of one of its dependencies can change a finding on one side until the next re-vendor.
- The bundle is one 10 MB file because the HED validator is inside it, and splitting it makes the bytes depend on the Deno cache path.
- Every move of nemar-cli's pin (its workflow runs monthly) turns this repository's CI red until the file is copied and `deno run -A scripts/vendor-bids-validator.ts --relock` is run; that needs Deno on a maintainer's machine, not in CI.
- `docs.nemar.org/web/uploading` describes BIDS validation as server-side only, so it needs a matching update in the documentation repository, which this PR does not touch.

Refs #161
The entries that merged to staging since 0.2.32 move under the version heading, as the release
pull request does for every release. Unreleased is empty again for the next change.
@neuromechanist
neuromechanist merged commit 08f0491 into main Oct 21, 2026
10 checks passed
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