@mastra/convex 1.7.3 → 1.7.4-alpha.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.
@@ -3,7 +3,7 @@ name: mastra-convex
3
3
  description: Documentation for @mastra/convex. Use when working with @mastra/convex APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/convex"
6
- version: "1.7.3"
6
+ version: "1.7.4-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.3",
2
+ "version": "1.7.4-alpha.0",
3
3
  "package": "@mastra/convex",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_server = require("./server-Bcgr5CcA.cjs");
2
+ const require_server = require("./server-uHLma0g7.cjs");
3
3
  const require_schema = require("./schema.cjs");
4
4
  let _mastra_core_cache = require("@mastra/core/cache");
5
5
  let _mastra_core_storage = require("@mastra/core/storage");
@@ -401,6 +401,17 @@ async function retireRunFence(client, fence) {
401
401
  });
402
402
  return applied;
403
403
  }
404
+ /** Deletes up to `limit` claims whose epoch-ms `column` is older than `cutoff`. Returns how many were deleted. */
405
+ async function pruneRunClaims(client, tableName, column, cutoff, limit) {
406
+ const { result } = await callRunClaim(client, {
407
+ op: "pruneRunClaims",
408
+ tableName,
409
+ column,
410
+ cutoff,
411
+ limit
412
+ }, "prune");
413
+ return result;
414
+ }
404
415
  //#endregion
405
416
  //#region src/storage/types.ts
406
417
  /**
@@ -1174,7 +1185,18 @@ function parseStoredOMRecord(doc) {
1174
1185
  supersededBy: doc.supersededBy ?? null
1175
1186
  };
1176
1187
  }
1177
- var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1188
+ var MemoryConvex = class MemoryConvex extends _mastra_core_storage.MemoryStorage {
1189
+ /**
1190
+ * Tables `prune()` can clean up. Run fences anchor on `retiredAt` (epoch ms), which stays unset until the
1191
+ * execution holding the fence settles, so a running execution's fence is
1192
+ * never pruned.
1193
+ */
1194
+ static retentionTables = { runFences: {
1195
+ table: _mastra_core_storage.TABLE_MEMORY_RUN_FENCES,
1196
+ column: "retiredAt",
1197
+ indexed: false,
1198
+ anchorType: "epoch-ms"
1199
+ } };
1178
1200
  supportsPartialThreadUpdate = true;
1179
1201
  supportsObservationalMemory = true;
1180
1202
  supportsObservationalMemoryHistorySearch = true;
@@ -1207,6 +1229,19 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1207
1229
  return this.#db.fenced(this.#runFenceCheck(fence, operation));
1208
1230
  }
1209
1231
  async init() {}
1232
+ async prune(policies, options) {
1233
+ return (0, _mastra_core_storage.executeRetentionPrune)({
1234
+ domain: "memory",
1235
+ targets: (0, _mastra_core_storage.resolveRetentionTargets)({
1236
+ policies,
1237
+ descriptor: MemoryConvex.retentionTables,
1238
+ order: ["runFences"]
1239
+ }),
1240
+ options,
1241
+ cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
1242
+ deleteBatch: (_target, cutoff, limit) => pruneRunClaims(this.#client, _mastra_core_storage.TABLE_MEMORY_RUN_FENCES, "retiredAt", Number(cutoff), limit)
1243
+ });
1244
+ }
1210
1245
  async dangerouslyClearAll() {
1211
1246
  await this.#db.clearTable({ tableName: _mastra_core_storage.TABLE_THREADS });
1212
1247
  await this.#db.clearTable({ tableName: _mastra_core_storage.TABLE_MESSAGES });
@@ -2272,7 +2307,18 @@ var ScoresConvex = class extends _mastra_core_storage.ScoresStorage {
2272
2307
  };
2273
2308
  //#endregion
2274
2309
  //#region src/storage/domains/workflows/index.ts
2275
- var WorkflowsConvex = class extends _mastra_core_storage.WorkflowsStorage {
2310
+ var WorkflowsConvex = class WorkflowsConvex extends _mastra_core_storage.WorkflowsStorage {
2311
+ /**
2312
+ * Tables `prune()` can clean up. Run ownership records anchor on `updatedAt` (epoch ms), which every
2313
+ * claim, renewal and release refreshes, so a live execution's record is never
2314
+ * older than its renew interval.
2315
+ */
2316
+ static retentionTables = { runOwnership: {
2317
+ table: _mastra_core_storage.TABLE_WORKFLOW_RUN_OWNERS,
2318
+ column: "updatedAt",
2319
+ indexed: false,
2320
+ anchorType: "epoch-ms"
2321
+ } };
2276
2322
  #db;
2277
2323
  #client;
2278
2324
  constructor(config) {
@@ -2287,6 +2333,19 @@ var WorkflowsConvex = class extends _mastra_core_storage.WorkflowsStorage {
2287
2333
  return true;
2288
2334
  }
2289
2335
  async init() {}
2336
+ async prune(policies, options) {
2337
+ return (0, _mastra_core_storage.executeRetentionPrune)({
2338
+ domain: "workflows",
2339
+ targets: (0, _mastra_core_storage.resolveRetentionTargets)({
2340
+ policies,
2341
+ descriptor: WorkflowsConvex.retentionTables,
2342
+ order: ["runOwnership"]
2343
+ }),
2344
+ options,
2345
+ cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
2346
+ deleteBatch: (_target, cutoff, limit) => pruneRunClaims(this.#client, _mastra_core_storage.TABLE_WORKFLOW_RUN_OWNERS, "updatedAt", Number(cutoff), limit)
2347
+ });
2348
+ }
2290
2349
  async dangerouslyClearAll() {
2291
2350
  await this.#db.clearTable({ tableName: _mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT });
2292
2351
  await this.#db.clearTable({ tableName: _mastra_core_storage.TABLE_WORKFLOW_RUN_OWNERS });