|
| 1 | +# MeTTaScript 2.0.3 |
| 2 | + |
| 3 | +Adds an opt-in, deterministic work budget that bounds how much a single query is allowed to compute. |
| 4 | +Nothing changes for existing programs: the budget is off by default, matching Hyperon, so every terminating |
| 5 | +program produces the same output as 2.0.2, validated byte-identical on the conformance oracle and the full |
| 6 | +test suite. Upgrading from 2.0.2 is safe. |
| 7 | + |
| 8 | +## A deterministic work budget |
| 9 | + |
| 10 | +2.0.2 made recursion depth deterministic but noted a remaining gap: a depth bound bounds depth, not total |
| 11 | +work, so a broadly branching search such as the PLN proof search in `plntestdirect` could run a very long |
| 12 | +time. This release adds the tool to bound that, a per-query limit on the number of evaluation steps. |
| 13 | + |
| 14 | +Set it three equivalent ways: |
| 15 | + |
| 16 | +- In a program: `(pragma! mettascript-max-steps 1000000)` |
| 17 | +- As a run option: `maxSteps: 1000000` |
| 18 | +- On the CLI: `--max-steps 1000000` |
| 19 | + |
| 20 | +When a query exceeds the budget, evaluation stops and yields `(Error <call> ResourceLimit)`. The marker is |
| 21 | +an ordinary value: it is catchable with `case`, and it does not abort the whole query, so every result |
| 22 | +produced before the limit is kept. A budget of `0` means unlimited, which is the default. |
| 23 | + |
| 24 | +The cut is a function of the program and the budget alone. It counts logical evaluation steps, the same way |
| 25 | +on the interpreted and compiled paths, so a query is cut at exactly the same point regardless of the host's |
| 26 | +JavaScript stack size or which evaluator runs it. A test pins this: a broad search is cut at an identical |
| 27 | +step count and returns identical output across four V8 stack sizes and both evaluator paths. |
| 28 | + |
| 29 | +## Why the name |
| 30 | + |
| 31 | +The pragma is `mettascript-max-steps`, not `max-steps`, because it is a MeTTaScript extension with no |
| 32 | +Hyperon equivalent. That is deliberately distinct from `(pragma! max-stack-depth N)`, a real Hyperon pragma |
| 33 | +that MeTTaScript implements. Hyperon has no work or step limit of its own, so this budget is ours and named |
| 34 | +as such. |
| 35 | + |
| 36 | +## Off by default |
| 37 | + |
| 38 | +The budget is opt-in. With no budget set, evaluation is unbounded, exactly as before and exactly as Hyperon. |
| 39 | +A step budget is the right tool for bounding a search you know may not terminate, or for making a long |
| 40 | +computation deterministic under a resource cap. It is not imposed on programs that do a lot of legitimate |
| 41 | +work. |
| 42 | + |
1 | 43 | # MeTTaScript 2.0.2 |
2 | 44 |
|
3 | 45 | A correctness release. Recursion depth is now deterministic: a program's output no longer depends on how |
|
0 commit comments