@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
@@ -1,4 +1,4 @@
1
- import { FileSessionRepo, type AcquiredSession, type SessionStore, type SessionRepo, type SessionTreeEntry } from "@sema-agent/core";
1
+ import { FileSessionRepo, type AcquiredSession, type SessionHead, type SessionStore, type SessionRepo, type SessionTreeEntry } from "@sema-agent/core";
2
2
  import type { SessionRunRollupSource, SessionSummary } from "./store-contracts.js";
3
3
  import type { SessionRowPatch } from "../session-row.js";
4
4
  import { type Logger } from "../observability/logger.js";
@@ -13,6 +13,8 @@ import { type StagedCommitOptions, type StagingHandle, type SyncRelation } from
13
13
  * 的作用域里才记,作用域外 —— 列表 / 导出 / 视图口 —— 是空操作,那些读只进运维面)。
14
14
  */
15
15
  export declare function createLocalSessionRepo(root: string): FileSessionRepo;
16
+ /** 本店包的 repo:core `SessionRepo` 且答头读(`headOf` —— 叶子出自它;core 7.55.0 起 `FileSessionRepo` / `InMemorySessionRepo` 都答)。 */
17
+ export type HeadReadingSessionRepo = SessionRepo & Required<Pick<SessionRepo, "headOf">>;
16
18
  export declare class LocalSessionStore implements SessionStore {
17
19
  private readonly repo;
18
20
  private readonly runs;
@@ -58,14 +60,14 @@ export declare class LocalSessionStore implements SessionStore {
58
60
  /** Pin map (`session-pinned.json`, {@link readPinnedSidecar}) — the local twin of `session_meta.pinned`. Its own file for
59
61
  * the same reason titles have theirs (one small map per concern, no format coupling); absent key = not pinned. */
60
62
  private readonly pinned;
61
- /** S-690 — instruction-source baselines (`session-instruction-sources.json`): the chain member the session's previous
63
+ /** [ref] — instruction-source baselines (`session-instruction-sources.json`): the chain member the session's previous
62
64
  * run selected, encoded like the SQL twins' `session_meta.instruction_source` column ('' = none; missing key = never
63
65
  * recorded). Its own file for the same reason titles have theirs: one small map per concern, no format coupling. */
64
66
  private readonly instructionSources;
65
67
  /**
66
68
  * 会话元数据(`session-incarnations.json`,一格的形与两种读法见 {@link SessionMetaCell}):**属主与化身的唯一真源**,SQL 孪生
67
69
  * `session_meta` 行上 `owner` / `incarnation` 两列在本店的对位。两样都**必须落盘**:
68
- * · 化身(S-790 / S-506,[ref] §2)的口径是「一位住客一生稳定」,记忆引擎按它绑定会话级记录(opt-out / 污染标记)——
70
+ * · 化身([ref] / [ref],[ref] §2)的口径是「一位住客一生稳定」,记忆引擎按它绑定会话级记录(opt-out / 污染标记)——
69
71
  * 重启后换一只值 = 同一位住客的 opt-out 不再绑它 = 静默恢复采集;
70
72
  * · 属主(7.119.0)是会话策略规则的存储键:规则按「会话 × 属主」存、按 run 的 principal 读 —— 重启后属主丢了,规则照样在跑,
71
73
  * 属主自己却读不到也删不掉(`409 conflict.session_ownerless`)。7.118.x 及更早属主只活在一只进程内存 Map 里,就是这个病。
@@ -91,7 +93,7 @@ export declare class LocalSessionStore implements SessionStore {
91
93
  * restart (the file-backed deployment); omit it for the in-memory deployment (nothing survives).
92
94
  * @param opts.log the `session_owner_claimed` line's sink (LocalBackend passes a logger at the deployment's LOG_LEVEL;
93
95
  * absent ⇒ an info-level JSON-line logger — a claim is never silent). */
94
- constructor(repo: SessionRepo, runs: SessionRunRollupSource, dataDir?: string, opts?: {
96
+ constructor(repo: HeadReadingSessionRepo, runs: SessionRunRollupSource, dataDir?: string, opts?: {
95
97
  log?: Pick<Logger, "info">;
96
98
  });
97
99
  /**
@@ -111,7 +113,7 @@ export declare class LocalSessionStore implements SessionStore {
111
113
  /** 盘上有没有这只会话(repo 的唯一探针;`open` 读整只存档,所以只在边档里没有那一格时才走到这里)。 */
112
114
  private existsInRepo;
113
115
  /**
114
- * 一只会话的元数据 —— 属主与化身的**唯一读口**(`ownerOf` / `sessionFaceOf` / `getHead` / 删除与换装的属主门都经它)。`undefined` = 无此会话。
116
+ * 一只会话的元数据 —— 属主与化身的**唯一读口**(按 id 读 {@link headOf} / 删除与换装的属主门都经它)。`undefined` = 无此会话。
115
117
  * 边档里有那一格 ⇒ 读它(一次同步读,两样同出一格,不会拼出混世代组合);没有那一格而盘上有会话(7.104.0 之前的会话从没被铸过化身)
116
118
  * ⇒ 补铸一格只有化身的(属主没有事实可写,不伪造)并落盘后再答 —— 之后的读都命中那一格,不再回 repo。
117
119
  */
@@ -122,13 +124,21 @@ export declare class LocalSessionStore implements SessionStore {
122
124
  * `undefined` = 补铸落盘之前那一格已被并发删除抹掉(只有锁外的 {@link metaOf} 走得到)。
123
125
  */
124
126
  private cellOfPresent;
125
- /** S-790:属主 + 化身一次读(SQL 孪生同义;`undefined` = 无此会话)—— 两样出自 {@link metaOf} 读到的同一格。 */
126
- sessionFaceOf(sessionId: string): Promise<SessionFace | undefined>;
127
- /** core `SessionStore.incarnationOf`(按 id 读住客,给没取会话的那一侧):{@link sessionFaceOf} 的化身那一半 —— 同一格、同一次读。 */
128
- incarnationOf(sessionId: string): Promise<string | undefined>;
127
+ /**
128
+ * core `SessionStore.headOf` —— 本店按 id 读一行的**唯一**读口(SQL 孪生同义;此前的 `ownerOf` / `sessionFaceOf` / `incarnationOf` / `getHead` / `getLeafId`
129
+ * 五只读并进来,规则见 `session-incarnation.ts` 头注)。属主与住客出自 {@link metaOf} 读到的同一格(local 后端属主 + 化身的唯一真源 —— 本店的**行**),
130
+ * 叶子出自会话存档(本店的**内容**;core `SessionRepo.headOf`:File repo 读日志首记录与尾、不重放 —— 存档首行的属主 / 令牌本店不读)。
131
+ * 存档读不出(会话头坏了、I/O 故障)⇒ 头照答行上的属主与住客,叶子那一格带着那只故障(`UnreadableLeaf`,读叶子的人收到它):只判归属的读者
132
+ * 不因坏存档改判,坏存档只让读内容的那一位看见(SQL 孪生的头不碰 `session_event`,同一条律;规则在 `session-incarnation.ts` 头注)。
133
+ * 行本身读不出(边档里还没有这一格、要从存档推出这只会话在不在,而存档读不出 —— {@link metaOf} 的探针)⇒ 整只拒。
134
+ * 两样住在两只文件里 ⇒ 先读那一格、读叶子、再同步复读那一格:格没了(读间被删)或换了主 / 换了住客 ⇒ `undefined`(调用方按删处理),
135
+ * 所以一只头从不把这一代的属主配上另一代的叶子([ref] 六轮复审同一条)。`undefined` = 无此会话。
136
+ * 化身那一格经 `headFromRow` 的 `absent` 读法(边档对象形恒有令牌;读不出的边档整只严格拒在 `metaOf` 之前)。
137
+ */
138
+ headOf(sessionId: string): Promise<SessionHead | undefined>;
129
139
  /**
130
140
  * 三条 acquire 腿(无 id 建 / 按 id 打开 / 按 id 首建)交出会话的唯一一处:住客 = 这只会话那一格({@link cellOfPresent} —— 刚建或刚在写锁里
131
- * 打开,就是在盘上的证明,不再回 repo 探一次),经与 {@link sessionFaceOf} 同一只解码(`sessionFaceFromRow`),挂到交出的会话上({@link occupiedBy})。
141
+ * 打开,就是在盘上的证明,不再回 repo 探一次),经活住客的唯一投影(`sessionFaceFromRow`)解码,挂到交出的会话上({@link occupiedBy})。
132
142
  */
133
143
  private handOut;
134
144
  /** Cheap pre-LLM probe (local twin). The map write needs no session_meta row, so there is
@@ -156,10 +166,10 @@ export declare class LocalSessionStore implements SessionStore {
156
166
  sessionSummaryOf(sessionId: string): Promise<SessionSummary | undefined>;
157
167
  /** 会话仓里这只会话的列表元数据(列表面上的行 = `repo.list()` 里的一项)。 */
158
168
  private listedMeta;
159
- /** S-690 —— 换源通告的基线读(local 孪生;三态读法与 SQL 两孪生的 `session_meta.instruction_source` 同一只编解码)。 */
169
+ /** [ref] —— 换源通告的基线读(local 孪生;三态读法与 SQL 两孪生的 `session_meta.instruction_source` 同一只编解码)。 */
160
170
  readInstructionSource(sessionId: string): Promise<InstructionSourceBaseline>;
161
171
  /**
162
- * S-690 —— CAS 覆写基线(契约见 `InstructionSourceStore`:期望值不符 ⇒ 不写;**没落盘 ⇒ 内存不动、抛**,与 SQL 孪生
172
+ * [ref] —— CAS 覆写基线(契约见 `InstructionSourceStore`:期望值不符 ⇒ 不写;**没落盘 ⇒ 内存不动、抛**,与 SQL 孪生
163
173
  * 「要么提交要么抛」同形 —— 修前写失败只 warn、内存照样前进,同来源的后续 run 在相等比较上短路、再也不重写,重启后
164
174
  * 比的是一份过期的盘,codex che-NM r1 [medium])。CAS 判定(在草稿上)、落盘、发布**整段在写链的一节里**(`commit`):下一节
165
175
  * 开始之前共享的那张表只含落过盘的值,判定永远不会建立在一个没落过盘的值上(codex che-NM r2 [medium])。
@@ -199,14 +209,14 @@ export declare class LocalSessionStore implements SessionStore {
199
209
  * ENOENT(首次启动没有这份档)在调用点就被排除,压根到不了这里。
200
210
  */
201
211
  private refuseSidecar;
202
- /** `which` 点名是哪一只边档(S-690 起有三只 —— 此前这句恒写 lastActivity,title 边档的失败也被报成「recency 降级」)。
212
+ /** `which` 点名是哪一只边档([ref] 起有三只 —— 此前这句恒写 lastActivity,title 边档的失败也被报成「recency 降级」)。
203
213
  * 节流仍是本实例一只。 */
204
214
  private warnSidecar;
205
215
  acquire(sessionId?: string, opts?: {
206
216
  requireExisting?: boolean;
207
217
  }): Promise<AcquiredSession>;
208
218
  private load;
209
- /** 为这只会话打开它自己的存档,锁内一形(调用方持这只会话的写锁,见 {@link load})。S-612:这是「为这只会话打开它自己的存档」的那一次
219
+ /** 为这只会话打开它自己的存档,锁内一形(调用方持这只会话的写锁,见 {@link load})。[ref]:这是「为这只会话打开它自己的存档」的那一次
210
220
  * (引擎 prepare 的 acquire)⇒ 包在打开作用域里:这次回放跳过了记录 ⇒ 打开成功后铸一帧 `session.records_skipped` 投给这只会话(唯一铸点
211
221
  * 与作用域见 `session-records-skipped-notice.ts`);读不出(`corrupt_session`)照旧原样上抛,不铸。存档只读这一次:住客那一格缺(更早版本
212
222
  * 写下的会话)时,这次打开就是补铸的证明({@link handOut})。GUARD(open 腿):打开一只已存在的会话**不写属主** —— 记下的属主(含「登记为
@@ -216,7 +226,7 @@ export declare class LocalSessionStore implements SessionStore {
216
226
  * Idempotently record a session's owner — never overwrites a RECORDED owner (incl. a recorded `null`, "registered ownerless";
217
227
  * mirrors TiDBSessionStore.register's first-write rule). TiDB parity: register INSERTs a session_meta row so the session EXISTS
218
228
  * (forkable) even before its first acquire/run — so we also ensure an EMPTY repo session exists (open if present → never
219
- * overwrite history; create if not), else `ownerOf` would say a registered-but-never-acquired session exists while `fork` 404s it.
229
+ * overwrite history; create if not), else `headOf` would say a registered-but-never-acquired session exists while `fork` 404s it.
220
230
  *
221
231
  * 首写判据在写链里判(两只并发登记:先落盘的那一只赢,后一只不改、也不建会话)。一只**盘上已有、属主从没被记下**的会话
222
232
  * (边档那一格只有化身 —— 7.118.x 及更早写下的,或更早到连化身都没有)是一次性迁移 M10 的对象(窗口见 `plugins/one-time-migrations.ts`
@@ -225,27 +235,12 @@ export declare class LocalSessionStore implements SessionStore {
225
235
  * `REQUIRE_PRINCIPAL=true`,授权口也只在那时才把 principal 递过来认领(`security.ts` `createAuthorizer`)。
226
236
  */
227
237
  register(sessionId: string, owner: string | null): Promise<void>;
228
- /** Owner of a session: `null` if ownerless (registered ownerless, or an owner that was never recorded — a session written by
229
- * an earlier version), `undefined` if no such session (mirrors TiDBSessionStore.ownerOf). Reads {@link metaOf}: the persisted
230
- * cell, so the answer survives a restart exactly like the SQL twins' `session_meta.owner` column does. (Before 7.119.0 the
231
- * owner lived in a process-local Map and this method answered `null` for every session after a restart — the S3 fallback
232
- * "on disk ⇒ ownerless" kept the E21 delete working, but froze every owner-keyed session-policy rule.) */
233
- ownerOf(sessionId: string): Promise<string | null | undefined>;
234
- /** [ref] 六轮复审:owner+leafId 原子快照 —— 先读那一格,读 leaf,再同步复读那一格:格没了(读间被删)或换了主 / 换了住客 ⇒
235
- * undefined(调用方按删处理)。 */
236
- getHead(sessionId: string): Promise<{
237
- owner: string | null;
238
- leafId: string | null;
239
- } | undefined>;
240
238
  /** 2c P1d-β — re-stamp the session's owner WITHOUT rewriting entries (the staged-commit `identical` path: the log is
241
239
  * already present & equal, so only the owner needs re-stamping to the importing principal, §9). Persisted like every
242
240
  * owner write; the incarnation is untouched (same occupant). No cell (no such session) ⇒ no-op. Only caller:
243
241
  * {@link commitStagedImport}, inside the session's write lock. */
244
242
  private restampOwner;
245
243
  touch(sessionId: string): Promise<void>;
246
- /** E18 — the session's current leaf SessionTreeEntry.id (@see TiDBSessionStore.getLeafId). Reads the repo's storage
247
- * leaf (no acquire-lock; InMemory/File repo reads don't lock). null when the session doesn't exist / has no leaf. */
248
- getLeafId(sessionId: string): Promise<string | null>;
249
244
  /** Durable history is retained by the repo; just drop the in-flight cache entry (mirrors TiDBSessionStore.release). */
250
245
  release(sessionId: string): Promise<void>;
251
246
  /**
@@ -259,7 +254,7 @@ export declare class LocalSessionStore implements SessionStore {
259
254
  * - `firstActivityAt` — the session's `createdAt` (repo metadata).
260
255
  * - `lastActivityAt` — the touch marker (falls back to `createdAt`); the keyset sort key.
261
256
  * - `objectivePreview`— the last USER-text entry, synthesized from the session tree (no run ledger).
262
- * - `runCount`/`lastStatus`/`lastRunId`/`lastTaskRunId` — S-1371:read from the run store handed in (`runs`; the TiDB
257
+ * - `runCount`/`lastStatus`/`lastRunId`/`lastTaskRunId` — [ref]:read from the run store handed in (`runs`; the TiDB
263
258
  * twin LEFT-JOINs `task_run` for the same values, the run store's own `listSessions` is that
264
259
  * join's same-semantics projection — latest run by `created_at DESC, task_id DESC`, count of all,
265
260
  * `lastTaskRunId` = that run's `result.runId`). One call per list (not per row); a session with no
@@ -282,16 +277,16 @@ export declare class LocalSessionStore implements SessionStore {
282
277
  }): Promise<SessionSummary[]>;
283
278
  /** 列表行要读的边档一次装齐(lastActivity / 标题 / 置顶 / 会话元数据);各自记忆化,只有第一次真读盘。 */
284
279
  private loadRowSidecars;
285
- /** 列表行上的属主:那一格的属主(没有格 / 属主从没被记下 ⇒ null —— 与 `ownerOf` 同答;列表不补铸缺的格,`ownerOf` / `sessionFaceOf` 在第一次读时补)。 */
280
+ /** 列表行上的属主:那一格的属主(没有格 / 属主从没被记下 ⇒ null —— 与 `headOf(id)?.owner` 同答;列表不补铸缺的格,`headOf` 在第一次读时补)。 */
286
281
  private ownerCellOf;
287
282
  /** 一只会话的列表行 —— {@link listSessions} 与 {@link sessionSummaryOf} 的**同一只**合成(字段来源逐位见 listSessions 的头注)。调用方先 {@link loadRowSidecars}。 */
288
283
  private summaryOf;
289
- /** S-1371:run 店里每个会话的 run 投影(按 sessionId 索引)。
284
+ /** [ref]:run 店里每个会话的 run 投影(按 sessionId 索引)。
290
285
  * **一次读**:run 店的 `listSessions` 本来就按会话聚合全账(无会话过滤口),这里取全量再按会话仓的 id 查表 —— 比逐会话 N 次读便宜,
291
286
  * 也不在会话店里另存一份 run 账。读失败 ⇒ 抛(不吞成 `0 / ""`:那会把「读不到」说成「没跑过」)。 */
292
287
  private runRollups;
293
288
  /**
294
- * 一行里 run 身份与计数的**唯一出处**(S-1371,会话行四位一源):四位全读 {@link runRollups} 的投影(与 SQL 双生的 `task_run` rn=1 JOIN 同口径);
289
+ * 一行里 run 身份与计数的**唯一出处**([ref],会话行四位一源):四位全读 {@link runRollups} 的投影(与 SQL 双生的 `task_run` rn=1 JOIN 同口径);
295
290
  * 该会话没有 run 行 ⇒ `0` / `""` / `null`、`lastTaskRunId` 缺席(TiDB 的 `COALESCE(…,0)` / null→"" 映射)。在途的最新一条:`lastRunId` 在场(run 行建出来就有)、
296
291
  * `lastTaskRunId` 缺席(`result` 在终局与 park 时才写)。
297
292
  */
@@ -303,8 +298,9 @@ export declare class LocalSessionStore implements SessionStore {
303
298
  * 属主按 core `SessionStore.fork` 契约(core 7.54.0 `sessionStoreContract` 的 [ownership] 格,唯一读法 {@link forkOwnerOf}):显式串 ⇒ 该串;
304
299
  * 无参 / 显式 `null` ⇒ **源会话记下的属主**(一份有主历史的拷贝永不降成匿名 —— 匿名的拷贝谁都能认领);源会话没记属主 ⇒ 拷贝也不记(读作无主)。
305
300
  * 修前把参数原样写进新格:`fork(owned, null)` 铸出一份匿名的有主历史。
306
- * 🚧 已知分歧(不在本版收):拷的是整份日志,含在飞的 assistant 轮(契约:只拷**已提交**的叶)—— 剪在飞轮的判据只能是引擎的 `settledForkOptions`
307
- * (core 7.54.0 未导出,#2098 排在 7.55.0),本仓不写第二份;钉 `test/session-store-contract-kit.test.ts` 的 `it.fails` 格。 */
301
+ * 拷**已提交**的叶(契约):在飞的 assistant 轮不进孩子 —— 分叉点只有引擎那一只判官(core 7.55.0 起包根导出的 `settledForkOptions`),本店把唤醒出来的源会话交给它、
302
+ * 把它的答案原样交给引擎自己的 `repo.fork`(与 core 内存店 `TtlSessionStore.fork` 同一条调用链);两只 SQL 孪生同读它(`session-fork.ts`)。钉:
303
+ * core 店契约盒的 `[fork]` 格(`test/session-store-contract-kit.test.ts`)。 */
308
304
  fork(sourceId: string, owner?: string | null): Promise<string | null>;
309
305
  /** 2c session-sync — EXPORT a session's full durable entry log (core `SessionRepo.exportEntries`; the
310
306
  * in-memory/file repo holds the whole log so there is no floor to bypass). null if the source is unknown / the
@@ -372,14 +368,14 @@ export declare class LocalSessionStore implements SessionStore {
372
368
  deleteSession(sessionId: string, owner: string | null): Promise<boolean>;
373
369
  /**
374
370
  * {@link deleteSession} 的锁内一形(调用方持这只会话的写锁;换装 {@link replaceEntriesHeld} 也走它)。
375
- * 删的是 SQL 孪生 `session_meta` 那一行在本店的全部对位:会话存档、三只行边档(标题 / 置顶 / S-690 的指令来源基线)、属主 + 化身那一格。
371
+ * 删的是 SQL 孪生 `session_meta` 那一行在本店的全部对位:会话存档、三只行边档(标题 / 置顶 / [ref] 的指令来源基线)、属主 + 化身那一格。
376
372
  * 三只边档的那一键**都经各自的写链删**(`commit`:草稿上删、落盘、再发布 —— 与写它们的那一笔同一条链、同一把会话锁),落不了盘 ⇒ 抛:
377
373
  * 留在盘上的值会挂到同 id 的下一位住客身上(E21 的删除权残留)。元数据格**最后**删:三只边档任一只落不了而抛时,那一格还在 ⇒ 会话对属主门仍
378
374
  * 「在」,重发删除照样走得进来、收敛;反过来先删格,重发就成了 no-op,残留永远留下。
379
375
  * 🔴 hydrate FIRST (workflow audit 2026-07-13): after a restart the maps start empty — an un-hydrated delete would find nothing and
380
376
  * the sidecar would keep the value (an E21 right-to-delete residue that would RESURRECT onto a same-id re-import). ensureLoaded is
381
377
  * memoized — first caller pays, rest no-op.
382
- * S-790:化身随那一格消失(同 id 重登记铸新的 —— 那就是下一位住客)。
378
+ * [ref]:化身随那一格消失(同 id 重登记铸新的 —— 那就是下一位住客)。
383
379
  */
384
380
  private deleteSessionHeld;
385
381
  get size(): number;
@@ -1,7 +1,7 @@
1
1
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
2
2
  import { join, resolve } from "node:path";
3
3
  import { assertFirstOwnerWritable, forkOwnerOf } from "./session-ownership.js";
4
- import { FileSessionRepo, SessionError, StoredSession, validateEntriesForImport } from "@sema-agent/core";
4
+ import { FileSessionRepo, SessionError, StoredSession, settledForkOptions, validateEntriesForImport } from "@sema-agent/core";
5
5
  import { z } from "zod";
6
6
  import { contentForkRelation, fastForwardSharedContentDiverged, identicalIdsAlsoIdenticalContent } from "../session-sync-content.js";
7
7
  import { quarantineUnreadableSidecar } from "./local-sidecar-quarantine.js";
@@ -9,7 +9,7 @@ import { createZodColumnReader, decodeJsonColumn, readStringRecordColumn, SqlJso
9
9
  import { ONE_TIME_MIGRATIONS, migrationWindowOpen } from "./one-time-migrations.js";
10
10
  import { createLogger } from "../observability/logger.js";
11
11
  import { UNMANAGED_RETENTION } from "./retention-store-sql.js";
12
- import { carriedIncarnation, mintSessionIncarnation, sessionFaceFromRow } from "../session-incarnation.js";
12
+ import { UnreadableLeaf, carriedIncarnation, headFromRow, mintSessionIncarnation, sessionFaceFromRow } from "../session-incarnation.js";
13
13
  import { decodeInstructionSource, encodeInstructionSource, sameInstructionSourceBaseline } from "../instruction-source-notice.js";
14
14
  import { noteReplayInSessionOpenScope, openSessionForItself } from "../session-records-skipped-notice.js";
15
15
  import { createCorruptReadFailOpenSeat } from "../observability/corrupt-read-seat.js";
@@ -257,12 +257,16 @@ export class LocalSessionStore {
257
257
  const cell = this.meta.state.entries.get(sessionId);
258
258
  return cell === undefined ? undefined : readSessionMetaCell(cell);
259
259
  }
260
- async sessionFaceOf(sessionId) {
261
- const meta = await this.metaOf(sessionId);
262
- return meta === undefined ? undefined : sessionFaceFromRow(sessionId, meta.owner ?? null, meta.incarnation);
263
- }
264
- async incarnationOf(sessionId) {
265
- return (await this.sessionFaceOf(sessionId))?.incarnation;
260
+ async headOf(sessionId) {
261
+ const before = await this.metaOf(sessionId);
262
+ if (before === undefined)
263
+ return undefined;
264
+ const leaf = await this.repo.headOf(sessionId).then((archive) => archive?.leafId ?? null, (fault) => new UnreadableLeaf(fault));
265
+ const cell = this.meta.state.entries.get(sessionId);
266
+ const after = cell === undefined ? undefined : readSessionMetaCell(cell);
267
+ if (after === undefined || after.incarnation !== before.incarnation || (after.owner ?? null) !== (before.owner ?? null))
268
+ return undefined;
269
+ return headFromRow(sessionId, before.owner ?? null, before.incarnation, leaf);
266
270
  }
267
271
  async handOut(sessionId, session) {
268
272
  const meta = await this.cellOfPresent(sessionId);
@@ -476,21 +480,6 @@ export class LocalSessionStore {
476
480
  this.log.info("session_owner_claimed", { sessionId });
477
481
  });
478
482
  }
479
- async ownerOf(sessionId) {
480
- const meta = await this.metaOf(sessionId);
481
- return meta === undefined ? undefined : (meta.owner ?? null);
482
- }
483
- async getHead(sessionId) {
484
- const before = await this.metaOf(sessionId);
485
- if (before === undefined)
486
- return undefined;
487
- const leafId = await this.getLeafId(sessionId);
488
- const cell = this.meta.state.entries.get(sessionId);
489
- const after = cell === undefined ? undefined : readSessionMetaCell(cell);
490
- if (after === undefined || after.incarnation !== before.incarnation || (after.owner ?? null) !== (before.owner ?? null))
491
- return undefined;
492
- return { owner: before.owner ?? null, leafId };
493
- }
494
483
  async restampOwner(sessionId, owner) {
495
484
  await this.writeMeta(sessionId, (before) => (before === undefined ? undefined : { incarnation: readSessionMetaCell(before).incarnation, owner }));
496
485
  }
@@ -498,17 +487,6 @@ export class LocalSessionStore {
498
487
  this.lastActivity.set(sessionId, new Date().toISOString());
499
488
  this.scheduleFlush();
500
489
  }
501
- async getLeafId(sessionId) {
502
- try {
503
- const session = await this.repo.open({ id: sessionId, createdAt: "" });
504
- return (await session.getStorage().getLeafId()) ?? null;
505
- }
506
- catch (e) {
507
- if (isNotFound(e))
508
- return null;
509
- throw e;
510
- }
511
- }
512
490
  async release(sessionId) {
513
491
  this.pending.delete(sessionId);
514
492
  }
@@ -586,7 +564,9 @@ export class LocalSessionStore {
586
564
  const source = this.meta.state.entries.get(sourceId);
587
565
  const forkOwner = forkOwnerOf(owner, source === undefined ? undefined : readSessionMetaCell(source).owner);
588
566
  try {
589
- const session = await this.repo.fork({ id: sourceId, createdAt: "" }, {});
567
+ const sourceMeta = { id: sourceId, createdAt: "" };
568
+ const forkOptions = await settledForkOptions(await this.repo.open(sourceMeta));
569
+ const session = await this.repo.fork(sourceMeta, forkOptions);
590
570
  const id = (await session.getMetadata()).id;
591
571
  await this.writeMeta(id, () => (forkOwner === undefined ? mintSessionIncarnation() : { incarnation: mintSessionIncarnation(), owner: forkOwner }));
592
572
  return id;
@@ -684,9 +664,10 @@ export class LocalSessionStore {
684
664
  else {
685
665
  await this.restampOwner(sessionId, owner);
686
666
  }
687
- const face = await this.sessionFaceOf(sessionId);
688
- if (face === undefined)
667
+ const meta = await this.metaOf(sessionId);
668
+ if (meta === undefined)
689
669
  throw new SessionError("storage", `LocalSessionStore: staged commit for session ${sessionId} left no session face — nothing was settled`);
670
+ const face = sessionFaceFromRow(sessionId, meta.owner ?? null, meta.incarnation);
690
671
  return { relation: rel.relation, face };
691
672
  });
692
673
  }
@@ -694,8 +675,8 @@ export class LocalSessionStore {
694
675
  return this.withSessionWriteLock(sessionId, () => this.deleteSessionHeld(sessionId, owner));
695
676
  }
696
677
  async deleteSessionHeld(sessionId, owner) {
697
- const current = await this.ownerOf(sessionId);
698
- if (current === undefined || !ownerEq(current, owner))
678
+ const current = await this.metaOf(sessionId);
679
+ if (current === undefined || !ownerEq(current.owner ?? null, owner))
699
680
  return false;
700
681
  try {
701
682
  await this.repo.delete({ id: sessionId, createdAt: "" });
@@ -19,7 +19,7 @@
19
19
  * ## Cost: one linear walk, the engine's
20
20
  * The branch is core's own `getPathToRoot` over the whole log (the walk every engine read of a local session makes, with its stop
21
21
  * rules: an entry without a parent ends it, a parent the log does not hold is `invalid_session`, an unknown leaf is `not_found`).
22
- * Since core 7.54.0 (#2092) that walk is linear; before, it built the path with `unshift` (quadratic — seconds on a long session, on
22
+ * Since core 7.54.0 ([ref]) that walk is linear; before, it built the path with `unshift` (quadratic — seconds on a long session, on
23
23
  * the event loop) and this module walked the `parentId` chain itself. The second walker is retired: the view reads the branch the
24
24
  * engine reads, by the engine's reading. Every later read of the window goes through the same walk, bounded by the floor.
25
25
  * A parent CYCLE (a corrupted log; the engine never writes one) is refused by that same walk: since core 7.54.1 it carries one
@@ -44,14 +44,14 @@ export declare function mailboxKeyDeleteSql(dialect: "tidb" | "pg", table: Mailb
44
44
  /** 店侧日志座(可选;boot 注入 `Logger`)。7.58.0 合并重扫 [medium]:坏行的 fail-closed 抛必须**响亮**——core 唯一的
45
45
  * claimLease 调用方(peer-session-drain)吞掉该错,店不记这一笔就成了「静默永久卡箱」。抛之前记
46
46
  * `mailbox_message_column_corrupt`(scope/handle/seq/column/code),运维按 seq 修行。
47
- * 🔴 S-550 车③a **改名并归一**:旧事件名 `mailbox_peer_meta_corrupt` 在 `hop_chain` 也变成 fail-closed 的
47
+ * 🔴 [ref] 车③a **改名并归一**:旧事件名 `mailbox_peer_meta_corrupt` 在 `hop_chain` 也变成 fail-closed 的
48
48
  * 那一刻就说不出真话了(同一条读腿两列同判)。一个事件 + 一个 `column` 字段,而不是两个事件名 —— 运维
49
49
  * 面按 column 分桶,店里只有一条留痕规则。 */
50
50
  export interface MailboxStoreLogger {
51
51
  warn(event: string, fields: Record<string, unknown>): void;
52
52
  }
53
53
  export declare function ensureTiDBMailboxSchema(pool: MySqlPool): Promise<void>;
54
- /** S-287:本 store 的索引**声明**(两方言共用一份)。PG 侧由下面的 `ensurePgMailboxSchema` 应用,MySQL 侧由 `tidb-pool.ts` 的中央 `ensureSchema` 应用(那里内联 `KEY` 已在 `CREATE TABLE` 里 ⇒ 新建库探到即零 DDL,存量库缺谁补谁)。加索引以外的 schema 变更仍归运维,见 `plugins/ensure-index.ts` 头注。 */
54
+ /** [ref]:本 store 的索引**声明**(两方言共用一份)。PG 侧由下面的 `ensurePgMailboxSchema` 应用,MySQL 侧由 `tidb-pool.ts` 的中央 `ensureSchema` 应用(那里内联 `KEY` 已在 `CREATE TABLE` 里 ⇒ 新建库探到即零 DDL,存量库缺谁补谁)。加索引以外的 schema 变更仍归运维,见 `plugins/ensure-index.ts` 头注。 */
55
55
  export declare const MAILBOX_INDEXES: readonly IndexSpec[];
56
56
  export declare function ensurePgMailboxSchema(q: (text: string, params?: unknown[]) => Promise<unknown>): Promise<void>;
57
57
  export declare class TiDBMailboxStore implements MailboxStore, MailboxRecipientLifecycle {
@@ -17,7 +17,7 @@ export interface PgMemoryEngineSchemaOptions {
17
17
  pgvector?: boolean;
18
18
  };
19
19
  }
20
- /** S-287:记忆引擎 PG 面的索引**声明**(MySQL 孪生是 `memory-engine-tidb.ts` 的内联 `KEY`/`UNIQUE KEY`,
20
+ /** [ref]:记忆引擎 PG 面的索引**声明**(MySQL 孪生是 `memory-engine-tidb.ts` 的内联 `KEY`/`UNIQUE KEY`,
21
21
  * 由 `tidb-pool.ts` 的中央 `ensureSchema` 用同一份声明补存量库)。 */
22
22
  export declare const MEMORY_ENGINE_INDEXES: readonly IndexSpec[];
23
23
  /** Idempotent DDL for the entry plane. Call once at startup (or run through your migration tool). */
@@ -73,10 +73,10 @@ export declare class MemoryRunStore implements InProcessClaimFence {
73
73
  * offered) → the terminal row → the active-run slot release. Returns whether the pending row is now this run's. */
74
74
  private writeTerminal;
75
75
  /** Durable F4: park NON-terminal `suspended`, KEEP the task_active claim. CAS on running/suspended (reaper-revert guard).
76
- * S-173:同时落 `result` —— 封口脱敏后的投影(`sealRunRowResult`,凭据不落;`null` = 没观察到 park 结果),SQL 孪生同注。 */
76
+ * [ref]:同时落 `result` —— 封口脱敏后的投影(`sealRunRowResult`,凭据不落;`null` = 没观察到 park 结果),SQL 孪生同注。 */
77
77
  setSuspended(taskId: string, result: PersistedTaskResult | null): Promise<void>;
78
78
  /** [ref] D-B: park NON-terminal `needs_review`, KEEP the claim. CAS on running/needs_review.
79
- * S-173:同 {@link setSuspended} 落封口脱敏后的 `result`。 */
79
+ * [ref]:同 {@link setSuspended} 落封口脱敏后的 `result`。 */
80
80
  setNeedsReview(taskId: string, result: PersistedTaskResult | null): Promise<void>;
81
81
  /** Durable F4 resume: flip suspended/needs_review → running (CAS) + reset cancel/preempt flags.
82
82
  * [ref](codex R1 [medium]):认领 = 接管 `instanceId`(= 当前持有副本;SQL 孪生同注)。CAS 输不改。 */
@@ -88,7 +88,7 @@ export declare class MemoryRunStore implements InProcessClaimFence {
88
88
  /** Runs newest-first, keyset on (createdAt, taskId) DESC; optional exact-match filters (owner is exact, like the SQL). */
89
89
  listRuns(opts: RunListQuery): Promise<RunRecord[]>;
90
90
  /**
91
- * S-297 —— 这个会话**最近一条腿**的窄指针({@link SqlRunStore.latestRunForSession} 的孪生:同一个排序口径
91
+ * [ref] —— 这个会话**最近一条腿**的窄指针({@link SqlRunStore.latestRunForSession} 的孪生:同一个排序口径
92
92
  * `createdAt DESC, taskId DESC`,与本店 {@link MemoryRunStore.listSessions} 挑 `rn=1` 那一行的比较器逐字同一份)。
93
93
  */
94
94
  latestRunForSession(sessionId: string): Promise<LatestRunRef | undefined>;
@@ -135,7 +135,7 @@ export declare class MemoryRunStore implements InProcessClaimFence {
135
135
  /** Fail stale `running` rows (crashed-run backstop) + release task_active for any now-terminal row. */
136
136
  reapStale(olderThanMs: number): Promise<number>;
137
137
  /** [ref] shared tail of both suspended-run reapers: flip one parked row → failed('approval.expired'), the
138
- * in-memory twin of the SQL UPDATE (`error`/`error_code` set directly — no result blob to derive from; S-173: the park-time `result` is cleared, same as the SQL `result = NULL`). */
138
+ * in-memory twin of the SQL UPDATE (`error`/`error_code` set directly — no result blob to derive from; [ref]: the park-time `result` is cleared, same as the SQL `result = NULL`). */
139
139
  private failExpiredPark;
140
140
  /** Release the claim for TERMINAL rows only — suspended/needs_review keep it (the `DELETE ta … WHERE tr.status
141
141
  * NOT IN ('running','suspended','needs_review')` twin, shared by reapStale + the [ref] suspended reapers). */
@@ -46,14 +46,14 @@ export interface MemorySyncStore {
46
46
  /** Transient failure: attempts+1 (SQL-atomic), record the error, schedule the next attempt. */
47
47
  fail(id: string, error: string, nextAttemptAtMs: number): Promise<void>;
48
48
  }
49
- /** S-287:push queue 的索引**声明**(MySQL 孪生 = `memory-sync-store-tidb.ts` 的内联 `KEY`)。 */
49
+ /** [ref]:push queue 的索引**声明**(MySQL 孪生 = `memory-sync-store-tidb.ts` 的内联 `KEY`)。 */
50
50
  export declare const MEMORY_SYNC_INDEXES: readonly IndexSpec[];
51
51
  /** Idempotent DDL for the sync plane (PG dialect). Call once at startup. */
52
52
  export declare function ensurePgMemorySyncSchema(query: PgQueryFn): Promise<void>;
53
53
  /**
54
54
  * 本店三只 JSON 承载列的**折码点**(唯一)—— 本店没有枚举式 corrupt 码,既有的「读不出来」口径就是
55
55
  * 响亮抛(`claimLeaseMs` 守卫 / dup id 一律 fail-loud)⇒ 折成响亮裸 `Error`,点名 `<表>.<列>` + 行标识
56
- * (S-550 车①② 裁定,沿用;不新铸码)。两个孪生共用本函数(MySQL 腿 import 它 —— 一条折码规则一个写者)。
56
+ * ([ref] 车①② 裁定,沿用;不新铸码)。两个孪生共用本函数(MySQL 腿 import 它 —— 一条折码规则一个写者)。
57
57
  */
58
58
  export declare function refusingMemorySyncRow<T>(read: () => T): T;
59
59
  /** Options for {@link PgMemorySyncStore}. */
@@ -115,7 +115,7 @@ export interface MemoryHistoryStore {
115
115
  /** Ops read face (§1.3 保留策略: v1 无界 + 运维计数 — quota/pruning waits for a demand signal). */
116
116
  countByScope(scope: string): Promise<number>;
117
117
  }
118
- /** S-287:history 表的索引**声明**(MySQL 孪生 = `memory-sync-store-tidb.ts` 的内联 `KEY`)。 */
118
+ /** [ref]:history 表的索引**声明**(MySQL 孪生 = `memory-sync-store-tidb.ts` 的内联 `KEY`)。 */
119
119
  export declare const MEMORY_HISTORY_INDEXES: readonly IndexSpec[];
120
120
  /** Idempotent DDL for the history table (PG dialect). Separate from the sync-plane ensure so S5.1
121
121
  * can wire the write point independently of the S4 sync wiring. */