@smthrs/control 1.0.0-rc.3 → 1.0.0-rc.4
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/cjs/ControlLive.d.ts.map +1 -1
- package/dist/cjs/ControlLive.js +21 -8
- package/dist/cjs/ControlLive.js.map +2 -2
- package/dist/cjs/ControlRuntime.d.ts.map +1 -1
- package/dist/cjs/ControlRuntime.js +64 -60
- package/dist/cjs/ControlRuntime.js.map +2 -2
- package/dist/cjs/SqlControlRuntime.d.ts.map +1 -1
- package/dist/cjs/SqlControlRuntime.js +3 -2
- package/dist/cjs/SqlControlRuntime.js.map +2 -2
- package/dist/esm/ControlLive.d.ts.map +1 -1
- package/dist/esm/ControlLive.js +5 -1
- package/dist/esm/ControlLive.js.map +1 -1
- package/dist/esm/ControlRuntime.d.ts.map +1 -1
- package/dist/esm/ControlRuntime.js +2 -1
- package/dist/esm/ControlRuntime.js.map +1 -1
- package/dist/esm/SqlControlRuntime.d.ts.map +1 -1
- package/dist/esm/SqlControlRuntime.js +2 -2
- package/dist/esm/SqlControlRuntime.js.map +1 -1
- package/docs/guides/postgres-tests.md +2 -0
- package/package.json +17 -17
- package/src/ControlLive.ts +22 -8
- package/src/ControlRuntime.ts +66 -62
- package/src/SqlControlRuntime.ts +4 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ControlRuntime.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Browser-safe port between the control plane and the execution engine, with a\n * deterministic in-memory implementation.\n *\n * `layerMemory` is the deterministic one: it models the production fence and\n * approval ordering seams but keeps everything in a `Map`, so nothing it\n * decides survives the process. The durable adapter is\n * {@link SqlControlRuntime}, and both are held to one shared contract suite \u2014\n * see `test/ControlContract.ts`.\n *\n * @since 0.1.0\n */\n\nimport * as Fault from \"@smthrs/flow/Fault\"\nimport type * as PersistedPlan from \"@smthrs/plan/Plan\"\nimport { Context, Crypto, Effect, Fiber, Layer, Option, Schema } from \"effect\"\nimport * as ApprovalAuthority from \"./ApprovalAuthority.ts\"\nimport type { ApprovalTarget, PlanInput } from \"./Control.ts\"\nimport {\n AlreadyResolved,\n ClaimLost,\n type CodeDrift,\n EnvelopeMismatch,\n FlowNotFound,\n InvalidInput,\n PersistenceError,\n PlanDenied,\n PlanDigestMismatch,\n PlanNotFound,\n RunNotFound,\n type Unauthorized\n} from \"./ControlError.ts\"\nimport type {\n Envelope,\n FlowId,\n GrantScope,\n IdempotencyKey,\n PlanCard,\n PlanDecision,\n PlanGraph,\n PlanNode,\n Principal,\n Receipt,\n RunId,\n RunStatus,\n RunSummary,\n SignalPayload\n} from \"./ControlSchema.ts\"\nimport { GrantScope as GrantScopeSchema, Principal as PrincipalSchema } from \"./ControlSchema.ts\"\nimport { canonicalIssue } from \"./internal/issues.ts\"\nimport {\n accepted,\n adoptedCode,\n alreadyApplied as replayReceipt,\n budgeted,\n canonical,\n codeDriftOf,\n emptyEnvelope,\n planCard,\n planFingerprint,\n sameEnvelope\n} from \"./internal/planning.ts\"\nimport { plannable } from \"./SystemFlows.ts\"\n\n/**\n * Immutable ordering keys for a run page. Control launches precede engine runs.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface RunCursor {\n readonly source: 0 | 1\n readonly sequence: number\n readonly createdAt: number\n readonly runId: RunId\n}\n\n/**\n * Durable summary filters, applied before projection and executor observation.\n * `limit` must be an integer from 1 through 500. Reuse a cursor with the same filters.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface RunQuery {\n readonly filters?: {\n readonly flowId?: FlowId | undefined\n readonly status?: RunStatus | undefined\n readonly terminal?: boolean | undefined\n readonly parentRunId?: RunId | undefined\n readonly lineageId?: string | undefined\n /** Created at or after this epoch millisecond. */\n readonly since?: number | undefined\n /** Created before this epoch millisecond. */\n readonly until?: number | undefined\n /** Only these runs; an empty list selects none. */\n readonly runIds?: ReadonlyArray<RunId> | undefined\n /**\n * Only runs this plane launched for a principal with this `id`, and this\n * `kind` when given. A run with no recorded launcher never matches.\n */\n readonly launchedBy?: { readonly id: string; readonly kind?: string | undefined } | undefined\n } | undefined\n /** Creation time first, newest or oldest; ties use the durable sequence. */\n readonly order?: \"newest\" | \"oldest\" | undefined\n readonly cursor?: RunCursor | undefined\n readonly limit: number\n}\n\n/**\n * Whether `run` was launched by the principal `launcher` names: the same `id`,\n * and the same `kind` when `launcher` gives one. A run with no recorded\n * launcher never matches.\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const launchedByMatches = (\n run: Pick<RunSummary, \"launchedBy\">,\n launcher: { readonly id: string; readonly kind?: string | undefined }\n): boolean =>\n run.launchedBy !== undefined && run.launchedBy.id === launcher.id &&\n (launcher.kind === undefined || run.launchedBy.kind === launcher.kind)\n\n/**\n * A bounded page; the cursor names the last selected row, even if retention removed it.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface RunPage {\n readonly items: ReadonlyArray<RunSummary>\n readonly nextCursor?: RunCursor | undefined\n}\n\n/**\n * One page of an inventory walk. `next` is the position to pass as `after`\n * for the following page; it is absent on the last page. `through` is the\n * highest position the walk covers: the first page pins it to the newest\n * entry at that moment, and the caller passes it back unchanged so every\n * later page stops there. A walk therefore ends even while new entries keep\n * arriving; they sort after `through` and belong to the next walk.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface IdPage {\n readonly ids: ReadonlyArray<string>\n readonly next?: number | undefined\n readonly through: number\n}\n\n/**\n * An inventory page request. Positions are the store's insertion-ordered row\n * key, so each page is one indexed seek. `limit` must be an integer from 1\n * through 500.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface IdPageRequest {\n readonly after?: number | undefined\n readonly through?: number | undefined\n readonly limit: number\n}\n\n/**\n * A durably admitted signal, bound at most once to one concrete wait token.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface SignalCommand {\n readonly commandId: string\n readonly runId: RunId\n readonly signal: SignalPayload\n readonly token: string | null\n readonly state: \"pending\" | \"delivered\" | \"rejected\" | \"terminal\"\n /**\n * Who admitted the signal, stamped at admission. The executor checks it\n * against `authorizeApproval` before the signal may complete a human wait,\n * and a replay after restart reads it here because no caller is present.\n * Absent on commands admitted before the column existed, which therefore\n * cannot answer a human wait.\n */\n readonly principal?: Principal | undefined\n}\n\n/**\n * A stored-plan page request: plans oldest first, after the insertion position\n * `after`, narrowed by flow and decision. `limit` must be an integer from 1\n * through 500.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface PlanQuery {\n readonly flowId?: FlowId | undefined\n readonly decision?: PlanDecision | undefined\n readonly after?: number | undefined\n readonly limit: number\n}\n\n/**\n * One page of stored plans. `next` is the insertion position a later page\n * continues after, present while more plans may match.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface PlanPage {\n readonly plans: ReadonlyArray<StoredPlan>\n readonly next?: number | undefined\n}\n\n/**\n * A decoded input and immutable plan stored before execution.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface StoredPlan {\n readonly card: PlanCard\n readonly decodedInput: unknown\n readonly decision: PlanDecision\n}\n\n/**\n * The durable answer to an approval request. A decision is not inferred from\n * the presence of a grant or from a boolean that also means denial.\n *\n * @category models\n * @since 0.1.0\n */\nexport const ApprovalDecision = Schema.Union([\n Schema.Struct({ _tag: Schema.Literal(\"Pending\") }),\n Schema.Struct({\n _tag: Schema.Literal(\"Approved\"),\n decisionPrincipal: PrincipalSchema,\n decidedAt: Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0)),\n scope: GrantScopeSchema\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Denied\"),\n decisionPrincipal: PrincipalSchema,\n decidedAt: Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))\n })\n])\n\n/**\n * Durable approval state.\n * @category models\n * @since 1.0.0\n */\nexport type ApprovalDecision = typeof ApprovalDecision.Type\n\n/**\n * An identity and its explicit approval decision.\n * @category models\n * @since 1.0.0\n */\nexport type ApprovalToken = ApprovalDecision & {\n readonly tokenId: string\n readonly target: ApprovalTarget\n}\n\n/**\n * A gate that still needs a decision.\n * @category errors\n * @since 1.0.0\n */\nexport class ApprovalPending extends Schema.TaggedError<ApprovalPending>()(\"/control/ApprovalPending\", {\n tokenId: Schema.String\n}) {\n override get message(): string {\n return \"Approval is still pending. Wait for a decision before proceeding.\"\n }\n}\n\n/**\n * A gate that was denied, not merely resolved.\n * @category errors\n * @since 1.0.0\n */\nexport class ApprovalDenied extends Schema.TaggedError<ApprovalDenied>()(\"/control/ApprovalDenied\", {\n tokenId: Schema.String,\n decisionPrincipal: PrincipalSchema\n}) {\n override get message(): string {\n return \"Approval was denied. This request cannot authorize the gated work.\"\n }\n}\n\n/**\n * Opens only an explicitly approved gate. Callers may park on ApprovalPending;\n * ApprovalDenied is terminal. This reads a runtime-issued token, not an\n * authentication credential, and does not itself install permissions.\n * @category combinators\n * @since 1.0.0\n */\nexport const requireApproved = (\n token: ApprovalToken\n): Effect.Effect<Extract<ApprovalToken, { readonly _tag: \"Approved\" }>, ApprovalPending | ApprovalDenied> =>\n token._tag === \"Approved\"\n ? Effect.succeed(token)\n : token._tag === \"Pending\"\n ? Effect.fail(new ApprovalPending({ tokenId: token.tokenId }))\n : Effect.fail(new ApprovalDenied({ tokenId: token.tokenId, decisionPrincipal: token.decisionPrincipal }))\n\n/**\n * One bulk permission grant. The envelope is deliberately not split into\n * individual capabilities at this boundary.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface BulkGrant {\n readonly tokenId: string\n readonly envelope: Envelope\n readonly scope: GrantScope\n readonly installedAt: number\n}\n\n/**\n * Result of launching an approved plan.\n *\n * @category models\n * @since 0.1.0\n */\nexport type LaunchResult =\n | {\n readonly _tag: \"Started\"\n readonly receipt: Receipt\n readonly run: RunSummary\n }\n | {\n readonly _tag: \"Parked\"\n readonly receipt: Receipt\n }\n\n/**\n * A plan card and whether this call is the one that created it.\n *\n * A plan under an idempotency key the runtime has already seen answers with the\n * STORED card, which is what idempotency means. `Control.plan` needs to tell\n * that apart from a first ask, because it journals `control.plan.created` and\n * an unconditional entry appended one creation per retry: `Channels.ingest`\n * passes a key on every webhook redelivery, so a watcher of the plan partition\n * replayed N creations of one plan.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface PlanOutcome {\n readonly card: PlanCard\n readonly created: boolean\n}\n\n/**\n * A stored idempotency-key outcome and the mutation fingerprint that produced\n * it.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface MutationRecord {\n readonly fingerprint: string\n readonly receipt: Receipt\n}\n\n/**\n * The outcome of claiming a run mutation's idempotency key before launch.\n *\n * `Claimed` is this call's mandate to launch: the key row was empty or did not\n * exist, and it now names this call. `Raced` is the resolution the plan verb's\n * key claim gives a loser \u2014 another mutation claimed the key first, and the\n * receipt it settled is the answer this call must return instead of launching\n * a second run.\n *\n * @category models\n * @since 0.1.0\n */\nexport type RunKeyClaim =\n | { readonly _tag: \"Claimed\" }\n | { readonly _tag: \"Raced\"; readonly receipt: Receipt }\n\n/**\n * Flow metadata used by the memory runtime's input-decoding hook.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface MemoryFlow {\n readonly flowId: FlowId\n readonly description: string\n readonly deployClass: boolean\n readonly envelope: Envelope\n /** Executable source/metadata identity included in the approved card. */\n readonly executionDigest?: string | undefined\n readonly decode?: ((input: unknown) => Effect.Effect<unknown, InvalidInput>) | undefined\n /**\n * Projects the decoded input into the keyed node graph the card reports.\n *\n * Planning performs no I/O, so this is a pure function of the input: the\n * host builds the graph (`@smthrs/core`'s `Graph.build`), keys it\n * (`@smthrs/plan`'s compiler), and reports each node as `cached` or `run`\n * against whatever step cache it holds.\n */\n readonly plan?:\n | ((\n input: unknown,\n planId: string\n ) => Effect.Effect<{\n readonly plan: PersistedPlan.Plan\n readonly statuses?: Readonly<Record<string, PlanNode[\"status\"]>> | undefined\n /** The built graph's labelled edges and declaration sites, reported outside the approval digest. */\n readonly graph?: PlanGraph | undefined\n }, InvalidInput>)\n | undefined\n}\n\n/**\n * In-memory runtime configuration.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface MemoryOptions {\n readonly flows?: ReadonlyArray<MemoryFlow> | undefined\n readonly now?: (() => number) | undefined\n readonly principal?: Omit<Principal, \"stampedAt\"> | undefined\n readonly approvalAuthority?: ApprovalAuthority.Service | undefined\n /** The engine version stamped on every run this runtime starts. */\n readonly engineVersion?: string | undefined\n}\n\n/**\n * One run that has been told to resume, and the sequence of the request.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface PendingResume {\n readonly runId: RunId\n readonly sequence: number\n /**\n * When the delegation was recorded.\n *\n * A host reads it to tell a decision it has just been handed from one that\n * has been standing unanswered: a run parked by a process that has since\n * exited has nobody left to recognize its own park, so its delegation is\n * taken up by whichever host can drive it once it has gone unanswered for\n * `Ownership.heartbeatStaleAfter` (triage B-15).\n */\n readonly requestedAtMs: number\n /**\n * The journal sequence of the operator's explicit `control.run.resume`\n * this delegation carries, when it carries one.\n *\n * An approval or a wake is background intent. An operator's resume of a\n * run a live host parked is handed to that host as a delegation too, and\n * this is what tells the host the operator asked: it records the\n * per-release retry permission under this sequence before it drives the\n * run (#2982, #3342).\n */\n readonly consent?: number | undefined\n}\n\n/**\n * Execution-engine operations required by `ControlLive`.\n *\n * A production adapter must fence every owner-sensitive write, implement\n * resume as join-or-claim, release claims on every waiting or terminal\n * transition, and translate all conflicts into typed failures. For a new\n * approval decision, authenticate the principal and call `authorizeApproval`\n * before target reads or receipt replay. Then call `lookupApproval`,\n * `resolveApproval` exactly once with an authority recheck, `installBulkGrant`\n * only on approval, and journal the decision. Commit the decision, grant,\n * journal entry, receipt, and any node resume delegation atomically. Resolution\n * must not require an installed grant or a flushed journal decision.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Service {\n /** The owning host's policy, independent of authentication and attribution. */\n readonly authorizeApproval: ApprovalAuthority.Service[\"authorize\"]\n readonly plan: (input: PlanInput) => Effect.Effect<PlanOutcome, FlowNotFound | InvalidInput | PersistenceError>\n readonly getPlan: (planId: string) => Effect.Effect<StoredPlan, PlanNotFound | PersistenceError>\n /** Plan ids in insertion order, one bounded page at a time. */\n readonly pagePlanIds: (\n request: IdPageRequest\n ) => Effect.Effect<IdPage, InvalidInput | PersistenceError>\n /** Stored plans in insertion order, narrowed by flow and decision, one bounded page at a time. */\n readonly queryPlans: (request: PlanQuery) => Effect.Effect<PlanPage, InvalidInput | PersistenceError>\n readonly lookupApproval: (\n target: ApprovalTarget\n ) => Effect.Effect<\n ApprovalToken,\n PlanDigestMismatch | EnvelopeMismatch | AlreadyResolved | PlanNotFound | RunNotFound | PersistenceError\n >\n /**\n * Creates the durable token for one in-run approval request, or returns the\n * existing one.\n *\n * Plan tokens are created by `plan`; nothing created tokens for `Node`\n * targets, so an in-run request (a parked `ask`, a permission requirement)\n * could never be decided through `approve`/`deny`. Registration is\n * idempotent \u2014 the executor calls it on every parked attempt \u2014 and returns\n * the token with its current tagged decision so a resumed attempt can read\n * the decision instead of parking again. A registered target that\n * disagrees with the stored digest or envelope is refused, exactly as\n * `lookupApproval` refuses it.\n */\n readonly registerApproval: (\n target: Extract<ApprovalTarget, { readonly _tag: \"Node\" }>\n ) => Effect.Effect<\n ApprovalToken,\n RunNotFound | PlanDigestMismatch | EnvelopeMismatch | PersistenceError\n >\n readonly installBulkGrant: (\n token: ApprovalToken,\n envelope: Envelope,\n scope: GrantScope\n ) => Effect.Effect<void, PersistenceError>\n /** Records the decision exactly once. Approval scope defaults to once; the\n * control boundary supplies the scope of the grant it installed. */\n readonly resolveApproval: (\n token: ApprovalToken,\n decision: \"approved\" | \"denied\",\n principal: Principal,\n scope?: GrantScope | undefined\n ) => Effect.Effect<void, AlreadyResolved | PersistenceError | Unauthorized>\n /**\n * Starts an approved plan. `principal` is the identity that asked; its `id`\n * and `kind` are recorded as the run's `launchedBy`, which decides which\n * readers a restricted listing or watch shows the run to.\n */\n readonly launch: (\n planId: string,\n digest: string,\n envelope: Envelope,\n principal?: Principal | undefined,\n reservedRunId?: RunId | undefined\n ) => Effect.Effect<\n LaunchResult,\n PlanNotFound | PlanDenied | PlanDigestMismatch | EnvelopeMismatch | ClaimLost | PersistenceError\n >\n readonly getRun: (runId: RunId) => Effect.Effect<RunSummary, RunNotFound | PersistenceError>\n /**\n * Every durable run id in insertion order, one bounded page at a time, for\n * recovery and journal partition discovery. Reads keys only; use queryRuns\n * for summaries.\n */\n readonly pageRunIds: (\n request: IdPageRequest\n ) => Effect.Effect<IdPage, InvalidInput | PersistenceError>\n readonly queryRuns: (request: RunQuery) => Effect.Effect<RunPage, InvalidInput | PersistenceError>\n readonly listFlows: Effect.Effect<\n ReadonlyArray<{ readonly flowId: FlowId; readonly description: string }>,\n PersistenceError\n >\n readonly deliverSignal: (runId: RunId, signal: SignalPayload) => Effect.Effect<void, RunNotFound | PersistenceError>\n readonly admitSignal: (\n commandId: string,\n runId: RunId,\n signal: SignalPayload,\n principal?: Principal | undefined\n ) => Effect.Effect<void, RunNotFound | PersistenceError>\n readonly signalCommand: (commandId: string) => Effect.Effect<SignalCommand | undefined, PersistenceError>\n readonly pendingSignals: Effect.Effect<ReadonlyArray<SignalCommand>, PersistenceError>\n readonly bindSignal: (commandId: string, token: string) => Effect.Effect<string | null, PersistenceError>\n readonly settleSignal: (\n commandId: string,\n state: \"delivered\" | \"rejected\" | \"terminal\"\n ) => Effect.Effect<void, PersistenceError>\n readonly deliveredSignals: (\n runId: RunId\n ) => Effect.Effect<ReadonlyArray<SignalPayload>, RunNotFound | PersistenceError>\n /**\n * Records, durably, that this run has been told to resume.\n *\n * The record is the delegation. A decision on an in-run approval can be\n * taken by any process holding the control database, and only the process\n * hosting the execution can act on it, so the intent has to outlive the call\n * that made it: an in-process event bus reaches one process, and a journal\n * entry is per run and needs a reader that already knows which run to read.\n * The returned sequence is the cursor {@link Service.clearResume} checks, so\n * a resume requested while one is being taken up is not lost with it.\n *\n * A terminal run is refused with `InvalidInput`: no host will ever take the\n * delegation up, and recording it would leave an orphaned row every host's\n * `pendingResumes` poll filters but nothing ever clears.\n *\n * `consent` is the journal sequence of an operator's explicit resume (see\n * {@link PendingResume.consent}). A later delegation without one keeps the\n * consent no host has taken up yet.\n */\n readonly requestResume: (\n runId: RunId,\n options?: { readonly consent?: number | undefined } | undefined\n ) => Effect.Effect<number, RunNotFound | InvalidInput | PersistenceError>\n /**\n * Every outstanding resume delegation for a run that is not terminal.\n *\n * This is what a host polls. A settled run's delegation is not reported: no\n * host will ever take it up, and reporting it forever would make an\n * unbounded backlog out of a run that is finished.\n */\n readonly pendingResumes: Effect.Effect<ReadonlyArray<PendingResume>, PersistenceError>\n /**\n * Clears a delegation a host has taken up, if it is still the one it read.\n *\n * The sequence check is what makes the clear safe: a resume requested\n * between the read and the clear has a higher sequence and survives, so the\n * host takes it up on its next tick instead of losing it.\n */\n readonly clearResume: (runId: RunId, sequence: number) => Effect.Effect<void, PersistenceError>\n readonly registerFiber: (\n runId: RunId,\n fiber: Fiber.Fiber<unknown, unknown>\n ) => Effect.Effect<void, RunNotFound | PersistenceError>\n /**\n * Interrupts and awaits the local fiber with no caller-held mutation locks.\n * `settle` wraps only the subsequent fenced status reconciliation, allowing\n * ControlLive to commit its terminal event in the same transaction.\n */\n readonly interrupt: (\n runId: RunId,\n settle?: (\n effect: Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n /**\n * Joins an owned run or claims a suspended run or expired dead-owner run.\n *\n * `scope: \"launched\"` restricts claims to runs this plane launched, including\n * dead-owner takeovers. An unindexed run is refused with `ClaimLost`; a run\n * already owned by this process is joined without changing its state.\n * Both `Control.resume` and `Control.run` with a Resume input, plus steer\n * wakes, pass it to preserve an engine-created run's continuation and fence.\n * `scope: \"any\"` (also the default) is a trusted low-level runtime\n * capability for hosts that can drive the claimed execution. Node approval\n * uses `requestResume` delegation instead of claiming here.\n */\n readonly resume: (\n runId: RunId,\n options?: {\n readonly scope?: \"launched\" | \"any\" | undefined\n } | undefined\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n /**\n * `resume`, recording the flow's current execution digest and this\n * runtime's engine version on the claimed run: the operator allowed it to\n * resume on changed code, so later checks compare against that code. A flow\n * that no longer exists, or that this host cannot run, has no code to adopt,\n * so this fails `CodeDrift` before the claim and the run stays where it was.\n */\n readonly resumeAdopting: (\n runId: RunId,\n options?: { readonly scope?: \"launched\" | \"any\" | undefined } | undefined\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | CodeDrift | PersistenceError>\n /**\n * The drift between the code the run recorded and the code that would\n * resume it, or `undefined` when there is none. Every path that re-drives a\n * parked run asks this before it claims or delegates; recovery paths that\n * only settle a run do not.\n */\n readonly codeDrift: (runId: RunId) => Effect.Effect<CodeDrift | undefined, RunNotFound | PersistenceError>\n /**\n * The code identity the run executes under: its own recorded digest and\n * engine version, or, for a row that recorded none (a trampoline round, or a\n * fork or child the engine wrote), those of its nearest same-flow ancestor.\n * `codeDrift` checks this identity, so an executor that enters the identity\n * read here runs exactly the code the check admitted.\n */\n readonly recordedCode: (\n runId: RunId\n ) => Effect.Effect<Pick<RunSummary, \"executionDigest\" | \"engineVersion\">, RunNotFound | PersistenceError>\n readonly claimFence: (runId: RunId) => Effect.Effect<string, RunNotFound | ClaimLost | PersistenceError>\n /**\n * Releases a launch the configured executor declined without changing its\n * public `accepted` status.\n *\n * The run remains available to an external executor, but the launching\n * process no longer appears to drive it. The presented fence is spent by\n * the release and cannot authorize a later write.\n */\n readonly releasePending: (\n runId: RunId,\n fence: string\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n readonly writeStatus: (\n runId: RunId,\n fence: string,\n status: RunStatus\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n readonly stampPrincipal: (submitted?: Principal | undefined) => Effect.Effect<Principal, PersistenceError>\n readonly lookupMutation: (\n key: IdempotencyKey,\n fingerprint: string\n ) => Effect.Effect<Receipt | undefined, PersistenceError>\n readonly recordMutation: (\n key: IdempotencyKey,\n fingerprint: string,\n receipt: Receipt\n ) => Effect.Effect<void, PersistenceError>\n /**\n * Claims a run mutation's idempotency key before any launch side effect.\n *\n * This is the run verb's half of the race `control_plan_keys` closes for\n * plans: a bare `lookupMutation`/`recordMutation` pair leaves two processes\n * that both missed the lookup free to both launch, and the loser's run row\n * outlives the `recordMutation` refusal that follows. The claim must run\n * FIRST, inside the same write transaction the mutation later records its\n * receipt in, so the loser's insert conflicts on the winner's committed key\n * row before a run row, a claim, or a journal entry exists \u2014 and the winner's\n * receipt, committed in that same transaction, is already there to read.\n *\n * `Raced` carries the winner's recorded receipt verbatim, which is the\n * convergence the plan verb gives a losing planner (`created: false` with\n * the stored card). A key claimed under another fingerprint is refused with\n * `InvalidInput`, the same refusal `plan` gives a colliding key. A key row\n * whose winner never recorded \u2014 possible only when the claim and the record\n * were not one transaction \u2014 is a `PersistenceError`, because there is no\n * honest receipt to answer with.\n */\n readonly claimRunKey: (\n key: IdempotencyKey,\n fingerprint: string\n ) => Effect.Effect<RunKeyClaim, InvalidInput | PersistenceError>\n /**\n * Releases a claim {@link Service.claimRunKey} took, without a receipt.\n *\n * Exactly one path needs it: a launch that answered `Parked` created no run\n * and records no receipt, so the claim must be withdrawn inside the same\n * transaction or the key would stay held forever by a mutation that settled\n * nothing. Every other outcome either records a receipt (the claim's whole\n * point) or fails and rolls the claim back with its transaction.\n */\n readonly releaseRunKey: (key: IdempotencyKey) => Effect.Effect<void, PersistenceError>\n readonly grants: Effect.Effect<ReadonlyArray<BulkGrant>, PersistenceError>\n}\n\n/**\n * Service key for the execution-engine port.\n *\n * @category services\n * @since 0.1.0\n */\nexport class ControlRuntime extends Context.Service<ControlRuntime, Service>()(\n \"/control/ControlRuntime\"\n) {}\n\n/**\n * Constructs a runtime service from an implementation record.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const make = (implementation: Service): Service => ControlRuntime.of(implementation)\n\n/**\n * Refuses an id page size outside 1 through 500, the `queryRuns` bound.\n *\n * @category validation\n * @since 1.0.0\n */\nexport const idPageLimit = (limit: number): Effect.Effect<void, InvalidInput> =>\n Number.isSafeInteger(limit) && limit >= 1 && limit <= 500\n ? Effect.void\n : Effect.fail(new InvalidInput({ issue: \"limit: must be an integer between 1 and 500\" }))\n\n/**\n * One inventory page over dense insertion positions, where `idAt` resolves a\n * position by direct lookup. Visits at most `limit` positions, so a page\n * costs and holds one page however many entries exist.\n */\nconst pageByPosition = (\n request: IdPageRequest,\n newest: number,\n idAt: (position: number) => string | undefined\n): IdPage => {\n const through = request.through ?? newest\n const ids: Array<string> = []\n let position = request.after ?? 0\n let visited = 0\n while (position < through && visited < request.limit) {\n position += 1\n visited += 1\n const id = idAt(position)\n if (id !== undefined) ids.push(id)\n }\n return position < through ? { ids, next: position, through } : { ids, through }\n}\n\ninterface MutablePlan {\n readonly card: PlanCard\n readonly decodedInput: unknown\n decision: \"pending\" | \"approved\" | \"denied\"\n}\n\ninterface MutableToken {\n readonly tokenId: string\n readonly target: ApprovalTarget\n decision: ApprovalDecision\n}\n\ninterface MutableRun {\n summary: RunSummary\n fence?: string | undefined\n localFence?: string | undefined\n fiber?: Fiber.Fiber<unknown, unknown> | undefined\n readonly sequence: number\n readonly signals: Array<SignalPayload>\n /** The sequence of the outstanding resume delegation, if there is one. */\n pendingResume?: number | undefined\n /** When that delegation was recorded. */\n pendingResumeAtMs?: number | undefined\n /** The operator's explicit resume that delegation carries, if any. */\n pendingConsent?: number | undefined\n}\n\n// SQL persistence breaks caller reference identity through serialization. The\n// memory adapter must copy at the same boundaries or its test results diverge\n// from the durable implementation when a caller mutates an input or result.\nconst snapshot = <A>(value: A): A => structuredClone(value)\n\nconst asStored = (plan: MutablePlan): StoredPlan => ({\n card: snapshot(plan.card),\n decodedInput: snapshot(plan.decodedInput),\n decision: plan.decision\n})\n\n// JSON tuple encoding keeps caller-chosen ids in separate fields, so a node's\n// request id cannot alias another run's request or a plan id.\nconst approvalKey = (target: ApprovalTarget): string =>\n target._tag === \"Plan\"\n ? JSON.stringify([target._tag, target.planId])\n : JSON.stringify([target._tag, target.runId, target.requestId])\n\nconst sameApprovalIdentity = (left: ApprovalTarget, right: ApprovalTarget): boolean =>\n left._tag === \"Plan\"\n ? right._tag === \"Plan\" && left.planId === right.planId\n : right._tag === \"Node\" && left.runId === right.runId && left.requestId === right.requestId\n\nconst approvalToken = (token: MutableToken): ApprovalToken => ({\n tokenId: token.tokenId,\n target: snapshot(token.target),\n ...snapshot(token.decision)\n})\n\n/**\n * Deterministic in-memory runtime. It models the production fence and approval\n * ordering seams but intentionally does not claim durable process survival;\n * see `control-runtime-engine-integration`.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerMemory = (options: MemoryOptions = {}): Layer.Layer<ControlRuntime, never, Crypto.Crypto> =>\n Layer.effect(\n ControlRuntime,\n Effect.gen(function*() {\n const crypto = yield* Crypto.Crypto\n const now = options.now ?? Date.now\n // The in-memory adapter stamps `memory`/`test` on a caller that names no\n // principal, so its default policy delegates that identity as well as\n // the local operator. Production policies never carry it.\n const approvalAuthority = options.approvalAuthority ?? (yield* ApprovalAuthority.make([\n {\n principal: { id: \"local\", kind: \"operator\" },\n scopes: [\"once\", \"run\", \"remembered\"],\n targets: [\"Plan\", \"Node\"]\n },\n { principal: { id: \"memory\", kind: \"test\" }, scopes: [\"once\", \"run\", \"remembered\"], targets: [\"Plan\", \"Node\"] }\n ]).pipe(Effect.orDie))\n const authorizeApproval = approvalAuthority.authorize.bind(approvalAuthority)\n const configuredFlows = options.flows ?? plannable.map((entry): MemoryFlow => ({\n flowId: entry.flowId,\n description: `Reserved ${entry.verb} system flow`,\n deployClass: entry.deployClass,\n envelope: emptyEnvelope\n }))\n const flows = new Map(configuredFlows.map((flow) =>\n [\n flow.flowId,\n { ...flow, envelope: snapshot(flow.envelope) }\n ] as const\n ))\n const plans = new Map<string, MutablePlan>()\n const planKeys = new Map<IdempotencyKey, {\n readonly fingerprint: string\n readonly planId: string\n }>()\n const tokens = new Map<string, MutableToken>()\n const runs = new Map<RunId, MutableRun>()\n const mutations = new Map<IdempotencyKey, MutationRecord>()\n const runKeys = new Map<IdempotencyKey, { readonly fingerprint: string }>()\n const installedGrants: Array<BulkGrant> = []\n const installedGrantKeys = new Set<string>()\n let planSequence = 0\n const signalCommands = new Map<string, SignalCommand>()\n let pendingSignalOffset = 0\n let runSequence = 0\n let fenceSequence = 0\n let resumeSequence = 0\n\n const requireRun = (runId: RunId): Effect.Effect<MutableRun, RunNotFound> =>\n Effect.fromOption(Option.fromNullishOr(runs.get(runId)), () => new RunNotFound({ runId }))\n\n const updateSummary = (run: MutableRun, fields: Partial<RunSummary>): RunSummary => {\n run.summary = snapshot({ ...run.summary, ...fields, updatedAt: now() })\n return snapshot(run.summary)\n }\n\n const checkFence = (runId: RunId, run: MutableRun, fence: string): Effect.Effect<void, ClaimLost> =>\n run.fence === undefined || run.fence !== fence\n ? Effect.fail(new ClaimLost({ runId }))\n : Effect.void\n\n /** `resume`, recording the identity `adopt` answers on the claimed run when given. */\n const resumeRun = <E = never>(\n runId: RunId,\n adopt?:\n | ((run: MutableRun) => Effect.Effect<Pick<RunSummary, \"executionDigest\" | \"engineVersion\">, E>)\n | undefined\n ): Effect.Effect<RunSummary, RunNotFound | ClaimLost | E> =>\n Effect.gen(function*() {\n const run = yield* requireRun(runId)\n if (\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" ||\n run.summary.status === \"failed\"\n ) return snapshot(run.summary)\n // Accepted claims are owned too; releasePending clears both fences.\n if (run.fence !== undefined) {\n /* v8 ignore next 3 -- one process holds this whole runtime, and it writes `fence` and `localFence` together; the peer this refuses exists only over a shared database, which is `SqlControlRuntime`'s fence */\n if (run.localFence === undefined || run.fence !== run.localFence) {\n return yield* new ClaimLost({ runId })\n }\n return snapshot(run.summary)\n }\n const adopted = adopt === undefined ? undefined : yield* adopt(run)\n const fence = `fence-${++fenceSequence}`\n run.fence = fence\n run.localFence = fence\n // Claiming ends the park, so it ends the record of who wrote it.\n return updateSummary(run, {\n ...adopted,\n status: \"accepted\",\n ownerId: \"memory-owner\",\n parkedBy: undefined\n })\n })\n\n const service = make({\n authorizeApproval,\n plan: Effect.fn(\"ControlRuntime.plan\")(function*(input) {\n const flow = flows.get(input.flowId)\n if (flow === undefined) return yield* new FlowNotFound({ flowId: input.flowId })\n const requestFingerprint = yield* Effect.try({\n // Validate before cloning. Canonicalization reports a throwing\n // getter at its stable path, while `structuredClone` would invoke\n // the getter first and erase that safe diagnostic.\n try: () => planFingerprint(input),\n catch: (cause) => new InvalidInput({ issue: canonicalIssue(cause) })\n })\n const submitted = yield* Effect.try({\n try: () => snapshot(input),\n catch: (cause) => new InvalidInput({ issue: canonicalIssue(cause) })\n })\n if (submitted.idempotencyKey !== undefined) {\n const prior = planKeys.get(submitted.idempotencyKey)\n if (prior !== undefined) {\n if (prior.fingerprint !== requestFingerprint) {\n return yield* new InvalidInput({\n issue: `idempotency key ${submitted.idempotencyKey} was used for another plan`\n })\n }\n const stored = plans.get(prior.planId)\n /* v8 ignore next -- this map never loses a plan a key names; `SqlControlRuntime` covers the storage that can */\n if (stored !== undefined) return { card: snapshot(stored.card), created: false }\n }\n }\n const decoded = yield* (flow.decode?.(submitted.input) ?? Effect.try({\n try: () => {\n canonical(submitted.input)\n return submitted.input\n },\n catch: (cause) => new InvalidInput({ issue: canonicalIssue(cause) })\n }))\n const planId = `plan-${++planSequence}`\n const handoff = flow.plan === undefined ? undefined : yield* flow.plan(decoded, planId)\n const card = snapshot(\n yield* planCard({\n planId,\n flowId: submitted.flowId,\n decodedInput: decoded,\n envelope: budgeted(flow.envelope, submitted.budget),\n deployClass: flow.deployClass,\n executionDigest: flow.executionDigest,\n handoff,\n idempotencyKey: submitted.idempotencyKey\n }).pipe(Effect.provideService(Crypto.Crypto, crypto))\n )\n // Decoding, planning and hashing may yield to another keyed plan.\n // Recheck immediately before publication, with no yield between a\n // successful check and the three map writes below.\n if (submitted.idempotencyKey !== undefined) {\n const prior = planKeys.get(submitted.idempotencyKey)\n if (prior !== undefined) {\n if (prior.fingerprint !== requestFingerprint) {\n return yield* new InvalidInput({\n issue: `idempotency key ${submitted.idempotencyKey} was used for another plan`\n })\n }\n const stored = plans.get(prior.planId)\n /* v8 ignore next -- this map never loses a plan a key names; `SqlControlRuntime` covers the storage that can */\n if (stored !== undefined) return { card: snapshot(stored.card), created: false }\n }\n }\n plans.set(planId, { card, decodedInput: snapshot(decoded), decision: \"pending\" })\n tokens.set(approvalKey(card.approval.target), {\n tokenId: planId,\n target: snapshot(card.approval.target),\n decision: { _tag: \"Pending\" }\n })\n if (submitted.idempotencyKey !== undefined) {\n planKeys.set(submitted.idempotencyKey, {\n fingerprint: requestFingerprint,\n planId\n })\n }\n return { card: snapshot(card), created: true }\n }),\n getPlan: Effect.fn(\"ControlRuntime.getPlan\")((planId) =>\n Effect.fromOption(Option.fromNullishOr(plans.get(planId)), () => new PlanNotFound({ planId })).pipe(\n Effect.map(asStored)\n )\n ),\n pagePlanIds: Effect.fn(\"ControlRuntime.pagePlanIds\")(function*(request) {\n yield* idPageLimit(request.limit)\n return pageByPosition(\n request,\n planSequence,\n (position) => plans.has(`plan-${position}`) ? `plan-${position}` : undefined\n )\n }),\n queryPlans: Effect.fn(\"ControlRuntime.queryPlans\")(function*(request) {\n yield* idPageLimit(request.limit)\n const matched: Array<StoredPlan> = []\n let position = request.after ?? 0\n while (position < planSequence && matched.length < request.limit) {\n position += 1\n const plan = plans.get(`plan-${position}`)\n if (\n plan !== undefined &&\n (request.flowId === undefined || plan.card.flowId === request.flowId) &&\n (request.decision === undefined || plan.decision === request.decision)\n ) matched.push(asStored(plan))\n }\n return position < planSequence ? { plans: matched, next: position } : { plans: matched }\n }),\n lookupApproval: Effect.fn(\"ControlRuntime.lookupApproval\")(function*(target) {\n const requested = snapshot(target)\n const tokenId = requested._tag === \"Plan\" ? requested.planId : requested.requestId\n const token = yield* Effect.fromOption(\n Option.fromNullishOr(tokens.get(approvalKey(requested))),\n () =>\n requested._tag === \"Node\"\n ? new RunNotFound({ runId: requested.runId })\n : new PlanNotFound({ planId: requested.planId })\n )\n // A stored target that disagrees with its composite key is corrupted;\n // accepting only its digest and envelope would recreate the alias the\n // composite identity closes. In memory the key is DERIVED from the\n // identity, so only a caller reaching into the map can produce the\n // disagreement; `SqlControlRuntime` stores the two apart and covers\n // the same refusal against a rewritten row.\n /* v8 ignore next 6 -- unreachable while the map key is derived from the identity it is compared against */\n if (!sameApprovalIdentity(token.target, requested)) {\n return yield* new PersistenceError({\n operation: \"validate an approval token\",\n message: \"The stored approval target does not match its identity\"\n })\n }\n if (token.target.digest !== requested.digest) {\n return yield* new PlanDigestMismatch({\n planId: tokenId,\n expected: token.target.digest,\n actual: requested.digest\n })\n }\n if (!sameEnvelope(token.target.envelope, requested.envelope)) {\n return yield* new EnvelopeMismatch({\n planId: tokenId,\n expected: canonical(token.target.envelope),\n actual: canonical(requested.envelope)\n })\n }\n if (token.decision._tag !== \"Pending\") return yield* new AlreadyResolved({ requestId: tokenId })\n return approvalToken(token)\n }),\n registerApproval: Effect.fn(\"ControlRuntime.registerApproval\")(function*(target) {\n const requested = snapshot(target)\n yield* requireRun(requested.runId)\n const key = approvalKey(requested)\n const existing = tokens.get(key)\n if (existing === undefined) {\n const stored: MutableToken = {\n tokenId: requested.requestId,\n target: requested,\n decision: { _tag: \"Pending\" }\n }\n tokens.set(key, stored)\n return approvalToken(stored)\n }\n /* v8 ignore next 6 -- as in `lookupApproval`: the map key is derived from the identity, so a stored target can only disagree with it after a reach into the map */\n if (!sameApprovalIdentity(existing.target, requested)) {\n return yield* new PersistenceError({\n operation: \"validate an approval token\",\n message: \"The stored approval target does not match its identity\"\n })\n }\n if (existing.target.digest !== requested.digest) {\n return yield* new PlanDigestMismatch({\n planId: requested.requestId,\n expected: existing.target.digest,\n actual: requested.digest\n })\n }\n if (!sameEnvelope(existing.target.envelope, requested.envelope)) {\n return yield* new EnvelopeMismatch({\n planId: requested.requestId,\n expected: canonical(existing.target.envelope),\n actual: canonical(requested.envelope)\n })\n }\n return approvalToken(existing)\n }),\n installBulkGrant: Effect.fn(\"ControlRuntime.installBulkGrant\")((token, envelope, scope) =>\n Effect.sync(() => {\n const storedToken = snapshot(token)\n const key = approvalKey(storedToken.target)\n if (installedGrantKeys.has(key)) return\n installedGrantKeys.add(key)\n installedGrants.push({\n tokenId: storedToken.tokenId,\n envelope: snapshot(envelope),\n scope,\n installedAt: now()\n })\n })\n ),\n resolveApproval: Effect.fn(\"ControlRuntime.resolveApproval\")(\n function*(token, decision, principal, scope = \"once\") {\n const requested = snapshot(token)\n const requestedPrincipal = snapshot(principal)\n const answer = yield* Schema.decodeUnknownEffect(ApprovalDecision)(\n decision === \"approved\"\n ? { _tag: \"Approved\", decisionPrincipal: requestedPrincipal, decidedAt: now(), scope }\n : { _tag: \"Denied\", decisionPrincipal: requestedPrincipal, decidedAt: now() }\n ).pipe(\n Effect.mapError(() =>\n new PersistenceError({\n operation: \"record an approval decision\",\n message: \"The approval decision metadata is invalid\"\n })\n )\n )\n yield* authorizeApproval({ principal: requestedPrincipal, target: requested.target, decision, scope })\n const mutable = tokens.get(approvalKey(requested.target))\n if (mutable === undefined || mutable.decision._tag !== \"Pending\") {\n return yield* new AlreadyResolved({ requestId: requested.tokenId })\n }\n mutable.decision = answer\n if (requested.target._tag === \"Plan\") {\n const plan = plans.get(requested.target.planId)\n /* v8 ignore next -- a plan token is only ever registered by `plan`, which stores the plan in the same call */\n if (plan !== undefined) plan.decision = decision\n }\n }\n ),\n launch: Effect.fn(\"ControlRuntime.launch\")(function*(planId, requestedDigest, envelope, principal, reservedRunId) {\n const plan = yield* Effect.fromOption(\n Option.fromNullishOr(plans.get(planId)),\n () => new PlanNotFound({ planId })\n )\n if (plan.card.digest !== requestedDigest) {\n return yield* new PlanDigestMismatch({\n planId,\n expected: plan.card.digest,\n actual: requestedDigest\n })\n }\n if (!sameEnvelope(plan.card.envelope, envelope)) {\n return yield* new EnvelopeMismatch({\n planId,\n expected: canonical(plan.card.envelope),\n actual: canonical(envelope)\n })\n }\n if (plan.decision === \"pending\") {\n return {\n _tag: \"Parked\",\n receipt: {\n _tag: \"Parked\",\n receiptId: `launch:${planId}`,\n planId,\n status: \"waiting-approval\"\n }\n }\n }\n if (plan.decision !== \"approved\") {\n return yield* new PlanDenied({ planId })\n }\n const sequence = ++runSequence\n const runId = reservedRunId ?? `run-${sequence}`\n if (runs.has(runId)) return yield* new PersistenceError({ operation: \"reserve a run\", message: \"Run identity already exists\" })\n const fence = `fence-${++fenceSequence}`\n const timestamp = now()\n const summary: RunSummary = {\n runId,\n flowId: plan.card.flowId,\n status: \"accepted\",\n planId,\n planDigest: plan.card.digest,\n ...(plan.card.executionDigest === undefined ? {} : { executionDigest: plan.card.executionDigest }),\n ...(options.engineVersion === undefined ? {} : { engineVersion: options.engineVersion }),\n ownerId: \"memory-owner\",\n ...(principal === undefined ? {} : { launchedBy: { id: principal.id, kind: principal.kind } }),\n ...(plan.card.envelope.budget.deadline === undefined\n ? {}\n : { deadlineAt: timestamp + plan.card.envelope.budget.deadline }),\n createdAt: timestamp,\n updatedAt: timestamp\n }\n runs.set(runId, {\n summary: snapshot(summary),\n fence,\n localFence: fence,\n sequence: runSequence,\n signals: []\n })\n return {\n _tag: \"Started\",\n receipt: accepted(`launch:${planId}:${runId}`, runId),\n run: snapshot(summary)\n }\n }),\n getRun: Effect.fn(\"ControlRuntime.getRun\")((runId) =>\n Effect.map(requireRun(runId), (run) => snapshot(run.summary))\n ),\n pageRunIds: Effect.fn(\"ControlRuntime.pageRunIds\")(function*(request) {\n yield* idPageLimit(request.limit)\n return pageByPosition(\n request,\n runSequence,\n (position) => runs.has(`run-${position}`) ? `run-${position}` : undefined\n )\n }),\n queryRuns: Effect.fn(\"ControlRuntime.queryRuns\")(function*(request) {\n if (!Number.isSafeInteger(request.limit) || request.limit < 1 || request.limit > 500) {\n return yield* new InvalidInput({ issue: \"limit: must be an integer between 1 and 500\" })\n }\n const selected: Array<MutableRun> = []\n const filters = request.filters\n const newest = request.order === \"newest\"\n const oldest = request.order === \"oldest\"\n const candidates = newest\n ? Array.from(runs.values()).sort((a, b) =>\n b.summary.createdAt - a.summary.createdAt || b.sequence - a.sequence\n )\n : oldest\n ? Array.from(runs.values()).sort((a, b) =>\n a.summary.createdAt - b.summary.createdAt || a.sequence - b.sequence\n )\n : runs.values()\n for (const run of candidates) {\n const after = request.cursor\n if (\n after !== undefined && (after.source !== 0 || (newest\n ? run.summary.createdAt > after.createdAt ||\n (run.summary.createdAt === after.createdAt && run.sequence >= after.sequence)\n : oldest\n ? run.summary.createdAt < after.createdAt ||\n (run.summary.createdAt === after.createdAt && run.sequence <= after.sequence)\n : run.sequence <= after.sequence))\n ) continue\n const summary = run.summary\n if (filters?.since !== undefined && summary.createdAt < filters.since) continue\n if (filters?.until !== undefined && summary.createdAt >= filters.until) continue\n if (filters?.runIds !== undefined && !filters.runIds.includes(summary.runId)) continue\n if (filters?.flowId !== undefined && summary.flowId !== filters.flowId) continue\n if (filters?.status !== undefined && summary.status !== filters.status) continue\n if (\n filters?.terminal !== undefined &&\n [\"completed\", \"failed\", \"cancelled\"].includes(summary.status) !== filters.terminal\n ) continue\n if (filters?.parentRunId !== undefined && summary.parentRunId !== filters.parentRunId) continue\n if (filters?.lineageId !== undefined && summary.lineageId !== filters.lineageId) continue\n if (filters?.launchedBy !== undefined && !launchedByMatches(summary, filters.launchedBy)) continue\n selected.push(run)\n if (selected.length > request.limit) break\n }\n const page = selected.slice(0, request.limit)\n const last = page.at(-1)\n return {\n items: page.map((run) => snapshot(run.summary)),\n ...(selected.length <= request.limit || last === undefined ? {} : {\n nextCursor: {\n source: 0 as const,\n sequence: last.sequence,\n createdAt: last.summary.createdAt,\n runId: last.summary.runId\n }\n })\n }\n }),\n listFlows: Effect.fn(\"ControlRuntime.listFlows\")(() =>\n Effect.sync(() =>\n Array.from(flows.values(), (flow) => ({\n flowId: flow.flowId,\n description: flow.description\n }))\n )\n )(),\n deliverSignal: Effect.fn(\"ControlRuntime.deliverSignal\")((runId, signal) =>\n Effect.tap(requireRun(runId), (run) => Effect.sync(() => void run.signals.push(snapshot(signal))))\n ),\n admitSignal: Effect.fn(\"ControlRuntime.admitSignal\")(function*(commandId, runId, signal, principal) {\n yield* requireRun(runId)\n if (!signalCommands.has(commandId)) {\n signalCommands.set(\n commandId,\n snapshot({\n commandId,\n runId,\n signal,\n token: null,\n state: \"pending\",\n ...(principal === undefined ? {} : { principal })\n })\n )\n }\n }),\n signalCommand: (commandId) => Effect.sync(() => snapshot(signalCommands.get(commandId))),\n pendingSignals: Effect.sync(() => {\n const pending = Array.from(signalCommands.values()).filter((command) => command.state === \"pending\")\n if (pendingSignalOffset >= pending.length) pendingSignalOffset = 0\n const page = pending.slice(pendingSignalOffset, pendingSignalOffset + 100)\n pendingSignalOffset += page.length\n return snapshot(page)\n }),\n bindSignal: (commandId, token) =>\n Effect.gen(function*() {\n const command = signalCommands.get(commandId)\n if (command === undefined) {\n return yield* new PersistenceError({\n operation: \"bind signal\",\n message: `No pending signal command ${commandId}`\n })\n }\n if (command.state !== \"pending\") return command.token\n if (\n command.token === null &&\n Array.from(signalCommands.values()).some((other) =>\n other.commandId !== commandId && other.token === token\n )\n ) return null\n const bound = command.token ?? token\n signalCommands.set(commandId, { ...command, token: bound })\n return bound\n }),\n settleSignal: (commandId, state) =>\n Effect.sync(() => {\n const command = signalCommands.get(commandId)\n if (command !== undefined && command.state === \"pending\") {\n signalCommands.set(commandId, { ...command, state })\n }\n }),\n deliveredSignals: Effect.fn(\"ControlRuntime.deliveredSignals\")((runId) =>\n Effect.map(\n requireRun(runId),\n (run) =>\n snapshot([\n ...run.signals,\n ...Array.from(signalCommands.values()).filter((command) =>\n command.runId === runId && command.state !== \"rejected\"\n ).map((command) => command.signal)\n ])\n )\n ),\n requestResume: Effect.fn(\"ControlRuntime.requestResume\")(function*(runId, options) {\n const run = yield* requireRun(runId)\n if (\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" ||\n run.summary.status === \"failed\"\n ) {\n return yield* new InvalidInput({\n issue: `run ${runId} is ${run.summary.status} and cannot take a resume`\n })\n }\n const sequence = ++resumeSequence\n run.pendingResume = sequence\n run.pendingResumeAtMs = now()\n run.pendingConsent = options?.consent ?? run.pendingConsent\n updateSummary(run, { pendingResume: sequence })\n return sequence\n }),\n pendingResumes: Effect.sync(() =>\n Array.from(runs.entries()).flatMap(([runId, run]) =>\n run.pendingResume === undefined || run.pendingResumeAtMs === undefined ||\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" || run.summary.status === \"failed\"\n ? []\n : [{\n runId,\n sequence: run.pendingResume,\n requestedAtMs: run.pendingResumeAtMs,\n ...(run.pendingConsent === undefined ? {} : { consent: run.pendingConsent })\n }]\n )\n ),\n clearResume: Effect.fn(\"ControlRuntime.clearResume\")((runId, sequence) =>\n Effect.sync(() => {\n const run = runs.get(runId)\n if (run === undefined || run.pendingResume !== sequence) return\n run.pendingResume = undefined\n run.pendingResumeAtMs = undefined\n run.pendingConsent = undefined\n updateSummary(run, { pendingResume: undefined })\n })\n ),\n registerFiber: Effect.fn(\"ControlRuntime.registerFiber\")((runId, fiber) =>\n Effect.tap(requireRun(runId), (run) =>\n Effect.sync(() => {\n run.fiber = fiber\n fiber.addObserver(() => {\n if (run.fiber === fiber) run.fiber = undefined\n })\n }))\n ),\n interrupt: Effect.fn(\"ControlRuntime.interrupt\")(function*(runId, settle = (effect) => effect) {\n const run = yield* requireRun(runId)\n // Terminal first, as `resume` does: a settled run released its fence,\n // and answering `ClaimLost` there would name the wrong problem.\n if (\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" ||\n run.summary.status === \"failed\"\n ) return snapshot(run.summary)\n if (run.localFence === undefined) return yield* new ClaimLost({ runId })\n const fence = run.localFence\n yield* checkFence(runId, run, fence)\n if (run.fiber !== undefined) yield* Fiber.interrupt(run.fiber)\n return yield* settle(Effect.gen(function*() {\n // Cleanup may settle the run or release and replace its owner.\n if (\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" ||\n run.summary.status === \"failed\"\n ) return snapshot(run.summary)\n yield* checkFence(runId, run, fence)\n run.fence = undefined\n run.localFence = undefined\n return updateSummary(run, { status: \"cancelled\", ownerId: undefined, parkedBy: undefined })\n }))\n }),\n codeDrift: Effect.fn(\"ControlRuntime.codeDrift\")(function*(runId) {\n const run = yield* requireRun(runId)\n return codeDriftOf(run.summary, flows.get(run.summary.flowId), options.engineVersion)\n }),\n recordedCode: Effect.fn(\"ControlRuntime.recordedCode\")(function*(runId) {\n const { executionDigest, engineVersion } = (yield* requireRun(runId)).summary\n return { executionDigest, engineVersion }\n }),\n resume: Effect.fn(\"ControlRuntime.resume\")((runId) => resumeRun(runId)),\n // `plan` refuses a flow this catalog does not hold, and the catalog is\n // fixed at construction, so a run's flow is never gone here and there\n // is always code to adopt. `SqlControlRuntime` reads a catalog that can\n // lose a flow, and refuses that case before the claim.\n resumeAdopting: Effect.fn(\"ControlRuntime.resumeAdopting\")((runId) =>\n resumeRun(\n runId,\n (run) => Effect.succeed(adoptedCode(run.summary, flows.get(run.summary.flowId), options.engineVersion))\n )\n ),\n claimFence: Effect.fn(\"ControlRuntime.claimFence\")(function*(runId) {\n const run = yield* requireRun(runId)\n if (run.localFence === undefined) return yield* new ClaimLost({ runId })\n return run.localFence\n }),\n releasePending: Effect.fn(\"ControlRuntime.releasePending\")(function*(runId, fence) {\n const run = yield* requireRun(runId)\n yield* checkFence(runId, run, fence)\n run.fence = undefined\n run.localFence = undefined\n return updateSummary(run, {\n status: \"accepted\",\n ownerId: undefined,\n parkedBy: undefined\n })\n }),\n writeStatus: Effect.fn(\"ControlRuntime.writeStatus\")(function*(runId, fence, status) {\n const run = yield* requireRun(runId)\n yield* checkFence(runId, run, fence)\n // Ownership is released by any status that is not being driven, so the\n // fence that wrote a terminal or parked status is spent by writing it.\n if (status === \"accepted\" || status === \"running\") {\n return updateSummary(run, { status, parkedBy: undefined })\n }\n run.fence = undefined\n run.localFence = undefined\n // The spent fence is kept on a park, and only on a park: it is the\n // only thing left on the row that says which host parked it.\n return updateSummary(run, {\n status,\n ownerId: undefined,\n parkedBy: status === \"parked\" || status === \"waiting-approval\" ? fence : undefined\n })\n }),\n // Precedence matches `SqlControlRuntime`: the submitted identity is\n // the one a server authenticated, and the configured one is this\n // composition's fallback for a caller that named none.\n stampPrincipal: Effect.fn(\"ControlRuntime.stampPrincipal\")((submitted) =>\n Effect.sync(() => ({\n id: submitted?.id ?? options.principal?.id ?? \"memory\",\n kind: submitted?.kind ?? options.principal?.kind ?? \"test\",\n stampedAt: now()\n }))\n ),\n lookupMutation: Effect.fn(\"ControlRuntime.lookupMutation\")((key, fingerprint) =>\n Effect.sync(() => {\n const record = mutations.get(key)\n if (record === undefined) return undefined\n return record.fingerprint === fingerprint\n ? replayReceipt(key, record.receipt)\n : { _tag: \"Conflict\", message: `idempotency key ${key} was used for another mutation` }\n })\n ),\n recordMutation: Effect.fn(\"ControlRuntime.recordMutation\")((key, fingerprint, receipt) =>\n Effect.gen(function*() {\n const prior = mutations.get(key)\n if (\n prior !== undefined &&\n (prior.fingerprint !== fingerprint || canonical(prior.receipt) !== canonical(receipt))\n ) {\n return yield* Effect.fail(\n new PersistenceError({\n operation: \"record a mutation\",\n message: `Idempotency key ${key} was already settled by another mutation`\n })\n )\n }\n mutations.set(key, { fingerprint, receipt: snapshot(receipt) })\n })\n ),\n claimRunKey: Effect.fn(\"ControlRuntime.claimRunKey\")(function*(key, fingerprint) {\n const holder = runKeys.get(key)\n if (holder !== undefined) {\n if (holder.fingerprint !== fingerprint) {\n return yield* new InvalidInput({\n issue: `idempotency key ${key} was used for another run`\n })\n }\n const record = mutations.get(key)\n if (record === undefined) {\n // One process owns this runtime, so reaching here takes a caller\n // that claimed and never recorded: the cross-process winner this\n // branch really models commits both in one transaction, which is\n // `SqlControlRuntime`'s seam.\n return yield* new PersistenceError({\n operation: \"read a mutation\",\n message: `run key ${key} was claimed by a mutation that recorded no receipt`\n })\n }\n return { _tag: \"Raced\" as const, receipt: snapshot(record.receipt) }\n }\n runKeys.set(key, { fingerprint })\n return { _tag: \"Claimed\" as const }\n }),\n releaseRunKey: Effect.fn(\"ControlRuntime.releaseRunKey\")((key) =>\n Effect.sync(() => {\n runKeys.delete(key)\n })\n ),\n grants: Effect.fn(\"ControlRuntime.grants\")(() => Effect.sync(() => snapshot(installedGrants)))()\n })\n return service\n })\n )\n\nFault.register(\"/control/ApprovalPending\", \"wait\")\nFault.register(\"/control/ApprovalDenied\", \"user\")\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,YAAuB;AAEvB,oBAAsE;AACtE,wBAAmC;AAEnC,0BAaO;AAiBP,2BAA6E;AAC7E,oBAA+B;AAC/B,sBAWO;AACP,yBAA0B;AAuDnB,MAAM,oBAAoB,CAC/B,KACA,aAEA,IAAI,eAAe,UAAa,IAAI,WAAW,OAAO,SAAS,OAC9D,SAAS,SAAS,UAAa,IAAI,WAAW,SAAS,SAAS;AAgH5D,MAAM,mBAAmB,qBAAO,MAAM;AAAA,EAC3C,qBAAO,OAAO,EAAE,MAAM,qBAAO,QAAQ,SAAS,EAAE,CAAC;AAAA,EACjD,qBAAO,OAAO;AAAA,IACZ,MAAM,qBAAO,QAAQ,UAAU;AAAA,IAC/B,mBAAmB,qBAAAA;AAAA,IACnB,WAAW,qBAAO,OAAO,MAAM,qBAAO,MAAM,GAAG,qBAAO,uBAAuB,CAAC,CAAC;AAAA,IAC/E,OAAO,qBAAAC;AAAA,EACT,CAAC;AAAA,EACD,qBAAO,OAAO;AAAA,IACZ,MAAM,qBAAO,QAAQ,QAAQ;AAAA,IAC7B,mBAAmB,qBAAAD;AAAA,IACnB,WAAW,qBAAO,OAAO,MAAM,qBAAO,MAAM,GAAG,qBAAO,uBA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QACxD,qBAAO,KAAK,MAAM;AAChB,kBAAQ,OAAO,GAAG;AAAA,QACpB,CAAC;AAAA,MACH;AAAA,MACA,QAAQ,qBAAO,GAAG,uBAAuB,EAAE,MAAM,qBAAO,KAAK,MAAM,SAAS,eAAe,CAAC,CAAC,EAAE;AAAA,IACjG,CAAC;AACD,WAAO;AAAA,EACT,CAAC;AACH;AAEF,MAAM,SAAS,4BAA4B,MAAM;AACjD,MAAM,SAAS,2BAA2B,MAAM;",
|
|
4
|
+
"sourcesContent": ["/**\n * Browser-safe port between the control plane and the execution engine, with a\n * deterministic in-memory implementation.\n *\n * `layerMemory` is the deterministic one: it models the production fence and\n * approval ordering seams but keeps everything in a `Map`, so nothing it\n * decides survives the process. The durable adapter is\n * {@link SqlControlRuntime}, and both are held to one shared contract suite \u2014\n * see `test/ControlContract.ts`.\n *\n * @since 0.1.0\n */\n\nimport * as Fault from \"@smthrs/flow/Fault\"\nimport type * as PersistedPlan from \"@smthrs/plan/Plan\"\nimport { Context, Crypto, Effect, Fiber, Layer, Option, Schema } from \"effect\"\nimport * as ApprovalAuthority from \"./ApprovalAuthority.ts\"\nimport type { ApprovalTarget, PlanInput } from \"./Control.ts\"\nimport {\n AlreadyResolved,\n ClaimLost,\n type CodeDrift,\n EnvelopeMismatch,\n FlowNotFound,\n InvalidInput,\n PersistenceError,\n PlanDenied,\n PlanDigestMismatch,\n PlanNotFound,\n RunNotFound,\n type Unauthorized\n} from \"./ControlError.ts\"\nimport type {\n Envelope,\n FlowId,\n GrantScope,\n IdempotencyKey,\n PlanCard,\n PlanDecision,\n PlanGraph,\n PlanNode,\n Principal,\n Receipt,\n RunId,\n RunStatus,\n RunSummary,\n SignalPayload\n} from \"./ControlSchema.ts\"\nimport { GrantScope as GrantScopeSchema, Principal as PrincipalSchema } from \"./ControlSchema.ts\"\nimport { canonicalIssue } from \"./internal/issues.ts\"\nimport {\n accepted,\n adoptedCode,\n alreadyApplied as replayReceipt,\n budgeted,\n canonical,\n codeDriftOf,\n emptyEnvelope,\n planCard,\n planFingerprint,\n sameEnvelope\n} from \"./internal/planning.ts\"\nimport { plannable } from \"./SystemFlows.ts\"\n\n/**\n * Immutable ordering keys for a run page. Control launches precede engine runs.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface RunCursor {\n readonly source: 0 | 1\n readonly sequence: number\n readonly createdAt: number\n readonly runId: RunId\n}\n\n/**\n * Durable summary filters, applied before projection and executor observation.\n * `limit` must be an integer from 1 through 500. Reuse a cursor with the same filters.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface RunQuery {\n readonly filters?: {\n readonly flowId?: FlowId | undefined\n readonly status?: RunStatus | undefined\n readonly terminal?: boolean | undefined\n readonly parentRunId?: RunId | undefined\n readonly lineageId?: string | undefined\n /** Created at or after this epoch millisecond. */\n readonly since?: number | undefined\n /** Created before this epoch millisecond. */\n readonly until?: number | undefined\n /** Only these runs; an empty list selects none. */\n readonly runIds?: ReadonlyArray<RunId> | undefined\n /**\n * Only runs this plane launched for a principal with this `id`, and this\n * `kind` when given. A run with no recorded launcher never matches.\n */\n readonly launchedBy?: { readonly id: string; readonly kind?: string | undefined } | undefined\n } | undefined\n /** Creation time first, newest or oldest; ties use the durable sequence. */\n readonly order?: \"newest\" | \"oldest\" | undefined\n readonly cursor?: RunCursor | undefined\n readonly limit: number\n}\n\n/**\n * Whether `run` was launched by the principal `launcher` names: the same `id`,\n * and the same `kind` when `launcher` gives one. A run with no recorded\n * launcher never matches.\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const launchedByMatches = (\n run: Pick<RunSummary, \"launchedBy\">,\n launcher: { readonly id: string; readonly kind?: string | undefined }\n): boolean =>\n run.launchedBy !== undefined && run.launchedBy.id === launcher.id &&\n (launcher.kind === undefined || run.launchedBy.kind === launcher.kind)\n\n/**\n * A bounded page; the cursor names the last selected row, even if retention removed it.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface RunPage {\n readonly items: ReadonlyArray<RunSummary>\n readonly nextCursor?: RunCursor | undefined\n}\n\n/**\n * One page of an inventory walk. `next` is the position to pass as `after`\n * for the following page; it is absent on the last page. `through` is the\n * highest position the walk covers: the first page pins it to the newest\n * entry at that moment, and the caller passes it back unchanged so every\n * later page stops there. A walk therefore ends even while new entries keep\n * arriving; they sort after `through` and belong to the next walk.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface IdPage {\n readonly ids: ReadonlyArray<string>\n readonly next?: number | undefined\n readonly through: number\n}\n\n/**\n * An inventory page request. Positions are the store's insertion-ordered row\n * key, so each page is one indexed seek. `limit` must be an integer from 1\n * through 500.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface IdPageRequest {\n readonly after?: number | undefined\n readonly through?: number | undefined\n readonly limit: number\n}\n\n/**\n * A durably admitted signal, bound at most once to one concrete wait token.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface SignalCommand {\n readonly commandId: string\n readonly runId: RunId\n readonly signal: SignalPayload\n readonly token: string | null\n readonly state: \"pending\" | \"delivered\" | \"rejected\" | \"terminal\"\n /**\n * Who admitted the signal, stamped at admission. The executor checks it\n * against `authorizeApproval` before the signal may complete a human wait,\n * and a replay after restart reads it here because no caller is present.\n * Absent on commands admitted before the column existed, which therefore\n * cannot answer a human wait.\n */\n readonly principal?: Principal | undefined\n}\n\n/**\n * A stored-plan page request: plans oldest first, after the insertion position\n * `after`, narrowed by flow and decision. `limit` must be an integer from 1\n * through 500.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface PlanQuery {\n readonly flowId?: FlowId | undefined\n readonly decision?: PlanDecision | undefined\n readonly after?: number | undefined\n readonly limit: number\n}\n\n/**\n * One page of stored plans. `next` is the insertion position a later page\n * continues after, present while more plans may match.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface PlanPage {\n readonly plans: ReadonlyArray<StoredPlan>\n readonly next?: number | undefined\n}\n\n/**\n * A decoded input and immutable plan stored before execution.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface StoredPlan {\n readonly card: PlanCard\n readonly decodedInput: unknown\n readonly decision: PlanDecision\n}\n\n/**\n * The durable answer to an approval request. A decision is not inferred from\n * the presence of a grant or from a boolean that also means denial.\n *\n * @category models\n * @since 0.1.0\n */\nexport const ApprovalDecision = Schema.Union([\n Schema.Struct({ _tag: Schema.Literal(\"Pending\") }),\n Schema.Struct({\n _tag: Schema.Literal(\"Approved\"),\n decisionPrincipal: PrincipalSchema,\n decidedAt: Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0)),\n scope: GrantScopeSchema\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Denied\"),\n decisionPrincipal: PrincipalSchema,\n decidedAt: Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))\n })\n])\n\n/**\n * Durable approval state.\n * @category models\n * @since 1.0.0\n */\nexport type ApprovalDecision = typeof ApprovalDecision.Type\n\n/**\n * An identity and its explicit approval decision.\n * @category models\n * @since 1.0.0\n */\nexport type ApprovalToken = ApprovalDecision & {\n readonly tokenId: string\n readonly target: ApprovalTarget\n}\n\n/**\n * A gate that still needs a decision.\n * @category errors\n * @since 1.0.0\n */\nexport class ApprovalPending extends Schema.TaggedError<ApprovalPending>()(\"/control/ApprovalPending\", {\n tokenId: Schema.String\n}) {\n override get message(): string {\n return \"Approval is still pending. Wait for a decision before proceeding.\"\n }\n}\n\n/**\n * A gate that was denied, not merely resolved.\n * @category errors\n * @since 1.0.0\n */\nexport class ApprovalDenied extends Schema.TaggedError<ApprovalDenied>()(\"/control/ApprovalDenied\", {\n tokenId: Schema.String,\n decisionPrincipal: PrincipalSchema\n}) {\n override get message(): string {\n return \"Approval was denied. This request cannot authorize the gated work.\"\n }\n}\n\n/**\n * Opens only an explicitly approved gate. Callers may park on ApprovalPending;\n * ApprovalDenied is terminal. This reads a runtime-issued token, not an\n * authentication credential, and does not itself install permissions.\n * @category combinators\n * @since 1.0.0\n */\nexport const requireApproved = (\n token: ApprovalToken\n): Effect.Effect<Extract<ApprovalToken, { readonly _tag: \"Approved\" }>, ApprovalPending | ApprovalDenied> =>\n token._tag === \"Approved\"\n ? Effect.succeed(token)\n : token._tag === \"Pending\"\n ? Effect.fail(new ApprovalPending({ tokenId: token.tokenId }))\n : Effect.fail(new ApprovalDenied({ tokenId: token.tokenId, decisionPrincipal: token.decisionPrincipal }))\n\n/**\n * One bulk permission grant. The envelope is deliberately not split into\n * individual capabilities at this boundary.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface BulkGrant {\n readonly tokenId: string\n readonly envelope: Envelope\n readonly scope: GrantScope\n readonly installedAt: number\n}\n\n/**\n * Result of launching an approved plan.\n *\n * @category models\n * @since 0.1.0\n */\nexport type LaunchResult =\n | {\n readonly _tag: \"Started\"\n readonly receipt: Receipt\n readonly run: RunSummary\n }\n | {\n readonly _tag: \"Parked\"\n readonly receipt: Receipt\n }\n\n/**\n * A plan card and whether this call is the one that created it.\n *\n * A plan under an idempotency key the runtime has already seen answers with the\n * STORED card, which is what idempotency means. `Control.plan` needs to tell\n * that apart from a first ask, because it journals `control.plan.created` and\n * an unconditional entry appended one creation per retry: `Channels.ingest`\n * passes a key on every webhook redelivery, so a watcher of the plan partition\n * replayed N creations of one plan.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface PlanOutcome {\n readonly card: PlanCard\n readonly created: boolean\n}\n\n/**\n * A stored idempotency-key outcome and the mutation fingerprint that produced\n * it.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface MutationRecord {\n readonly fingerprint: string\n readonly receipt: Receipt\n}\n\n/**\n * The outcome of claiming a run mutation's idempotency key before launch.\n *\n * `Claimed` is this call's mandate to launch: the key row was empty or did not\n * exist, and it now names this call. `Raced` is the resolution the plan verb's\n * key claim gives a loser \u2014 another mutation claimed the key first, and the\n * receipt it settled is the answer this call must return instead of launching\n * a second run.\n *\n * @category models\n * @since 0.1.0\n */\nexport type RunKeyClaim =\n | { readonly _tag: \"Claimed\" }\n | { readonly _tag: \"Raced\"; readonly receipt: Receipt }\n\n/**\n * Flow metadata used by the memory runtime's input-decoding hook.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface MemoryFlow {\n readonly flowId: FlowId\n readonly description: string\n readonly deployClass: boolean\n readonly envelope: Envelope\n /** Executable source/metadata identity included in the approved card. */\n readonly executionDigest?: string | undefined\n readonly decode?: ((input: unknown) => Effect.Effect<unknown, InvalidInput>) | undefined\n /**\n * Projects the decoded input into the keyed node graph the card reports.\n *\n * Planning performs no I/O, so this is a pure function of the input: the\n * host builds the graph (`@smthrs/core`'s `Graph.build`), keys it\n * (`@smthrs/plan`'s compiler), and reports each node as `cached` or `run`\n * against whatever step cache it holds.\n */\n readonly plan?:\n | ((\n input: unknown,\n planId: string\n ) => Effect.Effect<{\n readonly plan: PersistedPlan.Plan\n readonly statuses?: Readonly<Record<string, PlanNode[\"status\"]>> | undefined\n /** The built graph's labelled edges and declaration sites, reported outside the approval digest. */\n readonly graph?: PlanGraph | undefined\n }, InvalidInput>)\n | undefined\n}\n\n/**\n * In-memory runtime configuration.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface MemoryOptions {\n readonly flows?: ReadonlyArray<MemoryFlow> | undefined\n readonly now?: (() => number) | undefined\n readonly principal?: Omit<Principal, \"stampedAt\"> | undefined\n readonly approvalAuthority?: ApprovalAuthority.Service | undefined\n /** The engine version stamped on every run this runtime starts. */\n readonly engineVersion?: string | undefined\n}\n\n/**\n * One run that has been told to resume, and the sequence of the request.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface PendingResume {\n readonly runId: RunId\n readonly sequence: number\n /**\n * When the delegation was recorded.\n *\n * A host reads it to tell a decision it has just been handed from one that\n * has been standing unanswered: a run parked by a process that has since\n * exited has nobody left to recognize its own park, so its delegation is\n * taken up by whichever host can drive it once it has gone unanswered for\n * `Ownership.heartbeatStaleAfter` (triage B-15).\n */\n readonly requestedAtMs: number\n /**\n * The journal sequence of the operator's explicit `control.run.resume`\n * this delegation carries, when it carries one.\n *\n * An approval or a wake is background intent. An operator's resume of a\n * run a live host parked is handed to that host as a delegation too, and\n * this is what tells the host the operator asked: it records the\n * per-release retry permission under this sequence before it drives the\n * run (#2982, #3342).\n */\n readonly consent?: number | undefined\n}\n\n/**\n * Execution-engine operations required by `ControlLive`.\n *\n * A production adapter must fence every owner-sensitive write, implement\n * resume as join-or-claim, release claims on every waiting or terminal\n * transition, and translate all conflicts into typed failures. For a new\n * approval decision, authenticate the principal and call `authorizeApproval`\n * before target reads or receipt replay. Then call `lookupApproval`,\n * `resolveApproval` exactly once with an authority recheck, `installBulkGrant`\n * only on approval, and journal the decision. Commit the decision, grant,\n * journal entry, receipt, and any node resume delegation atomically. Resolution\n * must not require an installed grant or a flushed journal decision.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Service {\n /** The owning host's policy, independent of authentication and attribution. */\n readonly authorizeApproval: ApprovalAuthority.Service[\"authorize\"]\n readonly plan: (input: PlanInput) => Effect.Effect<PlanOutcome, FlowNotFound | InvalidInput | PersistenceError>\n readonly getPlan: (planId: string) => Effect.Effect<StoredPlan, PlanNotFound | PersistenceError>\n /** Plan ids in insertion order, one bounded page at a time. */\n readonly pagePlanIds: (\n request: IdPageRequest\n ) => Effect.Effect<IdPage, InvalidInput | PersistenceError>\n /** Stored plans in insertion order, narrowed by flow and decision, one bounded page at a time. */\n readonly queryPlans: (request: PlanQuery) => Effect.Effect<PlanPage, InvalidInput | PersistenceError>\n readonly lookupApproval: (\n target: ApprovalTarget\n ) => Effect.Effect<\n ApprovalToken,\n PlanDigestMismatch | EnvelopeMismatch | AlreadyResolved | PlanNotFound | RunNotFound | PersistenceError\n >\n /**\n * Creates the durable token for one in-run approval request, or returns the\n * existing one.\n *\n * Plan tokens are created by `plan`; nothing created tokens for `Node`\n * targets, so an in-run request (a parked `ask`, a permission requirement)\n * could never be decided through `approve`/`deny`. Registration is\n * idempotent \u2014 the executor calls it on every parked attempt \u2014 and returns\n * the token with its current tagged decision so a resumed attempt can read\n * the decision instead of parking again. A registered target that\n * disagrees with the stored digest or envelope is refused, exactly as\n * `lookupApproval` refuses it.\n */\n readonly registerApproval: (\n target: Extract<ApprovalTarget, { readonly _tag: \"Node\" }>\n ) => Effect.Effect<\n ApprovalToken,\n RunNotFound | PlanDigestMismatch | EnvelopeMismatch | PersistenceError\n >\n readonly installBulkGrant: (\n token: ApprovalToken,\n envelope: Envelope,\n scope: GrantScope\n ) => Effect.Effect<void, PersistenceError>\n /** Records the decision exactly once. Approval scope defaults to once; the\n * control boundary supplies the scope of the grant it installed. */\n readonly resolveApproval: (\n token: ApprovalToken,\n decision: \"approved\" | \"denied\",\n principal: Principal,\n scope?: GrantScope | undefined\n ) => Effect.Effect<void, AlreadyResolved | PersistenceError | Unauthorized>\n /**\n * Starts an approved plan. `principal` is the identity that asked; its `id`\n * and `kind` are recorded as the run's `launchedBy`, which decides which\n * readers a restricted listing or watch shows the run to.\n */\n readonly launch: (\n planId: string,\n digest: string,\n envelope: Envelope,\n principal?: Principal | undefined,\n reservedRunId?: RunId | undefined\n ) => Effect.Effect<\n LaunchResult,\n PlanNotFound | PlanDenied | PlanDigestMismatch | EnvelopeMismatch | ClaimLost | PersistenceError\n >\n readonly getRun: (runId: RunId) => Effect.Effect<RunSummary, RunNotFound | PersistenceError>\n /**\n * Every durable run id in insertion order, one bounded page at a time, for\n * recovery and journal partition discovery. Reads keys only; use queryRuns\n * for summaries.\n */\n readonly pageRunIds: (\n request: IdPageRequest\n ) => Effect.Effect<IdPage, InvalidInput | PersistenceError>\n readonly queryRuns: (request: RunQuery) => Effect.Effect<RunPage, InvalidInput | PersistenceError>\n readonly listFlows: Effect.Effect<\n ReadonlyArray<{ readonly flowId: FlowId; readonly description: string }>,\n PersistenceError\n >\n readonly deliverSignal: (runId: RunId, signal: SignalPayload) => Effect.Effect<void, RunNotFound | PersistenceError>\n readonly admitSignal: (\n commandId: string,\n runId: RunId,\n signal: SignalPayload,\n principal?: Principal | undefined\n ) => Effect.Effect<void, RunNotFound | PersistenceError>\n readonly signalCommand: (commandId: string) => Effect.Effect<SignalCommand | undefined, PersistenceError>\n readonly pendingSignals: Effect.Effect<ReadonlyArray<SignalCommand>, PersistenceError>\n readonly bindSignal: (commandId: string, token: string) => Effect.Effect<string | null, PersistenceError>\n readonly settleSignal: (\n commandId: string,\n state: \"delivered\" | \"rejected\" | \"terminal\"\n ) => Effect.Effect<void, PersistenceError>\n readonly deliveredSignals: (\n runId: RunId\n ) => Effect.Effect<ReadonlyArray<SignalPayload>, RunNotFound | PersistenceError>\n /**\n * Records, durably, that this run has been told to resume.\n *\n * The record is the delegation. A decision on an in-run approval can be\n * taken by any process holding the control database, and only the process\n * hosting the execution can act on it, so the intent has to outlive the call\n * that made it: an in-process event bus reaches one process, and a journal\n * entry is per run and needs a reader that already knows which run to read.\n * The returned sequence is the cursor {@link Service.clearResume} checks, so\n * a resume requested while one is being taken up is not lost with it.\n *\n * A terminal run is refused with `InvalidInput`: no host will ever take the\n * delegation up, and recording it would leave an orphaned row every host's\n * `pendingResumes` poll filters but nothing ever clears.\n *\n * `consent` is the journal sequence of an operator's explicit resume (see\n * {@link PendingResume.consent}). A later delegation without one keeps the\n * consent no host has taken up yet.\n */\n readonly requestResume: (\n runId: RunId,\n options?: { readonly consent?: number | undefined } | undefined\n ) => Effect.Effect<number, RunNotFound | InvalidInput | PersistenceError>\n /**\n * Every outstanding resume delegation for a run that is not terminal.\n *\n * This is what a host polls. A settled run's delegation is not reported: no\n * host will ever take it up, and reporting it forever would make an\n * unbounded backlog out of a run that is finished.\n */\n readonly pendingResumes: Effect.Effect<ReadonlyArray<PendingResume>, PersistenceError>\n /**\n * Clears a delegation a host has taken up, if it is still the one it read.\n *\n * The sequence check is what makes the clear safe: a resume requested\n * between the read and the clear has a higher sequence and survives, so the\n * host takes it up on its next tick instead of losing it.\n */\n readonly clearResume: (runId: RunId, sequence: number) => Effect.Effect<void, PersistenceError>\n readonly registerFiber: (\n runId: RunId,\n fiber: Fiber.Fiber<unknown, unknown>\n ) => Effect.Effect<void, RunNotFound | PersistenceError>\n /**\n * Interrupts and awaits the local fiber with no caller-held mutation locks.\n * `settle` wraps only the subsequent fenced status reconciliation, allowing\n * ControlLive to commit its terminal event in the same transaction.\n */\n readonly interrupt: (\n runId: RunId,\n settle?: (\n effect: Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n /**\n * Joins an owned run or claims a suspended run or expired dead-owner run.\n *\n * `scope: \"launched\"` restricts claims to runs this plane launched, including\n * dead-owner takeovers. An unindexed run is refused with `ClaimLost`; a run\n * already owned by this process is joined without changing its state.\n * Both `Control.resume` and `Control.run` with a Resume input, plus steer\n * wakes, pass it to preserve an engine-created run's continuation and fence.\n * `scope: \"any\"` (also the default) is a trusted low-level runtime\n * capability for hosts that can drive the claimed execution. Node approval\n * uses `requestResume` delegation instead of claiming here.\n */\n readonly resume: (\n runId: RunId,\n options?: {\n readonly scope?: \"launched\" | \"any\" | undefined\n } | undefined\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n /**\n * `resume`, recording the flow's current execution digest and this\n * runtime's engine version on the claimed run: the operator allowed it to\n * resume on changed code, so later checks compare against that code. A flow\n * that no longer exists, or that this host cannot run, has no code to adopt,\n * so this fails `CodeDrift` before the claim and the run stays where it was.\n */\n readonly resumeAdopting: (\n runId: RunId,\n options?: { readonly scope?: \"launched\" | \"any\" | undefined } | undefined\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | CodeDrift | PersistenceError>\n /**\n * The drift between the code the run recorded and the code that would\n * resume it, or `undefined` when there is none. Every path that re-drives a\n * parked run asks this before it claims or delegates; recovery paths that\n * only settle a run do not.\n */\n readonly codeDrift: (runId: RunId) => Effect.Effect<CodeDrift | undefined, RunNotFound | PersistenceError>\n /**\n * The code identity the run executes under: its own recorded digest and\n * engine version, or, for a row that recorded none (a trampoline round, or a\n * fork or child the engine wrote), those of its nearest same-flow ancestor.\n * `codeDrift` checks this identity, so an executor that enters the identity\n * read here runs exactly the code the check admitted.\n */\n readonly recordedCode: (\n runId: RunId\n ) => Effect.Effect<Pick<RunSummary, \"executionDigest\" | \"engineVersion\">, RunNotFound | PersistenceError>\n readonly claimFence: (runId: RunId) => Effect.Effect<string, RunNotFound | ClaimLost | PersistenceError>\n /**\n * Releases a launch the configured executor declined without changing its\n * public `accepted` status.\n *\n * The run remains available to an external executor, but the launching\n * process no longer appears to drive it. The presented fence is spent by\n * the release and cannot authorize a later write.\n */\n readonly releasePending: (\n runId: RunId,\n fence: string\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n readonly writeStatus: (\n runId: RunId,\n fence: string,\n status: RunStatus\n ) => Effect.Effect<RunSummary, RunNotFound | ClaimLost | PersistenceError>\n readonly stampPrincipal: (submitted?: Principal | undefined) => Effect.Effect<Principal, PersistenceError>\n readonly lookupMutation: (\n key: IdempotencyKey,\n fingerprint: string\n ) => Effect.Effect<Receipt | undefined, PersistenceError>\n readonly recordMutation: (\n key: IdempotencyKey,\n fingerprint: string,\n receipt: Receipt\n ) => Effect.Effect<void, PersistenceError>\n /**\n * Claims a run mutation's idempotency key before any launch side effect.\n *\n * This is the run verb's half of the race `control_plan_keys` closes for\n * plans: a bare `lookupMutation`/`recordMutation` pair leaves two processes\n * that both missed the lookup free to both launch, and the loser's run row\n * outlives the `recordMutation` refusal that follows. The claim must run\n * FIRST, inside the same write transaction the mutation later records its\n * receipt in, so the loser's insert conflicts on the winner's committed key\n * row before a run row, a claim, or a journal entry exists \u2014 and the winner's\n * receipt, committed in that same transaction, is already there to read.\n *\n * `Raced` carries the winner's recorded receipt verbatim, which is the\n * convergence the plan verb gives a losing planner (`created: false` with\n * the stored card). A key claimed under another fingerprint is refused with\n * `InvalidInput`, the same refusal `plan` gives a colliding key. A key row\n * whose winner never recorded \u2014 possible only when the claim and the record\n * were not one transaction \u2014 is a `PersistenceError`, because there is no\n * honest receipt to answer with.\n */\n readonly claimRunKey: (\n key: IdempotencyKey,\n fingerprint: string\n ) => Effect.Effect<RunKeyClaim, InvalidInput | PersistenceError>\n /**\n * Releases a claim {@link Service.claimRunKey} took, without a receipt.\n *\n * Exactly one path needs it: a launch that answered `Parked` created no run\n * and records no receipt, so the claim must be withdrawn inside the same\n * transaction or the key would stay held forever by a mutation that settled\n * nothing. Every other outcome either records a receipt (the claim's whole\n * point) or fails and rolls the claim back with its transaction.\n */\n readonly releaseRunKey: (key: IdempotencyKey) => Effect.Effect<void, PersistenceError>\n readonly grants: Effect.Effect<ReadonlyArray<BulkGrant>, PersistenceError>\n}\n\n/**\n * Service key for the execution-engine port.\n *\n * @category services\n * @since 0.1.0\n */\nexport class ControlRuntime extends Context.Service<ControlRuntime, Service>()(\n \"/control/ControlRuntime\"\n) {}\n\n/**\n * Constructs a runtime service from an implementation record.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const make = (implementation: Service): Service => ControlRuntime.of(implementation)\n\n/**\n * Refuses an id page size outside 1 through 500, the `queryRuns` bound.\n *\n * @category validation\n * @since 1.0.0\n */\nexport const idPageLimit = (limit: number): Effect.Effect<void, InvalidInput> =>\n Number.isSafeInteger(limit) && limit >= 1 && limit <= 500\n ? Effect.void\n : Effect.fail(new InvalidInput({ issue: \"limit: must be an integer between 1 and 500\" }))\n\n/**\n * One inventory page over dense insertion positions, where `idAt` resolves a\n * position by direct lookup. Visits at most `limit` positions, so a page\n * costs and holds one page however many entries exist.\n */\nconst pageByPosition = (\n request: IdPageRequest,\n newest: number,\n idAt: (position: number) => string | undefined\n): IdPage => {\n const through = request.through ?? newest\n const ids: Array<string> = []\n let position = request.after ?? 0\n let visited = 0\n while (position < through && visited < request.limit) {\n position += 1\n visited += 1\n const id = idAt(position)\n if (id !== undefined) ids.push(id)\n }\n return position < through ? { ids, next: position, through } : { ids, through }\n}\n\ninterface MutablePlan {\n readonly card: PlanCard\n readonly decodedInput: unknown\n decision: \"pending\" | \"approved\" | \"denied\"\n}\n\ninterface MutableToken {\n readonly tokenId: string\n readonly target: ApprovalTarget\n decision: ApprovalDecision\n}\n\ninterface MutableRun {\n summary: RunSummary\n fence?: string | undefined\n localFence?: string | undefined\n fiber?: Fiber.Fiber<unknown, unknown> | undefined\n readonly sequence: number\n readonly signals: Array<SignalPayload>\n /** The sequence of the outstanding resume delegation, if there is one. */\n pendingResume?: number | undefined\n /** When that delegation was recorded. */\n pendingResumeAtMs?: number | undefined\n /** The operator's explicit resume that delegation carries, if any. */\n pendingConsent?: number | undefined\n}\n\n// SQL persistence breaks caller reference identity through serialization. The\n// memory adapter must copy at the same boundaries or its test results diverge\n// from the durable implementation when a caller mutates an input or result.\nconst snapshot = <A>(value: A): A => structuredClone(value)\n\nconst asStored = (plan: MutablePlan): StoredPlan => ({\n card: snapshot(plan.card),\n decodedInput: snapshot(plan.decodedInput),\n decision: plan.decision\n})\n\n// JSON tuple encoding keeps caller-chosen ids in separate fields, so a node's\n// request id cannot alias another run's request or a plan id.\nconst approvalKey = (target: ApprovalTarget): string =>\n target._tag === \"Plan\"\n ? JSON.stringify([target._tag, target.planId])\n : JSON.stringify([target._tag, target.runId, target.requestId])\n\nconst sameApprovalIdentity = (left: ApprovalTarget, right: ApprovalTarget): boolean =>\n left._tag === \"Plan\"\n ? right._tag === \"Plan\" && left.planId === right.planId\n : right._tag === \"Node\" && left.runId === right.runId && left.requestId === right.requestId\n\nconst approvalToken = (token: MutableToken): ApprovalToken => ({\n tokenId: token.tokenId,\n target: snapshot(token.target),\n ...snapshot(token.decision)\n})\n\n/**\n * Deterministic in-memory runtime. It models the production fence and approval\n * ordering seams but intentionally does not claim durable process survival;\n * see `control-runtime-engine-integration`.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerMemory = (options: MemoryOptions = {}): Layer.Layer<ControlRuntime, never, Crypto.Crypto> =>\n Layer.effect(\n ControlRuntime,\n Effect.gen(function*() {\n const crypto = yield* Crypto.Crypto\n const now = options.now ?? Date.now\n // The in-memory adapter stamps `memory`/`test` on a caller that names no\n // principal, so its default policy delegates that identity as well as\n // the local operator. Production policies never carry it.\n const approvalAuthority = options.approvalAuthority ?? (yield* ApprovalAuthority.make([\n {\n principal: { id: \"local\", kind: \"operator\" },\n scopes: [\"once\", \"run\", \"remembered\"],\n targets: [\"Plan\", \"Node\"]\n },\n { principal: { id: \"memory\", kind: \"test\" }, scopes: [\"once\", \"run\", \"remembered\"], targets: [\"Plan\", \"Node\"] }\n ]).pipe(Effect.orDie))\n const authorizeApproval = approvalAuthority.authorize.bind(approvalAuthority)\n const configuredFlows = options.flows ?? plannable.map((entry): MemoryFlow => ({\n flowId: entry.flowId,\n description: `Reserved ${entry.verb} system flow`,\n deployClass: entry.deployClass,\n envelope: emptyEnvelope\n }))\n const flows = new Map(configuredFlows.map((flow) =>\n [\n flow.flowId,\n { ...flow, envelope: snapshot(flow.envelope) }\n ] as const\n ))\n const plans = new Map<string, MutablePlan>()\n const planKeys = new Map<IdempotencyKey, {\n readonly fingerprint: string\n readonly planId: string\n }>()\n const tokens = new Map<string, MutableToken>()\n const runs = new Map<RunId, MutableRun>()\n const mutations = new Map<IdempotencyKey, MutationRecord>()\n const runKeys = new Map<IdempotencyKey, { readonly fingerprint: string }>()\n const installedGrants: Array<BulkGrant> = []\n const installedGrantKeys = new Set<string>()\n let planSequence = 0\n const signalCommands = new Map<string, SignalCommand>()\n let pendingSignalOffset = 0\n let runSequence = 0\n let fenceSequence = 0\n let resumeSequence = 0\n\n const requireRun = (runId: RunId): Effect.Effect<MutableRun, RunNotFound> =>\n Effect.fromOption(Option.fromNullishOr(runs.get(runId)), () => new RunNotFound({ runId }))\n\n const updateSummary = (run: MutableRun, fields: Partial<RunSummary>): RunSummary => {\n run.summary = snapshot({ ...run.summary, ...fields, updatedAt: now() })\n return snapshot(run.summary)\n }\n\n const checkFence = (runId: RunId, run: MutableRun, fence: string): Effect.Effect<void, ClaimLost> =>\n run.fence === undefined || run.fence !== fence\n ? Effect.fail(new ClaimLost({ runId }))\n : Effect.void\n\n /** `resume`, recording the identity `adopt` answers on the claimed run when given. */\n const resumeRun = <E = never>(\n runId: RunId,\n adopt?:\n | ((run: MutableRun) => Effect.Effect<Pick<RunSummary, \"executionDigest\" | \"engineVersion\">, E>)\n | undefined\n ): Effect.Effect<RunSummary, RunNotFound | ClaimLost | E> =>\n Effect.gen(function*() {\n const run = yield* requireRun(runId)\n if (\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" ||\n run.summary.status === \"failed\"\n ) return snapshot(run.summary)\n // Accepted claims are owned too; releasePending clears both fences.\n if (run.fence !== undefined) {\n /* v8 ignore next 3 -- one process holds this whole runtime, and it writes `fence` and `localFence` together; the peer this refuses exists only over a shared database, which is `SqlControlRuntime`'s fence */\n if (run.localFence === undefined || run.fence !== run.localFence) {\n return yield* new ClaimLost({ runId })\n }\n return snapshot(run.summary)\n }\n const adopted = adopt === undefined ? undefined : yield* adopt(run)\n const fence = `fence-${++fenceSequence}`\n run.fence = fence\n run.localFence = fence\n // Claiming ends the park, so it ends the record of who wrote it.\n return updateSummary(run, {\n ...adopted,\n status: \"accepted\",\n ownerId: \"memory-owner\",\n parkedBy: undefined\n })\n })\n\n const service = make({\n authorizeApproval,\n plan: Effect.fn(\"ControlRuntime.plan\")(function*(input) {\n const flow = flows.get(input.flowId)\n if (flow === undefined) return yield* new FlowNotFound({ flowId: input.flowId })\n const requestFingerprint = yield* Effect.try({\n // Validate before cloning. Canonicalization reports a throwing\n // getter at its stable path, while `structuredClone` would invoke\n // the getter first and erase that safe diagnostic.\n try: () => planFingerprint(input),\n catch: (cause) => new InvalidInput({ issue: canonicalIssue(cause) })\n })\n const submitted = yield* Effect.try({\n try: () => snapshot(input),\n catch: (cause) => new InvalidInput({ issue: canonicalIssue(cause) })\n })\n if (submitted.idempotencyKey !== undefined) {\n const prior = planKeys.get(submitted.idempotencyKey)\n if (prior !== undefined) {\n if (prior.fingerprint !== requestFingerprint) {\n return yield* new InvalidInput({\n issue: `idempotency key ${submitted.idempotencyKey} was used for another plan`\n })\n }\n const stored = plans.get(prior.planId)\n /* v8 ignore next -- this map never loses a plan a key names; `SqlControlRuntime` covers the storage that can */\n if (stored !== undefined) return { card: snapshot(stored.card), created: false }\n }\n }\n const decoded = yield* (flow.decode?.(submitted.input) ?? Effect.try({\n try: () => {\n canonical(submitted.input)\n return submitted.input\n },\n catch: (cause) => new InvalidInput({ issue: canonicalIssue(cause) })\n }))\n const planId = `plan-${++planSequence}`\n const handoff = flow.plan === undefined ? undefined : yield* flow.plan(decoded, planId)\n const card = snapshot(\n yield* planCard({\n planId,\n flowId: submitted.flowId,\n decodedInput: decoded,\n envelope: budgeted(flow.envelope, submitted.budget),\n deployClass: flow.deployClass,\n executionDigest: flow.executionDigest,\n handoff,\n idempotencyKey: submitted.idempotencyKey\n }).pipe(Effect.provideService(Crypto.Crypto, crypto))\n )\n // Decoding, planning and hashing may yield to another keyed plan.\n // Recheck immediately before publication, with no yield between a\n // successful check and the three map writes below.\n if (submitted.idempotencyKey !== undefined) {\n const prior = planKeys.get(submitted.idempotencyKey)\n if (prior !== undefined) {\n if (prior.fingerprint !== requestFingerprint) {\n return yield* new InvalidInput({\n issue: `idempotency key ${submitted.idempotencyKey} was used for another plan`\n })\n }\n const stored = plans.get(prior.planId)\n /* v8 ignore next -- this map never loses a plan a key names; `SqlControlRuntime` covers the storage that can */\n if (stored !== undefined) return { card: snapshot(stored.card), created: false }\n }\n }\n plans.set(planId, { card, decodedInput: snapshot(decoded), decision: \"pending\" })\n tokens.set(approvalKey(card.approval.target), {\n tokenId: planId,\n target: snapshot(card.approval.target),\n decision: { _tag: \"Pending\" }\n })\n if (submitted.idempotencyKey !== undefined) {\n planKeys.set(submitted.idempotencyKey, {\n fingerprint: requestFingerprint,\n planId\n })\n }\n return { card: snapshot(card), created: true }\n }),\n getPlan: Effect.fn(\"ControlRuntime.getPlan\")((planId) =>\n Effect.fromOption(Option.fromNullishOr(plans.get(planId)), () => new PlanNotFound({ planId })).pipe(\n Effect.map(asStored)\n )\n ),\n pagePlanIds: Effect.fn(\"ControlRuntime.pagePlanIds\")(function*(request) {\n yield* idPageLimit(request.limit)\n return pageByPosition(\n request,\n planSequence,\n (position) => plans.has(`plan-${position}`) ? `plan-${position}` : undefined\n )\n }),\n queryPlans: Effect.fn(\"ControlRuntime.queryPlans\")(function*(request) {\n yield* idPageLimit(request.limit)\n const matched: Array<StoredPlan> = []\n let position = request.after ?? 0\n while (position < planSequence && matched.length < request.limit) {\n position += 1\n const plan = plans.get(`plan-${position}`)\n if (\n plan !== undefined &&\n (request.flowId === undefined || plan.card.flowId === request.flowId) &&\n (request.decision === undefined || plan.decision === request.decision)\n ) matched.push(asStored(plan))\n }\n return position < planSequence ? { plans: matched, next: position } : { plans: matched }\n }),\n lookupApproval: Effect.fn(\"ControlRuntime.lookupApproval\")(function*(target) {\n const requested = snapshot(target)\n const tokenId = requested._tag === \"Plan\" ? requested.planId : requested.requestId\n const token = yield* Effect.fromOption(\n Option.fromNullishOr(tokens.get(approvalKey(requested))),\n () =>\n requested._tag === \"Node\"\n ? new RunNotFound({ runId: requested.runId })\n : new PlanNotFound({ planId: requested.planId })\n )\n // A stored target that disagrees with its composite key is corrupted;\n // accepting only its digest and envelope would recreate the alias the\n // composite identity closes. In memory the key is DERIVED from the\n // identity, so only a caller reaching into the map can produce the\n // disagreement; `SqlControlRuntime` stores the two apart and covers\n // the same refusal against a rewritten row.\n /* v8 ignore next 6 -- unreachable while the map key is derived from the identity it is compared against */\n if (!sameApprovalIdentity(token.target, requested)) {\n return yield* new PersistenceError({\n operation: \"validate an approval token\",\n message: \"The stored approval target does not match its identity\"\n })\n }\n if (token.target.digest !== requested.digest) {\n return yield* new PlanDigestMismatch({\n planId: tokenId,\n expected: token.target.digest,\n actual: requested.digest\n })\n }\n if (!sameEnvelope(token.target.envelope, requested.envelope)) {\n return yield* new EnvelopeMismatch({\n planId: tokenId,\n expected: canonical(token.target.envelope),\n actual: canonical(requested.envelope)\n })\n }\n if (token.decision._tag !== \"Pending\") return yield* new AlreadyResolved({ requestId: tokenId })\n return approvalToken(token)\n }),\n registerApproval: Effect.fn(\"ControlRuntime.registerApproval\")(function*(target) {\n const requested = snapshot(target)\n yield* requireRun(requested.runId)\n const key = approvalKey(requested)\n const existing = tokens.get(key)\n if (existing === undefined) {\n const stored: MutableToken = {\n tokenId: requested.requestId,\n target: requested,\n decision: { _tag: \"Pending\" }\n }\n tokens.set(key, stored)\n return approvalToken(stored)\n }\n /* v8 ignore next 6 -- as in `lookupApproval`: the map key is derived from the identity, so a stored target can only disagree with it after a reach into the map */\n if (!sameApprovalIdentity(existing.target, requested)) {\n return yield* new PersistenceError({\n operation: \"validate an approval token\",\n message: \"The stored approval target does not match its identity\"\n })\n }\n if (existing.target.digest !== requested.digest) {\n return yield* new PlanDigestMismatch({\n planId: requested.requestId,\n expected: existing.target.digest,\n actual: requested.digest\n })\n }\n if (!sameEnvelope(existing.target.envelope, requested.envelope)) {\n return yield* new EnvelopeMismatch({\n planId: requested.requestId,\n expected: canonical(existing.target.envelope),\n actual: canonical(requested.envelope)\n })\n }\n return approvalToken(existing)\n }),\n installBulkGrant: Effect.fn(\"ControlRuntime.installBulkGrant\")((token, envelope, scope) =>\n Effect.sync(() => {\n const storedToken = snapshot(token)\n const key = approvalKey(storedToken.target)\n if (installedGrantKeys.has(key)) return\n installedGrantKeys.add(key)\n installedGrants.push({\n tokenId: storedToken.tokenId,\n envelope: snapshot(envelope),\n scope,\n installedAt: now()\n })\n })\n ),\n resolveApproval: Effect.fn(\"ControlRuntime.resolveApproval\")(\n function*(token, decision, principal, scope = \"once\") {\n const requested = snapshot(token)\n const requestedPrincipal = snapshot(principal)\n const answer = yield* Schema.decodeUnknownEffect(ApprovalDecision)(\n decision === \"approved\"\n ? { _tag: \"Approved\", decisionPrincipal: requestedPrincipal, decidedAt: now(), scope }\n : { _tag: \"Denied\", decisionPrincipal: requestedPrincipal, decidedAt: now() }\n ).pipe(\n Effect.mapError(() =>\n new PersistenceError({\n operation: \"record an approval decision\",\n message: \"The approval decision metadata is invalid\"\n })\n )\n )\n yield* authorizeApproval({ principal: requestedPrincipal, target: requested.target, decision, scope })\n const mutable = tokens.get(approvalKey(requested.target))\n if (mutable === undefined || mutable.decision._tag !== \"Pending\") {\n return yield* new AlreadyResolved({ requestId: requested.tokenId })\n }\n mutable.decision = answer\n if (requested.target._tag === \"Plan\") {\n const plan = plans.get(requested.target.planId)\n /* v8 ignore next -- a plan token is only ever registered by `plan`, which stores the plan in the same call */\n if (plan !== undefined) plan.decision = decision\n }\n }\n ),\n launch: Effect.fn(\"ControlRuntime.launch\")(\n function*(planId, requestedDigest, envelope, principal, reservedRunId) {\n const plan = yield* Effect.fromOption(\n Option.fromNullishOr(plans.get(planId)),\n () => new PlanNotFound({ planId })\n )\n if (plan.card.digest !== requestedDigest) {\n return yield* new PlanDigestMismatch({\n planId,\n expected: plan.card.digest,\n actual: requestedDigest\n })\n }\n if (!sameEnvelope(plan.card.envelope, envelope)) {\n return yield* new EnvelopeMismatch({\n planId,\n expected: canonical(plan.card.envelope),\n actual: canonical(envelope)\n })\n }\n if (plan.decision === \"pending\") {\n return {\n _tag: \"Parked\",\n receipt: {\n _tag: \"Parked\",\n receiptId: `launch:${planId}`,\n planId,\n status: \"waiting-approval\"\n }\n }\n }\n if (plan.decision !== \"approved\") {\n return yield* new PlanDenied({ planId })\n }\n const sequence = ++runSequence\n const runId = reservedRunId ?? `run-${sequence}`\n if (runs.has(runId)) {\n return yield* new PersistenceError({ operation: \"reserve a run\", message: \"Run identity already exists\" })\n }\n const fence = `fence-${++fenceSequence}`\n const timestamp = now()\n const summary: RunSummary = {\n runId,\n flowId: plan.card.flowId,\n status: \"accepted\",\n planId,\n planDigest: plan.card.digest,\n ...(plan.card.executionDigest === undefined ? {} : { executionDigest: plan.card.executionDigest }),\n ...(options.engineVersion === undefined ? {} : { engineVersion: options.engineVersion }),\n ownerId: \"memory-owner\",\n ...(principal === undefined ? {} : { launchedBy: { id: principal.id, kind: principal.kind } }),\n ...(plan.card.envelope.budget.deadline === undefined\n ? {}\n : { deadlineAt: timestamp + plan.card.envelope.budget.deadline }),\n createdAt: timestamp,\n updatedAt: timestamp\n }\n runs.set(runId, {\n summary: snapshot(summary),\n fence,\n localFence: fence,\n sequence: runSequence,\n signals: []\n })\n return {\n _tag: \"Started\",\n receipt: accepted(`launch:${planId}:${runId}`, runId),\n run: snapshot(summary)\n }\n }\n ),\n getRun: Effect.fn(\"ControlRuntime.getRun\")((runId) =>\n Effect.map(requireRun(runId), (run) => snapshot(run.summary))\n ),\n pageRunIds: Effect.fn(\"ControlRuntime.pageRunIds\")(function*(request) {\n yield* idPageLimit(request.limit)\n return pageByPosition(\n request,\n runSequence,\n (position) => runs.has(`run-${position}`) ? `run-${position}` : undefined\n )\n }),\n queryRuns: Effect.fn(\"ControlRuntime.queryRuns\")(function*(request) {\n if (!Number.isSafeInteger(request.limit) || request.limit < 1 || request.limit > 500) {\n return yield* new InvalidInput({ issue: \"limit: must be an integer between 1 and 500\" })\n }\n const selected: Array<MutableRun> = []\n const filters = request.filters\n const newest = request.order === \"newest\"\n const oldest = request.order === \"oldest\"\n const candidates = newest\n ? Array.from(runs.values()).sort((a, b) =>\n b.summary.createdAt - a.summary.createdAt || b.sequence - a.sequence\n )\n : oldest\n ? Array.from(runs.values()).sort((a, b) =>\n a.summary.createdAt - b.summary.createdAt || a.sequence - b.sequence\n )\n : runs.values()\n for (const run of candidates) {\n const after = request.cursor\n if (\n after !== undefined && (after.source !== 0 || (newest\n ? run.summary.createdAt > after.createdAt ||\n (run.summary.createdAt === after.createdAt && run.sequence >= after.sequence)\n : oldest\n ? run.summary.createdAt < after.createdAt ||\n (run.summary.createdAt === after.createdAt && run.sequence <= after.sequence)\n : run.sequence <= after.sequence))\n ) continue\n const summary = run.summary\n if (filters?.since !== undefined && summary.createdAt < filters.since) continue\n if (filters?.until !== undefined && summary.createdAt >= filters.until) continue\n if (filters?.runIds !== undefined && !filters.runIds.includes(summary.runId)) continue\n if (filters?.flowId !== undefined && summary.flowId !== filters.flowId) continue\n if (filters?.status !== undefined && summary.status !== filters.status) continue\n if (\n filters?.terminal !== undefined &&\n [\"completed\", \"failed\", \"cancelled\"].includes(summary.status) !== filters.terminal\n ) continue\n if (filters?.parentRunId !== undefined && summary.parentRunId !== filters.parentRunId) continue\n if (filters?.lineageId !== undefined && summary.lineageId !== filters.lineageId) continue\n if (filters?.launchedBy !== undefined && !launchedByMatches(summary, filters.launchedBy)) continue\n selected.push(run)\n if (selected.length > request.limit) break\n }\n const page = selected.slice(0, request.limit)\n const last = page.at(-1)\n return {\n items: page.map((run) => snapshot(run.summary)),\n ...(selected.length <= request.limit || last === undefined ? {} : {\n nextCursor: {\n source: 0 as const,\n sequence: last.sequence,\n createdAt: last.summary.createdAt,\n runId: last.summary.runId\n }\n })\n }\n }),\n listFlows: Effect.fn(\"ControlRuntime.listFlows\")(() =>\n Effect.sync(() =>\n Array.from(flows.values(), (flow) => ({\n flowId: flow.flowId,\n description: flow.description\n }))\n )\n )(),\n deliverSignal: Effect.fn(\"ControlRuntime.deliverSignal\")((runId, signal) =>\n Effect.tap(requireRun(runId), (run) => Effect.sync(() => void run.signals.push(snapshot(signal))))\n ),\n admitSignal: Effect.fn(\"ControlRuntime.admitSignal\")(function*(commandId, runId, signal, principal) {\n yield* requireRun(runId)\n if (!signalCommands.has(commandId)) {\n signalCommands.set(\n commandId,\n snapshot({\n commandId,\n runId,\n signal,\n token: null,\n state: \"pending\",\n ...(principal === undefined ? {} : { principal })\n })\n )\n }\n }),\n signalCommand: (commandId) => Effect.sync(() => snapshot(signalCommands.get(commandId))),\n pendingSignals: Effect.sync(() => {\n const pending = Array.from(signalCommands.values()).filter((command) => command.state === \"pending\")\n if (pendingSignalOffset >= pending.length) pendingSignalOffset = 0\n const page = pending.slice(pendingSignalOffset, pendingSignalOffset + 100)\n pendingSignalOffset += page.length\n return snapshot(page)\n }),\n bindSignal: (commandId, token) =>\n Effect.gen(function*() {\n const command = signalCommands.get(commandId)\n if (command === undefined) {\n return yield* new PersistenceError({\n operation: \"bind signal\",\n message: `No pending signal command ${commandId}`\n })\n }\n if (command.state !== \"pending\") return command.token\n if (\n command.token === null &&\n Array.from(signalCommands.values()).some((other) =>\n other.commandId !== commandId && other.token === token\n )\n ) return null\n const bound = command.token ?? token\n signalCommands.set(commandId, { ...command, token: bound })\n return bound\n }),\n settleSignal: (commandId, state) =>\n Effect.sync(() => {\n const command = signalCommands.get(commandId)\n if (command !== undefined && command.state === \"pending\") {\n signalCommands.set(commandId, { ...command, state })\n }\n }),\n deliveredSignals: Effect.fn(\"ControlRuntime.deliveredSignals\")((runId) =>\n Effect.map(\n requireRun(runId),\n (run) =>\n snapshot([\n ...run.signals,\n ...Array.from(signalCommands.values()).filter((command) =>\n command.runId === runId && command.state !== \"rejected\"\n ).map((command) => command.signal)\n ])\n )\n ),\n requestResume: Effect.fn(\"ControlRuntime.requestResume\")(function*(runId, options) {\n const run = yield* requireRun(runId)\n if (\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" ||\n run.summary.status === \"failed\"\n ) {\n return yield* new InvalidInput({\n issue: `run ${runId} is ${run.summary.status} and cannot take a resume`\n })\n }\n const sequence = ++resumeSequence\n run.pendingResume = sequence\n run.pendingResumeAtMs = now()\n run.pendingConsent = options?.consent ?? run.pendingConsent\n updateSummary(run, { pendingResume: sequence })\n return sequence\n }),\n pendingResumes: Effect.sync(() =>\n Array.from(runs.entries()).flatMap(([runId, run]) =>\n run.pendingResume === undefined || run.pendingResumeAtMs === undefined ||\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" || run.summary.status === \"failed\"\n ? []\n : [{\n runId,\n sequence: run.pendingResume,\n requestedAtMs: run.pendingResumeAtMs,\n ...(run.pendingConsent === undefined ? {} : { consent: run.pendingConsent })\n }]\n )\n ),\n clearResume: Effect.fn(\"ControlRuntime.clearResume\")((runId, sequence) =>\n Effect.sync(() => {\n const run = runs.get(runId)\n if (run === undefined || run.pendingResume !== sequence) return\n run.pendingResume = undefined\n run.pendingResumeAtMs = undefined\n run.pendingConsent = undefined\n updateSummary(run, { pendingResume: undefined })\n })\n ),\n registerFiber: Effect.fn(\"ControlRuntime.registerFiber\")((runId, fiber) =>\n Effect.tap(requireRun(runId), (run) =>\n Effect.sync(() => {\n run.fiber = fiber\n fiber.addObserver(() => {\n if (run.fiber === fiber) run.fiber = undefined\n })\n }))\n ),\n interrupt: Effect.fn(\"ControlRuntime.interrupt\")(function*(runId, settle = (effect) => effect) {\n const run = yield* requireRun(runId)\n // Terminal first, as `resume` does: a settled run released its fence,\n // and answering `ClaimLost` there would name the wrong problem.\n if (\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" ||\n run.summary.status === \"failed\"\n ) return snapshot(run.summary)\n if (run.localFence === undefined) return yield* new ClaimLost({ runId })\n const fence = run.localFence\n yield* checkFence(runId, run, fence)\n if (run.fiber !== undefined) yield* Fiber.interrupt(run.fiber)\n return yield* settle(Effect.gen(function*() {\n // Cleanup may settle the run or release and replace its owner.\n if (\n run.summary.status === \"cancelled\" ||\n run.summary.status === \"completed\" ||\n run.summary.status === \"failed\"\n ) return snapshot(run.summary)\n yield* checkFence(runId, run, fence)\n run.fence = undefined\n run.localFence = undefined\n return updateSummary(run, { status: \"cancelled\", ownerId: undefined, parkedBy: undefined })\n }))\n }),\n codeDrift: Effect.fn(\"ControlRuntime.codeDrift\")(function*(runId) {\n const run = yield* requireRun(runId)\n return codeDriftOf(run.summary, flows.get(run.summary.flowId), options.engineVersion)\n }),\n recordedCode: Effect.fn(\"ControlRuntime.recordedCode\")(function*(runId) {\n const { executionDigest, engineVersion } = (yield* requireRun(runId)).summary\n return { executionDigest, engineVersion }\n }),\n resume: Effect.fn(\"ControlRuntime.resume\")((runId) => resumeRun(runId)),\n // `plan` refuses a flow this catalog does not hold, and the catalog is\n // fixed at construction, so a run's flow is never gone here and there\n // is always code to adopt. `SqlControlRuntime` reads a catalog that can\n // lose a flow, and refuses that case before the claim.\n resumeAdopting: Effect.fn(\"ControlRuntime.resumeAdopting\")((runId) =>\n resumeRun(\n runId,\n (run) => Effect.succeed(adoptedCode(run.summary, flows.get(run.summary.flowId), options.engineVersion))\n )\n ),\n claimFence: Effect.fn(\"ControlRuntime.claimFence\")(function*(runId) {\n const run = yield* requireRun(runId)\n if (run.localFence === undefined) return yield* new ClaimLost({ runId })\n return run.localFence\n }),\n releasePending: Effect.fn(\"ControlRuntime.releasePending\")(function*(runId, fence) {\n const run = yield* requireRun(runId)\n yield* checkFence(runId, run, fence)\n run.fence = undefined\n run.localFence = undefined\n return updateSummary(run, {\n status: \"accepted\",\n ownerId: undefined,\n parkedBy: undefined\n })\n }),\n writeStatus: Effect.fn(\"ControlRuntime.writeStatus\")(function*(runId, fence, status) {\n const run = yield* requireRun(runId)\n yield* checkFence(runId, run, fence)\n // Ownership is released by any status that is not being driven, so the\n // fence that wrote a terminal or parked status is spent by writing it.\n if (status === \"accepted\" || status === \"running\") {\n return updateSummary(run, { status, parkedBy: undefined })\n }\n run.fence = undefined\n run.localFence = undefined\n // The spent fence is kept on a park, and only on a park: it is the\n // only thing left on the row that says which host parked it.\n return updateSummary(run, {\n status,\n ownerId: undefined,\n parkedBy: status === \"parked\" || status === \"waiting-approval\" ? fence : undefined\n })\n }),\n // Precedence matches `SqlControlRuntime`: the submitted identity is\n // the one a server authenticated, and the configured one is this\n // composition's fallback for a caller that named none.\n stampPrincipal: Effect.fn(\"ControlRuntime.stampPrincipal\")((submitted) =>\n Effect.sync(() => ({\n id: submitted?.id ?? options.principal?.id ?? \"memory\",\n kind: submitted?.kind ?? options.principal?.kind ?? \"test\",\n stampedAt: now()\n }))\n ),\n lookupMutation: Effect.fn(\"ControlRuntime.lookupMutation\")((key, fingerprint) =>\n Effect.sync(() => {\n const record = mutations.get(key)\n if (record === undefined) return undefined\n return record.fingerprint === fingerprint\n ? replayReceipt(key, record.receipt)\n : { _tag: \"Conflict\", message: `idempotency key ${key} was used for another mutation` }\n })\n ),\n recordMutation: Effect.fn(\"ControlRuntime.recordMutation\")((key, fingerprint, receipt) =>\n Effect.gen(function*() {\n const prior = mutations.get(key)\n if (\n prior !== undefined &&\n (prior.fingerprint !== fingerprint || canonical(prior.receipt) !== canonical(receipt))\n ) {\n return yield* Effect.fail(\n new PersistenceError({\n operation: \"record a mutation\",\n message: `Idempotency key ${key} was already settled by another mutation`\n })\n )\n }\n mutations.set(key, { fingerprint, receipt: snapshot(receipt) })\n })\n ),\n claimRunKey: Effect.fn(\"ControlRuntime.claimRunKey\")(function*(key, fingerprint) {\n const holder = runKeys.get(key)\n if (holder !== undefined) {\n if (holder.fingerprint !== fingerprint) {\n return yield* new InvalidInput({\n issue: `idempotency key ${key} was used for another run`\n })\n }\n const record = mutations.get(key)\n if (record === undefined) {\n // One process owns this runtime, so reaching here takes a caller\n // that claimed and never recorded: the cross-process winner this\n // branch really models commits both in one transaction, which is\n // `SqlControlRuntime`'s seam.\n return yield* new PersistenceError({\n operation: \"read a mutation\",\n message: `run key ${key} was claimed by a mutation that recorded no receipt`\n })\n }\n return { _tag: \"Raced\" as const, receipt: snapshot(record.receipt) }\n }\n runKeys.set(key, { fingerprint })\n return { _tag: \"Claimed\" as const }\n }),\n releaseRunKey: Effect.fn(\"ControlRuntime.releaseRunKey\")((key) =>\n Effect.sync(() => {\n runKeys.delete(key)\n })\n ),\n grants: Effect.fn(\"ControlRuntime.grants\")(() => Effect.sync(() => snapshot(installedGrants)))()\n })\n return service\n })\n )\n\nFault.register(\"/control/ApprovalPending\", \"wait\")\nFault.register(\"/control/ApprovalDenied\", \"user\")\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,YAAuB;AAEvB,oBAAsE;AACtE,wBAAmC;AAEnC,0BAaO;AAiBP,2BAA6E;AAC7E,oBAA+B;AAC/B,sBAWO;AACP,yBAA0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E,CAAC;AAAA,MACH;AAAA,MACA,aAAa,qBAAO,GAAG,4BAA4B,EAAE,WAAU,KAAK,aAAa;AAC/E,cAAM,SAAS,QAAQ,IAAI,GAAG;AAC9B,YAAI,WAAW,QAAW;AACxB,cAAI,OAAO,gBAAgB,aAAa;AACtC,mBAAO,OAAO,IAAI,iCAAa;AAAA,cAC7B,OAAO,mBAAmB,GAAG;AAAA,YAC/B,CAAC;AAAA,UACH;AACA,gBAAM,SAAS,UAAU,IAAI,GAAG;AAChC,cAAI,WAAW,QAAW;AAKxB,mBAAO,OAAO,IAAI,qCAAiB;AAAA,cACjC,WAAW;AAAA,cACX,SAAS,WAAW,GAAG;AAAA,YACzB,CAAC;AAAA,UACH;AACA,iBAAO,EAAE,MAAM,SAAkB,SAAS,SAAS,OAAO,OAAO,EAAE;AAAA,QACrE;AACA,gBAAQ,IAAI,KAAK,EAAE,YAAY,CAAC;AAChC,eAAO,EAAE,MAAM,UAAmB;AAAA,MACpC,CAAC;AAAA,MACD,eAAe,qBAAO,GAAG,8BAA8B;AAAA,QAAE,CAAC,QACxD,qBAAO,KAAK,MAAM;AAChB,kBAAQ,OAAO,GAAG;AAAA,QACpB,CAAC;AAAA,MACH;AAAA,MACA,QAAQ,qBAAO,GAAG,uBAAuB,EAAE,MAAM,qBAAO,KAAK,MAAM,SAAS,eAAe,CAAC,CAAC,EAAE;AAAA,IACjG,CAAC;AACD,WAAO;AAAA,EACT,CAAC;AACH;AAEF,MAAM,SAAS,4BAA4B,MAAM;AACjD,MAAM,SAAS,2BAA2B,MAAM;",
|
|
6
6
|
"names": ["PrincipalSchema", "GrantScopeSchema", "options", "replayReceipt"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlControlRuntime.d.ts","sourceRoot":"","sources":["../../src/SqlControlRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAGH,OAAO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AI,EAAE,CAAA"}
|
|
@@ -281,7 +281,9 @@ const makeRuntime = (options = {}) => {
|
|
|
281
281
|
// so the walk stops at one rather than telling a reader that a run
|
|
282
282
|
// which can proceed cannot.
|
|
283
283
|
...pendingWaits === void 0 ? {} : { pendingWaits },
|
|
284
|
-
...pendingWaits === void 0 || !pendingWaits.some(
|
|
284
|
+
...pendingWaits === void 0 || !pendingWaits.some(
|
|
285
|
+
(wait) => wait.reason === ControlExecutor.humanWaitReason
|
|
286
|
+
) || terminal(base.status) ? {} : { status: "waiting-approval" },
|
|
285
287
|
...pendingResume === void 0 ? {} : { pendingResume },
|
|
286
288
|
...parentRunId === void 0 ? {} : { parentRunId },
|
|
287
289
|
...lineageId === void 0 ? {} : { lineageId },
|
|
@@ -676,7 +678,6 @@ const makeRuntime = (options = {}) => {
|
|
|
676
678
|
const ids = JSON.stringify([...new Set(filters.runIds)]);
|
|
677
679
|
conditions.push(
|
|
678
680
|
sql.onDialectOrElse({
|
|
679
|
-
/* v8 ignore next -- PostgreSQL adapter; covered by //packages/smithers/control:postgresInventory */
|
|
680
681
|
pg: () => sql`runs.run_id IN (SELECT jsonb_array_elements_text(${ids}::jsonb))`,
|
|
681
682
|
orElse: () => sql`runs.run_id IN (SELECT value FROM json_each(${ids}))`
|
|
682
683
|
})
|