sdd-agent-platform 0.4.0 → 0.4.2
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/README.md +36 -39
- package/node_modules/@sdd-agent-platform/core/dist/ai-tools.js +72 -71
- package/node_modules/@sdd-agent-platform/core/dist/ai-tools.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/artifacts/ingestion.js +64 -9
- package/node_modules/@sdd-agent-platform/core/dist/artifacts/ingestion.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/artifacts/sdd-evidence.js +0 -1
- package/node_modules/@sdd-agent-platform/core/dist/artifacts/sdd-evidence.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/artifacts/sdd-result.js +26 -17
- package/node_modules/@sdd-agent-platform/core/dist/artifacts/sdd-result.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/config/init-project.d.ts +3 -0
- package/node_modules/@sdd-agent-platform/core/dist/config/init-project.js +13 -9
- package/node_modules/@sdd-agent-platform/core/dist/config/init-project.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/config/project-config.d.ts +3 -1
- package/node_modules/@sdd-agent-platform/core/dist/config/project-config.js +7 -3
- package/node_modules/@sdd-agent-platform/core/dist/config/project-config.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.d.ts +4 -4
- package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.js +16 -20
- package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/context/build-package.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/context/build-package.js +1 -7
- package/node_modules/@sdd-agent-platform/core/dist/context/build-package.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/context/evidence-summary.js +26 -8
- package/node_modules/@sdd-agent-platform/core/dist/context/evidence-summary.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/context/log-worker.js +2 -2
- package/node_modules/@sdd-agent-platform/core/dist/context/log-worker.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/context-offload/contracts.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/contracts.d.ts +4 -1
- package/node_modules/@sdd-agent-platform/core/dist/contracts.js +3 -0
- package/node_modules/@sdd-agent-platform/core/dist/contracts.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/delegation/model.d.ts +3 -0
- package/node_modules/@sdd-agent-platform/core/dist/delegation/validation.d.ts +3 -0
- package/node_modules/@sdd-agent-platform/core/dist/delegation/validation.js +7 -4
- package/node_modules/@sdd-agent-platform/core/dist/delegation/validation.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/document-chain.js +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/document-chain.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/project.js +8 -8
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/project.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/registries.js +0 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/registries.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-evidence.js +7 -7
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-evidence.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-trust.js +0 -24
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-trust.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/runtime-contracts.js +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/runtime-contracts.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/doctor.js +277 -3
- package/node_modules/@sdd-agent-platform/core/dist/doctor/doctor.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/evidence/lookup.d.ts +23 -0
- package/node_modules/@sdd-agent-platform/core/dist/evidence/lookup.js +61 -0
- package/node_modules/@sdd-agent-platform/core/dist/evidence/lookup.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/evidence-runtime/contracts.d.ts +11 -1
- package/node_modules/@sdd-agent-platform/core/dist/execution/agent-execution-records.js +15 -8
- package/node_modules/@sdd-agent-platform/core/dist/execution/agent-execution-records.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/execution/background-executor.js +4 -4
- package/node_modules/@sdd-agent-platform/core/dist/execution/background-executor.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/execution/foreground-subagents.js +3 -3
- package/node_modules/@sdd-agent-platform/core/dist/execution/foreground-subagents.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/execution/host-invocation.js +5 -4
- package/node_modules/@sdd-agent-platform/core/dist/execution/host-invocation.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/execution/resident-worker.js +16 -7
- package/node_modules/@sdd-agent-platform/core/dist/execution/resident-worker.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/execution/stage-team-runtime.d.ts +112 -0
- package/node_modules/@sdd-agent-platform/core/dist/execution/stage-team-runtime.js +145 -0
- package/node_modules/@sdd-agent-platform/core/dist/execution/stage-team-runtime.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/governance/policy.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/governance/policy.js +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/governance/policy.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/instructions.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/instructions.js +59 -66
- package/node_modules/@sdd-agent-platform/core/dist/instructions.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/lifecycle/decision-gate.js +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/lifecycle/decision-gate.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.d.ts +3 -0
- package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.js +55 -19
- package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/orchestration/contracts.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/orchestration/runtime.d.ts +12 -2
- package/node_modules/@sdd-agent-platform/core/dist/orchestration/runtime.js +62 -21
- package/node_modules/@sdd-agent-platform/core/dist/orchestration/runtime.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.d.ts +20 -2
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.js +218 -18
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-registry.js +17 -17
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-registry.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-runtime-static.d.ts +10 -0
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-runtime-static.js +32 -2
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-runtime-static.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/capability-sources.d.ts +2 -17
- package/node_modules/@sdd-agent-platform/core/dist/registries/capability-sources.js +222 -10
- package/node_modules/@sdd-agent-platform/core/dist/registries/capability-sources.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/command-team-runtime.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/command-team-runtime.js +9 -9
- package/node_modules/@sdd-agent-platform/core/dist/registries/command-team-runtime.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/eval-learning-context.js +4 -4
- package/node_modules/@sdd-agent-platform/core/dist/registries/eval-learning-context.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/query-status.js +2 -2
- package/node_modules/@sdd-agent-platform/core/dist/registries/query-status.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/tool-capabilities.js +3 -3
- package/node_modules/@sdd-agent-platform/core/dist/registries/tool-capabilities.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/tool-plugins.js +2 -2
- package/node_modules/@sdd-agent-platform/core/dist/registries/tool-plugins.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/worker-adapters.js +11 -11
- package/node_modules/@sdd-agent-platform/core/dist/registries/worker-adapters.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/workflow-gates.js +12 -12
- package/node_modules/@sdd-agent-platform/core/dist/registries/workflow-gates.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/risk/contracts.d.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/dist/risk/kernel.js +4 -4
- package/node_modules/@sdd-agent-platform/core/dist/risk/kernel.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/risk/legacy-adapters.js +4 -7
- package/node_modules/@sdd-agent-platform/core/dist/risk/legacy-adapters.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/risk/workflow-gates.d.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/dist/risk/workflow-gates.js +19 -17
- package/node_modules/@sdd-agent-platform/core/dist/risk/workflow-gates.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime-config.js +28 -13
- package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime-config.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime.d.ts +61 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/route-projection.d.ts +3 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/route-projection.js +192 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/route-projection.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/routing.js +73 -17
- package/node_modules/@sdd-agent-platform/core/dist/router/routing.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/runtime-import.d.ts +28 -0
- package/node_modules/@sdd-agent-platform/core/dist/router/runtime-import.js +373 -0
- package/node_modules/@sdd-agent-platform/core/dist/router/runtime-import.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/router/runtime-inspection.js +11 -4
- package/node_modules/@sdd-agent-platform/core/dist/router/runtime-inspection.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/runtime-validation.js +31 -3
- package/node_modules/@sdd-agent-platform/core/dist/router/runtime-validation.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/stage-route-binding.d.ts +37 -0
- package/node_modules/@sdd-agent-platform/core/dist/router/stage-route-binding.js +235 -0
- package/node_modules/@sdd-agent-platform/core/dist/router/stage-route-binding.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/router.d.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/router.js +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/router.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/run-state/artifacts.d.ts +16 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state/artifacts.js +168 -18
- package/node_modules/@sdd-agent-platform/core/dist/run-state/artifacts.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/run-state/events.js +2 -2
- package/node_modules/@sdd-agent-platform/core/dist/run-state/events.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.d.ts +3 -3
- package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.js +22 -54
- package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/run-state/invocation-ledger.js +2 -2
- package/node_modules/@sdd-agent-platform/core/dist/run-state/invocation-ledger.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/run-state/model.d.ts +53 -9
- package/node_modules/@sdd-agent-platform/core/dist/run-state/run-index.d.ts +0 -2
- package/node_modules/@sdd-agent-platform/core/dist/run-state/run-index.js +1 -3
- package/node_modules/@sdd-agent-platform/core/dist/run-state/run-index.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/run-state/run-state.js +51 -34
- package/node_modules/@sdd-agent-platform/core/dist/run-state/run-state.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.d.ts +65 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.js +169 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state/timing.d.ts +8 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state/timing.js +131 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state/timing.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state.d.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state.js +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/build.js +0 -3
- package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/build.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/findings.js +5 -44
- package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/findings.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/model.d.ts +1 -17
- package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.d.ts +20 -0
- package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.js +109 -14
- package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/runtime-projection-p0.d.ts +64 -0
- package/node_modules/@sdd-agent-platform/core/dist/runtime-projection-p0.js +200 -0
- package/node_modules/@sdd-agent-platform/core/dist/runtime-projection-p0.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/context.js +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/context.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.d.ts +6 -0
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.js +276 -0
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/run-binding.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/run-binding.js +15 -4
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/run-binding.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.d.ts +21 -0
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.js +139 -38
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/stage-artifacts.d.ts +55 -0
- package/node_modules/@sdd-agent-platform/core/dist/stage-artifacts.js +322 -0
- package/node_modules/@sdd-agent-platform/core/dist/stage-artifacts.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration-contracts.d.ts +55 -0
- package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration-contracts.js +241 -0
- package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration-contracts.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration.d.ts +888 -0
- package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration.js +3870 -0
- package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/stage-runtime/runtime.js +8 -1
- package/node_modules/@sdd-agent-platform/core/dist/stage-runtime/runtime.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/status/project-status.d.ts +105 -1
- package/node_modules/@sdd-agent-platform/core/dist/status/project-status.js +343 -8
- package/node_modules/@sdd-agent-platform/core/dist/status/project-status.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.d.ts +348 -3
- package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.js +1017 -8
- package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/subagents/contracts.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/subagents/runtime.js +7 -7
- package/node_modules/@sdd-agent-platform/core/dist/subagents/runtime.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/test-support/fixtures.js +21 -0
- package/node_modules/@sdd-agent-platform/core/dist/test-support/fixtures.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/test-support/run-state.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/test-support/run-state.js +19 -20
- package/node_modules/@sdd-agent-platform/core/dist/test-support/run-state.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/truth-reconciliation.d.ts +44 -0
- package/node_modules/@sdd-agent-platform/core/dist/truth-reconciliation.js +138 -0
- package/node_modules/@sdd-agent-platform/core/dist/truth-reconciliation.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/goal-verify.d.ts +0 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/goal-verify.js +44 -37
- package/node_modules/@sdd-agent-platform/core/dist/verification/goal-verify.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/rendering.d.ts +0 -2
- package/node_modules/@sdd-agent-platform/core/dist/verification/rendering.js +19 -49
- package/node_modules/@sdd-agent-platform/core/dist/verification/rendering.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/review-gate.d.ts +22 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/review-gate.js +53 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/review-gate.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/single-task-loop.d.ts +0 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/single-task-loop.js +213 -111
- package/node_modules/@sdd-agent-platform/core/dist/verification/single-task-loop.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.d.ts +28 -3
- package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.js +546 -125
- package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/validation-cache.d.ts +26 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/validation-cache.js +73 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/validation-cache.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.d.ts +76 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.js +450 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.d.ts +3 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.js +105 -30
- package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification.d.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification.js +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/work-units/contracts.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/evidence-packet.d.ts +24 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/evidence-packet.js +395 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/evidence-packet.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/hard-checks.d.ts +4 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/hard-checks.js +164 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/hard-checks.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/policy.d.ts +4 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/policy.js +182 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/policy.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/types.d.ts +88 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/types.js +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/types.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.js +17 -3
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/dependencies.d.ts +8 -4
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/dependencies.js +25 -11
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/dependencies.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.d.ts +37 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.js +188 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/migration-recovery.d.ts +40 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/migration-recovery.js +110 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/migration-recovery.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/repair-contract.d.ts +12 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/repair-contract.js +63 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/repair-contract.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve-task-run.d.ts +21 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve-task-run.js +95 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve-task-run.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.d.ts +80 -3
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.js +674 -41
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/runtime-projections.d.ts +228 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/runtime-projections.js +452 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/runtime-projections.js.map +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state.d.ts +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state.js +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/package.json +3 -3
- package/node_modules/@sdd-agent-platform/core/src/ai-tools.test.ts +49 -1
- package/node_modules/@sdd-agent-platform/core/src/ai-tools.ts +72 -71
- package/node_modules/@sdd-agent-platform/core/src/artifacts/ingestion.test.ts +38 -0
- package/node_modules/@sdd-agent-platform/core/src/artifacts/ingestion.ts +65 -9
- package/node_modules/@sdd-agent-platform/core/src/artifacts/sdd-evidence.ts +0 -1
- package/node_modules/@sdd-agent-platform/core/src/artifacts/sdd-result.test.ts +52 -6
- package/node_modules/@sdd-agent-platform/core/src/artifacts/sdd-result.ts +26 -17
- package/node_modules/@sdd-agent-platform/core/src/config/init-project.test.ts +44 -29
- package/node_modules/@sdd-agent-platform/core/src/config/init-project.ts +15 -11
- package/node_modules/@sdd-agent-platform/core/src/config/project-config.ts +10 -4
- package/node_modules/@sdd-agent-platform/core/src/config/starter-documents.ts +17 -20
- package/node_modules/@sdd-agent-platform/core/src/context/build-package.ts +2 -8
- package/node_modules/@sdd-agent-platform/core/src/context/context-build.test.ts +3 -2
- package/node_modules/@sdd-agent-platform/core/src/context/evidence-summary.ts +27 -8
- package/node_modules/@sdd-agent-platform/core/src/context/log-worker.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/src/context-offload/contracts.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/contracts.ts +4 -1
- package/node_modules/@sdd-agent-platform/core/src/delegation/model.ts +3 -0
- package/node_modules/@sdd-agent-platform/core/src/delegation/validation.ts +8 -5
- package/node_modules/@sdd-agent-platform/core/src/doctor/checks/document-chain.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/doctor/checks/project.ts +8 -8
- package/node_modules/@sdd-agent-platform/core/src/doctor/checks/registries.ts +0 -1
- package/node_modules/@sdd-agent-platform/core/src/doctor/checks/run-evidence.ts +7 -7
- package/node_modules/@sdd-agent-platform/core/src/doctor/checks/run-trust.ts +0 -21
- package/node_modules/@sdd-agent-platform/core/src/doctor/checks/runtime-contracts.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/doctor/doctor.test.ts +217 -7
- package/node_modules/@sdd-agent-platform/core/src/doctor/doctor.ts +301 -3
- package/node_modules/@sdd-agent-platform/core/src/evidence/lookup.ts +88 -0
- package/node_modules/@sdd-agent-platform/core/src/evidence-runtime/contracts.ts +12 -1
- package/node_modules/@sdd-agent-platform/core/src/execution/agent-execution-records.ts +16 -11
- package/node_modules/@sdd-agent-platform/core/src/execution/background-executor.test.ts +57 -2
- package/node_modules/@sdd-agent-platform/core/src/execution/background-executor.ts +4 -4
- package/node_modules/@sdd-agent-platform/core/src/execution/foreground-subagents.test.ts +11 -2
- package/node_modules/@sdd-agent-platform/core/src/execution/foreground-subagents.ts +3 -3
- package/node_modules/@sdd-agent-platform/core/src/execution/host-invocation.ts +5 -4
- package/node_modules/@sdd-agent-platform/core/src/execution/resident-worker.test.ts +17 -1
- package/node_modules/@sdd-agent-platform/core/src/execution/resident-worker.ts +16 -7
- package/node_modules/@sdd-agent-platform/core/src/execution/stage-team-runtime.test.ts +102 -0
- package/node_modules/@sdd-agent-platform/core/src/execution/stage-team-runtime.ts +271 -0
- package/node_modules/@sdd-agent-platform/core/src/execution/wave-executor.test.ts +14 -0
- package/node_modules/@sdd-agent-platform/core/src/governance/policy.test.ts +10 -0
- package/node_modules/@sdd-agent-platform/core/src/governance/policy.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/src/instructions.test.ts +34 -13
- package/node_modules/@sdd-agent-platform/core/src/instructions.ts +60 -67
- package/node_modules/@sdd-agent-platform/core/src/lifecycle/decision-gate.test.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/lifecycle/decision-gate.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/lifecycle/ship.test.ts +47 -0
- package/node_modules/@sdd-agent-platform/core/src/lifecycle/ship.ts +58 -19
- package/node_modules/@sdd-agent-platform/core/src/orchestration/contracts.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/orchestration/runtime.ts +74 -22
- package/node_modules/@sdd-agent-platform/core/src/phase8-contracts.test.ts +3 -3
- package/node_modules/@sdd-agent-platform/core/src/phase8-risk-kernel.test.ts +8 -3
- package/node_modules/@sdd-agent-platform/core/src/planning/task-graph.test.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/src/planning/wave-plan.test.ts +3 -0
- package/node_modules/@sdd-agent-platform/core/src/registries/agent-capability-catalog.ts +319 -20
- package/node_modules/@sdd-agent-platform/core/src/registries/agent-registry.ts +17 -17
- package/node_modules/@sdd-agent-platform/core/src/registries/agent-runtime-static.ts +42 -2
- package/node_modules/@sdd-agent-platform/core/src/registries/capability-sources.ts +238 -15
- package/node_modules/@sdd-agent-platform/core/src/registries/command-team-runtime.ts +10 -10
- package/node_modules/@sdd-agent-platform/core/src/registries/eval-learning-context.ts +4 -4
- package/node_modules/@sdd-agent-platform/core/src/registries/query-status.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/src/registries/registries.test.ts +45 -4
- package/node_modules/@sdd-agent-platform/core/src/registries/tool-capabilities.ts +3 -3
- package/node_modules/@sdd-agent-platform/core/src/registries/tool-plugins.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/src/registries/worker-adapters.ts +11 -11
- package/node_modules/@sdd-agent-platform/core/src/registries/workflow-gates.ts +12 -12
- package/node_modules/@sdd-agent-platform/core/src/risk/contracts.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/src/risk/kernel.ts +4 -4
- package/node_modules/@sdd-agent-platform/core/src/risk/legacy-adapters.ts +4 -7
- package/node_modules/@sdd-agent-platform/core/src/risk/workflow-gates.ts +20 -18
- package/node_modules/@sdd-agent-platform/core/src/router/agent-runtime-config.ts +32 -13
- package/node_modules/@sdd-agent-platform/core/src/router/agent-runtime.ts +68 -1
- package/node_modules/@sdd-agent-platform/core/src/router/route-projection.ts +212 -1
- package/node_modules/@sdd-agent-platform/core/src/router/route-sdd-task.test.ts +391 -6
- package/node_modules/@sdd-agent-platform/core/src/router/routing.ts +78 -17
- package/node_modules/@sdd-agent-platform/core/src/router/runtime-import.ts +453 -0
- package/node_modules/@sdd-agent-platform/core/src/router/runtime-inspection.ts +11 -4
- package/node_modules/@sdd-agent-platform/core/src/router/runtime-validation.ts +32 -3
- package/node_modules/@sdd-agent-platform/core/src/router/stage-route-binding.ts +279 -0
- package/node_modules/@sdd-agent-platform/core/src/router.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/src/run-state/artifacts.ts +173 -18
- package/node_modules/@sdd-agent-platform/core/src/run-state/events.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/src/run-state/inspect-run.ts +24 -59
- package/node_modules/@sdd-agent-platform/core/src/run-state/invocation-ledger.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/src/run-state/model.ts +59 -9
- package/node_modules/@sdd-agent-platform/core/src/run-state/run-index.ts +1 -5
- package/node_modules/@sdd-agent-platform/core/src/run-state/run-state.test.ts +53 -2
- package/node_modules/@sdd-agent-platform/core/src/run-state/run-state.ts +55 -41
- package/node_modules/@sdd-agent-platform/core/src/run-state/task-evidence.ts +252 -0
- package/node_modules/@sdd-agent-platform/core/src/run-state/timing.ts +146 -0
- package/node_modules/@sdd-agent-platform/core/src/run-state.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/src/runtime-analysis/build.ts +0 -3
- package/node_modules/@sdd-agent-platform/core/src/runtime-analysis/findings.ts +6 -46
- package/node_modules/@sdd-agent-platform/core/src/runtime-analysis/model.ts +1 -13
- package/node_modules/@sdd-agent-platform/core/src/runtime-analysis.test.ts +0 -2
- package/node_modules/@sdd-agent-platform/core/src/runtime-paths.ts +131 -14
- package/node_modules/@sdd-agent-platform/core/src/runtime-projection-p0.test.ts +96 -0
- package/node_modules/@sdd-agent-platform/core/src/runtime-projection-p0.ts +292 -0
- package/node_modules/@sdd-agent-platform/core/src/sdd-docs/context.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/sdd-docs/document-hashes.ts +306 -0
- package/node_modules/@sdd-agent-platform/core/src/sdd-docs/run-binding.ts +15 -4
- package/node_modules/@sdd-agent-platform/core/src/sdd-docs/task-parser.test.ts +261 -0
- package/node_modules/@sdd-agent-platform/core/src/sdd-docs/task-parser.ts +169 -41
- package/node_modules/@sdd-agent-platform/core/src/stage-artifacts.ts +450 -0
- package/node_modules/@sdd-agent-platform/core/src/stage-collaboration-contracts.ts +322 -0
- package/node_modules/@sdd-agent-platform/core/src/stage-collaboration.test.ts +2903 -0
- package/node_modules/@sdd-agent-platform/core/src/stage-collaboration.ts +5831 -0
- package/node_modules/@sdd-agent-platform/core/src/stage-runtime/runtime.test.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/stage-runtime/runtime.ts +9 -1
- package/node_modules/@sdd-agent-platform/core/src/status/project-status.test.ts +239 -16
- package/node_modules/@sdd-agent-platform/core/src/status/project-status.ts +497 -8
- package/node_modules/@sdd-agent-platform/core/src/storage/runtime-store.test.ts +560 -4
- package/node_modules/@sdd-agent-platform/core/src/storage/runtime-store.ts +1510 -9
- package/node_modules/@sdd-agent-platform/core/src/subagents/contracts.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/subagents/runtime.test.ts +3 -3
- package/node_modules/@sdd-agent-platform/core/src/subagents/runtime.ts +7 -7
- package/node_modules/@sdd-agent-platform/core/src/test-support/fixtures.ts +21 -0
- package/node_modules/@sdd-agent-platform/core/src/test-support/run-state.ts +20 -20
- package/node_modules/@sdd-agent-platform/core/src/truth-reconciliation.test.ts +72 -0
- package/node_modules/@sdd-agent-platform/core/src/truth-reconciliation.ts +177 -0
- package/node_modules/@sdd-agent-platform/core/src/verification/goal-verify.test.ts +13 -87
- package/node_modules/@sdd-agent-platform/core/src/verification/goal-verify.ts +46 -42
- package/node_modules/@sdd-agent-platform/core/src/verification/rendering.ts +18 -52
- package/node_modules/@sdd-agent-platform/core/src/verification/review-gate.test.ts +84 -0
- package/node_modules/@sdd-agent-platform/core/src/verification/review-gate.ts +77 -0
- package/node_modules/@sdd-agent-platform/core/src/verification/single-task-loop.test.ts +138 -64
- package/node_modules/@sdd-agent-platform/core/src/verification/single-task-loop.ts +226 -116
- package/node_modules/@sdd-agent-platform/core/src/verification/test-runtime.test.ts +148 -48
- package/node_modules/@sdd-agent-platform/core/src/verification/test-runtime.ts +619 -136
- package/node_modules/@sdd-agent-platform/core/src/verification/validation-cache.ts +106 -0
- package/node_modules/@sdd-agent-platform/core/src/verification/validation-wave.test.ts +383 -0
- package/node_modules/@sdd-agent-platform/core/src/verification/validation-wave.ts +556 -0
- package/node_modules/@sdd-agent-platform/core/src/verification/verify-contract.test.ts +131 -8
- package/node_modules/@sdd-agent-platform/core/src/verification/verify-contract.ts +117 -30
- package/node_modules/@sdd-agent-platform/core/src/verification.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/src/work-units/contracts.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/evidence-packet.ts +425 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/hard-checks.test.ts +507 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/hard-checks.ts +182 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/policy.test.ts +174 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/policy.ts +194 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/types.ts +115 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/affected-file-conflicts.ts +19 -4
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/dependencies.test.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/dependencies.ts +33 -11
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/latest-eligible-run.ts +224 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/migration-recovery.ts +158 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/repair-contract.ts +77 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve-task-run.ts +114 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve.test.ts +851 -9
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve.ts +862 -45
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/runtime-projections.ts +712 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-state.ts +1 -0
- package/package.json +1 -1
- package/packages/cli/dist/args.js +2 -2
- package/packages/cli/dist/args.js.map +1 -1
- package/packages/cli/dist/commands/ai-tools.js +13 -2
- package/packages/cli/dist/commands/ai-tools.js.map +1 -1
- package/packages/cli/dist/commands/context.js +1 -1
- package/packages/cli/dist/commands/context.js.map +1 -1
- package/packages/cli/dist/commands/execution.js +49 -1
- package/packages/cli/dist/commands/execution.js.map +1 -1
- package/packages/cli/dist/commands/governance.js +1 -1
- package/packages/cli/dist/commands/governance.js.map +1 -1
- package/packages/cli/dist/commands/init.js +6 -1
- package/packages/cli/dist/commands/init.js.map +1 -1
- package/packages/cli/dist/commands/lifecycle.js +15 -2
- package/packages/cli/dist/commands/lifecycle.js.map +1 -1
- package/packages/cli/dist/commands/registry/runtime.js +48 -2
- package/packages/cli/dist/commands/registry/runtime.js.map +1 -1
- package/packages/cli/dist/commands/run.js +52 -2
- package/packages/cli/dist/commands/run.js.map +1 -1
- package/packages/cli/dist/commands/stage-close.d.ts +6 -0
- package/packages/cli/dist/commands/stage-close.js +295 -0
- package/packages/cli/dist/commands/stage-close.js.map +1 -0
- package/packages/cli/dist/commands/status.js +70 -4
- package/packages/cli/dist/commands/status.js.map +1 -1
- package/packages/cli/dist/commands/tasks.js +4 -4
- package/packages/cli/dist/commands/tasks.js.map +1 -1
- package/packages/cli/dist/commands/test.js +272 -5
- package/packages/cli/dist/commands/test.js.map +1 -1
- package/packages/cli/dist/commands/verifies.js +9 -5
- package/packages/cli/dist/commands/verifies.js.map +1 -1
- package/packages/cli/dist/commands/verify.js +257 -20
- package/packages/cli/dist/commands/verify.js.map +1 -1
- package/packages/cli/dist/dispatch.js +4 -9
- package/packages/cli/dist/dispatch.js.map +1 -1
- package/packages/cli/dist/help.js +42 -27
- package/packages/cli/dist/help.js.map +1 -1
- package/packages/cli/dist/renderers/doctor.js +1 -1
- package/packages/cli/dist/renderers/doctor.js.map +1 -1
- package/packages/cli/dist/renderers/execution.js +1 -1
- package/packages/cli/dist/renderers/execution.js.map +1 -1
- package/packages/cli/dist/renderers/json.d.ts +1 -0
- package/packages/cli/dist/renderers/json.js +3 -0
- package/packages/cli/dist/renderers/json.js.map +1 -1
- package/packages/cli/dist/renderers/registry-runtime.d.ts +2 -1
- package/packages/cli/dist/renderers/registry-runtime.js +27 -2
- package/packages/cli/dist/renderers/registry-runtime.js.map +1 -1
- package/packages/cli/dist/renderers/router.js +5 -3
- package/packages/cli/dist/renderers/router.js.map +1 -1
- package/packages/cli/dist/renderers/workflow.d.ts +0 -4
- package/packages/cli/dist/renderers/workflow.js +46 -84
- package/packages/cli/dist/renderers/workflow.js.map +1 -1
- package/packages/cli/dist/skill-import-args.d.ts +10 -0
- package/packages/cli/dist/skill-import-args.js +47 -0
- package/packages/cli/dist/skill-import-args.js.map +1 -0
- package/packages/cli/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/cli/package.json +2 -2
- package/packages/core/dist/ai-tools.js +72 -71
- package/packages/core/dist/ai-tools.js.map +1 -1
- package/packages/core/dist/artifacts/ingestion.js +64 -9
- package/packages/core/dist/artifacts/ingestion.js.map +1 -1
- package/packages/core/dist/artifacts/sdd-evidence.js +0 -1
- package/packages/core/dist/artifacts/sdd-evidence.js.map +1 -1
- package/packages/core/dist/artifacts/sdd-result.js +26 -17
- package/packages/core/dist/artifacts/sdd-result.js.map +1 -1
- package/packages/core/dist/config/init-project.d.ts +3 -0
- package/packages/core/dist/config/init-project.js +13 -9
- package/packages/core/dist/config/init-project.js.map +1 -1
- package/packages/core/dist/config/project-config.d.ts +3 -1
- package/packages/core/dist/config/project-config.js +7 -3
- package/packages/core/dist/config/project-config.js.map +1 -1
- package/packages/core/dist/config/starter-documents.d.ts +4 -4
- package/packages/core/dist/config/starter-documents.js +16 -20
- package/packages/core/dist/config/starter-documents.js.map +1 -1
- package/packages/core/dist/context/build-package.d.ts +1 -1
- package/packages/core/dist/context/build-package.js +1 -7
- package/packages/core/dist/context/build-package.js.map +1 -1
- package/packages/core/dist/context/evidence-summary.js +26 -8
- package/packages/core/dist/context/evidence-summary.js.map +1 -1
- package/packages/core/dist/context/log-worker.js +2 -2
- package/packages/core/dist/context/log-worker.js.map +1 -1
- package/packages/core/dist/context-offload/contracts.d.ts +1 -1
- package/packages/core/dist/contracts.d.ts +4 -1
- package/packages/core/dist/contracts.js +3 -0
- package/packages/core/dist/contracts.js.map +1 -1
- package/packages/core/dist/delegation/model.d.ts +3 -0
- package/packages/core/dist/delegation/validation.d.ts +3 -0
- package/packages/core/dist/delegation/validation.js +7 -4
- package/packages/core/dist/delegation/validation.js.map +1 -1
- package/packages/core/dist/doctor/checks/document-chain.js +1 -1
- package/packages/core/dist/doctor/checks/document-chain.js.map +1 -1
- package/packages/core/dist/doctor/checks/project.js +8 -8
- package/packages/core/dist/doctor/checks/project.js.map +1 -1
- package/packages/core/dist/doctor/checks/registries.js +0 -1
- package/packages/core/dist/doctor/checks/registries.js.map +1 -1
- package/packages/core/dist/doctor/checks/run-evidence.js +7 -7
- package/packages/core/dist/doctor/checks/run-evidence.js.map +1 -1
- package/packages/core/dist/doctor/checks/run-trust.js +0 -24
- package/packages/core/dist/doctor/checks/run-trust.js.map +1 -1
- package/packages/core/dist/doctor/checks/runtime-contracts.js +1 -1
- package/packages/core/dist/doctor/checks/runtime-contracts.js.map +1 -1
- package/packages/core/dist/doctor/doctor.js +277 -3
- package/packages/core/dist/doctor/doctor.js.map +1 -1
- package/packages/core/dist/evidence/lookup.d.ts +23 -0
- package/packages/core/dist/evidence/lookup.js +61 -0
- package/packages/core/dist/evidence/lookup.js.map +1 -0
- package/packages/core/dist/evidence-runtime/contracts.d.ts +11 -1
- package/packages/core/dist/execution/agent-execution-records.js +15 -8
- package/packages/core/dist/execution/agent-execution-records.js.map +1 -1
- package/packages/core/dist/execution/background-executor.js +4 -4
- package/packages/core/dist/execution/background-executor.js.map +1 -1
- package/packages/core/dist/execution/foreground-subagents.js +3 -3
- package/packages/core/dist/execution/foreground-subagents.js.map +1 -1
- package/packages/core/dist/execution/host-invocation.js +5 -4
- package/packages/core/dist/execution/host-invocation.js.map +1 -1
- package/packages/core/dist/execution/resident-worker.js +16 -7
- package/packages/core/dist/execution/resident-worker.js.map +1 -1
- package/packages/core/dist/execution/stage-team-runtime.d.ts +112 -0
- package/packages/core/dist/execution/stage-team-runtime.js +145 -0
- package/packages/core/dist/execution/stage-team-runtime.js.map +1 -0
- package/packages/core/dist/governance/policy.d.ts +1 -1
- package/packages/core/dist/governance/policy.js +1 -1
- package/packages/core/dist/governance/policy.js.map +1 -1
- package/packages/core/dist/instructions.d.ts +1 -1
- package/packages/core/dist/instructions.js +59 -66
- package/packages/core/dist/instructions.js.map +1 -1
- package/packages/core/dist/lifecycle/decision-gate.js +1 -1
- package/packages/core/dist/lifecycle/decision-gate.js.map +1 -1
- package/packages/core/dist/lifecycle/ship.d.ts +3 -0
- package/packages/core/dist/lifecycle/ship.js +55 -19
- package/packages/core/dist/lifecycle/ship.js.map +1 -1
- package/packages/core/dist/orchestration/contracts.d.ts +1 -1
- package/packages/core/dist/orchestration/runtime.d.ts +12 -2
- package/packages/core/dist/orchestration/runtime.js +62 -21
- package/packages/core/dist/orchestration/runtime.js.map +1 -1
- package/packages/core/dist/registries/agent-capability-catalog.d.ts +20 -2
- package/packages/core/dist/registries/agent-capability-catalog.js +218 -18
- package/packages/core/dist/registries/agent-capability-catalog.js.map +1 -1
- package/packages/core/dist/registries/agent-registry.js +17 -17
- package/packages/core/dist/registries/agent-registry.js.map +1 -1
- package/packages/core/dist/registries/agent-runtime-static.d.ts +10 -0
- package/packages/core/dist/registries/agent-runtime-static.js +32 -2
- package/packages/core/dist/registries/agent-runtime-static.js.map +1 -1
- package/packages/core/dist/registries/capability-sources.d.ts +2 -17
- package/packages/core/dist/registries/capability-sources.js +222 -10
- package/packages/core/dist/registries/capability-sources.js.map +1 -1
- package/packages/core/dist/registries/command-team-runtime.d.ts +1 -1
- package/packages/core/dist/registries/command-team-runtime.js +9 -9
- package/packages/core/dist/registries/command-team-runtime.js.map +1 -1
- package/packages/core/dist/registries/eval-learning-context.js +4 -4
- package/packages/core/dist/registries/eval-learning-context.js.map +1 -1
- package/packages/core/dist/registries/query-status.js +2 -2
- package/packages/core/dist/registries/query-status.js.map +1 -1
- package/packages/core/dist/registries/tool-capabilities.js +3 -3
- package/packages/core/dist/registries/tool-capabilities.js.map +1 -1
- package/packages/core/dist/registries/tool-plugins.js +2 -2
- package/packages/core/dist/registries/tool-plugins.js.map +1 -1
- package/packages/core/dist/registries/worker-adapters.js +11 -11
- package/packages/core/dist/registries/worker-adapters.js.map +1 -1
- package/packages/core/dist/registries/workflow-gates.js +12 -12
- package/packages/core/dist/registries/workflow-gates.js.map +1 -1
- package/packages/core/dist/risk/contracts.d.ts +2 -2
- package/packages/core/dist/risk/kernel.js +4 -4
- package/packages/core/dist/risk/kernel.js.map +1 -1
- package/packages/core/dist/risk/legacy-adapters.js +4 -7
- package/packages/core/dist/risk/legacy-adapters.js.map +1 -1
- package/packages/core/dist/risk/workflow-gates.d.ts +2 -2
- package/packages/core/dist/risk/workflow-gates.js +19 -17
- package/packages/core/dist/risk/workflow-gates.js.map +1 -1
- package/packages/core/dist/router/agent-runtime-config.js +28 -13
- package/packages/core/dist/router/agent-runtime-config.js.map +1 -1
- package/packages/core/dist/router/agent-runtime.d.ts +61 -1
- package/packages/core/dist/router/route-projection.d.ts +3 -1
- package/packages/core/dist/router/route-projection.js +192 -1
- package/packages/core/dist/router/route-projection.js.map +1 -1
- package/packages/core/dist/router/routing.js +73 -17
- package/packages/core/dist/router/routing.js.map +1 -1
- package/packages/core/dist/router/runtime-import.d.ts +28 -0
- package/packages/core/dist/router/runtime-import.js +373 -0
- package/packages/core/dist/router/runtime-import.js.map +1 -0
- package/packages/core/dist/router/runtime-inspection.js +11 -4
- package/packages/core/dist/router/runtime-inspection.js.map +1 -1
- package/packages/core/dist/router/runtime-validation.js +31 -3
- package/packages/core/dist/router/runtime-validation.js.map +1 -1
- package/packages/core/dist/router/stage-route-binding.d.ts +37 -0
- package/packages/core/dist/router/stage-route-binding.js +235 -0
- package/packages/core/dist/router/stage-route-binding.js.map +1 -0
- package/packages/core/dist/router.d.ts +2 -0
- package/packages/core/dist/router.js +2 -0
- package/packages/core/dist/router.js.map +1 -1
- package/packages/core/dist/run-state/artifacts.d.ts +16 -0
- package/packages/core/dist/run-state/artifacts.js +168 -18
- package/packages/core/dist/run-state/artifacts.js.map +1 -1
- package/packages/core/dist/run-state/events.js +2 -2
- package/packages/core/dist/run-state/events.js.map +1 -1
- package/packages/core/dist/run-state/inspect-run.d.ts +3 -3
- package/packages/core/dist/run-state/inspect-run.js +22 -54
- package/packages/core/dist/run-state/inspect-run.js.map +1 -1
- package/packages/core/dist/run-state/invocation-ledger.js +2 -2
- package/packages/core/dist/run-state/invocation-ledger.js.map +1 -1
- package/packages/core/dist/run-state/model.d.ts +53 -9
- package/packages/core/dist/run-state/run-index.d.ts +0 -2
- package/packages/core/dist/run-state/run-index.js +1 -3
- package/packages/core/dist/run-state/run-index.js.map +1 -1
- package/packages/core/dist/run-state/run-state.js +51 -34
- package/packages/core/dist/run-state/run-state.js.map +1 -1
- package/packages/core/dist/run-state/task-evidence.d.ts +65 -0
- package/packages/core/dist/run-state/task-evidence.js +169 -0
- package/packages/core/dist/run-state/task-evidence.js.map +1 -0
- package/packages/core/dist/run-state/timing.d.ts +8 -0
- package/packages/core/dist/run-state/timing.js +131 -0
- package/packages/core/dist/run-state/timing.js.map +1 -0
- package/packages/core/dist/run-state.d.ts +2 -0
- package/packages/core/dist/run-state.js +2 -0
- package/packages/core/dist/run-state.js.map +1 -1
- package/packages/core/dist/runtime-analysis/build.js +0 -3
- package/packages/core/dist/runtime-analysis/build.js.map +1 -1
- package/packages/core/dist/runtime-analysis/findings.js +5 -44
- package/packages/core/dist/runtime-analysis/findings.js.map +1 -1
- package/packages/core/dist/runtime-analysis/model.d.ts +1 -17
- package/packages/core/dist/runtime-paths.d.ts +20 -0
- package/packages/core/dist/runtime-paths.js +109 -14
- package/packages/core/dist/runtime-paths.js.map +1 -1
- package/packages/core/dist/runtime-projection-p0.d.ts +64 -0
- package/packages/core/dist/runtime-projection-p0.js +200 -0
- package/packages/core/dist/runtime-projection-p0.js.map +1 -0
- package/packages/core/dist/sdd-docs/context.js +1 -1
- package/packages/core/dist/sdd-docs/context.js.map +1 -1
- package/packages/core/dist/sdd-docs/document-hashes.d.ts +6 -0
- package/packages/core/dist/sdd-docs/document-hashes.js +276 -0
- package/packages/core/dist/sdd-docs/document-hashes.js.map +1 -0
- package/packages/core/dist/sdd-docs/run-binding.d.ts +1 -1
- package/packages/core/dist/sdd-docs/run-binding.js +15 -4
- package/packages/core/dist/sdd-docs/run-binding.js.map +1 -1
- package/packages/core/dist/sdd-docs/task-parser.d.ts +21 -0
- package/packages/core/dist/sdd-docs/task-parser.js +139 -38
- package/packages/core/dist/sdd-docs/task-parser.js.map +1 -1
- package/packages/core/dist/stage-artifacts.d.ts +55 -0
- package/packages/core/dist/stage-artifacts.js +322 -0
- package/packages/core/dist/stage-artifacts.js.map +1 -0
- package/packages/core/dist/stage-collaboration-contracts.d.ts +55 -0
- package/packages/core/dist/stage-collaboration-contracts.js +241 -0
- package/packages/core/dist/stage-collaboration-contracts.js.map +1 -0
- package/packages/core/dist/stage-collaboration.d.ts +888 -0
- package/packages/core/dist/stage-collaboration.js +3870 -0
- package/packages/core/dist/stage-collaboration.js.map +1 -0
- package/packages/core/dist/stage-runtime/runtime.js +8 -1
- package/packages/core/dist/stage-runtime/runtime.js.map +1 -1
- package/packages/core/dist/status/project-status.d.ts +105 -1
- package/packages/core/dist/status/project-status.js +343 -8
- package/packages/core/dist/status/project-status.js.map +1 -1
- package/packages/core/dist/storage/runtime-store.d.ts +348 -3
- package/packages/core/dist/storage/runtime-store.js +1017 -8
- package/packages/core/dist/storage/runtime-store.js.map +1 -1
- package/packages/core/dist/subagents/contracts.d.ts +1 -1
- package/packages/core/dist/subagents/runtime.js +7 -7
- package/packages/core/dist/subagents/runtime.js.map +1 -1
- package/packages/core/dist/test-support/fixtures.js +21 -0
- package/packages/core/dist/test-support/fixtures.js.map +1 -1
- package/packages/core/dist/test-support/run-state.d.ts +1 -1
- package/packages/core/dist/test-support/run-state.js +19 -20
- package/packages/core/dist/test-support/run-state.js.map +1 -1
- package/packages/core/dist/truth-reconciliation.d.ts +44 -0
- package/packages/core/dist/truth-reconciliation.js +138 -0
- package/packages/core/dist/truth-reconciliation.js.map +1 -0
- package/packages/core/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/core/dist/verification/goal-verify.d.ts +0 -1
- package/packages/core/dist/verification/goal-verify.js +44 -37
- package/packages/core/dist/verification/goal-verify.js.map +1 -1
- package/packages/core/dist/verification/rendering.d.ts +0 -2
- package/packages/core/dist/verification/rendering.js +19 -49
- package/packages/core/dist/verification/rendering.js.map +1 -1
- package/packages/core/dist/verification/review-gate.d.ts +22 -0
- package/packages/core/dist/verification/review-gate.js +53 -0
- package/packages/core/dist/verification/review-gate.js.map +1 -0
- package/packages/core/dist/verification/single-task-loop.d.ts +0 -1
- package/packages/core/dist/verification/single-task-loop.js +213 -111
- package/packages/core/dist/verification/single-task-loop.js.map +1 -1
- package/packages/core/dist/verification/test-runtime.d.ts +28 -3
- package/packages/core/dist/verification/test-runtime.js +546 -125
- package/packages/core/dist/verification/test-runtime.js.map +1 -1
- package/packages/core/dist/verification/validation-cache.d.ts +26 -0
- package/packages/core/dist/verification/validation-cache.js +73 -0
- package/packages/core/dist/verification/validation-cache.js.map +1 -0
- package/packages/core/dist/verification/validation-wave.d.ts +76 -0
- package/packages/core/dist/verification/validation-wave.js +450 -0
- package/packages/core/dist/verification/validation-wave.js.map +1 -0
- package/packages/core/dist/verification/verify-contract.d.ts +3 -1
- package/packages/core/dist/verification/verify-contract.js +105 -30
- package/packages/core/dist/verification/verify-contract.js.map +1 -1
- package/packages/core/dist/verification.d.ts +2 -0
- package/packages/core/dist/verification.js +2 -0
- package/packages/core/dist/verification.js.map +1 -1
- package/packages/core/dist/work-units/contracts.d.ts +1 -1
- package/packages/core/dist/workflow-gate/evidence-packet.d.ts +24 -0
- package/packages/core/dist/workflow-gate/evidence-packet.js +395 -0
- package/packages/core/dist/workflow-gate/evidence-packet.js.map +1 -0
- package/packages/core/dist/workflow-gate/hard-checks.d.ts +4 -0
- package/packages/core/dist/workflow-gate/hard-checks.js +164 -0
- package/packages/core/dist/workflow-gate/hard-checks.js.map +1 -0
- package/packages/core/dist/workflow-gate/policy.d.ts +4 -0
- package/packages/core/dist/workflow-gate/policy.js +182 -0
- package/packages/core/dist/workflow-gate/policy.js.map +1 -0
- package/packages/core/dist/workflow-gate/types.d.ts +88 -0
- package/packages/core/dist/workflow-gate/types.js +2 -0
- package/packages/core/dist/workflow-gate/types.js.map +1 -0
- package/packages/core/dist/workflow-state/affected-file-conflicts.d.ts +1 -1
- package/packages/core/dist/workflow-state/affected-file-conflicts.js +17 -3
- package/packages/core/dist/workflow-state/affected-file-conflicts.js.map +1 -1
- package/packages/core/dist/workflow-state/dependencies.d.ts +8 -4
- package/packages/core/dist/workflow-state/dependencies.js +25 -11
- package/packages/core/dist/workflow-state/dependencies.js.map +1 -1
- package/packages/core/dist/workflow-state/latest-eligible-run.d.ts +37 -0
- package/packages/core/dist/workflow-state/latest-eligible-run.js +188 -0
- package/packages/core/dist/workflow-state/latest-eligible-run.js.map +1 -0
- package/packages/core/dist/workflow-state/migration-recovery.d.ts +40 -0
- package/packages/core/dist/workflow-state/migration-recovery.js +110 -0
- package/packages/core/dist/workflow-state/migration-recovery.js.map +1 -0
- package/packages/core/dist/workflow-state/repair-contract.d.ts +12 -0
- package/packages/core/dist/workflow-state/repair-contract.js +63 -0
- package/packages/core/dist/workflow-state/repair-contract.js.map +1 -0
- package/packages/core/dist/workflow-state/resolve-task-run.d.ts +21 -0
- package/packages/core/dist/workflow-state/resolve-task-run.js +95 -0
- package/packages/core/dist/workflow-state/resolve-task-run.js.map +1 -0
- package/packages/core/dist/workflow-state/resolve.d.ts +80 -3
- package/packages/core/dist/workflow-state/resolve.js +674 -41
- package/packages/core/dist/workflow-state/resolve.js.map +1 -1
- package/packages/core/dist/workflow-state/runtime-projections.d.ts +228 -0
- package/packages/core/dist/workflow-state/runtime-projections.js +452 -0
- package/packages/core/dist/workflow-state/runtime-projections.js.map +1 -0
- package/packages/core/dist/workflow-state.d.ts +1 -0
- package/packages/core/dist/workflow-state.js +1 -0
- package/packages/core/dist/workflow-state.js.map +1 -1
- package/packages/core/package.json +3 -3
- package/node_modules/@sdd-agent-platform/core/dist/doctor/render.d.ts +0 -2
- package/node_modules/@sdd-agent-platform/core/dist/doctor/render.js +0 -44
- package/node_modules/@sdd-agent-platform/core/dist/doctor/render.js.map +0 -1
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.d.ts +0 -17
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.js +0 -221
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.js.map +0 -1
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.d.ts +0 -91
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.js +0 -395
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.js.map +0 -1
- package/node_modules/@sdd-agent-platform/core/dist/sync-back.d.ts +0 -2
- package/node_modules/@sdd-agent-platform/core/dist/sync-back.js +0 -3
- package/node_modules/@sdd-agent-platform/core/dist/sync-back.js.map +0 -1
- package/node_modules/@sdd-agent-platform/core/src/sync-back/apply.ts +0 -248
- package/node_modules/@sdd-agent-platform/core/src/sync-back/inspect.ts +0 -522
- package/node_modules/@sdd-agent-platform/core/src/sync-back/sync-back.test.ts +0 -446
- package/node_modules/@sdd-agent-platform/core/src/sync-back.ts +0 -2
- package/packages/cli/dist/commands/artifact.d.ts +0 -6
- package/packages/cli/dist/commands/artifact.js +0 -168
- package/packages/cli/dist/commands/artifact.js.map +0 -1
- package/packages/cli/dist/commands/sync-back.d.ts +0 -6
- package/packages/cli/dist/commands/sync-back.js +0 -82
- package/packages/cli/dist/commands/sync-back.js.map +0 -1
- package/packages/cli/dist/renderers/artifacts.d.ts +0 -5
- package/packages/cli/dist/renderers/artifacts.js +0 -43
- package/packages/cli/dist/renderers/artifacts.js.map +0 -1
- package/packages/core/dist/doctor/render.d.ts +0 -2
- package/packages/core/dist/doctor/render.js +0 -44
- package/packages/core/dist/doctor/render.js.map +0 -1
- package/packages/core/dist/sync-back/apply.d.ts +0 -17
- package/packages/core/dist/sync-back/apply.js +0 -221
- package/packages/core/dist/sync-back/apply.js.map +0 -1
- package/packages/core/dist/sync-back/inspect.d.ts +0 -91
- package/packages/core/dist/sync-back/inspect.js +0 -395
- package/packages/core/dist/sync-back/inspect.js.map +0 -1
- package/packages/core/dist/sync-back.d.ts +0 -2
- package/packages/core/dist/sync-back.js +0 -3
- package/packages/core/dist/sync-back.js.map +0 -1
|
@@ -3,11 +3,17 @@ import { mkdir, readFile } from 'node:fs/promises';
|
|
|
3
3
|
import { getRuntimeStorePath, getSddDir } from '../runtime-paths.js';
|
|
4
4
|
import { exists } from './json-io.js';
|
|
5
5
|
import type { InvocationLedgerEntry, RuntimeEvent, RunState } from '../run-state/model.js';
|
|
6
|
-
import { RUNTIME_PROJECTION_ENVELOPE_CONTRACT_VERSION, type RuntimeProjectionEnvelope, type RuntimeProjectionStaleness } from '../contracts.js';
|
|
6
|
+
import { INVOCATION_LEDGER_CONTRACT_VERSION, RUNTIME_PROJECTION_ENVELOPE_CONTRACT_VERSION, type RuntimeProjectionEnvelope, type RuntimeProjectionStaleness } from '../contracts.js';
|
|
7
|
+
import type { AgentExecutionRecord, TeamSessionRecord } from '../router/agent-runtime.js';
|
|
8
|
+
import type { ResidentWorkerRuntimeRecord } from '../execution/resident-worker.js';
|
|
9
|
+
import { assertAdvisoryAssessment, assertValidFanInEvidenceSet, assertValidStageRoleResult, type FanInEvidenceSetRecord, type LlmAdvisorAssessmentRecord, type StageRoleResultRecord, type StageTeamSessionRecord } from '../execution/stage-team-runtime.js';
|
|
10
|
+
import type { WorkflowGateDecision, WorkflowGateDecisionKind } from '../workflow-gate/types.js';
|
|
11
|
+
import type { RegisteredStageArtifact } from '../stage-artifacts.js';
|
|
12
|
+
import type { RegisteredStageCollaborationContract } from '../stage-collaboration-contracts.js';
|
|
7
13
|
|
|
8
14
|
|
|
9
|
-
export const RUNTIME_STORE_SCHEMA_VERSION =
|
|
10
|
-
export const RUNTIME_STORE_CONTRACT_VERSION = 'phase-
|
|
15
|
+
export const RUNTIME_STORE_SCHEMA_VERSION = 12;
|
|
16
|
+
export const RUNTIME_STORE_CONTRACT_VERSION = 'phase-9.1-stage-collaboration-contracts-runtime-v12';
|
|
11
17
|
|
|
12
18
|
export type RuntimeStoreIssueCode = 'STORE_UNAVAILABLE' | 'SCHEMA_MISMATCH' | 'LEGACY_IMPORT_FAILED';
|
|
13
19
|
|
|
@@ -43,6 +49,224 @@ export interface RuntimeStoreDoctorCheck {
|
|
|
43
49
|
action?: string;
|
|
44
50
|
}
|
|
45
51
|
|
|
52
|
+
export type RuntimeArtifactPayloadStatus = 'active' | 'candidate' | 'partial' | 'active_attempt' | 'rejected' | 'superseded' | 'quarantined' | 'stale';
|
|
53
|
+
|
|
54
|
+
export interface RuntimeArtifactPayloadRecord {
|
|
55
|
+
payloadId: string;
|
|
56
|
+
runId: string;
|
|
57
|
+
sourceRunId: string;
|
|
58
|
+
branchSlug: string;
|
|
59
|
+
taskId: string | null;
|
|
60
|
+
logicalRef: string;
|
|
61
|
+
physicalPayloadPath: string;
|
|
62
|
+
artifactRole: string;
|
|
63
|
+
digest: string;
|
|
64
|
+
sequence: number;
|
|
65
|
+
status: RuntimeArtifactPayloadStatus;
|
|
66
|
+
supersedes: string | null;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
payload: unknown;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type RuntimeEvidenceSetScopeKind = 'task' | 'batch' | 'wave' | 'ship';
|
|
72
|
+
export type RuntimeEvidenceSetStatus = 'candidate' | 'accepted' | 'partial' | 'rejected' | 'superseded' | 'quarantined' | 'stale';
|
|
73
|
+
|
|
74
|
+
export interface RuntimeEvidenceSetItemRecord {
|
|
75
|
+
evidenceSetId: string;
|
|
76
|
+
payloadId: string;
|
|
77
|
+
logicalRef: string;
|
|
78
|
+
role: string;
|
|
79
|
+
required: boolean;
|
|
80
|
+
digestAtSelection: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface RuntimeEvidenceSetRecord {
|
|
84
|
+
evidenceSetId: string;
|
|
85
|
+
branchSlug: string;
|
|
86
|
+
scopeKind: RuntimeEvidenceSetScopeKind;
|
|
87
|
+
scopeId: string;
|
|
88
|
+
sourceRunId: string | null;
|
|
89
|
+
documentContractHashes: Record<string, string | null>;
|
|
90
|
+
gateDecisionId: string | null;
|
|
91
|
+
status: RuntimeEvidenceSetStatus;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
items: RuntimeEvidenceSetItemRecord[];
|
|
94
|
+
payload: unknown;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface RuntimeSelectionPointerRecord {
|
|
98
|
+
branchSlug: string;
|
|
99
|
+
scopeKind: RuntimeEvidenceSetScopeKind;
|
|
100
|
+
scopeId: string;
|
|
101
|
+
selectedEvidenceSetId: string;
|
|
102
|
+
selectedAt: string;
|
|
103
|
+
selectedByGateDecisionId: string | null;
|
|
104
|
+
reason: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface RuntimeResolvedEvidenceSelection {
|
|
108
|
+
source: 'selection_pointer' | 'candidate_payloads' | 'legacy_active_payloads' | 'none';
|
|
109
|
+
evidenceSet: RuntimeEvidenceSetRecord | null;
|
|
110
|
+
pointer: RuntimeSelectionPointerRecord | null;
|
|
111
|
+
payloads: RuntimeArtifactPayloadRecord[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
export type RuntimeDurableGapSeverity = 'info' | 'warning' | 'blocking';
|
|
116
|
+
export type RuntimeDurableGapStatus = 'open' | 'acknowledged' | 'resolved' | 'waived' | 'superseded';
|
|
117
|
+
export type RuntimeDurableGapSource = 'runtime' | 'gate_policy' | 'doctor' | 'validator' | 'agent' | 'team' | 'llm_advisor' | 'import';
|
|
118
|
+
|
|
119
|
+
export interface RuntimeDurableGapRecord {
|
|
120
|
+
gapId: string;
|
|
121
|
+
partition: string;
|
|
122
|
+
taskId: string | null;
|
|
123
|
+
runId: string | null;
|
|
124
|
+
stage: string | null;
|
|
125
|
+
gate: string | null;
|
|
126
|
+
source: RuntimeDurableGapSource;
|
|
127
|
+
category: string;
|
|
128
|
+
severity: RuntimeDurableGapSeverity;
|
|
129
|
+
status: RuntimeDurableGapStatus;
|
|
130
|
+
message: string;
|
|
131
|
+
recommendation: string | null;
|
|
132
|
+
evidenceRefs: string[];
|
|
133
|
+
proposalRefs: string[];
|
|
134
|
+
sourceRefs: string[];
|
|
135
|
+
createdAt: string;
|
|
136
|
+
updatedAt: string;
|
|
137
|
+
closedAt: string | null;
|
|
138
|
+
payload: unknown;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type RuntimeValidationWaveStatus = 'RUNNING' | 'PASS' | 'FAIL' | 'BLOCKED';
|
|
142
|
+
export type RuntimeValidationEnvironmentStatus = 'active' | 'completed' | 'failed' | 'blocked';
|
|
143
|
+
|
|
144
|
+
export interface RuntimeValidationEnvironmentSessionRecord {
|
|
145
|
+
sessionId: string;
|
|
146
|
+
partition: string;
|
|
147
|
+
runId: string | null;
|
|
148
|
+
waveRunId: string | null;
|
|
149
|
+
status: RuntimeValidationEnvironmentStatus;
|
|
150
|
+
reuseKey: string;
|
|
151
|
+
createdAt: string;
|
|
152
|
+
updatedAt: string;
|
|
153
|
+
payload: unknown;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface RuntimeValidationWaveRunRecord {
|
|
157
|
+
waveRunId: string;
|
|
158
|
+
partition: string;
|
|
159
|
+
runId: string | null;
|
|
160
|
+
taskIds: string[];
|
|
161
|
+
status: RuntimeValidationWaveStatus;
|
|
162
|
+
environmentSessionId: string;
|
|
163
|
+
startedAt: string;
|
|
164
|
+
completedAt: string;
|
|
165
|
+
payload: unknown;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface RuntimeAcceptanceEvidenceMapRecord {
|
|
169
|
+
mapId: string;
|
|
170
|
+
waveRunId: string;
|
|
171
|
+
testRunId: string;
|
|
172
|
+
partition: string;
|
|
173
|
+
runId: string;
|
|
174
|
+
taskId: string;
|
|
175
|
+
acceptanceRef: string;
|
|
176
|
+
status: string;
|
|
177
|
+
evidenceRefs: string[];
|
|
178
|
+
gaps: string[];
|
|
179
|
+
createdAt: string;
|
|
180
|
+
payload: unknown;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export type RuntimeValidationCacheEntryStatus = 'valid' | 'stale' | 'superseded';
|
|
184
|
+
|
|
185
|
+
export interface RuntimeValidationCacheEntryRecord {
|
|
186
|
+
cacheKey: string;
|
|
187
|
+
branchSlug: string;
|
|
188
|
+
command: string;
|
|
189
|
+
status: RuntimeValidationCacheEntryStatus;
|
|
190
|
+
sourceTestRunId: string;
|
|
191
|
+
sourceRunId: string;
|
|
192
|
+
sourceEvidenceSetId: string | null;
|
|
193
|
+
outputArtifact: string | null;
|
|
194
|
+
stdoutDigest: string;
|
|
195
|
+
stderrDigest: string;
|
|
196
|
+
createdAt: string;
|
|
197
|
+
lastUsedAt: string;
|
|
198
|
+
payload: unknown;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface RuntimeValidationCacheUseRecord {
|
|
202
|
+
useId: string;
|
|
203
|
+
cacheKey: string;
|
|
204
|
+
branchSlug: string;
|
|
205
|
+
testRunId: string;
|
|
206
|
+
runId: string;
|
|
207
|
+
taskId: string;
|
|
208
|
+
sourceTestRunId: string;
|
|
209
|
+
sourceEvidenceSetId: string | null;
|
|
210
|
+
reusedAt: string;
|
|
211
|
+
mappedTaskIds: string[];
|
|
212
|
+
reason: string;
|
|
213
|
+
payload: unknown;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type RuntimeRepairType = 'contract_repair' | 'implementation_repair' | 'validation_command_repair' | 'artifact_repair' | 'environment_repair' | 'gate_policy_repair' | 'migration_repair';
|
|
217
|
+
export type RuntimeRepairStatus = 'open' | 'in_progress' | 'resolved' | 'superseded';
|
|
218
|
+
|
|
219
|
+
export interface RuntimeRepairRecord {
|
|
220
|
+
repairId: string;
|
|
221
|
+
branchSlug: string;
|
|
222
|
+
taskId: string | null;
|
|
223
|
+
repairType: RuntimeRepairType;
|
|
224
|
+
repairOfRunId: string | null;
|
|
225
|
+
repairOfGateDecisionId: string | null;
|
|
226
|
+
status: RuntimeRepairStatus;
|
|
227
|
+
affectedTasks: string[];
|
|
228
|
+
blockers: string[];
|
|
229
|
+
recommendedCommands: string[];
|
|
230
|
+
requiredEvidence: string[];
|
|
231
|
+
createdAt: string;
|
|
232
|
+
resolvedAt: string | null;
|
|
233
|
+
payload: unknown;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export type RuntimeCapabilityAdoptionStage = 'spec' | 'plan' | 'tasks' | 'verifies' | 'do' | 'test' | 'goal-verify' | 'ship';
|
|
237
|
+
export type RuntimeCapabilityAdoptionStatus = 'adopted' | 'rejected' | 'unresolved';
|
|
238
|
+
export type RuntimeCapabilityAdoptionAuthority = 'sdd_contract' | 'sdd_gate';
|
|
239
|
+
|
|
240
|
+
export interface RuntimeCapabilityAdoptionRecord {
|
|
241
|
+
adoptionId: string;
|
|
242
|
+
branchSlug: string;
|
|
243
|
+
lifecycleStage: RuntimeCapabilityAdoptionStage;
|
|
244
|
+
capabilityDomain: string;
|
|
245
|
+
sourceId: string | null;
|
|
246
|
+
status: RuntimeCapabilityAdoptionStatus;
|
|
247
|
+
reason: string;
|
|
248
|
+
evidenceRefs: string[];
|
|
249
|
+
finalAuthority: RuntimeCapabilityAdoptionAuthority;
|
|
250
|
+
createdAt: string;
|
|
251
|
+
updatedAt: string;
|
|
252
|
+
payload: unknown;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface RuntimeStageArtifactFilter {
|
|
256
|
+
branchSlug?: string | null;
|
|
257
|
+
stage?: string | null;
|
|
258
|
+
artifactKind?: string | null;
|
|
259
|
+
producer?: string | null;
|
|
260
|
+
artifactRef?: string | null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface RuntimeStageCollaborationContractFilter {
|
|
264
|
+
branchSlug?: string | null;
|
|
265
|
+
stage?: string | null;
|
|
266
|
+
status?: RegisteredStageCollaborationContract['status'] | null;
|
|
267
|
+
contractRef?: string | null;
|
|
268
|
+
}
|
|
269
|
+
|
|
46
270
|
|
|
47
271
|
let runtimeStoreConstructorPromise: Promise<RuntimeStoreConstructor> | null = null;
|
|
48
272
|
|
|
@@ -108,6 +332,8 @@ function initializeRuntimeStoreSchema(db: RuntimeStoreDatabase): void {
|
|
|
108
332
|
if (currentVersion > RUNTIME_STORE_SCHEMA_VERSION) {
|
|
109
333
|
throw new RuntimeStoreError('SCHEMA_MISMATCH', `Runtime store schema ${currentVersion} is newer than supported schema ${RUNTIME_STORE_SCHEMA_VERSION}.`);
|
|
110
334
|
}
|
|
335
|
+
migrateRuntimeStoreSchema(db, currentVersion);
|
|
336
|
+
|
|
111
337
|
db.exec(`
|
|
112
338
|
CREATE TABLE IF NOT EXISTS runtime_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL, updated_at TEXT NOT NULL);
|
|
113
339
|
CREATE TABLE IF NOT EXISTS runs (run_id TEXT PRIMARY KEY, status TEXT NOT NULL, phase TEXT, current_task TEXT, partition TEXT, git_branch TEXT, task_id TEXT, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, state_json TEXT NOT NULL, state_hash TEXT NOT NULL);
|
|
@@ -125,7 +351,29 @@ CREATE TABLE IF NOT EXISTS source_snapshots (snapshot_id TEXT PRIMARY KEY, run_i
|
|
|
125
351
|
CREATE TABLE IF NOT EXISTS projections (projection_id TEXT PRIMARY KEY, projection_type TEXT NOT NULL, scope_key TEXT NOT NULL, generated_at TEXT NOT NULL, payload_json TEXT NOT NULL, UNIQUE(projection_type, scope_key));
|
|
126
352
|
CREATE TABLE IF NOT EXISTS legacy_imports (import_id TEXT PRIMARY KEY, run_id TEXT NOT NULL, entity_type TEXT NOT NULL, content_hash TEXT NOT NULL, imported_at TEXT NOT NULL, status TEXT NOT NULL, issue TEXT, UNIQUE(run_id, entity_type));
|
|
127
353
|
CREATE TABLE IF NOT EXISTS test_runs (test_run_id TEXT PRIMARY KEY, run_id TEXT NOT NULL, partition TEXT, task_id TEXT NOT NULL, status TEXT NOT NULL, started_at TEXT NOT NULL, completed_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE CASCADE);
|
|
128
|
-
CREATE TABLE IF NOT EXISTS test_steps (test_step_id TEXT PRIMARY KEY, test_run_id TEXT NOT NULL, run_id TEXT NOT NULL, task_id TEXT NOT NULL, command TEXT NOT NULL, status TEXT NOT NULL, exit_code INTEGER, duration_ms INTEGER NOT NULL, output_artifact TEXT
|
|
354
|
+
CREATE TABLE IF NOT EXISTS test_steps (test_step_id TEXT PRIMARY KEY, test_run_id TEXT NOT NULL, run_id TEXT NOT NULL, task_id TEXT NOT NULL, command TEXT NOT NULL, status TEXT NOT NULL, exit_code INTEGER, duration_ms INTEGER NOT NULL, output_artifact TEXT, payload_json TEXT NOT NULL, FOREIGN KEY(test_run_id) REFERENCES test_runs(test_run_id) ON DELETE CASCADE, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE CASCADE);
|
|
355
|
+
CREATE TABLE IF NOT EXISTS agent_executions (execution_id TEXT PRIMARY KEY, run_id TEXT NOT NULL, task_id TEXT NOT NULL, profile TEXT NOT NULL, status TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE CASCADE);
|
|
356
|
+
CREATE TABLE IF NOT EXISTS team_sessions (team_id TEXT PRIMARY KEY, run_id TEXT NOT NULL, task_id TEXT, status TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE CASCADE);
|
|
357
|
+
CREATE TABLE IF NOT EXISTS worker_runtimes (runtime_id TEXT NOT NULL, run_id TEXT NOT NULL, task_id TEXT NOT NULL, status TEXT NOT NULL, claimed_at TEXT NOT NULL, updated_at TEXT NOT NULL, payload_json TEXT NOT NULL, PRIMARY KEY(run_id, runtime_id), FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE CASCADE);
|
|
358
|
+
CREATE TABLE IF NOT EXISTS artifact_payloads (payload_id TEXT PRIMARY KEY, run_id TEXT NOT NULL, source_run_id TEXT NOT NULL, branch_slug TEXT NOT NULL, task_id TEXT, logical_ref TEXT NOT NULL, physical_payload_path TEXT NOT NULL, artifact_role TEXT NOT NULL, digest TEXT NOT NULL, sequence INTEGER NOT NULL, status TEXT NOT NULL, supersedes TEXT, created_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE CASCADE, UNIQUE(branch_slug, physical_payload_path), UNIQUE(run_id, logical_ref, digest));
|
|
359
|
+
CREATE TABLE IF NOT EXISTS evidence_sets (evidence_set_id TEXT PRIMARY KEY, branch_slug TEXT NOT NULL, scope_kind TEXT NOT NULL, scope_id TEXT NOT NULL, source_run_id TEXT, document_contract_hashes_json TEXT NOT NULL, gate_decision_id TEXT, status TEXT NOT NULL, created_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(source_run_id) REFERENCES runs(run_id) ON DELETE SET NULL);
|
|
360
|
+
CREATE TABLE IF NOT EXISTS evidence_set_items (evidence_set_id TEXT NOT NULL, payload_id TEXT NOT NULL, logical_ref TEXT NOT NULL, role TEXT NOT NULL, required INTEGER NOT NULL, digest_at_selection TEXT NOT NULL, PRIMARY KEY(evidence_set_id, payload_id), FOREIGN KEY(evidence_set_id) REFERENCES evidence_sets(evidence_set_id) ON DELETE CASCADE, FOREIGN KEY(payload_id) REFERENCES artifact_payloads(payload_id) ON DELETE CASCADE);
|
|
361
|
+
CREATE TABLE IF NOT EXISTS selection_pointers (branch_slug TEXT NOT NULL, scope_kind TEXT NOT NULL, scope_id TEXT NOT NULL, selected_evidence_set_id TEXT NOT NULL, selected_at TEXT NOT NULL, selected_by_gate_decision_id TEXT, reason TEXT NOT NULL, PRIMARY KEY(branch_slug, scope_kind, scope_id), FOREIGN KEY(selected_evidence_set_id) REFERENCES evidence_sets(evidence_set_id) ON DELETE CASCADE);
|
|
362
|
+
CREATE TABLE IF NOT EXISTS durable_gaps (gap_id TEXT PRIMARY KEY, partition TEXT NOT NULL, task_id TEXT, run_id TEXT, stage TEXT, gate_name TEXT, source TEXT NOT NULL, category TEXT NOT NULL, severity TEXT NOT NULL, status TEXT NOT NULL, message TEXT NOT NULL, recommendation TEXT, evidence_refs_json TEXT NOT NULL, proposal_refs_json TEXT NOT NULL, source_refs_json TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, closed_at TEXT, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE SET NULL);
|
|
363
|
+
CREATE TABLE IF NOT EXISTS stage_team_sessions (session_id TEXT PRIMARY KEY, partition TEXT NOT NULL, run_id TEXT, task_id TEXT, stage TEXT NOT NULL, lifecycle_profile TEXT NOT NULL, status TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE SET NULL);
|
|
364
|
+
CREATE TABLE IF NOT EXISTS stage_role_results (result_id TEXT PRIMARY KEY, session_id TEXT NOT NULL, partition TEXT NOT NULL, run_id TEXT, task_id TEXT, role_id TEXT NOT NULL, agent_id TEXT, output_kind TEXT NOT NULL, authority_ceiling TEXT NOT NULL, status TEXT NOT NULL, created_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE SET NULL);
|
|
365
|
+
CREATE TABLE IF NOT EXISTS llm_advisor_assessments (assessment_id TEXT PRIMARY KEY, session_id TEXT, partition TEXT NOT NULL, run_id TEXT, task_id TEXT, kind TEXT NOT NULL, concern TEXT NOT NULL, advisory_only INTEGER NOT NULL, created_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE SET NULL);
|
|
366
|
+
CREATE TABLE IF NOT EXISTS fan_in_evidence_sets (fan_in_id TEXT PRIMARY KEY, partition TEXT NOT NULL, run_id TEXT, task_id TEXT, stage TEXT NOT NULL, gate_input_only INTEGER NOT NULL, created_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE SET NULL);
|
|
367
|
+
CREATE TABLE IF NOT EXISTS workflow_gate_decisions (decision_id TEXT PRIMARY KEY, input_hash TEXT NOT NULL, partition TEXT NOT NULL, run_id TEXT, task_id TEXT, decision_kind TEXT NOT NULL, status TEXT NOT NULL, decided_by TEXT NOT NULL, generated_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE SET NULL);
|
|
368
|
+
CREATE TABLE IF NOT EXISTS validation_environment_sessions (session_id TEXT PRIMARY KEY, partition TEXT NOT NULL, run_id TEXT, wave_run_id TEXT, status TEXT NOT NULL, reuse_key TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE SET NULL);
|
|
369
|
+
CREATE TABLE IF NOT EXISTS validation_wave_runs (wave_run_id TEXT PRIMARY KEY, partition TEXT NOT NULL, run_id TEXT, task_ids_json TEXT NOT NULL, status TEXT NOT NULL, environment_session_id TEXT NOT NULL, started_at TEXT NOT NULL, completed_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE SET NULL);
|
|
370
|
+
CREATE TABLE IF NOT EXISTS acceptance_evidence_maps (map_id TEXT PRIMARY KEY, wave_run_id TEXT NOT NULL, test_run_id TEXT NOT NULL, partition TEXT NOT NULL, run_id TEXT NOT NULL, task_id TEXT NOT NULL, acceptance_ref TEXT NOT NULL, status TEXT NOT NULL, evidence_refs_json TEXT NOT NULL, gaps_json TEXT NOT NULL, created_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE CASCADE);
|
|
371
|
+
CREATE TABLE IF NOT EXISTS validation_cache_entries (cache_key TEXT PRIMARY KEY, branch_slug TEXT NOT NULL, command TEXT NOT NULL, status TEXT NOT NULL, source_test_run_id TEXT NOT NULL, source_run_id TEXT NOT NULL, source_evidence_set_id TEXT, output_artifact TEXT, stdout_digest TEXT NOT NULL, stderr_digest TEXT NOT NULL, created_at TEXT NOT NULL, last_used_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(source_test_run_id) REFERENCES test_runs(test_run_id) ON DELETE CASCADE, FOREIGN KEY(source_run_id) REFERENCES runs(run_id) ON DELETE CASCADE, FOREIGN KEY(source_evidence_set_id) REFERENCES evidence_sets(evidence_set_id) ON DELETE SET NULL);
|
|
372
|
+
CREATE TABLE IF NOT EXISTS validation_cache_uses (use_id TEXT PRIMARY KEY, cache_key TEXT NOT NULL, branch_slug TEXT NOT NULL, test_run_id TEXT NOT NULL, run_id TEXT NOT NULL, task_id TEXT NOT NULL, source_test_run_id TEXT NOT NULL, source_evidence_set_id TEXT, reused_at TEXT NOT NULL, mapped_task_ids_json TEXT NOT NULL, reason TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(cache_key) REFERENCES validation_cache_entries(cache_key) ON DELETE CASCADE, FOREIGN KEY(test_run_id) REFERENCES test_runs(test_run_id) ON DELETE CASCADE, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE CASCADE);
|
|
373
|
+
CREATE TABLE IF NOT EXISTS repair_records (repair_id TEXT PRIMARY KEY, branch_slug TEXT NOT NULL, task_id TEXT, repair_type TEXT NOT NULL, repair_of_run_id TEXT, repair_of_gate_decision_id TEXT, status TEXT NOT NULL, affected_tasks_json TEXT NOT NULL, blockers_json TEXT NOT NULL, recommended_commands_json TEXT NOT NULL, required_evidence_json TEXT NOT NULL, created_at TEXT NOT NULL, resolved_at TEXT, payload_json TEXT NOT NULL, FOREIGN KEY(repair_of_run_id) REFERENCES runs(run_id) ON DELETE SET NULL, FOREIGN KEY(repair_of_gate_decision_id) REFERENCES workflow_gate_decisions(decision_id) ON DELETE SET NULL);
|
|
374
|
+
CREATE TABLE IF NOT EXISTS capability_adoptions (adoption_id TEXT PRIMARY KEY, branch_slug TEXT NOT NULL, lifecycle_stage TEXT NOT NULL, capability_domain TEXT NOT NULL, source_id TEXT, status TEXT NOT NULL, reason TEXT NOT NULL, evidence_refs_json TEXT NOT NULL, final_authority TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, payload_json TEXT NOT NULL, UNIQUE(branch_slug, lifecycle_stage, capability_domain, source_id));
|
|
375
|
+
CREATE TABLE IF NOT EXISTS stage_artifacts (artifact_id TEXT PRIMARY KEY, branch_slug TEXT NOT NULL, stage TEXT NOT NULL, artifact_kind TEXT NOT NULL, producer TEXT NOT NULL, artifact_ref TEXT NOT NULL, content_hash TEXT NOT NULL, contract TEXT NOT NULL, target_ref TEXT, target_hash TEXT, review_ref TEXT, review_hash TEXT, verdict TEXT, finding_count INTEGER, blocking_count INTEGER, recommendation TEXT, frontmatter_json TEXT NOT NULL, registered_at TEXT NOT NULL, payload_json TEXT NOT NULL, UNIQUE(branch_slug, stage, artifact_ref, content_hash));
|
|
376
|
+
CREATE TABLE IF NOT EXISTS stage_collaboration_contracts (contract_id TEXT PRIMARY KEY, branch_slug TEXT NOT NULL, stage TEXT NOT NULL, contract_ref TEXT NOT NULL, content_hash TEXT NOT NULL, contract_version TEXT NOT NULL, producer TEXT NOT NULL, work_order_id TEXT, status TEXT NOT NULL, validation_errors_json TEXT NOT NULL, selected_agents_json TEXT NOT NULL, selected_skills_json TEXT NOT NULL, selected_materials_json TEXT NOT NULL, evidence_contracts_json TEXT NOT NULL, checkpoint_plan_json TEXT NOT NULL, rework_plan_json TEXT NOT NULL, permission_projection_json TEXT NOT NULL, frontmatter_json TEXT NOT NULL, registered_at TEXT NOT NULL, payload_json TEXT NOT NULL, UNIQUE(branch_slug, stage, contract_ref, content_hash));
|
|
129
377
|
CREATE INDEX IF NOT EXISTS idx_runs_partition_task_updated ON runs(partition, task_id, updated_at);
|
|
130
378
|
CREATE INDEX IF NOT EXISTS idx_events_run_time ON events(run_id, event_time, event_id);
|
|
131
379
|
CREATE INDEX IF NOT EXISTS idx_artifacts_run_path ON artifacts(run_id, path);
|
|
@@ -134,6 +382,31 @@ CREATE INDEX IF NOT EXISTS idx_evidence_attachments_branch_created ON evidence_a
|
|
|
134
382
|
CREATE INDEX IF NOT EXISTS idx_evidence_attachments_run_path ON evidence_attachments(run_id, relative_path);
|
|
135
383
|
CREATE INDEX IF NOT EXISTS idx_test_runs_run_task ON test_runs(run_id, task_id, completed_at);
|
|
136
384
|
CREATE INDEX IF NOT EXISTS idx_test_steps_test_run ON test_steps(test_run_id, status);
|
|
385
|
+
CREATE INDEX IF NOT EXISTS idx_agent_executions_run_task ON agent_executions(run_id, task_id, created_at);
|
|
386
|
+
CREATE INDEX IF NOT EXISTS idx_team_sessions_run_task ON team_sessions(run_id, task_id, created_at);
|
|
387
|
+
CREATE INDEX IF NOT EXISTS idx_worker_runtimes_run_task ON worker_runtimes(run_id, task_id, updated_at);
|
|
388
|
+
CREATE INDEX IF NOT EXISTS idx_artifact_payloads_logical ON artifact_payloads(branch_slug, logical_ref, status, sequence);
|
|
389
|
+
CREATE INDEX IF NOT EXISTS idx_artifact_payloads_run_logical ON artifact_payloads(run_id, logical_ref, status, sequence);
|
|
390
|
+
CREATE INDEX IF NOT EXISTS idx_evidence_sets_scope ON evidence_sets(branch_slug, scope_kind, scope_id, status, created_at);
|
|
391
|
+
CREATE INDEX IF NOT EXISTS idx_selection_pointers_scope ON selection_pointers(branch_slug, scope_kind, scope_id);
|
|
392
|
+
CREATE INDEX IF NOT EXISTS idx_durable_gaps_partition_task ON durable_gaps(partition, task_id, status, severity, updated_at);
|
|
393
|
+
CREATE INDEX IF NOT EXISTS idx_durable_gaps_run_task ON durable_gaps(run_id, task_id, status, severity, updated_at);
|
|
394
|
+
CREATE INDEX IF NOT EXISTS idx_stage_team_sessions_partition_task ON stage_team_sessions(partition, task_id, updated_at);
|
|
395
|
+
CREATE INDEX IF NOT EXISTS idx_stage_role_results_partition_task ON stage_role_results(partition, task_id, created_at);
|
|
396
|
+
CREATE INDEX IF NOT EXISTS idx_llm_advisor_assessments_partition_task ON llm_advisor_assessments(partition, task_id, created_at);
|
|
397
|
+
CREATE INDEX IF NOT EXISTS idx_fan_in_evidence_sets_partition_task ON fan_in_evidence_sets(partition, task_id, created_at);
|
|
398
|
+
CREATE INDEX IF NOT EXISTS idx_workflow_gate_decisions_partition_task ON workflow_gate_decisions(partition, task_id, decision_kind, generated_at);
|
|
399
|
+
CREATE INDEX IF NOT EXISTS idx_validation_environment_sessions_partition ON validation_environment_sessions(partition, wave_run_id, updated_at);
|
|
400
|
+
CREATE INDEX IF NOT EXISTS idx_validation_wave_runs_partition ON validation_wave_runs(partition, status, completed_at);
|
|
401
|
+
CREATE INDEX IF NOT EXISTS idx_acceptance_evidence_maps_task ON acceptance_evidence_maps(partition, task_id, acceptance_ref, created_at);
|
|
402
|
+
CREATE INDEX IF NOT EXISTS idx_validation_cache_entries_branch_status ON validation_cache_entries(branch_slug, status, last_used_at);
|
|
403
|
+
CREATE INDEX IF NOT EXISTS idx_validation_cache_uses_run_task ON validation_cache_uses(run_id, task_id, reused_at);
|
|
404
|
+
CREATE INDEX IF NOT EXISTS idx_repair_records_branch_status ON repair_records(branch_slug, status, repair_type, created_at);
|
|
405
|
+
CREATE INDEX IF NOT EXISTS idx_capability_adoptions_branch_domain ON capability_adoptions(branch_slug, capability_domain, status, updated_at);
|
|
406
|
+
CREATE INDEX IF NOT EXISTS idx_stage_artifacts_branch_stage ON stage_artifacts(branch_slug, stage, registered_at);
|
|
407
|
+
CREATE INDEX IF NOT EXISTS idx_stage_artifacts_ref ON stage_artifacts(branch_slug, stage, artifact_ref, content_hash);
|
|
408
|
+
CREATE INDEX IF NOT EXISTS idx_stage_collaboration_contracts_branch_stage ON stage_collaboration_contracts(branch_slug, stage, registered_at);
|
|
409
|
+
CREATE INDEX IF NOT EXISTS idx_stage_collaboration_contracts_ref ON stage_collaboration_contracts(branch_slug, stage, contract_ref, content_hash);
|
|
137
410
|
`);
|
|
138
411
|
db.exec(`PRAGMA user_version = ${RUNTIME_STORE_SCHEMA_VERSION}`);
|
|
139
412
|
const now = new Date().toISOString();
|
|
@@ -141,6 +414,43 @@ CREATE INDEX IF NOT EXISTS idx_test_steps_test_run ON test_steps(test_run_id, st
|
|
|
141
414
|
db.prepare('INSERT OR REPLACE INTO runtime_meta (key, value, updated_at) VALUES (?, ?, ?)').run('schema_version', String(RUNTIME_STORE_SCHEMA_VERSION), now);
|
|
142
415
|
}
|
|
143
416
|
|
|
417
|
+
function migrateRuntimeStoreSchema(db: RuntimeStoreDatabase, currentVersion: number): void {
|
|
418
|
+
if (currentVersion === 0 || currentVersion >= RUNTIME_STORE_SCHEMA_VERSION) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (currentVersion < 12) {
|
|
422
|
+
migrateNullableOutputArtifactColumns(db);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function migrateNullableOutputArtifactColumns(db: RuntimeStoreDatabase): void {
|
|
427
|
+
migrateNullableOutputArtifactColumn(db, 'test_steps', 'test_step_id TEXT PRIMARY KEY, test_run_id TEXT NOT NULL, run_id TEXT NOT NULL, task_id TEXT NOT NULL, command TEXT NOT NULL, status TEXT NOT NULL, exit_code INTEGER, duration_ms INTEGER NOT NULL, output_artifact TEXT, payload_json TEXT NOT NULL, FOREIGN KEY(test_run_id) REFERENCES test_runs(test_run_id) ON DELETE CASCADE, FOREIGN KEY(run_id) REFERENCES runs(run_id) ON DELETE CASCADE', 'test_step_id, test_run_id, run_id, task_id, command, status, exit_code, duration_ms, output_artifact, payload_json');
|
|
428
|
+
migrateNullableOutputArtifactColumn(db, 'validation_cache_entries', 'cache_key TEXT PRIMARY KEY, branch_slug TEXT NOT NULL, command TEXT NOT NULL, status TEXT NOT NULL, source_test_run_id TEXT NOT NULL, source_run_id TEXT NOT NULL, source_evidence_set_id TEXT, output_artifact TEXT, stdout_digest TEXT NOT NULL, stderr_digest TEXT NOT NULL, created_at TEXT NOT NULL, last_used_at TEXT NOT NULL, payload_json TEXT NOT NULL, FOREIGN KEY(source_test_run_id) REFERENCES test_runs(test_run_id) ON DELETE CASCADE, FOREIGN KEY(source_run_id) REFERENCES runs(run_id) ON DELETE CASCADE, FOREIGN KEY(source_evidence_set_id) REFERENCES evidence_sets(evidence_set_id) ON DELETE SET NULL', 'cache_key, branch_slug, command, status, source_test_run_id, source_run_id, source_evidence_set_id, output_artifact, stdout_digest, stderr_digest, created_at, last_used_at, payload_json');
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function migrateNullableOutputArtifactColumn(db: RuntimeStoreDatabase, tableName: string, columnDefinitionSql: string, columnsSql: string): void {
|
|
432
|
+
if (!runtimeStoreColumnIsNotNull(db, tableName, 'output_artifact')) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const tempTableName = `${tableName}_runtime_v12`;
|
|
436
|
+
db.exec('PRAGMA foreign_keys = OFF');
|
|
437
|
+
try {
|
|
438
|
+
db.exec(`DROP TABLE IF EXISTS ${tempTableName}`);
|
|
439
|
+
db.exec(`CREATE TABLE ${tempTableName} (${columnDefinitionSql})`);
|
|
440
|
+
db.exec(`INSERT INTO ${tempTableName} (${columnsSql}) SELECT ${columnsSql} FROM ${tableName}`);
|
|
441
|
+
db.exec(`DROP TABLE ${tableName}`);
|
|
442
|
+
db.exec(`ALTER TABLE ${tempTableName} RENAME TO ${tableName}`);
|
|
443
|
+
} finally {
|
|
444
|
+
db.exec('PRAGMA foreign_keys = ON');
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function runtimeStoreColumnIsNotNull(db: RuntimeStoreDatabase, tableName: string, columnName: string): boolean {
|
|
449
|
+
const rows = db.prepare(`PRAGMA table_info(${tableName})`).all() as Array<{ name?: string; notnull?: number }>;
|
|
450
|
+
const column = rows.find((row) => row.name === columnName);
|
|
451
|
+
return (column?.notnull ?? 0) === 1;
|
|
452
|
+
}
|
|
453
|
+
|
|
144
454
|
function readRuntimeStoreSchemaVersion(db: RuntimeStoreDatabase): number {
|
|
145
455
|
const row = db.prepare('PRAGMA user_version').get() as { user_version?: unknown } | undefined;
|
|
146
456
|
return typeof row?.user_version === 'number' ? row.user_version : 0;
|
|
@@ -209,6 +519,161 @@ export async function listRuntimeRunStates(projectRoot: string): Promise<RunStat
|
|
|
209
519
|
});
|
|
210
520
|
}
|
|
211
521
|
|
|
522
|
+
export async function recordRuntimeAgentExecution(projectRoot: string, record: AgentExecutionRecord): Promise<void> {
|
|
523
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
524
|
+
db.prepare('INSERT OR REPLACE INTO agent_executions (execution_id, run_id, task_id, profile, status, created_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')
|
|
525
|
+
.run(record.executionId, record.runId, record.taskId, record.profile, record.status, record.createdAt, record.updatedAt, JSON.stringify(record));
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export async function listRuntimeAgentExecutions(projectRoot: string, runId: string): Promise<AgentExecutionRecord[]> {
|
|
530
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
531
|
+
const rows = db.prepare('SELECT payload_json FROM agent_executions WHERE run_id = ? ORDER BY created_at ASC, execution_id ASC').all(runId) as Array<{ payload_json: string }>;
|
|
532
|
+
return rows.map((row) => JSON.parse(row.payload_json) as AgentExecutionRecord);
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export async function recordRuntimeTeamSession(projectRoot: string, record: TeamSessionRecord): Promise<void> {
|
|
537
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
538
|
+
db.prepare('INSERT OR REPLACE INTO team_sessions (team_id, run_id, task_id, status, created_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?)')
|
|
539
|
+
.run(record.teamId, record.runId, record.taskId, record.status, record.createdAt, record.updatedAt, JSON.stringify(record));
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export async function listRuntimeTeamSessions(projectRoot: string, runId: string): Promise<TeamSessionRecord[]> {
|
|
544
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
545
|
+
const rows = db.prepare('SELECT payload_json FROM team_sessions WHERE run_id = ? ORDER BY created_at ASC, team_id ASC').all(runId) as Array<{ payload_json: string }>;
|
|
546
|
+
return rows.map((row) => JSON.parse(row.payload_json) as TeamSessionRecord);
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
export async function recordRuntimeStageTeamSession(projectRoot: string, record: StageTeamSessionRecord): Promise<void> {
|
|
551
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
552
|
+
db.prepare('INSERT OR REPLACE INTO stage_team_sessions (session_id, partition, run_id, task_id, stage, lifecycle_profile, status, created_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
553
|
+
.run(record.sessionId, record.partition, record.runId, record.taskId, record.stage, record.lifecycleProfile, record.status, record.createdAt, record.updatedAt, JSON.stringify(record));
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
export async function listRuntimeStageTeamSessions(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null } = {}): Promise<StageTeamSessionRecord[]> {
|
|
558
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
559
|
+
const clauses: string[] = [];
|
|
560
|
+
const params: string[] = [];
|
|
561
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
562
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
563
|
+
const rows = db.prepare(`SELECT payload_json FROM stage_team_sessions${where} ORDER BY updated_at DESC, session_id ASC`).all(...params) as Array<{ payload_json: string }>;
|
|
564
|
+
return rows.map((row) => JSON.parse(row.payload_json) as StageTeamSessionRecord);
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export async function recordRuntimeStageRoleResult(projectRoot: string, record: StageRoleResultRecord): Promise<void> {
|
|
569
|
+
assertValidStageRoleResult(record);
|
|
570
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
571
|
+
db.prepare('INSERT OR REPLACE INTO stage_role_results (result_id, session_id, partition, run_id, task_id, role_id, agent_id, output_kind, authority_ceiling, status, created_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
572
|
+
.run(record.resultId, record.sessionId, record.partition, record.runId, record.taskId, record.roleId, record.agentId, record.outputKind, record.authorityCeiling, record.status, record.createdAt, JSON.stringify(record));
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export async function listRuntimeStageRoleResults(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; sessionId?: string | null } = {}): Promise<StageRoleResultRecord[]> {
|
|
577
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
578
|
+
const clauses: string[] = [];
|
|
579
|
+
const params: string[] = [];
|
|
580
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
581
|
+
if (input.sessionId) {
|
|
582
|
+
clauses.push('session_id = ?');
|
|
583
|
+
params.push(input.sessionId);
|
|
584
|
+
}
|
|
585
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
586
|
+
const rows = db.prepare(`SELECT payload_json FROM stage_role_results${where} ORDER BY created_at ASC, result_id ASC`).all(...params) as Array<{ payload_json: string }>;
|
|
587
|
+
return rows.map((row) => JSON.parse(row.payload_json) as StageRoleResultRecord);
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
export async function recordRuntimeLlmAdvisorAssessment(projectRoot: string, record: LlmAdvisorAssessmentRecord): Promise<void> {
|
|
592
|
+
assertAdvisoryAssessment(record);
|
|
593
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
594
|
+
db.prepare('INSERT OR REPLACE INTO llm_advisor_assessments (assessment_id, session_id, partition, run_id, task_id, kind, concern, advisory_only, created_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
595
|
+
.run(record.assessmentId, record.sessionId, record.partition, record.runId, record.taskId, record.kind, record.concern, record.advisoryOnly ? 1 : 0, record.createdAt, JSON.stringify(record));
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export async function listRuntimeLlmAdvisorAssessments(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; sessionId?: string | null } = {}): Promise<LlmAdvisorAssessmentRecord[]> {
|
|
600
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
601
|
+
const clauses: string[] = [];
|
|
602
|
+
const params: string[] = [];
|
|
603
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
604
|
+
if (input.sessionId) {
|
|
605
|
+
clauses.push('session_id = ?');
|
|
606
|
+
params.push(input.sessionId);
|
|
607
|
+
}
|
|
608
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
609
|
+
const rows = db.prepare(`SELECT payload_json FROM llm_advisor_assessments${where} ORDER BY created_at ASC, assessment_id ASC`).all(...params) as Array<{ payload_json: string }>;
|
|
610
|
+
return rows.map((row) => JSON.parse(row.payload_json) as LlmAdvisorAssessmentRecord);
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export async function recordRuntimeFanInEvidenceSet(projectRoot: string, record: FanInEvidenceSetRecord): Promise<void> {
|
|
615
|
+
assertValidFanInEvidenceSet(record);
|
|
616
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
617
|
+
db.prepare('INSERT OR REPLACE INTO fan_in_evidence_sets (fan_in_id, partition, run_id, task_id, stage, gate_input_only, created_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')
|
|
618
|
+
.run(record.fanInId, record.partition, record.runId, record.taskId, record.stage, record.gateInputOnly ? 1 : 0, record.createdAt, JSON.stringify(record));
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export async function listRuntimeFanInEvidenceSets(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null } = {}): Promise<FanInEvidenceSetRecord[]> {
|
|
623
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
624
|
+
const clauses: string[] = [];
|
|
625
|
+
const params: string[] = [];
|
|
626
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
627
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
628
|
+
const rows = db.prepare(`SELECT payload_json FROM fan_in_evidence_sets${where} ORDER BY created_at ASC, fan_in_id ASC`).all(...params) as Array<{ payload_json: string }>;
|
|
629
|
+
return rows.map((row) => JSON.parse(row.payload_json) as FanInEvidenceSetRecord);
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export async function recordRuntimeWorkflowGateDecision(projectRoot: string, decision: WorkflowGateDecision): Promise<void> {
|
|
634
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
635
|
+
db.prepare('INSERT OR REPLACE INTO workflow_gate_decisions (decision_id, input_hash, partition, run_id, task_id, decision_kind, status, decided_by, generated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
636
|
+
.run(decision.decisionId, decision.inputHash, decision.partition, decision.runId, decision.taskId, decision.decisionKind, decision.status, decision.decidedBy, decision.generatedAt, JSON.stringify(decision));
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
export async function listRuntimeWorkflowGateDecisions(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; decisionKind?: WorkflowGateDecisionKind | null } = {}): Promise<WorkflowGateDecision[]> {
|
|
641
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
642
|
+
const clauses: string[] = [];
|
|
643
|
+
const params: string[] = [];
|
|
644
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
645
|
+
if (input.decisionKind) {
|
|
646
|
+
clauses.push('decision_kind = ?');
|
|
647
|
+
params.push(input.decisionKind);
|
|
648
|
+
}
|
|
649
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
650
|
+
const rows = db.prepare(`SELECT payload_json FROM workflow_gate_decisions${where} ORDER BY generated_at DESC, decision_id ASC`).all(...params) as Array<{ payload_json: string }>;
|
|
651
|
+
return rows.map((row) => JSON.parse(row.payload_json) as WorkflowGateDecision);
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
export async function recordRuntimeWorkerRuntime(projectRoot: string, record: ResidentWorkerRuntimeRecord): Promise<void> {
|
|
657
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
658
|
+
db.prepare('INSERT OR REPLACE INTO worker_runtimes (runtime_id, run_id, task_id, status, claimed_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?)')
|
|
659
|
+
.run(record.runtimeId, record.runId, record.taskId, record.status, record.claimedAt, record.updatedAt, JSON.stringify(record));
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
export async function readRuntimeWorkerRuntime(projectRoot: string, runId: string, runtimeId: string): Promise<ResidentWorkerRuntimeRecord | null> {
|
|
664
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
665
|
+
const row = db.prepare('SELECT payload_json FROM worker_runtimes WHERE run_id = ? AND runtime_id = ?').get(runId, runtimeId) as { payload_json?: string } | undefined;
|
|
666
|
+
return row?.payload_json ? JSON.parse(row.payload_json) as ResidentWorkerRuntimeRecord : null;
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
export async function listRuntimeWorkerRuntimes(projectRoot: string, runId: string): Promise<ResidentWorkerRuntimeRecord[]> {
|
|
671
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
672
|
+
const rows = db.prepare('SELECT payload_json FROM worker_runtimes WHERE run_id = ? ORDER BY updated_at ASC, runtime_id ASC').all(runId) as Array<{ payload_json: string }>;
|
|
673
|
+
return rows.map((row) => JSON.parse(row.payload_json) as ResidentWorkerRuntimeRecord);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
|
|
212
677
|
export async function recordRuntimeActivity(projectRoot: string, entry: InvocationLedgerEntry): Promise<void> {
|
|
213
678
|
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
214
679
|
db.prepare('INSERT OR REPLACE INTO activities (activity_id, run_id, task_id, branch, kind, ref, status, created_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
@@ -232,6 +697,277 @@ export async function recordRuntimeEvidenceAttachment(projectRoot: string, input
|
|
|
232
697
|
});
|
|
233
698
|
}
|
|
234
699
|
|
|
700
|
+
export async function recordRuntimeStageArtifact(projectRoot: string, record: RegisteredStageArtifact): Promise<RegisteredStageArtifact> {
|
|
701
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
702
|
+
db.prepare('INSERT OR REPLACE INTO stage_artifacts (artifact_id, branch_slug, stage, artifact_kind, producer, artifact_ref, content_hash, contract, target_ref, target_hash, review_ref, review_hash, verdict, finding_count, blocking_count, recommendation, frontmatter_json, registered_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
703
|
+
.run(record.artifactId, record.branch, record.stage, record.kind, record.producer, record.ref, record.hash, record.contract, record.targetRef?.ref ?? null, record.targetHash ?? null, record.reviewRef?.ref ?? null, record.reviewHash ?? null, record.verdict ?? null, record.findingCount ?? null, record.blockingCount ?? null, record.recommendation ?? null, JSON.stringify(record.frontmatter), record.registeredAt, JSON.stringify(record));
|
|
704
|
+
});
|
|
705
|
+
return record;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
export async function listRuntimeStageArtifacts(projectRoot: string, filter: RuntimeStageArtifactFilter = {}): Promise<RegisteredStageArtifact[]> {
|
|
709
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
710
|
+
const clauses: string[] = [];
|
|
711
|
+
const params: string[] = [];
|
|
712
|
+
if (filter.branchSlug) {
|
|
713
|
+
clauses.push('branch_slug = ?');
|
|
714
|
+
params.push(filter.branchSlug);
|
|
715
|
+
}
|
|
716
|
+
if (filter.stage) {
|
|
717
|
+
clauses.push('stage = ?');
|
|
718
|
+
params.push(filter.stage);
|
|
719
|
+
}
|
|
720
|
+
if (filter.artifactKind) {
|
|
721
|
+
clauses.push('artifact_kind = ?');
|
|
722
|
+
params.push(filter.artifactKind);
|
|
723
|
+
}
|
|
724
|
+
if (filter.producer) {
|
|
725
|
+
clauses.push('producer = ?');
|
|
726
|
+
params.push(filter.producer);
|
|
727
|
+
}
|
|
728
|
+
if (filter.artifactRef) {
|
|
729
|
+
clauses.push('artifact_ref = ?');
|
|
730
|
+
params.push(filter.artifactRef);
|
|
731
|
+
}
|
|
732
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
733
|
+
const rows = db.prepare(`SELECT * FROM stage_artifacts${where} ORDER BY registered_at DESC, artifact_id ASC`).all(...params) as RuntimeStageArtifactRow[];
|
|
734
|
+
return rows.map(runtimeStageArtifactFromRow);
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
export async function readRuntimeStageArtifact(projectRoot: string, artifactId: string): Promise<RegisteredStageArtifact | null> {
|
|
739
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
740
|
+
const row = db.prepare('SELECT * FROM stage_artifacts WHERE artifact_id = ?').get(artifactId) as RuntimeStageArtifactRow | undefined;
|
|
741
|
+
return row ? runtimeStageArtifactFromRow(row) : null;
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
export async function recordRuntimeStageCollaborationContract(projectRoot: string, record: RegisteredStageCollaborationContract): Promise<RegisteredStageCollaborationContract> {
|
|
746
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
747
|
+
db.prepare('INSERT OR REPLACE INTO stage_collaboration_contracts (contract_id, branch_slug, stage, contract_ref, content_hash, contract_version, producer, work_order_id, status, validation_errors_json, selected_agents_json, selected_skills_json, selected_materials_json, evidence_contracts_json, checkpoint_plan_json, rework_plan_json, permission_projection_json, frontmatter_json, registered_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
748
|
+
.run(record.contractId, record.branch, record.stage, record.ref, record.hash, record.contract, record.producer, record.workOrderId ?? null, record.status, JSON.stringify(record.validationErrors), JSON.stringify(record.selectedAgents), JSON.stringify(record.selectedSkills), JSON.stringify(record.selectedMaterialPacks), JSON.stringify(record.evidenceContracts), JSON.stringify(record.checkpointPlan), JSON.stringify(record.reworkPlan), JSON.stringify(record.permissionProjection), JSON.stringify(record.frontmatter), record.registeredAt, JSON.stringify(record));
|
|
749
|
+
});
|
|
750
|
+
return record;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export async function listRuntimeStageCollaborationContracts(projectRoot: string, filter: RuntimeStageCollaborationContractFilter = {}): Promise<RegisteredStageCollaborationContract[]> {
|
|
754
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
755
|
+
const clauses: string[] = [];
|
|
756
|
+
const params: string[] = [];
|
|
757
|
+
if (filter.branchSlug) {
|
|
758
|
+
clauses.push('branch_slug = ?');
|
|
759
|
+
params.push(filter.branchSlug);
|
|
760
|
+
}
|
|
761
|
+
if (filter.stage) {
|
|
762
|
+
clauses.push('stage = ?');
|
|
763
|
+
params.push(filter.stage);
|
|
764
|
+
}
|
|
765
|
+
if (filter.status) {
|
|
766
|
+
clauses.push('status = ?');
|
|
767
|
+
params.push(filter.status);
|
|
768
|
+
}
|
|
769
|
+
if (filter.contractRef) {
|
|
770
|
+
clauses.push('contract_ref = ?');
|
|
771
|
+
params.push(filter.contractRef);
|
|
772
|
+
}
|
|
773
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
774
|
+
const rows = db.prepare(`SELECT * FROM stage_collaboration_contracts${where} ORDER BY registered_at DESC, contract_id ASC`).all(...params) as RuntimeStageCollaborationContractRow[];
|
|
775
|
+
return rows.map(runtimeStageCollaborationContractFromRow);
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
export async function readRuntimeStageCollaborationContract(projectRoot: string, contractId: string): Promise<RegisteredStageCollaborationContract | null> {
|
|
780
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
781
|
+
const row = db.prepare('SELECT * FROM stage_collaboration_contracts WHERE contract_id = ?').get(contractId) as RuntimeStageCollaborationContractRow | undefined;
|
|
782
|
+
return row ? runtimeStageCollaborationContractFromRow(row) : null;
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export async function recordRuntimeArtifactPayload(projectRoot: string, input: Omit<RuntimeArtifactPayloadRecord, 'sequence' | 'supersedes' | 'createdAt'> & { sequence?: number; supersedes?: string | null; createdAt?: string }): Promise<RuntimeArtifactPayloadRecord> {
|
|
787
|
+
const createdAt = input.createdAt ?? new Date().toISOString();
|
|
788
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
789
|
+
const sequence = input.sequence ?? nextArtifactPayloadSequence(db, input.branchSlug, input.taskId, input.logicalRef);
|
|
790
|
+
const activePayload = input.status === 'active'
|
|
791
|
+
? db.prepare('SELECT payload_id FROM artifact_payloads WHERE branch_slug = ? AND ((task_id IS NULL AND ? IS NULL) OR task_id = ?) AND logical_ref = ? AND status = ? ORDER BY sequence DESC LIMIT 1').get(input.branchSlug, input.taskId, input.taskId, input.logicalRef, 'active') as { payload_id?: string } | undefined
|
|
792
|
+
: undefined;
|
|
793
|
+
const supersedes = input.supersedes ?? activePayload?.payload_id ?? null;
|
|
794
|
+
if (input.status === 'active') {
|
|
795
|
+
db.prepare('UPDATE artifact_payloads SET status = ? WHERE branch_slug = ? AND ((task_id IS NULL AND ? IS NULL) OR task_id = ?) AND logical_ref = ? AND status = ?')
|
|
796
|
+
.run('superseded', input.branchSlug, input.taskId, input.taskId, input.logicalRef, 'active');
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
const record: RuntimeArtifactPayloadRecord = {
|
|
800
|
+
...input,
|
|
801
|
+
sequence,
|
|
802
|
+
supersedes,
|
|
803
|
+
createdAt
|
|
804
|
+
};
|
|
805
|
+
db.prepare('INSERT OR REPLACE INTO artifact_payloads (payload_id, run_id, source_run_id, branch_slug, task_id, logical_ref, physical_payload_path, artifact_role, digest, sequence, status, supersedes, created_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
806
|
+
.run(record.payloadId, record.runId, record.sourceRunId, record.branchSlug, record.taskId, record.logicalRef, record.physicalPayloadPath, record.artifactRole, record.digest, record.sequence, record.status, record.supersedes, record.createdAt, JSON.stringify(record.payload));
|
|
807
|
+
return record;
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
export async function resolveRuntimeArtifactPayload(projectRoot: string, runId: string, logicalRef: string): Promise<RuntimeArtifactPayloadRecord | null> {
|
|
812
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
813
|
+
const row = db.prepare('SELECT * FROM artifact_payloads WHERE run_id = ? AND logical_ref = ? ORDER BY CASE status WHEN \'active\' THEN 0 WHEN \'candidate\' THEN 1 WHEN \'superseded\' THEN 2 ELSE 3 END ASC, sequence DESC').get(runId, logicalRef) as RuntimeArtifactPayloadRow | undefined;
|
|
814
|
+
return row ? runtimeArtifactPayloadFromRow(row) : null;
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
export async function listRuntimeArtifactPayloads(projectRoot: string, input: { runId?: string | null; branchSlug?: string | null; taskId?: string | null; logicalRef?: string | null; status?: RuntimeArtifactPayloadStatus | null } = {}): Promise<RuntimeArtifactPayloadRecord[]> {
|
|
819
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
820
|
+
const clauses: string[] = [];
|
|
821
|
+
const params: string[] = [];
|
|
822
|
+
if (input.runId) {
|
|
823
|
+
clauses.push('run_id = ?');
|
|
824
|
+
params.push(input.runId);
|
|
825
|
+
}
|
|
826
|
+
if (input.branchSlug) {
|
|
827
|
+
clauses.push('branch_slug = ?');
|
|
828
|
+
params.push(input.branchSlug);
|
|
829
|
+
}
|
|
830
|
+
if (input.taskId) {
|
|
831
|
+
clauses.push('task_id = ?');
|
|
832
|
+
params.push(input.taskId);
|
|
833
|
+
}
|
|
834
|
+
if (input.logicalRef) {
|
|
835
|
+
clauses.push('logical_ref = ?');
|
|
836
|
+
params.push(input.logicalRef);
|
|
837
|
+
}
|
|
838
|
+
if (input.status) {
|
|
839
|
+
clauses.push('status = ?');
|
|
840
|
+
params.push(input.status);
|
|
841
|
+
}
|
|
842
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
843
|
+
const rows = db.prepare(`SELECT * FROM artifact_payloads${where} ORDER BY created_at DESC, sequence DESC`).all(...params) as RuntimeArtifactPayloadRow[];
|
|
844
|
+
return rows.map(runtimeArtifactPayloadFromRow);
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
export async function createRuntimeEvidenceSet(projectRoot: string, input: Omit<RuntimeEvidenceSetRecord, 'createdAt'> & { createdAt?: string }): Promise<RuntimeEvidenceSetRecord> {
|
|
849
|
+
const createdAt = input.createdAt ?? new Date().toISOString();
|
|
850
|
+
const record: RuntimeEvidenceSetRecord = { ...input, createdAt };
|
|
851
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
852
|
+
db.prepare('INSERT OR REPLACE INTO evidence_sets (evidence_set_id, branch_slug, scope_kind, scope_id, source_run_id, document_contract_hashes_json, gate_decision_id, status, created_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
853
|
+
.run(record.evidenceSetId, record.branchSlug, record.scopeKind, record.scopeId, record.sourceRunId, JSON.stringify(record.documentContractHashes), record.gateDecisionId, record.status, record.createdAt, JSON.stringify(record.payload));
|
|
854
|
+
for (const item of record.items) {
|
|
855
|
+
db.prepare('INSERT OR REPLACE INTO evidence_set_items (evidence_set_id, payload_id, logical_ref, role, required, digest_at_selection) VALUES (?, ?, ?, ?, ?, ?)')
|
|
856
|
+
.run(record.evidenceSetId, item.payloadId, item.logicalRef, item.role, item.required ? 1 : 0, item.digestAtSelection);
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
return record;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
export async function updateRuntimeSelectionPointer(projectRoot: string, pointer: RuntimeSelectionPointerRecord): Promise<RuntimeSelectionPointerRecord> {
|
|
863
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
864
|
+
const previous = db.prepare('SELECT selected_evidence_set_id FROM selection_pointers WHERE branch_slug = ? AND scope_kind = ? AND scope_id = ?')
|
|
865
|
+
.get(pointer.branchSlug, pointer.scopeKind, pointer.scopeId) as { selected_evidence_set_id?: string } | undefined;
|
|
866
|
+
db.prepare('INSERT OR REPLACE INTO selection_pointers (branch_slug, scope_kind, scope_id, selected_evidence_set_id, selected_at, selected_by_gate_decision_id, reason) VALUES (?, ?, ?, ?, ?, ?, ?)')
|
|
867
|
+
.run(pointer.branchSlug, pointer.scopeKind, pointer.scopeId, pointer.selectedEvidenceSetId, pointer.selectedAt, pointer.selectedByGateDecisionId, pointer.reason);
|
|
868
|
+
if (previous?.selected_evidence_set_id !== pointer.selectedEvidenceSetId) {
|
|
869
|
+
recordSelectionPointerActivity(db, pointer);
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
return pointer;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
export async function resolveRuntimeSelectedEvidence(projectRoot: string, input: { branchSlug: string; scopeKind: RuntimeEvidenceSetScopeKind; scopeId: string; fallbackRunIds?: string[]; fallbackTaskIds?: string[]; fallbackLogicalRefPrefixes?: string[]; allowCandidateFallback?: boolean }): Promise<RuntimeResolvedEvidenceSelection> {
|
|
876
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
877
|
+
const pointerRow = db.prepare('SELECT * FROM selection_pointers WHERE branch_slug = ? AND scope_kind = ? AND scope_id = ?').get(input.branchSlug, input.scopeKind, input.scopeId) as RuntimeSelectionPointerRow | undefined;
|
|
878
|
+
if (pointerRow) {
|
|
879
|
+
const evidenceSet = runtimeEvidenceSetFromDb(db, pointerRow.selected_evidence_set_id);
|
|
880
|
+
if (evidenceSet && evidenceSetMatchesFallbackRuns(evidenceSet, input.fallbackRunIds)) {
|
|
881
|
+
const payloads = payloadsForEvidenceSet(db, evidenceSet);
|
|
882
|
+
if (payloads.length > 0) {
|
|
883
|
+
return { source: 'selection_pointer', evidenceSet, pointer: runtimeSelectionPointerFromRow(pointerRow), payloads };
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
const fallbackPayloads = legacyFallbackPayloads(db, input);
|
|
888
|
+
if (fallbackPayloads.length === 0) {
|
|
889
|
+
return { source: 'none', evidenceSet: null, pointer: null, payloads: [] };
|
|
890
|
+
}
|
|
891
|
+
return input.allowCandidateFallback
|
|
892
|
+
? { source: 'candidate_payloads', evidenceSet: null, pointer: null, payloads: fallbackPayloads }
|
|
893
|
+
: { source: 'legacy_active_payloads', evidenceSet: null, pointer: null, payloads: fallbackPayloads };
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
export async function recordRuntimeDurableGap(projectRoot: string, input: Omit<RuntimeDurableGapRecord, 'createdAt' | 'updatedAt' | 'closedAt'> & { createdAt?: string; updatedAt?: string; closedAt?: string | null }): Promise<RuntimeDurableGapRecord> {
|
|
899
|
+
const createdAt = input.createdAt ?? new Date().toISOString();
|
|
900
|
+
const updatedAt = input.updatedAt ?? createdAt;
|
|
901
|
+
const record: RuntimeDurableGapRecord = {
|
|
902
|
+
...input,
|
|
903
|
+
createdAt,
|
|
904
|
+
updatedAt,
|
|
905
|
+
closedAt: input.closedAt ?? (terminalGapStatus(input.status) ? updatedAt : null)
|
|
906
|
+
};
|
|
907
|
+
assertDurableGapStatusAuthority(record.source, record.status);
|
|
908
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
909
|
+
db.prepare('INSERT OR REPLACE INTO durable_gaps (gap_id, partition, task_id, run_id, stage, gate_name, source, category, severity, status, message, recommendation, evidence_refs_json, proposal_refs_json, source_refs_json, created_at, updated_at, closed_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
910
|
+
.run(record.gapId, record.partition, record.taskId, record.runId, record.stage, record.gate, record.source, record.category, record.severity, record.status, record.message, record.recommendation, JSON.stringify(record.evidenceRefs), JSON.stringify(record.proposalRefs), JSON.stringify(record.sourceRefs), record.createdAt, record.updatedAt, record.closedAt, JSON.stringify(record.payload));
|
|
911
|
+
});
|
|
912
|
+
return record;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
export async function updateRuntimeDurableGapStatus(projectRoot: string, input: { gapId: string; status: RuntimeDurableGapStatus; source: RuntimeDurableGapSource; payload?: unknown; updatedAt?: string }): Promise<RuntimeDurableGapRecord | null> {
|
|
916
|
+
assertDurableGapStatusAuthority(input.source, input.status);
|
|
917
|
+
const updatedAt = input.updatedAt ?? new Date().toISOString();
|
|
918
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
919
|
+
const row = db.prepare('SELECT * FROM durable_gaps WHERE gap_id = ?').get(input.gapId) as RuntimeDurableGapRow | undefined;
|
|
920
|
+
if (!row) {
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
const existing = runtimeDurableGapFromRow(row);
|
|
924
|
+
const payload = input.payload ?? existing.payload;
|
|
925
|
+
const closedAt = terminalGapStatus(input.status) ? updatedAt : null;
|
|
926
|
+
db.prepare('UPDATE durable_gaps SET status = ?, source = ?, updated_at = ?, closed_at = ?, payload_json = ? WHERE gap_id = ?')
|
|
927
|
+
.run(input.status, input.source, updatedAt, closedAt, JSON.stringify(payload), input.gapId);
|
|
928
|
+
return {
|
|
929
|
+
...existing,
|
|
930
|
+
source: input.source,
|
|
931
|
+
status: input.status,
|
|
932
|
+
updatedAt,
|
|
933
|
+
closedAt,
|
|
934
|
+
payload
|
|
935
|
+
};
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
export async function listRuntimeDurableGaps(projectRoot: string, input: { partition?: string | null; taskId?: string | null; runId?: string | null; status?: RuntimeDurableGapStatus | 'open_terminal' | null; severity?: RuntimeDurableGapSeverity | null } = {}): Promise<RuntimeDurableGapRecord[]> {
|
|
940
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
941
|
+
const clauses: string[] = [];
|
|
942
|
+
const params: string[] = [];
|
|
943
|
+
if (input.partition) {
|
|
944
|
+
clauses.push('partition = ?');
|
|
945
|
+
params.push(input.partition);
|
|
946
|
+
}
|
|
947
|
+
if (input.taskId) {
|
|
948
|
+
clauses.push('task_id = ?');
|
|
949
|
+
params.push(input.taskId);
|
|
950
|
+
}
|
|
951
|
+
if (input.runId) {
|
|
952
|
+
clauses.push('run_id = ?');
|
|
953
|
+
params.push(input.runId);
|
|
954
|
+
}
|
|
955
|
+
if (input.status === 'open_terminal') {
|
|
956
|
+
clauses.push("status IN ('open', 'acknowledged')");
|
|
957
|
+
} else if (input.status) {
|
|
958
|
+
clauses.push('status = ?');
|
|
959
|
+
params.push(input.status);
|
|
960
|
+
}
|
|
961
|
+
if (input.severity) {
|
|
962
|
+
clauses.push('severity = ?');
|
|
963
|
+
params.push(input.severity);
|
|
964
|
+
}
|
|
965
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
966
|
+
const rows = db.prepare(`SELECT * FROM durable_gaps${where} ORDER BY updated_at DESC, gap_id ASC`).all(...params) as RuntimeDurableGapRow[];
|
|
967
|
+
return rows.map(runtimeDurableGapFromRow);
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
|
|
235
971
|
export async function recordRuntimeProjection(projectRoot: string, projectionType: string, scopeKey: string, payload: unknown): Promise<void> {
|
|
236
972
|
const now = new Date().toISOString();
|
|
237
973
|
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
@@ -351,13 +1087,13 @@ export interface RuntimeTestStepRecord {
|
|
|
351
1087
|
status: string;
|
|
352
1088
|
exitCode: number | null;
|
|
353
1089
|
durationMs: number;
|
|
354
|
-
outputArtifact: string;
|
|
1090
|
+
outputArtifact: string | null;
|
|
355
1091
|
payload: unknown;
|
|
356
1092
|
}
|
|
357
1093
|
|
|
358
1094
|
export async function recordRuntimeTestRun(projectRoot: string, record: RuntimeTestRunRecord): Promise<void> {
|
|
359
1095
|
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
360
|
-
db.prepare('INSERT
|
|
1096
|
+
db.prepare('INSERT INTO test_runs (test_run_id, run_id, partition, task_id, status, started_at, completed_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(test_run_id) DO UPDATE SET run_id = excluded.run_id, partition = excluded.partition, task_id = excluded.task_id, status = excluded.status, started_at = excluded.started_at, completed_at = excluded.completed_at, payload_json = excluded.payload_json')
|
|
361
1097
|
.run(record.testRunId, record.runId, record.partition, record.taskId, record.status, record.startedAt, record.completedAt, JSON.stringify(record.payload));
|
|
362
1098
|
});
|
|
363
1099
|
}
|
|
@@ -369,6 +1105,24 @@ export async function recordRuntimeTestStep(projectRoot: string, record: Runtime
|
|
|
369
1105
|
});
|
|
370
1106
|
}
|
|
371
1107
|
|
|
1108
|
+
export async function listRuntimeTestSteps(projectRoot: string, input: { runId?: string | null; testRunId?: string | null } = {}): Promise<RuntimeTestStepRecord[]> {
|
|
1109
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
1110
|
+
const clauses: string[] = [];
|
|
1111
|
+
const params: string[] = [];
|
|
1112
|
+
if (input.runId) {
|
|
1113
|
+
clauses.push('run_id = ?');
|
|
1114
|
+
params.push(input.runId);
|
|
1115
|
+
}
|
|
1116
|
+
if (input.testRunId) {
|
|
1117
|
+
clauses.push('test_run_id = ?');
|
|
1118
|
+
params.push(input.testRunId);
|
|
1119
|
+
}
|
|
1120
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
1121
|
+
const rows = db.prepare(`SELECT test_step_id, test_run_id, run_id, task_id, command, status, exit_code, duration_ms, output_artifact, payload_json FROM test_steps${where} ORDER BY test_step_id ASC`).all(...params) as RuntimeTestStepRow[];
|
|
1122
|
+
return rows.map(runtimeTestStepFromRow);
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
|
|
372
1126
|
export async function listRuntimeTestRuns(projectRoot: string, runId?: string | null): Promise<RuntimeTestRunRecord[]> {
|
|
373
1127
|
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
374
1128
|
const rows = runId
|
|
@@ -387,6 +1141,371 @@ export async function listRuntimeTestRuns(projectRoot: string, runId?: string |
|
|
|
387
1141
|
});
|
|
388
1142
|
}
|
|
389
1143
|
|
|
1144
|
+
export async function recordRuntimeValidationCacheEntry(projectRoot: string, record: RuntimeValidationCacheEntryRecord): Promise<void> {
|
|
1145
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
1146
|
+
db.prepare('INSERT INTO validation_cache_entries (cache_key, branch_slug, command, status, source_test_run_id, source_run_id, source_evidence_set_id, output_artifact, stdout_digest, stderr_digest, created_at, last_used_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(cache_key) DO UPDATE SET branch_slug = excluded.branch_slug, command = excluded.command, status = excluded.status, source_test_run_id = excluded.source_test_run_id, source_run_id = excluded.source_run_id, source_evidence_set_id = excluded.source_evidence_set_id, output_artifact = excluded.output_artifact, stdout_digest = excluded.stdout_digest, stderr_digest = excluded.stderr_digest, last_used_at = excluded.last_used_at, payload_json = excluded.payload_json')
|
|
1147
|
+
.run(record.cacheKey, record.branchSlug, record.command, record.status, record.sourceTestRunId, record.sourceRunId, record.sourceEvidenceSetId, record.outputArtifact, record.stdoutDigest, record.stderrDigest, record.createdAt, record.lastUsedAt, JSON.stringify(record.payload));
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
export async function readRuntimeValidationCacheEntry(projectRoot: string, input: { branchSlug: string; cacheKey: string }): Promise<RuntimeValidationCacheEntryRecord | null> {
|
|
1152
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
1153
|
+
const row = db.prepare('SELECT cache_key, branch_slug, command, status, source_test_run_id, source_run_id, source_evidence_set_id, output_artifact, stdout_digest, stderr_digest, created_at, last_used_at, payload_json FROM validation_cache_entries WHERE branch_slug = ? AND cache_key = ? AND status = ?').get(input.branchSlug, input.cacheKey, 'valid') as RuntimeValidationCacheEntryRow | undefined;
|
|
1154
|
+
return row ? runtimeValidationCacheEntryFromRow(row) : null;
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
export async function listRuntimeValidationCacheEntries(projectRoot: string, input: { branchSlug?: string | null; status?: RuntimeValidationCacheEntryStatus | null } = {}): Promise<RuntimeValidationCacheEntryRecord[]> {
|
|
1159
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
1160
|
+
const clauses: string[] = [];
|
|
1161
|
+
const params: string[] = [];
|
|
1162
|
+
if (input.branchSlug) {
|
|
1163
|
+
clauses.push('branch_slug = ?');
|
|
1164
|
+
params.push(input.branchSlug);
|
|
1165
|
+
}
|
|
1166
|
+
if (input.status) {
|
|
1167
|
+
clauses.push('status = ?');
|
|
1168
|
+
params.push(input.status);
|
|
1169
|
+
}
|
|
1170
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
1171
|
+
const rows = db.prepare(`SELECT cache_key, branch_slug, command, status, source_test_run_id, source_run_id, source_evidence_set_id, output_artifact, stdout_digest, stderr_digest, created_at, last_used_at, payload_json FROM validation_cache_entries${where} ORDER BY last_used_at DESC, cache_key ASC`).all(...params) as RuntimeValidationCacheEntryRow[];
|
|
1172
|
+
return rows.map(runtimeValidationCacheEntryFromRow);
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
export async function recordRuntimeValidationCacheUse(projectRoot: string, record: RuntimeValidationCacheUseRecord): Promise<void> {
|
|
1177
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
1178
|
+
db.prepare('INSERT OR REPLACE INTO validation_cache_uses (use_id, cache_key, branch_slug, test_run_id, run_id, task_id, source_test_run_id, source_evidence_set_id, reused_at, mapped_task_ids_json, reason, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
1179
|
+
.run(record.useId, record.cacheKey, record.branchSlug, record.testRunId, record.runId, record.taskId, record.sourceTestRunId, record.sourceEvidenceSetId, record.reusedAt, JSON.stringify(record.mappedTaskIds), record.reason, JSON.stringify(record.payload));
|
|
1180
|
+
db.prepare('UPDATE validation_cache_entries SET last_used_at = ? WHERE cache_key = ?')
|
|
1181
|
+
.run(record.reusedAt, record.cacheKey);
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
export async function listRuntimeValidationCacheUses(projectRoot: string, input: { branchSlug?: string | null; runId?: string | null; taskId?: string | null } = {}): Promise<RuntimeValidationCacheUseRecord[]> {
|
|
1186
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
1187
|
+
const clauses: string[] = [];
|
|
1188
|
+
const params: string[] = [];
|
|
1189
|
+
if (input.branchSlug) {
|
|
1190
|
+
clauses.push('branch_slug = ?');
|
|
1191
|
+
params.push(input.branchSlug);
|
|
1192
|
+
}
|
|
1193
|
+
if (input.runId) {
|
|
1194
|
+
clauses.push('run_id = ?');
|
|
1195
|
+
params.push(input.runId);
|
|
1196
|
+
}
|
|
1197
|
+
if (input.taskId) {
|
|
1198
|
+
clauses.push('task_id = ?');
|
|
1199
|
+
params.push(input.taskId);
|
|
1200
|
+
}
|
|
1201
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
1202
|
+
const rows = db.prepare(`SELECT use_id, cache_key, branch_slug, test_run_id, run_id, task_id, source_test_run_id, source_evidence_set_id, reused_at, mapped_task_ids_json, reason, payload_json FROM validation_cache_uses${where} ORDER BY reused_at DESC, use_id ASC`).all(...params) as RuntimeValidationCacheUseRow[];
|
|
1203
|
+
return rows.map(runtimeValidationCacheUseFromRow);
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
export async function recordRuntimeRepair(projectRoot: string, record: RuntimeRepairRecord): Promise<void> {
|
|
1208
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
1209
|
+
db.prepare('INSERT INTO repair_records (repair_id, branch_slug, task_id, repair_type, repair_of_run_id, repair_of_gate_decision_id, status, affected_tasks_json, blockers_json, recommended_commands_json, required_evidence_json, created_at, resolved_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(repair_id) DO UPDATE SET status = excluded.status, blockers_json = excluded.blockers_json, recommended_commands_json = excluded.recommended_commands_json, required_evidence_json = excluded.required_evidence_json, resolved_at = excluded.resolved_at, payload_json = excluded.payload_json')
|
|
1210
|
+
.run(record.repairId, record.branchSlug, record.taskId, record.repairType, record.repairOfRunId, record.repairOfGateDecisionId, record.status, JSON.stringify(record.affectedTasks), JSON.stringify(record.blockers), JSON.stringify(record.recommendedCommands), JSON.stringify(record.requiredEvidence), record.createdAt, record.resolvedAt, JSON.stringify(record.payload));
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
export async function listRuntimeRepairs(projectRoot: string, input: { branchSlug?: string | null; taskId?: string | null; status?: RuntimeRepairStatus | null } = {}): Promise<RuntimeRepairRecord[]> {
|
|
1215
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
1216
|
+
const clauses: string[] = [];
|
|
1217
|
+
const params: string[] = [];
|
|
1218
|
+
if (input.branchSlug) {
|
|
1219
|
+
clauses.push('branch_slug = ?');
|
|
1220
|
+
params.push(input.branchSlug);
|
|
1221
|
+
}
|
|
1222
|
+
if (input.taskId) {
|
|
1223
|
+
clauses.push('task_id = ?');
|
|
1224
|
+
params.push(input.taskId);
|
|
1225
|
+
}
|
|
1226
|
+
if (input.status) {
|
|
1227
|
+
clauses.push('status = ?');
|
|
1228
|
+
params.push(input.status);
|
|
1229
|
+
}
|
|
1230
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
1231
|
+
const rows = db.prepare(`SELECT repair_id, branch_slug, task_id, repair_type, repair_of_run_id, repair_of_gate_decision_id, status, affected_tasks_json, blockers_json, recommended_commands_json, required_evidence_json, created_at, resolved_at, payload_json FROM repair_records${where} ORDER BY created_at DESC, repair_id ASC`).all(...params) as RuntimeRepairRow[];
|
|
1232
|
+
return rows.map(runtimeRepairFromRow);
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
export async function recordRuntimeCapabilityAdoption(projectRoot: string, record: RuntimeCapabilityAdoptionRecord): Promise<void> {
|
|
1237
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
1238
|
+
db.prepare('INSERT INTO capability_adoptions (adoption_id, branch_slug, lifecycle_stage, capability_domain, source_id, status, reason, evidence_refs_json, final_authority, created_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(branch_slug, lifecycle_stage, capability_domain, source_id) DO UPDATE SET adoption_id = excluded.adoption_id, status = excluded.status, reason = excluded.reason, evidence_refs_json = excluded.evidence_refs_json, final_authority = excluded.final_authority, updated_at = excluded.updated_at, payload_json = excluded.payload_json')
|
|
1239
|
+
.run(record.adoptionId, record.branchSlug, record.lifecycleStage, record.capabilityDomain, record.sourceId, record.status, record.reason, JSON.stringify(record.evidenceRefs), record.finalAuthority, record.createdAt, record.updatedAt, JSON.stringify(record.payload));
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
export async function listRuntimeCapabilityAdoptions(projectRoot: string, input: { branchSlug?: string | null; lifecycleStage?: RuntimeCapabilityAdoptionStage | null; capabilityDomain?: string | null; status?: RuntimeCapabilityAdoptionStatus | null } = {}): Promise<RuntimeCapabilityAdoptionRecord[]> {
|
|
1244
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
1245
|
+
const clauses: string[] = [];
|
|
1246
|
+
const params: string[] = [];
|
|
1247
|
+
if (input.branchSlug) {
|
|
1248
|
+
clauses.push('branch_slug = ?');
|
|
1249
|
+
params.push(input.branchSlug);
|
|
1250
|
+
}
|
|
1251
|
+
if (input.lifecycleStage) {
|
|
1252
|
+
clauses.push('lifecycle_stage = ?');
|
|
1253
|
+
params.push(input.lifecycleStage);
|
|
1254
|
+
}
|
|
1255
|
+
if (input.capabilityDomain) {
|
|
1256
|
+
clauses.push('capability_domain = ?');
|
|
1257
|
+
params.push(input.capabilityDomain);
|
|
1258
|
+
}
|
|
1259
|
+
if (input.status) {
|
|
1260
|
+
clauses.push('status = ?');
|
|
1261
|
+
params.push(input.status);
|
|
1262
|
+
}
|
|
1263
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
1264
|
+
const rows = db.prepare(`SELECT adoption_id, branch_slug, lifecycle_stage, capability_domain, source_id, status, reason, evidence_refs_json, final_authority, created_at, updated_at, payload_json FROM capability_adoptions${where} ORDER BY updated_at DESC, adoption_id ASC`).all(...params) as RuntimeCapabilityAdoptionRow[];
|
|
1265
|
+
return rows.map(runtimeCapabilityAdoptionFromRow);
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
export async function recordRuntimeValidationEnvironmentSession(projectRoot: string, record: RuntimeValidationEnvironmentSessionRecord): Promise<void> {
|
|
1270
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
1271
|
+
db.prepare('INSERT OR REPLACE INTO validation_environment_sessions (session_id, partition, run_id, wave_run_id, status, reuse_key, created_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
1272
|
+
.run(record.sessionId, record.partition, record.runId, record.waveRunId, record.status, record.reuseKey, record.createdAt, record.updatedAt, JSON.stringify(record.payload));
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
export async function listRuntimeValidationEnvironmentSessions(projectRoot: string, input: { partition?: string | null; runId?: string | null; waveRunId?: string | null } = {}): Promise<RuntimeValidationEnvironmentSessionRecord[]> {
|
|
1277
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
1278
|
+
const clauses: string[] = [];
|
|
1279
|
+
const params: string[] = [];
|
|
1280
|
+
if (input.partition) {
|
|
1281
|
+
clauses.push('partition = ?');
|
|
1282
|
+
params.push(input.partition);
|
|
1283
|
+
}
|
|
1284
|
+
if (input.runId) {
|
|
1285
|
+
clauses.push('run_id = ?');
|
|
1286
|
+
params.push(input.runId);
|
|
1287
|
+
}
|
|
1288
|
+
if (input.waveRunId) {
|
|
1289
|
+
clauses.push('wave_run_id = ?');
|
|
1290
|
+
params.push(input.waveRunId);
|
|
1291
|
+
}
|
|
1292
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
1293
|
+
const rows = db.prepare(`SELECT session_id, partition, run_id, wave_run_id, status, reuse_key, created_at, updated_at, payload_json FROM validation_environment_sessions${where} ORDER BY updated_at DESC, session_id ASC`).all(...params) as Array<{ session_id: string; partition: string; run_id: string | null; wave_run_id: string | null; status: RuntimeValidationEnvironmentStatus; reuse_key: string; created_at: string; updated_at: string; payload_json: string }>;
|
|
1294
|
+
return rows.map((row) => ({ sessionId: row.session_id, partition: row.partition, runId: row.run_id, waveRunId: row.wave_run_id, status: row.status, reuseKey: row.reuse_key, createdAt: row.created_at, updatedAt: row.updated_at, payload: JSON.parse(row.payload_json) }));
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
export async function recordRuntimeValidationWaveRun(projectRoot: string, record: RuntimeValidationWaveRunRecord): Promise<void> {
|
|
1299
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
1300
|
+
db.prepare('INSERT OR REPLACE INTO validation_wave_runs (wave_run_id, partition, run_id, task_ids_json, status, environment_session_id, started_at, completed_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
1301
|
+
.run(record.waveRunId, record.partition, record.runId, JSON.stringify(record.taskIds), record.status, record.environmentSessionId, record.startedAt, record.completedAt, JSON.stringify(record.payload));
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
export async function listRuntimeValidationWaveRuns(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; waveRunId?: string | null } = {}): Promise<RuntimeValidationWaveRunRecord[]> {
|
|
1306
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
1307
|
+
const clauses: string[] = [];
|
|
1308
|
+
const params: string[] = [];
|
|
1309
|
+
if (input.partition) {
|
|
1310
|
+
clauses.push('partition = ?');
|
|
1311
|
+
params.push(input.partition);
|
|
1312
|
+
}
|
|
1313
|
+
if (input.runId) {
|
|
1314
|
+
clauses.push('run_id = ?');
|
|
1315
|
+
params.push(input.runId);
|
|
1316
|
+
}
|
|
1317
|
+
if (input.waveRunId) {
|
|
1318
|
+
clauses.push('wave_run_id = ?');
|
|
1319
|
+
params.push(input.waveRunId);
|
|
1320
|
+
}
|
|
1321
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
1322
|
+
const rows = db.prepare(`SELECT wave_run_id, partition, run_id, task_ids_json, status, environment_session_id, started_at, completed_at, payload_json FROM validation_wave_runs${where} ORDER BY completed_at DESC, wave_run_id ASC`).all(...params) as Array<{ wave_run_id: string; partition: string; run_id: string | null; task_ids_json: string; status: RuntimeValidationWaveStatus; environment_session_id: string; started_at: string; completed_at: string; payload_json: string }>;
|
|
1323
|
+
return rows
|
|
1324
|
+
.map((row) => ({ waveRunId: row.wave_run_id, partition: row.partition, runId: row.run_id, taskIds: JSON.parse(row.task_ids_json) as string[], status: row.status, environmentSessionId: row.environment_session_id, startedAt: row.started_at, completedAt: row.completed_at, payload: JSON.parse(row.payload_json) }))
|
|
1325
|
+
.filter((record) => !input.taskId || record.taskIds.includes(input.taskId));
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
export async function recordRuntimeAcceptanceEvidenceMap(projectRoot: string, record: RuntimeAcceptanceEvidenceMapRecord): Promise<void> {
|
|
1330
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
1331
|
+
db.prepare('INSERT OR REPLACE INTO acceptance_evidence_maps (map_id, wave_run_id, test_run_id, partition, run_id, task_id, acceptance_ref, status, evidence_refs_json, gaps_json, created_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
1332
|
+
.run(record.mapId, record.waveRunId, record.testRunId, record.partition, record.runId, record.taskId, record.acceptanceRef, record.status, JSON.stringify(record.evidenceRefs), JSON.stringify(record.gaps), record.createdAt, JSON.stringify(record.payload));
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
export async function listRuntimeAcceptanceEvidenceMaps(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; waveRunId?: string | null; testRunId?: string | null } = {}): Promise<RuntimeAcceptanceEvidenceMapRecord[]> {
|
|
1337
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
1338
|
+
const clauses: string[] = [];
|
|
1339
|
+
const params: string[] = [];
|
|
1340
|
+
if (input.partition) {
|
|
1341
|
+
clauses.push('partition = ?');
|
|
1342
|
+
params.push(input.partition);
|
|
1343
|
+
}
|
|
1344
|
+
if (input.runId) {
|
|
1345
|
+
clauses.push('run_id = ?');
|
|
1346
|
+
params.push(input.runId);
|
|
1347
|
+
}
|
|
1348
|
+
if (input.taskId) {
|
|
1349
|
+
clauses.push('task_id = ?');
|
|
1350
|
+
params.push(input.taskId);
|
|
1351
|
+
}
|
|
1352
|
+
if (input.waveRunId) {
|
|
1353
|
+
clauses.push('wave_run_id = ?');
|
|
1354
|
+
params.push(input.waveRunId);
|
|
1355
|
+
}
|
|
1356
|
+
if (input.testRunId) {
|
|
1357
|
+
clauses.push('test_run_id = ?');
|
|
1358
|
+
params.push(input.testRunId);
|
|
1359
|
+
}
|
|
1360
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
1361
|
+
const rows = db.prepare(`SELECT map_id, wave_run_id, test_run_id, partition, run_id, task_id, acceptance_ref, status, evidence_refs_json, gaps_json, created_at, payload_json FROM acceptance_evidence_maps${where} ORDER BY created_at DESC, map_id ASC`).all(...params) as Array<{ map_id: string; wave_run_id: string; test_run_id: string; partition: string; run_id: string; task_id: string; acceptance_ref: string; status: string; evidence_refs_json: string; gaps_json: string; created_at: string; payload_json: string }>;
|
|
1362
|
+
return rows.map((row) => ({ mapId: row.map_id, waveRunId: row.wave_run_id, testRunId: row.test_run_id, partition: row.partition, runId: row.run_id, taskId: row.task_id, acceptanceRef: row.acceptance_ref, status: row.status, evidenceRefs: JSON.parse(row.evidence_refs_json) as string[], gaps: JSON.parse(row.gaps_json) as string[], createdAt: row.created_at, payload: JSON.parse(row.payload_json) }));
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
interface RuntimeEvidenceSetRow {
|
|
1367
|
+
evidence_set_id: string;
|
|
1368
|
+
branch_slug: string;
|
|
1369
|
+
scope_kind: RuntimeEvidenceSetScopeKind;
|
|
1370
|
+
scope_id: string;
|
|
1371
|
+
source_run_id: string | null;
|
|
1372
|
+
document_contract_hashes_json: string;
|
|
1373
|
+
gate_decision_id: string | null;
|
|
1374
|
+
status: RuntimeEvidenceSetStatus;
|
|
1375
|
+
created_at: string;
|
|
1376
|
+
payload_json: string;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
interface RuntimeEvidenceSetItemRow {
|
|
1380
|
+
evidence_set_id: string;
|
|
1381
|
+
payload_id: string;
|
|
1382
|
+
logical_ref: string;
|
|
1383
|
+
role: string;
|
|
1384
|
+
required: number;
|
|
1385
|
+
digest_at_selection: string;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
interface RuntimeSelectionPointerRow {
|
|
1389
|
+
branch_slug: string;
|
|
1390
|
+
scope_kind: RuntimeEvidenceSetScopeKind;
|
|
1391
|
+
scope_id: string;
|
|
1392
|
+
selected_evidence_set_id: string;
|
|
1393
|
+
selected_at: string;
|
|
1394
|
+
selected_by_gate_decision_id: string | null;
|
|
1395
|
+
reason: string;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
function runtimeEvidenceSetFromDb(db: RuntimeStoreDatabase, evidenceSetId: string): RuntimeEvidenceSetRecord | null {
|
|
1399
|
+
const row = db.prepare('SELECT * FROM evidence_sets WHERE evidence_set_id = ?').get(evidenceSetId) as RuntimeEvidenceSetRow | undefined;
|
|
1400
|
+
if (!row) {
|
|
1401
|
+
return null;
|
|
1402
|
+
}
|
|
1403
|
+
const items = db.prepare('SELECT * FROM evidence_set_items WHERE evidence_set_id = ? ORDER BY logical_ref ASC, payload_id ASC').all(evidenceSetId) as RuntimeEvidenceSetItemRow[];
|
|
1404
|
+
return {
|
|
1405
|
+
evidenceSetId: row.evidence_set_id,
|
|
1406
|
+
branchSlug: row.branch_slug,
|
|
1407
|
+
scopeKind: row.scope_kind,
|
|
1408
|
+
scopeId: row.scope_id,
|
|
1409
|
+
sourceRunId: row.source_run_id,
|
|
1410
|
+
documentContractHashes: JSON.parse(row.document_contract_hashes_json) as Record<string, string | null>,
|
|
1411
|
+
gateDecisionId: row.gate_decision_id,
|
|
1412
|
+
status: row.status,
|
|
1413
|
+
createdAt: row.created_at,
|
|
1414
|
+
items: items.map((item) => ({
|
|
1415
|
+
evidenceSetId: item.evidence_set_id,
|
|
1416
|
+
payloadId: item.payload_id,
|
|
1417
|
+
logicalRef: item.logical_ref,
|
|
1418
|
+
role: item.role,
|
|
1419
|
+
required: item.required === 1,
|
|
1420
|
+
digestAtSelection: item.digest_at_selection
|
|
1421
|
+
})),
|
|
1422
|
+
payload: JSON.parse(row.payload_json)
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
function payloadsForEvidenceSet(db: RuntimeStoreDatabase, evidenceSet: RuntimeEvidenceSetRecord): RuntimeArtifactPayloadRecord[] {
|
|
1427
|
+
const payloadIds = evidenceSet.items.map((item) => item.payloadId);
|
|
1428
|
+
if (payloadIds.length === 0) {
|
|
1429
|
+
return [];
|
|
1430
|
+
}
|
|
1431
|
+
const rows = db.prepare(`SELECT * FROM artifact_payloads WHERE payload_id IN (${payloadIds.map(() => '?').join(',')})`).all(...payloadIds) as RuntimeArtifactPayloadRow[];
|
|
1432
|
+
const byId = new Map(rows.map((row) => [row.payload_id, runtimeArtifactPayloadFromRow(row)]));
|
|
1433
|
+
return payloadIds.flatMap((payloadId) => byId.get(payloadId) ? [byId.get(payloadId)!] : []);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
function runtimeSelectionPointerFromRow(row: RuntimeSelectionPointerRow): RuntimeSelectionPointerRecord {
|
|
1437
|
+
return {
|
|
1438
|
+
branchSlug: row.branch_slug,
|
|
1439
|
+
scopeKind: row.scope_kind,
|
|
1440
|
+
scopeId: row.scope_id,
|
|
1441
|
+
selectedEvidenceSetId: row.selected_evidence_set_id,
|
|
1442
|
+
selectedAt: row.selected_at,
|
|
1443
|
+
selectedByGateDecisionId: row.selected_by_gate_decision_id,
|
|
1444
|
+
reason: row.reason
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
function recordSelectionPointerActivity(db: RuntimeStoreDatabase, pointer: RuntimeSelectionPointerRecord): void {
|
|
1449
|
+
const evidenceSet = db.prepare('SELECT source_run_id FROM evidence_sets WHERE evidence_set_id = ?').get(pointer.selectedEvidenceSetId) as { source_run_id?: string | null } | undefined;
|
|
1450
|
+
if (!evidenceSet?.source_run_id) {
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
const entry: InvocationLedgerEntry = {
|
|
1454
|
+
contract: 'sdd-invocation-ledger-v1',
|
|
1455
|
+
version: INVOCATION_LEDGER_CONTRACT_VERSION,
|
|
1456
|
+
entryId: runtimeScopedId('selection-pointer', pointer.branchSlug, pointer.scopeKind, pointer.scopeId, pointer.selectedEvidenceSetId, pointer.selectedAt),
|
|
1457
|
+
runId: evidenceSet.source_run_id,
|
|
1458
|
+
taskId: pointer.scopeKind === 'task' ? pointer.scopeId : null,
|
|
1459
|
+
branch: pointer.branchSlug,
|
|
1460
|
+
kind: 'policy_evaluation',
|
|
1461
|
+
ref: `selection:${pointer.scopeKind}:${pointer.scopeId}`,
|
|
1462
|
+
status: 'selected',
|
|
1463
|
+
timestamp: pointer.selectedAt,
|
|
1464
|
+
inputHash: pointer.selectedByGateDecisionId,
|
|
1465
|
+
outputHash: pointer.selectedEvidenceSetId,
|
|
1466
|
+
materialRefs: [pointer.selectedEvidenceSetId],
|
|
1467
|
+
metadata: {
|
|
1468
|
+
scopeKind: pointer.scopeKind,
|
|
1469
|
+
scopeId: pointer.scopeId,
|
|
1470
|
+
selectedEvidenceSetId: pointer.selectedEvidenceSetId
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
db.prepare('INSERT OR REPLACE INTO activities (activity_id, run_id, task_id, branch, kind, ref, status, created_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
1474
|
+
.run(entry.entryId, entry.runId, entry.taskId, entry.branch, entry.kind, entry.ref, entry.status, entry.timestamp, JSON.stringify(entry));
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
function evidenceSetMatchesFallbackRuns(evidenceSet: RuntimeEvidenceSetRecord, fallbackRunIds?: string[]): boolean {
|
|
1478
|
+
if (!fallbackRunIds || fallbackRunIds.length === 0) {
|
|
1479
|
+
return true;
|
|
1480
|
+
}
|
|
1481
|
+
return Boolean(evidenceSet.sourceRunId && fallbackRunIds.includes(evidenceSet.sourceRunId));
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
function legacyFallbackPayloads(db: RuntimeStoreDatabase, input: { branchSlug: string; fallbackRunIds?: string[]; fallbackTaskIds?: string[]; fallbackLogicalRefPrefixes?: string[] }): RuntimeArtifactPayloadRecord[] {
|
|
1485
|
+
const clauses = ['status = ?', 'branch_slug = ?'];
|
|
1486
|
+
const params: string[] = ['active', input.branchSlug];
|
|
1487
|
+
const scopeClauses: string[] = [];
|
|
1488
|
+
const scopeParams: string[] = [];
|
|
1489
|
+
if (input.fallbackRunIds && input.fallbackRunIds.length > 0) {
|
|
1490
|
+
scopeClauses.push(`run_id IN (${input.fallbackRunIds.map(() => '?').join(',')})`);
|
|
1491
|
+
scopeParams.push(...input.fallbackRunIds);
|
|
1492
|
+
}
|
|
1493
|
+
if (input.fallbackTaskIds && input.fallbackTaskIds.length > 0) {
|
|
1494
|
+
scopeClauses.push(`task_id IN (${input.fallbackTaskIds.map(() => '?').join(',')})`);
|
|
1495
|
+
scopeParams.push(...input.fallbackTaskIds);
|
|
1496
|
+
}
|
|
1497
|
+
if (input.fallbackLogicalRefPrefixes && input.fallbackLogicalRefPrefixes.length > 0) {
|
|
1498
|
+
scopeClauses.push(`(task_id IS NULL AND (${input.fallbackLogicalRefPrefixes.map(() => 'logical_ref LIKE ?').join(' OR ')}))`);
|
|
1499
|
+
scopeParams.push(...input.fallbackLogicalRefPrefixes.map((prefix) => `${prefix}%`));
|
|
1500
|
+
}
|
|
1501
|
+
if (scopeClauses.length > 0) {
|
|
1502
|
+
clauses.push(`(${scopeClauses.join(' OR ')})`);
|
|
1503
|
+
params.push(...scopeParams);
|
|
1504
|
+
}
|
|
1505
|
+
const rows = db.prepare(`SELECT * FROM artifact_payloads WHERE ${clauses.join(' AND ')} ORDER BY created_at DESC, sequence DESC`).all(...params) as RuntimeArtifactPayloadRow[];
|
|
1506
|
+
return rows.map(runtimeArtifactPayloadFromRow);
|
|
1507
|
+
}
|
|
1508
|
+
|
|
390
1509
|
export async function recordLegacyImportFailure(projectRoot: string, runId: string, entityType: string, error: unknown): Promise<void> {
|
|
391
1510
|
try {
|
|
392
1511
|
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
@@ -405,10 +1524,10 @@ export async function inspectRuntimeStoreEvidence(projectRoot: string): Promise<
|
|
|
405
1524
|
const integrityRow = db.prepare('PRAGMA integrity_check').get() as { integrity_check?: string } | undefined;
|
|
406
1525
|
const schemaVersion = versionRow?.user_version ?? 0;
|
|
407
1526
|
if (schemaVersion !== RUNTIME_STORE_SCHEMA_VERSION) {
|
|
408
|
-
return [{ level: 'FAIL', check: 'runtime_store', message: `Runtime store schema version ${schemaVersion} does not match expected ${RUNTIME_STORE_SCHEMA_VERSION}.`, action: 'Run a compatible sdd version or rebuild
|
|
1527
|
+
return [{ level: 'FAIL', check: 'runtime_store', message: `Runtime store schema version ${schemaVersion} does not match expected ${RUNTIME_STORE_SCHEMA_VERSION}.`, action: 'Run a compatible sdd version or rebuild runtime.sqlite projections from canonical docs and accepted stage evidence refs.' }];
|
|
409
1528
|
}
|
|
410
1529
|
if (integrityRow?.integrity_check !== 'ok') {
|
|
411
|
-
return [{ level: 'FAIL', check: 'runtime_store', message: `Runtime store integrity check failed: ${integrityRow?.integrity_check ?? 'unknown'}.`, action: '
|
|
1530
|
+
return [{ level: 'FAIL', check: 'runtime_store', message: `Runtime store integrity check failed: ${integrityRow?.integrity_check ?? 'unknown'}.`, action: 'Preserve runtime.sqlite for debugging, then rebuild projections from canonical docs and accepted stage evidence refs.' }];
|
|
412
1531
|
}
|
|
413
1532
|
const checks: RuntimeStoreDoctorCheck[] = [{ level: 'PASS', check: 'runtime_store', message: `${RUNTIME_STORE_CONTRACT_VERSION} is available at ${storePath} with schema ${schemaVersion}.` }];
|
|
414
1533
|
const scopeLeak = db.prepare('SELECT COUNT(*) AS count FROM evidence_claims c JOIN runs r ON r.run_id = c.run_id WHERE c.partition IS NOT NULL AND r.partition IS NOT NULL AND c.partition <> r.partition').get() as { count?: number } | undefined;
|
|
@@ -423,7 +1542,7 @@ export async function inspectRuntimeStoreEvidence(projectRoot: string): Promise<
|
|
|
423
1542
|
const failedLegacy = legacy.find((row) => row.status === 'failed')?.count ?? 0;
|
|
424
1543
|
const importedLegacy = legacy.find((row) => row.status === 'imported')?.count ?? 0;
|
|
425
1544
|
checks.push(failedLegacy > 0
|
|
426
|
-
? { level: 'FAIL', check: 'runtime_legacy_import', message: `${failedLegacy} legacy import record(s) failed.`, action: 'Inspect
|
|
1545
|
+
? { level: 'FAIL', check: 'runtime_legacy_import', message: `${failedLegacy} legacy import record(s) failed.`, action: 'Inspect imported runtime records and repair malformed state/events/invocation metadata before continuing.' }
|
|
427
1546
|
: importedLegacy > 0
|
|
428
1547
|
? { level: 'PASS', check: 'runtime_legacy_import', message: `${importedLegacy} legacy runtime record(s) imported non-destructively; trust debt was preserved, not upgraded.` }
|
|
429
1548
|
: { level: 'PASS', check: 'runtime_legacy_import', message: 'No legacy runtime import debt detected.' });
|
|
@@ -434,6 +1553,373 @@ export async function inspectRuntimeStoreEvidence(projectRoot: string): Promise<
|
|
|
434
1553
|
}
|
|
435
1554
|
}
|
|
436
1555
|
|
|
1556
|
+
interface RuntimeArtifactPayloadRow {
|
|
1557
|
+
payload_id: string;
|
|
1558
|
+
run_id: string;
|
|
1559
|
+
source_run_id: string;
|
|
1560
|
+
branch_slug: string;
|
|
1561
|
+
task_id: string | null;
|
|
1562
|
+
logical_ref: string;
|
|
1563
|
+
physical_payload_path: string;
|
|
1564
|
+
artifact_role: string;
|
|
1565
|
+
digest: string;
|
|
1566
|
+
sequence: number;
|
|
1567
|
+
status: RuntimeArtifactPayloadStatus;
|
|
1568
|
+
supersedes: string | null;
|
|
1569
|
+
created_at: string;
|
|
1570
|
+
payload_json: string;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
function nextArtifactPayloadSequence(db: RuntimeStoreDatabase, branchSlug: string, taskId: string | null, logicalRef: string): number {
|
|
1574
|
+
const row = db.prepare('SELECT MAX(sequence) AS sequence FROM artifact_payloads WHERE branch_slug = ? AND ((task_id IS NULL AND ? IS NULL) OR task_id = ?) AND logical_ref = ?').get(branchSlug, taskId, taskId, logicalRef) as { sequence?: number | null } | undefined;
|
|
1575
|
+
return (row?.sequence ?? 0) + 1;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
interface RuntimeTestStepRow {
|
|
1579
|
+
test_step_id: string;
|
|
1580
|
+
test_run_id: string;
|
|
1581
|
+
run_id: string;
|
|
1582
|
+
task_id: string;
|
|
1583
|
+
command: string;
|
|
1584
|
+
status: string;
|
|
1585
|
+
exit_code: number | null;
|
|
1586
|
+
duration_ms: number;
|
|
1587
|
+
output_artifact: string | null;
|
|
1588
|
+
payload_json: string;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
function runtimeTestStepFromRow(row: RuntimeTestStepRow): RuntimeTestStepRecord {
|
|
1592
|
+
return {
|
|
1593
|
+
stepId: row.test_step_id,
|
|
1594
|
+
testRunId: row.test_run_id,
|
|
1595
|
+
runId: row.run_id,
|
|
1596
|
+
taskId: row.task_id,
|
|
1597
|
+
command: row.command,
|
|
1598
|
+
status: row.status,
|
|
1599
|
+
exitCode: row.exit_code,
|
|
1600
|
+
durationMs: row.duration_ms,
|
|
1601
|
+
outputArtifact: row.output_artifact,
|
|
1602
|
+
payload: JSON.parse(row.payload_json)
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
function runtimeArtifactPayloadFromRow(row: RuntimeArtifactPayloadRow): RuntimeArtifactPayloadRecord {
|
|
1608
|
+
return {
|
|
1609
|
+
payloadId: row.payload_id,
|
|
1610
|
+
runId: row.run_id,
|
|
1611
|
+
sourceRunId: row.source_run_id,
|
|
1612
|
+
branchSlug: row.branch_slug,
|
|
1613
|
+
taskId: row.task_id,
|
|
1614
|
+
logicalRef: row.logical_ref,
|
|
1615
|
+
physicalPayloadPath: row.physical_payload_path,
|
|
1616
|
+
artifactRole: row.artifact_role,
|
|
1617
|
+
digest: row.digest,
|
|
1618
|
+
sequence: row.sequence,
|
|
1619
|
+
status: row.status,
|
|
1620
|
+
supersedes: row.supersedes,
|
|
1621
|
+
createdAt: row.created_at,
|
|
1622
|
+
payload: JSON.parse(row.payload_json)
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
interface RuntimeValidationCacheEntryRow {
|
|
1628
|
+
cache_key: string;
|
|
1629
|
+
branch_slug: string;
|
|
1630
|
+
command: string;
|
|
1631
|
+
status: RuntimeValidationCacheEntryStatus;
|
|
1632
|
+
source_test_run_id: string;
|
|
1633
|
+
source_run_id: string;
|
|
1634
|
+
source_evidence_set_id: string | null;
|
|
1635
|
+
output_artifact: string | null;
|
|
1636
|
+
stdout_digest: string;
|
|
1637
|
+
stderr_digest: string;
|
|
1638
|
+
created_at: string;
|
|
1639
|
+
last_used_at: string;
|
|
1640
|
+
payload_json: string;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
function runtimeValidationCacheEntryFromRow(row: RuntimeValidationCacheEntryRow): RuntimeValidationCacheEntryRecord {
|
|
1644
|
+
return {
|
|
1645
|
+
cacheKey: row.cache_key,
|
|
1646
|
+
branchSlug: row.branch_slug,
|
|
1647
|
+
command: row.command,
|
|
1648
|
+
status: row.status,
|
|
1649
|
+
sourceTestRunId: row.source_test_run_id,
|
|
1650
|
+
sourceRunId: row.source_run_id,
|
|
1651
|
+
sourceEvidenceSetId: row.source_evidence_set_id,
|
|
1652
|
+
outputArtifact: row.output_artifact,
|
|
1653
|
+
stdoutDigest: row.stdout_digest,
|
|
1654
|
+
stderrDigest: row.stderr_digest,
|
|
1655
|
+
createdAt: row.created_at,
|
|
1656
|
+
lastUsedAt: row.last_used_at,
|
|
1657
|
+
payload: JSON.parse(row.payload_json)
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
interface RuntimeValidationCacheUseRow {
|
|
1662
|
+
use_id: string;
|
|
1663
|
+
cache_key: string;
|
|
1664
|
+
branch_slug: string;
|
|
1665
|
+
test_run_id: string;
|
|
1666
|
+
run_id: string;
|
|
1667
|
+
task_id: string;
|
|
1668
|
+
source_test_run_id: string;
|
|
1669
|
+
source_evidence_set_id: string | null;
|
|
1670
|
+
reused_at: string;
|
|
1671
|
+
mapped_task_ids_json: string;
|
|
1672
|
+
reason: string;
|
|
1673
|
+
payload_json: string;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
function runtimeValidationCacheUseFromRow(row: RuntimeValidationCacheUseRow): RuntimeValidationCacheUseRecord {
|
|
1677
|
+
return {
|
|
1678
|
+
useId: row.use_id,
|
|
1679
|
+
cacheKey: row.cache_key,
|
|
1680
|
+
branchSlug: row.branch_slug,
|
|
1681
|
+
testRunId: row.test_run_id,
|
|
1682
|
+
runId: row.run_id,
|
|
1683
|
+
taskId: row.task_id,
|
|
1684
|
+
sourceTestRunId: row.source_test_run_id,
|
|
1685
|
+
sourceEvidenceSetId: row.source_evidence_set_id,
|
|
1686
|
+
reusedAt: row.reused_at,
|
|
1687
|
+
mappedTaskIds: parseStringList(row.mapped_task_ids_json),
|
|
1688
|
+
reason: row.reason,
|
|
1689
|
+
payload: JSON.parse(row.payload_json)
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
interface RuntimeRepairRow {
|
|
1694
|
+
repair_id: string;
|
|
1695
|
+
branch_slug: string;
|
|
1696
|
+
task_id: string | null;
|
|
1697
|
+
repair_type: RuntimeRepairType;
|
|
1698
|
+
repair_of_run_id: string | null;
|
|
1699
|
+
repair_of_gate_decision_id: string | null;
|
|
1700
|
+
status: RuntimeRepairStatus;
|
|
1701
|
+
affected_tasks_json: string;
|
|
1702
|
+
blockers_json: string;
|
|
1703
|
+
recommended_commands_json: string;
|
|
1704
|
+
required_evidence_json: string;
|
|
1705
|
+
created_at: string;
|
|
1706
|
+
resolved_at: string | null;
|
|
1707
|
+
payload_json: string;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
function runtimeRepairFromRow(row: RuntimeRepairRow): RuntimeRepairRecord {
|
|
1711
|
+
return {
|
|
1712
|
+
repairId: row.repair_id,
|
|
1713
|
+
branchSlug: row.branch_slug,
|
|
1714
|
+
taskId: row.task_id,
|
|
1715
|
+
repairType: row.repair_type,
|
|
1716
|
+
repairOfRunId: row.repair_of_run_id,
|
|
1717
|
+
repairOfGateDecisionId: row.repair_of_gate_decision_id,
|
|
1718
|
+
status: row.status,
|
|
1719
|
+
affectedTasks: parseStringList(row.affected_tasks_json),
|
|
1720
|
+
blockers: parseStringList(row.blockers_json),
|
|
1721
|
+
recommendedCommands: parseStringList(row.recommended_commands_json),
|
|
1722
|
+
requiredEvidence: parseStringList(row.required_evidence_json),
|
|
1723
|
+
createdAt: row.created_at,
|
|
1724
|
+
resolvedAt: row.resolved_at,
|
|
1725
|
+
payload: JSON.parse(row.payload_json)
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
interface RuntimeCapabilityAdoptionRow {
|
|
1730
|
+
adoption_id: string;
|
|
1731
|
+
branch_slug: string;
|
|
1732
|
+
lifecycle_stage: RuntimeCapabilityAdoptionStage;
|
|
1733
|
+
capability_domain: string;
|
|
1734
|
+
source_id: string | null;
|
|
1735
|
+
status: RuntimeCapabilityAdoptionStatus;
|
|
1736
|
+
reason: string;
|
|
1737
|
+
evidence_refs_json: string;
|
|
1738
|
+
final_authority: RuntimeCapabilityAdoptionAuthority;
|
|
1739
|
+
created_at: string;
|
|
1740
|
+
updated_at: string;
|
|
1741
|
+
payload_json: string;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
function runtimeCapabilityAdoptionFromRow(row: RuntimeCapabilityAdoptionRow): RuntimeCapabilityAdoptionRecord {
|
|
1745
|
+
return {
|
|
1746
|
+
adoptionId: row.adoption_id,
|
|
1747
|
+
branchSlug: row.branch_slug,
|
|
1748
|
+
lifecycleStage: row.lifecycle_stage,
|
|
1749
|
+
capabilityDomain: row.capability_domain,
|
|
1750
|
+
sourceId: row.source_id,
|
|
1751
|
+
status: row.status,
|
|
1752
|
+
reason: row.reason,
|
|
1753
|
+
evidenceRefs: parseStringList(row.evidence_refs_json),
|
|
1754
|
+
finalAuthority: row.final_authority,
|
|
1755
|
+
createdAt: row.created_at,
|
|
1756
|
+
updatedAt: row.updated_at,
|
|
1757
|
+
payload: JSON.parse(row.payload_json)
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
interface RuntimeStageArtifactRow {
|
|
1762
|
+
artifact_id: string;
|
|
1763
|
+
branch_slug: string;
|
|
1764
|
+
stage: RegisteredStageArtifact['stage'];
|
|
1765
|
+
artifact_kind: RegisteredStageArtifact['kind'];
|
|
1766
|
+
producer: RegisteredStageArtifact['producer'];
|
|
1767
|
+
artifact_ref: string;
|
|
1768
|
+
content_hash: string;
|
|
1769
|
+
contract: string;
|
|
1770
|
+
target_ref: string | null;
|
|
1771
|
+
target_hash: string | null;
|
|
1772
|
+
review_ref: string | null;
|
|
1773
|
+
review_hash: string | null;
|
|
1774
|
+
verdict: RegisteredStageArtifact['verdict'] | null;
|
|
1775
|
+
finding_count: number | null;
|
|
1776
|
+
blocking_count: number | null;
|
|
1777
|
+
recommendation: RegisteredStageArtifact['recommendation'] | null;
|
|
1778
|
+
frontmatter_json: string;
|
|
1779
|
+
registered_at: string;
|
|
1780
|
+
payload_json: string;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
function runtimeStageArtifactFromRow(row: RuntimeStageArtifactRow): RegisteredStageArtifact {
|
|
1784
|
+
const payload = JSON.parse(row.payload_json) as RegisteredStageArtifact;
|
|
1785
|
+
return {
|
|
1786
|
+
...payload,
|
|
1787
|
+
artifactId: row.artifact_id,
|
|
1788
|
+
branch: row.branch_slug,
|
|
1789
|
+
stage: row.stage,
|
|
1790
|
+
kind: row.artifact_kind,
|
|
1791
|
+
producer: row.producer,
|
|
1792
|
+
ref: row.artifact_ref,
|
|
1793
|
+
hash: row.content_hash,
|
|
1794
|
+
contract: row.contract,
|
|
1795
|
+
targetRef: row.target_ref ? runtimeRefFromStoredRef(row.target_ref, row.target_hash ?? undefined) : undefined,
|
|
1796
|
+
targetHash: row.target_hash ?? undefined,
|
|
1797
|
+
reviewRef: row.review_ref ? runtimeRefFromStoredRef(row.review_ref, row.review_hash ?? undefined) : undefined,
|
|
1798
|
+
reviewHash: row.review_hash ?? undefined,
|
|
1799
|
+
verdict: row.verdict ?? undefined,
|
|
1800
|
+
findingCount: row.finding_count ?? undefined,
|
|
1801
|
+
blockingCount: row.blocking_count ?? undefined,
|
|
1802
|
+
recommendation: row.recommendation ?? undefined,
|
|
1803
|
+
frontmatter: JSON.parse(row.frontmatter_json) as Record<string, unknown>,
|
|
1804
|
+
registeredAt: row.registered_at
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
interface RuntimeStageCollaborationContractRow {
|
|
1809
|
+
contract_id: string;
|
|
1810
|
+
branch_slug: string;
|
|
1811
|
+
stage: RegisteredStageCollaborationContract['stage'];
|
|
1812
|
+
contract_ref: string;
|
|
1813
|
+
content_hash: string;
|
|
1814
|
+
contract_version: string;
|
|
1815
|
+
producer: RegisteredStageCollaborationContract['producer'];
|
|
1816
|
+
work_order_id: string | null;
|
|
1817
|
+
status: RegisteredStageCollaborationContract['status'];
|
|
1818
|
+
validation_errors_json: string;
|
|
1819
|
+
selected_agents_json: string;
|
|
1820
|
+
selected_skills_json: string;
|
|
1821
|
+
selected_materials_json: string;
|
|
1822
|
+
evidence_contracts_json: string;
|
|
1823
|
+
checkpoint_plan_json: string;
|
|
1824
|
+
rework_plan_json: string;
|
|
1825
|
+
permission_projection_json: string;
|
|
1826
|
+
frontmatter_json: string;
|
|
1827
|
+
registered_at: string;
|
|
1828
|
+
payload_json: string;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
function runtimeStageCollaborationContractFromRow(row: RuntimeStageCollaborationContractRow): RegisteredStageCollaborationContract {
|
|
1832
|
+
const payload = JSON.parse(row.payload_json) as RegisteredStageCollaborationContract;
|
|
1833
|
+
return {
|
|
1834
|
+
...payload,
|
|
1835
|
+
contractId: row.contract_id,
|
|
1836
|
+
branch: row.branch_slug,
|
|
1837
|
+
stage: row.stage,
|
|
1838
|
+
ref: row.contract_ref,
|
|
1839
|
+
hash: row.content_hash,
|
|
1840
|
+
contract: row.contract_version,
|
|
1841
|
+
producer: row.producer,
|
|
1842
|
+
workOrderId: row.work_order_id,
|
|
1843
|
+
status: row.status,
|
|
1844
|
+
validationErrors: JSON.parse(row.validation_errors_json) as string[],
|
|
1845
|
+
selectedAgents: JSON.parse(row.selected_agents_json) as string[],
|
|
1846
|
+
selectedSkills: JSON.parse(row.selected_skills_json) as string[],
|
|
1847
|
+
selectedMaterialPacks: JSON.parse(row.selected_materials_json) as string[],
|
|
1848
|
+
evidenceContracts: JSON.parse(row.evidence_contracts_json) as string[],
|
|
1849
|
+
checkpointPlan: JSON.parse(row.checkpoint_plan_json) as string[],
|
|
1850
|
+
reworkPlan: JSON.parse(row.rework_plan_json) as RegisteredStageCollaborationContract['reworkPlan'],
|
|
1851
|
+
permissionProjection: JSON.parse(row.permission_projection_json) as RegisteredStageCollaborationContract['permissionProjection'],
|
|
1852
|
+
frontmatter: JSON.parse(row.frontmatter_json) as Record<string, unknown>,
|
|
1853
|
+
registeredAt: row.registered_at
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
function runtimeRefFromStoredRef(ref: string, hash?: string): { kind: 'document' | 'artifact' | 'projection' | 'external'; ref: string; hash?: string } {
|
|
1858
|
+
const kind = ref.startsWith('specs/') ? 'document' : ref.startsWith('.sdd/runs/') ? 'artifact' : ref.startsWith('projection:') ? 'projection' : 'external';
|
|
1859
|
+
return hash ? { kind, ref, hash } : { kind, ref };
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
interface RuntimeDurableGapRow {
|
|
1863
|
+
gap_id: string;
|
|
1864
|
+
partition: string;
|
|
1865
|
+
task_id: string | null;
|
|
1866
|
+
run_id: string | null;
|
|
1867
|
+
stage: string | null;
|
|
1868
|
+
gate_name: string | null;
|
|
1869
|
+
source: RuntimeDurableGapSource;
|
|
1870
|
+
category: string;
|
|
1871
|
+
severity: RuntimeDurableGapSeverity;
|
|
1872
|
+
status: RuntimeDurableGapStatus;
|
|
1873
|
+
message: string;
|
|
1874
|
+
recommendation: string | null;
|
|
1875
|
+
evidence_refs_json: string;
|
|
1876
|
+
proposal_refs_json: string;
|
|
1877
|
+
source_refs_json: string;
|
|
1878
|
+
created_at: string;
|
|
1879
|
+
updated_at: string;
|
|
1880
|
+
closed_at: string | null;
|
|
1881
|
+
payload_json: string;
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
function runtimeDurableGapFromRow(row: RuntimeDurableGapRow): RuntimeDurableGapRecord {
|
|
1885
|
+
return {
|
|
1886
|
+
gapId: row.gap_id,
|
|
1887
|
+
partition: row.partition,
|
|
1888
|
+
taskId: row.task_id,
|
|
1889
|
+
runId: row.run_id,
|
|
1890
|
+
stage: row.stage,
|
|
1891
|
+
gate: row.gate_name,
|
|
1892
|
+
source: row.source,
|
|
1893
|
+
category: row.category,
|
|
1894
|
+
severity: row.severity,
|
|
1895
|
+
status: row.status,
|
|
1896
|
+
message: row.message,
|
|
1897
|
+
recommendation: row.recommendation,
|
|
1898
|
+
evidenceRefs: parseStringList(row.evidence_refs_json),
|
|
1899
|
+
proposalRefs: parseStringList(row.proposal_refs_json),
|
|
1900
|
+
sourceRefs: parseStringList(row.source_refs_json),
|
|
1901
|
+
createdAt: row.created_at,
|
|
1902
|
+
updatedAt: row.updated_at,
|
|
1903
|
+
closedAt: row.closed_at,
|
|
1904
|
+
payload: JSON.parse(row.payload_json)
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
function assertDurableGapStatusAuthority(source: RuntimeDurableGapSource, status: RuntimeDurableGapStatus): void {
|
|
1909
|
+
if (terminalGapStatus(status) && source !== 'runtime' && source !== 'gate_policy' && source !== 'doctor') {
|
|
1910
|
+
throw new Error(`Durable gap terminal status ${status} cannot be written by ${source}.`);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
function terminalGapStatus(status: RuntimeDurableGapStatus): boolean {
|
|
1915
|
+
return status === 'resolved' || status === 'waived' || status === 'superseded';
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
function parseStringList(raw: string): string[] {
|
|
1919
|
+
const parsed = JSON.parse(raw) as unknown;
|
|
1920
|
+
return Array.isArray(parsed) ? parsed.filter((item): item is string => typeof item === 'string') : [];
|
|
1921
|
+
}
|
|
1922
|
+
|
|
437
1923
|
interface RuntimeProjectionRow {
|
|
438
1924
|
projection_type: string;
|
|
439
1925
|
scope_key: string;
|
|
@@ -463,6 +1949,21 @@ function asRuntimeProjectionEnvelope<TPayload>(payload: unknown): RuntimeProject
|
|
|
463
1949
|
return candidate.contract === RUNTIME_PROJECTION_ENVELOPE_CONTRACT_VERSION ? candidate as RuntimeProjectionEnvelope<TPayload> : null;
|
|
464
1950
|
}
|
|
465
1951
|
|
|
1952
|
+
function appendRuntimeScopeClauses(clauses: string[], params: string[], input: { partition?: string | null; runId?: string | null; taskId?: string | null }): void {
|
|
1953
|
+
if (input.partition) {
|
|
1954
|
+
clauses.push('partition = ?');
|
|
1955
|
+
params.push(input.partition);
|
|
1956
|
+
}
|
|
1957
|
+
if (input.runId) {
|
|
1958
|
+
clauses.push('run_id = ?');
|
|
1959
|
+
params.push(input.runId);
|
|
1960
|
+
}
|
|
1961
|
+
if (input.taskId) {
|
|
1962
|
+
clauses.push('task_id = ?');
|
|
1963
|
+
params.push(input.taskId);
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
|
|
466
1967
|
export function runtimeScopedId(...parts: string[]): string {
|
|
467
1968
|
return createHash('sha256').update(parts.join('\0'), 'utf8').digest('hex').slice(0, 32);
|
|
468
1969
|
}
|