@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,61 @@
|
|
|
1
|
+
import { ActivityOutcomeKind } from '../../activities/index.js';
|
|
2
|
+
import { EventActorKind } from '../../kernel/index.js';
|
|
3
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
4
|
+
import { stageName } from '../contracts/identifiers.js';
|
|
5
|
+
import { ApprovalAuthorityKind, WorkflowStatus } from '../contracts/vocabulary.js';
|
|
6
|
+
import { activation, nextOrdinal, stateDraft } from './decision-events.js';
|
|
7
|
+
export function requestSupplementalActivity(state, request, input) {
|
|
8
|
+
if (state.status !== WorkflowStatus.Active || state.pendingActivation === undefined)
|
|
9
|
+
return { kind: 'ignored', reason: 'supplemental commands require an active WorkflowInstance' };
|
|
10
|
+
return {
|
|
11
|
+
kind: 'append',
|
|
12
|
+
events: [
|
|
13
|
+
stateDraft(state, input, OrchestrationEventType.SupplementalActivityQueued, {
|
|
14
|
+
activity: request.activity,
|
|
15
|
+
input: request.input,
|
|
16
|
+
requestedBy: request.requestedBy,
|
|
17
|
+
}, 1),
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function finishSupplemental(events, definition, state, input) {
|
|
22
|
+
if (input.outcome.kind !== ActivityOutcomeKind.Done) {
|
|
23
|
+
events.push(stateDraft(state, input, OrchestrationEventType.InstanceBlocked, { reason: `supplemental activity returned ${input.outcome.kind}` }, events.length + 1));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (state.supplementalQueue.length > 0) {
|
|
27
|
+
requestNextSupplemental(events, state, input);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const stage = definition.stages[stageName(state.currentStage)];
|
|
31
|
+
events.push(stateDraft(state, input, OrchestrationEventType.ActivityRequested, activation(state.workflowInstanceId, nextOrdinal(state), stage.activity, stage.with, {
|
|
32
|
+
execution: stage.execution,
|
|
33
|
+
stage: stageName(state.currentStage),
|
|
34
|
+
}), events.length + 1));
|
|
35
|
+
}
|
|
36
|
+
export function requestNextSupplemental(events, state, input) {
|
|
37
|
+
const next = state.supplementalQueue[0];
|
|
38
|
+
events.push(stateDraft(state, input, OrchestrationEventType.SupplementalActivityDequeued, { activity: next.activity, requestedBy: next.requestedBy }, events.length + 1), stateDraft(state, input, OrchestrationEventType.ActivityRequested, activation(state.workflowInstanceId, nextOrdinal(state), next.activity, next.input, {
|
|
39
|
+
execution: undefined,
|
|
40
|
+
supplemental: true,
|
|
41
|
+
}), events.length + 2));
|
|
42
|
+
}
|
|
43
|
+
// A command's `allowedActors` declares acceptance authority (ORCH-APPROVAL-AUTHORITY), not
|
|
44
|
+
// event provenance, so the invoking actor's provenance is resolved to an authority first.
|
|
45
|
+
export function isAuthorisedActor(allowed, actorKind) {
|
|
46
|
+
const authority = actorAuthority(actorKind);
|
|
47
|
+
return authority !== null && allowed.includes(authority);
|
|
48
|
+
}
|
|
49
|
+
// Provenance answers who emitted the event; authority answers who may invoke. A provider
|
|
50
|
+
// relays a person typing in a ticket comment, which D16 counts as `human` on any surface.
|
|
51
|
+
// `auto` is never inferred from transport: it requires operator consent, so granting it
|
|
52
|
+
// from an actor kind would escalate authority without one.
|
|
53
|
+
function actorAuthority(actorKind) {
|
|
54
|
+
switch (actorKind) {
|
|
55
|
+
case EventActorKind.Operator:
|
|
56
|
+
case EventActorKind.Integration:
|
|
57
|
+
return ApprovalAuthorityKind.Human;
|
|
58
|
+
default:
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { OrchestrationEventType, WatchGateVerdictSignal } from '../contracts/events.js';
|
|
2
|
+
import { ApprovalAuthorityKind, TransitionTargetKind } from '../contracts/vocabulary.js';
|
|
3
|
+
import { activation, nextOrdinal, stateDraft } from './decision-events.js';
|
|
4
|
+
export function finishRoute(events, definition, state, input, route) {
|
|
5
|
+
if (route.watchGates !== undefined) {
|
|
6
|
+
const gate = route.watchGates[0];
|
|
7
|
+
events.push(stateDraft(state, input, OrchestrationEventType.SignalWaitStarted, {
|
|
8
|
+
signalKind: WatchGateVerdictSignal,
|
|
9
|
+
from: Object.freeze([
|
|
10
|
+
{ kind: ApprovalAuthorityKind.Watch, watch: gate.watch },
|
|
11
|
+
{ kind: ApprovalAuthorityKind.Human },
|
|
12
|
+
]),
|
|
13
|
+
resume: route.target,
|
|
14
|
+
onRejectResume: gate.onRejectTarget,
|
|
15
|
+
}, events.length + 1));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (route.await !== undefined) {
|
|
19
|
+
events.push(stateDraft(state, input, OrchestrationEventType.SignalWaitStarted, { signalKind: route.await.signal, from: route.await.from, resume: route.await.resume }, events.length + 1));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (route.target.kind !== TransitionTargetKind.Stage) {
|
|
23
|
+
resumeToTarget(events, definition, state, input, route.target);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const count = (state.repeatCounts[route.id] ?? 0) + 1;
|
|
27
|
+
if (route.repeat !== undefined) {
|
|
28
|
+
if (count > route.repeat.max) {
|
|
29
|
+
events.push(stateDraft(state, input, OrchestrationEventType.InstanceBlocked, { reason: `repeat.max exceeded for ${route.id}` }, events.length + 1));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
events.push(stateDraft(state, input, OrchestrationEventType.RepeatCounted, { routeId: route.id, count }, events.length + 1));
|
|
33
|
+
}
|
|
34
|
+
pushStageEntry(events, definition, state, input, route.target.stage);
|
|
35
|
+
}
|
|
36
|
+
function pushStageEntry(events, definition, state, input, stageName) {
|
|
37
|
+
const stage = definition.stages[stageName];
|
|
38
|
+
events.push(stateDraft(state, input, OrchestrationEventType.StageEntered, { stage: stageName }, events.length + 1), stateDraft(state, input, OrchestrationEventType.ActivityRequested, activation(state.workflowInstanceId, nextOrdinal(state), stage.activity, stage.with, {
|
|
39
|
+
execution: stage.execution,
|
|
40
|
+
stage: stageName,
|
|
41
|
+
}), events.length + 2));
|
|
42
|
+
}
|
|
43
|
+
// Shared by a route with no gate (target reached directly) and a resumed wait
|
|
44
|
+
// (target reached after an accepted signal); neither carries repeat counting.
|
|
45
|
+
export function resumeToTarget(events, definition, state, input, target) {
|
|
46
|
+
if (target.kind === TransitionTargetKind.Complete) {
|
|
47
|
+
events.push(stateDraft(state, input, OrchestrationEventType.InstanceCompleted, {}, events.length + 1));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (target.kind === TransitionTargetKind.AwaitSignal) {
|
|
51
|
+
events.push(stateDraft(state, input, OrchestrationEventType.SignalWaitStarted, { signalKind: target.signal }, events.length + 1));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
pushStageEntry(events, definition, state, input, target.stage);
|
|
55
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { stageName } from '../contracts/identifiers.js';
|
|
2
|
+
import { TransitionTargetKind } from '../contracts/vocabulary.js';
|
|
3
|
+
function edges(stages, name) {
|
|
4
|
+
return Object.values(stages[name].on).flatMap((route) => route.target.kind === TransitionTargetKind.Stage ? [route.target.stage] : []);
|
|
5
|
+
}
|
|
6
|
+
export function assertReachable(entry, stages) {
|
|
7
|
+
const reached = new Set();
|
|
8
|
+
const visit = (name) => {
|
|
9
|
+
if (reached.has(name))
|
|
10
|
+
return;
|
|
11
|
+
reached.add(name);
|
|
12
|
+
for (const target of edges(stages, name))
|
|
13
|
+
visit(target);
|
|
14
|
+
};
|
|
15
|
+
visit(entry);
|
|
16
|
+
const missing = Object.keys(stages).filter((name) => !reached.has(name));
|
|
17
|
+
if (missing.length > 0)
|
|
18
|
+
throw new Error(`Unreachable workflow stage: ${missing.join(', ')}`);
|
|
19
|
+
}
|
|
20
|
+
export function assertCyclesBounded(stages) {
|
|
21
|
+
for (const [from, stage] of Object.entries(stages)) {
|
|
22
|
+
for (const route of Object.values(stage.on)) {
|
|
23
|
+
if (route.target.kind === TransitionTargetKind.Stage &&
|
|
24
|
+
canReach(stages, route.target.stage, stageName(from)) &&
|
|
25
|
+
route.repeat === undefined)
|
|
26
|
+
throw new Error(`Cycle-closing route ${route.id} requires repeat.max`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function canReach(stages, from, target) {
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
const visit = (name) => {
|
|
33
|
+
if (name === target)
|
|
34
|
+
return true;
|
|
35
|
+
if (seen.has(name))
|
|
36
|
+
return false;
|
|
37
|
+
seen.add(name);
|
|
38
|
+
return edges(stages, name).some(visit);
|
|
39
|
+
};
|
|
40
|
+
return visit(from);
|
|
41
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
import { OrchestrationEventType, } from '../contracts/events.js';
|
|
3
|
+
import { ActivityActivationStatus, WorkflowStatus } from '../contracts/vocabulary.js';
|
|
4
|
+
/**
|
|
5
|
+
* The single source of truth for which orchestration events change a
|
|
6
|
+
* workflow instance's status, and to what — every other consumer that needs
|
|
7
|
+
* to reflect status externally (GitHub labels, the operator board, delivery
|
|
8
|
+
* reactors) must derive from this table rather than hand-matching event
|
|
9
|
+
* types itself, or it silently falls out of sync whenever a new
|
|
10
|
+
* status-changing event type is introduced here.
|
|
11
|
+
*/
|
|
12
|
+
export const orchestrationStatusTransitions = {
|
|
13
|
+
[OrchestrationEventType.ActivityRequested]: WorkflowStatus.Active,
|
|
14
|
+
[OrchestrationEventType.ActivityWaiting]: WorkflowStatus.Waiting,
|
|
15
|
+
[OrchestrationEventType.SignalWaitStarted]: WorkflowStatus.Waiting,
|
|
16
|
+
[OrchestrationEventType.SignalAccepted]: WorkflowStatus.Active,
|
|
17
|
+
[OrchestrationEventType.InstanceCompleted]: WorkflowStatus.Completed,
|
|
18
|
+
[OrchestrationEventType.InstanceBlocked]: WorkflowStatus.Blocked,
|
|
19
|
+
[OrchestrationEventType.InstanceSuperseded]: WorkflowStatus.Superseded,
|
|
20
|
+
};
|
|
21
|
+
export function applyWorkflowInstanceEvent(state, event) {
|
|
22
|
+
if (isActivityFact(event))
|
|
23
|
+
return applyActivityFact(state, event);
|
|
24
|
+
if (isInteractionFact(event))
|
|
25
|
+
return applyInteractionFact(state, event);
|
|
26
|
+
if (isLifecycleFact(event))
|
|
27
|
+
return applyLifecycleFact(state, event);
|
|
28
|
+
applyCoordinationFact(state, event);
|
|
29
|
+
}
|
|
30
|
+
function isActivityFact(event) {
|
|
31
|
+
switch (event.eventType) {
|
|
32
|
+
case OrchestrationEventType.StageEntered:
|
|
33
|
+
case OrchestrationEventType.ActivityRequested:
|
|
34
|
+
case OrchestrationEventType.ActivityStarted:
|
|
35
|
+
case OrchestrationEventType.ActivityOutcomeAccepted:
|
|
36
|
+
case OrchestrationEventType.ActivityExecutionFailed:
|
|
37
|
+
case OrchestrationEventType.ActivityWaiting:
|
|
38
|
+
return true;
|
|
39
|
+
default:
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function applyActivityFact(state, event) {
|
|
44
|
+
switch (event.eventType) {
|
|
45
|
+
case OrchestrationEventType.StageEntered:
|
|
46
|
+
state.currentStage = event.payload.stage;
|
|
47
|
+
return;
|
|
48
|
+
case OrchestrationEventType.ActivityRequested:
|
|
49
|
+
applyActivityRequested(state, event.payload);
|
|
50
|
+
return;
|
|
51
|
+
case OrchestrationEventType.ActivityStarted:
|
|
52
|
+
updateActivationStatus(state, event.payload.activationId, ActivityActivationStatus.Running);
|
|
53
|
+
return;
|
|
54
|
+
case OrchestrationEventType.ActivityOutcomeAccepted:
|
|
55
|
+
state.acceptedOutcomes.push(event.payload.activationId);
|
|
56
|
+
state.lastOutcome = event.payload.outcome;
|
|
57
|
+
updateActivationStatus(state, event.payload.activationId, ActivityActivationStatus.Completed);
|
|
58
|
+
return;
|
|
59
|
+
case OrchestrationEventType.ActivityExecutionFailed:
|
|
60
|
+
state.acceptedOutcomes.push(event.payload.activationId);
|
|
61
|
+
updateActivationStatus(state, event.payload.activationId, ActivityActivationStatus.Completed);
|
|
62
|
+
return;
|
|
63
|
+
case OrchestrationEventType.ActivityWaiting:
|
|
64
|
+
applyActivityWaiting(state, event);
|
|
65
|
+
return;
|
|
66
|
+
default:
|
|
67
|
+
assertNever(event);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function isInteractionFact(event) {
|
|
71
|
+
switch (event.eventType) {
|
|
72
|
+
case OrchestrationEventType.SignalWaitStarted:
|
|
73
|
+
case OrchestrationEventType.SignalAccepted:
|
|
74
|
+
case OrchestrationEventType.SupplementalActivityQueued:
|
|
75
|
+
case OrchestrationEventType.SupplementalActivityDequeued:
|
|
76
|
+
return true;
|
|
77
|
+
default:
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function applyInteractionFact(state, event) {
|
|
82
|
+
switch (event.eventType) {
|
|
83
|
+
case OrchestrationEventType.SignalWaitStarted:
|
|
84
|
+
applySignalWaitStarted(state, event);
|
|
85
|
+
return;
|
|
86
|
+
case OrchestrationEventType.SignalAccepted:
|
|
87
|
+
state.status = orchestrationStatusTransitions[OrchestrationEventType.SignalAccepted];
|
|
88
|
+
state.acceptedSignalIds.push(event.payload.providerEventId);
|
|
89
|
+
delete state.waitingFor;
|
|
90
|
+
return;
|
|
91
|
+
case OrchestrationEventType.SupplementalActivityQueued:
|
|
92
|
+
state.supplementalQueue.push(event.payload);
|
|
93
|
+
return;
|
|
94
|
+
case OrchestrationEventType.SupplementalActivityDequeued:
|
|
95
|
+
state.supplementalQueue.shift();
|
|
96
|
+
return;
|
|
97
|
+
default:
|
|
98
|
+
assertNever(event);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function isLifecycleFact(event) {
|
|
102
|
+
switch (event.eventType) {
|
|
103
|
+
case OrchestrationEventType.RepeatCounted:
|
|
104
|
+
case OrchestrationEventType.RetryCounted:
|
|
105
|
+
case OrchestrationEventType.InstanceCompleted:
|
|
106
|
+
case OrchestrationEventType.InstanceBlocked:
|
|
107
|
+
case OrchestrationEventType.OperatorRetryRequested:
|
|
108
|
+
case OrchestrationEventType.InstanceSuperseded:
|
|
109
|
+
return true;
|
|
110
|
+
default:
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function applyLifecycleFact(state, event) {
|
|
115
|
+
switch (event.eventType) {
|
|
116
|
+
case OrchestrationEventType.RepeatCounted:
|
|
117
|
+
state.repeatCounts[event.payload.routeId] = event.payload.count;
|
|
118
|
+
return;
|
|
119
|
+
case OrchestrationEventType.RetryCounted:
|
|
120
|
+
state.retryCounts[event.payload.retryKey] = event.payload.count;
|
|
121
|
+
return;
|
|
122
|
+
case OrchestrationEventType.InstanceCompleted:
|
|
123
|
+
state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceCompleted];
|
|
124
|
+
delete state.pendingActivation;
|
|
125
|
+
delete state.waitingFor;
|
|
126
|
+
return;
|
|
127
|
+
case OrchestrationEventType.InstanceBlocked:
|
|
128
|
+
state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceBlocked];
|
|
129
|
+
state.blockReason = event.payload.reason;
|
|
130
|
+
return;
|
|
131
|
+
case OrchestrationEventType.OperatorRetryRequested:
|
|
132
|
+
state.operatorRetryCommandIds.push(event.payload.commandId);
|
|
133
|
+
return;
|
|
134
|
+
case OrchestrationEventType.InstanceSuperseded:
|
|
135
|
+
state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceSuperseded];
|
|
136
|
+
return;
|
|
137
|
+
default:
|
|
138
|
+
assertNever(event);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function applyCoordinationFact(state, event) {
|
|
142
|
+
switch (event.eventType) {
|
|
143
|
+
case OrchestrationEventType.InstanceStarted:
|
|
144
|
+
case OrchestrationEventType.ChildRequested:
|
|
145
|
+
case OrchestrationEventType.ChildStarted:
|
|
146
|
+
case OrchestrationEventType.GroupBudgetExhausted:
|
|
147
|
+
return;
|
|
148
|
+
case OrchestrationEventType.ChildCompleted:
|
|
149
|
+
state.childCompletionRecorded = true;
|
|
150
|
+
return;
|
|
151
|
+
case OrchestrationEventType.ChildCompletionConsumed:
|
|
152
|
+
state.acceptedChildCompletionIds.push(event.payload.childWorkflowInstanceId);
|
|
153
|
+
return;
|
|
154
|
+
case OrchestrationEventType.CausalActivationRejected:
|
|
155
|
+
state.causalRejectionIds.push(event.payload.triggerId);
|
|
156
|
+
return;
|
|
157
|
+
default:
|
|
158
|
+
assertNever(event);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function applyActivityWaiting(state, event) {
|
|
162
|
+
state.status = orchestrationStatusTransitions[OrchestrationEventType.ActivityWaiting];
|
|
163
|
+
state.waitingFor = {
|
|
164
|
+
signalKind: event.payload.outcome.data.signalKind,
|
|
165
|
+
intentEventId: event.payload.outcome.data.intentEventId,
|
|
166
|
+
};
|
|
167
|
+
state.lastOutcome = event.payload.outcome;
|
|
168
|
+
updateActivationStatus(state, event.payload.activationId, ActivityActivationStatus.Waiting);
|
|
169
|
+
}
|
|
170
|
+
function applySignalWaitStarted(state, event) {
|
|
171
|
+
state.status = orchestrationStatusTransitions[OrchestrationEventType.SignalWaitStarted];
|
|
172
|
+
state.waitingFor = {
|
|
173
|
+
signalKind: event.payload.signalKind,
|
|
174
|
+
...(event.payload.resourceId === undefined ? {} : { resourceId: event.payload.resourceId }),
|
|
175
|
+
...(event.payload.revision === undefined ? {} : { revision: event.payload.revision }),
|
|
176
|
+
...(event.payload.from === undefined ? {} : { from: event.payload.from }),
|
|
177
|
+
...(event.payload.resume === undefined ? {} : { resume: event.payload.resume }),
|
|
178
|
+
...(event.payload.onRejectResume === undefined
|
|
179
|
+
? {}
|
|
180
|
+
: { onRejectResume: event.payload.onRejectResume }),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function updateActivationStatus(state, activationId, status) {
|
|
184
|
+
if (state.pendingActivation?.activationId === activationId)
|
|
185
|
+
state.pendingActivation = { ...state.pendingActivation, status };
|
|
186
|
+
}
|
|
187
|
+
function applyActivityRequested(state, payload) {
|
|
188
|
+
state.status = orchestrationStatusTransitions[OrchestrationEventType.ActivityRequested];
|
|
189
|
+
delete state.waitingFor;
|
|
190
|
+
state.pendingActivation = {
|
|
191
|
+
activationId: payload.activationId,
|
|
192
|
+
ordinal: payload.ordinal,
|
|
193
|
+
activity: payload.activity,
|
|
194
|
+
...(payload.stage === undefined ? {} : { stage: payload.stage }),
|
|
195
|
+
input: payload.input,
|
|
196
|
+
execution: payload.execution,
|
|
197
|
+
status: ActivityActivationStatus.Pending,
|
|
198
|
+
...(payload.followOnIndex === undefined ? {} : { followOnIndex: payload.followOnIndex }),
|
|
199
|
+
...(payload.supplemental === true ? { supplemental: true } : {}),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export function immutableWorkflowInstanceView(state) {
|
|
203
|
+
return {
|
|
204
|
+
workflowInstanceId: state.workflowInstanceId,
|
|
205
|
+
workItemId: state.workItemId,
|
|
206
|
+
workflowName: state.workflowName,
|
|
207
|
+
orchestrationGroupId: state.orchestrationGroupId,
|
|
208
|
+
...(state.parentWorkflowInstanceId === undefined
|
|
209
|
+
? {}
|
|
210
|
+
: { parentWorkflowInstanceId: state.parentWorkflowInstanceId }),
|
|
211
|
+
...(state.watchId === undefined ? {} : { watchId: state.watchId }),
|
|
212
|
+
...(state.triggerId === undefined ? {} : { triggerId: state.triggerId }),
|
|
213
|
+
...(state.causalCycleId === undefined ? {} : { causalCycleId: state.causalCycleId }),
|
|
214
|
+
...(state.requestId === undefined ? {} : { requestId: state.requestId }),
|
|
215
|
+
status: state.status,
|
|
216
|
+
...(state.blockReason === undefined ? {} : { blockReason: state.blockReason }),
|
|
217
|
+
currentStage: state.currentStage,
|
|
218
|
+
repeatCounts: state.repeatCounts,
|
|
219
|
+
retryCounts: state.retryCounts,
|
|
220
|
+
supplementalQueue: state.supplementalQueue,
|
|
221
|
+
acceptedSignalIds: state.acceptedSignalIds,
|
|
222
|
+
operatorRetryCommandIds: state.operatorRetryCommandIds,
|
|
223
|
+
acceptedOutcomes: state.acceptedOutcomes,
|
|
224
|
+
acceptedChildCompletionIds: state.acceptedChildCompletionIds,
|
|
225
|
+
causalRejectionIds: state.causalRejectionIds,
|
|
226
|
+
childCompletionRecorded: state.childCompletionRecorded,
|
|
227
|
+
...(state.pendingActivation === undefined
|
|
228
|
+
? {}
|
|
229
|
+
: { pendingActivation: state.pendingActivation }),
|
|
230
|
+
...(state.lastOutcome === undefined ? {} : { lastOutcome: state.lastOutcome }),
|
|
231
|
+
...(state.waitingFor === undefined ? {} : { waitingFor: state.waitingFor }),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function assertNever(value) {
|
|
235
|
+
throw new Error(`Unhandled WorkflowInstance event: ${JSON.stringify(value)}`);
|
|
236
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
2
|
+
import { WorkflowStatus } from '../contracts/vocabulary.js';
|
|
3
|
+
import { applyWorkflowInstanceEvent, immutableWorkflowInstanceView, orchestrationStatusTransitions, } from './workflow-instance-events.js';
|
|
4
|
+
export { orchestrationStatusTransitions };
|
|
5
|
+
export function foldWorkflowInstance(events) {
|
|
6
|
+
const first = events.find((event) => event.eventType === OrchestrationEventType.InstanceStarted);
|
|
7
|
+
if (first === undefined)
|
|
8
|
+
return null;
|
|
9
|
+
const state = {
|
|
10
|
+
workflowInstanceId: first.stream.id,
|
|
11
|
+
workItemId: first.payload.workItemId,
|
|
12
|
+
workflowName: first.payload.workflowName,
|
|
13
|
+
orchestrationGroupId: first.payload.orchestrationGroupId,
|
|
14
|
+
...optionalChildFields(first.payload),
|
|
15
|
+
status: WorkflowStatus.Active,
|
|
16
|
+
currentStage: first.payload.entry,
|
|
17
|
+
repeatCounts: {},
|
|
18
|
+
retryCounts: {},
|
|
19
|
+
supplementalQueue: [],
|
|
20
|
+
acceptedSignalIds: [],
|
|
21
|
+
operatorRetryCommandIds: [],
|
|
22
|
+
acceptedOutcomes: [],
|
|
23
|
+
acceptedChildCompletionIds: [],
|
|
24
|
+
causalRejectionIds: [],
|
|
25
|
+
childCompletionRecorded: false,
|
|
26
|
+
};
|
|
27
|
+
for (const event of events)
|
|
28
|
+
applyWorkflowInstanceEvent(state, event);
|
|
29
|
+
return immutableWorkflowInstanceView(state);
|
|
30
|
+
}
|
|
31
|
+
function optionalChildFields(payload) {
|
|
32
|
+
return 'parentWorkflowInstanceId' in payload
|
|
33
|
+
? {
|
|
34
|
+
parentWorkflowInstanceId: payload.parentWorkflowInstanceId,
|
|
35
|
+
watchId: payload.watchId,
|
|
36
|
+
triggerId: payload.triggerId,
|
|
37
|
+
causalCycleId: payload.causalCycleId,
|
|
38
|
+
requestId: payload.requestId,
|
|
39
|
+
}
|
|
40
|
+
: {};
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { matchesRequiredValues } from '../../kernel/index.js';
|
|
2
|
+
import { workflowName } from '../contracts/identifiers.js';
|
|
3
|
+
export function compileWorkflowSelectors(selectors) {
|
|
4
|
+
return selectors.map((selector) => ({
|
|
5
|
+
match: selector.match,
|
|
6
|
+
matchMode: selector.matchMode,
|
|
7
|
+
workflow: workflowName(selector.workflow),
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
export function selectWorkflow(candidate, selectors, fallback) {
|
|
11
|
+
return selectors.find((selector) => selectorMatches(selector, candidate))?.workflow ?? fallback;
|
|
12
|
+
}
|
|
13
|
+
function selectorMatches(selector, candidate) {
|
|
14
|
+
const { match, matchMode } = selector;
|
|
15
|
+
return (matchesRequiredValues(matchMode, match.tags ?? [], candidate.tags) &&
|
|
16
|
+
matchesRequiredValues(matchMode, match.kind ?? [], singleton(candidate.kind)) &&
|
|
17
|
+
matchesRequiredValues(matchMode, match.adapter ?? [], singleton(candidate.adapter)));
|
|
18
|
+
}
|
|
19
|
+
function singleton(value) {
|
|
20
|
+
return value === undefined ? [] : [value];
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from './application/orchestration-projection.js';
|
|
2
|
+
export * from './application/orchestration-repository.js';
|
|
3
|
+
export * from './application/orchestration-service.js';
|
|
4
|
+
export * from './application/advance-workflow.js';
|
|
5
|
+
export * from './application/signal-reactor.js';
|
|
6
|
+
export * from './application/watch-reactor.js';
|
|
7
|
+
export * from './contracts/activity-outcome.js';
|
|
8
|
+
export * from './contracts/commands.js';
|
|
9
|
+
export * from './contracts/config.js';
|
|
10
|
+
export * from './contracts/event-decoder.js';
|
|
11
|
+
export * from './contracts/events.js';
|
|
12
|
+
export * from './contracts/identifiers.js';
|
|
13
|
+
export * from './contracts/streams.js';
|
|
14
|
+
export * from './contracts/views.js';
|
|
15
|
+
export * from './contracts/vocabulary.js';
|
|
16
|
+
export * from './domain/compiler.js';
|
|
17
|
+
export * from './domain/interpreter.js';
|
|
18
|
+
export * from './domain/workflow-instance.js';
|
|
19
|
+
export * from './domain/workflow-selector.js';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export class ProjectionRunner {
|
|
2
|
+
journal;
|
|
3
|
+
projections;
|
|
4
|
+
checkpoints;
|
|
5
|
+
registered;
|
|
6
|
+
caughtUpToGlobalPosition;
|
|
7
|
+
constructor(journal, projections, checkpoints, registered = []) {
|
|
8
|
+
this.journal = journal;
|
|
9
|
+
this.projections = projections;
|
|
10
|
+
this.checkpoints = checkpoints;
|
|
11
|
+
this.registered = registered;
|
|
12
|
+
}
|
|
13
|
+
// One shared journal read for every registered definition, not one per
|
|
14
|
+
// definition: readAll ultimately re-derives its content-fingerprint via
|
|
15
|
+
// readdir/stat on every call, so fanning that out per-definition costs a
|
|
16
|
+
// full filesystem probe per definition on every tick even when nothing
|
|
17
|
+
// changed. Fetching once and slicing per-checkpoint in memory keeps the
|
|
18
|
+
// same polling cadence at a fraction of the syscall cost.
|
|
19
|
+
//
|
|
20
|
+
// Resident hosts call this on a fast, fixed idle cadence (control-plane
|
|
21
|
+
// never backs off the internal runner loop, only the external poll), so a
|
|
22
|
+
// fully idle system still calls this multiple times a second. Without this
|
|
23
|
+
// short-circuit that means a per-registered-projection checkpoint file
|
|
24
|
+
// read every call forever, even though nothing changed. Only mark a
|
|
25
|
+
// position "caught up" once every definition processed fewer than a full
|
|
26
|
+
// batch — otherwise a backlog bigger than `limit` would get marked caught
|
|
27
|
+
// up after its first (partial) batch and never finish draining.
|
|
28
|
+
async runRegisteredOnce(limit = 100) {
|
|
29
|
+
const allEvents = await this.journal.readAll(0);
|
|
30
|
+
const latestGlobalPosition = allEvents.at(-1)?.globalPosition ?? 0;
|
|
31
|
+
if (this.caughtUpToGlobalPosition !== undefined &&
|
|
32
|
+
latestGlobalPosition <= this.caughtUpToGlobalPosition)
|
|
33
|
+
return 0;
|
|
34
|
+
const counts = await Promise.all(this.registered.map((definition) => this.applyFrom(definition, allEvents, limit)));
|
|
35
|
+
if (counts.every((count) => count < limit))
|
|
36
|
+
this.caughtUpToGlobalPosition = latestGlobalPosition;
|
|
37
|
+
return counts.reduce((total, count) => total + count, 0);
|
|
38
|
+
}
|
|
39
|
+
async runOnce(definition, limit = 100) {
|
|
40
|
+
const consumer = `projection:${definition.name}`;
|
|
41
|
+
const events = await this.journal.readAll(await this.checkpoints.load(consumer), limit);
|
|
42
|
+
return this.apply(definition, consumer, events);
|
|
43
|
+
}
|
|
44
|
+
async applyFrom(definition, allEvents, limit) {
|
|
45
|
+
const consumer = `projection:${definition.name}`;
|
|
46
|
+
const checkpoint = await this.checkpoints.load(consumer);
|
|
47
|
+
const events = allEvents.filter((event) => event.globalPosition > checkpoint).slice(0, limit);
|
|
48
|
+
return this.apply(definition, consumer, events);
|
|
49
|
+
}
|
|
50
|
+
async apply(definition, consumer, events) {
|
|
51
|
+
for (const event of events) {
|
|
52
|
+
const selected = definition.select(event);
|
|
53
|
+
if (selected !== null) {
|
|
54
|
+
const previous = await this.projections.read(definition.name, selected.key);
|
|
55
|
+
if ((previous?.lastGlobalPosition ?? 0) < event.globalPosition) {
|
|
56
|
+
await this.projections.write({
|
|
57
|
+
namespace: definition.name,
|
|
58
|
+
key: selected.key,
|
|
59
|
+
lastGlobalPosition: event.globalPosition,
|
|
60
|
+
value: definition.project(previous?.value ?? definition.initial(selected.key), event),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
await this.checkpoints.save(consumer, event.globalPosition);
|
|
65
|
+
}
|
|
66
|
+
return events.length;
|
|
67
|
+
}
|
|
68
|
+
async rebuild(definition) {
|
|
69
|
+
await this.projections.clear(definition.name);
|
|
70
|
+
await this.checkpoints.reset(`projection:${definition.name}`);
|
|
71
|
+
let total = 0;
|
|
72
|
+
while (true) {
|
|
73
|
+
const count = await this.runOnce(definition);
|
|
74
|
+
total += count;
|
|
75
|
+
if (count < 100)
|
|
76
|
+
return total;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFile, rm } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { atomicJson, encode } from './file-projection-store.js';
|
|
4
|
+
export class FileCheckpointStore {
|
|
5
|
+
root;
|
|
6
|
+
constructor(root) {
|
|
7
|
+
this.root = root;
|
|
8
|
+
}
|
|
9
|
+
async load(consumer) {
|
|
10
|
+
try {
|
|
11
|
+
const value = JSON.parse(await readFile(this.path(consumer), 'utf8'));
|
|
12
|
+
if (value.consumer !== consumer ||
|
|
13
|
+
!Number.isSafeInteger(value.globalPosition) ||
|
|
14
|
+
value.globalPosition < 0)
|
|
15
|
+
throw new Error(`Invalid checkpoint: ${consumer}`);
|
|
16
|
+
return value.globalPosition;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error.code === 'ENOENT')
|
|
20
|
+
return 0;
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async save(consumer, globalPosition) {
|
|
25
|
+
if (globalPosition < (await this.load(consumer)))
|
|
26
|
+
throw new Error(`Checkpoint regression for ${consumer}`);
|
|
27
|
+
await atomicJson(this.path(consumer), { consumer, globalPosition });
|
|
28
|
+
}
|
|
29
|
+
async reset(consumer) {
|
|
30
|
+
await rm(this.path(consumer), { force: true });
|
|
31
|
+
}
|
|
32
|
+
path(consumer) {
|
|
33
|
+
return join(this.root, 'checkpoints', `${encode(consumer)}.json`);
|
|
34
|
+
}
|
|
35
|
+
}
|