@cotal-ai/runtime 0.45.0 → 0.46.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/fork.d.ts +2 -0
- package/dist/fork.d.ts.map +1 -1
- package/dist/fork.js +3 -1
- package/dist/fork.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -10
- package/dist/index.js.map +1 -1
- package/dist/mesh-handler.d.ts +37 -9
- package/dist/mesh-handler.d.ts.map +1 -1
- package/dist/mesh-handler.js +59 -54
- package/dist/mesh-handler.js.map +1 -1
- package/dist/resolve-checkpoint.d.ts +40 -1
- package/dist/resolve-checkpoint.d.ts.map +1 -1
- package/dist/resolve-checkpoint.js +32 -5
- package/dist/resolve-checkpoint.js.map +1 -1
- package/dist/run-command.d.ts +2 -1
- package/dist/run-command.d.ts.map +1 -1
- package/dist/run-command.js +305 -100
- package/dist/run-command.js.map +1 -1
- package/dist/run-driver.d.ts.map +1 -1
- package/dist/run-driver.js +11 -1
- package/dist/run-driver.js.map +1 -1
- package/dist/run-host.d.ts +12 -0
- package/dist/run-host.d.ts.map +1 -0
- package/dist/run-host.js +159 -0
- package/dist/run-host.js.map +1 -0
- package/package.json +5 -5
package/dist/fork.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export interface ForkPlan {
|
|
|
53
53
|
readonly fromStep: string;
|
|
54
54
|
/** The parent's pins, verbatim — what the child must be created under, not what it would resolve. */
|
|
55
55
|
readonly pins: RunPins;
|
|
56
|
+
/** The program the child runs: the parent's, recorded on the child so it resumes without a file. */
|
|
57
|
+
readonly source: string;
|
|
56
58
|
/** The entries the child inherits as history, in the parent's recorded order. */
|
|
57
59
|
readonly cut: readonly JournalEntry[];
|
|
58
60
|
readonly admissible: boolean;
|
package/dist/fork.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork.d.ts","sourceRoot":"","sources":["../src/fork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AC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,oGAAoG;AACpG,qBAAa,UAAW,SAAQ,KAAK;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAIlC;AAED;;;;;;;;;GASG;AACH,qBAAa,UAAW,SAAQ,OAAO;IAGnC,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADtB,IAAI,EAAE,WAAW,EACA,KAAK,EAAE,MAAM;IAKvB,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa;CAIhE;AAuBD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CA4LlE;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC;CAChC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAC9B,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAoC3B;AAED,gGAAgG;AAChG,qBAAa,iBAAkB,SAAQ,KAAK;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ;gBAAd,IAAI,EAAE,QAAQ;CAQpC"}
|
package/dist/fork.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRunSpec, readRunRecord } from "@cotal-ai/core";
|
|
1
|
+
import { createRunSpec, readRunRecord, recordRunProgram } from "@cotal-ai/core";
|
|
2
2
|
import { Journal, JournalReadOnlyError, journalEntryKeyString, run as runProgram, RunDivergence, UnwalkableScope, ScopeBranchMissing, stepKeyString, } from "@cotal-ai/lang";
|
|
3
3
|
/** The journal kinds that open a scope, i.e. whose entry can ENCLOSE a cut point. */
|
|
4
4
|
const SCOPE_KINDS = new Set(["parallel", "race", "fanOut", "conclave"]);
|
|
@@ -233,6 +233,7 @@ export async function planFork(req) {
|
|
|
233
233
|
actor: req.actor,
|
|
234
234
|
fromStep: req.fromStepKey,
|
|
235
235
|
pins: req.pins,
|
|
236
|
+
source: req.source,
|
|
236
237
|
cut,
|
|
237
238
|
admissible: refusals.length === 0,
|
|
238
239
|
refusals,
|
|
@@ -284,6 +285,7 @@ export async function commitFork(kv, endpoint, plan, store) {
|
|
|
284
285
|
createdAt: plan.at,
|
|
285
286
|
forkedFrom: { run: plan.parent, step: plan.fromStep },
|
|
286
287
|
});
|
|
288
|
+
await recordRunProgram(kv, endpoint, { v: 1, run: plan.child, source: plan.source, at: plan.at });
|
|
287
289
|
return { child: plan.child, copied: plan.cut.length, lineageRecorded: true };
|
|
288
290
|
}
|
|
289
291
|
/** A fork the plan refused, offered for commit anyway. The plan carries the per-step reason. */
|
package/dist/fork.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork.js","sourceRoot":"","sources":["../src/fork.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"fork.js","sourceRoot":"","sources":["../src/fork.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,GAAG,IAAI,UAAU,EACjB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,aAAa,GASd,MAAM,gBAAgB,CAAC;AAExB,qFAAqF;AACrF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAo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AAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AAC/E,CAAC;AAED,gGAAgG;AAChG,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACrB;IAArB,YAAqB,IAAc;QACjC,KAAK,CACH,OAAO,IAAI,CAAC,MAAM,mBAAmB,IAAI,CAAC,QAAQ,IAAI;YACpD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9F,8DAA8D,CACjE,CAAC;QALiB,SAAI,GAAJ,IAAI,CAAU;QAMjC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,CAAU;IAC3B,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAI,GAA4B,EAAE,MAAM,CAAC;QACpD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,GAAG;YAAE,OAAO,GAAG,CAAC;QACrD,GAAG,GAAG,KAAK,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { RunJournalStore, RunJournalUnavailable } from "./journal-store.js";
|
|
12
12
|
export { startRun, driveRun, PauseToken, type RunLease, type DriveRequest, type DriveOutcome, type AdoptingHandler, type SeatAdoptingHandler } from "./run-driver.js";
|
|
13
|
-
export { MeshHandler, EpfSettleWatcher, CheckpointAnswerMissing, waitConsumerName, waitConsumerConfig, rearmOutstandingPauses, outstandingPauseTokens, type MeshHandlerBinding, type SettleWatcher, } from "./mesh-handler.js";
|
|
14
|
-
export { resolveCheckpoint, openCheckpointToken, CheckpointNotOpen, type ResolveCheckpointDeps, type ResolveCheckpointRequest, type ResolveCheckpointResult, } from "./resolve-checkpoint.js";
|
|
13
|
+
export { MeshHandler, EpfSettleWatcher, CheckpointAnswerMissing, waitConsumerName, waitConsumerConfig, rearmOutstandingPauses, outstandingPauseTokens, readSupervise, spawnArgs, type MeshHandlerBinding, type SettleWatcher, } from "./mesh-handler.js";
|
|
14
|
+
export { resolveCheckpoint, locateOpenCheckpoint, answerOpenCheckpoint, openCheckpointToken, CheckpointNotOpen, type OpenCheckpoint, type ResolveCheckpointDeps, type ResolveCheckpointRequest, type ResolveCheckpointResult, } from "./resolve-checkpoint.js";
|
|
15
15
|
export { renderRunContext, UnrenderableNotice, type RunContextRender } from "./run-context.js";
|
|
16
16
|
export { migrateRun, commitMigration, migrationSeats, MigrationNotAdmissible, type MigrateRequest, type MigrateReport, type MigrateOrphan, type MigrateOverrides, type MigrateDivergence, type OrphanVerdict, } from "./migrate.js";
|
|
17
17
|
export { planFork, commitFork, ForkNotAdmissible, CutJournal, CutReached, type ForkRequest, type ForkPlan, type ForkRefusal, type ForkCommitResult, } from "./fork.js";
|
|
18
18
|
export { runWorkflow } from "./run-command.js";
|
|
19
|
+
export { cotalLangRunHost } from "./run-host.js";
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,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AAC;AACtK,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,SAAS,EACT,KAAK,kBAAkB,EACvB,KAAK,aAAa,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,30 +10,36 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { RunJournalStore, RunJournalUnavailable } from "./journal-store.js";
|
|
12
12
|
export { startRun, driveRun, PauseToken } from "./run-driver.js";
|
|
13
|
-
export { MeshHandler, EpfSettleWatcher, CheckpointAnswerMissing, waitConsumerName, waitConsumerConfig, rearmOutstandingPauses, outstandingPauseTokens, } from "./mesh-handler.js";
|
|
14
|
-
export { resolveCheckpoint, openCheckpointToken, CheckpointNotOpen, } from "./resolve-checkpoint.js";
|
|
13
|
+
export { MeshHandler, EpfSettleWatcher, CheckpointAnswerMissing, waitConsumerName, waitConsumerConfig, rearmOutstandingPauses, outstandingPauseTokens, readSupervise, spawnArgs, } from "./mesh-handler.js";
|
|
14
|
+
export { resolveCheckpoint, locateOpenCheckpoint, answerOpenCheckpoint, openCheckpointToken, CheckpointNotOpen, } from "./resolve-checkpoint.js";
|
|
15
15
|
export { renderRunContext, UnrenderableNotice } from "./run-context.js";
|
|
16
16
|
export { migrateRun, commitMigration, migrationSeats, MigrationNotAdmissible, } from "./migrate.js";
|
|
17
17
|
export { planFork, commitFork, ForkNotAdmissible, CutJournal, CutReached, } from "./fork.js";
|
|
18
18
|
export { runWorkflow } from "./run-command.js";
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
//
|
|
19
|
+
export { cotalLangRunHost } from "./run-host.js";
|
|
20
|
+
// Self-register `cotal run` — the workflow-run operator surface — and the `run-host` the manager
|
|
21
|
+
// drives runs through (SPEC 14.3). Importing this package from a composition root (bin/run.ts) is
|
|
22
|
+
// what puts the command on the CLI and the host in the manager's reach; library users who import
|
|
23
|
+
// the driver API get both registrations too, and they are inert until a dispatcher or a manager
|
|
24
|
+
// resolves them.
|
|
22
25
|
import { registry } from "@cotal-ai/core";
|
|
23
26
|
import { targetFlags } from "@cotal-ai/workspace";
|
|
24
27
|
import { runWorkflow as runWorkflowCommand } from "./run-command.js";
|
|
28
|
+
import { cotalLangRunHost as runHost } from "./run-host.js";
|
|
29
|
+
registry.register(runHost);
|
|
25
30
|
const runCommand = {
|
|
26
31
|
kind: "command",
|
|
27
32
|
name: "run",
|
|
28
33
|
group: "Manager",
|
|
29
|
-
summary: "operate workflow runs — start, resume, list, inspect, answer",
|
|
30
|
-
usage: "run <start --file <program> [--timeout <dur>] | resume <runId> --file <program> | ps | journal <runId> | answer <runId> <stepKey>
|
|
34
|
+
summary: "operate workflow runs — start, resume, list, inspect, answer (hosted by the manager)",
|
|
35
|
+
usage: "run <start --file <program> [--timeout <dur>] | resume <runId> [--local --file <program>] | ps [--endpoint <ep>] | journal <runId> [--endpoint <ep>] | answer <runId> <stepKey> [--value <json>] [--artifact <ref>] [--endpoint <ep>] [--local --by <who>]> [--local]",
|
|
31
36
|
flags: [
|
|
32
37
|
...targetFlags,
|
|
33
|
-
{ name: "file", type: "string", short: "f", value: "<program>", description: "cotal-lang program source (start
|
|
34
|
-
{ name: "
|
|
38
|
+
{ name: "file", type: "string", short: "f", value: "<program>", description: "cotal-lang program source (start; resume --local when no program is recorded)" },
|
|
39
|
+
{ name: "local", type: "boolean", description: "drive in this process instead of on the manager (bare broker, or a run the manager cannot host)" },
|
|
40
|
+
{ name: "endpoint", type: "string", value: "<ep>", description: "endpoint the run record lives under (ps, journal, answer; default: manager)" },
|
|
35
41
|
{ name: "timeout", type: "string", value: "<dur>", description: "default checkpoint timeout for this drive (default: 1h)" },
|
|
36
|
-
{ name: "by", type: "string", value: "<who>", description: "who is answering (answer;
|
|
42
|
+
{ name: "by", type: "string", value: "<who>", description: "who is answering (answer --local only; the manager records the caller)" },
|
|
37
43
|
{ name: "value", type: "string", value: "<json>", description: "checkpoint answer payload as JSON (answer)" },
|
|
38
44
|
{ name: "artifact", type: "string", value: "<ref>", description: "artifact reference attached to the answer (answer)" },
|
|
39
45
|
],
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAuG,MAAM,iBAAiB,CAAC;AACtK,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB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
|
|
372
372
|
*
|
|
373
373
|
* `permits`, `supervise` and `onFork` are POLICY, not identity (§6.4): they ride the journalled
|
|
374
|
-
* request and are enforced where they bind (`permits` at `turn`, `supervise`
|
|
375
|
-
* `onFork` at fork adoption)
|
|
374
|
+
* request and are enforced where they bind (`permits` at `turn`, `supervise` as the manager's
|
|
375
|
+
* restart budget on the spawn submission, an `onFork` at fork adoption).
|
|
376
376
|
*/
|
|
377
377
|
spawn(req: SpawnRequest, ctx: EffectContext): Promise<AgentHandleValue>;
|
|
378
378
|
/**
|
|
@@ -645,6 +645,29 @@ export declare function waitConsumerName(requestId: string): string;
|
|
|
645
645
|
* this wait's to see.
|
|
646
646
|
*/
|
|
647
647
|
export declare function waitConsumerConfig(space: string, requestId: string, channel: string): Record<string, unknown>;
|
|
648
|
+
/**
|
|
649
|
+
* Read a spawn's `permits` as the budgets this host can enforce: `turns`, a positive integer of
|
|
650
|
+
* turns the run may dispatch to the agent, and `wallClock`, a duration from the spawn after which
|
|
651
|
+
* no turn is admitted. Anything else (tokens, spend) is a budget this host has no meter for, and a
|
|
652
|
+
* budget it cannot enforce is refused loudly rather than accepted as a silent no-op.
|
|
653
|
+
*/
|
|
654
|
+
/** The restart budget this host asks the manager to enforce for a spawn. */
|
|
655
|
+
type AgentSupervise = {
|
|
656
|
+
restarts: number;
|
|
657
|
+
windowMs: number;
|
|
658
|
+
};
|
|
659
|
+
/**
|
|
660
|
+
* Read a spawn's `supervise` as the restart policy this host can enforce: `restarts`, a positive
|
|
661
|
+
* integer of in-window process deaths the manager may restart under the same handle, and
|
|
662
|
+
* `window`, an optional duration (default `10m`) those deaths are counted in. Anything else is a
|
|
663
|
+
* policy this host has no restart for, and a policy it cannot enforce is refused loudly rather
|
|
664
|
+
* than accepted as a silent no-op.
|
|
665
|
+
*/
|
|
666
|
+
export declare function readSupervise(raw: unknown, persona: string): AgentSupervise;
|
|
667
|
+
/** The manager `spawn` args a {@link SpawnRequest} submits: persona names the persona file
|
|
668
|
+
* (`name`), `join` becomes the seat's channel subscriptions. `permits` stay on the run (they
|
|
669
|
+
* bind at `turn`); `supervise` travels because the manager is who restarts the process. */
|
|
670
|
+
export declare function spawnArgs(req: SpawnRequest): Record<string, unknown>;
|
|
648
671
|
/**
|
|
649
672
|
* RE-ARM the timers of every pause this run is still holding, under THIS driver's coordinates.
|
|
650
673
|
*
|
|
@@ -695,18 +718,23 @@ export declare function outstandingPauseTokens(entries: readonly JournalEntry[])
|
|
|
695
718
|
/**
|
|
696
719
|
* The settle watcher over EPF, which is where the one-use settle fact lives.
|
|
697
720
|
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
*
|
|
721
|
+
* It POLLS the fact's subject through the plane's own leader-served read rather than binding a
|
|
722
|
+
* consumer to it. The earlier shape created an ephemeral consumer per wait, and an ephemeral create
|
|
723
|
+
* rides the bare `CONSUMER.CREATE.<stream>` form, whose request body is not subject-ACL confinable
|
|
724
|
+
* and which no minted profile may hold (SPEC 13.9). The run driver's credential holds the
|
|
725
|
+
* `STREAM.MSG.GET` read on EPF already, for the same fact, so the watcher reads what the driver can
|
|
726
|
+
* read and nothing more. A settle is a record, not a notification: the fact may already be there
|
|
727
|
+
* when the wait begins, and the first read answers at once.
|
|
728
|
+
*
|
|
729
|
+
* The cadence is the same one the handler already takes its fires on: the deadline is durable and
|
|
730
|
+
* authoritative, and a poll only bounds how late its observation can be.
|
|
703
731
|
*/
|
|
704
732
|
export declare class EpfSettleWatcher implements SettleWatcher {
|
|
705
|
-
private readonly js;
|
|
706
733
|
private readonly jsm;
|
|
707
734
|
private readonly space;
|
|
708
735
|
private readonly pollMs;
|
|
709
|
-
constructor(
|
|
736
|
+
constructor(jsm: JetStreamManager, space: string, pollMs?: number);
|
|
710
737
|
awaitSettle(ref: CheckpointRef): Promise<CheckpointSettleFact>;
|
|
711
738
|
}
|
|
739
|
+
export {};
|
|
712
740
|
//# sourceMappingURL=mesh-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh-handler.d.ts","sourceRoot":"","sources":["../src/mesh-handler.ts"],"names":[],"mappings":"AAmBA,OAAO,
|
|
1
|
+
{"version":3,"file":"mesh-handler.d.ts","sourceRoot":"","sources":["../src/mesh-handler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAyCL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAGzB,KAAK,QAAQ,EAKd,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAO,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EASL,KAAK,UAAU,EACf,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,EAGrB,MAAM,gBAAgB,CAAC;AAExB,kGAAkG;AAClG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;;;;;OASG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,EA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MG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAqB3E;AAkED;;4FAE4F;AAC5F,wBAAgB,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASpE;AAqND;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE;IAAE,EAAE,EAAE,EAAE,CAAC;IAAC,EAAE,EAAE,eAAe,CAAC;IAAC,GAAG,EAAE,gBAAgB,CAAA;CAAE,EAC5D,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,CAAC,EAChF,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,EAAE,CAYjF;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAElD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFN,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,SAAe;IAGlC,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;CASrE"}
|
package/dist/mesh-handler.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* again.
|
|
18
18
|
*/
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
20
|
-
import { mintCheckpoint, heartbeatCheckpoint, resumeCheckpoint, readCheckpointSettle, readCheckpointAnswer, readCheckpointStatus, readCheckpointSpec, reconcileCheckpointSchedule, handleCheckpointFire,
|
|
20
|
+
import { mintCheckpoint, heartbeatCheckpoint, resumeCheckpoint, readCheckpointSettle, readCheckpointAnswer, readCheckpointStatus, readCheckpointSpec, reconcileCheckpointSchedule, handleCheckpointFire, eptStreamName, eptSubject, chatStream, chatSubject, isConcreteChannel, assertSafePattern, assertValidChannel, presenceBucket, liveKvEntries, IncompleteKvScan, openMembersRegistry, openChannelRegistry, writeChannelConfig, readMember, commitMember, tombstoneMember, StaleMembershipWrite, runNoticeId, writeRunNotice, actionContext, invokeCommand, readGoalResult, readGoalStatus, resolveService, listRunNotices, markRunNoticeConsumed, listRunNoticesForRun, readRunRecord, writeRunStatus, EpEnvelopeError, } from "@cotal-ai/core";
|
|
21
21
|
import { renderRunContext } from "./run-context.js";
|
|
22
22
|
import { Kvm } from "@nats-io/kv";
|
|
23
23
|
import { parseDuration, Cancelled, EffectError, Journal, EffectRefused, askSchemaShape, conformsToAskSchema, journalEntryKeyString, stepKeyString, } from "@cotal-ai/lang";
|
|
@@ -895,8 +895,8 @@ export class MeshHandler {
|
|
|
895
895
|
* and the fact is the thing a resume can still read.
|
|
896
896
|
*
|
|
897
897
|
* `permits`, `supervise` and `onFork` are POLICY, not identity (§6.4): they ride the journalled
|
|
898
|
-
* request and are enforced where they bind (`permits` at `turn`, `supervise`
|
|
899
|
-
* `onFork` at fork adoption)
|
|
898
|
+
* request and are enforced where they bind (`permits` at `turn`, `supervise` as the manager's
|
|
899
|
+
* restart budget on the spawn submission, an `onFork` at fork adoption).
|
|
900
900
|
*/
|
|
901
901
|
async spawn(req, ctx) {
|
|
902
902
|
if (ctx.signal.cancelled)
|
|
@@ -913,12 +913,12 @@ export class MeshHandler {
|
|
|
913
913
|
// A budget this host cannot meter is refused before anything is submitted: accepting it and
|
|
914
914
|
// enforcing nothing would be the silent no-op the effect table exists to prevent.
|
|
915
915
|
const permits = req.permits !== undefined ? readPermits(req.permits, req.persona) : undefined;
|
|
916
|
-
// Same rule, for the other policy option. `supervise` is
|
|
917
|
-
//
|
|
918
|
-
//
|
|
919
|
-
//
|
|
916
|
+
// Same rule, for the other policy option. `supervise` is a declarative restart policy: it
|
|
917
|
+
// is parsed here (a malformed or unknown-key record is refused before anything is submitted)
|
|
918
|
+
// and travels on the spawn args so the manager can restart the seat in place. A host that
|
|
919
|
+
// cannot restart in place refuses at accept rather than accepting a silent no-op.
|
|
920
920
|
if (req.supervise !== undefined)
|
|
921
|
-
|
|
921
|
+
readSupervise(req.supervise, req.persona);
|
|
922
922
|
// A seat a migration kept for this persona (§11.2): the orphaned spawn's GOAL becomes this
|
|
923
923
|
// step's own, bound with that spawn's floor and the step it came from. From here the two kinds
|
|
924
924
|
// of spawn are one path — the terminal is read under the bound goal, the handle comes from it,
|
|
@@ -1968,11 +1968,36 @@ export function waitConsumerConfig(space, requestId, channel) {
|
|
|
1968
1968
|
* late its observation can be, and a shorter poll buys latency at the cost of fetch traffic. */
|
|
1969
1969
|
const WAIT_POLL_MS = 2_000;
|
|
1970
1970
|
/**
|
|
1971
|
-
* Read a spawn's `
|
|
1972
|
-
*
|
|
1973
|
-
*
|
|
1974
|
-
*
|
|
1971
|
+
* Read a spawn's `supervise` as the restart policy this host can enforce: `restarts`, a positive
|
|
1972
|
+
* integer of in-window process deaths the manager may restart under the same handle, and
|
|
1973
|
+
* `window`, an optional duration (default `10m`) those deaths are counted in. Anything else is a
|
|
1974
|
+
* policy this host has no restart for, and a policy it cannot enforce is refused loudly rather
|
|
1975
|
+
* than accepted as a silent no-op.
|
|
1975
1976
|
*/
|
|
1977
|
+
export function readSupervise(raw, persona) {
|
|
1978
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
1979
|
+
throw new Error(`spawn(${persona}): supervise must be a record of { restarts, window? }, got ${JSON.stringify(raw)}`);
|
|
1980
|
+
let restarts;
|
|
1981
|
+
let windowMs;
|
|
1982
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
1983
|
+
if (key === "restarts") {
|
|
1984
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 1)
|
|
1985
|
+
throw new Error(`spawn(${persona}): supervise.restarts must be a positive integer, got ${JSON.stringify(value)}`);
|
|
1986
|
+
restarts = value;
|
|
1987
|
+
}
|
|
1988
|
+
else if (key === "window") {
|
|
1989
|
+
if (typeof value !== "string")
|
|
1990
|
+
throw new Error(`spawn(${persona}): supervise.window must be a duration string, got ${JSON.stringify(value)}`);
|
|
1991
|
+
windowMs = parseDuration(value);
|
|
1992
|
+
}
|
|
1993
|
+
else {
|
|
1994
|
+
throw new Error(`spawn(${persona}): supervise.${key} is not a restart policy this host enforces; it takes restarts and window, and a policy it cannot enforce is refused rather than ignored`);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
if (restarts === undefined)
|
|
1998
|
+
throw new Error(`spawn(${persona}): supervise.restarts must be a positive integer`);
|
|
1999
|
+
return { restarts, windowMs: windowMs ?? parseDuration("10m") };
|
|
2000
|
+
}
|
|
1976
2001
|
function readPermits(raw, persona) {
|
|
1977
2002
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
1978
2003
|
throw new Error(`spawn(${persona}): permits must be a record of budgets, got ${JSON.stringify(raw)}`);
|
|
@@ -2033,14 +2058,16 @@ function scopeOf(key) {
|
|
|
2033
2058
|
* crash-before-bind case). Matches the manager's default readiness budget. */
|
|
2034
2059
|
const DISCHARGE_TERMINAL_BOUND_MS = 30_000;
|
|
2035
2060
|
/** The manager `spawn` args a {@link SpawnRequest} submits: persona names the persona file
|
|
2036
|
-
* (`name`), `join` becomes the seat's channel subscriptions.
|
|
2037
|
-
|
|
2061
|
+
* (`name`), `join` becomes the seat's channel subscriptions. `permits` stay on the run (they
|
|
2062
|
+
* bind at `turn`); `supervise` travels because the manager is who restarts the process. */
|
|
2063
|
+
export function spawnArgs(req) {
|
|
2038
2064
|
return {
|
|
2039
2065
|
name: req.persona,
|
|
2040
2066
|
...(req.model !== undefined ? { model: req.model } : {}),
|
|
2041
2067
|
...(req.variant !== undefined ? { variant: req.variant } : {}),
|
|
2042
2068
|
...(req.role !== undefined ? { role: req.role } : {}),
|
|
2043
2069
|
...(req.join !== undefined && req.join.length > 0 ? { subscribe: req.join.map((c) => c.channel) } : {}),
|
|
2070
|
+
...(req.supervise !== undefined ? { supervise: readSupervise(req.supervise, req.persona) } : {}),
|
|
2044
2071
|
};
|
|
2045
2072
|
}
|
|
2046
2073
|
/** The acceptance-floor fields worth binding: the allocated identity a discharge despawns by, and
|
|
@@ -2302,56 +2329,34 @@ export function outstandingPauseTokens(entries) {
|
|
|
2302
2329
|
/**
|
|
2303
2330
|
* The settle watcher over EPF, which is where the one-use settle fact lives.
|
|
2304
2331
|
*
|
|
2305
|
-
*
|
|
2306
|
-
*
|
|
2307
|
-
*
|
|
2308
|
-
*
|
|
2309
|
-
*
|
|
2332
|
+
* It POLLS the fact's subject through the plane's own leader-served read rather than binding a
|
|
2333
|
+
* consumer to it. The earlier shape created an ephemeral consumer per wait, and an ephemeral create
|
|
2334
|
+
* rides the bare `CONSUMER.CREATE.<stream>` form, whose request body is not subject-ACL confinable
|
|
2335
|
+
* and which no minted profile may hold (SPEC 13.9). The run driver's credential holds the
|
|
2336
|
+
* `STREAM.MSG.GET` read on EPF already, for the same fact, so the watcher reads what the driver can
|
|
2337
|
+
* read and nothing more. A settle is a record, not a notification: the fact may already be there
|
|
2338
|
+
* when the wait begins, and the first read answers at once.
|
|
2339
|
+
*
|
|
2340
|
+
* The cadence is the same one the handler already takes its fires on: the deadline is durable and
|
|
2341
|
+
* authoritative, and a poll only bounds how late its observation can be.
|
|
2310
2342
|
*/
|
|
2311
2343
|
export class EpfSettleWatcher {
|
|
2312
|
-
js;
|
|
2313
2344
|
jsm;
|
|
2314
2345
|
space;
|
|
2315
2346
|
pollMs;
|
|
2316
|
-
constructor(
|
|
2317
|
-
this.js = js;
|
|
2347
|
+
constructor(jsm, space, pollMs = FIRE_POLL_MS) {
|
|
2318
2348
|
this.jsm = jsm;
|
|
2319
2349
|
this.space = space;
|
|
2320
2350
|
this.pollMs = pollMs;
|
|
2321
2351
|
}
|
|
2322
2352
|
async awaitSettle(ref) {
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
});
|
|
2331
|
-
const name = created.name;
|
|
2332
|
-
try {
|
|
2333
|
-
const consumer = await this.js.consumers.get(stream, name);
|
|
2334
|
-
for (;;) {
|
|
2335
|
-
const batch = await consumer.fetch({ max_messages: 1, expires: this.pollMs });
|
|
2336
|
-
for await (const m of batch) {
|
|
2337
|
-
m.ack();
|
|
2338
|
-
const settled = await readCheckpointSettle(this.jsm, this.space, ref);
|
|
2339
|
-
// Read the fact back through the plane's own parser rather than trusting these bytes: the
|
|
2340
|
-
// subject is one-use, so whatever is on it IS the answer, and the parser is what says the
|
|
2341
|
-
// answer is well formed.
|
|
2342
|
-
if (settled !== undefined)
|
|
2343
|
-
return settled;
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
finally {
|
|
2348
|
-
try {
|
|
2349
|
-
await this.jsm.consumers.delete(stream, name);
|
|
2350
|
-
}
|
|
2351
|
-
catch {
|
|
2352
|
-
// The consumer carries its own inactivity threshold, so a failed delete is reaped rather
|
|
2353
|
-
// than leaked — the case `run-journal` had to learn the hard way.
|
|
2354
|
-
}
|
|
2353
|
+
for (;;) {
|
|
2354
|
+
const settled = await readCheckpointSettle(this.jsm, this.space, ref);
|
|
2355
|
+
if (settled !== undefined)
|
|
2356
|
+
return settled;
|
|
2357
|
+
// Unrefed: a wait that loses its race to a cancellation or a fire must not hold the process
|
|
2358
|
+
// open for one more poll on its way out.
|
|
2359
|
+
await new Promise((r) => setTimeout(r, this.pollMs).unref());
|
|
2355
2360
|
}
|
|
2356
2361
|
}
|
|
2357
2362
|
}
|