Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Validating deployment data (SHACL)

A deployment can check its data against the conditions of its Dolfin package: concept conditions (equivalent to … [ … ]), field value constraints, keys, derived fields and one of:. Agrafe compiles them to SHACL shapes when you deploy, then validates on request. For what each construct means, see the grammar reference.

The data checked is everything a SPARQL query of the deployment sees: the deployed facts, the triples written through the API, and what the package’s rules and its reasoning profile infer from them (without domain and range typing). Validation never changes the data.

Inferences are recomputed for every validation and every query, never stored. A condition that depends on now() (someone turning 18) is therefore always up to date: there is nothing to redeploy or refresh when time passes.

The endpoint

MethodEndpoint
GET or POST/api/data/<id>/validate

It needs the header Authorization: Bearer <token> with a token of this deployment, as for triples (see Deployments). Without a token the answer is 401, with another deployment’s token 403, and an unknown deployment 404.

Optional parameters, in the query string:

ParameterEffect
format=turtleAnswer with the report as RDF (sh:ValidationReport, written as N-Triples, which any Turtle parser reads) instead of JSON. The header Accept: text/turtle does the same.
now=<dateTime>The time now() stands for, for example now=2026-06-15T12:00:00Z: in the date conditions and in the package’s rules alike, so one run sees one instant. Default: the time of the request. Use it to get the same answer every time.
curl -H "Authorization: Bearer dlf_live_…" \
  "https://agrafe.dolfin.fr/api/data/<id>/validate"

The answer

{
  "conforms": false,
  "results": [{
    "focus_node": "<https://…/people/main#bob>",
    "path": null,
    "value": "<https://…/people/main#bob>",
    "component": "SPARQLConstraintComponent",
    "severity": "Violation",
    "message": "CanVote: condition not met",
    "messages": [{"lang": null, "text": "CanVote: condition not met"}],
    "concept": "CanVote",
    "source_shape": "<https://…/people/main#CanVoteShape>"
  }],
  "skipped": [],
  "warnings": []
}
FieldMeaning
conformstrue when there is no result at all.
resultsOne entry per failed check. focus_node is the checked node, path the property path of the check in SPARQL path syntax (null for a check on the node itself), value the offending value, component the SHACL constraint that failed (e.g. MinCountConstraintComponent), severity Violation, Warning or Info, message a readable explanation (the shape’s own or a generated English default), messages only the shape’s own sh:message literals with their language (lang null when untagged; messages of sh:sparql constraints are generated by the Dolfin compiler and are English only), source_shape the shape that failed, and concept the concept of that shape (null for a field’s check). Nodes are written as <iri>, _:blank or a literal.
skippedThe constructs of the package that could not be turned into shapes, as {concept, reason, file, span, concept_span} (file and the spans, with 1-based start_line, start_col, end_line, end_col, are missing for deployments made before they were recorded). They were not checked, so conforms: true says nothing about them.
warningsShapes the validator ignored, as text. Also not checked.

Deployments made before validation

Shapes are compiled at deploy time. A deployment created before validation existed has none, and the endpoint answers 409 with “redeploy it to enable validation” rather than reporting that the data conforms. Update the deployment (or deploy again) to fix it.

If the package’s conditions cannot be compiled to shapes at all (for example a cycle of negated conditions), the deployment still works but the endpoint answers 422 with the reason.

From the interface

Open the project and choose the Validation tab of the output pane. Pick what to validate: Live: current package (selected by default, and available before any deploy) or one of the deployments. Optionally set now = to the time now() stands for (read as UTC; empty means the time of the request), and press Validate.

Live: current package checks the facts of your saved files against shapes compiled from them right now, like the SPARQL tab’s live entry: no deployment, and nothing is written. The data includes the instances and facts of your locked imports, as a deployment does. With it selected, validation runs again by itself each time the tab is shown and each time you save a file while the tab is open. A deployment is only validated when you press Validate.

A green Conforms badge means no check failed. Otherwise the badge counts the violations, and the warnings and infos if there are any. The table below lists one row per failed check, sorted by focus node: Severity, Focus node, Path (“(node itself)” for a check on the node), Value, Message and Component. IRIs are shortened with the package’s prefixes. Click a focus node to open it, ringed, in the Instances tab (when it is in the project’s live data), a condition’s message to open that condition in the editor, and a Not checked concept to open the skipped construct (or, for older deployments, the concept) in the editor.

A Not checked list appears when some constructs could not be turned into shapes, and an Ignored shapes list for the validator’s warnings, even when the badge is green: those parts were not validated, so “Conforms” says nothing about them.

You learn this before running anything: right after a deploy, and on each row of the Deployments tab, a line reads N constructs not checked by validation (with a link to this tab), Validation unavailable: shapes could not be generated (reason) when the conditions could not be compiled (the deployment still works), or Validation not available, redeploy for a deployment made before validation existed. Nothing is shown when every construct is checked. These lines come from what was recorded at deploy time; no validation runs to display them.

For a deployment made before validation existed, the tab says to redeploy it and offers a button to the Deployments tab (see Deployments). When the conditions cannot be compiled to shapes, it shows the reason instead of a badge.

Checking the project’s own facts in the editor

The facts you write in the project can be checked before any deploy. Tick Validation in the header of the Problems panel: Agrafe checks the facts of the files as they are in the editor (unsaved edits included) against the package’s shapes (with your locked imports’ instances and facts as data), and lists each failed check as a problem with code S017, underlined on the fact it is about (or on the concept’s name when it is about no fact of yours, such as a fact generated by a mapping). A Violation is an error, a Warning a warning, an Info an info. While Validation is ticked, the same check also runs by itself a moment after each save. Unticked (the default), no fact check runs and no S017 / S041 problem is listed or counted. The checkbox gates S017 and S041 (a fact that fails an equivalent to concept it is asserted to be, see Problems): the rules check (S040, see Problems) runs after each save either way. The choice is remembered per project in this browser.

Only the project’s own facts are checked here, not a deployment’s data (use the Validation tab for that). Editing a file removes its S017 problems until the next check, since they may no longer point at the right line.

From an AI assistant

The MCP tool validate_deployment runs the same validation and returns the same JSON.