claude-memory-layer 1.0.50 → 1.0.52

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.
package/dist/cli/index.js CHANGED
@@ -2327,6 +2327,10 @@ var DEFAULT_CONFIG2 = {
2327
2327
  // 5 minutes
2328
2328
  cleanupDays: 7
2329
2329
  };
2330
+ function isRetryableLanceCommitConflict(error) {
2331
+ const normalized = error.toLowerCase();
2332
+ return normalized.includes("lance") && normalized.includes("commit") && normalized.includes("conflict");
2333
+ }
2330
2334
  var VectorOutbox = class {
2331
2335
  constructor(db, config) {
2332
2336
  this.db = db;
@@ -2431,6 +2435,16 @@ var VectorOutbox = class {
2431
2435
  );
2432
2436
  if (rows.length === 0) return;
2433
2437
  const retryCount = rows[0].retry_count;
2438
+ if (isRetryableLanceCommitConflict(error)) {
2439
+ await dbRun(
2440
+ this.db,
2441
+ `UPDATE vector_outbox
2442
+ SET status = 'pending', error = ?, updated_at = ?
2443
+ WHERE job_id = ?`,
2444
+ [error, now, jobId]
2445
+ );
2446
+ return;
2447
+ }
2434
2448
  const newStatus = retryCount >= this.config.maxRetries - 1 ? "failed" : "pending";
2435
2449
  await dbRun(
2436
2450
  this.db,
@@ -4114,6 +4128,7 @@ var SQLiteEventStore = class {
4114
4128
  async getOutboxStats(options = {}) {
4115
4129
  await this.initialize();
4116
4130
  const thresholdMs = Number.isFinite(options.stuckThresholdMs) && (options.stuckThresholdMs ?? 0) >= 0 ? options.stuckThresholdMs : DEFAULT_OUTBOX_STUCK_THRESHOLD_MS;
4131
+ const maxRetries = Number.isFinite(options.maxRetries) && (options.maxRetries ?? 0) > 0 ? options.maxRetries : DEFAULT_OUTBOX_MAX_RETRIES;
4117
4132
  const now = options.now ?? /* @__PURE__ */ new Date();
4118
4133
  const threshold = new Date(now.getTime() - thresholdMs).toISOString();
4119
4134
  const embeddingRows = sqliteAll(
@@ -4131,8 +4146,8 @@ var SQLiteEventStore = class {
4131
4146
  if (!Number.isFinite(time)) return null;
4132
4147
  return Math.max(0, now.getTime() - time);
4133
4148
  };
4134
- const fromRows = (rows, stuckProcessing, oldestProcessingAgeMs) => {
4135
- const out = { pending: 0, processing: 0, failed: 0, total: 0, stuckProcessing, oldestProcessingAgeMs };
4149
+ const fromRows = (rows, stuckProcessing, oldestProcessingAgeMs, retryableFailed, quarantinedFailed) => {
4150
+ const out = { pending: 0, processing: 0, failed: 0, retryableFailed, quarantinedFailed, total: 0, stuckProcessing, oldestProcessingAgeMs };
4136
4151
  for (const row of rows) {
4137
4152
  const key = row.status;
4138
4153
  if (key === "pending" || key === "processing" || key === "failed") {
@@ -4156,6 +4171,22 @@ var SQLiteEventStore = class {
4156
4171
  FROM embedding_outbox
4157
4172
  WHERE status = 'processing'`
4158
4173
  );
4174
+ const embeddingRetryableFailed = sqliteGet(
4175
+ this.db,
4176
+ `SELECT COUNT(*) as count
4177
+ FROM embedding_outbox
4178
+ WHERE status = 'failed'
4179
+ AND retry_count < ?`,
4180
+ [maxRetries]
4181
+ );
4182
+ const embeddingQuarantinedFailed = sqliteGet(
4183
+ this.db,
4184
+ `SELECT COUNT(*) as count
4185
+ FROM embedding_outbox
4186
+ WHERE status = 'failed'
4187
+ AND retry_count >= ?`,
4188
+ [maxRetries]
4189
+ );
4159
4190
  const vectorStuck = sqliteGet(
4160
4191
  this.db,
4161
4192
  `SELECT COUNT(*) as count
@@ -4170,16 +4201,36 @@ var SQLiteEventStore = class {
4170
4201
  FROM vector_outbox
4171
4202
  WHERE status = 'processing'`
4172
4203
  );
4204
+ const vectorRetryableFailed = sqliteGet(
4205
+ this.db,
4206
+ `SELECT COUNT(*) as count
4207
+ FROM vector_outbox
4208
+ WHERE status = 'failed'
4209
+ AND retry_count < ?`,
4210
+ [maxRetries]
4211
+ );
4212
+ const vectorQuarantinedFailed = sqliteGet(
4213
+ this.db,
4214
+ `SELECT COUNT(*) as count
4215
+ FROM vector_outbox
4216
+ WHERE status = 'failed'
4217
+ AND retry_count >= ?`,
4218
+ [maxRetries]
4219
+ );
4173
4220
  return {
4174
4221
  embedding: fromRows(
4175
4222
  embeddingRows,
4176
4223
  Number(embeddingStuck?.count ?? 0),
4177
- processingAgeMs(embeddingOldest?.oldest)
4224
+ processingAgeMs(embeddingOldest?.oldest),
4225
+ Number(embeddingRetryableFailed?.count ?? 0),
4226
+ Number(embeddingQuarantinedFailed?.count ?? 0)
4178
4227
  ),
4179
4228
  vector: fromRows(
4180
4229
  vectorRows,
4181
4230
  Number(vectorStuck?.count ?? 0),
4182
- processingAgeMs(vectorOldest?.oldest)
4231
+ processingAgeMs(vectorOldest?.oldest),
4232
+ Number(vectorRetryableFailed?.count ?? 0),
4233
+ Number(vectorQuarantinedFailed?.count ?? 0)
4183
4234
  )
4184
4235
  };
4185
4236
  }
@@ -18721,8 +18772,10 @@ function aggregateOutbox(outbox) {
18721
18772
  const pending = (outbox.embedding?.pending || 0) + (outbox.vector?.pending || 0);
18722
18773
  const processing = (outbox.embedding?.processing || 0) + (outbox.vector?.processing || 0);
18723
18774
  const failed = (outbox.embedding?.failed || 0) + (outbox.vector?.failed || 0);
18775
+ const retryableFailed = (outbox.embedding?.retryableFailed || 0) + (outbox.vector?.retryableFailed || 0);
18776
+ const quarantinedFailed = (outbox.embedding?.quarantinedFailed || 0) + (outbox.vector?.quarantinedFailed || 0);
18724
18777
  const stuckProcessing = (outbox.embedding?.stuckProcessing || 0) + (outbox.vector?.stuckProcessing || 0);
18725
- return { pending, processing, failed, stuckProcessing };
18778
+ return { pending, processing, failed, retryableFailed, quarantinedFailed, stuckProcessing };
18726
18779
  }
18727
18780
  healthRouter.get("/setup", async (c) => {
18728
18781
  const memoryService = getLightweightServiceFromQuery(c);
@@ -18791,6 +18844,8 @@ healthRouter.get("/", async (c) => {
18791
18844
  const outboxPending = outbox.embedding.pending + outbox.vector.pending;
18792
18845
  const outboxProcessing = outbox.embedding.processing + outbox.vector.processing;
18793
18846
  const outboxFailed = outbox.embedding.failed + outbox.vector.failed;
18847
+ const outboxRetryableFailed = (outbox.embedding.retryableFailed ?? 0) + (outbox.vector.retryableFailed ?? 0);
18848
+ const outboxQuarantinedFailed = (outbox.embedding.quarantinedFailed ?? 0) + (outbox.vector.quarantinedFailed ?? 0);
18794
18849
  const outboxStuckProcessing = outbox.embedding.stuckProcessing + outbox.vector.stuckProcessing;
18795
18850
  const oldestProcessingAgeMs = Math.max(
18796
18851
  outbox.embedding.oldestProcessingAgeMs ?? 0,
@@ -18811,6 +18866,8 @@ healthRouter.get("/", async (c) => {
18811
18866
  pending: outboxPending,
18812
18867
  processing: outboxProcessing,
18813
18868
  failed: outboxFailed,
18869
+ retryableFailed: outboxRetryableFailed,
18870
+ quarantinedFailed: outboxQuarantinedFailed,
18814
18871
  stuckProcessing: outboxStuckProcessing,
18815
18872
  oldestProcessingAgeMs
18816
18873
  }
@@ -20856,12 +20913,12 @@ function formatVectorStatusReport(input) {
20856
20913
  `Vector count: ${input.stats.vectorCount}`,
20857
20914
  `Total events: ${input.stats.totalEvents}`,
20858
20915
  "",
20859
- "Queue pending processing failed stuck total oldest",
20916
+ "Queue pending processing failed retryable quarantined stuck total oldest",
20860
20917
  formatQueueRow("Embedding", embedding),
20861
20918
  formatQueueRow("Vector", vector),
20862
20919
  formatQueueRow("Total", totals),
20863
20920
  "",
20864
- `Totals: pending=${totals.pending}, processing=${totals.processing}, failed=${totals.failed}, stuck=${totals.stuckProcessing}, total=${totals.total}`,
20921
+ `Totals: pending=${totals.pending}, processing=${totals.processing}, failed=${totals.failed}, retryableFailed=${totals.retryableFailed ?? 0}, quarantinedFailed=${totals.quarantinedFailed ?? 0}, stuck=${totals.stuckProcessing}, total=${totals.total}`,
20865
20922
  `Oldest processing age: ${formatDuration2(oldestProcessingAge)}`,
20866
20923
  `Status: ${status}`
20867
20924
  ];
@@ -20875,6 +20932,8 @@ function normalizeQueue(queue) {
20875
20932
  pending: numberOrZero(queue.pending),
20876
20933
  processing: numberOrZero(queue.processing),
20877
20934
  failed: numberOrZero(queue.failed),
20935
+ retryableFailed: numberOrZero(queue.retryableFailed),
20936
+ quarantinedFailed: numberOrZero(queue.quarantinedFailed),
20878
20937
  total: numberOrZero(queue.total),
20879
20938
  stuckProcessing: numberOrZero(queue.stuckProcessing),
20880
20939
  oldestProcessingAgeMs: Number.isFinite(queue.oldestProcessingAgeMs ?? Number.NaN) ? queue.oldestProcessingAgeMs : null
@@ -20885,6 +20944,8 @@ function sumQueues(a, b) {
20885
20944
  pending: a.pending + b.pending,
20886
20945
  processing: a.processing + b.processing,
20887
20946
  failed: a.failed + b.failed,
20947
+ retryableFailed: (a.retryableFailed ?? 0) + (b.retryableFailed ?? 0),
20948
+ quarantinedFailed: (a.quarantinedFailed ?? 0) + (b.quarantinedFailed ?? 0),
20888
20949
  stuckProcessing: a.stuckProcessing + b.stuckProcessing,
20889
20950
  total: a.total + b.total,
20890
20951
  oldestProcessingAgeMs: maxNullable2(a.oldestProcessingAgeMs, b.oldestProcessingAgeMs)
@@ -20896,6 +20957,8 @@ function formatQueueRow(label, queue) {
20896
20957
  String(queue.pending).padStart(7),
20897
20958
  String(queue.processing).padStart(11),
20898
20959
  String(queue.failed).padStart(7),
20960
+ String(queue.retryableFailed ?? 0).padStart(9),
20961
+ String(queue.quarantinedFailed ?? 0).padStart(11),
20899
20962
  String(queue.stuckProcessing).padStart(6),
20900
20963
  String(queue.total).padStart(6),
20901
20964
  formatDuration2(queue.oldestProcessingAgeMs).padStart(7)
@@ -20907,7 +20970,8 @@ function maxNullable2(a, b) {
20907
20970
  return Math.max(a, b);
20908
20971
  }
20909
20972
  function numberOrZero(value) {
20910
- return Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;
20973
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return 0;
20974
+ return Math.floor(value);
20911
20975
  }
20912
20976
  function formatDuration2(ms) {
20913
20977
  if (ms === null) return "none";
@@ -21538,7 +21602,7 @@ async function runOperationCli(action, label) {
21538
21602
  }
21539
21603
  }
21540
21604
  var program = new Command();
21541
- program.name("claude-memory-layer").description("Claude Code Memory Plugin CLI").version("1.0.50");
21605
+ program.name("claude-memory-layer").description("Claude Code Memory Plugin CLI").version("1.0.52");
21542
21606
  program.command("market-context").description("Fetch read-only DART/FRED/Finnhub context with structured MarketContextSnapshot bull/bear/risk/catalyst analysis").option("--company <name>", "Company name for DART fallback search and report subject").option("--dart-corp-code <code>", "Exact DART corp_code for issuer-specific filings").option("--symbol <ticker>", "Listed ticker for Finnhub company profile").option("--providers <list>", "Comma-separated providers: dart,fred,finnhub").option("--fred-series <list>", "Comma-separated FRED series IDs").option("--json", "Print structured JSON including analysis.marketSnapshot").option("--no-snapshot", "Disable MarketContextSnapshot and DART company snapshot analysis").action(async (options) => {
21543
21607
  try {
21544
21608
  await runMarketContextCommand(options);