@crewhaus/tool-money 0.7.0 → 0.8.1

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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ CrewHaus Factory
2
+ Copyright 2026 Max Meier
3
+
4
+ This product includes software developed by Max Meier
5
+ (operating as StudioMax — https://studiomax.io) and contributors.
6
+
7
+ The CrewHaus name and logo are trademarks of Max Meier. See
8
+ https://github.com/crewhaus/factory/blob/main/TRADEMARK.md for the
9
+ use-of-marks policy.
package/README.md CHANGED
@@ -27,6 +27,20 @@ Cents, pence, yen. Floating point produces totals that do not add up, and
27
27
  that fails reconciliation. Every amount in and out of these tools is an
28
28
  integer, and the schemas reject anything else.
29
29
 
30
+ An amount must also be one a JSON number holds exactly: at most 2^53 − 1
31
+ minor units (about 90 trillion dollars in cents). A larger one has already
32
+ been rounded by the time it arrives, so it is refused, with a pointer to a
33
+ larger unit. Inside, the arithmetic is exact however large the intermediate
34
+ products get — a tax rate times an amount passes 2^53 long before the amount
35
+ does — and a total that would itself pass the limit is refused by name
36
+ rather than reported a unit off. `PurchaseOrderMatch` takes fractional
37
+ quantities (kilograms, hours) and compares them as the decimals written; its
38
+ exposure figures are computed exactly and rounded to whole minor units, half
39
+ away from zero. `StatementParse` reads amounts out of a
40
+ file, so an amount there past the limit is a rejected row that says so, and a
41
+ total past it comes back `null` with `totalsUnavailable` saying which; the
42
+ transactions themselves are unaffected.
43
+
30
44
  Splitting is largest-remainder, so the parts always sum to the whole. 100
31
45
  cents three ways is 34, 33, 33 — never 33, 33, 33 with a cent unaccounted
32
46
  for. A full return refunds exactly what was charged, and a lot's partial
@@ -54,11 +68,18 @@ wrong side of a year boundary depending on the machine.
54
68
 
55
69
  ## Controls, not suggestions
56
70
 
57
- `SpendLimitCheck` is the gate an unattended harness consults before moving
58
- money. A limit a model is asked to respect is a suggestion; a limit computed
59
- from the record of what has already been spent is a limit. It reports every
60
- limit a payment breaks rather than the first, and the headroom that would
61
- pass.
71
+ `SpendLimitCheck` applies velocity, counterparty and quiet-hours limits to a
72
+ proposed payment, the same way every time, and reports every limit it breaks
73
+ rather than the first, plus the headroom that would pass. It computes over the
74
+ history, the limits and the clock it is given, and enforces nothing by
75
+ itself: when a model supplies those, the verdict is advisory — a model that
76
+ would move money past a limit can equally leave out the history or skip the
77
+ check. So a limit that must hold belongs where the model cannot edit it: in
78
+ the policy of the tool that moves the money (for `EvmSendTransaction`, the
79
+ spec's `transaction_policy`). The result says which clock it used (`clock`),
80
+ and `now` — on this tool, `RefundAbuseCheck` and `WebhookSignatureVerify` —
81
+ is for tests and replays only: it replaces the real clock, and every time
82
+ window, a webhook's replay tolerance included, moves with it.
62
83
 
63
84
  When `knownCounterparties` is declared, that list **is** the allow-list, and
64
85
  payment history does not extend it. Treating anyone previously paid as known
package/dist/index.js CHANGED
@@ -14,12 +14,12 @@
14
14
  * Nothing here moves money, reaches a payment provider, or decides that
15
15
  * somebody is committing fraud. It computes, checks and reports.
16
16
  */
17
- import { readFileSync, statSync } from "node:fs";
18
17
  import { buildTool } from "@crewhaus/tool-builder";
19
- import { ASSERT_OPS } from "@crewhaus/tool-schema";
18
+ import { openForRead } from "@crewhaus/tool-safety/fs";
19
+ import { ASSERT_OPS, regexRunContext } from "@crewhaus/tool-schema";
20
20
  import { z } from "zod";
21
21
  import { SHIPPING_POLICIES, computeRefund, } from "./lib/allocate";
22
- import { codeLines } from "./lib/coding";
22
+ import { codeLinesAnsweringPatterns } from "./lib/coding";
23
23
  import { checkSpendLimit, refundAbuseSignals } from "./lib/controls";
24
24
  import { IDENTIFIER_KINDS, detectKind, validateIdentifier, } from "./lib/identifiers";
25
25
  import { LOT_METHODS, computeCostBasis } from "./lib/lots";
@@ -27,7 +27,7 @@ import { matchInvoiceToPurchaseOrder } from "./lib/match";
27
27
  import { DATE_ORDERS, STATEMENT_FORMATS, parseStatement } from "./lib/statement";
28
28
  import { ROUNDING_MODES, ROUNDING_SCOPES, calculateTax } from "./lib/tax";
29
29
  import { verifyWebhookSignature } from "./lib/webhook";
30
- import { resolveSafe } from "./paths";
30
+ import { resolveSafe, workspaceRoot } from "./paths";
31
31
  const json = (value) => JSON.stringify(value);
32
32
  const LIMITS = {
33
33
  lines: 5_000,
@@ -44,7 +44,17 @@ const checkSchema = z.object({
44
44
  flags: z.string().optional(),
45
45
  message: z.string().optional(),
46
46
  });
47
- const minorUnits = z.number().int();
47
+ /**
48
+ * An amount in minor units: an integer a double holds exactly. Past 2^53 − 1
49
+ * a JSON number has already been rounded before the tool sees it, so it is
50
+ * refused rather than computed with.
51
+ */
52
+ const UNSAFE_AMOUNT = "is past ±(2^53 − 1) minor units, the largest amount computed exactly — express it in a larger unit";
53
+ const minorUnits = z
54
+ .number()
55
+ .int()
56
+ .min(Number.MIN_SAFE_INTEGER, UNSAFE_AMOUNT)
57
+ .max(Number.MAX_SAFE_INTEGER, UNSAFE_AMOUNT);
48
58
  /**
49
59
  * An instant, as epoch milliseconds or ISO-8601 WITH an offset.
50
60
  *
@@ -67,6 +77,13 @@ function parseInstant(value, field) {
67
77
  return parsed;
68
78
  }
69
79
  const instantField = z.union([z.string(), z.number()]);
80
+ /**
81
+ * The `now` a caller may pass. It replaces the real clock, which moves every
82
+ * time window with it — the spend windows, the quiet hours, a webhook's
83
+ * replay tolerance — so it is for tests and replays of a recorded event, not
84
+ * for a live decision.
85
+ */
86
+ const CLOCK_OVERRIDE = "tests and replays only; omit it for a live decision — it replaces the real clock, and every time window moves with it";
70
87
  // ---------------------------------------------------------------------------
71
88
  export const paymentIdentifierValidate = buildTool({
72
89
  name: "PaymentIdentifierValidate",
@@ -138,7 +155,7 @@ export const refundAmountCompute = buildTool({
138
155
  lines: z
139
156
  .array(z.object({
140
157
  id: z.string().min(1),
141
- quantity: z.number().int().positive(),
158
+ quantity: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
142
159
  unitPriceMinor: minorUnits,
143
160
  taxMinor: minorUnits.optional(),
144
161
  discountMinor: minorUnits.optional(),
@@ -146,7 +163,10 @@ export const refundAmountCompute = buildTool({
146
163
  .min(1)
147
164
  .max(LIMITS.lines),
148
165
  returned: z
149
- .array(z.object({ lineId: z.string().min(1), quantity: z.number().int().positive() }))
166
+ .array(z.object({
167
+ lineId: z.string().min(1),
168
+ quantity: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
169
+ }))
150
170
  .min(1)
151
171
  .max(LIMITS.lines),
152
172
  orderDiscountMinor: minorUnits.optional(),
@@ -234,7 +254,7 @@ export const costBasisCompute = buildTool({
234
254
  });
235
255
  export const spendLimitCheck = buildTool({
236
256
  name: "SpendLimitCheck",
237
- description: "Decide whether a proposed payment fits inside the operator's velocity, counterparty and quiet-hours limits, given what has already been spent. Use it as the gate an unattended harness actually consults before moving money: a limit a model is asked to respect is a suggestion, while one computed from the record of prior spend is a limit. It reports every limit the payment breaks rather than the first, and the headroom that would pass.",
257
+ description: "Check a proposed payment against velocity, counterparty and quiet-hours limits, given the payments already made, and report every limit it breaks rather than the first, plus the headroom that would pass. Use it to apply the same limits the same way every time: the window arithmetic is exact and repeatable. It computes over the history, the limits and the clock passed in, and enforces nothing by itself — when the caller writes those inputs the verdict is advisory, so a limit that must hold belongs where the caller cannot edit it: in the policy of the tool that moves the money, such as transaction_policy for EvmSendTransaction.",
238
258
  inputSchema: z.object({
239
259
  proposed: z.object({ amountMinor: minorUnits, counterparty: z.string().optional() }),
240
260
  history: z
@@ -256,13 +276,18 @@ export const spendLimitCheck = buildTool({
256
276
  knownCounterpartiesOnly: z.boolean().optional(),
257
277
  knownCounterparties: z.array(z.string()).max(10_000).optional(),
258
278
  }),
259
- now: instantField.optional().describe("overrides the real clock, for tests and replays"),
279
+ now: instantField.optional().describe(CLOCK_OVERRIDE),
260
280
  }),
261
281
  readOnly: true,
262
282
  concurrencySafe: true,
263
283
  execute: async (input) => {
264
284
  const nowMs = input.now === undefined ? Date.now() : parseInstant(input.now, "now");
265
- return json(checkSpendLimit(input.proposed, input.history, input.limits, nowMs));
285
+ return json({
286
+ ...checkSpendLimit(input.proposed, input.history, input.limits, nowMs),
287
+ // Said in the payload, where whoever acts on the verdict reads it.
288
+ clock: input.now === undefined ? "runtime" : "caller-supplied",
289
+ basis: "the history and limits passed in this call; this verdict is only as binding as the record they came from",
290
+ });
266
291
  },
267
292
  });
268
293
  export const refundAbuseCheck = buildTool({
@@ -287,7 +312,7 @@ export const refundAbuseCheck = buildTool({
287
312
  refundCount: z.number().int().nonnegative().optional(),
288
313
  })
289
314
  .optional(),
290
- now: instantField.optional(),
315
+ now: instantField.optional().describe(CLOCK_OVERRIDE),
291
316
  }),
292
317
  readOnly: true,
293
318
  concurrencySafe: true,
@@ -311,7 +336,7 @@ export const webhookSignatureVerify = buildTool({
311
336
  .describe("NAME of the environment variable holding the signing secret, never the secret"),
312
337
  toleranceSeconds: z.number().int().positive().max(86_400).optional().describe("default 300"),
313
338
  scheme: z.string().optional().describe("default v1"),
314
- now: instantField.optional(),
339
+ now: instantField.optional().describe(CLOCK_OVERRIDE),
315
340
  }),
316
341
  readOnly: true,
317
342
  concurrencySafe: true,
@@ -370,18 +395,33 @@ export const statementParse = buildTool({
370
395
  .positive()
371
396
  .max(20_000)
372
397
  .optional()
373
- .describe("cap the returned list; default 500"),
398
+ .describe("cap the returned transaction and rejected lists; default 500"),
374
399
  }),
375
400
  readOnly: true,
376
401
  concurrencySafe: true,
377
402
  execute: async (input) => {
378
403
  const at = resolveSafe("StatementParse", input.file);
379
- const size = statSync(at.real).size;
380
- if (size > LIMITS.statementBytes) {
381
- throw new Error(`${at.rel} is ${size} bytes, over the ${LIMITS.statementBytes}-byte limit`);
404
+ // Opened without blocking and only as a regular file: a FIFO with no
405
+ // writer blocks an ordinary open for ever, and the read here was
406
+ // synchronous, so a named pipe in the workspace stopped the whole
407
+ // harness. The byte limit is enforced while reading, not by a size the
408
+ // file reported before it was opened.
409
+ const read = await openForRead(workspaceRoot(), input.file, {
410
+ maxBytes: LIMITS.statementBytes,
411
+ });
412
+ if (!read.ok)
413
+ throw new Error(`StatementParse: ${read.reason}`);
414
+ if (read.truncated) {
415
+ throw new Error(`StatementParse: ${JSON.stringify(input.file)} is over the ${LIMITS.statementBytes}-byte limit, so it was not read`);
382
416
  }
383
- const result = parseStatement(readFileSync(at.real, "utf-8"), input);
384
417
  const limit = input.limit ?? 500;
418
+ // Only what is returned is held: the counts and the totals still cover
419
+ // every row, but a file of a million unreadable blocks is not a million
420
+ // objects in memory on the way to showing five hundred of them.
421
+ const result = parseStatement(read.text, {
422
+ ...input,
423
+ keep: { transactions: limit, rejected: limit },
424
+ });
385
425
  return json({
386
426
  file: at.rel,
387
427
  format: result.format,
@@ -390,8 +430,14 @@ export const statementParse = buildTool({
390
430
  totalMinor: result.totalMinor,
391
431
  debitMinor: result.debitMinor,
392
432
  creditMinor: result.creditMinor,
433
+ // Set, with the reason, when a total is past what a number holds exactly.
434
+ ...(result.totalsUnavailable === null ? {} : { totalsUnavailable: result.totalsUnavailable }),
435
+ // Capped like the transactions: a file of nothing but unreadable rows
436
+ // would otherwise come back as one reason per row, whatever its size.
393
437
  rejected: result.rejected,
394
- transactions: result.transactions.slice(0, limit),
438
+ rejectedCount: result.rejectedCount,
439
+ rejectedTruncated: result.rejectedCount > limit,
440
+ transactions: result.transactions,
395
441
  truncated: result.count > limit,
396
442
  });
397
443
  },
@@ -424,10 +470,17 @@ export const glCodeSuggest = buildTool({
424
470
  }),
425
471
  readOnly: true,
426
472
  concurrencySafe: true,
427
- execute: async (input) => json(codeLines(input.lines, input.rules, {
428
- version: input.version,
429
- defaultAccount: input.defaultAccount,
430
- })),
473
+ execute: async (input, ctx) => {
474
+ // `matches` patterns run in the regex worker, before the rules are read,
475
+ // a chunk of lines at a time: a pattern that cannot be run to an answer
476
+ // is undetermined, and the line goes to review rather than to a
477
+ // lower-priority rule.
478
+ return json(await codeLinesAnsweringPatterns(input.lines, input.rules, {
479
+ version: input.version,
480
+ defaultAccount: input.defaultAccount,
481
+ run: regexRunContext(ctx),
482
+ }));
483
+ },
431
484
  });
432
485
  /**
433
486
  * The normalized statement row, and the parser that produces it.
@@ -18,6 +18,13 @@
18
18
  * dropped, since dropping it would silently lose the money.
19
19
  */
20
20
  export declare function allocateProportional(totalMinor: number, weights: ReadonlyArray<number>): number[];
21
+ /**
22
+ * {@link allocateProportional} in exact integers. Each share's exact value is
23
+ * a quotient and a remainder over the weights' sum, so the largest remainders
24
+ * are compared exactly: a double's `magnitude × weight` passes 2^53 on an
25
+ * ordinary invoice's cents times its lines' values.
26
+ */
27
+ export declare function allocateExact(total: bigint, weights: ReadonlyArray<bigint>): bigint[];
21
28
  export type OrderLine = {
22
29
  readonly id: string;
23
30
  readonly quantity: number;