@proofoftech/flowsafe 0.4.0 → 0.7.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 (271) hide show
  1. package/CHANGELOG.md +327 -0
  2. package/README.md +295 -251
  3. package/dist/agent-runner/approval-shapes.d.ts +36 -0
  4. package/dist/agent-runner/approval-shapes.d.ts.map +1 -0
  5. package/dist/agent-runner/approval-shapes.js +101 -0
  6. package/dist/agent-runner/approval-shapes.js.map +1 -0
  7. package/dist/agent-runner/durable-agent-runner.d.ts +158 -0
  8. package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -0
  9. package/dist/agent-runner/durable-agent-runner.js +295 -0
  10. package/dist/agent-runner/durable-agent-runner.js.map +1 -0
  11. package/dist/agent-runner/index.d.ts +3 -0
  12. package/dist/agent-runner/index.d.ts.map +1 -0
  13. package/dist/agent-runner/index.js +10 -0
  14. package/dist/agent-runner/index.js.map +1 -0
  15. package/dist/approval-api/contract.d.ts +2 -2
  16. package/dist/approval-api/d1-store.d.ts.map +1 -1
  17. package/dist/approval-api/d1-store.js +87 -19
  18. package/dist/approval-api/d1-store.js.map +1 -1
  19. package/dist/approval-api/grants.d.ts +1 -1
  20. package/dist/approval-api/grants.js +1 -1
  21. package/dist/approval-api/index.d.ts +1 -1
  22. package/dist/approval-api/index.d.ts.map +1 -1
  23. package/dist/approval-api/index.js.map +1 -1
  24. package/dist/approval-api/router.d.ts +2 -2
  25. package/dist/approval-api/router.d.ts.map +1 -1
  26. package/dist/approval-api/router.js +1 -0
  27. package/dist/approval-api/router.js.map +1 -1
  28. package/dist/approval-api/service.d.ts +10 -11
  29. package/dist/approval-api/service.d.ts.map +1 -1
  30. package/dist/approval-api/service.js +22 -9
  31. package/dist/approval-api/service.js.map +1 -1
  32. package/dist/approval-api/store.d.ts +27 -22
  33. package/dist/approval-api/store.d.ts.map +1 -1
  34. package/dist/approval-api/store.js +25 -9
  35. package/dist/approval-api/store.js.map +1 -1
  36. package/dist/approval-api/tenant-context.d.ts +6 -6
  37. package/dist/approval-api/tenant-context.d.ts.map +1 -1
  38. package/dist/approval-api/tenant-context.js +15 -0
  39. package/dist/approval-api/tenant-context.js.map +1 -1
  40. package/dist/approval-api/tenant-store.d.ts +1 -1
  41. package/dist/approval-api/tenant-store.d.ts.map +1 -1
  42. package/dist/approval-api/types.d.ts +13 -4
  43. package/dist/approval-api/types.d.ts.map +1 -1
  44. package/dist/approval-api/types.js +2 -1
  45. package/dist/approval-api/types.js.map +1 -1
  46. package/dist/approval-ui/App.d.ts +2 -2
  47. package/dist/approval-ui/FilterBar.d.ts +3 -3
  48. package/dist/approval-ui/FilterBar.js +3 -3
  49. package/dist/approval-ui/client.d.ts +1 -1
  50. package/dist/approval-ui/components.d.ts +1 -1
  51. package/dist/approval-ui/stream.d.ts +3 -3
  52. package/dist/approval-ui/stream.js +2 -2
  53. package/dist/approval-ui/use-approval-dashboard.d.ts +9 -12
  54. package/dist/approval-ui/use-approval-dashboard.d.ts.map +1 -1
  55. package/dist/approval-ui/use-approval-dashboard.js +6 -9
  56. package/dist/approval-ui/use-approval-dashboard.js.map +1 -1
  57. package/dist/approval-ui/use-web-socket-transport.d.ts +1 -1
  58. package/dist/approval-ui/use-web-socket-transport.js +1 -1
  59. package/dist/background-tasks/d1-storage.d.ts +66 -0
  60. package/dist/background-tasks/d1-storage.d.ts.map +1 -0
  61. package/dist/background-tasks/d1-storage.js +196 -0
  62. package/dist/background-tasks/d1-storage.js.map +1 -0
  63. package/dist/background-tasks/host.d.ts +82 -0
  64. package/dist/background-tasks/host.d.ts.map +1 -0
  65. package/dist/background-tasks/host.js +275 -0
  66. package/dist/background-tasks/host.js.map +1 -0
  67. package/dist/background-tasks/index.d.ts +7 -0
  68. package/dist/background-tasks/index.d.ts.map +1 -0
  69. package/dist/background-tasks/index.js +10 -0
  70. package/dist/background-tasks/index.js.map +1 -0
  71. package/dist/background-tasks/routes.d.ts +15 -0
  72. package/dist/background-tasks/routes.d.ts.map +1 -0
  73. package/dist/background-tasks/routes.js +144 -0
  74. package/dist/background-tasks/routes.js.map +1 -0
  75. package/dist/do-runner/breakwater-keys.d.ts +1 -1
  76. package/dist/do-runner/breakwater-keys.js +1 -1
  77. package/dist/do-runner/cf-types.d.ts +1 -1
  78. package/dist/do-runner/d1-storage.d.ts +347 -5
  79. package/dist/do-runner/d1-storage.d.ts.map +1 -1
  80. package/dist/do-runner/d1-storage.js +571 -17
  81. package/dist/do-runner/d1-storage.js.map +1 -1
  82. package/dist/do-runner/do-error-response.d.ts +29 -0
  83. package/dist/do-runner/do-error-response.d.ts.map +1 -0
  84. package/dist/do-runner/do-error-response.js +73 -0
  85. package/dist/do-runner/do-error-response.js.map +1 -0
  86. package/dist/do-runner/durable-object.d.ts +3 -3
  87. package/dist/do-runner/durable-object.d.ts.map +1 -1
  88. package/dist/do-runner/durable-object.js +7 -21
  89. package/dist/do-runner/durable-object.js.map +1 -1
  90. package/dist/do-runner/hub-do.d.ts +2 -2
  91. package/dist/do-runner/index.d.ts +9 -3
  92. package/dist/do-runner/index.d.ts.map +1 -1
  93. package/dist/do-runner/index.js +8 -2
  94. package/dist/do-runner/index.js.map +1 -1
  95. package/dist/do-runner/init.d.ts +20 -0
  96. package/dist/do-runner/init.d.ts.map +1 -1
  97. package/dist/do-runner/init.js +12 -1
  98. package/dist/do-runner/init.js.map +1 -1
  99. package/dist/do-runner/memory-id.d.ts +3 -3
  100. package/dist/do-runner/memory-id.js +3 -3
  101. package/dist/do-runner/path-safe-id.d.ts +6 -6
  102. package/dist/do-runner/path-safe-id.js +6 -6
  103. package/dist/do-runner/pubsub.d.ts +18 -0
  104. package/dist/do-runner/pubsub.d.ts.map +1 -0
  105. package/dist/do-runner/pubsub.js +42 -0
  106. package/dist/do-runner/pubsub.js.map +1 -0
  107. package/dist/do-runner/runtime.d.ts +24 -1
  108. package/dist/do-runner/runtime.d.ts.map +1 -1
  109. package/dist/do-runner/runtime.js +28 -2
  110. package/dist/do-runner/runtime.js.map +1 -1
  111. package/dist/do-runner/thread-do.d.ts +74 -0
  112. package/dist/do-runner/thread-do.d.ts.map +1 -0
  113. package/dist/do-runner/thread-do.js +156 -0
  114. package/dist/do-runner/thread-do.js.map +1 -0
  115. package/dist/do-runner/thread-header.d.ts +16 -0
  116. package/dist/do-runner/thread-header.d.ts.map +1 -0
  117. package/dist/do-runner/thread-header.js +24 -0
  118. package/dist/do-runner/thread-header.js.map +1 -0
  119. package/dist/goals/index.d.ts +2 -0
  120. package/dist/goals/index.d.ts.map +1 -0
  121. package/dist/goals/index.js +7 -0
  122. package/dist/goals/index.js.map +1 -0
  123. package/dist/goals/objective-routes.d.ts +87 -0
  124. package/dist/goals/objective-routes.d.ts.map +1 -0
  125. package/dist/goals/objective-routes.js +375 -0
  126. package/dist/goals/objective-routes.js.map +1 -0
  127. package/dist/host-kit/approval-bridge.d.ts +28 -8
  128. package/dist/host-kit/approval-bridge.d.ts.map +1 -1
  129. package/dist/host-kit/approval-bridge.js +37 -15
  130. package/dist/host-kit/approval-bridge.js.map +1 -1
  131. package/dist/host-kit/bearer-auth.d.ts +1 -1
  132. package/dist/host-kit/bearer-auth.js +1 -1
  133. package/dist/host-kit/env-vars.d.ts +20 -0
  134. package/dist/host-kit/env-vars.d.ts.map +1 -1
  135. package/dist/host-kit/env-vars.js +30 -0
  136. package/dist/host-kit/env-vars.js.map +1 -1
  137. package/dist/host-kit/flowsafe-worker.d.ts +113 -6
  138. package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
  139. package/dist/host-kit/flowsafe-worker.js +253 -63
  140. package/dist/host-kit/flowsafe-worker.js.map +1 -1
  141. package/dist/host-kit/host-approval-service.d.ts +13 -13
  142. package/dist/host-kit/host-approval-service.js +10 -10
  143. package/dist/host-kit/index.d.ts +3 -1
  144. package/dist/host-kit/index.d.ts.map +1 -1
  145. package/dist/host-kit/index.js +7 -0
  146. package/dist/host-kit/index.js.map +1 -1
  147. package/dist/host-kit/memory-boundary.d.ts +64 -0
  148. package/dist/host-kit/memory-boundary.d.ts.map +1 -0
  149. package/dist/host-kit/memory-boundary.js +109 -0
  150. package/dist/host-kit/memory-boundary.js.map +1 -0
  151. package/dist/host-kit/route-path.d.ts +17 -0
  152. package/dist/host-kit/route-path.d.ts.map +1 -0
  153. package/dist/host-kit/route-path.js +35 -0
  154. package/dist/host-kit/route-path.js.map +1 -0
  155. package/dist/host-kit/run-router.d.ts +10 -11
  156. package/dist/host-kit/run-router.d.ts.map +1 -1
  157. package/dist/host-kit/run-router.js.map +1 -1
  158. package/dist/host-kit/stream-router.d.ts +1 -1
  159. package/dist/host-kit/stream-router.d.ts.map +1 -1
  160. package/dist/host-kit/stream-ticket.d.ts +3 -3
  161. package/dist/host-kit/stream-ticket.d.ts.map +1 -1
  162. package/dist/host-kit/stream-ticket.js +1 -1
  163. package/dist/host-kit/tenant-registry.d.ts +1 -1
  164. package/dist/host-kit/tenant-registry.js +1 -1
  165. package/dist/host-kit/thread-topology.d.ts +44 -0
  166. package/dist/host-kit/thread-topology.d.ts.map +1 -0
  167. package/dist/host-kit/thread-topology.js +76 -0
  168. package/dist/host-kit/thread-topology.js.map +1 -0
  169. package/dist/host-kit/verifier.d.ts +1 -1
  170. package/dist/host-kit/verifier.js +1 -1
  171. package/dist/index.d.ts +4 -8
  172. package/dist/index.d.ts.map +1 -1
  173. package/dist/index.js +4 -4
  174. package/dist/index.js.map +1 -1
  175. package/dist/internal-error-response.d.ts +3 -0
  176. package/dist/internal-error-response.d.ts.map +1 -0
  177. package/dist/internal-error-response.js +20 -0
  178. package/dist/internal-error-response.js.map +1 -0
  179. package/dist/numeric-config.d.ts +4 -0
  180. package/dist/numeric-config.d.ts.map +1 -0
  181. package/dist/numeric-config.js +23 -0
  182. package/dist/numeric-config.js.map +1 -0
  183. package/dist/schedules/index.d.ts +5 -0
  184. package/dist/schedules/index.d.ts.map +1 -0
  185. package/dist/schedules/index.js +13 -0
  186. package/dist/schedules/index.js.map +1 -0
  187. package/dist/schedules/router.d.ts +66 -0
  188. package/dist/schedules/router.d.ts.map +1 -0
  189. package/dist/schedules/router.js +827 -0
  190. package/dist/schedules/router.js.map +1 -0
  191. package/dist/schedules/schedules-d1.d.ts +30 -0
  192. package/dist/schedules/schedules-d1.d.ts.map +1 -0
  193. package/dist/schedules/schedules-d1.js +374 -0
  194. package/dist/schedules/schedules-d1.js.map +1 -0
  195. package/dist/schedules/storage.d.ts +11 -0
  196. package/dist/schedules/storage.d.ts.map +1 -0
  197. package/dist/schedules/storage.js +34 -0
  198. package/dist/schedules/storage.js.map +1 -0
  199. package/dist/schedules/tick.d.ts +132 -0
  200. package/dist/schedules/tick.d.ts.map +1 -0
  201. package/dist/schedules/tick.js +598 -0
  202. package/dist/schedules/tick.js.map +1 -0
  203. package/dist/signal-providers/delivery.d.ts +24 -0
  204. package/dist/signal-providers/delivery.d.ts.map +1 -0
  205. package/dist/signal-providers/delivery.js +62 -0
  206. package/dist/signal-providers/delivery.js.map +1 -0
  207. package/dist/signal-providers/github-provider.d.ts +33 -0
  208. package/dist/signal-providers/github-provider.d.ts.map +1 -0
  209. package/dist/signal-providers/github-provider.js +116 -0
  210. package/dist/signal-providers/github-provider.js.map +1 -0
  211. package/dist/signal-providers/host-do.d.ts +81 -0
  212. package/dist/signal-providers/host-do.d.ts.map +1 -0
  213. package/dist/signal-providers/host-do.js +229 -0
  214. package/dist/signal-providers/host-do.js.map +1 -0
  215. package/dist/signal-providers/host-topology.d.ts +27 -0
  216. package/dist/signal-providers/host-topology.d.ts.map +1 -0
  217. package/dist/signal-providers/host-topology.js +36 -0
  218. package/dist/signal-providers/host-topology.js.map +1 -0
  219. package/dist/signal-providers/index.d.ts +8 -0
  220. package/dist/signal-providers/index.d.ts.map +1 -0
  221. package/dist/signal-providers/index.js +21 -0
  222. package/dist/signal-providers/index.js.map +1 -0
  223. package/dist/signal-providers/provider.d.ts +93 -0
  224. package/dist/signal-providers/provider.d.ts.map +1 -0
  225. package/dist/signal-providers/provider.js +89 -0
  226. package/dist/signal-providers/provider.js.map +1 -0
  227. package/dist/signal-providers/subscription-d1.d.ts +88 -0
  228. package/dist/signal-providers/subscription-d1.d.ts.map +1 -0
  229. package/dist/signal-providers/subscription-d1.js +259 -0
  230. package/dist/signal-providers/subscription-d1.js.map +1 -0
  231. package/dist/signal-providers/webhook-route.d.ts +96 -0
  232. package/dist/signal-providers/webhook-route.d.ts.map +1 -0
  233. package/dist/signal-providers/webhook-route.js +444 -0
  234. package/dist/signal-providers/webhook-route.js.map +1 -0
  235. package/dist/signals/client.d.ts +72 -0
  236. package/dist/signals/client.d.ts.map +1 -0
  237. package/dist/signals/client.js +87 -0
  238. package/dist/signals/client.js.map +1 -0
  239. package/dist/signals/d1-shared.d.ts +43 -0
  240. package/dist/signals/d1-shared.d.ts.map +1 -0
  241. package/dist/signals/d1-shared.js +46 -0
  242. package/dist/signals/d1-shared.js.map +1 -0
  243. package/dist/signals/index.d.ts +9 -0
  244. package/dist/signals/index.d.ts.map +1 -0
  245. package/dist/signals/index.js +15 -0
  246. package/dist/signals/index.js.map +1 -0
  247. package/dist/signals/notification-dispatch.d.ts +52 -0
  248. package/dist/signals/notification-dispatch.d.ts.map +1 -0
  249. package/dist/signals/notification-dispatch.js +198 -0
  250. package/dist/signals/notification-dispatch.js.map +1 -0
  251. package/dist/signals/notifications-d1.d.ts +27 -0
  252. package/dist/signals/notifications-d1.d.ts.map +1 -0
  253. package/dist/signals/notifications-d1.js +703 -0
  254. package/dist/signals/notifications-d1.js.map +1 -0
  255. package/dist/signals/router.d.ts +73 -0
  256. package/dist/signals/router.d.ts.map +1 -0
  257. package/dist/signals/router.js +240 -0
  258. package/dist/signals/router.js.map +1 -0
  259. package/dist/signals/storage.d.ts +11 -0
  260. package/dist/signals/storage.d.ts.map +1 -0
  261. package/dist/signals/storage.js +27 -0
  262. package/dist/signals/storage.js.map +1 -0
  263. package/dist/signals/thread-do-routes.d.ts +82 -0
  264. package/dist/signals/thread-do-routes.d.ts.map +1 -0
  265. package/dist/signals/thread-do-routes.js +660 -0
  266. package/dist/signals/thread-do-routes.js.map +1 -0
  267. package/dist/signals/thread-state-d1.d.ts +22 -0
  268. package/dist/signals/thread-state-d1.d.ts.map +1 -0
  269. package/dist/signals/thread-state-d1.js +83 -0
  270. package/dist/signals/thread-state-d1.js.map +1 -0
  271. package/package.json +11 -2
@@ -1,4 +1,4 @@
1
- import { D1Store } from '@mastra/cloudflare-d1';
1
+ import { MastraCompositeStore, type MastraStorageDomains } from '@mastra/core/storage';
2
2
  import type { D1DatabaseBinding } from './cf-types.js';
3
3
  export interface D1StorageOptions {
4
4
  /** D1 binding from the Worker/DO environment. */
@@ -7,8 +7,17 @@ export interface D1StorageOptions {
7
7
  id?: string;
8
8
  /** Table name prefix (letters, numbers, underscores). */
9
9
  tablePrefix?: string;
10
+ /**
11
+ * Additional storage domains composed over the D1Store default, such as
12
+ * notifications and thread state, which @mastra/cloudflare-d1 does not ship, so
13
+ * they are flowsafe-owned D1 impls). Injected rather than imported so this
14
+ * lower layer never depends on `signals/` (which imports do-runner) — build
15
+ * them with `createSignalStorageDomains()` and pass them here. Absent ⇒ the
16
+ * bare D1Store, byte-identical to before this seam existed.
17
+ */
18
+ domains?: MastraStorageDomains;
10
19
  }
11
- export declare function createD1Storage(options: D1StorageOptions): D1Store;
20
+ export declare function createD1Storage(options: D1StorageOptions): MastraCompositeStore;
12
21
  /**
13
22
  * Minimal structural D1 surface the purge uses — same posture as the
14
23
  * approval store: tests back it with node:sqlite, Workers pass env.DB.
@@ -56,6 +65,17 @@ export interface PurgeExpiredRunsOptions {
56
65
  /** Clock override for tests. */
57
66
  now?: () => number;
58
67
  }
68
+ /**
69
+ * The tables `purgeExpiredWorkflowRuns` deletes from under the run TTL — the
70
+ * production anchor the schema guard cross-checks every `run-ttl` retention
71
+ * declaration against, the retention counterpart of
72
+ * TENANT_RANGE_PURGE_TABLES for the offboarding leg. One table, because the run
73
+ * TTL rides a `run_id` range paired with artifact deletion and an app-owned
74
+ * index (its own block below), not the tenant-range map. The guard reads THIS,
75
+ * not a literal copied into the test, so a purge that changes what it targets
76
+ * and a guard that still blesses the old set cannot drift apart silently.
77
+ */
78
+ export declare const RUN_TTL_PURGE_TABLES: readonly string[];
59
79
  /**
60
80
  * Data-retention purge: deletes TERMINAL runs (success/failed/tripwire/
61
81
  * canceled/bailed/skipped) whose updatedAt is older than the TTL from
@@ -68,6 +88,247 @@ export interface PurgeExpiredRunsOptions {
68
88
  * DO alarm) stays with the caller. Returns the number of deleted rows.
69
89
  */
70
90
  export declare function purgeExpiredWorkflowRuns(db: SnapshotDatabase, options: PurgeExpiredRunsOptions): Promise<number>;
91
+ export interface PurgeExpiredThreadsOptions {
92
+ /** Threads untouched for longer than this are eligible, with their messages. */
93
+ ttlMs: number;
94
+ /** Must match createD1Storage's tablePrefix. */
95
+ tablePrefix?: string;
96
+ /**
97
+ * Threads processed per call. Default 100 — the shrinking eligible set is the
98
+ * cursor, so a first backlog drains across firings instead of blowing one
99
+ * invocation's budget (same batching rationale as purgeExpiredWorkflowRuns).
100
+ */
101
+ limit?: number;
102
+ /** Clock override for tests. */
103
+ now?: () => number;
104
+ }
105
+ export interface PurgeExpiredThreadsResult {
106
+ threads: number;
107
+ messages: number;
108
+ }
109
+ /**
110
+ * The tables `purgeExpiredThreads` deletes from under the thread TTL — the
111
+ * production anchor the schema guard cross-checks the `thread-ttl` retention
112
+ * declaration against, AND the target set a `cascade` child must appear in to be
113
+ * believed. Both tables are here because the purge reaps a thread and
114
+ * its messages together: `mastra_threads` by its own `updatedAt`,
115
+ * `mastra_messages` by cascade (a message has no idleness signal of its own — see
116
+ * the purge doc). So the inventory's `mastra_messages: { retention: cascade with
117
+ * mastra_threads }` is only legal because `mastra_messages` is genuinely a delete
118
+ * target here; a cascade naming a parent whose purge never touches the child is
119
+ * the lie the guard now catches.
120
+ */
121
+ export declare const THREAD_TTL_PURGE_TABLES: readonly string[];
122
+ /**
123
+ * Thread-level retention (docs/agent-memory-tenancy.md item 7): deletes agent
124
+ * memory threads whose `updatedAt` is older than the TTL, each with its
125
+ * messages. The terminal-status shape `purgeExpiredWorkflowRuns` uses does not
126
+ * transfer — threads are not per-run and have no status, so there is nothing to
127
+ * prove "finished" about one. Time since last write IS the only signal a thread
128
+ * is done, which is why the TTL keys on `updatedAt` (the D1 memory domain stamps
129
+ * it on every saveThread, so an active conversation never ages out).
130
+ *
131
+ * MESSAGES BEFORE THREADS: a message carries a `createdAt` but no `updatedAt`,
132
+ * so there is no per-message IDLENESS signal — a message's lifetime is its
133
+ * thread's, and its rows are reachable only through it. Deleting a thread first
134
+ * would strand its messages beyond every later firing of this purge (only
135
+ * purgeTenant, at offboarding, still ranges over their salted `thread_id`).
136
+ *
137
+ * EVERY statement re-checks the CURRENT row rather than trusting the SELECT's id
138
+ * list, and that is load-bearing here in a way it is not for
139
+ * purgeExpiredWorkflowRuns (where terminal status is absorbing, so its re-check
140
+ * is belt-and-braces). "Idle" is precisely NOT absorbing — a thread can come
141
+ * back to life mid-purge — and the writer is not atomic either: the memory
142
+ * domain's saveMessages issues its message insert and its `UPDATE mastra_threads
143
+ * SET updatedAt` as two INDEPENDENT calls under one Promise.all, so a send's
144
+ * message can be visible while its thread still reads idle. That TORN state is
145
+ * what each guard answers:
146
+ *
147
+ * - The message DELETE re-reads the thread's current `updatedAt` (subquery) AND
148
+ * bounds itself to `createdAt < cutoff`. The subquery alone would sweep a
149
+ * just-arrived message into the same statement as the genuinely old ones —
150
+ * it keys on the THREAD's staleness, and the bump has not landed — silently
151
+ * destroying the message the user just sent. `createdAt` is the message's own
152
+ * evidence of recency, and the only guard that survives a torn write.
153
+ * - The thread DELETE re-checks `updatedAt < cutoff` AND fires only when `NOT
154
+ * EXISTS` any message for it. Sequence alone cannot carry "messages before
155
+ * threads": a message landing after the message DELETE leaves an idle-looking
156
+ * thread whose row would go out from under it. The NOT EXISTS makes the
157
+ * invariant — never delete a thread a message points at — a property of the
158
+ * statement rather than of timing.
159
+ *
160
+ * Together: a torn or concurrent send at ANY point in the sequence keeps both
161
+ * its message and its thread; the thread's next firing (by then bumped, or by
162
+ * then genuinely idle again) decides its fate on fresh evidence.
163
+ *
164
+ * Residuals, both accepted, neither reachable by a read path: (1) a send landing
165
+ * between the two DELETEs loses the already-expiring history while the thread
166
+ * and the new message survive — strictly better than the deletion that was
167
+ * milliseconds away. (2) A message inserted AFTER its thread's row is already
168
+ * gone is orphaned by the writer, not by this purge; D1 offers no cross-statement
169
+ * transaction through this seam to close it. An orphan is unreachable by recall
170
+ * (nothing lists a thread that does not exist), stays tenant-salted on its
171
+ * `thread_id`, and is reaped by purgeTenant at offboarding — a hygiene cost, not
172
+ * a leak.
173
+ *
174
+ * `mastra_resources` (working memory) is deliberately untouched: a resource is
175
+ * the OWNER's, shared across every thread they have, so one thread aging out
176
+ * says nothing about it. It is reaped at offboarding (purgeTenant).
177
+ *
178
+ * Missing tables read as zero (a deployment with no agent memory never created
179
+ * them). Scheduling stays with the caller — see createFlowsafeWorker's
180
+ * THREAD_RETENTION_DAYS duty.
181
+ */
182
+ export declare function purgeExpiredThreads(db: SnapshotDatabase, options: PurgeExpiredThreadsOptions): Promise<PurgeExpiredThreadsResult>;
183
+ /**
184
+ * The table `purgeExpiredBackgroundTasks` deletes from under the background-task
185
+ * TTL — the production anchor the schema guard cross-checks the
186
+ * `background-task-ttl` retention declaration against. It is the background-task
187
+ * counterpart to RUN_TTL_PURGE_TABLES. One table: the TTL rides `completedAt` on
188
+ * `mastra_background_tasks` alone, no cascade.
189
+ */
190
+ export declare const BACKGROUND_TASK_TTL_PURGE_TABLES: readonly string[];
191
+ export interface PurgeExpiredBackgroundTasksOptions {
192
+ /**
193
+ * Completed task records untouched for longer than this expire. Default
194
+ * 3_600_000 (1h) — core `BackgroundTaskManager.cleanup`'s `completedTtlMs`.
195
+ */
196
+ completedTtlMs?: number;
197
+ /**
198
+ * Failed / cancelled / timed_out task records older than this expire. Default
199
+ * 86_400_000 (24h) — core's `failedTtlMs`. Kept longer than completed so a
200
+ * failure stays inspectable.
201
+ */
202
+ failedTtlMs?: number;
203
+ /** Must match createD1Storage's tablePrefix. */
204
+ tablePrefix?: string;
205
+ /** Clock override for tests. */
206
+ now?: () => number;
207
+ }
208
+ export interface PurgeExpiredBackgroundTasksResult {
209
+ /** Deleted 'completed' rows. */
210
+ completed: number;
211
+ /** Deleted 'failed' | 'cancelled' | 'timed_out' rows. */
212
+ failed: number;
213
+ }
214
+ /**
215
+ * Background-task TTL cleanup: deletes terminal task
216
+ * rows from `mastra_background_tasks` once their `completedAt` is older than the
217
+ * TTL, mirroring core `BackgroundTaskManager.cleanup()` at the storage layer so
218
+ * a purge cron can reap them WITHOUT a live manager — the same posture as
219
+ * purgeExpiredWorkflowRuns/purgeExpiredThreads (raw D1 binding, failure-isolated
220
+ * as a cron duty). Two windows, exactly as core: completed rows expire fast
221
+ * (default 1h), failed/cancelled/timed_out slowly (default 24h) so a failure
222
+ * stays inspectable.
223
+ *
224
+ * `completedAt` is stored as ISO-8601 TEXT (`toISOString()`), so lexicographic
225
+ * `<` against an ISO cutoff is a correct timestamp comparison — the same bet the
226
+ * other purges take. `completedAt IS NOT NULL` is load-bearing: a row without a
227
+ * completion stamp cannot be proven old, so it survives (fail safe). Live rows
228
+ * (pending / running / suspended) are never matched — deleting a suspended task
229
+ * mid-flight would strand its resume. A missing table reads as zero (background
230
+ * tasks may never have run). Scheduling stays with the caller.
231
+ */
232
+ export declare function purgeExpiredBackgroundTasks(db: SnapshotDatabase, options?: PurgeExpiredBackgroundTasksOptions): Promise<PurgeExpiredBackgroundTasksResult>;
233
+ /**
234
+ * The table `purgeExpiredNotifications` deletes from under the notification TTL
235
+ * — the anchor the schema guard cross-checks the `notification-ttl` retention
236
+ * declaration against. It is the notification counterpart to
237
+ * BACKGROUND_TASK_TTL_PURGE_TABLES.
238
+ */
239
+ export declare const NOTIFICATION_TTL_PURGE_TABLES: readonly string[];
240
+ export interface PurgeExpiredNotificationsOptions {
241
+ /**
242
+ * Resolved (delivered/seen/dismissed/archived/discarded) notifications whose
243
+ * `updatedAt` is older than this expire. PENDING rows are never touched — one
244
+ * may be waiting on a future `deliverAt`, and reaping it would drop a signal
245
+ * the model has not seen. No default: the caller (createFlowsafeWorker's cron)
246
+ * gates this on an opt-in retention window, since a durable inbox is meant to
247
+ * be readable until the host says otherwise.
248
+ */
249
+ ttlMs: number;
250
+ /** Must match createD1Storage's tablePrefix. */
251
+ tablePrefix?: string;
252
+ /** Clock override for tests. */
253
+ now?: () => number;
254
+ }
255
+ /**
256
+ * Notification TTL cleanup: deletes terminal agent-inbox
257
+ * rows from `mastra_notifications` once their `updatedAt` is older than the TTL,
258
+ * at the storage layer so a cron reaps them without a live agent — the same
259
+ * posture as the other purges (raw D1 binding, failure-isolated as a cron duty).
260
+ * `updatedAt` is ISO-8601 TEXT, so lexicographic `<` is a correct timestamp
261
+ * comparison. A missing table reads as zero (notifications may never have been
262
+ * sent). Scheduling stays with the caller.
263
+ */
264
+ export declare function purgeExpiredNotifications(db: SnapshotDatabase, options: PurgeExpiredNotificationsOptions): Promise<number>;
265
+ /**
266
+ * The table `purgeExpiredThreadState` deletes from under the thread-state TTL —
267
+ * the anchor the schema guard cross-checks the `thread-state-ttl` retention
268
+ * declaration against.
269
+ */
270
+ export declare const THREAD_STATE_TTL_PURGE_TABLES: readonly string[];
271
+ export interface PurgeExpiredThreadStateOptions {
272
+ /**
273
+ * Thread-state rows (state-signal lanes + goals) whose `updatedAt` is older
274
+ * than this expire. An actively-updated goal or task lane bumps `updatedAt`
275
+ * on every write, so it never ages out; an abandoned thread's state does. No
276
+ * default (opt-in, like the notification and thread TTLs — durable state is
277
+ * kept until the host sets a window).
278
+ */
279
+ ttlMs: number;
280
+ /** Must match createD1Storage's tablePrefix. */
281
+ tablePrefix?: string;
282
+ /** Clock override for tests. */
283
+ now?: () => number;
284
+ }
285
+ /**
286
+ * Thread-state TTL cleanup: deletes thread-state rows
287
+ * from `mastra_thread_state` once their `updatedAt` is older than the TTL. Keys
288
+ * on `updatedAt` for the same reason `purgeExpiredThreads` does — thread state
289
+ * has no terminal status, so time-since-last-write is the only "done" signal.
290
+ * ISO-8601 TEXT encoding; missing table reads as zero; scheduling stays with the
291
+ * caller. Independent of the thread TTL (an orphan row is reaped here or at
292
+ * offboarding by purgeTenant), so it self-bounds without touching the delicate
293
+ * messages-before-threads ordering of purgeExpiredThreads.
294
+ */
295
+ export declare function purgeExpiredThreadState(db: SnapshotDatabase, options: PurgeExpiredThreadStateOptions): Promise<number>;
296
+ /**
297
+ * The table `purgeExpiredScheduleTriggers` deletes from under the trigger-row TTL
298
+ * — the anchor the schema guard cross-checks the `schedule-trigger-ttl` retention
299
+ * declaration against. It is the schedule-trigger counterpart to
300
+ * THREAD_STATE_TTL_PURGE_TABLES.
301
+ * Only the trigger HISTORY expires; the schedule rows themselves are standing
302
+ * config (retention 'none', reaped at offboarding by purgeTenant).
303
+ */
304
+ export declare const SCHEDULE_TRIGGER_TTL_PURGE_TABLES: readonly string[];
305
+ export interface PurgeExpiredScheduleTriggersOptions {
306
+ /**
307
+ * Trigger-history rows whose `actualFireAt` is older than this expire. No
308
+ * default (opt-in, like the notification/thread-state TTLs): a schedule's fire
309
+ * history is inspectable until the host sets a window.
310
+ */
311
+ ttlMs: number;
312
+ /** Must match createD1Storage's tablePrefix. */
313
+ tablePrefix?: string;
314
+ /** Clock override for tests. */
315
+ now?: () => number;
316
+ }
317
+ /**
318
+ * Schedule-trigger TTL cleanup: deletes trigger-history
319
+ * rows from `mastra_schedule_triggers` once their `actualFireAt` is older than the
320
+ * TTL, at the storage layer so a cron reaps them without a live tick — the same
321
+ * posture as the other purges (raw D1 binding, failure-isolated as a cron duty).
322
+ *
323
+ * `actualFireAt` is stored as INTEGER ms-epoch (core types
324
+ * `ScheduleTrigger.actualFireAt` as `number`, unlike the ISO-TEXT timestamp
325
+ * columns the other domains use), so the comparison is a NUMERIC `<` against a
326
+ * numeric cutoff — a correct timestamp comparison over integers. A missing table
327
+ * reads as zero (schedules may never have fired). Scheduling stays with the
328
+ * caller. Deleting trigger history never touches a live schedule (its own row is
329
+ * in `mastra_schedules`), so there is no ordering constraint.
330
+ */
331
+ export declare function purgeExpiredScheduleTriggers(db: SnapshotDatabase, options: PurgeExpiredScheduleTriggersOptions): Promise<number>;
71
332
  /**
72
333
  * Additive, app-owned index for the tenant range predicate. It couples us to
73
334
  * Mastra's snapshot column name (`run_id`, snake_case — its timestamps are
@@ -76,7 +337,7 @@ export declare function purgeExpiredWorkflowRuns(db: SnapshotDatabase, options:
76
337
  */
77
338
  export declare function ensureSnapshotRunIdIndex(db: SnapshotDatabase, tablePrefix?: string): Promise<void>;
78
339
  export interface PurgeTenantOptions {
79
- /** MUST satisfy INV-3 (^[a-z0-9]{3,32}$) — see the range note below. */
340
+ /** Must satisfy the tenant-ID pattern `^[a-z0-9]{3,32}$`; see the range note below. */
80
341
  tenantId: string;
81
342
  /** Must match createD1Storage's tablePrefix. */
82
343
  tablePrefix?: string;
@@ -98,9 +359,90 @@ export interface PurgeTenantResult {
98
359
  messages: number;
99
360
  /** Agent-memory rows: salted resource ids (working memory). */
100
361
  resources: number;
362
+ /** Background-task rows, ranged over their tenant-salted `run_id`. */
363
+ backgroundTasks: number;
364
+ /** Agent-inbox rows, ranged over their tenant-salted `thread_id`. */
365
+ notifications: number;
366
+ /** Thread-state rows (state lanes + goals), ranged over `thread_id`. */
367
+ threadState: number;
368
+ /** Schedule rows, metadata-filtered on their `metadata.tenantId`. */
369
+ schedules: number;
370
+ /** Schedule-trigger rows, metadata-filtered on their `metadata.tenantId`. */
371
+ scheduleTriggers: number;
101
372
  approvals: number;
373
+ /** Signal-subscription rows, filtered by the `tenant_id` column. */
374
+ subscriptions: number;
102
375
  artifacts: number;
103
376
  }
377
+ /**
378
+ * The `PurgeTenantResult` field a range-purged table reports into. A feature
379
+ * adopting a new `mastra_*` domain (notifications, thread-state, background
380
+ * tasks, schedules) adds its counter HERE, its row to
381
+ * TENANT_RANGE_PURGE_TABLES, and its field to PurgeTenantResult — all in the
382
+ * same change. The union is what makes that mechanical rather than
383
+ * remembered: a counter with no result field fails the pin below, and a result
384
+ * field with no counter fails the `memory` initializer in purgeTenant.
385
+ */
386
+ export type TenantRangePurgeCounter = 'threads' | 'messages' | 'resources' | 'backgroundTasks' | 'notifications' | 'threadState';
387
+ /** One table purgeTenant reaps by the tenant-exact `[tid_, tid\x60)` range predicate. */
388
+ export interface TenantRangePurgeTable {
389
+ /** The PurgeTenantResult field this table's deleted-row count lands in. */
390
+ counter: TenantRangePurgeCounter;
391
+ /** Unprefixed table name; purgeTenant applies the host's tablePrefix. */
392
+ table: string;
393
+ /**
394
+ * The tenant-salted column the range rides. Thread-keyed tables use their
395
+ * `thread_id` (a minted `${tenantId}_${uuid}`); row-keyed tables use their own
396
+ * salted `id`. Any column whose values are salted ids works — that is the
397
+ * whole reason the ids are salted at mint (docs/agent-memory-tenancy.md).
398
+ */
399
+ column: string;
400
+ }
401
+ /**
402
+ * The tenant-range purge inventory, extensible by construction: each
403
+ * later feature appends its adopted table here instead of editing purgeTenant's
404
+ * body, so adoption is one additive row plus the counter/result pair the types
405
+ * force alongside it. Ordering is not load-bearing (the deletes run
406
+ * concurrently; see purgeTenant).
407
+ *
408
+ * `mastra_workflow_snapshot` is deliberately absent: it rides the same range but
409
+ * over `run_id`, paired with artifact deletion and an app-owned index, so it
410
+ * keeps its own block. `mastra_background_tasks` rides the range over
411
+ * its own `run_id` — the originating run's tenant-salted id, always present on a
412
+ * task row — without artifacts or an app index, so it lives here. Tables no
413
+ * feature writes yet (`mastra_scorers`) are absent because nothing salts their
414
+ * ids yet — the schema-guard's inventory pin is what forces that decision when a
415
+ * feature adopts one.
416
+ */
417
+ export declare const TENANT_RANGE_PURGE_TABLES: readonly TenantRangePurgeTable[];
418
+ /**
419
+ * The `PurgeTenantResult` field a metadata-filtered table reports into. Schedule
420
+ * schedule rows key on slugified ids (`agent_<slug>`/`schedule_<slug>`), NOT
421
+ * tenant-salted ids, so the `[tid_, tid\x60)` range predicate cannot reach them —
422
+ * the tenant lives in `metadata.tenantId`. This is the second
423
+ * offboarding kind alongside the range counter: a feature adopting a metadata-keyed
424
+ * domain adds its counter HERE, its row to TENANT_METADATA_PURGE_TABLES, and its
425
+ * PurgeTenantResult field in the same change, pinned the same way.
426
+ */
427
+ export type TenantMetadataPurgeCounter = 'schedules' | 'scheduleTriggers';
428
+ /** One table purgeTenant reaps by `json_extract(metadata, '$.tenantId') = ?`. */
429
+ export interface TenantMetadataPurgeTable {
430
+ /** The PurgeTenantResult field this table's deleted-row count lands in. */
431
+ counter: TenantMetadataPurgeCounter;
432
+ /** Unprefixed table name; purgeTenant applies the host's tablePrefix. */
433
+ table: string;
434
+ }
435
+ /**
436
+ * The metadata-filtered purge inventory — the offboarding coverage for
437
+ * tables whose tenant is a JSON `metadata.tenantId` (stamped by the schedules
438
+ * facade at create + the tick on every trigger), not a salted id column. Both
439
+ * schedule tables are here: schedule rows and their trigger history. The DELETE is
440
+ * `WHERE json_extract(metadata, '$.tenantId') = ?` (the same SQLite json_extract
441
+ * the run-snapshot purge already uses on `snapshot`), so a NULL/absent metadata
442
+ * never matches — every row our facade/tick writes carries it, so this reaps them
443
+ * all. Ordering is not load-bearing (deletes run concurrently; see purgeTenant).
444
+ */
445
+ export declare const TENANT_METADATA_PURGE_TABLES: readonly TenantMetadataPurgeTable[];
104
446
  /**
105
447
  * Complete tenant offboarding: reaps EVERY tenant-keyed store — snapshot
106
448
  * rows of ANY status (a tenant's suspended-and-abandoned runs are never
@@ -110,9 +452,9 @@ export interface PurgeTenantResult {
110
452
  * tenant's approval records (titles, summaries, payloads, decider
111
453
  * identities), and its R2 artifacts.
112
454
  *
113
- * The snapshot predicate is a RANGE over the INV-1 salted runId:
455
+ * The snapshot predicate is a range over the tenant-salted runId:
114
456
  * `run_id >= '<tid>_' AND run_id < '<tid>' || CHAR(0x60)`. tenantId is
115
- * re-validated against INV-3 here — not for injection safety (every query is
457
+ * revalidated against the tenant-ID pattern here — not for injection safety (every query is
116
458
  * parameter-bound) but for RANGE-EXACTNESS: the predicate selects exactly one
117
459
  * tenant only because the charset excludes every character in [0x5F, 0x60]
118
460
  * ('_' is 0x5F; its successor 0x60, backtick, closes the range under BINARY
@@ -1 +1 @@
1
- {"version":3,"file":"d1-storage.d.ts","sourceRoot":"","sources":["../../src/do-runner/d1-storage.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,gDAAgD;IAChD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAYlE;AAcD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAC3C;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC;IAC9C,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxB,GAAG,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC,EAAE,CAAA;KAAE,CAAC,CAAC;CAC/C;AAED,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,uBAAuB;IACtC,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;I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