sdd-agent-platform 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -23
- package/node_modules/@sdd-agent-platform/core/dist/ai-tools.js +31 -28
- package/node_modules/@sdd-agent-platform/core/dist/ai-tools.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/config/init-project.js +3 -2
- package/node_modules/@sdd-agent-platform/core/dist/config/init-project.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.d.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.js +14 -5
- package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/contracts.d.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/contracts.js +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/contracts.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-evidence.js +3 -3
- 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/doctor.js +155 -1
- 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 +54 -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 -0
- 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/resident-worker.js +14 -6
- 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/instructions.js +36 -36
- package/node_modules/@sdd-agent-platform/core/dist/instructions.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.d.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.js +37 -17
- package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.d.ts +16 -1
- package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.js +174 -16
- 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 +2 -2
- 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 +31 -1
- 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/workflow-gates.js +5 -5
- package/node_modules/@sdd-agent-platform/core/dist/registries/workflow-gates.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime-config.js +27 -12
- 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 +59 -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 +191 -0
- 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 +32 -6
- package/node_modules/@sdd-agent-platform/core/dist/router/routing.js.map +1 -1
- 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/run-state/artifacts.js +48 -15
- 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 -1
- package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.js +15 -49
- 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 +25 -1
- package/node_modules/@sdd-agent-platform/core/dist/run-state/run-state.js +21 -14
- 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 +62 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.js +130 -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.d.ts +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state.js +1 -0
- package/node_modules/@sdd-agent-platform/core/dist/run-state.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.d.ts +10 -0
- package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.js +44 -14
- package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.js.map +1 -1
- 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 +4 -0
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.js +189 -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.js +12 -3
- 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 +20 -0
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.js +101 -21
- package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/status/project-status.d.ts +62 -1
- package/node_modules/@sdd-agent-platform/core/dist/status/project-status.js +192 -4
- 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 +195 -2
- package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.js +499 -2
- package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.js +23 -1
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.d.ts +19 -0
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.js +114 -12
- package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.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.js +16 -2
- package/node_modules/@sdd-agent-platform/core/dist/test-support/run-state.js.map +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/goal-verify.js +34 -2
- 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.js +15 -5
- 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.js +102 -9
- 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 +16 -1
- package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.js +355 -69
- 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-wave.d.ts +58 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.js +428 -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 +2 -0
- package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.js +116 -18
- 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/workflow-gate/evidence-packet.d.ts +24 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/evidence-packet.js +182 -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 +130 -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 +146 -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 +89 -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 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.js +16 -1
- 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 +38 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.js +122 -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/resolve.d.ts +27 -0
- package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.js +166 -37
- 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.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 +1 -1
- package/node_modules/@sdd-agent-platform/core/src/ai-tools.ts +31 -28
- package/node_modules/@sdd-agent-platform/core/src/artifacts/sdd-result.test.ts +50 -4
- package/node_modules/@sdd-agent-platform/core/src/config/init-project.test.ts +13 -10
- package/node_modules/@sdd-agent-platform/core/src/config/init-project.ts +3 -2
- package/node_modules/@sdd-agent-platform/core/src/config/starter-documents.ts +15 -5
- package/node_modules/@sdd-agent-platform/core/src/contracts.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/src/doctor/checks/run-evidence.ts +3 -3
- package/node_modules/@sdd-agent-platform/core/src/doctor/doctor.test.ts +117 -5
- package/node_modules/@sdd-agent-platform/core/src/doctor/doctor.ts +164 -1
- package/node_modules/@sdd-agent-platform/core/src/evidence/lookup.ts +80 -0
- package/node_modules/@sdd-agent-platform/core/src/evidence-runtime/contracts.ts +12 -0
- 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 +7 -0
- package/node_modules/@sdd-agent-platform/core/src/execution/resident-worker.test.ts +5 -0
- package/node_modules/@sdd-agent-platform/core/src/execution/resident-worker.ts +14 -6
- 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 +4 -0
- package/node_modules/@sdd-agent-platform/core/src/governance/policy.test.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/src/instructions.test.ts +11 -5
- package/node_modules/@sdd-agent-platform/core/src/instructions.ts +36 -36
- package/node_modules/@sdd-agent-platform/core/src/lifecycle/ship.ts +39 -17
- package/node_modules/@sdd-agent-platform/core/src/phase8-contracts.test.ts +3 -2
- package/node_modules/@sdd-agent-platform/core/src/phase8-risk-kernel.test.ts +5 -0
- 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 +269 -17
- package/node_modules/@sdd-agent-platform/core/src/registries/agent-registry.ts +2 -2
- package/node_modules/@sdd-agent-platform/core/src/registries/agent-runtime-static.ts +41 -1
- package/node_modules/@sdd-agent-platform/core/src/registries/capability-sources.ts +238 -15
- package/node_modules/@sdd-agent-platform/core/src/registries/registries.test.ts +27 -2
- package/node_modules/@sdd-agent-platform/core/src/registries/workflow-gates.ts +5 -5
- package/node_modules/@sdd-agent-platform/core/src/router/agent-runtime-config.ts +31 -12
- package/node_modules/@sdd-agent-platform/core/src/router/agent-runtime.ts +66 -1
- package/node_modules/@sdd-agent-platform/core/src/router/route-projection.ts +211 -0
- package/node_modules/@sdd-agent-platform/core/src/router/route-sdd-task.test.ts +151 -3
- package/node_modules/@sdd-agent-platform/core/src/router/routing.ts +35 -6
- 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/run-state/artifacts.ts +48 -15
- 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 +17 -52
- 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 +28 -1
- package/node_modules/@sdd-agent-platform/core/src/run-state/run-state.test.ts +3 -0
- package/node_modules/@sdd-agent-platform/core/src/run-state/run-state.ts +22 -18
- package/node_modules/@sdd-agent-platform/core/src/run-state/task-evidence.ts +206 -0
- package/node_modules/@sdd-agent-platform/core/src/run-state.ts +1 -0
- package/node_modules/@sdd-agent-platform/core/src/runtime-paths.ts +54 -14
- 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 +207 -0
- package/node_modules/@sdd-agent-platform/core/src/sdd-docs/run-binding.ts +12 -3
- package/node_modules/@sdd-agent-platform/core/src/sdd-docs/task-parser.test.ts +139 -0
- package/node_modules/@sdd-agent-platform/core/src/sdd-docs/task-parser.ts +137 -24
- package/node_modules/@sdd-agent-platform/core/src/status/project-status.ts +268 -5
- package/node_modules/@sdd-agent-platform/core/src/storage/runtime-store.test.ts +368 -4
- package/node_modules/@sdd-agent-platform/core/src/storage/runtime-store.ts +697 -2
- package/node_modules/@sdd-agent-platform/core/src/sync-back/apply.ts +23 -1
- package/node_modules/@sdd-agent-platform/core/src/sync-back/inspect.ts +145 -12
- package/node_modules/@sdd-agent-platform/core/src/sync-back/sync-back.test.ts +132 -9
- 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 +16 -2
- package/node_modules/@sdd-agent-platform/core/src/verification/goal-verify.test.ts +1 -1
- package/node_modules/@sdd-agent-platform/core/src/verification/goal-verify.ts +38 -5
- package/node_modules/@sdd-agent-platform/core/src/verification/rendering.ts +15 -5
- package/node_modules/@sdd-agent-platform/core/src/verification/review-gate.test.ts +77 -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 +64 -4
- package/node_modules/@sdd-agent-platform/core/src/verification/single-task-loop.ts +110 -12
- package/node_modules/@sdd-agent-platform/core/src/verification/test-runtime.test.ts +72 -25
- package/node_modules/@sdd-agent-platform/core/src/verification/test-runtime.ts +402 -77
- package/node_modules/@sdd-agent-platform/core/src/verification/validation-wave.test.ts +341 -0
- package/node_modules/@sdd-agent-platform/core/src/verification/validation-wave.ts +513 -0
- package/node_modules/@sdd-agent-platform/core/src/verification/verify-contract.test.ts +144 -5
- package/node_modules/@sdd-agent-platform/core/src/verification/verify-contract.ts +129 -18
- package/node_modules/@sdd-agent-platform/core/src/verification.ts +2 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/evidence-packet.ts +196 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/hard-checks.test.ts +171 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/hard-checks.ts +143 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/policy.test.ts +137 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/policy.ts +155 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-gate/types.ts +114 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/affected-file-conflicts.ts +18 -1
- 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 +156 -0
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve.test.ts +351 -2
- package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve.ts +227 -39
- package/node_modules/@sdd-agent-platform/core/src/workflow-state.ts +1 -0
- package/package.json +1 -1
- package/packages/cli/dist/commands/status.js +2 -2
- package/packages/cli/dist/commands/status.js.map +1 -1
- package/packages/cli/dist/commands/sync-back.js +1 -1
- package/packages/cli/dist/commands/sync-back.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 +94 -5
- package/packages/cli/dist/commands/test.js.map +1 -1
- package/packages/cli/dist/commands/verifies.js +5 -3
- package/packages/cli/dist/commands/verifies.js.map +1 -1
- package/packages/cli/dist/commands/verify.js +48 -7
- package/packages/cli/dist/commands/verify.js.map +1 -1
- package/packages/cli/dist/help.js +32 -18
- package/packages/cli/dist/help.js.map +1 -1
- package/packages/cli/dist/renderers/artifacts.js +1 -1
- package/packages/cli/dist/renderers/artifacts.js.map +1 -1
- package/packages/cli/dist/renderers/registry-runtime.js +7 -2
- package/packages/cli/dist/renderers/registry-runtime.js.map +1 -1
- package/packages/cli/dist/renderers/router.js +4 -2
- package/packages/cli/dist/renderers/router.js.map +1 -1
- package/packages/cli/dist/renderers/workflow.js +33 -12
- package/packages/cli/dist/renderers/workflow.js.map +1 -1
- package/packages/cli/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/cli/package.json +2 -2
- package/packages/core/dist/ai-tools.js +31 -28
- package/packages/core/dist/ai-tools.js.map +1 -1
- package/packages/core/dist/config/init-project.js +3 -2
- package/packages/core/dist/config/init-project.js.map +1 -1
- package/packages/core/dist/config/starter-documents.d.ts +1 -1
- package/packages/core/dist/config/starter-documents.js +14 -5
- package/packages/core/dist/config/starter-documents.js.map +1 -1
- package/packages/core/dist/contracts.d.ts +2 -0
- package/packages/core/dist/contracts.js +2 -0
- package/packages/core/dist/contracts.js.map +1 -1
- package/packages/core/dist/doctor/checks/run-evidence.js +3 -3
- package/packages/core/dist/doctor/checks/run-evidence.js.map +1 -1
- package/packages/core/dist/doctor/doctor.js +155 -1
- 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 +54 -0
- package/packages/core/dist/evidence/lookup.js.map +1 -0
- package/packages/core/dist/evidence-runtime/contracts.d.ts +11 -0
- 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/resident-worker.js +14 -6
- 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/instructions.js +36 -36
- package/packages/core/dist/instructions.js.map +1 -1
- package/packages/core/dist/lifecycle/ship.d.ts +2 -0
- package/packages/core/dist/lifecycle/ship.js +37 -17
- package/packages/core/dist/lifecycle/ship.js.map +1 -1
- package/packages/core/dist/registries/agent-capability-catalog.d.ts +16 -1
- package/packages/core/dist/registries/agent-capability-catalog.js +174 -16
- package/packages/core/dist/registries/agent-capability-catalog.js.map +1 -1
- package/packages/core/dist/registries/agent-registry.js +2 -2
- 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 +31 -1
- 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/workflow-gates.js +5 -5
- package/packages/core/dist/registries/workflow-gates.js.map +1 -1
- package/packages/core/dist/router/agent-runtime-config.js +27 -12
- package/packages/core/dist/router/agent-runtime-config.js.map +1 -1
- package/packages/core/dist/router/agent-runtime.d.ts +59 -1
- package/packages/core/dist/router/route-projection.d.ts +3 -1
- package/packages/core/dist/router/route-projection.js +191 -0
- package/packages/core/dist/router/route-projection.js.map +1 -1
- package/packages/core/dist/router/routing.js +32 -6
- package/packages/core/dist/router/routing.js.map +1 -1
- 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/run-state/artifacts.js +48 -15
- 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 -1
- package/packages/core/dist/run-state/inspect-run.js +15 -49
- 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 +25 -1
- package/packages/core/dist/run-state/run-state.js +21 -14
- package/packages/core/dist/run-state/run-state.js.map +1 -1
- package/packages/core/dist/run-state/task-evidence.d.ts +62 -0
- package/packages/core/dist/run-state/task-evidence.js +130 -0
- package/packages/core/dist/run-state/task-evidence.js.map +1 -0
- package/packages/core/dist/run-state.d.ts +1 -0
- package/packages/core/dist/run-state.js +1 -0
- package/packages/core/dist/run-state.js.map +1 -1
- package/packages/core/dist/runtime-paths.d.ts +10 -0
- package/packages/core/dist/runtime-paths.js +44 -14
- package/packages/core/dist/runtime-paths.js.map +1 -1
- 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 +4 -0
- package/packages/core/dist/sdd-docs/document-hashes.js +189 -0
- package/packages/core/dist/sdd-docs/document-hashes.js.map +1 -0
- package/packages/core/dist/sdd-docs/run-binding.js +12 -3
- package/packages/core/dist/sdd-docs/run-binding.js.map +1 -1
- package/packages/core/dist/sdd-docs/task-parser.d.ts +20 -0
- package/packages/core/dist/sdd-docs/task-parser.js +101 -21
- package/packages/core/dist/sdd-docs/task-parser.js.map +1 -1
- package/packages/core/dist/status/project-status.d.ts +62 -1
- package/packages/core/dist/status/project-status.js +192 -4
- package/packages/core/dist/status/project-status.js.map +1 -1
- package/packages/core/dist/storage/runtime-store.d.ts +195 -2
- package/packages/core/dist/storage/runtime-store.js +499 -2
- package/packages/core/dist/storage/runtime-store.js.map +1 -1
- package/packages/core/dist/sync-back/apply.js +23 -1
- package/packages/core/dist/sync-back/apply.js.map +1 -1
- package/packages/core/dist/sync-back/inspect.d.ts +19 -0
- package/packages/core/dist/sync-back/inspect.js +114 -12
- package/packages/core/dist/sync-back/inspect.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.js +16 -2
- package/packages/core/dist/test-support/run-state.js.map +1 -1
- package/packages/core/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/core/dist/verification/goal-verify.js +34 -2
- package/packages/core/dist/verification/goal-verify.js.map +1 -1
- package/packages/core/dist/verification/rendering.js +15 -5
- 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.js +102 -9
- package/packages/core/dist/verification/single-task-loop.js.map +1 -1
- package/packages/core/dist/verification/test-runtime.d.ts +16 -1
- package/packages/core/dist/verification/test-runtime.js +355 -69
- package/packages/core/dist/verification/test-runtime.js.map +1 -1
- package/packages/core/dist/verification/validation-wave.d.ts +58 -0
- package/packages/core/dist/verification/validation-wave.js +428 -0
- package/packages/core/dist/verification/validation-wave.js.map +1 -0
- package/packages/core/dist/verification/verify-contract.d.ts +2 -0
- package/packages/core/dist/verification/verify-contract.js +116 -18
- 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/workflow-gate/evidence-packet.d.ts +24 -0
- package/packages/core/dist/workflow-gate/evidence-packet.js +182 -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 +130 -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 +146 -0
- package/packages/core/dist/workflow-gate/policy.js.map +1 -0
- package/packages/core/dist/workflow-gate/types.d.ts +89 -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 -0
- package/packages/core/dist/workflow-state/affected-file-conflicts.js +16 -1
- 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 +38 -0
- package/packages/core/dist/workflow-state/latest-eligible-run.js +122 -0
- package/packages/core/dist/workflow-state/latest-eligible-run.js.map +1 -0
- package/packages/core/dist/workflow-state/resolve.d.ts +27 -0
- package/packages/core/dist/workflow-state/resolve.js +166 -37
- package/packages/core/dist/workflow-state/resolve.js.map +1 -1
- 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 +1 -1
|
@@ -4,10 +4,14 @@ 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
6
|
import { 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';
|
|
7
11
|
|
|
8
12
|
|
|
9
|
-
export const RUNTIME_STORE_SCHEMA_VERSION =
|
|
10
|
-
export const RUNTIME_STORE_CONTRACT_VERSION = 'phase-
|
|
13
|
+
export const RUNTIME_STORE_SCHEMA_VERSION = 6;
|
|
14
|
+
export const RUNTIME_STORE_CONTRACT_VERSION = 'phase-8.17-validation-wave-runtime-v6';
|
|
11
15
|
|
|
12
16
|
export type RuntimeStoreIssueCode = 'STORE_UNAVAILABLE' | 'SCHEMA_MISMATCH' | 'LEGACY_IMPORT_FAILED';
|
|
13
17
|
|
|
@@ -43,6 +47,108 @@ export interface RuntimeStoreDoctorCheck {
|
|
|
43
47
|
action?: string;
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
export type RuntimeArtifactPayloadStatus = 'active' | 'candidate' | 'rejected' | 'superseded';
|
|
51
|
+
|
|
52
|
+
export interface RuntimeArtifactPayloadRecord {
|
|
53
|
+
payloadId: string;
|
|
54
|
+
runId: string;
|
|
55
|
+
sourceRunId: string;
|
|
56
|
+
branchSlug: string;
|
|
57
|
+
taskId: string | null;
|
|
58
|
+
logicalRef: string;
|
|
59
|
+
physicalPayloadPath: string;
|
|
60
|
+
artifactRole: string;
|
|
61
|
+
digest: string;
|
|
62
|
+
sequence: number;
|
|
63
|
+
status: RuntimeArtifactPayloadStatus;
|
|
64
|
+
supersedes: string | null;
|
|
65
|
+
createdAt: string;
|
|
66
|
+
payload: unknown;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface RuntimeSyncBackDecisionRecord {
|
|
70
|
+
decisionId: string;
|
|
71
|
+
runId: string;
|
|
72
|
+
branch: string;
|
|
73
|
+
taskId: string | null;
|
|
74
|
+
status: string;
|
|
75
|
+
proposalPath: string | null;
|
|
76
|
+
proposalDigest: string | null;
|
|
77
|
+
proposalPayloadId: string | null;
|
|
78
|
+
reasons: string[];
|
|
79
|
+
createdAt: string;
|
|
80
|
+
updatedAt: string;
|
|
81
|
+
payload: unknown;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type RuntimeDurableGapSeverity = 'info' | 'warning' | 'blocking';
|
|
85
|
+
export type RuntimeDurableGapStatus = 'open' | 'acknowledged' | 'resolved' | 'waived' | 'superseded';
|
|
86
|
+
export type RuntimeDurableGapSource = 'runtime' | 'gate_policy' | 'doctor' | 'validator' | 'agent' | 'team' | 'llm_advisor' | 'import';
|
|
87
|
+
|
|
88
|
+
export interface RuntimeDurableGapRecord {
|
|
89
|
+
gapId: string;
|
|
90
|
+
partition: string;
|
|
91
|
+
taskId: string | null;
|
|
92
|
+
runId: string | null;
|
|
93
|
+
stage: string | null;
|
|
94
|
+
gate: string | null;
|
|
95
|
+
source: RuntimeDurableGapSource;
|
|
96
|
+
category: string;
|
|
97
|
+
severity: RuntimeDurableGapSeverity;
|
|
98
|
+
status: RuntimeDurableGapStatus;
|
|
99
|
+
message: string;
|
|
100
|
+
recommendation: string | null;
|
|
101
|
+
evidenceRefs: string[];
|
|
102
|
+
proposalRefs: string[];
|
|
103
|
+
sourceRefs: string[];
|
|
104
|
+
createdAt: string;
|
|
105
|
+
updatedAt: string;
|
|
106
|
+
closedAt: string | null;
|
|
107
|
+
payload: unknown;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type RuntimeValidationWaveStatus = 'RUNNING' | 'PASS' | 'FAIL' | 'BLOCKED';
|
|
111
|
+
export type RuntimeValidationEnvironmentStatus = 'active' | 'completed' | 'failed' | 'blocked';
|
|
112
|
+
|
|
113
|
+
export interface RuntimeValidationEnvironmentSessionRecord {
|
|
114
|
+
sessionId: string;
|
|
115
|
+
partition: string;
|
|
116
|
+
runId: string | null;
|
|
117
|
+
waveRunId: string | null;
|
|
118
|
+
status: RuntimeValidationEnvironmentStatus;
|
|
119
|
+
reuseKey: string;
|
|
120
|
+
createdAt: string;
|
|
121
|
+
updatedAt: string;
|
|
122
|
+
payload: unknown;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface RuntimeValidationWaveRunRecord {
|
|
126
|
+
waveRunId: string;
|
|
127
|
+
partition: string;
|
|
128
|
+
runId: string | null;
|
|
129
|
+
taskIds: string[];
|
|
130
|
+
status: RuntimeValidationWaveStatus;
|
|
131
|
+
environmentSessionId: string;
|
|
132
|
+
startedAt: string;
|
|
133
|
+
completedAt: string;
|
|
134
|
+
payload: unknown;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface RuntimeAcceptanceEvidenceMapRecord {
|
|
138
|
+
mapId: string;
|
|
139
|
+
waveRunId: string;
|
|
140
|
+
testRunId: string;
|
|
141
|
+
partition: string;
|
|
142
|
+
runId: string;
|
|
143
|
+
taskId: string;
|
|
144
|
+
acceptanceRef: string;
|
|
145
|
+
status: string;
|
|
146
|
+
evidenceRefs: string[];
|
|
147
|
+
gaps: string[];
|
|
148
|
+
createdAt: string;
|
|
149
|
+
payload: unknown;
|
|
150
|
+
}
|
|
151
|
+
|
|
46
152
|
|
|
47
153
|
let runtimeStoreConstructorPromise: Promise<RuntimeStoreConstructor> | null = null;
|
|
48
154
|
|
|
@@ -126,6 +232,20 @@ CREATE TABLE IF NOT EXISTS projections (projection_id TEXT PRIMARY KEY, projecti
|
|
|
126
232
|
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
233
|
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
234
|
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 NOT NULL, 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);
|
|
235
|
+
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);
|
|
236
|
+
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);
|
|
237
|
+
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);
|
|
238
|
+
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));
|
|
239
|
+
CREATE TABLE IF NOT EXISTS sync_back_decisions (decision_id TEXT PRIMARY KEY, run_id TEXT NOT NULL, branch TEXT NOT NULL, task_id TEXT, status TEXT NOT NULL, proposal_path TEXT, proposal_digest TEXT, proposal_payload_id TEXT, 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);
|
|
240
|
+
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);
|
|
241
|
+
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);
|
|
242
|
+
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);
|
|
243
|
+
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);
|
|
244
|
+
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);
|
|
245
|
+
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);
|
|
246
|
+
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);
|
|
247
|
+
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);
|
|
248
|
+
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);
|
|
129
249
|
CREATE INDEX IF NOT EXISTS idx_runs_partition_task_updated ON runs(partition, task_id, updated_at);
|
|
130
250
|
CREATE INDEX IF NOT EXISTS idx_events_run_time ON events(run_id, event_time, event_id);
|
|
131
251
|
CREATE INDEX IF NOT EXISTS idx_artifacts_run_path ON artifacts(run_id, path);
|
|
@@ -134,6 +254,22 @@ CREATE INDEX IF NOT EXISTS idx_evidence_attachments_branch_created ON evidence_a
|
|
|
134
254
|
CREATE INDEX IF NOT EXISTS idx_evidence_attachments_run_path ON evidence_attachments(run_id, relative_path);
|
|
135
255
|
CREATE INDEX IF NOT EXISTS idx_test_runs_run_task ON test_runs(run_id, task_id, completed_at);
|
|
136
256
|
CREATE INDEX IF NOT EXISTS idx_test_steps_test_run ON test_steps(test_run_id, status);
|
|
257
|
+
CREATE INDEX IF NOT EXISTS idx_agent_executions_run_task ON agent_executions(run_id, task_id, created_at);
|
|
258
|
+
CREATE INDEX IF NOT EXISTS idx_team_sessions_run_task ON team_sessions(run_id, task_id, created_at);
|
|
259
|
+
CREATE INDEX IF NOT EXISTS idx_worker_runtimes_run_task ON worker_runtimes(run_id, task_id, updated_at);
|
|
260
|
+
CREATE INDEX IF NOT EXISTS idx_artifact_payloads_logical ON artifact_payloads(branch_slug, logical_ref, status, sequence);
|
|
261
|
+
CREATE INDEX IF NOT EXISTS idx_artifact_payloads_run_logical ON artifact_payloads(run_id, logical_ref, status, sequence);
|
|
262
|
+
CREATE INDEX IF NOT EXISTS idx_sync_back_decisions_run_task ON sync_back_decisions(run_id, task_id, updated_at);
|
|
263
|
+
CREATE INDEX IF NOT EXISTS idx_durable_gaps_partition_task ON durable_gaps(partition, task_id, status, severity, updated_at);
|
|
264
|
+
CREATE INDEX IF NOT EXISTS idx_durable_gaps_run_task ON durable_gaps(run_id, task_id, status, severity, updated_at);
|
|
265
|
+
CREATE INDEX IF NOT EXISTS idx_stage_team_sessions_partition_task ON stage_team_sessions(partition, task_id, updated_at);
|
|
266
|
+
CREATE INDEX IF NOT EXISTS idx_stage_role_results_partition_task ON stage_role_results(partition, task_id, created_at);
|
|
267
|
+
CREATE INDEX IF NOT EXISTS idx_llm_advisor_assessments_partition_task ON llm_advisor_assessments(partition, task_id, created_at);
|
|
268
|
+
CREATE INDEX IF NOT EXISTS idx_fan_in_evidence_sets_partition_task ON fan_in_evidence_sets(partition, task_id, created_at);
|
|
269
|
+
CREATE INDEX IF NOT EXISTS idx_workflow_gate_decisions_partition_task ON workflow_gate_decisions(partition, task_id, decision_kind, generated_at);
|
|
270
|
+
CREATE INDEX IF NOT EXISTS idx_validation_environment_sessions_partition ON validation_environment_sessions(partition, wave_run_id, updated_at);
|
|
271
|
+
CREATE INDEX IF NOT EXISTS idx_validation_wave_runs_partition ON validation_wave_runs(partition, status, completed_at);
|
|
272
|
+
CREATE INDEX IF NOT EXISTS idx_acceptance_evidence_maps_task ON acceptance_evidence_maps(partition, task_id, acceptance_ref, created_at);
|
|
137
273
|
`);
|
|
138
274
|
db.exec(`PRAGMA user_version = ${RUNTIME_STORE_SCHEMA_VERSION}`);
|
|
139
275
|
const now = new Date().toISOString();
|
|
@@ -209,6 +345,161 @@ export async function listRuntimeRunStates(projectRoot: string): Promise<RunStat
|
|
|
209
345
|
});
|
|
210
346
|
}
|
|
211
347
|
|
|
348
|
+
export async function recordRuntimeAgentExecution(projectRoot: string, record: AgentExecutionRecord): Promise<void> {
|
|
349
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
350
|
+
db.prepare('INSERT OR REPLACE INTO agent_executions (execution_id, run_id, task_id, profile, status, created_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')
|
|
351
|
+
.run(record.executionId, record.runId, record.taskId, record.profile, record.status, record.createdAt, record.updatedAt, JSON.stringify(record));
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export async function listRuntimeAgentExecutions(projectRoot: string, runId: string): Promise<AgentExecutionRecord[]> {
|
|
356
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
357
|
+
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 }>;
|
|
358
|
+
return rows.map((row) => JSON.parse(row.payload_json) as AgentExecutionRecord);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export async function recordRuntimeTeamSession(projectRoot: string, record: TeamSessionRecord): Promise<void> {
|
|
363
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
364
|
+
db.prepare('INSERT OR REPLACE INTO team_sessions (team_id, run_id, task_id, status, created_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?)')
|
|
365
|
+
.run(record.teamId, record.runId, record.taskId, record.status, record.createdAt, record.updatedAt, JSON.stringify(record));
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export async function listRuntimeTeamSessions(projectRoot: string, runId: string): Promise<TeamSessionRecord[]> {
|
|
370
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
371
|
+
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 }>;
|
|
372
|
+
return rows.map((row) => JSON.parse(row.payload_json) as TeamSessionRecord);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export async function recordRuntimeStageTeamSession(projectRoot: string, record: StageTeamSessionRecord): Promise<void> {
|
|
377
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
378
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
379
|
+
.run(record.sessionId, record.partition, record.runId, record.taskId, record.stage, record.lifecycleProfile, record.status, record.createdAt, record.updatedAt, JSON.stringify(record));
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export async function listRuntimeStageTeamSessions(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null } = {}): Promise<StageTeamSessionRecord[]> {
|
|
384
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
385
|
+
const clauses: string[] = [];
|
|
386
|
+
const params: string[] = [];
|
|
387
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
388
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
389
|
+
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 }>;
|
|
390
|
+
return rows.map((row) => JSON.parse(row.payload_json) as StageTeamSessionRecord);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export async function recordRuntimeStageRoleResult(projectRoot: string, record: StageRoleResultRecord): Promise<void> {
|
|
395
|
+
assertValidStageRoleResult(record);
|
|
396
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
397
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
398
|
+
.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));
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export async function listRuntimeStageRoleResults(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; sessionId?: string | null } = {}): Promise<StageRoleResultRecord[]> {
|
|
403
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
404
|
+
const clauses: string[] = [];
|
|
405
|
+
const params: string[] = [];
|
|
406
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
407
|
+
if (input.sessionId) {
|
|
408
|
+
clauses.push('session_id = ?');
|
|
409
|
+
params.push(input.sessionId);
|
|
410
|
+
}
|
|
411
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
412
|
+
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 }>;
|
|
413
|
+
return rows.map((row) => JSON.parse(row.payload_json) as StageRoleResultRecord);
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export async function recordRuntimeLlmAdvisorAssessment(projectRoot: string, record: LlmAdvisorAssessmentRecord): Promise<void> {
|
|
418
|
+
assertAdvisoryAssessment(record);
|
|
419
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
420
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
421
|
+
.run(record.assessmentId, record.sessionId, record.partition, record.runId, record.taskId, record.kind, record.concern, record.advisoryOnly ? 1 : 0, record.createdAt, JSON.stringify(record));
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export async function listRuntimeLlmAdvisorAssessments(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; sessionId?: string | null } = {}): Promise<LlmAdvisorAssessmentRecord[]> {
|
|
426
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
427
|
+
const clauses: string[] = [];
|
|
428
|
+
const params: string[] = [];
|
|
429
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
430
|
+
if (input.sessionId) {
|
|
431
|
+
clauses.push('session_id = ?');
|
|
432
|
+
params.push(input.sessionId);
|
|
433
|
+
}
|
|
434
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
435
|
+
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 }>;
|
|
436
|
+
return rows.map((row) => JSON.parse(row.payload_json) as LlmAdvisorAssessmentRecord);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export async function recordRuntimeFanInEvidenceSet(projectRoot: string, record: FanInEvidenceSetRecord): Promise<void> {
|
|
441
|
+
assertValidFanInEvidenceSet(record);
|
|
442
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
443
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?)')
|
|
444
|
+
.run(record.fanInId, record.partition, record.runId, record.taskId, record.stage, record.gateInputOnly ? 1 : 0, record.createdAt, JSON.stringify(record));
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export async function listRuntimeFanInEvidenceSets(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null } = {}): Promise<FanInEvidenceSetRecord[]> {
|
|
449
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
450
|
+
const clauses: string[] = [];
|
|
451
|
+
const params: string[] = [];
|
|
452
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
453
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
454
|
+
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 }>;
|
|
455
|
+
return rows.map((row) => JSON.parse(row.payload_json) as FanInEvidenceSetRecord);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export async function recordRuntimeWorkflowGateDecision(projectRoot: string, decision: WorkflowGateDecision): Promise<void> {
|
|
460
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
461
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
462
|
+
.run(decision.decisionId, decision.inputHash, decision.partition, decision.runId, decision.taskId, decision.decisionKind, decision.status, decision.decidedBy, decision.generatedAt, JSON.stringify(decision));
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export async function listRuntimeWorkflowGateDecisions(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; decisionKind?: WorkflowGateDecisionKind | null } = {}): Promise<WorkflowGateDecision[]> {
|
|
467
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
468
|
+
const clauses: string[] = [];
|
|
469
|
+
const params: string[] = [];
|
|
470
|
+
appendRuntimeScopeClauses(clauses, params, input);
|
|
471
|
+
if (input.decisionKind) {
|
|
472
|
+
clauses.push('decision_kind = ?');
|
|
473
|
+
params.push(input.decisionKind);
|
|
474
|
+
}
|
|
475
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
476
|
+
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 }>;
|
|
477
|
+
return rows.map((row) => JSON.parse(row.payload_json) as WorkflowGateDecision);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
export async function recordRuntimeWorkerRuntime(projectRoot: string, record: ResidentWorkerRuntimeRecord): Promise<void> {
|
|
483
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
484
|
+
db.prepare('INSERT OR REPLACE INTO worker_runtimes (runtime_id, run_id, task_id, status, claimed_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?)')
|
|
485
|
+
.run(record.runtimeId, record.runId, record.taskId, record.status, record.claimedAt, record.updatedAt, JSON.stringify(record));
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export async function readRuntimeWorkerRuntime(projectRoot: string, runId: string, runtimeId: string): Promise<ResidentWorkerRuntimeRecord | null> {
|
|
490
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
491
|
+
const row = db.prepare('SELECT payload_json FROM worker_runtimes WHERE run_id = ? AND runtime_id = ?').get(runId, runtimeId) as { payload_json?: string } | undefined;
|
|
492
|
+
return row?.payload_json ? JSON.parse(row.payload_json) as ResidentWorkerRuntimeRecord : null;
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export async function listRuntimeWorkerRuntimes(projectRoot: string, runId: string): Promise<ResidentWorkerRuntimeRecord[]> {
|
|
497
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
498
|
+
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 }>;
|
|
499
|
+
return rows.map((row) => JSON.parse(row.payload_json) as ResidentWorkerRuntimeRecord);
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
|
|
212
503
|
export async function recordRuntimeActivity(projectRoot: string, entry: InvocationLedgerEntry): Promise<void> {
|
|
213
504
|
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
214
505
|
db.prepare('INSERT OR REPLACE INTO activities (activity_id, run_id, task_id, branch, kind, ref, status, created_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
@@ -232,6 +523,164 @@ export async function recordRuntimeEvidenceAttachment(projectRoot: string, input
|
|
|
232
523
|
});
|
|
233
524
|
}
|
|
234
525
|
|
|
526
|
+
export async function recordRuntimeArtifactPayload(projectRoot: string, input: Omit<RuntimeArtifactPayloadRecord, 'sequence' | 'supersedes' | 'createdAt'> & { sequence?: number; supersedes?: string | null; createdAt?: string }): Promise<RuntimeArtifactPayloadRecord> {
|
|
527
|
+
const createdAt = input.createdAt ?? new Date().toISOString();
|
|
528
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
529
|
+
const sequence = input.sequence ?? nextArtifactPayloadSequence(db, input.branchSlug, input.taskId, input.logicalRef);
|
|
530
|
+
const activePayload = input.status === 'active'
|
|
531
|
+
? 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
|
|
532
|
+
: undefined;
|
|
533
|
+
const supersedes = input.supersedes ?? activePayload?.payload_id ?? null;
|
|
534
|
+
if (input.status === 'active') {
|
|
535
|
+
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 = ?')
|
|
536
|
+
.run('superseded', input.branchSlug, input.taskId, input.taskId, input.logicalRef, 'active');
|
|
537
|
+
}
|
|
538
|
+
const record: RuntimeArtifactPayloadRecord = {
|
|
539
|
+
...input,
|
|
540
|
+
sequence,
|
|
541
|
+
supersedes,
|
|
542
|
+
createdAt
|
|
543
|
+
};
|
|
544
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
545
|
+
.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));
|
|
546
|
+
return record;
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
export async function resolveRuntimeArtifactPayload(projectRoot: string, runId: string, logicalRef: string): Promise<RuntimeArtifactPayloadRecord | null> {
|
|
551
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
552
|
+
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;
|
|
553
|
+
return row ? runtimeArtifactPayloadFromRow(row) : null;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
export async function listRuntimeArtifactPayloads(projectRoot: string, input: { runId?: string | null; branchSlug?: string | null; taskId?: string | null; logicalRef?: string | null; status?: RuntimeArtifactPayloadStatus | null } = {}): Promise<RuntimeArtifactPayloadRecord[]> {
|
|
558
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
559
|
+
const clauses: string[] = [];
|
|
560
|
+
const params: string[] = [];
|
|
561
|
+
if (input.runId) {
|
|
562
|
+
clauses.push('run_id = ?');
|
|
563
|
+
params.push(input.runId);
|
|
564
|
+
}
|
|
565
|
+
if (input.branchSlug) {
|
|
566
|
+
clauses.push('branch_slug = ?');
|
|
567
|
+
params.push(input.branchSlug);
|
|
568
|
+
}
|
|
569
|
+
if (input.taskId) {
|
|
570
|
+
clauses.push('task_id = ?');
|
|
571
|
+
params.push(input.taskId);
|
|
572
|
+
}
|
|
573
|
+
if (input.logicalRef) {
|
|
574
|
+
clauses.push('logical_ref = ?');
|
|
575
|
+
params.push(input.logicalRef);
|
|
576
|
+
}
|
|
577
|
+
if (input.status) {
|
|
578
|
+
clauses.push('status = ?');
|
|
579
|
+
params.push(input.status);
|
|
580
|
+
}
|
|
581
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
582
|
+
const rows = db.prepare(`SELECT * FROM artifact_payloads${where} ORDER BY created_at DESC, sequence DESC`).all(...params) as RuntimeArtifactPayloadRow[];
|
|
583
|
+
return rows.map(runtimeArtifactPayloadFromRow);
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export async function recordRuntimeSyncBackDecision(projectRoot: string, record: RuntimeSyncBackDecisionRecord): Promise<void> {
|
|
588
|
+
const payloadJson = JSON.stringify({ payload: record.payload, reasons: record.reasons });
|
|
589
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
590
|
+
db.prepare('INSERT OR REPLACE INTO sync_back_decisions (decision_id, run_id, branch, task_id, status, proposal_path, proposal_digest, proposal_payload_id, created_at, updated_at, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
591
|
+
.run(record.decisionId, record.runId, record.branch, record.taskId, record.status, record.proposalPath, record.proposalDigest, record.proposalPayloadId, record.createdAt, record.updatedAt, payloadJson);
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
export async function readRuntimeSyncBackDecision(projectRoot: string, runId: string, taskId?: string | null): Promise<RuntimeSyncBackDecisionRecord | null> {
|
|
596
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
597
|
+
const row = taskId
|
|
598
|
+
? db.prepare('SELECT * FROM sync_back_decisions WHERE run_id = ? AND task_id = ? ORDER BY updated_at DESC LIMIT 1').get(runId, taskId)
|
|
599
|
+
: db.prepare('SELECT * FROM sync_back_decisions WHERE run_id = ? ORDER BY updated_at DESC LIMIT 1').get(runId);
|
|
600
|
+
return row ? runtimeSyncBackDecisionFromRow(row as RuntimeSyncBackDecisionRow) : null;
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export async function listRuntimeSyncBackDecisions(projectRoot: string, runId: string): Promise<RuntimeSyncBackDecisionRecord[]> {
|
|
605
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
606
|
+
const rows = db.prepare('SELECT * FROM sync_back_decisions WHERE run_id = ? ORDER BY updated_at DESC, decision_id ASC').all(runId) as RuntimeSyncBackDecisionRow[];
|
|
607
|
+
return rows.map(runtimeSyncBackDecisionFromRow);
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
export async function recordRuntimeDurableGap(projectRoot: string, input: Omit<RuntimeDurableGapRecord, 'createdAt' | 'updatedAt' | 'closedAt'> & { createdAt?: string; updatedAt?: string; closedAt?: string | null }): Promise<RuntimeDurableGapRecord> {
|
|
612
|
+
const createdAt = input.createdAt ?? new Date().toISOString();
|
|
613
|
+
const updatedAt = input.updatedAt ?? createdAt;
|
|
614
|
+
const record: RuntimeDurableGapRecord = {
|
|
615
|
+
...input,
|
|
616
|
+
createdAt,
|
|
617
|
+
updatedAt,
|
|
618
|
+
closedAt: input.closedAt ?? (terminalGapStatus(input.status) ? updatedAt : null)
|
|
619
|
+
};
|
|
620
|
+
assertDurableGapStatusAuthority(record.source, record.status);
|
|
621
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
622
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
623
|
+
.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));
|
|
624
|
+
});
|
|
625
|
+
return record;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
export async function updateRuntimeDurableGapStatus(projectRoot: string, input: { gapId: string; status: RuntimeDurableGapStatus; source: RuntimeDurableGapSource; payload?: unknown; updatedAt?: string }): Promise<RuntimeDurableGapRecord | null> {
|
|
629
|
+
assertDurableGapStatusAuthority(input.source, input.status);
|
|
630
|
+
const updatedAt = input.updatedAt ?? new Date().toISOString();
|
|
631
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
632
|
+
const row = db.prepare('SELECT * FROM durable_gaps WHERE gap_id = ?').get(input.gapId) as RuntimeDurableGapRow | undefined;
|
|
633
|
+
if (!row) {
|
|
634
|
+
return null;
|
|
635
|
+
}
|
|
636
|
+
const existing = runtimeDurableGapFromRow(row);
|
|
637
|
+
const payload = input.payload ?? existing.payload;
|
|
638
|
+
const closedAt = terminalGapStatus(input.status) ? updatedAt : null;
|
|
639
|
+
db.prepare('UPDATE durable_gaps SET status = ?, source = ?, updated_at = ?, closed_at = ?, payload_json = ? WHERE gap_id = ?')
|
|
640
|
+
.run(input.status, input.source, updatedAt, closedAt, JSON.stringify(payload), input.gapId);
|
|
641
|
+
return {
|
|
642
|
+
...existing,
|
|
643
|
+
source: input.source,
|
|
644
|
+
status: input.status,
|
|
645
|
+
updatedAt,
|
|
646
|
+
closedAt,
|
|
647
|
+
payload
|
|
648
|
+
};
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
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[]> {
|
|
653
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
654
|
+
const clauses: string[] = [];
|
|
655
|
+
const params: string[] = [];
|
|
656
|
+
if (input.partition) {
|
|
657
|
+
clauses.push('partition = ?');
|
|
658
|
+
params.push(input.partition);
|
|
659
|
+
}
|
|
660
|
+
if (input.taskId) {
|
|
661
|
+
clauses.push('task_id = ?');
|
|
662
|
+
params.push(input.taskId);
|
|
663
|
+
}
|
|
664
|
+
if (input.runId) {
|
|
665
|
+
clauses.push('run_id = ?');
|
|
666
|
+
params.push(input.runId);
|
|
667
|
+
}
|
|
668
|
+
if (input.status === 'open_terminal') {
|
|
669
|
+
clauses.push("status IN ('open', 'acknowledged')");
|
|
670
|
+
} else if (input.status) {
|
|
671
|
+
clauses.push('status = ?');
|
|
672
|
+
params.push(input.status);
|
|
673
|
+
}
|
|
674
|
+
if (input.severity) {
|
|
675
|
+
clauses.push('severity = ?');
|
|
676
|
+
params.push(input.severity);
|
|
677
|
+
}
|
|
678
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
679
|
+
const rows = db.prepare(`SELECT * FROM durable_gaps${where} ORDER BY updated_at DESC, gap_id ASC`).all(...params) as RuntimeDurableGapRow[];
|
|
680
|
+
return rows.map(runtimeDurableGapFromRow);
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
|
|
235
684
|
export async function recordRuntimeProjection(projectRoot: string, projectionType: string, scopeKey: string, payload: unknown): Promise<void> {
|
|
236
685
|
const now = new Date().toISOString();
|
|
237
686
|
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
@@ -387,6 +836,103 @@ export async function listRuntimeTestRuns(projectRoot: string, runId?: string |
|
|
|
387
836
|
});
|
|
388
837
|
}
|
|
389
838
|
|
|
839
|
+
export async function recordRuntimeValidationEnvironmentSession(projectRoot: string, record: RuntimeValidationEnvironmentSessionRecord): Promise<void> {
|
|
840
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
841
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
842
|
+
.run(record.sessionId, record.partition, record.runId, record.waveRunId, record.status, record.reuseKey, record.createdAt, record.updatedAt, JSON.stringify(record.payload));
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
export async function listRuntimeValidationEnvironmentSessions(projectRoot: string, input: { partition?: string | null; runId?: string | null; waveRunId?: string | null } = {}): Promise<RuntimeValidationEnvironmentSessionRecord[]> {
|
|
847
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
848
|
+
const clauses: string[] = [];
|
|
849
|
+
const params: string[] = [];
|
|
850
|
+
if (input.partition) {
|
|
851
|
+
clauses.push('partition = ?');
|
|
852
|
+
params.push(input.partition);
|
|
853
|
+
}
|
|
854
|
+
if (input.runId) {
|
|
855
|
+
clauses.push('run_id = ?');
|
|
856
|
+
params.push(input.runId);
|
|
857
|
+
}
|
|
858
|
+
if (input.waveRunId) {
|
|
859
|
+
clauses.push('wave_run_id = ?');
|
|
860
|
+
params.push(input.waveRunId);
|
|
861
|
+
}
|
|
862
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
863
|
+
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 }>;
|
|
864
|
+
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) }));
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
export async function recordRuntimeValidationWaveRun(projectRoot: string, record: RuntimeValidationWaveRunRecord): Promise<void> {
|
|
869
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
870
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
871
|
+
.run(record.waveRunId, record.partition, record.runId, JSON.stringify(record.taskIds), record.status, record.environmentSessionId, record.startedAt, record.completedAt, JSON.stringify(record.payload));
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
export async function listRuntimeValidationWaveRuns(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; waveRunId?: string | null } = {}): Promise<RuntimeValidationWaveRunRecord[]> {
|
|
876
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
877
|
+
const clauses: string[] = [];
|
|
878
|
+
const params: string[] = [];
|
|
879
|
+
if (input.partition) {
|
|
880
|
+
clauses.push('partition = ?');
|
|
881
|
+
params.push(input.partition);
|
|
882
|
+
}
|
|
883
|
+
if (input.runId) {
|
|
884
|
+
clauses.push('run_id = ?');
|
|
885
|
+
params.push(input.runId);
|
|
886
|
+
}
|
|
887
|
+
if (input.waveRunId) {
|
|
888
|
+
clauses.push('wave_run_id = ?');
|
|
889
|
+
params.push(input.waveRunId);
|
|
890
|
+
}
|
|
891
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
892
|
+
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 }>;
|
|
893
|
+
return rows
|
|
894
|
+
.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) }))
|
|
895
|
+
.filter((record) => !input.taskId || record.taskIds.includes(input.taskId));
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
export async function recordRuntimeAcceptanceEvidenceMap(projectRoot: string, record: RuntimeAcceptanceEvidenceMapRecord): Promise<void> {
|
|
900
|
+
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
901
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
902
|
+
.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));
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
export async function listRuntimeAcceptanceEvidenceMaps(projectRoot: string, input: { partition?: string | null; runId?: string | null; taskId?: string | null; waveRunId?: string | null; testRunId?: string | null } = {}): Promise<RuntimeAcceptanceEvidenceMapRecord[]> {
|
|
907
|
+
return withRuntimeStore(projectRoot, ({ db }) => {
|
|
908
|
+
const clauses: string[] = [];
|
|
909
|
+
const params: string[] = [];
|
|
910
|
+
if (input.partition) {
|
|
911
|
+
clauses.push('partition = ?');
|
|
912
|
+
params.push(input.partition);
|
|
913
|
+
}
|
|
914
|
+
if (input.runId) {
|
|
915
|
+
clauses.push('run_id = ?');
|
|
916
|
+
params.push(input.runId);
|
|
917
|
+
}
|
|
918
|
+
if (input.taskId) {
|
|
919
|
+
clauses.push('task_id = ?');
|
|
920
|
+
params.push(input.taskId);
|
|
921
|
+
}
|
|
922
|
+
if (input.waveRunId) {
|
|
923
|
+
clauses.push('wave_run_id = ?');
|
|
924
|
+
params.push(input.waveRunId);
|
|
925
|
+
}
|
|
926
|
+
if (input.testRunId) {
|
|
927
|
+
clauses.push('test_run_id = ?');
|
|
928
|
+
params.push(input.testRunId);
|
|
929
|
+
}
|
|
930
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '';
|
|
931
|
+
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 }>;
|
|
932
|
+
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) }));
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
|
|
390
936
|
export async function recordLegacyImportFailure(projectRoot: string, runId: string, entityType: string, error: unknown): Promise<void> {
|
|
391
937
|
try {
|
|
392
938
|
await withRuntimeStore(projectRoot, ({ db }) => {
|
|
@@ -434,6 +980,140 @@ export async function inspectRuntimeStoreEvidence(projectRoot: string): Promise<
|
|
|
434
980
|
}
|
|
435
981
|
}
|
|
436
982
|
|
|
983
|
+
interface RuntimeArtifactPayloadRow {
|
|
984
|
+
payload_id: string;
|
|
985
|
+
run_id: string;
|
|
986
|
+
source_run_id: string;
|
|
987
|
+
branch_slug: string;
|
|
988
|
+
task_id: string | null;
|
|
989
|
+
logical_ref: string;
|
|
990
|
+
physical_payload_path: string;
|
|
991
|
+
artifact_role: string;
|
|
992
|
+
digest: string;
|
|
993
|
+
sequence: number;
|
|
994
|
+
status: RuntimeArtifactPayloadStatus;
|
|
995
|
+
supersedes: string | null;
|
|
996
|
+
created_at: string;
|
|
997
|
+
payload_json: string;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
function nextArtifactPayloadSequence(db: RuntimeStoreDatabase, branchSlug: string, taskId: string | null, logicalRef: string): number {
|
|
1001
|
+
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;
|
|
1002
|
+
return (row?.sequence ?? 0) + 1;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
function runtimeArtifactPayloadFromRow(row: RuntimeArtifactPayloadRow): RuntimeArtifactPayloadRecord {
|
|
1006
|
+
return {
|
|
1007
|
+
payloadId: row.payload_id,
|
|
1008
|
+
runId: row.run_id,
|
|
1009
|
+
sourceRunId: row.source_run_id,
|
|
1010
|
+
branchSlug: row.branch_slug,
|
|
1011
|
+
taskId: row.task_id,
|
|
1012
|
+
logicalRef: row.logical_ref,
|
|
1013
|
+
physicalPayloadPath: row.physical_payload_path,
|
|
1014
|
+
artifactRole: row.artifact_role,
|
|
1015
|
+
digest: row.digest,
|
|
1016
|
+
sequence: row.sequence,
|
|
1017
|
+
status: row.status,
|
|
1018
|
+
supersedes: row.supersedes,
|
|
1019
|
+
createdAt: row.created_at,
|
|
1020
|
+
payload: JSON.parse(row.payload_json)
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
interface RuntimeSyncBackDecisionRow {
|
|
1025
|
+
decision_id: string;
|
|
1026
|
+
run_id: string;
|
|
1027
|
+
branch: string;
|
|
1028
|
+
task_id: string | null;
|
|
1029
|
+
status: string;
|
|
1030
|
+
proposal_path: string | null;
|
|
1031
|
+
proposal_digest: string | null;
|
|
1032
|
+
proposal_payload_id: string | null;
|
|
1033
|
+
created_at: string;
|
|
1034
|
+
updated_at: string;
|
|
1035
|
+
payload_json: string;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
function runtimeSyncBackDecisionFromRow(row: RuntimeSyncBackDecisionRow): RuntimeSyncBackDecisionRecord {
|
|
1039
|
+
const parsed = JSON.parse(row.payload_json) as { payload?: unknown; reasons?: unknown };
|
|
1040
|
+
return {
|
|
1041
|
+
decisionId: row.decision_id,
|
|
1042
|
+
runId: row.run_id,
|
|
1043
|
+
branch: row.branch,
|
|
1044
|
+
taskId: row.task_id,
|
|
1045
|
+
status: row.status,
|
|
1046
|
+
proposalPath: row.proposal_path,
|
|
1047
|
+
proposalDigest: row.proposal_digest,
|
|
1048
|
+
proposalPayloadId: row.proposal_payload_id,
|
|
1049
|
+
reasons: Array.isArray(parsed.reasons) ? parsed.reasons.filter((reason): reason is string => typeof reason === 'string') : [],
|
|
1050
|
+
createdAt: row.created_at,
|
|
1051
|
+
updatedAt: row.updated_at,
|
|
1052
|
+
payload: parsed.payload ?? null
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
interface RuntimeDurableGapRow {
|
|
1057
|
+
gap_id: string;
|
|
1058
|
+
partition: string;
|
|
1059
|
+
task_id: string | null;
|
|
1060
|
+
run_id: string | null;
|
|
1061
|
+
stage: string | null;
|
|
1062
|
+
gate_name: string | null;
|
|
1063
|
+
source: RuntimeDurableGapSource;
|
|
1064
|
+
category: string;
|
|
1065
|
+
severity: RuntimeDurableGapSeverity;
|
|
1066
|
+
status: RuntimeDurableGapStatus;
|
|
1067
|
+
message: string;
|
|
1068
|
+
recommendation: string | null;
|
|
1069
|
+
evidence_refs_json: string;
|
|
1070
|
+
proposal_refs_json: string;
|
|
1071
|
+
source_refs_json: string;
|
|
1072
|
+
created_at: string;
|
|
1073
|
+
updated_at: string;
|
|
1074
|
+
closed_at: string | null;
|
|
1075
|
+
payload_json: string;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
function runtimeDurableGapFromRow(row: RuntimeDurableGapRow): RuntimeDurableGapRecord {
|
|
1079
|
+
return {
|
|
1080
|
+
gapId: row.gap_id,
|
|
1081
|
+
partition: row.partition,
|
|
1082
|
+
taskId: row.task_id,
|
|
1083
|
+
runId: row.run_id,
|
|
1084
|
+
stage: row.stage,
|
|
1085
|
+
gate: row.gate_name,
|
|
1086
|
+
source: row.source,
|
|
1087
|
+
category: row.category,
|
|
1088
|
+
severity: row.severity,
|
|
1089
|
+
status: row.status,
|
|
1090
|
+
message: row.message,
|
|
1091
|
+
recommendation: row.recommendation,
|
|
1092
|
+
evidenceRefs: parseStringList(row.evidence_refs_json),
|
|
1093
|
+
proposalRefs: parseStringList(row.proposal_refs_json),
|
|
1094
|
+
sourceRefs: parseStringList(row.source_refs_json),
|
|
1095
|
+
createdAt: row.created_at,
|
|
1096
|
+
updatedAt: row.updated_at,
|
|
1097
|
+
closedAt: row.closed_at,
|
|
1098
|
+
payload: JSON.parse(row.payload_json)
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
function assertDurableGapStatusAuthority(source: RuntimeDurableGapSource, status: RuntimeDurableGapStatus): void {
|
|
1103
|
+
if (terminalGapStatus(status) && source !== 'runtime' && source !== 'gate_policy' && source !== 'doctor') {
|
|
1104
|
+
throw new Error(`Durable gap terminal status ${status} cannot be written by ${source}.`);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
function terminalGapStatus(status: RuntimeDurableGapStatus): boolean {
|
|
1109
|
+
return status === 'resolved' || status === 'waived' || status === 'superseded';
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
function parseStringList(raw: string): string[] {
|
|
1113
|
+
const parsed = JSON.parse(raw) as unknown;
|
|
1114
|
+
return Array.isArray(parsed) ? parsed.filter((item): item is string => typeof item === 'string') : [];
|
|
1115
|
+
}
|
|
1116
|
+
|
|
437
1117
|
interface RuntimeProjectionRow {
|
|
438
1118
|
projection_type: string;
|
|
439
1119
|
scope_key: string;
|
|
@@ -463,6 +1143,21 @@ function asRuntimeProjectionEnvelope<TPayload>(payload: unknown): RuntimeProject
|
|
|
463
1143
|
return candidate.contract === RUNTIME_PROJECTION_ENVELOPE_CONTRACT_VERSION ? candidate as RuntimeProjectionEnvelope<TPayload> : null;
|
|
464
1144
|
}
|
|
465
1145
|
|
|
1146
|
+
function appendRuntimeScopeClauses(clauses: string[], params: string[], input: { partition?: string | null; runId?: string | null; taskId?: string | null }): void {
|
|
1147
|
+
if (input.partition) {
|
|
1148
|
+
clauses.push('partition = ?');
|
|
1149
|
+
params.push(input.partition);
|
|
1150
|
+
}
|
|
1151
|
+
if (input.runId) {
|
|
1152
|
+
clauses.push('run_id = ?');
|
|
1153
|
+
params.push(input.runId);
|
|
1154
|
+
}
|
|
1155
|
+
if (input.taskId) {
|
|
1156
|
+
clauses.push('task_id = ?');
|
|
1157
|
+
params.push(input.taskId);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
|
|
466
1161
|
export function runtimeScopedId(...parts: string[]): string {
|
|
467
1162
|
return createHash('sha256').update(parts.join('\0'), 'utf8').digest('hex').slice(0, 32);
|
|
468
1163
|
}
|