@cotal-ai/lang 0.23.0 → 0.25.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/README.md +68 -0
- package/dist/effects.d.ts +19 -0
- package/dist/effects.d.ts.map +1 -1
- package/dist/effects.js +23 -0
- package/dist/effects.js.map +1 -1
- package/dist/engine/bridge.d.ts +71 -0
- package/dist/engine/bridge.d.ts.map +1 -0
- package/dist/engine/bridge.js +277 -0
- package/dist/engine/bridge.js.map +1 -0
- package/dist/engine/ctx.d.ts +140 -0
- package/dist/engine/ctx.d.ts.map +1 -0
- package/dist/engine/ctx.js +834 -0
- package/dist/engine/ctx.js.map +1 -0
- package/dist/engine/frame.d.ts +69 -0
- package/dist/engine/frame.d.ts.map +1 -0
- package/dist/engine/frame.js +105 -0
- package/dist/engine/frame.js.map +1 -0
- package/dist/engine/host.d.ts +77 -0
- package/dist/engine/host.d.ts.map +1 -0
- package/dist/engine/host.js +134 -0
- package/dist/engine/host.js.map +1 -0
- package/dist/engine/worker-entry.d.ts +26 -0
- package/dist/engine/worker-entry.d.ts.map +1 -0
- package/dist/engine/worker-entry.js +175 -0
- package/dist/engine/worker-entry.js.map +1 -0
- package/dist/engine/worker.d.ts +156 -0
- package/dist/engine/worker.d.ts.map +1 -0
- package/dist/engine/worker.js +123 -0
- package/dist/engine/worker.js.map +1 -0
- package/dist/errors.d.ts +92 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +187 -2
- package/dist/errors.js.map +1 -1
- package/dist/grammar.d.ts.map +1 -1
- package/dist/grammar.js +561 -128
- package/dist/grammar.js.map +1 -1
- package/dist/index.d.ts +19 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/dist/interpret.d.ts +59 -12
- package/dist/interpret.d.ts.map +1 -1
- package/dist/interpret.js +831 -613
- package/dist/interpret.js.map +1 -1
- package/dist/journal.d.ts +218 -9
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +306 -12
- package/dist/journal.js.map +1 -1
- package/dist/keys.d.ts +39 -1
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +61 -0
- package/dist/keys.js.map +1 -1
- package/dist/library.d.ts +65 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/library.js +537 -0
- package/dist/library.js.map +1 -0
- package/dist/notify-fact.d.ts +8 -0
- package/dist/notify-fact.d.ts.map +1 -0
- package/dist/notify-fact.js +69 -0
- package/dist/notify-fact.js.map +1 -0
- package/dist/perform.d.ts +138 -0
- package/dist/perform.d.ts.map +1 -0
- package/dist/perform.js +1052 -0
- package/dist/perform.js.map +1 -0
- package/dist/pins.d.ts +102 -0
- package/dist/pins.d.ts.map +1 -0
- package/dist/pins.js +107 -0
- package/dist/pins.js.map +1 -0
- package/dist/primitives.d.ts +14 -0
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +45 -5
- package/dist/primitives.js.map +1 -1
- package/dist/sim.d.ts +24 -2
- package/dist/sim.d.ts.map +1 -1
- package/dist/sim.js +9 -1
- package/dist/sim.js.map +1 -1
- package/dist/syntax.d.ts +34 -0
- package/dist/syntax.d.ts.map +1 -0
- package/dist/syntax.js +178 -0
- package/dist/syntax.js.map +1 -0
- package/dist/transform/emit.d.ts +23 -0
- package/dist/transform/emit.d.ts.map +1 -0
- package/dist/transform/emit.js +934 -0
- package/dist/transform/emit.js.map +1 -0
- package/dist/transform/index.d.ts +34 -0
- package/dist/transform/index.d.ts.map +1 -0
- package/dist/transform/index.js +31 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/transform/scope.d.ts +58 -0
- package/dist/transform/scope.d.ts.map +1 -0
- package/dist/transform/scope.js +500 -0
- package/dist/transform/scope.js.map +1 -0
- package/dist/transform/seam.d.ts +78 -0
- package/dist/transform/seam.d.ts.map +1 -0
- package/dist/transform/seam.js +111 -0
- package/dist/transform/seam.js.map +1 -0
- package/dist/values.d.ts +35 -1
- package/dist/values.d.ts.map +1 -1
- package/dist/values.js +0 -0
- package/dist/values.js.map +1 -1
- package/package.json +9 -4
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @cotal-ai/lang
|
|
2
|
+
|
|
3
|
+
Cotal Lang, the workflow language a durable Cotal run executes: a small subset of JavaScript in
|
|
4
|
+
which every interaction with the world is one of a dozen effects and everything else is pure. This
|
|
5
|
+
package is the validator, the interpreter, the step journal, the effect interface a host
|
|
6
|
+
implements, and the simulator and dry run that exercise a program with no broker.
|
|
7
|
+
|
|
8
|
+
**Tier:** `packages/` (the standard). Depends on nothing else in the repo; it knows about effects,
|
|
9
|
+
not about NATS. The host that runs a program on the mesh is `@cotal-ai/runtime`.
|
|
10
|
+
|
|
11
|
+
**Two engines.** `run`/`resume` are the tree-walker, language version `1`, and it stays the replay
|
|
12
|
+
engine for every run recorded under it. `engine/` is version `2`: a different language, not a faster
|
|
13
|
+
one, and the one fresh driver runs execute on. Each engine stamps the pins it resolves with its own
|
|
14
|
+
version and compares a recorded version against its own, which is why `WALKER_LANGUAGE_VERSION` and
|
|
15
|
+
`ENGINE_LANGUAGE_VERSION` are two constants and `LANGUAGE_VERSION` is an alias for the current
|
|
16
|
+
language, the engine's. A record binds only under the engine that wrote it (L5008). The engine
|
|
17
|
+
requires node 22 or newer and refuses below it with L1000, an implementation limit that is
|
|
18
|
+
deliberately not in the error catalog. A host runs a program in the engine's worker thread with the
|
|
19
|
+
handler either built inside it from cloneable config, or — when the handler is a live object, as a
|
|
20
|
+
driver's is — kept in the host with the effect seam bridged over a message port (`engine/bridge.ts`).
|
|
21
|
+
|
|
22
|
+
The language is defined by [`spec/cotal-lang.md`](../../spec/cotal-lang.md) (normative; every
|
|
23
|
+
`js` block in it is validated by this package's surface suite) and its wire footprint by
|
|
24
|
+
[SPEC.md §14](../../SPEC.md#14-workflow-runs-v05). The guide is
|
|
25
|
+
[docs/workflows.md](../../docs/workflows.md).
|
|
26
|
+
|
|
27
|
+
## Use
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { validate, run, dryRun, SimHandler, Journal } from "@cotal-ai/lang";
|
|
31
|
+
|
|
32
|
+
const source = `
|
|
33
|
+
const builder = await spawn("builder")
|
|
34
|
+
const r = await turn(builder, { name: "build", deadline: "30m" })
|
|
35
|
+
log(r.status)
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
validate(source); // throws LangErrors, every refusal with code, cause, fix
|
|
39
|
+
|
|
40
|
+
const script = { turns: { build: { status: "done", at: 1 } } };
|
|
41
|
+
const plan = await dryRun(source, script); // what it would do, with no agent touched
|
|
42
|
+
|
|
43
|
+
const first = await run(source, { runId: "r-1", handler: new SimHandler(script) });
|
|
44
|
+
// first.journal.entries() is the step journal; first.pins is what a resume must be handed back.
|
|
45
|
+
|
|
46
|
+
const again = await run(source, {
|
|
47
|
+
runId: "r-1",
|
|
48
|
+
pins: first.pins,
|
|
49
|
+
journal: new Journal({ run: "r-1", entries: first.journal.entries() }),
|
|
50
|
+
handler: new SimHandler({}), // nothing is scripted: every step replays
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`run` performs effects through the `EffectHandler` you pass and records each in the `Journal`;
|
|
55
|
+
hand the same journal and pins back and the same program resumes. `SimHandler` scripts turns, asks,
|
|
56
|
+
checkpoints and events and refuses anything unscripted (L6001), so a simulation cannot silently
|
|
57
|
+
invent an answer. It does advance ONE virtual clock in the order effects are asked, so a `race` under
|
|
58
|
+
it is decided by that order and declaration order rather than by the durations the arms wrote; the
|
|
59
|
+
rule (least recorded clock, ties by declaration order) is what is applied, the clocks are the
|
|
60
|
+
simulator's.
|
|
61
|
+
|
|
62
|
+
## Suites
|
|
63
|
+
|
|
64
|
+
`pnpm test` in this directory runs every smoke: grammar, keys, journal, pins, scopes, sim,
|
|
65
|
+
interpret, fuel, dryrun, examples, options, notify-fact, migrate, semantics (the pure fragment
|
|
66
|
+
against node) and surface (the syntax table, the library tables, and that every example in the
|
|
67
|
+
reference and the guide validates).
|
|
68
|
+
`smoke/mutations/*.json` are the `pnpm mutation-proof` targets.
|
package/dist/effects.d.ts
CHANGED
|
@@ -154,6 +154,25 @@ export declare class Cancelled extends Error {
|
|
|
154
154
|
readonly reason: string;
|
|
155
155
|
constructor(reason: string);
|
|
156
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* The host is stopping before the next effect, and the program is not at fault.
|
|
159
|
+
*
|
|
160
|
+
* A driver holds a run under a lease with an absolute horizon, and it may be asked to hand the run
|
|
161
|
+
* back. Neither is a fact about the workflow: it has not failed and it has not finished, it is
|
|
162
|
+
* exactly where its journal says it is. So this is raised BEFORE an effect is begun — never once a
|
|
163
|
+
* handler has been dispatched — and it travels like {@link Cancelled} and `JournalAppendRejected`:
|
|
164
|
+
* a workflow's `try` cannot catch it. A program that could catch its host's shutdown could carry on
|
|
165
|
+
* performing effects after the horizon it was granted, which is the thing the stop exists to end.
|
|
166
|
+
*
|
|
167
|
+
* The language raises it; it never accepts it from outside. A caller answers only "should I stop,
|
|
168
|
+
* and why" — if a driver could throw the class itself it could also throw something catchable, and
|
|
169
|
+
* the guarantee would be the caller's to keep rather than the language's.
|
|
170
|
+
*/
|
|
171
|
+
export declare class RunReleased extends Error {
|
|
172
|
+
readonly reason: string;
|
|
173
|
+
readonly code = "L5012";
|
|
174
|
+
constructor(reason: string);
|
|
175
|
+
}
|
|
157
176
|
/**
|
|
158
177
|
* Raw outcome to what the program sees, computed from TODAY's source.
|
|
159
178
|
*
|
package/dist/effects.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../src/effects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,E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E,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,UAAU,CAAC,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/E,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACpE,MAAM,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpF,aAAa,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE"}
|
package/dist/effects.js
CHANGED
|
@@ -32,6 +32,29 @@ export class Cancelled extends Error {
|
|
|
32
32
|
this.name = "Cancelled";
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The host is stopping before the next effect, and the program is not at fault.
|
|
37
|
+
*
|
|
38
|
+
* A driver holds a run under a lease with an absolute horizon, and it may be asked to hand the run
|
|
39
|
+
* back. Neither is a fact about the workflow: it has not failed and it has not finished, it is
|
|
40
|
+
* exactly where its journal says it is. So this is raised BEFORE an effect is begun — never once a
|
|
41
|
+
* handler has been dispatched — and it travels like {@link Cancelled} and `JournalAppendRejected`:
|
|
42
|
+
* a workflow's `try` cannot catch it. A program that could catch its host's shutdown could carry on
|
|
43
|
+
* performing effects after the horizon it was granted, which is the thing the stop exists to end.
|
|
44
|
+
*
|
|
45
|
+
* The language raises it; it never accepts it from outside. A caller answers only "should I stop,
|
|
46
|
+
* and why" — if a driver could throw the class itself it could also throw something catchable, and
|
|
47
|
+
* the guarantee would be the caller's to keep rather than the language's.
|
|
48
|
+
*/
|
|
49
|
+
export class RunReleased extends Error {
|
|
50
|
+
reason;
|
|
51
|
+
code = "L5012";
|
|
52
|
+
constructor(reason) {
|
|
53
|
+
super(`this run was released before its next effect: ${reason}`);
|
|
54
|
+
this.reason = reason;
|
|
55
|
+
this.name = "RunReleased";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
35
58
|
/**
|
|
36
59
|
* Raw outcome to what the program sees, computed from TODAY's source.
|
|
37
60
|
*
|
package/dist/effects.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.js","sourceRoot":"","sources":["../src/effects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAiJH,kGAAkG;AAElG,+EAA+E;AAC/E,MAAM,OAAO,WAAY,SAAQ,KAAK;IAEzB;IACA;IAEA;IAJX,YACW,IAAY,EACZ,IAAY,EACrB,OAAe,EACN,MAA0C;QAEnD,KAAK,CAAC,OAAO,CAAC,CAAC;QALN,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAoC;QAGnD,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,oFAAoF;AACpF,MAAM,OAAO,SAAU,SAAQ,KAAK;IACb;IAArB,YAAqB,MAAc;QACjC,KAAK,CAAC,cAAc,MAAM,EAAE,CAAC,CAAC;QADX,WAAM,GAAN,MAAM,CAAQ;QAEjC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CACnC,GAAkB,EAClB,QAAqD;IAErD,IAAI,GAAG,CAA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F,gGAAgG;IAChG,mDAAmD;IACnD,MAAM,WAAW,GAAG,QAAQ,IAAI,MAAM,CAAC;IACvC,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,UAAU;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;IACtG,MAAM,IAAI,WAAW,CACnB,OAAO,EACP,oBAAoB,EACpB,8RAA8R,CAC/R,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The effect bridge: a run in the worker, its effects and its durable journal in the host.
|
|
3
|
+
*
|
|
4
|
+
* The module-named handler in `worker.ts` builds the whole effect path inside the thread, which is
|
|
5
|
+
* right when a handler CAN be built from cloneable config. A driver's handler cannot: it is a live
|
|
6
|
+
* object holding sockets, a mesh client and a lease-bound journal appender, and shipping any of
|
|
7
|
+
* that into the isolate that also holds the hostile program would put credentials one Compartment
|
|
8
|
+
* escape away from the code they exist to confine. This module is the other route: the handler and
|
|
9
|
+
* the durable store STAY IN THE HOST, and the thread forwards the seam over a MessagePort.
|
|
10
|
+
*
|
|
11
|
+
* WHY THIS IS SOUND, measured against the contracts rather than assumed: the durable half of the
|
|
12
|
+
* journal is `JournalStore.append(entry): Promise<void>`, awaited by `Journal.persist` before a
|
|
13
|
+
* key joins `order` and before any effect fires — an async contract, which a port hop preserves
|
|
14
|
+
* with the awaits lining up exactly as they line up over a PubAck today. Every `EffectHandler`
|
|
15
|
+
* member except `now()` is async for the same reason. What is genuinely synchronous is `now()`
|
|
16
|
+
* (a journal stamp) and the stop flag, and both go over shared memory: the stop buffer as it
|
|
17
|
+
* always has, the clock over a dedicated SharedArrayBuffer this module owns — post the request,
|
|
18
|
+
* `Atomics.wait`, read the answer. The handler's clock is injectable, so the bridge may not
|
|
19
|
+
* shortcut it with the thread's own `Date.now()`: a simulated clock bridged that way would run a
|
|
20
|
+
* program under two disagreeing times.
|
|
21
|
+
*
|
|
22
|
+
* WHAT CROSSES, and why every crossing is already fenced: effect requests, effect results, journal
|
|
23
|
+
* entries, a failure's `code`/`kind`/`message`/`detail`, and a bind's `external` — exactly the
|
|
24
|
+
* values the journal records, which the crossing rule (values.ts) fences at their write sites.
|
|
25
|
+
* Errors cross with their DOMAIN, because perform.ts grades the two domains differently: the host
|
|
26
|
+
* side stamps `"effect"` for an `EffectError` and `"host"` for anything else, and the thread
|
|
27
|
+
* rehydrates the real class so a bridged failure journals byte-for-byte as an in-process one.
|
|
28
|
+
*
|
|
29
|
+
* TWO CALLS RUN AGAINST THE ARROW, and both are part of the handler's contract rather than
|
|
30
|
+
* optional extras: `ctx.bind(external)` (the handler declaring the resource it just created —
|
|
31
|
+
* host → thread, because the journal it must reach lives in the thread; its durable append then
|
|
32
|
+
* comes straight back out to the host's store) and `signal.onCancel` (a race loser's cancellation
|
|
33
|
+
* — thread → host, fired at the mirror the host handler was given). The host never blocks its
|
|
34
|
+
* loop, which is what makes the one blocking wait in the thread safe: a `now()` posted while the
|
|
35
|
+
* host is mid-effect is answered by the port handler immediately, from a synchronous clock.
|
|
36
|
+
*/
|
|
37
|
+
import type { MessagePort } from "node:worker_threads";
|
|
38
|
+
import type { EffectHandler } from "../effects.js";
|
|
39
|
+
import type { JournalStore } from "../journal.js";
|
|
40
|
+
/** One 16-byte SharedArrayBuffer: an Int32 answer flag at 0, the Float64 clock value at 8. */
|
|
41
|
+
export declare const CLOCK_BYTES = 16;
|
|
42
|
+
/**
|
|
43
|
+
* THE THREAD'S HALF: an {@link EffectHandler} and a {@link JournalStore} over the port.
|
|
44
|
+
*
|
|
45
|
+
* Owned by the worker entry. The live `EffectContext` of every in-flight effect is kept by `seq`
|
|
46
|
+
* so a host-initiated `bind` reaches the real context (and through it, the real journal), and so
|
|
47
|
+
* a cancellation fires at the host the moment the thread's signal fires.
|
|
48
|
+
*/
|
|
49
|
+
export declare function bridgedSeam(port: MessagePort, clock: SharedArrayBuffer): {
|
|
50
|
+
handler: EffectHandler;
|
|
51
|
+
store: JournalStore;
|
|
52
|
+
};
|
|
53
|
+
export interface BridgeHost {
|
|
54
|
+
/** The buffer the thread's `now()` blocks on; hand it to the worker beside the port. */
|
|
55
|
+
readonly clock: SharedArrayBuffer;
|
|
56
|
+
/** Stop servicing. Called once the run has answered; a message after that has no run behind it. */
|
|
57
|
+
close(): void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* THE HOST'S HALF: service the thread's seam from a live handler and a live store.
|
|
61
|
+
*
|
|
62
|
+
* The context handed to the handler is rebuilt around the wire's plain data: `bind` forwards to
|
|
63
|
+
* the thread (where the journal lives) and its durable append comes back through `store.append`
|
|
64
|
+
* on this side; `signal` is a mirror the thread's cancellations flip. The host never blocks —
|
|
65
|
+
* every branch here either answers from a synchronous clock or awaits work it already owns.
|
|
66
|
+
*/
|
|
67
|
+
export declare function serviceBridge(port: MessagePort, seam: {
|
|
68
|
+
readonly handler: EffectHandler;
|
|
69
|
+
readonly store: JournalStore;
|
|
70
|
+
}): BridgeHost;
|
|
71
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/engine/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,eAAe,CAAC;AAGhE,8FAA8F;AAC9F,eAAO,MAAM,WAAW,KAAK,CAAC;AAuF9B;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,GAAG;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,CA+ExH;AAED,MAAM,WAAW,UAAU;IACzB,wFAAwF;IACxF,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,mGAAmG;IACnG,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GAAG,UAAU,CAkGpI"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The effect bridge: a run in the worker, its effects and its durable journal in the host.
|
|
3
|
+
*
|
|
4
|
+
* The module-named handler in `worker.ts` builds the whole effect path inside the thread, which is
|
|
5
|
+
* right when a handler CAN be built from cloneable config. A driver's handler cannot: it is a live
|
|
6
|
+
* object holding sockets, a mesh client and a lease-bound journal appender, and shipping any of
|
|
7
|
+
* that into the isolate that also holds the hostile program would put credentials one Compartment
|
|
8
|
+
* escape away from the code they exist to confine. This module is the other route: the handler and
|
|
9
|
+
* the durable store STAY IN THE HOST, and the thread forwards the seam over a MessagePort.
|
|
10
|
+
*
|
|
11
|
+
* WHY THIS IS SOUND, measured against the contracts rather than assumed: the durable half of the
|
|
12
|
+
* journal is `JournalStore.append(entry): Promise<void>`, awaited by `Journal.persist` before a
|
|
13
|
+
* key joins `order` and before any effect fires — an async contract, which a port hop preserves
|
|
14
|
+
* with the awaits lining up exactly as they line up over a PubAck today. Every `EffectHandler`
|
|
15
|
+
* member except `now()` is async for the same reason. What is genuinely synchronous is `now()`
|
|
16
|
+
* (a journal stamp) and the stop flag, and both go over shared memory: the stop buffer as it
|
|
17
|
+
* always has, the clock over a dedicated SharedArrayBuffer this module owns — post the request,
|
|
18
|
+
* `Atomics.wait`, read the answer. The handler's clock is injectable, so the bridge may not
|
|
19
|
+
* shortcut it with the thread's own `Date.now()`: a simulated clock bridged that way would run a
|
|
20
|
+
* program under two disagreeing times.
|
|
21
|
+
*
|
|
22
|
+
* WHAT CROSSES, and why every crossing is already fenced: effect requests, effect results, journal
|
|
23
|
+
* entries, a failure's `code`/`kind`/`message`/`detail`, and a bind's `external` — exactly the
|
|
24
|
+
* values the journal records, which the crossing rule (values.ts) fences at their write sites.
|
|
25
|
+
* Errors cross with their DOMAIN, because perform.ts grades the two domains differently: the host
|
|
26
|
+
* side stamps `"effect"` for an `EffectError` and `"host"` for anything else, and the thread
|
|
27
|
+
* rehydrates the real class so a bridged failure journals byte-for-byte as an in-process one.
|
|
28
|
+
*
|
|
29
|
+
* TWO CALLS RUN AGAINST THE ARROW, and both are part of the handler's contract rather than
|
|
30
|
+
* optional extras: `ctx.bind(external)` (the handler declaring the resource it just created —
|
|
31
|
+
* host → thread, because the journal it must reach lives in the thread; its durable append then
|
|
32
|
+
* comes straight back out to the host's store) and `signal.onCancel` (a race loser's cancellation
|
|
33
|
+
* — thread → host, fired at the mirror the host handler was given). The host never blocks its
|
|
34
|
+
* loop, which is what makes the one blocking wait in the thread safe: a `now()` posted while the
|
|
35
|
+
* host is mid-effect is answered by the port handler immediately, from a synchronous clock.
|
|
36
|
+
*/
|
|
37
|
+
import { EffectError } from "../effects.js";
|
|
38
|
+
/** One 16-byte SharedArrayBuffer: an Int32 answer flag at 0, the Float64 clock value at 8. */
|
|
39
|
+
export const CLOCK_BYTES = 16;
|
|
40
|
+
/** The ten async members of {@link EffectHandler}, the only methods the bridge will forward. */
|
|
41
|
+
const METHODS = [
|
|
42
|
+
"spawn",
|
|
43
|
+
"turn",
|
|
44
|
+
"ask",
|
|
45
|
+
"checkpoint",
|
|
46
|
+
"sleep",
|
|
47
|
+
"wait",
|
|
48
|
+
"notify",
|
|
49
|
+
"monitor",
|
|
50
|
+
"openConclave",
|
|
51
|
+
"closeConclave",
|
|
52
|
+
];
|
|
53
|
+
function flatten(e) {
|
|
54
|
+
if (e instanceof EffectError) {
|
|
55
|
+
return {
|
|
56
|
+
domain: "effect",
|
|
57
|
+
name: e.name,
|
|
58
|
+
message: e.message,
|
|
59
|
+
code: e.code,
|
|
60
|
+
kind: e.kind,
|
|
61
|
+
...(e.detail !== undefined ? { detail: e.detail } : {}),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const err = e;
|
|
65
|
+
return {
|
|
66
|
+
domain: "host",
|
|
67
|
+
name: typeof err?.name === "string" ? err.name : "Error",
|
|
68
|
+
message: typeof err?.message === "string" ? err.message : String(e),
|
|
69
|
+
...(typeof err?.code === "string" ? { code: err.code } : {}),
|
|
70
|
+
...(err?.indeterminate === true ? { indeterminate: true } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The thread's side of a flattened error, as the class the grading site expects.
|
|
75
|
+
*
|
|
76
|
+
* An `"effect"` failure becomes the real `EffectError`, because perform.ts records it as the
|
|
77
|
+
* step's outcome; a `"host"` failure becomes a plain Error carrying whatever identifying fields
|
|
78
|
+
* crossed, because the host domain is graded on shape, not class, and `indeterminate` must survive
|
|
79
|
+
* for the journal's L5010 text to say the honest thing about an append nobody saw land.
|
|
80
|
+
*/
|
|
81
|
+
function rehydrate(w) {
|
|
82
|
+
if (w.domain === "effect")
|
|
83
|
+
return new EffectError(w.code ?? "L4000", w.kind ?? "handler-fault", w.message, w.detail);
|
|
84
|
+
const e = new Error(w.message);
|
|
85
|
+
e.name = w.name;
|
|
86
|
+
if (w.code !== undefined)
|
|
87
|
+
e.code = w.code;
|
|
88
|
+
if (w.indeterminate === true)
|
|
89
|
+
e.indeterminate = true;
|
|
90
|
+
return e;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* THE THREAD'S HALF: an {@link EffectHandler} and a {@link JournalStore} over the port.
|
|
94
|
+
*
|
|
95
|
+
* Owned by the worker entry. The live `EffectContext` of every in-flight effect is kept by `seq`
|
|
96
|
+
* so a host-initiated `bind` reaches the real context (and through it, the real journal), and so
|
|
97
|
+
* a cancellation fires at the host the moment the thread's signal fires.
|
|
98
|
+
*/
|
|
99
|
+
export function bridgedSeam(port, clock) {
|
|
100
|
+
const flag = new Int32Array(clock, 0, 1);
|
|
101
|
+
const value = new Float64Array(clock, 8, 1);
|
|
102
|
+
let seq = 0;
|
|
103
|
+
const pending = new Map();
|
|
104
|
+
const live = new Map();
|
|
105
|
+
port.on("message", (m) => {
|
|
106
|
+
if (m.kind === "answer") {
|
|
107
|
+
const p = pending.get(m.seq);
|
|
108
|
+
// An answer nobody is waiting for is a protocol disagreement, not a value to drop quietly.
|
|
109
|
+
if (p === undefined)
|
|
110
|
+
throw new Error(`cotal-lang effect bridge: the host answered seq ${m.seq}, which this thread never asked`);
|
|
111
|
+
pending.delete(m.seq);
|
|
112
|
+
live.delete(m.seq);
|
|
113
|
+
if (m.ok)
|
|
114
|
+
p.resolve(m.value);
|
|
115
|
+
else
|
|
116
|
+
p.reject(rehydrate(m.error));
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (m.kind === "bind") {
|
|
120
|
+
const ctx = live.get(m.seq);
|
|
121
|
+
if (ctx === undefined) {
|
|
122
|
+
// The effect settled between the handler's bind and this message arriving. The handler's
|
|
123
|
+
// own await of `bind` is what carries the refusal; answering is all this side can do.
|
|
124
|
+
port.postMessage({ kind: "bind-answer", bseq: m.bseq, error: { domain: "host", name: "Error", message: `effect ${m.seq} is no longer in flight; its bind cannot reach the journal` } });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
void ctx.bind(m.external).then(() => port.postMessage({ kind: "bind-answer", bseq: m.bseq }), (e) => port.postMessage({ kind: "bind-answer", bseq: m.bseq, error: flatten(e) }));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
throw new Error(`cotal-lang effect bridge: the host sent a message kind this thread does not know (${String(m.kind)})`);
|
|
131
|
+
});
|
|
132
|
+
const call = (method, req, ctx) => {
|
|
133
|
+
const s = seq++;
|
|
134
|
+
live.set(s, ctx);
|
|
135
|
+
ctx.signal.onCancel((reason) => port.postMessage({ kind: "cancel", seq: s, reason }));
|
|
136
|
+
const answer = new Promise((resolve, reject) => pending.set(s, { resolve, reject }));
|
|
137
|
+
port.postMessage({
|
|
138
|
+
kind: "effect",
|
|
139
|
+
seq: s,
|
|
140
|
+
method,
|
|
141
|
+
req,
|
|
142
|
+
ctx: {
|
|
143
|
+
key: ctx.key,
|
|
144
|
+
requestId: ctx.requestId,
|
|
145
|
+
attempt: ctx.attempt,
|
|
146
|
+
...(ctx.resume !== undefined ? { resume: ctx.resume } : {}),
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
return answer;
|
|
150
|
+
};
|
|
151
|
+
const handler = {
|
|
152
|
+
// The flag is cleared BEFORE the request is posted, so a host that answers before this thread
|
|
153
|
+
// reaches the wait leaves the flag already flipped and the wait returns "not-equal" at once.
|
|
154
|
+
now() {
|
|
155
|
+
Atomics.store(flag, 0, 0);
|
|
156
|
+
port.postMessage({ kind: "now" });
|
|
157
|
+
Atomics.wait(flag, 0, 0);
|
|
158
|
+
return value[0];
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
for (const m of METHODS) {
|
|
162
|
+
handler[m] = (req, ctx) => call(m, req, ctx);
|
|
163
|
+
}
|
|
164
|
+
const store = {
|
|
165
|
+
append(entry) {
|
|
166
|
+
const s = seq++;
|
|
167
|
+
const answer = new Promise((resolve, reject) => pending.set(s, { resolve: () => resolve(), reject }));
|
|
168
|
+
port.postMessage({ kind: "append", seq: s, entry });
|
|
169
|
+
return answer;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
return { handler, store };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* THE HOST'S HALF: service the thread's seam from a live handler and a live store.
|
|
176
|
+
*
|
|
177
|
+
* The context handed to the handler is rebuilt around the wire's plain data: `bind` forwards to
|
|
178
|
+
* the thread (where the journal lives) and its durable append comes back through `store.append`
|
|
179
|
+
* on this side; `signal` is a mirror the thread's cancellations flip. The host never blocks —
|
|
180
|
+
* every branch here either answers from a synchronous clock or awaits work it already owns.
|
|
181
|
+
*/
|
|
182
|
+
export function serviceBridge(port, seam) {
|
|
183
|
+
const clock = new SharedArrayBuffer(CLOCK_BYTES);
|
|
184
|
+
const flag = new Int32Array(clock, 0, 1);
|
|
185
|
+
const value = new Float64Array(clock, 8, 1);
|
|
186
|
+
let bseq = 0;
|
|
187
|
+
const binds = new Map();
|
|
188
|
+
const cancels = new Map();
|
|
189
|
+
port.on("message", (m) => {
|
|
190
|
+
if (m.kind === "now") {
|
|
191
|
+
value[0] = seam.handler.now();
|
|
192
|
+
Atomics.store(flag, 0, 1);
|
|
193
|
+
Atomics.notify(flag, 0);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (m.kind === "append") {
|
|
197
|
+
void seam.store.append(m.entry).then(() => port.postMessage({ kind: "answer", seq: m.seq, ok: true, value: undefined }), (e) => port.postMessage({ kind: "answer", seq: m.seq, ok: false, error: flatten(e) }));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (m.kind === "effect") {
|
|
201
|
+
const seqHere = m.seq;
|
|
202
|
+
let cancelled = false;
|
|
203
|
+
let reason;
|
|
204
|
+
const listeners = [];
|
|
205
|
+
cancels.set(seqHere, {
|
|
206
|
+
fire: (r) => {
|
|
207
|
+
cancelled = true;
|
|
208
|
+
reason = r;
|
|
209
|
+
for (const fn of listeners)
|
|
210
|
+
fn(r);
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
const ctx = {
|
|
214
|
+
key: m.ctx.key,
|
|
215
|
+
requestId: m.ctx.requestId,
|
|
216
|
+
attempt: m.ctx.attempt,
|
|
217
|
+
...(m.ctx.resume !== undefined ? { resume: m.ctx.resume } : {}),
|
|
218
|
+
signal: {
|
|
219
|
+
get cancelled() {
|
|
220
|
+
return cancelled;
|
|
221
|
+
},
|
|
222
|
+
get reason() {
|
|
223
|
+
return reason;
|
|
224
|
+
},
|
|
225
|
+
onCancel(fn) {
|
|
226
|
+
listeners.push(fn);
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
bind: (external) => {
|
|
230
|
+
const b = bseq++;
|
|
231
|
+
const answer = new Promise((resolve, reject) => binds.set(b, { resolve, reject }));
|
|
232
|
+
port.postMessage({ kind: "bind", bseq: b, seq: seqHere, external });
|
|
233
|
+
return answer;
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
const method = seam.handler[m.method];
|
|
237
|
+
// The method set is this module's own constant, so an unknown name is the two sides
|
|
238
|
+
// disagreeing about the protocol — refused as an answer, never dispatched dynamically.
|
|
239
|
+
if (!METHODS.includes(m.method) || typeof method !== "function") {
|
|
240
|
+
port.postMessage({ kind: "answer", seq: seqHere, ok: false, error: { domain: "host", name: "Error", message: `the effect bridge does not forward "${String(m.method)}"` } });
|
|
241
|
+
cancels.delete(seqHere);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
void method.call(seam.handler, m.req, ctx).then((v) => {
|
|
245
|
+
cancels.delete(seqHere);
|
|
246
|
+
port.postMessage({ kind: "answer", seq: seqHere, ok: true, value: v });
|
|
247
|
+
}, (e) => {
|
|
248
|
+
cancels.delete(seqHere);
|
|
249
|
+
port.postMessage({ kind: "answer", seq: seqHere, ok: false, error: flatten(e) });
|
|
250
|
+
});
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (m.kind === "cancel") {
|
|
254
|
+
// A cancel finds its mirror only while the effect is in flight: the answer deletes the
|
|
255
|
+
// mirror, so the walker's post-settle blanket cancellations (aimed at arms that already
|
|
256
|
+
// returned) do not cross. Deliberate, and pinned by the engine suite's parked-loser cells:
|
|
257
|
+
// the host handler hears a cancel exactly when its effect is still open, which is the only
|
|
258
|
+
// time it can act on one.
|
|
259
|
+
cancels.get(m.seq)?.fire(m.reason);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (m.kind === "bind-answer") {
|
|
263
|
+
const b = binds.get(m.bseq);
|
|
264
|
+
if (b === undefined)
|
|
265
|
+
throw new Error(`cotal-lang effect bridge: the thread answered bind ${m.bseq}, which this host never asked`);
|
|
266
|
+
binds.delete(m.bseq);
|
|
267
|
+
if (m.error === undefined)
|
|
268
|
+
b.resolve();
|
|
269
|
+
else
|
|
270
|
+
b.reject(rehydrate(m.error));
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
throw new Error(`cotal-lang effect bridge: the thread sent a message kind this host does not know (${String(m.kind)})`);
|
|
274
|
+
});
|
|
275
|
+
return { clock, close: () => port.close() };
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/engine/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,8FAA8F;AAC9F,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B,gGAAgG;AAChG,MAAM,OAAO,GAAG;IACd,OAAO;IACP,MAAM;IACN,KAAK;IACL,YAAY;IACZ,OAAO;IACP,MAAM;IACN,QAAQ;IACR,SAAS;IACT,cAAc;IACd,eAAe;CACP,CAAC;AAmCX,SAAS,OAAO,CAAC,CAAU;IACzB,IAAI,CAAC,YAAY,WAAW,EAAE,CAAC;QAC7B,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,GAAG,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxD,CAAC;IACJ,CAAC;IACD,MAA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