@substrat-run/adapter-cloudflare 0.220.0 → 0.222.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/broker-telemetry.d.ts +2 -5
  2. package/dist/broker-telemetry.d.ts.map +1 -1
  3. package/dist/broker-telemetry.js +2 -5
  4. package/dist/broker-telemetry.js.map +1 -1
  5. package/dist/control-plane-do.d.ts +280 -65
  6. package/dist/control-plane-do.d.ts.map +1 -1
  7. package/dist/control-plane-do.js +737 -245
  8. package/dist/control-plane-do.js.map +1 -1
  9. package/dist/delivery-broker-do.d.ts +3 -2
  10. package/dist/delivery-broker-do.d.ts.map +1 -1
  11. package/dist/delivery-broker-do.js +10 -4
  12. package/dist/delivery-broker-do.js.map +1 -1
  13. package/dist/delivery-handoff.d.ts +17 -1
  14. package/dist/delivery-handoff.d.ts.map +1 -1
  15. package/dist/delivery-handoff.js +19 -5
  16. package/dist/delivery-handoff.js.map +1 -1
  17. package/dist/directory-cutover.d.ts +243 -0
  18. package/dist/directory-cutover.d.ts.map +1 -0
  19. package/dist/directory-cutover.js +604 -0
  20. package/dist/directory-cutover.js.map +1 -0
  21. package/dist/directory-mirror-apply.d.ts +19 -1
  22. package/dist/directory-mirror-apply.d.ts.map +1 -1
  23. package/dist/directory-mirror-apply.js +19 -3
  24. package/dist/directory-mirror-apply.js.map +1 -1
  25. package/dist/directory-mirror-backfill.d.ts +2 -0
  26. package/dist/directory-mirror-backfill.d.ts.map +1 -1
  27. package/dist/directory-mirror-backfill.js +6 -4
  28. package/dist/directory-mirror-backfill.js.map +1 -1
  29. package/dist/directory-mirror.d.ts +24 -0
  30. package/dist/directory-mirror.d.ts.map +1 -1
  31. package/dist/directory-mirror.js +16 -2
  32. package/dist/directory-mirror.js.map +1 -1
  33. package/dist/directory-objects.d.ts +40 -0
  34. package/dist/directory-objects.d.ts.map +1 -1
  35. package/dist/directory-objects.js +134 -2
  36. package/dist/directory-objects.js.map +1 -1
  37. package/dist/directory-placement.d.ts.map +1 -1
  38. package/dist/directory-placement.js +9 -1
  39. package/dist/directory-placement.js.map +1 -1
  40. package/dist/directory-split-inventory.d.ts +5 -3
  41. package/dist/directory-split-inventory.d.ts.map +1 -1
  42. package/dist/directory-split-inventory.js +13 -6
  43. package/dist/directory-split-inventory.js.map +1 -1
  44. package/dist/directory-tenant-orgs.d.ts +19 -0
  45. package/dist/directory-tenant-orgs.d.ts.map +1 -0
  46. package/dist/directory-tenant-orgs.js +33 -0
  47. package/dist/directory-tenant-orgs.js.map +1 -0
  48. package/dist/directory-tenant-roles.d.ts +35 -0
  49. package/dist/directory-tenant-roles.d.ts.map +1 -0
  50. package/dist/directory-tenant-roles.js +78 -0
  51. package/dist/directory-tenant-roles.js.map +1 -0
  52. package/dist/directory-tenant-tuples.d.ts +165 -0
  53. package/dist/directory-tenant-tuples.d.ts.map +1 -0
  54. package/dist/directory-tenant-tuples.js +197 -0
  55. package/dist/directory-tenant-tuples.js.map +1 -0
  56. package/dist/host.d.ts +65 -3
  57. package/dist/host.d.ts.map +1 -1
  58. package/dist/host.js +422 -64
  59. package/dist/host.js.map +1 -1
  60. package/dist/index.d.ts +1 -0
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +1 -0
  63. package/dist/index.js.map +1 -1
  64. package/dist/platform-sweeper-do.d.ts +1 -1
  65. package/dist/platform-sweeper-do.js +1 -1
  66. package/dist/route-read-model-publisher.d.ts +6 -1
  67. package/dist/route-read-model-publisher.d.ts.map +1 -1
  68. package/dist/route-read-model-publisher.js +51 -13
  69. package/dist/route-read-model-publisher.js.map +1 -1
  70. package/dist/scope-do.d.ts +28 -2
  71. package/dist/scope-do.d.ts.map +1 -1
  72. package/dist/scope-do.js +398 -68
  73. package/dist/scope-do.js.map +1 -1
  74. package/dist/scope-sweeper-do.d.ts +28 -0
  75. package/dist/scope-sweeper-do.d.ts.map +1 -1
  76. package/dist/scope-sweeper-do.js +88 -50
  77. package/dist/scope-sweeper-do.js.map +1 -1
  78. package/dist/scope-wake.d.ts +12 -1
  79. package/dist/scope-wake.d.ts.map +1 -1
  80. package/dist/scope-wake.js +14 -1
  81. package/dist/scope-wake.js.map +1 -1
  82. package/dist/scope-work.d.ts +1 -1
  83. package/dist/scope-work.js +1 -1
  84. package/dist/scope-work.js.map +1 -1
  85. package/dist/tenant-due-work-do.d.ts +95 -0
  86. package/dist/tenant-due-work-do.d.ts.map +1 -0
  87. package/dist/tenant-due-work-do.js +149 -0
  88. package/dist/tenant-due-work-do.js.map +1 -0
  89. package/package.json +10 -10
@@ -12,9 +12,6 @@ import type { AnalyticsEngineDatasetLike } from './connector-calls.js';
12
12
  export declare function brokerTelemetryDataset(env: unknown): AnalyticsEngineDatasetLike | null;
13
13
  /** A sink writing every point and state report into `dataset`, in `BROKER_DATA_POINT_LAYOUT`. */
14
14
  export declare function analyticsBrokerSink(dataset: AnalyticsEngineDatasetLike): BrokerTelemetrySink;
15
- /** The broker object's (tenant, app) from its name, `brokerName(tenantId, app)`. */
16
- export declare function brokerIdsOf(name: string | undefined): {
17
- tenantId: string;
18
- app: string;
19
- };
15
+ /** The broker object's (tenant, app, environment) from its name: the kernel's `brokerIdsOf`. */
16
+ export { brokerIdsOf } from '@substrat-run/kernel';
20
17
  //# sourceMappingURL=broker-telemetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"broker-telemetry.d.ts","sourceRoot":"","sources":["../src/broker-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAA6C,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,uGAAuG;AACvG,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,0BAA0B,GAAG,IAAI,CAKtF;AAED,iGAAiG;AACjG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,mBAAmB,CAK5F;AAED,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAGvF"}
1
+ {"version":3,"file":"broker-telemetry.d.ts","sourceRoot":"","sources":["../src/broker-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAA6C,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,uGAAuG;AACvG,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,0BAA0B,GAAG,IAAI,CAKtF;AAED,iGAAiG;AACjG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,mBAAmB,CAK5F;AAED,gGAAgG;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
@@ -21,9 +21,6 @@ export function analyticsBrokerSink(dataset) {
21
21
  state: (s) => dataset.writeDataPoint(brokerDataPoint(s)),
22
22
  };
23
23
  }
24
- /** The broker object's (tenant, app) from its name, `brokerName(tenantId, app)`. */
25
- export function brokerIdsOf(name) {
26
- const at = name?.indexOf('/') ?? -1;
27
- return at > 0 ? { tenantId: name.slice(0, at), app: name.slice(at + 1) } : { tenantId: name ?? '', app: '' };
28
- }
24
+ /** The broker object's (tenant, app, environment) from its name: the kernel's `brokerIdsOf`. */
25
+ export { brokerIdsOf } from '@substrat-run/kernel';
29
26
  //# sourceMappingURL=broker-telemetry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"broker-telemetry.js","sourceRoot":"","sources":["../src/broker-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAA4B,MAAM,sBAAsB,CAAC;AAG3G,uGAAuG;AACvG,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,MAAM,EAAE,GAAI,GAAkD,EAAE,CAAC,wBAAwB,CAAC,CAAC;IAC3F,OAAO,EAAE,IAAI,OAAQ,EAAiC,CAAC,cAAc,KAAK,UAAU;QAClF,CAAC,CAAE,EAAiC;QACpC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,mBAAmB,CAAC,OAAmC;IACrE,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACxD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;KACzD,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,WAAW,CAAC,IAAwB;IAClD,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,IAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACjH,CAAC"}
1
+ {"version":3,"file":"broker-telemetry.js","sourceRoot":"","sources":["../src/broker-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAA4B,MAAM,sBAAsB,CAAC;AAG3G,uGAAuG;AACvG,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,MAAM,EAAE,GAAI,GAAkD,EAAE,CAAC,wBAAwB,CAAC,CAAC;IAC3F,OAAO,EAAE,IAAI,OAAQ,EAAiC,CAAC,cAAc,KAAK,UAAU;QAClF,CAAC,CAAE,EAAiC;QACpC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,mBAAmB,CAAC,OAAmC;IACrE,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACxD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;KACzD,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
@@ -8,10 +8,18 @@ import { type SupersedeMajor } from '@substrat-run/kernel';
8
8
  import { type RouteReadModelFlush, type RouteReadModelStatus } from './route-read-model-publisher.js';
9
9
  import { type PeerCallTargetRow } from './peer-call-target.js';
10
10
  import { type MirrorFlush, type MirrorStatus } from './directory-mirror.js';
11
+ export type { RoleRow } from './directory-tenant-roles.js';
11
12
  import { type BackfillLimits, type BackfillOwner, type BackfillStatus } from './directory-mirror-backfill.js';
12
13
  import type { MirrorBackfillPass } from './directory-mirror.js';
13
14
  import { type VerifyLimits, type VerifyOwner, type VerifyStatus } from './directory-mirror-verify.js';
14
- import type { AdminLogEntry, OnBehalfOf, DeclaredMigration, ListPage, OpsFailureEntry, SweepRunEntry, RoleDefinition, DirectoryCopyByReference, DirectoryDumpPage, ScopeDumpTable, ScopeStatus, ScopeStorageSample, RequestDay, RequestRollupDay, CostDay, MeterDay, MeterDayTake, StaleScope, StaleScopeTake, VerticalOwnerPeriod, Tenant, TenantId, AppEnvironment, TenantStatus, PeerInstanceResolution, VerticalResolution, ErrorCode } from '@substrat-run/contracts';
15
+ import { type CutoverRow, type CutoverStatus } from './directory-cutover.js';
16
+ import { type MemberTupleRow } from './directory-tenant-tuples.js';
17
+ export type { MemberTupleRow } from './directory-tenant-tuples.js';
18
+ import { type OrgRow } from './directory-tenant-orgs.js';
19
+ export type { OrgRow } from './directory-tenant-orgs.js';
20
+ import { type RoleRow } from './directory-tenant-roles.js';
21
+ import type { AdminLogEntry, OnBehalfOf, DeclaredMigration, ListPage, OpsFailureEntry, SweepRunEntry, RoleDefinition, DirectoryCopyByReference, DirectoryDumpPage, ScopeDumpTable, ScopeId, ScopeStatus, ScopeStorageSample, RequestDay, RequestRollupDay, CostDay, MeterDay, MeterDayTake, StaleScope, StaleScopeTake, VerticalOwnerPeriod, Tenant, TenantId, AppEnvironment, EnvironmentServing, EnvironmentServeAcknowledgement, EnvironmentEffects, ConnectionReach, TenantStatus, PeerInstanceResolution, VerticalResolution, ErrorCode } from '@substrat-run/contracts';
22
+ import type { DependentErasure, OwedDependentErasure } from '@substrat-run/contracts';
15
23
  import type { AccessLogMethod, DeploymentWireAuth, FindingEntry, FindingFilter, FindingRuleEntry, FindingRuleInput, FindingStatusInput } from '@substrat-run/contracts';
16
24
  import type { ConnectLink, ConnectLinkConsume } from '@substrat-run/contracts';
17
25
  /**
@@ -80,14 +88,6 @@ export interface ConnectionGrantDoRow {
80
88
  granted_at: string;
81
89
  revoked_at: string | null;
82
90
  }
83
- export interface RoleRow {
84
- tenant_id: string;
85
- role_key: string;
86
- permissions: string;
87
- source: string;
88
- /** Absent on an older control plane's projection wire. */
89
- holder?: 'person' | 'system' | null;
90
- }
91
91
  /** The raw directory row; the coordinator maps it through the `scope` contract. */
92
92
  export interface ScopeRow {
93
93
  scope_id: string;
@@ -120,6 +120,8 @@ export interface ScopeRow {
120
120
  archived_at: string | null;
121
121
  /** The status it was archived from (#1524); null when not archived or archived before it was recorded. */
122
122
  archived_from_status?: string | null;
123
+ /** #2993: added by `SCOPE_COLUMNS_ADDED`; the declared type, NULL for 'home'. */
124
+ scope_type?: string | null;
123
125
  created_at: string;
124
126
  }
125
127
  export interface HostnameRow {
@@ -251,13 +253,6 @@ export interface ChannelHistoryRow {
251
253
  actor: string;
252
254
  at: string;
253
255
  }
254
- export interface OrgRow {
255
- org_id: string;
256
- tenant_id: string;
257
- slug: string;
258
- name: string;
259
- created_at: string;
260
- }
261
256
  export interface AccessLogRow {
262
257
  id: string;
263
258
  actor: string;
@@ -430,12 +425,6 @@ export interface DirectoryInventory {
430
425
  tenantsByStatus: Record<string, number>;
431
426
  }
432
427
  /** The shape the coordinator hands `recordAdmin`; before/after are arbitrary JSON. */
433
- /** One org membership as `listMembers` reads it (#2047: with its expiry). */
434
- export interface MemberTupleRow {
435
- subject: string;
436
- revoked_at: string | null;
437
- expires_at: string | null;
438
- }
439
428
  export interface AdminEntryInput {
440
429
  id: string;
441
430
  actor: string;
@@ -517,7 +506,7 @@ export declare const BACKFILL_FAILURES_KEY = "versionMigrationsBackfillFailures"
517
506
  /** How long the backfill waits after its `failures`-th failure in a row: doubling, capped. */
518
507
  export declare function backfillBackoffMs(failures: number): number;
519
508
  /** The directory writes `ControlPlaneDO.reply` answers for (#113): each refuses with a typed throw. */
520
- export declare const REPLIED_METHODS: readonly ['createTenant', 'setTenantStatus', 'markScopeStoresFenced', 'reapTenant', 'setTenantName', 'putTenantStore', 'putBlobStore', 'provisionScope', 'createOrg', 'registerIdentityPool', 'linkIdentity', 'createFindingRule', 'insertVersion', 'verticalScopeStores', 'recordStoreDriverRelease', 'approveStoreDriverReleaseAndAudit', 'recordStoreDriverRevokeWalk', 'revokeStoreDriverReleaseAndAudit', 'storeDriverDeclarations', 'storeDriverRolloutPending', 'storeDriverRolloutWalked', 'holdStoreDriver', 'beginStoreDriverRollout', 'finishStoreDriverRollout', 'claimStoreDriverRebuild', 'advanceStoreDriverRebuild', 'updateVerticalListed', 'updateVerticalPublishRequest', 'updateVerticalInstallsBlocked', 'updateVerticalTenantProvisioner', 'updateVerticalEmailSender', 'updateVerticalTraceSampling', 'deleteVertical', 'admitVersion', 'rejectVersion', 'setVerticalServing', 'promoteChannel', 'defineRoleOrRefusal', 'assignTenantRole', 'writeTenantTuple', 'writeOrgTenantTuple', 'writeTenantSystemGrant', 'grantConnectionInDirectory', 'revokeConnectionGrantInDirectory', 'insertOrg', 'bindHostnameInDirectory', 'setHostnameStatus', 'setHostnameIssuance', 'deleteHostname', 'grantEntitlement', 'revokeEntitlement', 'putTenantStoreAndAudit', 'putBlobStoreAndAudit', 'recordStoreDriverReleaseAndAudit', 'beginStoreDriverRolloutAndAudit', 'finishStoreDriverRolloutAndAudit', 'importDumpAndAudit', 'stageRestorePage', 'commitStagedRestoreAndAudit', 'discardStagedRestore', 'registerIdentityPoolAndAudit', 'insertConnectionAndAudit', 'updateConnectionSecretAndAudit', 'revokeConnectionAndAudit', 'linkIdentityAndAudit', 'unlinkIdentityAndAudit', 'markAccessLogDrainedAndAudit', 'pruneAccessLogAndAudit', 'setDirectoryLakeCapture', 'ackDirectoryOutbox', 'advanceDirectoryLakeBackfill', 'pruneDirectoryLakeWindow', 'writeImpersonationAndAudit', 'endImpersonationAndAudit', 'setIssueStatusAndAudit', 'defineEnvironmentAndAudit', 'removeEnvironmentAndAudit'];
509
+ export declare const REPLIED_METHODS: readonly ['createTenant', 'setTenantStatus', 'markScopeStoresFenced', 'reapTenant', 'setTenantName', 'putTenantStore', 'putBlobStore', 'provisionScope', 'createOrg', 'registerIdentityPool', 'linkIdentity', 'createFindingRule', 'insertVersion', 'verticalScopeStores', 'recordStoreDriverRelease', 'approveStoreDriverReleaseAndAudit', 'recordStoreDriverRevokeWalk', 'revokeStoreDriverReleaseAndAudit', 'storeDriverDeclarations', 'storeDriverRolloutPending', 'storeDriverRolloutWalked', 'holdStoreDriver', 'beginStoreDriverRollout', 'finishStoreDriverRollout', 'claimStoreDriverRebuild', 'advanceStoreDriverRebuild', 'updateVerticalListed', 'updateVerticalPublishRequest', 'updateVerticalInstallsBlocked', 'updateVerticalTenantProvisioner', 'updateVerticalEmailSender', 'updateVerticalTraceSampling', 'deleteVertical', 'admitVersion', 'rejectVersion', 'setVerticalServing', 'promoteChannel', 'recordEarlierMajorPromote', 'setEarlierMajorServing', 'defineRoleOrRefusal', 'assignTenantRole', 'writeTenantTuple', 'writeOrgTenantTuple', 'writeTenantSystemGrant', 'grantConnectionInDirectory', 'revokeConnectionGrantInDirectory', 'insertOrg', 'bindHostnameInDirectory', 'setHostnameStatus', 'setHostnameIssuance', 'deleteHostname', 'grantEntitlement', 'revokeEntitlement', 'putTenantStoreAndAudit', 'putBlobStoreAndAudit', 'recordStoreDriverReleaseAndAudit', 'beginStoreDriverRolloutAndAudit', 'finishStoreDriverRolloutAndAudit', 'importDumpAndAudit', 'stageRestorePage', 'commitStagedRestoreAndAudit', 'discardStagedRestore', 'registerIdentityPoolAndAudit', 'insertConnectionAndAudit', 'updateConnectionSecretAndAudit', 'revokeConnectionAndAudit', 'linkIdentityAndAudit', 'unlinkIdentityAndAudit', 'markAccessLogDrainedAndAudit', 'pruneAccessLogAndAudit', 'setDirectoryLakeCapture', 'ackDirectoryOutbox', 'advanceDirectoryLakeBackfill', 'pruneDirectoryLakeWindow', 'writeImpersonationAndAudit', 'endImpersonationAndAudit', 'setIssueStatusAndAudit', 'defineEnvironmentAndAudit', 'removeEnvironmentAndAudit', 'setEnvironmentServingAndAudit', 'claimEnvironmentServe', 'setEnvironmentEffectsAndAudit'];
521
510
  export type RepliedMethod = (typeof REPLIED_METHODS)[number];
522
511
  /**
523
512
  * How long a stage holds off another restore's first page, counted from its last page. A restore
@@ -538,6 +527,10 @@ export declare class ControlPlaneDO extends DurableObject {
538
527
  private readonly kernelSql;
539
528
  /** Settles once the constructor's #1764 backfill check has run (awaited by the tests). */
540
529
  readonly backfillArmed: Promise<void>;
530
+ /** The pass recovers a handoff interrupted after the directory commit. */
531
+ private armTenantDueWork;
532
+ private autoReapAt;
533
+ private armSnapshotReap;
541
534
  constructor(ctx: DurableObjectState, env: unknown);
542
535
  /** Set where `DIRECTORY_MIRROR` is on and the two object namespaces are bound; null otherwise. */
543
536
  private readonly directoryMirror;
@@ -579,6 +572,35 @@ export declare class ControlPlaneDO extends DurableObject {
579
572
  }) | {
580
573
  enabled: false;
581
574
  };
575
+ /** Set where `DIRECTORY_CUTOVER` is on, or a tenant is not off yet; null otherwise. */
576
+ private readonly directoryCutover;
577
+ /** The cut-over's comparison age limit: the production default, other in a test directory. */
578
+ protected directoryCutoverOptions(): {
579
+ verifyMaxAgeMs?: number;
580
+ };
581
+ /**
582
+ * Flip a tenant's directory reads (and first writes) of the cut-over tables to its own object, or
583
+ * back. On is gated in code (`DirectoryCutover.refusal`): the dual-write on, the tenant's last
584
+ * comparison clean, nothing in flight. Off drains every write the object made first into this
585
+ * directory before reads return here. Staff only (the worker's route).
586
+ */
587
+ cutOverTenantDirectory(tenantId: string, to: 'on' | 'off', actor: string): Promise<{
588
+ row: CutoverRow;
589
+ } | {
590
+ refused: string;
591
+ }>;
592
+ /** Where each tenant's flag stands: a page after `after`, or the one `tenantId` names. */
593
+ directoryCutoverStatus(query?: {
594
+ tenantId?: string;
595
+ after?: string;
596
+ limit?: number;
597
+ }): CutoverStatus | {
598
+ enabled: false;
599
+ };
600
+ /** The alarm's cut-over pass, now (staff, and tests): drains, flips off it can complete, registry records. */
601
+ settleDirectoryCutover(): Promise<CutoverStatus | {
602
+ enabled: false;
603
+ }>;
582
604
  /** Set where a `ROUTES` KV namespace is bound; null otherwise, and the read model is off. */
583
605
  private routePublisher;
584
606
  /** #3494: the restore stage's cleanup in flight, which every stage door awaits (`dropRestoreStage`). */
@@ -935,7 +957,7 @@ export declare class ControlPlaneDO extends DurableObject {
935
957
  * previous status (for the audit before/after). Idempotent: set-to-empty DELETEs
936
958
  * plus the status flip converge on a re-run after a partial failure.
937
959
  */
938
- reapTenant(tenantId: string, audit?: AdminEntryInput): string;
960
+ reapTenant(tenantId: string, audit?: AdminEntryInput, deletingBy?: string): string;
939
961
  /**
940
962
  * Rename the DISPLAY name (never the slug); throw if absent; return the previous name. A rename
941
963
  * to the name it already has writes nothing, `audit` included; otherwise `audit`'s `before` is
@@ -1154,6 +1176,26 @@ export declare class ControlPlaneDO extends DurableObject {
1154
1176
  forkedFrom: string | null;
1155
1177
  forkedAt: string | null;
1156
1178
  expiresAt: string | null;
1179
+ /**
1180
+ * #2993: the declared type the host fixed, NULL for 'home'. Absent from a host with no declared
1181
+ * types, which writes the row it always did (NULL) and judges no existing one.
1182
+ */
1183
+ scopeType?: string | null;
1184
+ /**
1185
+ * #2995 (K-64): the parent a `provision-child` names, as requested. Fixed when the row is first
1186
+ * written and never moved (`provisionedParent`, judged here against the row in the write's own
1187
+ * unit). For a new row the parent is judged again here too — of this tenant, `active`, no copy
1188
+ * and no child — so an archive of the parent cannot land between the host's check and this
1189
+ * write. The host has judged the types already. Absent: no parent named.
1190
+ */
1191
+ parentScopeId?: string;
1192
+ /**
1193
+ * #3625 (K-64): the host judged this provision an install (`claimsHome`): parentless, of type
1194
+ * `home`, primary, naming its app itself. Refused here, in the write's own unit, while the app has a
1195
+ * live home scope in the tenant, so two installs racing cannot both pass. Absent: not judged, as
1196
+ * every write was before it.
1197
+ */
1198
+ claimsHome?: boolean;
1157
1199
  }, createdAt: string): boolean;
1158
1200
  /**
1159
1201
  * The scope's migration state, projected into the directory so the fleet
@@ -1174,7 +1216,15 @@ export declare class ControlPlaneDO extends DurableObject {
1174
1216
  tenantId?: string;
1175
1217
  status?: string[];
1176
1218
  vertical?: string;
1219
+ /** #2995: the children of this scope only. */
1220
+ parentScopeId?: string;
1177
1221
  } & ListPage): ScopeRow[];
1222
+ /**
1223
+ * #2993 part 4: the scope types other than `home` that the vertical's scopes hold, every tenant's
1224
+ * and every status but `reaped`, each once. What a promote judges the incoming version's declared
1225
+ * types against. A vertical none of whose scopes is typed answers `[]`.
1226
+ */
1227
+ scopeTypesHeldBy(vertical: string, servingRef?: string): string[];
1178
1228
  /** #2178: `PROVISIONED_VERSIONS_SQL` over the directory — one row per version, however many scopes. */
1179
1229
  provisionedVersionsOf(vertical: string, serving: ServingPointer | null, ownerTenant: string | null): InstallsReconciled[];
1180
1230
  /** Cross-checks the pair (K-3): a scope under a DIFFERENT tenant reads as absent. */
@@ -1234,13 +1284,43 @@ export declare class ControlPlaneDO extends DurableObject {
1234
1284
  code: ErrorCode;
1235
1285
  message: string;
1236
1286
  };
1287
+ /**
1288
+ * #2995 (K-64): archive a scope AND its children, in one unit, so a child never outlives its parent
1289
+ * by a crash between two writes. The parent is judged as `transitionScopeOrRefusal` judges it; each
1290
+ * child in `from` is archived with it, and a child already archived or reaped is left as it is. A
1291
+ * refused parent archives none. Answers the parent's previous state and each child's, for the
1292
+ * coordinator's audit rows and its lifecycle deliveries.
1293
+ */
1294
+ archiveScopeFamilyOrRefusal(tenantId: string, scopeId: string, from: string[], action: string): {
1295
+ ok: true;
1296
+ status: string;
1297
+ vertical: string | null;
1298
+ children: {
1299
+ scopeId: string;
1300
+ status: string;
1301
+ vertical: string | null;
1302
+ }[];
1303
+ } | {
1304
+ ok: false;
1305
+ code: ErrorCode;
1306
+ message: string;
1307
+ };
1308
+ /**
1309
+ * #2995: the ids of `parentScopeId`'s children in `tenantId` whose status is one of `statuses`, oldest
1310
+ * first. What a coordinator reaps before their parent: a child does not outlive it.
1311
+ */
1312
+ childScopeIds(tenantId: string, parentScopeId: string, statuses: string[]): string[];
1313
+ /** A transition's refusal, read in the same synchronous turn as the write that follows it. */
1314
+ private judgeTransition;
1315
+ /** The writes of one judged transition. Called inside the caller's transaction. */
1316
+ private applyTransition;
1237
1317
  /**
1238
1318
  * Kept for a coordinator from before #2447, which calls it and reads the previous role (for the
1239
1319
  * audit `before`) or null. The definition is judged as `defineRoleOrRefusal` judges it, and a
1240
1320
  * refusal is THROWN, so such a coordinator cannot read it as the previous role and audit a change
1241
1321
  * that never happened.
1242
1322
  */
1243
- defineRole(tenantId: string, role: RoleDefinition): RoleDefinition | null;
1323
+ defineRole(tenantId: string, role: RoleDefinition): RoleDefinition | null | Promise<RoleDefinition | null>;
1244
1324
  /**
1245
1325
  * INSERT OR REPLACE; answer the previous role (for the audit `before`) or null. Judged first, in
1246
1326
  * the same unit (#2447, `reservedRoleDefinitionRefusal`): against `reservation`, what the
@@ -1260,20 +1340,38 @@ export declare class ControlPlaneDO extends DurableObject {
1260
1340
  before: RoleDefinition | null;
1261
1341
  } | {
1262
1342
  refused: string;
1263
- };
1264
- private defineRoleIn;
1265
- /** Raw rows; the coordinator parses them through the `tenantRole` contract. */
1343
+ } | Promise<{
1344
+ before: RoleDefinition | null;
1345
+ } | {
1346
+ refused: string;
1347
+ }>;
1348
+ /** Raw rows; the coordinator parses them through the `tenantRole` contract. One cut-over tenant's are its object's (3e). */
1266
1349
  listRoles(filter: {
1267
1350
  tenantId?: string;
1268
1351
  source?: string;
1269
- } & ListPage): RoleRow[];
1270
- getRole(tenantId: string, key: string): RoleDefinition | undefined;
1352
+ } & ListPage): RoleRow[] | Promise<RoleRow[]>;
1353
+ /** A role as stored; a cut-over tenant's from its object (3e). The decisions in this object read `readRole` directly. */
1354
+ getRole(tenantId: string, key: string): RoleDefinition | undefined | Promise<RoleDefinition | undefined>;
1355
+ /** Whether the tenant's tuples and removal fences are read from, and first written to, its own object. */
1356
+ private tuplesCutOver;
1357
+ /** Whether the tenant's organizations are read from, and first written to, its own object (the third family). */
1358
+ private orgsCutOver;
1359
+ /** This directory as a `TupleStore`: its rows, its admin log, its orgs. */
1360
+ private tupleStore;
1361
+ /**
1362
+ * Run `fn` with no other call into this object between its first step and its end. For a cut-over
1363
+ * tenant's unit that reads what this directory still writes (a system switch, a connection) and
1364
+ * writes first in the tenant's object: the read, the object's write and the fallback are then one
1365
+ * step for every other call here, as the synchronous unit is for a tenant not cut over. A failure
1366
+ * is answered after the step, never thrown inside it (a throw there resets the object).
1367
+ */
1368
+ private exclusive;
1271
1369
  /**
1272
1370
  * A tenant tuple, upserted. With `audit` (#2526, `grant` at the tenant node, called through
1273
1371
  * `reply`), its admin row commits in the same transaction; without, as a coordinator from before
1274
- * #2526 calls it, and as this object's own units do, it is the bare write.
1372
+ * #2526 calls it, it is the bare write.
1275
1373
  */
1276
- writeTenantTuple(tenantId: string, subject: string, relation: string, object: string, expiresAt: string | null, audit?: AdminEntryInput): void;
1374
+ writeTenantTuple(tenantId: string, subject: string, relation: string, object: string, expiresAt: string | null, audit?: AdminEntryInput): void | Promise<void>;
1277
1375
  /**
1278
1376
  * #2526: `assignRole` at the tenant node — the role's reservation judged (`reserved`, what the
1279
1377
  * coordinator's modules reserve to a system principal: a role mixing them with other keys is
@@ -1282,19 +1380,25 @@ export declare class ControlPlaneDO extends DurableObject {
1282
1380
  */
1283
1381
  assignTenantRole(tenantId: string, principal: string, roleKey: string, reserved: readonly string[], audit: AdminEntryInput): {
1284
1382
  refused?: string;
1285
- };
1383
+ } | Promise<{
1384
+ refused?: string;
1385
+ }>;
1286
1386
  /**
1287
1387
  * #2526: a tenant tuple that names an org — `grantToOrg` at the tenant node, and `addMember` —
1288
- * with its admin row, in one unit, refused `not_found` when the org is not in the tenant.
1388
+ * with its admin row, in one unit, refused `not_found` when the org is not in the tenant. For a
1389
+ * cut-over tenant the org is asked here first: an org is never removed from a live tenant, so the
1390
+ * answer still holds when the object writes.
1289
1391
  */
1290
- writeOrgTenantTuple(tenantId: string, orgId: string, subject: string, relation: string, object: string, expiresAt: string | null, audit: AdminEntryInput): void;
1392
+ writeOrgTenantTuple(tenantId: string, orgId: string, subject: string, relation: string, object: string, expiresAt: string | null, audit: AdminEntryInput): void | Promise<void>;
1291
1393
  /**
1292
1394
  * #1743: a tenant-level `system:<module>` grant, refused while the record holds the module
1293
1395
  * off on any scope (`scopesSwitchedOffFor`). Synchronous, so the read and the write are one
1294
- * DO unit. Answers the switched-off scopes; non-empty means nothing was written. With `audit`
1295
- * (#2526, through `reply`), the row commits with the tuple, and a refusal records none.
1396
+ * DO unit; for a cut-over tenant, one exclusive step (`exclusive`), the switch read here and the
1397
+ * grant written first in the object. Answers the switched-off scopes; non-empty means nothing was
1398
+ * written. With `audit` (#2526, through `reply`), the row commits with the tuple, and a refusal
1399
+ * records none.
1296
1400
  */
1297
- writeTenantSystemGrant(tenantId: string, moduleId: string, relation: string, expiresAt: string | null, audit?: AdminEntryInput): string[];
1401
+ writeTenantSystemGrant(tenantId: string, moduleId: string, relation: string, expiresAt: string | null, audit?: AdminEntryInput): string[] | Promise<string[]>;
1298
1402
  /** The admin read: the bare hostname row, for the bind/status/unbind paths. */
1299
1403
  readHostname(hostname: string): HostnameRow | undefined;
1300
1404
  /**
@@ -1328,6 +1432,8 @@ export declare class ControlPlaneDO extends DurableObject {
1328
1432
  target_scope_id: string;
1329
1433
  invalidated: number;
1330
1434
  }[];
1435
+ /** #3625 (K-64): the home scope of (tenant, app, environment), or null (kernel `homeScopeIn`). */
1436
+ homeScopeOf(tenantId: TenantId, vertical: string, environment?: string): ScopeId | null;
1331
1437
  /** D-83 (#3530 step 3): the app's environments in the tenant, production first (kernel `environmentsOf`). */
1332
1438
  listEnvironments(tenantId: TenantId, vertical: string): AppEnvironment[];
1333
1439
  /**
@@ -1351,6 +1457,47 @@ export declare class ControlPlaneDO extends DurableObject {
1351
1457
  }, audit: AdminEntryInput): {
1352
1458
  removed: boolean;
1353
1459
  };
1460
+ /**
1461
+ * #3530 step 4: record what an environment's own serving script now runs, compare-and-set on the
1462
+ * record the upload diffed from (kernel `setEnvironmentServingIn`), with its admin row in the
1463
+ * same transaction. False, with nothing written and no row, when the record moved since.
1464
+ */
1465
+ setEnvironmentServingAndAudit(input: {
1466
+ tenantId: TenantId;
1467
+ vertical: string;
1468
+ name: string;
1469
+ }, next: EnvironmentServing, expected: EnvironmentServing | null, audit: AdminEntryInput, claim?: string,
1470
+ /** #3638: what this serve acknowledges in this environment, judged and recorded here. */
1471
+ acknowledge?: EnvironmentServeAcknowledgement): boolean;
1472
+ /**
1473
+ * #3530 step 4: take an environment's serve lease (kernel `claimEnvironmentServeIn`), so its serves
1474
+ * run one at a time. Unaudited: it moves nothing a reader sees, and the serve it guards is audited.
1475
+ */
1476
+ claimEnvironmentServe(input: {
1477
+ tenantId: TenantId;
1478
+ vertical: string;
1479
+ name: string;
1480
+ }, claim: string, leaseMs: number): boolean;
1481
+ /** #3530 step 4: give the lease back, if `claim` still holds it. */
1482
+ releaseEnvironmentServe(input: {
1483
+ tenantId: TenantId;
1484
+ vertical: string;
1485
+ name: string;
1486
+ }, claim: string): void;
1487
+ /**
1488
+ * #3530 step 6: give a named environment connections of its own, or take that back (kernel
1489
+ * `setEnvironmentEffectsIn`), with its admin row in the same transaction. No row when nothing changed.
1490
+ */
1491
+ setEnvironmentEffectsAndAudit(input: {
1492
+ tenantId: TenantId;
1493
+ vertical: string;
1494
+ name: string;
1495
+ }, effects: EnvironmentEffects, audit: AdminEntryInput): {
1496
+ changed: boolean;
1497
+ before: EnvironmentEffects;
1498
+ };
1499
+ /** #3530 step 6: which connections the scope's effects may go through (kernel `connectionReachIn`). */
1500
+ connectionReach(tenantId: TenantId, scopeId: string): ConnectionReach;
1354
1501
  /** Directory write and endpoint checks share this DO's serialized unit. */
1355
1502
  setPeerBinding(tenantId: string, callerScopeId: string, vertical: string, targetScopeId: string | null): {
1356
1503
  ok: false;
@@ -1572,6 +1719,21 @@ export declare class ControlPlaneDO extends DurableObject {
1572
1719
  doClassesJson: string;
1573
1720
  migrationTag: string;
1574
1721
  }, audit?: AdminEntryInput, expected?: ServedFrom, supersede?: SupersedeMajor): boolean;
1722
+ /**
1723
+ * K-65 (#3539): record a release into an earlier major, served on its own script: only that major's
1724
+ * entry of `earlier_majors` moves, compare-and-set on `expected` (`releasedEarlierMajorJson`, which
1725
+ * refuses `precondition_failed`), and `audit`'s `before` is the entry this unit read.
1726
+ */
1727
+ setEarlierMajorServing(slug: string, major: number, s: {
1728
+ ref: string;
1729
+ versionId: string;
1730
+ doClasses: string[];
1731
+ migrationTag: string;
1732
+ }, expected: {
1733
+ versionId: string;
1734
+ doClasses: string[];
1735
+ migrationTag: string;
1736
+ }, audit: AdminEntryInput): boolean;
1575
1737
  /** #2351: the digest of the migrations read from a version's bundle, or `undefined` for no such version. */
1576
1738
  readMigrationsExtracted(id: string): {
1577
1739
  verticalSlug: string;
@@ -1656,6 +1818,21 @@ export declare class ControlPlaneDO extends DurableObject {
1656
1818
  writeImpersonationAndAudit(...args: Required<Parameters<ControlPlaneDO['writeImpersonation']>>): ReturnType<ControlPlaneDO['writeImpersonation']>;
1657
1819
  endImpersonationAndAudit(...args: Required<Parameters<ControlPlaneDO['endImpersonation']>>): ReturnType<ControlPlaneDO['endImpersonation']>;
1658
1820
  setIssueStatusAndAudit(...args: Required<Parameters<ControlPlaneDO['setIssueStatus']>>): ReturnType<ControlPlaneDO['setIssueStatus']>;
1821
+ /**
1822
+ * K-63 (#3624): what an erasure did at a master's dependents. An `erased` dependent leaves the
1823
+ * ledger, an `outstanding` one is kept with its next try; one admin row, in the same unit.
1824
+ */
1825
+ recordDependentErasures(tenantId: string, subjectId: string, outcomes: readonly DependentErasure[], audit: AdminEntryInput): void;
1826
+ /**
1827
+ * K-63 (#3624): hold each dependent as owed, before the master's erasure runs. The statements run
1828
+ * in one synchronous call, so the object commits them together. A row already owed is kept.
1829
+ */
1830
+ holdDependentErasures(tenantId: string, subjectId: string, dependents: readonly {
1831
+ vertical: string;
1832
+ scopeId: string;
1833
+ }[]): void;
1834
+ /** K-63 (#3624): the owed dependent erasures due at `now`, oldest due first. */
1835
+ dueDependentErasures(now: string, limit: number): OwedDependentErasure[];
1659
1836
  scopeErasureEpoch(tenantId: string, scopeId: string): number;
1660
1837
  /** The erasure claim (`SUBJECT_ERASURE_CLAIM_SQL`): false when the scope moved since the fence was read. */
1661
1838
  claimSubjectErasure(tenantId: string, scopeId: string, fence: SubjectErasureFence): boolean;
@@ -1676,14 +1853,28 @@ export declare class ControlPlaneDO extends DurableObject {
1676
1853
  leaseUntil: string;
1677
1854
  owner: string;
1678
1855
  limit: number;
1856
+ tenantId?: string;
1679
1857
  }): ScopeScriptCopyRow[];
1680
1858
  /** `HostAdmin.markScopeStoresFenced`: read and written in one synchronous step, so an unarchive is before or after. */
1681
- markScopeStoresFenced(tenantId: string, scopeId: string, whileTenantDeleting: boolean, audit?: AdminEntryInput): void;
1859
+ markScopeStoresFenced(tenantId: string, scopeId: string, whileTenantDeleting: boolean, audit?: AdminEntryInput, deadlines?: {
1860
+ archivedBy?: string;
1861
+ deletingBy?: string;
1862
+ }): void;
1682
1863
  scopeStoresFencedAt(tenantId: string, scopeId: string): string | null;
1683
1864
  /** #3314: `expiredBy` claims only while the expiry is set and due, in the claim's own write. */
1684
1865
  beginScopeScriptReap(tenantId: string, scopeId: string, expiredBy?: string): 'claimed' | 'pending' | 'missing' | 'not-due';
1685
1866
  settleScopeScriptCopy(tenantId: string, scopeId: string, scriptRef: string, moveId: string, state: string, loadStamp: string | null, revision: string | null, claimedBy?: string): boolean;
1686
1867
  touchScopeScriptCopy(tenantId: string, scopeId: string, scriptRef: string, moveId: string): void;
1868
+ nextScopeCopyDue(tenantId: string, now: string): string | null;
1869
+ listDueScopeCopyTenants(input: {
1870
+ after: string;
1871
+ by: string;
1872
+ now: string;
1873
+ limit: number;
1874
+ }): {
1875
+ tenantId: string;
1876
+ dueAt: string;
1877
+ }[];
1687
1878
  listScopeScriptCopies(filter: {
1688
1879
  tenantId?: string;
1689
1880
  scopeId?: string;
@@ -1735,22 +1926,29 @@ export declare class ControlPlaneDO extends DurableObject {
1735
1926
  * refuses on the listing it read itself first, so only a listing landing inside that window passes.
1736
1927
  */
1737
1928
  promoteChannel(from: string | null, history: ChannelHistoryRow, unlistedOnly: boolean, audit: AdminEntryInput, breakingWithinMajor?: string | null): boolean;
1929
+ /**
1930
+ * K-65 (#3539): the unit of a release into an earlier major, which moves no channel: its admin row
1931
+ * lands only while major `major`'s script still runs `from`, the version its gates were judged
1932
+ * against, with the listing and the admission read here as `promoteChannel` reads them for prod.
1933
+ * False, with nothing written, when that script moved.
1934
+ */
1935
+ recordEarlierMajorPromote(slug: string, major: number, from: string, versionId: string, unlistedOnly: boolean, audit: AdminEntryInput, breakingWithinMajor: string | null): boolean;
1738
1936
  listChannels(verticalSlug: string, page?: ListPage): ChannelRow[];
1739
1937
  insertChannelHistory(h: ChannelHistoryRow): void;
1740
1938
  listChannelHistory(verticalSlug: string, channel?: string, page?: ListPage): ChannelHistoryRow[];
1741
- readOrg(tenantId: string, orgId: string): OrgRow | undefined;
1939
+ readOrg(tenantId: string, orgId: string): OrgRow | undefined | Promise<OrgRow | undefined>;
1742
1940
  /** Returns false when the org already exists (idempotent); throws on slug collision. */
1743
- createOrg(orgId: string, tenantId: string, slug: string, name: string, createdAt: string): boolean;
1941
+ createOrg(orgId: string, tenantId: string, slug: string, name: string, createdAt: string): boolean | Promise<boolean>;
1744
1942
  /**
1745
1943
  * #2526: `createOrg` with its admin row, in one unit; an org that already exists writes nothing,
1746
1944
  * the row included. A new name rather than a trailing argument on `createOrg`, which an older
1747
1945
  * ControlPlaneDO already lists in `REPLIED_METHODS`: there the argument would be dropped and the
1748
1946
  * org created with no row, where an unknown method fails closed.
1749
1947
  */
1750
- insertOrg(orgId: string, tenantId: string, slug: string, name: string, createdAt: string, audit: AdminEntryInput): boolean;
1751
- listOrgs(tenantId: string): OrgRow[];
1752
- /** The tenant-level reads, synchronous, for a bound asked inside one of this object's units (#1184). */
1753
- private readonly directoryReader;
1948
+ insertOrg(orgId: string, tenantId: string, slug: string, name: string, createdAt: string, audit: AdminEntryInput): boolean | Promise<boolean>;
1949
+ /** A cut-over tenant's org, created first in its object; a slug's conflict is rethrown here with its code. */
1950
+ private createOrgFirst;
1951
+ listOrgs(tenantId: string): OrgRow[] | Promise<OrgRow[]>;
1754
1952
  /**
1755
1953
  * A membership change as ONE DO unit (#1184) — `HostAdmin.applyMembership`. Synchronous, so
1756
1954
  * no other request into this object runs between its reads and its writes: an add's removal
@@ -1763,41 +1961,41 @@ export declare class ControlPlaneDO extends DurableObject {
1763
1961
  * The org row's `before`/`after` are written here, since only the unit knows the expiry.
1764
1962
  * `reserved` (#2430) is what the coordinator's modules reserve to a system principal: an add of
1765
1963
  * a role carrying one is a person conferring it, refused in the unit (`reservedRoleRefusal`).
1964
+ * For a cut-over tenant (K-68 step 3e) the same unit runs in its object, whose tuples, fences and
1965
+ * roles are the ones written first; whether the org exists is asked here, where orgs are kept.
1766
1966
  */
1767
- applyMembership(change: MembershipChange, row: AdminEntryInput, orgRow?: AdminEntryInput, reserved?: readonly string[]): MembershipChangeResult;
1967
+ applyMembership(change: MembershipChange, row: AdminEntryInput, orgRow?: AdminEntryInput, reserved?: readonly string[]): MembershipChangeResult | Promise<MembershipChangeResult>;
1768
1968
  /**
1769
1969
  * A tenant-level removal as ONE DO unit (#1184) — `unassignRole` at the tenant node, and
1770
1970
  * `removeMember`: the tombstone, the principal's removal fence, and the audit row, which
1771
1971
  * K-21 writes only when something changed. The fence is raised either way: a removal of
1772
1972
  * someone whose add is still on its way takes nothing, and must still win. One method, so
1773
1973
  * no add can run between the revoke and the fence. Returns whether anything changed.
1774
- */
1775
- revokeAndFence(tenantId: string, principal: string, relation: string, object: string, row: AdminEntryInput): boolean;
1776
- /**
1777
- * `revokeAndFence`'s writes, for inside a transaction a caller already holds.
1778
1974
  *
1779
- * The time is minted HERE, in the unit, never taken from `row.at`: the coordinator mints its
1780
- * row before an awaited RPC, and a queue delay in between would age the fence by however
1781
- * long the call waited, which an add's cutoff would read as a removal from before its window
1782
- * (Codex round 3). The fence is compared with an add's `occurredAt`, stamped by the ScopeDO's
1783
- * clock. Both are this platform's own NTP-disciplined time, sub-second apart, which is far
1784
- * inside `MEMBERSHIP_REMOVAL_SKEW_MS`.
1785
- */
1786
- private revokeAndFenceIn;
1975
+ * The time is minted in the unit, never taken from `row.at`: the coordinator mints its row
1976
+ * before an awaited RPC, and a queue delay in between would age the fence by however long the
1977
+ * call waited, which an add's cutoff would read as a removal from before its window (Codex
1978
+ * round 3). The fence is compared with an add's `occurredAt`, stamped by the ScopeDO's clock.
1979
+ * Both are this platform's own NTP-disciplined time, sub-second apart, which is far inside
1980
+ * `MEMBERSHIP_REMOVAL_SKEW_MS`.
1981
+ */
1982
+ revokeAndFence(tenantId: string, principal: string, relation: string, object: string, row: AdminEntryInput): boolean | Promise<boolean>;
1787
1983
  /** Tombstone any tenant tuple by its exact (subject, relation, object). Returns
1788
- * whether a live row changed, so a repeat revoke is a silent no-op. */
1984
+ * whether a live row changed, so a repeat revoke is a silent no-op. A cut-over tenant's is
1985
+ * refused here (K-68 step 3e: its tuples are written in its object first). */
1789
1986
  revokeTenantTuple(tenantId: string, subject: string, relation: string, object: string, at: string): boolean;
1790
1987
  /** Members of an org. Live only unless `includeRevoked` — revoked rows are evidence. */
1791
- listMembers(tenantId: string, object: string, includeRevoked: boolean): MemberTupleRow[];
1792
- tenantTuples(tenantId: string, subject: string, relationPrefix: string): TupleRow[];
1988
+ listMembers(tenantId: string, object: string, includeRevoked: boolean): MemberTupleRow[] | Promise<MemberTupleRow[]>;
1989
+ tenantTuples(tenantId: string, subject: string, relationPrefix: string): TupleRow[] | Promise<TupleRow[]>;
1793
1990
  /**
1794
1991
  * ALL of a tenant's tenant-level tuples — the read behind scope-local projection
1795
1992
  * (docs/architecture/scope-local-permissions.md). Includes tombstoned rows so the
1796
1993
  * projection mirrors the directory exactly and the checker's own `live()` filter
1797
1994
  * drops them identically. Not on the request hot path — this runs on the admin
1798
- * write path, projecting into a tenant's scopes.
1995
+ * write path, projecting into a tenant's scopes. A cut-over tenant's are its object's, so a
1996
+ * revocation it made first is projected even while its fallback is still owed here.
1799
1997
  */
1800
- dumpTenantTuples(tenantId: string): TupleRow[];
1998
+ dumpTenantTuples(tenantId: string): TupleRow[] | Promise<TupleRow[]>;
1801
1999
  private readEntitlement;
1802
2000
  /**
1803
2001
  * Upsert; returns before/after for the host's audit row, `changed: false` when
@@ -2054,7 +2252,24 @@ export declare class ControlPlaneDO extends DurableObject {
2054
2252
  grantedAt: string;
2055
2253
  }, audit: AdminEntryInput): {
2056
2254
  vertical: string;
2057
- };
2255
+ } | Promise<{
2256
+ vertical: string;
2257
+ }>;
2258
+ /**
2259
+ * K-68 step 3e: a tenant-level connection grant of a cut-over tenant, as one exclusive step
2260
+ * (`exclusive`): the connection judged here as it stands, the tuple written first in the tenant's
2261
+ * object, and the record (`_substrat_connection_grants`, still this directory's) carried with it to
2262
+ * the fallback, which writes the record, the tuple and the admin row in one transaction. A revoke of
2263
+ * the connection can then land only after the grant, as it could in the synchronous unit; if the
2264
+ * fallback is applied later, `applyCarried` tombstones the record as that revoke's cascade would have.
2265
+ */
2266
+ private grantConnectionFirst;
2267
+ /**
2268
+ * K-68 step 3e: a write the directory still owns that rode a first write (`CarriedWrite`), in the
2269
+ * fallback's transaction. A connection revoked since the grant was judged tombstones the record at
2270
+ * its revoke time (#592's cascade): the grant came first, and the revoke took it.
2271
+ */
2272
+ private applyCarried;
2058
2273
  /**
2059
2274
  * #2732: `revokeFromConnection`'s directory half as one unit, after the scope's tuple was
2060
2275
  * delivered gone. The scope-level record is tombstoned (K-21), so the additive reconcile never
@@ -2103,7 +2318,7 @@ export declare class ControlPlaneDO extends DurableObject {
2103
2318
  * for — what the switch passes the scope as `tenantHeld`, so a subject whose only authority
2104
2319
  * there is a tenant tuple is still switchable. Read here, where the tenant tuples live.
2105
2320
  */
2106
- tenantHeldOf(kind: SwitchKind, tenantId: string, keys: readonly string[], now: string): string[];
2321
+ tenantHeldOf(kind: SwitchKind, tenantId: string, keys: readonly string[], now: string): string[] | Promise<string[]>;
2107
2322
  /** The fleet read. */
2108
2323
  listSystemSwitches(filter?: SystemSwitchRecordFilter): SystemSwitchRecordRow[];
2109
2324
  /** One scope's recorded positions of one kind, by subject — the status read's `recorded` join. */