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.
@@ -2337,6 +2337,10 @@ var DEFAULT_CONFIG2 = {
2337
2337
  // 5 minutes
2338
2338
  cleanupDays: 7
2339
2339
  };
2340
+ function isRetryableLanceCommitConflict(error) {
2341
+ const normalized = error.toLowerCase();
2342
+ return normalized.includes("lance") && normalized.includes("commit") && normalized.includes("conflict");
2343
+ }
2340
2344
  var VectorOutbox = class {
2341
2345
  constructor(db, config) {
2342
2346
  this.db = db;
@@ -2441,6 +2445,16 @@ var VectorOutbox = class {
2441
2445
  );
2442
2446
  if (rows.length === 0) return;
2443
2447
  const retryCount = rows[0].retry_count;
2448
+ if (isRetryableLanceCommitConflict(error)) {
2449
+ await dbRun(
2450
+ this.db,
2451
+ `UPDATE vector_outbox
2452
+ SET status = 'pending', error = ?, updated_at = ?
2453
+ WHERE job_id = ?`,
2454
+ [error, now, jobId]
2455
+ );
2456
+ return;
2457
+ }
2444
2458
  const newStatus = retryCount >= this.config.maxRetries - 1 ? "failed" : "pending";
2445
2459
  await dbRun(
2446
2460
  this.db,
@@ -4124,6 +4138,7 @@ var SQLiteEventStore = class {
4124
4138
  async getOutboxStats(options = {}) {
4125
4139
  await this.initialize();
4126
4140
  const thresholdMs = Number.isFinite(options.stuckThresholdMs) && (options.stuckThresholdMs ?? 0) >= 0 ? options.stuckThresholdMs : DEFAULT_OUTBOX_STUCK_THRESHOLD_MS;
4141
+ const maxRetries = Number.isFinite(options.maxRetries) && (options.maxRetries ?? 0) > 0 ? options.maxRetries : DEFAULT_OUTBOX_MAX_RETRIES;
4127
4142
  const now = options.now ?? /* @__PURE__ */ new Date();
4128
4143
  const threshold = new Date(now.getTime() - thresholdMs).toISOString();
4129
4144
  const embeddingRows = sqliteAll(
@@ -4141,8 +4156,8 @@ var SQLiteEventStore = class {
4141
4156
  if (!Number.isFinite(time)) return null;
4142
4157
  return Math.max(0, now.getTime() - time);
4143
4158
  };
4144
- const fromRows = (rows, stuckProcessing, oldestProcessingAgeMs) => {
4145
- const out = { pending: 0, processing: 0, failed: 0, total: 0, stuckProcessing, oldestProcessingAgeMs };
4159
+ const fromRows = (rows, stuckProcessing, oldestProcessingAgeMs, retryableFailed, quarantinedFailed) => {
4160
+ const out = { pending: 0, processing: 0, failed: 0, retryableFailed, quarantinedFailed, total: 0, stuckProcessing, oldestProcessingAgeMs };
4146
4161
  for (const row of rows) {
4147
4162
  const key = row.status;
4148
4163
  if (key === "pending" || key === "processing" || key === "failed") {
@@ -4166,6 +4181,22 @@ var SQLiteEventStore = class {
4166
4181
  FROM embedding_outbox
4167
4182
  WHERE status = 'processing'`
4168
4183
  );
4184
+ const embeddingRetryableFailed = sqliteGet(
4185
+ this.db,
4186
+ `SELECT COUNT(*) as count
4187
+ FROM embedding_outbox
4188
+ WHERE status = 'failed'
4189
+ AND retry_count < ?`,
4190
+ [maxRetries]
4191
+ );
4192
+ const embeddingQuarantinedFailed = sqliteGet(
4193
+ this.db,
4194
+ `SELECT COUNT(*) as count
4195
+ FROM embedding_outbox
4196
+ WHERE status = 'failed'
4197
+ AND retry_count >= ?`,
4198
+ [maxRetries]
4199
+ );
4169
4200
  const vectorStuck = sqliteGet(
4170
4201
  this.db,
4171
4202
  `SELECT COUNT(*) as count
@@ -4180,16 +4211,36 @@ var SQLiteEventStore = class {
4180
4211
  FROM vector_outbox
4181
4212
  WHERE status = 'processing'`
4182
4213
  );
4214
+ const vectorRetryableFailed = sqliteGet(
4215
+ this.db,
4216
+ `SELECT COUNT(*) as count
4217
+ FROM vector_outbox
4218
+ WHERE status = 'failed'
4219
+ AND retry_count < ?`,
4220
+ [maxRetries]
4221
+ );
4222
+ const vectorQuarantinedFailed = sqliteGet(
4223
+ this.db,
4224
+ `SELECT COUNT(*) as count
4225
+ FROM vector_outbox
4226
+ WHERE status = 'failed'
4227
+ AND retry_count >= ?`,
4228
+ [maxRetries]
4229
+ );
4183
4230
  return {
4184
4231
  embedding: fromRows(
4185
4232
  embeddingRows,
4186
4233
  Number(embeddingStuck?.count ?? 0),
4187
- processingAgeMs(embeddingOldest?.oldest)
4234
+ processingAgeMs(embeddingOldest?.oldest),
4235
+ Number(embeddingRetryableFailed?.count ?? 0),
4236
+ Number(embeddingQuarantinedFailed?.count ?? 0)
4188
4237
  ),
4189
4238
  vector: fromRows(
4190
4239
  vectorRows,
4191
4240
  Number(vectorStuck?.count ?? 0),
4192
- processingAgeMs(vectorOldest?.oldest)
4241
+ processingAgeMs(vectorOldest?.oldest),
4242
+ Number(vectorRetryableFailed?.count ?? 0),
4243
+ Number(vectorQuarantinedFailed?.count ?? 0)
4193
4244
  )
4194
4245
  };
4195
4246
  }
@@ -14881,6 +14932,8 @@ function summarizeProjectOutbox(outbox) {
14881
14932
  pending: (embedding.pending || 0) + (vector.pending || 0),
14882
14933
  processing: (embedding.processing || 0) + (vector.processing || 0),
14883
14934
  failed: (embedding.failed || 0) + (vector.failed || 0),
14935
+ retryableFailed: (embedding.retryableFailed || 0) + (vector.retryableFailed || 0),
14936
+ quarantinedFailed: (embedding.quarantinedFailed || 0) + (vector.quarantinedFailed || 0),
14884
14937
  stuckProcessing: (embedding.stuckProcessing || 0) + (vector.stuckProcessing || 0)
14885
14938
  };
14886
14939
  }
@@ -15218,8 +15271,10 @@ function aggregateOutbox(outbox) {
15218
15271
  const pending = (outbox.embedding?.pending || 0) + (outbox.vector?.pending || 0);
15219
15272
  const processing = (outbox.embedding?.processing || 0) + (outbox.vector?.processing || 0);
15220
15273
  const failed = (outbox.embedding?.failed || 0) + (outbox.vector?.failed || 0);
15274
+ const retryableFailed = (outbox.embedding?.retryableFailed || 0) + (outbox.vector?.retryableFailed || 0);
15275
+ const quarantinedFailed = (outbox.embedding?.quarantinedFailed || 0) + (outbox.vector?.quarantinedFailed || 0);
15221
15276
  const stuckProcessing = (outbox.embedding?.stuckProcessing || 0) + (outbox.vector?.stuckProcessing || 0);
15222
- return { pending, processing, failed, stuckProcessing };
15277
+ return { pending, processing, failed, retryableFailed, quarantinedFailed, stuckProcessing };
15223
15278
  }
15224
15279
  healthRouter.get("/setup", async (c) => {
15225
15280
  const memoryService = getLightweightServiceFromQuery(c);
@@ -15288,6 +15343,8 @@ healthRouter.get("/", async (c) => {
15288
15343
  const outboxPending = outbox.embedding.pending + outbox.vector.pending;
15289
15344
  const outboxProcessing = outbox.embedding.processing + outbox.vector.processing;
15290
15345
  const outboxFailed = outbox.embedding.failed + outbox.vector.failed;
15346
+ const outboxRetryableFailed = (outbox.embedding.retryableFailed ?? 0) + (outbox.vector.retryableFailed ?? 0);
15347
+ const outboxQuarantinedFailed = (outbox.embedding.quarantinedFailed ?? 0) + (outbox.vector.quarantinedFailed ?? 0);
15291
15348
  const outboxStuckProcessing = outbox.embedding.stuckProcessing + outbox.vector.stuckProcessing;
15292
15349
  const oldestProcessingAgeMs = Math.max(
15293
15350
  outbox.embedding.oldestProcessingAgeMs ?? 0,
@@ -15308,6 +15365,8 @@ healthRouter.get("/", async (c) => {
15308
15365
  pending: outboxPending,
15309
15366
  processing: outboxProcessing,
15310
15367
  failed: outboxFailed,
15368
+ retryableFailed: outboxRetryableFailed,
15369
+ quarantinedFailed: outboxQuarantinedFailed,
15311
15370
  stuckProcessing: outboxStuckProcessing,
15312
15371
  oldestProcessingAgeMs
15313
15372
  }