@sema-agent/server 1.323.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/approval-hmac.d.ts +40 -0
- package/dist/approval-hmac.js +67 -0
- package/dist/approval.d.ts +31 -0
- package/dist/approval.js +72 -4
- package/dist/audit.d.ts +26 -0
- package/dist/audit.js +40 -1
- package/dist/auth-bridge.d.ts +10 -0
- package/dist/auth-bridge.js +47 -4
- package/dist/auth-keys.d.ts +19 -0
- package/dist/auth-keys.js +13 -0
- package/dist/bake-runner/main.d.ts +5 -0
- package/dist/bake-runner/main.js +43 -4
- package/dist/bake-runner/protocol.d.ts +57 -0
- package/dist/bake-runner/protocol.js +58 -3
- package/dist/bake-runner/runner.d.ts +54 -0
- package/dist/bake-runner/runner.js +87 -5
- package/dist/bench/l8/artifact.d.ts +63 -0
- package/dist/bench/l8/artifact.js +61 -2
- package/dist/bench/l8/escape.d.ts +36 -0
- package/dist/bench/l8/escape.js +25 -0
- package/dist/bench/l8/index.d.ts +14 -0
- package/dist/bench/l8/index.js +14 -0
- package/dist/bench/l8/probes.d.ts +74 -0
- package/dist/bench/l8/probes.js +60 -0
- package/dist/bench/l8/run-probes.d.ts +43 -0
- package/dist/bench/l8/run-probes.js +45 -2
- package/dist/bench/s1/arms.d.ts +126 -0
- package/dist/bench/s1/arms.js +188 -13
- package/dist/bench/s1/live-deps.d.ts +66 -0
- package/dist/bench/s1/live-deps.js +249 -11
- package/dist/bench/s1/oracle.d.ts +49 -0
- package/dist/bench/s1/oracle.js +36 -1
- package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
- package/dist/bench/s1/repair-oracle-adapter.js +30 -0
- package/dist/bench/s1/reviewer.d.ts +38 -0
- package/dist/bench/s1/reviewer.js +34 -0
- package/dist/bench/s1/row.d.ts +77 -0
- package/dist/bench/s1/row.js +62 -0
- package/dist/bench/s1/run-firm.d.ts +47 -0
- package/dist/bench/s1/run-firm.js +70 -4
- package/dist/bench/s1/runner-ctx.d.ts +71 -0
- package/dist/bench/s1/runner-ctx.js +36 -0
- package/dist/bench/s1/tasks.d.ts +108 -0
- package/dist/bench/s1/tasks.js +115 -0
- package/dist/boot-reclaim.d.ts +19 -0
- package/dist/boot-reclaim.js +20 -0
- package/dist/brain.d.ts +25 -0
- package/dist/brain.js +61 -1
- package/dist/budget.d.ts +66 -0
- package/dist/budget.js +128 -4
- package/dist/capabilities/builtin-tools.d.ts +3 -0
- package/dist/capabilities/builtin-tools.js +3 -0
- package/dist/capabilities/center-plugins.d.ts +17 -1
- package/dist/capabilities/center-plugins.js +45 -4
- package/dist/capabilities/center-prompts.d.ts +46 -0
- package/dist/capabilities/center-prompts.js +57 -3
- package/dist/capabilities/code-review-council.d.ts +28 -0
- package/dist/capabilities/code-review-council.js +40 -7
- package/dist/capabilities/collab-wire.d.ts +2 -0
- package/dist/capabilities/collab-workflows.d.ts +7 -0
- package/dist/capabilities/collab-workflows.js +44 -1
- package/dist/capabilities/oa-tools.d.ts +6 -0
- package/dist/capabilities/oa-tools.js +10 -0
- package/dist/capabilities/prompt.d.ts +14 -0
- package/dist/capabilities/prompt.js +14 -0
- package/dist/capabilities/prompts/code-review.d.ts +14 -0
- package/dist/capabilities/prompts/code-review.js +14 -0
- package/dist/capabilities/prompts/identity.d.ts +6 -0
- package/dist/capabilities/prompts/identity.js +6 -0
- package/dist/capabilities/prompts/team.d.ts +4 -0
- package/dist/capabilities/prompts/team.js +4 -0
- package/dist/capabilities/repo-tools.d.ts +11 -0
- package/dist/capabilities/repo-tools.js +8 -0
- package/dist/capabilities/sandbox-file-send.d.ts +95 -0
- package/dist/capabilities/sandbox-file-send.js +91 -3
- package/dist/capabilities/scenarios.d.ts +130 -0
- package/dist/capabilities/scenarios.js +180 -7
- package/dist/capabilities/select-environment-tool.d.ts +7 -0
- package/dist/capabilities/select-environment-tool.js +30 -0
- package/dist/capabilities/send-user-file-tool.d.ts +33 -0
- package/dist/capabilities/send-user-file-tool.js +65 -1
- package/dist/capabilities/skills.d.ts +29 -0
- package/dist/capabilities/skills.js +13 -2
- package/dist/capabilities/team.d.ts +22 -0
- package/dist/capabilities/team.js +22 -2
- package/dist/capabilities/tool-defer.d.ts +26 -0
- package/dist/capabilities/tool-defer.js +3 -0
- package/dist/config-center/apply-effective.d.ts +65 -0
- package/dist/config-center/apply-effective.js +204 -12
- package/dist/config-center/http-client.d.ts +34 -0
- package/dist/config-center/http-client.js +68 -0
- package/dist/config-center/restart-signal.d.ts +22 -0
- package/dist/config-center/restart-signal.js +39 -0
- package/dist/config-center/skills-mcp.d.ts +20 -1
- package/dist/config-center/skills-mcp.js +42 -7
- package/dist/config-center/types.d.ts +92 -1
- package/dist/config-lkg.d.ts +12 -0
- package/dist/config-lkg.js +41 -0
- package/dist/config-provider.d.ts +78 -0
- package/dist/config-provider.js +165 -2
- package/dist/config-types.d.ts +546 -0
- package/dist/config.d.ts +64 -0
- package/dist/config.js +455 -60
- package/dist/degenerate-instrument.d.ts +38 -0
- package/dist/degenerate-instrument.js +55 -3
- package/dist/elicitation.d.ts +39 -0
- package/dist/elicitation.js +87 -3
- package/dist/env-facts.d.ts +61 -0
- package/dist/env-facts.js +73 -7
- package/dist/fleet/fleet-bus.d.ts +185 -0
- package/dist/fleet/fleet-bus.js +333 -27
- package/dist/fleet/subagent-tail-bus.d.ts +11 -0
- package/dist/fleet/subagent-tail-bus.js +33 -2
- package/dist/fleet-client.d.ts +38 -0
- package/dist/fleet-client.js +44 -9
- package/dist/fleet-lease.d.ts +46 -0
- package/dist/fleet-lease.js +73 -5
- package/dist/hooks/branch-transcript.d.ts +8 -0
- package/dist/hooks/branch-transcript.js +33 -0
- package/dist/hooks/cc-stop-prompt.d.ts +42 -0
- package/dist/hooks/cc-stop-prompt.js +43 -1
- package/dist/hooks/hook-llm.d.ts +15 -0
- package/dist/hooks/hook-llm.js +47 -0
- package/dist/hooks/hook-runner.d.ts +89 -0
- package/dist/hooks/hook-runner.js +327 -18
- package/dist/http/idempotency.d.ts +31 -0
- package/dist/http/idempotency.js +34 -0
- package/dist/http/principal-gate.d.ts +17 -0
- package/dist/http/principal-gate.js +35 -3
- package/dist/http/route-ctx.d.ts +36 -0
- package/dist/http/routes/approvals-assistant.d.ts +25 -0
- package/dist/http/routes/approvals-assistant.js +253 -23
- package/dist/http/routes/attachments.js +22 -4
- package/dist/http/routes/capabilities.d.ts +7 -0
- package/dist/http/routes/capabilities.js +202 -1
- package/dist/http/routes/fleet.d.ts +6 -0
- package/dist/http/routes/fleet.js +94 -5
- package/dist/http/routes/images.d.ts +17 -0
- package/dist/http/routes/images.js +222 -14
- package/dist/http/routes/leader.d.ts +7 -0
- package/dist/http/routes/leader.js +10 -0
- package/dist/http/routes/memory-policy.d.ts +6 -0
- package/dist/http/routes/memory-policy.js +38 -6
- package/dist/http/routes/notify-wake.d.ts +10 -0
- package/dist/http/routes/notify-wake.js +19 -3
- package/dist/http/routes/observability.d.ts +6 -0
- package/dist/http/routes/observability.js +19 -2
- package/dist/http/routes/runs.d.ts +15 -0
- package/dist/http/routes/runs.js +464 -41
- package/dist/http/routes/session-sync.d.ts +15 -0
- package/dist/http/routes/session-sync.js +229 -19
- package/dist/http/routes/sessions-list.d.ts +6 -0
- package/dist/http/routes/sessions-list.js +35 -4
- package/dist/http/routes/sessions.d.ts +14 -0
- package/dist/http/routes/sessions.js +176 -31
- package/dist/http/routes/side-query.d.ts +8 -0
- package/dist/http/routes/side-query.js +26 -1
- package/dist/http/routes/tasks.d.ts +18 -0
- package/dist/http/routes/tasks.js +501 -38
- package/dist/http/routes/trace-usage.d.ts +10 -0
- package/dist/http/routes/trace-usage.js +66 -14
- package/dist/http/routes/workflows.d.ts +12 -0
- package/dist/http/routes/workflows.js +180 -19
- package/dist/http/run-meta.d.ts +11 -0
- package/dist/http/run-meta.js +6 -0
- package/dist/http/send.d.ts +19 -0
- package/dist/http/send.js +11 -0
- package/dist/http/server.d.ts +255 -0
- package/dist/http/server.js +921 -75
- package/dist/http/sse-log.d.ts +15 -0
- package/dist/http/sse-log.js +16 -0
- package/dist/http/tar.d.ts +9 -0
- package/dist/http/tar.js +21 -5
- package/dist/http/wire-gate.d.ts +9 -0
- package/dist/http/wire-gate.js +9 -0
- package/dist/http/wire-types.d.ts +187 -0
- package/dist/http/workspace-content.d.ts +8 -0
- package/dist/http/workspace-content.js +10 -0
- package/dist/images/bake-validate.d.ts +63 -0
- package/dist/images/bake-validate.js +71 -1
- package/dist/images/manifest.d.ts +19 -0
- package/dist/images/manifest.js +6 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +10 -5
- package/dist/key-resolver.d.ts +23 -0
- package/dist/key-resolver.js +27 -2
- package/dist/leader/diffout.d.ts +23 -0
- package/dist/leader/diffout.js +8 -1
- package/dist/leader/diffup.d.ts +32 -0
- package/dist/leader/diffup.js +43 -0
- package/dist/leader/endpoint.d.ts +20 -0
- package/dist/leader/endpoint.js +25 -2
- package/dist/leader/fanout.d.ts +60 -0
- package/dist/leader/fanout.js +29 -3
- package/dist/leader/grader-env-factory.d.ts +74 -0
- package/dist/leader/grader-env-factory.js +62 -3
- package/dist/leader/leader.d.ts +97 -0
- package/dist/leader/leader.js +151 -4
- package/dist/leader/merge.d.ts +94 -0
- package/dist/leader/merge.js +112 -9
- package/dist/leader/planner.d.ts +52 -0
- package/dist/leader/planner.js +47 -3
- package/dist/leader/repair-oracle.d.ts +61 -0
- package/dist/leader/repair-oracle.js +59 -1
- package/dist/leader/repair-wire.d.ts +78 -0
- package/dist/leader/repair-wire.js +79 -2
- package/dist/leader/wire.d.ts +79 -0
- package/dist/leader/wire.js +255 -8
- package/dist/lsp/e2b-bridge.d.ts +16 -0
- package/dist/lsp/e2b-bridge.js +32 -4
- package/dist/lsp/e2b-manager.d.ts +10 -0
- package/dist/lsp/e2b-manager.js +18 -2
- package/dist/lsp/lsp-frames.d.ts +12 -0
- package/dist/lsp/lsp-frames.js +12 -0
- package/dist/lsp/manager.d.ts +12 -0
- package/dist/lsp/manager.js +35 -2
- package/dist/lsp/types.d.ts +10 -0
- package/dist/lsp/ws-transport.d.ts +12 -0
- package/dist/lsp/ws-transport.js +53 -5
- package/dist/lsp-evict.d.ts +14 -0
- package/dist/lsp-evict.js +15 -1
- package/dist/main.js +2132 -96
- package/dist/memory-export.d.ts +1 -0
- package/dist/memory-export.js +4 -0
- package/dist/memory-scope.d.ts +49 -0
- package/dist/memory-scope.js +87 -4
- package/dist/memory-sync-client.d.ts +24 -0
- package/dist/memory-sync-client.js +41 -2
- package/dist/memory-sync.d.ts +23 -0
- package/dist/memory-sync.js +70 -1
- package/dist/model-select.d.ts +39 -0
- package/dist/model-select.js +42 -1
- package/dist/observability/cost-quota.d.ts +20 -0
- package/dist/observability/cost-quota.js +4 -0
- package/dist/observability/cost-taxonomy.d.ts +45 -0
- package/dist/observability/cost-taxonomy.js +34 -0
- package/dist/observability/logger.d.ts +1 -0
- package/dist/observability/logger.js +6 -0
- package/dist/observability/metrics.d.ts +13 -0
- package/dist/observability/metrics.js +63 -0
- package/dist/observability/otel-exporter.d.ts +9 -0
- package/dist/observability/otel-exporter.js +11 -3
- package/dist/observability/principal-context.d.ts +9 -0
- package/dist/observability/principal-context.js +9 -0
- package/dist/observability/prompt-manifest.d.ts +37 -0
- package/dist/observability/prompt-manifest.js +35 -1
- package/dist/observability/rate-limit.d.ts +10 -0
- package/dist/observability/rate-limit.js +1 -0
- package/dist/observability/tool-trace.d.ts +24 -0
- package/dist/observability/tool-trace.js +41 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
- package/dist/orchestration/hardened-vm-runner.js +119 -4
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
- package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
- package/dist/orchestration/hardened-vm-worker.js +27 -0
- package/dist/orchestration/subagent-steer.d.ts +44 -0
- package/dist/orchestration/subagent-steer.js +45 -1
- package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
- package/dist/orchestration/workflow-agent-steer.js +80 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
- package/dist/orchestration/workflow-completion-inbox.js +283 -32
- package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
- package/dist/orchestration/workflow-notify-journal.js +187 -13
- package/dist/parked-decide.d.ts +61 -0
- package/dist/parked-decide.js +58 -1
- package/dist/per-task-image.d.ts +54 -0
- package/dist/per-task-image.js +41 -0
- package/dist/plan-cache-probe.d.ts +35 -0
- package/dist/plan-cache-probe.js +18 -3
- package/dist/plugins/approval-exemption-store.d.ts +7 -0
- package/dist/plugins/approval-exemption-store.js +28 -2
- package/dist/plugins/approval-store-sql.d.ts +64 -0
- package/dist/plugins/approval-store-sql.js +32 -0
- package/dist/plugins/background-agent-store-sql.d.ts +55 -0
- package/dist/plugins/background-agent-store-sql.js +91 -4
- package/dist/plugins/background-shell-support.d.ts +98 -0
- package/dist/plugins/background-shell-support.js +117 -13
- package/dist/plugins/blob-backend.d.ts +104 -0
- package/dist/plugins/blob-backend.js +163 -6
- package/dist/plugins/breaker-state-sql.d.ts +65 -1
- package/dist/plugins/breaker-state-sql.js +46 -8
- package/dist/plugins/caching-session-store.d.ts +42 -0
- package/dist/plugins/caching-session-store.js +63 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
- package/dist/plugins/checkpoint-store-sql.js +239 -11
- package/dist/plugins/file-outcome-sink.d.ts +4 -0
- package/dist/plugins/file-outcome-sink.js +9 -0
- package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
- package/dist/plugins/file-resume-anchor-store.js +43 -4
- package/dist/plugins/file-run-store.d.ts +90 -0
- package/dist/plugins/file-run-store.js +145 -13
- package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
- package/dist/plugins/file-snapshot-store-sql.js +178 -10
- package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
- package/dist/plugins/file-workflow-journal-store.js +10 -0
- package/dist/plugins/fork-routing-session-store.d.ts +47 -0
- package/dist/plugins/fork-routing-session-store.js +51 -3
- package/dist/plugins/host-platform.d.ts +69 -0
- package/dist/plugins/host-platform.js +81 -2
- package/dist/plugins/image-bake-store-sql.d.ts +136 -1
- package/dist/plugins/image-bake-store-sql.js +241 -7
- package/dist/plugins/image-index-sql.d.ts +46 -0
- package/dist/plugins/image-index-sql.js +113 -4
- package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
- package/dist/plugins/k8s-bg-scripts.js +88 -4
- package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
- package/dist/plugins/k8s-exec-protocol.js +41 -0
- package/dist/plugins/local-checkpoint-store.d.ts +40 -0
- package/dist/plugins/local-checkpoint-store.js +86 -7
- package/dist/plugins/local-session-store.d.ts +157 -0
- package/dist/plugins/local-session-store.js +289 -34
- package/dist/plugins/local-task-attachment-store.js +14 -2
- package/dist/plugins/mailbox-store-sql.d.ts +38 -0
- package/dist/plugins/mailbox-store-sql.js +39 -6
- package/dist/plugins/memory-engine-pg.d.ts +30 -0
- package/dist/plugins/memory-engine-pg.js +122 -4
- package/dist/plugins/memory-engine-tidb.d.ts +26 -0
- package/dist/plugins/memory-engine-tidb.js +115 -5
- package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
- package/dist/plugins/memory-engine-vector-util.js +5 -0
- package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
- package/dist/plugins/memory-resume-anchor-store.js +17 -0
- package/dist/plugins/memory-run-store.d.ts +63 -0
- package/dist/plugins/memory-run-store.js +73 -8
- package/dist/plugins/memory-session-policy-store.d.ts +17 -0
- package/dist/plugins/memory-session-policy-store.js +17 -0
- package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
- package/dist/plugins/memory-sync-store-pg.js +45 -2
- package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
- package/dist/plugins/memory-sync-store-tidb.js +31 -1
- package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
- package/dist/plugins/outcome-ledger-sql.js +97 -3
- package/dist/plugins/pg-approval-store.d.ts +7 -0
- package/dist/plugins/pg-approval-store.js +7 -0
- package/dist/plugins/pg-breaker-state.d.ts +6 -0
- package/dist/plugins/pg-breaker-state.js +6 -0
- package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
- package/dist/plugins/pg-checkpoint-store.js +8 -0
- package/dist/plugins/pg-cost-quota.d.ts +17 -0
- package/dist/plugins/pg-cost-quota.js +6 -0
- package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/pg-file-snapshot-store.js +6 -0
- package/dist/plugins/pg-image-bake.d.ts +9 -0
- package/dist/plugins/pg-image-bake.js +9 -0
- package/dist/plugins/pg-image-index.d.ts +9 -0
- package/dist/plugins/pg-image-index.js +9 -0
- package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
- package/dist/plugins/pg-outcome-ledger.js +9 -0
- package/dist/plugins/pg-pool.d.ts +50 -0
- package/dist/plugins/pg-pool.js +78 -0
- package/dist/plugins/pg-query.d.ts +11 -0
- package/dist/plugins/pg-rate-limiter.d.ts +23 -0
- package/dist/plugins/pg-rate-limiter.js +12 -2
- package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/pg-resume-anchor-store.js +5 -0
- package/dist/plugins/pg-run-store.d.ts +7 -0
- package/dist/plugins/pg-run-store.js +7 -0
- package/dist/plugins/pg-safe-json.d.ts +13 -0
- package/dist/plugins/pg-safe-json.js +40 -4
- package/dist/plugins/pg-session-policy-store.d.ts +5 -0
- package/dist/plugins/pg-session-policy-store.js +5 -0
- package/dist/plugins/pg-session-storage.d.ts +72 -0
- package/dist/plugins/pg-session-storage.js +152 -20
- package/dist/plugins/pg-session-store.d.ts +10 -0
- package/dist/plugins/pg-session-store.js +10 -0
- package/dist/plugins/pg-tool-result-store.d.ts +7 -0
- package/dist/plugins/pg-tool-result-store.js +7 -0
- package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-journal-store.js +7 -0
- package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-run-store.js +7 -0
- package/dist/plugins/posix-shell-fs.d.ts +3 -0
- package/dist/plugins/posix-shell-fs.js +31 -1
- package/dist/plugins/remote-env-adb.d.ts +25 -0
- package/dist/plugins/remote-env-adb.js +95 -12
- package/dist/plugins/remote-env-e2b.d.ts +146 -0
- package/dist/plugins/remote-env-e2b.js +371 -40
- package/dist/plugins/remote-env-file-error.d.ts +34 -0
- package/dist/plugins/remote-env-file-error.js +37 -0
- package/dist/plugins/remote-env-host.d.ts +151 -0
- package/dist/plugins/remote-env-host.js +468 -70
- package/dist/plugins/remote-env-k8s.d.ts +135 -0
- package/dist/plugins/remote-env-k8s.js +318 -32
- package/dist/plugins/remote-env-local-docker.d.ts +65 -0
- package/dist/plugins/remote-env-local-docker.js +149 -24
- package/dist/plugins/remote-env-ssh.d.ts +35 -0
- package/dist/plugins/remote-env-ssh.js +117 -20
- package/dist/plugins/remote-scratchpad.d.ts +38 -0
- package/dist/plugins/remote-scratchpad.js +32 -2
- package/dist/plugins/remote-shell.d.ts +22 -0
- package/dist/plugins/remote-shell.js +27 -1
- package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
- package/dist/plugins/resume-anchor-store-sql.js +11 -0
- package/dist/plugins/roster-store-sql.d.ts +27 -0
- package/dist/plugins/roster-store-sql.js +54 -0
- package/dist/plugins/run-store-sql.d.ts +194 -0
- package/dist/plugins/run-store-sql.js +210 -9
- package/dist/plugins/s3-presign.d.ts +20 -0
- package/dist/plugins/s3-presign.js +49 -2
- package/dist/plugins/scheduler-support.d.ts +12 -0
- package/dist/plugins/scheduler-support.js +75 -3
- package/dist/plugins/send-file-ledger.d.ts +15 -0
- package/dist/plugins/send-file-ledger.js +53 -4
- package/dist/plugins/send-user-file.d.ts +77 -0
- package/dist/plugins/send-user-file.js +92 -4
- package/dist/plugins/session-policy-store-sql.d.ts +15 -0
- package/dist/plugins/session-policy-store-sql.js +75 -3
- package/dist/plugins/session-store.d.ts +45 -0
- package/dist/plugins/session-store.js +51 -0
- package/dist/plugins/sql-driver.d.ts +77 -0
- package/dist/plugins/sql-driver.js +4 -0
- package/dist/plugins/sql-escape.d.ts +8 -0
- package/dist/plugins/sql-escape.js +8 -0
- package/dist/plugins/sql-row-helpers.d.ts +25 -0
- package/dist/plugins/sql-row-helpers.js +25 -0
- package/dist/plugins/store-backend.d.ts +103 -0
- package/dist/plugins/store-backend.js +120 -27
- package/dist/plugins/store-contracts.d.ts +62 -0
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/task-attachment-store.d.ts +60 -0
- package/dist/plugins/task-attachment-store.js +49 -3
- package/dist/plugins/task-list-store-sql.d.ts +25 -0
- package/dist/plugins/task-list-store-sql.js +21 -0
- package/dist/plugins/tidb-approval-store.d.ts +6 -0
- package/dist/plugins/tidb-approval-store.js +6 -0
- package/dist/plugins/tidb-breaker-state.d.ts +5 -0
- package/dist/plugins/tidb-breaker-state.js +5 -0
- package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
- package/dist/plugins/tidb-checkpoint-store.js +7 -0
- package/dist/plugins/tidb-cost-quota.d.ts +6 -0
- package/dist/plugins/tidb-cost-quota.js +1 -0
- package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/tidb-file-snapshot-store.js +6 -0
- package/dist/plugins/tidb-image-bake.d.ts +8 -0
- package/dist/plugins/tidb-image-bake.js +8 -0
- package/dist/plugins/tidb-image-index.d.ts +8 -0
- package/dist/plugins/tidb-image-index.js +8 -0
- package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
- package/dist/plugins/tidb-outcome-ledger.js +10 -0
- package/dist/plugins/tidb-pool.d.ts +56 -0
- package/dist/plugins/tidb-pool.js +181 -1
- package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
- package/dist/plugins/tidb-rate-limiter.js +5 -2
- package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/tidb-resume-anchor-store.js +5 -0
- package/dist/plugins/tidb-run-store.d.ts +7 -0
- package/dist/plugins/tidb-run-store.js +7 -0
- package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
- package/dist/plugins/tidb-session-policy-store.js +5 -0
- package/dist/plugins/tidb-session-storage.d.ts +43 -0
- package/dist/plugins/tidb-session-storage.js +62 -3
- package/dist/plugins/tidb-session-store.d.ts +142 -0
- package/dist/plugins/tidb-session-store.js +264 -16
- package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
- package/dist/plugins/tidb-tool-result-store.js +7 -0
- package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/tidb-workflow-journal-store.js +7 -0
- package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
- package/dist/plugins/tidb-workflow-run-store.js +8 -0
- package/dist/plugins/tool-result-store-sql.d.ts +58 -0
- package/dist/plugins/tool-result-store-sql.js +38 -2
- package/dist/plugins/web-search.d.ts +35 -0
- package/dist/plugins/web-search.js +45 -9
- package/dist/plugins/workflow-journal-limits.d.ts +10 -0
- package/dist/plugins/workflow-journal-limits.js +10 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
- package/dist/plugins/workflow-journal-store-sql.js +58 -2
- package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
- package/dist/plugins/workflow-run-store-sql.js +84 -6
- package/dist/plugins/worktree-isolation.d.ts +45 -0
- package/dist/plugins/worktree-isolation.js +105 -6
- package/dist/plugins/write-behind-counter.d.ts +56 -1
- package/dist/plugins/write-behind-counter.js +53 -14
- package/dist/principal-jwt.d.ts +24 -0
- package/dist/principal-jwt.js +60 -5
- package/dist/project-memory.d.ts +22 -0
- package/dist/project-memory.js +144 -15
- package/dist/prompts-domain-validate.d.ts +28 -0
- package/dist/prompts-domain-validate.js +42 -1
- package/dist/question.d.ts +33 -0
- package/dist/question.js +69 -2
- package/dist/resource-suspend.d.ts +21 -0
- package/dist/resource-suspend.js +16 -0
- package/dist/router/route-orchestration.d.ts +78 -0
- package/dist/router/route-orchestration.js +77 -0
- package/dist/run-local.d.ts +32 -0
- package/dist/run-local.js +172 -8
- package/dist/runs.d.ts +189 -4
- package/dist/runs.js +465 -24
- package/dist/runtime-caps-resolver.d.ts +106 -0
- package/dist/runtime-caps-resolver.js +89 -4
- package/dist/runtime-governance.d.ts +84 -0
- package/dist/runtime-governance.js +127 -1
- package/dist/sandbox-pkg-source.d.ts +23 -0
- package/dist/sandbox-pkg-source.js +37 -0
- package/dist/sealed-key.d.ts +54 -0
- package/dist/sealed-key.js +68 -3
- package/dist/security.d.ts +108 -0
- package/dist/security.js +145 -6
- package/dist/sema-registry.d.ts +21 -0
- package/dist/sema-registry.js +21 -0
- package/dist/session-leaf-bus.d.ts +31 -0
- package/dist/session-leaf-bus.js +32 -0
- package/dist/session-sync-content.d.ts +46 -0
- package/dist/session-sync-content.js +47 -1
- package/dist/session-sync-kernel.d.ts +89 -0
- package/dist/session-sync-kernel.js +48 -3
- package/dist/session-sync.d.ts +125 -0
- package/dist/session-sync.js +181 -8
- package/dist/session-titler.d.ts +26 -0
- package/dist/session-titler.js +41 -7
- package/dist/session-watch.d.ts +53 -1
- package/dist/session-watch.js +73 -9
- package/dist/sighup-idle.d.ts +30 -0
- package/dist/sighup-idle.js +12 -1
- package/dist/spec-fields.d.ts +91 -3
- package/dist/spec-fields.js +116 -4
- package/dist/task-cwd.d.ts +50 -0
- package/dist/task-cwd.js +68 -1
- package/dist/task-mcp.d.ts +47 -0
- package/dist/task-mcp.js +29 -0
- package/dist/task-settings.d.ts +175 -0
- package/dist/task-settings.js +226 -11
- package/dist/task-workflow.d.ts +67 -0
- package/dist/task-workflow.js +75 -8
- package/dist/tool-approval.d.ts +91 -0
- package/dist/tool-approval.js +215 -0
- package/dist/trace/artifacts.d.ts +9 -0
- package/dist/trace/artifacts.js +30 -5
- package/dist/trace/core-keyset-guard.d.ts +18 -0
- package/dist/trace/ledger-sink.d.ts +43 -0
- package/dist/trace/ledger-sink.js +64 -5
- package/dist/trace/project.d.ts +133 -0
- package/dist/trace/project.js +189 -2
- package/dist/trace/redact.d.ts +19 -0
- package/dist/trace/redact.js +66 -9
- package/dist/usage-analytics.d.ts +26 -0
- package/dist/usage-analytics.js +26 -3
- package/package.json +1 -1
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { historyRowFrom } from "./memory-sync-store-pg.js";
|
|
2
|
+
/** Table names (single source) — SAME names as PG_MEMORY_SYNC_TABLES (the two dialects never share
|
|
3
|
+
* one database). */
|
|
2
4
|
export const TIDB_MEMORY_SYNC_TABLES = {
|
|
3
5
|
syncCursors: "agent_memory_engine_sync_cursors",
|
|
4
6
|
pushQueue: "agent_memory_engine_push_queue",
|
|
5
7
|
history: "agent_memory_engine_history",
|
|
6
8
|
};
|
|
9
|
+
/** Idempotent DDL for the sync plane (TiDB dialect). Call once at startup.
|
|
10
|
+
* Key budget: utf8mb4 = 4 bytes/char, index cap 3072 bytes ⇒ PK(scope,peer) = 380 chars = 1520 B ✓. */
|
|
7
11
|
export async function ensureTiDBMemorySyncSchema(pool) {
|
|
8
12
|
await pool.query(`CREATE TABLE IF NOT EXISTS ${TIDB_MEMORY_SYNC_TABLES.syncCursors} (
|
|
9
13
|
scope VARCHAR(190) NOT NULL,
|
|
@@ -24,11 +28,14 @@ export async function ensureTiDBMemorySyncSchema(pool) {
|
|
|
24
28
|
KEY idx_next_attempt (next_attempt_at)
|
|
25
29
|
)`);
|
|
26
30
|
}
|
|
31
|
+
/** JSON-column defense: mysql2 normally hands back parsed objects for JSON columns, but string
|
|
32
|
+
* shapes leak through (connection flags/proxies) — same posture as memory-engine-tidb.ts. */
|
|
27
33
|
function fromJson(v) {
|
|
28
34
|
if (typeof v === "string")
|
|
29
35
|
return JSON.parse(v);
|
|
30
36
|
return v;
|
|
31
37
|
}
|
|
38
|
+
/** BIGINT columns may arrive as string depending on driver flags — normalize defensively. */
|
|
32
39
|
function toMs(v) {
|
|
33
40
|
return typeof v === "number" ? v : Number(v);
|
|
34
41
|
}
|
|
@@ -43,6 +50,7 @@ export class TiDBMemorySyncStore {
|
|
|
43
50
|
}
|
|
44
51
|
this.claimLeaseMs = lease;
|
|
45
52
|
}
|
|
53
|
+
// ── cursors ────────────────────────────────────────────────────────────────
|
|
46
54
|
async getCursor(scope, peer) {
|
|
47
55
|
const [rows] = await this.pool.query(`SELECT base_revs, updated_at_ms FROM ${TIDB_MEMORY_SYNC_TABLES.syncCursors} WHERE scope = ? AND peer = ?`, [scope, peer]);
|
|
48
56
|
const row = rows[0];
|
|
@@ -56,11 +64,16 @@ export class TiDBMemorySyncStore {
|
|
|
56
64
|
};
|
|
57
65
|
}
|
|
58
66
|
async putCursor(cursor) {
|
|
67
|
+
// The table's ONLY unique key is PK(scope,peer) ⇒ ON DUPLICATE KEY UPDATE has exactly one
|
|
68
|
+
// possible trigger — no hijack face (the entries-table ban does NOT apply; see header).
|
|
59
69
|
await this.pool.query(`INSERT INTO ${TIDB_MEMORY_SYNC_TABLES.syncCursors} (scope, peer, base_revs, updated_at_ms)
|
|
60
70
|
VALUES (?, ?, ?, ?)
|
|
61
71
|
ON DUPLICATE KEY UPDATE base_revs = VALUES(base_revs), updated_at_ms = VALUES(updated_at_ms)`, [cursor.scope, cursor.peer, JSON.stringify(cursor.baseRevs), cursor.updatedAtMs]);
|
|
62
72
|
}
|
|
73
|
+
// ── push queue ─────────────────────────────────────────────────────────────
|
|
63
74
|
async enqueue(item) {
|
|
75
|
+
// Plain INSERT, fail-loud on a duplicate id (ER_DUP_ENTRY 1062) — caller mints uuidv7 per
|
|
76
|
+
// enqueue, a dup is a caller bug, never silently absorbed. Same posture as the PG twin.
|
|
64
77
|
await this.pool.query(`INSERT INTO ${TIDB_MEMORY_SYNC_TABLES.pushQueue} (id, scope, entry_id, payload, attempts, next_attempt_at, last_error)
|
|
65
78
|
VALUES (?, ?, ?, ?, 0, ?, NULL)`, [item.id, item.scope, item.entryId, JSON.stringify(item.payload), item.nextAttemptAtMs]);
|
|
66
79
|
}
|
|
@@ -68,6 +81,10 @@ export class TiDBMemorySyncStore {
|
|
|
68
81
|
if (limit <= 0)
|
|
69
82
|
return [];
|
|
70
83
|
const leasedUntilMs = nowMs + this.claimLeaseMs;
|
|
84
|
+
// Optimistic CAS claim (header rationale): read the due candidates, then win each row with a
|
|
85
|
+
// conditional UPDATE on the exact next_attempt_at we read. Losers (another worker claimed, or
|
|
86
|
+
// fail()/a re-schedule moved the row) see affectedRows=0 and are skipped — the SKIP LOCKED
|
|
87
|
+
// equivalent, without pessimistic locks or a held connection.
|
|
71
88
|
const [candidates] = await this.pool.query(`SELECT id, scope, entry_id, payload, attempts, next_attempt_at, last_error
|
|
72
89
|
FROM ${TIDB_MEMORY_SYNC_TABLES.pushQueue}
|
|
73
90
|
WHERE next_attempt_at <= ?
|
|
@@ -75,11 +92,13 @@ export class TiDBMemorySyncStore {
|
|
|
75
92
|
LIMIT ?`, [nowMs, limit]);
|
|
76
93
|
const claimed = [];
|
|
77
94
|
for (const row of candidates) {
|
|
95
|
+
// affectedRows=CHANGED 语义坑防御:lease = nowMs + claimLeaseMs > nowMs ≥ 读到的 next_attempt_at
|
|
96
|
+
// (WHERE 已保证),新值严格大于旧值 ⇒ 匹配必 change ⇒ affectedRows=1 恒等于「真的赢了」。
|
|
78
97
|
const [res] = await this.pool.query(`UPDATE ${TIDB_MEMORY_SYNC_TABLES.pushQueue}
|
|
79
98
|
SET next_attempt_at = ?
|
|
80
99
|
WHERE id = ? AND next_attempt_at = ?`, [leasedUntilMs, row.id, toMs(row.next_attempt_at)]);
|
|
81
100
|
if (res.affectedRows !== 1)
|
|
82
|
-
continue;
|
|
101
|
+
continue; // lost the race — skip, never block
|
|
83
102
|
claimed.push({
|
|
84
103
|
id: row.id,
|
|
85
104
|
scope: row.scope,
|
|
@@ -96,12 +115,20 @@ export class TiDBMemorySyncStore {
|
|
|
96
115
|
await this.pool.query(`DELETE FROM ${TIDB_MEMORY_SYNC_TABLES.pushQueue} WHERE id = ?`, [id]);
|
|
97
116
|
}
|
|
98
117
|
async fail(id, error, nextAttemptAtMs) {
|
|
118
|
+
// attempts = attempts + 1 is SQL-atomic (never read-modify-write in JS); the increment also
|
|
119
|
+
// guarantees the row CHANGES — the claim verdict is honest under BOTH affectedRows semantics
|
|
120
|
+
// (mysql2 default = FOUND_ROWS/matched; changed-only would also work here).
|
|
99
121
|
await this.pool.query(`UPDATE ${TIDB_MEMORY_SYNC_TABLES.pushQueue}
|
|
100
122
|
SET attempts = attempts + 1, last_error = ?, next_attempt_at = ?
|
|
101
123
|
WHERE id = ?`, [error, nextAttemptAtMs, id]);
|
|
102
124
|
}
|
|
103
125
|
}
|
|
126
|
+
// ── 142-S5 §1.3 — history table (tombstone + rev chain), TiDB dialect ───────────────────────────
|
|
127
|
+
/** Idempotent DDL for the history table (TiDB dialect). Key budget: PK(id,rev) = CHAR(36)+
|
|
128
|
+
* VARCHAR(128) = 164 chars ≤ 3072-byte utf8mb4 index cap ✓; KEY(scope) = 190 chars ✓. */
|
|
104
129
|
export async function ensureTiDBMemoryHistorySchema(pool) {
|
|
130
|
+
// scope column + written_at_ms BIGINT = the same design-doc amendments as the Pg twin (see
|
|
131
|
+
// MemoryHistoryAppendRow.scope / ensurePgMemoryHistorySchema).
|
|
105
132
|
await pool.query(`CREATE TABLE IF NOT EXISTS ${TIDB_MEMORY_SYNC_TABLES.history} (
|
|
106
133
|
id CHAR(36) NOT NULL,
|
|
107
134
|
rev VARCHAR(128) NOT NULL,
|
|
@@ -122,6 +149,9 @@ export class TiDBMemoryHistoryStore {
|
|
|
122
149
|
async appendHistory(rows) {
|
|
123
150
|
if (rows.length === 0)
|
|
124
151
|
return;
|
|
152
|
+
// ONE multi-row INSERT; dup (id,rev) replay = no-op via `ON DUPLICATE KEY UPDATE id = id`
|
|
153
|
+
// (header rationale: NOT INSERT IGNORE — IGNORE swallows non-dup errors too). PK(id,rev) is the
|
|
154
|
+
// only unique key ⇒ the ODKU trigger is unambiguous, and the "update" writes nothing.
|
|
125
155
|
const params = [];
|
|
126
156
|
for (const r of rows) {
|
|
127
157
|
params.push(r.id, r.rev, r.prevRev ?? null, r.op, r.scope, r.snapshot === undefined || r.snapshot === null ? null : JSON.stringify(r.snapshot), r.writtenAtMs);
|
|
@@ -2,6 +2,7 @@ import type { Pool as MySqlPool } from "mysql2/promise";
|
|
|
2
2
|
import type { Pool as PgPool, PoolClient } from "pg";
|
|
3
3
|
import type { TaskOutcome as CoreTaskOutcome } from "@sema-agent/core";
|
|
4
4
|
import { type SqlDriver } from "./sql-driver.js";
|
|
5
|
+
/** Mechanical signals — the ONLY tier a future self-scheduler may read (council blocker 1). */
|
|
5
6
|
export interface MechanicalOutcome {
|
|
6
7
|
route?: "single" | "fanout";
|
|
7
8
|
workerCount?: number;
|
|
@@ -14,6 +15,7 @@ export interface MechanicalOutcome {
|
|
|
14
15
|
costMicroUsd?: number;
|
|
15
16
|
turns?: number;
|
|
16
17
|
}
|
|
18
|
+
/** LLM-assisted signals — dashboard-only, NEVER drives automatic change, NEVER co-weighted. */
|
|
17
19
|
export interface LlmAssistedOutcome {
|
|
18
20
|
stuckEvents?: number;
|
|
19
21
|
verifier?: {
|
|
@@ -21,35 +23,94 @@ export interface LlmAssistedOutcome {
|
|
|
21
23
|
confidence: number;
|
|
22
24
|
};
|
|
23
25
|
}
|
|
26
|
+
/** Raw inputs to the v1 task-signature (council Q11 candidate (a): structural/keyword hash). */
|
|
24
27
|
export interface SignatureInputs {
|
|
25
28
|
taskType?: string;
|
|
26
29
|
toolset?: string[];
|
|
27
30
|
targetLang?: string;
|
|
28
31
|
moduleCount?: number;
|
|
32
|
+
/** Optional explicit tag override (council Q11 candidate (c)). When set, it IS the signature. */
|
|
29
33
|
tag?: string;
|
|
30
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Run-status classification (council blocker 3 — attribution noise). Gates whether the
|
|
37
|
+
* mechanical signal reflects TASK quality at all: an `infra-aborted` run died in the basework (sandbox
|
|
38
|
+
* OOM / git-ownership / timeout / harvest fail) BEFORE reaching the grader, so its 0/total oracle is an
|
|
39
|
+
* infra-health signal, NOT a task-difficulty signal. Route/budget learning must read `completed-graded`
|
|
40
|
+
* rows ONLY; `infra-aborted` rows are kept for the infra-health dashboard but excluded from training.
|
|
41
|
+
* (Found live: the task#2b backfill showed 9% pass-rate that was really 10/11 infra deaths since fixed.)
|
|
42
|
+
*/
|
|
31
43
|
export type RunStatus = "completed-graded" | "infra-aborted";
|
|
32
44
|
export interface TaskOutcome {
|
|
33
45
|
taskId?: string;
|
|
34
46
|
model: string;
|
|
47
|
+
/** Default "completed-graded" if omitted. Set "infra-aborted" for runs that never reached the grader. */
|
|
35
48
|
runStatus?: RunStatus;
|
|
36
49
|
signatureInputs: SignatureInputs;
|
|
37
50
|
mechanical: MechanicalOutcome;
|
|
38
51
|
llmAssisted?: LlmAssistedOutcome;
|
|
52
|
+
/** design/73 §1 consumption: the VERBATIM core `TaskOutcome` fact this row was derived from (status/
|
|
53
|
+
* errorCode/oracleHadRedRun/oracle blob — fields the v1 columns predate). Stored as-is in `core_outcome`
|
|
54
|
+
* so red-line ② (`oracleHadRedRun`) and the free-form oracle survive lossless; the mapped mechanical
|
|
55
|
+
* columns stay the aggregate/query surface. */
|
|
39
56
|
core?: unknown;
|
|
40
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* v1 task-signature (council Q11, recommended candidate (a)): a deterministic structural hash — zero
|
|
60
|
+
* embedder, coarse on purpose (routing is a coarse decision). An explicit `tag` short-circuits to the
|
|
61
|
+
* tag itself (candidate (c)).
|
|
62
|
+
*/
|
|
41
63
|
export declare function taskSignature(s: SignatureInputs): string;
|
|
64
|
+
/**
|
|
65
|
+
* Derive the coarse outcome from MECHANICAL fields only (council blocker 1: llmAssisted never participates).
|
|
66
|
+
* pass = all hidden tests green AND both build exits 0 AND merge ok; fail = nothing graded green; else partial.
|
|
67
|
+
*/
|
|
42
68
|
export declare function deriveOutcome(m: MechanicalOutcome, runStatus?: RunStatus): "pass" | "partial" | "fail" | "aborted";
|
|
69
|
+
/**
|
|
70
|
+
* design/73 §1 → §7 bridge: project one CORE `TaskOutcome` fact (the `RunnerDeps.onTaskOutcome` seam,
|
|
71
|
+
* core 1.226) onto a v1 ledger row. Lossless: the verbatim fact rides `core` → the `core_outcome` JSON
|
|
72
|
+
* column (red-line ② `oracleHadRedRun` + the free-form oracle blob have no v1 columns); the mapped
|
|
73
|
+
* mechanical fields keep the existing aggregate surface working. Mapping rules:
|
|
74
|
+
* - `signatureInputs.tag = o.taskSignature` — core already emits THE aggregation key, so the ledger's
|
|
75
|
+
* tag short-circuit adopts it verbatim (no re-derivation drift);
|
|
76
|
+
* - oracle counts: `oracle.oraclePassed/oracleTotal` when the harness supplied numeric counts, else the
|
|
77
|
+
* required `green` bit as 1/0 over 1 (an honest degenerate count, not a fabrication);
|
|
78
|
+
* - `runStatus` stays "completed-graded": core's red line ③ means emission only happens at a REAL
|
|
79
|
+
* mechanical-oracle terminal (an infra-aborted run never reaches the emit point).
|
|
80
|
+
*/
|
|
43
81
|
export declare function coreOutcomeToLedgerRow(o: CoreTaskOutcome): TaskOutcome;
|
|
82
|
+
/**
|
|
83
|
+
* PG translation of the `outcome_ledger` DDL in tidb-pool.ts SCHEMA_STATEMENTS:
|
|
84
|
+
* JSON→JSONB, DATETIME(3)→TIMESTAMPTZ(3), TINYINT(1)→SMALLINT, INT→INTEGER, inline KEY→separate CREATE INDEX.
|
|
85
|
+
* The table is DISJOINT from every other store's tables, so this self-contained set is safe (no shadowing).
|
|
86
|
+
*
|
|
87
|
+
* SCHEMA POLICY: see the header of pg-pool.ts — the code is the single source of truth, schema changes are
|
|
88
|
+
* drop-and-recreate, and NO new `ALTER TABLE` seams are added here; fold into the CREATE instead.
|
|
89
|
+
*/
|
|
44
90
|
export declare const PG_OUTCOME_LEDGER_SCHEMA: string[];
|
|
91
|
+
/** Idempotent self-contained PG schema apply (for the integration test; central aggregation via pg-pool.ts). */
|
|
45
92
|
export declare function ensurePgOutcomeLedgerSchema(pool: PgPool | PoolClient): Promise<void>;
|
|
93
|
+
/** Dual-dialect outcome ledger. See the file header for the dialect-delta ledger. */
|
|
46
94
|
export declare class SqlOutcomeLedger {
|
|
47
95
|
private readonly db;
|
|
48
96
|
constructor(db: SqlDriver);
|
|
97
|
+
/** Pick the dialect's SQL text. Both statements stay written out at the call site ON PURPOSE. */
|
|
49
98
|
private q;
|
|
99
|
+
/** JSON column encode: TiDB stores `JSON.stringify` verbatim; PG runs the deep NUL/lone-surrogate
|
|
100
|
+
* sanitize (a raw tool_result/core blob can carry bytes PG's jsonb column rejects, ERRCODE 22P05) — this
|
|
101
|
+
* store's blobs are observability/dashboard data, so the lossy (U+FFFD) sanitize is the right tier
|
|
102
|
+
* (not the lossless envelope checkpoint-store-sql.ts uses for the approval trust boundary). */
|
|
50
103
|
private json;
|
|
104
|
+
/** Record one graded task run. Idempotent only by row id; callers pass distinct runs. */
|
|
51
105
|
record(o: TaskOutcome): Promise<string>;
|
|
106
|
+
/** design/73 §1 seam consumption: record one CORE outcome fact (see {@link coreOutcomeToLedgerRow}). */
|
|
52
107
|
recordCore(o: CoreTaskOutcome): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Read-only aggregate for the dashboard / offline backtest: pass-rate + mean cost per (signature, model).
|
|
110
|
+
* 🔴 Defaults to `completed-graded` rows ONLY — the route/budget-learning signal must exclude infra-aborted
|
|
111
|
+
* runs (council blocker 3: a basework death is not a task-difficulty signal). Pass
|
|
112
|
+
* `includeAborted: true` only for the infra-health view, never for training.
|
|
113
|
+
*/
|
|
53
114
|
summary(opts?: {
|
|
54
115
|
taskSignature?: string;
|
|
55
116
|
includeAborted?: boolean;
|
|
@@ -61,9 +122,11 @@ export declare class SqlOutcomeLedger {
|
|
|
61
122
|
meanCostMicroUsd: number;
|
|
62
123
|
}>>;
|
|
63
124
|
}
|
|
125
|
+
/** MySQL-protocol (TiDB) binding — historical class name + ctor shape preserved. */
|
|
64
126
|
export declare class TiDBOutcomeLedger extends SqlOutcomeLedger {
|
|
65
127
|
constructor(pool: MySqlPool);
|
|
66
128
|
}
|
|
129
|
+
/** PostgreSQL binding — historical class name + ctor shape preserved. */
|
|
67
130
|
export declare class PgOutcomeLedger extends SqlOutcomeLedger {
|
|
68
131
|
constructor(pool: PgPool);
|
|
69
132
|
}
|
|
@@ -1,6 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome ledger (design/73 §7) — the read-only first step of grounded self-evolution. SINGLE-FILE
|
|
3
|
+
* DUAL-DIALECT (design/158 A12 定型半场): ONE implementation, TWO dialects; the historical
|
|
4
|
+
* `TiDBOutcomeLedger` / `PgOutcomeLedger` class names survive as thin ctor subclasses so every consumer
|
|
5
|
+
* (store-backend.ts, pg-pool.ts, the unit + real-DB suites) is untouched.
|
|
6
|
+
*
|
|
7
|
+
* One row per graded task run, keyed by (taskSignature, model). v1 is STRICTLY READ-ONLY: it records
|
|
8
|
+
* outcomes for a dashboard + as the dataset for an offline backtest (bandit vs fixed routing). It drives
|
|
9
|
+
* NO automatic policy change — that is flag-gated and must first pass the offline-backtest gate
|
|
10
|
+
* (council blocker 3 / major 7).
|
|
11
|
+
*
|
|
12
|
+
* 🔴 Signal-hardness split is the load-bearing invariant (council blocker 1): only `mechanical` fields
|
|
13
|
+
* (oracle pass/total, build exits, mergeOk, cost, turns, route, replan) may ever drive an automatic
|
|
14
|
+
* policy change. `llmAssisted` (stuck counts, verifier verdict+confidence) is dashboard-only, carried in
|
|
15
|
+
* its own blob, never co-weighted with mechanical. `outcome` is DERIVED from mechanical fields ONLY.
|
|
16
|
+
*
|
|
17
|
+
* ── Dialect deltas, kept EXPLICIT ────────────────────────────────────────────────────────────────────
|
|
18
|
+
* - `?` placeholders vs `$n` - JSON columns bound `CAST(? AS JSON)`-free (TiDB
|
|
19
|
+
* stores the string verbatim) vs `$n::jsonb`
|
|
20
|
+
* - JSON encode: TiDB `JSON.stringify` verbatim vs PG `pgSafeJsonStringify` (deep NUL/lone-surrogate
|
|
21
|
+
* sanitize — a raw tool_result/core blob can carry bytes PG's text/jsonb columns reject, ERRCODE 22P05)
|
|
22
|
+
* - affected/SELECT rows via `result.rowCount` / `result.rows` (not RowDataPacket/ResultSetHeader) — via SqlDriver
|
|
23
|
+
* - BIGINT (cost_micro_usd) read back as a STRING by node-pg → wrapped in `Number(...)`
|
|
24
|
+
* - `AVG(outcome = 'pass')` (MySQL boolean→1/0) vs `AVG((outcome = 'pass')::int)` (PG has no boolean→int coercion)
|
|
25
|
+
* - merge_ok TINYINT(1) vs SMALLINT (0/1 in/out) - DATETIME(3) vs TIMESTAMPTZ(3) (Date in/out)
|
|
26
|
+
* - schema ownership: TiDB DDL lives in tidb-pool.ts SCHEMA_STATEMENTS; the PG DDL is exported from HERE
|
|
27
|
+
* (`PG_OUTCOME_LEDGER_SCHEMA` + `ensurePgOutcomeLedgerSchema`) for pg-pool.ts + the integration test.
|
|
28
|
+
*
|
|
29
|
+
* Kept in lock-step across dialects by the shared real-DB integration suite
|
|
30
|
+
* (test/pg-outcome-ledger-integration.test.ts, both engines run the SAME scenarios in parallel).
|
|
31
|
+
*/
|
|
1
32
|
import { randomUUID, createHash } from "node:crypto";
|
|
2
33
|
import { pgSafeJsonStringify } from "./pg-safe-json.js";
|
|
3
34
|
import { mysqlDriver, pgDriver } from "./sql-driver.js";
|
|
35
|
+
/**
|
|
36
|
+
* v1 task-signature (council Q11, recommended candidate (a)): a deterministic structural hash — zero
|
|
37
|
+
* embedder, coarse on purpose (routing is a coarse decision). An explicit `tag` short-circuits to the
|
|
38
|
+
* tag itself (candidate (c)).
|
|
39
|
+
*/
|
|
4
40
|
export function taskSignature(s) {
|
|
5
41
|
if (s.tag)
|
|
6
42
|
return `tag:${s.tag}`;
|
|
@@ -12,7 +48,14 @@ export function taskSignature(s) {
|
|
|
12
48
|
});
|
|
13
49
|
return `h:${createHash("sha256").update(canon).digest("hex").slice(0, 16)}`;
|
|
14
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Derive the coarse outcome from MECHANICAL fields only (council blocker 1: llmAssisted never participates).
|
|
53
|
+
* pass = all hidden tests green AND both build exits 0 AND merge ok; fail = nothing graded green; else partial.
|
|
54
|
+
*/
|
|
15
55
|
export function deriveOutcome(m, runStatus = "completed-graded") {
|
|
56
|
+
// An infra-aborted run never reached the grader — its 0/total is infra, not task quality. Don't let it
|
|
57
|
+
// read as "fail" (which a self-scheduler would mistake for task difficulty); mark it "aborted" so the
|
|
58
|
+
// backtest can exclude it (council blocker 3).
|
|
16
59
|
if (runStatus === "infra-aborted")
|
|
17
60
|
return "aborted";
|
|
18
61
|
const oracleGreen = m.oracleTotal != null && m.oracleTotal > 0 && m.oraclePassed === m.oracleTotal;
|
|
@@ -20,9 +63,24 @@ export function deriveOutcome(m, runStatus = "completed-graded") {
|
|
|
20
63
|
const mergeGreen = m.mergeOk !== false;
|
|
21
64
|
if (oracleGreen && buildGreen && mergeGreen)
|
|
22
65
|
return "pass";
|
|
66
|
+
// "partial" needs POSITIVE green evidence. An OMITTED mergeOk is non-evidence — counting it green (the
|
|
67
|
+
// pre-2026-07 behavior) made "fail" unreachable for any row without an explicit mergeOk:false, so a
|
|
68
|
+
// fully-red oracle read as "partial" (caught wiring the design/73 §1 bridge, whose rows carry no mergeOk).
|
|
23
69
|
const anyGreen = oracleGreen || (m.oraclePassed != null && m.oraclePassed > 0) || m.mergeOk === true;
|
|
24
70
|
return anyGreen ? "partial" : "fail";
|
|
25
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* design/73 §1 → §7 bridge: project one CORE `TaskOutcome` fact (the `RunnerDeps.onTaskOutcome` seam,
|
|
74
|
+
* core 1.226) onto a v1 ledger row. Lossless: the verbatim fact rides `core` → the `core_outcome` JSON
|
|
75
|
+
* column (red-line ② `oracleHadRedRun` + the free-form oracle blob have no v1 columns); the mapped
|
|
76
|
+
* mechanical fields keep the existing aggregate surface working. Mapping rules:
|
|
77
|
+
* - `signatureInputs.tag = o.taskSignature` — core already emits THE aggregation key, so the ledger's
|
|
78
|
+
* tag short-circuit adopts it verbatim (no re-derivation drift);
|
|
79
|
+
* - oracle counts: `oracle.oraclePassed/oracleTotal` when the harness supplied numeric counts, else the
|
|
80
|
+
* required `green` bit as 1/0 over 1 (an honest degenerate count, not a fabrication);
|
|
81
|
+
* - `runStatus` stays "completed-graded": core's red line ③ means emission only happens at a REAL
|
|
82
|
+
* mechanical-oracle terminal (an infra-aborted run never reaches the emit point).
|
|
83
|
+
*/
|
|
26
84
|
export function coreOutcomeToLedgerRow(o) {
|
|
27
85
|
const passed = typeof o.oracle?.oraclePassed === "number" ? o.oracle.oraclePassed : o.oracle?.green ? 1 : 0;
|
|
28
86
|
const total = typeof o.oracle?.oracleTotal === "number" ? o.oracle.oracleTotal : 1;
|
|
@@ -30,6 +88,8 @@ export function coreOutcomeToLedgerRow(o) {
|
|
|
30
88
|
taskId: o.runId.slice(0, 64),
|
|
31
89
|
model: (o.model ?? "unknown").slice(0, 190),
|
|
32
90
|
signatureInputs: {
|
|
91
|
+
// 🔴 `taskSignature()` prepends "tag:" → the final task_signature must fit VARCHAR(190).
|
|
92
|
+
// Cap the raw tag at 190 − len("tag:") = 186 so the prefixed key never overflows/truncates the column.
|
|
33
93
|
tag: o.taskSignature.slice(0, 186),
|
|
34
94
|
...(o.signatureInputs?.toolset ? { toolset: o.signatureInputs.toolset } : {}),
|
|
35
95
|
...(o.signatureInputs?.targetLang ? { targetLang: o.signatureInputs.targetLang } : {}),
|
|
@@ -44,6 +104,14 @@ export function coreOutcomeToLedgerRow(o) {
|
|
|
44
104
|
core: o,
|
|
45
105
|
};
|
|
46
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* PG translation of the `outcome_ledger` DDL in tidb-pool.ts SCHEMA_STATEMENTS:
|
|
109
|
+
* JSON→JSONB, DATETIME(3)→TIMESTAMPTZ(3), TINYINT(1)→SMALLINT, INT→INTEGER, inline KEY→separate CREATE INDEX.
|
|
110
|
+
* The table is DISJOINT from every other store's tables, so this self-contained set is safe (no shadowing).
|
|
111
|
+
*
|
|
112
|
+
* SCHEMA POLICY: see the header of pg-pool.ts — the code is the single source of truth, schema changes are
|
|
113
|
+
* drop-and-recreate, and NO new `ALTER TABLE` seams are added here; fold into the CREATE instead.
|
|
114
|
+
*/
|
|
47
115
|
export const PG_OUTCOME_LEDGER_SCHEMA = [
|
|
48
116
|
`CREATE TABLE IF NOT EXISTS outcome_ledger (
|
|
49
117
|
id VARCHAR(64) NOT NULL,
|
|
@@ -75,31 +143,44 @@ export const PG_OUTCOME_LEDGER_SCHEMA = [
|
|
|
75
143
|
`CREATE INDEX IF NOT EXISTS idx_outcome_ledger_outcome ON outcome_ledger (outcome)`,
|
|
76
144
|
`CREATE INDEX IF NOT EXISTS idx_outcome_ledger_created ON outcome_ledger (created_at)`,
|
|
77
145
|
];
|
|
146
|
+
/** Idempotent self-contained PG schema apply (for the integration test; central aggregation via pg-pool.ts). */
|
|
78
147
|
export async function ensurePgOutcomeLedgerSchema(pool) {
|
|
79
148
|
for (const stmt of PG_OUTCOME_LEDGER_SCHEMA)
|
|
80
149
|
await pool.query(stmt);
|
|
81
150
|
}
|
|
151
|
+
/** Dual-dialect outcome ledger. See the file header for the dialect-delta ledger. */
|
|
82
152
|
export class SqlOutcomeLedger {
|
|
83
153
|
db;
|
|
84
154
|
constructor(db) {
|
|
85
155
|
this.db = db;
|
|
86
156
|
}
|
|
157
|
+
/** Pick the dialect's SQL text. Both statements stay written out at the call site ON PURPOSE. */
|
|
87
158
|
q(tidb, pg) {
|
|
88
159
|
return this.db.dialect === "tidb" ? tidb : pg;
|
|
89
160
|
}
|
|
161
|
+
/** JSON column encode: TiDB stores `JSON.stringify` verbatim; PG runs the deep NUL/lone-surrogate
|
|
162
|
+
* sanitize (a raw tool_result/core blob can carry bytes PG's jsonb column rejects, ERRCODE 22P05) — this
|
|
163
|
+
* store's blobs are observability/dashboard data, so the lossy (U+FFFD) sanitize is the right tier
|
|
164
|
+
* (not the lossless envelope checkpoint-store-sql.ts uses for the approval trust boundary). */
|
|
90
165
|
json(value) {
|
|
91
166
|
return this.db.dialect === "tidb" ? JSON.stringify(value) : pgSafeJsonStringify(value);
|
|
92
167
|
}
|
|
168
|
+
/** Record one graded task run. Idempotent only by row id; callers pass distinct runs. */
|
|
93
169
|
async record(o) {
|
|
94
170
|
const id = randomUUID().replace(/-/g, "").slice(0, 32);
|
|
95
171
|
const sig = taskSignature(o.signatureInputs);
|
|
96
172
|
const m = o.mechanical;
|
|
97
173
|
const runStatus = o.runStatus ?? "completed-graded";
|
|
98
|
-
await this.db.query(this.q(
|
|
174
|
+
await this.db.query(this.q(
|
|
175
|
+
// 🔴 byte-for-byte preserved from tidb-outcome-ledger.ts (pre-collapse) — the parity harness
|
|
176
|
+
// diffs this literally, so its indentation is NOT reflowed to the new call-site nesting.
|
|
177
|
+
`INSERT INTO outcome_ledger
|
|
99
178
|
(id, task_signature, model, task_id, run_status, route, worker_count, oracle_passed, oracle_total,
|
|
100
179
|
assemble_exit, lint_exit, merge_ok, replan_triggers, cost_micro_usd, turns, outcome,
|
|
101
180
|
llm_assisted, signature_inputs, core_outcome, created_at)
|
|
102
|
-
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
181
|
+
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
182
|
+
// 🔴 byte-for-byte preserved from pg-outcome-ledger.ts (pre-collapse).
|
|
183
|
+
`INSERT INTO outcome_ledger
|
|
103
184
|
(id, task_signature, model, task_id, run_status, route, worker_count, oracle_passed, oracle_total,
|
|
104
185
|
assemble_exit, lint_exit, merge_ok, replan_triggers, cost_micro_usd, turns, outcome,
|
|
105
186
|
llm_assisted, signature_inputs, core_outcome, created_at)
|
|
@@ -114,9 +195,16 @@ export class SqlOutcomeLedger {
|
|
|
114
195
|
]);
|
|
115
196
|
return id;
|
|
116
197
|
}
|
|
198
|
+
/** design/73 §1 seam consumption: record one CORE outcome fact (see {@link coreOutcomeToLedgerRow}). */
|
|
117
199
|
async recordCore(o) {
|
|
118
200
|
await this.record(coreOutcomeToLedgerRow(o));
|
|
119
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Read-only aggregate for the dashboard / offline backtest: pass-rate + mean cost per (signature, model).
|
|
204
|
+
* 🔴 Defaults to `completed-graded` rows ONLY — the route/budget-learning signal must exclude infra-aborted
|
|
205
|
+
* runs (council blocker 3: a basework death is not a task-difficulty signal). Pass
|
|
206
|
+
* `includeAborted: true` only for the infra-health view, never for training.
|
|
207
|
+
*/
|
|
120
208
|
async summary(opts = {}) {
|
|
121
209
|
const clauses = [];
|
|
122
210
|
const params = [];
|
|
@@ -124,10 +212,14 @@ export class SqlOutcomeLedger {
|
|
|
124
212
|
clauses.push("run_status = 'completed-graded'");
|
|
125
213
|
if (opts.taskSignature) {
|
|
126
214
|
params.push(opts.taskSignature);
|
|
215
|
+
// 🔴 placeholder ARITY differs, not just the token: TiDB's `?` is positional-anonymous (always just
|
|
216
|
+
// "?"), while PG's `$n` must name the actual ordinal — `params.length` after the push IS that ordinal.
|
|
127
217
|
clauses.push(this.q("task_signature = ?", `task_signature = $${params.length}`));
|
|
128
218
|
}
|
|
129
219
|
const where = clauses.length ? `WHERE ${clauses.join(" AND ")}` : "";
|
|
130
|
-
const { rows } = await this.db.query(this.q(
|
|
220
|
+
const { rows } = await this.db.query(this.q(
|
|
221
|
+
// 🔴 byte-for-byte preserved (both statements) — not reflowed to the new call-site nesting.
|
|
222
|
+
`SELECT task_signature, model, COUNT(*) n,
|
|
131
223
|
AVG(outcome = 'pass') pass_rate, AVG(cost_micro_usd) mean_cost
|
|
132
224
|
FROM outcome_ledger ${where}
|
|
133
225
|
GROUP BY task_signature, model
|
|
@@ -145,11 +237,13 @@ export class SqlOutcomeLedger {
|
|
|
145
237
|
}));
|
|
146
238
|
}
|
|
147
239
|
}
|
|
240
|
+
/** MySQL-protocol (TiDB) binding — historical class name + ctor shape preserved. */
|
|
148
241
|
export class TiDBOutcomeLedger extends SqlOutcomeLedger {
|
|
149
242
|
constructor(pool) {
|
|
150
243
|
super(mysqlDriver(pool));
|
|
151
244
|
}
|
|
152
245
|
}
|
|
246
|
+
/** PostgreSQL binding — historical class name + ctor shape preserved. */
|
|
153
247
|
export class PgOutcomeLedger extends SqlOutcomeLedger {
|
|
154
248
|
constructor(pool) {
|
|
155
249
|
super(pgDriver(pool));
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin re-export shim (design/158 A12 收编 — see src/plugins/approval-store-sql.ts for the
|
|
3
|
+
* implementation, now SINGLE-FILE DUAL-DIALECT alongside the TiDB twin). Class name, ctor arity,
|
|
4
|
+
* and every exported type/const/helper stay EXACTLY as they were so no consumer (pg-pool.ts's
|
|
5
|
+
* central schema composition, store-backend.ts, test/pg-approval-store-integration.test.ts) has
|
|
6
|
+
* to move.
|
|
7
|
+
*/
|
|
1
8
|
export { PgApprovalStore, PG_APPROVAL_SCHEMA, ensureSchema, type ApprovalRow, type ApprovalStatus, } from "./approval-store-sql.js";
|
|
2
9
|
//# sourceMappingURL=pg-approval-store.d.ts.map
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin re-export shim (design/158 A12 收编 — see src/plugins/approval-store-sql.ts for the
|
|
3
|
+
* implementation, now SINGLE-FILE DUAL-DIALECT alongside the TiDB twin). Class name, ctor arity,
|
|
4
|
+
* and every exported type/const/helper stay EXACTLY as they were so no consumer (pg-pool.ts's
|
|
5
|
+
* central schema composition, store-backend.ts, test/pg-approval-store-integration.test.ts) has
|
|
6
|
+
* to move.
|
|
7
|
+
*/
|
|
1
8
|
export { PgApprovalStore, PG_APPROVAL_SCHEMA, ensureSchema, } from "./approval-store-sql.js";
|
|
2
9
|
//# sourceMappingURL=pg-approval-store.js.map
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export shim (design/158 A12 收编) — the real implementation moved to breaker-state-sql.ts
|
|
3
|
+
* (single-file dual-dialect: `SqlBreakerState` + the `TiDBBreakerState`/`PgBreakerState` ctor subclasses).
|
|
4
|
+
* Kept so every consumer's `from "./pg-breaker-state.js"` import (incl. pg-pool.ts's central ensureSchema
|
|
5
|
+
* composition and the real dual-DB integration suite) keeps working unchanged.
|
|
6
|
+
*/
|
|
1
7
|
export { PgBreakerState, PG_BREAKER_STATE_SCHEMA, ensureSchema } from "./breaker-state-sql.js";
|
|
2
8
|
//# sourceMappingURL=pg-breaker-state.d.ts.map
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export shim (design/158 A12 收编) — the real implementation moved to breaker-state-sql.ts
|
|
3
|
+
* (single-file dual-dialect: `SqlBreakerState` + the `TiDBBreakerState`/`PgBreakerState` ctor subclasses).
|
|
4
|
+
* Kept so every consumer's `from "./pg-breaker-state.js"` import (incl. pg-pool.ts's central ensureSchema
|
|
5
|
+
* composition and the real dual-DB integration suite) keeps working unchanged.
|
|
6
|
+
*/
|
|
1
7
|
export { PgBreakerState, PG_BREAKER_STATE_SCHEMA, ensureSchema } from "./breaker-state-sql.js";
|
|
2
8
|
//# sourceMappingURL=pg-breaker-state.js.map
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL `CheckpointStore` — the implementation now lives in the single-file dual-dialect
|
|
3
|
+
* `checkpoint-store-sql.ts` (design/158 A12 定型半场), alongside its TiDB twin so the dialect deltas
|
|
4
|
+
* (placeholders, ON CONFLICT, `IS NOT DISTINCT FROM` + its placeholder-arity consequence, the lossless
|
|
5
|
+
* JSON envelope) read side by side instead of drifting across two files.
|
|
6
|
+
*
|
|
7
|
+
* This file is the historical import path: class name and ctor shape unchanged.
|
|
8
|
+
*/
|
|
1
9
|
export { PgCheckpointStore } from "./checkpoint-store-sql.js";
|
|
2
10
|
//# sourceMappingURL=pg-checkpoint-store.d.ts.map
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL `CheckpointStore` — the implementation now lives in the single-file dual-dialect
|
|
3
|
+
* `checkpoint-store-sql.ts` (design/158 A12 定型半场), alongside its TiDB twin so the dialect deltas
|
|
4
|
+
* (placeholders, ON CONFLICT, `IS NOT DISTINCT FROM` + its placeholder-arity consequence, the lossless
|
|
5
|
+
* JSON envelope) read side by side instead of drifting across two files.
|
|
6
|
+
*
|
|
7
|
+
* This file is the historical import path: class name and ctor shape unchanged.
|
|
8
|
+
*/
|
|
1
9
|
export { PgCheckpointStore } from "./checkpoint-store-sql.js";
|
|
2
10
|
//# sourceMappingURL=pg-checkpoint-store.js.map
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL-backed cross-replica per-key CUMULATIVE cost quota — the PG twin of {@link TiDBCostQuota}
|
|
3
|
+
* (src/plugins/tidb-cost-quota.ts). Behaviourally identical (same {@link QuotaTracker} surface, same
|
|
4
|
+
* SOFT/eventual-consistency write-behind semantics: atomic `micro = micro + delta` per aligned window
|
|
5
|
+
* bucket), PostgreSQL dialect instead of MySQL/TiDB. The two are kept in lock-step by ONE shared real-DB
|
|
6
|
+
* integration suite (test/pg-cost-quota-integration.test.ts) running the SAME scenarios on BOTH engines.
|
|
7
|
+
*
|
|
8
|
+
* design/158 A12 C1b: this file used to carry a PRIVATE inline copy of the write-behind counter, hardwired
|
|
9
|
+
* to the `cost_quota` columns — the third copy of the same 150 lines. It is gone; both dialects now share
|
|
10
|
+
* ONE dialect-parameterized implementation (write-behind-counter.ts), and the dialect deltas this header
|
|
11
|
+
* used to enumerate ($n placeholders / ON CONFLICT increment / rowCount / BIGINT-as-string) are documented
|
|
12
|
+
* and branched THERE. Only the table binding lives here.
|
|
13
|
+
*/
|
|
1
14
|
import type { Pool, PoolClient } from "pg";
|
|
2
15
|
import type { QuotaDecision, QuotaTracker } from "../observability/cost-quota.js";
|
|
3
16
|
import { type CounterDegradeHook } from "./write-behind-counter.js";
|
|
@@ -13,6 +26,10 @@ export declare class PgCostQuota implements QuotaTracker {
|
|
|
13
26
|
startRefresh(intervalMs?: number): this;
|
|
14
27
|
stop(): void;
|
|
15
28
|
}
|
|
29
|
+
/** PG DDL for the `cost_quota` table (translated from tidb-pool.ts SCHEMA_STATEMENTS: BIGINT same,
|
|
30
|
+
* DATETIME(3)→TIMESTAMPTZ(3), inline `KEY idx_window`→separate CREATE INDEX). DISJOINT from other stores'
|
|
31
|
+
* tables, so a self-contained ensureSchema is safe (the central pg-pool aggregation is done separately). */
|
|
16
32
|
export declare const PG_COST_QUOTA_SCHEMA: string[];
|
|
33
|
+
/** Idempotent schema apply for the cost_quota table (the PG twin of tidb-pool.ts ensureSchema). */
|
|
17
34
|
export declare function ensureSchema(pool: Pool | PoolClient): Promise<void>;
|
|
18
35
|
//# sourceMappingURL=pg-cost-quota.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PgWriteBehindCounter } from "./write-behind-counter.js";
|
|
2
|
+
/** The counter's table binding for the cumulative cost quota (mirror of the TiDB twin's binding). */
|
|
2
3
|
const COST_QUOTA_TABLE = { table: "cost_quota", keyCol: "scope_key", valCol: "micro" };
|
|
3
4
|
export class PgCostQuota {
|
|
4
5
|
limitMicroUsd;
|
|
@@ -15,6 +16,7 @@ export class PgCostQuota {
|
|
|
15
16
|
add(scopeKey, micro) {
|
|
16
17
|
this.counter.addLocal(scopeKey, micro);
|
|
17
18
|
}
|
|
19
|
+
// write-behind lifecycle (delegated; exposed for the reaper/tests)
|
|
18
20
|
flush() {
|
|
19
21
|
return this.counter.flush();
|
|
20
22
|
}
|
|
@@ -32,6 +34,9 @@ export class PgCostQuota {
|
|
|
32
34
|
this.counter.stop();
|
|
33
35
|
}
|
|
34
36
|
}
|
|
37
|
+
/** PG DDL for the `cost_quota` table (translated from tidb-pool.ts SCHEMA_STATEMENTS: BIGINT same,
|
|
38
|
+
* DATETIME(3)→TIMESTAMPTZ(3), inline `KEY idx_window`→separate CREATE INDEX). DISJOINT from other stores'
|
|
39
|
+
* tables, so a self-contained ensureSchema is safe (the central pg-pool aggregation is done separately). */
|
|
35
40
|
export const PG_COST_QUOTA_SCHEMA = [
|
|
36
41
|
`CREATE TABLE IF NOT EXISTS cost_quota (
|
|
37
42
|
scope_key VARCHAR(190) NOT NULL,
|
|
@@ -42,6 +47,7 @@ export const PG_COST_QUOTA_SCHEMA = [
|
|
|
42
47
|
)`,
|
|
43
48
|
`CREATE INDEX IF NOT EXISTS idx_cost_quota_window ON cost_quota (window_bucket)`,
|
|
44
49
|
];
|
|
50
|
+
/** Idempotent schema apply for the cost_quota table (the PG twin of tidb-pool.ts ensureSchema). */
|
|
45
51
|
export async function ensureSchema(pool) {
|
|
46
52
|
for (const stmt of PG_COST_QUOTA_SCHEMA)
|
|
47
53
|
await pool.query(stmt);
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin re-export shim (design/158 A12 定型半场) — the real implementation collapsed into
|
|
3
|
+
* `file-snapshot-store-sql.ts` (single file, dual dialect). Kept so every existing import path
|
|
4
|
+
* (store-backend.ts, the migration script, the contract/integration/minio-equivalence suites) is
|
|
5
|
+
* untouched: same class name, same ctor arity, same exported surface.
|
|
6
|
+
*/
|
|
1
7
|
export { PgFileSnapshotStore } from "./file-snapshot-store-sql.js";
|
|
2
8
|
//# sourceMappingURL=pg-file-snapshot-store.d.ts.map
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin re-export shim (design/158 A12 定型半场) — the real implementation collapsed into
|
|
3
|
+
* `file-snapshot-store-sql.ts` (single file, dual dialect). Kept so every existing import path
|
|
4
|
+
* (store-backend.ts, the migration script, the contract/integration/minio-equivalence suites) is
|
|
5
|
+
* untouched: same class name, same ctor arity, same exported surface.
|
|
6
|
+
*/
|
|
1
7
|
export { PgFileSnapshotStore } from "./file-snapshot-store-sql.js";
|
|
2
8
|
//# sourceMappingURL=pg-file-snapshot-store.js.map
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL BAKE store — the implementation now lives in the single-file dual-dialect
|
|
3
|
+
* `image-bake-store-sql.ts` (design/158 A12 定型半场), alongside its TiDB twin so the dialect deltas
|
|
4
|
+
* (placeholders, ON CONFLICT, jsonb casts, the admission-statement divergence, the PG-only
|
|
5
|
+
* protocol-byte defenses) read side by side instead of drifting across two files.
|
|
6
|
+
*
|
|
7
|
+
* This file is the historical import path: class name, ctor shape, `PG_IMAGE_BAKE_SCHEMA` and
|
|
8
|
+
* `ensureSchema` are unchanged, so pg-pool.ts / store-backend.ts / the integration suite are untouched.
|
|
9
|
+
*/
|
|
1
10
|
export { PgImageBake, PG_IMAGE_BAKE_SCHEMA, ensurePgImageBakeSchema as ensureSchema } from "./image-bake-store-sql.js";
|
|
2
11
|
export type { BakeStatus, BakeState, BakeErrorCode, BakeRecord, BakeEvent, CreateBakeInput, BakeTerminal, } from "./store-contracts.js";
|
|
3
12
|
//# sourceMappingURL=pg-image-bake.d.ts.map
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL BAKE store — the implementation now lives in the single-file dual-dialect
|
|
3
|
+
* `image-bake-store-sql.ts` (design/158 A12 定型半场), alongside its TiDB twin so the dialect deltas
|
|
4
|
+
* (placeholders, ON CONFLICT, jsonb casts, the admission-statement divergence, the PG-only
|
|
5
|
+
* protocol-byte defenses) read side by side instead of drifting across two files.
|
|
6
|
+
*
|
|
7
|
+
* This file is the historical import path: class name, ctor shape, `PG_IMAGE_BAKE_SCHEMA` and
|
|
8
|
+
* `ensureSchema` are unchanged, so pg-pool.ts / store-backend.ts / the integration suite are untouched.
|
|
9
|
+
*/
|
|
1
10
|
export { PgImageBake, PG_IMAGE_BAKE_SCHEMA, ensurePgImageBakeSchema as ensureSchema } from "./image-bake-store-sql.js";
|
|
2
11
|
//# sourceMappingURL=pg-image-bake.js.map
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL-backed sandbox-image-pool INDEX store — the PG twin of {@link TiDBImageIndex}
|
|
3
|
+
* (src/plugins/tidb-image-index.ts).
|
|
4
|
+
*
|
|
5
|
+
* Thin re-export shim (design/158 A12 定型半场): the real implementation is the single-file dual-dialect
|
|
6
|
+
* `image-index-sql.ts` (`SqlImageIndex` + this file's `PgImageIndex` ctor subclass). Class name, ctor
|
|
7
|
+
* arity, and the exported type/schema surface are UNCHANGED — every consumer (store-backend.ts, pg-pool.ts,
|
|
8
|
+
* the real-DB integration suite) imports from here exactly as before.
|
|
9
|
+
*/
|
|
1
10
|
export { PgImageIndex, PG_IMAGE_INDEX_SCHEMA, ensureSchema } from "./image-index-sql.js";
|
|
2
11
|
export type { ImageNestedBuildMode, ImageCapabilities, ImagePodContract, ImageStatus, ImageVisibility, ImageIndexEntry, ImageIndexUpsert, ImageViewer, ImageListFilter, } from "./store-contracts.js";
|
|
3
12
|
//# sourceMappingURL=pg-image-index.d.ts.map
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL-backed sandbox-image-pool INDEX store — the PG twin of {@link TiDBImageIndex}
|
|
3
|
+
* (src/plugins/tidb-image-index.ts).
|
|
4
|
+
*
|
|
5
|
+
* Thin re-export shim (design/158 A12 定型半场): the real implementation is the single-file dual-dialect
|
|
6
|
+
* `image-index-sql.ts` (`SqlImageIndex` + this file's `PgImageIndex` ctor subclass). Class name, ctor
|
|
7
|
+
* arity, and the exported type/schema surface are UNCHANGED — every consumer (store-backend.ts, pg-pool.ts,
|
|
8
|
+
* the real-DB integration suite) imports from here exactly as before.
|
|
9
|
+
*/
|
|
1
10
|
export { PgImageIndex, PG_IMAGE_INDEX_SCHEMA, ensureSchema } from "./image-index-sql.js";
|
|
2
11
|
//# sourceMappingURL=pg-image-index.js.map
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL outcome ledger — the implementation now lives in the single-file dual-dialect
|
|
3
|
+
* `outcome-ledger-sql.ts` (design/158 A12 定型半场), alongside its TiDB twin so the dialect deltas
|
|
4
|
+
* (placeholders, JSON encode, the AVG boolean-coercion divergence) read side by side instead of
|
|
5
|
+
* drifting across two files.
|
|
6
|
+
*
|
|
7
|
+
* This file is the historical import path: class name, `PG_OUTCOME_LEDGER_SCHEMA` and `ensureSchema`
|
|
8
|
+
* are unchanged, so pg-pool.ts / store-backend.ts / the integration suite are untouched.
|
|
9
|
+
*/
|
|
1
10
|
export { PgOutcomeLedger, PG_OUTCOME_LEDGER_SCHEMA, ensurePgOutcomeLedgerSchema as ensureSchema, } from "./outcome-ledger-sql.js";
|
|
2
11
|
export type { TaskOutcome, RunStatus } from "./outcome-ledger-sql.js";
|
|
3
12
|
//# sourceMappingURL=pg-outcome-ledger.d.ts.map
|