Version 8.8.0

All pages

Validation

Solid Memo checks that the data it reads from a Pod, and every change it writes, has the form the app expects. This page says what's checked and when, and what happens to data that doesn't fit.

Solid Memo checks the data it works on against its shapes and the DCAT-AP profile, in the browser:

No shape constrains text in Markdown, and the app shows any text safely (markdown.md). A published library release is held to npm run library:check's Markdown rules on how its text shows.

Flow

Validating an instance
The validation screen lists the instance's documents and checks each against its published shape with the SHACL engine.
The diagram's source
flowchart LR
    accTitle: Validating an instance
    accDescr: The validation screen lists the instance's documents and checks each against its published shape with the SHACL engine.
    ui["ValidationContainer<br/>#/validate"] --> uc["validateInstance"]
    uc --> docs["instanceDocumentUrls<br/>meta, preferences, palettes, catalog,<br/>every deck's cards + reviews,<br/>every draft's documents"]
    docs --> port["ShapeValidator.validateDocument"]
    port --> pod["pod document<br/>(authenticated fetch)"]
    port --> shapes["ns/shapes/&lt;class&gt;/v&lt;N&gt;.ttl<br/>(published with the site)"]
    port --> engine["rdf-validate-shacl<br/>(lazy chunk)"]

Off the page

The app reads, parses and checks the documents it didn't write in a Web Worker, not in the page:

The page sends each one as a job (offPage.ts): the address or the text, and what it's read as. The worker runs the adapter's own code on it (offPageJobs.ts) and sends back only what the port gives: the typed result and the check's report. offPageAdapters.ts is the ports' side in the page, which the composition root wires in (appUseCases.ts).

Profiles: DCAT-AP and SKOS

Data is held to two published profiles, vendored verbatim under packages/lib/vocab/vendor/README.md, pinned by commit and sha256 in packages/lib/vocab/vendor/manifest.json (which a test checks), and published with the site at /vendor/:

ProfileShapesApplies to
dcat-apDCAT-AP 3.0.1 (SEMIC)catalogs, decks and deck releases, distributions, agents
skosSkoHub skos.shacl.ttl + skos.bestPractice.shacl.ttl, for SKOSthe concept schemes in ns/vocab/

The report

Per document, the report gives its URL and status, and per subject one of these:

The summary line says "All 9 documents conform" or "3 violations in 2 documents". A subject is checked in its stored format, so outdated but valid data passes. The format update is separate.

A document can hold any number of subjects, and a report any number of documents, so the report lists LIST_LIMIT (50) subjects and documents in all at a time (usePaged). It says how many more there are, and shows more on request. A subject can have any number of results, so each lists at most LIST_LIMIT of them.

The invalid data policy

checkInstance runs when an instance is opened (useDataCheck, query ["validation", instance, "opening"]), and validateInstance after a format update. The developer view's full check is cached apart (["validation", instance, "full"]), so neither report stands in for the other; refreshing ["validation", instance] makes both again. What happens when the report doesn't conform is a preference, sm:invalidDataPolicy, a concept of sm:InvalidDataPolicies (vocab.md):

PolicyWhat the app does
Block the instance (sm:blockInstance)The workspace waits for the check, then shows the Data check notice in place of every screen. Preferences and the validation view stay reachable, so the policy can be changed.
Set invalid data aside (sm:blockSubject, the default)A deck whose entry, cards or review states don't conform is set aside (deckSetAside): listed as "Set aside", not offered for study, its pages saying so. The deck list still offers to rename, pause and delete it, as each list states (deckHeld on DeckListScreen); the Studio holds those too (studio.md). When the catalog or a deck group doesn't conform, the deck list's arrangement is set aside (arrangementSetAside): until it's fixed, the list shows every deck but can't be rearranged, nor its groups renamed or deleted, as with a list a newer version arranged. Any other subject that doesn't conform (a deck's agents or distribution, the catalog's publisher, the preferences, the instance record) sets nothing aside; the write check still refuses a write that leaves it not conforming. Everything else works. The notice names the decks set aside, says when the list can't be rearranged, and reports the rest.
Warn only (sm:warnOnly)The notice, and nothing else.

The notice sits above every screen, so what it lists is bounded. It names at most LIST_LIMIT (50) of the decks set aside and says how many more there are. It says that the app leaves the data as it is, to be fixed outside the app. The report's problems are drawn only once the user opens them (LazyDetails): the documents the check couldn't read and the subjects with results, never the conforming or untyped ones, paged as in the full report. The Studio's health screen lists at most 50 of each of its data check's lists too.

Data another app wrote

A subject is Solid Memo's when it has a Solid Memo class (sm:Deck, sm:Card, …), or carries sm:formatVersion, Solid Memo's stamp on every subject it writes. The catalog (catalog.ttl#catalog) is Solid Memo's, and so is a subject that one of Solid Memo's subjects names as its dcterms:creator, dcterms:publisher or dcat:distribution (ownership.ts), even when another app's rewrite drops its stamp. The catalog, a deck's agents and its distribution have no Solid Memo class. Such a link counts only where Solid Memo's shapes write it. In an instance's catalog.ttl, that's a creator or a distribution on a deck, and a publisher on the catalog or a deck group. In a release or a draft, a document that is an sm:Deck, it's a creator, a distribution or a publisher on the deck, and a publisher on its series. In a deck's cards or reviews document, or any other, no such link counts. A subject of a Solid Memo class counts only the links of that class, whatever other class it says it has. The subject it names must be of the class the link names, a foaf:Agent or a dcat:Distribution, and of no other class a shape describes. One with more than 32 values of rdf:type, more than the checks read, never counts. Only the #catalog of a catalog.ttl is the catalog without its class. Any other subject named that way stays another app's.

A review state of another scheduler is never Solid Memo's, whatever its stamp: any value of sm:scheduler but the sm:sm2 and sm:fsrs6 IRIs, a literal too. The rule is for review states only. A subject counts as one when it's typed sm:ReviewState, or has no Solid Memo class at all, and isn't the catalog. A subject with any other Solid Memo class (sm:Card, sm:Deck, …), and the catalog, is read as one whatever sm:scheduler it names, so it stays Solid Memo's and is held to its shape. Another scheduler's state only gets warnings (data-model.md). An FSRS-6 state, naming sm:fsrs6, is Solid Memo's own: it's checked against FSRS review state 1, and its violations count as any other.

Any other subject is another app's, marked foreign. It's checked against the shape its class picks (a foaf:Agent against AgentV1) and DCAT-AP, but every result about it is a warning. Under every policy it sets no deck aside, leaves the arrangement as it is and blocks no instance. The document holding it still conforms, and gets its receipt. Only the developer report shows its results. A subject another app wrote with a Solid Memo class is held to that class's shape.

The Solid client keeps some IRIs for subjects it hasn't saved yet (LOCAL_NODE), so a document can't state one as data: its subject would have no URL to report. A read leaves out any statement that names such an IRI, so the check, the deck writes and every other reader never see it. The one exception is the library that makes a release public, which reads the text of the release's access control itself. Such a statement still counts toward a read's limits. A patch leaves it in the document; a write of the whole document drops it. A document that says nothing else reads as empty, so removing its deck deletes the document, whereas other foreign data keeps it.

A release in the library, or one added from a link, is wholly its publisher's: nothing in it is marked foreign, a link to a blank-node member counts as any other link, and every violation in it counts.

Deleting an instance, a deck or a draft removes from each document only Solid Memo's subjects of that document's kind, conforming or not, and deletes a document only when it's left empty (data-model.md). Another app's subject, and anything whose owner is unclear, is kept with its document, which the result names as kept.

A catalog's or deck group's link to another app's member is that app's data too. The member may be a subject of the same document that isn't Solid Memo's (a schema:Dataset, say, which fails DCAT-AP's class check), or a blank node (which fails the shape's sh:nodeKind sh:IRI). Either way, the result about the link is a warning, in the check and the write check alike: the catalog still conforms, the arrangement stays editable, and writing the catalog whole keeps such a link. A link to a subject of the document that nothing describes, the document's own IRI among them, is still the catalog's own problem.

A value another app added to one of Solid Memo's subjects is that app's data as well. The writer keeps every value of a property the subject's shape doesn't own, so another app's values survive a save. DCAT-AP constrains some of those properties, such as dcterms:accrualPeriodicity or a second dcterms:publisher on a deck's entry, or a second dcterms:type on an agent that several decks name. A DCAT-AP result about such a property is a warning, in the check and the write check alike (foreignValues in shaclShapeValidator.ts). The deck isn't set aside, and its entry, its agents and its distribution can still be saved and upgraded, with the value kept. The properties Solid Memo writes are the subject's classes, its format stamp, the fields of the shapes it's read by, and Solid Memo's own terms (sm:completedChapter, say). A result about one of those, or one with no property, still counts. A subject no shape is read by keeps every result. However many results another app's values give, they count as warnings toward the limit on a check's results (above), so they never add a ResultLimit that counts: the report still shows that one, as a warning. One past the limit of the subject's own violations still counts.

Another app may also add a value to a property Solid Memo writes, such as a dcat:theme on a deck's entry that the deck's shape takes but that isn't a skos:Concept. The reader reads it back and the writer writes it again, so a result about it would refuse every write of the entry. The write check holds each value a write adds to its class, a theme copied from a release say, so a value in the document that fails the class check is another app's. So DCAT-AP's class check on a value of such a property is a warning in the check (isClassOfValue). It's a warning in the write check too, unless the write adds that value (addedValues, from the dataset's recorded changes). The recorded changes leave out every triple that names a blank node, so the class check on a blank-node value is a warning in the write check even when the write adds it. Solid Memo adds values by IRI or as literals, never as a blank node, so a blank-node value there is one it kept as it read it. Nothing may describe the value, the document may describe it as something else, or it may be one of Solid Memo's subjects in a role it never has. The class check on a catalog's link to a member of the document that nothing describes still counts, as above. So does every other DCAT-AP result about a property Solid Memo writes, such as a second value where DCAT-AP allows one.

Another app may give a node that a subject of Solid Memo's links to more rdf:type statements than the engine reads, so the engine checks it as having none. DCAT-AP's class check on a link to such a node, a catalog's link to a member included, is then a warning in both checks (isOverTypedValue), and the node's own result names the problem.

The write check

Every repository write is checked: a deck, its agents and distribution, the catalog, cards, review states, preferences, a palette and its color sets, the instance record. Only the subjects the write touches are checked, so an old problem elsewhere in the document doesn't block it. They're checked against their shapes, and in a document with DCAT subjects, against DCAT-AP, where a result about another app's value is a warning (checkSubjects in shaclShapeValidator.ts, wired into the repositories as checkWrite in appUseCases.ts). A write that wouldn't conform is refused with every problem named, and nothing is saved.

Every caller names where the write goes (WriteContext in writeCheck.ts), and that picks the shapes, as pickShapes picks them for a read:

A published release is never written.

A release a learner adds from a link is checked in the "library" context (validateDataset(url, dataset, "library")): each subject against its library shape, no DCAT-AP. The check is of the read the library made (DeckLibrary.readRelease), which no login goes with, and the read that passes is the one imported. A violation refuses the release; a warning doesn't. Once the check has found as many violations as a check keeps (MAX_RESULTS_PER_CHECK), counted across all the release's subjects, it checks no more of them against their shapes, nor lists them, and a ResultLimit says there are more. It still names a subject in a newer format, which refuses the release as too new instead. The refusal counts the violations found, not the ResultLimit, and names no more of them than that limit.

An instance's documents are checked whole, since the health screen lists every problem: those of an instance registered outside the user's storages too, which the app can't tell apart from the user's own when it checks a document. Each subject keeps as many results as a check keeps. A release that conforms is checked whole as well. So the time a check takes grows with the document, and the limits on what's read bound it: RELEASE_LIMITS for a release, and FOREIGN_LIMITS for a document outside the user's storages. A check never compares each subject with every other one. It runs in a worker, off the page, so the page stays responsive while it runs (Off the page). It still lets other work run every few hundred subjects, and sooner after subjects with a few thousand values between them, and a check of the whole document against DCAT-AP keeps the same pace, node by node. One subject is checked in one go, and those same limits bound its values for one predicate: no more than 4,096 (MAX_VALUES_PER_PREDICATE), in a release and in a document outside the user's storages alike. Only a deck schedule's due days (sm:dueOnDay) may number up to 65,536 (MAX_DUE_DAYS) in a document outside the user's storages, as a schedule names each day its prompts fall due, up to a hundred years ahead. A release keeps the lower bound for them too. So a large document makes the check long, and a check that runs past its deadline is ended.

Data that doesn't fit

Solid Memo doesn't repair or remove what a check finds. It leaves such data as it is and writes no repair over it; only the format update rewrites data, from an older format:

The CI cross-check

CI checks what Solid Memo publishes again with an independent SHACL engine, pySHACL (pinned in scripts/requirements-ci.txt), which runs SPARQL-based constraints too. scripts/shacl_crosscheck.py holds to DCAT-AP:

It holds that release, the draft deck, chapter and step 1 fixtures, and the review-state fixtures (review state 2 and FSRS review state 1 in one reviews document) to Solid Memo's own shapes. It holds the vocabulary's concept schemes to SkoHub's SKOS shapes, best practice included. The script picks the shape of each of a subject's classes by format version, context and the values a shape fixes, as pickShapes does, and targets it with sh:targetNode.

Each version is checked beside the index, only for the subjects it states something about, targeted the same way. DCAT-AP asks a node only about its own statements and their objects' class, so a version can't break an index node it says nothing about, and the index has its own check. The script stops if DCAT-AP starts asking more, or if any document states rdfs:subClassOf, since either would break that. The checks run in parallel, one process per CPU. A disagreement between the engines, or a constraint the browser's engine can't run, fails CI.

The script reads ns/ and decks/ from the repository, each file at the IRI the site publishes it under, without a build or the network, as its own job beside the build. Locally: pip install -r scripts/requirements-ci.txt, then npm run crosscheck. That runs python3 scripts/shacl_crosscheck.py, and says what to install if pySHACL is missing.