Storage model
The store has a two-level layout:Operations
The operations are defined by the Host contract described in Protocol.Read a value
The read request contains:
The response contains a
found boolean and a value byte sequence. A missing
key is not an error: found is false and no value is returned.
Reading a value does not create its namespace or key.
Write a value
The write request contains the samenamespace and key fields plus:
Writing an existing key replaces its value. The operation returns an error
string when the write is rejected, for example when the namespace is
read-only.
Delete a value
The delete request containsnamespace and key. Deleting an existing key
removes its value. Deleting a key that does not exist succeeds without changing
the store.
The operation returns an error string when deletion is rejected, including an
attempt to delete from a read-only namespace.
List keys
The list request contains anamespace field:
- When
namespaceis non-empty, the response contains the keys currently present in that namespace. - When
namespaceis empty, the response contains the names of all namespaces currently present in the store.
Lifecycle and persistence
The Kernel creates the KV store when it creates the service manager. The store is in memory:- stopping or restarting a service does not clear its KV values;
- loading a new version of the same service does not clear its KV values; and
- restarting the Kernel creates a new empty store and clears all values.
Concurrency and value ownership
The Kernel synchronizes individual KV operations. Reads, writes, deletes, and lists are safe when multiple service calls happen concurrently. There is no transaction or compare-and-swap operation. A sequence such as “read, modify, write” is not atomic with respect to another service. If several services update the same key, coordinate ownership or design the value so that lost updates do not corrupt the application state. The Kernel copies byte values when storing and reading them. Mutating a byte buffer after a write does not change the stored value, and mutating a returned buffer does not change the value in the store.The sys namespace
sys is a Kernel-managed, read-only namespace. Services can read and list
it, but writes and deletes through the service host boundary return an
error.
The Kernel uses this namespace for host-managed state, including service
registry information — for example, sys/service/catalog/<name> for scanned
package metadata and sys/service/<instance-id> for a running instance’s
registered routes and transports. Do not write to sys, and do not depend on
undocumented system keys unless the Kernel documentation explicitly defines
them.
Backend behavior
WASM and gRPC services use the same KV contract:- a WASM service reaches the store through the generated host bindings; and
- a gRPC service reaches the store through the Kernel’s host callback channel.
static service has no code and never calls
these operations itself.
Recommended usage
Use a predictable namespace and key scheme:found result before decoding a
value, handle write and delete errors, and avoid treating a successful write
as durable persistence.