thumbgate 1.39.0 → 1.40.1

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 (180) hide show
  1. package/.agents/skills/craft-playbook-gate/SKILL.md +51 -0
  2. package/.agents/skills/qwenwork-policy-group-honesty-not-clone/SKILL.md +36 -0
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.well-known/llms.txt +2 -2
  5. package/.well-known/mcp/server-card.json +1 -1
  6. package/README.md +11 -5
  7. package/adapters/claude/.mcp.json +6 -2
  8. package/adapters/codex/config.toml +5 -0
  9. package/adapters/forge/forge.yaml +4 -4
  10. package/adapters/future-agi/.mcp.json +1 -1
  11. package/adapters/future-agi/config.toml +1 -1
  12. package/adapters/future-agi/opencode.json +1 -1
  13. package/adapters/herdr/herdr-plugin.toml +2 -2
  14. package/adapters/mcp/server-stdio.js +104 -7
  15. package/adapters/opencode/opencode.json +1 -1
  16. package/adapters/strands/strands-middleware.js +31 -4
  17. package/bin/cli.js +191 -54
  18. package/config/brand-standards.json +131 -0
  19. package/config/gates/default.json +18 -1
  20. package/config/github-about.json +1 -1
  21. package/config/mcp-allowlists.json +16 -3
  22. package/config/merge-quality-checks.json +3 -1
  23. package/config/post-deploy-marketing-pages.json +4 -4
  24. package/config/schemas/task-outcome-receipt.schema.json +9 -0
  25. package/hooks/hooks.json +24 -0
  26. package/openapi/openapi.yaml +7 -3
  27. package/package.json +87 -33
  28. package/public/about.html +2 -2
  29. package/public/admin.html +771 -0
  30. package/public/agent-manager.html +3 -3
  31. package/public/agents-cost-savings.html +1 -1
  32. package/public/ai-malpractice-prevention.html +12 -12
  33. package/public/architecture.html +0 -1
  34. package/public/assets/diagrams/decision.svg +3 -3
  35. package/public/assets/diagrams/hero-thumbs.svg +2 -4
  36. package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +1 -1
  37. package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +1 -1
  38. package/public/blog/git-at-agent-scale.html +2 -2
  39. package/public/blog/inside-your-boundary.html +1 -1
  40. package/public/blog/process-over-outcome-gates.html +1 -1
  41. package/public/case-studies.html +5 -6
  42. package/public/codex-enterprise.html +1 -1
  43. package/public/codex-plugin.html +1 -1
  44. package/public/dashboard.html +775 -483
  45. package/public/diagnostic.html +15 -10
  46. package/public/enterprise-governance.html +26 -174
  47. package/public/eval-scorecard.html +3 -4
  48. package/public/eval-scorecard.json +2 -2
  49. package/public/evaluations.html +0 -1
  50. package/public/founders.html +3 -3
  51. package/public/gaming-playbook.html +4 -4
  52. package/public/guide.html +3 -5
  53. package/public/index.html +302 -97
  54. package/public/install.html +16 -10
  55. package/public/js/buyer-intent.js +49 -8
  56. package/public/lessons.html +246 -83
  57. package/public/numbers.html +32 -33
  58. package/public/operator-framework.html +44 -72
  59. package/public/peter.html +3 -3
  60. package/public/platform-partners.html +1 -1
  61. package/public/pricing.html +163 -66
  62. package/public/pro.html +3 -1
  63. package/public/project-switcher.js +76 -0
  64. package/public/whitepaper.html +1 -2
  65. package/scripts/action-receipts.js +393 -0
  66. package/scripts/activation-quickstart.js +15 -3
  67. package/scripts/activation-tracker.js +280 -3
  68. package/scripts/agent-action-inventory.js +235 -143
  69. package/scripts/agent-operations-planner.js +1 -1
  70. package/scripts/agent-readiness.js +36 -6
  71. package/scripts/agentic-prompt-pipelines.js +901 -0
  72. package/scripts/analytics-window.js +7 -1
  73. package/scripts/async-job-runner.js +66 -11
  74. package/scripts/audit-trail.js +37 -24
  75. package/scripts/auto-promote-gates.js +37 -27
  76. package/scripts/auto-wire-hooks.js +64 -25
  77. package/scripts/backfill-lesson-scopes.js +122 -0
  78. package/scripts/billing.js +889 -132
  79. package/scripts/bot-detection.js +112 -0
  80. package/scripts/brand-standards-gate.js +571 -0
  81. package/scripts/chatgpt-ads-readiness-pack.js +1 -1
  82. package/scripts/cli-demo.js +5 -27
  83. package/scripts/cli-schema.js +25 -1
  84. package/scripts/commercial-offer.js +2 -2
  85. package/scripts/contextfs.js +9 -3
  86. package/scripts/craft-playbook-gate.js +550 -0
  87. package/scripts/cross-encoder-reranker.js +4 -0
  88. package/scripts/dashboard-chat.js +11 -0
  89. package/scripts/dashboard.js +574 -167
  90. package/scripts/decision-journal.js +7 -4
  91. package/scripts/docker-sandbox-planner.js +3 -3
  92. package/scripts/export-dpo-pairs.js +12 -7
  93. package/scripts/failure-diagnostics.js +11 -0
  94. package/scripts/feedback-aggregate.js +4 -0
  95. package/scripts/feedback-attribution.js +6 -4
  96. package/scripts/feedback-history-distiller.js +18 -6
  97. package/scripts/feedback-loop.js +255 -89
  98. package/scripts/feedback-paths.js +8 -1
  99. package/scripts/feedback-sanitizer.js +5 -0
  100. package/scripts/feedback-scope.js +106 -0
  101. package/scripts/feedback-session.js +8 -2
  102. package/scripts/filesystem-search.js +13 -8
  103. package/scripts/financial-control-plane.js +707 -45
  104. package/scripts/gate-stats.js +38 -5
  105. package/scripts/gates-engine.js +1326 -240
  106. package/scripts/generate-eval-scorecard.js +0 -1
  107. package/scripts/gitlab-sdlc-prompts.js +397 -0
  108. package/scripts/harness-tool-names.js +31 -5
  109. package/scripts/hook-runtime.js +10 -0
  110. package/scripts/hybrid-feedback-context.js +7 -2
  111. package/scripts/intervention-policy.js +2 -1
  112. package/scripts/lesson-canonical.js +2 -2
  113. package/scripts/lesson-db.js +55 -14
  114. package/scripts/lesson-graph.js +2 -1
  115. package/scripts/lesson-retrieval.js +95 -9
  116. package/scripts/lesson-search.js +86 -22
  117. package/scripts/lesson-synthesis.js +21 -5
  118. package/scripts/mabl-failure-honesty.js +273 -0
  119. package/scripts/mailer/index.js +17 -1
  120. package/scripts/mailer/resend-mailer.js +213 -179
  121. package/scripts/migrate-project-scope.js +209 -0
  122. package/scripts/model-distress-detector.js +3 -3
  123. package/scripts/operational-integrity.js +436 -3
  124. package/scripts/override-audit.js +2 -0
  125. package/scripts/owner-admin.js +338 -0
  126. package/scripts/pr-manager.js +194 -1
  127. package/scripts/product-feedback.js +35 -0
  128. package/scripts/progressive-signoff.js +260 -0
  129. package/scripts/project-catalog.js +243 -0
  130. package/scripts/project-dashboard.js +61 -0
  131. package/scripts/project-evidence.js +172 -0
  132. package/scripts/project-identity.js +182 -0
  133. package/scripts/project-scope.js +381 -0
  134. package/scripts/prompt-eval.js +1 -1
  135. package/scripts/prompt-guard.js +446 -52
  136. package/scripts/proof-report.js +232 -0
  137. package/scripts/provider-action-normalizer.js +14 -6
  138. package/scripts/qwenwork-policy-group.js +413 -0
  139. package/scripts/rate-limiter.js +41 -0
  140. package/scripts/secret-redaction.js +171 -25
  141. package/scripts/secret-scanner.js +101 -42
  142. package/scripts/self-protection.js +2 -2
  143. package/scripts/seo-gsd.js +14 -14
  144. package/scripts/session-context-dedupe.js +66 -0
  145. package/scripts/settings-hierarchy.js +4 -2
  146. package/scripts/statusline-meta.js +34 -23
  147. package/scripts/tailscale-october-access.js +416 -0
  148. package/scripts/task-outcomes.js +58 -2
  149. package/scripts/telemetry-analytics.js +260 -16
  150. package/scripts/thumbgate-search.js +23 -9
  151. package/scripts/tool-kpi-tracker.js +5 -2
  152. package/scripts/tool-registry.js +42 -1
  153. package/scripts/triage-savings-calculator.js +1 -1
  154. package/scripts/vector-store.js +4 -1
  155. package/scripts/verified-lessons.js +270 -0
  156. package/scripts/verify-marketing-pages-deployed.js +2 -2
  157. package/scripts/workflow-sentinel.js +29 -10
  158. package/server.json +2 -2
  159. package/src/api/server.js +2478 -470
  160. package/src/feedback.js +21 -0
  161. package/src/hermes-sync-plane.js +2 -1
  162. package/src/index.js +2 -0
  163. package/src/lesson-search.js +9 -0
  164. package/src/mckinsey-top-company-ai-coding.js +493 -0
  165. package/src/mcp/email-triage-server/index.js +973 -0
  166. package/src/mcp/email-triage-server/package.json +12 -0
  167. package/src/mcp/server.js +3 -0
  168. package/src/mcp-writeguard.js +772 -11
  169. package/src/openshell-lovable-engine.js +1475 -0
  170. package/src/task-outcome.js +3 -0
  171. package/config/evals/agent-safety-eval.json +0 -447
  172. package/config/evals/retrieval-ranking-golden.json +0 -522
  173. package/config/progressive/01-wire-only.json +0 -11
  174. package/config/progressive/02-dashboard-empty-ok.json +0 -10
  175. package/config/progressive/03-one-lesson.json +0 -10
  176. package/config/progressive/04-warn-fires.json +0 -11
  177. package/config/progressive/05-strict-optional.json +0 -11
  178. package/config/progressive/README.md +0 -15
  179. package/public/assets/diagrams/agent-integration.png +0 -0
  180. package/public/assets/diagrams/thumbgate-architecture.png +0 -0
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ const { tenantDataScope, assertScopedDataPath } = require('./feedback-scope');
5
+
4
6
  /**
5
7
  * Lesson DB — SQLite + FTS5 backing store for feedback & memories.
6
8
  *
@@ -16,15 +18,27 @@ const path = require('node:path');
16
18
  const fs = require('node:fs');
17
19
  const { readJsonl } = require('./fs-utils');
18
20
  const { resolveFeedbackDir } = require('./feedback-paths');
21
+ const { projectForRecord } = require('./project-identity');
19
22
 
20
23
  function resolveDefaultDbPath(options = {}) {
21
24
  return path.join(resolveFeedbackDir(options), 'lessons.sqlite');
22
25
  }
23
26
 
27
+ function upgradeProjectColumns(db) {
28
+ db.transaction(() => {
29
+ const columns = new Set(db.prepare('PRAGMA table_info(lessons)').all().map((column) => column.name));
30
+ if (!columns.has('projectKey')) db.exec("ALTER TABLE lessons ADD COLUMN projectKey TEXT NOT NULL DEFAULT 'unassigned'");
31
+ if (!columns.has('sourceRecordId')) db.exec('ALTER TABLE lessons ADD COLUMN sourceRecordId TEXT');
32
+ if (!columns.has('projectName')) db.exec("ALTER TABLE lessons ADD COLUMN projectName TEXT NOT NULL DEFAULT 'Unassigned (before project tracking)'");
33
+ db.exec('CREATE INDEX IF NOT EXISTS idx_lessons_project ON lessons(projectKey, timestamp)');
34
+ })();
35
+ }
36
+
24
37
  /** @returns {import('better-sqlite3').Database} */
25
38
  function initDB(dbPath) {
26
39
  const Database = require('better-sqlite3');
27
- const resolvedPath = dbPath || process.env.LESSON_DB_PATH || resolveDefaultDbPath();
40
+ const scope = tenantDataScope();
41
+ const resolvedPath = scope ? assertScopedDataPath(dbPath || path.join(scope.feedbackDir, 'lessons.sqlite')) : (dbPath || process.env.LESSON_DB_PATH || resolveDefaultDbPath());
28
42
 
29
43
  // Ensure parent directory exists
30
44
  const dir = path.dirname(resolvedPath);
@@ -62,6 +76,8 @@ function initDB(dbPath) {
62
76
  CREATE INDEX IF NOT EXISTS idx_lessons_skill ON lessons(skill);
63
77
  `);
64
78
 
79
+ upgradeProjectColumns(db);
80
+
65
81
  // FTS5 virtual table for full-text search
66
82
  db.exec(`
67
83
  CREATE VIRTUAL TABLE IF NOT EXISTS lessons_fts USING fts5(
@@ -175,12 +191,27 @@ function searchSessions(db, query, limit = 10) {
175
191
  * 3. Always store if whatToChange is empty (raw feedback, not actionable yet)
176
192
  */
177
193
  function upsertLesson(db, feedbackEvent, memoryRecord) {
194
+ return db.transaction(() => upsertLessonInTransaction(db, feedbackEvent, memoryRecord)).immediate();
195
+ }
196
+
197
+ function upsertLessonInTransaction(db, feedbackEvent, memoryRecord) {
178
198
  // Rule 1: skip pruned records — they add noise, not signal
179
199
  if (memoryRecord?.pruned) {
180
200
  return null;
181
201
  }
182
202
 
183
- const id = memoryRecord?.id || feedbackEvent.id;
203
+ const project = projectForRecord(feedbackEvent);
204
+ const sourceRecordId = memoryRecord?.id || feedbackEvent.id;
205
+ const prior = db.prepare('SELECT id FROM lessons WHERE projectKey = ? AND sourceRecordId = ?').get(project.projectKey, sourceRecordId);
206
+ const lookup = db.prepare('SELECT projectKey, sourceRecordId FROM lessons WHERE id = ?');
207
+ let id = prior?.id || sourceRecordId;
208
+ let collision = lookup.get(id);
209
+ let suffix = 0;
210
+ while (collision && (collision.projectKey !== project.projectKey || (collision.sourceRecordId && collision.sourceRecordId !== sourceRecordId))) {
211
+ id = sourceRecordId + '@' + project.projectKey + (suffix ? '@' + suffix : '');
212
+ suffix++;
213
+ collision = lookup.get(id);
214
+ }
184
215
  const signal = feedbackEvent.signal === 'positive' || feedbackEvent.signal === 'up' ? 'positive' : 'negative';
185
216
  const tags = Array.isArray(feedbackEvent.tags) ? feedbackEvent.tags : [];
186
217
  const tagsJson = JSON.stringify(tags);
@@ -207,9 +238,9 @@ function upsertLesson(db, feedbackEvent, memoryRecord) {
207
238
 
208
239
  const stmt = db.prepare(`
209
240
  INSERT OR REPLACE INTO lessons
210
- (id, signal, context, whatWentWrong, whatToChange, whatWorked, domain, tags, rootCause, importance, skill, timestamp, sourceFeedbackId, pruned)
241
+ (id, signal, context, whatWentWrong, whatToChange, whatWorked, domain, tags, rootCause, importance, skill, timestamp, sourceFeedbackId, pruned, projectKey, projectName, sourceRecordId)
211
242
  VALUES
212
- (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
243
+ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
213
244
  `);
214
245
 
215
246
  stmt.run(
@@ -227,6 +258,9 @@ function upsertLesson(db, feedbackEvent, memoryRecord) {
227
258
  feedbackEvent.timestamp || new Date().toISOString(),
228
259
  feedbackEvent.id,
229
260
  0, // not pruned (we skip pruned above)
261
+ project.projectKey,
262
+ project.projectName,
263
+ sourceRecordId,
230
264
  );
231
265
 
232
266
  return id;
@@ -253,10 +287,11 @@ function findDuplicate(db, whatToChange, tags, opts = null) {
253
287
  if (!whatToChange || !whatToChange.trim()) return null;
254
288
 
255
289
  // Layer 1: exact match on whatToChange text (normalized)
290
+ const projectKey = projectForRecord(opts?.feedbackEvent || opts?.memoryRecord || {}).projectKey;
256
291
  const normalized = whatToChange.trim().toLowerCase();
257
292
  const candidates = db.prepare(
258
- `SELECT id, importance, tags FROM lessons WHERE LOWER(TRIM(whatToChange)) = ?`,
259
- ).all(normalized);
293
+ `SELECT id, importance, tags FROM lessons WHERE LOWER(TRIM(whatToChange)) = ? AND projectKey = ?`,
294
+ ).all(normalized, projectKey);
260
295
 
261
296
  if (candidates.length > 0) {
262
297
  for (const c of candidates) {
@@ -290,12 +325,12 @@ function findDuplicate(db, whatToChange, tags, opts = null) {
290
325
  const rows = signalFilter
291
326
  ? db.prepare(
292
327
  `SELECT id, importance, tags, whatToChange, whatWentWrong, whatWorked
293
- FROM lessons WHERE signal = ? AND pruned = 0`,
294
- ).all(signalFilter)
328
+ FROM lessons WHERE signal = ? AND pruned = 0 AND projectKey = ?`,
329
+ ).all(signalFilter, projectKey)
295
330
  : db.prepare(
296
331
  `SELECT id, importance, tags, whatToChange, whatWentWrong, whatWorked
297
- FROM lessons WHERE pruned = 0`,
298
- ).all();
332
+ FROM lessons WHERE pruned = 0 AND projectKey = ?`,
333
+ ).all(projectKey);
299
334
  for (const row of rows) {
300
335
  const rowRecord = {
301
336
  whatToChange: row.whatToChange,
@@ -327,14 +362,14 @@ function findDuplicate(db, whatToChange, tags, opts = null) {
327
362
  * @returns {{ removed: number, kept: number }}
328
363
  */
329
364
  function compactLessons(db) {
330
- const all = db.prepare('SELECT id, whatToChange, importance, timestamp, tags FROM lessons ORDER BY timestamp DESC').all();
365
+ const all = db.prepare('SELECT id, whatToChange, importance, timestamp, tags, projectKey FROM lessons ORDER BY timestamp DESC').all();
331
366
  const seen = new Map(); // normalized whatToChange → best record
332
367
  const toDelete = [];
333
368
  const PRIORITY = { critical: 4, high: 3, medium: 2, low: 1 };
334
369
 
335
370
  for (const row of all) {
336
371
  if (!row.whatToChange || !row.whatToChange.trim()) continue;
337
- const key = row.whatToChange.trim().toLowerCase();
372
+ const key = row.projectKey + '\0' + row.whatToChange.trim().toLowerCase();
338
373
 
339
374
  if (!seen.has(key)) {
340
375
  seen.set(key, row);
@@ -383,6 +418,7 @@ function searchLessons(db, query, options = {}) {
383
418
  // No query — return most recent lessons with optional filters
384
419
  let sql = 'SELECT * FROM lessons WHERE 1=1';
385
420
  const params = [];
421
+ if (options.projectKey != null) { sql += ' AND projectKey = ?'; params.push(options.projectKey); }
386
422
 
387
423
  if (options.signal) {
388
424
  sql += ' AND signal = ?';
@@ -409,6 +445,7 @@ function searchLessons(db, query, options = {}) {
409
445
  WHERE lessons_fts MATCH ?
410
446
  `;
411
447
  const params = [safeQuery];
448
+ if (options.projectKey != null) { sql += ' AND l.projectKey = ?'; params.push(options.projectKey); }
412
449
 
413
450
  if (options.signal) {
414
451
  sql += ' AND l.signal = ?';
@@ -468,6 +505,7 @@ function inferCorrectiveActions(db, feedbackEvent, limit = 3) {
468
505
  SELECT whatToChange, tags, timestamp
469
506
  FROM lessons l
470
507
  WHERE l.signal = 'negative'
508
+ AND l.projectKey = ?
471
509
  AND l.whatToChange IS NOT NULL
472
510
  AND l.whatToChange != ''
473
511
  AND (${tagPlaceholders})
@@ -475,7 +513,7 @@ function inferCorrectiveActions(db, feedbackEvent, limit = 3) {
475
513
  LIMIT 20
476
514
  `;
477
515
 
478
- candidates = db.prepare(sql).all(...tagParams);
516
+ candidates = db.prepare(sql).all(projectForRecord(feedbackEvent).projectKey, ...tagParams);
479
517
  }
480
518
 
481
519
  // 2. Domain fallback if no tag matches
@@ -484,6 +522,7 @@ function inferCorrectiveActions(db, feedbackEvent, limit = 3) {
484
522
  SELECT whatToChange, tags, timestamp
485
523
  FROM lessons l
486
524
  WHERE l.signal = 'negative'
525
+ AND l.projectKey = ?
487
526
  AND l.whatToChange IS NOT NULL
488
527
  AND l.whatToChange != ''
489
528
  AND l.domain = ?
@@ -491,7 +530,7 @@ function inferCorrectiveActions(db, feedbackEvent, limit = 3) {
491
530
  LIMIT 10
492
531
  `;
493
532
 
494
- candidates = db.prepare(sql).all(domain);
533
+ candidates = db.prepare(sql).all(projectForRecord(feedbackEvent).projectKey, domain);
495
534
  }
496
535
 
497
536
  if (candidates.length === 0) return [];
@@ -612,6 +651,7 @@ function fallbackLikeSearch(db, query, options, limit) {
612
651
  });
613
652
 
614
653
  let sql = `SELECT * FROM lessons WHERE ${conditions.join(' AND ')}`;
654
+ if (options.projectKey != null) { sql += ' AND projectKey = ?'; params.push(options.projectKey); }
615
655
 
616
656
  if (options.signal) {
617
657
  sql += ' AND signal = ?';
@@ -647,6 +687,7 @@ function safeParseTags(tagsStr) {
647
687
 
648
688
  const lessonDbApi = {
649
689
  initDB,
690
+ upgradeProjectColumns,
650
691
  upsertLesson,
651
692
  upsertSession,
652
693
  searchSessions,
@@ -11,6 +11,7 @@ const { normalizeScope, missingScopeFields } = require('./memory-scope-readiness
11
11
 
12
12
  function scopeKey(record) {
13
13
  const scope = normalizeScope(record || {});
14
+ if (record?.projectKey) scope.projectId = record.projectKey;
14
15
  return missingScopeFields(scope).length ? null : JSON.stringify([scope.entityId, scope.projectId, scope.processId, scope.sessionId]);
15
16
  }
16
17
 
@@ -22,7 +23,7 @@ function sameScope(a, b) {
22
23
  function sameScopeIdentity(a, b) {
23
24
  const left = normalizeScope(a);
24
25
  const right = normalizeScope(b);
25
- return Object.keys(left).every(field => left[field] === right[field]);
26
+ return require('./project-identity').projectForRecord(a).projectKey === require('./project-identity').projectForRecord(b).projectKey && Object.keys(left).every(field => left[field] === right[field]);
26
27
  }
27
28
 
28
29
  const EDGE_TYPES = ['supersedes', 'contradicts', 'duplicate_of', 'refines'];
@@ -48,15 +48,20 @@ const MAX_RETRIEVAL_MEMORY_LINES = Math.max(
48
48
  function isRetrievableMemory(memory, options = {}) {
49
49
  if (!memory || typeof memory !== 'object') return false;
50
50
  const { looksLikeTransportBlob } = require('./feedback-sanitizer');
51
+ const { isTranscriptShaped } = require('./project-scope');
52
+ if (isTranscriptShaped(memory)) return false;
53
+
51
54
  const title = String(memory.title || '');
52
55
  const content = String(memory.content || '');
53
- const combined = `${title}\n${content}`.trim();
56
+ const whatWentWrong = String(memory.whatWentWrong || '');
57
+ const combined = `${title}\n${content}\n${whatWentWrong}`.trim();
54
58
  const maxChars = Number.isFinite(options.maxMemoryChars)
55
59
  ? Math.max(1, options.maxMemoryChars)
56
60
  : MAX_RETRIEVAL_MEMORY_CHARS;
57
61
  if (!combined || combined.length > maxChars) return false;
58
62
  return !looksLikeTransportBlob(title)
59
63
  && !looksLikeTransportBlob(content)
64
+ && !looksLikeTransportBlob(whatWentWrong)
60
65
  && !looksLikeTransportBlob(combined);
61
66
  }
62
67
 
@@ -71,10 +76,25 @@ function selectRetrievalMemories(memories = [], options = {}) {
71
76
  includeShared: options.includeShared !== false,
72
77
  }).allowed;
73
78
  }
74
- return selected.filter((memory) => matchesMetadataFilters(
75
- memory,
76
- options.metadataFilters || options.filters,
77
- ));
79
+
80
+ const { resolveProjectFromCwd, isLessonRelevantForProject } = require('./project-scope');
81
+ const targetProject = options.project || (options.cwd ? resolveProjectFromCwd(options.cwd) : null);
82
+ if (targetProject) {
83
+ selected = selected.filter((memory) => isLessonRelevantForProject(memory, targetProject));
84
+ }
85
+ return selected
86
+ .filter((memory) => {
87
+ if (options.includeDemoted !== true) {
88
+ const up = Number(memory.upVotes || 0);
89
+ const down = Number(memory.downVotes || 0);
90
+ if (memory.demoted === true || down > up) return false;
91
+ }
92
+ return true;
93
+ })
94
+ .filter((memory) => matchesMetadataFilters(
95
+ memory,
96
+ options.metadataFilters || options.filters,
97
+ ));
78
98
  }
79
99
 
80
100
  function normalizedValues(value) {
@@ -298,7 +318,29 @@ function retrieveRelevantLessons(toolName, actionContext, options = {}) {
298
318
  const deduped = applyGraphResolution(dedupeSupersededLessons(reranked), options, memories);
299
319
  const selected = filterTopP(deduped, resolveTopP(options), { minKeep: options.minKeep });
300
320
 
301
- const shaped = selected.slice(0, maxResults).map((x) => shapeLesson(x));
321
+ let finalPool = selected;
322
+ if (options.rankByVerifications === true || (options.rankByVerifications !== false && selected.some((item) => Number(item.verificationCount || 0) > 0))) {
323
+ finalPool = [...selected].sort((a, b) => {
324
+ const vcA = Number(a.verificationCount || 0);
325
+ const vcB = Number(b.verificationCount || 0);
326
+ if (vcB !== vcA) return vcB - vcA;
327
+ const tA = a.lastVerifiedAt ? new Date(a.lastVerifiedAt).getTime() : 0;
328
+ const tB = b.lastVerifiedAt ? new Date(b.lastVerifiedAt).getTime() : 0;
329
+ if (tB !== tA) return tB - tA;
330
+ return (b.relevanceScore || 0) - (a.relevanceScore || 0);
331
+ });
332
+ }
333
+ const shaped = finalPool.slice(0, maxResults).map((x) => {
334
+ const s = shapeLesson(x);
335
+ if (options.now) {
336
+ const t = s.lastVerifiedAt ? new Date(s.lastVerifiedAt).getTime() : null;
337
+ if (t && Number.isFinite(t)) {
338
+ const nowDate = (options.now instanceof Date ? options.now : new Date(options.now)).getTime();
339
+ s.stale = (nowDate - t) / (1000 * 60 * 60 * 24) > 30;
340
+ }
341
+ }
342
+ return s;
343
+ });
302
344
 
303
345
  // Attach retrieval quality tier once (non-enumerable-ish via property on array)
304
346
  try {
@@ -389,6 +431,24 @@ function shapeLesson(m, retrieval = null) {
389
431
  signal: m.signal === 'negative' || m.signal === 'positive' ? m.signal : (m.tags?.includes('negative') ? 'negative' : 'positive'),
390
432
  rule: m.structuredRule || null,
391
433
  relevanceScore: m.rerankedScore ?? m.relevanceScore,
434
+ verificationStatus: m.verificationStatus || (Number(m.verificationCount || 0) > 0 ? 'verified' : 'unverified'),
435
+ verificationCount: Number(m.verificationCount || 0),
436
+ verifications: Array.isArray(m.verifications) ? m.verifications : [],
437
+ lastVerifiedAt: m.lastVerifiedAt || null,
438
+ badge: (function() {
439
+ const count = Number(m.verificationCount || 0);
440
+ if (count <= 0 || !m.lastVerifiedAt) return 'unverified';
441
+ return `verified ${count}x, last ${String(m.lastVerifiedAt).split('T')[0]}`;
442
+ })(),
443
+ stale: (function() {
444
+ if (!m.lastVerifiedAt) return false;
445
+ const t = new Date(m.lastVerifiedAt).getTime();
446
+ if (!Number.isFinite(t)) return false;
447
+ return (Date.now() - t) / (1000 * 60 * 60 * 24) > 30;
448
+ })(),
449
+ upVotes: Number(m.upVotes || 0),
450
+ downVotes: Number(m.downVotes || 0),
451
+ netVotes: Number(m.upVotes || 0) - Number(m.downVotes || 0),
392
452
  timestamp: m.timestamp,
393
453
  };
394
454
  if (m.lessonGraph) shaped.graph = m.lessonGraph;
@@ -489,9 +549,10 @@ async function retrieveRelevantLessonsAsync(toolName, actionContext, options = {
489
549
  // Short-circuit: skip embedding/dense search completely
490
550
  const { rerankLessons } = require('./lesson-reranker');
491
551
  const reranked = rerankLessons(actionContext, dedupeCandidatePool(lexicalScored), { topK: Math.max(maxResults * 2, maxResults), toolName });
492
- return filterTopP(applyGraphResolution(dedupeSupersededLessons(reranked), options, memories), resolveTopP(options), { minKeep: options.minKeep })
552
+ const shaped = filterTopP(applyGraphResolution(dedupeSupersededLessons(reranked), options, memories), resolveTopP(options), { minKeep: options.minKeep })
493
553
  .slice(0, maxResults)
494
554
  .map((x) => shapeLesson(x));
555
+ return curateRetrievedLessonsWithSubqSnap(toolName, actionContext, shaped, options);
495
556
  }
496
557
 
497
558
  const queryPlan = lexicalScored[0]?.relevanceScore >= (options.rewriteBelowScore ?? 0.6)
@@ -601,7 +662,7 @@ async function retrieveRelevantLessonsAsync(toolName, actionContext, options = {
601
662
  queryTransformation: queryPlan,
602
663
  semanticProvider: options.embedderId || 'configured',
603
664
  } : null;
604
- return cut.map((lesson) => shapeLesson(lesson, retrieval));
665
+ return curateRetrievedLessonsWithSubqSnap(toolName, actionContext, cut.map((lesson) => shapeLesson(lesson, retrieval)), options);
605
666
  } catch {
606
667
  // Legacy fuse path below
607
668
  }
@@ -636,7 +697,8 @@ async function retrieveRelevantLessonsAsync(toolName, actionContext, options = {
636
697
  const rows = filterTopP(applyGraphResolution(dedupeSupersededLessons(reranked), options, memories), resolveTopP(options), { minKeep: options.minKeep })
637
698
  .slice(0, maxResults)
638
699
  .map((x) => shapeLesson(x));
639
- return attachArrayRetrievalMeta(rows, {
700
+ const curatedRows = await curateRetrievedLessonsWithSubqSnap(toolName, actionContext, rows, options);
701
+ return attachArrayRetrievalMeta(curatedRows, {
640
702
  strategy: 'hybrid-rrf+bm25',
641
703
  indexUpdatedAtMs: options.indexUpdatedAtMs ?? null,
642
704
  });
@@ -896,6 +958,29 @@ function calculateRetrievalEntropy(lessons) {
896
958
  return Number(entropy.toFixed(4));
897
959
  }
898
960
 
961
+ async function curateRetrievedLessonsWithSubqSnap(toolName, actionContext, lessons, options = {}) {
962
+ if (!Array.isArray(lessons) || lessons.length === 0) return [];
963
+ const enabled = options.subqCurate === true || process.env.THUMBGATE_SUBQ_CONTEXT_CURATION === '1';
964
+ if (!enabled) return lessons;
965
+ try {
966
+ const { curateContextWithSubqSnap } = require('../src/mcp-writeguard');
967
+ const res = await curateContextWithSubqSnap({
968
+ toolName,
969
+ actionContext,
970
+ candidates: lessons,
971
+ apiKey: options.subqApiKey,
972
+ threshold: options.subqThreshold ?? 0.5,
973
+ minKeep: options.minKeep ?? 0,
974
+ timeoutMs: options.subqTimeoutMs ?? 450,
975
+ fetchImpl: options.fetchImpl,
976
+ allowKeychain: Boolean(options.allowKeychain),
977
+ });
978
+ return res.curated;
979
+ } catch {
980
+ return lessons;
981
+ }
982
+ }
983
+
899
984
  module.exports = {
900
985
  applyGraphResolution,
901
986
  retrieveRelevantLessons,
@@ -917,6 +1002,7 @@ module.exports = {
917
1002
  buildQueryVariants,
918
1003
  buildQueryPlan,
919
1004
  attachArrayRetrievalMeta,
1005
+ curateRetrievedLessonsWithSubqSnap,
920
1006
  MAX_RETRIEVAL_MEMORY_CHARS,
921
1007
  MAX_RETRIEVAL_MEMORY_LINES,
922
1008
  };
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const { tenantDataScope, assertScopedDataPath } = require('./feedback-scope');
4
+
3
5
  const path = require('node:path');
4
6
  const { readJSONL, getFeedbackPaths } = require('./feedback-loop');
5
7
  const { buildMemoryLifecycleView, scoreHybridMemoryMatch } = require('./agent-memory-lifecycle');
@@ -148,22 +150,11 @@ function buildLessonQuery(memory, parsed, sourceFeedback) {
148
150
  }
149
151
 
150
152
  function resolveLessonPaths(options = {}) {
151
- if (options.feedbackDir) {
152
- const feedbackDir = path.resolve(String(options.feedbackDir));
153
- return {
154
- FEEDBACK_DIR: feedbackDir,
155
- FEEDBACK_LOG_PATH: path.join(feedbackDir, 'feedback-log.jsonl'),
156
- MEMORY_LOG_PATH: path.join(feedbackDir, 'memory-log.jsonl'),
157
- PREVENTION_RULES_PATH: path.join(feedbackDir, 'prevention-rules.md'),
158
- AUTO_GATES_PATH: path.join(feedbackDir, 'auto-promoted-gates.json'),
159
- };
160
- }
161
-
162
- const paths = getFeedbackPaths();
153
+ const paths = getFeedbackPaths(options.feedbackDir ? { feedbackDir: path.resolve(String(options.feedbackDir)) } : {});
163
154
  return {
164
155
  ...paths,
165
- PREVENTION_RULES_PATH: path.join(paths.FEEDBACK_DIR, 'prevention-rules.md'),
166
- AUTO_GATES_PATH: path.join(paths.FEEDBACK_DIR, 'auto-promoted-gates.json'),
156
+ PREVENTION_RULES_PATH: assertScopedDataPath(path.join(paths.FEEDBACK_DIR, 'prevention-rules.md')),
157
+ AUTO_GATES_PATH: assertScopedDataPath(path.join(paths.FEEDBACK_DIR, 'auto-promoted-gates.json')),
167
158
  };
168
159
  }
169
160
 
@@ -200,6 +191,7 @@ function readPreventionRuleMatches(queryText, limit = 3, options = {}) {
200
191
  }
201
192
 
202
193
  function readAutoGates(options = {}) {
194
+ if (options.projectKey != null) return { gates: require('./project-catalog').readProjectGates(resolveLessonPaths(options).FEEDBACK_DIR, options).filter(require('./project-identity').isGeneratedGate) };
203
195
  const { AUTO_GATES_PATH } = resolveLessonPaths(options);
204
196
  try {
205
197
  return JSON.parse(require('node:fs').readFileSync(AUTO_GATES_PATH, 'utf-8'));
@@ -241,6 +233,8 @@ function buildGateMatches(memory, parsed, limit = 3, options = {}) {
241
233
  .sort((a, b) => b.score - a.score)
242
234
  .slice(0, limit)
243
235
  .map(({ gate, score }) => ({
236
+ ...require('./project-identity').projectForRecord(gate),
237
+ scope: gate.scope || (gate.projectKey ? 'project' : 'global'),
244
238
  id: gate.id,
245
239
  action: gate.action,
246
240
  pattern: gate.pattern,
@@ -429,7 +423,7 @@ function scoreLesson(queryText, memory, parsed, sourceFeedback) {
429
423
  function buildLessonResult(memory, sourceFeedback, options = {}) {
430
424
  const parsed = parseLessonContent(memory.content);
431
425
  const lessonQuery = buildLessonQuery(memory, parsed, sourceFeedback);
432
- const ruleMatches = readPreventionRuleMatches(lessonQuery, Number(options.ruleLimit || 3), options);
426
+ const ruleMatches = options.projectKey != null ? [] : readPreventionRuleMatches(lessonQuery, Number(options.ruleLimit || 3), options);
433
427
  const gateMatches = buildGateMatches(memory, parsed, Number(options.gateLimit || 3), options);
434
428
  const { score, evidenceScore, priorScore, matchedTokens } = scoreLesson(options.query || '', memory, parsed, sourceFeedback);
435
429
  const harnessRecommendations = buildHarnessRecommendations(memory, parsed, sourceFeedback, ruleMatches, gateMatches);
@@ -437,8 +431,9 @@ function buildLessonResult(memory, sourceFeedback, options = {}) {
437
431
  const memoryLifecycle = buildMemoryLifecycleView(memory, { query: options.query || '' });
438
432
 
439
433
  return {
434
+ ...require('./project-identity').projectForRecord(memory),
440
435
  id: memory.id,
441
- title: memory.title,
436
+ title: (function() { const isStale = memory.lastVerifiedAt && ((new Date((options.now || Date.now())).getTime() - new Date(memory.lastVerifiedAt).getTime()) / 86400000 > 30); return (isStale ? "[STALE] " : "") + memory.title; })(),
442
437
  category: memory.category,
443
438
  importance: memory.importance,
444
439
  tags: Array.isArray(memory.tags) ? memory.tags : [],
@@ -448,6 +443,26 @@ function buildLessonResult(memory, sourceFeedback, options = {}) {
448
443
  evidenceScore: Number(evidenceScore.toFixed(4)),
449
444
  priorScore: Number(priorScore.toFixed(4)),
450
445
  matchedTokens,
446
+ verificationStatus: memory.verificationStatus || (Number(memory.verificationCount || 0) > 0 ? 'verified' : 'unverified'),
447
+ verificationCount: Number(memory.verificationCount || 0),
448
+ verifications: Array.isArray(memory.verifications) ? memory.verifications : [],
449
+ lastVerifiedAt: memory.lastVerifiedAt || null,
450
+ badge: (function() {
451
+ const count = Number(memory.verificationCount || 0);
452
+ if (count <= 0 || !memory.lastVerifiedAt) return 'unverified';
453
+ return `verified ${count}x, last ${String(memory.lastVerifiedAt).split('T')[0]}`;
454
+ })(),
455
+ stale: (function() {
456
+ if (!memory.lastVerifiedAt) return false;
457
+ const t = new Date(memory.lastVerifiedAt).getTime();
458
+ if (!Number.isFinite(t)) return false;
459
+ const nowDate = (options.now instanceof Date ? options.now : new Date(options.now || Date.now())).getTime();
460
+ return (nowDate - t) / (1000 * 60 * 60 * 24) > 30;
461
+ })(),
462
+ upVotes: Number(memory.upVotes || 0),
463
+ downVotes: Number(memory.downVotes || 0),
464
+ netVotes: Number(memory.upVotes || 0) - Number(memory.downVotes || 0),
465
+ demoted: (memory.demoted === true) || (Number(memory.downVotes || 0) > Number(memory.upVotes || 0)),
451
466
  lesson: {
452
467
  summary: parsed.summary,
453
468
  content: memory.content,
@@ -485,13 +500,18 @@ function searchLessons(query = '', options = {}) {
485
500
  const { MEMORY_LOG_PATH, FEEDBACK_DIR, FEEDBACK_LOG_PATH } = resolveLessonPaths(options);
486
501
 
487
502
  // Try SQLite FTS5 first — falls back to JSONL Jaccard if unavailable
488
- const sqliteResults = tryFts5Search(query, options);
503
+ const sqliteResults = options.projectKey != null ? null : tryFts5Search(query, options);
489
504
  if (sqliteResults) return sqliteResults;
490
505
 
491
- const allMemories = readJSONL(MEMORY_LOG_PATH);
506
+ // Exact error lookup (Search before solving)
507
+ const { lookupLessonByError } = require('./verified-lessons');
508
+ const exactErrorMatch = options.projectKey != null ? null : lookupLessonByError(query, { feedbackDir: FEEDBACK_DIR, now: options.now });
509
+
510
+ const allMemories = require('./project-catalog').readProjectRows(FEEDBACK_DIR, 'memory-log.jsonl', options);
492
511
  const memories = selectRetrievalMemories(allMemories, options);
493
- const feedbackEntries = readJSONL(FEEDBACK_LOG_PATH);
494
- const feedbackById = new Map(feedbackEntries.map((entry) => [entry.id, entry]));
512
+ const feedbackEntries = require('./project-catalog').readProjectRows(FEEDBACK_DIR, 'feedback-log.jsonl', options);
513
+ const feedbackKey = (projectKey, id) => `${projectKey}\0${id}`;
514
+ const feedbackById = new Map(feedbackEntries.map((entry) => [feedbackKey(entry.projectKey, entry.id), entry]));
495
515
  const parsedLimit = Number(options.limit || 10);
496
516
  const limit = Number.isFinite(parsedLimit) && parsedLimit > 0 ? parsedLimit : 10;
497
517
  const category = options.category ? String(options.category).trim() : '';
@@ -503,10 +523,13 @@ function searchLessons(query = '', options = {}) {
503
523
  .filter(Boolean);
504
524
 
505
525
  let results = memories
506
- .map((memory) => buildLessonResult(memory, feedbackById.get(memory.sourceFeedbackId), {
526
+ .map((memory) => buildLessonResult(memory, feedbackById.get(feedbackKey(memory.projectKey, memory.sourceFeedbackId)), {
507
527
  query,
528
+ projectKey: options.projectKey,
508
529
  ruleLimit: options.ruleLimit,
509
530
  gateLimit: options.gateLimit,
531
+ now: options.now,
532
+ feedbackDir: FEEDBACK_DIR,
510
533
  }));
511
534
 
512
535
  if (category) {
@@ -539,6 +562,47 @@ function searchLessons(query = '', options = {}) {
539
562
  results = [...reranked, ...tail];
540
563
  }
541
564
 
565
+ if (exactErrorMatch) {
566
+ const existingMatch = results.find((r) => r.id === exactErrorMatch.id);
567
+ if (existingMatch) {
568
+ results = [existingMatch, ...results.filter((r) => r.id !== exactErrorMatch.id)];
569
+ } else {
570
+ const formattedExact = {
571
+ id: exactErrorMatch.id,
572
+ title: (exactErrorMatch.stale ? '[STALE] ' : '') + exactErrorMatch.title,
573
+ category: exactErrorMatch.category || 'error',
574
+ importance: exactErrorMatch.importance || 'high',
575
+ tags: exactErrorMatch.tags || [],
576
+ timestamp: exactErrorMatch.timestamp || null,
577
+ score: 1.0,
578
+ evidenceScore: 1.0,
579
+ verificationStatus: exactErrorMatch.verificationStatus,
580
+ verificationCount: exactErrorMatch.verificationCount,
581
+ verifications: exactErrorMatch.verifications,
582
+ lastVerifiedAt: exactErrorMatch.lastVerifiedAt,
583
+ badge: exactErrorMatch.badge,
584
+ stale: exactErrorMatch.stale,
585
+ upVotes: exactErrorMatch.upVotes,
586
+ downVotes: exactErrorMatch.downVotes,
587
+ netVotes: exactErrorMatch.netVotes,
588
+ lesson: {
589
+ summary: exactErrorMatch.title,
590
+ content: exactErrorMatch.content,
591
+ whatWentWrong: exactErrorMatch.errorPattern,
592
+ howToAvoid: exactErrorMatch.fix,
593
+ },
594
+ systemResponse: {
595
+ promotedToMemory: true,
596
+ linkedPreventionRules: [],
597
+ linkedAutoGates: [],
598
+ harnessRecommendations: [],
599
+ correctiveActions: [{ type: 'verified_fix', source: 'verified_seed', text: exactErrorMatch.fix, fix: exactErrorMatch.fix }],
600
+ },
601
+ };
602
+ results = [formattedExact, ...results];
603
+ }
604
+ }
605
+
542
606
  return {
543
607
  query: String(query || ''),
544
608
  limit,
@@ -570,7 +634,7 @@ function tryFts5Search(query, options) {
570
634
  let db = null;
571
635
  try {
572
636
  const { initDB, searchLessons: fts5Search, getStats } = require('./lesson-db');
573
- db = initDB();
637
+ db = tenantDataScope() ? initDB(path.join(resolveLessonPaths(options).FEEDBACK_DIR, 'lessons.sqlite')) : initDB();
574
638
  const stats = getStats(db);
575
639
 
576
640
  // If DB is empty, skip (not yet backfilled)
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
+ const { projectForRecord, matchesProject } = require('./project-identity');
5
+ const { iterateRows, accountAttribution, attributionForFile } = require('./project-catalog');
4
6
  const { canonicalHash, findCanonicalDuplicate } = require('./lesson-canonical');
5
7
 
6
8
  const SIMILARITY_THRESHOLD = 0.6;
@@ -48,8 +50,19 @@ function appendJSONLLocal(filePath, record) {
48
50
  * The canonical pass runs first because it's O(N) with constant work per
49
51
  * entry and rejects trivial duplicates before we pay the Jaccard price.
50
52
  */
53
+ function readLessonsInFile(memoryLogPath, projectKey) {
54
+ if (!fs.existsSync(memoryLogPath) || fs.lstatSync(memoryLogPath).isSymbolicLink()) return [];
55
+ const attribution = accountAttribution(path.dirname(memoryLogPath));
56
+ const rows = [];
57
+ for (const record of iterateRows(memoryLogPath)) {
58
+ const row = { ...record, ...projectForRecord(record, attributionForFile(attribution, memoryLogPath)) };
59
+ if (row.projectKey === projectKey) rows.push(row);
60
+ }
61
+ return rows;
62
+ }
63
+
51
64
  function findSimilarLesson(memoryLogPath, newRecord) {
52
- const existing = readJSONLLocal(memoryLogPath, { maxLines: 200 });
65
+ const existing = readLessonsInFile(memoryLogPath, projectForRecord(newRecord).projectKey).slice(-200);
53
66
 
54
67
  // Layer 1: canonical-hash exact match (normalization-invariant).
55
68
  const canonicalMatch = findCanonicalDuplicate(existing, newRecord);
@@ -143,14 +156,16 @@ function synthesizePreventionRule(lesson) {
143
156
  /**
144
157
  * Update a single record in a JSONL file by ID.
145
158
  */
146
- function updateRecordInJsonl(filePath, recordId, updatedRecord) {
159
+ function updateRecordInJsonl(filePath, recordId, updatedRecord, options = {}) {
147
160
  if (!fs.existsSync(filePath)) return false;
148
161
  const lines = fs.readFileSync(filePath, 'utf-8').split('\n').filter(Boolean);
162
+ const projectKey = options.projectKey ?? updatedRecord.projectKey;
163
+ const attribution = attributionForFile(options.attribution || accountAttribution(path.dirname(filePath)), filePath);
149
164
  let found = false;
150
165
  const updated = lines.map(function(line) {
151
166
  try {
152
167
  const obj = JSON.parse(line);
153
- if (obj.id === recordId) {
168
+ if (obj.id === recordId && matchesProject(projectForRecord(obj, attribution), projectKey)) {
154
169
  found = true;
155
170
  return JSON.stringify(updatedRecord);
156
171
  }
@@ -166,13 +181,14 @@ function updateRecordInJsonl(filePath, recordId, updatedRecord) {
166
181
  /**
167
182
  * Delete a single record from a JSONL file by ID.
168
183
  */
169
- function deleteRecordFromJsonl(filePath, recordId) {
184
+ function deleteRecordFromJsonl(filePath, recordId, options = {}) {
170
185
  if (!fs.existsSync(filePath)) return false;
171
186
  const lines = fs.readFileSync(filePath, 'utf-8').split('\n').filter(Boolean);
187
+ const attribution = attributionForFile(options.attribution || accountAttribution(path.dirname(filePath)), filePath);
172
188
  const filtered = lines.filter(function(line) {
173
189
  try {
174
190
  const obj = JSON.parse(line);
175
- return obj.id !== recordId;
191
+ return obj.id !== recordId || !matchesProject(projectForRecord(obj, attribution), options.projectKey);
176
192
  } catch { return true; }
177
193
  });
178
194
  if (filtered.length === lines.length) return false;