Skip to content

Phase B1: dataset quality summaries (#2324) - #2375

Merged
neuromechanist merged 17 commits into
feature/issue-2324-epic-pipeline-progressfrom
feature/issue-2324-b1-quality-summaries
Nov 25, 2026
Merged

neuromechanist merged 17 commits into
feature/issue-2324-epic-pipeline-progressfrom
feature/issue-2324-b1-quality-summaries

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Part of #2324 (phase B1 of the live quality views, ADR 0137 decision 8). Takes the B1 items of #2341 and the page-bundle issue #2331.

What changed

  • shared/contract/view-digest.ts: an I-JSON reader (RFC 7493) and nemar.view-digest.v1 (RFC 8785).
    The reader refuses a duplicate member (escaped or not), a lone surrogate, a noncharacter, nesting past 64 and a number that is not finite, and flags an integer literal past 2^53 - 1.
    All nine digest vectors (computed_view and numbers among them) and all fourteen refusals replay.
  • test/fixtures/quality/ica-views/: nemar-process tests/fixtures/ica-views (product and index.json) at e4feec7b, byte for byte, held to SHA256SUMS.json.
    With NEMAR_PROCESS_DIR naming a checkout that holds the commit, each copy is compared with git show.
    .gitattributes keeps git from normalizing it.
  • backend/src/services/quality-documents.ts and shared/contract/data-quality.ts:
    • a zod mirror of the dataset dataQuality (level and recipes only, closed root, integers at most 2^53 - 1, lengths counted in code points), with every pattern held to the bundle's text;
    • the writer's rules run again (nemar-process dataquality.problems): counts add up, listed + left out = failed + skipped, n = bins + underflow + overflow, edges, min/median/max, observed_range, unsafe integers;
    • the run checks: one entry keyed by the stamp's recipe; recipe version, dataset version and input equal the stamp's; record_sha256 equals the dataset record's bytes; counts equal the recordings table's; and every metric is bare or <plugin>: for a plugin of the recipe's quality checkpoint;
    • nemar.record-checks.v1 (all nine vectors replay);
    • recordQualityEntry, a recording's entry projected from its record. Recipe metrics come from extensions.nemar.metrics (so lineNoiseBeforeDb is the number, never summaryMetrics' table). Each plugin that ran adds its step's qualityMetrics (<plugin>: names only). views_skipped admits nemar-process's own words. Record checks run before the entry is returned. No route serves it yet (B2).
  • Migration 0151 compute_quality_documents: one row per stamp, with dataset_id and recipe from the stamp, the entry (65,536 or fewer characters), record_sha256 and written_at, and an index on (dataset_id, recipe, stamp_id).
    Deleted with the dataset in services/deletion.ts.
  • Reconcile (compute-pipeline-progress.ts): a succeeded run's product/desc-<label>_dataquality.json (at most 64 KiB) is checked as above against the record bytes read once for the run's link.
    A refused summary is not kept. It logs quality_not_written stamp=<id> reason=<word> and never holds the run back.
    A read fault leaves the run for a later call.
  • Serving: readPipelineExtensions is the one read /<id>/metadata.json and /<id>/page-bundle.json both use.
    extensions.dataQuality carries the summary of each recipe's current public derivative: stored, catalog or published, the newest by stored_at, with the larger key winning a tie.
    The predicate is CURRENT_PUBLIC_DERIVATIVE_SQL, for B2 to reuse.
    A canary shows nothing, and so does a concealed deposit. A private dataset is still a 404.
    The page bundle now carries processing, signalJourney and dataQuality (page-bundle.json does not carry the pipeline extensions #2331).
  • shared/compute-recipes.ts: recipeQualityDocumentPath, recipeQualityPlugins, and the maxFiles comment (17 files per recording, about 1,470 recordings).
  • CHANGELOG (Unreleased, Added), including the corrected nemar-ica file count in the result-limit bullet.

B1 checklist

  • Dataset dataQuality projection, level/recipes only, closed root
  • Writer rules run again: n = bins + underflow + overflow; observed_range; listed + left out = failed + skipped
  • views_skipped accepts nemar-process's words (no_good_window, frame_rotated, no_serving_index, not_in_serving_index, serving_index_stale)
  • Recipe metrics from extensions.nemar.metrics, plugin metrics from their step's qualityMetrics, merged
  • lineNoiseBeforeDb read from extensions.nemar.metrics
  • dataset_id bound from the stamp (write) and the D1 rows (read), never the document
  • nemar-quality:percentBrainComponents checked against the P7 fixture (n = 1; it equals the plugin step's value)
  • Integers at most 2^53 - 1
  • nemar.record-checks.v1 before an entry is returned
  • All nine view-digest vectors and the fourteen refusals, floats included
  • compute-recipes.ts maxFiles comment: 17 files per recording, about 1,470 recordings
  • Fixtures taken from nemar-process tests/fixtures/ica-views at a pin, by digest

Gates

  • bun run typecheck, bun run lint, bunx biome check on every touched TypeScript file: clean
  • bun run migrations:d1-check: 142 migrations replayed on real D1, catalog matches bun:sqlite
  • Root, targeted (485 pass): view-digest-contract, quality-documents-contract (also with NEMAR_PROCESS_DIR, byte comparison included), compute-recipes, contract-neuroschema, contract-schemas, adr-index, plugin-manifest-contract, compute-progress-contract
  • compute-recipes-process-drift with NEMAR_REQUIRE_PROCESS_RECIPES=1 against nemar-process e4feec7b: 16 pass
  • Backend, targeted (279 + 214 pass): quality-documents, metadata-json-quality, compute-quality-documents-migration, compute-pipeline, compute-progress-reconcile, metadata-json-pipeline-route, page-bundle-*, compute-progress-route, compute-runner-progress, compute-pipeline-grid, compute-pipeline-progress-migration, compute-derivatives, metadata-json-*, anonymity-projection, anonymity-publication-paths, anonymous-release, anonymity-writers, bids-index-session-modalities, data-route-manifest-stream, landing-payload-archive
  • Not run, would check: the full bun test, because it is the epic-to-dev gate (about 80 minutes). Also not run: anonymity-identifier-withheld, because it reaches real S3 and times out (Unit tier: anonymity-identifier-withheld page-bundle test reaches real S3 and times out #1548).

Mutation table

Each mutation was applied alone, the named suites were run, and the file was restored (git status was clean after each). 60 mutations, all killed.
M12 first survived: the profile comparison made the input comparison redundant, since the schema pairs them. The redundant profile comparison is removed (2a85c4c), and M12 is now killed.

# Mutation Killed by
M01 drop the retention term of the current public derivative metadata-json-quality, quality-documents (3)
M02 drop the state term metadata-json-quality
M03 newest by key alone metadata-json-quality
M04 tie to the smaller key metadata-json-quality
M05 drop the dataset bind on the summary join metadata-json-quality
M06 newest derivative that has a summary (fall back to an older run) metadata-json-quality
M07 skip the record digest check contract, quality-documents
M08 drop the counts check contract, quality-documents
M09 accept any plugin prefix (dataset) contract, quality-documents
M10 take the first entry contract
M11 drop the dataset_version comparison contract
M12 drop the input comparison contract (after 2a85c4c)
M13 drop counts_unbalanced contract
M14 drop listing_mismatch contract
M15 drop the n rule contract
M16 count missing in n contract
M17 drop the observed_range rule contract
M18 ignore the unsafe-integer flag contract
M19 open the document root (.passthrough()) contract
M20 count UTF-16 units instead of code points contract (Ajv agreement)
M21 drop the not_processed cap contract
M22 skip the record checks contract
M23 read summaryMetrics contract (7)
M24 merge every plugin step, ran or not contract
M25 accept an unprefixed plugin metric contract
M26 accept a prefixed recipe metric contract
M27 accept any plugin prefix (record) contract
M28 drop the store-profile rule contract (Ajv agreement)
M29 close views_skipped reason to neuroschema's five words contract
M30 drop the producer pairing of metric names contract
M31 change one character of relativeLocation contract
M32 record checks: drop view_source_mismatch contract (vectors)
M33 record checks: also check a plugin view's source contract (vectors)
M34 record checks: a skipped key never names a view contract (vectors)
M35 record checks: drop metric_producer_mismatch contract (vectors)
M36 metric names: accept any prefix contract, quality-documents
M37 I-JSON: accept a duplicate member view-digest, contract
M38 I-JSON: drop the noncharacter check view-digest
M39 I-JSON: drop the lone-surrogate check view-digest
M40 I-JSON: depth limit 65 view-digest
M41 JCS: print integers with .0 view-digest (9)
M42 JCS: sort names by locale view-digest
M43 JCS: escape / view-digest
M44 I-JSON: __proto__ through the setter view-digest
M45 I-JSON: let a byte order mark through view-digest, contract
M46 I-JSON: never flag an unsafe integer view-digest, contract
M47 reconcile: write the run when the summary cannot be read quality-documents
M48 reconcile: keep a failed run's summary quality-documents
M49 reconcile: bind the record's dataset instead of the stamp's quality-documents
M50 metadata.json: drop the anonymous gate metadata-json-quality
M51 page bundle: drop the anonymous gate metadata-json-quality
M52 page bundle: drop the pipeline read metadata-json-quality
M53 pipelineExtensions: drop dataQuality metadata-json-quality, quality-documents (7)
M54 deletion: keep the summaries compute-pipeline
M55 migration: drop the record digest GLOB compute-quality-documents-migration
M56 migration: drop the entry shape check compute-quality-documents-migration
M57 drop the recipe_version comparison contract
M58 drop the size check contract
M59 strip a byte order mark while decoding contract
M60 record entry: accept another recipe version contract

Deviations from the plan

  1. The digest and the I-JSON reader are in shared/contract/view-digest.ts, not B2's quality-route.ts. The backend reads the dataset summary with the reader in B1, and B2 imports it.
  2. The recording-level projection is in B1, as the lead scoped it. It checks the head of each view (key, kind, source) and the store-profile rule; validating the full view declaration stays B2's view mirror (quality-views.ts).
  3. The tests are named after this repo's conventions: test/quality-documents-contract.unit.test.ts and test/view-digest-contract.unit.test.ts, not test/contract/quality-documents-agreement.test.ts.
  4. The dataset version is compared with the stamp's version tag too, since pages name it. The profile is not compared on its own (see M12).
  5. The counts are compared with the recordings table's statuses (passed = succeeded rows, total = rows), which is how nemar-process writes them (see owner question 1).
  6. The route suites set promoted rows with SQL. The real promoteDerivative is exercised in quality-documents.test.ts through readPipelineExtensions, the read both routes call. It does not go over HTTP because an eligible dataset needs a version row, and with one the handlers reach S3.
  7. In the page bundle, a failed pipeline read fails the metadata component (no-store), while metadata.json leaves the namespaces out. This keeps a bundle that lacks them from being cached as complete.
  8. The run's signalJourney link now hashes the record's bytes rather than re-encoded text. The two are identical for valid UTF-8 with no byte order mark.
  9. The whole product and index.json were copied, because B2 needs the view files.

Questions for the owner

  1. The counts rule. neuroschema docs/processing-extensions.md says the dataset summary's counts.passed equals the last declared checkpoint's passed. nemar-process writes passed as the succeeded recordings, so the two differ when a plugin is skipped on a succeeded recording (that recording counts skipped at quality). B1 holds the summary to the recordings table, as nemar-process writes it. Should neuroschema's sentence change, or the writer?
  2. Withdrawn datasets. On metadata.json, the pipeline namespaces are gated like processing and signalJourney: public and not concealed. A dataset withdrawn after its derivative was promoted still shows its summary there, while B2's route will refuse a withdrawn dataset. Should dataQuality also drop for a withdrawn dataset?
  3. The derivative key (Phase 7: quality views in the backend #2341). B1 does not touch the derivative key; the serving-index digest question stays open for the owner.
  4. Migration numbers (for information). The open branches for Epic: Publication readiness and expanded binary screening #2182 and A1: Coverage contract and reader registry #2185 each add a migration numbered 0150 that differs from the epic's 0150. Whichever reaches dev second renumbers; B1 takes 0151.

No remote environment was touched: nothing was deployed, and no dev or production D1 was read or written.

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.

RFC 8785 canonical form and an I-JSON reader that refuses duplicate
members, lone surrogates, noncharacters, nesting past 64 and numbers
that are not finite. Replays all nine view-digest vectors and the
fourteen refusals. Tested: targeted unit tests.
nemar-process tests/fixtures/ica-views at e4feec7b, byte for byte,
with SHA256SUMS.json and provenance; never normalized by git.
Fixture for phases B1 and B2 (#2341).
17 files per recording with the record (P7), so maxFiles 25,000
admits about 1,470 recordings. Comment only (#2341).
A zod mirror of the dataset dataQuality document (level and recipes
only, closed root, integers capped at 2^53-1), the writer rules run
again (counts, listing, histograms, observed_range), the checks
against a run's stamp, record digest, table counts and plugins, and
the projection of a recording's entry with nemar.record-checks.v1.
Ajv agreement corpora, the nine record-checks vectors and the P7
fixture. Tested: targeted unit tests.
Migration 0151: one dataset quality summary per stamp, bound to the
stamp's dataset, with named CHECKs and a dataset index. Tested on
bun:sqlite and Miniflare D1, and migrations:d1-check.
A succeeded run's desc-<label>_dataquality.json (at most 64 KiB) is
checked against its stamp, the bytes of its dataset record, its
recordings table and the recipe's plugins, and kept for its stamp
with the stamp's dataset; a refusal is a fixed log word and never
holds the run back. Deleted with the dataset. Tested: targeted
backend tests over Miniflare R2 with the P7 product.
The dataset dataQuality of each recipe's current public derivative
(stored, catalog or published, newest by stored_at), behind the
public and concealed-deposit gate. The page bundle now carries the
processing, signalJourney and dataQuality namespaces by the same read
as metadata.json (#2331). Tested: targeted route tests.
The schema pairs input_kind with profile, so comparing the profile
with the stamp's again was an equivalent mutant. Tested: targeted
contract tests and mutation run.
Tested: not applicable (documentation).
JSON.stringify can print a number longer than it was written
(1000e17 in 21 characters), so an entry within 65,536 bytes as
written could fail the 0151 CHECK and the whole reconcile batch.
Refused as entry_too_large. Tested: contract and reconcile tests
with a 62,641-byte summary (#2375 review).
A record's member named __proto__ would set the prototype of the
merged metrics instead of reaching the schema. Every name must be a
metricName before it is copied. Tested: contract tests, a number and
an object (#2375 review).
A page's summary comes from a catalog or published row that no
later catalog row superseded (ADR 0123) and whose date has not
passed, in the row picked and in the rows that could hide it.
Tested: the real promotion of A then B, and route tests for a
superseded and a dated row (#2375 review).
A dataset with withdrawn_at set shows no summary on metadata.json
or the page bundle, whatever its visibility, as the view route will
refuse it (owner ruling). Tested: route tests.
A failed read of the pipeline's namespaces no longer fails the
bundle's metadata component: name and description stand, the
namespaces are left out as metadata.json leaves them, the bundle
says pipeline_degraded and is not complete, so it is no-store.
Tested: a dropped table, and the isBundleComplete truth table
(#2375 review).
The counts rule (passed = succeeded recordings), superseded and
dated derivatives, withdrawn datasets, entry_too_large and the
bundle's pipeline_degraded. Tested: not applicable.
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review round 1 fixes and owner rulings, head c9dbcc8 (six commits on top of 52989cf).

  • Entry outgrowing the column (75919a5): checkDatasetQualityDocument refuses entry_too_large when the entry, written again, is over 65,536 characters. The reviewer's 62,641-byte summary with edges 1000e17, 1001e17, ... (an entry of 146,191 characters) is in the contract test and the reconcile test. The run reconciles, no summary is kept, and quality_not_written reason=entry_too_large is logged.
  • __proto__ (b29dffb): every metric name must be a metricName before it is copied, and a name that is not is refused with entry_invalid. Tested with __proto__ as a number and as an object, in extensions.nemar.metrics and in a plugin step's qualityMetrics. The dataset document refuses it with document_invalid.
  • Superseded and dated rows (118f101): superseded_at IS NULL and an expires_at that has not passed, on both the row picked and the NOT EXISTS rows. The A/B test promotes A and then B with the real promoteDerivative, and B's summary shows even though A is newer. The route tests cover a superseded row and a dated row, and pin that the read returns exactly one current row per recipe.
  • Withdrawn datasets (e0c9793, owner ruling): a dataset with withdrawn_at set shows no dataQuality on metadata.json or the page bundle, whatever its visibility.
  • Page-bundle failure path (e26dd90, lead ruling): a failed pipeline read keeps the metadata component, including name and description, leaves the three namespaces out, sets pipeline_degraded: true, and makes the bundle complete: false and no-store. metadata.json still answers 200 without the namespaces. The test breaks the read by dropping the table.
  • Counts (owner ruling): passed is the recordings that succeeded. The rule is unchanged and is now documented in the CHANGELOG (c9dbcc8). neuroschema's sentence is to change in 0.6.1.
  • Derivative key: left for B2, as ruled.

Gates:

New mutations, each applied alone with the file restored after it: 18, all killed.

# Mutation Killed by
N01 drop the entry size check contract, quality-documents
N02 drop the outer superseded term quality-documents, metadata-json-quality
N03 drop the inner superseded term quality-documents, metadata-json-quality
N04 drop the outer date term metadata-json-quality
N05 drop the inner date term metadata-json-quality
N06 drop the withdrawn term metadata-json-quality
N07 copy a recipe metric before checking its name contract
N08 copy a plugin metric before checking its name contract
N09 page bundle: fail the metadata component metadata-json-quality
N10 page bundle: call a degraded bundle complete metadata-json-quality, page-bundle unit
N11 page bundle: never pass the flag metadata-json-quality
N12 page bundle: never report the flag metadata-json-quality
R01-R06 rerun on the new SQL: retention term, state term, newest by key alone, tie to the smaller key, the summary's dataset bind, falling back to a derivative that has a summary metadata-json-quality (R01 also quality-documents)

N02 survived its first run: the superseded row became a second current row that the read happened to overwrite. Both tests now assert that CURRENT_QUALITY_DOCUMENTS_SQL returns one row per recipe.

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 25, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2375

Version: 0.10.40-PR2375.6e32df3
Commit: 6e32df3


🤖 Updated on each push.

Publishing never clears superseded_at, so a catalog row superseded
and then published stayed hidden. The superseded term now applies
to catalog rows only, on the row picked and the rows that could
hide it. Tested: the real promote, supersede and publish sequence,
and four mutations of the term (#2375 round 2).
CI's nemar-process checkout is a sparse partial clone of dev, so
asking it for the pinned commit fetched it, and each file after it,
from GitHub: the test timed out. Git now runs with
GIT_NO_LAZY_FETCH and a time bound, all files are read in one
git cat-file --batch, and an absent commit or object skips with a
logged reason. Tested: unset, a dev partial clone, a blob-less clone
of the pin and a full checkout (0.2-0.5 s each).
@neuromechanist
neuromechanist merged commit e9aff59 into feature/issue-2324-epic-pipeline-progress Nov 25, 2026
48 of 53 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2324-b1-quality-summaries branch November 25, 2026 23:34

This branch was previously deployed

1 inactive deployment
npm — 6e32df3f Deployed Nov 25, 2026 by neuromechanist via publish #4896
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