@atolis-hq/wake 0.2.97 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- 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 +436 -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/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/templates/SETUP.md +0 -115
- /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,25 @@
|
|
|
1
|
+
import { orchestrationActivityOutcome } from '../contracts/activity-outcome.js';
|
|
2
|
+
import { acceptActivityOutcome as decideActivityOutcome } from '../domain/interpreter.js';
|
|
3
|
+
export class AcceptActivityOutcome {
|
|
4
|
+
repository;
|
|
5
|
+
workflows;
|
|
6
|
+
reconcileChildCompletions;
|
|
7
|
+
constructor(repository, workflows, reconcileChildCompletions) {
|
|
8
|
+
this.repository = repository;
|
|
9
|
+
this.workflows = workflows;
|
|
10
|
+
this.reconcileChildCompletions = reconcileChildCompletions;
|
|
11
|
+
}
|
|
12
|
+
async execute(command, context) {
|
|
13
|
+
const loaded = await this.repository.loadRequired(command.workflowInstanceId);
|
|
14
|
+
const decision = decideActivityOutcome(this.workflows.definition(loaded.view.workflowName), loaded.view, {
|
|
15
|
+
...command,
|
|
16
|
+
outcome: orchestrationActivityOutcome(command.outcome),
|
|
17
|
+
occurredAt: context.occurredAt,
|
|
18
|
+
causationId: context.commandId,
|
|
19
|
+
});
|
|
20
|
+
if (decision.kind === 'append')
|
|
21
|
+
await this.repository.append(command.workflowInstanceId, loaded.sequence, decision.events);
|
|
22
|
+
await this.reconcileChildCompletions(context);
|
|
23
|
+
return (await this.repository.loadRequired(command.workflowInstanceId)).view;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { acceptSignal as decideSignal, waitForSignal as decideSignalWait, } from '../domain/interpreter.js';
|
|
2
|
+
export class AcceptSignal {
|
|
3
|
+
repository;
|
|
4
|
+
workflows;
|
|
5
|
+
work;
|
|
6
|
+
constructor(repository, workflows, work) {
|
|
7
|
+
this.repository = repository;
|
|
8
|
+
this.workflows = workflows;
|
|
9
|
+
this.work = work;
|
|
10
|
+
}
|
|
11
|
+
async wait(workflowInstanceId, expectation, context) {
|
|
12
|
+
const loaded = await this.repository.loadRequired(workflowInstanceId);
|
|
13
|
+
const decision = decideSignalWait(loaded.view, expectation, {
|
|
14
|
+
occurredAt: context.occurredAt,
|
|
15
|
+
causationId: context.commandId,
|
|
16
|
+
});
|
|
17
|
+
if (decision.kind === 'ignored')
|
|
18
|
+
throw new Error(decision.reason);
|
|
19
|
+
await this.repository.append(workflowInstanceId, loaded.sequence, decision.events);
|
|
20
|
+
return (await this.repository.loadRequired(workflowInstanceId)).view;
|
|
21
|
+
}
|
|
22
|
+
async execute(workflowInstanceId, signal, context) {
|
|
23
|
+
const loaded = await this.repository.loadRequired(workflowInstanceId);
|
|
24
|
+
const item = await this.work.get(loaded.view.workItemId);
|
|
25
|
+
const decision = decideSignal(this.workflows.definition(loaded.view.workflowName), loaded.view, {
|
|
26
|
+
signal,
|
|
27
|
+
occurredAt: context.occurredAt,
|
|
28
|
+
causationId: context.commandId,
|
|
29
|
+
consent: item?.autoApprovalGranted ?? false,
|
|
30
|
+
});
|
|
31
|
+
if (decision.kind === 'append')
|
|
32
|
+
await this.repository.append(workflowInstanceId, loaded.sequence, decision.events);
|
|
33
|
+
return (await this.repository.loadRequired(workflowInstanceId)).view;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { EventSourceKind, createEventDraft } from '../../kernel/index.js';
|
|
2
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
3
|
+
import { commandName, workflowInstanceId, } from '../contracts/identifiers.js';
|
|
4
|
+
import { workflowInstanceStream } from '../contracts/streams.js';
|
|
5
|
+
import { WorkflowStatus } from '../contracts/vocabulary.js';
|
|
6
|
+
import { requestOperatorRetry as decideOperatorRetry, requestSupplementalActivity as decideSupplementalActivity, } from '../domain/interpreter.js';
|
|
7
|
+
import { isAuthorisedActor } from '../domain/supplemental-policy.js';
|
|
8
|
+
export class OperatorRetryIneligibleError extends Error {
|
|
9
|
+
constructor(detail) {
|
|
10
|
+
super(detail);
|
|
11
|
+
this.name = 'OperatorRetryIneligibleError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class AdvanceWorkflow {
|
|
15
|
+
repository;
|
|
16
|
+
workflows;
|
|
17
|
+
constructor(repository, workflows) {
|
|
18
|
+
this.repository = repository;
|
|
19
|
+
this.workflows = workflows;
|
|
20
|
+
}
|
|
21
|
+
async requestSupplementalActivity(id, request, context) {
|
|
22
|
+
const loaded = await this.repository.loadRequired(id);
|
|
23
|
+
const configured = this.workflows.definition(loaded.view.workflowName).commands[commandName(request.command)];
|
|
24
|
+
if (configured === undefined)
|
|
25
|
+
throw new Error(`Unknown supplemental command: ${request.command}`);
|
|
26
|
+
if (!isAuthorisedActor(configured.allowedActors, context.actor.kind))
|
|
27
|
+
throw new Error(`Actor kind ${context.actor.kind} is not authorised for ${request.command}`);
|
|
28
|
+
const decision = decideSupplementalActivity(loaded.view, {
|
|
29
|
+
activity: configured.activity,
|
|
30
|
+
input: configured.with,
|
|
31
|
+
requestedBy: context.actor.id,
|
|
32
|
+
}, { occurredAt: context.occurredAt, causationId: context.commandId });
|
|
33
|
+
if (decision.kind === 'ignored')
|
|
34
|
+
throw new Error(decision.reason);
|
|
35
|
+
await this.repository.append(id, loaded.sequence, decision.events);
|
|
36
|
+
return (await this.repository.loadRequired(id)).view;
|
|
37
|
+
}
|
|
38
|
+
async markActivationStarted(id, activationId, context) {
|
|
39
|
+
const loaded = await this.repository.load(id);
|
|
40
|
+
if (loaded.view?.pendingActivation?.activationId !== activationId)
|
|
41
|
+
return loaded.view;
|
|
42
|
+
const event = createEventDraft({
|
|
43
|
+
eventId: `${context.commandId}:${OrchestrationEventType.ActivityStarted}`,
|
|
44
|
+
eventType: OrchestrationEventType.ActivityStarted,
|
|
45
|
+
occurredAt: context.occurredAt,
|
|
46
|
+
correlationId: context.correlationId,
|
|
47
|
+
causationId: context.commandId,
|
|
48
|
+
actor: context.actor,
|
|
49
|
+
source: { kind: EventSourceKind.Internal, id: 'orchestration-service' },
|
|
50
|
+
stream: workflowInstanceStream(workflowInstanceId(id)),
|
|
51
|
+
payload: { activationId },
|
|
52
|
+
});
|
|
53
|
+
await this.repository.append(id, loaded.sequence, [event]);
|
|
54
|
+
return (await this.repository.load(id)).view;
|
|
55
|
+
}
|
|
56
|
+
async block(id, reason, context) {
|
|
57
|
+
const loaded = await this.repository.load(id);
|
|
58
|
+
if (loaded.view === null || loaded.view.status === WorkflowStatus.Blocked)
|
|
59
|
+
return loaded.view;
|
|
60
|
+
const event = createEventDraft({
|
|
61
|
+
eventId: `${context.commandId}:${OrchestrationEventType.InstanceBlocked}`,
|
|
62
|
+
eventType: OrchestrationEventType.InstanceBlocked,
|
|
63
|
+
occurredAt: context.occurredAt,
|
|
64
|
+
correlationId: context.correlationId,
|
|
65
|
+
causationId: context.commandId,
|
|
66
|
+
actor: context.actor,
|
|
67
|
+
source: { kind: EventSourceKind.Internal, id: 'orchestration-service' },
|
|
68
|
+
stream: workflowInstanceStream(id),
|
|
69
|
+
payload: { reason },
|
|
70
|
+
});
|
|
71
|
+
await this.repository.append(id, loaded.sequence, [event]);
|
|
72
|
+
return (await this.repository.load(id)).view;
|
|
73
|
+
}
|
|
74
|
+
async resolveExecutionFailure(id, input, context) {
|
|
75
|
+
const loaded = await this.repository.load(id);
|
|
76
|
+
if (loaded.view === null ||
|
|
77
|
+
loaded.view.status === WorkflowStatus.Blocked ||
|
|
78
|
+
loaded.view.pendingActivation?.activationId !== input.activationId ||
|
|
79
|
+
loaded.view.acceptedOutcomes.includes(input.activationId))
|
|
80
|
+
return loaded.view;
|
|
81
|
+
const stream = workflowInstanceStream(id);
|
|
82
|
+
await this.repository.append(id, loaded.sequence, [
|
|
83
|
+
createEventDraft({
|
|
84
|
+
eventId: `${context.commandId}:${OrchestrationEventType.ActivityExecutionFailed}`,
|
|
85
|
+
eventType: OrchestrationEventType.ActivityExecutionFailed,
|
|
86
|
+
occurredAt: context.occurredAt,
|
|
87
|
+
correlationId: context.correlationId,
|
|
88
|
+
causationId: context.commandId,
|
|
89
|
+
actor: context.actor,
|
|
90
|
+
source: { kind: EventSourceKind.Internal, id: 'orchestration-service' },
|
|
91
|
+
stream,
|
|
92
|
+
payload: input,
|
|
93
|
+
}),
|
|
94
|
+
createEventDraft({
|
|
95
|
+
eventId: `${context.commandId}:${OrchestrationEventType.InstanceBlocked}`,
|
|
96
|
+
eventType: OrchestrationEventType.InstanceBlocked,
|
|
97
|
+
occurredAt: context.occurredAt,
|
|
98
|
+
correlationId: context.correlationId,
|
|
99
|
+
causationId: context.commandId,
|
|
100
|
+
actor: context.actor,
|
|
101
|
+
source: { kind: EventSourceKind.Internal, id: 'orchestration-service' },
|
|
102
|
+
stream,
|
|
103
|
+
payload: { reason: input.reason },
|
|
104
|
+
}),
|
|
105
|
+
]);
|
|
106
|
+
return (await this.repository.load(id)).view;
|
|
107
|
+
}
|
|
108
|
+
async retryBlockedFailedStage(id, context) {
|
|
109
|
+
const loaded = await this.repository.load(id);
|
|
110
|
+
if (loaded.view === null)
|
|
111
|
+
throw new OperatorRetryIneligibleError('WorkflowInstance does not exist');
|
|
112
|
+
if (loaded.view.operatorRetryCommandIds.includes(context.commandId))
|
|
113
|
+
return loaded.view;
|
|
114
|
+
const decision = decideOperatorRetry(this.workflows.definition(loaded.view.workflowName), loaded.view, {
|
|
115
|
+
commandId: context.commandId,
|
|
116
|
+
occurredAt: context.occurredAt,
|
|
117
|
+
causationId: context.commandId,
|
|
118
|
+
});
|
|
119
|
+
if (decision.kind === 'ignored')
|
|
120
|
+
throw new OperatorRetryIneligibleError(decision.reason);
|
|
121
|
+
try {
|
|
122
|
+
await this.repository.append(id, loaded.sequence, decision.events);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
const reloaded = await this.repository.loadRequired(id);
|
|
126
|
+
if (reloaded.view.operatorRetryCommandIds.includes(context.commandId))
|
|
127
|
+
return reloaded.view;
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
return (await this.repository.loadRequired(id)).view;
|
|
131
|
+
}
|
|
132
|
+
async get(id) {
|
|
133
|
+
return (await this.repository.load(id)).view;
|
|
134
|
+
}
|
|
135
|
+
async listPendingActivations(workItemId) {
|
|
136
|
+
return (await this.repository.list())
|
|
137
|
+
.filter((view) => view !== null &&
|
|
138
|
+
view.status === WorkflowStatus.Active &&
|
|
139
|
+
view.pendingActivation !== undefined &&
|
|
140
|
+
(workItemId === undefined || view.workItemId === workItemId))
|
|
141
|
+
.map((view) => ({ workflow: view, activation: view.pendingActivation }));
|
|
142
|
+
}
|
|
143
|
+
async listWaiting(signalKind) {
|
|
144
|
+
return (await this.repository.list()).filter((view) => view?.status === WorkflowStatus.Waiting &&
|
|
145
|
+
(signalKind === undefined || view.waitingFor?.signalKind === signalKind));
|
|
146
|
+
}
|
|
147
|
+
async listAll() {
|
|
148
|
+
return (await this.repository.list()).filter((view) => view !== null);
|
|
149
|
+
}
|
|
150
|
+
async listWatchMatches(eventType) {
|
|
151
|
+
return (await this.listAll()).flatMap((parent) => {
|
|
152
|
+
const definition = this.workflows.definition(parent.workflowName);
|
|
153
|
+
return definition.watches
|
|
154
|
+
.filter((watch) => watch.on?.events.includes(eventType) === true &&
|
|
155
|
+
watch.while.stages.includes(parent.currentStage) &&
|
|
156
|
+
watch.while.statuses.some((status) => status === parent.status))
|
|
157
|
+
.map((watch) => ({ parent, watch }));
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createEventDraft, EventSourceKind, WrongExpectedSequenceError, } from '../../kernel/index.js';
|
|
2
|
+
import { selectOrchestrationEvent } from '../contracts/event-decoder.js';
|
|
3
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
4
|
+
import { isOrchestrationGroupStream, primaryOrchestrationGroupStream, } from '../contracts/streams.js';
|
|
5
|
+
export class CoordinationClaims {
|
|
6
|
+
journal;
|
|
7
|
+
constructor(journal) {
|
|
8
|
+
this.journal = journal;
|
|
9
|
+
}
|
|
10
|
+
async claimPrimary(workItemId, workflowInstanceId, context) {
|
|
11
|
+
const stream = primaryOrchestrationGroupStream(workItemId);
|
|
12
|
+
for (;;) {
|
|
13
|
+
const events = await this.journal.readStream(stream);
|
|
14
|
+
const owner = primaryOwner(groupEvents(events));
|
|
15
|
+
if (owner !== undefined) {
|
|
16
|
+
if (owner === workflowInstanceId)
|
|
17
|
+
return;
|
|
18
|
+
throw new Error(`WorkItem already has an active primary workflow owned by ${owner}`);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
await this.journal.append(stream, events.length, [
|
|
22
|
+
createEventDraft({
|
|
23
|
+
eventId: `${context.commandId}:${OrchestrationEventType.PrimaryClaimed}:${workItemId}`,
|
|
24
|
+
eventType: OrchestrationEventType.PrimaryClaimed,
|
|
25
|
+
occurredAt: context.occurredAt,
|
|
26
|
+
correlationId: context.correlationId,
|
|
27
|
+
causationId: context.commandId,
|
|
28
|
+
actor: context.actor,
|
|
29
|
+
source: { kind: EventSourceKind.Internal, id: 'orchestration-service' },
|
|
30
|
+
stream,
|
|
31
|
+
payload: { workItemId, workflowInstanceId },
|
|
32
|
+
}),
|
|
33
|
+
]);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (!(error instanceof WrongExpectedSequenceError))
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async primaryWorkflowInstanceId(workItemId) {
|
|
43
|
+
return primaryOwner(groupEvents(await this.journal.readStream(primaryOrchestrationGroupStream(workItemId))));
|
|
44
|
+
}
|
|
45
|
+
async claimWithinBudget(stream, request, context) {
|
|
46
|
+
for (;;) {
|
|
47
|
+
const events = await this.journal.readStream(stream);
|
|
48
|
+
if (claimedRequestIds(groupEvents(events)).has(request.requestId))
|
|
49
|
+
return true;
|
|
50
|
+
if (events.length >= request.maxPerGroup)
|
|
51
|
+
return false;
|
|
52
|
+
try {
|
|
53
|
+
await this.journal.append(stream, events.length, [
|
|
54
|
+
createEventDraft({
|
|
55
|
+
eventId: `${context.commandId}:${OrchestrationEventType.GroupClaimed}:${request.requestId}`,
|
|
56
|
+
eventType: OrchestrationEventType.GroupClaimed,
|
|
57
|
+
occurredAt: context.occurredAt,
|
|
58
|
+
correlationId: context.correlationId,
|
|
59
|
+
causationId: context.commandId,
|
|
60
|
+
actor: context.actor,
|
|
61
|
+
source: { kind: EventSourceKind.Internal, id: 'orchestration-service' },
|
|
62
|
+
stream,
|
|
63
|
+
payload: { key: stream.id, requestId: request.requestId },
|
|
64
|
+
}),
|
|
65
|
+
]);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (!(error instanceof WrongExpectedSequenceError))
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function primaryOwner(events) {
|
|
76
|
+
for (const event of events) {
|
|
77
|
+
switch (event.eventType) {
|
|
78
|
+
case OrchestrationEventType.PrimaryClaimed:
|
|
79
|
+
return event.payload.workflowInstanceId;
|
|
80
|
+
case OrchestrationEventType.GroupClaimed:
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
assertNever(event);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
function claimedRequestIds(events) {
|
|
89
|
+
return new Set(events.flatMap((event) => {
|
|
90
|
+
switch (event.eventType) {
|
|
91
|
+
case OrchestrationEventType.GroupClaimed:
|
|
92
|
+
return [event.payload.requestId];
|
|
93
|
+
case OrchestrationEventType.PrimaryClaimed:
|
|
94
|
+
return [];
|
|
95
|
+
default:
|
|
96
|
+
return assertNever(event);
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
function groupEvents(events) {
|
|
101
|
+
return events
|
|
102
|
+
.map(selectOrchestrationEvent)
|
|
103
|
+
.filter((event) => event !== null && isOrchestrationGroupStream(event.stream));
|
|
104
|
+
}
|
|
105
|
+
function assertNever(value) {
|
|
106
|
+
throw new Error(`Unhandled Orchestration group event: ${JSON.stringify(value)}`);
|
|
107
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { WrongExpectedSequenceError, } from '../../kernel/index.js';
|
|
2
|
+
import { selectOrchestrationEvent } from '../contracts/event-decoder.js';
|
|
3
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
4
|
+
import { workflowInstanceId } from '../contracts/identifiers.js';
|
|
5
|
+
import { workflowInstanceStream } from '../contracts/streams.js';
|
|
6
|
+
import { coordinationDraft } from '../domain/coordination-events.js';
|
|
7
|
+
import { stateDraft } from '../domain/decision-events.js';
|
|
8
|
+
export class GroupBudgetRecorder {
|
|
9
|
+
journal;
|
|
10
|
+
constructor(journal) {
|
|
11
|
+
this.journal = journal;
|
|
12
|
+
}
|
|
13
|
+
async record(parent, metadata, maxPerGroup, context) {
|
|
14
|
+
const stream = workflowInstanceStream(workflowInstanceId(parent.workflowInstanceId));
|
|
15
|
+
const payload = { ...metadata, maxPerGroup };
|
|
16
|
+
for (;;) {
|
|
17
|
+
const events = await this.journal.readStream(stream);
|
|
18
|
+
if (events.some((event) => {
|
|
19
|
+
const owned = selectOrchestrationEvent(event);
|
|
20
|
+
return (owned?.eventType === OrchestrationEventType.GroupBudgetExhausted &&
|
|
21
|
+
owned.payload.requestId === metadata.requestId);
|
|
22
|
+
}))
|
|
23
|
+
return;
|
|
24
|
+
try {
|
|
25
|
+
await this.journal.append(stream, events.length, [
|
|
26
|
+
coordinationDraft({
|
|
27
|
+
workflowInstanceId: parent.workflowInstanceId,
|
|
28
|
+
eventIdPrefix: context.commandId,
|
|
29
|
+
occurredAt: context.occurredAt,
|
|
30
|
+
correlationId: parent.orchestrationGroupId,
|
|
31
|
+
causationId: context.commandId,
|
|
32
|
+
}, OrchestrationEventType.GroupBudgetExhausted, payload, 1),
|
|
33
|
+
stateDraft(parent, { occurredAt: context.occurredAt, causationId: context.commandId }, OrchestrationEventType.InstanceBlocked, { reason: `watch group budget exhausted for ${metadata.watchId}` }, 2),
|
|
34
|
+
]);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (!(error instanceof WrongExpectedSequenceError))
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { selectWorkflowOrchestrationEvent } from '../contracts/event-decoder.js';
|
|
2
|
+
import { isWorkflowInstanceStream } from '../contracts/streams.js';
|
|
3
|
+
import { foldWorkflowInstance } from '../domain/workflow-instance.js';
|
|
4
|
+
export const orchestrationProjection = {
|
|
5
|
+
name: 'orchestration',
|
|
6
|
+
select(event) {
|
|
7
|
+
const owned = selectWorkflowOrchestrationEvent(event);
|
|
8
|
+
return owned !== null && isWorkflowInstanceStream(owned.stream)
|
|
9
|
+
? { key: owned.stream.id }
|
|
10
|
+
: null;
|
|
11
|
+
},
|
|
12
|
+
initial: () => ({ events: [], view: null }),
|
|
13
|
+
project(previous, event) {
|
|
14
|
+
const owned = selectWorkflowOrchestrationEvent(event);
|
|
15
|
+
if (owned === null || !isWorkflowInstanceStream(owned.stream))
|
|
16
|
+
return previous;
|
|
17
|
+
const events = [...previous.events, owned];
|
|
18
|
+
return { events, view: foldWorkflowInstance(events) };
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { decodeOrchestrationEvent, selectWorkflowOrchestrationEvent, } from '../contracts/event-decoder.js';
|
|
2
|
+
import { workflowInstanceId } from '../contracts/identifiers.js';
|
|
3
|
+
import { isWorkflowInstanceStream, workflowInstanceStream } from '../contracts/streams.js';
|
|
4
|
+
import { foldWorkflowInstance } from '../domain/workflow-instance.js';
|
|
5
|
+
export class OrchestrationRepository {
|
|
6
|
+
journal;
|
|
7
|
+
constructor(journal) {
|
|
8
|
+
this.journal = journal;
|
|
9
|
+
}
|
|
10
|
+
async load(id) {
|
|
11
|
+
const events = await this.journal.readStream(workflowInstanceStream(workflowInstanceId(id)));
|
|
12
|
+
const owned = events
|
|
13
|
+
.map(selectWorkflowOrchestrationEvent)
|
|
14
|
+
.filter((event) => event !== null && isWorkflowInstanceStream(event.stream));
|
|
15
|
+
return { sequence: events.length, view: foldWorkflowInstance(owned) };
|
|
16
|
+
}
|
|
17
|
+
async loadRequired(id) {
|
|
18
|
+
const loaded = await this.load(id);
|
|
19
|
+
if (loaded.view === null)
|
|
20
|
+
throw new Error('WorkflowInstance does not exist');
|
|
21
|
+
return { sequence: loaded.sequence, view: loaded.view };
|
|
22
|
+
}
|
|
23
|
+
async append(id, sequence, drafts) {
|
|
24
|
+
const events = await this.journal.append(workflowInstanceStream(workflowInstanceId(id)), sequence, drafts);
|
|
25
|
+
return events.map(decodeOrchestrationEvent).filter(isWorkflowEvent);
|
|
26
|
+
}
|
|
27
|
+
async list() {
|
|
28
|
+
const ids = new Set((await this.journal.readAll(0))
|
|
29
|
+
.filter((event) => isWorkflowInstanceStream(event.stream))
|
|
30
|
+
.map((event) => event.stream.id));
|
|
31
|
+
return Promise.all([...ids].map(async (id) => (await this.load(id)).view));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function isWorkflowEvent(event) {
|
|
35
|
+
return isWorkflowInstanceStream(event.stream);
|
|
36
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { AcceptActivityOutcome } from './accept-activity-outcome.js';
|
|
2
|
+
import { AcceptSignal } from './accept-signal.js';
|
|
3
|
+
import { AdvanceWorkflow } from './advance-workflow.js';
|
|
4
|
+
import { CoordinationClaims } from './coordination-claims.js';
|
|
5
|
+
import { GroupBudgetRecorder } from './group-budget-recorder.js';
|
|
6
|
+
import { OrchestrationRepository } from './orchestration-repository.js';
|
|
7
|
+
import { RequestChild } from './request-child.js';
|
|
8
|
+
import { StartWorkflow } from './start-workflow.js';
|
|
9
|
+
export class OrchestrationService {
|
|
10
|
+
startWorkflow;
|
|
11
|
+
acceptActivityOutcome;
|
|
12
|
+
acceptWorkflowSignal;
|
|
13
|
+
advanceWorkflow;
|
|
14
|
+
childWorkflows;
|
|
15
|
+
constructor(journal, work, definitions) {
|
|
16
|
+
const repository = new OrchestrationRepository(journal);
|
|
17
|
+
const claims = new CoordinationClaims(journal);
|
|
18
|
+
this.startWorkflow = new StartWorkflow(repository, claims, work, definitions);
|
|
19
|
+
this.acceptWorkflowSignal = new AcceptSignal(repository, this.startWorkflow, work);
|
|
20
|
+
this.advanceWorkflow = new AdvanceWorkflow(repository, this.startWorkflow);
|
|
21
|
+
this.childWorkflows = new RequestChild(repository, claims, new GroupBudgetRecorder(journal), this.startWorkflow, this.advanceWorkflow);
|
|
22
|
+
this.acceptActivityOutcome = new AcceptActivityOutcome(repository, this.startWorkflow, (context) => this.childWorkflows.reconcileChildCompletions(context));
|
|
23
|
+
}
|
|
24
|
+
start(command, context) {
|
|
25
|
+
return this.startWorkflow.execute(command, context);
|
|
26
|
+
}
|
|
27
|
+
requestChild(request, context) {
|
|
28
|
+
return this.childWorkflows.execute(request, context);
|
|
29
|
+
}
|
|
30
|
+
rejectCausalActivation(request, context) {
|
|
31
|
+
return this.childWorkflows.rejectCausalActivation(request, context);
|
|
32
|
+
}
|
|
33
|
+
acceptOutcome(command, context) {
|
|
34
|
+
return this.acceptActivityOutcome.execute(command, context);
|
|
35
|
+
}
|
|
36
|
+
waitForSignal(workflowInstanceId, expectation, context) {
|
|
37
|
+
return this.acceptWorkflowSignal.wait(workflowInstanceId, expectation, context);
|
|
38
|
+
}
|
|
39
|
+
acceptSignal(workflowInstanceId, signal, context) {
|
|
40
|
+
return this.acceptWorkflowSignal.execute(workflowInstanceId, signal, context);
|
|
41
|
+
}
|
|
42
|
+
requestSupplementalActivity(workflowInstanceId, request, context) {
|
|
43
|
+
return this.advanceWorkflow.requestSupplementalActivity(workflowInstanceId, request, context);
|
|
44
|
+
}
|
|
45
|
+
markActivationStarted(workflowInstanceId, activationId, context) {
|
|
46
|
+
return this.advanceWorkflow.markActivationStarted(workflowInstanceId, activationId, context);
|
|
47
|
+
}
|
|
48
|
+
block(workflowInstanceId, reason, context) {
|
|
49
|
+
return this.advanceWorkflow.block(workflowInstanceId, reason, context);
|
|
50
|
+
}
|
|
51
|
+
resolveExecutionFailure(workflowInstanceId, input, context) {
|
|
52
|
+
return this.advanceWorkflow.resolveExecutionFailure(workflowInstanceId, input, context);
|
|
53
|
+
}
|
|
54
|
+
retryBlockedFailedStage(workflowInstanceId, context) {
|
|
55
|
+
return this.advanceWorkflow.retryBlockedFailedStage(workflowInstanceId, context);
|
|
56
|
+
}
|
|
57
|
+
get(id) {
|
|
58
|
+
return this.advanceWorkflow.get(id);
|
|
59
|
+
}
|
|
60
|
+
getPrimaryWorkflowInstanceId(workItemId) {
|
|
61
|
+
return this.childWorkflows.getPrimaryWorkflowInstanceId(workItemId);
|
|
62
|
+
}
|
|
63
|
+
listPendingActivations(workItemId) {
|
|
64
|
+
return this.advanceWorkflow.listPendingActivations(workItemId);
|
|
65
|
+
}
|
|
66
|
+
listWaiting(signalKind) {
|
|
67
|
+
return this.advanceWorkflow.listWaiting(signalKind);
|
|
68
|
+
}
|
|
69
|
+
listAll() {
|
|
70
|
+
return this.advanceWorkflow.listAll();
|
|
71
|
+
}
|
|
72
|
+
reconcileChildCompletions(context) {
|
|
73
|
+
return this.childWorkflows.reconcileChildCompletions(context);
|
|
74
|
+
}
|
|
75
|
+
isCausalRepeat(workflowInstanceId, triggerId, causalCycleId, requestId) {
|
|
76
|
+
return this.childWorkflows.isCausalRepeat(workflowInstanceId, triggerId, causalCycleId, requestId);
|
|
77
|
+
}
|
|
78
|
+
listWatchMatches(eventType) {
|
|
79
|
+
return this.advanceWorkflow.listWatchMatches(eventType);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export const createOrchestrationService = (journal, work, definitions) => new OrchestrationService(journal, work, definitions);
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
2
|
+
import { signalName } from '../contracts/identifiers.js';
|
|
3
|
+
import { childOrchestrationGroupStream } from '../contracts/streams.js';
|
|
4
|
+
import { WorkflowStatus } from '../contracts/vocabulary.js';
|
|
5
|
+
import { childMetadata, childRequestId, coordinationMetadata } from '../domain/child-policy.js';
|
|
6
|
+
import { coordinationDraft } from '../domain/coordination-events.js';
|
|
7
|
+
import { stateDraft } from '../domain/decision-events.js';
|
|
8
|
+
import { acceptSignal as decideSignal } from '../domain/interpreter.js';
|
|
9
|
+
export class RequestChild {
|
|
10
|
+
repository;
|
|
11
|
+
claims;
|
|
12
|
+
groupBudgets;
|
|
13
|
+
workflows;
|
|
14
|
+
advance;
|
|
15
|
+
constructor(repository, claims, groupBudgets, workflows, advance) {
|
|
16
|
+
this.repository = repository;
|
|
17
|
+
this.claims = claims;
|
|
18
|
+
this.groupBudgets = groupBudgets;
|
|
19
|
+
this.workflows = workflows;
|
|
20
|
+
this.advance = advance;
|
|
21
|
+
}
|
|
22
|
+
async execute(request, context) {
|
|
23
|
+
const parent = await this.repository.loadRequired(request.parentWorkflowInstanceId);
|
|
24
|
+
const id = childRequestId(request);
|
|
25
|
+
if (request.requestId !== id)
|
|
26
|
+
throw new Error('Child request id must be stable for its parent, watch, and trigger');
|
|
27
|
+
const existing = await this.repository.load(id);
|
|
28
|
+
if (existing.view !== null)
|
|
29
|
+
return existing.view;
|
|
30
|
+
const group = childOrchestrationGroupStream(parent.view.orchestrationGroupId, request.watchId);
|
|
31
|
+
const metadata = coordinationMetadata(parent.view, request);
|
|
32
|
+
if (!(await this.claims.claimWithinBudget(group, request, context))) {
|
|
33
|
+
await this.groupBudgets.record(parent.view, metadata, request.maxPerGroup, context);
|
|
34
|
+
return { kind: 'group-budget-exhausted', requestId: request.requestId };
|
|
35
|
+
}
|
|
36
|
+
return this.workflows.execute({
|
|
37
|
+
workflowInstanceId: id,
|
|
38
|
+
workItemId: parent.view.workItemId,
|
|
39
|
+
workflowName: request.workflowName,
|
|
40
|
+
orchestrationGroupId: parent.view.orchestrationGroupId,
|
|
41
|
+
parentWorkflowInstanceId: request.parentWorkflowInstanceId,
|
|
42
|
+
watchId: request.watchId,
|
|
43
|
+
triggerId: request.triggerId,
|
|
44
|
+
causalCycleId: request.causalCycleId,
|
|
45
|
+
requestId: request.requestId,
|
|
46
|
+
}, context);
|
|
47
|
+
}
|
|
48
|
+
async rejectCausalActivation(request, context) {
|
|
49
|
+
const loaded = await this.repository.loadRequired(request.parentWorkflowInstanceId);
|
|
50
|
+
if (loaded.view.causalRejectionIds.includes(request.triggerId))
|
|
51
|
+
return loaded.view;
|
|
52
|
+
const metadata = coordinationMetadata(loaded.view, request);
|
|
53
|
+
await this.repository.append(loaded.view.workflowInstanceId, loaded.sequence, [
|
|
54
|
+
this.coordinationEvent(loaded.view, context, OrchestrationEventType.CausalActivationRejected, metadata, 1),
|
|
55
|
+
stateDraft(loaded.view, { occurredAt: context.occurredAt, causationId: context.commandId }, OrchestrationEventType.InstanceBlocked, { reason: 'causal activation rejected' }, 2),
|
|
56
|
+
]);
|
|
57
|
+
return (await this.repository.loadRequired(loaded.view.workflowInstanceId)).view;
|
|
58
|
+
}
|
|
59
|
+
async reconcileChildCompletions(context) {
|
|
60
|
+
for (const child of await this.advance.listAll()) {
|
|
61
|
+
if (child.parentWorkflowInstanceId !== undefined && child.status === WorkflowStatus.Completed)
|
|
62
|
+
await this.complete(child, {
|
|
63
|
+
...context,
|
|
64
|
+
commandId: `${context.commandId}:child:${child.workflowInstanceId}`,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async isCausalRepeat(workflowInstanceId, triggerId, causalCycleId, requestId) {
|
|
69
|
+
const parent = await this.repository.loadRequired(workflowInstanceId);
|
|
70
|
+
return (await this.advance.listAll()).some((view) => view.orchestrationGroupId === parent.view.orchestrationGroupId &&
|
|
71
|
+
view.parentWorkflowInstanceId !== undefined &&
|
|
72
|
+
view.requestId !== requestId &&
|
|
73
|
+
(view.triggerId === triggerId ||
|
|
74
|
+
(causalCycleId !== undefined && view.causalCycleId === causalCycleId)));
|
|
75
|
+
}
|
|
76
|
+
async getPrimaryWorkflowInstanceId(workItemId) {
|
|
77
|
+
return this.claims.primaryWorkflowInstanceId(workItemId);
|
|
78
|
+
}
|
|
79
|
+
async complete(child, context) {
|
|
80
|
+
const metadata = childMetadata(child);
|
|
81
|
+
const childLoaded = await this.repository.loadRequired(child.workflowInstanceId);
|
|
82
|
+
if (!childLoaded.view.childCompletionRecorded)
|
|
83
|
+
await this.repository.append(child.workflowInstanceId, childLoaded.sequence, [
|
|
84
|
+
this.coordinationEvent(child, context, OrchestrationEventType.ChildCompleted, metadata, 1),
|
|
85
|
+
]);
|
|
86
|
+
const parent = await this.repository.loadRequired(metadata.parentWorkflowInstanceId);
|
|
87
|
+
if (parent.view.acceptedChildCompletionIds.includes(child.workflowInstanceId))
|
|
88
|
+
return;
|
|
89
|
+
const signal = {
|
|
90
|
+
kind: signalName(OrchestrationEventType.ChildCompleted),
|
|
91
|
+
actorId: 'orchestration',
|
|
92
|
+
actorDecision: { authorized: true, evidenceId: child.workflowInstanceId },
|
|
93
|
+
providerEventId: child.workflowInstanceId,
|
|
94
|
+
childWorkflowInstanceId: child.workflowInstanceId,
|
|
95
|
+
requestId: metadata.requestId,
|
|
96
|
+
};
|
|
97
|
+
const decision = decideSignal(this.workflows.definition(parent.view.workflowName), parent.view, {
|
|
98
|
+
signal,
|
|
99
|
+
occurredAt: context.occurredAt,
|
|
100
|
+
causationId: context.commandId,
|
|
101
|
+
});
|
|
102
|
+
if (decision.kind === 'ignored')
|
|
103
|
+
return;
|
|
104
|
+
await this.repository.append(parent.view.workflowInstanceId, parent.sequence, [
|
|
105
|
+
...decision.events,
|
|
106
|
+
this.coordinationEvent(parent.view, context, OrchestrationEventType.ChildCompletionConsumed, metadata, 2),
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
coordinationEvent(state, context, eventType, payload, ordinal) {
|
|
110
|
+
return coordinationDraft({
|
|
111
|
+
workflowInstanceId: state.workflowInstanceId,
|
|
112
|
+
eventIdPrefix: context.commandId,
|
|
113
|
+
occurredAt: context.occurredAt,
|
|
114
|
+
correlationId: state.orchestrationGroupId,
|
|
115
|
+
causationId: context.commandId,
|
|
116
|
+
}, eventType, payload, ordinal);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function createSignalReactor(orchestration) {
|
|
2
|
+
return {
|
|
3
|
+
async accept(signal, context) {
|
|
4
|
+
const waiting = await orchestration.listWaiting(signal.kind);
|
|
5
|
+
const accepted = [];
|
|
6
|
+
for (const instance of waiting) {
|
|
7
|
+
if (instance === null)
|
|
8
|
+
continue;
|
|
9
|
+
const before = instance.acceptedSignalIds.length;
|
|
10
|
+
const after = await orchestration.acceptSignal(instance.workflowInstanceId, signal, context);
|
|
11
|
+
if (after.acceptedSignalIds.length > before)
|
|
12
|
+
accepted.push(after);
|
|
13
|
+
}
|
|
14
|
+
return accepted;
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|