# Replica Rail: running an independent ZeroExternal replica Any machine with Node.js 24 can keep a verified, read-only copy of ZeroExternal's public knowledge and keep computing runtime packs when the central server is unreachable. No account, key or dependency is needed. ```sh curl -O https://zeroexternal.ai/network/replica-node.mjs node replica-node.mjs sync --from https://zeroexternal.ai --dir ./replica # copy and check node replica-node.mjs verify --dir ./replica # rebuild the state from the store alone node replica-node.mjs serve --dir ./replica --port 8787 # serve reads and compute ``` `sync` reads `GET /v1/replica`, a manifest sealed with the platform receipt key (`/v1/receipts/keys`; pin it with `--keys file` once confirmed through an independent channel, e.g. `docs/receipt-keys/zeroexternal.ai.json`). The replica checks: - the Ed25519 signature of the manifest; - that the digest of every node it copied (`[id, status, updated_at]`, sorted, canonical JSON) equals the signed `heads.nodes.set_sha256`; - the SHA-256 of every object (runtime packs, this replica node). Everything is stored content-addressed in `blobs/sha256/`; each blob is also served as `/ipfs/` (raw codec, sha2-256), so the same bytes can be pinned in IPFS. A replica can sync from another replica: the origin-signed manifest travels with the copy, so trust never depends on the peer. `serve` answers `/v1/replica` (its own signed manifest with the origin's inside), `/v1/evolution/nodes`, `/v1/evolution/nodes/{id}`, `/v1/evolution/anchors`, `/api/runtime/catalog`, `/v1/rails`, `/v1/receipts/keys` and `/v1/public/evaluate?runtime={pack}` (alias `/v1/replica/evaluate`): a runtime pack is run from the store in a bounded worker and the result is signed with the replica's own key (`did:key`). ## Event log `GET /v1/replica/events?after=&limit=` is the event log of the Evidence Hypergraph: one event per public fact — `node.created`, `edge.linked` (evidence), `link.created`, `hyperedge.created`, `node.transition` / `edge.transition` (evidence state), `retraction.recorded`, `node.status` / `edge.status` / `hyperedge.status` (withdrawal) and `anchor.created`. Events are ordered by time and chained: `hash = sha256(canonical({prev, seq, type, at, data}))`, `prev` of seq 1 is 64 zeros. Every page carries a `checkpoint` over the head `{seq, hash}` sealed with the receipt key; `/v1/replica` also lists the head in `heads.events`. On a repeated `sync` the replica first checks that its last event still has the same hash upstream, then fetches only the newer events and refetches only the nodes they touch; if the node set then differs from the signed head it falls back to a full copy. If the held last event differs upstream, the history was rewritten: the replica refetches the log from genesis and reports `rewritten` with the seq and both hashes. `verify` checks the whole chain from genesis against the signed checkpoint and rebuilds the hypergraph state by replay (nodes, evidence links, links, hyperedges, withdrawals, the latest evidence state, anchors), then compares it with the stored records. A replica serves `/v1/replica/events` itself with the origin checkpoint, so another replica can sync the log from it. The log is derived from the record tables, not stored separately: it holds public columns only (no owner ids, author ids or keys) and its append-only property is checked by replicas, not guaranteed by the storage. ## Peer announce and contribution ledger A replica can announce itself and prove what it holds and computes: ``` node replica-node.mjs announce --to https://zeroexternal.ai [--dir ./replica] [--url https://my.replica] [--gpu NAME] ``` 1. `GET /v1/replica/peers/challenge?did=` returns a challenge sealed with the receipt key, valid 10 minutes: a random `seq` of the event log and a runtime pack with random parameters. 2. The replica answers from its own store: the event hash at that `seq` and `result_sha256 = sha256(canonical(result))` of the pack computed locally. It signs the canonical JSON of the announce (`zeroexternal.replica-peer-announce.v1`) with its did:key and posts `{payload, signature}` to `POST /v1/replica/peers`. 3. The origin checks the DID signature and its own seal, compares the hash with its log and recomputes the pack in its bounded workers. Matching answers become entries in the append-only ledger (`GET /v1/replica/contributions?did=`) and a sealed contribution receipt is returned; a mismatch is a 422 that records nothing. One challenge counts once (409 on replay). A 422 says why in `error.reasons[].code`: `replica_stale` (the replica has not synced up to the asked seq), `event_hash_mismatch`, `numeric_mismatch`, `runtime_version_mismatch` (pack bytes other than the `pack_sha256` the task is bound to), `missing_answer`, `invalid_answer`, `origin_verifier_disagrees`. A bad DID signature or seal is a 401 before any proof is read. A numeric mismatch is described by magnitude only (differing leaves, first path, largest relative difference to one digit) when the answer carries its small `result`; the origin never echoes its own hash or values. An exact hash match counts as `compute_reproduction`. A result with the same structure whose every number is within `1e-10` relative of the origin recompute (JavaScriptCore and V8 round `Math.log`/`sin`/`exp` differently in the last bits; iPhones drift up to ~1e-12 on Lyapunov sums) counts apart as `compute_agreement`, with the difference and both hashes in its ledger detail; it is never used for compute routing. `&tasks=N` (1..8) on the challenge asks for N pack tasks at once, for a node with a worker pool; each task carries `pack_sha256` and `input_sha256`, the event question its `snapshot_seq`. `GET /v1/replica/peers` lists announced peers with declared resources, sync state against the origin log (`current`, `behind`, `diverged`) and verified totals. Peers with a URL verified in the last 7 days also appear in the manifest's `peers`. What an announce is not: CPU, RAM, disk and GPU are recorded as declared, never verified. The origin never fetches the announced URL. An announce grants no network resource enrollment (`/api/network/resources` keeps its owner authorization), no job, payment, scope or verified identity, and a compute proof is a reproduction by that replica, never independent review. There is no count quota; only real storage pressure delays a write, and a per-minute flood guard (each announce costs the origin a recompute) answers 429 with Retry-After. ## Built-in runtimes on a replica `/v1/replica` carries `payload.engine` (`zeroexternal.replica-engine.v1`): every file the server runner needs for the built-in catalog runtimes (the solver and verifier sources pinned by `SOURCE_MANIFEST` plus `server/offline/worker.mjs`), each with SHA-256 and IPFS CIDv1, and per runtime its pinned sources, defaults and numeric fields. `sync` fetches the files it does not hold yet from `GET /v1/replica/engine/{rel}` (`--engine no` skips them); a replica serves the same path to replicas that sync from it. ``` node replica-node.mjs compute --runtime yang_baxter --params '{"u":0.5,"v":-1}' curl 'http://127.0.0.1:8787/v1/public/evaluate?runtime=yang_baxter&u=0.5&v=-1' ``` The replica lays the files out by path and runs the solver and the verifier in fresh bounded workers exactly as the server runner does, so `result_sha256` equals the origin's `/v1/public/evaluate` for the same parameters. Dataset shards too large to bundle (hexagon) are fetched on demand from the upstream and checked by the worker against the pinned dataset index. This is origin code sealed by the origin key: run a replica where you are willing to run it. A replica holding the engine asks for `/v1/replica/peers/challenge?engine=1`, which adds a built-in runtime at random valid parameters to the challenge; the origin recomputes it like the pack. ## Routing computation to verified peers `GET /v1/replica/route?runtime={id}` lists peers with a URL verified in the last 7 days: first those whose answers for this runtime the origin recomputed (`basis: verified`, ranked by count), then those that only declare it. Each entry has the peer's `/v1/public/evaluate` URL; `origin_fallback` is the origin's own. The client calls the peer, checks the did:key signature of the replica result and compares `result_sha256` with the origin or a second peer. The origin never calls a peer, assigns a job or pays; a peer result is a reproduction by that replica. ## Neuro Engine: become a node Any device whose owner opts in can be a node. A node mines knowledge, not hashes: it keeps a checked copy of the event log and reproduces runtime computations the origin seals, and the origin records only answers it recomputed. - Browser (iPhone, iPad, Android, Mac, Windows, Linux): open https://zeroexternal.ai/node/, tick the consent box, press Start. The page (`/node/neuro-node.mjs`, no dependencies) creates a non-extractable Ed25519 key, derives its did:key, keeps both and the synced log in IndexedDB, computes packs in a Web Worker on bytes that match the signed manifest and repeats while the page is open. Mobile systems suspend background pages, so it pauses there. - Computer or server, continuous: `node replica-node.mjs work --to https://zeroexternal.ai --dir ./replica`. It syncs and announces in a loop (`--pause` seconds, default 60), backs off up to five minutes on failures, honours Retry-After and resumes with the same did:key. Keep it alive with a service manager, for example: ``` # /etc/systemd/system/zeroexternal-node.service [Service] ExecStart=/usr/bin/node /opt/zeroexternal-node/replica-node.mjs work --to https://zeroexternal.ai --dir /opt/zeroexternal-node/replica Restart=always DynamicUser=yes StateDirectory=zeroexternal-node ``` Both use the same protocol as above (challenge → own answers → signed announce → origin recompute → ledger). Announces may declare `resources.device`: `class` (desktop, mobile, native, server, accelerator, unknown), `platform` and `accelerators` (for example webgpu, webnn, wasm, cuda, metal, npu). Like CPU, RAM and disk these are declared, never verified; no runtime uses GPU, NPU or ASIC compute yet. The ledger (`/v1/replica/contributions?did=`) is the per-device record of verified contribution; nothing is paid or granted for it today. ## Boundaries - Public records only. Private rows, owner ids, sessions and keys are never in the manifest or the copy. - A replica is read-only. Verified state is committed only by the platform verifier; a replica result is a reproduction by that replica, never independent review. - Bitcoin holds only Merkle roots (`/v1/evolution/anchors`); scientific data stays off-chain. - Peers in `/network/replicas.json` are re-verified on every sync and never trusted for being listed. ## Status of the decentralization program | Part | State | | --- | --- | | Content-addressed public knowledge, IPFS CIDs, verified replication | live in this release (`/v1/replica`, replica node) | | State recovery from the replica's own store | live (`verify`) | | Computation without the central server | live: runtime packs and all built-in catalog runtimes (`payload.engine`, `compute`) | | Bitcoin root | anchors live; the replica manifest carries the latest roots | | Signed event log, incremental sync, state rebuilt by replay | live (`/v1/replica/events`) | | Writes through replicas, multi-writer sync | not yet: writes still go to the central SQLite | | Peer announcement (did:key), challenge-verified contribution ledger | live (`/v1/replica/peers`, `announce`) | | Routing of computation to challenge-verified peers | live as client-side routing (`/v1/replica/route`); the origin dispatches no jobs | | Verified (not declared) CPU, RAM, disk, GPU capacity | not yet: resources stay declared | | Disk of the central server | not solved by software alone: needs more storage or an off-site backup target |