@descryy/core 0.4.0 → 0.5.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 (353) hide show
  1. package/dist/budget/reply.d.ts +11 -46
  2. package/dist/budget/reply.d.ts.map +1 -1
  3. package/dist/budget/reply.js +10 -39
  4. package/dist/budget/reply.js.map +1 -1
  5. package/dist/budget/size.d.ts +2 -21
  6. package/dist/budget/size.d.ts.map +1 -1
  7. package/dist/budget/size.js +3 -24
  8. package/dist/budget/size.js.map +1 -1
  9. package/dist/capabilities/preconditions.d.ts +7 -68
  10. package/dist/capabilities/preconditions.d.ts.map +1 -1
  11. package/dist/capabilities/preconditions.js +6 -57
  12. package/dist/capabilities/preconditions.js.map +1 -1
  13. package/dist/contracts/engine.d.ts +23 -11
  14. package/dist/contracts/engine.d.ts.map +1 -1
  15. package/dist/contracts/engine.js +23 -11
  16. package/dist/contracts/engine.js.map +1 -1
  17. package/dist/contracts/orphans.d.ts +18 -122
  18. package/dist/contracts/orphans.d.ts.map +1 -1
  19. package/dist/contracts/orphans.js +36 -134
  20. package/dist/contracts/orphans.js.map +1 -1
  21. package/dist/contracts/paths.d.ts +4 -114
  22. package/dist/contracts/paths.d.ts.map +1 -1
  23. package/dist/contracts/paths.js +7 -140
  24. package/dist/contracts/paths.js.map +1 -1
  25. package/dist/contracts/shapes.d.ts +13 -66
  26. package/dist/contracts/shapes.d.ts.map +1 -1
  27. package/dist/contracts/shapes.js +20 -91
  28. package/dist/contracts/shapes.js.map +1 -1
  29. package/dist/governance/budget.d.ts +12 -48
  30. package/dist/governance/budget.d.ts.map +1 -1
  31. package/dist/governance/budget.js +12 -48
  32. package/dist/governance/budget.js.map +1 -1
  33. package/dist/governance/candidate-boundary.d.ts +4 -32
  34. package/dist/governance/candidate-boundary.d.ts.map +1 -1
  35. package/dist/governance/candidate-boundary.js +4 -32
  36. package/dist/governance/candidate-boundary.js.map +1 -1
  37. package/dist/governance/escalation.d.ts +7 -45
  38. package/dist/governance/escalation.d.ts.map +1 -1
  39. package/dist/governance/escalation.js +7 -45
  40. package/dist/governance/escalation.js.map +1 -1
  41. package/dist/governance/fact-boundary.d.ts +7 -49
  42. package/dist/governance/fact-boundary.d.ts.map +1 -1
  43. package/dist/governance/fact-boundary.js +5 -43
  44. package/dist/governance/fact-boundary.js.map +1 -1
  45. package/dist/governance/finding-funnel.d.ts +11 -72
  46. package/dist/governance/finding-funnel.d.ts.map +1 -1
  47. package/dist/governance/finding-funnel.js +9 -68
  48. package/dist/governance/finding-funnel.js.map +1 -1
  49. package/dist/graph/build.d.ts +9 -90
  50. package/dist/graph/build.d.ts.map +1 -1
  51. package/dist/graph/build.js +15 -62
  52. package/dist/graph/build.js.map +1 -1
  53. package/dist/graph/cross-language.d.ts +4 -43
  54. package/dist/graph/cross-language.d.ts.map +1 -1
  55. package/dist/graph/cross-language.js +9 -77
  56. package/dist/graph/cross-language.js.map +1 -1
  57. package/dist/graph/merge.d.ts +8 -88
  58. package/dist/graph/merge.d.ts.map +1 -1
  59. package/dist/graph/merge.js +9 -93
  60. package/dist/graph/merge.js.map +1 -1
  61. package/dist/graph/observed-tests.d.ts +7 -68
  62. package/dist/graph/observed-tests.d.ts.map +1 -1
  63. package/dist/graph/observed-tests.js +5 -60
  64. package/dist/graph/observed-tests.js.map +1 -1
  65. package/dist/graph/persist.d.ts +2 -25
  66. package/dist/graph/persist.d.ts.map +1 -1
  67. package/dist/graph/persist.js +2 -25
  68. package/dist/graph/persist.js.map +1 -1
  69. package/dist/graph/runtime-confirmation.d.ts +14 -91
  70. package/dist/graph/runtime-confirmation.d.ts.map +1 -1
  71. package/dist/graph/runtime-confirmation.js +19 -103
  72. package/dist/graph/runtime-confirmation.js.map +1 -1
  73. package/dist/ledger/mint.d.ts +9 -43
  74. package/dist/ledger/mint.d.ts.map +1 -1
  75. package/dist/ledger/mint.js +15 -65
  76. package/dist/ledger/mint.js.map +1 -1
  77. package/dist/ledger/resolve.d.ts +13 -81
  78. package/dist/ledger/resolve.d.ts.map +1 -1
  79. package/dist/ledger/resolve.js +13 -76
  80. package/dist/ledger/resolve.js.map +1 -1
  81. package/dist/multipr/fingerprint.d.ts +5 -46
  82. package/dist/multipr/fingerprint.d.ts.map +1 -1
  83. package/dist/multipr/fingerprint.js +22 -74
  84. package/dist/multipr/fingerprint.js.map +1 -1
  85. package/dist/multipr/hidden-dependency.d.ts +13 -73
  86. package/dist/multipr/hidden-dependency.d.ts.map +1 -1
  87. package/dist/multipr/hidden-dependency.js +12 -63
  88. package/dist/multipr/hidden-dependency.js.map +1 -1
  89. package/dist/multipr/mechanical.d.ts +25 -160
  90. package/dist/multipr/mechanical.d.ts.map +1 -1
  91. package/dist/multipr/mechanical.js +21 -137
  92. package/dist/multipr/mechanical.js.map +1 -1
  93. package/dist/multipr/migration-heads.d.ts +18 -105
  94. package/dist/multipr/migration-heads.d.ts.map +1 -1
  95. package/dist/multipr/migration-heads.js +15 -84
  96. package/dist/multipr/migration-heads.js.map +1 -1
  97. package/dist/multipr/overlap.d.ts +16 -94
  98. package/dist/multipr/overlap.d.ts.map +1 -1
  99. package/dist/multipr/overlap.js +25 -105
  100. package/dist/multipr/overlap.js.map +1 -1
  101. package/dist/multipr/scope-store.d.ts +15 -80
  102. package/dist/multipr/scope-store.d.ts.map +1 -1
  103. package/dist/multipr/scope-store.js +17 -87
  104. package/dist/multipr/scope-store.js.map +1 -1
  105. package/dist/multipr/superseded.d.ts +10 -95
  106. package/dist/multipr/superseded.d.ts.map +1 -1
  107. package/dist/multipr/superseded.js +7 -60
  108. package/dist/multipr/superseded.js.map +1 -1
  109. package/dist/query/confirmed-facts.d.ts +12 -58
  110. package/dist/query/confirmed-facts.d.ts.map +1 -1
  111. package/dist/query/confirmed-facts.js +8 -47
  112. package/dist/query/confirmed-facts.js.map +1 -1
  113. package/dist/query/declared-value-closure.d.ts +13 -104
  114. package/dist/query/declared-value-closure.d.ts.map +1 -1
  115. package/dist/query/declared-value-closure.js +15 -104
  116. package/dist/query/declared-value-closure.js.map +1 -1
  117. package/dist/query/memory.d.ts +4 -16
  118. package/dist/query/memory.d.ts.map +1 -1
  119. package/dist/query/memory.js +9 -22
  120. package/dist/query/memory.js.map +1 -1
  121. package/dist/query/prominence.d.ts +6 -55
  122. package/dist/query/prominence.d.ts.map +1 -1
  123. package/dist/query/prominence.js +6 -55
  124. package/dist/query/prominence.js.map +1 -1
  125. package/dist/query/provider.d.ts +27 -93
  126. package/dist/query/provider.d.ts.map +1 -1
  127. package/dist/query/provider.js +8 -29
  128. package/dist/query/provider.js.map +1 -1
  129. package/dist/query/queries.d.ts +15 -65
  130. package/dist/query/queries.d.ts.map +1 -1
  131. package/dist/query/queries.js +30 -104
  132. package/dist/query/queries.js.map +1 -1
  133. package/dist/query/refusal-fetch.d.ts +8 -85
  134. package/dist/query/refusal-fetch.d.ts.map +1 -1
  135. package/dist/query/refusal-fetch.js +11 -93
  136. package/dist/query/refusal-fetch.js.map +1 -1
  137. package/dist/query/refusal-questions.d.ts +17 -92
  138. package/dist/query/refusal-questions.d.ts.map +1 -1
  139. package/dist/query/refusal-questions.js +14 -78
  140. package/dist/query/refusal-questions.js.map +1 -1
  141. package/dist/query/resolution-floor.d.ts +3 -23
  142. package/dist/query/resolution-floor.d.ts.map +1 -1
  143. package/dist/query/resolution-floor.js +3 -23
  144. package/dist/query/resolution-floor.js.map +1 -1
  145. package/dist/query/root-cause-score.d.ts +11 -161
  146. package/dist/query/root-cause-score.d.ts.map +1 -1
  147. package/dist/query/root-cause-score.js +6 -137
  148. package/dist/query/root-cause-score.js.map +1 -1
  149. package/dist/query/row-closure-picture.d.ts +5 -67
  150. package/dist/query/row-closure-picture.d.ts.map +1 -1
  151. package/dist/query/row-closure-picture.js +6 -67
  152. package/dist/query/row-closure-picture.js.map +1 -1
  153. package/dist/query/similar-incidents.d.ts +6 -41
  154. package/dist/query/similar-incidents.d.ts.map +1 -1
  155. package/dist/query/similar-incidents.js +15 -69
  156. package/dist/query/similar-incidents.js.map +1 -1
  157. package/dist/query/sqlite.d.ts +3 -7
  158. package/dist/query/sqlite.d.ts.map +1 -1
  159. package/dist/query/sqlite.js +9 -19
  160. package/dist/query/sqlite.js.map +1 -1
  161. package/dist/query/test-coverage.d.ts +5 -45
  162. package/dist/query/test-coverage.d.ts.map +1 -1
  163. package/dist/query/test-coverage.js +10 -53
  164. package/dist/query/test-coverage.js.map +1 -1
  165. package/dist/query/traverse.d.ts +22 -126
  166. package/dist/query/traverse.d.ts.map +1 -1
  167. package/dist/query/traverse.js +25 -126
  168. package/dist/query/traverse.js.map +1 -1
  169. package/dist/query/unresolved.d.ts +19 -164
  170. package/dist/query/unresolved.d.ts.map +1 -1
  171. package/dist/query/unresolved.js +11 -138
  172. package/dist/query/unresolved.js.map +1 -1
  173. package/dist/query/verification-status.d.ts +12 -109
  174. package/dist/query/verification-status.d.ts.map +1 -1
  175. package/dist/query/verification-status.js +9 -99
  176. package/dist/query/verification-status.js.map +1 -1
  177. package/dist/recording/migrate.d.ts +4 -10
  178. package/dist/recording/migrate.d.ts.map +1 -1
  179. package/dist/recording/migrate.js +4 -10
  180. package/dist/recording/migrate.js.map +1 -1
  181. package/dist/recording/reader.d.ts +2 -7
  182. package/dist/recording/reader.d.ts.map +1 -1
  183. package/dist/recording/reader.js +2 -7
  184. package/dist/recording/reader.js.map +1 -1
  185. package/dist/recording/redact.d.ts +6 -57
  186. package/dist/recording/redact.d.ts.map +1 -1
  187. package/dist/recording/redact.js +8 -64
  188. package/dist/recording/redact.js.map +1 -1
  189. package/dist/recording/schema.d.ts +3 -38
  190. package/dist/recording/schema.d.ts.map +1 -1
  191. package/dist/recording/schema.js +3 -38
  192. package/dist/recording/schema.js.map +1 -1
  193. package/dist/recording/writer.d.ts +11 -74
  194. package/dist/recording/writer.d.ts.map +1 -1
  195. package/dist/recording/writer.js +3 -43
  196. package/dist/recording/writer.js.map +1 -1
  197. package/dist/scoping/fanout.d.ts +6 -68
  198. package/dist/scoping/fanout.d.ts.map +1 -1
  199. package/dist/scoping/fanout.js +6 -68
  200. package/dist/scoping/fanout.js.map +1 -1
  201. package/dist/scoping/score.d.ts +20 -70
  202. package/dist/scoping/score.d.ts.map +1 -1
  203. package/dist/scoping/score.js +20 -70
  204. package/dist/scoping/score.js.map +1 -1
  205. package/dist/scoping/tiers.d.ts +4 -16
  206. package/dist/scoping/tiers.d.ts.map +1 -1
  207. package/dist/scoping/tiers.js +4 -16
  208. package/dist/scoping/tiers.js.map +1 -1
  209. package/dist/scoping/traverse.d.ts +3 -25
  210. package/dist/scoping/traverse.d.ts.map +1 -1
  211. package/dist/scoping/traverse.js +14 -49
  212. package/dist/scoping/traverse.js.map +1 -1
  213. package/dist/scoping/weights.d.ts +10 -74
  214. package/dist/scoping/weights.d.ts.map +1 -1
  215. package/dist/scoping/weights.js +14 -86
  216. package/dist/scoping/weights.js.map +1 -1
  217. package/dist/sources/confirmed/incidents.d.ts +5 -35
  218. package/dist/sources/confirmed/incidents.d.ts.map +1 -1
  219. package/dist/sources/confirmed/incidents.js +14 -48
  220. package/dist/sources/confirmed/incidents.js.map +1 -1
  221. package/dist/sources/git/diff.d.ts +71 -65
  222. package/dist/sources/git/diff.d.ts.map +1 -1
  223. package/dist/sources/git/diff.js +136 -83
  224. package/dist/sources/git/diff.js.map +1 -1
  225. package/dist/sources/git/env.d.ts +7 -0
  226. package/dist/sources/git/env.d.ts.map +1 -1
  227. package/dist/sources/git/env.js +10 -11
  228. package/dist/sources/git/env.js.map +1 -1
  229. package/dist/sources/git/history.d.ts +64 -84
  230. package/dist/sources/git/history.d.ts.map +1 -1
  231. package/dist/sources/git/history.js +141 -112
  232. package/dist/sources/git/history.js.map +1 -1
  233. package/dist/sources/git/incidents.d.ts +13 -75
  234. package/dist/sources/git/incidents.d.ts.map +1 -1
  235. package/dist/sources/git/incidents.js +21 -91
  236. package/dist/sources/git/incidents.js.map +1 -1
  237. package/dist/sources/git/index.d.ts +5 -3
  238. package/dist/sources/git/index.d.ts.map +1 -1
  239. package/dist/sources/git/index.js +3 -2
  240. package/dist/sources/git/index.js.map +1 -1
  241. package/dist/sources/git/source.d.ts +9 -79
  242. package/dist/sources/git/source.d.ts.map +1 -1
  243. package/dist/sources/git/source.js +33 -133
  244. package/dist/sources/git/source.js.map +1 -1
  245. package/dist/sources/migrations/across-change.d.ts +94 -0
  246. package/dist/sources/migrations/across-change.d.ts.map +1 -0
  247. package/dist/sources/migrations/across-change.js +278 -0
  248. package/dist/sources/migrations/across-change.js.map +1 -0
  249. package/dist/sources/migrations/dialects.d.ts +20 -36
  250. package/dist/sources/migrations/dialects.d.ts.map +1 -1
  251. package/dist/sources/migrations/dialects.js +11 -36
  252. package/dist/sources/migrations/dialects.js.map +1 -1
  253. package/dist/sources/migrations/index.d.ts +3 -1
  254. package/dist/sources/migrations/index.d.ts.map +1 -1
  255. package/dist/sources/migrations/index.js +2 -1
  256. package/dist/sources/migrations/index.js.map +1 -1
  257. package/dist/sources/migrations/read.d.ts +14 -79
  258. package/dist/sources/migrations/read.d.ts.map +1 -1
  259. package/dist/sources/migrations/read.js +14 -89
  260. package/dist/sources/migrations/read.js.map +1 -1
  261. package/dist/sources/workspace/workspace.d.ts +6 -42
  262. package/dist/sources/workspace/workspace.d.ts.map +1 -1
  263. package/dist/sources/workspace/workspace.js +10 -53
  264. package/dist/sources/workspace/workspace.js.map +1 -1
  265. package/dist/store/driver/driver.d.ts +9 -38
  266. package/dist/store/driver/driver.d.ts.map +1 -1
  267. package/dist/store/driver/driver.js +4 -22
  268. package/dist/store/driver/driver.js.map +1 -1
  269. package/dist/store/driver/node-sqlite.d.ts +3 -12
  270. package/dist/store/driver/node-sqlite.d.ts.map +1 -1
  271. package/dist/store/driver/node-sqlite.js +4 -18
  272. package/dist/store/driver/node-sqlite.js.map +1 -1
  273. package/dist/store/index.d.ts +2 -7
  274. package/dist/store/index.d.ts.map +1 -1
  275. package/dist/store/index.js +4 -10
  276. package/dist/store/index.js.map +1 -1
  277. package/dist/store/migrate.d.ts +14 -50
  278. package/dist/store/migrate.d.ts.map +1 -1
  279. package/dist/store/migrate.js +15 -52
  280. package/dist/store/migrate.js.map +1 -1
  281. package/dist/store/reader.d.ts +19 -84
  282. package/dist/store/reader.d.ts.map +1 -1
  283. package/dist/store/reader.js +25 -92
  284. package/dist/store/reader.js.map +1 -1
  285. package/dist/store/schema.d.ts +14 -76
  286. package/dist/store/schema.d.ts.map +1 -1
  287. package/dist/store/schema.js +14 -76
  288. package/dist/store/schema.js.map +1 -1
  289. package/dist/store/writer.d.ts +14 -88
  290. package/dist/store/writer.d.ts.map +1 -1
  291. package/dist/store/writer.js +29 -123
  292. package/dist/store/writer.js.map +1 -1
  293. package/dist/tiers/certify.d.ts +46 -281
  294. package/dist/tiers/certify.d.ts.map +1 -1
  295. package/dist/tiers/certify.js +46 -226
  296. package/dist/tiers/certify.js.map +1 -1
  297. package/dist/tiers/ladder.d.ts +7 -51
  298. package/dist/tiers/ladder.d.ts.map +1 -1
  299. package/dist/tiers/ladder.js +13 -89
  300. package/dist/tiers/ladder.js.map +1 -1
  301. package/dist/validation/attributes.d.ts +6 -55
  302. package/dist/validation/attributes.d.ts.map +1 -1
  303. package/dist/validation/attributes.js +6 -55
  304. package/dist/validation/attributes.js.map +1 -1
  305. package/dist/validation/config-graph.d.ts +7 -56
  306. package/dist/validation/config-graph.d.ts.map +1 -1
  307. package/dist/validation/config-graph.js +15 -61
  308. package/dist/validation/config-graph.js.map +1 -1
  309. package/dist/validation/env.d.ts +7 -1
  310. package/dist/validation/env.d.ts.map +1 -1
  311. package/dist/validation/env.js +3 -1
  312. package/dist/validation/env.js.map +1 -1
  313. package/dist/validation/join-substitution.d.ts +22 -120
  314. package/dist/validation/join-substitution.d.ts.map +1 -1
  315. package/dist/validation/join-substitution.js +13 -90
  316. package/dist/validation/join-substitution.js.map +1 -1
  317. package/dist/validation/migration-integrity.d.ts +11 -72
  318. package/dist/validation/migration-integrity.d.ts.map +1 -1
  319. package/dist/validation/migration-integrity.js +16 -79
  320. package/dist/validation/migration-integrity.js.map +1 -1
  321. package/dist/validation/migrations.d.ts +22 -101
  322. package/dist/validation/migrations.d.ts.map +1 -1
  323. package/dist/validation/migrations.js +19 -83
  324. package/dist/validation/migrations.js.map +1 -1
  325. package/dist/validation/nodes.d.ts +3 -1
  326. package/dist/validation/nodes.d.ts.map +1 -1
  327. package/dist/validation/nodes.js +3 -1
  328. package/dist/validation/nodes.js.map +1 -1
  329. package/dist/validation/rollback.d.ts +10 -73
  330. package/dist/validation/rollback.d.ts.map +1 -1
  331. package/dist/validation/rollback.js +15 -82
  332. package/dist/validation/rollback.js.map +1 -1
  333. package/dist/validation/route-drift.d.ts +9 -62
  334. package/dist/validation/route-drift.d.ts.map +1 -1
  335. package/dist/validation/route-drift.js +7 -52
  336. package/dist/validation/route-drift.js.map +1 -1
  337. package/dist/validation/sources.d.ts +16 -94
  338. package/dist/validation/sources.d.ts.map +1 -1
  339. package/dist/validation/sources.js +51 -147
  340. package/dist/validation/sources.js.map +1 -1
  341. package/dist/worker/pool.d.ts +6 -45
  342. package/dist/worker/pool.d.ts.map +1 -1
  343. package/dist/worker/pool.js +5 -42
  344. package/dist/worker/pool.js.map +1 -1
  345. package/dist/worker/protocol.d.ts +7 -20
  346. package/dist/worker/protocol.d.ts.map +1 -1
  347. package/dist/worker/protocol.js +3 -10
  348. package/dist/worker/protocol.js.map +1 -1
  349. package/dist/worker/traversal.worker.d.ts +2 -21
  350. package/dist/worker/traversal.worker.d.ts.map +1 -1
  351. package/dist/worker/traversal.worker.js +4 -23
  352. package/dist/worker/traversal.worker.js.map +1 -1
  353. package/package.json +11 -2
@@ -1,40 +1,10 @@
1
- /**
2
- * The hard per-run budget — §41 rule 16, `ai-layer-plan.md` §11 (Phase 4,
3
- * P17/P18). `ai-governance-spec.md` §8 names this explicitly as *not* its
4
- * document's job: *"a property of the harness (Phase 4, P17/P18), not of a
5
- * per-finding gate... Full spec: Phase 4 (P17), not this document."* This
6
- * module is that property.
7
- *
8
- * *"Enforced by the runtime harness, not by the AI's own judgment of when to
9
- * stop"* (`descry-ai-layer.md`, "Execution budget"). A cap the model can
10
- * reason its way past is not a cap (§41 rule 16's own words) — so, same as
11
- * G1–G4, this is a pure function the pipeline calls, never a prompt
12
- * instruction.
13
- *
14
- * ## Four caps, two scopes
15
- *
16
- * `ai-layer-plan.md` §11 names four: *"max turns per investigation · max
17
- * cost per run · max concurrent open hypotheses · max tool calls per
18
- * hypothesis."* Two are per-run (cost, concurrency); two are per-hypothesis
19
- * (turns, tool calls) and are checked against every currently-open
20
- * hypothesis independently — one hypothesis running long does not budget-fail
21
- * a sibling that has spent nothing.
22
- *
23
- * ## The default values
24
- *
25
- * `documents/architecture/investigation-budget-spec.md` (P17) is where these
26
- * are ruled and justified; this module imports them from there in spirit —
27
- * they are declared once, here, because the spec document is prose and this
28
- * is the value the harness actually reads. A caller may always supply its
29
- * own {@link InvestigationBudget}; the exported default is a starting point,
30
- * tuned from data, the same convention `CLAUDE.md` already applies to node
31
- * budgets.
32
- */
33
- /**
34
- * P17's ruled starting values — `documents/architecture/investigation-budget-spec.md`.
35
- * Not a measurement; a starting point to tune from real runs, same as the
36
- * node budgets `CLAUDE.md` already treats this way.
37
- */
1
+ /** Hard per-run budget — §41 rule 16, ai-layer-plan §11 P17/P18. Enforced
2
+ * by the harness as a pure function (same as G1-G4), never the model's own
3
+ * judgment of when to stop. Four caps, two scopes: per-run (cost,
4
+ * concurrency) and per-hypothesis (turns, tool calls — checked against each
5
+ * open hypothesis independently). Defaults are a tuning starting point (P17). */
6
+ /** P17's starting values (`investigation-budget-spec.md`) — not a
7
+ * measurement, tuned from real runs like `CLAUDE.md`'s node budgets. */
38
8
  export const DEFAULT_INVESTIGATION_BUDGET = {
39
9
  maxTurnsPerInvestigation: 8,
40
10
  maxToolCallsPerHypothesis: 6,
@@ -47,10 +17,8 @@ export const BUDGET_CAP_NAMES = [
47
17
  "maxConcurrentOpenHypotheses",
48
18
  "costCeilingPerRunUsd",
49
19
  ];
50
- /**
51
- * Check `usage` against `budget`. Never throws — this is a check, not an
52
- * execution of the thing it is checking, same posture as G1–G4.
53
- */
20
+ /** Checks `usage` against `budget`. Never throws — a check, not an
21
+ * execution of the thing being checked (same posture as G1–G4). */
54
22
  export function checkRunBudget(budget, usage) {
55
23
  const exceeded = [];
56
24
  if (usage.costSpentUsd > budget.costCeilingPerRunUsd) {
@@ -87,13 +55,9 @@ export function checkRunBudget(budget, usage) {
87
55
  }
88
56
  return { withinBudget: exceeded.length === 0, exceeded };
89
57
  }
90
- /**
91
- * Whether a specific hypothesis has reached its per-hypothesis round limit —
92
- * the input `../../ir/src/hypothesis.ts`'s `deriveHypothesisState` needs for
93
- * its `roundLimitReached` field. A thin, named convenience over
94
- * {@link checkRunBudget} so a caller does not have to re-derive "does this
95
- * one hypothesis's own cap show up in `exceeded`" by hand.
96
- */
58
+ /** Whether one hypothesis hit its round limit — feeds
59
+ * `hypothesis.ts`'s `deriveHypothesisState.roundLimitReached`. Thin
60
+ * convenience over {@link checkRunBudget}. */
97
61
  export function hypothesisRoundLimitReached(budget, usage) {
98
62
  return (usage.turnsSpent > budget.maxTurnsPerInvestigation ||
99
63
  usage.toolCallsSpent > budget.maxToolCallsPerHypothesis);
@@ -1 +1 @@
1
- {"version":3,"file":"budget.js","sourceRoot":"","sources":["../../src/governance/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAcH;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAwB;IAC/D,wBAAwB,EAAE,CAAC;IAC3B,yBAAyB,EAAE,CAAC;IAC5B,2BAA2B,EAAE,CAAC;IAC9B,oBAAoB,EAAE,GAAG;CAC1B,CAAC;AAgBF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,0BAA0B;IAC1B,2BAA2B;IAC3B,6BAA6B;IAC7B,sBAAsB;CACd,CAAC;AAkBX;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAA2B,E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AAC,cAAc,EAAE,CAAC;QAC9C,IAAI,UAAU,CAAC,UAAU,GAAG,MAAM,CAAC,wBAAwB,EAAE,CAAC;YAC5D,QAAQ,CAAC,IAAI,CAAC;gBACZ,GAAG,EAAE,0BAA0B;gBAC/B,KAAK,EAAE,MAAM,CAAC,wBAAwB;gBACtC,MAAM,EAAE,UAAU,CAAC,UAAU;gBAC7B,YAAY,EAAE,UAAU,CAAC,YAAY;aACtC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,UAAU,CAAC,cAAc,GAAG,MAAM,CAAC,yBAAyB,EAAE,CAAC;YACjE,QAAQ,CAAC,IAAI,CAAC;gBACZ,GAAG,EAAE,2BAA2B;gBAChC,KAAK,EAAE,MAAM,CAAC,yBAAyB;gBACvC,MAAM,EAAE,UAAU,CAAC,cAAc;gBACjC,YAAY,EAAE,UAAU,CAAC,YAAY;aACtC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;AAC3D,CAAC;AAED;;+CAE+C;AAC/C,MAAM,UAAU,2BAA2B,CACzC,MAA2B,EAC3B,KAA4B;IAE5B,OAAO,CACL,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,wBAAwB;QAClD,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,yBAAyB,CACxD,CAAC;AACJ,CAAC"}
@@ -1,30 +1,6 @@
1
1
  /**
2
- * G2 — the candidate boundary (`ai-governance-spec.md` §3, `ai-layer-plan.md` §5).
3
- *
4
- * **The plan (stage 6) may only contain items from the deterministic
5
- * candidate set stages 3–5 produced.** Stage 5 (risk prioritization) is
6
- * itself deterministic — "scores in, ordering out. Does not invent
7
- * candidates" (`ai-layer-plan.md` §1) — so a plan item naming a node outside
8
- * that set could only have been invented by stage 6's own model slot, and is
9
- * rejected outright rather than down-ranked.
10
- *
11
- * Same shape as G1, one stage later, and built as the same kind of pure
12
- * function: `ai-governance-spec.md` §10 — "candidate-set membership checking
13
- * on the plan... no new tool surface, no new IR type." A candidate set is a
14
- * set of node ids; this module does not care how stages 3–5 produced it.
15
- *
16
- * ## Reject the item, not the plan
17
- *
18
- * `ai-governance-spec.md` §3's own negative control: "a plan naming a target
19
- * outside the candidate set. G2 must reject the item, not the whole plan —
20
- * the rest of the plan proceeds if the remaining items are valid." So the
21
- * result partitions the plan rather than failing it wholesale.
22
- *
23
- * `PlanItem` is deliberately the smallest shape G2 needs — one node id.
24
- * Phase 3's real plan item will carry more (a rationale, a priority, a test
25
- * strategy); the generic parameter lets a caller pass its real type through
26
- * unchanged and get it back in `accepted`/`rejected`, rather than this
27
- * module owning a plan-item type the pipeline would then have to conform to.
2
+ * G2, the candidate boundary (ai-governance-spec.md §3, ai-layer-plan.md §5): the stage-6 plan may only contain items from the deterministic candidate set stages 3-5 produced.
3
+ * A plan item naming an outside node can only have been invented by stage 6's model slot, rejected outright — the item, not the whole plan (§3's negative control). `PlanItem` is just a node id; the generic parameter passes a caller's real type through unchanged.
28
4
  */
29
5
  /** The smallest shape G2 needs from a plan item: what node it targets. */
30
6
  export interface PlanItem {
@@ -39,11 +15,7 @@ export interface CandidateBoundaryResult<T extends PlanItem> {
39
15
  readonly accepted: readonly T[];
40
16
  readonly rejected: readonly RejectedPlanItem<T>[];
41
17
  }
42
- /**
43
- * Check every item in `plan` against `candidateNodeIds` — the deterministic
44
- * set stages 3–5 produced. An item whose `targetNodeId` is not in that set
45
- * is rejected with a reason; the rest of the plan is unaffected. Never
46
- * throws — this is a check, not an execution of the thing it is checking.
47
- */
18
+ /** Check every plan item against candidateNodeIds; an item outside the set
19
+ * is rejected with a reason, the rest unaffected. Never throws. */
48
20
  export declare function checkCandidateBoundary<T extends PlanItem>(plan: readonly T[], candidateNodeIds: ReadonlySet<string>): CandidateBoundaryResult<T>;
49
21
  //# sourceMappingURL=candidate-boundary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-boundary.d.ts","sourceRoot":"","sources":["../../src/governance/candidate-boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,QAAQ;IAClD,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,QAAQ;IACzD,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,QAAQ,EACvD,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,GACpC,uBAAuB,CAAC,CAAC,CAAC,CAgB5B"}
1
+ {"version":3,"file":"candidate-boundary.d.ts","sourceRoot":"","sources":["../../src/governance/candidate-boundary.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,QAAQ;IAClD,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,QAAQ;IACzD,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;CACnD;AAED;oEACoE;AACpE,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,QAAQ,EACvD,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,GACpC,uBAAuB,CAAC,CAAC,CAAC,CAgB5B"}
@@ -1,37 +1,9 @@
1
1
  /**
2
- * G2 — the candidate boundary (`ai-governance-spec.md` §3, `ai-layer-plan.md` §5).
3
- *
4
- * **The plan (stage 6) may only contain items from the deterministic
5
- * candidate set stages 3–5 produced.** Stage 5 (risk prioritization) is
6
- * itself deterministic — "scores in, ordering out. Does not invent
7
- * candidates" (`ai-layer-plan.md` §1) — so a plan item naming a node outside
8
- * that set could only have been invented by stage 6's own model slot, and is
9
- * rejected outright rather than down-ranked.
10
- *
11
- * Same shape as G1, one stage later, and built as the same kind of pure
12
- * function: `ai-governance-spec.md` §10 — "candidate-set membership checking
13
- * on the plan... no new tool surface, no new IR type." A candidate set is a
14
- * set of node ids; this module does not care how stages 3–5 produced it.
15
- *
16
- * ## Reject the item, not the plan
17
- *
18
- * `ai-governance-spec.md` §3's own negative control: "a plan naming a target
19
- * outside the candidate set. G2 must reject the item, not the whole plan —
20
- * the rest of the plan proceeds if the remaining items are valid." So the
21
- * result partitions the plan rather than failing it wholesale.
22
- *
23
- * `PlanItem` is deliberately the smallest shape G2 needs — one node id.
24
- * Phase 3's real plan item will carry more (a rationale, a priority, a test
25
- * strategy); the generic parameter lets a caller pass its real type through
26
- * unchanged and get it back in `accepted`/`rejected`, rather than this
27
- * module owning a plan-item type the pipeline would then have to conform to.
28
- */
29
- /**
30
- * Check every item in `plan` against `candidateNodeIds` — the deterministic
31
- * set stages 3–5 produced. An item whose `targetNodeId` is not in that set
32
- * is rejected with a reason; the rest of the plan is unaffected. Never
33
- * throws — this is a check, not an execution of the thing it is checking.
2
+ * G2, the candidate boundary (ai-governance-spec.md §3, ai-layer-plan.md §5): the stage-6 plan may only contain items from the deterministic candidate set stages 3-5 produced.
3
+ * A plan item naming an outside node can only have been invented by stage 6's model slot, rejected outright — the item, not the whole plan (§3's negative control). `PlanItem` is just a node id; the generic parameter passes a caller's real type through unchanged.
34
4
  */
5
+ /** Check every plan item against candidateNodeIds; an item outside the set
6
+ * is rejected with a reason, the rest unaffected. Never throws. */
35
7
  export function checkCandidateBoundary(plan, candidateNodeIds) {
36
8
  const accepted = [];
37
9
  const rejected = [];
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-boundary.js","sourceRoot":"","sources":["../../src/governance/candidate-boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAkBH;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAkB,EAClB,gBAAqC;IAErC,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,MAAM,QAAQ,GAA0B,EAAE,CAAC;IAE3C,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI;gBACJ,MAAM,EAAE,eAAe,IAAI,CAAC,YAAY,kDAAkD;aAC3F,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC"}
1
+ {"version":3,"file":"candidate-boundary.js","sourceRoot":"","sources":["../../src/governance/candidate-boundary.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkBH;oEACoE;AACpE,MAAM,UAAU,sBAAsB,CACpC,IAAkB,EAClB,gBAAqC;IAErC,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,MAAM,QAAQ,GAA0B,EAAE,CAAC;IAE3C,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI;gBACJ,MAAM,EAAE,eAAe,IAAI,CAAC,YAAY,kDAAkD;aAC3F,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC"}
@@ -1,43 +1,8 @@
1
- /**
2
- * Escalation — §41 rule 17, `ai-layer-plan.md` §11 (Phase 4, P17/P18).
3
- *
4
- * *"AI must escalate to the developer rather than keep investigating
5
- * when..."* — three conditions named in the architecture (budget exhausted,
6
- * a hypothesis stuck past its round limit, unresolved graph/runtime
7
- * contradiction), widened to five in the plan's own §11: *"budget exhausted
8
- * with hypotheses open · unresolved contradictory evidence · a fact only a
9
- * human holds · an action gate reached · every hypothesis refuted with the
10
- * anomaly unexplained."*
11
- *
12
- * Same shape as {@link "./budget.ts"} and G1–G4: a pure function over
13
- * caller-supplied facts, evaluated outside the model, never a prompt telling
14
- * the model when to stop. `ai-layer-plan.md` §0's own words, one layer up:
15
- * *"a rule the model can reason its way past is not a rule."*
16
- *
17
- * ## Four of five inputs are not computed here
18
- *
19
- * Only the budget trigger is derivable from `./budget.ts`'s own output.
20
- * The other four name conditions this module has no way to detect on its
21
- * own, and deliberately does not try to:
22
- *
23
- * - **Unresolved contradictory evidence** — §10's graph-vs-runtime
24
- * contradiction machinery (P21) is what detects a contradiction at all;
25
- * this module only reacts to the caller having found one.
26
- * - **A fact only a human holds** — inherits the `questions` MCP tool /
27
- * `ConfirmedFact` machinery (`packages/core/src/query/refusal-questions.ts`,
28
- * `confirmed-facts.ts`) already built for a different stage. Whether an
29
- * open, unanswered question exists is that machinery's own state, not
30
- * something recomputed here.
31
- * - **An action gate reached** — G5 (`ai-tool-contract.md` §7's two-call
32
- * handshake) already governs whether a write may proceed; this module
33
- * just names the fact of having reached it as one more reason to stop and
34
- * hand control back.
35
- * - **Every hypothesis refuted, anomaly unexplained** — depends on every
36
- * open hypothesis's terminal state (`../../ir/src/hypothesis.ts`) plus a
37
- * judgement that no other explanation covers the original anomaly. The
38
- * "no other explanation" half is not a fact this module can derive from a
39
- * list of rejected hypotheses alone, so it stays a caller-supplied flag.
40
- */
1
+ /** Escalation — §41 rule 17, ai-layer-plan §11 P17/P18. Pure function over
2
+ * caller-supplied facts (like `budget.ts`/G1-G4) — never a prompt telling
3
+ * the model when to stop. Five triggers: budget exhausted w/ open
4
+ * hypotheses (only one computed here); unresolved contradiction; a fact
5
+ * only a human holds; an action gate reached; every hypothesis refuted, anomaly unexplained. */
41
6
  export declare const ESCALATION_TRIGGERS: readonly ["budget-exhausted-with-hypotheses-open", "unresolved-contradictory-evidence", "fact-only-a-human-holds", "action-gate-reached", "every-hypothesis-refuted-unexplained"];
42
7
  export type EscalationTrigger = (typeof ESCALATION_TRIGGERS)[number];
43
8
  export interface EscalationCheckInput {
@@ -54,10 +19,7 @@ export interface EscalationCheckInput {
54
19
  /** Caller-supplied: every hypothesis this run opened has reached `rejected`, and the anomaly that started the investigation still has no confirmed or supported explanation. */
55
20
  readonly allHypothesesRejectedAnomalyUnexplained: boolean;
56
21
  }
57
- /**
58
- * Check `input` against all five triggers. Never throws — a check, not an
59
- * execution of the thing it is checking. More than one trigger may fire in
60
- * the same call; an empty result means the loop may keep running.
61
- */
22
+ /** Checks `input` against all five triggers. Never throws — more than one
23
+ * may fire at once; empty means the loop may keep running. */
62
24
  export declare function checkEscalation(input: EscalationCheckInput): readonly EscalationTrigger[];
63
25
  //# sourceMappingURL=escalation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"escalation.d.ts","sourceRoot":"","sources":["../../src/governance/escalation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;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,EAAE,OAAO,CAAC;CAC3D;AAED;+DAC+D;AAC/D,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,iBAAiB,EAAE,CAoBzF"}
@@ -1,43 +1,8 @@
1
- /**
2
- * Escalation — §41 rule 17, `ai-layer-plan.md` §11 (Phase 4, P17/P18).
3
- *
4
- * *"AI must escalate to the developer rather than keep investigating
5
- * when..."* — three conditions named in the architecture (budget exhausted,
6
- * a hypothesis stuck past its round limit, unresolved graph/runtime
7
- * contradiction), widened to five in the plan's own §11: *"budget exhausted
8
- * with hypotheses open · unresolved contradictory evidence · a fact only a
9
- * human holds · an action gate reached · every hypothesis refuted with the
10
- * anomaly unexplained."*
11
- *
12
- * Same shape as {@link "./budget.ts"} and G1–G4: a pure function over
13
- * caller-supplied facts, evaluated outside the model, never a prompt telling
14
- * the model when to stop. `ai-layer-plan.md` §0's own words, one layer up:
15
- * *"a rule the model can reason its way past is not a rule."*
16
- *
17
- * ## Four of five inputs are not computed here
18
- *
19
- * Only the budget trigger is derivable from `./budget.ts`'s own output.
20
- * The other four name conditions this module has no way to detect on its
21
- * own, and deliberately does not try to:
22
- *
23
- * - **Unresolved contradictory evidence** — §10's graph-vs-runtime
24
- * contradiction machinery (P21) is what detects a contradiction at all;
25
- * this module only reacts to the caller having found one.
26
- * - **A fact only a human holds** — inherits the `questions` MCP tool /
27
- * `ConfirmedFact` machinery (`packages/core/src/query/refusal-questions.ts`,
28
- * `confirmed-facts.ts`) already built for a different stage. Whether an
29
- * open, unanswered question exists is that machinery's own state, not
30
- * something recomputed here.
31
- * - **An action gate reached** — G5 (`ai-tool-contract.md` §7's two-call
32
- * handshake) already governs whether a write may proceed; this module
33
- * just names the fact of having reached it as one more reason to stop and
34
- * hand control back.
35
- * - **Every hypothesis refuted, anomaly unexplained** — depends on every
36
- * open hypothesis's terminal state (`../../ir/src/hypothesis.ts`) plus a
37
- * judgement that no other explanation covers the original anomaly. The
38
- * "no other explanation" half is not a fact this module can derive from a
39
- * list of rejected hypotheses alone, so it stays a caller-supplied flag.
40
- */
1
+ /** Escalation — §41 rule 17, ai-layer-plan §11 P17/P18. Pure function over
2
+ * caller-supplied facts (like `budget.ts`/G1-G4) — never a prompt telling
3
+ * the model when to stop. Five triggers: budget exhausted w/ open
4
+ * hypotheses (only one computed here); unresolved contradiction; a fact
5
+ * only a human holds; an action gate reached; every hypothesis refuted, anomaly unexplained. */
41
6
  export const ESCALATION_TRIGGERS = [
42
7
  "budget-exhausted-with-hypotheses-open",
43
8
  "unresolved-contradictory-evidence",
@@ -45,11 +10,8 @@ export const ESCALATION_TRIGGERS = [
45
10
  "action-gate-reached",
46
11
  "every-hypothesis-refuted-unexplained",
47
12
  ];
48
- /**
49
- * Check `input` against all five triggers. Never throws — a check, not an
50
- * execution of the thing it is checking. More than one trigger may fire in
51
- * the same call; an empty result means the loop may keep running.
52
- */
13
+ /** Checks `input` against all five triggers. Never throws — more than one
14
+ * may fire at once; empty means the loop may keep running. */
53
15
  export function checkEscalation(input) {
54
16
  const triggers = [];
55
17
  if (input.budgetExceeded && input.openHypothesesCount > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"escalation.js","sourceRoot":"","sources":["../../src/governance/escalation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,uCAAuC;IACvC,mCAAmC;IACnC,yBAAyB;IACzB,qBAAqB;IACrB,sCAAsC;CAC9B,CAAC;AAmBX;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,QAAQ,GAAwB,EAAE,CAAC;IAEzC,IAAI,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,EAAE,CAAC;QAC1D,QAAQ,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,KAAK,CAAC,0BAA0B,EAAE,CA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AAuC,EAAE,CAAC;QAClD,QAAQ,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,49 +1,11 @@
1
- /**
2
- * G1 — the fact boundary (`ai-governance-spec.md` §2, `ai-layer-plan.md` §5).
3
- *
4
- * **No fact enters the model's context unless a tool produced it. No fact
5
- * leaves a model slot unless it references something a tool returned.**
6
- *
7
- * This is the first of the two gates P9 builds (`ai-governance-spec.md` §10):
8
- * "citation-checking on every slot output... a pure function over
9
- * already-recorded tool calls... no new tool surface, no new IR type."
10
- *
11
- * ## Why a citation is `{ seq }`, not `{ runId, seq }`
12
- *
13
- * `recorded_calls`'s primary key is `(run_id, seq)` (`../recording/schema.ts`),
14
- * and the gate is defined as checking a claim "against **this run's own**
15
- * recorded tool calls" — the run is the boundary, not a parameter a slot
16
- * output gets to name. `checkFactBoundary` takes the `RecordedRun` it is
17
- * checking against and a citation carries only `seq`. A citation naming a
18
- * call from a different run does not fail because the run id mismatches —
19
- * it fails because no call with that `seq` exists in *this* run's own
20
- * ordered list, which is the same failure as a fabricated seq and needs no
21
- * separate case (negative control 7, `ai-layer-plan.md` §9 layer 5).
22
- *
23
- * ## Why a whole claim is rejected on any unresolved citation
24
- *
25
- * A claim with two citations, one real and one fabricated, is not "half
26
- * true." §41.1 (never invent graph facts) does not have a partial-credit
27
- * form, so one bad citation invalidates the claim it was attached to, not
28
- * just itself — the same posture `ai-tool-contract.md`'s invariants take
29
- * toward a payload that "looks complete."
30
- *
31
- * ## Path is a key array, not a string
32
- *
33
- * `data.callers[0]` is a plausible citation shape, but parsing that string
34
- * back into a traversal is a small grammar this gate does not need to own.
35
- * `readonly (string | number)[]` says the same thing with no parser and no
36
- * ambiguity about what `[0]` means against an object vs. an array.
37
- */
1
+ /** G1 fact boundary (`ai-governance-spec.md` §2, `ai-layer-plan.md` §5): no fact enters or leaves
2
+ * a model slot without a tool citation. Citation is `{seq}`, not `{runId,seq}` — the run itself
3
+ * is the boundary. One unresolved citation rejects the whole claim (§41.1: no partial credit). */
38
4
  import type { RecordedRun } from "../recording/reader.ts";
39
5
  /** One segment of a citation path: an object key or an array index. */
40
6
  export type CitationPathSegment = string | number;
41
- /**
42
- * A pointer at one fact a tool call actually returned, within the run being
43
- * checked. `seq` names the call (`recorded_calls.seq`); `path`, when given,
44
- * narrows the citation to a field within that call's `result` rather than
45
- * the whole envelope. Omitted `path` cites the whole result.
46
- */
7
+ /** A pointer at one fact a tool call returned, within the run being checked. `seq` names the
8
+ * call; `path`, when given, narrows to a field in that call's `result`. Omitted `path` cites the whole result. */
47
9
  export interface Citation {
48
10
  readonly seq: number;
49
11
  readonly path?: readonly CitationPathSegment[];
@@ -67,11 +29,7 @@ export interface FactBoundaryResult {
67
29
  readonly accepted: readonly FactualClaim[];
68
30
  readonly rejected: readonly RejectedClaim[];
69
31
  }
70
- /**
71
- * Check every claim in `output` against `run`'s own recorded calls. A claim
72
- * with no citations, or with any citation that does not resolve, is
73
- * rejected with its reasons; everything else is accepted. Never throws —
74
- * this is a check, not an execution of the thing it is checking.
75
- */
32
+ /** Checks every claim in `output` against `run`'s own recorded calls. Uncited or unresolved
33
+ * citations reject the claim with reasons; everything else is accepted. Never throws — a check, not an execution. */
76
34
  export declare function checkFactBoundary(output: SlotOutput, run: RecordedRun): FactBoundaryResult;
77
35
  //# sourceMappingURL=fact-boundary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fact-boundary.d.ts","sourceRoot":"","sources":["../../src/governance/fact-boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAExE,uEAAuE;AACvE,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAA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AQ,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;CACzC;AAED,kGAAkG;AAClG,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,6FAA6F;IAC7F,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;CAC7C;AA2BD;sHACsH;AACtH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,GAAG,kBAAkB,CAwB1F"}
@@ -1,40 +1,6 @@
1
- /**
2
- * G1 — the fact boundary (`ai-governance-spec.md` §2, `ai-layer-plan.md` §5).
3
- *
4
- * **No fact enters the model's context unless a tool produced it. No fact
5
- * leaves a model slot unless it references something a tool returned.**
6
- *
7
- * This is the first of the two gates P9 builds (`ai-governance-spec.md` §10):
8
- * "citation-checking on every slot output... a pure function over
9
- * already-recorded tool calls... no new tool surface, no new IR type."
10
- *
11
- * ## Why a citation is `{ seq }`, not `{ runId, seq }`
12
- *
13
- * `recorded_calls`'s primary key is `(run_id, seq)` (`../recording/schema.ts`),
14
- * and the gate is defined as checking a claim "against **this run's own**
15
- * recorded tool calls" — the run is the boundary, not a parameter a slot
16
- * output gets to name. `checkFactBoundary` takes the `RecordedRun` it is
17
- * checking against and a citation carries only `seq`. A citation naming a
18
- * call from a different run does not fail because the run id mismatches —
19
- * it fails because no call with that `seq` exists in *this* run's own
20
- * ordered list, which is the same failure as a fabricated seq and needs no
21
- * separate case (negative control 7, `ai-layer-plan.md` §9 layer 5).
22
- *
23
- * ## Why a whole claim is rejected on any unresolved citation
24
- *
25
- * A claim with two citations, one real and one fabricated, is not "half
26
- * true." §41.1 (never invent graph facts) does not have a partial-credit
27
- * form, so one bad citation invalidates the claim it was attached to, not
28
- * just itself — the same posture `ai-tool-contract.md`'s invariants take
29
- * toward a payload that "looks complete."
30
- *
31
- * ## Path is a key array, not a string
32
- *
33
- * `data.callers[0]` is a plausible citation shape, but parsing that string
34
- * back into a traversal is a small grammar this gate does not need to own.
35
- * `readonly (string | number)[]` says the same thing with no parser and no
36
- * ambiguity about what `[0]` means against an object vs. an array.
37
- */
1
+ /** G1 fact boundary (`ai-governance-spec.md` §2, `ai-layer-plan.md` §5): no fact enters or leaves
2
+ * a model slot without a tool citation. Citation is `{seq}`, not `{runId,seq}` — the run itself
3
+ * is the boundary. One unresolved citation rejects the whole claim (§41.1: no partial credit). */
38
4
  function resolvesWithin(value, path) {
39
5
  let cursor = value;
40
6
  for (const key of path) {
@@ -61,12 +27,8 @@ function checkCitation(citation, callsBySeq) {
61
27
  }
62
28
  return null;
63
29
  }
64
- /**
65
- * Check every claim in `output` against `run`'s own recorded calls. A claim
66
- * with no citations, or with any citation that does not resolve, is
67
- * rejected with its reasons; everything else is accepted. Never throws —
68
- * this is a check, not an execution of the thing it is checking.
69
- */
30
+ /** Checks every claim in `output` against `run`'s own recorded calls. Uncited or unresolved
31
+ * citations reject the claim with reasons; everything else is accepted. Never throws — a check, not an execution. */
70
32
  export function checkFactBoundary(output, run) {
71
33
  const callsBySeq = new Map(run.calls.map((call) => [call.seq, call]));
72
34
  const accepted = [];
@@ -1 +1 @@
1
- {"version":3,"file":"fact-boundary.js","sourceRoot":"","sources":["../../src/governance/fact-boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAyCH,SAAS,cAAc,CAAC,KAAc,EAAE,IAAoC;IAC1E,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,M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IAErC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;YAClE,SAAS;QACX,CAAC;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS;aAC5B,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;aACtD,MAAM,CAAC,CAAC,MAAM,EAAoB,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;QAEzD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC"}
@@ -1,60 +1,10 @@
1
- /**
2
- * The governance funnel — architecture §20.1.
3
- *
4
- * > *"Without this layer, a run that surfaces 200 findings gets read by
5
- * > nobody. Volume without governance is functionally the same as no output at
6
- * > all."*
7
- *
8
- * §20.1 draws a five-filter funnel ending in a hard cap. Two of its boxes had
9
- * no implementation anywhere: **F2, "known false positives from the feedback
10
- * store,"** and **the HARD CAP itself**, whose value architecture §32 item 6
11
- * has carried as a blank since the document was written (*"Hard cap value —
12
- * how many findings is 'a few'"*, Tuning, *"set from early runs"*).
13
- *
14
- * `CLAUDE.md` rule 5 — *"a few high-confidence findings, never an exhaustive
15
- * maybe-list"* — is the rule aimed most directly at what this whole category
16
- * of tool gets wrong, and it was the one rule with no number behind it. Three
17
- * per-check caps of 25 existed (`contracts/orphans.ts`, `validation/rollback.ts`,
18
- * `validation/env.ts`), which is not the same thing: three checks at 25 present
19
- * 75 items and nothing objects.
20
- *
21
- * ## The cap values, and where they come from
22
- *
23
- * §20.1 states its own worked example in prose: *"Twenty-seven possible issues
24
- * get ignored. Three confirmed issues plus two worth checking get acted on
25
- * immediately."* **Three plus two is five**, and that is `pr`'s cap — read off
26
- * the architecture rather than invented.
27
- *
28
- * The other three are scaled to their trigger the same way `NODE_BUDGETS`
29
- * already is, and for the same reason: an IDE hover and a nightly sweep are
30
- * not the same reading surface. **Starting values, not measurements** —
31
- * `CLAUDE.md`'s standing convention for every number in this project.
32
- *
33
- * ## What this module deliberately does not own
34
- *
35
- * - **It does not assign a category.** Only G4 does (`ai-governance-spec.md`
36
- * §11). This runs strictly after, on already-categorised findings, and
37
- * reorders and truncates them without touching a single field.
38
- * - **It does not store dismissals.** `isDismissed` is a caller-supplied
39
- * predicate. The ledger is `descry-desktop`'s (§21.3 puts the feedback store
40
- * next to the runs it belongs to); the *filter* is governance and belongs
41
- * here, next to G1–G4.
42
- * - **It never silently drops anything.** Every finding that entered leaves in
43
- * exactly one of `reported` / `unconfirmed` / `suppressed`, and the count it
44
- * truncated is a structured field with a rendered sentence — the same rule
45
- * `ai-tool-contract.md` §4 technique 5 applies one layer down (*"a capped
46
- * result that looks complete is the same defect as a zero that looks like a
47
- * finding"*).
48
- */
1
+ /** §20.1 governance funnel — five filters ending in a hard cap; F2 (feedback-store false
2
+ * positives) and the cap itself were unimplemented until now. Caps are starting values (pr=5,
3
+ * §20.1's own 3+2 example). Never silently drops: every finding lands in reported/unconfirmed/suppressed. */
49
4
  import { type Finding } from "@descryy/ir";
50
5
  import type { Trigger } from "../scoping/tiers.ts";
51
- /**
52
- * How many findings one run may report, per trigger.
53
- *
54
- * `pr` is architecture §20.1's own arithmetic (3 confirmed + 2 worth
55
- * checking). The rest are scaled to the reading surface, the same shape
56
- * `NODE_BUDGETS` uses, and are starting values pending real runs to tune from.
57
- */
6
+ /** Findings one run may report, per trigger. `pr`=5 is §20.1's own arithmetic (3+2). The rest
7
+ * scale to the reading surface (same shape as NODE_BUDGETS) — starting values, not measurements. */
58
8
  export declare const FINDING_CAPS: {
59
9
  /** A hover is one line of screen. More than one finding there is a list nobody reads. */
60
10
  readonly "ide-hover": 1;
@@ -67,10 +17,8 @@ export declare const FINDING_CAPS: {
67
17
  };
68
18
  export interface FindingFunnelOptions {
69
19
  readonly trigger: Trigger;
70
- /**
71
- * F2. `true` suppresses the finding. Supplied by the caller's feedback store
72
- * — see the module doc for why the ledger is not here.
73
- */
20
+ /** F2. `true` suppresses the finding. Supplied by the caller's feedback store — the ledger
21
+ * lives in descry-desktop (§21.3), the filter lives here. */
74
22
  readonly isDismissed?: (finding: Finding) => boolean;
75
23
  /** Overrides the trigger's cap. For a caller that has measured its own; not a way to opt out. */
76
24
  readonly cap?: number;
@@ -91,19 +39,10 @@ export interface FindingFunnelResult {
91
39
  readonly suppressed: readonly Finding[];
92
40
  readonly truncation: FindingTruncation;
93
41
  }
94
- /**
95
- * Run §20.1's funnel over one run's findings.
96
- *
97
- * Pure and total: same input, same output, and every input finding appears in
98
- * exactly one output list. Deterministic ordering — required by
99
- * `ai-layer-plan.md` §9 layer 6's replay guarantee, so ties break on the
100
- * finding's own fingerprint rather than on input order.
101
- */
42
+ /** §20.1's funnel. Pure and total — every input finding appears in exactly one output list.
43
+ * Deterministic ordering (replay guarantee, §9 layer 6): ties break on fingerprint, not input order. */
102
44
  export declare function runFindingFunnel(findings: readonly Finding[], options: FindingFunnelOptions): FindingFunnelResult;
103
- /**
104
- * Re-exported so a caller wiring the funnel and its ledger imports one module.
105
- * The implementation lives in `@descryy/ir`'s identity module — see
106
- * `DEC-NEXT-edge-id-prefix-split` for why an identity gets exactly one home.
107
- */
45
+ /** Re-exported so a caller wiring the funnel and ledger imports one module — implementation
46
+ * lives in @descryy/ir's identity module (DEC-NEXT-edge-id-prefix-split). */
108
47
  export { findingFingerprint } from "@descryy/ir";
109
48
  //# sourceMappingURL=finding-funnel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"finding-funnel.d.ts","sourceRoot":"","sources":["../../src/governance/finding-funnel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAsB,KAAK,OAAO,EAAuB,MAAM,aAAa,CAAC;AAEpF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;IACvB,yFAAyF;;IAEzF,uEAAuE;;IAEvE,kCAAkC;;IAElC,oFAAoF;;CAE1C,CAAC;AAc7C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;IACrD,iGAAiG;IACjG,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sGAAsG;IACtG,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,iFAAiF;IACjF,QAAQ,CAAC,WAAW,EAAE,SAAS,OAAO,EAAE,CAAC;IACzC,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,SAAS,OAAO,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;CACxC;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9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