Skip to main content

Module foreign

Module foreign 

Source
Expand description

Cross-mesh resolution (SPEC 9.6, 9.7), minimal form: names under hosts this mesh does not own.

§How the engine sees foreign names

The engine reads only its store, and the store holds only what verified on the way in. So foreign records are imported into the store before the engine reads them, through a read-through layer around every runtime (CrossMesh): when a function reads a name under a host this mesh does not own, the layer first

  1. resolves that host (its key document and its mesh document, resolve_mesh, cached),
  2. brings the name’s bindings up to date from the host’s bindings resource (9.7): the binding answering now and, walking back by since, every earlier one the store lacks, each with its descriptor (fetched by hash, checked by put_descriptor), appended with bind_name in order;
  3. for a stored function, brings the cell’s versions up to date: from the host’s versions endpoint (9.8) when its mesh document lists one, every version the store lacks, each receipt fetched by hash and checked; otherwise the host’s envelope for the cell now, then, walking back (as of just before each receipt’s start), every earlier version the store lacks. Everything is fetched and checked by the store-less crate::client::Client (envelopes against the request, signatures against the signer’s key document, fetched from the signer’s own host); each receipt is then stored with put_receipt (which verifies it again against the key document stored for its signer) and put_version, oldest first.

A foreign function that is not stored (a formula on the other mesh) is evaluated by this mesh from its descriptor and its inputs, which are imported the same way: its value is recomputed, never taken on trust.

Versions and bindings are append-only in the store, in transaction order; importing the full history back to the first version (or binding) the store lacks keeps them so, so the store answers every asof as the other mesh would. A history that does not extend what the store holds (the other mesh rewrote it) is refused with E_INPUT_UNAVAILABLE.

Answers for asofs at or before the last confirmation never change; answers about “now” are confirmed again after Ttls::current (bindings after Ttls::binding). The memo is kept honest by Foreign::take_invalidated: every cell whose versions grew is reported to the engine (stored_version_added) after the request.

§Caches and lifetimes

WhatWhereLifetime
key documentsmemory (KeyCache) and the store’s namespace record300 s; a key id the cached document lacks refetches it at once (at most every 10 s)
mesh documentsmemory300 s
a name’s bindingsthe storeconfirmed again after 60 s
a cell’s versionsthe storeconfirmed again after 60 s, for requests about now
descriptors, receiptsthe storeforever: content-addressed

Not in 0.1.x: slices over foreign functions (E_INPUT_UNAVAILABLE: the store would hold only the members read so far), cells of a foreign name’s earlier bindings that were never imported while current, and pending answers from the other mesh (E_INPUT_UNAVAILABLE).

Structs§

CrossMesh
A runtime with cross-mesh reads in front of it (see the module documentation).
Foreign
The cross-mesh resolver of a mesh: the Client’s fetches and checks, then the import into the store.
KeyCache
Key documents this mesh has fetched or been given, by host: each the result of interpreting a retrieval (SPEC 9.3), a failure included.

Functions§

host_of
The host of a function name or namespace: its first segment.
pct
Percent-encodes a value as SPEC 5.1 says (literal characters as themselves).

Type Aliases§

ForeignError
A failure of cross-mesh resolution: the client’s error (its code is the error envelope’s).