Skip to content

Quality inventory, copy and reader - #2537

Merged
neuromechanist merged 19 commits into
feature/issue-2524-epic-quality-axesfrom
feature/issue-2525-quality-inventory
Nov 28, 2026
Merged

neuromechanist merged 19 commits into
feature/issue-2524-epic-quality-axesfrom
feature/issue-2525-quality-inventory

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2525 (epic #2524), phase 0a.3 PR 2 of 2. It follows #2534 (neuroschema 0.7.0 vendored).

This PR declares every quality element once, with its sentences and a typed reader (ADR 0146 decisions 3 and 4). Nothing reads it yet: website 0b/1b and the phase 1a checker will.

Files

  • shared/contract/quality/inventory.json: item set 1.0.0. It has 33 elements: 11 signal, 13 metadata, 7 annotation, 2 precondition. It also declares 21 reason words, 9 producers with their current versions, and the profile eeg-bids-metadata-stats-2024, which is named on the legacy table's 13 rows.
  • shared/contract/quality/inventory.schema.json: draft 2020-12, $id https://api.nemar.org/schemas/quality-inventory-v1.json, $defs Element, Producer, Reason, Profile, closed everywhere.
  • shared/contract/quality/copy.json (nemar.quality-copy.v1): 137 keys, sorted, including the 21 literal banner.<axis>.<state> keys, 16 fix.* sentences each with its .href, the six datatype.<word> display names, and the not-computable sentences for each count unit.
  • shared/contract/quality/build-sums.mjs [--check] and SHA256SUMS.json (nemar.contract-files.v1). The sums cover the three files, read as git blobs of HEAD; uncommitted changes to them are refused. The list names no commit.
  • shared/contract/quality-inventory.ts, exported from shared/contract/index.ts. It provides the constants, the strict zod schemas, QUALITY_INVENTORY and QUALITY_COPY (parsed at import), and four functions: qualityProducerVersion, qualityInventoryProblem (17 words, first broken rule in order), qualityElementsFor and fillQualityCopy.
  • test/contract-schemas.test.ts: quality-inventory.ts is in STRICT_BY_DESIGN, and QUALITY_INVENTORY_NAMES (6 schemas) joins STRICT_NAMES (now 41) and the index-export test.
  • .github/workflows/test.yml: the process-copy sparse list adds recipes/nemar_process/plugins/{nemar_quality,nemar_spectrum}/manifest.json, with the comments updated. The metrics test reads them under NEMAR_REQUIRE_PROCESS_RECIPES: "1".
  • test/unit-pure-timings.json (both new files), and CHANGELOG.md (Unreleased).

Tests and what they hold

test/quality-inventory-contract.unit.test.ts (28 tests):

  • every exported constant is pinned, and the axis counts are fixed;
  • nemar-floor and nemar-ica carry findRecipe(...).version, @bids/validator carries validator-version.json, and nemar-zarr carries ZARR_ENGINE_VERSION from scripts/zarr/zarr_queue.py (a text test);
  • a literal list of the website's keys exists in the copy (a mutation test checks that a deleted key is named), and every fix.* has a docs.nemar.org .href;
  • the withheld reasons exist;
  • an 18-case corpus gets the same verdict from Ajv 2020 strict and from zod. It includes a 48 and a 49 code-point astral display_name, display_precision 6 and 7, an unknown key, a bad prefix, an empty, repeated or unknown applies_to, and a fix without fix.;
  • one broken fixture per qualityInventoryProblem word, in order, plus null for the committed files;
  • the states, the state.* and state_word.* keys, and the bundle's qualityState enum are the same eight words, and the value.* words are qualityItemResult.value without null;
  • ids, reason words and exported variables match the bundle's qualityItemResult.id, failureCode and metricName patterns;
  • copy rules and fillQualityCopy, and qualityElementsFor for MEG (metadata and signal) and for mixed datatypes;
  • SHA256SUMS.json sizes and digests, a mutation test (a flipped byte, a missing file and an unlisted file are each reported), and build-sums.mjs --check spawned, which exits 0;
  • the inventory's neuroschema_version equals NEUROSCHEMA_VERSION.

test/quality-inventory-metrics.unit.test.ts (6 tests):

  • Every signal element's exported variable is a metric the pinned nemar-process product writes. The product is the recording record's extensions.nemar.metrics, plus the plugin metrics in processingSteps[].qualityMetrics and the nemar-ica distributions.
  • Every distribution has an element.
  • Each stored unit maps to the element's unit (count maps to components, iterations or channels; fraction maps to % with scale 100; nat maps to nats).
  • The plugin manifests from NEMAR_PROCESS_DIR parse under PluginManifestSchema, and every metric they declare is written. Without the variable this test skips and logs why; under NEMAR_REQUIRE_PROCESS_RECIPES=1 a missing manifest fails it.

Deviations from the card

  1. producers (array) replaces producer (lead ruling 7). The six floor metrics name ["nemar-floor", "nemar-ica"], and the ICA and plugin metrics name ["nemar-ica"].
  2. QUALITY_COPY_READ_PREFIXES adds heading. and legend.. Without them, the card's own keys heading.version and legend.title would be copy_key_unread.
  3. lineNoiseAfterDb's definition stands alone. It now reads "How far power at 50 or 60 Hz (whichever was larger before removal) stands above neighboring frequencies, after the band-stop filters." The source text "The same, after ..." reads as nothing in a tooltip of its own.
  4. The metadata banners say "Metadata completeness ..." without "quality", as the card's explicit banner.metadata.* rows do. Signal and annotation say "Signal quality ..." and "Annotation quality ...".
  5. id_repeated also covers repeated reason words and profile ids, and prerequisite_unknown also covers a reason's blocks_on. qualityProducerVersion throws on an undeclared producer instead of returning null. build-sums.mjs exempts itself from the "not listed" check.
  6. The card's local gate points NEMAR_PROCESS_DIR at a nemar-process checkout on main, which has no plugin manifests, so the manifest comparison skips there. I also ran the metrics test against nemar-process dev (a93410f) with NEMAR_REQUIRE_PROCESS_RECIPES=1, and it passed.

The docs pages for the fix.*.href targets are filed as nemarOrg/docs#151 (lead ruling 6). The TypeScript replay of the item-checks and conformance-checks vectors belongs to phase 1a.

What the website will need (handoff to 0b, website#625)

  • A second copy source, in scripts/copy-quality-views-vocabulary.mjs or a sibling scripts/copy-quality-contract.mjs. It reads nemar-cli shared/contract/quality/SHA256SUMS.json, requires format === "nemar.contract-files.v1", and checks each listed file's size and SHA-256 before writing. It copies inventory.json and copy.json to src/lib/quality/contract/ (shipped) and inventory.schema.json to test/fixtures/quality/contract/ (tests only), and refuses any listed path it cannot place.
  • A third source for the state vectors: shared/contract/neuroschema/quality/SHA256SUMS.json (nemar.vendored-files.v1), copying vectors/*.json to test/fixtures/quality/vectors/.
  • A pin, src/lib/quality/contract/pin.json (nemar.website-vendored-quality.v1), recording item_set_version, neuroschema_version, the nemar-cli commit (git -C "$NEMAR_CLI_DIR" rev-parse HEAD) and every copied file's digest. A drift test holds the copies to the pin and the pin to nemar-cli.
  • .github/workflows/ci.yml: add /shared/contract/quality/ and /shared/contract/neuroschema/quality/ to the nemar-cli-contract sparse list, plus an env var naming the sums file.
  • Re-run the existing views copy: its pin moves to 0.7.0.
  • A {datatype} placeholder is filled with datatype.<word> (EEG, MEG, iEEG, EMG, NIRS, motion), never the raw word. A not-computable sentence is chosen by the element's count_unit: not_computable.<unit> and not_computable.blocked_by.<unit>, where unit is recordings, participants or dataset. state.not_computable is the generic "Not computable: {reason}.".
  • QUALITY_INVENTORY and the elements qualityElementsFor returns are deep-frozen and typed read-only.
  • The website's key names follow this copy (state_word.<state>, qualifier.stale_dataset, qualifier.stale_unrecorded, info.direction.<d>, info.exported, precondition.integrity.{present,complete,incomplete,not_audited}, precondition.conformance.not_stored, reason.<word>, legend.title, footer.how_computed). The site writes no state sentence of its own.
  • The website's drift tests against nemar-cli dev stay red until the whole epic merges (one merge).

Gates

  • bun shared/contract/quality/build-sums.mjs --check
  • bun run typecheck && bun run lint
  • bunx biome check on shared/contract/quality, the reader, index and the three test files: clean
  • NEMAR_PROCESS_DIR=<nemar-process checkout> bun test on quality-inventory-contract, quality-inventory-metrics, contract-schemas and ci-tier-routing: 243 pass, 1 skip (the manifest comparison: that checkout's main has no plugins)
  • the same metrics test, with contract-neuroschema and plugin-manifest-contract, against nemar-process dev with NEMAR_REQUIRE_PROCESS_RECIPES=1: 165 pass
  • Not run: the full suite (it runs at epic to dev).

Review

  • Review round 1 (538c653): 1 important and 3 moderate findings, all fixed, plus the lead's producer ruling.

    • Added datatype display names (datatype.* keys, with a datatype. read prefix) and a test that every datatype has one.
    • Not-computable sentences now come per count_unit, with both units tested, so the six dataset-level elements with prerequisites no longer read "1 of 1 recordings". not_computable.blocked_by became not_computable.blocked_by.<unit>.
    • The metadata and annotation not_supported banners now end ": NEMAR has no checker for it."
    • QUALITY_INVENTORY is deep-frozen and typed DeepReadonly; a test checks that a push and an assignment throw.
    • The build-sums --check spawn now runs git with GIT_OPTIONAL_LOCKS=0 and has a 30 s timeout. The flake did not reproduce in 11 runs of the combined set, including after bun install.
    • Added PRODUCERS_IN_THIS_EPIC (nemar-metadata, nemar-annotation, each with the file its phase ships). It follows the TOLERATED_GAPS pattern: every producer of an element with a non-empty supported_for has a non-null current_version unless it is listed, and an entry whose file exists, or that names no supported element, fails. The epic-to-dev seam review checks that the set is empty.
    • Added UNVERSIONED_BY_DESIGN (nemar-data-plane): the integrity audit is built but has no version. It is not an epic exception, so the lead should confirm it.
    • Tests: the card set gives 250 pass, 1 skip (the manifests are not on nemar-process main). Typecheck, lint, biome and build-sums --check pass.
  • Review round 2 (f6b849a): three changes, all applied.

    • Per the lead's ruling, nemar-data-plane is now current_version: "1.0.0", which stands for today's integrity rule (data_complete, bytes_present, ADR 0005 and ADR 0064). A comment beside the test's pin says a change to the rule bumps the version. UNVERSIONED_BY_DESIGN is removed.
    • nemar-metadata is now current_version: null until phase 1a ships it. The stale check reads the inventory instead of guessed paths: an entry fails if its producer is versioned, undeclared, or names no supported element. A pure staleExceptions function makes each of these cases testable.
    • The self-check now gives the curator a supported element, so the "no version needed" line can fail.
    • SHA256SUMS is regenerated. The card set gives 250 pass, 1 skip, three times in a row. Typecheck, lint, biome and build-sums --check pass.
  • CI fix (465a36b): unit-pure shard 3/6 failed because test/docs-links.unit.test.ts ("every referenced page exists") rejected the 16 fix.*.href links in copy.json. Those docs pages do not exist yet (nemarOrg/docs#151). The test now has a PENDING_PAGES map (/quality/metadata, /quality/annotation, /quality/conformance, each naming docs#151) that tolerates those pages only when the pointer is in shared/contract/quality/copy.json. A new test fails once the docs repository publishes a page or once copy.json stops pointing at it, so the entry cannot be left behind.


Agentic AI tools were used. Workflows follow the Research Skills (doi:10.5281/zenodo.20696515). The author assumes full responsibility for this content and associated changes.

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2537

Version: 0.10.61-PR2537.465a36b
Commit: 465a36b


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit cf2c3ef into feature/issue-2524-epic-quality-axes Nov 28, 2026
31 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2525-quality-inventory branch November 28, 2026 22:37

This branch was previously deployed

1 inactive deployment
npm — 465a36b4 Deployed Nov 28, 2026 by neuromechanist via publish #5310
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