mayura 0.1.0-dev.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +152 -35
- package/docs/README.md +82 -0
- package/docs/ai-agents.md +73 -0
- package/docs/cli/dev.md +111 -0
- package/docs/cli/init.md +192 -0
- package/docs/cli/operations.md +235 -0
- package/docs/cli/overview.md +129 -0
- package/docs/cli/run.md +182 -0
- package/docs/concepts/agent.md +197 -0
- package/docs/concepts/costs-and-budgets.md +177 -0
- package/docs/concepts/outcomes.md +154 -0
- package/docs/concepts/permissions.md +155 -0
- package/docs/concepts/runtime.md +172 -0
- package/docs/concepts/tools.md +202 -0
- package/docs/concepts/workflows.md +134 -0
- package/docs/guides/approvals-and-human-input.md +278 -0
- package/docs/guides/artifacts.md +123 -0
- package/docs/guides/child-agents.md +158 -0
- package/docs/guides/code-mode.md +233 -0
- package/docs/guides/deployment.md +644 -0
- package/docs/guides/durable-workflows.md +463 -0
- package/docs/guides/guardrails.md +205 -0
- package/docs/guides/helpers.md +176 -0
- package/docs/guides/lifecycle-hooks.md +187 -0
- package/docs/guides/mcp.md +123 -0
- package/docs/guides/memory-and-context.md +293 -0
- package/docs/guides/model-providers.md +371 -0
- package/docs/guides/model-routing.md +138 -0
- package/docs/guides/observability.md +238 -0
- package/docs/guides/operator-console.md +140 -0
- package/docs/guides/react.md +276 -0
- package/docs/guides/sagas-and-loops.md +212 -0
- package/docs/guides/server-and-client.md +559 -0
- package/docs/guides/skills.md +152 -0
- package/docs/guides/storage.md +251 -0
- package/docs/guides/streaming.md +146 -0
- package/docs/guides/terminal.md +166 -0
- package/docs/guides/testing.md +220 -0
- package/docs/guides/vision.md +155 -0
- package/docs/guides/webhooks.md +172 -0
- package/docs/guides/workflow-composition.md +141 -0
- package/docs/guides/workflow-operations.md +269 -0
- package/docs/installation.md +90 -0
- package/docs/introduction.md +74 -0
- package/docs/project/credits.md +78 -0
- package/docs/project/security.md +178 -0
- package/docs/project/support.md +91 -0
- package/docs/project/versioning.md +122 -0
- package/docs/quickstart.md +190 -0
- package/docs/reference/entry-points.md +146 -0
- package/lib/adapter-code-docker/dist/index.d.ts +8 -1
- package/lib/adapter-code-docker/dist/index.d.ts.map +1 -1
- package/lib/adapter-code-docker/dist/index.js +64 -67
- package/lib/adapter-code-docker/dist/index.js.map +1 -1
- package/lib/adapter-code-docker/dist/options.d.ts +15 -0
- package/lib/adapter-code-docker/dist/options.d.ts.map +1 -0
- package/lib/adapter-code-docker/dist/options.js +56 -0
- package/lib/adapter-code-docker/dist/options.js.map +1 -0
- package/lib/adapter-code-docker/image/Dockerfile +4 -2
- package/lib/adapter-code-docker/package.json +1 -1
- package/lib/adapter-code-docker/src/index.ts +63 -65
- package/lib/adapter-code-docker/src/options.ts +51 -0
- package/lib/adapter-code-quickjs/dist/index.d.ts +16 -4
- package/lib/adapter-code-quickjs/dist/index.d.ts.map +1 -1
- package/lib/adapter-code-quickjs/dist/index.js +94 -50
- package/lib/adapter-code-quickjs/dist/index.js.map +1 -1
- package/lib/adapter-code-quickjs/dist/worker-command.d.ts +27 -0
- package/lib/adapter-code-quickjs/dist/worker-command.d.ts.map +1 -0
- package/lib/adapter-code-quickjs/dist/worker-command.js +66 -0
- package/lib/adapter-code-quickjs/dist/worker-command.js.map +1 -0
- package/lib/adapter-code-quickjs/dist/worker.js +421 -104
- package/lib/adapter-code-quickjs/dist/worker.js.map +1 -1
- package/lib/adapter-code-quickjs/package.json +1 -1
- package/lib/adapter-code-quickjs/src/index.ts +88 -44
- package/lib/adapter-code-quickjs/src/worker-command.ts +68 -0
- package/lib/adapter-code-quickjs/src/worker.ts +315 -89
- package/lib/adapter-mcp/package.json +1 -1
- package/lib/artifacts/dist/contracts.d.ts +6 -2
- package/lib/artifacts/dist/contracts.d.ts.map +1 -1
- package/lib/artifacts/dist/contracts.js.map +1 -1
- package/lib/artifacts/dist/index.d.ts +1 -0
- package/lib/artifacts/dist/index.d.ts.map +1 -1
- package/lib/artifacts/dist/index.js +1 -0
- package/lib/artifacts/dist/index.js.map +1 -1
- package/lib/artifacts/dist/local-store.d.ts.map +1 -1
- package/lib/artifacts/dist/local-store.js +4 -7
- package/lib/artifacts/dist/local-store.js.map +1 -1
- package/lib/artifacts/dist/media.d.ts +11 -0
- package/lib/artifacts/dist/media.d.ts.map +1 -0
- package/lib/artifacts/dist/media.js +18 -0
- package/lib/artifacts/dist/media.js.map +1 -0
- package/lib/artifacts/package.json +1 -1
- package/lib/artifacts/src/contracts.ts +6 -2
- package/lib/artifacts/src/index.ts +1 -0
- package/lib/artifacts/src/local-store.ts +5 -7
- package/lib/artifacts/src/media.ts +20 -0
- package/lib/cli/dist/agent-guide.d.ts +10 -0
- package/lib/cli/dist/agent-guide.d.ts.map +1 -0
- package/lib/cli/dist/agent-guide.js +48 -0
- package/lib/cli/dist/agent-guide.js.map +1 -0
- package/lib/cli/dist/application.d.ts +24 -0
- package/lib/cli/dist/application.d.ts.map +1 -1
- package/lib/cli/dist/application.js +21 -0
- package/lib/cli/dist/application.js.map +1 -1
- package/lib/cli/dist/bin.js +26 -6
- package/lib/cli/dist/bin.js.map +1 -1
- package/lib/cli/dist/dev.d.ts.map +1 -1
- package/lib/cli/dist/dev.js +7 -1
- package/lib/cli/dist/dev.js.map +1 -1
- package/lib/cli/dist/index.d.ts +3 -3
- package/lib/cli/dist/index.d.ts.map +1 -1
- package/lib/cli/dist/index.js +19 -9
- package/lib/cli/dist/index.js.map +1 -1
- package/lib/cli/dist/interactive.d.ts.map +1 -1
- package/lib/cli/dist/interactive.js +52 -11
- package/lib/cli/dist/interactive.js.map +1 -1
- package/lib/cli/dist/operations.d.ts +25 -2
- package/lib/cli/dist/operations.d.ts.map +1 -1
- package/lib/cli/dist/operations.js +125 -12
- package/lib/cli/dist/operations.js.map +1 -1
- package/lib/cli/dist/output.d.ts.map +1 -1
- package/lib/cli/dist/output.js +3 -0
- package/lib/cli/dist/output.js.map +1 -1
- package/lib/cli/dist/providers.d.ts +34 -4
- package/lib/cli/dist/providers.d.ts.map +1 -1
- package/lib/cli/dist/providers.js +26 -5
- package/lib/cli/dist/providers.js.map +1 -1
- package/lib/cli/package.json +1 -1
- package/lib/cli/src/agent-guide.ts +47 -0
- package/lib/cli/src/application.ts +24 -0
- package/lib/cli/src/bin.ts +22 -5
- package/lib/cli/src/dev.ts +5 -1
- package/lib/cli/src/index.ts +18 -10
- package/lib/cli/src/interactive.ts +44 -12
- package/lib/cli/src/operations.ts +82 -12
- package/lib/cli/src/output.ts +3 -0
- package/lib/cli/src/providers.ts +45 -10
- package/lib/cli/starters/approval-workflow/dot-env.example +11 -0
- package/lib/cli/starters/approval-workflow/package.json +1 -2
- package/lib/cli/starters/approval-workflow/src/config.ts +25 -7
- package/lib/cli/starters/approval-workflow/src/intake.ts +1 -2
- package/lib/cli/starters/approval-workflow/src/model.ts +11 -4
- package/lib/cli/starters/approval-workflow/src/workflow.ts +1 -2
- package/lib/cli/starters/cli-agent/README.md +121 -0
- package/lib/cli/starters/cli-agent/dot-env.example +37 -0
- package/lib/cli/starters/cli-agent/dot-github/workflows/ci.yml +13 -0
- package/lib/cli/starters/cli-agent/dot-gitignore +10 -0
- package/lib/cli/starters/cli-agent/mayura.project.json +15 -0
- package/lib/cli/starters/cli-agent/package.json +28 -0
- package/lib/cli/starters/cli-agent/skills/release-notes/SKILL.md +18 -0
- package/lib/cli/starters/cli-agent/skills/release-notes/references/example.md +12 -0
- package/lib/cli/starters/cli-agent/src/assistant.ts +124 -0
- package/lib/cli/starters/cli-agent/src/cli.ts +72 -0
- package/lib/cli/starters/cli-agent/src/config.ts +117 -0
- package/lib/cli/starters/cli-agent/src/model.ts +34 -0
- package/lib/cli/starters/cli-agent/src/workspace.ts +170 -0
- package/lib/cli/starters/cli-agent/test/assistant.test.ts +205 -0
- package/lib/cli/starters/cli-agent/tsconfig.json +20 -0
- package/lib/cli/starters/event-automation/README.md +4 -3
- package/lib/cli/starters/event-automation/dot-env.example +11 -0
- package/lib/cli/starters/event-automation/package.json +1 -2
- package/lib/cli/starters/event-automation/src/config.ts +25 -7
- package/lib/cli/starters/event-automation/src/ingress.ts +3 -5
- package/lib/cli/starters/event-automation/src/model.ts +11 -4
- package/lib/cli/starters/event-automation/src/send-sample.ts +1 -1
- package/lib/cli/starters/event-automation/src/tracker/main.ts +1 -1
- package/lib/cli/starters/event-automation/src/tracker/mcp-server.ts +1 -1
- package/lib/cli/starters/event-automation/src/tracker/tickets.ts +1 -1
- package/lib/cli/starters/event-automation/src/tracker-tools.ts +1 -1
- package/lib/cli/starters/event-automation/src/triage.ts +15 -22
- package/lib/cli/starters/event-automation/src/workflows.ts +1 -1
- package/lib/cli/starters/event-automation/test/automation.test.ts +3 -3
- package/lib/cli/starters/research-team/README.md +2 -2
- package/lib/cli/starters/research-team/dot-env.example +11 -0
- package/lib/cli/starters/research-team/package.json +1 -2
- package/lib/cli/starters/research-team/src/config.ts +25 -7
- package/lib/cli/starters/research-team/src/desk.ts +1 -2
- package/lib/cli/starters/research-team/src/library/index.ts +1 -2
- package/lib/cli/starters/research-team/src/model.ts +11 -4
- package/lib/cli/starters/research-team/src/services.ts +1 -1
- package/lib/cli/starters/research-team/src/team.ts +1 -2
- package/lib/cli/starters/research-team/src/workflow.ts +45 -59
- package/lib/cli/starters/support-agent/dot-env.example +11 -0
- package/lib/cli/starters/support-agent/package.json +1 -2
- package/lib/cli/starters/support-agent/src/assistant.ts +5 -5
- package/lib/cli/starters/support-agent/src/config.ts +25 -7
- package/lib/cli/starters/support-agent/src/guardrails.ts +3 -1
- package/lib/cli/starters/support-agent/src/model.ts +11 -4
- package/lib/cli/starters/support-agent/src/returns.ts +1 -2
- package/lib/cli/starters/support-agent/test/support.test.ts +25 -1
- package/lib/cli/templates/basic-agent.ts +1 -2
- package/lib/cli/templates/capability-policy.ts +1 -2
- package/lib/cli/templates/code-mode-workflow.ts +1 -1
- package/lib/cli/templates/durable-approval.ts +1 -1
- package/lib/cli/templates/parallel-research.ts +1 -2
- package/lib/cli/templates/typed-tool-runner.ts +1 -2
- package/lib/client/dist/forms.d.ts.map +1 -1
- package/lib/client/dist/forms.js +3 -4
- package/lib/client/dist/forms.js.map +1 -1
- package/lib/client/dist/headless.d.ts +3 -1
- package/lib/client/dist/headless.d.ts.map +1 -1
- package/lib/client/dist/headless.js +10 -6
- package/lib/client/dist/headless.js.map +1 -1
- package/lib/client/dist/index.d.ts +95 -6
- package/lib/client/dist/index.d.ts.map +1 -1
- package/lib/client/dist/index.js +397 -124
- package/lib/client/dist/index.js.map +1 -1
- package/lib/client/dist/workflows.d.ts +1 -1
- package/lib/client/dist/workflows.d.ts.map +1 -1
- package/lib/client/dist/workflows.js +7 -6
- package/lib/client/dist/workflows.js.map +1 -1
- package/lib/client/package.json +1 -1
- package/lib/client/src/forms.ts +3 -4
- package/lib/client/src/headless.ts +13 -7
- package/lib/client/src/index.ts +344 -74
- package/lib/client/src/workflows.ts +8 -7
- package/lib/client-react/package.json +1 -1
- package/lib/code-mode/dist/index.d.ts +32 -1
- package/lib/code-mode/dist/index.d.ts.map +1 -1
- package/lib/code-mode/dist/index.js +289 -221
- package/lib/code-mode/dist/index.js.map +1 -1
- package/lib/code-mode/package.json +1 -1
- package/lib/code-mode/src/index.ts +288 -184
- package/lib/code-mode-workflows/package.json +1 -1
- package/lib/context/package.json +1 -1
- package/lib/core/dist/budget.d.ts.map +1 -1
- package/lib/core/dist/budget.js +17 -2
- package/lib/core/dist/budget.js.map +1 -1
- package/lib/core/dist/contracts.d.ts +57 -0
- package/lib/core/dist/contracts.d.ts.map +1 -1
- package/lib/core/dist/contracts.js +36 -0
- package/lib/core/dist/contracts.js.map +1 -1
- package/lib/core/dist/destination.d.ts +12 -0
- package/lib/core/dist/destination.d.ts.map +1 -0
- package/lib/core/dist/destination.js +37 -0
- package/lib/core/dist/destination.js.map +1 -0
- package/lib/core/dist/event-stream.d.ts +1 -1
- package/lib/core/dist/event-stream.d.ts.map +1 -1
- package/lib/core/dist/event-stream.js +7 -0
- package/lib/core/dist/event-stream.js.map +1 -1
- package/lib/core/dist/host.d.ts +3 -0
- package/lib/core/dist/host.d.ts.map +1 -1
- package/lib/core/dist/host.js +3 -0
- package/lib/core/dist/host.js.map +1 -1
- package/lib/core/dist/index.d.ts +2 -0
- package/lib/core/dist/index.d.ts.map +1 -1
- package/lib/core/dist/index.js +2 -0
- package/lib/core/dist/index.js.map +1 -1
- package/lib/core/dist/media.d.ts +98 -0
- package/lib/core/dist/media.d.ts.map +1 -0
- package/lib/core/dist/media.js +227 -0
- package/lib/core/dist/media.js.map +1 -0
- package/lib/core/dist/model-schema.d.ts +37 -0
- package/lib/core/dist/model-schema.d.ts.map +1 -0
- package/lib/core/dist/model-schema.js +154 -0
- package/lib/core/dist/model-schema.js.map +1 -0
- package/lib/core/package.json +1 -1
- package/lib/core/src/budget.ts +17 -2
- package/lib/core/src/contracts.ts +71 -3
- package/lib/core/src/destination.ts +33 -0
- package/lib/core/src/event-stream.ts +5 -1
- package/lib/core/src/host.ts +3 -0
- package/lib/core/src/index.ts +2 -0
- package/lib/core/src/media.ts +228 -0
- package/lib/core/src/model-schema.ts +129 -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/guardrails/package.json +1 -1
- package/lib/helpers/package.json +1 -1
- package/lib/memory/dist/index.js +1 -1
- package/lib/memory/dist/index.js.map +1 -1
- package/lib/memory/dist/native.d.ts.map +1 -1
- package/lib/memory/dist/native.js +4 -3
- package/lib/memory/dist/native.js.map +1 -1
- package/lib/memory/package.json +1 -1
- package/lib/memory/src/index.ts +1 -1
- package/lib/memory/src/native.ts +4 -3
- package/lib/memory-remote/package.json +1 -1
- package/lib/observability/package.json +1 -1
- package/lib/provider-anthropic/dist/index.d.ts +36 -3
- package/lib/provider-anthropic/dist/index.d.ts.map +1 -1
- package/lib/provider-anthropic/dist/index.js +128 -78
- package/lib/provider-anthropic/dist/index.js.map +1 -1
- package/lib/provider-anthropic/package.json +1 -1
- package/lib/provider-anthropic/src/index.ts +152 -76
- package/lib/provider-openai/dist/index.d.ts +71 -4
- package/lib/provider-openai/dist/index.d.ts.map +1 -1
- package/lib/provider-openai/dist/index.js +259 -96
- package/lib/provider-openai/dist/index.js.map +1 -1
- package/lib/provider-openai/package.json +1 -1
- package/lib/provider-openai/src/index.ts +282 -84
- package/lib/runtime/dist/agent.d.ts +18 -1
- package/lib/runtime/dist/agent.d.ts.map +1 -1
- package/lib/runtime/dist/agent.js +59 -3
- package/lib/runtime/dist/agent.js.map +1 -1
- package/lib/runtime/dist/composition.d.ts.map +1 -1
- package/lib/runtime/dist/composition.js +2 -1
- package/lib/runtime/dist/composition.js.map +1 -1
- package/lib/runtime/dist/hooks.d.ts +15 -3
- package/lib/runtime/dist/hooks.d.ts.map +1 -1
- package/lib/runtime/dist/hooks.js.map +1 -1
- package/lib/runtime/dist/index.d.ts +1 -1
- package/lib/runtime/dist/index.d.ts.map +1 -1
- package/lib/runtime/dist/index.js.map +1 -1
- package/lib/runtime/dist/response.d.ts +7 -1
- package/lib/runtime/dist/response.d.ts.map +1 -1
- package/lib/runtime/dist/response.js +23 -2
- package/lib/runtime/dist/response.js.map +1 -1
- package/lib/runtime/dist/router.d.ts +10 -3
- package/lib/runtime/dist/router.d.ts.map +1 -1
- package/lib/runtime/dist/router.js +45 -8
- package/lib/runtime/dist/router.js.map +1 -1
- package/lib/runtime/dist/runtime.d.ts +9 -1
- package/lib/runtime/dist/runtime.d.ts.map +1 -1
- package/lib/runtime/dist/runtime.js +50 -22
- package/lib/runtime/dist/runtime.js.map +1 -1
- package/lib/runtime/package.json +1 -1
- package/lib/runtime/src/agent.ts +69 -3
- package/lib/runtime/src/composition.ts +2 -1
- package/lib/runtime/src/hooks.ts +10 -4
- package/lib/runtime/src/index.ts +1 -1
- package/lib/runtime/src/response.ts +20 -2
- package/lib/runtime/src/router.ts +43 -10
- package/lib/runtime/src/runtime.ts +58 -27
- package/lib/sdk/dist/index.d.ts +9 -1
- package/lib/sdk/dist/index.d.ts.map +1 -1
- package/lib/sdk/dist/index.js +9 -1
- package/lib/sdk/dist/index.js.map +1 -1
- package/lib/sdk/package.json +1 -1
- package/lib/sdk/src/index.ts +9 -1
- package/lib/server/dist/index.d.ts +201 -3
- package/lib/server/dist/index.d.ts.map +1 -1
- package/lib/server/dist/index.js +701 -149
- 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 +611 -135
- package/lib/server/src/inspector-bundle.ts +4 -4
- package/lib/server-node/dist/hardening.d.ts +1 -1
- package/lib/server-node/dist/hardening.d.ts.map +1 -1
- package/lib/server-node/dist/hardening.js +4 -2
- package/lib/server-node/dist/hardening.js.map +1 -1
- package/lib/server-node/dist/index.d.ts +2 -1
- package/lib/server-node/dist/index.d.ts.map +1 -1
- package/lib/server-node/dist/index.js.map +1 -1
- package/lib/server-node/dist/probe.js +2 -2
- package/lib/server-node/dist/probe.js.map +1 -1
- package/lib/server-node/dist/production.d.ts +8 -1
- package/lib/server-node/dist/production.d.ts.map +1 -1
- package/lib/server-node/dist/production.js +15 -2
- package/lib/server-node/dist/production.js.map +1 -1
- package/lib/server-node/package.json +1 -1
- package/lib/server-node/src/hardening.ts +5 -3
- package/lib/server-node/src/index.ts +2 -1
- package/lib/server-node/src/probe.ts +2 -2
- package/lib/server-node/src/production.ts +23 -3
- package/lib/skills/dist/index.d.ts +81 -0
- package/lib/skills/dist/index.d.ts.map +1 -0
- package/lib/skills/dist/index.js +311 -0
- package/lib/skills/dist/index.js.map +1 -0
- package/lib/skills/package.json +5 -0
- package/lib/skills/src/index.ts +260 -0
- package/lib/storage/dist/index.d.ts +1 -1
- package/lib/storage/dist/index.d.ts.map +1 -1
- package/lib/storage/dist/index.js.map +1 -1
- package/lib/storage/package.json +1 -1
- package/lib/storage/src/index.ts +1 -1
- package/lib/storage-contracts/dist/contracts.d.ts +12 -5
- package/lib/storage-contracts/dist/contracts.d.ts.map +1 -1
- package/lib/storage-contracts/dist/contracts.js +24 -6
- package/lib/storage-contracts/dist/contracts.js.map +1 -1
- package/lib/storage-contracts/dist/index.d.ts +2 -0
- package/lib/storage-contracts/dist/index.d.ts.map +1 -1
- package/lib/storage-contracts/dist/index.js +2 -0
- package/lib/storage-contracts/dist/index.js.map +1 -1
- package/lib/storage-contracts/dist/memory-contracts.js +1 -1
- package/lib/storage-contracts/dist/memory-contracts.js.map +1 -1
- package/lib/storage-contracts/dist/run-records.d.ts +100 -0
- package/lib/storage-contracts/dist/run-records.d.ts.map +1 -0
- package/lib/storage-contracts/dist/run-records.js +464 -0
- package/lib/storage-contracts/dist/run-records.js.map +1 -0
- package/lib/storage-contracts/dist/schema-digest.d.ts +17 -0
- package/lib/storage-contracts/dist/schema-digest.d.ts.map +1 -0
- package/lib/storage-contracts/dist/schema-digest.js +94 -0
- package/lib/storage-contracts/dist/schema-digest.js.map +1 -0
- package/lib/storage-contracts/dist/submission-journal.js +1 -1
- package/lib/storage-contracts/dist/submission-journal.js.map +1 -1
- package/lib/storage-contracts/dist/workflow-format5.d.ts +30 -2
- package/lib/storage-contracts/dist/workflow-format5.d.ts.map +1 -1
- package/lib/storage-contracts/dist/workflow-format5.js +57 -5
- package/lib/storage-contracts/dist/workflow-format5.js.map +1 -1
- package/lib/storage-contracts/package.json +1 -1
- package/lib/storage-contracts/src/contracts.ts +29 -5
- package/lib/storage-contracts/src/index.ts +2 -0
- package/lib/storage-contracts/src/memory-contracts.ts +1 -1
- package/lib/storage-contracts/src/run-records.ts +365 -0
- package/lib/storage-contracts/src/schema-digest.ts +71 -0
- package/lib/storage-contracts/src/submission-journal.ts +1 -1
- package/lib/storage-contracts/src/workflow-format5.ts +70 -6
- package/lib/storage-postgres/dist/index.d.ts +1 -1
- package/lib/storage-postgres/dist/index.d.ts.map +1 -1
- package/lib/storage-postgres/dist/index.js.map +1 -1
- package/lib/storage-postgres/dist/postgres.d.ts +15 -0
- package/lib/storage-postgres/dist/postgres.d.ts.map +1 -1
- package/lib/storage-postgres/dist/postgres.js +18 -7
- package/lib/storage-postgres/dist/postgres.js.map +1 -1
- package/lib/storage-postgres/package.json +1 -1
- package/lib/storage-postgres/src/index.ts +1 -1
- package/lib/storage-postgres/src/postgres.ts +34 -8
- package/lib/storage-sql/dist/aggregate-session.js +1 -1
- package/lib/storage-sql/dist/aggregate-session.js.map +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-validation.js +1 -1
- package/lib/storage-sql/dist/workflow-tree-validation.js.map +1 -1
- package/lib/storage-sql/package.json +1 -1
- package/lib/storage-sql/src/aggregate-session.ts +1 -1
- package/lib/storage-sql/src/scheduled-database.ts +1 -1
- package/lib/storage-sql/src/workflow-tree-validation.ts +1 -1
- package/lib/storage-sqlite/dist/sqlite-database.js +4 -4
- package/lib/storage-sqlite/dist/sqlite-database.js.map +1 -1
- package/lib/storage-sqlite/dist/sqlite-worker.js +2 -2
- package/lib/storage-sqlite/dist/sqlite-worker.js.map +1 -1
- package/lib/storage-sqlite/dist/sqlite.js +1 -1
- package/lib/storage-sqlite/dist/sqlite.js.map +1 -1
- package/lib/storage-sqlite/package.json +1 -1
- package/lib/storage-sqlite/src/sqlite-database.ts +4 -4
- package/lib/storage-sqlite/src/sqlite-worker.ts +2 -2
- package/lib/storage-sqlite/src/sqlite.ts +1 -1
- package/lib/terminal/dist/index.d.ts +92 -0
- package/lib/terminal/dist/index.d.ts.map +1 -0
- package/lib/terminal/dist/index.js +397 -0
- package/lib/terminal/dist/index.js.map +1 -0
- package/lib/terminal/package.json +5 -0
- package/lib/terminal/src/index.ts +273 -0
- package/lib/testing/dist/index.d.ts +44 -1
- package/lib/testing/dist/index.d.ts.map +1 -1
- package/lib/testing/dist/index.js +63 -10
- package/lib/testing/dist/index.js.map +1 -1
- package/lib/testing/package.json +1 -1
- package/lib/testing/src/index.ts +83 -10
- package/lib/tools/dist/index.d.ts +32 -4
- package/lib/tools/dist/index.d.ts.map +1 -1
- package/lib/tools/dist/index.js +64 -11
- package/lib/tools/dist/index.js.map +1 -1
- package/lib/tools/package.json +1 -1
- package/lib/tools/src/index.ts +74 -13
- package/lib/workflows/dist/abandoned.d.ts +15 -0
- package/lib/workflows/dist/abandoned.d.ts.map +1 -0
- package/lib/workflows/dist/abandoned.js +33 -0
- package/lib/workflows/dist/abandoned.js.map +1 -0
- package/lib/workflows/dist/agent-step.d.ts +83 -0
- package/lib/workflows/dist/agent-step.d.ts.map +1 -0
- package/lib/workflows/dist/agent-step.js +161 -0
- package/lib/workflows/dist/agent-step.js.map +1 -0
- package/lib/workflows/dist/children-runtime.js +8 -8
- package/lib/workflows/dist/children-runtime.js.map +1 -1
- package/lib/workflows/dist/composite-fleet.js +2 -2
- package/lib/workflows/dist/composite-fleet.js.map +1 -1
- package/lib/workflows/dist/composite-host.d.ts.map +1 -1
- package/lib/workflows/dist/composite-host.js +26 -2
- package/lib/workflows/dist/composite-host.js.map +1 -1
- package/lib/workflows/dist/hook-relay.js +2 -2
- package/lib/workflows/dist/hook-relay.js.map +1 -1
- package/lib/workflows/dist/index.d.ts +1 -1
- package/lib/workflows/dist/index.d.ts.map +1 -1
- package/lib/workflows/dist/index.js.map +1 -1
- package/lib/workflows/dist/leadership.js +3 -3
- package/lib/workflows/dist/leadership.js.map +1 -1
- package/lib/workflows/dist/lifecycle-definition.d.ts +26 -4
- package/lib/workflows/dist/lifecycle-definition.d.ts.map +1 -1
- package/lib/workflows/dist/lifecycle-definition.js +31 -6
- package/lib/workflows/dist/lifecycle-definition.js.map +1 -1
- package/lib/workflows/dist/lifecycle-fleet.d.ts.map +1 -1
- package/lib/workflows/dist/lifecycle-fleet.js +9 -11
- package/lib/workflows/dist/lifecycle-fleet.js.map +1 -1
- package/lib/workflows/dist/lifecycle-host.d.ts.map +1 -1
- package/lib/workflows/dist/lifecycle-host.js +26 -2
- package/lib/workflows/dist/lifecycle-host.js.map +1 -1
- package/lib/workflows/dist/lifecycle-human-transport.d.ts +22 -2
- package/lib/workflows/dist/lifecycle-human-transport.d.ts.map +1 -1
- package/lib/workflows/dist/lifecycle-human-transport.js +115 -33
- package/lib/workflows/dist/lifecycle-human-transport.js.map +1 -1
- package/lib/workflows/dist/lifecycle-runtime.d.ts +62 -1
- package/lib/workflows/dist/lifecycle-runtime.d.ts.map +1 -1
- package/lib/workflows/dist/lifecycle-runtime.js +268 -64
- package/lib/workflows/dist/lifecycle-runtime.js.map +1 -1
- package/lib/workflows/dist/lifecycle.d.ts +6 -4
- package/lib/workflows/dist/lifecycle.d.ts.map +1 -1
- package/lib/workflows/dist/lifecycle.js +2 -0
- package/lib/workflows/dist/lifecycle.js.map +1 -1
- package/lib/workflows/dist/loop-runtime.d.ts.map +1 -1
- package/lib/workflows/dist/loop-runtime.js +38 -26
- package/lib/workflows/dist/loop-runtime.js.map +1 -1
- package/lib/workflows/dist/migration.d.ts +1 -1
- package/lib/workflows/dist/migration.d.ts.map +1 -1
- package/lib/workflows/dist/migration.js +3 -3
- package/lib/workflows/dist/migration.js.map +1 -1
- package/lib/workflows/dist/operator-transports.d.ts +24 -2
- package/lib/workflows/dist/operator-transports.d.ts.map +1 -1
- package/lib/workflows/dist/operator-transports.js +49 -3
- 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 +34 -22
- package/lib/workflows/dist/runtime.js.map +1 -1
- package/lib/workflows/dist/saga-runtime.d.ts.map +1 -1
- package/lib/workflows/dist/saga-runtime.js +44 -30
- package/lib/workflows/dist/saga-runtime.js.map +1 -1
- package/lib/workflows/dist/scheduled-helpers.d.ts.map +1 -1
- package/lib/workflows/dist/scheduled-helpers.js +3 -3
- package/lib/workflows/dist/scheduled-helpers.js.map +1 -1
- package/lib/workflows/dist/storage-failure.d.ts +16 -0
- package/lib/workflows/dist/storage-failure.d.ts.map +1 -0
- package/lib/workflows/dist/storage-failure.js +38 -0
- package/lib/workflows/dist/storage-failure.js.map +1 -0
- package/lib/workflows/dist/sweep-position.d.ts +22 -0
- package/lib/workflows/dist/sweep-position.d.ts.map +1 -0
- package/lib/workflows/dist/sweep-position.js +45 -0
- package/lib/workflows/dist/sweep-position.js.map +1 -0
- package/lib/workflows/dist/traces.js +2 -2
- package/lib/workflows/dist/traces.js.map +1 -1
- package/lib/workflows/dist/worker.d.ts +31 -0
- package/lib/workflows/dist/worker.d.ts.map +1 -1
- package/lib/workflows/dist/worker.js +94 -0
- package/lib/workflows/dist/worker.js.map +1 -1
- package/lib/workflows/package.json +1 -1
- package/lib/workflows/src/abandoned.ts +32 -0
- package/lib/workflows/src/agent-step.ts +199 -0
- package/lib/workflows/src/children-runtime.ts +8 -8
- package/lib/workflows/src/composite-fleet.ts +2 -2
- package/lib/workflows/src/composite-host.ts +21 -3
- package/lib/workflows/src/hook-relay.ts +2 -2
- package/lib/workflows/src/index.ts +2 -1
- package/lib/workflows/src/leadership.ts +3 -3
- package/lib/workflows/src/lifecycle-definition.ts +50 -9
- package/lib/workflows/src/lifecycle-fleet.ts +7 -8
- package/lib/workflows/src/lifecycle-host.ts +21 -5
- package/lib/workflows/src/lifecycle-human-transport.ts +110 -26
- package/lib/workflows/src/lifecycle-runtime.ts +270 -60
- package/lib/workflows/src/lifecycle.ts +7 -0
- package/lib/workflows/src/loop-runtime.ts +34 -25
- package/lib/workflows/src/migration.ts +2 -2
- package/lib/workflows/src/operator-transports.ts +48 -4
- package/lib/workflows/src/runtime.ts +28 -22
- package/lib/workflows/src/saga-runtime.ts +38 -28
- package/lib/workflows/src/scheduled-helpers.ts +3 -3
- package/lib/workflows/src/storage-failure.ts +37 -0
- package/lib/workflows/src/sweep-position.ts +52 -0
- package/lib/workflows/src/traces.ts +2 -2
- package/lib/workflows/src/worker.ts +79 -1
- package/lib/workstream/dist/humans.d.ts +7 -3
- package/lib/workstream/dist/humans.d.ts.map +1 -1
- package/lib/workstream/dist/humans.js +13 -2
- package/lib/workstream/dist/humans.js.map +1 -1
- package/lib/workstream/dist/index.js +2 -2
- package/lib/workstream/dist/index.js.map +1 -1
- package/lib/workstream/dist/timers.js +2 -2
- package/lib/workstream/dist/timers.js.map +1 -1
- package/lib/workstream/dist/webhooks.d.ts +6 -2
- package/lib/workstream/dist/webhooks.d.ts.map +1 -1
- package/lib/workstream/dist/webhooks.js +17 -7
- package/lib/workstream/dist/webhooks.js.map +1 -1
- package/lib/workstream/package.json +1 -1
- package/lib/workstream/src/humans.ts +15 -5
- package/lib/workstream/src/index.ts +2 -2
- package/lib/workstream/src/timers.ts +2 -2
- package/lib/workstream/src/webhooks.ts +21 -8
- package/llms-full.txt +9766 -0
- package/llms.txt +92 -0
- package/package.json +18 -6
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { freezeJson, jsonValue, MayuraError, validate } from '../../core/dist/index.js';
|
|
2
2
|
import { StorageError, assertWorkflowLoopStateMatchesManifest, initialWorkflowLoopState, workflowLoopState } from '../../storage-contracts/dist/index.js';
|
|
3
3
|
import { digest, resolveBinding } from './definition.js';
|
|
4
|
-
import {
|
|
4
|
+
import { createSubmission, workflowStorageFailure } from './storage-failure.js';
|
|
5
|
+
import { createWorkflowLifecycleRuntime, submitWorkflowLifecycleUnder, unknownWorkflowPolicy, workflowPolicyDigest, workflowPolicySettings } from './lifecycle-runtime.js';
|
|
5
6
|
import { assertWorkflowLoop, loopManifest } from './loop-definition.js';
|
|
6
7
|
import { assertMigrationAllowed, assertWorkflowMigration, migrationCommand, migrationEvent, nodeFingerprint, planWorkflowMigration } from './migration.js';
|
|
7
8
|
const hashPattern = /^[a-f0-9]{64}$/;
|
|
@@ -38,9 +39,7 @@ async function storage(operation) {
|
|
|
38
39
|
return await operation();
|
|
39
40
|
}
|
|
40
41
|
catch (error) {
|
|
41
|
-
|
|
42
|
-
throw error;
|
|
43
|
-
throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow loop storage is unavailable; inspect current state before retrying.');
|
|
42
|
+
throw workflowStorageFailure(error, 'workflow loop run');
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
/** Drive an explicitly bounded loop one lifecycle child at a time. */
|
|
@@ -65,14 +64,22 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
65
64
|
}
|
|
66
65
|
const lifecycle = createWorkflowLifecycleRuntime(options);
|
|
67
66
|
const scopeKey = digest('mayura:scope:v1', scope);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
// Index n of `settings` and of `policies` is the same policy the lifecycle runtime knows at index n.
|
|
68
|
+
const settings = workflowPolicySettings(options);
|
|
69
|
+
const policies = settings.map(entry => workflowPolicyDigest('mayura:workflow-loop-policy:v1', scope, entry));
|
|
70
|
+
const policy = policies[0];
|
|
71
|
+
/** Index of the policy a loop was started with; its later iterations and limits keep that policy. */
|
|
72
|
+
const pinnedIndex = (state) => {
|
|
73
|
+
const index = policies.indexOf(state.policy);
|
|
74
|
+
if (index < 0)
|
|
75
|
+
throw unknownWorkflowPolicy();
|
|
76
|
+
return index;
|
|
77
|
+
};
|
|
71
78
|
let closed = false;
|
|
72
79
|
let pendingCallbacks = 0;
|
|
73
80
|
const ensureOpen = () => { if (closed)
|
|
74
81
|
throw new MayuraError('CANCELLED', 'Workflow loop runtime is closed.'); };
|
|
75
|
-
const checked = async (schema, candidate, boundary) => {
|
|
82
|
+
const checked = async (schema, candidate, boundary, maxBytes = maxOutputBytes) => {
|
|
76
83
|
if (pendingCallbacks >= maxPendingCallbacks)
|
|
77
84
|
throw new MayuraError('LIMIT_EXCEEDED', 'Loop callback capacity is full.');
|
|
78
85
|
pendingCallbacks += 1;
|
|
@@ -81,20 +88,21 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
81
88
|
released = true;
|
|
82
89
|
pendingCallbacks -= 1;
|
|
83
90
|
} };
|
|
84
|
-
const operation = Promise.resolve().then(() => validate(schema, candidate, boundary, { maxBytes
|
|
91
|
+
const operation = Promise.resolve().then(() => validate(schema, candidate, boundary, { maxBytes }));
|
|
85
92
|
void operation.then(release, release);
|
|
86
93
|
let timer;
|
|
87
94
|
try {
|
|
88
95
|
return jsonValue(await Promise.race([operation, new Promise((_resolve, reject) => {
|
|
89
96
|
timer = setTimeout(() => reject(new MayuraError('TIMEOUT', 'Loop schema validation timed out.')), callbackTimeoutMs);
|
|
90
|
-
})]), { maxBytes
|
|
97
|
+
})]), { maxBytes });
|
|
91
98
|
}
|
|
92
99
|
finally {
|
|
93
100
|
if (timer !== undefined)
|
|
94
101
|
clearTimeout(timer);
|
|
95
102
|
}
|
|
96
103
|
};
|
|
97
|
-
|
|
104
|
+
/** `anyPolicy` admits operator controls (pause, resume, cancel, migrate) on a loop whose settings are not listed. */
|
|
105
|
+
const load = async (id, anyPolicy = false) => {
|
|
98
106
|
ensureOpen();
|
|
99
107
|
if (typeof id !== 'string' || !hashPattern.test(id))
|
|
100
108
|
throw new MayuraError('INVALID_INPUT', 'A workflow loop run ID is required.');
|
|
@@ -103,8 +111,8 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
103
111
|
throw new MayuraError('NOT_FOUND', 'Workflow loop run was not found in this scope.');
|
|
104
112
|
if (record.scope !== scopeKey || record.id !== id)
|
|
105
113
|
throw new MayuraError('CONFLICT', 'Stored loop identity does not match its requested scope.');
|
|
106
|
-
if (
|
|
107
|
-
|
|
114
|
+
if (!anyPolicy)
|
|
115
|
+
pinnedIndex(decoded(record));
|
|
108
116
|
return record;
|
|
109
117
|
};
|
|
110
118
|
const verify = (definition, record, state) => {
|
|
@@ -119,9 +127,9 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
119
127
|
};
|
|
120
128
|
const save = (record, state, type, data = {}) => storage(() => store.update({ scope: scopeKey, id: record.id, expectedVersion: record.version,
|
|
121
129
|
state: jsonValue(state), events: [{ type, data }] }));
|
|
122
|
-
const mutate = async (id, transition, type, data = {}) => {
|
|
130
|
+
const mutate = async (id, transition, type, data = {}, anyPolicy = false) => {
|
|
123
131
|
for (let attempt = 0; attempt < 32; attempt++) {
|
|
124
|
-
const record = await load(id);
|
|
132
|
+
const record = await load(id, anyPolicy);
|
|
125
133
|
const state = decoded(record);
|
|
126
134
|
const paused = state.status === 'paused';
|
|
127
135
|
if (!transition(state))
|
|
@@ -133,7 +141,7 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
133
141
|
return await save(record, state, type, data);
|
|
134
142
|
}
|
|
135
143
|
catch (error) {
|
|
136
|
-
if (!(error instanceof StorageError) || error.
|
|
144
|
+
if (!(error instanceof StorageError) || error.storageCode !== 'CONFLICT')
|
|
137
145
|
throw error;
|
|
138
146
|
}
|
|
139
147
|
}
|
|
@@ -168,7 +176,7 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
168
176
|
}
|
|
169
177
|
if (!again) {
|
|
170
178
|
try {
|
|
171
|
-
state.output = await checked(definition.output, loopValue(definition.result, state.input, state.current), 'output');
|
|
179
|
+
state.output = await checked(definition.output, loopValue(definition.result, state.input, state.current), 'output', settings[pinnedIndex(state)].maxOutputBytes);
|
|
172
180
|
state.status = 'succeeded';
|
|
173
181
|
}
|
|
174
182
|
catch (error) {
|
|
@@ -198,7 +206,7 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
198
206
|
}
|
|
199
207
|
let child;
|
|
200
208
|
try {
|
|
201
|
-
child = await lifecycle
|
|
209
|
+
child = await submitWorkflowLifecycleUnder(lifecycle, pinnedIndex(state), definition.body, { input,
|
|
202
210
|
idempotencyKey: digest('mayura:workflow-loop-child:v1', { loopRunId: id, iteration: state.iteration }) });
|
|
203
211
|
}
|
|
204
212
|
catch (error) {
|
|
@@ -264,8 +272,8 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
264
272
|
const input = await checked(definition.input, freezeJson(jsonValue(command.input, { maxBytes: maxOutputBytes })), 'input');
|
|
265
273
|
const state = initialWorkflowLoopState(loopManifest(definition), input, definition.digest, policy, options.maxCostMicros);
|
|
266
274
|
const id = digest('mayura:workflow-loop-run-id:v1', { scope: scopeKey, submissionKey: command.idempotencyKey });
|
|
267
|
-
const created = await
|
|
268
|
-
definitionHash: definition.digest, state: jsonValue(state), events: [{ type: 'loop.run.created', data: {} }] }));
|
|
275
|
+
const created = await createSubmission(() => store.create({ scope: scopeKey, id, idempotencyKey: `loop:${command.idempotencyKey}`,
|
|
276
|
+
definitionHash: definition.digest, state: jsonValue(state), events: [{ type: 'loop.run.created', data: {} }] }), 'workflow loop run');
|
|
269
277
|
verify(definition, created.record, decoded(created.record));
|
|
270
278
|
return view(created.record);
|
|
271
279
|
},
|
|
@@ -279,26 +287,29 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
279
287
|
throw new MayuraError('CONFLICT', 'A terminal loop cannot be paused.');
|
|
280
288
|
state.status = 'paused';
|
|
281
289
|
return true;
|
|
282
|
-
}, 'loop.run.paused')),
|
|
290
|
+
}, 'loop.run.paused', {}, true)),
|
|
283
291
|
resume: async (id) => view(await mutate(id, state => {
|
|
284
292
|
if (state.status !== 'paused')
|
|
285
293
|
throw new MayuraError('CONFLICT', 'Only a paused loop can be resumed.');
|
|
286
294
|
state.status = 'running';
|
|
287
295
|
return true;
|
|
288
|
-
}, 'loop.run.resumed')),
|
|
296
|
+
}, 'loop.run.resumed', {}, true)),
|
|
289
297
|
migrate: async (migration, command) => {
|
|
290
298
|
ensureOpen();
|
|
291
299
|
assertWorkflowMigration(migration);
|
|
292
300
|
assertWorkflowLoop(migration.from);
|
|
293
301
|
assertWorkflowLoop(migration.to);
|
|
294
302
|
const { id, actorId, commandId, dryRun = false } = migrationCommand(command);
|
|
295
|
-
|
|
303
|
+
// A reviewed migration is the explicit way to move a loop onto the current settings, whichever it started under.
|
|
304
|
+
const record = await load(id, true);
|
|
296
305
|
const state = decoded(record);
|
|
297
306
|
verify(migration.from, record, state);
|
|
298
307
|
const toManifest = loopManifest(migration.to);
|
|
299
308
|
const preconditions = [];
|
|
300
309
|
if (state.status !== 'paused')
|
|
301
310
|
preconditions.push({ node: '*', reason: `The loop is ${state.status}; pause it before migrating.` });
|
|
311
|
+
if (state.spentMicros > options.maxCostMicros)
|
|
312
|
+
preconditions.push({ node: '*', reason: 'The loop already spent more than the current maxCostMicros.' });
|
|
302
313
|
if (toManifest.maxIterations < state.iteration)
|
|
303
314
|
preconditions.push({ node: 'control', reason: `The loop already ran ${state.iteration} iterations; the new maxIterations is ${toManifest.maxIterations}.` });
|
|
304
315
|
let activeBody;
|
|
@@ -319,7 +330,8 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
319
330
|
if (dryRun)
|
|
320
331
|
return freezeJson(jsonValue({ plan }));
|
|
321
332
|
assertMigrationAllowed(plan);
|
|
322
|
-
const next = { ...state, definition: migration.to.digest, maxIterations: toManifest.maxIterations
|
|
333
|
+
const next = { ...state, definition: migration.to.digest, maxIterations: toManifest.maxIterations,
|
|
334
|
+
policy, maxCostMicros: options.maxCostMicros };
|
|
323
335
|
try {
|
|
324
336
|
assertWorkflowLoopStateMatchesManifest(workflowLoopState({ id, state: jsonValue(next) }), toManifest);
|
|
325
337
|
}
|
|
@@ -334,7 +346,7 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
334
346
|
return freezeJson(jsonValue({ plan, snapshot: view(migrated) }));
|
|
335
347
|
},
|
|
336
348
|
cancel: async (id) => {
|
|
337
|
-
let record = await load(id);
|
|
349
|
+
let record = await load(id, true);
|
|
338
350
|
const state = decoded(record);
|
|
339
351
|
if (terminal.has(state.status))
|
|
340
352
|
return view(record);
|
|
@@ -346,7 +358,7 @@ export function createWorkflowLoopRuntime(options) {
|
|
|
346
358
|
account(current, child, false);
|
|
347
359
|
current.status = 'cancelled';
|
|
348
360
|
return true;
|
|
349
|
-
}, 'loop.run.cancelled');
|
|
361
|
+
}, 'loop.run.cancelled', {}, true);
|
|
350
362
|
return view(record);
|
|
351
363
|
},
|
|
352
364
|
close: () => { if (!closed) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-runtime.js","sourceRoot":"","sources":["../src/loop-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAoD,MAAM,cAAc,CAAC;AAE9H,OAAO,EAAE,YAAY,EAAE,sCAAsC,EAAE,wBAAwB,EAAE,iBAAiB,EACV,MAAM,2BAA2B,CAAC;AAClI,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,8BAA8B,EACL,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAwB,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAC5B,MAAM,gBAAgB,CAAC;AA2B7H,MAAM,WAAW,GAAG,gBAAgB,CAAC;AACrC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAqB,CAAC,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC,CAAC;AACrG,MAAM,aAAa,GAAG,CAAC,KAAgC,EAAW,EAAE,CAClE,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAE5F,SAAS,OAAO,CAAC,MAAoB;IACnC,IAAI,CAAC;QAAC,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAAC,CAAC;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,CAAC,CAAC,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACtF,MAAM,GAAG,MAAM,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE;gBAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;oBAAE,OAAO,KAAK,CAAC;gBACpF,IAAI,KAAK,IAAI,OAAO,CAAC,UAAU,KAAK,KAAK,CAAC,EAAE;oBAAE,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBAC7E,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC;gBAAC,OAAO,IAAI,CAAC;YAC5C,CAAC,EAAE,oBAAoB,CAAC,CAAC;YAAC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;QAAC,CAAC;QAClD,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAAC,MAAM,GAAG,IAAI,CAAC;YAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAAC,CAAC,CAAC,CAAC;QACnE,KAAK,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE,GAAG,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,GACzG,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { freezeJson, jsonValue, MayuraError, validate, type InferInput, type JsonObject, type JsonValue } from '@mayura/core';\nimport type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';\nimport { StorageError, assertWorkflowLoopStateMatchesManifest, initialWorkflowLoopState, workflowLoopState,\n type StoredRecord, type WorkflowLoopBinding, type WorkflowLoopState, type WorkflowLoopStatus } from '@mayura/storage-contracts';\nimport { digest, resolveBinding } from './definition.js';\nimport { createWorkflowLifecycleRuntime, type WorkflowLifecycleRuntime, type WorkflowLifecycleRuntimeOptions,\n type WorkflowLifecycleSnapshot } from './lifecycle-runtime.js';\nimport { assertWorkflowLoop, loopManifest, type AnyWorkflowLoop } from './loop-definition.js';\nimport { assertMigrationAllowed, assertWorkflowMigration, migrationCommand, migrationEvent, nodeFingerprint, planWorkflowMigration,\n type MigrationBlocker, type MigrationCommand, type WorkflowMigration, type WorkflowMigrationResult } from './migration.js';\n\nexport interface WorkflowLoopRuntimeOptions extends WorkflowLifecycleRuntimeOptions {}\nexport interface WorkflowLoopSnapshot {\n readonly id: string; readonly version: number; readonly status: WorkflowLoopStatus; readonly iteration: number;\n readonly childRunId: string | null; readonly current: JsonValue; readonly output: JsonValue;\n readonly budget: { readonly spentMicros: number; readonly maxCostMicros: number };\n}\nexport interface WorkflowLoopRuntime {\n readonly profile: 'loop-v1'; readonly lifecycle: WorkflowLifecycleRuntime;\n submit<D extends AnyWorkflowLoop>(definition: D, command: { readonly input: InferInput<D['input']>; readonly idempotencyKey: string }): Promise<WorkflowLoopSnapshot>;\n inspect(id: string): Promise<WorkflowLoopSnapshot>;\n events(id: string, after?: number): ReturnType<WorkflowLoopRuntimeOptions['store']['events']>;\n runUntilSettled(definition: AnyWorkflowLoop, id: string): Promise<WorkflowLoopSnapshot>;\n /** Quiescent operator pause: no further iteration is started or driven; an active child keeps its own state. */\n pause(id: string): Promise<WorkflowLoopSnapshot>;\n resume(id: string): Promise<WorkflowLoopSnapshot>;\n /**\n * Plan (dryRun) or apply a reviewed migration of a paused loop. Control settings apply from the next iteration; an\n * active iteration child keeps its link only if it already runs the target body definition (migrate it first).\n */\n migrate(migration: WorkflowMigration<AnyWorkflowLoop, AnyWorkflowLoop>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowLoopSnapshot>>;\n cancel(id: string): Promise<WorkflowLoopSnapshot>; close(): void;\n /** Let admitted iteration effects settle within the deadline, then close. */\n drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;\n}\n\nconst hashPattern = /^[a-f0-9]{64}$/;\nconst terminal = new Set<WorkflowLoopStatus>(['succeeded', 'failed', 'limit_exceeded', 'cancelled']);\nconst childTerminal = (value: WorkflowLifecycleSnapshot): boolean =>\n ['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown'].includes(value.status);\n\nfunction decoded(record: StoredRecord): WorkflowLoopState {\n try { return workflowLoopState(record); }\n catch { throw new MayuraError('CONFLICT', 'Stored workflow loop state failed integrity validation.'); }\n}\nfunction view(record: StoredRecord): WorkflowLoopSnapshot {\n const state = decoded(record);\n return freezeJson(jsonValue({ id: record.id, version: record.version, status: state.status,\n iteration: state.iteration, childRunId: state.childRunId, current: state.current, output: state.output,\n budget: { spentMicros: state.spentMicros, maxCostMicros: state.maxCostMicros } })) as unknown as WorkflowLoopSnapshot;\n}\nfunction loopValue(binding: WorkflowLoopBinding, input: JsonValue, current: JsonValue): JsonValue {\n if (binding.kind === 'literal') return jsonValue(binding.value);\n let value = binding.kind === 'input' ? input : current;\n for (const segment of binding.path) {\n if (value === null || typeof value !== 'object' || !Object.hasOwn(value, segment)) {\n throw new MayuraError('INVALID_INPUT', 'Workflow loop binding cannot resolve its path.');\n }\n value = (value as JsonObject)[segment]!;\n }\n return jsonValue(value);\n}\nasync function storage<T>(operation: () => Promise<T>): Promise<T> {\n try { return await operation(); }\n catch (error) {\n if (error instanceof StorageError && error.code === 'CONFLICT') throw error;\n throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow loop storage is unavailable; inspect current state before retrying.');\n }\n}\n\n/** Drive an explicitly bounded loop one lifecycle child at a time. */\nexport function createWorkflowLoopRuntime(options: WorkflowLoopRuntimeOptions): WorkflowLoopRuntime {\n const store = options.store; 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 < 1 || value.length > 128)) {\n throw new MayuraError('INVALID_CONFIG', 'Workflow loop scope and policy version are required.');\n }\n if (!Array.isArray(options.permissions?.allow) || options.permissions.allow.length > 4_096\n || options.permissions.allow.some(value => typeof value !== 'string' || value.length < 1 || value.length > 256)) {\n throw new MayuraError('INVALID_CONFIG', 'Workflow loop permissions must be bounded explicit grants.');\n }\n if (!Number.isSafeInteger(options.maxCostMicros) || options.maxCostMicros < 0) throw new MayuraError('INVALID_CONFIG', 'A bounded loop cost is required.');\n const maxOutputBytes = options.maxOutputBytes ?? 1_048_576; const callbackTimeoutMs = options.callbackTimeoutMs ?? 30_000;\n const maxPendingCallbacks = options.maxPendingCallbacks ?? 32;\n if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 1 || !Number.isSafeInteger(callbackTimeoutMs) || callbackTimeoutMs < 1\n || !Number.isSafeInteger(maxPendingCallbacks) || maxPendingCallbacks < 1 || maxPendingCallbacks > 128) {\n throw new MayuraError('INVALID_CONFIG', 'Workflow loop callback limits are invalid.');\n }\n const lifecycle = createWorkflowLifecycleRuntime(options); const scopeKey = digest('mayura:scope:v1', scope);\n const policy = digest('mayura:workflow-loop-policy:v1', { scope, permissions: [...options.permissions.allow].sort(),\n policyVersion: options.policyVersion, maxCostMicros: options.maxCostMicros, maxOutputBytes,\n approvalTtlMs: options.approvalTtlMs ?? 3_600_000 });\n let closed = false; let pendingCallbacks = 0;\n const ensureOpen = (): void => { if (closed) throw new MayuraError('CANCELLED', 'Workflow loop runtime is closed.'); };\n const checked = async (schema: AnyWorkflowLoop['input'] | AnyWorkflowLoop['output'], candidate: unknown,\n boundary: 'input' | 'output'): Promise<JsonValue> => {\n if (pendingCallbacks >= maxPendingCallbacks) throw new MayuraError('LIMIT_EXCEEDED', 'Loop callback capacity is full.');\n pendingCallbacks += 1; let released = false; const release = (): void => { if (!released) { released = true; pendingCallbacks -= 1; } };\n const operation = Promise.resolve().then(() => validate(schema, candidate, boundary, { maxBytes: maxOutputBytes }));\n void operation.then(release, release); let timer: ReturnType<typeof setTimeout> | undefined;\n try { return jsonValue(await Promise.race([operation, new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => reject(new MayuraError('TIMEOUT', 'Loop schema validation timed out.')), callbackTimeoutMs);\n })]), { maxBytes: maxOutputBytes }); }\n finally { if (timer !== undefined) clearTimeout(timer); }\n };\n const load = async (id: string): Promise<StoredRecord> => {\n ensureOpen(); if (typeof id !== 'string' || !hashPattern.test(id)) throw new MayuraError('INVALID_INPUT', 'A workflow loop run ID is required.');\n const record = await storage(() => store.read(scopeKey, id)); if (!record) throw new MayuraError('NOT_FOUND', 'Workflow loop run was not found in this scope.');\n if (record.scope !== scopeKey || record.id !== id) throw new MayuraError('CONFLICT', 'Stored loop identity does not match its requested scope.');\n if (decoded(record).policy !== policy) throw new MayuraError('CONFLICT', 'Stored loop policy does not match this runtime.'); return record;\n };\n const verify = (definition: AnyWorkflowLoop, record: StoredRecord, state: WorkflowLoopState): void => {\n if (record.definitionHash !== definition.digest || state.definition !== definition.digest) throw new MayuraError('CONFLICT', 'Workflow loop definition does not match persisted state.');\n try { assertWorkflowLoopStateMatchesManifest(state, loopManifest(definition)); }\n catch { throw new MayuraError('CONFLICT', 'Workflow loop state does not match its persisted definition.'); }\n };\n const save = (record: StoredRecord, state: WorkflowLoopState, type: string, data: JsonObject = {}) =>\n storage(() => store.update({ scope: scopeKey, id: record.id, expectedVersion: record.version,\n state: jsonValue(state) as JsonObject, events: [{ type, data }] }));\n const mutate = async (id: string, transition: (state: WorkflowLoopState) => boolean, type: string, data: JsonObject = {}) => {\n for (let attempt = 0; attempt < 32; attempt++) {\n const record = await load(id); const state = decoded(record); const paused = state.status === 'paused'; if (!transition(state)) return record;\n // Progress recorded while paused never un-pauses the loop; only a terminal outcome or an explicit resume does.\n if (paused && !terminal.has(state.status) && type !== 'loop.run.resumed') state.status = 'paused';\n try { return await save(record, state, type, data); }\n catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; }\n }\n throw new MayuraError('CONFLICT', 'Workflow loop contention exceeded the bounded retry limit.');\n };\n const account = (state: WorkflowLoopState, child: WorkflowLifecycleSnapshot, complete: boolean): void => {\n state.spentMicros = state.spentMicros - state.activeSpentMicros + child.budget.spentMicros;\n state.activeSpentMicros = complete ? 0 : child.budget.spentMicros;\n if (!Number.isSafeInteger(state.spentMicros) || state.spentMicros > state.maxCostMicros) throw new MayuraError('LIMIT_EXCEEDED', 'Workflow loop exceeded its persisted cost ceiling.');\n };\n\n const run = async (definition: AnyWorkflowLoop, id: string): Promise<WorkflowLoopSnapshot> => {\n assertWorkflowLoop(definition);\n for (let wave = 0; wave < definition.maxIterations * 2 + 4; wave++) {\n let record = await load(id); let state = decoded(record); verify(definition, record, state);\n if (terminal.has(state.status) || state.status === 'paused') return view(record);\n if (state.childRunId === null && state.iteration > 0) {\n let again: boolean;\n try { const condition = loopValue(definition.continueWhen, state.input, state.current);\n if (typeof condition !== 'boolean') throw new MayuraError('INVALID_OUTPUT', 'Loop continuation must resolve to a boolean.'); again = condition; }\n catch { state.status = 'failed'; record = await save(record, state, 'loop.condition.rejected'); return view(record); }\n if (!again) {\n try { state.output = await checked(definition.output, loopValue(definition.result, state.input, state.current), 'output'); state.status = 'succeeded'; }\n catch (error) {\n if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code)) throw error;\n state.status = 'failed';\n }\n record = await save(record, state, state.status === 'succeeded' ? 'loop.run.succeeded' : 'loop.output.rejected'); return view(record);\n }\n if (state.iteration >= state.maxIterations) { state.status = 'limit_exceeded'; record = await save(record, state, 'loop.limit.exceeded'); return view(record); }\n }\n if (state.childRunId === null) {\n let input: JsonValue;\n try { input = state.iteration === 0 ? resolveBinding(definition.initial, state.input, {})\n : loopValue(definition.next, state.input, state.current); }\n catch { state.status = 'failed'; record = await save(record, state, 'loop.input.rejected'); return view(record); }\n let child: WorkflowLifecycleSnapshot;\n try { child = await lifecycle.submit(definition.body, { input,\n idempotencyKey: digest('mayura:workflow-loop-child:v1', { loopRunId: id, iteration: state.iteration }) }); }\n catch (error) {\n if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code)) throw error;\n state.status = 'failed'; record = await save(record, state, 'loop.child.rejected'); return view(record);\n }\n record = await mutate(id, current => { if (current.childRunId !== null || current.iteration !== state.iteration) return false;\n current.childRunId = child.id; current.status = 'running'; return true;\n }, 'loop.child.linked', { iteration: state.iteration, childRunId: child.id });\n state = decoded(record);\n }\n const childId = state.childRunId!; let child = await lifecycle.inspect(childId);\n child = await lifecycle.runUntilSettled(definition.body, child.id);\n if (!childTerminal(child)) {\n record = await mutate(id, current => { if (current.childRunId !== child.id || terminal.has(current.status)) return false;\n account(current, child, false); current.status = child.status === 'waiting' ? 'waiting' : 'running'; return true;\n }, 'loop.child.waiting', { iteration: state.iteration, childRunId: child.id });\n return view(record);\n }\n if (child.status !== 'succeeded') {\n record = await mutate(id, current => { if (current.childRunId !== child.id || terminal.has(current.status)) return false;\n account(current, child, false); current.status = 'failed'; return true;\n }, 'loop.child.failed', { iteration: state.iteration, childRunId: child.id, childStatus: child.status });\n return view(record);\n }\n await mutate(id, current => { if (current.childRunId !== child.id) return false;\n account(current, child, true); current.current = child.output; current.iteration += 1;\n current.childRunId = null; current.status = 'running'; return true;\n }, 'loop.iteration.succeeded', { iteration: state.iteration, childRunId: child.id });\n }\n return view(await load(id));\n };\n\n return Object.freeze<WorkflowLoopRuntime>({ profile: 'loop-v1', lifecycle,\n submit: async (definition, command) => {\n ensureOpen(); assertWorkflowLoop(definition);\n if (definition.maxCostMicros > options.maxCostMicros) throw new MayuraError('LIMIT_EXCEEDED', 'Loop static cost exceeds its runtime ceiling.');\n if (typeof command.idempotencyKey !== 'string' || command.idempotencyKey.length < 1 || command.idempotencyKey.length > 128) throw new MayuraError('INVALID_INPUT', 'A bounded loop submission key is required.');\n const input = await checked(definition.input, freezeJson(jsonValue(command.input, { maxBytes: maxOutputBytes })), 'input');\n const state = initialWorkflowLoopState(loopManifest(definition), input, definition.digest, policy, options.maxCostMicros);\n const id = digest('mayura:workflow-loop-run-id:v1', { scope: scopeKey, submissionKey: command.idempotencyKey });\n const created = await storage(() => store.create({ scope: scopeKey, id, idempotencyKey: `loop:${command.idempotencyKey}`,\n definitionHash: definition.digest, state: jsonValue(state) as JsonObject, events: [{ type: 'loop.run.created', data: {} }] }));\n verify(definition, created.record, decoded(created.record)); return view(created.record);\n },\n inspect: async id => view(await load(id)),\n events: (id, after = 0) => { ensureOpen(); return storage(() => store.events(scopeKey, id, after)); },\n runUntilSettled: run,\n pause: async id => view(await mutate(id, state => {\n if (state.status === 'paused') return false;\n if (terminal.has(state.status)) throw new MayuraError('CONFLICT', 'A terminal loop cannot be paused.');\n state.status = 'paused'; return true;\n }, 'loop.run.paused')),\n resume: async id => view(await mutate(id, state => {\n if (state.status !== 'paused') throw new MayuraError('CONFLICT', 'Only a paused loop can be resumed.');\n state.status = 'running'; return true;\n }, 'loop.run.resumed')),\n migrate: async (migration, command) => {\n ensureOpen(); assertWorkflowMigration(migration); assertWorkflowLoop(migration.from); assertWorkflowLoop(migration.to);\n const { id, actorId, commandId, dryRun = false } = migrationCommand(command);\n const record = await load(id); const state = decoded(record); verify(migration.from, record, state);\n const toManifest = loopManifest(migration.to);\n const preconditions: MigrationBlocker[] = [];\n if (state.status !== 'paused') preconditions.push({ node: '*', reason: `The loop is ${state.status}; pause it before migrating.` });\n if (toManifest.maxIterations < state.iteration) preconditions.push({ node: 'control', reason: `The loop already ran ${state.iteration} iterations; the new maxIterations is ${toManifest.maxIterations}.` });\n let activeBody: string | undefined;\n if (state.childRunId !== null) {\n const child = await storage(() => store.read(scopeKey, state.childRunId!));\n if (!child) throw new MayuraError('CONFLICT', 'The active loop iteration child is missing.');\n activeBody = child.definitionHash;\n }\n const nodes = (definition: AnyWorkflowLoop, effective: boolean) => {\n const { body, ...control } = loopManifest(definition);\n return [{ id: 'body', kind: 'loop-body', dependsOn: [], fingerprint: nodeFingerprint({ body: effective && activeBody ? activeBody : body.definitionHash }) },\n { id: 'control', kind: 'loop-control', dependsOn: [], fingerprint: nodeFingerprint({ ...control, bodyBounds: { maxCostMicros: body.maxCostMicros, maxCalls: body.maxCalls } }) }];\n };\n const plan = planWorkflowMigration({ migration, format: 'loop-v1', runId: id, fromDigest: migration.from.digest, toDigest: migration.to.digest,\n from: nodes(migration.from, true), to: nodes(migration.to, false),\n steps: [{ id: 'body', status: state.childRunId !== null ? 'running' : 'pending' }, { id: 'control', status: 'pending' }], preconditions });\n if (dryRun) return freezeJson(jsonValue({ plan })) as unknown as WorkflowMigrationResult<WorkflowLoopSnapshot>;\n assertMigrationAllowed(plan);\n const next: WorkflowLoopState = { ...state, definition: migration.to.digest, maxIterations: toManifest.maxIterations };\n try { assertWorkflowLoopStateMatchesManifest(workflowLoopState({ id, state: jsonValue(next) as JsonObject }), toManifest); }\n catch { throw new MayuraError('CONFLICT', 'Migration refused: the migrated loop 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 storage(() => 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 verify(migration.to, migrated, decoded(migrated));\n return freezeJson(jsonValue({ plan, snapshot: view(migrated) })) as unknown as WorkflowMigrationResult<WorkflowLoopSnapshot>;\n },\n cancel: async id => { let record = await load(id); const state = decoded(record); if (terminal.has(state.status)) return view(record);\n const child = state.childRunId ? await lifecycle.cancel(state.childRunId) : undefined;\n record = await mutate(id, current => { if (terminal.has(current.status)) return false;\n if (child && current.childRunId === child.id) account(current, child, false);\n current.status = 'cancelled'; return true;\n }, 'loop.run.cancelled'); return view(record); },\n close: () => { if (!closed) { closed = true; lifecycle.close(); } },\n drain: async options => { const report = await lifecycle.drain(options); closed = true; return report; },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"loop-runtime.js","sourceRoot":"","sources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,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,GACzG,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { freezeJson, jsonValue, MayuraError, validate, type InferInput, type JsonObject, type JsonValue } from '@mayura/core';\nimport type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';\nimport { StorageError, assertWorkflowLoopStateMatchesManifest, initialWorkflowLoopState, workflowLoopState,\n type StoredRecord, type WorkflowLoopBinding, type WorkflowLoopState, type WorkflowLoopStatus } from '@mayura/storage-contracts';\nimport { digest, resolveBinding } from './definition.js';\nimport { createSubmission, workflowStorageFailure } from './storage-failure.js';\nimport { createWorkflowLifecycleRuntime, submitWorkflowLifecycleUnder, unknownWorkflowPolicy, workflowPolicyDigest, workflowPolicySettings,\n type WorkflowLifecycleRuntime, type WorkflowLifecycleRuntimeOptions, type WorkflowLifecycleSnapshot } from './lifecycle-runtime.js';\nimport { assertWorkflowLoop, loopManifest, type AnyWorkflowLoop } from './loop-definition.js';\nimport { assertMigrationAllowed, assertWorkflowMigration, migrationCommand, migrationEvent, nodeFingerprint, planWorkflowMigration,\n type MigrationBlocker, type MigrationCommand, type WorkflowMigration, type WorkflowMigrationResult } from './migration.js';\n\nexport interface WorkflowLoopRuntimeOptions extends WorkflowLifecycleRuntimeOptions {}\nexport interface WorkflowLoopSnapshot {\n readonly id: string; readonly version: number; readonly status: WorkflowLoopStatus; readonly iteration: number;\n readonly childRunId: string | null; readonly current: JsonValue; readonly output: JsonValue;\n readonly budget: { readonly spentMicros: number; readonly maxCostMicros: number };\n}\nexport interface WorkflowLoopRuntime {\n readonly profile: 'loop-v1'; readonly lifecycle: WorkflowLifecycleRuntime;\n submit<D extends AnyWorkflowLoop>(definition: D, command: { readonly input: InferInput<D['input']>; readonly idempotencyKey: string }): Promise<WorkflowLoopSnapshot>;\n inspect(id: string): Promise<WorkflowLoopSnapshot>;\n events(id: string, after?: number): ReturnType<WorkflowLoopRuntimeOptions['store']['events']>;\n runUntilSettled(definition: AnyWorkflowLoop, id: string): Promise<WorkflowLoopSnapshot>;\n /** Quiescent operator pause: no further iteration is started or driven; an active child keeps its own state. */\n pause(id: string): Promise<WorkflowLoopSnapshot>;\n resume(id: string): Promise<WorkflowLoopSnapshot>;\n /**\n * Plan (dryRun) or apply a reviewed migration of a paused loop. Control settings apply from the next iteration; an\n * active iteration child keeps its link only if it already runs the target body definition (migrate it first).\n */\n migrate(migration: WorkflowMigration<AnyWorkflowLoop, AnyWorkflowLoop>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowLoopSnapshot>>;\n cancel(id: string): Promise<WorkflowLoopSnapshot>; close(): void;\n /** Let admitted iteration effects settle within the deadline, then close. */\n drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;\n}\n\nconst hashPattern = /^[a-f0-9]{64}$/;\nconst terminal = new Set<WorkflowLoopStatus>(['succeeded', 'failed', 'limit_exceeded', 'cancelled']);\nconst childTerminal = (value: WorkflowLifecycleSnapshot): boolean =>\n ['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown'].includes(value.status);\n\nfunction decoded(record: StoredRecord): WorkflowLoopState {\n try { return workflowLoopState(record); }\n catch { throw new MayuraError('CONFLICT', 'Stored workflow loop state failed integrity validation.'); }\n}\nfunction view(record: StoredRecord): WorkflowLoopSnapshot {\n const state = decoded(record);\n return freezeJson(jsonValue({ id: record.id, version: record.version, status: state.status,\n iteration: state.iteration, childRunId: state.childRunId, current: state.current, output: state.output,\n budget: { spentMicros: state.spentMicros, maxCostMicros: state.maxCostMicros } })) as unknown as WorkflowLoopSnapshot;\n}\nfunction loopValue(binding: WorkflowLoopBinding, input: JsonValue, current: JsonValue): JsonValue {\n if (binding.kind === 'literal') return jsonValue(binding.value);\n let value = binding.kind === 'input' ? input : current;\n for (const segment of binding.path) {\n if (value === null || typeof value !== 'object' || !Object.hasOwn(value, segment)) {\n throw new MayuraError('INVALID_INPUT', 'Workflow loop binding cannot resolve its path.');\n }\n value = (value as JsonObject)[segment]!;\n }\n return jsonValue(value);\n}\nasync function storage<T>(operation: () => Promise<T>): Promise<T> {\n try { return await operation(); }\n catch (error) {\n throw workflowStorageFailure(error, 'workflow loop run');\n }\n}\n\n/** Drive an explicitly bounded loop one lifecycle child at a time. */\nexport function createWorkflowLoopRuntime(options: WorkflowLoopRuntimeOptions): WorkflowLoopRuntime {\n const store = options.store; 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 < 1 || value.length > 128)) {\n throw new MayuraError('INVALID_CONFIG', 'Workflow loop scope and policy version are required.');\n }\n if (!Array.isArray(options.permissions?.allow) || options.permissions.allow.length > 4_096\n || options.permissions.allow.some(value => typeof value !== 'string' || value.length < 1 || value.length > 256)) {\n throw new MayuraError('INVALID_CONFIG', 'Workflow loop permissions must be bounded explicit grants.');\n }\n if (!Number.isSafeInteger(options.maxCostMicros) || options.maxCostMicros < 0) throw new MayuraError('INVALID_CONFIG', 'A bounded loop cost is required.');\n const maxOutputBytes = options.maxOutputBytes ?? 1_048_576; const callbackTimeoutMs = options.callbackTimeoutMs ?? 30_000;\n const maxPendingCallbacks = options.maxPendingCallbacks ?? 32;\n if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 1 || !Number.isSafeInteger(callbackTimeoutMs) || callbackTimeoutMs < 1\n || !Number.isSafeInteger(maxPendingCallbacks) || maxPendingCallbacks < 1 || maxPendingCallbacks > 128) {\n throw new MayuraError('INVALID_CONFIG', 'Workflow loop callback limits are invalid.');\n }\n const lifecycle = createWorkflowLifecycleRuntime(options); const scopeKey = digest('mayura:scope:v1', scope);\n // Index n of `settings` and of `policies` is the same policy the lifecycle runtime knows at index n.\n const settings = workflowPolicySettings(options);\n const policies = settings.map(entry => workflowPolicyDigest('mayura:workflow-loop-policy:v1', scope, entry)); const policy = policies[0]!;\n /** Index of the policy a loop was started with; its later iterations and limits keep that policy. */\n const pinnedIndex = (state: WorkflowLoopState): number => {\n const index = policies.indexOf(state.policy); if (index < 0) throw unknownWorkflowPolicy(); return index;\n };\n let closed = false; let pendingCallbacks = 0;\n const ensureOpen = (): void => { if (closed) throw new MayuraError('CANCELLED', 'Workflow loop runtime is closed.'); };\n const checked = async (schema: AnyWorkflowLoop['input'] | AnyWorkflowLoop['output'], candidate: unknown,\n boundary: 'input' | 'output', maxBytes = maxOutputBytes): Promise<JsonValue> => {\n if (pendingCallbacks >= maxPendingCallbacks) throw new MayuraError('LIMIT_EXCEEDED', 'Loop callback capacity is full.');\n pendingCallbacks += 1; let released = false; const release = (): void => { if (!released) { released = true; pendingCallbacks -= 1; } };\n const operation = Promise.resolve().then(() => validate(schema, candidate, boundary, { maxBytes }));\n void operation.then(release, release); let timer: ReturnType<typeof setTimeout> | undefined;\n try { return jsonValue(await Promise.race([operation, new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => reject(new MayuraError('TIMEOUT', 'Loop schema validation timed out.')), callbackTimeoutMs);\n })]), { maxBytes }); }\n finally { if (timer !== undefined) clearTimeout(timer); }\n };\n /** `anyPolicy` admits operator controls (pause, resume, cancel, migrate) on a loop whose settings are not listed. */\n const load = async (id: string, anyPolicy = false): Promise<StoredRecord> => {\n ensureOpen(); if (typeof id !== 'string' || !hashPattern.test(id)) throw new MayuraError('INVALID_INPUT', 'A workflow loop run ID is required.');\n const record = await storage(() => store.read(scopeKey, id)); if (!record) throw new MayuraError('NOT_FOUND', 'Workflow loop run was not found in this scope.');\n if (record.scope !== scopeKey || record.id !== id) throw new MayuraError('CONFLICT', 'Stored loop identity does not match its requested scope.');\n if (!anyPolicy) pinnedIndex(decoded(record)); return record;\n };\n const verify = (definition: AnyWorkflowLoop, record: StoredRecord, state: WorkflowLoopState): void => {\n if (record.definitionHash !== definition.digest || state.definition !== definition.digest) throw new MayuraError('CONFLICT', 'Workflow loop definition does not match persisted state.');\n try { assertWorkflowLoopStateMatchesManifest(state, loopManifest(definition)); }\n catch { throw new MayuraError('CONFLICT', 'Workflow loop state does not match its persisted definition.'); }\n };\n const save = (record: StoredRecord, state: WorkflowLoopState, type: string, data: JsonObject = {}) =>\n storage(() => store.update({ scope: scopeKey, id: record.id, expectedVersion: record.version,\n state: jsonValue(state) as JsonObject, events: [{ type, data }] }));\n const mutate = async (id: string, transition: (state: WorkflowLoopState) => boolean, type: string, data: JsonObject = {}, anyPolicy = false) => {\n for (let attempt = 0; attempt < 32; attempt++) {\n const record = await load(id, anyPolicy); const state = decoded(record); const paused = state.status === 'paused'; if (!transition(state)) return record;\n // Progress recorded while paused never un-pauses the loop; only a terminal outcome or an explicit resume does.\n if (paused && !terminal.has(state.status) && type !== 'loop.run.resumed') state.status = 'paused';\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 loop contention exceeded the bounded retry limit.');\n };\n const account = (state: WorkflowLoopState, child: WorkflowLifecycleSnapshot, complete: boolean): void => {\n state.spentMicros = state.spentMicros - state.activeSpentMicros + child.budget.spentMicros;\n state.activeSpentMicros = complete ? 0 : child.budget.spentMicros;\n if (!Number.isSafeInteger(state.spentMicros) || state.spentMicros > state.maxCostMicros) throw new MayuraError('LIMIT_EXCEEDED', 'Workflow loop exceeded its persisted cost ceiling.');\n };\n\n const run = async (definition: AnyWorkflowLoop, id: string): Promise<WorkflowLoopSnapshot> => {\n assertWorkflowLoop(definition);\n for (let wave = 0; wave < definition.maxIterations * 2 + 4; wave++) {\n let record = await load(id); let state = decoded(record); verify(definition, record, state);\n if (terminal.has(state.status) || state.status === 'paused') return view(record);\n if (state.childRunId === null && state.iteration > 0) {\n let again: boolean;\n try { const condition = loopValue(definition.continueWhen, state.input, state.current);\n if (typeof condition !== 'boolean') throw new MayuraError('INVALID_OUTPUT', 'Loop continuation must resolve to a boolean.'); again = condition; }\n catch { state.status = 'failed'; record = await save(record, state, 'loop.condition.rejected'); return view(record); }\n if (!again) {\n try { state.output = await checked(definition.output, loopValue(definition.result, state.input, state.current), 'output',\n settings[pinnedIndex(state)]!.maxOutputBytes); state.status = 'succeeded'; }\n catch (error) {\n if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code)) throw error;\n state.status = 'failed';\n }\n record = await save(record, state, state.status === 'succeeded' ? 'loop.run.succeeded' : 'loop.output.rejected'); return view(record);\n }\n if (state.iteration >= state.maxIterations) { state.status = 'limit_exceeded'; record = await save(record, state, 'loop.limit.exceeded'); return view(record); }\n }\n if (state.childRunId === null) {\n let input: JsonValue;\n try { input = state.iteration === 0 ? resolveBinding(definition.initial, state.input, {})\n : loopValue(definition.next, state.input, state.current); }\n catch { state.status = 'failed'; record = await save(record, state, 'loop.input.rejected'); return view(record); }\n let child: WorkflowLifecycleSnapshot;\n try { child = await submitWorkflowLifecycleUnder(lifecycle, pinnedIndex(state), definition.body, { input,\n idempotencyKey: digest('mayura:workflow-loop-child:v1', { loopRunId: id, iteration: state.iteration }) }); }\n catch (error) {\n if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code)) throw error;\n state.status = 'failed'; record = await save(record, state, 'loop.child.rejected'); return view(record);\n }\n record = await mutate(id, current => { if (current.childRunId !== null || current.iteration !== state.iteration) return false;\n current.childRunId = child.id; current.status = 'running'; return true;\n }, 'loop.child.linked', { iteration: state.iteration, childRunId: child.id });\n state = decoded(record);\n }\n const childId = state.childRunId!; let child = await lifecycle.inspect(childId);\n child = await lifecycle.runUntilSettled(definition.body, child.id);\n if (!childTerminal(child)) {\n record = await mutate(id, current => { if (current.childRunId !== child.id || terminal.has(current.status)) return false;\n account(current, child, false); current.status = child.status === 'waiting' ? 'waiting' : 'running'; return true;\n }, 'loop.child.waiting', { iteration: state.iteration, childRunId: child.id });\n return view(record);\n }\n if (child.status !== 'succeeded') {\n record = await mutate(id, current => { if (current.childRunId !== child.id || terminal.has(current.status)) return false;\n account(current, child, false); current.status = 'failed'; return true;\n }, 'loop.child.failed', { iteration: state.iteration, childRunId: child.id, childStatus: child.status });\n return view(record);\n }\n await mutate(id, current => { if (current.childRunId !== child.id) return false;\n account(current, child, true); current.current = child.output; current.iteration += 1;\n current.childRunId = null; current.status = 'running'; return true;\n }, 'loop.iteration.succeeded', { iteration: state.iteration, childRunId: child.id });\n }\n return view(await load(id));\n };\n\n return Object.freeze<WorkflowLoopRuntime>({ profile: 'loop-v1', lifecycle,\n submit: async (definition, command) => {\n ensureOpen(); assertWorkflowLoop(definition);\n if (definition.maxCostMicros > options.maxCostMicros) throw new MayuraError('LIMIT_EXCEEDED', 'Loop static cost exceeds its runtime ceiling.');\n if (typeof command.idempotencyKey !== 'string' || command.idempotencyKey.length < 1 || command.idempotencyKey.length > 128) throw new MayuraError('INVALID_INPUT', 'A bounded loop submission key is required.');\n const input = await checked(definition.input, freezeJson(jsonValue(command.input, { maxBytes: maxOutputBytes })), 'input');\n const state = initialWorkflowLoopState(loopManifest(definition), input, definition.digest, policy, options.maxCostMicros);\n const id = digest('mayura:workflow-loop-run-id:v1', { scope: scopeKey, submissionKey: command.idempotencyKey });\n const created = await createSubmission(() => store.create({ scope: scopeKey, id, idempotencyKey: `loop:${command.idempotencyKey}`,\n definitionHash: definition.digest, state: jsonValue(state) as JsonObject, events: [{ type: 'loop.run.created', data: {} }] }), 'workflow loop run');\n verify(definition, created.record, decoded(created.record)); return view(created.record);\n },\n inspect: async id => view(await load(id)),\n events: (id, after = 0) => { ensureOpen(); return storage(() => store.events(scopeKey, id, after)); },\n runUntilSettled: run,\n pause: async id => view(await mutate(id, state => {\n if (state.status === 'paused') return false;\n if (terminal.has(state.status)) throw new MayuraError('CONFLICT', 'A terminal loop cannot be paused.');\n state.status = 'paused'; return true;\n }, 'loop.run.paused', {}, true)),\n resume: async id => view(await mutate(id, state => {\n if (state.status !== 'paused') throw new MayuraError('CONFLICT', 'Only a paused loop can be resumed.');\n state.status = 'running'; return true;\n }, 'loop.run.resumed', {}, true)),\n migrate: async (migration, command) => {\n ensureOpen(); assertWorkflowMigration(migration); assertWorkflowLoop(migration.from); assertWorkflowLoop(migration.to);\n const { id, actorId, commandId, dryRun = false } = migrationCommand(command);\n // A reviewed migration is the explicit way to move a loop onto the current settings, whichever it started under.\n const record = await load(id, true); const state = decoded(record); verify(migration.from, record, state);\n const toManifest = loopManifest(migration.to);\n const preconditions: MigrationBlocker[] = [];\n if (state.status !== 'paused') preconditions.push({ node: '*', reason: `The loop is ${state.status}; pause it before migrating.` });\n if (state.spentMicros > options.maxCostMicros) preconditions.push({ node: '*', reason: 'The loop already spent more than the current maxCostMicros.' });\n if (toManifest.maxIterations < state.iteration) preconditions.push({ node: 'control', reason: `The loop already ran ${state.iteration} iterations; the new maxIterations is ${toManifest.maxIterations}.` });\n let activeBody: string | undefined;\n if (state.childRunId !== null) {\n const child = await storage(() => store.read(scopeKey, state.childRunId!));\n if (!child) throw new MayuraError('CONFLICT', 'The active loop iteration child is missing.');\n activeBody = child.definitionHash;\n }\n const nodes = (definition: AnyWorkflowLoop, effective: boolean) => {\n const { body, ...control } = loopManifest(definition);\n return [{ id: 'body', kind: 'loop-body', dependsOn: [], fingerprint: nodeFingerprint({ body: effective && activeBody ? activeBody : body.definitionHash }) },\n { id: 'control', kind: 'loop-control', dependsOn: [], fingerprint: nodeFingerprint({ ...control, bodyBounds: { maxCostMicros: body.maxCostMicros, maxCalls: body.maxCalls } }) }];\n };\n const plan = planWorkflowMigration({ migration, format: 'loop-v1', runId: id, fromDigest: migration.from.digest, toDigest: migration.to.digest,\n from: nodes(migration.from, true), to: nodes(migration.to, false),\n steps: [{ id: 'body', status: state.childRunId !== null ? 'running' : 'pending' }, { id: 'control', status: 'pending' }], preconditions });\n if (dryRun) return freezeJson(jsonValue({ plan })) as unknown as WorkflowMigrationResult<WorkflowLoopSnapshot>;\n assertMigrationAllowed(plan);\n const next: WorkflowLoopState = { ...state, definition: migration.to.digest, maxIterations: toManifest.maxIterations,\n policy, maxCostMicros: options.maxCostMicros };\n try { assertWorkflowLoopStateMatchesManifest(workflowLoopState({ id, state: jsonValue(next) as JsonObject }), toManifest); }\n catch { throw new MayuraError('CONFLICT', 'Migration refused: the migrated loop 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 storage(() => 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 verify(migration.to, migrated, decoded(migrated));\n return freezeJson(jsonValue({ plan, snapshot: view(migrated) })) as unknown as WorkflowMigrationResult<WorkflowLoopSnapshot>;\n },\n cancel: async id => { let record = await load(id, true); const state = decoded(record); if (terminal.has(state.status)) return view(record);\n const child = state.childRunId ? await lifecycle.cancel(state.childRunId) : undefined;\n record = await mutate(id, current => { if (terminal.has(current.status)) return false;\n if (child && current.childRunId === child.id) account(current, child, false);\n current.status = 'cancelled'; return true;\n }, 'loop.run.cancelled', {}, true); return view(record); },\n close: () => { if (!closed) { closed = true; lifecycle.close(); } },\n drain: async options => { const report = await lifecycle.drain(options); closed = true; return report; },\n });\n}\n"]}
|
|
@@ -38,7 +38,7 @@ export interface MigrationNode {
|
|
|
38
38
|
readonly fingerprint: string;
|
|
39
39
|
readonly evidence?: string;
|
|
40
40
|
}
|
|
41
|
-
/** Evidence of a manifest node: the tool a receipt must name, or whether a human request carries a deadline. */
|
|
41
|
+
/** Evidence of a manifest node: the tool a receipt must name, or whether a human request or signal step carries a deadline. */
|
|
42
42
|
export declare function nodeEvidence(node: {
|
|
43
43
|
readonly kind: string;
|
|
44
44
|
readonly tool?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../src/migration.ts"],"names":[],"mappings":"AAAA,OAAO,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AwB,CAAC,CAAC,CAAC,CAYjI"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MayuraError, freezeJson, jsonValue } from '../../core/dist/index.js';
|
|
2
2
|
import { digest } from './definition.js';
|
|
3
|
-
/** Evidence of a manifest node: the tool a receipt must name, or whether a human request carries a deadline. */
|
|
3
|
+
/** Evidence of a manifest node: the tool a receipt must name, or whether a human request or signal step carries a deadline. */
|
|
4
4
|
export function nodeEvidence(node) {
|
|
5
5
|
if (node.kind === 'tool' && typeof node.tool === 'string')
|
|
6
6
|
return `tool:${node.tool}`;
|
|
7
|
-
if (node.kind === 'human')
|
|
8
|
-
return node.deadlineAtMs === null || node.deadlineAtMs === undefined ?
|
|
7
|
+
if (node.kind === 'human' || node.kind === 'signal')
|
|
8
|
+
return node.deadlineAtMs === null || node.deadlineAtMs === undefined ? node.kind : `${node.kind}:deadline`;
|
|
9
9
|
return undefined;
|
|
10
10
|
}
|
|
11
11
|
/** Statuses of a step that has not started and holds nothing. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../src/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAqCzC,gHAAgH;AAChH,MAAM,UAAU,YAAY,CAAC,IAAyF;IACpH,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;IACtF,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC,YAAY,KAAK,IAAI,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAC7H,OAAO,SAAS,CAAC;AACnB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AAsC,CAAC,MAAM,CAAC;QAAC,MAAM,EAAE,GAAI,SAAS,CAAC,EAAoC,CAAC,MAAM,CAAC;QACzI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE;YAAE,MAAM,IAAI,WAAW,CAAC,gBAAgB,EAAE,cAAc,SAAS,CAAC,EAAE,mDAAmD,CAAC,CAAC;QAC9L,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAAE,MAAM,IAAI,WAAW,CAAC,gBAAgB,EAAE,iBAAiB,SAAS,CAAC,EAAE,wBAAwB,CAAC,CAAC;QAC3H,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IACpG,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,cAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/G,GAAG,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import { MayuraError, freezeJson, jsonValue, type JsonValue } from '@mayura/core';\nimport { digest } from './definition.js';\n\n/**\n * Reviewed in-place migration of an in-flight durable run from one definition version to another. The migration is a\n * declaration; the framework decides what is safe from the run's actual state and refuses everything else.\n */\nexport interface WorkflowMigrationOptions<F, T> {\n /** Stable identity recorded in the run's audit trail, for example `invoice-review-1-to-2` (letters, digits, `.`, `_`, `-`). */\n readonly id: string;\n readonly from: F;\n readonly to: T;\n /** Target node id -> source node id, for steps that were renamed. Only unstarted or waiting steps can be renamed. */\n readonly renames?: Readonly<Record<string, string>>;\n /** Target node ids whose definition changed but whose settled source result the reviewer accepts as-is. */\n readonly acceptCompleted?: readonly string[];\n /** Source node ids that settled and are removed by the new definition; the reviewer accepts dropping their results. */\n readonly acceptRemoved?: readonly string[];\n readonly description?: string;\n}\nexport interface WorkflowMigration<F = unknown, T = unknown> {\n readonly kind: 'mayura.workflow-migration';\n readonly id: string;\n readonly from: F;\n readonly to: T;\n readonly renames: Readonly<Record<string, string>>;\n readonly acceptCompleted: readonly string[];\n readonly acceptRemoved: readonly string[];\n readonly description: string;\n}\n\n/**\n * One node of a definition, reduced to what a migration compares. `fingerprint` covers the node's full definition.\n * `evidence` names what a settled step's recorded state is bound to (for a tool step, the tool its receipt names):\n * a changed node can only accept an existing result when this is unchanged.\n */\nexport interface MigrationNode { readonly id: string; readonly kind: string; readonly dependsOn: readonly string[]; readonly fingerprint: string; readonly evidence?: string }\n\n/** Evidence of a manifest node: the tool a receipt must name, or whether a human request carries a deadline. */\nexport function nodeEvidence(node: { readonly kind: string; readonly tool?: unknown; readonly deadlineAtMs?: unknown }): string | undefined {\n if (node.kind === 'tool' && typeof node.tool === 'string') return `tool:${node.tool}`;\n if (node.kind === 'human') return node.deadlineAtMs === null || node.deadlineAtMs === undefined ? 'human' : 'human:deadline';\n return undefined;\n}\n/** The run's current state of one source step, normalized across formats. */\nexport interface MigrationStep { readonly id: string; readonly status: string }\n\nexport type MigrationAction =\n | 'keep' // unchanged node; state carried\n | 'update' // changed node that never started; carried as pending under the new definition\n | 'reset' // changed node that was waiting (approval, human, timer, signal); re-issued as pending\n | 'accept' // changed node that settled; the reviewer accepts the existing result\n | 'add' // new node; starts pending\n | 'remove'; // source node dropped by the new definition\nexport interface MigrationPlanEntry {\n readonly action: MigrationAction;\n /** Node id in the target definition (absent for `remove`). */\n readonly target?: string;\n /** Node id in the source definition (absent for `add`). */\n readonly source?: string;\n readonly status?: string;\n}\nexport interface MigrationBlocker { readonly node: string; readonly reason: string }\nexport interface MigrationPlan {\n readonly migrationId: string;\n readonly format: string;\n readonly runId: string;\n readonly fromDigest: string;\n readonly toDigest: string;\n readonly entries: readonly MigrationPlanEntry[];\n readonly blockers: readonly MigrationBlocker[];\n readonly allowed: boolean;\n}\n\n/** Statuses of a step that has not started and holds nothing. */\nconst unstarted = new Set(['pending']);\n/** Statuses of a step parked on an external decision; a changed definition re-issues the request. */\nconst parked = new Set(['waiting', 'approved', 'forward_waiting', 'compensation_waiting']);\n/** Statuses with work possibly in flight or with an unresolved effect; never changed, removed or renamed. */\nconst inFlight = new Set(['dispatching', 'unknown', 'leased', 'started', 'running']);\n/** Successfully settled statuses that dependent steps may build on (a bypassed lifecycle step never ran; its output is null). */\nconst succeeded = new Set(['succeeded', 'compensated', 'bypassed']);\n/** A step whose condition did not hold: it holds nothing, so a changed definition decides the condition again. */\nconst reconsidered = new Set(['bypassed']);\n\nconst identifier = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;\nconst nodePattern = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;\n/** Migration ids appear in URLs and audit events: no separators. */\nconst migrationIdPattern = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;\n\nexport function defineWorkflowMigration<F, T>(options: WorkflowMigrationOptions<F, T>): WorkflowMigration<F, T> {\n try {\n if (!options || typeof options !== 'object' || typeof options.id !== 'string' || !migrationIdPattern.test(options.id) || !options.from || !options.to) throw new Error();\n const renames = Object.entries(options.renames ?? {});\n if (renames.length > 256 || renames.some(([to, from]) => !nodePattern.test(to) || typeof from !== 'string' || !nodePattern.test(from))\n || new Set(renames.map(([, from]) => from)).size !== renames.length) throw new Error();\n const list = (value: unknown): string[] => {\n if (value === undefined) return [];\n if (!Array.isArray(value) || value.length > 256 || value.some(item => typeof item !== 'string' || !nodePattern.test(item))) throw new Error();\n return [...new Set(value as string[])].sort();\n };\n const description = options.description ?? '';\n if (typeof description !== 'string' || description.length > 2_048) throw new Error();\n return Object.freeze({ kind: 'mayura.workflow-migration' as const, id: options.id, from: options.from, to: options.to,\n renames: Object.freeze(Object.fromEntries(renames)), acceptCompleted: Object.freeze(list(options.acceptCompleted)),\n acceptRemoved: Object.freeze(list(options.acceptRemoved)), description });\n } catch { throw new MayuraError('INVALID_CONFIG', 'A workflow migration needs a bounded id, both definitions, and bounded node lists.'); }\n}\n\nexport function assertWorkflowMigration(value: unknown): asserts value is WorkflowMigration {\n if (!value || typeof value !== 'object' || (value as WorkflowMigration).kind !== 'mayura.workflow-migration' || !Object.isFrozen(value)) {\n throw new MayuraError('INVALID_CONFIG', 'A genuine defineWorkflowMigration value is required.');\n }\n}\n\n/** Canonical fingerprint of one manifest node: every field except the node's id. */\nexport function nodeFingerprint(node: Readonly<Record<string, unknown>>): string {\n const { id: _id, ...rest } = node; void _id;\n return digest('mayura:migration-node:v1', freezeJson(jsonValue(rest)) as JsonValue);\n}\n\n/**\n * Decide, from the run's real state, what a migration does to each node. The format migrator applies the entries only\n * when `allowed`; blockers explain every refusal.\n */\nexport function planWorkflowMigration(input: {\n readonly migration: WorkflowMigration; readonly format: string; readonly runId: string; readonly fromDigest: string; readonly toDigest: string;\n readonly from: readonly MigrationNode[]; readonly to: readonly MigrationNode[]; readonly steps: readonly MigrationStep[];\n /** Format-level refusals found before node planning (for example: run not paused, run is a wait target). */\n readonly preconditions?: readonly MigrationBlocker[];\n}): MigrationPlan {\n const { migration } = input;\n const source = new Map(input.from.map(node => [node.id, node])); const target = new Map(input.to.map(node => [node.id, node]));\n const status = new Map(input.steps.map(step => [step.id, step.status]));\n const blockers: MigrationBlocker[] = [...(input.preconditions ?? [])]; const entries: MigrationPlanEntry[] = [];\n const renamed = new Map(Object.entries(migration.renames)); const renamedSources = new Set(renamed.values());\n const accepted = new Set(migration.acceptCompleted); const removable = new Set(migration.acceptRemoved);\n if (input.fromDigest === input.toDigest) blockers.push({ node: '*', reason: 'The source and target definitions are identical.' });\n for (const [to, from] of renamed) {\n if (!target.has(to)) blockers.push({ node: to, reason: 'A rename targets a node the new definition does not have.' });\n if (!source.has(from)) blockers.push({ node: from, reason: 'A rename names a source node the old definition does not have.' });\n if (source.has(to) && to !== from) blockers.push({ node: to, reason: 'A rename cannot target a node id that still exists in the old definition.' });\n }\n for (const id of accepted) if (!target.has(id)) blockers.push({ node: id, reason: 'acceptCompleted names a node the new definition does not have.' });\n for (const id of removable) if (!source.has(id) || target.has(id)) blockers.push({ node: id, reason: 'acceptRemoved names a node that is not removed.' });\n\n const carried = new Map<string, string>(); // target id -> effective carried status\n for (const node of input.to) {\n const from = renamed.get(node.id) ?? (source.has(node.id) && !renamedSources.has(node.id) ? node.id : undefined);\n if (from === undefined) { entries.push({ action: 'add', target: node.id }); carried.set(node.id, 'pending'); continue; }\n const previous = source.get(from); const current = status.get(from) ?? 'pending';\n if (!previous) continue;\n const changed = previous.fingerprint !== node.fingerprint || previous.kind !== node.kind || from !== node.id;\n if (inFlight.has(current)) {\n if (changed) blockers.push({ node: node.id, reason: `Step \"${from}\" is ${current}; a step with work in flight or an unresolved effect cannot change.` });\n entries.push({ action: 'keep', target: node.id, source: from, status: current }); carried.set(node.id, current); continue;\n }\n if (!changed) { entries.push({ action: 'keep', target: node.id, source: from, status: current }); carried.set(node.id, current); continue; }\n if (previous.kind !== node.kind && !unstarted.has(current)) {\n blockers.push({ node: node.id, reason: `Step \"${from}\" already started as a ${previous.kind} and cannot become a ${node.kind}.` }); carried.set(node.id, current); continue;\n }\n if (unstarted.has(current)) { entries.push({ action: 'update', target: node.id, source: from, status: current }); carried.set(node.id, 'pending'); continue; }\n if (parked.has(current) || reconsidered.has(current)) { entries.push({ action: 'reset', target: node.id, source: from, status: current }); carried.set(node.id, 'pending'); continue; }\n // Blocked nodes still count with their current status below, so dependents report only root causes.\n if (from !== node.id) { blockers.push({ node: node.id, reason: `Step \"${from}\" already settled (${current}); settled steps cannot be renamed.` }); carried.set(node.id, current); continue; }\n if (!accepted.has(node.id)) {\n blockers.push({ node: node.id, reason: `Step \"${from}\" already settled (${current}) and its definition changed; list it in acceptCompleted to keep the existing result.` });\n carried.set(node.id, current); continue;\n }\n // A recorded result stays bound to what produced it: a receipt from one tool cannot stand for another tool.\n if (previous.evidence !== node.evidence) {\n blockers.push({ node: node.id, reason: `Step \"${from}\" settled (${current}) under ${previous.evidence ?? 'another definition'}; the new definition names ${node.evidence ?? 'something else'}, so its result cannot be accepted.` });\n carried.set(node.id, current); continue;\n }\n entries.push({ action: 'accept', target: node.id, source: from, status: current }); carried.set(node.id, current);\n }\n for (const node of input.from) {\n const kept = target.has(node.id) && !renamedSources.has(node.id) && !renamed.has(node.id);\n if (kept || renamedSources.has(node.id)) continue;\n const current = status.get(node.id) ?? 'pending';\n if (inFlight.has(current)) blockers.push({ node: node.id, reason: `Step \"${node.id}\" is ${current} and cannot be removed.` });\n else if (!unstarted.has(current) && !parked.has(current) && current !== 'skipped' && !reconsidered.has(current) && !removable.has(node.id)) {\n blockers.push({ node: node.id, reason: `Step \"${node.id}\" already settled (${current}); list it in acceptRemoved to drop its result.` });\n } else entries.push({ action: 'remove', source: node.id, status: current });\n }\n // A step that keeps a started or settled state must have dependencies that already succeeded under the new graph.\n for (const node of input.to) {\n const current = carried.get(node.id);\n if (current === undefined || unstarted.has(current)) continue;\n for (const dependency of node.dependsOn) {\n const dependencyStatus = carried.get(dependency) ?? 'pending';\n if (!succeeded.has(dependencyStatus)) blockers.push({ node: node.id, reason: `Step \"${node.id}\" is ${current} but its new dependency \"${dependency}\" has not succeeded.` });\n }\n }\n return freezeJson(jsonValue({ migrationId: migration.id, format: input.format, runId: input.runId, fromDigest: input.fromDigest, toDigest: input.toDigest,\n entries, blockers, allowed: blockers.length === 0 })) as unknown as MigrationPlan;\n}\n\n/** Result of a migration request: always the plan; the migrated snapshot unless it was a dry run. */\nexport interface WorkflowMigrationResult<S> { readonly plan: MigrationPlan; readonly snapshot?: S }\n\n/** Audit event payload recorded with every applied migration. */\nexport function migrationEvent(plan: MigrationPlan, actorId: string, commandId: string): { readonly type: 'run.migrated'; readonly data: Record<string, JsonValue> } {\n return { type: 'run.migrated', data: { migrationId: plan.migrationId, from: plan.fromDigest, to: plan.toDigest, actorId, commandId,\n actions: plan.entries.map(entry => `${entry.action}:${entry.target ?? entry.source}`).join(',').slice(0, 2_048) } };\n}\n\n/** Reject a plan with blockers, surfacing the first reason. */\nexport function assertMigrationAllowed(plan: MigrationPlan): void {\n if (!plan.allowed) throw new MayuraError('CONFLICT', `Migration refused: ${plan.blockers[0]?.reason ?? 'unknown reason'}`);\n}\n\n/** Identity of the actor and command applying a migration; both are recorded in the audit event. */\nexport interface MigrationCommand { readonly id: string; readonly actorId: string; readonly commandId: string; readonly dryRun?: boolean }\nexport function migrationCommand(value: MigrationCommand): MigrationCommand {\n if (!value || typeof value !== 'object' || typeof value.id !== 'string' || !/^[a-f0-9]{64}$/.test(value.id) || typeof value.actorId !== 'string' || !identifier.test(value.actorId)\n || typeof value.commandId !== 'string' || !identifier.test(value.commandId) || (value.dryRun !== undefined && typeof value.dryRun !== 'boolean')) {\n throw new MayuraError('INVALID_INPUT', 'A migration command needs a run id, a bounded actor id and a bounded command id.');\n }\n return value;\n}\n\n/** Reviewed migrations a host offers, indexed by source definition digest. */\nexport interface WorkflowMigrationCatalog<M extends WorkflowMigration = WorkflowMigration> {\n /** Migrations whose source is the given pinned definition digest, in registration order. */\n from(definitionHash: string): readonly M[];\n get(id: string): M | undefined;\n readonly all: readonly M[];\n}\nexport function createWorkflowMigrationCatalog<M extends WorkflowMigration>(migrations: readonly M[]): WorkflowMigrationCatalog<M> {\n if (!Array.isArray(migrations) || migrations.length > 1_024) throw new MayuraError('INVALID_CONFIG', 'A migration catalog holds at most 1,024 migrations.');\n const byId = new Map<string, M>(); const bySource = new Map<string, M[]>();\n for (const migration of migrations) {\n const candidate: unknown = migration; assertWorkflowMigration(candidate);\n const from = (migration.from as { readonly digest?: unknown }).digest; const to = (migration.to as { readonly digest?: unknown }).digest;\n if (typeof from !== 'string' || typeof to !== 'string' || from === to) throw new MayuraError('INVALID_CONFIG', `Migration \"${migration.id}\" must connect two different definition versions.`);\n if (byId.has(migration.id)) throw new MayuraError('INVALID_CONFIG', `Migration id \"${migration.id}\" is registered twice.`);\n byId.set(migration.id, migration); bySource.set(from, [...(bySource.get(from) ?? []), migration]);\n }\n return Object.freeze({ from: (definitionHash: string) => Object.freeze([...(bySource.get(definitionHash) ?? [])]),\n get: (id: string) => byId.get(id), all: Object.freeze([...migrations]) });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../src/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAqCzC,+HAA+H;AAC/H,MAAM,UAAU,YAAY,CAAC,IAAyF;IACpH,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;IACtF,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,YAAY,KAAK,IAAI,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,WAAW,CAAC;IAChK,OAAO,SAAS,CAAC;AACnB,CAAC;AA+BD,iEAAiE;AACjE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AACvC,qGAAqG;AACrG,MAAM,MAAM,GAAG,IAAI,GAAG,CA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AAQ,IAAI,IAAI,KAAK,EAAE;YAAE,MAAM,IAAI,WAAW,CAAC,gBAAgB,EAAE,cAAc,SAAS,CAAC,EAAE,mDAAmD,CAAC,CAAC;QAC9L,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAAE,MAAM,IAAI,WAAW,CAAC,gBAAgB,EAAE,iBAAiB,SAAS,CAAC,EAAE,wBAAwB,CAAC,CAAC;QAC3H,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IACpG,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,cAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/G,GAAG,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import { MayuraError, freezeJson, jsonValue, type JsonValue } from '@mayura/core';\nimport { digest } from './definition.js';\n\n/**\n * Reviewed in-place migration of an in-flight durable run from one definition version to another. The migration is a\n * declaration; the framework decides what is safe from the run's actual state and refuses everything else.\n */\nexport interface WorkflowMigrationOptions<F, T> {\n /** Stable identity recorded in the run's audit trail, for example `invoice-review-1-to-2` (letters, digits, `.`, `_`, `-`). */\n readonly id: string;\n readonly from: F;\n readonly to: T;\n /** Target node id -> source node id, for steps that were renamed. Only unstarted or waiting steps can be renamed. */\n readonly renames?: Readonly<Record<string, string>>;\n /** Target node ids whose definition changed but whose settled source result the reviewer accepts as-is. */\n readonly acceptCompleted?: readonly string[];\n /** Source node ids that settled and are removed by the new definition; the reviewer accepts dropping their results. */\n readonly acceptRemoved?: readonly string[];\n readonly description?: string;\n}\nexport interface WorkflowMigration<F = unknown, T = unknown> {\n readonly kind: 'mayura.workflow-migration';\n readonly id: string;\n readonly from: F;\n readonly to: T;\n readonly renames: Readonly<Record<string, string>>;\n readonly acceptCompleted: readonly string[];\n readonly acceptRemoved: readonly string[];\n readonly description: string;\n}\n\n/**\n * One node of a definition, reduced to what a migration compares. `fingerprint` covers the node's full definition.\n * `evidence` names what a settled step's recorded state is bound to (for a tool step, the tool its receipt names):\n * a changed node can only accept an existing result when this is unchanged.\n */\nexport interface MigrationNode { readonly id: string; readonly kind: string; readonly dependsOn: readonly string[]; readonly fingerprint: string; readonly evidence?: string }\n\n/** Evidence of a manifest node: the tool a receipt must name, or whether a human request or signal step carries a deadline. */\nexport function nodeEvidence(node: { readonly kind: string; readonly tool?: unknown; readonly deadlineAtMs?: unknown }): string | undefined {\n if (node.kind === 'tool' && typeof node.tool === 'string') return `tool:${node.tool}`;\n if (node.kind === 'human' || node.kind === 'signal') return node.deadlineAtMs === null || node.deadlineAtMs === undefined ? node.kind : `${node.kind}:deadline`;\n return undefined;\n}\n/** The run's current state of one source step, normalized across formats. */\nexport interface MigrationStep { readonly id: string; readonly status: string }\n\nexport type MigrationAction =\n | 'keep' // unchanged node; state carried\n | 'update' // changed node that never started; carried as pending under the new definition\n | 'reset' // changed node that was waiting (approval, human, timer, signal); re-issued as pending\n | 'accept' // changed node that settled; the reviewer accepts the existing result\n | 'add' // new node; starts pending\n | 'remove'; // source node dropped by the new definition\nexport interface MigrationPlanEntry {\n readonly action: MigrationAction;\n /** Node id in the target definition (absent for `remove`). */\n readonly target?: string;\n /** Node id in the source definition (absent for `add`). */\n readonly source?: string;\n readonly status?: string;\n}\nexport interface MigrationBlocker { readonly node: string; readonly reason: string }\nexport interface MigrationPlan {\n readonly migrationId: string;\n readonly format: string;\n readonly runId: string;\n readonly fromDigest: string;\n readonly toDigest: string;\n readonly entries: readonly MigrationPlanEntry[];\n readonly blockers: readonly MigrationBlocker[];\n readonly allowed: boolean;\n}\n\n/** Statuses of a step that has not started and holds nothing. */\nconst unstarted = new Set(['pending']);\n/** Statuses of a step parked on an external decision; a changed definition re-issues the request. */\nconst parked = new Set(['waiting', 'approved', 'forward_waiting', 'compensation_waiting']);\n/** Statuses with work possibly in flight or with an unresolved effect; never changed, removed or renamed. */\nconst inFlight = new Set(['dispatching', 'unknown', 'leased', 'started', 'running']);\n/** Successfully settled statuses that dependent steps may build on (a bypassed lifecycle step never ran; its output is null). */\nconst succeeded = new Set(['succeeded', 'compensated', 'bypassed']);\n/** A step whose condition did not hold: it holds nothing, so a changed definition decides the condition again. */\nconst reconsidered = new Set(['bypassed']);\n\nconst identifier = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;\nconst nodePattern = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;\n/** Migration ids appear in URLs and audit events: no separators. */\nconst migrationIdPattern = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;\n\nexport function defineWorkflowMigration<F, T>(options: WorkflowMigrationOptions<F, T>): WorkflowMigration<F, T> {\n try {\n if (!options || typeof options !== 'object' || typeof options.id !== 'string' || !migrationIdPattern.test(options.id) || !options.from || !options.to) throw new Error();\n const renames = Object.entries(options.renames ?? {});\n if (renames.length > 256 || renames.some(([to, from]) => !nodePattern.test(to) || typeof from !== 'string' || !nodePattern.test(from))\n || new Set(renames.map(([, from]) => from)).size !== renames.length) throw new Error();\n const list = (value: unknown): string[] => {\n if (value === undefined) return [];\n if (!Array.isArray(value) || value.length > 256 || value.some(item => typeof item !== 'string' || !nodePattern.test(item))) throw new Error();\n return [...new Set(value as string[])].sort();\n };\n const description = options.description ?? '';\n if (typeof description !== 'string' || description.length > 2_048) throw new Error();\n return Object.freeze({ kind: 'mayura.workflow-migration' as const, id: options.id, from: options.from, to: options.to,\n renames: Object.freeze(Object.fromEntries(renames)), acceptCompleted: Object.freeze(list(options.acceptCompleted)),\n acceptRemoved: Object.freeze(list(options.acceptRemoved)), description });\n } catch { throw new MayuraError('INVALID_CONFIG', 'A workflow migration needs a bounded id, both definitions, and bounded node lists.'); }\n}\n\nexport function assertWorkflowMigration(value: unknown): asserts value is WorkflowMigration {\n if (!value || typeof value !== 'object' || (value as WorkflowMigration).kind !== 'mayura.workflow-migration' || !Object.isFrozen(value)) {\n throw new MayuraError('INVALID_CONFIG', 'A genuine defineWorkflowMigration value is required.');\n }\n}\n\n/** Canonical fingerprint of one manifest node: every field except the node's id. */\nexport function nodeFingerprint(node: Readonly<Record<string, unknown>>): string {\n const { id: _id, ...rest } = node; void _id;\n return digest('mayura:migration-node:v1', freezeJson(jsonValue(rest)) as JsonValue);\n}\n\n/**\n * Decide, from the run's real state, what a migration does to each node. The format migrator applies the entries only\n * when `allowed`; blockers explain every refusal.\n */\nexport function planWorkflowMigration(input: {\n readonly migration: WorkflowMigration; readonly format: string; readonly runId: string; readonly fromDigest: string; readonly toDigest: string;\n readonly from: readonly MigrationNode[]; readonly to: readonly MigrationNode[]; readonly steps: readonly MigrationStep[];\n /** Format-level refusals found before node planning (for example: run not paused, run is a wait target). */\n readonly preconditions?: readonly MigrationBlocker[];\n}): MigrationPlan {\n const { migration } = input;\n const source = new Map(input.from.map(node => [node.id, node])); const target = new Map(input.to.map(node => [node.id, node]));\n const status = new Map(input.steps.map(step => [step.id, step.status]));\n const blockers: MigrationBlocker[] = [...(input.preconditions ?? [])]; const entries: MigrationPlanEntry[] = [];\n const renamed = new Map(Object.entries(migration.renames)); const renamedSources = new Set(renamed.values());\n const accepted = new Set(migration.acceptCompleted); const removable = new Set(migration.acceptRemoved);\n if (input.fromDigest === input.toDigest) blockers.push({ node: '*', reason: 'The source and target definitions are identical.' });\n for (const [to, from] of renamed) {\n if (!target.has(to)) blockers.push({ node: to, reason: 'A rename targets a node the new definition does not have.' });\n if (!source.has(from)) blockers.push({ node: from, reason: 'A rename names a source node the old definition does not have.' });\n if (source.has(to) && to !== from) blockers.push({ node: to, reason: 'A rename cannot target a node id that still exists in the old definition.' });\n }\n for (const id of accepted) if (!target.has(id)) blockers.push({ node: id, reason: 'acceptCompleted names a node the new definition does not have.' });\n for (const id of removable) if (!source.has(id) || target.has(id)) blockers.push({ node: id, reason: 'acceptRemoved names a node that is not removed.' });\n\n const carried = new Map<string, string>(); // target id -> effective carried status\n for (const node of input.to) {\n const from = renamed.get(node.id) ?? (source.has(node.id) && !renamedSources.has(node.id) ? node.id : undefined);\n if (from === undefined) { entries.push({ action: 'add', target: node.id }); carried.set(node.id, 'pending'); continue; }\n const previous = source.get(from); const current = status.get(from) ?? 'pending';\n if (!previous) continue;\n const changed = previous.fingerprint !== node.fingerprint || previous.kind !== node.kind || from !== node.id;\n if (inFlight.has(current)) {\n if (changed) blockers.push({ node: node.id, reason: `Step \"${from}\" is ${current}; a step with work in flight or an unresolved effect cannot change.` });\n entries.push({ action: 'keep', target: node.id, source: from, status: current }); carried.set(node.id, current); continue;\n }\n if (!changed) { entries.push({ action: 'keep', target: node.id, source: from, status: current }); carried.set(node.id, current); continue; }\n if (previous.kind !== node.kind && !unstarted.has(current)) {\n blockers.push({ node: node.id, reason: `Step \"${from}\" already started as a ${previous.kind} and cannot become a ${node.kind}.` }); carried.set(node.id, current); continue;\n }\n if (unstarted.has(current)) { entries.push({ action: 'update', target: node.id, source: from, status: current }); carried.set(node.id, 'pending'); continue; }\n if (parked.has(current) || reconsidered.has(current)) { entries.push({ action: 'reset', target: node.id, source: from, status: current }); carried.set(node.id, 'pending'); continue; }\n // Blocked nodes still count with their current status below, so dependents report only root causes.\n if (from !== node.id) { blockers.push({ node: node.id, reason: `Step \"${from}\" already settled (${current}); settled steps cannot be renamed.` }); carried.set(node.id, current); continue; }\n if (!accepted.has(node.id)) {\n blockers.push({ node: node.id, reason: `Step \"${from}\" already settled (${current}) and its definition changed; list it in acceptCompleted to keep the existing result.` });\n carried.set(node.id, current); continue;\n }\n // A recorded result stays bound to what produced it: a receipt from one tool cannot stand for another tool.\n if (previous.evidence !== node.evidence) {\n blockers.push({ node: node.id, reason: `Step \"${from}\" settled (${current}) under ${previous.evidence ?? 'another definition'}; the new definition names ${node.evidence ?? 'something else'}, so its result cannot be accepted.` });\n carried.set(node.id, current); continue;\n }\n entries.push({ action: 'accept', target: node.id, source: from, status: current }); carried.set(node.id, current);\n }\n for (const node of input.from) {\n const kept = target.has(node.id) && !renamedSources.has(node.id) && !renamed.has(node.id);\n if (kept || renamedSources.has(node.id)) continue;\n const current = status.get(node.id) ?? 'pending';\n if (inFlight.has(current)) blockers.push({ node: node.id, reason: `Step \"${node.id}\" is ${current} and cannot be removed.` });\n else if (!unstarted.has(current) && !parked.has(current) && current !== 'skipped' && !reconsidered.has(current) && !removable.has(node.id)) {\n blockers.push({ node: node.id, reason: `Step \"${node.id}\" already settled (${current}); list it in acceptRemoved to drop its result.` });\n } else entries.push({ action: 'remove', source: node.id, status: current });\n }\n // A step that keeps a started or settled state must have dependencies that already succeeded under the new graph.\n for (const node of input.to) {\n const current = carried.get(node.id);\n if (current === undefined || unstarted.has(current)) continue;\n for (const dependency of node.dependsOn) {\n const dependencyStatus = carried.get(dependency) ?? 'pending';\n if (!succeeded.has(dependencyStatus)) blockers.push({ node: node.id, reason: `Step \"${node.id}\" is ${current} but its new dependency \"${dependency}\" has not succeeded.` });\n }\n }\n return freezeJson(jsonValue({ migrationId: migration.id, format: input.format, runId: input.runId, fromDigest: input.fromDigest, toDigest: input.toDigest,\n entries, blockers, allowed: blockers.length === 0 })) as unknown as MigrationPlan;\n}\n\n/** Result of a migration request: always the plan; the migrated snapshot unless it was a dry run. */\nexport interface WorkflowMigrationResult<S> { readonly plan: MigrationPlan; readonly snapshot?: S }\n\n/** Audit event payload recorded with every applied migration. */\nexport function migrationEvent(plan: MigrationPlan, actorId: string, commandId: string): { readonly type: 'run.migrated'; readonly data: Record<string, JsonValue> } {\n return { type: 'run.migrated', data: { migrationId: plan.migrationId, from: plan.fromDigest, to: plan.toDigest, actorId, commandId,\n actions: plan.entries.map(entry => `${entry.action}:${entry.target ?? entry.source}`).join(',').slice(0, 2_048) } };\n}\n\n/** Reject a plan with blockers, surfacing the first reason. */\nexport function assertMigrationAllowed(plan: MigrationPlan): void {\n if (!plan.allowed) throw new MayuraError('CONFLICT', `Migration refused: ${plan.blockers[0]?.reason ?? 'unknown reason'}`);\n}\n\n/** Identity of the actor and command applying a migration; both are recorded in the audit event. */\nexport interface MigrationCommand { readonly id: string; readonly actorId: string; readonly commandId: string; readonly dryRun?: boolean }\nexport function migrationCommand(value: MigrationCommand): MigrationCommand {\n if (!value || typeof value !== 'object' || typeof value.id !== 'string' || !/^[a-f0-9]{64}$/.test(value.id) || typeof value.actorId !== 'string' || !identifier.test(value.actorId)\n || typeof value.commandId !== 'string' || !identifier.test(value.commandId) || (value.dryRun !== undefined && typeof value.dryRun !== 'boolean')) {\n throw new MayuraError('INVALID_INPUT', 'A migration command needs a run id, a bounded actor id and a bounded command id.');\n }\n return value;\n}\n\n/** Reviewed migrations a host offers, indexed by source definition digest. */\nexport interface WorkflowMigrationCatalog<M extends WorkflowMigration = WorkflowMigration> {\n /** Migrations whose source is the given pinned definition digest, in registration order. */\n from(definitionHash: string): readonly M[];\n get(id: string): M | undefined;\n readonly all: readonly M[];\n}\nexport function createWorkflowMigrationCatalog<M extends WorkflowMigration>(migrations: readonly M[]): WorkflowMigrationCatalog<M> {\n if (!Array.isArray(migrations) || migrations.length > 1_024) throw new MayuraError('INVALID_CONFIG', 'A migration catalog holds at most 1,024 migrations.');\n const byId = new Map<string, M>(); const bySource = new Map<string, M[]>();\n for (const migration of migrations) {\n const candidate: unknown = migration; assertWorkflowMigration(candidate);\n const from = (migration.from as { readonly digest?: unknown }).digest; const to = (migration.to as { readonly digest?: unknown }).digest;\n if (typeof from !== 'string' || typeof to !== 'string' || from === to) throw new MayuraError('INVALID_CONFIG', `Migration \"${migration.id}\" must connect two different definition versions.`);\n if (byId.has(migration.id)) throw new MayuraError('INVALID_CONFIG', `Migration id \"${migration.id}\" is registered twice.`);\n byId.set(migration.id, migration); bySource.set(from, [...(bySource.get(from) ?? []), migration]);\n }\n return Object.freeze({ from: (definitionHash: string) => Object.freeze([...(bySource.get(definitionHash) ?? [])]),\n get: (id: string) => byId.get(id), all: Object.freeze([...migrations]) });\n}\n"]}
|