@descryy/core 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (361) hide show
  1. package/dist/budget/reply.d.ts +11 -46
  2. package/dist/budget/reply.d.ts.map +1 -1
  3. package/dist/budget/reply.js +10 -39
  4. package/dist/budget/reply.js.map +1 -1
  5. package/dist/budget/size.d.ts +2 -21
  6. package/dist/budget/size.d.ts.map +1 -1
  7. package/dist/budget/size.js +3 -24
  8. package/dist/budget/size.js.map +1 -1
  9. package/dist/capabilities/preconditions.d.ts +7 -68
  10. package/dist/capabilities/preconditions.d.ts.map +1 -1
  11. package/dist/capabilities/preconditions.js +6 -57
  12. package/dist/capabilities/preconditions.js.map +1 -1
  13. package/dist/contracts/engine.d.ts +23 -11
  14. package/dist/contracts/engine.d.ts.map +1 -1
  15. package/dist/contracts/engine.js +23 -11
  16. package/dist/contracts/engine.js.map +1 -1
  17. package/dist/contracts/orphans.d.ts +18 -122
  18. package/dist/contracts/orphans.d.ts.map +1 -1
  19. package/dist/contracts/orphans.js +36 -134
  20. package/dist/contracts/orphans.js.map +1 -1
  21. package/dist/contracts/paths.d.ts +4 -114
  22. package/dist/contracts/paths.d.ts.map +1 -1
  23. package/dist/contracts/paths.js +7 -140
  24. package/dist/contracts/paths.js.map +1 -1
  25. package/dist/contracts/shapes.d.ts +13 -66
  26. package/dist/contracts/shapes.d.ts.map +1 -1
  27. package/dist/contracts/shapes.js +20 -91
  28. package/dist/contracts/shapes.js.map +1 -1
  29. package/dist/governance/budget.d.ts +12 -48
  30. package/dist/governance/budget.d.ts.map +1 -1
  31. package/dist/governance/budget.js +12 -48
  32. package/dist/governance/budget.js.map +1 -1
  33. package/dist/governance/candidate-boundary.d.ts +4 -32
  34. package/dist/governance/candidate-boundary.d.ts.map +1 -1
  35. package/dist/governance/candidate-boundary.js +4 -32
  36. package/dist/governance/candidate-boundary.js.map +1 -1
  37. package/dist/governance/escalation.d.ts +7 -45
  38. package/dist/governance/escalation.d.ts.map +1 -1
  39. package/dist/governance/escalation.js +7 -45
  40. package/dist/governance/escalation.js.map +1 -1
  41. package/dist/governance/fact-boundary.d.ts +7 -49
  42. package/dist/governance/fact-boundary.d.ts.map +1 -1
  43. package/dist/governance/fact-boundary.js +5 -43
  44. package/dist/governance/fact-boundary.js.map +1 -1
  45. package/dist/governance/finding-funnel.d.ts +11 -72
  46. package/dist/governance/finding-funnel.d.ts.map +1 -1
  47. package/dist/governance/finding-funnel.js +9 -68
  48. package/dist/governance/finding-funnel.js.map +1 -1
  49. package/dist/graph/build.d.ts +9 -90
  50. package/dist/graph/build.d.ts.map +1 -1
  51. package/dist/graph/build.js +15 -62
  52. package/dist/graph/build.js.map +1 -1
  53. package/dist/graph/cross-language.d.ts +4 -43
  54. package/dist/graph/cross-language.d.ts.map +1 -1
  55. package/dist/graph/cross-language.js +9 -77
  56. package/dist/graph/cross-language.js.map +1 -1
  57. package/dist/graph/merge.d.ts +8 -88
  58. package/dist/graph/merge.d.ts.map +1 -1
  59. package/dist/graph/merge.js +9 -93
  60. package/dist/graph/merge.js.map +1 -1
  61. package/dist/graph/observed-tests.d.ts +7 -68
  62. package/dist/graph/observed-tests.d.ts.map +1 -1
  63. package/dist/graph/observed-tests.js +5 -60
  64. package/dist/graph/observed-tests.js.map +1 -1
  65. package/dist/graph/persist.d.ts +2 -25
  66. package/dist/graph/persist.d.ts.map +1 -1
  67. package/dist/graph/persist.js +2 -25
  68. package/dist/graph/persist.js.map +1 -1
  69. package/dist/graph/runtime-confirmation.d.ts +14 -91
  70. package/dist/graph/runtime-confirmation.d.ts.map +1 -1
  71. package/dist/graph/runtime-confirmation.js +19 -103
  72. package/dist/graph/runtime-confirmation.js.map +1 -1
  73. package/dist/ledger/mint.d.ts +9 -43
  74. package/dist/ledger/mint.d.ts.map +1 -1
  75. package/dist/ledger/mint.js +15 -65
  76. package/dist/ledger/mint.js.map +1 -1
  77. package/dist/ledger/resolve.d.ts +13 -81
  78. package/dist/ledger/resolve.d.ts.map +1 -1
  79. package/dist/ledger/resolve.js +13 -76
  80. package/dist/ledger/resolve.js.map +1 -1
  81. package/dist/multipr/fingerprint.d.ts +5 -46
  82. package/dist/multipr/fingerprint.d.ts.map +1 -1
  83. package/dist/multipr/fingerprint.js +22 -74
  84. package/dist/multipr/fingerprint.js.map +1 -1
  85. package/dist/multipr/hidden-dependency.d.ts +13 -73
  86. package/dist/multipr/hidden-dependency.d.ts.map +1 -1
  87. package/dist/multipr/hidden-dependency.js +12 -63
  88. package/dist/multipr/hidden-dependency.js.map +1 -1
  89. package/dist/multipr/mechanical.d.ts +25 -160
  90. package/dist/multipr/mechanical.d.ts.map +1 -1
  91. package/dist/multipr/mechanical.js +21 -137
  92. package/dist/multipr/mechanical.js.map +1 -1
  93. package/dist/multipr/migration-heads.d.ts +18 -105
  94. package/dist/multipr/migration-heads.d.ts.map +1 -1
  95. package/dist/multipr/migration-heads.js +15 -84
  96. package/dist/multipr/migration-heads.js.map +1 -1
  97. package/dist/multipr/overlap.d.ts +16 -94
  98. package/dist/multipr/overlap.d.ts.map +1 -1
  99. package/dist/multipr/overlap.js +25 -105
  100. package/dist/multipr/overlap.js.map +1 -1
  101. package/dist/multipr/scope-store.d.ts +15 -80
  102. package/dist/multipr/scope-store.d.ts.map +1 -1
  103. package/dist/multipr/scope-store.js +17 -87
  104. package/dist/multipr/scope-store.js.map +1 -1
  105. package/dist/multipr/superseded.d.ts +10 -95
  106. package/dist/multipr/superseded.d.ts.map +1 -1
  107. package/dist/multipr/superseded.js +7 -60
  108. package/dist/multipr/superseded.js.map +1 -1
  109. package/dist/query/confirmed-facts.d.ts +12 -58
  110. package/dist/query/confirmed-facts.d.ts.map +1 -1
  111. package/dist/query/confirmed-facts.js +8 -47
  112. package/dist/query/confirmed-facts.js.map +1 -1
  113. package/dist/query/declared-value-closure.d.ts +13 -104
  114. package/dist/query/declared-value-closure.d.ts.map +1 -1
  115. package/dist/query/declared-value-closure.js +15 -104
  116. package/dist/query/declared-value-closure.js.map +1 -1
  117. package/dist/query/memory.d.ts +4 -16
  118. package/dist/query/memory.d.ts.map +1 -1
  119. package/dist/query/memory.js +9 -22
  120. package/dist/query/memory.js.map +1 -1
  121. package/dist/query/prominence.d.ts +6 -55
  122. package/dist/query/prominence.d.ts.map +1 -1
  123. package/dist/query/prominence.js +6 -55
  124. package/dist/query/prominence.js.map +1 -1
  125. package/dist/query/provider.d.ts +27 -93
  126. package/dist/query/provider.d.ts.map +1 -1
  127. package/dist/query/provider.js +8 -29
  128. package/dist/query/provider.js.map +1 -1
  129. package/dist/query/queries.d.ts +15 -65
  130. package/dist/query/queries.d.ts.map +1 -1
  131. package/dist/query/queries.js +30 -104
  132. package/dist/query/queries.js.map +1 -1
  133. package/dist/query/refusal-fetch.d.ts +8 -85
  134. package/dist/query/refusal-fetch.d.ts.map +1 -1
  135. package/dist/query/refusal-fetch.js +11 -93
  136. package/dist/query/refusal-fetch.js.map +1 -1
  137. package/dist/query/refusal-questions.d.ts +17 -92
  138. package/dist/query/refusal-questions.d.ts.map +1 -1
  139. package/dist/query/refusal-questions.js +14 -78
  140. package/dist/query/refusal-questions.js.map +1 -1
  141. package/dist/query/resolution-floor.d.ts +3 -23
  142. package/dist/query/resolution-floor.d.ts.map +1 -1
  143. package/dist/query/resolution-floor.js +3 -23
  144. package/dist/query/resolution-floor.js.map +1 -1
  145. package/dist/query/root-cause-score.d.ts +11 -161
  146. package/dist/query/root-cause-score.d.ts.map +1 -1
  147. package/dist/query/root-cause-score.js +6 -137
  148. package/dist/query/root-cause-score.js.map +1 -1
  149. package/dist/query/row-closure-picture.d.ts +5 -67
  150. package/dist/query/row-closure-picture.d.ts.map +1 -1
  151. package/dist/query/row-closure-picture.js +6 -67
  152. package/dist/query/row-closure-picture.js.map +1 -1
  153. package/dist/query/similar-incidents.d.ts +6 -41
  154. package/dist/query/similar-incidents.d.ts.map +1 -1
  155. package/dist/query/similar-incidents.js +15 -69
  156. package/dist/query/similar-incidents.js.map +1 -1
  157. package/dist/query/sqlite.d.ts +3 -7
  158. package/dist/query/sqlite.d.ts.map +1 -1
  159. package/dist/query/sqlite.js +9 -19
  160. package/dist/query/sqlite.js.map +1 -1
  161. package/dist/query/test-coverage.d.ts +5 -45
  162. package/dist/query/test-coverage.d.ts.map +1 -1
  163. package/dist/query/test-coverage.js +10 -53
  164. package/dist/query/test-coverage.js.map +1 -1
  165. package/dist/query/traverse.d.ts +22 -126
  166. package/dist/query/traverse.d.ts.map +1 -1
  167. package/dist/query/traverse.js +25 -126
  168. package/dist/query/traverse.js.map +1 -1
  169. package/dist/query/unresolved.d.ts +19 -164
  170. package/dist/query/unresolved.d.ts.map +1 -1
  171. package/dist/query/unresolved.js +11 -138
  172. package/dist/query/unresolved.js.map +1 -1
  173. package/dist/query/verification-status.d.ts +12 -109
  174. package/dist/query/verification-status.d.ts.map +1 -1
  175. package/dist/query/verification-status.js +9 -99
  176. package/dist/query/verification-status.js.map +1 -1
  177. package/dist/recording/migrate.d.ts +4 -10
  178. package/dist/recording/migrate.d.ts.map +1 -1
  179. package/dist/recording/migrate.js +4 -10
  180. package/dist/recording/migrate.js.map +1 -1
  181. package/dist/recording/reader.d.ts +2 -7
  182. package/dist/recording/reader.d.ts.map +1 -1
  183. package/dist/recording/reader.js +2 -7
  184. package/dist/recording/reader.js.map +1 -1
  185. package/dist/recording/redact.d.ts +6 -57
  186. package/dist/recording/redact.d.ts.map +1 -1
  187. package/dist/recording/redact.js +8 -64
  188. package/dist/recording/redact.js.map +1 -1
  189. package/dist/recording/schema.d.ts +3 -38
  190. package/dist/recording/schema.d.ts.map +1 -1
  191. package/dist/recording/schema.js +3 -38
  192. package/dist/recording/schema.js.map +1 -1
  193. package/dist/recording/writer.d.ts +11 -74
  194. package/dist/recording/writer.d.ts.map +1 -1
  195. package/dist/recording/writer.js +3 -43
  196. package/dist/recording/writer.js.map +1 -1
  197. package/dist/scoping/fanout.d.ts +6 -68
  198. package/dist/scoping/fanout.d.ts.map +1 -1
  199. package/dist/scoping/fanout.js +6 -68
  200. package/dist/scoping/fanout.js.map +1 -1
  201. package/dist/scoping/score.d.ts +20 -70
  202. package/dist/scoping/score.d.ts.map +1 -1
  203. package/dist/scoping/score.js +20 -70
  204. package/dist/scoping/score.js.map +1 -1
  205. package/dist/scoping/tiers.d.ts +4 -16
  206. package/dist/scoping/tiers.d.ts.map +1 -1
  207. package/dist/scoping/tiers.js +4 -16
  208. package/dist/scoping/tiers.js.map +1 -1
  209. package/dist/scoping/traverse.d.ts +3 -25
  210. package/dist/scoping/traverse.d.ts.map +1 -1
  211. package/dist/scoping/traverse.js +14 -49
  212. package/dist/scoping/traverse.js.map +1 -1
  213. package/dist/scoping/weights.d.ts +10 -74
  214. package/dist/scoping/weights.d.ts.map +1 -1
  215. package/dist/scoping/weights.js +14 -86
  216. package/dist/scoping/weights.js.map +1 -1
  217. package/dist/sources/confirmed/incidents.d.ts +5 -35
  218. package/dist/sources/confirmed/incidents.d.ts.map +1 -1
  219. package/dist/sources/confirmed/incidents.js +14 -48
  220. package/dist/sources/confirmed/incidents.js.map +1 -1
  221. package/dist/sources/git/diff.d.ts +93 -63
  222. package/dist/sources/git/diff.d.ts.map +1 -1
  223. package/dist/sources/git/diff.js +200 -81
  224. package/dist/sources/git/diff.js.map +1 -1
  225. package/dist/sources/git/env.d.ts +7 -0
  226. package/dist/sources/git/env.d.ts.map +1 -1
  227. package/dist/sources/git/env.js +10 -11
  228. package/dist/sources/git/env.js.map +1 -1
  229. package/dist/sources/git/history.d.ts +64 -84
  230. package/dist/sources/git/history.d.ts.map +1 -1
  231. package/dist/sources/git/history.js +141 -112
  232. package/dist/sources/git/history.js.map +1 -1
  233. package/dist/sources/git/incidents.d.ts +13 -75
  234. package/dist/sources/git/incidents.d.ts.map +1 -1
  235. package/dist/sources/git/incidents.js +21 -91
  236. package/dist/sources/git/incidents.js.map +1 -1
  237. package/dist/sources/git/index.d.ts +5 -3
  238. package/dist/sources/git/index.d.ts.map +1 -1
  239. package/dist/sources/git/index.js +3 -2
  240. package/dist/sources/git/index.js.map +1 -1
  241. package/dist/sources/git/source.d.ts +9 -79
  242. package/dist/sources/git/source.d.ts.map +1 -1
  243. package/dist/sources/git/source.js +33 -133
  244. package/dist/sources/git/source.js.map +1 -1
  245. package/dist/sources/migrations/across-change.d.ts +94 -0
  246. package/dist/sources/migrations/across-change.d.ts.map +1 -0
  247. package/dist/sources/migrations/across-change.js +278 -0
  248. package/dist/sources/migrations/across-change.js.map +1 -0
  249. package/dist/sources/migrations/dialects.d.ts +20 -36
  250. package/dist/sources/migrations/dialects.d.ts.map +1 -1
  251. package/dist/sources/migrations/dialects.js +11 -36
  252. package/dist/sources/migrations/dialects.js.map +1 -1
  253. package/dist/sources/migrations/index.d.ts +3 -1
  254. package/dist/sources/migrations/index.d.ts.map +1 -1
  255. package/dist/sources/migrations/index.js +2 -1
  256. package/dist/sources/migrations/index.js.map +1 -1
  257. package/dist/sources/migrations/read.d.ts +14 -79
  258. package/dist/sources/migrations/read.d.ts.map +1 -1
  259. package/dist/sources/migrations/read.js +14 -89
  260. package/dist/sources/migrations/read.js.map +1 -1
  261. package/dist/sources/workspace/workspace.d.ts +6 -42
  262. package/dist/sources/workspace/workspace.d.ts.map +1 -1
  263. package/dist/sources/workspace/workspace.js +10 -53
  264. package/dist/sources/workspace/workspace.js.map +1 -1
  265. package/dist/store/driver/driver.d.ts +9 -38
  266. package/dist/store/driver/driver.d.ts.map +1 -1
  267. package/dist/store/driver/driver.js +4 -22
  268. package/dist/store/driver/driver.js.map +1 -1
  269. package/dist/store/driver/node-sqlite.d.ts +3 -12
  270. package/dist/store/driver/node-sqlite.d.ts.map +1 -1
  271. package/dist/store/driver/node-sqlite.js +4 -18
  272. package/dist/store/driver/node-sqlite.js.map +1 -1
  273. package/dist/store/index.d.ts +2 -7
  274. package/dist/store/index.d.ts.map +1 -1
  275. package/dist/store/index.js +4 -10
  276. package/dist/store/index.js.map +1 -1
  277. package/dist/store/migrate.d.ts +14 -50
  278. package/dist/store/migrate.d.ts.map +1 -1
  279. package/dist/store/migrate.js +15 -52
  280. package/dist/store/migrate.js.map +1 -1
  281. package/dist/store/reader.d.ts +19 -84
  282. package/dist/store/reader.d.ts.map +1 -1
  283. package/dist/store/reader.js +25 -92
  284. package/dist/store/reader.js.map +1 -1
  285. package/dist/store/schema.d.ts +14 -76
  286. package/dist/store/schema.d.ts.map +1 -1
  287. package/dist/store/schema.js +14 -76
  288. package/dist/store/schema.js.map +1 -1
  289. package/dist/store/writer.d.ts +14 -88
  290. package/dist/store/writer.d.ts.map +1 -1
  291. package/dist/store/writer.js +29 -123
  292. package/dist/store/writer.js.map +1 -1
  293. package/dist/tiers/certify.d.ts +46 -281
  294. package/dist/tiers/certify.d.ts.map +1 -1
  295. package/dist/tiers/certify.js +46 -226
  296. package/dist/tiers/certify.js.map +1 -1
  297. package/dist/tiers/ladder.d.ts +7 -51
  298. package/dist/tiers/ladder.d.ts.map +1 -1
  299. package/dist/tiers/ladder.js +13 -89
  300. package/dist/tiers/ladder.js.map +1 -1
  301. package/dist/validation/attributes.d.ts +6 -55
  302. package/dist/validation/attributes.d.ts.map +1 -1
  303. package/dist/validation/attributes.js +6 -55
  304. package/dist/validation/attributes.js.map +1 -1
  305. package/dist/validation/config-graph.d.ts +7 -56
  306. package/dist/validation/config-graph.d.ts.map +1 -1
  307. package/dist/validation/config-graph.js +15 -61
  308. package/dist/validation/config-graph.js.map +1 -1
  309. package/dist/validation/env.d.ts +47 -8
  310. package/dist/validation/env.d.ts.map +1 -1
  311. package/dist/validation/env.js +119 -31
  312. package/dist/validation/env.js.map +1 -1
  313. package/dist/validation/index.d.ts +2 -0
  314. package/dist/validation/index.d.ts.map +1 -1
  315. package/dist/validation/index.js +1 -0
  316. package/dist/validation/index.js.map +1 -1
  317. package/dist/validation/join-substitution.d.ts +22 -120
  318. package/dist/validation/join-substitution.d.ts.map +1 -1
  319. package/dist/validation/join-substitution.js +13 -90
  320. package/dist/validation/join-substitution.js.map +1 -1
  321. package/dist/validation/migration-integrity.d.ts +11 -72
  322. package/dist/validation/migration-integrity.d.ts.map +1 -1
  323. package/dist/validation/migration-integrity.js +16 -79
  324. package/dist/validation/migration-integrity.js.map +1 -1
  325. package/dist/validation/migrations.d.ts +22 -101
  326. package/dist/validation/migrations.d.ts.map +1 -1
  327. package/dist/validation/migrations.js +19 -83
  328. package/dist/validation/migrations.js.map +1 -1
  329. package/dist/validation/nodes.d.ts +3 -1
  330. package/dist/validation/nodes.d.ts.map +1 -1
  331. package/dist/validation/nodes.js +3 -1
  332. package/dist/validation/nodes.js.map +1 -1
  333. package/dist/validation/orm-registration.d.ts +106 -0
  334. package/dist/validation/orm-registration.d.ts.map +1 -0
  335. package/dist/validation/orm-registration.js +191 -0
  336. package/dist/validation/orm-registration.js.map +1 -0
  337. package/dist/validation/rollback.d.ts +10 -73
  338. package/dist/validation/rollback.d.ts.map +1 -1
  339. package/dist/validation/rollback.js +15 -82
  340. package/dist/validation/rollback.js.map +1 -1
  341. package/dist/validation/route-drift.d.ts +9 -62
  342. package/dist/validation/route-drift.d.ts.map +1 -1
  343. package/dist/validation/route-drift.js +7 -52
  344. package/dist/validation/route-drift.js.map +1 -1
  345. package/dist/validation/sources.d.ts +16 -94
  346. package/dist/validation/sources.d.ts.map +1 -1
  347. package/dist/validation/sources.js +51 -147
  348. package/dist/validation/sources.js.map +1 -1
  349. package/dist/worker/pool.d.ts +6 -45
  350. package/dist/worker/pool.d.ts.map +1 -1
  351. package/dist/worker/pool.js +5 -42
  352. package/dist/worker/pool.js.map +1 -1
  353. package/dist/worker/protocol.d.ts +7 -20
  354. package/dist/worker/protocol.d.ts.map +1 -1
  355. package/dist/worker/protocol.js +3 -10
  356. package/dist/worker/protocol.js.map +1 -1
  357. package/dist/worker/traversal.worker.d.ts +2 -21
  358. package/dist/worker/traversal.worker.d.ts.map +1 -1
  359. package/dist/worker/traversal.worker.js +4 -23
  360. package/dist/worker/traversal.worker.js.map +1 -1
  361. package/package.json +11 -2
@@ -1,15 +1,6 @@
1
1
  /**
2
- * Reads over the stored graph.
3
- *
4
- * Deliberately thin. This is not the query layer (plan Step 9) — it is the row
5
- * access the query layer will be written against, and nothing here knows about
6
- * scoring, budgets or traversal. Keeping the split means the query layer can be
7
- * tested against an in-memory adjacency provider with no database at all, which
8
- * is what stops 95% of the engine's tests needing SQLite and a worker.
9
- *
10
- * No row from `driver/` reaches a caller unconverted: SQLite has no booleans, no
11
- * null-vs-undefined distinction and no nested values, so every read here maps
12
- * columns back into IR shapes rather than handing out raw rows.
2
+ * Reads over the stored graph. Deliberately thin — not the query layer (Step 9), just the row access it's written against; the split lets the query layer test against an in-memory provider, no database, no SQLite in 95% of tests.
3
+ * No row from driver/ reaches a caller unconverted: SQLite has no booleans, no null-vs-undefined, no nested values.
13
4
  */
14
5
  import { createHash } from "node:crypto";
15
6
  import { canonicalJson, isEdgeType, isNodeType, } from "@descryy/ir";
@@ -19,8 +10,8 @@ const EDGE_COLUMNS = "id, source, target, type, resolution, confidence, produced
19
10
  const UNRESOLVED_REF_COLUMNS = "from_node_id, edge_type, raw_target, file_path, line, produced_by, reason, attrs";
20
11
  function toNode(row) {
21
12
  if (!isNodeType(row.type)) {
22
- // Only reachable if something wrote around the Normaliser, which is exactly
23
- // the case worth failing loudly on rather than coercing.
13
+ // Only reachable if something wrote around the Normaliser — worth
14
+ // failing loudly on rather than coercing.
24
15
  throw new Error(`stored node ${row.id} has an unknown type: ${row.type}`);
25
16
  }
26
17
  const type = row.type;
@@ -74,32 +65,17 @@ export function getNode(driver, id) {
74
65
  const row = driver.prepare(`SELECT ${NODE_COLUMNS} FROM nodes WHERE id = ?`).get(id);
75
66
  return row === undefined ? undefined : toNode(row);
76
67
  }
77
- /**
78
- * Every node declared in any of `paths` — the diff-to-seeds step.
79
- *
80
- * A diff names files; scoping seeds on nodes. Nothing bridged the two until now,
81
- * because every measurement so far started from node ids it had just built.
82
- *
83
- * **Which files miss is as important as which nodes hit.** A path present in the
84
- * diff and absent from the graph is not an empty result — it is a file the
85
- * analysis never read, and reporting its blast radius as "nothing affected"
86
- * would put an unanalysed file in §20.2's *confirmed clean* category when it
87
- * belongs in *not analysable*. So the misses come back alongside the hits and
88
- * the caller cannot take one without the other.
89
- *
90
- * Paths are matched exactly. They are repo-relative by the Normaliser's rule, so
91
- * a caller passing absolute paths gets zero hits and is told so by `missing`
92
- * rather than by silence.
93
- */
68
+ /** Every node declared in any of `paths` — the diff-to-seeds step. Misses
69
+ * matter as much as hits: an absent path is an unanalysed file (§20.2), not
70
+ * an empty result, so both return together. Paths matched exactly (repo-relative); absolute paths get zero hits via `missing`. */
94
71
  export function nodesInFiles(driver, paths) {
95
72
  const wanted = [...new Set(paths)].sort();
96
73
  if (wanted.length === 0)
97
74
  return { nodes: [], missing: [] };
98
75
  const nodes = [];
99
76
  const seen = new Set();
100
- // Chunked because SQLite's default parameter ceiling is 999 and a large PR
101
- // legitimately exceeds it. Splitting here rather than asking the caller to
102
- // keeps the limit where it belongs — a property of the driver, not of a diff.
77
+ // Chunked: SQLite's default parameter ceiling is 999, and a large PR
78
+ // legitimately exceeds it. Kept a driver property, not a caller's concern.
103
79
  const CHUNK = 500;
104
80
  for (let i = 0; i < wanted.length; i += CHUNK) {
105
81
  const chunk = wanted.slice(i, i + CHUNK);
@@ -117,14 +93,9 @@ export function nodesInFiles(driver, paths) {
117
93
  const hit = new Set(nodes.map((n) => n.file).filter((f) => f !== null));
118
94
  return { nodes, missing: wanted.filter((p) => !hit.has(p)) };
119
95
  }
120
- /**
121
- * Every node of one type, capped, with one row of headroom.
122
- *
123
- * `limit + 1` is fetched so the caller can tell "exactly the limit" from "the
124
- * limit and more" without a second `COUNT(*)`. A set-property question answered
125
- * over a silently truncated set is a fact computed from a sample, so the
126
- * distinction has to be available.
127
- */
96
+ /** Every node of one type, capped, with one row of headroom. `limit + 1` is
97
+ * fetched so the caller can tell "exactly the limit" from "more", without a
98
+ * second COUNT(*) — a truncated set answering a set-property question needs that distinction available. */
128
99
  export function nodesOfType(driver, type, limit) {
129
100
  const rows = driver
130
101
  .prepare(`SELECT ${NODE_COLUMNS} FROM nodes WHERE type = ? ORDER BY id ASC LIMIT ${Math.max(1, Math.floor(limit)) + 1}`)
@@ -132,23 +103,9 @@ export function nodesOfType(driver, type, limit) {
132
103
  const truncated = rows.length > limit;
133
104
  return { nodes: rows.slice(0, limit).map(toNode), truncated };
134
105
  }
135
- /**
136
- * Nodes matching a name and/or a file — the "I know what it's called" lookup.
137
- *
138
- * Deliberately returns **every** match rather than a best one. Two functions in
139
- * a repository can legitimately share a name, and picking one by a heuristic —
140
- * shortest path, most edges, first row — is how a caller ends up reasoning
141
- * confidently about the wrong symbol. Ambiguity is the caller's to report, so
142
- * the reader hands it over intact.
143
- *
144
- * `repo` narrows to nodes minted by a run recorded against that repository —
145
- * a subquery against `adapter_runs`, since `nodes` itself carries no `repo`
146
- * column (only `run_id`). Added for `descry-runtime`'s graph correlator: a
147
- * multi-repo session (frontend + backend merged into one store, per DEC-228)
148
- * makes a same-named symbol in the wrong repository a real candidate for a
149
- * bare `findNodes({ name })` call, and nothing before this filtered it out.
150
- * Omitted, this behaves exactly as before — existing callers are unaffected.
151
- */
106
+ /** Nodes matching a name and/or file — the "I know what it's called" lookup.
107
+ * Returns every match, never a best one: picking one by heuristic is how a
108
+ * caller reasons confidently about the wrong symbol. `repo` narrows via an adapter_runs subquery (nodes carries no repo column) — added for descry-runtime's multi-repo correlator (DEC-228); omitted, behaves exactly as before. */
152
109
  export function findNodes(driver, criteria) {
153
110
  const clauses = [];
154
111
  const params = [];
@@ -173,13 +130,8 @@ export function findNodes(driver, criteria) {
173
130
  .all(...params)
174
131
  .map(toNode);
175
132
  }
176
- /**
177
- * Edges leaving a node, optionally filtered by type and capped.
178
- *
179
- * The cap is not optional politeness. The prior-art graphs on this machine have
180
- * a max in-degree of 1,036 (`append`) — materialising every neighbour of a hub
181
- * node during a traversal is how a 200-node budget turns into a 10,000-row read.
182
- */
133
+ /** Edges leaving a node, filtered by type and capped. Not optional politeness:
134
+ * a real graph's max in-degree of 1,036 turns a 200-node budget into a 10,000-row read without it. */
183
135
  export function outgoing(driver, id, options = {}) {
184
136
  return adjacency(driver, "source", id, options);
185
137
  }
@@ -191,9 +143,8 @@ function adjacency(driver, column, id, options) {
191
143
  const typeFilter = types === undefined || types.length === 0
192
144
  ? ""
193
145
  : ` AND type IN (${types.map(() => "?").join(", ")})`;
194
- // Ranked before truncation, so a cap keeps the most trustworthy neighbours
195
- // rather than whichever rows the index happened to reach first. `id` breaks
196
- // ties so the result is stable across runs.
146
+ // Ranked before truncation, so a cap keeps the most trustworthy neighbours,
147
+ // not whichever rows the index reached first. `id` breaks ties for stability.
197
148
  const sql = `SELECT ${EDGE_COLUMNS} FROM edges WHERE ${column} = ?${typeFilter}` +
198
149
  ` ORDER BY resolution DESC, confidence DESC, id ASC` +
199
150
  (options.limit === undefined ? "" : ` LIMIT ${Math.max(0, Math.floor(options.limit))}`);
@@ -202,18 +153,9 @@ function adjacency(driver, column, id, options) {
202
153
  .all(id, ...(types ?? []))
203
154
  .map(toEdge);
204
155
  }
205
- /**
206
- * Refusal-ledger rows, for the question-grouping layer (DEC-243) to consume.
207
- *
208
- * `classified` (default `true`) restricts to `attrs IS NOT NULL` — rows with
209
- * no `attrs` at all can never become a question (DEC-242: an unset
210
- * `refusalClass` is never askable) and are always the majority of this table
211
- * early in a producer's rollout — sherpa-frontend alone carries ~13,000. That
212
- * filter is a real optimisation, not an approximation: it changes which rows
213
- * are *materialised*, never which rows the grouper would have turned into a
214
- * question. The unclassified count for disclosure is `counts(driver)
215
- * .unresolvedRefs` minus this function's own row count, not recomputed here.
216
- */
156
+ /** Refusal-ledger rows for the question-grouping layer (DEC-243). `classified`
157
+ * (default true) restricts to `attrs IS NOT NULL` — rows with none can never
158
+ * become a question (DEC-242) and dominate early rollout (~13,000 on sherpa-frontend). A real optimisation, not an approximation: it never drops a groupable row. */
217
159
  export function unresolvedRefs(driver, options = {}) {
218
160
  const classified = options.classified ?? true;
219
161
  const where = classified ? "WHERE attrs IS NOT NULL" : "";
@@ -234,18 +176,9 @@ export function counts(driver) {
234
176
  runs: one("SELECT COUNT(*) AS n FROM adapter_runs"),
235
177
  };
236
178
  }
237
- /**
238
- * A hash of the store's logical content, independent of insertion order.
239
- *
240
- * This is the instrument for the determinism proof: ingesting the same batches
241
- * in a permuted order must produce the same hash. Without it, "the graph does
242
- * not depend on adapter ordering" is an assertion nobody can check, and by the
243
- * time a real ordering dependency shows up it presents as an unreproducible
244
- * difference in impact scores.
245
- *
246
- * `written_at` is excluded — a wall-clock stamp is not logical content, and
247
- * including it would make the proof untestable rather than making it stronger.
248
- */
179
+ /** Hash of the store's logical content, independent of insertion order — the
180
+ * determinism proof's instrument (permuted-order ingestion must hash the
181
+ * same). `written_at` is excluded: a wall-clock stamp isn't logical content. */
249
182
  export function contentHash(driver) {
250
183
  const digest = createHash("sha256");
251
184
  for (const table of [...DERIVED_TABLES, ...EARNED_TABLES].sort()) {
@@ -1 +1 @@
1
- {"version":3,"file":"reader.js","sourceRoot":"","sources":["../../src/store/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,GAOX,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAsC5D,MAAM,YAAY,GAChB,2FAA2F,CAAC;AAC9F,MAAM,YAAY,GAChB,uFAAuF,CAAC;AAC1F,MAAM,sBAAsB,GAC1B,kFAAkF,CAAC;AAErF,SAAS,MAAM,CAAC,GAAY;IAC1B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,4EAA4E;QAC5E,yDAAyD;QACzD,MAAM,IAAI,KAAK,CAAC,eAAe,GAAG,CAAC,EAAE,yBAAyB,GAAG,CAAC,IAA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MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;QAC5B,KAAK,MAAM,GAAG,IAAI,IAAI;YAAE,MAAM,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -1,88 +1,26 @@
1
- /**
2
- * The graph schema.
3
- *
4
- * Held as a TypeScript constant rather than a `.sql` file on disk. Reading a
5
- * sibling `.sql` at runtime resolves to `src/` under Node's type stripping and
6
- * `dist/` after `tsc`, so it needs an asset-copy build step and then behaves
7
- * differently in tests than in production — the same class of trap the build
8
- * plan flags for the traversal worker entrypoint. A constant has neither
9
- * problem and costs nothing but syntax highlighting.
10
- *
11
- * ## Five corrections to the written schema
12
- *
13
- * Architecture §24.1 and blueprint §0.8 both describe this schema, and both need
14
- * amending. Each is recorded here because the docs are the shared reference and
15
- * a silent divergence is worse than either version.
16
- *
17
- * 1. **No `properties` table.** §11.8 names `nodes`/`edges`/`properties`, but
18
- * §24.1 and blueprint §0.8 both use a JSON column instead. An entity-
19
- * attribute-value table turns every node read into a join and defeats the
20
- * adjacency performance target that §11.8's own traversal decision rests on.
21
- * Language-specific detail lives in the `attrs` JSON column, which nothing
22
- * above the IR reads.
23
- *
24
- * 2. **No `edges.weight`.** Blueprint §0.8 lists it. But `EdgeWeight` in §12.4
25
- * is tuning config keyed by edge *type*, not a per-row value — storing it per
26
- * row would let 30,000 copies of one tunable drift apart. The single genuine
27
- * per-edge quantity, `CHANGES_WITH`'s co-change count, lives in `attrs`.
28
- *
29
- * 3. **No `edges.language`.** Both §24.1 and blueprint §0.8 declare it, and
30
- * `IREdge` has no such field — nothing in the IR could ever populate it. A
31
- * column no producer can fill is a column every reader must special-case.
32
- *
33
- * 4. **`nodes.language` is nullable.** §24.1 declares it `NOT NULL`. DEC-014
34
- * establishes that `API_ENDPOINT` — the cross-language join node — belongs to
35
- * no language, and XL-2 asserts it carries none. `NOT NULL` makes the join
36
- * node unstorable.
37
- *
38
- * 5. **Composite adjacency indices.** Blueprint §0.8 indexes `edges(source)` and
39
- * `edges(target)`. Every traversal hop filters by edge type as well, and the
40
- * prior-art measurement on this machine found a max in-degree of 1,036 — so
41
- * a single-column index means scanning a thousand rows to keep four.
42
- * `edges(source, type)` and `edges(target, type)` are the real access paths.
43
- *
44
- * ## Derived vs earned — DEC-017
45
- *
46
- * The partition is expressed in `DERIVED_TABLES` / `EARNED_TABLES` below rather
47
- * than left as prose, because the only thing that makes DEC-017 real is that
48
- * `dropDerived()` can be tested to leave the earned side untouched.
49
- */
50
- /**
51
- * Bumped when the IR itself changes shape, not when an adapter changes.
52
- *
53
- * DEC-017: on mismatch, refuse to read, drop derived, rebuild, migrate earned.
54
- * A stored graph is derived data and is never the source of truth.
55
- */
1
+ /** Graph schema (TS constant, not `.sql` — avoids a build/dist path trap).
2
+ * Diverges from written docs (§24.1, blueprint §0.8): no `properties` table
3
+ * (JSON `attrs`); no `edges.weight`/`edges.language` (tuning config resp.
4
+ * no IR field); `nodes.language` nullable (API_ENDPOINT, DEC-014); composite
5
+ * `(source/target, type)` indices (max in-degree 1,036). Derived/earned: DEC-017. */
6
+ /** Bumped when the IR itself changes shape, not when an adapter changes.
7
+ * DEC-017: on mismatch, refuse to read, drop derived, rebuild, migrate earned. */
56
8
  export declare const IR_SCHEMA_VERSION = 4;
57
- /**
58
- * The tag on every node id, derived from the constant rather than restated.
59
- *
60
- * A graph tagged otherwise is not ours, and the whole point of the tag is to say
61
- * so out loud instead of silently failing to match. Restating it here as a
62
- * literal would let the store keep validating the previous scheme after an id
63
- * change — the exact failure the tag exists to prevent.
64
- */
9
+ /** Tag on every node id, derived from the constant, not restated — a
10
+ * literal here would keep validating the old scheme after an id change. */
65
11
  export declare const NODE_ID_SCHEME: string;
66
12
  /**
67
13
  * Regenerable from source. Dropping these loses time, never information.
68
14
  */
69
15
  export declare const DERIVED_TABLES: readonly ["nodes", "edges", "unresolved_refs", "file_hashes", "embeddings", "adapter_runs"];
70
- /**
71
- * Cannot be regenerated: a run that witnessed an edge fire is gone once the
72
- * process exits, a run that executed a test is gone the same way, and a human's
73
- * correction of a wrong edge is not in the source at all. These survive every
74
- * rebuild.
75
- */
16
+ /** Cannot be regenerated — a witnessed edge, an executed test, or a human's
17
+ * correction exists nowhere in source. These survive every rebuild. */
76
18
  export declare const EARNED_TABLES: readonly ["observed_edges", "observed_tests", "edge_corrections", "incident_links", "pr_scopes"];
77
19
  export type DerivedTable = (typeof DERIVED_TABLES)[number];
78
20
  export type EarnedTable = (typeof EARNED_TABLES)[number];
79
- /**
80
- * Children before parents. Stated explicitly rather than derived by reversing
81
- * `DERIVED_TABLES`: `PRAGMA foreign_keys` cannot be changed inside a
82
- * transaction, so a drop in the wrong order either fails or leans on cascade
83
- * behaviour to rescue it. Neither should be left to the order someone happened
84
- * to list the tables in.
85
- */
21
+ /** Children before parents, stated explicitly (not derived by reversing
22
+ * `DERIVED_TABLES`) — `PRAGMA foreign_keys` can't change mid-transaction,
23
+ * so wrong order fails or leans on cascade to rescue it. */
86
24
  export declare const DERIVED_DROP_ORDER: readonly ["embeddings", "unresolved_refs", "edges", "nodes", "file_hashes", "adapter_runs"];
87
25
  export declare const SCHEMA_SQL = "\n-- ---------------------------------------------------------------------------\n-- graph_meta \u2014 identity of the store itself. Read before anything else.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS graph_meta (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n) STRICT;\n\n-- ---------------------------------------------------------------------------\n-- adapter_runs \u2014 one row per accepted IRBatch. \u00A724.1's adapter registry state\n-- and DEC-015's invalidation key are the same thing, so they are one table.\n--\n-- id is derived (hash of producer + repo + commit + source files), never an\n-- autoincrement rowid: re-ingesting an identical batch must reuse the same row,\n-- or idempotence is impossible to state.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS adapter_runs (\n id TEXT PRIMARY KEY,\n repo TEXT NOT NULL,\n -- The identity scope workspace-scoped ids in this batch were computed under\n -- (DEC-054). NULL means \"this repository alone\". Recorded because the scope is\n -- configuration: once it changes, no node id in this run can be re-derived from\n -- the row itself, and a workspace typo is otherwise invisible after the fact.\n workspace TEXT,\n commit_sha TEXT NOT NULL,\n adapter_id TEXT NOT NULL, -- the part before '@'\n adapter_version TEXT NOT NULL, -- the part after '@'\n produced_by TEXT NOT NULL, -- adapter_id@adapter_version, as written on every row\n reached_resolution INTEGER NOT NULL,\n source_files TEXT NOT NULL, -- JSON array; the invalidation key (DEC-015)\n file_count INTEGER NOT NULL,\n written_at INTEGER NOT NULL\n) STRICT;\n\nCREATE INDEX IF NOT EXISTS idx_runs_adapter ON adapter_runs(adapter_id);\nCREATE INDEX IF NOT EXISTS idx_runs_producer ON adapter_runs(produced_by);\n\n-- ---------------------------------------------------------------------------\n-- nodes\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS nodes (\n id TEXT PRIMARY KEY,\n type TEXT NOT NULL,\n name TEXT NOT NULL,\n file_path TEXT, -- null for fileless types (DEC-014)\n start_line INTEGER,\n end_line INTEGER,\n language TEXT, -- correction 4: nullable\n produced_by TEXT NOT NULL,\n resolution INTEGER NOT NULL,\n attrs TEXT NOT NULL, -- JSON; correction 1\n run_id TEXT NOT NULL REFERENCES adapter_runs(id) ON DELETE CASCADE\n) STRICT;\n\nCREATE INDEX IF NOT EXISTS idx_nodes_type ON nodes(type);\nCREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name);\nCREATE INDEX IF NOT EXISTS idx_nodes_file ON nodes(file_path);\nCREATE INDEX IF NOT EXISTS idx_nodes_resolution ON nodes(resolution);\nCREATE INDEX IF NOT EXISTS idx_nodes_run ON nodes(run_id);\n\n-- ---------------------------------------------------------------------------\n-- edges. Primary key is hash(from, to, type) per DEC-012, so two adapters\n-- finding the same relationship collide by construction \u2014 which is what makes\n-- a merge policy statable at all. 30% of prior-art edges were exact\n-- duplicates, so this is load-bearing rather than tidy.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS edges (\n id TEXT PRIMARY KEY,\n source TEXT NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,\n target TEXT NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,\n type TEXT NOT NULL,\n resolution INTEGER NOT NULL,\n confidence REAL NOT NULL,\n produced_by TEXT NOT NULL,\n observed_by_run TEXT, -- present exactly when resolution = 4\n attrs TEXT, -- JSON or null; corrections 1 and 2\n run_id TEXT NOT NULL REFERENCES adapter_runs(id) ON DELETE CASCADE,\n CHECK (resolution BETWEEN 0 AND 4),\n CHECK (confidence BETWEEN 0.0 AND 1.0),\n CHECK ((resolution = 4) = (observed_by_run IS NOT NULL))\n) STRICT;\n\n-- Correction 5: the real access paths. Every hop filters by type.\nCREATE INDEX IF NOT EXISTS idx_edges_source_type ON edges(source, type);\nCREATE INDEX IF NOT EXISTS idx_edges_target_type ON edges(target, type);\nCREATE INDEX IF NOT EXISTS idx_edges_resolution ON edges(resolution);\nCREATE INDEX IF NOT EXISTS idx_edges_run ON edges(run_id);\n\n-- ---------------------------------------------------------------------------\n-- unresolved_refs \u2014 DEC-016. What an adapter saw but could not resolve.\n--\n-- Not edges, because a name-matched guess is a false claim under \u00A711B.1. Not\n-- discarded either, because then \u00A711B.6 recall has no denominator and \u00A720.2's\n-- \"not analysable\" category has nothing to count. On the prior-art graphs this\n-- is 52-60% of everything emitted.\n-- ---------------------------------------------------------------------------\n-- id is a content hash, never an autoincrement rowid: an insertion-order key\n-- would make the permuted-ingest determinism proof impossible to state, and two\n-- byte-identical references are the same reference.\nCREATE TABLE IF NOT EXISTS unresolved_refs (\n id TEXT PRIMARY KEY,\n from_node_id TEXT NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,\n edge_type TEXT NOT NULL,\n raw_target TEXT NOT NULL,\n file_path TEXT,\n line INTEGER,\n produced_by TEXT NOT NULL,\n reason TEXT NOT NULL,\n -- DEC-242's attrs.blockedBy/attrs.refusalClass live here, JSON or null --\n -- same optional-attrs treatment as edges (correction 2), and deliberately\n -- excluded from id's content hash below: this is classification of a\n -- refusal, not part of what makes two refusals the same refusal. Added in\n -- schema version 3 -- DEC-017 governs what that bump costs an existing\n -- store (drop derived, rebuild; earned tables untouched).\n attrs TEXT,\n run_id TEXT NOT NULL REFERENCES adapter_runs(id) ON DELETE CASCADE\n) STRICT;\n\nCREATE INDEX IF NOT EXISTS idx_unresolved_from ON unresolved_refs(from_node_id);\nCREATE INDEX IF NOT EXISTS idx_unresolved_target ON unresolved_refs(raw_target);\nCREATE INDEX IF NOT EXISTS idx_unresolved_run ON unresolved_refs(run_id);\n\n-- ---------------------------------------------------------------------------\n-- file_hashes \u2014 \u00A711.14 rebuild acceleration. Layer 1 change detection is\n-- defined against this table and v2.1 never declared it.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS file_hashes (\n file_path TEXT PRIMARY KEY,\n hash TEXT NOT NULL,\n last_parsed_at INTEGER NOT NULL\n) STRICT;\n\n-- ---------------------------------------------------------------------------\n-- embeddings \u2014 pointer table only. No vector extension is loaded in this build;\n-- \u00A78.2 keeps vectors in pgvector hosted or a local extension, and a column of\n-- serialised floats with no index would be a scan, not a search.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS embeddings (\n node_id TEXT PRIMARY KEY REFERENCES nodes(id) ON DELETE CASCADE,\n vector_reference TEXT NOT NULL,\n model_version TEXT NOT NULL\n) STRICT;\n\n-- ===========================================================================\n-- EARNED \u2014 DEC-017. Never dropped. No REFERENCES into the derived tables:\n-- a foreign key would cascade these away with the graph they describe, which\n-- is precisely the outcome the partition exists to prevent.\n-- ===========================================================================\n\n-- R4 evidence. An edge witnessed firing during a live run (\u00A711B.3). This is the\n-- product's core moat and cannot be recomputed from source at any price.\nCREATE TABLE IF NOT EXISTS observed_edges (\n edge_id TEXT NOT NULL,\n run_id TEXT NOT NULL,\n from_node_id TEXT NOT NULL,\n to_node_id TEXT NOT NULL,\n edge_type TEXT NOT NULL,\n commit_sha TEXT NOT NULL,\n observed_at INTEGER NOT NULL,\n PRIMARY KEY (edge_id, run_id)\n) STRICT;\n\n-- Which tests actually ran, and what happened. The coverage axis \u2014 AI layer \u00A720's\n-- \"Verification status\" \u2014 a different question from confidence, needing a\n-- different carrier.\n--\n-- Earned for the same reason as observed_edges, one step over: nothing in the\n-- source says which tests executed, so a rebuild that dropped this would turn\n-- \"what I actually verified\" silently back into \"what might be affected\".\n--\n-- Not an edge, deliberately. A test-runner's evidence carries no stack, so an\n-- observed test names exactly one node \u2014 its own TEST_CASE \u2014 and pairing it with\n-- a function it merely co-occurred with would mint an edge from temporal\n-- coincidence. That is why this is a table and not a promotion of a TESTS edge\n-- to R4; see DEC-NEXT-test-run-coverage-has-no-carrier.md.\n--\n-- (node_id, run_id) is the identity: two runs of one test are two facts, while a\n-- retry inside one run is the same fact re-observed, so the latter updates in\n-- place. Within-run retries are therefore not distinguishable here \u2014 a disclosed\n-- limit, not an oversight; this table is a coverage carrier, not a flake detector.\nCREATE TABLE IF NOT EXISTS observed_tests (\n node_id TEXT NOT NULL,\n run_id TEXT NOT NULL,\n qualified_name TEXT NOT NULL,\n outcome TEXT NOT NULL, -- 'passed' | 'failed' | 'skipped'\n -- REAL, not INTEGER, and this was an INTEGER until a real run proved it could\n -- not be. Runners report fractional milliseconds \u2014 node:test emits 2.316958 \u2014\n -- and a STRICT table refuses that value outright, so every write failed on\n -- first contact with an actual suite while the unit tests, which all passed\n -- integer literals, stayed green. Rounding was the other option and is worse:\n -- sub-millisecond tests are ordinary here, and 0.36 rounded to 0 reads as\n -- \"instant\", the same falsehood the null-rather-than-zero rule below refuses.\n duration_ms REAL,\n commit_sha TEXT NOT NULL,\n observed_at INTEGER NOT NULL,\n PRIMARY KEY (node_id, run_id)\n) STRICT;\n\nCREATE INDEX IF NOT EXISTS idx_observed_tests_run ON observed_tests(run_id);\n\n-- \u00A711B.5. A human said an edge was wrong, or runtime contradicted it. Feeding\n-- this back is how precision improves; losing it repeats the same false claim.\nCREATE TABLE IF NOT EXISTS edge_corrections (\n edge_id TEXT PRIMARY KEY,\n verdict TEXT NOT NULL, -- 'wrong' | 'right'\n reason TEXT NOT NULL,\n corrected_at INTEGER NOT NULL\n) STRICT;\n\n-- \u00A714.2. One pull request's computed scope, and it is EARNED rather than derived\n-- for a reason that is easy to get backwards.\n--\n-- Everything else on the derived side can be regenerated from source because the\n-- source is what produced it. A PR scope cannot: it was computed against a graph\n-- at one commit, and that graph moves. Recomputing it later answers a DIFFERENT\n-- question and returns a plausible answer to it \u2014 so dropping this table does\n-- not lose time, it loses the COMPARISON BASIS. Overlap scoring between two PRs\n-- is only meaningful when both scopes were computed against the same graph, and\n-- nothing in a recomputed row would say that it was not.\n--\n-- graph_commit_sha is therefore not decoration: it is the field that makes two\n-- rows comparable or not, and a reader that ignores it will happily overlap a\n-- scope from last week with one from today and report a number.\n--\n-- scope_json holds the node id set. Kept opaque here on purpose: the shape of a\n-- scope is the scoping layer's business, and a column per dimension would need\n-- a migration every time that layer learns something. What the store guarantees\n-- is that the bytes come back unchanged with the commit they were computed at.\nCREATE TABLE IF NOT EXISTS pr_scopes (\n pr_id TEXT NOT NULL,\n repo TEXT NOT NULL,\n -- The head commit of the PR itself.\n head_sha TEXT NOT NULL,\n -- The commit the GRAPH was at when this scope was computed. Two scopes are\n -- comparable only when these agree.\n graph_commit_sha TEXT NOT NULL,\n scope_json TEXT NOT NULL,\n node_count INTEGER NOT NULL,\n computed_at INTEGER NOT NULL,\n PRIMARY KEY (repo, pr_id, graph_commit_sha)\n) STRICT;\n\n-- The access path for overlap scoring: every scope computed against one graph.\n-- Without it, comparing N PRs scans the whole table N times.\nCREATE INDEX IF NOT EXISTS idx_pr_scopes_graph ON pr_scopes(repo, graph_commit_sha);\n\n-- Incident and fix-pattern links. Accumulated from real failures over time.\nCREATE TABLE IF NOT EXISTS incident_links (\n incident_node_id TEXT NOT NULL,\n target_node_id TEXT NOT NULL,\n kind TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (incident_node_id, target_node_id, kind)\n) STRICT;\n";
88
26
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/store/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,QAAkC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,cAAc,6FAOjB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,aAAa,kGAMhB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,6FAOa,CAAC;AAE7C,eAAO,MAAM,UAAU,8gaA+PtB,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/store/schema.ts"],"names":[],"mappings":"AAAA;;;;sFAIsF;AAItF;mFACmF;AACnF,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;4EAC4E;AAC5E,eAAO,MAAM,cAAc,QAAkC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,cAAc,6FAOjB,CAAC;AAEX;wEACwE;AACxE,eAAO,MAAM,aAAa,kGAMhB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD;;6DAE6D;AAC7D,eAAO,MAAM,kBAAkB,6FAOa,CAAC;AAE7C,eAAO,MAAM,UAAU,8gaA+PtB,CAAC"}
@@ -1,68 +1,14 @@
1
- /**
2
- * The graph schema.
3
- *
4
- * Held as a TypeScript constant rather than a `.sql` file on disk. Reading a
5
- * sibling `.sql` at runtime resolves to `src/` under Node's type stripping and
6
- * `dist/` after `tsc`, so it needs an asset-copy build step and then behaves
7
- * differently in tests than in production — the same class of trap the build
8
- * plan flags for the traversal worker entrypoint. A constant has neither
9
- * problem and costs nothing but syntax highlighting.
10
- *
11
- * ## Five corrections to the written schema
12
- *
13
- * Architecture §24.1 and blueprint §0.8 both describe this schema, and both need
14
- * amending. Each is recorded here because the docs are the shared reference and
15
- * a silent divergence is worse than either version.
16
- *
17
- * 1. **No `properties` table.** §11.8 names `nodes`/`edges`/`properties`, but
18
- * §24.1 and blueprint §0.8 both use a JSON column instead. An entity-
19
- * attribute-value table turns every node read into a join and defeats the
20
- * adjacency performance target that §11.8's own traversal decision rests on.
21
- * Language-specific detail lives in the `attrs` JSON column, which nothing
22
- * above the IR reads.
23
- *
24
- * 2. **No `edges.weight`.** Blueprint §0.8 lists it. But `EdgeWeight` in §12.4
25
- * is tuning config keyed by edge *type*, not a per-row value — storing it per
26
- * row would let 30,000 copies of one tunable drift apart. The single genuine
27
- * per-edge quantity, `CHANGES_WITH`'s co-change count, lives in `attrs`.
28
- *
29
- * 3. **No `edges.language`.** Both §24.1 and blueprint §0.8 declare it, and
30
- * `IREdge` has no such field — nothing in the IR could ever populate it. A
31
- * column no producer can fill is a column every reader must special-case.
32
- *
33
- * 4. **`nodes.language` is nullable.** §24.1 declares it `NOT NULL`. DEC-014
34
- * establishes that `API_ENDPOINT` — the cross-language join node — belongs to
35
- * no language, and XL-2 asserts it carries none. `NOT NULL` makes the join
36
- * node unstorable.
37
- *
38
- * 5. **Composite adjacency indices.** Blueprint §0.8 indexes `edges(source)` and
39
- * `edges(target)`. Every traversal hop filters by edge type as well, and the
40
- * prior-art measurement on this machine found a max in-degree of 1,036 — so
41
- * a single-column index means scanning a thousand rows to keep four.
42
- * `edges(source, type)` and `edges(target, type)` are the real access paths.
43
- *
44
- * ## Derived vs earned — DEC-017
45
- *
46
- * The partition is expressed in `DERIVED_TABLES` / `EARNED_TABLES` below rather
47
- * than left as prose, because the only thing that makes DEC-017 real is that
48
- * `dropDerived()` can be tested to leave the earned side untouched.
49
- */
1
+ /** Graph schema (TS constant, not `.sql` — avoids a build/dist path trap).
2
+ * Diverges from written docs (§24.1, blueprint §0.8): no `properties` table
3
+ * (JSON `attrs`); no `edges.weight`/`edges.language` (tuning config resp.
4
+ * no IR field); `nodes.language` nullable (API_ENDPOINT, DEC-014); composite
5
+ * `(source/target, type)` indices (max in-degree 1,036). Derived/earned: DEC-017. */
50
6
  import { NODE_ID_PREFIX } from "@descryy/ir";
51
- /**
52
- * Bumped when the IR itself changes shape, not when an adapter changes.
53
- *
54
- * DEC-017: on mismatch, refuse to read, drop derived, rebuild, migrate earned.
55
- * A stored graph is derived data and is never the source of truth.
56
- */
7
+ /** Bumped when the IR itself changes shape, not when an adapter changes.
8
+ * DEC-017: on mismatch, refuse to read, drop derived, rebuild, migrate earned. */
57
9
  export const IR_SCHEMA_VERSION = 4; // 3 -> 4: edge ids move e1: -> e2:, DEC-323
58
- /**
59
- * The tag on every node id, derived from the constant rather than restated.
60
- *
61
- * A graph tagged otherwise is not ours, and the whole point of the tag is to say
62
- * so out loud instead of silently failing to match. Restating it here as a
63
- * literal would let the store keep validating the previous scheme after an id
64
- * change — the exact failure the tag exists to prevent.
65
- */
10
+ /** Tag on every node id, derived from the constant, not restated — a
11
+ * literal here would keep validating the old scheme after an id change. */
66
12
  export const NODE_ID_SCHEME = NODE_ID_PREFIX.replace(":", "");
67
13
  /**
68
14
  * Regenerable from source. Dropping these loses time, never information.
@@ -75,12 +21,8 @@ export const DERIVED_TABLES = [
75
21
  "embeddings",
76
22
  "adapter_runs",
77
23
  ];
78
- /**
79
- * Cannot be regenerated: a run that witnessed an edge fire is gone once the
80
- * process exits, a run that executed a test is gone the same way, and a human's
81
- * correction of a wrong edge is not in the source at all. These survive every
82
- * rebuild.
83
- */
24
+ /** Cannot be regenerated — a witnessed edge, an executed test, or a human's
25
+ * correction exists nowhere in source. These survive every rebuild. */
84
26
  export const EARNED_TABLES = [
85
27
  "observed_edges",
86
28
  "observed_tests",
@@ -88,13 +30,9 @@ export const EARNED_TABLES = [
88
30
  "incident_links",
89
31
  "pr_scopes",
90
32
  ];
91
- /**
92
- * Children before parents. Stated explicitly rather than derived by reversing
93
- * `DERIVED_TABLES`: `PRAGMA foreign_keys` cannot be changed inside a
94
- * transaction, so a drop in the wrong order either fails or leans on cascade
95
- * behaviour to rescue it. Neither should be left to the order someone happened
96
- * to list the tables in.
97
- */
33
+ /** Children before parents, stated explicitly (not derived by reversing
34
+ * `DERIVED_TABLES`) — `PRAGMA foreign_keys` can't change mid-transaction,
35
+ * so wrong order fails or leans on cascade to rescue it. */
98
36
  export const DERIVED_DROP_ORDER = [
99
37
  "embeddings",
100
38
  "unresolved_refs",
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/store/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,CAAC,4CAA4C;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,cAAc;CACN,CAAC;AAEX;;;;;GAKG;AACH,MAAM,C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AAkB,GAAG;IAChC,YAAY;IACZ,iBAAiB;IACjB,OAAO;IACP,OAAO;IACP,aAAa;IACb,cAAc;CAC4B,CAAC;AAE7C,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+PzB,CAAC"}
@@ -1,62 +1,6 @@
1
1
  /**
2
- * The batch writer — DEC-015.
3
- *
4
- * "The writer deletes everything previously written by `producedBy` for
5
- * `sourceFiles`, then inserts, in one transaction." That sentence hides three
6
- * decisions the decision entry does not make, and getting any of them wrong
7
- * loses data silently. They are made here and each is tested.
8
- *
9
- * ## 1. Invalidation matches on adapter *id* and *repo*, not `producedBy` alone
10
- *
11
- * `producedBy` is `id@version`. Matching the full string would mean an adapter
12
- * upgrade never invalidates anything the old version wrote — the two producers
13
- * would simply coexist, and the graph would hold both readings of every file
14
- * forever. §24.1 is explicit: "an adapter version bump invalidates every node
15
- * and edge that adapter produced". So overlap is computed on the id, and the
16
- * version is what makes the *stale* rows recognisable.
17
- *
18
- * `repo` is a second, equally load-bearing part of the same match, added after
19
- * a real defect: a store holding more than one repository (`descry-runtime`'s
20
- * graph correlator merges a frontend and a backend into one store to trace
21
- * across them, per DEC-228) can have two repos using the same adapter with an
22
- * overlapping relative file path — `src/index.ts`, `package.json`, anything
23
- * common. Without `repo` in this match, writing the second repo's batch reads
24
- * as "adapter X re-ran over a file it already owned" and evicts the first
25
- * repo's run outright — silent cross-repository data loss, not a wrong
26
- * answer. `invalidateAdapter` below is intentionally *not* repo-scoped — its
27
- * own contract is "every repo," a different, explicitly global operation.
28
- *
29
- * ## 2. Prior runs are matched by file-set *overlap*, not equality
30
- *
31
- * A batch is the unit of invalidation, but the batch that previously owned a
32
- * file may have covered a different set of files. Deleting only exact-matching
33
- * runs leaves two rows for the same symbol; deleting only the intersection is
34
- * impossible, because an edge has no file. So every prior run of the same
35
- * adapter that touches *any* of these files is replaced whole — and the files
36
- * it covered that this batch does not re-supply are reported as `evictedFiles`.
37
- * Reporting them is the honest-degradation rule (principle 7): the caller is
38
- * told what fell out, rather than discovering it as a missing edge next week.
39
- *
40
- * ## 3. A run also cleans up after its own previous write
41
- *
42
- * The run id is content-derived from producer, repo, commit and file set — not
43
- * from the nodes. So an adapter re-run at the same commit over the same files
44
- * lands on the *same* run id, and "delete the prior runs" excludes it by
45
- * definition. Without a self-clean pass, rows that run no longer produces stay
46
- * forever: the upsert refreshes what is still there and nothing removes what is
47
- * not. Every write therefore ends by deleting its own run's rows that this batch
48
- * did not supply.
49
- *
50
- * ## 4. Re-supplied nodes are updated, not deleted and recreated
51
- *
52
- * A node id is stable across file moves by construction (DEC-004), so re-parsing
53
- * a file normally yields the ids that were already there. Deleting a prior run's
54
- * nodes wholesale would cascade away every edge *other* runs had pointing into
55
- * them, and those runs will not be re-run. Instead: upsert the ids this batch
56
- * supplies, then delete the prior run — whose remaining nodes are exactly those
57
- * it no longer produces. Edges into a node that genuinely disappeared do cascade
58
- * away, and are reported as `orphanedEdges`, because keeping an edge to a node
59
- * that no longer exists is the wrong-edge failure the precision rule forbids.
2
+ * Batch writer (DEC-015). Prior runs matched on adapter id+repo (not full `producedBy` — §24.1 version bumps invalidate; DEC-228 multi-repo stores need `repo` or cross-repo files silently evict each other), by file-set *overlap* not equality (evicted files reported, principle 7).
3
+ * Run id is content-derived, so a same-commit re-run self-cleans what it stopped producing. Re-supplied nodes are upserted, not deleted+recreated (DEC-004 stable ids) — only genuinely-gone nodes cascade, reported as `orphanedEdges`.
60
4
  */
61
5
  import { type IRBatch } from "@descryy/ir";
62
6
  import type { SqlDriver } from "./driver/driver.ts";
@@ -67,45 +11,27 @@ export interface WriteResult {
67
11
  readonly unresolvedWritten: number;
68
12
  /** Prior runs of the same adapter that this batch replaced. */
69
13
  readonly runsReplaced: number;
70
- /**
71
- * Files a replaced run covered that this batch did not re-supply. Their rows
72
- * are gone and will not come back until the adapter is re-run over them.
73
- * Non-empty is not an error, but it is never silent.
74
- */
14
+ /** Files a replaced run covered that this batch didn't re-supply — gone until
15
+ * re-run. Non-empty is not an error, but never silent. */
75
16
  readonly evictedFiles: readonly string[];
76
- /**
77
- * Edges removed because an endpoint node ceased to exist. Always reported:
78
- * this is the one place the store deletes something nobody asked it to.
79
- */
17
+ /** Edges removed because an endpoint node ceased to exist — the one place
18
+ * the store deletes something nobody asked it to. */
80
19
  readonly orphanedEdges: number;
81
20
  }
82
21
  export interface WriteOptions {
83
22
  /** Injectable so the determinism proof is not at the mercy of the wall clock. */
84
23
  readonly now?: () => number;
85
24
  }
86
- /**
87
- * A run id derived from the batch's content, never a counter.
88
- *
89
- * Re-ingesting an identical batch must land on the same row, or "idempotent"
90
- * cannot even be stated as a property. `sourceFiles` is sorted first so that an
91
- * adapter listing the same files in a different order does not create a second
92
- * run for identical work.
93
- */
25
+ /** Run id derived from the batch's content, never a counter — re-ingesting an
26
+ * identical batch must land on the same row. `sourceFiles` sorted first so
27
+ * order doesn't create a second run for identical work. */
94
28
  export declare function runIdFor(batch: IRBatch): string;
95
- /**
96
- * Write one normalised batch. **Input must already have passed the Normaliser** —
97
- * this function does no validation, on purpose. Two validators drift; one
98
- * validator at the boundary is a boundary.
99
- */
29
+ /** Writes one normalised batch. Input must already have passed the Normaliser —
30
+ * this does no validation, on purpose. Two validators drift. */
100
31
  export declare function writeBatch(driver: SqlDriver, batch: IRBatch, options?: WriteOptions): WriteResult;
101
- /**
102
- * Remove everything an adapter ever produced, at every version, for every repo.
103
- *
104
- * §24.1's invalidation rule, as its own operation rather than a side effect of
105
- * writing. It is deliberately separate from `writeBatch`: an upgraded adapter
106
- * usually re-runs over a subset of files first, and folding this into the write
107
- * path would make a partial re-run delete data it was never going to replace.
108
- */
32
+ /** Removes everything an adapter ever produced, at every version, every repo
33
+ * (§24.1). Kept separate from `writeBatch` — folding it in would make a
34
+ * partial re-run delete data it was never going to replace. */
109
35
  export declare function invalidateAdapter(driver: SqlDriver, adapterId: string): {
110
36
  runsRemoved: number;
111
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/store/writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAGH,OAAO,EAAyB,KAAK,OAAO,EAAmC,MAAM,aAAa,CAAC;AAGnG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,iFAAiF;IACjF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAYD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI/C;AAmCD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,YAAiB,GACzB,WAAW,C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