@odla-ai/chapter 0.47.10 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -185,6 +185,8 @@ interface ChapterSignupControl {
185
185
  sourceId: string;
186
186
  /** Follower-vault key holding the dedicated edge secret. */
187
187
  secretName?: string;
188
+ /** Optional per-runtime vault keys. When present, unlisted runtimes and legacy untargeted deliveries fail closed. */
189
+ runtimeSecrets?: Readonly<Record<string, string>>;
188
190
  /** Stripe mode this deployed environment accepts. */
189
191
  stripeMode: "test" | "live";
190
192
  }
@@ -192,6 +194,7 @@ interface ChapterSignupControl {
192
194
  interface ResolvedSignupControl {
193
195
  sourceId: string;
194
196
  secretName: string;
197
+ runtimeSecrets?: Readonly<Record<string, string>>;
195
198
  stripeMode: "test" | "live";
196
199
  }
197
200
 
@@ -367,6 +370,9 @@ interface ChapterNetworkReader {
367
370
  * receive pushed records. It must explicitly declare `readers` before any peer
368
371
  * can browse its CRM. */
369
372
  interface ChapterNetwork {
373
+ /** Require the protected super-admin tier for remote mutations and operational
374
+ * detail. Ordinary admins retain routine name/email directory reads. */
375
+ requireSuperAdminWrites?: boolean;
370
376
  targets?: readonly ChapterNetworkTarget[];
371
377
  readers?: readonly ChapterNetworkReader[];
372
378
  }
@@ -421,6 +427,7 @@ interface ResolvedNetworkReader {
421
427
  }
422
428
  /** Fully-resolved leader network configuration. */
423
429
  interface ResolvedNetwork {
430
+ requireSuperAdminWrites?: boolean;
424
431
  targets: readonly ResolvedNetworkTarget[];
425
432
  readers: readonly ResolvedNetworkReader[];
426
433
  }
@@ -615,7 +622,9 @@ interface ChapterScheduling {
615
622
  }
616
623
  /** How a signed-in user's role is determined.
617
624
  *
618
- * - `"claim"` reads a role ladder from a JWT claim (the member-site model:
625
+ * - `"clerk"` reads backend-only private Clerk roles for each authorization
626
+ * check, without trusting public metadata or stale session roles.
627
+ * - `"claim"` reads a role ladder from a JWT claim (the legacy member-site model:
619
628
  * `provisional → member → admin`). Admin is the last (highest) rung; the
620
629
  * Studio-managed super-admin tier sits above it.
621
630
  * - `"table"` gates on the deny-all `admins` allowlist (the hub model):
@@ -623,23 +632,25 @@ interface ChapterScheduling {
623
632
  *
624
633
  * Defaults: `"claim"` in `chapter` mode, `"table"` in `hub` mode. */
625
634
  interface ChapterAuth {
626
- source?: "claim" | "table";
635
+ /** `clerk` reads backend-only private_metadata.role on each request, ignoring
636
+ * JWT/public roles. Select explicitly after the coordinated role migration. */
637
+ source?: "claim" | "table" | "clerk";
627
638
  /** JWT claim holding the role, for `source: "claim"`. Default `"role"`. */
628
639
  claim?: string;
629
- /** Role ladder low→high, for `source: "claim"`. The last entry is admin.
640
+ /** Role ladder low→high, for claim or private Clerk roles. The last entry is admin.
630
641
  * Default `["provisional", "member", "admin"]`. */
631
642
  ladder?: readonly string[];
632
643
  /** Enable the Studio-managed super-admin tier — the only tier that may
633
- * create/modify admins. Default: `true` for `"claim"`, `false` for `"table"`. */
644
+ * create/modify admins. Default: `true` for `"claim"`/`"clerk"`, `false` for `"table"`. */
634
645
  superAdmins?: boolean;
635
646
  /** Authority behind the super-admin tier. `"table"` preserves the legacy
636
- * app allowlist; `"odla"` reads protected `$users.role`. Default `"table"`
637
- * for backward compatibility. */
647
+ * app allowlist; `"odla"` reads protected `$users.role` by exact subject ID.
648
+ * Default `"odla"` for private Clerk mode, `"table"` for legacy modes. */
638
649
  superAdminSource?: "table" | "odla";
639
650
  }
640
651
  /** The fully-resolved auth policy (defaults applied) carried on the {@link Chapter}. */
641
652
  interface ResolvedAuth {
642
- source: "claim" | "table";
653
+ source: "claim" | "table" | "clerk";
643
654
  claim: string;
644
655
  ladder: readonly string[];
645
656
  /** The highest ladder rung (last entry) — the "admin" gate. */
@@ -919,12 +930,13 @@ interface NetworkCommercialFact {
919
930
  eventType: string;
920
931
  eventCreated: number;
921
932
  livemode: boolean;
922
- objectKind: CommercialObjectKind | "ignored";
933
+ objectKind: CommercialObjectKind | "payment_intent" | "ignored";
923
934
  objectId: string;
924
935
  identity: CommercialIdentity;
925
936
  applicationId?: string;
926
937
  personId?: string;
927
938
  membershipId?: string;
939
+ seatId?: string;
928
940
  customerId?: string;
929
941
  subscriptionId?: string;
930
942
  invoiceId?: string;
@@ -936,6 +948,18 @@ interface NetworkCommercialFact {
936
948
  currency?: string;
937
949
  amountCents?: number;
938
950
  amountPaidCents?: number;
951
+ amountReceivedCents?: number;
952
+ invoiceTotalCents?: number;
953
+ billingReason?: string;
954
+ invoicePaidAt?: number;
955
+ invoicePeriodEndsAt?: number;
956
+ /** Complete, non-prorated recurring invoice lines; absent when ambiguous or truncated. */
957
+ recurringInvoiceLines?: Array<{
958
+ priceId: string;
959
+ quantity: number;
960
+ startsAt: number;
961
+ endsAt: number;
962
+ }>;
939
963
  amountRemainingCents?: number;
940
964
  currentPeriodStart?: number;
941
965
  currentPeriodEnd?: number;
@@ -957,6 +981,8 @@ interface NetworkCommercialException {
957
981
  }
958
982
  /** Complete deterministic view rebuilt from the append-only commercial event log. */
959
983
  interface NetworkCommercialProjection {
984
+ /** Standalone named-seat payments; subscription PaymentIntents are already counted in invoices. */
985
+ seatPayments?: NetworkCommercialProjectedRow[];
960
986
  customers: NetworkCommercialProjectedRow[];
961
987
  subscriptions: NetworkCommercialProjectedRow[];
962
988
  invoices: NetworkCommercialProjectedRow[];
@@ -997,6 +1023,7 @@ declare function reconcileStripeSnapshot(shadow: NetworkCommercialProjection, sn
997
1023
  subscriptions: StripeObjectSnapshot;
998
1024
  invoices: StripeObjectSnapshot;
999
1025
  refunds: StripeObjectSnapshot;
1026
+ payments?: StripeObjectSnapshot;
1000
1027
  }, sources: readonly NetworkCommercialSource[]): StripeCommercialReconciliation;
1001
1028
 
1002
1029
  /** Reduce a verified Stripe event to a bounded, PII-free fact. */
@@ -1228,6 +1255,505 @@ declare function chapterDb(mode: ChapterMode, auth: ResolvedAuth, includeNetwork
1228
1255
  rules: DbRules;
1229
1256
  };
1230
1257
 
1258
+ /** Immutable commercial policy, separate from the recurring base SKU. */
1259
+ interface MembershipOfferingVersion {
1260
+ id: string;
1261
+ chapterId: string;
1262
+ baseSkuId: string;
1263
+ version: number;
1264
+ status: "draft" | "published" | "retired";
1265
+ effectiveFrom: number;
1266
+ effectiveUntil?: number;
1267
+ basePriceCents: number;
1268
+ currency: string;
1269
+ interval: "month" | "year";
1270
+ term: {
1271
+ kind: "fixed_end";
1272
+ endsAt: number;
1273
+ } | {
1274
+ kind: "rolling_months";
1275
+ months: number;
1276
+ };
1277
+ autoRenew: true;
1278
+ paymentGraceDays: number;
1279
+ seatPriceCents: number;
1280
+ seatPurchaseWindowCalendarMonths: number;
1281
+ requiredDisclosures: string[];
1282
+ }
1283
+ /** Cohort qualification survives the expiration of its monetary benefit. */
1284
+ interface MembershipDiscountPolicyVersion {
1285
+ id: string;
1286
+ chapterId: string;
1287
+ version: number;
1288
+ status: "draft" | "published" | "retired";
1289
+ cohortLabel: string;
1290
+ cohortEligibleSkuIds: string[];
1291
+ discountEligibleSkuIds: string[];
1292
+ softTarget: number;
1293
+ percentOffBps: number;
1294
+ qualifyingStartsAt: number;
1295
+ qualifyingEndsAt: number;
1296
+ benefitDuration: {
1297
+ kind: "first_term" | "while_active";
1298
+ } | {
1299
+ kind: "fixed_end";
1300
+ endsAt: number;
1301
+ };
1302
+ }
1303
+ /** Add UTC calendar months, clamping month-end dates while preserving the time. */
1304
+ declare function addMembershipCalendarMonths(input: number | string, months: number): number;
1305
+ /** Normalize one version before publishing or issuing it; never retain caller-owned nested objects. */
1306
+ declare function membershipOfferingVersion(value: unknown): MembershipOfferingVersion;
1307
+ /** Normalize cohort and discount eligibility independently; zero discount can still confer founding status. */
1308
+ declare function membershipDiscountPolicyVersion(value: unknown): MembershipDiscountPolicyVersion;
1309
+
1310
+ /** Frozen commercial terms supplied by the issuing membership authority, never the browser. */
1311
+ interface SubscriptionBillingTerms {
1312
+ /** Immutable offering version whose base Price is subscribed. */
1313
+ offeringVersionId: string;
1314
+ /** Immutable discount policy, independent of the base SKU and permanent cohort. */
1315
+ discount?: {
1316
+ policyVersionId: string;
1317
+ couponId: string;
1318
+ percentOffBps: number;
1319
+ duration: "once" | "forever";
1320
+ };
1321
+ /** Extended initial paid service end, epoch milliseconds. Renewal starts here. */
1322
+ initialTermEndsAt?: number;
1323
+ }
1324
+
1325
+ /** Money and service promise frozen at offer issuance, not recomputed from later policy edits. */
1326
+ interface MembershipCommercialOffer {
1327
+ offering: MembershipOfferingVersion;
1328
+ discountPolicy: MembershipDiscountPolicyVersion | null;
1329
+ issuedAt: number;
1330
+ founding: boolean;
1331
+ dueTodayCents: number;
1332
+ /** Fixed service end only; rolling service starts at the provider-confirmed payment. */
1333
+ initialTermEndsAt?: number;
1334
+ renewalCents: number;
1335
+ billingTerms: SubscriptionBillingTerms;
1336
+ }
1337
+ /** Calculate a new offer from authority-owned policy and its approved, dues-paying cohort count.
1338
+ * This pure function does not reserve a position or make a shadow ledger authoritative.
1339
+ * Persist the returned promise before accepting consent or performing provider I/O.
1340
+ */
1341
+ declare function createMembershipCommercialOffer(input: {
1342
+ offering: unknown;
1343
+ discountPolicy?: unknown;
1344
+ approvedFoundingCount: number;
1345
+ now: number;
1346
+ /** Coupon identity must be partitioned by app, environment, runtime and immutable policy. */
1347
+ couponId?: string;
1348
+ }): MembershipCommercialOffer;
1349
+
1350
+ /** Verified source identity supplied by the server adapter, never by a browser's price payload. */
1351
+ interface MembershipOfferRequest {
1352
+ offerId: string;
1353
+ applicationId: string;
1354
+ appId: string;
1355
+ chapterId: string;
1356
+ environment: string;
1357
+ runtime: string;
1358
+ skuId: string;
1359
+ now: number;
1360
+ lifetimeMs: number;
1361
+ }
1362
+ /** Durable pre-payment promise. The opaque digest is what the member acknowledges. */
1363
+ interface IssuedMembershipOffer {
1364
+ id: string;
1365
+ applicationId: string;
1366
+ appId: string;
1367
+ chapterId: string;
1368
+ environment: string;
1369
+ runtime: string;
1370
+ skuId: string;
1371
+ issuedAt: number;
1372
+ expiresAt: number;
1373
+ digest: string;
1374
+ contract: MembershipCommercialOffer;
1375
+ }
1376
+ /** Stable request identity shared by the issuer and a verifying follower. */
1377
+ declare function membershipOfferIdForRequest(input: Pick<MembershipOfferRequest, "appId" | "chapterId" | "environment" | "runtime" | "applicationId"> & {
1378
+ requestId: string;
1379
+ }): Promise<string>;
1380
+ /** Validate and copy a trusted authority response before saving it as a chapter projection.
1381
+ * This verifies the complete target, normalized money promise and digest; it does not
1382
+ * authenticate its transport or make caller-supplied offers authoritative.
1383
+ */
1384
+ declare function verifyIssuedMembershipOffer(value: unknown, expected: MembershipOfferRequest): Promise<IssuedMembershipOffer>;
1385
+ /** Issue in the network data scope with a revision fence against policy/cohort changes.
1386
+ * The authority state must be explicitly initialized and every policy/count mutation
1387
+ * must increment its revision in the same transaction. Shadow data never qualifies.
1388
+ * This function neither calls Stripe nor grants access. Its caller authenticates the
1389
+ * source deployment before invoking it and must enforce expiry before checkout starts.
1390
+ */
1391
+ declare function issueMembershipCommercialOffer(db: ChapterDb, input: MembershipOfferRequest): Promise<IssuedMembershipOffer>;
1392
+
1393
+ /** A dedicated two-sided edge: no chapter receives the network database credential. */
1394
+ interface MembershipAuthorityPeer {
1395
+ appId: string;
1396
+ chapterId: string;
1397
+ environment: string;
1398
+ runtime: string;
1399
+ secretName: string;
1400
+ /** Authority-configured, product-separated recurring named-seat Price. Omit to disable seat commands. */
1401
+ seatPriceId?: string;
1402
+ }
1403
+ /** Business API configuration, independent of the browser UI. May be mounted in
1404
+ * the existing BNF backend using its existing odla database; no extra app required.
1405
+ */
1406
+ interface MembershipAuthorityHandlerOptions {
1407
+ peers: readonly MembershipAuthorityPeer[];
1408
+ /** Connect to the network owner's database (BNF), never a chapter projection. */
1409
+ makeDb: () => ChapterDb;
1410
+ now?: () => number;
1411
+ offerLifetimeMs: number;
1412
+ /** Network vault slot; never supplied by a caller. Defaults to stripe_secret_key. */
1413
+ stripeSecretName?: string;
1414
+ }
1415
+ /** Signed server-to-server route; the runtime is included in the signed request target. */
1416
+ declare const MEMBERSHIP_AUTHORITY_PATH = "/api/membership-authority";
1417
+ /** Create the narrow signed offer issuer. Authentication maps each dedicated edge
1418
+ * to an exact app/chapter/environment/runtime; callers cannot select another scope,
1419
+ * provide prices, grant roles, or run arbitrary network database operations.
1420
+ * Replayed signed requests are safe because issuance is durably idempotent.
1421
+ */
1422
+ declare function createMembershipAuthorityHandler(options: MembershipAuthorityHandlerOptions): (req: Request) => Promise<Response>;
1423
+
1424
+ /** Per-tier policy overrides prevent a chapter-wide price claim leaking into another SKU. */
1425
+ interface TierPaymentPolicy {
1426
+ refundPolicyText: string;
1427
+ trustCopy?: string;
1428
+ }
1429
+
1430
+ /** Server-owned source identity; the browser never supplies an offer or its price. */
1431
+ interface MembershipQuoteTarget {
1432
+ appId: string;
1433
+ chapterId: string;
1434
+ environment: string;
1435
+ runtime: string;
1436
+ applicationId: string;
1437
+ skuId: string;
1438
+ }
1439
+ /** Host transport adapter; may call the signed edge or an in-process network command. */
1440
+ type MembershipOfferIssuer = (input: MembershipQuoteTarget & {
1441
+ requestId: string;
1442
+ }) => Promise<IssuedMembershipOffer>;
1443
+
1444
+ /** A consented offer, bound once to the follower's immutable provider Price and quote. */
1445
+ interface MembershipCheckoutBindingInput extends MembershipQuoteTarget {
1446
+ offerId: string;
1447
+ offerDigest: string;
1448
+ quoteDigest: string;
1449
+ priceId: string;
1450
+ }
1451
+ /** Content-free authority receipt. It does not mean paid, approved, or entitled. */
1452
+ interface MembershipCheckoutBinding extends MembershipCheckoutBindingInput {
1453
+ id: string;
1454
+ boundAt: number;
1455
+ }
1456
+ /** Stable per-application binding identity, separate from an individual offer generation. */
1457
+ declare function membershipCheckoutBindingId(input: MembershipQuoteTarget): Promise<string>;
1458
+ /** Validate an authenticated transport's receipt and discard all undeclared fields. */
1459
+ declare function verifyMembershipCheckoutBinding(value: unknown, input: MembershipCheckoutBindingInput): Promise<MembershipCheckoutBinding>;
1460
+ /** Bind accepted terms in the network transaction before any provider creation.
1461
+ * Replays preserve an already-bound offer after its issuance window ends.
1462
+ * A different offer/Price/consent for the same application is never a second purchase.
1463
+ */
1464
+ declare function bindMembershipCheckout(db: ChapterDb, input: MembershipCheckoutBindingInput, now: number): Promise<MembershipCheckoutBinding>;
1465
+
1466
+ /** References only. Money facts must already exist in the verified network Stripe event log. */
1467
+ interface ConfirmMembershipPaymentInput extends MembershipQuoteTarget {
1468
+ eventId: string;
1469
+ providerSubscriptionId: string;
1470
+ providerCustomerId: string;
1471
+ }
1472
+ /** The network identity remains source-linked until an explicit canonical Person link exists. */
1473
+ interface MembershipPaymentReceipt {
1474
+ membershipId: string;
1475
+ status: string;
1476
+ initialTermStartedAt: number;
1477
+ initialTermEndsAt: number;
1478
+ cohort: string;
1479
+ memberNumber?: number;
1480
+ }
1481
+ /** Stable network membership identity for the exact chapter application and runtime. */
1482
+ declare function networkMembershipId(input: MembershipQuoteTarget): Promise<string>;
1483
+ /** Commit payment and the pending primary entitlement together, before chapter access can advance.
1484
+ * An authenticated Chapter supplies references, never a paid amount or a synthetic Person id.
1485
+ * A missing independently verified Stripe fact is retryable; browser success is not evidence.
1486
+ */
1487
+ declare function confirmMembershipPayment(db: ChapterDb, input: ConfirmMembershipPaymentInput, now: number): Promise<MembershipPaymentReceipt>;
1488
+
1489
+ /** Session identity attested by the signed chapter adapter, never a browser's email_verified flag. */
1490
+ interface NamedSeatRecipientInput extends MembershipQuoteTarget {
1491
+ seatId: string;
1492
+ recipientApplicationId: string;
1493
+ recipientUserId: string;
1494
+ verifiedRecipientEmail: string;
1495
+ }
1496
+
1497
+ /** Verified full initial refund and subscription cancellation, not a browser assertion. */
1498
+ interface MembershipRefundReceipt {
1499
+ membershipId: string;
1500
+ status: "refunded";
1501
+ refundedCents: number;
1502
+ subscriptionCanceled: true;
1503
+ }
1504
+ /** Refund the frozen initial membership purchase; retain cohort and member order permanently.
1505
+ * The adapter authenticates the operator. Pending state prevents new access while provider effects retry.
1506
+ */
1507
+ declare function refundNetworkMembership(db: ChapterDb, input: MembershipQuoteTarget, secretKey: string, now: number): Promise<MembershipRefundReceipt>;
1508
+
1509
+ /** Current authoritative billing state; a chapter projection must not derive it from arrival order. */
1510
+ interface MembershipRenewalReceipt {
1511
+ membershipId: string;
1512
+ status: string;
1513
+ termEndsAt: number;
1514
+ graceEndsAt: number;
1515
+ autoRenew: boolean;
1516
+ }
1517
+ /** Apply independently verified renewal success/failure, including co-terminating named seats.
1518
+ * The period and immutable Price set, not webhook delivery order, fence progression.
1519
+ */
1520
+ declare function reconcileMembershipRenewal(db: ChapterDb, input: MembershipQuoteTarget & {
1521
+ eventId: string;
1522
+ }, now: number): Promise<MembershipRenewalReceipt>;
1523
+
1524
+ /** Short-lived decision from current network state; never a durable bearer capability. */
1525
+ interface MembershipAccessReceipt {
1526
+ membershipId: string;
1527
+ allowed: boolean;
1528
+ status: string;
1529
+ accessEndsAt: number;
1530
+ revision: number;
1531
+ }
1532
+ /** Enforce term/grace expiry even when a webhook, cron, or Clerk role update is delayed. */
1533
+ declare function readMembershipAccess(db: ChapterDb, input: MembershipQuoteTarget, now: number): Promise<MembershipAccessReceipt>;
1534
+ /** Reject an invalid network receipt before a chapter grants private-content access. */
1535
+ declare function verifyMembershipAccessReceipt(value: unknown, input: MembershipQuoteTarget, now: number): Promise<MembershipAccessReceipt>;
1536
+
1537
+ /** Named-seat offer for the authenticated purchaser, not a transferable gift or arbitrary quantity. */
1538
+ interface NamedSeatOffer {
1539
+ membershipId: string;
1540
+ amountCents: number;
1541
+ currency: string;
1542
+ interval: "year" | "month";
1543
+ termEndsAt: number;
1544
+ purchaseEndsAt: number;
1545
+ autoRenew: boolean;
1546
+ eligible: boolean;
1547
+ digest: string;
1548
+ seat?: {
1549
+ seatId: string;
1550
+ status: string;
1551
+ recipientName: string;
1552
+ recipientEmail: string;
1553
+ };
1554
+ }
1555
+ /** Stable commercial consent fingerprint; eligibility is always checked again at checkout. */
1556
+ declare function namedSeatOfferDigest(offer: Omit<NamedSeatOffer, "digest">): Promise<string>;
1557
+ /** Read the frozen offering and any existing seat without reserving or charging anything. */
1558
+ declare function readNamedSeatOffer(db: ChapterDb, input: MembershipQuoteTarget, now: number): Promise<NamedSeatOffer>;
1559
+
1560
+ /** Identity attested by the recipient's chapter after checking Clerk's verified primary email. */
1561
+ interface NamedSeatInvitationRequest {
1562
+ appId: string;
1563
+ chapterId: string;
1564
+ environment: string;
1565
+ runtime: string;
1566
+ seatId: string;
1567
+ recipientUserId: string;
1568
+ verifiedRecipientEmail: string;
1569
+ }
1570
+ /** Recipient-visible invitation; no purchaser contact information or provider credentials. */
1571
+ interface NamedSeatInvitation {
1572
+ seatId: string;
1573
+ primaryApplicationId: string;
1574
+ skuId: string;
1575
+ recipientName: string;
1576
+ status: string;
1577
+ acceptanceEndsAt: number;
1578
+ termEndsAt: number;
1579
+ }
1580
+ /** Resolve the invitation only for its named, verified person (or already bound user ID). */
1581
+ declare function readNamedSeatInvitation(db: ChapterDb, input: NamedSeatInvitationRequest, now: number): Promise<NamedSeatInvitation>;
1582
+ /** Recipient access requires both current primary membership and this exact bound seat's entitlement. */
1583
+ declare function readNamedSeatAccess(db: ChapterDb, input: MembershipQuoteTarget & {
1584
+ seatId: string;
1585
+ recipientUserId: string;
1586
+ recipientApplicationId: string;
1587
+ }, now: number): Promise<MembershipAccessReceipt>;
1588
+
1589
+ /** Exact configured chapter/runtime serviced by one scheduled network worker. */
1590
+ type MembershipEffectScope = Pick<MembershipQuoteTarget, "appId" | "chapterId" | "environment" | "runtime">;
1591
+ /** Downstream requests carry only identifiers; the signed chapter receiver reads current state and deduplicates by effectId. */
1592
+ interface MembershipChapterEffect extends MembershipQuoteTarget {
1593
+ effectId: string;
1594
+ seatId: string;
1595
+ kind: "invite_named_recipient" | "grant_named_recipient_access" | "revoke_named_recipient_access";
1596
+ }
1597
+ /** Recover provider effects and expired invitations from durable state, independently of browser/webhook retries.
1598
+ * The optional chapter adapter must return a durable, idempotent receipt. An absent adapter leaves work visibly pending.
1599
+ * Provider HTTP timeouts, ambiguous receipts and scope conflicts never become success or an unbounded automatic retry loop.
1600
+ */
1601
+ declare function drainMembershipEffects(db: ChapterDb, options: {
1602
+ scope: MembershipEffectScope;
1603
+ stripeSecretKey: string;
1604
+ limit?: number;
1605
+ deliverChapterEffect?: (input: MembershipChapterEffect) => Promise<{
1606
+ effectId: string;
1607
+ complete: true;
1608
+ }>;
1609
+ }, now: number): Promise<{
1610
+ complete: number;
1611
+ pending: number;
1612
+ expired: number;
1613
+ more: boolean;
1614
+ }>;
1615
+
1616
+ /** Minimal chapter-owned delivery data, fetched over the authenticated runtime edge, never from a browser payload. */
1617
+ interface MembershipChapterEffectData extends MembershipChapterEffect {
1618
+ recipientName: string;
1619
+ recipientEmail: string;
1620
+ recipientUserId: string | null;
1621
+ recipientApplicationId: string | null;
1622
+ acceptanceEndsAt: number;
1623
+ termEndsAt: number;
1624
+ applicable: boolean;
1625
+ }
1626
+ /** Read current effect eligibility and the named recipient from the authoritative seat, not a stale queued message. */
1627
+ declare function readMembershipChapterEffect(db: ChapterDb, input: MembershipChapterEffect, now: number): Promise<MembershipChapterEffectData>;
1628
+
1629
+ /** Inputs supplied by an authenticated chapter backend; no browser credentials cross this edge. */
1630
+ interface RequestMembershipOfferOptions {
1631
+ secret: string;
1632
+ targetUrl: string;
1633
+ appId: string;
1634
+ chapterId: string;
1635
+ environment: string;
1636
+ runtime: string;
1637
+ applicationId: string;
1638
+ skuId: string;
1639
+ requestId: string;
1640
+ /** A configured service binding may replace public fetch, but must not fall back when absent. */
1641
+ fetch?: typeof globalThis.fetch;
1642
+ }
1643
+ /** Request and verify one durable network offer before any payment provider call. */
1644
+ declare function requestMembershipCommercialOffer(options: RequestMembershipOfferOptions): Promise<IssuedMembershipOffer>;
1645
+ /** Bind the exact consent and Price before Stripe is contacted. */
1646
+ declare function requestMembershipCheckoutBinding(options: MembershipCheckoutBindingInput & Pick<RequestMembershipOfferOptions, "secret" | "targetUrl" | "fetch">): Promise<MembershipCheckoutBinding>;
1647
+ type AuthorityTransport = Pick<RequestMembershipOfferOptions, "secret" | "targetUrl" | "fetch">;
1648
+ /** Fetch current delivery state; the caller cannot substitute an email, account, term, or entitlement. */
1649
+ declare function requestMembershipChapterEffect(options: MembershipChapterEffect & AuthorityTransport): Promise<MembershipChapterEffectData>;
1650
+ /** Only the named buyer's prepared payment details; no network credentials or canonical PII. */
1651
+ interface NamedSeatCheckoutReceipt {
1652
+ seatId: string;
1653
+ paymentIntentId: string;
1654
+ clientSecret: string;
1655
+ amountCents: number;
1656
+ currency: string;
1657
+ termEndsAt: number;
1658
+ status: string;
1659
+ }
1660
+ /** Result of attesting one verified recipient's acceptance or completed Journey. */
1661
+ interface NamedSeatRecipientReceipt {
1662
+ seatId: string;
1663
+ status: string;
1664
+ recipientApplicationId: string;
1665
+ }
1666
+ /** Full seat-only refund. The purchaser's primary subscription is not canceled. */
1667
+ interface NamedSeatRefundReceipt {
1668
+ seatId: string;
1669
+ status: "refunded";
1670
+ refundedCents: number;
1671
+ subscriptionCanceled: false;
1672
+ }
1673
+ /** Refund a declined recipient's exact bound seat; the caller authenticates the chapter operator. */
1674
+ declare function requestNamedSeatDecline(options: NamedSeatRecipientInput & AuthorityTransport): Promise<NamedSeatRefundReceipt>;
1675
+ /** Verified purchaser identity and their named recipient, with no caller-selected pricing. */
1676
+ type NamedSeatCheckoutRequest = MembershipQuoteTarget & {
1677
+ recipientName: string;
1678
+ recipientEmail: string;
1679
+ purchaserEmail: string;
1680
+ purchaserUserId: string;
1681
+ };
1682
+ /** Reserve the exact recipient before freezing local consent, without contacting a payment provider. */
1683
+ declare function requestNamedSeatReservation(options: NamedSeatCheckoutRequest & AuthorityTransport): Promise<Pick<NamedSeatCheckoutReceipt, "seatId" | "amountCents" | "currency" | "termEndsAt">>;
1684
+ /** Reference to an independent network Stripe fact, never caller-supplied payment amounts. */
1685
+ type NamedSeatEvidenceRequest = MembershipQuoteTarget & {
1686
+ seatId: string;
1687
+ eventId: string;
1688
+ };
1689
+ /** Read an authenticated purchaser's seat terms and existing named recipient. */
1690
+ declare function requestNamedSeatOffer(options: MembershipQuoteTarget & AuthorityTransport): Promise<NamedSeatOffer>;
1691
+ /** Look up one invitation only after the chapter verifies the recipient's current primary email. */
1692
+ declare function requestNamedSeatInvitation(options: NamedSeatInvitationRequest & AuthorityTransport): Promise<NamedSeatInvitation>;
1693
+ /** Check the exact recipient's current entitlement rather than relying on a cached account role. */
1694
+ declare function requestNamedSeatAccess(options: MembershipQuoteTarget & {
1695
+ seatId: string;
1696
+ recipientUserId: string;
1697
+ recipientApplicationId: string;
1698
+ } & AuthorityTransport): Promise<MembershipAccessReceipt>;
1699
+ /** Prepare one named purchase through the configured network Price, never a caller-selected Price. */
1700
+ declare function requestNamedSeatCheckout(options: NamedSeatCheckoutRequest & AuthorityTransport): Promise<NamedSeatCheckoutReceipt>;
1701
+ /** Forward only the reference to independently verified network payment evidence. */
1702
+ declare function requestNamedSeatPayment(options: NamedSeatEvidenceRequest & AuthorityTransport): Promise<{
1703
+ seatId: string;
1704
+ reconciled: true;
1705
+ }>;
1706
+ /** Forward a complete seat refund without changing the purchaser's membership. */
1707
+ declare function requestNamedSeatRefund(options: NamedSeatEvidenceRequest & AuthorityTransport): Promise<{
1708
+ seatId: string;
1709
+ reconciled: true;
1710
+ }>;
1711
+ /** Claim only the verified named recipient's invitation. */
1712
+ declare function requestNamedSeatAcceptance(options: NamedSeatRecipientInput & AuthorityTransport): Promise<NamedSeatRecipientReceipt>;
1713
+ /** Attest that recipient's own completed Journey. */
1714
+ declare function requestNamedSeatApproval(options: NamedSeatRecipientInput & AuthorityTransport): Promise<NamedSeatRecipientReceipt>;
1715
+ /** Reconcile local provider references against independently signed network Stripe facts. */
1716
+ declare function requestMembershipPayment(options: ConfirmMembershipPaymentInput & AuthorityTransport): Promise<MembershipPaymentReceipt>;
1717
+ /** Attest durable chapter Journey approval; the network alone assigns order and entitlement. */
1718
+ declare function requestMembershipApproval(options: MembershipQuoteTarget & AuthorityTransport): Promise<MembershipPaymentReceipt>;
1719
+ /** Refund only the network's frozen initial invoice and cancel its subscription. Caller must authenticate the operator first. */
1720
+ declare function requestMembershipRefund(options: MembershipQuoteTarget & AuthorityTransport): Promise<MembershipRefundReceipt>;
1721
+ /** Advance billing only from independently verified network invoice evidence. */
1722
+ declare function requestMembershipRenewal(options: MembershipQuoteTarget & {
1723
+ eventId: string;
1724
+ } & AuthorityTransport): Promise<MembershipRenewalReceipt>;
1725
+ /** Read current entitlement for one authenticated member; network outages must fail closed. */
1726
+ declare function requestMembershipAccess(options: MembershipQuoteTarget & AuthorityTransport): Promise<MembershipAccessReceipt>;
1727
+
1728
+ /** The signed chapter adapter attests that its own Journey approval is durable.
1729
+ * Payment, cohort and order come exclusively from network authority records.
1730
+ * An issued paid founding promise is honored even after the soft target is reached.
1731
+ */
1732
+ declare function approveNetworkMembership(db: ChapterDb, input: MembershipQuoteTarget, now: number): Promise<MembershipPaymentReceipt>;
1733
+
1734
+ /** Validate a trusted transport response before using it to advance a chapter Journey. */
1735
+ declare function verifyMembershipPaymentReceipt(value: unknown, target: MembershipQuoteTarget): Promise<MembershipPaymentReceipt>;
1736
+
1737
+ /** Reconcile invoices, cancellation settings and provider-initiated full initial refunds from independent evidence.
1738
+ * Current Stripe reads arbitrate out-of-order subscription events. Only paid invoices extend a membership term.
1739
+ */
1740
+ declare function reconcileMembershipBilling(db: ChapterDb, input: MembershipQuoteTarget & {
1741
+ eventId: string;
1742
+ }, now: number, stripeSecretName?: string): Promise<MembershipRenewalReceipt>;
1743
+
1744
+ /** Opt-in network-scope schema. Do not install as independent chapter authorities. */
1745
+ declare const membershipOfferEntities: Record<string, Entity>;
1746
+ /** Browser callers cannot read, issue or alter commercial promises. */
1747
+ declare const membershipOfferRules: DbRules;
1748
+
1749
+ /** Authoritative network purchase records, installed once in the network scope.
1750
+ * A canonical Person link is optional until explicit reconciliation; source identity is not.
1751
+ * These records must never be populated by a shadow projection writer.
1752
+ */
1753
+ declare const membershipAuthorityEntities: Record<string, Entity>;
1754
+ /** Backend-only authority; browser roles, including a network admin, cannot directly change these rows. */
1755
+ declare const membershipAuthorityRules: DbRules;
1756
+
1231
1757
  /** Validate one complete parent or chapter authoring layer with actionable paths. */
1232
1758
  declare function validateMemberContentDocument(input: unknown, options?: MemberContentValidationOptions): MemberContentValidationResult;
1233
1759
  /** Validate or fail closed with every actionable document error. */
@@ -1572,7 +2098,7 @@ declare function createBuilderLibraryEnvelope(document: BuilderLibraryDocument):
1572
2098
 
1573
2099
  /** The default shared CRM graph: people (with the application/member pipeline)
1574
2100
  * plus businesses and the `works_at` relation, in both modes. */
1575
- declare function defaultCrm(_mode: ChapterMode): CrmConfig;
2101
+ declare function defaultCrm(mode: ChapterMode): CrmConfig;
1576
2102
 
1577
2103
  /** The `groups` row (attrs) for `chapter` mode. Missing config falls back to
1578
2104
  * empty copy / defaults, so a minimal config still provisions cleanly. */
@@ -1664,11 +2190,10 @@ declare function render(template: string, vars: Record<string, string>): string;
1664
2190
  */
1665
2191
  declare function renderTemplateBody(group: EmailGroup, template: string, vars: Record<string, string>): string | null;
1666
2192
  /**
1667
- * E1 (exactly-once): given the prior `emailLog` rows for a `dedupeKey`, has the
2193
+ * E1 (confirmed delivery): given prior `emailLog` rows for a `dedupeKey`, has the
1668
2194
  * mail already been delivered? A prior row with **no error** means yes — the
1669
- * caller short-circuits the resend. Failure rows (which carry an `error` and are
1670
- * written without the dedupe mutationId) do not count, so a retry after a failure
1671
- * can still succeed.
2195
+ * caller short-circuits the resend. Pending/uncertain rows carry an error marker;
2196
+ * the orchestration layer must reconcile those rather than blindly resending.
1672
2197
  */
1673
2198
  declare function isAlreadySent(priorRows: ReadonlyArray<{
1674
2199
  error?: unknown;
@@ -1729,10 +2254,12 @@ interface NotifyDeps {
1729
2254
  envName: string;
1730
2255
  sender?: MailSender;
1731
2256
  from?: string;
2257
+ /** Runtime-local non-production inbox; never changes the shared chapter setting. */
2258
+ debugEmail?: string;
1732
2259
  now: () => number;
1733
2260
  newId: () => string;
1734
2261
  }
1735
- /** One templated send. `dedupeKey` is the exactly-once key. */
2262
+ /** One templated send. `dedupeKey` identifies one durable delivery workflow. */
1736
2263
  interface NotifyInput {
1737
2264
  group: EmailGroup;
1738
2265
  template: string;
@@ -1749,15 +2276,30 @@ interface NotifyResult {
1749
2276
  reason?: string;
1750
2277
  }
1751
2278
  /**
1752
- * Send a templated lifecycle email exactly once. Short-circuits on a prior
1753
- * successful send; otherwise plans delivery (dev fail-safe applies), sends via the
1754
- * transport when one is wired and the plan calls for it, and records an emailLog
1755
- * row either way (success keyed for exactly-once, failure unkeyed for retry).
2279
+ * Claim before sending. Confirmed sends short-circuit; uncertain sends never
2280
+ * automatically repeat. Non-production redirect/log-only safeguards still apply.
1756
2281
  */
1757
2282
  declare function sendTemplated(deps: NotifyDeps, input: NotifyInput): Promise<NotifyResult>;
1758
2283
  /** Project a `groups` row into the {@link EmailGroup} the email pipeline reads. */
1759
2284
  declare function emailGroupFrom(row: Record<string, unknown>): EmailGroup;
1760
2285
 
2286
+ /** Evidence from an authenticated operator resolving an uncertain provider outcome. */
2287
+ interface LifecycleDeliveryResolution {
2288
+ id: string;
2289
+ groupId: string;
2290
+ expectedAttempt: number;
2291
+ expectedState: "sending" | "uncertain";
2292
+ decision: "confirmed_delivered" | "confirmed_not_delivered";
2293
+ actorId: string;
2294
+ reason: string;
2295
+ messageId?: string;
2296
+ }
2297
+ /** Resolve only the exact reviewed attempt. This never sends mail itself.
2298
+ * A confirmed non-delivery permits the original workflow to retry its frozen payload.
2299
+ * It must not be used merely because a message has not yet appeared in an inbox.
2300
+ */
2301
+ declare function reconcileLifecycleDelivery(db: ChapterDb, input: LifecycleDeliveryResolution, now: number): Promise<void>;
2302
+
1761
2303
  /**
1762
2304
  * Apply defaults + validate the pipeline config. With no config, the complete
1763
2305
  * reference pipeline. With `stages` given but the subsets omitted, the subsets
@@ -1780,6 +2322,17 @@ declare function canBook(status: string, p: ResolvedPipeline): boolean;
1780
2322
  /** May an application be approved (→ member) from this status? */
1781
2323
  declare function canApprove(status: string, p: ResolvedPipeline): boolean;
1782
2324
 
2325
+ /** Provider evidence retained from a signed initial invoice, not browser success. */
2326
+ interface MembershipInvoiceEvidence {
2327
+ invoiceId?: string;
2328
+ subscriptionId?: string;
2329
+ customerId?: string;
2330
+ currency?: string;
2331
+ total?: number;
2332
+ amountPaid?: number;
2333
+ status?: string;
2334
+ }
2335
+
1783
2336
  /** A group row's payment configuration, as far as readiness cares. */
1784
2337
  interface PaymentsGroup {
1785
2338
  stripePublishableKey?: string | null;
@@ -1814,16 +2367,30 @@ type WebhookEvent = ({
1814
2367
  kind: "gift_revoked";
1815
2368
  giftIntentId: string;
1816
2369
  reason: "refunded" | "canceled";
2370
+ } | {
2371
+ kind: "seat_paid" | "seat_refunded";
2372
+ seatId: string;
2373
+ applicationId?: string;
2374
+ customerId?: string;
1817
2375
  } | {
1818
2376
  kind: "first_payment";
1819
2377
  applicationId?: string;
1820
2378
  customerId?: string;
1821
2379
  renewalAt?: number;
2380
+ invoice?: MembershipInvoiceEvidence;
1822
2381
  } | {
1823
2382
  kind: "renewal";
1824
2383
  applicationId?: string;
1825
2384
  customerId?: string;
1826
2385
  renewalAt?: number;
2386
+ } | {
2387
+ kind: "renewal_failed";
2388
+ applicationId?: string;
2389
+ customerId?: string;
2390
+ } | {
2391
+ kind: "subscription_changed";
2392
+ applicationId?: string;
2393
+ customerId?: string;
1827
2394
  } | {
1828
2395
  kind: "refunded";
1829
2396
  applicationId?: string;
@@ -1857,7 +2424,9 @@ declare function findApplicationRef(obj: Record<string, unknown>): {
1857
2424
  /** Normalize a verified Stripe event into a {@link WebhookEvent}. `invoice.paid`
1858
2425
  * splits into first_payment vs renewal by `billing_reason`; refunds and
1859
2426
  * cancellations map directly; everything else is ignored (acked, not retried). */
1860
- declare function normalizeWebhookEvent(event: StripeEvent): WebhookEvent;
2427
+ declare function normalizeWebhookEvent(event: StripeEvent, options?: {
2428
+ requireProviderPayment?: boolean;
2429
+ }): WebhookEvent;
1861
2430
  /** First-payment patch: advance submitted→paid_pending_vetting (never any other
1862
2431
  * transition) and record the renewal date. Empty when nothing changed, so the
1863
2432
  * caller can skip the write. */
@@ -1869,14 +2438,15 @@ declare function firstPaymentPatch(currentStatus: string, renewalAt?: number): {
1869
2438
  declare function renewalPatch(renewalAt: number): {
1870
2439
  renewalAt: number;
1871
2440
  };
1872
- /** Refund patch — the SOLE writer of status "refunded" (the admin refund route
1873
- * issues the Stripe refund but never sets this; the webhook does). */
2441
+ /** A verified full refund closes the paid lifecycle and its renewal display. */
1874
2442
  declare function refundedPatch(): {
1875
2443
  status: "refunded";
2444
+ renewalAt: 0;
1876
2445
  };
1877
2446
  /** Subscription-cancellation patch. */
1878
2447
  declare function canceledPatch(): {
1879
2448
  canceled: true;
2449
+ renewalAt: 0;
1880
2450
  };
1881
2451
 
1882
2452
  /** Current wire version for parent-authored admission decisions. */
@@ -2034,6 +2604,8 @@ declare function submitApplication(db: ChapterDb, chapter: Chapter, fields: Reco
2034
2604
  admissionGrant?: AdmissionGrantRow;
2035
2605
  /** Server-validated gift offer selected from active signed control. */
2036
2606
  giftOfferId?: string;
2607
+ /** Server-selected deployment partition, including free applications. */
2608
+ runtime?: string;
2037
2609
  }): Promise<SubmitResult>;
2038
2610
  /** The `groups`-row fields the join config exposes. */
2039
2611
  interface JoinConfigGroup {
@@ -2275,6 +2847,15 @@ interface NetworkStageTransition {
2275
2847
  interface NetworkRecordEdit {
2276
2848
  fields: NetworkEditableField[];
2277
2849
  allowedStages: NetworkStageTransition[];
2850
+ /** Durable application operation awaiting reconciliation by its original operator. */
2851
+ pendingAction?: {
2852
+ mutationId: string;
2853
+ stage: string;
2854
+ expectedStage: string;
2855
+ expectedRevision: number;
2856
+ actorId: string;
2857
+ actorEmail?: string;
2858
+ };
2278
2859
  }
2279
2860
  /** Signed follower mutation dispatched by a leader admin. Exactly one of
2280
2861
  * `fields` or `stage` is present. */
@@ -2374,34 +2955,12 @@ interface ProjectionDeps {
2374
2955
  /** Safe defaults when a target does not declare an explicit field allowlist. */
2375
2956
  declare const DEFAULT_SHARE_FIELDS: Readonly<Record<string, readonly string[]>>;
2376
2957
 
2377
- /** Map a shared prospect to a crm `person` input (only the fields the default
2378
- * person type accepts). Name falls back to first+last, then the email. */
2379
- declare function sharedPersonInput(person: SharedPerson): Record<string, unknown>;
2380
- /** Backward-compatible display tag retained while structured origin rows are
2381
- * the durable leader-id → local-record mapping. */
2382
- declare function networkSourceTag(type: string, hubRecordId: string, sourceId?: string): string;
2383
- /** Normalize the backwards-compatible person/business shapes into the versioned
2384
- * generic record envelope the receiver writes. */
2385
- declare function normalizeSharedRecord(record: SharedPerson | SharedBusiness | SharedRecord, fallbackSourceId?: string): NormalizedSharedRecord;
2386
- /** Build the allowlisted payload sent from one leader CRM record to a target.
2387
- * A target with an explicit `fields` map only accepts the types it lists. */
2388
- declare function sharedRecordFromCrm(crm: Crm, record: CrmRecord, target: ResolvedNetworkTarget, sourceId?: string): SharedRecord;
2389
- /**
2390
- * Upsert a leader-shared CRM record into this follower. Accepts the original
2391
- * person wire shape plus the versioned generic shape. Re-shares resolve through
2392
- * a durable provenance tag; people/businesses also converge by natural key.
2393
- */
2394
- declare function projectSharedRecord(deps: ProjectionDeps, shared: SharedPerson | SharedBusiness | SharedRecord, options?: {
2395
- sourceId?: string;
2396
- sourceUrl?: string;
2397
- }): Promise<{
2398
- recordId: string;
2399
- }>;
2400
2958
  /** An arriving applicant, as far as the CRM projection cares. `extra` carries the
2401
2959
  * site-configured `crmFields` (values from the application), merged on top of the
2402
2960
  * built-in identity/contact set. */
2403
2961
  interface Applicant {
2404
2962
  applicationId: string;
2963
+ tierId?: string;
2405
2964
  email: string;
2406
2965
  firstName?: string;
2407
2966
  lastName?: string;
@@ -2424,13 +2983,36 @@ declare function projectApplicant(deps: ProjectionDeps, applicant: Applicant): P
2424
2983
  recordId: string;
2425
2984
  }>;
2426
2985
 
2986
+ /** Map a shared prospect to a crm `person` input (only the fields the default
2987
+ * person type accepts). Name falls back to first+last, then the email. */
2988
+ declare function sharedPersonInput(person: SharedPerson): Record<string, unknown>;
2989
+ /** Backward-compatible display tag retained while structured origin rows are
2990
+ * the durable leader-id → local-record mapping. */
2991
+ declare function networkSourceTag(type: string, hubRecordId: string, sourceId?: string): string;
2992
+ /** Normalize the backwards-compatible person/business shapes into the versioned
2993
+ * generic record envelope the receiver writes. */
2994
+ declare function normalizeSharedRecord(record: SharedPerson | SharedBusiness | SharedRecord, fallbackSourceId?: string): NormalizedSharedRecord;
2995
+ /** Build the allowlisted payload sent from one leader CRM record to a target.
2996
+ * A target with an explicit `fields` map only accepts the types it lists. */
2997
+ declare function sharedRecordFromCrm(crm: Crm, record: CrmRecord, target: ResolvedNetworkTarget, sourceId?: string): SharedRecord;
2998
+ /**
2999
+ * Upsert a leader-shared CRM record into this follower. Accepts the original
3000
+ * person wire shape plus the versioned generic shape. Re-shares resolve through
3001
+ * a durable provenance tag; people/businesses also converge by natural key.
3002
+ */
3003
+ declare function projectSharedRecord(deps: ProjectionDeps, shared: SharedPerson | SharedBusiness | SharedRecord, options?: {
3004
+ sourceId?: string;
3005
+ sourceUrl?: string;
3006
+ }): Promise<{
3007
+ recordId: string;
3008
+ }>;
3009
+
2427
3010
  /** The crm `person` input for one application row: the built-in identity/contact
2428
3011
  * fields plus each configured `crmFields` value present on the row. */
2429
3012
  declare function personInputFromApp(chapter: Chapter, app: Record<string, unknown>): Record<string, unknown>;
2430
- /** Upsert the person record for one application (or a synthetic `{ email,
2431
- * firstName }` account row) and mirror its stage, billing snapshot, and Clerk
2432
- * identity. `stage` is the `applications.status` to mirror — omit for
2433
- * account-only rows not in the pipeline. Throws on failure (the backfill route
3013
+ /** Upsert the person record for one application and mirror its stage, billing
3014
+ * snapshot, and Clerk identity. Account-only identities must use
3015
+ * syncAccountToCrm. Throws on failure (the backfill route
2434
3016
  * counts; the operational call sites wrap in `.catch`). */
2435
3017
  declare function syncApplicationToCrm(deps: ProjectionDeps & {
2436
3018
  chapter: Chapter;
@@ -2439,8 +3021,8 @@ declare function syncApplicationToCrm(deps: ProjectionDeps & {
2439
3021
  stage?: string;
2440
3022
  }): Promise<string | null>;
2441
3023
  /** Backfill / repair: project every application (newest per person) and every
2442
- * account-only `$users` row into the CRM. Idempotent (safe to re-run). Dev
2443
- * volumes fit one 1000-row page. Returns `{ synced, errors }`. */
3024
+ * `$users` row into the CRM without giving accounts an application or stage.
3025
+ * Pages are bounded; callers receive errors rather than a false success. */
2444
3026
  declare function backfillCrm(deps: ProjectionDeps & {
2445
3027
  chapter: Chapter;
2446
3028
  }): Promise<{
@@ -2566,8 +3148,12 @@ declare function updateClerkUserMetadataByEmail(secretKey: string, email: string
2566
3148
  * repairs a previously missed create (`refreshed: true`). */
2567
3149
  declare function createClerkUser(secretKey: string, input: ClerkUserInput, fetchImpl?: typeof fetch): Promise<ClerkResult>;
2568
3150
 
3151
+ /** Backend metadata field selected for all role reads and writes. */
3152
+ type ClerkRoleMetadata = "public" | "private";
3153
+ /** Resolve one source for authorization, roster, guards and lifecycle writers. */
3154
+ declare function clerkRoleMetadata(auth: ResolvedAuth): ClerkRoleMetadata;
2569
3155
  /** A Clerk user as chapter's role layer sees it. `role` defaults to the lowest
2570
- * rung when `public_metadata` carries none. Raw public/private metadata is
3156
+ * rung when the selected metadata source carries none. Raw public/private metadata is
2571
3157
  * returned only from this backend helper; `profile` and `applicationId` are the
2572
3158
  * normalized Chapter-owned private signals. */
2573
3159
  interface ClerkUserRecord {
@@ -2582,20 +3168,57 @@ interface ClerkUserRecord {
2582
3168
  /** Look a Clerk user up by email. `null` when no such user — or when the lookup
2583
3169
  * fails (a role gate treats an unresolvable user as absent, matching the site's
2584
3170
  * own fallback). Role defaults to provisional when unset. */
2585
- declare function clerkGetUserByEmail(secretKey: string, email: string, fetchImpl?: typeof fetch): Promise<ClerkUserRecord | null>;
3171
+ declare function clerkGetUserByEmail(secretKey: string, email: string, fetchImpl?: typeof fetch, source?: ClerkRoleMetadata): Promise<ClerkUserRecord | null>;
2586
3172
  /** Fetch a Clerk user by id, for role-change gating. `null` when missing or on a
2587
3173
  * failed lookup. Role defaults to provisional when unset. */
2588
- declare function clerkGetUser(secretKey: string, id: string, fetchImpl?: typeof fetch): Promise<ClerkUserRecord | null>;
3174
+ declare function clerkGetUser(secretKey: string, id: string, fetchImpl?: typeof fetch, source?: ClerkRoleMetadata): Promise<ClerkUserRecord | null>;
2589
3175
  /** List ALL Clerk users with their roles, auto-paginating. A membership community
2590
3176
  * outgrows one page, and a fixed `limit=100` would silently drop members from the
2591
3177
  * admin roster with no error — so this pages (offset in steps of {@link PAGE})
2592
3178
  * until a short page. A page fetch that fails THROWS rather than returning a
2593
3179
  * partial list, so the caller never mistakes a truncated roster for the whole. */
2594
- declare function clerkListUsers(secretKey: string, fetchImpl?: typeof fetch): Promise<ClerkUserRecord[]>;
2595
- /** Write a user's role: a MERGE-PATCH of only `{ role }` on `public_metadata`.
2596
- * The backend-only profile lives in `private_metadata`, so the two signals
2597
- * cannot overwrite each other. Returns whether the role write stuck. */
2598
- declare function clerkSetRole(secretKey: string, id: string, role: string, fetchImpl?: typeof fetch): Promise<boolean>;
3180
+ declare function clerkListUsers(secretKey: string, fetchImpl?: typeof fetch, source?: ClerkRoleMetadata): Promise<ClerkUserRecord[]>;
3181
+ /** Merge only the selected role key. Private mode removes the legacy public role
3182
+ * atomically while preserving profiles/foreign keys. No private-to-public fallback. */
3183
+ declare function clerkSetRole(secretKey: string, id: string, role: string, fetchImpl?: typeof fetch, source?: ClerkRoleMetadata): Promise<boolean>;
3184
+
3185
+ /** Operator-supplied evidence for EVERY active runtime sharing this Clerk instance.
3186
+ * Resolve the expected inventory from odla, not from only the current checkout.
3187
+ * Readiness means the private-role build is staged and old role writers paused. */
3188
+ interface PrivateRoleRuntimeProof {
3189
+ runtime: string;
3190
+ version: string;
3191
+ privateRoleReady: boolean;
3192
+ roleWritesPaused: boolean;
3193
+ }
3194
+ /** Fresh operator-reviewed inventory for a dev-only migration dry run.
3195
+ * This evidence is not write authority and the planner performs no provider I/O. */
3196
+ interface PrivateRoleMigrationInput {
3197
+ environment: string;
3198
+ expectedRuntimes: readonly string[];
3199
+ runtimes: readonly PrivateRoleRuntimeProof[];
3200
+ /** Existing active protected odla grants, resolved by exact Clerk subject.
3201
+ * Never derive this set from public/private Clerk metadata or legacy tables. */
3202
+ protectedSuperAdminUserIds: readonly string[];
3203
+ users: readonly ClerkUserRecord[];
3204
+ ladder: readonly string[];
3205
+ }
3206
+ /** Dry-run only: does not change Clerk, odla roles, runtime configuration or keys.
3207
+ * Conflicting sources require review. A successful plan is NOT an atomic lock;
3208
+ * keep all writers paused and re-read the exact role fields before each write.
3209
+ * Resume requires a new plan; never replay a stale snapshot over newer roles. */
3210
+ declare function planPrivateRoleMigration(input: PrivateRoleMigrationInput): {
3211
+ ready: boolean;
3212
+ blockers: string[];
3213
+ changes: {
3214
+ userId: string;
3215
+ role: string;
3216
+ publicRole: unknown;
3217
+ privateRole: unknown;
3218
+ }[];
3219
+ alreadyCurrent: number;
3220
+ totalUsers: number;
3221
+ };
2599
3222
 
2600
3223
  /** Which auth mode a secret is required for: `"client"` (publishable key only) or
2601
3224
  * `"full"` (server-side profile/role reads + writes, needing the vault secret). */
@@ -2672,7 +3295,7 @@ interface IntegrationDescriptor {
2672
3295
  * the one public `setting` (the `pk_*` publishable key, served to the SPA), the
2673
3296
  * `secrets` auth mode `"full"` needs in the tenant vault, BOTH sync directions —
2674
3297
  * the inbound `$users` webhook mirror (`provider->odla`) and the outbound
2675
- * public role/private profile write via `clerk_secret_key` (`odla->provider`,
3298
+ * selected private-role (or legacy public-role) / private-profile write via `clerk_secret_key` (`odla->provider`,
2676
3299
  * chapter's `clerk.ts`) — and the `provision` split. Data only; it performs
2677
3300
  * none of it.
2678
3301
  */
@@ -2942,9 +3565,10 @@ type TierGroupRow = TierGroup & {
2942
3565
  };
2943
3566
  /**
2944
3567
  * Every tier a group offers, ordered, including the implicit tier synthesized
2945
- * for a chapter that predates tiers. Never throws on a missing namespace: a
2946
- * deployment whose schema has not been pushed yet reads as "no rows", which
2947
- * resolves to the legacy single tier.
3568
+ * for a chapter with a successfully read empty tier collection. Unavailable,
3569
+ * malformed, or unprovisioned storage fails closed; it must never turn an
3570
+ * outage into an implicit free or legacy-price membership. Retiring all stored
3571
+ * tiers leaves no offers rather than reviving the legacy group price.
2948
3572
  */
2949
3573
  declare function loadTiers(db: ChapterDb, group: TierGroupRow): Promise<ChapterTier[]>;
2950
3574
  /** The tiers a join page may show: active, and joinable as configured. */
@@ -3053,6 +3677,8 @@ interface SignupControlPolicy {
3053
3677
  trustCopy?: string;
3054
3678
  commitmentText?: string;
3055
3679
  normsText?: string;
3680
+ /** Price-specific refund/trust copy, keyed by an explicitly declared tier. */
3681
+ tierPolicies?: Readonly<Record<string, TierPaymentPolicy>>;
3056
3682
  }
3057
3683
  /** Bounded semantic design tokens delegated to the chapter signup surface. */
3058
3684
  interface SignupControlTheme {
@@ -3084,6 +3710,14 @@ interface SignupControlDocument {
3084
3710
  interface SignupControlEnvelope {
3085
3711
  digest: string;
3086
3712
  document: SignupControlDocument;
3713
+ /** Signed transport identity, deliberately excluded from the shared document digest. */
3714
+ deliveryTarget?: SignupControlRuntimeTarget;
3715
+ }
3716
+ /** Exact deployment receiving a shared data-environment revision. */
3717
+ interface SignupControlRuntimeTarget {
3718
+ appId: string;
3719
+ environment: string;
3720
+ runtime: string;
3087
3721
  }
3088
3722
  /** Exact follower acknowledgement for one accepted or replayed revision. */
3089
3723
  interface SignupControlReceipt {
@@ -3091,6 +3725,8 @@ interface SignupControlReceipt {
3091
3725
  target: {
3092
3726
  chapterId: string;
3093
3727
  environment: string;
3728
+ appId?: string;
3729
+ runtime?: string;
3094
3730
  };
3095
3731
  revision: number;
3096
3732
  digest: string;
@@ -3098,7 +3734,7 @@ interface SignupControlReceipt {
3098
3734
  acknowledgedAt: number;
3099
3735
  }
3100
3736
  /** Stable reason codes returned when a follower refuses desired state. */
3101
- type SignupControlRejection = "invalid_document" | "invalid_digest" | "wrong_source" | "wrong_target" | "wrong_environment" | "wrong_stripe_mode" | "stale_revision" | "conflicting_revision" | "materialization_failed";
3737
+ type SignupControlRejection = "invalid_document" | "invalid_digest" | "wrong_source" | "wrong_target" | "wrong_environment" | "wrong_runtime" | "wrong_stripe_mode" | "stale_revision" | "conflicting_revision" | "materialization_failed";
3102
3738
  /** Normalized document result returned by the package validator. */
3103
3739
  type SignupControlValidation = {
3104
3740
  ok: true;
@@ -3218,8 +3854,18 @@ interface ChapterPromotionInput {
3218
3854
  /** Export the provider-independent pieces of one exact active signup revision. */
3219
3855
  declare function exportChapterPromotion(input: ChapterPromotionInput): Promise<PromotionAdapterResult>;
3220
3856
 
3221
- /** Storage boundary for a member-system field. */
3857
+ /** Logical aggregate boundary, not a requirement for a separate database/app. */
3222
3858
  type MemberSystemScope = "network" | "chapter" | "provider";
3859
+ /** Business ownership is independent of the reusable command implementation.
3860
+ * Network records live in BNF's existing odla database. Protected platform roles
3861
+ * are not business records and remain writable only by odla administration.
3862
+ */
3863
+ declare const MEMBER_SYSTEM_RECORD_OWNERS: {
3864
+ readonly network: "built-not-found";
3865
+ readonly chapter: "owning-chapter";
3866
+ readonly provider: "originating-provider";
3867
+ readonly protectedRoles: "odla-platform";
3868
+ };
3223
3869
  /** Durable authority allowed to write a member-system field. */
3224
3870
  type MemberSystemWriter = "network_person" | "chapter_journey" | "network_membership" | "network_entitlement" | "network_seat" | "network_discount_policy" | "network_referral_ledger" | "network_investment_ledger" | "network_commercial_projection" | "clerk" | "stripe";
3225
3871
  /** Read model that may receive an allowlisted field. */
@@ -3237,7 +3883,9 @@ interface MemberFieldAuthority {
3237
3883
  sensitivity: MemberFieldSensitivity;
3238
3884
  memberAccess: MemberFieldSelfAccess;
3239
3885
  }
3240
- /** Each field has one durable writer. BNF is an operator projection, never a writer. */
3886
+ /** Each field has one aggregate command writer. BNF owns network aggregates and
3887
+ * hosts their server commands; bnf_admin names a read projection, not a credential.
3888
+ */
3241
3889
  declare const MEMBER_SYSTEM_AUTHORITY_MATRIX: readonly MemberFieldAuthority[];
3242
3890
  /** Fields a member may change through self-service. */
3243
3891
  declare const MEMBER_SELF_EDITABLE_FIELDS: Set<string>;
@@ -3254,7 +3902,11 @@ interface MemberSystemWriteIntent {
3254
3902
  }
3255
3903
  /** Result of checking a proposed mutation against surface, writer, and revision rules. */
3256
3904
  type MemberSystemWriteDisposition = "apply" | "reject_bnf_surface" | "reject_unknown_field" | "reject_wrong_writer" | "reject_stale_revision";
3257
- /** Reject BNF, wrong-writer, unknown-field, and stale-revision mutations. */
3905
+ /** Validate an aggregate command, not a user's authorization. A bare BNF surface
3906
+ * label is still insufficient: its backend must select the field's specific
3907
+ * writer after authenticating and authorizing the caller. This helper cannot
3908
+ * constrain an unrestricted database credential or grant protected platform roles.
3909
+ */
3258
3910
  declare function classifyMemberSystemWrite(intent: MemberSystemWriteIntent): MemberSystemWriteDisposition;
3259
3911
  /** Result of validating an authority matrix. */
3260
3912
  interface MemberAuthorityValidation {
@@ -3279,10 +3931,12 @@ type JourneyEnding = typeof JOURNEY_ENDINGS[number];
3279
3931
  declare const REQUIRED_NOTICE_KINDS: readonly ["payment_receipt", "refund_confirmation", "security_alert", "legal_notice", "membership_status", "renewal_notice", "cancellation_confirmation"];
3280
3932
  /** A typed required notice allowed despite discretionary contact suppression. */
3281
3933
  type RequiredNoticeKind = typeof REQUIRED_NOTICE_KINDS[number];
3282
- /** Availability inputs that distinguish the BNF UI from the odla data plane. */
3934
+ /** Availability inputs distinguish BNF's browser UI, authority backend and odla. */
3283
3935
  interface MemberSystemAvailabilityInput {
3284
3936
  odlaReachable: boolean;
3285
3937
  bnfFrontendReachable: boolean;
3938
+ /** Explicit backend health is required; unknown is not evidence of readiness. */
3939
+ bnfBackendReachable: boolean;
3286
3940
  }
3287
3941
  /** Capabilities allowed at the current BNF and odla availability state. */
3288
3942
  interface MemberSystemAvailability {
@@ -3292,9 +3946,9 @@ interface MemberSystemAvailability {
3292
3946
  newApplication: boolean;
3293
3947
  newCheckout: boolean;
3294
3948
  providerRenewalsMayContinue: true;
3295
- reason?: "odla_unavailable" | "bnf_frontend_unavailable";
3949
+ reason?: "odla_unavailable" | "bnf_backend_unavailable" | "bnf_frontend_unavailable";
3296
3950
  }
3297
- /** BNF is optional for chapter execution; odla is not. */
3951
+ /** Only BNF's frontend is optional for dependent chapter execution. */
3298
3952
  declare function memberSystemAvailability(input: MemberSystemAvailabilityInput): MemberSystemAvailability;
3299
3953
  /** Partition metadata supplied by a verified Stripe event. */
3300
3954
  interface MemberStripeIdentity {
@@ -3406,4 +4060,33 @@ declare const SILVER_SALT_P0_FIXTURE: {
3406
4060
  };
3407
4061
  };
3408
4062
 
3409
- export { ADMISSION_GRANTS_PATH, ADMISSION_GRANTS_SCHEMA_VERSION, type AccountModel, type AdminNotificationTrigger, type AdmissionDecision, type AdmissionGrantDocument, type AdmissionGrantEnvelope, type AdmissionGrantInput, type AdmissionGrantReceipt, type AdmissionGrantRejection, type AdmissionGrantRevisionRow, type AdmissionGrantRow, type AdmissionGrantValidation, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, BUILDER_LIBRARY_ADMIN_PATH, BUILDER_LIBRARY_CONTROL_PATH, BUILDER_LIBRARY_MANIFEST_PATH, BUILDER_LIBRARY_PROMOTE_PATH, BUILDER_LIBRARY_SCHEMA_VERSION, type BuilderLibraryBrandAssetRef, type BuilderLibraryDocument, type BuilderLibraryEnvelope, type BuilderLibraryManifest, type BuilderLibraryPromotionProvenance, type BuilderLibraryReceipt, type BuilderLibraryResource, type BuilderLibraryResourceKind, type BuilderLibraryResourceProvenance, type BuilderLibraryResourceStatus, type BuilderLibraryScope, type BuilderLibrarySource, type BuilderLibrarySourceType, type BuilderLibraryTarget, type BuilderLibraryValidationOptions, type BuilderLibraryValidationResult, type BuilderLibraryViewer, type BuyerGiftClaim, CHAPTER_FLOW_FIELDS_SCHEMA_VERSION, CHAPTER_PROMOTION_ADAPTER, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterBuilderLibrary, type ChapterCommercialParityRecord, type ChapterCommercialParitySnapshot, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmailIdentity, type ChapterEmails, type ChapterFieldFlow, type ChapterFlowField, type ChapterFlowFieldContract, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMemberContent, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterPromotionInput, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterSignupControl, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkUserInput, type ClerkUserRecord, type CommercialIdentity, type CommercialObjectKind, type CommercialParityException, type CommercialParityExceptionKind, type CommercialParityPartition, type CommercialParityResult, type CompiledChapterBrandTokens, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EffectiveMemberContent, type EffectiveMemberContentPage, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, GIFT_OFFER_CATALOG_VERSION, type GiftOffer, type GiftOfferCatalog, type GiftOfferTarget, type GiftOfferValidation, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, JOURNEY_ENDINGS, JOURNEY_STAGES, type JoinConfigGroup, type JoinConfigTier, type JoinContinuation, type JourneyEnding, type JourneyStage, type LeaderCrmOptions, type LeaderFormationConfig, type LiveEvent, MAX_GIFT_OFFERS, MEMBERSHIP_PAGE_RENDERER, MEMBER_CONTENT_CONTROL_PATH, MEMBER_CONTENT_PATH, MEMBER_CONTENT_SCHEMA_VERSION, MEMBER_SELF_EDITABLE_FIELDS, MEMBER_SELF_READABLE_FIELDS, MEMBER_SYSTEM_AUTHORITY_MATRIX, MEMBER_SYSTEM_CONTRACT_VERSION, MEMBER_SYSTEM_RECOVERY_OBJECTIVES, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberAuthorityValidation, type MemberContentDocument, type MemberContentEnvelope, type MemberContentPage, type MemberContentPageProjection, type MemberContentProjection, type MemberContentReceipt, type MemberContentRejection, type MemberContentSource, type MemberContentSourceType, type MemberContentTarget, type MemberContentTierAuthority, type MemberContentValidationOptions, type MemberContentValidationResult, type MemberContentViewer, type MemberFieldAuthority, type MemberFieldSelfAccess, type MemberFieldSensitivity, type MemberPageAudience, type MemberPageNavigation, type MemberPageUpsell, type MemberPageUpsellOffer, type MemberPageUpsellOverride, type MemberSession, type MemberStripeDisposition, type MemberStripeIdentity, type MemberStripeTarget, type MemberSystemAvailability, type MemberSystemAvailabilityInput, type MemberSystemEventReceiptInput, type MemberSystemEventReplayPlan, type MemberSystemMigrationPlan, type MemberSystemMigrationRow, type MemberSystemProjection, type MemberSystemRecoveryObjectives, type MemberSystemRollbackPlan, type MemberSystemScope, type MemberSystemWriteDisposition, type MemberSystemWriteIntent, type MemberSystemWriter, type MembershipPageDocument, type MembershipPageValidationOptions, type MembershipPageValidationResult, type MembershipTierAuthority, type MembershipTierCallout, type MembershipTierCapacity, type MembershipTierMarkdownResult, type MembershipTierPresentation, type MembershipTierVariant, type NetworkCommercialException, type NetworkCommercialFact, type NetworkCommercialProjectedRow, type NetworkCommercialProjection, type NetworkEditableField, type NetworkRecord, type NetworkRecordEdit, type NetworkRecordMutation, type NetworkRecordMutationResult, type NetworkRecordNote, type NetworkRecordPage, type NetworkRecordSort, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NetworkStageTransition, type NetworkTargetTransportStatus, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type PublicGiftOffer, REQUIRED_NOTICE_KINDS, type ReconcileDecision, type RequiredNoticeKind, type ResolvedApplication, type ResolvedAuth, type ResolvedBuilderLibrary, type ResolvedLeaderFormation, type ResolvedMemberContent, type ResolvedMemberPageUpsell, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type ResolvedSignupControl, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, SIGNUP_CONTROL_PATH, SIGNUP_CONTROL_SCHEMA_VERSION, SIGNUP_CONTROL_THEME_MARKER, SIGNUP_CONTROL_THEME_STYLE_ID, SILVER_SALT_P0_FIXTURE, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type SignupControlApplication, type SignupControlDocument, type SignupControlEnvelope, type SignupControlPolicy, type SignupControlReceipt, type SignupControlRejection, type SignupControlTheme, type SignupControlThemeHead, type SignupControlThemeMetadata, type SignupControlThemeOptions, type SignupControlThemeRevision, type SignupControlThemeStyleTarget, type SignupControlTier, type SignupControlValidation, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationFlowFields, applicationSummary, applyMembershipTierMarkdown, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildBuilderLibraryManifest, buildChapterCommercialParitySnapshot, buildGroupSeed, buildTierSeeds, builderLibraryDigest, canApprove, canBook, canChangeRole, canTransition, canViewBuilderLibraryResource, canceledPatch, canonicalBuilderLibrary, canonicalMemberContent, canonicalSignupControl, chapterBrandFromTokens, chapterDb, chapterFlowFieldContract, clampArray, classifyMemberStripeEvent, classifyMemberSystemWrite, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, commercialParityDigest, composeMemberContent, createAdmissionGrantEnvelope, createBuilderLibraryEnvelope, createChapterIntegration, createClerkInvitation, createClerkUser, createMemberContentEnvelope, createSignupControlEnvelope, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, exportChapterPromotion, findAdmissionGrant, findApplicationRef, findGiftOffer, findTier, firstPaymentPatch, formatChapterCopy, formationFields, formationFlowFields, getVaultSecret, giftOfferActive, hasDisclaimerAck, hydrateSignupControlTheme, injectSignupControlThemeHead, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, joinConfigTiers, leaderCrmConfig, listStripeObjects, loadLatestAdmissionRevision, loadOfferableTiers, loadTiers, materializeAdmissionGrants, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberContentDigest, memberContentDocument, memberSession, memberSystemAvailability, memberSystemRollbackPlan, membershipPageDocument, membershipTierPresentationFromMarkdown, networkCommercialSourceKey, networkSourceTag, normalizeAdmissionEmail, normalizeChapterEmail, normalizeNetworkCommercialStripeEvent, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, planMemberSystemEventReplay, planMemberSystemMigration, projectApplicant, projectBuilderLibraryDelivery, projectMemberContent, projectMemberSelf, projectNetworkCommercialEvents, projectSharedRecord, promoteBuilderLibraryResource, publicGiftOffers, reconcileCommercialParitySnapshot, reconcileMeetings, reconcileStripeSnapshot, refundedPatch, render, renderSignupControlThemeHead, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveBuilderLibrary, resolveChapterCopy, resolveJoinContinuation, resolveLeaderFormation, resolveMemberContent, resolveNetworkCommercialReadModel, resolveNetworkPersonRegistry, resolvePipeline, resolveScheduling, resolveSignupControl, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, signupControlDigest, slotWindow, stageIndex, stripeCall, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, tierIsFree, tierPayable, updateClerkUserMetadata, updateClerkUserMetadataByEmail, validateAdmissionGrantDocument, validateBuilderLibraryDocument, validateGiftOfferCatalog, validateMemberContentDocument, validateMemberSystemAuthority, validateMembershipPageDocument, validateScheduling, validateSignupControlDocument, webhookMutationId };
4063
+ /** Separate authoritative collections inside the network owner's EXISTING database.
4064
+ * Legacy networkMembership/networkEntitlement/networkSeat remain shadow/rollback
4065
+ * data. This mapping never migrates, copies, or promotes their contents.
4066
+ */
4067
+ declare const MEMBERSHIP_AUTHORITY_COLLECTIONS: {
4068
+ readonly networkMembership: "membershipRecord";
4069
+ readonly networkEntitlement: "membershipEntitlement";
4070
+ readonly networkSeat: "membershipSeat";
4071
+ };
4072
+ /** Additive, deny-all descriptor. Compose once in BNF alongside its existing
4073
+ * policy and commercial integrations, never in each chapter. No activation seeds:
4074
+ * a reviewed authority-state command must explicitly enable a chapter afterward.
4075
+ */
4076
+ declare function createMembershipAuthorityIntegration(): {
4077
+ id: string;
4078
+ title: string;
4079
+ npm: string;
4080
+ schema: {
4081
+ entities: {
4082
+ [k: string]: Entity;
4083
+ };
4084
+ links: {};
4085
+ };
4086
+ rules: {
4087
+ [k: string]: Rule;
4088
+ };
4089
+ seeds: never[];
4090
+ };
4091
+
4092
+ export { ADMISSION_GRANTS_PATH, ADMISSION_GRANTS_SCHEMA_VERSION, type AccountModel, type AdminNotificationTrigger, type AdmissionDecision, type AdmissionGrantDocument, type AdmissionGrantEnvelope, type AdmissionGrantInput, type AdmissionGrantReceipt, type AdmissionGrantRejection, type AdmissionGrantRevisionRow, type AdmissionGrantRow, type AdmissionGrantValidation, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, BUILDER_LIBRARY_ADMIN_PATH, BUILDER_LIBRARY_CONTROL_PATH, BUILDER_LIBRARY_MANIFEST_PATH, BUILDER_LIBRARY_PROMOTE_PATH, BUILDER_LIBRARY_SCHEMA_VERSION, type BuilderLibraryBrandAssetRef, type BuilderLibraryDocument, type BuilderLibraryEnvelope, type BuilderLibraryManifest, type BuilderLibraryPromotionProvenance, type BuilderLibraryReceipt, type BuilderLibraryResource, type BuilderLibraryResourceKind, type BuilderLibraryResourceProvenance, type BuilderLibraryResourceStatus, type BuilderLibraryScope, type BuilderLibrarySource, type BuilderLibrarySourceType, type BuilderLibraryTarget, type BuilderLibraryValidationOptions, type BuilderLibraryValidationResult, type BuilderLibraryViewer, type BuyerGiftClaim, CHAPTER_FLOW_FIELDS_SCHEMA_VERSION, CHAPTER_PROMOTION_ADAPTER, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterBuilderLibrary, type ChapterCommercialParityRecord, type ChapterCommercialParitySnapshot, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmailIdentity, type ChapterEmails, type ChapterFieldFlow, type ChapterFlowField, type ChapterFlowFieldContract, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMemberContent, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterPromotionInput, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterSignupControl, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkRoleMetadata, type ClerkUserInput, type ClerkUserRecord, type CommercialIdentity, type CommercialObjectKind, type CommercialParityException, type CommercialParityExceptionKind, type CommercialParityPartition, type CommercialParityResult, type CompiledChapterBrandTokens, type ConfirmMembershipPaymentInput, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EffectiveMemberContent, type EffectiveMemberContentPage, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, GIFT_OFFER_CATALOG_VERSION, type GiftOffer, type GiftOfferCatalog, type GiftOfferTarget, type GiftOfferValidation, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, type IssuedMembershipOffer, JOURNEY_ENDINGS, JOURNEY_STAGES, type JoinConfigGroup, type JoinConfigTier, type JoinContinuation, type JourneyEnding, type JourneyStage, type LeaderCrmOptions, type LeaderFormationConfig, type LifecycleDeliveryResolution, type LiveEvent, MAX_GIFT_OFFERS, MEMBERSHIP_AUTHORITY_COLLECTIONS, MEMBERSHIP_AUTHORITY_PATH, MEMBERSHIP_PAGE_RENDERER, MEMBER_CONTENT_CONTROL_PATH, MEMBER_CONTENT_PATH, MEMBER_CONTENT_SCHEMA_VERSION, MEMBER_SELF_EDITABLE_FIELDS, MEMBER_SELF_READABLE_FIELDS, MEMBER_SYSTEM_AUTHORITY_MATRIX, MEMBER_SYSTEM_CONTRACT_VERSION, MEMBER_SYSTEM_RECORD_OWNERS, MEMBER_SYSTEM_RECOVERY_OBJECTIVES, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberAuthorityValidation, type MemberContentDocument, type MemberContentEnvelope, type MemberContentPage, type MemberContentPageProjection, type MemberContentProjection, type MemberContentReceipt, type MemberContentRejection, type MemberContentSource, type MemberContentSourceType, type MemberContentTarget, type MemberContentTierAuthority, type MemberContentValidationOptions, type MemberContentValidationResult, type MemberContentViewer, type MemberFieldAuthority, type MemberFieldSelfAccess, type MemberFieldSensitivity, type MemberPageAudience, type MemberPageNavigation, type MemberPageUpsell, type MemberPageUpsellOffer, type MemberPageUpsellOverride, type MemberSession, type MemberStripeDisposition, type MemberStripeIdentity, type MemberStripeTarget, type MemberSystemAvailability, type MemberSystemAvailabilityInput, type MemberSystemEventReceiptInput, type MemberSystemEventReplayPlan, type MemberSystemMigrationPlan, type MemberSystemMigrationRow, type MemberSystemProjection, type MemberSystemRecoveryObjectives, type MemberSystemRollbackPlan, type MemberSystemScope, type MemberSystemWriteDisposition, type MemberSystemWriteIntent, type MemberSystemWriter, type MembershipAccessReceipt, type MembershipAuthorityHandlerOptions, type MembershipAuthorityPeer, type MembershipChapterEffect, type MembershipChapterEffectData, type MembershipCheckoutBinding, type MembershipCheckoutBindingInput, type MembershipCommercialOffer, type MembershipDiscountPolicyVersion, type MembershipEffectScope, type MembershipOfferIssuer, type MembershipOfferRequest, type MembershipOfferingVersion, type MembershipPageDocument, type MembershipPageValidationOptions, type MembershipPageValidationResult, type MembershipPaymentReceipt, type MembershipQuoteTarget, type MembershipRefundReceipt, type MembershipRenewalReceipt, type MembershipTierAuthority, type MembershipTierCallout, type MembershipTierCapacity, type MembershipTierMarkdownResult, type MembershipTierPresentation, type MembershipTierVariant, type NamedSeatCheckoutReceipt, type NamedSeatCheckoutRequest, type NamedSeatEvidenceRequest, type NamedSeatInvitation, type NamedSeatInvitationRequest, type NamedSeatOffer, type NamedSeatRecipientReceipt, type NamedSeatRefundReceipt, type NetworkCommercialException, type NetworkCommercialFact, type NetworkCommercialProjectedRow, type NetworkCommercialProjection, type NetworkEditableField, type NetworkRecord, type NetworkRecordEdit, type NetworkRecordMutation, type NetworkRecordMutationResult, type NetworkRecordNote, type NetworkRecordPage, type NetworkRecordSort, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NetworkStageTransition, type NetworkTargetTransportStatus, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type PrivateRoleMigrationInput, type PrivateRoleRuntimeProof, type ProjectionDeps, type PublicGiftOffer, REQUIRED_NOTICE_KINDS, type ReconcileDecision, type RequestMembershipOfferOptions, type RequiredNoticeKind, type ResolvedApplication, type ResolvedAuth, type ResolvedBuilderLibrary, type ResolvedLeaderFormation, type ResolvedMemberContent, type ResolvedMemberPageUpsell, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type ResolvedSignupControl, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, SIGNUP_CONTROL_PATH, SIGNUP_CONTROL_SCHEMA_VERSION, SIGNUP_CONTROL_THEME_MARKER, SIGNUP_CONTROL_THEME_STYLE_ID, SILVER_SALT_P0_FIXTURE, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type SignupControlApplication, type SignupControlDocument, type SignupControlEnvelope, type SignupControlPolicy, type SignupControlReceipt, type SignupControlRejection, type SignupControlRuntimeTarget, type SignupControlTheme, type SignupControlThemeHead, type SignupControlThemeMetadata, type SignupControlThemeOptions, type SignupControlThemeRevision, type SignupControlThemeStyleTarget, type SignupControlTier, type SignupControlValidation, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, addMembershipCalendarMonths, applicantProfile, applicationBookingUpdate, applicationFlowFields, applicationSummary, applyMembershipTierMarkdown, approveNetworkMembership, backfillCrm, bindMembershipCheckout, bookingDecision, brandTokens, bucketSeries, buildBuilderLibraryManifest, buildChapterCommercialParitySnapshot, buildGroupSeed, buildTierSeeds, builderLibraryDigest, canApprove, canBook, canChangeRole, canTransition, canViewBuilderLibraryResource, canceledPatch, canonicalBuilderLibrary, canonicalMemberContent, canonicalSignupControl, chapterBrandFromTokens, chapterDb, chapterFlowFieldContract, clampArray, classifyMemberStripeEvent, classifyMemberSystemWrite, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkRoleMetadata, clerkSetRole, clerkUserRequest, commercialParityDigest, composeMemberContent, confirmMembershipPayment, createAdmissionGrantEnvelope, createBuilderLibraryEnvelope, createChapterIntegration, createClerkInvitation, createClerkUser, createMemberContentEnvelope, createMembershipAuthorityHandler, createMembershipAuthorityIntegration, createMembershipCommercialOffer, createSignupControlEnvelope, dashboardMetricData, defaultCrm, defineChapter, drainMembershipEffects, emailGroupFrom, endForSlot, exportChapterPromotion, findAdmissionGrant, findApplicationRef, findGiftOffer, findTier, firstPaymentPatch, formatChapterCopy, formationFields, formationFlowFields, getVaultSecret, giftOfferActive, hasDisclaimerAck, hydrateSignupControlTheme, injectSignupControlThemeHead, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, issueMembershipCommercialOffer, joinConfig, joinConfigTiers, leaderCrmConfig, listStripeObjects, loadLatestAdmissionRevision, loadOfferableTiers, loadTiers, materializeAdmissionGrants, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberContentDigest, memberContentDocument, memberSession, memberSystemAvailability, memberSystemRollbackPlan, membershipAuthorityEntities, membershipAuthorityRules, membershipCheckoutBindingId, membershipDiscountPolicyVersion, membershipOfferEntities, membershipOfferIdForRequest, membershipOfferRules, membershipOfferingVersion, membershipPageDocument, membershipTierPresentationFromMarkdown, namedSeatOfferDigest, networkCommercialSourceKey, networkMembershipId, networkSourceTag, normalizeAdmissionEmail, normalizeChapterEmail, normalizeNetworkCommercialStripeEvent, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, planMemberSystemEventReplay, planMemberSystemMigration, planPrivateRoleMigration, projectApplicant, projectBuilderLibraryDelivery, projectMemberContent, projectMemberSelf, projectNetworkCommercialEvents, projectSharedRecord, promoteBuilderLibraryResource, publicGiftOffers, readMembershipAccess, readMembershipChapterEffect, readNamedSeatAccess, readNamedSeatInvitation, readNamedSeatOffer, reconcileCommercialParitySnapshot, reconcileLifecycleDelivery, reconcileMeetings, reconcileMembershipBilling, reconcileMembershipRenewal, reconcileStripeSnapshot, refundNetworkMembership, refundedPatch, render, renderSignupControlThemeHead, renderSummary, renderTemplateBody, renewalPatch, requestMembershipAccess, requestMembershipApproval, requestMembershipChapterEffect, requestMembershipCheckoutBinding, requestMembershipCommercialOffer, requestMembershipPayment, requestMembershipRefund, requestMembershipRenewal, requestNamedSeatAcceptance, requestNamedSeatAccess, requestNamedSeatApproval, requestNamedSeatCheckout, requestNamedSeatDecline, requestNamedSeatInvitation, requestNamedSeatOffer, requestNamedSeatPayment, requestNamedSeatRefund, requestNamedSeatReservation, resolveApplication, resolveAuth, resolveBuilderLibrary, resolveChapterCopy, resolveJoinContinuation, resolveLeaderFormation, resolveMemberContent, resolveNetworkCommercialReadModel, resolveNetworkPersonRegistry, resolvePipeline, resolveScheduling, resolveSignupControl, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, signupControlDigest, slotWindow, stageIndex, stripeCall, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, tierIsFree, tierPayable, updateClerkUserMetadata, updateClerkUserMetadataByEmail, validateAdmissionGrantDocument, validateBuilderLibraryDocument, validateGiftOfferCatalog, validateMemberContentDocument, validateMemberSystemAuthority, validateMembershipPageDocument, validateScheduling, validateSignupControlDocument, verifyIssuedMembershipOffer, verifyMembershipAccessReceipt, verifyMembershipCheckoutBinding, verifyMembershipPaymentReceipt, webhookMutationId };