@sema-agent/server 7.150.0 → 7.152.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 (514) hide show
  1. package/MIGRATION.md +451 -0
  2. package/README.md +15 -3
  3. package/README.zh-CN.md +10 -2
  4. package/USAGE.md +144 -87
  5. package/deploy/sema-up/README.md +11 -4
  6. package/deploy/sema-up/chart/Chart.yaml +1 -1
  7. package/deploy/sema-up/chart/templates/NOTES.txt +5 -0
  8. package/deploy/sema-up/chart/templates/_helpers.tpl +15 -16
  9. package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -3
  10. package/deploy/sema-up/chart/templates/server.yaml +5 -3
  11. package/deploy/sema-up/chart/values-full-single.yaml +3 -1
  12. package/deploy/sema-up/chart/values.yaml +8 -1
  13. package/deploy/sema-up/cluster-up.sh +7 -6
  14. package/deploy/sema-up/kube-up.sh +6 -6
  15. package/deploy/sema-up/lib/flagshape.sh +36 -8
  16. package/deploy/sema-up/lib/helm-values-cluster.py +2 -0
  17. package/deploy/sema-up/lib/helm-values-kube.py +2 -0
  18. package/deploy/sema-up/machines.example.yaml +3 -1
  19. package/deploy/sema-up/sema-up.sh +22 -16
  20. package/dist/adoption/import.js +3 -3
  21. package/dist/approval-ask-audit-store.d.ts +1 -1
  22. package/dist/approval-ask-machine.d.ts +4 -10
  23. package/dist/approval-ask-retention.d.ts +1 -1
  24. package/dist/approval-card.d.ts +12 -14
  25. package/dist/approval-gate-currency.d.ts +9 -9
  26. package/dist/approval-gate-currency.js +3 -4
  27. package/dist/approval-hmac.d.ts +17 -1
  28. package/dist/approval-hmac.js +7 -1
  29. package/dist/approval-queue-kind.d.ts +1 -1
  30. package/dist/approval.d.ts +2 -2
  31. package/dist/approval.js +2 -2
  32. package/dist/auth-bridge.d.ts +20 -0
  33. package/dist/auth-bridge.js +9 -0
  34. package/dist/background-session-reap.d.ts +1 -1
  35. package/dist/bake-runner/main.d.ts +4 -2
  36. package/dist/bind-host.d.ts +3 -6
  37. package/dist/bind-host.js +4 -7
  38. package/dist/boot/budget-tracing.js +1 -1
  39. package/dist/boot/coordinators.d.ts +1 -1
  40. package/dist/boot/coordinators.js +9 -10
  41. package/dist/boot/device-lane.js +2 -0
  42. package/dist/boot/engine-lease.d.ts +5 -0
  43. package/dist/boot/engine-lease.js +1 -0
  44. package/dist/boot/execution-env.d.ts +9 -14
  45. package/dist/boot/execution-env.js +85 -22
  46. package/dist/boot/execution-lane.js +32 -5
  47. package/dist/boot/late-binds.d.ts +8 -4
  48. package/dist/boot/late-binds.js +7 -1
  49. package/dist/boot/leader.d.ts +31 -30
  50. package/dist/boot/leader.js +38 -28
  51. package/dist/boot/leg-path-adjudication.d.ts +40 -0
  52. package/dist/boot/leg-path-adjudication.js +18 -0
  53. package/dist/boot/memory-consolidation.d.ts +3 -2
  54. package/dist/boot/memory-consolidation.js +6 -6
  55. package/dist/boot/parked-revive-gate.js +3 -15
  56. package/dist/boot/reapers.d.ts +6 -1
  57. package/dist/boot/reapers.js +13 -2
  58. package/dist/boot/resolve-spec.d.ts +3 -3
  59. package/dist/boot/resolve-spec.js +43 -48
  60. package/dist/boot/runner-deps.d.ts +46 -35
  61. package/dist/boot/runner-deps.js +94 -91
  62. package/dist/boot/session-age-out.d.ts +36 -0
  63. package/dist/boot/session-age-out.js +101 -0
  64. package/dist/boot/session-faces.d.ts +5 -14
  65. package/dist/boot/session-faces.js +9 -5
  66. package/dist/boot/shutdown.d.ts +6 -0
  67. package/dist/boot/shutdown.js +10 -4
  68. package/dist/boot/stage-01-config.js +2 -0
  69. package/dist/boot/stage-02-web-admin-pull.js +4 -5
  70. package/dist/boot/stage-05-execution-env.d.ts +5 -3
  71. package/dist/boot/stage-05-execution-env.js +3 -2
  72. package/dist/boot/stage-06-runners.d.ts +9 -4
  73. package/dist/boot/stage-06-runners.js +24 -9
  74. package/dist/boot/stage-07-capability-layer.d.ts +8 -4
  75. package/dist/boot/stage-07-capability-layer.js +3 -2
  76. package/dist/boot/stage-08-reapers.d.ts +8 -4
  77. package/dist/boot/stage-08-reapers.js +4 -2
  78. package/dist/boot/stage-09-leader.d.ts +12 -5
  79. package/dist/boot/stage-09-leader.js +14 -5
  80. package/dist/boot/stage-10-http-server.d.ts +19 -5
  81. package/dist/boot/stage-10-http-server.js +14 -21
  82. package/dist/boot/stores.js +7 -4
  83. package/dist/boot/web-admin.js +5 -8
  84. package/dist/boot/workflow-orchestration.d.ts +7 -2
  85. package/dist/boot/workflow-orchestration.js +24 -7
  86. package/dist/bounded-rotation.d.ts +29 -0
  87. package/dist/bounded-rotation.js +24 -0
  88. package/dist/capabilities/approvals-push.d.ts +3 -3
  89. package/dist/capabilities/scenarios.d.ts +28 -13
  90. package/dist/capabilities/scenarios.js +2 -2
  91. package/dist/capability-facts.d.ts +43 -32
  92. package/dist/capability-facts.js +45 -51
  93. package/dist/card-rule-offers.d.ts +32 -0
  94. package/dist/card-rule-offers.js +130 -0
  95. package/dist/center-credential.d.ts +25 -6
  96. package/dist/center-credential.js +25 -5
  97. package/dist/config-catalog.d.ts +26 -7
  98. package/dist/config-catalog.js +26 -22
  99. package/dist/config-dir-trust.js +4 -2
  100. package/dist/config-invariants.d.ts +20 -8
  101. package/dist/config-invariants.js +55 -12
  102. package/dist/config-lkg.d.ts +5 -19
  103. package/dist/config-lkg.js +8 -62
  104. package/dist/config-provider.d.ts +1 -1
  105. package/dist/config-root-migration.d.ts +2 -2
  106. package/dist/config-types.d.ts +38 -42
  107. package/dist/config.d.ts +58 -7
  108. package/dist/config.js +90 -40
  109. package/dist/control-socket.d.ts +51 -0
  110. package/dist/control-socket.js +115 -0
  111. package/dist/deployment-governance.d.ts +2 -1
  112. package/dist/deployment-shape.d.ts +9 -1
  113. package/dist/deployment-shape.js +2 -1
  114. package/dist/device-protocol.d.ts +5 -4
  115. package/dist/device-protocol.js +1 -1
  116. package/dist/device-ws-hub.d.ts +7 -0
  117. package/dist/device-ws-hub.js +10 -3
  118. package/dist/device-ws-protocol.d.ts +63 -10
  119. package/dist/device-ws-protocol.js +56 -25
  120. package/dist/elicitation.js +2 -2
  121. package/dist/engine-identity.d.ts +19 -7
  122. package/dist/engine-identity.js +10 -2
  123. package/dist/entry-mode-clamp-notice.d.ts +2 -1
  124. package/dist/entry-problems.d.ts +40 -3
  125. package/dist/entry-problems.js +3 -1
  126. package/dist/execution-env-refusal.d.ts +29 -0
  127. package/dist/execution-env-refusal.js +8 -0
  128. package/dist/execution-lane-caps.d.ts +3 -1
  129. package/dist/field-conflict.d.ts +1 -1
  130. package/dist/file-history-capture.d.ts +11 -4
  131. package/dist/file-history-capture.js +9 -6
  132. package/dist/file-history-disclosure.d.ts +7 -5
  133. package/dist/file-history-disclosure.js +7 -5
  134. package/dist/fleet/drain-entry.d.ts +4 -0
  135. package/dist/fleet/engine-signal.d.ts +12 -29
  136. package/dist/fleet/engine-signal.js +1 -7
  137. package/dist/fleet-client.js +2 -5
  138. package/dist/gate-settlement.d.ts +1 -8
  139. package/dist/gate-settlement.js +0 -4
  140. package/dist/history-anchor.js +1 -1
  141. package/dist/hitl-delivery.d.ts +2 -3
  142. package/dist/hitl-delivery.js +0 -2
  143. package/dist/hooks/hook-llm.js +4 -2
  144. package/dist/hooks/hook-runner.d.ts +3 -2
  145. package/dist/hooks/hook-runner.js +18 -3
  146. package/dist/host-decision.d.ts +11 -11
  147. package/dist/host-lsp-manager.d.ts +2 -2
  148. package/dist/http/active-run-conflict.d.ts +35 -2
  149. package/dist/http/active-run-conflict.js +48 -19
  150. package/dist/http/admission.js +17 -2
  151. package/dist/http/approval-sweeps.d.ts +1 -1
  152. package/dist/http/approval-sweeps.js +10 -7
  153. package/dist/http/checkpoint-ctx.d.ts +4 -0
  154. package/dist/http/checkpoint-ctx.js +2 -0
  155. package/dist/http/dispatch.d.ts +8 -3
  156. package/dist/http/dispatch.js +59 -32
  157. package/dist/http/durable-run-leg.js +16 -17
  158. package/dist/http/health-reader.d.ts +16 -9
  159. package/dist/http/health-reader.js +2 -1
  160. package/dist/http/health-self-report.d.ts +9 -1
  161. package/dist/http/health-self-report.js +3 -1
  162. package/dist/http/owner-access.d.ts +33 -14
  163. package/dist/http/owner-access.js +40 -10
  164. package/dist/http/principal-gate.d.ts +49 -21
  165. package/dist/http/principal-gate.js +61 -11
  166. package/dist/http/request-channel.d.ts +23 -0
  167. package/dist/http/request-channel.js +9 -0
  168. package/dist/http/request-guards.js +17 -2
  169. package/dist/http/resume-ctx-read.js +42 -3
  170. package/dist/http/resume-legs.d.ts +4 -3
  171. package/dist/http/resume-legs.js +367 -117
  172. package/dist/http/route-ctx.d.ts +91 -15
  173. package/dist/http/route-ctx.js +17 -0
  174. package/dist/http/route-table.d.ts +5 -1
  175. package/dist/http/route-table.js +4 -0
  176. package/dist/http/routes/admin-config-refresh.js +3 -3
  177. package/dist/http/routes/admin-drain.d.ts +3 -0
  178. package/dist/http/routes/admin-drain.js +7 -7
  179. package/dist/http/routes/admin-memory-optout.d.ts +1 -1
  180. package/dist/http/routes/admin-memory-optout.js +3 -3
  181. package/dist/http/routes/adoption.js +3 -5
  182. package/dist/http/routes/agents-roster.js +2 -3
  183. package/dist/http/routes/approvals-assistant.d.ts +2 -1
  184. package/dist/http/routes/approvals-assistant.js +99 -51
  185. package/dist/http/routes/background.d.ts +3 -3
  186. package/dist/http/routes/capabilities.d.ts +4 -0
  187. package/dist/http/routes/capabilities.js +38 -10
  188. package/dist/http/routes/config-catalog.js +2 -2
  189. package/dist/http/routes/devices.js +1 -1
  190. package/dist/http/routes/diagnostics.d.ts +3 -3
  191. package/dist/http/routes/diagnostics.js +19 -7
  192. package/dist/http/routes/fleet.js +10 -8
  193. package/dist/http/routes/images.js +10 -10
  194. package/dist/http/routes/memory-bundle.js +3 -3
  195. package/dist/http/routes/memory-compliance.js +3 -3
  196. package/dist/http/routes/memory-consolidation.js +2 -2
  197. package/dist/http/routes/memory-origin.js +3 -3
  198. package/dist/http/routes/memory-policy.js +2 -2
  199. package/dist/http/routes/observability.js +3 -3
  200. package/dist/http/routes/projects.d.ts +3 -2
  201. package/dist/http/routes/projects.js +4 -5
  202. package/dist/http/routes/retention-ops.js +3 -3
  203. package/dist/http/routes/rules.js +5 -5
  204. package/dist/http/routes/run-permission-mode.d.ts +2 -1
  205. package/dist/http/routes/run-permission-mode.js +2 -2
  206. package/dist/http/routes/runs.d.ts +4 -9
  207. package/dist/http/routes/runs.js +171 -65
  208. package/dist/http/routes/session-sync.d.ts +22 -9
  209. package/dist/http/routes/session-sync.js +204 -107
  210. package/dist/http/routes/sessions-list.js +13 -7
  211. package/dist/http/routes/sessions.js +30 -15
  212. package/dist/http/routes/tasks.js +46 -41
  213. package/dist/http/routes/trace-usage.js +2 -2
  214. package/dist/http/routes/workflows.js +1 -1
  215. package/dist/http/server.d.ts +30 -30
  216. package/dist/http/server.js +16 -4
  217. package/dist/http/submit-ctx.d.ts +1 -1
  218. package/dist/http/submit-ctx.js +7 -4
  219. package/dist/http/wire-types.d.ts +14 -4
  220. package/dist/human-facing-args.d.ts +33 -0
  221. package/dist/human-facing-args.js +33 -0
  222. package/dist/identity-source.d.ts +20 -3
  223. package/dist/identity-source.js +14 -0
  224. package/dist/index.d.ts +5 -1
  225. package/dist/k8s-api-credentials.d.ts +29 -0
  226. package/dist/k8s-api-credentials.js +25 -0
  227. package/dist/lane-home-probe.d.ts +3 -7
  228. package/dist/lane-home-probe.js +2 -2
  229. package/dist/leader/diffup.d.ts +19 -0
  230. package/dist/leader/diffup.js +7 -0
  231. package/dist/leader/leader.d.ts +116 -11
  232. package/dist/leader/leader.js +69 -5
  233. package/dist/leader/repair-wire.js +2 -2
  234. package/dist/leader/run-entry.d.ts +2 -1
  235. package/dist/leader/run-entry.js +1 -1
  236. package/dist/leader/wire.d.ts +42 -132
  237. package/dist/leader/wire.js +81 -67
  238. package/dist/leg-facts.d.ts +13 -5
  239. package/dist/leg-facts.js +2 -1
  240. package/dist/memory-scope.d.ts +23 -11
  241. package/dist/memory-scope.js +18 -6
  242. package/dist/memory-sync-client.d.ts +30 -2
  243. package/dist/memory-sync-client.js +16 -9
  244. package/dist/model-entry-headers.d.ts +9 -10
  245. package/dist/model-entry-headers.js +0 -4
  246. package/dist/model-entry-refusal.d.ts +7 -4
  247. package/dist/model-entry-refusal.js +11 -5
  248. package/dist/model-plane-face.d.ts +1 -1
  249. package/dist/model-plane-face.js +3 -1
  250. package/dist/model-route-endpoint.d.ts +13 -7
  251. package/dist/model-route-endpoint.js +14 -11
  252. package/dist/model-select.d.ts +22 -0
  253. package/dist/model-select.js +9 -0
  254. package/dist/model-unreachable-notice.d.ts +11 -0
  255. package/dist/model-unreachable-notice.js +4 -4
  256. package/dist/object-store-buckets.d.ts +640 -6
  257. package/dist/object-store-buckets.js +166 -0
  258. package/dist/observability/err-text.d.ts +7 -0
  259. package/dist/observability/err-text.js +5 -0
  260. package/dist/observability/fail-open.d.ts +25 -17
  261. package/dist/observability/fail-open.js +25 -17
  262. package/dist/observability/logger.js +3 -1
  263. package/dist/observability/metrics.js +1 -0
  264. package/dist/operator-roster.d.ts +68 -0
  265. package/dist/operator-roster.js +32 -0
  266. package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
  267. package/dist/orchestration/workflow-notify-journal.js +12 -1
  268. package/dist/orchestration/workflow-park-decision.d.ts +70 -18
  269. package/dist/orchestration/workflow-park-decision.js +49 -10
  270. package/dist/orchestration/workflow-park-holder.d.ts +65 -0
  271. package/dist/orchestration/workflow-park-holder.js +98 -0
  272. package/dist/orchestration/workflow-record-fence.d.ts +36 -0
  273. package/dist/orchestration/workflow-record-fence.js +42 -0
  274. package/dist/outbound-dispatcher.d.ts +71 -8
  275. package/dist/outbound-dispatcher.js +48 -7
  276. package/dist/owner-faces.d.ts +2 -2
  277. package/dist/parked-decide.d.ts +106 -55
  278. package/dist/parked-decide.js +153 -117
  279. package/dist/peer-directory.d.ts +2 -2
  280. package/dist/peer-inbound-face.d.ts +2 -6
  281. package/dist/peer-inbound-face.js +0 -3
  282. package/dist/permission-mode-admission.d.ts +74 -5
  283. package/dist/permission-mode-admission.js +56 -3
  284. package/dist/plugins/adoption-log-sql.d.ts +3 -1
  285. package/dist/plugins/adoption-log-sql.js +7 -1
  286. package/dist/plugins/approval-ask-store-file.d.ts +14 -2
  287. package/dist/plugins/approval-ask-store-file.js +11 -0
  288. package/dist/plugins/approval-ask-store-memory.d.ts +10 -1
  289. package/dist/plugins/approval-ask-store-memory.js +35 -10
  290. package/dist/plugins/approval-ask-store-sql.d.ts +69 -4
  291. package/dist/plugins/approval-ask-store-sql.js +45 -5
  292. package/dist/plugins/approval-exemption-store.js +3 -0
  293. package/dist/plugins/approval-nonce-store.js +2 -0
  294. package/dist/plugins/blob-backend.d.ts +83 -7
  295. package/dist/plugins/blob-backend.js +57 -6
  296. package/dist/plugins/breaker-state-sql.js +2 -0
  297. package/dist/plugins/caching-session-store.d.ts +9 -15
  298. package/dist/plugins/caching-session-store.js +6 -0
  299. package/dist/plugins/checkpoint-index-columns.d.ts +20 -16
  300. package/dist/plugins/checkpoint-index-columns.js +3 -6
  301. package/dist/plugins/checkpoint-store-face.d.ts +119 -61
  302. package/dist/plugins/checkpoint-store-face.js +134 -55
  303. package/dist/plugins/device-store-sql.js +6 -0
  304. package/dist/plugins/error-origin.d.ts +18 -0
  305. package/dist/plugins/error-origin.js +10 -0
  306. package/dist/plugins/execution-placement-sql.js +6 -6
  307. package/dist/plugins/image-bake-store-sql.js +6 -0
  308. package/dist/plugins/image-index-sql.js +4 -0
  309. package/dist/plugins/landed-attendants.d.ts +212 -0
  310. package/dist/plugins/landed-attendants.js +161 -0
  311. package/dist/plugins/leader-run-store-sql.js +4 -0
  312. package/dist/plugins/local-checkpoint-store.d.ts +13 -3
  313. package/dist/plugins/local-checkpoint-store.js +38 -49
  314. package/dist/plugins/local-session-live-reference.d.ts +40 -0
  315. package/dist/plugins/local-session-live-reference.js +39 -0
  316. package/dist/plugins/local-session-store.d.ts +71 -33
  317. package/dist/plugins/local-session-store.js +129 -27
  318. package/dist/plugins/memory-engine-pg.js +4 -0
  319. package/dist/plugins/memory-engine-sql-apply.js +5 -2
  320. package/dist/plugins/memory-engine-tidb.js +4 -0
  321. package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
  322. package/dist/plugins/memory-sync-store-pg.js +5 -0
  323. package/dist/plugins/memory-sync-store-tidb.js +5 -0
  324. package/dist/plugins/one-time-migrations.d.ts +104 -80
  325. package/dist/plugins/one-time-migrations.js +226 -132
  326. package/dist/plugins/org-delivery-quota-store.js +4 -1
  327. package/dist/plugins/outcome-ledger-sql.js +2 -0
  328. package/dist/plugins/permission-rule-store-sql.js +11 -4
  329. package/dist/plugins/pg-cost-quota.js +4 -0
  330. package/dist/plugins/pg-pool.js +35 -10
  331. package/dist/plugins/pg-rate-limiter.js +2 -0
  332. package/dist/plugins/posix-shell-fs.d.ts +6 -1
  333. package/dist/plugins/posix-shell-fs.js +4 -1
  334. package/dist/plugins/remote-env-adb.d.ts +19 -15
  335. package/dist/plugins/remote-env-adb.js +41 -15
  336. package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
  337. package/dist/plugins/remote-env-connect-seat.js +72 -0
  338. package/dist/plugins/remote-env-device.d.ts +22 -5
  339. package/dist/plugins/remote-env-device.js +106 -8
  340. package/dist/plugins/remote-env-e2b.d.ts +15 -6
  341. package/dist/plugins/remote-env-e2b.js +42 -32
  342. package/dist/plugins/remote-env-file-error.js +6 -2
  343. package/dist/plugins/remote-env-host.d.ts +46 -10
  344. package/dist/plugins/remote-env-host.js +124 -52
  345. package/dist/plugins/remote-env-k8s.d.ts +109 -41
  346. package/dist/plugins/remote-env-k8s.js +160 -54
  347. package/dist/plugins/remote-env-local-docker.d.ts +13 -8
  348. package/dist/plugins/remote-env-local-docker.js +34 -41
  349. package/dist/plugins/remote-env-ssh.d.ts +18 -12
  350. package/dist/plugins/remote-env-ssh.js +60 -59
  351. package/dist/plugins/remote-shell.d.ts +98 -1
  352. package/dist/plugins/remote-shell.js +218 -0
  353. package/dist/plugins/replica-registration.d.ts +1 -1
  354. package/dist/plugins/replica-registration.js +1 -1
  355. package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
  356. package/dist/plugins/resume-anchor-store-sql.js +12 -5
  357. package/dist/plugins/retention-lane-store-sql.js +4 -0
  358. package/dist/plugins/retention-sql.d.ts +20 -2
  359. package/dist/plugins/retention-sql.js +11 -0
  360. package/dist/plugins/run-store-sql.d.ts +21 -2
  361. package/dist/plugins/run-store-sql.js +31 -7
  362. package/dist/plugins/s3-presign.d.ts +23 -0
  363. package/dist/plugins/s3-presign.js +37 -3
  364. package/dist/plugins/scenario-prefix-switch-m42.d.ts +1 -1
  365. package/dist/plugins/scenario-prefix-switch-m42.js +2 -2
  366. package/dist/plugins/scheduler-support.d.ts +2 -2
  367. package/dist/plugins/scheduler-support.js +0 -3
  368. package/dist/plugins/schema-consistency.d.ts +4 -2
  369. package/dist/plugins/schema-consistency.js +19 -2
  370. package/dist/plugins/schema-indexes.js +2 -0
  371. package/dist/plugins/send-file-ledger.d.ts +2 -2
  372. package/dist/plugins/send-file-ledger.js +5 -2
  373. package/dist/plugins/send-user-file.d.ts +3 -4
  374. package/dist/plugins/send-user-file.js +56 -52
  375. package/dist/plugins/serving-requirement.d.ts +26 -7
  376. package/dist/plugins/serving-requirement.js +11 -4
  377. package/dist/plugins/session-birth.d.ts +6 -2
  378. package/dist/plugins/session-blob-claim-token.d.ts +15 -0
  379. package/dist/plugins/session-blob-claim-token.js +20 -0
  380. package/dist/plugins/session-blob-namespace.d.ts +46 -0
  381. package/dist/plugins/session-blob-namespace.js +116 -0
  382. package/dist/plugins/session-capture-record-store-sql.js +2 -0
  383. package/dist/plugins/session-ext-table.d.ts +14 -1
  384. package/dist/plugins/session-ext-table.js +5 -1
  385. package/dist/plugins/session-row-sql.d.ts +49 -2
  386. package/dist/plugins/session-row-sql.js +56 -13
  387. package/dist/plugins/session-store-sql.d.ts +34 -18
  388. package/dist/plugins/session-store-sql.js +98 -17
  389. package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
  390. package/dist/plugins/shared-memory-store-sql.js +6 -2
  391. package/dist/plugins/snapshot-bucket-presence.d.ts +25 -2
  392. package/dist/plugins/snapshot-bucket-presence.js +8 -2
  393. package/dist/plugins/sql-driver.d.ts +2 -1
  394. package/dist/plugins/sql-driver.js +18 -3
  395. package/dist/plugins/sql-errors.d.ts +11 -6
  396. package/dist/plugins/sql-errors.js +5 -6
  397. package/dist/plugins/sql-json-column.d.ts +1 -1
  398. package/dist/plugins/stop-then-start-sentence.d.ts +10 -4
  399. package/dist/plugins/stop-then-start-sentence.js +14 -10
  400. package/dist/plugins/stop-then-start.d.ts +109 -0
  401. package/dist/plugins/stop-then-start.js +104 -0
  402. package/dist/plugins/store-backend.d.ts +84 -15
  403. package/dist/plugins/store-backend.js +236 -72
  404. package/dist/plugins/store-boundary.d.ts +57 -0
  405. package/dist/plugins/store-boundary.js +139 -0
  406. package/dist/plugins/store-contracts.d.ts +17 -0
  407. package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
  408. package/dist/plugins/store-fault-sentence-m53.js +25 -0
  409. package/dist/plugins/store-fault.d.ts +26 -7
  410. package/dist/plugins/store-fault.js +18 -2
  411. package/dist/plugins/task-attachment-store.d.ts +2 -1
  412. package/dist/plugins/task-attachment-store.js +14 -1
  413. package/dist/plugins/task-list-store-sql.d.ts +2 -2
  414. package/dist/plugins/task-list-store-sql.js +10 -8
  415. package/dist/plugins/tidb-cost-quota.js +4 -0
  416. package/dist/plugins/tidb-pool.js +21 -25
  417. package/dist/plugins/tidb-rate-limiter.js +4 -0
  418. package/dist/plugins/user-input-ledger-sql.js +4 -0
  419. package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
  420. package/dist/plugins/workflow-run-store-sql.js +64 -4
  421. package/dist/plugins/workspace-custody.d.ts +4 -3
  422. package/dist/plugins/workspace-fill.d.ts +4 -7
  423. package/dist/plugins/workspace-fill.js +2 -1
  424. package/dist/plugins/write-behind-counter.js +5 -0
  425. package/dist/project-context.d.ts +0 -2
  426. package/dist/project-context.js +4 -8
  427. package/dist/project-registry.d.ts +46 -0
  428. package/dist/project-registry.js +44 -0
  429. package/dist/question.d.ts +2 -1
  430. package/dist/question.js +5 -13
  431. package/dist/request-form.d.ts +6 -1
  432. package/dist/request-form.js +4 -1
  433. package/dist/request-key-closure.js +1 -1
  434. package/dist/request-value-closure.d.ts +4 -0
  435. package/dist/request-value-closure.js +10 -0
  436. package/dist/rule-issue-reading.d.ts +1 -1
  437. package/dist/rules-consent.d.ts +1 -1
  438. package/dist/run-acceptance.d.ts +3 -2
  439. package/dist/run-acceptance.js +4 -6
  440. package/dist/run-local.js +9 -9
  441. package/dist/runs.d.ts +54 -16
  442. package/dist/runs.js +67 -13
  443. package/dist/runtime-governance.d.ts +5 -4
  444. package/dist/security.d.ts +30 -32
  445. package/dist/security.js +41 -7
  446. package/dist/sema-config-dir.d.ts +2 -1
  447. package/dist/server-secret-env.d.ts +12 -10
  448. package/dist/server-secret-env.js +24 -15
  449. package/dist/session-bindings.d.ts +82 -0
  450. package/dist/session-bindings.js +18 -0
  451. package/dist/session-children-retire.d.ts +2 -2
  452. package/dist/session-children-retire.js +2 -6
  453. package/dist/session-deletion.d.ts +16 -1
  454. package/dist/session-error-wire.d.ts +3 -3
  455. package/dist/session-error-wire.js +3 -3
  456. package/dist/session-incarnation.d.ts +10 -0
  457. package/dist/session-incarnation.js +10 -1
  458. package/dist/session-kind.d.ts +57 -0
  459. package/dist/session-kind.js +22 -0
  460. package/dist/session-row.d.ts +21 -1
  461. package/dist/session-row.js +7 -1
  462. package/dist/session-sync-kernel.d.ts +24 -14
  463. package/dist/session-sync-kernel.js +3 -6
  464. package/dist/session-sync.d.ts +25 -103
  465. package/dist/session-sync.js +14 -76
  466. package/dist/session-titler.d.ts +10 -3
  467. package/dist/session-titler.js +19 -6
  468. package/dist/ssh-host-key.d.ts +5 -0
  469. package/dist/ssh-host-key.js +3 -0
  470. package/dist/stores-sql/blob-index-sql.d.ts +30 -9
  471. package/dist/stores-sql/blob-index-sql.js +40 -21
  472. package/dist/stores-sql/checkpoint-store-sql.d.ts +54 -27
  473. package/dist/stores-sql/checkpoint-store-sql.js +70 -146
  474. package/dist/stores-sql/file-history-store-sql.d.ts +113 -15
  475. package/dist/stores-sql/file-history-store-sql.js +205 -95
  476. package/dist/stores-sql/pg-session-storage.d.ts +34 -7
  477. package/dist/stores-sql/pg-session-storage.js +37 -13
  478. package/dist/stores-sql/retention-store-sql.d.ts +1 -9
  479. package/dist/stores-sql/retention-store-sql.js +5 -19
  480. package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
  481. package/dist/stores-sql/session-policy-store-sql.js +61 -44
  482. package/dist/stores-sql/session-write-hooks.d.ts +11 -0
  483. package/dist/stores-sql/tidb-session-store.d.ts +58 -7
  484. package/dist/stores-sql/tidb-session-store.js +37 -13
  485. package/dist/submission-exit.d.ts +3 -2
  486. package/dist/submission-exit.js +9 -1
  487. package/dist/task-cwd.d.ts +2 -2
  488. package/dist/task-settings.d.ts +7 -5
  489. package/dist/task-settings.js +3 -3
  490. package/dist/terminal.d.ts +33 -2
  491. package/dist/terminal.js +139 -9
  492. package/dist/tool-approval.d.ts +465 -507
  493. package/dist/tool-approval.js +606 -1222
  494. package/dist/trace/core-keyset-guard.d.ts +1 -1
  495. package/dist/trace/ledger-events.d.ts +3 -3
  496. package/dist/trace/project.d.ts +2 -3
  497. package/dist/trace/redact.js +3 -2
  498. package/dist/trace/self-minted-wire.d.ts +571 -178
  499. package/dist/trace/self-minted-wire.js +189 -56
  500. package/dist/web-admin-client/apply-effective.js +2 -2
  501. package/dist/web-admin-client/read-warnings.d.ts +2 -2
  502. package/dist/web-admin-client/read-warnings.js +1 -1
  503. package/dist/web-admin-client/types.d.ts +1 -1
  504. package/dist/workspace-space.d.ts +10 -4
  505. package/dist/workspace-space.js +4 -1
  506. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +79 -28
  507. package/package.json +7 -3
  508. package/scripts/embed-minimal.mjs +3 -3
  509. package/wire-changes/server@7.151.0.json +762 -0
  510. package/wire-changes/server@7.152.0.json +900 -0
  511. package/dist/config-d-migration.d.ts +0 -37
  512. package/dist/config-d-migration.js +0 -60
  513. package/dist/http/session-inherit-env.d.ts +0 -36
  514. package/dist/http/session-inherit-env.js +0 -6
@@ -8,7 +8,7 @@ import { FileWorkflowJournalStore } from "@sema-agent/core";
8
8
  import { fileSessionCaptureRecordStore } from "@sema-agent/core";
9
9
  import { TiDBOutcomeLedger, PgOutcomeLedger } from "./outcome-ledger-sql.js";
10
10
  import { FileOutcomeSink } from "./file-outcome-sink.js";
11
- import { TiDBWorkflowRunStore, TiDBWorkflowCompletionInbox, TiDBWorkflowNotifyJournalStore, TiDBWorkflowAgentSessionIndex, SqlWorkflowParkDecisionStore, PgWorkflowRunStore, PgWorkflowCompletionInbox, PgWorkflowNotifyJournalStore, PgWorkflowAgentSessionIndex } from "./workflow-run-store-sql.js";
11
+ import { TiDBWorkflowRunStore, TiDBWorkflowCompletionInbox, TiDBWorkflowNotifyJournalStore, TiDBWorkflowAgentSessionIndex, SqlWorkflowParkDecisionStore, SqlWorkflowRunStore, PgWorkflowRunStore, PgWorkflowCompletionInbox, PgWorkflowNotifyJournalStore, PgWorkflowAgentSessionIndex } from "./workflow-run-store-sql.js";
12
12
  import { FileRunStore } from "./file-run-store.js";
13
13
  import { LocalWorkflowParkDecisionStore } from "../orchestration/workflow-park-decision.js";
14
14
  import { StoreBootRefusalError } from "./store-contracts.js";
@@ -25,6 +25,7 @@ import { SKILL_EXEMPTION_CUTOFF_ID } from "./one-time-migration-marker.js";
25
25
  import { LocalTaskAttachmentStore } from "./local-task-attachment-store.js";
26
26
  import { assertRetiredSchemaAbsentOnPool } from "./schema-consistency.js";
27
27
  import { LocalSessionStore, createLocalSessionRepo } from "./local-session-store.js";
28
+ import { createLocalWorkflowRunsSeat } from "./local-session-live-reference.js";
28
29
  import { localStoreDeclarationOf } from "../local-store-declaration.js";
29
30
  import { SESSION_PLACEMENTS } from "./session-placement.js";
30
31
  import { LocalCheckpointStore, dropLocalCheckpointCtxStrict } from "./local-checkpoint-store.js";
@@ -40,19 +41,22 @@ import { TiDBSendFileLedger, PgSendFileLedger, FileSendFileLedger } from "./send
40
41
  import { FileUserInputLedgerStore } from "./user-input-ledger-file.js";
41
42
  import { TiDBUserInputLedgerStore, PgUserInputLedgerStore } from "./user-input-ledger-sql.js";
42
43
  import { TiDBResumeAnchorStore, PgResumeAnchorStore } from "./resume-anchor-store-sql.js";
43
- import { TiDBSessionPolicyStore, PgSessionPolicyStore } from "../stores-sql/session-policy-store-sql.js";
44
- import { countClientWriteOn } from "./session-withdraw-sql.js";
45
- import { TiDBWorkflowJournalStore, PgWorkflowJournalStore } from "../stores-sql/workflow-journal-store-sql.js";
46
- import { TiDBFileHistoryStore, PgFileHistoryStore, FILE_HISTORY_BLOB_KEY_PREFIX } from "../stores-sql/file-history-store-sql.js";
47
- import { SqlBlobIndex } from "../stores-sql/blob-index-sql.js";
48
- import { MinioBlobBackend } from "./blob-backend.js";
44
+ import { TiDBSessionPolicyStore, PgSessionPolicyStore, SqlSessionPolicyStore } from "../stores-sql/session-policy-store-sql.js";
45
+ import { SQL_SESSION_ROOT_SEAT } from "./session-row-sql.js";
46
+ import { TiDBWorkflowJournalStore, PgWorkflowJournalStore, SqlWorkflowJournalStore } from "../stores-sql/workflow-journal-store-sql.js";
47
+ import { TiDBFileHistoryStore, PgFileHistoryStore, SqlFileHistoryStore, SqlBlobExchange, SqlBlobLanding } from "../stores-sql/file-history-store-sql.js";
48
+ import { createLocalLandedAttendantSeat, createSqlLandedAttendantSeat } from "./landed-attendants.js";
49
+ import { SqlBlobIndex, blobGcCutoffAt } from "../stores-sql/blob-index-sql.js";
50
+ import { createSessionBlobBackend } from "./blob-backend.js";
51
+ import { createSessionBlobNamespace } from "./session-blob-namespace.js";
52
+ import { ensureSessionBlobClaimToken } from "./session-blob-claim-token.js";
49
53
  import { buildDisplaySafeUrl } from "../trace/redact.js";
50
54
  import { fileMemoryControlDirFor, memoryEngineRootFor } from "../memory-scope.js";
51
55
  import { createTidbPool, ensureSchema as ensureTidbSchema } from "./tidb-pool.js";
52
56
  import { createPgPool, ensurePgSchema, pgPoolOptions } from "./pg-pool.js";
53
57
  import { TiDBRunStore, PgRunStore } from "./run-store-sql.js";
54
- import { TiDBCheckpointStore, PgCheckpointStore } from "../stores-sql/checkpoint-store-sql.js";
55
- import { TiDBToolResultStore, PgToolResultStore } from "../stores-sql/tool-result-store-sql.js";
58
+ import { TiDBCheckpointStore, PgCheckpointStore, SqlCheckpointStore } from "../stores-sql/checkpoint-store-sql.js";
59
+ import { TiDBToolResultStore, PgToolResultStore, SqlToolResultStore } from "../stores-sql/tool-result-store-sql.js";
56
60
  import { TiDBImageIndex, PgImageIndex } from "./image-index-sql.js";
57
61
  import { TiDBImageBake, PgImageBake } from "./image-bake-store-sql.js";
58
62
  import { TiDBLeaderRunStore, PgLeaderRunStore } from "./leader-run-store-sql.js";
@@ -62,8 +66,8 @@ import { TiDBCostQuota } from "./tidb-cost-quota.js";
62
66
  import { PgCostQuota } from "./pg-cost-quota.js";
63
67
  import { TiDBRateLimiter } from "./tidb-rate-limiter.js";
64
68
  import { PgRateLimiter } from "./pg-rate-limiter.js";
65
- import { TiDBSessionStore } from "../stores-sql/tidb-session-store.js";
66
- import { PgSessionStore } from "../stores-sql/pg-session-storage.js";
69
+ import { TiDBSessionStore, TiDBStagingHandle } from "../stores-sql/tidb-session-store.js";
70
+ import { PgSessionStore, PgSessionStorage, PgStagingHandle } from "../stores-sql/pg-session-storage.js";
67
71
  import { SqlSessionStore } from "./session-store-sql.js";
68
72
  import { TiDBSharedMemoryStore, PgSharedMemoryStore } from "./shared-memory-store-sql.js";
69
73
  import { TiDBAdoptionLogStore, PgAdoptionLogStore } from "./adoption-log-sql.js";
@@ -83,6 +87,14 @@ import { admitLocalDataRoot, holdLocalDataRootAdmission } from "./local-data-roo
83
87
  import { mysqlDriver, pgDriver } from "./sql-driver.js";
84
88
  import { localDataRootHoldsData, storeDegradedReasonFor } from "../store-posture.js";
85
89
  import { openWithinWait } from "./store-open-wait.js";
90
+ import { sealStoreClass, sealStoreObject } from "./store-boundary.js";
91
+ import { WindowedSessionStorage } from "../stores-sql/windowed-session-storage.js";
92
+ import { PgBackgroundAgentStore, TiDBBackgroundAgentStore } from "../stores-sql/background-agent-store-sql.js";
93
+ import { PgMailboxStore, TiDBMailboxStore } from "../stores-sql/mailbox-store-sql.js";
94
+ import { PgRosterStore, TiDBRosterStore } from "../stores-sql/roster-store-sql.js";
95
+ import { TiDBSessionStorage } from "../stores-sql/tidb-session-storage.js";
96
+ import { PgUsageWindowStore, TiDBUsageWindowStore } from "../stores-sql/usage-window-store-sql.js";
97
+ import { createCardScopeRootSeat } from "./checkpoint-store-face.js";
86
98
  export function createRunStallWiring(config, observers) {
87
99
  const count = observers?.runStallVerdicts;
88
100
  return { windowMs: () => config.runStaleSec * 1000, onVerdicts: (landed) => count?.(landed) };
@@ -90,19 +102,10 @@ export function createRunStallWiring(config, observers) {
90
102
  export function workflowJournalOf(config, backend) {
91
103
  return config.selfOrchestrationEnabled && backend ? backend.workflowJournal() : undefined;
92
104
  }
93
- function fileHistoryOptions(config) {
94
- const s = config.snapshotBlobStore;
95
- const placement = s
105
+ function fileHistoryOptions(config, namespace) {
106
+ const placement = namespace
96
107
  ? {
97
- blobs: new MinioBlobBackend({
98
- endpoint: s.endpoint,
99
- bucket: s.bucket,
100
- accessKey: s.accessKey,
101
- secretKey: s.secretKey,
102
- ...(s.region ? { region: s.region } : {}),
103
- keyPrefix: `${s.keyPrefix ?? ""}${FILE_HISTORY_BLOB_KEY_PREFIX}`,
104
- ...(s.presignTtlSec ? { presignTtlSec: s.presignTtlSec } : {}),
105
- }),
108
+ blobs: createSessionBlobBackend(namespace, "file-history"),
106
109
  }
107
110
  : {
108
111
  ...(config.snapshotBlobSqlMaxBytes !== undefined ? { blobSqlMaxBytes: config.snapshotBlobSqlMaxBytes } : {}),
@@ -110,35 +113,21 @@ function fileHistoryOptions(config) {
110
113
  };
111
114
  return { ...config.fileHistory, ...placement };
112
115
  }
113
- function legacyBlobIndex(config, dialect, pool) {
114
- const s = config.snapshotBlobStore;
115
- const bytes = s
116
- ? new MinioBlobBackend({
117
- endpoint: s.endpoint,
118
- bucket: s.bucket,
119
- accessKey: s.accessKey,
120
- secretKey: s.secretKey,
121
- ...(s.region ? { region: s.region } : {}),
122
- ...(s.keyPrefix ? { keyPrefix: s.keyPrefix } : {}),
123
- ...(s.presignTtlSec ? { presignTtlSec: s.presignTtlSec } : {}),
124
- })
125
- : undefined;
116
+ function legacyBlobIndex(config, dialect, pool, namespace) {
117
+ const bytes = namespace ? createSessionBlobBackend(namespace, "legacy-blobs") : undefined;
126
118
  return new SqlBlobIndex(dialect, pool, { table: "snapshot_blob", ...(bytes !== undefined ? { bytes } : {}), log: createLogger(config.logLevel) });
127
119
  }
128
- async function legacySweepImpl(config, dialect, pool) {
120
+ async function legacySweepImpl(config, dialect, pool, namespace) {
129
121
  const sql = "SELECT blob_hash FROM snapshot_blob";
130
- let orphans;
131
- if (dialect === "mysql") {
132
- const [rows] = await pool.query(sql);
133
- orphans = rows.map((r) => String(r.blob_hash));
134
- }
135
- else {
122
+ const collect = async () => {
123
+ if (dialect === "mysql") {
124
+ const [rows] = await pool.query(sql);
125
+ return rows.map((r) => String(r.blob_hash));
126
+ }
136
127
  const r = await pool.query(sql);
137
- orphans = r.rows.map((row) => row.blob_hash);
138
- }
139
- if (orphans.length === 0)
140
- return 0;
141
- return legacyBlobIndex(config, dialect, pool).sweep(orphans);
128
+ return r.rows.map((row) => row.blob_hash);
129
+ };
130
+ return legacyBlobIndex(config, dialect, pool, namespace).sweep(collect, blobGcCutoffAt(Date.now()));
142
131
  }
143
132
  export function createSqlRetentionCallHooks(db, opts, input) {
144
133
  const deployment = createRetentionDeploymentHooks(db.dialect, opts, input);
@@ -151,7 +140,7 @@ export function createSqlRetentionExecutor(db, opts) {
151
140
  const hooks = createSqlRetentionCallHooks(db, opts, input);
152
141
  return { store: new SqlRetentionStore(db, { ...storeOpts, transactionHooks: hooks.hooks }), hooks, call: { domain: input.domain, cutoffMs: input.cutoffMs } };
153
142
  };
154
- return {
143
+ return sealStoreObject({
155
144
  retention: reads.retention,
156
145
  listRetentionDomains: () => reads.listRetentionDomains(),
157
146
  previewRetention: (input) => reads.previewRetention(input),
@@ -171,7 +160,7 @@ export function createSqlRetentionExecutor(db, opts) {
171
160
  const one = forCall(input);
172
161
  return one.store.deleteOrphanToolResults(one.call);
173
162
  },
174
- };
163
+ }, "sql-retention-executor", { listRetentionDomains: "exit", previewRetention: "exit", expireCheckpoints: "exit", deleteExpiredSessions: "exit", deleteOrphanToolResults: "exit" });
175
164
  }
176
165
  async function afterSessionErase(db, opts, sessions) {
177
166
  if (!opts.completionInbox || sessions.length === 0)
@@ -180,7 +169,7 @@ async function afterSessionErase(db, opts, sessions) {
180
169
  }
181
170
  export function createSqlSessionEraser(db, opts) {
182
171
  const storeOpts = { ...(opts.mailboxTables ? { sessionBoxScope: sessionTenantScope } : {}), ...(opts.logger !== undefined ? { logger: opts.logger } : {}) };
183
- return {
172
+ return sealStoreObject({
184
173
  async erase(input) {
185
174
  const rows = createSessionRowsHook(db.dialect, opts, input.owner ?? "");
186
175
  const store = new SqlRetentionStore(db, { ...storeOpts, transactionHooks: { retention: { beforeDelete: rows.beforeDelete }, session: createSqlSessionWriteHooks(db) } });
@@ -201,7 +190,7 @@ export function createSqlSessionEraser(db, opts) {
201
190
  }
202
191
  }
203
192
  },
204
- };
193
+ }, "sql-session-eraser", { erase: "exit" });
205
194
  }
206
195
  export function assertCloudSnapshotBlobPosture(kind, config) {
207
196
  if (kind === "local" || config.snapshotBlobStore || config.snapshotBlobAllowSql)
@@ -226,21 +215,49 @@ const SQL_BLOB_POSTURE_FACTS = {
226
215
  export function buildSqlOneTimeMigrationInput(config) {
227
216
  return { lanes: deployedExecutionLanes(config), liveRunWindowMs: config.runStaleSec * 1000, identityBoundary: DEPLOYMENT_SHAPE_PREDICATES.identityBoundary.holds(config) };
228
217
  }
218
+ function decisionStoreBoundOnce(held, records, make) {
219
+ if (held === undefined)
220
+ return make();
221
+ if (held.records !== records)
222
+ throw new Error("store backend: the workflow park decision store is already bound to another workflow record store — a backend keeps one decision store, fenced by the one record store every workflow record write goes through");
223
+ return held;
224
+ }
225
+ function sqlRecordFenceOf(records) {
226
+ if (records instanceof SqlWorkflowRunStore)
227
+ return records;
228
+ throw new Error("SQL store backend: the workflow park decision store's record fence must be this backend's SQL workflow record store (workflowRun()) — a decision row is written in the same transaction that locks the run's record row");
229
+ }
230
+ function policyStoreLoggerOf(onWarn) {
231
+ return onWarn !== undefined ? { warn: (msg, fields) => onWarn(msg, fields) } : createLogger();
232
+ }
233
+ export function sqlLandedAttendantsOf(db, history, policy) {
234
+ return createSqlLandedAttendantSeat(db, { history, policy });
235
+ }
229
236
  class TiDBBackend {
230
237
  pool;
231
238
  config;
232
239
  observers;
240
+ onWarn;
233
241
  kind = "mysql";
234
- constructor(pool, config, observers) {
242
+ constructor(pool, config, observers, onWarn) {
235
243
  this.pool = pool;
236
244
  this.config = config;
237
245
  this.observers = observers;
246
+ this.onWarn = onWarn;
247
+ this.blobNamespaceInst = config.snapshotBlobStore ? createSessionBlobNamespace(config.snapshotBlobStore) : undefined;
248
+ }
249
+ async ensureSchema() {
250
+ await ensureTidbSchema(this.pool);
251
+ if (this.blobNamespaceInst)
252
+ this.blobNamespaceInst.bind(await ensureSessionBlobClaimToken(mysqlDriver(this.pool)));
238
253
  }
239
- ensureSchema() { return ensureTidbSchema(this.pool); }
240
254
  close() { return this.pool.end(); }
255
+ sessionBlobNamespace() { return this.blobNamespaceInst; }
256
+ blobNamespaceInst;
241
257
  run() { return (this.runStoreInst ??= new TiDBRunStore(this.pool, createRunStallWiring(this.config, this.observers))); }
242
258
  runStoreInst;
243
- resumeAnchor() { return new TiDBResumeAnchorStore(this.pool); }
259
+ resumeAnchor() { return (this.resumeAnchorInst ??= new TiDBResumeAnchorStore(this.pool)); }
260
+ resumeAnchorInst;
244
261
  approvalExemption() { return new TiDBApprovalExemptionStore(this.pool); }
245
262
  approvalNonce() { return new TiDBApprovalNonceStore(this.pool); }
246
263
  orgDeliveryQuota() { return new TiDBOrgDeliveryQuotaStore(this.pool); }
@@ -248,12 +265,16 @@ class TiDBBackend {
248
265
  permissionRule() { return createSqlPermissionRuleStores(mysqlDriver(this.pool)); }
249
266
  sendFileLedger() { return new TiDBSendFileLedger(this.pool); }
250
267
  userInputLedger() { return new TiDBUserInputLedgerStore(this.pool); }
251
- sessionPolicy(logger) { return new TiDBSessionPolicyStore(this.pool, countClientWriteOn, logger ?? createLogger()); }
252
- fileHistory() { return new TiDBFileHistoryStore(this.pool, fileHistoryOptions(this.config)); }
268
+ sessionPolicy() { return (this.sessionPolicyInst ??= new TiDBSessionPolicyStore(this.pool, SQL_SESSION_ROOT_SEAT, policyStoreLoggerOf(this.onWarn))); }
269
+ sessionPolicyInst;
270
+ fileHistory() { return (this.fileHistoryInst ??= new TiDBFileHistoryStore(this.pool, fileHistoryOptions(this.config, this.sessionBlobNamespace()))); }
271
+ fileHistoryInst;
272
+ landedAttendants() { return (this.landedAttendantsInst ??= sqlLandedAttendantsOf(mysqlDriver(this.pool), this.fileHistory(), this.sessionPolicy())); }
273
+ landedAttendantsInst;
253
274
  memoryOptOutGrant() { return new TiDBMemoryOptOutGrantStore(this.pool); }
254
275
  sessionCaptureRecords() { return () => (this.captureRecordsInst ??= new TiDBSessionCaptureRecordStore(this.pool)); }
255
276
  captureRecordsInst;
256
- legacySnapshotBlobSweep() { return legacySweepImpl(this.config, "mysql", this.pool); }
277
+ legacySnapshotBlobSweep() { return legacySweepImpl(this.config, "mysql", this.pool, this.sessionBlobNamespace()); }
257
278
  runOneTimeMigrations() { return runSqlOneTimeMigrations("mysql", this.pool, buildSqlOneTimeMigrationInput(this.config)); }
258
279
  workflowJournal() { return new TiDBWorkflowJournalStore(this.pool); }
259
280
  outcomeSink() { return new TiDBOutcomeLedger(this.pool); }
@@ -261,10 +282,12 @@ class TiDBBackend {
261
282
  completionInbox(onWarn) { return new TiDBWorkflowCompletionInbox(this.pool, onWarn); }
262
283
  notifyJournal() { return new TiDBWorkflowNotifyJournalStore(this.pool); }
263
284
  workflowAgentSessionIndex() { return new TiDBWorkflowAgentSessionIndex(this.pool); }
264
- workflowParkDecisions() { return (this.parkDecisionsInst ??= new SqlWorkflowParkDecisionStore(this.run())); }
285
+ workflowParkDecisions(records) { return (this.parkDecisionsInst = decisionStoreBoundOnce(this.parkDecisionsInst, records, () => new SqlWorkflowParkDecisionStore(this.run(), sqlRecordFenceOf(records)))); }
265
286
  parkDecisionsInst;
266
287
  sharedMemoryStore(authorizer) { return new TiDBSharedMemoryStore(this.pool, authorizer); }
267
- checkpoint(logger) { return new TiDBCheckpointStore(this.pool, logger, { retention: sqlStoreRetention(this.config.retentionSweep) }); }
288
+ cardScopeRootSeat = createCardScopeRootSeat();
289
+ bindCardScopeRoot(read) { this.cardScopeRootSeat.bind(read); }
290
+ checkpoint(logger) { return new TiDBCheckpointStore(this.pool, logger, { retention: sqlStoreRetention(this.config.retentionSweep), cardScopeRoot: this.cardScopeRootSeat }); }
268
291
  checkpointReadView() { return this.checkpoint(); }
269
292
  toolResult() { return new TiDBToolResultStore(this.pool, { retention: sqlStoreRetention(this.config.retentionSweep) }); }
270
293
  imageIndex() { return new TiDBImageIndex(this.pool); }
@@ -283,21 +306,40 @@ class TiDBBackend {
283
306
  pgPool() { return undefined; }
284
307
  async dbNowMs() { const [rows] = await this.pool.query("SELECT ROUND(UNIX_TIMESTAMP(NOW(3))*1000) AS ms"); return Number(rows[0]?.ms); }
285
308
  }
309
+ sealStoreClass(TiDBBackend, "tidb-backend", {
310
+ ensureSchema: "boot", close: "boot", sessionBlobNamespace: "exit", run: "exit", resumeAnchor: "exit", approvalExemption: "exit", approvalNonce: "exit", orgDeliveryQuota: "exit",
311
+ approvalAsk: "exit", permissionRule: "exit", sendFileLedger: "exit", userInputLedger: "exit", sessionPolicy: "exit", fileHistory: "exit",
312
+ memoryOptOutGrant: "exit", sessionCaptureRecords: "exit", legacySnapshotBlobSweep: "exit", runOneTimeMigrations: "boot", workflowJournal: "exit",
313
+ outcomeSink: "exit", workflowRun: "exit", completionInbox: "exit", notifyJournal: "exit", workflowAgentSessionIndex: "exit", workflowParkDecisions: "exit",
314
+ sharedMemoryStore: "exit", checkpoint: "exit", checkpointReadView: "exit", toolResult: "exit", imageIndex: "exit", imageBake: "exit", leaderRun: "exit",
315
+ device: "exit", retention: "exit", sessionEraser: "exit", retentionLane: "exit", breaker: "exit", costQuota: "exit", rateLimiter: "exit", session: "exit",
316
+ adoptionLog: "exit", mysqlPool: "boot", pgPool: "boot", dbNowMs: "exit", landedAttendants: "exit", bindCardScopeRoot: "exit",
317
+ });
286
318
  class PgBackend {
287
319
  pool;
288
320
  config;
289
321
  observers;
322
+ onWarn;
290
323
  kind = "pg";
291
- constructor(pool, config, observers) {
324
+ constructor(pool, config, observers, onWarn) {
292
325
  this.pool = pool;
293
326
  this.config = config;
294
327
  this.observers = observers;
328
+ this.onWarn = onWarn;
329
+ this.blobNamespaceInst = config.snapshotBlobStore ? createSessionBlobNamespace(config.snapshotBlobStore) : undefined;
330
+ }
331
+ async ensureSchema() {
332
+ await ensurePgSchema(this.pool);
333
+ if (this.blobNamespaceInst)
334
+ this.blobNamespaceInst.bind(await ensureSessionBlobClaimToken(pgDriver(this.pool)));
295
335
  }
296
- ensureSchema() { return ensurePgSchema(this.pool); }
297
336
  close() { return this.pool.end(); }
337
+ sessionBlobNamespace() { return this.blobNamespaceInst; }
338
+ blobNamespaceInst;
298
339
  run() { return (this.runStoreInst ??= new PgRunStore(this.pool, createRunStallWiring(this.config, this.observers))); }
299
340
  runStoreInst;
300
- resumeAnchor() { return new PgResumeAnchorStore(this.pool); }
341
+ resumeAnchor() { return (this.resumeAnchorInst ??= new PgResumeAnchorStore(this.pool)); }
342
+ resumeAnchorInst;
301
343
  approvalExemption() { return new PgApprovalExemptionStore(this.pool); }
302
344
  approvalNonce() { return new PgApprovalNonceStore(this.pool); }
303
345
  orgDeliveryQuota() { return new PgOrgDeliveryQuotaStore(this.pool); }
@@ -305,12 +347,16 @@ class PgBackend {
305
347
  permissionRule() { return createSqlPermissionRuleStores(pgDriver(this.pool)); }
306
348
  sendFileLedger() { return new PgSendFileLedger(this.pool); }
307
349
  userInputLedger() { return new PgUserInputLedgerStore(this.pool); }
308
- sessionPolicy(logger) { return new PgSessionPolicyStore(this.pool, countClientWriteOn, logger ?? createLogger()); }
309
- fileHistory() { return new PgFileHistoryStore(this.pool, fileHistoryOptions(this.config)); }
350
+ sessionPolicy() { return (this.sessionPolicyInst ??= new PgSessionPolicyStore(this.pool, SQL_SESSION_ROOT_SEAT, policyStoreLoggerOf(this.onWarn))); }
351
+ sessionPolicyInst;
352
+ fileHistory() { return (this.fileHistoryInst ??= new PgFileHistoryStore(this.pool, fileHistoryOptions(this.config, this.sessionBlobNamespace()))); }
353
+ fileHistoryInst;
354
+ landedAttendants() { return (this.landedAttendantsInst ??= sqlLandedAttendantsOf(pgDriver(this.pool), this.fileHistory(), this.sessionPolicy())); }
355
+ landedAttendantsInst;
310
356
  memoryOptOutGrant() { return new PgMemoryOptOutGrantStore(this.pool); }
311
357
  sessionCaptureRecords() { return () => (this.captureRecordsInst ??= new PgSessionCaptureRecordStore(this.pool)); }
312
358
  captureRecordsInst;
313
- legacySnapshotBlobSweep() { return legacySweepImpl(this.config, "pg", this.pool); }
359
+ legacySnapshotBlobSweep() { return legacySweepImpl(this.config, "pg", this.pool, this.sessionBlobNamespace()); }
314
360
  runOneTimeMigrations() { return runSqlOneTimeMigrations("pg", this.pool, buildSqlOneTimeMigrationInput(this.config)); }
315
361
  workflowJournal() { return new PgWorkflowJournalStore(this.pool); }
316
362
  outcomeSink() { return new PgOutcomeLedger(this.pool); }
@@ -318,10 +364,12 @@ class PgBackend {
318
364
  completionInbox(onWarn) { return new PgWorkflowCompletionInbox(this.pool, onWarn); }
319
365
  notifyJournal() { return new PgWorkflowNotifyJournalStore(this.pool); }
320
366
  workflowAgentSessionIndex() { return new PgWorkflowAgentSessionIndex(this.pool); }
321
- workflowParkDecisions() { return (this.parkDecisionsInst ??= new SqlWorkflowParkDecisionStore(this.run())); }
367
+ workflowParkDecisions(records) { return (this.parkDecisionsInst = decisionStoreBoundOnce(this.parkDecisionsInst, records, () => new SqlWorkflowParkDecisionStore(this.run(), sqlRecordFenceOf(records)))); }
322
368
  parkDecisionsInst;
323
369
  sharedMemoryStore(authorizer) { return new PgSharedMemoryStore(this.pool, authorizer); }
324
- checkpoint(logger) { return new PgCheckpointStore(this.pool, logger, { retention: sqlStoreRetention(this.config.retentionSweep) }); }
370
+ cardScopeRootSeat = createCardScopeRootSeat();
371
+ bindCardScopeRoot(read) { this.cardScopeRootSeat.bind(read); }
372
+ checkpoint(logger) { return new PgCheckpointStore(this.pool, logger, { retention: sqlStoreRetention(this.config.retentionSweep), cardScopeRoot: this.cardScopeRootSeat }); }
325
373
  checkpointReadView() { return this.checkpoint(); }
326
374
  toolResult() { return new PgToolResultStore(this.pool, { retention: sqlStoreRetention(this.config.retentionSweep) }); }
327
375
  imageIndex() { return new PgImageIndex(this.pool); }
@@ -340,6 +388,15 @@ class PgBackend {
340
388
  pgPool() { return this.pool; }
341
389
  async dbNowMs() { const res = await this.pool.query("SELECT ROUND(EXTRACT(EPOCH FROM now())*1000) AS ms"); return Number(res.rows[0]?.ms); }
342
390
  }
391
+ sealStoreClass(PgBackend, "pg-backend", {
392
+ ensureSchema: "boot", close: "boot", sessionBlobNamespace: "exit", run: "exit", resumeAnchor: "exit", approvalExemption: "exit", approvalNonce: "exit", orgDeliveryQuota: "exit",
393
+ approvalAsk: "exit", permissionRule: "exit", sendFileLedger: "exit", userInputLedger: "exit", sessionPolicy: "exit", fileHistory: "exit",
394
+ memoryOptOutGrant: "exit", sessionCaptureRecords: "exit", legacySnapshotBlobSweep: "exit", runOneTimeMigrations: "boot", workflowJournal: "exit",
395
+ outcomeSink: "exit", workflowRun: "exit", completionInbox: "exit", notifyJournal: "exit", workflowAgentSessionIndex: "exit", workflowParkDecisions: "exit",
396
+ sharedMemoryStore: "exit", checkpoint: "exit", checkpointReadView: "exit", toolResult: "exit", imageIndex: "exit", imageBake: "exit", leaderRun: "exit",
397
+ device: "exit", retention: "exit", sessionEraser: "exit", retentionLane: "exit", breaker: "exit", costQuota: "exit", rateLimiter: "exit", session: "exit",
398
+ adoptionLog: "exit", mysqlPool: "boot", pgPool: "boot", dbNowMs: "exit", landedAttendants: "exit", bindCardScopeRoot: "exit",
399
+ });
343
400
  export function localSessionRowsOf(backend) {
344
401
  return backend instanceof LocalBackend ? backend.session() : undefined;
345
402
  }
@@ -364,6 +421,7 @@ class LocalBackend {
364
421
  fileBackend;
365
422
  runStore;
366
423
  sessionStore;
424
+ workflowRunsSeat = createLocalWorkflowRunsSeat();
367
425
  resumeAnchorStore;
368
426
  approvalExemptionStore;
369
427
  approvalNonceStore;
@@ -399,11 +457,17 @@ class LocalBackend {
399
457
  stall: createRunStallWiring(config, observers),
400
458
  });
401
459
  const physicalRoot = this.fileBackend.root;
460
+ const checkpoints = this.fileBackend.checkpointStore;
461
+ const listCheckpoints = checkpoints.listBySession;
462
+ const ageOut = listCheckpoints !== undefined
463
+ ? { liveReferences: { checkpoints: { listBySession: (q) => listCheckpoints.call(checkpoints, q) }, agents: this.fileBackend.backgroundAgentStore, workflows: this.workflowRunsSeat } }
464
+ : {};
402
465
  this.sessionStore = new LocalSessionStore(createLocalSessionRepo(physicalRoot), this.runStore, physicalRoot, {
403
466
  log: createLogger(config.logLevel),
404
467
  durability: this.storeDeclaration.durability,
405
468
  placements: SESSION_PLACEMENTS,
406
469
  withdrawCheckpointCtx: (sessionId) => dropLocalCheckpointCtxStrict(physicalRoot, sessionId),
470
+ ...ageOut,
407
471
  });
408
472
  this.parkDecisionLedgerRoot = config.workflowRunStoreBackend === "memory" ? undefined : join(this.fileBackend.root, "workflows");
409
473
  this.resumeAnchorStore = new FileResumeAnchorStore(this.fileBackend.root);
@@ -502,7 +566,12 @@ class LocalBackend {
502
566
  ...importedLayerRoot,
503
567
  };
504
568
  }
569
+ closing = false;
570
+ exclusiveDataRoot() {
571
+ return this.closing ? undefined : this.fileBackend.root;
572
+ }
505
573
  async close() {
574
+ this.closing = true;
506
575
  await this.sessionStore.dispose();
507
576
  this.runStore.dispose();
508
577
  this.resumeAnchorStore.dispose();
@@ -518,8 +587,10 @@ class LocalBackend {
518
587
  await this.fileBackend.dispose();
519
588
  }
520
589
  run() { return this.runStore; }
521
- workflowParkDecisions() {
522
- return (this.parkDecisionsInst ??= new LocalWorkflowParkDecisionStore(this.runStore, this.parkDecisionLedgerRoot));
590
+ workflowParkDecisions(records) {
591
+ if (records instanceof SqlWorkflowRunStore)
592
+ throw new Error("local store backend: the workflow park decision store's record fence must be the in-process record fence (FencedWorkflowRecordStore), not a SQL record store — the local backend keeps its decisions in this process");
593
+ return (this.parkDecisionsInst = decisionStoreBoundOnce(this.parkDecisionsInst, records, () => new LocalWorkflowParkDecisionStore(this.runStore, records, this.parkDecisionLedgerRoot)));
523
594
  }
524
595
  parkDecisionsInst;
525
596
  resumeAnchor() { return this.resumeAnchorStore; }
@@ -544,8 +615,11 @@ class LocalBackend {
544
615
  durability: this.storeDeclaration.durability,
545
616
  getActiveTaskId: (sessionId) => this.runStore.getActiveTaskId(sessionId),
546
617
  readSessionOwner: async (sessionId) => (await this.sessionStore.headOf(sessionId))?.owner,
618
+ cardScopeRoot: this.cardScopeRootSeat,
547
619
  }));
548
620
  }
621
+ cardScopeRootSeat = createCardScopeRootSeat();
622
+ bindCardScopeRoot(read) { this.cardScopeRootSeat.bind(read); }
549
623
  checkpoint() {
550
624
  const cs = this.checkpointStoreOf();
551
625
  if (!this.checkpointProbeWired) {
@@ -565,12 +639,15 @@ class LocalBackend {
565
639
  localStoreDeclaration() { return this.storeDeclaration; }
566
640
  fileUsageWindowStore() { return this.fileBackend.usageWindowStore; }
567
641
  fileHistory() { return this.fileBackend.fileHistoryStore; }
642
+ landedAttendants() { return (this.landedAttendantsInst ??= createLocalLandedAttendantSeat({ sessions: this.sessionStore, history: this.fileBackend.fileHistoryStore, policy: this.fileBackend.sessionPolicyStore, anchors: this.resumeAnchorStore })); }
643
+ landedAttendantsInst;
568
644
  memoryOptOutGrant() { return undefined; }
569
645
  sessionCaptureRecords() { return this.captureRecordsSource; }
570
646
  captureRecordsSource;
571
647
  workflowJournal() { return this.workflowJournalStore; }
572
648
  outcomeSink() { return this.outcomeSinkInst; }
573
649
  session() { return this.sessionStore; }
650
+ bindWorkflowRunReader(reader) { this.workflowRunsSeat.bind(reader); }
574
651
  toolResult() { return this.fileBackend.toolResultStore; }
575
652
  engineFileStores() {
576
653
  const fb = this.fileBackend;
@@ -638,6 +715,9 @@ class RefusedLocalBackend {
638
715
  async close() {
639
716
  await this.release();
640
717
  }
718
+ exclusiveDataRoot() {
719
+ return undefined;
720
+ }
641
721
  run() { return this.refused(); }
642
722
  resumeAnchor() { return this.refused(); }
643
723
  approvalExemption() { return this.refused(); }
@@ -649,6 +729,7 @@ class RefusedLocalBackend {
649
729
  userInputLedger() { return this.refused(); }
650
730
  sessionPolicy() { return this.refused(); }
651
731
  fileHistory() { return this.refused(); }
732
+ landedAttendants() { return this.refused(); }
652
733
  memoryOptOutGrant() { return this.refused(); }
653
734
  sessionCaptureRecords() { return this.refused(); }
654
735
  workflowJournal() { return this.refused(); }
@@ -659,6 +740,8 @@ class RefusedLocalBackend {
659
740
  toolResult() { return this.refused(); }
660
741
  fileUsageWindowStore() { return this.refused(); }
661
742
  localStoreDeclaration() { return this.refused(); }
743
+ bindWorkflowRunReader() { this.refused(); }
744
+ bindCardScopeRoot() { this.refused(); }
662
745
  mysqlPool() { return undefined; }
663
746
  pgPool() { return undefined; }
664
747
  }
@@ -669,12 +752,12 @@ export function createStoreBackend(config, onWarn, onError, observers) {
669
752
  if (!config.pg)
670
753
  return undefined;
671
754
  const pool = createPgPool(pgPoolOptions(config.pg, config.dbQueryTimeoutMs), onWarn);
672
- return withRetiredSchemaProbe(new PgBackend(pool, config, observers), { dialect: "pg", pool }, { lanes: deployedExecutionLanes(config) });
755
+ return withRetiredSchemaProbe(new PgBackend(pool, config, observers, onWarn), { dialect: "pg", pool }, { lanes: deployedExecutionLanes(config) });
673
756
  }
674
757
  if (!config.tidb)
675
758
  return undefined;
676
759
  const pool = createTidbPool(config);
677
- return withRetiredSchemaProbe(new TiDBBackend(pool, config, observers), { dialect: "mysql", pool }, { lanes: deployedExecutionLanes(config) });
760
+ return withRetiredSchemaProbe(new TiDBBackend(pool, config, observers, onWarn), { dialect: "mysql", pool }, { lanes: deployedExecutionLanes(config) });
678
761
  }
679
762
  function openAdmittedLocalBackend(config, admission, sinks) {
680
763
  let admitted = admission;
@@ -729,6 +812,16 @@ export async function openStoreBackendWithFallback(config, logger, observers, lo
729
812
  sqlEngine === undefined
730
813
  ? await attempt()
731
814
  : await openWithinWait(attempt, config.storeLockWaitMs, (w) => logger.warn("store_sql_open_wait", { engine: sqlEngine, endpoint: buildDisplaySafeUrl(sqlStoreCoordinatesAsUrl(config)), waitMs: w.waitMs, error: w.error }));
815
+ const namespace = backend?.sessionBlobNamespace?.();
816
+ if (namespace !== undefined) {
817
+ try {
818
+ await namespace.establish();
819
+ }
820
+ catch (refusal) {
821
+ await backend?.close().catch(() => undefined);
822
+ throw refusal;
823
+ }
824
+ }
732
825
  }
733
826
  catch (err) {
734
827
  void inFlight?.close().catch(() => undefined);
@@ -770,4 +863,75 @@ export function buildSqlStoreOpenRefusal(engine, endpoint, waitedMs, err) {
770
863
  next +
771
864
  `or run explicitly in memory with DB_BACKEND=memory (and remove the ${coords} coordinates).`);
772
865
  }
866
+ sealStoreClass(WindowedSessionStorage, "windowed-session-storage", {
867
+ getMetadata: "exit", getLeafId: "exit", createEntryId: "exit", findEntries: "exit", getLabel: "exit", getPathToRoot: "exit", getEntries: "exit",
868
+ getFloorId: "exit", getReplayLoss: "exit", logMarkNow: "exit", getEntry: "exit", appendEntry: "exit", setLeafId: "exit",
869
+ });
870
+ sealStoreClass(TiDBBackgroundAgentStore, "tidb-background-agent-store", {
871
+ put: "exit", get: "exit", update: "exit", updateIf: "exit", listBySession: "exit", listByScope: "exit", delete: "exit", reap: "exit", listScopes: "exit",
872
+ });
873
+ sealStoreClass(PgBackgroundAgentStore, "pg-background-agent-store", {
874
+ put: "exit", get: "exit", update: "exit", updateIf: "exit", listBySession: "exit", listByScope: "exit", delete: "exit", reap: "exit", listScopes: "exit",
875
+ });
876
+ sealStoreClass(SqlBlobIndex, "sql-blob-index", { put: "exit", get: "exit", has: "exit", sweep: "exit" });
877
+ sealStoreClass(SqlCheckpointStore, "sql-checkpoint-store", {
878
+ put: "exit", get: "exit", listBySession: "exit", resolve: "exit", reopen: "exit", recordExecutionOutcome: "exit", setPendingSteer: "exit", expire: "exit",
879
+ reap: "exit", reapExpired: "exit", listExpiredApprovalGates: "exit", listPending: "exit", listByScope: "exit", listPendingSessionIds: "exit",
880
+ findPendingTokenBySession: "exit", findCheckpointCandidatesForAsk: "exit", findDecidedApprovalsForBinding: "exit", peekScopeByToken: "exit",
881
+ peekPendingScope: "exit", hostSessionOfCard: "exit", putCtx: "exit", getCtx: "exit", rewriteCtxWhileClaimed: "exit", rewriteCtxRows: "exit", reapCtx: "exit",
882
+ deleteBySession: "exit", cardScopeRootOf: "exit",
883
+ });
884
+ sealStoreClass(SqlFileHistoryStore, "sql-file-history-store", {
885
+ trackEdit: "exit", annulTrack: "exit", snapshot: "exit", restore: "exit", canRestore: "exit", reap: "exit", deleteBySession: "exit", sweepOrphanBlobs: "exit",
886
+ adoptScope: "exit", exportHistory: "exit", importHistory: "exit", importFailureOf: "exit", prepareImport: "exit",
887
+ lockScopeOn: "in-store", publishImportOn: "in-store", deleteScopeOn: "in-store",
888
+ });
889
+ sealStoreClass(SqlBlobExchange, "sql-blob-exchange", { put: "exit", get: "exit", has: "exit" });
890
+ sealStoreClass(SqlBlobLanding, "sql-blob-landing", { putAt: "exit", visibleAt: "exit" });
891
+ sealStoreClass(TiDBMailboxStore, "tidb-mailbox-store", {
892
+ append: "exit", claimLease: "exit", ack: "exit", moveDecision: "exit", releaseLease: "exit", peekCount: "exit", drop: "exit", reap: "exit",
893
+ retireRecipient: "exit", listRetiredRecipients: "exit",
894
+ });
895
+ sealStoreClass(PgMailboxStore, "pg-mailbox-store", {
896
+ append: "exit", claimLease: "exit", ack: "exit", moveDecision: "exit", releaseLease: "exit", peekCount: "exit", drop: "exit", reap: "exit",
897
+ retireRecipient: "exit", listRetiredRecipients: "exit",
898
+ });
899
+ sealStoreClass(PgSessionStorage, "pg-session-storage", {
900
+ getMetadata: "exit", getLeafId: "exit", createEntryId: "exit", findEntries: "exit", getLabel: "exit", getPathToRoot: "exit", getEntries: "exit",
901
+ getFloorId: "exit", getReplayLoss: "exit", logMarkNow: "exit", getEntry: "exit", appendEntry: "exit", setLeafId: "exit", getEpochAnchor: "exit",
902
+ });
903
+ sealStoreObject(PgSessionStorage, "pg-session-storage-static", { wake: "exit" });
904
+ sealStoreClass(PgSessionStore, "pg-session-store", {
905
+ acquire: "exit", register: "exit", registerWithReceipt: "exit", deleteSessionIf: "exit", placementOf: "exit", listPlaced: "exit", headOf: "exit",
906
+ touch: "exit", release: "exit", forget: "exit", fork: "exit", forkTo: "exit", exportEntries: "exit", listEntryIds: "exit", exportEntriesStream: "exit",
907
+ importEntries: "exit", replaceEntries: "exit", beginImportStaging: "exit", readStagedEntries: "exit", sweepStagingSessions: "exit", dispose: "exit",
908
+ });
909
+ sealStoreClass(PgStagingHandle, "pg-staging-handle", { appendBatch: "exit", commit: "exit", abort: "exit" });
910
+ sealStoreClass(SqlRetentionStore, "sql-retention-store", {
911
+ listRetentionDomains: "exit", previewRetention: "exit", expireCheckpoints: "exit", deleteExpiredSessions: "exit", eraseSession: "exit",
912
+ deleteOrphanToolResults: "exit",
913
+ });
914
+ sealStoreClass(TiDBRosterStore, "tidb-roster-store", { record: "exit", resolve: "exit", list: "exit", releaseAgent: "exit", reapOlderThan: "exit" });
915
+ sealStoreClass(PgRosterStore, "pg-roster-store", { record: "exit", resolve: "exit", list: "exit", releaseAgent: "exit", reapOlderThan: "exit" });
916
+ sealStoreClass(SqlSessionPolicyStore, "sql-session-policy-store", {
917
+ getRules: "exit", listBySession: "exit", putRules: "exit", deleteBySession: "exit", discloseErased: "exit", isDupKeyError: "exit",
918
+ putRulesOn: "in-store", eraseOn: "in-store",
919
+ });
920
+ sealStoreClass(TiDBSessionStorage, "tidb-session-storage", {
921
+ getMetadata: "exit", getLeafId: "exit", createEntryId: "exit", findEntries: "exit", getLabel: "exit", getPathToRoot: "exit", getEntries: "exit",
922
+ getFloorId: "exit", getReplayLoss: "exit", logMarkNow: "exit", getEntry: "exit", appendEntry: "exit", setLeafId: "exit", getEpochAnchor: "exit",
923
+ });
924
+ sealStoreObject(TiDBSessionStorage, "tidb-session-storage-static", { wake: "exit" });
925
+ sealStoreClass(TiDBSessionStore, "tidb-session-store", {
926
+ acquire: "exit", register: "exit", registerWithReceipt: "exit", deleteSessionIf: "exit", placementOf: "exit", listPlaced: "exit", headOf: "exit",
927
+ touch: "exit", release: "exit", forget: "exit", fork: "exit", forkTo: "exit", exportEntries: "exit", listEntryIds: "exit", exportEntriesStream: "exit",
928
+ importEntries: "exit", replaceEntries: "exit", beginImportStaging: "exit", readStagedEntries: "exit", sweepStagingSessions: "exit", dispose: "exit",
929
+ });
930
+ sealStoreClass(TiDBStagingHandle, "tidb-staging-handle", { appendBatch: "exit", commit: "exit", abort: "exit" });
931
+ sealStoreClass(SqlToolResultStore, "sql-tool-result-store", { put: "exit", ownerOf: "exit", get: "exit", reap: "exit", deleteBySession: "exit" });
932
+ sealStoreClass(TiDBUsageWindowStore, "tidb-usage-window-store", { charge: "exit", read: "exit" });
933
+ sealStoreClass(PgUsageWindowStore, "pg-usage-window-store", { charge: "exit", read: "exit" });
934
+ sealStoreClass(SqlWorkflowJournalStore, "sql-workflow-journal-store", {
935
+ append: "exit", load: "exit", locator: "exit", loadPage: "exit", resumeClaim: "exit", releaseResumeClaim: "exit", reapExpired: "exit",
936
+ });
773
937
  //# sourceMappingURL=store-backend.js.map
@@ -0,0 +1,57 @@
1
+ import type { SqlExec } from "./sql-driver.js";
2
+ /** T 的公开成员里**一切可调用**的键(含可选成员、同步或 Promise 联合返回;`keyof` 天然不含 private / protected;getter 不是可调用成员)。 */
3
+ export type CallableKeysOf<T> = {
4
+ [K in keyof T]-?: NonNullable<T[K]> extends (...a: never[]) => unknown ? K : never;
5
+ }[keyof T];
6
+ /** 出口表的闭集三词(见文件头注)。 */
7
+ export type StoreExitWord = "exit" | "boot" | "in-store";
8
+ /** 成员的首参是不是调用方借来的语句面(`SqlExec` 形:事务连接 / 它的 `query` 面)—— `in-store` 只许给这一形。首参可缺省 / 是别的型 ⇒ 不是。 */
9
+ type LendsStatementFace<F> = F extends (first: infer P, ...rest: never[]) => unknown ? ([P] extends [SqlExec] ? true : false) : false;
10
+ /** 一只店的出口表:每个公开可调用成员的去处(闭集三词,见文件头注;借语句面的成员 `exit | in-store`,其余 `exit | boot`)。 */
11
+ export type StoreExitPlan<T> = Readonly<{
12
+ [K in CallableKeysOf<T>]: LendsStatementFace<NonNullable<T[K]>> extends true ? "exit" | "in-store" : "exit" | "boot";
13
+ }>;
14
+ /**
15
+ * `boot` 一词只许这些名字(闭集):只在起服阶段被调、它们的错进起服拒句(要库的原码 / 原句,`databaseAnswerCodesOf` 一类读者),或交出给起服装配的原始池。
16
+ * · `ensureSchema` / `runOneTimeMigrations`:起服建表与一次性迁移(stage-01..04);
17
+ * · `close`:停机时关池(错进停机日志);
18
+ * · `mysqlPool` / `pgPool`:后端交给起服装配的原始池 —— 装配拿它铸的店各自封口(记忆引擎、会话审计、任务清单车道)。
19
+ */
20
+ export declare const BOOT_METHOD_NAMES: ReadonlySet<string>;
21
+ /** 封过的成员带的标记(值 = 它的 `site`):门读它判「这一只封过」;继承成员靠它断言基类先封。 */
22
+ export declare const SEALED_STORE_MEMBER: unique symbol;
23
+ /** 一次封口的登记(门读):店词、形(类 / 对象)、名字、出口表。对象形按店词只登记第一次(工厂每次调用都铸新对象,登记不随调用次数增长)。 */
24
+ export interface StoreSealRecord {
25
+ readonly store: string;
26
+ readonly kind: "class" | "object";
27
+ readonly name: string;
28
+ readonly plan: Readonly<Record<string | symbol, StoreExitWord>>;
29
+ }
30
+ /** 本进程已登记的封口(门读;不可写)。 */
31
+ export declare function storeSealRecords(): readonly StoreSealRecord[];
32
+ /**
33
+ * 封一只店类:`plan` 里每个 `exit` 成员 —— 本类原型上**自有**的 ⇒ 包一层;继承来的 ⇒ 断言继承到的那一只已封(否则加载即抛:先封基类)。
34
+ * 封口行住在店类的定义旁边;`src/stores-sql/**` 的店类例外 —— 那个目录要能原样搬进 core 包(对本仓其余部分零依赖,`test/dependency-direction-gate.test.ts` R8),
35
+ * 店边界是本服务的事(运维日志座、对外句词表),所以它们的封口住在组合座 `plugins/store-backend.ts`(装配它们的那一处)。
36
+ * 形参读类的 `prototype`(不读构造签名):受保护 / 抽象构造器的店基类同样能封;出口表按原型的实例形 `P` 穷尽。
37
+ * 异步生成器方法照封(调用交回的生成器对象由封口同封,迭代中途的错同样过边界);同步生成器方法拒封(加载即抛:它的错在调用返回之后才发生,封口接不住)。
38
+ */
39
+ export declare function sealStoreClass<P extends object>(ctor: {
40
+ readonly prototype: P;
41
+ readonly name: string;
42
+ }, store: string, plan: StoreExitPlan<P>): void;
43
+ /**
44
+ * 封一只对象(工厂产物 / 读器 / 事务对象 / 店类的静态面):原地包 `plan` 里每个 `exit` 的自有可调用属性,交回**同一引用**。
45
+ * 运行期另断言「对象自有的可调用属性 ⊆ 表的键」(普通对象;工厂的对象先 `satisfies` 接口保住具体类型;多出一个 ⇒ 封口时就抛)。表里的可选成员对象上可以没有。
46
+ * 类的静态面(构造器)同样经这一只封;它的穷尽只靠编译期的表(TS 私有的静态成员运行期看不出私有)。
47
+ */
48
+ export declare function sealStoreObject<T extends object>(obj: T, store: string, plan: StoreExitPlan<T>): T;
49
+ /**
50
+ * 封一只**导出的自由函数**出店口(它自己借连接、拨库,调用方是店外的装配 / 读面 —— 不是哪只已封店方法的体):交回同签名的包过的函数,
51
+ * 同步抛与拒绝都过边界。`site` 是 `<店>.<动词>` 的字面词。
52
+ */
53
+ export declare function sealStoreFunction<A extends unknown[], R>(fn: (...a: A) => R, site: string): (...a: A) => R;
54
+ /** 惰性异步可迭代的封口:迭代中途(取下一项 / 提前结束)的错同样过边界。交回一只新的可迭代(原可迭代只被它读;生成器的 `return` 值原样交回)。 */
55
+ export declare function sealStoreIterable<E>(it: AsyncIterable<E>, site: string): AsyncGenerator<E, unknown, undefined>;
56
+ export {};
57
+ //# sourceMappingURL=store-boundary.d.ts.map