@inhuman.tools/plexus-expectations 0.1.0 → 0.3.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/dist/driver/actor-machine.d.ts +1 -1
- package/dist/driver/actor-machine.d.ts.map +1 -1
- package/dist/executor/kernel-intern.d.ts.map +1 -1
- package/dist/executor/kernel-intern.js +11 -5
- package/dist/executor/kernel-intern.js.map +1 -1
- package/dist/executor/orchestrator.d.ts +1 -0
- package/dist/executor/orchestrator.d.ts.map +1 -1
- package/dist/executor/orchestrator.js +18 -7
- package/dist/executor/orchestrator.js.map +1 -1
- package/package.json +10 -10
- package/src/executor/kernel-intern.ts +12 -5
- package/src/executor/orchestrator.ts +15 -7
- package/dist/driver/PEWDriverConnection.d.ts +0 -139
- package/dist/driver/PEWDriverConnection.d.ts.map +0 -1
- package/dist/driver/PEWDriverConnection.js +0 -298
- package/dist/driver/PEWDriverConnection.js.map +0 -1
- package/dist/error-with-invariant.d.ts +0 -9
- package/dist/error-with-invariant.d.ts.map +0 -1
- package/dist/error-with-invariant.js +0 -12
- package/dist/error-with-invariant.js.map +0 -1
- package/dist/shared/attention.d.ts +0 -27
- package/dist/shared/attention.d.ts.map +0 -1
- package/dist/shared/attention.js +0 -116
- package/dist/shared/attention.js.map +0 -1
- package/dist/shared/models/ApprovableExpectation.d.ts +0 -15
- package/dist/shared/models/ApprovableExpectation.d.ts.map +0 -1
- package/dist/shared/models/ApprovableExpectation.js +0 -138
- package/dist/shared/models/ApprovableExpectation.js.map +0 -1
- package/dist/shared/models/IntrospectingPlexusModel.d.ts +0 -8
- package/dist/shared/models/IntrospectingPlexusModel.d.ts.map +0 -1
- package/dist/shared/models/IntrospectingPlexusModel.js +0 -48
- package/dist/shared/models/IntrospectingPlexusModel.js.map +0 -1
- package/dist/shared/models/ProgrammaticJob.d.ts +0 -6
- package/dist/shared/models/ProgrammaticJob.d.ts.map +0 -1
- package/dist/shared/models/ProgrammaticJob.js +0 -80
- package/dist/shared/models/ProgrammaticJob.js.map +0 -1
- package/dist/shared/models/WorkExpectationWithIntrospection.d.ts +0 -4
- package/dist/shared/models/WorkExpectationWithIntrospection.d.ts.map +0 -1
- package/dist/shared/models/WorkExpectationWithIntrospection.js +0 -28
- package/dist/shared/models/WorkExpectationWithIntrospection.js.map +0 -1
- package/dist/shared/resolution.d.ts +0 -39
- package/dist/shared/resolution.d.ts.map +0 -1
- package/dist/shared/resolution.js +0 -124
- package/dist/shared/resolution.js.map +0 -1
|
@@ -22,7 +22,7 @@ export declare const expectationActorMachine: import("xstate").StateMachine<impo
|
|
|
22
22
|
readonly aborted: {};
|
|
23
23
|
readonly released: {};
|
|
24
24
|
};
|
|
25
|
-
}>;
|
|
25
|
+
}, import("xstate").MetaObject>;
|
|
26
26
|
export type ActorPhase = StateValueFrom<typeof expectationActorMachine>;
|
|
27
27
|
export type ActorPhaseEvent = EventFromLogic<typeof expectationActorMachine>;
|
|
28
28
|
//# sourceMappingURL=actor-machine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor-machine.d.ts","sourceRoot":"","sources":["../../src/driver/actor-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB;UAEV,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS
|
|
1
|
+
{"version":3,"file":"actor-machine.d.ts","sourceRoot":"","sources":["../../src/driver/actor-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB;UAEV,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS;;;;;;;;;;+BAiC1E,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel-intern.d.ts","sourceRoot":"","sources":["../../src/executor/kernel-intern.ts"],"names":[],"mappings":"AAWA,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AASzE,KAAK,UAAU,GAAG;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"kernel-intern.d.ts","sourceRoot":"","sources":["../../src/executor/kernel-intern.ts"],"names":[],"mappings":"AAWA,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AASzE,KAAK,UAAU,GAAG;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC,CAAA;CAAE,CAAC;AAYvF,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,GAC9C,OAAO,CAAC,SAAS,CAAC,CA2CpB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAG3F;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB5F;AAED,wFAAwF;AACxF,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAa7D"}
|
|
@@ -21,10 +21,16 @@ export function acquireConnection(kernel, owner, connectionId, construct) {
|
|
|
21
21
|
existing.refs.add(owner);
|
|
22
22
|
return existing.pending;
|
|
23
23
|
}
|
|
24
|
+
const created = Promise.resolve().then(construct);
|
|
24
25
|
const lease = {
|
|
25
26
|
refs: new Set([owner]),
|
|
26
|
-
|
|
27
|
+
created,
|
|
28
|
+
pending: created.then((instance) => {
|
|
29
|
+
if (bag.connections.get(connectionId) !== lease)
|
|
30
|
+
throw new ConnectionMiss("connection-dropped", `connection ${connectionId} dropped during construction`);
|
|
27
31
|
lease.mirror = reaction(() => {
|
|
32
|
+
if (bag.connections.get(connectionId) !== lease)
|
|
33
|
+
return null;
|
|
28
34
|
const spec = kernel.connections[connectionId];
|
|
29
35
|
if (spec === undefined)
|
|
30
36
|
return null;
|
|
@@ -34,7 +40,7 @@ export function acquireConnection(kernel, owner, connectionId, construct) {
|
|
|
34
40
|
return null;
|
|
35
41
|
return { ready, error: instance.error, live: extraLiveFromState(instance.state) };
|
|
36
42
|
}, (snap) => {
|
|
37
|
-
if (snap == null)
|
|
43
|
+
if (snap == null || bag.connections.get(connectionId) !== lease)
|
|
38
44
|
return;
|
|
39
45
|
kernel.connections[connectionId]?.stampProcess({
|
|
40
46
|
readyState: snap.ready,
|
|
@@ -48,7 +54,7 @@ export function acquireConnection(kernel, owner, connectionId, construct) {
|
|
|
48
54
|
};
|
|
49
55
|
bag.connections.set(connectionId, lease);
|
|
50
56
|
void lease.pending.then(undefined, () => {
|
|
51
|
-
if (lease.refs.size === 0)
|
|
57
|
+
if (lease.refs.size === 0 && bag.connections.get(connectionId) === lease)
|
|
52
58
|
bag.connections.delete(connectionId);
|
|
53
59
|
});
|
|
54
60
|
return lease.pending;
|
|
@@ -74,7 +80,7 @@ export async function dropConnection(kernel, connectionId) {
|
|
|
74
80
|
const owners = [...lease.refs];
|
|
75
81
|
lease.refs.clear();
|
|
76
82
|
const miss = new ConnectionMiss("connection-dropped", `connection ${connectionId} dropped`);
|
|
77
|
-
const disposing = lease.
|
|
83
|
+
const disposing = lease.created.then((instance) => {
|
|
78
84
|
instance.abortOnDrop(miss);
|
|
79
85
|
return instance[Symbol.asyncDispose]();
|
|
80
86
|
}, () => { });
|
|
@@ -91,7 +97,7 @@ export function disposeKernelConnections(kernel) {
|
|
|
91
97
|
for (const lease of bag.connections.values()) {
|
|
92
98
|
lease.refs.clear();
|
|
93
99
|
lease.mirror?.();
|
|
94
|
-
void lease.
|
|
100
|
+
void lease.created.then((instance) => instance[Symbol.asyncDispose](), () => { });
|
|
95
101
|
}
|
|
96
102
|
bag.connections.clear();
|
|
97
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel-intern.js","sourceRoot":"","sources":["../../src/executor/kernel-intern.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAA0B,MAAM,MAAM,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAkB,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,OAAQ,KAAqB,CAAC,gBAAgB,KAAK,UAAU,CAAC,CAAC,CAAE,KAAqB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5G,CAAC;
|
|
1
|
+
{"version":3,"file":"kernel-intern.js","sourceRoot":"","sources":["../../src/executor/kernel-intern.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAA0B,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G,KAAK,CAAC,OAAO,CAAC,IAAI,CAClC,CAAC,QAAQ,EAAE,EAAE;QACX,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;IACzC,CAAC,EACD,GAAG,EAAE,GAAE,CAAC,CACT,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,aAAa,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACjF,MAAM,SAAS,CAAC;AAClB,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,wBAAwB,CAAC,MAAc;IACrD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO;IACxC,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACnB,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,CACrB,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,EAC7C,GAAG,EAAE,GAAE,CAAC,CACT,CAAC;IACJ,CAAC;IACD,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["/**\n * Process-local connection intern table keyed by the kernel root object.\n *\n * Session wrap is Yjs load. Park drops an owner ref and must not dispose the\n * instance — {@link disposeKernelConnections} is kernel teardown only.\n * Rejected: last-ref dispose. Switching seats reminted every driver.\n */\nimport { DefaultedWeakMap } from \"@here.build/collections\";\nimport { comparer, reaction, type IReactionDisposer } from \"mobx\";\n\nimport { ConnectionMiss } from \"../driver/connection-miss.js\";\nimport { extraLiveFromState, type PEWDriver } from \"../driver/PEWDriver.js\";\nimport type { ConnectionSpec } from \"../shared/models/ConnectionSpec.js\";\nimport { asReadyState } from \"../shared/types.js\";\n\ntype InternOwner = { forgetConnection(id: string): void };\n\nfunction internOwnerOf(owner: object): InternOwner | undefined {\n return typeof (owner as InternOwner).forgetConnection === \"function\" ? (owner as InternOwner) : undefined;\n}\n\ntype KernelRoot = { readonly connections: Record<string, ConnectionSpec | undefined> };\ntype ConnectionHold = {\n readonly refs: Set<object>;\n /** Raw construction remains disposable even when the consumer lease is revoked. */\n readonly created: Promise<PEWDriver>;\n readonly pending: Promise<PEWDriver>;\n mirror: IReactionDisposer | undefined;\n};\ntype KernelIntern = { readonly connections: Map<string, ConnectionHold> };\n\nconst internByKernel = new DefaultedWeakMap<object, KernelIntern>(() => ({ connections: new Map() }));\n\nexport function acquireConnection(\n kernel: KernelRoot,\n owner: object,\n connectionId: string,\n construct: () => PEWDriver | Promise<PEWDriver>,\n): Promise<PEWDriver> {\n const bag = internByKernel.get(kernel);\n const existing = bag.connections.get(connectionId);\n if (existing !== undefined) {\n existing.refs.add(owner);\n return existing.pending;\n }\n const created = Promise.resolve().then(construct);\n const lease: ConnectionHold = {\n refs: new Set([owner]),\n created,\n pending: created.then((instance) => {\n if (bag.connections.get(connectionId) !== lease)\n throw new ConnectionMiss(\"connection-dropped\", `connection ${connectionId} dropped during construction`);\n lease.mirror = reaction(\n () => {\n if (bag.connections.get(connectionId) !== lease) return null;\n const spec = kernel.connections[connectionId];\n if (spec === undefined) return null;\n const ready = asReadyState(instance.readyState);\n // Bootstrapping remint must not wipe a ready catalog.\n if (ready !== \"ready\" && ready !== \"failed\" && spec.readyState === \"ready\") return null;\n return { ready, error: instance.error, live: extraLiveFromState(instance.state) };\n },\n (snap) => {\n if (snap == null || bag.connections.get(connectionId) !== lease) return;\n kernel.connections[connectionId]?.stampProcess({\n readyState: snap.ready,\n error: snap.error,\n live: snap.live,\n });\n },\n { fireImmediately: true, equals: comparer.structural },\n );\n return instance;\n }),\n mirror: undefined,\n };\n bag.connections.set(connectionId, lease);\n void lease.pending.then(undefined, () => {\n if (lease.refs.size === 0 && bag.connections.get(connectionId) === lease) bag.connections.delete(connectionId);\n });\n return lease.pending;\n}\n\nexport function releaseConnection(kernel: object, owner: object, connectionId: string): void {\n if (!internByKernel.has(kernel)) return;\n internByKernel.get(kernel).connections.get(connectionId)?.refs.delete(owner);\n}\n\n/**\n * Remint door. Logout/drop — not park, not last-ref.\n * Pending lease still `asyncDispose`s when it fulfills. Next `ensure` remints.\n */\nexport async function dropConnection(kernel: KernelRoot, connectionId: string): Promise<void> {\n if (!internByKernel.has(kernel)) return;\n const bag = internByKernel.get(kernel);\n const lease = bag.connections.get(connectionId);\n if (lease === undefined) return;\n bag.connections.delete(connectionId);\n lease.mirror?.();\n const owners = [...lease.refs];\n lease.refs.clear();\n const miss = new ConnectionMiss(\"connection-dropped\", `connection ${connectionId} dropped`);\n const disposing = lease.created.then(\n (instance) => {\n instance.abortOnDrop(miss);\n return instance[Symbol.asyncDispose]();\n },\n () => {},\n );\n for (const owner of owners) internOwnerOf(owner)?.forgetConnection(connectionId);\n await disposing;\n}\n\n/** Kernel teardown only. Session park is a document wrap, not a connection lifetime. */\nexport function disposeKernelConnections(kernel: object): void {\n if (!internByKernel.has(kernel)) return;\n const bag = internByKernel.get(kernel);\n internByKernel.delete(kernel);\n for (const lease of bag.connections.values()) {\n lease.refs.clear();\n lease.mirror?.();\n void lease.created.then(\n (instance) => instance[Symbol.asyncDispose](),\n () => {},\n );\n }\n bag.connections.clear();\n}\n"]}
|
|
@@ -57,6 +57,7 @@ export declare abstract class Orchestrator<K extends KernelPlexus = KernelPlexus
|
|
|
57
57
|
* completes the job right after.
|
|
58
58
|
*/
|
|
59
59
|
protected stampCrash(_job: Job, _phase: "license" | "body", _detail: string): void;
|
|
60
|
+
protected get canApplyResults(): boolean;
|
|
60
61
|
/** In-flight claimed Jobs (handler has not `finally`'d). */
|
|
61
62
|
protected inFlightJobs(): Iterable<Job>;
|
|
62
63
|
/** Abort an in-flight executor. No-op if the job is not claimed here. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/executor/orchestrator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAG1B,KAAK,SAAS,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAE9C,OAAO,EAAE,KAAK,kBAAkB,EAAE,eAAe,EAAgB,MAAM,qCAAqC,CAAC;AAC7G,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE3E,4EAA4E;AAC5E,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,8BAAsB,YAAY,CAChC,CAAC,SAAS,YAAY,GAAG,YAAY,EACrC,CAAC,SAAS,aAAa,GAAG,aAAa,CACvC,YAAW,UAAU;;aA2BH,MAAM,EAAE,CAAC;aACT,OAAO,EAAE,CAAC;IAV5B;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,iBAAiB,6CAAkC;gBAIpD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC;IA+C5B,SAAS,KAAK,aAAa,IAAI,GAAG,EAAE,CAUnC;IAED;;;;;;OAMG;IACH,gBAAgB,CAAC,CAAC,SAAS,GAAG,EAC5B,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EACxB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AW,EAAE,eAAe,GAAG,SAAS,GAAG,SAAS;IAIjE,OAAO,CAAC,CAAC,SAAS,kBAAkB,EAAE,WAAW,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS;IA4EtF,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAIhD,wEAAwE;IACxE,SAAS,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAIlD,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAMlC,kFAAkF;IAClF,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;;OAGG;IACH,QAAQ,IAAI,IAAI;IAOhB;;;OAGG;IACH,SAAS,CAAC,aAAa,IAAI,IAAI;IAS/B,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAcxB,IAAI,OAAO,+BAEV;IAED,IAAI,WAAW,yDAEd;CACF"}
|
|
@@ -102,7 +102,7 @@ let Orchestrator = (() => {
|
|
|
102
102
|
this.kernel = kernel;
|
|
103
103
|
this.session = session;
|
|
104
104
|
this.#mirrorDisposers.push(autorun(() => {
|
|
105
|
-
if (this.#
|
|
105
|
+
if (!this.#activated.get() || !this.canApplyResults)
|
|
106
106
|
return;
|
|
107
107
|
for (const name of Object.keys(this.drivers)) {
|
|
108
108
|
// Driver discovery is intentionally eager so the kernel catalog can
|
|
@@ -114,7 +114,7 @@ let Orchestrator = (() => {
|
|
|
114
114
|
}
|
|
115
115
|
}));
|
|
116
116
|
this.#disposeWork = autorun(() => {
|
|
117
|
-
if (this.#
|
|
117
|
+
if (!this.#activated.get() || !this.canApplyResults)
|
|
118
118
|
return;
|
|
119
119
|
for (const node of collectReachable(this.session.root)) {
|
|
120
120
|
if (node.isDone || isTreeOrphan(node))
|
|
@@ -136,7 +136,7 @@ let Orchestrator = (() => {
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
this.#disposeAborts = autorun(() => {
|
|
139
|
-
if (this.#
|
|
139
|
+
if (!this.#activated.get() || !this.canApplyResults)
|
|
140
140
|
return;
|
|
141
141
|
const live = new Set(this.reachableJobs);
|
|
142
142
|
for (const [job, ac] of this.#jobAbort) {
|
|
@@ -174,7 +174,7 @@ let Orchestrator = (() => {
|
|
|
174
174
|
invariant(!this.#processes.has(Class), `Orchestrator: executor already registered for ${Class.name}`);
|
|
175
175
|
const seal = options?.seal !== false;
|
|
176
176
|
this.#processes.set(Class, autorun(() => {
|
|
177
|
-
if (this.#
|
|
177
|
+
if (!this.#activated.get() || !this.canApplyResults)
|
|
178
178
|
return;
|
|
179
179
|
for (const node of this.reachableJobs) {
|
|
180
180
|
if (!(node instanceof Class))
|
|
@@ -200,7 +200,11 @@ let Orchestrator = (() => {
|
|
|
200
200
|
}));
|
|
201
201
|
}
|
|
202
202
|
#startGuard(job, license, execute, seal) {
|
|
203
|
+
if (!this.canApplyResults)
|
|
204
|
+
return;
|
|
203
205
|
const settle = action((ok) => {
|
|
206
|
+
if (!this.canApplyResults)
|
|
207
|
+
return;
|
|
204
208
|
if (job.orchestrationResult !== null || job.completed || job.cancelled)
|
|
205
209
|
return;
|
|
206
210
|
job.orchestrationResult = ok;
|
|
@@ -213,6 +217,8 @@ let Orchestrator = (() => {
|
|
|
213
217
|
});
|
|
214
218
|
// A guard that threw never licensed the job: deny it with a crash receipt.
|
|
215
219
|
const crashed = action((error) => {
|
|
220
|
+
if (!this.canApplyResults)
|
|
221
|
+
return;
|
|
216
222
|
if (job.orchestrationResult !== null || job.completed || job.cancelled)
|
|
217
223
|
return;
|
|
218
224
|
this.#recordCrash(job, "license", error);
|
|
@@ -245,6 +251,8 @@ let Orchestrator = (() => {
|
|
|
245
251
|
}
|
|
246
252
|
}
|
|
247
253
|
#startExecute(job, execute, seal) {
|
|
254
|
+
if (!this.canApplyResults)
|
|
255
|
+
return;
|
|
248
256
|
if (this.#bodyStarted.has(job) || job.completed || job.cancelled)
|
|
249
257
|
return;
|
|
250
258
|
if (job.orchestrationResult !== true)
|
|
@@ -256,16 +264,16 @@ let Orchestrator = (() => {
|
|
|
256
264
|
const ac = new AbortController();
|
|
257
265
|
this.#jobAbort.set(job, ac);
|
|
258
266
|
void Promise.resolve()
|
|
259
|
-
.then(() => execute(job, ac.signal, this))
|
|
267
|
+
.then(() => this.canApplyResults ? execute(job, ac.signal, this) : undefined)
|
|
260
268
|
.then(() => false, (error) => {
|
|
261
269
|
// An abort (cancel, park, leaving the graph) is not a crash: the aborter owns the ending.
|
|
262
|
-
if (ac.signal.aborted || job.completed || job.cancelled)
|
|
270
|
+
if (!this.canApplyResults || ac.signal.aborted || job.completed || job.cancelled)
|
|
263
271
|
return false;
|
|
264
272
|
action(() => this.#recordCrash(job, "body", error))();
|
|
265
273
|
return true;
|
|
266
274
|
})
|
|
267
275
|
.then(action((crashed) => {
|
|
268
|
-
if (seal || crashed)
|
|
276
|
+
if (this.canApplyResults && (seal || crashed))
|
|
269
277
|
job.markComplete();
|
|
270
278
|
this.#jobAbort.delete(job);
|
|
271
279
|
}))
|
|
@@ -287,6 +295,9 @@ let Orchestrator = (() => {
|
|
|
287
295
|
* completes the job right after.
|
|
288
296
|
*/
|
|
289
297
|
stampCrash(_job, _phase, _detail) { }
|
|
298
|
+
get canApplyResults() {
|
|
299
|
+
return !this.#disposed;
|
|
300
|
+
}
|
|
290
301
|
/** In-flight claimed Jobs (handler has not `finally`'d). */
|
|
291
302
|
inFlightJobs() {
|
|
292
303
|
return this.#jobAbort.keys();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/executor/orchestrator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAA0B,QAAQ,EAAE,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;YACzF,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YAC1B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;gBAAE,OAAO,EAAE,CAAC;QACnE,CAAC;QAED,IAAI,OAAO;YACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QAClC,CAAC;QAED,IAAI,WAAW;YACb,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;QACtC,CAAC;;;SApZmB,YAAY;AAuZlC,SAAS,gBAAgB,CAAC,IAAa;IACrC,IAAI,CAAC,CAAC,IAAI,YAAY,aAAa,CAAC;QAAE,OAAO,IAAI,GAAG,EAAE,CAAC;IACvD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,IAAI,IAAI,YAAY,eAAe;YAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { DefaultedMap } from \"@here.build/collections\";\nimport { action, autorun, comparer, computed, observable, type IReactionDisposer, reaction, toJS } from \"mobx\";\nimport invariant from \"tiny-invariant\";\n\nimport {\n acquireConnection,\n releaseConnection,\n} from \"./kernel-intern.js\";\nimport { ExpectationActor } from \"../driver/ExpectationActor.js\";\nimport {\n type ConnectionSecretsView,\n type DriverConnectionClass,\n extraLiveFromState,\n isDriverConnectionClass,\n type PEWDriver,\n} from \"../driver/PEWDriver.js\";\nimport { DriverSpec } from \"../shared/models/DriverSpec.js\";\nimport { Job } from \"../shared/models/Job.js\";\nimport { WorkContainer, walkWork } from \"../shared/models/WorkContainer.js\";\nimport { type AnyWorkExpectation, WorkExpectation, isTreeOrphan } from \"../shared/models/WorkExpectation.js\";\nimport { type KernelPlexus, type SessionPlexus } from \"../shared/types.js\";\n\n/** Class identity for `instanceof`. `registerExecutor` never constructs. */\nexport type JobConstructor<T extends Job = Job> = abstract new (...args: any[]) => T;\n\n/**\n * Seam: session work graph → honor (PEW) and claim (Job).\n *\n * Honor is reachable PEW → handle. Unstarted cancel writes the durable\n * ending here and must not poke `ensure` — MCP: an unstarted tool must not\n * spin the server. Do not call `Actor.complete` — unstarted Work has no\n * Actor. `handle` is not the sealer. License is phase 1 on an Approvable\n * leaf. A sealed parent is not honored (the\n * child is already ending in the agentic runtime, or must not start).\n *\n * INTERN TABLE IS NOT AN ATOM. `#connections` is a plain Map of kernel-interned\n * instances (one live driver per kernel connection id). Honor re-enters by\n * reading catalog `spec.readyState` and, once minted, `instance.readyState`.\n * `handle` only when `ready`.\n *\n * A rejected ensure/load memo IS the sticky failure (no hot loop).\n *\n * Honor and Job claim do not start in the constructor. PEW autorun used to\n * run during `super()`, so a readiness Promise after construct was not a\n * gate. Call {@link activate} after replicas are pinned and recovery ran.\n *\n * Import discipline: this module does not import harness or the session document.\n */\nexport abstract class Orchestrator<\n K extends KernelPlexus = KernelPlexus,\n S extends SessionPlexus = SessionPlexus,\n> implements Disposable {\n #disposed = false;\n #admissionStopped = false;\n readonly #activated = observable.box(false);\n readonly #disposeWork: () => void;\n /** Disposed with the orchestrator — a dead session must not keep writing the live kernel catalog. */\n readonly #mirrorDisposers: IReactionDisposer[] = [];\n readonly #processes = new Map<JobConstructor, () => void>();\n /** Execute (phase 2) — started BODY. */\n readonly #jobAbort = new Map<Job, AbortController>();\n /** In-flight license (phase 1). */\n readonly #guardAbort = new Map<Job, AbortController>();\n /**\n * Process-local: execute already claimed this job. Survives seal:false\n * so the starter does not re-run BODY. A new Orchestrator is empty —\n * bootstrap `orchestrated && !completed` runs execute once more.\n */\n readonly #bodyStarted = new WeakSet<Job>();\n /**\n * Origin-dispatched PEW skip. Lives here, not on the session subclass:\n * honor used to run during `super()`, and subclass fields are unassigned\n * then (JS). A child WeakSet made `shouldHonor` throw `undefined.has`.\n */\n protected readonly originCompletions = new WeakSet<WorkExpectation>();\n readonly #disposeAborts: () => void;\n\n constructor(\n public readonly kernel: K,\n public readonly session: S,\n ) {\n this.#mirrorDisposers.push(\n autorun(() => {\n if (this.#disposed || !this.#activated.get()) return;\n for (const name of Object.keys(this.drivers)) {\n // Driver discovery is intentionally eager so the kernel catalog can\n // expose class-side offers and live facts before a connection is\n // ensured. A session may not be able to load every driver in a\n // shared kernel, so consume a rejected discovery promise here; the\n // driver spec already carries the failure for interested readers.\n void this.#classes.get(name).catch(() => {});\n }\n }),\n );\n this.#disposeWork = autorun(() => {\n if (this.#disposed || !this.#activated.get()) return;\n for (const node of collectReachable(this.session.root)) {\n if (node.isDone || isTreeOrphan(node)) continue;\n if (!this.shouldHonor(node)) continue;\n const spec = this.connections[node.connectionId];\n if (spec === undefined) continue;\n void spec.readyState;\n const instance = this.#connections.get(node.connectionId);\n if (instance !== undefined) {\n if (instance.readyState === \"ready\") instance.handle(node);\n continue;\n }\n invariant(Object.hasOwn(this.connections, node.connectionId), `unknown connection ${node.connectionId}`);\n void this.ensure(node.connectionId);\n }\n });\n this.#disposeAborts = autorun(() => {\n if (this.#disposed || !this.#activated.get()) return;\n const live = new Set(this.reachableJobs);\n for (const [job, ac] of this.#jobAbort) {\n if (live.has(job) || ac.signal.aborted) continue;\n ac.abort();\n }\n for (const [job, ac] of this.#guardAbort) {\n if (live.has(job) || ac.signal.aborted) continue;\n ac.abort();\n }\n });\n }\n\n @computed\n protected get reachableJobs(): Job[] {\n const root = this.session.root;\n const jobs = new Set<Job>();\n if (root instanceof Job) jobs.add(root);\n if (root instanceof WorkContainer) {\n for (const job of Iterator.from(walkWork(root)).filter((node): node is Job => node instanceof Job)) {\n jobs.add(job);\n }\n }\n return [...jobs];\n }\n\n /**\n * Two functions. License (phase 1) returns `true` | `false` and writes\n * `orchestrationResult` (`orchestrated` follows). `true` → await execute\n * (phase 2). `false` → skip execute, `completed = true`. Bootstrap\n * `orchestrated && !completed` skips the license and runs execute.\n * `signal` aborts when the job leaves the graph or the orchestrator disposes.\n */\n registerExecutor<T extends Job>(\n Class: JobConstructor<T>,\n license: (job: T, orchestrator: this) => boolean | Promise<boolean>,\n execute: (job: T, signal: AbortSignal, orchestrator: this) => void | Promise<void>,\n options?: { readonly seal?: boolean },\n ): void {\n invariant(!this.#processes.has(Class), `Orchestrator: executor already registered for ${Class.name}`);\n const seal = options?.seal !== false;\n this.#processes.set(\n Class,\n autorun(() => {\n if (this.#disposed || !this.#activated.get()) return;\n for (const node of this.reachableJobs) {\n if (!(node instanceof Class)) continue;\n const job = node as T;\n if (job.completed || job.cancelled) continue;\n if (job.orchestrationResult === false) {\n job.markComplete();\n continue;\n }\n if (job.orchestrationResult === true) {\n this.#startExecute(job, execute, seal);\n continue;\n }\n if (this.#guardAbort.has(job) || this.#jobAbort.has(job)) continue;\n // Ordering is data on the job: wait here until every predecessor is released.\n if (!job.afterReleased) continue;\n this.#startGuard(job, license, execute, seal);\n }\n }),\n );\n }\n\n #startGuard<T extends Job>(\n job: T,\n license: (job: T, orchestrator: this) => boolean | Promise<boolean>,\n execute: (job: T, signal: AbortSignal, orchestrator: this) => void | Promise<void>,\n seal: boolean,\n ): void {\n const settle = action((ok: boolean) => {\n if (job.orchestrationResult !== null || job.completed || job.cancelled) return;\n job.orchestrationResult = ok;\n if (ok) {this.#startExecute(job, execute, seal);}\n else {job.markComplete();}\n });\n // A guard that threw never licensed the job: deny it with a crash receipt.\n const crashed = action((error: unknown) => {\n if (job.orchestrationResult !== null || job.completed || job.cancelled) return;\n this.#recordCrash(job, \"license\", error);\n job.orchestrationResult = false;\n job.markComplete();\n });\n try {\n const result = license(job, this);\n if (typeof result === \"boolean\") {\n settle(result);\n return;\n }\n const ac = new AbortController();\n this.#guardAbort.set(job, ac);\n void result.then(\n (ok) => {\n if (ac.signal.aborted) return;\n settle(ok);\n return ok;\n },\n (error: unknown) => {\n if (ac.signal.aborted) return;\n crashed(error);\n },\n ).finally(\n action(() => {\n this.#guardAbort.delete(job);\n }),\n );\n } catch (error) {\n crashed(error);\n }\n }\n\n #startExecute<T extends Job>(\n job: T,\n execute: (job: T, signal: AbortSignal, orchestrator: this) => void | Promise<void>,\n seal: boolean,\n ): void {\n if (this.#bodyStarted.has(job) || job.completed || job.cancelled) return;\n if (job.orchestrationResult !== true) return;\n this.#bodyStarted.add(job);\n action(() => {\n job.markStarted();\n })();\n const ac = new AbortController();\n this.#jobAbort.set(job, ac);\n void Promise.resolve()\n .then(() => execute(job, ac.signal, this))\n .then(\n () => false,\n (error: unknown) => {\n // An abort (cancel, park, leaving the graph) is not a crash: the aborter owns the ending.\n if (ac.signal.aborted || job.completed || job.cancelled) return false;\n action(() => this.#recordCrash(job, \"body\", error))();\n return true;\n },\n )\n .then(\n action((crashed: boolean) => {\n if (seal || crashed) job.markComplete();\n this.#jobAbort.delete(job);\n }),\n )\n .catch(() => {});\n }\n\n #recordCrash(job: Job, phase: \"license\" | \"body\", error: unknown): void {\n const detail = error instanceof Error ? error.message : String(error);\n job.crash = `${phase}: ${detail === \"\" ? \"unknown error\" : detail}`;\n try {\n this.stampCrash(job, phase, detail);\n } catch {\n /* the crash fact is already on the job; the receipt is best effort */\n }\n }\n\n /**\n * Host hook: a guard or body threw. `job.crash` is set; write the receipt\n * the job's joiners read (a tool outcome, a call failure). The orchestrator\n * completes the job right after.\n */\n protected stampCrash(_job: Job, _phase: \"license\" | \"body\", _detail: string): void {}\n\n /** In-flight claimed Jobs (handler has not `finally`'d). */\n protected inFlightJobs(): Iterable<Job> {\n return this.#jobAbort.keys();\n }\n\n /** Abort an in-flight executor. No-op if the job is not claimed here. */\n abortJob(job: Job, reason?: unknown): void {\n this.#jobAbort.get(job)?.abort(reason);\n }\n\n readonly #connections = new Map<string, PEWDriver>();\n readonly #classes = new DefaultedMap<string, Promise<DriverConnectionClass>>(this.#loadDriverClass.bind(this));\n readonly #ensured = new DefaultedMap<string, Promise<PEWDriver>>(this.#ensureConnection.bind(this));\n\n abstract loadDriverModule(driver: DriverSpec): Promise<DriverConnectionClass>;\n\n /**\n * Honor still `handle`s leftover attach PEW. Origin-dispatched completions\n * return false (PR4). Default true unless the node is in {@link originCompletions}.\n */\n protected shouldHonor(node: WorkExpectation): boolean {\n return !this.originCompletions.has(node);\n }\n\n /** Process-local. Secrets are never a Plexus field. */\n protected connectionSecrets(_connectionId: string): ConnectionSecretsView {\n return { get: () => undefined };\n }\n\n /** After bootstrap, before ensure settles. The session host binds the settings writer here. */\n protected attachConnection(_connectionId: string, _instance: PEWDriver): void {}\n\n connectionOf(expectation: WorkExpectation): PEWDriver | undefined {\n return this.#connections.get(expectation.connectionId);\n }\n\n actorOf<T extends AnyWorkExpectation>(expectation: T): ExpectationActor<T> | undefined {\n const connection = this.connectionOf(expectation);\n if (!connection?.has(expectation)) return undefined;\n return connection.resolveExpectation(expectation);\n }\n\n #loadDriverClass(driverName: string): Promise<DriverConnectionClass> {\n return (async () => {\n // JS: subclass fields (SessionOrchestrator.sessionDaemon) are unassigned during super().\n await Promise.resolve();\n const driver = this.drivers[driverName];\n invariant(driver !== undefined, `unknown driver ${driverName}`);\n try {\n const cls = await this.loadDriverModule(driver);\n invariant(isDriverConnectionClass(cls), \"loadDriverModule: result is not a PEWDriver class\");\n // Occupancy is kernel-plane: interned connections outlive a session wrap.\n cls.awareness = this.kernel.awareness;\n cls.driverName = driverName;\n const spec = this.drivers[driverName];\n if (spec !== undefined) {\n spec.stampLoad({\n readyState: \"ready\",\n error: \"\",\n offersJson: JSON.stringify(cls.offers),\n live: extraLiveFromState(cls.state),\n });\n // Offers are class state a driver may keep fresh (local detection). The\n // reaction also holds the observation that wakes a lazy `cls.offers`.\n this.#mirrorDisposers.push(\n reaction(\n () => toJS(cls.offers),\n (offers) => {\n if (!this.#disposed) spec.offers = offers;\n },\n { equals: comparer.structural },\n ),\n );\n }\n return cls;\n } catch (error) {\n const spec = this.drivers[driverName];\n if (spec !== undefined) spec.stampLoad({ readyState: \"failed\", error: String(error) });\n throw error;\n }\n })();\n }\n\n #ensureConnection(connectionId: string): Promise<PEWDriver> {\n const pending = (async () => {\n const driver = this.kernel.root.connections[connectionId]?.driver;\n invariant(driver !== undefined, `unknown driver for connection ${connectionId}`);\n const instance = await acquireConnection(this.kernel.root, this, connectionId, async () => {\n const cls = await this.#classes.get(driver.name);\n const minted = new cls(\n connectionId,\n // YAML: settings stamped onto the connection before ensure.\n this.kernel.root.connections[connectionId]?.configuration ?? {},\n this.connectionSecrets(connectionId),\n );\n action(() => {\n minted.awareness = this.kernel.awareness; // kernel occupancy, not session\n })();\n return minted;\n });\n action(() => {\n instance.awareness = this.kernel.awareness;\n })();\n this.#connections.set(connectionId, instance);\n await instance.ensureBootstrapStarted();\n this.attachConnection(connectionId, instance);\n return instance;\n })();\n void pending.then(undefined, () => {});\n return pending;\n }\n\n ensure(connectionId: string): Promise<PEWDriver> {\n return this.#ensured.get(connectionId);\n }\n\n /** True once the connection memo has been poked — without poking it. */\n protected isEnsured(connectionId: string): boolean {\n return this.#ensured.has(connectionId);\n }\n\n /** Intern-owner remint. Deletes the sticky `#ensured` memo. */\n forgetConnection(id: string): void {\n this.#ensured.delete(id);\n this.#connections.delete(id);\n releaseConnection(this.kernel.root, this, id);\n }\n\n /** True after {@link activate}; constructor and registerExecutor do not honor. */\n get activated(): boolean {\n return this.#activated.get();\n }\n\n /**\n * Start honor, Job claim, and driver discovery. Idempotent. No-op after\n * park/dispose — those already stopped admission.\n */\n activate(): void {\n if (this.#disposed || this.#admissionStopped) return;\n action(() => {\n this.#activated.set(true);\n })();\n }\n\n /**\n * Stop honor and new claim. In-flight BODY and live connections stay —\n * park waits dispatched MCP before {@link Symbol.dispose} releases them.\n */\n protected stopAdmission(): void {\n if (this.#admissionStopped) return;\n this.#admissionStopped = true;\n this.#disposeWork();\n for (const dispose of this.#processes.values()) dispose();\n this.#processes.clear();\n for (const ac of this.#guardAbort.values()) ac.abort(\"park\");\n }\n\n [Symbol.dispose](): void {\n if (this.#disposed) return;\n this.#disposed = true;\n this.stopAdmission();\n for (const ac of this.#jobAbort.values()) ac.abort();\n for (const ac of this.#guardAbort.values()) ac.abort();\n this.#disposeAborts();\n this.#jobAbort.clear();\n this.#guardAbort.clear();\n for (const id of this.#connections.keys()) releaseConnection(this.kernel.root, this, id);\n this.#connections.clear();\n for (const dispose of this.#mirrorDisposers.splice(0)) dispose();\n }\n\n get drivers() {\n return this.kernel.root.drivers;\n }\n\n get connections() {\n return this.kernel.root.connections;\n }\n}\n\nfunction collectReachable(root: unknown): Set<WorkExpectation> {\n if (!(root instanceof WorkContainer)) return new Set();\n const found = new Set<WorkExpectation>();\n for (const node of walkWork(root)) {\n if (node instanceof WorkExpectation) found.add(node);\n }\n return found;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/executor/orchestrator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAA0B,QAAQ,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC/G,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAGL,kBAAkB,EAClB,uBAAuB,GAExB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAA2B,eAAe,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAM7G;;;;;;;;;;;;;;;;;;;;;;GAsBG;IACmB,YAAY;;;iBAAZ,YAAY;;;YA8EhC,8LAAc,aAAa,6DAU1B;;;QA1DiB,MAAM,GA9B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IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;gBAAE,OAAO,EAAE,CAAC;QACnE,CAAC;QAED,IAAI,OAAO;YACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QAClC,CAAC;QAED,IAAI,WAAW;YACb,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;QACtC,CAAC;;;SA5ZmB,YAAY;AA+ZlC,SAAS,gBAAgB,CAAC,IAAa;IACrC,IAAI,CAAC,CAAC,IAAI,YAAY,aAAa,CAAC;QAAE,OAAO,IAAI,GAAG,EAAE,CAAC;IACvD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,IAAI,IAAI,YAAY,eAAe;YAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { DefaultedMap } from \"@here.build/collections\";\nimport { action, autorun, comparer, computed, observable, type IReactionDisposer, reaction, toJS } from \"mobx\";\nimport invariant from \"tiny-invariant\";\n\nimport {\n acquireConnection,\n releaseConnection,\n} from \"./kernel-intern.js\";\nimport { ExpectationActor } from \"../driver/ExpectationActor.js\";\nimport {\n type ConnectionSecretsView,\n type DriverConnectionClass,\n extraLiveFromState,\n isDriverConnectionClass,\n type PEWDriver,\n} from \"../driver/PEWDriver.js\";\nimport { DriverSpec } from \"../shared/models/DriverSpec.js\";\nimport { Job } from \"../shared/models/Job.js\";\nimport { WorkContainer, walkWork } from \"../shared/models/WorkContainer.js\";\nimport { type AnyWorkExpectation, WorkExpectation, isTreeOrphan } from \"../shared/models/WorkExpectation.js\";\nimport { type KernelPlexus, type SessionPlexus } from \"../shared/types.js\";\n\n/** Class identity for `instanceof`. `registerExecutor` never constructs. */\nexport type JobConstructor<T extends Job = Job> = abstract new (...args: any[]) => T;\n\n/**\n * Seam: session work graph → honor (PEW) and claim (Job).\n *\n * Honor is reachable PEW → handle. Unstarted cancel writes the durable\n * ending here and must not poke `ensure` — MCP: an unstarted tool must not\n * spin the server. Do not call `Actor.complete` — unstarted Work has no\n * Actor. `handle` is not the sealer. License is phase 1 on an Approvable\n * leaf. A sealed parent is not honored (the\n * child is already ending in the agentic runtime, or must not start).\n *\n * INTERN TABLE IS NOT AN ATOM. `#connections` is a plain Map of kernel-interned\n * instances (one live driver per kernel connection id). Honor re-enters by\n * reading catalog `spec.readyState` and, once minted, `instance.readyState`.\n * `handle` only when `ready`.\n *\n * A rejected ensure/load memo IS the sticky failure (no hot loop).\n *\n * Honor and Job claim do not start in the constructor. PEW autorun used to\n * run during `super()`, so a readiness Promise after construct was not a\n * gate. Call {@link activate} after replicas are pinned and recovery ran.\n *\n * Import discipline: this module does not import harness or the session document.\n */\nexport abstract class Orchestrator<\n K extends KernelPlexus = KernelPlexus,\n S extends SessionPlexus = SessionPlexus,\n> implements Disposable {\n #disposed = false;\n #admissionStopped = false;\n readonly #activated = observable.box(false);\n readonly #disposeWork: () => void;\n /** Disposed with the orchestrator — a dead session must not keep writing the live kernel catalog. */\n readonly #mirrorDisposers: IReactionDisposer[] = [];\n readonly #processes = new Map<JobConstructor, () => void>();\n /** Execute (phase 2) — started BODY. */\n readonly #jobAbort = new Map<Job, AbortController>();\n /** In-flight license (phase 1). */\n readonly #guardAbort = new Map<Job, AbortController>();\n /**\n * Process-local: execute already claimed this job. Survives seal:false\n * so the starter does not re-run BODY. A new Orchestrator is empty —\n * bootstrap `orchestrated && !completed` runs execute once more.\n */\n readonly #bodyStarted = new WeakSet<Job>();\n /**\n * Origin-dispatched PEW skip. Lives here, not on the session subclass:\n * honor used to run during `super()`, and subclass fields are unassigned\n * then (JS). A child WeakSet made `shouldHonor` throw `undefined.has`.\n */\n protected readonly originCompletions = new WeakSet<WorkExpectation>();\n readonly #disposeAborts: () => void;\n\n constructor(\n public readonly kernel: K,\n public readonly session: S,\n ) {\n this.#mirrorDisposers.push(\n autorun(() => {\n if (!this.#activated.get() || !this.canApplyResults) return;\n for (const name of Object.keys(this.drivers)) {\n // Driver discovery is intentionally eager so the kernel catalog can\n // expose class-side offers and live facts before a connection is\n // ensured. A session may not be able to load every driver in a\n // shared kernel, so consume a rejected discovery promise here; the\n // driver spec already carries the failure for interested readers.\n void this.#classes.get(name).catch(() => {});\n }\n }),\n );\n this.#disposeWork = autorun(() => {\n if (!this.#activated.get() || !this.canApplyResults) return;\n for (const node of collectReachable(this.session.root)) {\n if (node.isDone || isTreeOrphan(node)) continue;\n if (!this.shouldHonor(node)) continue;\n const spec = this.connections[node.connectionId];\n if (spec === undefined) continue;\n void spec.readyState;\n const instance = this.#connections.get(node.connectionId);\n if (instance !== undefined) {\n if (instance.readyState === \"ready\") instance.handle(node);\n continue;\n }\n invariant(Object.hasOwn(this.connections, node.connectionId), `unknown connection ${node.connectionId}`);\n void this.ensure(node.connectionId);\n }\n });\n this.#disposeAborts = autorun(() => {\n if (!this.#activated.get() || !this.canApplyResults) return;\n const live = new Set(this.reachableJobs);\n for (const [job, ac] of this.#jobAbort) {\n if (live.has(job) || ac.signal.aborted) continue;\n ac.abort();\n }\n for (const [job, ac] of this.#guardAbort) {\n if (live.has(job) || ac.signal.aborted) continue;\n ac.abort();\n }\n });\n }\n\n @computed\n protected get reachableJobs(): Job[] {\n const root = this.session.root;\n const jobs = new Set<Job>();\n if (root instanceof Job) jobs.add(root);\n if (root instanceof WorkContainer) {\n for (const job of Iterator.from(walkWork(root)).filter((node): node is Job => node instanceof Job)) {\n jobs.add(job);\n }\n }\n return [...jobs];\n }\n\n /**\n * Two functions. License (phase 1) returns `true` | `false` and writes\n * `orchestrationResult` (`orchestrated` follows). `true` → await execute\n * (phase 2). `false` → skip execute, `completed = true`. Bootstrap\n * `orchestrated && !completed` skips the license and runs execute.\n * `signal` aborts when the job leaves the graph or the orchestrator disposes.\n */\n registerExecutor<T extends Job>(\n Class: JobConstructor<T>,\n license: (job: T, orchestrator: this) => boolean | Promise<boolean>,\n execute: (job: T, signal: AbortSignal, orchestrator: this) => void | Promise<void>,\n options?: { readonly seal?: boolean },\n ): void {\n invariant(!this.#processes.has(Class), `Orchestrator: executor already registered for ${Class.name}`);\n const seal = options?.seal !== false;\n this.#processes.set(\n Class,\n autorun(() => {\n if (!this.#activated.get() || !this.canApplyResults) return;\n for (const node of this.reachableJobs) {\n if (!(node instanceof Class)) continue;\n const job = node as T;\n if (job.completed || job.cancelled) continue;\n if (job.orchestrationResult === false) {\n job.markComplete();\n continue;\n }\n if (job.orchestrationResult === true) {\n this.#startExecute(job, execute, seal);\n continue;\n }\n if (this.#guardAbort.has(job) || this.#jobAbort.has(job)) continue;\n // Ordering is data on the job: wait here until every predecessor is released.\n if (!job.afterReleased) continue;\n this.#startGuard(job, license, execute, seal);\n }\n }),\n );\n }\n\n #startGuard<T extends Job>(\n job: T,\n license: (job: T, orchestrator: this) => boolean | Promise<boolean>,\n execute: (job: T, signal: AbortSignal, orchestrator: this) => void | Promise<void>,\n seal: boolean,\n ): void {\n if (!this.canApplyResults) return;\n const settle = action((ok: boolean) => {\n if (!this.canApplyResults) return;\n if (job.orchestrationResult !== null || job.completed || job.cancelled) return;\n job.orchestrationResult = ok;\n if (ok) {this.#startExecute(job, execute, seal);}\n else {job.markComplete();}\n });\n // A guard that threw never licensed the job: deny it with a crash receipt.\n const crashed = action((error: unknown) => {\n if (!this.canApplyResults) return;\n if (job.orchestrationResult !== null || job.completed || job.cancelled) return;\n this.#recordCrash(job, \"license\", error);\n job.orchestrationResult = false;\n job.markComplete();\n });\n try {\n const result = license(job, this);\n if (typeof result === \"boolean\") {\n settle(result);\n return;\n }\n const ac = new AbortController();\n this.#guardAbort.set(job, ac);\n void result.then(\n (ok) => {\n if (ac.signal.aborted) return;\n settle(ok);\n return ok;\n },\n (error: unknown) => {\n if (ac.signal.aborted) return;\n crashed(error);\n },\n ).finally(\n action(() => {\n this.#guardAbort.delete(job);\n }),\n );\n } catch (error) {\n crashed(error);\n }\n }\n\n #startExecute<T extends Job>(\n job: T,\n execute: (job: T, signal: AbortSignal, orchestrator: this) => void | Promise<void>,\n seal: boolean,\n ): void {\n if (!this.canApplyResults) return;\n if (this.#bodyStarted.has(job) || job.completed || job.cancelled) return;\n if (job.orchestrationResult !== true) return;\n this.#bodyStarted.add(job);\n action(() => {\n job.markStarted();\n })();\n const ac = new AbortController();\n this.#jobAbort.set(job, ac);\n void Promise.resolve()\n .then(() => this.canApplyResults ? execute(job, ac.signal, this) : undefined)\n .then(\n () => false,\n (error: unknown) => {\n // An abort (cancel, park, leaving the graph) is not a crash: the aborter owns the ending.\n if (!this.canApplyResults || ac.signal.aborted || job.completed || job.cancelled) return false;\n action(() => this.#recordCrash(job, \"body\", error))();\n return true;\n },\n )\n .then(\n action((crashed: boolean) => {\n if (this.canApplyResults && (seal || crashed)) job.markComplete();\n this.#jobAbort.delete(job);\n }),\n )\n .catch(() => {});\n }\n\n #recordCrash(job: Job, phase: \"license\" | \"body\", error: unknown): void {\n const detail = error instanceof Error ? error.message : String(error);\n job.crash = `${phase}: ${detail === \"\" ? \"unknown error\" : detail}`;\n try {\n this.stampCrash(job, phase, detail);\n } catch {\n /* the crash fact is already on the job; the receipt is best effort */\n }\n }\n\n /**\n * Host hook: a guard or body threw. `job.crash` is set; write the receipt\n * the job's joiners read (a tool outcome, a call failure). The orchestrator\n * completes the job right after.\n */\n protected stampCrash(_job: Job, _phase: \"license\" | \"body\", _detail: string): void {}\n\n protected get canApplyResults(): boolean {\n return !this.#disposed;\n }\n\n /** In-flight claimed Jobs (handler has not `finally`'d). */\n protected inFlightJobs(): Iterable<Job> {\n return this.#jobAbort.keys();\n }\n\n /** Abort an in-flight executor. No-op if the job is not claimed here. */\n abortJob(job: Job, reason?: unknown): void {\n this.#jobAbort.get(job)?.abort(reason);\n }\n\n readonly #connections = new Map<string, PEWDriver>();\n readonly #classes = new DefaultedMap<string, Promise<DriverConnectionClass>>(this.#loadDriverClass.bind(this));\n readonly #ensured = new DefaultedMap<string, Promise<PEWDriver>>(this.#ensureConnection.bind(this));\n\n abstract loadDriverModule(driver: DriverSpec): Promise<DriverConnectionClass>;\n\n /**\n * Honor still `handle`s leftover attach PEW. Origin-dispatched completions\n * return false (PR4). Default true unless the node is in {@link originCompletions}.\n */\n protected shouldHonor(node: WorkExpectation): boolean {\n return !this.originCompletions.has(node);\n }\n\n /** Process-local. Secrets are never a Plexus field. */\n protected connectionSecrets(_connectionId: string): ConnectionSecretsView {\n return { get: () => undefined };\n }\n\n /** After bootstrap, before ensure settles. The session host binds the settings writer here. */\n protected attachConnection(_connectionId: string, _instance: PEWDriver): void {}\n\n connectionOf(expectation: WorkExpectation): PEWDriver | undefined {\n return this.#connections.get(expectation.connectionId);\n }\n\n actorOf<T extends AnyWorkExpectation>(expectation: T): ExpectationActor<T> | undefined {\n const connection = this.connectionOf(expectation);\n if (!connection?.has(expectation)) return undefined;\n return connection.resolveExpectation(expectation);\n }\n\n #loadDriverClass(driverName: string): Promise<DriverConnectionClass> {\n return (async () => {\n // JS: subclass fields (SessionOrchestrator.sessionDaemon) are unassigned during super().\n await Promise.resolve();\n const driver = this.drivers[driverName];\n invariant(driver !== undefined, `unknown driver ${driverName}`);\n try {\n const cls = await this.loadDriverModule(driver);\n invariant(isDriverConnectionClass(cls), \"loadDriverModule: result is not a PEWDriver class\");\n // Occupancy is kernel-plane: interned connections outlive a session wrap.\n cls.awareness = this.kernel.awareness;\n cls.driverName = driverName;\n const spec = this.drivers[driverName];\n if (spec !== undefined) {\n spec.stampLoad({\n readyState: \"ready\",\n error: \"\",\n offersJson: JSON.stringify(cls.offers),\n live: extraLiveFromState(cls.state),\n });\n // Offers are class state a driver may keep fresh (local detection). The\n // reaction also holds the observation that wakes a lazy `cls.offers`.\n this.#mirrorDisposers.push(\n reaction(\n () => toJS(cls.offers),\n (offers) => {\n if (!this.#disposed) spec.offers = offers;\n },\n { equals: comparer.structural },\n ),\n );\n }\n return cls;\n } catch (error) {\n const spec = this.drivers[driverName];\n if (spec !== undefined) spec.stampLoad({ readyState: \"failed\", error: String(error) });\n throw error;\n }\n })();\n }\n\n #ensureConnection(connectionId: string): Promise<PEWDriver> {\n const pending = (async () => {\n const driver = this.kernel.root.connections[connectionId]?.driver;\n invariant(driver !== undefined, `unknown driver for connection ${connectionId}`);\n const instance = await acquireConnection(this.kernel.root, this, connectionId, async () => {\n const cls = await this.#classes.get(driver.name);\n const minted = new cls(\n connectionId,\n // YAML: settings stamped onto the connection before ensure.\n this.kernel.root.connections[connectionId]?.configuration ?? {},\n this.connectionSecrets(connectionId),\n );\n action(() => {\n minted.awareness = this.kernel.awareness; // kernel occupancy, not session\n })();\n return minted;\n });\n action(() => {\n instance.awareness = this.kernel.awareness;\n })();\n this.#connections.set(connectionId, instance);\n await instance.ensureBootstrapStarted();\n this.attachConnection(connectionId, instance);\n return instance;\n })();\n void pending.then(undefined, () => {});\n return pending;\n }\n\n ensure(connectionId: string): Promise<PEWDriver> {\n return this.#ensured.get(connectionId);\n }\n\n /** True once the connection memo has been poked — without poking it. */\n protected isEnsured(connectionId: string): boolean {\n return this.#ensured.has(connectionId);\n }\n\n /** Intern-owner remint. Deletes the sticky `#ensured` memo. */\n forgetConnection(id: string): void {\n this.#ensured.delete(id);\n this.#connections.delete(id);\n releaseConnection(this.kernel.root, this, id);\n }\n\n /** True after {@link activate}; constructor and registerExecutor do not honor. */\n get activated(): boolean {\n return this.#activated.get();\n }\n\n /**\n * Start honor, Job claim, and driver discovery. Idempotent. No-op after\n * park/dispose — those already stopped admission.\n */\n activate(): void {\n if (this.#disposed || this.#admissionStopped) return;\n action(() => {\n this.#activated.set(true);\n })();\n }\n\n /**\n * Stop honor and new claim. In-flight BODY and live connections stay —\n * park waits dispatched MCP before {@link Symbol.dispose} releases them.\n */\n protected stopAdmission(): void {\n if (this.#admissionStopped) return;\n this.#admissionStopped = true;\n this.#disposeWork();\n for (const dispose of this.#processes.values()) dispose();\n this.#processes.clear();\n for (const ac of this.#guardAbort.values()) ac.abort(\"park\");\n }\n\n [Symbol.dispose](): void {\n if (this.#disposed) return;\n this.#disposed = true;\n this.stopAdmission();\n for (const ac of this.#jobAbort.values()) ac.abort();\n for (const ac of this.#guardAbort.values()) ac.abort();\n this.#disposeAborts();\n this.#jobAbort.clear();\n this.#guardAbort.clear();\n for (const id of this.#connections.keys()) releaseConnection(this.kernel.root, this, id);\n this.#connections.clear();\n for (const dispose of this.#mirrorDisposers.splice(0)) dispose();\n }\n\n get drivers() {\n return this.kernel.root.drivers;\n }\n\n get connections() {\n return this.kernel.root.connections;\n }\n}\n\nfunction collectReachable(root: unknown): Set<WorkExpectation> {\n if (!(root instanceof WorkContainer)) return new Set();\n const found = new Set<WorkExpectation>();\n for (const node of walkWork(root)) {\n if (node instanceof WorkExpectation) found.add(node);\n }\n return found;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inhuman.tools/plexus-expectations",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Work graph: WorkExpectation (PEW), Job + honoring executor.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Merkle Bonsai",
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
"!**/*.test.*"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@here.build/collections": "0.
|
|
35
|
+
"@here.build/collections": "0.10.0",
|
|
36
36
|
"tiny-invariant": "^1.3.3",
|
|
37
|
-
"zod": "^4.
|
|
37
|
+
"zod": "^4.6.7",
|
|
38
38
|
"tslib": "2.8.1",
|
|
39
|
-
"xstate": "5.
|
|
40
|
-
"@inhuman.tools/error-with-invariant": "^0.
|
|
39
|
+
"xstate": "5.33.3",
|
|
40
|
+
"@inhuman.tools/error-with-invariant": "^0.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^24.
|
|
44
|
-
"eslint": "
|
|
45
|
-
"prettier": "3.
|
|
46
|
-
"typescript": "6.0.
|
|
47
|
-
"vitest": "
|
|
43
|
+
"@types/node": "^24.19.2",
|
|
44
|
+
"eslint": "10.13.0",
|
|
45
|
+
"prettier": "3.9.10",
|
|
46
|
+
"typescript": "6.0.3",
|
|
47
|
+
"vitest": "5.0.5",
|
|
48
48
|
"yjs": "13.6.33",
|
|
49
49
|
"mobx": "6.16.1",
|
|
50
50
|
"@here.build/plexus": "^0.9.6",
|
|
@@ -22,6 +22,8 @@ function internOwnerOf(owner: object): InternOwner | undefined {
|
|
|
22
22
|
type KernelRoot = { readonly connections: Record<string, ConnectionSpec | undefined> };
|
|
23
23
|
type ConnectionHold = {
|
|
24
24
|
readonly refs: Set<object>;
|
|
25
|
+
/** Raw construction remains disposable even when the consumer lease is revoked. */
|
|
26
|
+
readonly created: Promise<PEWDriver>;
|
|
25
27
|
readonly pending: Promise<PEWDriver>;
|
|
26
28
|
mirror: IReactionDisposer | undefined;
|
|
27
29
|
};
|
|
@@ -41,11 +43,16 @@ export function acquireConnection(
|
|
|
41
43
|
existing.refs.add(owner);
|
|
42
44
|
return existing.pending;
|
|
43
45
|
}
|
|
46
|
+
const created = Promise.resolve().then(construct);
|
|
44
47
|
const lease: ConnectionHold = {
|
|
45
48
|
refs: new Set([owner]),
|
|
46
|
-
|
|
49
|
+
created,
|
|
50
|
+
pending: created.then((instance) => {
|
|
51
|
+
if (bag.connections.get(connectionId) !== lease)
|
|
52
|
+
throw new ConnectionMiss("connection-dropped", `connection ${connectionId} dropped during construction`);
|
|
47
53
|
lease.mirror = reaction(
|
|
48
54
|
() => {
|
|
55
|
+
if (bag.connections.get(connectionId) !== lease) return null;
|
|
49
56
|
const spec = kernel.connections[connectionId];
|
|
50
57
|
if (spec === undefined) return null;
|
|
51
58
|
const ready = asReadyState(instance.readyState);
|
|
@@ -54,7 +61,7 @@ export function acquireConnection(
|
|
|
54
61
|
return { ready, error: instance.error, live: extraLiveFromState(instance.state) };
|
|
55
62
|
},
|
|
56
63
|
(snap) => {
|
|
57
|
-
if (snap == null) return;
|
|
64
|
+
if (snap == null || bag.connections.get(connectionId) !== lease) return;
|
|
58
65
|
kernel.connections[connectionId]?.stampProcess({
|
|
59
66
|
readyState: snap.ready,
|
|
60
67
|
error: snap.error,
|
|
@@ -69,7 +76,7 @@ export function acquireConnection(
|
|
|
69
76
|
};
|
|
70
77
|
bag.connections.set(connectionId, lease);
|
|
71
78
|
void lease.pending.then(undefined, () => {
|
|
72
|
-
if (lease.refs.size === 0) bag.connections.delete(connectionId);
|
|
79
|
+
if (lease.refs.size === 0 && bag.connections.get(connectionId) === lease) bag.connections.delete(connectionId);
|
|
73
80
|
});
|
|
74
81
|
return lease.pending;
|
|
75
82
|
}
|
|
@@ -93,7 +100,7 @@ export async function dropConnection(kernel: KernelRoot, connectionId: string):
|
|
|
93
100
|
const owners = [...lease.refs];
|
|
94
101
|
lease.refs.clear();
|
|
95
102
|
const miss = new ConnectionMiss("connection-dropped", `connection ${connectionId} dropped`);
|
|
96
|
-
const disposing = lease.
|
|
103
|
+
const disposing = lease.created.then(
|
|
97
104
|
(instance) => {
|
|
98
105
|
instance.abortOnDrop(miss);
|
|
99
106
|
return instance[Symbol.asyncDispose]();
|
|
@@ -112,7 +119,7 @@ export function disposeKernelConnections(kernel: object): void {
|
|
|
112
119
|
for (const lease of bag.connections.values()) {
|
|
113
120
|
lease.refs.clear();
|
|
114
121
|
lease.mirror?.();
|
|
115
|
-
void lease.
|
|
122
|
+
void lease.created.then(
|
|
116
123
|
(instance) => instance[Symbol.asyncDispose](),
|
|
117
124
|
() => {},
|
|
118
125
|
);
|
|
@@ -81,7 +81,7 @@ export abstract class Orchestrator<
|
|
|
81
81
|
) {
|
|
82
82
|
this.#mirrorDisposers.push(
|
|
83
83
|
autorun(() => {
|
|
84
|
-
if (this.#
|
|
84
|
+
if (!this.#activated.get() || !this.canApplyResults) return;
|
|
85
85
|
for (const name of Object.keys(this.drivers)) {
|
|
86
86
|
// Driver discovery is intentionally eager so the kernel catalog can
|
|
87
87
|
// expose class-side offers and live facts before a connection is
|
|
@@ -93,7 +93,7 @@ export abstract class Orchestrator<
|
|
|
93
93
|
}),
|
|
94
94
|
);
|
|
95
95
|
this.#disposeWork = autorun(() => {
|
|
96
|
-
if (this.#
|
|
96
|
+
if (!this.#activated.get() || !this.canApplyResults) return;
|
|
97
97
|
for (const node of collectReachable(this.session.root)) {
|
|
98
98
|
if (node.isDone || isTreeOrphan(node)) continue;
|
|
99
99
|
if (!this.shouldHonor(node)) continue;
|
|
@@ -110,7 +110,7 @@ export abstract class Orchestrator<
|
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
this.#disposeAborts = autorun(() => {
|
|
113
|
-
if (this.#
|
|
113
|
+
if (!this.#activated.get() || !this.canApplyResults) return;
|
|
114
114
|
const live = new Set(this.reachableJobs);
|
|
115
115
|
for (const [job, ac] of this.#jobAbort) {
|
|
116
116
|
if (live.has(job) || ac.signal.aborted) continue;
|
|
@@ -154,7 +154,7 @@ export abstract class Orchestrator<
|
|
|
154
154
|
this.#processes.set(
|
|
155
155
|
Class,
|
|
156
156
|
autorun(() => {
|
|
157
|
-
if (this.#
|
|
157
|
+
if (!this.#activated.get() || !this.canApplyResults) return;
|
|
158
158
|
for (const node of this.reachableJobs) {
|
|
159
159
|
if (!(node instanceof Class)) continue;
|
|
160
160
|
const job = node as T;
|
|
@@ -182,7 +182,9 @@ export abstract class Orchestrator<
|
|
|
182
182
|
execute: (job: T, signal: AbortSignal, orchestrator: this) => void | Promise<void>,
|
|
183
183
|
seal: boolean,
|
|
184
184
|
): void {
|
|
185
|
+
if (!this.canApplyResults) return;
|
|
185
186
|
const settle = action((ok: boolean) => {
|
|
187
|
+
if (!this.canApplyResults) return;
|
|
186
188
|
if (job.orchestrationResult !== null || job.completed || job.cancelled) return;
|
|
187
189
|
job.orchestrationResult = ok;
|
|
188
190
|
if (ok) {this.#startExecute(job, execute, seal);}
|
|
@@ -190,6 +192,7 @@ export abstract class Orchestrator<
|
|
|
190
192
|
});
|
|
191
193
|
// A guard that threw never licensed the job: deny it with a crash receipt.
|
|
192
194
|
const crashed = action((error: unknown) => {
|
|
195
|
+
if (!this.canApplyResults) return;
|
|
193
196
|
if (job.orchestrationResult !== null || job.completed || job.cancelled) return;
|
|
194
197
|
this.#recordCrash(job, "license", error);
|
|
195
198
|
job.orchestrationResult = false;
|
|
@@ -228,6 +231,7 @@ export abstract class Orchestrator<
|
|
|
228
231
|
execute: (job: T, signal: AbortSignal, orchestrator: this) => void | Promise<void>,
|
|
229
232
|
seal: boolean,
|
|
230
233
|
): void {
|
|
234
|
+
if (!this.canApplyResults) return;
|
|
231
235
|
if (this.#bodyStarted.has(job) || job.completed || job.cancelled) return;
|
|
232
236
|
if (job.orchestrationResult !== true) return;
|
|
233
237
|
this.#bodyStarted.add(job);
|
|
@@ -237,19 +241,19 @@ export abstract class Orchestrator<
|
|
|
237
241
|
const ac = new AbortController();
|
|
238
242
|
this.#jobAbort.set(job, ac);
|
|
239
243
|
void Promise.resolve()
|
|
240
|
-
.then(() => execute(job, ac.signal, this))
|
|
244
|
+
.then(() => this.canApplyResults ? execute(job, ac.signal, this) : undefined)
|
|
241
245
|
.then(
|
|
242
246
|
() => false,
|
|
243
247
|
(error: unknown) => {
|
|
244
248
|
// An abort (cancel, park, leaving the graph) is not a crash: the aborter owns the ending.
|
|
245
|
-
if (ac.signal.aborted || job.completed || job.cancelled) return false;
|
|
249
|
+
if (!this.canApplyResults || ac.signal.aborted || job.completed || job.cancelled) return false;
|
|
246
250
|
action(() => this.#recordCrash(job, "body", error))();
|
|
247
251
|
return true;
|
|
248
252
|
},
|
|
249
253
|
)
|
|
250
254
|
.then(
|
|
251
255
|
action((crashed: boolean) => {
|
|
252
|
-
if (seal || crashed) job.markComplete();
|
|
256
|
+
if (this.canApplyResults && (seal || crashed)) job.markComplete();
|
|
253
257
|
this.#jobAbort.delete(job);
|
|
254
258
|
}),
|
|
255
259
|
)
|
|
@@ -273,6 +277,10 @@ export abstract class Orchestrator<
|
|
|
273
277
|
*/
|
|
274
278
|
protected stampCrash(_job: Job, _phase: "license" | "body", _detail: string): void {}
|
|
275
279
|
|
|
280
|
+
protected get canApplyResults(): boolean {
|
|
281
|
+
return !this.#disposed;
|
|
282
|
+
}
|
|
283
|
+
|
|
276
284
|
/** In-flight claimed Jobs (handler has not `finally`'d). */
|
|
277
285
|
protected inFlightJobs(): Iterable<Job> {
|
|
278
286
|
return this.#jobAbort.keys();
|