@atolis-hq/wake 0.2.97 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/activities/agent/agent-activity-definition.js +26 -0
- package/dist/src/activities/agent/agent-activity.js +171 -0
- package/dist/src/activities/agent/agent-result.js +149 -0
- package/dist/src/activities/contracts/activity.js +10 -0
- package/dist/src/activities/contracts/config.js +2 -0
- package/dist/src/activities/contracts/event-schema.js +302 -0
- package/dist/src/activities/contracts/events.js +42 -0
- package/dist/src/activities/contracts/identifiers.js +29 -0
- package/dist/src/activities/contracts/registry.js +71 -0
- package/dist/src/activities/contracts/streams.js +17 -0
- package/dist/src/activities/contracts/vocabulary.js +58 -0
- package/dist/src/activities/index.js +21 -0
- package/dist/src/activities/pr/activity-support.js +111 -0
- package/dist/src/activities/pr/application.js +158 -0
- package/dist/src/activities/pr/approve.js +85 -0
- package/dist/src/activities/pr/capability.js +11 -0
- package/dist/src/activities/pr/decision-claim.js +76 -0
- package/dist/src/activities/pr/event-drafts.js +66 -0
- package/dist/src/activities/pr/intent.js +37 -0
- package/dist/src/activities/pr/merge-authority-gate.js +14 -0
- package/dist/src/activities/pr/merge.js +110 -0
- package/dist/src/activities/pr/policy.js +135 -0
- package/dist/src/activities/pr/projection.js +130 -0
- package/dist/src/activities/pr/vocabulary.js +30 -0
- package/dist/src/activities/review/authorization.js +22 -0
- package/dist/src/activities/review/contracts.js +22 -0
- package/dist/src/activities/review/signals.js +3 -0
- package/dist/src/bootstrap/analytics-projection.js +26 -0
- package/dist/src/bootstrap/board-projection.js +337 -0
- package/dist/src/bootstrap/composition-root.js +382 -0
- package/dist/src/bootstrap/config/load-config.js +51 -0
- package/dist/src/bootstrap/config/root-schema.js +134 -0
- package/dist/src/bootstrap/external-ref.js +12 -0
- package/dist/src/bootstrap/fake-provider-files.js +44 -0
- package/dist/src/bootstrap/fake-scenarios.js +22 -0
- package/dist/src/bootstrap/index.js +48 -0
- package/dist/src/bootstrap/initialise.js +434 -0
- package/dist/src/bootstrap/paths.js +15 -0
- package/dist/src/bootstrap/projection-runtime.js +27 -0
- package/dist/src/bootstrap/runner-quota-reporter.js +21 -0
- package/dist/src/bootstrap/runner-registry.js +30 -0
- package/dist/src/bootstrap/schedule-checkpoint-store.js +49 -0
- package/dist/src/bootstrap/self-update-application.js +195 -0
- package/dist/src/bootstrap/self-update-failure-log.js +33 -0
- package/dist/src/bootstrap/source-update-port.js +47 -0
- package/dist/src/bootstrap/status-publish-activity.js +42 -0
- package/dist/src/bootstrap/surface-api-applications.js +325 -0
- package/dist/src/bootstrap/surface-api-execution-applications.js +95 -0
- package/dist/src/bootstrap/surface-api-metadata.js +12 -0
- package/dist/src/bootstrap/surface-api-projection-pages.js +22 -0
- package/dist/src/bootstrap/surface-api-run-context.js +5 -0
- package/dist/src/bootstrap/surface-api-transcripts.js +57 -0
- package/dist/src/bootstrap/surface-api-work-applications.js +199 -0
- package/dist/src/bootstrap/surface-applications.js +7 -0
- package/dist/src/bootstrap/surface-cli-applications.js +701 -0
- package/dist/src/bootstrap/update-ledger.js +61 -0
- package/dist/src/bootstrap/update-maintenance-lease.js +176 -0
- package/dist/src/{version.js → bootstrap/version.js} +35 -51
- package/dist/src/control-plane/application/advance-once.js +184 -0
- package/dist/src/control-plane/application/control-plane-projection.js +42 -0
- package/dist/src/control-plane/application/control-plane-service.js +42 -0
- package/dist/src/control-plane/application/intake-pipeline.js +29 -0
- package/dist/src/control-plane/application/runner-control-service.js +66 -0
- package/dist/src/control-plane/application/runner-pipeline.js +57 -0
- package/dist/src/control-plane/application/schedule-service.js +47 -0
- package/dist/src/control-plane/application/work-cancellation-policy.js +31 -0
- package/dist/src/control-plane/contracts/commands.js +10 -0
- package/dist/src/control-plane/contracts/config.js +22 -0
- package/dist/src/control-plane/contracts/events.js +81 -0
- package/dist/src/control-plane/contracts/streams.js +5 -0
- package/dist/src/control-plane/domain/dispatch-policy.js +15 -0
- package/dist/src/control-plane/domain/quota-policy.js +26 -0
- package/dist/src/control-plane/domain/runner-quota.js +35 -0
- package/dist/src/control-plane/domain/schedule-policy.js +46 -0
- package/dist/src/control-plane/index.js +20 -0
- package/dist/src/control-plane/infrastructure/intake-host.js +24 -0
- package/dist/src/control-plane/infrastructure/resident-host.js +45 -0
- package/dist/src/control-plane/infrastructure/tick-host.js +35 -0
- package/dist/src/execution/application/activation-claim.js +50 -0
- package/dist/src/execution/application/active-run-cancellation.js +14 -0
- package/dist/src/execution/application/execution-activity.js +97 -0
- package/dist/src/execution/application/execution-projection.js +17 -0
- package/dist/src/execution/application/execution-service.js +372 -0
- package/dist/src/execution/application/execution-validation.js +26 -0
- package/dist/src/execution/application/recovery-service.js +212 -0
- package/dist/src/execution/application/run-lifecycle.js +115 -0
- package/dist/src/execution/application/run-liveness-service.js +80 -0
- package/dist/src/execution/application/run-repository.js +27 -0
- package/dist/src/execution/contracts/commands.js +1 -0
- package/dist/src/execution/contracts/config.js +35 -0
- package/dist/src/execution/contracts/control-plane.js +1 -0
- package/dist/src/execution/contracts/event-factory.js +53 -0
- package/dist/src/execution/contracts/events.js +274 -0
- package/dist/src/execution/contracts/identifiers.js +5 -0
- package/dist/src/execution/contracts/liveness.js +1 -0
- package/dist/src/execution/contracts/results.js +1 -0
- package/dist/src/execution/contracts/runner.js +15 -0
- package/dist/src/execution/contracts/streams.js +10 -0
- package/dist/src/execution/contracts/views.js +1 -0
- package/dist/src/execution/contracts/vocabulary.js +43 -0
- package/dist/src/execution/contracts/workspace.js +1 -0
- package/dist/src/execution/domain/run-result.js +34 -0
- package/dist/src/execution/domain/run.js +142 -0
- package/dist/src/execution/index.js +31 -0
- package/dist/src/execution/infrastructure/agent-runner-adapter.js +114 -0
- package/dist/src/execution/infrastructure/process-execution.js +29 -0
- package/dist/src/execution/infrastructure/prompt-templates.js +42 -0
- package/dist/src/execution/infrastructure/runners/claude.js +120 -0
- package/dist/src/execution/infrastructure/runners/codex.js +143 -0
- package/dist/src/execution/infrastructure/runners/command.js +4 -0
- package/dist/src/execution/infrastructure/runners/cursor.js +69 -0
- package/dist/src/execution/infrastructure/runners/fake-scenarios.js +99 -0
- package/dist/src/execution/infrastructure/runners/fake.js +65 -0
- package/dist/src/execution/infrastructure/runners/registry.js +26 -0
- package/dist/src/execution/infrastructure/transcript-store.js +223 -0
- package/dist/src/execution/infrastructure/transcripts.js +11 -0
- package/dist/src/execution/infrastructure/workspace/fake-workspace.js +19 -0
- package/dist/src/execution/infrastructure/workspace/git-workspace.js +241 -0
- package/dist/src/integrations/application/agent-run-publication-reactor.js +111 -0
- package/dist/src/integrations/application/artifact-registration-reactor.js +159 -0
- package/dist/src/integrations/application/poll-service.js +25 -0
- package/dist/src/integrations/application/terminal-agent-run-report.js +40 -0
- package/dist/src/integrations/application/work-admission.js +31 -0
- package/dist/src/integrations/application/work-conclusion.js +19 -0
- package/dist/src/integrations/contracts/artifact-events.js +60 -0
- package/dist/src/integrations/contracts/artifact-vocabulary.js +9 -0
- package/dist/src/integrations/contracts/config.js +14 -0
- package/dist/src/integrations/contracts/identifiers.js +5 -0
- package/dist/src/integrations/contracts/intake-rules.js +14 -0
- package/dist/src/integrations/contracts/intake.js +1 -0
- package/dist/src/integrations/contracts/outcome-vocabulary.js +7 -0
- package/dist/src/integrations/contracts/provider.js +37 -0
- package/dist/src/integrations/contracts/streams.js +10 -0
- package/dist/src/integrations/delivery/application/delivery-outcome-reactor.js +75 -0
- package/dist/src/integrations/delivery/application/delivery-projector.js +165 -0
- package/dist/src/integrations/delivery/application/delivery-service.js +173 -0
- package/dist/src/integrations/delivery/contracts/commands.js +1 -0
- package/dist/src/integrations/delivery/contracts/config.js +1 -0
- package/dist/src/integrations/delivery/contracts/event-factory.js +18 -0
- package/dist/src/integrations/delivery/contracts/events.js +86 -0
- package/dist/src/integrations/delivery/contracts/intents.js +89 -0
- package/dist/src/integrations/delivery/contracts/views.js +1 -0
- package/dist/src/integrations/delivery/contracts/vocabulary.js +22 -0
- package/dist/src/integrations/fake/durable-delivery-provider.js +48 -0
- package/dist/src/integrations/fake/external-sink.js +9 -0
- package/dist/src/integrations/fake/external-source.js +44 -0
- package/dist/src/integrations/fake/inbound-translator.js +130 -0
- package/dist/src/integrations/fake/provider.js +95 -0
- package/dist/src/integrations/github/application/agent-context-reader.js +54 -0
- package/dist/src/integrations/github/application/agent-run-comment.js +94 -0
- package/dist/src/integrations/github/application/comment-history-reader.js +43 -0
- package/dist/src/integrations/github/application/inbound-context.js +10 -0
- package/dist/src/integrations/github/application/inbound-review-signals.js +159 -0
- package/dist/src/integrations/github/application/inbound-translator.js +231 -0
- package/dist/src/integrations/github/application/inbound-watch-gate-signals.js +84 -0
- package/dist/src/integrations/github/application/intake-policy.js +23 -0
- package/dist/src/integrations/github/application/outbound-translator.js +47 -0
- package/dist/src/integrations/github/application/poll-service.js +29 -0
- package/dist/src/integrations/github/application/pull-request-translation.js +10 -0
- package/dist/src/integrations/github/application/resource-links.js +8 -0
- package/dist/src/integrations/github/application/review-command-translator.js +16 -0
- package/dist/src/integrations/github/application/wake-labels.js +95 -0
- package/dist/src/integrations/github/contracts/config.js +47 -0
- package/dist/src/integrations/github/contracts/events.js +127 -0
- package/dist/src/integrations/github/contracts/external-key.js +19 -0
- package/dist/src/integrations/github/contracts/payloads.js +9 -0
- package/dist/src/integrations/github/contracts/vocabulary.js +55 -0
- package/dist/src/integrations/github/index.js +31 -0
- package/dist/src/integrations/github/infrastructure/client-reads.js +214 -0
- package/dist/src/integrations/github/infrastructure/client.js +132 -0
- package/dist/src/integrations/github/infrastructure/content-fingerprint.js +10 -0
- package/dist/src/integrations/github/infrastructure/delivery.js +31 -0
- package/dist/src/integrations/github/infrastructure/etag-cache.js +56 -0
- package/dist/src/integrations/github/infrastructure/gh-auth.js +19 -0
- package/dist/src/integrations/github/infrastructure/issue-source.js +109 -0
- package/dist/src/integrations/github/infrastructure/pr-source.js +186 -0
- package/dist/src/integrations/github/infrastructure/review-source.js +70 -0
- package/dist/src/integrations/github/infrastructure/source.js +108 -0
- package/dist/src/integrations/github/provider.js +96 -0
- package/dist/src/integrations/index.js +30 -0
- package/dist/src/kernel/contracts/checkpoint-store.js +1 -0
- package/dist/src/kernel/contracts/clock.js +1 -0
- package/dist/src/kernel/contracts/commands.js +1 -0
- package/dist/src/kernel/contracts/event-journal.js +2 -0
- package/dist/src/kernel/contracts/event-schema.js +54 -0
- package/dist/src/kernel/contracts/events.js +11 -0
- package/dist/src/kernel/contracts/id-generator.js +1 -0
- package/dist/src/kernel/contracts/identifiers.js +8 -0
- package/dist/src/kernel/contracts/projection-store.js +1 -0
- package/dist/src/kernel/contracts/relations.js +1 -0
- package/dist/src/kernel/contracts/schema.js +17 -0
- package/dist/src/kernel/contracts/vocabulary.js +6 -0
- package/dist/src/kernel/domain/event-envelope.js +29 -0
- package/dist/src/kernel/domain/match-mode.js +11 -0
- package/dist/src/kernel/domain/relation.js +10 -0
- package/dist/src/kernel/index.js +17 -0
- package/dist/src/{lib/clock.js → kernel/infrastructure/system-clock.js} +3 -3
- package/dist/src/kernel/infrastructure/ulid-id-generator.js +9 -0
- package/dist/src/main.js +137 -1030
- package/dist/src/orchestration/application/accept-activity-outcome.js +25 -0
- package/dist/src/orchestration/application/accept-signal.js +35 -0
- package/dist/src/orchestration/application/advance-workflow.js +160 -0
- package/dist/src/orchestration/application/coordination-claims.js +107 -0
- package/dist/src/orchestration/application/group-budget-recorder.js +43 -0
- package/dist/src/orchestration/application/orchestration-projection.js +20 -0
- package/dist/src/orchestration/application/orchestration-repository.js +36 -0
- package/dist/src/orchestration/application/orchestration-service.js +82 -0
- package/dist/src/orchestration/application/request-child.js +118 -0
- package/dist/src/orchestration/application/signal-reactor.js +17 -0
- package/dist/src/orchestration/application/start-workflow.js +51 -0
- package/dist/src/orchestration/application/watch-reactor.js +82 -0
- package/dist/src/orchestration/contracts/activity-outcome.js +18 -0
- package/dist/src/orchestration/contracts/commands.js +1 -0
- package/dist/src/orchestration/contracts/config.js +128 -0
- package/dist/src/orchestration/contracts/event-decoder.js +263 -0
- package/dist/src/orchestration/contracts/events.js +41 -0
- package/dist/src/orchestration/contracts/identifiers.js +35 -0
- package/dist/src/orchestration/contracts/streams.js +38 -0
- package/dist/src/orchestration/contracts/views.js +1 -0
- package/dist/src/orchestration/contracts/vocabulary.js +30 -0
- package/dist/src/orchestration/domain/activation-policy.js +55 -0
- package/dist/src/orchestration/domain/approval-defaults.js +17 -0
- package/dist/src/orchestration/domain/child-policy.js +63 -0
- package/dist/src/orchestration/domain/compiler.js +162 -0
- package/dist/src/orchestration/domain/coordination-events.js +25 -0
- package/dist/src/orchestration/domain/decision-events.js +47 -0
- package/dist/src/orchestration/domain/interpreter.js +49 -0
- package/dist/src/orchestration/domain/operator-retry-policy.js +34 -0
- package/dist/src/orchestration/domain/retry-policy.js +26 -0
- package/dist/src/orchestration/domain/signal-policy.js +120 -0
- package/dist/src/orchestration/domain/supplemental-policy.js +61 -0
- package/dist/src/orchestration/domain/transition.js +55 -0
- package/dist/src/orchestration/domain/workflow-graph.js +41 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +236 -0
- package/dist/src/orchestration/domain/workflow-instance.js +41 -0
- package/dist/src/orchestration/domain/workflow-selector.js +21 -0
- package/dist/src/orchestration/index.js +19 -0
- package/dist/src/persistence/application/projection-runner.js +79 -0
- package/dist/src/persistence/filesystem/file-checkpoint-store.js +35 -0
- package/dist/src/persistence/filesystem/file-event-journal.js +143 -0
- package/dist/src/persistence/filesystem/file-lock.js +91 -0
- package/dist/src/persistence/filesystem/file-projection-store.js +64 -0
- package/dist/src/persistence/index.js +8 -0
- package/dist/src/persistence/memory/in-memory-checkpoint-store.js +14 -0
- package/dist/src/persistence/memory/in-memory-event-journal.js +88 -0
- package/dist/src/persistence/memory/in-memory-projection-store.js +17 -0
- package/dist/src/resources/application/lookup-projections.js +48 -0
- package/dist/src/resources/application/resource-lookup.js +16 -0
- package/dist/src/resources/application/resource-projections.js +81 -0
- package/dist/src/resources/application/resource-repository.js +18 -0
- package/dist/src/resources/application/resource-service.js +83 -0
- package/dist/src/resources/contracts/commands.js +1 -0
- package/dist/src/resources/contracts/config.js +2 -0
- package/dist/src/resources/contracts/events.js +83 -0
- package/dist/src/resources/contracts/identifiers.js +15 -0
- package/dist/src/resources/contracts/streams.js +6 -0
- package/dist/src/resources/contracts/views.js +1 -0
- package/dist/src/resources/contracts/vocabulary.js +67 -0
- package/dist/src/resources/domain/correlation.js +8 -0
- package/dist/src/resources/domain/resource.js +58 -0
- package/dist/src/resources/index.js +14 -0
- package/dist/src/surfaces/api/contracts/activities.js +1 -0
- package/dist/src/surfaces/api/contracts/board.js +2 -0
- package/dist/src/surfaces/api/contracts/common.js +46 -0
- package/dist/src/surfaces/api/contracts/control-plane.js +5 -0
- package/dist/src/surfaces/api/contracts/events.js +1 -0
- package/dist/src/surfaces/api/contracts/execution.js +1 -0
- package/dist/src/surfaces/api/contracts/index.js +13 -0
- package/dist/src/surfaces/api/contracts/observability.js +1 -0
- package/dist/src/surfaces/api/contracts/orchestration.js +1 -0
- package/dist/src/surfaces/api/contracts/resources.js +1 -0
- package/dist/src/surfaces/api/contracts/status.js +1 -0
- package/dist/src/surfaces/api/contracts/system.js +1 -0
- package/dist/src/surfaces/api/contracts/transport-values.js +39 -0
- package/dist/src/surfaces/api/contracts/work.js +17 -0
- package/dist/src/surfaces/api/http-server.js +121 -0
- package/dist/src/surfaces/api/presenters/activities.js +1 -0
- package/dist/src/surfaces/api/presenters/board.js +3 -0
- package/dist/src/surfaces/api/presenters/control-plane.js +1 -0
- package/dist/src/surfaces/api/presenters/events.js +1 -0
- package/dist/src/surfaces/api/presenters/execution.js +59 -0
- package/dist/src/surfaces/api/presenters/observability.js +1 -0
- package/dist/src/surfaces/api/presenters/orchestration.js +19 -0
- package/dist/src/surfaces/api/presenters/resources.js +15 -0
- package/dist/src/surfaces/api/presenters/status.js +3 -0
- package/dist/src/surfaces/api/presenters/system.js +14 -0
- package/dist/src/surfaces/api/presenters/work.js +16 -0
- package/dist/src/surfaces/api/problem-details.js +9 -0
- package/dist/src/surfaces/api/router.js +13 -0
- package/dist/src/surfaces/api/routes/activities.js +1 -0
- package/dist/src/surfaces/api/routes/applications.js +1 -0
- package/dist/src/surfaces/api/routes/commands.js +82 -0
- package/dist/src/surfaces/api/routes/control-plane.js +6 -0
- package/dist/src/surfaces/api/routes/events.js +1 -0
- package/dist/src/surfaces/api/routes/execution.js +8 -0
- package/dist/src/surfaces/api/routes/index.js +18 -0
- package/dist/src/surfaces/api/routes/observability.js +1 -0
- package/dist/src/surfaces/api/routes/orchestration.js +1 -0
- package/dist/src/surfaces/api/routes/pagination.js +78 -0
- package/dist/src/surfaces/api/routes/read.js +135 -0
- package/dist/src/surfaces/api/routes/resources.js +1 -0
- package/dist/src/surfaces/api/routes/responses.js +67 -0
- package/dist/src/surfaces/api/routes/system.js +1 -0
- package/dist/src/surfaces/api/routes/work.js +9 -0
- package/dist/src/surfaces/cli/commands/api.js +1 -0
- package/dist/src/surfaces/cli/commands/audit.js +10 -0
- package/dist/src/surfaces/cli/commands/correlate.js +2 -0
- package/dist/src/surfaces/cli/commands/doctor.js +6 -0
- package/dist/src/surfaces/cli/commands/init.js +39 -0
- package/dist/src/surfaces/cli/commands/sandbox-entrypoint.js +33 -0
- package/dist/src/surfaces/cli/commands/sandbox-setup.js +29 -0
- package/dist/src/surfaces/cli/commands/sandbox.js +105 -0
- package/dist/src/surfaces/cli/commands/self-update.js +38 -0
- package/dist/src/surfaces/cli/commands/smoke.js +16 -0
- package/dist/src/surfaces/cli/commands/start.js +1 -0
- package/dist/src/surfaces/cli/commands/stop.js +13 -0
- package/dist/src/surfaces/cli/commands/tick.js +1 -0
- package/dist/src/surfaces/cli/commands/ui.js +2 -0
- package/dist/src/surfaces/cli/commands/validate-state.js +5 -0
- package/dist/src/surfaces/cli/infrastructure/docker-cli.js +221 -0
- package/dist/src/surfaces/cli/infrastructure/process-log.js +86 -0
- package/dist/src/surfaces/cli/main.js +140 -0
- package/dist/src/surfaces/cli/usage.js +33 -0
- package/dist/src/surfaces/contracts/config.js +34 -0
- package/dist/src/surfaces/index.js +47 -0
- package/dist/src/surfaces/web-assets/assets/index-Bfn4FwZG.css +1 -0
- package/dist/src/surfaces/web-assets/assets/index-ipB6JPGU.js +1090 -0
- package/dist/src/surfaces/web-assets/index.html +13 -0
- package/dist/src/surfaces/web-host/asset-source.js +1 -0
- package/dist/src/surfaces/web-host/packaged-assets.js +44 -0
- package/dist/src/work/application/work-projection.js +59 -0
- package/dist/src/work/application/work-repository.js +18 -0
- package/dist/src/work/application/work-service.js +117 -0
- package/dist/src/work/contracts/commands.js +1 -0
- package/dist/src/work/contracts/config.js +2 -0
- package/dist/src/work/contracts/events.js +103 -0
- package/dist/src/work/contracts/identifiers.js +5 -0
- package/dist/src/work/contracts/streams.js +6 -0
- package/dist/src/work/contracts/views.js +1 -0
- package/dist/src/work/contracts/vocabulary.js +6 -0
- package/dist/src/work/domain/work-item.js +89 -0
- package/dist/src/work/index.js +11 -0
- package/docker/Dockerfile +10 -6
- package/docker/Dockerfile.packaged +3 -3
- package/package.json +29 -4
- package/prompts/implement.md +2 -2
- package/templates/SETUP.md +7 -7
- package/dist/src/adapters/claude/claude-runner.js +0 -529
- package/dist/src/adapters/codex/codex-runner.js +0 -503
- package/dist/src/adapters/cursor/cursor-runner.js +0 -418
- package/dist/src/adapters/docker/docker-cli.js +0 -150
- package/dist/src/adapters/fake/fake-artifact-verifier.js +0 -14
- package/dist/src/adapters/fake/fake-github-pull-request-activity-source.js +0 -77
- package/dist/src/adapters/fake/fake-resource-index.js +0 -21
- package/dist/src/adapters/fake/fake-runner.js +0 -77
- package/dist/src/adapters/fake/fake-ticketing-system.js +0 -185
- package/dist/src/adapters/fake/fake-workspace-manager.js +0 -81
- package/dist/src/adapters/fs/resource-index.js +0 -126
- package/dist/src/adapters/fs/self-update-ledger.js +0 -17
- package/dist/src/adapters/fs/state-store.js +0 -775
- package/dist/src/adapters/git/git-workspace-manager.js +0 -289
- package/dist/src/adapters/github/github-artifact-verifier.js +0 -38
- package/dist/src/adapters/github/github-auth.js +0 -16
- package/dist/src/adapters/github/github-client.js +0 -249
- package/dist/src/adapters/github/github-etag-cache.js +0 -57
- package/dist/src/adapters/github/github-issues-work-source.js +0 -692
- package/dist/src/adapters/github/github-pull-request-activity-source.js +0 -584
- package/dist/src/adapters/github/github-pull-request-merge-actor.js +0 -45
- package/dist/src/adapters/http/ui-assets.js +0 -1188
- package/dist/src/adapters/http/ui-data.js +0 -1107
- package/dist/src/adapters/http/ui-server.js +0 -458
- package/dist/src/adapters/runner/cli-command.js +0 -73
- package/dist/src/adapters/runner/prompt-templates.js +0 -76
- package/dist/src/adapters/runner/runner-cli-adapter.js +0 -112
- package/dist/src/adapters/runner/runner-registry.js +0 -139
- package/dist/src/adapters/runner/runtime-events.js +0 -32
- package/dist/src/adapters/runner/stage-prompt.js +0 -268
- package/dist/src/adapters/runner/transcripts.js +0 -25
- package/dist/src/cli/audit-command.js +0 -36
- package/dist/src/cli/correlate-command.js +0 -62
- package/dist/src/cli/doctor-command.js +0 -48
- package/dist/src/cli/init-command.js +0 -18
- package/dist/src/cli/sandbox-command.js +0 -258
- package/dist/src/cli/sandbox-entrypoint-command.js +0 -88
- package/dist/src/cli/sandbox-exec-logging.js +0 -7
- package/dist/src/cli/sandbox-resume.js +0 -79
- package/dist/src/cli/sandbox-setup-command.js +0 -31
- package/dist/src/cli/scaffold-assets.js +0 -100
- package/dist/src/cli/self-update-command.js +0 -198
- package/dist/src/cli/startup-preflight.js +0 -134
- package/dist/src/cli/stop-command.js +0 -46
- package/dist/src/cli/ui-command.js +0 -27
- package/dist/src/config/defaults.js +0 -10
- package/dist/src/config/discover-config-files.js +0 -11
- package/dist/src/config/load-config.js +0 -69
- package/dist/src/config/split-config.js +0 -14
- package/dist/src/core/active-run-recovery.js +0 -44
- package/dist/src/core/approval-intents.js +0 -16
- package/dist/src/core/audit-events.js +0 -82
- package/dist/src/core/control-plane.js +0 -192
- package/dist/src/core/event-builders.js +0 -153
- package/dist/src/core/event-resolver.js +0 -249
- package/dist/src/core/lifecycle-service.js +0 -8
- package/dist/src/core/live-execution.js +0 -81
- package/dist/src/core/outbox.js +0 -198
- package/dist/src/core/policy-engine.js +0 -389
- package/dist/src/core/projection-updater.js +0 -693
- package/dist/src/core/quota-backoff.js +0 -69
- package/dist/src/core/run-lease.js +0 -38
- package/dist/src/core/scheduled-workflow-source.js +0 -199
- package/dist/src/core/sink-router.js +0 -107
- package/dist/src/core/stale-run-reconciler.js +0 -352
- package/dist/src/core/tick-runner.js +0 -2442
- package/dist/src/core/workspace-cleanup.js +0 -117
- package/dist/src/domain/branch-naming.js +0 -14
- package/dist/src/domain/custom-commands.js +0 -58
- package/dist/src/domain/event-types.js +0 -158
- package/dist/src/domain/manual-labels.js +0 -1
- package/dist/src/domain/resource-uri.js +0 -38
- package/dist/src/domain/runner-routing.js +0 -127
- package/dist/src/domain/runtime-events.js +0 -36
- package/dist/src/domain/schema.js +0 -1233
- package/dist/src/domain/sources.js +0 -16
- package/dist/src/domain/stages.js +0 -36
- package/dist/src/domain/work-item-labels.js +0 -48
- package/dist/src/domain/work-item-lifecycle.js +0 -10
- package/dist/src/domain/work-item-status.js +0 -33
- package/dist/src/domain/workflows.js +0 -159
- package/dist/src/lib/deep-merge.js +0 -14
- package/dist/src/lib/detached-process-logging.js +0 -46
- package/dist/src/lib/event-log.js +0 -21
- package/dist/src/lib/format.js +0 -41
- package/dist/src/lib/json-file.js +0 -23
- package/dist/src/lib/lock.js +0 -181
- package/dist/src/lib/log-rotation.js +0 -42
- package/dist/src/lib/paths.js +0 -52
- package/dist/src/lib/process-identity.js +0 -54
- package/dist/src/lib/state-health.js +0 -30
- package/dist/src/lib/work-id.js +0 -19
- package/dist/src/lib/yaml-file.js +0 -20
- /package/dist/src/{core → activities/pr}/contracts.js +0 -0
- /package/dist/src/{domain/types.js → control-plane/contracts/views.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineClosedVocabulary } from '../../kernel/index.js';
|
|
2
|
+
export const TransitionTargetKind = defineClosedVocabulary({
|
|
3
|
+
Stage: 'stage',
|
|
4
|
+
Complete: 'complete',
|
|
5
|
+
AwaitSignal: 'await-signal',
|
|
6
|
+
});
|
|
7
|
+
export const WorkflowStatus = defineClosedVocabulary({
|
|
8
|
+
Active: 'active',
|
|
9
|
+
Waiting: 'waiting',
|
|
10
|
+
Completed: 'completed',
|
|
11
|
+
Blocked: 'blocked',
|
|
12
|
+
Superseded: 'superseded',
|
|
13
|
+
});
|
|
14
|
+
export const ActivityActivationStatus = defineClosedVocabulary({
|
|
15
|
+
Pending: 'pending',
|
|
16
|
+
Running: 'running',
|
|
17
|
+
Waiting: 'waiting',
|
|
18
|
+
Completed: 'completed',
|
|
19
|
+
});
|
|
20
|
+
export const WorkflowInstanceKind = defineClosedVocabulary({
|
|
21
|
+
Primary: 'primary',
|
|
22
|
+
Child: 'child',
|
|
23
|
+
});
|
|
24
|
+
// Who may satisfy a wait. Distinct from EventActorKind: that vocabulary answers
|
|
25
|
+
// who emitted an event (provenance); this answers who may open a gate (authority).
|
|
26
|
+
export const ApprovalAuthorityKind = defineClosedVocabulary({
|
|
27
|
+
Human: 'human',
|
|
28
|
+
Auto: 'auto',
|
|
29
|
+
Watch: 'watch',
|
|
30
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
2
|
+
import { childStartMetadata } from './child-policy.js';
|
|
3
|
+
import { childStartDrafts } from './coordination-events.js';
|
|
4
|
+
import { activation, startDraft, stateDraft } from './decision-events.js';
|
|
5
|
+
export function startInstance(input) {
|
|
6
|
+
const stage = input.definition.stages[input.definition.entry];
|
|
7
|
+
const child = childStartMetadata(input);
|
|
8
|
+
const childEvents = child === undefined
|
|
9
|
+
? []
|
|
10
|
+
: childStartDrafts({
|
|
11
|
+
workflowInstanceId: input.workflowInstanceId,
|
|
12
|
+
eventIdPrefix: input.causationId,
|
|
13
|
+
occurredAt: input.occurredAt,
|
|
14
|
+
correlationId: input.correlationId,
|
|
15
|
+
causationId: input.causationId,
|
|
16
|
+
}, child, input.definition.name);
|
|
17
|
+
return {
|
|
18
|
+
kind: 'append',
|
|
19
|
+
events: [
|
|
20
|
+
...childEvents,
|
|
21
|
+
startDraft(input, OrchestrationEventType.InstanceStarted, {
|
|
22
|
+
workItemId: input.workItemId,
|
|
23
|
+
workflowName: input.definition.name,
|
|
24
|
+
orchestrationGroupId: input.orchestrationGroupId,
|
|
25
|
+
entry: input.definition.entry,
|
|
26
|
+
...child,
|
|
27
|
+
}, childEvents.length + 1),
|
|
28
|
+
startDraft(input, OrchestrationEventType.StageEntered, { stage: input.definition.entry }, childEvents.length + 2),
|
|
29
|
+
startDraft(input, OrchestrationEventType.ActivityRequested, activation(input.workflowInstanceId, 1, stage.activity, stage.with, {
|
|
30
|
+
execution: stage.execution,
|
|
31
|
+
stage: input.definition.entry,
|
|
32
|
+
}), childEvents.length + 3),
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function isPendingOutcome(state, input) {
|
|
37
|
+
return (state.pendingActivation !== undefined &&
|
|
38
|
+
state.pendingActivation.activationId === input.activationId &&
|
|
39
|
+
!state.acceptedOutcomes.includes(input.activationId));
|
|
40
|
+
}
|
|
41
|
+
export function acceptOutcomeDraft(state, input) {
|
|
42
|
+
return stateDraft(state, input, OrchestrationEventType.ActivityOutcomeAccepted, { activationId: input.activationId, outcome: input.outcome }, 1);
|
|
43
|
+
}
|
|
44
|
+
export function requestFollowOn(events, state, input, activities) {
|
|
45
|
+
const pending = state.pendingActivation;
|
|
46
|
+
const nextFollowOnIndex = (pending.followOnIndex ?? -1) + 1;
|
|
47
|
+
if (nextFollowOnIndex >= activities.length)
|
|
48
|
+
return false;
|
|
49
|
+
const next = activities[nextFollowOnIndex];
|
|
50
|
+
events.push(stateDraft(state, input, OrchestrationEventType.ActivityRequested, activation(state.workflowInstanceId, pending.ordinal + 1, next.use, next.with, {
|
|
51
|
+
execution: undefined,
|
|
52
|
+
followOnIndex: nextFollowOnIndex,
|
|
53
|
+
}), events.length + 1));
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ActivityOutcomeKind } from '../../activities/index.js';
|
|
2
|
+
import { ApprovalAuthorityKind } from '../contracts/vocabulary.js';
|
|
3
|
+
/**
|
|
4
|
+
* A `done` route with no explicit `await`/`watchGates` requires human
|
|
5
|
+
* approval before advancing by default, since a watchGate is itself an
|
|
6
|
+
* approval-equivalent and an explicit await is already what the author
|
|
7
|
+
* wants. A stage opts out with `requiresApproval: false`.
|
|
8
|
+
*/
|
|
9
|
+
export function defaultApprovalAwait(stage, outcomeKind, route) {
|
|
10
|
+
if (route.await !== undefined)
|
|
11
|
+
return route.await;
|
|
12
|
+
if (outcomeKind !== ActivityOutcomeKind.Done ||
|
|
13
|
+
route.watchGates !== undefined ||
|
|
14
|
+
stage.requiresApproval === false)
|
|
15
|
+
return undefined;
|
|
16
|
+
return { signal: 'approved', from: [ApprovalAuthorityKind.Human] };
|
|
17
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { workflowInstanceId, } from '../contracts/identifiers.js';
|
|
2
|
+
import { WorkflowInstanceKind } from '../contracts/vocabulary.js';
|
|
3
|
+
export function childStartMetadata(input) {
|
|
4
|
+
if (input.parentWorkflowInstanceId === undefined)
|
|
5
|
+
return undefined;
|
|
6
|
+
return {
|
|
7
|
+
parentWorkflowInstanceId: input.parentWorkflowInstanceId,
|
|
8
|
+
watchId: input.watchId,
|
|
9
|
+
triggerId: input.triggerId,
|
|
10
|
+
orchestrationGroupId: input.orchestrationGroupId,
|
|
11
|
+
causalCycleId: input.causalCycleId,
|
|
12
|
+
requestId: input.requestId,
|
|
13
|
+
childWorkflowInstanceId: input.workflowInstanceId,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function childMetadata(child) {
|
|
17
|
+
if (child.parentWorkflowInstanceId === undefined ||
|
|
18
|
+
child.watchId === undefined ||
|
|
19
|
+
child.triggerId === undefined ||
|
|
20
|
+
child.causalCycleId === undefined ||
|
|
21
|
+
child.requestId === undefined)
|
|
22
|
+
throw new Error('Child workflow metadata is incomplete');
|
|
23
|
+
return {
|
|
24
|
+
parentWorkflowInstanceId: child.parentWorkflowInstanceId,
|
|
25
|
+
watchId: child.watchId,
|
|
26
|
+
triggerId: child.triggerId,
|
|
27
|
+
orchestrationGroupId: child.orchestrationGroupId,
|
|
28
|
+
causalCycleId: child.causalCycleId,
|
|
29
|
+
requestId: child.requestId,
|
|
30
|
+
childWorkflowInstanceId: child.workflowInstanceId,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function validateChildProvenance(command) {
|
|
34
|
+
const values = [
|
|
35
|
+
command.parentWorkflowInstanceId,
|
|
36
|
+
command.watchId,
|
|
37
|
+
command.triggerId,
|
|
38
|
+
command.causalCycleId,
|
|
39
|
+
command.requestId,
|
|
40
|
+
];
|
|
41
|
+
const provided = values.filter((value) => value !== undefined).length;
|
|
42
|
+
if (provided === 0)
|
|
43
|
+
return WorkflowInstanceKind.Primary;
|
|
44
|
+
if (provided !== values.length)
|
|
45
|
+
throw new Error('Complete child provenance must be provided');
|
|
46
|
+
if (command.requestId !== command.workflowInstanceId)
|
|
47
|
+
throw new Error('Child request id must equal its WorkflowInstance id');
|
|
48
|
+
return WorkflowInstanceKind.Child;
|
|
49
|
+
}
|
|
50
|
+
export function childRequestId(request) {
|
|
51
|
+
return workflowInstanceId(`${request.parentWorkflowInstanceId}:watch:${request.watchId}:trigger:${request.triggerId}`);
|
|
52
|
+
}
|
|
53
|
+
export function coordinationMetadata(parent, request) {
|
|
54
|
+
return {
|
|
55
|
+
parentWorkflowInstanceId: parent.workflowInstanceId,
|
|
56
|
+
watchId: request.watchId,
|
|
57
|
+
triggerId: request.triggerId,
|
|
58
|
+
orchestrationGroupId: parent.orchestrationGroupId,
|
|
59
|
+
causalCycleId: request.causalCycleId,
|
|
60
|
+
requestId: request.requestId,
|
|
61
|
+
childWorkflowInstanceId: request.requestId,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { activityName, ActivityOutcomeKind, } from '../../activities/index.js';
|
|
2
|
+
import { workflowDefinitionConfigSchema, } from '../contracts/config.js';
|
|
3
|
+
import { commandName, signalName, stageName, watchId, workflowName, } from '../contracts/identifiers.js';
|
|
4
|
+
import { ApprovalAuthorityKind, TransitionTargetKind } from '../contracts/vocabulary.js';
|
|
5
|
+
import { defaultApprovalAwait } from './approval-defaults.js';
|
|
6
|
+
import { assertCyclesBounded, assertReachable } from './workflow-graph.js';
|
|
7
|
+
export function compileWorkflow(name, input, activities, knownWorkflowNames = [name]) {
|
|
8
|
+
const compiledName = workflowName(name);
|
|
9
|
+
const config = workflowDefinitionConfigSchema.parse(input);
|
|
10
|
+
const rawStageNames = Object.keys(config.stages);
|
|
11
|
+
for (const candidate of rawStageNames) {
|
|
12
|
+
if (isReservedTerminal(candidate))
|
|
13
|
+
throw new Error(`Reserved stage name: ${candidate}`);
|
|
14
|
+
}
|
|
15
|
+
const stageNames = rawStageNames.map(stageName);
|
|
16
|
+
const entry = config.entry ?? stageNames[0];
|
|
17
|
+
if (!(entry in config.stages))
|
|
18
|
+
throw new Error(`Unknown workflow entry stage: ${entry}`);
|
|
19
|
+
const compiledEntry = stageName(entry);
|
|
20
|
+
const declaredWatchIds = new Set((config.watches ?? []).map((watch) => watch.id));
|
|
21
|
+
const stages = compileStages(compiledName, config.stages, activities, declaredWatchIds);
|
|
22
|
+
const commands = compileCommands(config, activities);
|
|
23
|
+
const watches = compileWatches(config, rawStageNames, knownWorkflowNames);
|
|
24
|
+
assertReachable(compiledEntry, stages);
|
|
25
|
+
assertCyclesBounded(stages);
|
|
26
|
+
return Object.freeze({
|
|
27
|
+
name: compiledName,
|
|
28
|
+
entry: compiledEntry,
|
|
29
|
+
commands: Object.freeze(commands),
|
|
30
|
+
watches: Object.freeze(watches),
|
|
31
|
+
stages: Object.freeze(stages),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function compileWatches(config, stageNames, knownWorkflowNames) {
|
|
35
|
+
const ids = new Set();
|
|
36
|
+
return (config.watches ?? []).map((watch) => {
|
|
37
|
+
if (ids.has(watch.id))
|
|
38
|
+
throw new Error(`Duplicate watch id: ${watch.id}`);
|
|
39
|
+
ids.add(watch.id);
|
|
40
|
+
const unknownStages = watch.while.stages.filter((stage) => !stageNames.includes(stage));
|
|
41
|
+
if (unknownStages.length > 0)
|
|
42
|
+
throw new Error(`Unknown watch stage: ${unknownStages.join(', ')}`);
|
|
43
|
+
if (!knownWorkflowNames.includes(watch.workflow))
|
|
44
|
+
throw new Error(`Unknown watch workflow: ${watch.workflow}`);
|
|
45
|
+
return Object.freeze({
|
|
46
|
+
...watch,
|
|
47
|
+
id: watchId(watch.id),
|
|
48
|
+
workflow: workflowName(watch.workflow),
|
|
49
|
+
while: Object.freeze({
|
|
50
|
+
stages: Object.freeze(watch.while.stages.map(stageName)),
|
|
51
|
+
statuses: Object.freeze([...watch.while.statuses]),
|
|
52
|
+
}),
|
|
53
|
+
...(watch.on === undefined
|
|
54
|
+
? {}
|
|
55
|
+
: { on: Object.freeze({ events: Object.freeze([...watch.on.events]) }) }),
|
|
56
|
+
...(watch.schedule === undefined ? {} : { schedule: Object.freeze({ ...watch.schedule }) }),
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function compileStages(compiledWorkflowName, configured, activities, declaredWatchIds) {
|
|
61
|
+
const context = {
|
|
62
|
+
workflowName: compiledWorkflowName,
|
|
63
|
+
activities,
|
|
64
|
+
declaredWatchIds,
|
|
65
|
+
};
|
|
66
|
+
return Object.fromEntries(Object.entries(configured).map(([stageName, stage]) => [
|
|
67
|
+
stageName,
|
|
68
|
+
compileStage(context, stageName, stage, configured),
|
|
69
|
+
]));
|
|
70
|
+
}
|
|
71
|
+
function compileStage(context, rawStageName, stage, allStages) {
|
|
72
|
+
const { workflowName: compiledWorkflowName, activities, declaredWatchIds } = context;
|
|
73
|
+
const definition = activities.describe(activityName(stage.activity));
|
|
74
|
+
const on = Object.fromEntries(Object.entries(stage.on).map(([outcomeKind, route]) => {
|
|
75
|
+
if (!definition.outcomeKinds.includes(outcomeKind))
|
|
76
|
+
throw new Error(`Workflow outcome route ${outcomeKind} is not declared by Activity ${definition.name}`);
|
|
77
|
+
if (!isReservedTerminal(route.then) && !(route.then in allStages))
|
|
78
|
+
throw new Error(`Unknown transition target: ${route.then}`);
|
|
79
|
+
if (route.await !== undefined && route.watchGates !== undefined)
|
|
80
|
+
throw new Error(`Route ${compiledWorkflowName}:${rawStageName}:${outcomeKind} cannot configure both await and watchGates`);
|
|
81
|
+
const followOns = route.activities?.map((activity) => ({
|
|
82
|
+
use: activityName(activity.use),
|
|
83
|
+
with: activities.validateInput(activityName(activity.use), activity.with),
|
|
84
|
+
}));
|
|
85
|
+
const target = compileTarget(route.then, outcomeKind);
|
|
86
|
+
const effectiveAwait = defaultApprovalAwait(stage, outcomeKind, route);
|
|
87
|
+
const compiled = Object.freeze({
|
|
88
|
+
target,
|
|
89
|
+
...(route.repeat === undefined ? {} : { repeat: route.repeat }),
|
|
90
|
+
...(route.retry === undefined ? {} : { retry: route.retry }),
|
|
91
|
+
...(followOns === undefined ? {} : { activities: Object.freeze(followOns) }),
|
|
92
|
+
...(effectiveAwait === undefined
|
|
93
|
+
? {}
|
|
94
|
+
: {
|
|
95
|
+
await: compileAwait(compiledWorkflowName, rawStageName, target, effectiveAwait, declaredWatchIds),
|
|
96
|
+
}),
|
|
97
|
+
...(route.watchGates === undefined
|
|
98
|
+
? {}
|
|
99
|
+
: {
|
|
100
|
+
watchGates: compileWatchGates(compiledWorkflowName, rawStageName, outcomeKind, route.watchGates, declaredWatchIds, allStages),
|
|
101
|
+
}),
|
|
102
|
+
id: `${compiledWorkflowName}:${rawStageName}:${outcomeKind}`,
|
|
103
|
+
});
|
|
104
|
+
return [outcomeKind, compiled];
|
|
105
|
+
}));
|
|
106
|
+
return Object.freeze({
|
|
107
|
+
activity: definition.name,
|
|
108
|
+
with: activities.validateInput(definition.name, stage.with),
|
|
109
|
+
...(stage.execution === undefined ? {} : { execution: stage.execution }),
|
|
110
|
+
on: Object.freeze(on),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function compileWatchGates(workflow, rawStageName, outcomeKind, entries, declaredWatchIds, allStages) {
|
|
114
|
+
if (entries.length !== 1)
|
|
115
|
+
throw new Error(`Route ${workflow}:${rawStageName}:${outcomeKind} configures ${entries.length} watchGates; exactly 1 is supported`);
|
|
116
|
+
return Object.freeze(entries.map((entry) => {
|
|
117
|
+
const normalized = typeof entry === 'string' ? { watch: entry } : entry;
|
|
118
|
+
if (!declaredWatchIds.has(normalized.watch))
|
|
119
|
+
throw new Error(`Unknown watch reference in workflow "${workflow}" stage "${rawStageName}": "${normalized.watch}"`);
|
|
120
|
+
const onRejectThen = normalized.onReject?.then ?? rawStageName;
|
|
121
|
+
if (!isReservedTerminal(onRejectThen) && !(onRejectThen in allStages))
|
|
122
|
+
throw new Error(`Unknown watchGates onReject target: ${onRejectThen}`);
|
|
123
|
+
return Object.freeze({
|
|
124
|
+
watch: watchId(normalized.watch),
|
|
125
|
+
onRejectTarget: compileTarget(onRejectThen, outcomeKind),
|
|
126
|
+
});
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
function compileAwait(workflow, rawStageName, resume, config, declaredWatchIds) {
|
|
130
|
+
return Object.freeze({
|
|
131
|
+
signal: signalName(config.signal),
|
|
132
|
+
from: Object.freeze(config.from.map((entry) => compileAuthority(workflow, rawStageName, entry, declaredWatchIds))),
|
|
133
|
+
resume,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function compileAuthority(workflow, rawStageName, entry, declaredWatchIds) {
|
|
137
|
+
if (entry === ApprovalAuthorityKind.Human)
|
|
138
|
+
return { kind: ApprovalAuthorityKind.Human };
|
|
139
|
+
if (entry === ApprovalAuthorityKind.Auto)
|
|
140
|
+
return { kind: ApprovalAuthorityKind.Auto };
|
|
141
|
+
if (!declaredWatchIds.has(entry.id))
|
|
142
|
+
throw new Error(`Unknown watch reference in workflow "${workflow}" stage "${rawStageName}": "${entry.id}"`);
|
|
143
|
+
return { kind: ApprovalAuthorityKind.Watch, watch: watchId(entry.id) };
|
|
144
|
+
}
|
|
145
|
+
function compileCommands(config, activities) {
|
|
146
|
+
return Object.fromEntries(Object.entries(config.commands ?? {}).map(([command, configured]) => [
|
|
147
|
+
commandName(command),
|
|
148
|
+
Object.freeze({
|
|
149
|
+
activity: activityName(configured.activity),
|
|
150
|
+
with: activities.validateInput(activityName(configured.activity), configured.with),
|
|
151
|
+
allowedActors: Object.freeze([...configured.allowedActors]),
|
|
152
|
+
}),
|
|
153
|
+
]));
|
|
154
|
+
}
|
|
155
|
+
const isReservedTerminal = (target) => target === ActivityOutcomeKind.Done || target === 'await-human';
|
|
156
|
+
function compileTarget(target, outcomeKind) {
|
|
157
|
+
if (target === ActivityOutcomeKind.Done)
|
|
158
|
+
return { kind: TransitionTargetKind.Complete };
|
|
159
|
+
if (target === 'await-human')
|
|
160
|
+
return { kind: TransitionTargetKind.AwaitSignal, signal: signalName(outcomeKind) };
|
|
161
|
+
return { kind: TransitionTargetKind.Stage, stage: stageName(target) };
|
|
162
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createEventDraft, EventActorKind, EventSourceKind } from '../../kernel/index.js';
|
|
2
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
3
|
+
import { workflowInstanceId, } from '../contracts/identifiers.js';
|
|
4
|
+
import { workflowInstanceStream } from '../contracts/streams.js';
|
|
5
|
+
const actor = { kind: EventActorKind.System, id: 'orchestration' };
|
|
6
|
+
const source = { kind: EventSourceKind.Internal, id: 'orchestration' };
|
|
7
|
+
export function coordinationDraft(context, eventType, payload, ordinal) {
|
|
8
|
+
return createEventDraft({
|
|
9
|
+
eventId: `${context.eventIdPrefix}:${eventType}:${ordinal}`,
|
|
10
|
+
eventType,
|
|
11
|
+
occurredAt: context.occurredAt,
|
|
12
|
+
correlationId: context.correlationId,
|
|
13
|
+
causationId: context.causationId,
|
|
14
|
+
actor,
|
|
15
|
+
source,
|
|
16
|
+
stream: workflowInstanceStream(workflowInstanceId(context.workflowInstanceId)),
|
|
17
|
+
payload,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function childStartDrafts(context, metadata, workflowName) {
|
|
21
|
+
return [
|
|
22
|
+
coordinationDraft(context, OrchestrationEventType.ChildRequested, { ...metadata, workflowName }, 1),
|
|
23
|
+
coordinationDraft(context, OrchestrationEventType.ChildStarted, metadata, 2),
|
|
24
|
+
];
|
|
25
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { activationId } from '../../activities/index.js';
|
|
2
|
+
import { createEventDraft, EventActorKind, EventSourceKind } from '../../kernel/index.js';
|
|
3
|
+
import { workflowInstanceId, } from '../contracts/identifiers.js';
|
|
4
|
+
import { workflowInstanceStream } from '../contracts/streams.js';
|
|
5
|
+
const actor = { kind: EventActorKind.System, id: 'orchestration' };
|
|
6
|
+
const source = { kind: EventSourceKind.Internal, id: 'orchestration' };
|
|
7
|
+
export function nextOrdinal(state) {
|
|
8
|
+
return (state.pendingActivation?.ordinal ?? 0) + 1;
|
|
9
|
+
}
|
|
10
|
+
export function activation(id, ordinal, activity, input, options) {
|
|
11
|
+
return {
|
|
12
|
+
activationId: activationId(`${id}:activity:${ordinal}`),
|
|
13
|
+
ordinal,
|
|
14
|
+
activity,
|
|
15
|
+
...(options.stage === undefined ? {} : { stage: options.stage }),
|
|
16
|
+
input,
|
|
17
|
+
execution: options.execution,
|
|
18
|
+
...(options.followOnIndex === undefined ? {} : { followOnIndex: options.followOnIndex }),
|
|
19
|
+
...(options.supplemental === true ? { supplemental: true } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function startDraft(input, eventType, payload, ordinal) {
|
|
23
|
+
return createEventDraft({
|
|
24
|
+
eventId: `${input.causationId}:${eventType}:${ordinal}`,
|
|
25
|
+
eventType,
|
|
26
|
+
occurredAt: input.occurredAt,
|
|
27
|
+
correlationId: input.correlationId,
|
|
28
|
+
causationId: input.causationId,
|
|
29
|
+
actor,
|
|
30
|
+
source,
|
|
31
|
+
stream: workflowInstanceStream(workflowInstanceId(input.workflowInstanceId)),
|
|
32
|
+
payload,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export function stateDraft(state, input, eventType, payload, ordinal) {
|
|
36
|
+
return createEventDraft({
|
|
37
|
+
eventId: `${input.causationId}:${eventType}:${ordinal}`,
|
|
38
|
+
eventType,
|
|
39
|
+
occurredAt: input.occurredAt,
|
|
40
|
+
correlationId: state.orchestrationGroupId,
|
|
41
|
+
causationId: input.causationId,
|
|
42
|
+
actor,
|
|
43
|
+
source,
|
|
44
|
+
stream: workflowInstanceStream(workflowInstanceId(state.workflowInstanceId)),
|
|
45
|
+
payload,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ActivityOutcomeKind } from '../../activities/index.js';
|
|
2
|
+
import { OrchestrationEventType, } from '../contracts/events.js';
|
|
3
|
+
import { stageName } from '../contracts/identifiers.js';
|
|
4
|
+
import { acceptOutcomeDraft, isPendingOutcome, requestFollowOn, } from './activation-policy.js';
|
|
5
|
+
import { stateDraft } from './decision-events.js';
|
|
6
|
+
import { mayRetry, requestRetry } from './retry-policy.js';
|
|
7
|
+
import { acceptWaitingOutcome } from './signal-policy.js';
|
|
8
|
+
import { finishSupplemental, requestNextSupplemental } from './supplemental-policy.js';
|
|
9
|
+
import { finishRoute } from './transition.js';
|
|
10
|
+
export { startInstance } from './activation-policy.js';
|
|
11
|
+
export { acceptSignal, waitForSignal } from './signal-policy.js';
|
|
12
|
+
export { requestSupplementalActivity } from './supplemental-policy.js';
|
|
13
|
+
export { isOperatorRetryEligible, requestOperatorRetry } from './operator-retry-policy.js';
|
|
14
|
+
export function acceptActivityOutcome(definition, state, input) {
|
|
15
|
+
if (!isPendingOutcome(state, input))
|
|
16
|
+
return { kind: 'ignored', reason: 'outcome is not for the pending activation' };
|
|
17
|
+
if (input.outcome.kind === ActivityOutcomeKind.Waiting)
|
|
18
|
+
return acceptWaitingOutcome(state, input);
|
|
19
|
+
const events = [acceptOutcomeDraft(state, input)];
|
|
20
|
+
const pending = state.pendingActivation;
|
|
21
|
+
if (pending.supplemental === true) {
|
|
22
|
+
finishSupplemental(events, definition, state, input);
|
|
23
|
+
return { kind: 'append', events };
|
|
24
|
+
}
|
|
25
|
+
const route = definition.stages[stageName(state.currentStage)]?.on[input.outcome.kind];
|
|
26
|
+
if (route === undefined) {
|
|
27
|
+
// The outcome still durably happened even though this stage never
|
|
28
|
+
// declared how to route it — recording it (not just blocking) is what
|
|
29
|
+
// keeps the activation resolved, so nothing can later mistake it for
|
|
30
|
+
// still being open and resolve it via an unrelated signal.
|
|
31
|
+
events.push(stateDraft(state, input, OrchestrationEventType.InstanceBlocked, { reason: `unconfigured outcome ${input.outcome.kind}` }, events.length + 1));
|
|
32
|
+
return { kind: 'append', events };
|
|
33
|
+
}
|
|
34
|
+
if (input.outcome.kind !== ActivityOutcomeKind.Done) {
|
|
35
|
+
if (mayRetry(route, state, input.outcome))
|
|
36
|
+
requestRetry(events, definition, state, input);
|
|
37
|
+
else
|
|
38
|
+
finishRoute(events, definition, state, input, route);
|
|
39
|
+
return { kind: 'append', events };
|
|
40
|
+
}
|
|
41
|
+
if (state.supplementalQueue.length > 0) {
|
|
42
|
+
requestNextSupplemental(events, state, input);
|
|
43
|
+
return { kind: 'append', events };
|
|
44
|
+
}
|
|
45
|
+
if (requestFollowOn(events, state, input, route.activities ?? []))
|
|
46
|
+
return { kind: 'append', events };
|
|
47
|
+
finishRoute(events, definition, state, input, route);
|
|
48
|
+
return { kind: 'append', events };
|
|
49
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ActivityOutcomeKind } from '../../activities/index.js';
|
|
2
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
3
|
+
import { stageName } from '../contracts/identifiers.js';
|
|
4
|
+
import { ActivityActivationStatus, WorkflowStatus } from '../contracts/vocabulary.js';
|
|
5
|
+
import { activation, nextOrdinal, stateDraft } from './decision-events.js';
|
|
6
|
+
export function isOperatorRetryEligible(view) {
|
|
7
|
+
const pending = view.pendingActivation;
|
|
8
|
+
return (view.status === WorkflowStatus.Blocked &&
|
|
9
|
+
view.blockReason === 'unconfigured outcome failed' &&
|
|
10
|
+
pending !== undefined &&
|
|
11
|
+
pending.status === ActivityActivationStatus.Completed &&
|
|
12
|
+
pending.supplemental !== true &&
|
|
13
|
+
pending.followOnIndex === undefined &&
|
|
14
|
+
view.lastOutcome?.kind === ActivityOutcomeKind.Failed &&
|
|
15
|
+
view.acceptedOutcomes.includes(pending.activationId));
|
|
16
|
+
}
|
|
17
|
+
export function requestOperatorRetry(definition, state, input) {
|
|
18
|
+
if (input.commandId.length === 0)
|
|
19
|
+
return { kind: 'ignored', reason: 'operator retry command id is required' };
|
|
20
|
+
if (!isOperatorRetryEligible(state))
|
|
21
|
+
return {
|
|
22
|
+
kind: 'ignored',
|
|
23
|
+
reason: 'workflow is not blocked for an unconfigured failed outcome',
|
|
24
|
+
};
|
|
25
|
+
const stage = definition.stages[stageName(state.currentStage)];
|
|
26
|
+
const events = [
|
|
27
|
+
stateDraft(state, input, OrchestrationEventType.OperatorRetryRequested, { activationId: state.pendingActivation.activationId, commandId: input.commandId }, 1),
|
|
28
|
+
stateDraft(state, input, OrchestrationEventType.ActivityRequested, activation(state.workflowInstanceId, nextOrdinal(state), stage.activity, stage.with, {
|
|
29
|
+
execution: stage.execution,
|
|
30
|
+
stage: stageName(state.currentStage),
|
|
31
|
+
}), 2),
|
|
32
|
+
];
|
|
33
|
+
return { kind: 'append', events };
|
|
34
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RetrySafety } from '../../activities/index.js';
|
|
2
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
3
|
+
import { stageName } from '../contracts/identifiers.js';
|
|
4
|
+
import { activation, nextOrdinal, stateDraft } from './decision-events.js';
|
|
5
|
+
export function mayRetry(route, state, outcome) {
|
|
6
|
+
if (route.retry === undefined || requiresReconciliation(outcome))
|
|
7
|
+
return false;
|
|
8
|
+
const retryKey = `${state.currentStage}:${outcome.kind}`;
|
|
9
|
+
return (state.retryCounts[retryKey] ?? 0) < route.retry.max;
|
|
10
|
+
}
|
|
11
|
+
export function requestRetry(events, definition, state, input) {
|
|
12
|
+
const retryKey = `${state.currentStage}:${input.outcome.kind}`;
|
|
13
|
+
const count = (state.retryCounts[retryKey] ?? 0) + 1;
|
|
14
|
+
const stage = definition.stages[stageName(state.currentStage)];
|
|
15
|
+
events.push(stateDraft(state, input, OrchestrationEventType.RetryCounted, { retryKey, count }, events.length + 1), stateDraft(state, input, OrchestrationEventType.ActivityRequested, activation(state.workflowInstanceId, nextOrdinal(state), stage.activity, stage.with, {
|
|
16
|
+
execution: stage.execution,
|
|
17
|
+
stage: stageName(state.currentStage),
|
|
18
|
+
}), events.length + 2));
|
|
19
|
+
}
|
|
20
|
+
function requiresReconciliation(outcome) {
|
|
21
|
+
if (typeof outcome.data !== 'object' || outcome.data === null)
|
|
22
|
+
return false;
|
|
23
|
+
if (!('retrySafety' in outcome.data))
|
|
24
|
+
return false;
|
|
25
|
+
return outcome.data.retrySafety === RetrySafety.RequiresReconciliation;
|
|
26
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ActivityOutcomeKind } from '../../activities/index.js';
|
|
2
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
3
|
+
import { stageName } from '../contracts/identifiers.js';
|
|
4
|
+
import { ActivityActivationStatus, ApprovalAuthorityKind, WorkflowStatus, } from '../contracts/vocabulary.js';
|
|
5
|
+
import { activation, nextOrdinal, stateDraft } from './decision-events.js';
|
|
6
|
+
import { resumeToTarget } from './transition.js';
|
|
7
|
+
export function waitForSignal(state, expectation, input) {
|
|
8
|
+
if (state.status !== WorkflowStatus.Waiting && state.status !== WorkflowStatus.Blocked)
|
|
9
|
+
return { kind: 'ignored', reason: 'WorkflowInstance is not waiting or blocked' };
|
|
10
|
+
if (expectation.signalKind.trim().length === 0)
|
|
11
|
+
return { kind: 'ignored', reason: 'signal kind must not be empty' };
|
|
12
|
+
return {
|
|
13
|
+
kind: 'append',
|
|
14
|
+
events: [stateDraft(state, input, OrchestrationEventType.SignalWaitStarted, expectation, 1)],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function acceptSignal(definition, state, input) {
|
|
18
|
+
const rejection = signalRejectionReason(state, input);
|
|
19
|
+
if (rejection !== null)
|
|
20
|
+
return { kind: 'ignored', reason: rejection };
|
|
21
|
+
const signal = input.signal;
|
|
22
|
+
const expected = state.waitingFor;
|
|
23
|
+
const authority = signal.authority ?? { kind: ApprovalAuthorityKind.Human };
|
|
24
|
+
const events = [
|
|
25
|
+
stateDraft(state, input, OrchestrationEventType.SignalAccepted, { ...signal, authority }, 1),
|
|
26
|
+
];
|
|
27
|
+
if (signal.outcome === ActivityOutcomeKind.Rejected) {
|
|
28
|
+
if (expected.onRejectResume !== undefined) {
|
|
29
|
+
resumeToTarget(events, definition, state, input, expected.onRejectResume);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
requestCurrentStage(events, definition, state, input);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (expected.resume !== undefined) {
|
|
36
|
+
resumeToTarget(events, definition, state, input, expected.resume);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
requestCurrentStage(events, definition, state, input);
|
|
40
|
+
}
|
|
41
|
+
return { kind: 'append', events };
|
|
42
|
+
}
|
|
43
|
+
function requestCurrentStage(events, definition, state, input) {
|
|
44
|
+
const stage = definition.stages[stageName(state.currentStage)];
|
|
45
|
+
events.push(stateDraft(state, input, OrchestrationEventType.ActivityRequested, activation(state.workflowInstanceId, nextOrdinal(state), stage.activity, stage.with, {
|
|
46
|
+
execution: stage.execution,
|
|
47
|
+
stage: stageName(state.currentStage),
|
|
48
|
+
}), events.length + 1));
|
|
49
|
+
}
|
|
50
|
+
function signalRejectionReason(state, input) {
|
|
51
|
+
const signal = input.signal;
|
|
52
|
+
if (state.acceptedSignalIds.includes(signal.providerEventId))
|
|
53
|
+
return 'provider signal was already accepted';
|
|
54
|
+
const expected = state.waitingFor;
|
|
55
|
+
if (state.status !== WorkflowStatus.Waiting || expected === undefined)
|
|
56
|
+
return 'WorkflowInstance is not waiting for a signal';
|
|
57
|
+
if (!matchesExpectation(signal, expected))
|
|
58
|
+
return 'signal does not match the current expectation';
|
|
59
|
+
if (!hasDecisionEvidence(signal))
|
|
60
|
+
return 'signal lacks authorized actor decision evidence';
|
|
61
|
+
if (signal.providerEventId.trim().length === 0)
|
|
62
|
+
return 'signal lacks provider event identity';
|
|
63
|
+
if (!signalAuthorityAccepted(signal, expected, input.consent ?? false))
|
|
64
|
+
return 'signal authority is not accepted by this wait';
|
|
65
|
+
if (!watchGateOutcomeAccepted(signal, expected))
|
|
66
|
+
return 'watch-gate signal outcome is neither done nor rejected';
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function signalAuthorityAccepted(signal, expected, consent) {
|
|
70
|
+
if (expected.from === undefined)
|
|
71
|
+
return true;
|
|
72
|
+
const authority = signal.authority ?? { kind: ApprovalAuthorityKind.Human };
|
|
73
|
+
return authorityAccepted(authority, expected.from, consent);
|
|
74
|
+
}
|
|
75
|
+
function watchGateOutcomeAccepted(signal, expected) {
|
|
76
|
+
return (expected.onRejectResume === undefined ||
|
|
77
|
+
signal.outcome === undefined ||
|
|
78
|
+
signal.outcome === ActivityOutcomeKind.Done ||
|
|
79
|
+
signal.outcome === ActivityOutcomeKind.Rejected);
|
|
80
|
+
}
|
|
81
|
+
function authorityAccepted(authority, declared, consent) {
|
|
82
|
+
switch (authority.kind) {
|
|
83
|
+
case ApprovalAuthorityKind.Human:
|
|
84
|
+
return declared.some((entry) => entry.kind === ApprovalAuthorityKind.Human);
|
|
85
|
+
case ApprovalAuthorityKind.Auto:
|
|
86
|
+
return consent && declared.some((entry) => entry.kind === ApprovalAuthorityKind.Auto);
|
|
87
|
+
case ApprovalAuthorityKind.Watch:
|
|
88
|
+
return declared.some((entry) => entry.kind === ApprovalAuthorityKind.Watch && entry.watch === authority.watch);
|
|
89
|
+
default:
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function acceptWaitingOutcome(state, input) {
|
|
94
|
+
const waiting = waitingOutcome(input.outcome);
|
|
95
|
+
if (waiting === null)
|
|
96
|
+
return { kind: 'ignored', reason: 'waiting outcome lacks expectation' };
|
|
97
|
+
if (state.pendingActivation?.status === ActivityActivationStatus.Waiting &&
|
|
98
|
+
state.waitingFor?.intentEventId === waiting.data.intentEventId &&
|
|
99
|
+
state.waitingFor.signalKind === waiting.data.signalKind)
|
|
100
|
+
return { kind: 'ignored', reason: 'waiting outcome was already recorded' };
|
|
101
|
+
const events = [
|
|
102
|
+
stateDraft(state, input, OrchestrationEventType.ActivityWaiting, { activationId: input.activationId, outcome: waiting }, 1),
|
|
103
|
+
];
|
|
104
|
+
return { kind: 'append', events };
|
|
105
|
+
}
|
|
106
|
+
function matchesExpectation(signal, expected) {
|
|
107
|
+
return (signal.kind === expected?.signalKind &&
|
|
108
|
+
signal.resourceId === expected.resourceId &&
|
|
109
|
+
signal.revision === expected.revision);
|
|
110
|
+
}
|
|
111
|
+
function hasDecisionEvidence(signal) {
|
|
112
|
+
return (signal.actorId.trim().length > 0 &&
|
|
113
|
+
signal.actorDecision.authorized &&
|
|
114
|
+
signal.actorDecision.evidenceId.trim().length > 0);
|
|
115
|
+
}
|
|
116
|
+
function waitingOutcome(outcome) {
|
|
117
|
+
return outcome.kind === ActivityOutcomeKind.Waiting
|
|
118
|
+
? outcome
|
|
119
|
+
: null;
|
|
120
|
+
}
|