@afaik-lab/weigh 0.0.0 → 0.6.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 (349) hide show
  1. package/.env.example +49 -0
  2. package/LICENSE +373 -0
  3. package/README.md +103 -1
  4. package/dist/agent.d.ts +83 -0
  5. package/dist/agent.d.ts.map +1 -0
  6. package/dist/agent.js +204 -0
  7. package/dist/agent.js.map +1 -0
  8. package/dist/ceilings.d.ts +32 -0
  9. package/dist/ceilings.d.ts.map +1 -0
  10. package/dist/ceilings.js +61 -0
  11. package/dist/ceilings.js.map +1 -0
  12. package/dist/cli.d.ts +3 -0
  13. package/dist/cli.d.ts.map +1 -0
  14. package/dist/cli.js +530 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/config-cli.d.ts +15 -0
  17. package/dist/config-cli.d.ts.map +1 -0
  18. package/dist/config-cli.js +141 -0
  19. package/dist/config-cli.js.map +1 -0
  20. package/dist/config.d.ts +198 -0
  21. package/dist/config.d.ts.map +1 -0
  22. package/dist/config.js +373 -0
  23. package/dist/config.js.map +1 -0
  24. package/dist/context-cli.d.ts +35 -0
  25. package/dist/context-cli.d.ts.map +1 -0
  26. package/dist/context-cli.js +251 -0
  27. package/dist/context-cli.js.map +1 -0
  28. package/dist/context.d.ts +118 -0
  29. package/dist/context.d.ts.map +1 -0
  30. package/dist/context.js +159 -0
  31. package/dist/context.js.map +1 -0
  32. package/dist/corrections/correction-set.d.ts +67 -0
  33. package/dist/corrections/correction-set.d.ts.map +1 -0
  34. package/dist/corrections/correction-set.js +104 -0
  35. package/dist/corrections/correction-set.js.map +1 -0
  36. package/dist/corrections/correction.d.ts +74 -0
  37. package/dist/corrections/correction.d.ts.map +1 -0
  38. package/dist/corrections/correction.js +154 -0
  39. package/dist/corrections/correction.js.map +1 -0
  40. package/dist/corrections/follow-up.d.ts +69 -0
  41. package/dist/corrections/follow-up.d.ts.map +1 -0
  42. package/dist/corrections/follow-up.js +217 -0
  43. package/dist/corrections/follow-up.js.map +1 -0
  44. package/dist/corrections/index.d.ts +31 -0
  45. package/dist/corrections/index.d.ts.map +1 -0
  46. package/dist/corrections/index.js +31 -0
  47. package/dist/corrections/index.js.map +1 -0
  48. package/dist/corrections/ledger.d.ts +78 -0
  49. package/dist/corrections/ledger.d.ts.map +1 -0
  50. package/dist/corrections/ledger.js +117 -0
  51. package/dist/corrections/ledger.js.map +1 -0
  52. package/dist/corrections/promotion.d.ts +119 -0
  53. package/dist/corrections/promotion.d.ts.map +1 -0
  54. package/dist/corrections/promotion.js +221 -0
  55. package/dist/corrections/promotion.js.map +1 -0
  56. package/dist/corrections/schema.d.ts +125 -0
  57. package/dist/corrections/schema.d.ts.map +1 -0
  58. package/dist/corrections/schema.js +100 -0
  59. package/dist/corrections/schema.js.map +1 -0
  60. package/dist/corrections-cli.d.ts +28 -0
  61. package/dist/corrections-cli.d.ts.map +1 -0
  62. package/dist/corrections-cli.js +157 -0
  63. package/dist/corrections-cli.js.map +1 -0
  64. package/dist/diff.d.ts +105 -0
  65. package/dist/diff.d.ts.map +1 -0
  66. package/dist/diff.js +202 -0
  67. package/dist/diff.js.map +1 -0
  68. package/dist/doctor.d.ts +38 -0
  69. package/dist/doctor.d.ts.map +1 -0
  70. package/dist/doctor.js +197 -0
  71. package/dist/doctor.js.map +1 -0
  72. package/dist/events.d.ts +21 -0
  73. package/dist/events.d.ts.map +1 -0
  74. package/dist/events.js +5 -0
  75. package/dist/events.js.map +1 -0
  76. package/dist/findings.d.ts +510 -0
  77. package/dist/findings.d.ts.map +1 -0
  78. package/dist/findings.js +645 -0
  79. package/dist/findings.js.map +1 -0
  80. package/dist/follow-up-cli.d.ts +88 -0
  81. package/dist/follow-up-cli.d.ts.map +1 -0
  82. package/dist/follow-up-cli.js +208 -0
  83. package/dist/follow-up-cli.js.map +1 -0
  84. package/dist/harness.d.ts +64 -0
  85. package/dist/harness.d.ts.map +1 -0
  86. package/dist/harness.js +71 -0
  87. package/dist/harness.js.map +1 -0
  88. package/dist/help/command-help.d.ts +9 -0
  89. package/dist/help/command-help.d.ts.map +1 -0
  90. package/dist/help/command-help.js +21 -0
  91. package/dist/help/command-help.js.map +1 -0
  92. package/dist/help/commands/answer.d.ts +3 -0
  93. package/dist/help/commands/answer.d.ts.map +1 -0
  94. package/dist/help/commands/answer.js +39 -0
  95. package/dist/help/commands/answer.js.map +1 -0
  96. package/dist/help/commands/config.d.ts +3 -0
  97. package/dist/help/commands/config.d.ts.map +1 -0
  98. package/dist/help/commands/config.js +25 -0
  99. package/dist/help/commands/config.js.map +1 -0
  100. package/dist/help/commands/context.d.ts +3 -0
  101. package/dist/help/commands/context.d.ts.map +1 -0
  102. package/dist/help/commands/context.js +44 -0
  103. package/dist/help/commands/context.js.map +1 -0
  104. package/dist/help/commands/corrections.d.ts +3 -0
  105. package/dist/help/commands/corrections.d.ts.map +1 -0
  106. package/dist/help/commands/corrections.js +30 -0
  107. package/dist/help/commands/corrections.js.map +1 -0
  108. package/dist/help/commands/doctor.d.ts +3 -0
  109. package/dist/help/commands/doctor.d.ts.map +1 -0
  110. package/dist/help/commands/doctor.js +12 -0
  111. package/dist/help/commands/doctor.js.map +1 -0
  112. package/dist/help/commands/index.d.ts +4 -0
  113. package/dist/help/commands/index.d.ts.map +1 -0
  114. package/dist/help/commands/index.js +27 -0
  115. package/dist/help/commands/index.js.map +1 -0
  116. package/dist/help/commands/memory.d.ts +3 -0
  117. package/dist/help/commands/memory.d.ts.map +1 -0
  118. package/dist/help/commands/memory.js +33 -0
  119. package/dist/help/commands/memory.js.map +1 -0
  120. package/dist/help/commands/models.d.ts +3 -0
  121. package/dist/help/commands/models.d.ts.map +1 -0
  122. package/dist/help/commands/models.js +17 -0
  123. package/dist/help/commands/models.js.map +1 -0
  124. package/dist/help/commands/options.d.ts +4 -0
  125. package/dist/help/commands/options.d.ts.map +1 -0
  126. package/dist/help/commands/options.js +13 -0
  127. package/dist/help/commands/options.js.map +1 -0
  128. package/dist/help/commands/review.d.ts +3 -0
  129. package/dist/help/commands/review.d.ts.map +1 -0
  130. package/dist/help/commands/review.js +50 -0
  131. package/dist/help/commands/review.js.map +1 -0
  132. package/dist/help/commands/sessions.d.ts +3 -0
  133. package/dist/help/commands/sessions.d.ts.map +1 -0
  134. package/dist/help/commands/sessions.js +23 -0
  135. package/dist/help/commands/sessions.js.map +1 -0
  136. package/dist/help/commands/show.d.ts +3 -0
  137. package/dist/help/commands/show.d.ts.map +1 -0
  138. package/dist/help/commands/show.js +18 -0
  139. package/dist/help/commands/show.js.map +1 -0
  140. package/dist/help/help.d.ts +16 -0
  141. package/dist/help/help.d.ts.map +1 -0
  142. package/dist/help/help.js +68 -0
  143. package/dist/help/help.js.map +1 -0
  144. package/dist/help/index.d.ts +4 -0
  145. package/dist/help/index.d.ts.map +1 -0
  146. package/dist/help/index.js +7 -0
  147. package/dist/help/index.js.map +1 -0
  148. package/dist/index.d.ts +80 -0
  149. package/dist/index.d.ts.map +1 -0
  150. package/dist/index.js +51 -0
  151. package/dist/index.js.map +1 -0
  152. package/dist/knowledge/block.d.ts +65 -0
  153. package/dist/knowledge/block.d.ts.map +1 -0
  154. package/dist/knowledge/block.js +89 -0
  155. package/dist/knowledge/block.js.map +1 -0
  156. package/dist/knowledge/claim.d.ts +143 -0
  157. package/dist/knowledge/claim.d.ts.map +1 -0
  158. package/dist/knowledge/claim.js +303 -0
  159. package/dist/knowledge/claim.js.map +1 -0
  160. package/dist/knowledge/index.d.ts +32 -0
  161. package/dist/knowledge/index.d.ts.map +1 -0
  162. package/dist/knowledge/index.js +29 -0
  163. package/dist/knowledge/index.js.map +1 -0
  164. package/dist/knowledge/novelty.d.ts +65 -0
  165. package/dist/knowledge/novelty.d.ts.map +1 -0
  166. package/dist/knowledge/novelty.js +100 -0
  167. package/dist/knowledge/novelty.js.map +1 -0
  168. package/dist/knowledge/recall.d.ts +134 -0
  169. package/dist/knowledge/recall.d.ts.map +1 -0
  170. package/dist/knowledge/recall.js +229 -0
  171. package/dist/knowledge/recall.js.map +1 -0
  172. package/dist/knowledge/recalled-claim.d.ts +35 -0
  173. package/dist/knowledge/recalled-claim.d.ts.map +1 -0
  174. package/dist/knowledge/recalled-claim.js +67 -0
  175. package/dist/knowledge/recalled-claim.js.map +1 -0
  176. package/dist/knowledge/recalled.d.ts +70 -0
  177. package/dist/knowledge/recalled.d.ts.map +1 -0
  178. package/dist/knowledge/recalled.js +149 -0
  179. package/dist/knowledge/recalled.js.map +1 -0
  180. package/dist/knowledge/schema.d.ts +83 -0
  181. package/dist/knowledge/schema.d.ts.map +1 -0
  182. package/dist/knowledge/schema.js +96 -0
  183. package/dist/knowledge/schema.js.map +1 -0
  184. package/dist/knowledge/staleness.d.ts +48 -0
  185. package/dist/knowledge/staleness.d.ts.map +1 -0
  186. package/dist/knowledge/staleness.js +85 -0
  187. package/dist/knowledge/staleness.js.map +1 -0
  188. package/dist/knowledge/store.d.ts +100 -0
  189. package/dist/knowledge/store.d.ts.map +1 -0
  190. package/dist/knowledge/store.js +184 -0
  191. package/dist/knowledge/store.js.map +1 -0
  192. package/dist/memory/compose-file.d.ts +14 -0
  193. package/dist/memory/compose-file.d.ts.map +1 -0
  194. package/dist/memory/compose-file.js +25 -0
  195. package/dist/memory/compose-file.js.map +1 -0
  196. package/dist/memory/index.d.ts +43 -0
  197. package/dist/memory/index.d.ts.map +1 -0
  198. package/dist/memory/index.js +119 -0
  199. package/dist/memory/index.js.map +1 -0
  200. package/dist/memory/oss.d.ts +62 -0
  201. package/dist/memory/oss.d.ts.map +1 -0
  202. package/dist/memory/oss.js +230 -0
  203. package/dist/memory/oss.js.map +1 -0
  204. package/dist/memory/platform.d.ts +37 -0
  205. package/dist/memory/platform.d.ts.map +1 -0
  206. package/dist/memory/platform.js +131 -0
  207. package/dist/memory/platform.js.map +1 -0
  208. package/dist/memory/scope.d.ts +49 -0
  209. package/dist/memory/scope.d.ts.map +1 -0
  210. package/dist/memory/scope.js +70 -0
  211. package/dist/memory/scope.js.map +1 -0
  212. package/dist/memory/types.d.ts +113 -0
  213. package/dist/memory/types.d.ts.map +1 -0
  214. package/dist/memory/types.js +18 -0
  215. package/dist/memory/types.js.map +1 -0
  216. package/dist/memory-cli.d.ts +17 -0
  217. package/dist/memory-cli.d.ts.map +1 -0
  218. package/dist/memory-cli.js +107 -0
  219. package/dist/memory-cli.js.map +1 -0
  220. package/dist/models-cli.d.ts +12 -0
  221. package/dist/models-cli.d.ts.map +1 -0
  222. package/dist/models-cli.js +54 -0
  223. package/dist/models-cli.js.map +1 -0
  224. package/dist/models.d.ts +111 -0
  225. package/dist/models.d.ts.map +1 -0
  226. package/dist/models.js +228 -0
  227. package/dist/models.js.map +1 -0
  228. package/dist/paths.d.ts +35 -0
  229. package/dist/paths.d.ts.map +1 -0
  230. package/dist/paths.js +65 -0
  231. package/dist/paths.js.map +1 -0
  232. package/dist/profile.d.ts +28 -0
  233. package/dist/profile.d.ts.map +1 -0
  234. package/dist/profile.js +154 -0
  235. package/dist/profile.js.map +1 -0
  236. package/dist/progress.d.ts +70 -0
  237. package/dist/progress.d.ts.map +1 -0
  238. package/dist/progress.js +132 -0
  239. package/dist/progress.js.map +1 -0
  240. package/dist/quiet.d.ts +2 -0
  241. package/dist/quiet.d.ts.map +1 -0
  242. package/dist/quiet.js +21 -0
  243. package/dist/quiet.js.map +1 -0
  244. package/dist/reconcile/continuation.d.ts +132 -0
  245. package/dist/reconcile/continuation.d.ts.map +1 -0
  246. package/dist/reconcile/continuation.js +306 -0
  247. package/dist/reconcile/continuation.js.map +1 -0
  248. package/dist/reconcile/index.d.ts +26 -0
  249. package/dist/reconcile/index.d.ts.map +1 -0
  250. package/dist/reconcile/index.js +28 -0
  251. package/dist/reconcile/index.js.map +1 -0
  252. package/dist/reconcile/outcome-set.d.ts +53 -0
  253. package/dist/reconcile/outcome-set.d.ts.map +1 -0
  254. package/dist/reconcile/outcome-set.js +124 -0
  255. package/dist/reconcile/outcome-set.js.map +1 -0
  256. package/dist/reconcile/outcome.d.ts +56 -0
  257. package/dist/reconcile/outcome.d.ts.map +1 -0
  258. package/dist/reconcile/outcome.js +60 -0
  259. package/dist/reconcile/outcome.js.map +1 -0
  260. package/dist/reconcile/reconciliation.d.ts +49 -0
  261. package/dist/reconcile/reconciliation.d.ts.map +1 -0
  262. package/dist/reconcile/reconciliation.js +88 -0
  263. package/dist/reconcile/reconciliation.js.map +1 -0
  264. package/dist/reconcile/schema.d.ts +157 -0
  265. package/dist/reconcile/schema.d.ts.map +1 -0
  266. package/dist/reconcile/schema.js +97 -0
  267. package/dist/reconcile/schema.js.map +1 -0
  268. package/dist/record/index.d.ts +23 -0
  269. package/dist/record/index.d.ts.map +1 -0
  270. package/dist/record/index.js +25 -0
  271. package/dist/record/index.js.map +1 -0
  272. package/dist/record/review-record.d.ts +28 -0
  273. package/dist/record/review-record.d.ts.map +1 -0
  274. package/dist/record/review-record.js +78 -0
  275. package/dist/record/review-record.js.map +1 -0
  276. package/dist/record/schema.d.ts +153 -0
  277. package/dist/record/schema.d.ts.map +1 -0
  278. package/dist/record/schema.js +87 -0
  279. package/dist/record/schema.js.map +1 -0
  280. package/dist/record/store.d.ts +83 -0
  281. package/dist/record/store.d.ts.map +1 -0
  282. package/dist/record/store.js +162 -0
  283. package/dist/record/store.js.map +1 -0
  284. package/dist/record/stored-review.d.ts +36 -0
  285. package/dist/record/stored-review.d.ts.map +1 -0
  286. package/dist/record/stored-review.js +90 -0
  287. package/dist/record/stored-review.js.map +1 -0
  288. package/dist/refute.d.ts +318 -0
  289. package/dist/refute.d.ts.map +1 -0
  290. package/dist/refute.js +513 -0
  291. package/dist/refute.js.map +1 -0
  292. package/dist/render.d.ts +212 -0
  293. package/dist/render.d.ts.map +1 -0
  294. package/dist/render.js +544 -0
  295. package/dist/render.js.map +1 -0
  296. package/dist/review-cli.d.ts +181 -0
  297. package/dist/review-cli.d.ts.map +1 -0
  298. package/dist/review-cli.js +598 -0
  299. package/dist/review-cli.js.map +1 -0
  300. package/dist/reviewer.d.ts +297 -0
  301. package/dist/reviewer.d.ts.map +1 -0
  302. package/dist/reviewer.js +584 -0
  303. package/dist/reviewer.js.map +1 -0
  304. package/dist/session-cli.d.ts +17 -0
  305. package/dist/session-cli.d.ts.map +1 -0
  306. package/dist/session-cli.js +62 -0
  307. package/dist/session-cli.js.map +1 -0
  308. package/dist/session.d.ts +36 -0
  309. package/dist/session.d.ts.map +1 -0
  310. package/dist/session.js +105 -0
  311. package/dist/session.js.map +1 -0
  312. package/dist/settings.d.ts +68 -0
  313. package/dist/settings.d.ts.map +1 -0
  314. package/dist/settings.js +175 -0
  315. package/dist/settings.js.map +1 -0
  316. package/dist/show-cli.d.ts +39 -0
  317. package/dist/show-cli.d.ts.map +1 -0
  318. package/dist/show-cli.js +56 -0
  319. package/dist/show-cli.js.map +1 -0
  320. package/dist/stdout.d.ts +28 -0
  321. package/dist/stdout.d.ts.map +1 -0
  322. package/dist/stdout.js +44 -0
  323. package/dist/stdout.js.map +1 -0
  324. package/dist/target.d.ts +58 -0
  325. package/dist/target.d.ts.map +1 -0
  326. package/dist/target.js +96 -0
  327. package/dist/target.js.map +1 -0
  328. package/dist/tools/index.d.ts +93 -0
  329. package/dist/tools/index.d.ts.map +1 -0
  330. package/dist/tools/index.js +146 -0
  331. package/dist/tools/index.js.map +1 -0
  332. package/dist/tools/root.d.ts +62 -0
  333. package/dist/tools/root.d.ts.map +1 -0
  334. package/dist/tools/root.js +51 -0
  335. package/dist/tools/root.js.map +1 -0
  336. package/dist/usage.d.ts +75 -0
  337. package/dist/usage.d.ts.map +1 -0
  338. package/dist/usage.js +100 -0
  339. package/dist/usage.js.map +1 -0
  340. package/dist/version.d.ts +14 -0
  341. package/dist/version.d.ts.map +1 -0
  342. package/dist/version.js +26 -0
  343. package/dist/version.js.map +1 -0
  344. package/dist/workspace.d.ts +48 -0
  345. package/dist/workspace.d.ts.map +1 -0
  346. package/dist/workspace.js +126 -0
  347. package/dist/workspace.js.map +1 -0
  348. package/docker-compose.yml +61 -0
  349. package/package.json +72 -1
@@ -0,0 +1,303 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ import { claimInputSchema, claimMetadataSchema } from './schema.js';
5
+ /** The confidence a claim gets when its writer offers none. */
6
+ const ASSUMED = 0.7;
7
+ /** `applies` marker for a claim that holds everywhere in the repository. */
8
+ const EVERYWHERE = '*';
9
+ /**
10
+ * One thing that is true of a repository.
11
+ *
12
+ * Stored as a memory whose text is what a search has to match against, with
13
+ * everything that makes it checkable in the metadata beside it. The text is
14
+ * therefore built for retrieval rather than for reading: the statement, the
15
+ * kind, and the paths the claim cites, because a change's meaning lives in its
16
+ * code and its files rather than in prose about them. The statement is read
17
+ * back out of the metadata, which leaves the text free to be tuned.
18
+ */
19
+ export class Claim {
20
+ kind;
21
+ statement;
22
+ evidence;
23
+ applies;
24
+ confidence;
25
+ source;
26
+ at;
27
+ commit;
28
+ id;
29
+ score;
30
+ scope;
31
+ verified;
32
+ similarity;
33
+ /** Compiled `applies` globs, built once per claim and only if asked for. */
34
+ _globs;
35
+ constructor(kind, statement, evidence,
36
+ /**
37
+ * Globs this claim governs, or `['*']` for a rule of the house.
38
+ *
39
+ * Empty is the common case and means "found by similarity alone". The
40
+ * marker is deliberate rather than a default because unglobbed-means-always
41
+ * does not survive a store with a few hundred claims in it — while a writer
42
+ * who forgets the marker still gets found by proximity, which is a claim
43
+ * arriving late rather than a claim going missing.
44
+ */
45
+ applies, confidence, source, at, commit,
46
+ /** The store's own id, on a claim that was read back. */
47
+ id = undefined,
48
+ /** Relevance, on a claim that came back from a search. */
49
+ score = undefined,
50
+ /**
51
+ * The scope it was stored under, on a claim that was read back.
52
+ *
53
+ * Absent means it was written with no scope at all — what holds wherever
54
+ * this reviewer is working. Kept because a read at user scope filters on
55
+ * the user and nothing narrower, so it answers with every repository's
56
+ * claims too, and only the record itself says which it is.
57
+ */
58
+ scope = undefined,
59
+ /** When the claim was last found to still hold, and at which commit. */
60
+ verified = undefined,
61
+ /**
62
+ * How close it is in meaning alone, on a claim that came back from a
63
+ * search, when the backend says. `score` may blend in keyword matches and
64
+ * is scaled by what else the search found, so it cannot be held to a fixed
65
+ * floor; this can.
66
+ */
67
+ similarity = undefined) {
68
+ this.kind = kind;
69
+ this.statement = statement;
70
+ this.evidence = evidence;
71
+ this.applies = applies;
72
+ this.confidence = confidence;
73
+ this.source = source;
74
+ this.at = at;
75
+ this.commit = commit;
76
+ this.id = id;
77
+ this.score = score;
78
+ this.scope = scope;
79
+ this.verified = verified;
80
+ this.similarity = similarity;
81
+ }
82
+ /**
83
+ * Validates what a writer supplied and fills in what it left out.
84
+ *
85
+ * Throws rather than coercing: this is the one gate between a priming agent
86
+ * and the store, and a claim that is wrong about its own shape is the kind of
87
+ * thing that is only noticed months later, in a review that reads strangely.
88
+ *
89
+ * `head` is the commit the repository was at when the claim was written,
90
+ * used when the writer names none. It is what tells a claim that went stale
91
+ * from one that never held: the code it cites can be read at that commit.
92
+ */
93
+ static parse(data, now = new Date(), head) {
94
+ const parsed = claimInputSchema.safeParse(data);
95
+ if (!parsed.success) {
96
+ const issue = parsed.error.issues[0];
97
+ const where = issue?.path.length ? ` at ${issue.path.join('.')}` : '';
98
+ throw new Error(`not a context claim — ${issue?.message ?? 'unrecognised shape'}${where}`);
99
+ }
100
+ const { kind, statement, evidence, applies, confidence, provenance } = parsed.data;
101
+ return new Claim(kind, statement.trim(), evidence, applies ?? [], confidence ?? ASSUMED, provenance?.source ?? 'priming', provenance?.at ?? now.toISOString(), provenance?.commit ?? head);
102
+ }
103
+ /**
104
+ * A stored memory read back as a claim, or nothing when it is not one.
105
+ *
106
+ * The store holds more than claims — the prompt path has been writing
107
+ * whatever it learned about its user into the same backend — so the metadata
108
+ * carries a marker and anything without it is left alone rather than
109
+ * guessed at.
110
+ */
111
+ static fromRecord(record) {
112
+ const parsed = claimMetadataSchema.safeParse(record.metadata);
113
+ if (!parsed.success)
114
+ return undefined;
115
+ const meta = parsed.data;
116
+ return new Claim(meta.kind, meta.statement ?? Claim.statementOf(record.memory, meta.kind), meta.evidence, meta.applies ?? [], meta.confidence, meta.source, meta.at, meta.commit, record.id, record.score, record.runId, meta.verified, record.similarity);
117
+ }
118
+ /**
119
+ * This claim, found to still hold at `commit`.
120
+ *
121
+ * What a refresh records about a claim it read again and kept, so the next
122
+ * refresh does not read it again unless its files change after this.
123
+ */
124
+ verifiedAt(commit, now = new Date()) {
125
+ return new Claim(this.kind, this.statement, this.evidence, this.applies, this.confidence, this.source, this.at, this.commit, this.id, this.score, this.scope, { commit, at: now.toISOString() }, this.similarity);
126
+ }
127
+ /**
128
+ * The commit this claim was last known to hold at: when it was last
129
+ * verified, else when it was written. A change to its files after this is
130
+ * what makes it worth reading again.
131
+ */
132
+ get knownAt() {
133
+ return this.verified?.commit ?? this.commit;
134
+ }
135
+ /** The files the evidence cites, without their line ranges. */
136
+ get cites() {
137
+ return [...new Set(this.evidence.map((one) => one.replace(/:\d+(?:-\d+)?$/, '')).filter(Boolean))];
138
+ }
139
+ /**
140
+ * Whether this claim is about anything under `prefix`, a path relative to
141
+ * the repository root.
142
+ *
143
+ * It is when it cites a file there, or when one of its globs could match a
144
+ * file there. A glob is compared by its literal head, the part before the
145
+ * first wildcard: `src/**` is about `src/knowledge`, and so is a house rule,
146
+ * which is about everything.
147
+ */
148
+ touches(prefix) {
149
+ const under = Claim._normalise(prefix);
150
+ if (!under)
151
+ return true;
152
+ const overlaps = (path) => path === under || path.startsWith(`${under}/`) || under.startsWith(`${path}/`) || path === '';
153
+ if (this.cites.some((path) => path === under || path.startsWith(`${under}/`)))
154
+ return true;
155
+ return this.applies.some((glob) => overlaps(Claim._literalHead(glob)));
156
+ }
157
+ static _normalise(path) {
158
+ const trimmed = path.replace(/^\.\/+/, '');
159
+ // A loop rather than /\/+$/, which rescans from every slash of a path
160
+ // full of them that does not end in one.
161
+ let end = trimmed.length;
162
+ while (end > 0 && trimmed[end - 1] === '/')
163
+ end--;
164
+ return trimmed.slice(0, end);
165
+ }
166
+ /** `src/knowledge/**` → `src/knowledge`; `*` → ``. */
167
+ static _literalHead(glob) {
168
+ const parts = [];
169
+ for (const part of glob.split('/')) {
170
+ if (/[*?{[]/.test(part))
171
+ break;
172
+ parts.push(part);
173
+ }
174
+ return parts.join('/');
175
+ }
176
+ /**
177
+ * The statement recovered from the stored text, for a record written before
178
+ * the statement was kept in the metadata. Takes the first line and strips the
179
+ * kind prefix; the evidence paths below it are not part of the sentence.
180
+ */
181
+ static statementOf(text, kind) {
182
+ const first = text.split('\n')[0] ?? text;
183
+ const prefix = `${kind}: `;
184
+ return first.startsWith(prefix) ? first.slice(prefix.length) : first;
185
+ }
186
+ /** A rule of the house: in every review of this repository, unsearched. */
187
+ get isHouseRule() {
188
+ return this.applies.includes(EVERYWHERE);
189
+ }
190
+ /**
191
+ * Whether this claim governs a path.
192
+ *
193
+ * A guarantee rather than a ranking: a claim whose glob names the file under
194
+ * review reaches the review whatever a similarity score would have said
195
+ * about it. A double star crosses directories, a single one and `?` do not,
196
+ * and `{a,b}` is expanded — enough to write a glob over nested TypeScript
197
+ * sources and no more.
198
+ */
199
+ appliesTo(path) {
200
+ if (this.isHouseRule)
201
+ return true;
202
+ this._globs ??= this.applies.flatMap((glob) => Claim._expand(glob)).map((glob) => Claim._pattern(glob));
203
+ return this._globs.some((rx) => rx.test(path));
204
+ }
205
+ /** `a/{b,c}.ts` as the two globs it stands for. */
206
+ static _expand(glob) {
207
+ const open = glob.indexOf('{');
208
+ const close = open === -1 ? -1 : glob.indexOf('}', open);
209
+ if (open === -1 || close === -1)
210
+ return [glob];
211
+ const head = glob.slice(0, open);
212
+ const tail = glob.slice(close + 1);
213
+ return glob
214
+ .slice(open + 1, close)
215
+ .split(',')
216
+ .flatMap((one) => Claim._expand(`${head}${one.trim()}${tail}`));
217
+ }
218
+ static _pattern(glob) {
219
+ let out = '';
220
+ for (let i = 0; i < glob.length; i++) {
221
+ const char = glob[i];
222
+ if (char === '*') {
223
+ if (glob[i + 1] === '*') {
224
+ // A double star followed by a slash matches no directories as well
225
+ // as many, so a glob over src covers a file directly in src — which
226
+ // is what anyone writing it meant.
227
+ if (glob[i + 2] === '/') {
228
+ out += '(?:.*/)?';
229
+ i += 2;
230
+ }
231
+ else {
232
+ out += '.*';
233
+ i += 1;
234
+ }
235
+ }
236
+ else {
237
+ out += '[^/]*';
238
+ }
239
+ }
240
+ else if (char === '?') {
241
+ out += '[^/]';
242
+ }
243
+ else {
244
+ out += char.replace(/[.+^${}()|[\]\\]/g, '\\$&');
245
+ }
246
+ }
247
+ return new RegExp(`^${out}$`);
248
+ }
249
+ /**
250
+ * What the store holds as the memory itself, and embeds.
251
+ *
252
+ * The paths are here because this string is the only part of a claim a
253
+ * vector search can see. A claim about an auth service embeds closer to a
254
+ * hunk that touches auth files when the file names travel with the sentence,
255
+ * and nothing is lost by it: the statement is read back from the metadata.
256
+ */
257
+ text() {
258
+ return [`${this.kind}: ${this.statement}`, this.cites.join(' ')].filter(Boolean).join('\n');
259
+ }
260
+ metadata() {
261
+ return {
262
+ weigh: 'claim',
263
+ kind: this.kind,
264
+ statement: this.statement,
265
+ evidence: [...this.evidence],
266
+ ...(this.applies.length && { applies: [...this.applies] }),
267
+ confidence: this.confidence,
268
+ source: this.source,
269
+ ...(this.commit && { commit: this.commit }),
270
+ at: this.at,
271
+ ...(this.verified && { verified: { ...this.verified } }),
272
+ };
273
+ }
274
+ toJSON() {
275
+ return {
276
+ ...(this.id && { id: this.id }),
277
+ kind: this.kind,
278
+ statement: this.statement,
279
+ evidence: [...this.evidence],
280
+ ...(this.applies.length && { applies: [...this.applies] }),
281
+ confidence: this.confidence,
282
+ provenance: { source: this.source, ...(this.commit && { commit: this.commit }), at: this.at },
283
+ ...(this.verified && { verified: { ...this.verified } }),
284
+ ...(this.score !== undefined && { score: this.score }),
285
+ ...(this.similarity !== undefined && { similarity: this.similarity }),
286
+ };
287
+ }
288
+ /** One claim as `weigh context` prints it. */
289
+ describe() {
290
+ const meta = [
291
+ this.id ? `id ${this.id}` : null,
292
+ `confidence ${this.confidence.toFixed(2)}`,
293
+ this.score !== undefined ? `score ${this.score.toFixed(3)}` : null,
294
+ this.applies.length ? `applies ${this.applies.join(' ')}` : null,
295
+ this.source,
296
+ this.at.slice(0, 10),
297
+ ]
298
+ .filter(Boolean)
299
+ .join(' · ');
300
+ return [`• ${this.kind} ${this.statement}`, ` ${meta}`, ` ${this.evidence.join(', ')}`].join('\n');
301
+ }
302
+ }
303
+ //# sourceMappingURL=claim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim.js","sourceRoot":"","sources":["../../src/knowledge/claim.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAG5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAmD,MAAM,aAAa,CAAC;AAErH,+DAA+D;AAC/D,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB,4EAA4E;AAC5E,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;;;;;;;;GASG;AACH,MAAM,OAAO,KAAK;IAKL,IAAI;IACJ,SAAS;IACT,QAAQ;IAUR,OAAO;IACP,UAAU;IACV,MAAM;IACN,EAAE;IACF,MAAM;IAEN,EAAE;IAEF,KAAK;IASL,KAAK;IAEL,QAAQ;IAOR,UAAU;IA1CrB,4EAA4E;IACpE,MAAM,CAAuB;IAErC,YACW,IAAU,EACV,SAAiB,EACjB,QAA2B;IACpC;;;;;;;;OAQG;IACM,OAA0B,EAC1B,UAAkB,EAClB,MAAmB,EACnB,EAAU,EACV,MAA0B;IACnC,yDAAyD;IAChD,EAAE,GAAuB,SAAS;IAC3C,0DAA0D;IACjD,KAAK,GAAuB,SAAS;IAC9C;;;;;;;OAOG;IACM,KAAK,GAAuB,SAAS;IAC9C,wEAAwE;IAC/D,QAAQ,GAA+C,SAAS;IACzE;;;;;OAKG;IACM,UAAU,GAAuB,SA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tE,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,QAAQ;QACN,MAAM,IAAI,GAAG;YACX,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;YAChC,cAAc,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC1C,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;YAClE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;YAChE,IAAI,CAAC,MAAM;YACX,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;SACrB;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,KAAK,CAAC,CAAC;QACf,OAAO,CAAC,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxG,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * What Weigh knows about a repository, as opposed to about a change.
3
+ *
4
+ * A review reads code and reports on it. What it cannot read off a diff is what
5
+ * the repository is *like* — which service owns the tokens, which patterns are
6
+ * deliberate, which file everything breaks in. That is written down here, by a
7
+ * priming agent before any review and by Weigh afterwards, and recalled into
8
+ * the review context so a finding about a house convention is never born.
9
+ *
10
+ * One class each: `Claim` is one thing that is true, `Knowledge` is the typed
11
+ * way in and out of the store, and `schema.ts` is the contract every writer is
12
+ * held to. `Recall` is how claims find their way to a change — four mechanisms
13
+ * over three scopes — `KnowledgeBlock` is one labelled group of what it found,
14
+ * and `Recalled` is the whole of it, budgeted and rendered for the prompt.
15
+ * `Novelty` keeps a claim the repository already holds from being written again.
16
+ */
17
+ export { KINDS, SOURCES, claimInputSchema, claimMetadataSchema } from './schema.js';
18
+ export type { ClaimInput, ClaimMetadata, ClaimSource, Kind } from './schema.js';
19
+ export { Claim } from './claim.js';
20
+ export { Knowledge } from './store.js';
21
+ export type { ConfirmAt } from './store.js';
22
+ export { KnowledgeBlock } from './block.js';
23
+ export { RecalledClaim } from './recalled-claim.js';
24
+ export type { Mechanism } from './recalled-claim.js';
25
+ export { Recalled } from './recalled.js';
26
+ export { Recall } from './recall.js';
27
+ export { Novelty } from './novelty.js';
28
+ export type { SkipReason, Skipped } from './novelty.js';
29
+ export { Staleness } from './staleness.js';
30
+ export type { StaleClaim, StaleReason } from './staleness.js';
31
+ export type { ChangeUnderReview, RecallLimits } from './recall.js';
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/knowledge/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACpF,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9D,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,29 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ /**
5
+ * What Weigh knows about a repository, as opposed to about a change.
6
+ *
7
+ * A review reads code and reports on it. What it cannot read off a diff is what
8
+ * the repository is *like* — which service owns the tokens, which patterns are
9
+ * deliberate, which file everything breaks in. That is written down here, by a
10
+ * priming agent before any review and by Weigh afterwards, and recalled into
11
+ * the review context so a finding about a house convention is never born.
12
+ *
13
+ * One class each: `Claim` is one thing that is true, `Knowledge` is the typed
14
+ * way in and out of the store, and `schema.ts` is the contract every writer is
15
+ * held to. `Recall` is how claims find their way to a change — four mechanisms
16
+ * over three scopes — `KnowledgeBlock` is one labelled group of what it found,
17
+ * and `Recalled` is the whole of it, budgeted and rendered for the prompt.
18
+ * `Novelty` keeps a claim the repository already holds from being written again.
19
+ */
20
+ export { KINDS, SOURCES, claimInputSchema, claimMetadataSchema } from './schema.js';
21
+ export { Claim } from './claim.js';
22
+ export { Knowledge } from './store.js';
23
+ export { KnowledgeBlock } from './block.js';
24
+ export { RecalledClaim } from './recalled-claim.js';
25
+ export { Recalled } from './recalled.js';
26
+ export { Recall } from './recall.js';
27
+ export { Novelty } from './novelty.js';
28
+ export { Staleness } from './staleness.js';
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/knowledge/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEpF,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,65 @@
1
+ import type { Scope } from '../memory/scope.js';
2
+ import type { Claim } from './claim.js';
3
+ import type { Knowledge } from './store.js';
4
+ /**
5
+ * Why a claim was not written.
6
+ *
7
+ * - `held`: the repository already holds this sentence.
8
+ * - `repeated`: an earlier claim in the same batch says it.
9
+ * - `similar`: a held claim reads closely enough to be the same fact in other
10
+ * words. Not written, so a person or the writer can decide.
11
+ */
12
+ export type SkipReason = 'held' | 'repeated' | 'similar';
13
+ /** A claim that was not written, and the claim it was matched to. */
14
+ export interface Skipped {
15
+ claim: Claim;
16
+ reason: SkipReason;
17
+ /** The claim it matched: one held by the store, or one earlier in the batch. */
18
+ match: Claim;
19
+ }
20
+ /**
21
+ * Which of a batch of claims the repository does not hold yet.
22
+ *
23
+ * `context add` writes whatever it is handed, and the store keeps it word for
24
+ * word. A claim written twice is recalled twice and paid for twice in every
25
+ * review it reaches. A fleet of explorers produces duplicates by construction,
26
+ * so this is what `context add --if-new` runs before it writes.
27
+ *
28
+ * Two checks, because neither is enough alone:
29
+ *
30
+ * - The same sentence, compared after folding case, spacing and a closing
31
+ * full stop. Read from one listing of the scope, not from a search, so
32
+ * whether it is found never depends on a similarity score.
33
+ * - A close match in meaning, for the same fact in other words. Measured on
34
+ * this repository's own claims, reworded duplicates came in at 0.79 – 0.89
35
+ * and related but different claims at 0.71 – 0.74. Too close for a number to
36
+ * decide alone, so a claim above the floor is held back and named with its
37
+ * match, never dropped silently and never written on a guess.
38
+ *
39
+ * Held to the vector similarity, not the search's score: mem0 blends keyword
40
+ * and entity matches into that and scales it by what else the search found,
41
+ * so one pair scored 0.92 in one store and 0.49 in another. The search is by
42
+ * the statement alone. The stored text carries the cited paths too, and
43
+ * searching with them pushed every claim about the same files towards the
44
+ * floor, related or not.
45
+ */
46
+ export declare class Novelty {
47
+ private readonly _knowledge;
48
+ /** The score at which a held claim counts as the same fact. 1 checks exact repeats only. */
49
+ private readonly _similar;
50
+ /** How many similarity searches run at once. */
51
+ private static readonly _PARALLEL;
52
+ constructor(_knowledge: Knowledge,
53
+ /** The score at which a held claim counts as the same fact. 1 checks exact repeats only. */
54
+ _similar: number);
55
+ /** The claims to write, and the ones held back with what they matched. */
56
+ sift(claims: readonly Claim[], scope: Scope): Promise<{
57
+ fresh: Claim[];
58
+ skipped: Skipped[];
59
+ }>;
60
+ /** The closest held claim at or above the floor, if there is one. */
61
+ private _nearest;
62
+ /** A statement with case, spacing and a closing full stop folded away. */
63
+ private static _key;
64
+ }
65
+ //# sourceMappingURL=novelty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"novelty.d.ts","sourceRoot":"","sources":["../../src/knowledge/novelty.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;AAEzD,qEAAqE;AACrE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,gFAAgF;IAChF,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,OAAO;IAKhB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,4FAA4F;IAC5F,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAN3B,gDAAgD;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAK;IAEtC,YACmB,UAAU,EAAE,SAAS;IACtC,4FAA4F;IAC3E,QAAQ,EAAE,MAAM,EAC/B;IAEJ,0EAA0E;IACpE,IAAI,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,CAiClG;IAED,qEAAqE;YACvD,QAAQ;IAStB,0EAA0E;IAC1E,OAAO,CAAC,MAAM,CAAC,IAAI;CAQpB"}
@@ -0,0 +1,100 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ import PQueue from 'p-queue';
5
+ /**
6
+ * Which of a batch of claims the repository does not hold yet.
7
+ *
8
+ * `context add` writes whatever it is handed, and the store keeps it word for
9
+ * word. A claim written twice is recalled twice and paid for twice in every
10
+ * review it reaches. A fleet of explorers produces duplicates by construction,
11
+ * so this is what `context add --if-new` runs before it writes.
12
+ *
13
+ * Two checks, because neither is enough alone:
14
+ *
15
+ * - The same sentence, compared after folding case, spacing and a closing
16
+ * full stop. Read from one listing of the scope, not from a search, so
17
+ * whether it is found never depends on a similarity score.
18
+ * - A close match in meaning, for the same fact in other words. Measured on
19
+ * this repository's own claims, reworded duplicates came in at 0.79 – 0.89
20
+ * and related but different claims at 0.71 – 0.74. Too close for a number to
21
+ * decide alone, so a claim above the floor is held back and named with its
22
+ * match, never dropped silently and never written on a guess.
23
+ *
24
+ * Held to the vector similarity, not the search's score: mem0 blends keyword
25
+ * and entity matches into that and scales it by what else the search found,
26
+ * so one pair scored 0.92 in one store and 0.49 in another. The search is by
27
+ * the statement alone. The stored text carries the cited paths too, and
28
+ * searching with them pushed every claim about the same files towards the
29
+ * floor, related or not.
30
+ */
31
+ export class Novelty {
32
+ _knowledge;
33
+ _similar;
34
+ /** How many similarity searches run at once. */
35
+ static _PARALLEL = 8;
36
+ constructor(_knowledge,
37
+ /** The score at which a held claim counts as the same fact. 1 checks exact repeats only. */
38
+ _similar) {
39
+ this._knowledge = _knowledge;
40
+ this._similar = _similar;
41
+ }
42
+ /** The claims to write, and the ones held back with what they matched. */
43
+ async sift(claims, scope) {
44
+ const held = new Map();
45
+ for (const claim of await this._knowledge.list(scope)) {
46
+ const key = Novelty._key(claim);
47
+ if (!held.has(key))
48
+ held.set(key, claim);
49
+ }
50
+ const unseen = [];
51
+ const skipped = [];
52
+ const batch = new Map();
53
+ for (const claim of claims) {
54
+ const key = Novelty._key(claim);
55
+ const same = held.get(key);
56
+ const earlier = batch.get(key);
57
+ if (same)
58
+ skipped.push({ claim, reason: 'held', match: same });
59
+ else if (earlier)
60
+ skipped.push({ claim, reason: 'repeated', match: earlier });
61
+ else {
62
+ batch.set(key, claim);
63
+ unseen.push(claim);
64
+ }
65
+ }
66
+ if (this._similar >= 1 || unseen.length === 0)
67
+ return { fresh: unseen, skipped };
68
+ const queue = new PQueue({ concurrency: Novelty._PARALLEL });
69
+ const nearest = await queue.addAll(unseen.map((claim) => () => this._nearest(claim, scope)));
70
+ const fresh = [];
71
+ for (const [i, claim] of unseen.entries()) {
72
+ const match = nearest[i];
73
+ if (match)
74
+ skipped.push({ claim, reason: 'similar', match });
75
+ else
76
+ fresh.push(claim);
77
+ }
78
+ return { fresh, skipped };
79
+ }
80
+ /** The closest held claim at or above the floor, if there is one. */
81
+ async _nearest(claim, scope) {
82
+ const near = await this._knowledge.search(claim.statement, scope, { topK: 3, threshold: this._similar });
83
+ // Checked here as well: a backend that ignores the threshold must not
84
+ // turn every nearest neighbour into a duplicate. Similarity alone where
85
+ // the backend reports it, since a blended score moves with the store.
86
+ const close = (one) => one.similarity ?? one.score ?? 0;
87
+ return near.filter((one) => close(one) >= this._similar).sort((a, b) => close(b) - close(a))[0];
88
+ }
89
+ /** A statement with case, spacing and a closing full stop folded away. */
90
+ static _key(claim) {
91
+ const folded = claim.statement.toLowerCase().replace(/\s+/g, ' ').trim();
92
+ // A loop rather than /[.;]+$/, which rescans from every stop in a run of
93
+ // them that does not end the statement.
94
+ let end = folded.length;
95
+ while (end > 0 && (folded[end - 1] === '.' || folded[end - 1] === ';'))
96
+ end--;
97
+ return folded.slice(0, end);
98
+ }
99
+ }
100
+ //# sourceMappingURL=novelty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"novelty.js","sourceRoot":"","sources":["../../src/knowledge/novelty.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,MAAM,MAAM,SAAS,CAAC;AAuB7B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,OAAO;IAKC,UAAU;IAEV,QAAQ;IAN3B,gDAAgD;IACxC,MAAM,CAAU,SAAS,GAAG,CAAC,CAAC;IAEtC,YACmB,UAAqB;IACtC,4FAA4F;IAC3E,QAAgB;0BAFhB,UAAU;wBAEV,QAAQ;IACxB,CAAC;IAEJ,0EAA0E;IAC1E,KAAK,CAAC,IAAI,CAAC,MAAwB,EAAE,KAAY;QAC/C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAiB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