@descryy/core 0.1.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 (366) hide show
  1. package/LICENSE +21 -0
  2. package/dist/capabilities/index.d.ts +3 -0
  3. package/dist/capabilities/index.d.ts.map +1 -0
  4. package/dist/capabilities/index.js +2 -0
  5. package/dist/capabilities/index.js.map +1 -0
  6. package/dist/capabilities/preconditions.d.ts +99 -0
  7. package/dist/capabilities/preconditions.d.ts.map +1 -0
  8. package/dist/capabilities/preconditions.js +94 -0
  9. package/dist/capabilities/preconditions.js.map +1 -0
  10. package/dist/contracts/engine.d.ts +90 -0
  11. package/dist/contracts/engine.d.ts.map +1 -0
  12. package/dist/contracts/engine.js +291 -0
  13. package/dist/contracts/engine.js.map +1 -0
  14. package/dist/contracts/index.d.ts +9 -0
  15. package/dist/contracts/index.d.ts.map +1 -0
  16. package/dist/contracts/index.js +5 -0
  17. package/dist/contracts/index.js.map +1 -0
  18. package/dist/contracts/orphans.d.ts +96 -0
  19. package/dist/contracts/orphans.d.ts.map +1 -0
  20. package/dist/contracts/orphans.js +241 -0
  21. package/dist/contracts/orphans.js.map +1 -0
  22. package/dist/contracts/paths.d.ts +132 -0
  23. package/dist/contracts/paths.d.ts.map +1 -0
  24. package/dist/contracts/paths.js +245 -0
  25. package/dist/contracts/paths.js.map +1 -0
  26. package/dist/contracts/shapes.d.ts +99 -0
  27. package/dist/contracts/shapes.d.ts.map +1 -0
  28. package/dist/contracts/shapes.js +196 -0
  29. package/dist/contracts/shapes.js.map +1 -0
  30. package/dist/governance/budget.d.ts +89 -0
  31. package/dist/governance/budget.d.ts.map +1 -0
  32. package/dist/governance/budget.js +101 -0
  33. package/dist/governance/budget.js.map +1 -0
  34. package/dist/governance/candidate-boundary.d.ts +49 -0
  35. package/dist/governance/candidate-boundary.d.ts.map +1 -0
  36. package/dist/governance/candidate-boundary.js +51 -0
  37. package/dist/governance/candidate-boundary.js.map +1 -0
  38. package/dist/governance/escalation.d.ts +63 -0
  39. package/dist/governance/escalation.d.ts.map +1 -0
  40. package/dist/governance/escalation.js +72 -0
  41. package/dist/governance/escalation.js.map +1 -0
  42. package/dist/governance/fact-boundary.d.ts +77 -0
  43. package/dist/governance/fact-boundary.d.ts.map +1 -0
  44. package/dist/governance/fact-boundary.js +91 -0
  45. package/dist/governance/fact-boundary.js.map +1 -0
  46. package/dist/governance/finding-funnel.d.ts +109 -0
  47. package/dist/governance/finding-funnel.d.ts.map +1 -0
  48. package/dist/governance/finding-funnel.js +137 -0
  49. package/dist/governance/finding-funnel.js.map +1 -0
  50. package/dist/governance/index.d.ts +11 -0
  51. package/dist/governance/index.d.ts.map +1 -0
  52. package/dist/governance/index.js +6 -0
  53. package/dist/governance/index.js.map +1 -0
  54. package/dist/graph/build.d.ts +127 -0
  55. package/dist/graph/build.d.ts.map +1 -0
  56. package/dist/graph/build.js +0 -0
  57. package/dist/graph/build.js.map +1 -0
  58. package/dist/graph/cross-language.d.ts +70 -0
  59. package/dist/graph/cross-language.d.ts.map +1 -0
  60. package/dist/graph/cross-language.js +104 -0
  61. package/dist/graph/cross-language.js.map +1 -0
  62. package/dist/graph/index.d.ts +11 -0
  63. package/dist/graph/index.d.ts.map +1 -0
  64. package/dist/graph/index.js +6 -0
  65. package/dist/graph/index.js.map +1 -0
  66. package/dist/graph/merge.d.ts +95 -0
  67. package/dist/graph/merge.d.ts.map +1 -0
  68. package/dist/graph/merge.js +131 -0
  69. package/dist/graph/merge.js.map +1 -0
  70. package/dist/graph/persist.d.ts +42 -0
  71. package/dist/graph/persist.d.ts.map +1 -0
  72. package/dist/graph/persist.js +52 -0
  73. package/dist/graph/persist.js.map +1 -0
  74. package/dist/graph/runtime-confirmation.d.ts +169 -0
  75. package/dist/graph/runtime-confirmation.d.ts.map +1 -0
  76. package/dist/graph/runtime-confirmation.js +318 -0
  77. package/dist/graph/runtime-confirmation.js.map +1 -0
  78. package/dist/index.d.ts +18 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +19 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/ledger/index.d.ts +5 -0
  83. package/dist/ledger/index.d.ts.map +1 -0
  84. package/dist/ledger/index.js +3 -0
  85. package/dist/ledger/index.js.map +1 -0
  86. package/dist/ledger/mint.d.ts +81 -0
  87. package/dist/ledger/mint.d.ts.map +1 -0
  88. package/dist/ledger/mint.js +138 -0
  89. package/dist/ledger/mint.js.map +1 -0
  90. package/dist/ledger/resolve.d.ts +124 -0
  91. package/dist/ledger/resolve.d.ts.map +1 -0
  92. package/dist/ledger/resolve.js +290 -0
  93. package/dist/ledger/resolve.js.map +1 -0
  94. package/dist/multipr/fingerprint.d.ts +56 -0
  95. package/dist/multipr/fingerprint.d.ts.map +1 -0
  96. package/dist/multipr/fingerprint.js +169 -0
  97. package/dist/multipr/fingerprint.js.map +1 -0
  98. package/dist/multipr/hidden-dependency.d.ts +120 -0
  99. package/dist/multipr/hidden-dependency.d.ts.map +1 -0
  100. package/dist/multipr/hidden-dependency.js +185 -0
  101. package/dist/multipr/hidden-dependency.js.map +1 -0
  102. package/dist/multipr/index.d.ts +14 -0
  103. package/dist/multipr/index.d.ts.map +1 -0
  104. package/dist/multipr/index.js +8 -0
  105. package/dist/multipr/index.js.map +1 -0
  106. package/dist/multipr/mechanical.d.ts +239 -0
  107. package/dist/multipr/mechanical.d.ts.map +1 -0
  108. package/dist/multipr/mechanical.js +333 -0
  109. package/dist/multipr/mechanical.js.map +1 -0
  110. package/dist/multipr/migration-heads.d.ts +160 -0
  111. package/dist/multipr/migration-heads.d.ts.map +1 -0
  112. package/dist/multipr/migration-heads.js +212 -0
  113. package/dist/multipr/migration-heads.js.map +1 -0
  114. package/dist/multipr/overlap.d.ts +186 -0
  115. package/dist/multipr/overlap.d.ts.map +1 -0
  116. package/dist/multipr/overlap.js +254 -0
  117. package/dist/multipr/overlap.js.map +1 -0
  118. package/dist/multipr/scope-store.d.ts +105 -0
  119. package/dist/multipr/scope-store.d.ts.map +1 -0
  120. package/dist/multipr/scope-store.js +182 -0
  121. package/dist/multipr/scope-store.js.map +1 -0
  122. package/dist/multipr/superseded.d.ts +133 -0
  123. package/dist/multipr/superseded.d.ts.map +1 -0
  124. package/dist/multipr/superseded.js +128 -0
  125. package/dist/multipr/superseded.js.map +1 -0
  126. package/dist/query/confirmed-facts.d.ts +56 -0
  127. package/dist/query/confirmed-facts.d.ts.map +1 -0
  128. package/dist/query/confirmed-facts.js +64 -0
  129. package/dist/query/confirmed-facts.js.map +1 -0
  130. package/dist/query/declared-value-closure.d.ts +126 -0
  131. package/dist/query/declared-value-closure.d.ts.map +1 -0
  132. package/dist/query/declared-value-closure.js +156 -0
  133. package/dist/query/declared-value-closure.js.map +1 -0
  134. package/dist/query/index.d.ts +28 -0
  135. package/dist/query/index.d.ts.map +1 -0
  136. package/dist/query/index.js +15 -0
  137. package/dist/query/index.js.map +1 -0
  138. package/dist/query/memory.d.ts +20 -0
  139. package/dist/query/memory.d.ts.map +1 -0
  140. package/dist/query/memory.js +55 -0
  141. package/dist/query/memory.js.map +1 -0
  142. package/dist/query/provider.d.ts +127 -0
  143. package/dist/query/provider.d.ts.map +1 -0
  144. package/dist/query/provider.js +54 -0
  145. package/dist/query/provider.js.map +1 -0
  146. package/dist/query/queries.d.ts +119 -0
  147. package/dist/query/queries.d.ts.map +1 -0
  148. package/dist/query/queries.js +267 -0
  149. package/dist/query/queries.js.map +1 -0
  150. package/dist/query/refusal-fetch.d.ts +114 -0
  151. package/dist/query/refusal-fetch.d.ts.map +1 -0
  152. package/dist/query/refusal-fetch.js +200 -0
  153. package/dist/query/refusal-fetch.js.map +1 -0
  154. package/dist/query/refusal-questions.d.ts +123 -0
  155. package/dist/query/refusal-questions.d.ts.map +1 -0
  156. package/dist/query/refusal-questions.js +122 -0
  157. package/dist/query/refusal-questions.js.map +1 -0
  158. package/dist/query/root-cause-score.d.ts +218 -0
  159. package/dist/query/root-cause-score.d.ts.map +1 -0
  160. package/dist/query/root-cause-score.js +251 -0
  161. package/dist/query/root-cause-score.js.map +1 -0
  162. package/dist/query/row-closure-picture.d.ts +108 -0
  163. package/dist/query/row-closure-picture.d.ts.map +1 -0
  164. package/dist/query/row-closure-picture.js +131 -0
  165. package/dist/query/row-closure-picture.js.map +1 -0
  166. package/dist/query/similar-incidents.d.ts +76 -0
  167. package/dist/query/similar-incidents.d.ts.map +1 -0
  168. package/dist/query/similar-incidents.js +169 -0
  169. package/dist/query/similar-incidents.js.map +1 -0
  170. package/dist/query/sqlite.d.ts +13 -0
  171. package/dist/query/sqlite.d.ts.map +1 -0
  172. package/dist/query/sqlite.js +54 -0
  173. package/dist/query/sqlite.js.map +1 -0
  174. package/dist/query/traverse.d.ts +110 -0
  175. package/dist/query/traverse.d.ts.map +1 -0
  176. package/dist/query/traverse.js +0 -0
  177. package/dist/query/traverse.js.map +1 -0
  178. package/dist/query/unresolved.d.ts +195 -0
  179. package/dist/query/unresolved.d.ts.map +1 -0
  180. package/dist/query/unresolved.js +225 -0
  181. package/dist/query/unresolved.js.map +1 -0
  182. package/dist/query/verification-status.d.ts +134 -0
  183. package/dist/query/verification-status.d.ts.map +1 -0
  184. package/dist/query/verification-status.js +163 -0
  185. package/dist/query/verification-status.js.map +1 -0
  186. package/dist/recording/index.d.ts +26 -0
  187. package/dist/recording/index.d.ts.map +1 -0
  188. package/dist/recording/index.js +30 -0
  189. package/dist/recording/index.js.map +1 -0
  190. package/dist/recording/migrate.d.ts +22 -0
  191. package/dist/recording/migrate.d.ts.map +1 -0
  192. package/dist/recording/migrate.js +51 -0
  193. package/dist/recording/migrate.js.map +1 -0
  194. package/dist/recording/reader.d.ts +27 -0
  195. package/dist/recording/reader.d.ts.map +1 -0
  196. package/dist/recording/reader.js +55 -0
  197. package/dist/recording/reader.js.map +1 -0
  198. package/dist/recording/redact.d.ts +63 -0
  199. package/dist/recording/redact.d.ts.map +1 -0
  200. package/dist/recording/redact.js +98 -0
  201. package/dist/recording/redact.js.map +1 -0
  202. package/dist/recording/schema.d.ts +41 -0
  203. package/dist/recording/schema.d.ts.map +1 -0
  204. package/dist/recording/schema.js +104 -0
  205. package/dist/recording/schema.js.map +1 -0
  206. package/dist/recording/writer.d.ts +120 -0
  207. package/dist/recording/writer.d.ts.map +1 -0
  208. package/dist/recording/writer.js +81 -0
  209. package/dist/recording/writer.js.map +1 -0
  210. package/dist/scoping/fanout.d.ts +86 -0
  211. package/dist/scoping/fanout.d.ts.map +1 -0
  212. package/dist/scoping/fanout.js +95 -0
  213. package/dist/scoping/fanout.js.map +1 -0
  214. package/dist/scoping/index.d.ts +10 -0
  215. package/dist/scoping/index.d.ts.map +1 -0
  216. package/dist/scoping/index.js +6 -0
  217. package/dist/scoping/index.js.map +1 -0
  218. package/dist/scoping/score.d.ts +83 -0
  219. package/dist/scoping/score.d.ts.map +1 -0
  220. package/dist/scoping/score.js +125 -0
  221. package/dist/scoping/score.js.map +1 -0
  222. package/dist/scoping/tiers.d.ts +32 -0
  223. package/dist/scoping/tiers.d.ts.map +1 -0
  224. package/dist/scoping/tiers.js +35 -0
  225. package/dist/scoping/tiers.js.map +1 -0
  226. package/dist/scoping/traverse.d.ts +60 -0
  227. package/dist/scoping/traverse.d.ts.map +1 -0
  228. package/dist/scoping/traverse.js +172 -0
  229. package/dist/scoping/traverse.js.map +1 -0
  230. package/dist/scoping/weights.d.ts +97 -0
  231. package/dist/scoping/weights.d.ts.map +1 -0
  232. package/dist/scoping/weights.js +167 -0
  233. package/dist/scoping/weights.js.map +1 -0
  234. package/dist/sources/git/diff.d.ts +53 -0
  235. package/dist/sources/git/diff.d.ts.map +1 -0
  236. package/dist/sources/git/diff.js +140 -0
  237. package/dist/sources/git/diff.js.map +1 -0
  238. package/dist/sources/git/env.d.ts +2 -0
  239. package/dist/sources/git/env.d.ts.map +1 -0
  240. package/dist/sources/git/env.js +21 -0
  241. package/dist/sources/git/env.js.map +1 -0
  242. package/dist/sources/git/history.d.ts +140 -0
  243. package/dist/sources/git/history.d.ts.map +1 -0
  244. package/dist/sources/git/history.js +314 -0
  245. package/dist/sources/git/history.js.map +1 -0
  246. package/dist/sources/git/index.d.ts +7 -0
  247. package/dist/sources/git/index.d.ts.map +1 -0
  248. package/dist/sources/git/index.js +4 -0
  249. package/dist/sources/git/index.js.map +1 -0
  250. package/dist/sources/git/source.d.ts +95 -0
  251. package/dist/sources/git/source.d.ts.map +1 -0
  252. package/dist/sources/git/source.js +0 -0
  253. package/dist/sources/git/source.js.map +1 -0
  254. package/dist/sources/migrations/dialects.d.ts +59 -0
  255. package/dist/sources/migrations/dialects.d.ts.map +1 -0
  256. package/dist/sources/migrations/dialects.js +84 -0
  257. package/dist/sources/migrations/dialects.js.map +1 -0
  258. package/dist/sources/migrations/index.d.ts +3 -0
  259. package/dist/sources/migrations/index.d.ts.map +1 -0
  260. package/dist/sources/migrations/index.js +2 -0
  261. package/dist/sources/migrations/index.js.map +1 -0
  262. package/dist/sources/migrations/read.d.ts +113 -0
  263. package/dist/sources/migrations/read.d.ts.map +1 -0
  264. package/dist/sources/migrations/read.js +270 -0
  265. package/dist/sources/migrations/read.js.map +1 -0
  266. package/dist/sources/workspace/index.d.ts +3 -0
  267. package/dist/sources/workspace/index.d.ts.map +1 -0
  268. package/dist/sources/workspace/index.js +2 -0
  269. package/dist/sources/workspace/index.js.map +1 -0
  270. package/dist/sources/workspace/workspace.d.ts +64 -0
  271. package/dist/sources/workspace/workspace.d.ts.map +1 -0
  272. package/dist/sources/workspace/workspace.js +294 -0
  273. package/dist/sources/workspace/workspace.js.map +1 -0
  274. package/dist/store/driver/driver.d.ts +82 -0
  275. package/dist/store/driver/driver.d.ts.map +1 -0
  276. package/dist/store/driver/driver.js +31 -0
  277. package/dist/store/driver/driver.js.map +1 -0
  278. package/dist/store/driver/node-sqlite.d.ts +28 -0
  279. package/dist/store/driver/node-sqlite.d.ts.map +1 -0
  280. package/dist/store/driver/node-sqlite.js +188 -0
  281. package/dist/store/driver/node-sqlite.js.map +1 -0
  282. package/dist/store/index.d.ts +33 -0
  283. package/dist/store/index.d.ts.map +1 -0
  284. package/dist/store/index.js +46 -0
  285. package/dist/store/index.js.map +1 -0
  286. package/dist/store/migrate.d.ts +68 -0
  287. package/dist/store/migrate.d.ts.map +1 -0
  288. package/dist/store/migrate.js +140 -0
  289. package/dist/store/migrate.js.map +1 -0
  290. package/dist/store/reader.d.ts +127 -0
  291. package/dist/store/reader.d.ts.map +1 -0
  292. package/dist/store/reader.js +269 -0
  293. package/dist/store/reader.js.map +1 -0
  294. package/dist/store/schema.d.ts +87 -0
  295. package/dist/store/schema.d.ts.map +1 -0
  296. package/dist/store/schema.js +322 -0
  297. package/dist/store/schema.js.map +1 -0
  298. package/dist/store/writer.d.ts +116 -0
  299. package/dist/store/writer.d.ts.map +1 -0
  300. package/dist/store/writer.js +279 -0
  301. package/dist/store/writer.js.map +1 -0
  302. package/dist/tiers/certify.d.ts +375 -0
  303. package/dist/tiers/certify.d.ts.map +1 -0
  304. package/dist/tiers/certify.js +434 -0
  305. package/dist/tiers/certify.js.map +1 -0
  306. package/dist/tiers/index.d.ts +5 -0
  307. package/dist/tiers/index.d.ts.map +1 -0
  308. package/dist/tiers/index.js +3 -0
  309. package/dist/tiers/index.js.map +1 -0
  310. package/dist/tiers/ladder.d.ts +73 -0
  311. package/dist/tiers/ladder.d.ts.map +1 -0
  312. package/dist/tiers/ladder.js +197 -0
  313. package/dist/tiers/ladder.js.map +1 -0
  314. package/dist/validation/config-graph.d.ts +104 -0
  315. package/dist/validation/config-graph.d.ts.map +1 -0
  316. package/dist/validation/config-graph.js +205 -0
  317. package/dist/validation/config-graph.js.map +1 -0
  318. package/dist/validation/env.d.ts +243 -0
  319. package/dist/validation/env.d.ts.map +1 -0
  320. package/dist/validation/env.js +447 -0
  321. package/dist/validation/env.js.map +1 -0
  322. package/dist/validation/index.d.ts +16 -0
  323. package/dist/validation/index.d.ts.map +1 -0
  324. package/dist/validation/index.js +9 -0
  325. package/dist/validation/index.js.map +1 -0
  326. package/dist/validation/join-substitution.d.ts +186 -0
  327. package/dist/validation/join-substitution.d.ts.map +1 -0
  328. package/dist/validation/join-substitution.js +191 -0
  329. package/dist/validation/join-substitution.js.map +1 -0
  330. package/dist/validation/migrations.d.ts +133 -0
  331. package/dist/validation/migrations.d.ts.map +1 -0
  332. package/dist/validation/migrations.js +315 -0
  333. package/dist/validation/migrations.js.map +1 -0
  334. package/dist/validation/nodes.d.ts +32 -0
  335. package/dist/validation/nodes.d.ts.map +1 -0
  336. package/dist/validation/nodes.js +45 -0
  337. package/dist/validation/nodes.js.map +1 -0
  338. package/dist/validation/rollback.d.ts +124 -0
  339. package/dist/validation/rollback.d.ts.map +1 -0
  340. package/dist/validation/rollback.js +302 -0
  341. package/dist/validation/rollback.js.map +1 -0
  342. package/dist/validation/route-drift.d.ts +108 -0
  343. package/dist/validation/route-drift.d.ts.map +1 -0
  344. package/dist/validation/route-drift.js +103 -0
  345. package/dist/validation/route-drift.js.map +1 -0
  346. package/dist/validation/sources.d.ts +153 -0
  347. package/dist/validation/sources.d.ts.map +1 -0
  348. package/dist/validation/sources.js +409 -0
  349. package/dist/validation/sources.js.map +1 -0
  350. package/dist/worker/index.d.ts +5 -0
  351. package/dist/worker/index.d.ts.map +1 -0
  352. package/dist/worker/index.js +3 -0
  353. package/dist/worker/index.js.map +1 -0
  354. package/dist/worker/pool.d.ts +73 -0
  355. package/dist/worker/pool.d.ts.map +1 -0
  356. package/dist/worker/pool.js +203 -0
  357. package/dist/worker/pool.js.map +1 -0
  358. package/dist/worker/protocol.d.ts +91 -0
  359. package/dist/worker/protocol.d.ts.map +1 -0
  360. package/dist/worker/protocol.js +19 -0
  361. package/dist/worker/protocol.js.map +1 -0
  362. package/dist/worker/traversal.worker.d.ts +25 -0
  363. package/dist/worker/traversal.worker.d.ts.map +1 -0
  364. package/dist/worker/traversal.worker.js +124 -0
  365. package/dist/worker/traversal.worker.js.map +1 -0
  366. package/package.json +29 -0
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The store: open a graph, write batches into it, read rows back out.
3
+ */
4
+ import type { OpenOptions, SqlDriver } from "./driver/driver.ts";
5
+ export interface OpenStoreOptions extends OpenOptions {
6
+ /** Swap the backend. The reason the driver interface exists (DEC-018). */
7
+ readonly driver?: SqlDriver;
8
+ }
9
+ export interface Store {
10
+ readonly driver: SqlDriver;
11
+ /** True when this call created the schema, rather than opening an existing graph. */
12
+ readonly created: boolean;
13
+ close(): void;
14
+ }
15
+ /**
16
+ * Open (or create) a graph at `path`, or `":memory:"` for a throwaway one.
17
+ *
18
+ * Migration runs on open, so there is no window in which a caller holds a handle
19
+ * to a store whose version has not been checked — DEC-017's "refuse to read"
20
+ * has to happen before the first read, not on the first query.
21
+ */
22
+ export declare function openStore(path: string, options?: OpenStoreOptions): Store;
23
+ export { DriverError } from "./driver/driver.ts";
24
+ export type { DriverVersion, OpenOptions, RunResult, SqlDriver, SqlParam, SqlStatement, } from "./driver/driver.ts";
25
+ export { NodeSqliteDriver } from "./driver/node-sqlite.ts";
26
+ export { migrate, verifyReadOnly, dropDerived, rebuildStaleGraph, SchemaVersionError } from "./migrate.ts";
27
+ export { DERIVED_TABLES, DERIVED_DROP_ORDER, EARNED_TABLES, IR_SCHEMA_VERSION, NODE_ID_SCHEME, SCHEMA_SQL, } from "./schema.ts";
28
+ export type { DerivedTable, EarnedTable } from "./schema.ts";
29
+ export { writeBatch, invalidateAdapter, runIdFor, putFileHash, getFileHash } from "./writer.ts";
30
+ export type { WriteResult, WriteOptions } from "./writer.ts";
31
+ export { getNode, findNodes, nodesOfType, nodesInFiles, outgoing, incoming, counts, contentHash } from "./reader.ts";
32
+ export type { StoreCounts } from "./reader.ts";
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGjE,MAAM,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a graph, write batches into it, read rows back out.
3
+ */
4
+ import { NodeSqliteDriver } from "./driver/node-sqlite.js";
5
+ import { migrate, verifyReadOnly } from "./migrate.js";
6
+ /**
7
+ * Open (or create) a graph at `path`, or `":memory:"` for a throwaway one.
8
+ *
9
+ * Migration runs on open, so there is no window in which a caller holds a handle
10
+ * to a store whose version has not been checked — DEC-017's "refuse to read"
11
+ * has to happen before the first read, not on the first query.
12
+ */
13
+ export function openStore(path, options = {}) {
14
+ const driver = options.driver ?? new NodeSqliteDriver();
15
+ const openOptions = {
16
+ ...(options.wal === undefined ? {} : { wal: options.wal }),
17
+ ...(options.readOnly === undefined ? {} : { readOnly: options.readOnly }),
18
+ };
19
+ driver.open(path, openOptions);
20
+ try {
21
+ // A read-only handle cannot run migrate — even CREATE TABLE IF NOT EXISTS
22
+ // needs write permission — so it verifies instead. Same DEC-017 rule, reads
23
+ // only. This is the path the traversal worker takes.
24
+ if (options.readOnly === true) {
25
+ verifyReadOnly(driver);
26
+ return { driver, created: false, close: () => driver.close() };
27
+ }
28
+ const { created } = migrate(driver);
29
+ return {
30
+ driver,
31
+ created,
32
+ close: () => driver.close(),
33
+ };
34
+ }
35
+ catch (error) {
36
+ driver.close();
37
+ throw error;
38
+ }
39
+ }
40
+ export { DriverError } from "./driver/driver.js";
41
+ export { NodeSqliteDriver } from "./driver/node-sqlite.js";
42
+ export { migrate, verifyReadOnly, dropDerived, rebuildStaleGraph, SchemaVersionError } from "./migrate.js";
43
+ export { DERIVED_TABLES, DERIVED_DROP_ORDER, EARNED_TABLES, IR_SCHEMA_VERSION, NODE_ID_SCHEME, SCHEMA_SQL, } from "./schema.js";
44
+ export { writeBatch, invalidateAdapter, runIdFor, putFileHash, getFileHash } from "./writer.js";
45
+ export { getNode, findNodes, nodesOfType, nodesInFiles, outgoing, incoming, counts, contentHash } from "./reader.js";
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.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IACd,CAAC;AACH,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AASjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC3G,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,UAAU,GACX,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGhG,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Schema creation and IR-version enforcement — DEC-017.
3
+ *
4
+ * The rule this file implements: **on IR-version mismatch, refuse to read.**
5
+ * Not "migrate what we can", not "read it and hope". A graph written under a
6
+ * different IR carries node ids from a different identity scheme, and reading it
7
+ * would silently mix two incompatible id spaces — the failure would surface much
8
+ * later as missing edges, with nothing to trace it back to.
9
+ */
10
+ import { type SqlDriver } from "./driver/driver.ts";
11
+ export declare class SchemaVersionError extends Error {
12
+ readonly name = "SchemaVersionError";
13
+ readonly found: number;
14
+ readonly expected: number;
15
+ constructor(found: number, expected: number);
16
+ }
17
+ /**
18
+ * Create the schema if absent, then verify the store is one this build can read.
19
+ *
20
+ * Returns whether the store was newly created, which the caller needs in order
21
+ * to distinguish "empty because it is new" from "empty because a rebuild is
22
+ * pending" — two states that look identical from a row count.
23
+ */
24
+ export declare function migrate(driver: SqlDriver): {
25
+ created: boolean;
26
+ };
27
+ /**
28
+ * Verify a graph without writing to it.
29
+ *
30
+ * The traversal worker opens its own read-only handle (handles are not
31
+ * transferable between threads), and `migrate` cannot run there — even
32
+ * `CREATE TABLE IF NOT EXISTS` needs write permission, so the ordinary path
33
+ * would fail on a perfectly healthy graph. This performs the same DEC-017 check
34
+ * with reads only.
35
+ *
36
+ * Deliberately refuses an empty database rather than creating one: a read-only
37
+ * consumer that silently accepts "no schema" would report an empty answer for a
38
+ * graph that was never built, which is the difference between "nothing matched"
39
+ * and "nothing was analysed".
40
+ */
41
+ export declare function verifyReadOnly(driver: SqlDriver): void;
42
+ /**
43
+ * Drop and recreate every derived table, leaving earned data untouched.
44
+ *
45
+ * This is the whole operational content of DEC-017. It is also what makes the
46
+ * decision falsifiable: a test asserts the earned rows are still there
47
+ * afterwards, so the partition cannot quietly stop being real.
48
+ */
49
+ export declare function dropDerived(driver: SqlDriver): void;
50
+ /**
51
+ * MK-4 — the repair `SchemaVersionError`'s own message now names: a caller
52
+ * that is *about to rebuild the graph anyway* (`analyze`, and only `analyze`
53
+ * — every other tool stays a reader and keeps refusing per DEC-017) can call
54
+ * this first instead of hitting the refusal and stopping.
55
+ *
56
+ * Deliberately a separate entry point from `migrate()`, not a flag on it:
57
+ * `migrate()`'s whole contract is "refuse to read a version this build does
58
+ * not expect," and folding a silent repair into the same function would make
59
+ * every caller's version check optionally not a check. This one opens its own
60
+ * short-lived handle, repairs if (and only if) the stored version is a real
61
+ * mismatch — never on a brand-new graph, where `migrate()`'s own create path
62
+ * already does the right thing — and closes again, so the caller always goes
63
+ * on to open its own handle through the normal, checked path.
64
+ */
65
+ export declare function rebuildStaleGraph(driver: SqlDriver): {
66
+ readonly rebuilt: boolean;
67
+ };
68
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/store/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGjE,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAkB,IAAI,wBAAwB;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAU5C;AAkBD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CA4B/D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsBtD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CASnD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAQlF"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Schema creation and IR-version enforcement — DEC-017.
3
+ *
4
+ * The rule this file implements: **on IR-version mismatch, refuse to read.**
5
+ * Not "migrate what we can", not "read it and hope". A graph written under a
6
+ * different IR carries node ids from a different identity scheme, and reading it
7
+ * would silently mix two incompatible id spaces — the failure would surface much
8
+ * later as missing edges, with nothing to trace it back to.
9
+ */
10
+ import { DriverError } from "./driver/driver.js";
11
+ import { DERIVED_DROP_ORDER, IR_SCHEMA_VERSION, NODE_ID_SCHEME, SCHEMA_SQL } from "./schema.js";
12
+ export class SchemaVersionError extends Error {
13
+ name = "SchemaVersionError";
14
+ found;
15
+ expected;
16
+ constructor(found, expected) {
17
+ super(`stored graph was written under IR schema version ${found}, this build expects ${expected}. ` +
18
+ `The graph is derived data (DEC-017): drop the derived tables and rebuild — call "analyze" ` +
19
+ `to do this; it detects exactly this condition and repairs it before reading anything else. ` +
20
+ `Earned data — R4 observations, edge corrections, incident links — survives.`);
21
+ this.found = found;
22
+ this.expected = expected;
23
+ }
24
+ }
25
+ function readMeta(driver, key) {
26
+ const row = driver.prepare("SELECT key, value FROM graph_meta WHERE key = ?").get(key);
27
+ return row?.value;
28
+ }
29
+ function writeMeta(driver, key, value) {
30
+ driver
31
+ .prepare("INSERT INTO graph_meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value")
32
+ .run(key, value);
33
+ }
34
+ /**
35
+ * Create the schema if absent, then verify the store is one this build can read.
36
+ *
37
+ * Returns whether the store was newly created, which the caller needs in order
38
+ * to distinguish "empty because it is new" from "empty because a rebuild is
39
+ * pending" — two states that look identical from a row count.
40
+ */
41
+ export function migrate(driver) {
42
+ return driver.transaction(() => {
43
+ driver.exec(SCHEMA_SQL);
44
+ const storedVersion = readMeta(driver, "ir_schema_version");
45
+ if (storedVersion === undefined) {
46
+ writeMeta(driver, "ir_schema_version", String(IR_SCHEMA_VERSION));
47
+ writeMeta(driver, "node_id_scheme", NODE_ID_SCHEME);
48
+ return { created: true };
49
+ }
50
+ const found = Number(storedVersion);
51
+ if (!Number.isInteger(found)) {
52
+ throw new DriverError(`graph_meta.ir_schema_version is not an integer: ${storedVersion}`);
53
+ }
54
+ if (found !== IR_SCHEMA_VERSION)
55
+ throw new SchemaVersionError(found, IR_SCHEMA_VERSION);
56
+ const scheme = readMeta(driver, "node_id_scheme");
57
+ if (scheme !== NODE_ID_SCHEME) {
58
+ // The `n1:` tag exists for exactly this check — three bytes per id buying
59
+ // a recognisable mismatch instead of a silent one (DEC-011).
60
+ throw new DriverError(`stored graph uses node id scheme ${String(scheme)}, this build writes ${NODE_ID_SCHEME}`);
61
+ }
62
+ return { created: false };
63
+ });
64
+ }
65
+ /**
66
+ * Verify a graph without writing to it.
67
+ *
68
+ * The traversal worker opens its own read-only handle (handles are not
69
+ * transferable between threads), and `migrate` cannot run there — even
70
+ * `CREATE TABLE IF NOT EXISTS` needs write permission, so the ordinary path
71
+ * would fail on a perfectly healthy graph. This performs the same DEC-017 check
72
+ * with reads only.
73
+ *
74
+ * Deliberately refuses an empty database rather than creating one: a read-only
75
+ * consumer that silently accepts "no schema" would report an empty answer for a
76
+ * graph that was never built, which is the difference between "nothing matched"
77
+ * and "nothing was analysed".
78
+ */
79
+ export function verifyReadOnly(driver) {
80
+ const exists = driver
81
+ .prepare("SELECT COUNT(*) AS n FROM sqlite_master WHERE type = 'table' AND name = 'graph_meta'")
82
+ .get();
83
+ if ((exists?.n ?? 0) === 0) {
84
+ throw new DriverError("no graph at this path — build one before opening it read-only");
85
+ }
86
+ const found = Number(readMeta(driver, "ir_schema_version"));
87
+ if (!Number.isInteger(found)) {
88
+ throw new DriverError("graph_meta.ir_schema_version is missing or not an integer");
89
+ }
90
+ if (found !== IR_SCHEMA_VERSION)
91
+ throw new SchemaVersionError(found, IR_SCHEMA_VERSION);
92
+ const scheme = readMeta(driver, "node_id_scheme");
93
+ if (scheme !== NODE_ID_SCHEME) {
94
+ throw new DriverError(`stored graph uses node id scheme ${String(scheme)}, this build writes ${NODE_ID_SCHEME}`);
95
+ }
96
+ }
97
+ /**
98
+ * Drop and recreate every derived table, leaving earned data untouched.
99
+ *
100
+ * This is the whole operational content of DEC-017. It is also what makes the
101
+ * decision falsifiable: a test asserts the earned rows are still there
102
+ * afterwards, so the partition cannot quietly stop being real.
103
+ */
104
+ export function dropDerived(driver) {
105
+ driver.transaction(() => {
106
+ for (const table of DERIVED_DROP_ORDER) {
107
+ driver.exec(`DROP TABLE IF EXISTS ${table}`);
108
+ }
109
+ driver.exec(SCHEMA_SQL);
110
+ writeMeta(driver, "ir_schema_version", String(IR_SCHEMA_VERSION));
111
+ writeMeta(driver, "node_id_scheme", NODE_ID_SCHEME);
112
+ });
113
+ }
114
+ /**
115
+ * MK-4 — the repair `SchemaVersionError`'s own message now names: a caller
116
+ * that is *about to rebuild the graph anyway* (`analyze`, and only `analyze`
117
+ * — every other tool stays a reader and keeps refusing per DEC-017) can call
118
+ * this first instead of hitting the refusal and stopping.
119
+ *
120
+ * Deliberately a separate entry point from `migrate()`, not a flag on it:
121
+ * `migrate()`'s whole contract is "refuse to read a version this build does
122
+ * not expect," and folding a silent repair into the same function would make
123
+ * every caller's version check optionally not a check. This one opens its own
124
+ * short-lived handle, repairs if (and only if) the stored version is a real
125
+ * mismatch — never on a brand-new graph, where `migrate()`'s own create path
126
+ * already does the right thing — and closes again, so the caller always goes
127
+ * on to open its own handle through the normal, checked path.
128
+ */
129
+ export function rebuildStaleGraph(driver) {
130
+ driver.exec(SCHEMA_SQL);
131
+ const storedVersion = readMeta(driver, "ir_schema_version");
132
+ if (storedVersion === undefined)
133
+ return { rebuilt: false };
134
+ const found = Number(storedVersion);
135
+ if (!Number.isInteger(found) || found === IR_SCHEMA_VERSION)
136
+ return { rebuilt: false };
137
+ dropDerived(driver);
138
+ return { rebuilt: true };
139
+ }
140
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/store/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhG,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACzB,IAAI,GAAG,oBAAoB,CAAC;IACrC,KAAK,CAAS;IACd,QAAQ,CAAS;IAE1B,YAAY,KAAa,EAAE,QAAgB;QACzC,KAAK,CACH,oDAAoD,KAAK,wBAAwB,QAAQ,IAAI;YAC3F,4FAA4F;YAC5F,6FAA6F;YAC7F,6EAA6E,CAChF,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAOD,SAAS,QAAQ,CAAC,MAAiB,EAAE,GAAW;IAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAU,iDAAiD,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AAC,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAClE,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IACjD,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxB,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC5D,IAAI,aAAa,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,iBAAiB;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACvF,WAAW,CAAC,MAAM,CAAC,CAAC;IACpB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,127 @@
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.
13
+ */
14
+ import { type EdgeType, type IREdge, type IRNode, type NodeType, type UnresolvedRef } from "@descryy/ir";
15
+ import type { SqlDriver } from "./driver/driver.ts";
16
+ export declare function getNode(driver: SqlDriver, id: string): IRNode | undefined;
17
+ /**
18
+ * Every node declared in any of `paths` — the diff-to-seeds step.
19
+ *
20
+ * A diff names files; scoping seeds on nodes. Nothing bridged the two until now,
21
+ * because every measurement so far started from node ids it had just built.
22
+ *
23
+ * **Which files miss is as important as which nodes hit.** A path present in the
24
+ * diff and absent from the graph is not an empty result — it is a file the
25
+ * analysis never read, and reporting its blast radius as "nothing affected"
26
+ * would put an unanalysed file in §20.2's *confirmed clean* category when it
27
+ * belongs in *not analysable*. So the misses come back alongside the hits and
28
+ * the caller cannot take one without the other.
29
+ *
30
+ * Paths are matched exactly. They are repo-relative by the Normaliser's rule, so
31
+ * a caller passing absolute paths gets zero hits and is told so by `missing`
32
+ * rather than by silence.
33
+ */
34
+ export declare function nodesInFiles(driver: SqlDriver, paths: readonly string[]): {
35
+ readonly nodes: IRNode[];
36
+ readonly missing: string[];
37
+ };
38
+ /**
39
+ * Every node of one type, capped, with one row of headroom.
40
+ *
41
+ * `limit + 1` is fetched so the caller can tell "exactly the limit" from "the
42
+ * limit and more" without a second `COUNT(*)`. A set-property question answered
43
+ * over a silently truncated set is a fact computed from a sample, so the
44
+ * distinction has to be available.
45
+ */
46
+ export declare function nodesOfType(driver: SqlDriver, type: NodeType, limit: number): {
47
+ readonly nodes: IRNode[];
48
+ readonly truncated: boolean;
49
+ };
50
+ /**
51
+ * Nodes matching a name and/or a file — the "I know what it's called" lookup.
52
+ *
53
+ * Deliberately returns **every** match rather than a best one. Two functions in
54
+ * a repository can legitimately share a name, and picking one by a heuristic —
55
+ * shortest path, most edges, first row — is how a caller ends up reasoning
56
+ * confidently about the wrong symbol. Ambiguity is the caller's to report, so
57
+ * the reader hands it over intact.
58
+ *
59
+ * `repo` narrows to nodes minted by a run recorded against that repository —
60
+ * a subquery against `adapter_runs`, since `nodes` itself carries no `repo`
61
+ * column (only `run_id`). Added for `descry-runtime`'s graph correlator: a
62
+ * multi-repo session (frontend + backend merged into one store, per DEC-228)
63
+ * makes a same-named symbol in the wrong repository a real candidate for a
64
+ * bare `findNodes({ name })` call, and nothing before this filtered it out.
65
+ * Omitted, this behaves exactly as before — existing callers are unaffected.
66
+ */
67
+ export declare function findNodes(driver: SqlDriver, criteria: {
68
+ readonly name?: string;
69
+ readonly file?: string;
70
+ readonly repo?: string;
71
+ readonly limit?: number;
72
+ }): IRNode[];
73
+ /**
74
+ * Edges leaving a node, optionally filtered by type and capped.
75
+ *
76
+ * The cap is not optional politeness. The prior-art graphs on this machine have
77
+ * a max in-degree of 1,036 (`append`) — materialising every neighbour of a hub
78
+ * node during a traversal is how a 200-node budget turns into a 10,000-row read.
79
+ */
80
+ export declare function outgoing(driver: SqlDriver, id: string, options?: {
81
+ types?: readonly EdgeType[];
82
+ limit?: number;
83
+ }): IREdge[];
84
+ export declare function incoming(driver: SqlDriver, id: string, options?: {
85
+ types?: readonly EdgeType[];
86
+ limit?: number;
87
+ }): IREdge[];
88
+ /**
89
+ * Refusal-ledger rows, for the question-grouping layer (DEC-243) to consume.
90
+ *
91
+ * `classified` (default `true`) restricts to `attrs IS NOT NULL` — rows with
92
+ * no `attrs` at all can never become a question (DEC-242: an unset
93
+ * `refusalClass` is never askable) and are always the majority of this table
94
+ * early in a producer's rollout — sherpa-frontend alone carries ~13,000. That
95
+ * filter is a real optimisation, not an approximation: it changes which rows
96
+ * are *materialised*, never which rows the grouper would have turned into a
97
+ * question. The unclassified count for disclosure is `counts(driver)
98
+ * .unresolvedRefs` minus this function's own row count, not recomputed here.
99
+ */
100
+ export declare function unresolvedRefs(driver: SqlDriver, options?: {
101
+ readonly classified?: boolean;
102
+ readonly limit?: number;
103
+ }): {
104
+ readonly refs: UnresolvedRef[];
105
+ readonly truncated: boolean;
106
+ };
107
+ export interface StoreCounts {
108
+ readonly nodes: number;
109
+ readonly edges: number;
110
+ readonly unresolvedRefs: number;
111
+ readonly runs: number;
112
+ }
113
+ export declare function counts(driver: SqlDriver): StoreCounts;
114
+ /**
115
+ * A hash of the store's logical content, independent of insertion order.
116
+ *
117
+ * This is the instrument for the determinism proof: ingesting the same batches
118
+ * in a permuted order must produce the same hash. Without it, "the graph does
119
+ * not depend on adapter ordering" is an assertion nobody can check, and by the
120
+ * time a real ordering dependency shows up it presents as an unreproducible
121
+ * difference in impact scores.
122
+ *
123
+ * `written_at` is excluded — a wall-clock stamp is not logical content, and
124
+ * including it would make the proof untestable rather than making it stronger.
125
+ */
126
+ export declare function contentHash(driver: SqlDriver): string;
127
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/store/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,QAAQ,EAEb,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAuGpD,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CA4B1D;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,MAAM,GACZ;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAU3D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE;IACR,QAAQ,CAAC,IAAI,CAAC,EAA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