Compute actions
A compute action is an app method that runs outside the log, on a job node, over sealed input files, and writes sealed output files. A call cannot do this work: it stops at 2 s, its whole log entry stays under 1 MiB, and its result is copied to every replica. A compute run may take up to 15 minutes and 4 GiB, reads up to 64 input files (2 GiB in all), writes up to 2 GiB across its output files (each file at most 2 GiB), and leaves only a small result in the log.
Raw data leaves the attested machines only where an app sends it out over outbound HTTP from a call or an action.
Files are sealed at rest and in transit.
A job node is an attested TDX node that holds no cluster key, so it sees an input’s plaintext only while the run reads it (the ciphertext is kept for up to JOB_RESULT_TTL, 1 hour).
To write one, see the Compute actions guide.
A call or a compute run
Section titled “A call or a compute run”| Call | Compute run | |
|---|---|---|
| Runs on | The app’s leader | A job node |
| Time | 2 s | Up to 15 minutes, declared per method |
| Entry in the log | The call and its diff, under 1 MiB | An attempt per try and one final entry (the start rides in the starting call’s entry) |
| State access | Reads and writes the app’s state | None: inputs in, outputs and a small result out |
| Network | Outbound HTTP to approved hosts, recorded in the entry | None |
| Repeatable | Linearized once | Deterministic: a restart gives the same output |
Use a call for anything that must read or write state, and a compute run for work that only turns files into files. A compute run reaches state in one place, its result method, which the node runs as an ordinary logged call when the run ends.
Two components
Section titled “Two components”An app with compute methods is built as two components from one crate, and a job node only ever receives the second.
App component (app.wasm) |
Compute component (compute.wasm) |
|
|---|---|---|
| World | calimero:app/app |
calimero:app/compute |
| Runs on | The replicas | Job nodes |
| Holds | Every method, the state, the result methods | The compute methods only |
| Imports | State, events, blobs, xcall, outbound HTTP, files, runs, WASI |
types, files, job and the WASI interfaces Rust std needs; no state, xcall, events, blobs, runs or wasi:http |
| Export | handle |
run |
The two worlds differ in who may start work.
runs is imported by the app world only: start and cancel are logged writes, so a compute run cannot start another.
A client never calls a compute method or a result method itself: /intents and /views refuse both with 422 APP_ERROR, code WrongKind.
job is imported by the compute world only: run-id, inputs and progress describe the run in progress.
Neither world imports the other’s interface, so the install-time import check is the sandbox, not a policy the host remembers to apply.
Building.
An author changes nothing: #[app::compute] and #[app::compute_result] mark the methods, and meroctl app build <crate> --out app.wasm --compute-out compute.wasm builds the crate twice.
The second build sets --cfg calimero_compute in its own target directory, binds world compute, keeps only the compute methods and exports run.
A crate with no compute methods builds one component and has no compute output.
The bundle.
The signed manifest carries the compute component as compute (per service as services[].compute), next to wasm.
The manifest signature and the artifact digest cover it like every artifact, and an older node ignores the field.
meroctl app pack --wasm app.wasm --compute compute.wasm packs one.
Install checks. A node prepares the compute component on the compute engine only, never the replica engine, and refuses the release unless all of these hold:
- it imports nothing outside the compute world (
400 BAD_BUNDLE); - its ABI is the compute world’s (
400 BAD_BUNDLE); - its ABI lists exactly the compute methods of the app component’s ABI, with the same caps (
400 COMPUTE_ABI_MISMATCH).
The release records the compute hash per service, and the app’s record carries the running release’s compute hash next to its bundle. A compute component is never an app’s bundle, and replicas never prepare it.
A run pins its component.
When a start is logged, the leader fills the app’s compute hash into the entry, and every replica records it as the run’s computeBundle.
An upgrade does not move a run already started.
A start on an app whose running release ships no compute component is refused with the soft error no compute component and records nothing.
A raw single .wasm upload has no compute component, so it cannot start runs: ship a signed .mpk that carries both.
Billing stays on the app component.
Usage is billed to the run’s bundle, the app component that started it, and the result method runs on the replicas’ app component.
The usage series carry app, org and developer.
Files for component apps
Section titled “Files for component apps”A component app (the wasmtime runtime) has files: sealed blobs.
A file shares its ids and the BlobRef type with the blobs of Blobs.
A call, view, timer or init may create a file and ask for its size and hash, but files.open is refused there.
A sealed file’s contents can be read only inside a compute run of the app release the organization approved, and leave only as a compute output published through a logged call.
- Sealing. Each file has a random 256-bit data key.
Its content is cut into 64 KiB chunks, each sealed with AES-256-GCM under that key, with the chunk index in the nonce and a last-chunk flag in the authenticated data, so chunks cannot be reordered, dropped or truncated.
The blob id is
hex(SHA-256(ciphertext)), the same id space every blob uses. - The seal. The app’s blob record for the file holds its plaintext size, its plaintext SHA-256 and the data key wrapped under the app’s file key, in rows the guest cannot reach.
The file key is
HMAC-SHA256(K_c, "calimero.files.v1|" || app), derived from the cluster key and separate from the app’s TEE key. Opening a file checks the plaintext size and hash against the record, because GCM alone does not commit to the key. Plaintext exists only in the memory of an attested node. - Where they live. On the app’s replicas, not on every node: a file is stored locally and pushed to the other replicas over the node-to-node blob route, and a write succeeds once a majority of the app group’s Raft voters hold it. A replica move hands the files over with the rest of the app.
- Uploads.
POST /apps/{app}/fileswith the raw bytes (through the sealed channel, like any request) uploads a file of up to 16 MiB; a larger file goes through an upload session (POST /apps/{app}/files/uploads, one part per request; see Blobs). The receiving node passes the body to the app’s leader, which seals it, charges the quota, stores it on a majority of the group’s voters and commits the blob record. A file is at most 47 MiB (MAX_FILE_BYTES). The answer carries the file’sid(the blob id, which an app andruns.starttake as aBlobRef), its size and plaintextsha256. Only the app’s owner and members of its organization (rolememberor above) may upload or list files, even where ananyonegrant admits others, because the organization pays for the bytes. - Who sees what.
GET /apps/{app}/blobslists the files after the blobs, andGET /apps/{app}/blobs/{id}/infoanswers a file’s size and plaintext SHA-256, to the owner and the organization’s members only. Everyone else gets the list without files and404on a file’s info, as for an id the app does not hold. Neither answer carries a key or content. A pipeline run’s input and non-final output files are held and are in neither (Events, receipts and exports). - No download, no grant. A file is read by the app’s own code through the
filesinterface (open,info, andcreateto write), never through the API:GET /apps/{app}/blobs/{id}answers409 NOT_SUPPORTED, andblobs.grantrefuses a file. - No delete. There is no
files.delete: dropping the last reference is the delete. - Retention. Files follow the retention of blobs.
A file is held while a stored
BlobRefnames it, and is forgottenBLOB_IDLE_MS(1 hour) after it was made or after its last reference went. Every replica forgets the record in the same entry, and the bytes are then collected from every node that holds them. An uploaded file is held the same way, so the app has that hour to store itsBlobRef. - Quota. Stored plaintext bytes are counted per organization in the system group.
A write is charged before its record commits and released when retention collects the file or the app is deleted; one past
maxFileBytesPerOrgis refused with429 QUOTA_EXCEEDED. - Who may use them. Calls, timers and
initcreate files. Views and actions may read them, and an action may send what it read out over outbound HTTP, but an action cannot write one. A migration touches no file.
An old component that does not import calimero:app/files keeps linking, because the WIT package moves additively to calimero:app@0.5.1.
The job node
Section titled “The job node”A job node is started with merod run --job-node --cluster-identity <key> and registered in the system state’s node directory with role: job (POST /ops/nodes).
It is deliberately not a replica.
- It is never a Raft member, not even a learner: a member keeps its log sealed under the cluster key, and a job node must never hold that key.
- It has no KMS key, no store and no cluster key, and serves only
/health,/attestationand/job/*. Run files live in a scratch directory under its data directory, as ciphertext only. - It is excluded from admission and promotion, app placement and replica moves, blob pushes and majorities, key delivery and the placement counts.
- A node’s role is fixed at registration; to change it, remove the node first.
A job node can be registered only once every replica node, voter and learner, runs at least the release of the node being registered (else
409 CLUSTER_NOT_UPGRADED), so no older node ever applies a job record.
Attestation, purpose=jobs.
A job node answers GET /attestation?purpose=jobs and nothing else: one TDX quote binds the nonce, the cluster identity, the node id, its X25519 transport key, an Ed25519 job key and its release.
A replica answers 404 to the same request.
The leader verifies the quote with the same code clients use (verify_job_key, sharing verify_report and the peer policy), then checks that the attested release is approved for the app’s organization, as Node::may_send does for replicas.
Because a job node attests only for jobs, no channel that carries the cluster secret, the cluster key, Raft or blob traffic can open to it.
Who attests a job node
Section titled “Who attests a job node”The leader does, whenever it needs a job node, with a fresh nonce. It checks the quote against the peer policy and the release the job node names, that the document names this cluster and this node, and that the quote binds the cluster identity this cluster signs with. A release past an operator’s deadline is refused, and so is a release the app’s organization has not approved for that app. A verified answer is reused for up to a minute, until the directory registers or removes the node, or until a channel to it fails; a refused or unreachable answer is never kept. A job node never receives the cluster’s KMS key or the cluster key: it attests only its job key, so no channel that carries them opens to it.
Operators read the verdict from GET /ops/job-nodes/{id}/attestation.
It runs the leader’s check, without the per-app approval, and answers one of three states with HTTP 200.
admitted carries the attested release.
refused is final: the node answered and its attestation does not pass, with the reason.
It covers a 400 or 404 from the node (the only statuses a job node answers on its own; a replica registered as a job node answers 404), a 2xx answer that is oversized or does not decode, a quote that fails the verification checks, and a collateral source answering 400 or 404 to the PCK certificate or TCB info request, the two requests that carry values the node chose.
unreachable is transient, so ask again later: no answer (connect, timeout, TLS or redirect failure, a connection cut mid-body), any other status from the node (a proxy or load balancer in front of a booting node can answer a 3xx, 401, 403, 421, 5xx, 408, 425 or 429), or an outage of a service verification needs: any other collateral failure, including a 401 or 403, or a 404 on a CRL or QE identity, and the release host.
An id that is not a registered job node answers 404.
The route answers 503 when this node’s directory could not be brought up to date.
Only compute components. A job node prepares what it is given on the compute world, so an app component, which imports state and runs, is refused with BAD_BUNDLE even when the cluster signed it.
The leader never offers one: it sends the run’s pinned compute component, and the job node logs each component it prepares by hash.
Admission. Every assignment and bundle upload carries a signature by the cluster identity key, an Ed25519 key every cluster node derives from the cluster key.
The job node is configured with the public half (--cluster-identity, read with GET /ops/cluster) and refuses anything else.
Only an attested TD of this cluster holds the cluster key, so a valid signature proves the sender is a node of the cluster, and a job node runs only its own cluster’s work.
One run’s life
Section titled “One run’s life”- Start. A call, timer or init (a logged write) calls
runs.start(method, args, inputs). The start is part of the call’s outcome and is dropped if the call fails, or if an input is no longer a sealed file of the app when it applies. It is refused (no compute component) when the app’s running release ships no compute component, and the entry pins that release’s compute component to the run. The other refusals come back as soft errors the calling method handles; nothing is recorded. In order:not a compute method,arguments too large(over 64 KiB),too many inputs(over 64),input named twice,input is not a file of this app,inputs too large(over 2 GiB declared), thentoo many runs started(16 by one call) andtoo many active runs(64 for the app). The last two are checked after the same-job answer below, so a repeated start of a run already active is answered even at the caps.runs.cancelof a run that is not active answersno such active run; run records that cannot be read make both trapHostDenied. Each input is pinned as one more reference while the run is active, so retention keeps it even when no state refers to it; the pin goes when the record is dropped. An active run with the same method, arguments and inputs is answered instead of a second one. The run is queued. - Queue and caps. The leader asks the system group for a place (
AcquireRun). The system group grants it while the organization is undermaxConcurrentRunsPerOrg(4), its reserved fuel plus this run’s fuel is withincomputeFuelPerOrg(10 times the fuel cap), and fewer than job nodes times 2 runs are granted in all. Otherwise the run waits, the organization whose oldest waiting run is oldest first. - Attempt. The leader picks the least-loaded job node (fewest runs, then lowest id; a node that lost an attempt of this run is chosen only if no other is free) and attests it.
It delivers the run’s compute component (never the app component), the assignment (wrapped input keys, the wrapped noise seed, a capability token and the budget, signed with the cluster identity) and the inputs as ciphertext.
Only after the node accepts them does the leader commit
computeAttempt(run, attempt, node, job key, assignment digest) in the app’s log, so a busy or unreachable node costs no attempt. - Per-run key re-wrap. For each input the leader unwraps the data key with the app’s file key and re-wraps it to the job node’s attested transport key: an ephemeral X25519 key, HKDF-SHA256 over the key pair, the app, run, attempt and index, then AES-256-GCM.
The job node opens it only through its sealed transport, never as a raw Diffie-Hellman oracle.
The noise seed (
HMAC-SHA256(file key, "calimero.compute.seed.v1|" || run)) is wrapped the same way. Wrapped keys travel only in the assignment, never in the log, and each wrap’s ephemeral key and nonce derive from the file key and the app, run, attempt, kind, index and job key, so any leader can rebuild the exact assignment an attempt’s digest names. - The run. The job node calls the compute component’s
runexport deterministically, with no network, and writes its outputs as new sealed files. - Heartbeats by polling. The leader polls
GET /job/runs/{app}/{run}/{attempt}everyJOB_POLL(2 s) with a token any replica can derive. The answer is the heartbeat and carries progress (percent and step), which the leader keeps in memory and serves fromGET /apps/{app}/runs/{run}. - Signed report. When the run ends, the job node signs a report with its job key over the app, run, attempt, status, result hash, every output (id, size, hash, segment hashes), usage and the digest of the assignment it ran.
The leader checks the signature, then charges the outputs to the file quota (a refusal ends the run as failed with reason
quota). It then fetches each output’s ciphertext and key, checks each segment’s hash and the file id against the report, opens the file against the reported size and hash, wraps the key under the app’s file key and stores the file on a majority of the replicas. - Final entry. The leader runs the result method inside the final entry, as
kind = callwith the system as caller, and proposescomputeFinalcarrying the report, the signature, the outputs, the usage and the result method’s outcome in one atomic entry. The entry registers each output as a sealed file of the app before the result method’s writes apply, so aBlobRefthe result method stores is counted at once. Every replica verifies the signature against the job key and assignment digest of that attempt, and applies only the first final entry of a run’s current attempt. Then the leader releases the system slot and counts the usage. Inputs stay held forBLOB_IDLE_MSafter the final unless state refers to them.
The result method takes the whole outcome as its one parameter, whatever the parameter is named: a ComputeOutcome in the SDK, in JSON:
{ "run": "r1", "method": "digest", "attempt": 1, "status": "done", "reason": null, "result": "<base64>", "outputs": [{ "id": "<64 hex: a BlobRef>", "size": "12", "sha256": "<hex>" }], "usage": { "cpuSeconds": 1.5, "gibSeconds": 0.25, "fuel": "99" }}statusisdone,failedorcancelled. A cancel isstatus: cancelledwithreason: null.reasonis set only for failed runs and is one offuel,memory,trap,app-error,integrity,lost,timeout,refused,quota,not-grantedortoo-large. A wall clock that ran out is not a reason of its own: it is a lost attempt, retried on another job node, andlostonce every attempt is spent.not-grantedmeans the queue gave the run no place withinQUEUED_RUN_TIMEOUTof healthy time, andtoo-largethat the final did not fit the log even without its result method.quotameans the outputs would have passed the payer’s file quota: the run ends failed with no outputs.resultis the compute method’s return bytes as standard base64, present only for done.outputs[].idis the output’s blob id, aBlobRef.sizeandfuelare decimal strings (64-bit integers), andsha256is the plaintext’s hex digest. Only a done run, or a cancel that carries the job node’s signed report of a finished run, has outputs.
Keeping an output.
The final registers every output as a sealed file with no reference.
The result method keeps one by storing its BlobRef in the app’s state.
An output it does not store is forgotten BLOB_IDLE_MS after the final, and the organization’s file quota is released when the bytes are collected, as for any file.
If the result method itself fails, the run keeps its outcome and its outputs are registered, but with nothing referring to them they go the same way.
Neither /intents nor /views reaches a result method, for any caller, and the SDK macro refuses compute_result on a public method, so no client can forge an outcome.
A compromised leader can still forge a run’s final, because the final is the leader’s entry.
It gains nothing a leader does not hold already: it has the cluster key and the plaintext of every file it serves.
The signed report protects against a job node and against a replica applying a job outcome nobody signed, not against the leader.
GET /apps/{app}/runs/{run} answers, for anyone who can reach the app, the run’s method, state, cancelRequested, startTsMs, attempts with their nodes, input and output ids, usage and reason, its caps (fuel, memoryMib, wallSecs), and progress while it runs.
To those who may list the app’s files it also shows, while the run is queued, queue: { state, pool, capacity, reason? }: state is unplaced (the queue has no slot for it yet), waiting or granted (a place is held and no job node has taken it), and a waiting run’s reason is NO_CAPACITY (no job node in its pool), POOL_FULL, PAYER_AT_RUN_QUOTA or PAYER_AT_FUEL_QUOTA.
The leader also logs one warning per run that has waited NO_CAPACITY for a minute of healthy time.
Plaintext sizes and SHA-256 hashes of inputs and outputs are shown only to callers who may list the app’s files; others get ids.
It never returns arguments or keys.
GET /apps/{app}/runs?limit=<n>&before=<cursor> answers { runs, next } with the same objects, newest start first (ties by run id, descending), limit 1 to 100 (default 20) and next an opaque cursor for before, null on the last page.
Active runs carry progress, and an app that is not a component app answers 404 NOT_FOUND.
Only the active runs and the last FINISHED_RUNS_KEPT (256) finished ones are kept, so the list reaches no further back and a page reads at most MAX_ACTIVE_RUNS plus 256 records.
A bad limit or before is a 400 (BAD_LIMIT, BAD_CURSOR).
The sizes and hashes follow the same rule as the single run.
A run keeps no log.
A module’s stdout, stderr and log lines may hold user data, which neither Calimero nor the operator may see, so the job node seals none and the leader asks for none; a report that names one does not hold up, and the attempt runs again elsewhere.
Up to 1.0.0-rc.35 a run kept its final attempt’s log as a sealed file of the app; a final that earlier release logged still applies as it did, its log held with the last 256 run records and then collected, but no route answers it: the files export does not know it.
GET /apps/{app}/runs/{run}/logs is deprecated and answers { logs: [] }, to the app’s owner and its organization’s members only.
To read a compute method’s log lines, run it on your own machine with meroctl local compute run, which prints them on stderr as log: <line>, a failed run’s included. A job node never collects them: its host drops every line as the module writes it.
Restarts, cancel and caps
Section titled “Restarts, cancel and caps”- A lost attempt. No answer from the job node for
JOB_LOST_AFTER(20 s) marks the attempt lost, as does aloststate from the job node or a report that does not hold up. OnUNKNOWN_RUN(404), or while the job node awaits its inputs, the leader first re-sends the attempt, unless it already sent it in this leadership; only then is the attempt lost. The leader commits attempt + 1 on another job node when one is free (the node that lost it is reused only if no other is free), up toMAX_ATTEMPTS(3), then ends the run as failed with reasonlost. A new leader starts every running attempt’s clock at its takeover and keeps polling the same attempt. The leader counts only healthy time toward this clock, the deadline and the queue timeout: time in which its own read of the system group succeeded. An outage of the system group therefore never loses or times out an attempt. A valid report the job node gave is held, so the leader’s own failing writes (charge, push to the replicas, propose) never count as silence. A job node that reports but will not hand its outputs over gets no such credit: the attempt is lost. Outage time is forgiven for at mostQUEUED_RUN_TIMEOUT, and the lost and cancel clocks also end in wall time at ten times their limit. Whatever the leader sees or holds, a running run with no final by its attempt’s timestamp plus its wall cap plusDEADLINE_GRACEplusQUEUED_RUN_TIMEOUTends as failed with reasontimeout. That ceiling is measured on the app clock from the attempt’s timestamp, so it survives leader changes. The unplaced and cancel clocks start when the current leader first sees the run in that state, and restart with each leader term. A granted run no job node takes endsrefusedafterQUEUED_RUN_TIMEOUTof healthy time, and at mostQUEUED_RUN_TIMEOUTplus as much again of app time. A held report also stands when the job node restarts or forgets the attempt, while the final waits on the leader’s own writes. Before an attempt is declared lost or timed out, the leader looks for a committed final, a held report and one fresh poll, and ends the run from any of them. A lost attempt is not charged. - Same output on any node. The noise seed is the same for every attempt of a run, the clock is the start entry’s timestamp, and the engine is configured for determinism (see Decisions), so a restart produces byte-identical output and a run never yields two results. Node-local failures (instance pool, allocation, disk) end an attempt as lost, never as the app’s failure.
- Deadline. A run with no report by its attempt’s timestamp plus its wall cap plus
DEADLINE_GRACE(60 s), less the leader’s outages (at mostQUEUED_RUN_TIMEOUT), ends as failed with reasontimeout. - Cancel.
runs.cancel(run)in a logged write marks the run; the leader stops the job and commits a cancelled final entry, which may carry the job node’s signed cancelled report and its usage. A cancel whose job node does not answer has no usage, and a run that already finished keeps its report and outputs (done stays done). A job node that keeps answering that the run still runs cannot hold the run open:CANCEL_DEADLINE(20 s of healthy time, at most ten times that in wall time) after the current leader first sees the cancel, the run ends from the signed report the leader already holds for the attempt, else cancelled with no usage, and the job node is sent a last delete. Later reports for the attempt change nothing, as the first final wins. The result method seescancelled. Refused and quota finals are leader entries too. - Caps. A method declares
fuel,memoryMib,wallSecsand its result method in the ABI. Hitting the fuel or memory cap ends the run failed withfuelormemory; nothing is recorded as done and no output is registered. The wall cap is a lost attempt (see CA25), because how fast a machine runs is not the app’s doing.
Pipeline runs
Section titled “Pipeline runs”A release that registers pipelines (pipelines in its manifest, checked at install) can run them in the group of any app made from it, compute-only apps included.
A pipeline that names sources, sinks, publish, notify or an input’s accept, maxFileSize, format or schema is refused with NOT_IN_V1, as are when, runIf, uses, loops and variables: the engine runs none of them.
POST /apps/{app}/pipelines/{name}/runs { inputs, params } starts one and answers 200 { run }.
The node judges the request against the pinned pipeline before logging anything: NO_SUCH_PIPELINE, BAD_INPUTS (an input unbound, past its maxItems, or a file the app does not hold), BAD_PARAMS (typed, within min, max and enum, defaults filled), TOO_MANY_PIPELINE_RUNS (8 running per app, 429), PIPELINES_NEED_ONE_SERVICE and 409 CLUSTER_NOT_UPGRADED until every node runs this release.
The run pins the release’s pipeline by hash and its compute component, so an upgrade of the app changes neither a run that started before it.
A step’s work is ordinary compute runs (RunRecord.pipeline names the step), so placement, retries, caps, quotas and billing are the run driver’s, unchanged.
Their ids are <run>.<step>.<index>, and they have no result method: the step keeps the job’s result (at most 64 KiB) and its outputs, which are held as file retention says.
The leader decides each pending step and logs it as a pipelineStep entry (start with its first runs, skipped, upstream failed, cancelled, or failed with a code); apply accepts the first decision for a step, so a leader that changes mid-run never runs a step twice.
A step starts when every step it needs succeeded; one whose need failed is upstreamFailed; the run is succeeded when every step succeeded or was skipped, succeededWithFailures when besides that a fan-out tolerated failed items, cancelled when it was cancelled, else failed.
A step that cannot be built fails with TOO_MANY_ITEMS, TOO_MANY_INPUTS (past 10,000 files), ARGS_TOO_LARGE, RUN_TOO_LARGE (one run’s arguments and inputs past what one decision may carry), BAD_REF, NO_RESULT, BAD_RESULT or RESULTS_TOO_LARGE; a pipeline whose definition cannot be found fails its steps with PIPELINE_UNAVAILABLE.
Only those who may handle the app’s files (its owner and its organization’s members) start, cancel or retry a run, even where an anyone grant admits others (403); anyone who reaches the app reads it without results or file hashes.
A linked app of the same organization starts, reads and cancels runs of its own (Runs an app starts).
Step rows. The pipeline run’s record (a hidden row, rows::CPIPE) keeps only counters and flags per step, so completing a step rewrites a record whose size does not grow with its fan-out.
Each step run’s outputs, result and cache key live in a hidden row of their own (rows::CITEM, keyed <pipeline run>/<step>/<index>), written once when that run ends or is answered from the cache; every finished run has one, an empty one for a run that failed.
The leader keeps each fan-out’s runs in memory and reads no row twice.
A step with fewer readable rows than it finished is flagged, and the leader fails a step that would be built from it with ITEMS_UNREADABLE rather than build from part of the data; apply never reads the rows except to drop them with the record.
A record 1.0.0-rc.19 wrote, with the per-run data inline, is still read.
Modules. A step may run a compute method of another package (module: <package>[@<version>]), pinned to the release resolved at install, so a newer release of the module changes nothing until the pipeline’s own package is released again; uninstalling a pinned release is 409 MODULE_IN_USE.
The step runs under the app’s owner, payer and file keys; only the compute component and its caps are the module’s.
Fan-out
Section titled “Fan-out”forEach: inputs.x makes one item per file of that input, forEach: <step>.outputs one per output file of that step in item order, and forEach: <step>.results one per result of that fan-out step (each a JSON value).
No items skips the step, and more than maxItems fails it with TOO_MANY_ITEMS before any run starts.
batch: b groups the items in order into runs of at most b, so a failed run fails all of its items.
The runs start in waves: the first decision records how many runs the step will have, and a more decision starts the next indices while the step runs, so at most maxParallel of its runs are active and never more than the app has room for.
A wave is also held to what the compute queue would grant now: the free places of the pool its runs go to, and the runs and fuel the payer’s quotas leave.
So a fan-out wider than its pool waits in its step, not in the queue, where a run would end not-granted after the queue timeout.
A step with no run active still starts one, so a step never waits on itself and a pool with no job node still ends that run not-granted.
Run ids are <run>.<step>.<index>, so a decision repeated after a change of leader changes nothing.
The input order of a fan-out run is the step’s inputs references in the order written, with the run’s item files where item stands, or first when item is not listed.
A step with no inputs gets just its item files.
In args, item is the item: a result’s JSON value, or a file’s id (a list of them when batch is above 1).
<step>.outputs and <step>.results are always in item order, whatever order the runs ended in.
collect: <fan-out step>.outputs is one run whose inputs are all of that step’s outputs in item order, then the step’s other inputs.
A step keeps its results only while they total at most 1 MiB (MAX_STEP_RESULTS_BYTES); past that it still succeeds, but a step that refers to <step>.results fails with RESULTS_TOO_LARGE.
allowFailures (a count, or a percentage of the items rounded down) lets the step succeed with failedItems recorded and only the successful runs’ outputs and results kept; one item over it, the step stops creating runs, cancels its active runs and fails.
Without it any failed item does that.
failFast: true on the pipeline cancels every other step at the first failed one and ends the run failed.
A step’s pool places its runs: they take places on that pool’s job nodes only, and a run whose pool has no job node waits.
A step without pool is placed by its memory, in the smallest pool that fits.
A named pool is used only once every node runs this release; until then its runs are placed by memory.
GET /apps/{app}/pipeline-runs/{run} answers the record, GET /apps/{app}/pipeline-runs the recent ones, and POST /apps/{app}/pipeline-runs/{run}/cancel stops a run.
Output sizes, hashes and step results are shown only to those who may list the app’s files.
Step cache
Section titled “Step cache”A step run whose compute component, method, arguments and input contents equal those of an earlier successful run in the same app reuses that run’s outputs and result: it makes no run record, no job and no usage.
Inputs are compared by the SHA-256 of their plaintext, so the same content under another file id is a hit; those hashes never leave the app.
The leader makes the key when it builds a run and looks it up before deciding the step; apply checks that the entry and every output are still held and takes the hit as a finished run.
cache: false on a step turns it off for that step.
Modules are assumed deterministic for equal inputs, so a module whose output varies must be run with cache: false.
Caps are not part of the key: an output that succeeded under some caps is the same under any, which is what lets a retry with raised limits reuse the items that already succeeded.
The view shows cached per step (every run of it was a hit) and cachedItems, the items of a fan-out answered from the cache.
An entry holds its outputs for at most 7 days after it was written or last used and the app keeps at most 4096; the oldest go first, judged by the timestamps of the applied entries, and the outputs then follow normal file retention.
A start that names a file id the app does not hold answers 410 INPUT_EXPIRED, which cannot tell a file that expired from one that never existed.
File retention
Section titled “File retention”A run started once the logged cluster version brings fileRetention (and finalOutputsOnly, which gives it its final steps) releases its files by these rules, judged on the timestamps of the applied entries, never a node’s clock.
A released file loses the run’s reference and is then forgotten by the blob retention once nothing else refers to it, an hour later (BLOB_IDLE_MS).
Its quota is given back when the leader collects it.
| Files | Held until |
|---|---|
| Inputs | at least 24 hours after the run ended (INPUT_RETRY_WINDOW_MS, then the idle hour), so a retry inside that window finds them; a retry holds them again for its own run |
Outputs of a step the pipeline’s outputs names (the final outputs; a pipeline with no outputs has none) |
the app’s resultDays after the run ended: 1 to 90, 7 (DEFAULT_RESULT_DAYS) until set; see below |
| Outputs of every other step (intermediates) | the end of the run; the step cache holds a cached step’s outputs on for its own 7 days and no longer |
An app’s owner, or whoever manages its organization’s apps, sets resultDays for every pipeline of the app (PUT /apps/{app}/pipeline-settings, a passkey step-up over { resultDays }, meroctl cloud compute pipeline settings).
It is one componentResultDays entry in the app’s log, and a sweep reads the value current when it runs: shortening it releases results already older than the new value at the next sweep, lengthening it keeps the results not yet released.
Inputs keep their 24 hours whatever it says.
The route answers 409 FEATURE_NOT_ACTIVE below the cluster version that brings fileRetention.
A run started once the cluster version brings runScopedFiles wraps its inputs and intermediates under a run key that is deleted when the inputs are released, so no backup can open them afterwards.
The final outputs stay under the app’s file key and are in the backups until those expire.
The step cache keeps only runs whose outputs are final: an intermediate output is never reused by another run, so a retry computes the intermediates again.
A record that is dropped before its time (the last 64 finished runs are kept) releases what it still holds, once.
A run started before the cluster version brings fileRetention holds its inputs and outputs until its record is dropped.
The leader checks each app it leads and logs a componentSweep entry at most every 15 minutes (SWEEP_EVERY_MS), when an idle blob, a cache entry or a finished run’s hold is due, so an app that records nothing else still expires its files.
This holds for a compute-only app too, whose collected files give their quota back the same way.
Retries
Section titled “Retries”Below the pipeline a step run is already retried by the run driver: a lost job node, or an attempt that is refused or fails attestation, gets up to three attempts, and the lost ones are unbilled.
A fuel, memory, trap or app-error failure is final for that run and is never retried automatically.
POST /apps/{app}/pipeline-runs/{run}/retry { limits?, maxCost? } starts a new pipeline run from an ended one: the same pipeline at the same release version, hash and compute component (even if the app upgraded since), the same inputs and params, retryOf set, and the given per-step limits replacing the pipeline’s own for those fields.
An override above the method’s cap is 400 LIMIT_EXCEEDS_CAP and a step the pipeline lacks is 400 BAD_LIMITS; a run that is still running is 409 STILL_RUNNING.
Steps and items that succeeded before and made final outputs are step cache hits and cost nothing; a step whose outputs are intermediates runs again, because those files are wrapped under the retried run’s run key and no other run reads them.
The cache key leaves caps out so that raising a limit does not miss a final output that is already cached.
The inputs are held for at least 24 hours after the run ended; a retry of a run whose record is gone, or whose input was forgotten, answers 410 INPUT_EXPIRED.
Cost cap
Section titled “Cost cap”maxCost (a decimal string of micro-units) on a start caps what the run may owe.
A person may leave it out. A start or retry by an API key or by an app must give it (400 MAX_COST_REQUIRED), so a cluster with no price table takes starts from people alone.
The cap is the caller’s own ceiling on one run: the node sets no limit on it, so it is not a budget over a key’s or an app’s runs.
It needs the operator’s price table (409 NO_PRICE_TABLE without one) and is priced by it: the node copies the table onto the run, with the pipeline’s worstCase under it, which the start answers, so apply never reads system state.
The cap stops admission and does not refuse the plan: a run whose worstCase is above maxCost still starts.
Before every start or more decision the leader counts what the run may owe: the priced usage of its finished runs (never above runCost of their caps) plus the worst case of every active run, and starts only the runs that fit.
When the next run does not fit, the step is failed with COST_CAP: the runs already going finish and are paid for, no more start, dependents are upstreamFailed and the run ends failed.
Whether it fits depends on the wave: a small pool starts fewer runs at once, and the ones that finished count at what they used, so a fan-out can finish under a cap on a small pool that fails it with COST_CAP on a large one.
Apply judges the same sum again from the record alone and refuses a decision that would pass the cap.
Cached runs cost nothing.
The view shows cost (maxCost, priceVersion, table, worstCase), costSoFar and each step’s cost.
Runs an app starts
Section titled “Runs an app starts”An app uses another app’s pipelines as it uses its methods: a synchronous cross-app call naming the pipeline app, which the node answers itself.
calimero_sdk::pipeline makes the three of them.
| Method | Kind | Arguments | Answer |
|---|---|---|---|
pipeline.start |
call | { pipeline, start: { inputs?, params?, maxCost?, idempotencyKey? } } |
{ run, worstCase? }, as the start route |
pipeline.get |
view | { run } |
the run, as GET /apps/{app}/pipeline-runs/{run} shows it to those who handle the app’s files |
pipeline.cancel |
call | { run } |
null |
A method name holds no dot in an app’s ABI, so these are never a method of the target.
The node admits the calling app on the latest system state: the pipeline app must be linked under one of its references, created with it or attached by whoever manages both (403 FORBIDDEN otherwise), and both must be in one organization.
It judges the app alone: a person’s delegation never applies, and a read-only member’s run views a run but starts and cancels none.
The run’s caller is { "kind": "app", "app": <the calling app> }.
The app reads and cancels only the runs it started; any other run is 404, as an unknown one.
It sees its run’s results and file hashes, since it chose the run’s inputs and the owner linked it to do so.
It may use any file the pipeline app holds whose id it knows, and no file of its own: another id is 410 INPUT_EXPIRED.
The pipeline app’s payer pays, maxCost is required (a ceiling the calling app chooses, not a budget the node sets), and the app counts against the pipeline app’s 8 running runs.
An idempotencyKey is the calling app’s own: the same string from a person or another app starts another run.
Without one, the node uses the call’s own key, derived from the calling run’s, so a re-run of the calling method answers the run it already started.
A start whose answer outlasts the calling run’s wait (3 s) may still be logged, and the retry answers it.
An answer over 1 MiB is refused like any synchronous call’s, so a run with very many outputs is read through the pipeline app’s own routes.
A start by an app is in the pipeline app’s log only from the cluster version that brings pipelineAppCaller: below it the start is refused 409 FEATURE_NOT_ACTIVE.
Validate and estimate
Section titled “Validate and estimate”Both are reads: nothing is logged and nothing is stored.
POST /pipelines/validate { source, package?, version? } lists every problem of a pipeline source, each with its path and stable code.
Alone it judges the structure; with a release the caller sees (404 otherwise) it also checks against what installing that release would build: its compute methods as self, its module pins resolved as install resolves them, and the cluster’s pools.
That check, like install, also refuses an input’s maxItems above the 1,024 files one start takes (BAD_MAX_ITEMS).
A valid answer carries the canonical pipeline, worstCaseFuel and, with a price table, worstCaseCost.
POST /apps/{app}/pipelines/{name}/estimate answers the runs, fuel and cost per step for the file counts given (ids are only counted, never checked for being held).
A forEach over inputs.x makes ceil(min(count, maxItems) / batch) runs, and one over a step’s outputs keeps maxItems; with no counts it is the worst case.
Events, receipts and exports
Section titled “Events, receipts and exports”GET /apps/{app}/pipeline-runs/{run}/events is a server-sent event stream, open to whoever may read the run: a snapshot, then run and step events as the run moves, then end, and the stream closes.
The events carry metadata only, never results or file ids; the node polls the run’s strong view every 500 ms and diffs it, so a follower answers through the leader.
A node serves at most 64 subscribers per app (429 TOO_MANY_SUBSCRIBERS), and a stream lasts at most an hour.
GET /apps/{app}/pipeline-runs/{run}/receipt answers, once the run ended (409 RUN_NOT_ENDED before), { receipt, node, signature }: the run’s pipeline hash, the modules by compute hash, each input’s size and hash, and per step run the attempt, the job node, its job key, the assignment digest, the hash of its signed report, its signature, outputs and usage (cached runs name their cache key), signed by the answering node’s receipt key over "calimero.pipeline.receipt.v1\0" ‖ JCS(receipt).
Only those who may handle the app’s files read it.
Only a run’s final outputs leave the cluster: the files of the steps the pipeline’s outputs names.
The API names those steps on the start request, and the app’s leader keeps them as finalSteps on the logged pipelineStart only when its logged cluster version brings finalOutputsOnly.
Apply then sets FileSeal::held on the run’s input files and on the outputs of every other step (a cache hit’s included), and on all outputs when outputs is absent.
A step’s outputs it hands out count in FileSeal::final_refs while the run’s record exists, and a file leaves when it is not held or some run record counts it final, so another run’s use of it as an input or an intermediate does not hide it.
A done final that arrives after its step settled, or after its run record is gone, is held.
A held file that leaves no more is not in the files list, and its info, export and segments answer 404 as for an id the app does not hold, to every caller; the app’s own code sees it as missing, and compute::publish (so a grant) refuses it as NOT_A_RUN_OUTPUT, in the leader’s check and again in apply (BlobsState::is_output_of).
Held files count toward the app’s file cap.
A new run takes a file as an input only if it may leave, or it is a held upload of the caller’s own (FileSeal::named_by; a pipeline key’s uploads are its own, not its person’s): the API checks it against the leader’s record and pipelineStart judges it again in apply, so no pipeline passes another run’s intermediate output, or another member’s upload a run holds, on as a final output.
An app’s own runs.start takes only files that may leave.
A run’s view shows the result and results of the steps it hands out only, as it shows their files.
Steps still read held files as inputs inside the run.
An output leaves the cluster sealed to a key its requester holds: POST /apps/{app}/files/{id}/export { recipient } (an X25519 public key, 64 hex) answers { app, id, size, sha256, segments, ephemeral, wrapped }, the file’s data key wrapped to recipient, and the segments come from GET /apps/{app}/files/{id}/segments/{k}.
The client checks every segment against the list and the plaintext’s size and SHA-256 before it accepts the file (meroctl cloud compute pipeline download writes <target>.part and moves it into place only then).
An account may export 30 times a minute per node (429 TOO_MANY_EXPORTS).
Usage and billing
Section titled “Usage and billing”The job node measures CPU seconds, peak memory times wall time (GiB-seconds) and fuel used, and signs them in its report.
The node that commits the final entry adds calimero_app_compute_cpu_seconds_total, calimero_app_compute_gib_seconds_total and calimero_app_compute_fuel_total (labels app, org, developer) and counts the call in calimero_app_calls_total{kind="compute"}, only for runs that ended with a job node’s signed report.
See Observability.
A job node exposes no usage series.
Limits
Section titled “Limits”| Limit | Value | Constant |
|---|---|---|
| Wall time of a run | 900 s (15 minutes) | MAX_COMPUTE_WALL_SECS |
| Memory of a run | 4096 MiB | MAX_COMPUTE_MEMORY_MIB |
| Fuel of a run | 10^12 | MAX_COMPUTE_FUEL |
| Arguments of a start | 64 KiB | MAX_COMPUTE_ARGS_BYTES |
| Inputs of a run | 64 files, 2 GiB in all | MAX_RUN_INPUTS, MAX_RUN_INPUT_BYTES |
| Inputs of a run a pipeline builds | 10,000 files, 2 GiB in all | MAX_PIPELINE_RUN_INPUTS, MAX_RUN_INPUT_BYTES |
| One file (input or output) | 2 GiB | MAX_FILE_BYTES |
| All files written by one compute run | 2 GiB | MAX_COMPUTE_FILE_BYTES |
| All files written by one call | 64 MiB | MAX_RUN_FILE_BYTES |
| Open files in one run | 16 | MAX_OPEN_FILES |
| Files created in one call | 1000 | MAX_NEW_FILES |
| A file or output held with no reference | 1 hour | BLOB_IDLE_MS |
Result of a compute method (past it the run ends Trap(HostDenied, "result too large") with no result) |
64 KiB | MAX_COMPUTE_RESULT_BYTES |
| Progress step | 128 bytes | MAX_PROGRESS_STEP_BYTES |
| Runs started by one call | 16 | MAX_STARTS_PER_RUN |
| Active runs of one app | 64 | MAX_ACTIVE_RUNS |
| Finished runs kept per app | 256 | FINISHED_RUNS_KEPT |
| Attempts per run | 3 | MAX_ATTEMPTS |
| Heartbeat poll | 2 s | JOB_POLL |
| A status, delete, load or output-key request to a job node, in a pool apart from transfers | 5 s | JOB_CONTROL_TIMEOUT |
| An attestation fetch from a job node | 10 s | JOB_ATTEST_TIMEOUT |
| Attempt declared lost | 20 s without an answer | JOB_LOST_AFTER |
| Leader deadline past the wall cap | 60 s | DEADLINE_GRACE |
| A cancel the job node does not confirm | 20 s healthy time (at most 200 s wall time), from the current leader’s first sight, then the run ends | CANCEL_DEADLINE |
| A granted run no job node takes | 10 minutes healthy time (at most 20 minutes), from the current leader’s first sight, then failed refused |
QUEUED_RUN_TIMEOUT |
| Runs one job node takes at once | 2 | RUNS_PER_JOB_NODE |
| Concurrent job operations per node | 8 | MAX_INFLIGHT_JOB_OPS |
| Concurrent runs per organization | 4 | Quotas.maxConcurrentRunsPerOrg |
| Reserved fuel per organization | 10 times the fuel cap | Quotas.computeFuelPerOrg |
| Stored file bytes per organization | 50 GB | Quotas.maxFileBytesPerOrg |
| One assignment request | 8 MiB | MAX_ASSIGNMENT_BYTES |
| A finished run kept for its leader | 1 hour | JOB_RESULT_TTL |
| A run waiting for its inputs | 10 minutes | AWAITING_INPUTS_TTL |
| Sealed bytes a job node holds | 8 GiB | MAX_FINISHED_BYTES |
| File chunk | 64 KiB plus a 16-byte tag | CHUNK_BYTES, TAG_BYTES |
Decisions
Section titled “Decisions”Each row is one decision and the reason for it.
| # | Decision | Why |
|---|---|---|
| CA1 | The WIT package stays one package and moves additively to calimero:app@0.5.1, with new files, runs and job interfaces (a file is created, opened and read, never deleted) and no change to any existing type. The import check accepts calimero:app/*@0.5.z for z up to 1. |
Components built against 0.5.0 keep linking, as wasmtime’s semver matching within 0.5.z allows. |
| CA2 | A compute run is a second component, world calimero:app/compute, whose run export the job node calls through the existing action kind. Its profile is fixed per method in the ABI of both components: compute: { fuel, memoryMib, wallSecs, result }. The result method is marked computeResult, runs as kind = call with the system as caller, and /intents refuses it. Host caps are 900 s, 4096 MiB and MAX_COMPUTE_FUEL. |
One action kind with two profiles keeps the model small, and a result method no client can call means no client can forge an outcome. The result method stays on the app component, which is the one that may write state. |
| CA3 | Files use a random 256-bit data key per file, 64 KiB AES-256-GCM chunks with the index in the nonce and a last-chunk flag in the authenticated data, and a per-app file key HMAC-SHA256(K_c, "calimero.files.v1|" || app) that wraps data keys with a fresh subkey per wrap. Opening checks the plaintext size and SHA-256 against the blob’s record. A file is a list of segments of 256 chunks, and its id is a domain-separated SHA-256 of the segment hashes, so it never equals a plain blob’s content hash and files still share the blobs’ ids. |
The file key is separate from the app’s TEE key, which is also a curve private key. A fresh subkey per wrap removes any random-nonce bound per key, and GCM does not commit to its key, so the recorded hash does. |
| CA4 | Component files live on the app’s replicas, pushed over the existing blob route and successful at a majority of those replicas. | A cluster-wide majority multiplies disk for large uploads. Replicas already survive a node loss and move with the app. |
| CA5 | Uploads go through the sealed channel to POST /apps/{app}/blobs. The receiving node passes the body to the app’s leader, which seals, charges, stores on a majority of the voters and commits the blob record; an upload is at most 47 MiB. A file cannot be downloaded or granted through the API: GET answers 409. |
Core publishes no app public key to seal to, and a per-file key is what a run’s re-wrap needs. |
| CA6 | A per-organization stored-file quota, maxFileBytesPerOrg (50 GB), is counted in the system group, charged before a file’s record commits, and released when retention collects the file or the app is deleted. |
The organization pays for the bytes. The charge is not atomic with the app log, so a crash between them can leave a small over-count. |
| CA7 | Job nodes are registered with role: job but are never Raft members. They are excluded from admission, placement, blob pushes, key delivery and placement counts, and run merod run --job-node with no KMS key, no cluster key and no store. |
A member keeps its log sealed under the cluster key, which a job node must never hold. “No vote” then holds structurally rather than by policy. |
| CA8 | Q-P1, how the leader checks a job node’s release. The existing attestation machinery, with a job variant: GET /attestation?purpose=jobs returns a quote binding the transport key and an Ed25519 job key, verified by verify_job_key with the shared peer policy. The attested release must then be approved for the app’s organization. |
One verification path, one policy. The leader learns the job node’s keys and its release from a single quote, before it re-wraps anything to it. |
| CA9 | For each input the leader unwraps the data key and re-wraps it to the job node’s attested transport key (ephemeral X25519, HKDF over the key pair, app, run, attempt and index, AES-256-GCM). The noise seed is wrapped the same way. The run token is HMAC-SHA256(file key, "calimero.compute.token.v1|" || run || "|" || attempt with the attempt in decimal`. |
Wrapped keys travel only in the assignment, never in the log. The job node opens them through its sealed transport, and any replica can derive the token, so a new leader can keep polling. |
| CA10 | Replaced by CA26. An earlier design had the job node accept an assignment only from a leader whose receipt key it attested and whose URL it listed. | Attesting the leader cost the job node a fetch, a cache and an amplification path for every sender. |
| CA11 | Q-P4, heartbeats and progress. They are polls, not log entries. The leader polls the job node every JOB_POLL; the answer is the heartbeat and carries progress, kept in memory and served from GET /apps/{app}/runs/{run}. No answer for JOB_LOST_AFTER, or UNKNOWN_RUN, marks the attempt lost and a new attempt starts elsewhere, at most MAX_ATTEMPTS. A new leader starts the clock at takeover. A run with no report by its wall cap plus 60 s fails with timeout. |
A heartbeat in the log would put a write on every replica every few seconds for work that produces no state. Polling keeps the log to one entry per attempt and one final entry, and the token is derivable by any replica. |
| CA12 | The job node signs its final report with its job key over the app, run, attempt, status, result hash, outputs and usage. The final entry carries the report and signature. Every replica verifies it against the job key recorded for that attempt and applies only the first final entry for a non-final run’s current attempt. Cancel, lost and timeout finals are leader entries with no job signature. | Otherwise anything that reaches the leader could post a result. Verification at apply is deterministic, so every replica reaches the same verdict. |
| CA13 | The component log gets two lifecycle entries, computeAttempt and computeFinal; a start rides in the starting call’s outcome (computeStarts) and is dropped if the call fails. The result method runs inside the final entry on the leader. Run records are host records the guest cannot reach through its own storage. |
One atomic entry means a result is recorded exactly when the run is. A failing result method leaves the run done, because the work itself succeeded. |
| CA14 | runs.start is idempotent: an active run with the same method, argument hash and inputs is returned. runs.cancel marks the run, and the leader aborts the job and commits a cancelled final entry with the usage so far. The app decides who may cancel. |
A retried call cannot start the same expensive work twice. |
| CA15 | The queue and caps live in the system group: AcquireRun grants while the organization’s running count, reserved fuel and the job nodes’ total capacity allow, else queues, and ReleaseRun frees and grants the next, oldest waiting organization first. The fuel reservation is the fuel declared and is released at the final entry. |
Quotas are enforced at apply, where every replica agrees, and one organization’s backlog cannot starve another’s. |
| CA16 | Compute components are prepared and run only on a dedicated compute engine, never the replica engine, and use a dedicated configuration: on-demand allocation instead of pooling, canonicalized NaNs, no threads, memory sized from the budget, a fixed clock equal to the start entry’s timestamp, randomness from ChaCha20 over the noise seed, and no network. | A restart on another job node must produce byte-identical output, so nothing that varies by machine or by moment may reach the guest. A replica can then never run a compute component, nor a job node an app component. |
| CA17 | The job node measures CPU seconds, peak memory times wall time and fuel used, and signs them. The leader that commits the final entry adds the compute usage series and counts the call. A lost attempt is not charged. | Billing follows the signed report, so it matches what ran, and a node’s failure is not the customer’s cost. |
| CA18 | A node on a release without files refuses to prepare a bundle that imports calimero:app/files, so it never runs, leads or answers for such an app. No release floor is needed. |
Mixed-release replicas exist only while an upgrade moves apps, and the older ones are then retired. Run records follow the same rule. |
| CA19 | The majority for a file push is over the app group’s Raft voters, read from the group’s status, not the system directory’s replica list. | During a move the directory holds a union of old and new replicas, and a majority over it would be wrong. |
| CA20 | A file whose record failed to commit is deleted, and its charge refunded, only after a no-op barrier entry of the current leader commits and a strong read shows the record absent. | Raft then guarantees the failed entry can never commit. Without the barrier a late commit would leave a record pointing at deleted bytes. |
| CA21 | Uploading to a component app needs its owner or an organization role of member or above, even when the app is public. |
The organization pays for stored bytes, so strangers and guests cannot fill its quota. |
| CA22 | The file quota is counted per app in the system state with payer totals kept in step. A release is taken from what apply actually removed, never from what a run saw when it was built. | A stale view cannot refund more than was charged. |
| CA23 | A job node attests only for purpose=jobs, bound to its transport key, job key and release, and answers no plain attestation. Every peer request carrying the cluster secret goes through one gate to replicas only. A node’s role is fixed at registration. A job node runs from a narrow JobConfig with no storage key. |
No channel that carries the cluster secret, the cluster key, Raft or blob traffic can ever open to a job node. |
| CA24 | Peers are gated by node id, never by an address string, and addresses are compared normalized. A job node can be registered only once every replica node, voter and learner, runs at least the registering node’s release (else 409 CLUSTER_NOT_UPGRADED). The jobs attestation binds the cluster, node id, transport key, job key and release. |
An address is spoofable, an id is not. No older node can apply or snapshot a record it does not understand. |
| CA25 | A run’s outcome never depends on the node it ran on. Node-local failures (instance pool, allocation, OS memory, file I/O) are Unavailable, retried elsewhere and never reported as the app’s failure. A cancel is cancelled, running out of wall time is a lost attempt retried on another job node (fuel is the deterministic cap, and timeout is the leader’s deadline), reads fill to the requested size, a compute run sees constant caller and time values, and wasi:random is capped per call. Accepted: stack depth may differ by CPU, so a run at the recursion limit can end differently on two job nodes. |
A customer must never pay for, or be told about, a fault of someone else’s hardware. The recursion-limit case is a known gap. |
| CA26 | Job-node admission is a cluster identity key: every cluster node derives one Ed25519 key from the cluster key, the job node is started with its public half, and every assignment and bundle upload carries a signature. Runs are keyed by app, run and attempt, and a report also binds the digest of the exact assignment it ran. | Only an attested TD of this cluster can hold the cluster key, so a signature proves the sender is a node of the cluster, with no attestation fetch or cache on the job node. This replaces CA10. A job node also prepares every bundle on the compute world, so a signed app component is refused (BAD_BUNDLE) too. |
| CA27 | A job node decides input integrity once, from the uploaded bytes in memory, so its own disk can never turn a correct input into a signed failure. A computeAttempt entry records the job key and the assignment digest, and every replica verifies a final report against both. Later read failures are lost attempts. |
The disk of a job node is outside the trust boundary, and a report must be checkable by a replica that never talked to the job node. |
| CA28 | A run that can never be granted (its fuel alone exceeds the quota, or it was released), or that is granted but taken by no job node within QUEUED_RUN_TIMEOUT (10 minutes of healthy time, at most twice that), ends as failed with reason refused, and a run the queue grants no place in that time ends not-granted. Every value a job node signs is bounded at apply: output sizes and count, fuel within the declared cap, CPU and memory within the run’s caps. An input of a run is pinned as a reference while the run is active and for the retry window after it ended (file retention), so retention cannot collect it while the run can still be retried. |
No run may occupy an app’s active set forever, and a compromised job node cannot make a replica apply an absurd value. |
| CA29 | Assignments are deterministic: each wrap’s ephemeral key and nonce derive from the file key and the run, attempt, kind, index and job key. The leader delivers an assignment before committing its attempt. A cancel bills the usage the job node signed when it stopped, and has none when the job node does not answer. | Any leader can rebuild the exact assignment an attempt’s digest names, and a busy or unreachable job node costs no attempt. |
| CA30 | A file is a sealed blob: it shares the blobs’ ids, BlobRef replaces a separate file id, and there is no delete. Retention is that of blobs: a file nothing refers to is forgotten BLOB_IDLE_MS after it was made, and the quota is released when it is collected. |
One identifier and one retention rule for every byte an app holds, and a reference in state is the only thing that has to be kept honest. |
| CA31 | A run’s outputs are registered as sealed files by the final entry, before the result method applies, and are kept only if the result method stores their BlobRef. Inputs are pinned while the run’s record is kept. |
An output the app never claims cannot linger or hold quota, and an input cannot be collected under a run that reads it. |
| CA32 | One crate builds two components: the app component (world app, imports runs) and the compute component (world compute, imports job, export run). meroctl app build writes both, the compute one through --cfg calimero_compute in its own target directory, and the signed manifest carries it as compute. |
The compute component has no state, xcall, events, blobs, runs or wasi:http to import, so what a job node can do is enforced by the import check, and authors write one crate. |
| CA33 | Install prepares the compute component on the compute engine only and requires its ABI to be the compute world’s and to list exactly the app ABI’s compute methods with the same caps (400 BAD_BUNDLE, 400 COMPUTE_ABI_MISMATCH). Both come from one signed release. |
The two components cannot drift: the app’s result methods, caps and the compute methods a job node runs always describe the same methods. |
| CA34 | A run pins the compute component of the release the app was running when its start was logged (RunRecord.compute_bundle, filled by the leader into the entry, never read at apply). An app with no compute component cannot start a run (no compute component), so a raw single .wasm upload cannot start runs. |
Every replica records the same hash, and a restart on another job node, or after an upgrade, runs the same component. |
| CA35 | The leader sends a job node only the run’s compute component as Assignment.bundle, and the job node refuses an app component. Billing and the result method stay on the app component, and the compute usage series carry app, org and developer. |
A job node never receives code that could reach state, and the organization is billed against the release that started the run. |
In calimero-node
Section titled “In calimero-node”Where the node implements this chapter, by the names in its code: paths are under crates/node/src unless another crate is named.
The design and its reasons are above; a module’s own detail is in its //! doc, and the node’s mental model is crates/node/AGENTS.md.
Job nodes
Section titled “Job nodes”Code: NodeRole::Job, job_node.rs, node/job.rs.
Registration
Section titled “Registration”POST /ops/nodes { id, addr, zone?, role?, pool? } is operator-signed.
role is replica (the default) or job; it is in the signed arguments unless it is replica, and pool only when set.
DELETE /ops/nodes/{id} removes a node and changes system membership only for a node that is in it.
| Refusal | Status | When |
|---|---|---|
NODE_HOLDS_CLUSTER |
400 | role: job for a system voter, learner or --peers id |
ADDRESS_TAKEN |
409 | another id holds the address (RegisterNode) |
CLUSTER_NOT_UPGRADED |
409 | a replica node, voter or learner, runs an older release than the node being registered |
JOB_NODE |
400 | /ops/apps/{app}/replicas names a job node |
RegisterNode also refuses a second role for an id.
Its refusals bind only nodes that run this release, so upgrade the voters before anything else.
A node registered as a replica becomes a learner only after it attests its transport key as a cluster node (attests_as_replica), so --peers must list only replica nodes.
Keeping job nodes out of the cluster’s own work
Section titled “Keeping job nodes out of the cluster’s own work”- Every site that picks nodes for the cluster’s work reads
SystemState::replica_nodes/replica_node(id), nevernodes; a ceremony holder is resolved the same way. internal/cluster-keyrefuses a job node,/ops/placementlists it with itsrole, and app counts stay replica-only.- Nodes are reached by id: Raft’s
PeerTransport::sendusesNode::replica_addr(id)(the directory’s address, else--peers; none for a job node). internal/cluster-keyusesNode::key_recipient_addr(id): the directory’s address, else the system group’s membership, else--peersbefore genesis only.- Address-only callers (
Node::peer, sopeer_postand streams) compare normalized addresses (system::normalize_addr) and refuse any that is not a replica’s.
The job node process
Section titled “The job node process”merod run --job-node calls run_job(JobConfig): no store, K_c, KMS, Raft or system group.
It serves /health, /attestation and GET /job/load ({ running, capacity }; capacity is --job-slots, default RUNS_PER_JOB_NODE).
/attestation answers only purpose=jobs; any other purpose, or none, is 404.
Its Ed25519 job key is made in memory at start.
The leader’s side
Section titled “The leader’s side”Node::attest_job(id, app)fetchespurpose=jobsover a fresh nonce and verifies it withverify_job_keyunder--peer-profilesand--peer-min-release.- It then refuses a release the app’s org or account has not approved (
release_may_hold, asmay_senddoes). - A verdict is kept
JOB_ATTEST_TTL(60 s) while the directory’snode_epochfor the id is unchanged, and until a channel to it fails (forget_job). - It fails outright when the directory could not be brought up to date.
/ops/placementreads a job node’s release through the same cached attestation.GET /ops/job-nodes/{id}/attestationruns the check without the per-app approval;JobAttestErrorsorts statuses (5xx, 408, 425, 429 and transport failures areunreachable, any other non-2xxrefused).Node::job_load(peer)asks over a sealed channel pinned to the attested transport key.- Reads from a job node (
attest_job,job_load) stop atMAX_JOB_RESPONSE_BYTES.
Job runs
Section titled “Job runs”Code: job_node/{admission,bundles,runs,exec}.rs, job_wire.rs.
Admission
Section titled “Admission”The cluster identity is backup::cluster_identity_key, an Ed25519 key with seed HMAC-SHA256(K_c, "calimero.cluster-identity.v1").
A job node has no --peers and attests nothing about a sender.
At start check_cluster_identity refuses a key that is not a curve point or is of small order, and signatures are checked strictly.
The identity is bound into the job node’s quote (AttestationDoc::cluster_identity, job_key_binding), so attest_job refuses a job node that serves another cluster.
PUT /job/bundles/{hash} needs x-bundle-signature, the identity’s signature over "calimero.compute.bundle.v1\0" || hash (403 BAD_SIGNATURE).
It checks the hash and prepares the component once on the compute engine, keeping MAX_JOB_BUNDLES (least recently used goes first).
An app component is 400 BAD_BUNDLE.
POST /job/runs (at most MAX_ASSIGNMENT_BYTES, 8 MiB) takes an Assignment (job_wire).
It is signed by the identity over a length-prefixed binary message of every field (assignment_message, big-endian integers); Node::sign_assignment is the cluster side.
Its refusals, in order:
- shape:
400 BAD_ASSIGNMENTorBAD_BUDGET, duplicate input ids,413 TOO_MANY_INPUTS,INPUT_TOO_LARGEorINPUTS_TOO_LARGE; 403 BAD_SIGNATURE;- an assignment already held answers its state, or
409 RUN_CONFLICTif it differs; 503 BUSYat--job-slotsruns waiting or running, or when finished outputs on disk plus what active runs and the new one may still write passMAX_FINISHED_BYTES(nothing is evicted);409 NEED_BUNDLE;400 NOT_COMPUTE: the compute ABI does not list the method;400 BAD_WRAP: every wrapped key must open now throughunwrap_for_job, so a key made for another node, run, attempt or index never gets in.
Routes of one run
Section titled “Routes of one run”Runs are keyed by (app, run, attempt); every other route is /job/runs/{app}/{run}/{attempt}/... with the app id URL-encoded.
Each needs the run token in x-run-token (constant-time compare), and a wrong token answers as an unknown run, 404 UNKNOWN_RUN.
| Route | Does |
|---|---|
PUT .../inputs/{i}/{k} |
Takes segment k of input i in any order, if its length and SHA-256 match the assignment (400 BAD_SEGMENT, 404 NO_SUCH_SEGMENT) |
GET .../{attempt} |
{ state: awaiting | running | done | lost, progress?, report?, signature? } |
GET .../outputs/{i}/{k} |
One segment of an output’s ciphertext, read by range (404 NO_SUCH_SEGMENT past the last) |
GET .../outputs/{i}/key |
The output’s data key (hex), once done |
DELETE ... |
Sets the cancel flag, waits CANCEL_WAIT, answers the last status and drops the run with its scratch files |
GET .../log/{k}, .../log/key |
Deprecated: 404 NO_LOG for any run (runs::no_log) |
- An input whose segment list does not hash to its id is
400 BAD_ASSIGNMENT. - Each segment is written at
k * SEGMENT_BYTESin the input’s scratch file. - After the last segment, the file is streamed through the opener (
exec::input_matches) to prove it opens to the declared size and hash. - An input that fails that check ends the run with a signed
integrityreport, since the leader sent it. - The run starts on its own OS thread once every input is in.
donecarries the signed report, a failed run’s included;lost(anUnavailabletrap, a thread panic, node file I/O) is never signed.- Outputs are listed in the order the run finished them.
- A run that did not stop on
DELETEstays and answersrunning. - Runs not deleted are swept
JOB_RESULT_TTLafter they end; runs still awaiting inputs end lost afterAWAITING_INPUTS_TTL. - The scratch directory is emptied at start, so a restarted node knows no runs.
- Sealed request bodies are decrypted and buffered before any route check, bounded by the sealed in-flight cap; that is accepted.
Executing and reporting
Section titled “Executing and reporting”- The run invokes the compute component’s
runexport as an action over the assignment’s files only (Assignment.bundlenames the component). - Inputs are streamed from the scratch ciphertext through
FileOpenerand checked withfinish_expectingat the end; a failure then is a read error, so the run is lost, notintegrity. - Outputs are sealed to disk under a fresh key each (
NewFile.ciphertextstays empty). - The engine is
WasmtimeEngine::for_compute, run throughWasmtimeEngine::run_compute(ComputeRun), the setupcrates/meroctl/computealso uses. calimero_app_engine_wasmtime::ending_ofclassifies a trap, andexec::classifymaps it ontoFailReason; aTimeoutis a lost attempt.- A trap or app-error report carries the text in
Report::message(signed, at mostMAX_REPORT_MESSAGE_BYTES). Reportusage is integers:cpuMicros(thread CPU),gibMicros(peak memory times wall) andfuel.- The job key signs
"calimero.compute.report.v1\0", the SHA-256 of the assignment message and the length-prefixed fields (report_message). - One encoding only: ids and hashes are lowercase 64 hex, a done report has no reason, and a failed one has a reason and neither result nor outputs.
verify_report(job_key, assignment_digest, report, signature)is the one check the leader uses.Assignment’sDebughides the token and wrapped keys; the seed and keys live inZeroizing, except the seed copy in the host core’sInvocation.
Compute runs
Section titled “Compute runs”Code: component/runs.rs.
Starting a run
Section titled “Starting a run”runs.startputsOutcome::compute_starts(andcompute_cancels) in the outcome, and the node fills the app’sowner(Outcome::name_owner).- The leader reads the payer from fresh system state when it acquires.
- A read-only member’s call that starts or cancels a run is refused like one that writes keys.
apply(statusOkonly) writes aRunRecordas a hidden row (rows::CRUN) and adds the id toComponentHead::active_runs.- A start past
MAX_ACTIVE_RUNS, or of a known id, is dropped;finished_runskeeps the lastFINISHED_RUNS_KEPTids. RunRecord::compute_bundleisComponentHead::compute_bundle, set by the app log’sInitorUpgradeentry; apply never reads system state for it.- A record with no
compute_bundle(from before compute components) means no compute component. runs.startanswers the soft errorNO_COMPUTE_COMPONENTwhen the running release has none.- The host refuses an input that is a plain blob, unknown, or a file the same run just made.
pin_inputsadds one reference per input at the start and removes it at the final.- An upgrade that would leave an active run’s result method undeclared is refused on the leader (
RunNeedsResultMethod). - A run record that cannot be read makes the host deny start and cancel (
RUN_RECORDS_UNREADABLE). - A run being cancelled is not the answer to a start of the same job.
initstarts runs on its own bundle.
computeAttempt and computeFinal
Section titled “computeAttempt and computeFinal”computeAttempt { run, attempt, node, jobKey, assignmentDigest, tsMs } applies to an active run with no cancel requested.
attempt must be the next number and at most MAX_ATTEMPTS, and both keys must be 64 lowercase hex; it sets running.
computeFinal { run, attempt, outcome, report?, signature?, outputs, usage, result, baseIndex, tsMs, idTerm, idSeq } ends the run.
The first valid final of the latest attempt (0 before any) wins.
| Outcome | Needs |
|---|---|
done, or failed with fuel, memory, trap, app-error, integrity, cancelled |
A report that verify_report accepts under the attempt’s jobKey and assignmentDigest, same status and reason, outputs and usage exactly the report’s |
cancelled |
cancelRequested; either the leader’s (no report, zero usage) or the job node’s verified cancelled report |
failed lost |
Every attempt used |
failed quota |
Nothing further |
failed timeout |
A run that was assigned |
failed refused, failed not-granted |
A run with no attempt |
Leader outcomes carry no report, no outputs and zero usage.
Outputs are bounded by MAX_NEW_FILES, MAX_FILE_BYTES each and MAX_COMPUTE_FILE_BYTES together.
A job’s CPU and memory usage are at most the wall cap plus DEADLINE_GRACE.
An output id that is not a blob id, is already a blob of the app, or is listed twice is refused.
Every permanent refusal changes nothing and answers AppError; only a stale baseIndex answers conflict and leaves the run active.
Applying a final, in order:
- records the final and releases the inputs;
- registers each output with
BlobTable::add_file, marking itFileSeal.output(publishable); - applies
resultas a call’s outcome, if its status isOk, with its own starts and cancels.
AppMachine::blob_view_with_outputsgives the leader’s result run the records the final will leave, sostorage_putaccepts those references.- The result method runs with
runs_provider(Some(run)), which leaves out the ending run, so its own start of the same job is a new run. new_file_bytescounts only the result method’s new files for the charge gate;Noneon overflow refuses the entry.- A final over the log’s cap loses only its result method’s outcome.
- A final over the cap even without it is not built (
FINAL_TOO_LARGE), and the leader ends the runFailed{tooLarge}. - The result method’s argument is camelCase, as the SDK’s
ComputeOutcome; fixtures:compute_fixture.rs(calimero-app-engine-wasmtime),apps/fixture-compute.
Run logs
Section titled “Run logs”A production node collects no app log lines: HostCore::with_logs is off unless Config::app_logs.
A development node (--dev, merod local) prints each line through node::component::print_app_logs (target app_log) and stores none.
A leader sends no x-run-log header, without which a job node of 1.0.0-rc.35 or earlier answers its report signed without a log.
A report that names a log fails report_is_valid, so its attempt is lost.
Report::log stays in the wire format and report_message so old finals replay identically.
For such a final, check_final takes a log only when it is the report’s, and apply_compute_final keeps it only within MAX_RUN_LOG_BYTES (kept_log).
That log is a FileSeal.log file named by RunRecord::log, held until finish_run drops the record, counted toward the quota, and hidden from the app (NodeFiles::sealed) and from runs.publish.
The files export answers it 404, and GET /apps/{app}/runs/{run}/logs answers { logs: [] } behind files_gate.
The queue in the system group
Section titled “The queue in the system group”SystemState::compute (RunSlot) holds the queue; AcquireRun and ReleaseRun run the grant pass (grant_runs).
AcquireRunis idempotent, needs the app’s payer and fuel at mostMAX_COMPUTE_FUEL, and answers{ state: granted | queued | refused, code, retryable }.- Retryable codes:
NOT_PAYER,APP_QUEUE_FULL. Permanent:NO_SUCH_APP,FUEL_OVER_RUN_MAX,FUEL_OVER_QUOTA,RUN_NO_POOL,RELEASED(released_runskeeps the last 256 per app). AcquireRunandReleaseRunare proposed only once a job node is registered, which already requires every system node on this release.- A queued run whose fuel passes a lowered
computeFuelPerOrgis markedRunSlot::refused, and the leader ends itfailed refused. - Free places go first to the payer served longest ago (
run_served), then the one whose oldest waiting run has the smallestseq. RegisterNode,RemoveNode,SetQuotas,SetPools,TransferAppandremove_appre-run the pass; a granted run is never taken back.- Reachability and approved releases are the leader’s attested view, not replicated state, so apply cannot count them and the leader bounds a run’s wait instead.
Pools. SystemState::pools is set by POST /ops/pools (operator-signed cluster / __set_pools / { pools }), each with runsPerNode and maxMemoryMib.
A job node’s NodeRecord::pool places it (empty is DEFAULT_POOL, "standard"), and a pool’s capacity is its nodes times runsPerNode (pool_capacity).
A node in a pool the cluster does not define adds no capacity.
A run goes to the smallest pool that fits its memory (pool_for), or to the pool a pipeline step names (AcquireRun { pool }) when that pool fits its memory cap.
AcquireRun refuses a run no pool fits (RUN_NO_POOL), and pick_job keeps only the slot’s pool’s nodes.
SetPools refuses to remove a pool with job nodes or runs (409 POOL_IN_USE).
With no pools defined, capacity is the registered job nodes times RUNS_PER_JOB_NODE.
Prices and quotas. SystemState::price_table (GET/POST /ops/prices, cluster / __set_price_table / { table }) holds a calimero_pipeline::PriceTable.
SetPriceTable takes only version = current + 1 (409 PRICE_VERSION) and a nonzero fuel rate (400 BAD_PRICES).
A payer’s limits (SystemState::payer_quotas) are its override in SystemState::org_quotas, else the cluster’s.
POST /ops/quotas with org sets an override (cluster / __set_org_quotas / { payer, quotas }); a field set to null clears it.
Lowering an override never revokes a granted run.
These three operator routes answer 409 UPGRADE_PENDING while a node is behind (Node::require_current_release).
Driving compute runs
Section titled “Driving compute runs”Code: node/component/compute.rs, compute/{job_io,finish}.rs.
The loop and its memory
Section titled “The loop and its memory”lib.rs calls Node::drive_runs every JOB_POLL and when a call commits (runs_kick).
For each component app this node leads, one task frees stray slots and starts one step task per active run, so a long transfer delays no other run.
A step that finds this node no longer leads does nothing, and every step works from the replicated record and system state.
In memory (Watch, per run and term) the leader keeps the healthy-time accumulator, the last answer, a held report, whether it sent the attempt, the last progress and staged outputs.
A loss the job node announces (lost, a new key, UNKNOWN_RUN after sending) first finishes from a held report (lost_unless_held).
rescue is the look at the record, a held report and one fresh poll before an attempt is lost.
Placing and assigning
Section titled “Placing and assigning”- A queued run takes
AcquireRun; a permanent refusal ends itFailed{refused}, a retryable one waits. Node::survey_jobsattests each job node and asks its load outside the assignment lock.pick_job, under the lock (assigning,reserved), picks among the pool’s nodes the fewest runs, then the lowest id.build_assignmentbuilds it from the record, each input’sFileSealwrapped key and the job node’s keys;wrap_for_job_derivedmakes the wraps reproducible.- The component (
push_bundlethroughbundle_wasm, signed withsign_bundle), assignment and inputs are delivered; a503is not a failed channel, so the next candidate is tried. Inputs go one segment at a time, from this node’s store or fetched from a replica. - Only then is
computeAttemptcommitted; a delivered run whose attempt did not commit is deleted.
A run whose pinned compute component is no longer installed, or that has none recorded, ends Failed{refused} at once, before a slot is taken.
A digest or job key that differs from what the leader rebuilds means the attempt is lost.
The run token is HMAC(file key, run | attempt).
Polling, outputs and the final
Section titled “Polling, outputs and the final”404 UNKNOWN_RUNorawaitingmakes the leader send again (component onNEED_BUNDLE), unless it already sent in this term; then the attempt is lost.- A done report’s outputs are charged to the payer before any is fetched (
QUOTA_EXCEEDEDends the runFailed{quota}). store_file(node/component/compute/finish.rs) fetches each output one segment at a time, checks it against the signed list, and stores and pushes it before asking for the next.Watch::fetchedcounts stored segments, so a cut fetch resumes; each answer counts as the job node being alive.- Each output’s key is wrapped under the app file key into a
FileMark, and the ciphertext goes to a majority of voters throughpush_files. logged_entrybuilds the final insidepropose_led; a final answeredconflictis run again.- A final the record shows still active after commit is refused for good; if reported, the attempt is lost and its staged outputs discarded.
- A new term keeps outputs staged for the same attempt (
ComputeState::take); a failed charge is refunded only if it may have landed (charge_may_have_landed). - Staged outputs are undone (refund, delete) on every exit but the commit of their final.
delete_unmarked_outputsdeletes bytes only after a barrier and a strong read show no blob of that id, since another leader’s final may register the same content.sweep_watchesundoes staged outputs of ended runs and counts a final whose proposal answer was lost.- After a final commits the leader releases the slot, deletes the job run and adds the usage to
calimero_app_compute_*andcalimero_app_calls_total{kind="compute"}.
Cancel
Section titled “Cancel”A cancel first takes a report the job already has (a done run keeps its outputs).
Otherwise it deletes the job run and ends the run Cancelled with the usage of the signed cancelled report, or none.
A run that did not stop is deleted again each round until CANCEL_DEADLINE.
A cancel whose poll gets no answer ends from a held report, else cancelled with no usage, without a delete.
Job channels
Section titled “Job channels”| Call | Pool | Timeout |
|---|---|---|
job_call: status poll, delete, load, output key |
MAX_INFLIGHT_JOB_CONTROL (32) |
JOB_CONTROL_TIMEOUT (5 s) |
| Attestation fetch | JOB_ATTEST_TIMEOUT (10 s) |
|
job_transfer: assignment, component, inputs, output bodies |
MAX_INFLIGHT_JOB_OPS (8) |
JOB_TRANSFER_TIMEOUT (300 s) |
A wait of JOB_CONTROL_TIMEOUT for a control place is BusyHere: the poll is Deferred and nothing is forgotten.
Every job-channel failure goes through forget_job.
- A queued run’s
queuecomes fromNode::queue_json;SystemState::wait_reasontests in the orderNO_CAPACITY,POOL_FULL,PAYER_AT_RUN_QUOTA,PAYER_AT_FUEL_QUOTA. - The
NO_CAPACITYwarning fires afterNO_CAPACITY_WARN_AFTER(60 s), once per term. - Progress and the failure text (
final.message) are shown only to those who may list the app’s files. - Both run routes are the reserved view
__runanswered by the leader (Node::run_view, onerun_json); the list isAppMachine::runs_page. - The list’s
beforecursor isstartTsMs:run, bounded byMAX_RUNS_CURSOR_BYTES.
Pipeline runs
Section titled “Pipeline runs”Code: component/pipelines.rs (apply), node/component/compute/pipelines.rs (leader loop), api/pipelines.rs (routes).
Records
Section titled “Records”A compute-only app’s group gets an init entry with no outcome (init_compute_only), so it has the component executor that holds files.
PipelineRun (rows::CPIPE) fixes the release version, the pipeline hash, the compute component and modules at start, with the bound inputs, params, caller and payer.
A start with an idempotency key stores the key’s hash (over the caller and the key) as key, and rows::CPKEY maps it to the run until the run is dropped: another start with that key is refused with KEY_TAKEN, which the API answers with the first run. Run ids stay random, so a dropped run’s id, whose step runs the app keeps longer, is never reused.
It also names its secretParams, the params the pipeline declares secret: run_json and build_receipt show each as { hmacSha256 } (shown_params), and only the node’s own retry and idempotency check read __pipeline_run with secrets: true for the values.
Per step a StepState keeps counters and flags only (status, started, fan, finished, failed_items, cost, run_cost, capped, results_bytes, results_too_large, reason).
The head keeps active_pipelines (at most MAX_ACTIVE_PIPELINE_RUNS) and the last FINISHED_PIPELINE_RUNS_KEPT finished ids.
A run’s retention (Retention: which holds were released) is set by the leader beside the run’s final_steps (from the pipeline’s outputs); settle_pipeline releases the intermediates at the run’s end, and ComponentCmd::Sweep (sweep_pipelines) the inputs and the final outputs when their time came (the outputs by ComponentHead::result_days, set by ComponentCmd::ResultDays).
Item rows (rows::CITEM, key <pipeline run>/<step>/<index as 8 digits>) hold ItemRow { cached_key, outputs, result }.
A run’s id is run_id(pipeline, step, index) and RunRecord::pipeline carries the index, so a run’s end finds its row without a search.
StepState::cached_count and cached_items are counters.
AppMachine::pipeline_runfills each step’sruns,run_outputs,run_resultsandcached_keysfrom the rows, stopping afterfinishedof them.pipeline_headis the record without them; the leader’s loop, the list view, the events view and a retry read it, and the loop fills only the steps it needs (fill_steps).- Apply reads the record alone and never stores those fields.
- A step with fewer readable rows than
finishedis flaggeditems_unreadable, andplanfails a step built from it withITEMS_UNREADABLE. - Dropping an ended run’s record deletes its item rows and releases their output pins in the same apply.
- A record from 1.0.0-rc.19 (per-run data inline, no
started) is read throughStepStateRepr; its finished runs count aslegacy_items, whichfillanddrop_step_itemstake as found.
Entries
Section titled “Entries”| Entry | Applies |
|---|---|
pipelineStart |
Pins every input (+1) and, with finalSteps, holds them; refused for a known id, a full app or an input that is not a held file |
pipelineStep { run, step, decision } |
A StepVerdict: Start, More, Skipped, UpstreamFailed, Cancelled or Failed { reason }; a pending step takes its first decision only |
pipelineCancel |
Flags the run and its active step runs |
Startwrites oneRunRecordper run (no result method) and recordsfan: { total, items, batch, allowed }.Moreis accepted only while the step runs, for the next indices belowtotal, until failures passallowed.- A start the app’s
MAX_ACTIVE_RUNScannot hold, or after a cancel or a failFast stop, changes nothing; one that can never work fails the step. Failedis also accepted for a running fan-out with runs left to create.apply_compute_finalsettles a linked run’s step in the same apply: it pins and keeps the outputs and result per index, holds them unless the run’sfinalStepsnames the step, and counts failed or cancelled items.- A result is kept up to
MAX_STEP_RESULT_BYTES, and a step’s together up toMAX_STEP_RESULTS_BYTES(elseresults_too_large). - A step is
succeededonce every run is final andfailed_itemsis at mostfan.allowed(zero while the run is cancelled or stopping). PipelineRun::fail_fastmakes the first failed step setstopping, cancel pending steps and flag running steps’ runs.
The leader’s loop
Section titled “The leader’s loop”Node::drive_pipelines runs beside drive_runs and is stateless: plan decides every pending step from the records and a hint read before it, the QueueRoom the system state’s queue_room answers for the app’s payer, less the app’s runs not queued yet.
It also decides the next More wave of each running fan-out: maxParallel less its active runs, bounded by the app’s room, by what the queue would grant runs of the step’s caps and pool (at least one when the step has none active) and by MAX_STEP_RUNS.
The hint is the leader’s local read and only sizes a wave: apply never reads the queue, so a stale read makes a wave smaller, or lets a run wait in the queue, and changes nothing a replica computes.
A wave is cut so its encoded runs stay within MAX_DECISION_RUNS_BYTES; a run that alone cannot fit fails the step with RUN_TOO_LARGE.
A decision is proposed only while it still applies (the step pending, or the fan-out’s next index unchanged).
The leader keeps each fan-out’s runs in memory by (group, pipeline run, step), so no item row is read twice.
A pipeline whose definition is gone (pipeline_by_hash answers 404) gets Failed{PIPELINE_UNAVAILABLE} for its unstarted or unfinished steps.
The only caches are of immutable data: Node::pipeline_by_hash and caps_of_component, read from the ABI with abi_of without compiling.
build_stepbuilds a step’s runs: inargs,params.xbecomes the run’s value or the default and<step>.resultthat step’s result as JSON; noargsis no bytes.- A step’s inputs (
inputs.x,<step>.outputs) are deduplicated and at mostMAX_PIPELINE_RUN_INPUTS. - A module step (
bundle_of) uses that module’s caps and setsStepRun::compute_bundle; apply accepts only a bundle the run pinned (UNKNOWN_MODULE). - A step’s
poolgoesStepRun::pool→RunRecord::pool→AcquireRun { pool }; the leader proposes it only whileNode::nodes_behind_releaseis empty. - A run with no result method ends with an empty result outcome and prepares nothing on the replica engine.
Routes
Section titled “Routes”- Start, cancel and retry need
api::may_handle_files(403 FORBIDDENotherwise). - An app’s
pipeline.start,pipeline.getandpipeline.cancelare routed byNodeXcalltoapi::pipelines::for_app, which judges the link (linked_app) and shares the start (start_launch) with the route. - Start and cancel travel to the leader as the host commands
__pipeline_startand__pipeline_cancel; reads use the reserved view__pipeline_run(PIPELINE_VIEW). - Retry (
api/pipelines.rs::retry) refuses a running run (STILL_RUNNING), checkslimitswithcheck_limitsand starts through the samestart_launchas a start.retry_ofand per-steplimits(calimero_pipeline::Limits) are applied inbuild_stepwithLimits::overridden_by, then clamped to the caps; apply refuses limits for a step the run lacks. - Validate (any signed-in account;
Node::validate_pipeline) checks against theEnvinstall builds (packages/pipelines.rs::env_for,resolve_modules,pool_ceilings). A release the caller does not see (sees_release) is404, andpackageorversionalone is400 BAD_RELEASE. - Estimate uses the start’s gate (
may_run) and answerscalimero_pipeline::estimate; bothinputsandcounts, or an undeclared input, is400 BAD_INPUTS. - Events (
api/pipeline_events.rs) arecalimero_client::pipeline_eventsbuilt byRunProgress::from_viewfrom__pipeline_runwithfiles: false. They poll everyPIPELINE_EVENTS_POLLand cap atMAX_RUN_SUBSCRIBERS_PER_APP(Node::pipeline_subscribers) andPIPELINE_EVENTS_MAX_SECS, with a keep-alive every 15 s. Access is judged when the stream opens; a503view is retried on the next poll, and any other error ends the stream.
Receipts
Section titled “Receipts”- A linked run’s final writes a
StepRunProof(component/proofs.rs,rows::CPROOFby step run id); a leader-ended run’s proof has no report fields. - Proofs go with the pipeline run’s record (
drop_step_proofs), so they outlive theRunRecords. - A cached run has no proof; its item row keeps its cache key.
PipelineRun::input_filesrecords each input’s size and hash at start.api/pipeline_receipt.rsreads both through__pipeline_runwithreceipt: trueand answers acalimero_client::receipt::PipelineReceiptsigned byNode::sign_pipeline_receiptoverreceipt_message.?version=2(ReceiptQuery, else400 BAD_VERSION) adds each proof’sJobEvidence(rows::CREPORT, kept apart so the proof row keeps its old shape) andjobAttestations.computeAttemptcarriesAttemptEntry::job_attestationonly for a pipeline’s run, only whileNode::replicas_take_logs, and only while the run keeps none for that job key.- A linked final writes that attestation once per pipeline run and job key (
rows::CJOB,<pipeline run>/<job key>). - The view adds evidence only when asked (
evidence: true), so an API node on the previous release still reads the answer. - The client checks it with
calimero_client::receipt::verify_job_reportsandClient::verify_receipt.
Cost cap
Section titled “Cost cap”PipelineRun::cost is a CostCap { maxCost, priceVersion, table, worstCase }, copied from sys_fresh’s price table by the start route.
PipelineRun::committed_cost sums each step’s StepState::cost (priced_cost of finished runs, added in settle_step_run) and, for a running step, its active runs times StepState::run_cost.
plan cuts each wave with Budget::afford and adds Failed{COST_CAP} for the step in the same round when the cap kept runs out.
Apply refuses a Start or More whose worst case would pass the cap, and takes Failed{COST_CAP} on a running step as StepState::capped.
Step cache
Section titled “Step cache”Code: component/step_cache.rs.
rows::CCACHEholdsCacheEntry { outputs, result, ts_ms, source_run }by key; the head’sstep_cachekeeps keys oldest first.cache_keyis the SHA-256 of the JCS of compute bundle, method, args hash and each input’s plaintext SHA-256 in order.build_stepputs it inStepRun::cache_key(none forcache: falseor an input of unknown content),RunRecord::cache_keycarries it, and apply never recomputes it.- A linked run that ends done writes or refreshes its entry and pins its outputs; a result past
MAX_STEP_RESULT_BYTESis not cached. planputs hits (CacheView::hit) inStart/Morecached: [{ index, key }]; hits cost no room, and a wave ends at the first miss past its size.- Apply takes hits as finished runs in index order; a hit whose entry or outputs are gone ends the wave there (
CACHE_GONEif first). expire_step_cachedrops entries pastMAX_CACHE_ENTRIESorCACHE_TTL_MS, at mostCACHE_EXPIRY_STEPper entry; a hit moves its entry last.StepState::is_cachedandcached_itemsfeedcachedandcachedItems; a start answers503 UNAVAILABLEwhen the leader does not answer.