solve-engine 1.0.0-beta.6 → 1.0.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 (206) hide show
  1. package/README.md +10 -3
  2. package/dist/{BytecodeBuilder-3egMyuDi.d.cts → BytecodeBuilder-B0xskcv5.d.cts} +2 -1
  3. package/dist/{BytecodeBuilder-3egMyuDi.d.ts → BytecodeBuilder-B0xskcv5.d.ts} +2 -1
  4. package/dist/{Configuration-fVpd-HC-.d.cts → Configuration-B-G5gTRn.d.cts} +107 -29
  5. package/dist/{Configuration-fVpd-HC-.d.ts → Configuration-B-G5gTRn.d.ts} +107 -29
  6. package/dist/{EngineError-DvPSnhZi.d.cts → EngineError-LU7W7AgI.d.cts} +96 -16
  7. package/dist/{EngineError-DvPSnhZi.d.ts → EngineError-LU7W7AgI.d.ts} +96 -16
  8. package/dist/{Lexer-W9MBOP0V.d.ts → Lexer-BN5mt30n.d.ts} +16 -0
  9. package/dist/{Lexer-Cfm79Dak.d.cts → Lexer-D78E2yDW.d.cts} +16 -0
  10. package/dist/{PackageRegistry-CjDt-Jy_.d.ts → PackageRegistry-DFeINv2O.d.ts} +54 -13
  11. package/dist/{PackageRegistry-pHtKythi.d.cts → PackageRegistry-u2zdfFaj.d.cts} +54 -13
  12. package/dist/{Parselet-DEdF9I7n.d.ts → Parselet-BaySkMV3.d.ts} +37 -5
  13. package/dist/{Parselet-Cu0bLSis.d.cts → Parselet-DuI1Pjiq.d.cts} +37 -5
  14. package/dist/{ScopeManager-CKfQtl7l.d.cts → ScopeManager-B6GzdhVG.d.cts} +75 -6
  15. package/dist/{ScopeManager-B5k0nk05.d.ts → ScopeManager-udv4Twwq.d.ts} +75 -6
  16. package/dist/{VMCheckpoints-BmDwIXgK.d.ts → VMCheckpoints-BiaIlOOY.d.ts} +4 -4
  17. package/dist/{VMCheckpoints-CqFuLwrT.d.cts → VMCheckpoints-DwLjivM7.d.cts} +4 -4
  18. package/dist/{Value-KtAQNHur.d.cts → Value-CXJqDH9J.d.cts} +5 -2
  19. package/dist/{Value-KtAQNHur.d.ts → Value-CXJqDH9J.d.ts} +5 -2
  20. package/dist/{chunk-CSG5XVNJ.cjs → chunk-3AFRJYP4.cjs} +556 -414
  21. package/dist/chunk-3AFRJYP4.cjs.map +1 -0
  22. package/dist/chunk-3BOK2LDK.js +17 -0
  23. package/dist/chunk-3BOK2LDK.js.map +1 -0
  24. package/dist/{chunk-6RDSQURE.js → chunk-3D7V24DG.js} +57 -6
  25. package/dist/chunk-3D7V24DG.js.map +1 -0
  26. package/dist/{chunk-MEOHSQEH.js → chunk-3LAEG75D.js} +47 -15
  27. package/dist/chunk-3LAEG75D.js.map +1 -0
  28. package/dist/{chunk-NUR3K7EW.js → chunk-3VNGREMU.js} +118 -41
  29. package/dist/chunk-3VNGREMU.js.map +1 -0
  30. package/dist/{chunk-4AVD7NZW.cjs → chunk-4B2CNWQU.cjs} +13 -7
  31. package/dist/chunk-4B2CNWQU.cjs.map +1 -0
  32. package/dist/{chunk-6GCKCWLB.js → chunk-526PMQOA.js} +126 -69
  33. package/dist/chunk-526PMQOA.js.map +1 -0
  34. package/dist/{chunk-2CS6OMZK.js → chunk-5F4C26RU.js} +8 -5
  35. package/dist/chunk-5F4C26RU.js.map +1 -0
  36. package/dist/{chunk-M4N5GA5Z.cjs → chunk-5KMIY374.cjs} +57 -6
  37. package/dist/chunk-5KMIY374.cjs.map +1 -0
  38. package/dist/{chunk-R24DI24X.cjs → chunk-5LI5EPGJ.cjs} +6 -5
  39. package/dist/chunk-5LI5EPGJ.cjs.map +1 -0
  40. package/dist/{chunk-BAMZT3GL.js → chunk-5WVP4YHP.js} +939 -134
  41. package/dist/chunk-5WVP4YHP.js.map +1 -0
  42. package/dist/{chunk-MZOVP3WI.cjs → chunk-6KFYJ6TD.cjs} +3 -2
  43. package/dist/chunk-6KFYJ6TD.cjs.map +1 -0
  44. package/dist/{chunk-BXKJLM5R.cjs → chunk-6WFMPTGB.cjs} +972 -636
  45. package/dist/chunk-6WFMPTGB.cjs.map +1 -0
  46. package/dist/{chunk-2MV4HBKC.cjs → chunk-A2N2GFCG.cjs} +10 -10
  47. package/dist/{chunk-2MV4HBKC.cjs.map → chunk-A2N2GFCG.cjs.map} +1 -1
  48. package/dist/chunk-ADBA3XBE.cjs +20 -0
  49. package/dist/chunk-ADBA3XBE.cjs.map +1 -0
  50. package/dist/{chunk-MBNQVDVC.cjs → chunk-AMOJYLG2.cjs} +16 -10
  51. package/dist/chunk-AMOJYLG2.cjs.map +1 -0
  52. package/dist/{chunk-CLVQBF5C.cjs → chunk-AQNHHJMJ.cjs} +5 -5
  53. package/dist/{chunk-CLVQBF5C.cjs.map → chunk-AQNHHJMJ.cjs.map} +1 -1
  54. package/dist/{chunk-AHCLWAM5.cjs → chunk-BHTNFEGZ.cjs} +13 -13
  55. package/dist/chunk-BHTNFEGZ.cjs.map +1 -0
  56. package/dist/{chunk-62W2DYYA.cjs → chunk-E4NUZXVK.cjs} +58 -27
  57. package/dist/chunk-E4NUZXVK.cjs.map +1 -0
  58. package/dist/{chunk-LVLUHTRD.js → chunk-GLG5ZMX7.js} +54 -23
  59. package/dist/chunk-GLG5ZMX7.js.map +1 -0
  60. package/dist/{chunk-BVAR5J2F.js → chunk-GQCOSXMG.js} +117 -6
  61. package/dist/chunk-GQCOSXMG.js.map +1 -0
  62. package/dist/{chunk-QDMPOAI7.cjs → chunk-HDP7VK3C.cjs} +1118 -313
  63. package/dist/chunk-HDP7VK3C.cjs.map +1 -0
  64. package/dist/{chunk-GVWHCL2N.js → chunk-HMOISHXR.js} +217 -75
  65. package/dist/chunk-HMOISHXR.js.map +1 -0
  66. package/dist/{chunk-MTX2KVU7.cjs → chunk-HVQFNJKE.cjs} +122 -90
  67. package/dist/chunk-HVQFNJKE.cjs.map +1 -0
  68. package/dist/{chunk-OC6LTXYS.cjs → chunk-JMXUNXQS.cjs} +126 -7
  69. package/dist/chunk-JMXUNXQS.cjs.map +1 -0
  70. package/dist/{chunk-WWOLFXTX.cjs → chunk-KBSXGXPM.cjs} +10 -7
  71. package/dist/chunk-KBSXGXPM.cjs.map +1 -0
  72. package/dist/{chunk-YU2CUNFO.js → chunk-KV7UW6T6.js} +11 -5
  73. package/dist/chunk-KV7UW6T6.js.map +1 -0
  74. package/dist/{chunk-CCJPSHGI.cjs → chunk-N7FNVFXW.cjs} +4 -12
  75. package/dist/chunk-N7FNVFXW.cjs.map +1 -0
  76. package/dist/{chunk-CYFK5SY2.js → chunk-O3ANBHSA.js} +169 -39
  77. package/dist/chunk-O3ANBHSA.js.map +1 -0
  78. package/dist/{chunk-NZFKROS7.cjs → chunk-PA4VC73I.cjs} +130 -72
  79. package/dist/chunk-PA4VC73I.cjs.map +1 -0
  80. package/dist/{chunk-NJTXJ5AG.cjs → chunk-PFUESQTW.cjs} +18 -18
  81. package/dist/{chunk-NJTXJ5AG.cjs.map → chunk-PFUESQTW.cjs.map} +1 -1
  82. package/dist/{chunk-SFQWJMKT.js → chunk-QY25VWBF.js} +51 -12
  83. package/dist/chunk-QY25VWBF.js.map +1 -0
  84. package/dist/{chunk-WC5FFSHB.js → chunk-R3PY4G7J.js} +3 -3
  85. package/dist/{chunk-WC5FFSHB.js.map → chunk-R3PY4G7J.js.map} +1 -1
  86. package/dist/{chunk-M5E34VG5.js → chunk-SBUFNJVE.js} +3 -3
  87. package/dist/{chunk-M5E34VG5.js.map → chunk-SBUFNJVE.js.map} +1 -1
  88. package/dist/{chunk-UKPGSAZW.js → chunk-TMA4RCEN.js} +3 -3
  89. package/dist/{chunk-UKPGSAZW.js.map → chunk-TMA4RCEN.js.map} +1 -1
  90. package/dist/{chunk-FN2WMF2W.cjs → chunk-U5VAY32K.cjs} +215 -138
  91. package/dist/chunk-U5VAY32K.cjs.map +1 -0
  92. package/dist/{chunk-DUEZFTK2.js → chunk-UKQHXPGW.js} +4 -12
  93. package/dist/chunk-UKQHXPGW.js.map +1 -0
  94. package/dist/{chunk-4CVLFLOB.cjs → chunk-UM6BVY2S.cjs} +201 -69
  95. package/dist/chunk-UM6BVY2S.cjs.map +1 -0
  96. package/dist/{chunk-75JP4BZX.js → chunk-UQ3UIZJC.js} +3 -2
  97. package/dist/chunk-UQ3UIZJC.js.map +1 -0
  98. package/dist/{chunk-PCPX42KL.js → chunk-V4XG5QF6.js} +16 -10
  99. package/dist/chunk-V4XG5QF6.js.map +1 -0
  100. package/dist/{chunk-GPPLSM2Z.js → chunk-VB37OC6I.js} +6 -5
  101. package/dist/chunk-VB37OC6I.js.map +1 -0
  102. package/dist/{chunk-MVBEL57Q.js → chunk-Y7FT4IQT.js} +500 -170
  103. package/dist/chunk-Y7FT4IQT.js.map +1 -0
  104. package/dist/{chunk-OFXOTECC.js → chunk-YPPPYLSR.js} +7 -7
  105. package/dist/chunk-YPPPYLSR.js.map +1 -0
  106. package/dist/{chunk-M4F66R4O.cjs → chunk-YWQ6V4ZN.cjs} +121 -82
  107. package/dist/chunk-YWQ6V4ZN.cjs.map +1 -0
  108. package/dist/constants.cjs +5 -5
  109. package/dist/constants.d.cts +1 -1
  110. package/dist/constants.d.ts +1 -1
  111. package/dist/constants.js +2 -2
  112. package/dist/engine.cjs +31 -31
  113. package/dist/engine.d.cts +11 -11
  114. package/dist/engine.d.ts +11 -11
  115. package/dist/engine.js +21 -21
  116. package/dist/errors.cjs +19 -19
  117. package/dist/errors.d.cts +2 -2
  118. package/dist/errors.d.ts +2 -2
  119. package/dist/errors.js +1 -1
  120. package/dist/format.cjs +29 -22
  121. package/dist/format.cjs.map +1 -1
  122. package/dist/format.d.cts +1 -2
  123. package/dist/format.d.ts +1 -2
  124. package/dist/format.js +23 -16
  125. package/dist/format.js.map +1 -1
  126. package/dist/index.cjs +31 -31
  127. package/dist/index.d.cts +10 -10
  128. package/dist/index.d.ts +10 -10
  129. package/dist/index.js +22 -22
  130. package/dist/language.cjs +8 -8
  131. package/dist/language.cjs.map +1 -1
  132. package/dist/language.d.cts +10 -10
  133. package/dist/language.d.ts +10 -10
  134. package/dist/language.js +6 -6
  135. package/dist/language.js.map +1 -1
  136. package/dist/lexer.cjs +18 -18
  137. package/dist/lexer.d.cts +2 -2
  138. package/dist/lexer.d.ts +2 -2
  139. package/dist/lexer.js +6 -6
  140. package/dist/normalizer.cjs +12 -12
  141. package/dist/normalizer.js +6 -6
  142. package/dist/packages.cjs +39 -39
  143. package/dist/packages.d.cts +9 -9
  144. package/dist/packages.d.ts +9 -9
  145. package/dist/packages.js +16 -16
  146. package/dist/parser.cjs +15 -15
  147. package/dist/parser.d.cts +23 -9
  148. package/dist/parser.d.ts +23 -9
  149. package/dist/parser.js +5 -5
  150. package/dist/{pipeline-CrsRPmsv.d.ts → pipeline-B6k5lCB7.d.ts} +1 -1
  151. package/dist/{pipeline-DPUQt7yL.d.cts → pipeline-BEb3hujr.d.cts} +1 -1
  152. package/dist/resolvers.d.cts +2 -2
  153. package/dist/resolvers.d.ts +2 -2
  154. package/dist/uom.cjs +17 -17
  155. package/dist/uom.d.cts +2 -2
  156. package/dist/uom.d.ts +2 -2
  157. package/dist/uom.js +7 -7
  158. package/dist/utilities.cjs +8 -4
  159. package/dist/utilities.d.cts +19 -3
  160. package/dist/utilities.d.ts +19 -3
  161. package/dist/utilities.js +2 -2
  162. package/dist/vm.cjs +43 -31
  163. package/dist/vm.d.cts +105 -9
  164. package/dist/vm.d.ts +105 -9
  165. package/dist/vm.js +9 -9
  166. package/package.json +3 -3
  167. package/dist/chunk-2CS6OMZK.js.map +0 -1
  168. package/dist/chunk-4AVD7NZW.cjs.map +0 -1
  169. package/dist/chunk-4CVLFLOB.cjs.map +0 -1
  170. package/dist/chunk-62W2DYYA.cjs.map +0 -1
  171. package/dist/chunk-6GCKCWLB.js.map +0 -1
  172. package/dist/chunk-6RDSQURE.js.map +0 -1
  173. package/dist/chunk-75JP4BZX.js.map +0 -1
  174. package/dist/chunk-AHCLWAM5.cjs.map +0 -1
  175. package/dist/chunk-BAMZT3GL.js.map +0 -1
  176. package/dist/chunk-BVAR5J2F.js.map +0 -1
  177. package/dist/chunk-BXKJLM5R.cjs.map +0 -1
  178. package/dist/chunk-CCJPSHGI.cjs.map +0 -1
  179. package/dist/chunk-CSG5XVNJ.cjs.map +0 -1
  180. package/dist/chunk-CYFK5SY2.js.map +0 -1
  181. package/dist/chunk-DUEZFTK2.js.map +0 -1
  182. package/dist/chunk-FN2WMF2W.cjs.map +0 -1
  183. package/dist/chunk-GPPLSM2Z.js.map +0 -1
  184. package/dist/chunk-GVWHCL2N.js.map +0 -1
  185. package/dist/chunk-LVLUHTRD.js.map +0 -1
  186. package/dist/chunk-M4F66R4O.cjs.map +0 -1
  187. package/dist/chunk-M4N5GA5Z.cjs.map +0 -1
  188. package/dist/chunk-MBNQVDVC.cjs.map +0 -1
  189. package/dist/chunk-MEOHSQEH.js.map +0 -1
  190. package/dist/chunk-MTX2KVU7.cjs.map +0 -1
  191. package/dist/chunk-MVBEL57Q.js.map +0 -1
  192. package/dist/chunk-MZOVP3WI.cjs.map +0 -1
  193. package/dist/chunk-N5YFR4UP.cjs +0 -10
  194. package/dist/chunk-N5YFR4UP.cjs.map +0 -1
  195. package/dist/chunk-NUR3K7EW.js.map +0 -1
  196. package/dist/chunk-NZFKROS7.cjs.map +0 -1
  197. package/dist/chunk-OC6LTXYS.cjs.map +0 -1
  198. package/dist/chunk-OFXOTECC.js.map +0 -1
  199. package/dist/chunk-PCPX42KL.js.map +0 -1
  200. package/dist/chunk-PFSDGGYL.js +0 -8
  201. package/dist/chunk-PFSDGGYL.js.map +0 -1
  202. package/dist/chunk-QDMPOAI7.cjs.map +0 -1
  203. package/dist/chunk-R24DI24X.cjs.map +0 -1
  204. package/dist/chunk-SFQWJMKT.js.map +0 -1
  205. package/dist/chunk-WWOLFXTX.cjs.map +0 -1
  206. package/dist/chunk-YU2CUNFO.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { V as Value } from './Value-KtAQNHur.cjs';
2
- import { U as UserFunctionDef, A as AnonymousBodyDef, a as BytecodeProgram } from './BytecodeBuilder-3egMyuDi.cjs';
3
- import { E as EngineError } from './EngineError-DvPSnhZi.cjs';
4
- import { D as DiagnosticPipeline } from './pipeline-DPUQt7yL.cjs';
1
+ import { V as Value } from './Value-CXJqDH9J.cjs';
2
+ import { U as UserFunctionDef, A as AnonymousBodyDef, a as BytecodeProgram } from './BytecodeBuilder-B0xskcv5.cjs';
3
+ import { E as EngineError } from './EngineError-LU7W7AgI.cjs';
4
+ import { D as DiagnosticPipeline } from './pipeline-BEb3hujr.cjs';
5
5
  import { VariableResolver } from './variables.cjs';
6
6
 
7
7
  /**
@@ -19,8 +19,27 @@ import { VariableResolver } from './variables.cjs';
19
19
  * @param maxFunctionRecursionDepth - Maximum nested user-defined-function
20
20
  * calls (default 50). See the VM interface's `pushCallFrame` doc for why
21
21
  * this exists as its own dedicated guard, separate from `maxInstructions`.
22
+ * @param maxCollectionSize - Maximum elements a Range or Matrix may be
23
+ * expanded to by `map`/`reduce` (default 100000). Neither of the two
24
+ * counters above can see that expansion, since it happens inside one
25
+ * opcode and never touches the value stack.
26
+ * @param maxAllocatedElements - Maximum elements one evaluation may
27
+ * materialise in TOTAL (default 2000000). The parameter above bounds one
28
+ * collection; per-site bounds do not compose, and an operation whose result
29
+ * is the product of two legal operands (a matrix multiply) is bounded by
30
+ * neither. See `vm/AllocationBudget.ts`.
31
+ * @param maxFunctionCalls - Maximum user-defined-function calls one
32
+ * evaluation may make in total (default 10000). `maxFunctionRecursionDepth`
33
+ * above bounds how deep they nest and cannot see how many there are: a
34
+ * doubling chain reaches two million calls at a depth of twenty-two.
35
+ * @param maxDateOffsetYears - How far forward `<date> + N workdays` may
36
+ * reach, in years (default 100). The one date offset that walks rather than
37
+ * computing, so the one that needs a ceiling. See `addBusinessDays()`.
38
+ * @param minDateOffsetYears - The same bound backwards, negative (default
39
+ * -100).
40
+ * @param context - Registries belonging to the engine that created this VM.
22
41
  */
23
- declare function createVM(registry: OpRegistry, maxStackDepth?: number, maxInstructions?: number, maxFunctionRecursionDepth?: number, context?: EngineContext): VM;
42
+ declare function createVM(registry: OpRegistry, maxStackDepth?: number, maxInstructions?: number, maxFunctionRecursionDepth?: number, maxCollectionSize?: number, maxAllocatedElements?: number, maxFunctionCalls?: number, maxDateOffsetYears?: number, minDateOffsetYears?: number, context?: EngineContext): VM;
24
43
  /**
25
44
  * Compiled bytecode ready for VM execution.
26
45
  *
@@ -310,7 +329,26 @@ declare class OpRegistry {
310
329
  interface VM {
311
330
  push(value: Value): void;
312
331
  pop(): Value;
332
+ /**
333
+ * Pop the top of the stack as a number.
334
+ *
335
+ * @throws `STACK_UNDERFLOW` (INTERNAL) if the stack is empty. Unlike
336
+ * `pop()`, which answers an empty stack with `0`, this reports it: a
337
+ * handler asking for a number has no way to tell that `0` from a real
338
+ * one. Every Value converts, so there is no operand-type throw here.
339
+ */
313
340
  popNumber(): number;
341
+ /**
342
+ * Pop the top of the stack as a string, e.g. a unit name a handler's own
343
+ * bytecode pushed for it to read.
344
+ *
345
+ * @throws `STACK_UNDERFLOW` (INTERNAL) if the stack is empty, and
346
+ * `MALFORMED_BYTECODE_OPERAND_TYPE` (VALIDATION, recoverable) if the
347
+ * value on top is not a string. Both are structured `EngineError`s
348
+ * naming this method, in place of the raw TypeError a bare `pop()!` and
349
+ * a compile-time-only cast used to produce somewhere further along. A
350
+ * handler that would rather branch than throw can `peek()` first.
351
+ */
314
352
  popString(): string;
315
353
  peek(): Value;
316
354
  getStack(): Value[];
@@ -360,8 +398,39 @@ interface VM {
360
398
  getScalarEquation(variable: string): ScalarEquationDef | undefined;
361
399
  hasScalarEquation(variable: string): boolean;
362
400
  reset(): void;
401
+ /** The innermost call frame's bindings, or `undefined` when no call is in progress. Read-only, for building a frame that extends the current one rather than replacing it (see `BIND_UNKNOWN`'s handler). */
402
+ getCallFrame(): ReadonlyMap<string, Value> | undefined;
363
403
  getMaxInstructions(): number;
364
404
  getMaxStackDepth(): number;
405
+ /** Maximum elements a Range or Matrix may be expanded to by `map`/`reduce`. See `constants/Configuration.ts`'s `maxCollectionSize`. */
406
+ getMaxCollectionSize(): number;
407
+ /**
408
+ * Maximum elements (collection Values, matrix cells) one evaluation may
409
+ * materialise in total.
410
+ *
411
+ * The bound the two limits above cannot be. Both are checked between
412
+ * opcodes, so neither sees what one opcode allocates inside a loop of its
413
+ * own, and `getMaxCollectionSize()` bounds one collection without bounding
414
+ * the total. See `vm/AllocationBudget.ts` for the counter this configures
415
+ * and for why charging goes through that module rather than through the VM.
416
+ */
417
+ getMaxAllocatedElements(): number;
418
+ /**
419
+ * Maximum user-defined-function calls one evaluation may make in total.
420
+ *
421
+ * `maxFunctionRecursionDepth` (see `pushCallFrame` above) bounds how DEEP
422
+ * calls nest; this bounds how MANY there are, which is a different number
423
+ * and the one a doubling chain runs away with: twenty-two lines of
424
+ * `f(v) = g(v) + g(v)` reach two million calls at a depth of twenty-two.
425
+ * Held by `vm/AllocationBudget.ts` rather than counted here, because it has
426
+ * to survive `executeBytecode()` re-entering itself, exactly like the
427
+ * element tally and unlike `maxInstructions`.
428
+ */
429
+ getMaxFunctionCalls(): number;
430
+ /** How far forward `<date> + N workdays` may reach, in years. The one date offset that walks the calendar rather than computing, so the one with a ceiling. See `constants/Configuration.ts`'s `date.maxOffsetYears`. */
431
+ getMaxDateOffsetYears(): number;
432
+ /** The same bound backwards, as a negative number of years. */
433
+ getMinDateOffsetYears(): number;
365
434
  getInstructionCount(): number;
366
435
  incrementInstructions(n: number): void;
367
436
  /** Active AbortSignal for the current expression evaluation. Checked before cache writes. */
@@ -556,4 +625,4 @@ declare class ScopeManager {
556
625
  clear(): void;
557
626
  }
558
627
 
559
- export { type Bytecode as B, DependencyGraph as D, type ExpressionRecord as E, type LineExecutionContext as L, OpRegistry as O, type PluginFunctionHandler as P, ScopeManager as S, type VM as V, type DagSnapshot as a, type EngineContext as b, createVM as c, executeBytecode as e, sharedOpRegistry as s };
628
+ export { type Bytecode as B, type DagSnapshot as D, type ExpressionRecord as E, type LineExecutionContext as L, OpRegistry as O, type PluginFunctionHandler as P, ScopeManager as S, type VM as V, DependencyGraph as a, type EngineContext as b, createVM as c, executeBytecode as e, sharedOpRegistry as s };
@@ -1,7 +1,7 @@
1
- import { V as Value } from './Value-KtAQNHur.js';
2
- import { U as UserFunctionDef, A as AnonymousBodyDef, a as BytecodeProgram } from './BytecodeBuilder-3egMyuDi.js';
3
- import { E as EngineError } from './EngineError-DvPSnhZi.js';
4
- import { D as DiagnosticPipeline } from './pipeline-CrsRPmsv.js';
1
+ import { V as Value } from './Value-CXJqDH9J.js';
2
+ import { U as UserFunctionDef, A as AnonymousBodyDef, a as BytecodeProgram } from './BytecodeBuilder-B0xskcv5.js';
3
+ import { E as EngineError } from './EngineError-LU7W7AgI.js';
4
+ import { D as DiagnosticPipeline } from './pipeline-B6k5lCB7.js';
5
5
  import { VariableResolver } from './variables.js';
6
6
 
7
7
  /**
@@ -19,8 +19,27 @@ import { VariableResolver } from './variables.js';
19
19
  * @param maxFunctionRecursionDepth - Maximum nested user-defined-function
20
20
  * calls (default 50). See the VM interface's `pushCallFrame` doc for why
21
21
  * this exists as its own dedicated guard, separate from `maxInstructions`.
22
+ * @param maxCollectionSize - Maximum elements a Range or Matrix may be
23
+ * expanded to by `map`/`reduce` (default 100000). Neither of the two
24
+ * counters above can see that expansion, since it happens inside one
25
+ * opcode and never touches the value stack.
26
+ * @param maxAllocatedElements - Maximum elements one evaluation may
27
+ * materialise in TOTAL (default 2000000). The parameter above bounds one
28
+ * collection; per-site bounds do not compose, and an operation whose result
29
+ * is the product of two legal operands (a matrix multiply) is bounded by
30
+ * neither. See `vm/AllocationBudget.ts`.
31
+ * @param maxFunctionCalls - Maximum user-defined-function calls one
32
+ * evaluation may make in total (default 10000). `maxFunctionRecursionDepth`
33
+ * above bounds how deep they nest and cannot see how many there are: a
34
+ * doubling chain reaches two million calls at a depth of twenty-two.
35
+ * @param maxDateOffsetYears - How far forward `<date> + N workdays` may
36
+ * reach, in years (default 100). The one date offset that walks rather than
37
+ * computing, so the one that needs a ceiling. See `addBusinessDays()`.
38
+ * @param minDateOffsetYears - The same bound backwards, negative (default
39
+ * -100).
40
+ * @param context - Registries belonging to the engine that created this VM.
22
41
  */
23
- declare function createVM(registry: OpRegistry, maxStackDepth?: number, maxInstructions?: number, maxFunctionRecursionDepth?: number, context?: EngineContext): VM;
42
+ declare function createVM(registry: OpRegistry, maxStackDepth?: number, maxInstructions?: number, maxFunctionRecursionDepth?: number, maxCollectionSize?: number, maxAllocatedElements?: number, maxFunctionCalls?: number, maxDateOffsetYears?: number, minDateOffsetYears?: number, context?: EngineContext): VM;
24
43
  /**
25
44
  * Compiled bytecode ready for VM execution.
26
45
  *
@@ -310,7 +329,26 @@ declare class OpRegistry {
310
329
  interface VM {
311
330
  push(value: Value): void;
312
331
  pop(): Value;
332
+ /**
333
+ * Pop the top of the stack as a number.
334
+ *
335
+ * @throws `STACK_UNDERFLOW` (INTERNAL) if the stack is empty. Unlike
336
+ * `pop()`, which answers an empty stack with `0`, this reports it: a
337
+ * handler asking for a number has no way to tell that `0` from a real
338
+ * one. Every Value converts, so there is no operand-type throw here.
339
+ */
313
340
  popNumber(): number;
341
+ /**
342
+ * Pop the top of the stack as a string, e.g. a unit name a handler's own
343
+ * bytecode pushed for it to read.
344
+ *
345
+ * @throws `STACK_UNDERFLOW` (INTERNAL) if the stack is empty, and
346
+ * `MALFORMED_BYTECODE_OPERAND_TYPE` (VALIDATION, recoverable) if the
347
+ * value on top is not a string. Both are structured `EngineError`s
348
+ * naming this method, in place of the raw TypeError a bare `pop()!` and
349
+ * a compile-time-only cast used to produce somewhere further along. A
350
+ * handler that would rather branch than throw can `peek()` first.
351
+ */
314
352
  popString(): string;
315
353
  peek(): Value;
316
354
  getStack(): Value[];
@@ -360,8 +398,39 @@ interface VM {
360
398
  getScalarEquation(variable: string): ScalarEquationDef | undefined;
361
399
  hasScalarEquation(variable: string): boolean;
362
400
  reset(): void;
401
+ /** The innermost call frame's bindings, or `undefined` when no call is in progress. Read-only, for building a frame that extends the current one rather than replacing it (see `BIND_UNKNOWN`'s handler). */
402
+ getCallFrame(): ReadonlyMap<string, Value> | undefined;
363
403
  getMaxInstructions(): number;
364
404
  getMaxStackDepth(): number;
405
+ /** Maximum elements a Range or Matrix may be expanded to by `map`/`reduce`. See `constants/Configuration.ts`'s `maxCollectionSize`. */
406
+ getMaxCollectionSize(): number;
407
+ /**
408
+ * Maximum elements (collection Values, matrix cells) one evaluation may
409
+ * materialise in total.
410
+ *
411
+ * The bound the two limits above cannot be. Both are checked between
412
+ * opcodes, so neither sees what one opcode allocates inside a loop of its
413
+ * own, and `getMaxCollectionSize()` bounds one collection without bounding
414
+ * the total. See `vm/AllocationBudget.ts` for the counter this configures
415
+ * and for why charging goes through that module rather than through the VM.
416
+ */
417
+ getMaxAllocatedElements(): number;
418
+ /**
419
+ * Maximum user-defined-function calls one evaluation may make in total.
420
+ *
421
+ * `maxFunctionRecursionDepth` (see `pushCallFrame` above) bounds how DEEP
422
+ * calls nest; this bounds how MANY there are, which is a different number
423
+ * and the one a doubling chain runs away with: twenty-two lines of
424
+ * `f(v) = g(v) + g(v)` reach two million calls at a depth of twenty-two.
425
+ * Held by `vm/AllocationBudget.ts` rather than counted here, because it has
426
+ * to survive `executeBytecode()` re-entering itself, exactly like the
427
+ * element tally and unlike `maxInstructions`.
428
+ */
429
+ getMaxFunctionCalls(): number;
430
+ /** How far forward `<date> + N workdays` may reach, in years. The one date offset that walks the calendar rather than computing, so the one with a ceiling. See `constants/Configuration.ts`'s `date.maxOffsetYears`. */
431
+ getMaxDateOffsetYears(): number;
432
+ /** The same bound backwards, as a negative number of years. */
433
+ getMinDateOffsetYears(): number;
365
434
  getInstructionCount(): number;
366
435
  incrementInstructions(n: number): void;
367
436
  /** Active AbortSignal for the current expression evaluation. Checked before cache writes. */
@@ -556,4 +625,4 @@ declare class ScopeManager {
556
625
  clear(): void;
557
626
  }
558
627
 
559
- export { type Bytecode as B, DependencyGraph as D, type ExpressionRecord as E, type LineExecutionContext as L, OpRegistry as O, type PluginFunctionHandler as P, ScopeManager as S, type VM as V, type DagSnapshot as a, type EngineContext as b, createVM as c, executeBytecode as e, sharedOpRegistry as s };
628
+ export { type Bytecode as B, type DagSnapshot as D, type ExpressionRecord as E, type LineExecutionContext as L, OpRegistry as O, type PluginFunctionHandler as P, ScopeManager as S, type VM as V, DependencyGraph as a, type EngineContext as b, createVM as c, executeBytecode as e, sharedOpRegistry as s };
@@ -1,6 +1,6 @@
1
- import { V as Value } from './Value-KtAQNHur.js';
2
- import { V as VM } from './ScopeManager-B5k0nk05.js';
3
- import { U as UserFunctionDef } from './BytecodeBuilder-3egMyuDi.js';
1
+ import { V as Value } from './Value-CXJqDH9J.js';
2
+ import { V as VM } from './ScopeManager-udv4Twwq.js';
3
+ import { U as UserFunctionDef } from './BytecodeBuilder-B0xskcv5.js';
4
4
 
5
5
  /**
6
6
  * A point-in-time snapshot of VM variable state.
@@ -168,4 +168,4 @@ declare class VMCheckpointer {
168
168
  get vmInstance(): VM;
169
169
  }
170
170
 
171
- export { type VMCheckpoint as V, VMCheckpointer as a };
171
+ export { VMCheckpointer as V, type VMCheckpoint as a };
@@ -1,6 +1,6 @@
1
- import { V as Value } from './Value-KtAQNHur.cjs';
2
- import { V as VM } from './ScopeManager-CKfQtl7l.cjs';
3
- import { U as UserFunctionDef } from './BytecodeBuilder-3egMyuDi.cjs';
1
+ import { V as Value } from './Value-CXJqDH9J.cjs';
2
+ import { V as VM } from './ScopeManager-B6GzdhVG.cjs';
3
+ import { U as UserFunctionDef } from './BytecodeBuilder-B0xskcv5.cjs';
4
4
 
5
5
  /**
6
6
  * A point-in-time snapshot of VM variable state.
@@ -168,4 +168,4 @@ declare class VMCheckpointer {
168
168
  get vmInstance(): VM;
169
169
  }
170
170
 
171
- export { type VMCheckpoint as V, VMCheckpointer as a };
171
+ export { VMCheckpointer as V, type VMCheckpoint as a };
@@ -266,11 +266,14 @@ type DisplayBase = "hex" | "bin" | "oct";
266
266
  * as zero in arithmetic, and nothing about that failure is visible at the point
267
267
  * of use.
268
268
  *
269
- * @param n - The number itself, in full precision.
269
+ * @param n - The number itself, in full precision. A `bigint` is accepted for
270
+ * the same reason the type is numeric at all: `12345678901234567890n as hex`
271
+ * has an exact answer, and forcing it through a double first rendered
272
+ * 0xAB54A98CEB1F0800 for a value ending 0AD2.
270
273
  * @param base - How to display it, defaulting to hexadecimal. Carried in the
271
274
  * `unit` slot, which is free for this type.
272
275
  */
273
- declare function hexValue(n: number, base?: DisplayBase): Value;
276
+ declare function hexValue(n: number | bigint, base?: DisplayBase): Value;
274
277
  /** Create a BigInt-typed Value (arbitrary-precision integer). */
275
278
  declare function bigIntValue(n: bigint): Value;
276
279
  /** Create a String-typed Value. */
@@ -266,11 +266,14 @@ type DisplayBase = "hex" | "bin" | "oct";
266
266
  * as zero in arithmetic, and nothing about that failure is visible at the point
267
267
  * of use.
268
268
  *
269
- * @param n - The number itself, in full precision.
269
+ * @param n - The number itself, in full precision. A `bigint` is accepted for
270
+ * the same reason the type is numeric at all: `12345678901234567890n as hex`
271
+ * has an exact answer, and forcing it through a double first rendered
272
+ * 0xAB54A98CEB1F0800 for a value ending 0AD2.
270
273
  * @param base - How to display it, defaulting to hexadecimal. Carried in the
271
274
  * `unit` slot, which is free for this type.
272
275
  */
273
- declare function hexValue(n: number, base?: DisplayBase): Value;
276
+ declare function hexValue(n: number | bigint, base?: DisplayBase): Value;
274
277
  /** Create a BigInt-typed Value (arbitrary-precision integer). */
275
278
  declare function bigIntValue(n: bigint): Value;
276
279
  /** Create a String-typed Value. */