@afaik-lab/weigh 0.0.0-stage → 0.6.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 (349) hide show
  1. package/.env.example +49 -0
  2. package/LICENSE +373 -0
  3. package/README.md +102 -2
  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 +132 -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 +297 -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 +94 -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 +227 -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 +580 -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 +70 -4
@@ -0,0 +1,31 @@
1
+ /**
2
+ * What a human said about a finding.
3
+ *
4
+ * A review that is read and forgotten is a linter with opinions. The cycle
5
+ * this subsystem exists for is: Weigh reports, a person answers — by fixing
6
+ * it, or by saying why they will not — and that answer changes the next review.
7
+ * This is the half that records the answer. Two things consume it: a refute
8
+ * pass that may stand on a ruling, and promotion, which turns the reason
9
+ * behind a disputed finding into a claim the reviewer is told before it forms
10
+ * a view — so the finding is never born rather than filtered forever.
11
+ *
12
+ * The taxonomy in `schema.ts` is the load-bearing part, not the storage. Four
13
+ * of its five labels are a "no", and they do not mean the same thing: two say
14
+ * the finding was never true, two concede it is true and decline to act now.
15
+ * Only the first two may ever kill a finding.
16
+ *
17
+ * One class each: `FollowUp` reads the words, `Correction` is one ruling,
18
+ * `Corrections` decides where they live, `CorrectionSet` is the rulings in
19
+ * force over one review, `Promotion` writes what one teaches into repository
20
+ * knowledge — and `schema.ts` is what they agree on.
21
+ */
22
+ export { CORRECTION_LABELS, CORRECTION_VERSION, LABEL_RULES, correctionSchema } from './schema.js';
23
+ export type { CorrectionJson, CorrectionLabel, LabelRule } from './schema.js';
24
+ export { Correction } from './correction.js';
25
+ export type { CorrectionInput } from './correction.js';
26
+ export { FollowUp } from './follow-up.js';
27
+ export type { Attribution, FindingRef } from './follow-up.js';
28
+ export { Corrections } from './ledger.js';
29
+ export { CorrectionSet } from './correction-set.js';
30
+ export { Promotion } from './promotion.js';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/corrections/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnG,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,31 @@
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 a human said about a finding.
6
+ *
7
+ * A review that is read and forgotten is a linter with opinions. The cycle
8
+ * this subsystem exists for is: Weigh reports, a person answers — by fixing
9
+ * it, or by saying why they will not — and that answer changes the next review.
10
+ * This is the half that records the answer. Two things consume it: a refute
11
+ * pass that may stand on a ruling, and promotion, which turns the reason
12
+ * behind a disputed finding into a claim the reviewer is told before it forms
13
+ * a view — so the finding is never born rather than filtered forever.
14
+ *
15
+ * The taxonomy in `schema.ts` is the load-bearing part, not the storage. Four
16
+ * of its five labels are a "no", and they do not mean the same thing: two say
17
+ * the finding was never true, two concede it is true and decline to act now.
18
+ * Only the first two may ever kill a finding.
19
+ *
20
+ * One class each: `FollowUp` reads the words, `Correction` is one ruling,
21
+ * `Corrections` decides where they live, `CorrectionSet` is the rulings in
22
+ * force over one review, `Promotion` writes what one teaches into repository
23
+ * knowledge — and `schema.ts` is what they agree on.
24
+ */
25
+ export { CORRECTION_LABELS, CORRECTION_VERSION, LABEL_RULES, correctionSchema } from './schema.js';
26
+ export { Correction } from './correction.js';
27
+ export { FollowUp } from './follow-up.js';
28
+ export { Corrections } from './ledger.js';
29
+ export { CorrectionSet } from './correction-set.js';
30
+ export { Promotion } from './promotion.js';
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/corrections/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEnG,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { Correction } from './correction.js';
2
+ /**
3
+ * Where human rulings are kept, and how one is found again.
4
+ *
5
+ * **A file, and not the store alone**, with the reasoning beside the code.
6
+ * The original argument was that Mem0 is a semantic store while this
7
+ * lookup is exact; scoped reads settled that part — a list at target scope
8
+ * answers with a change's records exactly, and matching a fingerprint over them
9
+ * is not a similarity search. What is left is the dependency and the answer
10
+ * shape, and both point here. A correction has to be recordable on a machine
11
+ * with no backend configured, because corrections are the loop this whole
12
+ * project is for and a feature that needs Qdrant to say "that is intentional"
13
+ * is a feature most repositories never use. And a refuter asking "did a human
14
+ * rule on this" needs a definite no: a store that is down would turn no record
15
+ * into no answer, and a kill would rest on a question nobody answered.
16
+ *
17
+ * The store still gets its half. Promotion writes an `intentional` out as a
18
+ * convention claim in repo scope, where recall by meaning is exactly the point
19
+ * — the general truth goes in the store, the exact ruling stays here.
20
+ *
21
+ * **Not the whole answer once CI runs this**, and the blocker is identity
22
+ * rather than the medium. A ruling recorded on a runner is in a home directory
23
+ * that is deleted with the container, and one recorded here is keyed to a path
24
+ * no runner has: `repoSlug` hashes the absolute root, so `/home/runner/work/…`
25
+ * is a different repository, and a store record would be no better off — every
26
+ * read is filtered by `userId`, which defaults to `$USER`. Either way a ruling
27
+ * is one person's, on one machine.
28
+ *
29
+ * Settled on the shape, not yet built. With a memory backend enabled the store
30
+ * is where a ruling goes, because it is the only half that crosses machines,
31
+ * and this file stays as the write that needs no backend and no network; both
32
+ * are read and `inForce`'s latest-wins per fingerprint resolves the overlap.
33
+ * Two rules come with it: `infer: false`, so extraction cannot paraphrase the
34
+ * one record that has to be quoted back; and a store that cannot be read counts
35
+ * as *unknown* rather than *no*, so a refuter may not kill a finding on a
36
+ * ruling it failed to fetch — a read failure makes a review noisier, never
37
+ * quieter. What both halves wait on is an identity that is neither this path
38
+ * nor this person: the remote's `owner/repo`, and a user that is a team. A
39
+ * correction is the first record here that is not a personal memory. That
40
+ * identity is the GitHub phase's to decide, which is also where PR comments
41
+ * arrive — as the input, not as the ledger, since a per-PR thread cannot hold a
42
+ * ruling that reaches every branch.
43
+ *
44
+ * One file per repository, keyed by the same slug a review and a memory scope
45
+ * use, so the three cannot disagree about which repository they mean. Lines
46
+ * rather than a document, because a ruling is an event: appending is atomic
47
+ * enough for a human typing one at a time, and rewriting a file to record what
48
+ * someone said invites losing what they said before.
49
+ */
50
+ export declare class Corrections {
51
+ private readonly _dir;
52
+ constructor(_dir?: string);
53
+ get dir(): string;
54
+ fileFor(target: string): string;
55
+ /** Writes one ruling and returns the path it landed in. */
56
+ record(correction: Correction): string;
57
+ /**
58
+ * Every ruling ever recorded about a repository, oldest first.
59
+ *
60
+ * Strict: a line it cannot read throws, naming the line. This file is small,
61
+ * hand-editable and the only record of what a human decided — skipping a
62
+ * line that will not parse would silently drop a ruling, which looks exactly
63
+ * like never having made it. Callers on the review path are the ones that
64
+ * degrade, and they do it where a reader can see the warning.
65
+ */
66
+ all(target: string): Correction[];
67
+ /**
68
+ * The rulings in force for one branch — the latest one per finding.
69
+ *
70
+ * Latest wins, and only the latest: ruling again on a finding is how someone
71
+ * changes their mind, and a refuter handed both answers would be choosing
72
+ * between them on its own.
73
+ */
74
+ inForce(target: string, branch: string | null): Correction[];
75
+ /** The ruling in force on one finding, if a human has made one. */
76
+ forFinding(target: string, branch: string | null, fingerprint: string): Correction | undefined;
77
+ }
78
+ //# sourceMappingURL=ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../src/corrections/ledger.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,GAAE,MAA4B,EAAI;IAEnE,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9B;IAED,2DAA2D;IAC3D,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAKrC;IAED;;;;;;;;OAQG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,CAQhC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,EAAE,CAQ3D;IAED,mEAAmE;IACnE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAE7F;CACF"}
@@ -0,0 +1,117 @@
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 { appendFileSync, existsSync, readFileSync } from 'fs';
5
+ import { join } from 'path';
6
+ import { ensureDir, paths } from '../paths.js';
7
+ import { repoSlug } from '../target.js';
8
+ import { Correction } from './correction.js';
9
+ /**
10
+ * Where human rulings are kept, and how one is found again.
11
+ *
12
+ * **A file, and not the store alone**, with the reasoning beside the code.
13
+ * The original argument was that Mem0 is a semantic store while this
14
+ * lookup is exact; scoped reads settled that part — a list at target scope
15
+ * answers with a change's records exactly, and matching a fingerprint over them
16
+ * is not a similarity search. What is left is the dependency and the answer
17
+ * shape, and both point here. A correction has to be recordable on a machine
18
+ * with no backend configured, because corrections are the loop this whole
19
+ * project is for and a feature that needs Qdrant to say "that is intentional"
20
+ * is a feature most repositories never use. And a refuter asking "did a human
21
+ * rule on this" needs a definite no: a store that is down would turn no record
22
+ * into no answer, and a kill would rest on a question nobody answered.
23
+ *
24
+ * The store still gets its half. Promotion writes an `intentional` out as a
25
+ * convention claim in repo scope, where recall by meaning is exactly the point
26
+ * — the general truth goes in the store, the exact ruling stays here.
27
+ *
28
+ * **Not the whole answer once CI runs this**, and the blocker is identity
29
+ * rather than the medium. A ruling recorded on a runner is in a home directory
30
+ * that is deleted with the container, and one recorded here is keyed to a path
31
+ * no runner has: `repoSlug` hashes the absolute root, so `/home/runner/work/…`
32
+ * is a different repository, and a store record would be no better off — every
33
+ * read is filtered by `userId`, which defaults to `$USER`. Either way a ruling
34
+ * is one person's, on one machine.
35
+ *
36
+ * Settled on the shape, not yet built. With a memory backend enabled the store
37
+ * is where a ruling goes, because it is the only half that crosses machines,
38
+ * and this file stays as the write that needs no backend and no network; both
39
+ * are read and `inForce`'s latest-wins per fingerprint resolves the overlap.
40
+ * Two rules come with it: `infer: false`, so extraction cannot paraphrase the
41
+ * one record that has to be quoted back; and a store that cannot be read counts
42
+ * as *unknown* rather than *no*, so a refuter may not kill a finding on a
43
+ * ruling it failed to fetch — a read failure makes a review noisier, never
44
+ * quieter. What both halves wait on is an identity that is neither this path
45
+ * nor this person: the remote's `owner/repo`, and a user that is a team. A
46
+ * correction is the first record here that is not a personal memory. That
47
+ * identity is the GitHub phase's to decide, which is also where PR comments
48
+ * arrive — as the input, not as the ledger, since a per-PR thread cannot hold a
49
+ * ruling that reaches every branch.
50
+ *
51
+ * One file per repository, keyed by the same slug a review and a memory scope
52
+ * use, so the three cannot disagree about which repository they mean. Lines
53
+ * rather than a document, because a ruling is an event: appending is atomic
54
+ * enough for a human typing one at a time, and rewriting a file to record what
55
+ * someone said invites losing what they said before.
56
+ */
57
+ export class Corrections {
58
+ _dir;
59
+ constructor(_dir = paths.corrections()) {
60
+ this._dir = _dir;
61
+ }
62
+ get dir() {
63
+ return this._dir;
64
+ }
65
+ fileFor(target) {
66
+ return join(this._dir, `${repoSlug(target)}.jsonl`);
67
+ }
68
+ /** Writes one ruling and returns the path it landed in. */
69
+ record(correction) {
70
+ const path = this.fileFor(correction.target);
71
+ ensureDir(this._dir);
72
+ appendFileSync(path, JSON.stringify(correction.toJSON()) + '\n');
73
+ return path;
74
+ }
75
+ /**
76
+ * Every ruling ever recorded about a repository, oldest first.
77
+ *
78
+ * Strict: a line it cannot read throws, naming the line. This file is small,
79
+ * hand-editable and the only record of what a human decided — skipping a
80
+ * line that will not parse would silently drop a ruling, which looks exactly
81
+ * like never having made it. Callers on the review path are the ones that
82
+ * degrade, and they do it where a reader can see the warning.
83
+ */
84
+ all(target) {
85
+ const path = this.fileFor(target);
86
+ if (!existsSync(path))
87
+ return [];
88
+ return readFileSync(path, 'utf-8')
89
+ .split('\n')
90
+ .map((line, i) => ({ line: line.trim(), at: i + 1 }))
91
+ .filter(({ line }) => line.length > 0)
92
+ .map(({ line, at }) => Correction.parse(line, `${path}:${at}`));
93
+ }
94
+ /**
95
+ * The rulings in force for one branch — the latest one per finding.
96
+ *
97
+ * Latest wins, and only the latest: ruling again on a finding is how someone
98
+ * changes their mind, and a refuter handed both answers would be choosing
99
+ * between them on its own.
100
+ */
101
+ inForce(target, branch) {
102
+ const latest = new Map();
103
+ for (const correction of this.all(target)) {
104
+ if (!correction.appliesTo(branch))
105
+ continue;
106
+ const held = latest.get(correction.fingerprint);
107
+ if (!held || held.at <= correction.at)
108
+ latest.set(correction.fingerprint, correction);
109
+ }
110
+ return [...latest.values()];
111
+ }
112
+ /** The ruling in force on one finding, if a human has made one. */
113
+ forFinding(target, branch, fingerprint) {
114
+ return this.inForce(target, branch).find((one) => one.fingerprint === fingerprint);
115
+ }
116
+ }
117
+ //# sourceMappingURL=ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../src/corrections/ledger.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,OAAO,WAAW;IACO,IAAI;IAAjC,YAA6B,IAAI,GAAW,KAAK,CAAC,WAAW,EAAE;oBAAlC,IAAI;IAAiC,CAAC;IAEnE,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,MAAc;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,2DAA2D;IAC3D,MAAM,CAAC,UAAsB;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC7C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,cAAc,CAAC,IAAI,EAAE,IAAI,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,WAAW,EAAE,UAAU,CAAC,CAAC;QACxF,CAAC;QACD,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,mEAAmE;IACnE,UAAU,CAAC,MAAc,EAAE,MAAqB,EAAE,WAAmB;QACnE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,KAAK,WAAW,CAAC,CAAC;IACrF,CAAC;CACF"}
@@ -0,0 +1,119 @@
1
+ import { Claim } from '../knowledge/claim.js';
2
+ import type { Knowledge } from '../knowledge/store.js';
3
+ import type { Correction } from './correction.js';
4
+ /**
5
+ * What a ruling teaches, written where the next review will read it.
6
+ *
7
+ * This is the difference between a filter and a loop. A ledger lookup runs
8
+ * forever: the finding is produced on every review of the file and taken out
9
+ * again afterwards. A promoted claim reaches the reviewer before it forms a
10
+ * view, so the finding is never born.
11
+ *
12
+ * It promotes the human's reason, not their ruling. Two labels teach, and both
13
+ * were made to supply a reason for exactly this: an `intentional` says how the
14
+ * repository does things, and an `incorrect` had to point at the code that
15
+ * shows the misreading. "You misread line 8" generalises to nothing, while
16
+ * "baskets are validated as arrays at src/dto.ts:12" is a fact about the code
17
+ * that holds next week too. Same ruling, useful half.
18
+ *
19
+ * The reason goes in verbatim. A model asked to phrase it better is a model
20
+ * paraphrasing an invariant, which is the thing `Knowledge.add` passes
21
+ * `infer: false` to prevent — and a claim in the ruler's words is one they can
22
+ * recognise when a later review quotes it back at them.
23
+ *
24
+ * One rule holds the whole thing up: what is written is a positive claim about
25
+ * the code, never an instruction about reviewing. "qty is validated at
26
+ * dto.ts:12" is bounded and falsifiable — delete the validation and the claim
27
+ * is wrong, and the finding comes back. "Stop reporting overflow in total.js"
28
+ * is unbounded, unfalsifiable, and teaches the reviewer towards silence, which
29
+ * is the failure this taxonomy calls the one nobody ever finds out about.
30
+ */
31
+ export declare class Promotion {
32
+ private readonly _knowledge;
33
+ private readonly _onWarn?;
34
+ constructor(_knowledge: Knowledge, _onWarn?: ((message: string) => void) | undefined);
35
+ /** Whether anything can be written at all. */
36
+ get enabled(): boolean;
37
+ /** Why nothing can be written, when nothing can. */
38
+ get reason(): string | undefined;
39
+ /**
40
+ * The claim one ruling teaches, or nothing when it teaches nothing.
41
+ *
42
+ * Pure, and separate from writing it, so what a label turns into can be
43
+ * asserted without a store — and so a caller can show someone what would be
44
+ * written before it is.
45
+ *
46
+ * The two shapes differ in where they hold. An `intentional` is a rule of
47
+ * the house: `applies: ['*']`, which `Recall` injects into every review of
48
+ * the repository, because a convention the reviewer only hears about when it
49
+ * touches one file is a convention it will break in the next. An
50
+ * `incorrect` is a fact about particular code, so it is globbed to the paths
51
+ * it came from — the guarantee where it matters, and proximity everywhere
52
+ * else. That is also what answers the objection the taxonomy raised against
53
+ * teaching from a misreading: the claim does not enter every later prompt,
54
+ * only the reviews that touch those files.
55
+ */
56
+ static claimFor(correction: Correction, options?: {
57
+ commit?: string;
58
+ now?: Date;
59
+ }): Claim | undefined;
60
+ /**
61
+ * What a batch of rulings teaches: one claim per reason.
62
+ *
63
+ * Two rulings that give the same reason are one claim, as they are to
64
+ * `pending`. The store keeps what it is handed word for word, so written
65
+ * twice the sentence would be recalled twice and paid for twice.
66
+ *
67
+ * Merged rather than dropped. An `incorrect` claim is pinned to the files
68
+ * its finding came from, so the same reason given for findings in two files
69
+ * has to hold in both — keeping only the first would stop it being recalled
70
+ * for the second. It dates from the earliest of the rulings, since a claim
71
+ * is as old as the first time someone said it.
72
+ */
73
+ static claimsFor(corrections: readonly Correction[], options?: {
74
+ commit?: string;
75
+ now?: Date;
76
+ }): Claim[];
77
+ private static _merged;
78
+ /**
79
+ * Writes what these rulings teach, and says what it could not write.
80
+ *
81
+ * Never throws, and never fails its caller. A ruling is recorded in the
82
+ * ledger before this runs, so a store that is down costs the loop its
83
+ * compounding and leaves the filter — the finding is reported and taken out
84
+ * again, which is noisier than it should be rather than quieter. That is the
85
+ * direction everything else here fails in too.
86
+ *
87
+ * One write per claim rather than one batch, so a backend that fails on the
88
+ * third of three still has the first two, and what comes back is what the
89
+ * store accepted rather than what it was offered.
90
+ *
91
+ * Through `claimsFor`, so two rulings in one batch with the same reason are
92
+ * one write. `pending` cannot catch those: neither is in the store when it
93
+ * looks.
94
+ */
95
+ of(corrections: readonly Correction[], target: string, options?: {
96
+ commit?: string;
97
+ }): Promise<Claim[]>;
98
+ /**
99
+ * The rulings here that nothing in the store has learned yet.
100
+ *
101
+ * Matched on the statement, which is the sentence the human wrote: the
102
+ * claim record carries its source and its evidence but not the fingerprint
103
+ * it came from, so two rulings that gave the same reason count as one claim.
104
+ * That is the harmless direction — the claim is there either way — and the
105
+ * exact join waits for a reason to need it, which is a slice that has to
106
+ * retract a promoted claim when its ruling is overruled.
107
+ *
108
+ * One search per claim, by its own words, rather than one capped listing of
109
+ * the repository: past the cap a claim already written would fall out of
110
+ * the sample and be written again, so "already taught" would depend on a
111
+ * limit that exists for prompt size. The exact sentence is its own nearest
112
+ * neighbour, so a handful of results is enough to find it.
113
+ */
114
+ pending(corrections: readonly Correction[], target: string): Promise<Correction[]>;
115
+ private _taught;
116
+ /** The file paths in a list of evidence, each without its line part. */
117
+ private static _paths;
118
+ }
119
+ //# sourceMappingURL=promotion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../../src/corrections/promotion.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAiBlD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,SAAS;IAElB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAF3B,YACmB,UAAU,EAAE,SAAS,EACrB,OAAO,CAAC,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,aAAA,EAClD;IAEJ,8CAA8C;IAC9C,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,oDAAoD;IACpD,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,IAAI,CAAA;KAAO,GAAG,KAAK,GAAG,SAAS,CA+BxG;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,IAAI,CAAA;KAAO,GAAG,KAAK,EAAE,CAS3G;IAED,OAAO,CAAC,MAAM,CAAC,OAAO;IAoBtB;;;;;;;;;;;;;;;;OAgBG;IACG,EAAE,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAsBhH;IAED;;;;;;;;;;;;;;;OAeG;IACG,OAAO,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAQvF;YAEa,OAAO;IAOrB,wEAAwE;IACxE,OAAO,CAAC,MAAM,CAAC,MAAM;CAGtB"}
@@ -0,0 +1,221 @@
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 { Claim } from '../knowledge/claim.js';
5
+ import { Scope } from '../memory/scope.js';
6
+ /** How many neighbours to look through for a claim's exact sentence. */
7
+ const TAUGHT_PROBE = 10;
8
+ /**
9
+ * The confidence a promoted claim is written at.
10
+ *
11
+ * Above the 0.7 a writer gets for free, because a human typed it and the
12
+ * taxonomy made them cite code for it. Not 1.0: the sentence is theirs, and
13
+ * people are wrong about their own repositories too.
14
+ */
15
+ const CITED_BY_A_HUMAN = 0.9;
16
+ /** `applies` marker for a claim that holds everywhere. See `Claim.isHouseRule`. */
17
+ const EVERYWHERE = '*';
18
+ /**
19
+ * What a ruling teaches, written where the next review will read it.
20
+ *
21
+ * This is the difference between a filter and a loop. A ledger lookup runs
22
+ * forever: the finding is produced on every review of the file and taken out
23
+ * again afterwards. A promoted claim reaches the reviewer before it forms a
24
+ * view, so the finding is never born.
25
+ *
26
+ * It promotes the human's reason, not their ruling. Two labels teach, and both
27
+ * were made to supply a reason for exactly this: an `intentional` says how the
28
+ * repository does things, and an `incorrect` had to point at the code that
29
+ * shows the misreading. "You misread line 8" generalises to nothing, while
30
+ * "baskets are validated as arrays at src/dto.ts:12" is a fact about the code
31
+ * that holds next week too. Same ruling, useful half.
32
+ *
33
+ * The reason goes in verbatim. A model asked to phrase it better is a model
34
+ * paraphrasing an invariant, which is the thing `Knowledge.add` passes
35
+ * `infer: false` to prevent — and a claim in the ruler's words is one they can
36
+ * recognise when a later review quotes it back at them.
37
+ *
38
+ * One rule holds the whole thing up: what is written is a positive claim about
39
+ * the code, never an instruction about reviewing. "qty is validated at
40
+ * dto.ts:12" is bounded and falsifiable — delete the validation and the claim
41
+ * is wrong, and the finding comes back. "Stop reporting overflow in total.js"
42
+ * is unbounded, unfalsifiable, and teaches the reviewer towards silence, which
43
+ * is the failure this taxonomy calls the one nobody ever finds out about.
44
+ */
45
+ export class Promotion {
46
+ _knowledge;
47
+ _onWarn;
48
+ constructor(_knowledge, _onWarn) {
49
+ this._knowledge = _knowledge;
50
+ this._onWarn = _onWarn;
51
+ }
52
+ /** Whether anything can be written at all. */
53
+ get enabled() {
54
+ return this._knowledge.enabled;
55
+ }
56
+ /** Why nothing can be written, when nothing can. */
57
+ get reason() {
58
+ return this._knowledge.reason;
59
+ }
60
+ /**
61
+ * The claim one ruling teaches, or nothing when it teaches nothing.
62
+ *
63
+ * Pure, and separate from writing it, so what a label turns into can be
64
+ * asserted without a store — and so a caller can show someone what would be
65
+ * written before it is.
66
+ *
67
+ * The two shapes differ in where they hold. An `intentional` is a rule of
68
+ * the house: `applies: ['*']`, which `Recall` injects into every review of
69
+ * the repository, because a convention the reviewer only hears about when it
70
+ * touches one file is a convention it will break in the next. An
71
+ * `incorrect` is a fact about particular code, so it is globbed to the paths
72
+ * it came from — the guarantee where it matters, and proximity everywhere
73
+ * else. That is also what answers the objection the taxonomy raised against
74
+ * teaching from a misreading: the claim does not enter every later prompt,
75
+ * only the reviews that touch those files.
76
+ */
77
+ static claimFor(correction, options = {}) {
78
+ if (!correction.teaches)
79
+ return undefined;
80
+ // Both labels that teach are refused without a reason, so this is a record
81
+ // written by hand or before that was enforced. Nothing can be learned from
82
+ // a bare "no".
83
+ if (!correction.reason)
84
+ return undefined;
85
+ const house = correction.label === 'intentional';
86
+ // The finding's own location is evidence, and for an `intentional` it is
87
+ // usually the only evidence there is: the label needs a reason and not a
88
+ // citation, because the code being called deliberate is the code the
89
+ // finding already named.
90
+ const evidence = [...new Set([`${correction.finding.path}:${correction.finding.line}`, ...correction.citations])];
91
+ return Claim.parse({
92
+ kind: house ? 'convention' : 'invariant',
93
+ statement: correction.reason,
94
+ evidence,
95
+ applies: house ? [EVERYWHERE] : Promotion._paths(evidence),
96
+ confidence: CITED_BY_A_HUMAN,
97
+ provenance: {
98
+ source: 'correction',
99
+ // When the ruling was made, not when it was promoted. A claim
100
+ // promoted late is as old as the sentence in it.
101
+ at: correction.at,
102
+ ...(options.commit && { commit: options.commit }),
103
+ },
104
+ }, options.now);
105
+ }
106
+ /**
107
+ * What a batch of rulings teaches: one claim per reason.
108
+ *
109
+ * Two rulings that give the same reason are one claim, as they are to
110
+ * `pending`. The store keeps what it is handed word for word, so written
111
+ * twice the sentence would be recalled twice and paid for twice.
112
+ *
113
+ * Merged rather than dropped. An `incorrect` claim is pinned to the files
114
+ * its finding came from, so the same reason given for findings in two files
115
+ * has to hold in both — keeping only the first would stop it being recalled
116
+ * for the second. It dates from the earliest of the rulings, since a claim
117
+ * is as old as the first time someone said it.
118
+ */
119
+ static claimsFor(corrections, options = {}) {
120
+ const groups = new Map();
121
+ for (const correction of corrections) {
122
+ const claim = Promotion.claimFor(correction, options);
123
+ if (!claim)
124
+ continue;
125
+ const key = `${claim.kind}:${claim.statement}`;
126
+ groups.set(key, [...(groups.get(key) ?? []), claim]);
127
+ }
128
+ return [...groups.values()].map((group) => (group.length === 1 ? group[0] : Promotion._merged(group, options.now)));
129
+ }
130
+ static _merged(claims, now) {
131
+ const first = claims[0];
132
+ const union = (pick) => [...new Set(claims.flatMap(pick))];
133
+ return Claim.parse({
134
+ kind: first.kind,
135
+ statement: first.statement,
136
+ evidence: union((claim) => claim.evidence),
137
+ applies: union((claim) => claim.applies),
138
+ confidence: first.confidence,
139
+ provenance: {
140
+ source: first.source,
141
+ at: claims.map((claim) => claim.at).sort()[0],
142
+ ...(first.commit && { commit: first.commit }),
143
+ },
144
+ }, now);
145
+ }
146
+ /**
147
+ * Writes what these rulings teach, and says what it could not write.
148
+ *
149
+ * Never throws, and never fails its caller. A ruling is recorded in the
150
+ * ledger before this runs, so a store that is down costs the loop its
151
+ * compounding and leaves the filter — the finding is reported and taken out
152
+ * again, which is noisier than it should be rather than quieter. That is the
153
+ * direction everything else here fails in too.
154
+ *
155
+ * One write per claim rather than one batch, so a backend that fails on the
156
+ * third of three still has the first two, and what comes back is what the
157
+ * store accepted rather than what it was offered.
158
+ *
159
+ * Through `claimsFor`, so two rulings in one batch with the same reason are
160
+ * one write. `pending` cannot catch those: neither is in the store when it
161
+ * looks.
162
+ */
163
+ async of(corrections, target, options = {}) {
164
+ const claims = Promotion.claimsFor(corrections, options);
165
+ if (claims.length === 0)
166
+ return [];
167
+ if (!this._knowledge.enabled) {
168
+ this._onWarn?.(`${claims.length} ruling(s) teach something, but memory is off — ${this.reason ?? 'no backend'}. ` +
169
+ 'They stay in the ledger; run `weigh corrections promote` once a backend is configured.');
170
+ return [];
171
+ }
172
+ const scope = Scope.repo(target);
173
+ const written = [];
174
+ for (const claim of claims) {
175
+ try {
176
+ written.push(...(await this._knowledge.add([claim], scope)));
177
+ }
178
+ catch (err) {
179
+ this._onWarn?.(`not promoted — ${err?.message ?? err}`);
180
+ }
181
+ }
182
+ return written;
183
+ }
184
+ /**
185
+ * The rulings here that nothing in the store has learned yet.
186
+ *
187
+ * Matched on the statement, which is the sentence the human wrote: the
188
+ * claim record carries its source and its evidence but not the fingerprint
189
+ * it came from, so two rulings that gave the same reason count as one claim.
190
+ * That is the harmless direction — the claim is there either way — and the
191
+ * exact join waits for a reason to need it, which is a slice that has to
192
+ * retract a promoted claim when its ruling is overruled.
193
+ *
194
+ * One search per claim, by its own words, rather than one capped listing of
195
+ * the repository: past the cap a claim already written would fall out of
196
+ * the sample and be written again, so "already taught" would depend on a
197
+ * limit that exists for prompt size. The exact sentence is its own nearest
198
+ * neighbour, so a handful of results is enough to find it.
199
+ */
200
+ async pending(corrections, target) {
201
+ const scope = Scope.repo(target);
202
+ const pending = [];
203
+ for (const correction of corrections) {
204
+ const claim = Promotion.claimFor(correction);
205
+ if (claim && !(await this._taught(claim, scope)))
206
+ pending.push(correction);
207
+ }
208
+ return pending;
209
+ }
210
+ async _taught(claim, scope) {
211
+ // No floor: the configured threshold is tuned for recall into a prompt,
212
+ // and an exact match must not be dropped by it.
213
+ const near = await this._knowledge.search(claim.text(), scope, { topK: TAUGHT_PROBE, threshold: 0 });
214
+ return near.some((one) => one.source === 'correction' && one.statement === claim.statement);
215
+ }
216
+ /** The file paths in a list of evidence, each without its line part. */
217
+ static _paths(evidence) {
218
+ return [...new Set(evidence.map((one) => one.replace(/:\d+(?:-\d+)?$/, '')).filter(Boolean))];
219
+ }
220
+ }
221
+ //# sourceMappingURL=promotion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion.js","sourceRoot":"","sources":["../../src/corrections/promotion.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,wEAAwE;AACxE,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,mFAAmF;AACnF,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,SAAS;IAED,UAAU;IACV,OAAO;IAF1B,YACmB,UAAqB,EACrB,OAAmC;0BADnC,UAAU;uBACV,OAAO;IACvB,CAAC;IAEJ,8CAA8C;IAC9C,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,oDAAoD;IACpD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAsB,EAAE,OAAO,GAAoC,EAAE;QACnF,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAC1C,2EAA2E;QAC3E,2EAA2E;QAC3E,eAAe;QACf,IAAI,CAAC,UAAU,CAAC,MAAM;YAAE,OAAO,SAAS,CAAC;QAEzC,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,KAAK,aAAa,CAAC;QACjD,yEAAyE;QACzE,yEAAyE;QACzE,qEAAqE;QACrE,yBAAyB;QACzB,MAAM,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