@atolis-hq/wake 0.2.97 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/src/activities/agent/agent-activity-definition.js +26 -0
- package/dist/src/activities/agent/agent-activity.js +171 -0
- package/dist/src/activities/agent/agent-result.js +149 -0
- package/dist/src/activities/contracts/activity.js +10 -0
- package/dist/src/activities/contracts/config.js +2 -0
- package/dist/src/activities/contracts/event-schema.js +302 -0
- package/dist/src/activities/contracts/events.js +42 -0
- package/dist/src/activities/contracts/identifiers.js +29 -0
- package/dist/src/activities/contracts/registry.js +71 -0
- package/dist/src/activities/contracts/streams.js +17 -0
- package/dist/src/activities/contracts/vocabulary.js +58 -0
- package/dist/src/activities/index.js +21 -0
- package/dist/src/activities/pr/activity-support.js +111 -0
- package/dist/src/activities/pr/application.js +158 -0
- package/dist/src/activities/pr/approve.js +85 -0
- package/dist/src/activities/pr/capability.js +11 -0
- package/dist/src/activities/pr/decision-claim.js +76 -0
- package/dist/src/activities/pr/event-drafts.js +66 -0
- package/dist/src/activities/pr/intent.js +37 -0
- package/dist/src/activities/pr/merge-authority-gate.js +14 -0
- package/dist/src/activities/pr/merge.js +110 -0
- package/dist/src/activities/pr/policy.js +135 -0
- package/dist/src/activities/pr/projection.js +130 -0
- package/dist/src/activities/pr/vocabulary.js +30 -0
- package/dist/src/activities/review/authorization.js +22 -0
- package/dist/src/activities/review/contracts.js +22 -0
- package/dist/src/activities/review/signals.js +3 -0
- package/dist/src/bootstrap/analytics-projection.js +26 -0
- package/dist/src/bootstrap/board-projection.js +337 -0
- package/dist/src/bootstrap/composition-root.js +382 -0
- package/dist/src/bootstrap/config/load-config.js +51 -0
- package/dist/src/bootstrap/config/root-schema.js +134 -0
- package/dist/src/bootstrap/external-ref.js +12 -0
- package/dist/src/bootstrap/fake-provider-files.js +44 -0
- package/dist/src/bootstrap/fake-scenarios.js +22 -0
- package/dist/src/bootstrap/index.js +48 -0
- package/dist/src/bootstrap/initialise.js +436 -0
- package/dist/src/bootstrap/paths.js +15 -0
- package/dist/src/bootstrap/projection-runtime.js +27 -0
- package/dist/src/bootstrap/runner-quota-reporter.js +21 -0
- package/dist/src/bootstrap/runner-registry.js +30 -0
- package/dist/src/bootstrap/schedule-checkpoint-store.js +49 -0
- package/dist/src/bootstrap/self-update-application.js +195 -0
- package/dist/src/bootstrap/self-update-failure-log.js +33 -0
- package/dist/src/bootstrap/source-update-port.js +47 -0
- package/dist/src/bootstrap/status-publish-activity.js +42 -0
- package/dist/src/bootstrap/surface-api-applications.js +325 -0
- package/dist/src/bootstrap/surface-api-execution-applications.js +95 -0
- package/dist/src/bootstrap/surface-api-metadata.js +12 -0
- package/dist/src/bootstrap/surface-api-projection-pages.js +22 -0
- package/dist/src/bootstrap/surface-api-run-context.js +5 -0
- package/dist/src/bootstrap/surface-api-transcripts.js +57 -0
- package/dist/src/bootstrap/surface-api-work-applications.js +199 -0
- package/dist/src/bootstrap/surface-applications.js +7 -0
- package/dist/src/bootstrap/surface-cli-applications.js +701 -0
- package/dist/src/bootstrap/update-ledger.js +61 -0
- package/dist/src/bootstrap/update-maintenance-lease.js +176 -0
- package/dist/src/{version.js → bootstrap/version.js} +35 -51
- package/dist/src/control-plane/application/advance-once.js +184 -0
- package/dist/src/control-plane/application/control-plane-projection.js +42 -0
- package/dist/src/control-plane/application/control-plane-service.js +42 -0
- package/dist/src/control-plane/application/intake-pipeline.js +29 -0
- package/dist/src/control-plane/application/runner-control-service.js +66 -0
- package/dist/src/control-plane/application/runner-pipeline.js +57 -0
- package/dist/src/control-plane/application/schedule-service.js +47 -0
- package/dist/src/control-plane/application/work-cancellation-policy.js +31 -0
- package/dist/src/control-plane/contracts/commands.js +10 -0
- package/dist/src/control-plane/contracts/config.js +22 -0
- package/dist/src/control-plane/contracts/events.js +81 -0
- package/dist/src/control-plane/contracts/streams.js +5 -0
- package/dist/src/control-plane/domain/dispatch-policy.js +15 -0
- package/dist/src/control-plane/domain/quota-policy.js +26 -0
- package/dist/src/control-plane/domain/runner-quota.js +35 -0
- package/dist/src/control-plane/domain/schedule-policy.js +46 -0
- package/dist/src/control-plane/index.js +20 -0
- package/dist/src/control-plane/infrastructure/intake-host.js +24 -0
- package/dist/src/control-plane/infrastructure/resident-host.js +45 -0
- package/dist/src/control-plane/infrastructure/tick-host.js +35 -0
- package/dist/src/execution/application/activation-claim.js +50 -0
- package/dist/src/execution/application/active-run-cancellation.js +14 -0
- package/dist/src/execution/application/execution-activity.js +97 -0
- package/dist/src/execution/application/execution-projection.js +17 -0
- package/dist/src/execution/application/execution-service.js +372 -0
- package/dist/src/execution/application/execution-validation.js +26 -0
- package/dist/src/execution/application/recovery-service.js +212 -0
- package/dist/src/execution/application/run-lifecycle.js +115 -0
- package/dist/src/execution/application/run-liveness-service.js +80 -0
- package/dist/src/execution/application/run-repository.js +27 -0
- package/dist/src/execution/contracts/commands.js +1 -0
- package/dist/src/execution/contracts/config.js +35 -0
- package/dist/src/execution/contracts/control-plane.js +1 -0
- package/dist/src/execution/contracts/event-factory.js +53 -0
- package/dist/src/execution/contracts/events.js +274 -0
- package/dist/src/execution/contracts/identifiers.js +5 -0
- package/dist/src/execution/contracts/liveness.js +1 -0
- package/dist/src/execution/contracts/results.js +1 -0
- package/dist/src/execution/contracts/runner.js +15 -0
- package/dist/src/execution/contracts/streams.js +10 -0
- package/dist/src/execution/contracts/views.js +1 -0
- package/dist/src/execution/contracts/vocabulary.js +43 -0
- package/dist/src/execution/contracts/workspace.js +1 -0
- package/dist/src/execution/domain/run-result.js +34 -0
- package/dist/src/execution/domain/run.js +142 -0
- package/dist/src/execution/index.js +31 -0
- package/dist/src/execution/infrastructure/agent-runner-adapter.js +114 -0
- package/dist/src/execution/infrastructure/process-execution.js +29 -0
- package/dist/src/execution/infrastructure/prompt-templates.js +42 -0
- package/dist/src/execution/infrastructure/runners/claude.js +120 -0
- package/dist/src/execution/infrastructure/runners/codex.js +143 -0
- package/dist/src/execution/infrastructure/runners/command.js +4 -0
- package/dist/src/execution/infrastructure/runners/cursor.js +69 -0
- package/dist/src/execution/infrastructure/runners/fake-scenarios.js +99 -0
- package/dist/src/execution/infrastructure/runners/fake.js +65 -0
- package/dist/src/execution/infrastructure/runners/registry.js +26 -0
- package/dist/src/execution/infrastructure/transcript-store.js +223 -0
- package/dist/src/execution/infrastructure/transcripts.js +11 -0
- package/dist/src/execution/infrastructure/workspace/fake-workspace.js +19 -0
- package/dist/src/execution/infrastructure/workspace/git-workspace.js +241 -0
- package/dist/src/integrations/application/agent-run-publication-reactor.js +111 -0
- package/dist/src/integrations/application/artifact-registration-reactor.js +159 -0
- package/dist/src/integrations/application/poll-service.js +25 -0
- package/dist/src/integrations/application/terminal-agent-run-report.js +40 -0
- package/dist/src/integrations/application/work-admission.js +31 -0
- package/dist/src/integrations/application/work-conclusion.js +19 -0
- package/dist/src/integrations/contracts/artifact-events.js +60 -0
- package/dist/src/integrations/contracts/artifact-vocabulary.js +9 -0
- package/dist/src/integrations/contracts/config.js +14 -0
- package/dist/src/integrations/contracts/identifiers.js +5 -0
- package/dist/src/integrations/contracts/intake-rules.js +14 -0
- package/dist/src/integrations/contracts/intake.js +1 -0
- package/dist/src/integrations/contracts/outcome-vocabulary.js +7 -0
- package/dist/src/integrations/contracts/provider.js +37 -0
- package/dist/src/integrations/contracts/streams.js +10 -0
- package/dist/src/integrations/delivery/application/delivery-outcome-reactor.js +75 -0
- package/dist/src/integrations/delivery/application/delivery-projector.js +165 -0
- package/dist/src/integrations/delivery/application/delivery-service.js +173 -0
- package/dist/src/integrations/delivery/contracts/commands.js +1 -0
- package/dist/src/integrations/delivery/contracts/config.js +1 -0
- package/dist/src/integrations/delivery/contracts/event-factory.js +18 -0
- package/dist/src/integrations/delivery/contracts/events.js +86 -0
- package/dist/src/integrations/delivery/contracts/intents.js +89 -0
- package/dist/src/integrations/delivery/contracts/views.js +1 -0
- package/dist/src/integrations/delivery/contracts/vocabulary.js +22 -0
- package/dist/src/integrations/fake/durable-delivery-provider.js +48 -0
- package/dist/src/integrations/fake/external-sink.js +9 -0
- package/dist/src/integrations/fake/external-source.js +44 -0
- package/dist/src/integrations/fake/inbound-translator.js +130 -0
- package/dist/src/integrations/fake/provider.js +95 -0
- package/dist/src/integrations/github/application/agent-context-reader.js +54 -0
- package/dist/src/integrations/github/application/agent-run-comment.js +94 -0
- package/dist/src/integrations/github/application/comment-history-reader.js +43 -0
- package/dist/src/integrations/github/application/inbound-context.js +10 -0
- package/dist/src/integrations/github/application/inbound-review-signals.js +159 -0
- package/dist/src/integrations/github/application/inbound-translator.js +231 -0
- package/dist/src/integrations/github/application/inbound-watch-gate-signals.js +84 -0
- package/dist/src/integrations/github/application/intake-policy.js +23 -0
- package/dist/src/integrations/github/application/outbound-translator.js +47 -0
- package/dist/src/integrations/github/application/poll-service.js +29 -0
- package/dist/src/integrations/github/application/pull-request-translation.js +10 -0
- package/dist/src/integrations/github/application/resource-links.js +8 -0
- package/dist/src/integrations/github/application/review-command-translator.js +16 -0
- package/dist/src/integrations/github/application/wake-labels.js +95 -0
- package/dist/src/integrations/github/contracts/config.js +47 -0
- package/dist/src/integrations/github/contracts/events.js +127 -0
- package/dist/src/integrations/github/contracts/external-key.js +19 -0
- package/dist/src/integrations/github/contracts/payloads.js +9 -0
- package/dist/src/integrations/github/contracts/vocabulary.js +55 -0
- package/dist/src/integrations/github/index.js +31 -0
- package/dist/src/integrations/github/infrastructure/client-reads.js +214 -0
- package/dist/src/integrations/github/infrastructure/client.js +132 -0
- package/dist/src/integrations/github/infrastructure/content-fingerprint.js +10 -0
- package/dist/src/integrations/github/infrastructure/delivery.js +31 -0
- package/dist/src/integrations/github/infrastructure/etag-cache.js +56 -0
- package/dist/src/integrations/github/infrastructure/gh-auth.js +19 -0
- package/dist/src/integrations/github/infrastructure/issue-source.js +109 -0
- package/dist/src/integrations/github/infrastructure/pr-source.js +186 -0
- package/dist/src/integrations/github/infrastructure/review-source.js +70 -0
- package/dist/src/integrations/github/infrastructure/source.js +108 -0
- package/dist/src/integrations/github/provider.js +96 -0
- package/dist/src/integrations/index.js +30 -0
- package/dist/src/kernel/contracts/checkpoint-store.js +1 -0
- package/dist/src/kernel/contracts/clock.js +1 -0
- package/dist/src/kernel/contracts/commands.js +1 -0
- package/dist/src/kernel/contracts/event-journal.js +2 -0
- package/dist/src/kernel/contracts/event-schema.js +54 -0
- package/dist/src/kernel/contracts/events.js +11 -0
- package/dist/src/kernel/contracts/id-generator.js +1 -0
- package/dist/src/kernel/contracts/identifiers.js +8 -0
- package/dist/src/kernel/contracts/projection-store.js +1 -0
- package/dist/src/kernel/contracts/relations.js +1 -0
- package/dist/src/kernel/contracts/schema.js +17 -0
- package/dist/src/kernel/contracts/vocabulary.js +6 -0
- package/dist/src/kernel/domain/event-envelope.js +29 -0
- package/dist/src/kernel/domain/match-mode.js +11 -0
- package/dist/src/kernel/domain/relation.js +10 -0
- package/dist/src/kernel/index.js +17 -0
- package/dist/src/{lib/clock.js → kernel/infrastructure/system-clock.js} +3 -3
- package/dist/src/kernel/infrastructure/ulid-id-generator.js +9 -0
- package/dist/src/main.js +137 -1030
- package/dist/src/orchestration/application/accept-activity-outcome.js +25 -0
- package/dist/src/orchestration/application/accept-signal.js +35 -0
- package/dist/src/orchestration/application/advance-workflow.js +160 -0
- package/dist/src/orchestration/application/coordination-claims.js +107 -0
- package/dist/src/orchestration/application/group-budget-recorder.js +43 -0
- package/dist/src/orchestration/application/orchestration-projection.js +20 -0
- package/dist/src/orchestration/application/orchestration-repository.js +36 -0
- package/dist/src/orchestration/application/orchestration-service.js +82 -0
- package/dist/src/orchestration/application/request-child.js +118 -0
- package/dist/src/orchestration/application/signal-reactor.js +17 -0
- package/dist/src/orchestration/application/start-workflow.js +51 -0
- package/dist/src/orchestration/application/watch-reactor.js +82 -0
- package/dist/src/orchestration/contracts/activity-outcome.js +18 -0
- package/dist/src/orchestration/contracts/commands.js +1 -0
- package/dist/src/orchestration/contracts/config.js +128 -0
- package/dist/src/orchestration/contracts/event-decoder.js +263 -0
- package/dist/src/orchestration/contracts/events.js +41 -0
- package/dist/src/orchestration/contracts/identifiers.js +35 -0
- package/dist/src/orchestration/contracts/streams.js +38 -0
- package/dist/src/orchestration/contracts/views.js +1 -0
- package/dist/src/orchestration/contracts/vocabulary.js +30 -0
- package/dist/src/orchestration/domain/activation-policy.js +55 -0
- package/dist/src/orchestration/domain/approval-defaults.js +17 -0
- package/dist/src/orchestration/domain/child-policy.js +63 -0
- package/dist/src/orchestration/domain/compiler.js +162 -0
- package/dist/src/orchestration/domain/coordination-events.js +25 -0
- package/dist/src/orchestration/domain/decision-events.js +47 -0
- package/dist/src/orchestration/domain/interpreter.js +49 -0
- package/dist/src/orchestration/domain/operator-retry-policy.js +34 -0
- package/dist/src/orchestration/domain/retry-policy.js +26 -0
- package/dist/src/orchestration/domain/signal-policy.js +120 -0
- package/dist/src/orchestration/domain/supplemental-policy.js +61 -0
- package/dist/src/orchestration/domain/transition.js +55 -0
- package/dist/src/orchestration/domain/workflow-graph.js +41 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +236 -0
- package/dist/src/orchestration/domain/workflow-instance.js +41 -0
- package/dist/src/orchestration/domain/workflow-selector.js +21 -0
- package/dist/src/orchestration/index.js +19 -0
- package/dist/src/persistence/application/projection-runner.js +79 -0
- package/dist/src/persistence/filesystem/file-checkpoint-store.js +35 -0
- package/dist/src/persistence/filesystem/file-event-journal.js +143 -0
- package/dist/src/persistence/filesystem/file-lock.js +91 -0
- package/dist/src/persistence/filesystem/file-projection-store.js +64 -0
- package/dist/src/persistence/index.js +8 -0
- package/dist/src/persistence/memory/in-memory-checkpoint-store.js +14 -0
- package/dist/src/persistence/memory/in-memory-event-journal.js +88 -0
- package/dist/src/persistence/memory/in-memory-projection-store.js +17 -0
- package/dist/src/resources/application/lookup-projections.js +48 -0
- package/dist/src/resources/application/resource-lookup.js +16 -0
- package/dist/src/resources/application/resource-projections.js +81 -0
- package/dist/src/resources/application/resource-repository.js +18 -0
- package/dist/src/resources/application/resource-service.js +83 -0
- package/dist/src/resources/contracts/commands.js +1 -0
- package/dist/src/resources/contracts/config.js +2 -0
- package/dist/src/resources/contracts/events.js +83 -0
- package/dist/src/resources/contracts/identifiers.js +15 -0
- package/dist/src/resources/contracts/streams.js +6 -0
- package/dist/src/resources/contracts/views.js +1 -0
- package/dist/src/resources/contracts/vocabulary.js +67 -0
- package/dist/src/resources/domain/correlation.js +8 -0
- package/dist/src/resources/domain/resource.js +58 -0
- package/dist/src/resources/index.js +14 -0
- package/dist/src/surfaces/api/contracts/activities.js +1 -0
- package/dist/src/surfaces/api/contracts/board.js +2 -0
- package/dist/src/surfaces/api/contracts/common.js +46 -0
- package/dist/src/surfaces/api/contracts/control-plane.js +5 -0
- package/dist/src/surfaces/api/contracts/events.js +1 -0
- package/dist/src/surfaces/api/contracts/execution.js +1 -0
- package/dist/src/surfaces/api/contracts/index.js +13 -0
- package/dist/src/surfaces/api/contracts/observability.js +1 -0
- package/dist/src/surfaces/api/contracts/orchestration.js +1 -0
- package/dist/src/surfaces/api/contracts/resources.js +1 -0
- package/dist/src/surfaces/api/contracts/status.js +1 -0
- package/dist/src/surfaces/api/contracts/system.js +1 -0
- package/dist/src/surfaces/api/contracts/transport-values.js +39 -0
- package/dist/src/surfaces/api/contracts/work.js +17 -0
- package/dist/src/surfaces/api/http-server.js +121 -0
- package/dist/src/surfaces/api/presenters/activities.js +1 -0
- package/dist/src/surfaces/api/presenters/board.js +3 -0
- package/dist/src/surfaces/api/presenters/control-plane.js +1 -0
- package/dist/src/surfaces/api/presenters/events.js +1 -0
- package/dist/src/surfaces/api/presenters/execution.js +59 -0
- package/dist/src/surfaces/api/presenters/observability.js +1 -0
- package/dist/src/surfaces/api/presenters/orchestration.js +19 -0
- package/dist/src/surfaces/api/presenters/resources.js +15 -0
- package/dist/src/surfaces/api/presenters/status.js +3 -0
- package/dist/src/surfaces/api/presenters/system.js +14 -0
- package/dist/src/surfaces/api/presenters/work.js +16 -0
- package/dist/src/surfaces/api/problem-details.js +9 -0
- package/dist/src/surfaces/api/router.js +13 -0
- package/dist/src/surfaces/api/routes/activities.js +1 -0
- package/dist/src/surfaces/api/routes/applications.js +1 -0
- package/dist/src/surfaces/api/routes/commands.js +82 -0
- package/dist/src/surfaces/api/routes/control-plane.js +6 -0
- package/dist/src/surfaces/api/routes/events.js +1 -0
- package/dist/src/surfaces/api/routes/execution.js +8 -0
- package/dist/src/surfaces/api/routes/index.js +18 -0
- package/dist/src/surfaces/api/routes/observability.js +1 -0
- package/dist/src/surfaces/api/routes/orchestration.js +1 -0
- package/dist/src/surfaces/api/routes/pagination.js +78 -0
- package/dist/src/surfaces/api/routes/read.js +135 -0
- package/dist/src/surfaces/api/routes/resources.js +1 -0
- package/dist/src/surfaces/api/routes/responses.js +67 -0
- package/dist/src/surfaces/api/routes/system.js +1 -0
- package/dist/src/surfaces/api/routes/work.js +9 -0
- package/dist/src/surfaces/cli/commands/api.js +1 -0
- package/dist/src/surfaces/cli/commands/audit.js +10 -0
- package/dist/src/surfaces/cli/commands/correlate.js +2 -0
- package/dist/src/surfaces/cli/commands/doctor.js +6 -0
- package/dist/src/surfaces/cli/commands/init.js +39 -0
- package/dist/src/surfaces/cli/commands/sandbox-entrypoint.js +33 -0
- package/dist/src/surfaces/cli/commands/sandbox-setup.js +29 -0
- package/dist/src/surfaces/cli/commands/sandbox.js +105 -0
- package/dist/src/surfaces/cli/commands/self-update.js +38 -0
- package/dist/src/surfaces/cli/commands/smoke.js +16 -0
- package/dist/src/surfaces/cli/commands/start.js +1 -0
- package/dist/src/surfaces/cli/commands/stop.js +13 -0
- package/dist/src/surfaces/cli/commands/tick.js +1 -0
- package/dist/src/surfaces/cli/commands/ui.js +2 -0
- package/dist/src/surfaces/cli/commands/validate-state.js +5 -0
- package/dist/src/surfaces/cli/infrastructure/docker-cli.js +221 -0
- package/dist/src/surfaces/cli/infrastructure/process-log.js +86 -0
- package/dist/src/surfaces/cli/main.js +140 -0
- package/dist/src/surfaces/cli/usage.js +33 -0
- package/dist/src/surfaces/contracts/config.js +34 -0
- package/dist/src/surfaces/index.js +47 -0
- package/dist/src/surfaces/web-assets/assets/index-Bfn4FwZG.css +1 -0
- package/dist/src/surfaces/web-assets/assets/index-ipB6JPGU.js +1090 -0
- package/dist/src/surfaces/web-assets/index.html +13 -0
- package/dist/src/surfaces/web-host/asset-source.js +1 -0
- package/dist/src/surfaces/web-host/packaged-assets.js +44 -0
- package/dist/src/work/application/work-projection.js +59 -0
- package/dist/src/work/application/work-repository.js +18 -0
- package/dist/src/work/application/work-service.js +117 -0
- package/dist/src/work/contracts/commands.js +1 -0
- package/dist/src/work/contracts/config.js +2 -0
- package/dist/src/work/contracts/events.js +103 -0
- package/dist/src/work/contracts/identifiers.js +5 -0
- package/dist/src/work/contracts/streams.js +6 -0
- package/dist/src/work/contracts/views.js +1 -0
- package/dist/src/work/contracts/vocabulary.js +6 -0
- package/dist/src/work/domain/work-item.js +89 -0
- package/dist/src/work/index.js +11 -0
- package/docker/Dockerfile +10 -6
- package/docker/Dockerfile.packaged +3 -3
- package/package.json +29 -4
- package/prompts/implement.md +2 -2
- package/dist/src/adapters/claude/claude-runner.js +0 -529
- package/dist/src/adapters/codex/codex-runner.js +0 -503
- package/dist/src/adapters/cursor/cursor-runner.js +0 -418
- package/dist/src/adapters/docker/docker-cli.js +0 -150
- package/dist/src/adapters/fake/fake-artifact-verifier.js +0 -14
- package/dist/src/adapters/fake/fake-github-pull-request-activity-source.js +0 -77
- package/dist/src/adapters/fake/fake-resource-index.js +0 -21
- package/dist/src/adapters/fake/fake-runner.js +0 -77
- package/dist/src/adapters/fake/fake-ticketing-system.js +0 -185
- package/dist/src/adapters/fake/fake-workspace-manager.js +0 -81
- package/dist/src/adapters/fs/resource-index.js +0 -126
- package/dist/src/adapters/fs/self-update-ledger.js +0 -17
- package/dist/src/adapters/fs/state-store.js +0 -775
- package/dist/src/adapters/git/git-workspace-manager.js +0 -289
- package/dist/src/adapters/github/github-artifact-verifier.js +0 -38
- package/dist/src/adapters/github/github-auth.js +0 -16
- package/dist/src/adapters/github/github-client.js +0 -249
- package/dist/src/adapters/github/github-etag-cache.js +0 -57
- package/dist/src/adapters/github/github-issues-work-source.js +0 -692
- package/dist/src/adapters/github/github-pull-request-activity-source.js +0 -584
- package/dist/src/adapters/github/github-pull-request-merge-actor.js +0 -45
- package/dist/src/adapters/http/ui-assets.js +0 -1188
- package/dist/src/adapters/http/ui-data.js +0 -1107
- package/dist/src/adapters/http/ui-server.js +0 -458
- package/dist/src/adapters/runner/cli-command.js +0 -73
- package/dist/src/adapters/runner/prompt-templates.js +0 -76
- package/dist/src/adapters/runner/runner-cli-adapter.js +0 -112
- package/dist/src/adapters/runner/runner-registry.js +0 -139
- package/dist/src/adapters/runner/runtime-events.js +0 -32
- package/dist/src/adapters/runner/stage-prompt.js +0 -268
- package/dist/src/adapters/runner/transcripts.js +0 -25
- package/dist/src/cli/audit-command.js +0 -36
- package/dist/src/cli/correlate-command.js +0 -62
- package/dist/src/cli/doctor-command.js +0 -48
- package/dist/src/cli/init-command.js +0 -18
- package/dist/src/cli/sandbox-command.js +0 -258
- package/dist/src/cli/sandbox-entrypoint-command.js +0 -88
- package/dist/src/cli/sandbox-exec-logging.js +0 -7
- package/dist/src/cli/sandbox-resume.js +0 -79
- package/dist/src/cli/sandbox-setup-command.js +0 -31
- package/dist/src/cli/scaffold-assets.js +0 -100
- package/dist/src/cli/self-update-command.js +0 -198
- package/dist/src/cli/startup-preflight.js +0 -134
- package/dist/src/cli/stop-command.js +0 -46
- package/dist/src/cli/ui-command.js +0 -27
- package/dist/src/config/defaults.js +0 -10
- package/dist/src/config/discover-config-files.js +0 -11
- package/dist/src/config/load-config.js +0 -69
- package/dist/src/config/split-config.js +0 -14
- package/dist/src/core/active-run-recovery.js +0 -44
- package/dist/src/core/approval-intents.js +0 -16
- package/dist/src/core/audit-events.js +0 -82
- package/dist/src/core/control-plane.js +0 -192
- package/dist/src/core/event-builders.js +0 -153
- package/dist/src/core/event-resolver.js +0 -249
- package/dist/src/core/lifecycle-service.js +0 -8
- package/dist/src/core/live-execution.js +0 -81
- package/dist/src/core/outbox.js +0 -198
- package/dist/src/core/policy-engine.js +0 -389
- package/dist/src/core/projection-updater.js +0 -693
- package/dist/src/core/quota-backoff.js +0 -69
- package/dist/src/core/run-lease.js +0 -38
- package/dist/src/core/scheduled-workflow-source.js +0 -199
- package/dist/src/core/sink-router.js +0 -107
- package/dist/src/core/stale-run-reconciler.js +0 -352
- package/dist/src/core/tick-runner.js +0 -2442
- package/dist/src/core/workspace-cleanup.js +0 -117
- package/dist/src/domain/branch-naming.js +0 -14
- package/dist/src/domain/custom-commands.js +0 -58
- package/dist/src/domain/event-types.js +0 -158
- package/dist/src/domain/manual-labels.js +0 -1
- package/dist/src/domain/resource-uri.js +0 -38
- package/dist/src/domain/runner-routing.js +0 -127
- package/dist/src/domain/runtime-events.js +0 -36
- package/dist/src/domain/schema.js +0 -1233
- package/dist/src/domain/sources.js +0 -16
- package/dist/src/domain/stages.js +0 -36
- package/dist/src/domain/work-item-labels.js +0 -48
- package/dist/src/domain/work-item-lifecycle.js +0 -10
- package/dist/src/domain/work-item-status.js +0 -33
- package/dist/src/domain/workflows.js +0 -159
- package/dist/src/lib/deep-merge.js +0 -14
- package/dist/src/lib/detached-process-logging.js +0 -46
- package/dist/src/lib/event-log.js +0 -21
- package/dist/src/lib/format.js +0 -41
- package/dist/src/lib/json-file.js +0 -23
- package/dist/src/lib/lock.js +0 -181
- package/dist/src/lib/log-rotation.js +0 -42
- package/dist/src/lib/paths.js +0 -52
- package/dist/src/lib/process-identity.js +0 -54
- package/dist/src/lib/state-health.js +0 -30
- package/dist/src/lib/work-id.js +0 -19
- package/dist/src/lib/yaml-file.js +0 -20
- package/templates/SETUP.md +0 -115
- /package/dist/src/{core → activities/pr}/contracts.js +0 -0
- /package/dist/src/{domain/types.js → control-plane/contracts/views.js} +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { reportedArtifactSchema } from '../../activities/index.js';
|
|
2
|
+
import { createEventDraft, EventActorKind, EventSourceKind, } from '../../kernel/index.js';
|
|
3
|
+
import { OrchestrationEventType, selectWorkflowOrchestrationEvent, workflowInstanceStream, } from '../../orchestration/index.js';
|
|
4
|
+
import { ResourceCorrelationProvenance, ResourceCorrelationRole, resourceId, resourceKind, ResourceStreamKind, } from '../../resources/index.js';
|
|
5
|
+
import { ArtifactEventType, decodeArtifactEvent, } from '../contracts/artifact-events.js';
|
|
6
|
+
import { ArtifactVerificationResult, ArtifactVerificationStatus, } from '../contracts/artifact-vocabulary.js';
|
|
7
|
+
import { integrationStream } from '../contracts/streams.js';
|
|
8
|
+
export class ArtifactRegistrationReactor {
|
|
9
|
+
dependencies;
|
|
10
|
+
constructor(dependencies) {
|
|
11
|
+
this.dependencies = dependencies;
|
|
12
|
+
}
|
|
13
|
+
async runOnce(limit = 100) {
|
|
14
|
+
const consumer = 'reactor:artifact-registration';
|
|
15
|
+
const events = await this.dependencies.journal.readAll(await this.dependencies.checkpoints.load(consumer), limit);
|
|
16
|
+
for (const event of events) {
|
|
17
|
+
const outcome = selectWorkflowOrchestrationEvent(event);
|
|
18
|
+
if (outcome?.eventType === OrchestrationEventType.ActivityOutcomeAccepted)
|
|
19
|
+
await this.register(outcome);
|
|
20
|
+
await this.dependencies.checkpoints.save(consumer, event.globalPosition);
|
|
21
|
+
}
|
|
22
|
+
await this.reconcileAmbiguous();
|
|
23
|
+
return events.length;
|
|
24
|
+
}
|
|
25
|
+
async register(outcome) {
|
|
26
|
+
const artifacts = reportedArtifacts(outcome.payload.outcome.data);
|
|
27
|
+
if (artifacts.length === 0)
|
|
28
|
+
return;
|
|
29
|
+
const branch = await this.branchFor(outcome.payload.activationId);
|
|
30
|
+
if (branch === undefined)
|
|
31
|
+
return;
|
|
32
|
+
const workItemId = await this.workItemFor(outcome.stream.id);
|
|
33
|
+
if (workItemId === null)
|
|
34
|
+
return;
|
|
35
|
+
for (const artifact of artifacts)
|
|
36
|
+
await this.verifyAndRegister({
|
|
37
|
+
workflowInstanceId: outcome.stream.id,
|
|
38
|
+
activationId: outcome.payload.activationId,
|
|
39
|
+
artifact,
|
|
40
|
+
correlationId: outcome.correlationId,
|
|
41
|
+
causationId: outcome.eventId,
|
|
42
|
+
occurredAt: outcome.recordedAt,
|
|
43
|
+
}, branch, workItemId, 1);
|
|
44
|
+
}
|
|
45
|
+
async reconcileAmbiguous() {
|
|
46
|
+
const latest = new Map();
|
|
47
|
+
for (const event of await this.dependencies.journal.readAll(0)) {
|
|
48
|
+
if (event.eventType !== ArtifactEventType.VerificationUnresolved)
|
|
49
|
+
continue;
|
|
50
|
+
const decoded = decodeArtifactEvent(event);
|
|
51
|
+
const key = `${decoded.causationId}:${decoded.payload.artifact.externalKey.adapter}:${decoded.payload.artifact.externalKey.key}`;
|
|
52
|
+
latest.set(key, decoded);
|
|
53
|
+
}
|
|
54
|
+
for (const event of latest.values()) {
|
|
55
|
+
if (event.payload.status !== ArtifactVerificationStatus.Ambiguous || event.payload.escalated)
|
|
56
|
+
continue;
|
|
57
|
+
const branch = await this.branchFor(event.payload.activationId);
|
|
58
|
+
const workItemId = await this.workItemFor(event.payload.workflowInstanceId);
|
|
59
|
+
if (branch === undefined || workItemId === null)
|
|
60
|
+
continue;
|
|
61
|
+
await this.verifyAndRegister({
|
|
62
|
+
workflowInstanceId: event.payload.workflowInstanceId,
|
|
63
|
+
activationId: event.payload.activationId,
|
|
64
|
+
artifact: event.payload.artifact,
|
|
65
|
+
correlationId: event.correlationId,
|
|
66
|
+
causationId: event.causationId,
|
|
67
|
+
occurredAt: event.recordedAt,
|
|
68
|
+
}, branch, workItemId, event.payload.attempt + 1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async verifyAndRegister(record, branch, workItemId, attempt) {
|
|
72
|
+
const provider = this.dependencies.providers.find((candidate) => candidate.adapter === record.artifact.externalKey.adapter);
|
|
73
|
+
if (provider === undefined)
|
|
74
|
+
return;
|
|
75
|
+
const verified = await provider.verifyArtifact(record.artifact.kind, record.artifact.externalKey, {
|
|
76
|
+
workspaceBranch: branch,
|
|
77
|
+
});
|
|
78
|
+
if (typeof verified === 'string') {
|
|
79
|
+
await this.recordUnresolved(provider, record, verified, attempt);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
await this.registerVerified(record, verified, workItemId);
|
|
83
|
+
}
|
|
84
|
+
async registerVerified(record, verified, workItemId) {
|
|
85
|
+
const existing = await this.dependencies.resources.findByExternalKey(verified.externalKey);
|
|
86
|
+
const resource = existing ??
|
|
87
|
+
(await this.dependencies.resources.discover({
|
|
88
|
+
resourceId: resourceId(this.dependencies.ids.next(ResourceStreamKind.Resource)),
|
|
89
|
+
kind: verified.kind,
|
|
90
|
+
externalKey: verified.externalKey,
|
|
91
|
+
capabilities: verified.capabilities,
|
|
92
|
+
...(verified.revision === undefined ? {} : { revision: verified.revision }),
|
|
93
|
+
}, context(record.causationId, record.correlationId, record.occurredAt)));
|
|
94
|
+
try {
|
|
95
|
+
await this.dependencies.resources.correlate(resource.resourceId, workItemId, ResourceCorrelationRole.Primary, context(record.causationId, record.correlationId, record.occurredAt), ResourceCorrelationProvenance.AgentReported);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Resources records primary conflicts durably; this flow never guesses a secondary relation.
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async recordUnresolved(provider, record, result, attempt) {
|
|
102
|
+
const stream = integrationStream(provider.adapter);
|
|
103
|
+
const sequence = (await this.dependencies.journal.readStream(stream)).length;
|
|
104
|
+
const ambiguous = result === ArtifactVerificationResult.Ambiguous;
|
|
105
|
+
const escalated = ambiguous && attempt >= (this.dependencies.maxAmbiguityReconciliationAttempts ?? 3);
|
|
106
|
+
await this.dependencies.journal.append(stream, sequence, [
|
|
107
|
+
createEventDraft({
|
|
108
|
+
eventId: `${record.causationId}:artifact:${record.artifact.externalKey.key}:unresolved:${attempt}`,
|
|
109
|
+
eventType: ArtifactEventType.VerificationUnresolved,
|
|
110
|
+
occurredAt: record.occurredAt,
|
|
111
|
+
correlationId: record.correlationId,
|
|
112
|
+
causationId: record.causationId,
|
|
113
|
+
actor: { kind: EventActorKind.Integration, id: 'artifact-registration' },
|
|
114
|
+
source: { kind: EventSourceKind.Internal, id: 'artifact-registration' },
|
|
115
|
+
stream,
|
|
116
|
+
payload: {
|
|
117
|
+
workflowInstanceId: record.workflowInstanceId,
|
|
118
|
+
activationId: record.activationId,
|
|
119
|
+
artifact: record.artifact,
|
|
120
|
+
status: ambiguous
|
|
121
|
+
? ArtifactVerificationStatus.Ambiguous
|
|
122
|
+
: ArtifactVerificationStatus.Failed,
|
|
123
|
+
attempt,
|
|
124
|
+
escalated,
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
]);
|
|
128
|
+
}
|
|
129
|
+
async branchFor(activationId) {
|
|
130
|
+
return (await this.dependencies.runs.list(activationId)).at(-1)?.workspace?.branch;
|
|
131
|
+
}
|
|
132
|
+
async workItemFor(workflow) {
|
|
133
|
+
const events = await this.dependencies.journal.readStream(workflowInstanceStream(workflow));
|
|
134
|
+
const started = events
|
|
135
|
+
.map(selectWorkflowOrchestrationEvent)
|
|
136
|
+
.find((event) => event?.eventType === OrchestrationEventType.InstanceStarted);
|
|
137
|
+
return started?.payload.workItemId ?? null;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function reportedArtifacts(value) {
|
|
141
|
+
if (typeof value !== 'object' || value === null || !('reportedArtifacts' in value))
|
|
142
|
+
return [];
|
|
143
|
+
const artifacts = value.reportedArtifacts;
|
|
144
|
+
if (!Array.isArray(artifacts))
|
|
145
|
+
return [];
|
|
146
|
+
return artifacts
|
|
147
|
+
.map((artifact) => reportedArtifactSchema.safeParse(artifact))
|
|
148
|
+
.flatMap((result) => result.success
|
|
149
|
+
? [{ kind: resourceKind(result.data.kind), externalKey: result.data.externalKey }]
|
|
150
|
+
: []);
|
|
151
|
+
}
|
|
152
|
+
function context(commandId, correlationId, occurredAt) {
|
|
153
|
+
return {
|
|
154
|
+
commandId: `${commandId}:artifact-registration`,
|
|
155
|
+
correlationId: correlationId,
|
|
156
|
+
occurredAt,
|
|
157
|
+
actor: { kind: EventActorKind.Integration, id: 'artifact-registration' },
|
|
158
|
+
};
|
|
159
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { integrationStream } from '../contracts/streams.js';
|
|
2
|
+
export class PollService {
|
|
3
|
+
journal;
|
|
4
|
+
instance;
|
|
5
|
+
constructor(journal, instance) {
|
|
6
|
+
this.journal = journal;
|
|
7
|
+
this.instance = instance;
|
|
8
|
+
}
|
|
9
|
+
/** Resolves to the count of newly appended drafts, so callers can tell activity from a quiet poll. */
|
|
10
|
+
async pollOnce(signal) {
|
|
11
|
+
const drafts = await this.instance.source.poll(signal);
|
|
12
|
+
let appended = 0;
|
|
13
|
+
for (const draft of drafts) {
|
|
14
|
+
if (!this.instance.eventTypes.includes(draft.eventType))
|
|
15
|
+
throw new Error(`Provider ${this.instance.adapter} emitted an unknown event type`);
|
|
16
|
+
const stream = integrationStream(this.instance.adapter);
|
|
17
|
+
const existing = await this.journal.readStream(stream);
|
|
18
|
+
if (existing.some((event) => event.eventId === draft.eventId))
|
|
19
|
+
continue;
|
|
20
|
+
await this.journal.append(stream, existing.length, [{ ...draft, stream }]);
|
|
21
|
+
appended += 1;
|
|
22
|
+
}
|
|
23
|
+
return appended;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function projectTerminalAgentRunReport(input) {
|
|
2
|
+
if (input.run.finishedAt === undefined)
|
|
3
|
+
return null;
|
|
4
|
+
const agent = input.run.agent;
|
|
5
|
+
return {
|
|
6
|
+
runId: input.run.runId,
|
|
7
|
+
...(input.stage === undefined ? {} : { stage: input.stage }),
|
|
8
|
+
...runnerFields(input.run.runner),
|
|
9
|
+
startedAt: input.run.startedAt,
|
|
10
|
+
finishedAt: input.run.finishedAt,
|
|
11
|
+
displayBody: displayBodyFor(agent, input.run.failure),
|
|
12
|
+
outcome: agent?.outcome ?? 'FAILED',
|
|
13
|
+
...sessionIdField(agent),
|
|
14
|
+
...(input.run.workspace === undefined ? {} : { workspacePath: input.run.workspace.path }),
|
|
15
|
+
metadata: agent?.metadata ?? {},
|
|
16
|
+
...(input.awaitingApproval === true ? { awaitingApproval: true } : {}),
|
|
17
|
+
...(input.watchGateVerdict === undefined ? {} : { watchGateVerdict: input.watchGateVerdict }),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function runnerFields(runner) {
|
|
21
|
+
if (runner === undefined)
|
|
22
|
+
return {};
|
|
23
|
+
return {
|
|
24
|
+
runner: runner.name,
|
|
25
|
+
...(runner.model === undefined ? {} : { model: runner.model }),
|
|
26
|
+
...(runner.pool === undefined ? {} : { runnerPool: runner.pool }),
|
|
27
|
+
...(runner.cli === undefined ? {} : { cli: runner.cli }),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function displayBodyFor(agent, failure) {
|
|
31
|
+
if (agent?.displayBody !== undefined && agent.displayBody.length > 0)
|
|
32
|
+
return agent.displayBody;
|
|
33
|
+
if (failure?.message !== undefined && failure.message.length > 0)
|
|
34
|
+
return failure.message;
|
|
35
|
+
return 'Runner failed without a response.';
|
|
36
|
+
}
|
|
37
|
+
function sessionIdField(agent) {
|
|
38
|
+
const sessionId = agent?.metadata.sessionId;
|
|
39
|
+
return typeof sessionId === 'string' ? { sessionId } : {};
|
|
40
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { orchestrationGroupId, workflowInstanceId, } from '../../orchestration/index.js';
|
|
2
|
+
import { ResourceCorrelationRole, } from '../../resources/index.js';
|
|
3
|
+
// The single place a newly observed external object becomes Wake work: discover the
|
|
4
|
+
// resource, create the WorkItem with its intake tags, correlate the two, then start the
|
|
5
|
+
// workflow configuration selects. No adapter proposes a workflow name.
|
|
6
|
+
export async function admitObservedWork(services, input, context,
|
|
7
|
+
// Provider evidence that the entry stage must already see, recorded before the start.
|
|
8
|
+
beforeStart) {
|
|
9
|
+
await services.resources.discover({
|
|
10
|
+
resourceId: input.resourceId,
|
|
11
|
+
kind: input.kind,
|
|
12
|
+
externalKey: input.externalKey,
|
|
13
|
+
capabilities: input.capabilities,
|
|
14
|
+
...(input.revision === undefined ? {} : { revision: input.revision }),
|
|
15
|
+
...(input.title === undefined ? {} : { title: input.title }),
|
|
16
|
+
}, context);
|
|
17
|
+
await services.work.create({ workItemId: input.workItemId, objective: input.objective, tags: input.tags }, context);
|
|
18
|
+
await services.resources.correlate(input.resourceId, input.workItemId, ResourceCorrelationRole.Primary, context);
|
|
19
|
+
if (beforeStart !== undefined)
|
|
20
|
+
await beforeStart();
|
|
21
|
+
await services.orchestration.start({
|
|
22
|
+
workflowInstanceId: workflowInstanceId(`primary:${input.workItemId}`),
|
|
23
|
+
workItemId: input.workItemId,
|
|
24
|
+
workflowName: services.routing.select({
|
|
25
|
+
tags: input.tags,
|
|
26
|
+
kind: input.kind,
|
|
27
|
+
adapter: input.adapter,
|
|
28
|
+
}),
|
|
29
|
+
orchestrationGroupId: orchestrationGroupId(`primary:${input.workItemId}`),
|
|
30
|
+
}, context);
|
|
31
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WorkStatus } from '../../work/index.js';
|
|
2
|
+
import { ExternalWorkOutcome } from '../contracts/outcome-vocabulary.js';
|
|
3
|
+
// Mirrors work-admission.ts's shared, adapter-neutral seam: an adapter
|
|
4
|
+
// translator calls this once it observes an external resource's terminal
|
|
5
|
+
// outcome. Self-idempotent — a duplicate or replayed observation, or Wake's
|
|
6
|
+
// own close echoing back through the next poll, is a safe no-op because it
|
|
7
|
+
// checks current WorkItem state rather than relying on WorkService's
|
|
8
|
+
// throw-on-non-Open guard.
|
|
9
|
+
export async function concludeObservedWork(services, input) {
|
|
10
|
+
const current = await services.work.get(input.workItemId);
|
|
11
|
+
if (current === null || current.state !== WorkStatus.Open)
|
|
12
|
+
return;
|
|
13
|
+
if (input.outcome === ExternalWorkOutcome.Completed) {
|
|
14
|
+
await services.conclusion.closeWork(input.workItemId, input.reason);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
await services.conclusion.cancelWork(input.workItemId, input.reason);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { activationId } from '../../activities/index.js';
|
|
3
|
+
import { brandedStringSchema, eventEnvelopeSchema, } from '../../kernel/index.js';
|
|
4
|
+
import { workflowInstanceId } from '../../orchestration/index.js';
|
|
5
|
+
import { resourceKind } from '../../resources/index.js';
|
|
6
|
+
import { ArtifactVerificationStatus, } from './artifact-vocabulary.js';
|
|
7
|
+
import { adapterId } from './identifiers.js';
|
|
8
|
+
import { IntegrationStreamKind, integrationStream } from './streams.js';
|
|
9
|
+
export const ArtifactEventType = {
|
|
10
|
+
VerificationUnresolved: 'integration.artifact-verification-unresolved',
|
|
11
|
+
};
|
|
12
|
+
const schema = eventEnvelopeSchema
|
|
13
|
+
.extend({
|
|
14
|
+
eventType: z.literal(ArtifactEventType.VerificationUnresolved),
|
|
15
|
+
stream: z
|
|
16
|
+
.object({
|
|
17
|
+
kind: z.literal(IntegrationStreamKind.Integration),
|
|
18
|
+
id: brandedStringSchema(adapterId),
|
|
19
|
+
})
|
|
20
|
+
.strict(),
|
|
21
|
+
payload: z
|
|
22
|
+
.object({
|
|
23
|
+
workflowInstanceId: brandedStringSchema(workflowInstanceId),
|
|
24
|
+
activationId: brandedStringSchema(activationId),
|
|
25
|
+
artifact: z
|
|
26
|
+
.object({
|
|
27
|
+
kind: brandedStringSchema(resourceKind),
|
|
28
|
+
externalKey: z
|
|
29
|
+
.object({ adapter: brandedStringSchema(adapterId), key: z.string().min(1) })
|
|
30
|
+
.strict(),
|
|
31
|
+
})
|
|
32
|
+
.strict(),
|
|
33
|
+
status: z.enum([ArtifactVerificationStatus.Failed, ArtifactVerificationStatus.Ambiguous]),
|
|
34
|
+
attempt: z.number().int().positive(),
|
|
35
|
+
escalated: z.boolean(),
|
|
36
|
+
})
|
|
37
|
+
.strict(),
|
|
38
|
+
})
|
|
39
|
+
.superRefine((event, context) => {
|
|
40
|
+
if (event.stream.id !== event.payload.artifact.externalKey.adapter)
|
|
41
|
+
context.addIssue({
|
|
42
|
+
code: 'custom',
|
|
43
|
+
path: [],
|
|
44
|
+
message: 'Artifact adapter must identify its integration stream',
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
export function decodeArtifactEvent(event) {
|
|
48
|
+
const result = schema.safeParse(event);
|
|
49
|
+
if (!result.success)
|
|
50
|
+
throw new Error(`Invalid artifact event ${event.eventId}: ${result.error.message}`, {
|
|
51
|
+
cause: result.error,
|
|
52
|
+
});
|
|
53
|
+
return result.data;
|
|
54
|
+
}
|
|
55
|
+
export function artifactVerificationUnresolvedDraft(input) {
|
|
56
|
+
return { ...input, schemaVersion: 1 };
|
|
57
|
+
}
|
|
58
|
+
export function artifactIntegrationStream(adapter) {
|
|
59
|
+
return integrationStream(adapter);
|
|
60
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineClosedVocabulary } from '../../kernel/index.js';
|
|
2
|
+
export const ArtifactVerificationResult = defineClosedVocabulary({
|
|
3
|
+
NotFound: 'not-found',
|
|
4
|
+
Ambiguous: 'ambiguous',
|
|
5
|
+
});
|
|
6
|
+
export const ArtifactVerificationStatus = defineClosedVocabulary({
|
|
7
|
+
Failed: 'failed',
|
|
8
|
+
Ambiguous: 'ambiguous',
|
|
9
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const providerEntrySchema = z
|
|
3
|
+
.looseObject({
|
|
4
|
+
provider: z
|
|
5
|
+
.string()
|
|
6
|
+
.trim()
|
|
7
|
+
.regex(/^[a-z][a-z0-9-]*$/)
|
|
8
|
+
.optional(),
|
|
9
|
+
enabled: z.boolean().default(true),
|
|
10
|
+
})
|
|
11
|
+
.transform((value) => ({ ...value, enabled: value.enabled ?? true }));
|
|
12
|
+
export const integrationsConfigSchema = z
|
|
13
|
+
.record(z.string().regex(/^[a-z][a-z0-9-]*$/), providerEntrySchema)
|
|
14
|
+
.default({});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { matchesRequiredValues } from '../../kernel/index.js';
|
|
2
|
+
// With no rules configured every observation is admitted and carries no tags; otherwise an
|
|
3
|
+
// observation must match at least one rule, and collects the tags of every rule it matches.
|
|
4
|
+
export function evaluateIntakeRules(rules, facts) {
|
|
5
|
+
if (rules.length === 0)
|
|
6
|
+
return { admitted: true, tags: [] };
|
|
7
|
+
const matched = rules.filter((rule) => ruleMatches(rule, facts));
|
|
8
|
+
if (matched.length === 0)
|
|
9
|
+
return { admitted: false, tags: [] };
|
|
10
|
+
return { admitted: true, tags: [...new Set(matched.flatMap((rule) => rule.tags))] };
|
|
11
|
+
}
|
|
12
|
+
function ruleMatches(rule, facts) {
|
|
13
|
+
return Object.entries(rule.where).every(([facet, required]) => matchesRequiredValues(rule.matchMode, required, facts[facet] ?? []));
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { defineClosedVocabulary } from '../../kernel/index.js';
|
|
2
|
+
// How an external resource (a GitHub issue today; any future adapter's
|
|
3
|
+
// ticket) concluded, independent of that provider's own vocabulary.
|
|
4
|
+
export const ExternalWorkOutcome = defineClosedVocabulary({
|
|
5
|
+
Completed: 'completed',
|
|
6
|
+
Cancelled: 'cancelled',
|
|
7
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { adapterId } from './identifiers.js';
|
|
2
|
+
export class ProviderRegistry {
|
|
3
|
+
definitions = new Map();
|
|
4
|
+
register(definition) {
|
|
5
|
+
if (this.definitions.has(definition.provider))
|
|
6
|
+
throw new Error(`Provider ${definition.provider} exists`);
|
|
7
|
+
this.definitions.set(definition.provider, definition);
|
|
8
|
+
}
|
|
9
|
+
compose(config, services) {
|
|
10
|
+
const instances = [];
|
|
11
|
+
const failures = [];
|
|
12
|
+
for (const [name, entry] of Object.entries(config)) {
|
|
13
|
+
if (!entry.enabled)
|
|
14
|
+
continue;
|
|
15
|
+
const provider = entry.provider ?? name;
|
|
16
|
+
const definition = this.definitions.get(provider);
|
|
17
|
+
if (definition === undefined)
|
|
18
|
+
throw new Error(`Provider ${provider} is not registered`);
|
|
19
|
+
const adapter = adapterId(name);
|
|
20
|
+
try {
|
|
21
|
+
instances.push(definition.create({
|
|
22
|
+
adapter,
|
|
23
|
+
config: definition.parseConfig(entry),
|
|
24
|
+
...(services === undefined ? {} : { services }),
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
failures.push({
|
|
29
|
+
adapter,
|
|
30
|
+
provider,
|
|
31
|
+
error: error instanceof Error ? error.message : String(error),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { instances, failures };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const IntegrationStreamKind = { Integration: 'integration', Delivery: 'delivery' };
|
|
2
|
+
export const integrationStream = (id) => ({
|
|
3
|
+
kind: IntegrationStreamKind.Integration,
|
|
4
|
+
id,
|
|
5
|
+
});
|
|
6
|
+
export const isIntegrationStream = (stream) => stream.kind === IntegrationStreamKind.Integration;
|
|
7
|
+
export const deliveryStream = (intentEventId) => ({
|
|
8
|
+
kind: IntegrationStreamKind.Delivery,
|
|
9
|
+
id: intentEventId,
|
|
10
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ActivityOutcomeKind, activationId } from '../../../activities/index.js';
|
|
2
|
+
import { EventActorKind } from '../../../kernel/index.js';
|
|
3
|
+
import { ActivityActivationStatus, workflowInstanceId, } from '../../../orchestration/index.js';
|
|
4
|
+
import { DeliveryEventType, selectDeliveryEvent } from '../contracts/events.js';
|
|
5
|
+
import { DeliveryResultKind } from '../contracts/vocabulary.js';
|
|
6
|
+
const deliveryResultSignalKind = 'delivery-result';
|
|
7
|
+
export class DeliveryOutcomeReactor {
|
|
8
|
+
journal;
|
|
9
|
+
checkpoints;
|
|
10
|
+
orchestration;
|
|
11
|
+
constructor(journal, checkpoints, orchestration) {
|
|
12
|
+
this.journal = journal;
|
|
13
|
+
this.checkpoints = checkpoints;
|
|
14
|
+
this.orchestration = orchestration;
|
|
15
|
+
}
|
|
16
|
+
async runOnce() {
|
|
17
|
+
const consumer = 'reactor:delivery-outcomes';
|
|
18
|
+
const events = await this.journal.readAll(await this.checkpoints.load(consumer));
|
|
19
|
+
for (const event of events) {
|
|
20
|
+
const delivery = selectDeliveryEvent(event);
|
|
21
|
+
if (delivery !== null) {
|
|
22
|
+
const command = {
|
|
23
|
+
workflowInstanceId: workflowInstanceId(delivery.payload.workflowInstanceId),
|
|
24
|
+
activationId: activationId(delivery.payload.activationId),
|
|
25
|
+
};
|
|
26
|
+
if (await this.isAwaitingThisDelivery(command, delivery.payload.intentEventId)) {
|
|
27
|
+
if (delivery.eventType === DeliveryEventType.Confirmed ||
|
|
28
|
+
(delivery.eventType === DeliveryEventType.Reconciled &&
|
|
29
|
+
delivery.payload.result === DeliveryResultKind.Confirmed))
|
|
30
|
+
await this.orchestration.acceptOutcome({
|
|
31
|
+
...command,
|
|
32
|
+
outcome: {
|
|
33
|
+
kind: ActivityOutcomeKind.Done,
|
|
34
|
+
data: { deliveryEventId: delivery.eventId },
|
|
35
|
+
},
|
|
36
|
+
}, {
|
|
37
|
+
commandId: delivery.eventId,
|
|
38
|
+
correlationId: event.correlationId,
|
|
39
|
+
actor: { kind: EventActorKind.System, id: 'delivery-outcome-reactor' },
|
|
40
|
+
occurredAt: event.recordedAt,
|
|
41
|
+
});
|
|
42
|
+
if (delivery.eventType === DeliveryEventType.Failed)
|
|
43
|
+
await this.orchestration.acceptOutcome({
|
|
44
|
+
...command,
|
|
45
|
+
outcome: {
|
|
46
|
+
kind: ActivityOutcomeKind.Failed,
|
|
47
|
+
data: { reason: delivery.payload.code },
|
|
48
|
+
},
|
|
49
|
+
}, {
|
|
50
|
+
commandId: delivery.eventId,
|
|
51
|
+
correlationId: event.correlationId,
|
|
52
|
+
actor: { kind: EventActorKind.System, id: 'delivery-outcome-reactor' },
|
|
53
|
+
occurredAt: event.recordedAt,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
await this.checkpoints.save(consumer, event.globalPosition);
|
|
58
|
+
}
|
|
59
|
+
return events.length;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A delivery's own completion may only resolve the activation that
|
|
63
|
+
* actually asked to wait on it (an activity outcome of `waiting` with
|
|
64
|
+
* `signalKind: 'delivery-result'`, e.g. pr.approve/pr.merge) — never a
|
|
65
|
+
* merely-still-open activation left pending for an unrelated reason
|
|
66
|
+
* (e.g. a technical failure with no configured route for that stage).
|
|
67
|
+
*/
|
|
68
|
+
async isAwaitingThisDelivery(command, intentEventId) {
|
|
69
|
+
const view = await this.orchestration.get(command.workflowInstanceId);
|
|
70
|
+
return (view?.pendingActivation?.activationId === command.activationId &&
|
|
71
|
+
view.pendingActivation.status === ActivityActivationStatus.Waiting &&
|
|
72
|
+
view.waitingFor?.signalKind === deliveryResultSignalKind &&
|
|
73
|
+
view.waitingFor.intentEventId === intentEventId);
|
|
74
|
+
}
|
|
75
|
+
}
|