@sema-agent/server 7.134.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 (458) hide show
  1. package/MIGRATION.md +134 -0
  2. package/USAGE.md +98 -30
  3. package/dist/adoption/plan.d.ts +1 -1
  4. package/dist/approval-ask-audit-store.d.ts +24 -24
  5. package/dist/approval-ask-machine.d.ts +2 -2
  6. package/dist/approval-card.d.ts +62 -150
  7. package/dist/approval-card.js +33 -51
  8. package/dist/approval-content-kind.d.ts +22 -5
  9. package/dist/approval-content-kind.js +8 -1
  10. package/dist/approval-deny-reasons.d.ts +1 -1
  11. package/dist/approval-gate-currency.d.ts +22 -3
  12. package/dist/approval-gate-currency.js +44 -18
  13. package/dist/approval-hmac.d.ts +7 -7
  14. package/dist/approval-policy-settlement.d.ts +2 -2
  15. package/dist/approval-reconciler.d.ts +3 -3
  16. package/dist/approval.d.ts +8 -8
  17. package/dist/approval.js +4 -2
  18. package/dist/auth-bridge.d.ts +1 -1
  19. package/dist/auto-mode-face.d.ts +4 -4
  20. package/dist/background-session-reap.d.ts +2 -2
  21. package/dist/bake-runner/main.d.ts +2 -2
  22. package/dist/bake-runner/runner.d.ts +4 -4
  23. package/dist/bench/s1/live-deps.d.ts +1 -1
  24. package/dist/bench/s1/run-firm.d.ts +1 -1
  25. package/dist/boot/coordinators.d.ts +2 -2
  26. package/dist/boot/coordinators.js +2 -2
  27. package/dist/boot/deferred-sandbox-path-env.d.ts +0 -6
  28. package/dist/boot/deferred-sandbox-path-env.js +0 -5
  29. package/dist/boot/engine-lease.d.ts +5 -5
  30. package/dist/boot/execution-env.d.ts +16 -15
  31. package/dist/boot/execution-env.js +19 -21
  32. package/dist/boot/fatal-exit.d.ts +2 -2
  33. package/dist/boot/late-binds.d.ts +1 -1
  34. package/dist/boot/leader.d.ts +1 -1
  35. package/dist/boot/memory-boundary.d.ts +2 -2
  36. package/dist/boot/memory-consolidation.d.ts +15 -15
  37. package/dist/boot/parked-revive-gate.d.ts +3 -3
  38. package/dist/boot/parked-revive-gate.js +3 -2
  39. package/dist/boot/reapers.d.ts +4 -4
  40. package/dist/boot/resolve-spec.d.ts +1 -1
  41. package/dist/boot/resolve-spec.js +28 -24
  42. package/dist/boot/runner-deps.d.ts +11 -11
  43. package/dist/boot/runner-deps.js +3 -2
  44. package/dist/boot/session-faces.d.ts +3 -3
  45. package/dist/boot/session-faces.js +11 -30
  46. package/dist/boot/shutdown.d.ts +5 -5
  47. package/dist/boot/side-query-lane.d.ts +2 -2
  48. package/dist/boot/stage-05-execution-env.js +4 -4
  49. package/dist/boot/stage-06-runners.js +0 -2
  50. package/dist/boot/stores.js +2 -1
  51. package/dist/boot/web-admin.d.ts +17 -17
  52. package/dist/boot/web-admin.js +5 -10
  53. package/dist/boot/workflow-orchestration.js +2 -9
  54. package/dist/brain.d.ts +11 -11
  55. package/dist/budget.d.ts +4 -4
  56. package/dist/capabilities/approvals-push.d.ts +4 -4
  57. package/dist/capabilities/builtin-tools.d.ts +5 -5
  58. package/dist/capabilities/center-plugins.d.ts +5 -5
  59. package/dist/capabilities/center-plugins.js +1 -1
  60. package/dist/capabilities/center-prompts.d.ts +1 -1
  61. package/dist/capabilities/center-wiring.d.ts +1 -1
  62. package/dist/capabilities/composite-members.d.ts +1 -1
  63. package/dist/capabilities/execution-lane.d.ts +5 -5
  64. package/dist/capabilities/execution-lane.js +2 -2
  65. package/dist/capabilities/hands-lane.d.ts +5 -5
  66. package/dist/capabilities/mcp-probe.d.ts +10 -7
  67. package/dist/capabilities/sandbox-file-send.d.ts +1 -18
  68. package/dist/capabilities/sandbox-file-send.js +0 -7
  69. package/dist/capabilities/scenarios.d.ts +28 -10
  70. package/dist/capabilities/scenarios.js +15 -5
  71. package/dist/capabilities/send-user-file-tool.d.ts +1 -1
  72. package/dist/capabilities/skills.d.ts +31 -12
  73. package/dist/capabilities/skills.js +23 -17
  74. package/dist/capabilities/tool-defer.d.ts +1 -1
  75. package/dist/capability-facts.d.ts +26 -25
  76. package/dist/capability-facts.js +14 -16
  77. package/dist/center-config-tier.d.ts +1 -1
  78. package/dist/center-credential.d.ts +4 -4
  79. package/dist/checkpoint-identity.d.ts +5 -0
  80. package/dist/checkpoint-identity.js +14 -0
  81. package/dist/config-catalog.d.ts +12 -12
  82. package/dist/config-invariants.d.ts +4 -4
  83. package/dist/config-invariants.js +3 -2
  84. package/dist/config-lkg.d.ts +1 -1
  85. package/dist/config-provider.d.ts +13 -13
  86. package/dist/config-provider.js +2 -1
  87. package/dist/config-types.d.ts +83 -83
  88. package/dist/config.d.ts +26 -24
  89. package/dist/config.js +12 -10
  90. package/dist/cross-session-settings.d.ts +1 -1
  91. package/dist/delegated-session-owner.d.ts +16 -13
  92. package/dist/delegated-session-owner.js +9 -10
  93. package/dist/deployment-governance.d.ts +16 -16
  94. package/dist/deployment-shape.d.ts +127 -0
  95. package/dist/deployment-shape.js +72 -0
  96. package/dist/device-store.d.ts +1 -1
  97. package/dist/device-ws-hub.d.ts +1 -1
  98. package/dist/egress-redirect.d.ts +1 -1
  99. package/dist/entry-mode-clamp-notice.d.ts +2 -2
  100. package/dist/env-facts.d.ts +10 -9
  101. package/dist/env-facts.js +1 -1
  102. package/dist/env-name-allowlist-knobs.d.ts +5 -5
  103. package/dist/exec-bounds.d.ts +2 -2
  104. package/dist/execution-lane-caps.d.ts +31 -43
  105. package/dist/execution-lane-caps.js +0 -13
  106. package/dist/file-history-capture.d.ts +9 -9
  107. package/dist/file-history-disclosure.d.ts +23 -11
  108. package/dist/file-history-disclosure.js +7 -12
  109. package/dist/fleet/drain-entry.d.ts +2 -2
  110. package/dist/fleet/fleet-bus.d.ts +22 -14
  111. package/dist/fleet/fleet-bus.js +5 -5
  112. package/dist/fleet/fleet-reconciler.d.ts +9 -9
  113. package/dist/fleet/subagent-tail-bus.d.ts +4 -4
  114. package/dist/fleet-client.d.ts +13 -13
  115. package/dist/fleet-lease.d.ts +16 -16
  116. package/dist/governance-http-status.d.ts +2 -2
  117. package/dist/hooks/hook-llm.d.ts +7 -7
  118. package/dist/hooks/hook-runner.d.ts +57 -30
  119. package/dist/hooks/hook-runner.js +36 -18
  120. package/dist/host-decision.d.ts +5 -5
  121. package/dist/host-lsp-manager.d.ts +5 -5
  122. package/dist/hosted-posture.d.ts +23 -13
  123. package/dist/hosted-posture.js +4 -9
  124. package/dist/http/admission.d.ts +2 -2
  125. package/dist/http/admission.js +20 -5
  126. package/dist/http/approval-sweeps.d.ts +1 -1
  127. package/dist/http/approval-sweeps.js +2 -1
  128. package/dist/http/checkpoint-ctx.d.ts +39 -13
  129. package/dist/http/checkpoint-ctx.js +74 -35
  130. package/dist/http/dispatch.d.ts +3 -3
  131. package/dist/http/durable-run-leg.js +4 -3
  132. package/dist/http/idempotency.d.ts +2 -2
  133. package/dist/http/mcp-dial-deadline.d.ts +7 -5
  134. package/dist/http/memory-compliance-failure-reply.d.ts +4 -4
  135. package/dist/http/owner-access.d.ts +4 -6
  136. package/dist/http/owner-access.js +1 -1
  137. package/dist/http/principal-gate.d.ts +7 -7
  138. package/dist/http/principal-gate.js +3 -2
  139. package/dist/http/readiness.d.ts +1 -1
  140. package/dist/http/request-guards.d.ts +4 -4
  141. package/dist/http/request-guards.js +2 -1
  142. package/dist/http/resume-ctx-read.d.ts +7 -7
  143. package/dist/http/resume-ctx-read.js +1 -1
  144. package/dist/http/resume-legs.d.ts +3 -3
  145. package/dist/http/resume-legs.js +11 -8
  146. package/dist/http/route-ctx.d.ts +29 -29
  147. package/dist/http/route-table.d.ts +9 -9
  148. package/dist/http/routes/agents-roster.d.ts +1 -1
  149. package/dist/http/routes/approvals-assistant.d.ts +5 -5
  150. package/dist/http/routes/approvals-assistant.js +55 -15
  151. package/dist/http/routes/background.d.ts +3 -3
  152. package/dist/http/routes/background.js +2 -2
  153. package/dist/http/routes/capabilities.d.ts +1 -1
  154. package/dist/http/routes/capabilities.js +16 -8
  155. package/dist/http/routes/config-catalog.d.ts +1 -1
  156. package/dist/http/routes/devices.d.ts +1 -1
  157. package/dist/http/routes/diagnostics.d.ts +3 -3
  158. package/dist/http/routes/fleet.d.ts +1 -1
  159. package/dist/http/routes/fleet.js +2 -1
  160. package/dist/http/routes/mcp-reconnect.d.ts +4 -4
  161. package/dist/http/routes/mcp-reconnect.js +3 -3
  162. package/dist/http/routes/memory-consolidation.d.ts +1 -1
  163. package/dist/http/routes/notify-wake.d.ts +1 -1
  164. package/dist/http/routes/notify-wake.js +2 -2
  165. package/dist/http/routes/rules.d.ts +1 -1
  166. package/dist/http/routes/runs.js +22 -10
  167. package/dist/http/routes/session-sync.d.ts +1 -1
  168. package/dist/http/routes/session-sync.js +73 -44
  169. package/dist/http/routes/sessions-list.js +1 -1
  170. package/dist/http/routes/sessions.js +30 -44
  171. package/dist/http/routes/tasks.d.ts +1 -1
  172. package/dist/http/routes/trace-usage.d.ts +1 -1
  173. package/dist/http/routes/workflows.d.ts +3 -0
  174. package/dist/http/routes/workflows.js +31 -28
  175. package/dist/http/send.d.ts +5 -5
  176. package/dist/http/server.d.ts +34 -34
  177. package/dist/http/session-inherit-env.d.ts +3 -3
  178. package/dist/http/sse-lifecycle.d.ts +1 -1
  179. package/dist/http/sse-log.d.ts +2 -2
  180. package/dist/http/submit-ctx.js +1 -1
  181. package/dist/http/sync-submit-body.d.ts +1 -1
  182. package/dist/http/verify-rounds.d.ts +1 -1
  183. package/dist/http/wire-types.d.ts +28 -21
  184. package/dist/instruction-source-notice.d.ts +2 -2
  185. package/dist/key-resolver.d.ts +3 -3
  186. package/dist/lane-home-probe.d.ts +1 -1
  187. package/dist/leader/diffout.d.ts +1 -1
  188. package/dist/leader/diffup.d.ts +2 -2
  189. package/dist/leader/endpoint.d.ts +1 -1
  190. package/dist/leader/fanout.d.ts +1 -1
  191. package/dist/leader/leader.d.ts +4 -4
  192. package/dist/leader/merge.d.ts +3 -3
  193. package/dist/leader/repair-wire.d.ts +1 -1
  194. package/dist/leader/wire.d.ts +6 -6
  195. package/dist/list-entry-display.d.ts +1 -1
  196. package/dist/lsp-evict.d.ts +1 -1
  197. package/dist/mcp-assertion-header.d.ts +1 -1
  198. package/dist/memory-layer-legacy-lock.d.ts +1 -1
  199. package/dist/memory-operator-faces.d.ts +1 -1
  200. package/dist/memory-posture.js +4 -2
  201. package/dist/memory-project-layer.d.ts +1 -1
  202. package/dist/memory-scope.d.ts +19 -19
  203. package/dist/memory-store-refusal.d.ts +4 -4
  204. package/dist/model-entry-headers.d.ts +2 -2
  205. package/dist/model-entry-refusal.d.ts +17 -17
  206. package/dist/model-provider.d.ts +10 -10
  207. package/dist/model-reach-scope.d.ts +1 -1
  208. package/dist/model-route-endpoint.d.ts +6 -6
  209. package/dist/model-route-url.d.ts +5 -5
  210. package/dist/model-select.d.ts +15 -6
  211. package/dist/model-select.js +5 -0
  212. package/dist/model-unreachable-notice.d.ts +3 -3
  213. package/dist/namespaced-rule-name.d.ts +15 -5
  214. package/dist/namespaced-rule-name.js +3 -2
  215. package/dist/observability/corrupt-read-seat.d.ts +9 -9
  216. package/dist/observability/cost-taxonomy.d.ts +1 -1
  217. package/dist/observability/err-text.d.ts +1 -1
  218. package/dist/observability/fail-open.d.ts +12 -8
  219. package/dist/observability/fail-open.js +12 -8
  220. package/dist/observability/metrics.d.ts +3 -3
  221. package/dist/observability/run-terminal.d.ts +36 -36
  222. package/dist/observability/secret-env-scrub.d.ts +3 -3
  223. package/dist/observability/tool-trace.d.ts +1 -1
  224. package/dist/operator-ask.d.ts +4 -4
  225. package/dist/orchestration/workflow-agent-session-index.d.ts +3 -3
  226. package/dist/orchestration/workflow-completion-inbox.d.ts +20 -5
  227. package/dist/orchestration/workflow-completion-inbox.js +29 -7
  228. package/dist/orchestration/workflow-notify-journal.d.ts +43 -19
  229. package/dist/orchestration/workflow-notify-journal.js +17 -0
  230. package/dist/outbound-dispatcher.d.ts +4 -4
  231. package/dist/parent-watch.d.ts +4 -4
  232. package/dist/parked-decide.d.ts +16 -15
  233. package/dist/parked-decide.js +5 -4
  234. package/dist/parked-revive-surface.d.ts +7 -7
  235. package/dist/parked-revive-surface.js +2 -3
  236. package/dist/peer-directory.d.ts +3 -3
  237. package/dist/peer-directory.js +1 -1
  238. package/dist/permission-rule-list.d.ts +10 -1
  239. package/dist/permission-rule-list.js +7 -5
  240. package/dist/permission-rule-vocab.d.ts +2 -2
  241. package/dist/plugins/adoption-log-sql.d.ts +1 -1
  242. package/dist/plugins/approval-ask-store-file.d.ts +8 -1
  243. package/dist/plugins/approval-ask-store-file.js +6 -3
  244. package/dist/plugins/approval-ask-store-memory.d.ts +11 -7
  245. package/dist/plugins/approval-ask-store-memory.js +11 -7
  246. package/dist/plugins/approval-ask-store-sql.d.ts +34 -15
  247. package/dist/plugins/approval-ask-store-sql.js +18 -5
  248. package/dist/plugins/approval-exemption-store.d.ts +3 -3
  249. package/dist/plugins/approval-nonce-store.d.ts +3 -3
  250. package/dist/plugins/background-agent-store-sql.d.ts +1 -1
  251. package/dist/plugins/background-shell-support.d.ts +2 -2
  252. package/dist/plugins/blob-backend.d.ts +1 -1
  253. package/dist/plugins/caching-session-store.d.ts +23 -32
  254. package/dist/plugins/caching-session-store.js +5 -17
  255. package/dist/plugins/checkpoint-index-columns.d.ts +81 -0
  256. package/dist/plugins/checkpoint-index-columns.js +62 -0
  257. package/dist/plugins/checkpoint-store-sql.d.ts +44 -66
  258. package/dist/plugins/checkpoint-store-sql.js +55 -102
  259. package/dist/plugins/device-store-sql.d.ts +7 -6
  260. package/dist/plugins/e2b-orphan-reclaim.d.ts +1 -1
  261. package/dist/plugins/ensure-schema-lock-policy.d.ts +1 -1
  262. package/dist/plugins/file-history-store-sql.d.ts +9 -7
  263. package/dist/plugins/file-history-store-sql.js +27 -15
  264. package/dist/plugins/file-run-store.d.ts +8 -8
  265. package/dist/plugins/fork-routing-session-store.d.ts +2 -2
  266. package/dist/plugins/fork-routing-session-store.js +1 -1
  267. package/dist/plugins/host-platform.d.ts +10 -10
  268. package/dist/plugins/image-bake-store-sql.d.ts +1 -1
  269. package/dist/plugins/image-index-sql.d.ts +1 -1
  270. package/dist/plugins/leader-run-store-sql.d.ts +1 -1
  271. package/dist/plugins/local-checkpoint-store.d.ts +10 -10
  272. package/dist/plugins/local-checkpoint-store.js +3 -4
  273. package/dist/plugins/local-session-store.d.ts +34 -38
  274. package/dist/plugins/local-session-store.js +20 -39
  275. package/dist/plugins/local-session-window.d.ts +1 -1
  276. package/dist/plugins/mailbox-store-sql.d.ts +2 -2
  277. package/dist/plugins/memory-engine-pg.d.ts +1 -1
  278. package/dist/plugins/memory-run-store.d.ts +4 -4
  279. package/dist/plugins/memory-sync-store-pg.d.ts +3 -3
  280. package/dist/plugins/one-time-migrations.d.ts +66 -40
  281. package/dist/plugins/one-time-migrations.js +115 -34
  282. package/dist/plugins/outcome-ledger-sql.d.ts +1 -1
  283. package/dist/plugins/park-commit-watch.d.ts +3 -3
  284. package/dist/plugins/permission-rule-store-file.d.ts +5 -5
  285. package/dist/plugins/permission-rule-store-file.js +12 -19
  286. package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
  287. package/dist/plugins/permission-rule-store-sql.js +67 -24
  288. package/dist/plugins/pg-cost-quota.d.ts +1 -1
  289. package/dist/plugins/pg-pool.d.ts +2 -2
  290. package/dist/plugins/pg-pool.js +5 -2
  291. package/dist/plugins/pg-rate-limiter.d.ts +1 -1
  292. package/dist/plugins/pg-session-storage.d.ts +8 -20
  293. package/dist/plugins/pg-session-storage.js +14 -27
  294. package/dist/plugins/remote-env-adb.d.ts +10 -10
  295. package/dist/plugins/remote-env-device.d.ts +10 -9
  296. package/dist/plugins/remote-env-device.js +6 -2
  297. package/dist/plugins/remote-env-e2b.d.ts +3 -3
  298. package/dist/plugins/remote-env-host.d.ts +16 -16
  299. package/dist/plugins/remote-env-k8s.d.ts +8 -8
  300. package/dist/plugins/remote-env-local-docker.d.ts +2 -2
  301. package/dist/plugins/remote-env-ssh.d.ts +4 -4
  302. package/dist/plugins/remote-scratchpad.d.ts +2 -3
  303. package/dist/plugins/remote-scratchpad.js +0 -4
  304. package/dist/plugins/remote-shell.d.ts +6 -6
  305. package/dist/plugins/retention-lane-store-sql.d.ts +4 -4
  306. package/dist/plugins/retention-store-sql.d.ts +4 -4
  307. package/dist/plugins/roster-store-sql.d.ts +1 -1
  308. package/dist/plugins/run-store-sql.d.ts +8 -8
  309. package/dist/plugins/schema-consistency.d.ts +2 -2
  310. package/dist/plugins/schema-ensure-legs.d.ts +3 -3
  311. package/dist/plugins/schema-indexes.d.ts +1 -1
  312. package/dist/plugins/schema-live-columns.d.ts +1 -1
  313. package/dist/plugins/session-event-payload.d.ts +4 -4
  314. package/dist/plugins/session-fork.d.ts +34 -0
  315. package/dist/plugins/session-fork.js +29 -0
  316. package/dist/plugins/session-ownership.js +1 -1
  317. package/dist/plugins/session-placement.d.ts +1 -1
  318. package/dist/plugins/session-policy-store-sql.d.ts +12 -12
  319. package/dist/plugins/session-store.d.ts +2 -2
  320. package/dist/plugins/session-store.js +2 -2
  321. package/dist/plugins/shared-memory-store-sql.d.ts +2 -2
  322. package/dist/plugins/sql-driver.d.ts +8 -8
  323. package/dist/plugins/sql-errors.d.ts +1 -1
  324. package/dist/plugins/sql-json-column.d.ts +21 -21
  325. package/dist/plugins/sql-row-helpers.d.ts +2 -2
  326. package/dist/plugins/store-backend.d.ts +17 -16
  327. package/dist/plugins/store-backend.js +3 -3
  328. package/dist/plugins/store-contracts.d.ts +21 -21
  329. package/dist/plugins/task-attachment-store.d.ts +2 -2
  330. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  331. package/dist/plugins/tidb-pool.d.ts +2 -2
  332. package/dist/plugins/tidb-pool.js +9 -2
  333. package/dist/plugins/tidb-session-store.d.ts +16 -26
  334. package/dist/plugins/tidb-session-store.js +15 -27
  335. package/dist/plugins/tool-result-store-sql.d.ts +1 -1
  336. package/dist/plugins/usage-window-store-sql.d.ts +3 -3
  337. package/dist/plugins/user-input-ledger-file.d.ts +1 -1
  338. package/dist/plugins/user-input-ledger-sql.d.ts +3 -3
  339. package/dist/plugins/web-search.d.ts +19 -5
  340. package/dist/plugins/web-search.js +19 -4
  341. package/dist/{orchestration/workflow-journal-entry.d.ts → plugins/workflow-journal-payload.d.ts} +23 -32
  342. package/dist/plugins/workflow-journal-payload.js +32 -0
  343. package/dist/plugins/workflow-journal-store-sql.d.ts +28 -14
  344. package/dist/plugins/workflow-journal-store-sql.js +34 -15
  345. package/dist/plugins/workflow-run-store-sql.d.ts +4 -4
  346. package/dist/posture-source.d.ts +11 -11
  347. package/dist/principal-jwt.d.ts +6 -6
  348. package/dist/project-identity.d.ts +3 -3
  349. package/dist/project-memory.d.ts +4 -4
  350. package/dist/read-face-posture.d.ts +7 -7
  351. package/dist/request-key-closure.d.ts +1 -1
  352. package/dist/request-key-closure.js +1 -1
  353. package/dist/request-value-closure.d.ts +15 -8
  354. package/dist/request-value-closure.js +2 -0
  355. package/dist/router/route-orchestration.d.ts +11 -16
  356. package/dist/router/route-orchestration.js +2 -12
  357. package/dist/rule-entry-list.d.ts +8 -7
  358. package/dist/rule-entry-list.js +2 -9
  359. package/dist/rules-consent.d.ts +6 -6
  360. package/dist/rules-consent.js +2 -0
  361. package/dist/run-cancel-context.d.ts +5 -5
  362. package/dist/run-local.d.ts +10 -10
  363. package/dist/runs.d.ts +13 -11
  364. package/dist/runs.js +15 -1
  365. package/dist/runtime-caps-resolver.d.ts +6 -6
  366. package/dist/runtime-governance.d.ts +9 -9
  367. package/dist/sandbox-pkg-source.d.ts +9 -31
  368. package/dist/sandbox-pkg-source.js +14 -8
  369. package/dist/sealed-key.d.ts +3 -3
  370. package/dist/security.d.ts +23 -26
  371. package/dist/security.js +12 -9
  372. package/dist/server-secret-env.d.ts +10 -10
  373. package/dist/session-children-retire.d.ts +1 -1
  374. package/dist/session-error-wire.d.ts +7 -7
  375. package/dist/session-incarnation.d.ts +52 -35
  376. package/dist/session-incarnation.js +23 -8
  377. package/dist/session-policy-wire.d.ts +27 -5
  378. package/dist/session-policy-wire.js +15 -1
  379. package/dist/session-records-skipped-notice.d.ts +1 -1
  380. package/dist/session-sync-kernel.d.ts +4 -4
  381. package/dist/session-sync.d.ts +49 -6
  382. package/dist/session-sync.js +52 -10
  383. package/dist/session-titler.d.ts +7 -6
  384. package/dist/session-titler.js +8 -13
  385. package/dist/session-watch.d.ts +3 -3
  386. package/dist/session-watch.js +4 -4
  387. package/dist/sighup-idle.d.ts +2 -2
  388. package/dist/spec-fields.d.ts +4 -4
  389. package/dist/sql-engine-posture.d.ts +3 -3
  390. package/dist/store-posture.d.ts +2 -2
  391. package/dist/stored-request-tool-axes-m19.d.ts +1 -1
  392. package/dist/task-a2a.d.ts +3 -1
  393. package/dist/task-a2a.js +34 -2
  394. package/dist/task-cwd.d.ts +7 -88
  395. package/dist/task-cwd.js +2 -15
  396. package/dist/task-mcp.d.ts +12 -8
  397. package/dist/task-mcp.js +19 -4
  398. package/dist/task-settings.d.ts +30 -18
  399. package/dist/task-settings.js +33 -3
  400. package/dist/task-workflow.d.ts +0 -24
  401. package/dist/task-workflow.js +2 -1
  402. package/dist/terminal.d.ts +5 -5
  403. package/dist/tighten-only-seats.d.ts +7 -6
  404. package/dist/tighten-only-seats.js +1 -1
  405. package/dist/tool-approval.d.ts +143 -197
  406. package/dist/tool-approval.js +13 -28
  407. package/dist/tool-rule-names.d.ts +2 -2
  408. package/dist/trace/core-keyset-guard.d.ts +12 -7
  409. package/dist/trace/engine-notice-wire.d.ts +5 -5
  410. package/dist/trace/engine-notice-wire.js +1 -0
  411. package/dist/trace/exit-seat.d.ts +31 -4
  412. package/dist/trace/exit-seat.js +41 -63
  413. package/dist/trace/ledger-events.d.ts +3 -3
  414. package/dist/trace/ledger-sink.d.ts +1 -1
  415. package/dist/trace/model-segment.d.ts +3 -3
  416. package/dist/trace/project.d.ts +47 -45
  417. package/dist/trace/project.js +33 -1
  418. package/dist/trace/redact.d.ts +44 -30
  419. package/dist/trace/redact.js +191 -89
  420. package/dist/trace/self-minted-wire.d.ts +35 -14
  421. package/dist/trace/self-minted-wire.js +8 -0
  422. package/dist/trace/sema-provenance.d.ts +1 -1
  423. package/dist/trace/task-notification-facets.d.ts +4 -4
  424. package/dist/trace/wire-projection-faces.d.ts +3 -3
  425. package/dist/trace/wire-projection-faces.js +1 -1
  426. package/dist/unattended-permission-mode.d.ts +5 -5
  427. package/dist/url-credential.d.ts +52 -0
  428. package/dist/url-credential.js +49 -0
  429. package/dist/url-refusal.d.ts +6 -2
  430. package/dist/url-refusal.js +8 -1
  431. package/dist/usage-analytics.d.ts +2 -2
  432. package/dist/user-input-ledger.d.ts +23 -23
  433. package/dist/web-admin-client/apply-effective.d.ts +5 -5
  434. package/dist/web-admin-client/apply-effective.js +2 -1
  435. package/dist/web-admin-client/apply-ledger.d.ts +2 -2
  436. package/dist/web-admin-client/center-request.d.ts +2 -2
  437. package/dist/web-admin-client/facade.d.ts +5 -5
  438. package/dist/web-admin-client/facade.js +1 -1
  439. package/dist/web-admin-client/hot-keys-registry.d.ts +2 -2
  440. package/dist/web-admin-client/http-client.d.ts +4 -4
  441. package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
  442. package/dist/web-admin-client/pull-state.d.ts +1 -1
  443. package/dist/web-admin-client/read-face.d.ts +2 -2
  444. package/dist/web-admin-client/read-warnings.d.ts +5 -5
  445. package/dist/web-admin-client/restart-signal.d.ts +6 -6
  446. package/dist/web-admin-client/skills-mcp.d.ts +28 -3
  447. package/dist/web-admin-client/skills-mcp.js +29 -1
  448. package/dist/web-admin-client/types.d.ts +16 -9
  449. package/dist/workspace-space.d.ts +5 -3
  450. package/dist/write-protection.d.ts +2 -2
  451. package/package.json +4 -3
  452. package/scripts/drain-check-local.mjs +2 -1
  453. package/scripts/drain-check.mysql.sql +4 -2
  454. package/scripts/drain-check.pg.sql +4 -2
  455. package/skills/loop.md +1 -1
  456. package/dist/http/run-declared-families.d.ts +0 -16
  457. package/dist/http/run-declared-families.js +0 -12
  458. package/dist/orchestration/workflow-journal-entry.js +0 -27
@@ -8,10 +8,10 @@
8
8
  *
9
9
  * 并发正确性(本 store 的靶心;两副本同 key 并发 charge 绝不能丢账——丢账方向=治理窗漏放):
10
10
  * - **ensure-first + 行锁**(mailbox twin 正字先例,[ref] 复审靶1):事务内先幂等建空行
11
- * (形 A,S-127:MySQL `ON DUPLICATE KEY UPDATE <pk> = <pk>` / PG `ON CONFLICT DO NOTHING`)⇒
11
+ * (形 A,[ref]:MySQL `ON DUPLICATE KEY UPDATE <pk> = <pk>` / PG `ON CONFLICT DO NOTHING`)⇒
12
12
  * `SELECT … FOR UPDATE` 时行恒在,「无行 FOR UPDATE + INSERT」的并发死锁/dup 撞车形整个消掉。
13
13
  * MySQL 侧动词**不能**是 `INSERT IGNORE`:InnoDB 对重复键的 IGNORE 取 S 锁,随后的 FOR UPDATE 要升 X,
14
- * 两个并发 charge 各持一把 S 互等 ⇒ ER_LOCK_DEADLOCK(B-013);ON DUPLICATE 的重复键取的就是 X。
14
+ * 两个并发 charge 各持一把 S 互等 ⇒ ER_LOCK_DEADLOCK([ref]);ON DUPLICATE 的重复键取的就是 X。
15
15
  * - charge 频率低(core 只在任务进场/turn 边界/收尾 delta 提交),悲观锁简单正确,不用乐观 CAS。
16
16
  * - `read` 无锁单 SELECT(readUsageRecord 纯函数);行缺席 = EMPTY_USAGE_WINDOW_RECORD。
17
17
  * - record JSON 坏形(手工污染)= **fail-loud throw**:治理窗算错=计费面撒谎,不 fail-open。
@@ -29,7 +29,7 @@ import type { UsageWindow, UsageWindowReading, UsageWindowRecord, UsageWindowSto
29
29
  import { type JsonColumnShape } from "./sql-json-column.js";
30
30
  export declare const USAGE_WINDOW_TABLE = "usage_window";
31
31
  /**
32
- * `usage_window.record` 的**形读者**(S-550 车③a:本店既有的那一份深度判据逐字搬进来,一个字没改判)。
32
+ * `usage_window.record` 的**形读者**([ref] 车③a:本店既有的那一份深度判据逐字搬进来,一个字没改判)。
33
33
  *
34
34
  * 判据深到内层元素:非数值 tokens 参与累加会得到 `"0oops"` ⇒ `exhausted:false` ⇒ **超额账户被判未耗尽**
35
35
  * (与 core `FileUsageWindowStore` 的 validateSlots/validateBuckets 同轴)。
@@ -15,7 +15,7 @@ export declare class MemoryUserInputLedgerStore implements UserInputLedgerStore
15
15
  listOpen(after?: OpenScanCursor, limit?: number): Promise<OpenScanPage>;
16
16
  listCrashed(sessionId: string): Promise<UserInputAcceptance[]>;
17
17
  listUnannounced(sessionId: string, limit: number): Promise<UserInputAcceptance[]>;
18
- /** S-965:会话树删除 = 一行会话级墓碑(守卫:该会话此刻有行 ⇒ 落;否则零写、回 0)。写抛 ⇒ 原样抛(协调器据此不删会话本体)。 */
18
+ /** [ref]:会话树删除 = 一行会话级墓碑(守卫:该会话此刻有行 ⇒ 落;否则零写、回 0)。写抛 ⇒ 原样抛(协调器据此不删会话本体)。 */
19
19
  deleteBySession(sessionId: string): Promise<number>;
20
20
  }
21
21
  /** local 车道(File)孪生。 */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * S-928 用户输入受理账本的 **SQL** 孪生(单文件双方言,[ref] A12 收拢形;两条语句并排写死,方言差异显式)。
2
+ * [ref] 用户输入受理账本的 **SQL** 孪生(单文件双方言,[ref] A12 收拢形;两条语句并排写死,方言差异显式)。
3
3
  * 语义属主 = `src/user-input-ledger.ts`;File / Memory 两只在 `user-input-ledger-file.ts`。四只孪生吃同一组试剂盒断言
4
4
  * (`test/helpers/user-input-ledger-kit.ts`;本孪生的真双库腿在 `test/store-contract-kit-db-integration.test.ts`)。
5
5
  *
@@ -13,12 +13,12 @@
13
13
  * 无 owner / principal / scope 列(行随它挂靠的会话走 —— 收编形Ⅲ);`writer` 是受理进程的 `instanceId`(随进程消亡,不是租户轴)。
14
14
  * 行里不存输入正文(只有身份与时刻)。
15
15
  *
16
- * ## 会话树删除(S-965)
16
+ * ## 会话树删除([ref])
17
17
  * `deleteBySession` = `DELETE … WHERE session_id = ?`(真删行;File 孪生是一行会话级墓碑,同义)。两条删会话树的级联各有一臂:在线删除协调器
18
18
  * 经本动词;托管留存的事务化孪生(`retention-store-sql.ts` `purgeSessionTrees` ④)在**自己的事务**里对本表发同一只谓词(`session_id` 单键,
19
19
  * 多值集合按方言)—— 它不调店,理由见该文件顶注的布局裁定(一个事务 ⇒ 一条连接 ⇒ 一个属主)。谓词走 `(session_id, state, accepted_at_ms)` 索引的前缀。
20
20
  *
21
- * ## 读不出的行(S-969 L6):逐行跳过,游标按原始行推进
21
+ * ## 读不出的行([ref] L6):逐行跳过,游标按原始行推进
22
22
  * 三只读口都按 `state` 列取行(`= 'open'` / `= 'converged'`),所以 `state` 词表外的行任何读口都取不到;被取到的行上读不出的列 —— `input_kind`
23
23
  * 词表外(新版本写的输入族:滚动发布 / 回滚的混版窗)、收敛行缺 `state_at_ms` —— 由 {@link readRows} 逐行跳过 + 计 F 类 tag
24
24
  * `server.user-input-ledger.corrupt-record-skipped`(File 孪生重放坏行的同一只登记座),其余行照交。修前一行读不出 ⇒ 整页抛:收敛断点不前进
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Multi-provider, picked by `WEB_SEARCH_PROVIDER`:
7
7
  * - `brave` — Brave Web Search API (GET, `X-Subscription-Token` header); with `WEB_SEARCH_ENDPOINT` set to a
8
- * Brave-compatible gateway's full search URL (e.g. a self-hosted Nólë gateway, S-669) the same leg
8
+ * Brave-compatible gateway's full search URL (e.g. a self-hosted Nólë gateway, [ref]) the same leg
9
9
  * serves that backend — no new provider word, `capabilities.webSearch.backend` still reads `brave`
10
10
  * - `tavily` — Tavily Search API (POST, `Authorization: Bearer`, native include/exclude_domains)
11
11
  * - `searxng` — a self-hosted SearXNG instance (GET `?format=json`, no auth)
@@ -54,6 +54,7 @@
54
54
  * 验证搜索配对不对。挂哪儿(boot 期一次性 warn / `/health` 子字段 / 显式端点)未定 ——
55
55
  * 注意 boot 期探活会给每次启动加一次出网,多租/离线部署要能关。
56
56
  */
57
+ import { type UrlCredentialFacts } from "../url-credential.js";
57
58
  /**
58
59
  * Search providers this backend speaks —— **词表的唯一属主**(运行期与类型同一份)。
59
60
  * Absent `WEB_SEARCH_PROVIDER` ⇒ no backend ⇒ WebSearch is not assembled.
@@ -69,7 +70,7 @@
69
70
  export declare const WEB_SEARCH_PROVIDERS: readonly ["brave", "tavily", "searxng"];
70
71
  export type WebSearchProvider = (typeof WEB_SEARCH_PROVIDERS)[number];
71
72
  /**
72
- * S-382:`GET /v1/capabilities` 的 `webSearch` 位 —— **部署默认后端**的闭集自述。
73
+ * [ref]:`GET /v1/capabilities` 的 `webSearch` 位 —— **部署默认后端**的闭集自述。
73
74
  *
74
75
  * ## 病
75
76
  * 「这台 worker 的搜索走哪只后端」此前只在 operator 面可知(`GET /v1/config/catalog` 的
@@ -159,7 +160,7 @@ export declare function setWebSearchBadPayloadObserver(fn: ((provider: string) =
159
160
  /**
160
161
  * Build the `WebSearchConfig` (a `search` fn + `maxResults`) for `assembleFullBodyTools({ webSearch })`. The API key
161
162
  * stays captured in this closure — it is never surfaced to the model or the tool args. Every error a leg throws leaves
162
- * through {@link redactedBackendFailure} (S-716 ③).
163
+ * through {@link redactedBackendFailure} ([ref] ③).
163
164
  */
164
165
  export declare function createWebSearchBackend(cfg: WebSearchBackendConfig): WebSearchBackend;
165
166
  /**
@@ -195,7 +196,7 @@ export declare function webSearchConfigFromEnv(env?: NodeJS.ProcessEnv): WebSear
195
196
  * · `absent` —— 没带(或 `null`)⇒ 用部署后端;
196
197
  * · `honored` —— 每个字段形对,且 `provider` 点名了一只本部署会说的后端 ⇒ 这次调用用它;
197
198
  * · `malformed` —— 任一字段形错 ⇒ 受理面 400 `request.field_invalid`(`issue` 逐字点名字段)。
198
- * **`provider` 缺席或不在词表里也是形错**(S-199 主会话改判,codex 验修 V1 [high]):一段 `settings.webSearch` 就是
199
+ * **`provider` 缺席或不在词表里也是形错**([ref] 主会话改判,codex 验修 V1 [high]):一段 `settings.webSearch` 就是
199
200
  * 调用方在点名目的地(`endpoint` / `apiKey` 都挂在它点名的那只后端上),认不出就拒,不静默换成部署后端 —— 改判前
200
201
  * 这一形回落部署后端,`{provider:"searx", endpoint:<私有地址>}` 的查询于是发到了部署配的后端。env 腿的同一只
201
202
  * {@link isWebSearchProvider} 守卫对**部署**的词表外答「不装配」,那是部署自己的缺席,不是换别人的目的地。
@@ -210,9 +211,22 @@ export type RequestWebSearchVerdict = {
210
211
  } | {
211
212
  readonly kind: "honored";
212
213
  readonly config: WebSearchBackendConfig;
213
- } | {
214
+ }
215
+ /** `facts` = 拒体的机读位(`field` + `reason`;只有「endpoint 带凭据」这一族在场,与 MCP / A2A / http 钩子三座同一只铸点)。 */
216
+ | {
214
217
  readonly kind: "malformed";
215
218
  readonly issue: string;
219
+ readonly facts?: UrlCredentialFacts;
216
220
  };
217
221
  export declare function judgeRequestWebSearch(raw: unknown): RequestWebSearchVerdict;
222
+ /**
223
+ * **fresh 提交门**读的判决([ref],受理面 `admission.ts` 独有):{@link judgeRequestWebSearch}(装配点读的那一只,续跑重放也走)+ 一条只属于新提交的 ——
224
+ * 采纳下来的 `endpoint` 带凭据(userinfo 一形已在上面的判官里拒,句子不变;这里补凭据名参数:名字在日志脱敏器凭据名表里的 query / fragment 参数)⇒ `malformed`,
225
+ * 拒句说出路,机读位 `field` + `reason` 与 MCP / A2A / http 钩子三座同一只铸点。
226
+ *
227
+ * 为什么不并进 {@link judgeRequestWebSearch}:那一只被装配点读(续跑重放存量 body),在那里答 `malformed` 的后果是「这次调用不装配 WebSearch」(见 `capabilities/scenarios.ts`)——
228
+ * 升级前停驻的任务会悄悄卸载这个工具,比不拒更糟;已落盘的字节也不因拒而消失。与 MCP 条目门 / A2A 对端门 / hooks matcher 判据同一条 `fresh` 限定律。
229
+ * 部署 env 的 `WEB_SEARCH_ENDPOINT` 同理不判:那是运维的配置,不进任何请求的停驻 ctx。
230
+ */
231
+ export declare function judgeFreshRequestWebSearch(raw: unknown): RequestWebSearchVerdict;
218
232
  //# sourceMappingURL=web-search.d.ts.map
@@ -2,6 +2,7 @@ import { validateHeaderValue } from "node:http";
2
2
  import { createSearxngSearchBackend } from "@sema-agent/core";
3
3
  import { isHierarchicalUrl } from "@sema-agent/settings-schema";
4
4
  import { redactSecrets } from "../trace/redact.js";
5
+ import { buildRequestUrlCredentialRefusal, findUrlCredential, findUrlUserinfo, urlCredentialFacts } from "../url-credential.js";
5
6
  export const WEB_SEARCH_PROVIDERS = ["brave", "tavily", "searxng"];
6
7
  function isWebSearchProvider(word) {
7
8
  return WEB_SEARCH_PROVIDERS.includes(word);
@@ -201,8 +202,8 @@ function judgeEndpoint(raw) {
201
202
  return ABSENT;
202
203
  if (!isHierarchicalUrl(raw))
203
204
  return { ok: false, issue: ENDPOINT_FORM };
204
- const url = new URL(raw);
205
- return url.username !== "" || url.password !== "" ? { ok: false, issue: ENDPOINT_USERINFO } : { ok: true, value: raw };
205
+ const credential = findUrlUserinfo(raw);
206
+ return credential !== undefined ? { ok: false, issue: ENDPOINT_USERINFO, credential } : { ok: true, value: raw };
206
207
  }
207
208
  const COUNT_FORM = "must be a number ≥ 1";
208
209
  function judgeCount(raw) {
@@ -320,8 +321,10 @@ export function judgeRequestWebSearch(raw) {
320
321
  maxResults: judgeCount(s.maxResults),
321
322
  };
322
323
  for (const [field, j] of Object.entries(fields)) {
323
- if (!j.ok)
324
- return { kind: "malformed", issue: `settings.webSearch.${field} ${j.issue}` };
324
+ if (!j.ok) {
325
+ const at = `settings.webSearch.${field}`;
326
+ return { kind: "malformed", issue: `${at} ${j.issue}`, ...(j.credential === undefined ? {} : { facts: urlCredentialFacts(at, j.credential) }) };
327
+ }
325
328
  }
326
329
  return {
327
330
  kind: "honored",
@@ -333,4 +336,16 @@ export function judgeRequestWebSearch(raw) {
333
336
  }),
334
337
  };
335
338
  }
339
+ const ENDPOINT_CREDENTIAL_EXIT = "settings.webSearch.apiKey is stored sealed: send the credential as settings.webSearch.apiKey (brave and tavily send it as a request header; " +
340
+ "the searxng backend sends no credential from a request, so a searxng instance that needs one is declared in the deployment's WEB_SEARCH_ENDPOINT instead)";
341
+ export function judgeFreshRequestWebSearch(raw) {
342
+ const verdict = judgeRequestWebSearch(raw);
343
+ if (verdict.kind !== "honored" || verdict.config.endpoint === undefined)
344
+ return verdict;
345
+ const credential = findUrlCredential(verdict.config.endpoint);
346
+ if (credential === undefined)
347
+ return verdict;
348
+ const refusal = buildRequestUrlCredentialRefusal("settings.webSearch.endpoint", credential, ENDPOINT_CREDENTIAL_EXIT);
349
+ return { kind: "malformed", issue: refusal.message, facts: refusal.facts };
350
+ }
336
351
  //# sourceMappingURL=web-search.js.map
@@ -1,5 +1,6 @@
1
1
  /**
2
- * S-185(core 7.10.0 [ref] / B-049)—— `WorkflowJournalEntry` **两臂**的单点读写。
2
+ * [ref](core 7.10.0 [ref] / [ref])—— `WorkflowJournalEntry` **两臂**的单点读写;`workflow_journal.result` 这一列的**单一属主叶**(写腿编码、读腿解码与判官
3
+ * 都在这里 —— SQL 店与 journal HTTP 读面的 SQL 分页腿共读,core 7.55.0 T3 起从 `orchestration/workflow-journal-entry.ts` 搬到列属主的家)。
3
4
  *
4
5
  * core 7.10.0 把 journal 记录从一个 interface 换成了判别联合:
5
6
  * `{ callKey, result }` —— 这一序数的子代跑完了,`result` 是它的 `TaskResult`;
@@ -15,17 +16,17 @@
15
16
  * 承重记录**——而 journal 是 LOAD-BEARING(丢一条 = 一次已完成的子代被当成没跑过而重跑,外部副作用重复)。
16
17
  * 收敛到这里之后,第三臂到货 ⇒ 本文件**一处**编译红。
17
18
  *
18
- * 🔴 **park 臂的形是 fail-closed 的**:core 的类型要求 `parked.terminal.kind === "paused"`。从盘上读回来的
19
- * 字节没有类型,所以 {@link readJournalRowBody} 在铸 park 臂时**亲验**这一位,不合就判坏——它是 LOAD-BEARING
20
- * 面上的坏行(一条说自己 park 了却拿不出暂停终局的记录,既不能驱动、也不能当成跑完),吞掉它会让 resume
21
- * 在一个被钉住的子代 session 旁边重新起一只活跑,正是 core 那条「一次性、响亮」的 schema 台阶要防的形。
19
+ * 🔴 **读回一行的判官是 core 的那一只**(core 7.55.0 [ref] T3 `readWorkflowJournalEntry`):从盘上读回来的字节没有类型,一条
20
+ * 「说自己 park 了却拿不出带令牌的暂停终局」的记录、一条完成臂不是对象的记录,既不能驱动、也不能当成跑完 —— 吞掉它会让 resume 在一个被
21
+ * 钉住的子代 session 旁边重新起一只活跑。本仓此前自判 park 臂的 `terminal.kind`(漏了 checkpoint 令牌那一条);现在本仓只做**信封解码**
22
+ * ({@link journalLogicalRow}:`{"parked": …}` 判别位活在载荷里),臂的判定全交 core,坏行 ⇒ `WorkflowJournalIncompatibleError`
23
+ * (码 `workflow.journal_incompatible`,点名序数)—— core 的两只内置 journal 与它的店契约盒对坏行要的就是这一只拒绝。
22
24
  *
23
25
  * 🔴 **盘上的编码是那道台阶的一部分**,不是实现细节:见 {@link journalRowPayloadOf} 的顶注(park 载荷走
24
26
  * `{"parked": …}` 信封,好让**回滚/混版**的老读者拿到一个没有 `terminal` 的对象、落进 core 的响亮拒绝臂,
25
27
  * 而不是把一个暂停终局当成可重放结果)。
26
28
  */
27
- import type { TaskResult, WorkflowJournalEntry } from "@sema-agent/core";
28
- import type { JsonColumnReader } from "../plugins/sql-json-column.js";
29
+ import { type TaskResult, type WorkflowJournalEntry } from "@sema-agent/core";
29
30
  /** park 臂的载荷型(core 的 `WorkflowJournalEntry` park 成员逐字):一只 `terminal` 收敛到 `paused` 的 `TaskResult`。 */
30
31
  export type ParkedTaskResult = TaskResult & {
31
32
  terminal: Extract<TaskResult["terminal"], {
@@ -64,33 +65,23 @@ export declare function journalEntryPayload(entry: WorkflowJournalEntry): {
64
65
  */
65
66
  export declare function journalRowPayloadOf(entry: WorkflowJournalEntry): string;
66
67
  /**
67
- * 盘上一行 payload 的**形读者**(S-550 车③a:`workflow_journal.result` 这一列的唯一判据)。
68
- *
69
- * 判别式 = 解出来的对象上有没有**自有** `parked` 键。它与 `TaskResult` 结构上不相交(core 的 `TaskResult`
70
- * 没有这个成员),所以历史字节(裸 TaskResult)恒判 result 臂 —— 不需要任何「老字节 = result」的兼容规则,
71
- * 判别式自己就说清了。
72
- *
73
- * park 臂验 `terminal.kind === "paused"`;不合 ⇒ 判坏,由 LOAD-BEARING 的读腿把它当店故障传上去。
74
- * 一条「说自己 park 了却拿不出暂停终局」的行既驱动不了、也不能当跑完,吞掉它会让 resume 在被钉住的子代
75
- * session 旁边重新起一只活跑 —— 与 {@link journalRowPayloadOf} 那道信封屏障要防的是同一件事。
76
- *
77
- * 🔴 **「一只 JSON 对象」这一条也必须判**(S-550):此前回装点是裸 `JSON.parse` + `as TaskResult`,于是
78
- * 一行 `null` 字面 / JSON 字符串标量 / 双重编码的 `result` 会被当成一条**合法的已完成记录**端给 resume
79
- * (`{callKey, result: null}`)—— 那正是「一次已完成的子代被当成跑过而不再跑」与「一条坏行冒充跑完」
80
- * 两种最坏形的同一个入口。
68
+ * 盘上一行 payload 的**信封解码**(本仓唯一自判的部分;{@link journalRowPayloadOf} 的逆):载荷是一只对象且带**自有** `parked` 键 ⇒ 停驻臂(值 = 信封里那一份),
69
+ * 否则整份载荷是完成臂 —— `parked` 与 core 的 `TaskResult` 结构上不相交,所以历史字节(裸 TaskResult)恒判完成臂,不需要任何「老字节 = result」的兼容规则。
70
+ * 交出的是 core `readWorkflowJournalEntry` 要的**逻辑行**(`callKey` + 两臂之一);两臂里装的东西拿不拿得出续跑要读的(完成臂是对象 / 停驻臂是带令牌的
71
+ * paused 终局)归 core 判。
81
72
  */
82
- export declare const readJournalRowBody: JsonColumnReader<JournalRowBody>;
83
- /** {@link readJournalRowBody} 收窄出来的两臂(判别位已定,载荷已验形)。 */
84
- export type JournalRowBody = {
85
- parked: true;
86
- payload: ParkedTaskResult;
73
+ export declare function journalLogicalRow(callKey: string, payload: unknown): {
74
+ readonly callKey: string;
75
+ readonly parked: unknown;
87
76
  } | {
88
- parked: false;
89
- payload: TaskResult;
77
+ readonly callKey: string;
78
+ readonly result: unknown;
90
79
  };
91
80
  /**
92
- * {@link journalRowPayloadOf} 的逆的**后半**:已解码、已验形的载荷 → 记录。**唯一**的铸点(SQL 店的 `load`
93
- * 与 HTTP journal 读面共读它;两处各自经 `decodeJsonColumn(text, readJournalRowBody, …)` 把文本收成这只体)。
81
+ * 一格 `workflow_journal.result` 读回一条记录的**唯一读法**(SQL 店的 `load` 与 HTTP journal 读面的 SQL 分页腿共读它):JSON 解码 → 信封解码
82
+ * ({@link journalLogicalRow})→ core `readWorkflowJournalEntry`。判官说坏 ⇒ 抛 `WorkflowJournalIncompatibleError`(码 `workflow.journal_incompatible`,
83
+ * 序数 = core 对 `callKey` 的解析;拒句是 core 判官的定句,不引存下的值)。读不成 JSON 的格是一条读不成对象的行(同判坏,同一只拒绝);
84
+ * 投影漏了的格(`not-text`,读腿写错)原样抛 —— 那是程序错,不是坏数据。
94
85
  */
95
- export declare function journalEntryOfBody(callKey: string, body: JournalRowBody): WorkflowJournalEntry;
96
- //# sourceMappingURL=workflow-journal-entry.d.ts.map
86
+ export declare function journalEntryOfCell(runId: string, callKey: string, cell: unknown, where: string): WorkflowJournalEntry;
87
+ //# sourceMappingURL=workflow-journal-payload.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { WorkflowJournalIncompatibleError, callKeyOrdinal, readWorkflowJournalEntry } from "@sema-agent/core";
2
+ import { SqlJsonColumnError, decodeJsonColumn } from "./sql-json-column.js";
3
+ export function journalEntryPayload(entry) {
4
+ return entry.parked !== undefined ? { payload: entry.parked, parked: true } : { payload: entry.result, parked: false };
5
+ }
6
+ export function journalRowPayloadOf(entry) {
7
+ const { payload, parked } = journalEntryPayload(entry);
8
+ return JSON.stringify(parked ? { parked: payload } : payload);
9
+ }
10
+ const ANY_JSON = (body) => ({ value: body });
11
+ export function journalLogicalRow(callKey, payload) {
12
+ return payload !== null && typeof payload === "object" && !Array.isArray(payload) && Object.hasOwn(payload, "parked")
13
+ ? { callKey, parked: payload.parked }
14
+ : { callKey, result: payload };
15
+ }
16
+ export function journalEntryOfCell(runId, callKey, cell, where) {
17
+ let payload;
18
+ try {
19
+ payload = decodeJsonColumn(cell, ANY_JSON, where);
20
+ }
21
+ catch (e) {
22
+ if (!(e instanceof SqlJsonColumnError) || e.problem !== "not-json")
23
+ throw e;
24
+ payload = cell;
25
+ }
26
+ const row = journalLogicalRow(callKey, payload);
27
+ const reading = readWorkflowJournalEntry(row);
28
+ if ("corrupt" in reading)
29
+ throw new WorkflowJournalIncompatibleError(runId, callKeyOrdinal(callKey), row);
30
+ return reading.entry;
31
+ }
32
+ //# sourceMappingURL=workflow-journal-payload.js.map
@@ -15,7 +15,7 @@
15
15
  * record (InMemory `{ scope, byOrdinal }` / File "first line names the scope, one line per ordinal"):
16
16
  * - `workflow_journal_owner (run_id) PK` — the run's ONE owning scope, the `incarnation` token minted by the claim
17
17
  * that wrote the record, and `appended_at_ms` (the owner's last append; the GC clock of this row). Written by the
18
- * run's first append; never a second scope (S-197, below).
18
+ * run's first append; never a second scope ([ref], below).
19
19
  * - `workflow_journal (run_id, incarnation, ordinal) PK` — one row per recorded call, keyed by the owner record that
20
20
  * wrote it. NO scope column: a run's scope lives in exactly one place, so "one run, two scopes" is not a state this
21
21
  * schema can hold.
@@ -26,7 +26,7 @@
26
26
  * OVERWRITES (last-write-wins) — a resumed run re-appends its replayed prefix verbatim, so this is the exact InMemory
27
27
  * `byOrdinal.set(ordinal, …)` semantics, not a duplicate row.
28
28
  *
29
- * 🔴 **The scope wall — ONE predicate, both faces** (S-197; core `workflowJournalStoreContract` "scope wall" case;
29
+ * 🔴 **The scope wall — ONE predicate, both faces** ([ref]; core `workflowJournalStoreContract` "scope wall" case;
30
30
  * core's InMemory / File stores refuse the same way): a run's journal belongs to the scope of its first append. Every
31
31
  * face answers through the owner row and the same pair `workflow_journal_owner.run_id = ? AND scope = ?`:
32
32
  * - `append` writes its row through `INSERT … SELECT … FROM workflow_journal_owner WHERE run_id = ? AND scope = ?` —
@@ -43,7 +43,7 @@
43
43
  * owner's row at the same ordinal. With the incarnation in the key, the stale write lands on a key of the dead record —
44
44
  * a row readable by no one, removed by the sweep — and the new record's rows are untouchable by it, on every engine,
45
45
  * without a locking clause.
46
- * Before S-197 the scope sat on every row: the read faces filtered it, the write face never judged it (a cross-scope
46
+ * Before [ref] the scope sat on every row: the read faces filtered it, the write face never judged it (a cross-scope
47
47
  * append on a NEW ordinal inserted a second scope's row into the run; on an EXISTING ordinal it overwrote the owner's
48
48
  * result under the owner's scope), held up by "runId is unique per scope and the owner is the sole writer".
49
49
  *
@@ -59,9 +59,10 @@
59
59
  * a multi-byte UTF-8 payload would silently slip past the byte-budget cap on PG with plain `LENGTH`, so
60
60
  * the twin uses the byte-counting function instead — codex R3, real dual-DB-suite-confirmed) in `loadPage`'s
61
61
  * size-gate CASE.
62
- * - `loadPage`'s bind-param ORDER: TiDB's `?`s appear in query-text order (maxResultBytes first, inside the
63
- * CASE, ahead of runId/scope), so its params array is `[maxResultBytes, runId, scope, limit, offset]`; PG's
64
- * `$n` are POSITIONAL (not text-order), so its array is `[runId, scope, maxResultBytes, limit, offset]`
62
+ * - `loadPage`'s bind-param ORDER (both the chunk read and the single oversize-row read go through `readRows`): TiDB's `?`s
63
+ * appear in query-text order (the byte gate first, inside the CASE, ahead of runId/scope), so its params array is
64
+ * `[inlineBytes, runId, scope, from, limit]`; PG's `$n` are POSITIONAL (not text-order), so its array is
65
+ * `[runId, scope, inlineBytes, from, limit]`
65
66
  * (`$3` inside the CASE refers to the third element regardless of where `$3` sits in the text). Same
66
67
  * placeholder-arity-fallout class the sql-driver.ts header calls out for null-safe compares.
67
68
  * - affectedRows vs rowCount (via SqlDriver's normalized `affected`). The guarded write reads it as the wall's
@@ -96,12 +97,12 @@ export declare class SqlWorkflowJournalStore implements WorkflowJournalStore {
96
97
  /** Record one agent's result. Idempotent per (run_id, ordinal) under the run's owner record: the PK upsert OVERWRITES (last-write-wins), so a
97
98
  * resumed run re-appending its replayed prefix verbatim leaves no duplicate. callKeyOrdinal is the SOLE ordinal
98
99
  * source (core's parser — a malformed key collapses to 0, matching InMemory). Throws on a REAL failure
99
- * (LOAD-BEARING) — an oversize entry included, on BOTH arms (S-194 / core 7.12.0 [ref]; see below) — and REFUSES an
100
- * append under a scope other than the run's owner, on any ordinal and both arms, writing nothing (S-197; the scope
100
+ * (LOAD-BEARING) — an oversize entry included, on BOTH arms ([ref] / core 7.12.0 [ref]; see below) — and REFUSES an
101
+ * append under a scope other than the run's owner, on any ordinal and both arms, writing nothing ([ref]; the scope
101
102
  * wall in the file header). */
102
103
  append(runId: string, scope: string, entry: WorkflowJournalEntry): Promise<void>;
103
104
  /** Entries for `runId` IF its owner scope === `scope`, ASCENDING by ordinal; otherwise EMPTY. CORE-9 audit
104
- * BLOCKER: the scope wall (S-197: the owner row, the same predicate append writes through) — the LLM controls
105
+ * BLOCKER: the scope wall ([ref]: the owner row, the same predicate append writes through) — the LLM controls
105
106
  * `resumeFromRunId`, so a cross-scope runId resolves to an empty journal (resume safely diverges to live, never
106
107
  * discloses another tenant's results). Each row's `result` is the persisted JSON.stringify(TaskResult) → JSON.parse
107
108
  * back. Throws on failure (LOAD-BEARING). */
@@ -109,8 +110,16 @@ export declare class SqlWorkflowJournalStore implements WorkflowJournalStore {
109
110
  /** [ref] locator 云形(core 1.353 WorkflowJournalStore.locator additive):SQL 店的 journal 坐标=
110
111
  * [ref] HTTP 读面路由(file 店返 jsonl 路径=CC 本地形;此处返云形,core 铸 diagnostics 教句时单源引用)。 */
111
112
  locator(runId: string, _scope: string): string;
112
- /** codex R1-H2:分页投影读——LIMIT/OFFSET 界行数,字节门界单行字节(超限行不取 result 全文,只回字节数;
113
- * 读面标 truncated)。ORDER BY ordinal 与 load 同轴;scope 墙与 load 同一只 JOIN(S-197)。
113
+ /** 分页投影读 —— **判整份 journal,取一页**。
114
+ *
115
+ * 🔴 判的范围 = `load` 的范围:这条 journal 里只要有一行(任意一页、任意大小)被 core 的判官判坏,本读就抛 `WorkflowJournalIncompatibleError`(点名按序数升序的第一条坏行 ——
116
+ * 与内存 / 文件店 `load` 逐行判的次序同),页只是投影。修前只判本页取到、且不超 `maxResultBytes` 的行:同一条坏 journal 在内存 / 文件上整次拒、在这里答 200
117
+ * (坏行在别的页、或是超单行门的坏行 —— 后者只出尺寸存根,永不解码)。判官只有一只、判的范围只有一个,页不是判的单位。
118
+ *
119
+ * 读法:按序数的键集游标分块(每块 {@link JOURNAL_SCAN_CHUNK_ROWS} 行,`ORDER BY ordinal` 的主键序;不用 OFFSET —— 活 run 在读的同时还在 append,位置偏移会在块界上漏行或重行),
120
+ * 每行经 {@link journalEntryOfCell}(`load` 的同一只回装点)判一遍;位置落在 `[offset, offset + limit)` 里的行进页。内存峰值 ≤ 正在读的一块 + 已收下的页(各 ≤ 50 行 × `maxResultBytes`,读面传 64 KiB)+ 一条超门的行(驱动 / 解码的开销另计):
121
+ * 行字节超 `maxResultBytes` 的行在块里只回字节数(库端 CASE 门,全文不过线),判它时单条取回全文、判完即弃 —— 页里它仍只是 `resultJson: null` 的尺寸存根。
122
+ * ORDER BY ordinal 与 `load` 同轴;scope 墙与 `load` 同一只 JOIN([ref])。读放大:每次读 = 整份 journal 的一遍主键范围扫描(≤ 一次续跑 `load` 的量),这是「判整份」的代价。
114
123
  * 🔴 param ORDER differs by dialect (see file header): TiDB's `?`s bind in text order (maxResultBytes first,
115
124
  * inside the CASE); PG's `$n` are positional, so its array keeps runId/scope first. Never unify — a swap
116
125
  * silently mis-binds the OTHER dialect's placeholders. */
@@ -123,7 +132,12 @@ export declare class SqlWorkflowJournalStore implements WorkflowJournalStore {
123
132
  resultJson: string | null;
124
133
  resultBytes: number;
125
134
  }>>;
126
- /** GC — purge ALL journal entries for a run (every incarnation), then its owner row (S-197). Scoped by run_id alone;
135
+ /** 超 `maxResultBytes` 的那一行的全文:单条读(序数 ≥ 它的第一行)—— 返回的行**必须就是它**(序数相等);它在块读与这次读之间被清扫了,读到的是「序数更大的下一行」,
136
+ * 那是别人的字节,不能挂在它的键下判 ⇒ 无可判(`undefined`),下一块读自然读到那一行、用它自己的键判。 */
137
+ private oversizeCellOf;
138
+ /** 读面的**唯一**行读法(`loadPage` 的块读与超门行的单条读共用):序数 ≥ `from` 的至多 `limit` 行,字节超 `inlineBytes` 的行 `resultJson` 为 null(只回 `resultBytes`)。 */
139
+ private readRows;
140
+ /** GC — purge ALL journal entries for a run (every incarnation), then its owner row ([ref]). Scoped by run_id alone;
127
141
  * idempotent (returns the journal rows removed). Mirrors the resume-anchor store's deleteBySession. An append racing the
128
142
  * two DELETEs can leave a row behind without its owner record; it is keyed by the dead incarnation — readable and
129
143
  * overwritable by no one (file header) — and the GC sweep removes it by age. */
@@ -157,9 +171,9 @@ export declare class SqlWorkflowJournalStore implements WorkflowJournalStore {
157
171
  * bound. A resume of a journal older than the retention window simply re-runs live (resume is an optimization).
158
172
  * Idempotent; returns the journal rows purged.
159
173
  *
160
- * S-197: the same cutoff then purges owner rows whose OWN clock (`appended_at_ms`, pushed by every append of the
174
+ * [ref]: the same cutoff then purges owner rows whose OWN clock (`appended_at_ms`, pushed by every append of the
161
175
  * owner) is older. Each DELETE's predicate reads only the row it deletes — a cross-table "owner with no rows left"
162
- * test inside the DELETE would be a non-current read on every engine here (the B-022 lesson: TiDB pins start_ts, PG
176
+ * test inside the DELETE would be a non-current read on every engine here (the [ref] lesson: TiDB pins start_ts, PG
163
177
  * READ COMMITTED re-checks only the target row), so a concurrent append could have its owner deleted from under it.
164
178
  * Every row of a run was written by an append that first pushed the owner's clock (monotonically — GREATEST) to at least
165
179
  * that row's `created_at_ms`, so an owner past the cutoff normally has no row left after the first DELETE. The one
@@ -1,18 +1,13 @@
1
1
  import { callKeyOrdinal } from "@sema-agent/core";
2
2
  import { assertJournalEntryFits } from "@sema-agent/core";
3
- import { journalEntryOfBody, journalRowPayloadOf, readJournalRowBody } from "../orchestration/workflow-journal-entry.js";
3
+ import { journalEntryOfCell, journalRowPayloadOf } from "./workflow-journal-payload.js";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { mysqlDriver, pgDriver } from "./sql-driver.js";
6
- import { decodeJsonColumn, foldJsonColumn, jsonColumnText, jsonColumnTextExpr } from "./sql-json-column.js";
6
+ import { jsonColumnText, jsonColumnTextExpr } from "./sql-json-column.js";
7
7
  const DEFAULT_RESUME_CLAIM_TTL_MS = 60 * 60 * 1000;
8
- function decodeJournalResult(cell, where) {
9
- try {
10
- return decodeJsonColumn(cell, readJournalRowBody, where);
11
- }
12
- catch (e) {
13
- throw foldJsonColumn(e, (m) => `workflow journal: ${m} — refusing rather than replay a journal entry nobody can read`);
14
- }
15
- }
8
+ const INT_MIN = -2147483648;
9
+ const INT_MAX = 2147483647;
10
+ const JOURNAL_SCAN_CHUNK_ROWS = 50;
16
11
  export class SqlWorkflowJournalStore {
17
12
  db;
18
13
  resumeClaimTtlMs;
@@ -43,18 +38,42 @@ export class SqlWorkflowJournalStore {
43
38
  const { rows } = await this.db.query(this.q(`SELECT call_key, ${jsonColumnText("tidb", "result")} FROM workflow_journal JOIN workflow_journal_owner USING (run_id, incarnation) WHERE run_id = ? AND scope = ? ORDER BY ordinal ASC`, `SELECT call_key, ${jsonColumnText("pg", "result")} FROM workflow_journal JOIN workflow_journal_owner USING (run_id, incarnation) WHERE run_id = $1 AND scope = $2 ORDER BY ordinal ASC`), [runId, scope]);
44
39
  return rows.map((r) => {
45
40
  const callKey = String(r.call_key);
46
- return journalEntryOfBody(callKey, decodeJournalResult(r.result, `workflow_journal.result for run ${runId} entry ${callKey}`));
41
+ return journalEntryOfCell(runId, callKey, r.result, `workflow_journal.result for run ${runId} entry ${callKey}`);
47
42
  });
48
43
  }
49
44
  locator(runId, _scope) {
50
45
  return `/v1/workflows/${runId}/journal`;
51
46
  }
52
47
  async loadPage(runId, scope, opts) {
48
+ const page = [];
49
+ let position = 0;
50
+ let from = INT_MIN;
51
+ for (;;) {
52
+ const chunk = await this.readRows(runId, scope, from, JOURNAL_SCAN_CHUNK_ROWS, opts.maxResultBytes);
53
+ for (const row of chunk) {
54
+ const cell = row.resultJson ?? (await this.oversizeCellOf(runId, scope, row.ordinal));
55
+ if (typeof cell === "string")
56
+ journalEntryOfCell(runId, row.callKey, cell, `workflow_journal.result for run ${runId} entry ${row.callKey}`);
57
+ if (position >= opts.offset && position < opts.offset + opts.limit)
58
+ page.push({ callKey: row.callKey, resultJson: row.resultJson, resultBytes: row.resultBytes });
59
+ position += 1;
60
+ }
61
+ const last = chunk.at(-1);
62
+ if (last === undefined || chunk.length < JOURNAL_SCAN_CHUNK_ROWS || last.ordinal >= INT_MAX)
63
+ return page;
64
+ from = last.ordinal + 1;
65
+ }
66
+ }
67
+ async oversizeCellOf(runId, scope, ordinal) {
68
+ const row = (await this.readRows(runId, scope, ordinal, 1, INT_MAX))[0];
69
+ return row !== undefined && row.ordinal === ordinal && row.resultJson !== null ? row.resultJson : undefined;
70
+ }
71
+ async readRows(runId, scope, from, limit, inlineBytes) {
53
72
  const params = this.db.dialect === "tidb"
54
- ? [opts.maxResultBytes, runId, scope, opts.limit, opts.offset]
55
- : [runId, scope, opts.maxResultBytes, opts.limit, opts.offset];
56
- const { rows } = await this.db.query(this.q(`SELECT call_key, CASE WHEN LENGTH(result) > ? THEN NULL ELSE ${jsonColumnTextExpr("tidb", "result")} END AS result_json, LENGTH(result) AS result_bytes FROM workflow_journal JOIN workflow_journal_owner USING (run_id, incarnation) WHERE run_id = ? AND scope = ? ORDER BY ordinal ASC LIMIT ? OFFSET ?`, `SELECT call_key, CASE WHEN OCTET_LENGTH(result) > $3 THEN NULL ELSE ${jsonColumnTextExpr("pg", "result")} END AS result_json, OCTET_LENGTH(result) AS result_bytes FROM workflow_journal JOIN workflow_journal_owner USING (run_id, incarnation) WHERE run_id = $1 AND scope = $2 ORDER BY ordinal ASC LIMIT $4 OFFSET $5`), params);
57
- return rows.map((r) => ({ callKey: String(r.call_key), resultJson: r.result_json === null ? null : String(r.result_json), resultBytes: Number(r.result_bytes) }));
73
+ ? [inlineBytes, runId, scope, from, limit]
74
+ : [runId, scope, inlineBytes, from, limit];
75
+ const { rows } = await this.db.query(this.q(`SELECT ordinal, call_key, CASE WHEN LENGTH(result) > ? THEN NULL ELSE ${jsonColumnTextExpr("tidb", "result")} END AS result_json, LENGTH(result) AS result_bytes FROM workflow_journal JOIN workflow_journal_owner USING (run_id, incarnation) WHERE run_id = ? AND scope = ? AND ordinal >= ? ORDER BY ordinal ASC LIMIT ?`, `SELECT ordinal, call_key, CASE WHEN OCTET_LENGTH(result) > $3 THEN NULL ELSE ${jsonColumnTextExpr("pg", "result")} END AS result_json, OCTET_LENGTH(result) AS result_bytes FROM workflow_journal JOIN workflow_journal_owner USING (run_id, incarnation) WHERE run_id = $1 AND scope = $2 AND ordinal >= $4 ORDER BY ordinal ASC LIMIT $5`), params);
76
+ return rows.map((r) => ({ ordinal: Number(r.ordinal), callKey: String(r.call_key), resultJson: r.result_json === null ? null : String(r.result_json), resultBytes: Number(r.result_bytes) }));
58
77
  }
59
78
  async deleteByRun(runId) {
60
79
  const res = await this.db.query(this.q("DELETE FROM workflow_journal WHERE run_id = ?", "DELETE FROM workflow_journal WHERE run_id = $1"), [runId]);
@@ -70,7 +70,7 @@ type WorkflowRun = Parameters<WorkflowRunStore["put"]>[1];
70
70
  export declare const MAX_RUN_BLOB_BYTES: number;
71
71
  declare const onWarnType: (msg: string, meta: Record<string, unknown>) => void;
72
72
  export type InboxWarn = typeof onWarnType;
73
- /** S-107:workflow_run 行的 `error`(脚本抛出的 `err.message`)在**两条写腿**(put / update 常态 + oversize 降级)
73
+ /** [ref]:workflow_run 行的 `error`(脚本抛出的 `err.message`)在**两条写腿**(put / update 常态 + oversize 降级)
74
74
  * 同一口脱;`result` 由 core 完成时源头脱。幂等,不抛(超大 ⇒ 占位)。
75
75
  * core 7.48.0 起 `error` 在铸点也过 core 的 `redactSecrets`,但两张脱敏表互不为超集(本仓的表多认几种记号,core 的表多认另几种)⇒ 这一口暂留;
76
76
  * 退役条件 = core 的脱敏表成为两表的并集(本仓的每一种记号它都认)—— 到那时这一口与它的两条调用一起删。 */
@@ -90,12 +90,12 @@ export declare function withRedactedError<T extends {
90
90
  * 第一臂,「那张表独自作数」—— 剥成缺席就把一条走第一臂的记录推去走派生臂,而派生的两个缓存只装这条 run
91
91
  * **自己做出**的 park,继承来、从未跑到的那一条**只存在于被剥掉的那张表里**,于是它要么被漏掉、要么被
92
92
  * 当成不存在而在 resume 时活着重跑([ref] 正要消灭的形)。它同时也是本仓 `/decide` 的 workflow 车道复核
93
- * 「这条 park 属于这条 run」的**单一真源**(S-252)。实现上三级全部走 `{...上一级}` 展开、没有任何一级点名裁它,机器背书 =
93
+ * 「这条 park 属于这条 run」的**单一真源**([ref])。实现上三级全部走 `{...上一级}` 展开、没有任何一级点名裁它,机器背书 =
94
94
  * `test/slim-oversize-run.test.ts` 里那两格(最狠的一级上 `parks` 仍逐字完整 + 负控:记录本来没有
95
95
  * 这一位时不许凭空补 `[]`)。缺席 ⇒ 不补:补 `[]` 会把「这版引擎没写这个位」伪造成「这条 run 没有 park」,
96
96
  * 而 core 对两者的处置相反。
97
97
  *
98
- * 🔴 **S-252(7.75.0):阶梯不再为 park 另存第二份恢复身份。** 7.71.0 的 S-192 曾在 `agents[]` 里逐行保住
98
+ * 🔴 **[ref](7.75.0):阶梯不再为 park 另存第二份恢复身份。** 7.71.0 的 [ref] 曾在 `agents[]` 里逐行保住
99
99
  * `callKey`/`sessionId`/`parkedCheckpointToken`(外加两级 `label` 预算与一枚不可恢复标记),因为当时
100
100
  * `/decide` 的复核只认那一行。core 7.17.0 之后同一条记录上有了 `parks[]`,那份保留就成了**第二个会漂的
101
101
  * 定义**(真案:最后一级清空 `agents` 之后 token 仍躺在同一个 blob 的 `parks` 里,而 `/decide` 照拒)。
@@ -185,7 +185,7 @@ export declare class SqlWorkflowNotifyJournalStore implements WorkflowNotifyJour
185
185
  get(runId: string): Promise<WorkflowNotifyJournalEntry | null>;
186
186
  }
187
187
  /**
188
- * S-185 车CM —— **workflow 出身 park 的有界 join 索引** SQL 双生(契约与纪律的唯一属主 =
188
+ * [ref] 车CM —— **workflow 出身 park 的有界 join 索引** SQL 双生(契约与纪律的唯一属主 =
189
189
  * {@link import("../orchestration/workflow-agent-session-index.js").WorkflowAgentSessionIndex} 的文件头,
190
190
  * 这里只记方言差)。行是 `WorkflowRun` 的派生投影(一行一枚指针),写者只有一个(Journaling 装饰器的写观察点);
191
191
  * 收割在删 run 行的同一个方法里按同一张待删 id 表删它们的指针({@link SqlWorkflowRunStore.reap})。
@@ -1,17 +1,17 @@
1
1
  /**
2
- * S-167 → S-178 → S-1492 —— **一个部署级旋钮的值是谁定的**,五词闭集 + 一句运维指路。
2
+ * [ref] → [ref] → [ref] —— **一个部署级旋钮的值是谁定的**,五词闭集 + 一句运维指路。
3
3
  *
4
4
  * ## 为什么是一个共享件而不是每键一份
5
5
  *
6
- * S-167 给 `READ_FACE` 造了这套东西(值 + 来源 + 指路句),理由写在 `read-face-posture.ts` 的顶注里:
6
+ * [ref] 给 `READ_FACE` 造了这套东西(值 + 来源 + 指路句),理由写在 `read-face-posture.ts` 的顶注里:
7
7
  * 「缺席」这一态里塞着两件不同的事(单机 turnkey 没表态 vs 多租户就是要引擎默认),而把它们分开之后,
8
- * **env 恒赢的判据**与**运维面「为什么这台机器是这个值」**才有真答案。S-178 把同一条律推到另外三个键
8
+ * **env 恒赢的判据**与**运维面「为什么这台机器是这个值」**才有真答案。[ref] 把同一条律推到另外三个键
9
9
  * (`STREAM_ASK_WINDOW_MS` / `DURABLE_APPROVAL` / `SESSION_AUTO_TITLE`)时,唯一诚实的做法是**抽这一份**
10
10
  * ——四词表抄第二遍的那天,两份表会在加词时分家,而「这个值是谁定的」在运维面上是个是非题,不能有两个答案。
11
11
  *
12
12
  * ## 优先序(与 `config.ts` 的 `postureOn` 同形)
13
13
  * `env 显式` > `center 发布` > `车道声明` > `posture 派生` > `引擎/服务端默认`。
14
- * `lane`(S-1492,[ref])= **执行车道的契约行替运维声明了这个旋钮的缺省**(目前只有 `READ_FACE`:隔离型车道的读面缺省 `open`,声明在 `execution-lane-caps.ts`)。
14
+ * `lane`([ref],[ref])= **执行车道的契约行替运维声明了这个旋钮的缺省**(目前只有 `READ_FACE`:隔离型车道的读面缺省 `open`,声明在 `execution-lane-caps.ts`)。
15
15
  * 它是出处,不是表态:运维从没写过这个键,所以与 `posture` 一样不算「有人要求过」({@link isExplicitPosture});比 `posture` 优先,因为车道声明比整机 posture 更具体
16
16
  * (同一台单机上 `e2b` 沙箱里的读面缺省 `open`,理由是沙箱边界而不是「一个可信主人」)。
17
17
  *
@@ -22,12 +22,12 @@
22
22
  * 得到一句谁都不认的空话,或者更坏:一句**对某些键是假的**话。
23
23
  *
24
24
  * 🔴 `centerMeaning` 是 G-7(test [ref])的修复面,成因是一次真的过期断言:这一臂原本硬编码
25
- * 「applied from the web-admin (**restart-to-apply**)」,而 S-174(core 7.10.0 [ref])之后
25
+ * 「applied from the web-admin (**restart-to-apply**)」,而 [ref](core 7.10.0 [ref])之后
26
26
  * `readFace.face` 是**热换席**(`Runner.swapDeps({readFace})`,下一拍 refresh 当场换进全部 Runner,
27
27
  * `read-face` 重启片也不再为它签理由)——运维照那句话去滚动重启一片 fleet,重启的是一个已经生效的变更。
28
28
  * 生效时机是**键**的事实,不是四词表的属性,所以它跟 `postureMeaning` 一样归键。
29
29
  */
30
- /** 旋钮取值来源的闭集词表(顺序 = 优先序;五词,S-1492 起多 `lane`)。 */
30
+ /** 旋钮取值来源的闭集词表(顺序 = 优先序;五词,[ref] 起多 `lane`)。 */
31
31
  export declare const POSTURE_SOURCE_WORDS: readonly ["env", "center", "lane", "posture", "engine-default"];
32
32
  /** 一个旋钮的取值来源(闭集五词)。加词 ⇒ {@link postureSourceNote} 的穷举 switch 编译红。 */
33
33
  export type PostureSource = (typeof POSTURE_SOURCE_WORDS)[number];
@@ -41,13 +41,13 @@ export interface PostureKnobFacts {
41
41
  * 还是这个键根本没有 center 腿?),以及怎么把这个键取回来。只在 `source === "center"` 时被读到。
42
42
  *
43
43
  * 🔴 为什么归键而不是共享(G-7 的成因):生效时机是键的事实。同一句「restart-to-apply」对
44
- * `readFace.face` 是假的(S-174 热换席),对三个 S-178 旋钮则连触发条件都没有(`config.ts` 的
44
+ * `readFace.face` 是假的([ref] 热换席),对三个 [ref] 旋钮则连触发条件都没有(`config.ts` 的
45
45
  * `postureSourceOfKnob` / `postureSourceOfNumEnv` 只产 env/posture/engine-default,center 写不到
46
46
  * 它们)—— 一句共享的硬编码必然对其中一类说谎。
47
47
  */
48
48
  readonly centerMeaning: string;
49
49
  /**
50
- * `lane` 那一臂**专属**的一句话(S-1492):执行车道的契约行为什么替这个旋钮声明了缺省、这一声明的风险是什么、怎么钉回。只在 `source === "lane"` 时被读到。
50
+ * `lane` 那一臂**专属**的一句话([ref]):执行车道的契约行为什么替这个旋钮声明了缺省、这一声明的风险是什么、怎么钉回。只在 `source === "lane"` 时被读到。
51
51
  * 与 `centerMeaning` 同理由归键:没有 lane 腿的旋钮(今天除 `READ_FACE` 外都是)写一句「本键没有 lane 腿」,比一句会骗人的通用话诚实。
52
52
  */
53
53
  readonly laneMeaning: string;
@@ -64,17 +64,17 @@ export declare function postureSourceNote(facts: PostureKnobFacts): string;
64
64
  /**
65
65
  * 这个值是**运维显式表态**的吗?
66
66
  *
67
- * 🔴 S-178 施工时真踩(本批全量抓出):`hasOperatorGateIntent`(`src/approval.ts`)判「运维表达过门意图
67
+ * 🔴 [ref] 施工时真踩(本批全量抓出):`hasOperatorGateIntent`(`src/approval.ts`)判「运维表达过门意图
68
68
  * 没有」时读的是 `durableApproval` 这个**值** —— 那在本键进 posture 家族之前是对的(它只有显式设过才为
69
69
  * 真),之后当场失真:单机 turnkey 上 posture 派生的 `true` 会被读成「运维要门」,于是 run-local 那条
70
70
  * **结构上没有 durable 门**的腿在每次 boot 打一条补偿 warn,而它其实正处在「零门意图的既定姿势」里。
71
- * 这与 S-167 头注①记的是**同一形**病(用一个会被 posture 铸出来的量当「有人表态过」的代理)。
71
+ * 这与 [ref] 头注①记的是**同一形**病(用一个会被 posture 铸出来的量当「有人表态过」的代理)。
72
72
  *
73
73
  * ⇒ 判据落到**来源**上,穷举 switch(五词闭集加员即编译红):`env`(这台机器的运维写下的)与 `center`
74
74
  * (组织发布的)是表态;`lane`(车道契约行声明的缺省)、`posture`(姿态派生)与 `engine-default`(内建缺省)都**不是**「有人要求过」。
75
75
  */
76
76
  export declare function isExplicitPosture(source: PostureSource): boolean;
77
- /** operator 诊断面的一行读数:值 + 来源 + 指路句。三个 S-178 旋钮与 S-167 的 readFace 同形。 */
77
+ /** operator 诊断面的一行读数:值 + 来源 + 指路句。三个 [ref] 旋钮与 [ref] 的 readFace 同形。 */
78
78
  export interface PostureKnobReading<V> {
79
79
  value: V;
80
80
  source: PostureSource;