Mod permissions, channels and blob storage
Three host services that Enki B specifies for every mod
(Enki B (docs/superpowers/specs/2026-09-27-enki-b-mod-platform-contract-design.md)
§4, §7, §8). Their native Rust APIs and host plumbing exist on both hosts,
and guests reach them through manifold:perms/permissions,
manifold:net/mod-channel and manifold:storage/blob-store, published in the
open 0.2 track (see Guest interfaces). Mods’ permission
and channel declarations reach the host in their ModDeclarations (see
Declaring).
Declaring
A mod writes its permissions in mod.toml and its channels in
Plugin::build:
[permissions]
# Platform nodes (and limits) the mod's own (mod-self) operations use.
uses = ["build.load-chunks"]
[[permissions.declare]]
name = "enki.use"
default = "admin" # who holds it without configuration: player | admin
[[limits]]
name = "enki.cells.max"
default = { player = 65_536, admin = 8_388_608 }
max = 134_217_728
let edit = app.add_channel(ChannelDecl {
requires: Some("enki.use".into()),
..ChannelDecl::client_to_server("edit")
});
- Into the declarations.
#[mod_entry]reads the crate’smod.tomlat build time and bakes[permissions]and[[limits]]intoModDeclarations::permissions;add_channelregistrations becomeModDeclarations::channels, numbered by position (ModChannel). Both are format 13 fields.cargo mod buildrefuses a component whose declarations disagree with its manifest. - The rules. One rule set,
platform_decls(crates/manifold-modloader/src/platform_decls.rs), runs in the manifest parser,cargo mod build, the loader on both hosts and the catalogue: nodes and limits only under the mod’s own id (a platform namespace is refused naming its owner);usesnames platform nodes or the mod’s own declarations; no name twice; limits<ns>.<thing>.maxwith0 <= default <= max; channel names[a-z0-9_-], unique, and arequiresthat is a platform node or one the mod declares. A module that breaks one fails its load with an error naming the mod and the name. - Joining the services. The server registers every loaded mod’s
declarations at boot, after the orchestrator loads and before any
connection
(
mod_platform::install_server_declarations(crates/manifold-host-core/src/mod_platform.rs)). A client registers its loaded mods’ channels before each client tick (sync_client_channels), so modules delivered after the handshake join too. Labels are implied catalog keys:<mod-id>.permission.<local>, with.description.
Permission nodes
A player has a level (Player < Admin) and a set of permission nodes,
dotted names <namespace>.<name> such as build.edit. A limit is a valued
node, an i64 per player, named <namespace>.<thing>.max.
- One catalogue.
PermissionCatalogue(crates/manifold-server-state/src/permissions/catalogue.rs) holds every node and limit. The platform programs register theirs at boot (permissions::platform(crates/manifold-server-state/src/permissions/platform.rs)): Enki’sbuild.*andworld.*, Pygmalion’sanimation.*and Talos’stalos_observe::nodes::NODES(crates/manifold-server-state/src/talos_observe/nodes.rs), each with its own defaults. A loaded mod’s declarations join throughregister_mod, namespaced by its id. - One seam. Every check goes through
anim_contract::player_has_node(crates/manifold-server-state/src/anim_contract.rs), a bit test in the player’s resolved set inConnectionPermission(crates/manifold-server-state/src/connection_permission.rs). Admin and the local host hold every node; a node the catalogue does not know is Admin’s only; an unknown connection holds nothing. - Resolution. A connection’s set is resolved at accept and on change, never
per check, from its level, local-host status and its proven account’s
entry in
permissions.ron. A node is held when its default isplayeror the file grants it, unless the file denies it;denynever removes anything from Admin or the local host. Limits take the local host’smax, else the declared default for the level. mod-self. An operation a mod makes on its own authority (a transaction, animation or physics op with actormod-self) needs every node it would need from a player, held only if the mod declares it or lists it inuses; a mod’suseslist is its whole scope, not documentation (#584). Every boundary that accepts amod-selfactor checks through one fail-closed seam inpermissions(crates/manifold-server-state/src/permissions/mod.rs):mod_self_check(world, mod_id, node) -> Result<(), ModSelfDenied>(mod_self_has_nodeis its boolean form). Without the permission table, or for a mod that registered nothing, nothing is held. The refusal,ModSelfDenied { mod_id, node }, names the mod and the missing entry:mod `enki` used `build.state` without declaring it in [permissions] uses, andModSelfDenied::to_textgives the same message as the localized keyengine.permissions.mod_self_undeclared($mod,$node). A boundary whose wire refusal already names the node keeps it (a transaction or animation op is refusednot-permitted(node)) and logs the named refusal at debug level.mod-selflimits. A mod’s value for a limit ismod_self_limit(world, mod_id, name) -> Result<i64, ModSelfDenied>(PermissionCatalogue::mod_self_limiton a catalogue): the limit’s operator ceiling, itsmax, when the mod declares it or lists it inuses, and refused otherwise (also for an unknown limit or an unregistered mod). A mod is never given a level’s column: it is not an admin. Server configuration lowering a mod’s ceiling is B-PERM2 (#249).Ruleactors. The engine’s own rules hold every node and are never checked; only engine code can act as a rule.- Guard. The
mod_self_guardworkspace guard (inmanifold-test-support) scans every crate’s sources and fails on aModSelfarm that yieldstrue,Ok(())or the admin limit tier, or shares its arm withRule. ItsKNOWN_UNFIXEDlist names files whose fix is in flight (the physics boundary, #584); an entry is removed when its fix lands. - The client’s copy. Each connection receives its own level, nodes and
limits in
S2C::PermissionsUpdate(client state:OwnPermissions(crates/manifold-client-state/src/mod_channel.rs)), once its grants are installed and after every change. It is for display and UI gating only. - Mod UIs. The reserved
manifold:ui-actor-permissionbundle entry carries the actor’s level, then the nodes it holds and the limit values within the mod’s scope (UiActorPermissionWire(crates/manifold-mod-types/src/ui_actor.rs)). A guest that decodes only the level still reads it.
permissions.ron
An optional file beside ops.ron in the server data directory. ops.ron keeps
meaning Admin. Both are keyed on the account a join proves, never a display
name, and share one table and one version-1 migration
(operators (docs/architecture/player-identity.md), #557).
// permissions.ron — keyed on proven accounts; labels are for reading only
(
version: 2,
players: [
(account: Offline("3b6a27bc…"), label: "Carol", grant: ["enki.use"]),
(account: Platform("6f1d0e2c…"), label: "Dave", grant: ["enki.use"], deny: ["build.edit"]),
],
)
A missing file grants nothing; a malformed one grants nothing, logs a
warning and is never overwritten. /perm show <user> lists the online
players with that name. /perm grant <user> <node> (Admin) grants the proven
account of the one online player named <user>; /perm revoke <user> <node>
revokes it from online players with that name and from entries labelled with
it. Both rewrite the file atomically and update connected players at once. A
version-1 file (players keyed by platform username) loads as unbound names,
which bind only on a platform-signed join. Tiers, default overrides and
per-player limit values are not applied yet (#249); a file that uses them
loads its players and warns.
Platform namespaces
The namespaces platform programs own are reserved mod ids
(reserved.rs (crates/manifold-modloader/src/reserved.rs)), listed with
their owners in the platform-namespaces table (docs/architecture/extension-contracts.md).
Mod message channel
A mod declares named channels between its halves
(ChannelDecl (crates/manifold-mod-types/src/channel.rs)): a direction,
a size cap, a token bucket and an optional requires node. Every message
rides one reliable transport channel, CH_MOD (7), as C2S::Mod or
S2C::Mod, so a large mod payload never delays engine events.
- Handles. Both sides build the same
ModChannelRegistry(crates/manifold-host-core/src/mod_channel.rs) from the loaded mods’ declarations: mods sorted by id, then each mod’s channels in declaration order. Handles are derived, never exchanged; the mod-set check makes both sides load the same modules. A guest numbers its channels by declaration position. - Server delivery. The inbound phase stages each message
(
mod_channel(crates/manifold-server-state/src/mod_channel.rs) in server state); before the tick’s guest systems,deliver_server_inbounddrops and counts messages on an unknown handle, against the channel’s direction, over its size cap, from a sender without itsrequiresnode, or over the sender’s token bucket. The rest reach the mod’s inbox in arrival order with the sender’s player, level, and nodes and limits within the mod’s scope, captured at delivery. - Limits. A declaration is clamped by the server’s
ChannelLimits; an inline message never exceeds 1 MiB. Buckets refill per server tick in integer milli-tokens, identically on both hosts. - Replies (
server_send_to,server_broadcast) queueS2C::Modon the connection at once. The client checks its sends too (client_send), so a client learns it is rate limited instead of being dropped.
Only reliable inline messages are served. Transfers come later; an
unreliable-latest channel is served reliably, capped at the datagram size.
Blob storage
ModBlobStore (crates/manifold-server-state/src/mod_blobs.rs) keeps
per-mod blobs in the world save, in the world scope (per mod) and the
world-player scope (per mod and durable player id). Both hosts store them in
one redb table, mod_blobs_v1
(table helpers (crates/manifold-saves-types/src/mod_blobs.rs)), in the
same database as the chunks: the native save store and the browser’s
OPFS-backed RedbOpfsSaveStore.
- Keyed by the host. Every operation names the mod id the host authenticated; a guest never states it.
- Deferred results. Each call returns a request id; results drain through
take_completionson both executors. - Saved with the world. A write is staged and reaches the table in the world’s next save transaction, so blobs never disagree on disk with the world they describe. Reads see staged changes first; a failed save stages its rows again.
- Quotas. 1 GiB per mod for
worldand 256 MiB per mod per player forworld-player(noworld-playerquota in browser singleplayer); a write over quota fails and changes nothing. - Paths are 1 to 8
/-separated segments, at most 256 bytes, with no empty,.or..segment.
Guest interfaces
Each interface’s host functions run inside the mod’s own systems, where the
orchestrator lends the instance the world (Mod contract, the world
loan); outside one they fail with
outside-system, and on the side an interface does not serve with
wrong-side. The logic lives once in
manifold-wasm-host-core::capability (crates/manifold-wasm-host-core/src/capability/)
over per-side ports that
platform_ports (crates/manifold-host-core/src/platform_ports/mod.rs)
installs; the wasmtime host and the jco shims only convert values.
| Interface | Functions | Sides | SDK |
|---|---|---|---|
manifold:net/mod-channel (consent listed) | send (client), send-to, broadcast (server), take-inbound | both | channel (crates/manifold-mod-substrate/src/channel.rs): ModApp::add_channel::<T> returns a typed ModChannel<T> for a #[derive(ModMessage)] type, with send, send_to, broadcast and receive |
manifold:storage/blob-store (consent operator) | read, write, delete, list, take-completions, quota | server | blob_store (crates/manifold-mod-substrate/src/blob_store.rs) |
manifold:perms/permissions (consent listed) | level, has, limit, actor-has (server), own-level, own-has, own-limit (client), declared | both | permissions (crates/manifold-mod-substrate/src/permissions.rs) |
- Channels. A channel’s number is its declaration position.
ModApp::add_channel::<T>recordsT’sModMessage::NAMEas the declaration’smessage, which names the type whose postcard encoding the channel’s opaque payloads are (PAYLOADS.tomlmod-message).take-inbounddrains every channel of the mod at once, so the SDK keeps messages per channel until each is read. The server half sees each sender’s player, itspermission-level(theu8ladder: Player 0, Admin 200) and the nodes and limits within the mod’s scope. A client send’s token bucket refills against the client’sTickCursor. - Blobs. Operations keep the deferred shape and complete at the call
(Enki B issue 32): the store’s results move into the instance’s own queue
at once, so the next
take-completionsreturns them in call order. A call that reaches no store (outside a system, on the client, a key whose player part does not match its scope, a server without a store) still returns an id, numbered from bit 63 up so it never meets the store’s ids, and its failure arrives at the next drain. - Permissions. The server answers for any connected peer and, through
actor-has, formod-self(the nodes the mod declares and lists inuses); aplayer-refwhose durable id is not the connection’s isunknown-peer. The client answers for its own player from the lastS2C::PermissionsUpdate(Player and nothing held before the first).declaredanswers from the mod’s checked declarations on either side.
Regression coverage
-
Declaration rules:
manifold-modloader(platform_decls, the manifest sections); the loader refusing a platform-namespace node:manifold-wasm-hostexport_split;cargo mod build’s manifest check. -
Catalogue, resolution, namespace rule, the
mod-selfrefusal and limits, andmod-selftransactions and animation ops: unit tests inmanifold-server-state(permissions,connection_permission,transaction,anim_contract) and themod_self_guardscan;permissions.ronand/perm(including a mod’s nodes and limits) inmanifold-server. -
Channel registry and token buckets:
manifold-host-coremod_channeltests; blob store:manifold-server-statemod_blobs; the redb table:manifold-saves-typesmod_blobs(the helpers both hosts use). -
On a real server over the local transport:
mod_platform_e2e.rs(crates/manifold-server/tests/mod_platform_e2e.rs) (ordering, every drop reason, sender context, replies, permission updates, blobs across a restart; and theenki-stubfixture mod’smod.tomlpermissions and channels registered on a server and a client with the same handles, a message flowing from its client half to its server half and back). -
Guest interfaces: unit tests in
manifold-wasm-host-core’scapabilitymodules; the real ports inmanifold-host-core’s suite (platform_channel,platform_storage_perms); theplatform-smoketest mod through wasmtime on a server world inmanifold-server’splatform_smoke_e2e, and through wasmtime and jco against the recording ports (capability::platform_record) inweb_parity.rs(crates/manifold-wasm-host/tests/web_parity.rs) (browser CI job).