@graview/ship 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,7 +70,7 @@ so a host in front of it knows what it must keep answering for `openRemote`, `gr
70
70
  | Method | Path | Says |
71
71
  |---|---|---|
72
72
  | GET | `/graview/state` | the graph, the log, the stored version and the modules on |
73
- | POST | `/graview/ops` | calls in, the ops they produced out — or `undo`, batches to take back; a `batch` already in the log is answered with the ops it made; 409 with the policy's sentence and a `reason` when refused, 429 with `Retry-After` when the host is busy |
73
+ | POST | `/graview/ops` | calls in, the ops they produced out — or `undo`, batches to take back; a `batch` the asking seat already landed is answered with the ops it made, and one that is somebody else's or not `batch:<tag>:<n>` is refused `invalid`; 409 with the policy's sentence and a `reason` when refused, 429 with `Retry-After` when the host is busy |
74
74
  | GET | `/graview/since?seq=N` | the ops appended after N — everyone else's |
75
75
  | GET | `/graview/health` | ship's own report, plus where the data is |
76
76
  | GET | `/graview/export` | the whole store as one bundle, the way out |
@@ -88,8 +88,11 @@ but health. Whatever a host asks for rides along: `openRemote({ headers })` send
88
88
  every request, and the framework never reads them. What a call came through (`via`: `web`,
89
89
  `api`, `mcp:Claude`), recorded on the op, is the host's word too: `viaOf(request, seat)` says
90
90
  it, or `SEAT_HEADERS.via` where the seat headers are trusted (`openRemote({ via })` sends it,
91
- `mcp` and `cli` from the commands). A `via` in a call's body or message is never read; without
92
- either, a socket's calls are `web` and an HTTP call's `api`. `openRemote(...).settled()` resolves once every call sent
91
+ `mcp` and `cli` from the commands). A `via` in a call's body or message is a claim, never read
92
+ on its own: `openRemote` sends the one a call was applied with (a guest view applies with
93
+ `view:<name>`), and `liveProtocol({ viaOf: (peer, claimed) => … })` lets a host judge it —
94
+ asked of every change, it answers the via to record, and nothing keeps the host's own. Without
95
+ any of these, a socket's calls are `web` and an HTTP call's `api`. `openRemote(...).settled()` resolves once every call sent
93
96
  so far has been answered — a browser never waits for it; a host that must report the
94
97
  server's verdict before it exits does.
95
98
 
@@ -109,15 +112,16 @@ counts it, and it goes again the moment the server is reached. `remote.counters(
109
112
  (`RemoteCounters`) counts `reconnects`, `rebases` (the server's ops landing under pending
110
113
  calls), `conflicts` and `resyncs`, for a beacon. Three options shape it: `backoff`, a function
111
114
  of the attempt in milliseconds or `{ min, max, factor }` for the jittered default (250, 10000,
112
- 2); `presenceEveryMs`, how often an unchanged presence is said again down the socket; and
115
+ 2); `presenceEveryMs`, a heartbeat down the socket opted into (by default the socket says
116
+ `here` only when where the client stands changes — see below); and
113
117
  `visible`, a predicate — while it answers false no presence is said, and in a page it reads
114
118
  `document.visibilityState` unless given.
115
119
 
116
120
  | From | Message | Carries |
117
121
  |---|---|---|
118
122
  | client | `hello` | `seq`, the last op it has (none: the welcome carries the whole state); `protocol`; `wire` (`LIVE_WIRE`); `build`, the host's build the page runs |
119
- | client | `call` | `cid`, `calls`, `intent`, `batch`, and `base`: the revision of each field it changes |
120
- | client | `undo` | `cid`, `batches` to take back |
123
+ | client | `call` | `cid`, `calls`, `intent`, `batch`, `base` (the revision of each field it changes), and `via`: a claim of the channel, such as a guest view's `view:<name>`, which a server records only if it accepts it |
124
+ | client | `undo` | `cid`, `batches` to take back, and a `via` claim as on `call` |
121
125
  | client | `here` / `bye` | a presence, as `/graview/here` takes it; gone |
122
126
  | server | `welcome` | `protocol`, `wire`, `version` (the declaration it serves), `build`, `participant` (this socket's own key, built from its seat), `seq` (the server's last), and the `ops` after the client's seq |
123
127
  | server | `ack` | `cid`, `batch`, `seq` and the `ops` the call made |
@@ -131,26 +135,111 @@ Seqs mean what `/graview/since?seq=N` means, and `hello` and `welcome` carry `WI
131
135
  A host on any runtime attaches a socket with `createStoreHandler(...).connect(request, { send,
132
136
  close })`, which reads the seat from the upgrade and answers with the connection to hand each
133
137
  message to; `serveStore` does this for Node's upgrade. What a seat may not see holds on the
134
- socket as on the routes.
138
+ socket as on the routes, and so does its id (FR-55): no record id the seat may not see is in
139
+ anything it is sent — a welcome, ops, an ack, a conflict, a route's answer. A seen record's
140
+ field that names a hidden one is cleared, or, when the record cannot do without that field,
141
+ the record is withheld from the seat whole; a withheld op keeps no hidden id in any
142
+ primitive. `seatLens(store, principal)` is that judgement, the one every surface reads.
135
143
 
136
144
  A host that hibernates — a Durable Object wakes on a message with no closure left — holds
137
145
  each socket's state itself. `liveProtocol({ store })` (from `@graview/ship/runtime`) is the
138
146
  same protocol as functions over the store and one plain-JSON `LiveSocketState` per socket,
139
- `{ seat, via, cursor?, participant?, held? }`, the thing `serializeAttachment` keeps:
147
+ `{ seat, via, cursor?, participant?, build?, hostBuild?, held? }`, the thing
148
+ `serializeAttachment` keeps:
140
149
 
141
150
  ```ts
142
- const live = liveProtocol({ store, version: app.version, flush });
151
+ // A seat's key outlives a wake: kept in the Durable Object's storage, never only in a map in memory.
152
+ // And it is the seat's, not the tab's: seatOfTab(principal) leaves the session out, so every tab is one key.
153
+ const keyOf = (principal) => {
154
+ const seat = seatOfTab(principal);
155
+ const key = `seat:${sha256Hex(JSON.stringify(seat)).slice(0, 24)}`;
156
+ ctx.storage.sql.exec("INSERT OR IGNORE INTO seats (key, seat) VALUES (?, ?)", key, JSON.stringify(seat));
157
+ return key;
158
+ };
159
+ const seatOf = (key) => {
160
+ const row = ctx.storage.sql.exec("SELECT seat FROM seats WHERE key = ?", key).toArray()[0];
161
+ return row ? JSON.parse(row.seat) : undefined;
162
+ };
163
+ const live = liveProtocol({ store, version: app.version, flush, seatOf });
143
164
  // On the upgrade: the seat and channel, read once (handler.seatFor(request) does this with seatOf and viaOf).
144
- ws.serializeAttachment(live.open(seat, "web"));
165
+ ws.serializeAttachment(live.open(keyOf(principal), "web", { build }));
145
166
  // On each message, after any wake:
146
- const peer = { ...ws.deserializeAttachment(), send: (text) => ws.send(text) };
167
+ const peer = { ...ws.deserializeAttachment(), send: (text) => ws.send(text), close: (code, reason) => ws.close(code, reason) };
147
168
  const { landed, presence } = await live.receive(peer, text, whoIsHere);
148
169
  const { send, ...state } = peer;
149
170
  ws.serializeAttachment(state);
150
171
  if (landed) live.publish(landed, otherPeers); // each as its own seat sees them, from its own cursor
151
172
  ```
152
173
 
174
+ `publish` and `tell` make each seat's view once, however many sockets it holds: a seat key is
175
+ resolved once, and each run of ops is redacted and written once and sent down every socket of
176
+ that seat (200 ops to 50 sockets of 5 seats: 4.7 ms, where it was 43 ms; 50 sockets of 50
177
+ seats are still 50 views). A withheld op is served under an opaque batch, `withheld:<16 hex>`,
178
+ a keyed hash of its batch — the same for every op of one batch — so a seat cannot tell which
179
+ session made a change it may not see; the seat that made it is served its own. The key is
180
+ drawn once per store held, so a host that wakes holds a new one; `liveProtocol({ withheldKey })`
181
+ keeps it the same across wakes, and is never sent to a client.
182
+
183
+ **The attachment budget.** Cloudflare refuses an attachment over 2,048 bytes, and a seat
184
+ held whole is most of that: a person with fifty roles is about 1.9 kB of state on its own.
185
+ So `seat` may be a host's key (a string) — `live.open("user:6b3f…", "web")` — which
186
+ `liveProtocol({ seatOf: (key) => principal })` resolves on every message. Keep what it reads
187
+ where a wake does not empty it — the sketch above keeps it in the Durable Object's storage; a
188
+ map in memory is empty after the first wake — and make the key from `seatOfTab(principal)`,
189
+ the seat without its session: a key with the session in it is one view per tab where it would
190
+ be one per seat. A key the host no longer resolves is told to open again (`{ t: "error",
191
+ reopen: true }` — "The host no longer knows who this socket is…"), closed with code 4000 when
192
+ the peer has a `close`, and served nothing more; `openRemote` opens a new socket, the host
193
+ reads the seat from its upgrade again, and what the tab had not had answered is sent again and
194
+ lands once. A call's `cid` is at most 64 characters (a
195
+ longer one is refused `invalid`, in words), so `held` stays small, and the client's and the
196
+ host's builds are kept to 64. The budget, held by a test: a socket's state with a seat key,
197
+ a busy call held and the host's own presence beside it stays within 1 KB (measured: 350
198
+ bytes of state, 692 with a presence), half the attachment, the rest the host's.
199
+
153
200
  `connect()` is this protocol with the state in memory, so there is one implementation.
201
+ Every `liveProtocol` option is an option of `createStoreHandler` and `serveStore` too, so a
202
+ host gets it either way: `limit`, `admit`, `build` (a string, or a function of the socket),
203
+ `minProtocol`, `minHostProtocol`, `refusal` and `withheldKey` by the same names; and, where
204
+ the handler already has a name that reads the request, the protocol's `viaOf` as
205
+ `viaClaimed` and its `seatOf` as `seatOfKey` — with `seatKey(seat)`, handed the seat without
206
+ its session (`seatOfTab`), the key a socket the
207
+ handler opens keeps in its state instead of the principal.
208
+
209
+ **An ack waits for `flush`, and a failed flush is never acked.** `flush(landed)` is handed
210
+ every op the protocol landed that is not durable yet, in seq order — what just landed, after
211
+ any a failed flush left — so a host that writes ops to a ledger writes exactly those (and
212
+ skips one it is handed again). Flushes run one at a time. When one rejects, the client is
213
+ refused `unavailable` ("Your change could not be saved just now. It is kept, and sent again
214
+ until it is."), keeps the change, and sends it again; the socket's cursor does not move,
215
+ `receive` answers no `landed`, and the ops stay in the store but are held back from every
216
+ socket until a flush holds them — the change sent again, or the next change, which hands
217
+ them over first. A change sent again after a failed flush is never made twice and never
218
+ acked before it is durable. `createStoreHandler({ store, flush })` takes the same `flush`.
219
+ **A change anybody else hears is a change that is written**: while an op's flush is under way
220
+ it is held back from every socket — pushes, and the ops a `hello` is welcomed with — and it
221
+ goes down once the flush resolves (a hibernating host publishes the `landed` that `receive`
222
+ or `post` answers; `createStoreHandler` does it itself). A flush that fails was heard by
223
+ nobody. A host without a `flush` pushes every op the moment it lands. A whole-state read
224
+ (`/graview/state`, a hello without a seq) is the store as it stands in memory.
225
+
226
+ **A host that routes its own requests** answers the routes with meaning through the same
227
+ protocol, so it keeps what `createStoreHandler` does — a batch sent again answered once, a
228
+ stale write a conflict, its `limit`, a refusal's reason, the ops as the seat may see them:
229
+
230
+ ```ts
231
+ // POST /graview/ops, in the host's own router, after it has said who is asking:
232
+ const { status, body, headers, landed } = await live.post(await request.text(), { seat, via: "api" });
233
+ if (landed) live.publish(landed, peers);
234
+ return Response.json(body, { status, headers });
235
+ // GET /graview/state and /graview/since?seq=N, as the seat sees them:
236
+ live.state({ seat, via: "api" });
237
+ live.since(seq, { seat, via: "api" });
238
+ ```
239
+
240
+ `post` answers a `WireAnswer` — `{ status, body, headers }` — and is the handler's
241
+ `POST /graview/ops`: the handler calls it, so the two answer every body the same. `WireAsked`
242
+ is who asks, `{ seat, via, build? }`.
154
243
 
155
244
  **Who is here is the server's to say.** A presence carries its `kind`, a display `name`
156
245
  and, for an agent, `onBehalfOf` (the person's id) and `onBehalfOfName`, all built from the
@@ -162,12 +251,31 @@ Somebody without a socket — an agent acting over MCP or an RPC, a polling tab
162
251
  stands until `until`. The handler does this itself for every op an agent seat lands in its
163
252
  store (`POST /graview/ops`, an MCP handler over the same store, the host's own loop), for
164
253
  `VISITOR_PRESENCE_TTL_MS`; `createStoreHandler({ announceAgents: false })` turns it off and a
165
- number sets the time. A hibernating host keeps `who` itself, with `announcePresence(who,
254
+ number sets the time. An agent that only reads lands no op, so hand `handler.onCall` to
255
+ `createMcpHttpHandler`'s `onCall` (`@graview/tools`): every tool call announces the agent seat
256
+ the same way, reads included. A hibernating host keeps `who` itself, with `announcePresence(who,
166
257
  visitorPresence(seat), ttlMs)`, and hands it to `receive` and `tell`; a visitor past its
167
- `until` is never told. Each seat is told as it may see: an agent acting for a person the
258
+ `until` is never told. `nextExpiry(who)` (from `@graview/core`) says when the next visitor
259
+ goes, in epoch ms, for the host's alarm: on it, `tell` the room again and the visitor is gone
260
+ from every map. The handler keeps that timer itself. Each seat is told as it may see: an agent acting for a person the
168
261
  seat may not see is shown without `onBehalfOf` or the name. The Shell draws it as "Claude,
169
262
  for Ada" (`presenceName`).
170
263
 
264
+ **A socket holds its presence; it needs no heartbeat.** The `here` a socket says comes back
265
+ from the server stamped `held: "socket"` (a client's own claim of it is dropped), and such a
266
+ presence stands for as long as the server lists it — `presenceStands` and `foldPresence` do
267
+ not expire it by its `at`. The host drops it when the socket closes, at once. So
268
+ `openRemote` says `here` down a socket only when where it stands changes: an idle tab says
269
+ nothing, and a hibernating host is not woken to hear it. A host that rebuilds `who` from its
270
+ own records cannot drop the stamp: `tell(who, peers)` — and `receive(peer, text, who,
271
+ peers)`, for the presence a welcome is followed by — says `held: "socket"` on every presence
272
+ whose participant one of the sockets it is handed holds, whatever the host built, and says a
273
+ visitor's `until` as the host gave it. A poller is still held by time
274
+ (the handler's own time to live) and says where it is with every poll. A client whose own socket dropped
275
+ lets the held presences it was told go after `REMOTE_PRESENCE_TTL_MS` without a list from
276
+ the server. A host that keeps a socket's presence by time can ask for the old heartbeat
277
+ with `presenceEveryMs`.
278
+
171
279
  **The declaration changes under open tabs.** A host that adds a field calls
172
280
  `handler.declarationChanged({ app })` — over an adapter the handler opens the store again
173
281
  with `openStore`, which migrates it; over a store the host holds it is handed
@@ -177,16 +285,37 @@ makes a `liveProtocol` over the new store and calls `declared(peers)`. `openRemo
177
285
  app fetches and compiles its document), opens a new remote store on the server's migrated
178
286
  state and hands it to `remote.onDeclaration((next, version) => …)`. The calls still on the
179
287
  way are offered again there under the batch they were sent in, so one the server already
180
- made is not made twice, and one that no longer fits is refused in words on
181
- `next.onRefusal`. No page reloads. A polling client learns it the same way: every answer a
288
+ made is not made twice, and one that no longer fits is refused in words on `onRefusal`. No
289
+ page reloads. A host whose own store judges by more than the declaration says — an owner
290
+ sight Graview Cloud adds — passes `localApp: (app) => app` to shape the app the browser's
291
+ store is built from, the first one and every one `resolveApp` gives, so the browser refuses
292
+ only what the server would. **The host's wiring goes with it:** every listener put on the first store —
293
+ `onRefusal`, `onConflict`, `onStatus`, `onBuild`, `presence.onWho`, `onDeclaration` — is
294
+ carried to each store that replaces it, and `counters()` run on, so a host writes its
295
+ listeners once and only swaps which store it mounts (one added again is told twice).
296
+ `presence.onWho` tells a listener added late who is here already, at once, and
297
+ `remote.who()` says it any time. A polling client learns it the same way: every answer a
182
298
  poll reads (`/graview/state`, `/graview/since`, `/graview/here`, the `/graview/ops` answer)
183
299
  says the declaration `version` and the host's `build`, and `openRemote` compares it on each.
300
+ `version` is the host's own monotonic number for the declaration it serves — `app.version`,
301
+ or a host's document version — handed to `liveProtocol({ version })` and, on the client, to
302
+ `resolveApp(version)`: it names one declaration and only ever grows. A `declaration` push or
303
+ a welcome with the number a client already serves is ignored, so a host that pushes twice
304
+ reopens nothing.
184
305
 
185
306
  **Version skew.** A host says its `build` (an opaque string) in every welcome; a page that
186
307
  said another in its hello keeps working and `remote.onBuild(…)` is told once. A host with
187
308
  `minProtocol` answers an older protocol's hello with `reload`: `openRemote` writes every
188
309
  call not yet answered to its `carry` (`{ storage, key }`, `sessionStorage` in a page),
189
310
  calls `reloadPage`, and the next `openRemote` with the same `carry` offers them again.
311
+ A host whose build differs per upgrade — the worker that carried the socket says which shell
312
+ it serves — says it per socket: `live.open(seat, via, { build })` keeps it in the socket's
313
+ state as `hostBuild`, or `liveProtocol({ build: (peer) => … })` answers it from the socket.
314
+ A host that changes its own half of the wire (its routing, its auth, its shell) numbers it:
315
+ `openRemote({ hostProtocol })` says the number in `hello.hostProtocol`, and
316
+ `liveProtocol({ minHostProtocol })` (or `createStoreHandler`'s) answers a hello below it —
317
+ absent is 0 — with `reload` carrying `hostProtocol`, so an old page reloads with its calls
318
+ carried exactly as for `minProtocol`. `hello.protocol` stays `WIRE_PROTOCOL`, ship's.
190
319
  Two codecs on one path are told apart by `hello.wire`, and by the WebSocket subprotocol
191
320
  `LIVE_SUBPROTOCOL` (`graview.ship.1`): `serveStore` answers it, a Worker answers its upgrade
192
321
  with `liveSubprotocol(request)`, and `openRemote` sends it with `subprotocol: true` or hands
@@ -198,33 +327,106 @@ field is refused, before anything is written, naming the field, theirs and yours
198
327
  `openRemote` sends one with every call and hands the refusal to `remote.onConflict(…)`,
199
328
  with `conflict.keepTheirs()` and `conflict.useMine()`.
200
329
 
330
+ **A batch is answered only to whoever made it.** A client names the batch its call lands in,
331
+ so a call sent again after a lost answer is answered with the ops it made the first time —
332
+ and only ever with the asking seat's own ops: a batch that holds somebody else's (another
333
+ person, or the same agent acting for somebody else) is refused `invalid` in words, and so is
334
+ any batch not shaped as a `Store` mints it, `batch:<tag>:<n>` or `undo:<tag>:<n>`
335
+ (`isClientBatch`). A call that names none lands in a batch the server mints outside that
336
+ shape. A host's own store mints there too with `new Store({ batchIds: serverBatchIds() })`,
337
+ so nothing a host lands itself — a migration, a seed, an agent's RPC — is in a batch a client
338
+ could have named first; `createStoreHandler` does this for the store it opens.
339
+ `authoredBy(author, seat)` is the judgement of "the same seat". A batch's tag belongs to the
340
+ first seat that landed under it, so nobody names another client's next batch
341
+ (`batch:<her tag>:<n+1>`) before she does: a batch under somebody else's tag is refused
342
+ `invalid`, and so is one under the store's own minting tag (`store.batchTag`), so even a held
343
+ store that still mints `batch:<tag>:<n>` cannot have its next batch named first. **A host
344
+ holding its own store should still give it `batchIds: serverBatchIds()`**: then its batches
345
+ are not in a client's shape at all, and a reader of the log can tell a client's from the
346
+ host's.
347
+
201
348
  **A refusal says why** (FR-46). Every `refused` on the socket, and every refusing answer of
202
349
  `POST /graview/ops` (409, or 413 at a host's cap), carries a `reason` from a closed set,
203
350
  `REFUSAL_REASONS`, which never changes meaning:
204
351
 
205
352
  | `reason` | What it means |
206
353
  |---|---|
207
- | `forbidden` | the seat may not: the policy, a sight, an agent's declared acts, a module turned off; `wouldNeed` names the roles that could, when the policy knows them |
208
- | `missing` | what the call names is not there: a record, or a batch to take back |
354
+ | `forbidden` | the seat may not: the policy, an agent's declared acts, a module turned off (for the host's own seat); `wouldNeed` names the roles that could, when the policy knows them |
355
+ | `missing` | what the call names is not there for this seat: a record that does not exist or one it may not see — answered alike, so a refusal never tells a guessed id from a real one (FR-55) — or a batch to take back |
209
356
  | `invalid` | the call as asked does not fit: its arguments, the kind, a rule, a call before `hello` |
210
357
  | `limit` | the host's hard cap: the call can never succeed as asked, however long the caller waits |
358
+ | `unavailable` | the host takes no changes for a while and cannot say how long — a room read-only while it is checked, a write to storage that failed; the one refusal that is not final |
211
359
 
212
360
  `openRemote`'s `remote.onRefusal((sentence, refusal) => …)` is handed the reason beside the
213
- sentence, and `remote.send` throws a `RemoteRefusedError` carrying it. The routes' other
361
+ sentence, and `remote.send` throws a `RemoteRefusedError` carrying it. What a person reads is
362
+ said for them (`wireRefusalOf`): arguments that do not fit field by field, in the words the
363
+ form asked in ("“Add a task” was not made: Name — …"), and an act the app does not have by
364
+ the name the call gave and no other ("This app has no act called “dance”."). A host words a
365
+ refusal itself with `liveProtocol({ refusal: (error, calls, peer) => … })`, on the socket
366
+ and through `post`: it answers the `{ reason, sentence, wouldNeed? }` to send, or nothing
367
+ for ship's. The routes' other
214
368
  refusing answers say one too: 401 `forbidden`, 404 `missing`, 400 `invalid`.
215
369
 
216
370
  **Busy is not refused** (FR-45). A host's `limit` option — on `createStoreHandler`, `serveStore`
217
371
  and `liveProtocol` — is asked of every change before it is judged, with the seat, the channel,
218
- the size in bytes and the calls. It answers nothing, `{ retryAfter }` or `{ refuse }`:
372
+ the size in bytes and the calls. It answers nothing, `{ retryAfter }`, `{ refuse }` or `{ unavailable }`:
219
373
 
220
374
  - **busy** — `{ retryAfter }` in milliseconds, for a rate or a queue: "not now". The socket says
221
375
  `busy` and HTTP answers 429 with `Retry-After`. Nothing is judged and nothing is refused:
222
376
  `openRemote` keeps the change shown and pending and sends it again after the wait. Every later
223
377
  call on that socket is busy too until the held one comes again, and HTTP posts go one at a
224
378
  time, so a burst lands in the order it was made.
379
+
380
+ **The units, loudly.** `retryAfter` — in `limit`'s answer, in the socket's `busy`, and in the
381
+ JSON body of a 429 — is **milliseconds**. The `Retry-After` header is **seconds** (or an
382
+ HTTP date), as HTTP says; ship's handler rounds the wait up to whole seconds there.
383
+ `openRemote` reads each in its own unit, and a host that puts seconds in the JSON body too
384
+ (`retryAfter: 2` beside `Retry-After: 2`) is caught: a JSON wait under 50 beside a header
385
+ that says the same number of seconds is read as those seconds.
225
386
  - **refused, `limit`** — `{ refuse }`, a sentence, for a hard cap such as a message over the
226
387
  size a host takes: it would be refused however long the client waited, so it is refused now
227
388
  and taken back.
389
+ - **refused, `unavailable`** — `{ unavailable }`, a sentence, for a spell with no known end,
390
+ such as a room read-only while it is checked. The socket says `refused` with the reason
391
+ `unavailable` and HTTP answers 503 with it. Nothing is judged and nothing is taken back:
392
+ `openRemote` keeps the change shown and pending, and sends it again after its `backoff`,
393
+ with every call made behind it, until the host takes it.
394
+
395
+ `limit` is asked only of a change that has not landed: a call sent again after it did — its
396
+ ack lost with the socket — is answered with the ops it made, whatever the host would say now.
397
+
398
+ **A cap on what a change would do is `admit`.** `limit` is asked before a change is compiled,
399
+ so it cannot count what the change would do — how many records a call removes, how many the
400
+ store would hold after it — and a host's own wrapper around its acts is gone round by the
401
+ socket and `POST /graview/ops`. `admit(asked, planned)` — on `liveProtocol`,
402
+ `createStoreHandler` and `serveStore` — is asked after the calls (or the undo) are compiled
403
+ and applied, before anything is kept, with `limit`'s `asked` and the store's own plan of the
404
+ change (`PlannedChange`, from `@graview/core`): its ops and primitives, `added`, `removed` and
405
+ `changed` records and links (a removed record's links among the links removed), and
406
+ `nodesAfter` and `edgesAfter`. No second rehearsal on a copy: it is the store's `applyAll`
407
+ asking (`ApplyOptions.admit`). Its answers mean what `limit`'s do — `{ refuse }` refused
408
+ `limit` (413), `{ retryAfter }` busy (429), `{ unavailable }` refused `unavailable` (503) — and
409
+ a change it answers is put back: not kept, not flushed, not sent to anybody.
410
+
411
+ ```ts
412
+ admit: (asked, planned) =>
413
+ asked.seat.kind === "agent" && planned.removed.nodes > 25
414
+ ? { refuse: `That would remove ${planned.removed.nodes} records; an agent may remove at most 25 in one call.` }
415
+ : planned.nodesAfter > MAX_NODES
416
+ ? { refuse: `This app holds ${MAX_NODES} records, the most an app may hold for now.` }
417
+ : undefined,
418
+ ```
419
+
420
+ **A preview is judged as its batch would be.** `store.previewAll(calls, { author, via, admit })`
421
+ takes what `applyAll` takes and runs `applyAll`'s own path on a rehearsal of the store — its
422
+ graph and log copied, nobody listening — so it refuses exactly when the apply would: the
423
+ policy, the seat's sight, an act's own guard, whatever `admit` throws. Otherwise it answers
424
+ the ops as the log would hold them, marked not kept (ids `preview:<n>`, `kept: false`), with
425
+ the rules broken after. It writes, logs and tells nothing, and spends no id the store mints next.
426
+
427
+ ```ts
428
+ const would = store.previewAll(calls, { author: seat, via, admit: (planned) => caps(seat, planned) });
429
+ ```
228
430
 
229
431
  ## The hosted-store contract
230
432
 
package/dist/handler.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { type AnySchema, type GraviewApp, type PersistenceAdapter, type Presence, type Principal, type Store } from "@graview/core";
2
- import { type Limit, type LiveConnection, type LiveSocket } from "./live.js";
3
- import { presenceSeenBy, type LiveProtocol, type LiveSocketState } from "./live-protocol.js";
1
+ import { type AnySchema, type GraviewApp, type Operation, type PersistenceAdapter, type PlannedChange, type Presence, type Principal, type Store, type MutationCall, type WireRefusal } from "@graview/core";
2
+ import { type Limit, type LimitAnswer, type LimitAsked, type LiveConnection, type LiveSocket } from "./live.js";
3
+ import { presenceSeenBy, type LiveProtocol, type LiveSocketState, type ServedSocket } from "./live-protocol.js";
4
4
  import { type OpenedStore } from "./open-store.js";
5
5
  import { SEAT_HEADERS } from "./seat-headers.js";
6
6
  import type { GraphSnapshot } from "./snapshot.js";
@@ -60,7 +60,7 @@ export declare const WIRE: readonly [{
60
60
  }, {
61
61
  readonly method: "POST";
62
62
  readonly path: "/graview/ops";
63
- readonly says: "calls in, the ops they produced out — or `undo`, batches to take back; a `batch` already in the log is answered with the ops it made; 409 with the policy's sentence and a `reason` when refused, 429 with `Retry-After` when the host is busy";
63
+ readonly says: "calls in, the ops they produced out — or `undo`, batches to take back; a `batch` the asking seat already landed is answered with the ops it made, and one that is somebody else's or not `batch:<tag>:<n>` is refused `invalid`; 409 with the policy's sentence and a `reason` when refused, 429 with `Retry-After` when the host is busy, 503 with the reason `unavailable` when it takes no changes for a while";
64
64
  }, {
65
65
  readonly method: "GET";
66
66
  readonly path: "/graview/since";
@@ -141,15 +141,48 @@ interface HandlerOptions<S extends AnySchema> {
141
141
  * `{ retryAfter }` is BUSY: the socket says `busy`, HTTP answers 429 with
142
142
  * `Retry-After`, and the client sends the change again after the wait.
143
143
  * `{ refuse }` is a hard cap: refused with reason `limit` (413 over
144
- * HTTP), and the client takes the change back.
144
+ * HTTP), and the client takes the change back. `{ unavailable }` is a
145
+ * spell with no known end: refused `unavailable` (503 over HTTP), and
146
+ * the client keeps the change and sends it again, backing off.
145
147
  */
146
148
  readonly limit?: Limit;
149
+ /**
150
+ * THE HOST'S CAPS ON WHAT A CHANGE WOULD DO: `liveProtocol`'s `admit`,
151
+ * on the socket and `POST /graview/ops`. Asked after a change is
152
+ * compiled and before anything is kept, with `limit`'s `asked` and the
153
+ * store's own plan of it; answered as `limit` is answered.
154
+ */
155
+ readonly admit?: (asked: LimitAsked, planned: PlannedChange) => LimitAnswer | undefined;
147
156
  /**
148
157
  * THE HOST'S BUILD (FR-44), an opaque string said in every welcome. A
149
158
  * client on another build keeps working and is told once, so a person
150
159
  * can reload when it suits them.
151
160
  */
152
- readonly build?: string;
161
+ readonly build?: string | ((peer: ServedSocket) => string | undefined);
162
+ /**
163
+ * WHAT A CLIENT CLAIMS ITS CHANGE CAME THROUGH, JUDGED (FR-52):
164
+ * `liveProtocol`'s `viaOf`, for the socket and every post. `viaOf` above
165
+ * reads the request; this reads a call's own `via` claim — a guest
166
+ * view's `view:<name>` — and answers the via to record, or nothing to
167
+ * keep the host's. Absent, a claim is never read.
168
+ */
169
+ readonly viaClaimed?: (peer: ServedSocket, claimed: string | undefined) => string | undefined;
170
+ /**
171
+ * A SOCKET KEEPS A KEY, NOT ITS SEAT (FR-41): `seatKey` names the seat
172
+ * `seatOf` read as a host's key, which a socket's state keeps instead of
173
+ * the principal — small enough for a Durable Object's attachment — and
174
+ * `seatOfKey` (`liveProtocol`'s `seatOf`) resolves it on every message.
175
+ * `seatKey` is handed the seat without its session (`seatOfTab`), so
176
+ * every tab of one seat holds one key and `publish` makes one view of
177
+ * it; keep what `seatOfKey` reads where a wake does not empty it. A key
178
+ * it no longer resolves is told to open again, and is opened again.
179
+ */
180
+ readonly seatKey?: (seat: Principal) => string | undefined;
181
+ readonly seatOfKey?: (key: string) => Principal | undefined;
182
+ /** A refusal in the host's words: `liveProtocol`'s `refusal`, on the socket and `POST /graview/ops`. */
183
+ readonly refusal?: (error: unknown, calls: readonly MutationCall[], peer: ServedSocket) => WireRefusal | undefined;
184
+ /** The key a withheld op's opaque batch is minted under: `liveProtocol`'s `withheldKey`, the same across wakes. */
185
+ readonly withheldKey?: string;
153
186
  /**
154
187
  * THE LOWEST LIVE PROTOCOL SERVED (FR-44). A socket whose hello says an
155
188
  * older one is answered `reload`: its client keeps what it had not sent,
@@ -157,6 +190,13 @@ interface HandlerOptions<S extends AnySchema> {
157
190
  * Absent, every protocol is served.
158
191
  */
159
192
  readonly minProtocol?: number;
193
+ /**
194
+ * THE LOWEST HOST PROTOCOL SERVED (FR-44): the host's own number for its
195
+ * half of the wire, beside `WIRE_PROTOCOL`. A socket whose hello says an
196
+ * older `hostProtocol` (`openRemote({ hostProtocol })`; absent is 0) is
197
+ * answered `reload`, as below `minProtocol`.
198
+ */
199
+ readonly minHostProtocol?: number;
160
200
  }
161
201
  /**
162
202
  * THE DECLARATION THE HOST NOW SERVES (FR-43), handed to
@@ -168,7 +208,7 @@ interface HandlerOptions<S extends AnySchema> {
168
208
  export interface DeclarationChange {
169
209
  readonly app: GraviewApp<AnySchema>;
170
210
  readonly store?: Store<AnySchema>;
171
- readonly flush?: () => Promise<void>;
211
+ readonly flush?: (landed: readonly Operation[]) => Promise<void>;
172
212
  readonly migrated?: readonly string[];
173
213
  }
174
214
  /** The handler opens its own store from an adapter: one declaration plus one adapter is a running deployment. */
@@ -198,8 +238,13 @@ export interface AdapterStoreHandlerOptions<S extends AnySchema> extends Handler
198
238
  export interface HeldStoreHandlerOptions<S extends AnySchema> extends HandlerOptions<S> {
199
239
  readonly store: Store<S>;
200
240
  readonly adapter?: never;
201
- /** Resolves once what landed is durable: a call's answer waits for it. Absent, the answer goes at once. */
202
- readonly flush?: () => Promise<void>;
241
+ /**
242
+ * Resolves once what landed is durable: a call's answer waits for it.
243
+ * Handed the ops not yet durable, in seq order (`liveProtocol`'s
244
+ * `flush`); one that rejects refuses the call `unavailable`, and the
245
+ * change is kept and sent again. Absent, the answer goes at once.
246
+ */
247
+ readonly flush?: (landed: readonly Operation[]) => Promise<void>;
203
248
  /** What opening the store migrated, in the migrations' own words: said in the state, as `openStore`'s would be. */
204
249
  readonly migrated?: readonly string[];
205
250
  }
@@ -249,6 +294,18 @@ export interface StoreHandler<S extends AnySchema> {
249
294
  * — because it is the host who knows who the seat is.
250
295
  */
251
296
  announce(presence: Presence, ttlMs?: number): void;
297
+ /**
298
+ * AN AGENT CALLED, AND IS HERE: the hook `createMcpHttpHandler`'s
299
+ * `onCall` takes (`@graview/tools`), so an agent seat is announced on
300
+ * every tool call — a read lands no op, and would otherwise leave it out
301
+ * of the room. Announced as an op of its would announce it: an agent
302
+ * seat only, for `announceAgents`' time and never when that is `false`,
303
+ * not when it holds a socket here, and for whom only to a seat that may
304
+ * see the person. Bound, so it can be handed on as it is.
305
+ */
306
+ readonly onCall: (call: {
307
+ readonly principal: Principal;
308
+ }) => void;
252
309
  /** Writes what is pending and lets the adapter go — or, over a store the host holds, writes what is pending and leaves the store open. */
253
310
  close(): Promise<void>;
254
311
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EAEd,KAAK,UAAU,EAGf,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAwC,KAAK,KAAK,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AACnH,OAAO,EAIL,cAAc,EAId,KAAK,YAAY,EACjB,KAAK,eAAe,EAErB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAa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