@edihasaj/recall 0.8.3 → 0.8.4

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 (58) hide show
  1. package/README.md +10 -0
  2. package/dist/{chunk-4LZMHQ6Y.js → chunk-2E34372Y.js} +6 -6
  3. package/dist/{chunk-YL23MKB3.js → chunk-3Z6IBPRZ.js} +3 -3
  4. package/dist/{chunk-QDA5M3AJ.js → chunk-DZHYYRCM.js} +4 -2
  5. package/dist/{chunk-QDA5M3AJ.js.map → chunk-DZHYYRCM.js.map} +1 -1
  6. package/dist/{chunk-Z6RT5BUO.js → chunk-I2DRSMD2.js} +2 -2
  7. package/dist/{chunk-72USXFEP.js → chunk-ICG6DSO4.js} +4 -4
  8. package/dist/{chunk-JRIM7VBY.js → chunk-JAOWDQG4.js} +2 -2
  9. package/dist/{chunk-L2YIWNLN.js → chunk-MD2A3WQ3.js} +7 -7
  10. package/dist/{chunk-R3DJIEID.js → chunk-OAZPBXRV.js} +3 -3
  11. package/dist/{chunk-DRHHOFBX.js → chunk-PSJ3YWEV.js} +263 -13
  12. package/dist/chunk-PSJ3YWEV.js.map +1 -0
  13. package/dist/chunk-PUMEMKGF.js +29 -0
  14. package/dist/chunk-PUMEMKGF.js.map +1 -0
  15. package/dist/{chunk-37K4DPRI.js → chunk-U2VFIJ3S.js} +2 -2
  16. package/dist/{chunk-3OYO5BW3.js → chunk-VG3MKOXJ.js} +4 -4
  17. package/dist/chunk-VG3MKOXJ.js.map +1 -0
  18. package/dist/{chunk-5E3KREDH.js → chunk-XYGS5CQU.js} +31 -7
  19. package/dist/chunk-XYGS5CQU.js.map +1 -0
  20. package/dist/{cleanup-XOIYUPHS.js → cleanup-LAPA52UR.js} +10 -6
  21. package/dist/cli.js +22 -21
  22. package/dist/cli.js.map +1 -1
  23. package/dist/daemon.js +30 -18
  24. package/dist/daemon.js.map +1 -1
  25. package/dist/{dispatcher-43DWN3ZP.js → dispatcher-VUTOVBS4.js} +6 -6
  26. package/dist/{embeddings-GKNH2E3N.js → embeddings-OEKBWLMK.js} +3 -3
  27. package/dist/{ingest-QOZDSJOA.js → ingest-KKJFZUPZ.js} +6 -6
  28. package/dist/mcp.js +10 -9
  29. package/dist/mcp.js.map +1 -1
  30. package/dist/{quality-2JOLSIC3.js → quality-6PPLSMMN.js} +4 -4
  31. package/dist/retrieval-T35UHKSO.js +13 -0
  32. package/dist/{store-2BPQPOOZ.js → store-2OU73NXB.js} +3 -3
  33. package/dist/sync-server.js +6 -0
  34. package/dist/sync-server.js.map +1 -1
  35. package/dist/{tasks-IFHV6EBT.js → tasks-NJL2P26Y.js} +8 -6
  36. package/dist/{usage-YBS74UEU.js → usage-H54D63YI.js} +3 -3
  37. package/package.json +2 -1
  38. package/dist/chunk-3OYO5BW3.js.map +0 -1
  39. package/dist/chunk-5E3KREDH.js.map +0 -1
  40. package/dist/chunk-DRHHOFBX.js.map +0 -1
  41. package/dist/retrieval-PQE7OHHJ.js +0 -13
  42. /package/dist/{chunk-4LZMHQ6Y.js.map → chunk-2E34372Y.js.map} +0 -0
  43. /package/dist/{chunk-YL23MKB3.js.map → chunk-3Z6IBPRZ.js.map} +0 -0
  44. /package/dist/{chunk-Z6RT5BUO.js.map → chunk-I2DRSMD2.js.map} +0 -0
  45. /package/dist/{chunk-72USXFEP.js.map → chunk-ICG6DSO4.js.map} +0 -0
  46. /package/dist/{chunk-JRIM7VBY.js.map → chunk-JAOWDQG4.js.map} +0 -0
  47. /package/dist/{chunk-L2YIWNLN.js.map → chunk-MD2A3WQ3.js.map} +0 -0
  48. /package/dist/{chunk-R3DJIEID.js.map → chunk-OAZPBXRV.js.map} +0 -0
  49. /package/dist/{chunk-37K4DPRI.js.map → chunk-U2VFIJ3S.js.map} +0 -0
  50. /package/dist/{cleanup-XOIYUPHS.js.map → cleanup-LAPA52UR.js.map} +0 -0
  51. /package/dist/{dispatcher-43DWN3ZP.js.map → dispatcher-VUTOVBS4.js.map} +0 -0
  52. /package/dist/{embeddings-GKNH2E3N.js.map → embeddings-OEKBWLMK.js.map} +0 -0
  53. /package/dist/{ingest-QOZDSJOA.js.map → ingest-KKJFZUPZ.js.map} +0 -0
  54. /package/dist/{quality-2JOLSIC3.js.map → quality-6PPLSMMN.js.map} +0 -0
  55. /package/dist/{retrieval-PQE7OHHJ.js.map → retrieval-T35UHKSO.js.map} +0 -0
  56. /package/dist/{store-2BPQPOOZ.js.map → store-2OU73NXB.js.map} +0 -0
  57. /package/dist/{tasks-IFHV6EBT.js.map → tasks-NJL2P26Y.js.map} +0 -0
  58. /package/dist/{usage-YBS74UEU.js.map → usage-H54D63YI.js.map} +0 -0
@@ -8,7 +8,7 @@ import {
8
8
  memoryEntities,
9
9
  or,
10
10
  sql
11
- } from "./chunk-QDA5M3AJ.js";
11
+ } from "./chunk-DZHYYRCM.js";
12
12
 
13
13
  // src/graph/store.ts
14
14
  import { randomUUID } from "crypto";
@@ -279,4 +279,4 @@ export {
279
279
  countEntities,
280
280
  countRelations
281
281
  };
282
- //# sourceMappingURL=chunk-Z6RT5BUO.js.map
282
+ //# sourceMappingURL=chunk-I2DRSMD2.js.map
@@ -2,14 +2,14 @@ import {
2
2
  listEntitiesForMemory,
3
3
  listMemoryIdsForEntity,
4
4
  neighborsOf
5
- } from "./chunk-Z6RT5BUO.js";
5
+ } from "./chunk-I2DRSMD2.js";
6
6
  import {
7
7
  getMemory
8
- } from "./chunk-3OYO5BW3.js";
8
+ } from "./chunk-VG3MKOXJ.js";
9
9
  import {
10
10
  hybridSearch,
11
11
  searchMemoryFtsIndex
12
- } from "./chunk-JRIM7VBY.js";
12
+ } from "./chunk-JAOWDQG4.js";
13
13
 
14
14
  // src/graph/retrieval.ts
15
15
  var SEED_WEIGHT = 1;
@@ -120,4 +120,4 @@ async function graphQuery(db, query, embeddingConfig, options = {}) {
120
120
  export {
121
121
  graphQuery
122
122
  };
123
- //# sourceMappingURL=chunk-72USXFEP.js.map
123
+ //# sourceMappingURL=chunk-ICG6DSO4.js.map
@@ -3,7 +3,7 @@ import {
3
3
  llmUsage,
4
4
  memories,
5
5
  memoryEmbeddings
6
- } from "./chunk-QDA5M3AJ.js";
6
+ } from "./chunk-DZHYYRCM.js";
7
7
  import {
8
8
  getProviderConfig,
9
9
  hasProviderConfigured,
@@ -2343,4 +2343,4 @@ export {
2343
2343
  findSemanticDuplicates,
2344
2344
  findSimilarRejectedExemplar
2345
2345
  };
2346
- //# sourceMappingURL=chunk-JRIM7VBY.js.map
2346
+ //# sourceMappingURL=chunk-JAOWDQG4.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  graphQuery
3
- } from "./chunk-72USXFEP.js";
3
+ } from "./chunk-ICG6DSO4.js";
4
4
  import {
5
5
  getEntity,
6
6
  listEntities,
7
7
  listMemoryIdsForEntity,
8
8
  neighborsOf
9
- } from "./chunk-Z6RT5BUO.js";
9
+ } from "./chunk-I2DRSMD2.js";
10
10
  import {
11
11
  captureCorrectionFallback,
12
12
  compileContext,
@@ -30,7 +30,7 @@ import {
30
30
  scanAndStore,
31
31
  sessionEndFallback,
32
32
  signalOutcomeFallback
33
- } from "./chunk-4LZMHQ6Y.js";
33
+ } from "./chunk-2E34372Y.js";
34
34
  import {
35
35
  DEFAULT_LEASE_SECONDS,
36
36
  TaskClaimConflictError,
@@ -51,18 +51,18 @@ import {
51
51
  releaseTask,
52
52
  rollbackMemory,
53
53
  submitTask
54
- } from "./chunk-DRHHOFBX.js";
54
+ } from "./chunk-PSJ3YWEV.js";
55
55
  import {
56
56
  confirmMemory,
57
57
  demoteGlobalMemory,
58
58
  getMemory,
59
59
  queryMemories,
60
60
  rejectMemory
61
- } from "./chunk-3OYO5BW3.js";
61
+ } from "./chunk-VG3MKOXJ.js";
62
62
  import {
63
63
  loadEmbeddingConfigFromEnv,
64
64
  tagActivitySource
65
- } from "./chunk-JRIM7VBY.js";
65
+ } from "./chunk-JAOWDQG4.js";
66
66
 
67
67
  // src/mcp/factory.ts
68
68
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -1131,4 +1131,4 @@ function createRecallMcpServer(db = initDb()) {
1131
1131
  export {
1132
1132
  createRecallMcpServer
1133
1133
  };
1134
- //# sourceMappingURL=chunk-L2YIWNLN.js.map
1134
+ //# sourceMappingURL=chunk-MD2A3WQ3.js.map
@@ -3,10 +3,10 @@ import {
3
3
  linkMemoryToEntity,
4
4
  upsertEntity,
5
5
  upsertRelation
6
- } from "./chunk-Z6RT5BUO.js";
6
+ } from "./chunk-I2DRSMD2.js";
7
7
  import {
8
8
  getMemory
9
- } from "./chunk-3OYO5BW3.js";
9
+ } from "./chunk-VG3MKOXJ.js";
10
10
 
11
11
  // src/graph/extractor.ts
12
12
  var PATH_RE = /(?:^|[\s`'"(])((?:\.{0,2}\/)?(?:[A-Za-z0-9_.-]+\/){1,}[A-Za-z0-9_.-]+\.[A-Za-z0-9]{1,8})/g;
@@ -232,4 +232,4 @@ export {
232
232
  mergeAndIngest,
233
233
  safeIngestMemoryById
234
234
  };
235
- //# sourceMappingURL=chunk-R3DJIEID.js.map
235
+ //# sourceMappingURL=chunk-OAZPBXRV.js.map
@@ -12,10 +12,10 @@ import {
12
12
  promoteMemory,
13
13
  queryMemories,
14
14
  updateMemoryCaptureContext
15
- } from "./chunk-3OYO5BW3.js";
15
+ } from "./chunk-VG3MKOXJ.js";
16
16
  import {
17
17
  desc
18
- } from "./chunk-37K4DPRI.js";
18
+ } from "./chunk-U2VFIJ3S.js";
19
19
  import {
20
20
  CONFIDENCE,
21
21
  LlmCredentialError,
@@ -24,7 +24,7 @@ import {
24
24
  findSimilarRejectedExemplar,
25
25
  loadEmbeddingConfigFromEnv,
26
26
  queueMemoryEmbeddingSync
27
- } from "./chunk-JRIM7VBY.js";
27
+ } from "./chunk-JAOWDQG4.js";
28
28
  import {
29
29
  activityEvents,
30
30
  and,
@@ -45,7 +45,7 @@ import {
45
45
  memoryMaintenanceTasks,
46
46
  or,
47
47
  sql
48
- } from "./chunk-QDA5M3AJ.js";
48
+ } from "./chunk-DZHYYRCM.js";
49
49
  import {
50
50
  hasProviderConfigured,
51
51
  init_keychain
@@ -1198,6 +1198,12 @@ function runDeterministicCleanup(db, opts = { dryRun: true }) {
1198
1198
  if (!opts.only || opts.only === "globalize_cross_repo") {
1199
1199
  plan.push(...planGlobalizeCrossRepo(db));
1200
1200
  }
1201
+ if (!opts.only || opts.only === "reject_test_fixture_repo") {
1202
+ plan.push(...planRejectTestFixtureRepos(db));
1203
+ }
1204
+ if (!opts.only || opts.only === "reject_invalid_scope") {
1205
+ plan.push(...planRejectInvalidScopes(db));
1206
+ }
1201
1207
  const counts = summarize(plan);
1202
1208
  if (!opts.dryRun) {
1203
1209
  for (const item of plan) {
@@ -1217,6 +1223,12 @@ function runDeterministicCleanup(db, opts = { dryRun: true }) {
1217
1223
  case "globalize_cross_repo":
1218
1224
  applyGlobalizeCrossRepo(db, runId, item);
1219
1225
  break;
1226
+ case "reject_test_fixture_repo":
1227
+ applyRejectTestFixtureRepo(db, runId, item);
1228
+ break;
1229
+ case "reject_invalid_scope":
1230
+ applyRejectInvalidScope(db, runId, item);
1231
+ break;
1220
1232
  }
1221
1233
  }
1222
1234
  }
@@ -1237,6 +1249,9 @@ function summarize(plan) {
1237
1249
  let commandSuppressions = 0;
1238
1250
  let globalizations = 0;
1239
1251
  let globalizeLosers = 0;
1252
+ let testFixtureRejections = 0;
1253
+ let invalidScopeRejections = 0;
1254
+ let e2eArtifactRejections = 0;
1240
1255
  for (const p of plan) {
1241
1256
  if (p.kind === "dedupe_exact_merge") {
1242
1257
  dedupeClusters += 1;
@@ -1247,9 +1262,16 @@ function summarize(plan) {
1247
1262
  repeatPromotions += 1;
1248
1263
  } else if (p.kind === "suppress_unproductive_command") {
1249
1264
  commandSuppressions += 1;
1250
- } else {
1265
+ } else if (p.kind === "globalize_cross_repo") {
1251
1266
  globalizations += 1;
1252
1267
  globalizeLosers += p.loser_ids.length;
1268
+ } else if (p.kind === "reject_test_fixture_repo") {
1269
+ testFixtureRejections += 1;
1270
+ } else {
1271
+ invalidScopeRejections += 1;
1272
+ }
1273
+ if (p.kind === "reject_fragment_candidate" && p.reasons.includes("e2e_verification_artifact")) {
1274
+ e2eArtifactRejections += 1;
1253
1275
  }
1254
1276
  }
1255
1277
  return {
@@ -1259,7 +1281,10 @@ function summarize(plan) {
1259
1281
  repeat_promotions: repeatPromotions,
1260
1282
  command_suppressions: commandSuppressions,
1261
1283
  globalizations,
1262
- globalize_losers: globalizeLosers
1284
+ globalize_losers: globalizeLosers,
1285
+ test_fixture_rejections: testFixtureRejections,
1286
+ invalid_scope_rejections: invalidScopeRejections,
1287
+ e2e_artifact_rejections: e2eArtifactRejections
1263
1288
  };
1264
1289
  }
1265
1290
  function normalizeText(text) {
@@ -1427,6 +1452,8 @@ var VERB_HINTS = [
1427
1452
  "close",
1428
1453
  "send",
1429
1454
  "receive",
1455
+ "treat",
1456
+ "propose",
1430
1457
  "configure",
1431
1458
  "enable",
1432
1459
  "disable"
@@ -1438,6 +1465,25 @@ var TRAILING_DOUBLE_DOT_RE = /\.{2,}\s*$/;
1438
1465
  var TRAILING_DASH_RE = /[—–-]\s*$/;
1439
1466
  var EMBEDDED_QUESTION_RE = /^\s*(?:always|never|must|don't|do not|required|prefer|should)\s+(?:can|could|would|will|do|does|did|is|are|was|were|have|has|should|may|might)\s+(?:you|we|i|they|it|he|she)\b/i;
1440
1467
  var RULE_FILLER_PREFIX_RE = /^\s*(?:always|never|must|don't|do not|prefer|required)\s+(?:just|now|uh|um|so|like|maybe|kinda|sort\s+of)\b/i;
1468
+ var VAGUE_SPEECH_FRAGMENT_RE = /\b(?:or whatever|and stuff like that|stuff like that|something like that|things like that)\b/i;
1469
+ var WORKSPACE_ONLY_RULE_RE = /^\s*(?:always\s+)?keep\s+(?:all\s+)?(?:edits|work|changes)\s+inside\s+(?:(?:the\s+)?current\s+|(?:the\s+)?specified\s+|the\s+)?workspace(?:\s+at\s+\S+)?\.?\s*$/i;
1470
+ var BENCHMARK_ARTIFACT_RULE_RE = /\b(?:agent-scorecard|data\/agent-runs\.json|generated scorecard|benchmark tasks?|Oktapod and OpenClaw|OpenClaw and Oktapod|do not add Hermes)\b/i;
1471
+ var TOOL_EMBARGO_TASK_RULE_RE = /^\s*do\s+not\s+(?:open\s+browser,\s+screenshot,\s+or\s+devtools\s+tools|open\s+browser,\s+take\s+screenshots,\s+or\s+use\s+devtools\s+tools)(?:\s+(?:during|for)\s+(?:this\s+|the\s+)?(?:task|benchmark(?:\s+run)?))?\.?\s*$/i;
1472
+ var E2E_VERIFICATION_ARTIFACT_RE = /\b(?:recall\s+(?:e2e|end[- ]to[- ]end)\s+verification|(?:e2e|end[- ]to[- ]end)\s+verification\s+(?:smoke|fixture|artifact)|for\s+recall\s+(?:e2e|end[- ]to[- ]end)\s+verification)\b/i;
1473
+ var ACTIVE_FRAGMENT_REASONS = /* @__PURE__ */ new Set([
1474
+ "bare_modal",
1475
+ "trailing_question",
1476
+ "trailing_double_dot",
1477
+ "trailing_dash",
1478
+ "dangling_connector",
1479
+ "filler_prefix",
1480
+ "vague_speech_fragment",
1481
+ "workspace_only_runtime_rule",
1482
+ "benchmark_artifact_rule",
1483
+ "tool_embargo_task_rule",
1484
+ "e2e_verification_artifact",
1485
+ "embedded_question"
1486
+ ]);
1441
1487
  var MAX_RULE_LENGTH = 300;
1442
1488
  var MIN_RULE_LENGTH = 20;
1443
1489
  function planRejectFragments(db) {
@@ -1446,16 +1492,17 @@ function planRejectFragments(db) {
1446
1492
  text: memories.text,
1447
1493
  source: memories.source,
1448
1494
  status: memories.status
1449
- }).from(memories).where(and(eq(memories.status, "candidate"), eq(memories.source, "user_correction"))).all();
1495
+ }).from(memories).where(and(inArray(memories.status, ["active", "candidate"]), eq(memories.source, "user_correction"))).all();
1450
1496
  const out = [];
1451
1497
  for (const row of rows) {
1452
1498
  const reasons = qualityReasons(row.text);
1453
- if (reasons.length > 0) {
1499
+ const actionableReasons = row.status === "active" ? reasons.filter((reason) => ACTIVE_FRAGMENT_REASONS.has(reason)) : reasons;
1500
+ if (actionableReasons.length > 0) {
1454
1501
  out.push({
1455
1502
  kind: "reject_fragment_candidate",
1456
1503
  memory_id: row.id,
1457
1504
  text: row.text,
1458
- reasons
1505
+ reasons: actionableReasons
1459
1506
  });
1460
1507
  }
1461
1508
  }
@@ -1472,6 +1519,11 @@ function qualityReasons(rawText) {
1472
1519
  if (TRAILING_DASH_RE.test(text)) reasons.push("trailing_dash");
1473
1520
  if (DANGLING_CONNECTOR_RE.test(text)) reasons.push("dangling_connector");
1474
1521
  if (RULE_FILLER_PREFIX_RE.test(text)) reasons.push("filler_prefix");
1522
+ if (VAGUE_SPEECH_FRAGMENT_RE.test(text)) reasons.push("vague_speech_fragment");
1523
+ if (WORKSPACE_ONLY_RULE_RE.test(text)) reasons.push("workspace_only_runtime_rule");
1524
+ if (BENCHMARK_ARTIFACT_RULE_RE.test(text)) reasons.push("benchmark_artifact_rule");
1525
+ if (TOOL_EMBARGO_TASK_RULE_RE.test(text)) reasons.push("tool_embargo_task_rule");
1526
+ if (E2E_VERIFICATION_ARTIFACT_RE.test(text)) reasons.push("e2e_verification_artifact");
1475
1527
  if (EMBEDDED_QUESTION_RE.test(text)) reasons.push("embedded_question");
1476
1528
  const words = text.toLowerCase().replace(/[^\w' ]+/g, " ").split(/\s+/).filter(Boolean);
1477
1529
  const hasVerb = words.some((w) => VERB_HINTS.includes(w));
@@ -1480,7 +1532,7 @@ function qualityReasons(rawText) {
1480
1532
  }
1481
1533
  function applyRejectFragment(db, runId, plan) {
1482
1534
  const before = getMemory(db, plan.memory_id);
1483
- if (!before || before.status !== "candidate") return;
1535
+ if (!before || !["active", "candidate"].includes(before.status)) return;
1484
1536
  const now = (/* @__PURE__ */ new Date()).toISOString();
1485
1537
  db.update(memories).set({ status: "rejected", dedupe_key: null, updated_at: now }).where(eq(memories.id, plan.memory_id)).run();
1486
1538
  const after = getMemory(db, plan.memory_id);
@@ -1507,6 +1559,124 @@ function applyRejectFragment(db, runId, plan) {
1507
1559
  created_at: now
1508
1560
  }).run();
1509
1561
  }
1562
+ var TEST_FIXTURE_REPO_RE = /^test\/recall-[a-z0-9-]+-repo-[a-z0-9]+$/i;
1563
+ function planRejectTestFixtureRepos(db) {
1564
+ const rows = db.select({
1565
+ id: memories.id,
1566
+ repo: memories.repo,
1567
+ text: memories.text,
1568
+ status: memories.status
1569
+ }).from(memories).where(inArray(memories.status, ["active", "candidate"])).all();
1570
+ return rows.filter((row) => row.repo != null && TEST_FIXTURE_REPO_RE.test(row.repo)).map((row) => ({
1571
+ kind: "reject_test_fixture_repo",
1572
+ memory_id: row.id,
1573
+ repo: row.repo,
1574
+ text: row.text
1575
+ }));
1576
+ }
1577
+ function applyRejectTestFixtureRepo(db, runId, plan) {
1578
+ const before = getMemory(db, plan.memory_id);
1579
+ if (!before || !["active", "candidate"].includes(before.status)) return;
1580
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1581
+ db.update(memories).set({ status: "rejected", dedupe_key: null, updated_at: now }).where(eq(memories.id, plan.memory_id)).run();
1582
+ const after = getMemory(db, plan.memory_id);
1583
+ recordAuditWithSnapshot(
1584
+ db,
1585
+ plan.memory_id,
1586
+ "rejected",
1587
+ DEFAULT_ACTOR,
1588
+ `cleanup_test_fixture_repo:${plan.repo}:run:${runId}`,
1589
+ before,
1590
+ after ?? null
1591
+ );
1592
+ db.insert(maintenanceCleanupLog).values({
1593
+ id: randomUUID3(),
1594
+ run_id: runId,
1595
+ action: "reject_test_fixture_repo",
1596
+ memory_id: plan.memory_id,
1597
+ related_memory_id: null,
1598
+ before_snapshot: before,
1599
+ after_snapshot: after,
1600
+ details: { repo: plan.repo },
1601
+ reverted: false,
1602
+ reverted_at: null,
1603
+ created_at: now
1604
+ }).run();
1605
+ }
1606
+ function isTempPath(path) {
1607
+ if (!path) return false;
1608
+ return path.startsWith("/tmp/") || path.startsWith("/private/tmp/") || path.includes("/tmp/");
1609
+ }
1610
+ function isWorkspaceRootAlias(repo) {
1611
+ return repo === "Projects";
1612
+ }
1613
+ function planRejectInvalidScopes(db) {
1614
+ const rows = db.select({
1615
+ id: memories.id,
1616
+ scope: memories.scope,
1617
+ repo: memories.repo,
1618
+ path_scope: memories.path_scope,
1619
+ text: memories.text,
1620
+ status: memories.status,
1621
+ source: memories.source
1622
+ }).from(memories).where(inArray(memories.status, ["active", "candidate"])).all();
1623
+ const out = [];
1624
+ for (const row of rows) {
1625
+ if (row.source !== "user_correction") continue;
1626
+ if (qualityReasons(row.text).length > 0) continue;
1627
+ const reasons = [];
1628
+ if (row.scope === "path" && !row.path_scope) reasons.push("path_scope_without_path");
1629
+ if (row.scope === "path" && isTempPath(row.path_scope)) reasons.push("temp_path_scope");
1630
+ if (row.scope === "repo" && isTempPath(row.path_scope)) reasons.push("temp_repo_path_scope");
1631
+ if (row.repo && isTempPath(row.repo)) reasons.push("repo_field_is_temp_path");
1632
+ if (isWorkspaceRootAlias(row.repo)) reasons.push("workspace_root_repo_alias");
1633
+ if (reasons.length === 0) continue;
1634
+ out.push({
1635
+ kind: "reject_invalid_scope",
1636
+ memory_id: row.id,
1637
+ scope: row.scope,
1638
+ repo: row.repo,
1639
+ path_scope: row.path_scope,
1640
+ text: row.text,
1641
+ reasons
1642
+ });
1643
+ }
1644
+ return out;
1645
+ }
1646
+ function applyRejectInvalidScope(db, runId, plan) {
1647
+ const before = getMemory(db, plan.memory_id);
1648
+ if (!before || !["active", "candidate"].includes(before.status)) return;
1649
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1650
+ db.update(memories).set({ status: "rejected", dedupe_key: null, updated_at: now }).where(eq(memories.id, plan.memory_id)).run();
1651
+ const after = getMemory(db, plan.memory_id);
1652
+ recordAuditWithSnapshot(
1653
+ db,
1654
+ plan.memory_id,
1655
+ "rejected",
1656
+ DEFAULT_ACTOR,
1657
+ `cleanup_invalid_scope:${plan.reasons.join(",")}:run:${runId}`,
1658
+ before,
1659
+ after ?? null
1660
+ );
1661
+ db.insert(maintenanceCleanupLog).values({
1662
+ id: randomUUID3(),
1663
+ run_id: runId,
1664
+ action: "reject_invalid_scope",
1665
+ memory_id: plan.memory_id,
1666
+ related_memory_id: null,
1667
+ before_snapshot: before,
1668
+ after_snapshot: after,
1669
+ details: {
1670
+ scope: plan.scope,
1671
+ repo: plan.repo,
1672
+ path_scope: plan.path_scope,
1673
+ reasons: plan.reasons
1674
+ },
1675
+ reverted: false,
1676
+ reverted_at: null,
1677
+ created_at: now
1678
+ }).run();
1679
+ }
1510
1680
  function planPromoteRepeats(db) {
1511
1681
  const rows = db.select({
1512
1682
  id: memories.id,
@@ -1825,6 +1995,9 @@ function formatCleanupReport(report) {
1825
1995
  lines.push(` repeat_promotions: ${report.counts.repeat_promotions}`);
1826
1996
  lines.push(` command_suppressions: ${report.counts.command_suppressions}`);
1827
1997
  lines.push(` globalizations: ${report.counts.globalizations} (losers=${report.counts.globalize_losers})`);
1998
+ lines.push(` test_fixture_rejects: ${report.counts.test_fixture_rejections}`);
1999
+ lines.push(` invalid_scope_rejects:${report.counts.invalid_scope_rejections}`);
2000
+ lines.push(` e2e_artifact_rejects: ${report.counts.e2e_artifact_rejections}`);
1828
2001
  if (report.plan.length === 0) {
1829
2002
  lines.push(" (no actions)");
1830
2003
  return lines.join("\n");
@@ -1843,9 +2016,15 @@ function formatCleanupReport(report) {
1843
2016
  } else if (item.kind === "suppress_unproductive_command") {
1844
2017
  lines.push(` suppress: ${item.memory_id.slice(0, 8)} inj=${item.injection_count} followed=${item.followed_count}`);
1845
2018
  lines.push(` "${truncate(item.text, 80)}"`);
1846
- } else {
2019
+ } else if (item.kind === "globalize_cross_repo") {
1847
2020
  lines.push(` globalize: keep ${item.winner_id.slice(0, 8)} drop ${item.loser_ids.length} repos=[${item.repos.join(",")}]`);
1848
2021
  lines.push(` "${truncate(item.winner_text, 80)}"`);
2022
+ } else if (item.kind === "reject_test_fixture_repo") {
2023
+ lines.push(` reject-test-repo: ${item.memory_id.slice(0, 8)} repo=${item.repo}`);
2024
+ lines.push(` "${truncate(item.text, 80)}"`);
2025
+ } else {
2026
+ lines.push(` reject-invalid-scope: ${item.memory_id.slice(0, 8)} scope=${item.scope} repo=${item.repo ?? "-"} path=${item.path_scope ?? "-"} reasons=${item.reasons.join(",")}`);
2027
+ lines.push(` "${truncate(item.text, 80)}"`);
1849
2028
  }
1850
2029
  }
1851
2030
  return lines.join("\n");
@@ -2888,6 +3067,72 @@ function abandonOverAttemptTasks(db) {
2888
3067
  )).run();
2889
3068
  return result.changes;
2890
3069
  }
3070
+ var TEST_FIXTURE_REPO_RE2 = /^test\/recall-[a-z0-9-]+-repo-[a-z0-9]+$/i;
3071
+ function isTempPath2(value) {
3072
+ if (!value) return false;
3073
+ return value.startsWith("/tmp/") || value.startsWith("/private/tmp/") || value.includes("/tmp/");
3074
+ }
3075
+ function invalidTaskScopeReasons(repo) {
3076
+ const reasons = [];
3077
+ if (repo === "Projects") reasons.push("workspace_root_repo_alias");
3078
+ if (repo && TEST_FIXTURE_REPO_RE2.test(repo)) reasons.push("test_fixture_repo");
3079
+ if (isTempPath2(repo)) reasons.push("repo_field_is_temp_path");
3080
+ return reasons;
3081
+ }
3082
+ function payloadString(payload, key) {
3083
+ const value = payload[key];
3084
+ return typeof value === "string" && value.trim() ? value : null;
3085
+ }
3086
+ function taskTargetReasons(db, task) {
3087
+ const payload = task.payload ?? {};
3088
+ if (task.kind === "verify_capture" || task.kind === "refine_candidate") {
3089
+ const memoryId = payloadString(payload, "memory_id");
3090
+ if (!memoryId) return ["target_memory_id_missing"];
3091
+ const row = db.select({ status: memories.status }).from(memories).where(eq(memories.id, memoryId)).get();
3092
+ if (!row) return ["target_memory_missing"];
3093
+ if (row.status === "rejected") return ["target_memory_rejected"];
3094
+ }
3095
+ if (task.kind === "merge_duplicates") {
3096
+ const rawCandidates = Array.isArray(payload.candidates) ? payload.candidates : [];
3097
+ const ids = rawCandidates.map((candidate) => {
3098
+ if (!candidate || typeof candidate !== "object") return null;
3099
+ const id = candidate.id;
3100
+ return typeof id === "string" && id.trim() ? id : null;
3101
+ }).filter((id) => id != null);
3102
+ if (ids.length < 2) return ["merge_candidates_insufficient"];
3103
+ const live = db.select({ id: memories.id }).from(memories).where(and(
3104
+ inArray(memories.id, ids),
3105
+ inArray(memories.status, ["active", "candidate"])
3106
+ )).all();
3107
+ if (live.length < 2) return ["merge_candidates_not_live"];
3108
+ }
3109
+ return [];
3110
+ }
3111
+ function abandonInvalidOpenTasks(db, now = /* @__PURE__ */ new Date()) {
3112
+ const rows = db.select().from(memoryMaintenanceTasks).where(inArray(memoryMaintenanceTasks.status, OPEN_STATUSES)).all();
3113
+ let changed = 0;
3114
+ const nowIso = now.toISOString();
3115
+ for (const row of rows) {
3116
+ const reasons = [
3117
+ ...invalidTaskScopeReasons(row.repo),
3118
+ ...taskTargetReasons(db, row)
3119
+ ];
3120
+ if (reasons.length === 0) continue;
3121
+ const result = db.update(memoryMaintenanceTasks).set({
3122
+ status: "abandoned",
3123
+ failure_reason: `invalid_task:${[...new Set(reasons)].join(",")}`.slice(0, 500),
3124
+ claimed_by: null,
3125
+ claimed_at: null,
3126
+ claim_expires_at: null,
3127
+ completed_at: nowIso
3128
+ }).where(and(
3129
+ eq(memoryMaintenanceTasks.id, row.id),
3130
+ inArray(memoryMaintenanceTasks.status, OPEN_STATUSES)
3131
+ )).run();
3132
+ changed += result.changes;
3133
+ }
3134
+ return changed;
3135
+ }
2891
3136
  function applyBacklogCaps(db, config) {
2892
3137
  let dropped = 0;
2893
3138
  const overKindRows = db.select({
@@ -3127,6 +3372,7 @@ async function enqueueMaintenanceTasks(db, config = DEFAULT_ENQUEUE_CONFIG) {
3127
3372
  const expired = sweepExpiredLeases(db);
3128
3373
  abandonOverAttemptTasks(db);
3129
3374
  const expiredPending = expireStalePendingTasks(db, config.summary_max_age_days * 2);
3375
+ const invalid = abandonInvalidOpenTasks(db);
3130
3376
  const counts = {};
3131
3377
  counts.refine_candidate = produceRefineCandidateTasks(db, config);
3132
3378
  counts.summarize_history = produceSummarizeHistoryTasks(db, config);
@@ -3140,7 +3386,8 @@ async function enqueueMaintenanceTasks(db, config = DEFAULT_ENQUEUE_CONFIG) {
3140
3386
  per_kind: counts,
3141
3387
  expired_leases_swept: expired,
3142
3388
  dropped_over_cap: dropped,
3143
- expired_pending_tasks: expiredPending
3389
+ expired_pending_tasks: expiredPending,
3390
+ invalid_tasks_abandoned: invalid
3144
3391
  };
3145
3392
  }
3146
3393
  var MemoryScope = z.enum(["session", "path", "repo", "team", "global"]);
@@ -3376,6 +3623,7 @@ export {
3376
3623
  sweepExpiredLeases,
3377
3624
  expireStalePendingTasks,
3378
3625
  abandonOverAttemptTasks,
3626
+ abandonInvalidOpenTasks,
3379
3627
  applyBacklogCaps,
3380
3628
  enqueueExtractRulesFromPrompt,
3381
3629
  enqueueVerifyCapture,
@@ -3404,6 +3652,8 @@ export {
3404
3652
  planDedupeExact,
3405
3653
  planRejectFragments,
3406
3654
  qualityReasons,
3655
+ planRejectTestFixtureRepos,
3656
+ planRejectInvalidScopes,
3407
3657
  planPromoteRepeats,
3408
3658
  planSuppressCommands,
3409
3659
  planGlobalizeCrossRepo,
@@ -3418,4 +3668,4 @@ export {
3418
3668
  processCorrection,
3419
3669
  processReviewFeedback
3420
3670
  };
3421
- //# sourceMappingURL=chunk-DRHHOFBX.js.map
3671
+ //# sourceMappingURL=chunk-PSJ3YWEV.js.map