@sema-agent/server 7.133.0 → 7.135.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 (526) hide show
  1. package/MIGRATION.md +221 -0
  2. package/README.md +2 -2
  3. package/README.zh-CN.md +2 -2
  4. package/USAGE.md +222 -36
  5. package/deploy/sema-up/README.md +16 -0
  6. package/deploy/sema-up/chart/Chart.yaml +1 -1
  7. package/deploy/sema-up/chart/templates/NOTES.txt +15 -0
  8. package/deploy/sema-up/chart/templates/_helpers.tpl +129 -0
  9. package/deploy/sema-up/chart/templates/sealed-key.yaml +24 -0
  10. package/deploy/sema-up/chart/templates/server-v4pro.yaml +14 -0
  11. package/deploy/sema-up/chart/templates/server.yaml +14 -0
  12. package/deploy/sema-up/chart/values-full-single.yaml +5 -1
  13. package/deploy/sema-up/chart/values.yaml +34 -0
  14. package/dist/adoption/plan.d.ts +1 -1
  15. package/dist/approval-ask-audit-store.d.ts +25 -25
  16. package/dist/approval-ask-machine.d.ts +2 -2
  17. package/dist/approval-card.d.ts +66 -154
  18. package/dist/approval-card.js +33 -52
  19. package/dist/approval-content-kind.d.ts +26 -6
  20. package/dist/approval-content-kind.js +23 -3
  21. package/dist/approval-deny-reasons.d.ts +1 -1
  22. package/dist/approval-gate-currency.d.ts +91 -0
  23. package/dist/approval-gate-currency.js +120 -0
  24. package/dist/approval-hmac.d.ts +7 -7
  25. package/dist/approval-policy-settlement.d.ts +2 -2
  26. package/dist/approval-reconciler.d.ts +3 -3
  27. package/dist/approval.d.ts +14 -8
  28. package/dist/approval.js +35 -16
  29. package/dist/auth-bridge.d.ts +1 -1
  30. package/dist/auto-mode-face.d.ts +4 -4
  31. package/dist/background-session-reap.d.ts +2 -2
  32. package/dist/bake-runner/main.d.ts +2 -2
  33. package/dist/bake-runner/runner.d.ts +4 -4
  34. package/dist/bench/s1/live-deps.d.ts +1 -1
  35. package/dist/bench/s1/run-firm.d.ts +1 -1
  36. package/dist/boot/coordinators.d.ts +7 -2
  37. package/dist/boot/coordinators.js +8 -5
  38. package/dist/boot/deferred-sandbox-path-env.d.ts +0 -6
  39. package/dist/boot/deferred-sandbox-path-env.js +0 -5
  40. package/dist/boot/engine-lease.d.ts +5 -5
  41. package/dist/boot/execution-env.d.ts +16 -15
  42. package/dist/boot/execution-env.js +19 -21
  43. package/dist/boot/fatal-exit.d.ts +2 -2
  44. package/dist/boot/late-binds.d.ts +1 -1
  45. package/dist/boot/leader.d.ts +2 -0
  46. package/dist/boot/leader.js +2 -1
  47. package/dist/boot/memory-boundary.d.ts +2 -2
  48. package/dist/boot/memory-consolidation.d.ts +15 -15
  49. package/dist/boot/parked-revive-gate.d.ts +3 -3
  50. package/dist/boot/parked-revive-gate.js +3 -2
  51. package/dist/boot/read-deny-anchor-audit.js +2 -2
  52. package/dist/boot/reapers.d.ts +4 -4
  53. package/dist/boot/resolve-spec.d.ts +1 -1
  54. package/dist/boot/resolve-spec.js +28 -24
  55. package/dist/boot/runner-deps.d.ts +29 -16
  56. package/dist/boot/runner-deps.js +12 -2
  57. package/dist/boot/session-faces.d.ts +3 -3
  58. package/dist/boot/session-faces.js +11 -30
  59. package/dist/boot/shutdown.d.ts +5 -5
  60. package/dist/boot/side-query-lane.d.ts +2 -2
  61. package/dist/boot/stage-05-execution-env.js +4 -4
  62. package/dist/boot/stage-06-runners.d.ts +4 -3
  63. package/dist/boot/stage-06-runners.js +15 -4
  64. package/dist/boot/stage-07-capability-layer.d.ts +2 -1
  65. package/dist/boot/stage-08-reapers.d.ts +2 -1
  66. package/dist/boot/stage-09-leader.d.ts +2 -1
  67. package/dist/boot/stage-09-leader.js +2 -2
  68. package/dist/boot/stage-10-http-server.d.ts +2 -1
  69. package/dist/boot/stage-10-http-server.js +2 -1
  70. package/dist/boot/stores.d.ts +8 -0
  71. package/dist/boot/stores.js +10 -13
  72. package/dist/boot/web-admin.d.ts +21 -15
  73. package/dist/boot/web-admin.js +16 -12
  74. package/dist/boot/workflow-orchestration.js +2 -9
  75. package/dist/brain.d.ts +11 -11
  76. package/dist/budget.d.ts +4 -4
  77. package/dist/budget.js +5 -1
  78. package/dist/caller-text-echo.d.ts +2 -0
  79. package/dist/caller-text-echo.js +2 -1
  80. package/dist/canonical-json.d.ts +2 -41
  81. package/dist/canonical-json.js +2 -13
  82. package/dist/capabilities/approvals-push.d.ts +4 -4
  83. package/dist/capabilities/builtin-tools.d.ts +5 -5
  84. package/dist/capabilities/center-plugins.d.ts +5 -5
  85. package/dist/capabilities/center-plugins.js +1 -1
  86. package/dist/capabilities/center-prompts.d.ts +1 -1
  87. package/dist/capabilities/center-wiring.d.ts +1 -1
  88. package/dist/capabilities/composite-members.d.ts +2 -2
  89. package/dist/capabilities/composite-members.js +1 -1
  90. package/dist/capabilities/execution-lane.d.ts +5 -5
  91. package/dist/capabilities/execution-lane.js +2 -2
  92. package/dist/capabilities/hands-lane.d.ts +5 -5
  93. package/dist/capabilities/mcp-probe.d.ts +10 -7
  94. package/dist/capabilities/mcp-probe.js +2 -2
  95. package/dist/capabilities/sandbox-file-send.d.ts +1 -18
  96. package/dist/capabilities/sandbox-file-send.js +0 -7
  97. package/dist/capabilities/scenarios.d.ts +28 -10
  98. package/dist/capabilities/scenarios.js +15 -5
  99. package/dist/capabilities/send-user-file-tool.d.ts +1 -1
  100. package/dist/capabilities/skills.d.ts +31 -12
  101. package/dist/capabilities/skills.js +23 -17
  102. package/dist/capabilities/tool-defer.d.ts +1 -1
  103. package/dist/capability-facts.d.ts +27 -24
  104. package/dist/capability-facts.js +18 -20
  105. package/dist/center-config-tier.d.ts +1 -1
  106. package/dist/center-credential.d.ts +4 -4
  107. package/dist/checkpoint-ctx-seal-m28.d.ts +42 -0
  108. package/dist/checkpoint-ctx-seal-m28.js +19 -0
  109. package/dist/checkpoint-identity.d.ts +5 -0
  110. package/dist/checkpoint-identity.js +14 -0
  111. package/dist/config-catalog.d.ts +12 -12
  112. package/dist/config-invariants.d.ts +4 -4
  113. package/dist/config-invariants.js +3 -2
  114. package/dist/config-lkg.d.ts +1 -1
  115. package/dist/config-provider.d.ts +13 -13
  116. package/dist/config-provider.js +2 -1
  117. package/dist/config-types.d.ts +83 -83
  118. package/dist/config.d.ts +26 -24
  119. package/dist/config.js +12 -10
  120. package/dist/cross-session-settings.d.ts +1 -1
  121. package/dist/delegated-session-owner.d.ts +16 -13
  122. package/dist/delegated-session-owner.js +9 -10
  123. package/dist/deployment-governance.d.ts +16 -16
  124. package/dist/deployment-shape.d.ts +127 -0
  125. package/dist/deployment-shape.js +72 -0
  126. package/dist/device-store.d.ts +1 -1
  127. package/dist/device-ws-hub.d.ts +1 -1
  128. package/dist/egress-redirect.d.ts +1 -1
  129. package/dist/entry-mode-clamp-notice.d.ts +2 -2
  130. package/dist/env-facts.d.ts +10 -9
  131. package/dist/env-facts.js +1 -1
  132. package/dist/env-name-allowlist-knobs.d.ts +5 -5
  133. package/dist/exec-bounds.d.ts +2 -2
  134. package/dist/execution-lane-caps.d.ts +31 -43
  135. package/dist/execution-lane-caps.js +0 -13
  136. package/dist/field-conflict.d.ts +2 -1
  137. package/dist/field-conflict.js +1 -0
  138. package/dist/file-history-capture.d.ts +9 -9
  139. package/dist/file-history-disclosure.d.ts +50 -9
  140. package/dist/file-history-disclosure.js +8 -13
  141. package/dist/fleet/drain-entry.d.ts +2 -2
  142. package/dist/fleet/fleet-bus.d.ts +26 -14
  143. package/dist/fleet/fleet-bus.js +6 -5
  144. package/dist/fleet/fleet-reconciler.d.ts +9 -9
  145. package/dist/fleet/subagent-tail-bus.d.ts +4 -4
  146. package/dist/fleet-client.d.ts +13 -13
  147. package/dist/fleet-lease.d.ts +16 -16
  148. package/dist/governance-http-status.d.ts +2 -2
  149. package/dist/hooks/hook-llm.d.ts +7 -7
  150. package/dist/hooks/hook-runner.d.ts +57 -30
  151. package/dist/hooks/hook-runner.js +38 -20
  152. package/dist/host-decision.d.ts +5 -5
  153. package/dist/host-lsp-manager.d.ts +5 -5
  154. package/dist/hosted-posture.d.ts +23 -13
  155. package/dist/hosted-posture.js +4 -9
  156. package/dist/http/admission.d.ts +2 -2
  157. package/dist/http/admission.js +28 -5
  158. package/dist/http/approval-sweeps.d.ts +1 -1
  159. package/dist/http/approval-sweeps.js +5 -2
  160. package/dist/http/checkpoint-ctx.d.ts +183 -2
  161. package/dist/http/checkpoint-ctx.js +197 -2
  162. package/dist/http/dispatch.d.ts +3 -3
  163. package/dist/http/dispatch.js +3 -3
  164. package/dist/http/durable-run-leg.js +7 -5
  165. package/dist/http/idempotency.d.ts +4 -4
  166. package/dist/http/idempotency.js +2 -2
  167. package/dist/http/mcp-dial-deadline.d.ts +7 -5
  168. package/dist/http/memory-compliance-failure-reply.d.ts +4 -4
  169. package/dist/http/owner-access.d.ts +4 -6
  170. package/dist/http/owner-access.js +1 -1
  171. package/dist/http/principal-gate.d.ts +39 -13
  172. package/dist/http/principal-gate.js +30 -6
  173. package/dist/http/readiness.d.ts +1 -1
  174. package/dist/http/refusal-body.d.ts +12 -0
  175. package/dist/http/refusal-body.js +11 -0
  176. package/dist/http/request-guards.d.ts +4 -13
  177. package/dist/http/request-guards.js +4 -17
  178. package/dist/http/resume-ctx-read.d.ts +53 -6
  179. package/dist/http/resume-ctx-read.js +26 -3
  180. package/dist/http/resume-legs.d.ts +5 -4
  181. package/dist/http/resume-legs.js +47 -29
  182. package/dist/http/route-ctx.d.ts +29 -38
  183. package/dist/http/route-table.d.ts +9 -9
  184. package/dist/http/routes/agents-roster.d.ts +1 -1
  185. package/dist/http/routes/agents-roster.js +2 -3
  186. package/dist/http/routes/approvals-assistant.d.ts +5 -5
  187. package/dist/http/routes/approvals-assistant.js +91 -17
  188. package/dist/http/routes/background.d.ts +3 -3
  189. package/dist/http/routes/background.js +2 -2
  190. package/dist/http/routes/capabilities.d.ts +1 -1
  191. package/dist/http/routes/capabilities.js +16 -8
  192. package/dist/http/routes/config-catalog.d.ts +1 -1
  193. package/dist/http/routes/devices.d.ts +1 -1
  194. package/dist/http/routes/diagnostics.d.ts +6 -6
  195. package/dist/http/routes/diagnostics.js +1 -1
  196. package/dist/http/routes/fleet.d.ts +1 -1
  197. package/dist/http/routes/fleet.js +5 -4
  198. package/dist/http/routes/mcp-reconnect.d.ts +4 -4
  199. package/dist/http/routes/mcp-reconnect.js +3 -3
  200. package/dist/http/routes/memory-consolidation.d.ts +1 -1
  201. package/dist/http/routes/memory-origin.d.ts +1 -1
  202. package/dist/http/routes/notify-wake.d.ts +1 -1
  203. package/dist/http/routes/notify-wake.js +2 -2
  204. package/dist/http/routes/rules.d.ts +1 -1
  205. package/dist/http/routes/rules.js +4 -4
  206. package/dist/http/routes/runs.js +44 -11
  207. package/dist/http/routes/session-sync.d.ts +3 -2
  208. package/dist/http/routes/session-sync.js +109 -62
  209. package/dist/http/routes/sessions-list.d.ts +1 -1
  210. package/dist/http/routes/sessions-list.js +4 -5
  211. package/dist/http/routes/sessions.js +34 -48
  212. package/dist/http/routes/tasks.d.ts +1 -1
  213. package/dist/http/routes/tasks.js +21 -16
  214. package/dist/http/routes/trace-usage.d.ts +1 -1
  215. package/dist/http/routes/trace-usage.js +7 -9
  216. package/dist/http/routes/workflows.d.ts +3 -0
  217. package/dist/http/routes/workflows.js +31 -28
  218. package/dist/http/send.d.ts +5 -5
  219. package/dist/http/server.d.ts +39 -33
  220. package/dist/http/server.js +5 -2
  221. package/dist/http/session-inherit-env.d.ts +3 -3
  222. package/dist/http/sse-lifecycle.d.ts +1 -1
  223. package/dist/http/sse-log.d.ts +2 -2
  224. package/dist/http/submit-ctx.d.ts +4 -3
  225. package/dist/http/submit-ctx.js +19 -3
  226. package/dist/http/sync-submit-body.d.ts +1 -1
  227. package/dist/http/verify-rounds.d.ts +1 -1
  228. package/dist/http/wire-types.d.ts +35 -24
  229. package/dist/index.d.ts +2 -0
  230. package/dist/index.js +1 -0
  231. package/dist/instruction-source-notice.d.ts +2 -2
  232. package/dist/key-resolver.d.ts +3 -3
  233. package/dist/lane-home-probe.d.ts +1 -1
  234. package/dist/leader/diffout.d.ts +1 -1
  235. package/dist/leader/diffup.d.ts +2 -2
  236. package/dist/leader/endpoint.d.ts +1 -1
  237. package/dist/leader/fanout.d.ts +1 -1
  238. package/dist/leader/leader.d.ts +4 -4
  239. package/dist/leader/merge.d.ts +3 -3
  240. package/dist/leader/repair-wire.d.ts +1 -1
  241. package/dist/leader/wire.d.ts +9 -5
  242. package/dist/leader/wire.js +8 -7
  243. package/dist/list-entry-display.d.ts +1 -1
  244. package/dist/lsp-evict.d.ts +1 -1
  245. package/dist/main.js +1 -1
  246. package/dist/mcp-assertion-header.d.ts +1 -1
  247. package/dist/memory-layer-legacy-lock.d.ts +1 -1
  248. package/dist/memory-operator-faces.d.ts +1 -1
  249. package/dist/memory-origin-fence.js +2 -2
  250. package/dist/memory-posture.js +4 -2
  251. package/dist/memory-project-layer.d.ts +1 -1
  252. package/dist/memory-scope.d.ts +19 -19
  253. package/dist/memory-store-refusal.d.ts +4 -4
  254. package/dist/model-compat.d.ts +1 -1
  255. package/dist/model-entry-headers.d.ts +2 -2
  256. package/dist/model-entry-refusal.d.ts +17 -17
  257. package/dist/model-provider.d.ts +10 -10
  258. package/dist/model-reach-scope.d.ts +1 -1
  259. package/dist/model-route-endpoint.d.ts +6 -6
  260. package/dist/model-route-url.d.ts +5 -5
  261. package/dist/model-select.d.ts +15 -6
  262. package/dist/model-select.js +5 -0
  263. package/dist/model-unreachable-notice.d.ts +3 -3
  264. package/dist/namespaced-rule-name.d.ts +15 -5
  265. package/dist/namespaced-rule-name.js +3 -2
  266. package/dist/observability/corrupt-read-seat.d.ts +9 -9
  267. package/dist/observability/cost-taxonomy.d.ts +1 -1
  268. package/dist/observability/err-text.d.ts +1 -1
  269. package/dist/observability/fail-open.d.ts +12 -8
  270. package/dist/observability/fail-open.js +12 -8
  271. package/dist/observability/metrics.d.ts +3 -3
  272. package/dist/observability/prompt-manifest.d.ts +19 -8
  273. package/dist/observability/prompt-manifest.js +9 -8
  274. package/dist/observability/run-terminal.d.ts +36 -36
  275. package/dist/observability/secret-env-scrub.d.ts +3 -3
  276. package/dist/observability/tool-trace.d.ts +1 -1
  277. package/dist/observability/tool-trace.js +8 -9
  278. package/dist/operator-ask.d.ts +4 -4
  279. package/dist/orchestration/workflow-agent-session-index.d.ts +3 -3
  280. package/dist/orchestration/workflow-completion-inbox.d.ts +20 -5
  281. package/dist/orchestration/workflow-completion-inbox.js +29 -7
  282. package/dist/orchestration/workflow-notify-journal.d.ts +43 -19
  283. package/dist/orchestration/workflow-notify-journal.js +17 -0
  284. package/dist/orchestration/workflow-park-decision.d.ts +1 -1
  285. package/dist/orchestration/workflow-park-decision.js +1 -0
  286. package/dist/outbound-dispatcher.d.ts +4 -4
  287. package/dist/parent-watch.d.ts +4 -4
  288. package/dist/parked-decide.d.ts +20 -20
  289. package/dist/parked-decide.js +8 -5
  290. package/dist/parked-revive-surface.d.ts +7 -7
  291. package/dist/parked-revive-surface.js +2 -3
  292. package/dist/peer-directory.d.ts +3 -3
  293. package/dist/peer-directory.js +1 -1
  294. package/dist/permission-rule-list.d.ts +10 -1
  295. package/dist/permission-rule-list.js +7 -5
  296. package/dist/permission-rule-vocab.d.ts +3 -25
  297. package/dist/permission-rule-vocab.js +0 -13
  298. package/dist/plugins/adoption-log-sql.d.ts +1 -1
  299. package/dist/plugins/approval-ask-store-file.d.ts +8 -1
  300. package/dist/plugins/approval-ask-store-file.js +6 -3
  301. package/dist/plugins/approval-ask-store-memory.d.ts +11 -7
  302. package/dist/plugins/approval-ask-store-memory.js +11 -7
  303. package/dist/plugins/approval-ask-store-sql.d.ts +34 -15
  304. package/dist/plugins/approval-ask-store-sql.js +18 -5
  305. package/dist/plugins/approval-exemption-store.d.ts +3 -3
  306. package/dist/plugins/approval-nonce-store.d.ts +3 -3
  307. package/dist/plugins/approval-payload-fingerprint.d.ts +14 -6
  308. package/dist/plugins/approval-payload-fingerprint.js +1 -1
  309. package/dist/plugins/background-agent-store-sql.d.ts +1 -1
  310. package/dist/plugins/background-shell-support.d.ts +2 -2
  311. package/dist/plugins/blob-backend.d.ts +1 -1
  312. package/dist/plugins/caching-session-store.d.ts +24 -33
  313. package/dist/plugins/caching-session-store.js +8 -19
  314. package/dist/plugins/checkpoint-index-columns.d.ts +81 -0
  315. package/dist/plugins/checkpoint-index-columns.js +62 -0
  316. package/dist/plugins/checkpoint-store-sql.d.ts +66 -67
  317. package/dist/plugins/checkpoint-store-sql.js +100 -103
  318. package/dist/plugins/device-store-sql.d.ts +7 -6
  319. package/dist/plugins/e2b-orphan-reclaim.d.ts +1 -1
  320. package/dist/plugins/ensure-schema-lock-policy.d.ts +1 -1
  321. package/dist/plugins/file-history-store-sql.d.ts +9 -7
  322. package/dist/plugins/file-history-store-sql.js +27 -15
  323. package/dist/plugins/file-run-store.d.ts +8 -8
  324. package/dist/plugins/fork-routing-session-store.d.ts +2 -2
  325. package/dist/plugins/fork-routing-session-store.js +1 -1
  326. package/dist/plugins/host-platform.d.ts +10 -10
  327. package/dist/plugins/image-bake-store-sql.d.ts +1 -1
  328. package/dist/plugins/image-index-sql.d.ts +1 -1
  329. package/dist/plugins/leader-run-store-sql.d.ts +1 -1
  330. package/dist/plugins/local-checkpoint-store.d.ts +23 -12
  331. package/dist/plugins/local-checkpoint-store.js +29 -4
  332. package/dist/plugins/local-session-store.d.ts +44 -45
  333. package/dist/plugins/local-session-store.js +42 -52
  334. package/dist/plugins/local-session-window.d.ts +12 -6
  335. package/dist/plugins/local-session-window.js +1 -17
  336. package/dist/plugins/mailbox-store-sql.d.ts +2 -2
  337. package/dist/plugins/memory-engine-pg.d.ts +1 -1
  338. package/dist/plugins/memory-run-store.d.ts +4 -4
  339. package/dist/plugins/memory-sync-store-pg.d.ts +3 -3
  340. package/dist/plugins/one-time-migrations.d.ts +76 -39
  341. package/dist/plugins/one-time-migrations.js +127 -34
  342. package/dist/plugins/outcome-ledger-sql.d.ts +1 -1
  343. package/dist/plugins/park-commit-watch.d.ts +3 -3
  344. package/dist/plugins/permission-rule-store-file.d.ts +5 -5
  345. package/dist/plugins/permission-rule-store-file.js +16 -19
  346. package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
  347. package/dist/plugins/permission-rule-store-sql.js +74 -31
  348. package/dist/plugins/pg-cost-quota.d.ts +1 -1
  349. package/dist/plugins/pg-pool.d.ts +2 -2
  350. package/dist/plugins/pg-pool.js +5 -2
  351. package/dist/plugins/pg-rate-limiter.d.ts +1 -1
  352. package/dist/plugins/pg-session-storage.d.ts +9 -21
  353. package/dist/plugins/pg-session-storage.js +51 -42
  354. package/dist/plugins/remote-env-adb.d.ts +10 -10
  355. package/dist/plugins/remote-env-device.d.ts +22 -14
  356. package/dist/plugins/remote-env-device.js +28 -16
  357. package/dist/plugins/remote-env-e2b.d.ts +3 -3
  358. package/dist/plugins/remote-env-host.d.ts +16 -16
  359. package/dist/plugins/remote-env-k8s.d.ts +8 -8
  360. package/dist/plugins/remote-env-local-docker.d.ts +2 -2
  361. package/dist/plugins/remote-env-ssh.d.ts +4 -4
  362. package/dist/plugins/remote-scratchpad.d.ts +2 -3
  363. package/dist/plugins/remote-scratchpad.js +0 -4
  364. package/dist/plugins/remote-shell.d.ts +6 -6
  365. package/dist/plugins/retention-lane-store-sql.d.ts +4 -4
  366. package/dist/plugins/retention-store-sql.d.ts +4 -4
  367. package/dist/plugins/roster-store-sql.d.ts +1 -1
  368. package/dist/plugins/run-store-sql.d.ts +8 -8
  369. package/dist/plugins/schema-consistency.d.ts +2 -2
  370. package/dist/plugins/schema-ensure-legs.d.ts +3 -3
  371. package/dist/plugins/schema-indexes.d.ts +1 -1
  372. package/dist/plugins/schema-live-columns.d.ts +1 -1
  373. package/dist/plugins/session-event-payload.d.ts +4 -4
  374. package/dist/plugins/session-fork.d.ts +34 -0
  375. package/dist/plugins/session-fork.js +29 -0
  376. package/dist/plugins/session-ownership.d.ts +11 -0
  377. package/dist/plugins/session-ownership.js +11 -0
  378. package/dist/plugins/session-placement.d.ts +12 -14
  379. package/dist/plugins/session-placement.js +2 -15
  380. package/dist/plugins/session-policy-store-sql.d.ts +12 -12
  381. package/dist/plugins/session-store.d.ts +2 -2
  382. package/dist/plugins/session-store.js +2 -2
  383. package/dist/plugins/shared-memory-store-sql.d.ts +2 -2
  384. package/dist/plugins/sql-driver.d.ts +8 -8
  385. package/dist/plugins/sql-errors.d.ts +1 -1
  386. package/dist/plugins/sql-json-column.d.ts +21 -21
  387. package/dist/plugins/sql-row-helpers.d.ts +2 -2
  388. package/dist/plugins/store-backend.d.ts +17 -16
  389. package/dist/plugins/store-backend.js +3 -3
  390. package/dist/plugins/store-contracts.d.ts +21 -21
  391. package/dist/plugins/task-attachment-store.d.ts +2 -2
  392. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  393. package/dist/plugins/tidb-pool.d.ts +2 -2
  394. package/dist/plugins/tidb-pool.js +9 -2
  395. package/dist/plugins/tidb-session-store.d.ts +17 -27
  396. package/dist/plugins/tidb-session-store.js +52 -42
  397. package/dist/plugins/tool-result-store-sql.d.ts +1 -1
  398. package/dist/plugins/usage-window-store-sql.d.ts +3 -3
  399. package/dist/plugins/user-input-ledger-file.d.ts +1 -1
  400. package/dist/plugins/user-input-ledger-sql.d.ts +3 -3
  401. package/dist/plugins/web-search.d.ts +19 -5
  402. package/dist/plugins/web-search.js +19 -4
  403. package/dist/{orchestration/workflow-journal-entry.d.ts → plugins/workflow-journal-payload.d.ts} +23 -32
  404. package/dist/plugins/workflow-journal-payload.js +32 -0
  405. package/dist/plugins/workflow-journal-store-sql.d.ts +28 -14
  406. package/dist/plugins/workflow-journal-store-sql.js +34 -15
  407. package/dist/plugins/workflow-run-store-sql.d.ts +4 -4
  408. package/dist/posture-source.d.ts +11 -11
  409. package/dist/principal-jwt.d.ts +6 -6
  410. package/dist/project-identity.d.ts +3 -3
  411. package/dist/project-memory.d.ts +4 -4
  412. package/dist/read-face-posture.d.ts +7 -7
  413. package/dist/request-key-closure.d.ts +1 -1
  414. package/dist/request-key-closure.js +1 -1
  415. package/dist/request-tool-axes.d.ts +12 -0
  416. package/dist/request-tool-axes.js +20 -0
  417. package/dist/request-value-closure.d.ts +15 -8
  418. package/dist/request-value-closure.js +2 -0
  419. package/dist/router/route-orchestration.d.ts +11 -16
  420. package/dist/router/route-orchestration.js +2 -12
  421. package/dist/rule-entry-list.d.ts +8 -7
  422. package/dist/rule-entry-list.js +2 -9
  423. package/dist/rules-consent.d.ts +6 -6
  424. package/dist/rules-consent.js +2 -0
  425. package/dist/run-cancel-context.d.ts +5 -5
  426. package/dist/run-local.d.ts +10 -10
  427. package/dist/run-local.js +1 -0
  428. package/dist/runs.d.ts +15 -12
  429. package/dist/runs.js +19 -4
  430. package/dist/runtime-caps-resolver.d.ts +6 -6
  431. package/dist/runtime-governance.d.ts +9 -9
  432. package/dist/sandbox-pkg-source.d.ts +9 -31
  433. package/dist/sandbox-pkg-source.js +14 -8
  434. package/dist/sealed-key.d.ts +34 -2
  435. package/dist/sealed-key.js +55 -1
  436. package/dist/security.d.ts +31 -32
  437. package/dist/security.js +12 -9
  438. package/dist/server-secret-env.d.ts +10 -10
  439. package/dist/session-children-retire.d.ts +1 -1
  440. package/dist/session-error-wire.d.ts +19 -12
  441. package/dist/session-error-wire.js +4 -1
  442. package/dist/session-incarnation.d.ts +52 -35
  443. package/dist/session-incarnation.js +23 -8
  444. package/dist/session-policy-wire.d.ts +27 -5
  445. package/dist/session-policy-wire.js +15 -1
  446. package/dist/session-records-skipped-notice.d.ts +1 -1
  447. package/dist/session-sync-kernel.d.ts +38 -11
  448. package/dist/session-sync-kernel.js +10 -0
  449. package/dist/session-sync.d.ts +49 -6
  450. package/dist/session-sync.js +52 -10
  451. package/dist/session-titler.d.ts +7 -6
  452. package/dist/session-titler.js +8 -13
  453. package/dist/session-watch.d.ts +3 -3
  454. package/dist/session-watch.js +4 -4
  455. package/dist/sighup-idle.d.ts +2 -2
  456. package/dist/spec-fields.d.ts +4 -4
  457. package/dist/sql-engine-posture.d.ts +3 -3
  458. package/dist/store-posture.d.ts +2 -2
  459. package/dist/stored-request-tool-axes-m19.d.ts +1 -1
  460. package/dist/task-a2a.d.ts +3 -1
  461. package/dist/task-a2a.js +38 -5
  462. package/dist/task-cwd.d.ts +7 -88
  463. package/dist/task-cwd.js +2 -15
  464. package/dist/task-mcp.d.ts +14 -10
  465. package/dist/task-mcp.js +39 -12
  466. package/dist/task-settings.d.ts +34 -18
  467. package/dist/task-settings.js +34 -4
  468. package/dist/task-workflow.d.ts +0 -24
  469. package/dist/task-workflow.js +2 -1
  470. package/dist/terminal.d.ts +5 -5
  471. package/dist/tighten-only-seats.d.ts +7 -6
  472. package/dist/tighten-only-seats.js +1 -1
  473. package/dist/tool-approval.d.ts +273 -228
  474. package/dist/tool-approval.js +125 -47
  475. package/dist/tool-rule-names.d.ts +7 -1
  476. package/dist/trace/core-keyset-guard.d.ts +15 -9
  477. package/dist/trace/engine-notice-wire.d.ts +5 -5
  478. package/dist/trace/engine-notice-wire.js +1 -0
  479. package/dist/trace/exit-seat.d.ts +40 -1
  480. package/dist/trace/exit-seat.js +46 -14
  481. package/dist/trace/ledger-events.d.ts +6 -4
  482. package/dist/trace/ledger-sink.d.ts +1 -1
  483. package/dist/trace/model-segment.d.ts +3 -3
  484. package/dist/trace/project.d.ts +65 -46
  485. package/dist/trace/project.js +49 -5
  486. package/dist/trace/redact.d.ts +44 -27
  487. package/dist/trace/redact.js +343 -73
  488. package/dist/trace/self-minted-wire.d.ts +39 -14
  489. package/dist/trace/self-minted-wire.js +9 -0
  490. package/dist/trace/sema-provenance.d.ts +1 -1
  491. package/dist/trace/task-notification-facets.d.ts +4 -4
  492. package/dist/trace/wire-projection-faces.d.ts +9 -3
  493. package/dist/trace/wire-projection-faces.js +7 -1
  494. package/dist/unattended-permission-mode.d.ts +5 -5
  495. package/dist/url-credential.d.ts +52 -0
  496. package/dist/url-credential.js +49 -0
  497. package/dist/url-refusal.d.ts +6 -2
  498. package/dist/url-refusal.js +8 -1
  499. package/dist/usage-analytics.d.ts +2 -2
  500. package/dist/user-input-ledger.d.ts +23 -23
  501. package/dist/web-admin-client/apply-effective.d.ts +5 -5
  502. package/dist/web-admin-client/apply-effective.js +2 -1
  503. package/dist/web-admin-client/apply-ledger.d.ts +2 -2
  504. package/dist/web-admin-client/center-request.d.ts +2 -2
  505. package/dist/web-admin-client/facade.d.ts +5 -5
  506. package/dist/web-admin-client/facade.js +1 -1
  507. package/dist/web-admin-client/hot-keys-registry.d.ts +2 -2
  508. package/dist/web-admin-client/http-client.d.ts +4 -4
  509. package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
  510. package/dist/web-admin-client/pull-state.d.ts +1 -1
  511. package/dist/web-admin-client/read-face.d.ts +2 -2
  512. package/dist/web-admin-client/read-warnings.d.ts +5 -5
  513. package/dist/web-admin-client/restart-signal.d.ts +6 -6
  514. package/dist/web-admin-client/skills-mcp.d.ts +29 -4
  515. package/dist/web-admin-client/skills-mcp.js +31 -4
  516. package/dist/web-admin-client/types.d.ts +17 -10
  517. package/dist/workspace-space.d.ts +5 -3
  518. package/dist/write-protection.d.ts +2 -2
  519. package/package.json +4 -3
  520. package/scripts/drain-check-local.mjs +35 -2
  521. package/scripts/drain-check.mysql.sql +22 -2
  522. package/scripts/drain-check.pg.sql +22 -2
  523. package/skills/loop.md +1 -1
  524. package/dist/mcp-tool-faces.d.ts +0 -69
  525. package/dist/mcp-tool-faces.js +0 -104
  526. package/dist/orchestration/workflow-journal-entry.js +0 -27
@@ -26,14 +26,14 @@
26
26
  * exec; this seam stays on the plain (sql, params) form.
27
27
  *
28
28
  * ─────────────────────────────────────────────────────────────────────────────────────────────────
29
- * @contract txn.read-semantics — 本仓「事务里的读看到什么」的**唯一**成文处(S-131 / B-020 / B-022)
29
+ * @contract txn.read-semantics — 本仓「事务里的读看到什么」的**唯一**成文处([ref] / [ref] / [ref])
30
30
  * ─────────────────────────────────────────────────────────────────────────────────────────────────
31
31
  * 五只店的头注此前各写一套「为什么用这个事务动词」的理由(截断的、漏数的、讲历史沿革的都有)。
32
32
  * 判据从今天起只有这一处,店里只留一行 `{@link SqlTxConn.begin}` 指回来。
33
33
  *
34
34
  * **① 事务动词只有一个** —— `begin()`。曾经那个「悲观」专用动词(MySQL 腿发 TiDB 专有的
35
35
  * `BEGIN PESSIMISTIC`)已删除:那条语句在真 MySQL / MariaDB 上是 `ER_PARSE_ERROR`,四店 18 个事务
36
- * 一个都开不了(**B-020**),而它真正保证的东西现在由 ② 结构性地给出。同理,那个「可重复读」专用
36
+ * 一个都开不了(**[ref]**),而它真正保证的东西现在由 ② 结构性地给出。同理,那个「可重复读」专用
37
37
  * 动词也一并并入:隔离级不再由动词决定。
38
38
  *
39
39
  * **② 隔离级与事务模式是「连接的事实」,不是「动词的参数」** —— 见 {@link SqlDriver.facts}。
@@ -54,12 +54,12 @@
54
54
  * 的行**、读**值/时钟表达式**(不触任何存量行)、以及 PG 语法明禁加锁的形(**只有**聚合 / GROUP BY /
55
55
  * DISTINCT / 窗口 / 集合运算;`ORDER BY … LIMIT 1` 尾行读在 PG 上**合法**加锁,不属此类——7.60.0 重扫纠)。
56
56
  * 理由:TiDB 悲观事务的普通 SELECT 仍钉 `start_ts`,`lockScope` 的锁等待窗内别副本的提交看不见
57
- * (**B-022**);InnoDB REPEATABLE READ 下则由本事务的第一条一致性读建 read view —— 两条都是
57
+ * (**[ref]**);InnoDB REPEATABLE READ 下则由本事务的第一条一致性读建 read view —— 两条都是
58
58
  * **版本相关的副作用**,不是保证。机器门:`test/sql-txn-semantics-gate.test.ts`(G-B,例外闭集
59
59
  * `INTRA_TXN_PLAIN_READS` 每条带理由);真值神谕:`test/sql-txn-semantics-integration.test.ts`(三引擎)。
60
60
  *
61
61
  * **④ 引擎事实不进店** —— `SqlDriver.facts` 是**运维读面**(`GET /v1/diagnostics/wiring` 的 `sqlEngine`
62
- * 段与 `GET /v1/capabilities` 的 `store.sql` 位(7.106.0 起;此前顶层 `sql`,S-866 ①))的料。店里不许出现 `if (engine === …)`:引擎判别在全仓
62
+ * 段与 `GET /v1/capabilities` 的 `store.sql` 位(7.106.0 起;此前顶层 `sql`,[ref] ①))的料。店里不许出现 `if (engine === …)`:引擎判别在全仓
63
63
  * 只有连接初始化这一处,机器门 G-A 守着。`SqlDialect`(SQL **文本**方言,两值)与 `engine`(运行期
64
64
  * 引擎事实,三值)是两条轴,刻意不合成一个三值。
65
65
  *
@@ -125,7 +125,7 @@ export interface SqlExec {
125
125
  /** A pooled connection with transaction control (released by the caller in a `finally`). */
126
126
  export interface SqlTxConn extends SqlExec {
127
127
  /**
128
- * The ONE transaction verb (S-131). What its reads see is NOT decided here — it is decided once per
128
+ * The ONE transaction verb ([ref]). What its reads see is NOT decided here — it is decided once per
129
129
  * pooled connection at initialization and reported by {@link SqlDriver.facts}. Read the
130
130
  * `@contract txn.read-semantics` block at the top of this file before adding a transaction: the
131
131
  * short version is **intra-transaction collection reads are LOCKING reads**, and a plain `SELECT`
@@ -145,7 +145,7 @@ export interface SqlTxConn extends SqlExec {
145
145
  */
146
146
  export type SqlEngine = "tidb" | "innodb" | "pg";
147
147
  /**
148
- * What connection initialization ESTABLISHED and then READ BACK on this driver's pool (S-131 §1
148
+ * What connection initialization ESTABLISHED and then READ BACK on this driver's pool ([ref] §1
149
149
  * 补偿面). Operator read faces: `GET /v1/diagnostics/wiring` → `sqlEngine`, `GET /v1/capabilities`
150
150
  * → `sql`. Store code must never read this (machine gate G-A) — engine discrimination exists in
151
151
  * exactly one place in this repo, and it is `connect()`.
@@ -322,7 +322,7 @@ export declare const SQL_FACTS_ABSENT_WALLS: SqlWallsReading;
322
322
  export declare function sqlWallsOf(engine: SqlEngineReading | undefined): SqlWallsReading;
323
323
  /**
324
324
  * **数据库自己的钟**(毫秒),两方言各一句 —— 本仓这口钟在 SQL 面的**唯一**铸点([ref] A7 / [ref] /
325
- * 合并复审 R2 把 S-280 的 nonce 店并进来)。
325
+ * 合并复审 R2 把 [ref] 的 nonce 店并进来)。
326
326
  *
327
327
  * 用处永远是同一条:**一个时刻量的铸造点与它的判定点必须在同一个钟域**。副本各拿各的墙钟时,两台机器
328
328
  * 之间的偏差没有任何一条腿强制过上界(本仓 [ref]③ 记过一次真实的 11 分钟 NTP 纠正),于是
@@ -359,7 +359,7 @@ export interface SqlDriver extends SqlExec {
359
359
  * · `null`(还没借出过连接)—— 没有可报的东西,**不猜**;
360
360
  * · 事实 —— 最近一次初始化**回读复核**过的值。每条池连接首次借出都重跑一次初始化(记忆化按连接身份),
361
361
  * 所以池在致命错误后重连时,保证是在新连接上**重新建立**的,不是继承来的;
362
- * · `null`(借出过、但最近一次初始化被**拒**)—— S-137 ④:保证此刻建立不起来,读面就报缺席。
362
+ * · `null`(借出过、但最近一次初始化被**拒**)—— [ref] ④:保证此刻建立不起来,读面就报缺席。
363
363
  * 此前这里是「一次成功即长期有效」的快照:连接被驱逐、新连接初始化被拒之后,诊断面仍在陈述一条
364
364
  * 已经不成立的结构保证。降级由 `establishSession()` 一处完成,并留 loud warn。
365
365
  */
@@ -90,7 +90,7 @@ export declare const PG_DEADLOCK_DETECTED_SQLSTATE = "40P01";
90
90
  * 它**不是**「锁序可以随便写」的许可证 —— 锁序的属主仍是店(真值神谕 =
91
91
  * `test/sql-lock-shape-innodb-integration.test.ts` 三引擎并发套)。
92
92
  *
93
- * 引擎事实(2026-09-20 真 InnoDB 实测,S-529 取证):同一把缺行主键上 N=8 路并发「`FOR UPDATE` 缺行读
93
+ * 引擎事实(2026-09-20 真 InnoDB 实测,[ref] 取证):同一把缺行主键上 N=8 路并发「`FOR UPDATE` 缺行读
94
94
  * → `INSERT`」,InnoDB(REPEATABLE READ,gap lock + insert-intention)恒定 1 成 7 死锁;TiDB(悲观、无
95
95
  * gap lock)与 PG(READ COMMITTED,缺行 `FOR UPDATE` 不取锁)各自零死锁。⇒ 这条谓词实际的受众是
96
96
  * **MySQL 协议腿**,两方言都认只是为了让店不必自己判引擎。
@@ -1,5 +1,5 @@
1
1
  /**
2
- * **SQL JSON 列读腿的唯一属主**(S-550 设计稿 §2)—— 一列 JSON 怎么**投影**、怎么**恰好解一次码**、
2
+ * **SQL JSON 列读腿的唯一属主**([ref] 设计稿 §2)—— 一列 JSON 怎么**投影**、怎么**恰好解一次码**、
3
3
  * 读不出形怎么**拒**,整仓只有这一份定义。
4
4
  *
5
5
  * ── 病(KM / 7.92.2 C1 的真案,三库实测两次换形之后的终形)────────────────────────────────────
@@ -23,11 +23,11 @@
23
23
  * `test/sql-json-column-single-owner.test.ts` 四道:①`JSON.parse(` 在 `src/plugins/**` 只许出现在本文件
24
24
  * (未改调的店走显式 `PENDING_STORES` 登记 + 反向门);②JSON 承载列(清单由 `schema-ensure-legs` 的录制
25
25
  * 驱动**机器派生**,不手抄)在 SELECT 投影里必须经 {@link jsonColumnText};③{@link decodeJsonColumn} 的
26
- * `read` 实参必须是具名读者,禁内联 `(b) => b as T`;④(S-577)**读者 × 列可空性**求交,**双向**:每一只
26
+ * `read` 实参必须是具名读者,禁内联 `(b) => b as T`;④([ref])**读者 × 列可空性**求交,**双向**:每一只
27
27
  * 形读者对承载列的可空性要求写在门的那张闭集表里,与 DDL 机器派生的读数不符即红(两个方向各一格)。
28
28
  * 那条要求此前是注释里的一句散文,而整仓第二个用它的地方把它违了一整版。
29
29
  *
30
- * ── 「任意 JSON 值」那一族的三只铸点(S-577;区别在**名字**里,不在散文里)─────────────────────
30
+ * ── 「任意 JSON 值」那一族的三只铸点([ref];区别在**名字**里,不在散文里)─────────────────────
31
31
  * 一列的载荷没有声明形时,`null` 字面算不算合法值,**只由这一列有没有「缺席」这个状态**决定 —— 而那是
32
32
  * 列可空性的另一种说法。所以这一族按可空性拆成三只,各自的前置条件由门双向咬:
33
33
  * | 铸点 | 承载列必须 | JSON 字面 `null` |
@@ -69,9 +69,9 @@ export interface JsonColumnMember {
69
69
  *
70
70
  * 🔴 存在的唯一理由是「别名位在那里不合法」,**不是**给读腿留第二条路:读腿一律用 {@link jsonColumnText}
71
71
  * (别名是它的产物的一部分,理由见那只函数)。今天整仓**两处**消费方,各自的「别名位不合法」都是真的:
72
- * · `one-time-migrations.ts` 的 M4(把 `device_audit.detail` 里 JSON 文本 `null` 的旧行改成列 NULL)——
73
- * 它要在 `WHERE` 里判这一列的**文本**,而 `WHERE` 没有别名位;
74
- * · `workflow-journal-store-sql.ts` 的 `loadPage`(S-550 车③a)—— 那一列的投影裹在一条
72
+ * · `one-time-migrations.ts` 的几条改写(M8 / M17 / M18 / M21 的候选扫描与按原文 CAS 回写)——
73
+ * 它们要在 `WHERE` 里判这一列的**文本**,而 `WHERE` 没有别名位;
74
+ * · `workflow-journal-store-sql.ts` 的 `loadPage`([ref] 车③a)—— 那一列的投影裹在一条
75
75
  * `CASE WHEN LENGTH(result) > ? THEN NULL ELSE <expr> END AS result_json` 里:**别名属于整条 CASE**
76
76
  * (`result_json`,因为超字节门的那一支要给 `NULL`),CASE 里面的表达式位上写别名是语法错。
77
77
  * 而「怎么把一列 JSON 取成文本」这件事整仓只能有一种写法:两种承载(真 JSON 列 / LONGTEXT 别名)在这条
@@ -106,9 +106,9 @@ export type SqlJsonColumnBodyProblem = Exclude<SqlJsonColumnProblem, "not-text">
106
106
  * 店层码,**不上 wire**:店层折码口 {@link foldJsonColumn} 把它折成 {@link StoreCorruptError}
107
107
  * (有自己闭集契约词的店折成自己的码)。终局对外码经 7.92.2 的词法门,永不裸穿。
108
108
  *
109
- * 🔴 **它只许在 `not-text` 那一形上穿过店的边界**(S-608):`not-text` 是读腿自己的缺陷(投影漂),
109
+ * 🔴 **它只许在 `not-text` 那一形上穿过店的边界**([ref]):`not-text` 是读腿自己的缺陷(投影漂),
110
110
  * 按 {@link foldJsonColumn} 的规则不折、原样上抛;而体的两形一旦穿出去,上层就得**按列错误类**分类,
111
- * 那正是 S-608 的病 —— 读口按列错误分类、店按店拒绝形折码,两层各说各话,坏体于是落进「店抖动」臂。
111
+ * 那正是 [ref] 的病 —— 读口按列错误分类、店按店拒绝形折码,两层各说各话,坏体于是落进「店抖动」臂。
112
112
  */
113
113
  export declare class SqlJsonColumnError extends Error {
114
114
  readonly problem: SqlJsonColumnProblem;
@@ -157,9 +157,9 @@ export declare function decodeNullableJsonColumn<T>(cell: unknown, read: JsonCol
157
157
  /**
158
158
  * **「这一格耐久载荷读不出来」的店层拒绝**(整仓唯一一只)—— {@link foldJsonColumn} 的**恒定产物**。
159
159
  *
160
- * 🔴 为什么它必须是一只**具名类**而不是 `new Error(…)`(S-608 真案,7.95.1):折码的产物是**店交给
160
+ * 🔴 为什么它必须是一只**具名类**而不是 `new Error(…)`([ref] 真案,7.95.1):折码的产物是**店交给
161
161
  * 上层的契约**。折成裸 `Error` 之后,「这一行确定性地读不出来」与「店抖了一下」在上层**没有任何判别位**,
162
- * 而两者的处置完全相反(前者要人去修那一行,后者重试 / 保守当缺席)。S-577 给续跑上下文修的正是这条
162
+ * 而两者的处置完全相反(前者要人去修那一行,后者重试 / 保守当缺席)。[ref] 给续跑上下文修的正是这条
163
163
  * 分家,可它在 SQL 车道上**结构不可达**整整一版:读口按**列错误类**分类,而店早把列错误折成了裸
164
164
  * `Error` ⇒ 坏体一路掉进「店抖动 ⇒ 当缺席」臂,用户拿到的还是那个 409(local 车道答对,只是因为它
165
165
  * 根本没折码、把列错误漏了出来 —— 巧合式正确,不是同一份契约)。
@@ -187,9 +187,9 @@ export declare class StoreCorruptError extends Error {
187
187
  /**
188
188
  * 店层折码的**唯一规则**(`catch (e) { throw foldJsonColumn(e, (m) => \`XStore: ${m} — refusing …\`); }`)。
189
189
  *
190
- * 🔴 回调交出来的是**一句话**,不是一只错误(S-608 按类改):产物恒是 {@link StoreCorruptError},于是
190
+ * 🔴 回调交出来的是**一句话**,不是一只错误([ref] 按类改):产物恒是 {@link StoreCorruptError},于是
191
191
  * 「折成一只没有判别位的错」在**构造上**写不出来。此前这一格的签名是 `(message) => Error`,21 个调用点
192
- * 里 19 个折成了裸 `Error` —— 每一个都是一枚等着下一个消费方来踩的 S-608。
192
+ * 里 19 个折成了裸 `Error` —— 每一个都是一枚等着下一个消费方来踩的 [ref]。
193
193
  *
194
194
  * 🔴 `not-text` **不折**:它是读腿自己的缺陷(投影漏了),折成「这一行坏了」会把一次代码漂伪装成一次
195
195
  * 数据事故 —— 这条判别只写在这里一处(与它的容忍侧孪生 {@link isJsonColumnBodyProblem} 共用),
@@ -233,7 +233,7 @@ export declare function createZodColumnReader<T>(schema: z.ZodType<T>): JsonColu
233
233
  * 该店的域型交出去。整仓**只有这一处**做这一跳断言。
234
234
  *
235
235
  * 🔴 什么时候用它(硬条件,别扩大):这一列的键表属主**不在本层**,而那一层**没有导出验证器**。
236
- * 两族,判据同一条(S-577 把这段与本函数第一句对齐 —— 它此前只写了 core 那一族,于是第二族要么被迫
236
+ * 两族,判据同一条([ref] 把这段与本函数第一句对齐 —— 它此前只写了 core 那一族,于是第二族要么被迫
237
237
  * 违注、要么被迫另造一只读者,而「加一只特例读者」在本仓是红旗):
238
238
  * · 属主在 **core**:`Checkpoint` / `ResumeOutcome` / `GateOutcome` / `WorkflowRun` /
239
239
  * `BackgroundAgentRecord` …;
@@ -246,7 +246,7 @@ export declare function createZodColumnReader<T>(schema: z.ZodType<T>): JsonColu
246
246
  * 一列只要有**本层自己的** schema 属主,就必须用 {@link createZodColumnReader} —— 用本函数等于把形判据关小。
247
247
  *
248
248
  * 🔴 为什么是一只工厂而不是让每个店各写一遍 `typeof body !== "object"`:那是同一条判据的 N 份拷贝
249
- * (S-550 车② 初版真的写了六份),而且每一份都要自己那一跳 `as`。收成一处之后,判据只有一个写者,
249
+ * ([ref] 车② 初版真的写了六份),而且每一份都要自己那一跳 `as`。收成一处之后,判据只有一个写者,
250
250
  * 断言也只发生在这一行 —— 类型卫生门因此在每个店里都读到零。
251
251
  */
252
252
  export declare function createObjectColumnReader<T extends object>(): JsonColumnReader<T>;
@@ -265,17 +265,17 @@ export declare function isJsonObject(v: unknown): v is Record<string, unknown>;
265
265
  *
266
266
  * 🔴 前置条件(**门④ 机器执法,不是散文**):承载列**可空**,而「缺席」在它上面由**列的 NULL** 单独表达
267
267
  * (三态列);于是 JSON 字面 `null` 是一个与缺席**不同形**的合法值。用在 `NOT NULL` 列上当场红 —— 那种列
268
- * 根本没有缺席态,`null` 字面与「没有这一行」在点读的消费点上逐字同答,而那正是 S-577 的病灶
268
+ * 根本没有缺席态,`null` 字面与「没有这一行」在点读的消费点上逐字同答,而那正是 [ref] 的病灶
269
269
  * (`checkpoint_ctx.ctx`:`JSON NOT NULL` + 有结构的载荷,一整版都读回一个没人分得出来的 `null`)。
270
270
  * NOT NULL 且契约不透明的列用 {@link readOpaqueJsonValueColumn};缺席落 SQL NULL 的用
271
271
  * {@link readNonNullJsonValueColumn}(那一族把 `null` 字面判坏)。
272
272
  *
273
273
  * 之所以叫得出「三态」:范本是 `approval_ask.updated_input`([ref] / [ref])—— 列 NULL = 没带编辑,
274
274
  * JSON 文本 `"null"` = **编辑成 null**,对象 = 编辑成那只对象;把 `"null"` 判成坏体会把一条合法的人类
275
- * 编辑抹掉。这一句是**理由**,不是名单:哪几处在用它由门数,别在这里写计数(S-577 之前这里写着
275
+ * 编辑抹掉。这一句是**理由**,不是名单:哪几处在用它由门数,别在这里写计数([ref] 之前这里写着
276
276
  * 「今天整仓只有一处符合」—— 那句话当时就是假的,而没有门看着的计数,下一个人加第二处时不会来改它)。
277
277
  *
278
- * 一列只要有结构,就**不许**用它 —— 那是把形判据静默关掉(这条是 S-577 的病灶判据,三只铸点同守)。
278
+ * 一列只要有结构,就**不许**用它 —— 那是把形判据静默关掉(这条是 [ref] 的病灶判据,三只铸点同守)。
279
279
  */
280
280
  export declare const readTriStateJsonValueColumn: JsonColumnReader<unknown>;
281
281
  /**
@@ -294,14 +294,14 @@ export declare const readTriStateJsonValueColumn: JsonColumnReader<unknown>;
294
294
  * 🔴 **它与 {@link readTriStateJsonValueColumn} 的实现逐字相同,而且必须各自独立写出来** —— 不许收成
295
295
  * `export const readOpaqueJsonValueColumn = readTriStateJsonValueColumn`(门④c2 会红)。两只的区别整个
296
296
  * 落在**前置条件**上(一只要可空列、一只要 NOT NULL 列),而前置条件的载体就是**名字**:合成一个名字就等于
297
- * 把两条互斥的前置条件重新揉回一起 —— 那正是 S-577 立案时那条散文析取的形。「去重」在这里去掉的不是重复,
297
+ * 把两条互斥的前置条件重新揉回一起 —— 那正是 [ref] 立案时那条散文析取的形。「去重」在这里去掉的不是重复,
298
298
  * 是判据。
299
299
  */
300
300
  export declare const readOpaqueJsonValueColumn: JsonColumnReader<unknown>;
301
301
  /**
302
302
  * **任意 JSON 值,但缺席由「列 NULL」表达**的列的形读者 —— `null` 字面判坏,其余一律是值。
303
303
  *
304
- * 🔴 这是**写腿吃 `unknown` 的那一族列**的正解(codex 对抗复审 [high] 验真后定形,S-550 车②):
304
+ * 🔴 这是**写腿吃 `unknown` 的那一族列**的正解(codex 对抗复审 [high] 验真后定形,[ref] 车②):
305
305
  * 写腿接的是 `unknown`(`PendingAction.args` / 账本行载荷 / leader 结果……),于是**数组 / 串 / 数 /
306
306
  * 布尔实参都写得进去** —— 拿 {@link readJsonObjectColumn} 判它们就是「写腿收得下、读腿读不出」,而且
307
307
  * 后果往往不是一行坏:`rows.map` 里一条这样的合法行会让整只读面抛。
@@ -312,14 +312,14 @@ export declare const readOpaqueJsonValueColumn: JsonColumnReader<unknown>;
312
312
  * (根本没有缺席态),用 {@link readOpaqueJsonValueColumn}。
313
313
  *
314
314
  * 🔴 与 {@link readTriStateJsonValueColumn} 同属「承载列必须**可空**」这一族,所以同受门④ 约束
315
- * (S-577):这族读者用在 `NOT NULL` 列上一律红 —— 列上没有 NULL 这个状态,「缺席」就无处安放,而写腿把
315
+ * ([ref]):这族读者用在 `NOT NULL` 列上一律红 —— 列上没有 NULL 这个状态,「缺席」就无处安放,而写腿把
316
316
  * 缺席落成 SQL NULL 这句话在那种列上根本执行不了。
317
317
  */
318
318
  export declare const readNonNullJsonValueColumn: JsonColumnReader<unknown>;
319
319
  /**
320
320
  * **一只 JSON 数组**的承载形读者(内容判据归各列自己的既有属主,这里只判承载形)。
321
321
  *
322
- * 🔴 为什么在属主里而不是各店各写一遍(S-550 车③a 把车② 的店内私有形上收):今天有三个消费方
322
+ * 🔴 为什么在属主里而不是各店各写一遍([ref] 车③a 把车② 的店内私有形上收):今天有三个消费方
323
323
  * (checkpoint 的 `rule_suggestions` / `pending_steer_queue`、memory-engine 的 `embedding`),判据逐字
324
324
  * 相同,而「这一格是不是一只数组」恰好是坏体四形的落点 —— 三份拷贝迟早有一份忘了判 `null` 字面。
325
325
  */
@@ -4,8 +4,8 @@
4
4
  * These were duplicated verbatim across the pg-/tidb- store twin pairs; each store imports the flavor
5
5
  * it was written against so call sites and semantics are byte-identical to before.
6
6
  *
7
- * 🔴 **JSON 列的解析不在这里,也永远不会回来**(S-550):本文件曾住着三只 `parseJson*`
8
- * (lenient → `null` / strict → 抛 / fallback → 兜底),三种失败方向由**调用点自选** —— 那正是 S-550
7
+ * 🔴 **JSON 列的解析不在这里,也永远不会回来**([ref]):本文件曾住着三只 `parseJson*`
8
+ * (lenient → `null` / strict → 抛 / fallback → 兜底),三种失败方向由**调用点自选** —— 那正是 [ref]
9
9
  * 要消灭的现状:同一格读不出的 JSON,在一个店里是「空体」、在另一个店里是「这一行不存在」、在第三个
10
10
  * 店里是异常。三只在车③b **删除**(零别名、零转出),整仓唯一属主 = `sql-json-column.ts`
11
11
  * (按文本投影 · 恰好解一次码 · 坏体一律拒),容忍写在店的调用点上(显式 `try/catch` + `recordFailOpen`)。
@@ -50,7 +50,7 @@ export type { ApprovalNonceStore } from "./approval-nonce-store.js";
50
50
  * 车3 刀 3a 起 `StoreBackend.approvalAsk()` 已在(见接口体的那条注)。 */
51
51
  export type { ApprovalAskStore, AskRow, NewAskRow, AskTransitionPatch, DecideAskInput, DecideResult, ExpireResult, BindGateInput, BatchRow, AskDecision } from "./approval-ask-store-sql.js";
52
52
  /** E6 SessionPolicyStore — core's interface, incl. its optional `deleteBySession` / `listBySession` seams (E21 purge / 2c
53
- * export; core's File and InMemory stores carry both since core 7.25.0 — S-546 A7 retired the service's own in-memory
53
+ * export; core's File and InMemory stores carry both since core 7.25.0 — [ref] A7 retired the service's own in-memory
54
54
  * twin that existed only because they once did not). tidb/pg = the SQL twin; local = core's FileSessionPolicyStore
55
55
  * (works local — rules need no cloud-only infra). The rev-line contract kit runs the SQL twin against core's InMemory
56
56
  * as oracle (`test/helpers/session-policy-rev-line-contract.ts`). */
@@ -94,12 +94,13 @@ export type ServiceFileHistoryStore = FileHistoryStore & {
94
94
  /** SVC-2 (core CORE-7) WorkflowJournalStore — core's interface PLUS the service `deleteByRun` (GC extra). tidb/pg =
95
95
  * durable SQL twins (cross-replica resume journal); local = the service {@link FileWorkflowJournalStore}
96
96
  * (single-box but RESTART-durable crash-safe JSONL, replacing core's InMemory). The shared equivalence suite keeps
97
- * all three byte-matched (scope guard / idempotent-per-ordinal / oversize **refusal** —— S-194 / core 7.12.0
97
+ * all three byte-matched (scope guard / idempotent-per-ordinal / oversize **refusal** —— [ref] / core 7.12.0
98
98
  * [ref] 起两臂一律抛 `workflow.journal_oversize`,判长口径归 core `assertJournalEntryFits` 单一属主). */
99
99
  export type ServiceWorkflowJournalStore = WorkflowJournalStore & {
100
- /** codex R1-H2(journal 读面界):分页+单行字节门的投影读——SQL 端 LIMIT/OFFSET 定行数、LENGTH 门
101
- * 定单行(超 maxResultBytes 的行 resultJson=null 只回 resultBytes,读面标 truncated)。HTTP 读面
102
- * 优先走此面;缺席(旧实现/in-memory)回落全量 load(元素少的店可受)。 */
100
+ /** journal 读面的分页投影读:**判整份、取一页**——与 `load` 同一个判的范围(这条 journal 里任一行被 core 的判官判坏,本读就抛
101
+ * `WorkflowJournalIncompatibleError`,点名按序数升序的第一条坏行;页不是判的单位),只是内存按块有界:返回 `[offset, offset+limit)` 位置上的行,
102
+ * 字节超 `maxResultBytes` 的行 `resultJson=null` 只回 `resultBytes`(读面标 truncated,全文不进页)。HTTP 读面优先走此面;
103
+ * 缺席(file / in-memory 店)回落 `load` 后在进程内切页——`load` 本身就整份判,两条路同答。 */
103
104
  loadPage?(runId: string, scope: string, opts: {
104
105
  offset: number;
105
106
  limit: number;
@@ -140,11 +141,11 @@ export type BreakerStateStore = TiDBBreakerState | PgBreakerState;
140
141
  export type CostQuotaStore = TiDBCostQuota | PgCostQuota;
141
142
  export type RateLimiterStore = TiDBRateLimiter | PgRateLimiter;
142
143
  /**
143
- * S-215 —— capture opt-out **记录载体的按平面取用座**。形与 core 的
144
+ * [ref] —— capture opt-out **记录载体的按平面取用座**。形与 core 的
144
145
  * `RunnerDeps.memoryCaptureRecordStore`(`(plane: { controlDir }) => SessionCaptureRecordStore`)同构,
145
146
  * 多一个**不指名平面**的缺省臂:`src()` = 「本部署记忆引擎自己那一只平面」。
146
147
  *
147
- * 🔴 为什么是工厂而不是一只实例(S-215 codex r1 [high] 验真后改形):core 的记忆平面**不止一个**
148
+ * 🔴 为什么是工厂而不是一只实例([ref] codex r1 [high] 验真后改形):core 的记忆平面**不止一个**
148
149
  * (`prepare-memory.js` 的 personal 平面自带 `derivePersonalControlDir(engineRoot)`,与 project 平面的
149
150
  * controlDir 不是同一只)。返回单只实例 ⇒ server 把所有平面折到一只目录上,于是升级前落在 personal
150
151
  * 控制面的旧 opt-out 记录在升级后读作**缺席**=采集恢复(隐私面的静默 fail-open)。按平面取用后,
@@ -173,7 +174,7 @@ export interface StoreBackend {
173
174
  /** Per-session per-toolName approval exemption ("本会话不再询问") — an approval MEMORY the F4
174
175
  * ask-gate consults after deny/neverAuto. REQUIRED on all backends (works local, like resumeAnchor). */
175
176
  approvalExemption(): ApprovalExemptionStore;
176
- /** S-280 直连门审批证明的一次性消费记录(`plan_review` 的 nonce)。REQUIRED on all backends —— 与
177
+ /** [ref] 直连门审批证明的一次性消费记录(`plan_review` 的 nonce)。REQUIRED on all backends —— 与
177
178
  * `approvalExemption` 同姿势:tidb/pg = SQL 双方言(单类双语句),local = File 追加日志 + 压实。
178
179
  * **不能**退化成进程内易失形:一次重启若把记录抹掉,JWT TTL 窗内的重放就复活了,而那正是本店要关的洞。 */
179
180
  approvalNonce(): ApprovalNonceStore;
@@ -185,7 +186,7 @@ export interface StoreBackend {
185
186
  /** [ref]([ref] §3.0-§3.2)流内审批协议持久层:每个流内工具调用一行的 ask 状态机 + 批行。
186
187
  * REQUIRED **且持久** on all backends — tidb/pg = SQL 双方言 twin;local = {@link FileApprovalAskStore}。
187
188
  *
188
- * 🔴 **「持久」是本口的契约,不是某条腿的巧合**(S-384):`resolveStreamApprovalGate` 自此**不再**
189
+ * 🔴 **「持久」是本口的契约,不是某条腿的巧合**([ref]):`resolveStreamApprovalGate` 自此**不再**
189
190
  * 单独判一次 ask 账的持久性 —— 那条合取项(旧 `volatile_ask_ledger`)存在的唯一理由是 local 车道
190
191
  * 当年交的是 `InMemoryApprovalAskStore`(两个进程内 Map ⇒ 重启同时丢重放基准、丢已接受的决议;
191
192
  * 「一次真实的人类批准凭空消失」与「对账便利丢失」不是一个量级)。File 形落地后三条腿全是持久店,
@@ -220,12 +221,12 @@ export interface StoreBackend {
220
221
  /** SendUserFile scope↔object ledger (multi-tenant list/revoke handle; the hashed key segment hides the
221
222
  * mapping from URLs). REQUIRED on all backends (works local — one JSONL, like approvalExemption). */
222
223
  sendFileLedger(): SendFileLedger;
223
- /** S-928 用户输入受理账本的存储孪生(「200 applied」受理的影子;语义属主 `src/user-input-ledger.ts`)。REQUIRED on all backends ——
224
+ /** [ref] 用户输入受理账本的存储孪生(「200 applied」受理的影子;语义属主 `src/user-input-ledger.ts`)。REQUIRED on all backends ——
224
225
  * local = File(数据根下 `user-input-ledger/ledger.jsonl`,singleton:追加 fd 与内存折叠都在实例里),SQL = 表 `user_input_acceptance`。 */
225
226
  userInputLedger(): UserInputLedgerStore;
226
227
  /** E6 durable SessionPolicyStore (operator-tightened per-session tool rules). REQUIRED on all backends — works local
227
228
  * (local = core's FileSessionPolicyStore), like resumeAnchor. Backs core's RunnerDeps.sessionPolicyStore.
228
- * `logger`:SQL 孪生抹除封键那一臂(S-891)的点名口(缺席 ⇒ 店退回 `console.warn`);local(core 的 File 店)不收。 */
229
+ * `logger`:SQL 孪生抹除封键那一臂([ref])的点名口(缺席 ⇒ 店退回 `console.warn`);local(core 的 File 店)不收。 */
229
230
  sessionPolicy(logger?: SessionPolicyStoreLogger): ServiceSessionPolicyStore;
230
231
  /** [ref] per-edited-file rewind FileHistoryStore (trackEdit/annulTrack/snapshot/restore over the tracked set;
231
232
  * also the 2c history-transfer store). REQUIRED on all backends (local = core's file-backed
@@ -243,14 +244,14 @@ export interface StoreBackend {
243
244
  * 「没有行 ⇒ 代码缺省 allow」—— 那是**放宽面**上的静默降级(permissionRule 那条禁令的同一理由)。
244
245
  * File 形候真实的 local+governed 部署需求出现再落(候需求档)。 */
245
246
  memoryOptOutGrant(): MemoryOptOutGrantStore | undefined;
246
- /** [ref]②([ref] §2.1b,core 7.0.2 [ref] 件2)/ S-215:会话 capture opt-out **记录**的载体 ——
247
+ /** [ref]②([ref] §2.1b,core 7.0.2 [ref] 件2)/ [ref]:会话 capture opt-out **记录**的载体 ——
247
248
  * core `RunnerDeps.memoryCaptureRecordStore` / `MemoryEngineOptions.captureRecordStore` 的持久层。
248
249
  * 与 §3.1 的**授权表**不是一个轴:那张管「谁**可以** opt-out」(operator 写的 verdict),这张管
249
250
  * 「谁**已经** opt-out」(用户写的一次性单向记录)。
250
251
  *
251
252
  * 返回的是**按平面取用的源**({@link SessionCaptureRecordSource}),不是一只实例 —— core 的记忆平面
252
253
  * 不止一只,折平会挪动旧记录的地址(理由全文见该类型的头注)。
253
- * 载体按车道分形,但**三条车道都供**(S-215 起):SQL 两支 = 双方言 twin(`session_capture_optout`,
254
+ * 载体按车道分形,但**三条车道都供**([ref] 起):SQL 两支 = 双方言 twin(`session_capture_optout`,
254
255
  * Promise 形三腿,池即依托 ⇒ 无条件供,`plane` 刻意忽略);`local` = core 的控制面文件三腿
255
256
  * `fileSessionCaptureRecordStore(controlDir)` 按平面现造,依托是**记忆引擎的控制面目录** ⇒ 记忆面暗的
256
257
  * 部署上该平面不存在,于是这一支**随引擎接线门缺席**(唯一的 `undefined` 成因,逐字理由见 LocalBackend 的实装注)。
@@ -259,7 +260,7 @@ export interface StoreBackend {
259
260
  * 确实就是文件三腿)、在**接线层面**是假的:core 的 `captureCarrierUnsupported`
260
261
  * (core 7.13.0 `prepare-task.js`)判的是「这个席位在不在」而不是「文件形能不能用」,叠上
261
262
  * `isRemoteExecutionEnv` 的接口形鸭子判(`remote-env.js`)把本仓 host lane 一并算作 remote,
262
- * 于是单机默认部署上 `memoryCapture:"off"` 两条 ingress 结构性不可达(B-085)。
263
+ * 于是单机默认部署上 `memoryCapture:"off"` 两条 ingress 结构性不可达([ref])。
263
264
  * 刻意仍不给 local 一个**内存** twin:内存形会在重启时把一条隐私记录静默丢掉(比文件三腿严格更差)。 */
264
265
  sessionCaptureRecords(): SessionCaptureRecordSource | undefined;
265
266
  /** Retired-epoch byte hygiene: GC grace-passed orphan `snapshot_blob` rows/objects — the whole-tree snapshot
@@ -301,7 +302,7 @@ export interface StoreBackend {
301
302
  /** 1.108 review fix (lens③ HIGH): the notify-JOURNAL twin — third leg of the same axis (a SQL run store +
302
303
  * inbox with a replica-LOCAL File journal stranded a dead replica's un-acked notify forever). */
303
304
  notifyJournal?(): import("../orchestration/workflow-notify-journal.js").WorkflowNotifyJournalStore;
304
- /** S-185 车CM:workflow 出身 park 的**有界 join** 索引(子会话 id → 它所属的 workflow run)。
305
+ /** [ref] 车CM:workflow 出身 park 的**有界 join** 索引(子会话 id → 它所属的 workflow run)。
305
306
  * 与 `workflowRun`/`completionInbox`/`notifyJournal` 同一条轴 —— SQL 后端 = 跨副本双生;`local` 车道
306
307
  * 缺席**是一个真答案**:那里的索引家在 run 店同一间屋子里(`LocalWorkflowAgentSessionIndex`,文件账本
307
308
  * 或纯内存),不需要经过 backend。契约与单写者纪律的属主 = orchestration/workflow-agent-session-index.ts。 */
@@ -396,7 +397,7 @@ export interface StoreBackend {
396
397
  * clock to expose replica clock skew (the write-behind counters bucket on LOCAL floor(now/windowMs); skew
397
398
  * splits a fleet window into disjoint buckets = soft-limit leak). OPTIONAL: local backend omits (no fleet). */
398
399
  dbNowMs?(): Promise<number>;
399
- /** S-1014(core 7.41.0 #1308):**local 后端专有**的 usage-window 账本店 = core `FileStorageBackend` 自己那一只(`usageWindowStore`)——
400
+ /** [ref](core 7.41.0 [ref]):**local 后端专有**的 usage-window 账本店 = core `FileStorageBackend` 自己那一只(`usageWindowStore`)——
400
401
  * 它的坏读披露座是 backend 构造时那**一只** `onCorruptRead`(core:「`FileStorageBackend` forwards its one sink」),所以坏账本拒(`usage_window.store_corrupt`,
401
402
  * 拒绝句不带盘上位置)的同时,路径进本 backend 的 `file_store_corrupt_read` 披露座(逐命中 warn)。修前 `boot/stores.ts` 在同一数据根上自己
402
403
  * `new FileUsageWindowStore(root)` 第二只实例、不接座 ⇒ 坏值只拒不披露,运维找不到是哪只文件。SQL 后端省略(它们有自己的 usage-window 双方言店)。 */
@@ -1,5 +1,5 @@
1
1
  import { homedir } from "node:os";
2
- import { createCorruptReadFailOpenSeat, createDurableAbsenceSeat } from "../observability/corrupt-read-seat.js";
2
+ import { createCorruptReadSeat, createDurableAbsenceSeat } from "../observability/corrupt-read-seat.js";
3
3
  import { createLogger } from "../observability/logger.js";
4
4
  import { join } from "node:path";
5
5
  import { AdoptionError, FileStorageBackend } from "@sema-agent/core";
@@ -272,7 +272,7 @@ class LocalBackend {
272
272
  this.sendFileLedgerStore = new FileSendFileLedger(this.fileBackend.root);
273
273
  this.userInputLedgerStore = new FileUserInputLedgerStore(this.fileBackend.root);
274
274
  this.workflowJournalStore = new FileWorkflowJournalStore(this.fileBackend.root, undefined, {
275
- onCorruptRead: createCorruptReadFailOpenSeat("server.workflow-journal.corrupt-record-skipped"),
275
+ onCorruptRead: createCorruptReadSeat(corruptReadWarn, "workflow_journal_refused", "workflow journal = a line the engine cannot read refuses the whole load; the run cannot be listed or resumed until the file is repaired from a kept copy"),
276
276
  });
277
277
  this.outcomeSinkInst = new FileOutcomeSink(this.fileBackend.root);
278
278
  const ownControlDir = fileMemoryControlDirFor(config);
@@ -324,7 +324,7 @@ class LocalBackend {
324
324
  checkpointStoreOf() {
325
325
  return (this.checkpointStoreInst ??= new LocalCheckpointStore(this.fileBackend.root, {
326
326
  getActiveTaskId: (sessionId) => this.runStore.getActiveTaskId(sessionId),
327
- ownerOf: (sessionId) => this.sessionStore.ownerOf(sessionId),
327
+ readSessionOwner: async (sessionId) => (await this.sessionStore.headOf(sessionId))?.owner,
328
328
  }));
329
329
  }
330
330
  checkpoint() {
@@ -9,7 +9,7 @@
9
9
  * Rules for this file:
10
10
  * - ZERO dialect dependencies (no mysql2, no pg) — types + pure functions only. The only imports
11
11
  * allowed are core contract types and the neutral sql-row-helpers leaf.
12
- * (S-550 车③a:`mapBakeRow`/`mapImageRow`/`BAKE_SELECT_COLS` 搬回了它们**唯一**的消费者
12
+ * ([ref] 车③a:`mapBakeRow`/`mapImageRow`/`BAKE_SELECT_COLS` 搬回了它们**唯一**的消费者
13
13
  * `image-bake-store-sql.ts` / `image-index-sql.ts` —— 「两个 SQL 孪生共用」那条理由在孪生合成
14
14
  * 单文件双方言之后就不存在了,而一条 SELECT 的**列清单**必须和它的**投影铸点**、**解码点**长在
15
15
  * 同一个文件里:否则 JSON 承载列的投影门(它按「这个文件查了哪张表」定列集)对那份清单是瞎的。)
@@ -20,7 +20,7 @@
20
20
  */
21
21
  import type { PeerSessionTempo, TaskResult, TaskStatus } from "@sema-agent/core";
22
22
  /**
23
- * **File 店族的 boot 期拒启基类**(S-384;把 `RunStoreStrictHydrateError` 的那条论证升成一条族规)。
23
+ * **File 店族的 boot 期拒启基类**([ref];把 `RunStoreStrictHydrateError` 的那条论证升成一条族规)。
24
24
  *
25
25
  * 🔴 **为什么必须是一个可判别的类型,而且必须是一个共同基类**:`openStoreBackendWithFallback` 对
26
26
  * **默认推导**的 local(`DB_BACKEND` 未设 —— 也就是绝大多数单机部署)有一条既有降级臂:mkdir / 只读盘
@@ -31,7 +31,7 @@ import type { PeerSessionTempo, TaskResult, TaskStatus } from "@sema-agent/core"
31
31
  * 「DB 不可达,已退回内存」把运维支去查连通性。
32
32
  *
33
33
  * 此前这条纪律是**逐个 `if instanceof` 手工登记**的(`AdoptionError` / `RunStoreStrictHydrateError`),
34
- * 于是「下一只会拒启的 File 店」默认是**漏的** —— S-384 的 ask 账本拒启就这么漏了一次(替补对抗复审
34
+ * 于是「下一只会拒启的 File 店」默认是**漏的** —— [ref] 的 ask 账本拒启就这么漏了一次(替补对抗复审
35
35
  * F1 [high] 实测:`DB_BACKEND` 未设时坏账本 ⇒ `{backend: undefined, degraded: true}`,不是拒启)。
36
36
  * 收法:**一个基类,一条重抛**。新 File 店的拒启只要 `extends StoreBootRefusalError` 就自动落在正确的
37
37
  * 一侧;忘了继承是**可见**的(它是一个必须显式选择的父类),而忘了往 if 链里加一行是不可见的。
@@ -97,7 +97,7 @@ export interface RunCancelContext {
97
97
  elapsedMs?: number;
98
98
  }
99
99
  /**
100
- * 🔴 S-947(cli [ref] 第 3 件 / L-212)—— **server 为什么中止了这条 run**:取消终局的机读成因,闭集。
100
+ * 🔴 [ref](cli [ref] 第 3 件 / [ref])—— **server 为什么中止了这条 run**:取消终局的机读成因,闭集。
101
101
  *
102
102
  * 病:非 detach 流断连、`POST /v1/runs/:id/cancel`、断连时有 ask 但 park 宽限用尽 —— 三件事在终局上**逐字同形**
103
103
  * (`failed` + `terminal.code:"cancelled"`),壳只能按 `errorMessage` 文案猜。
@@ -109,7 +109,7 @@ export interface RunCancelContext {
109
109
  * · `cancel_verb` —— `POST /v1/runs/:id/cancel`:同副本快路、跨副本耐久取消旗的轮询(四条腿的心跳 / 登记追平),
110
110
  * 以及 park 中的 run 被它直接终局化(那一形不经 abort,成因照样是这条动词)。
111
111
  * **刻意不在表里**(普查过、没有真站点):抢占(`preempt` 是优雅让出,终局是 `paused`,不是取消)、有序关停
112
- * (S-929 只把未决卡转 park,从不中止活 run;进程退出后的行由收割器落「持有者死亡」判决,那不是本仓铸的取消终局)、
112
+ * ([ref] 只把未决卡转 park,从不中止活 run;进程退出后的行由收割器落「持有者死亡」判决,那不是本仓铸的取消终局)、
113
113
  * `interrupt`(引擎的 turn 动词,终局 `completed` + `haltedByUser`)、detach 断连(不中止)。
114
114
  *
115
115
  * 词表属主 = 本文件(与它所在的 {@link PersistedTaskResult} 同住);**单写者** = `run-cancel-context.ts` 的 `createRunAbort`
@@ -123,7 +123,7 @@ export type AbortCause = (typeof ABORT_CAUSES)[number];
123
123
  * 本型是这一族键的**唯一登记处**(`trace/core-keyset-guard.ts` 的辖域线指向这里;那边另有一道编译期钉:
124
124
  * core 的 `TaskResult` 哪天长出同名键 ⇒ 当场红 —— 同一个键两个铸者是本型存在要防的那件事)。
125
125
  * · `cancelContext`([ref])—— 取消现场快照(分诊材料:多久没动静、起跑多久);
126
- * · `abortCause`(S-947)—— 这次取消是谁 / 什么发起的({@link AbortCause})。
126
+ * · `abortCause`([ref])—— 这次取消是谁 / 什么发起的({@link AbortCause})。
127
127
  * 两键**同一只铸点**(`mintCancelledResult`)、**同一条在场闸**(「只补空座」:终局就是被那次中止打断的那一条,
128
128
  * 才挂;与中止赛跑跑完的终局、引擎自带码的失败一律原样立住、两键都不挂)。差别只在缺席纪律:快照一键都证不出 ⇒ 整只缺席;
129
129
  * 成因在铸点那一刻恒已知 ⇒ 取消终局上恒在场。
@@ -141,14 +141,14 @@ export interface PersistedResultSideKeys {
141
141
  */
142
142
  export type PersistedTaskResult = TaskResult & PersistedResultSideKeys;
143
143
  /**
144
- * 🔴 run 店「持有它的实例丢了」那一判的**行上落款**(S-928 codex r1-F1 提为常量):三只 run 店的 `reapStale` 把心跳过期的 running 行翻成
144
+ * 🔴 run 店「持有它的实例丢了」那一判的**行上落款**([ref] codex r1-F1 提为常量):三只 run 店的 `reapStale` 把心跳过期的 running 行翻成
145
145
  * `failed` 并写下这一句。它是 run 店死亡判决留在行上的证据之一(另一只 = {@link RUN_ORPHANED_ERROR})—— 用户输入受理账本的收敛判词
146
- * (S-969 L8 起两车道同一只)据 {@link isHolderDeathVerdict} 在 reap **之后**仍能判出「写者死了」—— 7.116.0 起判据是同行的机读码 `run.stalled`({@link RUN_HOLDER_DEATH_CODES}),本句只给人读;三个写者同写句子与码。读时折叠成同一句话的 wire 展示站点
146
+ * ([ref] L8 起两车道同一只)据 {@link isHolderDeathVerdict} 在 reap **之后**仍能判出「写者死了」—— 7.116.0 起判据是同行的机读码 `run.stalled`({@link RUN_HOLDER_DEATH_CODES}),本句只给人读;三个写者同写句子与码。读时折叠成同一句话的 wire 展示站点
147
147
  * (`routes/runs.ts` 的 stale 折叠、`routes/trace-usage.ts` 的 WORKER_DOWN 帧)刻意留字面量:它们由文案冻结门逐字钉着,且不参与任何判据。
148
148
  */
149
149
  export declare const RUN_STALLED_ERROR = "run stalled (instance lost?)";
150
150
  /**
151
- * 🔴 File 车道「持有它的进程随重启没了」那一判的行上落款(S-969 L8 提为常量):boot 孤儿回收(`FileRunStore.reclaimOrphanedAtBoot`,
151
+ * 🔴 File 车道「持有它的进程随重启没了」那一判的行上落款([ref] L8 提为常量):boot 孤儿回收(`FileRunStore.reclaimOrphanedAtBoot`,
152
152
  * 数据根 LOCK 作证前世进程已死 ⇒ 仍 running 的行无条件判孤儿)与运行期 claim 接管的 running 臂(`judgeClaim`,外来 + owner 已死 + 无可续)
153
153
  * 都写这一句;接管臂在括号里附上前任持有者的进程指纹(取证用,形 = {@link buildRunOrphanedError})。与 {@link RUN_STALLED_ERROR} 同一种身份:
154
154
  * run 店写在行上的**死亡判决**,读者 = {@link isHolderDeathVerdict}(按同行的机读码 `run.orphaned` 判,本句只给人读)。
@@ -220,7 +220,7 @@ export interface RunRecord {
220
220
  * MY replica" (consult the in-process inflight/steerable map authoritatively) from "held elsewhere" (fall
221
221
  * back to the durable cross-replica flag). null for pre-column rows. */
222
222
  instanceId: string | null;
223
- /** 🔴 S-230 P-45 —— 这条 run 上**挂没挂着取消请求**(耐久 `cancel_requested` 列的投影,跨副本)。
223
+ /** 🔴 [ref] P-45 —— 这条 run 上**挂没挂着取消请求**(耐久 `cancel_requested` 列的投影,跨副本)。
224
224
  *
225
225
  * 语义就是那一列的字节:`POST /v1/runs/:id/cancel` 的 running 臂 CAS 成功即置位,持有副本的心跳拍
226
226
  * poll 到它就 abort;`markResuming`(续跑认领)把它清零 —— 一次撞上 suspend 的取消不许在恢复之后
@@ -325,7 +325,7 @@ export interface InProcessClaimFence {
325
325
  * 治理判决:门拒绝那条腿在 core 里走 `paused`/`failed`,永远不铸这个词;
326
326
  * · `parked` —— 停在门上还能再动(`suspended` 审批/资源门、`needs_review` 评审门)。
327
327
  *
328
- * 🔴 为什么是**一张表**而不是三张 switch(S-213③,2026-09-11):`blocked` 这个词此前在本仓有**两个
328
+ * 🔴 为什么是**一张表**而不是三张 switch([ref]③,2026-09-11):`blocked` 这个词此前在本仓有**两个
329
329
  * 独立写者**且答案互斥 —— `observability/run-terminal.ts` 判它是「治理判决,不是失败 ⇒ 不打行」,
330
330
  * `fleet/fleet-bus.ts` 判它是「非成功终局(agent 放弃)⇒ failed 桶、行离场」。两处各自穷举、各自正确
331
331
  * 地编译,而一条 `report_blocked` 的 run 在面板上离场、在引擎日志里一个字都没有。三张手抄的 switch
@@ -355,20 +355,20 @@ export type UnsuccessfulRunStatus = {
355
355
  [K in RunRecord["status"]]: (typeof RUN_STATUS_CLASS)[K] extends "unsuccessful" ? K : never;
356
356
  }[RunRecord["status"]];
357
357
  /** 表判为「park」(停在门上)的词 —— **从表派生**,不是手抄的第二份清单。今天 = `"suspended" | "needs_review"`。
358
- * 消费点(S-173:同步提交 200 体的 poll 回执 `status`,`http/sync-submit-body.ts`)拿它当型;表翻面 ⇒ 那里当场红。 */
358
+ * 消费点([ref]:同步提交 200 体的 poll 回执 `status`,`http/sync-submit-body.ts`)拿它当型;表翻面 ⇒ 那里当场红。 */
359
359
  export type ParkedRunStatus = {
360
360
  [K in RunRecord["status"]]: (typeof RUN_STATUS_CLASS)[K] extends "parked" ? K : never;
361
361
  }[RunRecord["status"]];
362
362
  /**
363
363
  * 一个状态词的类;**表里没有的词 ⇒ `undefined`**。
364
364
  *
365
- * 🔴 形参是 `string` 而不是 `RunRecord["status"]`(S-221):本函数的**全部工作**就是「这个词在不在表里」,
365
+ * 🔴 形参是 `string` 而不是 `RunRecord["status"]`([ref]):本函数的**全部工作**就是「这个词在不在表里」,
366
366
  * 把入参收成闭集等于在签名上宣称「传进来的一定是表内词」,而下一行的 `undefined` 臂正是为了不是的那些 ——
367
367
  * 签名与实现自相矛盾时,消费点只能靠 `as RunRecord["status"]` 硬转把窄读口(`{ status: string }`,
368
368
  * 三形 store 共同面)喂进来,而那正是本文件头注点名的 `rowToRun` 裸 cast 的同一条病。闭集词照样能传
369
369
  * (联合 ⊂ string),编译期的执法点在上面那张表的双向钉,不在这里。
370
370
  *
371
- * 导出面(S-221):`plugins/e2b-orphan-reclaim.ts` 的三臂判决(还能再动 / 终局 / 读不懂)需要的正是
371
+ * 导出面([ref]):`plugins/e2b-orphan-reclaim.ts` 的三臂判决(还能再动 / 终局 / 读不懂)需要的正是
372
372
  * 「类 + unknown」这一对,而不是三条 boolean 谓词各问一遍 —— 它此前因此自带了第二份词表。
373
373
  *
374
374
  * 🔴 查的是 **null 原型**的那只表,不是 `RUN_STATUS_CLASS` 本身(codex 对抗复审 r1 [high],亲验后修):
@@ -395,7 +395,7 @@ export declare function runStatusClassOf(status: string): RunStatusClass | undef
395
395
  */
396
396
  export declare function isTerminalRunStatus(status: RunRecord["status"]): boolean;
397
397
  /**
398
- * 「这一行的终局是**非成功**的吗」(S-213③ 的共享判据)——`failed` 与 `blocked` 两词。
398
+ * 「这一行的终局是**非成功**的吗」([ref]③ 的共享判据)——`failed` 与 `blocked` 两词。
399
399
  *
400
400
  * 🔴 它回答的问题与 {@link isTerminalRunStatus} **不同**:后者只问「还会不会再动」,本判据问「这次任务
401
401
  * 到底成没成」。凡是「这条 run 该不该在失败面上出声/离场」的判断都读这一条,不许再手抄
@@ -434,7 +434,7 @@ export declare function isParkedRunStatus(status: RunRecord["status"]): boolean;
434
434
  * 它不是「我知道它闲着」,所以不许铸出 `idle` 这个断言;
435
435
  * · 读不懂的词(滚动升级里新副本写入的新状态词经裸 cast 读到本进程)同判 —— 与
436
436
  * {@link isTerminalRunStatus} 族的保守方向一致。
437
- * · **缺席怎么渲染是 core 的辖域,本仓一个字都不复述**(S-514-JU:此处原写着「core 对缺席渲染成 `idle`」
437
+ * · **缺席怎么渲染是 core 的辖域,本仓一个字都不复述**([ref]-JU:此处原写着「core 对缺席渲染成 `idle`」
438
438
  * 并抄了当时 `list-agents-tool.js` 的旧三元 —— core 7.24.0 [ref] 把那一臂改成了一张 own-key 表 +
439
439
  * `unknown` 兜底,于是那句复述当天就成了假话,而它在本仓被抄了六处)。本表只负责**铸不铸键**;
440
440
  * 渲染词由**跑真 core 的黑盒**钉住(`test/peer-lane-e2e.test.ts` 的 G1 格),core 哪天再改那张表,
@@ -453,7 +453,7 @@ export declare const SESSION_TEMPO_BY_RUN_CLASS: {
453
453
  * 返回词缺席 ⇒ 调用方**不铸键**(不是铸 `idle`),理由逐字见上表头注。 */
454
454
  export declare function sessionTempoOfRunStatus(lastStatus: string): PeerSessionTempo | undefined;
455
455
  /**
456
- * 「**证得出**这条 run 活在别的副本上」——「他副本」那一句话的**唯一判据**(S-381 收编;S-430 迁居)。
456
+ * 「**证得出**这条 run 活在别的副本上」——「他副本」那一句话的**唯一判据**([ref] 收编;[ref] 迁居)。
457
457
  *
458
458
  * 成案:这个合取式此前在四处**逐字手抄**(`http/routes/runs.ts` 的 steer 臂与 interrupt 臂、同文件
459
459
  * `sendHandleMiss`、`http/routes/run-memory-capture.ts`),`POST /v1/sessions/:id/mcp/reconnect` 是第五处、`fleet/fleet-reconciler.ts` 是第六处 ——
@@ -466,7 +466,7 @@ export declare function sessionTempoOfRunStatus(lastStatus: string): PeerSession
466
466
  * `sendHandleMiss` 只对 `running` 行说这句话,而 steer 族在 park/终态两臂之后才走到这里 —— 各调用点
467
467
  * 的前置臂不同族,合进来会让某一处悄悄改判。
468
468
  *
469
- * 🔴 **为什么住在这里而不是 `http/route-ctx.ts`**(S-430):`src/fleet/fleet-reconciler.ts` 是第六个手抄点,
469
+ * 🔴 **为什么住在这里而不是 `http/route-ctx.ts`**([ref]):`src/fleet/fleet-reconciler.ts` 是第六个手抄点,
470
470
  * 而 `src/fleet/` 今天对 `src/http/` **零依赖**(边向恒是 http → fleet)。把消费方拉去 http 取一只纯谓词
471
471
  * 会凭空造一条反向装载边;而本文件正是 {@link RunRecord} 与它的兄弟谓词({@link isTerminalRunStatus} /
472
472
  * {@link isParkedRunStatus})的所在 —— 「关于 run 行的判词」本来就该在行的属主这里,http 与 fleet 都已经
@@ -492,7 +492,7 @@ export interface SessionSummary {
492
492
  * hop (`GET /v1/runs/:lastRunId/events`) when resuming a picked session, instead of a second lookup. */
493
493
  lastRunId: string | null;
494
494
  /** [ref]([ref]/[ref]):latest run 的 engine runId(`TaskResult.runId`,latest.result JSON 提取的
495
- * 零迁移路线 —— result 在终局与 park 时写、认领续跑即清空(S-173)⇒ 在跑 run 键诚实缺席);OMIT-when-absent,恒不铸 null。轴辨析与
495
+ * 零迁移路线 —— result 在终局与 park 时写、认领续跑即清空([ref])⇒ 在跑 run 键诚实缺席);OMIT-when-absent,恒不铸 null。轴辨析与
496
496
  * wire 半场见 `security.ts SessionListItem.lastTaskRunId`(同名同义)。 */
497
497
  lastTaskRunId?: string;
498
498
  /** The session's title: the user's (`patchSessionMeta`, unconditional; `null` clears it back to automatic) or the auto-titler's
@@ -504,7 +504,7 @@ export interface SessionSummary {
504
504
  pinned: boolean;
505
505
  }
506
506
  /**
507
- * S-1371 —— 会话**枚举面**读 run 账里「每会话的 run 投影」的窄读面:`runCount` / `lastStatus` / `lastRunId` / `lastTaskRunId` 四位,
507
+ * [ref] —— 会话**枚举面**读 run 账里「每会话的 run 投影」的窄读面:`runCount` / `lastStatus` / `lastRunId` / `lastTaskRunId` 四位,
508
508
  * 同一次读、同一条「最新一条」的口径。
509
509
  *
510
510
  * 为什么是 run 店自己的 `listSessions`、不另造一只读口:这四位在 SQL 双生里就是 `task_run` 的 `rn=1` JOIN(计数、最新一条的状态与 task_id、
@@ -521,7 +521,7 @@ export interface SessionRunRollupSource {
521
521
  }): Promise<ReadonlyArray<Pick<SessionSummary, "sessionId" | "runCount" | "lastStatus" | "lastRunId" | "lastTaskRunId">>>;
522
522
  }
523
523
  /**
524
- * S-297 —— 「这个会话**最近一条腿**是哪一条 run」的窄读面(`latestRunForSession` 的回值)。
524
+ * [ref] —— 「这个会话**最近一条腿**是哪一条 run」的窄读面(`latestRunForSession` 的回值)。
525
525
  *
526
526
  * 刻意**不是** {@link RunRecord}:那一形携 `result` 整只 blob,而本读面的三个消费点(run 身份 / 属主门 /
527
527
  * 排序口径的自证)一个都用不到它 —— 与 `listSessions` 只提标量 `lastTaskRunId` 而不拉 `result` 是同一条
@@ -31,7 +31,7 @@ import { type IndexSpec } from "./ensure-index.js";
31
31
  /**
32
32
  * 一条附件 meta 的**形属主**(整仓唯一那份键集)。
33
33
  *
34
- * 🔴 为什么是一只 schema 而不只是一个 interface(S-550 车③b):SQL 车道把这些字段拆成**标量列**,
34
+ * 🔴 为什么是一只 schema 而不只是一个 interface([ref] 车③b):SQL 车道把这些字段拆成**标量列**,
35
35
  * 形由 DDL 管;local 车道把整条记录**序列化成一个 JSON 档**(`attachments/<id>.json`),于是它需要一个
36
36
  * 运行期的形判据 —— 而那个判据必须与这里的键集是**同一份**(第二份键集分叉的那天 = 「写得进、读不出」)。
37
37
  * 所以类型从 schema 推导({@link TaskAttachmentRecord}),两者按构造不可能漂。
@@ -126,7 +126,7 @@ export declare function materializeAttachmentsInto(env: {
126
126
  }>;
127
127
  }, store: TaskAttachmentStore, sessionId: string): Promise<number>;
128
128
  export declare function ensureTiDBTaskAttachmentSchema(pool: Pool): Promise<void>;
129
- /** S-287:本 store 的索引**声明**(两方言共用一份)。PG 侧由下面的 `ensurePgTaskAttachmentSchema` 应用,MySQL 侧由 `tidb-pool.ts` 的中央 `ensureSchema` 应用(那里内联 `KEY` 已在 `CREATE TABLE` 里 ⇒ 新建库探到即零 DDL,存量库缺谁补谁)。加索引以外的 schema 变更仍归运维,见 `plugins/ensure-index.ts` 头注。 */
129
+ /** [ref]:本 store 的索引**声明**(两方言共用一份)。PG 侧由下面的 `ensurePgTaskAttachmentSchema` 应用,MySQL 侧由 `tidb-pool.ts` 的中央 `ensureSchema` 应用(那里内联 `KEY` 已在 `CREATE TABLE` 里 ⇒ 新建库探到即零 DDL,存量库缺谁补谁)。加索引以外的 schema 变更仍归运维,见 `plugins/ensure-index.ts` 头注。 */
130
130
  export declare const TASK_ATTACHMENT_INDEXES: readonly IndexSpec[];
131
131
  export declare function ensurePgTaskAttachmentSchema(q: PgQueryFn): Promise<void>;
132
132
  /** bytes → 4 MiB 块序列(共享切块器,两方言 + 完整性校验共用)。 */
@@ -27,7 +27,7 @@ export declare const TASK_LIST_ITEM_TABLE = "task_list_item";
27
27
  */
28
28
  export declare function taskListKeyFor(sessionId: string): string;
29
29
  /**
30
- * `task_list_item.item_json` 的**形读者**(S-550)。
30
+ * `task_list_item.item_json` 的**形读者**([ref])。
31
31
  *
32
32
  * 🔴 判据刻意只到「一只 JSON 对象 + 一把串 id」为止,**不复刻 core 的 `TaskListItem` 键表**:那张表的
33
33
  * 属主在 core(`tools/task-list.d.ts`),而 core 今天没有导出验证器 —— 在这里手写一份等价 schema 就是