mayura 1.2.0 → 1.2.1
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/docs/README.md +1 -0
- package/docs/concepts/workflows.md +60 -1
- package/docs/guides/durable-workflows.md +1 -1
- package/docs/guides/rag-production.md +29 -0
- package/docs/guides/rag.md +12 -2
- package/docs/guides/release-readiness.md +8 -22
- package/docs/guides/workflow-composition.md +1 -1
- package/docs/integrations/vector-pinecone.md +1 -1
- package/lib/adapter-code-docker/image/Dockerfile +1 -1
- package/lib/adapter-code-docker/package.json +1 -1
- package/lib/adapter-code-quickjs/package.json +1 -1
- package/lib/adapter-mcp/package.json +1 -1
- package/lib/ag-ui/package.json +1 -1
- package/lib/artifacts/package.json +1 -1
- package/lib/auth/package.json +1 -1
- package/lib/authz/package.json +1 -1
- package/lib/browser/package.json +1 -1
- package/lib/cli/dist/operations.d.ts +1 -0
- package/lib/cli/dist/operations.d.ts.map +1 -1
- package/lib/cli/dist/operations.js +13 -5
- package/lib/cli/dist/operations.js.map +1 -1
- package/lib/cli/package.json +1 -1
- package/lib/cli/src/operations.ts +9 -5
- package/lib/client/dist/index.d.ts.map +1 -1
- package/lib/client/dist/index.js +12 -4
- package/lib/client/dist/index.js.map +1 -1
- package/lib/client/dist/workflow-limits.d.ts +6 -0
- package/lib/client/dist/workflow-limits.d.ts.map +1 -0
- package/lib/client/dist/workflow-limits.js +15 -0
- package/lib/client/dist/workflow-limits.js.map +1 -0
- package/lib/client/dist/workflows.d.ts +3 -0
- package/lib/client/dist/workflows.d.ts.map +1 -1
- package/lib/client/dist/workflows.js +15 -7
- package/lib/client/dist/workflows.js.map +1 -1
- package/lib/client/package.json +1 -1
- package/lib/client/src/index.ts +7 -4
- package/lib/client/src/workflow-limits.ts +12 -0
- package/lib/client/src/workflows.ts +12 -6
- package/lib/client-react/package.json +1 -1
- package/lib/code-mode/package.json +1 -1
- package/lib/code-mode-workflows/package.json +1 -1
- package/lib/context/package.json +1 -1
- package/lib/core/dist/host.d.ts +1 -0
- package/lib/core/dist/host.d.ts.map +1 -1
- package/lib/core/dist/host.js +1 -0
- package/lib/core/dist/host.js.map +1 -1
- package/lib/core/dist/index.d.ts +1 -0
- package/lib/core/dist/index.d.ts.map +1 -1
- package/lib/core/dist/index.js +1 -0
- package/lib/core/dist/index.js.map +1 -1
- package/lib/core/dist/workflow-environment.d.ts +9 -0
- package/lib/core/dist/workflow-environment.d.ts.map +1 -0
- package/lib/core/dist/workflow-environment.js +15 -0
- package/lib/core/dist/workflow-environment.js.map +1 -0
- package/lib/core/dist/workflow-limits.d.ts +7 -0
- package/lib/core/dist/workflow-limits.d.ts.map +1 -0
- package/lib/core/dist/workflow-limits.js +17 -0
- package/lib/core/dist/workflow-limits.js.map +1 -0
- package/lib/core/package.json +1 -1
- package/lib/core/src/host.ts +1 -0
- package/lib/core/src/index.ts +1 -0
- package/lib/core/src/workflow-environment.ts +15 -0
- package/lib/core/src/workflow-limits.ts +16 -0
- package/lib/exporter-otlp/dist/otlp-http-json.js +1 -1
- package/lib/exporter-otlp/dist/otlp-http-json.js.map +1 -1
- package/lib/exporter-otlp/dist/signals.js +2 -2
- package/lib/exporter-otlp/dist/signals.js.map +1 -1
- package/lib/exporter-otlp/package.json +1 -1
- package/lib/exporter-otlp/src/otlp-http-json.ts +1 -1
- package/lib/exporter-otlp/src/signals.ts +2 -2
- package/lib/files/package.json +1 -1
- package/lib/guardrails/package.json +1 -1
- package/lib/helpers/package.json +1 -1
- package/lib/keys/package.json +1 -1
- package/lib/memory/package.json +1 -1
- package/lib/memory-remote/package.json +1 -1
- package/lib/observability/package.json +1 -1
- package/lib/provider-anthropic/package.json +1 -1
- package/lib/provider-openai/package.json +1 -1
- package/lib/rag/dist/bm25.d.ts +13 -0
- package/lib/rag/dist/bm25.d.ts.map +1 -0
- package/lib/rag/dist/bm25.js +76 -0
- package/lib/rag/dist/bm25.js.map +1 -0
- package/lib/rag/dist/document-lexical.d.ts +7 -0
- package/lib/rag/dist/document-lexical.d.ts.map +1 -0
- package/lib/rag/dist/document-lexical.js +33 -0
- package/lib/rag/dist/document-lexical.js.map +1 -0
- package/lib/rag/dist/evidence-window.d.ts +15 -0
- package/lib/rag/dist/evidence-window.d.ts.map +1 -0
- package/lib/rag/dist/evidence-window.js +52 -0
- package/lib/rag/dist/evidence-window.js.map +1 -0
- package/lib/rag/dist/retrieval.d.ts +6 -0
- package/lib/rag/dist/retrieval.d.ts.map +1 -1
- package/lib/rag/dist/retrieval.js +60 -6
- package/lib/rag/dist/retrieval.js.map +1 -1
- package/lib/rag/dist/vectors.d.ts +8 -0
- package/lib/rag/dist/vectors.d.ts.map +1 -1
- package/lib/rag/dist/vectors.js +121 -4
- package/lib/rag/dist/vectors.js.map +1 -1
- package/lib/rag/package.json +1 -1
- package/lib/rag/src/bm25.ts +35 -0
- package/lib/rag/src/document-lexical.ts +17 -0
- package/lib/rag/src/evidence-window.ts +41 -0
- package/lib/rag/src/retrieval.ts +56 -7
- package/lib/rag/src/vectors.ts +62 -4
- package/lib/runtime/package.json +1 -1
- package/lib/sandbox/package.json +1 -1
- package/lib/sdk/package.json +1 -1
- package/lib/server/dist/index.d.ts +2 -0
- package/lib/server/dist/index.d.ts.map +1 -1
- package/lib/server/dist/index.js +12 -4
- package/lib/server/dist/index.js.map +1 -1
- package/lib/server/dist/inspector-bundle.d.ts +1 -1
- package/lib/server/dist/inspector-bundle.d.ts.map +1 -1
- package/lib/server/dist/inspector-bundle.js +4 -4
- package/lib/server/dist/inspector-bundle.js.map +1 -1
- package/lib/server/package.json +1 -1
- package/lib/server/src/index.ts +9 -4
- package/lib/server/src/inspector-bundle.ts +4 -4
- package/lib/server-node/package.json +1 -1
- package/lib/skills/package.json +1 -1
- package/lib/storage/package.json +1 -1
- package/lib/storage-contracts/dist/scheduled-workflow-contracts.d.ts +2 -0
- package/lib/storage-contracts/dist/scheduled-workflow-contracts.d.ts.map +1 -1
- package/lib/storage-contracts/dist/scheduled-workflow-contracts.js.map +1 -1
- package/lib/storage-contracts/dist/workflow-format2.d.ts +2 -0
- package/lib/storage-contracts/dist/workflow-format2.d.ts.map +1 -1
- package/lib/storage-contracts/dist/workflow-format2.js +8 -7
- package/lib/storage-contracts/dist/workflow-format2.js.map +1 -1
- package/lib/storage-contracts/dist/workflow-format3.d.ts.map +1 -1
- package/lib/storage-contracts/dist/workflow-format3.js +9 -7
- package/lib/storage-contracts/dist/workflow-format3.js.map +1 -1
- package/lib/storage-contracts/dist/workflow-format4.d.ts +2 -0
- package/lib/storage-contracts/dist/workflow-format4.d.ts.map +1 -1
- package/lib/storage-contracts/dist/workflow-format4.js +9 -8
- package/lib/storage-contracts/dist/workflow-format4.js.map +1 -1
- package/lib/storage-contracts/dist/workflow-format5.d.ts +4 -0
- package/lib/storage-contracts/dist/workflow-format5.d.ts.map +1 -1
- package/lib/storage-contracts/dist/workflow-format5.js +9 -8
- package/lib/storage-contracts/dist/workflow-format5.js.map +1 -1
- package/lib/storage-contracts/dist/workflow-graph-contracts.d.ts +2 -0
- package/lib/storage-contracts/dist/workflow-graph-contracts.d.ts.map +1 -1
- package/lib/storage-contracts/dist/workflow-graph-contracts.js.map +1 -1
- package/lib/storage-contracts/dist/workflow-tree-contracts.d.ts +2 -0
- package/lib/storage-contracts/dist/workflow-tree-contracts.d.ts.map +1 -1
- package/lib/storage-contracts/dist/workflow-tree-contracts.js +5 -3
- package/lib/storage-contracts/dist/workflow-tree-contracts.js.map +1 -1
- package/lib/storage-contracts/package.json +1 -1
- package/lib/storage-contracts/src/scheduled-workflow-contracts.ts +2 -0
- package/lib/storage-contracts/src/workflow-format2.ts +10 -7
- package/lib/storage-contracts/src/workflow-format3.ts +9 -7
- package/lib/storage-contracts/src/workflow-format4.ts +11 -8
- package/lib/storage-contracts/src/workflow-format5.ts +13 -8
- package/lib/storage-contracts/src/workflow-graph-contracts.ts +2 -0
- package/lib/storage-contracts/src/workflow-tree-contracts.ts +7 -3
- package/lib/storage-postgres/package.json +1 -1
- package/lib/storage-sql/dist/scheduled-database.js +1 -1
- package/lib/storage-sql/dist/scheduled-database.js.map +1 -1
- package/lib/storage-sql/dist/workflow-tree-database.d.ts.map +1 -1
- package/lib/storage-sql/dist/workflow-tree-database.js +37 -1
- package/lib/storage-sql/dist/workflow-tree-database.js.map +1 -1
- package/lib/storage-sql/package.json +1 -1
- package/lib/storage-sql/src/scheduled-database.ts +1 -1
- package/lib/storage-sql/src/workflow-tree-database.ts +15 -1
- package/lib/storage-sqlite/package.json +1 -1
- package/lib/terminal/package.json +1 -1
- package/lib/testing/package.json +1 -1
- package/lib/threads/package.json +1 -1
- package/lib/tools/package.json +1 -1
- package/lib/voice/package.json +1 -1
- package/lib/workflows/dist/children-definition.d.ts +5 -1
- package/lib/workflows/dist/children-definition.d.ts.map +1 -1
- package/lib/workflows/dist/children-definition.js +6 -2
- package/lib/workflows/dist/children-definition.js.map +1 -1
- package/lib/workflows/dist/children-runtime.d.ts.map +1 -1
- package/lib/workflows/dist/children-runtime.js +4 -3
- package/lib/workflows/dist/children-runtime.js.map +1 -1
- package/lib/workflows/dist/definition.d.ts +4 -0
- package/lib/workflows/dist/definition.d.ts.map +1 -1
- package/lib/workflows/dist/definition.js +6 -3
- package/lib/workflows/dist/definition.js.map +1 -1
- package/lib/workflows/dist/graph-definition.d.ts +5 -1
- package/lib/workflows/dist/graph-definition.d.ts.map +1 -1
- package/lib/workflows/dist/graph-definition.js +8 -4
- package/lib/workflows/dist/graph-definition.js.map +1 -1
- package/lib/workflows/dist/lifecycle-definition.d.ts +5 -1
- package/lib/workflows/dist/lifecycle-definition.d.ts.map +1 -1
- package/lib/workflows/dist/lifecycle-definition.js +5 -2
- package/lib/workflows/dist/lifecycle-definition.js.map +1 -1
- package/lib/workflows/dist/lifecycle-runtime.d.ts.map +1 -1
- package/lib/workflows/dist/lifecycle-runtime.js +4 -5
- package/lib/workflows/dist/lifecycle-runtime.js.map +1 -1
- package/lib/workflows/dist/node-batches.d.ts +9 -0
- package/lib/workflows/dist/node-batches.d.ts.map +1 -0
- package/lib/workflows/dist/node-batches.js +19 -0
- package/lib/workflows/dist/node-batches.js.map +1 -0
- package/lib/workflows/dist/operator-transports.d.ts +1 -0
- package/lib/workflows/dist/operator-transports.d.ts.map +1 -1
- package/lib/workflows/dist/operator-transports.js +1 -0
- package/lib/workflows/dist/operator-transports.js.map +1 -1
- package/lib/workflows/dist/runtime.d.ts.map +1 -1
- package/lib/workflows/dist/runtime.js +6 -7
- package/lib/workflows/dist/runtime.js.map +1 -1
- package/lib/workflows/dist/scheduled-helpers.d.ts.map +1 -1
- package/lib/workflows/dist/scheduled-helpers.js +3 -2
- package/lib/workflows/dist/scheduled-helpers.js.map +1 -1
- package/lib/workflows/dist/scheduled.d.ts.map +1 -1
- package/lib/workflows/dist/scheduled.js +2 -1
- package/lib/workflows/dist/scheduled.js.map +1 -1
- package/lib/workflows/package.json +1 -1
- package/lib/workflows/src/children-definition.ts +10 -3
- package/lib/workflows/src/children-runtime.ts +3 -2
- package/lib/workflows/src/definition.ts +9 -2
- package/lib/workflows/src/graph-definition.ts +10 -3
- package/lib/workflows/src/lifecycle-definition.ts +10 -3
- package/lib/workflows/src/lifecycle-runtime.ts +4 -4
- package/lib/workflows/src/node-batches.ts +21 -0
- package/lib/workflows/src/operator-transports.ts +3 -1
- package/lib/workflows/src/runtime.ts +6 -6
- package/lib/workflows/src/scheduled-helpers.ts +3 -2
- package/lib/workflows/src/scheduled.ts +2 -1
- package/lib/workstream/package.json +1 -1
- package/llms-full.txt +116 -28
- package/llms.txt +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAwF,MAAM,cAAc,CA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KAAK,EAAE,CAAC,CAAC,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE;gBAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACnI,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { workflowAuthorization } from './authorization.js';\nimport type { Authorizer } from '@mayura/core';\nimport { Budget, MayuraError, assertPositiveInteger, freezeJson, jsonValue, validate, type ExecutionReceipt, type JsonObject, type JsonValue, type Permissions, type Scope } from '@mayura/core';\nimport { invokeTool } from '@mayura/tools';\nimport { bindToolApproval } from '@mayura/tools/host';\nimport { abandoned, dispatchedAt } from './abandoned.js';\nimport { createWorkflowDrainGate, type WorkflowDrainOptions, type WorkflowDrainReport } from './drain.js';\nimport { StorageError, assertWorkflowStateMatchesManifest, workflowState, workflowOutputs, mergeWorkflowReceipt,\n type WorkflowFormat2State as State, type WorkflowFormat2Step as Step, type WorkflowFormat2StepStatus as StepStatus,\n type WorkflowFormat2Status as Status, type AggregateStore, type StoredRecord } from '@mayura/storage-contracts';\nimport { assertWorkflow, charged, digest, resolveBinding, type AnyWorkflow, type WorkflowNode } from './definition.js';\nimport { assertMigrationAllowed, assertWorkflowMigration, migrationCommand, migrationEvent, nodeEvidence, nodeFingerprint, planWorkflowMigration,\n type MigrationBlocker, type MigrationCommand, type WorkflowMigration, type WorkflowMigrationResult } from './migration.js';\nimport { scheduledManifest } from './scheduled-helpers.js';\nimport { createSubmission, workflowStorageFailure } from './storage-failure.js';\n\nexport interface WorkflowSnapshot {\n readonly id: string; readonly version: number; readonly status: Status;\n readonly steps: Readonly<Record<string, Readonly<Step>>>;\n readonly output: JsonValue;\n readonly budget: { readonly spentMicros: number; readonly reservedMicros: number; readonly maxCostMicros: number };\n}\nexport interface VerifiedHuman { readonly id: string; readonly projectId: string; readonly canApprove: boolean }\nexport interface WorkflowRuntimeOptions {\n readonly store: AggregateStore; readonly scope: Scope; readonly permissions: Permissions;\n /** Host-owned core authorizer; decisions and audit delivery use its existing limits and lifecycle. */\n readonly authorization?: Authorizer;\n readonly policyVersion: string; readonly maxCostMicros: number;\n readonly approvalTtlMs?: number; readonly maxOutputBytes?: number;\n /** Trusted identity boundary. Credentials are opaque to the workflow and never persisted. */\n readonly verifyHuman?: (credential: unknown) => Promise<VerifiedHuman>;\n}\nconst terminalSteps = new Set<StepStatus>(['succeeded', 'failed', 'blocked', 'unknown', 'skipped']);\n\n/** Bounds trusted async callbacks; it cannot terminate synchronous JavaScript or undo effects. */\nasync function bounded<T>(operation: () => Promise<T>, timeoutMs: number): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([Promise.resolve().then(operation), new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new MayuraError('TIMEOUT', 'Workflow validation or control operation timed out.')), timeoutMs);\n })]);\n } finally { if (timer) clearTimeout(timer); }\n}\n\nfunction stateFrom(record: StoredRecord): State {\n try { return workflowState(record); }\n catch { throw new MayuraError('CONFLICT', 'Stored workflow state failed integrity validation.'); }\n}\n\n/** External storage diagnostics never cross the workflow's public error boundary. */\nasync function storageCall<T>(operation: () => Promise<T>): Promise<T> {\n try { return await operation(); }\n catch (error) { throw workflowStorageFailure(error, 'workflow run'); }\n}\nfunction snapshot(record: StoredRecord): WorkflowSnapshot {\n const state = stateFrom(record);\n return freezeJson(jsonValue({ id: record.id, version: record.version, status: state.status, steps: state.steps, output: state.output, budget: { spentMicros: state.spentMicros, reservedMicros: state.reservedMicros, maxCostMicros: state.maxCostMicros } })) as unknown as WorkflowSnapshot;\n}\n\n/** Known evidence is monotonic; stale cancellation snapshots cannot turn success back into unknown. */\nfunction mergeReceipt(previous: ExecutionReceipt | null, incoming: ExecutionReceipt): ExecutionReceipt {\n try { return mergeWorkflowReceipt(previous, incoming); }\n catch { throw new MayuraError('CONFLICT', 'Conflicting known execution evidence requires reconciliation.'); }\n}\nfunction outputs(state: State): Record<string, JsonValue> {\n try { return workflowOutputs(state); }\n catch { throw new MayuraError('CONFLICT', 'Stored workflow output failed integrity validation.'); }\n}\nfunction initialState(definition: AnyWorkflow, input: JsonValue, policy: string, maxCostMicros: number): State {\n return { format: 2, definition: definition.digest, policy, input, status: 'running', maxCostMicros, spentMicros: 0, reservedMicros: 0, output: null,\n steps: Object.fromEntries(definition.nodes.map(node => [node.id, { kind: node.kind, status: 'pending', callId: `step:${node.id}`, output: null, receipt: null, approval: null, costReserved: 0, candidateHash: null }])) };\n}\n\n/** Conservative durable DAG driver. No automatic replay/reclaim of dispatched effects. */\nexport function createWorkflowRuntime(options: WorkflowRuntimeOptions) {\n const { store } = options;\n const scope = Object.freeze({ principalId: options.scope.principalId, projectId: options.scope.projectId });\n if ([scope.principalId, scope.projectId, options.policyVersion].some(value => typeof value !== 'string' || !value.length || value.length > 128)) throw new MayuraError('INVALID_CONFIG', 'Workflow scope and policy version are required.');\n if (!Array.isArray(options.permissions?.allow) || options.permissions.allow.length > 4096 || options.permissions.allow.some(grant => typeof grant !== 'string' || !grant.length || grant.length > 256)) throw new MayuraError('INVALID_CONFIG', 'Workflow permissions must be bounded explicit grants.');\n const permissions = Object.freeze({ allow: Object.freeze([...options.permissions.allow]) });\n const maxCostMicros = options.maxCostMicros;\n if (!Number.isSafeInteger(maxCostMicros) || maxCostMicros < 0) throw new MayuraError('INVALID_CONFIG', 'A bounded workflow cost is required.');\n const approvalTtlMs = options.approvalTtlMs ?? 3_600_000;\n const maxOutputBytes = options.maxOutputBytes ?? 1_048_576;\n assertPositiveInteger(approvalTtlMs, 'approvalTtlMs'); assertPositiveInteger(maxOutputBytes, 'maxOutputBytes');\n const verifyHuman = options.verifyHuman;\n const auth = workflowAuthorization(options.authorization, scope);\n const scopeKey = digest('mayura:scope:v1', scope);\n const policy = digest('mayura:policy:v1', { scope, permissions: [...permissions.allow].sort(), policyVersion: options.policyVersion, maxCostMicros, maxOutputBytes, approvalTtlMs });\n const active = new Map<string, AbortController>();\n let closed = false; const gate = createWorkflowDrainGate();\n const ensureOpen = (): void => { if (closed) throw new MayuraError('CANCELLED', 'Workflow runtime is closed.'); };\n const load = async (id: string, allowClosed = false): Promise<StoredRecord> => {\n if (!allowClosed) ensureOpen();\n const record = await storageCall(() => store.read(scopeKey, id));\n if (!record) throw new MayuraError('NOT_FOUND', 'Workflow run was not found in this scope.');\n if (record.id !== id || record.scope !== scopeKey) throw new MayuraError('CONFLICT', 'Stored workflow identity does not match the requested scope.');\n stateFrom(record);\n return record;\n };\n const save = async (record: StoredRecord, state: State, type: string, data: JsonObject = {}): Promise<StoredRecord> =>\n storageCall(() => store.update({ scope: scopeKey, id: record.id, expectedVersion: record.version, state: jsonValue(state) as JsonObject, events: [{ type, data }] }));\n const mutate = async (id: string, update: (state: State) => boolean, type: string, data: JsonObject = {}, allowClosed = false): Promise<StoredRecord> => {\n for (let attempt = 0; attempt < 32; attempt++) {\n const record = await load(id, allowClosed); const state = stateFrom(record);\n if (!update(state)) return record;\n try { return await save(record, state, type, data); }\n catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n }\n throw new MayuraError('CONFLICT', 'Workflow contention exceeded the bounded retry limit.');\n };\n const candidate = (node: Extract<WorkflowNode, {kind:'tool'}>, input: JsonValue, runId: string, expiresAt: number | null): string =>\n digest('mayura:approval:v1', { runId, nodeId: node.id, tool: node.tool.id, toolVersion: node.tool.version, input, policy, expiresAt });\n\n async function executeNode(id: string, node: WorkflowNode, claimRetries = 0): Promise<void> {\n const record = await load(id); const state = stateFrom(record); const step = state.steps[node.id];\n await auth.execute(state.definition, id);\n // A first-wave read can finish after a predecessor settles and draining begins.\n // Such a node has not claimed an effect and must remain for the next worker.\n if (gate.draining || !step || state.policy !== policy || ['paused', 'cancelled'].includes(state.status)) return;\n // A dispatching step that no call in this process owns, past the tool's timeout and a margin, belongs to a process\n // that stopped: settle it as recoverAbandoned would, and never run the effect again.\n if (node.kind === 'tool' && step.status === 'dispatching') {\n if (active.has(`${id}/${node.id}`)) return;\n const dispatchedAtMs = await storageCall(() => dispatchedAt(store, scopeKey, id, 'step.dispatching', node.id));\n if (!abandoned(dispatchedAtMs, node.tool.timeoutMs, Date.now())) return;\n await mutate(id, current => {\n const target = current.steps[node.id];\n if (!target || target.status !== 'dispatching' || ['paused', 'cancelled'].includes(current.status) || active.has(`${id}/${node.id}`)) return false;\n target.status = target.receipt?.execution === 'succeeded' ? 'blocked' : 'unknown'; current.status = 'running'; return true;\n }, 'step.abandoned', { nodeId: node.id });\n return;\n }\n if (!['pending', 'approved'].includes(step.status)) return;\n const dependencies = (node.dependsOn ?? []).map(key => state.steps[key]!);\n if (dependencies.some(item => terminalSteps.has(item.status) && item.status !== 'succeeded')) {\n await mutate(id, current => { const next = current.steps[node.id]!; if (!['pending','approved'].includes(next.status)) return false; next.status = 'skipped'; return true; }, 'step.skipped', { nodeId: node.id }); return;\n }\n if (dependencies.some(item => item.status !== 'succeeded')) return;\n if (node.kind === 'join') {\n step.output = dependencies.map(item => item.output); step.status = 'succeeded';\n try { await save(record, state, 'step.completed', { nodeId: node.id }); } catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n const required = [`tool:${node.tool.id}`, ...node.tool.capabilities, ...(node.tool.effects === 'none' ? [] : [`effect:${node.tool.effects}`])];\n if (required.some(grant => !permissions.allow.includes(grant))) {\n step.status = 'blocked';\n try { await save(record, state, 'step.blocked', { nodeId: node.id, code: 'PERMISSION_DENIED' }); } catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n await auth.require('tool', node.tool.id, 'execute');\n let input: JsonValue;\n try { input = jsonValue(await bounded(() => validate(node.tool.input, resolveBinding(node.input, state.input, outputs(state)), 'input'), node.tool.timeoutMs), { maxBytes: maxOutputBytes }); }\n catch {\n step.status = 'failed';\n try { await save(record, state, 'step.failed', { nodeId: node.id, code: 'INVALID_INPUT' }); }\n catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n await auth.execute(state.definition, id);\n await auth.require('tool', node.tool.id, 'execute');\n const previousExpiry = step.approval?.expiresAt ?? 0;\n const reviewExpiry = node.approval ? (previousExpiry > Date.now() ? previousExpiry : Date.now() + approvalTtlMs) : null;\n const candidateHash = candidate(node, input, id, reviewExpiry);\n if (node.approval && (step.status !== 'approved' || step.approval?.digest !== candidateHash || step.approval.expiresAt <= Date.now())) {\n step.status = 'waiting'; step.approval = { digest: candidateHash, expiresAt: reviewExpiry!, humanId: null }; state.status = 'waiting';\n try { await save(record, state, 'approval.requested', { nodeId: node.id, digest: candidateHash }); } catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n if (node.tool.costMicros > state.maxCostMicros - state.spentMicros - state.reservedMicros) {\n step.status = 'blocked';\n try { await save(record, state, 'step.blocked', { nodeId: node.id, code: 'BUDGET_EXCEEDED' }); }\n catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n await auth.execute(state.definition, id);\n // Policy evaluation may yield after the earlier admission check. Linearize the\n // effect claim here; already-claimed work still drains through its receipt.\n if (gate.draining) return;\n step.status = 'dispatching'; step.candidateHash = candidateHash; step.costReserved = node.tool.costMicros;\n state.reservedMicros += node.tool.costMicros; state.status = 'running';\n try { await save(record, state, 'step.dispatching', { nodeId: node.id, callId: step.callId }); }\n catch (error) {\n // Retry the losing claim immediately: waiting for this wave would serialize independent handlers.\n // Every retry reloads permissions/candidate/budget state before crossing the dispatch boundary.\n if (error instanceof StorageError && error.storageCode === 'CONFLICT' && claimRetries < 32) return executeNode(id, node, claimRetries + 1);\n throw error;\n }\n const controller = new AbortController(); const activeKey = `${id}/${node.id}`; active.set(activeKey, controller);\n try {\n const raw = resolveBinding(node.input, state.input, outputs(state));\n // A step that needs approval reaches here only approved; the tool's own approval rule then accepts the call.\n const approvalBinding = node.approval ? bindToolApproval(node.tool, { runId: id, callId: `${id}/${step.callId}`, input: raw }) : undefined;\n const result = await invokeTool(node.tool, raw, {\n runId: id, callId: `${id}/${step.callId}`, scope, signal: controller.signal, permissions, ...(approvalBinding ? { approvalBinding } : {}),\n ...auth.toolContext(state.definition, id),\n budget: new Budget(node.tool.costMicros, 1), maxOutputBytes,\n beforeDispatch: async processed => {\n const current = stateFrom(await load(id));\n if (current.status !== 'running' || current.policy !== policy || current.steps[node.id]?.status !== 'dispatching' || candidate(node, processed, id, node.approval ? current.steps[node.id]!.approval!.expiresAt : null) !== candidateHash) {\n throw new MayuraError('CONFLICT', 'Workflow dispatch candidate is no longer authorized.');\n }\n if (node.approval && (current.steps[node.id]?.approval?.expiresAt ?? 0) <= Date.now()) throw new MayuraError('PERMISSION_DENIED', 'Approval expired before dispatch.');\n },\n onExecutionReceipt: async (receipt, settlement) => {\n await mutate(id, current => {\n const target = current.steps[node.id]!;\n // Retain late evidence but do not turn an operator-recovered unknown step back into success.\n target.receipt = mergeReceipt(target.receipt, receipt);\n if (receipt.execution !== 'unknown' && target.costReserved > 0) {\n current.reservedMicros -= target.costReserved;\n // Charge the reported usage (known plus unknown), capped at the reservation.\n if (receipt.execution !== 'not_started') current.spentMicros += charged(settlement, target.costReserved);\n target.costReserved = 0;\n }\n return true;\n }, 'effect.receipt', { nodeId: node.id, execution: receipt.execution }, true);\n },\n });\n await mutate(id, current => {\n const target = current.steps[node.id]!;\n if (target.status !== 'dispatching') return false;\n if (result.receipt) target.receipt = mergeReceipt(target.receipt, result.receipt);\n if (result.status === 'succeeded') { target.status = 'succeeded'; target.output = jsonValue(result.output, { maxBytes: maxOutputBytes }); }\n else target.status = result.status === 'outcome_unknown' ? 'unknown' : result.status === 'blocked' ? 'blocked' : 'failed';\n if (result.receipt?.execution === 'not_started' && target.costReserved > 0) { current.reservedMicros -= target.costReserved; target.costReserved = 0; }\n return true;\n }, 'step.completed', { nodeId: node.id, outcome: result.status });\n } finally { active.delete(activeKey); }\n }\n\n return {\n async submit<D extends AnyWorkflow>(definition: D, command: { input: unknown; idempotencyKey: string }): Promise<WorkflowSnapshot> {\n ensureOpen();\n assertWorkflow(definition);\n const idempotencyKey = command.idempotencyKey;\n if (typeof idempotencyKey !== 'string' || !idempotencyKey.length || idempotencyKey.length > 128) throw new MayuraError('INVALID_INPUT', 'A bounded submission key is required.');\n const admittedId = digest('mayura:run-id:v1', { scope: scopeKey, submissionKey: idempotencyKey });\n const inputSnapshot = freezeJson(jsonValue(command.input, { maxBytes: maxOutputBytes }));\n await auth.execute(definition.digest, admittedId);\n const input = jsonValue(await bounded(() => validate(definition.input, inputSnapshot, 'input'), 30_000), { maxBytes: maxOutputBytes });\n const state = initialState(definition, input, policy, maxCostMicros);\n const id = digest('mayura:run-id:v1', { scope: scopeKey, submissionKey: idempotencyKey });\n await auth.execute(definition.digest, id);\n const created = await createSubmission(() => store.create({ scope: scopeKey, id, idempotencyKey, definitionHash: definition.digest, state: jsonValue(state) as JsonObject, events: [{ type: 'run.created', data: {} }] }), 'workflow run');\n return snapshot(created.record);\n },\n inspect: async (id: string): Promise<WorkflowSnapshot> => snapshot(await load(id)),\n events: (id: string, after = 0) => { ensureOpen(); return storageCall(() => store.events(scopeKey, id, after)); },\n async runUntilSettled(definition: AnyWorkflow, id: string): Promise<WorkflowSnapshot> {\n const checkedSnapshot = async (record: StoredRecord) => { await auth.execute(definition.digest, id); return snapshot(record); };\n\n ensureOpen(); if (gate.draining) throw new MayuraError('CANCELLED', 'Workflow runtime is draining.');\n assertWorkflow(definition);\n await auth.execute(definition.digest, id);\n for (let wave = 0; wave <= definition.nodes.length + 1; wave++) {\n await auth.execute(definition.digest, id);\n const before = await load(id); const state = stateFrom(before);\n if (state.definition !== definition.digest || before.definitionHash !== definition.digest || state.policy !== policy || state.maxCostMicros !== maxCostMicros) throw new MayuraError('CONFLICT', 'Definition or policy changed; explicit migration/review is required.');\n if (Object.keys(state.steps).length !== definition.nodes.length || definition.nodes.some(node => !Object.hasOwn(state.steps, node.id))) throw new MayuraError('CONFLICT', 'Stored steps do not match the pinned definition.');\n for (const node of definition.nodes) {\n const step = state.steps[node.id]!;\n if (step.kind !== node.kind || (node.kind === 'tool' && step.receipt && step.receipt.toolId !== node.tool.id) || (step.status === 'succeeded' && (node.dependsOn ?? []).some(dependency => state.steps[dependency]?.status !== 'succeeded'))) throw new MayuraError('CONFLICT', 'Stored step evidence does not match the pinned graph.');\n }\n if (state.status === 'paused' || state.status === 'cancelled' || ['succeeded','failed','blocked','outcome_unknown'].includes(state.status)) return checkedSnapshot(before);\n // Each wave holds one drain admission until its effects and receipts settle.\n const release = gate.enter(); if (!release) return checkedSnapshot(before);\n try {\n const results = await Promise.allSettled(definition.nodes.map(node => executeNode(id, node)));\n const failure = results.find(result => result.status === 'rejected');\n if (failure?.status === 'rejected') throw failure.reason;\n } finally { release(); }\n let after = await load(id); const next = stateFrom(after); const steps = Object.values(next.steps);\n if (next.status === 'paused' || next.status === 'cancelled') return checkedSnapshot(after);\n if (steps.every(item => terminalSteps.has(item.status))) {\n if (steps.every(item => item.status === 'succeeded')) {\n try { next.output = jsonValue(await bounded(() => validate(definition.output, resolveBinding(definition.result, next.input, outputs(next)), 'output'), 30_000), { maxBytes: maxOutputBytes }); next.status = 'succeeded'; }\n catch { next.status = 'failed'; }\n } else next.status = steps.some(item => item.status === 'unknown') ? 'outcome_unknown' : steps.some(item => item.status === 'blocked') ? 'blocked' : 'failed';\n await auth.execute(definition.digest, id);\n try { after = await save(after, next, 'run.completed', { status: next.status }); }\n catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; after = await load(id); }\n return checkedSnapshot(after);\n }\n if (after.version === before.version) {\n if (steps.some(item => item.status === 'waiting') && !steps.some(item => item.status === 'dispatching') && next.status !== 'waiting') {\n next.status = 'waiting';\n try { after = await save(after, next, 'run.waiting'); } catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; after = await load(id); }\n }\n return checkedSnapshot(after);\n }\n }\n return checkedSnapshot(await load(id));\n },\n async approve(command: { id: string; nodeId: string; digest: string; credential: unknown }): Promise<WorkflowSnapshot> {\n ensureOpen();\n const { id, nodeId, digest: approvalDigest, credential } = command;\n await auth.require('run', id, 'approve');\n if (typeof id !== 'string' || !/^[a-f0-9]{64}$/.test(id) || typeof nodeId !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(nodeId) || typeof approvalDigest !== 'string' || !/^[a-f0-9]{64}$/.test(approvalDigest)) throw new MayuraError('INVALID_INPUT', 'Approval requires exact run, node and candidate identifiers.');\n if (!verifyHuman) throw new MayuraError('PERMISSION_DENIED', 'A trusted human identity verifier is required.');\n let human: VerifiedHuman;\n try {\n const verified = await bounded(() => verifyHuman(credential), 30_000);\n human = { id: verified.id, projectId: verified.projectId, canApprove: verified.canApprove };\n if (typeof human.id !== 'string' || !human.id.length || human.id.length > 256 || human.projectId !== scope.projectId || human.canApprove !== true) throw new Error();\n } catch { throw new MayuraError('PERMISSION_DENIED', 'Human identity verification failed.'); }\n await auth.require('run', id, 'approve');\n return snapshot(await mutate(id, state => {\n const step = state.steps[nodeId];\n if (state.status === 'cancelled' || state.policy !== policy || !step || step.status !== 'waiting' || !step.approval || step.approval.digest !== approvalDigest || step.approval.expiresAt <= Date.now()) throw new MayuraError('CONFLICT', 'Approval request is stale, expired or mismatched.');\n step.approval.humanId = human.id; step.status = 'approved'; if (state.status !== 'paused') state.status = 'running'; return true;\n }, 'approval.resolved', { nodeId, humanId: human.id }));\n },\n /** Persist a quiescent operator pause. In-flight effects must settle or reconcile first. */\n async pause(id: string): Promise<WorkflowSnapshot> {\n return snapshot(await mutate(id, state => {\n if (state.status === 'paused') return false;\n if (['succeeded','failed','blocked','outcome_unknown','cancelled'].includes(state.status)) {\n throw new MayuraError('CONFLICT', 'A terminal workflow cannot be paused.');\n }\n if (Object.values(state.steps).some(step => step.status === 'dispatching')) {\n throw new MayuraError('CONFLICT', 'A workflow with an in-flight effect cannot enter the quiescent paused state.');\n }\n state.status = 'paused'; return true;\n }, 'run.paused'));\n },\n /**\n * Plan (dryRun) or apply a reviewed migration of a paused run to a new definition version. The run stays paused;\n * resume it after review. Waiting approvals of unchanged steps stay valid (their digest does not bind the version).\n */\n async migrate(migration: WorkflowMigration<AnyWorkflow, AnyWorkflow>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowSnapshot>> {\n ensureOpen(); assertWorkflowMigration(migration); assertWorkflow(migration.from); assertWorkflow(migration.to);\n const { id, actorId, commandId, dryRun = false } = migrationCommand(command);\n const record = await load(id); const state = stateFrom(record);\n if (state.definition !== migration.from.digest || record.definitionHash !== migration.from.digest || state.policy !== policy || state.maxCostMicros !== maxCostMicros) {\n throw new MayuraError('CONFLICT', 'The run is not pinned to the migration source definition and this policy.');\n }\n const nodes = (definition: AnyWorkflow) => scheduledManifest(definition).graph.map(node =>\n ({ id: node.id, kind: node.kind, dependsOn: node.dependsOn, fingerprint: nodeFingerprint(node as unknown as Record<string, unknown>),\n ...(nodeEvidence(node) ? { evidence: nodeEvidence(node)! } : {}) }));\n const preconditions: MigrationBlocker[] = [];\n if (state.status !== 'paused') preconditions.push({ node: '*', reason: `The run is ${state.status}; pause it before migrating.` });\n const plan = planWorkflowMigration({ migration, format: 'workflow-v2', runId: id, fromDigest: migration.from.digest, toDigest: migration.to.digest,\n from: nodes(migration.from), to: nodes(migration.to), steps: Object.entries(state.steps).map(([step, value]) => ({ id: step, status: value.status })), preconditions });\n if (dryRun) return freezeJson(jsonValue({ plan })) as unknown as WorkflowMigrationResult<WorkflowSnapshot>;\n assertMigrationAllowed(plan);\n const fresh = initialState(migration.to, state.input, policy, maxCostMicros);\n const carried: Record<string, Step> = {};\n for (const entry of plan.entries) if (entry.target) carried[entry.target] = entry.action === 'keep' || entry.action === 'accept' ? state.steps[entry.source!]! : fresh.steps[entry.target]!;\n const next: State = { ...state, definition: migration.to.digest, steps: Object.fromEntries(migration.to.nodes.map(node => [node.id, carried[node.id]!])) };\n next.reservedMicros = Object.values(next.steps).reduce((sum, step) => sum + step.costReserved, 0);\n try { assertWorkflowStateMatchesManifest(workflowState({ id, state: jsonValue(next) as JsonObject }), scheduledManifest(migration.to)); }\n catch { throw new MayuraError('CONFLICT', 'Migration refused: the migrated state does not satisfy the new definition.'); }\n if (typeof store.migrate !== 'function') throw new MayuraError('UNSUPPORTED_PROFILE', 'This store cannot migrate in-flight workflow runs.');\n const migrated = await storageCall(() => store.migrate!({ scope: scopeKey, id, expectedVersion: record.version, expectedDefinitionHash: migration.from.digest,\n definitionHash: migration.to.digest, state: jsonValue(next) as JsonObject, events: [migrationEvent(plan, actorId, commandId) as { type: string; data: JsonObject }] }));\n return freezeJson(jsonValue({ plan, snapshot: snapshot(migrated) })) as unknown as WorkflowMigrationResult<WorkflowSnapshot>;\n },\n /** Resume scheduling only; unresolved waits remain waiting and grant no authority. */\n async resume(id: string): Promise<WorkflowSnapshot> {\n await auth.require('run', id, 'resume');\n return snapshot(await mutate(id, state => {\n if (state.status !== 'paused') throw new MayuraError('CONFLICT', 'Only a paused workflow can be resumed.');\n state.status = Object.values(state.steps).some(step => step.status === 'waiting') ? 'waiting' : 'running'; return true;\n }, 'run.resumed'));\n },\n async cancel(id: string): Promise<WorkflowSnapshot> {\n const record = await mutate(id, state => { if (['succeeded','failed','blocked','outcome_unknown','cancelled'].includes(state.status)) return false; state.status = 'cancelled'; return true; }, 'run.cancelled');\n for (const [key, controller] of active) if (key.startsWith(`${id}/`)) controller.abort();\n return snapshot(record);\n },\n /** Trusted operator action after establishing worker abandonment; never redispatches effects. */\n async recoverAbandoned(id: string): Promise<WorkflowSnapshot> {\n return snapshot(await mutate(id, state => {\n let changed = false;\n for (const step of Object.values(state.steps)) if (step.status === 'dispatching') {\n step.status = step.receipt?.execution === 'succeeded' ? 'blocked' : 'unknown'; changed = true;\n }\n if (changed && state.status !== 'cancelled') state.status = 'running';\n return changed;\n }, 'run.recovery_required'));\n },\n close(): void { closed = true; auth.close(); for (const controller of active.values()) controller.abort(); },\n /** Admit no new wave, let admitted effects settle within the deadline, then close. */\n drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport> {\n return gate.drain(options, () => { closed = true; auth.close(); for (const controller of active.values()) controller.abort(); });\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAwF,MAAM,cAAc,CAAC;AACjM,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAuD,MAAM,YAAY,CAAC;AAC1G,OAAO,EAAE,YAAY,EAAE,kCAAkC,EAAE,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAE/B,MAAM,2BAA2B,CAAC;AAClH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAuC,MAAM,iBAAiB,CAAC;AACvH,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAC1C,MAAM,gBAAgB,CAAC;AAC7H,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAkBhF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAa,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,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C;oBAAE,IAAI,IAAI,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;wBACjF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;wBAAC,OAAO,GAAG,IAAI,CAAC;oBAChG,CAAC;gBACD,IAAI,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW;oBAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;gBACtE,OAAO,OAAO,CAAC;YACjB,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC;QAC/B,CAAC;QACD,KAAK,KAAW,MAAM,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE;YAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC5G,sFAAsF;QACtF,KAAK,CAAC,OAA8B;YAClC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE;gBAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACnI,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { workflowAuthorization } from './authorization.js';\nimport { advanceWorkflowNodes } from './node-batches.js';\nimport { workflowNodeLimit } from '@mayura/core';\nimport type { Authorizer } from '@mayura/core';\nimport { Budget, MayuraError, assertPositiveInteger, freezeJson, jsonValue, validate, type ExecutionReceipt, type JsonObject, type JsonValue, type Permissions, type Scope } from '@mayura/core';\nimport { invokeTool } from '@mayura/tools';\nimport { bindToolApproval } from '@mayura/tools/host';\nimport { abandoned, dispatchedAt } from './abandoned.js';\nimport { createWorkflowDrainGate, type WorkflowDrainOptions, type WorkflowDrainReport } from './drain.js';\nimport { StorageError, assertWorkflowStateMatchesManifest, workflowState, workflowOutputs, mergeWorkflowReceipt,\n type WorkflowFormat2State as State, type WorkflowFormat2Step as Step, type WorkflowFormat2StepStatus as StepStatus,\n type WorkflowFormat2Status as Status, type AggregateStore, type StoredRecord } from '@mayura/storage-contracts';\nimport { assertWorkflow, charged, digest, resolveBinding, type AnyWorkflow, type WorkflowNode } from './definition.js';\nimport { assertMigrationAllowed, assertWorkflowMigration, migrationCommand, migrationEvent, nodeEvidence, nodeFingerprint, planWorkflowMigration,\n type MigrationBlocker, type MigrationCommand, type WorkflowMigration, type WorkflowMigrationResult } from './migration.js';\nimport { scheduledManifest } from './scheduled-helpers.js';\nimport { createSubmission, workflowStorageFailure } from './storage-failure.js';\n\nexport interface WorkflowSnapshot {\n readonly id: string; readonly version: number; readonly status: Status;\n readonly steps: Readonly<Record<string, Readonly<Step>>>;\n readonly output: JsonValue;\n readonly budget: { readonly spentMicros: number; readonly reservedMicros: number; readonly maxCostMicros: number };\n}\nexport interface VerifiedHuman { readonly id: string; readonly projectId: string; readonly canApprove: boolean }\nexport interface WorkflowRuntimeOptions {\n readonly store: AggregateStore; readonly scope: Scope; readonly permissions: Permissions;\n /** Host-owned core authorizer; decisions and audit delivery use its existing limits and lifecycle. */\n readonly authorization?: Authorizer;\n readonly policyVersion: string; readonly maxCostMicros: number;\n readonly approvalTtlMs?: number; readonly maxOutputBytes?: number;\n /** Trusted identity boundary. Credentials are opaque to the workflow and never persisted. */\n readonly verifyHuman?: (credential: unknown) => Promise<VerifiedHuman>;\n}\nconst terminalSteps = new Set<StepStatus>(['succeeded', 'failed', 'blocked', 'unknown', 'skipped']);\n\n/** Bounds trusted async callbacks; it cannot terminate synchronous JavaScript or undo effects. */\nasync function bounded<T>(operation: () => Promise<T>, timeoutMs: number): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([Promise.resolve().then(operation), new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new MayuraError('TIMEOUT', 'Workflow validation or control operation timed out.')), timeoutMs);\n })]);\n } finally { if (timer) clearTimeout(timer); }\n}\n\nfunction stateFrom(record: StoredRecord): State {\n try { return workflowState(record); }\n catch { throw new MayuraError('CONFLICT', 'Stored workflow state failed integrity validation.'); }\n}\n\n/** External storage diagnostics never cross the workflow's public error boundary. */\nasync function storageCall<T>(operation: () => Promise<T>): Promise<T> {\n try { return await operation(); }\n catch (error) { throw workflowStorageFailure(error, 'workflow run'); }\n}\nfunction snapshot(record: StoredRecord): WorkflowSnapshot {\n const state = stateFrom(record);\n return freezeJson(jsonValue({ id: record.id, version: record.version, status: state.status, steps: state.steps, output: state.output, budget: { spentMicros: state.spentMicros, reservedMicros: state.reservedMicros, maxCostMicros: state.maxCostMicros } })) as unknown as WorkflowSnapshot;\n}\n\n/** Known evidence is monotonic; stale cancellation snapshots cannot turn success back into unknown. */\nfunction mergeReceipt(previous: ExecutionReceipt | null, incoming: ExecutionReceipt): ExecutionReceipt {\n try { return mergeWorkflowReceipt(previous, incoming); }\n catch { throw new MayuraError('CONFLICT', 'Conflicting known execution evidence requires reconciliation.'); }\n}\nfunction outputs(state: State): Record<string, JsonValue> {\n try { return workflowOutputs(state); }\n catch { throw new MayuraError('CONFLICT', 'Stored workflow output failed integrity validation.'); }\n}\nfunction initialState(definition: AnyWorkflow, input: JsonValue, policy: string, maxCostMicros: number): State {\n return { format: 2, ...(definition.maxNodes === undefined ? {} : { maxNodes: definition.maxNodes }), definition: definition.digest, policy, input, status: 'running', maxCostMicros, spentMicros: 0, reservedMicros: 0, output: null,\n steps: Object.fromEntries(definition.nodes.map(node => [node.id, { kind: node.kind, status: 'pending', callId: `step:${node.id}`, output: null, receipt: null, approval: null, costReserved: 0, candidateHash: null }])) };\n}\n\n/** Conservative durable DAG driver. No automatic replay/reclaim of dispatched effects. */\nexport function createWorkflowRuntime(options: WorkflowRuntimeOptions) {\n const { store } = options;\n const scope = Object.freeze({ principalId: options.scope.principalId, projectId: options.scope.projectId });\n if ([scope.principalId, scope.projectId, options.policyVersion].some(value => typeof value !== 'string' || !value.length || value.length > 128)) throw new MayuraError('INVALID_CONFIG', 'Workflow scope and policy version are required.');\n if (!Array.isArray(options.permissions?.allow) || options.permissions.allow.length > 4096 || options.permissions.allow.some(grant => typeof grant !== 'string' || !grant.length || grant.length > 256)) throw new MayuraError('INVALID_CONFIG', 'Workflow permissions must be bounded explicit grants.');\n const permissions = Object.freeze({ allow: Object.freeze([...options.permissions.allow]) });\n const maxCostMicros = options.maxCostMicros;\n if (!Number.isSafeInteger(maxCostMicros) || maxCostMicros < 0) throw new MayuraError('INVALID_CONFIG', 'A bounded workflow cost is required.');\n const approvalTtlMs = options.approvalTtlMs ?? 3_600_000;\n const maxOutputBytes = options.maxOutputBytes ?? 1_048_576;\n assertPositiveInteger(approvalTtlMs, 'approvalTtlMs'); assertPositiveInteger(maxOutputBytes, 'maxOutputBytes');\n const verifyHuman = options.verifyHuman;\n const auth = workflowAuthorization(options.authorization, scope);\n const scopeKey = digest('mayura:scope:v1', scope);\n const policy = digest('mayura:policy:v1', { scope, permissions: [...permissions.allow].sort(), policyVersion: options.policyVersion, maxCostMicros, maxOutputBytes, approvalTtlMs });\n const active = new Map<string, AbortController>();\n let closed = false; const gate = createWorkflowDrainGate();\n const ensureOpen = (): void => { if (closed) throw new MayuraError('CANCELLED', 'Workflow runtime is closed.'); };\n const load = async (id: string, allowClosed = false): Promise<StoredRecord> => {\n if (!allowClosed) ensureOpen();\n const record = await storageCall(() => store.read(scopeKey, id));\n if (!record) throw new MayuraError('NOT_FOUND', 'Workflow run was not found in this scope.');\n if (record.id !== id || record.scope !== scopeKey) throw new MayuraError('CONFLICT', 'Stored workflow identity does not match the requested scope.');\n stateFrom(record);\n return record;\n };\n const save = async (record: StoredRecord, state: State, type: string, data: JsonObject = {}): Promise<StoredRecord> =>\n storageCall(() => store.update({ scope: scopeKey, id: record.id, expectedVersion: record.version, state: jsonValue(state) as JsonObject, events: [{ type, data }] }));\n const mutate = async (id: string, update: (state: State) => boolean, type: string, data: JsonObject = {}, allowClosed = false): Promise<StoredRecord> => {\n for (let attempt = 0; attempt < 32; attempt++) {\n const record = await load(id, allowClosed); const state = stateFrom(record);\n if (!update(state)) return record;\n try { return await save(record, state, type, data); }\n catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n }\n throw new MayuraError('CONFLICT', 'Workflow contention exceeded the bounded retry limit.');\n };\n const candidate = (node: Extract<WorkflowNode, {kind:'tool'}>, input: JsonValue, runId: string, expiresAt: number | null): string =>\n digest('mayura:approval:v1', { runId, nodeId: node.id, tool: node.tool.id, toolVersion: node.tool.version, input, policy, expiresAt });\n\n async function executeNode(id: string, node: WorkflowNode, claimRetries = 0): Promise<void> {\n const record = await load(id); const state = stateFrom(record); const step = state.steps[node.id];\n await auth.execute(state.definition, id);\n // A first-wave read can finish after a predecessor settles and draining begins.\n // Such a node has not claimed an effect and must remain for the next worker.\n if (gate.draining || !step || state.policy !== policy || ['paused', 'cancelled'].includes(state.status)) return;\n // A dispatching step that no call in this process owns, past the tool's timeout and a margin, belongs to a process\n // that stopped: settle it as recoverAbandoned would, and never run the effect again.\n if (node.kind === 'tool' && step.status === 'dispatching') {\n if (active.has(`${id}/${node.id}`)) return;\n const dispatchedAtMs = await storageCall(() => dispatchedAt(store, scopeKey, id, 'step.dispatching', node.id));\n if (!abandoned(dispatchedAtMs, node.tool.timeoutMs, Date.now())) return;\n await mutate(id, current => {\n const target = current.steps[node.id];\n if (!target || target.status !== 'dispatching' || ['paused', 'cancelled'].includes(current.status) || active.has(`${id}/${node.id}`)) return false;\n target.status = target.receipt?.execution === 'succeeded' ? 'blocked' : 'unknown'; current.status = 'running'; return true;\n }, 'step.abandoned', { nodeId: node.id });\n return;\n }\n if (!['pending', 'approved'].includes(step.status)) return;\n const dependencies = (node.dependsOn ?? []).map(key => state.steps[key]!);\n if (dependencies.some(item => terminalSteps.has(item.status) && item.status !== 'succeeded')) {\n await mutate(id, current => { const next = current.steps[node.id]!; if (!['pending','approved'].includes(next.status)) return false; next.status = 'skipped'; return true; }, 'step.skipped', { nodeId: node.id }); return;\n }\n if (dependencies.some(item => item.status !== 'succeeded')) return;\n if (node.kind === 'join') {\n step.output = dependencies.map(item => item.output); step.status = 'succeeded';\n try { await save(record, state, 'step.completed', { nodeId: node.id }); } catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n const required = [`tool:${node.tool.id}`, ...node.tool.capabilities, ...(node.tool.effects === 'none' ? [] : [`effect:${node.tool.effects}`])];\n if (required.some(grant => !permissions.allow.includes(grant))) {\n step.status = 'blocked';\n try { await save(record, state, 'step.blocked', { nodeId: node.id, code: 'PERMISSION_DENIED' }); } catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n await auth.require('tool', node.tool.id, 'execute');\n let input: JsonValue;\n try { input = jsonValue(await bounded(() => validate(node.tool.input, resolveBinding(node.input, state.input, outputs(state)), 'input'), node.tool.timeoutMs), { maxBytes: maxOutputBytes }); }\n catch {\n step.status = 'failed';\n try { await save(record, state, 'step.failed', { nodeId: node.id, code: 'INVALID_INPUT' }); }\n catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n await auth.execute(state.definition, id);\n await auth.require('tool', node.tool.id, 'execute');\n const previousExpiry = step.approval?.expiresAt ?? 0;\n const reviewExpiry = node.approval ? (previousExpiry > Date.now() ? previousExpiry : Date.now() + approvalTtlMs) : null;\n const candidateHash = candidate(node, input, id, reviewExpiry);\n if (node.approval && (step.status !== 'approved' || step.approval?.digest !== candidateHash || step.approval.expiresAt <= Date.now())) {\n step.status = 'waiting'; step.approval = { digest: candidateHash, expiresAt: reviewExpiry!, humanId: null }; state.status = 'waiting';\n try { await save(record, state, 'approval.requested', { nodeId: node.id, digest: candidateHash }); } catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n if (node.tool.costMicros > state.maxCostMicros - state.spentMicros - state.reservedMicros) {\n step.status = 'blocked';\n try { await save(record, state, 'step.blocked', { nodeId: node.id, code: 'BUDGET_EXCEEDED' }); }\n catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; }\n return;\n }\n await auth.execute(state.definition, id);\n // Policy evaluation may yield after the earlier admission check. Linearize the\n // effect claim here; already-claimed work still drains through its receipt.\n if (gate.draining) return;\n step.status = 'dispatching'; step.candidateHash = candidateHash; step.costReserved = node.tool.costMicros;\n state.reservedMicros += node.tool.costMicros; state.status = 'running';\n try { await save(record, state, 'step.dispatching', { nodeId: node.id, callId: step.callId }); }\n catch (error) {\n // Retry the losing claim immediately: waiting for this wave would serialize independent handlers.\n // Every retry reloads permissions/candidate/budget state before crossing the dispatch boundary.\n if (error instanceof StorageError && error.storageCode === 'CONFLICT' && claimRetries < 32) return executeNode(id, node, claimRetries + 1);\n throw error;\n }\n const controller = new AbortController(); const activeKey = `${id}/${node.id}`; active.set(activeKey, controller);\n try {\n const raw = resolveBinding(node.input, state.input, outputs(state));\n // A step that needs approval reaches here only approved; the tool's own approval rule then accepts the call.\n const approvalBinding = node.approval ? bindToolApproval(node.tool, { runId: id, callId: `${id}/${step.callId}`, input: raw }) : undefined;\n const result = await invokeTool(node.tool, raw, {\n runId: id, callId: `${id}/${step.callId}`, scope, signal: controller.signal, permissions, ...(approvalBinding ? { approvalBinding } : {}),\n ...auth.toolContext(state.definition, id),\n budget: new Budget(node.tool.costMicros, 1), maxOutputBytes,\n beforeDispatch: async processed => {\n const current = stateFrom(await load(id));\n if (current.status !== 'running' || current.policy !== policy || current.steps[node.id]?.status !== 'dispatching' || candidate(node, processed, id, node.approval ? current.steps[node.id]!.approval!.expiresAt : null) !== candidateHash) {\n throw new MayuraError('CONFLICT', 'Workflow dispatch candidate is no longer authorized.');\n }\n if (node.approval && (current.steps[node.id]?.approval?.expiresAt ?? 0) <= Date.now()) throw new MayuraError('PERMISSION_DENIED', 'Approval expired before dispatch.');\n },\n onExecutionReceipt: async (receipt, settlement) => {\n await mutate(id, current => {\n const target = current.steps[node.id]!;\n // Retain late evidence but do not turn an operator-recovered unknown step back into success.\n target.receipt = mergeReceipt(target.receipt, receipt);\n if (receipt.execution !== 'unknown' && target.costReserved > 0) {\n current.reservedMicros -= target.costReserved;\n // Charge the reported usage (known plus unknown), capped at the reservation.\n if (receipt.execution !== 'not_started') current.spentMicros += charged(settlement, target.costReserved);\n target.costReserved = 0;\n }\n return true;\n }, 'effect.receipt', { nodeId: node.id, execution: receipt.execution }, true);\n },\n });\n await mutate(id, current => {\n const target = current.steps[node.id]!;\n if (target.status !== 'dispatching') return false;\n if (result.receipt) target.receipt = mergeReceipt(target.receipt, result.receipt);\n if (result.status === 'succeeded') { target.status = 'succeeded'; target.output = jsonValue(result.output, { maxBytes: maxOutputBytes }); }\n else target.status = result.status === 'outcome_unknown' ? 'unknown' : result.status === 'blocked' ? 'blocked' : 'failed';\n if (result.receipt?.execution === 'not_started' && target.costReserved > 0) { current.reservedMicros -= target.costReserved; target.costReserved = 0; }\n return true;\n }, 'step.completed', { nodeId: node.id, outcome: result.status });\n } finally { active.delete(activeKey); }\n }\n\n return {\n async submit<D extends AnyWorkflow>(definition: D, command: { input: unknown; idempotencyKey: string }): Promise<WorkflowSnapshot> {\n ensureOpen();\n assertWorkflow(definition);\n const idempotencyKey = command.idempotencyKey;\n if (typeof idempotencyKey !== 'string' || !idempotencyKey.length || idempotencyKey.length > 128) throw new MayuraError('INVALID_INPUT', 'A bounded submission key is required.');\n const admittedId = digest('mayura:run-id:v1', { scope: scopeKey, submissionKey: idempotencyKey });\n const inputSnapshot = freezeJson(jsonValue(command.input, { maxBytes: maxOutputBytes }));\n await auth.execute(definition.digest, admittedId);\n const input = jsonValue(await bounded(() => validate(definition.input, inputSnapshot, 'input'), 30_000), { maxBytes: maxOutputBytes });\n const state = initialState(definition, input, policy, maxCostMicros);\n const id = digest('mayura:run-id:v1', { scope: scopeKey, submissionKey: idempotencyKey });\n await auth.execute(definition.digest, id);\n const created = await createSubmission(() => store.create({ scope: scopeKey, id, idempotencyKey, definitionHash: definition.digest, state: jsonValue(state) as JsonObject, events: [{ type: 'run.created', data: {} }] }), 'workflow run');\n return snapshot(created.record);\n },\n inspect: async (id: string): Promise<WorkflowSnapshot> => snapshot(await load(id)),\n events: (id: string, after = 0) => { ensureOpen(); return storageCall(() => store.events(scopeKey, id, after)); },\n async runUntilSettled(definition: AnyWorkflow, id: string): Promise<WorkflowSnapshot> {\n const checkedSnapshot = async (record: StoredRecord) => { await auth.execute(definition.digest, id); return snapshot(record); };\n\n ensureOpen(); if (gate.draining) throw new MayuraError('CANCELLED', 'Workflow runtime is draining.');\n assertWorkflow(definition);\n await auth.execute(definition.digest, id);\n for (let wave = 0; wave <= definition.nodes.length + 1; wave++) {\n await auth.execute(definition.digest, id);\n const before = await load(id); const state = stateFrom(before);\n if (state.definition !== definition.digest || before.definitionHash !== definition.digest || state.policy !== policy || state.maxCostMicros !== maxCostMicros) throw new MayuraError('CONFLICT', 'Definition or policy changed; explicit migration/review is required.');\n if (workflowNodeLimit(state.maxNodes) !== workflowNodeLimit(definition.maxNodes) || Object.keys(state.steps).length !== definition.nodes.length || definition.nodes.some(node => !Object.hasOwn(state.steps, node.id))) throw new MayuraError('CONFLICT', 'Stored steps do not match the pinned definition.');\n for (const node of definition.nodes) {\n const step = state.steps[node.id]!;\n if (step.kind !== node.kind || (node.kind === 'tool' && step.receipt && step.receipt.toolId !== node.tool.id) || (step.status === 'succeeded' && (node.dependsOn ?? []).some(dependency => state.steps[dependency]?.status !== 'succeeded'))) throw new MayuraError('CONFLICT', 'Stored step evidence does not match the pinned graph.');\n }\n if (state.status === 'paused' || state.status === 'cancelled' || ['succeeded','failed','blocked','outcome_unknown'].includes(state.status)) return checkedSnapshot(before);\n // Each wave holds one drain admission until its effects and receipts settle.\n const release = gate.enter(); if (!release) return checkedSnapshot(before);\n try {\n await advanceWorkflowNodes(definition.nodes.filter(node => !terminalSteps.has(state.steps[node.id]!.status)), node => executeNode(id, node));\n } finally { release(); }\n let after = await load(id); const next = stateFrom(after); const steps = Object.values(next.steps);\n if (next.status === 'paused' || next.status === 'cancelled') return checkedSnapshot(after);\n if (steps.every(item => terminalSteps.has(item.status))) {\n if (steps.every(item => item.status === 'succeeded')) {\n try { next.output = jsonValue(await bounded(() => validate(definition.output, resolveBinding(definition.result, next.input, outputs(next)), 'output'), 30_000), { maxBytes: maxOutputBytes }); next.status = 'succeeded'; }\n catch { next.status = 'failed'; }\n } else next.status = steps.some(item => item.status === 'unknown') ? 'outcome_unknown' : steps.some(item => item.status === 'blocked') ? 'blocked' : 'failed';\n await auth.execute(definition.digest, id);\n try { after = await save(after, next, 'run.completed', { status: next.status }); }\n catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; after = await load(id); }\n return checkedSnapshot(after);\n }\n if (after.version === before.version) {\n if (steps.some(item => item.status === 'waiting') && !steps.some(item => item.status === 'dispatching') && next.status !== 'waiting') {\n next.status = 'waiting';\n try { after = await save(after, next, 'run.waiting'); } catch (error) { if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT') throw error; after = await load(id); }\n }\n return checkedSnapshot(after);\n }\n }\n return checkedSnapshot(await load(id));\n },\n async approve(command: { id: string; nodeId: string; digest: string; credential: unknown }): Promise<WorkflowSnapshot> {\n ensureOpen();\n const { id, nodeId, digest: approvalDigest, credential } = command;\n await auth.require('run', id, 'approve');\n if (typeof id !== 'string' || !/^[a-f0-9]{64}$/.test(id) || typeof nodeId !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(nodeId) || typeof approvalDigest !== 'string' || !/^[a-f0-9]{64}$/.test(approvalDigest)) throw new MayuraError('INVALID_INPUT', 'Approval requires exact run, node and candidate identifiers.');\n if (!verifyHuman) throw new MayuraError('PERMISSION_DENIED', 'A trusted human identity verifier is required.');\n let human: VerifiedHuman;\n try {\n const verified = await bounded(() => verifyHuman(credential), 30_000);\n human = { id: verified.id, projectId: verified.projectId, canApprove: verified.canApprove };\n if (typeof human.id !== 'string' || !human.id.length || human.id.length > 256 || human.projectId !== scope.projectId || human.canApprove !== true) throw new Error();\n } catch { throw new MayuraError('PERMISSION_DENIED', 'Human identity verification failed.'); }\n await auth.require('run', id, 'approve');\n return snapshot(await mutate(id, state => {\n const step = state.steps[nodeId];\n if (state.status === 'cancelled' || state.policy !== policy || !step || step.status !== 'waiting' || !step.approval || step.approval.digest !== approvalDigest || step.approval.expiresAt <= Date.now()) throw new MayuraError('CONFLICT', 'Approval request is stale, expired or mismatched.');\n step.approval.humanId = human.id; step.status = 'approved'; if (state.status !== 'paused') state.status = 'running'; return true;\n }, 'approval.resolved', { nodeId, humanId: human.id }));\n },\n /** Persist a quiescent operator pause. In-flight effects must settle or reconcile first. */\n async pause(id: string): Promise<WorkflowSnapshot> {\n return snapshot(await mutate(id, state => {\n if (state.status === 'paused') return false;\n if (['succeeded','failed','blocked','outcome_unknown','cancelled'].includes(state.status)) {\n throw new MayuraError('CONFLICT', 'A terminal workflow cannot be paused.');\n }\n if (Object.values(state.steps).some(step => step.status === 'dispatching')) {\n throw new MayuraError('CONFLICT', 'A workflow with an in-flight effect cannot enter the quiescent paused state.');\n }\n state.status = 'paused'; return true;\n }, 'run.paused'));\n },\n /**\n * Plan (dryRun) or apply a reviewed migration of a paused run to a new definition version. The run stays paused;\n * resume it after review. Waiting approvals of unchanged steps stay valid (their digest does not bind the version).\n */\n async migrate(migration: WorkflowMigration<AnyWorkflow, AnyWorkflow>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowSnapshot>> {\n ensureOpen(); assertWorkflowMigration(migration); assertWorkflow(migration.from); assertWorkflow(migration.to);\n const { id, actorId, commandId, dryRun = false } = migrationCommand(command);\n const record = await load(id); const state = stateFrom(record);\n if (state.definition !== migration.from.digest || record.definitionHash !== migration.from.digest || state.policy !== policy || state.maxCostMicros !== maxCostMicros) {\n throw new MayuraError('CONFLICT', 'The run is not pinned to the migration source definition and this policy.');\n }\n const nodes = (definition: AnyWorkflow) => scheduledManifest(definition).graph.map(node =>\n ({ id: node.id, kind: node.kind, dependsOn: node.dependsOn, fingerprint: nodeFingerprint(node as unknown as Record<string, unknown>),\n ...(nodeEvidence(node) ? { evidence: nodeEvidence(node)! } : {}) }));\n const preconditions: MigrationBlocker[] = [];\n if (state.status !== 'paused') preconditions.push({ node: '*', reason: `The run is ${state.status}; pause it before migrating.` });\n const plan = planWorkflowMigration({ migration, format: 'workflow-v2', runId: id, fromDigest: migration.from.digest, toDigest: migration.to.digest,\n from: nodes(migration.from), to: nodes(migration.to), steps: Object.entries(state.steps).map(([step, value]) => ({ id: step, status: value.status })), preconditions });\n if (dryRun) return freezeJson(jsonValue({ plan })) as unknown as WorkflowMigrationResult<WorkflowSnapshot>;\n assertMigrationAllowed(plan);\n const fresh = initialState(migration.to, state.input, policy, maxCostMicros);\n const carried: Record<string, Step> = {};\n for (const entry of plan.entries) if (entry.target) carried[entry.target] = entry.action === 'keep' || entry.action === 'accept' ? state.steps[entry.source!]! : fresh.steps[entry.target]!;\n const next: State = { ...state, maxNodes: migration.to.maxNodes === false ? false : workflowNodeLimit(migration.to.maxNodes), definition: migration.to.digest, steps: Object.fromEntries(migration.to.nodes.map(node => [node.id, carried[node.id]!])) };\n next.reservedMicros = Object.values(next.steps).reduce((sum, step) => sum + step.costReserved, 0);\n try { assertWorkflowStateMatchesManifest(workflowState({ id, state: jsonValue(next) as JsonObject }), scheduledManifest(migration.to)); }\n catch { throw new MayuraError('CONFLICT', 'Migration refused: the migrated state does not satisfy the new definition.'); }\n if (typeof store.migrate !== 'function') throw new MayuraError('UNSUPPORTED_PROFILE', 'This store cannot migrate in-flight workflow runs.');\n const migrated = await storageCall(() => store.migrate!({ scope: scopeKey, id, expectedVersion: record.version, expectedDefinitionHash: migration.from.digest,\n definitionHash: migration.to.digest, state: jsonValue(next) as JsonObject, events: [migrationEvent(plan, actorId, commandId) as { type: string; data: JsonObject }] }));\n return freezeJson(jsonValue({ plan, snapshot: snapshot(migrated) })) as unknown as WorkflowMigrationResult<WorkflowSnapshot>;\n },\n /** Resume scheduling only; unresolved waits remain waiting and grant no authority. */\n async resume(id: string): Promise<WorkflowSnapshot> {\n await auth.require('run', id, 'resume');\n return snapshot(await mutate(id, state => {\n if (state.status !== 'paused') throw new MayuraError('CONFLICT', 'Only a paused workflow can be resumed.');\n state.status = Object.values(state.steps).some(step => step.status === 'waiting') ? 'waiting' : 'running'; return true;\n }, 'run.resumed'));\n },\n async cancel(id: string): Promise<WorkflowSnapshot> {\n const record = await mutate(id, state => { if (['succeeded','failed','blocked','outcome_unknown','cancelled'].includes(state.status)) return false; state.status = 'cancelled'; return true; }, 'run.cancelled');\n for (const [key, controller] of active) if (key.startsWith(`${id}/`)) controller.abort();\n return snapshot(record);\n },\n /** Trusted operator action after establishing worker abandonment; never redispatches effects. */\n async recoverAbandoned(id: string): Promise<WorkflowSnapshot> {\n return snapshot(await mutate(id, state => {\n let changed = false;\n for (const step of Object.values(state.steps)) if (step.status === 'dispatching') {\n step.status = step.receipt?.execution === 'succeeded' ? 'blocked' : 'unknown'; changed = true;\n }\n if (changed && state.status !== 'cancelled') state.status = 'running';\n return changed;\n }, 'run.recovery_required'));\n },\n close(): void { closed = true; auth.close(); for (const controller of active.values()) controller.abort(); },\n /** Admit no new wave, let admitted effects settle within the deadline, then close. */\n drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport> {\n return gate.drain(options, () => { closed = true; auth.close(); for (const controller of active.values()) controller.abort(); });\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduled-helpers.d.ts","sourceRoot":"","sources":["../src/scheduled-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scheduled-helpers.d.ts","sourceRoot":"","sources":["../src/scheduled-helpers.ts"],"names":[],"mappings":"AACA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AAA;CAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,EAAE,CAY7N;AAED,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAE3J,kGAAkG;AAClG,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,mBAAmB,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAiC,GAAG,CAAC,CAWvK;AAED,uGAAuG;AACvG,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAYhF;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAG3G"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { workflowNodeLimit } from '../../core/dist/index.js';
|
|
1
2
|
import { freezeJson, jsonValue, MayuraError } from '../../core/dist/index.js';
|
|
2
3
|
import { StorageError, workflowManifest, workflowState, workflowGraphState, } from '../../storage-contracts/dist/index.js';
|
|
3
4
|
// Only this module's deep-owned, fully validated views may enter these caches. In
|
|
@@ -67,7 +68,7 @@ export async function scheduledCallback(operation, timeoutMs, signal) {
|
|
|
67
68
|
}
|
|
68
69
|
/** Construct the original data-only definition material without changing its version hash. */
|
|
69
70
|
export function scheduledManifest(definition) {
|
|
70
|
-
return workflowManifest({ id: definition.id, version: definition.version,
|
|
71
|
+
return workflowManifest({ id: definition.id, version: definition.version, ...(definition.maxNodes === undefined ? {} : { maxNodes: definition.maxNodes }),
|
|
71
72
|
graph: definition.nodes.map(node => node.kind === 'join'
|
|
72
73
|
? { id: node.id, kind: node.kind, dependsOn: node.dependsOn }
|
|
73
74
|
: { id: node.id, kind: node.kind, dependsOn: node.dependsOn ?? [], tool: node.tool.id,
|
|
@@ -102,7 +103,7 @@ function checkOwnedView(view, scope, id, policyHash, profile) {
|
|
|
102
103
|
if (ownedViews.has(view))
|
|
103
104
|
return view;
|
|
104
105
|
if (!Array.isArray(view.jobs)
|
|
105
|
-
|| view.jobs.length >
|
|
106
|
+
|| view.jobs.length > workflowNodeLimit(view.record.state['maxNodes']) || !Number.isSafeInteger(view.record.version) || view.record.version < 1
|
|
106
107
|
|| !/^[a-f0-9]{64}$/.test(view.manifestHash) || !/^[a-f0-9]{64}$/.test(view.resourceHash)
|
|
107
108
|
|| view.record.definitionHash !== view.manifestHash)
|
|
108
109
|
throw new Error();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduled-helpers.js","sourceRoot":"","sources":["../src/scheduled-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAkB,MAAM,cAAc,CAAC;AAClF,OAAO,EACL,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,kBAAkB,GAGlE,MAAM,2BAA2B,CAAC;AAUnC,kFAAkF;AAClF,gFAAgF;AAChF,MAAM,UAAU,GAAG,IAAI,OAAO,EAAU,CAAC;AACzC,MAAM,WAAW,GAAG,IAAI,OAAO,EAAwF,CAAC;AAExH,4FAA4F;AAC5F,MAAM,UAAU,cAAc,CAAC,MAAoB,EAAE,OAAyB;IAC5E,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,KAAK,EAAE,OAAO,KAAK,OA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QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG;mBAC1J,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,MAAM,IAAI,KAAK,EAAE,CAAC;YAC3L,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QAAC,MAAM,IAAI,WAAW,CAAC,qBAAqB,EAAE,mDAAmD,CAAC,CAAC;IAAC,CAAC;AAChH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,QAAgB,EAAE,QAA4B;IAC9F,IAAI,CAAC;QAAC,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAAC,CAAC;IAC1D,MAAM,CAAC;QAAC,MAAM,IAAI,WAAW,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,EAAE,mDAAmD,CAAC,CAAC;IAAC,CAAC;AAClJ,CAAC","sourcesContent":["import { freezeJson, jsonValue, MayuraError, type JsonValue } from '@mayura/core';\nimport {\n StorageError, workflowManifest, workflowState, workflowGraphState,\n type Claim, type JobRecord, type ScheduledWorkflowSnapshot, type StorageErrorCode, type StoredEvent, type StoredRecord, type WorkflowManifest,\n type WorkflowGraphStoreSnapshot,\n} from '@mayura/storage-contracts';\nimport type { AnyWorkflow } from './definition.js';\nimport type { WorkflowSnapshot } from './runtime.js';\nimport type { WorkflowGraphSnapshot } from './graphs.js';\n\nexport type ScheduledProfile = 'scheduled-v1' | 'scheduled-v2';\nexport type ScheduledStoredSnapshot = ScheduledWorkflowSnapshot | WorkflowGraphStoreSnapshot;\nexport type ScheduledPublicSnapshot = WorkflowSnapshot | WorkflowGraphSnapshot;\n\ntype ScheduledState = ReturnType<typeof workflowState> | ReturnType<typeof workflowGraphState>;\n// Only this module's deep-owned, fully validated views may enter these caches. In\n// particular, neither adapter object identity nor Object.isFrozen grants trust.\nconst ownedViews = new WeakSet<object>();\nconst ownedStates = new WeakMap<StoredRecord, { readonly profile: ScheduledProfile; readonly state: ScheduledState }>();\n\n/** Select an exact profile decoder. Legacy validators never learn new-format acceptance. */\nexport function scheduledState(record: StoredRecord, profile: ScheduledProfile) {\n const known = ownedStates.get(record);\n if (known?.profile === profile) return known.state;\n return profile === 'scheduled-v1' ? workflowState(record) : workflowGraphState(record);\n}\n\nconst storageCodes = new Set<StorageErrorCode>(['INVALID_INPUT', 'CONFLICT', 'NOT_FOUND', 'STORAGE_UNAVAILABLE',\n 'STORE_CLOSED', 'STORE_NOT_INITIALIZED', 'QUEUE_FULL', 'STALE_CLAIM', 'LIMIT_EXCEEDED', 'SCHEDULED_WRITER_REQUIRED']);\n\n/** Preserve only stable storage codes; never copy adapter messages or inspect exception getters. */\n/** Fixed storage answer when an approval expired before admission: final for that call, and a new review is needed. */\nexport const reviewExpiredMessage = 'The approval expired; request a new review before admission.';\nexport const isReviewExpired = (error: unknown): boolean => error instanceof StorageError && error.storageCode === 'CONFLICT' && error.message === reviewExpiredMessage;\nexport async function scheduledStorage<T>(operation: () => Promise<T>, timeoutMs = 10_000, signal?: AbortSignal): Promise<T> {\n try { return await scheduledCallback(operation, timeoutMs, signal ?? new AbortController().signal); }\n catch (error) {\n let code: StorageErrorCode = 'STORAGE_UNAVAILABLE'; let refusal: string | undefined;\n try {\n const own = error instanceof StorageError ? Object.getOwnPropertyDescriptor(error, 'storageCode') : undefined;\n if (own && 'value' in own && storageCodes.has(own.value as StorageErrorCode)) code = own.value as StorageErrorCode;\n // A migration refusal is fixed storage text plus step ids; it is the reviewer's answer, so it is kept verbatim.\n const message = error instanceof StorageError ? Object.getOwnPropertyDescriptor(error, 'message') : undefined;\n if (code === 'CONFLICT' && message && 'value' in message && typeof message.value === 'string'\n && (/^Migration refused: [A-Za-z0-9 .,;:\"'()_-]{1,240}$/.test(message.value) || message.value === reviewExpiredMessage)) refusal = message.value;\n } catch { /* Exception proxies do not become public diagnostics. */ }\n throw new StorageError(code, refusal ?? 'Scheduled persistence could not confirm the requested transition. Inspect current state before retrying effects.');\n }\n}\n\nexport function isStorageCode(error: unknown, code: StorageErrorCode): boolean {\n return error instanceof StorageError && error.storageCode === code;\n}\n\n/** One bounded callback window. Late results/rejections are handled without further admission. */\nexport async function scheduledCallback<T>(operation: () => T | PromiseLike<T>, timeoutMs: number, signal: AbortSignal): Promise<T> {\n if (signal.aborted) throw new MayuraError('CANCELLED', 'The scheduled worker is closing.');\n return await new Promise<T>((resolve, reject) => {\n let finished = false;\n const clear = (): void => { clearTimeout(timer); signal.removeEventListener('abort', abort); };\n const end = (action: () => void): void => { if (!finished) { finished = true; clear(); action(); } };\n const abort = (): void => { end(() => reject(new MayuraError('CANCELLED', 'The scheduled operation was cancelled.'))); };\n const timer = setTimeout(() => { end(() => reject(new MayuraError('TIMEOUT', 'The scheduled callback exceeded its deadline.'))); }, timeoutMs);\n signal.addEventListener('abort', abort, { once: true });\n Promise.resolve().then(() => {\n if (signal.aborted) throw new MayuraError('CANCELLED', 'The scheduled operation was cancelled.');\n return operation();\n }).then(value => { end(() => resolve(value)); }, (error: unknown) => { end(() => reject(error)); });\n if (signal.aborted) abort();\n });\n}\n\n/** Construct the original data-only definition material without changing its version hash. */\nexport function scheduledManifest(definition: AnyWorkflow): WorkflowManifest {\n return workflowManifest({ id: definition.id, version: definition.version,\n graph: definition.nodes.map(node => node.kind === 'join'\n ? { id: node.id, kind: node.kind, dependsOn: node.dependsOn }\n : { id: node.id, kind: node.kind, dependsOn: node.dependsOn ?? [], tool: node.tool.id,\n toolVersion: node.tool.version, effects: node.tool.effects, capabilities: node.tool.capabilities,\n costMicros: node.tool.costMicros, approval: node.approval ?? false, input: node.input }),\n result: definition.result,\n });\n}\n\n/** Public workflow views retain effect/accounting truth without exposing persisted input. */\nexport function scheduledSnapshot(record: StoredRecord): WorkflowSnapshot;\nexport function scheduledSnapshot(record: StoredRecord, profile: ScheduledProfile): ScheduledPublicSnapshot;\nexport function scheduledSnapshot(record: StoredRecord, profile: ScheduledProfile = 'scheduled-v1'): ScheduledPublicSnapshot {\n const state = scheduledState(record, profile);\n return freezeJson(jsonValue({ id: record.id, version: record.version, status: state.status, steps: state.steps,\n output: state.output, budget: { spentMicros: state.spentMicros, reservedMicros: state.reservedMicros, maxCostMicros: state.maxCostMicros },\n })) as unknown as ScheduledPublicSnapshot;\n}\n\n/** Snapshot an adapter-owned response before using it for a later decision. */\nexport function scheduledView(raw: ScheduledWorkflowSnapshot, scope: string, id: string, policyHash: string): ScheduledWorkflowSnapshot;\nexport function scheduledView(raw: ScheduledStoredSnapshot, scope: string, id: string, policyHash: string, profile: ScheduledProfile): ScheduledStoredSnapshot;\nexport function scheduledView(raw: ScheduledStoredSnapshot, scope: string, id: string, policyHash: string, profile: ScheduledProfile = 'scheduled-v1'): ScheduledStoredSnapshot {\n try {\n const view = ownedViews.has(raw) ? raw\n : freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 })) as unknown as ScheduledStoredSnapshot;\n return checkOwnedView(view, scope, id, policyHash, profile);\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled state failed identity or integrity validation.'); }\n}\n\n/** Call only with JSON already copied and recursively frozen by this module. */\nfunction checkOwnedView(view: ScheduledStoredSnapshot, scope: string, id: string, policyHash: string, profile: ScheduledProfile): ScheduledStoredSnapshot {\n if (view.profile !== profile || view.record.scope !== scope || view.record.id !== id\n || view.policyHash !== policyHash || view.record.state['policy'] !== policyHash) throw new Error();\n // Requested authority is checked even for internal reuse; immutable structural\n // checks and decoding need happen only once for this exact owned snapshot.\n if (ownedViews.has(view)) return view;\n if (!Array.isArray(view.jobs)\n || view.jobs.length > 128 || !Number.isSafeInteger(view.record.version) || view.record.version < 1\n || !/^[a-f0-9]{64}$/.test(view.manifestHash) || !/^[a-f0-9]{64}$/.test(view.resourceHash)\n || view.record.definitionHash !== view.manifestHash) throw new Error();\n const state = scheduledState(view.record, profile);\n if (state.definition !== view.manifestHash || new Set(view.jobs.map(job => job.jobId)).size !== view.jobs.length\n || new Set(view.jobs.map(job => job.nodeId)).size !== view.jobs.length) throw new Error();\n for (const job of view.jobs) {\n checkJob(job, scope, id);\n const step = state.steps[job.nodeId];\n if (!step || step.kind !== 'tool' || step.candidateHash !== job.candidateHash) throw new Error();\n }\n freezeJson(state as unknown as JsonValue);\n ownedStates.set(view.record, { profile, state }); ownedViews.add(view);\n return view;\n}\n\n/** Own the complete submission acknowledgement before accessing nested adapter-owned data. */\nexport function scheduledSubmission(raw: unknown): { readonly snapshot: ScheduledStoredSnapshot; readonly created: boolean } {\n try {\n const value = freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 }));\n if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).length !== 2\n || !Object.hasOwn(value, 'snapshot') || typeof value['created'] !== 'boolean') throw new Error();\n return value as unknown as { readonly snapshot: ScheduledStoredSnapshot; readonly created: boolean };\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled submission response failed integrity validation.'); }\n}\n\n/** Structural response checks supplement, not replace, the adapter's transactional integrity checks. */\nfunction checkJob(job: JobRecord, scope: string, id: string): void {\n if (job.scope !== scope || job.runId !== id || typeof job.jobId !== 'string' || !job.jobId.length || job.jobId.length > 256\n || typeof job.nodeId !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(job.nodeId)\n || !/^[a-f0-9]{64}$/.test(job.candidateHash) || !/^[a-f0-9]{64}$/.test(job.definitionHash)\n || !Number.isSafeInteger(job.version) || job.version < 1 || !Number.isSafeInteger(job.fence) || job.fence < 0\n || !['ready', 'leased', 'started', 'succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown'].includes(job.state)\n || !job.intent || typeof job.intent !== 'object' || Array.isArray(job.intent)\n || !Array.isArray(job.resourceKeys) || job.resourceKeys.length > 32 || job.resourceKeys.some(key => typeof key !== 'string')\n || typeof job.leaseRevoked !== 'boolean' || typeof job.cancelRequested !== 'boolean') throw new Error();\n for (const value of [job.leaseUntilMs, job.startedAtMs, job.deadlineAtMs]) {\n if (value !== null && (!Number.isSafeInteger(value) || value < 0)) throw new Error();\n }\n}\n\n/** Renewal responses cannot change the identity of an admitted local execution. */\nexport function scheduledClaim(raw: Claim, expected: Pick<Claim, 'scope' | 'jobId' | 'workerId' | 'fence'>): Claim {\n try {\n const claim = freezeJson(jsonValue(raw, { maxBytes: 2_048 })) as unknown as Claim;\n if (claim.scope !== expected.scope || claim.jobId !== expected.jobId || claim.workerId !== expected.workerId || claim.fence !== expected.fence\n || !Number.isSafeInteger(claim.fence) || claim.fence < 1 || !Number.isSafeInteger(claim.leaseUntilMs) || claim.leaseUntilMs < 1) throw new Error();\n return claim;\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled claim failed identity or integrity validation.'); }\n}\n\n/** Bound and snapshot a claim batch before reserving local executor slots or invoking any tool. */\nexport function scheduledClaims(raw: readonly { readonly job: JobRecord; readonly claim: Claim }[], scope: string, id: string, workerId: string, limit: number): readonly { readonly job: JobRecord; readonly claim: Claim }[] {\n try {\n const values = freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 })) as unknown as typeof raw;\n if (!Array.isArray(values) || values.length > limit || new Set(values.map(value => value.job.jobId)).size !== values.length) throw new Error();\n for (const value of values) {\n checkJob(value.job, scope, id);\n scheduledClaim(value.claim, { scope, jobId: value.job.jobId, workerId, fence: value.job.fence });\n if (value.job.state !== 'leased' || value.job.workerId !== workerId || value.job.leaseUntilMs !== value.claim.leaseUntilMs\n || value.job.leaseRevoked || value.job.cancelRequested || value.job.startedAtMs !== null) throw new Error();\n }\n return values;\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled claim batch failed integrity validation.'); }\n}\n\nexport type ScheduledTransition = ScheduledStoredSnapshot | { readonly status: 'started' | 'already_started'; readonly snapshot: ScheduledStoredSnapshot };\n\n/** Every mutation response crosses the same identity boundary as an ordinary inspect response. */\nexport function scheduledTransition<T extends ScheduledTransition>(raw: T, scope: string, id: string, policyHash: string, profile: ScheduledProfile = 'scheduled-v1'): T {\n try {\n if (ownedViews.has(raw)) return scheduledView(raw as ScheduledStoredSnapshot, scope, id, policyHash, profile) as T;\n const value = freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 })) as unknown as T;\n if ('snapshot' in value) {\n if (value.status !== 'started' && value.status !== 'already_started') throw new Error();\n const snapshot = checkOwnedView(value.snapshot, scope, id, policyHash, profile);\n return Object.freeze({ ...value, snapshot }) as T;\n }\n return checkOwnedView(value, scope, id, policyHash, profile) as T;\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled transition response failed identity or integrity validation.'); }\n}\n\n/** Validate bounded canonical event pages; no adapter getters or malformed sequences reach callers. */\nexport function scheduledEvents(raw: StoredEvent[], after: number): StoredEvent[] {\n try {\n const events = freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 })) as unknown as StoredEvent[];\n if (!Array.isArray(events) || events.length > 1_000) throw new Error();\n let previous = after;\n for (const event of events) {\n if (!Number.isSafeInteger(event.sequence) || event.sequence !== previous + 1 || typeof event.type !== 'string' || !event.type.length || event.type.length > 128\n || typeof event.createdAt !== 'string' || !Number.isFinite(Date.parse(event.createdAt)) || !event.data || typeof event.data !== 'object' || Array.isArray(event.data)) throw new Error();\n previous = event.sequence;\n }\n return events;\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled event page failed integrity validation.'); }\n}\n\nexport function safeScheduledJson(value: unknown, maxBytes: number, boundary: 'input' | 'output'): JsonValue {\n try { return freezeJson(jsonValue(value, { maxBytes })); }\n catch { throw new MayuraError(boundary === 'input' ? 'INVALID_INPUT' : 'INVALID_OUTPUT', 'Scheduled data exceeds its bounded JSON boundary.'); }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scheduled-helpers.js","sourceRoot":"","sources":["../src/scheduled-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAkB,MAAM,cAAc,CAAC;AAClF,OAAO,EACL,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,kBAAkB,GAGlE,MAAM,2BAA2B,CAAC;AAUnC,kFAAkF;AAClF,gFAAgF;AAChF,MAAM,UAAU,GAAG,IAAI,OAAO,EAAU,CAAC;AACzC,MAAM,WAAW,GAAG,IAAI,OAAO,EAAwF,CAAC;AAExH,4FAA4F;AAC5F,MAAM,UAAU,cAAc,CAAC,MAAoB,EAAE,OAAyB;IAC5E,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,KAAK,EAAE,OAAO,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC;IACnD,OAAO,OAAO,KAAK,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAmB,CAAC,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,qBAAqB;IAC7G,cAAc,EAAE,uBAAuB,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,2BAA2B,CAAC,CAAC,CAAC;AAExH,oGAAoG;AACpG,uHAAuH;AACvH,MAAM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AAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,MAAM,IAAI,KAAK,EAAE,CAAC;YAC3L,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QAAC,MAAM,IAAI,WAAW,CAAC,qBAAqB,EAAE,mDAAmD,CAAC,CAAC;IAAC,CAAC;AAChH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,QAAgB,EAAE,QAA4B;IAC9F,IAAI,CAAC;QAAC,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAAC,CAAC;IAC1D,MAAM,CAAC;QAAC,MAAM,IAAI,WAAW,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,EAAE,mDAAmD,CAAC,CAAC;IAAC,CAAC;AAClJ,CAAC","sourcesContent":["import { workflowNodeLimit } from '@mayura/core';\nimport { freezeJson, jsonValue, MayuraError, type JsonValue } from '@mayura/core';\nimport {\n StorageError, workflowManifest, workflowState, workflowGraphState,\n type Claim, type JobRecord, type ScheduledWorkflowSnapshot, type StorageErrorCode, type StoredEvent, type StoredRecord, type WorkflowManifest,\n type WorkflowGraphStoreSnapshot,\n} from '@mayura/storage-contracts';\nimport type { AnyWorkflow } from './definition.js';\nimport type { WorkflowSnapshot } from './runtime.js';\nimport type { WorkflowGraphSnapshot } from './graphs.js';\n\nexport type ScheduledProfile = 'scheduled-v1' | 'scheduled-v2';\nexport type ScheduledStoredSnapshot = ScheduledWorkflowSnapshot | WorkflowGraphStoreSnapshot;\nexport type ScheduledPublicSnapshot = WorkflowSnapshot | WorkflowGraphSnapshot;\n\ntype ScheduledState = ReturnType<typeof workflowState> | ReturnType<typeof workflowGraphState>;\n// Only this module's deep-owned, fully validated views may enter these caches. In\n// particular, neither adapter object identity nor Object.isFrozen grants trust.\nconst ownedViews = new WeakSet<object>();\nconst ownedStates = new WeakMap<StoredRecord, { readonly profile: ScheduledProfile; readonly state: ScheduledState }>();\n\n/** Select an exact profile decoder. Legacy validators never learn new-format acceptance. */\nexport function scheduledState(record: StoredRecord, profile: ScheduledProfile) {\n const known = ownedStates.get(record);\n if (known?.profile === profile) return known.state;\n return profile === 'scheduled-v1' ? workflowState(record) : workflowGraphState(record);\n}\n\nconst storageCodes = new Set<StorageErrorCode>(['INVALID_INPUT', 'CONFLICT', 'NOT_FOUND', 'STORAGE_UNAVAILABLE',\n 'STORE_CLOSED', 'STORE_NOT_INITIALIZED', 'QUEUE_FULL', 'STALE_CLAIM', 'LIMIT_EXCEEDED', 'SCHEDULED_WRITER_REQUIRED']);\n\n/** Preserve only stable storage codes; never copy adapter messages or inspect exception getters. */\n/** Fixed storage answer when an approval expired before admission: final for that call, and a new review is needed. */\nexport const reviewExpiredMessage = 'The approval expired; request a new review before admission.';\nexport const isReviewExpired = (error: unknown): boolean => error instanceof StorageError && error.storageCode === 'CONFLICT' && error.message === reviewExpiredMessage;\nexport async function scheduledStorage<T>(operation: () => Promise<T>, timeoutMs = 10_000, signal?: AbortSignal): Promise<T> {\n try { return await scheduledCallback(operation, timeoutMs, signal ?? new AbortController().signal); }\n catch (error) {\n let code: StorageErrorCode = 'STORAGE_UNAVAILABLE'; let refusal: string | undefined;\n try {\n const own = error instanceof StorageError ? Object.getOwnPropertyDescriptor(error, 'storageCode') : undefined;\n if (own && 'value' in own && storageCodes.has(own.value as StorageErrorCode)) code = own.value as StorageErrorCode;\n // A migration refusal is fixed storage text plus step ids; it is the reviewer's answer, so it is kept verbatim.\n const message = error instanceof StorageError ? Object.getOwnPropertyDescriptor(error, 'message') : undefined;\n if (code === 'CONFLICT' && message && 'value' in message && typeof message.value === 'string'\n && (/^Migration refused: [A-Za-z0-9 .,;:\"'()_-]{1,240}$/.test(message.value) || message.value === reviewExpiredMessage)) refusal = message.value;\n } catch { /* Exception proxies do not become public diagnostics. */ }\n throw new StorageError(code, refusal ?? 'Scheduled persistence could not confirm the requested transition. Inspect current state before retrying effects.');\n }\n}\n\nexport function isStorageCode(error: unknown, code: StorageErrorCode): boolean {\n return error instanceof StorageError && error.storageCode === code;\n}\n\n/** One bounded callback window. Late results/rejections are handled without further admission. */\nexport async function scheduledCallback<T>(operation: () => T | PromiseLike<T>, timeoutMs: number, signal: AbortSignal): Promise<T> {\n if (signal.aborted) throw new MayuraError('CANCELLED', 'The scheduled worker is closing.');\n return await new Promise<T>((resolve, reject) => {\n let finished = false;\n const clear = (): void => { clearTimeout(timer); signal.removeEventListener('abort', abort); };\n const end = (action: () => void): void => { if (!finished) { finished = true; clear(); action(); } };\n const abort = (): void => { end(() => reject(new MayuraError('CANCELLED', 'The scheduled operation was cancelled.'))); };\n const timer = setTimeout(() => { end(() => reject(new MayuraError('TIMEOUT', 'The scheduled callback exceeded its deadline.'))); }, timeoutMs);\n signal.addEventListener('abort', abort, { once: true });\n Promise.resolve().then(() => {\n if (signal.aborted) throw new MayuraError('CANCELLED', 'The scheduled operation was cancelled.');\n return operation();\n }).then(value => { end(() => resolve(value)); }, (error: unknown) => { end(() => reject(error)); });\n if (signal.aborted) abort();\n });\n}\n\n/** Construct the original data-only definition material without changing its version hash. */\nexport function scheduledManifest(definition: AnyWorkflow): WorkflowManifest {\n return workflowManifest({ id: definition.id, version: definition.version, ...(definition.maxNodes === undefined ? {} : { maxNodes: definition.maxNodes }),\n graph: definition.nodes.map(node => node.kind === 'join'\n ? { id: node.id, kind: node.kind, dependsOn: node.dependsOn }\n : { id: node.id, kind: node.kind, dependsOn: node.dependsOn ?? [], tool: node.tool.id,\n toolVersion: node.tool.version, effects: node.tool.effects, capabilities: node.tool.capabilities,\n costMicros: node.tool.costMicros, approval: node.approval ?? false, input: node.input }),\n result: definition.result,\n });\n}\n\n/** Public workflow views retain effect/accounting truth without exposing persisted input. */\nexport function scheduledSnapshot(record: StoredRecord): WorkflowSnapshot;\nexport function scheduledSnapshot(record: StoredRecord, profile: ScheduledProfile): ScheduledPublicSnapshot;\nexport function scheduledSnapshot(record: StoredRecord, profile: ScheduledProfile = 'scheduled-v1'): ScheduledPublicSnapshot {\n const state = scheduledState(record, profile);\n return freezeJson(jsonValue({ id: record.id, version: record.version, status: state.status, steps: state.steps,\n output: state.output, budget: { spentMicros: state.spentMicros, reservedMicros: state.reservedMicros, maxCostMicros: state.maxCostMicros },\n })) as unknown as ScheduledPublicSnapshot;\n}\n\n/** Snapshot an adapter-owned response before using it for a later decision. */\nexport function scheduledView(raw: ScheduledWorkflowSnapshot, scope: string, id: string, policyHash: string): ScheduledWorkflowSnapshot;\nexport function scheduledView(raw: ScheduledStoredSnapshot, scope: string, id: string, policyHash: string, profile: ScheduledProfile): ScheduledStoredSnapshot;\nexport function scheduledView(raw: ScheduledStoredSnapshot, scope: string, id: string, policyHash: string, profile: ScheduledProfile = 'scheduled-v1'): ScheduledStoredSnapshot {\n try {\n const view = ownedViews.has(raw) ? raw\n : freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 })) as unknown as ScheduledStoredSnapshot;\n return checkOwnedView(view, scope, id, policyHash, profile);\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled state failed identity or integrity validation.'); }\n}\n\n/** Call only with JSON already copied and recursively frozen by this module. */\nfunction checkOwnedView(view: ScheduledStoredSnapshot, scope: string, id: string, policyHash: string, profile: ScheduledProfile): ScheduledStoredSnapshot {\n if (view.profile !== profile || view.record.scope !== scope || view.record.id !== id\n || view.policyHash !== policyHash || view.record.state['policy'] !== policyHash) throw new Error();\n // Requested authority is checked even for internal reuse; immutable structural\n // checks and decoding need happen only once for this exact owned snapshot.\n if (ownedViews.has(view)) return view;\n if (!Array.isArray(view.jobs)\n || view.jobs.length > workflowNodeLimit(view.record.state['maxNodes']) || !Number.isSafeInteger(view.record.version) || view.record.version < 1\n || !/^[a-f0-9]{64}$/.test(view.manifestHash) || !/^[a-f0-9]{64}$/.test(view.resourceHash)\n || view.record.definitionHash !== view.manifestHash) throw new Error();\n const state = scheduledState(view.record, profile);\n if (state.definition !== view.manifestHash || new Set(view.jobs.map(job => job.jobId)).size !== view.jobs.length\n || new Set(view.jobs.map(job => job.nodeId)).size !== view.jobs.length) throw new Error();\n for (const job of view.jobs) {\n checkJob(job, scope, id);\n const step = state.steps[job.nodeId];\n if (!step || step.kind !== 'tool' || step.candidateHash !== job.candidateHash) throw new Error();\n }\n freezeJson(state as unknown as JsonValue);\n ownedStates.set(view.record, { profile, state }); ownedViews.add(view);\n return view;\n}\n\n/** Own the complete submission acknowledgement before accessing nested adapter-owned data. */\nexport function scheduledSubmission(raw: unknown): { readonly snapshot: ScheduledStoredSnapshot; readonly created: boolean } {\n try {\n const value = freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 }));\n if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).length !== 2\n || !Object.hasOwn(value, 'snapshot') || typeof value['created'] !== 'boolean') throw new Error();\n return value as unknown as { readonly snapshot: ScheduledStoredSnapshot; readonly created: boolean };\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled submission response failed integrity validation.'); }\n}\n\n/** Structural response checks supplement, not replace, the adapter's transactional integrity checks. */\nfunction checkJob(job: JobRecord, scope: string, id: string): void {\n if (job.scope !== scope || job.runId !== id || typeof job.jobId !== 'string' || !job.jobId.length || job.jobId.length > 256\n || typeof job.nodeId !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(job.nodeId)\n || !/^[a-f0-9]{64}$/.test(job.candidateHash) || !/^[a-f0-9]{64}$/.test(job.definitionHash)\n || !Number.isSafeInteger(job.version) || job.version < 1 || !Number.isSafeInteger(job.fence) || job.fence < 0\n || !['ready', 'leased', 'started', 'succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown'].includes(job.state)\n || !job.intent || typeof job.intent !== 'object' || Array.isArray(job.intent)\n || !Array.isArray(job.resourceKeys) || job.resourceKeys.length > 32 || job.resourceKeys.some(key => typeof key !== 'string')\n || typeof job.leaseRevoked !== 'boolean' || typeof job.cancelRequested !== 'boolean') throw new Error();\n for (const value of [job.leaseUntilMs, job.startedAtMs, job.deadlineAtMs]) {\n if (value !== null && (!Number.isSafeInteger(value) || value < 0)) throw new Error();\n }\n}\n\n/** Renewal responses cannot change the identity of an admitted local execution. */\nexport function scheduledClaim(raw: Claim, expected: Pick<Claim, 'scope' | 'jobId' | 'workerId' | 'fence'>): Claim {\n try {\n const claim = freezeJson(jsonValue(raw, { maxBytes: 2_048 })) as unknown as Claim;\n if (claim.scope !== expected.scope || claim.jobId !== expected.jobId || claim.workerId !== expected.workerId || claim.fence !== expected.fence\n || !Number.isSafeInteger(claim.fence) || claim.fence < 1 || !Number.isSafeInteger(claim.leaseUntilMs) || claim.leaseUntilMs < 1) throw new Error();\n return claim;\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled claim failed identity or integrity validation.'); }\n}\n\n/** Bound and snapshot a claim batch before reserving local executor slots or invoking any tool. */\nexport function scheduledClaims(raw: readonly { readonly job: JobRecord; readonly claim: Claim }[], scope: string, id: string, workerId: string, limit: number): readonly { readonly job: JobRecord; readonly claim: Claim }[] {\n try {\n const values = freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 })) as unknown as typeof raw;\n if (!Array.isArray(values) || values.length > limit || new Set(values.map(value => value.job.jobId)).size !== values.length) throw new Error();\n for (const value of values) {\n checkJob(value.job, scope, id);\n scheduledClaim(value.claim, { scope, jobId: value.job.jobId, workerId, fence: value.job.fence });\n if (value.job.state !== 'leased' || value.job.workerId !== workerId || value.job.leaseUntilMs !== value.claim.leaseUntilMs\n || value.job.leaseRevoked || value.job.cancelRequested || value.job.startedAtMs !== null) throw new Error();\n }\n return values;\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled claim batch failed integrity validation.'); }\n}\n\nexport type ScheduledTransition = ScheduledStoredSnapshot | { readonly status: 'started' | 'already_started'; readonly snapshot: ScheduledStoredSnapshot };\n\n/** Every mutation response crosses the same identity boundary as an ordinary inspect response. */\nexport function scheduledTransition<T extends ScheduledTransition>(raw: T, scope: string, id: string, policyHash: string, profile: ScheduledProfile = 'scheduled-v1'): T {\n try {\n if (ownedViews.has(raw)) return scheduledView(raw as ScheduledStoredSnapshot, scope, id, policyHash, profile) as T;\n const value = freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 })) as unknown as T;\n if ('snapshot' in value) {\n if (value.status !== 'started' && value.status !== 'already_started') throw new Error();\n const snapshot = checkOwnedView(value.snapshot, scope, id, policyHash, profile);\n return Object.freeze({ ...value, snapshot }) as T;\n }\n return checkOwnedView(value, scope, id, policyHash, profile) as T;\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled transition response failed identity or integrity validation.'); }\n}\n\n/** Validate bounded canonical event pages; no adapter getters or malformed sequences reach callers. */\nexport function scheduledEvents(raw: StoredEvent[], after: number): StoredEvent[] {\n try {\n const events = freezeJson(jsonValue(raw, { maxBytes: 8_388_608, maxNodes: 300_000 })) as unknown as StoredEvent[];\n if (!Array.isArray(events) || events.length > 1_000) throw new Error();\n let previous = after;\n for (const event of events) {\n if (!Number.isSafeInteger(event.sequence) || event.sequence !== previous + 1 || typeof event.type !== 'string' || !event.type.length || event.type.length > 128\n || typeof event.createdAt !== 'string' || !Number.isFinite(Date.parse(event.createdAt)) || !event.data || typeof event.data !== 'object' || Array.isArray(event.data)) throw new Error();\n previous = event.sequence;\n }\n return events;\n } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled event page failed integrity validation.'); }\n}\n\nexport function safeScheduledJson(value: unknown, maxBytes: number, boundary: 'input' | 'output'): JsonValue {\n try { return freezeJson(jsonValue(value, { maxBytes })); }\n catch { throw new MayuraError(boundary === 'input' ? 'INVALID_INPUT' : 'INVALID_OUTPUT', 'Scheduled data exceeds its bounded JSON boundary.'); }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduled.d.ts","sourceRoot":"","sources":["../src/scheduled.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scheduled.d.ts","sourceRoot":"","sources":["../src/scheduled.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiK,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAGvO,OAAO,EAA2B,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC1G,OAAO,EAG4B,KAAK,+BAA+B,EACxC,KAAK,oBAAoB,EAAE,KAAK,YAAY,EAG1E,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACkB,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC7H,OAAO,EAA0C,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACpH,OAAO,EAAsC,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAiB,MAAM,cAAc,CAAC;AAC5F,OAAO,EAA8T,KAAK,uBAAuB,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzZ,MAAM,WAAW,+BAAgC,SAAQ,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC;IAC5F,QAAQ,CAAC,KAAK,EAAE,+BAA+B,CAAC;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE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,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACrE;AACD,6FAA6F;AAC7F,UAAU,0BAA0B;IAAG,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAA;CAAE;AAExH,iGAAiG;AACjG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,+BAA+B,GAAG,2BAA2B,EAAE,OAAO,EAAE,gBAAgB,EACrI,OAAO,CAAC,EAAE,SAAS,0BAA0B,EAAE,GAAG,sBAAsB,CAylBzE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { workflowAuthorization } from './authorization.js';
|
|
2
|
+
import { workflowNodeLimit } from '../../core/dist/index.js';
|
|
2
3
|
import { Budget, MayuraError, assertPositiveInteger, freezeJson, jsonValue, validate } from '../../core/dist/index.js';
|
|
3
4
|
import { invokeTool } from '../../tools/dist/index.js';
|
|
4
5
|
import { bindToolApproval } from '../../tools/dist/host.js';
|
|
@@ -758,7 +759,7 @@ export function createScheduledDriver(options, profile, catalog) {
|
|
|
758
759
|
carried[entry.target] = entry.action === 'keep' || entry.action === 'accept' ? state.steps[entry.source] : fresh.steps[entry.target];
|
|
759
760
|
}
|
|
760
761
|
const steps = Object.fromEntries(to.manifest.graph.map(node => [node.id, carried[node.id]]));
|
|
761
|
-
const next = { ...state, definition: migration.to.digest, steps,
|
|
762
|
+
const next = { ...state, maxNodes: migration.to.maxNodes === false ? false : workflowNodeLimit(migration.to.maxNodes), definition: migration.to.digest, steps,
|
|
762
763
|
reservedMicros: Object.values(steps).reduce((sum, step) => sum + step.costReserved, 0) };
|
|
763
764
|
// One attempt at the planned version: a concurrent change needs a fresh review, and a storage refusal keeps its reason.
|
|
764
765
|
let result;
|