# Writing a silo

> A minimal silo.json that validates, how to check it before you hand it over, how to submit it and what the owner sees.

Source: https://silosplatform.com/docs/writing-a-silo/

This is the short how-to. For what a silo is and how the owner installs one, read [Silos](https://silosplatform.com/docs/silos/) first.

## A minimal manifest

This manifest describes customer cases that a support agent keeps, one JSON file per case. A case that needs the owner's decision comes to the inbox. It validates as written.

```json
{
  "apiVersion": "silo-standard/v0",
  "metadata": {
    "id": "cases",
    "version": "0.1.0",
    "name": "Cases",
    "description": "Customer cases a Support agent keeps; the ones waiting on you come to your inbox"
  },
  "spec": {
    "producer": {
      "role": "support",
      "instructions": {
        "summary": "Keep one JSON file per customer case under silos/cases/, named by its id.",
        "protocol": [
          "Re-read a case before you write it; never write over a state the owner set.",
          "Set state to needs_owner only when you cannot go on without the owner's decision."
        ]
      }
    },
    "sources": [
      {
        "id": "cases", "type": "files", "root": "agent-state",
        "glob": "silos/cases/*.json", "parser": "json",
        "expects": { "producer": "agent", "cadence": "24h" }
      }
    ],
    "kinds": {
      "case": {
        "envelope": {
          "id": { "from": "filename", "mustMatchField": ["id"] },
          "identity": { "template": "{{subject}} · {{customer}}", "empty": "{{id}} · {{customer}}" },
          "state": { "field": "state" },
          "at": { "field": "openedAt" },
          "anchors": [{ "hub": "agent", "from": "location" }],
          "updatedBy": { "field": "updatedBy", "fallback": "agent" }
        },
        "states": [
          { "value": "open", "label": { "one": "open", "many": "open" } },
          { "value": "needs_owner", "label": { "one": "needs you", "many": "need you" } },
          { "value": "closed", "label": { "one": "closed", "many": "closed" }, "terminal": true }
        ],
        "ownerWritable": ["state"],
        "fields": {
          "subject": { "type": "string", "optional": true },
          "customer": { "type": "email", "required": true, "normalize": "trim-lowercase" },
          "openedAt": { "type": "timestamp", "required": true },
          "replyBy": { "type": "timestamp", "optional": true }
        },
        "roles": { "due": { "field": "replyBy" } },
        "examples": [
          {
            "id": "case-0001", "subject": "Refund for a double charge",
            "customer": "someone@example.com", "openedAt": "2026-01-10T09:00:00Z",
            "replyBy": "2026-01-12T09:00:00Z", "state": "needs_owner", "updatedBy": "agent"
          }
        ]
      }
    },
    "views": [
      { "id": "cases", "archetype": "list", "kind": "case",
        "columns": ["identity", "state", "replyBy"], "fold": { "when": "state = closed" } }
    ],
    "surfaces": {
      "rail": { "label": "Cases", "view": "cases" },
      "pulse": { "kind": "case", "aggregate": "count",
                 "label": { "one": "open case", "many": "open cases" } },
      "needs-you": [
        { "when": "state = needs_owner", "urgency": "due",
          "clears": "state != needs_owner", "actions": ["open", "set-field", "message-agent"] }
      ]
    },
    "actions": [
      { "verb": "set-field", "kind": "case", "fields": { "state": { "writableBy": "owner" } } },
      { "verb": "message-agent", "kind": "case", "to": "producer",
        "templates": ["Please draft a reply for {{identity}}"] },
      { "verb": "agent-record-write", "kind": "case", "by": "producer" },
      { "verb": "open" }
    ]
  }
}
```

Here is what each part does:

- **`metadata`** names the silo. `id` is lowercase letters, digits and dashes. `version` is semver, and you bump it for every update.
- **`producer`** is the role that writes the records. The owner binds that role to one or more agents when approving.
- **`sources`** says where the records live. `agent-state` expands under every agent's own state folder, and the glob must name a folder of its own. `expects.cadence` makes every slot say the data is stale once the last write is older than 24 hours.
- **`kinds.case`** maps each record onto the envelope every record has (id, identity sentence, state, date, anchor, who updated it), declares its states with plain-word labels, and lists its fields. At least one state must be `terminal`. The pulse counts only live, non-terminal states, and terminal states are what fold away.
- **`examples`** are mandatory: one to three per kind, and every one must read with your own manifest. They must be synthetic, never a real person's data.
- **`views`**, **`surfaces`** and **`actions`** say where the records appear and what the owner and the producer may do with them. An inbox entry must say what clears it (`clears`), and someone must be able to make that true. Here the owner can, because `set-field` lets them write `state`.

The full rules for every field, the expression language that `when` and `clears` use, and every check a manifest must pass are the **Silo Standard v0**, in the Silos repository under `docs/standard/`. Its authoring guide is `docs/standard/authoring.md`, and `docs/standard/reference/` holds the manifests Silos ships, each one a worked example.

## Check it before you hand it over

From a checkout of the Silos repository, run:

```sh
npm run silo-check -- my.silo.json
```

It runs the same validator Silos runs when a manifest is submitted. It exits 0 when the manifest validates and 1 when it does not, and it takes several files at once. Each finding names its position in the manifest and says in plain words what is wrong, then which check it failed. For example, a manifest with no terminal state gets:

```
spec.kinds.case.states: at least one state must be terminal (what counts as done)
```

On success it prints what the review dialog will tell the owner, worked from your examples, since there are no records where you are. For the manifest above that includes:

```
Home’s pulse: Cases: 1 open case.
Needs you · due: Refund for a double charge · someone@example.com — needs you · due Jan 12, 09:00 UTC
```

It also prints what the silo reads and how often, who may write what, and the brief a bound producer is handed at start.

Some checks only the Silos you install on can make: an id approved there before, another active silo reading the same folder, whether a sync producer holds a token, and the difference from an installed version.

## Submit it

A silo is always one `silo.json`. There is no package or folder format: the producer instructions travel inside it.

- **The owner** pastes it into **Install a silo…** in Settings › Silos (also at `/silos`), or picks the file, and presses **Submit for review…**.
- **An agent** submits it through the API, `POST /api/silos/submissions`, with its own token, from one of its turns. It cannot submit over a silo that is installed or was approved before, unless it is one of that silo's bound producers.

An invalid manifest creates nothing, and the errors come back in place. A valid one lands **pending**, the owner's own included. The owner's paste opens the review dialog straight away; an agent's submission waits in Needs you with **Review**.

## What the owner sees

The review dialog is derived by Silos from your manifest, not from your prose: the exact paths it will read, each slot rendered as a sentence from real records or from your `examples` (it says which), who writes what, and the proposed sync automation if there is one. Your `description`, instruction `summary`, `protocol` and sync `contract` appear apart, as a quote. Write them for a person deciding, but do not rely on them: only what the manifest declares is acted on.

Approving binds your producer role to one or more agents. The owner can switch each slot on or off afterwards on the silo's page.

An update goes through the same door. Bump `metadata.version`. Under **What changes**, the dialog lists every widening of what the silo may do on its own line, or says "nothing it may do widens". The examples of the installed version must still read with the new manifest.
