Sign in

InOrbit schemas

Versioned JSON Schemas for InOrbit's wire formats.

Each schema is a JSON Schema (draft 2020-12) document for a frame or a request or response body that InOrbit's agents, sensors and API exchange. Its $id is the URL it is served from, so a $ref resolves over HTTP. There is one immutable file per major version, v0 is a draft, and index.json lists everything for a program to read. Open, no sign-in.

Published schemas: 7. Versions: 7. · What a schema is · index.json

01The schemas

Published schemas and their versions.

Search by name, title, field path or $id. Built from the repository's schemas folder; index.json lists the same entries.

Status

7 schemas

agent · 1

approvals · 1

runner · 1

sensors · 4

02What it is

A JSON Schema is a declarative validator for a JSON document.

JSON has no types or required fields of its own, so a misspelt property, a missing one or a string where a number belongs is accepted until a program fails on it. A JSON Schema is a second JSON document that constrains the first: the properties it may have, the type and limits of each and which are required. A validator evaluates the document against the schema and returns whether it conforms, or the failing keyword and its path.

Below: a minimal schema, a document that validates and one that does not. The published schemas use the same keywords at greater size.

The schema
{
  "type": "object",
  "required": ["id", "kind"],
  "properties": {
    "id": { "type": "string" },
    "kind": { "enum": ["gate", "check", "score"] }
  },
  "additionalProperties": false
}
A document that passes
{ "id": "nudge-weight", "kind": "score" }
A document that fails
{ "id": "nudge-weight", "kind": "banana" }

Refused: kind is not in the enum (gate, check, score).

03Why they are published

The schema is the machine-readable contract of a wire format.

The schema is the exact definition of the body a service accepts or returns, or of the frame an agent sends. Because it is data and not prose, a program can use it: validate a payload before sending it or after receiving it, drive an editor's completion, generate types or a client model with a tool that reads JSON Schema (check its support for draft 2020-12), diff two versions field by field, and fail CI when a stored file stops conforming.

Schemas refer to each other by $id. The sensors/ingest body takes its timestamp, state word, labels and evidence digest from sensors/reading with a $ref to that file's URL, so a reading that is sent and one that is read share one definition and cannot drift.

A schema holds no customer data: it describes properties and limits, never values. The files are open: no sign-in, no token.

04Versions and status

One immutable file per major version, addressed by its $id.

Every schema lives at one address per major version: schemas.inorbit.hr/<area>/<name>/v<major>.json. The file names that same address in its $id, so a schema that refers to another resolves it from the web and a copied file cannot pass for another one; the build checks this for every file. Each schema also has a page per version, and .../latest/ always opens the newest one.

A stable major (v1 and up) never changes once it is published, so the server tells every cache to keep it for a year. A fix that would change what a valid document is becomes the next major, v2, at its own address, and v1 stays exactly as it was. Each page compares a version with the one before it, field by field.

v0 is the draft line. It may still be corrected, so it is kept for five minutes and then fetched again. A schema at v0 is a draft design; its description says what, if anything, uses it today.

Every schema carries one of three statuses. stable has a published major that will not change. draft may still be corrected. deprecated stays at its address so existing documents keep validating, and its page says which schema replaces it.

We call a change breaking when a document that was valid could stop being valid, or a program written against the old shape could misread a new one: removing or renaming a field, changing a field's type, making an optional field required, or tightening a limit. A breaking change is a new major. A schema that refuses unknown fields also needs a new major for a new optional field, because a validator that has the old file would refuse a document that uses it.

05Use one

Validate in an editor, in CI or in code.

In an editor that understands JSON Schema, map your files to the schema in the editor's settings, and it will mark a wrong field as you type and offer the allowed values. Do not put a $schema line in a document whose schema refuses fields it does not list: the line itself would be rejected. Each schema's page says whether it does.

In CI, run a validator on the files you keep in a repository. Any validator that supports JSON Schema draft 2020-12 works; the two below are only examples; we neither ship nor support them. Each schema's page also checks a pasted document in your browser.

To read one, or to vendor a copy, fetch it. It is plain JSON, with CORS open for browsers. A program that wants the whole list reads index.json: every schema with its page, versions, status and field names.

The coordinator compiles its published schemas into the binary and validates against them. The services behind the agent and sensor schemas enforce the same rules in their own code, and the repository's tests run every example and refused document through the published files, and the sensor service's real answers through the sensor schemas, so the two cannot drift. The iohr command line does not validate files against a schema yet.

VS Code, JetBrains: settings
"json.schemas": [
  { "fileMatch": ["my-file.json"], "url": "https://schemas.inorbit.hr/agent/signal/v0.json" }
]
check-jsonschema
check-jsonschema --schemafile https://schemas.inorbit.hr/agent/signal/v0.json my-file.json
ajv-cli
ajv validate --spec=draft2020 -s <(curl -s https://schemas.inorbit.hr/agent/signal/v0.json) -d my-file.json
curl
curl -s https://schemas.inorbit.hr/agent/signal/v0.json
Node, ajv: discover a version from index.json and validate
import Ajv2020 from "ajv/dist/2020.js";

const { schemas } = await (await fetch("https://schemas.inorbit.hr/index.json")).json();
const reading = schemas.find((s) => s.path === "sensors/reading");
const schema = await (await fetch(reading.versions[0].id)).json(); // newest first
const validate = new Ajv2020({ strict: false }).compile(schema);

validate(payload); // true, or false with validate.errors
06What a schema cannot tell you

A schema checks structure. The service checks semantics.

A schema can say an evidence digest is sha256: and 64 lowercase hex characters. It cannot say the digest matches the evidence the producer keeps, that the sender is the sensor's producer, or that the sensor is not paused or revoked. The service that accepts the document checks those, and it can still answer no to one that validates.

The reverse is tested for ingest: the refused documents are posted to the running service, and whatever the schema refuses the service must not accept. The example documents on each page have made-up values (their digests are a repeated pattern) and are the ones those tests use.