@sema-agent/server 1.322.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.
Files changed (539) hide show
  1. package/dist/approval-hmac.d.ts +40 -0
  2. package/dist/approval-hmac.js +67 -0
  3. package/dist/approval.d.ts +31 -0
  4. package/dist/approval.js +72 -4
  5. package/dist/audit.d.ts +26 -0
  6. package/dist/audit.js +40 -1
  7. package/dist/auth-bridge.d.ts +10 -0
  8. package/dist/auth-bridge.js +47 -4
  9. package/dist/auth-keys.d.ts +19 -0
  10. package/dist/auth-keys.js +13 -0
  11. package/dist/bake-runner/main.d.ts +5 -0
  12. package/dist/bake-runner/main.js +43 -4
  13. package/dist/bake-runner/protocol.d.ts +57 -0
  14. package/dist/bake-runner/protocol.js +58 -3
  15. package/dist/bake-runner/runner.d.ts +54 -0
  16. package/dist/bake-runner/runner.js +87 -5
  17. package/dist/bench/l8/artifact.d.ts +63 -0
  18. package/dist/bench/l8/artifact.js +61 -2
  19. package/dist/bench/l8/escape.d.ts +36 -0
  20. package/dist/bench/l8/escape.js +25 -0
  21. package/dist/bench/l8/index.d.ts +14 -0
  22. package/dist/bench/l8/index.js +14 -0
  23. package/dist/bench/l8/probes.d.ts +74 -0
  24. package/dist/bench/l8/probes.js +60 -0
  25. package/dist/bench/l8/run-probes.d.ts +43 -0
  26. package/dist/bench/l8/run-probes.js +45 -2
  27. package/dist/bench/s1/arms.d.ts +126 -0
  28. package/dist/bench/s1/arms.js +188 -13
  29. package/dist/bench/s1/live-deps.d.ts +66 -0
  30. package/dist/bench/s1/live-deps.js +249 -11
  31. package/dist/bench/s1/oracle.d.ts +49 -0
  32. package/dist/bench/s1/oracle.js +36 -1
  33. package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
  34. package/dist/bench/s1/repair-oracle-adapter.js +30 -0
  35. package/dist/bench/s1/reviewer.d.ts +38 -0
  36. package/dist/bench/s1/reviewer.js +34 -0
  37. package/dist/bench/s1/row.d.ts +77 -0
  38. package/dist/bench/s1/row.js +62 -0
  39. package/dist/bench/s1/run-firm.d.ts +47 -0
  40. package/dist/bench/s1/run-firm.js +70 -4
  41. package/dist/bench/s1/runner-ctx.d.ts +71 -0
  42. package/dist/bench/s1/runner-ctx.js +36 -0
  43. package/dist/bench/s1/tasks.d.ts +108 -0
  44. package/dist/bench/s1/tasks.js +115 -0
  45. package/dist/boot-reclaim.d.ts +19 -0
  46. package/dist/boot-reclaim.js +20 -0
  47. package/dist/brain.d.ts +25 -0
  48. package/dist/brain.js +61 -1
  49. package/dist/budget.d.ts +66 -0
  50. package/dist/budget.js +128 -4
  51. package/dist/capabilities/builtin-tools.d.ts +3 -0
  52. package/dist/capabilities/builtin-tools.js +3 -0
  53. package/dist/capabilities/center-plugins.d.ts +17 -1
  54. package/dist/capabilities/center-plugins.js +45 -4
  55. package/dist/capabilities/center-prompts.d.ts +46 -0
  56. package/dist/capabilities/center-prompts.js +57 -3
  57. package/dist/capabilities/code-review-council.d.ts +28 -0
  58. package/dist/capabilities/code-review-council.js +40 -7
  59. package/dist/capabilities/collab-wire.d.ts +2 -0
  60. package/dist/capabilities/collab-workflows.d.ts +7 -0
  61. package/dist/capabilities/collab-workflows.js +44 -1
  62. package/dist/capabilities/oa-tools.d.ts +6 -0
  63. package/dist/capabilities/oa-tools.js +10 -0
  64. package/dist/capabilities/prompt.d.ts +14 -0
  65. package/dist/capabilities/prompt.js +14 -0
  66. package/dist/capabilities/prompts/code-review.d.ts +14 -0
  67. package/dist/capabilities/prompts/code-review.js +14 -0
  68. package/dist/capabilities/prompts/identity.d.ts +6 -0
  69. package/dist/capabilities/prompts/identity.js +6 -0
  70. package/dist/capabilities/prompts/team.d.ts +4 -0
  71. package/dist/capabilities/prompts/team.js +4 -0
  72. package/dist/capabilities/repo-tools.d.ts +11 -0
  73. package/dist/capabilities/repo-tools.js +8 -0
  74. package/dist/capabilities/sandbox-file-send.d.ts +95 -0
  75. package/dist/capabilities/sandbox-file-send.js +91 -3
  76. package/dist/capabilities/scenarios.d.ts +130 -0
  77. package/dist/capabilities/scenarios.js +180 -7
  78. package/dist/capabilities/select-environment-tool.d.ts +7 -0
  79. package/dist/capabilities/select-environment-tool.js +30 -0
  80. package/dist/capabilities/send-user-file-tool.d.ts +33 -0
  81. package/dist/capabilities/send-user-file-tool.js +65 -1
  82. package/dist/capabilities/skills.d.ts +29 -0
  83. package/dist/capabilities/skills.js +13 -2
  84. package/dist/capabilities/team.d.ts +22 -0
  85. package/dist/capabilities/team.js +22 -2
  86. package/dist/capabilities/tool-defer.d.ts +26 -0
  87. package/dist/capabilities/tool-defer.js +3 -0
  88. package/dist/config-center/apply-effective.d.ts +65 -0
  89. package/dist/config-center/apply-effective.js +204 -12
  90. package/dist/config-center/http-client.d.ts +34 -0
  91. package/dist/config-center/http-client.js +68 -0
  92. package/dist/config-center/restart-signal.d.ts +22 -0
  93. package/dist/config-center/restart-signal.js +39 -0
  94. package/dist/config-center/skills-mcp.d.ts +20 -1
  95. package/dist/config-center/skills-mcp.js +42 -7
  96. package/dist/config-center/types.d.ts +92 -1
  97. package/dist/config-lkg.d.ts +12 -0
  98. package/dist/config-lkg.js +41 -0
  99. package/dist/config-provider.d.ts +78 -0
  100. package/dist/config-provider.js +165 -2
  101. package/dist/config-types.d.ts +546 -0
  102. package/dist/config.d.ts +64 -0
  103. package/dist/config.js +455 -60
  104. package/dist/degenerate-instrument.d.ts +38 -0
  105. package/dist/degenerate-instrument.js +55 -3
  106. package/dist/elicitation.d.ts +39 -0
  107. package/dist/elicitation.js +87 -3
  108. package/dist/env-facts.d.ts +61 -0
  109. package/dist/env-facts.js +73 -7
  110. package/dist/fleet/fleet-bus.d.ts +185 -0
  111. package/dist/fleet/fleet-bus.js +333 -27
  112. package/dist/fleet/subagent-tail-bus.d.ts +11 -0
  113. package/dist/fleet/subagent-tail-bus.js +33 -2
  114. package/dist/fleet-client.d.ts +38 -0
  115. package/dist/fleet-client.js +44 -9
  116. package/dist/fleet-lease.d.ts +46 -0
  117. package/dist/fleet-lease.js +73 -5
  118. package/dist/hooks/branch-transcript.d.ts +8 -0
  119. package/dist/hooks/branch-transcript.js +33 -0
  120. package/dist/hooks/cc-stop-prompt.d.ts +42 -0
  121. package/dist/hooks/cc-stop-prompt.js +43 -1
  122. package/dist/hooks/hook-llm.d.ts +15 -0
  123. package/dist/hooks/hook-llm.js +47 -0
  124. package/dist/hooks/hook-runner.d.ts +89 -0
  125. package/dist/hooks/hook-runner.js +327 -18
  126. package/dist/http/idempotency.d.ts +31 -0
  127. package/dist/http/idempotency.js +34 -0
  128. package/dist/http/principal-gate.d.ts +17 -0
  129. package/dist/http/principal-gate.js +35 -3
  130. package/dist/http/route-ctx.d.ts +36 -0
  131. package/dist/http/routes/approvals-assistant.d.ts +25 -0
  132. package/dist/http/routes/approvals-assistant.js +253 -23
  133. package/dist/http/routes/attachments.js +22 -4
  134. package/dist/http/routes/capabilities.d.ts +7 -0
  135. package/dist/http/routes/capabilities.js +202 -1
  136. package/dist/http/routes/fleet.d.ts +6 -0
  137. package/dist/http/routes/fleet.js +94 -5
  138. package/dist/http/routes/images.d.ts +17 -0
  139. package/dist/http/routes/images.js +222 -14
  140. package/dist/http/routes/leader.d.ts +7 -0
  141. package/dist/http/routes/leader.js +10 -0
  142. package/dist/http/routes/memory-policy.d.ts +6 -0
  143. package/dist/http/routes/memory-policy.js +38 -6
  144. package/dist/http/routes/notify-wake.d.ts +10 -0
  145. package/dist/http/routes/notify-wake.js +19 -3
  146. package/dist/http/routes/observability.d.ts +6 -0
  147. package/dist/http/routes/observability.js +19 -2
  148. package/dist/http/routes/runs.d.ts +15 -0
  149. package/dist/http/routes/runs.js +464 -41
  150. package/dist/http/routes/session-sync.d.ts +15 -0
  151. package/dist/http/routes/session-sync.js +229 -19
  152. package/dist/http/routes/sessions-list.d.ts +6 -0
  153. package/dist/http/routes/sessions-list.js +35 -4
  154. package/dist/http/routes/sessions.d.ts +14 -0
  155. package/dist/http/routes/sessions.js +176 -31
  156. package/dist/http/routes/side-query.d.ts +8 -0
  157. package/dist/http/routes/side-query.js +26 -1
  158. package/dist/http/routes/tasks.d.ts +18 -0
  159. package/dist/http/routes/tasks.js +501 -38
  160. package/dist/http/routes/trace-usage.d.ts +10 -0
  161. package/dist/http/routes/trace-usage.js +66 -14
  162. package/dist/http/routes/workflows.d.ts +12 -0
  163. package/dist/http/routes/workflows.js +180 -19
  164. package/dist/http/run-meta.d.ts +11 -0
  165. package/dist/http/run-meta.js +6 -0
  166. package/dist/http/send.d.ts +19 -0
  167. package/dist/http/send.js +11 -0
  168. package/dist/http/server.d.ts +255 -0
  169. package/dist/http/server.js +921 -75
  170. package/dist/http/sse-log.d.ts +15 -0
  171. package/dist/http/sse-log.js +16 -0
  172. package/dist/http/tar.d.ts +9 -0
  173. package/dist/http/tar.js +21 -5
  174. package/dist/http/wire-gate.d.ts +9 -0
  175. package/dist/http/wire-gate.js +9 -0
  176. package/dist/http/wire-types.d.ts +187 -0
  177. package/dist/http/workspace-content.d.ts +8 -0
  178. package/dist/http/workspace-content.js +10 -0
  179. package/dist/images/bake-validate.d.ts +63 -0
  180. package/dist/images/bake-validate.js +71 -1
  181. package/dist/images/manifest.d.ts +19 -0
  182. package/dist/images/manifest.js +6 -1
  183. package/dist/index.d.ts +1 -5
  184. package/dist/index.js +10 -5
  185. package/dist/key-resolver.d.ts +23 -0
  186. package/dist/key-resolver.js +27 -2
  187. package/dist/leader/diffout.d.ts +23 -0
  188. package/dist/leader/diffout.js +8 -1
  189. package/dist/leader/diffup.d.ts +32 -0
  190. package/dist/leader/diffup.js +43 -0
  191. package/dist/leader/endpoint.d.ts +20 -0
  192. package/dist/leader/endpoint.js +25 -2
  193. package/dist/leader/fanout.d.ts +60 -0
  194. package/dist/leader/fanout.js +29 -3
  195. package/dist/leader/grader-env-factory.d.ts +74 -0
  196. package/dist/leader/grader-env-factory.js +62 -3
  197. package/dist/leader/leader.d.ts +97 -0
  198. package/dist/leader/leader.js +151 -4
  199. package/dist/leader/merge.d.ts +94 -0
  200. package/dist/leader/merge.js +112 -9
  201. package/dist/leader/planner.d.ts +52 -0
  202. package/dist/leader/planner.js +47 -3
  203. package/dist/leader/repair-oracle.d.ts +61 -0
  204. package/dist/leader/repair-oracle.js +59 -1
  205. package/dist/leader/repair-wire.d.ts +78 -0
  206. package/dist/leader/repair-wire.js +79 -2
  207. package/dist/leader/wire.d.ts +79 -0
  208. package/dist/leader/wire.js +255 -8
  209. package/dist/lsp/e2b-bridge.d.ts +16 -0
  210. package/dist/lsp/e2b-bridge.js +32 -4
  211. package/dist/lsp/e2b-manager.d.ts +10 -0
  212. package/dist/lsp/e2b-manager.js +18 -2
  213. package/dist/lsp/lsp-frames.d.ts +12 -0
  214. package/dist/lsp/lsp-frames.js +12 -0
  215. package/dist/lsp/manager.d.ts +12 -0
  216. package/dist/lsp/manager.js +35 -2
  217. package/dist/lsp/types.d.ts +10 -0
  218. package/dist/lsp/ws-transport.d.ts +12 -0
  219. package/dist/lsp/ws-transport.js +53 -5
  220. package/dist/lsp-evict.d.ts +14 -0
  221. package/dist/lsp-evict.js +15 -1
  222. package/dist/main.js +2132 -96
  223. package/dist/memory-export.d.ts +1 -0
  224. package/dist/memory-export.js +4 -0
  225. package/dist/memory-scope.d.ts +49 -0
  226. package/dist/memory-scope.js +87 -4
  227. package/dist/memory-sync-client.d.ts +24 -0
  228. package/dist/memory-sync-client.js +41 -2
  229. package/dist/memory-sync.d.ts +23 -0
  230. package/dist/memory-sync.js +70 -1
  231. package/dist/model-select.d.ts +39 -0
  232. package/dist/model-select.js +42 -1
  233. package/dist/observability/cost-quota.d.ts +20 -0
  234. package/dist/observability/cost-quota.js +4 -0
  235. package/dist/observability/cost-taxonomy.d.ts +45 -0
  236. package/dist/observability/cost-taxonomy.js +34 -0
  237. package/dist/observability/logger.d.ts +1 -0
  238. package/dist/observability/logger.js +6 -0
  239. package/dist/observability/metrics.d.ts +13 -0
  240. package/dist/observability/metrics.js +63 -0
  241. package/dist/observability/otel-exporter.d.ts +9 -0
  242. package/dist/observability/otel-exporter.js +11 -3
  243. package/dist/observability/principal-context.d.ts +9 -0
  244. package/dist/observability/principal-context.js +9 -0
  245. package/dist/observability/prompt-manifest.d.ts +37 -0
  246. package/dist/observability/prompt-manifest.js +35 -1
  247. package/dist/observability/rate-limit.d.ts +10 -0
  248. package/dist/observability/rate-limit.js +1 -0
  249. package/dist/observability/tool-trace.d.ts +24 -0
  250. package/dist/observability/tool-trace.js +41 -1
  251. package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
  252. package/dist/orchestration/hardened-vm-runner.js +119 -4
  253. package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
  254. package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
  255. package/dist/orchestration/hardened-vm-worker.js +27 -0
  256. package/dist/orchestration/subagent-steer.d.ts +44 -0
  257. package/dist/orchestration/subagent-steer.js +45 -1
  258. package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
  259. package/dist/orchestration/workflow-agent-steer.js +80 -1
  260. package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
  261. package/dist/orchestration/workflow-completion-inbox.js +283 -32
  262. package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
  263. package/dist/orchestration/workflow-notify-journal.js +187 -13
  264. package/dist/parked-decide.d.ts +61 -0
  265. package/dist/parked-decide.js +58 -1
  266. package/dist/per-task-image.d.ts +54 -0
  267. package/dist/per-task-image.js +41 -0
  268. package/dist/plan-cache-probe.d.ts +35 -0
  269. package/dist/plan-cache-probe.js +18 -3
  270. package/dist/plugins/approval-exemption-store.d.ts +7 -0
  271. package/dist/plugins/approval-exemption-store.js +28 -2
  272. package/dist/plugins/approval-store-sql.d.ts +64 -0
  273. package/dist/plugins/approval-store-sql.js +32 -0
  274. package/dist/plugins/background-agent-store-sql.d.ts +55 -0
  275. package/dist/plugins/background-agent-store-sql.js +91 -4
  276. package/dist/plugins/background-shell-support.d.ts +98 -0
  277. package/dist/plugins/background-shell-support.js +117 -13
  278. package/dist/plugins/blob-backend.d.ts +104 -0
  279. package/dist/plugins/blob-backend.js +163 -6
  280. package/dist/plugins/breaker-state-sql.d.ts +65 -1
  281. package/dist/plugins/breaker-state-sql.js +46 -8
  282. package/dist/plugins/caching-session-store.d.ts +42 -0
  283. package/dist/plugins/caching-session-store.js +63 -3
  284. package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
  285. package/dist/plugins/checkpoint-store-sql.js +239 -11
  286. package/dist/plugins/file-outcome-sink.d.ts +4 -0
  287. package/dist/plugins/file-outcome-sink.js +9 -0
  288. package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
  289. package/dist/plugins/file-resume-anchor-store.js +43 -4
  290. package/dist/plugins/file-run-store.d.ts +90 -0
  291. package/dist/plugins/file-run-store.js +145 -13
  292. package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
  293. package/dist/plugins/file-snapshot-store-sql.js +178 -10
  294. package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
  295. package/dist/plugins/file-workflow-journal-store.js +10 -0
  296. package/dist/plugins/fork-routing-session-store.d.ts +47 -0
  297. package/dist/plugins/fork-routing-session-store.js +51 -3
  298. package/dist/plugins/host-platform.d.ts +69 -0
  299. package/dist/plugins/host-platform.js +81 -2
  300. package/dist/plugins/image-bake-store-sql.d.ts +136 -1
  301. package/dist/plugins/image-bake-store-sql.js +241 -7
  302. package/dist/plugins/image-index-sql.d.ts +46 -0
  303. package/dist/plugins/image-index-sql.js +113 -4
  304. package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
  305. package/dist/plugins/k8s-bg-scripts.js +88 -4
  306. package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
  307. package/dist/plugins/k8s-exec-protocol.js +41 -0
  308. package/dist/plugins/local-checkpoint-store.d.ts +40 -0
  309. package/dist/plugins/local-checkpoint-store.js +86 -7
  310. package/dist/plugins/local-session-store.d.ts +157 -0
  311. package/dist/plugins/local-session-store.js +289 -34
  312. package/dist/plugins/local-task-attachment-store.js +14 -2
  313. package/dist/plugins/mailbox-store-sql.d.ts +38 -0
  314. package/dist/plugins/mailbox-store-sql.js +39 -6
  315. package/dist/plugins/memory-engine-pg.d.ts +30 -0
  316. package/dist/plugins/memory-engine-pg.js +122 -4
  317. package/dist/plugins/memory-engine-tidb.d.ts +26 -0
  318. package/dist/plugins/memory-engine-tidb.js +115 -5
  319. package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
  320. package/dist/plugins/memory-engine-vector-util.js +5 -0
  321. package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
  322. package/dist/plugins/memory-resume-anchor-store.js +17 -0
  323. package/dist/plugins/memory-run-store.d.ts +63 -0
  324. package/dist/plugins/memory-run-store.js +73 -8
  325. package/dist/plugins/memory-session-policy-store.d.ts +17 -0
  326. package/dist/plugins/memory-session-policy-store.js +17 -0
  327. package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
  328. package/dist/plugins/memory-sync-store-pg.js +45 -2
  329. package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
  330. package/dist/plugins/memory-sync-store-tidb.js +31 -1
  331. package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
  332. package/dist/plugins/outcome-ledger-sql.js +97 -3
  333. package/dist/plugins/pg-approval-store.d.ts +7 -0
  334. package/dist/plugins/pg-approval-store.js +7 -0
  335. package/dist/plugins/pg-breaker-state.d.ts +6 -0
  336. package/dist/plugins/pg-breaker-state.js +6 -0
  337. package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
  338. package/dist/plugins/pg-checkpoint-store.js +8 -0
  339. package/dist/plugins/pg-cost-quota.d.ts +17 -0
  340. package/dist/plugins/pg-cost-quota.js +6 -0
  341. package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
  342. package/dist/plugins/pg-file-snapshot-store.js +6 -0
  343. package/dist/plugins/pg-image-bake.d.ts +9 -0
  344. package/dist/plugins/pg-image-bake.js +9 -0
  345. package/dist/plugins/pg-image-index.d.ts +9 -0
  346. package/dist/plugins/pg-image-index.js +9 -0
  347. package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
  348. package/dist/plugins/pg-outcome-ledger.js +9 -0
  349. package/dist/plugins/pg-pool.d.ts +50 -0
  350. package/dist/plugins/pg-pool.js +78 -0
  351. package/dist/plugins/pg-query.d.ts +11 -0
  352. package/dist/plugins/pg-rate-limiter.d.ts +23 -0
  353. package/dist/plugins/pg-rate-limiter.js +12 -2
  354. package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
  355. package/dist/plugins/pg-resume-anchor-store.js +5 -0
  356. package/dist/plugins/pg-run-store.d.ts +7 -0
  357. package/dist/plugins/pg-run-store.js +7 -0
  358. package/dist/plugins/pg-safe-json.d.ts +13 -0
  359. package/dist/plugins/pg-safe-json.js +40 -4
  360. package/dist/plugins/pg-session-policy-store.d.ts +5 -0
  361. package/dist/plugins/pg-session-policy-store.js +5 -0
  362. package/dist/plugins/pg-session-storage.d.ts +72 -0
  363. package/dist/plugins/pg-session-storage.js +152 -20
  364. package/dist/plugins/pg-session-store.d.ts +10 -0
  365. package/dist/plugins/pg-session-store.js +10 -0
  366. package/dist/plugins/pg-tool-result-store.d.ts +7 -0
  367. package/dist/plugins/pg-tool-result-store.js +7 -0
  368. package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
  369. package/dist/plugins/pg-workflow-journal-store.js +7 -0
  370. package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
  371. package/dist/plugins/pg-workflow-run-store.js +7 -0
  372. package/dist/plugins/posix-shell-fs.d.ts +3 -0
  373. package/dist/plugins/posix-shell-fs.js +31 -1
  374. package/dist/plugins/remote-env-adb.d.ts +25 -0
  375. package/dist/plugins/remote-env-adb.js +95 -12
  376. package/dist/plugins/remote-env-e2b.d.ts +146 -0
  377. package/dist/plugins/remote-env-e2b.js +371 -40
  378. package/dist/plugins/remote-env-file-error.d.ts +34 -0
  379. package/dist/plugins/remote-env-file-error.js +37 -0
  380. package/dist/plugins/remote-env-host.d.ts +151 -0
  381. package/dist/plugins/remote-env-host.js +468 -70
  382. package/dist/plugins/remote-env-k8s.d.ts +135 -0
  383. package/dist/plugins/remote-env-k8s.js +318 -32
  384. package/dist/plugins/remote-env-local-docker.d.ts +65 -0
  385. package/dist/plugins/remote-env-local-docker.js +149 -24
  386. package/dist/plugins/remote-env-ssh.d.ts +35 -0
  387. package/dist/plugins/remote-env-ssh.js +117 -20
  388. package/dist/plugins/remote-scratchpad.d.ts +38 -0
  389. package/dist/plugins/remote-scratchpad.js +32 -2
  390. package/dist/plugins/remote-shell.d.ts +22 -0
  391. package/dist/plugins/remote-shell.js +27 -1
  392. package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
  393. package/dist/plugins/resume-anchor-store-sql.js +11 -0
  394. package/dist/plugins/roster-store-sql.d.ts +27 -0
  395. package/dist/plugins/roster-store-sql.js +54 -0
  396. package/dist/plugins/run-store-sql.d.ts +194 -0
  397. package/dist/plugins/run-store-sql.js +210 -9
  398. package/dist/plugins/s3-presign.d.ts +20 -0
  399. package/dist/plugins/s3-presign.js +49 -2
  400. package/dist/plugins/scheduler-support.d.ts +12 -0
  401. package/dist/plugins/scheduler-support.js +75 -3
  402. package/dist/plugins/send-file-ledger.d.ts +15 -0
  403. package/dist/plugins/send-file-ledger.js +53 -4
  404. package/dist/plugins/send-user-file.d.ts +77 -0
  405. package/dist/plugins/send-user-file.js +92 -4
  406. package/dist/plugins/session-policy-store-sql.d.ts +15 -0
  407. package/dist/plugins/session-policy-store-sql.js +75 -3
  408. package/dist/plugins/session-store.d.ts +45 -0
  409. package/dist/plugins/session-store.js +51 -0
  410. package/dist/plugins/sql-driver.d.ts +77 -0
  411. package/dist/plugins/sql-driver.js +4 -0
  412. package/dist/plugins/sql-escape.d.ts +8 -0
  413. package/dist/plugins/sql-escape.js +8 -0
  414. package/dist/plugins/sql-row-helpers.d.ts +25 -0
  415. package/dist/plugins/sql-row-helpers.js +25 -0
  416. package/dist/plugins/store-backend.d.ts +103 -0
  417. package/dist/plugins/store-backend.js +120 -27
  418. package/dist/plugins/store-contracts.d.ts +62 -0
  419. package/dist/plugins/store-contracts.js +3 -0
  420. package/dist/plugins/task-attachment-store.d.ts +60 -0
  421. package/dist/plugins/task-attachment-store.js +49 -3
  422. package/dist/plugins/task-list-store-sql.d.ts +25 -0
  423. package/dist/plugins/task-list-store-sql.js +21 -0
  424. package/dist/plugins/tidb-approval-store.d.ts +6 -0
  425. package/dist/plugins/tidb-approval-store.js +6 -0
  426. package/dist/plugins/tidb-breaker-state.d.ts +5 -0
  427. package/dist/plugins/tidb-breaker-state.js +5 -0
  428. package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
  429. package/dist/plugins/tidb-checkpoint-store.js +7 -0
  430. package/dist/plugins/tidb-cost-quota.d.ts +6 -0
  431. package/dist/plugins/tidb-cost-quota.js +1 -0
  432. package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
  433. package/dist/plugins/tidb-file-snapshot-store.js +6 -0
  434. package/dist/plugins/tidb-image-bake.d.ts +8 -0
  435. package/dist/plugins/tidb-image-bake.js +8 -0
  436. package/dist/plugins/tidb-image-index.d.ts +8 -0
  437. package/dist/plugins/tidb-image-index.js +8 -0
  438. package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
  439. package/dist/plugins/tidb-outcome-ledger.js +10 -0
  440. package/dist/plugins/tidb-pool.d.ts +56 -0
  441. package/dist/plugins/tidb-pool.js +181 -1
  442. package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
  443. package/dist/plugins/tidb-rate-limiter.js +5 -2
  444. package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
  445. package/dist/plugins/tidb-resume-anchor-store.js +5 -0
  446. package/dist/plugins/tidb-run-store.d.ts +7 -0
  447. package/dist/plugins/tidb-run-store.js +7 -0
  448. package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
  449. package/dist/plugins/tidb-session-policy-store.js +5 -0
  450. package/dist/plugins/tidb-session-storage.d.ts +43 -0
  451. package/dist/plugins/tidb-session-storage.js +62 -3
  452. package/dist/plugins/tidb-session-store.d.ts +142 -0
  453. package/dist/plugins/tidb-session-store.js +264 -16
  454. package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
  455. package/dist/plugins/tidb-tool-result-store.js +7 -0
  456. package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
  457. package/dist/plugins/tidb-workflow-journal-store.js +7 -0
  458. package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
  459. package/dist/plugins/tidb-workflow-run-store.js +8 -0
  460. package/dist/plugins/tool-result-store-sql.d.ts +58 -0
  461. package/dist/plugins/tool-result-store-sql.js +38 -2
  462. package/dist/plugins/web-search.d.ts +35 -0
  463. package/dist/plugins/web-search.js +45 -9
  464. package/dist/plugins/workflow-journal-limits.d.ts +10 -0
  465. package/dist/plugins/workflow-journal-limits.js +10 -0
  466. package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
  467. package/dist/plugins/workflow-journal-store-sql.js +59 -3
  468. package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
  469. package/dist/plugins/workflow-run-store-sql.js +84 -6
  470. package/dist/plugins/worktree-isolation.d.ts +45 -0
  471. package/dist/plugins/worktree-isolation.js +105 -6
  472. package/dist/plugins/write-behind-counter.d.ts +56 -1
  473. package/dist/plugins/write-behind-counter.js +53 -14
  474. package/dist/principal-jwt.d.ts +24 -0
  475. package/dist/principal-jwt.js +60 -5
  476. package/dist/project-memory.d.ts +22 -0
  477. package/dist/project-memory.js +144 -15
  478. package/dist/prompts-domain-validate.d.ts +28 -0
  479. package/dist/prompts-domain-validate.js +42 -1
  480. package/dist/question.d.ts +33 -0
  481. package/dist/question.js +69 -2
  482. package/dist/resource-suspend.d.ts +21 -0
  483. package/dist/resource-suspend.js +16 -0
  484. package/dist/router/route-orchestration.d.ts +78 -0
  485. package/dist/router/route-orchestration.js +77 -0
  486. package/dist/run-local.d.ts +32 -0
  487. package/dist/run-local.js +172 -8
  488. package/dist/runs.d.ts +189 -4
  489. package/dist/runs.js +465 -24
  490. package/dist/runtime-caps-resolver.d.ts +106 -0
  491. package/dist/runtime-caps-resolver.js +89 -4
  492. package/dist/runtime-governance.d.ts +84 -0
  493. package/dist/runtime-governance.js +127 -1
  494. package/dist/sandbox-pkg-source.d.ts +23 -0
  495. package/dist/sandbox-pkg-source.js +37 -0
  496. package/dist/sealed-key.d.ts +54 -0
  497. package/dist/sealed-key.js +68 -3
  498. package/dist/security.d.ts +108 -0
  499. package/dist/security.js +145 -6
  500. package/dist/sema-registry.d.ts +21 -0
  501. package/dist/sema-registry.js +21 -0
  502. package/dist/session-leaf-bus.d.ts +31 -0
  503. package/dist/session-leaf-bus.js +32 -0
  504. package/dist/session-sync-content.d.ts +46 -0
  505. package/dist/session-sync-content.js +47 -1
  506. package/dist/session-sync-kernel.d.ts +89 -0
  507. package/dist/session-sync-kernel.js +48 -3
  508. package/dist/session-sync.d.ts +125 -0
  509. package/dist/session-sync.js +181 -8
  510. package/dist/session-titler.d.ts +26 -0
  511. package/dist/session-titler.js +41 -7
  512. package/dist/session-watch.d.ts +53 -1
  513. package/dist/session-watch.js +73 -9
  514. package/dist/sighup-idle.d.ts +30 -0
  515. package/dist/sighup-idle.js +12 -1
  516. package/dist/spec-fields.d.ts +91 -3
  517. package/dist/spec-fields.js +116 -4
  518. package/dist/task-cwd.d.ts +50 -0
  519. package/dist/task-cwd.js +68 -1
  520. package/dist/task-mcp.d.ts +47 -0
  521. package/dist/task-mcp.js +29 -0
  522. package/dist/task-settings.d.ts +175 -0
  523. package/dist/task-settings.js +226 -11
  524. package/dist/task-workflow.d.ts +67 -0
  525. package/dist/task-workflow.js +75 -8
  526. package/dist/tool-approval.d.ts +91 -0
  527. package/dist/tool-approval.js +215 -0
  528. package/dist/trace/artifacts.d.ts +9 -0
  529. package/dist/trace/artifacts.js +30 -5
  530. package/dist/trace/core-keyset-guard.d.ts +18 -0
  531. package/dist/trace/ledger-sink.d.ts +43 -0
  532. package/dist/trace/ledger-sink.js +64 -5
  533. package/dist/trace/project.d.ts +133 -0
  534. package/dist/trace/project.js +189 -2
  535. package/dist/trace/redact.d.ts +19 -0
  536. package/dist/trace/redact.js +66 -9
  537. package/dist/usage-analytics.d.ts +26 -0
  538. package/dist/usage-analytics.js +26 -3
  539. package/package.json +1 -1
@@ -1,2 +1,11 @@
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
  //# sourceMappingURL=pg-outcome-ledger.js.map
@@ -1,7 +1,57 @@
1
+ /**
2
+ * PostgreSQL pool + central schema — the PG sibling of tidb-pool.ts, for the second run-store backend
3
+ * (clay 2026-06-21). Schema ownership is CENTRAL (one ensurePgSchema, like tidb-pool's SCHEMA_STATEMENTS) — PG
4
+ * stores assume the tables exist and NEVER create their own (a per-store `CREATE TABLE IF NOT EXISTS` is
5
+ * first-writer-wins, so a trimmed table would shadow the full one and drop columns).
6
+ *
7
+ * Dialect deltas vs the MySQL DDL in tidb-pool.ts: JSON→JSONB, DATETIME(3)→TIMESTAMPTZ(3), TINYINT(1)→SMALLINT,
8
+ * inline `KEY …`→separate `CREATE INDEX`. checkpoint timestamps stay epoch-ms BIGINT (core's Checkpoint uses ms),
9
+ * matching the TiDB schema byte-for-byte semantically. Only the tables PG backends implement so far are listed
10
+ * (run-store + checkpoint); the remaining tidb-* tables are added as their PG stores land (tracked).
11
+ *
12
+ * ─────────────────────────────── SCHEMA POLICY (clay 裁 2026-07-26) ───────────────────────────────
13
+ * THIS CODE IS THE SINGLE SOURCE OF TRUTH for the PG schema. The stack is not yet in production and runs
14
+ * against a single local operator's database, so a schema change is DROP-AND-RECREATE (drop the database,
15
+ * boot, `ensurePgSchema` rebuilds it) — NOT an in-place migration.
16
+ *
17
+ * Consequence, and it is a hard rule: **do NOT add new `ALTER TABLE` seams here.** Every column / default /
18
+ * constraint change is folded into its own `CREATE TABLE`, and this array stays pure `CREATE TABLE` +
19
+ * `CREATE INDEX`. The historical additive-ALTER seams were folded in on 2026-07-26 (they had all decayed
20
+ * into permanent no-ops — the CREATEs already carried the columns).
21
+ *
22
+ * Because the seams are gone, the semantics they used to document now live as inline `--` comments ON THE
23
+ * COLUMN inside the CREATE, not as TypeScript comments outside the template literal: the full-set SQL
24
+ * baseline `docs/schema/baseline-pg.sql` is GENERATED from these statement strings, so only what is inside
25
+ * the SQL survives the export. The baseline is a derived artifact — regenerate it, never hand-edit it.
26
+ */
1
27
  import pg from "pg";
2
28
  import type { ServiceConfig } from "../config-types.js";
3
29
  export declare const PG_SCHEMA_STATEMENTS: readonly string[];
30
+ /** Build the pg PoolConfig from PG config (pure → unit-testable apart from the live connection) — the PG twin of
31
+ * tidbPoolOptions. `dbQueryTimeoutMs` (DB_QUERY_TIMEOUT_MS, S9 deeper fix) arms a POOL-WIDE per-query ceiling on
32
+ * every client the pool hands out, BOTH sides:
33
+ * - `statement_timeout` = T: SERVER-side cancel (sent as a startup parameter) — frees the server's resources
34
+ * and surfaces the canonical 57014 error on any statement that runs past T;
35
+ * - `query_timeout` = T + 5s: CLIENT-side read-timeout backstop for the cases the server can't answer at all
36
+ * (dead network / hung server — the S9 hang class). Slightly ABOVE statement_timeout on purpose, so the
37
+ * server's clean cancel normally wins and the client timer only fires when no response ever arrives (a
38
+ * query_timeout rejection makes pg-pool DESTROY that client, discarding the poisoned connection).
39
+ * Unset = both off (byte-compat: legit heavyweight statements — boot DDL, ≤64 MiB snapshot-blob rows — make a
40
+ * universal default unsafe; the S9 write-behind counter face carries its own always-on per-query timeout). */
4
41
  export declare function pgPoolOptions(pgCfg: NonNullable<ServiceConfig["pg"]>, dbQueryTimeoutMs?: number): pg.PoolConfig;
42
+ /** Create the PG pool from a connection string (or pg.PoolConfig). Thin — production backend-selection wiring
43
+ * (a ServiceConfig.pg sibling of .tidb) is a tracked follow-on. */
5
44
  export declare function createPgPool(opts: string | pg.PoolConfig): pg.Pool;
45
+ /** Idempotent central schema apply (the PG twin of tidb-pool.ts ensureSchema): the run/checkpoint tables here +
46
+ * every PG store's own (disjoint) tables. Order is irrelevant (CREATE IF NOT EXISTS, no cross-table FKs).
47
+ *
48
+ * Concurrency: callers run this concurrently — tests fan ALL integration suites out in parallel (each beforeAll
49
+ * calls ensurePgSchema), and in production every replica calls it at boot. Concurrent DDL on the SAME table makes
50
+ * PG raise `tuple concurrently updated` in its catalog. We serialize the entire run behind a session-level
51
+ * `pg_advisory_lock`: the first caller does the real CREATE/ALTER, the rest block until it unlocks then find every
52
+ * statement already satisfied (IF NOT EXISTS ⇒ no-op), so there is no catalog race. The DDL semantics are
53
+ * unchanged — only its timing is serialized. The advisory lock is SESSION (connection)-level, so the lock and
54
+ * ALL the DDL MUST run on the one client we hold; routing DDL through `pool.query` could land on a different
55
+ * pooled connection and silently void the lock. */
6
56
  export declare function ensurePgSchema(pool: pg.Pool): Promise<void>;
7
57
  //# sourceMappingURL=pg-pool.d.ts.map
@@ -1,4 +1,32 @@
1
+ /**
2
+ * PostgreSQL pool + central schema — the PG sibling of tidb-pool.ts, for the second run-store backend
3
+ * (clay 2026-06-21). Schema ownership is CENTRAL (one ensurePgSchema, like tidb-pool's SCHEMA_STATEMENTS) — PG
4
+ * stores assume the tables exist and NEVER create their own (a per-store `CREATE TABLE IF NOT EXISTS` is
5
+ * first-writer-wins, so a trimmed table would shadow the full one and drop columns).
6
+ *
7
+ * Dialect deltas vs the MySQL DDL in tidb-pool.ts: JSON→JSONB, DATETIME(3)→TIMESTAMPTZ(3), TINYINT(1)→SMALLINT,
8
+ * inline `KEY …`→separate `CREATE INDEX`. checkpoint timestamps stay epoch-ms BIGINT (core's Checkpoint uses ms),
9
+ * matching the TiDB schema byte-for-byte semantically. Only the tables PG backends implement so far are listed
10
+ * (run-store + checkpoint); the remaining tidb-* tables are added as their PG stores land (tracked).
11
+ *
12
+ * ─────────────────────────────── SCHEMA POLICY (clay 裁 2026-07-26) ───────────────────────────────
13
+ * THIS CODE IS THE SINGLE SOURCE OF TRUTH for the PG schema. The stack is not yet in production and runs
14
+ * against a single local operator's database, so a schema change is DROP-AND-RECREATE (drop the database,
15
+ * boot, `ensurePgSchema` rebuilds it) — NOT an in-place migration.
16
+ *
17
+ * Consequence, and it is a hard rule: **do NOT add new `ALTER TABLE` seams here.** Every column / default /
18
+ * constraint change is folded into its own `CREATE TABLE`, and this array stays pure `CREATE TABLE` +
19
+ * `CREATE INDEX`. The historical additive-ALTER seams were folded in on 2026-07-26 (they had all decayed
20
+ * into permanent no-ops — the CREATEs already carried the columns).
21
+ *
22
+ * Because the seams are gone, the semantics they used to document now live as inline `--` comments ON THE
23
+ * COLUMN inside the CREATE, not as TypeScript comments outside the template literal: the full-set SQL
24
+ * baseline `docs/schema/baseline-pg.sql` is GENERATED from these statement strings, so only what is inside
25
+ * the SQL survives the export. The baseline is a derived artifact — regenerate it, never hand-edit it.
26
+ */
1
27
  import pg from "pg";
28
+ // Each PG store owns its own (disjoint) tables' DDL via a standalone idempotent ensureSchema; the central apply
29
+ // composes them so production wires ONE ensurePgSchema (the PG twin of tidb-pool's single ensureSchema).
2
30
  import { ensureSchema as ensureSessionSchema } from "./pg-session-storage.js";
3
31
  import { ensureSchema as ensureToolResultSchema } from "./pg-tool-result-store.js";
4
32
  import { ensureSchema as ensureCostQuotaSchema } from "./pg-cost-quota.js";
@@ -46,6 +74,7 @@ export const PG_SCHEMA_STATEMENTS = [
46
74
  PRIMARY KEY (session_id)
47
75
  )`,
48
76
  `CREATE INDEX IF NOT EXISTS idx_task_active_task ON task_active (task_id)`,
77
+ // Durable-checkpoint (core 1.67 / design/45) — the FULL table (matches tidb-pool.ts checkpoint + its migrations).
49
78
  `CREATE TABLE IF NOT EXISTS checkpoint (
50
79
  token VARCHAR(120) NOT NULL,
51
80
  scope VARCHAR(190) NOT NULL,
@@ -77,6 +106,7 @@ export const PG_SCHEMA_STATEMENTS = [
77
106
  updated_at BIGINT NOT NULL,
78
107
  PRIMARY KEY (session_id)
79
108
  )`,
109
+ // E18 resume-at anchor map (the PG twin of the TiDB resume_anchor table — eventId→entryId; see tidb-pool.ts).
80
110
  `CREATE TABLE IF NOT EXISTS resume_anchor (
81
111
  session_id VARCHAR(64) NOT NULL,
82
112
  event_id VARCHAR(64) NOT NULL,
@@ -86,6 +116,8 @@ export const PG_SCHEMA_STATEMENTS = [
86
116
  PRIMARY KEY (session_id, event_id)
87
117
  )`,
88
118
  `CREATE INDEX IF NOT EXISTS idx_resume_anchor_session ON resume_anchor (session_id)`,
119
+ // Per-session per-toolName approval exemption (the PG twin — see tidb-pool.ts /
120
+ // docs/design/APPROVAL-SESSION-EXEMPTION.md).
89
121
  `CREATE TABLE IF NOT EXISTS approval_exemption (
90
122
  session_id VARCHAR(64) NOT NULL,
91
123
  tool_name VARCHAR(190) NOT NULL,
@@ -93,6 +125,9 @@ export const PG_SCHEMA_STATEMENTS = [
93
125
  created_at TIMESTAMPTZ(3) NOT NULL,
94
126
  PRIMARY KEY (session_id, tool_name)
95
127
  )`,
128
+ // SendUserFile server-side ledger (the PG twin — scope↔object mapping for per-tenant list/revoke; the hashed
129
+ // key segment hides this from URLs. id = uuidv7 time-ordered PK = keyset cursor; see tidb-pool.ts /
130
+ // send-file-ledger.ts).
96
131
  `CREATE TABLE IF NOT EXISTS sendfile_link (
97
132
  id VARCHAR(64) NOT NULL,
98
133
  scope VARCHAR(190) NOT NULL,
@@ -108,6 +143,9 @@ export const PG_SCHEMA_STATEMENTS = [
108
143
  PRIMARY KEY (id)
109
144
  )`,
110
145
  `CREATE INDEX IF NOT EXISTS idx_sendfile_link_scope ON sendfile_link (scope, id)`,
146
+ // E6 durable SessionPolicyStore (the PG twin of the TiDB session_policy table; policy_key = sha256(JSON.stringify(
147
+ // [sessionId, principal ?? null])) = a fixed 64-char hash PK; rules JSONB; CAS-versioned tighten-only — see
148
+ // tidb-pool.ts / tidb-session-policy-store.ts).
111
149
  `CREATE TABLE IF NOT EXISTS session_policy (
112
150
  policy_key CHAR(64) NOT NULL,
113
151
  session_id VARCHAR(64) NOT NULL,
@@ -122,6 +160,8 @@ export const PG_SCHEMA_STATEMENTS = [
122
160
  PRIMARY KEY (policy_key)
123
161
  )`,
124
162
  `CREATE INDEX IF NOT EXISTS idx_session_policy_session ON session_policy (session_id)`,
163
+ // E19 rewind-files (the PG twin of the TiDB snapshot_manifest/snapshot_blob; relPath→blob_hash manifest +
164
+ // content-addressed BYTEA blobs; core captureManifest/applyManifest do the walk/restore — see tidb-pool.ts).
125
165
  `CREATE TABLE IF NOT EXISTS snapshot_manifest (
126
166
  scope VARCHAR(64) NOT NULL,
127
167
  snap_key VARCHAR(64) NOT NULL,
@@ -143,6 +183,10 @@ export const PG_SCHEMA_STATEMENTS = [
143
183
  created_at TIMESTAMPTZ(3) NOT NULL
144
184
  )`,
145
185
  `CREATE INDEX IF NOT EXISTS idx_snapshot_blob_created ON snapshot_blob (created_at)`,
186
+ // SVC-2 (core CORE-7) durable WorkflowJournalStore — the PG twin of the TiDB workflow_journal table (cross-replica
187
+ // resume journal; (run_id, ordinal) PK = idempotent OVERWRITE upsert; `result` = JSON.stringify(TaskResult)). `result`
188
+ // is TEXT, NOT JSONB — the byte-match contract is "string in, string out" (the store JSON.parses on load); JSONB would
189
+ // make `pg` auto-parse the row back to an object and break the twin's String()→JSON.parse path. See pg-workflow-journal-store.ts.
146
190
  `CREATE TABLE IF NOT EXISTS workflow_journal (
147
191
  run_id VARCHAR(191) NOT NULL,
148
192
  ordinal INT NOT NULL,
@@ -157,6 +201,8 @@ export const PG_SCHEMA_STATEMENTS = [
157
201
  created_at BIGINT NOT NULL,
158
202
  PRIMARY KEY (run_id, ordinal)
159
203
  )`,
204
+ // RB-242 / WF2 ([1981] core 拍板 a 形):cross-replica workflow resume admission lease — the PG twin of
205
+ // workflow_resume_claim in tidb-pool.ts (rationale there; TTL = crash backstop only).
160
206
  `CREATE TABLE IF NOT EXISTS workflow_resume_claim (
161
207
  source_run_id VARCHAR(191) NOT NULL,
162
208
  scope VARCHAR(190) NOT NULL,
@@ -164,6 +210,8 @@ export const PG_SCHEMA_STATEMENTS = [
164
210
  claimed_at BIGINT NOT NULL,
165
211
  PRIMARY KEY (source_run_id, scope)
166
212
  )`,
213
+ // P1 (fleet failover): WorkflowRunStore + completion-inbox PG twins (design doc in tidb-workflow-run-store.ts).
214
+ // `run` is TEXT not jsonb (node-pg auto-parse would break the shared String()→JSON.parse path).
167
215
  `CREATE TABLE IF NOT EXISTS workflow_run (
168
216
  id VARCHAR(191) NOT NULL,
169
217
  scope VARCHAR(190) NOT NULL,
@@ -209,6 +257,7 @@ export const PG_SCHEMA_STATEMENTS = [
209
257
  PRIMARY KEY (session_id, kind, run_id)
210
258
  )`,
211
259
  `CREATE INDEX IF NOT EXISTS idx_wffence_until ON workflow_inbox_fence (until_ms)`,
260
+ // 1.108 review fix (lens③ HIGH): notify-journal PG twin (design note in tidb-pool.ts).
212
261
  `CREATE TABLE IF NOT EXISTS workflow_notify_journal (
213
262
  run_id VARCHAR(191) NOT NULL,
214
263
  scope VARCHAR(190) NOT NULL,
@@ -221,6 +270,17 @@ export const PG_SCHEMA_STATEMENTS = [
221
270
  )`,
222
271
  `CREATE INDEX IF NOT EXISTS idx_wfnotify_acked ON workflow_notify_journal (acked)`,
223
272
  ];
273
+ /** Build the pg PoolConfig from PG config (pure → unit-testable apart from the live connection) — the PG twin of
274
+ * tidbPoolOptions. `dbQueryTimeoutMs` (DB_QUERY_TIMEOUT_MS, S9 deeper fix) arms a POOL-WIDE per-query ceiling on
275
+ * every client the pool hands out, BOTH sides:
276
+ * - `statement_timeout` = T: SERVER-side cancel (sent as a startup parameter) — frees the server's resources
277
+ * and surfaces the canonical 57014 error on any statement that runs past T;
278
+ * - `query_timeout` = T + 5s: CLIENT-side read-timeout backstop for the cases the server can't answer at all
279
+ * (dead network / hung server — the S9 hang class). Slightly ABOVE statement_timeout on purpose, so the
280
+ * server's clean cancel normally wins and the client timer only fires when no response ever arrives (a
281
+ * query_timeout rejection makes pg-pool DESTROY that client, discarding the poisoned connection).
282
+ * Unset = both off (byte-compat: legit heavyweight statements — boot DDL, ≤64 MiB snapshot-blob rows — make a
283
+ * universal default unsafe; the S9 write-behind counter face carries its own always-on per-query timeout). */
224
284
  export function pgPoolOptions(pgCfg, dbQueryTimeoutMs) {
225
285
  return {
226
286
  host: pgCfg.host,
@@ -232,14 +292,32 @@ export function pgPoolOptions(pgCfg, dbQueryTimeoutMs) {
232
292
  ...(dbQueryTimeoutMs ? { statement_timeout: dbQueryTimeoutMs, query_timeout: dbQueryTimeoutMs + 5_000 } : {}),
233
293
  };
234
294
  }
295
+ /** Create the PG pool from a connection string (or pg.PoolConfig). Thin — production backend-selection wiring
296
+ * (a ServiceConfig.pg sibling of .tidb) is a tracked follow-on. */
235
297
  export function createPgPool(opts) {
236
298
  return typeof opts === "string" ? new pg.Pool({ connectionString: opts }) : new pg.Pool(opts);
237
299
  }
300
+ /** A fixed bigint key for the `pg_advisory_lock` that serializes the whole `ensurePgSchema` DDL run (see below).
301
+ * Arbitrary constant; only its uniqueness within this app matters (advisory-lock keys are app-private). */
238
302
  const ENSURE_SCHEMA_LOCK_KEY = 4906;
303
+ /** Idempotent central schema apply (the PG twin of tidb-pool.ts ensureSchema): the run/checkpoint tables here +
304
+ * every PG store's own (disjoint) tables. Order is irrelevant (CREATE IF NOT EXISTS, no cross-table FKs).
305
+ *
306
+ * Concurrency: callers run this concurrently — tests fan ALL integration suites out in parallel (each beforeAll
307
+ * calls ensurePgSchema), and in production every replica calls it at boot. Concurrent DDL on the SAME table makes
308
+ * PG raise `tuple concurrently updated` in its catalog. We serialize the entire run behind a session-level
309
+ * `pg_advisory_lock`: the first caller does the real CREATE/ALTER, the rest block until it unlocks then find every
310
+ * statement already satisfied (IF NOT EXISTS ⇒ no-op), so there is no catalog race. The DDL semantics are
311
+ * unchanged — only its timing is serialized. The advisory lock is SESSION (connection)-level, so the lock and
312
+ * ALL the DDL MUST run on the one client we hold; routing DDL through `pool.query` could land on a different
313
+ * pooled connection and silently void the lock. */
239
314
  export async function ensurePgSchema(pool) {
240
315
  const client = await pool.connect();
241
316
  let locked = false;
242
317
  try {
318
+ // pg_advisory_lock blocks until the lock is granted (the DDL run is short, so blocking is acceptable). If the
319
+ // lock op itself errors we DEGRADE to running the DDL unserialized rather than failing boot — the CREATE IF NOT
320
+ // EXISTS statements are still individually idempotent (they just lose the cross-caller serialization).
243
321
  try {
244
322
  await client.query("SELECT pg_advisory_lock($1)", [ENSURE_SCHEMA_LOCK_KEY]);
245
323
  locked = true;
@@ -1,7 +1,18 @@
1
+ /**
2
+ * `PgQueryFn` — the minimal pg query seam the server's PG-dialect stores are written against
3
+ * (`(text, params) => Promise<{ rows }>`; deliberately NO rowCount — callers assert post-state, not counts).
4
+ *
5
+ * HISTORY: this type used to be re-exported by `@sema-agent/core` from its pg REFERENCE adapter. core 1.424.0
6
+ * removed the whole example-adapter export surface from the npm package (clay's package-hygiene ruling,
7
+ * board [1803] — examples are in-repo samples, not user API). The type itself is server-owned wiring, so it
8
+ * moved here VERBATIM (same shape as core 1.423's `examples/adapters/pg-adapter.d.ts`); six plugins consume it.
9
+ */
1
10
  export interface PgQueryResult {
2
11
  rows: Array<Record<string, unknown>>;
3
12
  }
4
13
  export type PgQueryFn = (text: string, params?: unknown[]) => Promise<PgQueryResult>;
14
+ /** Same relocation as PgQueryFn (core 1.424 example-adapter export removal): the embedding seam the
15
+ * pg memory engine takes — verbatim shape from core 1.423's `examples/adapters/pg-adapter.d.ts`. */
5
16
  export interface PgEmbedder {
6
17
  embed(text: string): Promise<number[]>;
7
18
  dimensions: number;
@@ -1,3 +1,19 @@
1
+ /**
2
+ * PostgreSQL cross-replica per-key request rate limiter — the PG twin of {@link TiDBRateLimiter}
3
+ * (src/plugins/tidb-rate-limiter.ts). Behaviourally identical: a thin {@link RateGate} over a shared
4
+ * write-behind aggregating counter; `check` both COUNTS the request and decides, with the count summed
5
+ * fleet-wide via atomic write-behind aggregation. SAME class surface + SAME SOFT-limiting semantics
6
+ * (eventually consistent: a replica may briefly admit a few requests over the ceiling at a window
7
+ * boundary before peers' counts propagate).
8
+ *
9
+ * design/158 A12 C1b: the `PgWriteBehindCounter` this file used to define inline now lives in
10
+ * write-behind-counter.ts as the PG binding of ONE dialect-parameterized counter (the mysql2 twin is
11
+ * `WriteBehindCounter`); the SQL-dialect deltas are documented and branched there. It is re-exported here
12
+ * so the historical import path keeps working.
13
+ *
14
+ * Schema: this store's `rate_limit` table is DISJOINT from the other PG stores' tables, so a
15
+ * self-contained {@link PG_RATE_LIMITER_SCHEMA} + {@link ensureSchema} is safe (no shadowing).
16
+ */
1
17
  import type { Pool, PoolClient } from "pg";
2
18
  import type { RateDecision, RateGate } from "../observability/rate-limit.js";
3
19
  import { type CounterDegradeHook } from "./write-behind-counter.js";
@@ -8,12 +24,19 @@ export declare class PgRateLimiter implements RateGate {
8
24
  private readonly counter;
9
25
  constructor(pool: Pool, limit: number, windowMs?: number, now?: () => number, onDegraded?: CounterDegradeHook, queryTimeoutMs?: number);
10
26
  check(key: string): RateDecision;
27
+ /** The flush loop self-reaps old windows; the periodic sweeper has nothing to do for this backend. */
11
28
  sweep(): void;
12
29
  flush(): Promise<void>;
13
30
  refresh(): Promise<void>;
14
31
  startRefresh(intervalMs?: number): this;
15
32
  stop(): void;
16
33
  }
34
+ /**
35
+ * PG translation of tidb-pool's `rate_limit` DDL (SCHEMA_STATEMENTS): INT→INTEGER, DATETIME(3)→TIMESTAMPTZ(3),
36
+ * inline `KEY idx_window`→separate `CREATE INDEX`. The composite PK (limit_key, window_bucket) backs the
37
+ * atomic ON CONFLICT increment.
38
+ */
17
39
  export declare const PG_RATE_LIMITER_SCHEMA: string[];
40
+ /** Self-contained schema bootstrap for tests (the rate_limit table is disjoint from other stores). */
18
41
  export declare function ensureSchema(pool: Pool | PoolClient): Promise<void>;
19
42
  //# sourceMappingURL=pg-rate-limiter.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { PgWriteBehindCounter } from "./write-behind-counter.js";
2
2
  export { PgWriteBehindCounter } from "./write-behind-counter.js";
3
+ /** The counter's table binding for the per-key request rate limit (mirror of the TiDB twin's binding). */
3
4
  const RATE_LIMIT_TABLE = { table: "rate_limit", keyCol: "limit_key", valCol: "n" };
4
5
  export class PgRateLimiter {
5
6
  limit;
@@ -11,14 +12,17 @@ export class PgRateLimiter {
11
12
  check(key) {
12
13
  if (this.limit <= 0)
13
14
  return { allowed: true, retryAfterSec: 0, remaining: Number.POSITIVE_INFINITY };
14
- const usedBefore = this.counter.used(key);
15
- this.counter.addLocal(key, 1);
15
+ const usedBefore = this.counter.used(key); // fleet (last refresh) + local pending — soft/eventually consistent
16
+ this.counter.addLocal(key, 1); // count every request, like the in-memory limiter
16
17
  return usedBefore < this.limit
17
18
  ? { allowed: true, retryAfterSec: 0, remaining: this.limit - usedBefore - 1 }
18
19
  : { allowed: false, retryAfterSec: Math.max(1, this.counter.retryAfterSec()), remaining: 0 };
19
20
  }
21
+ /** The flush loop self-reaps old windows; the periodic sweeper has nothing to do for this backend. */
20
22
  sweep() {
23
+ /* no-op */
21
24
  }
25
+ // write-behind lifecycle (delegated; exposed for tests/parity)
22
26
  flush() {
23
27
  return this.counter.flush();
24
28
  }
@@ -33,6 +37,11 @@ export class PgRateLimiter {
33
37
  this.counter.stop();
34
38
  }
35
39
  }
40
+ /**
41
+ * PG translation of tidb-pool's `rate_limit` DDL (SCHEMA_STATEMENTS): INT→INTEGER, DATETIME(3)→TIMESTAMPTZ(3),
42
+ * inline `KEY idx_window`→separate `CREATE INDEX`. The composite PK (limit_key, window_bucket) backs the
43
+ * atomic ON CONFLICT increment.
44
+ */
36
45
  export const PG_RATE_LIMITER_SCHEMA = [
37
46
  `CREATE TABLE IF NOT EXISTS rate_limit (
38
47
  limit_key VARCHAR(190) NOT NULL,
@@ -43,6 +52,7 @@ export const PG_RATE_LIMITER_SCHEMA = [
43
52
  )`,
44
53
  `CREATE INDEX IF NOT EXISTS idx_rate_limit_window ON rate_limit (window_bucket)`,
45
54
  ];
55
+ /** Self-contained schema bootstrap for tests (the rate_limit table is disjoint from other stores). */
46
56
  export async function ensureSchema(pool) {
47
57
  for (const stmt of PG_RATE_LIMITER_SCHEMA)
48
58
  await pool.query(stmt);
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Thin re-export shim (design/158 A12 收编) — the real implementation moved to the single-file
3
+ * dual-dialect `resume-anchor-store-sql.ts` (shared with the TiDB twin via `SqlDriver`). Kept so
4
+ * consumers importing this path (store-backend.ts, the resume-anchor integration suite) don't move.
5
+ */
1
6
  export { PgResumeAnchorStore } from "./resume-anchor-store-sql.js";
2
7
  //# sourceMappingURL=pg-resume-anchor-store.d.ts.map
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Thin re-export shim (design/158 A12 收编) — the real implementation moved to the single-file
3
+ * dual-dialect `resume-anchor-store-sql.ts` (shared with the TiDB twin via `SqlDriver`). Kept so
4
+ * consumers importing this path (store-backend.ts, the resume-anchor integration suite) don't move.
5
+ */
1
6
  export { PgResumeAnchorStore } from "./resume-anchor-store-sql.js";
2
7
  //# sourceMappingURL=pg-resume-anchor-store.js.map
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Thin re-export shim (design/158 A12 定型半场 collapse): the real implementation now lives in
3
+ * `run-store-sql.ts` (single-file dual-dialect — TiDB + PG share one `SqlRunStore` body, dialect deltas
4
+ * kept EXPLICIT per statement). `PgRunStore`'s class name/ctor arity is unchanged so every existing
5
+ * consumer (store-backend.ts, the reaper/session integration suites) needs ZERO changes. New code
6
+ * should import from `run-store-sql.ts` directly.
7
+ */
1
8
  export { PgRunStore } from "./run-store-sql.js";
2
9
  //# sourceMappingURL=pg-run-store.d.ts.map
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Thin re-export shim (design/158 A12 定型半场 collapse): the real implementation now lives in
3
+ * `run-store-sql.ts` (single-file dual-dialect — TiDB + PG share one `SqlRunStore` body, dialect deltas
4
+ * kept EXPLICIT per statement). `PgRunStore`'s class name/ctor arity is unchanged so every existing
5
+ * consumer (store-backend.ts, the reaper/session integration suites) needs ZERO changes. New code
6
+ * should import from `run-store-sql.ts` directly.
7
+ */
1
8
  export { PgRunStore } from "./run-store-sql.js";
2
9
  //# sourceMappingURL=pg-run-store.js.map
@@ -1,9 +1,22 @@
1
1
  export declare function pgSanitizeText(s: string): string;
2
+ /** 有损深度安全 stringify(键+值)。 */
2
3
  export declare function pgSafeJsonStringify(value: unknown): string;
4
+ /** 无损:干净值原样;脏值折版本化信封(读侧 {@link pgLosslessJsonParse} 逐位还原)。干净值若**恰为
5
+ * 保留形**(用户数据撞信封/转义形)→ 套 {__pgSafe:"esc.v1", d:<原文>} 转义一层,读侧解一层——
6
+ * 保留形永不与用户数据歧义。 */
3
7
  export declare function pgLosslessJsonStringify(value: unknown): string;
8
+ /** detect-only:值树里是否含不可存码点(字符串值+属性名都查,零形变零拷贝)。干净输入(绝大多数)
9
+ * 让调用方走**引用原样**快路——canonical 化的 JSON round-trip 对干净输入也可能形变(undefined 值键
10
+ * 剥离等),CAS/rev 语义的臂必须先 detect 再变换。 */
4
11
  export declare function pgHasUnstorable(v: unknown): boolean;
12
+ /** codex R4→R7 终形:协议数据(approval args/checkpoint/ctx/outcome/rules/memory)一律**拒绝式**。
13
+ * 信封方案历经 R4-R7 四轮对抗全灭:行内判别子恒可被 ≤1.240 老行/用户数据撞形(静默解错=approval
14
+ * 信任边界破),进程旗恒有混旗副本窗(写读不同解)。唯一无歧义解=**脏值不进库**:PG 存不了
15
+ * NUL 是后端能力边界,fail-loud 暴露(清晰文案)严格优于修前的 22P05 神秘崩——两者都存不进,
16
+ * 但拒绝式下 review==execute 恒成立(库里只有干净值,展示面=执行面永逐位一致)。 */
5
17
  export declare class PgUnstorableError extends Error {
6
18
  constructor(what: string);
7
19
  }
20
+ /** 协议数据写面:干净=原样 stringify;脏={@link PgUnstorableError} fail-loud。 */
8
21
  export declare function pgProtocolJsonStringify(value: unknown, what: string): string;
9
22
  //# sourceMappingURL=pg-safe-json.d.ts.map
@@ -1,7 +1,26 @@
1
+ /**
2
+ * PG 写入臂族的统一序列化([1439]/[1442]test CF-UNICODE + codex 四 high 复审)。
3
+ *
4
+ * 病:PG 的 text/jsonb 域**不可存 NUL**(ERRCODE 22P05/22021),unpaired surrogate 同族——tool_result
5
+ * 夹带真 0x00(agent raw `cat` 二进制/含 NUL 文件)→ 写入即炸 → session append 崩、run 中途死
6
+ * (云独有指纹:file store 无此约束,[1438]②/[1439] 定谳归 server)。
7
+ *
8
+ * 三层工具,按臂的保真需求选用:
9
+ * - {@link pgSanitizeText}:裸 text 列(memory body / tool_result content)。
10
+ * - {@link pgSafeJsonStringify}:**深度** sanitize(键+值都扫——codex H2:replacer 换不了键名,
11
+ * 含 NUL 的属性名照样炸;撞键以 U+FFFD 追加消歧,诚实不静默覆盖)后 stringify。有损(U+FFFD),
12
+ * 用于观测/记账类 blob(session event、run 行、outcome、journal——内容语义容忍替换标记)。
13
+ * - {@link pgLosslessJsonStringify}/{@link pgLosslessJsonParse}:**无损信封**(codex H1:checkpoint 的
14
+ * pendingAction args 过 approval 信任边界,hash 绑定原文,有损替换=执行内容偏离已批内容)。
15
+ * 干净值原样直存(既有行形不变);含不可存码点才折 `{__pgSafeB64}` 信封(base64 承载 stringify
16
+ * 原文——stringify 输出恒 well-formed 转义形,base64 逐位保真),读侧解封逐位还原。
17
+ */
1
18
  const NUL_OR_LONE_SURROGATE = /\u0000|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
2
19
  export function pgSanitizeText(s) {
3
20
  return s.replace(NUL_OR_LONE_SURROGATE, "�");
4
21
  }
22
+ /** 深度 sanitize:字符串值+**属性名**都扫(数组递归;非 plain 值原样)。输入应为 JSON-plain 树
23
+ * (调用方先过 `JSON.parse(JSON.stringify(v))` 保 toJSON/undefined 语义——见 pgSafeJsonStringify)。 */
5
24
  function sanitizeDeep(v, state) {
6
25
  if (typeof v === "string") {
7
26
  const s = pgSanitizeText(v);
@@ -12,13 +31,13 @@ function sanitizeDeep(v, state) {
12
31
  if (Array.isArray(v))
13
32
  return v.map((x) => sanitizeDeep(x, state));
14
33
  if (v !== null && typeof v === "object") {
15
- const out = Object.create(null);
34
+ const out = Object.create(null); // codex R2-M:{} 会把 own "__proto__" 键吞进原型 setter
16
35
  for (const [k, val] of Object.entries(v)) {
17
36
  let key = pgSanitizeText(k);
18
37
  if (key !== k)
19
38
  state.changed = true;
20
39
  while (Object.prototype.hasOwnProperty.call(out, key)) {
21
- key += "�";
40
+ key += "�"; // 撞键消歧(两键仅差不可存字节的病态形)——追加标记,绝不静默覆盖
22
41
  state.changed = true;
23
42
  }
24
43
  out[key] = sanitizeDeep(val, state);
@@ -27,20 +46,27 @@ function sanitizeDeep(v, state) {
27
46
  }
28
47
  return v;
29
48
  }
49
+ /** 有损深度安全 stringify(键+值)。 */
30
50
  export function pgSafeJsonStringify(value) {
31
51
  const raw = JSON.stringify(value);
32
52
  if (raw === undefined)
33
- return raw;
34
- const plain = JSON.parse(raw);
53
+ return raw; // undefined 输入随 stringify 语义
54
+ const plain = JSON.parse(raw); // 先走一遍 stringify 语义(toJSON/undefined 剥离),再深扫
35
55
  const state = { changed: false };
36
56
  const clean = sanitizeDeep(plain, state);
37
57
  return state.changed ? JSON.stringify(clean) : raw;
38
58
  }
39
59
  const ENVELOPE_KEY = "__pgSafe";
40
60
  const ENVELOPE_VERSION = "b64.v1";
61
+ /** 信封判别:**精确形**(恰两键 {__pgSafe:"b64.v1", d:string})——codex R2-H2:单键存在性判别会把
62
+ * 「恰好带同名键的普通用户 JSON/老行」误当信封(合法 base64 静默解出别的对象、非 base64 读侧炸)。
63
+ * 精确形+版本号把碰撞面收到「用户恰好存逐位同形信封」,由 stringify 侧转义规避(见下)。 */
41
64
  function isEnvelope(o) {
42
65
  return Object.keys(o).length === 2 && o[ENVELOPE_KEY] === ENVELOPE_VERSION && typeof o.d === "string";
43
66
  }
67
+ /** 无损:干净值原样;脏值折版本化信封(读侧 {@link pgLosslessJsonParse} 逐位还原)。干净值若**恰为
68
+ * 保留形**(用户数据撞信封/转义形)→ 套 {__pgSafe:"esc.v1", d:<原文>} 转义一层,读侧解一层——
69
+ * 保留形永不与用户数据歧义。 */
44
70
  export function pgLosslessJsonStringify(value) {
45
71
  const raw = JSON.stringify(value);
46
72
  if (raw === undefined)
@@ -57,8 +83,12 @@ export function pgLosslessJsonStringify(value) {
57
83
  }
58
84
  return raw;
59
85
  }
86
+ // stringify 输出恒 well-formed(NUL/lone surrogate 均已是六字符转义),utf8→base64 逐位保真。
60
87
  return JSON.stringify({ [ENVELOPE_KEY]: ENVELOPE_VERSION, d: Buffer.from(raw, "utf8").toString("base64") });
61
88
  }
89
+ /** detect-only:值树里是否含不可存码点(字符串值+属性名都查,零形变零拷贝)。干净输入(绝大多数)
90
+ * 让调用方走**引用原样**快路——canonical 化的 JSON round-trip 对干净输入也可能形变(undefined 值键
91
+ * 剥离等),CAS/rev 语义的臂必须先 detect 再变换。 */
62
92
  export function pgHasUnstorable(v) {
63
93
  if (typeof v === "string")
64
94
  return NUL_OR_LONE_SURROGATE.test(v) ? (NUL_OR_LONE_SURROGATE.lastIndex = 0, true) : false;
@@ -72,6 +102,11 @@ export function pgHasUnstorable(v) {
72
102
  }
73
103
  return false;
74
104
  }
105
+ /** codex R4→R7 终形:协议数据(approval args/checkpoint/ctx/outcome/rules/memory)一律**拒绝式**。
106
+ * 信封方案历经 R4-R7 四轮对抗全灭:行内判别子恒可被 ≤1.240 老行/用户数据撞形(静默解错=approval
107
+ * 信任边界破),进程旗恒有混旗副本窗(写读不同解)。唯一无歧义解=**脏值不进库**:PG 存不了
108
+ * NUL 是后端能力边界,fail-loud 暴露(清晰文案)严格优于修前的 22P05 神秘崩——两者都存不进,
109
+ * 但拒绝式下 review==execute 恒成立(库里只有干净值,展示面=执行面永逐位一致)。 */
75
110
  export class PgUnstorableError extends Error {
76
111
  constructor(what) {
77
112
  super(`${what} contains bytes PostgreSQL cannot store (NUL / lone surrogate). ` +
@@ -79,6 +114,7 @@ export class PgUnstorableError extends Error {
79
114
  this.name = "PgUnstorableError";
80
115
  }
81
116
  }
117
+ /** 协议数据写面:干净=原样 stringify;脏={@link PgUnstorableError} fail-loud。 */
82
118
  export function pgProtocolJsonStringify(value, what) {
83
119
  const raw = JSON.stringify(value);
84
120
  if (raw === undefined)
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Thin re-export shim (design/158 A12 收编) — the real implementation lives in the single-file
3
+ * dual-dialect `session-policy-store-sql.ts` (`SqlSessionPolicyStore` + this file's historical
4
+ * `PgSessionPolicyStore` ctor subclass). Kept so every consumer's import path is untouched.
5
+ */
1
6
  export { PgSessionPolicyStore } from "./session-policy-store-sql.js";
2
7
  //# sourceMappingURL=pg-session-policy-store.d.ts.map
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Thin re-export shim (design/158 A12 收编) — the real implementation lives in the single-file
3
+ * dual-dialect `session-policy-store-sql.ts` (`SqlSessionPolicyStore` + this file's historical
4
+ * `PgSessionPolicyStore` ctor subclass). Kept so every consumer's import path is untouched.
5
+ */
1
6
  export { PgSessionPolicyStore } from "./session-policy-store-sql.js";
2
7
  //# sourceMappingURL=pg-session-policy-store.js.map