@plasius/economy 0.4.0 → 0.5.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.ts CHANGED
@@ -384,6 +384,787 @@ interface ReclaimGameplayAllocationInputV1 {
384
384
  /** Reclaims unused whole Tokens without changing spent history. */
385
385
  declare function reclaimGameplayAllocation(allocation: GameplayAllocationV1, input: ReclaimGameplayAllocationInputV1): GameplayAllocationV1;
386
386
 
387
+ type JournalChainId = string;
388
+ /** Locked head of one canonical transaction hash chain. */
389
+ interface JournalChainHeadV1 {
390
+ readonly schemaVersion: EconomyContractVersion;
391
+ readonly chainId: JournalChainId;
392
+ readonly version: number;
393
+ readonly lastTransactionId?: TransactionId;
394
+ readonly canonicalHash?: string;
395
+ readonly updatedAt: IsoTimestamp;
396
+ }
397
+ /** An effective economic transaction carrying its approved canonical hash. */
398
+ type ChainedEconomicJournalTransactionV1 = EconomicJournalTransactionV1 & {
399
+ readonly canonicalHash: string;
400
+ };
401
+ type JournalChainVerificationFailureCodeV1 = "duplicate-transaction" | "invalid-transaction" | "previous-hash-mismatch" | "canonical-hash-mismatch" | "end-head-mismatch";
402
+ /** Deterministic result of verifying one ordered canonical-chain segment. */
403
+ interface JournalChainVerificationResultV1 {
404
+ readonly schemaVersion: EconomyContractVersion;
405
+ readonly valid: boolean;
406
+ readonly checkedTransactions: number;
407
+ readonly observedHead: JournalChainHeadV1;
408
+ readonly failureCode?: JournalChainVerificationFailureCodeV1;
409
+ readonly firstInvalidTransactionId?: TransactionId;
410
+ }
411
+ /** Approved infrastructure adapter that hashes exact canonical UTF-8 bytes. */
412
+ type CanonicalPayloadHashFunctionV1 = (payload: string) => string;
413
+ /** Validates an empty or populated journal-chain head. */
414
+ declare function assertJournalChainHead(head: JournalChainHeadV1): void;
415
+ /**
416
+ * Proves that a hashed transaction extends the locked head and returns the
417
+ * exact next head. The persistence adapter must compare-and-swap the old
418
+ * version inside the same serializable transaction that appends the journal.
419
+ */
420
+ declare function advanceJournalChainHead(head: JournalChainHeadV1, transaction: ChainedEconomicJournalTransactionV1): JournalChainHeadV1;
421
+ /**
422
+ * Recomputes an ordered journal segment without implementing cryptography.
423
+ *
424
+ * The caller supplies an approved SHA-256 adapter. Malformed transactions are
425
+ * reported as integrity failures, while an invalid hash-adapter result is a
426
+ * contract error and fails closed.
427
+ */
428
+ declare function verifyJournalChainSegment(startHead: JournalChainHeadV1, transactions: readonly ChainedEconomicJournalTransactionV1[], expectedEndHead: JournalChainHeadV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): JournalChainVerificationResultV1;
429
+
430
+ /** Application ceiling below Cosmos DB's 100-operation transactional limit. */
431
+ declare const ECONOMY_AUTHORITY_MAX_BATCH_OPERATIONS = 80;
432
+ /** Commit-manifest create plus authority-head conditional replacement. */
433
+ declare const ECONOMY_AUTHORITY_COMMIT_OVERHEAD_OPERATIONS = 2;
434
+ /** Maximum referenced record writes within one 80-operation authority batch. */
435
+ declare const ECONOMY_AUTHORITY_MAX_RECORD_REFERENCES: number;
436
+ /** Application ceiling below Cosmos DB's 2 MiB transactional-batch limit. */
437
+ declare const ECONOMY_AUTHORITY_MAX_BATCH_BYTES = 1572864;
438
+ /** Validates adapter-measured transactional operation and byte counts. */
439
+ declare function assertEconomyAuthorityBatchLimits(operationCount: number, serializedBytes: number): void;
440
+ type EconomyAuthorityStateV1 = "open" | "acquisition-closed" | "closed" | "rebuilding";
441
+ type EconomyAuthorityCommitKindV1 = "genesis" | "first-party-command" | "provider-acceptance" | "provider-result" | "integrity-verification" | "state-transition" | "writer-fence-transition" | "reconstruction";
442
+ type EconomyAuthorityRecordKindV1 = "command-envelope" | "provider-evidence-manifest" | "provider-evidence" | "operational-handle-binding" | "workflow-event" | "accepted-receipt" | "result-receipt" | "journal-transaction" | "source-lot" | "source-lot-movement" | "gameplay-allocation" | "balance-projection" | "lifetime-projection" | "idempotency-result" | "outbox-event" | "work-item" | "dead-letter" | "integrity-receipt" | "integrity-anchor";
443
+ type EconomyAuthorityWriteKindV1 = "create" | "conditional-replace";
444
+ /**
445
+ * Canonical reference to one record created or conditionally replaced by an
446
+ * authority commit. Conditional replacements bind the previous content and a
447
+ * hash of the adapter's optimistic-concurrency token; unconditional replacement
448
+ * has no representation.
449
+ */
450
+ interface EconomyAuthorityRecordReferenceV1 {
451
+ readonly schemaVersion: EconomyContractVersion;
452
+ readonly recordKind: EconomyAuthorityRecordKindV1;
453
+ readonly recordId: string;
454
+ readonly writeKind: EconomyAuthorityWriteKindV1;
455
+ readonly contentHash: string;
456
+ readonly previousContentHash?: string;
457
+ readonly expectedConcurrencyTokenHash?: string;
458
+ }
459
+ /**
460
+ * Immutable, hash-linked record of one authoritative atomic boundary.
461
+ *
462
+ * First-party commands carry acceptance and terminal effects in one manifest.
463
+ * Provider commands use a provider-acceptance manifest followed by a
464
+ * provider-result manifest after external reconciliation.
465
+ */
466
+ interface EconomyAuthorityCommitManifestV1 {
467
+ readonly schemaVersion: EconomyContractVersion;
468
+ readonly commitId: string;
469
+ readonly authorityId: string;
470
+ readonly sequence: string;
471
+ readonly commitKind: EconomyAuthorityCommitKindV1;
472
+ readonly previousCommitHash?: string;
473
+ readonly commandId?: string;
474
+ readonly correlationId?: string;
475
+ readonly authorityStateBefore: EconomyAuthorityStateV1;
476
+ readonly authorityStateAfter: EconomyAuthorityStateV1;
477
+ readonly stateReasonCode?: string;
478
+ readonly recoveryVerificationReceiptId?: string;
479
+ readonly recoveryVerificationReceiptHash?: string;
480
+ readonly dualApprovalEvidenceHash?: string;
481
+ readonly writerRegion: string;
482
+ readonly writerFencingToken: string;
483
+ readonly recordReferences: readonly EconomyAuthorityRecordReferenceV1[];
484
+ readonly committedAt: IsoTimestamp;
485
+ }
486
+ /** Compare-and-swap projection for the singleton authority head. */
487
+ interface EconomyAuthorityHeadV1 {
488
+ readonly schemaVersion: EconomyContractVersion;
489
+ readonly authorityId: string;
490
+ readonly version: string;
491
+ readonly state: EconomyAuthorityStateV1;
492
+ readonly lastCommitId?: string;
493
+ readonly lastCommitHash?: string;
494
+ readonly writerRegion: string;
495
+ readonly writerFencingToken: string;
496
+ readonly updatedAt: IsoTimestamp;
497
+ }
498
+ /** Manifest plus the canonical hash calculated by an approved adapter. */
499
+ interface HashedEconomyAuthorityCommitManifestV1 {
500
+ readonly schemaVersion: EconomyContractVersion;
501
+ readonly manifest: EconomyAuthorityCommitManifestV1;
502
+ readonly canonicalHash: string;
503
+ }
504
+ type EconomyIntegrityVerificationStatusV1 = "valid" | "invalid";
505
+ type EconomyIntegrityFailureCodeV1 = "authority-head-mismatch" | "commit-hash-mismatch" | "commit-link-mismatch" | "record-hash-mismatch" | "journal-head-mismatch" | "projection-mismatch";
506
+ /** Immutable, privacy-safe evidence of one bounded integrity verification. */
507
+ interface EconomyIntegrityVerificationReceiptV1 {
508
+ readonly schemaVersion: EconomyContractVersion;
509
+ readonly verificationId: string;
510
+ readonly authorityId: string;
511
+ readonly status: EconomyIntegrityVerificationStatusV1;
512
+ readonly checkedThroughSequence: string;
513
+ readonly checkedCommits: string;
514
+ readonly checkedRecords: string;
515
+ readonly expectedAuthorityHeadHash: string;
516
+ readonly observedAuthorityHeadHash: string;
517
+ readonly expectedJournalHeadHash?: string;
518
+ readonly observedJournalHeadHash?: string;
519
+ readonly expectedProjectionSetHash?: string;
520
+ readonly observedProjectionSetHash?: string;
521
+ readonly anchorManifestHash?: string;
522
+ readonly failureCode?: EconomyIntegrityFailureCodeV1;
523
+ readonly firstInvalidCommitId?: string;
524
+ readonly firstInvalidRecordId?: string;
525
+ readonly verifiedAt: IsoTimestamp;
526
+ }
527
+ /**
528
+ * Canonical hourly Merkle-root manifest. Signing and storage are deliberately
529
+ * infrastructure responsibilities; this contract contains no private key,
530
+ * signature, storage URI, or administrator-proof claim.
531
+ */
532
+ interface EconomyIntegrityAnchorManifestV1 {
533
+ readonly schemaVersion: EconomyContractVersion;
534
+ readonly anchorId: string;
535
+ readonly authorityId: string;
536
+ readonly firstCommitSequence: string;
537
+ readonly lastCommitSequence: string;
538
+ readonly leafCount: string;
539
+ readonly merkleRootHash: string;
540
+ readonly authorityHeadHash: string;
541
+ readonly producedAt: IsoTimestamp;
542
+ }
543
+ /** Validates one create-only or optimistic conditional-replace reference. */
544
+ declare function assertEconomyAuthorityRecordReference(reference: EconomyAuthorityRecordReferenceV1): void;
545
+ /** Validates one immutable authority commit manifest. */
546
+ declare function assertEconomyAuthorityCommitManifest(manifest: EconomyAuthorityCommitManifestV1): void;
547
+ /** Validates an empty or populated singleton authority head. */
548
+ declare function assertEconomyAuthorityHead(head: EconomyAuthorityHeadV1): void;
549
+ /**
550
+ * Proves that a canonical manifest advances the locked singleton authority
551
+ * head by exactly one sequence and returns the compare-and-swap replacement.
552
+ */
553
+ declare function advanceEconomyAuthorityHead(head: EconomyAuthorityHeadV1, manifest: EconomyAuthorityCommitManifestV1, manifestCanonicalHash: string): EconomyAuthorityHeadV1;
554
+ /** Validates one append-only result from a bounded integrity check. */
555
+ declare function assertEconomyIntegrityVerificationReceipt(receipt: EconomyIntegrityVerificationReceiptV1): void;
556
+ /** Validates one canonical hourly Merkle-root manifest. */
557
+ declare function assertEconomyIntegrityAnchorManifest(manifest: EconomyIntegrityAnchorManifestV1): void;
558
+ /** Produces deterministic UTF-8 JSON for a singleton authority head. */
559
+ declare function canonicalEconomyAuthorityHeadPayload(head: EconomyAuthorityHeadV1): string;
560
+ /** Produces deterministic UTF-8 JSON for an authority commit manifest. */
561
+ declare function canonicalEconomyAuthorityCommitManifestPayload(manifest: EconomyAuthorityCommitManifestV1): string;
562
+ /** Produces deterministic UTF-8 JSON for an integrity-verification receipt. */
563
+ declare function canonicalEconomyIntegrityVerificationReceiptPayload(receipt: EconomyIntegrityVerificationReceiptV1): string;
564
+ /** Produces deterministic UTF-8 JSON for an hourly integrity anchor. */
565
+ declare function canonicalEconomyIntegrityAnchorManifestPayload(manifest: EconomyIntegrityAnchorManifestV1): string;
566
+ /**
567
+ * Proves that a reopening manifest binds a successful verification receipt.
568
+ * The consuming service remains responsible for its maximum allowed age.
569
+ */
570
+ declare function assertEconomyAuthorityRecoveryEvidence(manifest: EconomyAuthorityCommitManifestV1, receipt: EconomyIntegrityVerificationReceiptV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): void;
571
+ /**
572
+ * Returns a copy in the canonical record-reference order expected by manifests.
573
+ * Construction helpers may use this before validation; canonicalization itself
574
+ * never silently reorders a malformed manifest.
575
+ */
576
+ declare function sortEconomyAuthorityRecordReferences(references: readonly EconomyAuthorityRecordReferenceV1[]): readonly EconomyAuthorityRecordReferenceV1[];
577
+
578
+ type WalletKind = "household-treasury" | "personal" | "gameplay-allocation" | "hold" | "purchase-clearing" | "provider-clearing" | "system";
579
+ type WalletStatus = "active" | "restricted" | "closed";
580
+ type WalletOwnerType = "account" | "household" | "system";
581
+ /** Exact owner identity used by persistence lookups and IDOR-safe locking. */
582
+ interface WalletOwnerReferenceV1 {
583
+ readonly ownerType: WalletOwnerType;
584
+ readonly ownerId: AccountId | HouseholdId | "system";
585
+ }
586
+ /** Versioned authoritative wallet descriptor. */
587
+ interface WalletV1 {
588
+ readonly schemaVersion: EconomyContractVersion;
589
+ readonly walletId: WalletId;
590
+ readonly accountId: AccountId;
591
+ readonly kind: WalletKind;
592
+ readonly ownerType: WalletOwnerType;
593
+ readonly ownerId: AccountId | HouseholdId | "system";
594
+ readonly householdId?: HouseholdId;
595
+ readonly status: WalletStatus;
596
+ readonly version: number;
597
+ readonly createdAt: IsoTimestamp;
598
+ readonly closedAt?: IsoTimestamp;
599
+ }
600
+ /** Server-computed wallet totals. Clients must never derive authority from it. */
601
+ interface WalletBalanceSummaryV1 {
602
+ readonly schemaVersion: EconomyContractVersion;
603
+ readonly walletId: WalletId;
604
+ readonly available: TokenSubunitString;
605
+ readonly reserved: TokenSubunitString;
606
+ readonly held: TokenSubunitString;
607
+ readonly rewardProgress: TokenSubunitString;
608
+ readonly version: number;
609
+ readonly asOf: IsoTimestamp;
610
+ }
611
+ /** Lifetime aggregates used by the Token profile. */
612
+ interface WalletLifetimeTotalsV1 {
613
+ readonly schemaVersion: EconomyContractVersion;
614
+ readonly bought: TokenSubunitString;
615
+ readonly earned: TokenSubunitString;
616
+ readonly allocated: TokenSubunitString;
617
+ readonly reclaimed: TokenSubunitString;
618
+ readonly spent: TokenSubunitString;
619
+ readonly reversed: TokenSubunitString;
620
+ }
621
+ /** Validates an exact wallet owner without accepting a browser-derived role. */
622
+ declare function assertWalletOwnerReference(owner: WalletOwnerReferenceV1): void;
623
+ /** Validates wallet ownership, lifecycle, and optimistic-version facts. */
624
+ declare function assertWallet(wallet: WalletV1): void;
625
+ /** Validates non-negative server-computed wallet balance categories. */
626
+ declare function assertWalletBalanceSummary(summary: WalletBalanceSummaryV1): void;
627
+ /** Validates non-negative lifetime aggregates exposed by the profile API. */
628
+ declare function assertWalletLifetimeTotals(totals: WalletLifetimeTotalsV1): void;
629
+
630
+ type BalanceProjection = Readonly<Record<AccountId, TokenSubunitString>>;
631
+ interface BalanceProjectionSnapshotV1 {
632
+ readonly schemaVersion: EconomyContractVersion;
633
+ readonly balances: BalanceProjection;
634
+ readonly lastTransactionId?: TransactionId;
635
+ readonly rebuiltAt: IsoTimestamp;
636
+ }
637
+ type WalletProjectionBucket = "spendable" | "reserved" | "held";
638
+ /** Exclusive stored buckets for one wallet; reward progress is derived. */
639
+ interface WalletBalanceProjectionV1 {
640
+ readonly schemaVersion: EconomyContractVersion;
641
+ readonly walletId: WalletId;
642
+ readonly spendable: TokenSubunitString;
643
+ readonly reserved: TokenSubunitString;
644
+ readonly held: TokenSubunitString;
645
+ readonly version: number;
646
+ readonly lastTransactionId?: TransactionId;
647
+ readonly asOf: IsoTimestamp;
648
+ }
649
+ /** One atomic add operation against all exclusive buckets of a wallet. */
650
+ interface WalletBalanceDeltaV1 {
651
+ readonly schemaVersion: EconomyContractVersion;
652
+ readonly walletId: WalletId;
653
+ readonly spendableDelta: TokenSubunitString;
654
+ readonly reservedDelta: TokenSubunitString;
655
+ readonly heldDelta: TokenSubunitString;
656
+ }
657
+ /** Authoritative mapping from a ledger account to one wallet bucket. */
658
+ interface WalletPostingAccountBindingV1 {
659
+ readonly accountId: AccountId;
660
+ readonly walletId: WalletId;
661
+ readonly bucket: WalletProjectionBucket;
662
+ }
663
+ type WalletLifetimeBucket = "bought" | "earned" | "allocated" | "reclaimed" | "spent" | "reversed";
664
+ /** Positive monotonic contribution to one wallet lifetime counter. */
665
+ interface WalletLifetimeDeltaV1 {
666
+ readonly schemaVersion: EconomyContractVersion;
667
+ readonly walletId: WalletId;
668
+ readonly bucket: WalletLifetimeBucket;
669
+ readonly amount: TokenSubunitString;
670
+ }
671
+ /** Validates one exclusive-bucket projection. */
672
+ declare function assertWalletBalanceProjection(projection: WalletBalanceProjectionV1): void;
673
+ /** Validates one non-zero atomic wallet delta. */
674
+ declare function assertWalletBalanceDelta(delta: WalletBalanceDeltaV1): void;
675
+ /** Rejects duplicate wallet updates before one atomic persistence call. */
676
+ declare function assertWalletBalanceDeltaBatch(transactionId: TransactionId, deltas: readonly WalletBalanceDeltaV1[]): void;
677
+ /** Applies an atomic add locally for deterministic tests and rebuilds. */
678
+ declare function applyWalletBalanceDelta(projection: WalletBalanceProjectionV1, delta: WalletBalanceDeltaV1, transactionId: TransactionId, asOf: IsoTimestamp): WalletBalanceProjectionV1;
679
+ /**
680
+ * Converts exclusive storage buckets to the legacy display DTO. Available is
681
+ * independently usable whole Tokens in this wallet; rewardProgress is this
682
+ * wallet's sub-Token remainder and is never netted with another wallet.
683
+ */
684
+ declare function createWalletBalanceSummary(projection: WalletBalanceProjectionV1): WalletBalanceSummaryV1;
685
+ /** Enforces the stronger per-wallet semantics required by V1 query adapters. */
686
+ declare function assertDeterministicWalletBalanceSummary(summary: WalletBalanceSummaryV1): void;
687
+ /**
688
+ * Derives a single delta per wallet from wallet-linked postings and an
689
+ * authoritative account-to-bucket mapping. Unlinked system postings are not
690
+ * wallet projections.
691
+ */
692
+ declare function deriveWalletBalanceDeltas(transaction: EconomicJournalTransactionV1, bindings: readonly WalletPostingAccountBindingV1[]): readonly WalletBalanceDeltaV1[];
693
+ /**
694
+ * Rebuilds monotonic gross lifetime contributions from a settled transaction.
695
+ * Earlier bought/earned counters are never reduced by a later compensating
696
+ * transaction; removals accrue separately in `reversed`.
697
+ */
698
+ declare function deriveWalletLifetimeDeltas(transaction: EconomicJournalTransactionV1): readonly WalletLifetimeDeltaV1[];
699
+ /** Applies positive lifetime deltas for one wallet without rewriting history. */
700
+ declare function applyWalletLifetimeDeltas(current: WalletLifetimeTotalsV1, walletId: WalletId, deltas: readonly WalletLifetimeDeltaV1[]): WalletLifetimeTotalsV1;
701
+ /** Applies one balanced transaction without mutating the existing projection. */
702
+ declare function applyTransactionToProjection(current: BalanceProjection, transaction: LedgerTransactionV1): BalanceProjection;
703
+ /**
704
+ * Rebuilds balances deterministically and rejects duplicate economic envelopes.
705
+ */
706
+ declare function rebuildBalanceProjection(transactions: readonly LedgerTransactionV1[]): BalanceProjection;
707
+ /** Enforces non-negative balances only for spendable/reservable accounts. */
708
+ declare function assertNonNegativeAccounts(projection: BalanceProjection, protectedAccountIds: readonly AccountId[]): void;
709
+ /** Creates a versioned snapshot after a deterministic rebuild. */
710
+ declare function createProjectionSnapshot(transactions: readonly LedgerTransactionV1[], rebuiltAt: IsoTimestamp): BalanceProjectionSnapshotV1;
711
+
712
+ type EconomyCommandType = "credit-purchase" | "credit-subscription" | "credit-reward" | "credit-event" | "credit-competition" | "allocate" | "boost" | "reclaim" | "spend" | "hold" | "release-hold" | "refund" | "chargeback" | "reverse" | "adjust";
713
+ interface EconomyCommandEnvelopeV1 {
714
+ readonly schemaVersion: EconomyContractVersion;
715
+ readonly commandId: string;
716
+ readonly commandType: EconomyCommandType;
717
+ readonly idempotencyKey: string;
718
+ readonly actorAccountId: AccountId;
719
+ readonly subjectAccountId: AccountId;
720
+ readonly relationshipId?: string;
721
+ readonly authorizationVersion?: number;
722
+ readonly payloadHash: string;
723
+ readonly acceptedAt: IsoTimestamp;
724
+ readonly acceptedRegion: string;
725
+ readonly writerFencingToken: string;
726
+ }
727
+ type EconomyCommandWorkflowStateV1 = "accepted" | "processing" | "failed" | "completed";
728
+ /** Immutable workflow evidence; it is never an economic journal transaction. */
729
+ interface EconomyCommandWorkflowEventV1 {
730
+ readonly schemaVersion: EconomyContractVersion;
731
+ readonly workflowEventId: string;
732
+ readonly commandId: string;
733
+ readonly state: EconomyCommandWorkflowStateV1;
734
+ /** Stable non-sensitive classifier; detailed failure data stays operational. */
735
+ readonly failureCode?: string;
736
+ readonly occurredAt: IsoTimestamp;
737
+ }
738
+ interface EconomyOutboxEventV1 {
739
+ readonly schemaVersion: EconomyContractVersion;
740
+ readonly eventId: string;
741
+ readonly transactionId: TransactionId;
742
+ readonly eventType: string;
743
+ readonly payloadHash: string;
744
+ readonly occurredAt: IsoTimestamp;
745
+ }
746
+ interface PersistedIdempotencyResultV1 {
747
+ readonly transactionId: TransactionId;
748
+ readonly responseHash: string;
749
+ readonly recordedAt: IsoTimestamp;
750
+ }
751
+ /** Exact actor/subject/operation namespace for a caller-owned idempotency key. */
752
+ interface EconomyIdempotencyScopeV1 {
753
+ readonly schemaVersion: EconomyContractVersion;
754
+ readonly idempotencyKey: string;
755
+ readonly commandType: EconomyCommandType;
756
+ readonly actorAccountId: AccountId;
757
+ readonly subjectAccountId: AccountId;
758
+ }
759
+ /** V2 replay evidence bound to one accepted command and exact scope. */
760
+ interface ScopedPersistedIdempotencyResultV1 extends PersistedIdempotencyResultV1 {
761
+ readonly schemaVersion: EconomyContractVersion;
762
+ readonly commandId: string;
763
+ }
764
+ /** Validates replay evidence before it is returned across a command boundary. */
765
+ declare function assertScopedPersistedIdempotencyResult(result: ScopedPersistedIdempotencyResultV1): void;
766
+ /** Validates the namespace that prevents cross-principal replay collisions. */
767
+ declare function assertEconomyIdempotencyScope(scope: EconomyIdempotencyScopeV1): void;
768
+ /** Validates minimized accepted-command evidence before durable append. */
769
+ declare function assertEconomyCommandEnvelope(envelope: EconomyCommandEnvelopeV1): void;
770
+ /** Validates one immutable command-workflow state event. */
771
+ declare function assertEconomyCommandWorkflowEvent(event: EconomyCommandWorkflowEventV1): void;
772
+ /** Operations available only inside one serializable database transaction. */
773
+ interface EconomyUnitOfWork {
774
+ getWalletForUpdate(walletId: WalletId): Promise<WalletV1 | null>;
775
+ listSpendableLotsForUpdate(walletId: WalletId): Promise<readonly SourceLotV1[]>;
776
+ findLotForUpdate(lotId: LotId): Promise<SourceLotV1 | null>;
777
+ findIdempotencyResult(idempotencyKey: string): Promise<PersistedIdempotencyResultV1 | null>;
778
+ appendTransaction(transaction: LedgerTransactionV1): Promise<void>;
779
+ appendSourceLot(lot: SourceLotV1): Promise<void>;
780
+ updateSourceLotProjection(lotId: LotId, remainingAmount: TokenSubunitString, heldAmount: TokenSubunitString, reversedAmount: TokenSubunitString): Promise<void>;
781
+ saveBalanceProjection(projection: BalanceProjection, transactionId: TransactionId): Promise<void>;
782
+ saveIdempotencyResult(idempotencyKey: string, result: PersistedIdempotencyResultV1): Promise<void>;
783
+ appendOutboxEvent(event: EconomyOutboxEventV1): Promise<void>;
784
+ }
785
+ /** Adapter boundary for serializable, ACID economy mutations. */
786
+ interface EconomyPersistencePort {
787
+ runSerializable<T>(operation: (unitOfWork: EconomyUnitOfWork) => Promise<T>): Promise<T>;
788
+ getWallet(walletId: WalletId): Promise<WalletV1 | null>;
789
+ getBalanceProjection(walletId: WalletId): Promise<BalanceProjectionSnapshotV1 | null>;
790
+ getTransaction(transactionId: TransactionId): Promise<LedgerTransactionV1 | null>;
791
+ rebuildProjection(): Promise<BalanceProjection>;
792
+ }
793
+ /**
794
+ * V2 mutation surface. Unlike `EconomyUnitOfWork`, it has no absolute balance
795
+ * overwrite: journal, source-lot movement, allocation state, balance/lifetime
796
+ * deltas, idempotency, chain head, and outbox are committed atomically.
797
+ */
798
+ interface EconomyUnitOfWorkV2 {
799
+ getWalletForOwnerForUpdate(walletId: WalletId, owner: WalletOwnerReferenceV1): Promise<WalletV1 | null>;
800
+ listSpendableLotsForUpdate(walletId: WalletId): Promise<readonly VersionedSourceLotV1[]>;
801
+ findLotForUpdate(lotId: LotId): Promise<VersionedSourceLotV1 | null>;
802
+ getGameplayAllocationForUpdate(allocationId: AllocationId, householdId: HouseholdId, childAccountId: AccountId): Promise<GameplayAllocationV1 | null>;
803
+ findIdempotencyResult(scope: EconomyIdempotencyScopeV1): Promise<ScopedPersistedIdempotencyResultV1 | null>;
804
+ /** Locks and rejects any stale/non-active regional writer lease. */
805
+ lockActiveWriterFence(acceptedRegion: string, writerFencingToken: string): Promise<void>;
806
+ lockJournalChainHead(chainId: string): Promise<JournalChainHeadV1>;
807
+ appendCommandEnvelope(envelope: EconomyCommandEnvelopeV1): Promise<void>;
808
+ appendCommandWorkflowEvent(event: EconomyCommandWorkflowEventV1): Promise<void>;
809
+ appendTransaction(transaction: ChainedEconomicJournalTransactionV1): Promise<void>;
810
+ /** Appends `createInitialSourceLotSnapshot()` output; later changes are movements. */
811
+ appendSourceLot(snapshot: VersionedSourceLotV1): Promise<void>;
812
+ /** Appends movement evidence and applies its lot CAS as one operation. */
813
+ applySourceLotMovement(movement: SourceLotMovementV1): Promise<void>;
814
+ appendGameplayAllocation(allocation: GameplayAllocationV1): Promise<void>;
815
+ /**
816
+ * Compares `expectedVersion`, requires `allocation.version` to be exactly the
817
+ * next value, and never overwrites a stale row.
818
+ */
819
+ saveGameplayAllocation(allocation: GameplayAllocationV1, expectedVersion: number): Promise<void>;
820
+ /**
821
+ * Atomically adds deltas, verifies them against the appended postings and
822
+ * account bindings, and records transaction-scoped application keys.
823
+ */
824
+ applyWalletBalanceDeltas(transactionId: TransactionId, deltas: readonly WalletBalanceDeltaV1[]): Promise<void>;
825
+ /**
826
+ * Atomically increments monotonic lifetime counters after verifying the
827
+ * deltas against the appended transaction's deterministic classification.
828
+ */
829
+ applyWalletLifetimeDeltas(transactionId: TransactionId, deltas: readonly WalletLifetimeDeltaV1[]): Promise<void>;
830
+ saveIdempotencyResult(scope: EconomyIdempotencyScopeV1, result: ScopedPersistedIdempotencyResultV1): Promise<void>;
831
+ appendOutboxEvent(event: EconomyOutboxEventV1): Promise<void>;
832
+ /** Compare-and-swaps the full locked head, including its canonical hash. */
833
+ advanceJournalChainHead(expected: JournalChainHeadV1, next: JournalChainHeadV1): Promise<void>;
834
+ }
835
+ /**
836
+ * Additive authoritative persistence boundary for new consumers. V1 remains
837
+ * exported for compatibility but must not be adapted by delegating its
838
+ * absolute `saveBalanceProjection` operation to this interface.
839
+ */
840
+ interface EconomyPersistencePortV2 {
841
+ runSerializable<T>(operation: (unitOfWork: EconomyUnitOfWorkV2) => Promise<T>): Promise<T>;
842
+ getWallet(walletId: WalletId): Promise<WalletV1 | null>;
843
+ listWalletsByOwner(owner: WalletOwnerReferenceV1): Promise<readonly WalletV1[]>;
844
+ getGameplayAllocation(allocationId: AllocationId, householdId: HouseholdId, childAccountId: AccountId): Promise<GameplayAllocationV1 | null>;
845
+ getCommandEnvelope(commandId: string): Promise<EconomyCommandEnvelopeV1 | null>;
846
+ getTransaction(transactionId: TransactionId): Promise<ChainedEconomicJournalTransactionV1 | null>;
847
+ rebuildWalletBalanceProjections(): Promise<readonly WalletBalanceProjectionV1[]>;
848
+ }
849
+ /**
850
+ * V3 journal transaction whose legacy canonical `idempotencyKey` slot carries
851
+ * the HMAC digest, never the raw HTTP Idempotency-Key. The wire field remains
852
+ * unchanged so published transaction canonical bytes stay compatible.
853
+ */
854
+ type AuditedChainedEconomicJournalTransactionV1 = Omit<ChainedEconomicJournalTransactionV1, "idempotencyKey"> & {
855
+ readonly idempotencyKey: EconomyHmacSha256DigestV1;
856
+ };
857
+ /**
858
+ * Additive audit-capable mutation surface.
859
+ *
860
+ * First-party commands append acceptance, economic result, projections,
861
+ * idempotency result, outbox, authority manifest, and authority-head CAS in one
862
+ * serializable unit. Provider workflows use one unit for verified durable
863
+ * acceptance and a second unit for the reconciled economic result.
864
+ */
865
+ type EconomyUnitOfWorkV3 = Omit<EconomyUnitOfWorkV2, "appendCommandEnvelope" | "findIdempotencyResult" | "saveIdempotencyResult" | "appendTransaction"> & {
866
+ findAuditedIdempotencyResult(scope: EconomyAuditedIdempotencyScopeV1): Promise<EconomyAuditedIdempotencyResultV1 | null>;
867
+ lockAuthorityHead(authorityId: string): Promise<EconomyAuthorityHeadV1>;
868
+ appendCommandEnvelope(envelope: AuditedEconomyCommandEnvelopeV1): Promise<void>;
869
+ appendProviderEvidenceManifest(manifest: EconomyProviderEvidenceManifestV1): Promise<void>;
870
+ appendProviderEvidence(evidence: EconomyProviderEvidenceHashV1): Promise<void>;
871
+ appendEncryptedOperationalHandleBinding(binding: EconomyEncryptedOperationalHandleBindingV1): Promise<void>;
872
+ appendAcceptedCommandReceipt(receipt: EconomyAcceptedCommandReceiptV1): Promise<void>;
873
+ appendCommandResultReceipt(receipt: EconomyCommandResultReceiptV1): Promise<void>;
874
+ appendTransaction(transaction: AuditedChainedEconomicJournalTransactionV1): Promise<void>;
875
+ saveAuditedIdempotencyResult(scope: EconomyAuditedIdempotencyScopeV1, result: EconomyAuditedIdempotencyResultV1): Promise<void>;
876
+ appendAuthorityCommitManifest(manifest: EconomyAuthorityCommitManifestV1): Promise<void>;
877
+ advanceAuthorityHead(expected: EconomyAuthorityHeadV1, next: EconomyAuthorityHeadV1): Promise<void>;
878
+ appendIntegrityVerificationReceipt(receipt: EconomyIntegrityVerificationReceiptV1): Promise<void>;
879
+ appendIntegrityAnchorManifest(manifest: EconomyIntegrityAnchorManifestV1): Promise<void>;
880
+ };
881
+ /**
882
+ * V3 preserves every V2 economic primitive while making the audit records
883
+ * mandatory capabilities of an authoritative adapter. V1 and V2 remain
884
+ * exported unchanged for existing consumers.
885
+ */
886
+ type EconomyPersistencePortV3 = Omit<EconomyPersistencePortV2, "runSerializable" | "getCommandEnvelope" | "getTransaction"> & {
887
+ runSerializable<T>(operation: (unitOfWork: EconomyUnitOfWorkV3) => Promise<T>): Promise<T>;
888
+ getCommandEnvelope(commandId: string): Promise<AuditedEconomyCommandEnvelopeV1 | null>;
889
+ getTransaction(transactionId: TransactionId): Promise<AuditedChainedEconomicJournalTransactionV1 | null>;
890
+ getAcceptedCommandReceipt(commandId: string): Promise<EconomyAcceptedCommandReceiptV1 | null>;
891
+ getCommandResultReceipt(commandId: string): Promise<EconomyCommandResultReceiptV1 | null>;
892
+ listProviderEvidence(commandId: string): Promise<readonly EconomyProviderEvidenceHashV1[]>;
893
+ getProviderEvidenceManifest(commandId: string): Promise<EconomyProviderEvidenceManifestV1 | null>;
894
+ listEncryptedOperationalHandleBindings(commandId: string): Promise<readonly EconomyEncryptedOperationalHandleBindingV1[]>;
895
+ getAuthorityHead(authorityId: string): Promise<EconomyAuthorityHeadV1 | null>;
896
+ getAuthorityCommitManifest(commitId: string): Promise<EconomyAuthorityCommitManifestV1 | null>;
897
+ getIntegrityVerificationReceipt(verificationId: string): Promise<EconomyIntegrityVerificationReceiptV1 | null>;
898
+ getIntegrityAnchorManifest(anchorId: string): Promise<EconomyIntegrityAnchorManifestV1 | null>;
899
+ };
900
+ interface EconomyClockPort {
901
+ now(): IsoTimestamp;
902
+ }
903
+ interface EconomyIdPort {
904
+ nextId(namespace: string): string;
905
+ }
906
+
907
+ type EconomyCommandSourceV1 = "browser" | "shopify" | "ayet" | "bitlabs" | "operator" | "system";
908
+ type EconomyCommandProcessingModeV1 = "initial" | "replay";
909
+ type EconomyPrincipalTypeV1 = "account" | "delegated-child" | "service" | "operator";
910
+ type EconomyCausationKindV1 = "provider-event" | "economy-command" | "ledger-transaction" | "workflow-event" | "authority-commit";
911
+ /** One privacy-safe edge in an economy audit correlation graph. */
912
+ interface EconomyCausationReferenceV1 {
913
+ readonly schemaVersion: EconomyContractVersion;
914
+ readonly kind: EconomyCausationKindV1;
915
+ readonly causationId: string;
916
+ }
917
+ type EconomyHmacFingerprintDomainV1 = "economy.idempotency-key.v1" | "economy.provider-event-key.v1" | "economy.provider-object-key.v1" | "economy.provider-payload.v1" | "economy.provider-reconciliation.v1";
918
+ type EconomyHmacSha256DigestV1 = `hmac-sha256:${string}`;
919
+ /**
920
+ * A versioned, domain-separated HMAC fingerprint produced by an approved
921
+ * infrastructure adapter. It is a correlation token, not reversible evidence.
922
+ */
923
+ interface EconomyHmacFingerprintV1 {
924
+ readonly schemaVersion: EconomyContractVersion;
925
+ readonly fingerprintVersion: "1";
926
+ readonly algorithm: "hmac-sha256";
927
+ readonly domain: EconomyHmacFingerprintDomainV1;
928
+ readonly keyVersion: string;
929
+ readonly digest: EconomyHmacSha256DigestV1;
930
+ }
931
+ /**
932
+ * Hashes of sanitized authorization-decision manifests. The manifests must
933
+ * contain no raw tokens, capability payloads, session IDs, or personal data.
934
+ */
935
+ interface EconomyAuthorizationEvidenceV1 {
936
+ readonly schemaVersion: EconomyContractVersion;
937
+ readonly capabilityEvidenceHash: string;
938
+ readonly featureFlagEvidenceHash: string;
939
+ readonly assuranceEvidenceHash: string;
940
+ readonly authenticatedAt: IsoTimestamp;
941
+ readonly authorizedAt: IsoTimestamp;
942
+ }
943
+ /**
944
+ * Privacy-minimized command facts for the authoritative V3 boundary.
945
+ *
946
+ * This is deliberately standalone rather than extending
947
+ * `EconomyCommandEnvelopeV1`: the published legacy envelope contains a raw
948
+ * caller idempotency key, which must never enter new audit storage.
949
+ */
950
+ interface AuditedEconomyCommandEnvelopeV1 {
951
+ readonly schemaVersion: EconomyContractVersion;
952
+ readonly commandId: string;
953
+ readonly commandType: EconomyCommandType;
954
+ readonly commandSource: EconomyCommandSourceV1;
955
+ readonly idempotencyFingerprint: EconomyHmacFingerprintV1;
956
+ readonly actorAccountId: AccountId;
957
+ readonly subjectAccountId: AccountId;
958
+ readonly principalType: EconomyPrincipalTypeV1;
959
+ readonly relationshipId?: string;
960
+ readonly authorizationVersion?: number;
961
+ readonly authorizationEvidence: EconomyAuthorizationEvidenceV1;
962
+ readonly routeId: string;
963
+ readonly buildId: string;
964
+ readonly correlationId: string;
965
+ readonly causation?: EconomyCausationReferenceV1;
966
+ /**
967
+ * SHA-256 of the canonical, already-sanitized semantic command payload.
968
+ * Provider callback bytes use an HMAC fingerprint instead.
969
+ */
970
+ readonly payloadHash: string;
971
+ readonly providerEvidenceManifestHash?: string;
972
+ readonly acceptedAt: IsoTimestamp;
973
+ readonly acceptedRegion: string;
974
+ readonly writerFencingToken: string;
975
+ }
976
+ type EconomyAcquisitionProviderV1 = "shopify" | "ayet" | "bitlabs";
977
+ /**
978
+ * Privacy-minimized verified provider evidence. Every value derived from a raw
979
+ * provider identifier or callback body is represented by a domain-separated
980
+ * HMAC fingerprint. Signatures and payment data have no storage field.
981
+ */
982
+ interface EconomyProviderEvidenceHashV1 {
983
+ readonly schemaVersion: EconomyContractVersion;
984
+ /** Opaque internal identifier; never the provider's event identifier. */
985
+ readonly providerEventId: ProviderEventId;
986
+ readonly commandId: string;
987
+ readonly provider: EconomyAcquisitionProviderV1;
988
+ readonly providerObjectKeyFingerprint?: EconomyHmacFingerprintV1;
989
+ readonly providerEventKeyFingerprint: EconomyHmacFingerprintV1;
990
+ readonly eventType: string;
991
+ readonly payloadFingerprint: EconomyHmacFingerprintV1;
992
+ readonly reconciliationEvidenceFingerprint?: EconomyHmacFingerprintV1;
993
+ readonly signatureScheme: string;
994
+ readonly signatureVerifiedAt: IsoTimestamp;
995
+ readonly providerOccurredAt?: IsoTimestamp;
996
+ readonly receivedAt: IsoTimestamp;
997
+ readonly operationalHandleBindingId?: string;
998
+ }
999
+ type EconomyOperationalHandlePurposeV1 = "reconciliation" | "refund" | "dispute";
1000
+ /**
1001
+ * Ledger-side binding for a provider handle encrypted and retained by the
1002
+ * consuming site. The ciphertext, nonce, authentication tag, and key URI are
1003
+ * not package fields; only hashes and non-secret cryptographic metadata bind
1004
+ * the external sealed record.
1005
+ */
1006
+ interface EconomyEncryptedOperationalHandleBindingV1 {
1007
+ readonly schemaVersion: EconomyContractVersion;
1008
+ readonly handleBindingId: string;
1009
+ readonly commandId: string;
1010
+ readonly provider: EconomyAcquisitionProviderV1;
1011
+ readonly purpose: EconomyOperationalHandlePurposeV1;
1012
+ readonly cipherSuite: "AES-256-GCM";
1013
+ readonly keyVersion: string;
1014
+ readonly ciphertextContentHash: string;
1015
+ readonly encryptionContextHash: string;
1016
+ readonly createdAt: IsoTimestamp;
1017
+ }
1018
+ /** One canonical content reference inside a sanitized evidence manifest. */
1019
+ interface EconomyEvidenceRecordReferenceV1 {
1020
+ readonly schemaVersion: EconomyContractVersion;
1021
+ readonly recordId: string;
1022
+ readonly contentHash: string;
1023
+ }
1024
+ /**
1025
+ * Sanitized manifest bound by an audited provider command. Its referenced
1026
+ * records contain HMAC fingerprints, never raw provider material.
1027
+ */
1028
+ interface EconomyProviderEvidenceManifestV1 {
1029
+ readonly schemaVersion: EconomyContractVersion;
1030
+ readonly evidenceManifestId: string;
1031
+ readonly commandId: string;
1032
+ readonly provider: EconomyAcquisitionProviderV1;
1033
+ readonly evidenceReferences: readonly EconomyEvidenceRecordReferenceV1[];
1034
+ readonly operationalHandleReferences: readonly EconomyEvidenceRecordReferenceV1[];
1035
+ readonly createdAt: IsoTimestamp;
1036
+ }
1037
+ /** Privacy-safe acknowledgement returned after durable command acceptance. */
1038
+ interface EconomyAcceptedCommandReceiptV1 {
1039
+ readonly schemaVersion: EconomyContractVersion;
1040
+ readonly receiptId: string;
1041
+ readonly commandId: string;
1042
+ readonly correlationId: string;
1043
+ readonly commandEnvelopeHash: string;
1044
+ readonly acceptedAt: IsoTimestamp;
1045
+ }
1046
+ type EconomyCommandResultOutcomeV1 = "completed" | "failed" | "no-op";
1047
+ /**
1048
+ * Immutable terminal receipt. A completed result binds one journal
1049
+ * transaction, a failed result binds one safe failure code, and a no-op binds
1050
+ * one safe reason proving that no economic transaction was required.
1051
+ */
1052
+ interface EconomyCommandResultReceiptV1 {
1053
+ readonly schemaVersion: EconomyContractVersion;
1054
+ readonly receiptId: string;
1055
+ readonly commandId: string;
1056
+ readonly correlationId: string;
1057
+ readonly acceptedReceiptId: string;
1058
+ readonly commandEnvelopeHash: string;
1059
+ readonly outcome: EconomyCommandResultOutcomeV1;
1060
+ readonly resultHash: string;
1061
+ readonly transactionId?: TransactionId;
1062
+ readonly transactionCanonicalHash?: string;
1063
+ readonly failureCode?: string;
1064
+ readonly noOpCode?: string;
1065
+ readonly recordedAt: IsoTimestamp;
1066
+ }
1067
+ /** Raw-key-free actor/subject namespace used by authoritative V3 replay. */
1068
+ interface EconomyAuditedIdempotencyScopeV1 {
1069
+ readonly schemaVersion: EconomyContractVersion;
1070
+ readonly idempotencyFingerprint: EconomyHmacFingerprintV1;
1071
+ readonly commandType: EconomyCommandType;
1072
+ readonly actorAccountId: AccountId;
1073
+ readonly subjectAccountId: AccountId;
1074
+ readonly principalType: EconomyPrincipalTypeV1;
1075
+ readonly relationshipId?: string;
1076
+ readonly authorizationVersion?: number;
1077
+ }
1078
+ type EconomyAuditedIdempotencyStateV1 = "accepted" | EconomyCommandResultOutcomeV1;
1079
+ /**
1080
+ * Persisted V3 replay result. The adapter returns this record for an exact
1081
+ * canonical scope match; a fingerprint collision with different canonical
1082
+ * command bytes is a security conflict, never a replay.
1083
+ */
1084
+ interface EconomyAuditedIdempotencyResultV1 {
1085
+ readonly schemaVersion: EconomyContractVersion;
1086
+ readonly commandId: string;
1087
+ readonly commandEnvelopeHash: string;
1088
+ readonly acceptedReceiptId: string;
1089
+ readonly resultReceiptId?: string;
1090
+ readonly state: EconomyAuditedIdempotencyStateV1;
1091
+ readonly responseHash: string;
1092
+ readonly recordedAt: IsoTimestamp;
1093
+ }
1094
+ type EconomyCommandProcessingDispositionV1 = {
1095
+ readonly mode: "initial";
1096
+ } | {
1097
+ readonly mode: "replay";
1098
+ readonly result: EconomyAuditedIdempotencyResultV1;
1099
+ };
1100
+ /** Validates a domain-separated HMAC fingerprint and its expected domain. */
1101
+ declare function assertEconomyHmacFingerprint(fingerprint: EconomyHmacFingerprintV1, expectedDomain?: EconomyHmacFingerprintDomainV1): void;
1102
+ /** Validates hashes of a sanitized, server-derived authorization decision. */
1103
+ declare function assertEconomyAuthorizationEvidence(evidence: EconomyAuthorizationEvidenceV1): void;
1104
+ /** Validates a fingerprint-only, server-derived authoritative command. */
1105
+ declare function assertAuditedEconomyCommandEnvelope(envelope: AuditedEconomyCommandEnvelopeV1): void;
1106
+ /** Validates privacy-minimized provider evidence before immutable append. */
1107
+ declare function assertEconomyProviderEvidenceHash(evidence: EconomyProviderEvidenceHashV1): void;
1108
+ /** Validates a ledger binding for site-owned encrypted provider state. */
1109
+ declare function assertEconomyEncryptedOperationalHandleBinding(binding: EconomyEncryptedOperationalHandleBindingV1): void;
1110
+ /** Validates a canonical sanitized provider-evidence manifest. */
1111
+ declare function assertEconomyProviderEvidenceManifest(manifest: EconomyProviderEvidenceManifestV1): void;
1112
+ /** Validates a client-safe durable-acceptance receipt. */
1113
+ declare function assertEconomyAcceptedCommandReceipt(receipt: EconomyAcceptedCommandReceiptV1): void;
1114
+ /** Validates the exclusive completed, failed, and no-op result shapes. */
1115
+ declare function assertEconomyCommandResultReceipt(receipt: EconomyCommandResultReceiptV1): void;
1116
+ /** Validates the raw-key-free idempotency namespace used by V3. */
1117
+ declare function assertEconomyAuditedIdempotencyScope(scope: EconomyAuditedIdempotencyScopeV1): void;
1118
+ /** Validates an exact accepted or terminal V3 replay result. */
1119
+ declare function assertEconomyAuditedIdempotencyResult(result: EconomyAuditedIdempotencyResultV1): void;
1120
+ /**
1121
+ * Produces deterministic UTF-8 JSON for an audited-command hash adapter.
1122
+ * The legacy transaction canonical payload remains a separate stable format.
1123
+ */
1124
+ declare function canonicalAuditedEconomyCommandEnvelopePayload(envelope: AuditedEconomyCommandEnvelopeV1): string;
1125
+ /** Produces deterministic UTF-8 JSON for privacy-minimized provider evidence. */
1126
+ declare function canonicalEconomyProviderEvidenceHashPayload(evidence: EconomyProviderEvidenceHashV1): string;
1127
+ /** Produces deterministic UTF-8 JSON for an encrypted-handle binding. */
1128
+ declare function canonicalEconomyEncryptedOperationalHandleBindingPayload(binding: EconomyEncryptedOperationalHandleBindingV1): string;
1129
+ /** Produces deterministic UTF-8 JSON for a sanitized evidence manifest. */
1130
+ declare function canonicalEconomyProviderEvidenceManifestPayload(manifest: EconomyProviderEvidenceManifestV1): string;
1131
+ /** Produces deterministic UTF-8 JSON for a privacy-safe accepted receipt. */
1132
+ declare function canonicalEconomyAcceptedCommandReceiptPayload(receipt: EconomyAcceptedCommandReceiptV1): string;
1133
+ /** Produces deterministic UTF-8 JSON for a terminal command receipt. */
1134
+ declare function canonicalEconomyCommandResultReceiptPayload(receipt: EconomyCommandResultReceiptV1): string;
1135
+ /**
1136
+ * Rejects a replay candidate unless every canonical accepted-command byte
1137
+ * matches. Processing mode is intentionally external to the envelope, so the
1138
+ * original command source remains unchanged on replay.
1139
+ */
1140
+ declare function assertExactAuditedEconomyCommandReplay(existing: AuditedEconomyCommandEnvelopeV1, candidate: AuditedEconomyCommandEnvelopeV1): void;
1141
+
1142
+ /** Complete bounded record graph for one accepted authoritative command. */
1143
+ interface EconomyAuditGraphV1 {
1144
+ readonly schemaVersion: EconomyContractVersion;
1145
+ readonly commandEnvelope: AuditedEconomyCommandEnvelopeV1;
1146
+ readonly commandEnvelopeHash: string;
1147
+ readonly providerEvidenceManifest?: EconomyProviderEvidenceManifestV1;
1148
+ readonly providerEvidence: readonly EconomyProviderEvidenceHashV1[];
1149
+ readonly operationalHandleBindings: readonly EconomyEncryptedOperationalHandleBindingV1[];
1150
+ readonly acceptedReceipt: EconomyAcceptedCommandReceiptV1;
1151
+ readonly resultReceipt?: EconomyCommandResultReceiptV1;
1152
+ readonly transaction?: EconomicJournalTransactionV1 & {
1153
+ readonly canonicalHash: string;
1154
+ };
1155
+ readonly startAuthorityHead: EconomyAuthorityHeadV1;
1156
+ readonly commits: readonly HashedEconomyAuthorityCommitManifestV1[];
1157
+ readonly expectedAuthorityHead: EconomyAuthorityHeadV1;
1158
+ }
1159
+ /**
1160
+ * Validates every actor/subject, evidence, receipt, transaction, record, and
1161
+ * authority-chain edge for one bounded command graph.
1162
+ *
1163
+ * The callback must hash exact canonical UTF-8 bytes using approved SHA-256.
1164
+ * Raw provider data and idempotency keys are neither accepted nor reconstructed.
1165
+ */
1166
+ declare function assertEconomyAuditGraph(graph: EconomyAuditGraphV1, hash: CanonicalPayloadHashFunctionV1): void;
1167
+
387
1168
  declare const PRE_UTILITY_BACKER_COHORT: "pre_utility_backer_v1";
388
1169
  interface EarlyBackerWindowV1 {
389
1170
  readonly publicTokensLaunchAt: IsoTimestamp;
@@ -460,34 +1241,11 @@ interface EconomyErrorEnvelopeV1 {
460
1241
  declare class EconomyError extends Error {
461
1242
  readonly code: EconomyErrorCode;
462
1243
  constructor(code: EconomyErrorCode, message: string);
463
- }
464
- /** Throws a stable economy error when a domain assertion fails. */
465
- declare function economyAssert(condition: unknown, code: EconomyErrorCode, message: string): asserts condition;
466
- /** Creates a bounded, non-sensitive error contract for an HTTP adapter. */
467
- declare function toEconomyErrorEnvelope(error: EconomyError, requestId?: string): EconomyErrorEnvelopeV1;
468
-
469
- type JournalChainId = string;
470
- /** Locked head of one canonical transaction hash chain. */
471
- interface JournalChainHeadV1 {
472
- readonly schemaVersion: EconomyContractVersion;
473
- readonly chainId: JournalChainId;
474
- readonly version: number;
475
- readonly lastTransactionId?: TransactionId;
476
- readonly canonicalHash?: string;
477
- readonly updatedAt: IsoTimestamp;
478
- }
479
- /** An effective economic transaction carrying its approved canonical hash. */
480
- type ChainedEconomicJournalTransactionV1 = EconomicJournalTransactionV1 & {
481
- readonly canonicalHash: string;
482
- };
483
- /** Validates an empty or populated journal-chain head. */
484
- declare function assertJournalChainHead(head: JournalChainHeadV1): void;
485
- /**
486
- * Proves that a hashed transaction extends the locked head and returns the
487
- * exact next head. The persistence adapter must compare-and-swap the old
488
- * version inside the same serializable transaction that appends the journal.
489
- */
490
- declare function advanceJournalChainHead(head: JournalChainHeadV1, transaction: ChainedEconomicJournalTransactionV1): JournalChainHeadV1;
1244
+ }
1245
+ /** Throws a stable economy error when a domain assertion fails. */
1246
+ declare function economyAssert(condition: unknown, code: EconomyErrorCode, message: string): asserts condition;
1247
+ /** Creates a bounded, non-sensitive error contract for an HTTP adapter. */
1248
+ declare function toEconomyErrorEnvelope(error: EconomyError, requestId?: string): EconomyErrorEnvelopeV1;
491
1249
 
492
1250
  declare const MODULE_ALLOWANCE_PURPOSE: "junior-coder-module-entitlement";
493
1251
  type ModuleAllowanceStatusV1 = "active" | "closed";
@@ -685,386 +1443,108 @@ declare function assertModulePurchaseReconciliationObservation(observation: Modu
685
1443
  * Returns one forward-safe action. Callers must reload and lock authoritative
686
1444
  * state before carrying it out; `manual-review` never authorizes a mutation.
687
1445
  */
688
- declare function reconcileModulePurchase(observation: ModulePurchaseReconciliationObservationV1): ModulePurchaseReconciliationResultV1;
689
-
690
- type AdjustmentStatus = "draft" | "pending-approval" | "approved" | "rejected" | "executed" | "expired";
691
- /** Dual-control request; the resulting change is always a ledger transaction. */
692
- interface AdjustmentRequestV1 {
693
- readonly schemaVersion: EconomyContractVersion;
694
- readonly adjustmentId: string;
695
- readonly walletId: WalletId;
696
- readonly amount: TokenSubunitString;
697
- readonly reason: string;
698
- readonly ticketReference: string;
699
- readonly status: AdjustmentStatus;
700
- readonly initiatedByAccountId: AccountId;
701
- readonly initiatedAt: IsoTimestamp;
702
- readonly approvedByAccountId?: AccountId;
703
- readonly approvedAt?: IsoTimestamp;
704
- readonly resultingTransactionId?: TransactionId;
705
- }
706
- /** Proves that production adjustment approval was performed by another actor. */
707
- declare function assertDistinctAdjustmentApproval(request: AdjustmentRequestV1): void;
708
-
709
- type PaidLotLifecycleStatusV1 = "clear" | "partially-reversed" | "disputed" | "fully-reversed" | "chargeback-lost";
710
- type PaidLotLifecycleEventTypeV1 = "refund" | "dispute-hold" | "dispute-won" | "dispute-lost" | "chargeback" | "reversal";
711
- /** Paid-purchase facts not already carried by the source lot. */
712
- interface PaidLotPurchaseProvenanceV1 {
713
- readonly schemaVersion: EconomyContractVersion;
714
- readonly purchaseId: string;
715
- readonly catalogVersion: string;
716
- readonly purchasedAt: IsoTimestamp;
717
- }
718
- /** Provider-neutral refund/dispute evidence for a paid source lot. */
719
- interface PaidLotLifecycleEventV1 {
720
- readonly schemaVersion: EconomyContractVersion;
721
- readonly eventId: string;
722
- readonly lotId: LotId;
723
- readonly eventType: PaidLotLifecycleEventTypeV1;
724
- readonly amount: TokenSubunitString;
725
- readonly occurredAt: IsoTimestamp;
726
- }
727
- interface PaidLotLifecycleReceiptV1 {
728
- readonly schemaVersion: EconomyContractVersion;
729
- readonly event: PaidLotLifecycleEventV1;
730
- }
731
- /**
732
- * Retained paid-lot projection. Immutable purchase/original facts plus every
733
- * receipt are sufficient to rebuild all derived amounts in occurrence order.
734
- */
735
- interface PaidLotLifecycleV1 {
736
- readonly schemaVersion: EconomyContractVersion;
737
- readonly lotId: LotId;
738
- readonly payerAccountId: AccountId;
739
- readonly receivingHouseholdId: HouseholdId;
740
- readonly purchaseId: string;
741
- readonly catalogVersion: string;
742
- readonly purchasedAt: IsoTimestamp;
743
- readonly settledAt: IsoTimestamp;
744
- readonly creditedAt: IsoTimestamp;
745
- readonly originalAmount: TokenSubunitString;
746
- readonly retainedAmount: TokenSubunitString;
747
- readonly heldAmount: TokenSubunitString;
748
- readonly reversedAmount: TokenSubunitString;
749
- readonly refundedAmount: TokenSubunitString;
750
- readonly chargebackAmount: TokenSubunitString;
751
- readonly oneTimeReversalAmount: TokenSubunitString;
752
- readonly status: PaidLotLifecycleStatusV1;
753
- readonly version: number;
754
- readonly receipts: readonly PaidLotLifecycleReceiptV1[];
755
- readonly effectiveEventIds: readonly string[];
756
- }
757
- /** Exact signed projection deltas produced when one receipt is appended. */
758
- interface PaidLotLifecycleArithmeticV1 {
759
- readonly retainedDelta: TokenSubunitString;
760
- readonly heldDelta: TokenSubunitString;
761
- readonly reversedDelta: TokenSubunitString;
762
- readonly refundedDelta: TokenSubunitString;
763
- readonly chargebackDelta: TokenSubunitString;
764
- readonly oneTimeReversalDelta: TokenSubunitString;
765
- }
766
- interface PaidLotLifecycleMutationResultV1 {
767
- readonly lifecycle: PaidLotLifecycleV1;
768
- /** False only for an exact event-ID replay already recorded. */
769
- readonly applied: boolean;
770
- readonly stateChanged: boolean;
771
- readonly arithmetic: PaidLotLifecycleArithmeticV1;
772
- }
773
- /** Validates the paid purchase facts paired with a source lot. */
774
- declare function assertPaidLotPurchaseProvenance(provenance: PaidLotPurchaseProvenanceV1): void;
775
- /** Validates one provider-neutral paid-lot lifecycle event. */
776
- declare function assertPaidLotLifecycleEvent(event: PaidLotLifecycleEventV1): void;
777
- /** Validates and deterministically rebuilds retained paid-lot arithmetic. */
778
- declare function assertPaidLotLifecycle(lifecycle: PaidLotLifecycleV1): void;
779
- /** Creates the retained projection for one newly credited paid source lot. */
780
- declare function createPaidLotLifecycle(lot: SourceLotV1, provenance: PaidLotPurchaseProvenanceV1): PaidLotLifecycleV1;
781
- /**
782
- * Appends one event then rebuilds every receipt in authoritative occurrence
783
- * order. Exact retries succeed before stale-version validation.
784
- */
785
- declare function applyPaidLotLifecycleEvent(lifecycle: PaidLotLifecycleV1, event: PaidLotLifecycleEventV1, expectedVersion: number): PaidLotLifecycleMutationResultV1;
786
- /** Reduces unordered/retried lifecycle evidence in canonical event order. */
787
- declare function reducePaidLotLifecycleEvents(initial: PaidLotLifecycleV1, events: readonly PaidLotLifecycleEventV1[]): PaidLotLifecycleV1;
788
- /** Creates the exact retained-basis input used by early-backer evaluators. */
789
- declare function createEarlyBackerRetentionFromPaidLot(lifecycle: PaidLotLifecycleV1): PaidLotRetentionV1;
790
-
791
- type WalletKind = "household-treasury" | "personal" | "gameplay-allocation" | "hold" | "purchase-clearing" | "provider-clearing" | "system";
792
- type WalletStatus = "active" | "restricted" | "closed";
793
- type WalletOwnerType = "account" | "household" | "system";
794
- /** Exact owner identity used by persistence lookups and IDOR-safe locking. */
795
- interface WalletOwnerReferenceV1 {
796
- readonly ownerType: WalletOwnerType;
797
- readonly ownerId: AccountId | HouseholdId | "system";
798
- }
799
- /** Versioned authoritative wallet descriptor. */
800
- interface WalletV1 {
801
- readonly schemaVersion: EconomyContractVersion;
802
- readonly walletId: WalletId;
803
- readonly accountId: AccountId;
804
- readonly kind: WalletKind;
805
- readonly ownerType: WalletOwnerType;
806
- readonly ownerId: AccountId | HouseholdId | "system";
807
- readonly householdId?: HouseholdId;
808
- readonly status: WalletStatus;
809
- readonly version: number;
810
- readonly createdAt: IsoTimestamp;
811
- readonly closedAt?: IsoTimestamp;
812
- }
813
- /** Server-computed wallet totals. Clients must never derive authority from it. */
814
- interface WalletBalanceSummaryV1 {
815
- readonly schemaVersion: EconomyContractVersion;
816
- readonly walletId: WalletId;
817
- readonly available: TokenSubunitString;
818
- readonly reserved: TokenSubunitString;
819
- readonly held: TokenSubunitString;
820
- readonly rewardProgress: TokenSubunitString;
821
- readonly version: number;
822
- readonly asOf: IsoTimestamp;
823
- }
824
- /** Lifetime aggregates used by the Token profile. */
825
- interface WalletLifetimeTotalsV1 {
826
- readonly schemaVersion: EconomyContractVersion;
827
- readonly bought: TokenSubunitString;
828
- readonly earned: TokenSubunitString;
829
- readonly allocated: TokenSubunitString;
830
- readonly reclaimed: TokenSubunitString;
831
- readonly spent: TokenSubunitString;
832
- readonly reversed: TokenSubunitString;
833
- }
834
- /** Validates an exact wallet owner without accepting a browser-derived role. */
835
- declare function assertWalletOwnerReference(owner: WalletOwnerReferenceV1): void;
836
- /** Validates wallet ownership, lifecycle, and optimistic-version facts. */
837
- declare function assertWallet(wallet: WalletV1): void;
838
- /** Validates non-negative server-computed wallet balance categories. */
839
- declare function assertWalletBalanceSummary(summary: WalletBalanceSummaryV1): void;
840
- /** Validates non-negative lifetime aggregates exposed by the profile API. */
841
- declare function assertWalletLifetimeTotals(totals: WalletLifetimeTotalsV1): void;
842
-
843
- type BalanceProjection = Readonly<Record<AccountId, TokenSubunitString>>;
844
- interface BalanceProjectionSnapshotV1 {
845
- readonly schemaVersion: EconomyContractVersion;
846
- readonly balances: BalanceProjection;
847
- readonly lastTransactionId?: TransactionId;
848
- readonly rebuiltAt: IsoTimestamp;
849
- }
850
- type WalletProjectionBucket = "spendable" | "reserved" | "held";
851
- /** Exclusive stored buckets for one wallet; reward progress is derived. */
852
- interface WalletBalanceProjectionV1 {
853
- readonly schemaVersion: EconomyContractVersion;
854
- readonly walletId: WalletId;
855
- readonly spendable: TokenSubunitString;
856
- readonly reserved: TokenSubunitString;
857
- readonly held: TokenSubunitString;
858
- readonly version: number;
859
- readonly lastTransactionId?: TransactionId;
860
- readonly asOf: IsoTimestamp;
861
- }
862
- /** One atomic add operation against all exclusive buckets of a wallet. */
863
- interface WalletBalanceDeltaV1 {
864
- readonly schemaVersion: EconomyContractVersion;
865
- readonly walletId: WalletId;
866
- readonly spendableDelta: TokenSubunitString;
867
- readonly reservedDelta: TokenSubunitString;
868
- readonly heldDelta: TokenSubunitString;
869
- }
870
- /** Authoritative mapping from a ledger account to one wallet bucket. */
871
- interface WalletPostingAccountBindingV1 {
872
- readonly accountId: AccountId;
873
- readonly walletId: WalletId;
874
- readonly bucket: WalletProjectionBucket;
875
- }
876
- type WalletLifetimeBucket = "bought" | "earned" | "allocated" | "reclaimed" | "spent" | "reversed";
877
- /** Positive monotonic contribution to one wallet lifetime counter. */
878
- interface WalletLifetimeDeltaV1 {
879
- readonly schemaVersion: EconomyContractVersion;
880
- readonly walletId: WalletId;
881
- readonly bucket: WalletLifetimeBucket;
882
- readonly amount: TokenSubunitString;
883
- }
884
- /** Validates one exclusive-bucket projection. */
885
- declare function assertWalletBalanceProjection(projection: WalletBalanceProjectionV1): void;
886
- /** Validates one non-zero atomic wallet delta. */
887
- declare function assertWalletBalanceDelta(delta: WalletBalanceDeltaV1): void;
888
- /** Rejects duplicate wallet updates before one atomic persistence call. */
889
- declare function assertWalletBalanceDeltaBatch(transactionId: TransactionId, deltas: readonly WalletBalanceDeltaV1[]): void;
890
- /** Applies an atomic add locally for deterministic tests and rebuilds. */
891
- declare function applyWalletBalanceDelta(projection: WalletBalanceProjectionV1, delta: WalletBalanceDeltaV1, transactionId: TransactionId, asOf: IsoTimestamp): WalletBalanceProjectionV1;
892
- /**
893
- * Converts exclusive storage buckets to the legacy display DTO. Available is
894
- * independently usable whole Tokens in this wallet; rewardProgress is this
895
- * wallet's sub-Token remainder and is never netted with another wallet.
896
- */
897
- declare function createWalletBalanceSummary(projection: WalletBalanceProjectionV1): WalletBalanceSummaryV1;
898
- /** Enforces the stronger per-wallet semantics required by V1 query adapters. */
899
- declare function assertDeterministicWalletBalanceSummary(summary: WalletBalanceSummaryV1): void;
900
- /**
901
- * Derives a single delta per wallet from wallet-linked postings and an
902
- * authoritative account-to-bucket mapping. Unlinked system postings are not
903
- * wallet projections.
904
- */
905
- declare function deriveWalletBalanceDeltas(transaction: EconomicJournalTransactionV1, bindings: readonly WalletPostingAccountBindingV1[]): readonly WalletBalanceDeltaV1[];
906
- /**
907
- * Rebuilds monotonic gross lifetime contributions from a settled transaction.
908
- * Earlier bought/earned counters are never reduced by a later compensating
909
- * transaction; removals accrue separately in `reversed`.
910
- */
911
- declare function deriveWalletLifetimeDeltas(transaction: EconomicJournalTransactionV1): readonly WalletLifetimeDeltaV1[];
912
- /** Applies positive lifetime deltas for one wallet without rewriting history. */
913
- declare function applyWalletLifetimeDeltas(current: WalletLifetimeTotalsV1, walletId: WalletId, deltas: readonly WalletLifetimeDeltaV1[]): WalletLifetimeTotalsV1;
914
- /** Applies one balanced transaction without mutating the existing projection. */
915
- declare function applyTransactionToProjection(current: BalanceProjection, transaction: LedgerTransactionV1): BalanceProjection;
916
- /**
917
- * Rebuilds balances deterministically and rejects duplicate economic envelopes.
918
- */
919
- declare function rebuildBalanceProjection(transactions: readonly LedgerTransactionV1[]): BalanceProjection;
920
- /** Enforces non-negative balances only for spendable/reservable accounts. */
921
- declare function assertNonNegativeAccounts(projection: BalanceProjection, protectedAccountIds: readonly AccountId[]): void;
922
- /** Creates a versioned snapshot after a deterministic rebuild. */
923
- declare function createProjectionSnapshot(transactions: readonly LedgerTransactionV1[], rebuiltAt: IsoTimestamp): BalanceProjectionSnapshotV1;
924
-
925
- type EconomyCommandType = "credit-purchase" | "credit-subscription" | "credit-reward" | "credit-event" | "credit-competition" | "allocate" | "boost" | "reclaim" | "spend" | "hold" | "release-hold" | "refund" | "chargeback" | "reverse" | "adjust";
926
- interface EconomyCommandEnvelopeV1 {
927
- readonly schemaVersion: EconomyContractVersion;
928
- readonly commandId: string;
929
- readonly commandType: EconomyCommandType;
930
- readonly idempotencyKey: string;
931
- readonly actorAccountId: AccountId;
932
- readonly subjectAccountId: AccountId;
933
- readonly relationshipId?: string;
934
- readonly authorizationVersion?: number;
935
- readonly payloadHash: string;
936
- readonly acceptedAt: IsoTimestamp;
937
- readonly acceptedRegion: string;
938
- readonly writerFencingToken: string;
1446
+ declare function reconcileModulePurchase(observation: ModulePurchaseReconciliationObservationV1): ModulePurchaseReconciliationResultV1;
1447
+
1448
+ type AdjustmentStatus = "draft" | "pending-approval" | "approved" | "rejected" | "executed" | "expired";
1449
+ /** Dual-control request; the resulting change is always a ledger transaction. */
1450
+ interface AdjustmentRequestV1 {
1451
+ readonly schemaVersion: EconomyContractVersion;
1452
+ readonly adjustmentId: string;
1453
+ readonly walletId: WalletId;
1454
+ readonly amount: TokenSubunitString;
1455
+ readonly reason: string;
1456
+ readonly ticketReference: string;
1457
+ readonly status: AdjustmentStatus;
1458
+ readonly initiatedByAccountId: AccountId;
1459
+ readonly initiatedAt: IsoTimestamp;
1460
+ readonly approvedByAccountId?: AccountId;
1461
+ readonly approvedAt?: IsoTimestamp;
1462
+ readonly resultingTransactionId?: TransactionId;
939
1463
  }
940
- type EconomyCommandWorkflowStateV1 = "accepted" | "processing" | "failed" | "completed";
941
- /** Immutable workflow evidence; it is never an economic journal transaction. */
942
- interface EconomyCommandWorkflowEventV1 {
1464
+ /** Proves that production adjustment approval was performed by another actor. */
1465
+ declare function assertDistinctAdjustmentApproval(request: AdjustmentRequestV1): void;
1466
+
1467
+ type PaidLotLifecycleStatusV1 = "clear" | "partially-reversed" | "disputed" | "fully-reversed" | "chargeback-lost";
1468
+ type PaidLotLifecycleEventTypeV1 = "refund" | "dispute-hold" | "dispute-won" | "dispute-lost" | "chargeback" | "reversal";
1469
+ /** Paid-purchase facts not already carried by the source lot. */
1470
+ interface PaidLotPurchaseProvenanceV1 {
943
1471
  readonly schemaVersion: EconomyContractVersion;
944
- readonly workflowEventId: string;
945
- readonly commandId: string;
946
- readonly state: EconomyCommandWorkflowStateV1;
947
- /** Stable non-sensitive classifier; detailed failure data stays operational. */
948
- readonly failureCode?: string;
949
- readonly occurredAt: IsoTimestamp;
1472
+ readonly purchaseId: string;
1473
+ readonly catalogVersion: string;
1474
+ readonly purchasedAt: IsoTimestamp;
950
1475
  }
951
- interface EconomyOutboxEventV1 {
1476
+ /** Provider-neutral refund/dispute evidence for a paid source lot. */
1477
+ interface PaidLotLifecycleEventV1 {
952
1478
  readonly schemaVersion: EconomyContractVersion;
953
1479
  readonly eventId: string;
954
- readonly transactionId: TransactionId;
955
- readonly eventType: string;
956
- readonly payloadHash: string;
1480
+ readonly lotId: LotId;
1481
+ readonly eventType: PaidLotLifecycleEventTypeV1;
1482
+ readonly amount: TokenSubunitString;
957
1483
  readonly occurredAt: IsoTimestamp;
958
1484
  }
959
- interface PersistedIdempotencyResultV1 {
960
- readonly transactionId: TransactionId;
961
- readonly responseHash: string;
962
- readonly recordedAt: IsoTimestamp;
963
- }
964
- /** Exact actor/subject/operation namespace for a caller-owned idempotency key. */
965
- interface EconomyIdempotencyScopeV1 {
1485
+ interface PaidLotLifecycleReceiptV1 {
966
1486
  readonly schemaVersion: EconomyContractVersion;
967
- readonly idempotencyKey: string;
968
- readonly commandType: EconomyCommandType;
969
- readonly actorAccountId: AccountId;
970
- readonly subjectAccountId: AccountId;
1487
+ readonly event: PaidLotLifecycleEventV1;
971
1488
  }
972
- /** V2 replay evidence bound to one accepted command and exact scope. */
973
- interface ScopedPersistedIdempotencyResultV1 extends PersistedIdempotencyResultV1 {
1489
+ /**
1490
+ * Retained paid-lot projection. Immutable purchase/original facts plus every
1491
+ * receipt are sufficient to rebuild all derived amounts in occurrence order.
1492
+ */
1493
+ interface PaidLotLifecycleV1 {
974
1494
  readonly schemaVersion: EconomyContractVersion;
975
- readonly commandId: string;
976
- }
977
- /** Validates replay evidence before it is returned across a command boundary. */
978
- declare function assertScopedPersistedIdempotencyResult(result: ScopedPersistedIdempotencyResultV1): void;
979
- /** Validates the namespace that prevents cross-principal replay collisions. */
980
- declare function assertEconomyIdempotencyScope(scope: EconomyIdempotencyScopeV1): void;
981
- /** Validates minimized accepted-command evidence before durable append. */
982
- declare function assertEconomyCommandEnvelope(envelope: EconomyCommandEnvelopeV1): void;
983
- /** Validates one immutable command-workflow state event. */
984
- declare function assertEconomyCommandWorkflowEvent(event: EconomyCommandWorkflowEventV1): void;
985
- /** Operations available only inside one serializable database transaction. */
986
- interface EconomyUnitOfWork {
987
- getWalletForUpdate(walletId: WalletId): Promise<WalletV1 | null>;
988
- listSpendableLotsForUpdate(walletId: WalletId): Promise<readonly SourceLotV1[]>;
989
- findLotForUpdate(lotId: LotId): Promise<SourceLotV1 | null>;
990
- findIdempotencyResult(idempotencyKey: string): Promise<PersistedIdempotencyResultV1 | null>;
991
- appendTransaction(transaction: LedgerTransactionV1): Promise<void>;
992
- appendSourceLot(lot: SourceLotV1): Promise<void>;
993
- updateSourceLotProjection(lotId: LotId, remainingAmount: TokenSubunitString, heldAmount: TokenSubunitString, reversedAmount: TokenSubunitString): Promise<void>;
994
- saveBalanceProjection(projection: BalanceProjection, transactionId: TransactionId): Promise<void>;
995
- saveIdempotencyResult(idempotencyKey: string, result: PersistedIdempotencyResultV1): Promise<void>;
996
- appendOutboxEvent(event: EconomyOutboxEventV1): Promise<void>;
1495
+ readonly lotId: LotId;
1496
+ readonly payerAccountId: AccountId;
1497
+ readonly receivingHouseholdId: HouseholdId;
1498
+ readonly purchaseId: string;
1499
+ readonly catalogVersion: string;
1500
+ readonly purchasedAt: IsoTimestamp;
1501
+ readonly settledAt: IsoTimestamp;
1502
+ readonly creditedAt: IsoTimestamp;
1503
+ readonly originalAmount: TokenSubunitString;
1504
+ readonly retainedAmount: TokenSubunitString;
1505
+ readonly heldAmount: TokenSubunitString;
1506
+ readonly reversedAmount: TokenSubunitString;
1507
+ readonly refundedAmount: TokenSubunitString;
1508
+ readonly chargebackAmount: TokenSubunitString;
1509
+ readonly oneTimeReversalAmount: TokenSubunitString;
1510
+ readonly status: PaidLotLifecycleStatusV1;
1511
+ readonly version: number;
1512
+ readonly receipts: readonly PaidLotLifecycleReceiptV1[];
1513
+ readonly effectiveEventIds: readonly string[];
997
1514
  }
998
- /** Adapter boundary for serializable, ACID economy mutations. */
999
- interface EconomyPersistencePort {
1000
- runSerializable<T>(operation: (unitOfWork: EconomyUnitOfWork) => Promise<T>): Promise<T>;
1001
- getWallet(walletId: WalletId): Promise<WalletV1 | null>;
1002
- getBalanceProjection(walletId: WalletId): Promise<BalanceProjectionSnapshotV1 | null>;
1003
- getTransaction(transactionId: TransactionId): Promise<LedgerTransactionV1 | null>;
1004
- rebuildProjection(): Promise<BalanceProjection>;
1515
+ /** Exact signed projection deltas produced when one receipt is appended. */
1516
+ interface PaidLotLifecycleArithmeticV1 {
1517
+ readonly retainedDelta: TokenSubunitString;
1518
+ readonly heldDelta: TokenSubunitString;
1519
+ readonly reversedDelta: TokenSubunitString;
1520
+ readonly refundedDelta: TokenSubunitString;
1521
+ readonly chargebackDelta: TokenSubunitString;
1522
+ readonly oneTimeReversalDelta: TokenSubunitString;
1005
1523
  }
1006
- /**
1007
- * V2 mutation surface. Unlike `EconomyUnitOfWork`, it has no absolute balance
1008
- * overwrite: journal, source-lot movement, allocation state, balance/lifetime
1009
- * deltas, idempotency, chain head, and outbox are committed atomically.
1010
- */
1011
- interface EconomyUnitOfWorkV2 {
1012
- getWalletForOwnerForUpdate(walletId: WalletId, owner: WalletOwnerReferenceV1): Promise<WalletV1 | null>;
1013
- listSpendableLotsForUpdate(walletId: WalletId): Promise<readonly VersionedSourceLotV1[]>;
1014
- findLotForUpdate(lotId: LotId): Promise<VersionedSourceLotV1 | null>;
1015
- getGameplayAllocationForUpdate(allocationId: AllocationId, householdId: HouseholdId, childAccountId: AccountId): Promise<GameplayAllocationV1 | null>;
1016
- findIdempotencyResult(scope: EconomyIdempotencyScopeV1): Promise<ScopedPersistedIdempotencyResultV1 | null>;
1017
- /** Locks and rejects any stale/non-active regional writer lease. */
1018
- lockActiveWriterFence(acceptedRegion: string, writerFencingToken: string): Promise<void>;
1019
- lockJournalChainHead(chainId: string): Promise<JournalChainHeadV1>;
1020
- appendCommandEnvelope(envelope: EconomyCommandEnvelopeV1): Promise<void>;
1021
- appendCommandWorkflowEvent(event: EconomyCommandWorkflowEventV1): Promise<void>;
1022
- appendTransaction(transaction: ChainedEconomicJournalTransactionV1): Promise<void>;
1023
- /** Appends `createInitialSourceLotSnapshot()` output; later changes are movements. */
1024
- appendSourceLot(snapshot: VersionedSourceLotV1): Promise<void>;
1025
- /** Appends movement evidence and applies its lot CAS as one operation. */
1026
- applySourceLotMovement(movement: SourceLotMovementV1): Promise<void>;
1027
- appendGameplayAllocation(allocation: GameplayAllocationV1): Promise<void>;
1028
- /**
1029
- * Compares `expectedVersion`, requires `allocation.version` to be exactly the
1030
- * next value, and never overwrites a stale row.
1031
- */
1032
- saveGameplayAllocation(allocation: GameplayAllocationV1, expectedVersion: number): Promise<void>;
1033
- /**
1034
- * Atomically adds deltas, verifies them against the appended postings and
1035
- * account bindings, and records transaction-scoped application keys.
1036
- */
1037
- applyWalletBalanceDeltas(transactionId: TransactionId, deltas: readonly WalletBalanceDeltaV1[]): Promise<void>;
1038
- /**
1039
- * Atomically increments monotonic lifetime counters after verifying the
1040
- * deltas against the appended transaction's deterministic classification.
1041
- */
1042
- applyWalletLifetimeDeltas(transactionId: TransactionId, deltas: readonly WalletLifetimeDeltaV1[]): Promise<void>;
1043
- saveIdempotencyResult(scope: EconomyIdempotencyScopeV1, result: ScopedPersistedIdempotencyResultV1): Promise<void>;
1044
- appendOutboxEvent(event: EconomyOutboxEventV1): Promise<void>;
1045
- /** Compare-and-swaps the full locked head, including its canonical hash. */
1046
- advanceJournalChainHead(expected: JournalChainHeadV1, next: JournalChainHeadV1): Promise<void>;
1524
+ interface PaidLotLifecycleMutationResultV1 {
1525
+ readonly lifecycle: PaidLotLifecycleV1;
1526
+ /** False only for an exact event-ID replay already recorded. */
1527
+ readonly applied: boolean;
1528
+ readonly stateChanged: boolean;
1529
+ readonly arithmetic: PaidLotLifecycleArithmeticV1;
1047
1530
  }
1531
+ /** Validates the paid purchase facts paired with a source lot. */
1532
+ declare function assertPaidLotPurchaseProvenance(provenance: PaidLotPurchaseProvenanceV1): void;
1533
+ /** Validates one provider-neutral paid-lot lifecycle event. */
1534
+ declare function assertPaidLotLifecycleEvent(event: PaidLotLifecycleEventV1): void;
1535
+ /** Validates and deterministically rebuilds retained paid-lot arithmetic. */
1536
+ declare function assertPaidLotLifecycle(lifecycle: PaidLotLifecycleV1): void;
1537
+ /** Creates the retained projection for one newly credited paid source lot. */
1538
+ declare function createPaidLotLifecycle(lot: SourceLotV1, provenance: PaidLotPurchaseProvenanceV1): PaidLotLifecycleV1;
1048
1539
  /**
1049
- * Additive authoritative persistence boundary for new consumers. V1 remains
1050
- * exported for compatibility but must not be adapted by delegating its
1051
- * absolute `saveBalanceProjection` operation to this interface.
1540
+ * Appends one event then rebuilds every receipt in authoritative occurrence
1541
+ * order. Exact retries succeed before stale-version validation.
1052
1542
  */
1053
- interface EconomyPersistencePortV2 {
1054
- runSerializable<T>(operation: (unitOfWork: EconomyUnitOfWorkV2) => Promise<T>): Promise<T>;
1055
- getWallet(walletId: WalletId): Promise<WalletV1 | null>;
1056
- listWalletsByOwner(owner: WalletOwnerReferenceV1): Promise<readonly WalletV1[]>;
1057
- getGameplayAllocation(allocationId: AllocationId, householdId: HouseholdId, childAccountId: AccountId): Promise<GameplayAllocationV1 | null>;
1058
- getCommandEnvelope(commandId: string): Promise<EconomyCommandEnvelopeV1 | null>;
1059
- getTransaction(transactionId: TransactionId): Promise<ChainedEconomicJournalTransactionV1 | null>;
1060
- rebuildWalletBalanceProjections(): Promise<readonly WalletBalanceProjectionV1[]>;
1061
- }
1062
- interface EconomyClockPort {
1063
- now(): IsoTimestamp;
1064
- }
1065
- interface EconomyIdPort {
1066
- nextId(namespace: string): string;
1067
- }
1543
+ declare function applyPaidLotLifecycleEvent(lifecycle: PaidLotLifecycleV1, event: PaidLotLifecycleEventV1, expectedVersion: number): PaidLotLifecycleMutationResultV1;
1544
+ /** Reduces unordered/retried lifecycle evidence in canonical event order. */
1545
+ declare function reducePaidLotLifecycleEvents(initial: PaidLotLifecycleV1, events: readonly PaidLotLifecycleEventV1[]): PaidLotLifecycleV1;
1546
+ /** Creates the exact retained-basis input used by early-backer evaluators. */
1547
+ declare function createEarlyBackerRetentionFromPaidLot(lifecycle: PaidLotLifecycleV1): PaidLotRetentionV1;
1068
1548
 
1069
1549
  type WalletPortfolioComponentRole = "household-treasury" | "personal" | "gameplay-allocation" | "hold";
1070
1550
  /** One server-authorized component of a portfolio read. */
@@ -1386,6 +1866,278 @@ declare const BASELINE_MONTHLY_SUBSCRIPTION_PLAN: TokenSubscriptionPlanV1;
1386
1866
  /** Validates future provider-neutral recurrence without enabling it. */
1387
1867
  declare function assertTokenSubscriptionPlan(plan: TokenSubscriptionPlanV1): void;
1388
1868
 
1869
+ declare const ECONOMY_RECOVERY_PROTOCOL_VERSION: "1";
1870
+ type EconomyRecoveryProtocolVersion = typeof ECONOMY_RECOVERY_PROTOCOL_VERSION;
1871
+ type EconomyRecoveryRecordKindV1 = "acceptance" | "committed-result";
1872
+ type EconomyRecoveryDirectionV1 = "credit" | "debit";
1873
+ type EconomyEvidenceSignatureAlgorithmV1 = "ed25519" | "ecdsa-p256-sha256" | "rsa-pss-sha256";
1874
+ /** Public, non-secret metadata selected before detached signing. */
1875
+ interface EconomyEvidenceSignatureMetadataV1 {
1876
+ readonly schemaVersion: EconomyContractVersion;
1877
+ readonly signatureVersion: "1";
1878
+ readonly algorithm: EconomyEvidenceSignatureAlgorithmV1;
1879
+ readonly keyId: string;
1880
+ readonly signedAt: IsoTimestamp;
1881
+ }
1882
+ /** Public metadata plus the final detached signature value. */
1883
+ interface EconomyEvidenceSignatureV1 extends EconomyEvidenceSignatureMetadataV1 {
1884
+ readonly value: string;
1885
+ }
1886
+ /** Deterministic signing request safe to pass to an external key adapter. */
1887
+ interface EconomyPreparedEvidenceSignatureV1 {
1888
+ readonly contentAddressedId: string;
1889
+ readonly canonicalPayload: string;
1890
+ }
1891
+ /**
1892
+ * Encrypted reconstruction bytes stored outside the live authority.
1893
+ *
1894
+ * The plaintext must contain only the already-approved, privacy-minimized
1895
+ * authority records. Raw provider callbacks, signatures, payment data,
1896
+ * idempotency keys, email addresses, and exact birth data are forbidden.
1897
+ */
1898
+ interface EconomySealedRecoveryPayloadV1 {
1899
+ readonly schemaVersion: EconomyContractVersion;
1900
+ readonly payloadVersion: "1";
1901
+ readonly cipherSuite: "AES-256-GCM";
1902
+ readonly encoding: "base64url";
1903
+ readonly keyVersion: string;
1904
+ readonly nonce: string;
1905
+ readonly ciphertext: string;
1906
+ readonly authenticationTag: string;
1907
+ readonly plaintextContentHash: string;
1908
+ readonly encryptionContextHash: string;
1909
+ }
1910
+ /** Content-addressed body written identically to every evidence region. */
1911
+ interface EconomyRecoveryAcceptanceBodyV1 {
1912
+ readonly schemaVersion: EconomyContractVersion;
1913
+ readonly recoveryVersion: EconomyRecoveryProtocolVersion;
1914
+ readonly recordType: "economy-recovery-acceptance";
1915
+ readonly authorityId: string;
1916
+ readonly commandId: string;
1917
+ readonly correlationId: string;
1918
+ readonly idempotencyFingerprint: EconomyHmacFingerprintV1;
1919
+ readonly commandEnvelopeHash: string;
1920
+ readonly acceptedReceiptId: string;
1921
+ readonly acceptedReceiptHash: string;
1922
+ readonly sealedPayload: EconomySealedRecoveryPayloadV1;
1923
+ readonly preparedAt: IsoTimestamp;
1924
+ readonly acceptedAt: IsoTimestamp;
1925
+ }
1926
+ /**
1927
+ * Provider-neutral durable acceptance. The ID is SHA-256-addressed from the
1928
+ * canonical body and therefore remains identical in all evidence regions.
1929
+ */
1930
+ interface EconomyRecoveryAcceptanceEnvelopeV1 extends EconomyRecoveryAcceptanceBodyV1 {
1931
+ readonly acceptanceEnvelopeId: string;
1932
+ }
1933
+ /** Content-addressed result body written after the authority commit. */
1934
+ interface EconomyRecoveryCommittedResultBodyV1 {
1935
+ readonly schemaVersion: EconomyContractVersion;
1936
+ readonly recoveryVersion: EconomyRecoveryProtocolVersion;
1937
+ readonly recordType: "economy-recovery-committed-result";
1938
+ readonly authorityId: string;
1939
+ readonly commandId: string;
1940
+ readonly correlationId: string;
1941
+ readonly acceptanceEnvelopeId: string;
1942
+ readonly acceptanceEnvelopeHash: string;
1943
+ readonly resultReceiptId: string;
1944
+ readonly resultReceiptHash: string;
1945
+ readonly outcome: EconomyCommandResultOutcomeV1;
1946
+ readonly authorityCommitId: string;
1947
+ readonly authorityCommitHash: string;
1948
+ readonly authoritySequence: string;
1949
+ readonly authorityHeadHashAfter: string;
1950
+ readonly transactionId?: TransactionId;
1951
+ readonly transactionCanonicalHash?: string;
1952
+ readonly sealedPayload: EconomySealedRecoveryPayloadV1;
1953
+ readonly committedAt: IsoTimestamp;
1954
+ }
1955
+ /**
1956
+ * Immutable reconstruction result for one command. Failed and no-op commands
1957
+ * are retained as facts but cannot carry transaction identity or value.
1958
+ */
1959
+ interface EconomyRecoveryCommittedResultV1 extends EconomyRecoveryCommittedResultBodyV1 {
1960
+ readonly committedResultId: string;
1961
+ }
1962
+ /** Region-specific body proving one recovery record was durably retained. */
1963
+ interface EconomyRegionalEvidenceReceiptBodyV1 {
1964
+ readonly schemaVersion: EconomyContractVersion;
1965
+ readonly recoveryVersion: EconomyRecoveryProtocolVersion;
1966
+ readonly recordType: "economy-regional-evidence-receipt";
1967
+ readonly journalId: string;
1968
+ readonly region: string;
1969
+ readonly sequence: string;
1970
+ readonly previousReceiptHash?: string;
1971
+ readonly authorityId: string;
1972
+ readonly commandId: string;
1973
+ readonly recoveryRecordKind: EconomyRecoveryRecordKindV1;
1974
+ readonly recoveryRecordId: string;
1975
+ readonly recoveryRecordContentHash: string;
1976
+ readonly storedAt: IsoTimestamp;
1977
+ readonly retentionUntil: IsoTimestamp;
1978
+ }
1979
+ /**
1980
+ * Signed, content-addressed evidence-region acknowledgement.
1981
+ *
1982
+ * Its ID addresses the unsigned storage fact. Its detached signature covers
1983
+ * that ID, the exact canonical body, and the public signature metadata.
1984
+ */
1985
+ interface EconomyRegionalEvidenceReceiptV1 extends EconomyRegionalEvidenceReceiptBodyV1 {
1986
+ readonly evidenceReceiptId: string;
1987
+ readonly signature: EconomyEvidenceSignatureV1;
1988
+ }
1989
+ /** One sibling in a duplicate-last, binary SHA-256 Merkle proof. */
1990
+ interface EconomyMerkleProofStepV1 {
1991
+ readonly schemaVersion: EconomyContractVersion;
1992
+ readonly side: "left" | "right";
1993
+ readonly hash: string;
1994
+ }
1995
+ /** Portable proof that an authority commit is covered by an hourly anchor. */
1996
+ interface EconomyMerkleInclusionProofV1 {
1997
+ readonly schemaVersion: EconomyContractVersion;
1998
+ readonly proofVersion: "1";
1999
+ readonly algorithm: "duplicate-last-sha256-v1";
2000
+ readonly anchorId: string;
2001
+ readonly anchorManifestHash: string;
2002
+ readonly leafHash: string;
2003
+ readonly leafIndex: string;
2004
+ readonly leafCount: string;
2005
+ readonly siblings: readonly EconomyMerkleProofStepV1[];
2006
+ }
2007
+ /** Privacy-safe link from a customer receipt to one regional evidence fact. */
2008
+ interface EconomyPortableEvidenceReferenceV1 {
2009
+ readonly schemaVersion: EconomyContractVersion;
2010
+ readonly region: string;
2011
+ readonly evidenceReceiptId: string;
2012
+ readonly evidenceReceiptHash: string;
2013
+ }
2014
+ /** Content-addressed customer-facing receipt body. */
2015
+ interface EconomyPortableCustomerReceiptBodyV1 {
2016
+ readonly schemaVersion: EconomyContractVersion;
2017
+ readonly recoveryVersion: EconomyRecoveryProtocolVersion;
2018
+ readonly recordType: "economy-portable-customer-receipt";
2019
+ readonly authorityId: string;
2020
+ readonly commandId: string;
2021
+ readonly activityType: ActivityType;
2022
+ readonly direction: EconomyRecoveryDirectionV1;
2023
+ readonly tokenAmount: TokenSubunitString;
2024
+ readonly transactionId: TransactionId;
2025
+ readonly transactionCanonicalHash: string;
2026
+ readonly resultReceiptId: string;
2027
+ readonly resultReceiptHash: string;
2028
+ readonly committedResultId: string;
2029
+ readonly committedResultContentHash: string;
2030
+ readonly authorityCommitId: string;
2031
+ readonly authorityCommitHash: string;
2032
+ readonly authoritySequence: string;
2033
+ readonly regionalEvidence: readonly EconomyPortableEvidenceReferenceV1[];
2034
+ readonly merkleInclusionProof?: EconomyMerkleInclusionProofV1;
2035
+ readonly tokenTermsVersion: string;
2036
+ readonly cashRedemptionAllowed: false;
2037
+ readonly committedAt: IsoTimestamp;
2038
+ readonly issuedAt: IsoTimestamp;
2039
+ }
2040
+ /**
2041
+ * Downloadable signed receipt containing no payer, household, provider,
2042
+ * payment, email, session, or exact-age data.
2043
+ */
2044
+ interface EconomyPortableCustomerReceiptV1 extends EconomyPortableCustomerReceiptBodyV1 {
2045
+ readonly portableReceiptId: string;
2046
+ readonly signature: EconomyEvidenceSignatureV1;
2047
+ }
2048
+ /** Infrastructure-supplied signature verifier; this package owns no keys. */
2049
+ interface EconomyEvidenceSignatureVerificationInputV1 {
2050
+ readonly algorithm: EconomyEvidenceSignatureAlgorithmV1;
2051
+ readonly keyId: string;
2052
+ readonly signedAt: IsoTimestamp;
2053
+ readonly signature: string;
2054
+ readonly canonicalPayload: string;
2055
+ }
2056
+ type EconomyEvidenceSignatureVerifierV1 = (input: EconomyEvidenceSignatureVerificationInputV1) => boolean;
2057
+ /** Validates a bounded AES-GCM envelope without implementing cryptography. */
2058
+ declare function assertEconomySealedRecoveryPayload(payload: EconomySealedRecoveryPayloadV1): void;
2059
+ /** Canonical body bytes used to derive an acceptance-envelope ID. */
2060
+ declare function canonicalEconomyRecoveryAcceptanceBodyPayload(body: EconomyRecoveryAcceptanceBodyV1): string;
2061
+ /** Creates an acceptance record whose ID addresses its exact canonical body. */
2062
+ declare function createEconomyRecoveryAcceptanceEnvelope(body: EconomyRecoveryAcceptanceBodyV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): EconomyRecoveryAcceptanceEnvelopeV1;
2063
+ /** Validates schema, privacy shape, and the acceptance content address. */
2064
+ declare function assertEconomyRecoveryAcceptanceEnvelope(envelope: EconomyRecoveryAcceptanceEnvelopeV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): void;
2065
+ /** Canonical complete acceptance bytes written create-only in each region. */
2066
+ declare function canonicalEconomyRecoveryAcceptanceEnvelopePayload(envelope: EconomyRecoveryAcceptanceEnvelopeV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): string;
2067
+ /** Canonical body bytes used to derive a committed-result ID. */
2068
+ declare function canonicalEconomyRecoveryCommittedResultBodyPayload(body: EconomyRecoveryCommittedResultBodyV1): string;
2069
+ /** Creates a result record whose ID addresses its exact canonical body. */
2070
+ declare function createEconomyRecoveryCommittedResult(body: EconomyRecoveryCommittedResultBodyV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): EconomyRecoveryCommittedResultV1;
2071
+ /** Validates schema, privacy shape, and the committed-result content address. */
2072
+ declare function assertEconomyRecoveryCommittedResult(result: EconomyRecoveryCommittedResultV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): void;
2073
+ /** Canonical complete result bytes written create-only in each region. */
2074
+ declare function canonicalEconomyRecoveryCommittedResultPayload(result: EconomyRecoveryCommittedResultV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): string;
2075
+ /**
2076
+ * Proves that a committed result is the terminal recovery record for the exact
2077
+ * accepted command. It also recomputes the acceptance record hash.
2078
+ */
2079
+ declare function assertEconomyRecoveryResultLink(acceptance: EconomyRecoveryAcceptanceEnvelopeV1, result: EconomyRecoveryCommittedResultV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): void;
2080
+ /** Validates a detached evidence signature without owning signing keys. */
2081
+ declare function assertEconomyEvidenceSignatureMetadata(signature: EconomyEvidenceSignatureMetadataV1): void;
2082
+ /** Validates a detached evidence signature without owning signing keys. */
2083
+ declare function assertEconomyEvidenceSignature(signature: EconomyEvidenceSignatureV1): void;
2084
+ /** Canonical body bytes used to derive a regional evidence-receipt ID. */
2085
+ declare function canonicalEconomyRegionalEvidenceReceiptBodyPayload(body: EconomyRegionalEvidenceReceiptBodyV1): string;
2086
+ /** Creates a signed region receipt after the adapter has produced a signature. */
2087
+ declare function createEconomyRegionalEvidenceReceipt(body: EconomyRegionalEvidenceReceiptBodyV1, signature: EconomyEvidenceSignatureV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): EconomyRegionalEvidenceReceiptV1;
2088
+ /** Validates a region receipt and its content-addressed unsigned body. */
2089
+ declare function assertEconomyRegionalEvidenceReceipt(receipt: EconomyRegionalEvidenceReceiptV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): void;
2090
+ /**
2091
+ * Prepares the regional content address and exact bytes for an external signer.
2092
+ * No placeholder signature value is required or returned.
2093
+ */
2094
+ declare function prepareEconomyRegionalEvidenceReceiptSignature(body: EconomyRegionalEvidenceReceiptBodyV1, signature: EconomyEvidenceSignatureMetadataV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): EconomyPreparedEvidenceSignatureV1;
2095
+ /** Exact bytes covered by a regional receipt's detached signature. */
2096
+ declare function canonicalEconomyRegionalEvidenceReceiptSigningPayload(receipt: EconomyRegionalEvidenceReceiptV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): string;
2097
+ /** Canonical complete region-receipt bytes, including its signature. */
2098
+ declare function canonicalEconomyRegionalEvidenceReceiptPayload(receipt: EconomyRegionalEvidenceReceiptV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): string;
2099
+ /** Verifies one region receipt through an infrastructure-supplied key adapter. */
2100
+ declare function assertEconomyRegionalEvidenceReceiptSignature(receipt: EconomyRegionalEvidenceReceiptV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1, verifySignature: EconomyEvidenceSignatureVerifierV1): void;
2101
+ /**
2102
+ * Verifies an ordered regional hash-chain segment. Segments beginning after
2103
+ * sequence one must supply the trusted preceding receipt hash.
2104
+ */
2105
+ declare function assertEconomyRegionalEvidenceChain(receipts: readonly EconomyRegionalEvidenceReceiptV1[], expectedPreviousReceiptHash: string | undefined, hashCanonicalPayload: CanonicalPayloadHashFunctionV1, verifySignature: EconomyEvidenceSignatureVerifierV1): void;
2106
+ /**
2107
+ * Proves that at least two distinct regions retained byte-identical recovery
2108
+ * content. Region-specific receipt metadata and signatures may differ.
2109
+ */
2110
+ declare function assertEconomyRegionalEvidenceEquality(receipts: readonly EconomyRegionalEvidenceReceiptV1[], expectedRegions: readonly string[], hashCanonicalPayload: CanonicalPayloadHashFunctionV1): void;
2111
+ /** Validates the exact portable Merkle-proof shape. */
2112
+ declare function assertEconomyMerkleInclusionProof(proof: EconomyMerkleInclusionProofV1): void;
2113
+ /**
2114
+ * Recomputes duplicate-last Merkle inclusion against a canonical hourly anchor.
2115
+ * The hash adapter receives only domain-separated canonical node bytes.
2116
+ */
2117
+ declare function assertEconomyMerkleInclusion(proof: EconomyMerkleInclusionProofV1, anchor: EconomyIntegrityAnchorManifestV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): void;
2118
+ /** Canonical body bytes used to derive a portable receipt ID. */
2119
+ declare function canonicalEconomyPortableCustomerReceiptBodyPayload(body: EconomyPortableCustomerReceiptBodyV1): string;
2120
+ /** Creates a signed portable receipt from a canonical content-addressed body. */
2121
+ declare function createEconomyPortableCustomerReceipt(body: EconomyPortableCustomerReceiptBodyV1, signature: EconomyEvidenceSignatureV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): EconomyPortableCustomerReceiptV1;
2122
+ /** Validates schema, privacy shape, signature shape, and content address. */
2123
+ declare function assertEconomyPortableCustomerReceipt(receipt: EconomyPortableCustomerReceiptV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): void;
2124
+ /**
2125
+ * Prepares the portable content address and exact bytes for an external signer.
2126
+ * No placeholder signature value is required or returned.
2127
+ */
2128
+ declare function prepareEconomyPortableCustomerReceiptSignature(body: EconomyPortableCustomerReceiptBodyV1, signature: EconomyEvidenceSignatureMetadataV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): EconomyPreparedEvidenceSignatureV1;
2129
+ /** Exact bytes covered by a portable receipt's detached signature. */
2130
+ declare function canonicalEconomyPortableCustomerReceiptSigningPayload(receipt: EconomyPortableCustomerReceiptV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): string;
2131
+ /** Canonical complete portable-receipt bytes, including its signature. */
2132
+ declare function canonicalEconomyPortableCustomerReceiptPayload(receipt: EconomyPortableCustomerReceiptV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1): string;
2133
+ /** Verifies a portable receipt through an infrastructure-supplied key adapter. */
2134
+ declare function assertEconomyPortableCustomerReceiptSignature(receipt: EconomyPortableCustomerReceiptV1, hashCanonicalPayload: CanonicalPayloadHashFunctionV1, verifySignature: EconomyEvidenceSignatureVerifierV1): void;
2135
+ /**
2136
+ * Cross-validates the complete portable proof graph without storage, identity,
2137
+ * key-vault, or cloud-SDK dependencies.
2138
+ */
2139
+ declare function assertEconomyPortableCustomerReceiptEvidence(receipt: EconomyPortableCustomerReceiptV1, regionalReceipts: readonly EconomyRegionalEvidenceReceiptV1[], expectedRegions: readonly string[], anchor: EconomyIntegrityAnchorManifestV1 | undefined, hashCanonicalPayload: CanonicalPayloadHashFunctionV1, verifySignature: EconomyEvidenceSignatureVerifierV1): void;
2140
+
1389
2141
  type SpendRequestPurpose = "gameplay-conversion" | "non-gameplay";
1390
2142
  type SpendRequestStatus = "requested" | "approved" | "rejected" | "expired" | "executed" | "cancelled";
1391
2143
  /** Future child request; baseline adapters must reject creation while disabled. */
@@ -1407,4 +2159,4 @@ interface SpendRequestV1 {
1407
2159
  /** Validates future child requests while creation remains policy-disabled. */
1408
2160
  declare function assertSpendRequest(request: SpendRequestV1): void;
1409
2161
 
1410
- 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 CloseModuleAllowanceInputV1, type CreateGameplayAllocationInputV1, type CreateModuleAllowanceInputV1, type CreateModulePurchaseReceiptInputV1, type CreateModuleSpendHoldInputV1, type CreateModuleSpendQuoteInputV1, 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 FundModuleAllowanceInputV1, type FxSnapshotV1, type GameplayAllocationV1, type GameplayLimitsV1, type GbpMinorUnitString, type HouseholdId, type IsoTimestamp, type JournalChainHeadV1, type JournalChainId, type LearningEntitlementId, type LearningModuleVersionId, type LedgerPostingV1, type LedgerTransactionV1, type LotId, type LotRefundState, type LotTransferPolicy, type LotUseContextV1, type LotUseOperation, MODULE_ALLOWANCE_PURPOSE, type ModuleAllowanceId, type ModuleAllowanceStatusV1, type ModuleAllowanceV1, type ModulePurchaseEntitlementStateV1, type ModulePurchaseFinancialStateV1, type ModulePurchaseReceiptV1, type ModulePurchaseReconciliationActionV1, type ModulePurchaseReconciliationObservationV1, type ModulePurchaseReconciliationResultV1, type ModuleSpendHoldId, type ModuleSpendHoldStatusV1, type ModuleSpendHoldV1, type ModuleSpendQuoteId, type ModuleSpendQuoteV1, type ModuleSpendTransitionResultV1, PRE_UTILITY_BACKER_COHORT, type PaidLotLifecycleArithmeticV1, type PaidLotLifecycleEventTypeV1, type PaidLotLifecycleEventV1, type PaidLotLifecycleMutationResultV1, type PaidLotLifecycleReceiptV1, type PaidLotLifecycleStatusV1, type PaidLotLifecycleV1, type PaidLotPurchaseProvenanceV1, type PaidLotRetentionV1, type PeriodicLimitWindow, type PersistedIdempotencyResultV1, type PostingId, type ProviderEventId, type PurchaseCapMutationResultV1, type PurchaseCapReservationStatusV1, type PurchaseCapReservationTransitionReceiptV1, type PurchaseCapReservationTransitionTypeV1, type PurchaseCapReservationTransitionV1, type PurchaseCapReservationV1, type PurchaseCapScopeTypeV1, type PurchaseCreditInstructionV1, type PurchaseIntentDisputeDispositionV1, type PurchaseIntentLifecycleV1, type PurchaseIntentReductionV1, type PurchaseIntentStatus, type PurchaseIntentTransitionReceiptV1, type PurchaseIntentTransitionResultV1, type PurchaseIntentTransitionTypeV1, type PurchaseIntentTransitionV1, type PurchaseIntentV1, type PurchaseLimitPolicyV1, type ReclaimGameplayAllocationInputV1, type ReclaimModuleAllowanceInputV1, type RecurrenceInterval, type ReleaseModuleSpendHoldInputV1, type ReservePurchaseCapsCommandV1, type ReversalInputV1, type RewardActivityTransitionV1, type RewardConversionStatus, type RewardConversionV1, type RewardRateV1, type RollingPurchaseCapStateV1, type ScopedPersistedIdempotencyResultV1, type SettleModuleSpendHoldInputV1, 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, applyPaidLotLifecycleEvent, applyPurchaseIntentTransition, applySourceLotMovement, applyTransactionToProjection, applyWalletBalanceDelta, applyWalletLifetimeDeltas, assertActivityEntry, assertBalancedTransaction, assertDeterministicWalletBalanceSummary, assertDistinctAdjustmentApproval, assertEconomicJournalTransaction, assertEconomyCommandEnvelope, assertEconomyCommandWorkflowEvent, assertEconomyIdempotencyScope, assertEconomyIdentifier, assertFlatTokenCatalog, assertFxSnapshot, assertGameplayAllocation, assertJournalChainHead, assertModuleAllowance, assertModulePurchaseReceipt, assertModulePurchaseReconciliationObservation, assertModuleSpendHold, assertModuleSpendQuote, assertNonNegativeAccounts, assertOpenPurchaseIntent, assertPaidLotLifecycle, assertPaidLotLifecycleEvent, assertPaidLotPurchaseProvenance, assertPurchaseCapReservation, assertPurchaseCapReservationTransition, assertPurchaseIntentBinding, assertPurchaseIntentLifecycle, assertPurchaseIntentTransition, assertPurchaseLimitPolicy, assertReversalAvailable, assertRewardConversion, assertRewardRate, assertRollingPurchaseCapState, 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, calculateRollingPurchaseCapUsage, canUseSourceLot, canonicalTransactionPayload, closeModuleAllowance, convertRewardPayout, createEarlyBackerRetentionFromPaidLot, createGameplayAllocation, createInitialSourceLotSnapshot, createModuleAllowance, createModulePurchaseReceipt, createModuleSpendHold, createModuleSpendQuote, createPaidLotLifecycle, createProjectionSnapshot, createPurchaseIntentLifecycle, createReversalTransaction, createRollingPurchaseCapState, createWalletBalanceSummary, createWalletPortfolioLifetime, createWalletPortfolioSummary, deriveWalletBalanceDeltas, deriveWalletLifetimeDeltas, economyAssert, evaluateEarlyBacker, evaluateEarlyBackerBySettlementV2, fundModuleAllowance, isWholeTokenAmount, mapBitLabsConversionState, parseGbpMinorUnits, parseIsoTimestamp, parseTokenSubunits, rebuildBalanceProjection, reclaimGameplayAllocation, reclaimModuleAllowance, reconcileModulePurchase, reducePaidLotLifecycleEvents, reducePurchaseIntentTransitions, releaseModuleSpendHold, reserveRollingPurchaseCaps, selectSourceLots, serializeGbpMinorUnits, serializeTokenSubunits, settleModuleSpendHold, sortStringRecord, subunitsToWholeTokens, sumTokenSubunits, toEconomyErrorEnvelope, transitionRollingPurchaseCapReservation, wholeTokensToSubunits };
2162
+ export { type AccountId, type ActivityEntryV1, type ActivityStatus, type ActivityType, type AdjustmentRequestV1, type AdjustmentStatus, type AllocationId, type AllocationStatus, type AuditedChainedEconomicJournalTransactionV1, type AuditedEconomyCommandEnvelopeV1, 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 CanonicalPayloadHashFunctionV1, type ChainedEconomicJournalTransactionV1, type CloseModuleAllowanceInputV1, type CreateGameplayAllocationInputV1, type CreateModuleAllowanceInputV1, type CreateModulePurchaseReceiptInputV1, type CreateModuleSpendHoldInputV1, type CreateModuleSpendQuoteInputV1, EARLY_BACKER_SETTLEMENT_POLICY_V2, ECONOMY_AUTHORITY_COMMIT_OVERHEAD_OPERATIONS, ECONOMY_AUTHORITY_MAX_BATCH_BYTES, ECONOMY_AUTHORITY_MAX_BATCH_OPERATIONS, ECONOMY_AUTHORITY_MAX_RECORD_REFERENCES, ECONOMY_CONTRACT_VERSION, ECONOMY_RECOVERY_PROTOCOL_VERSION, type EarlyBackerEvaluationV1, type EarlyBackerEvaluationV2, type EarlyBackerWindowV1, type EconomicActivityStatusV1, type EconomicJournalStatus, type EconomicJournalTransactionV1, type EconomicWalletActivityEntryV1, type EconomyAcceptedCommandReceiptV1, type EconomyAcquisitionProviderV1, type EconomyAuditGraphV1, type EconomyAuditedIdempotencyResultV1, type EconomyAuditedIdempotencyScopeV1, type EconomyAuditedIdempotencyStateV1, type EconomyAuthorityCommitKindV1, type EconomyAuthorityCommitManifestV1, type EconomyAuthorityHeadV1, type EconomyAuthorityRecordKindV1, type EconomyAuthorityRecordReferenceV1, type EconomyAuthorityStateV1, type EconomyAuthorityWriteKindV1, type EconomyAuthorizationEvidenceV1, type EconomyCausationKindV1, type EconomyCausationReferenceV1, type EconomyClockPort, type EconomyCommandEnvelopeV1, type EconomyCommandProcessingDispositionV1, type EconomyCommandProcessingModeV1, type EconomyCommandResultOutcomeV1, type EconomyCommandResultReceiptV1, type EconomyCommandSourceV1, type EconomyCommandType, type EconomyCommandWorkflowEventV1, type EconomyCommandWorkflowStateV1, type EconomyContractVersion, type EconomyEncryptedOperationalHandleBindingV1, EconomyError, type EconomyErrorCode, type EconomyErrorEnvelopeV1, type EconomyEvidenceRecordReferenceV1, type EconomyEvidenceSignatureAlgorithmV1, type EconomyEvidenceSignatureMetadataV1, type EconomyEvidenceSignatureV1, type EconomyEvidenceSignatureVerificationInputV1, type EconomyEvidenceSignatureVerifierV1, type EconomyHmacFingerprintDomainV1, type EconomyHmacFingerprintV1, type EconomyHmacSha256DigestV1, type EconomyIdPort, type EconomyIdempotencyScopeV1, type EconomyIntegrityAnchorManifestV1, type EconomyIntegrityFailureCodeV1, type EconomyIntegrityVerificationReceiptV1, type EconomyIntegrityVerificationStatusV1, type EconomyMerkleInclusionProofV1, type EconomyMerkleProofStepV1, type EconomyOperationalHandlePurposeV1, type EconomyOutboxEventV1, type EconomyPersistencePort, type EconomyPersistencePortV2, type EconomyPersistencePortV3, type EconomyPortableCustomerReceiptBodyV1, type EconomyPortableCustomerReceiptV1, type EconomyPortableEvidenceReferenceV1, type EconomyPreparedEvidenceSignatureV1, type EconomyPrincipalTypeV1, type EconomyProviderEvidenceHashV1, type EconomyProviderEvidenceManifestV1, type EconomyQueryPortV1, type EconomyRecoveryAcceptanceBodyV1, type EconomyRecoveryAcceptanceEnvelopeV1, type EconomyRecoveryCommittedResultBodyV1, type EconomyRecoveryCommittedResultV1, type EconomyRecoveryDirectionV1, type EconomyRecoveryProtocolVersion, type EconomyRecoveryRecordKindV1, type EconomyRegionalEvidenceReceiptBodyV1, type EconomyRegionalEvidenceReceiptV1, type EconomySealedRecoveryPayloadV1, type EconomyUnitOfWork, type EconomyUnitOfWorkV2, type EconomyUnitOfWorkV3, type FundModuleAllowanceInputV1, type FxSnapshotV1, type GameplayAllocationV1, type GameplayLimitsV1, type GbpMinorUnitString, type HashedEconomyAuthorityCommitManifestV1, type HouseholdId, type IsoTimestamp, type JournalChainHeadV1, type JournalChainId, type JournalChainVerificationFailureCodeV1, type JournalChainVerificationResultV1, type LearningEntitlementId, type LearningModuleVersionId, type LedgerPostingV1, type LedgerTransactionV1, type LotId, type LotRefundState, type LotTransferPolicy, type LotUseContextV1, type LotUseOperation, MODULE_ALLOWANCE_PURPOSE, type ModuleAllowanceId, type ModuleAllowanceStatusV1, type ModuleAllowanceV1, type ModulePurchaseEntitlementStateV1, type ModulePurchaseFinancialStateV1, type ModulePurchaseReceiptV1, type ModulePurchaseReconciliationActionV1, type ModulePurchaseReconciliationObservationV1, type ModulePurchaseReconciliationResultV1, type ModuleSpendHoldId, type ModuleSpendHoldStatusV1, type ModuleSpendHoldV1, type ModuleSpendQuoteId, type ModuleSpendQuoteV1, type ModuleSpendTransitionResultV1, PRE_UTILITY_BACKER_COHORT, type PaidLotLifecycleArithmeticV1, type PaidLotLifecycleEventTypeV1, type PaidLotLifecycleEventV1, type PaidLotLifecycleMutationResultV1, type PaidLotLifecycleReceiptV1, type PaidLotLifecycleStatusV1, type PaidLotLifecycleV1, type PaidLotPurchaseProvenanceV1, type PaidLotRetentionV1, type PeriodicLimitWindow, type PersistedIdempotencyResultV1, type PostingId, type ProviderEventId, type PurchaseCapMutationResultV1, type PurchaseCapReservationStatusV1, type PurchaseCapReservationTransitionReceiptV1, type PurchaseCapReservationTransitionTypeV1, type PurchaseCapReservationTransitionV1, type PurchaseCapReservationV1, type PurchaseCapScopeTypeV1, type PurchaseCreditInstructionV1, type PurchaseIntentDisputeDispositionV1, type PurchaseIntentLifecycleV1, type PurchaseIntentReductionV1, type PurchaseIntentStatus, type PurchaseIntentTransitionReceiptV1, type PurchaseIntentTransitionResultV1, type PurchaseIntentTransitionTypeV1, type PurchaseIntentTransitionV1, type PurchaseIntentV1, type PurchaseLimitPolicyV1, type ReclaimGameplayAllocationInputV1, type ReclaimModuleAllowanceInputV1, type RecurrenceInterval, type ReleaseModuleSpendHoldInputV1, type ReservePurchaseCapsCommandV1, type ReversalInputV1, type RewardActivityTransitionV1, type RewardConversionStatus, type RewardConversionV1, type RewardRateV1, type RollingPurchaseCapStateV1, type ScopedPersistedIdempotencyResultV1, type SettleModuleSpendHoldInputV1, 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, advanceEconomyAuthorityHead, advanceJournalChainHead, applyPaidLotLifecycleEvent, applyPurchaseIntentTransition, applySourceLotMovement, applyTransactionToProjection, applyWalletBalanceDelta, applyWalletLifetimeDeltas, assertActivityEntry, assertAuditedEconomyCommandEnvelope, assertBalancedTransaction, assertDeterministicWalletBalanceSummary, assertDistinctAdjustmentApproval, assertEconomicJournalTransaction, assertEconomyAcceptedCommandReceipt, assertEconomyAuditGraph, assertEconomyAuditedIdempotencyResult, assertEconomyAuditedIdempotencyScope, assertEconomyAuthorityBatchLimits, assertEconomyAuthorityCommitManifest, assertEconomyAuthorityHead, assertEconomyAuthorityRecordReference, assertEconomyAuthorityRecoveryEvidence, assertEconomyAuthorizationEvidence, assertEconomyCommandEnvelope, assertEconomyCommandResultReceipt, assertEconomyCommandWorkflowEvent, assertEconomyEncryptedOperationalHandleBinding, assertEconomyEvidenceSignature, assertEconomyEvidenceSignatureMetadata, assertEconomyHmacFingerprint, assertEconomyIdempotencyScope, assertEconomyIdentifier, assertEconomyIntegrityAnchorManifest, assertEconomyIntegrityVerificationReceipt, assertEconomyMerkleInclusion, assertEconomyMerkleInclusionProof, assertEconomyPortableCustomerReceipt, assertEconomyPortableCustomerReceiptEvidence, assertEconomyPortableCustomerReceiptSignature, assertEconomyProviderEvidenceHash, assertEconomyProviderEvidenceManifest, assertEconomyRecoveryAcceptanceEnvelope, assertEconomyRecoveryCommittedResult, assertEconomyRecoveryResultLink, assertEconomyRegionalEvidenceChain, assertEconomyRegionalEvidenceEquality, assertEconomyRegionalEvidenceReceipt, assertEconomyRegionalEvidenceReceiptSignature, assertEconomySealedRecoveryPayload, assertExactAuditedEconomyCommandReplay, assertFlatTokenCatalog, assertFxSnapshot, assertGameplayAllocation, assertJournalChainHead, assertModuleAllowance, assertModulePurchaseReceipt, assertModulePurchaseReconciliationObservation, assertModuleSpendHold, assertModuleSpendQuote, assertNonNegativeAccounts, assertOpenPurchaseIntent, assertPaidLotLifecycle, assertPaidLotLifecycleEvent, assertPaidLotPurchaseProvenance, assertPurchaseCapReservation, assertPurchaseCapReservationTransition, assertPurchaseIntentBinding, assertPurchaseIntentLifecycle, assertPurchaseIntentTransition, assertPurchaseLimitPolicy, assertReversalAvailable, assertRewardConversion, assertRewardRate, assertRollingPurchaseCapState, 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, calculateRollingPurchaseCapUsage, canUseSourceLot, canonicalAuditedEconomyCommandEnvelopePayload, canonicalEconomyAcceptedCommandReceiptPayload, canonicalEconomyAuthorityCommitManifestPayload, canonicalEconomyAuthorityHeadPayload, canonicalEconomyCommandResultReceiptPayload, canonicalEconomyEncryptedOperationalHandleBindingPayload, canonicalEconomyIntegrityAnchorManifestPayload, canonicalEconomyIntegrityVerificationReceiptPayload, canonicalEconomyPortableCustomerReceiptBodyPayload, canonicalEconomyPortableCustomerReceiptPayload, canonicalEconomyPortableCustomerReceiptSigningPayload, canonicalEconomyProviderEvidenceHashPayload, canonicalEconomyProviderEvidenceManifestPayload, canonicalEconomyRecoveryAcceptanceBodyPayload, canonicalEconomyRecoveryAcceptanceEnvelopePayload, canonicalEconomyRecoveryCommittedResultBodyPayload, canonicalEconomyRecoveryCommittedResultPayload, canonicalEconomyRegionalEvidenceReceiptBodyPayload, canonicalEconomyRegionalEvidenceReceiptPayload, canonicalEconomyRegionalEvidenceReceiptSigningPayload, canonicalTransactionPayload, closeModuleAllowance, convertRewardPayout, createEarlyBackerRetentionFromPaidLot, createEconomyPortableCustomerReceipt, createEconomyRecoveryAcceptanceEnvelope, createEconomyRecoveryCommittedResult, createEconomyRegionalEvidenceReceipt, createGameplayAllocation, createInitialSourceLotSnapshot, createModuleAllowance, createModulePurchaseReceipt, createModuleSpendHold, createModuleSpendQuote, createPaidLotLifecycle, createProjectionSnapshot, createPurchaseIntentLifecycle, createReversalTransaction, createRollingPurchaseCapState, createWalletBalanceSummary, createWalletPortfolioLifetime, createWalletPortfolioSummary, deriveWalletBalanceDeltas, deriveWalletLifetimeDeltas, economyAssert, evaluateEarlyBacker, evaluateEarlyBackerBySettlementV2, fundModuleAllowance, isWholeTokenAmount, mapBitLabsConversionState, parseGbpMinorUnits, parseIsoTimestamp, parseTokenSubunits, prepareEconomyPortableCustomerReceiptSignature, prepareEconomyRegionalEvidenceReceiptSignature, rebuildBalanceProjection, reclaimGameplayAllocation, reclaimModuleAllowance, reconcileModulePurchase, reducePaidLotLifecycleEvents, reducePurchaseIntentTransitions, releaseModuleSpendHold, reserveRollingPurchaseCaps, selectSourceLots, serializeGbpMinorUnits, serializeTokenSubunits, settleModuleSpendHold, sortEconomyAuthorityRecordReferences, sortStringRecord, subunitsToWholeTokens, sumTokenSubunits, toEconomyErrorEnvelope, transitionRollingPurchaseCapReservation, verifyJournalChainSegment, wholeTokensToSubunits };