Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

manifold:world 0.2.0

Contract reference · Payloads · contract.json (crates/manifold-wasm-abi/wit/contract.json)

Contract 0.2.0, track 0.2: open, unreleased. Nothing on track 0.2 is released yet, so any item may still change in place (spec §7.2).

InterfaceKindConsentSidesOwner
block-readimportlistedbothenki
block-transactionimportlistedserverenki
block-typestypes-onlysilentbothenki
block-worldimportlistedserverenki

Interface block-read

import · consent listed · sides both · owner enki · kernel profiles read-windows · since 0.2.0

Block reads (Enki B §1). Both sides: the server reads the authoritative world live at the step the call runs in; the client reads its streamed chunk cache, which may be a round trip stale and never trusted by the server. A read never loads a chunk. Consent class listed.

Reads work inside the mod’s own systems, where the host lends the world (the read window, Enki B §1.3); outside one, get-block is none and the others fail with outside-system.

Functions

chunk-states

chunk-states: func(volume: volume-ref, bounds: block-box) -> result<list<tuple<chunk-coord, chunk-state>>, read-error>

The state of every chunk intersecting bounds.

  • Kernel profiles: read-windows.

get-block

get-block: func(volume: volume-ref, pos: block-pos) -> option<block-value>

The value at pos; none when its chunk is not resident or the volume does not exist.

  • Kernel profiles: read-windows.

read-region

read-region: func(volume: volume-ref, bounds: block-box, options: read-options) -> result<region-data, read-error>
  • Kernel profiles: read-windows.

registry-hash

registry-hash: func() -> list<u8>

SHA-256 of registry-snapshot, 32 bytes.

  • Kernel profiles: read-windows.
  • result: packed layout sha256-digest.

registry-snapshot

registry-snapshot: func() -> list<u8>

The compiled block model (Enki A), layout block-model-snapshot. Mods rebuild it with BlockModel::from_snapshot.

Types

block-box (alias)

= core/types.block-box

block-pos (alias)

= core/types.block-pos

block-value (alias)

= world/block-types.block-value

chunk-coord (alias)

= world/block-types.chunk-coord

chunk-state (enum)

IndexCaseAbout
0resident
1loading
2absent

read-error (variant)

IndexCasePayloadAbout
0too-largeu64More cells than one call may read; the limit.
1volume-not-foundnone
2unsupported-volumenoneA Daedalus assembly before its block storage implements reads.
3invalid-boxnone
4unknown-layeru32A layer id this world does not have.
5wrong-sidenone
6outside-systemnone

read-options (record)

FieldTypeAbout
layerslist<u32>Enki A layer ids. Empty means the solid layer only.
unknown-valueblock-valueWritten into cells whose chunk is not resident.
widthvalue-width

region-data (record)

FieldTypeAbout
boundsblock-box
widthvalue-width
valueslist<u8>Packed cell buffer (layout cell-buffer): one plane per requested layer, solid first, x fastest, then y, then z.
missinglist<chunk-coord>Chunks intersecting the box that were not resident.

value-width (alias)

= world/block-types.value-width

volume-ref (alias)

= core/types.volume-ref

Interface block-transaction

import · consent listed · sides server · owner enki · since 0.2.0

Transactional bulk block edits (Enki B §2) over the host’s one native submission API (§2.9). Server side; consent class listed.

A transaction is a list of ops submitted in one call and always atomic: it validates as a unit at the host’s apply slot, applies without interleaving, replicates as chunk deltas and optionally writes an undo record. submit follows core/ops (contract foundation §5.3); results arrive through take-results on this or a later tick. The host submits during the call, inside the mod’s server systems, where it lends the world (Enki B §3.4); outside one, submit fails with other("outside-system").

Functions

cancel

cancel: func(id: batch-id) -> bool

Cancel a transaction before its first chunk applies. False when it is unknown, not this mod’s, finished or already applying.

submit

submit: func(options: txn-options, ops: list<u8>) -> result<batch-id, submit-error>

Submit one transaction. ops is a sequence of [u32 length][postcard TxnOp] records (schema txn-ops), applied in order: a later op sees earlier ops’ output. Only broken framing fails the call (malformed(index)); an op this host does not implement, or a malformed op record, rejects the transaction in its result (unsupported(kind), malformed).

supports-op

supports-op: func(kind: op-kind) -> bool

Whether this host implements op kind (the TxnOp variant index: 0 fill, 1 write, 2 write-sparse, 3 write-if-unchanged, 4 map, 5 set-component, 6 remove-component, 7 props, 8 revert, 9 reapply, 10 expect).

take-results

take-results: func() -> list<u8>

This mod’s transaction results since the last call (schema txn-results).

Types

actor (alias)

= core/types.actor

batch-id (alias)

= core/ops.batch-id

blob-key (alias)

= storage/storage-types.blob-key

op-kind (alias)

= core/ops.op-kind

record-mode (variant)

IndexCasePayloadAbout
0nonenone
1to-blobblob-keyThe host writes the undo record straight to blob storage, in the calling mod’s namespace.

reveal (enum)

When other players see a transaction that applies over several ticks.

IndexCaseAbout
0progressive
1at-commit

submit-error (alias)

= core/ops.submit-error

txn-options (record)

FieldTypeAbout
volumevolume-ref
actoractor
requireslist<string>Permission nodes the actor must hold beyond the intrinsic ones (Enki B §8.5). At most 8.
unloadedunloaded-policy
neighbor-updatesboolWater wakes and Enki A derived-state updates. Off needs build.no-updates.
undorecord-mode
reveal-modereveal
labelstringDiagnostic text for logs and review hooks, at most 64 bytes.

unloaded-policy (enum)

What to do when a touched chunk is not resident.

IndexCaseAbout
0reject
1load

volume-ref (alias)

= core/types.volume-ref

Interface block-types

types-only · consent silent · sides both · owner enki · since 0.2.0

Block values and the records block-read and block-transaction share (Enki A, “Registry snapshot for mods”; contract foundation §4.5 rule 3, §15.1). Types only: importing this interface links nothing and needs no consent.

Types

block-value (alias)

A block value: an index into the world’s value table (Enki A). The numbers are session-local and never persisted; state strings name values durably (registry-snapshot maps between the two).

= u32

chunk-coord (record)

A chunk coordinate: block coordinates divided by 32, rounded down.

FieldTypeAbout
xs32
ys32
zs32

value-width (enum)

Bytes per cell in a packed cell buffer: 2 today, 4 if Enki A widens values. Readers check it.

IndexCaseAbout
0two
1four

Interface block-world

import · consent listed · sides server · owner enki · since 0.2.0

Server-side voxel-edit decision ABI of the player-edit handler (Enki B §3.4). Moved from manifold:game@0.1.0 with its records taken from core/types. The engine net-inbound phase fills the pending edit-request queue; the guest drains it and decides each edit. A decided edit is submitted during the call as a one-cell transaction of the host’s native write path; it validates first in this tick’s apply slot, commits the same tick and replicates as a block update. Its outcome arrives through take-results. get-block (voxel read) is intentionally deferred to its first consumer.

Functions

queue-edit

queue-edit: func(edit: decided-edit) -> result<batch-id, submit-error>

Queue a decided edit: a one-cell transaction, submitted now, that validates first in this tick’s apply slot. Fails only with the shared submit-error: malformed for a value wider than a block id, actor-unknown when the peer is not a connected player (the client is told of both), and other("not-handler") / other("outside-server-tick") when the caller is not the handler or calls outside a server-tick system.

  • Reports other("not-handler"): the caller is not the player-edit handler.
  • Reports other("outside-server-tick"): called outside a server-tick system.

reject-edit

reject-edit: func(peer: u64, client-seq: u32, reason: localized-text)

Reject a request for a game reason, routed back to the peer. The reason is shown in the requesting player’s language.

take-edit-requests

take-edit-requests: func() -> list<edit-request>

Drain this tick’s pending inbound edit requests.

take-results

take-results: func() -> list<u8>

Schema payload: the TxnResult records queue-edit’s batch ids resolve to, oldest first, with an Overflow record when some were dropped. An edit that writes the value already there is Committed with changed-cells 0; a refusal is Rejected.

Types

batch-id (alias)

= core/ops.batch-id

block-pos (alias)

= core/types.block-pos

decided-edit (record)

A decided edit. Carries the origin so an apply-failure rejection routes back to the requesting client. new-block is AIR for a break.

FieldTypeAbout
peeru64
client-sequ32
posblock-pos
world-spaceworld-space-id
new-blocku32

edit-action (variant)

Mirror of net-protocol’s EditAction. place carries the block id.

IndexCasePayloadAbout
0breaknone
1placeu32

edit-request (record)

An inbound client edit request, pre-staged by the host this tick.

FieldTypeAbout
peeru64
client-sequ32
posblock-pos
world-spaceworld-space-id
actionedit-action

localized-text (alias)

= core/text.localized-text

submit-error (alias)

= core/ops.submit-error

world-space-id (alias)

= core/types.world-space-id