@plasius/economy 0.1.0 → 0.3.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.
package/dist/index.d.cts CHANGED
@@ -39,8 +39,105 @@ declare function parseIsoTimestamp(value: IsoTimestamp): number;
39
39
  /** Returns a new record with keys sorted for canonical serialization. */
40
40
  declare function sortStringRecord(value: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
41
41
 
42
+ type TokenSource = "shopify" | "ayet" | "bitlabs" | "subscription" | "event" | "competition" | "adjustment";
43
+ type LotTransferPolicy = "household-allocatable" | "same-user-only" | "non-transferable";
44
+ type LotRefundState = "none" | "partial" | "refunded" | "disputed" | "chargeback-lost";
45
+ interface SourceLotV1 {
46
+ readonly schemaVersion: EconomyContractVersion;
47
+ readonly lotId: LotId;
48
+ readonly walletId: WalletId;
49
+ readonly beneficiaryAccountId: AccountId;
50
+ readonly householdId?: HouseholdId;
51
+ readonly payerAccountId?: AccountId;
52
+ readonly source: TokenSource;
53
+ readonly providerEventId?: ProviderEventId;
54
+ readonly rateVersion: string;
55
+ readonly settlementEvidenceHash: string;
56
+ readonly transferPolicy: LotTransferPolicy;
57
+ readonly refundState: LotRefundState;
58
+ readonly originalAmount: TokenSubunitString;
59
+ readonly remainingAmount: TokenSubunitString;
60
+ readonly heldAmount: TokenSubunitString;
61
+ readonly reversedAmount: TokenSubunitString;
62
+ readonly settledAt: IsoTimestamp;
63
+ readonly creditedAt: IsoTimestamp;
64
+ readonly cohortKey?: string;
65
+ }
66
+ type LotUseOperation = "allocate" | "spend" | "reclaim" | "refund";
67
+ interface LotUseContextV1 {
68
+ readonly operation: LotUseOperation;
69
+ readonly beneficiaryAccountId: AccountId;
70
+ readonly householdId?: HouseholdId;
71
+ }
72
+ interface SourceLotSliceV1 {
73
+ readonly lotId: LotId;
74
+ readonly amount: TokenSubunitString;
75
+ }
76
+ /** Versioned mutable projection around immutable V1 source-lot provenance. */
77
+ interface VersionedSourceLotV1 {
78
+ readonly schemaVersion: EconomyContractVersion;
79
+ readonly lot: SourceLotV1;
80
+ readonly version: number;
81
+ readonly updatedAt: IsoTimestamp;
82
+ }
83
+ type SourceLotMovementType = "allocate" | "boost" | "reclaim" | "spend" | "hold" | "release-hold" | "refund" | "chargeback" | "reversal";
84
+ /**
85
+ * Immutable movement applied to one source-lot projection by compare-and-swap.
86
+ * Signed deltas are authoritative; `resultingRefundState` is part of the same
87
+ * atomic version transition.
88
+ */
89
+ interface SourceLotMovementV1 {
90
+ readonly schemaVersion: EconomyContractVersion;
91
+ readonly movementId: string;
92
+ readonly transactionId: TransactionId;
93
+ readonly lotId: LotId;
94
+ readonly movementType: SourceLotMovementType;
95
+ readonly remainingDelta: TokenSubunitString;
96
+ readonly heldDelta: TokenSubunitString;
97
+ readonly reversedDelta: TokenSubunitString;
98
+ readonly expectedVersion: number;
99
+ readonly resultingVersion: number;
100
+ readonly expectedRefundState: LotRefundState;
101
+ readonly resultingRefundState: LotRefundState;
102
+ readonly occurredAt: IsoTimestamp;
103
+ }
104
+ /** Validates source-lot arithmetic, evidence, and immutable provenance fields. */
105
+ declare function assertSourceLot(lot: SourceLotV1): void;
106
+ /** Validates the optimistic projection wrapper used by V2 persistence. */
107
+ declare function assertVersionedSourceLot(snapshot: VersionedSourceLotV1): void;
108
+ /** Creates the only state accepted by the V2 append-source-lot operation. */
109
+ declare function createInitialSourceLotSnapshot(lot: SourceLotV1): VersionedSourceLotV1;
110
+ /** Validates movement shape and operation-specific delta direction. */
111
+ declare function assertSourceLotMovement(movement: SourceLotMovementV1): void;
112
+ /**
113
+ * Applies one immutable movement to a locked source-lot snapshot. Persistence
114
+ * must append the movement and compare-and-swap this result atomically.
115
+ */
116
+ declare function applySourceLotMovement(snapshot: VersionedSourceLotV1, movement: SourceLotMovementV1): VersionedSourceLotV1;
117
+ /** Returns unheld, unconsumed TokenSubunits in a source lot. */
118
+ declare function availableSourceLotAmount(lot: SourceLotV1): bigint;
119
+ /** Evaluates provider/source restrictions without trusting a browser claim. */
120
+ declare function canUseSourceLot(lot: SourceLotV1, context: LotUseContextV1): boolean;
121
+ /**
122
+ * Selects eligible lots deterministically in credited-time/lot-id order.
123
+ * The returned slices are a proposal; persistence must consume them atomically.
124
+ */
125
+ declare function selectSourceLots(lots: readonly SourceLotV1[], requestedAmount: TokenSubunitString, context: LotUseContextV1): readonly SourceLotSliceV1[];
126
+
42
127
  type ActivityType = "purchase" | "subscription" | "rewarded-ad" | "offerwall" | "allocation" | "boost" | "reclaim" | "spend" | "hold" | "refund" | "chargeback" | "adjustment" | "reversal" | "event" | "competition";
43
128
  type ActivityStatus = "pending" | "held" | "settled" | "reversed" | "failed";
129
+ /**
130
+ * States permitted on an immutable transaction accepted by the V2
131
+ * persistence boundary. Pending and failed work belongs to the command
132
+ * workflow, while a reversed presentation state is derived from an immutable
133
+ * compensating transaction rather than written back to the original journal
134
+ * row.
135
+ */
136
+ type EconomicJournalStatus = "held" | "settled";
137
+ /** A journal transaction that has an immediate economic effect. */
138
+ type EconomicJournalTransactionV1 = Omit<LedgerTransactionV1, "status"> & {
139
+ readonly status: EconomicJournalStatus;
140
+ };
44
141
  /** One signed side of an immutable double-entry transaction. */
45
142
  interface LedgerPostingV1 {
46
143
  readonly schemaVersion: EconomyContractVersion;
@@ -75,6 +172,8 @@ interface ActivityEntryV1 {
75
172
  readonly status: ActivityStatus;
76
173
  readonly occurredAt: IsoTimestamp;
77
174
  readonly amount: TokenSubunitString;
175
+ /** Stable source identity used for filtering and provenance presentation. */
176
+ readonly source: TokenSource;
78
177
  readonly beneficiaryAccountId?: AccountId;
79
178
  readonly maskedReference?: string;
80
179
  readonly sourceLabel: string;
@@ -83,6 +182,11 @@ interface ActivityEntryV1 {
83
182
  declare function assertActivityEntry(entry: ActivityEntryV1): void;
84
183
  /** Proves the structural and arithmetic invariants of one transaction. */
85
184
  declare function assertBalancedTransaction(transaction: LedgerTransactionV1): void;
185
+ /**
186
+ * Narrows a balanced V1 transaction to the states accepted by the V2 journal.
187
+ * This is additive: legacy V1 validators retain their existing status union.
188
+ */
189
+ declare function assertEconomicJournalTransaction(transaction: LedgerTransactionV1): asserts transaction is EconomicJournalTransactionV1;
86
190
  /**
87
191
  * Produces deterministic UTF-8 JSON for an approved SHA-256/HSM adapter.
88
192
  * Hashing itself deliberately remains outside this provider-neutral package.
@@ -217,52 +321,6 @@ declare function convertRewardPayout(providerPayoutMinorUnits: string, rate: Rew
217
321
  /** Maps BitLabs' signed callback state into an immutable journal transition. */
218
322
  declare function mapBitLabsConversionState(state: string): RewardActivityTransitionV1;
219
323
 
220
- type TokenSource = "shopify" | "ayet" | "bitlabs" | "subscription" | "event" | "competition" | "adjustment";
221
- type LotTransferPolicy = "household-allocatable" | "same-user-only" | "non-transferable";
222
- type LotRefundState = "none" | "partial" | "refunded" | "disputed" | "chargeback-lost";
223
- interface SourceLotV1 {
224
- readonly schemaVersion: EconomyContractVersion;
225
- readonly lotId: LotId;
226
- readonly walletId: WalletId;
227
- readonly beneficiaryAccountId: AccountId;
228
- readonly householdId?: HouseholdId;
229
- readonly payerAccountId?: AccountId;
230
- readonly source: TokenSource;
231
- readonly providerEventId?: ProviderEventId;
232
- readonly rateVersion: string;
233
- readonly settlementEvidenceHash: string;
234
- readonly transferPolicy: LotTransferPolicy;
235
- readonly refundState: LotRefundState;
236
- readonly originalAmount: TokenSubunitString;
237
- readonly remainingAmount: TokenSubunitString;
238
- readonly heldAmount: TokenSubunitString;
239
- readonly reversedAmount: TokenSubunitString;
240
- readonly settledAt: IsoTimestamp;
241
- readonly creditedAt: IsoTimestamp;
242
- readonly cohortKey?: string;
243
- }
244
- type LotUseOperation = "allocate" | "spend" | "reclaim" | "refund";
245
- interface LotUseContextV1 {
246
- readonly operation: LotUseOperation;
247
- readonly beneficiaryAccountId: AccountId;
248
- readonly householdId?: HouseholdId;
249
- }
250
- interface SourceLotSliceV1 {
251
- readonly lotId: LotId;
252
- readonly amount: TokenSubunitString;
253
- }
254
- /** Validates source-lot arithmetic, evidence, and immutable provenance fields. */
255
- declare function assertSourceLot(lot: SourceLotV1): void;
256
- /** Returns unheld, unconsumed TokenSubunits in a source lot. */
257
- declare function availableSourceLotAmount(lot: SourceLotV1): bigint;
258
- /** Evaluates provider/source restrictions without trusting a browser claim. */
259
- declare function canUseSourceLot(lot: SourceLotV1, context: LotUseContextV1): boolean;
260
- /**
261
- * Selects eligible lots deterministically in credited-time/lot-id order.
262
- * The returned slices are a proposal; persistence must consume them atomically.
263
- */
264
- declare function selectSourceLots(lots: readonly SourceLotV1[], requestedAmount: TokenSubunitString, context: LotUseContextV1): readonly SourceLotSliceV1[];
265
-
266
324
  type AllocationStatus = "active" | "closed";
267
325
  type PeriodicLimitWindow = "daily" | "weekly" | "monthly";
268
326
  interface GameplayLimitsV1 {
@@ -349,11 +407,36 @@ interface EarlyBackerEvaluationV1 {
349
407
  readonly contributingLotIds: readonly LotId[];
350
408
  readonly evaluatedAt: IsoTimestamp;
351
409
  }
410
+ declare const EARLY_BACKER_SETTLEMENT_POLICY_V2: "settlement-window-v2";
411
+ /**
412
+ * Additive evaluation result using settlement as the sole qualification event.
413
+ * Purchase and credit times remain provenance/order facts.
414
+ */
415
+ interface EarlyBackerEvaluationV2 {
416
+ readonly schemaVersion: EconomyContractVersion;
417
+ readonly policyVersion: typeof EARLY_BACKER_SETTLEMENT_POLICY_V2;
418
+ readonly qualificationEvent: "settled-at";
419
+ readonly cohortKey: typeof PRE_UTILITY_BACKER_COHORT;
420
+ readonly status: "not-qualified" | "provisional";
421
+ readonly payerAccountId: AccountId;
422
+ readonly receivingHouseholdId: HouseholdId;
423
+ readonly netRetainedAmount: TokenSubunitString;
424
+ readonly contributingLotIds: readonly LotId[];
425
+ readonly evaluatedAt: IsoTimestamp;
426
+ }
352
427
  /**
353
428
  * Recalculates provisional cohort basis from retained paid lots. It promises no
354
429
  * future reward and deliberately has no permanent entitled state.
355
430
  */
356
431
  declare function evaluateEarlyBacker(payerAccountId: AccountId, receivingHouseholdId: HouseholdId, paidLots: readonly PaidLotRetentionV1[], window: EarlyBackerWindowV1, evaluatedAt: IsoTimestamp): EarlyBackerEvaluationV1;
432
+ /**
433
+ * Evaluates the approved settlement-window policy. The caller owns environment
434
+ * and rollout classification: `publicTokensLaunchAt` and
435
+ * `firstPublicSpendLiveAt` must be derived from the entire public cohort, so
436
+ * staff, test, and closed-beta availability cannot open or close this window.
437
+ * The caller must also exclude non-production/test lots before evaluation.
438
+ */
439
+ declare function evaluateEarlyBackerBySettlementV2(payerAccountId: AccountId, receivingHouseholdId: HouseholdId, paidLots: readonly PaidLotRetentionV1[], window: EarlyBackerWindowV1, evaluatedAt: IsoTimestamp): EarlyBackerEvaluationV2;
357
440
 
358
441
  /** Stable machine-readable failures exposed by the economy domain. */
359
442
  type EconomyErrorCode = "INVALID_AMOUNT" | "AMOUNT_OUT_OF_RANGE" | "AMOUNT_NOT_WHOLE_TOKEN" | "INVALID_CONTRACT" | "UNBALANCED_TRANSACTION" | "DUPLICATE_IDENTIFIER" | "DUPLICATE_TRANSACTION" | "INSUFFICIENT_BALANCE" | "INSUFFICIENT_ELIGIBLE_LOTS" | "SOURCE_LOT_RESTRICTED" | "REVERSAL_ALREADY_EXISTS" | "NEGATIVE_PROJECTION" | "INVALID_TIME_WINDOW";
@@ -378,6 +461,29 @@ declare function economyAssert(condition: unknown, code: EconomyErrorCode, messa
378
461
  /** Creates a bounded, non-sensitive error contract for an HTTP adapter. */
379
462
  declare function toEconomyErrorEnvelope(error: EconomyError, requestId?: string): EconomyErrorEnvelopeV1;
380
463
 
464
+ type JournalChainId = string;
465
+ /** Locked head of one canonical transaction hash chain. */
466
+ interface JournalChainHeadV1 {
467
+ readonly schemaVersion: EconomyContractVersion;
468
+ readonly chainId: JournalChainId;
469
+ readonly version: number;
470
+ readonly lastTransactionId?: TransactionId;
471
+ readonly canonicalHash?: string;
472
+ readonly updatedAt: IsoTimestamp;
473
+ }
474
+ /** An effective economic transaction carrying its approved canonical hash. */
475
+ type ChainedEconomicJournalTransactionV1 = EconomicJournalTransactionV1 & {
476
+ readonly canonicalHash: string;
477
+ };
478
+ /** Validates an empty or populated journal-chain head. */
479
+ declare function assertJournalChainHead(head: JournalChainHeadV1): void;
480
+ /**
481
+ * Proves that a hashed transaction extends the locked head and returns the
482
+ * exact next head. The persistence adapter must compare-and-swap the old
483
+ * version inside the same serializable transaction that appends the journal.
484
+ */
485
+ declare function advanceJournalChainHead(head: JournalChainHeadV1, transaction: ChainedEconomicJournalTransactionV1): JournalChainHeadV1;
486
+
381
487
  type AdjustmentStatus = "draft" | "pending-approval" | "approved" | "rejected" | "executed" | "expired";
382
488
  /** Dual-control request; the resulting change is always a ledger transaction. */
383
489
  interface AdjustmentRequestV1 {
@@ -397,27 +503,14 @@ interface AdjustmentRequestV1 {
397
503
  /** Proves that production adjustment approval was performed by another actor. */
398
504
  declare function assertDistinctAdjustmentApproval(request: AdjustmentRequestV1): void;
399
505
 
400
- type BalanceProjection = Readonly<Record<AccountId, TokenSubunitString>>;
401
- interface BalanceProjectionSnapshotV1 {
402
- readonly schemaVersion: EconomyContractVersion;
403
- readonly balances: BalanceProjection;
404
- readonly lastTransactionId?: TransactionId;
405
- readonly rebuiltAt: IsoTimestamp;
406
- }
407
- /** Applies one balanced transaction without mutating the existing projection. */
408
- declare function applyTransactionToProjection(current: BalanceProjection, transaction: LedgerTransactionV1): BalanceProjection;
409
- /**
410
- * Rebuilds balances deterministically and rejects duplicate economic envelopes.
411
- */
412
- declare function rebuildBalanceProjection(transactions: readonly LedgerTransactionV1[]): BalanceProjection;
413
- /** Enforces non-negative balances only for spendable/reservable accounts. */
414
- declare function assertNonNegativeAccounts(projection: BalanceProjection, protectedAccountIds: readonly AccountId[]): void;
415
- /** Creates a versioned snapshot after a deterministic rebuild. */
416
- declare function createProjectionSnapshot(transactions: readonly LedgerTransactionV1[], rebuiltAt: IsoTimestamp): BalanceProjectionSnapshotV1;
417
-
418
506
  type WalletKind = "household-treasury" | "personal" | "gameplay-allocation" | "hold" | "purchase-clearing" | "provider-clearing" | "system";
419
507
  type WalletStatus = "active" | "restricted" | "closed";
420
508
  type WalletOwnerType = "account" | "household" | "system";
509
+ /** Exact owner identity used by persistence lookups and IDOR-safe locking. */
510
+ interface WalletOwnerReferenceV1 {
511
+ readonly ownerType: WalletOwnerType;
512
+ readonly ownerId: AccountId | HouseholdId | "system";
513
+ }
421
514
  /** Versioned authoritative wallet descriptor. */
422
515
  interface WalletV1 {
423
516
  readonly schemaVersion: EconomyContractVersion;
@@ -453,6 +546,8 @@ interface WalletLifetimeTotalsV1 {
453
546
  readonly spent: TokenSubunitString;
454
547
  readonly reversed: TokenSubunitString;
455
548
  }
549
+ /** Validates an exact wallet owner without accepting a browser-derived role. */
550
+ declare function assertWalletOwnerReference(owner: WalletOwnerReferenceV1): void;
456
551
  /** Validates wallet ownership, lifecycle, and optimistic-version facts. */
457
552
  declare function assertWallet(wallet: WalletV1): void;
458
553
  /** Validates non-negative server-computed wallet balance categories. */
@@ -460,7 +555,89 @@ declare function assertWalletBalanceSummary(summary: WalletBalanceSummaryV1): vo
460
555
  /** Validates non-negative lifetime aggregates exposed by the profile API. */
461
556
  declare function assertWalletLifetimeTotals(totals: WalletLifetimeTotalsV1): void;
462
557
 
463
- type EconomyCommandType = "credit-purchase" | "credit-reward" | "allocate" | "boost" | "reclaim" | "hold" | "refund" | "chargeback" | "adjust";
558
+ type BalanceProjection = Readonly<Record<AccountId, TokenSubunitString>>;
559
+ interface BalanceProjectionSnapshotV1 {
560
+ readonly schemaVersion: EconomyContractVersion;
561
+ readonly balances: BalanceProjection;
562
+ readonly lastTransactionId?: TransactionId;
563
+ readonly rebuiltAt: IsoTimestamp;
564
+ }
565
+ type WalletProjectionBucket = "spendable" | "reserved" | "held";
566
+ /** Exclusive stored buckets for one wallet; reward progress is derived. */
567
+ interface WalletBalanceProjectionV1 {
568
+ readonly schemaVersion: EconomyContractVersion;
569
+ readonly walletId: WalletId;
570
+ readonly spendable: TokenSubunitString;
571
+ readonly reserved: TokenSubunitString;
572
+ readonly held: TokenSubunitString;
573
+ readonly version: number;
574
+ readonly lastTransactionId?: TransactionId;
575
+ readonly asOf: IsoTimestamp;
576
+ }
577
+ /** One atomic add operation against all exclusive buckets of a wallet. */
578
+ interface WalletBalanceDeltaV1 {
579
+ readonly schemaVersion: EconomyContractVersion;
580
+ readonly walletId: WalletId;
581
+ readonly spendableDelta: TokenSubunitString;
582
+ readonly reservedDelta: TokenSubunitString;
583
+ readonly heldDelta: TokenSubunitString;
584
+ }
585
+ /** Authoritative mapping from a ledger account to one wallet bucket. */
586
+ interface WalletPostingAccountBindingV1 {
587
+ readonly accountId: AccountId;
588
+ readonly walletId: WalletId;
589
+ readonly bucket: WalletProjectionBucket;
590
+ }
591
+ type WalletLifetimeBucket = "bought" | "earned" | "allocated" | "reclaimed" | "spent" | "reversed";
592
+ /** Positive monotonic contribution to one wallet lifetime counter. */
593
+ interface WalletLifetimeDeltaV1 {
594
+ readonly schemaVersion: EconomyContractVersion;
595
+ readonly walletId: WalletId;
596
+ readonly bucket: WalletLifetimeBucket;
597
+ readonly amount: TokenSubunitString;
598
+ }
599
+ /** Validates one exclusive-bucket projection. */
600
+ declare function assertWalletBalanceProjection(projection: WalletBalanceProjectionV1): void;
601
+ /** Validates one non-zero atomic wallet delta. */
602
+ declare function assertWalletBalanceDelta(delta: WalletBalanceDeltaV1): void;
603
+ /** Rejects duplicate wallet updates before one atomic persistence call. */
604
+ declare function assertWalletBalanceDeltaBatch(transactionId: TransactionId, deltas: readonly WalletBalanceDeltaV1[]): void;
605
+ /** Applies an atomic add locally for deterministic tests and rebuilds. */
606
+ declare function applyWalletBalanceDelta(projection: WalletBalanceProjectionV1, delta: WalletBalanceDeltaV1, transactionId: TransactionId, asOf: IsoTimestamp): WalletBalanceProjectionV1;
607
+ /**
608
+ * Converts exclusive storage buckets to the legacy display DTO. Available is
609
+ * independently usable whole Tokens in this wallet; rewardProgress is this
610
+ * wallet's sub-Token remainder and is never netted with another wallet.
611
+ */
612
+ declare function createWalletBalanceSummary(projection: WalletBalanceProjectionV1): WalletBalanceSummaryV1;
613
+ /** Enforces the stronger per-wallet semantics required by V1 query adapters. */
614
+ declare function assertDeterministicWalletBalanceSummary(summary: WalletBalanceSummaryV1): void;
615
+ /**
616
+ * Derives a single delta per wallet from wallet-linked postings and an
617
+ * authoritative account-to-bucket mapping. Unlinked system postings are not
618
+ * wallet projections.
619
+ */
620
+ declare function deriveWalletBalanceDeltas(transaction: EconomicJournalTransactionV1, bindings: readonly WalletPostingAccountBindingV1[]): readonly WalletBalanceDeltaV1[];
621
+ /**
622
+ * Rebuilds monotonic gross lifetime contributions from a settled transaction.
623
+ * Earlier bought/earned counters are never reduced by a later compensating
624
+ * transaction; removals accrue separately in `reversed`.
625
+ */
626
+ declare function deriveWalletLifetimeDeltas(transaction: EconomicJournalTransactionV1): readonly WalletLifetimeDeltaV1[];
627
+ /** Applies positive lifetime deltas for one wallet without rewriting history. */
628
+ declare function applyWalletLifetimeDeltas(current: WalletLifetimeTotalsV1, walletId: WalletId, deltas: readonly WalletLifetimeDeltaV1[]): WalletLifetimeTotalsV1;
629
+ /** Applies one balanced transaction without mutating the existing projection. */
630
+ declare function applyTransactionToProjection(current: BalanceProjection, transaction: LedgerTransactionV1): BalanceProjection;
631
+ /**
632
+ * Rebuilds balances deterministically and rejects duplicate economic envelopes.
633
+ */
634
+ declare function rebuildBalanceProjection(transactions: readonly LedgerTransactionV1[]): BalanceProjection;
635
+ /** Enforces non-negative balances only for spendable/reservable accounts. */
636
+ declare function assertNonNegativeAccounts(projection: BalanceProjection, protectedAccountIds: readonly AccountId[]): void;
637
+ /** Creates a versioned snapshot after a deterministic rebuild. */
638
+ declare function createProjectionSnapshot(transactions: readonly LedgerTransactionV1[], rebuiltAt: IsoTimestamp): BalanceProjectionSnapshotV1;
639
+
640
+ type EconomyCommandType = "credit-purchase" | "credit-subscription" | "credit-reward" | "credit-event" | "credit-competition" | "allocate" | "boost" | "reclaim" | "spend" | "hold" | "release-hold" | "refund" | "chargeback" | "reverse" | "adjust";
464
641
  interface EconomyCommandEnvelopeV1 {
465
642
  readonly schemaVersion: EconomyContractVersion;
466
643
  readonly commandId: string;
@@ -475,6 +652,17 @@ interface EconomyCommandEnvelopeV1 {
475
652
  readonly acceptedRegion: string;
476
653
  readonly writerFencingToken: string;
477
654
  }
655
+ type EconomyCommandWorkflowStateV1 = "accepted" | "processing" | "failed" | "completed";
656
+ /** Immutable workflow evidence; it is never an economic journal transaction. */
657
+ interface EconomyCommandWorkflowEventV1 {
658
+ readonly schemaVersion: EconomyContractVersion;
659
+ readonly workflowEventId: string;
660
+ readonly commandId: string;
661
+ readonly state: EconomyCommandWorkflowStateV1;
662
+ /** Stable non-sensitive classifier; detailed failure data stays operational. */
663
+ readonly failureCode?: string;
664
+ readonly occurredAt: IsoTimestamp;
665
+ }
478
666
  interface EconomyOutboxEventV1 {
479
667
  readonly schemaVersion: EconomyContractVersion;
480
668
  readonly eventId: string;
@@ -488,6 +676,27 @@ interface PersistedIdempotencyResultV1 {
488
676
  readonly responseHash: string;
489
677
  readonly recordedAt: IsoTimestamp;
490
678
  }
679
+ /** Exact actor/subject/operation namespace for a caller-owned idempotency key. */
680
+ interface EconomyIdempotencyScopeV1 {
681
+ readonly schemaVersion: EconomyContractVersion;
682
+ readonly idempotencyKey: string;
683
+ readonly commandType: EconomyCommandType;
684
+ readonly actorAccountId: AccountId;
685
+ readonly subjectAccountId: AccountId;
686
+ }
687
+ /** V2 replay evidence bound to one accepted command and exact scope. */
688
+ interface ScopedPersistedIdempotencyResultV1 extends PersistedIdempotencyResultV1 {
689
+ readonly schemaVersion: EconomyContractVersion;
690
+ readonly commandId: string;
691
+ }
692
+ /** Validates replay evidence before it is returned across a command boundary. */
693
+ declare function assertScopedPersistedIdempotencyResult(result: ScopedPersistedIdempotencyResultV1): void;
694
+ /** Validates the namespace that prevents cross-principal replay collisions. */
695
+ declare function assertEconomyIdempotencyScope(scope: EconomyIdempotencyScopeV1): void;
696
+ /** Validates minimized accepted-command evidence before durable append. */
697
+ declare function assertEconomyCommandEnvelope(envelope: EconomyCommandEnvelopeV1): void;
698
+ /** Validates one immutable command-workflow state event. */
699
+ declare function assertEconomyCommandWorkflowEvent(event: EconomyCommandWorkflowEventV1): void;
491
700
  /** Operations available only inside one serializable database transaction. */
492
701
  interface EconomyUnitOfWork {
493
702
  getWalletForUpdate(walletId: WalletId): Promise<WalletV1 | null>;
@@ -509,6 +718,62 @@ interface EconomyPersistencePort {
509
718
  getTransaction(transactionId: TransactionId): Promise<LedgerTransactionV1 | null>;
510
719
  rebuildProjection(): Promise<BalanceProjection>;
511
720
  }
721
+ /**
722
+ * V2 mutation surface. Unlike `EconomyUnitOfWork`, it has no absolute balance
723
+ * overwrite: journal, source-lot movement, allocation state, balance/lifetime
724
+ * deltas, idempotency, chain head, and outbox are committed atomically.
725
+ */
726
+ interface EconomyUnitOfWorkV2 {
727
+ getWalletForOwnerForUpdate(walletId: WalletId, owner: WalletOwnerReferenceV1): Promise<WalletV1 | null>;
728
+ listSpendableLotsForUpdate(walletId: WalletId): Promise<readonly VersionedSourceLotV1[]>;
729
+ findLotForUpdate(lotId: LotId): Promise<VersionedSourceLotV1 | null>;
730
+ getGameplayAllocationForUpdate(allocationId: AllocationId, householdId: HouseholdId, childAccountId: AccountId): Promise<GameplayAllocationV1 | null>;
731
+ findIdempotencyResult(scope: EconomyIdempotencyScopeV1): Promise<ScopedPersistedIdempotencyResultV1 | null>;
732
+ /** Locks and rejects any stale/non-active regional writer lease. */
733
+ lockActiveWriterFence(acceptedRegion: string, writerFencingToken: string): Promise<void>;
734
+ lockJournalChainHead(chainId: string): Promise<JournalChainHeadV1>;
735
+ appendCommandEnvelope(envelope: EconomyCommandEnvelopeV1): Promise<void>;
736
+ appendCommandWorkflowEvent(event: EconomyCommandWorkflowEventV1): Promise<void>;
737
+ appendTransaction(transaction: ChainedEconomicJournalTransactionV1): Promise<void>;
738
+ /** Appends `createInitialSourceLotSnapshot()` output; later changes are movements. */
739
+ appendSourceLot(snapshot: VersionedSourceLotV1): Promise<void>;
740
+ /** Appends movement evidence and applies its lot CAS as one operation. */
741
+ applySourceLotMovement(movement: SourceLotMovementV1): Promise<void>;
742
+ appendGameplayAllocation(allocation: GameplayAllocationV1): Promise<void>;
743
+ /**
744
+ * Compares `expectedVersion`, requires `allocation.version` to be exactly the
745
+ * next value, and never overwrites a stale row.
746
+ */
747
+ saveGameplayAllocation(allocation: GameplayAllocationV1, expectedVersion: number): Promise<void>;
748
+ /**
749
+ * Atomically adds deltas, verifies them against the appended postings and
750
+ * account bindings, and records transaction-scoped application keys.
751
+ */
752
+ applyWalletBalanceDeltas(transactionId: TransactionId, deltas: readonly WalletBalanceDeltaV1[]): Promise<void>;
753
+ /**
754
+ * Atomically increments monotonic lifetime counters after verifying the
755
+ * deltas against the appended transaction's deterministic classification.
756
+ */
757
+ applyWalletLifetimeDeltas(transactionId: TransactionId, deltas: readonly WalletLifetimeDeltaV1[]): Promise<void>;
758
+ saveIdempotencyResult(scope: EconomyIdempotencyScopeV1, result: ScopedPersistedIdempotencyResultV1): Promise<void>;
759
+ appendOutboxEvent(event: EconomyOutboxEventV1): Promise<void>;
760
+ /** Compare-and-swaps the full locked head, including its canonical hash. */
761
+ advanceJournalChainHead(expected: JournalChainHeadV1, next: JournalChainHeadV1): Promise<void>;
762
+ }
763
+ /**
764
+ * Additive authoritative persistence boundary for new consumers. V1 remains
765
+ * exported for compatibility but must not be adapted by delegating its
766
+ * absolute `saveBalanceProjection` operation to this interface.
767
+ */
768
+ interface EconomyPersistencePortV2 {
769
+ runSerializable<T>(operation: (unitOfWork: EconomyUnitOfWorkV2) => Promise<T>): Promise<T>;
770
+ getWallet(walletId: WalletId): Promise<WalletV1 | null>;
771
+ listWalletsByOwner(owner: WalletOwnerReferenceV1): Promise<readonly WalletV1[]>;
772
+ getGameplayAllocation(allocationId: AllocationId, householdId: HouseholdId, childAccountId: AccountId): Promise<GameplayAllocationV1 | null>;
773
+ getCommandEnvelope(commandId: string): Promise<EconomyCommandEnvelopeV1 | null>;
774
+ getTransaction(transactionId: TransactionId): Promise<ChainedEconomicJournalTransactionV1 | null>;
775
+ rebuildWalletBalanceProjections(): Promise<readonly WalletBalanceProjectionV1[]>;
776
+ }
512
777
  interface EconomyClockPort {
513
778
  now(): IsoTimestamp;
514
779
  }
@@ -516,6 +781,151 @@ interface EconomyIdPort {
516
781
  nextId(namespace: string): string;
517
782
  }
518
783
 
784
+ type WalletPortfolioComponentRole = "household-treasury" | "personal" | "gameplay-allocation" | "hold";
785
+ /** One server-authorized component of a portfolio read. */
786
+ interface WalletPortfolioComponentScopeV1 {
787
+ readonly walletId: WalletId;
788
+ readonly role: WalletPortfolioComponentRole;
789
+ readonly beneficiaryAccountId?: AccountId;
790
+ }
791
+ /**
792
+ * Explicit portfolio scope assembled after authorization. It prevents a host's
793
+ * household treasury and same-user-only personal wallet from being silently
794
+ * represented as one wallet.
795
+ */
796
+ interface WalletPortfolioReadScopeV1 {
797
+ readonly schemaVersion: EconomyContractVersion;
798
+ readonly portfolioId: string;
799
+ readonly subjectAccountId: AccountId;
800
+ readonly components: readonly WalletPortfolioComponentScopeV1[];
801
+ }
802
+ interface WalletBalanceTotalsV1 {
803
+ readonly available: TokenSubunitString;
804
+ readonly reserved: TokenSubunitString;
805
+ readonly held: TokenSubunitString;
806
+ readonly rewardProgress: TokenSubunitString;
807
+ }
808
+ interface WalletPortfolioBalanceComponentV1 extends WalletPortfolioComponentScopeV1 {
809
+ readonly summary: WalletBalanceSummaryV1;
810
+ }
811
+ interface WalletPortfolioSummaryV1 {
812
+ readonly schemaVersion: EconomyContractVersion;
813
+ readonly portfolioId: string;
814
+ readonly subjectAccountId: AccountId;
815
+ readonly components: readonly WalletPortfolioBalanceComponentV1[];
816
+ /**
817
+ * Exact column sums for display only. Progress is intentionally not promoted
818
+ * across wallets because their source/transfer policies may differ.
819
+ */
820
+ readonly totals: WalletBalanceTotalsV1;
821
+ readonly asOf: IsoTimestamp;
822
+ }
823
+ /** Self-identifying lifetime read for one wallet. */
824
+ interface WalletLifetimeSnapshotV1 {
825
+ readonly schemaVersion: EconomyContractVersion;
826
+ readonly walletId: WalletId;
827
+ readonly totals: WalletLifetimeTotalsV1;
828
+ readonly version: number;
829
+ readonly asOf: IsoTimestamp;
830
+ }
831
+ interface WalletPortfolioLifetimeComponentV1 extends WalletPortfolioComponentScopeV1 {
832
+ readonly snapshot: WalletLifetimeSnapshotV1;
833
+ }
834
+ interface WalletPortfolioLifetimeV1 {
835
+ readonly schemaVersion: EconomyContractVersion;
836
+ readonly portfolioId: string;
837
+ readonly subjectAccountId: AccountId;
838
+ readonly components: readonly WalletPortfolioLifetimeComponentV1[];
839
+ readonly totals: WalletLifetimeTotalsV1;
840
+ readonly asOf: IsoTimestamp;
841
+ }
842
+ type EconomicActivityStatusV1 = "held" | "settled" | "reversed";
843
+ type WorkflowActivityStatusV1 = "pending" | "failed";
844
+ type WalletActivityStatusV1 = EconomicActivityStatusV1 | WorkflowActivityStatusV1;
845
+ interface WalletActivityBaseV1 {
846
+ readonly schemaVersion: EconomyContractVersion;
847
+ readonly activityId: string;
848
+ /** Component wallet whose signed display amount this row represents. */
849
+ readonly walletId: WalletId;
850
+ readonly activityType: ActivityType;
851
+ readonly occurredAt: IsoTimestamp;
852
+ readonly amount: TokenSubunitString;
853
+ readonly source: TokenSource;
854
+ readonly beneficiaryAccountId?: AccountId;
855
+ readonly maskedReference?: string;
856
+ readonly sourceLabel: string;
857
+ }
858
+ /** Economically effective or read-model-derived reversal activity. */
859
+ interface EconomicWalletActivityEntryV1 extends WalletActivityBaseV1 {
860
+ readonly entryKind: "economic";
861
+ readonly transactionId: TransactionId;
862
+ readonly status: EconomicActivityStatusV1;
863
+ }
864
+ /**
865
+ * Non-economic accepted/failed work. Its amount is display context only and is
866
+ * excluded from balances and lifetime aggregates.
867
+ */
868
+ interface WorkflowWalletActivityEntryV1 extends WalletActivityBaseV1 {
869
+ readonly entryKind: "workflow";
870
+ readonly commandId: string;
871
+ readonly status: WorkflowActivityStatusV1;
872
+ }
873
+ type WalletActivityEntryV1 = EconomicWalletActivityEntryV1 | WorkflowWalletActivityEntryV1;
874
+ interface WalletActivityFilterV1 {
875
+ readonly activityTypes?: readonly ActivityType[];
876
+ readonly statuses?: readonly WalletActivityStatusV1[];
877
+ readonly sources?: readonly TokenSource[];
878
+ readonly beneficiaryAccountId?: AccountId;
879
+ readonly fromInclusive?: IsoTimestamp;
880
+ readonly toExclusive?: IsoTimestamp;
881
+ }
882
+ interface WalletActivityPageRequestV1 {
883
+ readonly limit: number;
884
+ readonly cursor?: string;
885
+ readonly filter?: WalletActivityFilterV1;
886
+ }
887
+ interface WalletActivityPageV1 {
888
+ readonly schemaVersion: EconomyContractVersion;
889
+ readonly entries: readonly WalletActivityEntryV1[];
890
+ readonly hasMore: boolean;
891
+ readonly nextCursor?: string;
892
+ }
893
+ /** Validates a server-created, bounded portfolio scope. */
894
+ declare function assertWalletPortfolioReadScope(scope: WalletPortfolioReadScopeV1): void;
895
+ /** Validates a self-identifying wallet lifetime read. */
896
+ declare function assertWalletLifetimeSnapshot(snapshot: WalletLifetimeSnapshotV1): void;
897
+ /**
898
+ * Constructs a portfolio balance without merging wallet identities or
899
+ * promoting sub-Token progress across policy boundaries.
900
+ */
901
+ declare function createWalletPortfolioSummary(scope: WalletPortfolioReadScopeV1, components: readonly WalletPortfolioBalanceComponentV1[], asOf: IsoTimestamp): WalletPortfolioSummaryV1;
902
+ /** Validates a portfolio balance read independently of its producing adapter. */
903
+ declare function assertWalletPortfolioSummary(summary: WalletPortfolioSummaryV1): void;
904
+ /** Builds monotonic lifetime totals while retaining per-wallet components. */
905
+ declare function createWalletPortfolioLifetime(scope: WalletPortfolioReadScopeV1, components: readonly WalletPortfolioLifetimeComponentV1[], asOf: IsoTimestamp): WalletPortfolioLifetimeV1;
906
+ /** Validates a portfolio lifetime read independently of its producing adapter. */
907
+ declare function assertWalletPortfolioLifetime(lifetime: WalletPortfolioLifetimeV1): void;
908
+ /** Validates the economic/workflow activity discriminant and safe display data. */
909
+ declare function assertWalletActivityEntry(entry: WalletActivityEntryV1): void;
910
+ /** Validates bounded filters and opaque cursor input. */
911
+ declare function assertWalletActivityPageRequest(request: WalletActivityPageRequestV1): void;
912
+ /**
913
+ * Validates stable descending `(occurredAt, activityId)` page order and cursor
914
+ * presence. Cursors remain opaque to this provider-neutral package.
915
+ */
916
+ declare function assertWalletActivityPage(page: WalletActivityPageV1): void;
917
+ /** Prevents an activity cursor/result from expanding an authorized portfolio. */
918
+ declare function assertWalletActivityPageForPortfolio(page: WalletActivityPageV1, scope: WalletPortfolioReadScopeV1): void;
919
+ /** Read-only adapter boundary; authorization must precede scope construction. */
920
+ interface EconomyQueryPortV1 {
921
+ getWalletSummary(walletId: WalletId): Promise<WalletBalanceSummaryV1 | null>;
922
+ getWalletLifetime(walletId: WalletId): Promise<WalletLifetimeSnapshotV1 | null>;
923
+ listWalletActivity(walletId: WalletId, request: WalletActivityPageRequestV1): Promise<WalletActivityPageV1>;
924
+ getPortfolioSummary(scope: WalletPortfolioReadScopeV1): Promise<WalletPortfolioSummaryV1>;
925
+ getPortfolioLifetime(scope: WalletPortfolioReadScopeV1): Promise<WalletPortfolioLifetimeV1>;
926
+ listPortfolioActivity(scope: WalletPortfolioReadScopeV1, request: WalletActivityPageRequestV1): Promise<WalletActivityPageV1>;
927
+ }
928
+
519
929
  type RecurrenceInterval = "daily" | "weekly" | "monthly";
520
930
  /** Provider-neutral subscription contract. Site policy controls enablement. */
521
931
  interface TokenSubscriptionPlanV1 {
@@ -555,4 +965,4 @@ interface SpendRequestV1 {
555
965
  /** Validates future child requests while creation remains policy-disabled. */
556
966
  declare function assertSpendRequest(request: SpendRequestV1): void;
557
967
 
558
- export { type AccountId, type ActivityEntryV1, type ActivityStatus, type ActivityType, type AdjustmentRequestV1, type AdjustmentStatus, type AllocationId, type AllocationStatus, BASELINE_GBP_CATALOG_VERSION, BASELINE_GBP_REFERENCE_RATE, BASELINE_GBP_TOKEN_PACKS, BASELINE_MONTHLY_SUBSCRIPTION_PLAN, BASELINE_PURCHASE_LIMIT_POLICY, type BalanceProjection, type BalanceProjectionSnapshotV1, type BitLabsConversionState, type BoostGameplayAllocationInputV1, type CreateGameplayAllocationInputV1, ECONOMY_CONTRACT_VERSION, type EarlyBackerEvaluationV1, type EarlyBackerWindowV1, type EconomyClockPort, type EconomyCommandEnvelopeV1, type EconomyCommandType, type EconomyContractVersion, EconomyError, type EconomyErrorCode, type EconomyErrorEnvelopeV1, type EconomyIdPort, type EconomyOutboxEventV1, type EconomyPersistencePort, type EconomyUnitOfWork, type FxSnapshotV1, type GameplayAllocationV1, type GameplayLimitsV1, type HouseholdId, type IsoTimestamp, type LedgerPostingV1, type LedgerTransactionV1, type LotId, type LotRefundState, type LotTransferPolicy, type LotUseContextV1, type LotUseOperation, PRE_UTILITY_BACKER_COHORT, type PaidLotRetentionV1, type PeriodicLimitWindow, type PersistedIdempotencyResultV1, type PostingId, type ProviderEventId, type PurchaseIntentStatus, type PurchaseIntentV1, type PurchaseLimitPolicyV1, type ReclaimGameplayAllocationInputV1, type RecurrenceInterval, type ReversalInputV1, type RewardActivityTransitionV1, type RewardConversionStatus, type RewardConversionV1, type RewardRateV1, type SourceLotSliceV1, type SourceLotV1, type SpendRequestPurpose, type SpendRequestStatus, type SpendRequestV1, TOKEN_SUBUNITS_MAX, TOKEN_SUBUNITS_MIN, TOKEN_SUBUNITS_PER_TOKEN, type TokenPackV1, type TokenReferenceRateV1, type TokenSource, type TokenSubscriptionPlanV1, type TokenSubunitString, type TransactionId, type WalletBalanceSummaryV1, type WalletId, type WalletKind, type WalletLifetimeTotalsV1, type WalletOwnerType, type WalletStatus, type WalletV1, applyTransactionToProjection, assertActivityEntry, assertBalancedTransaction, assertDistinctAdjustmentApproval, assertEconomyIdentifier, assertFlatTokenCatalog, assertFxSnapshot, assertGameplayAllocation, assertNonNegativeAccounts, assertOpenPurchaseIntent, assertPurchaseIntentBinding, assertPurchaseLimitPolicy, assertReversalAvailable, assertRewardConversion, assertRewardRate, assertSourceLot, assertSpendRequest, assertTokenPack, assertTokenReferenceRate, assertTokenSubscriptionPlan, assertWallet, assertWalletBalanceSummary, assertWalletLifetimeTotals, availableSourceLotAmount, boostGameplayAllocation, canUseSourceLot, canonicalTransactionPayload, convertRewardPayout, createGameplayAllocation, createProjectionSnapshot, createReversalTransaction, economyAssert, evaluateEarlyBacker, isWholeTokenAmount, mapBitLabsConversionState, parseIsoTimestamp, parseTokenSubunits, rebuildBalanceProjection, reclaimGameplayAllocation, selectSourceLots, serializeTokenSubunits, sortStringRecord, subunitsToWholeTokens, sumTokenSubunits, toEconomyErrorEnvelope, wholeTokensToSubunits };
968
+ export { type AccountId, type ActivityEntryV1, type ActivityStatus, type ActivityType, type AdjustmentRequestV1, type AdjustmentStatus, type AllocationId, type AllocationStatus, BASELINE_GBP_CATALOG_VERSION, BASELINE_GBP_REFERENCE_RATE, BASELINE_GBP_TOKEN_PACKS, BASELINE_MONTHLY_SUBSCRIPTION_PLAN, BASELINE_PURCHASE_LIMIT_POLICY, type BalanceProjection, type BalanceProjectionSnapshotV1, type BitLabsConversionState, type BoostGameplayAllocationInputV1, type ChainedEconomicJournalTransactionV1, type CreateGameplayAllocationInputV1, EARLY_BACKER_SETTLEMENT_POLICY_V2, ECONOMY_CONTRACT_VERSION, type EarlyBackerEvaluationV1, type EarlyBackerEvaluationV2, type EarlyBackerWindowV1, type EconomicActivityStatusV1, type EconomicJournalStatus, type EconomicJournalTransactionV1, type EconomicWalletActivityEntryV1, type EconomyClockPort, type EconomyCommandEnvelopeV1, type EconomyCommandType, type EconomyCommandWorkflowEventV1, type EconomyCommandWorkflowStateV1, type EconomyContractVersion, EconomyError, type EconomyErrorCode, type EconomyErrorEnvelopeV1, type EconomyIdPort, type EconomyIdempotencyScopeV1, type EconomyOutboxEventV1, type EconomyPersistencePort, type EconomyPersistencePortV2, type EconomyQueryPortV1, type EconomyUnitOfWork, type EconomyUnitOfWorkV2, type FxSnapshotV1, type GameplayAllocationV1, type GameplayLimitsV1, type HouseholdId, type IsoTimestamp, type JournalChainHeadV1, type JournalChainId, type LedgerPostingV1, type LedgerTransactionV1, type LotId, type LotRefundState, type LotTransferPolicy, type LotUseContextV1, type LotUseOperation, PRE_UTILITY_BACKER_COHORT, type PaidLotRetentionV1, type PeriodicLimitWindow, type PersistedIdempotencyResultV1, type PostingId, type ProviderEventId, type PurchaseIntentStatus, type PurchaseIntentV1, type PurchaseLimitPolicyV1, type ReclaimGameplayAllocationInputV1, type RecurrenceInterval, type ReversalInputV1, type RewardActivityTransitionV1, type RewardConversionStatus, type RewardConversionV1, type RewardRateV1, type ScopedPersistedIdempotencyResultV1, type SourceLotMovementType, type SourceLotMovementV1, type SourceLotSliceV1, type SourceLotV1, type SpendRequestPurpose, type SpendRequestStatus, type SpendRequestV1, TOKEN_SUBUNITS_MAX, TOKEN_SUBUNITS_MIN, TOKEN_SUBUNITS_PER_TOKEN, type TokenPackV1, type TokenReferenceRateV1, type TokenSource, type TokenSubscriptionPlanV1, type TokenSubunitString, type TransactionId, type VersionedSourceLotV1, type WalletActivityEntryV1, type WalletActivityFilterV1, type WalletActivityPageRequestV1, type WalletActivityPageV1, type WalletActivityStatusV1, type WalletBalanceDeltaV1, type WalletBalanceProjectionV1, type WalletBalanceSummaryV1, type WalletBalanceTotalsV1, type WalletId, type WalletKind, type WalletLifetimeBucket, type WalletLifetimeDeltaV1, type WalletLifetimeSnapshotV1, type WalletLifetimeTotalsV1, type WalletOwnerReferenceV1, type WalletOwnerType, type WalletPortfolioBalanceComponentV1, type WalletPortfolioComponentRole, type WalletPortfolioComponentScopeV1, type WalletPortfolioLifetimeComponentV1, type WalletPortfolioLifetimeV1, type WalletPortfolioReadScopeV1, type WalletPortfolioSummaryV1, type WalletPostingAccountBindingV1, type WalletProjectionBucket, type WalletStatus, type WalletV1, type WorkflowActivityStatusV1, type WorkflowWalletActivityEntryV1, advanceJournalChainHead, applySourceLotMovement, applyTransactionToProjection, applyWalletBalanceDelta, applyWalletLifetimeDeltas, assertActivityEntry, assertBalancedTransaction, assertDeterministicWalletBalanceSummary, assertDistinctAdjustmentApproval, assertEconomicJournalTransaction, assertEconomyCommandEnvelope, assertEconomyCommandWorkflowEvent, assertEconomyIdempotencyScope, assertEconomyIdentifier, assertFlatTokenCatalog, assertFxSnapshot, assertGameplayAllocation, assertJournalChainHead, assertNonNegativeAccounts, assertOpenPurchaseIntent, assertPurchaseIntentBinding, assertPurchaseLimitPolicy, assertReversalAvailable, assertRewardConversion, assertRewardRate, assertScopedPersistedIdempotencyResult, assertSourceLot, assertSourceLotMovement, assertSpendRequest, assertTokenPack, assertTokenReferenceRate, assertTokenSubscriptionPlan, assertVersionedSourceLot, assertWallet, assertWalletActivityEntry, assertWalletActivityPage, assertWalletActivityPageForPortfolio, assertWalletActivityPageRequest, assertWalletBalanceDelta, assertWalletBalanceDeltaBatch, assertWalletBalanceProjection, assertWalletBalanceSummary, assertWalletLifetimeSnapshot, assertWalletLifetimeTotals, assertWalletOwnerReference, assertWalletPortfolioLifetime, assertWalletPortfolioReadScope, assertWalletPortfolioSummary, availableSourceLotAmount, boostGameplayAllocation, canUseSourceLot, canonicalTransactionPayload, convertRewardPayout, createGameplayAllocation, createInitialSourceLotSnapshot, createProjectionSnapshot, createReversalTransaction, createWalletBalanceSummary, createWalletPortfolioLifetime, createWalletPortfolioSummary, deriveWalletBalanceDeltas, deriveWalletLifetimeDeltas, economyAssert, evaluateEarlyBacker, evaluateEarlyBackerBySettlementV2, isWholeTokenAmount, mapBitLabsConversionState, parseIsoTimestamp, parseTokenSubunits, rebuildBalanceProjection, reclaimGameplayAllocation, selectSourceLots, serializeTokenSubunits, sortStringRecord, subunitsToWholeTokens, sumTokenSubunits, toEconomyErrorEnvelope, wholeTokensToSubunits };