@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
|
@@ -3,6 +3,7 @@ import type { ProcessLaunchPlan } from "@leitwerk-dev/process-sdk";
|
|
|
3
3
|
import type { LeitwerkConfig } from "../config/config-types.js";
|
|
4
4
|
import type { ProcessActionRegistry } from "../process-action-registry.js";
|
|
5
5
|
import type { ProcessGraphRegistry } from "../process-graph.js";
|
|
6
|
+
import type { ScopedSettingsService } from "../scoped-settings-service.js";
|
|
6
7
|
import { constructPolicySnapshot, ProcessModelPolicyConfigurationError } from "./construct.js";
|
|
7
8
|
import { recoverPreparation, resolveTurn, validateSelection } from "./evaluate.js";
|
|
8
9
|
import { fingerprintPolicy } from "./fingerprint.js";
|
|
@@ -23,6 +24,7 @@ import type {
|
|
|
23
24
|
ProcessModelPolicyFingerprintSubject,
|
|
24
25
|
ProcessModelPolicyProjectionByKind,
|
|
25
26
|
ProcessModelPolicyProjectionKind,
|
|
27
|
+
ProcessModelPolicyProjectionSubject,
|
|
26
28
|
ProcessModelPolicyProjectionSubjectFor,
|
|
27
29
|
ServerProcessModelPolicy,
|
|
28
30
|
} from "./types.js";
|
|
@@ -33,6 +35,7 @@ export type {
|
|
|
33
35
|
PersistedModelIntegrity,
|
|
34
36
|
PersistedModelIntegrityIssue,
|
|
35
37
|
PrepareLaunchPlanOptions,
|
|
38
|
+
ProcessModelAvailabilitySnapshot,
|
|
36
39
|
ProcessModelPolicyEvaluation,
|
|
37
40
|
ProcessModelPolicyEvaluationSubject,
|
|
38
41
|
ProcessModelPolicyFingerprintSubject,
|
|
@@ -47,6 +50,7 @@ export type {
|
|
|
47
50
|
ProjectedProcessModelConfiguration,
|
|
48
51
|
ServerProcessModelPolicy,
|
|
49
52
|
} from "./types.js";
|
|
53
|
+
export { isPinnedModelSelection } from "./types.js";
|
|
50
54
|
export { ProcessModelPolicyConfigurationError };
|
|
51
55
|
|
|
52
56
|
function resolutionMode(
|
|
@@ -112,17 +116,55 @@ export function createServerProcessModelPolicy(input: {
|
|
|
112
116
|
config: LeitwerkConfig;
|
|
113
117
|
processGraphs: ProcessGraphRegistry;
|
|
114
118
|
processActionRegistry: Pick<ProcessActionRegistry, "getTurnDefinition">;
|
|
119
|
+
scopedSettings?: Pick<ScopedSettingsService, "modelDefault">;
|
|
115
120
|
}): ServerProcessModelPolicy {
|
|
116
121
|
const snapshot = constructPolicySnapshot(input);
|
|
122
|
+
function scopedSnapshot(
|
|
123
|
+
processId: string,
|
|
124
|
+
process?: ProcessInstance,
|
|
125
|
+
plan?: ProcessLaunchPlan,
|
|
126
|
+
): PolicySnapshot {
|
|
127
|
+
if (!input.scopedSettings) return snapshot;
|
|
128
|
+
const policy = snapshot.processesById.get(processId);
|
|
129
|
+
if (!policy) return snapshot;
|
|
130
|
+
const processesById = new Map(snapshot.processesById);
|
|
131
|
+
processesById.set(processId, {
|
|
132
|
+
...policy,
|
|
133
|
+
scopedProfileIdForTurn: (turnId) =>
|
|
134
|
+
input.scopedSettings?.modelDefault(processId, turnId, process, plan) ?? null,
|
|
135
|
+
});
|
|
136
|
+
return { ...snapshot, processesById };
|
|
137
|
+
}
|
|
138
|
+
function projectionSnapshot(request: ProcessModelPolicyProjectionSubject): PolicySnapshot {
|
|
139
|
+
return request.kind === "process_configuration"
|
|
140
|
+
? scopedSnapshot(request.process.processId, request.process)
|
|
141
|
+
: request.kind === "launcher_preview"
|
|
142
|
+
? scopedSnapshot(request.processId, undefined, request.plan)
|
|
143
|
+
: snapshot;
|
|
144
|
+
}
|
|
145
|
+
|
|
117
146
|
return Object.freeze({
|
|
118
147
|
prepareLaunchPlan: (launchPlan: ProcessLaunchPlan, opts?: PrepareLaunchPlanOptions) =>
|
|
119
|
-
prepareLaunchPlan(
|
|
148
|
+
prepareLaunchPlan(
|
|
149
|
+
scopedSnapshot(launchPlan.processId, undefined, launchPlan),
|
|
150
|
+
launchPlan,
|
|
151
|
+
opts,
|
|
152
|
+
),
|
|
120
153
|
inspectPersistedState: (process: ProcessInstance) =>
|
|
121
154
|
inspectPersistedModelIntegrity(snapshot, process),
|
|
122
|
-
evaluate: (request: ProcessModelPolicyEvaluationSubject) =>
|
|
155
|
+
evaluate: (request: ProcessModelPolicyEvaluationSubject) =>
|
|
156
|
+
evaluateSubject(
|
|
157
|
+
request.kind === "process_turn" || request.kind === "preparation_recovery"
|
|
158
|
+
? scopedSnapshot(request.process.processId, request.process)
|
|
159
|
+
: request.kind === "launch_plan_turn"
|
|
160
|
+
? scopedSnapshot(request.plan.processId, undefined, request.plan)
|
|
161
|
+
: snapshot,
|
|
162
|
+
request,
|
|
163
|
+
),
|
|
123
164
|
project: <K extends ProcessModelPolicyProjectionKind>(
|
|
124
165
|
request: ProcessModelPolicyProjectionSubjectFor<K>,
|
|
125
|
-
) =>
|
|
166
|
+
) =>
|
|
167
|
+
projectPolicy(projectionSnapshot(request), request) as ProcessModelPolicyProjectionByKind[K],
|
|
126
168
|
fingerprint: (request: ProcessModelPolicyFingerprintSubject) =>
|
|
127
169
|
fingerprintPolicy(snapshot, request),
|
|
128
170
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { trimToNull } from "@leitwerk-dev/domain";
|
|
2
|
+
import { presentProcessModelPolicyFailure } from "../process-model-policy-presenter.js";
|
|
3
|
+
import { resolveDefault, resolveTurn } from "./evaluate.js";
|
|
3
4
|
import {
|
|
4
5
|
existingTurnSelectionFromProcess,
|
|
5
6
|
modelConfigurationFromLaunchInput,
|
|
@@ -40,10 +41,8 @@ function projectProfiles(
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
function sourceForPreview(
|
|
44
|
-
source
|
|
45
|
-
): ProjectedModelResolutionSource {
|
|
46
|
-
return source === "action_override" ? "instance_turn_config" : (source ?? "none");
|
|
44
|
+
function sourceForPreview(source: ProjectedModelResolutionSource): ProjectedModelResolutionSource {
|
|
45
|
+
return source === "action_override" ? "instance_turn_config" : source;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
function defaultProjection(
|
|
@@ -51,24 +50,19 @@ function defaultProjection(
|
|
|
51
50
|
configuration: ValidModelConfiguration,
|
|
52
51
|
): ProjectedModelDefault {
|
|
53
52
|
const policy = snapshot.processesById.get(configuration.processId);
|
|
54
|
-
const
|
|
55
|
-
const catalogId =
|
|
56
|
-
snapshot.profiles.find(
|
|
57
|
-
(profile) => !policy?.allowedProfileIds || policy.allowedProfileIds.has(profile.id),
|
|
58
|
-
)?.id ?? null;
|
|
59
|
-
const instanceId = configuration.defaultProfileId ?? null;
|
|
60
|
-
const effective = instanceId ?? processConfigId ?? catalogId;
|
|
53
|
+
const { selection } = resolveDefault(snapshot, configuration);
|
|
61
54
|
return {
|
|
62
|
-
processConfigModelProfileId:
|
|
63
|
-
instanceModelProfileId:
|
|
64
|
-
effectiveModelProfileId:
|
|
65
|
-
source:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
55
|
+
processConfigModelProfileId: trimToNull(policy?.defaultProfileId),
|
|
56
|
+
instanceModelProfileId: configuration.defaultProfileId ?? null,
|
|
57
|
+
effectiveModelProfileId: selection?.modelProfileId ?? null,
|
|
58
|
+
source:
|
|
59
|
+
selection?.provenance.source === "instance_default"
|
|
60
|
+
? "instance"
|
|
61
|
+
: selection?.provenance.source === "process_config_default"
|
|
62
|
+
? "process_config"
|
|
63
|
+
: selection
|
|
64
|
+
? "catalog_default"
|
|
65
|
+
: "none",
|
|
72
66
|
};
|
|
73
67
|
}
|
|
74
68
|
|
|
@@ -113,43 +107,10 @@ export function projectPolicy(
|
|
|
113
107
|
};
|
|
114
108
|
}
|
|
115
109
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
defaultModel: {
|
|
122
|
-
source: defaultModel.source,
|
|
123
|
-
profile: defaultModel.effectiveModelProfileId
|
|
124
|
-
? (profilesById.get(defaultModel.effectiveModelProfileId) ?? null)
|
|
125
|
-
: null,
|
|
126
|
-
},
|
|
127
|
-
turns: [...(policy?.llmTurnIds ?? [])].map((turnId) => {
|
|
128
|
-
const result = resolveTurn(
|
|
129
|
-
snapshot,
|
|
130
|
-
configuration,
|
|
131
|
-
turnId,
|
|
132
|
-
"resolve",
|
|
133
|
-
{ kind: "none" },
|
|
134
|
-
{ kind: "inherit" },
|
|
135
|
-
request.availability,
|
|
136
|
-
);
|
|
137
|
-
return {
|
|
138
|
-
turnId,
|
|
139
|
-
description: policy?.turnDescriptions[turnId] ?? turnId,
|
|
140
|
-
effective: {
|
|
141
|
-
source: sourceForPreview(result.selection?.provenance.source),
|
|
142
|
-
profile: result.selection
|
|
143
|
-
? (profilesById.get(result.selection.modelProfileId) ?? null)
|
|
144
|
-
: null,
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
}),
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const configuration = modelConfigurationFromProcess(request.process);
|
|
152
|
-
const selectedTurn = existingTurnSelectionFromProcess(request.process);
|
|
110
|
+
const configuration =
|
|
111
|
+
request.kind === "launcher_preview"
|
|
112
|
+
? modelConfigurationFromLaunchInput(processId, request.modelConfig)
|
|
113
|
+
: modelConfigurationFromProcess(request.process);
|
|
153
114
|
if (configuration.kind === "invalid") {
|
|
154
115
|
return {
|
|
155
116
|
state: { kind: "blocked", issues: configuration.issues },
|
|
@@ -169,13 +130,29 @@ export function projectPolicy(
|
|
|
169
130
|
const turns = [...(policy?.llmTurnIds ?? [])].map((turnId) => {
|
|
170
131
|
const instanceModelProfileId = configuration.turnProfileIds.get(turnId) ?? null;
|
|
171
132
|
const processConfigModelProfileId = trimToNull(policy?.turnProfileIds[turnId]);
|
|
133
|
+
const resolved = resolveTurn(
|
|
134
|
+
snapshot,
|
|
135
|
+
configuration,
|
|
136
|
+
turnId,
|
|
137
|
+
"resolve",
|
|
138
|
+
{ kind: "none" },
|
|
139
|
+
{ kind: "inherit" },
|
|
140
|
+
request.availability,
|
|
141
|
+
);
|
|
172
142
|
return {
|
|
173
143
|
turnId,
|
|
144
|
+
effectiveModelProfileId: resolved.selection?.modelProfileId ?? null,
|
|
145
|
+
effectiveSource: resolved.selection?.provenance.source ?? ("none" as const),
|
|
146
|
+
...(!resolved.ok ? { effectiveError: presentProcessModelPolicyFailure(resolved) } : {}),
|
|
174
147
|
description: policy?.turnDescriptions[turnId] ?? turnId,
|
|
175
148
|
pathType: policy?.turnPathTypes[turnId] ?? "primary",
|
|
176
149
|
processConfigModelProfileId,
|
|
177
150
|
instanceModelProfileId,
|
|
178
|
-
|
|
151
|
+
fixedModelProfileId: policy?.purposeProfileIdsByTurn[turnId] ?? null,
|
|
152
|
+
effectiveConfiguredModelProfileId:
|
|
153
|
+
policy?.purposeProfileIdsByTurn[turnId] ??
|
|
154
|
+
instanceModelProfileId ??
|
|
155
|
+
processConfigModelProfileId,
|
|
179
156
|
source: instanceModelProfileId
|
|
180
157
|
? ("instance" as const)
|
|
181
158
|
: processConfigModelProfileId
|
|
@@ -183,30 +160,39 @@ export function projectPolicy(
|
|
|
183
160
|
: ("default" as const),
|
|
184
161
|
};
|
|
185
162
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
163
|
+
|
|
164
|
+
if (request.kind === "launcher_preview") {
|
|
165
|
+
const profilesById = new Map(profiles.map((profile) => [profile.id, profile]));
|
|
166
|
+
return {
|
|
167
|
+
defaultModel: {
|
|
168
|
+
source: defaultModel.source,
|
|
169
|
+
profile: profilesById.get(defaultModel.effectiveModelProfileId ?? "") ?? null,
|
|
170
|
+
},
|
|
171
|
+
turns: turns.map((turn) => ({
|
|
172
|
+
turnId: turn.turnId,
|
|
173
|
+
description: turn.description,
|
|
174
|
+
effective: {
|
|
175
|
+
source: sourceForPreview(turn.effectiveSource),
|
|
176
|
+
...(turn.effectiveError ? { error: turn.effectiveError } : {}),
|
|
177
|
+
profile: profilesById.get(turn.effectiveModelProfileId ?? "") ?? null,
|
|
178
|
+
},
|
|
179
|
+
})),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const selectedTurn = existingTurnSelectionFromProcess(request.process);
|
|
198
184
|
return {
|
|
199
185
|
state: { kind: "ready" },
|
|
200
186
|
profiles,
|
|
201
187
|
defaultModel,
|
|
202
188
|
turns,
|
|
203
189
|
effectiveSelectedTurn:
|
|
204
|
-
selectedTurn.kind === "selected"
|
|
190
|
+
selectedTurn.kind === "selected"
|
|
205
191
|
? {
|
|
206
192
|
turnId: selectedTurn.turnId,
|
|
207
193
|
description: policy?.turnDescriptions[selectedTurn.turnId] ?? selectedTurn.turnId,
|
|
208
|
-
modelProfileId:
|
|
209
|
-
source:
|
|
194
|
+
modelProfileId: selectedTurn.selection.modelProfileId,
|
|
195
|
+
source: selectedTurn.selection.provenance.source,
|
|
210
196
|
}
|
|
211
197
|
: null,
|
|
212
198
|
};
|
|
@@ -162,6 +162,8 @@ export type ProcessModelPolicyFailure = ProcessModelPolicyFailureBase &
|
|
|
162
162
|
/** @internal */
|
|
163
163
|
readonly source: "configuration" | "selection_provenance";
|
|
164
164
|
/** @internal */
|
|
165
|
+
readonly message?: string;
|
|
166
|
+
/** @internal */
|
|
165
167
|
readonly issues: readonly (
|
|
166
168
|
| PersistedModelConfigurationIssue
|
|
167
169
|
| PersistedModelSelectionIssue
|
|
@@ -247,6 +249,8 @@ export interface ProjectedLauncherModelPreview {
|
|
|
247
249
|
readonly description: string;
|
|
248
250
|
/** @internal */
|
|
249
251
|
readonly effective: {
|
|
252
|
+
/** @internal */
|
|
253
|
+
readonly error?: string;
|
|
250
254
|
/** @internal */
|
|
251
255
|
readonly source: ProjectedModelResolutionSource;
|
|
252
256
|
/** @internal */
|
|
@@ -299,6 +303,14 @@ export type ProjectedProcessModelConfiguration = {
|
|
|
299
303
|
/** @internal */
|
|
300
304
|
readonly effectiveConfiguredModelProfileId: string | null;
|
|
301
305
|
/** @internal */
|
|
306
|
+
readonly fixedModelProfileId: string | null;
|
|
307
|
+
/** @internal */
|
|
308
|
+
readonly effectiveModelProfileId: string | null;
|
|
309
|
+
/** @internal */
|
|
310
|
+
readonly effectiveSource: ProcessSelectedTurnModelSource | "none";
|
|
311
|
+
/** @internal */
|
|
312
|
+
readonly effectiveError?: string;
|
|
313
|
+
/** @internal */
|
|
302
314
|
readonly source: "instance" | "process_config" | "default";
|
|
303
315
|
}[];
|
|
304
316
|
};
|
|
@@ -402,6 +414,8 @@ export type ProcessModelPolicyProjectionSubject =
|
|
|
402
414
|
/** @internal */
|
|
403
415
|
readonly kind: "launcher_preview";
|
|
404
416
|
/** @internal */
|
|
417
|
+
readonly plan?: ProcessLaunchPlan;
|
|
418
|
+
/** @internal */
|
|
405
419
|
readonly processId: string;
|
|
406
420
|
/** @internal */
|
|
407
421
|
readonly modelConfig: LaunchModelConfigInput;
|
|
@@ -479,10 +493,12 @@ export interface PolicyProcess {
|
|
|
479
493
|
readonly turnProfileIds: Readonly<Record<string, string | null>>;
|
|
480
494
|
readonly llmTurnIds: ReadonlySet<string>;
|
|
481
495
|
readonly purposeProfileIdsByTurn: Readonly<Record<string, string>>;
|
|
496
|
+
readonly scopedProfileIdForTurn?: (turnId: string) => string | null;
|
|
482
497
|
readonly turnDescriptions: Readonly<Record<string, string>>;
|
|
483
498
|
readonly turnPathTypes: Readonly<Record<string, string>>;
|
|
484
499
|
}
|
|
485
500
|
export interface PolicySnapshot {
|
|
501
|
+
readonly defaultProfileId: string;
|
|
486
502
|
readonly profiles: readonly PolicyProfile[];
|
|
487
503
|
readonly profilesById: ReadonlyMap<string, PolicyProfile>;
|
|
488
504
|
readonly processesById: ReadonlyMap<string, PolicyProcess>;
|
|
@@ -498,3 +514,13 @@ export function provenanceKindForSource(
|
|
|
498
514
|
? "explicit"
|
|
499
515
|
: "inherited";
|
|
500
516
|
}
|
|
517
|
+
|
|
518
|
+
/** Launch/action choices stay pinned when inherited defaults are refreshed. @internal */
|
|
519
|
+
export function isPinnedModelSelection(
|
|
520
|
+
selection: DurableModelSelection | null | undefined,
|
|
521
|
+
): boolean {
|
|
522
|
+
return (
|
|
523
|
+
selection?.provenance.source === "action_override" ||
|
|
524
|
+
selection?.provenance.source === "launch_override"
|
|
525
|
+
);
|
|
526
|
+
}
|
|
@@ -37,9 +37,12 @@ export function presentProcessModelPolicyFailure(failure: ProcessModelPolicyFail
|
|
|
37
37
|
case "model_unavailable":
|
|
38
38
|
return failure.reason ?? "The selected model is unavailable";
|
|
39
39
|
case "invalid_model_configuration":
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
return (
|
|
41
|
+
failure.message ??
|
|
42
|
+
(failure.source === "selection_provenance"
|
|
43
|
+
? "Persisted model selection provenance is invalid"
|
|
44
|
+
: "Persisted model configuration is invalid")
|
|
45
|
+
);
|
|
43
46
|
case "stale_evaluation_snapshot":
|
|
44
47
|
return "Model availability changed repeatedly during evaluation";
|
|
45
48
|
}
|
|
@@ -90,6 +93,7 @@ export function presentLauncherModelConfigPreview(
|
|
|
90
93
|
turnId: turn.turnId,
|
|
91
94
|
description: turn.description,
|
|
92
95
|
effective: {
|
|
96
|
+
...(turn.effective.error ? { error: turn.effective.error } : {}),
|
|
93
97
|
source: turn.effective.source,
|
|
94
98
|
profile: turn.effective.profile ? presentModelProfileOption(turn.effective.profile) : null,
|
|
95
99
|
},
|
|
@@ -2,6 +2,7 @@ import type { ExtensionProcessDefinition } from "@leitwerk-dev/process-sdk";
|
|
|
2
2
|
import { parseDurationMs } from "@leitwerk-dev/watcher-utils";
|
|
3
3
|
import { preflightHostDocker } from "@leitwerk-dev/worker-runners/local";
|
|
4
4
|
import type { LeitwerkConfig } from "./config/config-types.js";
|
|
5
|
+
import { resolveKubernetesDockerIsolation } from "./config/kubernetes-docker-isolation.js";
|
|
5
6
|
|
|
6
7
|
export interface ProcessRuntimeAvailabilityDeps {
|
|
7
8
|
config: LeitwerkConfig;
|
|
@@ -11,8 +12,9 @@ export interface ProcessRuntimeAvailabilityDeps {
|
|
|
11
12
|
|
|
12
13
|
export interface ResolvedKubernetesDockerConfig {
|
|
13
14
|
runtimeClassName: string;
|
|
15
|
+
nodeSelector?: Record<string, string>;
|
|
14
16
|
hostUsers?: boolean;
|
|
15
|
-
|
|
17
|
+
isolation?: "gvisor" | "virtual-machine";
|
|
16
18
|
processStorageClassName: string;
|
|
17
19
|
network?: import("./config/config-types.js").KubernetesDockerConfig["network"];
|
|
18
20
|
}
|
|
@@ -22,16 +24,19 @@ export function resolveKubernetesDockerConfig(
|
|
|
22
24
|
config: LeitwerkConfig,
|
|
23
25
|
): ResolvedKubernetesDockerConfig | undefined {
|
|
24
26
|
const docker = config.kubernetes?.docker;
|
|
27
|
+
const { isolation, errors } = resolveKubernetesDockerIsolation(docker);
|
|
25
28
|
if (
|
|
26
29
|
!docker?.runtime_class_name?.trim() ||
|
|
27
|
-
|
|
30
|
+
errors.length > 0 ||
|
|
31
|
+
(isolation === undefined && typeof docker.host_users !== "boolean") ||
|
|
28
32
|
!docker.process_storage_class_name?.trim()
|
|
29
33
|
) {
|
|
30
34
|
return undefined;
|
|
31
35
|
}
|
|
32
36
|
return {
|
|
33
37
|
runtimeClassName: docker.runtime_class_name,
|
|
34
|
-
...(docker.
|
|
38
|
+
...(docker.node_selector ? { nodeSelector: { ...docker.node_selector } } : {}),
|
|
39
|
+
...(isolation ? { isolation } : { hostUsers: docker.host_users }),
|
|
35
40
|
processStorageClassName: docker.process_storage_class_name,
|
|
36
41
|
...(docker.network ? { network: docker.network } : {}),
|
|
37
42
|
};
|
|
@@ -49,7 +54,7 @@ export async function assertProcessRuntimeAvailable(
|
|
|
49
54
|
case "kubernetes":
|
|
50
55
|
if (!resolveKubernetesDockerConfig(deps.config)) {
|
|
51
56
|
throw new Error(
|
|
52
|
-
"This process requires Docker; configure kubernetes.docker.runtime_class_name,
|
|
57
|
+
"This process requires Docker; configure kubernetes.docker.runtime_class_name, process_storage_class_name, and either isolation or host_users",
|
|
53
58
|
);
|
|
54
59
|
}
|
|
55
60
|
return;
|
|
@@ -1,6 +1,38 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
MappedItem,
|
|
3
|
+
MappedRun,
|
|
4
|
+
ProcessLifecycleStatus,
|
|
5
|
+
ProcessTurnRecord,
|
|
6
|
+
} from "@leitwerk-dev/domain";
|
|
2
7
|
import type { ProcessGraphView } from "@leitwerk-dev/process-sdk";
|
|
3
|
-
import type { ProcessTimelineTurnSummary } from "@leitwerk-dev/protocol";
|
|
8
|
+
import type { ProcessTimelineIteration, ProcessTimelineTurnSummary } from "@leitwerk-dev/protocol";
|
|
9
|
+
|
|
10
|
+
/** Mapped runs and items of one process, joined for presentation. @internal */
|
|
11
|
+
export interface MappedRunPresentation {
|
|
12
|
+
/** @internal */
|
|
13
|
+
runs: readonly MappedRun[];
|
|
14
|
+
/** @internal */
|
|
15
|
+
items: readonly MappedItem[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function iterationFor(
|
|
19
|
+
run: MappedRun,
|
|
20
|
+
item: MappedItem | undefined,
|
|
21
|
+
index: number,
|
|
22
|
+
itemKey: string,
|
|
23
|
+
): ProcessTimelineIteration {
|
|
24
|
+
return {
|
|
25
|
+
runId: run.id,
|
|
26
|
+
itemKey,
|
|
27
|
+
index,
|
|
28
|
+
count: run.itemCount,
|
|
29
|
+
label: item?.label ?? itemKey,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function withItemLabel(description: string, iteration: ProcessTimelineIteration): string {
|
|
34
|
+
return `${description}: ${iteration.label}`;
|
|
35
|
+
}
|
|
4
36
|
|
|
5
37
|
/** Navigation retains human decisions omitted by the business-flow diagram. */
|
|
6
38
|
export function presentProcessTurnNavigation(input: {
|
|
@@ -8,20 +40,66 @@ export function presentProcessTurnNavigation(input: {
|
|
|
8
40
|
turns: readonly ProcessTimelineTurnSummary[];
|
|
9
41
|
selectedTurnId: string | null;
|
|
10
42
|
lifecycleStatus: ProcessLifecycleStatus;
|
|
43
|
+
turnRecords?: readonly Pick<ProcessTurnRecord, "id" | "iteration">[];
|
|
44
|
+
mapped?: MappedRunPresentation;
|
|
11
45
|
}): {
|
|
12
46
|
turns: ProcessTimelineTurnSummary[];
|
|
13
|
-
plannedNextTurn: {
|
|
47
|
+
plannedNextTurn: {
|
|
48
|
+
turnId: string;
|
|
49
|
+
description: string;
|
|
50
|
+
iteration?: ProcessTimelineIteration;
|
|
51
|
+
} | null;
|
|
14
52
|
} {
|
|
53
|
+
const runs = new Map(input.mapped?.runs.map((run) => [run.id, run]) ?? []);
|
|
54
|
+
const items = new Map(
|
|
55
|
+
input.mapped?.items.map((item) => [`${item.runId}:${item.itemIndex}`, item]) ?? [],
|
|
56
|
+
);
|
|
57
|
+
const iterationsByRecordId = new Map<string, ProcessTimelineIteration>();
|
|
58
|
+
for (const record of input.turnRecords ?? []) {
|
|
59
|
+
const ref = record.iteration;
|
|
60
|
+
const run = ref ? runs.get(ref.runId) : undefined;
|
|
61
|
+
if (!ref || !run) continue;
|
|
62
|
+
iterationsByRecordId.set(
|
|
63
|
+
record.id,
|
|
64
|
+
iterationFor(run, items.get(`${ref.runId}:${ref.itemIndex}`), ref.itemIndex, ref.itemKey),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const describe = (turnId: string) => input.graph.turns.get(turnId)?.description.trim();
|
|
68
|
+
|
|
69
|
+
const activeRun = input.mapped?.runs.find(
|
|
70
|
+
(run) => run.status === "active" && run.turnId === input.selectedTurnId,
|
|
71
|
+
);
|
|
72
|
+
const nextItem =
|
|
73
|
+
input.lifecycleStatus === "active" && activeRun
|
|
74
|
+
? items.get(`${activeRun.id}:${activeRun.nextIndex + 1}`)
|
|
75
|
+
: undefined;
|
|
15
76
|
const path = input.graph.happyPath ?? [];
|
|
16
77
|
const currentIndex = path.indexOf(input.selectedTurnId ?? "");
|
|
17
78
|
const nextId =
|
|
18
79
|
input.lifecycleStatus === "active" && currentIndex >= 0 ? path[currentIndex + 1] : undefined;
|
|
19
80
|
const next = nextId ? input.graph.turns.get(nextId) : undefined;
|
|
81
|
+
let plannedNextTurn: {
|
|
82
|
+
turnId: string;
|
|
83
|
+
description: string;
|
|
84
|
+
iteration?: ProcessTimelineIteration;
|
|
85
|
+
} | null = next && nextId ? { turnId: nextId, description: next.description } : null;
|
|
86
|
+
if (activeRun && nextItem) {
|
|
87
|
+
const iteration = iterationFor(activeRun, nextItem, nextItem.itemIndex, nextItem.itemKey);
|
|
88
|
+
plannedNextTurn = {
|
|
89
|
+
turnId: activeRun.turnId,
|
|
90
|
+
description: withItemLabel(describe(activeRun.turnId) || activeRun.turnId, iteration),
|
|
91
|
+
iteration,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
20
95
|
return {
|
|
21
|
-
turns: input.turns.map((turn) =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
96
|
+
turns: input.turns.map((turn) => {
|
|
97
|
+
const displayTurn = describe(turn.turnId) || turn.displayTurn;
|
|
98
|
+
const iteration = iterationsByRecordId.get(turn.id);
|
|
99
|
+
return iteration
|
|
100
|
+
? { ...turn, displayTurn: withItemLabel(displayTurn, iteration), iteration }
|
|
101
|
+
: { ...turn, displayTurn };
|
|
102
|
+
}),
|
|
103
|
+
plannedNextTurn,
|
|
26
104
|
};
|
|
27
105
|
}
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
} from "@leitwerk-dev/domain";
|
|
8
8
|
import {
|
|
9
9
|
asWsEventPayloadRecord,
|
|
10
|
-
buildLiveTurnProjectionFromEvents,
|
|
11
10
|
buildPrimaryPathOperationalTraceItem,
|
|
12
11
|
compareTimestampStrings,
|
|
12
|
+
createLiveTurnProjection,
|
|
13
13
|
createTurnContinuationIndex,
|
|
14
14
|
extractPiSessionMessageText,
|
|
15
15
|
isPiSessionMessageEntryWithRecord,
|
|
@@ -19,12 +19,10 @@ import {
|
|
|
19
19
|
type PiSessionContentBlock,
|
|
20
20
|
type PiSessionEntry,
|
|
21
21
|
type PiSessionMessageRecord,
|
|
22
|
-
PRIMARY_PATH_OPERATIONAL_PI_EVENT_TYPES,
|
|
23
22
|
type PrimaryPathOperationalTraceItemSnapshot,
|
|
24
23
|
type PrimaryPathStreamingAssistantSnapshot,
|
|
25
24
|
type PrimaryPathTraceItemSnapshot,
|
|
26
25
|
reasoningPreviewTail,
|
|
27
|
-
snapshotTurnTrace,
|
|
28
26
|
type TurnPiInputPart,
|
|
29
27
|
type TurnPiInputSnapshot,
|
|
30
28
|
type TurnTracePreview,
|
|
@@ -37,7 +35,6 @@ import type { ReadonlyPiSessionTree } from "./pi-session-tree.js";
|
|
|
37
35
|
const MULTI_PART_PI_INPUT_SEPARATOR =
|
|
38
36
|
"\n\n--- UI-added separator between Pi input messages ---\n\n";
|
|
39
37
|
const PREVIEW_MAX_LENGTH = 520;
|
|
40
|
-
const OPERATIONAL_PI_EVENT_TYPE_SET = new Set<string>(PRIMARY_PATH_OPERATIONAL_PI_EVENT_TYPES);
|
|
41
38
|
|
|
42
39
|
function buildTurnPiInputSnapshot(parts: readonly TurnPiInputPart[]): TurnPiInputSnapshot | null {
|
|
43
40
|
const firstPart = parts[0];
|
|
@@ -181,19 +178,6 @@ function buildCompactionEntryTraceItem(
|
|
|
181
178
|
};
|
|
182
179
|
}
|
|
183
180
|
|
|
184
|
-
function buildOperationalEventTraceItem(
|
|
185
|
-
event: ProcessEvent,
|
|
186
|
-
): PrimaryPathOperationalTraceItemSnapshot | null {
|
|
187
|
-
if (!OPERATIONAL_PI_EVENT_TYPE_SET.has(event.eventType)) {
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
190
|
-
return buildPrimaryPathOperationalTraceItem({
|
|
191
|
-
eventType: event.eventType,
|
|
192
|
-
data: asWsEventPayloadRecord(event.data),
|
|
193
|
-
fallbackTimestamp: event.createdAt,
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
181
|
function eventTurnRecordId(event: ProcessEvent): string | null {
|
|
198
182
|
return readNonBlankString(event.data.turnRecordId);
|
|
199
183
|
}
|
|
@@ -357,7 +341,14 @@ function buildTurnTraceFromSlice(input: {
|
|
|
357
341
|
|
|
358
342
|
for (const event of input.events ?? []) {
|
|
359
343
|
if (eventTurnRecordId(event) === input.turnRecordId) {
|
|
360
|
-
appendOperationalTraceItem(
|
|
344
|
+
appendOperationalTraceItem(
|
|
345
|
+
traceItems,
|
|
346
|
+
buildPrimaryPathOperationalTraceItem({
|
|
347
|
+
eventType: event.eventType,
|
|
348
|
+
data: asWsEventPayloadRecord(event.data),
|
|
349
|
+
fallbackTimestamp: event.createdAt,
|
|
350
|
+
}),
|
|
351
|
+
);
|
|
361
352
|
}
|
|
362
353
|
}
|
|
363
354
|
|
|
@@ -423,12 +414,9 @@ export function buildCommittedTurnTrace(input: {
|
|
|
423
414
|
events: readonly ProcessEvent[];
|
|
424
415
|
}): TurnTraceSnapshot {
|
|
425
416
|
const sessionTrace = buildTurnTraceFromSession(input);
|
|
426
|
-
const trace =
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
),
|
|
430
|
-
sessionTrace?.piInput ?? null,
|
|
431
|
-
);
|
|
417
|
+
const trace = createLiveTurnProjection(
|
|
418
|
+
input.events.filter((event) => eventTurnRecordId(event) === input.turnRecord.id),
|
|
419
|
+
).snapshot(sessionTrace?.piInput ?? null);
|
|
432
420
|
if (sessionTrace && !hasAdditionalRecordedActivity(trace, sessionTrace)) return sessionTrace;
|
|
433
421
|
trace.usage ??= sessionTrace?.usage ?? null;
|
|
434
422
|
for (const item of sessionTrace?.traceItems ?? []) {
|