Skip to content

Blobs

A blob is immutable, content-addressed bytes kept outside every log: an attachment, an image, a model. Log entries are capped at 1 MiB and should stay small, so anything large goes to the blob store and the log carries only its id. The same store holds bundles and uploaded .mpk releases. Apps are calimero:app components, and the node keeps their blobs as described here.

Each node keeps blobs in its own RocksDB blobs column, sealed under the cluster’s storage key like everything else (Storage schema). A blob’s id is hex(SHA-256(bytes)); the API also accepts the base58 form.

  • Writes reach a majority. Storing a blob writes it locally and pushes it to every other node (internal/blob); the write succeeds once a majority of the cluster’s nodes hold it.
  • A node that missed one fetches it. A node asked for a blob it does not hold — it was down when the blob was stored — fetches it from a peer (internal/blob/get), checks the hash, and keeps it.

A blob larger than MAX_BLOB_BYTES (47 MiB, what still reaches every node inside the sealed envelope) is refused 413 TOO_LARGE up front; one past the sealed cap (64 MiB) is refused by the envelope. Larger content is a sealed file, which is stored in segments.

Bytes in the store belong to no one. The node records each of an app’s blobs (size, the uploader’s Content-Type, a reference count) as host-owned hidden rows of the app’s group (rows::CBLOB), outside the keyspace the app writes. The records replicate with the app and are ordered with its calls.

  • Typed references. State refers to a blob through a BlobRef, which the SDK stores as CBOR tag 51,739 (0xCA1B) around the blob’s 32-byte SHA-256 and sends in JSON as the 64-hex-digit id. A run that stores a reference to a blob the app does not hold traps HostDenied.
  • Host-tracked retention. Every replica counts references from the diffs it applies and the values they replace. A blob nothing refers to is held for one hour after its upload or after its last reference went (BLOB_IDLE_MS), so a client uploads first and attaches it with a later call. After that the app forgets it, judged against entry timestamps so every replica forgets it in the same entry; the leader then collects the bytes (below) and logs componentBlobsCollected.
  • No bytes in runs. The WIT blobs interface has info (size, SHA-256, content type; none for a blob the app does not hold) and grant(id, ttl). Calls, views, timers, init and xcall deliveries may use them; actions may not. Content a run must read is a sealed file, below.

POST /apps/{app}/blobs (raw bytes) by a signed-in caller who reaches the app and may write it — not a read-only API key and not a read-only team member. The blob is stored with the request’s Content-Type (printable ASCII, at most 127 bytes; application/octet-stream when none), which downloads answer with. The node pins the id on the app’s leader, stores the bytes on a majority, then commits componentBlob { id, size, mime, tsMs } to the app’s log. Any sealed parameter is refused 400 USE_FILES_API: sealed files have their own routes. An app holds at most 100,000 blobs and 10 GiB of plain blobs (429 QUOTA_EXCEEDED past either).

From cluster version 1.0.0-rc.39 an upload is charged to the app’s organization like a file: its size counts against maxFileBytesPerOrg, and GET /auth/usage shows it in fileBytes. The charge is taken before any bytes are stored, so an upload past the quota is 429 QUOTA_EXCEEDED and stores nothing. The entry carries metered: true, and the blob’s record keeps the charge: an upload of bytes the app already holds charged is given back at once, and the owner’s delete or the idle time gives the record’s charge back when the leader collects the bytes. Below that version uploads are not charged, and a blob uploaded then stays uncharged.

  • GET /apps/{app}/blobs/{id} downloads a blob the app holds, by anyone who reaches the app, with its recorded content type, except a published compute output (a grant is needed). A blob the app does not hold is 404, whether or not the bytes exist. A download asks the app’s leader whether the app still holds it; with no leader answering, 503.
  • Grants. blobs.grant(id, ttl) returns <expiresMs>.<mac>, an HMAC under a key derived from the cluster key over the app, the blob and the expiry (the run’s clock plus 1 s to 24 h). GET /apps/{app}/blobs/{id}?grant=<grant> downloads with no session on any node until it expires; a bad or expired grant answers 404.
  • GET /apps/{app}/blobs and /blobs/{id}/info list the app’s plain blobs and their sizes (files are listed only to those who may handle them, below).
  • Inside the sealed channel, a download is sealed frame by frame like any response.

DELETE /apps/{app}/blobs/{id}, by the app’s owner (while a member of its organization) or an organization admin, commits componentBlobForget: the app no longer has the blob, and the API answers 404 for it. Then the node collects the bytes (Node::collect_blob): it deletes them on every node unless

  • another app still holds the same content — asked of each app’s leader, because a lagging replica could miss a record committed a moment ago, and an app whose leader does not answer counts as holding it;
  • an upload of the same id is between storing its bytes and committing its record: every path that stores bytes first pins the id on the app’s leader until its record commits or fails (a peer’s pin is a lease that expires after 60 s), and every deletion asks whether the id is held or pinned; or
  • the content is a bundle or a release .mpk.

A leader change between a pin and its commit is not covered: the pin stays on the old leader.

A component app’s runs can also make sealed files: a file is written in a call, tick or init, and its contents are read only inside a compute run. A file is a sealed blob. It shares the blobs’ ids and the BlobRef type, and blobs.info answers for it with an empty content type. It cannot be downloaded or granted, and no blob upload can claim its id. A call, timer, init or xcall delivery may create a file, any run may ask for a file’s size and hash (files.info), and files.open is refused everywhere but a compute run. So 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. The node seals a file in the TD as 64 KiB AES-256-GCM chunks under a random data key, and wraps that key under a key derived from the cluster key for this app. The blob id is the SHA-256 of the ciphertext, so a replica can check what a peer sends. The app’s blob record for the file holds the plaintext size and SHA-256 and the wrapped key, in the hidden rows the guest cannot reach. The log entry carries these marks and never the ciphertext.

A file of a pipeline run’s inputs or intermediate steps is wrapped under a key of that run instead, as Run keys says.

A client uploads a file with POST /apps/{app}/files (the raw bytes, up to one part of 16 MiB) or, for a larger file, through an upload session. The answer is { id, blobId, size, sha256, index } for the plaintext. A node that does not lead the app passes the request to the leader. The leader seals the file as a run’s files are sealed, stores it on a majority of the app’s voters, and then commits the blob record as a command of the node’s own, which no /intents call can name. Only the app’s owner and the members (not guests) of its organization may upload and list files, even where the app is public.

An upload session lives in the leader’s memory, belongs to the account that began it, and takes the file one part per segment. POST /apps/{app}/files/uploads { size } answers { uploadId, partBytes, parts, expiresAt } (expiresAt in Unix seconds). PUT /apps/{app}/files/uploads/{uploadId}/parts/{k} takes part k as raw bytes, exactly partBytes but for the last, and answers { next } once the part is sealed and stored; its segment is pushed to a majority of the voters in the background, at most four segments ahead (past that the answer waits for a slot, up to 20 seconds, then is 503 FILES_UNAVAILABLE and the resent part replays its answer). Parts go in order: a part ahead of next is 409 PART_OUT_OF_ORDER naming next, a resent part answers its first answer, and a resent part with other bytes is 409 PART_CONFLICT. GET .../uploads/{uploadId} answers { uploadId, size, partBytes, parts, next, expiresAt }, for a client that resumes. POST .../uploads/{uploadId}/complete waits up to 20 seconds for every segment to reach a majority (else 503 FILES_UNAVAILABLE, and a retry resumes), charges the quota, commits the mark and answers like the single request; before every part is in it is 409 UPLOAD_INCOMPLETE naming next. It commits under the key node:upload-{uploadId}, so a retried complete answers the same file, even after a leader change. DELETE .../uploads/{uploadId} aborts the session and deletes what it stored. A session that is unknown, belongs to another account, has run out (no part for 15 minutes, or six hours old) or whose leader changed answers 404 UPLOAD_UNKNOWN, and the client begins again. An app holds at most 4 sessions, a node 32, and a leader’s open sessions declare at most 16 GiB together (429 TOO_MANY_UPLOADS). Nothing is charged before complete; a complete past the quota is 429 QUOTA_EXCEEDED and deletes the bytes. GET /apps/{app}/files lists the files ({ files: [{ id, blobId, size, sha256 }] }) and GET /apps/{app}/files/{id} answers one, to the app’s owner and its organization’s members; /apps/{app}/blobs lists plain blobs only and answers 409 NOT_SUPPORTED for a file id. The reason is that a file’s SHA-256 is the plaintext’s, and would let anyone confirm a guessed document. GET /apps/{app}/blobs lists the files after the blobs, and GET /apps/{app}/blobs/{id}/info answers a file’s size and SHA-256, to those people only.

The committed entry also records the account that uploaded the file, taken from the authenticated session or API key of the upload, never from a field of the request; a node that forwards the upload to the leader names it, and the leader refuses a name that is no account id. The app reads it with runs.uploader (files::uploader in the Rust SDK), which answers none for a file a call or a run made and for an unknown id. For a file a pipeline key uploaded it answers the account and the key’s id, account#keyId, so that file is not the account’s own. Every upload is sealed under a key of its own, so the same bytes uploaded twice are two files with two ids and two uploaders; the entry of an id the app already holds is refused, so a later upload never replaces the first uploader. A compute run does not see it. Everyone else gets the list without files, and 404 for a file’s info, as for an id the app does not hold. Neither answer ever carries the key or any content. An uploaded file is held like any file: for an hour unless the app stores a BlobRef to it.

There is no delete. files.finish returns the blob id, and the app keeps the file by storing it as a BlobRef, exactly as for an uploaded blob. The entry that makes the file also applies the state write that stores the reference, so the file is never collectable in between. A file nothing refers to is held for an hour from its entry, and one whose last reference went is forgotten the same way a blob is. Every replica forgets the record in the same entry, and the bytes are then collected from the nodes that hold them. A run may store a BlobRef to a file the app holds or one it finished earlier in the same run; a file exists only once that run’s entry commits, and a writer dropped unfinished leaves nothing.

A run holds at most 16 readers and writers at once, writes at most 2 GiB to one file and 64 MiB in all (a compute run 2 GiB in all), finishes at most 1,000 new files, and reads at most 1 MiB per read; an empty read is the end of the file. Every refusal that is not a policy violation is a fixed soft error string: no such file, files are not enabled, too many open files, file too large, run wrote too much, too many new files, file already finished or file write failed. A write refused for a size cap, or failed in the node, leaves the writer failed: it answers file write failed from then on, so finish never seals a truncated file. An unknown reader or writer handle traps HostDenied.

The ciphertext lives on the app’s replicas, not on every node. Before the leader proposes the entry, the new files are stored on it and pushed to the app’s other replicas. The call proceeds only once a majority of the app’s voters hold every new file; otherwise it fails with a retryable 503, nothing is logged, and its idempotency key is not spent. A node holds at most 256 MiB of new files’ ciphertext across all runs until their entries are proposed; a call that cannot get its share fails with a retryable 503, is not logged, and does not spend its idempotency key. A file is stored as segments of 256 sealed chunks (16 MiB of plaintext), each under its own hash, and the file’s id is the hash of that list; a replica that misses a segment fetches it from the other replicas when a run opens the file. If no replica can serve it, a call, tick or init is aborted with a retryable 503 and not logged, while a view is told the bytes are not available. A run reads a file by decrypting it as it goes, and the end of the stream checks the plaintext size and SHA-256 against the mark. A file that was altered or cut short fails the run with a trap, so no app can ignore it. Each file has its own random key, so no other app can mark the same ciphertext.

The plaintext bytes of an organization’s files count against maxFileBytesPerOrg (default 50 GB). A file counts from the moment it is charged until retention collects it. The charge is taken before any bytes move, so an upload or a call that would pass the quota fails with 429 QUOTA_EXCEEDED, nothing is logged and the stored bytes are removed. When the leader collects the bytes of files the app forgot, the same entry that logs the collection tells the node how many plaintext bytes it released. Deleting an app or an organization frees its files in the same system command. A node that stops hosting a deleted app drops the bytes of its files. The count and the app’s log are not one atomic step. When a record’s commit fails, the leader checks whether it was logged and settles the count either way. A crash between the two can still leave an over-count. Below cluster version 1.0.0-rc.32, transferring an app from a personal organization to someone outside it, which moved it to their personal organization, was refused if its files would pass that organization’s quota; from that version an app is transferred only within its organization. GET /auth/usage shows an account’s file bytes per payer.

A sealed file never leaves the cluster, with one exception: an app’s logged write can publish the output of one of its finished compute runs with runs.publish (compute::publish in the Rust SDK). The node answers a plain blob of the app, named by the SHA-256 of the plaintext. From then on blobs.info answers it, and blobs.grant gives a time-limited link, for example to an outside auditor. Until an app publishes, the same download answers 409.

A published blob downloads only through a grant, for every caller including the owner: the plain GET /apps/{app}/blobs/{id} answers 404. blobs.grant of it works only in logged writes (calls, timers, init, xcall deliveries), never in a view, so the log records who shared it. The owner or an org admin can revoke every grant made so far with POST /apps/{app}/blobs/{id}/revoke, after which a new grant holds. The blob record counts the revokes and a grant names the count it was made under, so every replica refuses a revoked grant, and a new leader does too. The app also keeps a floor above the count of every published blob it forgot, and a blob made again starts there, so a revoked grant stays refused when the same output is published again. DELETE /apps/{app}/blobs/{id} takes a published blob down: the app forgets it, its bytes are collected and its charge is released.

The platform enforces one rule: the id must be an output of a done run of this app. An uploaded file, a file a call made, another app’s output, a failed or cancelled run’s output and an unknown id answer the soft error NOT_A_RUN_OUTPUT. Each app decides who may publish, in the method that calls it. The rule is in the log, not in the leader. The leader decrypts the output, stores the plaintext on a majority of the app’s voters as it does a new file, and only then proposes the entry. The entry carries the source, the plain blob’s id and its size, never the bytes. Every replica applies the entry only if the source is a file the app’s records mark as a done run’s output, and the id and size are that file’s plaintext hash and size. Otherwise it answers NOT_A_RUN_OUTPUT and changes nothing, so a leader cannot publish anything else.

The plaintext counts against the organization’s file quota from the entry until retention collects it. Retention is a blob’s: the plain blob is held while a BlobRef in state names it, and for an hour after. Publishing an output the app already holds as a plain blob stores and charges nothing again. A run publishes at most 16 outputs, each at most 47 MiB (the plain blob it becomes; a larger output answers file too large) and 64 MiB together. Past that publish answers the soft error run published too much and records nothing.

Limit Value
A plain blob (MAX_BLOB_BYTES) 47 MiB (413 TOO_LARGE)
A sealed request (and so one upload request) 64 MiB
Blobs one app holds (MAX_COMPONENT_BLOBS) 100,000 (429 QUOTA_EXCEEDED past it)
A blob’s content type 127 bytes, printable ASCII
A blob held with no reference (BLOB_IDLE_MS) 1 hour
A sealed file held with no reference 1 hour
Plain blob bytes one app holds (MAX_APP_BLOB_BYTES) 10 GiB (429 QUOTA_EXCEEDED past it)
Plaintext bytes of an organization’s files and uploaded blobs maxFileBytesPerOrg, 50 GB (429 QUOTA_EXCEEDED past it)
New-file ciphertext all runs of a node hold before their entries 256 MiB
A grant 1 s to 24 h

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.

POST /bundles stores the WASM through internal/blob (majority required), and the system log records only {hash, size}. Log entries are capped at calimero_log::MAX_ENTRY_BYTES (1 MiB) because openraft gives each append one heartbeat. A call whose arguments pass MAX_ARGS_BYTES (512 KiB) is refused where it arrives (413 ARGS_TOO_LARGE), never proposed.

  • A download asks the leader with blob_held_strong through Node::ask_leader, which retries through an election for up to LEADER_ANSWER_WAIT (5 s) before 503.
  • Node::collect_blob deletes bytes on every node through internal/blob/delete.
  • Every deletion of bytes asks Node::blob_in_use: held or pinned, as each app’s leader answers, unknown counting as in use.
  • Pins live in node/blob_guards.rs; logged_entry pins on the leader for a publish, a call’s files and a run’s outputs.
  • A plain upload pins through Node::pin_on_leader: locally on the leader, else through internal/blob/pin, a lease of LEASE_TTL (60 s).
  • A put of an id (BlobGuards::put) also stops a deletion of that id caught between its checks and its delete, here and on every peer.
  • The client reports both the node’s 413 and the envelope’s refusal as TOO_LARGE.

Code: component/blobs.rs.

  • BlobRecord { size, mime, refs, idleSinceMs } lives in rows::CBLOB, in memory as BlobTable.
  • Upload and the owner’s delete commit componentBlob and componentBlobForget through CallRequest::host (Node::component_blob_cmd).
  • The mime is at most MAX_BLOB_MIME_BYTES, and an app holds at most MAX_COMPONENT_BLOBS and MAX_APP_BLOB_BYTES of plain blobs (refuse_full_app, in api/files.rs).
  • From Feature::MeteredBlobs (Node::require_features), blob_upload charges the size with ChargeFileBytes before storing, and componentBlob { metered } sets BlobRecord::metered. BlobTable::upload answers whether the record took the charge (not when it already held one, metered or published); the API refunds a charge the entry did not take. forget_blob and expire queue a metered record’s size in collect_files, released by BlobsCollected like a file’s.
  • The BlobRef CBOR tag is calimero_app_host::BLOB_REF_TAG; apply counts references with ref_deltas.
  • Idle blobs are forgotten by expiry_now at most BLOB_EXPIRY_STEP per entry and queued in ComponentHead::collect; the leader’s timer poll collects them, for a compute-only app too, and logs a componentSweep when a hold is due so an app with no other entries still expires its files (file retention).
  • Runs see the records through RunBlobs (HostCore::with_blobs); grants are keyed with grant_key(K_c).

Code: files.rs (re-exporting calimero_sealed::file), files/wrap.rs.

Piece Format
Chunk AES-256-GCM STREAM (FileSealer, FileOpener); nonce = 4 zero bytes + big-endian chunk index; AAD = calimero.file.v1 + a last-chunk flag byte
Segment SEGMENT_CHUNKS (256) whole chunks, SEGMENT_BYTES (16,781,312) stored bytes, the last one shorter (SegmentWriter, SegmentReader)
File id file_id: SHA-256 of "calimero.file.segments.v1\0" || u32 count || h0 || ... || hn-1
Wrapped data key wrap_key: salt || nonce || AES-256-GCM under a subkey of backup::file_key, the app id as AAD
  • FileOpener::finish_expecting checks the plaintext size and SHA-256.
  • FileMark and FileSeal list the segments (segments, required, at least one); FileMark::segment_hashes is the one well-formedness check.
  • wrap_for_job re-wraps to a job node: ephemeral X25519, then HKDF over both public keys, the kind (file key or noise seed), the length-prefixed app and run ids, attempt and index.
  • The job node opens it through SealedTransport::derive, which never returns the raw DH output (calimero_sealed::derive_shared).
  • noise_seed and run_token derive a run’s seed and capability from the file key.

Code: component/run_keys.rs, files::run_file_key, backup::write.

A pipeline run started once the logged cluster version brings runScopedFiles has a run key: 32 random bytes the leader draws and logs in the run’s start. Apply stores them as a hidden row of the app’s state (rows::CRUNKEY), so every replica holds them and a new replica receives them with the snapshot. The data key of a run’s inputs and intermediate outputs is wrapped under a subkey of the run key bound to the app and the run (wrap_key with files::run_file_key where it takes the app’s file key), and the file’s blob record names the run in scope. The final outputs, the steps the pipeline’s outputs names, are wrapped under the app’s file key as any other file.

No backup, recovery file or restore point carries a run key. backup::write writes an app’s snapshot again without the CRUNKEY rows (calimero_log::filter_snapshot_file, under the snapshot id <id>-k, because frames are bound to the id), and the recovery disk skips them and the segments of a scoped file, which no key it carries opens. So a backup of an app holds the wrapped data key of every such file but never what opens it.

A run holds its own key and the key of every input it was handed (a retry holds the key of the run it repeats); a key is deleted when the last run holding it releases its inputs or its record is dropped. Every copy of the files wrapped under it, in any backup, is then unreadable. After a full-cluster restore the inputs and intermediates of every run are lost by design: a start or retry that names such an input answers 410 INPUT_EXPIRED, a run that was running when the backup was taken ends refused at the step that needs them, and a read of one answers the file is lost. The key itself stays in the live nodes’ Raft log (the start entry carries it) and in their current snapshot until the log is compacted, and nowhere else: a backup, a restore point and a recovery file are written from the snapshot without it. A backup or restore point taken before a run’s start still holds an upload as the app’s file key wrapped it, so restoring it makes that input readable again: the inputs of a run started through the upload-then-start path are protected only from the start on. A call that stores a reference to a file under a run key is refused (a value refers to a file that goes with its run), because the file goes when the key does. The final outputs are restored, and a final output the owner deleted stays recoverable from the backups that held it until those backups expire.

An input uploaded before its run starts is wrapped under the app’s file key until the run’s start moves it, so a backup taken in between holds a copy that opens. At the start the leader wraps each input nothing refers to yet under the new key, and apply moves it only if that still holds (BlobTable::rescope): a file the app also refers to, or a final output another run holds, keeps the app’s file key.

Code: api/exports.rs.

  • Both file routes take files_gate (api::may_handle_files on a fresh system read) and judge the file on the leader (Node::file_record_strong, internal/blob/held with record), else 404.
  • POST /apps/{app}/pipeline-runs/{run}/export takes the run read (gate with *) and may_handle_files, reads the ended run’s record from the leader, and judges each output as a file export does, RUN_EXPORT_READS at once.
  • A segment is read from this node’s store or a replica (segment_from); one past the last is 404 NO_SUCH_SEGMENT.
  • wrapped is nonce || AES-256-GCM of the data key under HKDF(X25519(ephemeral secret, recipient)), salt calimero.export-wrap.v1. The HKDF info is ephemeral public || recipient public || u32 length-prefixed app id || u32 length-prefixed hex file id.
  • calimero_sealed::wrap::wrap_export refuses a low-order key, and a recipient that is not 64 hex is 400 BAD_RECIPIENT too.
  • calimero_client::Client::export_file_to opens it with unwrap_export and checks the segment list, each segment and the plaintext with finish_expecting.
  • ExportLimits is an in-memory token bucket of MAX_EXPORTS_PER_MINUTE over at most MAX_TRACKED_ACCOUNTS accounts (429 TOO_MANY_EXPORTS). A file export and a run export each take one token; segments take none.

Code: node/component/files.rs.

  • A run’s files provider (NodeFiles) is built per run from the app id, backup::file_key and the blob records; it touches keys, budgets and bytes only when the run touches a file.
  • A file’s record is BlobRecord::file, a FileSeal in rows::CBLOB, so snapshots and restore carry it.
  • Each segment is stored in the blobs column under seg.<hex hash>, with an empty index row seg/<hash> in meta in the same batch (Engine::put_segment, list_segments); there is no whole-file row.
  • Segments travel raw: PUT /internal/segment/{hash} (checked: the body’s SHA-256, at most SEGMENT_BYTES) and GET /internal/segment/{hash}.
  • A fetch is served only to a node approved for an app hosted here whose files list the hash (caller_may_hold), else 404.
  • A job transfer still sends the joined segments in one request.
  • Outcome::files carries marks only; apply records them as unreferenced blobs before the diff, for status Ok only.
  • BlobTable::upload and forget_blob refuse a file id.

No blob path (collect_blob, the blob routes) deletes a seg. row, and there is no peer delete. Collecting a file’s id releases its quota only. Node::sweep_segments (node/segments.rs, every SWEEP_EVERY, 10 min) deletes a segment no hosted app lists (BlobTable::holds_segment) and nothing pins (Node::pin_segments), when:

  • this node saw it listed at an earlier sweep, so its file was forgotten; or
  • it has been unlisted for SEGMENT_GRACE (24 h) since first seen.

First-seen times are in memory, so a restart restarts the grace. There is no caught-up check, so segments handed to a joining node before it applies survive the grace. A node that stops hosting an app deleted everywhere drops its segments at once (Node::drop_deleted_files); plain blobs stay.

  1. A run’s writers hold only their partial segment in memory, against MAX_PENDING_FILE_BYTES (PendingBytes). A write the budget cannot hold aborts the run as FileError::Unavailable.
  2. Node::charge_files charges the new files within CHARGE_WAIT, from the run’s thread. A refused charge answers 429 and logs nothing; one landing after the wait is refunded.
  3. Node::persist_files pushes the segments to the group’s voters and learners (its Raft membership), MAX_PUSHING_BLOBS at a time, under one deadline below FORWARD_TIMEOUT and MAX_PUSH_BYTES. It runs only after the entry bytes are built, so an entry replaced as too large stores nothing. It needs a majority of voters, this node counted; a voter with no address still counts.
  4. Without a majority the call is 503 FILES_UNAVAILABLE: the forward loops pass it on unretried, and the pushed bytes are removed.
  5. Node::discard undoes bytes and charge if the entry does not commit; NodeFiles::forget_made deletes segments no entry marks when the run ends.

A file that cannot be had aborts a logged run as 503 TIMEOUT (FileError::Unavailable) and ends a compute run Unavailable. Blocking on the runtime from a run needs a multi-thread runtime, else the run is refused.

  • open reads one segment at a time; a local segment is used only if its SHA-256 matches, else it is fetched from the other replicas (5 s).
  • Any opener failure is ReadError::Corrupt, which the host core makes a HostDenied trap.
  • Open readers hold OPEN_READER_BYTES against MAX_RUN_OPEN_BYTES per run and MAX_OPEN_FILE_BYTES per node; logged runs wait 1 s for it.
  • fetch_blob_from asks only the app’s other replicas, which serve a file they hold (holds_blob); bundles and other blobs still use every node.
  • Pushes skip members may_send refuses.
  • expire_blobs queues a forgotten file’s plaintext size in ComponentHead::collect_files beside its id in collect.
  • The leader’s componentBlobsCollected answers freed, and the node releases that many (collect_component_blobs), so a repeated entry releases nothing.
  • A queue past MAX_COLLECT_QUEUE drops its oldest ids with their sizes.
  • A snapshot without file-byte counts starts them at zero, and their release floors at zero.

hand_over_bytes hands the files over segment by segment with the bundle, and again after the voters change for files made during the move. The second hand-over is retried for 10 s and never abandons the move.

  • NodeFiles::publish answers only a file with FileSeal.output, which only apply_compute_final sets.
  • A run log of an earlier release is marked FileSeal.log instead (see Compute actions), so it is never published.
  • It proves the whole file and holds the plaintext against the pending budget (plaintext).
  • Outcome::published carries PublishedMark { source, id, size }.
  • run_with adds each new published plaintext to the run’s blobs, so logged_entry charges it (new_file_bytes) and persist_files pushes it.
  • apply_component_outcome checks every mark first (publishes_only_outputs, at most MAX_PUBLISHED_PER_RUN); one failing mark makes the entry a no-op.
  • Any no-op entry has its stored bytes discarded and its charge refunded (recorded_nothing).
  • BlobTable::add_published records the plain blob as BlobRecord::charged, application/octet-stream.
  • blob_download judges a published blob on the leader’s record (Node::blob_standing_strong).
  • BlobRecord::epoch counts revokes (ComponentCmd::BlobRevoke, __blob_revoke); a grant above zero carries its epoch (grant_token).
  • BlobTable::floor (the hidden rows::CBLOB row floor) rises above the epoch of any forgotten blob but a sealed file; add_published and upload start there.
  • load fails on an unreadable floor or record instead of defaulting, and revoking refuses at u32::MAX (no revocation left).
  • forget_blob queues a published blob’s bytes and charge in collect and collect_files.
  • A result method sees its outputs without the flag (blob_view_with_outputs), so a later call must publish them.
  • refuse_sealed_file answers 409 NOT_SUPPORTED on the blob routes, judged by the leader through file_held_strong.
  • /apps/{app}/storage counts files’ sealed bytes in blobBytes.

Code: node/component/uploads.rs.

  • PART_BYTES (16 MiB) is one part; Client::upload_file is the client side.
  • Access is api::files_gate; anyone else gets 403 on every /files route, and a part of the wrong length is 400 BAD_PART.
  • A session (Uploads, one Session each) holds the segment writer, segment and part hashes and what is on a majority.
  • UPLOAD_IDLE and UPLOAD_TTL bound it; Node::expire_uploads ends it on the timer poll or when this node stops leading.
  • SegmentWriter::write_more seals part k into segment k, and push_blobs pushes it in the background with backoff.
  • UPLOAD_WINDOW bounds segments not yet on a majority; past PART_PUSH_WAIT the answer is 503.
  • admit enforces the session limits and the payer’s quota at begin.
  • complete waits COMPLETE_WAIT, charges once (State::charged) and commits through commit_mark.
  • A retried complete replays from the leader’s record of the key (replayed, for the uploader only), even with no session left.
  • A recorded answer for another file under the same key wins, and the new file is undone.
  • When the commit’s fate is unknown (Upload::Unknown), the session keeps its bytes until it ends. Then a barrier decides: absent mark, refund and delete (Node::undo_unmarked).
  • Ending a session answers unknown at once, then stops its pushes and deletes its segments here (Node::end).
  • A follower forwards session requests one hop over internal/upload*, raw bodies, within PART_FORWARD_TIMEOUT.
  • The single request is a one-part session run through the same steps (Node::upload_file).
  • StorageStats::files carries each file’s id, size and SHA-256, and internal/storage sends it to a peer.
  • The uploader comes from the API’s principal (Principal::uploader: the account, or account#keyId for a pipeline key); internal/upload* refuse anything but printable ASCII of at most 128 bytes (valid_uploader).
  • BlobTable::add_uploaded stores it as FileSeal::uploader, and NodeFiles::uploader answers runs.uploader.
  • A failed commit is settled with a componentBarrier entry, then a read of the record: present succeeded, absent undone, no barrier possible kept.