@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,64 @@
1
+ /**
2
+ * DEC-223's answer half, matching side: which refusal-ledger rows does a
3
+ * confirmed fact actually answer?
4
+ *
5
+ * Deliberately does **not** mint a graph edge. Turning an answered row into a
6
+ * real `USES_API`/etc. edge needs a target to join against — an endpoint, a
7
+ * route — which this function has no way to resolve and which DEC-223 §6
8
+ * named as future work, not this row. What this function owns is narrower
9
+ * and load-bearing on its own: **which rows are answered, by what value, and
10
+ * that the match never crosses a repo or accessor boundary it should not.**
11
+ * A caller minting an edge from `answered` is the one obligated to pass
12
+ * `reliabilityCap`'s `humanAsserted: true` — this function does not compute a
13
+ * reliability class itself, because it has no resolution level to reason
14
+ * from (`UnresolvedRef` carries none — refusals are not edges and were never
15
+ * scored). Inventing one here would be exactly the overclaim principle 2
16
+ * exists to prevent.
17
+ */
18
+ /**
19
+ * Match ledger rows against confirmed facts, scoped to one repository.
20
+ *
21
+ * Three things keep a row out of `answered`, all deliberate:
22
+ *
23
+ * 1. **No `attrs.refusalClass === "value-unknown"`.** Everything else —
24
+ * unclassified, `capability-gap`, `out-of-scope`, `varies-per-call` — is
25
+ * not askable at all (DEC-242), so no fact could ever answer it; matching
26
+ * on `blockedBy` alone without this check would let a stored fact silently
27
+ * resolve a `varies-per-call` row that structurally has no single answer.
28
+ * 2. **No `attrs.blockedBy`, or it is not a string.** Nothing to key against.
29
+ * 3. **No fact in `facts` shares this repo's exact `(repo, blockedBy)` pair.**
30
+ * `facts` entries for a different `repo` are never consulted, even when the
31
+ * blockedBy text is identical — rule 3's "never an inference about a
32
+ * second case," enforced structurally rather than left to caller discipline.
33
+ */
34
+ export function applyConfirmedFacts(refs, facts, repo) {
35
+ const byBlockedBy = new Map();
36
+ for (const fact of facts) {
37
+ if (fact.repo !== repo)
38
+ continue;
39
+ const existing = byBlockedBy.get(fact.blockedBy);
40
+ if (existing === undefined)
41
+ byBlockedBy.set(fact.blockedBy, [fact]);
42
+ else
43
+ existing.push(fact);
44
+ }
45
+ const answered = [];
46
+ const stillOpen = [];
47
+ for (const ref of refs) {
48
+ const refusalClass = ref.attrs?.["refusalClass"];
49
+ const blockedBy = ref.attrs?.["blockedBy"];
50
+ if (refusalClass !== "value-unknown" || typeof blockedBy !== "string" || blockedBy === "") {
51
+ stillOpen.push(ref);
52
+ continue;
53
+ }
54
+ const matched = byBlockedBy.get(blockedBy);
55
+ if (matched === undefined) {
56
+ stillOpen.push(ref);
57
+ }
58
+ else {
59
+ answered.push({ ref, facts: matched });
60
+ }
61
+ }
62
+ return { answered, stillOpen };
63
+ }
64
+ //# sourceMappingURL=confirmed-facts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmed-facts.js","sourceRoot":"","sources":["../../src/query/confirmed-facts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA0BH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAA8B,EAC9B,KAA+B,EAC/B,IAAY;IAEZ,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAC;IACvD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,SAAS;QACjC,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,QAAQ,KAAK,SAAS;YAAE,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;;YAC/D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,QAAQ,GAAyB,EAAE,CAAC;IAC1C,MAAM,SAAS,GAAoB,EAAE,CAAC;IAEtC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,cAAc,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,YAAY,KAAK,eAAe,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC;YAC1F,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACpB,SAAS;QACX,CAAC;QACD,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * DEC-244's Row 2: wiring `resolveAgainstDeclared`'s output to actually close
3
+ * a ledger row.
4
+ *
5
+ * The grouper (DEC-243) turns rows into questions. `resolveAgainstDeclared`
6
+ * (`../ledger/resolve.ts`) turns a question into a per-environment answer
7
+ * from what the repository's own `.env*` files already state. Until this
8
+ * file, nothing joined the two — DEC-244's own measurement is 0 of 122 rows
9
+ * closed, not because either half is broken, but because neither called the
10
+ * other.
11
+ *
12
+ * ## What "closing" a row means here, and does not mean
13
+ *
14
+ * This produces a **classification**, never a graph edge — the same
15
+ * discipline `confirmed-facts.ts`'s header states for its own output and for
16
+ * the identical reason: minting `USES_API`/etc. needs a target to join
17
+ * against (an endpoint, a route) that this module has no way to resolve, and
18
+ * DEC-223 §6 already named that as separate, unbuilt work. A caller minting
19
+ * an edge from `closed`/`partiallyClosed` is the one obligated to attach the
20
+ * reliability this module already computed (`DECLARED_VALUE_RELIABILITY`,
21
+ * class A — see DEC-244 Row 1) rather than inventing its own.
22
+ *
23
+ * ## Why this is not a `ConfirmedFact`, and does not reuse its shape
24
+ *
25
+ * `ConfirmedFact` (DEC-223 §3) is testimony: one person's typed string,
26
+ * corroborated by nothing, capped at reliability class B by construction
27
+ * (`humanAsserted: true`). A value read from a repository's own `.env` file
28
+ * is the opposite kind of evidence — nobody asserted it, anyone can re-read
29
+ * the same file and get the same answer, and DEC-244 Row 1 rules it reaches
30
+ * class A on exactly the precedent `validation/env.ts` already established
31
+ * for `.env` reads generally (a direct, uninferred read of a declarative
32
+ * document, the same class of evidence that lets `adapter-openapi`/
33
+ * `adapter-sql` reach R3 with no language adapter at all). Constructing a
34
+ * `ConfirmedFact` here — with a synthetic `confirmedBy: "config:..."` and
35
+ * `humanAsserted` forced `false` at the call site — would make the *type*
36
+ * claim testimony while the *call site* claims otherwise, a distinction that
37
+ * survives exactly as long as every future caller remembers to look past the
38
+ * type to the call site. `DeclaredValueClosure` is the type-level guarantee
39
+ * instead: nothing shaped this way can ever be mistaken for testimony,
40
+ * because nothing about it says `confirmedBy`.
41
+ *
42
+ * ## The hard part: partial closure has to stay visibly partial
43
+ *
44
+ * `resolveAgainstDeclared`'s own `knownEnvironments` is deliberately narrow —
45
+ * it is *only* what this repository's `.env*` **filenames** assert exist,
46
+ * never invented. That narrowness is correct for `resolve.ts` (DEC-223's own
47
+ * "never guessed, always refused" rule) and creates a real trap one layer up:
48
+ * a repository can resolve **every environment its filenames mention** and
49
+ * still have a production deployment this reader has no way to see, because
50
+ * production's value never lived in a checked-in `.env*` file at all.
51
+ *
52
+ * Measured, not hypothetical: `sherpa-frontend` has exactly
53
+ * `.env.development` and `.env.development.local`, nothing named
54
+ * `production` anywhere in its `.env*` surface — `VITE_BACKEND_API_URL`
55
+ * resolves fully for `"development"` (`knownEnvironments.length === 1`), and
56
+ * a consumer that read that as "closed" would silently bind a `localhost`
57
+ * dev value to every production call site in the ledger. **That is the exact
58
+ * silent-failure shape this product exists to catch, reproduced inside the
59
+ * product**, which is why `MIN_KNOWN_ENVIRONMENTS_FOR_CLOSED` exists: a
60
+ * repository's own naming convention has to demonstrate it actually
61
+ * distinguishes more than one environment before this module will call
62
+ * anything fully closed. Below that bar, a fully-resolved result is reported
63
+ * as `"partially-closed"` — under-claiming is the safe direction (rule 2 —
64
+ * when in doubt, omit), and `resolution.knownEnvironments` stays attached to
65
+ * every closure record so a reader can see exactly what evidence there was.
66
+ *
67
+ * `sherpa-cf-worker` is the other real shape: it has **no** `.env*` files at
68
+ * all (its runtime config lives in `wrangler.toml`, `[vars]`/`[env.*.vars]`,
69
+ * a format `resolve.ts` deliberately does not read —
70
+ * `REQUEST-D-wrangler-vars-format.md`, not built). Every one of its rows
71
+ * therefore has `knownEnvironments.length === 0` and lands in `stillOpen`,
72
+ * which is correct and current, not a defect this module can fix.
73
+ */
74
+ import type { UnresolvedRef } from "@descryy/ir";
75
+ import { reliabilityCap } from "@descryy/ir";
76
+ import type { DeclaredEnvValue, LedgerAccessorResolution } from "../ledger/resolve.ts";
77
+ export type ClosureState = "closed" | "partially-closed";
78
+ /** One row, closed or partially closed against this repository's own declared config values. */
79
+ export interface DeclaredValueClosure {
80
+ readonly ref: UnresolvedRef;
81
+ readonly blockedBy: string;
82
+ readonly resolution: LedgerAccessorResolution;
83
+ readonly state: ClosureState;
84
+ /**
85
+ * Always `"A"` today — see the module header and DEC-244 Row 1.
86
+ * Carried per-closure rather than computed again by every caller, so a
87
+ * caller cannot accidentally pass `humanAsserted: true` and mislabel a
88
+ * direct read as testimony.
89
+ */
90
+ readonly reliability: ReturnType<typeof reliabilityCap>;
91
+ }
92
+ export interface DeclaredValueApplication {
93
+ readonly closed: readonly DeclaredValueClosure[];
94
+ readonly partiallyClosed: readonly DeclaredValueClosure[];
95
+ /**
96
+ * Everything else: not askable at all (wrong class, unset, no handle —
97
+ * `askableHandle` returned `null`), an unparseable `blockedBy`, zero
98
+ * `.env*` evidence for this repository, or a recognised name this
99
+ * repository's `.env*` files never set in any environment.
100
+ */
101
+ readonly stillOpen: readonly UnresolvedRef[];
102
+ }
103
+ /**
104
+ * A resolved value is a claim about *content* (what string a variable holds),
105
+ * not mere *existence* — `nameLevel: false`. At R3 this does not change the
106
+ * outcome (`reliabilityCap`'s R3/R4 branch returns `"A"` regardless of
107
+ * `nameLevel`), but a future caller reusing this constant at a lower
108
+ * resolution should not inherit a `nameLevel` value chosen for the wrong
109
+ * reason, so it is stated correctly here rather than left as an accident of
110
+ * R3 not needing it.
111
+ */
112
+ export declare const DECLARED_VALUE_RELIABILITY: import("@descryy/ir").ReliabilityClass;
113
+ /**
114
+ * Apply one repository's declared `.env*` values against its refusal ledger.
115
+ *
116
+ * The reconciliation this makes checkable, same law as the grouper and the
117
+ * Normaliser one level down each: every row in `refs` lands in exactly one
118
+ * of `closed`, `partiallyClosed` or `stillOpen` —
119
+ * `refs.length === closed.length + partiallyClosed.length + stillOpen.length`,
120
+ * always. `resolveAgainstDeclared` is called at most once per distinct
121
+ * `blockedBy` (cached), not once per row, matching `resolve.ts`'s own stated
122
+ * performance contract — "read once per repository ... runs many times
123
+ * against the result rather than rescanning per ledger row."
124
+ */
125
+ export declare function applyDeclaredValues(refs: readonly UnresolvedRef[], declared: readonly DeclaredEnvValue[]): DeclaredValueApplication;
126
+ //# sourceMappingURL=declared-value-closure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declared-value-closure.d.ts","sourceRoot":"","sources":["../../src/query/declared-value-closure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEvF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,kBAAkB,CAAC;AAEzD,gGAAgG;AAChG,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,wBAAwB,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACjD,QAAQ,CAAC,eAAe,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC1D;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,aAAa,EAAE,CAAC;CAC9C;AAKD;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,wCAA0D,CAAC;AAsBlG;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,SAAS,aAAa,EAAE,EAC9B,QAAQ,EAAE,SAAS,gBAAgB,EAAE,GACpC,wBAAwB,CAoC1B"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * DEC-244's Row 2: wiring `resolveAgainstDeclared`'s output to actually close
3
+ * a ledger row.
4
+ *
5
+ * The grouper (DEC-243) turns rows into questions. `resolveAgainstDeclared`
6
+ * (`../ledger/resolve.ts`) turns a question into a per-environment answer
7
+ * from what the repository's own `.env*` files already state. Until this
8
+ * file, nothing joined the two — DEC-244's own measurement is 0 of 122 rows
9
+ * closed, not because either half is broken, but because neither called the
10
+ * other.
11
+ *
12
+ * ## What "closing" a row means here, and does not mean
13
+ *
14
+ * This produces a **classification**, never a graph edge — the same
15
+ * discipline `confirmed-facts.ts`'s header states for its own output and for
16
+ * the identical reason: minting `USES_API`/etc. needs a target to join
17
+ * against (an endpoint, a route) that this module has no way to resolve, and
18
+ * DEC-223 §6 already named that as separate, unbuilt work. A caller minting
19
+ * an edge from `closed`/`partiallyClosed` is the one obligated to attach the
20
+ * reliability this module already computed (`DECLARED_VALUE_RELIABILITY`,
21
+ * class A — see DEC-244 Row 1) rather than inventing its own.
22
+ *
23
+ * ## Why this is not a `ConfirmedFact`, and does not reuse its shape
24
+ *
25
+ * `ConfirmedFact` (DEC-223 §3) is testimony: one person's typed string,
26
+ * corroborated by nothing, capped at reliability class B by construction
27
+ * (`humanAsserted: true`). A value read from a repository's own `.env` file
28
+ * is the opposite kind of evidence — nobody asserted it, anyone can re-read
29
+ * the same file and get the same answer, and DEC-244 Row 1 rules it reaches
30
+ * class A on exactly the precedent `validation/env.ts` already established
31
+ * for `.env` reads generally (a direct, uninferred read of a declarative
32
+ * document, the same class of evidence that lets `adapter-openapi`/
33
+ * `adapter-sql` reach R3 with no language adapter at all). Constructing a
34
+ * `ConfirmedFact` here — with a synthetic `confirmedBy: "config:..."` and
35
+ * `humanAsserted` forced `false` at the call site — would make the *type*
36
+ * claim testimony while the *call site* claims otherwise, a distinction that
37
+ * survives exactly as long as every future caller remembers to look past the
38
+ * type to the call site. `DeclaredValueClosure` is the type-level guarantee
39
+ * instead: nothing shaped this way can ever be mistaken for testimony,
40
+ * because nothing about it says `confirmedBy`.
41
+ *
42
+ * ## The hard part: partial closure has to stay visibly partial
43
+ *
44
+ * `resolveAgainstDeclared`'s own `knownEnvironments` is deliberately narrow —
45
+ * it is *only* what this repository's `.env*` **filenames** assert exist,
46
+ * never invented. That narrowness is correct for `resolve.ts` (DEC-223's own
47
+ * "never guessed, always refused" rule) and creates a real trap one layer up:
48
+ * a repository can resolve **every environment its filenames mention** and
49
+ * still have a production deployment this reader has no way to see, because
50
+ * production's value never lived in a checked-in `.env*` file at all.
51
+ *
52
+ * Measured, not hypothetical: `sherpa-frontend` has exactly
53
+ * `.env.development` and `.env.development.local`, nothing named
54
+ * `production` anywhere in its `.env*` surface — `VITE_BACKEND_API_URL`
55
+ * resolves fully for `"development"` (`knownEnvironments.length === 1`), and
56
+ * a consumer that read that as "closed" would silently bind a `localhost`
57
+ * dev value to every production call site in the ledger. **That is the exact
58
+ * silent-failure shape this product exists to catch, reproduced inside the
59
+ * product**, which is why `MIN_KNOWN_ENVIRONMENTS_FOR_CLOSED` exists: a
60
+ * repository's own naming convention has to demonstrate it actually
61
+ * distinguishes more than one environment before this module will call
62
+ * anything fully closed. Below that bar, a fully-resolved result is reported
63
+ * as `"partially-closed"` — under-claiming is the safe direction (rule 2 —
64
+ * when in doubt, omit), and `resolution.knownEnvironments` stays attached to
65
+ * every closure record so a reader can see exactly what evidence there was.
66
+ *
67
+ * `sherpa-cf-worker` is the other real shape: it has **no** `.env*` files at
68
+ * all (its runtime config lives in `wrangler.toml`, `[vars]`/`[env.*.vars]`,
69
+ * a format `resolve.ts` deliberately does not read —
70
+ * `REQUEST-D-wrangler-vars-format.md`, not built). Every one of its rows
71
+ * therefore has `knownEnvironments.length === 0` and lands in `stillOpen`,
72
+ * which is correct and current, not a defect this module can fix.
73
+ */
74
+ import { reliabilityCap } from "@descryy/ir";
75
+ import { askableHandle } from "./refusal-questions.js";
76
+ import { resolveAgainstDeclared } from "../ledger/resolve.js";
77
+ /** Direct reads of `.env*` need no resolution — same precedent `validation/env.ts` already uses (DEC-244 Row 1). */
78
+ const DECLARED_VALUE_RESOLUTION = 3;
79
+ /**
80
+ * A resolved value is a claim about *content* (what string a variable holds),
81
+ * not mere *existence* — `nameLevel: false`. At R3 this does not change the
82
+ * outcome (`reliabilityCap`'s R3/R4 branch returns `"A"` regardless of
83
+ * `nameLevel`), but a future caller reusing this constant at a lower
84
+ * resolution should not inherit a `nameLevel` value chosen for the wrong
85
+ * reason, so it is stated correctly here rather than left as an accident of
86
+ * R3 not needing it.
87
+ */
88
+ export const DECLARED_VALUE_RELIABILITY = reliabilityCap(DECLARED_VALUE_RESOLUTION, false, false);
89
+ /**
90
+ * A repository's own `.env*` naming has to name at least this many distinct
91
+ * environments before a fully-resolved result is trusted as `"closed"`
92
+ * rather than `"partially-closed"` — see the module header's `sherpa-frontend`
93
+ * case. Not tuned; picked as the smallest number that is structurally
94
+ * meaningful (one named environment proves nothing about whether a second,
95
+ * unnamed one exists; two or more is the repository's own convention
96
+ * demonstrating it actually distinguishes environments).
97
+ */
98
+ const MIN_KNOWN_ENVIRONMENTS_FOR_CLOSED = 2;
99
+ function classify(resolution) {
100
+ if (resolution.resolution === null)
101
+ return "open"; // blockedBy shape not recognised
102
+ if (resolution.knownEnvironments.length === 0)
103
+ return "open"; // no .env* evidence at all
104
+ if (resolution.resolved.length === 0)
105
+ return "open"; // known environments, resolved in none of them
106
+ if (resolution.unresolvedEnvironments.length > 0)
107
+ return "partially-closed"; // some known environments unresolved
108
+ if (resolution.knownEnvironments.length < MIN_KNOWN_ENVIRONMENTS_FOR_CLOSED)
109
+ return "partially-closed"; // thin evidence
110
+ return "closed";
111
+ }
112
+ /**
113
+ * Apply one repository's declared `.env*` values against its refusal ledger.
114
+ *
115
+ * The reconciliation this makes checkable, same law as the grouper and the
116
+ * Normaliser one level down each: every row in `refs` lands in exactly one
117
+ * of `closed`, `partiallyClosed` or `stillOpen` —
118
+ * `refs.length === closed.length + partiallyClosed.length + stillOpen.length`,
119
+ * always. `resolveAgainstDeclared` is called at most once per distinct
120
+ * `blockedBy` (cached), not once per row, matching `resolve.ts`'s own stated
121
+ * performance contract — "read once per repository ... runs many times
122
+ * against the result rather than rescanning per ledger row."
123
+ */
124
+ export function applyDeclaredValues(refs, declared) {
125
+ const cache = new Map();
126
+ const closed = [];
127
+ const partiallyClosed = [];
128
+ const stillOpen = [];
129
+ for (const ref of refs) {
130
+ const blockedBy = askableHandle(ref);
131
+ if (blockedBy === null) {
132
+ stillOpen.push(ref);
133
+ continue;
134
+ }
135
+ let resolution = cache.get(blockedBy);
136
+ if (resolution === undefined) {
137
+ resolution = resolveAgainstDeclared(blockedBy, declared);
138
+ cache.set(blockedBy, resolution);
139
+ }
140
+ const state = classify(resolution);
141
+ if (state === "open") {
142
+ stillOpen.push(ref);
143
+ continue;
144
+ }
145
+ const closure = {
146
+ ref,
147
+ blockedBy,
148
+ resolution,
149
+ state,
150
+ reliability: DECLARED_VALUE_RELIABILITY,
151
+ };
152
+ (state === "closed" ? closed : partiallyClosed).push(closure);
153
+ }
154
+ return { closed, partiallyClosed, stillOpen };
155
+ }
156
+ //# sourceMappingURL=declared-value-closure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declared-value-closure.js","sourceRoot":"","sources":["../../src/query/declared-value-closure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAgC9D,oHAAoH;AACpH,MAAM,yBAAyB,GAAoB,CAAC,CAAC;AAErD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,cAAc,CAAC,yBAAyB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAElG;;;;;;;;GAQG;AACH,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAE5C,SAAS,QAAQ,CAAC,UAAoC;IACpD,IAAI,UAAU,CAAC,UAAU,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,CAAC,iCAAiC;IACpF,IAAI,UAAU,CAAC,iBAAiB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,CAAC,2BAA2B;IACzF,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,CAAC,+CAA+C;IACpG,IAAI,UAAU,CAAC,sBAAsB,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,kBAAkB,CAAC,CAAC,qCAAqC;IAClH,IAAI,UAAU,CAAC,iBAAiB,CAAC,MAAM,GAAG,iCAAiC;QAAE,OAAO,kBAAkB,CAA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
@@ -0,0 +1,28 @@
1
+ export { rankEdges, applyAdjacencyOptions } from "./provider.ts";
2
+ export type { AdjacencyProvider, AdjacencyOptions, GraphStamp, QueryResult, } from "./provider.ts";
3
+ export { createMemoryProvider } from "./memory.ts";
4
+ export type { MemoryGraph } from "./memory.ts";
5
+ export { createStoreProvider, commitSpread } from "./sqlite.ts";
6
+ export { bfs, weightedBfs, findPath, API_JOIN_EDGE_TYPES } from "./traverse.ts";
7
+ export type { Direction, Reached, TraversalOptions, TraversalOutcome, WeightedOptions } from "./traverse.ts";
8
+ export { impactOf, rootCauseSearch, testsCovering, dataFlowFrom, DATA_FLOW_EDGE_TYPES, traceApi, changeRisk, changesWith, } from "./queries.ts";
9
+ export type { ImpactOptions, RootCauseMatch, ChangeRisk, CoChange } from "./queries.ts";
10
+ export { similarIncidents, tokenSetSimilarity, fileOverlapSimilarity } from "./similar-incidents.ts";
11
+ export type { SimilarFailureQuery, SimilarIncidentMatch, SimilarIncidentOptions, SimilarIncidentSignal, SimilarIncidentSignalKind, } from "./similar-incidents.ts";
12
+ export { classifyRefusal, classifyRefusals, readRate } from "./unresolved.ts";
13
+ export type { RefusalClass, RefusalScope, RefusalCensus, ReadRate } from "./unresolved.ts";
14
+ export { applyConfirmedFacts } from "./confirmed-facts.ts";
15
+ export type { ConfirmedFactApplication, ConfirmedFactMatch } from "./confirmed-facts.ts";
16
+ export { groupRefusalsIntoQuestions, groupRefusalsAcrossRepos, askableHandle } from "./refusal-questions.ts";
17
+ export type { RefusalSite, RefusalQuestion, RefusalDropCounts, GroupingResult, } from "./refusal-questions.ts";
18
+ export { summariseRefusals, fetchRefusalPage } from "./refusal-fetch.ts";
19
+ export type { RefusalSummary, RefusalPage, RefusalPageOk, RefusalPageRefused } from "./refusal-fetch.ts";
20
+ export { computeVerificationStatus, resolutionOfExercised } from "./verification-status.ts";
21
+ export type { CoverageCheck, ScopeItem } from "./verification-status.ts";
22
+ export { applyDeclaredValues, DECLARED_VALUE_RELIABILITY } from "./declared-value-closure.ts";
23
+ export type { ClosureState, DeclaredValueClosure, DeclaredValueApplication, } from "./declared-value-closure.ts";
24
+ export { describeRowClosures } from "./row-closure-picture.ts";
25
+ export type { EnvironmentValue, AssertedValue, RowClosurePicture, RowClosureApplication, } from "./row-closure-picture.ts";
26
+ export { rankRootCause, DEFAULT_ROOT_CAUSE_WEIGHTS, ROOT_CAUSE_TRACE_EDGE_TYPES, INCIDENT_SATURATION } from "./root-cause-score.ts";
27
+ export type { RootCauseWeights, RootCauseOptions, RankedRootCauseCandidate, RootCauseRanking, ChangeCouplingEvidence, } from "./root-cause-score.ts";
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACjE,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,WAAW,GACZ,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAChF,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE7G,OAAO,EACL,QAAQ,EACR,eAAe,EACf,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExF,OAAO,EAAE,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,aAAa,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACpI,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,15 @@
1
+ export { rankEdges, applyAdjacencyOptions } from "./provider.js";
2
+ export { createMemoryProvider } from "./memory.js";
3
+ export { createStoreProvider, commitSpread } from "./sqlite.js";
4
+ export { bfs, weightedBfs, findPath, API_JOIN_EDGE_TYPES } from "./traverse.js";
5
+ export { impactOf, rootCauseSearch, testsCovering, dataFlowFrom, DATA_FLOW_EDGE_TYPES, traceApi, changeRisk, changesWith, } from "./queries.js";
6
+ export { similarIncidents, tokenSetSimilarity, fileOverlapSimilarity } from "./similar-incidents.js";
7
+ export { classifyRefusal, classifyRefusals, readRate } from "./unresolved.js";
8
+ export { applyConfirmedFacts } from "./confirmed-facts.js";
9
+ export { groupRefusalsIntoQuestions, groupRefusalsAcrossRepos, askableHandle } from "./refusal-questions.js";
10
+ export { summariseRefusals, fetchRefusalPage } from "./refusal-fetch.js";
11
+ export { computeVerificationStatus, resolutionOfExercised } from "./verification-status.js";
12
+ export { applyDeclaredValues, DECLARED_VALUE_RELIABILITY } from "./declared-value-closure.js";
13
+ export { describeRowClosures } from "./row-closure-picture.js";
14
+ export { rankRootCause, DEFAULT_ROOT_CAUSE_WEIGHTS, ROOT_CAUSE_TRACE_EDGE_TYPES, INCIDENT_SATURATION } from "./root-cause-score.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAQjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGhF,OAAO,EACL,QAAQ,EACR,eAAe,EACf,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AASrG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQ7G,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGzE,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAG5F,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAO9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAQ/D,OAAO,EAAE,aAAa,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * An in-memory `AdjacencyProvider`.
3
+ *
4
+ * The reason the interface exists. Building one of these from a `BuildResult` is
5
+ * four lines and needs no file, no schema, no writer and no worker — so the
6
+ * traversal and query tests below it exercise the same code paths production
7
+ * uses, without any of the setup that would otherwise make them slow enough to
8
+ * skip.
9
+ */
10
+ import type { IREdge, IRNode, UnresolvedRef } from "@descryy/ir";
11
+ import { type AdjacencyProvider } from "./provider.ts";
12
+ export interface MemoryGraph {
13
+ readonly nodes: readonly IRNode[];
14
+ readonly edges: readonly IREdge[];
15
+ readonly unresolved?: readonly UnresolvedRef[];
16
+ readonly commitSha?: string | null;
17
+ readonly graphBuiltAt?: number | null;
18
+ }
19
+ export declare function createMemoryProvider(graph: MemoryGraph): AdjacencyProvider;
20
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/query/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAY,aAAa,EAAE,MAAM,aAAa,CAAC;AAE3E,OAAO,EAIL,KAAK,iBAAiB,EAEvB,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAC/C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CA8C1E"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * An in-memory `AdjacencyProvider`.
3
+ *
4
+ * The reason the interface exists. Building one of these from a `BuildResult` is
5
+ * four lines and needs no file, no schema, no writer and no worker — so the
6
+ * traversal and query tests below it exercise the same code paths production
7
+ * uses, without any of the setup that would otherwise make them slow enough to
8
+ * skip.
9
+ */
10
+ import { applyAdjacencyOptions, DEFAULT_NODE_SET_LIMIT, } from "./provider.js";
11
+ import { IR_SCHEMA_VERSION } from "../store/schema.js";
12
+ export function createMemoryProvider(graph) {
13
+ const nodes = new Map(graph.nodes.map((n) => [n.id, n]));
14
+ const out = new Map();
15
+ const inc = new Map();
16
+ for (const edge of graph.edges) {
17
+ (out.get(edge.from) ?? out.set(edge.from, []).get(edge.from)).push(edge);
18
+ (inc.get(edge.to) ?? inc.set(edge.to, []).get(edge.to)).push(edge);
19
+ }
20
+ const stamp = {
21
+ commitSha: graph.commitSha ?? null,
22
+ graphBuiltAt: graph.graphBuiltAt ?? null,
23
+ irSchemaVersion: IR_SCHEMA_VERSION,
24
+ };
25
+ // Indexed once rather than filtered per call: the contract engine asks for
26
+ // three types in a row, and a linear scan each time turns an O(n) report into
27
+ // an O(3n) one for no reason.
28
+ const byType = new Map();
29
+ for (const node of graph.nodes) {
30
+ let bucket = byType.get(node.type);
31
+ if (bucket === undefined)
32
+ byType.set(node.type, (bucket = []));
33
+ bucket.push(node);
34
+ }
35
+ for (const bucket of byType.values())
36
+ bucket.sort((a, b) => a.id.localeCompare(b.id));
37
+ return {
38
+ node: (id) => nodes.get(id),
39
+ outgoing: (id, options) => applyAdjacencyOptions(out.get(id) ?? [], options),
40
+ incoming: (id, options) => applyAdjacencyOptions(inc.get(id) ?? [], options),
41
+ nodesOfType: (type, limit = DEFAULT_NODE_SET_LIMIT) => {
42
+ const all = byType.get(type) ?? [];
43
+ return { nodes: all.slice(0, limit), truncated: all.length > limit };
44
+ },
45
+ unresolvedRefs: (options) => {
46
+ const classified = options?.classified ?? true;
47
+ const all = (graph.unresolved ?? []).filter((r) => !classified || r.attrs !== undefined);
48
+ const limit = options?.limit;
49
+ const truncated = limit !== undefined && all.length > limit;
50
+ return { refs: truncated ? all.slice(0, limit) : all, truncated };
51
+ },
52
+ baseStamp: () => stamp,
53
+ };
54
+ }
55
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/query/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAIvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE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,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;YACzF,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;YAC7B,MAAM,SAAS,GAAG,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC;YAC5D,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC;QACpE,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK;KACvB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * `AdjacencyProvider` — the interface every traversal is written against.
3
+ *
4
+ * Not an abstraction for its own sake. Two consequences follow from it and both
5
+ * are structural:
6
+ *
7
+ * 1. **Most of the engine's tests need no database.** A traversal written
8
+ * against SQLite is a traversal that can only be tested with a file, a
9
+ * schema, a writer and eventually a worker thread. Written against this, the
10
+ * same code runs over an in-memory graph built in four lines.
11
+ *
12
+ * 2. **Traversal stays identical across backends.** §11.8 chose application-code
13
+ * traversal over recursive CTEs precisely so that decay scoring, budgets and
14
+ * per-edge weights work the same on SQLite and Postgres. That only holds if
15
+ * the traversal never sees which one it is talking to.
16
+ *
17
+ * `incoming()` takes a limit and a ranking rather than returning everything.
18
+ * That is not politeness: the prior-art graphs measured for this build have a
19
+ * max in-degree of **1,036** (`append`), and materialising every neighbour of a
20
+ * hub turns a 200-node budget into a 10,000-row read.
21
+ */
22
+ import type { EdgeType, IREdge, IRNode, NodeType, ResolutionLevel, UnresolvedRef } from "@descryy/ir";
23
+ export interface AdjacencyOptions {
24
+ readonly types?: readonly EdgeType[];
25
+ /**
26
+ * Cap on returned edges, applied *after* ranking by resolution then confidence.
27
+ * A cap without a ranking keeps whichever rows the index reached first, which
28
+ * is both arbitrary and unstable between runs.
29
+ */
30
+ readonly limit?: number;
31
+ /** Drop edges below this confidence before ranking. */
32
+ readonly minConfidence?: number;
33
+ }
34
+ /**
35
+ * What every query response carries — §27.3's staleness rule.
36
+ *
37
+ * Threaded through from the start on purpose. Retrofitting a stamp through six
38
+ * return shapes later is the kind of change that gets deferred once and then
39
+ * never made, and a query layer that cannot say *how old and how well resolved*
40
+ * its answer is cannot support the honesty rules that the product is.
41
+ */
42
+ export interface GraphStamp {
43
+ /** The commit the graph was built from. Null on an empty graph. */
44
+ readonly commitSha: string | null;
45
+ /** Epoch ms of the most recent write. Null on an empty graph. */
46
+ readonly graphBuiltAt: number | null;
47
+ readonly irSchemaVersion: number;
48
+ /**
49
+ * The lowest resolution anything in *this answer* rests on.
50
+ *
51
+ * Per architecture principle 3 the reliability class of a finding is capped by
52
+ * the resolution of the edges beneath it, so this is the cap, computed per
53
+ * result rather than declared globally. A result touching one R0 edge is an R0
54
+ * result no matter how well resolved the rest of it is.
55
+ */
56
+ readonly resolutionFloor: ResolutionLevel;
57
+ }
58
+ /** Everything a query returns, so no caller can accidentally drop the disclosure. */
59
+ export interface QueryResult<T> {
60
+ readonly data: T;
61
+ readonly stamp: GraphStamp;
62
+ /** True when a budget or limit stopped the answer short of complete. */
63
+ readonly truncated: boolean;
64
+ /**
65
+ * Things the caller must be told, in plain words — §20.2's "not tested" and
66
+ * "not analysable" categories start here. Never empty for a degraded answer.
67
+ */
68
+ readonly notes: readonly string[];
69
+ }
70
+ /** What `nodesOfType` returned, and whether that was all of them. */
71
+ export interface NodeSet {
72
+ readonly nodes: readonly IRNode[];
73
+ /** True when the limit stopped the answer short. Never silently discarded. */
74
+ readonly truncated: boolean;
75
+ }
76
+ /** What `unresolvedRefs` returned, and whether that was all of them. */
77
+ export interface UnresolvedRefSet {
78
+ readonly refs: readonly UnresolvedRef[];
79
+ readonly truncated: boolean;
80
+ }
81
+ export interface AdjacencyProvider {
82
+ node(id: string): IRNode | undefined;
83
+ outgoing(id: string, options?: AdjacencyOptions): readonly IREdge[];
84
+ incoming(id: string, options?: AdjacencyOptions): readonly IREdge[];
85
+ /**
86
+ * Every node of one type, capped.
87
+ *
88
+ * The one query that is not adjacency, and it is here because a whole class of
89
+ * question cannot start from a seed. *"Which endpoints does the frontend call
90
+ * that no route serves?"* has no node to begin at — the answer is a property
91
+ * of the **set**, and the contract engine, the static-validation checks and
92
+ * the capability-tier generator all need it.
93
+ *
94
+ * Capped, and the cap is reported rather than applied quietly. `API_ENDPOINT`
95
+ * runs to the hundreds and is safe to enumerate; `FUNCTION` on a large
96
+ * monorepo runs to tens of thousands, and a caller that asked for all of them
97
+ * and silently received the first thousand would compute a set property over a
98
+ * sample and report it as a fact.
99
+ */
100
+ nodesOfType(type: NodeType, limit?: number): NodeSet;
101
+ /**
102
+ * Refusal-ledger rows — DEC-243's question grouper reads these. `classified`
103
+ * (default `true`) restricts to rows carrying `attrs` at all, which is every
104
+ * row that could ever become a question; see `store/reader.ts#unresolvedRefs`
105
+ * for why that is a real filter and not an approximation.
106
+ */
107
+ unresolvedRefs(options?: {
108
+ readonly classified?: boolean;
109
+ readonly limit?: number;
110
+ }): UnresolvedRefSet;
111
+ /** Graph-level provenance. The per-result `resolutionFloor` is computed by the query. */
112
+ baseStamp(): Omit<GraphStamp, "resolutionFloor">;
113
+ }
114
+ /** The cap `nodesOfType` applies when a caller names none. */
115
+ export declare const DEFAULT_NODE_SET_LIMIT = 5000;
116
+ /**
117
+ * Rank edges the way every caller wants them: best evidence first, stably.
118
+ *
119
+ * Resolution outranks confidence because they are not the same axis — a
120
+ * type-checked edge at 0.8 is a better fact than a name-matched one at 0.95, and
121
+ * §11A.5 exists because v2.0 could not tell those apart. `from`/`to`/`type`
122
+ * break the final tie so the order is identical between runs.
123
+ */
124
+ export declare function rankEdges(edges: readonly IREdge[]): IREdge[];
125
+ /** Apply type filter, confidence floor, ranking and limit. Shared by both providers. */
126
+ export declare function applyAdjacencyOptions(edges: readonly IREdge[], options?: Ad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