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

Live view and deployments

An app needs a schema to query and a place to write its data. Agrafe gives it two:

DeploymentLive view
SchemaFrozen: the files as they were at Deploy (or the last Update)Always the project’s current saved files, compiled on the fly
DataThe deployment’s data graphThe project’s live dev dataset, one per project
Id in URLsdeployment_id: /api/data/<deployment_id>/…project_id: /api/projects/<project_id>/live/…
TokenDeployment token, dlf_live_…Dev token, dlf_dev_…
Use it forProductionDeveloping the app while the schema still changes

A schema change never reaches a deployment until someone presses Update or deploys again (a new deployment has a new id and needs a new token). The live view sees it at once, so an app under development can keep the same URL and token through every edit of the schema.

Turning it on

The live view is off by default. Only the project owner can turn it on, with the Live view switch in the header of the Deployments panel, next to Deploy. While it is off, every live endpoint and tool refuses with the live_view_disabled error (MCP) or a 403 carrying the same JSON body (HTTP). Turning it off deletes nothing: the dev dataset and the dev tokens work again when it is turned back on, unless a token was revoked meanwhile.

Dev tokens

A dev token works for one project’s live view only. It is never accepted by a deployment endpoint (/api/data/…), and a deployment token is never accepted by a live endpoint. Each token is shown once when it is issued, and stored hashed, like a deployment token.

Issue and revoke dev tokens in the Deployments tab, under Live view dev tokens (+ Dev token, then Tokens to list and revoke them), or with the MCP tools issue_dev_token, list_dev_tokens and revoke_dev_token. Issuing one needs Live view on and the owner; other members do not see the section.

HTTP endpoints

All take Authorization: Bearer dlf_dev_…. Requests and responses are those of the deployment API:

EndpointLikeDoes
GET/POST /api/projects/<id>/live/sparql…/sparqlSPARQL over the current schema, its facts and mapped data, and the dev dataset. ?now= pins the rules’ clock.
POST /api/projects/<id>/live/triples…/triplesWrites a /triples body to the dev dataset: 201 {written, basis}. No source: one dataset per project.
POST /api/projects/<id>/live/validate/triples…/validate/triplesDry run of the write: the report with the batch, would_write and new_violations. Nothing written.
GET/POST /api/projects/<id>/live/validate…/validateThe SHACL report (JSON) of the current shapes on the project’s facts, mapped data and dev dataset, with basis. ?now= as /validate.

basis names the files compiled, each with its version. Errors: 401 (no token, a revoked one, or a token that is not a dev token), 403 (a dev token of another project, or Live view off), 422 (the project’s files do not compile, or a rejected write). Queries time out after 10 seconds and …/live/validate after 60; a write or its dry run (…/live/validate/triples) runs two validations and gets 20.

Writes are checked against the current shapes

A write gets the per-triple checks of /triples against the current files, then the SHACL shapes of the current files run on the dev dataset with and without the batch. A batch that adds a Violation is refused with 422 {error, new_violations}, and nothing is written. Violations already in the dataset do not block a write: after a schema change, the data it made invalid stays as it is and shows up in …/live/validate and the MCP validate_project. Nothing is migrated or deleted for you; fix the data with new writes, or start again with clear_live_data.

Going to production

The app reads its endpoint from its configuration, for example a .env file:

# development: the live view, survives schema changes
AGRAFE_API=https://agrafe.dolfin.fr/api/projects/<project_id>/live
AGRAFE_TOKEN=dlf_dev_…

# production: a deployment, a frozen release
AGRAFE_API=https://agrafe.dolfin.fr/api/data/<deployment_id>
AGRAFE_TOKEN=dlf_live_…

Only production switches to a deployment id. To release, deploy the project (the Deploy button or the MCP deploy_project); the deployment freezes the current files. The dev dataset is not part of it: deployments never contain dev data, and the dev data is never written to the project’s files. To seed a deployment with it, use the MCP copy_live_data_to(deployment_id): it adds the dev triples to the deployment’s data graph (a deployment’s schema is frozen, its data is writable through the same graph /triples uses), checked against that deployment’s own shapes, and refuses a copy that adds a Violation.

How to write the schema itself is in the Dolfin language book.