@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,104 @@
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 { FindingSet, Suppression } from '../findings.js';
5
+ /**
6
+ * The rulings that apply to this review, keyed by the finding each is about.
7
+ *
8
+ * Two callers ask different questions of them. The report asks whether to stop
9
+ * showing a finding: that is `applyTo`, and it needs no model call, because
10
+ * what to report is not a question anyone needs a second opinion on. The
11
+ * refuter asks whether it may kill a finding by citing a human: that is
12
+ * `grounds`, which its `corrected` ground is checked against.
13
+ *
14
+ * The two get different answers. A `wont-fix` means "real, and not now", which
15
+ * is enough to stop reporting but is not an argument that the finding is wrong.
16
+ * Which labels do which is decided in the taxonomy; this class only reads
17
+ * `silences` and `grounds` off a correction.
18
+ *
19
+ * Nothing here touches disk. The caller reads the ledger, as it reads the
20
+ * recalled claims and the prior review. That also makes failure safe: a ledger
21
+ * that cannot be read gives an empty set, so nothing is silenced and nothing is
22
+ * grounded, and the review says too much rather than too little. "Could not
23
+ * check" must never come out as "nobody ruled".
24
+ */
25
+ export class CorrectionSet {
26
+ _byFingerprint;
27
+ constructor(_byFingerprint) {
28
+ this._byFingerprint = _byFingerprint;
29
+ }
30
+ /**
31
+ * Indexes rulings by the finding they are about. The latest one wins.
32
+ *
33
+ * `Corrections.inForce` has already picked the latest and filtered by branch.
34
+ * This picks the latest again instead of trusting the input. If someone later
35
+ * builds a set from the whole ledger by mistake, it still holds the current
36
+ * ruling on each finding, not whichever one was written first.
37
+ */
38
+ static of(corrections) {
39
+ const byFingerprint = new Map();
40
+ for (const correction of corrections) {
41
+ const held = byFingerprint.get(correction.fingerprint);
42
+ if (!held || held.at <= correction.at)
43
+ byFingerprint.set(correction.fingerprint, correction);
44
+ }
45
+ return new CorrectionSet(byFingerprint);
46
+ }
47
+ /** Nobody has ruled, or nobody could be asked. The two behave alike here. */
48
+ static empty() {
49
+ return new CorrectionSet(new Map());
50
+ }
51
+ get size() {
52
+ return this._byFingerprint.size;
53
+ }
54
+ get isEmpty() {
55
+ return this._byFingerprint.size === 0;
56
+ }
57
+ /** For the line a run prints before it starts. */
58
+ describe() {
59
+ return `${this.size} ruling(s) in force`;
60
+ }
61
+ /**
62
+ * The ruling a refute pass may stand on, when a human made one.
63
+ *
64
+ * Only the two labels the taxonomy marks as grounds come back. The other
65
+ * three are in force, but they are not arguments. Agreeing with a finding is
66
+ * no reason to drop it, and a defect someone put off is still a defect. A
67
+ * pass allowed to kill on those would be learning to stop mentioning known
68
+ * bugs, and nobody ever sees that failure.
69
+ */
70
+ grounds(fingerprint) {
71
+ const correction = this._byFingerprint.get(fingerprint);
72
+ return correction?.grounds ? correction : undefined;
73
+ }
74
+ /**
75
+ * The findings that survive the rulings, carrying the ones that do not.
76
+ *
77
+ * Silenced findings are suppressed, not dropped, like a refute kill or a
78
+ * confidence floor. A finding that disappears between review and report
79
+ * looks the same as one that was never found. The ruler has the strongest
80
+ * claim to see it anyway: they are the one who asked for the silence, and
81
+ * the report is where they check it was heard.
82
+ *
83
+ * Only the labels that silence take anything out. A finding a human called a
84
+ * misreading is still reported, because the code may have changed since and
85
+ * made the claim true. Checking that is the refuter's job. The taxonomy makes
86
+ * that split; this is not a cautious reading of it.
87
+ */
88
+ applyTo(findings) {
89
+ if (this.isEmpty)
90
+ return findings;
91
+ const kept = [];
92
+ const answered = [];
93
+ for (const finding of findings) {
94
+ const correction = this._byFingerprint.get(finding.id);
95
+ if (!correction?.silences) {
96
+ kept.push(finding);
97
+ continue;
98
+ }
99
+ answered.push(new Suppression(finding, 'answered', correction.oneLine()));
100
+ }
101
+ return new FindingSet(kept, [...findings.suppressed, ...answered]);
102
+ }
103
+ }
104
+ //# sourceMappingURL=correction-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correction-set.js","sourceRoot":"","sources":["../../src/corrections/correction-set.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE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AED;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,QAAoB;QAC1B,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,QAAQ,CAAC;QAElC,MAAM,IAAI,GAAc,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAkB,EAAE,CAAC;QACnC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACvD,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACnB,SAAS;YACX,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,UAAU,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -0,0 +1,74 @@
1
+ import type { Finding } from '../findings.js';
2
+ import { type CorrectionJson, type CorrectionLabel, type LabelRule } from './schema.js';
3
+ /** Everything a ruling needs besides the words it was typed in. */
4
+ export interface CorrectionInput {
5
+ label: CorrectionLabel;
6
+ finding: Finding;
7
+ reason?: string | undefined;
8
+ citations?: readonly string[];
9
+ /** The review that printed the number, so `#3` stays meaningful later. */
10
+ review: string;
11
+ target: string;
12
+ branch: string | null;
13
+ by: string;
14
+ at?: string;
15
+ }
16
+ /**
17
+ * One human ruling on one finding.
18
+ *
19
+ * Keyed to the fingerprint rather than to a line, because the content anchor is
20
+ * what survives the edits a developer makes while answering — the ruling has to
21
+ * still be about the same defect after the file around it moves.
22
+ *
23
+ * It is a record of something said, not a row to be updated. Ruling twice on
24
+ * one finding writes twice, the later one wins, and both stay readable: "I said
25
+ * intentional and I was wrong" is itself a fact about this repository.
26
+ */
27
+ export declare class Correction {
28
+ readonly label: CorrectionLabel;
29
+ readonly fingerprint: string;
30
+ readonly reason: string | undefined;
31
+ readonly citations: readonly string[];
32
+ readonly review: string;
33
+ readonly target: string;
34
+ readonly branch: string | null;
35
+ readonly by: string;
36
+ readonly at: string;
37
+ /** The finding as it read when the ruling was made. */
38
+ readonly finding: CorrectionJson['finding'];
39
+ private constructor();
40
+ static of(input: CorrectionInput): Correction;
41
+ /** One line of the ledger, back as a ruling. */
42
+ static parse(text: string, where: string): Correction;
43
+ get rule(): LabelRule;
44
+ /** May a refute pass stand on this? */
45
+ get grounds(): boolean;
46
+ /** Does the finding stop being reported? */
47
+ get silences(): boolean;
48
+ /** May this become a claim the reviewer is told up front? */
49
+ get teaches(): boolean;
50
+ /**
51
+ * Is this ruling in force on a branch?
52
+ *
53
+ * A repo-wide ruling is in force everywhere. A branch-scoped one is in force
54
+ * where it was said and nowhere else — including on a detached HEAD, where
55
+ * the branch is null on both sides and the comparison still holds.
56
+ */
57
+ appliesTo(branch: string | null): boolean;
58
+ /** What this ruling does to a later review, in a sentence. */
59
+ effect(): string;
60
+ /**
61
+ * The ruling, what it rests on, and what it will do — as a claim describes
62
+ * itself, because the two are read side by side.
63
+ */
64
+ describe(): string;
65
+ /**
66
+ * The ruling as one line: whose answer it is, and what they said.
67
+ *
68
+ * The finding is left out. Both callers are already printing it: the
69
+ * suppressed block in a report, and the brief a refute pass is given.
70
+ */
71
+ oneLine(): string;
72
+ toJSON(): CorrectionJson;
73
+ }
74
+ //# sourceMappingURL=correction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correction.d.ts","sourceRoot":"","sources":["../../src/corrections/correction.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;A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AAQ,IAAI,OAAO,CAEtB;IAED,6DAA6D;IAC7D,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAExC;IAED,8DAA8D;IAC9D,MAAM,IAAI,MAAM,CAKf;IAED;;;OAGG;IACH,QAAQ,IAAI,MAAM,CAQjB;IAED;;;;;OAKG;IACH,OAAO,IAAI,MAAM,CAEhB;IAED,MAAM,IAAI,cAAc,CAavB;CACF"}
@@ -0,0 +1,154 @@
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 { CORRECTION_VERSION, correctionSchema, LABEL_RULES, } from './schema.js';
5
+ /**
6
+ * One human ruling on one finding.
7
+ *
8
+ * Keyed to the fingerprint rather than to a line, because the content anchor is
9
+ * what survives the edits a developer makes while answering — the ruling has to
10
+ * still be about the same defect after the file around it moves.
11
+ *
12
+ * It is a record of something said, not a row to be updated. Ruling twice on
13
+ * one finding writes twice, the later one wins, and both stay readable: "I said
14
+ * intentional and I was wrong" is itself a fact about this repository.
15
+ */
16
+ export class Correction {
17
+ label;
18
+ fingerprint;
19
+ reason;
20
+ citations;
21
+ review;
22
+ target;
23
+ branch;
24
+ by;
25
+ at;
26
+ /** The finding as it read when the ruling was made. */
27
+ finding;
28
+ constructor(data) {
29
+ this.label = data.label;
30
+ this.fingerprint = data.fingerprint;
31
+ this.reason = data.reason ?? undefined;
32
+ this.citations = data.citations;
33
+ this.review = data.review;
34
+ this.target = data.repo.target;
35
+ this.branch = data.repo.branch;
36
+ this.by = data.by;
37
+ this.at = data.at;
38
+ this.finding = data.finding;
39
+ }
40
+ static of(input) {
41
+ return new Correction({
42
+ version: CORRECTION_VERSION,
43
+ at: input.at ?? new Date().toISOString(),
44
+ by: input.by,
45
+ label: input.label,
46
+ fingerprint: input.finding.id,
47
+ reason: input.reason?.trim() || null,
48
+ citations: [...(input.citations ?? [])],
49
+ review: input.review,
50
+ repo: { target: input.target, branch: input.branch },
51
+ finding: {
52
+ path: input.finding.path,
53
+ line: input.finding.line,
54
+ title: input.finding.title,
55
+ severity: input.finding.severity,
56
+ category: input.finding.category,
57
+ },
58
+ });
59
+ }
60
+ /** One line of the ledger, back as a ruling. */
61
+ static parse(text, where) {
62
+ let raw;
63
+ try {
64
+ raw = JSON.parse(text);
65
+ }
66
+ catch (err) {
67
+ throw new Error(`${where}: not a correction (${err?.message ?? err})`);
68
+ }
69
+ const parsed = correctionSchema.safeParse(raw);
70
+ if (parsed.success)
71
+ return new Correction(parsed.data);
72
+ // Said apart from a malformed line, as the review record does it: a ruling
73
+ // from a later build is not a broken one, and sending someone to look for
74
+ // a corruption that is not there costs them an hour.
75
+ const version = raw?.version;
76
+ if (typeof version === 'number' && version !== CORRECTION_VERSION) {
77
+ throw new Error(`${where}: correction version ${version}, and this build reads ${CORRECTION_VERSION}`);
78
+ }
79
+ const issue = parsed.error.issues[0];
80
+ const at = issue?.path.length ? ` at ${issue.path.join('.')}` : '';
81
+ throw new Error(`${where}: not a correction — ${issue?.message ?? 'unrecognised shape'}${at}`);
82
+ }
83
+ get rule() {
84
+ return LABEL_RULES[this.label];
85
+ }
86
+ /** May a refute pass stand on this? */
87
+ get grounds() {
88
+ return this.rule.grounds;
89
+ }
90
+ /** Does the finding stop being reported? */
91
+ get silences() {
92
+ return this.rule.silences;
93
+ }
94
+ /** May this become a claim the reviewer is told up front? */
95
+ get teaches() {
96
+ return this.rule.teaches;
97
+ }
98
+ /**
99
+ * Is this ruling in force on a branch?
100
+ *
101
+ * A repo-wide ruling is in force everywhere. A branch-scoped one is in force
102
+ * where it was said and nowhere else — including on a detached HEAD, where
103
+ * the branch is null on both sides and the comparison still holds.
104
+ */
105
+ appliesTo(branch) {
106
+ return this.rule.reach === 'repo' || this.branch === branch;
107
+ }
108
+ /** What this ruling does to a later review, in a sentence. */
109
+ effect() {
110
+ const where = this.rule.reach === 'repo' ? 'on every branch of this repository' : 'on this branch';
111
+ if (this.grounds)
112
+ return `a ground a refute pass may stand on, ${where}`;
113
+ if (this.silences)
114
+ return `not reported again ${where}; still held to be a real defect`;
115
+ return `recorded as agreement ${where}; it changes no later review`;
116
+ }
117
+ /**
118
+ * The ruling, what it rests on, and what it will do — as a claim describes
119
+ * itself, because the two are read side by side.
120
+ */
121
+ describe() {
122
+ const meta = [this.fingerprint, this.by, this.at.slice(0, 10), ...(this.citations.length ? [`cites ${this.citations.join(' ')}`] : [])];
123
+ return [
124
+ `• ${this.label} ${this.finding.path}:${this.finding.line} ${this.finding.title}`,
125
+ ` ${meta.join(' · ')}`,
126
+ ...(this.reason ? [` "${this.reason}"`] : []),
127
+ ` ${this.effect()}`,
128
+ ].join('\n');
129
+ }
130
+ /**
131
+ * The ruling as one line: whose answer it is, and what they said.
132
+ *
133
+ * The finding is left out. Both callers are already printing it: the
134
+ * suppressed block in a report, and the brief a refute pass is given.
135
+ */
136
+ oneLine() {
137
+ return `${this.by} ruled it ${this.label} on ${this.at.slice(0, 10)}${this.reason ? `: "${this.reason}"` : ''}`;
138
+ }
139
+ toJSON() {
140
+ return {
141
+ version: CORRECTION_VERSION,
142
+ at: this.at,
143
+ by: this.by,
144
+ label: this.label,
145
+ fingerprint: this.fingerprint,
146
+ reason: this.reason ?? null,
147
+ citations: [...this.citations],
148
+ review: this.review,
149
+ repo: { target: this.target, branch: this.branch },
150
+ finding: this.finding,
151
+ };
152
+ }
153
+ }
154
+ //# sourceMappingURL=correction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correction.js","sourceRoot":"","sources":["../../src/corrections/correction.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAG5D,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,GAIZ,MAAM,aAAa,CAAC;AAgBrB;;;;;;;;;;GAUG;AACH,MAAM,OAAO,UA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AAI,CAAC,MAAM,IAAI,IAAI;YAC3B,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;YAC9B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;YAClD,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,69 @@
1
+ import { type CorrectionLabel } from './schema.js';
2
+ /** Which finding a ruling is about: the number the report printed, or its id. */
3
+ export type FindingRef = {
4
+ number: number;
5
+ } | {
6
+ fingerprint: string;
7
+ };
8
+ /** One ruling, as it was typed. */
9
+ export interface Attribution {
10
+ ref: FindingRef;
11
+ label: CorrectionLabel;
12
+ /** The human's own words, minus the reference and the label. */
13
+ reason?: string;
14
+ /** `path` or `path:line` tokens in the words. Checked by the caller. */
15
+ citations: string[];
16
+ }
17
+ /**
18
+ * A message answering a review.
19
+ *
20
+ * `weigh answer "#3 is intentional, we validate at the edge"` — and `#3` only
21
+ * means something beside the review that printed it, which is why the number is
22
+ * carried as a reference to be resolved rather than as an index into anything
23
+ * this class can see.
24
+ *
25
+ * Pure text in, structure out. No filesystem, no store, no review: the same
26
+ * parse has to serve a PR comment when that arrives, and the thing that
27
+ * differs between the two is where the review comes from, not the grammar.
28
+ */
29
+ export declare class FollowUp {
30
+ readonly attributions: readonly Attribution[];
31
+ private constructor();
32
+ /**
33
+ * Reads a message, or says why it cannot be read.
34
+ *
35
+ * All or nothing. A message that rules on three findings and misspells one
36
+ * label records none of them, because a partial record of what someone said
37
+ * is worse than no record: they would have to read the ledger to find out
38
+ * which half landed.
39
+ */
40
+ static parse(text: string): FollowUp;
41
+ /** What a message looks like, for a refusal that has to teach the grammar. */
42
+ static example(): string;
43
+ /** The vocabulary, one label per line, for the same refusals. */
44
+ static vocabulary(): string[];
45
+ get isEmpty(): boolean;
46
+ private static _attribute;
47
+ /**
48
+ * Every place the words name a label, in the order they appear.
49
+ *
50
+ * All of them, not one per phrase: a label said twice has to be seen twice,
51
+ * or the copy that was missed stays in the reason while the one that was
52
+ * found is cut out of the middle of a sentence.
53
+ */
54
+ private static _labels;
55
+ /** What is left after the reference and the label come out. */
56
+ private static _reason;
57
+ /**
58
+ * Paths in the words.
59
+ *
60
+ * A token counts when it looks like a path — it has a directory separator,
61
+ * or a `:line` after it. Loose on purpose: the caller checks every one
62
+ * against the tree and drops a word that only looked like a path (or refuses
63
+ * it, where the label needs a citation), while a strict pattern
64
+ * would quietly drop the citation a `incorrect` ruling needs to be recorded
65
+ * at all.
66
+ */
67
+ private static _citations;
68
+ }
69
+ //# sourceMappingURL=follow-up.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow-up.d.ts","sourceRoot":"","sources":["../../src/corrections/follow-up.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnF,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE,mCAAmC;AACnC,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,eAAe,CAAC;IACvB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AA2ED;;;;;;;;;;;GAWG;AACH,qBAAa,QAAQ;IACC,QAAQ,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE;IAAjE,OAAO,eAA8D;IAErE;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAyBnC;IAED,8EAA8E;IAC9E,MAAM,CAAC,OAAO,IAAI,MAAM,CAEvB;IAED,iEAAiE;IACjE,MAAM,CAAC,UAAU,IAAI,MAAM,EAAE,CAE5B;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,OAAO,CAAC,MAAM,CAAC,UAAU;IAoCzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,OAAO;IAkBtB,+DAA+D;IAC/D,OAAO,CAAC,MAAM,CAAC,OAAO;IAYtB;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;CAS1B"}
@@ -0,0 +1,217 @@
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 { CORRECTION_LABELS, LABEL_RULES } from './schema.js';
5
+ /**
6
+ * The ways people say each of the five things.
7
+ *
8
+ * Deliberately a list of phrases rather than a model call. The grammar has to
9
+ * read the same in a terminal and in a PR comment — one mental model, says the
10
+ * design — and a classifier that is right most of the time is the wrong shape
11
+ * for an input whose job is to silence findings. What it cannot parse it
12
+ * refuses, which is a failure anyone can see and retype.
13
+ *
14
+ * Longest first, because `correct` sits inside `not correct` and the shorter
15
+ * phrase would otherwise claim the match and invert the meaning.
16
+ */
17
+ const PHRASES = [
18
+ ['incorrect', 'incorrect'],
19
+ ['not correct', 'incorrect'],
20
+ ['misread', 'incorrect'],
21
+ ['misreading', 'incorrect'],
22
+ ['false positive', 'incorrect'],
23
+ ['not true', 'incorrect'],
24
+ ['mistaken', 'incorrect'],
25
+ ['wrong', 'incorrect'],
26
+ ['intentional', 'intentional'],
27
+ ['intended', 'intentional'],
28
+ ['deliberate', 'intentional'],
29
+ ['by design', 'intentional'],
30
+ ['on purpose', 'intentional'],
31
+ ['house style', 'intentional'],
32
+ ['how we do it', 'intentional'],
33
+ ["won't fix", 'wont-fix'],
34
+ ['wont fix', 'wont-fix'],
35
+ ['wont-fix', 'wont-fix'],
36
+ ["won't-fix", 'wont-fix'],
37
+ ['not fixing', 'wont-fix'],
38
+ ['deprioritised', 'wont-fix'],
39
+ ['deprioritized', 'wont-fix'],
40
+ ['out of scope', 'out-of-scope'],
41
+ ['out-of-scope', 'out-of-scope'],
42
+ ['not this change', 'out-of-scope'],
43
+ ['not in this change', 'out-of-scope'],
44
+ ['another change', 'out-of-scope'],
45
+ ['confirmed', 'confirmed'],
46
+ ['correct', 'confirmed'],
47
+ ['agreed', 'confirmed'],
48
+ ['agree', 'confirmed'],
49
+ ['good catch', 'confirmed'],
50
+ ['valid', 'confirmed'],
51
+ ['will fix', 'confirmed'],
52
+ ].sort((a, b) => b[0].length - a[0].length);
53
+ /**
54
+ * The same phrases as whole words.
55
+ *
56
+ * Whole words because a substring search reads `valid` out of "we validate at
57
+ * the edge" and `intended` out of "unintended", which is a reason being read
58
+ * as a second label — or as the opposite one.
59
+ */
60
+ const MATCHERS = PHRASES.map(([phrase, label]) => ({
61
+ rx: new RegExp(`\\b${phrase.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`, 'gi'),
62
+ label,
63
+ }));
64
+ /** `#3`, or a fingerprint typed out in full. */
65
+ const MARKER = /#(\d+)\b|\b([0-9a-f]{16})\b/g;
66
+ /** Connectives between a reference and the words that follow it. */
67
+ const FILLER = /^(?:is|are|was|were|it|this|that|that's|it's|looks|seems|but|and|so|because|since|as)\b/i;
68
+ /**
69
+ * A message answering a review.
70
+ *
71
+ * `weigh answer "#3 is intentional, we validate at the edge"` — and `#3` only
72
+ * means something beside the review that printed it, which is why the number is
73
+ * carried as a reference to be resolved rather than as an index into anything
74
+ * this class can see.
75
+ *
76
+ * Pure text in, structure out. No filesystem, no store, no review: the same
77
+ * parse has to serve a PR comment when that arrives, and the thing that
78
+ * differs between the two is where the review comes from, not the grammar.
79
+ */
80
+ export class FollowUp {
81
+ attributions;
82
+ constructor(attributions) {
83
+ this.attributions = attributions;
84
+ }
85
+ /**
86
+ * Reads a message, or says why it cannot be read.
87
+ *
88
+ * All or nothing. A message that rules on three findings and misspells one
89
+ * label records none of them, because a partial record of what someone said
90
+ * is worse than no record: they would have to read the ledger to find out
91
+ * which half landed.
92
+ */
93
+ static parse(text) {
94
+ const message = text.trim();
95
+ if (!message)
96
+ throw new Error('Nothing to record. Say which finding, and what about it.');
97
+ const markers = [...message.matchAll(MARKER)];
98
+ if (markers.length === 0) {
99
+ throw new Error(`Say which finding: ${FollowUp.example()}. Numbers are the ones the review printed.`);
100
+ }
101
+ const attributions = markers.map((marker, i) => {
102
+ const ref = marker[1] ? { number: Number(marker[1]) } : { fingerprint: marker[2] };
103
+ // One reference means the whole message is about it, whatever order the
104
+ // words came in — "intentional, #3" is as clear as "#3 is intentional".
105
+ // Several, and each one owns the words up to the next reference.
106
+ const start = marker.index + marker[0].length;
107
+ const words = markers.length === 1
108
+ ? message.replace(marker[0], ' ')
109
+ : message.slice(start, markers[i + 1]?.index ?? message.length);
110
+ return FollowUp._attribute(ref, words);
111
+ });
112
+ return new FollowUp(attributions);
113
+ }
114
+ /** What a message looks like, for a refusal that has to teach the grammar. */
115
+ static example() {
116
+ return '#3 is intentional';
117
+ }
118
+ /** The vocabulary, one label per line, for the same refusals. */
119
+ static vocabulary() {
120
+ return CORRECTION_LABELS.map((label) => `${label.padEnd(13)} ${LABEL_RULES[label].means}`);
121
+ }
122
+ get isEmpty() {
123
+ return this.attributions.length === 0;
124
+ }
125
+ static _attribute(ref, words) {
126
+ const found = FollowUp._labels(words);
127
+ const where = 'number' in ref ? `#${ref.number}` : ref.fingerprint;
128
+ if (found.length === 0) {
129
+ throw new Error(`I cannot tell what you are saying about ${where}. One of:\n${FollowUp.vocabulary()
130
+ .map((line) => ` ${line}`)
131
+ .join('\n')}`);
132
+ }
133
+ // Two labels about one finding is not a ruling, it is two. Asked rather
134
+ // than guessed: whichever one this picked would silence or fail to silence
135
+ // a finding on a coin toss.
136
+ const labels = [...new Set(found.map(([, label]) => label))];
137
+ if (labels.length > 1) {
138
+ throw new Error(`${where} is ${labels.join(' and ')} — say one thing about it, in one message.`);
139
+ }
140
+ // One label, maybe said more than once: "wont-fix, real bug but we won't
141
+ // fix it here". Only one of those is the ruling; the other is the person's
142
+ // own sentence, and cutting it out too leaves "but we it here" as the
143
+ // reason — which a promotion would then teach. So one span comes out: the
144
+ // label's own name when it was written, since that is how a ruling is
145
+ // spelled on purpose, and otherwise the first.
146
+ const label = labels[0];
147
+ const [span] = found.find(([at]) => words.slice(at[0], at[1]).toLowerCase() === label) ?? found[0];
148
+ const reason = FollowUp._reason(words.slice(0, span[0]) + ' ' + words.slice(span[1]));
149
+ return {
150
+ ref,
151
+ label,
152
+ ...(reason && { reason }),
153
+ citations: FollowUp._citations(words),
154
+ };
155
+ }
156
+ /**
157
+ * Every place the words name a label, in the order they appear.
158
+ *
159
+ * All of them, not one per phrase: a label said twice has to be seen twice,
160
+ * or the copy that was missed stays in the reason while the one that was
161
+ * found is cut out of the middle of a sentence.
162
+ */
163
+ static _labels(words) {
164
+ const hits = [];
165
+ for (const { rx, label } of MATCHERS) {
166
+ for (const hit of words.matchAll(rx))
167
+ hits.push([[hit.index, hit.index + hit[0].length], label]);
168
+ }
169
+ // Longest first where two start together, then left to right. A shorter
170
+ // phrase inside one already taken is the same words being read twice —
171
+ // `correct` inside `not correct`, `agree` inside `agreed`.
172
+ hits.sort(([a], [b]) => a[0] - b[0] || b[1] - a[1]);
173
+ const found = [];
174
+ for (const hit of hits) {
175
+ const [span] = hit;
176
+ if (found.some(([other]) => span[0] < other[1] && other[0] < span[1]))
177
+ continue;
178
+ found.push(hit);
179
+ }
180
+ return found;
181
+ }
182
+ /** What is left after the reference and the label come out. */
183
+ static _reason(rest) {
184
+ let reason = rest.trim();
185
+ // Loop, because "— it is because" is three of these in a row.
186
+ for (;;) {
187
+ const trimmed = reason.replace(/^[\s,:;.\-–—]+/, '').replace(FILLER, '');
188
+ if (trimmed === reason)
189
+ break;
190
+ reason = trimmed;
191
+ }
192
+ reason = reason.replace(/[\s,:;.\-–—]+$/, '').replace(/\s+/g, ' ').trim();
193
+ return reason || undefined;
194
+ }
195
+ /**
196
+ * Paths in the words.
197
+ *
198
+ * A token counts when it looks like a path — it has a directory separator,
199
+ * or a `:line` after it. Loose on purpose: the caller checks every one
200
+ * against the tree and drops a word that only looked like a path (or refuses
201
+ * it, where the label needs a citation), while a strict pattern
202
+ * would quietly drop the citation a `incorrect` ruling needs to be recorded
203
+ * at all.
204
+ */
205
+ static _citations(words) {
206
+ const found = [];
207
+ for (const raw of words.match(/[^\s,;()[\]"'`]+/g) ?? []) {
208
+ const token = raw.replace(/[.,;:]+$/, '');
209
+ if (!/\//.test(token) && !/^[\w.\-]+:\d+(?:-\d+)?$/.test(token))
210
+ continue;
211
+ if (!found.includes(token))
212
+ found.push(token);
213
+ }
214
+ return found;
215
+ }
216
+ }
217
+ //# sourceMappingURL=follow-up.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow-up.js","sourceRoot":"","sources":["../../src/corrections/follow-up.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAwB,MAAM,aAAa,CAAC;AAenF;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,GACX;IACE,CAAC,WAAW,EAAE,WAAW,CAAC;IAC1B,CAAC,aAAa,EAAE,WAAW,CAAC;IAC5B,CAAC,SAAS,EAAE,WAAW,CAAC;IACxB,CAAC,YAAY,EAAE,WAAW,CAAC;IAC3B,CAAC,gBAAgB,EAAE,WAAW,CAAC;IAC/B,CAAC,UAAU,EAAE,WAAW,CAAC;IACzB,CAAC,UAAU,EAAE,WAAW,CAAC;IACzB,CAAC,OAAO,EAAE,WAAW,CAAC;IAEtB,CAAC,aAAa,EAAE,aAAa,CAAC;IAC9B,CAAC,UAAU,EAAE,aAAa,CAAC;IAC3B,CAAC,YAAY,EAAE,aAAa,CAAC;IAC7B,CAAC,WAAW,EAAE,aAAa,CAAC;IAC5B,CAAC,YAAY,EAAE,aAAa,CAAC;IAC7B,CAAC,aAAa,EAA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