@procedures/client 0.22.0 → 0.23.0
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/CHANGELOG.md +61 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -1
- package/dist/client/client.d.ts +10 -3
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +14 -2
- package/dist/client/client.js.map +1 -1
- package/dist/events/publisher.d.ts +9 -4
- package/dist/events/publisher.d.ts.map +1 -1
- package/dist/events/publisher.js +39 -11
- package/dist/events/publisher.js.map +1 -1
- package/dist/procedures/collection/partition.d.ts +21 -0
- package/dist/procedures/collection/partition.d.ts.map +1 -1
- package/dist/procedures/collection/partition.js +27 -0
- package/dist/procedures/collection/partition.js.map +1 -1
- package/dist/procedures/envelope.d.ts +119 -0
- package/dist/procedures/envelope.d.ts.map +1 -0
- package/dist/procedures/envelope.js +371 -0
- package/dist/procedures/envelope.js.map +1 -0
- package/dist/procedures/index.d.ts +2 -0
- package/dist/procedures/index.d.ts.map +1 -1
- package/dist/procedures/index.js +2 -0
- package/dist/procedures/index.js.map +1 -1
- package/dist/server/procedure-server.d.ts +13 -1
- package/dist/server/procedure-server.d.ts.map +1 -1
- package/dist/server/procedure-server.js +16 -2
- package/dist/server/procedure-server.js.map +1 -1
- package/dist/server/types.d.ts +11 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js.map +1 -1
- package/package.json +1 -1
- package/src/browser.ts +9 -0
- package/src/client/client.ts +17 -4
- package/src/events/publisher.ts +47 -15
- package/src/procedures/collection/partition.ts +32 -0
- package/src/procedures/envelope.ts +468 -0
- package/src/procedures/index.ts +4 -0
- package/src/server/procedure-server.ts +23 -3
- package/src/server/types.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# @procedures/client
|
|
2
2
|
|
|
3
|
+
## 0.23.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f20beb1: The task store of an MCP host gives each client a fair share of its tasks (CLI-69). Before, the sessions of one client could fill the store (CLI-51). Then each other client got `TASKS_FULL` until those tasks ended their time.
|
|
8
|
+
|
|
9
|
+
MINOR: a breaking change before 1.0. Near the limit, the store refuses a client with its share or more, also when the store has free slots. Before, the store refused a task only when it was full (decision D13).
|
|
10
|
+
|
|
11
|
+
Changed:
|
|
12
|
+
|
|
13
|
+
- The key of a task (`shareKey`) tells its client. The default `mcpTaskShareKey` gives the principal of the request, else the session. The principal of the host token is the same for each caller, so a request with only the token gets the key of its session.
|
|
14
|
+
- The share of a client is `maxStored / (k + 1)`. `k` is the number of clients with tasks in the store, the new client included.
|
|
15
|
+
- When `reserve` slots or fewer are free, a client with its share or more gets no more tasks. Its new task replaces the oldest task of its session that ended. Without such a task, the request gets the error `-32600` with the code `TASKS_FULL`, as for a full store.
|
|
16
|
+
- A client below its share gets a task while the store has a free slot. Thus one client keeps at most `maxStored - reserve` tasks, also with many sessions.
|
|
17
|
+
- The total limit (`maxStored`, 1000 by default) and the limit of 100 tasks of a session stay as they are.
|
|
18
|
+
|
|
19
|
+
Added:
|
|
20
|
+
|
|
21
|
+
- The options `reserve`, `shareKey` and `clock` of `McpTaskStore`, and of `tasks` of `createMcpHost()` and `mcpFace()`. The default `reserve` is a tenth of `maxStored`, rounded down: 100 of 1000. `reserve: 0` turns the fair share off.
|
|
22
|
+
- `mcpTaskShareKey`, and the types `McpTaskShareContext` and `McpTaskCaller`. `createTask` of the store takes the caller as its fifth argument.
|
|
23
|
+
- `MCP_TASK_LIMITS.reserveDivisor`: 10.
|
|
24
|
+
- `identify(credentials)` of `ProcedureServer`, and the optional `identify` of `RequestHandler`. It gives the principal of a request before a call, from the checks of each call. The face handler of the procedures host and the narrowed handler of `mcpFace()` give it too. The MCP face uses it for the key of a task. Thus the request hook and the authenticate function run one more time for each new task.
|
|
25
|
+
|
|
26
|
+
Migration:
|
|
27
|
+
|
|
28
|
+
- The site and MiniMongo: no change. They have no MCP host.
|
|
29
|
+
- Graph: no change. Its MCP hosts have no task store.
|
|
30
|
+
- jarvis: no change. Its MCP host has no tasks.
|
|
31
|
+
- polite-crawler-mcp: no change. Each request has the host token, so each session is one client. A session with 100 tasks gets fewer tasks only when ten or more sessions are near the limit. To keep the rule of CLI-51, give `new McpTaskStore({ reserve: 0 })`.
|
|
32
|
+
- A host whose clients each have many sessions under one principal: each client keeps at most `maxStored - reserve` tasks. To keep the rule of CLI-51, give `reserve: 0` in `tasks` of the host or in `new McpTaskStore()`.
|
|
33
|
+
- 71091a5: Added: the envelope form of a program (coeval, decisions D6, D9 and D10, roadmap item M7). A call is `{ "type": ["client", "add"], "value": input }`, and a reference is `{ "type": "ref", "value": ["names", "sum"] }`. The `$proc` form does not change.
|
|
34
|
+
|
|
35
|
+
- `fromEnvelopeProgram()` changes a program in the envelope form into the `$proc` form. `toEnvelopeProgram()` changes a `$proc` program into the envelope form. `isEnvelopeProgram()` tells which form a value has.
|
|
36
|
+
- `client.exec()` and `client.execStream()` accept a program in the envelope form at the root. `client.exec(program, input)` puts the fields of `input` over the input, as for a `$proc` program.
|
|
37
|
+
- The root decides the form. In an envelope program, a `$proc`, `$ref` or `$literal` object is data. In a `$proc` program, an envelope is data, as before.
|
|
38
|
+
- A call with the value `null` has no input. The header `name` gives `$name`. A ref reads only the root `names`, and `["names", "last"]` reads the step before.
|
|
39
|
+
- The envelope form has no `$when`. A program that needs `$when` keeps the `$proc` form.
|
|
40
|
+
- The section "The envelope form" of `PROGRAM-FORMAT.md` gives the mapping and the rules. The section "Open questions and known differences" is now section 12.
|
|
41
|
+
|
|
42
|
+
## 0.22.1
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- c931188: The publisher refuses a subscriber of a collection `a.b` with partitions and no storage when its resolver gives no partition and `a` has partitions. Before, that subscriber listened to the plain topic `collections.a.b`. That is also the topic of the partition `b` of `a`. Thus the subscriber got the events of the tenant `b` of `a`, a leak across tenants (roadmap CLI-70, decision D23).
|
|
47
|
+
|
|
48
|
+
- The refusal is `FORBIDDEN` with the reason `partition-not-allowed`, as for the other refusals of a partition.
|
|
49
|
+
- The publisher does the check at the start of the subscription, at each re-check and before each event. Thus partitions of `a` that come later also end an open subscription, before it gets an event of `a`.
|
|
50
|
+
- The check is in the one route from the topic of a subscriber to the topic of the bus. Thus each subscriber over HTTP, WebSocket or MCP gets it.
|
|
51
|
+
- The registration check of CLI-57 cannot find this pair, because the resolver gives the partition only at the call. The calls of `a.b` without a partition already failed, because `a.b` has no storage.
|
|
52
|
+
- A subscriber of `a.b` whose resolver gives a partition does not change. A subscriber of `a` does not change. A collection `a.b` without the partitions of `a` does not change.
|
|
53
|
+
|
|
54
|
+
PATCH (decision D23): the change refuses only a subscription that gets the events of another tenant. No correct subscriber can rely on it. Each other subscription behaves as before.
|
|
55
|
+
|
|
56
|
+
Migration steps:
|
|
57
|
+
|
|
58
|
+
- Does a subscriber of `a.b` get `FORBIDDEN` with the reason `partition-not-allowed`? Then make the resolver of `a.b` give a partition. Or rename `a.b` to a name without a dot, for example `a_b`.
|
|
59
|
+
- The site: no change is necessary. It serves no collection.
|
|
60
|
+
- MiniMongo: no change is necessary. Its server serves no collection.
|
|
61
|
+
- Graph: no change is necessary. Its one served collection, `examples`, has no dot in its name.
|
|
62
|
+
- jarvis: no change is necessary. Its host serves no collection.
|
|
63
|
+
|
|
3
64
|
## 0.22.0
|
|
4
65
|
|
|
5
66
|
No changes in this release.
|