How it works · all pages

Start

Guides

Reference

Project

  1. Docs
  2. Guides
  3. How it works

How it works

The contract, content-addressed releases, delta transport, the node and the fleet.

  • 2 min read

1. The contract travels with the code (spec::contract, sdk). A tree carries a diaporos.contract file at its root; a Rust binary can embed one with a macro:

sdk::contract! {
    "name hello-svc",
    "port http 8080",
    "health http /health",
    "cap net.listen http",
    "cap env.read GREETING",
}

Packaging never runs the artifact, and the contract is checked at push time: a health check on an undeclared port, or a port without a net.listen grant, fails the push.

2. Releases are content-addressed (spec::tree, spec::manifest, build). A directory becomes a Merkle tree, like git: a blob per file, a tree object per directory, one root hash per release. Unchanged subtrees (say, node_modules) are shared between releases, and a stat cache skips re-hashing unchanged files. The release id is the manifest’s sha256; signatures, if any, cover that id.

3. Transport is a delta against what the node runs (store). The node says which releases it has; the store answers in one round trip with a pack: the missing objects, plus zstd --patch-from patches for changed files. diaporos serve exposes a store over HTTP, and push --remote uploads only what the server lacks.

4. The node (node):

Step What happens
pull apply the pack as it streams in, from peers first in a fleet, then the store; every object is checked against its hash
verify with a trust file, refuse a release no trusted key signed
materialize hardlink verified objects into releases/<root>/ (no copies). A retired release is rebuilt in place when possible, touching only subtrees whose hashes differ
launch through a runner: a plain process, or the Linux sandbox (Landlock, cgroup v2, an unprivileged uid). The environment is cleared, then gets DIAPOROS_* values, the contract’s env lines, and only the secrets it grants
health-gate the new release runs on a private loopback port beside the old one until its health check passes, or is rejected while the old one keeps serving
swap the node’s proxy owns the public port and moves new connections to the new release, then drains the old one (SIGTERM, then SIGKILL after the grace period)
supervise restarts with exponential backoff, liveness checks, and events, metrics and logs for all of the above

5. The fleet (fleet). A diaporos.fleet file names the store, the nodes and which services run where. diaporos fleet deploy rolls a release out a batch at a time, each node gating its own swap; on any failure it stops and rolls back every node it changed. There is no controller: the CLI drives the nodes, and the nodes share releases with each other.

↑↓ to move ↵ to open