Deploy a cluster as code
How a deployment goes from a folder of declarations to N graphs served behind policy — the Terraform-style declare → plan → apply → serve loop.
Apply
cluster apply executes the executable subset of the plan — stored-query and
policy-bundle changes, graph creates, and schema updates. There is no confirm
flag: cluster plan is the preview,
and apply recomputes the same diff under the state lock before executing, so a
stale preview can never be applied. Apply requires an existing state.json
(state_missing directs you to cluster import first).
For each applied create/update, the resource payload is written content-addressed into the local catalog:
<config-dir>/__cluster/resources/query/<graph>/<name>/<digest>.gq
<config-dir>/__cluster/resources/policy/<name>/<digest>.yaml
Extensions are fixed per kind regardless of the source file's name. Payloads
are written before the state update because state.json is the publish point:
if the final CAS-checked state write fails, no success is reported and the
digest-named blobs already written are inert — re-running apply is the repair.
Deletes remove the resource from state; their old payload blobs stay on disk
(garbage collection is a later stage). Re-running a converged apply is a no-op:
no state write, no revision change (state_written: false).
Applied means serving. A server started with --cluster <dir> boots from
the applied revision (see
Serving from the cluster); it
picks up newly applied state on its next restart. Until that restart, applied
means recorded in the catalog, nothing more.