feat(distribution-health): new leaf for validity verdicts and usability rollup#472
Merged
Conversation
…ty rollup Adds @lde/distribution-health, a pure leaf that interprets the raw results of @lde/distribution-probe and @lde/sparql-importer into a distribution health verdict. Three modules: - verdict: shallow (probe-result) and deep (import-outcome) mappers to a ValidityVerdict carrying a typed failure reason (parse-error / empty), a best-effort parser message, the validatedFingerprint judged against, and producer depth. - usability: the canonical rollup over reachability x validity x fingerprint freshness x depth. Reachability dominates; a verdict whose fingerprint no longer matches decays to unknown (staleness gate); a deep verdict beats a shallow one. - quads: verdict to DQV/PROV quads. Vocabulary is minted under the LDElements namespace (https://w3id.org/lde/), the same family @lde/pipeline already uses for sourceFingerprint; consumers such as NDE reuse these URIs rather than re-minting their own. Part of netwerk-digitaal-erfgoed/dataset-register#2103. Closes #468.
The verdict-to-quads mapping coined LDE vocabulary (and earlier NDE vocabulary) inside a generic leaf, which would force consumers to handle both def.nde.nl and w3id.org/lde predicates for the same data. It also diverged from the established pattern: analysis leaves such as @lde/iiif-validator return a plain TypeScript verdict and let the consumer (the NDE knowledge-graph pipeline) map it to RDF under its own namespace. Drop quads.ts / validityToQuads / ValidityProvenance and the n3 dependency. The package now exports only the verdict model + mappers and the usability rollup. Turning a verdict into DQV/PROV quads moves to the dataset-register and dataset-knowledge-graph consumers (epic tasks 4 and 5), under def.nde.nl.
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.
Closes #468. Part of the distribution-health feature: netwerk-digitaal-erfgoed/dataset-register#2103.
What
A new pure leaf package
@lde/distribution-healththat derives a distribution’s usability from two separately-produced signals — reachability (HTTP/SPARQL) and validity (does the fetched content parse as RDF?). It interprets the raw results of@lde/distribution-probeand@lde/sparql-importer; it does no I/O and is deliberately acyclic.It returns plain TypeScript only — no RDF, no vocabulary. Converting a verdict to RDF is the consumer’s job (see below), mirroring
@lde/iiif-validator.Two modules, built test-first (red→green→refactor, one behaviour per cycle):
verdict— aValidityVerdicttype (typed failure reasonparse-error/empty, best-effort parser message, thevalidatedFingerprintjudged against, producer depthshallow/deep) plus two mappers:probeResultToVerdict(shallow): interprets the body validation the probe already performs for small RDF dumps; returnsnullwhen the probe carries no validity signal (network/HTTP failure, SPARQL, or a large HEAD-only body).importOutcomeToVerdict(deep): a failed import is invalid (parse-error); a successful one is valid, oremptywhen it produced zero triples.usability— the one canonical rollup(reachability, verdicts) → { usable | unusable | unknown, cause }:validatedFingerprintequals the currently-observed fingerprint (anullfingerprint never matches, mirroringsourceFingerprint), else it decays tounknown. This is what stops a since-fixed dump showing red;shallow.RDF / vocabulary is the consumer’s responsibility
This package emits no quads and coins no predicates, so consumers never have to reconcile two namespaces for the same data. A consumer turns a
ValidityVerdictinto its own DQV/PROV quads under its own namespace — e.g. the NDE knowledge-graph pipeline / register write adqv:QualityMeasurementon the distribution underdef.nde.nl, alongside the existing quality measurements (qualityMeasurementsStage/failureUsage). TheValidityFailureReasonlocal names drop straight into a SKOS failure scheme (<scheme>#${reason}).This lands as epic tasks 4 (dataset-register) and 5 (dataset-knowledge-graph).
Tests
20 tests, 100% coverage. The usability rollup gets an exhaustive case matrix (reachability × validity × fingerprint fresh/stale × depth).
Notes
verdict.ts.0.0.0so the firstnx releaselands it at0.1.0; npm Trusted Publisher bootstrap is a one-time manual step per AGENTS.md.