claude-memory-layer 1.0.51 → 1.0.53

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.
@@ -2325,6 +2325,10 @@ var DEFAULT_CONFIG2 = {
2325
2325
  // 5 minutes
2326
2326
  cleanupDays: 7
2327
2327
  };
2328
+ function isRetryableLanceCommitConflict(error) {
2329
+ const normalized = error.toLowerCase();
2330
+ return normalized.includes("lance") && normalized.includes("commit") && normalized.includes("conflict");
2331
+ }
2328
2332
  var VectorOutbox = class {
2329
2333
  constructor(db, config) {
2330
2334
  this.db = db;
@@ -2429,6 +2433,16 @@ var VectorOutbox = class {
2429
2433
  );
2430
2434
  if (rows.length === 0) return;
2431
2435
  const retryCount = rows[0].retry_count;
2436
+ if (isRetryableLanceCommitConflict(error)) {
2437
+ await dbRun(
2438
+ this.db,
2439
+ `UPDATE vector_outbox
2440
+ SET status = 'pending', error = ?, updated_at = ?
2441
+ WHERE job_id = ?`,
2442
+ [error, now, jobId]
2443
+ );
2444
+ return;
2445
+ }
2432
2446
  const newStatus = retryCount >= this.config.maxRetries - 1 ? "failed" : "pending";
2433
2447
  await dbRun(
2434
2448
  this.db,
@@ -4112,6 +4126,7 @@ var SQLiteEventStore = class {
4112
4126
  async getOutboxStats(options = {}) {
4113
4127
  await this.initialize();
4114
4128
  const thresholdMs = Number.isFinite(options.stuckThresholdMs) && (options.stuckThresholdMs ?? 0) >= 0 ? options.stuckThresholdMs : DEFAULT_OUTBOX_STUCK_THRESHOLD_MS;
4129
+ const maxRetries = Number.isFinite(options.maxRetries) && (options.maxRetries ?? 0) > 0 ? options.maxRetries : DEFAULT_OUTBOX_MAX_RETRIES;
4115
4130
  const now = options.now ?? /* @__PURE__ */ new Date();
4116
4131
  const threshold = new Date(now.getTime() - thresholdMs).toISOString();
4117
4132
  const embeddingRows = sqliteAll(
@@ -4129,8 +4144,8 @@ var SQLiteEventStore = class {
4129
4144
  if (!Number.isFinite(time)) return null;
4130
4145
  return Math.max(0, now.getTime() - time);
4131
4146
  };
4132
- const fromRows = (rows, stuckProcessing, oldestProcessingAgeMs) => {
4133
- const out = { pending: 0, processing: 0, failed: 0, total: 0, stuckProcessing, oldestProcessingAgeMs };
4147
+ const fromRows = (rows, stuckProcessing, oldestProcessingAgeMs, retryableFailed, quarantinedFailed) => {
4148
+ const out = { pending: 0, processing: 0, failed: 0, retryableFailed, quarantinedFailed, total: 0, stuckProcessing, oldestProcessingAgeMs };
4134
4149
  for (const row of rows) {
4135
4150
  const key = row.status;
4136
4151
  if (key === "pending" || key === "processing" || key === "failed") {
@@ -4154,6 +4169,22 @@ var SQLiteEventStore = class {
4154
4169
  FROM embedding_outbox
4155
4170
  WHERE status = 'processing'`
4156
4171
  );
4172
+ const embeddingRetryableFailed = sqliteGet(
4173
+ this.db,
4174
+ `SELECT COUNT(*) as count
4175
+ FROM embedding_outbox
4176
+ WHERE status = 'failed'
4177
+ AND retry_count < ?`,
4178
+ [maxRetries]
4179
+ );
4180
+ const embeddingQuarantinedFailed = sqliteGet(
4181
+ this.db,
4182
+ `SELECT COUNT(*) as count
4183
+ FROM embedding_outbox
4184
+ WHERE status = 'failed'
4185
+ AND retry_count >= ?`,
4186
+ [maxRetries]
4187
+ );
4157
4188
  const vectorStuck = sqliteGet(
4158
4189
  this.db,
4159
4190
  `SELECT COUNT(*) as count
@@ -4168,16 +4199,36 @@ var SQLiteEventStore = class {
4168
4199
  FROM vector_outbox
4169
4200
  WHERE status = 'processing'`
4170
4201
  );
4202
+ const vectorRetryableFailed = sqliteGet(
4203
+ this.db,
4204
+ `SELECT COUNT(*) as count
4205
+ FROM vector_outbox
4206
+ WHERE status = 'failed'
4207
+ AND retry_count < ?`,
4208
+ [maxRetries]
4209
+ );
4210
+ const vectorQuarantinedFailed = sqliteGet(
4211
+ this.db,
4212
+ `SELECT COUNT(*) as count
4213
+ FROM vector_outbox
4214
+ WHERE status = 'failed'
4215
+ AND retry_count >= ?`,
4216
+ [maxRetries]
4217
+ );
4171
4218
  return {
4172
4219
  embedding: fromRows(
4173
4220
  embeddingRows,
4174
4221
  Number(embeddingStuck?.count ?? 0),
4175
- processingAgeMs(embeddingOldest?.oldest)
4222
+ processingAgeMs(embeddingOldest?.oldest),
4223
+ Number(embeddingRetryableFailed?.count ?? 0),
4224
+ Number(embeddingQuarantinedFailed?.count ?? 0)
4176
4225
  ),
4177
4226
  vector: fromRows(
4178
4227
  vectorRows,
4179
4228
  Number(vectorStuck?.count ?? 0),
4180
- processingAgeMs(vectorOldest?.oldest)
4229
+ processingAgeMs(vectorOldest?.oldest),
4230
+ Number(vectorRetryableFailed?.count ?? 0),
4231
+ Number(vectorQuarantinedFailed?.count ?? 0)
4181
4232
  )
4182
4233
  };
4183
4234
  }
@@ -14869,6 +14920,8 @@ function summarizeProjectOutbox(outbox) {
14869
14920
  pending: (embedding.pending || 0) + (vector.pending || 0),
14870
14921
  processing: (embedding.processing || 0) + (vector.processing || 0),
14871
14922
  failed: (embedding.failed || 0) + (vector.failed || 0),
14923
+ retryableFailed: (embedding.retryableFailed || 0) + (vector.retryableFailed || 0),
14924
+ quarantinedFailed: (embedding.quarantinedFailed || 0) + (vector.quarantinedFailed || 0),
14872
14925
  stuckProcessing: (embedding.stuckProcessing || 0) + (vector.stuckProcessing || 0)
14873
14926
  };
14874
14927
  }
@@ -15206,8 +15259,10 @@ function aggregateOutbox(outbox) {
15206
15259
  const pending = (outbox.embedding?.pending || 0) + (outbox.vector?.pending || 0);
15207
15260
  const processing = (outbox.embedding?.processing || 0) + (outbox.vector?.processing || 0);
15208
15261
  const failed = (outbox.embedding?.failed || 0) + (outbox.vector?.failed || 0);
15262
+ const retryableFailed = (outbox.embedding?.retryableFailed || 0) + (outbox.vector?.retryableFailed || 0);
15263
+ const quarantinedFailed = (outbox.embedding?.quarantinedFailed || 0) + (outbox.vector?.quarantinedFailed || 0);
15209
15264
  const stuckProcessing = (outbox.embedding?.stuckProcessing || 0) + (outbox.vector?.stuckProcessing || 0);
15210
- return { pending, processing, failed, stuckProcessing };
15265
+ return { pending, processing, failed, retryableFailed, quarantinedFailed, stuckProcessing };
15211
15266
  }
15212
15267
  healthRouter.get("/setup", async (c) => {
15213
15268
  const memoryService = getLightweightServiceFromQuery(c);
@@ -15276,6 +15331,8 @@ healthRouter.get("/", async (c) => {
15276
15331
  const outboxPending = outbox.embedding.pending + outbox.vector.pending;
15277
15332
  const outboxProcessing = outbox.embedding.processing + outbox.vector.processing;
15278
15333
  const outboxFailed = outbox.embedding.failed + outbox.vector.failed;
15334
+ const outboxRetryableFailed = (outbox.embedding.retryableFailed ?? 0) + (outbox.vector.retryableFailed ?? 0);
15335
+ const outboxQuarantinedFailed = (outbox.embedding.quarantinedFailed ?? 0) + (outbox.vector.quarantinedFailed ?? 0);
15279
15336
  const outboxStuckProcessing = outbox.embedding.stuckProcessing + outbox.vector.stuckProcessing;
15280
15337
  const oldestProcessingAgeMs = Math.max(
15281
15338
  outbox.embedding.oldestProcessingAgeMs ?? 0,
@@ -15296,6 +15353,8 @@ healthRouter.get("/", async (c) => {
15296
15353
  pending: outboxPending,
15297
15354
  processing: outboxProcessing,
15298
15355
  failed: outboxFailed,
15356
+ retryableFailed: outboxRetryableFailed,
15357
+ quarantinedFailed: outboxQuarantinedFailed,
15299
15358
  stuckProcessing: outboxStuckProcessing,
15300
15359
  oldestProcessingAgeMs
15301
15360
  }