@leitwerk-dev/server 0.3.1 → 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-BuJCdkvy.d.ts → app-CsuxFZT5.d.ts} +262 -121
- 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-QCHS3X33.js → chunk-FPMDWQF7.js} +2617 -562
- package/dist/chunk-FPMDWQF7.js.map +1 -0
- package/dist/{chunk-HK6BLLHA.js → chunk-MBHRCQFE.js} +2303 -1576
- 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/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 +4 -0
- 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/repositories.d.ts +12 -0
- package/dist/db/repositories.d.ts.map +1 -1
- package/dist/db/schema.d.ts +693 -2
- 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.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.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 +1 -6
- package/dist/process-action-presenter.d.ts.map +1 -1
- 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.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 +5 -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-turn-outcome-writes.d.ts +2 -0
- package/dist/process-engine/writes/build-turn-outcome-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/writes.d.ts +28 -60
- 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-trace.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts +14 -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-model-config.d.ts +4 -0
- package/dist/routes/process-model-config.d.ts.map +1 -0
- package/dist/routes/process-route-helpers.d.ts +8 -9
- 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.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +2 -0
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- 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.js +2 -1
- 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 +115 -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 +131 -40
- package/src/db/execution-inspection-repo.ts +163 -0
- package/src/db/history-window.ts +18 -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 +45 -12
- package/src/db/publication-repo.ts +63 -0
- package/src/db/repositories.ts +17 -0
- package/src/db/schema.ts +103 -1
- 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 +8 -2
- 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 -193
- 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 +7 -8
- package/src/integration-tool-registry.ts +59 -26
- 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 +22 -57
- package/src/process-action-registry.ts +31 -39
- package/src/process-engine/decision.ts +10 -0
- package/src/process-engine/engine.ts +11 -2
- package/src/process-engine/mapped-turns.ts +5 -7
- 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 +9 -13
- package/src/process-engine/ops/start-process.ts +34 -2
- package/src/process-engine/ops/turn-outcome.ts +61 -60
- 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 +21 -5
- 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 +9 -0
- package/src/process-engine/writes/build-process-abort-writes.ts +30 -20
- package/src/process-engine/writes/build-turn-outcome-writes.ts +39 -2
- package/src/process-engine/writes/commit-writes.ts +15 -2
- package/src/process-engine/writes/writes.ts +59 -74
- 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-trace.ts +12 -24
- package/src/process-ui-snapshot-presenter.ts +210 -295
- package/src/routes/future-executions.ts +5 -5
- package/src/routes/launchers.ts +51 -1
- package/src/routes/process-actions.ts +9 -9
- package/src/routes/process-detail.ts +25 -2
- package/src/routes/process-model-config.ts +70 -0
- package/src/routes/process-route-helpers.ts +153 -162
- 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 +2 -0
- package/src/supervisor/worker-event-ingestor.ts +30 -14
- package/src/supervisor/worker-start-payload-builder.ts +17 -0
- package/src/supervisor/worker-supervisor.ts +3 -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/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-MSJXFK33.js +0 -8
- package/dist/chunk-HK6BLLHA.js.map +0 -1
- package/dist/chunk-QCHS3X33.js.map +0 -1
- /package/dist/{app-MSJXFK33.js.map → app-JM4CBTND.js.map} +0 -0
|
@@ -16,6 +16,7 @@ import { generateId } from "../db/repo-helpers.js";
|
|
|
16
16
|
import type { RepositoryBundle } from "../db/repositories.js";
|
|
17
17
|
import type { ProcessActionRegistry } from "../process-action-registry.js";
|
|
18
18
|
import type { ProcessGraphRegistry } from "../process-graph.js";
|
|
19
|
+
import { deferTurnWaitStarts } from "./turn-wait-state.js";
|
|
19
20
|
import { buildServerTransitionWrites } from "./writes/build-server-transition-writes.js";
|
|
20
21
|
import { reserveSelectedTurnStart } from "./writes/reserve-selected-turn-start.js";
|
|
21
22
|
import {
|
|
@@ -129,6 +130,8 @@ export async function planMappedTurnEntries(input: {
|
|
|
129
130
|
const active = input.mappedRuns?.getActiveByInstance(input.process.id) ?? null;
|
|
130
131
|
let activeAborted = false;
|
|
131
132
|
for (let entry = 0; entry <= MAX_EMPTY_MAPPED_ENTRIES; entry += 1) {
|
|
133
|
+
// An empty mapped run may route straight into another gated turn.
|
|
134
|
+
deferTurnWaitStarts(input.processGraphs, input.process, writes);
|
|
132
135
|
const candidate: ProcessInstance = { ...input.process, ...writes.processPatch };
|
|
133
136
|
const startIndex = writes.turnStartWrites.findIndex(
|
|
134
137
|
(write) =>
|
|
@@ -181,12 +184,7 @@ export async function planMappedTurnEntries(input: {
|
|
|
181
184
|
instanceId: input.process.id,
|
|
182
185
|
turnId,
|
|
183
186
|
status: frozen.items.length > 0 ? "active" : "completed",
|
|
184
|
-
items: frozen.items
|
|
185
|
-
itemIndex: item.index,
|
|
186
|
-
itemKey: item.key,
|
|
187
|
-
label: item.label,
|
|
188
|
-
itemJson: item.itemJson,
|
|
189
|
-
})),
|
|
187
|
+
items: frozen.items,
|
|
190
188
|
},
|
|
191
189
|
});
|
|
192
190
|
appendProcessEvent(writes, candidate, {
|
|
@@ -201,7 +199,7 @@ export async function planMappedTurnEntries(input: {
|
|
|
201
199
|
}
|
|
202
200
|
const first = frozen.items[0];
|
|
203
201
|
if (first) {
|
|
204
|
-
start.input.iteration = { runId, itemKey: first.
|
|
202
|
+
start.input.iteration = { runId, itemKey: first.itemKey, itemIndex: 0 };
|
|
205
203
|
return { ok: true };
|
|
206
204
|
}
|
|
207
205
|
writes.turnStartWrites.splice(startIndex, 1);
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
resolveTurnContinuationUserPrompt,
|
|
10
10
|
} from "@leitwerk-dev/protocol";
|
|
11
11
|
import type { ReadonlyPiSessionTree } from "../../pi-session-tree.js";
|
|
12
|
-
import { accept, reject } from "../decision.js";
|
|
12
|
+
import { accept, modelOverrideMetadata, reject } from "../decision.js";
|
|
13
13
|
import { defineOperation } from "../operation.js";
|
|
14
14
|
import { readCurrentPrimaryPathLeafEntryId } from "../state-json.js";
|
|
15
15
|
import type { ProcessEngine, ProcessEngineDeps } from "../types.js";
|
|
@@ -138,18 +138,7 @@ export const ContinueFailedTurn = defineOperation<
|
|
|
138
138
|
stampActorOnEvents(writes, input.options?.actor, "continue_scheduled");
|
|
139
139
|
return accept({
|
|
140
140
|
writes,
|
|
141
|
-
metadata:
|
|
142
|
-
input.options?.nextTurnModelProfileId !== undefined ||
|
|
143
|
-
input.options?.providerOptions !== undefined
|
|
144
|
-
? {
|
|
145
|
-
...(input.options.nextTurnModelProfileId !== undefined
|
|
146
|
-
? { nextTurnModelProfileId: input.options.nextTurnModelProfileId }
|
|
147
|
-
: {}),
|
|
148
|
-
...(input.options.providerOptions !== undefined
|
|
149
|
-
? { providerOptions: input.options.providerOptions }
|
|
150
|
-
: {}),
|
|
151
|
-
}
|
|
152
|
-
: undefined,
|
|
141
|
+
metadata: modelOverrideMetadata(input.options),
|
|
153
142
|
});
|
|
154
143
|
},
|
|
155
144
|
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ProcessObservationUpdate } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
import { planCancelScheduledAction } from "../../future-execution/transition-planner.js";
|
|
3
|
+
import { resolveCurrentExecutionTurnRecordId } from "../../process-execution.js";
|
|
4
|
+
import { accept, reject } from "../decision.js";
|
|
5
|
+
import { defineOperation } from "../operation.js";
|
|
6
|
+
import { writeTurnWait } from "../turn-wait-state.js";
|
|
7
|
+
import { supersedeExecution } from "../writes/build-process-abort-writes.js";
|
|
8
|
+
import { reserveSelectedTurnStart } from "../writes/reserve-selected-turn-start.js";
|
|
9
|
+
import {
|
|
10
|
+
appendProcessEvent,
|
|
11
|
+
applyMetadataPatch,
|
|
12
|
+
applyProcessPatchField,
|
|
13
|
+
createWrites,
|
|
14
|
+
} from "../writes/writes.js";
|
|
15
|
+
|
|
16
|
+
/** Background reads happen outside the process lock; their writes never bypass coordination. @internal */
|
|
17
|
+
export const ApplyProcessObservation = defineOperation<
|
|
18
|
+
"process_observation",
|
|
19
|
+
ProcessObservationUpdate & { instanceId: string },
|
|
20
|
+
void
|
|
21
|
+
>({
|
|
22
|
+
kind: "process_observation",
|
|
23
|
+
label: "Record integration observation",
|
|
24
|
+
decide({ process, deps }, input) {
|
|
25
|
+
const expected = input.expected;
|
|
26
|
+
if (
|
|
27
|
+
expected.id !== process.id ||
|
|
28
|
+
expected.processId !== process.processId ||
|
|
29
|
+
expected.planRevision !== process.planRevision ||
|
|
30
|
+
expected.paramsJson !== process.paramsJson ||
|
|
31
|
+
expected.stateJson !== process.stateJson ||
|
|
32
|
+
expected.selectedTurnId !== process.selectedTurnId ||
|
|
33
|
+
expected.lifecycleStatus !== process.lifecycleStatus ||
|
|
34
|
+
JSON.stringify(expected.currentExecution) !== JSON.stringify(process.currentExecution) ||
|
|
35
|
+
Object.keys(input.metadata ?? {}).some(
|
|
36
|
+
(key) =>
|
|
37
|
+
JSON.stringify(expected.metadata?.[key]) !== JSON.stringify(process.metadata?.[key]),
|
|
38
|
+
) ||
|
|
39
|
+
(input.projectsJson !== undefined &&
|
|
40
|
+
input.projectsJson !== JSON.stringify(deps.projects.listByInstance(process.id)))
|
|
41
|
+
)
|
|
42
|
+
return reject("observation_superseded", "The process changed during the integration read");
|
|
43
|
+
const definition = deps.processGraphs.get(process.processId);
|
|
44
|
+
if (!definition) return reject("process_not_found", "Process definition is unavailable");
|
|
45
|
+
const writes = createWrites({ preserveUpdatedAt: input.preserveUpdatedAt });
|
|
46
|
+
if (input.state !== undefined) {
|
|
47
|
+
const state = definition.stateCodec.parse(input.state);
|
|
48
|
+
applyProcessPatchField(
|
|
49
|
+
writes,
|
|
50
|
+
process,
|
|
51
|
+
"stateJson",
|
|
52
|
+
JSON.stringify(definition.stateCodec.serialize(state)),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (input.metadata)
|
|
56
|
+
applyMetadataPatch(writes, process, { ...process.metadata, ...input.metadata });
|
|
57
|
+
if (input.lifecycleStatus || input.interrupt) {
|
|
58
|
+
if (["completed", "aborted"].includes(process.lifecycleStatus))
|
|
59
|
+
return reject("invalid_transition", "Terminal processes cannot resume maintenance");
|
|
60
|
+
if (input.interrupt && !definition.turns.has(input.interrupt.turnId))
|
|
61
|
+
return reject("invalid_transition", "Maintenance recovery turn is unavailable");
|
|
62
|
+
const recordId = resolveCurrentExecutionTurnRecordId(process, deps.turnStarts);
|
|
63
|
+
const record = recordId ? deps.turnRecords.getById(recordId) : null;
|
|
64
|
+
const start =
|
|
65
|
+
process.currentExecution?.kind === "worker_start"
|
|
66
|
+
? deps.turnStarts.getById(process.currentExecution.id)
|
|
67
|
+
: null;
|
|
68
|
+
supersedeExecution(writes, record, start);
|
|
69
|
+
for (const execution of deps.futureExecutions.listByInstance(process.id)) {
|
|
70
|
+
const plan = planCancelScheduledAction(execution, process.id);
|
|
71
|
+
if (plan) writes.futureExecutionPlans.push(plan);
|
|
72
|
+
}
|
|
73
|
+
writeTurnWait(
|
|
74
|
+
writes,
|
|
75
|
+
{ ...process, metadata: writes.processPatch.metadata ?? process.metadata },
|
|
76
|
+
null,
|
|
77
|
+
);
|
|
78
|
+
applyProcessPatchField(writes, process, "currentExecution", null);
|
|
79
|
+
applyProcessPatchField(
|
|
80
|
+
writes,
|
|
81
|
+
process,
|
|
82
|
+
"selectedTurnId",
|
|
83
|
+
input.lifecycleStatus ? null : (input.interrupt?.turnId ?? process.selectedTurnId),
|
|
84
|
+
);
|
|
85
|
+
applyProcessPatchField(
|
|
86
|
+
writes,
|
|
87
|
+
process,
|
|
88
|
+
"lifecycleStatus",
|
|
89
|
+
input.lifecycleStatus ?? "waiting",
|
|
90
|
+
);
|
|
91
|
+
if (input.interrupt && !input.lifecycleStatus) {
|
|
92
|
+
const turn = definition.turns.get(input.interrupt.turnId)?.definition;
|
|
93
|
+
if (!turn || (turn.kind !== "llm" && turn.kind !== "automatic") || !turn.waitFor)
|
|
94
|
+
return reject(
|
|
95
|
+
"invalid_transition",
|
|
96
|
+
"Maintenance recovery requires an existing gated worker turn",
|
|
97
|
+
);
|
|
98
|
+
reserveSelectedTurnStart(
|
|
99
|
+
writes,
|
|
100
|
+
{ ...process, ...writes.processPatch },
|
|
101
|
+
input.interrupt.turnId,
|
|
102
|
+
turn.kind,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
writes.workerIntent = {
|
|
106
|
+
kind: "stop_with_reason",
|
|
107
|
+
reason: input.interrupt?.reason ?? "MR maintenance finished",
|
|
108
|
+
};
|
|
109
|
+
appendProcessEvent(writes, process, {
|
|
110
|
+
eventType: input.lifecycleStatus
|
|
111
|
+
? `process_${input.lifecycleStatus}`
|
|
112
|
+
: "maintenance_interrupted",
|
|
113
|
+
level: "info",
|
|
114
|
+
message: input.interrupt?.reason ?? "MR maintenance finished",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return accept({ writes });
|
|
118
|
+
},
|
|
119
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Actor } from "@leitwerk-dev/domain";
|
|
2
2
|
import { buildRetryWrites } from "../../process-engine/writes/build-retry-writes.js";
|
|
3
3
|
import { stampActorOnEvents } from "../../process-engine/writes/writes.js";
|
|
4
|
-
import { accept, reject } from "../decision.js";
|
|
4
|
+
import { accept, modelOverrideMetadata, reject } from "../decision.js";
|
|
5
5
|
import { defineOperation } from "../operation.js";
|
|
6
6
|
|
|
7
7
|
export interface RetryFailedTurnInput {
|
|
@@ -49,17 +49,7 @@ export const RetryFailedTurn = defineOperation<"retry_failed_turn", RetryFailedT
|
|
|
49
49
|
stampActorOnEvents(writes, input.actor, "retry_scheduled");
|
|
50
50
|
return accept({
|
|
51
51
|
writes,
|
|
52
|
-
metadata:
|
|
53
|
-
input.nextTurnModelProfileId !== undefined || input.providerOptions !== undefined
|
|
54
|
-
? {
|
|
55
|
-
...(input.nextTurnModelProfileId !== undefined
|
|
56
|
-
? { nextTurnModelProfileId: input.nextTurnModelProfileId }
|
|
57
|
-
: {}),
|
|
58
|
-
...(input.providerOptions !== undefined
|
|
59
|
-
? { providerOptions: input.providerOptions }
|
|
60
|
-
: {}),
|
|
61
|
-
}
|
|
62
|
-
: undefined,
|
|
52
|
+
metadata: modelOverrideMetadata(input),
|
|
63
53
|
});
|
|
64
54
|
},
|
|
65
55
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Actor } from "@leitwerk-dev/domain";
|
|
2
2
|
import { generateId } from "../../db/repo-helpers.js";
|
|
3
|
-
import { accept, reject } from "../decision.js";
|
|
3
|
+
import { accept, modelOverrideMetadata, reject } from "../decision.js";
|
|
4
4
|
import { defineOperation } from "../operation.js";
|
|
5
5
|
import {
|
|
6
6
|
appendProcessEvent,
|
|
@@ -44,7 +44,13 @@ export const RetryStartup = defineOperation<
|
|
|
44
44
|
const id = generateId("tsr");
|
|
45
45
|
const state =
|
|
46
46
|
failed.state.kind === "preparation_failed"
|
|
47
|
-
?
|
|
47
|
+
? {
|
|
48
|
+
...failed.state,
|
|
49
|
+
// A new operator retry must validate current inputs; the previous
|
|
50
|
+
// failure remains on its original start record.
|
|
51
|
+
code: "model_required" as const,
|
|
52
|
+
safeSummary: "LLM start requires retry preparation",
|
|
53
|
+
}
|
|
48
54
|
: failed.state.start.kind === "automatic"
|
|
49
55
|
? { kind: "starting" as const, start: failed.state.start }
|
|
50
56
|
: {
|
|
@@ -92,17 +98,7 @@ export const RetryStartup = defineOperation<
|
|
|
92
98
|
return accept({
|
|
93
99
|
writes,
|
|
94
100
|
data: { startRecordId: id },
|
|
95
|
-
metadata:
|
|
96
|
-
input.nextTurnModelProfileId !== undefined || input.providerOptions !== undefined
|
|
97
|
-
? {
|
|
98
|
-
...(input.nextTurnModelProfileId !== undefined
|
|
99
|
-
? { nextTurnModelProfileId: input.nextTurnModelProfileId }
|
|
100
|
-
: {}),
|
|
101
|
-
...(input.providerOptions !== undefined
|
|
102
|
-
? { providerOptions: input.providerOptions }
|
|
103
|
-
: {}),
|
|
104
|
-
}
|
|
105
|
-
: undefined,
|
|
101
|
+
metadata: modelOverrideMetadata(input),
|
|
106
102
|
});
|
|
107
103
|
},
|
|
108
104
|
});
|
|
@@ -1,20 +1,46 @@
|
|
|
1
1
|
import type { Actor, TurnId } from "@leitwerk-dev/domain";
|
|
2
|
+
import type { WaitingProcessRestart } from "@leitwerk-dev/process-sdk";
|
|
2
3
|
import { buildTurnSelectionWrites } from "../../process-engine/writes/build-turn-selection-writes.js";
|
|
3
|
-
import { accept, noWrites } from "../decision.js";
|
|
4
|
+
import { accept, noWrites, reject } from "../decision.js";
|
|
4
5
|
import { defineOperation } from "../operation.js";
|
|
5
|
-
import { stampActorOnEvents } from "../writes/writes.js";
|
|
6
|
+
import { applyProcessPatchField, stampActorOnEvents } from "../writes/writes.js";
|
|
6
7
|
|
|
7
8
|
export interface StartProcessInput {
|
|
8
9
|
instanceId: string;
|
|
9
10
|
startTurnId: TurnId;
|
|
10
11
|
actor?: Actor;
|
|
11
12
|
onlyIfUnstarted?: boolean;
|
|
13
|
+
restart?: WaitingProcessRestart;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export const StartProcess = defineOperation<"start_process", StartProcessInput, void>({
|
|
15
17
|
kind: "start_process",
|
|
16
18
|
label: "Start process",
|
|
17
19
|
decide(ctx, input) {
|
|
20
|
+
const restart = input.restart;
|
|
21
|
+
if (
|
|
22
|
+
restart &&
|
|
23
|
+
(ctx.process.lifecycleStatus !== "waiting" ||
|
|
24
|
+
ctx.process.currentExecution !== null ||
|
|
25
|
+
ctx.process.selectedTurnId !== restart.expected.turnId ||
|
|
26
|
+
ctx.process.paramsJson !== restart.expected.paramsJson ||
|
|
27
|
+
ctx.process.stateJson !== restart.expected.stateJson)
|
|
28
|
+
) {
|
|
29
|
+
return reject("restart_superseded", "The captured waiting process has changed");
|
|
30
|
+
}
|
|
31
|
+
if (restart && ctx.deps.isNewTurnBlocked?.(input.instanceId)) {
|
|
32
|
+
return reject("session_transfer_in_progress", "A local session transfer is in progress");
|
|
33
|
+
}
|
|
34
|
+
const project = restart?.project
|
|
35
|
+
? ctx.deps.projects.getByInstanceAndKey(input.instanceId, restart.project.key)
|
|
36
|
+
: null;
|
|
37
|
+
if (
|
|
38
|
+
restart?.project &&
|
|
39
|
+
(!project || project.baseBranch !== restart.project.expectedBaseBranch)
|
|
40
|
+
) {
|
|
41
|
+
return reject("restart_superseded", "The captured process repository has changed");
|
|
42
|
+
}
|
|
43
|
+
if (restart) JSON.parse(restart.stateJson);
|
|
18
44
|
if (
|
|
19
45
|
input.onlyIfUnstarted &&
|
|
20
46
|
(ctx.process.lifecycleStatus !== "discovered" ||
|
|
@@ -29,6 +55,12 @@ export const StartProcess = defineOperation<"start_process", StartProcessInput,
|
|
|
29
55
|
trigger: "start",
|
|
30
56
|
});
|
|
31
57
|
if ("ok" in writes) return writes;
|
|
58
|
+
if (restart) {
|
|
59
|
+
applyProcessPatchField(writes, ctx.process, "stateJson", restart.stateJson);
|
|
60
|
+
if (project && restart.project) {
|
|
61
|
+
writes.projectWrite = { id: project.id, input: { baseBranch: restart.project.baseBranch } };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
32
64
|
stampActorOnEvents(writes, input.actor, "turn_selected");
|
|
33
65
|
return accept({ writes });
|
|
34
66
|
},
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
isAutomaticTurnDefinition,
|
|
10
10
|
isLlmTurnDefinition,
|
|
11
11
|
parseStructuralProcessState,
|
|
12
|
+
type ResolvedOutcomeContract,
|
|
12
13
|
} from "@leitwerk-dev/process-sdk";
|
|
13
14
|
import { validateTurnOutcomeCorrelation } from "../../domain-logic/turn-record-guards.js";
|
|
14
15
|
import { captureLeafOutcomeSnapshot } from "../../leaf-outcome-snapshot-capture.js";
|
|
@@ -95,11 +96,20 @@ function resolveOutcomePublication(input: {
|
|
|
95
96
|
turnId: string;
|
|
96
97
|
outcome: string;
|
|
97
98
|
turnPublishedProduct: string | null;
|
|
99
|
+
outcomeContract?: ResolvedOutcomeContract;
|
|
98
100
|
}): {
|
|
99
101
|
productName: string | null;
|
|
100
102
|
markdownParameterName: string | null;
|
|
101
103
|
resultSummaryParameter?: string;
|
|
102
104
|
} {
|
|
105
|
+
if (input.outcomeContract) {
|
|
106
|
+
const outcome = input.outcomeContract.outcomes[input.outcome];
|
|
107
|
+
return {
|
|
108
|
+
productName: outcome?.publishedProduct ?? input.outcomeContract.publishedProduct,
|
|
109
|
+
markdownParameterName: outcome?.turnResultMarkdownParameter ?? null,
|
|
110
|
+
resultSummaryParameter: outcome?.resultSummaryParameter,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
103
113
|
const definition = input.processGraphs.get(input.processId)?.turns.get(input.turnId)?.definition;
|
|
104
114
|
if (!definition || (!isLlmTurnDefinition(definition) && !isAutomaticTurnDefinition(definition))) {
|
|
105
115
|
return { productName: input.turnPublishedProduct, markdownParameterName: null };
|
|
@@ -158,6 +168,16 @@ export const TurnOutcome = defineOperation<"turn_outcome", TurnOutcomeInput, voi
|
|
|
158
168
|
input.onRecorded?.();
|
|
159
169
|
},
|
|
160
170
|
async decide(ctx, input) {
|
|
171
|
+
const currentStart =
|
|
172
|
+
ctx.process.currentExecution?.kind === "worker_start"
|
|
173
|
+
? ctx.deps.turnStarts.getById(ctx.process.currentExecution.id)
|
|
174
|
+
: null;
|
|
175
|
+
const outcomeContract =
|
|
176
|
+
currentStart?.state.kind === "accepted" && currentStart.state.start?.kind === "llm"
|
|
177
|
+
? (currentStart.state.start.outcomeContract as unknown as
|
|
178
|
+
| ResolvedOutcomeContract
|
|
179
|
+
| undefined)
|
|
180
|
+
: undefined;
|
|
161
181
|
const initialPayload = input.payload;
|
|
162
182
|
const turnGraph = getProcessTurnGraph(
|
|
163
183
|
ctx.deps.processGraphs,
|
|
@@ -171,13 +191,10 @@ export const TurnOutcome = defineOperation<"turn_outcome", TurnOutcomeInput, voi
|
|
|
171
191
|
turnId: initialPayload.turnId,
|
|
172
192
|
outcome: initialPayload.outcome,
|
|
173
193
|
turnPublishedProduct: turnGraph?.publishedProduct ?? null,
|
|
194
|
+
outcomeContract,
|
|
174
195
|
});
|
|
175
196
|
const payload = resolveEffectiveOutcomePayload({ payload: initialPayload, publication });
|
|
176
197
|
const publishedProduct = publication.productName;
|
|
177
|
-
const currentStart =
|
|
178
|
-
ctx.process.currentExecution?.kind === "worker_start"
|
|
179
|
-
? ctx.deps.turnStarts.getById(ctx.process.currentExecution.id)
|
|
180
|
-
: null;
|
|
181
198
|
const expected =
|
|
182
199
|
currentStart?.state.kind === "accepted" ? currentStart.state.turnRecordId : null;
|
|
183
200
|
const correlationError = validateTurnOutcomeCorrelation(ctx.process, payload, expected);
|
|
@@ -196,7 +213,10 @@ export const TurnOutcome = defineOperation<"turn_outcome", TurnOutcomeInput, voi
|
|
|
196
213
|
}
|
|
197
214
|
const requiredMarkdownError = validateRequiredTurnResultMarkdown({
|
|
198
215
|
payload,
|
|
199
|
-
required:
|
|
216
|
+
required: outcomeContract
|
|
217
|
+
? outcomeContract.turnResultMarkdown?.mode !== "none" &&
|
|
218
|
+
outcomeContract.turnResultMarkdown?.required === true
|
|
219
|
+
: turnGraph?.turnResultMarkdownRequired === true,
|
|
200
220
|
});
|
|
201
221
|
if (requiredMarkdownError) {
|
|
202
222
|
return reject(requiredMarkdownError.code, requiredMarkdownError.message);
|
|
@@ -274,70 +294,43 @@ export const TurnOutcome = defineOperation<"turn_outcome", TurnOutcomeInput, voi
|
|
|
274
294
|
});
|
|
275
295
|
}
|
|
276
296
|
const existing = ctx.deps.turnRecords.getById(payload.turnRecordId);
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
turnResultMarkdown: payload.turnResultMarkdown ?? null,
|
|
302
|
-
errorSummary: null,
|
|
303
|
-
errorClass: null,
|
|
304
|
-
startedAt: recordedAt,
|
|
305
|
-
endedAt: recordedAt,
|
|
306
|
-
};
|
|
297
|
+
const completion = {
|
|
298
|
+
turnType: payload.turnType,
|
|
299
|
+
status: "succeeded" as const,
|
|
300
|
+
resultPiEntryId: payload.resultPiEntryId ?? null,
|
|
301
|
+
turnResultMarkdown: payload.turnResultMarkdown ?? null,
|
|
302
|
+
endedAt: recordedAt,
|
|
303
|
+
};
|
|
304
|
+
const completedTurnRecord: ProcessTurnRecord = {
|
|
305
|
+
...(existing ?? {
|
|
306
|
+
id: payload.turnRecordId,
|
|
307
|
+
instanceId: input.instanceId,
|
|
308
|
+
turnId: payload.turnId,
|
|
309
|
+
attemptNumber: 1,
|
|
310
|
+
parentTurnRecordId: null,
|
|
311
|
+
pathType: payload.pathType ?? "primary",
|
|
312
|
+
forkPiEntryId: payload.forkPiEntryId ?? null,
|
|
313
|
+
modelProfileId: null,
|
|
314
|
+
startedAt: recordedAt,
|
|
315
|
+
}),
|
|
316
|
+
...completion,
|
|
317
|
+
turnType: existing ? (payload.turnType ?? existing.turnType) : payload.turnType,
|
|
318
|
+
errorSummary: null,
|
|
319
|
+
errorClass: null,
|
|
320
|
+
};
|
|
307
321
|
if (existing) {
|
|
308
322
|
baseWrites.turnRecordWrites.push({
|
|
309
323
|
kind: "update",
|
|
310
324
|
id: payload.turnRecordId,
|
|
311
|
-
input:
|
|
312
|
-
turnType: payload.turnType,
|
|
313
|
-
status: "succeeded",
|
|
314
|
-
resultPiEntryId: payload.resultPiEntryId ?? null,
|
|
315
|
-
turnResultMarkdown: payload.turnResultMarkdown ?? null,
|
|
316
|
-
endedAt: recordedAt,
|
|
317
|
-
},
|
|
325
|
+
input: completion,
|
|
318
326
|
});
|
|
319
327
|
} else {
|
|
328
|
+
const { modelProfileId, ...recordInput } = completedTurnRecord;
|
|
320
329
|
baseWrites.turnRecordWrites.push({
|
|
321
330
|
kind: "create",
|
|
322
331
|
input: {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
turnId: completedTurnRecord.turnId,
|
|
326
|
-
turnType: completedTurnRecord.turnType,
|
|
327
|
-
status: completedTurnRecord.status,
|
|
328
|
-
attemptNumber: completedTurnRecord.attemptNumber,
|
|
329
|
-
parentTurnRecordId: completedTurnRecord.parentTurnRecordId,
|
|
330
|
-
pathType: completedTurnRecord.pathType,
|
|
331
|
-
forkPiEntryId: completedTurnRecord.forkPiEntryId,
|
|
332
|
-
resultPiEntryId: completedTurnRecord.resultPiEntryId,
|
|
333
|
-
...(completedTurnRecord.modelProfileId !== null
|
|
334
|
-
? { modelProfileId: completedTurnRecord.modelProfileId }
|
|
335
|
-
: {}),
|
|
336
|
-
turnResultMarkdown: completedTurnRecord.turnResultMarkdown,
|
|
337
|
-
errorSummary: completedTurnRecord.errorSummary,
|
|
338
|
-
errorClass: completedTurnRecord.errorClass,
|
|
339
|
-
startedAt: completedTurnRecord.startedAt,
|
|
340
|
-
endedAt: completedTurnRecord.endedAt,
|
|
332
|
+
...recordInput,
|
|
333
|
+
...(modelProfileId !== null ? { modelProfileId } : {}),
|
|
341
334
|
},
|
|
342
335
|
});
|
|
343
336
|
}
|
|
@@ -357,6 +350,7 @@ export const TurnOutcome = defineOperation<"turn_outcome", TurnOutcomeInput, voi
|
|
|
357
350
|
processActionRegistry,
|
|
358
351
|
mappedRuns: ctx.deps.mappedRuns,
|
|
359
352
|
iteration: currentStart?.iteration ?? null,
|
|
353
|
+
outcomeContract: outcomeContract ? { ...outcomeContract } : undefined,
|
|
360
354
|
});
|
|
361
355
|
if (isWriteBuildFailure(outcomeWrites)) {
|
|
362
356
|
return reject(outcomeWrites.code, outcomeWrites.message);
|
|
@@ -456,7 +450,14 @@ export const TurnOutcome = defineOperation<"turn_outcome", TurnOutcomeInput, voi
|
|
|
456
450
|
...mergedWrites.processPatch,
|
|
457
451
|
stateJson: mergedWrites.processPatch.stateJson ?? ctx.process.stateJson,
|
|
458
452
|
};
|
|
453
|
+
const mappedWrite = mergedWrites.mappedRunWrites.find(
|
|
454
|
+
(write) =>
|
|
455
|
+
write.kind === "complete_item" && write.input.turnRecordId === completedTurnRecord.id,
|
|
456
|
+
);
|
|
459
457
|
const snapshotInput = await captureLeafOutcomeSnapshot({
|
|
458
|
+
...(mappedWrite?.kind === "complete_item"
|
|
459
|
+
? { mappedResult: JSON.parse(mappedWrite.input.resultJson) as unknown }
|
|
460
|
+
: {}),
|
|
460
461
|
process: capturedProcess,
|
|
461
462
|
projects,
|
|
462
463
|
processActionRegistry,
|