Skip to content

Data

How a Cases project and a Data project link, where the map lives, and how agents set both up in one step.

Applies to EngineCloud
View as Markdown
On this page
  1. One link, both ways
  2. Linking a repository
  3. Outcomes saved with the data
  4. Maps uploaded to Data
  5. Starting Cases from Data
  6. Agents set both up in one step

The use-case map lives in Cases, and so does Sypnorm. Sypnia Data is the data layer: sign-in, tables, the API, SQL, row-level security and MCP, with any ORM or none. Cases keeps the map, and Sypnorm, its ORM, derives the code side of the map. The two products link, so each shows what it needs from the other.

A Cases map links to one Data project, and asks that Data project to link back to it. You make the link from Cases: the MCP tool link_data_project, or the API:

Terminal
curl -X PUT https://cases.api.sypnia.com/v1/maps/la-espiga/data-project \
  -H "Authorization: Bearer $SYPNIA_TOKEN" -H "Content-Type: application/json" \
  -d '{ "data_project": "<ref>" }'

Cases checks that you can open the Data project, links the map to it, and asks Sypnia Data’s control plane to link back (PUT /v1/projects/{ref}/cases-map, with the map and its address). The answer’s reverse_link says Data linked back, and Data’s GET /v1/projects/{ref}/use-cases then names the map (cases: { map, url }). A Data project links to one map: linking it to a second map answers 409. Unlinking (DELETE /v1/maps/{map}/data-project) removes both sides.

WhereWhat you see
In Cases, on each use casethe tables it reads and writes, from the Data project’s real schema; whether row-level security is on; the policies, in plain words and in SQL; a warning when a table the case names does not exist, when row-level security is off, or when it is on without any policy
In Data, in the console’s «Use cases» tabthe map last uploaded with map --upload: how many cases, each case’s actor, the tables it reads and writes and the failures it can end in, and the command that uploads it again. Once linked, every upload there also reaches the Cases map, as a draft proposal

The warnings are suggestions for the team: Cases never changes a policy, and Data never changes the map.

In Sypnia Cloud, Cases reads the Data project as you. It checks your session first, then calls Data’s control plane with a key the two products share (Authorization: Service <key>) and the id of the person it verified. So every kind of session works, the key-bound (DPoP) one npx @sypnia/cases login saves included. Data accepts these calls only for what the link needs (who you are, the project, the link itself, and the linked project’s schema and SQL), and still checks your role in the project: a Data viewer cannot replay deliveries, for example (Authentication).

Linking a repository

Terminal
npx @sypnia/cases link la-espiga --data <ref>

writes the Cases map and the Data project into the [cases] table of sypnia.toml, so the CLI knows both, and links them, both ways. Then

Terminal
npx @sypnia/cases map --upload

sends the code side of the map to the Cases map (la-espiga) as a draft proposal (The map from your code). Named with --project <ref>, a Data project’s 20-letter ref sends it to that project instead: its use cases, with their tables, outcomes, starts and places, appear in the console’s «Use cases» tab, and Data forwards the map to the linked Cases map, also as a draft proposal. The code never changes an approved version: a person approves it (Versions, proposals and reviews).

Sypnorm runs on the Data project through its API, with each person’s token, or with a direct connection from your server (Runners). Nothing about the link requires Sypnorm: a Data project used with Prisma or plain SQL links to Cases the same way, and Cases reads its tables and policies.

Outcomes saved with the data

When a case’s outcome has listeners, the area’s service saves it in the outbox in the same Postgres transaction as the rows the case wrote, over its direct connection to the Data project. The browser never writes it: a case some case listens to is called at POST /_cases/<case-id> on its area’s service, with the person’s Sypnia Data session, and runs there under the project’s row-level security. The Data API runner refuses such a case, since the Data API never exposes the schema sypnia_cases (Runners). Cases nobody listens to can still run over the Data API with createRunner(client, { atomic: true }). The outbox and its delivery tables live in the schema sypnia_cases of the same Data project (Delivery).

Maps uploaded to Data

A map uploaded to Sypnia Data’s control plane (PUT /v1/projects/{ref}/use-cases) is kept with the Data project, one per project: each upload replaces the last one. When the project is linked, Data forwards the same document to the linked Cases map, as a draft proposal made on behalf of the person who uploaded it, and its answer says what happened: { "stored": 11, "cases": { "status": "forwarded", "map": "la-espiga", "proposal": "<id>" } }. When Cases does not take it at that moment, status is failed and the Data side is still saved; upload again to send it. A map uploaded before the link stays in Data only. The document carries each case’s id, area, title, actor, the tables it touches, its outcomes with their event names, its failures, its start, place and path in the navigation, the events it listens to, plus the navigation tree, the event graph and the check’s findings.

Starting Cases from Data

You use the same Sypnia account and session in both products. Data’s «Use cases» tab explains in plain words what use cases are, and links to Sypnia Cases. With the same account, a Cases map is created in your Sypnia organization (create_project in the MCP tools, or POST /v1/maps in the API) and linked to the Data project as above.

Agents set both up in one step

npx @sypnia/data init asks which ORM the app will use (plain SQL, Prisma, Drizzle or Sypnorm) and whether it will use Cases. Choosing Sypnorm or Cases installs @sypnia/cases in the app, with the app’s package manager (--no-install skips it), and the sypnia-cases skill, and the coding agent, signed in with your Sypnia account, uses the Cases MCP tools in one go:

  1. create_project: the Cases map, in the same organization as the Data project.
  2. link_data_project: the link, both ways.
  3. upload_map: the map Sypnorm derives from the code, as a draft proposal.
  4. read_map: to work from the approved map afterwards.
  1. One link, both ways
  2. Linking a repository
  3. Outcomes saved with the data
  4. Maps uploaded to Data
  5. Starting Cases from Data
  6. Agents set both up in one step

    Search pages, sections and terms