@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
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { emitRuntimeEvent, runnerRuntimeEvent } from '../runner/runtime-events.js';
|
|
2
|
-
import { createAgentExecution } from '../../core/live-execution.js';
|
|
3
|
-
export function createFakeRunner(result, options) {
|
|
4
|
-
const runner = {
|
|
5
|
-
async start(input) {
|
|
6
|
-
return createAgentExecution(input, (liveInput) => runner.run(liveInput));
|
|
7
|
-
},
|
|
8
|
-
async run(_) {
|
|
9
|
-
const cli = options?.cli ?? 'Fake';
|
|
10
|
-
const isCanceled = () => _.cancellationSignal?.aborted === true;
|
|
11
|
-
if (isCanceled()) {
|
|
12
|
-
return {
|
|
13
|
-
result: 'Fake runner canceled\nFAILED',
|
|
14
|
-
model: 'fake',
|
|
15
|
-
cli,
|
|
16
|
-
failureClass: 'infra',
|
|
17
|
-
metadata: { source: 'fake-runner', canceled: true },
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
await emitRuntimeEvent(_.onRuntimeEvent, runnerRuntimeEvent({
|
|
21
|
-
type: 'agent.process.started',
|
|
22
|
-
runId: _.runId,
|
|
23
|
-
projection: _.projection,
|
|
24
|
-
routing: _.routing,
|
|
25
|
-
cli,
|
|
26
|
-
model: 'fake',
|
|
27
|
-
payload: { synthetic: true },
|
|
28
|
-
}));
|
|
29
|
-
await emitRuntimeEvent(_.onRuntimeEvent, runnerRuntimeEvent({
|
|
30
|
-
type: 'agent.progress',
|
|
31
|
-
runId: _.runId,
|
|
32
|
-
projection: _.projection,
|
|
33
|
-
routing: _.routing,
|
|
34
|
-
cli,
|
|
35
|
-
model: 'fake',
|
|
36
|
-
sessionId: 'fake-session-1',
|
|
37
|
-
payload: { message: 'Fake runner completed', synthetic: true },
|
|
38
|
-
}));
|
|
39
|
-
await emitRuntimeEvent(_.onRuntimeEvent, runnerRuntimeEvent({
|
|
40
|
-
type: 'agent.process.exited',
|
|
41
|
-
runId: _.runId,
|
|
42
|
-
projection: _.projection,
|
|
43
|
-
routing: _.routing,
|
|
44
|
-
cli,
|
|
45
|
-
model: 'fake',
|
|
46
|
-
sessionId: 'fake-session-1',
|
|
47
|
-
payload: { exitCode: 0, synthetic: true },
|
|
48
|
-
}));
|
|
49
|
-
if (isCanceled()) {
|
|
50
|
-
return {
|
|
51
|
-
result: 'Fake runner canceled\nFAILED',
|
|
52
|
-
model: 'fake',
|
|
53
|
-
cli,
|
|
54
|
-
failureClass: 'infra',
|
|
55
|
-
metadata: { source: 'fake-runner', canceled: true },
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return (result ?? {
|
|
59
|
-
result: [
|
|
60
|
-
'Fake runner completed',
|
|
61
|
-
'',
|
|
62
|
-
'```wake-result',
|
|
63
|
-
'{ "status": "DONE" }',
|
|
64
|
-
'```',
|
|
65
|
-
'DONE',
|
|
66
|
-
].join('\n'),
|
|
67
|
-
model: 'fake',
|
|
68
|
-
cli,
|
|
69
|
-
session_id: 'fake-session-1',
|
|
70
|
-
metadata: {
|
|
71
|
-
source: 'fake-runner',
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
return runner;
|
|
77
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { access } from 'node:fs/promises';
|
|
2
|
-
import { LABELS_REQUESTED_EVENT } from '../../domain/event-types.js';
|
|
3
|
-
import { buildResourceUri } from '../../domain/resource-uri.js';
|
|
4
|
-
import { createEventEnvelope, createUnkeyedEventEnvelope } from '../../lib/event-log.js';
|
|
5
|
-
import { readJsonFile } from '../../lib/json-file.js';
|
|
6
|
-
const fakeSource = 'fake-ticketing';
|
|
7
|
-
function normalizeIssueEvents(issue, nowIso) {
|
|
8
|
-
const sourceUrl = `https://example.test/${issue.repo}/issues/${issue.number}`;
|
|
9
|
-
// The source names the *resource* it saw, never the work item: the resolver
|
|
10
|
-
// in tick-runner turns this into the canonical workItemKey (spec D1).
|
|
11
|
-
const resourceUri = buildResourceUri(fakeSource, 'issue', `${issue.repo}#${issue.number}`);
|
|
12
|
-
return [
|
|
13
|
-
createUnkeyedEventEnvelope({
|
|
14
|
-
eventId: `fake-issue-${issue.repo}-${issue.number}`,
|
|
15
|
-
streamScope: 'global-intake',
|
|
16
|
-
direction: 'inbound',
|
|
17
|
-
sourceSystem: 'fake-ticketing',
|
|
18
|
-
sourceEventType: 'fake.issue.upsert',
|
|
19
|
-
sourceRefs: {
|
|
20
|
-
repo: issue.repo,
|
|
21
|
-
issueNumber: issue.number,
|
|
22
|
-
sourceUrl,
|
|
23
|
-
resourceUri,
|
|
24
|
-
},
|
|
25
|
-
occurredAt: nowIso,
|
|
26
|
-
ingestedAt: nowIso,
|
|
27
|
-
trigger: 'immediate',
|
|
28
|
-
payload: {
|
|
29
|
-
issue: {
|
|
30
|
-
repo: issue.repo,
|
|
31
|
-
number: issue.number,
|
|
32
|
-
title: issue.title,
|
|
33
|
-
body: issue.body,
|
|
34
|
-
labels: issue.labels,
|
|
35
|
-
assignees: [],
|
|
36
|
-
state: 'open',
|
|
37
|
-
url: sourceUrl,
|
|
38
|
-
createdAt: nowIso,
|
|
39
|
-
updatedAt: nowIso,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
raw: {
|
|
43
|
-
title: issue.title,
|
|
44
|
-
body: issue.body,
|
|
45
|
-
labels: issue.labels,
|
|
46
|
-
},
|
|
47
|
-
}),
|
|
48
|
-
...issue.comments.map((comment, index) => createUnkeyedEventEnvelope({
|
|
49
|
-
eventId: `fake-comment-${issue.repo}-${issue.number}-${comment.id}-${index}`,
|
|
50
|
-
streamScope: 'work-item',
|
|
51
|
-
direction: 'inbound',
|
|
52
|
-
sourceSystem: 'fake-ticketing',
|
|
53
|
-
sourceEventType: 'fake.issue.comment.created',
|
|
54
|
-
sourceRefs: {
|
|
55
|
-
repo: issue.repo,
|
|
56
|
-
issueNumber: issue.number,
|
|
57
|
-
commentId: comment.id,
|
|
58
|
-
sourceUrl,
|
|
59
|
-
resourceUri,
|
|
60
|
-
},
|
|
61
|
-
occurredAt: nowIso,
|
|
62
|
-
ingestedAt: nowIso,
|
|
63
|
-
trigger: 'context-only',
|
|
64
|
-
payload: {
|
|
65
|
-
comment: {
|
|
66
|
-
...comment,
|
|
67
|
-
createdAt: nowIso,
|
|
68
|
-
updatedAt: nowIso,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
derivedHints: {
|
|
72
|
-
botAuthoredComment: false,
|
|
73
|
-
},
|
|
74
|
-
})),
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
export function createFakeTicketingSystem(options) {
|
|
78
|
-
return {
|
|
79
|
-
async pollEvents(_input) {
|
|
80
|
-
const nowIso = (options.now ?? (() => new Date()))().toISOString();
|
|
81
|
-
return options.tickets.flatMap((issue) => normalizeIssueEvents(issue, nowIso));
|
|
82
|
-
},
|
|
83
|
-
async deliverIntent(input) {
|
|
84
|
-
const publishedAt = (options.now ?? (() => new Date()))().toISOString();
|
|
85
|
-
if (input.event.sourceEventType === LABELS_REQUESTED_EVENT) {
|
|
86
|
-
const ticket = options.tickets.find((issue) => issue.repo === input.event.sourceRefs.repo &&
|
|
87
|
-
issue.number === input.event.sourceRefs.issueNumber);
|
|
88
|
-
const currentLabels = ticket?.labels ?? [];
|
|
89
|
-
const statusLabel = typeof input.event.payload.statusLabel === 'string'
|
|
90
|
-
? input.event.payload.statusLabel
|
|
91
|
-
: undefined;
|
|
92
|
-
const stageLabel = typeof input.event.payload.stageLabel === 'string'
|
|
93
|
-
? input.event.payload.stageLabel
|
|
94
|
-
: undefined;
|
|
95
|
-
const workflowLabel = typeof input.event.payload.workflowLabel === 'string'
|
|
96
|
-
? input.event.payload.workflowLabel
|
|
97
|
-
: undefined;
|
|
98
|
-
const frozenLabel = typeof input.event.payload.frozenLabel === 'string'
|
|
99
|
-
? input.event.payload.frozenLabel
|
|
100
|
-
: undefined;
|
|
101
|
-
const scheduledLabel = typeof input.event.payload.scheduledLabel === 'string'
|
|
102
|
-
? input.event.payload.scheduledLabel
|
|
103
|
-
: undefined;
|
|
104
|
-
const labels = [
|
|
105
|
-
...currentLabels.filter((label) => !label.startsWith('wake:status.') &&
|
|
106
|
-
!label.startsWith('wake:stage.') &&
|
|
107
|
-
!label.startsWith('wake:workflow.') &&
|
|
108
|
-
label !== 'wake:frozen' &&
|
|
109
|
-
label !== 'wake:scheduled-workflow'),
|
|
110
|
-
...(statusLabel === undefined
|
|
111
|
-
? currentLabels.filter((label) => label.startsWith('wake:status.'))
|
|
112
|
-
: [statusLabel]),
|
|
113
|
-
...(stageLabel === undefined
|
|
114
|
-
? currentLabels.filter((label) => label.startsWith('wake:stage.'))
|
|
115
|
-
: [stageLabel]),
|
|
116
|
-
...(workflowLabel === undefined
|
|
117
|
-
? currentLabels.filter((label) => label.startsWith('wake:workflow.'))
|
|
118
|
-
: [workflowLabel]),
|
|
119
|
-
...(frozenLabel === undefined ? [] : [frozenLabel]),
|
|
120
|
-
...(scheduledLabel === undefined ? [] : [scheduledLabel]),
|
|
121
|
-
];
|
|
122
|
-
return [
|
|
123
|
-
createEventEnvelope({
|
|
124
|
-
eventId: `${input.event.eventId}-labels-updated`,
|
|
125
|
-
workItemKey: input.event.workItemKey,
|
|
126
|
-
streamScope: 'work-item',
|
|
127
|
-
direction: 'outbound',
|
|
128
|
-
sourceSystem: 'fake-ticketing',
|
|
129
|
-
sourceEventType: 'ticket.labels.updated',
|
|
130
|
-
sourceRefs: {
|
|
131
|
-
...input.event.sourceRefs,
|
|
132
|
-
sink: 'fake-ticketing',
|
|
133
|
-
},
|
|
134
|
-
occurredAt: publishedAt,
|
|
135
|
-
ingestedAt: publishedAt,
|
|
136
|
-
trigger: 'context-only',
|
|
137
|
-
payload: {
|
|
138
|
-
intentEventId: input.event.eventId,
|
|
139
|
-
idempotencyKey: input.event.payload.idempotencyKey,
|
|
140
|
-
deliveryState: 'CONFIRMED',
|
|
141
|
-
labels,
|
|
142
|
-
},
|
|
143
|
-
}),
|
|
144
|
-
];
|
|
145
|
-
}
|
|
146
|
-
const commentId = `${input.event.eventId}-comment`;
|
|
147
|
-
return [
|
|
148
|
-
createEventEnvelope({
|
|
149
|
-
eventId: `${input.event.eventId}-delivery`,
|
|
150
|
-
workItemKey: input.event.workItemKey,
|
|
151
|
-
streamScope: 'work-item',
|
|
152
|
-
direction: 'outbound',
|
|
153
|
-
sourceSystem: 'fake-ticketing',
|
|
154
|
-
sourceEventType: 'ticket.reply.published',
|
|
155
|
-
sourceRefs: {
|
|
156
|
-
...input.event.sourceRefs,
|
|
157
|
-
commentId,
|
|
158
|
-
sink: 'fake-ticketing',
|
|
159
|
-
},
|
|
160
|
-
occurredAt: publishedAt,
|
|
161
|
-
ingestedAt: publishedAt,
|
|
162
|
-
trigger: 'context-only',
|
|
163
|
-
payload: {
|
|
164
|
-
intentEventId: input.event.eventId,
|
|
165
|
-
idempotencyKey: input.event.payload.idempotencyKey,
|
|
166
|
-
deliveryState: 'CONFIRMED',
|
|
167
|
-
providerId: commentId,
|
|
168
|
-
kind: input.event.payload.kind,
|
|
169
|
-
body: input.event.payload.body,
|
|
170
|
-
},
|
|
171
|
-
}),
|
|
172
|
-
];
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
export async function createFileBackedFakeTicketingSystem(options) {
|
|
177
|
-
try {
|
|
178
|
-
await access(options.fixturePath);
|
|
179
|
-
}
|
|
180
|
-
catch {
|
|
181
|
-
return createFakeTicketingSystem(options.now === undefined ? { tickets: [] } : { tickets: [], now: options.now });
|
|
182
|
-
}
|
|
183
|
-
const raw = await readJsonFile(options.fixturePath);
|
|
184
|
-
return createFakeTicketingSystem(options.now === undefined ? { tickets: raw } : { tickets: raw, now: options.now });
|
|
185
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { mkdir, rm } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
export class FakeWorkspaceValidationError extends Error {
|
|
4
|
-
failureSource = 'wake-workspace-validation';
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = 'FakeWorkspaceValidationError';
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export function createFakeWorkspaceManager(root, options = {}) {
|
|
11
|
-
function validation(input) {
|
|
12
|
-
if (options.failValidation === true) {
|
|
13
|
-
throw new FakeWorkspaceValidationError('fake workspace validation failed');
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
repo: input.repo,
|
|
17
|
-
expectedBranch: input.branch,
|
|
18
|
-
actualBranch: input.branch,
|
|
19
|
-
expectedRemoteUrl: input.remoteUrl,
|
|
20
|
-
actualRemoteUrl: input.remoteUrl,
|
|
21
|
-
baseRevision: 'fake-base',
|
|
22
|
-
headRevision: 'fake-head',
|
|
23
|
-
clean: true,
|
|
24
|
-
remoteAvailable: true,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
async prepareWorkspace({ workId, repo, issueNumber, }) {
|
|
29
|
-
// Keyed on the work id, symmetrically with the real git-backed manager.
|
|
30
|
-
const workspacePath = join(root, workId);
|
|
31
|
-
await mkdir(workspacePath, { recursive: true });
|
|
32
|
-
return {
|
|
33
|
-
workspacePath,
|
|
34
|
-
mergeConflictDetected: false,
|
|
35
|
-
validation: validation({
|
|
36
|
-
repo,
|
|
37
|
-
branch: `wake/issue-${issueNumber}`,
|
|
38
|
-
remoteUrl: `https://github.com/${repo}.git`,
|
|
39
|
-
}),
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
async prepareReadOnlyClone({ repo }) {
|
|
43
|
-
const workspacePath = join(root, repo.replace(/[\\/]/g, '__'), 'canonical');
|
|
44
|
-
await mkdir(workspacePath, { recursive: true });
|
|
45
|
-
return {
|
|
46
|
-
workspacePath,
|
|
47
|
-
validation: validation({
|
|
48
|
-
repo,
|
|
49
|
-
branch: 'main',
|
|
50
|
-
remoteUrl: `https://github.com/${repo}.git`,
|
|
51
|
-
}),
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
async recordWorkspaceBookkeeping() {
|
|
55
|
-
if (options.failBookkeeping === true) {
|
|
56
|
-
throw new Error('fake workspace bookkeeping failed');
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
branch: 'wake/issue-fake',
|
|
60
|
-
headRevision: 'fake-head-after-run',
|
|
61
|
-
diffSummary: '',
|
|
62
|
-
untrackedFiles: [],
|
|
63
|
-
unpushedCommits: {
|
|
64
|
-
hasUpstream: false,
|
|
65
|
-
count: 0,
|
|
66
|
-
commits: [],
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
async cleanupWorkspace({ workspacePath }) {
|
|
71
|
-
// Retry on Windows EBUSY/EPERM (AV/indexer holding a brief handle) to
|
|
72
|
-
// match the real git-backed workspace manager's cleanup behavior.
|
|
73
|
-
await rm(workspacePath, {
|
|
74
|
-
recursive: true,
|
|
75
|
-
force: true,
|
|
76
|
-
maxRetries: 5,
|
|
77
|
-
retryDelay: 200,
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { readdir } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import { acquireFileLock } from '../../lib/lock.js';
|
|
6
|
-
import { readJsonFile, writeJsonFile } from '../../lib/json-file.js';
|
|
7
|
-
import { isMissingPathError, stateHealthIssue, StateHealthError, } from '../../lib/state-health.js';
|
|
8
|
-
const shardContentsSchema = z.record(z.string(), z.string());
|
|
9
|
-
/**
|
|
10
|
-
* Addresses a resource uri to one of 256 shards.
|
|
11
|
-
*
|
|
12
|
-
* The uri is hashed as opaque bytes — this never splits on ':' and never
|
|
13
|
-
* inspects the locator, which is what lets core shard without violating
|
|
14
|
-
* "core compares uris for equality only" (ADR 0001 §1). Hashing also yields
|
|
15
|
-
* a filename-safe shard name for free; the raw uri contains '/', '#' and ':'
|
|
16
|
-
* and could not be a filename without escaping.
|
|
17
|
-
*/
|
|
18
|
-
export function shardFor(resourceUri) {
|
|
19
|
-
return createHash('sha256').update(resourceUri, 'utf8').digest('hex').slice(0, 2);
|
|
20
|
-
}
|
|
21
|
-
async function readShard(file) {
|
|
22
|
-
try {
|
|
23
|
-
return shardContentsSchema.parse(await readJsonFile(file));
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
if (isMissingPathError(error)) {
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
29
|
-
throw new StateHealthError([
|
|
30
|
-
stateHealthIssue({
|
|
31
|
-
surface: 'reverse-index',
|
|
32
|
-
kind: 'corrupted',
|
|
33
|
-
path: file,
|
|
34
|
-
message: error instanceof Error ? error.message : String(error),
|
|
35
|
-
}),
|
|
36
|
-
]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export async function validateResourceIndex(paths) {
|
|
40
|
-
const issues = [];
|
|
41
|
-
const entries = await readdir(paths.resourceIndexRoot, { withFileTypes: true }).catch((error) => {
|
|
42
|
-
if (isMissingPathError(error)) {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
throw error;
|
|
46
|
-
});
|
|
47
|
-
for (const entry of entries) {
|
|
48
|
-
if (!entry.isFile() || !entry.name.endsWith('.json')) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const file = join(paths.resourceIndexRoot, entry.name);
|
|
52
|
-
try {
|
|
53
|
-
shardContentsSchema.parse(await readJsonFile(file));
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
issues.push(stateHealthIssue({
|
|
57
|
-
surface: 'reverse-index',
|
|
58
|
-
kind: 'corrupted',
|
|
59
|
-
path: file,
|
|
60
|
-
message: error instanceof Error ? error.message : String(error),
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return issues;
|
|
65
|
-
}
|
|
66
|
-
// acquireFileLock is a non-blocking try-lock: when contended it returns
|
|
67
|
-
// { acquired: false } immediately rather than waiting. register/retract have
|
|
68
|
-
// no sensible "try again later" behavior at their call sites — skipping the
|
|
69
|
-
// write here is exactly the silent-drop corruption this index exists to
|
|
70
|
-
// avoid — so withShardLock must retry until it actually holds the lock.
|
|
71
|
-
// staleAfterMs (60s) already reclaims a lock from a crashed holder, so this
|
|
72
|
-
// bound only needs to outlast normal contention between live processes, not
|
|
73
|
-
// a dead one.
|
|
74
|
-
const SHARD_LOCK_RETRY_INTERVAL_MS = 25;
|
|
75
|
-
const SHARD_LOCK_RETRY_BUDGET_MS = 10_000;
|
|
76
|
-
function delay(ms) {
|
|
77
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
78
|
-
}
|
|
79
|
-
export function createResourceIndex({ paths }) {
|
|
80
|
-
async function withShardLock(shard, fn) {
|
|
81
|
-
const lockPath = `${paths.resourceIndexShardFile(shard)}.lock`;
|
|
82
|
-
const deadline = Date.now() + SHARD_LOCK_RETRY_BUDGET_MS;
|
|
83
|
-
for (;;) {
|
|
84
|
-
const lock = await acquireFileLock(lockPath, { staleAfterMs: 60_000 });
|
|
85
|
-
if (lock.acquired) {
|
|
86
|
-
try {
|
|
87
|
-
return await fn();
|
|
88
|
-
}
|
|
89
|
-
finally {
|
|
90
|
-
await lock.release();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (Date.now() >= deadline) {
|
|
94
|
-
throw new Error(`resource-index: timed out after ${SHARD_LOCK_RETRY_BUDGET_MS}ms waiting for lock on shard '${shard}' (${lockPath})`);
|
|
95
|
-
}
|
|
96
|
-
await delay(SHARD_LOCK_RETRY_INTERVAL_MS);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
async resolve(resourceUri) {
|
|
101
|
-
const shard = await readShard(paths.resourceIndexShardFile(shardFor(resourceUri)));
|
|
102
|
-
return shard[resourceUri];
|
|
103
|
-
},
|
|
104
|
-
async register(resourceUri, workItemKey) {
|
|
105
|
-
const shard = shardFor(resourceUri);
|
|
106
|
-
const file = paths.resourceIndexShardFile(shard);
|
|
107
|
-
await withShardLock(shard, async () => {
|
|
108
|
-
const contents = await readShard(file);
|
|
109
|
-
contents[resourceUri] = workItemKey;
|
|
110
|
-
await writeJsonFile(file, contents);
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
async retract(resourceUri) {
|
|
114
|
-
const shard = shardFor(resourceUri);
|
|
115
|
-
const file = paths.resourceIndexShardFile(shard);
|
|
116
|
-
await withShardLock(shard, async () => {
|
|
117
|
-
const contents = await readShard(file);
|
|
118
|
-
if (!(resourceUri in contents)) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
delete contents[resourceUri];
|
|
122
|
-
await writeJsonFile(file, contents);
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { readJsonFile, writeJsonFile } from '../../lib/json-file.js';
|
|
2
|
-
const EMPTY_LEDGER = {
|
|
3
|
-
lastAppliedTag: null,
|
|
4
|
-
lastKnownGoodTag: null,
|
|
5
|
-
badTags: [],
|
|
6
|
-
};
|
|
7
|
-
export async function readSelfUpdateLedger(path) {
|
|
8
|
-
try {
|
|
9
|
-
return await readJsonFile(path);
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return EMPTY_LEDGER;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export async function writeSelfUpdateLedger(path, ledger) {
|
|
16
|
-
await writeJsonFile(path, ledger);
|
|
17
|
-
}
|