cloving 0.3.20 → 1.0.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/{LICENSE.md → LICENSE} +1 -1
- package/README.md +475 -182
- package/dist/src/authority/budgets.d.ts +12 -0
- package/dist/src/authority/budgets.js +42 -0
- package/dist/src/authority/commands.d.ts +7 -0
- package/dist/src/authority/commands.js +263 -0
- package/dist/src/authority/details.d.ts +28 -0
- package/dist/src/authority/details.js +33 -0
- package/dist/src/authority/dispatch-decision.d.ts +40 -0
- package/dist/src/authority/dispatch-decision.js +47 -0
- package/dist/src/authority/effect-requests.d.ts +2 -0
- package/dist/src/authority/effect-requests.js +139 -0
- package/dist/src/authority/effect-results.d.ts +4 -0
- package/dist/src/authority/effect-results.js +236 -0
- package/dist/src/authority/events.d.ts +2 -0
- package/dist/src/authority/events.js +45 -0
- package/dist/src/authority/gate-reduction.d.ts +8 -0
- package/dist/src/authority/gate-reduction.js +109 -0
- package/dist/src/authority/gates.d.ts +48 -0
- package/dist/src/authority/gates.js +77 -0
- package/dist/src/authority/history-state.d.ts +15 -0
- package/dist/src/authority/history-state.js +61 -0
- package/dist/src/authority/history.d.ts +13 -0
- package/dist/src/authority/history.js +37 -0
- package/dist/src/authority/instants.d.ts +3 -0
- package/dist/src/authority/instants.js +38 -0
- package/dist/src/authority/leases.d.ts +15 -0
- package/dist/src/authority/leases.js +113 -0
- package/dist/src/authority/operations.d.ts +101 -0
- package/dist/src/authority/operations.js +75 -0
- package/dist/src/authority/reconciliation.d.ts +27 -0
- package/dist/src/authority/reconciliation.js +147 -0
- package/dist/src/authority/reducer.d.ts +41 -0
- package/dist/src/authority/reducer.js +139 -0
- package/dist/src/authority/reduction-state.d.ts +36 -0
- package/dist/src/authority/reduction-state.js +68 -0
- package/dist/src/authority/reduction.d.ts +6 -0
- package/dist/src/authority/reduction.js +160 -0
- package/dist/src/authority/status-closure.d.ts +4 -0
- package/dist/src/authority/status-closure.js +57 -0
- package/dist/src/authority/status-effects.d.ts +17 -0
- package/dist/src/authority/status-effects.js +43 -0
- package/dist/src/authority/status-input.d.ts +45 -0
- package/dist/src/authority/status-input.js +9 -0
- package/dist/src/authority/status.d.ts +32 -0
- package/dist/src/authority/status.js +256 -0
- package/dist/src/authority/stop-sequence.d.ts +37 -0
- package/dist/src/authority/stop-sequence.js +91 -0
- package/dist/src/authority/transitions.d.ts +63 -0
- package/dist/src/authority/transitions.js +122 -0
- package/dist/src/broker/actor/adapter-calls.d.ts +13 -0
- package/dist/src/broker/actor/adapter-calls.js +34 -0
- package/dist/src/broker/actor/adapter-outcomes.d.ts +28 -0
- package/dist/src/broker/actor/adapter-outcomes.js +80 -0
- package/dist/src/broker/actor/authority-actor.d.ts +25 -0
- package/dist/src/broker/actor/authority-actor.js +169 -0
- package/dist/src/broker/actor/authority-changes.d.ts +31 -0
- package/dist/src/broker/actor/authority-changes.js +46 -0
- package/dist/src/broker/actor/authority-connection.d.ts +15 -0
- package/dist/src/broker/actor/authority-connection.js +44 -0
- package/dist/src/broker/actor/authority-conversion.d.ts +10 -0
- package/dist/src/broker/actor/authority-conversion.js +72 -0
- package/dist/src/broker/actor/authority-delivery.d.ts +13 -0
- package/dist/src/broker/actor/authority-delivery.js +162 -0
- package/dist/src/broker/actor/authority-logger.d.ts +2 -0
- package/dist/src/broker/actor/authority-logger.js +19 -0
- package/dist/src/broker/actor/authority-policy.d.ts +9 -0
- package/dist/src/broker/actor/authority-policy.js +11 -0
- package/dist/src/broker/actor/authority-queries.d.ts +45 -0
- package/dist/src/broker/actor/authority-queries.js +85 -0
- package/dist/src/broker/actor/authority-receipts.d.ts +28 -0
- package/dist/src/broker/actor/authority-receipts.js +84 -0
- package/dist/src/broker/actor/authority-release.d.ts +13 -0
- package/dist/src/broker/actor/authority-release.js +69 -0
- package/dist/src/broker/actor/authority-runtime.d.ts +60 -0
- package/dist/src/broker/actor/authority-runtime.js +204 -0
- package/dist/src/broker/actor/authority-session.d.ts +65 -0
- package/dist/src/broker/actor/authority-session.js +252 -0
- package/dist/src/broker/actor/authority-settings.d.ts +33 -0
- package/dist/src/broker/actor/authority-settings.js +63 -0
- package/dist/src/broker/actor/authority-upgrades.d.ts +16 -0
- package/dist/src/broker/actor/authority-upgrades.js +12 -0
- package/dist/src/broker/actor/authority-watchdog.d.ts +14 -0
- package/dist/src/broker/actor/authority-watchdog.js +41 -0
- package/dist/src/broker/actor/authority.d.ts +14 -0
- package/dist/src/broker/actor/authority.js +115 -0
- package/dist/src/broker/actor/delivery-intents.d.ts +68 -0
- package/dist/src/broker/actor/delivery-intents.js +77 -0
- package/dist/src/broker/actor/delivery-plan.d.ts +2 -0
- package/dist/src/broker/actor/delivery-plan.js +109 -0
- package/dist/src/broker/actor/delivery-results.d.ts +11 -0
- package/dist/src/broker/actor/delivery-results.js +63 -0
- package/dist/src/broker/actor/effect-delivery.d.ts +19 -0
- package/dist/src/broker/actor/effect-delivery.js +118 -0
- package/dist/src/broker/actor/effect-plan.d.ts +41 -0
- package/dist/src/broker/actor/effect-plan.js +173 -0
- package/dist/src/broker/actor/effect-queries.d.ts +27 -0
- package/dist/src/broker/actor/effect-queries.js +80 -0
- package/dist/src/broker/actor/effect-turn.d.ts +25 -0
- package/dist/src/broker/actor/effect-turn.js +84 -0
- package/dist/src/broker/actor/pin-check.d.ts +6 -0
- package/dist/src/broker/actor/pin-check.js +12 -0
- package/dist/src/broker/actor/runtime-parts.d.ts +23 -0
- package/dist/src/broker/actor/runtime-parts.js +34 -0
- package/dist/src/broker/actor/stop-plan.d.ts +20 -0
- package/dist/src/broker/actor/stop-plan.js +46 -0
- package/dist/src/broker/actor/stop-turn.d.ts +17 -0
- package/dist/src/broker/actor/stop-turn.js +42 -0
- package/dist/src/broker/actor/turn-draft.d.ts +31 -0
- package/dist/src/broker/actor/turn-draft.js +138 -0
- package/dist/src/broker/actor/turn-plan.d.ts +17 -0
- package/dist/src/broker/actor/turn-plan.js +136 -0
- package/dist/src/broker/actor/turn-refusals.d.ts +8 -0
- package/dist/src/broker/actor/turn-refusals.js +35 -0
- package/dist/src/broker/actor/turn-staging.d.ts +78 -0
- package/dist/src/broker/actor/turn-staging.js +34 -0
- package/dist/src/broker/actor/turn-state.d.ts +34 -0
- package/dist/src/broker/actor/turn-state.js +208 -0
- package/dist/src/broker/authority-admission.d.ts +21 -0
- package/dist/src/broker/authority-admission.js +70 -0
- package/dist/src/broker/authority-restore.d.ts +30 -0
- package/dist/src/broker/authority-restore.js +165 -0
- package/dist/src/broker/decision-restore.d.ts +16 -0
- package/dist/src/broker/decision-restore.js +158 -0
- package/dist/src/broker/decision-upgrade.d.ts +3 -0
- package/dist/src/broker/decision-upgrade.js +12 -0
- package/dist/src/broker/effect-restore.d.ts +20 -0
- package/dist/src/broker/effect-restore.js +111 -0
- package/dist/src/broker/effect-upgrade.d.ts +3 -0
- package/dist/src/broker/effect-upgrade.js +9 -0
- package/dist/src/broker/operation-digest.d.ts +1 -0
- package/dist/src/broker/operation-digest.js +4 -0
- package/dist/src/broker/socket-address.d.ts +9 -0
- package/dist/src/broker/socket-address.js +14 -0
- package/dist/src/broker/workflow-pin.d.ts +2 -0
- package/dist/src/broker/workflow-pin.js +5 -0
- package/dist/src/chats/destination.d.ts +4 -0
- package/dist/src/chats/destination.js +94 -0
- package/dist/src/chats/import.d.ts +13 -0
- package/dist/src/chats/import.js +71 -0
- package/dist/src/chats/normalize.d.ts +20 -0
- package/dist/src/chats/normalize.js +139 -0
- package/dist/src/chats/reader.d.ts +15 -0
- package/dist/src/chats/reader.js +87 -0
- package/dist/src/cli/arguments.d.ts +23 -0
- package/dist/src/cli/arguments.js +154 -0
- package/dist/src/cli/client.d.ts +15 -0
- package/dist/src/cli/client.js +122 -0
- package/dist/src/cli/commands.d.ts +14 -0
- package/dist/src/cli/commands.js +253 -0
- package/dist/src/cli/main.d.ts +1 -0
- package/dist/src/cli/main.js +80 -0
- package/dist/src/cli/render.d.ts +8 -0
- package/dist/src/cli/render.js +186 -0
- package/dist/src/cli/runtime-arguments.d.ts +73 -0
- package/dist/src/cli/runtime-arguments.js +248 -0
- package/dist/src/cli/runtime-directory.d.ts +4 -0
- package/dist/src/cli/runtime-directory.js +25 -0
- package/dist/src/cli/toolchain.d.ts +3 -0
- package/dist/src/cli/toolchain.js +74 -0
- package/dist/src/cli/usage.d.ts +4 -0
- package/dist/src/cli/usage.js +124 -0
- package/dist/src/cli/validate.d.ts +38 -0
- package/dist/src/cli/validate.js +116 -0
- package/dist/src/cli/watch-board-view.d.ts +22 -0
- package/dist/src/cli/watch-board-view.js +128 -0
- package/dist/src/cli/watch-board.d.ts +15 -0
- package/dist/src/cli/watch-board.js +174 -0
- package/dist/src/cli/watch-element.d.ts +11 -0
- package/dist/src/cli/watch-element.js +6 -0
- package/dist/src/cli/watch-model.d.ts +29 -0
- package/dist/src/cli/watch-model.js +261 -0
- package/dist/src/cli/watch-navigation.d.ts +9 -0
- package/dist/src/cli/watch-navigation.js +40 -0
- package/dist/src/cli/watch-page.d.ts +1 -0
- package/dist/src/cli/watch-page.js +272 -0
- package/dist/src/cli/watch-paths.d.ts +2 -0
- package/dist/src/cli/watch-paths.js +52 -0
- package/dist/src/cli/watch-phases.d.ts +7 -0
- package/dist/src/cli/watch-phases.js +148 -0
- package/dist/src/cli/watch-reads.d.ts +28 -0
- package/dist/src/cli/watch-reads.js +244 -0
- package/dist/src/cli/watch-render.d.ts +139 -0
- package/dist/src/cli/watch-render.js +95 -0
- package/dist/src/cli/watch-server.d.ts +10 -0
- package/dist/src/cli/watch-server.js +176 -0
- package/dist/src/cli/watch-stream.d.ts +11 -0
- package/dist/src/cli/watch-stream.js +128 -0
- package/dist/src/cli/watch-turn.d.ts +29 -0
- package/dist/src/cli/watch-turn.js +130 -0
- package/dist/src/cli/watch-view.d.ts +39 -0
- package/dist/src/cli/watch-view.js +223 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +62 -0
- package/dist/src/daemon/claude-turn.d.ts +28 -0
- package/dist/src/daemon/claude-turn.js +135 -0
- package/dist/src/daemon/claude-worker.d.ts +26 -0
- package/dist/src/daemon/claude-worker.js +224 -0
- package/dist/src/daemon/codex-stream.d.ts +4 -0
- package/dist/src/daemon/codex-stream.js +113 -0
- package/dist/src/daemon/daemon.d.ts +46 -0
- package/dist/src/daemon/daemon.js +186 -0
- package/dist/src/daemon/delivery-router.d.ts +10 -0
- package/dist/src/daemon/delivery-router.js +34 -0
- package/dist/src/daemon/github-calls.d.ts +29 -0
- package/dist/src/daemon/github-calls.js +127 -0
- package/dist/src/daemon/github-issue-methods.d.ts +3 -0
- package/dist/src/daemon/github-issue-methods.js +99 -0
- package/dist/src/daemon/github-issue-privacy.d.ts +6 -0
- package/dist/src/daemon/github-issue-privacy.js +131 -0
- package/dist/src/daemon/github-merge.d.ts +18 -0
- package/dist/src/daemon/github-merge.js +259 -0
- package/dist/src/daemon/github-methods.d.ts +5 -0
- package/dist/src/daemon/github-methods.js +198 -0
- package/dist/src/daemon/github-operation.d.ts +38 -0
- package/dist/src/daemon/github-operation.js +57 -0
- package/dist/src/daemon/github-worker.d.ts +17 -0
- package/dist/src/daemon/github-worker.js +281 -0
- package/dist/src/daemon/host-environment.d.ts +8 -0
- package/dist/src/daemon/host-environment.js +14 -0
- package/dist/src/daemon/issue-queue.d.ts +9 -0
- package/dist/src/daemon/issue-queue.js +163 -0
- package/dist/src/daemon/notify-message.d.ts +14 -0
- package/dist/src/daemon/notify-message.js +48 -0
- package/dist/src/daemon/notify.d.ts +12 -0
- package/dist/src/daemon/notify.js +161 -0
- package/dist/src/daemon/operation-journal.d.ts +42 -0
- package/dist/src/daemon/operation-journal.js +53 -0
- package/dist/src/daemon/ticket-registration.d.ts +33 -0
- package/dist/src/daemon/ticket-registration.js +177 -0
- package/dist/src/daemon/ticket-source.d.ts +17 -0
- package/dist/src/daemon/ticket-source.js +36 -0
- package/dist/src/daemon/work-tree.d.ts +26 -0
- package/dist/src/daemon/work-tree.js +206 -0
- package/dist/src/effect-authorization.d.ts +21 -0
- package/dist/src/effect-authorization.js +14 -0
- package/dist/src/execution-pin.d.ts +4 -0
- package/dist/src/execution-pin.js +68 -0
- package/dist/src/host/start-delivery.d.ts +41 -0
- package/dist/src/host/start-delivery.js +68 -0
- package/dist/src/host/step-bridge-host.d.ts +79 -0
- package/dist/src/host/step-bridge-host.js +205 -0
- package/dist/src/host/step-claims.d.ts +31 -0
- package/dist/src/host/step-claims.js +85 -0
- package/dist/src/host/world-host.d.ts +21 -0
- package/dist/src/host/world-host.js +51 -0
- package/dist/src/host/world-reconciliation.d.ts +37 -0
- package/dist/src/host/world-reconciliation.js +75 -0
- package/dist/src/host/world-runs.d.ts +14 -0
- package/dist/src/host/world-runs.js +61 -0
- package/dist/src/operation-identity.d.ts +7 -0
- package/dist/src/operation-identity.js +59 -0
- package/dist/src/protocol.d.ts +35 -0
- package/dist/src/protocol.js +64 -0
- package/dist/src/resource-files.d.ts +1 -0
- package/dist/src/resource-files.js +29 -0
- package/dist/src/service/changes.d.ts +11 -0
- package/dist/src/service/changes.js +32 -0
- package/dist/src/service/decision-handler.d.ts +9 -0
- package/dist/src/service/decision-handler.js +233 -0
- package/dist/src/service/event-handler.d.ts +10 -0
- package/dist/src/service/event-handler.js +70 -0
- package/dist/src/service/expiry.d.ts +13 -0
- package/dist/src/service/expiry.js +53 -0
- package/dist/src/service/gateway.d.ts +21 -0
- package/dist/src/service/gateway.js +120 -0
- package/dist/src/service/registry.d.ts +40 -0
- package/dist/src/service/registry.js +13 -0
- package/dist/src/service/replies.d.ts +26 -0
- package/dist/src/service/replies.js +56 -0
- package/dist/src/service/run-handlers.d.ts +4 -0
- package/dist/src/service/run-handlers.js +271 -0
- package/dist/src/service/service.d.ts +58 -0
- package/dist/src/service/service.js +212 -0
- package/dist/src/service/submission-handler.d.ts +4 -0
- package/dist/src/service/submission-handler.js +206 -0
- package/dist/src/service/transport.d.ts +16 -0
- package/dist/src/service/transport.js +141 -0
- package/dist/src/service/worker-port.d.ts +85 -0
- package/dist/src/service/worker-port.js +126 -0
- package/dist/src/step-bridge.d.ts +57 -0
- package/dist/src/step-bridge.js +4 -0
- package/dist/src/steps/decision-gate.d.ts +2 -0
- package/dist/src/steps/decision-gate.js +8 -0
- package/dist/src/steps/load-cycle.d.ts +10 -0
- package/dist/src/steps/load-cycle.js +11 -0
- package/dist/src/steps/protected-effect.d.ts +2 -0
- package/dist/src/steps/protected-effect.js +8 -0
- package/dist/src/storage/decision-rows.d.ts +54 -0
- package/dist/src/storage/decision-rows.js +72 -0
- package/dist/src/storage/decision-snapshots.d.ts +17 -0
- package/dist/src/storage/decision-snapshots.js +25 -0
- package/dist/src/storage/domain-changes.d.ts +48 -0
- package/dist/src/storage/domain-changes.js +213 -0
- package/dist/src/storage/domain-rows.d.ts +85 -0
- package/dist/src/storage/domain-rows.js +129 -0
- package/dist/src/storage/domain-schema.d.ts +32 -0
- package/dist/src/storage/domain-schema.js +193 -0
- package/dist/src/storage/effect-changes.d.ts +5 -0
- package/dist/src/storage/effect-changes.js +105 -0
- package/dist/src/storage/effect-rows.d.ts +67 -0
- package/dist/src/storage/effect-rows.js +74 -0
- package/dist/src/storage/effect-schema.d.ts +1 -0
- package/dist/src/storage/effect-schema.js +59 -0
- package/dist/src/storage/statements.d.ts +9 -0
- package/dist/src/storage/statements.js +8 -0
- package/dist/src/submission.d.ts +42 -0
- package/dist/src/submission.js +71 -0
- package/dist/src/turn-profile.d.ts +13 -0
- package/dist/src/turn-profile.js +100 -0
- package/dist/src/workflow-admission.d.ts +45 -0
- package/dist/src/workflow-admission.js +151 -0
- package/dist/src/workflow-contracts.d.ts +27 -0
- package/dist/src/workflow-contracts.js +88 -0
- package/dist/src/workflow-declaration.d.ts +11 -0
- package/dist/src/workflow-declaration.js +57 -0
- package/dist/src/workflow-resources.d.ts +8 -0
- package/dist/src/workflow-resources.js +14 -0
- package/dist/src/workflows.d.ts +5 -0
- package/dist/src/workflows.js +3 -0
- package/dist/tools/compile-workflows.d.ts +1 -0
- package/dist/tools/compile-workflows.js +33 -0
- package/dist/tools/self-host-processes.d.ts +10 -0
- package/dist/tools/self-host-processes.js +151 -0
- package/dist/tools/self-host-workflows.d.ts +15 -0
- package/dist/tools/self-host-workflows.js +78 -0
- package/dist/tools/self-host.d.ts +1 -0
- package/dist/tools/self-host.js +261 -0
- package/dist/tools/self-update-host.d.ts +6 -0
- package/dist/tools/self-update-host.js +41 -0
- package/dist/tools/self-update.d.ts +10 -0
- package/dist/tools/self-update.js +105 -0
- package/dist/tools/workflow-manifest.d.ts +3 -0
- package/dist/tools/workflow-manifest.js +34 -0
- package/dist/workflows/develop-prd.d.ts +7 -0
- package/dist/workflows/develop-prd.js +97 -0
- package/dist/workflows/develop-ticket.d.ts +15 -0
- package/dist/workflows/develop-ticket.js +301 -0
- package/dist/workflows/issue-labels.d.ts +14 -0
- package/dist/workflows/issue-labels.js +36 -0
- package/package.json +82 -75
- package/dist/abstract_gpt/index.js +0 -55
- package/dist/cloving_gpt/adapters/Adapter.js +0 -2
- package/dist/cloving_gpt/adapters/azureopenai.js +0 -69
- package/dist/cloving_gpt/adapters/claude.js +0 -128
- package/dist/cloving_gpt/adapters/gemini.js +0 -135
- package/dist/cloving_gpt/adapters/gpt4all.js +0 -29
- package/dist/cloving_gpt/adapters/index.js +0 -2
- package/dist/cloving_gpt/adapters/mistral.js +0 -128
- package/dist/cloving_gpt/adapters/ollama.js +0 -128
- package/dist/cloving_gpt/adapters/openai.js +0 -100
- package/dist/cloving_gpt/index.js +0 -192
- package/dist/commands/analyze.js +0 -47
- package/dist/commands/chat.js +0 -14
- package/dist/commands/check.js +0 -7
- package/dist/commands/commit.js +0 -44
- package/dist/commands/config.js +0 -167
- package/dist/commands/describe.js +0 -235
- package/dist/commands/generate/code.js +0 -21
- package/dist/commands/generate/commit.js +0 -11
- package/dist/commands/generate/context.js +0 -82
- package/dist/commands/generate/docs.js +0 -11
- package/dist/commands/generate/documentation.js +0 -11
- package/dist/commands/generate/fizzbuzz.js +0 -35
- package/dist/commands/generate/init.js +0 -15
- package/dist/commands/generate/review.js +0 -11
- package/dist/commands/generate/sh.js +0 -95
- package/dist/commands/generate/shell.js +0 -11
- package/dist/commands/generate/unit_tests.js +0 -11
- package/dist/commands/init.js +0 -13
- package/dist/commands/models.js +0 -22
- package/dist/commands/project/build.js +0 -88
- package/dist/commands/project/complete.js +0 -12
- package/dist/commands/project/init.js +0 -82
- package/dist/commands/project/plan.js +0 -108
- package/dist/commands/proxy.js +0 -11
- package/dist/commands/review.js +0 -50
- package/dist/commands/tokens.js +0 -75
- package/dist/commands/unit_tests.js +0 -150
- package/dist/commands/update.js +0 -7
- package/dist/file2.js +0 -4
- package/dist/index.js +0 -136
- package/dist/managers/BlockManager.js +0 -120
- package/dist/managers/ChatManager.js +0 -653
- package/dist/managers/ChunkManager.js +0 -32
- package/dist/managers/CodeManager.js +0 -185
- package/dist/managers/CommitManager.js +0 -78
- package/dist/managers/DocsManager.js +0 -88
- package/dist/managers/DocumentationManager.js +0 -114
- package/dist/managers/InitManager.js +0 -230
- package/dist/managers/ProxyManager.js +0 -210
- package/dist/managers/ReviewManager.js +0 -131
- package/dist/managers/ShellManager.js +0 -163
- package/dist/managers/StreamManager.js +0 -308
- package/dist/managers/UnitTestManager.js +0 -243
- package/dist/managers/src/managers/ProxyManager.js +0 -1
- package/dist/newfile.js +0 -2
- package/dist/package.json +0 -86
- package/dist/utils/command_utils.js +0 -384
- package/dist/utils/config_utils.js +0 -249
- package/dist/utils/gitUtils.js +0 -42
- package/dist/utils/git_utils.js +0 -217
- package/dist/utils/modelUtils.js +0 -7
- package/dist/utils/model_utils.js +0 -7
- package/dist/utils/prompt_utils.js +0 -333
- package/dist/utils/prompts/CODEGEN_COULDNT_APPLY.md +0 -5
- package/dist/utils/prompts/CODEGEN_EXAMPLES.md +0 -82
- package/dist/utils/prompts/CODEGEN_INSTRUCTIONS.md +0 -43
- package/dist/utils/prompts/DOCS_INSTRUCTIONS.md +0 -9
- package/dist/utils/prompts/INIT_INSTRUCTIONS.md +0 -132
- package/dist/utils/prompts/REVIEW_INSTRUCTIONS.md +0 -49
- package/dist/utils/prompts/SHELL_INSTRUCTIONS.md +0 -15
- package/dist/utils/prompts/SPECIAL_FILES.md +0 -66
- package/dist/utils/prompts/index.js +0 -27
- package/dist/utils/string_utils.js +0 -505
- package/dist/utils/types.js +0 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type GateState } from "../../authority/gates.ts";
|
|
2
|
+
import { type AuthorityState, type EffectIntent } from "../../authority/reducer.ts";
|
|
3
|
+
import type { ExecutionManifest } from "../../workflow-admission.ts";
|
|
4
|
+
export interface DeliveryDecision {
|
|
5
|
+
readonly gateId: string;
|
|
6
|
+
readonly decision: string;
|
|
7
|
+
readonly answer: string | null;
|
|
8
|
+
}
|
|
9
|
+
export type Purpose = "dispatch" | "reconcile" | "stop";
|
|
10
|
+
export interface EffectArguments {
|
|
11
|
+
readonly leaseGeneration: number;
|
|
12
|
+
readonly capability: string;
|
|
13
|
+
readonly method: string;
|
|
14
|
+
readonly target: string;
|
|
15
|
+
readonly payload: string;
|
|
16
|
+
}
|
|
17
|
+
export interface DeliveryIntent extends EffectIntent, Partial<DeliveryDecision>, Partial<EffectArguments> {
|
|
18
|
+
readonly workflow: string;
|
|
19
|
+
readonly inputDigest: string;
|
|
20
|
+
readonly purpose: Purpose;
|
|
21
|
+
}
|
|
22
|
+
export type ProtectedIntent = DeliveryIntent & EffectArguments;
|
|
23
|
+
export type Undigested = Omit<DeliveryIntent, "inputDigest" | "purpose">;
|
|
24
|
+
export type Reconciliation = {
|
|
25
|
+
readonly kind: "accepted";
|
|
26
|
+
readonly receipt: string;
|
|
27
|
+
readonly worker?: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: "absent";
|
|
30
|
+
};
|
|
31
|
+
export type AdapterOutcome = Reconciliation | {
|
|
32
|
+
readonly kind: "completed";
|
|
33
|
+
readonly receipt: string;
|
|
34
|
+
readonly worker?: string;
|
|
35
|
+
readonly result: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "failed";
|
|
38
|
+
readonly receipt?: string;
|
|
39
|
+
readonly reason: string;
|
|
40
|
+
readonly result?: string;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: "stopped";
|
|
43
|
+
readonly receipt?: string;
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: "unknown";
|
|
46
|
+
readonly evidence?: string;
|
|
47
|
+
};
|
|
48
|
+
export interface Delivery {
|
|
49
|
+
readonly deliver: (intent: DeliveryIntent, signal: AbortSignal) => Promise<{
|
|
50
|
+
readonly receipt: string;
|
|
51
|
+
readonly worker?: string;
|
|
52
|
+
} | AdapterOutcome>;
|
|
53
|
+
readonly reconcile: (intent: DeliveryIntent, signal: AbortSignal) => Promise<AdapterOutcome>;
|
|
54
|
+
readonly stop?: (intent: DeliveryIntent, signal: AbortSignal) => Promise<AdapterOutcome>;
|
|
55
|
+
}
|
|
56
|
+
export type AvailableManifest = (pinned: ExecutionManifest) => ExecutionManifest | undefined;
|
|
57
|
+
export declare function intentDigest(intent: Undigested): string;
|
|
58
|
+
export declare function deliveryIntent(intent: Undigested): DeliveryIntent;
|
|
59
|
+
export declare function protectedIntent(state: AuthorityState, attempt: {
|
|
60
|
+
readonly intent: EffectIntent;
|
|
61
|
+
readonly purpose: Purpose;
|
|
62
|
+
}): readonly DeliveryIntent[];
|
|
63
|
+
export declare function gateDecision(gate: GateState | undefined): DeliveryDecision | null;
|
|
64
|
+
export declare function observingIntent(state: AuthorityState, attempt: {
|
|
65
|
+
readonly intent: EffectIntent;
|
|
66
|
+
readonly purpose: Purpose;
|
|
67
|
+
}): DeliveryIntent;
|
|
68
|
+
export declare function stageable(state: AuthorityState, held: ReadonlySet<string>): readonly DeliveryIntent[];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { continues, isSettled } from "../../authority/gates.js";
|
|
3
|
+
import { eligibleIntents, } from "../../authority/reducer.js";
|
|
4
|
+
import { gateContinuation } from "../../authority/reduction.js";
|
|
5
|
+
export function intentDigest(intent) {
|
|
6
|
+
const base = [intent.kind, intent.runId, intent.operationId, intent.workflow];
|
|
7
|
+
const bound = intent.gateId === undefined
|
|
8
|
+
? base
|
|
9
|
+
: [
|
|
10
|
+
...base,
|
|
11
|
+
intent.gateId,
|
|
12
|
+
intent.decision ?? null,
|
|
13
|
+
intent.answer ?? null,
|
|
14
|
+
];
|
|
15
|
+
return createHash("sha256").update(JSON.stringify(bound)).digest("hex");
|
|
16
|
+
}
|
|
17
|
+
export function deliveryIntent(intent) {
|
|
18
|
+
return { ...intent, purpose: "dispatch", inputDigest: intentDigest(intent) };
|
|
19
|
+
}
|
|
20
|
+
export function protectedIntent(state, attempt) {
|
|
21
|
+
const { intent, purpose } = attempt;
|
|
22
|
+
const workflow = workflowOf(state, intent.runId);
|
|
23
|
+
return Object.values(state.effects.operations)
|
|
24
|
+
.filter((operation) => operation.operationId === intent.operationId)
|
|
25
|
+
.flatMap((operation) => Object.values(state.effects.leases)
|
|
26
|
+
.filter((lease) => lease.resourceKey === operation.leaseKey)
|
|
27
|
+
.map((lease) => ({
|
|
28
|
+
...intent,
|
|
29
|
+
workflow,
|
|
30
|
+
purpose,
|
|
31
|
+
inputDigest: operation.inputDigest,
|
|
32
|
+
leaseGeneration: lease.generation,
|
|
33
|
+
capability: operation.capability,
|
|
34
|
+
method: operation.method,
|
|
35
|
+
target: operation.target,
|
|
36
|
+
payload: operation.payload,
|
|
37
|
+
})));
|
|
38
|
+
}
|
|
39
|
+
export function gateDecision(gate) {
|
|
40
|
+
if (gate === undefined || gate.kind === "untyped" || !continues(gate))
|
|
41
|
+
return null;
|
|
42
|
+
return {
|
|
43
|
+
gateId: gate.gateId,
|
|
44
|
+
decision: gate.outcome.decision,
|
|
45
|
+
answer: gate.outcome.answer,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function workflowOf(state, runId) {
|
|
49
|
+
return state.runs[runId]?.workflow ?? "";
|
|
50
|
+
}
|
|
51
|
+
function decisionOf(state, intent) {
|
|
52
|
+
return gateDecision(Object.values(state.gates).find((gate) => gate.runId === intent.runId &&
|
|
53
|
+
isSettled(gate) &&
|
|
54
|
+
gateContinuation(gate).operationId === intent.operationId));
|
|
55
|
+
}
|
|
56
|
+
export function observingIntent(state, attempt) {
|
|
57
|
+
const { intent, purpose } = attempt;
|
|
58
|
+
const undigested = {
|
|
59
|
+
...intent,
|
|
60
|
+
workflow: workflowOf(state, intent.runId),
|
|
61
|
+
...decisionOf(state, intent),
|
|
62
|
+
};
|
|
63
|
+
return { ...undigested, purpose, inputDigest: intentDigest(undigested) };
|
|
64
|
+
}
|
|
65
|
+
export function stageable(state, held) {
|
|
66
|
+
return eligibleIntents(state)
|
|
67
|
+
.filter((intent) => !held.has(intent.operationId))
|
|
68
|
+
.flatMap((intent) => intent.kind === "protected-effect"
|
|
69
|
+
? protectedIntent(state, { intent, purpose: "dispatch" })
|
|
70
|
+
: [
|
|
71
|
+
deliveryIntent({
|
|
72
|
+
...intent,
|
|
73
|
+
workflow: workflowOf(state, intent.runId),
|
|
74
|
+
...decisionOf(state, intent),
|
|
75
|
+
}),
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { execute } from "../../authority/reducer.js";
|
|
2
|
+
import { operationDigest } from "../operation-digest.js";
|
|
3
|
+
import { followUps, outcomeCommand, resultDocuments } from "./effect-plan.js";
|
|
4
|
+
import { draft, merged, unchanged, } from "./turn-draft.js";
|
|
5
|
+
import { followUp, openAttempts, staged } from "./turn-staging.js";
|
|
6
|
+
function closedAs(outcome) {
|
|
7
|
+
return outcome === "thrown" ? "failed" : outcome;
|
|
8
|
+
}
|
|
9
|
+
function heldAfter(closing, result) {
|
|
10
|
+
const { turn, delivery, outcome } = closing;
|
|
11
|
+
const settled = result !== undefined || closing.retried;
|
|
12
|
+
if (!settled && quiet.includes(outcome))
|
|
13
|
+
return turn.held;
|
|
14
|
+
return new Set([...turn.held].filter((operation) => operation !== delivery.operationId));
|
|
15
|
+
}
|
|
16
|
+
function blockedAfter(closing) {
|
|
17
|
+
const { turn, delivery, outcome } = closing;
|
|
18
|
+
if (outcome !== "blocked")
|
|
19
|
+
return turn.blocked;
|
|
20
|
+
return new Map([...turn.blocked, [delivery.operationId, delivery.effectId]]);
|
|
21
|
+
}
|
|
22
|
+
function closedDraft(closing, result) {
|
|
23
|
+
const { turn, delivery, outcome } = closing;
|
|
24
|
+
const closed = [
|
|
25
|
+
{
|
|
26
|
+
effect_id: delivery.effectId,
|
|
27
|
+
outcome: closedAs(outcome),
|
|
28
|
+
receipt: delivery.receipt,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
if (result === undefined)
|
|
32
|
+
return unchanged(turn.state, closed);
|
|
33
|
+
return draft(result, {
|
|
34
|
+
before: turn.state,
|
|
35
|
+
definitions: [],
|
|
36
|
+
closed,
|
|
37
|
+
documents: resultDocuments(delivery),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function planDelivery(planning) {
|
|
41
|
+
const { turn, delivery, epoch } = planning;
|
|
42
|
+
const outcome = delivery.epoch === epoch ? delivery.outcome : "stale-epoch";
|
|
43
|
+
const closing = {
|
|
44
|
+
turn,
|
|
45
|
+
delivery,
|
|
46
|
+
outcome,
|
|
47
|
+
retried: retriable.includes(outcome) &&
|
|
48
|
+
delivery.intent !== "protected-effect" &&
|
|
49
|
+
delivery.attempts < planning.effects.deliveryAttempts,
|
|
50
|
+
};
|
|
51
|
+
const result = recorded(turn.state, { ...delivery, outcome });
|
|
52
|
+
const base = result?.state ?? turn.state;
|
|
53
|
+
const steps = followUps(base, {
|
|
54
|
+
recordedAt: delivery.recordedAt,
|
|
55
|
+
effects: planning.effects,
|
|
56
|
+
blocked: blockedAfter(closing),
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
kind: "commit",
|
|
60
|
+
receipt: { kind: outcome },
|
|
61
|
+
change: merged(closedDraft(closing, result), steps.map(followUp)),
|
|
62
|
+
stage: staged(steps.at(-1)?.result.state ?? base, {
|
|
63
|
+
held: heldAfter(closing, result),
|
|
64
|
+
results: [
|
|
65
|
+
...(result === undefined ? [] : [result]),
|
|
66
|
+
...steps.map((step) => step.result),
|
|
67
|
+
],
|
|
68
|
+
closed: [delivery.operationId],
|
|
69
|
+
open: openAttempts(turn, [delivery.operationId]),
|
|
70
|
+
stop: {
|
|
71
|
+
...planning,
|
|
72
|
+
rows: [{ effectId: delivery.effectId, outcome: closedAs(outcome) }],
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const quiet = ["thrown", "failed", "blocked"];
|
|
78
|
+
const retriable = ["thrown", "failed"];
|
|
79
|
+
function recorded(state, delivery) {
|
|
80
|
+
const command = delivery.intent === "protected-effect"
|
|
81
|
+
? outcomeCommand({
|
|
82
|
+
...delivery,
|
|
83
|
+
storedReceipt: state.effects.operations[delivery.operationId]?.receipt ?? null,
|
|
84
|
+
})
|
|
85
|
+
: dispatchCommand(delivery);
|
|
86
|
+
if (command === undefined)
|
|
87
|
+
return undefined;
|
|
88
|
+
const result = execute(state, { command, recordedAt: delivery.recordedAt });
|
|
89
|
+
return result.kind === "accepted" ? result : undefined;
|
|
90
|
+
}
|
|
91
|
+
const runCommands = {
|
|
92
|
+
sent: (delivery) => ({
|
|
93
|
+
kind: "record-dispatch",
|
|
94
|
+
commandId: `dispatch:${operationDigest(delivery.operationId)}`,
|
|
95
|
+
runId: delivery.runId,
|
|
96
|
+
operationId: delivery.operationId,
|
|
97
|
+
receipt: delivery.receipt,
|
|
98
|
+
}),
|
|
99
|
+
stopped: (delivery) => ({
|
|
100
|
+
kind: "record-outcome",
|
|
101
|
+
commandId: `outcome:${delivery.effectId}`,
|
|
102
|
+
runId: delivery.runId,
|
|
103
|
+
operationId: delivery.operationId,
|
|
104
|
+
outcome: "stopped",
|
|
105
|
+
}),
|
|
106
|
+
};
|
|
107
|
+
function dispatchCommand(delivery) {
|
|
108
|
+
return runCommands[delivery.outcome]?.(delivery);
|
|
109
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JsonObject } from "solid-objects";
|
|
2
|
+
import type { DeliveryResult } from "./turn-plan.ts";
|
|
3
|
+
export type Outcome = Omit<DeliveryResult, "runId" | "intent" | "leaseGeneration" | "purpose" | "attempts"> & {
|
|
4
|
+
readonly inputDigest: string;
|
|
5
|
+
};
|
|
6
|
+
export interface Present {
|
|
7
|
+
readonly epoch: number;
|
|
8
|
+
readonly recordedAt: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function thrownOutcome(payload: JsonObject, present: Present): Outcome;
|
|
11
|
+
export declare function completedOutcome(payload: JsonObject, present: Present): Outcome;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { integer, optionalText, text } from "../../storage/domain-rows.js";
|
|
2
|
+
function stated(result, name) {
|
|
3
|
+
const value = Reflect.get(Object(result), name);
|
|
4
|
+
return typeof value === "string" ? value : null;
|
|
5
|
+
}
|
|
6
|
+
const resultKinds = [
|
|
7
|
+
"sent",
|
|
8
|
+
"withheld",
|
|
9
|
+
"blocked",
|
|
10
|
+
"accepted",
|
|
11
|
+
"refused",
|
|
12
|
+
"completed",
|
|
13
|
+
"failed",
|
|
14
|
+
"stopped",
|
|
15
|
+
"unknown",
|
|
16
|
+
"absent",
|
|
17
|
+
];
|
|
18
|
+
function resultKind(kind) {
|
|
19
|
+
const known = resultKinds.find((candidate) => candidate === kind);
|
|
20
|
+
if (known === undefined)
|
|
21
|
+
throw new Error(`invalid-delivery-result: ${kind}`);
|
|
22
|
+
return known;
|
|
23
|
+
}
|
|
24
|
+
function callback(payload) {
|
|
25
|
+
const intent = payload["arguments"];
|
|
26
|
+
return {
|
|
27
|
+
effectId: text(payload, "effectId"),
|
|
28
|
+
operationId: text(intent, "operationId"),
|
|
29
|
+
inputDigest: text(intent, "inputDigest"),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function thrownOutcome(payload, present) {
|
|
33
|
+
return {
|
|
34
|
+
...callback(payload),
|
|
35
|
+
outcome: "thrown",
|
|
36
|
+
receipt: null,
|
|
37
|
+
worker: null,
|
|
38
|
+
result: null,
|
|
39
|
+
reason: null,
|
|
40
|
+
...present,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function readOutcome(payload) {
|
|
44
|
+
const result = payload["result"];
|
|
45
|
+
return {
|
|
46
|
+
...callback(payload),
|
|
47
|
+
outcome: resultKind(text(result, "kind")),
|
|
48
|
+
receipt: optionalText(result, "receipt"),
|
|
49
|
+
worker: stated(result, "worker"),
|
|
50
|
+
result: stated(result, "result"),
|
|
51
|
+
reason: stated(result, "reason"),
|
|
52
|
+
epoch: integer(result, "epoch"),
|
|
53
|
+
recordedAt: text(result, "recordedAt"),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function completedOutcome(payload, present) {
|
|
57
|
+
try {
|
|
58
|
+
return readOutcome(payload);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return thrownOutcome(payload, present);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Database, JsonObject } from "solid-objects";
|
|
2
|
+
import type { AdapterCalls } from "./adapter-calls.ts";
|
|
3
|
+
import type { EffectSettings } from "./authority-settings.ts";
|
|
4
|
+
import type { AvailableManifest, Delivery, EffectArguments, ProtectedIntent } from "./delivery-intents.ts";
|
|
5
|
+
export interface EffectDelivery {
|
|
6
|
+
readonly reader: Database;
|
|
7
|
+
readonly delivery: Delivery;
|
|
8
|
+
readonly available: AvailableManifest | undefined;
|
|
9
|
+
readonly epoch: () => number;
|
|
10
|
+
readonly clock: () => string;
|
|
11
|
+
readonly calls: AdapterCalls;
|
|
12
|
+
readonly effects: EffectSettings;
|
|
13
|
+
}
|
|
14
|
+
export interface Attempt {
|
|
15
|
+
readonly intent: ProtectedIntent;
|
|
16
|
+
readonly effectId: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function deliverEffect(parts: EffectDelivery, attempt: Attempt): Promise<JsonObject>;
|
|
19
|
+
export declare function protectedArguments(value: JsonObject): EffectArguments;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { dispatchDecision, } from "../../authority/dispatch-decision.js";
|
|
2
|
+
import { integer, optionalInteger, optionalText, text, } from "../../storage/domain-rows.js";
|
|
3
|
+
import { budgetRow } from "../../storage/effect-rows.js";
|
|
4
|
+
import { effectInputDigest, storedBudget } from "../effect-restore.js";
|
|
5
|
+
import { settlement } from "./adapter-outcomes.js";
|
|
6
|
+
import { pinned } from "./pin-check.js";
|
|
7
|
+
const absent = {
|
|
8
|
+
attempt: undefined,
|
|
9
|
+
released: false,
|
|
10
|
+
runStatus: "",
|
|
11
|
+
workflow: "",
|
|
12
|
+
pinned: false,
|
|
13
|
+
operation: undefined,
|
|
14
|
+
lease: undefined,
|
|
15
|
+
budget: undefined,
|
|
16
|
+
};
|
|
17
|
+
async function dispatchRead(connection, attempt) {
|
|
18
|
+
const row = await connection.get("SELECT d.outcome, d.input_digest, a.lease_generation, o.released_sequence, r.status, r.workflow, p.status AS operation_status, p.capability, p.units, l.operation_id AS lease_owner, l.generation, l.expires_at, l.state AS lease_state, b.run_id, b.effect_limit, b.spent, b.capabilities, b.exhausted_sequence FROM deliveries d JOIN outbox o ON o.operation_id = d.operation_id JOIN runs r ON r.run_id = o.run_id JOIN dispatch_attempts a ON a.effect_id = d.effect_id JOIN operations p ON p.operation_id = d.operation_id JOIN leases l ON l.resource_key = p.lease_key JOIN run_budgets b ON b.run_id = o.run_id WHERE d.effect_id = ? AND d.operation_id = ?", [attempt.effectId, attempt.intent.operationId]);
|
|
19
|
+
if (row === undefined)
|
|
20
|
+
return absent;
|
|
21
|
+
const workflow = text(row, "workflow");
|
|
22
|
+
return {
|
|
23
|
+
attempt: {
|
|
24
|
+
outcome: optionalText(row, "outcome"),
|
|
25
|
+
inputDigest: text(row, "input_digest"),
|
|
26
|
+
leaseGeneration: optionalInteger(row, "lease_generation"),
|
|
27
|
+
},
|
|
28
|
+
released: optionalInteger(row, "released_sequence") !== null,
|
|
29
|
+
runStatus: text(row, "status"),
|
|
30
|
+
workflow,
|
|
31
|
+
pinned: await pinned(connection, {
|
|
32
|
+
workflow,
|
|
33
|
+
available: attempt.available,
|
|
34
|
+
}),
|
|
35
|
+
operation: {
|
|
36
|
+
status: text(row, "operation_status"),
|
|
37
|
+
capability: text(row, "capability"),
|
|
38
|
+
units: integer(row, "units"),
|
|
39
|
+
},
|
|
40
|
+
budget: storedBudget(budgetRow(row)),
|
|
41
|
+
lease: {
|
|
42
|
+
operationId: text(row, "lease_owner"),
|
|
43
|
+
generation: integer(row, "generation"),
|
|
44
|
+
expiresAt: text(row, "expires_at"),
|
|
45
|
+
state: text(row, "lease_state"),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async function called(parts, call) {
|
|
50
|
+
const { intent, name } = call;
|
|
51
|
+
const adapterCall = parts.delivery[name]?.bind(parts.delivery);
|
|
52
|
+
if (adapterCall === undefined)
|
|
53
|
+
return { kind: "unknown", reason: "stop-not-supported" };
|
|
54
|
+
return settlement(await parts.calls.call(intent.operationId, (signal) => adapterCall(intent, signal)), parts.effects.resultBytes);
|
|
55
|
+
}
|
|
56
|
+
const confirmations = ["stopped", "completed", "failed"];
|
|
57
|
+
async function stopRequested(parts, intent) {
|
|
58
|
+
const stopped = await called(parts, { intent, name: "stop" });
|
|
59
|
+
return confirmations.includes(stopped.kind)
|
|
60
|
+
? stopped
|
|
61
|
+
: called(parts, { intent, name: "reconcile" });
|
|
62
|
+
}
|
|
63
|
+
function decided(parts, attempt) {
|
|
64
|
+
const { intent } = attempt;
|
|
65
|
+
const now = parts.clock();
|
|
66
|
+
return parts.reader.connection(async (connection) => dispatchDecision(await dispatchRead(connection, {
|
|
67
|
+
...attempt,
|
|
68
|
+
available: parts.available,
|
|
69
|
+
}), {
|
|
70
|
+
intent: { ...intent, computedDigest: effectInputDigest(intent) },
|
|
71
|
+
now,
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
const withheld = { kind: "withheld" };
|
|
75
|
+
function unsent(decision) {
|
|
76
|
+
return decision === "stale" ? withheld : { kind: decision };
|
|
77
|
+
}
|
|
78
|
+
async function attempted(parts, attempt) {
|
|
79
|
+
const { intent } = attempt;
|
|
80
|
+
const first = await decided(parts, attempt);
|
|
81
|
+
if (first === "stale")
|
|
82
|
+
return withheld;
|
|
83
|
+
if (intent.purpose === "stop")
|
|
84
|
+
return stopRequested(parts, intent);
|
|
85
|
+
const known = await called(parts, { intent, name: "reconcile" });
|
|
86
|
+
if (known.kind !== "absent" || intent.purpose === "reconcile")
|
|
87
|
+
return known;
|
|
88
|
+
if (first !== "send")
|
|
89
|
+
return unsent(first);
|
|
90
|
+
const second = await decided(parts, attempt);
|
|
91
|
+
if (second !== "send")
|
|
92
|
+
return unsent(second);
|
|
93
|
+
const sent = await called(parts, { intent, name: "deliver" });
|
|
94
|
+
return sent.kind === "absent"
|
|
95
|
+
? { kind: "unknown", reason: "invalid-adapter-reply" }
|
|
96
|
+
: sent;
|
|
97
|
+
}
|
|
98
|
+
export async function deliverEffect(parts, attempt) {
|
|
99
|
+
const result = await attempted(parts, attempt);
|
|
100
|
+
return {
|
|
101
|
+
receipt: null,
|
|
102
|
+
worker: null,
|
|
103
|
+
result: null,
|
|
104
|
+
reason: null,
|
|
105
|
+
...result,
|
|
106
|
+
epoch: parts.epoch(),
|
|
107
|
+
recordedAt: parts.clock(),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export function protectedArguments(value) {
|
|
111
|
+
return {
|
|
112
|
+
leaseGeneration: integer(value, "leaseGeneration"),
|
|
113
|
+
capability: text(value, "capability"),
|
|
114
|
+
method: text(value, "method"),
|
|
115
|
+
target: text(value, "target"),
|
|
116
|
+
payload: text(value, "payload"),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type AuthorityState } from "../../authority/reducer.ts";
|
|
2
|
+
import type { EffectSettings } from "./authority-settings.ts";
|
|
3
|
+
import { type DeliveryIntent } from "./delivery-intents.ts";
|
|
4
|
+
import type { Accepted } from "./turn-draft.ts";
|
|
5
|
+
export interface Step {
|
|
6
|
+
readonly result: Accepted;
|
|
7
|
+
readonly before: AuthorityState;
|
|
8
|
+
}
|
|
9
|
+
export interface Promotion {
|
|
10
|
+
readonly recordedAt: string;
|
|
11
|
+
readonly effects: EffectSettings;
|
|
12
|
+
}
|
|
13
|
+
type Fields = Readonly<Record<string, unknown>>;
|
|
14
|
+
export declare function promoted(state: AuthorityState, promotion: Promotion): readonly Step[];
|
|
15
|
+
export interface FollowUp extends Promotion {
|
|
16
|
+
readonly blocked: ReadonlyMap<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export declare function followUps(state: AuthorityState, followUp: FollowUp): readonly Step[];
|
|
19
|
+
export interface ClosedAttempt {
|
|
20
|
+
readonly effectId: string;
|
|
21
|
+
readonly operationId: string;
|
|
22
|
+
readonly runId: string;
|
|
23
|
+
readonly leaseGeneration: number | null;
|
|
24
|
+
readonly purpose: string;
|
|
25
|
+
readonly outcome: string;
|
|
26
|
+
readonly receipt: string | null;
|
|
27
|
+
readonly worker: string | null;
|
|
28
|
+
readonly result: string | null;
|
|
29
|
+
readonly reason: string | null;
|
|
30
|
+
readonly storedReceipt: string | null;
|
|
31
|
+
}
|
|
32
|
+
export declare function outcomeCommand(attempt: ClosedAttempt): Fields | undefined;
|
|
33
|
+
export declare function resultDocuments(attempt: Pick<ClosedAttempt, "outcome" | "result">): readonly Fields[];
|
|
34
|
+
export interface Reconciling {
|
|
35
|
+
readonly results: readonly Accepted[];
|
|
36
|
+
readonly closed: readonly string[];
|
|
37
|
+
readonly open: ReadonlySet<string>;
|
|
38
|
+
}
|
|
39
|
+
export declare function rejectedReports(results: readonly Accepted[]): ReadonlySet<string>;
|
|
40
|
+
export declare function reconciliations(state: AuthorityState, reconciling: Reconciling): readonly DeliveryIntent[];
|
|
41
|
+
export {};
|