@forgezero/runtime 0.1.7 → 0.1.9

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <!--
2
2
  GENERATED FILE — do not edit.
3
3
 
4
- Change scripts/generate-guides.ts or its typed sources, run `bun run guides`,
4
+ Change tools/generate-guides.ts or its typed sources, run `bun run guides`,
5
5
  and commit the generator and rendered files together.
6
6
  -->
7
7
 
@@ -9,14 +9,77 @@
9
9
 
10
10
  The machinery behind a request handler — jobs, queues, an outbox, a hash-chained audit trail, mail, backups, schema validation and exact money. 44 public modules, each imported on its own.
11
11
 
12
- ## Global package root and supported runtimes
12
+ ## Package overview
13
13
 
14
- Anyone running a service, for the work that happens outside a request. Separate from `access` because a Cloudflare Worker wants the request pipeline and cannot run a backup job. Supported runtimes: bun, node. The global base/root import is @forgezero/runtime. Every public import or command is listed below; the documentation inventory is checked in both directions against package.json exports.
14
+ Anyone running a service, for the work that happens outside a request. Separate from `access` because a Cloudflare Worker wants the request pipeline and cannot run a backup job. Supported runtimes: bun, node. Package root: @forgezero/runtime. The sections below show the actual named imports emitted by each declaration entry point; wildcard imports are intentionally not used in the documentation.
15
15
 
16
16
  ```text
17
- import * as root from '@forgezero/runtime';
17
+ bun add @forgezero/runtime
18
18
  ```
19
19
 
20
+ ## ForgeZero package family
21
+
22
+ The five packages are installation boundaries. Choose a package by who installs it; choose a subpath by the capability used in that file.
23
+
24
+ | package | short description | runtimes | documentation |
25
+ |---|---|---|---|
26
+ | @forgezero/vault | Scoped secret access with Agent, API-key and systemd-credential sources. | bun, node, workers, deno | [Open](https://www.forgezero.net/docs/vault-package) |
27
+ | @forgezero/access | Typed route, principal, factor, RBAC and request-pipeline contracts. | bun, node, workers, deno | [Open](https://www.forgezero.net/docs/access) |
28
+ | @forgezero/providers | Typed external providers with priority, health and classified fallback. | bun, node, workers, deno | [Open](https://www.forgezero.net/docs/providers) |
29
+ | @forgezero/runtime | Portable runtime primitives for queries, jobs, events, schemas and finance. | bun, node | [Open](https://www.forgezero.net/docs/runtime) |
30
+ | @forgezero/agent | Operator CLI and managed-node agent for bootstrap, deploy and lifecycle. | bun, node | [Open](https://www.forgezero.net/docs/agent) |
31
+
32
+ ## @forgezero/runtime public imports and commands
33
+
34
+ Every row links to the detailed explanation and named-import/example area below. This table and those details are generated from the package inventory and emitted declarations.
35
+
36
+ | public entry | short description | runtime | details |
37
+ |---|---|---|---|
38
+ | @forgezero/runtime/query | Provider-neutral typed function contracts: decode untrusted input, run with caller-supplied services or storage, and strictly validate the result without coupling business logic to ForgeZero or ArangoDB. | portable | [Details + example](#forgezero-runtime-query) |
39
+ | @forgezero/runtime/jobs | Background work that never overlaps itself, advances a cursor only on success, and can be paused and inspected. | portable | [Details + example](#forgezero-runtime-jobs) |
40
+ | @forgezero/runtime/queue | Memory-only keyed work queue — awaited results, parallel across keys and strictly sequential within one; clustered callers atomically claim ownership in their own business store before submitting. | portable | [Details + example](#forgezero-runtime-queue) |
41
+ | @forgezero/runtime/outbox | Write the event with the record, deliver it after, in order per key with backoff and a dead-letter queue. | portable | [Details + example](#forgezero-runtime-outbox) |
42
+ | @forgezero/runtime/audit | Append-only records chained by hash, with a verifier that names the first altered entry. | portable | [Details + example](#forgezero-runtime-audit) |
43
+ | @forgezero/runtime/backup | Encrypted, chunked, verified snapshots to object storage — and the restore that reads them back. | portable | [Details + example](#forgezero-runtime-backup) |
44
+ | @forgezero/runtime/notify | Render a named template to text and HTML, escaped per part, refusing to send with a blank where a value should be. | portable | [Details + example](#forgezero-runtime-notify) |
45
+ | @forgezero/runtime/notify/templates | The six transactional messages ForgeZero sends. | portable | [Details + example](#forgezero-runtime-notify-templates) |
46
+ | @forgezero/runtime/calendar | Billing periods computed from an anchor, working days, holidays and due dates. | portable | [Details + example](#forgezero-runtime-calendar) |
47
+ | @forgezero/runtime/compliance | Screening as a decision record — tiers, rules and lists, failing closed when a list is unreachable. | portable | [Details + example](#forgezero-runtime-compliance) |
48
+ | @forgezero/runtime/totp | RFC 6238 TOTP on the existing HMAC — base32, an asymmetric window, and replay left to the caller. | portable | [Details + example](#forgezero-runtime-totp) |
49
+ | @forgezero/runtime/passkey | Passkeys for sites that are not us. A vault-held credential is as unphishable as one in a security chip provided the RP ID check never slips — `evil-example.com` ends with `example.com` and is a different site. | portable | [Details + example](#forgezero-runtime-passkey) |
50
+ | @forgezero/runtime/phrase | BIP-39 recovery phrases, and the salted verifier that proves one without being able to reconstruct it. | portable | [Details + example](#forgezero-runtime-phrase) |
51
+ | @forgezero/runtime/snp | Parse an AMD SEV-SNP attestation report at the firmware ABI offsets, and compare a TCB component by component so a microcode bump cannot mask a firmware downgrade. | portable | [Details + example](#forgezero-runtime-snp) |
52
+ | @forgezero/runtime/importers | Read secrets out of a .env, a CSV, or a Bitwarden or 1Password export — skipping what cannot be understood rather than guessing, and never putting a value in an error. | portable | [Details + example](#forgezero-runtime-importers) |
53
+ | @forgezero/runtime/openssh | OpenSSH wire encoding, so a derived ed25519 key becomes a line that pastes into authorized_keys. | portable | [Details + example](#forgezero-runtime-openssh) |
54
+ | @forgezero/runtime/ssh-cert | OpenSSH certificates, so access expires instead of having to be hunted down. Takes a signing FUNCTION rather than a secret key, which is what lets the CA live in a vault that never hands it out. | portable | [Details + example](#forgezero-runtime-ssh-cert) |
55
+ | @forgezero/runtime/slip10 | SLIP-0010 derivation for ed25519, hardened-only — BIP-32 does not work on this curve and produces halves that do not correspond. | portable | [Details + example](#forgezero-runtime-slip10) |
56
+ | @forgezero/runtime/identity | Hybrid Ed25519 + ML-DSA-65 request signing. One canonical string, so the compute agent that signs inside a guest and the API that verifies cannot drift — which two implementations of it certainly would. | portable | [Details + example](#forgezero-runtime-identity) |
57
+ | @forgezero/runtime/schema | Validate against JSON Schema, restrict what a caller may declare, and describe a schema as a form. | portable | [Details + example](#forgezero-runtime-schema) |
58
+ | @forgezero/runtime/schema/typebox | The TypeBox validator behind that interface. | portable | [Details + example](#forgezero-runtime-schema-typebox) |
59
+ | @forgezero/runtime/finance/discounts | Promotions as arithmetic over integer minor units. They never stack — one winner — and a percentage rounds down, because rounding a discount up gives away a unit of currency per invoice forever. | portable | [Details + example](#forgezero-runtime-finance-discounts) |
60
+ | @forgezero/runtime/finance/money | Exact amounts in minor units with the asset attached, so two currencies cannot be added. | portable | [Details + example](#forgezero-runtime-finance-money) |
61
+ | @forgezero/runtime/finance/venues | Trading venues, market types and symbols as data — spot, margin and futures behind one order model. | portable | [Details + example](#forgezero-runtime-finance-venues) |
62
+ | @forgezero/runtime/finance/ledger | Double-entry postings and derived balances. A hold is a posting, not a lock — the queue does the ordering. | portable | [Details + example](#forgezero-runtime-finance-ledger) |
63
+ | @forgezero/runtime/finance/commission | Profit net of flows, a high-water mark, the tier split and the referral share of our income. | portable | [Details + example](#forgezero-runtime-finance-commission) |
64
+ | @forgezero/runtime/finance/rates | What an asset is worth in USD, and how old that answer is. A peg never ages; a quote always does. | portable | [Details + example](#forgezero-runtime-finance-rates) |
65
+ | @forgezero/runtime/finance/transfers | Deposits and withdrawals as ordered pipelines, with screening reserved at position zero. | portable | [Details + example](#forgezero-runtime-finance-transfers) |
66
+ | @forgezero/runtime/finance/chain | Which chains exist, their confirmation depth by value band, assets and explorers — as data an admin edits. | portable | [Details + example](#forgezero-runtime-finance-chain) |
67
+ | @forgezero/runtime/finance/custody | Derive CREATE2 deposit addresses and EIP-712 custody digests — arithmetic over a seed and a salt, needing no credential and no node. | portable | [Details + example](#forgezero-runtime-finance-custody) |
68
+ | @forgezero/runtime/finance/derive | Declare a field ForgeZero generates rather than the tenant supplying: BIP-44 path arithmetic, and the choice of who is capable of generating the key. | portable | [Details + example](#forgezero-runtime-finance-derive) |
69
+ | @forgezero/runtime/finance/tax | Which jurisdiction may tax a sale, who accounts for it, and the three ways to be zero that report differently. Rates are data. | portable | [Details + example](#forgezero-runtime-finance-tax) |
70
+ | @forgezero/runtime/finance/storage | Write an amount so it is both exact and sortable: an authoritative string, and a number that is only an index. | portable | [Details + example](#forgezero-runtime-finance-storage) |
71
+ | @forgezero/runtime/realtime | Provider-neutral realtime audience, shard, event and delivery contracts. | portable | [Details + example](#forgezero-runtime-realtime) |
72
+ | @forgezero/runtime/passkey-hybrid | Versioned WebAuthn PRF plus ML-DSA companion proof construction and verification. | portable | [Details + example](#forgezero-runtime-passkey-hybrid) |
73
+ | @forgezero/runtime/otpauth | Parse and render otpauth URIs without binding enrolment to a UI framework. | portable | [Details + example](#forgezero-runtime-otpauth) |
74
+ | @forgezero/runtime/pipeline | Typed ordered application-pipeline execution with explicit evidence. | portable | [Details + example](#forgezero-runtime-pipeline) |
75
+ | @forgezero/runtime/finance/chain-addresses | Chain-address derivation records and validation independent of a node provider. | portable | [Details + example](#forgezero-runtime-finance-chain-addresses) |
76
+ | @forgezero/runtime/finance/chain-deposits | Provider-neutral deposit observation, confirmation and credit transitions. | portable | [Details + example](#forgezero-runtime-finance-chain-deposits) |
77
+ | @forgezero/runtime/finance/chain-withdrawals | Provider-neutral withdrawal approval, broadcast and finality transitions. | portable | [Details + example](#forgezero-runtime-finance-chain-withdrawals) |
78
+ | @forgezero/runtime/finance/chain-reconcile | Deterministic reconciliation between chain observations and durable transfer state. | portable | [Details + example](#forgezero-runtime-finance-chain-reconcile) |
79
+ | @forgezero/runtime/finance/market | Market order, fill and quote contracts independent of any exchange adapter. | portable | [Details + example](#forgezero-runtime-finance-market) |
80
+ | @forgezero/runtime/custody-share | Threshold-share parsing, validation and reconstruction. | portable | [Details + example](#forgezero-runtime-custody-share) |
81
+ | @forgezero/runtime/custody-crypto | Hybrid ML-KEM-768 plus X25519 custody-share sealing and opening. | portable | [Details + example](#forgezero-runtime-custody-crypto) |
82
+
20
83
  ## Commands
21
84
 
22
85
  bun add @forgezero/runtime — Install runtime contracts; import the required subpath so unused capabilities stay out of the bundle.
@@ -25,382 +88,1272 @@ bun add @forgezero/runtime — Install runtime contracts; import the required su
25
88
  bun add @forgezero/runtime
26
89
  ```
27
90
 
91
+ <a id="forgezero-runtime-query"></a>
28
92
  ## @forgezero/runtime/query
29
93
 
30
- Provider-neutral typed function contracts: decode untrusted input, run with caller-supplied services or storage, and strictly validate the result without coupling business logic to ForgeZero or ArangoDB.
94
+ Provider-neutral typed function contracts: decode untrusted input, run with caller-supplied services or storage, and strictly validate the result without coupling business logic to ForgeZero or ArangoDB. This entry exposes 3 named value exports and 8 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
31
95
 
32
96
  ```text
33
- import * as api from '@forgezero/runtime/query';
34
- ```
35
-
36
- ## @forgezero/runtime/jobs
97
+ import {
98
+ QueryContractError,
99
+ defineQuery,
100
+ implementQuery,
101
+ } from '@forgezero/runtime/query';
37
102
 
38
- Background work that never overlaps itself, advances a cursor only on success, and can be paused and inspected.
39
-
40
- ```text
41
- import * as api from '@forgezero/runtime/jobs';
103
+ import type {
104
+ QueryCodec,
105
+ QueryContract,
106
+ QueryDecode,
107
+ QueryExecution,
108
+ QueryImplementation,
109
+ QueryInput,
110
+ QueryIssue,
111
+ QueryOutput,
112
+ } from '@forgezero/runtime/query';
42
113
  ```
43
114
 
44
- ## @forgezero/runtime/queue
115
+ ## @forgezero/runtime/query — Define and implement a typed query
45
116
 
46
- Memory-only keyed work queue awaited results, parallel across keys and strictly sequential within one; clustered callers atomically claim ownership in their own business store before submitting.
117
+ Decode untrusted input and validate output around injected storage/services rather than embedding a database query in the route adapter.
47
118
 
48
119
  ```text
49
- import * as api from '@forgezero/runtime/queue';
50
- ```
120
+ import {
121
+ defineQuery,
122
+ implementQuery,
123
+ } from '@forgezero/runtime/query';
124
+ import {
125
+ T,
126
+ type Static,
127
+ typeboxQueryCodec,
128
+ } from '@forgezero/runtime/schema/typebox';
51
129
 
52
- ## @forgezero/runtime/outbox
130
+ const OrderKey = T.Object({ orderKey: T.String({ minLength: 1 }) });
131
+ const Order = T.Object({ orderKey: T.String(), total: T.String() });
132
+ type OrderRow = Static<typeof Order>;
133
+ type Stores = { orders: { find(key: string): Promise<OrderRow | null> } };
134
+ declare const stores: Stores;
53
135
 
54
- Write the event with the record, deliver it after, in order per key with backoff and a dead-letter queue.
136
+ const findOrder = defineQuery({
137
+ name: 'orders.find',
138
+ input: typeboxQueryCodec(OrderKey),
139
+ output: typeboxQueryCodec(T.Union([Order, T.Null()]))
140
+ });
141
+ export const runFindOrder = implementQuery(findOrder,
142
+ (context: Stores, input) => context.orders.find(input.orderKey)
143
+ );
55
144
 
56
- ```text
57
- import * as api from '@forgezero/runtime/outbox';
145
+ const order = await runFindOrder.execute(stores, { orderKey: 'ord_123' });
58
146
  ```
59
147
 
60
- ## @forgezero/runtime/audit
148
+ <a id="forgezero-runtime-jobs"></a>
149
+ ## @forgezero/runtime/jobs
150
+
151
+ Background work that never overlaps itself, advances a cursor only on success, and can be paused and inspected. This entry exposes 9 named value exports and 14 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
152
+
153
+ ```text
154
+ import {
155
+ VERSION,
156
+ createScheduler,
157
+ cursorJob,
158
+ defineJob,
159
+ everyMs,
160
+ memoryLock,
161
+ nextWallClockAt,
162
+ storeLock,
163
+ systemClock,
164
+ } from '@forgezero/runtime/jobs';
165
+
166
+ import type {
167
+ Clock,
168
+ CursorBatch,
169
+ CursorJobSpec,
170
+ CursorStore,
171
+ JobContext,
172
+ JobLock,
173
+ JobReport,
174
+ JobResult,
175
+ JobSpec,
176
+ Lease,
177
+ LockStore,
178
+ Scheduler,
179
+ SchedulerOptions,
180
+ WallClockSchedule,
181
+ } from '@forgezero/runtime/jobs';
182
+ ```
183
+
184
+ <a id="forgezero-runtime-queue"></a>
185
+ ## @forgezero/runtime/queue
61
186
 
62
- Append-only records chained by hash, with a verifier that names the first altered entry.
187
+ Memory-only keyed work queue — awaited results, parallel across keys and strictly sequential within one; clustered callers atomically claim ownership in their own business store before submitting. This entry exposes 5 named value exports and 6 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
63
188
 
64
189
  ```text
65
- import * as api from '@forgezero/runtime/audit';
190
+ import {
191
+ QueueKeyStoppedError,
192
+ QueueStoppedError,
193
+ TaskCancelledError,
194
+ createQueue,
195
+ queueWidthFor,
196
+ } from '@forgezero/runtime/queue';
197
+
198
+ import type {
199
+ DrainReport,
200
+ Queue,
201
+ QueueOptions,
202
+ QueueResourcePolicy,
203
+ QueueTask,
204
+ RetryPolicy,
205
+ } from '@forgezero/runtime/queue';
66
206
  ```
67
207
 
68
- ## @forgezero/runtime/backup
208
+ <a id="forgezero-runtime-outbox"></a>
209
+ ## @forgezero/runtime/outbox
69
210
 
70
- Encrypted, chunked, verified snapshots to object storage and the restore that reads them back.
211
+ Write the event with the record, deliver it after, in order per key with backoff and a dead-letter queue. This entry exposes 8 named value exports and 10 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
212
+
213
+ ```text
214
+ import {
215
+ DEFAULT_POLICY,
216
+ EVENT_STATES,
217
+ OutboxError,
218
+ VERSION,
219
+ backoffMs,
220
+ createOutbox,
221
+ memoryStore,
222
+ outboxJob,
223
+ } from '@forgezero/runtime/outbox';
224
+
225
+ import type {
226
+ DeliveryPolicy,
227
+ DeliveryResult,
228
+ DrainReport,
229
+ EventState,
230
+ Outbox,
231
+ OutboxEvent,
232
+ OutboxOptions,
233
+ OutboxStore,
234
+ PublishInput,
235
+ Transport,
236
+ } from '@forgezero/runtime/outbox';
237
+ ```
238
+
239
+ <a id="forgezero-runtime-audit"></a>
240
+ ## @forgezero/runtime/audit
71
241
 
72
- ```text
73
- import * as api from '@forgezero/runtime/backup';
74
- ```
242
+ Append-only records chained by hash, with a verifier that names the first altered entry. This entry exposes 12 named value exports and 10 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
243
+
244
+ ```text
245
+ import {
246
+ AuditChainError,
247
+ GENESIS_DIGEST,
248
+ VERSION,
249
+ appendRecord,
250
+ canonicalise,
251
+ createAuditChain,
252
+ exportRange,
253
+ hashDigester,
254
+ memoryStore,
255
+ sealedDigester,
256
+ verifyChain,
257
+ verifyExport,
258
+ } from '@forgezero/runtime/audit';
259
+
260
+ import type {
261
+ AppendOptions,
262
+ AuditChain,
263
+ AuditChainOptions,
264
+ AuditEntry,
265
+ AuditExport,
266
+ AuditRecord,
267
+ AuditStore,
268
+ ChainVerdict,
269
+ Digester,
270
+ EffectAuditRecord,
271
+ } from '@forgezero/runtime/audit';
272
+ ```
273
+
274
+ <a id="forgezero-runtime-backup"></a>
275
+ ## @forgezero/runtime/backup
75
276
 
277
+ Encrypted, chunked, verified snapshots to object storage — and the restore that reads them back. This entry exposes 11 named value exports and 10 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
278
+
279
+ ```text
280
+ import {
281
+ BackupError,
282
+ DEFAULT_RETENTION,
283
+ SNAPSHOT_FORMAT,
284
+ VERSION,
285
+ backupJob,
286
+ listSnapshots,
287
+ prune,
288
+ restore,
289
+ selectForDeletion,
290
+ snapshot,
291
+ verifySnapshot,
292
+ } from '@forgezero/runtime/backup';
293
+
294
+ import type {
295
+ ChunkRecord,
296
+ ObjectStore,
297
+ RestoreOptions,
298
+ RestoreReport,
299
+ RetentionPolicy,
300
+ RowSink,
301
+ RowSource,
302
+ SnapshotManifest,
303
+ SnapshotOptions,
304
+ VerifyReport,
305
+ } from '@forgezero/runtime/backup';
306
+ ```
307
+
308
+ <a id="forgezero-runtime-notify"></a>
76
309
  ## @forgezero/runtime/notify
77
310
 
78
- Render a named template to text and HTML, escaped per part, refusing to send with a blank where a value should be.
79
-
80
- ```text
81
- import * as api from '@forgezero/runtime/notify';
82
- ```
83
-
311
+ Render a named template to text and HTML, escaped per part, refusing to send with a blank where a value should be. This entry exposes 12 named value exports and 7 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
312
+
313
+ ```text
314
+ import {
315
+ CHANNELS,
316
+ NotifyError,
317
+ VERSION,
318
+ assertHeaderSafe,
319
+ button,
320
+ codeBlock,
321
+ createNotifier,
322
+ defineTemplate,
323
+ escapeHtml,
324
+ layout,
325
+ preview,
326
+ render,
327
+ } from '@forgezero/runtime/notify';
328
+
329
+ import type {
330
+ Channel,
331
+ Notification,
332
+ Notifier,
333
+ NotifierOptions,
334
+ Rendered,
335
+ TemplateSpec,
336
+ Transport,
337
+ } from '@forgezero/runtime/notify';
338
+ ```
339
+
340
+ <a id="forgezero-runtime-notify-templates"></a>
84
341
  ## @forgezero/runtime/notify/templates
85
342
 
86
- The six transactional messages ForgeZero sends.
343
+ The six transactional messages ForgeZero sends. This entry exposes 8 named value exports and 1 named type export. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
87
344
 
88
345
  ```text
89
- import * as api from '@forgezero/runtime/notify/templates';
346
+ import {
347
+ TEMPLATES,
348
+ ceremonyProposed,
349
+ custodianEnrolment,
350
+ escapeHtml,
351
+ invitation,
352
+ newDevice,
353
+ signInCode,
354
+ vaultLocked,
355
+ } from '@forgezero/runtime/notify/templates';
356
+
357
+ import type {
358
+ TemplateKey,
359
+ } from '@forgezero/runtime/notify/templates';
90
360
  ```
91
361
 
362
+ <a id="forgezero-runtime-calendar"></a>
92
363
  ## @forgezero/runtime/calendar
93
364
 
94
- Billing periods computed from an anchor, working days, holidays and due dates.
95
-
96
- ```text
97
- import * as api from '@forgezero/runtime/calendar';
98
- ```
99
-
365
+ Billing periods computed from an anchor, working days, holidays and due dates. This entry exposes 15 named value exports and 4 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
366
+
367
+ ```text
368
+ import {
369
+ CalendarError,
370
+ DAY_MS,
371
+ DEFAULT_WORKING_DAYS,
372
+ closedPeriods,
373
+ dayOfWeek,
374
+ daysOverdue,
375
+ fromDay,
376
+ isOverdue,
377
+ isWorkingDay,
378
+ nextWorkingDay,
379
+ periodAt,
380
+ periodIndexOn,
381
+ periodOn,
382
+ toDay,
383
+ workingDaysBetween,
384
+ } from '@forgezero/runtime/calendar';
385
+
386
+ import type {
387
+ BillingSchedule,
388
+ Calendar,
389
+ IsoDate,
390
+ Period,
391
+ } from '@forgezero/runtime/calendar';
392
+ ```
393
+
394
+ <a id="forgezero-runtime-compliance"></a>
100
395
  ## @forgezero/runtime/compliance
101
396
 
102
- Screening as a decision record — tiers, rules and lists, failing closed when a list is unreachable.
103
-
104
- ```text
105
- import * as api from '@forgezero/runtime/compliance';
106
- ```
107
-
397
+ Screening as a decision record — tiers, rules and lists, failing closed when a list is unreachable. This entry exposes 11 named value exports and 10 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
398
+
399
+ ```text
400
+ import {
401
+ ComplianceError,
402
+ RISK_LEVELS,
403
+ VERIFICATION_TIERS,
404
+ combineLists,
405
+ countryRule,
406
+ newCounterpartyRule,
407
+ screen,
408
+ screeningStage,
409
+ staticList,
410
+ tierLimitRule,
411
+ unavailableList,
412
+ } from '@forgezero/runtime/compliance';
413
+
414
+ import type {
415
+ ListEntry,
416
+ RiskLevel,
417
+ Rule,
418
+ RuleHit,
419
+ ScreenOptions,
420
+ ScreeningList,
421
+ StageOptions,
422
+ Subject,
423
+ Verdict,
424
+ VerificationTier,
425
+ } from '@forgezero/runtime/compliance';
426
+ ```
427
+
428
+ <a id="forgezero-runtime-totp"></a>
108
429
  ## @forgezero/runtime/totp
109
430
 
110
- RFC 6238 TOTP on the existing HMAC — base32, an asymmetric window, and replay left to the caller.
111
-
112
- ```text
113
- import * as api from '@forgezero/runtime/totp';
114
- ```
115
-
431
+ RFC 6238 TOTP on the existing HMAC — base32, an asymmetric window, and replay left to the caller. This entry exposes 13 named value exports and 3 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
432
+
433
+ ```text
434
+ import {
435
+ DEFAULT_DIGITS,
436
+ DEFAULT_STEP_SECONDS,
437
+ TotpError,
438
+ assertCode,
439
+ codeAt,
440
+ codeFor,
441
+ counterAt,
442
+ enrolmentUri,
443
+ fromBase32,
444
+ generateSecret,
445
+ secondsRemaining,
446
+ toBase32,
447
+ verifyCode,
448
+ } from '@forgezero/runtime/totp';
449
+
450
+ import type {
451
+ TotpOptions,
452
+ VerifyOptions,
453
+ VerifyResult,
454
+ } from '@forgezero/runtime/totp';
455
+ ```
456
+
457
+ <a id="forgezero-runtime-passkey"></a>
116
458
  ## @forgezero/runtime/passkey
117
459
 
118
- Passkeys for sites that are not us. A vault-held credential is as unphishable as one in a security chip provided the RP ID check never slips — `evil-example.com` ends with `example.com` and is a different site.
460
+ Passkeys for sites that are not us. A vault-held credential is as unphishable as one in a security chip provided the RP ID check never slips — `evil-example.com` ends with `example.com` and is a different site. This entry exposes 11 named value exports and 3 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
119
461
 
120
462
  ```text
121
- import * as api from '@forgezero/runtime/passkey';
463
+ import {
464
+ FLAG_BE,
465
+ FLAG_BS,
466
+ FLAG_UP,
467
+ FLAG_UV,
468
+ PasskeyError,
469
+ assertPasskey,
470
+ authenticatorData,
471
+ credentialIdFor,
472
+ passkeysFor,
473
+ rpIdMatches,
474
+ verifyAssertion,
475
+ } from '@forgezero/runtime/passkey';
476
+
477
+ import type {
478
+ Assertion,
479
+ AssertionRequest,
480
+ StoredPasskey,
481
+ } from '@forgezero/runtime/passkey';
122
482
  ```
123
483
 
484
+ <a id="forgezero-runtime-phrase"></a>
124
485
  ## @forgezero/runtime/phrase
125
486
 
126
- BIP-39 recovery phrases, and the salted verifier that proves one without being able to reconstruct it.
487
+ BIP-39 recovery phrases, and the salted verifier that proves one without being able to reconstruct it. This entry exposes 7 named value exports and 0 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
127
488
 
128
489
  ```text
129
- import * as api from '@forgezero/runtime/phrase';
490
+ import {
491
+ PHRASE_SALT_BYTES,
492
+ PHRASE_WORDS,
493
+ generatePhrase,
494
+ newSalt,
495
+ phraseToKey,
496
+ phraseVerifier,
497
+ validatePhrase,
498
+ } from '@forgezero/runtime/phrase';
130
499
  ```
131
500
 
501
+ <a id="forgezero-runtime-snp"></a>
132
502
  ## @forgezero/runtime/snp
133
503
 
134
- Parse an AMD SEV-SNP attestation report at the firmware ABI offsets, and compare a TCB component by component so a microcode bump cannot mask a firmware downgrade.
504
+ Parse an AMD SEV-SNP attestation report at the firmware ABI offsets, and compare a TCB component by component so a microcode bump cannot mask a firmware downgrade. This entry exposes 5 named value exports and 3 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
135
505
 
136
506
  ```text
137
- import * as api from '@forgezero/runtime/snp';
507
+ import {
508
+ REPORT_BYTES,
509
+ SnpError,
510
+ bindsNonce,
511
+ parseSnpReport,
512
+ tcbAtLeast,
513
+ } from '@forgezero/runtime/snp';
514
+
515
+ import type {
516
+ GuestPolicy,
517
+ SnpReport,
518
+ TcbVersion,
519
+ } from '@forgezero/runtime/snp';
138
520
  ```
139
521
 
522
+ <a id="forgezero-runtime-importers"></a>
140
523
  ## @forgezero/runtime/importers
141
524
 
142
- Read secrets out of a .env, a CSV, or a Bitwarden or 1Password export — skipping what cannot be understood rather than guessing, and never putting a value in an error.
525
+ Read secrets out of a .env, a CSV, or a Bitwarden or 1Password export — skipping what cannot be understood rather than guessing, and never putting a value in an error. This entry exposes 7 named value exports and 4 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
143
526
 
144
527
  ```text
145
- import * as api from '@forgezero/runtime/importers';
528
+ import {
529
+ IMPORT_FORMATS,
530
+ normaliseName,
531
+ parseBitwarden,
532
+ parseCsv,
533
+ parseEnv,
534
+ parseImport,
535
+ parseOnePassword,
536
+ } from '@forgezero/runtime/importers';
537
+
538
+ import type {
539
+ ImportFormat,
540
+ ImportResult,
541
+ ImportedSecret,
542
+ Skipped,
543
+ } from '@forgezero/runtime/importers';
146
544
  ```
147
545
 
546
+ <a id="forgezero-runtime-openssh"></a>
148
547
  ## @forgezero/runtime/openssh
149
548
 
150
- OpenSSH wire encoding, so a derived ed25519 key becomes a line that pastes into authorized_keys.
549
+ OpenSSH wire encoding, so a derived ed25519 key becomes a line that pastes into authorized_keys. This entry exposes 6 named value exports and 0 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
151
550
 
152
551
  ```text
153
- import * as api from '@forgezero/runtime/openssh';
552
+ import {
553
+ OpenSshError,
554
+ authorizedKey,
555
+ fingerprint,
556
+ parseAuthorizedKey,
557
+ publicKeyBlob,
558
+ signatureBlob,
559
+ } from '@forgezero/runtime/openssh';
154
560
  ```
155
561
 
562
+ <a id="forgezero-runtime-ssh-cert"></a>
156
563
  ## @forgezero/runtime/ssh-cert
157
564
 
158
- OpenSSH certificates, so access expires instead of having to be hunted down. Takes a signing FUNCTION rather than a secret key, which is what lets the CA live in a vault that never hands it out.
565
+ OpenSSH certificates, so access expires instead of having to be hunted down. Takes a signing FUNCTION rather than a secret key, which is what lets the CA live in a vault that never hands it out. This entry exposes 9 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
159
566
 
160
567
  ```text
161
- import * as api from '@forgezero/runtime/ssh-cert';
568
+ import {
569
+ CERT_TYPE_HOST,
570
+ CERT_TYPE_USER,
571
+ DEFAULT_EXTENSIONS,
572
+ SshCertError,
573
+ caFingerprint,
574
+ caFromSecretKey,
575
+ caPublicKeyLine,
576
+ isCurrentlyValid,
577
+ signCertificate,
578
+ } from '@forgezero/runtime/ssh-cert';
579
+
580
+ import type {
581
+ CertificateAuthority,
582
+ CertificateRequest,
583
+ } from '@forgezero/runtime/ssh-cert';
162
584
  ```
163
585
 
586
+ <a id="forgezero-runtime-slip10"></a>
164
587
  ## @forgezero/runtime/slip10
165
588
 
166
- SLIP-0010 derivation for ed25519, hardened-only — BIP-32 does not work on this curve and produces halves that do not correspond.
589
+ SLIP-0010 derivation for ed25519, hardened-only — BIP-32 does not work on this curve and produces halves that do not correspond. This entry exposes 5 named value exports and 1 named type export. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
167
590
 
168
591
  ```text
169
- import * as api from '@forgezero/runtime/slip10';
592
+ import {
593
+ HARDENED_OFFSET,
594
+ Slip10Error,
595
+ deriveChild,
596
+ derivePath,
597
+ masterFromSeed,
598
+ } from '@forgezero/runtime/slip10';
599
+
600
+ import type {
601
+ Slip10Node,
602
+ } from '@forgezero/runtime/slip10';
170
603
  ```
171
604
 
605
+ <a id="forgezero-runtime-identity"></a>
172
606
  ## @forgezero/runtime/identity
173
607
 
174
- Hybrid Ed25519 + ML-DSA-65 request signing. One canonical string, so the compute agent that signs inside a guest and the API that verifies cannot drift — which two implementations of it certainly would.
175
-
176
- ```text
177
- import * as api from '@forgezero/runtime/identity';
178
- ```
179
-
608
+ Hybrid Ed25519 + ML-DSA-65 request signing. One canonical string, so the compute agent that signs inside a guest and the API that verifies cannot drift — which two implementations of it certainly would. This entry exposes 16 named value exports and 6 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
609
+
610
+ ```text
611
+ import {
612
+ CLOCK_SKEW_SECONDS,
613
+ REQUEST_SIGNATURE_SUITE,
614
+ RESPONSE_KEY_HEADER,
615
+ RESPONSE_SEALING_SUITE,
616
+ canonicalString,
617
+ decodeSignatureHeader,
618
+ deriveKeysFromSeed,
619
+ derivePublicKeysFromSeed,
620
+ encodeSignatureHeader,
621
+ generateNodeKeys,
622
+ generateResponseRecipient,
623
+ openResponse,
624
+ sealResponse,
625
+ signRequest,
626
+ validResponsePublicKey,
627
+ verifyRequest,
628
+ } from '@forgezero/runtime/identity';
629
+
630
+ import type {
631
+ NodeKeyPair,
632
+ NodePublicKeys,
633
+ ResponseRecipient,
634
+ SealedResponse,
635
+ SignedEnvelope,
636
+ VerifyFailure,
637
+ } from '@forgezero/runtime/identity';
638
+ ```
639
+
640
+ <a id="forgezero-runtime-schema"></a>
180
641
  ## @forgezero/runtime/schema
181
642
 
182
- Validate against JSON Schema, restrict what a caller may declare, and describe a schema as a form.
643
+ Validate against JSON Schema, restrict what a caller may declare, and describe a schema as a form. This entry exposes 8 named value exports and 5 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
183
644
 
184
645
  ```text
185
- import * as api from '@forgezero/runtime/schema';
646
+ import {
647
+ DEFAULT_RESTRICTIONS,
648
+ SCHEMA_VERSION,
649
+ SchemaError,
650
+ VERSION,
651
+ describeJsonSchema,
652
+ readableFields,
653
+ restrictJsonSchema,
654
+ writeOnlyPaths,
655
+ } from '@forgezero/runtime/schema';
656
+
657
+ import type {
658
+ FieldKind,
659
+ FormField,
660
+ Restrictions,
661
+ SchemaValidator,
662
+ ValidationResult,
663
+ } from '@forgezero/runtime/schema';
186
664
  ```
187
665
 
188
- ## @forgezero/runtime/schema/typebox
666
+ ## @forgezero/runtime/schema — Restrict an untrusted JSON Schema before storing it
189
667
 
190
- The TypeBox validator behind that interface.
668
+ Tenant-supplied schemas are data, not executable code. Restriction rejects references, remote identifiers, unsupported keywords, excessive depth/size, and arrays without a bounded maxItems. Form metadata is derived from the accepted schema; write-only fields remain identifiable for secret handling.
191
669
 
192
670
  ```text
193
- import * as api from '@forgezero/runtime/schema/typebox';
671
+ import {
672
+ restrictJsonSchema,
673
+ describeJsonSchema,
674
+ writeOnlyPaths,
675
+ } from '@forgezero/runtime/schema';
676
+
677
+ const schema = restrictJsonSchema({
678
+ type: 'object', additionalProperties: false,
679
+ properties: {
680
+ recipients: { type: 'array', maxItems: 100, items: { type: 'string' } },
681
+ apiKey: { type: 'string', title: 'API key', writeOnly: true }
682
+ },
683
+ required: ['apiKey']
684
+ });
685
+ const fields = describeJsonSchema(schema);
686
+ const secretFields = writeOnlyPaths(fields);
194
687
  ```
195
688
 
196
- ## @forgezero/runtime/finance/discounts
689
+ <a id="forgezero-runtime-schema-typebox"></a>
690
+ ## @forgezero/runtime/schema/typebox
197
691
 
198
- Promotions as arithmetic over integer minor units. They never stack one winner and a percentage rounds down, because rounding a discount up gives away a unit of currency per invoice forever.
692
+ The TypeBox validator behind that interface. This entry exposes 4 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
199
693
 
200
694
  ```text
201
- import * as api from '@forgezero/runtime/finance/discounts';
695
+ import {
696
+ T,
697
+ parse,
698
+ typebox,
699
+ typeboxQueryCodec,
700
+ } from '@forgezero/runtime/schema/typebox';
701
+
702
+ import type {
703
+ Static,
704
+ TSchema,
705
+ } from '@forgezero/runtime/schema/typebox';
202
706
  ```
203
707
 
204
- ## @forgezero/runtime/finance/money
708
+ ## @forgezero/runtime/schema/typebox — One TypeBox shape for runtime validation and static types
205
709
 
206
- Exact amounts in minor units with the asset attached, so two currencies cannot be added.
710
+ TypeBox is an optional peer. Its schema is JSON Schema, so the same restriction and form layer applies. The query codec validates both untrusted input and returned output; malformed values fail instead of being coerced.
207
711
 
208
712
  ```text
209
- import * as api from '@forgezero/runtime/finance/money';
713
+ import {
714
+ T,
715
+ type Static,
716
+ parse,
717
+ typeboxQueryCodec,
718
+ } from '@forgezero/runtime/schema/typebox';
719
+
720
+ const User = T.Object({
721
+ userKey: T.String({ minLength: 1 }),
722
+ roles: T.Array(T.String(), { maxItems: 32 })
723
+ }, { additionalProperties: false });
724
+ type User = Static<typeof User>;
725
+ const user: User = parse(User, unknownInput);
726
+ const codec = typeboxQueryCodec(User);
210
727
  ```
211
728
 
212
- ## @forgezero/runtime/finance/venues
729
+ <a id="forgezero-runtime-finance-discounts"></a>
730
+ ## @forgezero/runtime/finance/discounts
213
731
 
214
- Trading venues, market types and symbols as dataspot, margin and futures behind one order model.
732
+ Promotions as arithmetic over integer minor units. They never stack one winner — and a percentage rounds down, because rounding a discount up gives away a unit of currency per invoice forever. This entry exposes 7 named value exports and 4 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
215
733
 
216
734
  ```text
217
- import * as api from '@forgezero/runtime/finance/venues';
735
+ import {
736
+ DiscountError,
737
+ assertCode,
738
+ assertWindow,
739
+ bestDiscount,
740
+ discountFor,
741
+ ineligibility,
742
+ normaliseCode,
743
+ } from '@forgezero/runtime/finance/discounts';
744
+
745
+ import type {
746
+ AppliedDiscount,
747
+ DiscountKind,
748
+ Ineligibility,
749
+ Promotion,
750
+ } from '@forgezero/runtime/finance/discounts';
218
751
  ```
219
752
 
220
- ## @forgezero/runtime/finance/ledger
753
+ <a id="forgezero-runtime-finance-money"></a>
754
+ ## @forgezero/runtime/finance/money
221
755
 
222
- Double-entry postings and derived balances. A hold is a posting, not a lock the queue does the ordering.
756
+ Exact amounts in minor units with the asset attached, so two currencies cannot be added. This entry exposes 22 named value exports and 3 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
757
+
758
+ ```text
759
+ import {
760
+ ASSETS,
761
+ MoneyError,
762
+ ROUNDING,
763
+ VERSION,
764
+ abs,
765
+ add,
766
+ allocate,
767
+ assetSpec,
768
+ compare,
769
+ convert,
770
+ defineAsset,
771
+ equals,
772
+ formatAmount,
773
+ isNegative,
774
+ isZero,
775
+ money,
776
+ mulRate,
777
+ negate,
778
+ parseAmount,
779
+ subtract,
780
+ toStep,
781
+ zero,
782
+ } from '@forgezero/runtime/finance/money';
783
+
784
+ import type {
785
+ AssetSpec,
786
+ Money,
787
+ Rounding,
788
+ } from '@forgezero/runtime/finance/money';
789
+ ```
790
+
791
+ <a id="forgezero-runtime-finance-venues"></a>
792
+ ## @forgezero/runtime/finance/venues
223
793
 
224
- ```text
225
- import * as api from '@forgezero/runtime/finance/ledger';
226
- ```
794
+ Trading venues, market types and symbols as data — spot, margin and futures behind one order model. This entry exposes 14 named value exports and 10 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
795
+
796
+ ```text
797
+ import {
798
+ MARKET_TYPES,
799
+ ORDER_SIDES,
800
+ ORDER_TYPES,
801
+ TIME_IN_FORCE,
802
+ VENUES,
803
+ VERSION,
804
+ VenueError,
805
+ notionalOf,
806
+ parseSymbol,
807
+ submitOrder,
808
+ symbolOf,
809
+ validateOrder,
810
+ venue,
811
+ venuesFor,
812
+ } from '@forgezero/runtime/finance/venues';
813
+
814
+ import type {
815
+ MarketSpec,
816
+ MarketType,
817
+ OrderRequest,
818
+ OrderResult,
819
+ OrderSide,
820
+ OrderStatus,
821
+ OrderType,
822
+ TimeInForce,
823
+ VenueAdapter,
824
+ VenueSpec,
825
+ } from '@forgezero/runtime/finance/venues';
826
+ ```
827
+
828
+ <a id="forgezero-runtime-finance-ledger"></a>
829
+ ## @forgezero/runtime/finance/ledger
227
830
 
831
+ Double-entry postings and derived balances. A hold is a posting, not a lock — the queue does the ordering. This entry exposes 21 named value exports and 6 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
832
+
833
+ ```text
834
+ import {
835
+ ACCOUNT_KINDS,
836
+ BUCKETS,
837
+ LedgerError,
838
+ MAX_LEDGER_ENTRIES,
839
+ VERSION,
840
+ accountId,
841
+ assertAvailable,
842
+ assertBalanced,
843
+ availableOf,
844
+ balanceOf,
845
+ balancesFrom,
846
+ captureHold,
847
+ heldOf,
848
+ parseAccount,
849
+ placeHold,
850
+ queueKeyFor,
851
+ releaseHold,
852
+ statement,
853
+ totalOf,
854
+ transfer,
855
+ trialBalance,
856
+ } from '@forgezero/runtime/finance/ledger';
857
+
858
+ import type {
859
+ AccountKind,
860
+ AccountRef,
861
+ Bucket,
862
+ Entry,
863
+ Transaction,
864
+ TrialBalance,
865
+ } from '@forgezero/runtime/finance/ledger';
866
+ ```
867
+
868
+ <a id="forgezero-runtime-finance-commission"></a>
228
869
  ## @forgezero/runtime/finance/commission
229
870
 
230
- Profit net of flows, a high-water mark, the tier split and the referral share of our income.
871
+ Profit net of flows, a high-water mark, the tier split and the referral share of our income. This entry exposes 9 named value exports and 6 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
231
872
 
232
873
  ```text
233
- import * as api from '@forgezero/runtime/finance/commission';
874
+ import {
875
+ CommissionError,
876
+ allocate,
877
+ chargeableProfit,
878
+ commissionTransaction,
879
+ nextHighWaterMark,
880
+ periodProfit,
881
+ projectPrepay,
882
+ splitCommission,
883
+ splitReferrals,
884
+ } from '@forgezero/runtime/finance/commission';
885
+
886
+ import type {
887
+ CommissionInput,
888
+ CommissionSplit,
889
+ PeriodPerformance,
890
+ Prepay,
891
+ PrepayInput,
892
+ ReferralShare,
893
+ } from '@forgezero/runtime/finance/commission';
234
894
  ```
235
895
 
896
+ <a id="forgezero-runtime-finance-rates"></a>
236
897
  ## @forgezero/runtime/finance/rates
237
898
 
238
- What an asset is worth in USD, and how old that answer is. A peg never ages; a quote always does.
239
-
240
- ```text
241
- import * as api from '@forgezero/runtime/finance/rates';
242
- ```
243
-
899
+ What an asset is worth in USD, and how old that answer is. A peg never ages; a quote always does. This entry exposes 11 named value exports and 7 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
900
+
901
+ ```text
902
+ import {
903
+ BASE_ASSET,
904
+ RATE_SOURCES,
905
+ RateError,
906
+ assertRate,
907
+ createRateTable,
908
+ describeRate,
909
+ isRegistered,
910
+ peg,
911
+ rateRefreshJob,
912
+ refreshRates,
913
+ registerAsset,
914
+ } from '@forgezero/runtime/finance/rates';
915
+
916
+ import type {
917
+ AssetEntry,
918
+ AssetRate,
919
+ RateFetcher,
920
+ RateSource,
921
+ RateTable,
922
+ RateTableOptions,
923
+ RefreshReport,
924
+ } from '@forgezero/runtime/finance/rates';
925
+ ```
926
+
927
+ <a id="forgezero-runtime-finance-transfers"></a>
244
928
  ## @forgezero/runtime/finance/transfers
245
929
 
246
- Deposits and withdrawals as ordered pipelines, with screening reserved at position zero.
930
+ Deposits and withdrawals as ordered pipelines, with screening reserved at position zero. This entry exposes 9 named value exports and 6 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
247
931
 
248
932
  ```text
249
- import * as api from '@forgezero/runtime/finance/transfers';
933
+ import {
934
+ DIRECTIONS,
935
+ PipelineError,
936
+ SCREENING_ORDER,
937
+ approvalStage,
938
+ balanceStage,
939
+ createTransferPipeline,
940
+ limitsStage,
941
+ notFrozenStage,
942
+ screeningStage,
943
+ } from '@forgezero/runtime/finance/transfers';
944
+
945
+ import type {
946
+ Direction,
947
+ PipelineResult,
948
+ Stage,
949
+ StageOutcome,
950
+ Transfer,
951
+ TransferPipeline,
952
+ } from '@forgezero/runtime/finance/transfers';
250
953
  ```
251
954
 
955
+ <a id="forgezero-runtime-finance-chain"></a>
252
956
  ## @forgezero/runtime/finance/chain
253
957
 
254
- Which chains exist, their confirmation depth by value band, assets and explorers — as data an admin edits.
958
+ Which chains exist, their confirmation depth by value band, assets and explorers — as data an admin edits. This entry exposes 9 named value exports and 5 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
255
959
 
256
960
  ```text
257
- import * as api from '@forgezero/runtime/finance/chain';
961
+ import {
962
+ ADDRESS_SCHEMES,
963
+ ChainError,
964
+ SEED_CHAINS,
965
+ SEED_CHAIN_ASSETS,
966
+ assertChain,
967
+ confirmationsFor,
968
+ createChainRegistry,
969
+ estimatedSeconds,
970
+ validateAddress,
971
+ } from '@forgezero/runtime/finance/chain';
972
+
973
+ import type {
974
+ AddressScheme,
975
+ ChainAsset,
976
+ ChainRegistry,
977
+ ChainSpec,
978
+ ConfirmationBand,
979
+ } from '@forgezero/runtime/finance/chain';
258
980
  ```
259
981
 
982
+ <a id="forgezero-runtime-finance-custody"></a>
260
983
  ## @forgezero/runtime/finance/custody
261
984
 
262
- Derive CREATE2 deposit addresses and EIP-712 custody digests — arithmetic over a seed and a salt, needing no credential and no node.
985
+ Derive CREATE2 deposit addresses and EIP-712 custody digests — arithmetic over a seed and a salt, needing no credential and no node. This entry exposes 8 named value exports and 0 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
263
986
 
264
987
  ```text
265
- import * as api from '@forgezero/runtime/finance/custody';
988
+ import {
989
+ CustodyError,
990
+ VERSION,
991
+ depositAddress,
992
+ domainSeparator,
993
+ orderSignatures,
994
+ saltFor,
995
+ toChecksumAddress,
996
+ withdrawDigest,
997
+ } from '@forgezero/runtime/finance/custody';
266
998
  ```
267
999
 
1000
+ <a id="forgezero-runtime-finance-derive"></a>
268
1001
  ## @forgezero/runtime/finance/derive
269
1002
 
270
- Declare a field ForgeZero generates rather than the tenant supplying: BIP-44 path arithmetic, and the choice of who is capable of generating the key.
1003
+ Declare a field ForgeZero generates rather than the tenant supplying: BIP-44 path arithmetic, and the choice of who is capable of generating the key. This entry exposes 11 named value exports and 4 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
271
1004
 
272
1005
  ```text
273
- import * as api from '@forgezero/runtime/finance/derive';
1006
+ import {
1007
+ CUSTODY,
1008
+ DERIVE_KEYWORD,
1009
+ DeriveError,
1010
+ SCHEMES,
1011
+ assertDeriveSpec,
1012
+ custodyOf,
1013
+ deriveSpecOf,
1014
+ derivedFields,
1015
+ derivedPaths,
1016
+ pathFor,
1017
+ suppliedPaths,
1018
+ } from '@forgezero/runtime/finance/derive';
1019
+
1020
+ import type {
1021
+ Custody,
1022
+ DeriveSpec,
1023
+ DerivedField,
1024
+ Scheme,
1025
+ } from '@forgezero/runtime/finance/derive';
274
1026
  ```
275
1027
 
1028
+ <a id="forgezero-runtime-finance-tax"></a>
276
1029
  ## @forgezero/runtime/finance/tax
277
1030
 
278
- Which jurisdiction may tax a sale, who accounts for it, and the three ways to be zero that report differently. Rates are data.
1031
+ Which jurisdiction may tax a sale, who accounts for it, and the three ways to be zero that report differently. Rates are data. This entry exposes 9 named value exports and 6 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
279
1032
 
280
1033
  ```text
281
- import * as api from '@forgezero/runtime/finance/tax';
1034
+ import {
1035
+ TREATMENTS,
1036
+ TaxError,
1037
+ applyTax,
1038
+ assertTaxRate,
1039
+ decideTax,
1040
+ describeTax,
1041
+ parseRate,
1042
+ percent,
1043
+ totalWithTax,
1044
+ } from '@forgezero/runtime/finance/tax';
1045
+
1046
+ import type {
1047
+ Customer,
1048
+ Supplier,
1049
+ TaxAmounts,
1050
+ TaxDecision,
1051
+ TaxRate,
1052
+ Treatment,
1053
+ } from '@forgezero/runtime/finance/tax';
282
1054
  ```
283
1055
 
1056
+ <a id="forgezero-runtime-finance-storage"></a>
284
1057
  ## @forgezero/runtime/finance/storage
285
1058
 
286
- Write an amount so it is both exact and sortable: an authoritative string, and a number that is only an index.
1059
+ Write an amount so it is both exact and sortable: an authoritative string, and a number that is only an index. This entry exposes 8 named value exports and 1 named type export. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
287
1060
 
288
1061
  ```text
289
- import * as api from '@forgezero/runtime/finance/storage';
1062
+ import {
1063
+ SORT_FIELD,
1064
+ fromStored,
1065
+ rangeBounds,
1066
+ sortExact,
1067
+ sortKey,
1068
+ storeAmount,
1069
+ toStored,
1070
+ withinRange,
1071
+ } from '@forgezero/runtime/finance/storage';
1072
+
1073
+ import type {
1074
+ StoredMoney,
1075
+ } from '@forgezero/runtime/finance/storage';
290
1076
  ```
291
1077
 
1078
+ <a id="forgezero-runtime-realtime"></a>
292
1079
  ## @forgezero/runtime/realtime
293
1080
 
294
- Provider-neutral realtime audience, shard, event and delivery contracts.
295
-
296
- ```text
297
- import * as api from '@forgezero/runtime/realtime';
298
- ```
299
-
1081
+ Provider-neutral realtime audience, shard, event and delivery contracts. This entry exposes 15 named value exports and 5 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
1082
+
1083
+ ```text
1084
+ import {
1085
+ REALTIME_MAX_BATCH_BYTES,
1086
+ REALTIME_MAX_EVENTS,
1087
+ REALTIME_MAX_EVENT_BYTES,
1088
+ REALTIME_MAX_SHARDS_PER_TOPIC,
1089
+ REALTIME_MAX_SOCKETS_PER_SHARD,
1090
+ canReceiveRealtimeAudience,
1091
+ issueRealtimeSubscriptionTicket,
1092
+ realtimeBatchBytes,
1093
+ realtimeHmac,
1094
+ realtimeShardKey,
1095
+ validateRealtimeAudience,
1096
+ validateRealtimeBatch,
1097
+ validateRealtimeSubscriptionTicket,
1098
+ verifyRealtimeHmac,
1099
+ verifyRealtimeSubscriptionToken,
1100
+ } from '@forgezero/runtime/realtime';
1101
+
1102
+ import type {
1103
+ RealtimeAudience,
1104
+ RealtimeBatch,
1105
+ RealtimeEvent,
1106
+ RealtimePrincipalKind,
1107
+ RealtimeSubscriptionTicket,
1108
+ } from '@forgezero/runtime/realtime';
1109
+ ```
1110
+
1111
+ <a id="forgezero-runtime-passkey-hybrid"></a>
300
1112
  ## @forgezero/runtime/passkey-hybrid
301
1113
 
302
- Versioned WebAuthn PRF plus ML-DSA companion proof construction and verification.
1114
+ Versioned WebAuthn PRF plus ML-DSA companion proof construction and verification. This entry exposes 8 named value exports and 4 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
303
1115
 
304
1116
  ```text
305
- import * as api from '@forgezero/runtime/passkey-hybrid';
1117
+ import {
1118
+ PASSKEY_HYBRID_SUITE,
1119
+ PASSKEY_HYBRID_VERSION,
1120
+ PASSKEY_ML_DSA_PUBLIC_KEY_BYTES,
1121
+ PASSKEY_ML_DSA_SIGNATURE_BYTES,
1122
+ PASSKEY_PRF_SALT,
1123
+ createPasskeyHybridProof,
1124
+ passkeyHybridMessage,
1125
+ verifyPasskeyHybridProof,
1126
+ } from '@forgezero/runtime/passkey-hybrid';
1127
+
1128
+ import type {
1129
+ PasskeyHybridBinding,
1130
+ PasskeyHybridProof,
1131
+ PasskeyHybridPurpose,
1132
+ PasskeyHybridRegistrationProof,
1133
+ } from '@forgezero/runtime/passkey-hybrid';
306
1134
  ```
307
1135
 
1136
+ <a id="forgezero-runtime-otpauth"></a>
308
1137
  ## @forgezero/runtime/otpauth
309
1138
 
310
- Parse and render otpauth URIs without binding enrolment to a UI framework.
1139
+ Parse and render otpauth URIs without binding enrolment to a UI framework. This entry exposes 4 named value exports and 1 named type export. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
311
1140
 
312
1141
  ```text
313
- import * as api from '@forgezero/runtime/otpauth';
1142
+ import {
1143
+ formatOtpAuth,
1144
+ fromManualSecret,
1145
+ newOtpAuth,
1146
+ parseOtpAuth,
1147
+ } from '@forgezero/runtime/otpauth';
1148
+
1149
+ import type {
1150
+ OtpAuth,
1151
+ } from '@forgezero/runtime/otpauth';
314
1152
  ```
315
1153
 
1154
+ <a id="forgezero-runtime-pipeline"></a>
316
1155
  ## @forgezero/runtime/pipeline
317
1156
 
318
- Typed ordered application-pipeline execution with explicit evidence.
1157
+ Typed ordered application-pipeline execution with explicit evidence. This entry exposes 6 named value exports and 3 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
319
1158
 
320
1159
  ```text
321
- import * as api from '@forgezero/runtime/pipeline';
1160
+ import {
1161
+ GIT_PROVIDERS,
1162
+ PipelineError,
1163
+ parsePush,
1164
+ shouldDeploy,
1165
+ verifyWebhook,
1166
+ webhookPath,
1167
+ } from '@forgezero/runtime/pipeline';
1168
+
1169
+ import type {
1170
+ DeployTrigger,
1171
+ GitProvider,
1172
+ PushEvent,
1173
+ } from '@forgezero/runtime/pipeline';
322
1174
  ```
323
1175
 
1176
+ <a id="forgezero-runtime-finance-chain-addresses"></a>
324
1177
  ## @forgezero/runtime/finance/chain-addresses
325
1178
 
326
- Chain-address derivation records and validation independent of a node provider.
1179
+ Chain-address derivation records and validation independent of a node provider. This entry exposes 10 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
327
1180
 
328
1181
  ```text
329
- import * as api from '@forgezero/runtime/finance/chain-addresses';
1182
+ import {
1183
+ AddressError,
1184
+ COUNTERFACTUAL_SCHEMES,
1185
+ assertDerivationMatches,
1186
+ create2Address,
1187
+ depositAddressBook,
1188
+ depositSaltFor,
1189
+ deriveDepositAddress,
1190
+ ownerOfAddress,
1191
+ toChecksumAddress,
1192
+ validateAddress,
1193
+ } from '@forgezero/runtime/finance/chain-addresses';
1194
+
1195
+ import type {
1196
+ AddressScheme,
1197
+ ChainDeployment,
1198
+ } from '@forgezero/runtime/finance/chain-addresses';
330
1199
  ```
331
1200
 
1201
+ <a id="forgezero-runtime-finance-chain-deposits"></a>
332
1202
  ## @forgezero/runtime/finance/chain-deposits
333
1203
 
334
- Provider-neutral deposit observation, confirmation and credit transitions.
1204
+ Provider-neutral deposit observation, confirmation and credit transitions. This entry exposes 8 named value exports and 5 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
335
1205
 
336
1206
  ```text
337
- import * as api from '@forgezero/runtime/finance/chain-deposits';
1207
+ import {
1208
+ DepositError,
1209
+ creditDeposit,
1210
+ cursorFrom,
1211
+ depositReference,
1212
+ describeScan,
1213
+ isConfirmed,
1214
+ rescanRange,
1215
+ scanOnce,
1216
+ } from '@forgezero/runtime/finance/chain-deposits';
1217
+
1218
+ import type {
1219
+ ChainReader,
1220
+ ChainTransfer,
1221
+ DepositCursor,
1222
+ ScanContext,
1223
+ ScanReport,
1224
+ } from '@forgezero/runtime/finance/chain-deposits';
338
1225
  ```
339
1226
 
1227
+ <a id="forgezero-runtime-finance-chain-withdrawals"></a>
340
1228
  ## @forgezero/runtime/finance/chain-withdrawals
341
1229
 
342
- Provider-neutral withdrawal approval, broadcast and finality transitions.
343
-
344
- ```text
345
- import * as api from '@forgezero/runtime/finance/chain-withdrawals';
346
- ```
347
-
1230
+ Provider-neutral withdrawal approval, broadcast and finality transitions. This entry exposes 14 named value exports and 5 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
1231
+
1232
+ ```text
1233
+ import {
1234
+ WITHDRAWAL_STATES,
1235
+ WithdrawalError,
1236
+ approveWithdrawal,
1237
+ broadcastKeyFor,
1238
+ canTransition,
1239
+ confirmWithdrawal,
1240
+ describeSweep,
1241
+ holdReference,
1242
+ markFailed,
1243
+ processOnce,
1244
+ refundFailed,
1245
+ rejectWithdrawal,
1246
+ requestWithdrawal,
1247
+ sweepForPayout,
1248
+ } from '@forgezero/runtime/finance/chain-withdrawals';
1249
+
1250
+ import type {
1251
+ Broadcaster,
1252
+ SweepCandidate,
1253
+ SweepPlan,
1254
+ Withdrawal,
1255
+ WithdrawalState,
1256
+ } from '@forgezero/runtime/finance/chain-withdrawals';
1257
+ ```
1258
+
1259
+ <a id="forgezero-runtime-finance-chain-reconcile"></a>
348
1260
  ## @forgezero/runtime/finance/chain-reconcile
349
1261
 
350
- Deterministic reconciliation between chain observations and durable transfer state.
1262
+ Deterministic reconciliation between chain observations and durable transfer state. This entry exposes 5 named value exports and 5 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
351
1263
 
352
1264
  ```text
353
- import * as api from '@forgezero/runtime/finance/chain-reconcile';
1265
+ import {
1266
+ DISCREPANCY_KINDS,
1267
+ ReconcileError,
1268
+ reconcileOnce,
1269
+ reconcileReport,
1270
+ shortfallUsd,
1271
+ } from '@forgezero/runtime/finance/chain-reconcile';
1272
+
1273
+ import type {
1274
+ Discrepancy,
1275
+ DiscrepancyKind,
1276
+ LedgerLiability,
1277
+ OnChainHolding,
1278
+ ReconcileReport,
1279
+ } from '@forgezero/runtime/finance/chain-reconcile';
354
1280
  ```
355
1281
 
1282
+ <a id="forgezero-runtime-finance-market"></a>
356
1283
  ## @forgezero/runtime/finance/market
357
1284
 
358
- Market order, fill and quote contracts independent of any exchange adapter.
1285
+ Market order, fill and quote contracts independent of any exchange adapter. This entry exposes 8 named value exports and 7 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
359
1286
 
360
1287
  ```text
361
- import * as api from '@forgezero/runtime/finance/market';
1288
+ import {
1289
+ MarketError,
1290
+ createFeed,
1291
+ disagreementOf,
1292
+ isStale,
1293
+ lastPrice,
1294
+ limitFor,
1295
+ stalenessOf,
1296
+ subscribe,
1297
+ } from '@forgezero/runtime/finance/market';
1298
+
1299
+ import type {
1300
+ Feed,
1301
+ FeedEvent,
1302
+ FeedOptions,
1303
+ PriceResult,
1304
+ Quote,
1305
+ StalenessPolicy,
1306
+ VenueSource,
1307
+ } from '@forgezero/runtime/finance/market';
362
1308
  ```
363
1309
 
1310
+ <a id="forgezero-runtime-custody-share"></a>
364
1311
  ## @forgezero/runtime/custody-share
365
1312
 
366
- Threshold-share parsing, validation and reconstruction.
1313
+ Threshold-share parsing, validation and reconstruction. This entry exposes 13 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
367
1314
 
368
1315
  ```text
369
- import * as api from '@forgezero/runtime/custody-share';
370
- ```
371
-
372
- ## @forgezero/runtime/custody-crypto
1316
+ import {
1317
+ PROBE_BYTES,
1318
+ factorWrapAad,
1319
+ joinProbeAndShare,
1320
+ openFactorEnvelope,
1321
+ openSealedToFactor,
1322
+ openShareWithPasskey,
1323
+ openShareWithPhrase,
1324
+ passkeyWrappingKey,
1325
+ phraseWrappingKey,
1326
+ sealShare,
1327
+ shareIndexOf,
1328
+ splitProbeAndShare,
1329
+ wrappingKeysFor,
1330
+ } from '@forgezero/runtime/custody-share';
373
1331
 
374
- Hybrid ML-KEM-768 plus X25519 custody-share sealing and opening.
375
-
376
- ```text
377
- import * as api from '@forgezero/runtime/custody-crypto';
1332
+ import type {
1333
+ SealedShare,
1334
+ WrappingKeys,
1335
+ } from '@forgezero/runtime/custody-share';
378
1336
  ```
379
1337
 
380
- ## Define and implement a typed query
1338
+ <a id="forgezero-runtime-custody-crypto"></a>
1339
+ ## @forgezero/runtime/custody-crypto
381
1340
 
382
- Decode untrusted input and validate output around injected storage/services rather than embedding a database query in the route adapter.
1341
+ Hybrid ML-KEM-768 plus X25519 custody-share sealing and opening. This entry exposes 6 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
383
1342
 
384
1343
  ```text
385
- import { defineQuery, implementQuery } from '@forgezero/runtime/query';
386
- import { T, type Static, typeboxQueryCodec } from '@forgezero/runtime/schema/typebox';
1344
+ import {
1345
+ deriveKey,
1346
+ openFromKey,
1347
+ openWithKey,
1348
+ sealToKey,
1349
+ sealWithKey,
1350
+ wrappingKeyPair,
1351
+ } from '@forgezero/runtime/custody-crypto';
387
1352
 
388
- const OrderKey = T.Object({ orderKey: T.String({ minLength: 1 }) });
389
- const Order = T.Object({ orderKey: T.String(), total: T.String() });
390
- type OrderRow = Static<typeof Order>;
391
- type Stores = { orders: { find(key: string): Promise<OrderRow | null> } };
392
- declare const stores: Stores;
393
-
394
- const findOrder = defineQuery({
395
- name: 'orders.find',
396
- input: typeboxQueryCodec(OrderKey),
397
- output: typeboxQueryCodec(T.Union([Order, T.Null()]))
398
- });
399
- export const runFindOrder = implementQuery(findOrder,
400
- (context: Stores, input) => context.orders.find(input.orderKey)
401
- );
402
-
403
- const order = await runFindOrder.execute(stores, { orderKey: 'ord_123' });
1353
+ import type {
1354
+ CipherBox,
1355
+ SealedToKey,
1356
+ } from '@forgezero/runtime/custody-crypto';
404
1357
  ```
405
1358
 
406
1359
  ## 1. Install, then import a subpath
@@ -410,8 +1363,12 @@ There is no root export, and that is deliberate. `import from "@forgezero/runtim
410
1363
  ```text
411
1364
  bun add @forgezero/runtime
412
1365
 
413
- import { parseAmount } from '@forgezero/runtime/finance/money';
414
- import { createScheduler } from '@forgezero/runtime/jobs';
1366
+ import {
1367
+ parseAmount,
1368
+ } from '@forgezero/runtime/finance/money';
1369
+ import {
1370
+ createScheduler,
1371
+ } from '@forgezero/runtime/jobs';
415
1372
 
416
1373
  // This throws. It is supposed to.
417
1374
  // import { anything } from '@forgezero/runtime';
@@ -472,8 +1429,15 @@ bun add @sinclair/typebox
472
1429
  An amount is minor units as a bigint with its asset attached, so two currencies cannot be added by accident and a rounding mode is always stated. A database needs a second thing the bigint cannot give it — an ORDER BY that works — so `finance/storage` writes both: the authoritative string, and a lossy double used for sorting and range filters only. One ETH is 10^18 minor units and a signed 64-bit column overflows at about nine ETH, which is why the exact value is never the sortable one.
473
1430
 
474
1431
  ```text
475
- import { parseAmount, mulRate, formatAmount } from '@forgezero/runtime/finance/money';
476
- import { toStored, rangeBounds } from '@forgezero/runtime/finance/storage';
1432
+ import {
1433
+ parseAmount,
1434
+ mulRate,
1435
+ formatAmount,
1436
+ } from '@forgezero/runtime/finance/money';
1437
+ import {
1438
+ toStored,
1439
+ rangeBounds,
1440
+ } from '@forgezero/runtime/finance/storage';
477
1441
 
478
1442
  const fee = mulRate(parseAmount('1250.00', 'USD'), '0.015', 'down');
479
1443
  formatAmount(fee); // '18.75' — never 18.749999999
@@ -502,7 +1466,11 @@ node_modules/@forgezero/runtime/contracts/src/
502
1466
  The lock and the cursor store are interfaces, so this runs against a database, Redis, or nothing at all in a test.
503
1467
 
504
1468
  ```text
505
- import { createScheduler, defineJob, cursorJob } from '@forgezero/runtime/jobs';
1469
+ import {
1470
+ createScheduler,
1471
+ defineJob,
1472
+ cursorJob,
1473
+ } from '@forgezero/runtime/jobs';
506
1474
  ```
507
1475
 
508
1476
  ## Never setInterval
@@ -572,7 +1540,10 @@ scheduler.status();
572
1540
  TypeBox is a peer dependency and optional. A project on Zod pulls none of it, because the interface is what the other packages depend on.
573
1541
 
574
1542
  ```text
575
- import { validate, describeForm } from '@forgezero/runtime/schema';
1543
+ import {
1544
+ validate,
1545
+ describeForm,
1546
+ } from '@forgezero/runtime/schema';
576
1547
 
577
1548
  // only if you validate with TypeBox
578
1549
  bun add @sinclair/typebox
@@ -583,7 +1554,10 @@ bun add @sinclair/typebox
583
1554
  Query strings are entirely strings, so values are converted before checking — otherwise ?port=587 fails a schema expecting a number on a perfectly well-formed request.
584
1555
 
585
1556
  ```text
586
- import { typebox, T } from '@forgezero/runtime/schema/typebox';
1557
+ import {
1558
+ typebox,
1559
+ T,
1560
+ } from '@forgezero/runtime/schema/typebox';
587
1561
 
588
1562
  const Config = T.Object(
589
1563
  { host: T.String(), port: T.Integer() },