Map: core / transport
What crosses a process or seat boundary, and how it is checked on arrival.
Three things cross: first-order values (FOValue) on every open protocol
position, a marshalled parent (Marshalled) when a helper shell starts, and
length-prefixed frames carrying both. Pipeline stages and
grant bodies cross nothing: stages are threads
(stages-are-threads) and a grant body
evaluates locally (sandbox-external-children).
The envelope is engine-protocol; why the host
never reads a parent is the engine protocol.
- Syntax, structure, semantics. Every JSON input is parsed to a
JsonDocument, decoded structurally into a raw form, then validated into domain values. Each refusal is a typedDecodeFailureat its JSON path. - Exhaustive both ways. Wire kinds are serde enums matched exhaustively; floats cross as IEEE-754 bits, so NaN and ±∞ survive.
Values — core/src/data.rs, core/src/data/
FOValue<X = NoExt> is the one first-order vocabulary, independent of
runtime values and shared by protocols and records. NoExt is uninhabited,
so a default FOValue is data all the way down.
data/datum.rs—Datum, the strict codec every typed payload uses (encode,decode), withtag,untag,field,exact_keys.record!derives an exact-key record with canonical (sorted) encoding and a nearest-key hint for an unknown key;variant!andlabel!do the same for payload and bare-tag enums. Withtyped, each also implementsty::Typed. Records ral reads back live infact(ErrorRecord,Io, …), below the checker.- The error record.
ErrorRecordis[frame, message, status, site]; the wire carries theErrorFactit projects from,{frame, reason, site}, whoseReasonisDatumbut notTyped(the error record). data/print.rs—pretty_printover aPrintableview, implemented byFOValuehere andVClosRefin the shell; it sits belowauthority(core-below-shell).data/string.rs—Str, the shared immutable string of IR and runtime values.data/byte_encoding.rs— bytes are base64 in JSON, native in binary codecs.
One walk joins ValClos to FOValue
(ir/value/first_order.rs). FOValue::walk hands each block, function or
handle (VClosRef::opacity) to a leaf function:
TryFrom<&ValClos> for FOValuerefuses it withNotData, naming the leaf and whether it was nested;FOValue::scrubbedwrites it as its`opaque [type: …]placeholder (Mooring::surface);From<FOValue> for ValClosis a plain fold.
Marshalling — core/src/marshal.rs, core/src/marshal/
Marshalled is one JSON document over the parent’s Image and the spawn’s
SpawnGrant; a wire value names rows and never nests another wire value.
Shell::marshal writes it; Shell::child_of reads it against the receiving
Runtime, constructs the session and pushes the grant’s layer
(shell-state). The store crosses; the continuation,
hooks and root-only terminal authority do not.
- Seats.
IdentityTransport::childshares the parent’sArc<Runtime>;Engine::bootreadsOrigin::Child(parent)against its own. Both callShell::child_of, run no root recipe, and read the same bytes. exarch’sstartrefusesNoDeskbefore marshalling. - Representation axis.
wire.rsis one familyWire/Row/Value/Binding/Framegeneric overD: IrData. The writer emitsWire<RuntimeData>(Bytes,Closedleaves); the reader decodesWire<RawData>(String,Arc<Scheme>leaves), with identical spelling. The axis exists becausedecode_structural(data/json/de.rs) forbids semantic serde validators, andBytesandClosedvalidate when deserialized. Admission is the semantic pass (one IR grammar). Wireholdsrows, the rootenv,context,sources,terms,fixingsandgrant.
Writing — write.rs
One borrowed walk emits rows dependencies-first. Nodes are allocations:
a nonempty environment (Env::addr; ∅ names no row). A list or map built at
run time is a closure like any other, its elements bound in its row. An
explicit Open/Close stack visits each once; a HashMap keyed by
address assigns its id at close. The borrowed image keeps every address alive
(depth-proof-env-seam).
Value::Closure { tags, val, env }— held syntax over its env row, the tag spine peeled syntactically into a flat list.Value::Builtin(name),Value::Handle(title).Value::Residual { builtin, env, supplied }— η ofbuiltinaftersupplied = arity − remainingarguments, over its env row; zero is real.
Writing is total but for the cwd. Val::Builtin, Val::Handle and
CompKind::Builtin (δ) are serde(skip); they occur only at a value
closure’s root, never under a tag (ValClos::variant), and δ only inside η.
The one refusal is a non-Unicode cwd: ProtocolFailure::Marshal, whose
message names the path and the remedy.
Reading — read.rs, read/ir.rs
marshal::read parses, bounds depth, decodes structurally, then admits and
constructs in one pass. Every refusal is a DecodeFailure at its JSON path,
wrapped once as ProtocolFailure::Decode { kind: Parent, operation: "child" }.
- Depth.
nestingrefuses a document deeper thanNESTING_LIMIT(65 536 levels;TooDeep) iteratively, before any recursive walk. Decoding and dropping the raw tree run on a grown stack (STACK, 64 MiB). - Rows. Row
iis built from rowsj < i; then the root env and handler frames from any row. A bad reference isUnresolvedRowwith aRowDefect:ForwardorAbsent.Env::from_bindingsrefuses duplicate names. - IR admission (
admit_val,admit_comp,admit_module) rebuilds each node through its constructor, recursing into linked modules:- byte leaves pass
Bytes::from_base64;Defineand binding schemes passClosed::new(OpenScheme); - a
Recindex lies in its group (RecIndex); - record and map literal fields,
withinoptions andgrantcapabilities are strictly ascending on the wire’s pair sequence, since they become the persistent map a node holds (admit_sorted_fields:UnorderedField,DuplicateField); update fields are distinct; - a
Site’s node ids lie in range (Site::check,DanglingNode); - a
Define’s schemes name exactly its pattern’s names, since exports are read off schemes (SchemeNames).
- byte leaves pass
- Closures.
ValClos::closurerefuses a foot naming what its env row does not bind (OpenClosure), then folds the tags back. - Builtins. Names resolve through Σ’s canonical values,
Signature::native(UnknownBuiltin), soBuiltinEntry::residual’s identity check holds. - Residuals.
BuiltinEntry::residualrebuilds the receiver’s η suffix whensupplied < arityand the env row binds exactly that entry and its firstsuppliedarguments; otherwiseInvalidResidualwith aResidualDefect:Saturated,EnvironmentSize,BuiltinUnbound,BuiltinForeignorArgumentUnbound. - Handles arrive withheld (
ValClos::withheld); observing one failswithheld-handle. - Handler frames keep entries, catch-all and
FrameKind. Each arm must be a block or function (Shape) and names are distinct, sinceHandlerEntry::ral_per_nametrusts its thunk. - Grant. The inherited stack is reheld (
rehold).RawSpawnGrantvalidates toInherit,Base(name)orRestrict(record), unfrozen;SpawnGrant::narrow_ontofreezes it against the child and pushes one layer (a-spawn-is-one-layer).
Framing — core/src/io/frame.rs
encode, put and read_frame delimit the engine protocol’s frames.
Marshalled has no inner length prefix: its carrying frame bounds it, and
in-process marshalling is unframed.
fusechecksMAX_FRAME_LEN(256 MiB) before the reader allocates and before the writer sends, returning typed actual/limit counts.encodeyields anEncoded;putfails only on I/O.- Frames bound length, not depth:
JsonDocument::parseis iterative, encoding runs underserde_stacker, recursive decoding underon_json_stack. FrameReadErrorpairs a portableFrameFailurewith report-onlyFrameDumpevidence, which never becomes the cause.
Typed JSON boundaries — core/src/data/json.rs
from_slice<T: JsonDecode> returns JsonInputFailure: syntax or a typed
DecodeFailure. JsonDocument keeps source ranges and every object entry,
so validation sees duplicate keys and numeric spellings.
RawFOValueandRawDatum<T>hold unchecked leaves untilvalidate. The raw graphs ofprotocol/json.rsandcarrier/json.rsvalidate before returning values. A non-finite float isDecodeCause::FiniteBits.serialize_structuralserves only audited raw representations whose fallible leaves are already checked;JsonEncodereturnsJsonEncodeFailure.- exarch’s
record/json.rsrunsMirror::checkbeforehydrate.record/log/raw.rsverifies the seal over the commit’s exact source slice before validating records;RecordLineFailureseparates syntax, envelope, seal and record failures.