@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,35 @@
1
+ import type { Claim } from './claim.js';
2
+ /** Why a claim is in front of the reviewer. Printed beside it. */
3
+ export type Mechanism = 'always' | 'path' | 'proximity' | 'listed';
4
+ /**
5
+ * One claim on its way into a review, and how it got there.
6
+ *
7
+ * The mechanism is kept because it is the difference between a guarantee and a
8
+ * guess: a claim that is in because its glob names the file under review is
9
+ * worth more than one that scored well against a hunk, and a reader calibrating
10
+ * the retrieval has no way to tell those apart afterwards otherwise.
11
+ */
12
+ export declare class RecalledClaim {
13
+ readonly claim: Claim;
14
+ readonly mechanism: Mechanism;
15
+ /** The changed file that pulled it in, for `path` and `proximity`. */
16
+ readonly because: string | undefined;
17
+ constructor(claim: Claim, mechanism: Mechanism,
18
+ /** The changed file that pulled it in, for `path` and `proximity`. */
19
+ because?: string | undefined);
20
+ /** The key a block dedupes on: four mechanisms can find the same claim. */
21
+ get key(): string;
22
+ /** The claim as the model reads it: the sentence, then why it is here. */
23
+ describe(): string[];
24
+ /**
25
+ * Why this claim is here, in words.
26
+ *
27
+ * Empty for a claim that was listed rather than found: its block says where
28
+ * it came from, and "it was in the list" is not a reason worth a line.
29
+ */
30
+ why(): string;
31
+ toJSON(): Record<string, unknown>;
32
+ /** One line for the calibration view, where the score is the point. */
33
+ explain(): string;
34
+ }
35
+ //# sourceMappingURL=recalled-claim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recalled-claim.d.ts","sourceRoot":"","sources":["../../src/knowledge/recalled-claim.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,kEAAkE;AAClE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEnE;;;;;;;GAOG;AACH,qBAAa,aAAa;IAEtB,QAAQ,CAAC,KAAK,EAAE,KAAK;IACrB,QAAQ,CAAC,SAAS,EAAE,SAAS;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAJtC,YACW,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS;IAC7B,sEAAsE;IAC7D,OAAO,GAAE,MAAM,GAAG,SAAqB,EAC9C;IAEJ,2EAA2E;IAC3E,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,0EAA0E;IAC1E,QAAQ,IAAI,MAAM,EAAE,CAMnB;IAED;;;;;OAKG;IACH,GAAG,IAAI,MAAM,CAWZ;IAED,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMhC;IAED,uEAAuE;IACvE,OAAO,IAAI,MAAM,CAIhB;CACF"}
@@ -0,0 +1,67 @@
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
+ * One claim on its way into a review, and how it got there.
6
+ *
7
+ * The mechanism is kept because it is the difference between a guarantee and a
8
+ * guess: a claim that is in because its glob names the file under review is
9
+ * worth more than one that scored well against a hunk, and a reader calibrating
10
+ * the retrieval has no way to tell those apart afterwards otherwise.
11
+ */
12
+ export class RecalledClaim {
13
+ claim;
14
+ mechanism;
15
+ because;
16
+ constructor(claim, mechanism,
17
+ /** The changed file that pulled it in, for `path` and `proximity`. */
18
+ because = undefined) {
19
+ this.claim = claim;
20
+ this.mechanism = mechanism;
21
+ this.because = because;
22
+ }
23
+ /** The key a block dedupes on: four mechanisms can find the same claim. */
24
+ get key() {
25
+ return this.claim.id ?? this.claim.statement;
26
+ }
27
+ /** The claim as the model reads it: the sentence, then why it is here. */
28
+ describe() {
29
+ const meta = [this.why(), `confidence ${this.claim.confidence.toFixed(2)}`].filter(Boolean).join(' · ');
30
+ return [
31
+ `- ${this.claim.kind}: ${this.claim.statement}`,
32
+ ` ${meta} · checkable at ${this.claim.evidence.join(', ')}`,
33
+ ];
34
+ }
35
+ /**
36
+ * Why this claim is here, in words.
37
+ *
38
+ * Empty for a claim that was listed rather than found: its block says where
39
+ * it came from, and "it was in the list" is not a reason worth a line.
40
+ */
41
+ why() {
42
+ switch (this.mechanism) {
43
+ case 'always':
44
+ return 'holds everywhere in this repository';
45
+ case 'path':
46
+ return `governs ${this.because ?? 'files in this change'}`;
47
+ case 'proximity':
48
+ return `related to ${this.because ?? 'this change'}`;
49
+ case 'listed':
50
+ return '';
51
+ }
52
+ }
53
+ toJSON() {
54
+ return {
55
+ ...this.claim.toJSON(),
56
+ mechanism: this.mechanism,
57
+ ...(this.because && { because: this.because }),
58
+ };
59
+ }
60
+ /** One line for the calibration view, where the score is the point. */
61
+ explain() {
62
+ const score = this.claim.score !== undefined ? ` · score ${this.claim.score.toFixed(3)}` : '';
63
+ const why = this.why();
64
+ return ` [${this.mechanism}]${score}${why ? ` · ${why}` : ''}`;
65
+ }
66
+ }
67
+ //# sourceMappingURL=recalled-claim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recalled-claim.js","sourceRoot":"","sources":["../../src/knowledge/recalled-claim.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAO5D;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IAEb,KAAK;IACL,SAAS;IAET,OAAO;IAJlB,YACW,KAAY,EACZ,SAAoB;IAC7B,sEAAsE;IAC7D,OAAO,GAAuB,SAAS;qBAHvC,KAAK;yBACL,SAAS;uBAET,OAAO;IACf,CAAC;IAEJ,2EAA2E;IAC3E,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;IAC/C,CAAC;IAED,0EAA0E;IAC1E,QAAQ;QACN,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,cAAc,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,C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E,CAAC;CACF"}
@@ -0,0 +1,70 @@
1
+ import type { KnowledgeBlock } from './block.js';
2
+ /**
3
+ * What reaches one review, in the blocks it is read in.
4
+ *
5
+ * The point of this is a finding that is never born. A convention has to be in
6
+ * the context before the model forms a view of the change, or the finding is
7
+ * produced every run and killed at refute — which costs a call, reads as noise,
8
+ * and teaches nobody anything. So what Weigh knows about the repository goes
9
+ * in with the diff.
10
+ *
11
+ * The blocks arrive already filled; this owns the budget over them. What does
12
+ * not fit is named in its block rather than dropped quietly, which is the rule
13
+ * the coverage ledger already follows: a review that was shown eleven of
14
+ * nineteen claims should say so, because the eight it did not see are exactly
15
+ * the ones that would explain a finding it got wrong.
16
+ */
17
+ export declare class Recalled {
18
+ private readonly _blocks;
19
+ constructor(_blocks: readonly KnowledgeBlock[],
20
+ /** Characters of claims to inline. The block's own budget, like the diff's. */
21
+ budget: number);
22
+ /** The blocks in reading order, those with something in them. */
23
+ get blocks(): readonly KnowledgeBlock[];
24
+ /** Claims found, whether or not they fit. */
25
+ get size(): number;
26
+ get isEmpty(): boolean;
27
+ /** How many were found and left out of the prompt. */
28
+ get dropped(): number;
29
+ /** One line for the progress reporter, before the review starts. */
30
+ describe(): string;
31
+ /**
32
+ * Spends the budget in priority order, not in reading order.
33
+ *
34
+ * The thread on this change is filled first and is never capped: a
35
+ * correction that fell off the end of a budget would be a defect silenced by
36
+ * accident, which is worse than a review that runs with no memory at all.
37
+ * Everything else takes what is left, in the order the blocks declare.
38
+ */
39
+ private _fit;
40
+ /**
41
+ * The part of the reviewer's instructions that only applies when something
42
+ * was recalled.
43
+ *
44
+ * Four sentences do the work. The first is why the claims are there at all:
45
+ * a change that follows a convention this repository holds is not a finding.
46
+ * The second is the one promotion rests on, and it was added after watching a
47
+ * review read a promoted claim and report the finding anyway, in a weaker
48
+ * form — it had been told that the precondition holds elsewhere, and reported
49
+ * the code for not checking it again. A claim that answers a finding has to
50
+ * answer the class of it, or promotion buys a reworded finding rather than no
51
+ * finding. The third is the escape hatch, because knowledge goes stale
52
+ * silently and a reviewer that trusts a stale claim over the code in front of
53
+ * it produces the most confusing kind of false positive. The fourth keeps the
54
+ * citation rule intact: a claim is context, never the evidence a finding rests
55
+ * on.
56
+ */
57
+ instructions(): string;
58
+ /** The blocks as the model receives them, above the change. */
59
+ render(): string;
60
+ toJSON(): Record<string, unknown>;
61
+ /**
62
+ * The same claims with their scores, for calibrating the retrieval.
63
+ *
64
+ * The caps and the threshold are numbers nobody can pick honestly from a
65
+ * design document, so this prints what came back and why: twenty real claims
66
+ * about a repository you know, run against a branch you know, and read it.
67
+ */
68
+ explain(): string;
69
+ }
70
+ //# sourceMappingURL=recalled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recalled.d.ts","sourceRoot":"","sources":["../../src/knowledge/recalled.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,QAAQ;IAEjB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAD1B,YACmB,OAAO,EAAE,SAAS,cAAc,EAAE;IACnD,+EAA+E;IAC/E,MAAM,EAAE,MAAM,EAGf;IAED,iEAAiE;IACjE,IAAI,MAAM,IAAI,SAAS,cAAc,EAAE,CAEtC;IAED,6CAA6C;IAC7C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,sDAAsD;IACtD,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,oEAAoE;IACpE,QAAQ,IAAI,MAAM,CAIjB;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI;IAcZ;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,IAAI,MAAM,CAgBrB;IAED,+DAA+D;IAC/D,MAAM,IAAI,MAAM,CAgBf;IAED,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOhC;IAED;;;;;;OAMG;IACH,OAAO,IAAI,MAAM,CAWhB;CACF"}
@@ -0,0 +1,149 @@
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 reaches one review, in the blocks it is read in.
6
+ *
7
+ * The point of this is a finding that is never born. A convention has to be in
8
+ * the context before the model forms a view of the change, or the finding is
9
+ * produced every run and killed at refute — which costs a call, reads as noise,
10
+ * and teaches nobody anything. So what Weigh knows about the repository goes
11
+ * in with the diff.
12
+ *
13
+ * The blocks arrive already filled; this owns the budget over them. What does
14
+ * not fit is named in its block rather than dropped quietly, which is the rule
15
+ * the coverage ledger already follows: a review that was shown eleven of
16
+ * nineteen claims should say so, because the eight it did not see are exactly
17
+ * the ones that would explain a finding it got wrong.
18
+ */
19
+ export class Recalled {
20
+ _blocks;
21
+ constructor(_blocks,
22
+ /** Characters of claims to inline. The block's own budget, like the diff's. */
23
+ budget) {
24
+ this._blocks = _blocks;
25
+ this._fit(budget);
26
+ }
27
+ /** The blocks in reading order, those with something in them. */
28
+ get blocks() {
29
+ return this._blocks.filter((block) => !block.isEmpty);
30
+ }
31
+ /** Claims found, whether or not they fit. */
32
+ get size() {
33
+ return this._blocks.reduce((n, block) => n + block.size, 0);
34
+ }
35
+ get isEmpty() {
36
+ return this.size === 0;
37
+ }
38
+ /** How many were found and left out of the prompt. */
39
+ get dropped() {
40
+ return this._blocks.reduce((n, block) => n + block.dropped, 0);
41
+ }
42
+ /** One line for the progress reporter, before the review starts. */
43
+ describe() {
44
+ const parts = this.blocks.map((block) => `${block.label} ${block.size}`);
45
+ const dropped = this.dropped ? ` · ${this.dropped} over budget` : '';
46
+ return `${this.size} claim${this.size === 1 ? '' : 's'} recalled — ${parts.join(', ')}${dropped}`;
47
+ }
48
+ /**
49
+ * Spends the budget in priority order, not in reading order.
50
+ *
51
+ * The thread on this change is filled first and is never capped: a
52
+ * correction that fell off the end of a budget would be a defect silenced by
53
+ * accident, which is worse than a review that runs with no memory at all.
54
+ * Everything else takes what is left, in the order the blocks declare.
55
+ */
56
+ _fit(budget) {
57
+ let left = budget;
58
+ for (const block of [...this._blocks].sort((a, b) => a.priority - b.priority)) {
59
+ let kept = 0;
60
+ for (const entry of block.found) {
61
+ const cost = entry.describe().join('\n').length + 1;
62
+ if (cost > left)
63
+ break;
64
+ left -= cost;
65
+ kept++;
66
+ }
67
+ block.keep(kept);
68
+ }
69
+ }
70
+ /**
71
+ * The part of the reviewer's instructions that only applies when something
72
+ * was recalled.
73
+ *
74
+ * Four sentences do the work. The first is why the claims are there at all:
75
+ * a change that follows a convention this repository holds is not a finding.
76
+ * The second is the one promotion rests on, and it was added after watching a
77
+ * review read a promoted claim and report the finding anyway, in a weaker
78
+ * form — it had been told that the precondition holds elsewhere, and reported
79
+ * the code for not checking it again. A claim that answers a finding has to
80
+ * answer the class of it, or promotion buys a reworded finding rather than no
81
+ * finding. The third is the escape hatch, because knowledge goes stale
82
+ * silently and a reviewer that trusts a stale claim over the code in front of
83
+ * it produces the most confusing kind of false positive. The fourth keeps the
84
+ * citation rule intact: a claim is context, never the evidence a finding rests
85
+ * on.
86
+ */
87
+ instructions() {
88
+ return [
89
+ '',
90
+ 'Before the change you will find what Weigh already knows about this repository, in',
91
+ 'labelled blocks, each claim with where it can be checked.',
92
+ '',
93
+ '- Judge the change against them. Code that follows a convention recorded there is not a',
94
+ ' finding, and reporting it as one is the failure these blocks exist to prevent.',
95
+ '- A claim that records a guarantee is an answer about that guarantee. Code which relies on',
96
+ ' one is not a finding for relying on it, and neither is code that does not check it again.',
97
+ ' If you think the guarantee is thinner than the claim says, say that in your summary.',
98
+ '- They are dated, and they can be wrong. If the code says otherwise, the code is right:',
99
+ ' note in your summary that the claim looks out of date, and do not report the change as',
100
+ ' a defect for disagreeing with it.',
101
+ '- Never cite a claim as the evidence for a finding. Evidence is code you read.',
102
+ ].join('\n');
103
+ }
104
+ /** The blocks as the model receives them, above the change. */
105
+ render() {
106
+ const blocks = this.blocks.filter((block) => block.kept.length > 0 || block.dropped > 0);
107
+ if (blocks.length === 0)
108
+ return '';
109
+ const out = ['# What Weigh knows'];
110
+ for (const block of blocks) {
111
+ out.push('', `## ${block.label}`, block.note, '');
112
+ for (const entry of block.kept)
113
+ out.push(...entry.describe());
114
+ if (block.dropped > 0) {
115
+ out.push('', `${block.dropped} further claim${block.dropped === 1 ? '' : 's'} in this block did not fit the context.`);
116
+ }
117
+ }
118
+ return out.join('\n');
119
+ }
120
+ toJSON() {
121
+ return {
122
+ claims: this.size,
123
+ dropped: this.dropped,
124
+ blocks: this.blocks.map((block) => block.toJSON()),
125
+ rendered: this.render(),
126
+ };
127
+ }
128
+ /**
129
+ * The same claims with their scores, for calibrating the retrieval.
130
+ *
131
+ * The caps and the threshold are numbers nobody can pick honestly from a
132
+ * design document, so this prints what came back and why: twenty real claims
133
+ * about a repository you know, run against a branch you know, and read it.
134
+ */
135
+ explain() {
136
+ if (this.isEmpty)
137
+ return 'Nothing recalled for this change.';
138
+ const out = [];
139
+ for (const block of this.blocks) {
140
+ out.push(`${block.label} — ${block.size} claim(s), ${block.dropped} over budget`);
141
+ for (const entry of block.found) {
142
+ out.push(` ${entry.claim.kind}: ${entry.claim.statement}`, entry.explain());
143
+ }
144
+ out.push('');
145
+ }
146
+ return out.join('\n').trimEnd();
147
+ }
148
+ }
149
+ //# sourceMappingURL=recalled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recalled.js","sourceRoot":"","sources":["../../src/knowledge/recalled.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAI5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,QAAQ;IAEA,OAAO;IAD1B,YACmB,OAAkC;IACnD,+EAA+E;IAC/E,MAAc;uBAFG,OAAO;QAIxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;IAED,iEAAiE;IACjE,IAAI,MAAM;QACR,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E,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/E,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,CAAC;QACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;CACF"}
@@ -0,0 +1,83 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The contract between everything that writes repository knowledge.
4
+ *
5
+ * Three actors produce it — a priming agent that explores a repository before
6
+ * any review, retrieval during a review, and Weigh writing back what it
7
+ * learned — so the shape is the thing that has to be specified. Two writers
8
+ * diverge the first time either side changes a field, which is also why none of
9
+ * them talks to the store directly: they all go through `weigh context`.
10
+ */
11
+ /** What kind of claim this is. */
12
+ export declare const KINDS: readonly ['architecture', 'convention', 'invariant', 'hotspot', 'glossary'];
13
+ export type Kind = (typeof KINDS)[number];
14
+ /**
15
+ * Who produced a claim.
16
+ *
17
+ * `correction` is a human ruling that taught something — the only source whose
18
+ * sentence a person wrote themselves. Added to the values this field may hold
19
+ * rather than over a version, because the metadata has no version and a claim
20
+ * written before a value existed still parses. It is worth telling apart from
21
+ * the other two: a claim Weigh inferred can be re-derived, and one a human
22
+ * typed cannot.
23
+ */
24
+ export declare const SOURCES: readonly ['priming', 'review', 'correction'];
25
+ export type ClaimSource = (typeof SOURCES)[number];
26
+ /**
27
+ * What a writer supplies.
28
+ *
29
+ * Evidence is required, and that is the whole design holding itself honest:
30
+ * context goes stale silently, and an agent confidently describing an
31
+ * architecture that was refactored away is worse than one with no context at
32
+ * all. A claim that cites nothing cannot be checked, so it is not accepted.
33
+ */
34
+ export declare const claimInputSchema: z.ZodObject<{
35
+ kind: z.ZodEnum<{
36
+ architecture: "architecture";
37
+ convention: "convention";
38
+ glossary: "glossary";
39
+ hotspot: "hotspot";
40
+ invariant: "invariant";
41
+ }>;
42
+ statement: z.ZodString;
43
+ evidence: z.ZodArray<z.ZodString>;
44
+ applies: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
+ confidence: z.ZodOptional<z.ZodNumber>;
46
+ provenance: z.ZodOptional<z.ZodObject<{
47
+ source: z.ZodOptional<z.ZodEnum<{
48
+ correction: "correction";
49
+ priming: "priming";
50
+ review: "review";
51
+ }>>;
52
+ commit: z.ZodOptional<z.ZodString>;
53
+ at: z.ZodOptional<z.ZodString>;
54
+ }, z.core.$strip>>;
55
+ }, z.core.$strip>;
56
+ export declare const claimMetadataSchema: z.ZodPreprocess<z.ZodObject<{
57
+ weigh: z.ZodLiteral<"claim">;
58
+ kind: z.ZodEnum<{
59
+ architecture: "architecture";
60
+ convention: "convention";
61
+ glossary: "glossary";
62
+ hotspot: "hotspot";
63
+ invariant: "invariant";
64
+ }>;
65
+ statement: z.ZodOptional<z.ZodString>;
66
+ evidence: z.ZodArray<z.ZodString>;
67
+ applies: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
+ confidence: z.ZodNumber;
69
+ source: z.ZodEnum<{
70
+ correction: "correction";
71
+ priming: "priming";
72
+ review: "review";
73
+ }>;
74
+ commit: z.ZodOptional<z.ZodString>;
75
+ at: z.ZodString;
76
+ verified: z.ZodOptional<z.ZodObject<{
77
+ commit: z.ZodString;
78
+ at: z.ZodString;
79
+ }, z.core.$strip>>;
80
+ }, z.core.$strip>, unknown>;
81
+ export type ClaimInput = z.infer<typeof claimInputSchema>;
82
+ export type ClaimMetadata = z.infer<typeof claimMetadataSchema>;
83
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/knowledge/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AAEH,kCAAkC;AAClC,eAAO,MAAM,KAAK,YAAI,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AACjG,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1C;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,YAAI,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAU,CAAC;AACpE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;iBAmB3B,CAAC;AA0CH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;2BAAsD,CAAC;AAEvF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,96 @@
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 { z } from 'zod';
5
+ /**
6
+ * The contract between everything that writes repository knowledge.
7
+ *
8
+ * Three actors produce it — a priming agent that explores a repository before
9
+ * any review, retrieval during a review, and Weigh writing back what it
10
+ * learned — so the shape is the thing that has to be specified. Two writers
11
+ * diverge the first time either side changes a field, which is also why none of
12
+ * them talks to the store directly: they all go through `weigh context`.
13
+ */
14
+ /** What kind of claim this is. */
15
+ export const KINDS = ['architecture', 'convention', 'invariant', 'hotspot', 'glossary'];
16
+ /**
17
+ * Who produced a claim.
18
+ *
19
+ * `correction` is a human ruling that taught something — the only source whose
20
+ * sentence a person wrote themselves. Added to the values this field may hold
21
+ * rather than over a version, because the metadata has no version and a claim
22
+ * written before a value existed still parses. It is worth telling apart from
23
+ * the other two: a claim Weigh inferred can be re-derived, and one a human
24
+ * typed cannot.
25
+ */
26
+ export const SOURCES = ['priming', 'review', 'correction'];
27
+ /**
28
+ * What a writer supplies.
29
+ *
30
+ * Evidence is required, and that is the whole design holding itself honest:
31
+ * context goes stale silently, and an agent confidently describing an
32
+ * architecture that was refactored away is worse than one with no context at
33
+ * all. A claim that cites nothing cannot be checked, so it is not accepted.
34
+ */
35
+ export const claimInputSchema = z.object({
36
+ kind: z.enum(KINDS),
37
+ statement: z.string().min(1).describe('One sentence, true of the repository rather than of a change'),
38
+ evidence: z
39
+ .array(z.string().min(1))
40
+ .min(1)
41
+ .describe('Where it can be checked: `path`, or `path:12-40` for a range'),
42
+ applies: z
43
+ .array(z.string().min(1))
44
+ .optional()
45
+ .describe('Globs this claim governs, or ["*"] for a rule that holds everywhere in the repository'),
46
+ confidence: z.number().min(0).max(1).optional(),
47
+ provenance: z
48
+ .object({
49
+ source: z.enum(SOURCES).optional(),
50
+ commit: z.string().optional(),
51
+ at: z.string().optional(),
52
+ })
53
+ .optional(),
54
+ });
55
+ /**
56
+ * Before the rename to Weigh, claims were marked `nimbus: 'claim'`. Stores
57
+ * written then still hold them, so they are read back as if marked `weigh`;
58
+ * the next update writes the new marker.
59
+ */
60
+ function fromNimbusMarker(metadata) {
61
+ if (typeof metadata !== 'object' || metadata === null)
62
+ return metadata;
63
+ const { nimbus, ...rest } = metadata;
64
+ if (nimbus !== 'claim' || 'weigh' in rest)
65
+ return metadata;
66
+ return { ...rest, weigh: 'claim' };
67
+ }
68
+ /** What travels with a claim in the store, and is read back as the claim. */
69
+ const claimMetadataObject = z.object({
70
+ weigh: z.literal('claim'),
71
+ kind: z.enum(KINDS),
72
+ /**
73
+ * The sentence itself, kept here as well as in the memory text.
74
+ *
75
+ * The text is the embedding surface and carries the evidence paths with the
76
+ * statement, so it is no longer something a statement can be parsed back out
77
+ * of. Optional because records written before that change have none, and a
78
+ * claim that predates a field is not a claim to throw away.
79
+ */
80
+ statement: z.string().optional(),
81
+ evidence: z.array(z.string()),
82
+ /** Globs this claim governs. `*` means everywhere — see `Claim.isHouseRule`. */
83
+ applies: z.array(z.string()).optional(),
84
+ confidence: z.number().min(0).max(1),
85
+ source: z.enum(SOURCES),
86
+ commit: z.string().optional(),
87
+ at: z.string(),
88
+ /**
89
+ * The last time someone read the code again and found the claim still
90
+ * holds, and the commit they read. Kept apart from `commit` and `at`, which
91
+ * say when it was written: a refresh moves this and leaves those alone.
92
+ */
93
+ verified: z.object({ commit: z.string(), at: z.string() }).optional(),
94
+ });
95
+ export const claimMetadataSchema = z.preprocess(fromNimbusMarker, claimMetadataObject);
96
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/knowledge/schema.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AAEH,kCAAkC;AAClC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AAGjG;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAU,CAAC;AAGpE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,8DAA8D,CAAC;IACrG,QAAQ,EAAE,CAAC;SACR,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACxB,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,8DAA8D,CAAC;IAC3E,OAAO,EAAE,CAAC;SACP,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,C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AM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACvC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd;;;;OAIG;IACH,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;CACtE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,UAAU,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { Claim } from './claim.js';
2
+ /** Why a claim is worth reading again. */
3
+ export type StaleReason = 'changed' | 'unstamped' | 'unknown-commit';
4
+ /** One claim that may no longer hold, and why. */
5
+ export interface StaleClaim {
6
+ claim: Claim;
7
+ reason: StaleReason;
8
+ /** The cited files that changed since the claim was last known to hold. */
9
+ changed: string[];
10
+ }
11
+ /**
12
+ * Which claims cite code that changed since they were last known to hold.
13
+ *
14
+ * A refresh cannot re-read every claim once a repository holds hundreds, and
15
+ * most of them cite files nobody touched. This narrows it to the ones whose
16
+ * evidence moved, by asking git, so the model reads only those.
17
+ *
18
+ * One `git diff` per distinct commit rather than one per claim. A priming run
19
+ * stamps every claim it writes with the same commit, so a store of a thousand
20
+ * claims written in five runs costs five diffs.
21
+ *
22
+ * The diff is from that commit to HEAD, commit to commit, because a stamp
23
+ * can only name a commit: a claim confirmed over uncommitted edits would
24
+ * name code nobody read. `uncommitted()` is how `context confirm` refuses
25
+ * those. Renames are off, so a cited file that was moved away shows up under
26
+ * the name the claim cites rather than only under its new one.
27
+ *
28
+ * What this cannot see: a claim that went wrong while its own files stayed the
29
+ * same, such as a convention that new code elsewhere stopped following.
30
+ * Reviews catch those, when a finding contradicts the claim and someone rules
31
+ * on it.
32
+ */
33
+ export declare class Staleness {
34
+ private readonly _root;
35
+ /** Files changed since each commit; null for a commit git does not know. */
36
+ private readonly _changes;
37
+ constructor(_root: string);
38
+ /** The claims worth reading again, in the order given. */
39
+ check(claims: readonly Claim[]): StaleClaim[];
40
+ /** One line saying why, for the text listing. */
41
+ static describe(stale: StaleClaim): string;
42
+ /** Tracked files whose working copy differs from HEAD, staged or not. */
43
+ uncommitted(): ReadonlySet<string>;
44
+ private static readonly _NAMES;
45
+ private _changedSince;
46
+ private _git;
47
+ }
48
+ //# sourceMappingURL=staleness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staleness.d.ts","sourceRoot":"","sources":["../../src/knowledge/staleness.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,0CAA0C;AAC1C,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAErE,kDAAkD;AAClD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,SAAS;IAIR,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiD;IAE1E,YAA6B,KAAK,EAAE,MAAM,EAAI;IAE9C,0DAA0D;IAC1D,KAAK,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,UAAU,EAAE,CAiB5C;IAED,iDAAiD;IACjD,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CASzC;IAED,yEAAyE;IACzE,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,CAGjC;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAqE;IAEnG,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,IAAI;CAIb"}