Skip to content

Dependencies

A dependency is a WebAssembly module used through ctx.deps.<key>. Its declaration states which bytes are needed and where to obtain them. It grants nothing. The operator’s allowlist admits by digest, kind and methods, whatever the source. For the same bytes, changing the source does not change admission, dispatch, state identity or permission.

Field Contract
record key Handler binding name, a JavaScript identifier other than log or gateway.
module Required human-readable module name, [a-z0-9][a-z0-9-]*. It labels the dependency and its operator policy.
version Required exact version, one to three dot-separated numbers. No range, latest or moving tag. This grammar is not full SemVer.
sha256 Required SHA-256 of the module bytes, exactly 64 lowercase hexadecimal characters. One digest per dependency for now.
kind Optional; when present, [a-z][a-z0-9-]{0,63}. The calling kind requested, such as sqlite, pure-compute or string-method. When omitted, the host takes the calling kind from the operator-allowed module identified by module and sha256. If that module does not determine a calling kind, the dependency is refused with NOT_ALLOWED before any call executes. An explicit unknown or incompatible kind is also refused with NOT_ALLOWED; the declaration never widens the allowlist.
methods Optional record of method signatures, with args and returns. It narrows what may be called; it never widens the allowlist. SQLite uses its fixed API and must omit this field.
from Source string or one-tag object, described below. Omission selects the operator’s default registry source.
license Optional license identifier or expression describing the module.
provenance Optional record: repository (source repository URL), commit (exact source commit), toolchain (build tool/version description), lockDigest (SHA-256 of the upstream build’s dependency lock). These are provenance claims, not permission or independent verification.
persistent, init, migrations State declarations, described under dependency state.

License and provenance are optional in the portable declaration today. A host or registry may require either as policy and must report what is missing. lockDigest describes an upstream module build; it does not introduce a realm module lock file. A later variants list beside sha256 is reserved without defining its entries or selection rules. This version must not silently select a variant it does not understand.

from is an extensible tagged union. Its current object form has exactly one source tag:

Form Meaning
{ local: "modules/stockfish-19.0.0.wasm" } A regular file inside the captured realm. Paths are realm-relative, without leading slash, backslash, . or .. components. A symbolic link or escape from the realm is refused. Human-readable filenames are encouraged.
{ registry: "default" } The operator-configured source named default. Any nonempty configured source name may replace it; an unknown name is refused. Omitting from means this default.
{ url: "https://modules.example.org/module.wasm" } Fetch at install if verified bytes are not already cached; verify and cache by digest. It is never fetched during a handler call. A URL must use HTTPS and contain no credentials or fragment. Its filename need not be the digest. A host follows no redirect unless its policy allows one, and a followed redirect must remain HTTPS.
{ realm: "another-realm" } Reserved, refused with DEPENDENCY_SOURCE_NOT_SUPPORTED_YET, naming the dependency and realm source. Consent, pinning, cycles and upgrades remain to be specified.

The unambiguous string shorthands are "./modules/example.wasm" for a local file and "https://modules.example.org/example.wasm" for a URL. Strip the leading ./ when resolving the local shorthand. Other strings are refused; a bare module name or version is not guessed to be a path or registry. Use the registry object form. This string-or-object convention does not import another package system’s ranges, Git sources or lock file.

New source tags may be added independently with their own consent and pinning rules, without changing existing tags. An unrecognized tag is refused explicitly as unsupported, naming the dependency; it must never fall back to the default registry.

Registry resolution. The module name and exact version describe the requested module; operator policy checks those labels where configured. A registry source fetches bytes by digest through an operator-configured digest-addressed store or HTTPS prefix, not by a name/version lookup. A host need not verify the author’s version label against the bytes; the digest decides. A registry may later resolve (module, exact version) to a candidate, but that candidate must still match the declared sha256. That lookup is reserved, not required of a host, and needs no second authored file.

Whatever the source, the digest is the identity of the bytes. A missing source or hash mismatch is refused naming the dependency and its source. DIGEST_MISMATCH must identify the expected digest without exposing secrets. Unverified bytes must not be cached or run. A cache hit must still be verified. Declaring or shipping bytes grants nothing.

realm.ts from is the only place a dependency source is declared. There is no module lock file or separate list to maintain. Legacy YAML realms keep loading modules/<sha256>.wasm with dependencies/manifest.json unchanged; their existing kind inference and module policy remain intact. This is legacy compatibility, not an alternate source declaration for a TypeScript realm.

A host validates the declared source and any explicit calling kind, verifies the module bytes and admits each dependency separately. It refuses an unsupported source explicitly and never substitutes another source or silently ignores its fields. A refused dependency does not prevent unrelated dependencies from being admitted.

These three complete definition objects show the local, registry and URL forms. They parse as TypeScript without SDK extensions. Installing them also requires the named bytes and an operator grant. The digests identify the audited module builds; the example URL and named registry are operator-provided locations, not a claim of a public download service.

Stockfish uses the non-SIMD build. Place those exact bytes in modules/stockfish-19.0.0.wasm:

// realm.ts (local Stockfish)
export default {
name: 'chess-modules',
version: '1.0.0',
dependencies: {
engine: {
module: 'stockfish',
version: '19.0.0',
sha256: 'b6e43bfbb09335610d64c93e343a2e42b03ebdf80aafa54db42a4dcc1f168056',
kind: 'string-method',
from: { local: 'modules/stockfish-19.0.0.wasm' },
methods: { analyse: { args: ['string', 'i32', 'i32', 'i32'], returns: 'string' } },
license: 'GPL-3.0-or-later',
},
},
}

SQLite from the operator’s default registry, with ephemeral state and no init file:

// realm.ts (registry SQLite)
export default {
name: 'sqlite-modules',
version: '1.0.0',
dependencies: {
db: {
module: 'sqlite3-wasi',
version: '3.53',
sha256: '9a5542e25e42fbbb48501bae0ab4295cdf0fd0f41219ec3b6c891c4a282e7779',
kind: 'sqlite',
from: { registry: 'default' },
},
},
}

H3 from an HTTPS location the operator permits. Substitute your actual module URL:

// realm.ts (URL module)
export default {
name: 'geo-modules',
version: '1.0.0',
dependencies: {
geo: {
module: 'h3-wasi',
version: '4.5',
sha256: '45cf0ddff91e19c561d2b5f309b04eadbfdd2018688c4e20f749be8805903882',
kind: 'pure-compute',
from: { url: 'https://modules.example.org/h3-4.5.wasm' },
methods: { latLngToCell: { args: ['f64', 'f64', 'i32'], returns: 'i64' } },
},
},
}

Renaming a local module changes captured realm identity because paths as well as bytes are covered. See readable dependency filenames.

A malformed dependency container or entry, or exceeding the reference limit of eight dependencies, refuses the declaration. The reference module byte limit is 32 MiB. An ordinary missing, unallowed or mismatched module refuses that dependency only. Other dependencies and handlers remain available, including handlers that do not call it. An uncaught refused call prevents a successful result; distinguishing every refused outcome from a failed dispatch across host profiles is not yet specified.

SQLite exposes exec(sql, params), returning rows as plain objects. Parameters are strings, numbers or null; bind values with parameters rather than interpolating SQL. Other dependencies may declare at most 64 methods, each an identifier of at most 64 characters, with exactly args (at most 16 types) and returns. Scalar types are i32, i64, f32, f64 and string. An i64 travels as a decimal string, not a potentially rounded JavaScript number.

If methods is present and nonempty, an undeclared method refuses with METHOD_NOT_DECLARED before execution, even if allowlisted. If omitted, only the operator’s permitted methods are callable. A declared method absent from the allowlist or with a different signature refuses that method only (METHOD_UNKNOWN or SIGNATURE_MISMATCH), with a DEPENDENCY_METHOD_REFUSED load diagnostic. A module whose exports disagree with the allowlist refuses the whole dependency. A realm does not choose how the host executes the module and gains no permission to load native libraries.

String methods pass and return ordinary strings to handlers. The module ABI uses UTF-8: each string argument is an i32 pointer/length pair; a string result is an i64 with the pointer in the high 32 bits and length in the low 32 bits. Empty is (0, 0). The module exports embabel_alloc(i32) -> i32 and embabel_free(i32, i32). The host frees argument buffers even after a trap and frees the result after copying it. Results cannot overlap arguments or escape module memory. Each string is at most 1 MiB and per-dispatch allocations at most 8 MiB. Invalid UTF-8, bounds or ownership violations fail the call.

The only specified state profile is SQLite (module: 'sqlite3-wasi', admitted as SQLite). persistent defaults to false. Ephemeral state starts empty for each dispatch. With persistent: true, a world, realm and dependency binding retains its private database. The host publishes changes only after successful dispatch and output validation. Failure, refusal or a conflicting concurrent publication leaves the previous stored state intact; a publication conflict returns STATE_CONFLICT. This storage is separate from the graph.

init names a contained script, at most 1 MiB, read from the admitted capture. It runs on empty state: each ephemeral dispatch or the first creation of persistent state. Editing the working copy does not change an admitted script. migrations is an ordered list of at most 64 distinct contained .sql paths, each at most 1 MiB; it requires init. On empty state, init runs before all migrations. On restored state, only the appended migrations run.

The stored fingerprint records admitted module identity/version/digest, the init hash and ordered migration hashes. Applied migrations must remain an unchanged prefix. Reordering, removing or editing one, or changing the base module/init identity, refuses reuse with DIGEST_MISMATCH, naming the first difference. A failing migration reports FAILED and does not publish its partial changes. The host neither silently wipes nor reinterprets old state. Fingerprints predating migrations mean an empty applied list.

State options on pure-compute are refused. State and migration semantics for other module kinds are not yet specified. Declaring kind: 'sqlite' on an arbitrary module does not grant SQLite support. Migrations are specified for the SQLite module profile only; generalization to additional admitted stateful kinds remains open.

The SDK offers ctx.deps.<key>.<method>.batch(calls) for declared scalar methods, with 1 to 256 calls and ordered results. A single-argument method uses a list of scalar values; a multi-argument method uses a list of argument tuples; a zero-argument method uses empty tuples. That is an SDK surface, not evidence of a portable host batch protocol. Host-side batch dispatch, partial results, failure ordering, cancellation and atomic state/commit semantics are not yet specified. Do not infer a transaction from a batch helper. Sequential awaited calls inside one dispatch use the ordinary scalar-call and success-only persistence rules above.

layers remains unsupported in the reference profiles and is refused as LAYERS_REFUSED. It is not an alternative to definition imports or a way to obtain another realm’s grants. Graph label composition remains separate from code and dependency-source composition.