@mmerterden/multi-agent-pipeline 20.40.0 → 20.42.0

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 (143) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/README.md +5 -2
  3. package/README.tr.md +5 -2
  4. package/docs/adr/0019-product-tree.md +143 -0
  5. package/docs/adr/README.md +1 -0
  6. package/docs/ecosystem.md +51 -14
  7. package/docs/facts.json +7 -7
  8. package/docs/features.md +15 -4
  9. package/install/claude.mjs +45 -3
  10. package/install/templates/claude-hooks.json +23 -1
  11. package/manifest.json +146 -107
  12. package/package.json +3 -2
  13. package/pipeline/commands/multi-agent/autopilot/SKILL.md +11 -0
  14. package/pipeline/commands/multi-agent/review-analysis/SKILL.md +1 -1
  15. package/pipeline/commands/multi-agent/setup/SKILL.md +1 -1
  16. package/pipeline/contract/types/index.d.ts +53 -49
  17. package/pipeline/lib/args.mjs +131 -4
  18. package/pipeline/lib/bg-launch.mjs +5 -2
  19. package/pipeline/lib/context-budget.mjs +5 -42
  20. package/pipeline/lib/credential-store.sh +11 -1
  21. package/pipeline/lib/hook-once.mjs +134 -0
  22. package/pipeline/lib/hook-registration.mjs +5 -0
  23. package/pipeline/lib/isotonic.mjs +73 -0
  24. package/pipeline/lib/low-disk.mjs +153 -0
  25. package/pipeline/lib/mcp-schema-load.mjs +90 -0
  26. package/pipeline/lib/md2confluence-v3.py +19 -10
  27. package/pipeline/lib/model-dispatch.sh +26 -2
  28. package/pipeline/lib/normalize-text.mjs +135 -0
  29. package/pipeline/lib/outbound-gate.mjs +21 -3
  30. package/pipeline/lib/plan-todos.sh +17 -4
  31. package/pipeline/lib/redact.mjs +12 -3
  32. package/pipeline/lib/risky-settings.mjs +198 -0
  33. package/pipeline/lib/route-state.sh +1 -0
  34. package/pipeline/lib/secret-patterns.generated.mjs +6 -2
  35. package/pipeline/lib/session-usage.mjs +232 -0
  36. package/pipeline/lib/source-digest.mjs +211 -0
  37. package/pipeline/lib/tdd-evidence.mjs +250 -17
  38. package/pipeline/lib/tiered-budget.mjs +87 -0
  39. package/pipeline/lib/untrusted-fence.mjs +132 -1
  40. package/pipeline/multi-agent-refs/analysis/locked.md +1 -1
  41. package/pipeline/multi-agent-refs/analysis/review.md +23 -1
  42. package/pipeline/multi-agent-refs/features/code-graph.md +11 -1
  43. package/pipeline/multi-agent-refs/features/cost-analysis.md +37 -2
  44. package/pipeline/multi-agent-refs/features/doctor.md +82 -4
  45. package/pipeline/multi-agent-refs/features/model-fallback.md +25 -0
  46. package/pipeline/multi-agent-refs/features/plan-todos.md +4 -0
  47. package/pipeline/multi-agent-refs/features/product-tree.md +68 -0
  48. package/pipeline/multi-agent-refs/features/unattended-gates.md +5 -3
  49. package/pipeline/multi-agent-refs/features/unattended-security.md +88 -1
  50. package/pipeline/multi-agent-refs/features/usage-reporting.md +33 -0
  51. package/pipeline/multi-agent-refs/help/en.md +2 -1
  52. package/pipeline/multi-agent-refs/help/tr.md +2 -1
  53. package/pipeline/multi-agent-refs/knowledge.md +58 -0
  54. package/pipeline/multi-agent-refs/outside-the-pipeline.md +6 -0
  55. package/pipeline/multi-agent-refs/phases/phase-0-init.md +4 -0
  56. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +5 -1
  57. package/pipeline/multi-agent-refs/phases/phase-2-dev.md +4 -4
  58. package/pipeline/multi-agent-refs/phases/phase-3-review.md +2 -2
  59. package/pipeline/multi-agent-refs/phases/phase-5-report.md +4 -0
  60. package/pipeline/multi-agent-refs/progress-contract.md +3 -1
  61. package/pipeline/office/index.html +13 -7
  62. package/pipeline/office/toolkit.json +1 -1
  63. package/pipeline/preferences-template.json +1 -0
  64. package/pipeline/rules/outside-the-pipeline.md +1 -1
  65. package/pipeline/schemas/doctor-report.schema.json +47 -0
  66. package/pipeline/schemas/learnings-ledger.schema.json +35 -2
  67. package/pipeline/schemas/office-archive.schema.json +225 -128
  68. package/pipeline/schemas/plan-todos.schema.json +29 -1
  69. package/pipeline/schemas/prefs.schema.json +146 -0
  70. package/pipeline/schemas/product-tree-overlay.schema.json +57 -0
  71. package/pipeline/schemas/product-tree.schema.json +136 -0
  72. package/pipeline/schemas/route-config.schema.json +51 -0
  73. package/pipeline/schemas/secret-patterns.json +17 -1
  74. package/pipeline/schemas/toolkit-path-params.json +15 -1
  75. package/pipeline/scripts/_cost-advise.mjs +357 -0
  76. package/pipeline/scripts/_cost-budget.mjs +78 -0
  77. package/pipeline/scripts/_cost.mjs +29 -0
  78. package/pipeline/scripts/_decode_text.py +107 -0
  79. package/pipeline/scripts/_eval-stats.mjs +182 -0
  80. package/pipeline/scripts/_guard-probe.mjs +406 -0
  81. package/pipeline/scripts/_guard_rules.py +336 -1
  82. package/pipeline/scripts/_learnings-promotion.mjs +229 -0
  83. package/pipeline/scripts/_locate.mjs +539 -0
  84. package/pipeline/scripts/_memory-policy.mjs +208 -33
  85. package/pipeline/scripts/_product-tree-extract.mjs +761 -0
  86. package/pipeline/scripts/_product-tree.mjs +923 -0
  87. package/pipeline/scripts/_retrieval.mjs +161 -4
  88. package/pipeline/scripts/_secret-scan.mjs +6 -1
  89. package/pipeline/scripts/_stack-routing.mjs +2 -0
  90. package/pipeline/scripts/_test-gaming.mjs +346 -0
  91. package/pipeline/scripts/_user_guard_rules.py +744 -0
  92. package/pipeline/scripts/agent-guard.py +69 -6
  93. package/pipeline/scripts/agent-guard.sh +8 -1
  94. package/pipeline/scripts/argv-secret-scan.mjs +2 -1
  95. package/pipeline/scripts/autopilot-loop.mjs +407 -0
  96. package/pipeline/scripts/autopilot-runner.mjs +38 -25
  97. package/pipeline/scripts/capture-resume.sh +9 -1
  98. package/pipeline/scripts/cost-analyze.mjs +66 -4
  99. package/pipeline/scripts/cost-budget-check.mjs +5 -13
  100. package/pipeline/scripts/disk-cleaner.mjs +1418 -0
  101. package/pipeline/scripts/doctor.mjs +324 -43
  102. package/pipeline/scripts/evidence-gate.mjs +90 -0
  103. package/pipeline/scripts/gate-ledger.mjs +76 -21
  104. package/pipeline/scripts/gc-tmp.sh +5 -0
  105. package/pipeline/scripts/graph-query.mjs +257 -17
  106. package/pipeline/scripts/guard-probe-known-holes.json +3 -0
  107. package/pipeline/scripts/learnings-ledger.mjs +680 -55
  108. package/pipeline/scripts/note-agent-event.mjs +2 -0
  109. package/pipeline/scripts/note-mcp-failure.mjs +363 -0
  110. package/pipeline/scripts/note-mcp-failure.sh +19 -0
  111. package/pipeline/scripts/note-skill-use.mjs +96 -23
  112. package/pipeline/scripts/office-archive.mjs +23 -10
  113. package/pipeline/scripts/office-memory.mjs +4 -1
  114. package/pipeline/scripts/persona-walk-anchors.mjs +443 -0
  115. package/pipeline/scripts/pre-commit-check.sh +2 -2
  116. package/pipeline/scripts/pre-push-check.sh +8 -1
  117. package/pipeline/scripts/product-tree-eval.mjs +685 -0
  118. package/pipeline/scripts/product-tree.mjs +544 -0
  119. package/pipeline/scripts/publish-staged.mjs +324 -0
  120. package/pipeline/scripts/route-learn.mjs +628 -0
  121. package/pipeline/scripts/run-scope-guard.mjs +55 -1
  122. package/pipeline/scripts/scan-agent-config.sh +1 -1
  123. package/pipeline/scripts/statusline.mjs +309 -0
  124. package/pipeline/scripts/test-integrity-gate.mjs +97 -2
  125. package/pipeline/scripts/triage-memory.mjs +12 -4
  126. package/pipeline/scripts/uninstall.mjs +1 -0
  127. package/pipeline/skills/.skill-manifest.json +15 -7
  128. package/pipeline/skills/.skills-index.json +25 -3
  129. package/pipeline/skills/shared/README.md +6 -4
  130. package/pipeline/skills/shared/core/google-play-compliance/references/examples.md +1 -1
  131. package/pipeline/skills/shared/core/multi-agent-review-analysis/SKILL.md +1 -1
  132. package/pipeline/skills/shared/external/backlog/SKILL.md +1 -1
  133. package/pipeline/skills/shared/external/disk-cleaner/SKILL.md +105 -0
  134. package/pipeline/skills/shared/external/disk-cleaner/evals/evals.json +62 -0
  135. package/pipeline/skills/shared/external/disk-cleaner/scripts/disk-cleaner.mjs +1418 -0
  136. package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +1 -1
  137. package/pipeline/skills/shared/external/spec-persona-walk/SKILL.md +118 -0
  138. package/pipeline/skills/shared/external/spec-persona-walk/evals/evals.json +50 -0
  139. package/pipeline/skills/shared/external/spec-persona-walk/scripts/persona-walk-anchors.mjs +443 -0
  140. package/pipeline/skills/shared/external/storekit/SKILL.md +1 -1
  141. package/pipeline/skills/shared/external/swiftdata/SKILL.md +1 -1
  142. package/pipeline/skills/skill-copies.json +9 -1
  143. package/pipeline/skills/skills-index.md +4 -2
@@ -23,20 +23,30 @@
23
23
  * nearDuplicate(a, b) two statements that say the same thing in other
24
24
  * words: TF-IDF cosine at or above the threshold, the
25
25
  * same numbers, the same negations and mostly the
26
- * same word order ("A over B" is not "B over A")
26
+ * same word order ("Keychain over UserDefaults" is
27
+ * not "UserDefaults over Keychain")
28
+ * shingleSimilarity(a, b) Jaccard overlap of adjacent word pairs, 0 unless
29
+ * both carry the same numbers and negations and
30
+ * three or more words; the cross-repository
31
+ * promotion measure (PROMOTION_SIMILARITY). Both
32
+ * read words of any script, fold every English "not"
33
+ * form and apostrophe, and treat a Turkish verb that
34
+ * differs only by its negative -me/-ma as a negation
35
+ * globalRowId(row) the `G:` id of a global ledger row
36
+ * GLOBAL_LEDGER_SLUG the folder under ~/.claude/memory/multi-agent/ that
37
+ * holds the global ledger; no repository writes it
27
38
  *
28
39
  * Zero dependencies.
29
40
  *
30
41
  * @module pipeline/scripts/_memory-policy
31
42
  */
32
43
 
33
- import { shortId, tokens } from "./_retrieval.mjs";
44
+ import { cosine, idfWeights as idf, shortId, tfidfVector as tfidf, tokens } from "./_retrieval.mjs";
34
45
  import { prefsPath, readPrefsFile } from "../lib/prefs-value.mjs";
35
46
 
36
47
  const CORROBORATION = 2;
37
48
  const NEAR_DUP = 0.9;
38
49
  const ORDER_OVERLAP = 0.5;
39
- const NEGATIONS = /\b(not|never|no|none|without|except|only|avoid|don't|do not)\b/gi;
40
50
 
41
51
  /** The preferences, `{}` when there are none, `null` when they exist but cannot be read. */
42
52
  function prefs(env) {
@@ -45,13 +55,23 @@ function prefs(env) {
45
55
  return r.status === "ok" ? r.prefs : null;
46
56
  }
47
57
 
48
- /** Stable id of a ledger row: its kind and its whitespace-folded statement. */
49
- export function ledgerRowId(row) {
50
- const statement = String(row?.statement || "")
58
+ export const GLOBAL_LEDGER_SLUG = "_global";
59
+ export const PROMOTION_SIMILARITY = 0.5;
60
+
61
+ const foldedStatement = (row) =>
62
+ String(row?.statement || "")
51
63
  .toLowerCase()
52
64
  .replace(/\s+/g, " ")
53
65
  .trim();
54
- return shortId("L", row?.kind, statement);
66
+
67
+ /** Stable id of a ledger row: its kind and its whitespace-folded statement. */
68
+ export function ledgerRowId(row) {
69
+ return shortId("L", row?.kind, foldedStatement(row));
70
+ }
71
+
72
+ /** Stable id of a global ledger row, from the same fields as `ledgerRowId`. */
73
+ export function globalRowId(row) {
74
+ return shortId("G", row?.kind, foldedStatement(row));
55
75
  }
56
76
 
57
77
  /** A ledger id in its stored form, or null when `raw` is not one. */
@@ -144,36 +164,149 @@ export function standing(feedback, now = Date.now()) {
144
164
  }
145
165
 
146
166
  const numbersIn = (s) => (String(s).match(/\d+(?:\.\d+)?/g) || []).sort().join(",");
167
+
168
+ // Words that negate on their own. Every English "not" form, contracted or
169
+ // not, folds to "not", so "Don't" and "Do not" read alike. Turkish verbal
170
+ // negation sits inside the verb and is compared word by word
171
+ // (turkishNegationPair); its free-standing words are listed here.
172
+ const NEGATORS = new Set([
173
+ "not",
174
+ "never",
175
+ "no",
176
+ "none",
177
+ "without",
178
+ "except",
179
+ "only",
180
+ "avoid",
181
+ "değil",
182
+ "asla",
183
+ "hiç",
184
+ "hiçbir",
185
+ "yok",
186
+ ]);
187
+ const NOT_FORMS = new Set([
188
+ "cannot",
189
+ "dont",
190
+ "doesnt",
191
+ "didnt",
192
+ "cant",
193
+ "wont",
194
+ "isnt",
195
+ "arent",
196
+ "wasnt",
197
+ "werent",
198
+ "shouldnt",
199
+ "wouldnt",
200
+ "couldnt",
201
+ "mustnt",
202
+ "neednt",
203
+ "hasnt",
204
+ "havent",
205
+ "hadnt",
206
+ "aint",
207
+ ]);
208
+
209
+ /** Lower-cased words of any script, apostrophes folded to one form and kept inside a word. */
210
+ const plainWords = (s) =>
211
+ String(s)
212
+ .normalize("NFC")
213
+ .toLowerCase()
214
+ .replace(/[\u2018\u2019\u02bc\u2032\u00b4`]/g, "'")
215
+ .match(/[\p{L}\p{N}]+(?:'[\p{L}]+)*/gu) || [];
216
+
147
217
  const negationsIn = (s) =>
148
- (String(s).toLowerCase().match(NEGATIONS) || [])
149
- .map((w) => w.replace(/\s+/g, " "))
218
+ plainWords(s)
219
+ .map((w) => (w.endsWith("n't") || NOT_FORMS.has(w) ? "not" : w))
220
+ .filter((w) => NEGATORS.has(w))
150
221
  .sort()
151
222
  .join(",");
152
223
 
153
- /** Inverse document frequencies over a corpus of token lists. */
154
- function idf(corpus) {
155
- const df = new Map();
156
- for (const doc of corpus) for (const t of new Set(doc)) df.set(t, (df.get(t) || 0) + 1);
157
- const n = corpus.length;
158
- return (t) => Math.log(1 + n / (df.get(t) || 1));
224
+ // What may follow the negative -me/-ma of a Turkish verb: the necessitative,
225
+ // past, reported past, future, infinitive, conditional and imperative suffixes.
226
+ const TR_AFTER_NEGATIVE = /^(?:meli|malı|d[ıiuü]|m[ıiuü]ş|y[ae]c[ae]k|m[ae]k|s[ae]|s[ıiuü]n)/;
227
+ const TR_VOWEL = "aeıioöuü";
228
+ const TR_HIGH = "ıiuü";
229
+
230
+ /**
231
+ * The positive forms a Turkish word would have if it carries the negative
232
+ * morpheme: "engellenmemeli" -> "engellenmeli", "kullanmıyor" -> "kullanıyor",
233
+ * "kullanılmayacak" -> "kullanılacak", "yazmaz" -> "yazar", "kullanmayın" ->
234
+ * "kullanın", "kullanmayan" -> "kullanan". The vowel of a past, reported
235
+ * past, imperative or second-person suffix follows the stem once the
236
+ * negative is gone ("kurmadı" -> "kurdu", "görmemiş" -> "görmüş", "olmasın"
237
+ * -> "olsun"), so all four high vowels are generated. A stem under two
238
+ * letters is not read, so a short word that merely contains "ma" is left alone.
239
+ */
240
+ function turkishPositives(word) {
241
+ const out = new Set();
242
+ for (let i = 2; i + 2 <= word.length; i++) {
243
+ if (word[i] !== "m") continue;
244
+ const stem = word.slice(0, i);
245
+ const v = word[i + 1];
246
+ const rest = word.slice(i + 2);
247
+ if (v === "e" || v === "a") {
248
+ if (TR_AFTER_NEGATIVE.test(rest)) out.add(stem + rest);
249
+ if (/^[dt][ıiuü]/.test(rest)) {
250
+ for (const c of "dt") for (const h of TR_HIGH) out.add(`${stem}${c}${h}${rest.slice(2)}`);
251
+ }
252
+ if (/^m[ıiuü]ş/.test(rest)) {
253
+ for (const h of TR_HIGH) out.add(`${stem}m${h}ş${rest.slice(3)}`);
254
+ }
255
+ if (/^s[ıiuü]n/.test(rest)) {
256
+ for (const h of TR_HIGH) out.add(`${stem}s${h}n${rest.slice(3)}`);
257
+ }
258
+ if (/^y[ıiuü]n/.test(rest)) {
259
+ for (const h of TR_HIGH) {
260
+ out.add(`${stem}${h}n${rest.slice(3)}`);
261
+ out.add(`${stem}y${h}n${rest.slice(3)}`);
262
+ }
263
+ }
264
+ if (/^y[ae]n/.test(rest)) {
265
+ out.add(stem + rest.slice(1));
266
+ out.add(stem + rest);
267
+ }
268
+ if (/^y[ae]c[ae]k/.test(rest)) out.add(stem + rest.slice(1));
269
+ if (rest.startsWith("z")) {
270
+ out.add(`${stem}r${rest.slice(1)}`);
271
+ for (const w of TR_VOWEL) out.add(`${stem}${w}r${rest.slice(1)}`);
272
+ }
273
+ }
274
+ if ("ıiuü".includes(v) && rest.startsWith("yor")) {
275
+ out.add(`${stem}${v}${rest}`);
276
+ out.add(stem + rest);
277
+ }
278
+ }
279
+ return out;
280
+ }
281
+
282
+ /** Two Turkish words that differ only by the verb's negative morpheme. */
283
+ function turkishNegationPair(a, b) {
284
+ return turkishPositives(a).has(b) || turkishPositives(b).has(a);
159
285
  }
160
286
 
161
- function tfidf(doc, weight) {
162
- const tf = new Map();
163
- for (const t of doc) tf.set(t, (tf.get(t) || 0) + 1);
164
- const v = new Map();
165
- for (const [t, c] of tf) v.set(t, c * weight(t));
166
- return v;
287
+ /** Does any word only one side holds negate a word only the other side holds? */
288
+ function oppositeWords(wordsA, wordsB) {
289
+ const inB = new Set(wordsB);
290
+ const inA = new Set(wordsA);
291
+ const onlyA = wordsA.filter((w) => !inB.has(w));
292
+ const onlyB = wordsB.filter((w) => !inA.has(w));
293
+ return onlyA.some((a) => onlyB.some((b) => turkishNegationPair(a, b)));
167
294
  }
168
295
 
169
- function cosine(va, vb) {
170
- let dot = 0;
171
- for (const [t, w] of va) dot += w * (vb.get(t) || 0);
172
- const norm = (v) => Math.sqrt([...v.values()].reduce((s, w) => s + w * w, 0));
173
- const d = norm(va) * norm(vb);
174
- return d ? dot / d : 0;
296
+ /**
297
+ * Whether two statements can say the same thing at all: the same numbers,
298
+ * the same negating words, and no Turkish verb that one side negates.
299
+ */
300
+ function sameClaimShape(a, b) {
301
+ return a.numbers === b.numbers && a.negations === b.negations && !oppositeWords(a.plain, b.plain);
175
302
  }
176
303
 
304
+ const claimShape = (text) => ({
305
+ numbers: numbersIn(text),
306
+ negations: negationsIn(text),
307
+ plain: plainWords(text),
308
+ });
309
+
177
310
  /** Jaccard overlap of adjacent token pairs: low when the same words come in another order. */
178
311
  function orderOverlap(a, b) {
179
312
  const pairs = (doc) => new Set(doc.slice(1).map((t, i) => `${doc[i]} ${t}`));
@@ -185,6 +318,50 @@ function orderOverlap(a, b) {
185
318
  return shared / (pa.size + pb.size - shared);
186
319
  }
187
320
 
321
+ /**
322
+ * What `shingleSimilarity` compares, computed once per statement so a
323
+ * pairwise pass over many repositories does not re-tokenize.
324
+ *
325
+ * @param {string} text
326
+ * @returns {{shingles: Set<string>, numbers: string, negations: string, plain: string[], words: number}}
327
+ */
328
+ export function shingleProfile(text) {
329
+ const words = tokens(text, { unicode: true });
330
+ return {
331
+ shingles: new Set(words.slice(1).map((t, i) => `${words[i]} ${t}`)),
332
+ ...claimShape(text),
333
+ words: words.length,
334
+ };
335
+ }
336
+
337
+ /**
338
+ * Similarity of two statements as the Jaccard overlap of their adjacent word
339
+ * pairs (2-shingles over the stemmed, stop-word-free tokens of any script).
340
+ *
341
+ * Pairs rather than single words because word order carries the claim:
342
+ * "prefer KeychainStore over UserDefaults" and "prefer UserDefaults over
343
+ * KeychainStore" share every word and few pairs. Words under three letters
344
+ * are not tokens, so they carry no order. A statement under three words is
345
+ * too generic to stand as evidence, and two statements whose numbers or
346
+ * negations differ say different things however many words they share, so
347
+ * each of those scores 0. A negation is a negating word in any contraction or
348
+ * apostrophe, or a Turkish verb that differs only by its negative -me/-ma.
349
+ *
350
+ * @param {string|ReturnType<typeof shingleProfile>} a
351
+ * @param {string|ReturnType<typeof shingleProfile>} b
352
+ * @returns {number} 0..1
353
+ */
354
+ export function shingleSimilarity(a, b) {
355
+ const pa = typeof a === "string" ? shingleProfile(a) : a;
356
+ const pb = typeof b === "string" ? shingleProfile(b) : b;
357
+ if (pa.words < 3 || pb.words < 3) return 0;
358
+ if (!sameClaimShape(pa, pb)) return 0;
359
+ let shared = 0;
360
+ for (const s of pa.shingles) if (pb.shingles.has(s)) shared++;
361
+ const union = pa.shingles.size + pb.shingles.size - shared;
362
+ return union ? shared / union : 0;
363
+ }
364
+
188
365
  /**
189
366
  * The existing statement `candidate` repeats in other words, or null.
190
367
  *
@@ -192,16 +369,14 @@ function orderOverlap(a, b) {
192
369
  * @param {string[]} existing statements of the same kind
193
370
  */
194
371
  export function nearDuplicate(candidate, existing) {
195
- const c = tokens(candidate);
372
+ const c = tokens(candidate, { unicode: true });
196
373
  if (c.length < 3) return null;
197
- const docs = existing.map((s) => tokens(s));
374
+ const docs = existing.map((s) => tokens(s, { unicode: true }));
198
375
  const weight = idf([...docs, c]);
199
376
  const vc = tfidf(c, weight);
200
- const nums = numbersIn(candidate);
201
- const negs = negationsIn(candidate);
377
+ const shape = claimShape(candidate);
202
378
  for (let i = 0; i < existing.length; i++) {
203
- if (numbersIn(existing[i]) !== nums) continue;
204
- if (negationsIn(existing[i]) !== negs) continue;
379
+ if (!sameClaimShape(shape, claimShape(existing[i]))) continue;
205
380
  if (orderOverlap(c, docs[i]) < ORDER_OVERLAP) continue;
206
381
  if (cosine(vc, tfidf(docs[i], weight)) >= NEAR_DUP) return existing[i];
207
382
  }