@substrat-run/adapter-cloudflare 0.221.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 (82) 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 +244 -67
  6. package/dist/control-plane-do.d.ts.map +1 -1
  7. package/dist/control-plane-do.js +664 -246
  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 +7 -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 +12 -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 +26 -1
  57. package/dist/host.d.ts.map +1 -1
  58. package/dist/host.js +262 -45
  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/scope-do.d.ts +11 -2
  67. package/dist/scope-do.d.ts.map +1 -1
  68. package/dist/scope-do.js +154 -40
  69. package/dist/scope-do.js.map +1 -1
  70. package/dist/scope-sweeper-do.d.ts +22 -0
  71. package/dist/scope-sweeper-do.d.ts.map +1 -1
  72. package/dist/scope-sweeper-do.js +74 -54
  73. package/dist/scope-sweeper-do.js.map +1 -1
  74. package/dist/scope-wake.d.ts +12 -1
  75. package/dist/scope-wake.d.ts.map +1 -1
  76. package/dist/scope-wake.js +14 -1
  77. package/dist/scope-wake.js.map +1 -1
  78. package/dist/tenant-due-work-do.d.ts +95 -0
  79. package/dist/tenant-due-work-do.d.ts.map +1 -0
  80. package/dist/tenant-due-work-do.js +149 -0
  81. package/dist/tenant-due-work-do.js.map +1 -0
  82. 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, EnvironmentServing, 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;
@@ -253,13 +253,6 @@ export interface ChannelHistoryRow {
253
253
  actor: string;
254
254
  at: string;
255
255
  }
256
- export interface OrgRow {
257
- org_id: string;
258
- tenant_id: string;
259
- slug: string;
260
- name: string;
261
- created_at: string;
262
- }
263
256
  export interface AccessLogRow {
264
257
  id: string;
265
258
  actor: string;
@@ -432,12 +425,6 @@ export interface DirectoryInventory {
432
425
  tenantsByStatus: Record<string, number>;
433
426
  }
434
427
  /** The shape the coordinator hands `recordAdmin`; before/after are arbitrary JSON. */
435
- /** One org membership as `listMembers` reads it (#2047: with its expiry). */
436
- export interface MemberTupleRow {
437
- subject: string;
438
- revoked_at: string | null;
439
- expires_at: string | null;
440
- }
441
428
  export interface AdminEntryInput {
442
429
  id: string;
443
430
  actor: string;
@@ -519,7 +506,7 @@ export declare const BACKFILL_FAILURES_KEY = "versionMigrationsBackfillFailures"
519
506
  /** How long the backfill waits after its `failures`-th failure in a row: doubling, capped. */
520
507
  export declare function backfillBackoffMs(failures: number): number;
521
508
  /** The directory writes `ControlPlaneDO.reply` answers for (#113): each refuses with a typed throw. */
522
- 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', 'setEnvironmentServingAndAudit', 'claimEnvironmentServe'];
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'];
523
510
  export type RepliedMethod = (typeof REPLIED_METHODS)[number];
524
511
  /**
525
512
  * How long a stage holds off another restore's first page, counted from its last page. A restore
@@ -540,6 +527,10 @@ export declare class ControlPlaneDO extends DurableObject {
540
527
  private readonly kernelSql;
541
528
  /** Settles once the constructor's #1764 backfill check has run (awaited by the tests). */
542
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;
543
534
  constructor(ctx: DurableObjectState, env: unknown);
544
535
  /** Set where `DIRECTORY_MIRROR` is on and the two object namespaces are bound; null otherwise. */
545
536
  private readonly directoryMirror;
@@ -581,6 +572,35 @@ export declare class ControlPlaneDO extends DurableObject {
581
572
  }) | {
582
573
  enabled: false;
583
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
+ }>;
584
604
  /** Set where a `ROUTES` KV namespace is bound; null otherwise, and the read model is off. */
585
605
  private routePublisher;
586
606
  /** #3494: the restore stage's cleanup in flight, which every stage door awaits (`dropRestoreStage`). */
@@ -937,7 +957,7 @@ export declare class ControlPlaneDO extends DurableObject {
937
957
  * previous status (for the audit before/after). Idempotent: set-to-empty DELETEs
938
958
  * plus the status flip converge on a re-run after a partial failure.
939
959
  */
940
- reapTenant(tenantId: string, audit?: AdminEntryInput): string;
960
+ reapTenant(tenantId: string, audit?: AdminEntryInput, deletingBy?: string): string;
941
961
  /**
942
962
  * Rename the DISPLAY name (never the slug); throw if absent; return the previous name. A rename
943
963
  * to the name it already has writes nothing, `audit` included; otherwise `audit`'s `before` is
@@ -1161,6 +1181,21 @@ export declare class ControlPlaneDO extends DurableObject {
1161
1181
  * types, which writes the row it always did (NULL) and judges no existing one.
1162
1182
  */
1163
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;
1164
1199
  }, createdAt: string): boolean;
1165
1200
  /**
1166
1201
  * The scope's migration state, projected into the directory so the fleet
@@ -1181,13 +1216,15 @@ export declare class ControlPlaneDO extends DurableObject {
1181
1216
  tenantId?: string;
1182
1217
  status?: string[];
1183
1218
  vertical?: string;
1219
+ /** #2995: the children of this scope only. */
1220
+ parentScopeId?: string;
1184
1221
  } & ListPage): ScopeRow[];
1185
1222
  /**
1186
1223
  * #2993 part 4: the scope types other than `home` that the vertical's scopes hold, every tenant's
1187
1224
  * and every status but `reaped`, each once. What a promote judges the incoming version's declared
1188
1225
  * types against. A vertical none of whose scopes is typed answers `[]`.
1189
1226
  */
1190
- scopeTypesHeldBy(vertical: string): string[];
1227
+ scopeTypesHeldBy(vertical: string, servingRef?: string): string[];
1191
1228
  /** #2178: `PROVISIONED_VERSIONS_SQL` over the directory — one row per version, however many scopes. */
1192
1229
  provisionedVersionsOf(vertical: string, serving: ServingPointer | null, ownerTenant: string | null): InstallsReconciled[];
1193
1230
  /** Cross-checks the pair (K-3): a scope under a DIFFERENT tenant reads as absent. */
@@ -1247,13 +1284,43 @@ export declare class ControlPlaneDO extends DurableObject {
1247
1284
  code: ErrorCode;
1248
1285
  message: string;
1249
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;
1250
1317
  /**
1251
1318
  * Kept for a coordinator from before #2447, which calls it and reads the previous role (for the
1252
1319
  * audit `before`) or null. The definition is judged as `defineRoleOrRefusal` judges it, and a
1253
1320
  * refusal is THROWN, so such a coordinator cannot read it as the previous role and audit a change
1254
1321
  * that never happened.
1255
1322
  */
1256
- defineRole(tenantId: string, role: RoleDefinition): RoleDefinition | null;
1323
+ defineRole(tenantId: string, role: RoleDefinition): RoleDefinition | null | Promise<RoleDefinition | null>;
1257
1324
  /**
1258
1325
  * INSERT OR REPLACE; answer the previous role (for the audit `before`) or null. Judged first, in
1259
1326
  * the same unit (#2447, `reservedRoleDefinitionRefusal`): against `reservation`, what the
@@ -1273,20 +1340,38 @@ export declare class ControlPlaneDO extends DurableObject {
1273
1340
  before: RoleDefinition | null;
1274
1341
  } | {
1275
1342
  refused: string;
1276
- };
1277
- private defineRoleIn;
1278
- /** 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). */
1279
1349
  listRoles(filter: {
1280
1350
  tenantId?: string;
1281
1351
  source?: string;
1282
- } & ListPage): RoleRow[];
1283
- 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;
1284
1369
  /**
1285
1370
  * A tenant tuple, upserted. With `audit` (#2526, `grant` at the tenant node, called through
1286
1371
  * `reply`), its admin row commits in the same transaction; without, as a coordinator from before
1287
- * #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.
1288
1373
  */
1289
- 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>;
1290
1375
  /**
1291
1376
  * #2526: `assignRole` at the tenant node — the role's reservation judged (`reserved`, what the
1292
1377
  * coordinator's modules reserve to a system principal: a role mixing them with other keys is
@@ -1295,19 +1380,25 @@ export declare class ControlPlaneDO extends DurableObject {
1295
1380
  */
1296
1381
  assignTenantRole(tenantId: string, principal: string, roleKey: string, reserved: readonly string[], audit: AdminEntryInput): {
1297
1382
  refused?: string;
1298
- };
1383
+ } | Promise<{
1384
+ refused?: string;
1385
+ }>;
1299
1386
  /**
1300
1387
  * #2526: a tenant tuple that names an org — `grantToOrg` at the tenant node, and `addMember` —
1301
- * 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.
1302
1391
  */
1303
- 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>;
1304
1393
  /**
1305
1394
  * #1743: a tenant-level `system:<module>` grant, refused while the record holds the module
1306
1395
  * off on any scope (`scopesSwitchedOffFor`). Synchronous, so the read and the write are one
1307
- * DO unit. Answers the switched-off scopes; non-empty means nothing was written. With `audit`
1308
- * (#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.
1309
1400
  */
1310
- 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[]>;
1311
1402
  /** The admin read: the bare hostname row, for the bind/status/unbind paths. */
1312
1403
  readHostname(hostname: string): HostnameRow | undefined;
1313
1404
  /**
@@ -1341,6 +1432,8 @@ export declare class ControlPlaneDO extends DurableObject {
1341
1432
  target_scope_id: string;
1342
1433
  invalidated: number;
1343
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;
1344
1437
  /** D-83 (#3530 step 3): the app's environments in the tenant, production first (kernel `environmentsOf`). */
1345
1438
  listEnvironments(tenantId: TenantId, vertical: string): AppEnvironment[];
1346
1439
  /**
@@ -1373,7 +1466,9 @@ export declare class ControlPlaneDO extends DurableObject {
1373
1466
  tenantId: TenantId;
1374
1467
  vertical: string;
1375
1468
  name: string;
1376
- }, next: EnvironmentServing, expected: EnvironmentServing | null, audit: AdminEntryInput, claim?: string): boolean;
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;
1377
1472
  /**
1378
1473
  * #3530 step 4: take an environment's serve lease (kernel `claimEnvironmentServeIn`), so its serves
1379
1474
  * run one at a time. Unaudited: it moves nothing a reader sees, and the serve it guards is audited.
@@ -1389,6 +1484,20 @@ export declare class ControlPlaneDO extends DurableObject {
1389
1484
  vertical: string;
1390
1485
  name: string;
1391
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;
1392
1501
  /** Directory write and endpoint checks share this DO's serialized unit. */
1393
1502
  setPeerBinding(tenantId: string, callerScopeId: string, vertical: string, targetScopeId: string | null): {
1394
1503
  ok: false;
@@ -1610,6 +1719,21 @@ export declare class ControlPlaneDO extends DurableObject {
1610
1719
  doClassesJson: string;
1611
1720
  migrationTag: string;
1612
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;
1613
1737
  /** #2351: the digest of the migrations read from a version's bundle, or `undefined` for no such version. */
1614
1738
  readMigrationsExtracted(id: string): {
1615
1739
  verticalSlug: string;
@@ -1694,6 +1818,21 @@ export declare class ControlPlaneDO extends DurableObject {
1694
1818
  writeImpersonationAndAudit(...args: Required<Parameters<ControlPlaneDO['writeImpersonation']>>): ReturnType<ControlPlaneDO['writeImpersonation']>;
1695
1819
  endImpersonationAndAudit(...args: Required<Parameters<ControlPlaneDO['endImpersonation']>>): ReturnType<ControlPlaneDO['endImpersonation']>;
1696
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[];
1697
1836
  scopeErasureEpoch(tenantId: string, scopeId: string): number;
1698
1837
  /** The erasure claim (`SUBJECT_ERASURE_CLAIM_SQL`): false when the scope moved since the fence was read. */
1699
1838
  claimSubjectErasure(tenantId: string, scopeId: string, fence: SubjectErasureFence): boolean;
@@ -1714,14 +1853,28 @@ export declare class ControlPlaneDO extends DurableObject {
1714
1853
  leaseUntil: string;
1715
1854
  owner: string;
1716
1855
  limit: number;
1856
+ tenantId?: string;
1717
1857
  }): ScopeScriptCopyRow[];
1718
1858
  /** `HostAdmin.markScopeStoresFenced`: read and written in one synchronous step, so an unarchive is before or after. */
1719
- 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;
1720
1863
  scopeStoresFencedAt(tenantId: string, scopeId: string): string | null;
1721
1864
  /** #3314: `expiredBy` claims only while the expiry is set and due, in the claim's own write. */
1722
1865
  beginScopeScriptReap(tenantId: string, scopeId: string, expiredBy?: string): 'claimed' | 'pending' | 'missing' | 'not-due';
1723
1866
  settleScopeScriptCopy(tenantId: string, scopeId: string, scriptRef: string, moveId: string, state: string, loadStamp: string | null, revision: string | null, claimedBy?: string): boolean;
1724
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
+ }[];
1725
1878
  listScopeScriptCopies(filter: {
1726
1879
  tenantId?: string;
1727
1880
  scopeId?: string;
@@ -1773,22 +1926,29 @@ export declare class ControlPlaneDO extends DurableObject {
1773
1926
  * refuses on the listing it read itself first, so only a listing landing inside that window passes.
1774
1927
  */
1775
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;
1776
1936
  listChannels(verticalSlug: string, page?: ListPage): ChannelRow[];
1777
1937
  insertChannelHistory(h: ChannelHistoryRow): void;
1778
1938
  listChannelHistory(verticalSlug: string, channel?: string, page?: ListPage): ChannelHistoryRow[];
1779
- readOrg(tenantId: string, orgId: string): OrgRow | undefined;
1939
+ readOrg(tenantId: string, orgId: string): OrgRow | undefined | Promise<OrgRow | undefined>;
1780
1940
  /** Returns false when the org already exists (idempotent); throws on slug collision. */
1781
- 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>;
1782
1942
  /**
1783
1943
  * #2526: `createOrg` with its admin row, in one unit; an org that already exists writes nothing,
1784
1944
  * the row included. A new name rather than a trailing argument on `createOrg`, which an older
1785
1945
  * ControlPlaneDO already lists in `REPLIED_METHODS`: there the argument would be dropped and the
1786
1946
  * org created with no row, where an unknown method fails closed.
1787
1947
  */
1788
- insertOrg(orgId: string, tenantId: string, slug: string, name: string, createdAt: string, audit: AdminEntryInput): boolean;
1789
- listOrgs(tenantId: string): OrgRow[];
1790
- /** The tenant-level reads, synchronous, for a bound asked inside one of this object's units (#1184). */
1791
- 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[]>;
1792
1952
  /**
1793
1953
  * A membership change as ONE DO unit (#1184) — `HostAdmin.applyMembership`. Synchronous, so
1794
1954
  * no other request into this object runs between its reads and its writes: an add's removal
@@ -1801,41 +1961,41 @@ export declare class ControlPlaneDO extends DurableObject {
1801
1961
  * The org row's `before`/`after` are written here, since only the unit knows the expiry.
1802
1962
  * `reserved` (#2430) is what the coordinator's modules reserve to a system principal: an add of
1803
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.
1804
1966
  */
1805
- 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>;
1806
1968
  /**
1807
1969
  * A tenant-level removal as ONE DO unit (#1184) — `unassignRole` at the tenant node, and
1808
1970
  * `removeMember`: the tombstone, the principal's removal fence, and the audit row, which
1809
1971
  * K-21 writes only when something changed. The fence is raised either way: a removal of
1810
1972
  * someone whose add is still on its way takes nothing, and must still win. One method, so
1811
1973
  * no add can run between the revoke and the fence. Returns whether anything changed.
1812
- */
1813
- revokeAndFence(tenantId: string, principal: string, relation: string, object: string, row: AdminEntryInput): boolean;
1814
- /**
1815
- * `revokeAndFence`'s writes, for inside a transaction a caller already holds.
1816
1974
  *
1817
- * The time is minted HERE, in the unit, never taken from `row.at`: the coordinator mints its
1818
- * row before an awaited RPC, and a queue delay in between would age the fence by however
1819
- * long the call waited, which an add's cutoff would read as a removal from before its window
1820
- * (Codex round 3). The fence is compared with an add's `occurredAt`, stamped by the ScopeDO's
1821
- * clock. Both are this platform's own NTP-disciplined time, sub-second apart, which is far
1822
- * inside `MEMBERSHIP_REMOVAL_SKEW_MS`.
1823
- */
1824
- 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>;
1825
1983
  /** Tombstone any tenant tuple by its exact (subject, relation, object). Returns
1826
- * 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). */
1827
1986
  revokeTenantTuple(tenantId: string, subject: string, relation: string, object: string, at: string): boolean;
1828
1987
  /** Members of an org. Live only unless `includeRevoked` — revoked rows are evidence. */
1829
- listMembers(tenantId: string, object: string, includeRevoked: boolean): MemberTupleRow[];
1830
- 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[]>;
1831
1990
  /**
1832
1991
  * ALL of a tenant's tenant-level tuples — the read behind scope-local projection
1833
1992
  * (docs/architecture/scope-local-permissions.md). Includes tombstoned rows so the
1834
1993
  * projection mirrors the directory exactly and the checker's own `live()` filter
1835
1994
  * drops them identically. Not on the request hot path — this runs on the admin
1836
- * 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.
1837
1997
  */
1838
- dumpTenantTuples(tenantId: string): TupleRow[];
1998
+ dumpTenantTuples(tenantId: string): TupleRow[] | Promise<TupleRow[]>;
1839
1999
  private readEntitlement;
1840
2000
  /**
1841
2001
  * Upsert; returns before/after for the host's audit row, `changed: false` when
@@ -2092,7 +2252,24 @@ export declare class ControlPlaneDO extends DurableObject {
2092
2252
  grantedAt: string;
2093
2253
  }, audit: AdminEntryInput): {
2094
2254
  vertical: string;
2095
- };
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;
2096
2273
  /**
2097
2274
  * #2732: `revokeFromConnection`'s directory half as one unit, after the scope's tuple was
2098
2275
  * delivered gone. The scope-level record is tombstoned (K-21), so the additive reconcile never
@@ -2141,7 +2318,7 @@ export declare class ControlPlaneDO extends DurableObject {
2141
2318
  * for — what the switch passes the scope as `tenantHeld`, so a subject whose only authority
2142
2319
  * there is a tenant tuple is still switchable. Read here, where the tenant tuples live.
2143
2320
  */
2144
- 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[]>;
2145
2322
  /** The fleet read. */
2146
2323
  listSystemSwitches(filter?: SystemSwitchRecordFilter): SystemSwitchRecordRow[];
2147
2324
  /** One scope's recorded positions of one kind, by subject — the status read's `recorded` join. */