gdp-wired 0.48.0 → 0.49.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 (295) hide show
  1. package/README.md +2 -2
  2. package/dist/core/bmc.js +10 -7
  3. package/dist/core/check.js +7 -2
  4. package/dist/core/count-attempt-work.d.ts +29 -0
  5. package/dist/core/count-attempt-work.js +96 -0
  6. package/dist/core/count-boolean-partition.d.ts +5 -0
  7. package/dist/core/count-boolean-partition.js +47 -0
  8. package/dist/core/count-bounded-quotient.d.ts +2 -0
  9. package/dist/core/count-bounded-quotient.js +13 -0
  10. package/dist/core/count-case-compose.d.ts +20 -0
  11. package/dist/core/count-case-compose.js +289 -0
  12. package/dist/core/count-cases.js +3 -2
  13. package/dist/core/count-cert-rename.d.ts +10 -0
  14. package/dist/core/count-cert-rename.js +69 -0
  15. package/dist/core/count-cert-transport.d.ts +10 -2
  16. package/dist/core/count-cert-transport.js +60 -9
  17. package/dist/core/count-certificate-minimize.d.ts +57 -0
  18. package/dist/core/count-certificate-minimize.js +263 -0
  19. package/dist/core/count-closed-family.d.ts +32 -0
  20. package/dist/core/count-closed-family.js +143 -0
  21. package/dist/core/count-closing-budget.d.ts +10 -0
  22. package/dist/core/count-closing-budget.js +49 -0
  23. package/dist/core/count-closing-needs.d.ts +5 -0
  24. package/dist/core/count-closing-needs.js +9 -0
  25. package/dist/core/count-component-budget.d.ts +5 -0
  26. package/dist/core/count-component-budget.js +9 -0
  27. package/dist/core/count-copy-shape.d.ts +11 -0
  28. package/dist/core/count-copy-shape.js +40 -0
  29. package/dist/core/count-disjoint-funding.d.ts +75 -0
  30. package/dist/core/count-disjoint-funding.js +284 -0
  31. package/dist/core/count-emitter-frame-pool.d.ts +23 -0
  32. package/dist/core/count-emitter-frame-pool.js +87 -0
  33. package/dist/core/count-final-step.d.ts +5 -0
  34. package/dist/core/count-final-step.js +20 -0
  35. package/dist/core/count-fixed-frame.d.ts +4 -0
  36. package/dist/core/count-fixed-frame.js +30 -0
  37. package/dist/core/count-frames.d.ts +25 -0
  38. package/dist/core/count-frames.js +118 -0
  39. package/dist/core/count-frozen-guard.d.ts +2 -0
  40. package/dist/core/count-frozen-guard.js +31 -0
  41. package/dist/core/count-generation-phase.d.ts +7 -0
  42. package/dist/core/count-generation-phase.js +33 -0
  43. package/dist/core/count-guard-composition.d.ts +12 -0
  44. package/dist/core/count-guard-composition.js +48 -0
  45. package/dist/core/count-guard-context.d.ts +11 -0
  46. package/dist/core/count-guard-context.js +50 -0
  47. package/dist/core/count-guard-facts.d.ts +50 -0
  48. package/dist/core/count-guard-facts.js +97 -0
  49. package/dist/core/count-guard-proposals.d.ts +7 -0
  50. package/dist/core/count-guard-proposals.js +106 -0
  51. package/dist/core/count-guard-shape.d.ts +18 -0
  52. package/dist/core/count-guard-shape.js +100 -0
  53. package/dist/core/count-guard-tree.d.ts +17 -0
  54. package/dist/core/count-guard-tree.js +125 -0
  55. package/dist/core/count-leader-facts.d.ts +10 -0
  56. package/dist/core/count-leader-facts.js +52 -0
  57. package/dist/core/count-leader.d.ts +10 -0
  58. package/dist/core/count-leader.js +331 -0
  59. package/dist/core/count-lemma-transport.d.ts +8 -0
  60. package/dist/core/count-lemma-transport.js +47 -0
  61. package/dist/core/count-lifted-budget.d.ts +54 -0
  62. package/dist/core/count-lifted-budget.js +97 -0
  63. package/dist/core/count-lifted-copy.d.ts +3 -0
  64. package/dist/core/count-lifted-copy.js +166 -0
  65. package/dist/core/count-lifted-increment.d.ts +3 -0
  66. package/dist/core/count-lifted-increment.js +146 -0
  67. package/dist/core/count-lifted-load.d.ts +5 -0
  68. package/dist/core/count-lifted-load.js +179 -0
  69. package/dist/core/count-lifted-prerequisite.d.ts +14 -0
  70. package/dist/core/count-lifted-prerequisite.js +53 -0
  71. package/dist/core/count-lifted-replacement.d.ts +3 -0
  72. package/dist/core/count-lifted-replacement.js +540 -0
  73. package/dist/core/count-lifted-shape.d.ts +63 -0
  74. package/dist/core/count-lifted-shape.js +115 -0
  75. package/dist/core/count-lifted-strategy.d.ts +7 -0
  76. package/dist/core/count-lifted-strategy.js +226 -0
  77. package/dist/core/count-lifted-transports.d.ts +32 -0
  78. package/dist/core/count-lifted-transports.js +293 -0
  79. package/dist/core/count-load-shape.d.ts +17 -0
  80. package/dist/core/count-load-shape.js +67 -0
  81. package/dist/core/count-minimal-view.d.ts +26 -0
  82. package/dist/core/count-minimal-view.js +46 -0
  83. package/dist/core/count-operation-observation.d.ts +9 -0
  84. package/dist/core/count-operation-observation.js +22 -0
  85. package/dist/core/count-operation-order.d.ts +5 -0
  86. package/dist/core/count-operation-order.js +4 -0
  87. package/dist/core/count-phase.d.ts +9 -0
  88. package/dist/core/count-phase.js +127 -0
  89. package/dist/core/count-premise-search.d.ts +9 -0
  90. package/dist/core/count-premise-search.js +41 -0
  91. package/dist/core/count-premise-view.d.ts +19 -0
  92. package/dist/core/count-premise-view.js +220 -0
  93. package/dist/core/count-prerequisite-components.d.ts +67 -0
  94. package/dist/core/count-prerequisite-components.js +239 -0
  95. package/dist/core/count-prerequisite-memory.d.ts +24 -0
  96. package/dist/core/count-prerequisite-memory.js +37 -0
  97. package/dist/core/count-prerequisite-plan.d.ts +12 -0
  98. package/dist/core/count-prerequisite-plan.js +88 -0
  99. package/dist/core/count-primitive-budget.d.ts +1 -0
  100. package/dist/core/count-primitive-budget.js +8 -0
  101. package/dist/core/count-project-free.d.ts +3 -0
  102. package/dist/core/count-project-free.js +24 -0
  103. package/dist/core/count-project-witness.d.ts +4 -0
  104. package/dist/core/count-project-witness.js +48 -0
  105. package/dist/core/count-proof-rescope.d.ts +14 -0
  106. package/dist/core/count-proof-rescope.js +71 -0
  107. package/dist/core/count-proof-scope.d.ts +68 -0
  108. package/dist/core/count-proof-scope.js +333 -0
  109. package/dist/core/count-prune-owned-root.d.ts +5 -0
  110. package/dist/core/count-prune-owned-root.js +27 -0
  111. package/dist/core/count-query-context.d.ts +3 -0
  112. package/dist/core/count-query-context.js +7 -0
  113. package/dist/core/count-query.d.ts +15 -0
  114. package/dist/core/count-query.js +59 -0
  115. package/dist/core/count-quorum-leaf.d.ts +9 -0
  116. package/dist/core/count-quorum-leaf.js +38 -0
  117. package/dist/core/count-reachability-budget.d.ts +1 -0
  118. package/dist/core/count-reachability-budget.js +7 -0
  119. package/dist/core/count-reachability-reconcile.d.ts +11 -0
  120. package/dist/core/count-reachability-reconcile.js +19 -0
  121. package/dist/core/count-reachability.d.ts +50 -0
  122. package/dist/core/count-reachability.js +351 -0
  123. package/dist/core/count-rebase-path.d.ts +9 -0
  124. package/dist/core/count-rebase-path.js +68 -0
  125. package/dist/core/count-recipe-context.d.ts +45 -0
  126. package/dist/core/count-recipe-context.js +71 -0
  127. package/dist/core/count-recipe-controller.d.ts +115 -0
  128. package/dist/core/count-recipe-controller.js +417 -0
  129. package/dist/core/count-recipe-graph.d.ts +36 -0
  130. package/dist/core/count-recipe-graph.js +211 -0
  131. package/dist/core/count-recovery/conditional-check-cache.js +3 -2
  132. package/dist/core/count-recovery/conditional-cuts.js +5 -4
  133. package/dist/core/count-recovery/conditional-proof.d.ts +37 -3
  134. package/dist/core/count-recovery/conditional-proof.js +72 -30
  135. package/dist/core/count-recovery/derivability-closure.js +2 -1
  136. package/dist/core/count-recovery/guard-cases.js +2 -1
  137. package/dist/core/count-recovery/reframe-tree.d.ts +2 -0
  138. package/dist/core/count-recovery/reframe-tree.js +24 -0
  139. package/dist/core/count-recovery/replay-linear-skeleton.d.ts +2 -0
  140. package/dist/core/count-recovery/replay-linear-skeleton.js +28 -0
  141. package/dist/core/count-recovery/row-cases.js +2 -1
  142. package/dist/core/count-rejection-budget.d.ts +8 -0
  143. package/dist/core/count-rejection-budget.js +15 -0
  144. package/dist/core/count-replacement.d.ts +5 -0
  145. package/dist/core/count-replacement.js +129 -0
  146. package/dist/core/count-replay-diagnostic.d.ts +21 -0
  147. package/dist/core/count-replay-diagnostic.js +49 -0
  148. package/dist/core/count-replay-skeleton.d.ts +4 -0
  149. package/dist/core/count-replay-skeleton.js +28 -0
  150. package/dist/core/count-rescope-funding.d.ts +3 -0
  151. package/dist/core/count-rescope-funding.js +17 -0
  152. package/dist/core/count-restrictions.d.ts +11 -0
  153. package/dist/core/count-restrictions.js +31 -0
  154. package/dist/core/count-retry-budget.d.ts +67 -0
  155. package/dist/core/count-retry-budget.js +114 -0
  156. package/dist/core/count-retry-round.d.ts +24 -0
  157. package/dist/core/count-retry-round.js +44 -0
  158. package/dist/core/count-row-agreement.d.ts +35 -0
  159. package/dist/core/count-row-agreement.js +270 -0
  160. package/dist/core/count-row-aliases.d.ts +3 -0
  161. package/dist/core/count-row-aliases.js +59 -0
  162. package/dist/core/count-row-composition.d.ts +6 -0
  163. package/dist/core/count-row-composition.js +55 -0
  164. package/dist/core/count-row-copy-linear.d.ts +4 -0
  165. package/dist/core/count-row-copy-linear.js +83 -0
  166. package/dist/core/count-row-copy.d.ts +4 -0
  167. package/dist/core/count-row-copy.js +94 -0
  168. package/dist/core/count-row-policy.d.ts +3 -0
  169. package/dist/core/count-row-policy.js +56 -0
  170. package/dist/core/count-row-reindex.d.ts +11 -0
  171. package/dist/core/count-row-reindex.js +126 -0
  172. package/dist/core/count-row-support.d.ts +9 -0
  173. package/dist/core/count-row-support.js +42 -0
  174. package/dist/core/count-row-symmetry.d.ts +7 -0
  175. package/dist/core/count-row-symmetry.js +100 -0
  176. package/dist/core/count-scope-hyps.d.ts +2 -0
  177. package/dist/core/count-scope-hyps.js +163 -0
  178. package/dist/core/count-scope-row-reuse.d.ts +3 -0
  179. package/dist/core/count-scope-row-reuse.js +92 -0
  180. package/dist/core/count-search-allowance.d.ts +1 -0
  181. package/dist/core/count-search-allowance.js +17 -0
  182. package/dist/core/count-stabilize-tree.d.ts +9 -0
  183. package/dist/core/count-stabilize-tree.js +35 -0
  184. package/dist/core/count-stage-trace.d.ts +8 -0
  185. package/dist/core/count-stage-trace.js +45 -0
  186. package/dist/core/count-strategies.d.ts +16 -0
  187. package/dist/core/count-strategies.js +155 -0
  188. package/dist/core/count-strategy-premises.d.ts +5 -0
  189. package/dist/core/count-strategy-premises.js +14 -0
  190. package/dist/core/count-strategy.d.ts +41 -0
  191. package/dist/core/count-strategy.js +76 -0
  192. package/dist/core/count-support.js +3 -2
  193. package/dist/core/count-tier-budget.d.ts +14 -0
  194. package/dist/core/count-tier-budget.js +64 -0
  195. package/dist/core/count-unwritten-prefix.d.ts +24 -0
  196. package/dist/core/count-unwritten-prefix.js +97 -0
  197. package/dist/core/count-write-shape.d.ts +15 -0
  198. package/dist/core/count-write-shape.js +73 -0
  199. package/dist/core/counts.d.ts +37 -13
  200. package/dist/core/counts.js +990 -127
  201. package/dist/core/cycles.js +5 -4
  202. package/dist/core/cyclic.js +11 -10
  203. package/dist/core/data.js +16 -15
  204. package/dist/core/dsl-deadline.d.ts +3 -0
  205. package/dist/core/dsl-deadline.js +27 -0
  206. package/dist/core/dsl.d.ts +9 -0
  207. package/dist/core/dsl.js +156 -51
  208. package/dist/core/evaluation-admission.d.ts +1 -0
  209. package/dist/core/evaluation-admission.js +3 -0
  210. package/dist/core/exists.d.ts +6 -1
  211. package/dist/core/exists.js +51 -9
  212. package/dist/core/field-laws.d.ts +3 -1
  213. package/dist/core/field-laws.js +140 -2
  214. package/dist/core/finite-houdini.d.ts +6 -0
  215. package/dist/core/finite-houdini.js +63 -21
  216. package/dist/core/finite-tiny.js +95 -67
  217. package/dist/core/fixtures/count-completion/paxos-decision.json +1 -0
  218. package/dist/core/fresh.js +5 -1
  219. package/dist/core/infer.js +45 -30
  220. package/dist/core/kind.js +2 -1
  221. package/dist/core/lemma-cuts.js +11 -10
  222. package/dist/core/linear-admission.d.ts +14 -0
  223. package/dist/core/linear-admission.js +151 -0
  224. package/dist/core/machine.d.ts +5 -2
  225. package/dist/core/machine.js +105 -31
  226. package/dist/core/meter.d.ts +22 -0
  227. package/dist/core/meter.js +34 -0
  228. package/dist/core/nonterm.js +4 -3
  229. package/dist/core/prover-row-budget.d.ts +3 -0
  230. package/dist/core/prover-row-budget.js +106 -0
  231. package/dist/core/quorum-laws.d.ts +21 -1
  232. package/dist/core/quorum-laws.js +27 -3
  233. package/dist/core/rationals.js +3 -2
  234. package/dist/core/rejection-discovery.d.ts +34 -0
  235. package/dist/core/rejection-discovery.js +36 -0
  236. package/dist/core/rejection-stage.d.ts +39 -0
  237. package/dist/core/rejection-stage.js +205 -0
  238. package/dist/core/request-quotient.d.ts +8 -0
  239. package/dist/core/request-quotient.js +299 -0
  240. package/dist/core/row-agreement-shape.d.ts +15 -0
  241. package/dist/core/row-agreement-shape.js +68 -0
  242. package/dist/core/runtime-wall.d.ts +2 -0
  243. package/dist/core/search-policy.d.ts +15 -0
  244. package/dist/core/search-policy.js +68 -0
  245. package/dist/core/solver.d.ts +1 -1
  246. package/dist/core/solver.js +40 -6
  247. package/dist/core/step-work.d.ts +12 -0
  248. package/dist/core/step-work.js +14 -0
  249. package/dist/core/strategy-premises.d.ts +8 -0
  250. package/dist/core/strategy-premises.js +64 -0
  251. package/dist/core/system.js +4 -3
  252. package/dist/core/table-admission.d.ts +1 -0
  253. package/dist/core/table-admission.js +3 -0
  254. package/dist/core/trace-clock.d.ts +3 -0
  255. package/dist/core/trace-clock.js +16 -0
  256. package/dist/core/transfer.js +3 -2
  257. package/dist/core/translate.js +16 -3
  258. package/dist/core/wall.d.ts +6 -1
  259. package/dist/core/wall.js +23 -9
  260. package/dist/core/watch.d.ts +1 -1
  261. package/dist/core/watch.js +13 -4
  262. package/dist/core/work-admission.d.ts +164 -0
  263. package/dist/core/work-admission.js +418 -0
  264. package/dist/core/work-amount.d.ts +21 -0
  265. package/dist/core/work-amount.js +80 -0
  266. package/dist/core/work-collections.d.ts +11 -0
  267. package/dist/core/work-collections.js +198 -0
  268. package/dist/core/work-kinds.d.ts +11 -0
  269. package/dist/core/work-kinds.js +9 -0
  270. package/dist/core/work-meter.d.ts +8 -0
  271. package/dist/core/work-meter.js +83 -0
  272. package/dist/core/work-observe.d.ts +12 -0
  273. package/dist/core/work-observe.js +39 -0
  274. package/dist/core/work-profile.d.ts +10 -0
  275. package/dist/core/work-profile.js +21 -0
  276. package/dist/core/work-refusal.d.ts +1 -0
  277. package/dist/core/work-refusal.js +6 -0
  278. package/dist/interchange/format.js +2 -0
  279. package/dist/kernel/cdcl.js +93 -40
  280. package/dist/kernel/epr.js +23 -8
  281. package/dist/kernel/kernel.d.ts +47 -1
  282. package/dist/kernel/kernel.js +417 -68
  283. package/dist/kernel/prove.d.ts +49 -3
  284. package/dist/kernel/prove.js +468 -122
  285. package/dist/kernel/prover-rows.d.ts +1 -0
  286. package/dist/kernel/prover-rows.js +12 -1
  287. package/dist/kernel/reader.d.ts +1 -1
  288. package/dist/kernel/reader.js +57 -12
  289. package/dist/kernel/simplex.js +9 -2
  290. package/dist/lean-kernel/emit.d.ts +9 -1
  291. package/dist/lean-kernel/emit.js +144 -22
  292. package/dist/lean-kernel/legacy-family-library.d.ts +1 -0
  293. package/dist/lean-kernel/legacy-family-library.js +5 -0
  294. package/dist/lean-kernel/library.js +3 -3
  295. package/package.json +1 -1
@@ -0,0 +1,351 @@
1
+ // Incomplete, untrusted reachable-refutation search. Only the unchanged ledger
2
+ // replay on ORIGINAL init/step can reject. No trace, model or finite exhaustion
3
+ // can prove a law. No protocol/operation/map/label-specific search templates.
4
+ import { interpret, walk } from "./machine.js";
5
+ import { retainedSamplePath, retainedSamples } from "./exists.js";
6
+ import { finiteEvaluator } from "./finite-houdini.js";
7
+ import { createRejectionStage } from "./rejection-stage.js";
8
+ import { countGenerationPhase } from "./count-generation-phase.js";
9
+ import { countReachabilityAllowance } from "./count-reachability-budget.js";
10
+ import { requestQuotient } from "./request-quotient.js";
11
+ import { startWork } from "./work-admission.js";
12
+ import { completeWorkProfile } from "./work-profile.js";
13
+ import { strategyLawKey } from "./strategy-premises.js";
14
+ import { reachEdge, reachState, withReachabilityWork } from "./work-observe.js";
15
+ import { BudgetExpired, checkBudget, clock, fullRate, keyValue } from "../kernel/prove.js";
16
+ import { WallExpired } from "./wall.js";
17
+ // The production scheduler must opt in before context hashing, samples, replay
18
+ // ledger creation or any screen-side allocation. Direct calls remain explicit.
19
+ export function optionalReachabilityScreen(create) {
20
+ return process.env.GDP_COUNT_REACHABILITY_SCREEN === '1' ? create() : undefined;
21
+ }
22
+ function tick() {
23
+ checkBudget('reachable screen');
24
+ if (completeWorkProfile.enabled)
25
+ startWork('ticks', 1, 'reachable bookkeeping');
26
+ }
27
+ const natural = (x) => typeof x === 'number' && Number.isSafeInteger(x) && x >= 0;
28
+ const atoms = (c) => c.op === 'and' ? c.xs.flatMap(atoms) : [c];
29
+ // Lazy scalar/product/set enumeration. Irrelevant fields may be held at zero
30
+ // only when the existing source analysis supports it; guard inputs stay live.
31
+ function* requests(m, p, size) {
32
+ const tags = new Map(), guard = new Set();
33
+ walk(m.step, o => { tick(); if (o.op === '=' && o.a && o.b) {
34
+ const a = o.a, b = o.b, v = a.op === 'var' ? a : b, k = a.op === 'var' ? b : a;
35
+ if (v.op === 'var' && k.op === 'const' && m.inputs.includes(v.name) && natural(k.value)) {
36
+ let set = tags.get(v.name);
37
+ if (!set)
38
+ tags.set(v.name, set = new Set());
39
+ set.add(k.value);
40
+ }
41
+ } });
42
+ if (m.assume)
43
+ walk(m.assume, o => { tick(); if (o.op === 'var')
44
+ guard.add(String(o.name)); if (o.op === 'get')
45
+ guard.add(String(o.map)); });
46
+ const domain = (name) => {
47
+ let bound = size;
48
+ for (const c of m.assume ? atoms(m.assume) : [])
49
+ if ((c.op === '<' || c.op === '<=') && c.a.op === 'var' && c.a.name === name) {
50
+ const k = c.b.op === 'const' ? c.b.value : c.b.op === 'var' ? p[c.b.name] : undefined;
51
+ if (natural(k))
52
+ bound = Math.min(bound, k + (c.op === '<=' ? 1 : 0));
53
+ }
54
+ const values = new Set();
55
+ for (let i = 0; i < bound; i++) {
56
+ tick();
57
+ values.add(i);
58
+ }
59
+ for (const x of tags.get(name) ?? []) {
60
+ tick();
61
+ values.add(x);
62
+ }
63
+ return [...values];
64
+ };
65
+ const names = [...m.inputs, ...m.inputMaps ?? []], base = Object.fromEntries(names.map(name => [name, m.inputs.includes(name) ? 0 : new Map()]));
66
+ const selector = [...tags].filter(([, vs]) => vs.size > 1).sort((a, b) => b[1].size - a[1].size || m.inputs.indexOf(a[0]) - m.inputs.indexOf(b[0]))[0]?.[0];
67
+ const values = selector ? domain(selector) : [undefined];
68
+ const seeds = values.flatMap(value => { const r = { ...base, ...selector ? { [selector]: value } : {} }; return [r, r]; });
69
+ const quotient = seeds.length ? requestQuotient(m, seeds) : undefined;
70
+ function* product(fields, at, r) {
71
+ tick();
72
+ if (at === fields.length) {
73
+ yield r;
74
+ return;
75
+ }
76
+ const name = fields[at];
77
+ if (m.inputs.includes(name)) {
78
+ for (const value of domain(name))
79
+ yield* product(fields, at + 1, { ...r, [name]: value });
80
+ return;
81
+ }
82
+ const bits = [];
83
+ for (let i = 0; i < size; i++) {
84
+ tick();
85
+ bits.push(false);
86
+ }
87
+ for (;;) {
88
+ tick();
89
+ const cells = new Map();
90
+ for (let i = 0; i < bits.length; i++) {
91
+ tick();
92
+ if (bits[i])
93
+ cells.set(i, 1);
94
+ }
95
+ yield* product(fields, at + 1, { ...r, [name]: cells });
96
+ let i = 0;
97
+ for (; i < bits.length && bits[i]; i++) {
98
+ tick();
99
+ bits[i] = false;
100
+ }
101
+ if (i === bits.length)
102
+ break;
103
+ bits[i] = true;
104
+ }
105
+ }
106
+ for (const value of values) {
107
+ tick();
108
+ const projected = quotient?.selector === selector ? quotient?.reads.get(value) : undefined;
109
+ const live = projected ? names.filter(name => name !== selector && (projected.includes(name) || guard.has(name))) : names.filter(name => name !== selector);
110
+ yield* product(live, 0, { ...base, ...selector ? { [selector]: value } : {} });
111
+ }
112
+ }
113
+ function tightLaw(law) {
114
+ const tighten = (c) => { tick(); return c.op === 'and' || c.op === 'or' ? { ...c, xs: c.xs.map(tighten) } : c.op === 'not' ? { ...c, x: tighten(c.x) } : c.op === 'all' ? { ...c, c: tighten(c.c) } : c.op === '<=' ? { ...c, op: '<' } : c; };
115
+ return { ...law, holds: tighten(law.holds) };
116
+ }
117
+ export function countReachabilityScreen(source, m, caller, root, samplesHint, funding = new Map()) {
118
+ const ledger = createRejectionStage(source, m, caller, [], root), evaluate = finiteEvaluator(m), run = interpret(source, tick), receipts = new Map();
119
+ // Keep the ledger's canonical objects private. Evidence is intentionally
120
+ // cloned; only request-unique validated names cross the scheduler boundary.
121
+ const registered = new Map(caller.map(law => [law.name, { law, key: strategyLawKey(law) }]));
122
+ const refresh = () => {
123
+ const active = new Set(ledger.active()), rejected = [];
124
+ for (const [name, entry] of registered)
125
+ if (!active.has(entry.law)) {
126
+ rejected.push(name);
127
+ const row = receipts.get(name);
128
+ if (row)
129
+ row.outcome = 'rejected';
130
+ }
131
+ return rejected;
132
+ };
133
+ const seedSamples = () => samplesHint?.() ?? (retainedSamples(source).length ? retainedSamples(source) : retainedSamples(m));
134
+ const replay = (law, node) => {
135
+ tick();
136
+ if (evaluate(law, node.p, node.state) !== false)
137
+ return false;
138
+ // The candidate state's origin is never trusted, even when it was cached.
139
+ // Publication is atomic inside the existing rejection ledger.
140
+ ledger.reachable(node.p, node.path);
141
+ refresh();
142
+ return !!ledger.safety() || !ledger.active().includes(law);
143
+ };
144
+ const step = (node, request) => {
145
+ tick();
146
+ try {
147
+ reachEdge();
148
+ const state = run.step(node.p, node.state, request);
149
+ reachState();
150
+ const path = [];
151
+ for (const r of node.path) {
152
+ tick();
153
+ path.push(r);
154
+ }
155
+ path.push(request);
156
+ return { p: node.p, state, path, depth: node.depth + 1 };
157
+ }
158
+ catch (error) {
159
+ if (error instanceof BudgetExpired || error instanceof WallExpired)
160
+ throw error;
161
+ return undefined;
162
+ }
163
+ };
164
+ const initial = (p) => { tick(); try {
165
+ reachState();
166
+ return { p, state: run.init(p), path: [], depth: 0 };
167
+ }
168
+ catch (error) {
169
+ if (error instanceof BudgetExpired || error instanceof WallExpired)
170
+ throw error;
171
+ return undefined;
172
+ } };
173
+ function screen(law, ordinary, citing, until, model) {
174
+ checkBudget('reachable promotion parent');
175
+ const existing = registered.get(law.name), keyOfLaw = strategyLawKey(law);
176
+ if (existing && existing.key !== keyOfLaw)
177
+ throw Error('ambiguous reachable candidate name');
178
+ if (!existing) {
179
+ registered.set(law.name, { law, key: keyOfLaw });
180
+ ledger.addCandidates([law]);
181
+ }
182
+ law = registered.get(law.name).law;
183
+ refresh();
184
+ const previous = receipts.get(law.name);
185
+ if (previous)
186
+ return previous;
187
+ // Names are unique within a request. A changed/reordered body with the
188
+ // same name may lose reuse, but must never earn another search grant.
189
+ const key = law.name, fund = funding.get(key) ?? { grant: countReachabilityAllowance(root, ordinary, citing), used: 0 };
190
+ funding.set(key, fund);
191
+ const grant = Math.max(0, fund.grant - fund.used), start = clock(), end = Math.min(until, start + grant);
192
+ const row = { law: law.name, stage: 'samples', outcome: 'no-witness', granted: Math.max(0, end - start) * fullRate, used: 0, incomplete: true, phases: [], maxSize: 0, maxDepth: 0 };
193
+ receipts.set(law.name, row);
194
+ let found = false;
195
+ const seen = (node) => { row.maxSize = Math.max(row.maxSize, ...Object.values(node.p), 0); row.maxDepth = Math.max(row.maxDepth, node.depth); return found = replay(law, node); };
196
+ const phase = (stage, allowance, body) => {
197
+ if (found || clock() >= end)
198
+ return;
199
+ row.stage = stage;
200
+ const before = clock(), result = countGenerationPhase(Math.min(end, before + allowance), () => withReachabilityWork(body));
201
+ row.phases.push({ stage, used: (clock() - before) * fullRate, complete: result.complete });
202
+ if (!result.complete)
203
+ row.outcome = 'exhausted';
204
+ };
205
+ try {
206
+ const samples = seedSamples();
207
+ phase('samples', Math.min(root / 1000, grant / 3), () => {
208
+ const tight = tightLaw(law);
209
+ const priority = [], other = [];
210
+ for (const { p, sts } of samples)
211
+ for (const state of sts) {
212
+ tick();
213
+ if (evaluate(law, p, state) === false) {
214
+ const path = retainedSamplePath(state, tick);
215
+ if (path && seen({ p, state, path, depth: path.length }))
216
+ return;
217
+ }
218
+ // Evaluate tightness before reconstructing long paths. Non-tight samples
219
+ // must not consume the entire cheap phase's allowance in path copies.
220
+ ;
221
+ (evaluate(tight, p, state) === false ? priority : other).push({ p, state });
222
+ }
223
+ let frontier = [...priority, ...other];
224
+ for (let depth = 0; depth < 2; depth++) {
225
+ const children = [];
226
+ while (frontier.length) {
227
+ const next = [];
228
+ for (const item of frontier) {
229
+ tick();
230
+ if (!item.node) {
231
+ const path = retainedSamplePath(item.state, tick);
232
+ if (!path)
233
+ continue;
234
+ item.node = { p: item.p, state: item.state, path, depth: path.length };
235
+ }
236
+ item.iter ??= requests(source, item.p, Math.max(1, ...Object.values(item.p), 3));
237
+ const r = item.iter.next();
238
+ if (r.done)
239
+ continue;
240
+ next.push(item);
241
+ const child = step(item.node, r.value);
242
+ if (child) {
243
+ if (seen(child))
244
+ return;
245
+ children.push({ ...child, node: child });
246
+ }
247
+ }
248
+ frontier = next;
249
+ }
250
+ frontier = children;
251
+ }
252
+ });
253
+ phase('model', Math.max(0, end - clock()) / 3, () => {
254
+ if (!model)
255
+ return;
256
+ const p = Object.fromEntries(source.params.map(name => [name, model[name] ?? 0]));
257
+ if (!Object.values(p).every(natural))
258
+ return;
259
+ const request = Object.fromEntries(source.inputs.map(name => [name, model[name] ?? 0]));
260
+ for (const name of source.inputMaps ?? [])
261
+ request[name] = new Map();
262
+ for (const [name, value] of Object.entries(model)) {
263
+ tick();
264
+ const bracket = name.indexOf('['), map = request[name.slice(0, bracket)];
265
+ if (bracket >= 0 && name.endsWith(']') && map instanceof Map) {
266
+ const k = keyValue(name, model);
267
+ if (natural(k) && natural(value))
268
+ map.set(k, value);
269
+ }
270
+ }
271
+ const roots = [];
272
+ const init = initial(p);
273
+ if (init)
274
+ roots.push(init);
275
+ for (const sample of samples)
276
+ if (source.params.every(name => sample.p[name] === p[name]))
277
+ for (const state of sample.sts) {
278
+ tick();
279
+ if (Object.keys(source.state).some(name => model[name] !== undefined && state.scalars[name] !== model[name]))
280
+ continue;
281
+ const path = retainedSamplePath(state, tick);
282
+ if (path)
283
+ roots.push({ p, state, path, depth: path.length });
284
+ }
285
+ for (const node of roots) {
286
+ tick();
287
+ if (seen(node))
288
+ return;
289
+ const child = step(node, request);
290
+ if (child && seen(child))
291
+ return;
292
+ }
293
+ });
294
+ phase('frontier', Math.max(0, end - clock()), () => {
295
+ const signature = (state) => JSON.stringify(state, (_key, value) => { tick(); return value instanceof Map ? [...value].sort((a, b) => { tick(); return a[0] - b[0]; }) : value; });
296
+ const lanes = [], params = new Set();
297
+ const add = (p) => { tick(); const key = JSON.stringify(p); if (params.has(key))
298
+ return; params.add(key); const node = initial(p); if (node) {
299
+ if (seen(node))
300
+ return;
301
+ lanes.push({ queue: [node], keys: new Set([signature(node.state)]), at: 0 });
302
+ } };
303
+ if (model)
304
+ add(Object.fromEntries(source.params.map(name => [name, model[name] ?? 0])));
305
+ for (let size = 1; !found; size++) {
306
+ tick();
307
+ if (!source.params.length && size > 1 && lanes.every(l => l.at >= l.queue.length))
308
+ break;
309
+ add(Object.fromEntries(source.params.map(name => [name, size])));
310
+ for (const lane of lanes)
311
+ for (let work = 0; work < 64 && !found; work++) {
312
+ tick();
313
+ const node = lane.queue[lane.at];
314
+ if (!node)
315
+ break;
316
+ lane.iter ??= requests(source, node.p, Math.max(size, ...Object.values(node.p), 1));
317
+ const r = lane.iter.next();
318
+ if (r.done) {
319
+ lane.iter = undefined;
320
+ lane.at++;
321
+ continue;
322
+ }
323
+ const child = step(node, r.value);
324
+ if (child) {
325
+ if (seen(child))
326
+ return;
327
+ const key = signature(child.state);
328
+ if (!lane.keys.has(key)) {
329
+ lane.keys.add(key);
330
+ lane.queue.push(child);
331
+ }
332
+ }
333
+ }
334
+ }
335
+ });
336
+ if (found)
337
+ row.outcome = ledger.safety() === 'broken' ? 'broken' : 'rejected';
338
+ else if (clock() >= end)
339
+ row.outcome = 'exhausted';
340
+ return row;
341
+ }
342
+ finally {
343
+ const spent = clock() - start;
344
+ fund.used += spent;
345
+ row.used = spent * fullRate;
346
+ refresh();
347
+ }
348
+ }
349
+ return { screen, evidence: ledger.evidence, rejectedNames: refresh, rejected: () => refresh().map(name => registered.get(name).law), safety: ledger.safety,
350
+ receipts: (laws) => { refresh(); return laws.map(law => ({ ...receipts.get(law.name) ?? { law: law.name, stage: 'not-required', outcome: 'not-required', granted: 0, used: 0, incomplete: true, phases: [], maxSize: 0, maxDepth: 0 }, cumulativeUsed: (funding.get(law.name)?.used ?? 0) * fullRate })); } };
351
+ }
@@ -0,0 +1,9 @@
1
+ import { type Goal, type Path, type Tree } from '../kernel/kernel.js';
2
+ export declare function rebasePath(g: Goal, tree: Tree, from: Path, to: Path, until: number, target?: Goal): Tree | undefined;
3
+ export declare function pruneForcedCuts(g: Goal, tree: Tree, root: Path, cuts: {
4
+ split: Record<string, number>;
5
+ no: Tree;
6
+ }[], until: number): {
7
+ tree: Tree;
8
+ removed: number;
9
+ };
@@ -0,0 +1,68 @@
1
+ // Untrusted exact reindexing after removing path assumptions. This never
2
+ // searches and never certifies a result; the caller must check the final tree.
3
+ import { canon } from "../kernel/kernel.js";
4
+ import { late } from "../kernel/prove.js";
5
+ import { rowsAt } from "../kernel/prove.js";
6
+ export function rebasePath(g, tree, from, to, until, target = g) {
7
+ const indices = new WeakMap();
8
+ const visit = (t, a, b) => {
9
+ if (late(until))
10
+ return undefined;
11
+ if (!('leaf' in t)) {
12
+ const id = canon(t.split), known = b.get(id)?.holds;
13
+ if (known !== undefined)
14
+ return visit(known ? t.yes : t.no, new Map(a).set(id, { lin: t.split, holds: known }), b);
15
+ const yes = visit(t.yes, new Map(a).set(id, { lin: t.split, holds: true }), new Map(b).set(id, { lin: t.split, holds: true }));
16
+ const no = yes && visit(t.no, new Map(a).set(id, { lin: t.split, holds: false }), new Map(b).set(id, { lin: t.split, holds: false }));
17
+ return yes && no ? { split: t.split, yes, no } : undefined;
18
+ }
19
+ const before = rowsAt(g, a), after = rowsAt(target, b);
20
+ let at = indices.get(after);
21
+ if (!at) {
22
+ at = new Map();
23
+ after.forEach((r, i) => { const id = canon(r.lin); if (!at.has(id))
24
+ at.set(id, i); });
25
+ indices.set(after, at);
26
+ }
27
+ const map = (i) => i < before.length ? at.get(canon(before[i].lin)) : i - before.length + after.length;
28
+ const leaf = [];
29
+ for (const step of t.leaf) {
30
+ if (step.kind !== 'input') {
31
+ leaf.push(step);
32
+ continue;
33
+ }
34
+ const index = map(step.index);
35
+ if (index === undefined)
36
+ return undefined;
37
+ leaf.push({ ...step, index });
38
+ }
39
+ const products = [];
40
+ for (const [a, b] of t.products ?? []) {
41
+ const x = map(a), y = map(b);
42
+ if (x === undefined || y === undefined)
43
+ return undefined;
44
+ products.push([x, y]);
45
+ }
46
+ return { leaf, ...(t.products ? { products } : {}), ...(t.squares ? { squares: t.squares } : {}) };
47
+ };
48
+ return visit(tree, from, to);
49
+ }
50
+ // Cuts are listed in the order they extended the path. Drop a cut only when
51
+ // its retained branch can be reindexed without that assumption. Rejected or
52
+ // timed-out proposals retain the original exhaustive split and its proof.
53
+ export function pruneForcedCuts(g, tree, root, cuts, until) {
54
+ const paths = [new Map(root)];
55
+ for (const cut of cuts)
56
+ paths.push(new Map(paths.at(-1)).set(canon(cut.split), { lin: cut.split, holds: true }));
57
+ let out = tree, removed = 0;
58
+ for (let i = cuts.length - 1; i >= 0; i--) {
59
+ const cut = cuts[i], shorter = rebasePath(g, out, paths[i + 1], paths[i], until);
60
+ if (shorter) {
61
+ out = shorter;
62
+ removed++;
63
+ }
64
+ else
65
+ out = { split: cut.split, yes: out, no: cut.no };
66
+ }
67
+ return { tree: out, removed };
68
+ }
@@ -0,0 +1,45 @@
1
+ export type CountRecipeContextEvent = {
2
+ phase: 'count-recipe-context';
3
+ outcome: 'refused';
4
+ reason: 'fixed-inventory-context-changed';
5
+ structured: boolean;
6
+ } | {
7
+ phase: 'count-recipe-context';
8
+ outcome: 'reused';
9
+ reason: 'same-inventory-structured-reentry';
10
+ structured: boolean;
11
+ previousStructured: boolean;
12
+ terminalRecipes: number;
13
+ totalRecipes: number;
14
+ };
15
+ export type CountRecipeContextCounts = {
16
+ contextChanges: number;
17
+ structuredReentries: number;
18
+ terminalStructuredReentries: number;
19
+ };
20
+ export type CountRecipeInventoryCounts = {
21
+ passesCreated: number;
22
+ sameContextReentries: number;
23
+ capRefusals: number;
24
+ };
25
+ export declare const countRecipeInventorySnapshot: () => Readonly<CountRecipeInventoryCounts>;
26
+ export declare const countRecipeInventoryDifference: (after: Readonly<CountRecipeInventoryCounts>, before: Readonly<CountRecipeInventoryCounts>) => CountRecipeInventoryCounts;
27
+ export declare const countRecipeContextSnapshot: () => Readonly<CountRecipeContextCounts>;
28
+ export declare const countRecipeContextDifference: (after: Readonly<CountRecipeContextCounts>, before: Readonly<CountRecipeContextCounts>) => CountRecipeContextCounts;
29
+ type FixedInventory = {
30
+ context: string;
31
+ states: readonly {
32
+ recipes: readonly {
33
+ terminal: boolean;
34
+ }[];
35
+ }[];
36
+ };
37
+ export declare const countRecipeContextCap = 4;
38
+ export declare class CountRecipeContexts<T extends FixedInventory> {
39
+ private readonly entries;
40
+ private last;
41
+ get size(): number;
42
+ acquire(context: string, structured: boolean, create: () => T, observe?: (event: CountRecipeContextEvent) => void): T | undefined;
43
+ }
44
+ export declare function countRecipeContextDecision(pass: FixedInventory, context: string, previousStructured: boolean | undefined, structured: boolean, observe?: (event: CountRecipeContextEvent) => void): boolean;
45
+ export {};
@@ -0,0 +1,71 @@
1
+ // Bounded per-context recipe inventories; no proof acceptance authority.
2
+ // Counters are observations only and do not affect control flow.
3
+ import { workLedger } from "./work-admission.js";
4
+ const totals = { contextChanges: 0, structuredReentries: 0, terminalStructuredReentries: 0 };
5
+ const inventoryTotals = { passesCreated: 0, sameContextReentries: 0, capRefusals: 0 };
6
+ export const countRecipeInventorySnapshot = () => ({ ...inventoryTotals });
7
+ export const countRecipeInventoryDifference = (after, before) => ({ passesCreated: after.passesCreated - before.passesCreated, sameContextReentries: after.sameContextReentries - before.sameContextReentries, capRefusals: after.capRefusals - before.capRefusals });
8
+ export const countRecipeContextSnapshot = () => ({ ...totals });
9
+ export const countRecipeContextDifference = (after, before) => ({ contextChanges: after.contextChanges - before.contextChanges, structuredReentries: after.structuredReentries - before.structuredReentries, terminalStructuredReentries: after.terminalStructuredReentries - before.terminalStructuredReentries });
10
+ // A fixed pass never changes its inventory. Distinct contexts get fresh passes
11
+ // under the same caller-owned allowance, with no held state or credit copied.
12
+ export const countRecipeContextCap = 4;
13
+ export class CountRecipeContexts {
14
+ entries = new Map();
15
+ last;
16
+ get size() { return this.entries.size; }
17
+ acquire(context, structured, create, observe) {
18
+ const entry = this.entries.get(context);
19
+ if (entry) {
20
+ // Keep the existing same-context comparison and diagnostic charges exactly.
21
+ workLedger.start('tableCells', Math.min(context.length, entry.pass.context.length), 'count recipe inventory context');
22
+ if (!countRecipeContextDecision(entry.pass, context, entry.structured, structured, observe))
23
+ return undefined;
24
+ inventoryTotals.sameContextReentries++;
25
+ entry.structured = structured;
26
+ this.last = entry.pass;
27
+ return entry.pass;
28
+ }
29
+ if (this.entries.size >= countRecipeContextCap) {
30
+ // Fifth distinct key: no inventory construction, search or new allowance.
31
+ // The existing comparison/refusal event remains the only attempted work.
32
+ const last = this.last;
33
+ workLedger.start('tableCells', Math.min(context.length, last.context.length), 'count recipe inventory context');
34
+ countRecipeContextDecision(last, context, undefined, structured, observe);
35
+ inventoryTotals.capRefusals++;
36
+ return undefined;
37
+ }
38
+ const pass = create();
39
+ if (pass.context !== context)
40
+ throw Error('count recipe context factory mismatch');
41
+ this.entries.set(context, { pass, structured });
42
+ this.last = pass;
43
+ inventoryTotals.passesCreated++;
44
+ return pass;
45
+ }
46
+ }
47
+ export function countRecipeContextDecision(pass, context, previousStructured, structured, observe) {
48
+ workLedger.start('ticks', 1, 'count recipe context decision');
49
+ if (context !== pass.context) {
50
+ totals.contextChanges++;
51
+ observe?.({ phase: 'count-recipe-context', outcome: 'refused', reason: 'fixed-inventory-context-changed', structured });
52
+ return false;
53
+ }
54
+ if (previousStructured !== undefined && previousStructured !== structured) {
55
+ let terminalRecipes = 0, totalRecipes = 0;
56
+ for (const state of pass.states) {
57
+ workLedger.start('ticks', 1, 'count recipe context member');
58
+ for (const recipe of state.recipes) {
59
+ workLedger.start('ticks', 1, 'count recipe context recipe');
60
+ totalRecipes++;
61
+ if (recipe.terminal)
62
+ terminalRecipes++;
63
+ }
64
+ }
65
+ totals.structuredReentries++;
66
+ if (terminalRecipes === totalRecipes)
67
+ totals.terminalStructuredReentries++;
68
+ observe?.({ phase: 'count-recipe-context', outcome: 'reused', reason: 'same-inventory-structured-reentry', structured, previousStructured, terminalRecipes, totalRecipes });
69
+ }
70
+ return true;
71
+ }
@@ -0,0 +1,115 @@
1
+ import { type CountRecipeGraph } from './count-recipe-graph.js';
2
+ import { CountAttemptTickets, type CountAttemptStop, type CountRetryKey } from './count-retry-budget.js';
3
+ import { type LiftedWorkBudget } from './count-lifted-budget.js';
4
+ import { type HeldCountPayload } from './count-closed-family.js';
5
+ import { type WorkLedger } from './work-admission.js';
6
+ import { type WorkAmount } from './work-amount.js';
7
+ export type CountControllerRecipe = Readonly<{
8
+ id: string;
9
+ kind: 'ordinary' | 'strategy';
10
+ required?: readonly string[];
11
+ caseKeys?: readonly string[];
12
+ }>;
13
+ export type CountControllerMember = Readonly<{
14
+ name: string;
15
+ reference: number;
16
+ recipes: readonly CountControllerRecipe[];
17
+ }>;
18
+ export type CountCaptured<T> = Readonly<{
19
+ payload: T;
20
+ premises: readonly string[];
21
+ checkedReduced: boolean;
22
+ checkCost: WorkAmount;
23
+ }>;
24
+ type RecipeState = {
25
+ recipe: CountControllerRecipe;
26
+ tickets: CountAttemptTickets;
27
+ terminal: boolean;
28
+ keys: readonly CountRetryKey[];
29
+ stop?: CountAttemptStop;
30
+ };
31
+ type MemberState = {
32
+ member: CountControllerMember;
33
+ recipes: RecipeState[];
34
+ allotted?: WorkAmount;
35
+ allocationCohort?: number;
36
+ allocationRemaining?: WorkAmount;
37
+ used: WorkAmount;
38
+ held?: CountCaptured<unknown> & {
39
+ recipeId: string;
40
+ };
41
+ };
42
+ export declare function countRecipeAllocationCohort(members: Iterable<string>, graph: CountRecipeGraph, selected: string, tick: () => void): number;
43
+ export declare function countRecipeMemberAllotment(remaining: WorkAmount, cohort: number, kind: 'ordinary' | 'strategy', tick: WorkAmount): WorkAmount;
44
+ export declare class CountRecipePass<T> {
45
+ readonly bank: WorkLedger;
46
+ readonly rootEpoch: number;
47
+ readonly original: WorkAmount;
48
+ readonly rootEnd: WorkAmount;
49
+ readonly states: MemberState[];
50
+ supplierRepairUsed: boolean;
51
+ context: string;
52
+ constructor(members: readonly CountControllerMember[], context: string, bank?: WorkLedger);
53
+ reconcile(context: string): void;
54
+ held(): ReadonlyMap<string, CountCaptured<T> & {
55
+ recipeId: string;
56
+ }>;
57
+ }
58
+ export declare function claimCountClosingFallback(pass: {
59
+ supplierRepairUsed: boolean;
60
+ }, actualTransportDecline: boolean): boolean;
61
+ export type CountRecipePassSnapshot<T> = Readonly<{
62
+ rootEpoch: number;
63
+ original: WorkAmount;
64
+ rootEnd: WorkAmount;
65
+ context: string;
66
+ supplierRepairUsed: boolean;
67
+ states: readonly (Omit<MemberState, 'recipes' | 'held'> & {
68
+ recipes: readonly (Omit<RecipeState, 'tickets'> & {
69
+ tickets: ReturnType<CountAttemptTickets['snapshot']>;
70
+ })[];
71
+ held?: CountCaptured<T> & {
72
+ recipeId: string;
73
+ };
74
+ })[];
75
+ }>;
76
+ export type CountRecipeClosingEntry<T> = Readonly<{
77
+ pass: CountRecipePassSnapshot<T>;
78
+ targets: readonly string[];
79
+ reason: CountControllerReason;
80
+ failure?: CountControllerFailure;
81
+ }>;
82
+ export declare const countRecipeCaptureObservation: {
83
+ failures: number;
84
+ };
85
+ export declare function snapshotCountRecipePass<T>(pass: CountRecipePass<T>): CountRecipePassSnapshot<T>;
86
+ export type CountControllerHooks<T, R, P = CountCaptured<T>> = Readonly<{
87
+ construct: (name: string, recipe: CountControllerRecipe, lease: LiftedWorkBudget | undefined) => P | undefined;
88
+ capture?: (name: string, recipe: CountControllerRecipe, proposal: P) => CountCaptured<T> | undefined;
89
+ preflight?: (name: string, recipe: CountControllerRecipe) => boolean;
90
+ close: (rows: readonly HeldCountPayload<T>[], targetInFamily: boolean, wholeClosed?: () => readonly HeldCountPayload<T>[]) => R;
91
+ declinedMember?: () => string | undefined;
92
+ repairSuppliers?: (name: string, payload: T) => Readonly<{
93
+ payload: T;
94
+ premises: readonly string[];
95
+ }> | undefined;
96
+ observe?: (event: Record<string, unknown>) => void;
97
+ active?: ReadonlySet<string>;
98
+ basis?: ReadonlySet<string>;
99
+ beforeClosing?: (entry: CountRecipeClosingEntry<T>) => void;
100
+ }>;
101
+ export type CountControllerReason = 'stale-root' | 'target-held' | 'target-blocked' | 'nothing-eligible' | 'phase-cap';
102
+ export type CountControllerFailure = Readonly<{
103
+ law?: string;
104
+ recipe?: string;
105
+ outcome: 'decline' | 'not-started' | 'hard-cap' | 'unfinished';
106
+ reason: string;
107
+ stop?: CountAttemptStop;
108
+ }>;
109
+ export declare function runCountRecipeController<T, R, P = CountCaptured<T>>(pass: CountRecipePass<T>, targets: readonly string[], hooks: CountControllerHooks<T, R, P>): Readonly<{
110
+ result?: R;
111
+ reason: CountControllerReason;
112
+ failure?: CountControllerFailure;
113
+ closingRoute?: 'legacy' | 'subset' | 'empty' | 'unfunded';
114
+ }>;
115
+ export {};