@edihasaj/recall 1.4.0 → 1.4.14

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 (86) hide show
  1. package/README.md +17 -7
  2. package/dist/{chunk-EAFRT7RX.js → chunk-22KM2YEO.js} +7 -2
  3. package/dist/{chunk-EAFRT7RX.js.map → chunk-22KM2YEO.js.map} +1 -1
  4. package/dist/{chunk-PUMEMKGF.js → chunk-47CB7PKL.js} +7 -1
  5. package/dist/{chunk-PUMEMKGF.js.map → chunk-47CB7PKL.js.map} +1 -1
  6. package/dist/{chunk-FHEH6QDU.js → chunk-7Z3CCCS2.js} +6 -1
  7. package/dist/{chunk-FHEH6QDU.js.map → chunk-7Z3CCCS2.js.map} +1 -1
  8. package/dist/chunk-AQOI4FCW.js +23 -0
  9. package/dist/chunk-AQOI4FCW.js.map +1 -0
  10. package/dist/{chunk-JKWK73GY.js → chunk-BWKFROGW.js} +101 -11
  11. package/dist/chunk-BWKFROGW.js.map +1 -0
  12. package/dist/{chunk-JYWURG5T.js → chunk-CYAODQOH.js} +12 -2
  13. package/dist/chunk-CYAODQOH.js.map +1 -0
  14. package/dist/{chunk-UWERS646.js → chunk-DJNJQA7L.js} +8 -4
  15. package/dist/{chunk-UWERS646.js.map → chunk-DJNJQA7L.js.map} +1 -1
  16. package/dist/{chunk-6QFOCUEJ.js → chunk-GGUWKT6I.js} +111 -21
  17. package/dist/chunk-GGUWKT6I.js.map +1 -0
  18. package/dist/{chunk-JO5LRCA2.js → chunk-HFHNPOBW.js} +207 -24
  19. package/dist/chunk-HFHNPOBW.js.map +1 -0
  20. package/dist/{chunk-JSTZKFZR.js → chunk-HRUNR5JJ.js} +14 -9
  21. package/dist/{chunk-JSTZKFZR.js.map → chunk-HRUNR5JJ.js.map} +1 -1
  22. package/dist/{chunk-65XK27KK.js → chunk-HUMJTWWT.js} +81 -161
  23. package/dist/chunk-HUMJTWWT.js.map +1 -0
  24. package/dist/{chunk-53GKSF42.js → chunk-JFUMA4WV.js} +308 -169
  25. package/dist/chunk-JFUMA4WV.js.map +1 -0
  26. package/dist/{chunk-MMYLXICL.js → chunk-KOBZIF2X.js} +8 -4
  27. package/dist/{chunk-MMYLXICL.js.map → chunk-KOBZIF2X.js.map} +1 -1
  28. package/dist/{chunk-7Q5CBVUT.js → chunk-M3ASNCVM.js} +234 -49
  29. package/dist/chunk-M3ASNCVM.js.map +1 -0
  30. package/dist/chunk-Q2KCBLJO.js +594 -0
  31. package/dist/chunk-Q2KCBLJO.js.map +1 -0
  32. package/dist/{chunk-CW3XJDH7.js → chunk-RWEX4VJE.js} +6 -2
  33. package/dist/{chunk-CW3XJDH7.js.map → chunk-RWEX4VJE.js.map} +1 -1
  34. package/dist/{chunk-LUIYWYOT.js → chunk-VSEAVK7X.js} +51 -3
  35. package/dist/chunk-VSEAVK7X.js.map +1 -0
  36. package/dist/{chunk-WZWXYBP6.js → chunk-XCFTE74H.js} +6 -3
  37. package/dist/{chunk-WZWXYBP6.js.map → chunk-XCFTE74H.js.map} +1 -1
  38. package/dist/{cleanup-RHNBHBNP.js → cleanup-YCYA6BJB.js} +11 -10
  39. package/dist/cli.js +648 -793
  40. package/dist/cli.js.map +1 -1
  41. package/dist/codex-trust-Z7LNNRVT.js +74 -0
  42. package/dist/codex-trust-Z7LNNRVT.js.map +1 -0
  43. package/dist/daemon.js +181 -61
  44. package/dist/daemon.js.map +1 -1
  45. package/dist/dispatcher-FP3WS74F.js +22 -0
  46. package/dist/{embeddings-HDNAGCOS.js → embeddings-VZPCFCEY.js} +7 -5
  47. package/dist/ingest-QEKMNVL7.js +20 -0
  48. package/dist/{keychain-5KXUHKMF.js → keychain-2PXI2EGF.js} +3 -3
  49. package/dist/mcp.js +18 -14
  50. package/dist/mcp.js.map +1 -1
  51. package/dist/{memory-value-6JUQEYJZ.js → memory-value-XSPRH6KY.js} +11 -10
  52. package/dist/provenance-GJR7S7VA.js +50 -0
  53. package/dist/provenance-GJR7S7VA.js.map +1 -0
  54. package/dist/quality-TWOC3UMF.js +25 -0
  55. package/dist/retrieval-RW6YBQ6P.js +15 -0
  56. package/dist/{store-5C7ZKKZF.js → store-HIM5US7B.js} +4 -4
  57. package/dist/sync-server.js +5 -2
  58. package/dist/sync-server.js.map +1 -1
  59. package/dist/{tasks-AJ62N26N.js → tasks-TAXJSUKB.js} +11 -10
  60. package/dist/{usage-VQ5LJCNH.js → usage-XMYRFJBJ.js} +7 -4
  61. package/dist/{usage-VQ5LJCNH.js.map → usage-XMYRFJBJ.js.map} +1 -1
  62. package/drizzle/0011_compact_telemetry_dedupe_keys.sql +25 -0
  63. package/drizzle/meta/_journal.json +7 -0
  64. package/package.json +15 -12
  65. package/dist/chunk-53GKSF42.js.map +0 -1
  66. package/dist/chunk-65XK27KK.js.map +0 -1
  67. package/dist/chunk-6QFOCUEJ.js.map +0 -1
  68. package/dist/chunk-7Q5CBVUT.js.map +0 -1
  69. package/dist/chunk-JKWK73GY.js.map +0 -1
  70. package/dist/chunk-JO5LRCA2.js.map +0 -1
  71. package/dist/chunk-LUIYWYOT.js.map +0 -1
  72. package/dist/dispatcher-ON7LNX6X.js +0 -21
  73. package/dist/ingest-MHPMJPUA.js +0 -18
  74. package/dist/quality-HVTIOIXP.js +0 -24
  75. package/dist/retrieval-72EIHKRF.js +0 -13
  76. package/dist/tasks-AJ62N26N.js.map +0 -1
  77. /package/dist/{chunk-JYWURG5T.js.map → cleanup-YCYA6BJB.js.map} +0 -0
  78. /package/dist/{cleanup-RHNBHBNP.js.map → dispatcher-FP3WS74F.js.map} +0 -0
  79. /package/dist/{dispatcher-ON7LNX6X.js.map → embeddings-VZPCFCEY.js.map} +0 -0
  80. /package/dist/{embeddings-HDNAGCOS.js.map → ingest-QEKMNVL7.js.map} +0 -0
  81. /package/dist/{ingest-MHPMJPUA.js.map → keychain-2PXI2EGF.js.map} +0 -0
  82. /package/dist/{keychain-5KXUHKMF.js.map → memory-value-XSPRH6KY.js.map} +0 -0
  83. /package/dist/{memory-value-6JUQEYJZ.js.map → quality-TWOC3UMF.js.map} +0 -0
  84. /package/dist/{quality-HVTIOIXP.js.map → retrieval-RW6YBQ6P.js.map} +0 -0
  85. /package/dist/{retrieval-72EIHKRF.js.map → store-HIM5US7B.js.map} +0 -0
  86. /package/dist/{store-5C7ZKKZF.js.map → tasks-TAXJSUKB.js.map} +0 -0
@@ -1,26 +1,33 @@
1
1
  import {
2
2
  matchTokens,
3
3
  textMatchScore
4
- } from "./chunk-FHEH6QDU.js";
5
- import {
6
- desc
7
- } from "./chunk-CW3XJDH7.js";
4
+ } from "./chunk-7Z3CCCS2.js";
8
5
  import {
9
6
  appendEvidence,
10
7
  countDistinctCorrectionSessions,
11
8
  createMemory,
12
- defineOwn,
13
9
  demoteMemory,
14
10
  getMemory,
11
+ hasNonDurableProvenance,
15
12
  incrementMemoryRepetition,
13
+ isGeneratedCaptureContext,
14
+ isTaskLimitedRule,
16
15
  listMemories,
17
16
  memoryDedupeKey,
18
17
  normalizeDedupeText,
19
18
  promoteMemory,
20
19
  queryMemories,
20
+ recordAudit,
21
+ recordAuditWithSnapshot,
21
22
  restoreAutoInject,
22
23
  updateMemoryCaptureContext
23
- } from "./chunk-JO5LRCA2.js";
24
+ } from "./chunk-HFHNPOBW.js";
25
+ import {
26
+ desc
27
+ } from "./chunk-RWEX4VJE.js";
28
+ import {
29
+ defineOwn
30
+ } from "./chunk-AQOI4FCW.js";
24
31
  import {
25
32
  CONFIDENCE,
26
33
  LlmCredentialError,
@@ -30,11 +37,11 @@ import {
30
37
  findSimilarRejectedExemplar,
31
38
  loadEmbeddingConfigFromEnv,
32
39
  queueMemoryEmbeddingSync
33
- } from "./chunk-JKWK73GY.js";
40
+ } from "./chunk-BWKFROGW.js";
34
41
  import {
35
42
  hasProviderConfigured,
36
43
  init_keychain
37
- } from "./chunk-WZWXYBP6.js";
44
+ } from "./chunk-XCFTE74H.js";
38
45
  import {
39
46
  activityEvents,
40
47
  and,
@@ -55,128 +62,28 @@ import {
55
62
  memoryMaintenanceTasks,
56
63
  or,
57
64
  sql
58
- } from "./chunk-LUIYWYOT.js";
65
+ } from "./chunk-VSEAVK7X.js";
66
+ import {
67
+ init_define_RECALL_BUILD_INFO
68
+ } from "./chunk-CYAODQOH.js";
59
69
 
60
70
  // src/maintenance/tasks.ts
61
- import { randomUUID as randomUUID5 } from "crypto";
71
+ init_define_RECALL_BUILD_INFO();
72
+ import { randomUUID as randomUUID4 } from "crypto";
62
73
  import { z } from "zod";
63
74
 
64
75
  // src/maintenance/appliers.ts
65
- import { randomUUID as randomUUID4 } from "crypto";
76
+ init_define_RECALL_BUILD_INFO();
77
+ import { randomUUID as randomUUID3 } from "crypto";
66
78
 
67
- // src/audit/trail.ts
68
- import { randomUUID } from "crypto";
69
- function recordAudit(db, memoryId, action, actor, reason, beforeSnapshot, afterSnapshot) {
70
- const id = randomUUID();
71
- if (afterSnapshot === void 0) {
72
- const mem = getMemory(db, memoryId);
73
- if (mem) {
74
- afterSnapshot = JSON.stringify(mem);
75
- }
76
- }
77
- db.insert(auditTrail).values({
78
- id,
79
- memory_id: memoryId,
80
- action,
81
- actor,
82
- before_snapshot: beforeSnapshot ?? null,
83
- after_snapshot: afterSnapshot ?? null,
84
- reason: reason ?? null,
85
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
86
- }).run();
87
- return id;
88
- }
89
- function recordAuditWithSnapshot(db, memoryId, action, actor, reason, before, after) {
90
- return recordAudit(
91
- db,
92
- memoryId,
93
- action,
94
- actor,
95
- reason,
96
- before ? JSON.stringify(before) : null,
97
- after ? JSON.stringify(after) : null
98
- );
99
- }
100
- function getAuditTrail(db, memoryId) {
101
- return db.select().from(auditTrail).where(eq(auditTrail.memory_id, memoryId)).orderBy(desc(auditTrail.timestamp)).all().map(rowToAudit);
102
- }
103
- function getRecentAudit(db, limit = 50) {
104
- return db.select().from(auditTrail).orderBy(desc(auditTrail.timestamp)).limit(limit).all().map(rowToAudit);
105
- }
106
- function diffSnapshots(before, after) {
107
- if (!before || !after) return [];
108
- const a = JSON.parse(before);
109
- const b = JSON.parse(after);
110
- const diffs = [];
111
- const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
112
- for (const key of keys) {
113
- if (key === "evidence" || key === "embedding") continue;
114
- const va = JSON.stringify(a[key]);
115
- const vb = JSON.stringify(b[key]);
116
- if (va !== vb) {
117
- diffs.push({ field: key, before: a[key], after: b[key] });
118
- }
119
- }
120
- return diffs;
121
- }
122
- function rollbackMemory(db, memoryId, auditEntryId, actor) {
123
- const entry = db.select().from(auditTrail).where(eq(auditTrail.id, auditEntryId)).get();
124
- if (!entry) return false;
125
- const snapshot = entry.before_snapshot;
126
- if (!snapshot) return false;
127
- const beforeRollback = getMemory(db, memoryId);
128
- const restored = JSON.parse(snapshot);
129
- db.update(memories).set({
130
- text: restored.text,
131
- type: restored.type,
132
- scope: restored.scope,
133
- path_scope: restored.path_scope,
134
- status: restored.status,
135
- confidence: restored.confidence,
136
- source: restored.source,
137
- evidence: restored.evidence,
138
- capture_context: restored.capture_context,
139
- repetition_count: restored.repetition_count,
140
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
141
- }).where(eq(memories.id, memoryId)).run();
142
- queueMemoryEmbeddingSync(db, memoryId);
143
- recordAuditWithSnapshot(
144
- db,
145
- memoryId,
146
- "rolled_back",
147
- actor,
148
- `Rolled back to state from ${entry.timestamp}`,
149
- beforeRollback ?? null,
150
- getMemory(db, memoryId) ?? null
151
- );
152
- return true;
153
- }
154
- function formatAuditTrail(entries) {
155
- if (entries.length === 0) return "No audit entries.";
156
- const lines = ["# Audit Trail", ""];
157
- for (const e of entries) {
158
- const diffs = diffSnapshots(e.before_snapshot, e.after_snapshot);
159
- const diffStr = diffs.length > 0 ? ` [${diffs.map((d) => `${d.field}: ${JSON.stringify(d.before)} \u2192 ${JSON.stringify(d.after)}`).join(", ")}]` : "";
160
- lines.push(
161
- `${e.timestamp.slice(0, 19)} ${e.action.padEnd(22)} by ${e.actor}${e.reason ? ` \u2014 ${e.reason}` : ""}${diffStr}`
162
- );
163
- }
164
- return lines.join("\n");
165
- }
166
- function rowToAudit(row) {
167
- return {
168
- id: row.id,
169
- memory_id: row.memory_id,
170
- action: row.action,
171
- actor: row.actor,
172
- before_snapshot: row.before_snapshot,
173
- after_snapshot: row.after_snapshot,
174
- reason: row.reason,
175
- timestamp: row.timestamp
176
- };
177
- }
79
+ // src/capture/correction.ts
80
+ init_define_RECALL_BUILD_INFO();
81
+
82
+ // src/repo/quality.ts
83
+ init_define_RECALL_BUILD_INFO();
178
84
 
179
85
  // src/health/scoring.ts
86
+ init_define_RECALL_BUILD_INFO();
180
87
  var WEIGHTS = {
181
88
  confidence: 0.4,
182
89
  freshness: 0.25,
@@ -400,6 +307,7 @@ function clamp2(n, min = 0, max = 1) {
400
307
  }
401
308
 
402
309
  // src/maintenance/dispatcher.ts
310
+ init_define_RECALL_BUILD_INFO();
403
311
  init_keychain();
404
312
  var DISPATCH_AGENT = "recall:dispatcher";
405
313
  var DEFAULT_LEASE_SECONDS = 120;
@@ -785,6 +693,7 @@ function formatDispatchReport(report) {
785
693
  import { createHash } from "crypto";
786
694
 
787
695
  // src/capture/scope.ts
696
+ init_define_RECALL_BUILD_INFO();
788
697
  import { existsSync, readFileSync } from "fs";
789
698
  import { dirname, extname, basename, join } from "path";
790
699
  var SCOPE_MARKERS = [
@@ -1045,10 +954,12 @@ function inferFromGitOwnership(filePath, repoPath) {
1045
954
  }
1046
955
 
1047
956
  // src/maintenance/cleanup.ts
1048
- import { randomUUID as randomUUID3 } from "crypto";
957
+ init_define_RECALL_BUILD_INFO();
958
+ import { randomUUID as randomUUID2 } from "crypto";
1049
959
 
1050
960
  // src/contradictions/detector.ts
1051
- import { randomUUID as randomUUID2 } from "crypto";
961
+ init_define_RECALL_BUILD_INFO();
962
+ import { randomUUID } from "crypto";
1052
963
  function countContradictionCandidates(db, repo) {
1053
964
  const conditions = [inArray(memories.status, ["active", "candidate"])];
1054
965
  if (repo) conditions.push(eq(memories.repo, repo));
@@ -1076,7 +987,7 @@ function detectContradictions(db, repo) {
1076
987
  )
1077
988
  ).get();
1078
989
  if (!existing) {
1079
- const id = randomUUID2();
990
+ const id = randomUUID();
1080
991
  const now2 = (/* @__PURE__ */ new Date()).toISOString();
1081
992
  db.insert(contradictions).values({
1082
993
  id,
@@ -1260,6 +1171,7 @@ function wordOverlap(a, b) {
1260
1171
  }
1261
1172
 
1262
1173
  // src/capture/context.ts
1174
+ init_define_RECALL_BUILD_INFO();
1263
1175
  var SYSTEM_SCAFFOLD_RE = /(?:^\s*[⏺⎿❯✻※]|<\/?task-notification>|task-notification|hook activity|\[correction_summary\]|correction_summary|session(?:start| start| end) hook|stop hook|<system-reminder>|<\/?command-(?:name|message)>|recent_tool_calls|probeport qa agent contract|you extract durable memory candidates for a personal agent runtime|required schema_version:\s*memory_extraction|##\s*(?:run context|scout assignment|lead verifier assignment|available tool commands|mapped local files|allowed secret environment names))/i;
1264
1176
  var NON_USER_CONTEXT_RE = /\b(?:sub-?agent (?:context|transcript|output|notification)|(?:during|after) compaction|compaction (?:context|summary|transcript)|compacting (?:the )?(?:context|conversation)|system repair (?:context|transcript)|self[- ]repair context|repair context|cron context)\b/i;
1265
1177
  var INJECTION_ARTIFACT_RE = new RegExp(
@@ -1310,6 +1222,7 @@ function changeControlClauses(text) {
1310
1222
  return text.split(/(?:\r?\n|[.!?;])+/).map((clause) => clause.trim()).filter((clause) => /\b(?:commit|push|committing|pushing)\b/i.test(clause));
1311
1223
  }
1312
1224
  function isEphemeralTaskConstraint(ruleText, rawPrompt) {
1225
+ if (isTaskLimitedRule(ruleText)) return true;
1313
1226
  if (!GENERIC_CHANGE_CONTROL_RE.test(ruleText)) return false;
1314
1227
  if (/\b(?:secret|credential|token|private key|\.env|config(?:uration)?|generated file|lockfile)s?\b/i.test(ruleText)) {
1315
1228
  return false;
@@ -1336,10 +1249,11 @@ function looksLikeQuestionContext(text) {
1336
1249
  return /\?\s*$/.test(text.trim()) || /(?:^|[.!?]\s+)(?:how|why|what|where|which|who|can|could|should|would|do|does|did|is|are|was|were|have|has)\b/i.test(text);
1337
1250
  }
1338
1251
  function isNonUserCaptureContext(text) {
1339
- return SYSTEM_SCAFFOLD_RE.test(text) || NON_USER_CONTEXT_RE.test(text) || INJECTION_ARTIFACT_RE.test(text) || EPHEMERAL_TASK_CONTEXT_RE.test(text) || looksLikePastedOperationalReport(text) || LLM_WORKER_PROMPT_RE.test(text) || CODEX_INTERNAL_PROMPT_RE.test(text) || looksLikeQuestionContext(text);
1252
+ return isGeneratedCaptureContext(text) || SYSTEM_SCAFFOLD_RE.test(text) || NON_USER_CONTEXT_RE.test(text) || INJECTION_ARTIFACT_RE.test(text) || EPHEMERAL_TASK_CONTEXT_RE.test(text) || looksLikePastedOperationalReport(text) || LLM_WORKER_PROMPT_RE.test(text) || CODEX_INTERNAL_PROMPT_RE.test(text) || looksLikeQuestionContext(text);
1340
1253
  }
1341
1254
 
1342
1255
  // src/scanner/signal.ts
1256
+ init_define_RECALL_BUILD_INFO();
1343
1257
  var ACTIVE_COMMAND_PATTERNS = [
1344
1258
  /^use\b/i
1345
1259
  ];
@@ -1459,7 +1373,7 @@ var SUPPRESS_INJECTION_FLOOR = 50;
1459
1373
  var GLOBALIZE_REPO_FLOOR = 3;
1460
1374
  var DEFAULT_ACTOR = "maintenance:cleanup";
1461
1375
  function runDeterministicCleanup(db, opts = { dryRun: true }) {
1462
- const runId = randomUUID3();
1376
+ const runId = randomUUID2();
1463
1377
  const startedAt = (/* @__PURE__ */ new Date()).toISOString();
1464
1378
  const plan = [];
1465
1379
  if (!opts.only || opts.only === "dedupe_exact_merge") {
@@ -1674,7 +1588,7 @@ function applyDedupeExact(db, runId, plan) {
1674
1588
  after ?? null
1675
1589
  );
1676
1590
  db.insert(maintenanceCleanupLog).values({
1677
- id: randomUUID3(),
1591
+ id: randomUUID2(),
1678
1592
  run_id: runId,
1679
1593
  action: "dedupe_exact_merge",
1680
1594
  memory_id: loser.id,
@@ -1870,7 +1784,7 @@ function applyRejectFragment(db, runId, plan) {
1870
1784
  after ?? null
1871
1785
  );
1872
1786
  db.insert(maintenanceCleanupLog).values({
1873
- id: randomUUID3(),
1787
+ id: randomUUID2(),
1874
1788
  run_id: runId,
1875
1789
  action: "reject_fragment_candidate",
1876
1790
  memory_id: plan.memory_id,
@@ -1914,7 +1828,7 @@ function applyRejectTestFixtureRepo(db, runId, plan) {
1914
1828
  after ?? null
1915
1829
  );
1916
1830
  db.insert(maintenanceCleanupLog).values({
1917
- id: randomUUID3(),
1831
+ id: randomUUID2(),
1918
1832
  run_id: runId,
1919
1833
  action: "reject_test_fixture_repo",
1920
1834
  memory_id: plan.memory_id,
@@ -1983,7 +1897,7 @@ function applyRejectInvalidScope(db, runId, plan) {
1983
1897
  after ?? null
1984
1898
  );
1985
1899
  db.insert(maintenanceCleanupLog).values({
1986
- id: randomUUID3(),
1900
+ id: randomUUID2(),
1987
1901
  run_id: runId,
1988
1902
  action: "reject_invalid_scope",
1989
1903
  memory_id: plan.memory_id,
@@ -2042,7 +1956,7 @@ function applyRejectGenericScannedTooling(db, runId, plan) {
2042
1956
  after ?? null
2043
1957
  );
2044
1958
  db.insert(maintenanceCleanupLog).values({
2045
- id: randomUUID3(),
1959
+ id: randomUUID2(),
2046
1960
  run_id: runId,
2047
1961
  action: "reject_generic_scanned_tooling",
2048
1962
  memory_id: plan.memory_id,
@@ -2070,6 +1984,8 @@ function planPromoteRepeats(db) {
2070
1984
  const out = [];
2071
1985
  for (const row of rows) {
2072
1986
  const text = row.text.trim();
1987
+ const memory = getMemory(db, row.id);
1988
+ if (!memory || hasNonDurableProvenance(memory)) continue;
2073
1989
  if (row.scope === "session") continue;
2074
1990
  if (qualityReasons(text).length > 0) continue;
2075
1991
  if (isDestructiveRisky(text)) continue;
@@ -2081,7 +1997,7 @@ function planPromoteRepeats(db) {
2081
1997
  }
2082
1998
  function applyPromoteRepeat(db, runId, plan) {
2083
1999
  const before = getMemory(db, plan.memory_id);
2084
- if (!before || before.status !== "candidate") return;
2000
+ if (!before || before.status !== "candidate" || hasNonDurableProvenance(before)) return;
2085
2001
  const now = (/* @__PURE__ */ new Date()).toISOString();
2086
2002
  db.update(memories).set({ status: "active", confidence: Math.max(before.confidence, 0.7), updated_at: now, last_validated_at: now }).where(eq(memories.id, plan.memory_id)).run();
2087
2003
  const after = getMemory(db, plan.memory_id);
@@ -2095,7 +2011,7 @@ function applyPromoteRepeat(db, runId, plan) {
2095
2011
  after ?? null
2096
2012
  );
2097
2013
  db.insert(maintenanceCleanupLog).values({
2098
- id: randomUUID3(),
2014
+ id: randomUUID2(),
2099
2015
  run_id: runId,
2100
2016
  action: "promote_repeat_correction",
2101
2017
  memory_id: plan.memory_id,
@@ -2153,7 +2069,7 @@ function applySuppressCommand(db, runId, plan) {
2153
2069
  after ?? null
2154
2070
  );
2155
2071
  db.insert(maintenanceCleanupLog).values({
2156
- id: randomUUID3(),
2072
+ id: randomUUID2(),
2157
2073
  run_id: runId,
2158
2074
  action: "suppress_unproductive_command",
2159
2075
  memory_id: plan.memory_id,
@@ -2248,7 +2164,7 @@ function applyGlobalizeCrossRepo(db, runId, plan) {
2248
2164
  after ?? null
2249
2165
  );
2250
2166
  db.insert(maintenanceCleanupLog).values({
2251
- id: randomUUID3(),
2167
+ id: randomUUID2(),
2252
2168
  run_id: runId,
2253
2169
  action: "globalize_cross_repo",
2254
2170
  memory_id: winner.id,
@@ -2275,7 +2191,7 @@ function applyGlobalizeCrossRepo(db, runId, plan) {
2275
2191
  afterLoser ?? null
2276
2192
  );
2277
2193
  db.insert(maintenanceCleanupLog).values({
2278
- id: randomUUID3(),
2194
+ id: randomUUID2(),
2279
2195
  run_id: runId,
2280
2196
  action: "globalize_cross_repo",
2281
2197
  memory_id: loserId,
@@ -2422,6 +2338,7 @@ function truncate(s, n) {
2422
2338
  }
2423
2339
 
2424
2340
  // src/security/redaction.ts
2341
+ init_define_RECALL_BUILD_INFO();
2425
2342
  var SECRET_PATTERNS = [
2426
2343
  [/\b(Authorization\s*:\s*Bearer\s+)[^\s"'\\]+/gi, "$1[REDACTED]"],
2427
2344
  [/\b(api-key\s*:\s*)[^\s"'\\]+/gi, "$1[REDACTED]"],
@@ -2654,7 +2571,9 @@ async function processCorrection(db, text, ctx) {
2654
2571
  wakeDispatcherBestEffort();
2655
2572
  return { ids: [], pendingTaskId: taskId ?? `dedup:${promptId}` };
2656
2573
  }
2657
- const corrections = detectCorrections(text);
2574
+ const corrections = detectCorrections(text).filter(
2575
+ (correction) => correction.type === "review_pattern" || qualityReasons(correction.text).length === 0
2576
+ );
2658
2577
  if (corrections.length === 0 && ctx.force_semantic_capture) {
2659
2578
  corrections.push({
2660
2579
  type: "rule",
@@ -2667,12 +2586,12 @@ async function processCorrection(db, text, ctx) {
2667
2586
  const profile = getRepoQualityProfile(db, ctx.repo);
2668
2587
  const ids = [];
2669
2588
  const captureContext = buildCaptureContext(ctx);
2589
+ let blockedByRejectedExemplar = 0;
2670
2590
  for (const correction of corrections) {
2671
- if (correction.type !== "review_pattern") {
2672
- const reasons = qualityReasons(correction.text);
2673
- if (reasons.length > 0) continue;
2591
+ if (await isSimilarToRejectedFragmentSemantic(db, correction.text)) {
2592
+ blockedByRejectedExemplar++;
2593
+ continue;
2674
2594
  }
2675
- if (await isSimilarToRejectedFragmentSemantic(db, correction.text)) continue;
2676
2595
  const evidence = correction.type === "review_pattern" ? {
2677
2596
  type: "review_feedback",
2678
2597
  reported_by_user: true,
@@ -2754,7 +2673,7 @@ async function processCorrection(db, text, ctx) {
2754
2673
  });
2755
2674
  ids.push(id);
2756
2675
  }
2757
- return { ids };
2676
+ return { ids, blockedByRejectedExemplar };
2758
2677
  }
2759
2678
  function stablePromptId(sessionId, repo, text) {
2760
2679
  const hash = createHash("sha256").update(`${sessionId}${repo ?? ""}${normalizeDedupeText(text)}`).digest("hex").slice(0, 16);
@@ -2848,17 +2767,16 @@ function textSimilarity(a, b) {
2848
2767
  }
2849
2768
  var REJECTED_EXEMPLAR_THRESHOLD = 0.7;
2850
2769
  var REJECTED_EXEMPLAR_SEMANTIC_THRESHOLD = 0.85;
2851
- function isMachineRejection(db, memoryId) {
2852
- const latest = db.select({ actor: auditTrail.actor }).from(auditTrail).where(and(eq(auditTrail.memory_id, memoryId), eq(auditTrail.action, "rejected"))).orderBy(desc(auditTrail.timestamp)).limit(1).get();
2853
- if (!latest) return false;
2854
- return MACHINE_REJECTION_ACTORS.some((actor) => latest.actor.startsWith(actor));
2770
+ var HUMAN_REJECTION_ACTORS = ["mcp", "cli"];
2771
+ function isHumanRejection(db, memoryId) {
2772
+ const rows = db.select({ actor: auditTrail.actor }).from(auditTrail).where(and(eq(auditTrail.memory_id, memoryId), eq(auditTrail.action, "rejected"))).all();
2773
+ return rows.some((row) => HUMAN_REJECTION_ACTORS.includes(row.actor));
2855
2774
  }
2856
- var MACHINE_REJECTION_ACTORS = ["auto-pruner", "cleanup_script", "maintenance:cleanup"];
2857
2775
  function isSimilarToRejectedFragment(db, text, threshold = REJECTED_EXEMPLAR_THRESHOLD) {
2858
2776
  const rejected = queryMemories(db, { status: "rejected" }).filter((m) => m.source === "user_correction" || m.source === "user_reported_review");
2859
2777
  for (const exemplar of rejected) {
2860
2778
  if (textSimilarity(text, exemplar.text) < threshold) continue;
2861
- if (isMachineRejection(db, exemplar.id)) continue;
2779
+ if (!isHumanRejection(db, exemplar.id)) continue;
2862
2780
  return true;
2863
2781
  }
2864
2782
  return false;
@@ -2869,7 +2787,13 @@ async function isSimilarToRejectedFragmentSemantic(db, text, options = {}) {
2869
2787
  if (isSimilarToRejectedFragment(db, text, lexicalT)) return true;
2870
2788
  const config = loadEmbeddingConfigFromEnv();
2871
2789
  if (!config) return false;
2872
- const match = await findSimilarRejectedExemplar(db, text, config, semanticT);
2790
+ const match = await findSimilarRejectedExemplar(
2791
+ db,
2792
+ text,
2793
+ config,
2794
+ semanticT,
2795
+ (id) => isHumanRejection(db, id)
2796
+ );
2873
2797
  return match != null;
2874
2798
  }
2875
2799
  async function findDuplicateMemory(db, repo, type, text, threshold) {
@@ -3104,7 +3028,7 @@ function applySummarizeSession(db, task, result) {
3104
3028
  const payload = task.payload;
3105
3029
  const sessionId = payload.session_id;
3106
3030
  if (!sessionId) throw new ApplyError("payload missing session_id", "invalid-state");
3107
- const id = randomUUID4();
3031
+ const id = randomUUID3();
3108
3032
  const now = (/* @__PURE__ */ new Date()).toISOString();
3109
3033
  db.insert(historySnippets).values({
3110
3034
  id,
@@ -3122,7 +3046,7 @@ function applySynthesizeRepo(db, task, result) {
3122
3046
  const payload = task.payload;
3123
3047
  const repo = payload.repo;
3124
3048
  if (!repo) throw new ApplyError("payload missing repo", "invalid-state");
3125
- const id = randomUUID4();
3049
+ const id = randomUUID3();
3126
3050
  const now = (/* @__PURE__ */ new Date()).toISOString();
3127
3051
  db.insert(historySnippets).values({
3128
3052
  id,
@@ -3140,7 +3064,7 @@ function applyExtractRulesFromPrompt(db, task, result) {
3140
3064
  const payload = task.payload;
3141
3065
  const repo = payload.repo ?? null;
3142
3066
  const profile = getRepoQualityProfile(db, repo ?? void 0);
3143
- if (!result.rules || result.rules.length === 0) {
3067
+ if (!result.rules || result.rules.length === 0 || isNonUserCaptureContext(payload.raw_prompt ?? "")) {
3144
3068
  return { audit_entry_id: null, target_id: task.id, changed_fields: [] };
3145
3069
  }
3146
3070
  const captureContext = {
@@ -3356,7 +3280,7 @@ function hasActiveTaskForTarget(db, kind, target) {
3356
3280
  }
3357
3281
  function insertTaskIdempotent(db, input) {
3358
3282
  if (hasActiveTaskForTarget(db, input.kind, input.target)) return null;
3359
- const id = randomUUID5();
3283
+ const id = randomUUID4();
3360
3284
  db.insert(memoryMaintenanceTasks).values({
3361
3285
  id,
3362
3286
  kind: input.kind,
@@ -4048,12 +3972,8 @@ export {
4048
3972
  formatHealthReport,
4049
3973
  getRepoQualityProfile,
4050
3974
  seedScannedConfidence,
4051
- recordAudit,
4052
- recordAuditWithSnapshot,
4053
- getAuditTrail,
4054
- getRecentAudit,
4055
- rollbackMemory,
4056
- formatAuditTrail,
3975
+ isEphemeralTaskConstraint,
3976
+ isNonUserCaptureContext,
4057
3977
  DEFAULT_LEASE_SECONDS2 as DEFAULT_LEASE_SECONDS,
4058
3978
  DEFAULT_PRIORITIES,
4059
3979
  DEFAULT_ENQUEUE_CONFIG,
@@ -4118,4 +4038,4 @@ export {
4118
4038
  processCorrection,
4119
4039
  processReviewFeedback
4120
4040
  };
4121
- //# sourceMappingURL=chunk-65XK27KK.js.map
4041
+ //# sourceMappingURL=chunk-HUMJTWWT.js.map