@atolis-hq/wake 0.2.96 → 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 -2365
- 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,51 @@
|
|
|
1
|
+
import { WorkStatus } from '../../work/index.js';
|
|
2
|
+
import { WorkflowInstanceKind } from '../contracts/vocabulary.js';
|
|
3
|
+
import { validateChildProvenance } from '../domain/child-policy.js';
|
|
4
|
+
import { startInstance } from '../domain/interpreter.js';
|
|
5
|
+
export class StartWorkflow {
|
|
6
|
+
repository;
|
|
7
|
+
claims;
|
|
8
|
+
work;
|
|
9
|
+
definitions;
|
|
10
|
+
constructor(repository, claims, work, definitions) {
|
|
11
|
+
this.repository = repository;
|
|
12
|
+
this.claims = claims;
|
|
13
|
+
this.work = work;
|
|
14
|
+
this.definitions = definitions;
|
|
15
|
+
}
|
|
16
|
+
async execute(command, context) {
|
|
17
|
+
const item = await this.work.get(command.workItemId);
|
|
18
|
+
if (item === null || item.state !== WorkStatus.Open)
|
|
19
|
+
throw new Error('WorkItem must exist and be open');
|
|
20
|
+
const definition = this.definition(command.workflowName);
|
|
21
|
+
const existing = await this.repository.load(command.workflowInstanceId);
|
|
22
|
+
if (existing.view !== null)
|
|
23
|
+
return existing.view;
|
|
24
|
+
const startKind = validateChildProvenance(command);
|
|
25
|
+
if (startKind === WorkflowInstanceKind.Primary) {
|
|
26
|
+
await this.claims.claimPrimary(command.workItemId, command.workflowInstanceId, context);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const parent = await this.repository.loadRequired(command.parentWorkflowInstanceId);
|
|
30
|
+
if (parent.view.workItemId !== command.workItemId ||
|
|
31
|
+
parent.view.orchestrationGroupId !== command.orchestrationGroupId)
|
|
32
|
+
throw new Error('Child workflow must share its parent WorkItem and orchestration group');
|
|
33
|
+
}
|
|
34
|
+
const decision = startInstance({
|
|
35
|
+
...command,
|
|
36
|
+
definition,
|
|
37
|
+
occurredAt: context.occurredAt,
|
|
38
|
+
correlationId: context.correlationId,
|
|
39
|
+
causationId: context.commandId,
|
|
40
|
+
});
|
|
41
|
+
if (decision.kind === 'append')
|
|
42
|
+
await this.repository.append(command.workflowInstanceId, 0, decision.events);
|
|
43
|
+
return (await this.repository.loadRequired(command.workflowInstanceId)).view;
|
|
44
|
+
}
|
|
45
|
+
definition(name) {
|
|
46
|
+
const definition = this.definitions[name];
|
|
47
|
+
if (definition === undefined)
|
|
48
|
+
throw new Error(`Unknown workflow: ${name}`);
|
|
49
|
+
return definition;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { selectRunExecutionEvent } from '../../execution/index.js';
|
|
2
|
+
import { correlationId, EventActorKind, } from '../../kernel/index.js';
|
|
3
|
+
import { selectOrchestrationEvent } from '../contracts/event-decoder.js';
|
|
4
|
+
import { workflowInstanceId, workflowName, } from '../contracts/identifiers.js';
|
|
5
|
+
const checkpoint = 'reactor:orchestration.watch';
|
|
6
|
+
export function createWatchReactor(orchestration, journal, checkpoints, runs) {
|
|
7
|
+
return {
|
|
8
|
+
async react(event, context) {
|
|
9
|
+
const causalCycle = orchestrationCausalCycleId(selectOrchestrationEvent(event));
|
|
10
|
+
const sourceWorkflowInstanceId = await resolveRunWorkflowInstanceId(event, runs);
|
|
11
|
+
for (const match of await orchestration.listWatchMatches(event.eventType)) {
|
|
12
|
+
if (sourceWorkflowInstanceId !== undefined &&
|
|
13
|
+
match.parent.workflowInstanceId !== sourceWorkflowInstanceId)
|
|
14
|
+
continue;
|
|
15
|
+
const requestId = workflowInstanceId(`${match.parent.workflowInstanceId}:watch:${match.watch.id}:trigger:${event.eventId}`);
|
|
16
|
+
const request = {
|
|
17
|
+
parentWorkflowInstanceId: match.parent.workflowInstanceId,
|
|
18
|
+
watchId: match.watch.id,
|
|
19
|
+
triggerId: event.eventId,
|
|
20
|
+
workflowName: workflowName(match.watch.workflow),
|
|
21
|
+
causalCycleId: causalCycle ?? requestId,
|
|
22
|
+
requestId,
|
|
23
|
+
maxPerGroup: match.watch.maxPerGroup,
|
|
24
|
+
};
|
|
25
|
+
const requestContext = {
|
|
26
|
+
...context,
|
|
27
|
+
commandId: watchCommandId(context, match, event),
|
|
28
|
+
};
|
|
29
|
+
if ((await orchestration.isCausalRepeat?.(match.parent.workflowInstanceId, event.eventId, causalCycle, request.requestId)) === true) {
|
|
30
|
+
await orchestration.rejectCausalActivation(request, requestContext);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const result = await orchestration.requestChild(request, requestContext);
|
|
34
|
+
if (result === undefined || result === null)
|
|
35
|
+
throw new Error(`Watch child request ${request.requestId} did not complete durably`);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
async runOnce(limit = 100) {
|
|
39
|
+
if (journal === undefined || checkpoints === undefined)
|
|
40
|
+
throw new Error('WatchReactor journal and checkpoints are required to run');
|
|
41
|
+
const events = await journal.readAll(await checkpoints.load(checkpoint), limit);
|
|
42
|
+
for (const event of events) {
|
|
43
|
+
await this.react(event, commandContext(event));
|
|
44
|
+
await checkpoints.save(checkpoint, event.globalPosition);
|
|
45
|
+
}
|
|
46
|
+
return events.length;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function commandContext(event) {
|
|
51
|
+
return {
|
|
52
|
+
commandId: `${event.eventId}:watch`,
|
|
53
|
+
correlationId: correlationId(event.correlationId),
|
|
54
|
+
occurredAt: event.occurredAt,
|
|
55
|
+
actor: { kind: EventActorKind.System, id: 'watch-reactor' },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A run-lifecycle event (e.g. `execution.run-succeeded`) fires for every run
|
|
60
|
+
* in the system, including a watch's own spawned child re-running its own
|
|
61
|
+
* activity on retry. Without this, `listWatchMatches` would treat any
|
|
62
|
+
* currently-eligible parent's declared event type as a match regardless of
|
|
63
|
+
* which run actually produced it, causing a child's own retry (or an
|
|
64
|
+
* unrelated workflow's run) to spuriously re-trigger the same watch.
|
|
65
|
+
*/
|
|
66
|
+
async function resolveRunWorkflowInstanceId(event, runs) {
|
|
67
|
+
if (runs === undefined)
|
|
68
|
+
return undefined;
|
|
69
|
+
const runEvent = selectRunExecutionEvent(event);
|
|
70
|
+
if (runEvent === null)
|
|
71
|
+
return undefined;
|
|
72
|
+
const run = (await runs.load(runEvent.stream.id)).view;
|
|
73
|
+
return run?.workflowInstanceId;
|
|
74
|
+
}
|
|
75
|
+
function orchestrationCausalCycleId(event) {
|
|
76
|
+
return event !== null && 'causalCycleId' in event.payload
|
|
77
|
+
? event.payload.causalCycleId
|
|
78
|
+
: undefined;
|
|
79
|
+
}
|
|
80
|
+
function watchCommandId(context, match, event) {
|
|
81
|
+
return `${context.commandId}:parent:${match.parent.workflowInstanceId}:watch:${match.watch.id}:trigger:${event.eventId}`;
|
|
82
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ActivityOutcomeKind, } from '../../activities/index.js';
|
|
2
|
+
import { signalName } from './identifiers.js';
|
|
3
|
+
export function orchestrationActivityOutcome(outcome) {
|
|
4
|
+
if (outcome.kind !== ActivityOutcomeKind.Waiting)
|
|
5
|
+
return outcome;
|
|
6
|
+
if (typeof outcome.data !== 'object' || outcome.data === null)
|
|
7
|
+
throw new Error('Waiting Activity outcome lacks expectation');
|
|
8
|
+
const intentEventId = Reflect.get(outcome.data, 'intentEventId');
|
|
9
|
+
const rawSignalKind = Reflect.get(outcome.data, 'signalKind');
|
|
10
|
+
if (typeof intentEventId !== 'string' || intentEventId.length === 0)
|
|
11
|
+
throw new Error('Waiting Activity outcome requires intentEventId');
|
|
12
|
+
if (typeof rawSignalKind !== 'string' || rawSignalKind.length === 0)
|
|
13
|
+
throw new Error('Waiting Activity outcome requires signalKind');
|
|
14
|
+
return {
|
|
15
|
+
kind: ActivityOutcomeKind.Waiting,
|
|
16
|
+
data: { intentEventId, signalKind: signalName(rawSignalKind) },
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ApprovalAuthorityKind, WorkflowStatus } from './vocabulary.js';
|
|
3
|
+
import { WorkspaceMode } from '../../execution/index.js';
|
|
4
|
+
import { MatchMode } from '../../kernel/index.js';
|
|
5
|
+
const identifier = z.string().trim().min(1);
|
|
6
|
+
const bound = z.object({ max: z.number().int().positive() }).strict();
|
|
7
|
+
const approvalAuthorityKind = z.enum([
|
|
8
|
+
ApprovalAuthorityKind.Human,
|
|
9
|
+
ApprovalAuthorityKind.Auto,
|
|
10
|
+
ApprovalAuthorityKind.Watch,
|
|
11
|
+
]);
|
|
12
|
+
// Shorthand: a bare `human`/`auto` string, or an explicit `{ kind: watch, id }` reference.
|
|
13
|
+
const approvalAuthorityConfigSchema = z.union([
|
|
14
|
+
z.literal(ApprovalAuthorityKind.Human),
|
|
15
|
+
z.literal(ApprovalAuthorityKind.Auto),
|
|
16
|
+
z.object({ kind: z.literal(ApprovalAuthorityKind.Watch), id: identifier }).strict(),
|
|
17
|
+
]);
|
|
18
|
+
export const awaitConfigSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
signal: identifier,
|
|
21
|
+
from: z.array(approvalAuthorityConfigSchema).min(1).readonly(),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
const watchGateConfigSchema = z.union([
|
|
25
|
+
identifier,
|
|
26
|
+
z
|
|
27
|
+
.object({
|
|
28
|
+
watch: identifier,
|
|
29
|
+
onReject: z.object({ then: identifier }).strict().optional(),
|
|
30
|
+
})
|
|
31
|
+
.strict(),
|
|
32
|
+
]);
|
|
33
|
+
const commandName = z.string().regex(/^\/[a-z][a-z0-9-]*$/);
|
|
34
|
+
const canonicalEventName = z.string().regex(/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/);
|
|
35
|
+
const watchStatus = z.enum([WorkflowStatus.Active, WorkflowStatus.Waiting, WorkflowStatus.Blocked]);
|
|
36
|
+
export const watchConfigSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
id: identifier,
|
|
39
|
+
while: z
|
|
40
|
+
.object({
|
|
41
|
+
stages: z.array(identifier).min(1).readonly(),
|
|
42
|
+
statuses: z.array(watchStatus).min(1).readonly(),
|
|
43
|
+
})
|
|
44
|
+
.strict(),
|
|
45
|
+
on: z
|
|
46
|
+
.object({ events: z.array(canonicalEventName).min(1).readonly() })
|
|
47
|
+
.strict()
|
|
48
|
+
.optional(),
|
|
49
|
+
schedule: z.object({ cron: identifier }).strict().optional(),
|
|
50
|
+
workflow: identifier,
|
|
51
|
+
maxPerGroup: z.number().int().positive(),
|
|
52
|
+
})
|
|
53
|
+
.strict()
|
|
54
|
+
.refine((value) => value.on !== undefined || value.schedule !== undefined, {
|
|
55
|
+
message: 'Watch requires on or schedule',
|
|
56
|
+
});
|
|
57
|
+
export const followOnActivityConfigSchema = z
|
|
58
|
+
.object({
|
|
59
|
+
use: identifier,
|
|
60
|
+
with: z.unknown().optional(),
|
|
61
|
+
})
|
|
62
|
+
.strict();
|
|
63
|
+
export const outcomeRouteConfigSchema = z
|
|
64
|
+
.object({
|
|
65
|
+
activities: z.array(followOnActivityConfigSchema).readonly().optional(),
|
|
66
|
+
then: identifier,
|
|
67
|
+
repeat: bound.optional(),
|
|
68
|
+
retry: bound.optional(),
|
|
69
|
+
await: awaitConfigSchema.optional(),
|
|
70
|
+
watchGates: z.array(watchGateConfigSchema).optional(),
|
|
71
|
+
})
|
|
72
|
+
.strict();
|
|
73
|
+
export const stageConfigSchema = z
|
|
74
|
+
.object({
|
|
75
|
+
activity: identifier,
|
|
76
|
+
with: z.unknown().optional(),
|
|
77
|
+
execution: z
|
|
78
|
+
.object({
|
|
79
|
+
workspace: z
|
|
80
|
+
.enum([WorkspaceMode.None, WorkspaceMode.ReadOnly, WorkspaceMode.Branch])
|
|
81
|
+
.optional(),
|
|
82
|
+
runnerPool: identifier.optional(),
|
|
83
|
+
})
|
|
84
|
+
.strict()
|
|
85
|
+
.optional(),
|
|
86
|
+
on: z
|
|
87
|
+
.record(identifier, outcomeRouteConfigSchema)
|
|
88
|
+
.refine((value) => Object.keys(value).length > 0),
|
|
89
|
+
requiresApproval: z.boolean().optional(),
|
|
90
|
+
})
|
|
91
|
+
.strict();
|
|
92
|
+
export const supplementalCommandConfigSchema = z
|
|
93
|
+
.object({
|
|
94
|
+
activity: identifier,
|
|
95
|
+
with: z.unknown().optional(),
|
|
96
|
+
allowedActors: z.array(approvalAuthorityKind).min(1).readonly(),
|
|
97
|
+
})
|
|
98
|
+
.strict();
|
|
99
|
+
export const workflowDefinitionConfigSchema = z
|
|
100
|
+
.object({
|
|
101
|
+
entry: identifier.optional(),
|
|
102
|
+
commands: z.record(commandName, supplementalCommandConfigSchema).optional(),
|
|
103
|
+
watches: z.array(watchConfigSchema).readonly().optional(),
|
|
104
|
+
stages: z
|
|
105
|
+
.record(identifier, stageConfigSchema)
|
|
106
|
+
.refine((value) => Object.keys(value).length > 0),
|
|
107
|
+
})
|
|
108
|
+
.strict();
|
|
109
|
+
// A single identifier is shorthand for a one-entry list, so every facet is matched the same way.
|
|
110
|
+
const selectorValues = z
|
|
111
|
+
.union([identifier, z.array(identifier).min(1)])
|
|
112
|
+
.transform((value) => (typeof value === 'string' ? [value] : value));
|
|
113
|
+
export const workflowSelectorConfigSchema = z
|
|
114
|
+
.object({
|
|
115
|
+
match: z
|
|
116
|
+
.object({
|
|
117
|
+
tags: selectorValues.optional(),
|
|
118
|
+
kind: selectorValues.optional(),
|
|
119
|
+
adapter: selectorValues.optional(),
|
|
120
|
+
})
|
|
121
|
+
.strict()
|
|
122
|
+
.refine((value) => Object.values(value).some((facet) => facet !== undefined), {
|
|
123
|
+
message: 'Workflow selector match requires at least one of tags, kind, or adapter',
|
|
124
|
+
}),
|
|
125
|
+
matchMode: z.enum([MatchMode.Any, MatchMode.All]).default(MatchMode.Any),
|
|
126
|
+
workflow: identifier,
|
|
127
|
+
})
|
|
128
|
+
.strict();
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { activationId, activityName, ActivityOutcomeKind } from '../../activities/index.js';
|
|
3
|
+
import { WorkspaceMode } from '../../execution/index.js';
|
|
4
|
+
import { brandedStringSchema, eventEnvelopeSchema, } from '../../kernel/index.js';
|
|
5
|
+
import { workItemId } from '../../work/index.js';
|
|
6
|
+
import { orchestrationActivityOutcome, } from './activity-outcome.js';
|
|
7
|
+
import { OrchestrationEventType, } from './events.js';
|
|
8
|
+
import { orchestrationGroupId, signalName, stageName, watchId, workflowInstanceId, workflowName, } from './identifiers.js';
|
|
9
|
+
import { childOrchestrationGroupStreamId, OrchestrationStreamKind, primaryOrchestrationGroupStreamId, } from './streams.js';
|
|
10
|
+
import { ApprovalAuthorityKind, TransitionTargetKind } from './vocabulary.js';
|
|
11
|
+
export const workflowInstanceIdSchema = brandedStringSchema(workflowInstanceId);
|
|
12
|
+
export const workflowStreamSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
kind: z.literal(OrchestrationStreamKind.WorkflowInstance),
|
|
15
|
+
id: workflowInstanceIdSchema,
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
const primaryGroupIdSchema = brandedStringSchema(primaryOrchestrationGroupStreamId);
|
|
19
|
+
export const childGroupIdSchema = brandedStringSchema(childOrchestrationGroupStreamId);
|
|
20
|
+
export const primaryGroupStreamSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
kind: z.literal(OrchestrationStreamKind.Group),
|
|
23
|
+
id: primaryGroupIdSchema,
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
export const childGroupStreamSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
kind: z.literal(OrchestrationStreamKind.Group),
|
|
29
|
+
id: childGroupIdSchema,
|
|
30
|
+
})
|
|
31
|
+
.strict();
|
|
32
|
+
export const childMetadataShape = {
|
|
33
|
+
parentWorkflowInstanceId: workflowInstanceIdSchema,
|
|
34
|
+
watchId: z.string().min(1),
|
|
35
|
+
triggerId: z.string().min(1),
|
|
36
|
+
orchestrationGroupId: brandedStringSchema(orchestrationGroupId),
|
|
37
|
+
causalCycleId: z.string().min(1),
|
|
38
|
+
requestId: z.string().min(1),
|
|
39
|
+
childWorkflowInstanceId: workflowInstanceIdSchema,
|
|
40
|
+
};
|
|
41
|
+
export const childMetadataSchema = z.object(childMetadataShape).strict();
|
|
42
|
+
export const outcomeSchema = z
|
|
43
|
+
.object({ kind: z.string().min(1), data: z.unknown().optional() })
|
|
44
|
+
.strict();
|
|
45
|
+
export const waitingOutcomeSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
kind: z.literal(ActivityOutcomeKind.Waiting),
|
|
48
|
+
data: z
|
|
49
|
+
.object({
|
|
50
|
+
intentEventId: z.string().min(1),
|
|
51
|
+
signalKind: brandedStringSchema(signalName),
|
|
52
|
+
})
|
|
53
|
+
.strict(),
|
|
54
|
+
})
|
|
55
|
+
.strict()
|
|
56
|
+
.transform((outcome) => orchestrationActivityOutcome(outcome));
|
|
57
|
+
const executionSchema = z
|
|
58
|
+
.object({
|
|
59
|
+
workspace: z
|
|
60
|
+
.enum([WorkspaceMode.None, WorkspaceMode.ReadOnly, WorkspaceMode.Branch])
|
|
61
|
+
.optional(),
|
|
62
|
+
runnerPool: z.string().min(1).optional(),
|
|
63
|
+
})
|
|
64
|
+
.strict();
|
|
65
|
+
export const activityRequestedSchema = z
|
|
66
|
+
.object({
|
|
67
|
+
activationId: brandedStringSchema(activationId),
|
|
68
|
+
ordinal: z.number().int().positive(),
|
|
69
|
+
activity: brandedStringSchema(activityName),
|
|
70
|
+
stage: brandedStringSchema(stageName).optional(),
|
|
71
|
+
input: z.unknown(),
|
|
72
|
+
execution: executionSchema.optional(),
|
|
73
|
+
followOnIndex: z.number().int().nonnegative().optional(),
|
|
74
|
+
supplemental: z.literal(true).optional(),
|
|
75
|
+
})
|
|
76
|
+
.strict();
|
|
77
|
+
const approvalAuthoritySchema = z.discriminatedUnion('kind', [
|
|
78
|
+
z.object({ kind: z.literal(ApprovalAuthorityKind.Human) }).strict(),
|
|
79
|
+
z.object({ kind: z.literal(ApprovalAuthorityKind.Auto) }).strict(),
|
|
80
|
+
z
|
|
81
|
+
.object({ kind: z.literal(ApprovalAuthorityKind.Watch), watch: brandedStringSchema(watchId) })
|
|
82
|
+
.strict(),
|
|
83
|
+
]);
|
|
84
|
+
const transitionTargetSchema = z.discriminatedUnion('kind', [
|
|
85
|
+
z
|
|
86
|
+
.object({ kind: z.literal(TransitionTargetKind.Stage), stage: brandedStringSchema(stageName) })
|
|
87
|
+
.strict(),
|
|
88
|
+
z.object({ kind: z.literal(TransitionTargetKind.Complete) }).strict(),
|
|
89
|
+
z
|
|
90
|
+
.object({
|
|
91
|
+
kind: z.literal(TransitionTargetKind.AwaitSignal),
|
|
92
|
+
signal: brandedStringSchema(signalName),
|
|
93
|
+
})
|
|
94
|
+
.strict(),
|
|
95
|
+
]);
|
|
96
|
+
export const expectationSchema = z
|
|
97
|
+
.object({
|
|
98
|
+
signalKind: brandedStringSchema(signalName),
|
|
99
|
+
resourceId: z.string().optional(),
|
|
100
|
+
revision: z.string().optional(),
|
|
101
|
+
from: z.array(approvalAuthoritySchema).min(1).optional(),
|
|
102
|
+
resume: transitionTargetSchema.optional(),
|
|
103
|
+
onRejectResume: transitionTargetSchema.optional(),
|
|
104
|
+
})
|
|
105
|
+
.strict();
|
|
106
|
+
export const signalSchema = z
|
|
107
|
+
.object({
|
|
108
|
+
kind: brandedStringSchema(signalName),
|
|
109
|
+
resourceId: z.string().optional(),
|
|
110
|
+
revision: z.string().optional(),
|
|
111
|
+
actorId: z.string().min(1),
|
|
112
|
+
actorDecision: z.object({ authorized: z.boolean(), evidenceId: z.string().min(1) }).strict(),
|
|
113
|
+
providerEventId: z.string().min(1),
|
|
114
|
+
childWorkflowInstanceId: workflowInstanceIdSchema.optional(),
|
|
115
|
+
requestId: z.string().optional(),
|
|
116
|
+
authority: approvalAuthoritySchema.optional(),
|
|
117
|
+
outcome: z
|
|
118
|
+
.enum([
|
|
119
|
+
ActivityOutcomeKind.Done,
|
|
120
|
+
ActivityOutcomeKind.Rejected,
|
|
121
|
+
ActivityOutcomeKind.Blocked,
|
|
122
|
+
ActivityOutcomeKind.Failed,
|
|
123
|
+
])
|
|
124
|
+
.optional(),
|
|
125
|
+
})
|
|
126
|
+
.strict();
|
|
127
|
+
export const emptySchema = z.object({}).strict();
|
|
128
|
+
export const workflowEnvelope = (eventType, payload) => eventEnvelopeSchema.extend({
|
|
129
|
+
eventType: z.literal(eventType),
|
|
130
|
+
stream: workflowStreamSchema,
|
|
131
|
+
payload,
|
|
132
|
+
});
|
|
133
|
+
export const primaryGroupEnvelope = (eventType, payload) => eventEnvelopeSchema.extend({
|
|
134
|
+
eventType: z.literal(eventType),
|
|
135
|
+
stream: primaryGroupStreamSchema,
|
|
136
|
+
payload,
|
|
137
|
+
});
|
|
138
|
+
export const childGroupEnvelope = (eventType, payload) => eventEnvelopeSchema.extend({
|
|
139
|
+
eventType: z.literal(eventType),
|
|
140
|
+
stream: childGroupStreamSchema,
|
|
141
|
+
payload,
|
|
142
|
+
});
|
|
143
|
+
const primaryClaimedEnvelope = primaryGroupEnvelope(OrchestrationEventType.PrimaryClaimed, z
|
|
144
|
+
.object({
|
|
145
|
+
workItemId: brandedStringSchema(workItemId),
|
|
146
|
+
workflowInstanceId: workflowInstanceIdSchema,
|
|
147
|
+
})
|
|
148
|
+
.strict()).superRefine((event, context) => {
|
|
149
|
+
if (event.stream.id !== `primary:${event.payload.workItemId}`)
|
|
150
|
+
context.addIssue({
|
|
151
|
+
code: 'custom',
|
|
152
|
+
path: ['payload', 'workItemId'],
|
|
153
|
+
message: 'Primary claim work item must identify its stream',
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
const groupClaimedEnvelope = childGroupEnvelope(OrchestrationEventType.GroupClaimed, z.object({ key: childGroupIdSchema, requestId: z.string().min(1) }).strict()).superRefine((event, context) => {
|
|
157
|
+
if (event.payload.key !== event.stream.id)
|
|
158
|
+
context.addIssue({
|
|
159
|
+
code: 'custom',
|
|
160
|
+
path: ['payload', 'key'],
|
|
161
|
+
message: 'Group claim key must identify its stream',
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
const eventSchema = z.discriminatedUnion('eventType', [
|
|
165
|
+
workflowEnvelope(OrchestrationEventType.InstanceStarted, z.union([
|
|
166
|
+
z
|
|
167
|
+
.object({
|
|
168
|
+
workItemId: brandedStringSchema(workItemId),
|
|
169
|
+
workflowName: brandedStringSchema(workflowName),
|
|
170
|
+
orchestrationGroupId: brandedStringSchema(orchestrationGroupId),
|
|
171
|
+
entry: brandedStringSchema(stageName),
|
|
172
|
+
})
|
|
173
|
+
.strict(),
|
|
174
|
+
z
|
|
175
|
+
.object({
|
|
176
|
+
workItemId: brandedStringSchema(workItemId),
|
|
177
|
+
workflowName: brandedStringSchema(workflowName),
|
|
178
|
+
entry: brandedStringSchema(stageName),
|
|
179
|
+
...childMetadataShape,
|
|
180
|
+
})
|
|
181
|
+
.strict(),
|
|
182
|
+
])),
|
|
183
|
+
workflowEnvelope(OrchestrationEventType.StageEntered, z.object({ stage: brandedStringSchema(stageName) }).strict()),
|
|
184
|
+
workflowEnvelope(OrchestrationEventType.ActivityRequested, activityRequestedSchema),
|
|
185
|
+
workflowEnvelope(OrchestrationEventType.ActivityStarted, z.object({ activationId: brandedStringSchema(activationId) }).strict()),
|
|
186
|
+
workflowEnvelope(OrchestrationEventType.ActivityOutcomeAccepted, z
|
|
187
|
+
.object({
|
|
188
|
+
activationId: brandedStringSchema(activationId),
|
|
189
|
+
outcome: outcomeSchema,
|
|
190
|
+
})
|
|
191
|
+
.strict()),
|
|
192
|
+
workflowEnvelope(OrchestrationEventType.ActivityExecutionFailed, z
|
|
193
|
+
.object({
|
|
194
|
+
activationId: brandedStringSchema(activationId),
|
|
195
|
+
runId: z.string().min(1),
|
|
196
|
+
reason: z.string().min(1),
|
|
197
|
+
})
|
|
198
|
+
.strict()),
|
|
199
|
+
workflowEnvelope(OrchestrationEventType.ActivityWaiting, z
|
|
200
|
+
.object({
|
|
201
|
+
activationId: brandedStringSchema(activationId),
|
|
202
|
+
outcome: waitingOutcomeSchema,
|
|
203
|
+
})
|
|
204
|
+
.strict()),
|
|
205
|
+
workflowEnvelope(OrchestrationEventType.SignalWaitStarted, expectationSchema),
|
|
206
|
+
workflowEnvelope(OrchestrationEventType.SignalAccepted, signalSchema),
|
|
207
|
+
workflowEnvelope(OrchestrationEventType.SupplementalActivityQueued, z
|
|
208
|
+
.object({
|
|
209
|
+
activity: brandedStringSchema(activityName),
|
|
210
|
+
input: z.unknown(),
|
|
211
|
+
requestedBy: z.string().min(1),
|
|
212
|
+
})
|
|
213
|
+
.strict()),
|
|
214
|
+
workflowEnvelope(OrchestrationEventType.SupplementalActivityDequeued, z
|
|
215
|
+
.object({
|
|
216
|
+
activity: brandedStringSchema(activityName),
|
|
217
|
+
requestedBy: z.string().min(1),
|
|
218
|
+
})
|
|
219
|
+
.strict()),
|
|
220
|
+
workflowEnvelope(OrchestrationEventType.RepeatCounted, z.object({ routeId: z.string().min(1), count: z.number().int().positive() }).strict()),
|
|
221
|
+
workflowEnvelope(OrchestrationEventType.RetryCounted, z.object({ retryKey: z.string().min(1), count: z.number().int().positive() }).strict()),
|
|
222
|
+
workflowEnvelope(OrchestrationEventType.InstanceCompleted, emptySchema),
|
|
223
|
+
workflowEnvelope(OrchestrationEventType.InstanceBlocked, z.object({ reason: z.string() }).strict()),
|
|
224
|
+
workflowEnvelope(OrchestrationEventType.OperatorRetryRequested, z
|
|
225
|
+
.object({
|
|
226
|
+
activationId: brandedStringSchema(activationId),
|
|
227
|
+
commandId: z.string().min(1),
|
|
228
|
+
})
|
|
229
|
+
.strict()),
|
|
230
|
+
workflowEnvelope(OrchestrationEventType.InstanceSuperseded, emptySchema),
|
|
231
|
+
workflowEnvelope(OrchestrationEventType.ChildRequested, z.object({ ...childMetadataShape, workflowName: brandedStringSchema(workflowName) }).strict()),
|
|
232
|
+
workflowEnvelope(OrchestrationEventType.ChildStarted, childMetadataSchema),
|
|
233
|
+
workflowEnvelope(OrchestrationEventType.ChildCompleted, childMetadataSchema),
|
|
234
|
+
workflowEnvelope(OrchestrationEventType.ChildCompletionConsumed, childMetadataSchema),
|
|
235
|
+
workflowEnvelope(OrchestrationEventType.CausalActivationRejected, childMetadataSchema),
|
|
236
|
+
workflowEnvelope(OrchestrationEventType.GroupBudgetExhausted, z.object({ ...childMetadataShape, maxPerGroup: z.number().int().positive() }).strict()),
|
|
237
|
+
primaryClaimedEnvelope,
|
|
238
|
+
groupClaimedEnvelope,
|
|
239
|
+
]);
|
|
240
|
+
export function decodeOrchestrationEvent(event) {
|
|
241
|
+
const result = eventSchema.safeParse(event);
|
|
242
|
+
if (!result.success)
|
|
243
|
+
throw invalidOrchestrationEvent(event, result.error);
|
|
244
|
+
return result.data;
|
|
245
|
+
}
|
|
246
|
+
export function selectOrchestrationEvent(event) {
|
|
247
|
+
return event.eventType.startsWith('orchestration.') ? decodeOrchestrationEvent(event) : null;
|
|
248
|
+
}
|
|
249
|
+
export function selectWorkflowOrchestrationEvent(event) {
|
|
250
|
+
const owned = selectOrchestrationEvent(event);
|
|
251
|
+
if (owned === null)
|
|
252
|
+
return null;
|
|
253
|
+
switch (owned.eventType) {
|
|
254
|
+
case OrchestrationEventType.PrimaryClaimed:
|
|
255
|
+
case OrchestrationEventType.GroupClaimed:
|
|
256
|
+
return null;
|
|
257
|
+
default:
|
|
258
|
+
return owned;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function invalidOrchestrationEvent(event, cause) {
|
|
262
|
+
return new Error(`Invalid Orchestration event ${event.eventId} at global position ${event.globalPosition} (${event.eventType}): ${cause.message}`, { cause });
|
|
263
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { signalName } from './identifiers.js';
|
|
2
|
+
export const OrchestrationEventType = {
|
|
3
|
+
InstanceStarted: 'orchestration.instance-started',
|
|
4
|
+
StageEntered: 'orchestration.stage-entered',
|
|
5
|
+
ActivityRequested: 'orchestration.activity-requested',
|
|
6
|
+
ActivityStarted: 'orchestration.activity-started',
|
|
7
|
+
ActivityOutcomeAccepted: 'orchestration.activity-outcome-accepted',
|
|
8
|
+
ActivityExecutionFailed: 'orchestration.activity-execution-failed',
|
|
9
|
+
ActivityWaiting: 'orchestration.activity-waiting',
|
|
10
|
+
SignalWaitStarted: 'orchestration.signal-wait-started',
|
|
11
|
+
SignalAccepted: 'orchestration.signal-accepted',
|
|
12
|
+
SupplementalActivityQueued: 'orchestration.supplemental-activity-queued',
|
|
13
|
+
SupplementalActivityDequeued: 'orchestration.supplemental-activity-dequeued',
|
|
14
|
+
RepeatCounted: 'orchestration.repeat-counted',
|
|
15
|
+
RetryCounted: 'orchestration.retry-counted',
|
|
16
|
+
InstanceCompleted: 'orchestration.instance-completed',
|
|
17
|
+
InstanceBlocked: 'orchestration.instance-blocked',
|
|
18
|
+
OperatorRetryRequested: 'orchestration.operator-retry-requested',
|
|
19
|
+
InstanceSuperseded: 'orchestration.instance-superseded',
|
|
20
|
+
ChildRequested: 'orchestration.child-requested',
|
|
21
|
+
ChildStarted: 'orchestration.child-started',
|
|
22
|
+
ChildCompleted: 'orchestration.child-completed',
|
|
23
|
+
ChildCompletionConsumed: 'orchestration.child-completion-consumed',
|
|
24
|
+
CausalActivationRejected: 'orchestration.causal-activation-rejected',
|
|
25
|
+
GroupBudgetExhausted: 'orchestration.group-budget-exhausted',
|
|
26
|
+
PrimaryClaimed: 'orchestration.primary-claimed',
|
|
27
|
+
GroupClaimed: 'orchestration.group-claimed',
|
|
28
|
+
};
|
|
29
|
+
export const WatchGateVerdictSignal = signalName('orchestration.watch-gate-verdict');
|
|
30
|
+
export const ApprovedSignal = signalName('approved');
|
|
31
|
+
/**
|
|
32
|
+
* Every consumer that needs to know whether a wait renders as "awaiting
|
|
33
|
+
* approval" externally (GitHub labels, the operator board, the agent-run
|
|
34
|
+
* comment footer) must derive it from this single predicate, or it silently
|
|
35
|
+
* falls out of sync whenever a new approval-style signal kind is added —
|
|
36
|
+
* exactly what happened when the watchGate verdict channel shipped and only
|
|
37
|
+
* some of those consumers were updated to recognize it.
|
|
38
|
+
*/
|
|
39
|
+
export function isApprovalAwaitingSignalKind(signalKind) {
|
|
40
|
+
return signalKind === ApprovedSignal || signalKind === WatchGateVerdictSignal;
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const workflowName = (value) => {
|
|
2
|
+
if (!/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(value))
|
|
3
|
+
throw new Error(`Invalid workflow name: ${value}`);
|
|
4
|
+
return value;
|
|
5
|
+
};
|
|
6
|
+
export const stageName = (value) => {
|
|
7
|
+
if (!/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(value))
|
|
8
|
+
throw new Error(`Invalid stage name: ${value}`);
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
export const signalName = (value) => {
|
|
12
|
+
if (!/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(value))
|
|
13
|
+
throw new Error(`Invalid signal name: ${value}`);
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
16
|
+
export const commandName = (value) => {
|
|
17
|
+
if (!/^\/[a-z][a-z0-9-]*$/.test(value))
|
|
18
|
+
throw new Error(`Invalid command name: ${value}`);
|
|
19
|
+
return value;
|
|
20
|
+
};
|
|
21
|
+
export const workflowInstanceId = (value) => {
|
|
22
|
+
if (value.trim().length === 0)
|
|
23
|
+
throw new Error('WorkflowInstance id must not be empty');
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
export const orchestrationGroupId = (value) => {
|
|
27
|
+
if (value.trim().length === 0)
|
|
28
|
+
throw new Error('Orchestration group id must not be empty');
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
export const watchId = (value) => {
|
|
32
|
+
if (!/^[a-z][a-z0-9-]*$/.test(value))
|
|
33
|
+
throw new Error(`Invalid WatchId: ${value}`);
|
|
34
|
+
return value;
|
|
35
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const OrchestrationStreamKind = {
|
|
2
|
+
WorkflowInstance: 'workflow-instance',
|
|
3
|
+
Group: 'orchestration-group',
|
|
4
|
+
};
|
|
5
|
+
export const orchestrationGroupStreamId = (value) => {
|
|
6
|
+
return value.startsWith('primary:')
|
|
7
|
+
? primaryOrchestrationGroupStreamId(value)
|
|
8
|
+
: childOrchestrationGroupStreamId(value);
|
|
9
|
+
};
|
|
10
|
+
export const primaryOrchestrationGroupStreamId = (value) => {
|
|
11
|
+
if (!/^primary:work-[a-z0-9-]+$/.test(value))
|
|
12
|
+
throw new Error(`Invalid primary orchestration group stream key: ${value}`);
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
export const childOrchestrationGroupStreamId = (value) => {
|
|
16
|
+
if (!/^group:[^:]+:watch:[^:]+$/.test(value))
|
|
17
|
+
throw new Error(`Invalid child orchestration group stream key: ${value}`);
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
export const workflowInstanceStream = (id) => ({
|
|
21
|
+
kind: OrchestrationStreamKind.WorkflowInstance,
|
|
22
|
+
id,
|
|
23
|
+
});
|
|
24
|
+
export const primaryOrchestrationGroupStream = (workItemId) => ({
|
|
25
|
+
kind: OrchestrationStreamKind.Group,
|
|
26
|
+
id: primaryOrchestrationGroupStreamId(`primary:${workItemId}`),
|
|
27
|
+
});
|
|
28
|
+
export const childOrchestrationGroupStream = (orchestrationGroupId, watchId) => ({
|
|
29
|
+
kind: OrchestrationStreamKind.Group,
|
|
30
|
+
id: childOrchestrationGroupStreamId(`group:${component(orchestrationGroupId)}:watch:${component(watchId)}`),
|
|
31
|
+
});
|
|
32
|
+
export const isWorkflowInstanceStream = (stream) => stream.kind === OrchestrationStreamKind.WorkflowInstance;
|
|
33
|
+
export const isOrchestrationGroupStream = (stream) => stream.kind === OrchestrationStreamKind.Group;
|
|
34
|
+
function component(value) {
|
|
35
|
+
if (value.trim().length === 0)
|
|
36
|
+
throw new Error('Orchestration group key part must not be empty');
|
|
37
|
+
return encodeURIComponent(value);
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|