Metakit / API
@doeixd/metakit/artifact
Portable semantic artifacts (@doeixd/metakit/artifact).
Encodes and decodes the portable subset of MetaKit Expr nodes as versioned
Effect Schema values: paths, JSON-safe literals, bound Rows variables,
core/foreign calls by stable (id, version), conditionals, and matches.
Never serializes JavaScript closures (Opaque), raw SchemaAST internals,
or interpreter functions, and never fabricates Expr<Env, A> without
validating wire shape, size/depth limits, operator registry & allowlist,
path scope, arity, and result kind against the caller's Schemas.
Bundles write an expression or a transition for a reader outside
JavaScript, in one profile (docs/bundles.md).
Namespaces
DEFAULT_LIMITS | Default resource bounds for portable artifacts. |
Hash | The one place MetaKit hashes a definition: the canonical JSON rules, the domain tags and SHA-256. The rules are written out in docs/semantics.md ("Content… |
Functions
canonicalizeNode | Deterministic canonical form of a PortableNode: literal object keys sorted, while strictly preserving evaluation order, If/Match branch order, and operator… |
canonicalJson | The canonical JSON of a PortableArtifactV1 (Hash.canonical of its canonical form). Fails with Unhashable for a hand-built artifact holding a leaf JSON… |
decodeBundle | Read a bundle written by encodeExprBundle or encodeTransitionBundle, applying every check its encoder applies: the size bound counted the same way, the… |
decodeExpr | Decode and validate a wire artifact into a typed Expr<EnvOf<Shape>, R['Type']> over a multi-slice environment { slice: Schema }. |
decodeForSchema | Decode and validate a wire artifact into a typed Expr<S['Type'], R['Type']> over a single Schema. |
encodeExpr | Encode an Expr into a versioned PortableArtifactV1. Rejects Opaque nodes, non-portable literals (NaN, Infinity, -0, functions, symbols, class instances),… |
encodeExprBundle | Write expr as a bundle of profile (Language.safeIntK3), its paths read against env, the Schema of each slice ({ row: Account }). |
encodeTransitionBundle | Write transition as a bundle of profile, its paths read against { state, input, supplied } built from its Schemas. A write is stated with its target's kind… |
evidenceKey | Compute an EvidenceKey (ev:sha256:<hex>, domain metakit/evidence@1) for caching reader/verifier results. Returns Option.none() if any required foreign op… |
fingerprint | Compute the deterministic ArtifactFingerprint (sha256:<hex>, domain metakit/expr@3) of an Expr or an already-encoded PortableArtifactV1: its canonical… |
fnHashes | A function's executable and contract hashes. The executable hash (metakit/fn@1) covers what decides a call: its parameters' names and interfaces (by name),… |
machineHashes | A machine's executable and contract hashes. The executable hash (metakit/machine@1) is each message tag with its transition's executable hash, sorted by… |
operationFingerprint | The definition hash (sha256:<hex>, domain metakit/operation@1) of a derived operation: what decides a call's outcome. That is its parameters' names and… |
operationHashes | A derived operation's executable and contract hashes. The executable hash is operationFingerprint's (metakit/operation@1), which every call of it holds. The… |
registry | Build an OperationRegistry from Operations and/or Languages. Identical or signature-compatible duplicate registrations are idempotent; conflicting… |
schemaFingerprint | Hash schema's interface (domain metakit/schema@1): the value EvidenceKeyInput.schemaFingerprint takes for a target's Schema. |
schemaInterface | The interface of schema's decoded side, as a canonical value: two Schemas that differ only in documentation, names or field order have equal interfaces.… |
transitionHashes | A transition's executable and contract hashes. The executable hash (metakit/transition@4) covers its guard, writes and emits, and the interface of each path… |
Values
BundleNode | One entry of a bundle's node table. A child is the index of an earlier entry. A Path holds the interface of the Schema it was built with (schemaInterface),… |
CODEC_VERSION | Current wire format version for portable expression artifacts. |
emptyRegistry | Registry with no foreign operations (core operators only). |
PortableArtifactV1 | |
PortableBundleV1 | A bundle of either kind, as decodeBundle reads it. |
PortableExprBundleV1 | An expression's bundle: node is its root in nodes. |
PortableLiteral | |
PortableNodeSchema | |
PortableOpRef | |
PortableSlot | One path a bundle reads: the host supplies one value of it per call. |
PortableTransitionBundleV1 | A transition's bundle: each expression a step evaluates is a root in nodes. ensures is left out, as the executable hash leaves it out: no step evaluates it,… |
WriteRequirement | What the state before a step must hold, read from one slot, for a write to go; where one fails the step refuses as Unwritable (docs/semantics.md, §6 step… |
Classes
ArtifactDecodeError | A wire artifact failed version, schema, scope, arity, or result-type validation. |
ArtifactLimitError | An artifact exceeded a configured resource limit. |
BundleRefusedError | A definition is outside the profile, a path it reads cannot be a slot, a write cannot be stated, or (decode only) the fingerprint is not the one its content… |
DuplicateOperationError | Two incompatible operations were registered under the same id@version. |
EvidenceStore | A key-value store of evidence. Prove.machine and Prove.fn read it where it is provided and prove as before where it is not; @doeixd/metakit/sql/stored needs… |
UnknownOperationError | An artifact referenced an unknown, unregistered, or disallowed operator. |
UnsupportedNodeError | A node or literal value lies outside the portable subset: an Opaque node, a literal such as NaN or a function ('Lit'), or a bound read outside its fold… |
Interfaces
AllowlistPolicy | Policy controlling which operators an externally received artifact may invoke. |
ArtifactLimits | Bounds enforced during both encoding and decoding to guard against hostile inputs. |
DecodeBaseOptions | |
DecodeEnvOptions | |
DecodeSchemaOptions | |
DefinitionHashes | A definition's two hashes (docs/semantics.md, "Executable and contract hashes"). |
EncodeOptions | |
EvidenceKeyInput | Inputs that decide whether cached execution/verification evidence may be reused. |
FnDefinition | A function as its hashes read it: what Fn.params(...)…body(...) builds. |
MachineDefinition | A machine as its hashes read it: its state Schema, its start and its arms by message tag. |
OperationRegistry | Immutable registry resolving (id, version) to declared AnyOperations. |
TransitionDefinition | A transition as its contract hash reads it: its terms and the Schemas a proof of it assumes. |
Types
ArtifactError | |
ArtifactFingerprint | Content fingerprint of a canonical portable expression artifact (sha256:<hex>). |
BundleError | |
EncodeError | |
EvidenceKey | Cache key for reader/verification evidence (ev:sha256:<hex>). Distinct from a definition's hash: includes reader identity/version, backend profile, schema… |
OperationFingerprint | Content hash of a derived operation's definition (sha256:<hex>, domain metakit/operation@1). |
PortableNode | |
PortableRowsOver | |
RegistrySource | Source accepted by Artifact.registry: a single Operation or a Language. |
SchemaFingerprint | Hash of a Schema's interface (sha256:<hex>, domain metakit/schema@1). |
SchemaInterface | The canonical interface of a Schema, as schemaInterface writes it. |