Merge pull request 'Module state is hq ADR 0202 (0201 landed first for a provider's derivations)' (#19) from fix/adr-0202-module-state into main
mesh/delivery held for a person: merged without a passing check: only a person decides that it goes on

This commit is contained in:
2026-10-04 09:01:24 +00:00
8 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
// State — the current value of something a module keeps on the bus, which every machine sees,
// including one that joins later (novox/hq ADR 0201). Not history: that is an event. Never a secret,
// including one that joins later (novox/hq ADR 0202). Not history: that is an event. Never a secret,
// sealed or not: a bucket is kept, and a machine joining a year later reads it whole.
//
// A module declares the state it keeps (`state` in its manifest) and the state of others it reads
@@ -65,7 +65,7 @@ function bound(): StateChannel {
if (!channel) {
throw new Error(
"no runtime to keep state through — a module's state is reached through the runtime that launched " +
"its bundle (novox/hq ADR 0201)",
"its bundle (novox/hq ADR 0202)",
);
}
return channel;
+2 -2
View File
@@ -71,7 +71,7 @@ function startSession(): Session {
});
const ask = (method: string, params: unknown): Promise<unknown> => askAs(`bundle-${nextOut++}`, method, params);
// The module's state (ADR 0201): each watch's changes arrive as `mesh/state` requests naming the
// The module's state (ADR 0202): each watch's changes arrive as `mesh/state` requests naming the
// watch by the id it was asked with, so its handler is registered under that id before it is asked
// — the current values arrive before the watch itself is answered.
const watches = new Map<string, (change: StateChange<unknown>) => Promise<void>>();
@@ -176,7 +176,7 @@ function startSession(): Session {
return;
}
case "mesh/state": {
// One change to a state this bundle watches (ADR 0201), answered once its handler has taken
// One change to a state this bundle watches (ADR 0202), answered once its handler has taken
// it. The runtime delivers a watch's changes one at a time, in order.
const p = request.params as { watch?: string; change?: StateChange<unknown> } | undefined;
const deliver = p?.watch !== undefined ? watches.get(String(p.watch)) : undefined;