Expand description
Publishing stored cells as the mesh (datumesh-mesh publish-stored): a JSON lines file of
stored functions and their cells, signed with the mesh’s key, put in the store.
Each line is one of:
- a descriptor (since 0.3.1, CONTRACT-1.7a H1):
{"descriptor": <function descriptor>}: the descriptor is put withput_descriptorand binds nothing. Only a stored function is accepted (code.lang=stored,code.body="",inputs=[]); any other is refused at its line. A class later in the file (or in a later run) may name its hash as a method; - a function:
{"function": "<ns>/<name>", "signature": {...}, "bound": "<instant>"}: the descriptor{"code": {"body": "", "lang": "stored"}, "inputs": [], "signature": ...}is put and the name bound to it frombound(unless it already is); - a formula function:
{"formula": "<ns>/<name>", "source": "<formula>", "signature": {...}, "bound": "<instant>"}: defined withdatumesh_formula::definition::define_function(its callees as bound atbound) and published (put_descriptor,bind_namefrombound) unless the name is already bound to that function; its cells are evaluated on demand by the mesh; - a class (since 0.2.2, spec-0.5.0, 16.2):
{"class": "<ns>/<name>", "descriptor": {...as written...}, "bound": "<instant>"}: defined with the formula crate’sdefine_class(core’s rules: the class is under one of the mesh’s own namespaces, elseE_CLASS_OWNER; the method functions are those bound as ofbound),put_class, andbind_classfromboundunless the name is already bound to that class hash. Method functions come first in the file (or in an earlier one),boundlater than theirs. A line with bothclassanddescriptoris a class line; - a cell:
{"cell": {"fn": "<ns>/<name>", "args": {<name>: <typed scalar>}}, "value": <typed scalar> or {"blob": "<file>", "media_type": "<type>"}, "tx"?, "asof"?, "issued"?, "licence", "summary"}: a blob’s file (relative to the JSON lines file) is put withput_bloband the value is<sha256>:<length>:<media type>; the receipt is signed with the mesh’s key (computed_bythe mesh host,publisherthe cell’s namespace,validits valid-time arguments;issueddefaults to the later ofasofand the key’s start) and stored withput_receiptandput_version.txandasofdefault to the run’s clock now (since 0.3.1, H4), each independently. Asourceobject (since 0.4.0, spec-0.6.0 C2:name,url,retrieved, and optionallysha256andtakeover, nothing else) marks the value as relayed: the receipt signs it, and its trust isrelayed; its rules are the receipt’s (retrievedno later thanissued, a publisher that does not relay itself,https://URLs), refused at the line.
The function of a cell is the one its name is bound to as of the cell’s tx. Re-running a
file changes nothing (a cell line without tx whose latest version states the same thing is
skipped, since 0.3.1): descriptors and blobs are content-addressed, signing is deterministic
(the same receipt, the same hash), and a version already there is skipped. The key is never
logged.
Rule A (since 0.3.0, CONTRACT-1.8b H1): no binding starts earlier than the mesh clock. The
start of a binding (a name’s, a class’s, or a class method’s N/m) is its bound, or the
clock’s now when bound is left out, and a start earlier than now is refused with
PublishErrorKind::StartBeforeNow. A --backfill run (PublishOptions::backfill) lifts
the start check, and is refused (PublishErrorKind::Backfill) when a name it would bind has
a binding, or when a namespace of such a name has any binding (store 0.4.2’s
has_bindings_under). A run that writes appends one line to the log: {"at": …, "namespaces": […], "starts": […]}, a JCS object.
No partial writes (since 0.3.1, CONTRACT-1.7a H2): the file is read in two passes. The first
plans every write the second one makes, and checks each as the store will: a bind is refused
when its start is not later than the latest binding of its name (the store’s, or one planned
earlier in the file, W1b), when the name is of the other kind (a class or a function), or when
its namespace is suspended; a cell’s function must be bound as of its tx (counting the
earlier binds of the file), its blob must be readable, tx <= asof <= issued, and a version
at or after its tx must be this receipt. Receipts are signed in the first pass (signing is
deterministic), so their hashes are known. A file that the first pass refuses writes nothing.
Structs§
- Publish
Error - Why a run stopped: the line, what was wrong, and its typed kind.
- Publish
Options - How a run reads the clock and whether it backfills (CONTRACT-1.8b H1).
- Published
- What a run put.
Enums§
- Publish
Error Kind - Why a line (or the file, at line 0) was refused.
Functions§
- publish_
stored - Publishes the file at
pathintostoreas the meshhostsigning withkey(see the module documentation). The mesh’s own namespaces arehostalone: seepublish_stored_in. The clock is the system clock, and there is no backfill. The cells are written on one lane; seepublish_stored_lanesfor the parallel lanes. - publish_
stored_ checked - As
publish_stored_with, with the public rule (Build 2 Part 3, D8: datumesh-http always enforces it;publish-storedcalls this). A file that defines a computed function (formula) is refused unless the tests of the function (the file’s, and those already held for the same function hash) exercise every derived edge case and every branch, and all of the file’s tests pass:PublishErrorKind::TestsMissingat the function’s line,PublishErrorKind::TestsFailingat the failing test’s line. Stored functions are exempt. Nothing is written when refused. - publish_
stored_ checked_ lanes - As
publish_stored_lanes, with the public rule (seepublish_stored_checked): the path ofdatumesh-mesh publish-stored(D8). - publish_
stored_ in - As
publish_stored, for a mesh that owns the namespaces (hosts)owned(Config::namespaces): a class line is accepted for a class under one of them, and refused withE_CLASS_OWNER(in thePublishError::detail) under any other. Since 0.2.2. The system clock, and no backfill. - publish_
stored_ lanes - As
publish_stored_with, with the cells written on parallel lanes (CONTRACT-perf H5, H6):DATUMESH_PUBLISH_LANES(a positive integer) if set, elsemin(4, available_parallelism()). The same receipts, versions and rows as one lane; only the order of the inserts across different cells differs. The variable is read once per run, before the file is read. - publish_
stored_ with - As
publish_stored_in, with the run’s clock and backfill (CONTRACT-1.8b H1, rule A). The cells are written in file order on one lane, as in 0.3.2 (CONTRACT-perf H2). - receipt_
json - The receipt JSON of a signed receipt: its payload’s members and
sig.