Skip to content

W5: dataset quality summary and verification utilities - #595

Merged
neuromechanist merged 14 commits into
feature/issue-586-epic-pipeline-progressfrom
feature/issue-588-w5-summary
Nov 26, 2026
Merged

neuromechanist merged 14 commits into
feature/issue-586-epic-pipeline-progressfrom
feature/issue-588-w5-summary

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Phase W5 of the live quality views (#588, epic #586, nemarOrg/nemar-cli#2324): the dataset quality summary and the verification utilities.

Verification utilities, on W4's readers

  • verify.ts:
    • subtleSha256 now lives here; model.ts re-exports it.
    • verifyBytes(bytes, {size, sha256}) answers null, file_missing, file_size_mismatch or file_digest_mismatch. It compares the size first, so bytes of the wrong length are never hashed. prepare-ahead.ts uses it.
    • canonicalJson, viewDigest and viewDigestOfText implement nemar.view-digest.v1 (RFC 8785).
    • viewDigestOfText reads through read.ts's I-JSON parser.
    • digestable moved here from guards.ts, which imports it. It refuses a sparse array and any object whose prototype is neither Object.prototype nor null (a Date, a Map, a class instance).
  • tsv.ts: the C3 role reader on read.ts's grammar. declaredColumns, typedColumn and readDeclaredTsv are the column checks model.ts already used; they were moved here, not rewritten, and model.ts imports them.

The dataset summary

  • dataset-summary.ts:
    • readQualitySummary(metadata, id) decides what the page shows. It returns none, refused (a word and one sentence) or shown.
    • summaryTree builds one element tree, which DatasetQualitySummary.astro prints with toHtml.
  • Order of checks:
    1. The page's own gate: anything but anonymous: false shows nothing.
    2. A dataQuality member must be present.
    3. The document head must name this dataset.
    4. dataQuality must meet the dataset-level schema.
    5. Each recipe must keep the writer's rules.
    6. Each histogram must build; a number too large to draw exactly (a bin wider than binary64, a density past it, or a total past 2^53 - 1 with the missing count) refuses with histogram_too_large.
  • A summary that fails a check draws nothing and says why in one sentence.
  • What a shown summary prints, per recipe:
    • an h3 per recipe, with its version, the dataset version, and the copy read;
    • the counts: discovered, succeeded (counts.passed, the succeeded recordings, by the owner's ruling on nemar-cli B1), failed and skipped;
    • the recordings not processed, and how many more were left out.
  • Per metric:
    • its values ("1 value" in the singular), median and observed_range, and the missing count; a metric with no value prints "none" once;
    • its histogram through W4's histogramSvg and toHtml, with a role="img" text alternative that names every bar, both ends and the missing count by stored text;
    • an eager data table (the server draws it; no script runs).
  • Every number printed is a stored value's text. The backend reads metadata.json as binary64 and writes it back with JSON.stringify, so numberText prints exactly the served text.
    • Bins of unequal width are drawn by density, but no density is printed: histogramSvg gains {storedTextOnly}, which leaves out the density tick. The panel's drawing is unchanged.
  • dataset-guards.ts:
    • datasetQualityValid: dataQuality at the dataset level, closed at every level.
    • ownRange: a metric's observed range as an own member only, used by both the writer's rules and the summary (a metric named constructor never finds Object.prototype's).
    • dataPaperValid: the data paper schema.
    • documentHeadValid: the root's envelope and the identity members it selects.
    • writerRuleBroken: the backend's writer rules, in its order and with its words.
  • DatasetTabs.astro:
    • The "coming soon" placeholder and its CSS are gone.
    • The Data quality tab and its panel are drawn only when the summary shows something.
    • The dataset page passes quality={readQualitySummary(metadata, id)}.

Fixtures, captured rather than hand-written
scripts/capture-quality-summary-fixtures.mjs runs nemar-cli's real dataRoutes over a real migrated database, with rows written as backend/test/metadata-json-quality.test.ts writes them. It was run at nemar-cli 39e2ee3f.

  • metadata-*.json is the body as served, one world per gate: shown, published, a summary spread over six recordings, canary only, concealed, withdrawn, tombstoned, never published, and private (404).
  • dataset-quality-verdicts.json holds 60 dataset-level documents. Each carries Ajv's verdict over nemar-cli's vendored bundle and the first writer rule broken according to the backend's writerRuleBroken. The script also requires Ajv and the backend's zod schema to agree on every document.

A W4 fix

  • guards.ts's obj looked a member's guard up with rule.props?.[key].
  • So a member named constructor, toString, valueOf or hasOwnProperty found Object.prototype's function, which returned something truthy. The member passed a closed object, the view envelope included.
  • The lookup now takes own members only. Tests in quality-views-dataset-guards.test.ts.

Testing

  • bun run typecheck: 0 errors. bun run lint: clean. Biome on every touched test file, the Vitest configs and scripts/capture-quality-summary-fixtures.mjs (its seven intended deletes carry a biome-ignore with the reason): clean.
  • Targeted Vitest (all pass):
    • quality-summary (168), quality-summary-pages (4), dataset-tabs.astro (5), quality-views-dataset-guards (19)
    • quality-views-verify (34), quality-views-tsv (36)
    • quality-views-guards, quality-views-models, quality-views-checks, quality-views-render
  • bun run build: passes. bun run check:quality-views-size: every budget holds; only the worker with its lazy chunk moved (11.8 to 11.9 KB, from digestable's hole and prototype checks):
Measured Size Budget
Worker on its own 10.6 KB 12 KB
Worker with its lazy guards-computed chunk 11.9 KB 12 KB
Main thread, largest lazy renderer (histogram) 21.4 KB 30 KB
First screen, Components tab 24.3 KB 30 KB
First screen, Spectrum tab 24.0 KB 30 KB

The summary is drawn on the server and adds no client script.

  • Full bun run test: 260 files passed and 7 skipped; 8243 tests passed and 55 skipped. The drift tests skip locally and are expected to be red in CI until nemar-cli dev carries the epic.

Rendering DatasetTabs

  • test/dataset-tabs.astro.test.ts renders DatasetTabs through experimental_AstroContainer for a none, a refused and a shown summary. It checks that the Data quality tab and panel exist only for refused and shown, that every aria-controls and aria-labelledby pair up, that the panel starts hidden with its tab unselected, that the refusal sentence appears with no figure or table, and that a shown summary has an h3 per recipe and a figure per metric.
  • Astro 6's Vite config does not load under Vitest 2 (Vite 7 against Vite 5), so vitest.astro.config.ts is a second Vitest project (vitest.workspace.ts) that compiles .astro files with Astro's own compiler (a transitive dependency, nothing added), strips the TypeScript with esbuild, loads style and script virtual modules empty, and stubs the compiler's $$metadata. bun run test runs both projects; the unit config excludes *.astro.test.ts.
  • The regex tests of DatasetTabs are gone; the source checks kept are "no placeholder" and the dataset page's quality={readQualitySummary(metadata, id)}.

What the tests pin

  • The embed page renders no quality data. A walk of static imports from src/pages/dataset/[id]/embed.astro never reaches DatasetTabs, DatasetQualitySummary or dataset-summary.ts. The dataset page is the control: the same walk from it reaches all three.
  • None renders for the canary-only, concealed, withdrawn, tombstoned or never-published fixtures. On the page side, a document whose anonymous is true, missing, null, "false" or 0 shows nothing.
  • A summary whose schema fails, whose record digest is not a SHA-256, whose writer rules fail or whose histogram holds numbers too large renders nothing but one plain sentence, with none of its numbers. The review's inputs are cases: edges [-1.7e308, 1.7e308, 1.75e308, 1.79e308], and missing = 9007199254740991; both meet the schema and the writer's rules.
  • Counts match the stored text, which the tests read from the served body.
  • Every number in each figure's text and text alternative appears in that metric's stored JSON.
  • Accessibility:
    • every aria-labelledby resolves to a non-empty element, and the ids are unique;
    • each figure has a figcaption, and each table a caption and th scope="col";
    • each SVG is aria-hidden and not focusable, and each details has a summary.
  • Stored text is escaped.
  • Verdict corpus: the W5 share replays, 6 data-paper and 5 root cases. The 8 dataQuality cases are recording entries, so they stay with W6.
  • All 9 view-digest.v1 cases (canonical text and digest) and its 14 refusals replay.
  • verifyBytes checks every declared file of the model vectors, finds each file refusal's word, and checks the shipped copies against pin.json.
  • tsv.ts replays every nemar.table model case, drawn or refused, covering all nine reader words.

Mutation table

Each mutation was applied alone; the nine suites (the eight unit suites and dataset-tabs.astro) were run, and the file was restored. The logged run, on the pushed head with a clean tree: 72 mutations, 72 killed.

  • V04 first survived in the first round: a declaration nested 65 deep and built in code still got a digest; a test was added (bae0a80).
  • In the review round, a separate hasOwn branch in the summary was unreachable after the writer's rules (an equivalent mutant). The lookup is now one helper, ownRange, which both use; its mutation (W09) is killed by a test of writerRuleBroken's contract with an inherited range.
  • A01 (tab always shown) is now killed by the container render test, not a regex.
  • The script is kept outside the repository.
# Mutation Result
S01 page gate: only anonymous: true hides killed
S02 page gate dropped killed
S03 document head not checked killed
S04 dataset id not compared killed
S05 schema guard skipped killed
S06 writer rules skipped killed
S07 a histogram too large skipped silently killed
S07b cap_exceeded given the wrong reason killed
S08 density tick printed killed
S09 text alternative drops the ends killed
S10 text alternative drops the missing count killed
S11 counts in the wrong columns killed
S12 left-out count not said killed
S13 values rounded for print killed
S14 an empty summary shown killed
S15 text alternative without the bars killed
S16 text alternative drops a bar killed
S17 "1 values" killed
S18 "none" three times for no value killed
S19 recipe heading an h4 killed
G01-G07 root, entry, counts, range, histogram, distribution, listed recording opened killed
G08 recipe id takes uppercase killed
G09 recipe id multiline (a final newline passes) killed
G10 metric name 129 killed
G11 unit 64 (the UTF-16 count of 32 code points) killed
G12 not_processed cap 201 killed
G13 input/profile pairing dropped killed
G14 integer cap 2^53 killed
G15 negative counts killed
G16 unversioned dataset refused killed
G17 description 501 killed
G18 one edge killed
G19 status word open killed
W01 counts_unbalanced dropped killed
W02 listing_mismatch dropped killed
W03 missing counted in n killed
W04 flat edges accepted killed
W05 extra observed range accepted killed
W06 observed max not compared killed
W07 median above max accepted killed
W08 counts length not compared killed
W09 inherited range looked up killed
D01 DOI suffix by \S killed
D02 DOI suffix takes a space killed
D03 data paper open killed
D04 schema_version multiline killed
D05 dataset id multiline killed
D06 data papers unchecked killed
P01 prototype names pass a closed object (the W4 fix reverted) killed
V01 JCS: names by locale killed
V02 JCS: integers with .0 killed
V03 JCS: escape / killed
V04 digest depth 65 killed
V05 size not compared killed
V06 digest not compared killed
V07 digest of text without I-JSON killed
V08 lone surrogates digested killed
V09 sparse array digested killed
V10 Date and Map digested killed
T01 column_missing dropped killed
T02 column_repeated dropped killed
T03 cells not checked by type killed
A01 tab always shown killed (render test)
A02 page passes no summary killed
A03 embed imports the tabs killed
H01 storedTextOnly ignored killed

Deviations

  • The "digest" gate.
    • The page has no recorded digest of the summary to recompute: metadata.json carries none.
    • record_sha256 names the dataset record, which the page does not fetch. The backend checked it against the record's bytes when it kept the summary (nemar-cli B1).
    • So the page checks that record_sha256 is a SHA-256 (a schema rule); one that is not refuses the summary with its sentence.
    • Comparing it with the signalJourney link's digest would be wrong: that link follows the latest ended run, the summary the current promoted one.
  • The verdict corpus.
    • The 8 dataQuality cases are all recording entries, which the panel reads, so they remain W6's (NOT_DRAWN now says W6).
    • No corpus case is at the dataset level, so that guard is held instead to the 60 Ajv verdicts captured from nemar-cli.
  • documentHeadValid does not check the whole document. It checks the root's envelope and the identity members, which is what the summary relies on. The page reads the rest of metadata.json member by member, as it did before.
  • No empty state. A dataset without a promoted derivative (most datasets today) has no Data quality tab, rather than a tab saying nothing.
  • DatasetTabs changed beyond the placeholder lines:
    • a quality prop and two imports;
    • the tab and panel inside {showQuality && (...)}, with tabindex="0" on the panel;
    • the header comment;
    • the removed --soon CSS.
  • [id].astro: the DatasetTabs call is now multi-line, and the SSR comment no longer says "coming soon".
  • No browser check. The summary is tested as the element tree the server prints, and DatasetTabs through Astro's container (a test project added here); nothing was viewed in a browser.
  • Follow-up (lead): nemar-cli's writerRuleBroken has the same plain observed-range lookup; the lead files it.

For W6 (overlap)

  • DatasetTabs: showQuality gates only the Data quality tab and its panel. A Quality panel tab goes beside them as its own tab, and the tablist script handles a missing tab.
  • [id].astro: the DatasetTabs element now spans five lines.
  • guards.ts: the closed-object fix changes verdicts for members named after Object.prototype properties. No corpus case uses one.
  • model.ts: subtleSha256 comes from verify.ts (re-exported), ColumnDecl from tsv.ts (re-exported), and histogramOf(content) is now exported.
  • For quality-api:
    • verifyBytes(bytes, file) returns the model's words;
    • viewDigest(declaration) and viewDigestOfText(text) return null when the value has no canonical form;
    • canonicalJson gives the RFC 8785 text.
  • test/quality-views-guards.test.ts: NOT_DRAWN.dataQuality is now "W6", and the two lines after it point to the W5 test.
  • Small additions: AGENTS.md has four new map lines (one for the Vitest projects), and the header comment of quality-views.css changed.
  • Component tests: a *.astro.test.ts file renders a component through experimental_AstroContainer (vitest.astro.config.ts); W6 can test QualityPanel the same way.

Refs #588, nemarOrg/nemar-cli#2324.

Agentic AI tools were used.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

@neuromechanist
neuromechanist merged commit b8734e8 into feature/issue-586-epic-pipeline-progress Nov 26, 2026
3 of 4 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-588-w5-summary branch November 26, 2026 04:34
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