@secondlayer/shared 7.7.0 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/src/archive/derived-stage-report.d.ts +99 -0
  2. package/dist/src/archive/derived-stage-report.js +64 -0
  3. package/dist/src/archive/derived-stage-report.js.map +10 -0
  4. package/dist/src/archive/disk-guard.d.ts +46 -0
  5. package/dist/src/archive/disk-guard.js +69 -0
  6. package/dist/src/archive/disk-guard.js.map +10 -0
  7. package/dist/src/archive/key-registry.d.ts +52 -0
  8. package/dist/src/archive/key-registry.js +168 -0
  9. package/dist/src/archive/key-registry.js.map +11 -0
  10. package/dist/src/archive/per-height-digest.d.ts +99 -0
  11. package/dist/src/archive/per-height-digest.js +194 -0
  12. package/dist/src/archive/per-height-digest.js.map +11 -0
  13. package/dist/src/archive/progress.d.ts +36 -0
  14. package/dist/src/archive/progress.js +75 -0
  15. package/dist/src/archive/progress.js.map +10 -0
  16. package/dist/src/archive/range-digest.d.ts +7 -0
  17. package/dist/src/archive/semantic-digest-builder.d.ts +1094 -0
  18. package/dist/src/archive/semantic-digest-builder.js +302 -0
  19. package/dist/src/archive/semantic-digest-builder.js.map +11 -0
  20. package/dist/src/archive/semantic-digest.d.ts +131 -0
  21. package/dist/src/archive/semantic-digest.js +143 -0
  22. package/dist/src/archive/semantic-digest.js.map +10 -0
  23. package/dist/src/archive/status.d.ts +92 -0
  24. package/dist/src/archive/status.js +106 -0
  25. package/dist/src/archive/status.js.map +10 -0
  26. package/dist/src/db/index.d.ts +11 -1
  27. package/dist/src/db/index.js +26 -1
  28. package/dist/src/db/index.js.map +6 -5
  29. package/dist/src/db/queries/chain-reorgs.d.ts +7 -0
  30. package/dist/src/db/queries/chain-reorgs.js +25 -1
  31. package/dist/src/db/queries/chain-reorgs.js.map +6 -5
  32. package/dist/src/db/queries/contracts.d.ts +7 -0
  33. package/dist/src/db/queries/instance.d.ts +1038 -0
  34. package/dist/src/db/queries/instance.js +92 -0
  35. package/dist/src/db/queries/instance.js.map +10 -0
  36. package/dist/src/db/queries/integrity.d.ts +7 -0
  37. package/dist/src/db/queries/subgraph-gaps.d.ts +7 -0
  38. package/dist/src/db/queries/subgraph-operations.d.ts +7 -0
  39. package/dist/src/db/queries/subgraphs.d.ts +10 -1
  40. package/dist/src/db/queries/subgraphs.js +47 -23
  41. package/dist/src/db/queries/subgraphs.js.map +7 -7
  42. package/dist/src/db/queries/subscriptions.d.ts +7 -0
  43. package/dist/src/db/queries/subscriptions.js +47 -31
  44. package/dist/src/db/queries/subscriptions.js.map +5 -5
  45. package/dist/src/db/schema.d.ts +8 -1
  46. package/dist/src/index.d.ts +11 -1
  47. package/dist/src/index.js +26 -1
  48. package/dist/src/index.js.map +6 -5
  49. package/dist/src/node/client.d.ts +11 -1
  50. package/dist/src/node/client.js +42 -4
  51. package/dist/src/node/client.js.map +3 -3
  52. package/dist/src/node/local-client.d.ts +7 -0
  53. package/dist/src/node/nakamoto.d.ts +22 -7
  54. package/dist/src/node/nakamoto.js +46 -5
  55. package/dist/src/node/nakamoto.js.map +3 -3
  56. package/migrations/0115_instances.ts +33 -0
  57. package/package.json +38 -2
@@ -0,0 +1,1094 @@
1
+ import { ColumnType, Generated } from "kysely";
2
+ interface BlocksTable {
3
+ height: number;
4
+ hash: string;
5
+ parent_hash: string;
6
+ burn_block_height: number;
7
+ burn_block_hash: ColumnType<string | null, string | null | undefined, string | null>;
8
+ /** Nakamoto StacksBlockId. Null on rows ingested before it was persisted. */
9
+ index_block_hash: ColumnType<string | null, string | null | undefined, string | null>;
10
+ timestamp: number;
11
+ canonical: Generated<boolean>;
12
+ created_at: Generated<Date>;
13
+ }
14
+ interface TransactionsTable {
15
+ tx_id: string;
16
+ block_height: number;
17
+ tx_index: Generated<number>;
18
+ type: string;
19
+ sender: string;
20
+ status: string;
21
+ contract_id: string | null;
22
+ function_name: string | null;
23
+ function_args: Generated<unknown | null>;
24
+ raw_result: Generated<string | null>;
25
+ raw_tx: string;
26
+ created_at: Generated<Date>;
27
+ }
28
+ interface EventsTable {
29
+ id: Generated<string>;
30
+ tx_id: string;
31
+ block_height: number;
32
+ event_index: number;
33
+ type: string;
34
+ data: unknown;
35
+ created_at: Generated<Date>;
36
+ }
37
+ interface TransactionsArchiveTable {
38
+ archive_id: Generated<string>;
39
+ tx_id: string;
40
+ block_height: number;
41
+ tx_index: number;
42
+ type: string;
43
+ sender: string;
44
+ status: string;
45
+ contract_id: string | null;
46
+ function_name: string | null;
47
+ function_args: unknown | null;
48
+ raw_result: string | null;
49
+ raw_tx: string;
50
+ created_at: Date;
51
+ orphaned_block_hash: string | null;
52
+ archived_at: Generated<Date>;
53
+ }
54
+ interface EventsArchiveTable {
55
+ archive_id: Generated<string>;
56
+ id: string;
57
+ tx_id: string;
58
+ block_height: number;
59
+ event_index: number;
60
+ type: string;
61
+ data: unknown;
62
+ created_at: Date;
63
+ orphaned_block_hash: string | null;
64
+ archived_at: Generated<Date>;
65
+ }
66
+ interface DeadLetterEventsTable {
67
+ id: Generated<string>;
68
+ block_height: number;
69
+ tx_id: string;
70
+ event_index: number;
71
+ event_type: string;
72
+ data: unknown;
73
+ reason: string;
74
+ created_at: Generated<Date>;
75
+ }
76
+ interface MempoolTransactionsTable {
77
+ seq: Generated<string>;
78
+ tx_id: string;
79
+ raw_tx: string;
80
+ type: string;
81
+ sender: string;
82
+ contract_id: string | null;
83
+ function_name: string | null;
84
+ function_args: unknown | null;
85
+ received_at: Generated<Date>;
86
+ }
87
+ interface IndexProgressTable {
88
+ network: string;
89
+ last_indexed_block: Generated<number>;
90
+ last_contiguous_block: Generated<number>;
91
+ highest_seen_block: Generated<number>;
92
+ updated_at: Generated<Date>;
93
+ }
94
+ interface SubgraphsTable {
95
+ id: Generated<string>;
96
+ name: string;
97
+ version: Generated<string>;
98
+ status: Generated<string>;
99
+ definition: Record<string, unknown>;
100
+ schema_hash: string;
101
+ handler_path: string;
102
+ schema_name: string | null;
103
+ start_block: Generated<number>;
104
+ last_processed_block: Generated<number>;
105
+ reindex_from_block: number | null;
106
+ reindex_to_block: number | null;
107
+ last_error: string | null;
108
+ last_error_at: Date | null;
109
+ total_processed: Generated<number>;
110
+ total_errors: Generated<number>;
111
+ account_id: string;
112
+ handler_code: string | null;
113
+ source_code: string | null;
114
+ project_id: string | null;
115
+ visibility: Generated<string>;
116
+ /** Paid (wallet-ghost) deploys expire unless renewed or claimed; NULL = no expiry. */
117
+ expires_at: Date | null;
118
+ /** (event type, contract) probe pairs persisted at deploy for weight classification. */
119
+ sparse_probe_targets: unknown | null;
120
+ database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
121
+ sandbox_workers: Generated<boolean>;
122
+ created_at: Generated<Date>;
123
+ updated_at: Generated<Date>;
124
+ }
125
+ interface ContractsTable {
126
+ contract_id: string;
127
+ deployer: string;
128
+ block_height: number;
129
+ canonical: Generated<boolean>;
130
+ abi: unknown | null;
131
+ declared_traits: Generated<string[]>;
132
+ inferred_standards: Generated<string[]>;
133
+ abi_status: Generated<string>;
134
+ abi_fetched_at: Date | null;
135
+ created_at: Generated<Date>;
136
+ }
137
+ interface SubgraphGapsTable {
138
+ id: Generated<string>;
139
+ subgraph_id: string;
140
+ subgraph_name: string;
141
+ gap_start: number;
142
+ gap_end: number;
143
+ reason: string;
144
+ detected_at: Generated<Date>;
145
+ resolved_at: Date | null;
146
+ }
147
+ type SubgraphOperationKind = "reindex" | "backfill";
148
+ type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
149
+ interface SubgraphOperationsTable {
150
+ id: Generated<string>;
151
+ subgraph_id: string;
152
+ subgraph_name: string;
153
+ account_id: string | null;
154
+ kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
155
+ status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
156
+ from_block: number | null;
157
+ to_block: number | null;
158
+ cancel_requested: Generated<boolean>;
159
+ locked_by: string | null;
160
+ locked_until: Date | null;
161
+ started_at: Date | null;
162
+ finished_at: Date | null;
163
+ processed_blocks: number | null;
164
+ error: string | null;
165
+ created_at: Generated<Date>;
166
+ updated_at: Generated<Date>;
167
+ /** 'light' (contract-scoped sparse) | 'heavy' (broad). Claim budgets heavy. */
168
+ weight: Generated<string>;
169
+ /** Candidate-event denominator computed at enqueue (sparse ops only). */
170
+ estimated_events: string | number | bigint | null;
171
+ /** Events processed so far — written by the progress flush. */
172
+ processed_events: string | number | bigint | null;
173
+ /** Backfill ops' own crash checkpoint — advanced conditionally in-tx with
174
+ * each written block; replays skip at/below it. NULL for reindex ops
175
+ * (those checkpoint on subgraphs.last_processed_block). */
176
+ cursor_block: string | number | bigint | null;
177
+ }
178
+ interface ApiKeysTable {
179
+ id: Generated<string>;
180
+ key_hash: string;
181
+ key_prefix: string;
182
+ name: string | null;
183
+ status: Generated<string>;
184
+ rate_limit: Generated<number>;
185
+ ip_address: string;
186
+ account_id: string;
187
+ product: Generated<"account" | "streams" | "index">;
188
+ tier: "free" | "build" | "scale" | "enterprise" | null;
189
+ last_used_at: Date | null;
190
+ revoked_at: Date | null;
191
+ created_at: Generated<Date>;
192
+ }
193
+ /** Singleton self-host / publisher identity. Network is immutable. */
194
+ interface InstancesTable {
195
+ id: Generated<string>;
196
+ network: string;
197
+ created_at: Generated<Date>;
198
+ }
199
+ interface AccountsTable {
200
+ id: Generated<string>;
201
+ /** NULL for unclaimed ghost accounts (anonymous self-serve keys). */
202
+ email: string | null;
203
+ /** True for anonymous self-serve accounts until claimed via magic link. */
204
+ ghost: Generated<boolean>;
205
+ /** Stacks principal owning a wallet-ghost account (x402-paid deploys). */
206
+ wallet_principal: string | null;
207
+ plan: Generated<string>;
208
+ display_name: string | null;
209
+ bio: string | null;
210
+ avatar_url: string | null;
211
+ slug: string | null;
212
+ stripe_customer_id: string | null;
213
+ /** Opt-out toggle for the subgraph reindex-completion email. Defaults true. */
214
+ notify_reindex_complete: Generated<boolean>;
215
+ created_at: Generated<Date>;
216
+ }
217
+ interface SessionsTable {
218
+ id: Generated<string>;
219
+ token_hash: string;
220
+ token_prefix: string;
221
+ account_id: string;
222
+ ip_address: string;
223
+ expires_at: Generated<Date>;
224
+ revoked_at: Date | null;
225
+ last_used_at: Date | null;
226
+ created_at: Generated<Date>;
227
+ }
228
+ /**
229
+ * One-time claim tokens for ghost accounts. The raw token only ever appears in
230
+ * the claim URL returned at mint time; we store its sha256. A used token marks
231
+ * the account as claimed (or merged into an existing account).
232
+ */
233
+ interface ClaimTokensTable {
234
+ id: Generated<string>;
235
+ account_id: string;
236
+ token_hash: string;
237
+ created_at: Generated<Date>;
238
+ expires_at: Date;
239
+ used_at: Date | null;
240
+ }
241
+ interface MagicLinksTable {
242
+ id: Generated<string>;
243
+ email: string;
244
+ token: string;
245
+ code: string | null;
246
+ expires_at: Date;
247
+ used_at: Date | null;
248
+ failed_attempts: Generated<number>;
249
+ created_at: Generated<Date>;
250
+ }
251
+ interface UsageDailyTable {
252
+ account_id: string;
253
+ tenant_id: string | null;
254
+ date: string;
255
+ api_requests: Generated<number>;
256
+ deliveries: Generated<number>;
257
+ streams_events_returned: Generated<number>;
258
+ index_decoded_events_returned: Generated<number>;
259
+ }
260
+ interface UsageSnapshotsTable {
261
+ id: Generated<string>;
262
+ account_id: string;
263
+ measured_at: Generated<Date>;
264
+ storage_bytes: Generated<number>;
265
+ }
266
+ interface AccountInsightsTable {
267
+ id: Generated<string>;
268
+ account_id: string;
269
+ category: string;
270
+ insight_type: string;
271
+ resource_id: string | null;
272
+ severity: string;
273
+ title: string;
274
+ body: string;
275
+ data: unknown;
276
+ dismissed_at: Date | null;
277
+ expires_at: Date | null;
278
+ created_at: Generated<Date>;
279
+ }
280
+ interface AccountAgentRunsTable {
281
+ id: Generated<string>;
282
+ account_id: string;
283
+ started_at: Generated<Date>;
284
+ completed_at: Date | null;
285
+ status: Generated<string>;
286
+ input_tokens: Generated<number>;
287
+ output_tokens: Generated<number>;
288
+ cost_usd: Generated<number>;
289
+ insights_created: Generated<number>;
290
+ error: string | null;
291
+ }
292
+ interface SubgraphProcessingStatsTable {
293
+ id: Generated<string>;
294
+ subgraph_name: string;
295
+ api_key_id: string | null;
296
+ bucket_start: Date | null;
297
+ bucket_end: Date | null;
298
+ blocks_processed: number | null;
299
+ total_time_ms: number | null;
300
+ handler_time_ms: number | null;
301
+ flush_time_ms: number | null;
302
+ max_block_time_ms: number | null;
303
+ max_handler_time_ms: number | null;
304
+ avg_ops_per_block: number | null;
305
+ is_catchup: Generated<boolean>;
306
+ created_at: Generated<Date>;
307
+ }
308
+ interface SubgraphTableSnapshotsTable {
309
+ id: Generated<string>;
310
+ subgraph_name: string;
311
+ api_key_id: string | null;
312
+ table_name: string;
313
+ row_count: number | null;
314
+ created_at: Generated<Date>;
315
+ }
316
+ interface SubgraphHealthSnapshotsTable {
317
+ id: Generated<string>;
318
+ subgraph_id: string;
319
+ total_processed: number;
320
+ total_errors: number;
321
+ last_processed_block: number | null;
322
+ captured_at: Generated<Date>;
323
+ }
324
+ interface SubgraphUsageDailyTable {
325
+ subgraph_id: string;
326
+ date: string;
327
+ query_count: Generated<number>;
328
+ }
329
+ interface ProjectsTable {
330
+ id: Generated<string>;
331
+ name: string;
332
+ slug: string;
333
+ account_id: string;
334
+ settings: Generated<Record<string, unknown>>;
335
+ network: Generated<string>;
336
+ node_rpc: string | null;
337
+ created_at: Generated<Date>;
338
+ updated_at: Generated<Date>;
339
+ }
340
+ interface TeamMembersTable {
341
+ id: Generated<string>;
342
+ project_id: string;
343
+ account_id: string;
344
+ role: Generated<string>;
345
+ invited_by: string | null;
346
+ created_at: Generated<Date>;
347
+ }
348
+ interface TeamInvitationsTable {
349
+ id: Generated<string>;
350
+ project_id: string;
351
+ email: string;
352
+ role: Generated<string>;
353
+ token: string;
354
+ invited_by: string | null;
355
+ expires_at: Date;
356
+ accepted_at: Date | null;
357
+ created_at: Generated<Date>;
358
+ }
359
+ interface ProcessedStripeEventsTable {
360
+ event_id: string;
361
+ event_type: string;
362
+ processed_at: Generated<Date>;
363
+ }
364
+ interface DecodedEventsTable {
365
+ cursor: string;
366
+ block_height: number;
367
+ tx_id: string;
368
+ tx_index: number;
369
+ event_index: number;
370
+ event_type: string;
371
+ microblock_hash: string | null;
372
+ canonical: Generated<boolean>;
373
+ contract_id: string | null;
374
+ sender: string | null;
375
+ recipient: string | null;
376
+ amount: string | null;
377
+ asset_identifier: string | null;
378
+ value: string | null;
379
+ memo: string | null;
380
+ /** Decoded payload for event types that don't fit the flat columns
381
+ * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
382
+ payload: unknown | null;
383
+ source_cursor: string;
384
+ created_at: Generated<Date>;
385
+ }
386
+ interface DecoderCheckpointsTable {
387
+ decoder_name: string;
388
+ last_cursor: string | null;
389
+ updated_at: Generated<Date>;
390
+ }
391
+ interface ChainReorgsTable {
392
+ id: Generated<string>;
393
+ detected_at: Generated<Date>;
394
+ fork_point_height: number;
395
+ old_index_block_hash: string | null;
396
+ new_index_block_hash: string | null;
397
+ orphaned_from_height: number;
398
+ orphaned_from_event_index: number;
399
+ orphaned_to_height: number;
400
+ orphaned_to_event_index: number;
401
+ new_canonical_height: number;
402
+ new_canonical_event_index: number;
403
+ created_at: Generated<Date>;
404
+ }
405
+ type Pox4FunctionName = "stack-stx" | "delegate-stx" | "stack-extend" | "stack-increase" | "revoke-delegate-stx" | "delegate-stack-stx" | "delegate-stack-extend" | "delegate-stack-increase" | "stack-aggregation-commit" | "stack-aggregation-commit-indexed" | "stack-aggregation-increase" | "set-signer-key-authorization";
406
+ interface Pox4CallsTable {
407
+ cursor: string;
408
+ block_height: number;
409
+ block_time: Date;
410
+ burn_block_height: number;
411
+ tx_id: string;
412
+ tx_index: number;
413
+ function_name: Pox4FunctionName;
414
+ caller: string;
415
+ stacker: string | null;
416
+ delegate_to: string | null;
417
+ amount_ustx: string | null;
418
+ lock_period: number | null;
419
+ pox_addr_version: number | null;
420
+ pox_addr_hashbytes: string | null;
421
+ pox_addr_btc: string | null;
422
+ start_cycle: number | null;
423
+ end_cycle: number | null;
424
+ signer_key: string | null;
425
+ signer_signature: string | null;
426
+ auth_id: string | null;
427
+ max_amount: string | null;
428
+ reward_cycle: number | null;
429
+ aggregated_amount_ustx: string | null;
430
+ aggregated_signer_index: number | null;
431
+ auth_period: number | null;
432
+ auth_topic: string | null;
433
+ auth_allowed: boolean | null;
434
+ result_ok: boolean;
435
+ result_raw: string;
436
+ canonical: Generated<boolean>;
437
+ source_cursor: string;
438
+ created_at: Generated<Date>;
439
+ }
440
+ interface Pox4CyclesDailyTable {
441
+ date: string;
442
+ reward_cycle: number;
443
+ total_stacked_ustx: Generated<string>;
444
+ solo_stackers: Generated<number>;
445
+ delegated_principals: Generated<number>;
446
+ unique_pools: Generated<number>;
447
+ unique_signers: Generated<number>;
448
+ calls_today: Generated<number>;
449
+ updated_at: Generated<Date>;
450
+ }
451
+ interface Pox4SignersDailyTable {
452
+ date: string;
453
+ reward_cycle: number;
454
+ signer_key: string;
455
+ weight_ustx: Generated<string>;
456
+ stacker_count: Generated<number>;
457
+ aggregation_calls: Generated<number>;
458
+ updated_at: Generated<Date>;
459
+ }
460
+ type Pox5EventTopic = "set-bond-admin" | "set-pause-admin" | "pause-rewards" | "setup-bond" | "add-to-allowlist" | "register-for-bond" | "update-bond-registration" | "register-signer" | "stake" | "stake-update" | "announce-l1-early-exit" | "unstake-sbtc" | "unstake" | "calculate-rewards" | "bond-distribution" | "claim-rewards" | "claim-staker-rewards-for-signer" | "grant-signer-key" | "revoke-signer-grant";
461
+ interface Pox5EventsTable {
462
+ cursor: string;
463
+ block_height: number;
464
+ block_time: Date;
465
+ tx_id: string;
466
+ tx_index: number;
467
+ event_index: number;
468
+ topic: Pox5EventTopic;
469
+ staker: string | null;
470
+ signer: string | null;
471
+ signer_manager: string | null;
472
+ bond_index: number | null;
473
+ amount_ustx: string | null;
474
+ amount_sats: string | null;
475
+ reward_cycle: number | null;
476
+ first_reward_cycle: number | null;
477
+ unlock_cycle: number | null;
478
+ unlock_burn_height: number | null;
479
+ is_l1_lock: boolean | null;
480
+ signer_key: string | null;
481
+ data: unknown;
482
+ canonical: Generated<boolean>;
483
+ source_cursor: string;
484
+ created_at: Generated<Date>;
485
+ }
486
+ interface BurnBlockRewardsTable {
487
+ cursor: string;
488
+ burn_block_height: number;
489
+ burn_block_hash: string;
490
+ reward_index: number;
491
+ recipient_btc: string;
492
+ amount_sats: string;
493
+ burn_amount: Generated<string>;
494
+ created_at: Generated<Date>;
495
+ }
496
+ interface BurnBlockRewardSlotsTable {
497
+ cursor: string;
498
+ burn_block_height: number;
499
+ burn_block_hash: string;
500
+ slot_index: number;
501
+ holder_btc: string;
502
+ created_at: Generated<Date>;
503
+ }
504
+ type SbtcEventTopic = "completed-deposit" | "withdrawal-create" | "withdrawal-accept" | "withdrawal-reject" | "key-rotation" | "update-protocol-contract";
505
+ interface SbtcEventsTable {
506
+ cursor: string;
507
+ block_height: number;
508
+ block_time: Date;
509
+ tx_id: string;
510
+ tx_index: number;
511
+ event_index: number;
512
+ topic: SbtcEventTopic;
513
+ request_id: number | null;
514
+ amount: string | null;
515
+ sender: string | null;
516
+ recipient_btc_version: number | null;
517
+ recipient_btc_hashbytes: string | null;
518
+ bitcoin_txid: string | null;
519
+ output_index: number | null;
520
+ sweep_txid: string | null;
521
+ burn_hash: string | null;
522
+ burn_height: number | null;
523
+ signer_bitmap: string | null;
524
+ max_fee: string | null;
525
+ fee: string | null;
526
+ block_height_at_request: number | null;
527
+ governance_contract_type: number | null;
528
+ governance_new_contract: string | null;
529
+ signer_aggregate_pubkey: string | null;
530
+ signer_threshold: number | null;
531
+ signer_address: string | null;
532
+ signer_keys_count: number | null;
533
+ canonical: Generated<boolean>;
534
+ source_cursor: string;
535
+ created_at: Generated<Date>;
536
+ }
537
+ type SbtcTokenEventType = "transfer" | "mint" | "burn";
538
+ interface SbtcTokenEventsTable {
539
+ cursor: string;
540
+ block_height: number;
541
+ block_time: Date;
542
+ tx_id: string;
543
+ tx_index: number;
544
+ event_index: number;
545
+ event_type: SbtcTokenEventType;
546
+ sender: string | null;
547
+ recipient: string | null;
548
+ amount: string;
549
+ memo: string | null;
550
+ canonical: Generated<boolean>;
551
+ source_cursor: string;
552
+ created_at: Generated<Date>;
553
+ }
554
+ /**
555
+ * BTC L1 settlement status for sBTC withdrawal sweeps. Filled by the indexer's
556
+ * settlement-confirmer worker, which polls our own bitcoind for confirmations of
557
+ * each `withdrawal-accept`'s `sweep_txid` and surfaces real settlement on the
558
+ * withdrawal lifecycle (the API's `settlement.{btc_confirmations,
559
+ * settlement_confirmed}` placeholder). Keyed on `sweep_txid` (not `request_id`):
560
+ * a request can produce more than one sweep over its life (RBF/rebroadcast), so
561
+ * each broadcast keeps its own confirmation history.
562
+ */
563
+ interface SbtcSettlementsTable {
564
+ sweep_txid: string;
565
+ request_id: number;
566
+ btc_confirmations: Generated<number>;
567
+ settlement_confirmed: Generated<boolean>;
568
+ /** Confirming Bitcoin block — null while the sweep is unconfirmed. */
569
+ block_hash: string | null;
570
+ block_height: number | null;
571
+ first_seen_at: Generated<Date>;
572
+ last_checked_at: Generated<Date>;
573
+ /** Set once, when `settlement_confirmed` first flips true. */
574
+ confirmed_at: Date | null;
575
+ updated_at: Generated<Date>;
576
+ }
577
+ interface SbtcSupplySnapshotsTable {
578
+ date: string;
579
+ total_supply: Generated<string>;
580
+ mints_today: Generated<string>;
581
+ burns_today: Generated<string>;
582
+ deposit_count: Generated<number>;
583
+ withdrawal_create_count: Generated<number>;
584
+ withdrawal_accept_count: Generated<number>;
585
+ withdrawal_reject_count: Generated<number>;
586
+ updated_at: Generated<Date>;
587
+ }
588
+ type BnsNameEventTopic = "new-name" | "transfer-name" | "renew-name" | "burn-name" | "new-airdrop";
589
+ interface BnsNameEventsTable {
590
+ cursor: string;
591
+ block_height: number;
592
+ block_time: Date;
593
+ tx_id: string;
594
+ tx_index: number;
595
+ event_index: number;
596
+ topic: BnsNameEventTopic;
597
+ namespace: string;
598
+ name: string;
599
+ fqn: string;
600
+ owner: string | null;
601
+ bns_id: string;
602
+ registered_at: number | null;
603
+ imported_at: number | null;
604
+ renewal_height: number | null;
605
+ stx_burn: string | null;
606
+ preordered_by: string | null;
607
+ hashed_salted_fqn_preorder: string | null;
608
+ canonical: Generated<boolean>;
609
+ source_cursor: string;
610
+ created_at: Generated<Date>;
611
+ }
612
+ type BnsNamespaceEventStatus = "launch" | "transfer-manager" | "freeze-manager" | "update-price-manager" | "freeze-price-manager" | "turn-off-manager-transfers";
613
+ interface BnsNamespaceEventsTable {
614
+ cursor: string;
615
+ block_height: number;
616
+ block_time: Date;
617
+ tx_id: string;
618
+ tx_index: number;
619
+ event_index: number;
620
+ status: BnsNamespaceEventStatus;
621
+ namespace: string;
622
+ manager: string | null;
623
+ manager_frozen: boolean | null;
624
+ manager_transfers_disabled: boolean | null;
625
+ price_function: string | null;
626
+ price_frozen: boolean | null;
627
+ lifetime: number | null;
628
+ revealed_at: number | null;
629
+ launched_at: number | null;
630
+ canonical: Generated<boolean>;
631
+ source_cursor: string;
632
+ created_at: Generated<Date>;
633
+ }
634
+ type BnsMarketplaceAction = "list-in-ustx" | "unlist-in-ustx" | "buy-in-ustx";
635
+ interface BnsMarketplaceEventsTable {
636
+ cursor: string;
637
+ block_height: number;
638
+ block_time: Date;
639
+ tx_id: string;
640
+ tx_index: number;
641
+ event_index: number;
642
+ action: BnsMarketplaceAction;
643
+ bns_id: string;
644
+ price_ustx: string | null;
645
+ commission: string | null;
646
+ canonical: Generated<boolean>;
647
+ source_cursor: string;
648
+ created_at: Generated<Date>;
649
+ }
650
+ interface BnsNamesTable {
651
+ fqn: string;
652
+ namespace: string;
653
+ name: string;
654
+ owner: string;
655
+ bns_id: string;
656
+ registered_at: number | null;
657
+ renewal_height: number | null;
658
+ last_event_cursor: string;
659
+ last_event_at: Date;
660
+ updated_at: Generated<Date>;
661
+ }
662
+ interface BnsNamespacesTable {
663
+ namespace: string;
664
+ manager: string | null;
665
+ manager_frozen: Generated<boolean>;
666
+ price_frozen: Generated<boolean>;
667
+ lifetime: number | null;
668
+ launched_at: number | null;
669
+ last_event_cursor: string;
670
+ last_event_at: Date;
671
+ name_count: Generated<number>;
672
+ updated_at: Generated<Date>;
673
+ }
674
+ /**
675
+ * Memoized `ctx.client.readOnly()` results. Keyed on `index_block_hash` so a
676
+ * reorg-replaced block never inherits the orphaned fork's answer; a NULL
677
+ * `index_block_hash` marks a caller-declared contract-constant value, cached
678
+ * once per contract+args instead of once per block.
679
+ */
680
+ interface ChainReadCacheTable {
681
+ id: Generated<number>;
682
+ contract_id: string;
683
+ function_name: string;
684
+ args_hash: string;
685
+ index_block_hash: string | null;
686
+ block_height: ColumnType<number | null, number | null | undefined, number | null>;
687
+ result_hex: string;
688
+ created_at: Generated<Date>;
689
+ }
690
+ /**
691
+ * A block that arrived for a height we already hold, staged until a later
692
+ * block's `parent_hash` says which of the two the chain kept. See migration
693
+ * 0112 — adopting on first sight picked the losing fork twice.
694
+ */
695
+ interface PendingForkBlocksTable {
696
+ height: number;
697
+ block_hash: string;
698
+ parent_hash: string;
699
+ /** The canonical hash we held at this height when the contender arrived. */
700
+ incumbent_hash: string;
701
+ /** The raw observer payload, replayed verbatim if this fork wins. */
702
+ payload: ColumnType<unknown, unknown, unknown>;
703
+ received_at: Generated<Date>;
704
+ }
705
+ type ObserverJournalStatus = "received" | "processed" | "failed";
706
+ /**
707
+ * Exact observer callback receipt. `raw_body` is immutable evidence; the
708
+ * processing columns are updated only after the current derived-state write
709
+ * succeeds or fails.
710
+ */
711
+ interface ObserverJournalTable {
712
+ sequence: Generated<string>;
713
+ network: string;
714
+ path: string;
715
+ source: string | null;
716
+ received_at: Generated<Date>;
717
+ raw_body: ColumnType<Buffer, Buffer, Buffer>;
718
+ raw_body_sha256: string;
719
+ status: ColumnType<ObserverJournalStatus, ObserverJournalStatus | undefined, ObserverJournalStatus>;
720
+ semantic_sha256: string | null;
721
+ block_height: number | null;
722
+ block_hash: string | null;
723
+ burn_block_height: number | null;
724
+ burn_block_hash: string | null;
725
+ result: unknown | null;
726
+ error: string | null;
727
+ processed_at: Date | null;
728
+ }
729
+ interface Database {
730
+ blocks: BlocksTable;
731
+ transactions: TransactionsTable;
732
+ events: EventsTable;
733
+ transactions_archive: TransactionsArchiveTable;
734
+ events_archive: EventsArchiveTable;
735
+ dead_letter_events: DeadLetterEventsTable;
736
+ mempool_transactions: MempoolTransactionsTable;
737
+ index_progress: IndexProgressTable;
738
+ contracts: ContractsTable;
739
+ subgraphs: SubgraphsTable;
740
+ api_keys: ApiKeysTable;
741
+ instances: InstancesTable;
742
+ accounts: AccountsTable;
743
+ sessions: SessionsTable;
744
+ magic_links: MagicLinksTable;
745
+ claim_tokens: ClaimTokensTable;
746
+ usage_daily: UsageDailyTable;
747
+ usage_snapshots: UsageSnapshotsTable;
748
+ account_insights: AccountInsightsTable;
749
+ account_agent_runs: AccountAgentRunsTable;
750
+ subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
751
+ subgraph_processing_stats: SubgraphProcessingStatsTable;
752
+ subgraph_table_snapshots: SubgraphTableSnapshotsTable;
753
+ subgraph_gaps: SubgraphGapsTable;
754
+ subgraph_operations: SubgraphOperationsTable;
755
+ subgraph_usage_daily: SubgraphUsageDailyTable;
756
+ projects: ProjectsTable;
757
+ team_members: TeamMembersTable;
758
+ team_invitations: TeamInvitationsTable;
759
+ processed_stripe_events: ProcessedStripeEventsTable;
760
+ tenants: TenantsTable;
761
+ tenant_usage_monthly: TenantUsageMonthlyTable;
762
+ tenant_compute_addons: TenantComputeAddonsTable;
763
+ account_spend_caps: AccountSpendCapsTable;
764
+ account_credits: AccountCreditsTable;
765
+ provisioning_audit_log: ProvisioningAuditLogTable;
766
+ subscriptions: SubscriptionsTable;
767
+ subscription_outbox: SubscriptionOutboxTable;
768
+ subscription_deliveries: SubscriptionDeliveriesTable;
769
+ trigger_evaluator_state: TriggerEvaluatorStateTable;
770
+ decoded_events: DecodedEventsTable;
771
+ decoder_checkpoints: DecoderCheckpointsTable;
772
+ chain_reorgs: ChainReorgsTable;
773
+ pox4_calls: Pox4CallsTable;
774
+ pox4_cycles_daily: Pox4CyclesDailyTable;
775
+ pox4_signers_daily: Pox4SignersDailyTable;
776
+ pox5_events: Pox5EventsTable;
777
+ burn_block_rewards: BurnBlockRewardsTable;
778
+ burn_block_reward_slots: BurnBlockRewardSlotsTable;
779
+ sbtc_events: SbtcEventsTable;
780
+ sbtc_token_events: SbtcTokenEventsTable;
781
+ sbtc_settlements: SbtcSettlementsTable;
782
+ sbtc_supply_snapshots: SbtcSupplySnapshotsTable;
783
+ bns_name_events: BnsNameEventsTable;
784
+ bns_namespace_events: BnsNamespaceEventsTable;
785
+ bns_marketplace_events: BnsMarketplaceEventsTable;
786
+ bns_names: BnsNamesTable;
787
+ bns_namespaces: BnsNamespacesTable;
788
+ service_heartbeats: ServiceHeartbeatsTable;
789
+ x402_payments: X402PaymentsTable;
790
+ x402_balances: X402BalancesTable;
791
+ chain_read_cache: ChainReadCacheTable;
792
+ pending_fork_blocks: PendingForkBlocksTable;
793
+ observer_journal: ObserverJournalTable;
794
+ }
795
+ /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
796
+ interface X402BalancesTable {
797
+ principal: string;
798
+ balance_usd_micros: Generated<string | number | bigint>;
799
+ /** Month bucket ("YYYY-MM") the spend counter applies to. */
800
+ spent_month: string | null;
801
+ spent_month_usd_micros: Generated<string | number | bigint>;
802
+ updated_at: Generated<Date>;
803
+ }
804
+ interface ServiceHeartbeatsTable {
805
+ name: string;
806
+ updated_at: Generated<Date>;
807
+ }
808
+ /** x402 pay-per-request ledger (control plane). One row per settled payment,
809
+ * keyed by challenge nonce + settled txid. `state` tracks confirmed-tier
810
+ * settlement and post-serve reorg reversal. */
811
+ interface X402PaymentsTable {
812
+ id: Generated<string>;
813
+ nonce: string;
814
+ txid: string;
815
+ asset: string;
816
+ amount: string;
817
+ payer: string;
818
+ surface: string;
819
+ state: Generated<"pending" | "confirmed" | "reverted">;
820
+ created_at: Generated<Date>;
821
+ updated_at: Generated<Date>;
822
+ /** "payment" = per-call settle; "deposit" = prepaid balance top-up. */
823
+ kind: Generated<string>;
824
+ /** Linked claimed account once the paying wallet is attached (continuity). */
825
+ account_id: string | null;
826
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
827
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
828
+ credit_usd_micros: string | null;
829
+ /** Idempotency key: stamped exactly once when this row's credit is applied.
830
+ * NULL means never credited (or not a credit-bearing row). Pre-migration
831
+ * non-pending deposit rows are backfilled to a non-null sentinel so the
832
+ * reconciler's heal path can never double-credit them. */
833
+ credited_at: Generated<Date> | null;
834
+ }
835
+ type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
836
+ interface TenantsTable {
837
+ id: Generated<string>;
838
+ account_id: string;
839
+ slug: string;
840
+ status: ColumnType<TenantStatus, TenantStatus | undefined, TenantStatus>;
841
+ plan: string;
842
+ cpus: ColumnType<number, number | string, number | string>;
843
+ memory_mb: number;
844
+ storage_limit_mb: number;
845
+ storage_used_mb: number | null;
846
+ pg_container_id: string | null;
847
+ api_container_id: string | null;
848
+ processor_container_id: string | null;
849
+ target_database_url_enc: Buffer;
850
+ tenant_jwt_secret_enc: Buffer;
851
+ anon_key_enc: Buffer;
852
+ service_key_enc: Buffer;
853
+ api_url_internal: string;
854
+ api_url_public: string;
855
+ suspended_at: Date | null;
856
+ last_health_check_at: Date | null;
857
+ last_active_at: Generated<Date>;
858
+ service_gen: Generated<number>;
859
+ anon_gen: Generated<number>;
860
+ project_id: string | null;
861
+ created_at: Generated<Date>;
862
+ updated_at: Generated<Date>;
863
+ }
864
+ interface TenantUsageMonthlyTable {
865
+ id: Generated<string>;
866
+ tenant_id: string;
867
+ period_month: Date;
868
+ storage_peak_mb: Generated<number>;
869
+ storage_avg_mb: Generated<number>;
870
+ storage_last_mb: Generated<number>;
871
+ measurements: Generated<number>;
872
+ first_at: Generated<Date>;
873
+ last_at: Generated<Date>;
874
+ }
875
+ interface TenantComputeAddonsTable {
876
+ id: Generated<string>;
877
+ tenant_id: string;
878
+ memory_mb_delta: Generated<number>;
879
+ cpu_delta: Generated<number | string>;
880
+ storage_mb_delta: Generated<number>;
881
+ effective_from: Generated<Date>;
882
+ effective_until: Date | null;
883
+ stripe_subscription_item_id: string | null;
884
+ created_at: Generated<Date>;
885
+ }
886
+ interface AccountSpendCapsTable {
887
+ account_id: string;
888
+ monthly_cap_cents: number | null;
889
+ compute_cap_cents: number | null;
890
+ storage_cap_cents: number | null;
891
+ alert_threshold_pct: Generated<number>;
892
+ alert_sent_at: Date | null;
893
+ frozen_at: Date | null;
894
+ updated_at: Generated<Date>;
895
+ }
896
+ /** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
897
+ interface AccountCreditsTable {
898
+ account_id: string;
899
+ balance_usd_micros: Generated<string | number | bigint>;
900
+ /** Month bucket ("YYYY-MM") the spend counter applies to. */
901
+ spent_month: string | null;
902
+ spent_month_usd_micros: Generated<string | number | bigint>;
903
+ updated_at: Generated<Date>;
904
+ }
905
+ type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
906
+ type ProvisioningAuditStatus = "ok" | "error";
907
+ interface ProvisioningAuditLogTable {
908
+ id: Generated<string>;
909
+ tenant_id: string | null;
910
+ tenant_slug: string | null;
911
+ account_id: string | null;
912
+ actor: string;
913
+ event: ProvisioningAuditEvent;
914
+ status: ProvisioningAuditStatus;
915
+ detail: unknown | null;
916
+ error: string | null;
917
+ created_at: Generated<Date>;
918
+ }
919
+ type SubscriptionStatus = "active" | "paused" | "error";
920
+ /** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
921
+ * `chain` reacts to raw chain events matched directly off the Index/Streams
922
+ * clock (no subgraph). See migration 0088. */
923
+ type SubscriptionKind = "subgraph" | "chain";
924
+ type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
925
+ type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
926
+ interface SubscriptionsTable {
927
+ id: Generated<string>;
928
+ account_id: string;
929
+ project_id: string | null;
930
+ name: string;
931
+ status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
932
+ kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
933
+ /** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
934
+ subgraph_name: string | null;
935
+ /** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
936
+ table_name: string | null;
937
+ /** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
938
+ * subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
939
+ * import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
940
+ triggers: unknown | null;
941
+ filter: Generated<unknown>;
942
+ format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
943
+ runtime: SubscriptionRuntime | null;
944
+ url: string;
945
+ signing_secret_enc: Buffer;
946
+ auth_config: Generated<unknown>;
947
+ max_retries: Generated<number>;
948
+ timeout_ms: Generated<number>;
949
+ concurrency: Generated<number>;
950
+ circuit_failures: Generated<number>;
951
+ circuit_opened_at: Date | null;
952
+ last_delivery_at: Date | null;
953
+ last_success_at: Date | null;
954
+ last_error: string | null;
955
+ created_at: Generated<Date>;
956
+ updated_at: Generated<Date>;
957
+ }
958
+ type OutboxStatus = "pending" | "delivered" | "dead";
959
+ interface SubscriptionOutboxTable {
960
+ id: Generated<string>;
961
+ subscription_id: string;
962
+ kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
963
+ /** Null for chain-subscription rows. */
964
+ subgraph_name: string | null;
965
+ /** Null for chain-subscription rows. */
966
+ table_name: string | null;
967
+ block_height: number | bigint;
968
+ tx_id: string | null;
969
+ row_pk: unknown;
970
+ event_type: string;
971
+ payload: unknown;
972
+ dedup_key: string;
973
+ attempt: Generated<number>;
974
+ next_attempt_at: Generated<Date>;
975
+ status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
976
+ is_replay: Generated<boolean>;
977
+ delivered_at: Date | null;
978
+ failed_at: Date | null;
979
+ locked_by: string | null;
980
+ locked_until: Date | null;
981
+ created_at: Generated<Date>;
982
+ }
983
+ interface SubscriptionDeliveriesTable {
984
+ id: Generated<string>;
985
+ /** Nullable after migration 0077 — outbox row may be cleaned up while
986
+ * delivery telemetry is retained. */
987
+ outbox_id: string | null;
988
+ subscription_id: string;
989
+ attempt: number;
990
+ status_code: number | null;
991
+ response_headers: unknown | null;
992
+ response_body: string | null;
993
+ error_message: string | null;
994
+ duration_ms: number | null;
995
+ dispatched_at: Generated<Date>;
996
+ }
997
+ /** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
998
+ * One loop serves all chain subscriptions, so the cursor is global. */
999
+ interface TriggerEvaluatorStateTable {
1000
+ id: Generated<boolean>;
1001
+ last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
1002
+ /** Watermark for the async sBTC settlement-confirmed webhook scan; null until
1003
+ * the evaluator fast-forwards it on first run. */
1004
+ last_settlement_scan_at: ColumnType<Date | null, Date | null | undefined, Date | null>;
1005
+ updated_at: Generated<Date>;
1006
+ }
1007
+ /**
1008
+ * v1 canonical byte encoding for chain identity — the shape that lets
1009
+ * independently-run runtimes agree on the same block.
1010
+ *
1011
+ * The exact-body digest (`sha256:parquet-object`) proves capture fidelity to one
1012
+ * source: replay the same bytes, get the same rows. It cannot prove two nodes
1013
+ * observed the same chain, because their Parquet encoders legally differ in
1014
+ * column padding, compression, JSON key order, and null placement — two
1015
+ * operators processing the same block can ship byte-different Parquets that
1016
+ * carry identical content.
1017
+ *
1018
+ * The semantic digest is the shape that lets independent runtimes agree. Every
1019
+ * value on a block/transaction/event is normalized into a canonical byte string
1020
+ * by rules that MUST NOT change without a version bump. Two v1 computations
1021
+ * over the same range agree, or one is wrong about the chain — never about
1022
+ * formatting.
1023
+ *
1024
+ * Encoding rules (v1):
1025
+ * - Fields join with `\x1f` (ASCII US, unit separator — cannot legally
1026
+ * appear in any chain value; a printable delimiter risks collision with
1027
+ * contract-emitted strings).
1028
+ * - Null encodes as `\x00` (single NUL). Distinct from empty string `""`.
1029
+ * - Integers encode as their base-10 string. bigint → decimal string.
1030
+ * - JSON payload columns (function_args, event data) encode as canonical
1031
+ * JSON: object keys sorted lexicographically, no whitespace, bigint →
1032
+ * quoted decimal string, non-finite numbers rejected.
1033
+ * - Field order per record type is fixed and never reordered.
1034
+ * - Digest = sha256(bytes), lowercase hex.
1035
+ *
1036
+ * Rollup rules (v1) — order MUST match the archive's stream order or an
1037
+ * honest re-will disagree with the manifest:
1038
+ * - blocks: (height asc)
1039
+ * - transactions: (block_height asc, tx_index asc, tx_id asc)
1040
+ * - events: (block_height asc, event_index asc, tx_id asc)
1041
+ * Per-partition rollup is `sha256(concat(row_digest_bytes))` in stream order.
1042
+ *
1043
+ * Test vectors under `packages/shared/src/archive/__fixtures__/semantic-digest/`
1044
+ * pin the encoding. Any change to bytes must bump the spec version.
1045
+ */
1046
+ declare const SEMANTIC_DIGEST_SPEC_V1: "sha256:semantic-v1";
1047
+ type SemanticDigestSpec = typeof SEMANTIC_DIGEST_SPEC_V1;
1048
+ /**
1049
+ * Per-partition digest record — the shape that lands in the snapshot manifest.
1050
+ * Complements the existing `sha256:parquet-object` per-partition digest by
1051
+ * proving semantic identity independent of file encoding.
1052
+ */
1053
+ interface PartitionSemanticDigest {
1054
+ dataset: "blocks" | "transactions" | "events";
1055
+ from_block: number;
1056
+ to_block: number;
1057
+ row_count: number;
1058
+ digest: string | null;
1059
+ digest_spec: SemanticDigestSpec;
1060
+ }
1061
+ import { Kysely } from "kysely";
1062
+ /**
1063
+ * Compute per-partition semantic-v1 digests directly from a database — the same
1064
+ * bytes an exporter would produce, without writing Parquet. Callers: the CLI
1065
+ * verifier's `--semantic` pass, and (in future) the node replay auditor.
1066
+ *
1067
+ * SQL and ordering MUST match the archive exporter's stream (see
1068
+ * `packages/indexer/src/archive/export-snapshot.ts`). If either drifts, an
1069
+ * honest re-computation will disagree with the manifest even though both are
1070
+ * correct — and there is no way to tell which is wrong. Any change here needs
1071
+ * a matching change there.
1072
+ */
1073
+ type CanonicalDataset = "blocks" | "transactions" | "events";
1074
+ interface StreamOptions {
1075
+ batchRows?: number;
1076
+ }
1077
+ /**
1078
+ * Compute one partition's semantic-v1 digest. Empty ranges return `null` — an
1079
+ * empty range has no digest, distinct from "digest of zero rows" which would
1080
+ * compare equal across datasets.
1081
+ */
1082
+ declare function computePartitionSemanticDigest(db: Kysely<Database>, dataset: CanonicalDataset, fromBlock: number, toBlock: number, options?: StreamOptions): Promise<PartitionSemanticDigest>;
1083
+ type PartitionSemanticComparison = {
1084
+ dataset: CanonicalDataset
1085
+ from_block: number
1086
+ to_block: number
1087
+ status: "match" | "digest-mismatch" | "count-mismatch" | "missing-locally"
1088
+ expected_digest: string | null
1089
+ actual_digest: string | null
1090
+ expected_rows: number
1091
+ actual_rows: number
1092
+ };
1093
+ declare function comparePartitionSemanticDigests(local: readonly PartitionSemanticDigest[], reference: readonly PartitionSemanticDigest[]): PartitionSemanticComparison[];
1094
+ export { computePartitionSemanticDigest, comparePartitionSemanticDigests, PartitionSemanticComparison, CanonicalDataset };