@leitwerk-dev/server 0.3.0 → 0.4.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/{app-WfwKzrVk.d.ts → app-CsuxFZT5.d.ts} +332 -111
- package/dist/app-JM4CBTND.js +8 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/auth/fastify-auth.d.ts +9 -0
- package/dist/auth/fastify-auth.d.ts.map +1 -1
- package/dist/{chunk-LK3RO6C7.js → chunk-FPMDWQF7.js} +3050 -645
- package/dist/chunk-FPMDWQF7.js.map +1 -0
- package/dist/{chunk-KIOQNNG6.js → chunk-MBHRCQFE.js} +2781 -1822
- package/dist/chunk-MBHRCQFE.js.map +1 -0
- package/dist/config/config-loader.d.ts +1 -1
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-types.d.ts +14 -1
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/config/kubernetes-docker-isolation.d.ts +7 -0
- package/dist/config/kubernetes-docker-isolation.d.ts.map +1 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/execution-inspection-repo.d.ts +15 -0
- package/dist/db/execution-inspection-repo.d.ts.map +1 -0
- package/dist/db/history-window.d.ts +11 -0
- package/dist/db/history-window.d.ts.map +1 -0
- package/dist/db/mapped-llm-run-repo.d.ts +56 -0
- package/dist/db/mapped-llm-run-repo.d.ts.map +1 -0
- package/dist/db/process-event-repo.d.ts +2 -0
- package/dist/db/process-event-repo.d.ts.map +1 -1
- package/dist/db/process-instance-repo.d.ts +4 -1
- package/dist/db/process-instance-repo.d.ts.map +1 -1
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts +2 -1
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts.map +1 -1
- package/dist/db/process-project-repo.d.ts +2 -0
- package/dist/db/process-project-repo.d.ts.map +1 -1
- package/dist/db/process-skill-repo.d.ts.map +1 -1
- package/dist/db/process-turn-annotation-repo.d.ts +4 -1
- package/dist/db/process-turn-annotation-repo.d.ts.map +1 -1
- package/dist/db/process-turn-record-repo.d.ts +7 -1
- package/dist/db/process-turn-record-repo.d.ts.map +1 -1
- package/dist/db/publication-repo.d.ts +5 -0
- package/dist/db/publication-repo.d.ts.map +1 -0
- package/dist/db/repo-helpers.d.ts +6 -0
- package/dist/db/repo-helpers.d.ts.map +1 -1
- package/dist/db/repositories.d.ts +16 -0
- package/dist/db/repositories.d.ts.map +1 -1
- package/dist/db/schema.d.ts +1177 -71
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/scoped-settings-repo.d.ts +37 -0
- package/dist/db/scoped-settings-repo.d.ts.map +1 -0
- package/dist/db/skill-repo.d.ts +3 -0
- package/dist/db/skill-repo.d.ts.map +1 -1
- package/dist/db/turn-start-record-repo.d.ts +2 -1
- package/dist/db/turn-start-record-repo.d.ts.map +1 -1
- package/dist/db/turn-summary-repo.d.ts +1 -1
- package/dist/db/turn-summary-repo.d.ts.map +1 -1
- package/dist/db/worker-lease-repo.d.ts +2 -1
- package/dist/db/worker-lease-repo.d.ts.map +1 -1
- package/dist/domain-logic/outcome-tools.d.ts.map +1 -1
- package/dist/external-source-service.d.ts.map +1 -1
- package/dist/future-execution/execution.d.ts +4 -1
- package/dist/future-execution/execution.d.ts.map +1 -1
- package/dist/future-execution/launch-lifecycle.d.ts +9 -25
- package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
- package/dist/future-execution/lifecycle.d.ts +3 -28
- package/dist/future-execution/lifecycle.d.ts.map +1 -1
- package/dist/future-execution/model-projection.d.ts.map +1 -1
- package/dist/future-execution/reconciliation.d.ts +1 -0
- package/dist/future-execution/reconciliation.d.ts.map +1 -1
- package/dist/future-execution-presenter.d.ts +4 -14
- package/dist/future-execution-presenter.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/integration-tool-registry.d.ts +11 -2
- package/dist/integration-tool-registry.d.ts.map +1 -1
- package/dist/launch-coordinator-test-harness.d.ts.map +1 -1
- package/dist/launch-coordinator.d.ts.map +1 -1
- package/dist/launcher-model-config-service.d.ts +7 -1
- package/dist/launcher-model-config-service.d.ts.map +1 -1
- package/dist/leaf-outcome-snapshot-capture.d.ts +1 -0
- package/dist/leaf-outcome-snapshot-capture.d.ts.map +1 -1
- package/dist/main.js +3 -3
- package/dist/primary-path-snapshot.d.ts.map +1 -1
- package/dist/process-action-presenter.d.ts +11 -0
- package/dist/process-action-presenter.d.ts.map +1 -0
- package/dist/process-action-registry.d.ts.map +1 -1
- package/dist/process-engine/decision.d.ts +2 -0
- package/dist/process-engine/decision.d.ts.map +1 -1
- package/dist/process-engine/engine.d.ts.map +1 -1
- package/dist/process-engine/mapped-turns.d.ts +45 -0
- package/dist/process-engine/mapped-turns.d.ts.map +1 -0
- package/dist/process-engine/operation.d.ts +1 -1
- package/dist/process-engine/operation.d.ts.map +1 -1
- package/dist/process-engine/ops/accept-worker-turn-start.d.ts +2 -0
- package/dist/process-engine/ops/accept-worker-turn-start.d.ts.map +1 -1
- package/dist/process-engine/ops/continue-failed-turn.d.ts.map +1 -1
- package/dist/process-engine/ops/process-observation.d.ts +6 -0
- package/dist/process-engine/ops/process-observation.d.ts.map +1 -0
- package/dist/process-engine/ops/retry-failed-turn.d.ts.map +1 -1
- package/dist/process-engine/ops/retry-startup.d.ts.map +1 -1
- package/dist/process-engine/ops/start-process.d.ts +2 -0
- package/dist/process-engine/ops/start-process.d.ts.map +1 -1
- package/dist/process-engine/ops/turn-outcome.d.ts.map +1 -1
- package/dist/process-engine/ops/turn-wait.d.ts +30 -0
- package/dist/process-engine/ops/turn-wait.d.ts.map +1 -0
- package/dist/process-engine/ops/update-model-config.d.ts +9 -0
- package/dist/process-engine/ops/update-model-config.d.ts.map +1 -0
- package/dist/process-engine/recorder.d.ts.map +1 -1
- package/dist/process-engine/turn-start-preflight.d.ts +6 -0
- package/dist/process-engine/turn-start-preflight.d.ts.map +1 -1
- package/dist/process-engine/turn-wait-state.d.ts +24 -0
- package/dist/process-engine/turn-wait-state.d.ts.map +1 -0
- package/dist/process-engine/turn-worker-requirement.d.ts +2 -0
- package/dist/process-engine/turn-worker-requirement.d.ts.map +1 -1
- package/dist/process-engine/types.d.ts +10 -1
- package/dist/process-engine/types.d.ts.map +1 -1
- package/dist/process-engine/writes/build-process-abort-writes.d.ts +3 -1
- package/dist/process-engine/writes/build-process-abort-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-recovery-start-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +10 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-selection-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/commit-writes.d.ts +2 -0
- package/dist/process-engine/writes/commit-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/reserve-selected-turn-start.d.ts +5 -0
- package/dist/process-engine/writes/reserve-selected-turn-start.d.ts.map +1 -0
- package/dist/process-engine/writes/writes.d.ts +35 -49
- package/dist/process-engine/writes/writes.d.ts.map +1 -1
- package/dist/process-graph.d.ts +1 -1
- package/dist/process-graph.d.ts.map +1 -1
- package/dist/process-inspection-reader.d.ts +21 -0
- package/dist/process-inspection-reader.d.ts.map +1 -0
- package/dist/process-inspection-trace.d.ts +13 -0
- package/dist/process-inspection-trace.d.ts.map +1 -0
- package/dist/process-inspection.d.ts +22 -0
- package/dist/process-inspection.d.ts.map +1 -0
- package/dist/process-instance-tree-presenter.d.ts +4 -3
- package/dist/process-instance-tree-presenter.d.ts.map +1 -1
- package/dist/process-launch-executor.d.ts +2 -0
- package/dist/process-launch-executor.d.ts.map +1 -1
- package/dist/process-launch-plan.d.ts +1 -0
- package/dist/process-launch-plan.d.ts.map +1 -1
- package/dist/process-launcher-registry.d.ts.map +1 -1
- package/dist/process-model-config.d.ts +19 -0
- package/dist/process-model-config.d.ts.map +1 -0
- package/dist/process-model-policy/construct.d.ts.map +1 -1
- package/dist/process-model-policy/evaluate.d.ts.map +1 -1
- package/dist/process-model-policy/index.d.ts +4 -1
- package/dist/process-model-policy/index.d.ts.map +1 -1
- package/dist/process-model-policy/project.d.ts.map +1 -1
- package/dist/process-model-policy/types.d.ts +18 -0
- package/dist/process-model-policy/types.d.ts.map +1 -1
- package/dist/process-model-policy-presenter.d.ts.map +1 -1
- package/dist/process-runtime-availability.d.ts +2 -1
- package/dist/process-runtime-availability.d.ts.map +1 -1
- package/dist/process-turn-navigation.d.ts +12 -2
- package/dist/process-turn-navigation.d.ts.map +1 -1
- package/dist/process-turn-trace.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts +15 -3
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- package/dist/routes/future-executions.d.ts.map +1 -1
- package/dist/routes/launchers.d.ts.map +1 -1
- package/dist/routes/process-actions.d.ts.map +1 -1
- package/dist/routes/process-detail.d.ts.map +1 -1
- package/dist/routes/process-diagnostics-assembler.d.ts +3 -1
- package/dist/routes/process-diagnostics-assembler.d.ts.map +1 -1
- package/dist/routes/process-model-config.d.ts +4 -0
- package/dist/routes/process-model-config.d.ts.map +1 -0
- package/dist/routes/process-primary-path-assembler.d.ts +4 -12
- package/dist/routes/process-primary-path-assembler.d.ts.map +1 -1
- package/dist/routes/process-route-helpers.d.ts +15 -41
- package/dist/routes/process-route-helpers.d.ts.map +1 -1
- package/dist/routes/processes.d.ts.map +1 -1
- package/dist/routes/settings.d.ts +11 -0
- package/dist/routes/settings.d.ts.map +1 -0
- package/dist/routes/ticket-creation.d.ts.map +1 -1
- package/dist/scoped-settings-service.d.ts +83 -0
- package/dist/scoped-settings-service.d.ts.map +1 -0
- package/dist/server-bootstrap/build-host-capabilities.d.ts +2 -0
- package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
- package/dist/server-bootstrap/register-http.d.ts.map +1 -1
- package/dist/session-summary-projection.d.ts.map +1 -1
- package/dist/skills/bundled-skills.d.ts +5 -0
- package/dist/skills/bundled-skills.d.ts.map +1 -0
- package/dist/skills/catalog-service.d.ts +1 -0
- package/dist/skills/catalog-service.d.ts.map +1 -1
- package/dist/skills/extension-importer.d.ts +11 -0
- package/dist/skills/extension-importer.d.ts.map +1 -0
- package/dist/skills/launch-skills.d.ts +11 -0
- package/dist/skills/launch-skills.d.ts.map +1 -0
- package/dist/skills/skill-frontmatter.d.ts +5 -0
- package/dist/skills/skill-frontmatter.d.ts.map +1 -1
- package/dist/skills/source-importer.d.ts +3 -0
- package/dist/skills/source-importer.d.ts.map +1 -1
- package/dist/startup-evidence.d.ts +3 -0
- package/dist/startup-evidence.d.ts.map +1 -1
- package/dist/supervisor/execution-inspection-ingestor.d.ts +9 -0
- package/dist/supervisor/execution-inspection-ingestor.d.ts.map +1 -0
- package/dist/supervisor/ipc-handler.d.ts +2 -0
- package/dist/supervisor/ipc-handler.d.ts.map +1 -1
- package/dist/supervisor/worker-event-ingestor.d.ts +1 -0
- package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts +2 -0
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +4 -0
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts +2 -2
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts.map +1 -1
- package/dist/test-helpers/accepted-turn-start.d.ts +18 -4
- package/dist/test-helpers/accepted-turn-start.d.ts.map +1 -1
- package/dist/test-helpers/owned-test-deps.d.ts +18 -0
- package/dist/test-helpers/owned-test-deps.d.ts.map +1 -0
- package/dist/test-helpers/prepared-fixture-start.d.ts.map +1 -1
- package/dist/test-helpers/process-model-fixtures.d.ts +1 -0
- package/dist/test-helpers/process-model-fixtures.d.ts.map +1 -1
- package/dist/test-helpers/scoped-settings-fixtures.d.ts +16 -0
- package/dist/test-helpers/scoped-settings-fixtures.d.ts.map +1 -0
- package/dist/test-helpers/skill-fixtures.d.ts +4 -0
- package/dist/test-helpers/skill-fixtures.d.ts.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +14 -10
- package/dist/testing.js.map +1 -1
- package/dist/tool-approval-gate.d.ts +3 -0
- package/dist/tool-approval-gate.d.ts.map +1 -1
- package/dist/turn-progress.d.ts.map +1 -1
- package/dist/turn-wait-service.d.ts +28 -0
- package/dist/turn-wait-service.d.ts.map +1 -0
- package/dist/worker-runtime-profile-selection.d.ts +2 -0
- package/dist/worker-runtime-profile-selection.d.ts.map +1 -1
- package/package.json +20 -19
- package/src/app.ts +117 -5
- package/src/auth/fastify-auth.ts +13 -0
- package/src/config/config-loader.ts +40 -2
- package/src/config/config-types.ts +14 -1
- package/src/config/kubernetes-docker-isolation.ts +21 -0
- package/src/db/database.ts +159 -40
- package/src/db/execution-inspection-repo.ts +163 -0
- package/src/db/history-window.ts +18 -0
- package/src/db/mapped-llm-run-repo.ts +177 -0
- package/src/db/process-event-repo.ts +88 -10
- package/src/db/process-instance-repo.ts +9 -2
- package/src/db/process-leaf-outcome-snapshot-repo.ts +8 -2
- package/src/db/process-project-repo.ts +4 -0
- package/src/db/process-skill-repo.ts +9 -2
- package/src/db/process-turn-annotation-repo.ts +27 -9
- package/src/db/process-turn-record-repo.ts +53 -13
- package/src/db/publication-repo.ts +63 -0
- package/src/db/repo-helpers.ts +11 -1
- package/src/db/repositories.ts +22 -0
- package/src/db/schema.ts +173 -2
- package/src/db/scoped-settings-repo.ts +234 -0
- package/src/db/skill-repo.ts +89 -27
- package/src/db/turn-start-record-repo.ts +13 -3
- package/src/db/turn-summary-repo.ts +12 -3
- package/src/db/worker-lease-repo.ts +8 -2
- package/src/domain-logic/outcome-tools.ts +4 -149
- package/src/external-source-service.ts +33 -7
- package/src/future-execution/execution.ts +9 -2
- package/src/future-execution/launch-lifecycle.ts +87 -78
- package/src/future-execution/lifecycle.ts +5 -34
- package/src/future-execution/model-projection.ts +2 -0
- package/src/future-execution/reconciliation.ts +7 -0
- package/src/future-execution-presenter.ts +14 -22
- package/src/integration-tool-registry.ts +59 -26
- package/src/launch-coordinator-test-harness.ts +8 -4
- package/src/launch-coordinator.ts +10 -1
- package/src/launcher-model-config-service.ts +24 -3
- package/src/leaf-outcome-snapshot-capture.ts +2 -0
- package/src/primary-path-snapshot.ts +3 -4
- package/src/process-action-presenter.ts +98 -0
- package/src/process-action-registry.ts +31 -39
- package/src/process-engine/decision.ts +10 -0
- package/src/process-engine/engine.ts +13 -4
- package/src/process-engine/mapped-turns.ts +328 -0
- package/src/process-engine/operation.ts +1 -1
- package/src/process-engine/ops/accept-worker-turn-start.ts +6 -0
- package/src/process-engine/ops/continue-failed-turn.ts +2 -13
- package/src/process-engine/ops/process-observation.ts +119 -0
- package/src/process-engine/ops/retry-failed-turn.ts +2 -12
- package/src/process-engine/ops/retry-startup.ts +10 -13
- package/src/process-engine/ops/start-process.ts +34 -2
- package/src/process-engine/ops/turn-outcome.ts +65 -62
- package/src/process-engine/ops/turn-wait.ts +225 -0
- package/src/process-engine/ops/update-model-config.ts +66 -0
- package/src/process-engine/recorder.ts +33 -5
- package/src/process-engine/runner.ts +8 -8
- package/src/process-engine/turn-start-preflight.ts +168 -105
- package/src/process-engine/turn-wait-state.ts +126 -0
- package/src/process-engine/turn-worker-requirement.ts +4 -0
- package/src/process-engine/types.ts +15 -0
- package/src/process-engine/writes/build-process-abort-writes.ts +30 -19
- package/src/process-engine/writes/build-recovery-start-writes.ts +1 -0
- package/src/process-engine/writes/build-turn-outcome-writes.ts +118 -21
- package/src/process-engine/writes/build-turn-selection-writes.ts +2 -31
- package/src/process-engine/writes/commit-writes.ts +20 -2
- package/src/process-engine/writes/reserve-selected-turn-start.ts +44 -0
- package/src/process-engine/writes/writes.ts +73 -61
- package/src/process-graph.ts +0 -1
- package/src/process-inspection-reader.ts +305 -0
- package/src/process-inspection-trace.ts +176 -0
- package/src/process-inspection.ts +169 -0
- package/src/process-instance-tree-presenter.ts +56 -216
- package/src/process-launch-executor.ts +5 -2
- package/src/process-launch-plan.ts +17 -2
- package/src/process-launcher-registry.ts +28 -16
- package/src/process-model-config.ts +100 -0
- package/src/process-model-policy/construct.ts +1 -0
- package/src/process-model-policy/evaluate.ts +34 -32
- package/src/process-model-policy/index.ts +45 -3
- package/src/process-model-policy/project.ts +62 -76
- package/src/process-model-policy/types.ts +26 -0
- package/src/process-model-policy-presenter.ts +7 -3
- package/src/process-runtime-availability.ts +9 -4
- package/src/process-turn-navigation.ts +86 -8
- package/src/process-turn-trace.ts +12 -24
- package/src/process-ui-snapshot-presenter.ts +249 -298
- package/src/routes/future-executions.ts +5 -5
- package/src/routes/launchers.ts +51 -1
- package/src/routes/process-actions.ts +10 -10
- package/src/routes/process-detail.ts +25 -2
- package/src/routes/process-diagnostics-assembler.ts +32 -6
- package/src/routes/process-model-config.ts +70 -0
- package/src/routes/process-primary-path-assembler.ts +17 -33
- package/src/routes/process-route-helpers.ts +161 -327
- package/src/routes/processes.ts +2 -0
- package/src/routes/settings.ts +173 -0
- package/src/routes/ticket-creation.ts +28 -5
- package/src/scoped-settings-service.ts +736 -0
- package/src/server-bootstrap/build-host-capabilities.ts +42 -0
- package/src/server-bootstrap/register-http.ts +7 -1
- package/src/session-summary-projection.ts +1 -2
- package/src/skills/bundled-skills.ts +64 -0
- package/src/skills/catalog-service.ts +35 -6
- package/src/skills/extension-importer.ts +97 -0
- package/src/skills/launch-skills.ts +19 -0
- package/src/skills/skill-frontmatter.ts +13 -0
- package/src/skills/source-importer.ts +3 -0
- package/src/startup-evidence.ts +20 -0
- package/src/supervisor/execution-inspection-ingestor.ts +55 -0
- package/src/supervisor/ipc-handler.ts +29 -18
- package/src/supervisor/worker-event-ingestor.ts +30 -14
- package/src/supervisor/worker-start-payload-builder.ts +42 -0
- package/src/supervisor/worker-supervisor.ts +5 -0
- package/src/supervisor/worker-turn-ipc-recorder.ts +13 -1
- package/src/test-helpers/accepted-turn-start.ts +51 -27
- package/src/test-helpers/owned-test-deps.ts +45 -0
- package/src/test-helpers/prepared-fixture-start.ts +1 -0
- package/src/test-helpers/process-model-fixtures.ts +2 -0
- package/src/test-helpers/scoped-settings-fixtures.ts +126 -0
- package/src/test-helpers/skill-fixtures.ts +28 -0
- package/src/testing.ts +4 -1
- package/src/tool-approval-gate.ts +16 -0
- package/src/turn-progress.ts +3 -2
- package/src/turn-wait-service.ts +228 -0
- package/src/worker-runtime-profile-selection.ts +8 -1
- package/dist/app-4QSV4FUQ.js +0 -8
- package/dist/chunk-KIOQNNG6.js.map +0 -1
- package/dist/chunk-LK3RO6C7.js.map +0 -1
- /package/dist/{app-4QSV4FUQ.js.map → app-JM4CBTND.js.map} +0 -0
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
MappedTurnItemRef,
|
|
3
|
+
ProcessInstance,
|
|
4
|
+
ProcessProject,
|
|
5
|
+
TurnOutcomePayload,
|
|
6
|
+
} from "@leitwerk-dev/domain";
|
|
7
|
+
import {
|
|
8
|
+
applyOutcomeContract,
|
|
9
|
+
resolveOutcomeContract,
|
|
10
|
+
SafeOutcomePlanningError,
|
|
11
|
+
} from "@leitwerk-dev/process-sdk";
|
|
12
|
+
import type { RepositoryBundle } from "../../db/repositories.js";
|
|
2
13
|
import {
|
|
3
14
|
checkTurnOutcomeAvailability,
|
|
4
15
|
validateTurnOutcome,
|
|
@@ -8,6 +19,7 @@ import type { ProcessActionRegistry } from "../../process-action-registry.js";
|
|
|
8
19
|
import type { ProcessGraphRegistry } from "../../process-graph.js";
|
|
9
20
|
import { validateQueuedProcessInput } from "../../process-input-dispatch.js";
|
|
10
21
|
import type { TurnRecordMarkdownLookup } from "../../turn-result-markdown.js";
|
|
22
|
+
import { buildMappedItemOutcomeWrites } from "../mapped-turns.js";
|
|
11
23
|
import { buildServerTransitionWrites } from "./build-server-transition-writes.js";
|
|
12
24
|
import { buildTurnSelectionWrites } from "./build-turn-selection-writes.js";
|
|
13
25
|
import { createDeferredExtensionEvent } from "./deferred-extension-events.js";
|
|
@@ -30,6 +42,21 @@ function hasExplicitTurnSelectionChange(process: ProcessInstance, writes: Writes
|
|
|
30
42
|
);
|
|
31
43
|
}
|
|
32
44
|
|
|
45
|
+
function loadPreparedData(
|
|
46
|
+
process: ProcessInstance,
|
|
47
|
+
payload: TurnOutcomePayload,
|
|
48
|
+
events?: Pick<RepositoryBundle, "events">["events"],
|
|
49
|
+
): unknown {
|
|
50
|
+
const preparationEvent = events
|
|
51
|
+
?.listByInstanceTurnRecordEventTypes(process.id, payload.turnRecordId, ["turn.prepared"])
|
|
52
|
+
.at(-1);
|
|
53
|
+
return preparationEvent?.data &&
|
|
54
|
+
typeof preparationEvent.data === "object" &&
|
|
55
|
+
"data" in preparationEvent.data
|
|
56
|
+
? preparationEvent.data.data
|
|
57
|
+
: undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
33
60
|
async function buildProcessTurnOutcomeEffectWrites(
|
|
34
61
|
processGraphs: ProcessGraphRegistry,
|
|
35
62
|
process: ProcessInstance,
|
|
@@ -37,24 +64,34 @@ async function buildProcessTurnOutcomeEffectWrites(
|
|
|
37
64
|
payload: TurnOutcomePayload,
|
|
38
65
|
processActionRegistry: ProcessActionRegistry,
|
|
39
66
|
turnRecords: TurnRecordMarkdownLookup,
|
|
67
|
+
events?: Pick<RepositoryBundle, "events">["events"],
|
|
40
68
|
): Promise<WriteBuildResult> {
|
|
41
69
|
const serverDef = processActionRegistry.getServerDefinition(process.processId);
|
|
42
70
|
const handlers = serverDef?.turnOutcomeHandlers.get(payload.turnId) ?? [];
|
|
43
71
|
|
|
44
72
|
const { params, state } = processActionRegistry.resolveContextData(process.processId, process);
|
|
45
73
|
const plan = createProcessPlanCollector({ process, projects, params, state, turnRecords });
|
|
74
|
+
const prepared = loadPreparedData(process, payload, events);
|
|
46
75
|
|
|
47
76
|
for (const handler of handlers) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
77
|
+
try {
|
|
78
|
+
await handler(
|
|
79
|
+
{
|
|
80
|
+
turnRecordId: payload.turnRecordId,
|
|
81
|
+
turnId: payload.turnId,
|
|
82
|
+
outcome: payload.outcome,
|
|
83
|
+
params: payload.params ?? {},
|
|
84
|
+
turnResultMarkdown: payload.turnResultMarkdown ?? null,
|
|
85
|
+
...(prepared !== undefined ? { prepared } : {}),
|
|
86
|
+
},
|
|
87
|
+
plan.context,
|
|
88
|
+
);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (error instanceof SafeOutcomePlanningError) {
|
|
91
|
+
return { ok: false, code: error.code, message: error.message };
|
|
92
|
+
}
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
58
95
|
}
|
|
59
96
|
|
|
60
97
|
for (const queuedInput of plan.queuedInputs) {
|
|
@@ -90,6 +127,8 @@ async function buildProcessTurnOutcomeEffectWrites(
|
|
|
90
127
|
|
|
91
128
|
/** @internal */
|
|
92
129
|
export interface TurnOutcomePlanningInput {
|
|
130
|
+
/** Frozen declarations from the accepted start. @internal */
|
|
131
|
+
outcomeContract?: Record<string, unknown>;
|
|
93
132
|
/** @internal */
|
|
94
133
|
process: ProcessInstance;
|
|
95
134
|
/** @internal */
|
|
@@ -102,6 +141,12 @@ export interface TurnOutcomePlanningInput {
|
|
|
102
141
|
processGraphs: ProcessGraphRegistry;
|
|
103
142
|
/** @internal */
|
|
104
143
|
processActionRegistry: ProcessActionRegistry;
|
|
144
|
+
/** @internal */
|
|
145
|
+
events?: Pick<RepositoryBundle, "events">["events"];
|
|
146
|
+
/** @internal */
|
|
147
|
+
mappedRuns?: RepositoryBundle["mappedRuns"];
|
|
148
|
+
/** Mapped item executed by the accepted start, when any. @internal */
|
|
149
|
+
iteration?: MappedTurnItemRef | null;
|
|
105
150
|
}
|
|
106
151
|
|
|
107
152
|
/** @internal */
|
|
@@ -109,10 +154,41 @@ export async function buildTurnOutcomeWrites(
|
|
|
109
154
|
input: TurnOutcomePlanningInput,
|
|
110
155
|
): Promise<WriteBuildResult> {
|
|
111
156
|
const knownProjectKeys = new Set(input.projects.map((project) => project.key));
|
|
112
|
-
|
|
157
|
+
let turnDefinition = input.processActionRegistry.getTurnDefinition(
|
|
113
158
|
input.process.processId,
|
|
114
159
|
input.payload.turnId,
|
|
115
160
|
);
|
|
161
|
+
if (turnDefinition?.kind === "llm") {
|
|
162
|
+
try {
|
|
163
|
+
let snapshot = input.outcomeContract;
|
|
164
|
+
if (!snapshot) {
|
|
165
|
+
const ref = input.iteration;
|
|
166
|
+
const item = ref ? input.mappedRuns?.getItem(ref.runId, ref.itemIndex) : undefined;
|
|
167
|
+
const run = ref ? input.mappedRuns?.getById(ref.runId) : undefined;
|
|
168
|
+
snapshot = {
|
|
169
|
+
...resolveOutcomeContract(
|
|
170
|
+
turnDefinition,
|
|
171
|
+
input.processActionRegistry.resolveContextData(input.process.processId, input.process),
|
|
172
|
+
ref && item && run
|
|
173
|
+
? {
|
|
174
|
+
...ref,
|
|
175
|
+
item: JSON.parse(item.itemJson),
|
|
176
|
+
itemLabel: item.label,
|
|
177
|
+
itemCount: run.itemCount,
|
|
178
|
+
}
|
|
179
|
+
: undefined,
|
|
180
|
+
),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
turnDefinition = applyOutcomeContract(turnDefinition, snapshot);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
return {
|
|
186
|
+
ok: false,
|
|
187
|
+
code: "invalid_outcome_contract",
|
|
188
|
+
message: error instanceof Error ? error.message : "Invalid outcome contract",
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
116
192
|
const availabilityError = checkTurnOutcomeAvailability(
|
|
117
193
|
input.processGraphs,
|
|
118
194
|
turnDefinition,
|
|
@@ -151,6 +227,34 @@ export async function buildTurnOutcomeWrites(
|
|
|
151
227
|
);
|
|
152
228
|
}
|
|
153
229
|
const processForEffects: ProcessInstance = { ...input.process, ...baseWrites.processPatch };
|
|
230
|
+
const outcomeEvent = createDeferredExtensionEvent(input.process.id, "turn_outcome", {
|
|
231
|
+
turnRecordId: input.payload.turnRecordId,
|
|
232
|
+
turnId: input.payload.turnId,
|
|
233
|
+
outcome: input.payload.outcome,
|
|
234
|
+
params: input.payload.params ?? {},
|
|
235
|
+
turnResultMarkdown: input.payload.turnResultMarkdown ?? null,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const mappedSpec = turnDefinition?.kind === "llm" ? turnDefinition.forEach : undefined;
|
|
239
|
+
if (mappedSpec) {
|
|
240
|
+
const mappedWrites = await buildMappedItemOutcomeWrites({
|
|
241
|
+
processGraphs: input.processGraphs,
|
|
242
|
+
registry: input.processActionRegistry,
|
|
243
|
+
mappedRuns: input.mappedRuns,
|
|
244
|
+
process: processForEffects,
|
|
245
|
+
projects: input.projects,
|
|
246
|
+
payload: input.payload,
|
|
247
|
+
spec: mappedSpec,
|
|
248
|
+
iteration: input.iteration,
|
|
249
|
+
prepared: loadPreparedData(processForEffects, input.payload, input.events),
|
|
250
|
+
});
|
|
251
|
+
if (isWriteBuildFailure(mappedWrites)) {
|
|
252
|
+
return mappedWrites;
|
|
253
|
+
}
|
|
254
|
+
const writes = mergeWrites(baseWrites, mappedWrites);
|
|
255
|
+
writes.extensionEvents.push(outcomeEvent);
|
|
256
|
+
return writes;
|
|
257
|
+
}
|
|
154
258
|
|
|
155
259
|
const effectWrites = await buildProcessTurnOutcomeEffectWrites(
|
|
156
260
|
input.processGraphs,
|
|
@@ -159,6 +263,7 @@ export async function buildTurnOutcomeWrites(
|
|
|
159
263
|
input.payload,
|
|
160
264
|
input.processActionRegistry,
|
|
161
265
|
input.turnRecords,
|
|
266
|
+
input.events,
|
|
162
267
|
);
|
|
163
268
|
if (isWriteBuildFailure(effectWrites)) {
|
|
164
269
|
return effectWrites;
|
|
@@ -195,15 +300,7 @@ export async function buildTurnOutcomeWrites(
|
|
|
195
300
|
}
|
|
196
301
|
}
|
|
197
302
|
|
|
198
|
-
writes.extensionEvents.push(
|
|
199
|
-
createDeferredExtensionEvent(input.process.id, "turn_outcome", {
|
|
200
|
-
turnRecordId: input.payload.turnRecordId,
|
|
201
|
-
turnId: input.payload.turnId,
|
|
202
|
-
outcome: input.payload.outcome,
|
|
203
|
-
params: input.payload.params ?? {},
|
|
204
|
-
turnResultMarkdown: input.payload.turnResultMarkdown ?? null,
|
|
205
|
-
}),
|
|
206
|
-
);
|
|
303
|
+
writes.extensionEvents.push(outcomeEvent);
|
|
207
304
|
|
|
208
305
|
return writes;
|
|
209
306
|
}
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
type TransitionTrigger,
|
|
6
6
|
type TurnId,
|
|
7
7
|
} from "@leitwerk-dev/domain";
|
|
8
|
-
import { generateId } from "../../db/repo-helpers.js";
|
|
9
8
|
import { tryTransition } from "../../domain-logic/process-state-machine.js";
|
|
10
9
|
import { getProcessTurnGraph, type ProcessGraphRegistry } from "../../process-graph.js";
|
|
11
10
|
import { selectedTurnRequiresWorker } from "../turn-worker-requirement.js";
|
|
11
|
+
import { reserveSelectedTurnStart } from "./reserve-selected-turn-start.js";
|
|
12
12
|
import {
|
|
13
13
|
appendProcessEvent,
|
|
14
14
|
applyProcessPatchField,
|
|
@@ -116,36 +116,7 @@ export function buildTurnSelectionWrites(
|
|
|
116
116
|
if (input.toTurnId && targetLifecycleStatus === "active") {
|
|
117
117
|
const target = getProcessTurnGraph(processGraphs, process.processId, input.toTurnId);
|
|
118
118
|
if (target?.turnType === "llm" || target?.turnType === "automatic") {
|
|
119
|
-
|
|
120
|
-
writes.turnStartWrites.push({
|
|
121
|
-
kind: "create",
|
|
122
|
-
input: {
|
|
123
|
-
id: startId,
|
|
124
|
-
instanceId: process.id,
|
|
125
|
-
turnId: input.toTurnId,
|
|
126
|
-
turnType: target.turnType,
|
|
127
|
-
proposedTurnRecordId: generateId("trn"),
|
|
128
|
-
startKind: "selected_turn",
|
|
129
|
-
recoveryTurnRecordId: null,
|
|
130
|
-
continuation: null,
|
|
131
|
-
state:
|
|
132
|
-
target.turnType === "automatic"
|
|
133
|
-
? { kind: "starting", start: { kind: "automatic" } }
|
|
134
|
-
: {
|
|
135
|
-
kind: "preparation_failed",
|
|
136
|
-
requestedModelProfileId: process.selectedTurnModelProfileId ?? null,
|
|
137
|
-
providerOptions: {},
|
|
138
|
-
code: "model_required",
|
|
139
|
-
safeSummary: "LLM start requires model preflight",
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
applyProcessPatchField(writes, process, "currentExecution", {
|
|
144
|
-
kind: "worker_start",
|
|
145
|
-
id: startId,
|
|
146
|
-
});
|
|
147
|
-
if (target.turnType === "llm")
|
|
148
|
-
applyProcessPatchField(writes, process, "lifecycleStatus", "error");
|
|
119
|
+
reserveSelectedTurnStart(writes, process, input.toTurnId, target.turnType);
|
|
149
120
|
}
|
|
150
121
|
} else if (
|
|
151
122
|
input.toTurnId === null ||
|
|
@@ -57,6 +57,8 @@ export interface RecordCommit {
|
|
|
57
57
|
/** @internal */
|
|
58
58
|
committedProject: ProcessProject | null;
|
|
59
59
|
/** @internal */
|
|
60
|
+
initialProjects?: ProcessProject[];
|
|
61
|
+
/** @internal */
|
|
60
62
|
committedTurnRecords: ProcessTurnRecord[];
|
|
61
63
|
/** @internal */
|
|
62
64
|
committedLeafOutcomeSnapshots: ProcessLeafOutcomeSnapshot[];
|
|
@@ -192,6 +194,11 @@ export function commitWrites(
|
|
|
192
194
|
return deps.transaction((repos) => {
|
|
193
195
|
const processBefore = repos.processes.getById(instanceId);
|
|
194
196
|
const committedTurnRecords: ProcessTurnRecord[] = [];
|
|
197
|
+
for (const write of writes.mappedRunWrites) {
|
|
198
|
+
if (write.kind === "create") repos.mappedRuns.create(write.input);
|
|
199
|
+
else if (write.kind === "complete_item") repos.mappedRuns.completeItem(write.input);
|
|
200
|
+
else repos.mappedRuns.abortActiveByInstance(instanceId);
|
|
201
|
+
}
|
|
195
202
|
for (const write of writes.turnStartWrites) {
|
|
196
203
|
if (write.kind === "create") repos.turnStarts.create(write.input);
|
|
197
204
|
else if (!repos.turnStarts.compareAndSetState(write)) {
|
|
@@ -245,7 +252,9 @@ export function commitWrites(
|
|
|
245
252
|
|
|
246
253
|
const processAfter =
|
|
247
254
|
writes.changedFields.length > 0
|
|
248
|
-
? repos.processes.update(instanceId, writes.processPatch
|
|
255
|
+
? repos.processes.update(instanceId, writes.processPatch, {
|
|
256
|
+
preserveUpdatedAt: writes.preserveUpdatedAt,
|
|
257
|
+
})
|
|
249
258
|
: repos.processes.getById(instanceId);
|
|
250
259
|
const committedProject = writes.projectWrite
|
|
251
260
|
? repos.projects.update(writes.projectWrite.id, writes.projectWrite.input)
|
|
@@ -258,6 +267,11 @@ export function commitWrites(
|
|
|
258
267
|
`Process project '${committedProject.id}' does not belong to '${instanceId}'`,
|
|
259
268
|
);
|
|
260
269
|
}
|
|
270
|
+
const initialProjects = (writes.initialProjects ?? []).map((project) => {
|
|
271
|
+
if (project.instanceId !== instanceId)
|
|
272
|
+
throw new Error("Initial repository belongs to another process");
|
|
273
|
+
return repos.projects.create(project);
|
|
274
|
+
});
|
|
261
275
|
|
|
262
276
|
for (const write of writes.pendingExternalSourceFireWrites) {
|
|
263
277
|
if (write.kind === "create") {
|
|
@@ -298,6 +312,7 @@ export function commitWrites(
|
|
|
298
312
|
processBefore,
|
|
299
313
|
processAfter,
|
|
300
314
|
committedProject,
|
|
315
|
+
initialProjects,
|
|
301
316
|
committedTurnRecords,
|
|
302
317
|
turnEventSequences,
|
|
303
318
|
committedLeafOutcomeSnapshots,
|
|
@@ -320,6 +335,8 @@ export function deriveReactions(
|
|
|
320
335
|
effects.push({ kind: "broadcast", frame });
|
|
321
336
|
}
|
|
322
337
|
if (commit.committedProject) effects.push(buildProjectUpdatedEffect(commit.committedProject));
|
|
338
|
+
for (const project of commit.initialProjects ?? [])
|
|
339
|
+
effects.push(buildProjectUpdatedEffect(project));
|
|
323
340
|
if (writes.changedFields.length > 0) {
|
|
324
341
|
const includeClosedAt =
|
|
325
342
|
commit.processAfter !== null &&
|
|
@@ -330,7 +347,8 @@ export function deriveReactions(
|
|
|
330
347
|
...(includeClosedAt ? { closedAt: commit.processAfter?.closedAt ?? null } : {}),
|
|
331
348
|
};
|
|
332
349
|
let changedFields =
|
|
333
|
-
commit.processAfter?.updatedAt
|
|
350
|
+
commit.processAfter?.updatedAt !== commit.processBefore?.updatedAt &&
|
|
351
|
+
!writes.changedFields.includes("updatedAt")
|
|
334
352
|
? [...writes.changedFields, "updatedAt"]
|
|
335
353
|
: writes.changedFields;
|
|
336
354
|
if (includeClosedAt && !changedFields.includes("closedAt")) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { MappedTurnItemRef, ProcessInstance } from "@leitwerk-dev/domain";
|
|
2
|
+
import { generateId } from "../../db/repo-helpers.js";
|
|
3
|
+
import { applyProcessPatchField, type Writes } from "./writes.js";
|
|
4
|
+
|
|
5
|
+
/** Reserves a worker start without creating an attempt; acceptance creates the record. @internal */
|
|
6
|
+
export function reserveSelectedTurnStart(
|
|
7
|
+
writes: Writes,
|
|
8
|
+
process: ProcessInstance,
|
|
9
|
+
turnId: string,
|
|
10
|
+
turnType: "llm" | "automatic",
|
|
11
|
+
iteration?: MappedTurnItemRef,
|
|
12
|
+
): void {
|
|
13
|
+
const startId = generateId("tsr");
|
|
14
|
+
writes.turnStartWrites.push({
|
|
15
|
+
kind: "create",
|
|
16
|
+
input: {
|
|
17
|
+
id: startId,
|
|
18
|
+
instanceId: process.id,
|
|
19
|
+
turnId,
|
|
20
|
+
turnType,
|
|
21
|
+
proposedTurnRecordId: generateId("trn"),
|
|
22
|
+
startKind: "selected_turn",
|
|
23
|
+
recoveryTurnRecordId: null,
|
|
24
|
+
continuation: null,
|
|
25
|
+
state:
|
|
26
|
+
turnType === "automatic"
|
|
27
|
+
? { kind: "starting", start: { kind: "automatic" } }
|
|
28
|
+
: {
|
|
29
|
+
kind: "preparation_failed",
|
|
30
|
+
requestedModelProfileId: process.selectedTurnModelProfileId ?? null,
|
|
31
|
+
providerOptions: {},
|
|
32
|
+
code: "model_required",
|
|
33
|
+
safeSummary: "LLM start requires model preflight",
|
|
34
|
+
},
|
|
35
|
+
...(iteration ? { iteration } : {}),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
applyProcessPatchField(writes, process, "currentExecution", {
|
|
39
|
+
kind: "worker_start",
|
|
40
|
+
id: startId,
|
|
41
|
+
});
|
|
42
|
+
// Model preflight activates LLM starts before the worker can accept them.
|
|
43
|
+
if (turnType === "llm") applyProcessPatchField(writes, process, "lifecycleStatus", "error");
|
|
44
|
+
}
|
|
@@ -7,6 +7,10 @@ import {
|
|
|
7
7
|
type TurnStartRecord,
|
|
8
8
|
} from "@leitwerk-dev/domain";
|
|
9
9
|
import type { DurableWsFrameInput } from "@leitwerk-dev/protocol";
|
|
10
|
+
import type {
|
|
11
|
+
CompleteMappedItemInput,
|
|
12
|
+
CreateMappedRunInput,
|
|
13
|
+
} from "../../db/mapped-llm-run-repo.js";
|
|
10
14
|
import type {
|
|
11
15
|
CreatePendingExternalSourceFireInput,
|
|
12
16
|
UpdatePendingExternalSourceFireInput,
|
|
@@ -14,7 +18,10 @@ import type {
|
|
|
14
18
|
import type { CreateProcessEventInput } from "../../db/process-event-repo.js";
|
|
15
19
|
import type { UpdateProcessInstanceInput } from "../../db/process-instance-repo.js";
|
|
16
20
|
import type { CreateProcessLeafOutcomeSnapshotInput } from "../../db/process-leaf-outcome-snapshot-repo.js";
|
|
17
|
-
import type {
|
|
21
|
+
import type {
|
|
22
|
+
CreateProcessProjectInput,
|
|
23
|
+
UpdateProcessProjectInput,
|
|
24
|
+
} from "../../db/process-project-repo.js";
|
|
18
25
|
import type {
|
|
19
26
|
CreateProcessTurnAnnotationInput,
|
|
20
27
|
UpdateProcessTurnAnnotationInput,
|
|
@@ -30,34 +37,45 @@ import type { DeferredProcessExtensionEvent } from "./deferred-extension-events.
|
|
|
30
37
|
/** @internal */
|
|
31
38
|
export type DurableBroadcast = DurableWsFrameInput;
|
|
32
39
|
|
|
40
|
+
/** @internal */
|
|
41
|
+
type CreateWrite<T> = {
|
|
42
|
+
/** @internal */
|
|
43
|
+
kind: "create";
|
|
44
|
+
/** @internal */
|
|
45
|
+
input: T;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** @internal */
|
|
49
|
+
type UpdateWrite<T> = {
|
|
50
|
+
/** @internal */
|
|
51
|
+
kind: "update";
|
|
52
|
+
/** @internal */
|
|
53
|
+
id: string;
|
|
54
|
+
/** @internal */
|
|
55
|
+
input: T;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** @internal */
|
|
59
|
+
type DeleteWrite = {
|
|
60
|
+
/** @internal */
|
|
61
|
+
kind: "delete";
|
|
62
|
+
/** @internal */
|
|
63
|
+
id: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
33
66
|
/** @internal */
|
|
34
67
|
export type TurnRecordWrite =
|
|
35
|
-
|
|
|
36
|
-
|
|
37
|
-
kind: "create";
|
|
38
|
-
/** @internal */
|
|
39
|
-
input: CreateProcessTurnRecordInput;
|
|
40
|
-
}
|
|
41
|
-
| {
|
|
42
|
-
/** @internal */
|
|
43
|
-
kind: "update";
|
|
44
|
-
/** @internal */
|
|
45
|
-
id: string;
|
|
46
|
-
/** @internal */
|
|
47
|
-
input: UpdateProcessTurnRecordInput;
|
|
48
|
-
};
|
|
68
|
+
| CreateWrite<CreateProcessTurnRecordInput>
|
|
69
|
+
| UpdateWrite<UpdateProcessTurnRecordInput>;
|
|
49
70
|
|
|
50
71
|
/** @internal */
|
|
51
72
|
export type TurnStartWrite =
|
|
52
|
-
|
|
|
53
|
-
|
|
54
|
-
kind: "create";
|
|
55
|
-
/** @internal */
|
|
56
|
-
input: Omit<TurnStartRecord, "id" | "createdAt" | "updatedAt"> & {
|
|
73
|
+
| CreateWrite<
|
|
74
|
+
Omit<TurnStartRecord, "id" | "createdAt" | "updatedAt"> & {
|
|
57
75
|
/** @internal */
|
|
58
76
|
id?: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
77
|
+
}
|
|
78
|
+
>
|
|
61
79
|
| {
|
|
62
80
|
/** @internal */
|
|
63
81
|
kind: "cas_state";
|
|
@@ -71,34 +89,26 @@ export type TurnStartWrite =
|
|
|
71
89
|
|
|
72
90
|
/** @internal */
|
|
73
91
|
export type TurnAnnotationWrite =
|
|
92
|
+
| CreateWrite<CreateProcessTurnAnnotationInput>
|
|
93
|
+
| UpdateWrite<UpdateProcessTurnAnnotationInput>
|
|
94
|
+
| DeleteWrite;
|
|
95
|
+
|
|
96
|
+
/** Mapped-run writes, committed in order before turn starts. @internal */
|
|
97
|
+
export type MappedRunWrite =
|
|
98
|
+
| CreateWrite<CreateMappedRunInput>
|
|
74
99
|
| {
|
|
75
100
|
/** @internal */
|
|
76
|
-
kind: "
|
|
77
|
-
/** @internal */
|
|
78
|
-
input: CreateProcessTurnAnnotationInput;
|
|
79
|
-
}
|
|
80
|
-
| {
|
|
81
|
-
/** @internal */
|
|
82
|
-
kind: "update";
|
|
83
|
-
/** @internal */
|
|
84
|
-
id: string;
|
|
101
|
+
kind: "complete_item";
|
|
85
102
|
/** @internal */
|
|
86
|
-
input:
|
|
103
|
+
input: CompleteMappedItemInput;
|
|
87
104
|
}
|
|
88
105
|
| {
|
|
89
106
|
/** @internal */
|
|
90
|
-
kind: "
|
|
91
|
-
/** @internal */
|
|
92
|
-
id: string;
|
|
107
|
+
kind: "abort_active";
|
|
93
108
|
};
|
|
94
109
|
|
|
95
110
|
/** @internal */
|
|
96
|
-
export type LeafOutcomeSnapshotWrite =
|
|
97
|
-
/** @internal */
|
|
98
|
-
kind: "create";
|
|
99
|
-
/** @internal */
|
|
100
|
-
input: CreateProcessLeafOutcomeSnapshotInput;
|
|
101
|
-
};
|
|
111
|
+
export type LeafOutcomeSnapshotWrite = CreateWrite<CreateProcessLeafOutcomeSnapshotInput>;
|
|
102
112
|
|
|
103
113
|
/** @internal */
|
|
104
114
|
export type WorkerIntent =
|
|
@@ -129,26 +139,9 @@ export type WorkerIntent =
|
|
|
129
139
|
|
|
130
140
|
/** @internal */
|
|
131
141
|
export type PendingExternalSourceFireWrite =
|
|
132
|
-
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
/** @internal */
|
|
136
|
-
input: CreatePendingExternalSourceFireInput;
|
|
137
|
-
}
|
|
138
|
-
| {
|
|
139
|
-
/** @internal */
|
|
140
|
-
kind: "update";
|
|
141
|
-
/** @internal */
|
|
142
|
-
id: string;
|
|
143
|
-
/** @internal */
|
|
144
|
-
input: UpdatePendingExternalSourceFireInput;
|
|
145
|
-
}
|
|
146
|
-
| {
|
|
147
|
-
/** @internal */
|
|
148
|
-
kind: "delete";
|
|
149
|
-
/** @internal */
|
|
150
|
-
id: string;
|
|
151
|
-
};
|
|
142
|
+
| CreateWrite<CreatePendingExternalSourceFireInput>
|
|
143
|
+
| UpdateWrite<UpdatePendingExternalSourceFireInput>
|
|
144
|
+
| DeleteWrite;
|
|
152
145
|
|
|
153
146
|
/** @internal */
|
|
154
147
|
export interface DecisionMetadata {
|
|
@@ -171,6 +164,10 @@ const METADATA_KEY_GROUPS = {
|
|
|
171
164
|
|
|
172
165
|
/** @internal */
|
|
173
166
|
export interface Writes {
|
|
167
|
+
/** Internal scheduling writes do not count as process activity. @internal */
|
|
168
|
+
preserveUpdatedAt?: boolean;
|
|
169
|
+
/** A fenced, successful server-side wait check. Never supplied by extensions. @internal */
|
|
170
|
+
waitForAdmission?: string;
|
|
174
171
|
/** @internal */
|
|
175
172
|
processPatch: UpdateProcessInstanceInput;
|
|
176
173
|
/** @internal */
|
|
@@ -182,11 +179,15 @@ export interface Writes {
|
|
|
182
179
|
/** @internal */
|
|
183
180
|
input: UpdateProcessProjectInput;
|
|
184
181
|
};
|
|
182
|
+
/** Initial bindings, committed before the first worker start. @internal */
|
|
183
|
+
initialProjects?: CreateProcessProjectInput[];
|
|
185
184
|
/** @internal */
|
|
186
185
|
turnRecordWrites: TurnRecordWrite[];
|
|
187
186
|
/** @internal */
|
|
188
187
|
turnStartWrites: TurnStartWrite[];
|
|
189
188
|
/** @internal */
|
|
189
|
+
mappedRunWrites: MappedRunWrite[];
|
|
190
|
+
/** @internal */
|
|
190
191
|
turnAnnotationWrites: TurnAnnotationWrite[];
|
|
191
192
|
/** @internal */
|
|
192
193
|
leafOutcomeSnapshotWrites: LeafOutcomeSnapshotWrite[];
|
|
@@ -221,11 +222,15 @@ export type WriteBuildResult = Writes | WriteBuildFailure;
|
|
|
221
222
|
|
|
222
223
|
export function createWrites(init: Partial<Writes> = {}): Writes {
|
|
223
224
|
return {
|
|
225
|
+
...(init.preserveUpdatedAt ? { preserveUpdatedAt: true } : {}),
|
|
226
|
+
...(init.waitForAdmission ? { waitForAdmission: init.waitForAdmission } : {}),
|
|
224
227
|
processPatch: init.processPatch ?? {},
|
|
225
228
|
changedFields: [...(init.changedFields ?? [])],
|
|
226
229
|
...(init.projectWrite ? { projectWrite: init.projectWrite } : {}),
|
|
230
|
+
...(init.initialProjects ? { initialProjects: [...init.initialProjects] } : {}),
|
|
227
231
|
turnRecordWrites: [...(init.turnRecordWrites ?? [])],
|
|
228
232
|
turnStartWrites: [...(init.turnStartWrites ?? [])],
|
|
233
|
+
mappedRunWrites: [...(init.mappedRunWrites ?? [])],
|
|
229
234
|
turnAnnotationWrites: [...(init.turnAnnotationWrites ?? [])],
|
|
230
235
|
leafOutcomeSnapshotWrites: [...(init.leafOutcomeSnapshotWrites ?? [])],
|
|
231
236
|
events: [...(init.events ?? [])],
|
|
@@ -243,6 +248,7 @@ export function mergeWrites(...writesList: Array<Writes | undefined>): Writes {
|
|
|
243
248
|
for (const writes of writesList) {
|
|
244
249
|
if (!writes) continue;
|
|
245
250
|
Object.assign(merged.processPatch, writes.processPatch);
|
|
251
|
+
if (writes.waitForAdmission) merged.waitForAdmission = writes.waitForAdmission;
|
|
246
252
|
for (const field of writes.changedFields) {
|
|
247
253
|
if (!merged.changedFields.includes(field)) {
|
|
248
254
|
merged.changedFields.push(field);
|
|
@@ -252,8 +258,14 @@ export function mergeWrites(...writesList: Array<Writes | undefined>): Writes {
|
|
|
252
258
|
if (merged.projectWrite) throw new Error("Cannot merge multiple process-project writes");
|
|
253
259
|
merged.projectWrite = writes.projectWrite;
|
|
254
260
|
}
|
|
261
|
+
if (writes.initialProjects) {
|
|
262
|
+
if (merged.initialProjects)
|
|
263
|
+
throw new Error("Cannot merge multiple initial repository bindings");
|
|
264
|
+
merged.initialProjects = writes.initialProjects;
|
|
265
|
+
}
|
|
255
266
|
merged.turnRecordWrites.push(...writes.turnRecordWrites);
|
|
256
267
|
merged.turnStartWrites.push(...writes.turnStartWrites);
|
|
268
|
+
merged.mappedRunWrites.push(...writes.mappedRunWrites);
|
|
257
269
|
merged.turnAnnotationWrites.push(...writes.turnAnnotationWrites);
|
|
258
270
|
merged.leafOutcomeSnapshotWrites.push(...writes.leafOutcomeSnapshotWrites);
|
|
259
271
|
merged.events.push(...writes.events);
|
package/src/process-graph.ts
CHANGED