@orygn/opa-mcp 0.5.0 → 0.6.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 (176) hide show
  1. package/CHANGELOG.md +244 -1
  2. package/README.md +98 -51
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +1 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/config.d.ts +13 -3
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +35 -5
  9. package/dist/config.js.map +1 -1
  10. package/dist/constants.d.ts +1 -6
  11. package/dist/constants.d.ts.map +1 -1
  12. package/dist/constants.js +17 -3
  13. package/dist/constants.js.map +1 -1
  14. package/dist/lib/conftest-cli.d.ts.map +1 -1
  15. package/dist/lib/conftest-cli.js +81 -17
  16. package/dist/lib/conftest-cli.js.map +1 -1
  17. package/dist/lib/errors.d.ts +4 -5
  18. package/dist/lib/errors.d.ts.map +1 -1
  19. package/dist/lib/errors.js +15 -3
  20. package/dist/lib/errors.js.map +1 -1
  21. package/dist/lib/inline-paths.d.ts +37 -0
  22. package/dist/lib/inline-paths.d.ts.map +1 -0
  23. package/dist/lib/inline-paths.js +162 -0
  24. package/dist/lib/inline-paths.js.map +1 -0
  25. package/dist/lib/opa-cli.d.ts +10 -0
  26. package/dist/lib/opa-cli.d.ts.map +1 -1
  27. package/dist/lib/opa-cli.js +9 -2
  28. package/dist/lib/opa-cli.js.map +1 -1
  29. package/dist/lib/opa-client.d.ts +27 -1
  30. package/dist/lib/opa-client.d.ts.map +1 -1
  31. package/dist/lib/opa-client.js +98 -14
  32. package/dist/lib/opa-client.js.map +1 -1
  33. package/dist/lib/opa-paths.d.ts +11 -1
  34. package/dist/lib/opa-paths.d.ts.map +1 -1
  35. package/dist/lib/opa-paths.js +25 -21
  36. package/dist/lib/opa-paths.js.map +1 -1
  37. package/dist/lib/output.d.ts.map +1 -1
  38. package/dist/lib/output.js +83 -10
  39. package/dist/lib/output.js.map +1 -1
  40. package/dist/lib/rego-ast-walker.d.ts +0 -6
  41. package/dist/lib/rego-ast-walker.d.ts.map +1 -1
  42. package/dist/lib/rego-ast-walker.js +48 -46
  43. package/dist/lib/rego-ast-walker.js.map +1 -1
  44. package/dist/lib/rego-counterexample.d.ts +14 -1
  45. package/dist/lib/rego-counterexample.d.ts.map +1 -1
  46. package/dist/lib/rego-counterexample.js +40 -10
  47. package/dist/lib/rego-counterexample.js.map +1 -1
  48. package/dist/lib/rego-input-path.d.ts +20 -0
  49. package/dist/lib/rego-input-path.d.ts.map +1 -0
  50. package/dist/lib/rego-input-path.js +70 -0
  51. package/dist/lib/rego-input-path.js.map +1 -0
  52. package/dist/lib/rego-ir.d.ts +2 -1
  53. package/dist/lib/rego-ir.d.ts.map +1 -1
  54. package/dist/lib/rego-smt-encoder.d.ts +35 -0
  55. package/dist/lib/rego-smt-encoder.d.ts.map +1 -1
  56. package/dist/lib/rego-smt-encoder.js +81 -8
  57. package/dist/lib/rego-smt-encoder.js.map +1 -1
  58. package/dist/lib/rego-type-inferencer.d.ts +26 -1
  59. package/dist/lib/rego-type-inferencer.d.ts.map +1 -1
  60. package/dist/lib/rego-type-inferencer.js +68 -0
  61. package/dist/lib/rego-type-inferencer.js.map +1 -1
  62. package/dist/lib/rego-verify-engine.d.ts.map +1 -1
  63. package/dist/lib/rego-verify-engine.js +171 -90
  64. package/dist/lib/rego-verify-engine.js.map +1 -1
  65. package/dist/lib/rego-z3.d.ts +56 -0
  66. package/dist/lib/rego-z3.d.ts.map +1 -1
  67. package/dist/lib/rego-z3.js +276 -7
  68. package/dist/lib/rego-z3.js.map +1 -1
  69. package/dist/lib/subprocess.d.ts +13 -0
  70. package/dist/lib/subprocess.d.ts.map +1 -1
  71. package/dist/lib/subprocess.js +153 -18
  72. package/dist/lib/subprocess.js.map +1 -1
  73. package/dist/lib/tool-helpers.d.ts +12 -25
  74. package/dist/lib/tool-helpers.d.ts.map +1 -1
  75. package/dist/lib/tool-helpers.js +66 -40
  76. package/dist/lib/tool-helpers.js.map +1 -1
  77. package/dist/prompts/index.js +2 -2
  78. package/dist/resources/index.js +1 -1
  79. package/dist/resources/index.js.map +1 -1
  80. package/dist/resources/patterns.d.ts +1 -1
  81. package/dist/resources/patterns.d.ts.map +1 -1
  82. package/dist/resources/patterns.js +2 -3
  83. package/dist/resources/patterns.js.map +1 -1
  84. package/dist/server.d.ts +2 -2
  85. package/dist/server.d.ts.map +1 -1
  86. package/dist/server.js +40 -5
  87. package/dist/server.js.map +1 -1
  88. package/dist/tools/authoring/capabilities.d.ts +4 -0
  89. package/dist/tools/authoring/capabilities.d.ts.map +1 -1
  90. package/dist/tools/authoring/capabilities.js +41 -4
  91. package/dist/tools/authoring/capabilities.js.map +1 -1
  92. package/dist/tools/authoring/check-schema.d.ts +6 -0
  93. package/dist/tools/authoring/check-schema.d.ts.map +1 -1
  94. package/dist/tools/authoring/check-schema.js +56 -3
  95. package/dist/tools/authoring/check-schema.js.map +1 -1
  96. package/dist/tools/authoring/format.d.ts.map +1 -1
  97. package/dist/tools/authoring/format.js +2 -2
  98. package/dist/tools/authoring/format.js.map +1 -1
  99. package/dist/tools/authoring/lint.d.ts.map +1 -1
  100. package/dist/tools/authoring/lint.js +8 -6
  101. package/dist/tools/authoring/lint.js.map +1 -1
  102. package/dist/tools/authoring/migrate-v1.d.ts.map +1 -1
  103. package/dist/tools/authoring/migrate-v1.js +20 -4
  104. package/dist/tools/authoring/migrate-v1.js.map +1 -1
  105. package/dist/tools/authoring/parse.d.ts.map +1 -1
  106. package/dist/tools/authoring/parse.js +3 -3
  107. package/dist/tools/authoring/parse.js.map +1 -1
  108. package/dist/tools/bundles/sign.d.ts.map +1 -1
  109. package/dist/tools/bundles/sign.js +14 -34
  110. package/dist/tools/bundles/sign.js.map +1 -1
  111. package/dist/tools/conftest/index.d.ts +5 -0
  112. package/dist/tools/conftest/index.d.ts.map +1 -1
  113. package/dist/tools/conftest/index.js.map +1 -1
  114. package/dist/tools/conftest/test.d.ts.map +1 -1
  115. package/dist/tools/conftest/test.js +16 -17
  116. package/dist/tools/conftest/test.js.map +1 -1
  117. package/dist/tools/conftest/verify.d.ts.map +1 -1
  118. package/dist/tools/conftest/verify.js +14 -18
  119. package/dist/tools/conftest/verify.js.map +1 -1
  120. package/dist/tools/evaluation/_shared.js +9 -12
  121. package/dist/tools/evaluation/_shared.js.map +1 -1
  122. package/dist/tools/evaluation/bench.d.ts +20 -9
  123. package/dist/tools/evaluation/bench.d.ts.map +1 -1
  124. package/dist/tools/evaluation/bench.js +31 -12
  125. package/dist/tools/evaluation/bench.js.map +1 -1
  126. package/dist/tools/evaluation/compile.js +4 -4
  127. package/dist/tools/evaluation/compile.js.map +1 -1
  128. package/dist/tools/evaluation/eval.d.ts.map +1 -1
  129. package/dist/tools/evaluation/eval.js +12 -16
  130. package/dist/tools/evaluation/eval.js.map +1 -1
  131. package/dist/tools/evaluation/exec.d.ts.map +1 -1
  132. package/dist/tools/evaluation/exec.js +3 -4
  133. package/dist/tools/evaluation/exec.js.map +1 -1
  134. package/dist/tools/evaluation/test-multiroot.d.ts +2 -0
  135. package/dist/tools/evaluation/test-multiroot.d.ts.map +1 -1
  136. package/dist/tools/evaluation/test-multiroot.js +23 -6
  137. package/dist/tools/evaluation/test-multiroot.js.map +1 -1
  138. package/dist/tools/evaluation/test.d.ts.map +1 -1
  139. package/dist/tools/evaluation/test.js +8 -6
  140. package/dist/tools/evaluation/test.js.map +1 -1
  141. package/dist/tools/helpers/coverage-gaps.d.ts.map +1 -1
  142. package/dist/tools/helpers/coverage-gaps.js +3 -4
  143. package/dist/tools/helpers/coverage-gaps.js.map +1 -1
  144. package/dist/tools/helpers/describe-policy.d.ts.map +1 -1
  145. package/dist/tools/helpers/describe-policy.js +2 -2
  146. package/dist/tools/helpers/describe-policy.js.map +1 -1
  147. package/dist/tools/helpers/explain-decision.d.ts.map +1 -1
  148. package/dist/tools/helpers/explain-decision.js +3 -4
  149. package/dist/tools/helpers/explain-decision.js.map +1 -1
  150. package/dist/tools/helpers/explain-undefined.d.ts.map +1 -1
  151. package/dist/tools/helpers/explain-undefined.js +131 -22
  152. package/dist/tools/helpers/explain-undefined.js.map +1 -1
  153. package/dist/tools/helpers/fix.d.ts +11 -5
  154. package/dist/tools/helpers/fix.d.ts.map +1 -1
  155. package/dist/tools/helpers/fix.js +88 -45
  156. package/dist/tools/helpers/fix.js.map +1 -1
  157. package/dist/tools/helpers/generate-test-skeleton.d.ts.map +1 -1
  158. package/dist/tools/helpers/generate-test-skeleton.js +105 -21
  159. package/dist/tools/helpers/generate-test-skeleton.js.map +1 -1
  160. package/dist/tools/helpers/playground-share.d.ts +4 -2
  161. package/dist/tools/helpers/playground-share.d.ts.map +1 -1
  162. package/dist/tools/helpers/playground-share.js +13 -3
  163. package/dist/tools/helpers/playground-share.js.map +1 -1
  164. package/dist/tools/helpers/policy-diff.d.ts.map +1 -1
  165. package/dist/tools/helpers/policy-diff.js +3 -4
  166. package/dist/tools/helpers/policy-diff.js.map +1 -1
  167. package/dist/tools/helpers/security-audit.d.ts.map +1 -1
  168. package/dist/tools/helpers/security-audit.js +19 -19
  169. package/dist/tools/helpers/security-audit.js.map +1 -1
  170. package/dist/tools/meta/index.d.ts +1 -1
  171. package/dist/tools/server-management/_shared.d.ts.map +1 -1
  172. package/dist/tools/server-management/_shared.js +13 -1
  173. package/dist/tools/server-management/_shared.js.map +1 -1
  174. package/dist/types.d.ts +1 -1
  175. package/dist/types.d.ts.map +1 -1
  176. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  import { walkModule } from './rego-ast-walker.js';
2
- import { inferTypes } from './rego-type-inferencer.js';
3
- import { createInputVars, encodeRule } from './rego-smt-encoder.js';
2
+ import { collectPathReads, inferTypes } from './rego-type-inferencer.js';
3
+ import { clauseInputPaths, createInputVars, structuralAxioms, encodeRule, } from './rego-smt-encoder.js';
4
4
  import { extractCounterexample, formatCounterexample, } from './rego-counterexample.js';
5
5
  import { describeProperty } from './rego-property-parser.js';
6
- import { getZ3, withZ3Lock } from './rego-z3.js';
6
+ import { getZ3, isZ3RecoverableMessage, isZ3UnavailableMessage, withZ3Lock, Z3_SOLVER_MAX_MEMORY_MB, } from './rego-z3.js';
7
7
  // Monotonically increasing counter used to generate a unique prefix for all
8
8
  // Z3 constant names within each runVerify call. This prevents sort conflicts
9
9
  // when the same input path is inferred with different sorts across calls
@@ -17,6 +17,10 @@ const SOLVER_TIMEOUT_MS = 10_000;
17
17
  * The caller must pass the JSON-parsed result of `opa parse --format=json`.
18
18
  */
19
19
  export async function runVerify(ast, property, signal) {
20
+ return verifyAttempt(ast, property, signal, 0);
21
+ }
22
+ /** One attempt; a fault that cuts it short earns one more on a fresh module. */
23
+ async function verifyAttempt(ast, property, signal, attempt) {
20
24
  const walked = walkModule(ast);
21
25
  const warnings = [];
22
26
  const targetClauses = walked.rules.get(property.ruleName);
@@ -58,6 +62,49 @@ export async function runVerify(ast, property, signal) {
58
62
  for (const conflict of typeResult.conflicts) {
59
63
  warnings.push(conflict.reason);
60
64
  }
65
+ // How this rule reads each path. Scoped to the rule under test: what
66
+ // another rule of the module does with a field says nothing about the
67
+ // inputs that reach this one.
68
+ const reads = collectPathReads(targetClauses);
69
+ // Every path this rule reads, with its segments. Also what a witness may
70
+ // name: a path from another rule has no constraint here, so model
71
+ // completion would invent a value for it.
72
+ const rulePaths = new Map();
73
+ for (const path of clauseInputPaths(targetClauses)) {
74
+ const segs = walked.inputPaths.get(path);
75
+ if (segs !== undefined)
76
+ rulePaths.set(path, segs);
77
+ }
78
+ // A field the rule reads beneath is an object in any input that reaches
79
+ // that read, yet the model gives it one scalar value. Comparing it as a
80
+ // value in a way the structural axioms do not cover (anything but
81
+ // equality with a scalar literal or a string built-in) can then be
82
+ // satisfied by a model whose witness carries the object, on which OPA
83
+ // decides the comparison the other way; under a negated property the
84
+ // directions that happen to hold for an object flip. No verdict from such
85
+ // a model can be trusted, so the rule is reported inconclusive.
86
+ const comparedParents = [...reads.valueReads]
87
+ .filter((path) => {
88
+ const segs = rulePaths.get(path);
89
+ if (segs === undefined)
90
+ return false;
91
+ for (const otherSegs of rulePaths.values()) {
92
+ if (otherSegs.length > segs.length && segs.every((seg, i) => otherSegs[i] === seg)) {
93
+ return true;
94
+ }
95
+ }
96
+ return false;
97
+ })
98
+ .sort();
99
+ if (comparedParents.length > 0) {
100
+ return inconclusive(property, `Rule "${property.ruleName}" compares ${comparedParents.join(', ')} as a value and also reads a field beneath it. Such a field is an object wherever the deeper read holds, which the encoder cannot model, so verification is inconclusive.`, [
101
+ ...unsupportedInRule,
102
+ {
103
+ constructType: 'parent_field_compared_as_value',
104
+ description: `${comparedParents.join(', ')} compared as a value while a field beneath it is also read`,
105
+ },
106
+ ], warnings);
107
+ }
61
108
  signal?.throwIfAborted();
62
109
  // Everything below touches the shared Z3 Context, which is one
63
110
  // single-threaded WASM heap. Concurrent MCP tool calls must not overlap
@@ -78,110 +125,134 @@ export async function runVerify(ast, property, signal) {
78
125
  if (encoded.unencodable) {
79
126
  return inconclusive(property, `Rule "${property.ruleName}" contains a value or operand the encoder cannot represent (for example a null literal). Verification is inconclusive rather than guessed.`, unsupportedInRule, warnings);
80
127
  }
81
- // Z3's high-level Solver and Model objects use FinalizationRegistry internally
82
- // (solver_dec_ref / model_dec_ref) so they are cleaned up when GC'd.
83
- // We avoid holding a reference to the Model beyond extractCounterexample so
84
- // it becomes eligible for GC as soon as the call returns, reducing WASM heap
85
- // pressure under high call volume.
128
+ // Released in the finally below, along with its model, rather than
129
+ // left to the collector, which cannot see Z3's memory: measured, that
130
+ // release alone is what holds 1500 solves at about 210 MB. The
131
+ // formula's nodes go through z3-solver's finalizers, which rego-z3
132
+ // holds until no solve is running.
86
133
  const solver = new Z3.Solver();
87
- // Set timeout to prevent hanging on complex policies
88
- solver.set('timeout', SOLVER_TIMEOUT_MS);
89
- switch (property.kind) {
90
- case 'always_true':
91
- // Prove rule is always true: check if NOT(rule) is satisfiable.
92
- // SAT → counterexample (input where rule is false)
93
- // UNSAT → proven always true
94
- solver.add(Z3.Not(encoded.formula));
95
- break;
96
- case 'never_true':
97
- // Prove rule is never true: check if rule IS satisfiable.
98
- // SAT → counterexample (input where rule fires, violating "never")
99
- // UNSAT → proven never true
100
- solver.add(encoded.formula);
101
- break;
102
- case 'satisfiable':
103
- // Check if any input satisfies the rule.
104
- // SAT → witness found (not a bug, just a satisfying input)
105
- // UNSAT → rule is vacuously false / dead code
106
- solver.add(encoded.formula);
107
- break;
108
- }
109
- signal?.throwIfAborted();
110
- let solverResult = await solver.check();
111
- // Prefer a witness in which every field the rule reads is PRESENT.
112
- //
113
- // With absence modelled, Z3 will happily satisfy NOT(rule) by omitting a
114
- // field, which is sound but unhelpful: "it fails when the input is empty"
115
- // is rarely the case a reviewer is chasing. Re-ask with presence forced and
116
- // keep that model when one exists, otherwise fall back to the original.
117
- // Soundness is unaffected either way, since both are real models.
118
- if (solverResult === 'sat' && presenceVars.size > 0) {
119
- solver.push();
120
- for (const present of presenceVars.values())
121
- solver.add(present);
122
- const withPresence = await solver.check();
123
- if (withPresence === 'sat') {
124
- solverResult = withPresence;
134
+ try {
135
+ // Bounded in time and in memory. The solver's memory bound sits below
136
+ // the process ceiling so that running out answers "unknown" at a
137
+ // checkpoint instead of failing an allocation; see rego-z3.ts.
138
+ solver.set('timeout', SOLVER_TIMEOUT_MS);
139
+ solver.set('max_memory', Z3_SOLVER_MAX_MEMORY_MB);
140
+ switch (property.kind) {
141
+ case 'always_true':
142
+ // Prove rule is always true: check if NOT(rule) is satisfiable.
143
+ // SAT → counterexample (input where rule is false)
144
+ // UNSAT → proven always true
145
+ solver.add(Z3.Not(encoded.formula));
146
+ break;
147
+ case 'never_true':
148
+ // Prove rule is never true: check if rule IS satisfiable.
149
+ // SAT → counterexample (input where rule fires, violating "never")
150
+ // UNSAT → proven never true
151
+ solver.add(encoded.formula);
152
+ break;
153
+ case 'satisfiable':
154
+ // Check if any input satisfies the rule.
155
+ // SAT → witness found (not a bug, just a satisfying input)
156
+ // UNSAT → rule is vacuously false / dead code
157
+ solver.add(encoded.formula);
158
+ break;
125
159
  }
126
- else {
127
- solver.pop();
160
+ signal?.throwIfAborted();
161
+ // What any real input looks like, alongside the property.
162
+ for (const axiom of structuralAxioms(Z3, walked.inputPaths, reads.scalarPaths, presenceVars)) {
163
+ solver.add(axiom);
128
164
  }
129
- }
130
- if (solverResult === 'unknown') {
131
- return inconclusive(property, `Z3 solver returned "unknown" (timeout or resource limit reached after ${SOLVER_TIMEOUT_MS}ms). The policy may be too complex for automated verification.`, unsupportedInRule, warnings);
132
- }
133
- if (solverResult === 'unsat') {
165
+ let solverResult = await solver.check();
166
+ // Prefer a witness in which every field the rule reads is PRESENT.
167
+ //
168
+ // With absence modelled, Z3 will happily satisfy NOT(rule) by omitting a
169
+ // field, which is sound but unhelpful: "it fails when the input is empty"
170
+ // is rarely the case a reviewer is chasing. Re-ask with presence forced and
171
+ // keep that model when one exists, otherwise fall back to the original.
172
+ // Soundness is unaffected either way, since both are real models.
173
+ if (solverResult === 'sat' && presenceVars.size > 0) {
174
+ solver.push();
175
+ for (const present of presenceVars.values())
176
+ solver.add(present);
177
+ const withPresence = await solver.check();
178
+ if (withPresence === 'sat') {
179
+ solverResult = withPresence;
180
+ }
181
+ else {
182
+ // The model belongs to the last check; after the pop that was an
183
+ // unsat one, so ask again before reading it.
184
+ solver.pop();
185
+ solverResult = await solver.check();
186
+ }
187
+ }
188
+ if (solverResult === 'unknown') {
189
+ return inconclusive(property, `Z3 solver returned "unknown": the ${SOLVER_TIMEOUT_MS}ms time limit or the ${Z3_SOLVER_MAX_MEMORY_MB} MB memory limit was reached. The policy may be too complex for automated verification.`, unsupportedInRule, warnings);
190
+ }
191
+ if (solverResult === 'unsat') {
192
+ if (property.kind === 'satisfiable') {
193
+ // No satisfying input exists -- rule is dead code or has contradictory conditions.
194
+ return {
195
+ verdict: 'unsatisfiable',
196
+ property: describeProperty(property),
197
+ rule: property.ruleName,
198
+ unsupportedConstructs: unsupportedInRule,
199
+ warnings,
200
+ message: `UNSATISFIABLE: No input can make "${property.ruleName}" true. The rule may be dead code or have contradictory conditions.`,
201
+ };
202
+ }
203
+ // For always_true / never_true: UNSAT on the negation = property proven
204
+ return {
205
+ verdict: 'proven',
206
+ property: describeProperty(property),
207
+ rule: property.ruleName,
208
+ unsupportedConstructs: unsupportedInRule,
209
+ warnings,
210
+ message: `PROVEN: ${describeProperty(property)}.`,
211
+ };
212
+ }
213
+ // SAT: read the model and release it as soon as the witness is out; it
214
+ // is Z3 memory the collector cannot see.
215
+ const witnessVars = new Map([...inputVars].filter(([path]) => rulePaths.has(path)));
216
+ const witnessPresence = new Map([...presenceVars].filter(([path]) => rulePaths.has(path)));
217
+ const model = solver.model();
218
+ let ce;
219
+ try {
220
+ ce = extractCounterexample(model, witnessVars, typeResult.sorts, witnessPresence);
221
+ }
222
+ finally {
223
+ model.release();
224
+ }
225
+ const ceFormatted = formatCounterexample(ce);
134
226
  if (property.kind === 'satisfiable') {
135
- // No satisfying input exists -- rule is dead code or has contradictory conditions.
136
227
  return {
137
- verdict: 'unsatisfiable',
228
+ verdict: 'proven',
138
229
  property: describeProperty(property),
139
230
  rule: property.ruleName,
231
+ counterexample: ce,
232
+ counterexampleFormatted: ceFormatted,
140
233
  unsupportedConstructs: unsupportedInRule,
141
234
  warnings,
142
- message: `UNSATISFIABLE: No input can make "${property.ruleName}" true. The rule may be dead code or have contradictory conditions.`,
235
+ message: `SATISFIABLE: Found an input that makes "${property.ruleName}" true.\n\nWitness input:\n${ceFormatted}`,
143
236
  };
144
237
  }
145
- // For always_true / never_true: UNSAT on the negation = property proven
238
+ // always_true / never_true: SAT means we found a violation
239
+ const ceLabel = property.kind === 'always_true'
240
+ ? 'input where rule is FALSE'
241
+ : 'input where rule is TRUE (violates "never")';
146
242
  return {
147
- verdict: 'proven',
148
- property: describeProperty(property),
149
- rule: property.ruleName,
150
- unsupportedConstructs: unsupportedInRule,
151
- warnings,
152
- message: `PROVEN: ${describeProperty(property)}.`,
153
- };
154
- }
155
- // SAT: pass solver.model() inline so the Model object is not kept alive
156
- // beyond extractCounterexample -- it becomes GC-eligible immediately after.
157
- const ce = extractCounterexample(solver.model(), inputVars, typeResult.sorts, presenceVars);
158
- const ceFormatted = formatCounterexample(ce);
159
- if (property.kind === 'satisfiable') {
160
- return {
161
- verdict: 'proven',
243
+ verdict: 'counterexample',
162
244
  property: describeProperty(property),
163
245
  rule: property.ruleName,
164
246
  counterexample: ce,
165
247
  counterexampleFormatted: ceFormatted,
166
248
  unsupportedConstructs: unsupportedInRule,
167
249
  warnings,
168
- message: `SATISFIABLE: Found an input that makes "${property.ruleName}" true.\n\nWitness input:\n${ceFormatted}`,
250
+ message: `COUNTEREXAMPLE: Property does NOT hold. Found ${ceLabel}:\n\n${ceFormatted}`,
169
251
  };
170
252
  }
171
- // always_true / never_true: SAT means we found a violation
172
- const ceLabel = property.kind === 'always_true'
173
- ? 'input where rule is FALSE'
174
- : 'input where rule is TRUE (violates "never")';
175
- return {
176
- verdict: 'counterexample',
177
- property: describeProperty(property),
178
- rule: property.ruleName,
179
- counterexample: ce,
180
- counterexampleFormatted: ceFormatted,
181
- unsupportedConstructs: unsupportedInRule,
182
- warnings,
183
- message: `COUNTEREXAMPLE: Property does NOT hold. Found ${ceLabel}:\n\n${ceFormatted}`,
184
- };
253
+ finally {
254
+ solver.release();
255
+ }
185
256
  });
186
257
  }
187
258
  catch (e) {
@@ -191,10 +262,20 @@ export async function runVerify(ast, property, signal) {
191
262
  if (signal?.aborted)
192
263
  throw e;
193
264
  const detail = e instanceof Error ? e.message : String(e);
265
+ // A fault cut this solve short; the next getZ3 brings up a fresh module,
266
+ // so the call is worth one more try before it is reported.
267
+ if (attempt === 0 && isZ3RecoverableMessage(detail)) {
268
+ return verifyAttempt(ast, property, signal, 1);
269
+ }
194
270
  const isSortConflict = /sort/i.test(detail) && /incompat/i.test(detail);
195
- return inconclusive(property, isSortConflict
196
- ? 'The rule constrains an input field to conflicting types (for example, compared against both a number and a string), which cannot be encoded for SMT solving.'
197
- : 'Verification could not be completed due to an internal encoding or solver error.', [
271
+ // A dead Z3 says so in its message; that is the one thing the caller can
272
+ // act on (restart), so it goes through verbatim.
273
+ const z3Down = isZ3UnavailableMessage(detail);
274
+ return inconclusive(property, z3Down
275
+ ? detail
276
+ : isSortConflict
277
+ ? 'The rule constrains an input field to conflicting types (for example, compared against both a number and a string), which cannot be encoded for SMT solving.'
278
+ : 'Verification could not be completed due to an internal encoding or solver error.', [
198
279
  ...unsupportedInRule,
199
280
  {
200
281
  constructType: isSortConflict ? 'type_conflict' : 'encoding_error',
@@ -1 +1 @@
1
- {"version":3,"file":"rego-verify-engine.js","sourceRoot":"","sources":["../../src/lib/rego-verify-engine.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAuB,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjD,4EAA4E;AAC5E,6EAA6E;AAC7E,yEAAyE;AACzE,0EAA0E;AAC1E,qBAAqB;AACrB,IAAI,kBAAkB,GAAG,CAAC,CAAC;AAe3B,6CAA6C;AAC7C,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,GAAc,EACd,QAAwB,EACxB,MAAoB;IAEpB,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,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E,IAAI;oBACd,IAAI,EAAE,IAAI;oBACV,cAAc,EAAE,YAAY;oBAC5B,uBAAuB,EAAE,cAAc;oBACvC,qBAAqB;oBACrB,QAAQ;oBACR,OAAO,EAAE,sBAAsB,IAAI,kEAAkE;iBACtG,CAAC;YACJ,CAAC;YACD,OAAO;gBACL,OAAO,EAAE,eAAe;gBACxB,QAAQ,EAAE,IAAI;gBACd,IAAI,EAAE,IAAI;gBACV,qBAAqB;gBACrB,QAAQ;gBACR,OAAO,EAAE,wBAAwB,IAAI,sEAAsE;aAC5G,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -1,10 +1,66 @@
1
1
  import type { init as Z3Init } from 'z3-solver';
2
2
  export type Z3Context = ReturnType<Awaited<ReturnType<typeof Z3Init>>['Context']>;
3
+ /**
4
+ * Ceiling on Z3's own allocations, in megabytes. Reached, Z3 raises an
5
+ * ordinary exception that the engine turns into an inconclusive verdict.
6
+ * Without it the WASM heap itself runs out, and that abort surfaces outside
7
+ * every try/catch as an uncaughtException that ends the server.
8
+ */
9
+ export declare const Z3_MEMORY_MAX_MB = 1024;
10
+ /**
11
+ * The solver's own bound, checked at its checkpoints, where running out
12
+ * degrades to an "unknown" answer. It sits well below the process ceiling on
13
+ * purpose: at the same value the allocator's exception won the race, and an
14
+ * allocation failing inside a destructor ends in an abort rather than an
15
+ * error. Measured in review: equal caps aborted four times in four; a lower
16
+ * solver bound answered "unknown" four times in four.
17
+ */
18
+ export declare const Z3_SOLVER_MAX_MEMORY_MB = 768;
3
19
  /**
4
20
  * Return the shared Z3 Context, initializing WASM on first call.
5
21
  * Safe to call from concurrent async paths.
6
22
  */
7
23
  export declare function getZ3(): Promise<Z3Context>;
24
+ /** Read back a Z3 global parameter, after initialisation. */
25
+ export declare function getZ3Param(name: string): Promise<string | null>;
26
+ /** Whether a Z3 critical section is running right now. */
27
+ export declare function isZ3Busy(): boolean;
28
+ /**
29
+ * Give up on the Z3 module in use. Called when it failed outside a try/catch:
30
+ * the heap it lives in cannot be trusted. The next call brings up a fresh
31
+ * module, a bounded number of times per process.
32
+ */
33
+ export declare function markZ3Unusable(reason: string): void;
34
+ /**
35
+ * Whether an error message is one of the two this module produces once Z3
36
+ * has been given up on. The engine passes such a message through to the
37
+ * caller verbatim, since a restart is the one thing they can do about it.
38
+ */
39
+ export declare function isZ3UnavailableMessage(detail: string): boolean;
40
+ /**
41
+ * Whether a failure is the solve in flight being cut short by a fault, which
42
+ * a fresh module can answer: the engine retries such a call once.
43
+ */
44
+ export declare function isZ3RecoverableMessage(detail: string): boolean;
45
+ /**
46
+ * How many fresh modules this process may still bring up after a fault.
47
+ * Three for the life of the process, however far apart the faults: each
48
+ * retained instance costs memory, and a fourth fault is a pattern to
49
+ * restart out of, not to ride.
50
+ */
51
+ export declare function z3RecoveriesLeft(): number;
52
+ /** For tests: how many finalizers are waiting for the open section to close. */
53
+ export declare function deferredFinalizersForTesting(): number;
54
+ /**
55
+ * For tests: what z3-solver's finalizers go through. Runs at once when no
56
+ * section is open, otherwise once the open one closes.
57
+ */
58
+ export declare function enqueueFinalizerForTesting(finalizer: () => void): void;
59
+ /**
60
+ * Whether an uncaught error is the WASM heap giving out, rather than some
61
+ * unrelated failure that happened while a solve was running.
62
+ */
63
+ export declare function isZ3Failure(e: unknown): boolean;
8
64
  /**
9
65
  * Run `fn` with exclusive access to the shared Z3 Context.
10
66
  *
@@ -1 +1 @@
1
- {"version":3,"file":"rego-z3.d.ts","sourceRoot":"","sources":["../../src/lib/rego-z3.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC;AAKhD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAKlF;;;GAGG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC,CAKhD;AASD;;;;;;;;GAQG;AACH,wBAAs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