@substrat-run/adapter-cloudflare 0.240.0 → 0.242.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 (72) hide show
  1. package/dist/connection-sweep-do.d.ts +12 -0
  2. package/dist/connection-sweep-do.d.ts.map +1 -1
  3. package/dist/connection-sweep-do.js +28 -6
  4. package/dist/connection-sweep-do.js.map +1 -1
  5. package/dist/control-plane-do.d.ts +22 -0
  6. package/dist/control-plane-do.d.ts.map +1 -1
  7. package/dist/control-plane-do.js +60 -13
  8. package/dist/control-plane-do.js.map +1 -1
  9. package/dist/control-plane-object.d.ts +23 -0
  10. package/dist/control-plane-object.d.ts.map +1 -0
  11. package/dist/control-plane-object.js +92 -0
  12. package/dist/control-plane-object.js.map +1 -0
  13. package/dist/delivery-broker-supervisor-do.d.ts +19 -0
  14. package/dist/delivery-broker-supervisor-do.d.ts.map +1 -1
  15. package/dist/delivery-broker-supervisor-do.js +27 -0
  16. package/dist/delivery-broker-supervisor-do.js.map +1 -1
  17. package/dist/directory-placement.d.ts.map +1 -1
  18. package/dist/directory-placement.js +7 -0
  19. package/dist/directory-placement.js.map +1 -1
  20. package/dist/egress-gate.d.ts +71 -0
  21. package/dist/egress-gate.d.ts.map +1 -0
  22. package/dist/egress-gate.js +80 -0
  23. package/dist/egress-gate.js.map +1 -0
  24. package/dist/host.d.ts +1058 -18
  25. package/dist/host.d.ts.map +1 -1
  26. package/dist/host.js +135 -29
  27. package/dist/host.js.map +1 -1
  28. package/dist/index.d.ts +4 -3
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +5 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/listed-object.d.ts +24 -0
  33. package/dist/listed-object.d.ts.map +1 -0
  34. package/dist/listed-object.js +43 -0
  35. package/dist/listed-object.js.map +1 -0
  36. package/dist/peer-read-evidence.d.ts +31 -31
  37. package/dist/peer-read-evidence.d.ts.map +1 -1
  38. package/dist/peer-read-evidence.js +75 -0
  39. package/dist/peer-read-evidence.js.map +1 -1
  40. package/dist/route-resolver.d.ts +22 -1
  41. package/dist/route-resolver.d.ts.map +1 -1
  42. package/dist/route-resolver.js +1 -1
  43. package/dist/route-resolver.js.map +1 -1
  44. package/dist/scope-do.d.ts +5 -0
  45. package/dist/scope-do.d.ts.map +1 -1
  46. package/dist/scope-do.js +32 -10
  47. package/dist/scope-do.js.map +1 -1
  48. package/dist/scope-facets.d.ts +15 -4
  49. package/dist/scope-facets.d.ts.map +1 -1
  50. package/dist/scope-facets.js +66 -13
  51. package/dist/scope-facets.js.map +1 -1
  52. package/dist/scope-object.d.ts +28 -0
  53. package/dist/scope-object.d.ts.map +1 -0
  54. package/dist/scope-object.js +13 -0
  55. package/dist/scope-object.js.map +1 -0
  56. package/dist/scope-supervisor-do.d.ts +3 -1
  57. package/dist/scope-supervisor-do.d.ts.map +1 -1
  58. package/dist/scope-supervisor-do.js +24 -5
  59. package/dist/scope-supervisor-do.js.map +1 -1
  60. package/dist/supplied-pass-box.d.ts +16 -2
  61. package/dist/supplied-pass-box.d.ts.map +1 -1
  62. package/dist/supplied-pass-box.js +92 -28
  63. package/dist/supplied-pass-box.js.map +1 -1
  64. package/dist/tenant-due-index-do.d.ts +33 -0
  65. package/dist/tenant-due-index-do.d.ts.map +1 -1
  66. package/dist/tenant-due-index-do.js +47 -0
  67. package/dist/tenant-due-index-do.js.map +1 -1
  68. package/dist/tenant-due-work-do.d.ts +18 -0
  69. package/dist/tenant-due-work-do.d.ts.map +1 -1
  70. package/dist/tenant-due-work-do.js +21 -0
  71. package/dist/tenant-due-work-do.js.map +1 -1
  72. package/package.json +13 -12
package/dist/host.d.ts CHANGED
@@ -2,16 +2,1000 @@ import type { EntityGrantShape, RelayAnswer, SignedRelayProof } from '@substrat-
2
2
  import type { DueScheduleGate, LoadProjection, LoadRoleRepair, PurgeSweepMode, RoleJudge, TenantVerdict } from './scope-do.js';
3
3
  import { type SystemDoorMoved } from './system-door.js';
4
4
  import { type ExecutorRouteNotDue } from './executor-route.js';
5
- import { type WireFailure, type PushedImport, type ExportedBatch, type ExportReadInput, type ImportBatch, type ImportResult, type ImportState, type ManifestImports, type ManifestConnectionLandings, type ManifestConnectors, type ImportCursorMoveAt, type ImportCursorMoved, type AttachmentRecord, type UploadLinkView, type BlobStoreHandle, type ImpersonationSession, type ImpersonationSessionId, type ConnectionId, type ModuleId, type SystemSwitchOutcome, type SystemScheduleEntry, type PeerGrantsEntry, type EntityHistoryInput, type EventCauseInput, type EventEffectsInput, type EffectsTree, type InvocationEventsInput, type InvocationEvents, type DeadLettersInput, type DeadLetter, type LifecycleFlowInput, type LifecycleFlowResult, type OperationSeriesInput, type OperationSeriesResult, type CauseChain, type EventFacetInput, type EventFacetResult, type HistoryEntry, type Page, type SweepRunsPayload, type DomainEvent, type EntitlementGrant, type EntityRef, type ProjectedConnectionGrant, type ProjectedConnectionKey, type ProjectedIdentityLink, type PermissionKey, type PlatformActorId, type OnBehalfOf, type BecomeCapabilityInput, type BoundedBecomeMint, type BoundedBecomeRevoke, type BoundedUnbind, type BecomeLinkState, type PrincipalBecomeCapabilityInput, type PrincipalBindLinkInput, type BoundedBindLinkMint, type CapabilityExchangeOptions, type CapabilityExchange, type CapabilityId, type CapabilityFilter, type CapabilityPage, type CapabilityRecord, type MintedCapability, type PrincipalId, type ResolvedIdentity, type QueryScopeInput, type ReadScopeTableInput, type RoleDefinition, type Scope, type ScopeDumpInput, type ScopeDumpTable, type ScopeDumpChange, type ScopeDumpChanges, type ScopeDumpPage, type ScopeDumpPageTable, type ScopeDumpSample, type ScopeCopyEstimate, type ScopeLineage, type SubjectReadPage, type SubjectReadRequest, type ScopeId, type PlatformRequestEntry, type PlatformRequestFilter, type PlatformRequestId, type ScopeTable, type DenialFilter, type DenialSummary, type PermissionDenial, type RefusalFilter, type RefusalRecord, type ScopeQueryResult, type ScopeTablePage, type TenantId, type TenantStoreHandle, type ModuleObjectsRecord, type Coverage, type PeerCoverage, type PeerSwitchOutcome, type VerticalCaller, type LifecycleDelivery, type ScopeLifecycle, type StoredScopeLifecycle } from '@substrat-run/contracts';
5
+ import { type ErrorCode, type WireFailure, type PushedImport, type ExportedBatch, type ExportReadInput, type ImportBatch, type ImportResult, type ImportState, type ManifestImports, type ManifestConnectionLandings, type ManifestConnectors, type ImportCursorMoveAt, type ImportCursorMoved, type FindingEntry, type FindingFilter, type FindingRuleEntry, type FindingRuleInput, type FindingStatusInput, type AttachmentRecord, type UploadLinkView, type BlobStoreHandle, type DeploymentWireAuth, type ConnectLink, type ConnectLinkConsume, type ImpersonationSession, type ImpersonationSessionId, type ConnectionId, type ModuleId, type SystemSwitchOutcome, type SystemScheduleEntry, type PeerGrantsEntry, type AdminLogEntry, type OpsFailureEntry, type EntityHistoryInput, type EventCauseInput, type EventEffectsInput, type EffectsTree, type InvocationEventsInput, type InvocationEvents, type DeadLettersInput, type DeadLetter, type LifecycleFlowInput, type LifecycleFlowResult, type OperationSeriesInput, type OperationSeriesResult, type CauseChain, type EventFacetInput, type EventFacetResult, type HistoryEntry, type Page, type SweepRunEntry, type SweepRunsPayload, type DomainEvent, type EntitlementGrant, type EntityRef, type ListPage, type ScopeStorageSample, type StorageGauge, type RequestDay, type RequestRollupDay, type CostDay, type MeterDay, type MeterDayTake, type StaleScope, type StaleScopeTake, type VerticalOwnerPeriod, type ProjectedConnectionGrant, type ProjectedConnectionKey, type ProjectedIdentityLink, type PermissionKey, type PlatformActorId, type OnBehalfOf, type BecomeCapabilityInput, type BoundedBecomeMint, type BoundedBecomeRevoke, type BoundedUnbind, type BecomeLinkState, type PrincipalBecomeCapabilityInput, type PrincipalBindLinkInput, type BoundedBindLinkMint, type CapabilityExchangeOptions, type CapabilityExchange, type CapabilityId, type CapabilityFilter, type CapabilityPage, type CapabilityRecord, type MintedCapability, type PrincipalId, type ResolvedIdentity, type QueryScopeInput, type ReadScopeTableInput, type RoleDefinition, type Scope, type DirectoryCopyByReference, type DirectoryDumpPage, type ScopeDumpInput, type ScopeDumpTable, type ScopeDumpChange, type ScopeDumpChanges, type ScopeDumpPage, type ScopeDumpPageTable, type ScopeDumpSample, type ScopeCopyEstimate, type ScopeLineage, type DependentErasure, type OwedDependentErasure, type SubjectReadPage, type SubjectReadRequest, type ScopeId, type PlatformRequestEntry, type PlatformRequestFilter, type PlatformRequestId, type ScopeStatus, type ScopeTable, type DenialFilter, type DenialSummary, type PermissionDenial, type RefusalFilter, type RefusalRecord, type ScopeQueryResult, type ScopeTablePage, type Tenant, type TenantId, type TenantStatus, type TenantStoreHandle, type ModuleObjectsRecord, type AppEnvironment, type EnvironmentServing, type EnvironmentServeAcknowledgement, type EnvironmentEffects, type ConnectionReach, type Coverage, type PeerCoverage, type PeerSwitchOutcome, type VerticalCaller, type VerticalResolution, type DeclaredMigration, type LifecycleDelivery, type ScopeLifecycle, type StoredScopeLifecycle } from '@substrat-run/contracts';
6
6
  import { type ContainerPassDoorDeps, type ContainerPassLauncher, type DetachedPassTicket, type SystemAttachments } from '@substrat-run/kernel';
7
- import { type RedeemedUploadLink, type UploadLinkInspection, type UploadLinkRedeemInput, type ChildScopeCaller, type CarriedAway, type KeptCopy, type LoadMarker, type AppliedMigration, type BlobStoreProvisionInput, type ScopeAttachments, type AttachmentUploadInput, type OpenedAttachment, type OpenedAttachmentStream, type AttachmentOpenOptions, type ExecutorDeadLetter, type ExecutorDrainReport, type ExecutorHandler, type ExecutorRetryPolicy, type MigrateScopeOutcome, type MigrationFrontier, type ConnectorHandler, type ConnectorOptions, type FetchLike, type SecretBox, type HostAdmin, type ModuleRegistration, type OperationHandler, type PermissionChecker, type ProvisionScopeInput, type ScheduleRegistration, type ScheduleRunReport, type ScheduleTick, type ScheduleStateKind, type ScopeHost, type ScopeStub, type PersonScopeOptions, type ScopeStubOptions, type InvokeOptions, type TenantRelationalStore, type TenantStoreProvisionInput, type FreshnessRegistration, type FreshnessReport, type AttachmentExtractor, type AttachmentTextBackfillBatch, type AttachmentTextBounds, type AttachmentTextRecheckPage, type ExtractionOutcome, type JobDriveReport, type JobDueKey, type JobHandler, type JobRun, type JobRunClaim, type JobRunFilter, type JobRunPatch, type JobRunScope, type JobRunRow, type JobStepRow, type StartJobRunInput, type LiveReadSurface, type SubjectRedactionCounts, type LegacySubjectRedactionCounts, type PlatformRequestRawRow, type UndrainedEvents, type UndrainedRead, type OutboxSubscriber, type SwitchOutcome, type SwitchedOff, type RecordedOffCarry, type SwitchCarryWire, type SystemScheduleState, type PeerGrantsRow, type SystemGrantsEntry, type ConnectorCallRecorder, type ScopeRoleHolder, type RelayScopeDoors, type Holdings, type ScopeDelegation, type DumpTable, type RoleState, type DeclaredPermissions, type PurgePass } from '@substrat-run/kernel';
7
+ import { type SupersedeMajor } from '@substrat-run/kernel';
8
+ import type { DirectoryLakeBackfillPage, DirectoryLakeCaptureResult, DirectoryLakeCaptureState, DirectoryLakeDataset, DirectoryLakePruneRefusal, DirectoryLakeRow } from '@substrat-run/kernel';
9
+ import { type MarkupScheduleRecord } from '@substrat-run/kernel';
10
+ import { type RedeemedUploadLink, type UploadLinkInspection, type UploadLinkRedeemInput, type ChildScopeCaller, type CarriedAway, type KeptCopy, type LoadMarker, type AuditedOperationRef, type AuditedOperationRow, type TelemetryPruneReport, type AppliedMigration, type BuildUsageInput, type TenantBuildUsageFilter, type TenantBuildUsageRow, type TenantModelUsageMeterFilter, type TenantModelUsageMeterRow, type BlobStoreProvisionInput, type ScopeAttachments, type AttachmentUploadInput, type OpenedAttachment, type OpenedAttachmentStream, type AttachmentOpenOptions, type ExecutorDeadLetter, type ExecutorDrainReport, type ExecutorHandler, type MembershipChange, type MembershipChangeResult, type ExecutorRetryPolicy, type MigrateScopeOutcome, type MigrationFrontier, type SecretBoxCanaryMode, type ImpersonationRow, type ConnectorHandler, type ConnectorOptions, type FetchLike, type SecretBox, type HostAdmin, type ModuleRegistration, type OperationHandler, type PermissionChecker, type ProvisionScopeInput, type ScheduleRegistration, type ScheduleRunReport, type ScheduleTick, type ScheduleStateKind, type ScopeHost, type ScopeStub, type PersonScopeOptions, type ScopeStubOptions, type InvokeOptions, type TenantRelationalStore, type TenantStoreProvisionInput, type FreshnessRegistration, type FreshnessReport, type AttachmentExtractor, type AttachmentTextBackfillBatch, type AttachmentTextBounds, type AttachmentTextRecheckPage, type ExtractionOutcome, type JobDriveReport, type JobDueKey, type JobHandler, type JobRun, type JobRunClaim, type JobRunFilter, type JobRunPatch, type JobRunScope, type JobRunRow, type JobStepRow, type StartJobRunInput, type LiveReadSurface, type SubjectRedactionCounts, type LegacySubjectRedactionCounts, type SubjectTextTarget, type PlatformRequestRawRow, type UndrainedEvents, type UndrainedRead, type OutboxSubscriber, type SwitchOutcome, type SwitchedOff, type SystemSwitchRecordFilter, type SystemSwitchRecordRow, type SwitchKind, type SwitchRecordPrior, type SwitchRecordWrite, type RecordedOffCarry, type SwitchCarryWire, type SystemScheduleState, type PeerGrantsRow, type SystemGrantsEntry, type ServedFrom, type ExpectedServing, type InstallsReconciled, type ServingPointer, type ConnectorCallRecorder, type ScopeRoleHolder, type RelayScopeDoors, type Holdings, type ScopeDelegation, type DumpTable, type RoleState, type DeclaredPermissions, type PurgePass, type FindingChange, type FindingPruneReport, type ConnectLinkKeyRow, type ScopeStorageAttempt, type ScopeStorageFilter, type ScopeStorageReadingInput, type RequestDayFilter, type RequestDayReadInput, type RequestRollupDayFilter, type CostDayFilter, type CostDayTotals, type CostDayTotalsFilter, type CostDayReadInput, type CostContainersInput, type CostContainersResult, type CostRollupDayFilter, type ScopeObjectReadInput, type ScopeObjectTarget, type TenantRequestMeterRow, type RequestMeterDayRow, type MeterDayFilter, type MeterDayTakeFilter, type MeterDayTakeInput, type StaleScopeFilter, type StaleScopeTakeFilter, type StaleScopeTakeInput, type StaleScopeTakeResult, type MeterDayTakeResult } from '@substrat-run/kernel';
8
11
  import { type OrphanSweepReport, type OrphanSweepRequest } from '@substrat-run/kernel';
9
- import { type CopyRestoreFence } from '@substrat-run/kernel';
12
+ import { type CopyRestoreFence, type ScopeCopyMoveConfirmation, type SubjectErasureFence, type VerticalScopeStore, type DeploymentWireAuthFilter, type ScopeCopyBackfillResult, type ScopeCopyRole, type ScopeScriptCopyRow } from '@substrat-run/kernel';
10
13
  import { type ScopeStoreHostOptions, type ScopeStoreStubOptions, type StoreErasureReplay, type StoreStub } from '@substrat-run/kernel';
11
14
  import type { PlatformRequestSettle, ShapeCursor } from '@substrat-run/kernel';
15
+ import type { StoreDriverApprovalRecord, StoreDriverHoldMode, StoreDriverRebuildFailure, StoreDriverRebuildRecord, StoreDriverReleaseRecord, StoreDriverRevokeWalkRecord, StoreDriverRolloutAction, StoreDriverRolloutRecord, StoreDriverRolloutState, StoreDriverRolloutTarget, StoreDriverState } from '@substrat-run/kernel';
12
16
  import { type D1TenantStores } from './d1.js';
13
17
  import { type R2BlobStores } from './r2.js';
18
+ import type { AccessLogRow, AuditLogQuery, IssueQuery, OpsFailureQuery, SweepRunQuery, SweepRunRow, OpsFailureRow, ModelUsageQuery, ModelUsageRow, ChannelHistoryRow, ChannelRow, ConnectionDoRow, ConnectionGrantDoRow, EntitlementRow, HostnameRow, MemberTupleRow, OrgRow, RoleRow, RouteRow, ScopeRow, VerticalRow, VersionRow, VersionListRow, LifecycleTargetRow, RepliedMethod } from './control-plane-do.js';
14
19
  import { type DoReply } from './do-reply.js';
20
+ export interface ControlPlaneStub {
21
+ /** #113: one of `REPLIED_METHODS`, its refusal answered as data (`ControlPlaneDO.reply`). */
22
+ reply<M extends RepliedMethod>(method: M, args: Parameters<ControlPlaneStub[M]>): Promise<DoReply<Awaited<ReturnType<ControlPlaneStub[M]>>>>;
23
+ /** #1713: hosted scopes and their directory lifecycle (`ControlPlaneDO.lifecycleTargets`). */
24
+ lifecycleTargets(filter: {
25
+ tenantId?: string;
26
+ scopeId?: string;
27
+ drift?: boolean;
28
+ unrecorded?: boolean;
29
+ limit?: number;
30
+ }): Promise<LifecycleTargetRow[]>;
31
+ /** #1713: what a scope's deployment acknowledged holding; K-69 (#3540): and which deployment that was. */
32
+ recordLifecycleReceipt(scopeId: string, delivered: string, at: string, tenantRecorded?: boolean, deployment?: string | null): Promise<void>;
33
+ /** #2016: note the heal's tenant-record asks, success or failure, so the walk rotates. */
34
+ recordTenantAsks(scopeIds: string[], at: string): Promise<void>;
35
+ /** #3119: count a failed delivery; `news` says whether it earns an ops-failure row. */
36
+ recordLifecycleFailure(scopeId: string, wanted: string, deployment: string, error: string, at: string): Promise<{
37
+ failures: number;
38
+ news: boolean;
39
+ retryAt: string;
40
+ }>;
41
+ /** #1713: raise the directory's epoch to at least this; answers the epoch now. */
42
+ raiseLifecycleEpoch(atLeast: number): Promise<number>;
43
+ createTenant(id: string, slug: string, name: string, createdAt: string, provisionedByTenant: string | null, audit: AdminEntry): Promise<Tenant | null>;
44
+ setTenantStatus(tenantId: string, status: TenantStatus, audit: AdminEntry): Promise<string>;
45
+ setTenantName(tenantId: string, name: string, audit: AdminEntry): Promise<string>;
46
+ reapTenant(tenantId: string, audit: AdminEntry, deletingBy?: string): Promise<string>;
47
+ getTenant(tenantId: string): Promise<Tenant | undefined>;
48
+ listTenants(page?: ListPage): Promise<Tenant[]>;
49
+ getTenantStore(tenantId: string, vertical: string, binding: string): Promise<{
50
+ kind: string;
51
+ ref: string;
52
+ } | undefined>;
53
+ putTenantStore(row: {
54
+ tenantId: string;
55
+ vertical: string;
56
+ binding: string;
57
+ kind: string;
58
+ ref: string;
59
+ createdAt: string;
60
+ }, audit?: AdminEntry): Promise<{
61
+ kind: string;
62
+ ref: string;
63
+ }>;
64
+ listTenantStores(filter: {
65
+ tenantId?: string;
66
+ vertical?: string;
67
+ }): Promise<{
68
+ tenant_id: string;
69
+ vertical: string;
70
+ binding: string;
71
+ driver: string;
72
+ ref: string;
73
+ created_at: string;
74
+ }[]>;
75
+ recordStoreDriverRelease(input: {
76
+ driver: string;
77
+ sha256: string;
78
+ sourceCommit: string;
79
+ actor: string;
80
+ at: string;
81
+ }, audit?: AdminEntry): Promise<{
82
+ record: StoreDriverReleaseRecord;
83
+ created: boolean;
84
+ }>;
85
+ getStoreDriverRelease(driver: string, sha256: string): Promise<StoreDriverReleaseRecord | undefined>;
86
+ storeDriverApprovals(driver: string): Promise<StoreDriverApprovalRecord[]>;
87
+ liveStoreDriverApproval(driver: string, sha256: string): Promise<StoreDriverApprovalRecord | undefined>;
88
+ approveStoreDriverReleaseAndAudit(input: {
89
+ driver: string;
90
+ sha256: string;
91
+ reason: string;
92
+ sourceReferences: StoreDriverApprovalRecord['sourceReferences'];
93
+ isolationReview: StoreDriverApprovalRecord['isolationReview'];
94
+ schema: number;
95
+ foundation?: number;
96
+ className: string;
97
+ operations: readonly string[];
98
+ actor: string;
99
+ at: string;
100
+ }, audit: AdminEntry): Promise<StoreDriverApprovalRecord>;
101
+ storeDriverRevokeWalk(approvalId: string): Promise<StoreDriverRevokeWalkRecord | undefined>;
102
+ recordStoreDriverRevokeWalk(input: {
103
+ approvalId: string;
104
+ driver: string;
105
+ holder: string;
106
+ cursor: string | null;
107
+ actor: string;
108
+ reason: string;
109
+ rolloutSeq: number;
110
+ }): Promise<StoreDriverRevokeWalkRecord>;
111
+ revokeStoreDriverReleaseAndAudit(input: {
112
+ approvalId: string;
113
+ driver: string;
114
+ sha256: string;
115
+ holder: string;
116
+ actor: string;
117
+ at: string;
118
+ reason: string;
119
+ emergency: boolean;
120
+ }, audit: AdminEntry): Promise<StoreDriverApprovalRecord>;
121
+ storeDriverState(driver: string): Promise<StoreDriverState>;
122
+ storeDriverDeclarations(driver: string): Promise<{
123
+ verticals: {
124
+ vertical: string;
125
+ stores: VerticalScopeStore[];
126
+ }[];
127
+ unreadable: string[];
128
+ }>;
129
+ storeDriverRolloutPending(input: {
130
+ driver: string;
131
+ sha256: string;
132
+ action: StoreDriverRolloutAction;
133
+ limit: number;
134
+ }): Promise<{
135
+ verticals: StoreDriverRolloutTarget[];
136
+ pending: number;
137
+ walked: number;
138
+ unreadable: string[];
139
+ }>;
140
+ storeDriverRolloutWalked(input: {
141
+ driver: string;
142
+ seq: number;
143
+ limit: number;
144
+ }): Promise<{
145
+ verticals: StoreDriverRolloutTarget[];
146
+ walked: number;
147
+ }>;
148
+ holdStoreDriver(input: {
149
+ driver: string;
150
+ holder: string;
151
+ mode: StoreDriverHoldMode;
152
+ ttlMs: number;
153
+ renew?: boolean;
154
+ rolloutSeq?: number;
155
+ }): Promise<boolean>;
156
+ releaseStoreDriverHold(input: {
157
+ driver: string;
158
+ holder: string;
159
+ }): Promise<void>;
160
+ beginStoreDriverRollout(input: {
161
+ driver: string;
162
+ sha256: string;
163
+ action: StoreDriverRolloutAction;
164
+ holder: string;
165
+ actor: string;
166
+ at: string;
167
+ }, audit?: AdminEntry): Promise<StoreDriverRolloutRecord>;
168
+ finishStoreDriverRollout(input: {
169
+ driver: string;
170
+ seq: number;
171
+ holder: string;
172
+ state: Exclude<StoreDriverRolloutState, 'rolling'>;
173
+ detail: string | null;
174
+ walked?: readonly StoreDriverRolloutTarget[];
175
+ at: string;
176
+ }, audit?: AdminEntry): Promise<StoreDriverRolloutRecord>;
177
+ storeDriverRebuild(driver: string): Promise<StoreDriverRebuildRecord | undefined>;
178
+ claimStoreDriverRebuild(input: {
179
+ driver: string;
180
+ fingerprint: string;
181
+ holder: string;
182
+ ttlMs: number;
183
+ at: string;
184
+ restart?: boolean;
185
+ attestedBy?: string;
186
+ }): Promise<StoreDriverRebuildRecord | null>;
187
+ advanceStoreDriverRebuild(input: {
188
+ driver: string;
189
+ fingerprint: string;
190
+ holder: string;
191
+ cursor: string | null;
192
+ failures: readonly StoreDriverRebuildFailure[];
193
+ done: boolean;
194
+ verified?: boolean;
195
+ ttlMs: number;
196
+ release?: boolean;
197
+ at: string;
198
+ }): Promise<StoreDriverRebuildRecord>;
199
+ getBlobStore(tenantId: string, vertical: string, binding: string): Promise<{
200
+ kind: string;
201
+ ref: string;
202
+ } | undefined>;
203
+ putBlobStore(row: {
204
+ tenantId: string;
205
+ vertical: string;
206
+ binding: string;
207
+ kind: string;
208
+ ref: string;
209
+ createdAt: string;
210
+ }, audit?: AdminEntry): Promise<{
211
+ kind: string;
212
+ ref: string;
213
+ }>;
214
+ listBlobStores(filter: {
215
+ tenantId?: string;
216
+ vertical?: string;
217
+ }): Promise<{
218
+ tenant_id: string;
219
+ vertical: string;
220
+ binding: string;
221
+ kind: string;
222
+ ref: string;
223
+ created_at: string;
224
+ }[]>;
225
+ provisionScope(tenantId: string, scopeId: string, record: {
226
+ slug: string;
227
+ kind: string;
228
+ name: string;
229
+ vertical: string | null;
230
+ storageShape: string;
231
+ jurisdiction: string | null;
232
+ /** #2993: the declared type, NULL for 'home'; absent from a host with no declared types. */
233
+ scopeType?: string | null;
234
+ /** #2995: the parent a provision-child names, fixed and judged again in the write's unit. */
235
+ parentScopeId?: string;
236
+ /**
237
+ * #3625: an install (`true`), refused in the write's unit while the app has a home scope in the
238
+ * tenant. #2993: `'sibling'`, a sibling of an app that declares scope types, refused the same way.
239
+ */
240
+ claimsHome?: boolean | 'sibling';
241
+ }, createdAt: string): Promise<boolean>;
242
+ setMigrationState(scopeId: string, schemaVersion: string, failure: {
243
+ version: string;
244
+ error: string;
245
+ } | null): Promise<void>;
246
+ listScopes(filter: {
247
+ tenantId?: string;
248
+ status?: string[];
249
+ vertical?: string;
250
+ parentScopeId?: string;
251
+ } & ListPage): Promise<ScopeRow[]>;
252
+ getScopeRecord(tenantId: string, scopeId: string): Promise<ScopeRow | undefined>;
253
+ /** #2178: `PROVISIONED_VERSIONS_SQL` — the versions the scopes a promote or a serve moves last reconciled. */
254
+ provisionedVersionsOf(vertical: string, serving: ServingPointer | null, ownerTenant: string | null): Promise<InstallsReconciled[]>;
255
+ /** #2993 part 4: the types other than `home` the vertical's unreaped scopes hold. */
256
+ scopeTypesHeldBy(vertical: string, servingRef?: string): Promise<string[]>;
257
+ /** The getScope gate's refusal as data, null when access is allowed (#1718). */
258
+ scopeAccessRefusal(tenantId: string, scopeId: string): Promise<{
259
+ code: ErrorCode | null;
260
+ message: string;
261
+ reason?: string;
262
+ } | null | undefined>;
263
+ /** A scope lifecycle transition, its refusal answered as data (#1718). */
264
+ transitionScopeOrRefusal(tenantId: string, scopeId: string, from: string[], to: ScopeStatus, action: string): Promise<{
265
+ ok: true;
266
+ status: string;
267
+ vertical: string | null;
268
+ } | {
269
+ ok: false;
270
+ code: ErrorCode | null;
271
+ message: string;
272
+ }>;
273
+ /** #2995: archive a scope and its children in one unit; a refused parent archives none. */
274
+ archiveScopeFamilyOrRefusal(tenantId: string, scopeId: string, from: string[], action: string): Promise<{
275
+ ok: true;
276
+ status: string;
277
+ vertical: string | null;
278
+ children: {
279
+ scopeId: string;
280
+ status: string;
281
+ vertical: string | null;
282
+ }[];
283
+ } | {
284
+ ok: false;
285
+ code: ErrorCode | null;
286
+ message: string;
287
+ }>;
288
+ /** #2995: a scope's children in the given statuses, oldest first. */
289
+ childScopeIds(tenantId: string, parentScopeId: string, statuses: string[]): Promise<string[]>;
290
+ /** Kept for a coordinator from before #2447: the previous role, or null; a refusal is thrown. */
291
+ defineRole(tenantId: string, role: RoleDefinition): Promise<RoleDefinition | null>;
292
+ /** #2447: judged in the unit against `reservation` and the tenant's other roles; a refusal writes nothing. */
293
+ defineRoleOrRefusal(tenantId: string, role: RoleDefinition, reservation: {
294
+ reserved: string[];
295
+ declared: string[];
296
+ }, seatedInScopes: boolean, audit: AdminEntry): Promise<{
297
+ before: RoleDefinition | null;
298
+ } | {
299
+ refused: string;
300
+ }>;
301
+ listRoles(filter: {
302
+ tenantId?: string;
303
+ source?: string;
304
+ } & ListPage): Promise<RoleRow[]>;
305
+ getRole(tenantId: string, key: string): Promise<RoleDefinition | undefined>;
306
+ /** #2526: a tenant tuple and its admin row, in one unit. */
307
+ writeTenantTuple(tenantId: string, subject: string, relation: string, object: string, expiresAt: string | null, audit: AdminEntry): Promise<void>;
308
+ /** #2526: `assignRole` at the tenant node — the reservation judged, the tuple and its row. */
309
+ assignTenantRole(tenantId: string, principal: string, roleKey: string, reserved: string[], audit: AdminEntry): Promise<{
310
+ refused?: string;
311
+ }>;
312
+ /** #2526: a tenant tuple naming an org and its row, refused `not_found` without the org. */
313
+ writeOrgTenantTuple(tenantId: string, orgId: string, subject: string, relation: string, object: string, expiresAt: string | null, audit: AdminEntry): Promise<void>;
314
+ /** #1743: a tenant-level `system:` grant — answers the switched-off scopes; empty = written, with its row (#2526). */
315
+ writeTenantSystemGrant(tenantId: string, moduleId: string, relation: string, expiresAt: string | null, audit: AdminEntry): Promise<string[]>;
316
+ /** All of a tenant's identity links — for identity-link projection (#406). */
317
+ dumpTenantIdentities(tenantId: string): Promise<{
318
+ provider: string;
319
+ external_id: string;
320
+ principal_id: string;
321
+ scope_id: string | null;
322
+ }[]>;
323
+ /** All of a tenant's tenant-level tuples (incl tombstones) — for scope-local projection. */
324
+ dumpTenantTuples(tenantId: string): Promise<{
325
+ subject: string;
326
+ relation: string;
327
+ object: string;
328
+ expires_at: string | null;
329
+ revoked_at: string | null;
330
+ }[]>;
331
+ readRoute(hostname: string): Promise<RouteRow | undefined>;
332
+ /** #1706: "vertical Y in tenant T", by the kernel's one rule — see `HostAdmin.resolveVerticalInstance`. */
333
+ resolveVerticalInstance(tenantId: string, vertical: string): Promise<VerticalResolution>;
334
+ resolvePeerInstance(tenantId: string, callerScopeId: string, vertical: string): Promise<unknown>;
335
+ peerBinding(tenantId: string, callerScopeId: string, vertical: string): Promise<{
336
+ target_scope_id: string;
337
+ invalidated: number;
338
+ } | undefined>;
339
+ peerBindings(tenantId: string, callerScopeId: string): Promise<{
340
+ vertical: string;
341
+ target_scope_id: string;
342
+ invalidated: number;
343
+ }[]>;
344
+ setPeerBinding(tenantId: string, callerScopeId: string, vertical: string, targetScopeId: string | null): Promise<{
345
+ ok: true;
346
+ changed: boolean;
347
+ previous: string | null;
348
+ } | {
349
+ ok: false;
350
+ code: 'not_found';
351
+ message: string;
352
+ }>;
353
+ /** #3625 (K-64): the home scope of (tenant, app, environment), or null (kernel `homeScopeIn`). */
354
+ homeScopeOf(tenantId: string, vertical: string, environment?: string): Promise<string | null>;
355
+ /** D-83 (#3530 step 3): an app's environments, production first. */
356
+ listEnvironments(tenantId: string, vertical: string): Promise<AppEnvironment[]>;
357
+ /** Called through `reply`, so a refusal keeps its code. */
358
+ defineEnvironmentAndAudit(input: {
359
+ tenantId: string;
360
+ vertical: string;
361
+ name: string;
362
+ }, by: string, audit: AdminEntry): Promise<{
363
+ environment: AppEnvironment;
364
+ created: boolean;
365
+ }>;
366
+ removeEnvironmentAndAudit(input: {
367
+ tenantId: string;
368
+ vertical: string;
369
+ name: string;
370
+ }, audit: AdminEntry): Promise<{
371
+ removed: boolean;
372
+ }>;
373
+ /** #3530 step 4; called through `reply`. False when the record moved since `expected`. */
374
+ setEnvironmentServingAndAudit(input: {
375
+ tenantId: string;
376
+ vertical: string;
377
+ name: string;
378
+ }, next: EnvironmentServing, expected: EnvironmentServing | null, audit: AdminEntry, claim?: string, acknowledge?: EnvironmentServeAcknowledgement): Promise<boolean>;
379
+ /** #3530 step 4: an environment's serve lease; called through `reply`. */
380
+ claimEnvironmentServe(input: {
381
+ tenantId: string;
382
+ vertical: string;
383
+ name: string;
384
+ }, claim: string, leaseMs: number): Promise<boolean>;
385
+ releaseEnvironmentServe(input: {
386
+ tenantId: string;
387
+ vertical: string;
388
+ name: string;
389
+ }, claim: string): Promise<void>;
390
+ /** #3530 step 6: an environment given connections of its own; called through `reply`. */
391
+ setEnvironmentEffectsAndAudit(input: {
392
+ tenantId: string;
393
+ vertical: string;
394
+ name: string;
395
+ }, effects: EnvironmentEffects, audit: AdminEntry): Promise<{
396
+ changed: boolean;
397
+ before: EnvironmentEffects;
398
+ }>;
399
+ /** #3530 step 6: which connections the scope's effects may go through. */
400
+ connectionReach(tenantId: string, scopeId: string): Promise<ConnectionReach>;
401
+ /** #2526: the guard, the demotion, the bind and its row, one unit; called through `reply`. */
402
+ bindHostnameInDirectory(h: {
403
+ hostname: string;
404
+ tenantId: string;
405
+ scopeId: string;
406
+ surface: string;
407
+ region: string | null;
408
+ canonical: boolean;
409
+ createdAt: string;
410
+ }, audit: AdminEntry): Promise<void>;
411
+ setHostnameStatus(hostname: string, status: string, note: string | null, audit?: AdminEntry): Promise<boolean>;
412
+ setHostnameIssuance(hostname: string, fields: {
413
+ status: string;
414
+ note: string | null;
415
+ customHostnameId?: string | null;
416
+ validationRecords: string | null;
417
+ }, audit?: AdminEntry): Promise<boolean>;
418
+ deleteHostname(hostname: string, owner?: {
419
+ tenantId: string;
420
+ scopeId: string;
421
+ }, audit?: AdminEntry): Promise<{
422
+ tenant_id: string;
423
+ scope_id: string;
424
+ status: string;
425
+ } | null>;
426
+ listHostnames(filter: {
427
+ tenantId?: string;
428
+ scopeId?: string;
429
+ status?: string;
430
+ verticalSlug?: string;
431
+ } & ListPage): Promise<HostnameRow[]>;
432
+ readVertical(slug: string): Promise<VerticalRow | undefined>;
433
+ insertVertical(slug: string, name: string, source: string, ownerTenant: string | null, envSpec: string | null, installSpec: string | null, listed: number, createdAt: string, audit: AdminEntry): Promise<void>;
434
+ /** #2501: every period of a slug's ownership, oldest first. */
435
+ listVerticalOwners(slug: string): Promise<VerticalOwnerPeriod[]>;
436
+ updateVerticalManifestMeta(slug: string, envSpec: string | null, installSpec: string | null, listed?: number | null): Promise<void>;
437
+ updateVerticalListed(slug: string, listed: number, audit: AdminEntry): Promise<void>;
438
+ updateVerticalPublishRequest(slug: string, requestedAt: string, audit: AdminEntry): Promise<void>;
439
+ updateVerticalInstallsBlocked(slug: string, blocked: number, audit: AdminEntry): Promise<void>;
440
+ updateVerticalTenantProvisioner(slug: string, granted: number, audit: AdminEntry): Promise<void>;
441
+ updateVerticalEmailSender(slug: string, granted: number, audit: AdminEntry): Promise<void>;
442
+ updateVerticalTraceSampling(slug: string, serving: number, previews: number, audit: AdminEntry): Promise<void>;
443
+ deleteVertical(slug: string, audit: AdminEntry, until?: string): Promise<void>;
444
+ listVerticals(page?: ListPage): Promise<VerticalRow[]>;
445
+ readVersion(id: string): Promise<VersionRow | undefined>;
446
+ insertVersion(v: {
447
+ id: string;
448
+ verticalSlug: string;
449
+ version: string;
450
+ manifestDigest: string;
451
+ permissionDigest: string;
452
+ migrationDigest: string;
453
+ deploymentRef: string | null;
454
+ admission: string;
455
+ admissionNote: string | null;
456
+ manifestJson: string | null;
457
+ originJson: string | null;
458
+ migrations: DeclaredMigration[] | null;
459
+ bundleDigest?: string | null;
460
+ createdAt: string;
461
+ }, audit: AdminEntry): Promise<void>;
462
+ verticalScopeStores(slug: string): Promise<VerticalScopeStore[]>;
463
+ readVersionMigrations(id: string): Promise<{
464
+ verticalSlug: string;
465
+ migrations: DeclaredMigration[] | null;
466
+ } | undefined>;
467
+ listVersions(verticalSlug: string, page?: ListPage): Promise<VersionListRow[]>;
468
+ /** #2528: judged in the DO's unit, which fills the row's `before` and `after`. */
469
+ admitVersion(id: string, audit: AdminEntry): Promise<void>;
470
+ rejectVersion(id: string, note: string, audit: AdminEntry): Promise<void>;
471
+ bindScopeVersion(scopeId: string, versionId: string, verticalSlug: string, expectedVersionId?: string | null, expectedErasureEpoch?: number, confirmMove?: ScopeCopyMoveConfirmation, servingRef?: string, expectedServing?: ExpectedServing, audit?: AdminEntry, environmentAcknowledge?: EnvironmentServeAcknowledgement): Promise<boolean>;
472
+ /** #3638: the same bind, called through `reply`, so a named environment's checkpoint refusal arrives typed. */
473
+ bindScopeVersionJudged(scopeId: string, versionId: string, verticalSlug: string, expectedVersionId?: string | null, expectedErasureEpoch?: number, confirmMove?: ScopeCopyMoveConfirmation, servingRef?: string, expectedServing?: ExpectedServing, audit?: AdminEntry, environmentAcknowledge?: EnvironmentServeAcknowledgement): Promise<boolean>;
474
+ servesNow(expected: ExpectedServing): Promise<boolean>;
475
+ scopeErasureEpoch(tenantId: string, scopeId: string): Promise<number>;
476
+ recordDependentErasures(tenantId: string, subjectId: string, outcomes: readonly DependentErasure[], audit: AdminEntry): Promise<void>;
477
+ dueDependentErasures(now: string, limit: number): Promise<OwedDependentErasure[]>;
478
+ holdDependentErasures(tenantId: string, subjectId: string, dependents: readonly {
479
+ vertical: string;
480
+ scopeId: string;
481
+ }[]): Promise<void>;
482
+ claimSubjectErasure(tenantId: string, scopeId: string, fence: SubjectErasureFence): Promise<boolean>;
483
+ recordScopeScriptCopy(tenantId: string, scopeId: string, scriptRef: string, moveId: string, role?: ScopeCopyRole | null, loadStamp?: string | null, leaseMs?: number): Promise<'recorded' | 'reaping' | 'missing' | 'invalid'>;
484
+ backfillScopeScriptCopy(tenantId: string, scopeId: string, scriptRef: string, audit: AdminEntry): Promise<ScopeCopyBackfillResult>;
485
+ claimExpiredScopeScriptCopies(input: {
486
+ now: string;
487
+ leaseUntil: string;
488
+ owner: string;
489
+ limit: number;
490
+ tenantId?: string;
491
+ scopeId?: string;
492
+ }): Promise<ScopeScriptCopyRow[]>;
493
+ beginScopeScriptReap(tenantId: string, scopeId: string, expiredBy?: string): Promise<'claimed' | 'pending' | 'missing' | 'not-due'>;
494
+ markScopeStoresFenced(tenantId: string, scopeId: string, whileTenantDeleting: boolean, audit: AdminEntry, deadlines?: {
495
+ archivedBy?: string;
496
+ deletingBy?: string;
497
+ }): Promise<void>;
498
+ scopeStoresFencedAt(tenantId: string, scopeId: string): Promise<string | null>;
499
+ settleScopeScriptCopy(tenantId: string, scopeId: string, scriptRef: string, moveId: string, state: string, loadStamp: string | null, revision: string | null, claimedBy?: string): Promise<boolean>;
500
+ touchScopeScriptCopy(tenantId: string, scopeId: string, scriptRef: string, moveId: string): Promise<void>;
501
+ renewScopeScriptCopy(tenantId: string, scopeId: string, moveId: string, leaseMs?: number): Promise<{
502
+ renewedAt: number;
503
+ leaseUntil: string;
504
+ } | null>;
505
+ listScopeScriptCopies(filter: {
506
+ tenantId?: string;
507
+ scopeId?: string;
508
+ state?: string;
509
+ limit?: number;
510
+ after?: {
511
+ scriptRef: string;
512
+ moveId: string;
513
+ };
514
+ }): Promise<ScopeScriptCopyRow[]>;
515
+ markScopeProvisioned(scopeId: string, versionId: string | null, retirementsFinished?: boolean, boundShapes?: string[], audit?: AdminEntry): Promise<void>;
516
+ setVerticalServing(slug: string, s: {
517
+ ref: string;
518
+ versionId: string;
519
+ doClassesJson: string;
520
+ migrationTag: string;
521
+ }, audit: AdminEntry, expected?: ServedFrom, supersede?: SupersedeMajor): Promise<boolean>;
522
+ setEarlierMajorServing(slug: string, major: number, s: {
523
+ ref: string;
524
+ versionId: string;
525
+ doClasses: string[];
526
+ migrationTag: string;
527
+ }, expected: {
528
+ versionId: string;
529
+ doClasses: string[];
530
+ migrationTag: string;
531
+ }, audit: AdminEntry): Promise<boolean>;
532
+ readMigrationsExtracted(id: string): Promise<{
533
+ verticalSlug: string;
534
+ digest: string | null;
535
+ } | undefined>;
536
+ recordMigrationsExtracted(id: string, digest: string, audit: AdminEntry): Promise<void>;
537
+ recordWireAuth(row: DeploymentWireAuth, audit: AdminEntry): Promise<boolean>;
538
+ listWireAuth(filter: DeploymentWireAuthFilter): Promise<DeploymentWireAuth[]>;
539
+ setScopeServingRef(scopeId: string, servingRef: string | null, expectedErasureEpoch?: number, confirmMove?: ScopeCopyMoveConfirmation, audit?: AdminEntry): Promise<boolean>;
540
+ setScopeExpiresAt(scopeId: string, expiresAt: string | null, audit: AdminEntry): Promise<boolean>;
541
+ keepAlivePendingScopeCopy(tenantId: string, scopeId: string, moveId: string, status: string, expectedExpiresAt: string | null, expiresAt: string | null, audit: AdminEntry): Promise<boolean>;
542
+ /** #2555: `onlyWhile` removes the scope only if still in that status, judged in the DO's unit. */
543
+ deleteScopeDirectory(scopeId: string, onlyWhile?: 'provisioning'): Promise<boolean | void>;
544
+ readChannel(verticalSlug: string, channel: string): Promise<ChannelRow | undefined>;
545
+ promoteChannel(from: string | null, history: ChannelHistoryRow, unlistedOnly: boolean, audit: AdminEntry,
546
+ /** #3539: the K-65 refusal this promote earns if the vertical is listed, judged in the unit. */
547
+ breakingWithinMajor?: string | null): Promise<boolean>;
548
+ recordEarlierMajorPromote(slug: string, major: number, from: string, versionId: string, unlistedOnly: boolean, audit: AdminEntry, breakingWithinMajor: string | null): Promise<boolean>;
549
+ listChannels(verticalSlug: string, page?: ListPage): Promise<ChannelRow[]>;
550
+ insertChannelHistory(h: ChannelHistoryRow): Promise<void>;
551
+ listChannelHistory(verticalSlug: string, channel?: string, page?: ListPage): Promise<ChannelHistoryRow[]>;
552
+ readOrg(tenantId: string, orgId: string): Promise<OrgRow | undefined>;
553
+ createOrg(orgId: string, tenantId: string, slug: string, name: string, createdAt: string): Promise<boolean>;
554
+ /** #2526: `createOrg` with its admin row, in one unit. */
555
+ insertOrg(orgId: string, tenantId: string, slug: string, name: string, createdAt: string, audit: AdminEntry): Promise<boolean>;
556
+ listOrgs(tenantId: string): Promise<OrgRow[]>;
557
+ /** #1184: a bounded, fenced tenant-role add, as one DO unit. */
558
+ applyMembership(change: MembershipChange, row: AdminEntry, orgRow?: AdminEntry, reserved?: readonly string[]): Promise<MembershipChangeResult>;
559
+ /**
560
+ * #1184: a tenant-level removal — the K-21 tombstone, the removal fence and (only if it
561
+ * changed anything) the audit row — as one DO unit. Returns whether anything changed.
562
+ */
563
+ revokeAndFence(tenantId: string, principal: string, relation: string, object: string, row: AdminEntry): Promise<boolean>;
564
+ listMembers(tenantId: string, object: string, includeRevoked: boolean): Promise<MemberTupleRow[]>;
565
+ grantEntitlement(tenantId: string, key: string, input: {
566
+ expiresAt?: string | null;
567
+ quota?: number | null;
568
+ plan?: string | null;
569
+ }, actor: string, audit?: AdminEntry): Promise<{
570
+ changed: boolean;
571
+ before: EntitlementRow | null;
572
+ after: EntitlementRow;
573
+ }>;
574
+ revokeEntitlement(tenantId: string, key: string, audit?: AdminEntry): Promise<EntitlementRow | null>;
575
+ tenantHoldsEntitlement(tenantId: string, key: string): Promise<boolean>;
576
+ listEntitlements(tenantId: string): Promise<EntitlementRow[]>;
577
+ /** The three projections §5's meters fold from (#38); narrowed when a tenant is given. */
578
+ meterRows(tenantId?: string): Promise<{
579
+ tenants: {
580
+ tenant_id: string;
581
+ slug: string;
582
+ status: string;
583
+ }[];
584
+ scopes: {
585
+ tenant_id: string;
586
+ status: string;
587
+ archived_from_status: string | null;
588
+ }[];
589
+ entitlements: {
590
+ tenant_id: string;
591
+ entitlement_key: string;
592
+ plan: string | null;
593
+ expires_at: string | null;
594
+ }[];
595
+ /** #1524: the stored gauge's latest sample per non-reaped scope. */
596
+ storage: ScopeStorageSample[];
597
+ storageAttempts: ScopeStorageAttempt[];
598
+ /** #2212: the latest sample per (scope, binding). */
599
+ storeStorage: {
600
+ tenantId: TenantId;
601
+ bytes: number;
602
+ readAt: string;
603
+ }[];
604
+ /** #2501: the latest attachment sample per non-reaped scope. */
605
+ attachmentStorage: {
606
+ tenantId: TenantId;
607
+ bytes: number;
608
+ }[];
609
+ }>;
610
+ readTenantStorageGauge(tenantId: TenantId, limit: number): Promise<{
611
+ gauge: StorageGauge;
612
+ truncated: boolean;
613
+ }>;
614
+ /** #1524: the stored storage gauge — kernel `storage-gauge.ts`, run inside the directory DO. */
615
+ recordScopeStorage(readings: readonly ScopeStorageReadingInput[]): Promise<{
616
+ recorded: number;
617
+ }>;
618
+ listScopeStorage(filter?: ScopeStorageFilter): Promise<ScopeStorageSample[]>;
619
+ listScopeStorageAttempts(): Promise<ScopeStorageAttempt[]>;
620
+ pruneScopeStorage(limit: number): Promise<number>;
621
+ /** #2501: the daily request rollup — kernel `request-rollup.ts`, run inside the directory DO. */
622
+ recordRequestDay(input: RequestDayReadInput): Promise<{
623
+ recorded: number;
624
+ }>;
625
+ listRequestDays(filter?: RequestDayFilter): Promise<RequestDay[]>;
626
+ listRequestRollupDays(filter?: RequestRollupDayFilter): Promise<RequestRollupDay[]>;
627
+ listTenantRequestMeter(tenantId: TenantId, since: string, until: string, limit: number): Promise<TenantRequestMeterRow[]>;
628
+ listRequestMeterDays(since: string, until: string): Promise<RequestMeterDayRow[]>;
629
+ pruneRequestDays(limit: number, retentionMonths: number | null): Promise<number>;
630
+ /** #3316: the daily Cloudflare cost rollup and the scope-object ledger — kernel `cost-rollup.ts`. */
631
+ recordCostDay(input: CostDayReadInput): Promise<{
632
+ recorded: number;
633
+ }>;
634
+ recordCostContainers(input: CostContainersInput): Promise<CostContainersResult>;
635
+ listCostDays(filter?: CostDayFilter): Promise<CostDay[]>;
636
+ listCostRollupDays(filter?: CostRollupDayFilter): Promise<RequestRollupDay[]>;
637
+ sumCostDays(filter: CostDayTotalsFilter): Promise<CostDayTotals>;
638
+ pruneCostDays(limit: number, retentionMonths: number | null): Promise<number>;
639
+ listScopeObjectsDue(input: {
640
+ limit: number;
641
+ retryMs: number;
642
+ }): Promise<ScopeObjectTarget[]>;
643
+ recordScopeObject(input: ScopeObjectReadInput): Promise<void>;
644
+ /** #2501: the daily meter snapshot — kernel `meter-days.ts`, run inside the directory DO. */
645
+ recordMeterDay(input: MeterDayTakeInput): Promise<MeterDayTakeResult>;
646
+ listMeterDays(filter?: MeterDayFilter): Promise<MeterDay[]>;
647
+ listMeterDayTakes(filter?: MeterDayTakeFilter): Promise<MeterDayTake[]>;
648
+ pruneMeterDays(limit: number, retentionMonths: number | null): Promise<number>;
649
+ /** #3313: the daily stale-scopes report — kernel `stale-scopes.ts`, run inside the directory DO. */
650
+ recordStaleScopes(input: StaleScopeTakeInput): Promise<StaleScopeTakeResult>;
651
+ listStaleScopes(filter?: StaleScopeFilter): Promise<StaleScope[]>;
652
+ listStaleScopeTakes(filter?: StaleScopeTakeFilter): Promise<StaleScopeTake[]>;
653
+ insertConnection(row: {
654
+ id: string;
655
+ tenantId: string;
656
+ vertical: string;
657
+ provider: string;
658
+ label: string;
659
+ externalAccountRef: string | null;
660
+ scopes: string;
661
+ expiresAt: string | null;
662
+ createdBy: string;
663
+ createdAt: string;
664
+ keyId: string;
665
+ ciphertext: string;
666
+ ownerScopeId: string | null;
667
+ }, audit?: AdminEntry): Promise<void>;
668
+ listConnections(filter: {
669
+ tenantId?: string;
670
+ vertical?: string;
671
+ provider?: string;
672
+ externalAccountRef?: string;
673
+ ownerScopeId?: string | null;
674
+ includeRevoked?: boolean;
675
+ }): Promise<ConnectionDoRow[]>;
676
+ readConnection(id: string): Promise<ConnectionDoRow | undefined>;
677
+ /** #687: this connection's sealing-key rows — current and retired alike. */
678
+ readConnectionKeys(connectionId: string): Promise<{
679
+ key_id: string;
680
+ public_key: string;
681
+ wrapped_key_id: string;
682
+ wrapped_private: string;
683
+ retired_at: string | null;
684
+ }[]>;
685
+ /** #687: mint-if-absent; returns the CURRENT key after the write, so a lost race adopts the winner's. */
686
+ insertConnectionKey(row: {
687
+ connectionId: string;
688
+ keyId: string;
689
+ publicKey: string;
690
+ wrappedKeyId: string;
691
+ wrappedPrivate: string;
692
+ createdAt: string;
693
+ }): Promise<{
694
+ key_id: string;
695
+ public_key: string;
696
+ } | undefined>;
697
+ readLiveConnection(tenantId: string, vertical: string, provider: string, externalAccountRef?: string, ownerScopeId?: string): Promise<(ConnectionDoRow & {
698
+ key_id: string;
699
+ ciphertext: string;
700
+ }) | undefined>;
701
+ updateConnectionSecret(id: string, keyId: string, ciphertext: string, expiresAt: string | null, at: string, audit?: AdminEntry): Promise<void>;
702
+ revokeConnection(id: string, at: string, audit?: AdminEntry): Promise<boolean>;
703
+ insertConnectLink(row: {
704
+ id: string;
705
+ tenantId: string;
706
+ scopeId: string;
707
+ vertical: string;
708
+ provider: string;
709
+ createdBy: string;
710
+ subjectRef: string | null;
711
+ returnUrl: string | null;
712
+ createdAt: string;
713
+ expiresAt: string;
714
+ }, audit: AdminEntry): Promise<ConnectLink>;
715
+ readConnectLink(key: ConnectLinkKeyRow): Promise<ConnectLink | undefined>;
716
+ listConnectLinks(filter: {
717
+ tenantId: string;
718
+ scopeId?: string;
719
+ ids?: readonly string[];
720
+ provider?: string;
721
+ outstandingOnly?: boolean;
722
+ }, now: string): Promise<ConnectLink[]>;
723
+ revokeConnectLink(key: ConnectLinkKeyRow, audit: AdminEntry): Promise<{
724
+ link: ConnectLink;
725
+ changed: boolean;
726
+ } | undefined>;
727
+ consumeConnectLink(input: ConnectLinkKeyRow & {
728
+ provider: string;
729
+ accountRef?: string;
730
+ accountLabel?: string;
731
+ }, now: string, audit: AdminEntry): Promise<ConnectLinkConsume>;
732
+ restoreConnectLink(key: ConnectLinkKeyRow, now: string, audit: AdminEntry): Promise<ConnectLink | undefined>;
733
+ /** #2526: `grantToConnection`'s directory half — the checks, the record, the tenant tuple, the row. */
734
+ grantConnectionInDirectory(row: {
735
+ connectionId: string;
736
+ tenantId: string;
737
+ permission: string;
738
+ scopeId: string | null;
739
+ expiresAt: string | null;
740
+ grantedBy: string;
741
+ grantedAt: string;
742
+ }, audit: AdminEntry): Promise<{
743
+ vertical: string;
744
+ }>;
745
+ /** #2732: `revokeFromConnection`'s directory half — the record tombstoned, the row when anything changed. */
746
+ revokeConnectionGrantInDirectory(row: {
747
+ connectionId: string;
748
+ tenantId: string;
749
+ permission: string;
750
+ scopeId: string;
751
+ revokedAt: string;
752
+ tupleChanged: boolean;
753
+ }, audit: AdminEntry): Promise<{
754
+ changed: boolean;
755
+ }>;
756
+ listConnectionGrants(tenantId: string): Promise<ConnectionGrantDoRow[]>;
757
+ recordSwitchedOff(row: SwitchRecordWrite): Promise<SwitchRecordPrior>;
758
+ recordSwitchedOn(row: SwitchRecordWrite): Promise<SwitchRecordPrior>;
759
+ restoreSwitchRecord(key: {
760
+ kind: SwitchKind;
761
+ tenantId: string;
762
+ scopeId: string;
763
+ key: string;
764
+ operationId: string;
765
+ }, prior: SwitchRecordPrior,
766
+ /** #2045: also clear the call's own owed mark, in the same directory transaction. */
767
+ clearOwed?: boolean): Promise<void>;
768
+ listSystemSwitches(filter?: SystemSwitchRecordFilter): Promise<SystemSwitchRecordRow[]>;
769
+ switchRecordsOf(kind: SwitchKind, tenantId: string, scopeId: string): Promise<[string, 'on' | 'off'][]>;
770
+ /** #2045: each record row's position and fence together — what a move to the record reads, never the two apart. */
771
+ switchRecordStatesOf(kind: SwitchKind, tenantId: string, scopeId: string): Promise<[string, {
772
+ position: 'on' | 'off';
773
+ fence: string;
774
+ }][]>;
775
+ /** #2045: the subjects owed a re-assert to their record — every switch call's, until the scope confirms it. */
776
+ switchesOwedOf(kind: SwitchKind, tenantId: string, scopeId: string): Promise<[string, string][]>;
777
+ clearSwitchOwed(kind: SwitchKind, tenantId: string, scopeId: string, key: string, fence: string): Promise<void>;
778
+ tenantHeldOf(kind: SwitchKind, tenantId: string, keys: readonly string[], now: string): Promise<string[]>;
779
+ recordConnectionUse(id: string, error: string | null, at: string): Promise<{
780
+ tenantId: string;
781
+ vertical: string;
782
+ provider: string;
783
+ } | null | void>;
784
+ putConnectorState(id: string, key: string, value: string, at: string): Promise<void>;
785
+ getConnectorState(id: string, key: string): Promise<string | undefined>;
786
+ swapConnectorState(id: string, key: string, expected: string | null, value: string, at: string): Promise<boolean>;
787
+ putConnectorStateFenced(id: string, fenceKey: string, expected: string | null, writes: readonly {
788
+ key: string;
789
+ value: string;
790
+ }[], at: string): Promise<boolean>;
791
+ listConnectorState(id: string, prefix?: string): Promise<{
792
+ key: string;
793
+ value: string;
794
+ }[]>;
795
+ linkIdentity(provider: string, externalId: string, principal: string, tenantId: string, scopeId: string | null, createdAt: string, audit?: AdminEntry): Promise<boolean>;
796
+ /** Delete a principal's identity link(s) in a tenant. Idempotent (returns whether it changed). */
797
+ unlinkIdentity(tenantId: string, principal: string, audit?: AdminEntry): Promise<boolean>;
798
+ readPool(provider: string): Promise<{
799
+ provider: string;
800
+ topology: string;
801
+ tenant_id: string | null;
802
+ } | undefined>;
803
+ registerIdentityPool(provider: string, topology: string, tenantId: string | null, createdAt: string, audit?: AdminEntry): Promise<boolean>;
804
+ identityTenants(provider: string, externalId: string): Promise<string[]>;
805
+ identityMemberships(provider: string, externalId: string, access: {
806
+ id: string;
807
+ actor: string;
808
+ onBehalfOf: OnBehalfOf | null;
809
+ at: string;
810
+ }): Promise<{
811
+ topology: string | null;
812
+ memberships: unknown[];
813
+ }>;
814
+ resolveIdentity(tenantId: string, provider: string, externalId: string): Promise<{
815
+ principal: string;
816
+ scopeId: string | null;
817
+ } | undefined>;
818
+ writeImpersonation(values: (string | null)[], audit?: AdminEntry): Promise<void>;
819
+ readImpersonation(id: string): Promise<ImpersonationRow | undefined>;
820
+ endImpersonation(id: string, endedAt: string, audit?: AdminEntry): Promise<void>;
821
+ listImpersonations(filter: unknown, now: string): Promise<ImpersonationRow[]>;
822
+ recordAccess(entry: {
823
+ id: string;
824
+ actor: string;
825
+ method: string;
826
+ tenantId: string | null;
827
+ scopeId: string | null;
828
+ params: string | null;
829
+ resultCount: number;
830
+ onBehalfOf: OnBehalfOf | null;
831
+ at: string;
832
+ }): Promise<void>;
833
+ accessLog(query: {
834
+ actor?: string;
835
+ tenantId?: string;
836
+ method?: string;
837
+ drained?: boolean;
838
+ } & ListPage): Promise<AccessLogRow[]>;
839
+ markAccessLogDrained(upToId: string, drainedAt: string, audit?: AdminEntry): Promise<number>;
840
+ pruneAccessLog(limit: number, audit?: AdminEntry): Promise<number>;
841
+ setDirectoryLakeCapture(datasets: readonly DirectoryLakeDataset[], audit: AdminEntry): Promise<DirectoryLakeCaptureResult>;
842
+ directoryLakeCapture(): Promise<DirectoryLakeCaptureState[]>;
843
+ directoryOutbox(limit: number): Promise<DirectoryLakeRow[]>;
844
+ ackDirectoryOutbox(upToSeq: number, ref: string, audit: AdminEntry): Promise<number>;
845
+ directoryLakeBackfill(dataset: DirectoryLakeDataset, after: number, limit: number): Promise<DirectoryLakeBackfillPage>;
846
+ advanceDirectoryLakeBackfill(dataset: DirectoryLakeDataset, page: {
847
+ after: number;
848
+ next: number | null;
849
+ done: boolean;
850
+ }, audit: AdminEntry): Promise<DirectoryLakeCaptureState>;
851
+ pruneDirectoryLakeWindow(dataset: DirectoryLakeDataset, before: string, limit: number, audit: AdminEntry): Promise<{
852
+ pruned: number;
853
+ refused: DirectoryLakePruneRefusal | null;
854
+ }>;
855
+ /** #3464: the directory's SecretBox canary, and the oldest secret it holds sealed (`guardSecretBox`). */
856
+ readSecretBoxCanary(): Promise<{
857
+ keyId: string;
858
+ ciphertext: string;
859
+ } | undefined>;
860
+ insertSecretBoxCanary(row: {
861
+ keyId: string;
862
+ ciphertext: string;
863
+ createdAt: string;
864
+ }): Promise<void>;
865
+ oldestWrappedSecret(): Promise<{
866
+ keyId: string;
867
+ ciphertext: string;
868
+ } | undefined>;
869
+ readSubjectKey(scopeId: string, subjectId: string): Promise<{
870
+ keyId: string | null;
871
+ wrappedDek: string | null;
872
+ shreddedAt: string | null;
873
+ } | undefined>;
874
+ /** #3464: several subjects' rows at once; a subject with no row is absent. */
875
+ readSubjectKeys(scopeId: string, subjectIds: readonly string[]): Promise<{
876
+ subjectId: string;
877
+ keyId: string | null;
878
+ wrappedDek: string | null;
879
+ shreddedAt: string | null;
880
+ }[]>;
881
+ /** Tombstoned subjects, in subject-id order. `cursor` is the last id already returned. */
882
+ listShreddedSubjects(scopeId: string, tenantId: string, cursor: string | null): Promise<string[]>;
883
+ insertSubjectKey(input: {
884
+ scopeId: string;
885
+ subjectId: string;
886
+ tenantId: string;
887
+ keyId: string;
888
+ wrappedDek: string;
889
+ createdAt: string;
890
+ }): Promise<void>;
891
+ tombstoneSubjectKey(input: {
892
+ scopeId: string;
893
+ subjectId: string;
894
+ tenantId: string;
895
+ at: string;
896
+ }): Promise<{
897
+ existed: boolean;
898
+ }>;
899
+ recordAdmin(entry: AdminEntry): Promise<void>;
900
+ auditLog(query: AuditLogQuery): Promise<AdminLogEntry[]>;
901
+ recordOpsFailure(row: OpsFailureRow): Promise<void>;
902
+ settleUnrecordedOutcome(input: {
903
+ actor: string;
904
+ intentId: string;
905
+ error: string;
906
+ }): Promise<boolean>;
907
+ auditedOperations(refs: AuditedOperationRef[]): Promise<AuditedOperationRow[]>;
908
+ /** #1632: subject erasure's directory half — `redactSubjectDirectoryText`. */
909
+ redactSubjectText(target: SubjectTextTarget): Promise<void>;
910
+ listOpsFailures(query: OpsFailureQuery): Promise<OpsFailureEntry[]>;
911
+ recordSweepRun(row: SweepRunRow): Promise<void>;
912
+ listSweepRuns(query: SweepRunQuery): Promise<SweepRunEntry[]>;
913
+ listIssues(query: IssueQuery): Promise<unknown[]>;
914
+ /** #1632: the telemetry retentions, run by the scheduled pass — `telemetryRetentionStatements`. */
915
+ pruneTelemetry(limit: number): Promise<TelemetryPruneReport>;
916
+ pruneFindings(limit: number, audit: AdminEntry): Promise<FindingPruneReport>;
917
+ listFindings(filter: FindingFilter): Promise<FindingEntry[]>;
918
+ setFindingStatus(tenantId: TenantId, id: string, status: FindingStatusInput, at: string, audit: AdminEntry): Promise<FindingChange | undefined>;
919
+ createFindingRule(tenantId: TenantId, input: FindingRuleInput, createdBy: string, at: string, audit: AdminEntry): Promise<{
920
+ rule: FindingRuleEntry;
921
+ suppressed: string[];
922
+ }>;
923
+ revokeFindingRule(tenantId: TenantId, ruleId: string, at: string, audit: AdminEntry): Promise<{
924
+ before: FindingRuleEntry;
925
+ after: FindingRuleEntry;
926
+ } | undefined>;
927
+ listFindingRules(tenantId: TenantId, activeAt: string | undefined, limit: number | undefined): Promise<FindingRuleEntry[]>;
928
+ setIssueStatus(fingerprint: string, status: 'new' | 'resolved' | 'ignored', at: string, audit?: AdminEntry): Promise<{
929
+ before: unknown;
930
+ after: unknown;
931
+ } | undefined>;
932
+ recordModelUsage(row: ModelUsageRow): Promise<{
933
+ recorded: boolean;
934
+ }>;
935
+ listModelUsage(query: ModelUsageQuery): Promise<ModelUsageRow[]>;
936
+ listTenantModelUsageMeter(query: TenantModelUsageMeterFilter): Promise<TenantModelUsageMeterRow[]>;
937
+ insertMarkupRowAndAudit(values: (string | number | null)[], audit: AdminEntry): Promise<void>;
938
+ listMarkupRows(tenantId?: string): Promise<MarkupScheduleRecord[]>;
939
+ recordBuildUsage(input: BuildUsageInput): Promise<{
940
+ recorded: boolean;
941
+ }>;
942
+ listTenantBuildUsage(query: TenantBuildUsageFilter): Promise<TenantBuildUsageRow[]>;
943
+ exportDump(): Promise<ScopeDumpTable[]>;
944
+ exportDumpPage(cursor: string | null, opts?: {
945
+ maxBytes?: number;
946
+ byReference?: DirectoryCopyByReference;
947
+ }): Promise<DirectoryDumpPage & {
948
+ copiedTables?: number;
949
+ }>;
950
+ importDump(tables: ScopeDumpTable[], audit?: AdminEntry): Promise<void>;
951
+ putTenantStoreAndAudit: AuditRequired<ControlPlaneStub['putTenantStore']>;
952
+ putBlobStoreAndAudit: AuditRequired<ControlPlaneStub['putBlobStore']>;
953
+ recordStoreDriverReleaseAndAudit: AuditRequired<ControlPlaneStub['recordStoreDriverRelease']>;
954
+ beginStoreDriverRolloutAndAudit: AuditRequired<ControlPlaneStub['beginStoreDriverRollout']>;
955
+ finishStoreDriverRolloutAndAudit: AuditRequired<ControlPlaneStub['finishStoreDriverRollout']>;
956
+ importDumpAndAudit: AuditRequired<ControlPlaneStub['importDump']>;
957
+ stageRestorePage(stageId: string, seq: number, tables: ScopeDumpTable[]): Promise<{
958
+ staged: boolean;
959
+ }>;
960
+ commitStagedRestore(stageId: string, audit?: AdminEntry, opts?: {
961
+ overwrite?: boolean;
962
+ }): Promise<{
963
+ tables: number;
964
+ rows: number;
965
+ }>;
966
+ commitStagedRestoreAndAudit: AuditRequired<ControlPlaneStub['commitStagedRestore']>;
967
+ discardStagedRestore(stageId: string): Promise<{
968
+ discarded: boolean;
969
+ }>;
970
+ registerIdentityPoolAndAudit: AuditRequired<ControlPlaneStub['registerIdentityPool']>;
971
+ insertConnectionAndAudit: AuditRequired<ControlPlaneStub['insertConnection']>;
972
+ updateConnectionSecretAndAudit: AuditRequired<ControlPlaneStub['updateConnectionSecret']>;
973
+ revokeConnectionAndAudit: AuditRequired<ControlPlaneStub['revokeConnection']>;
974
+ linkIdentityAndAudit: AuditRequired<ControlPlaneStub['linkIdentity']>;
975
+ unlinkIdentityAndAudit: AuditRequired<ControlPlaneStub['unlinkIdentity']>;
976
+ markAccessLogDrainedAndAudit: AuditRequired<ControlPlaneStub['markAccessLogDrained']>;
977
+ pruneAccessLogAndAudit: AuditRequired<ControlPlaneStub['pruneAccessLog']>;
978
+ writeImpersonationAndAudit: AuditRequired<ControlPlaneStub['writeImpersonation']>;
979
+ endImpersonationAndAudit: AuditRequired<ControlPlaneStub['endImpersonation']>;
980
+ setIssueStatusAndAudit: AuditRequired<ControlPlaneStub['setIssueStatus']>;
981
+ }
982
+ type AuditRequired<F> = F extends (...args: infer A) => infer R ? (...args: Required<A>) => R : never;
983
+ interface AdminEntry {
984
+ id: string;
985
+ actor: string;
986
+ action: string;
987
+ /** Null for platform-level actions that target no tenant (K-23). */
988
+ tenantId: string | null;
989
+ /** The event that caused this action, when one did (K-22 §4.2). */
990
+ causedBy: string | null;
991
+ /** Who the actor acted for (#977), when an attributed view wrote the row. */
992
+ onBehalfOf: OnBehalfOf | null;
993
+ scopeId: string | null;
994
+ vertical: string | null;
995
+ before: unknown;
996
+ after: unknown;
997
+ at: string;
998
+ }
15
999
  interface ScopeStubRpc {
16
1000
  /**
17
1001
  * #2993 part 3: fix the scope's type at its provision, judged by the class's declared types; the
@@ -1082,14 +2066,16 @@ export interface LifecycleDeliveryReport {
1082
2066
  /** Deliveries that did not land: each is an ops-failure row, and the heal sweep asks again. */
1083
2067
  failed: number;
1084
2068
  /**
1085
- * K-69 (#3540): scopes owed a retry, or their first delivery after a restore, that were handed to
1086
- * the {@link LifecycleRetryOwner} instead of delivered here. Absent without an owner.
2069
+ * K-69 (#3540): scopes owed a retry, their first delivery after a restore, a hold's delivery to the
2070
+ * deployment that serves them now or a tenant-record ask (#2016), handed to the
2071
+ * {@link LifecycleRetryOwner} instead of delivered here. Absent without an owner.
1087
2072
  */
1088
2073
  handedOver?: number;
1089
2074
  }
1090
2075
  /**
1091
- * K-69 (#3540): one scope whose failed lifecycle delivery is owed a retry, or that is owed its first
1092
- * delivery after a directory restore, and when it is due (epoch ms).
2076
+ * K-69 (#3540): one scope owed a delivery its {@link LifecycleRetryOwner} makes (a failed delivery's
2077
+ * retry, its first delivery after a directory restore, a hold's delivery to the deployment that serves
2078
+ * it now, or its #2016 tenant-record ask), and when it is due (epoch ms).
1093
2079
  */
1094
2080
  export interface LifecycleRetryItem {
1095
2081
  tenantId: TenantId;
@@ -1113,7 +2099,15 @@ export interface LifecycleRetryItem {
1113
2099
  * be missing only from a store that took none: one that serves the scope since it acknowledged. The
1114
2100
  * sweep delivers none of those holds: one acknowledged at the deployment that still serves the scope
1115
2101
  * is owed nothing, and one acknowledged elsewhere (or before the receipt named a deployment) is handed
1116
- * over. A hold the deployment has not acknowledged, and the #2016 tenant-record asks, stay the sweep's.
2102
+ * over. A hold the deployment has not acknowledged stays the sweep's, so a hold that did not land is
2103
+ * never delayed.
2104
+ *
2105
+ * So is the #2016 tenant-record ask (`owedTenantAsk`). The sweep's rotation still finds the scopes
2106
+ * owed one, and hands each over, noted as asked, so the rotation moves on; it lists one again only
2107
+ * once its last ask is a re-look old ({@link LIFECYCLE_TENANT_ASK_RELOOK_MS}), which recovers a
2108
+ * handoff that was lost. A delivery that lands without the record is the event: it makes the next
2109
+ * ask due on the owner a re-look on. The owner asks with a delivery, and asks again a re-look on while
2110
+ * the deployment cannot record; one that fails is a retry on the directory's back-off (#3119).
1117
2111
  */
1118
2112
  export interface LifecycleRetryOwner {
1119
2113
  /** Make each item due on its tenant's owner. A throw is logged, and the next sweep hands the scope over again. */
@@ -1125,6 +2119,14 @@ export interface LifecycleRetryOwner {
1125
2119
  * looks again a minute on, then on the directory's back-off.
1126
2120
  */
1127
2121
  export declare const LIFECYCLE_RETRY_FIRST_LOOK_MS = 60000;
2122
+ /**
2123
+ * K-69 (#3540), #2016: with a {@link LifecycleRetryOwner}, how long after a tenant-record ask the
2124
+ * next one is due while the deployment answers without the record. The sweep's rotation reaches each
2125
+ * such scope once a pass while fewer than {@link TENANT_UNRECORDED_PER_PASS} are owed one, so this is
2126
+ * the pass's period: the cadence the sweep asks at. An ask that fails waits on the directory's
2127
+ * back-off (#3119) instead, as any failed delivery does.
2128
+ */
2129
+ export declare const LIFECYCLE_TENANT_ASK_RELOOK_MS: number;
1128
2130
  /**
1129
2131
  * The PEER kill switch's reach into the deployment actually serving a scope (#1706).
1130
2132
  *
@@ -1339,6 +2341,13 @@ export interface CloudflareScopeHostOptions {
1339
2341
  * the clear.
1340
2342
  */
1341
2343
  secretBox?: SecretBox;
2344
+ /**
2345
+ * #3464: whether every seal first proves `secretBox` holds the directory's key, against a canary
2346
+ * the ControlPlaneDO keeps (`guardSecretBox`), and how a directory with none is seeded. Omitted or
2347
+ * `off`: no canary, as before. Ignored without a `secretBox` (which refuses every seal already) and
2348
+ * on a host with no control plane, which has no directory to keep one in.
2349
+ */
2350
+ secretBoxCanary?: SecretBoxCanaryMode;
1342
2351
  /**
1343
2352
  * Egress for connectors. Defaults to the runtime's `fetch`. Injectable so a
1344
2353
  * provider can be stood up in memory for tests and dev.
@@ -1374,6 +2383,22 @@ export interface CloudflareScopeHostOptions {
1374
2383
  * it for existing scopes wants a one-time `reconcileTenantProjection` back-fill.
1375
2384
  */
1376
2385
  scopeLocalPermissions?: boolean;
2386
+ /**
2387
+ * The verticals whose scopes this host's `scope` namespace serves (#1343, phase 2 of
2388
+ * `docs/briefs/dashboard-control-plane-retirement.md`). A projection (`fanOut`, and the one
2389
+ * `provisionScope` and `unarchiveScope` push) writes through `this.scopeStub`, so a scope of
2390
+ * any other vertical would be addressed in THIS namespace under its id: a Durable Object
2391
+ * nothing serves, created by a membership change. With the list set, a scope whose directory
2392
+ * row names another vertical (or none) is skipped: the vertical is always the one the
2393
+ * directory records, never one a caller or the scope supplies. Skipping is safe only for a
2394
+ * scope never projected, which keeps reading its permissions from the directory. A scope
2395
+ * already on its local projection (`permission_source = 'local'`) has no path back to the
2396
+ * directory, so skipping it would withhold every later revocation from it. Before a host
2397
+ * sets this, every scope it would exclude that is already projected needs its projection kept
2398
+ * current by whichever host serves it, or an explicit reconciliation. Unset: every scope the
2399
+ * directory lists, as before.
2400
+ */
2401
+ projectsVerticals?: readonly string[];
1377
2402
  /**
1378
2403
  * The live R2 client for per-tenant blob stores (#473) — `createR2BlobStores` with the
1379
2404
  * platform's Cloudflare credential. Same split as `tenantStores`: the ControlPlaneDO
@@ -1580,6 +2605,8 @@ export declare class CloudflareScopeHost implements ScopeHost {
1580
2605
  private readonly cpLess;
1581
2606
  /** Project + evaluate permissions scope-locally (scope-local-permissions.md). */
1582
2607
  private readonly scopeLocalPermissions;
2608
+ /** `projectsVerticals`, or undefined for every scope. */
2609
+ private readonly projectsVerticals;
1583
2610
  private readonly moduleIds;
1584
2611
  /** #2430: what a registered module declares `holder: 'system'` — `assignRole`'s refusal reads it. */
1585
2612
  private readonly reservedKeys;
@@ -1615,6 +2642,8 @@ export declare class CloudflareScopeHost implements ScopeHost {
1615
2642
  private readonly predicateNames;
1616
2643
  /** Executor id → {eventType, handler} (K-22 §4.2). Coordinator-side, not in the DO. */
1617
2644
  private readonly secretBox;
2645
+ /** #3464: the canary mode `secretBox` was guarded with, which its preflight reports. */
2646
+ private readonly secretBoxCanaryMode;
1618
2647
  private readonly fetchImpl;
1619
2648
  private readonly streamIdleMs;
1620
2649
  private readonly connectorCalls;
@@ -2839,9 +3868,11 @@ export declare class CloudflareScopeHost implements ScopeHost {
2839
3868
  * handed over as it fails, and the heal sweep hands over, undelivered, the scopes it finds owed one,
2840
3869
  * the live scopes it finds owed their first delivery after a restore (`owedFirstDelivery`), and the
2841
3870
  * acknowledged holds whose deployment moved (`owedHoldRedelivery`). An acknowledged hold whose
2842
- * deployment did not move is not delivered at all. `retry` is the owner's own run: only a scope owed
2843
- * one of the three, delivered even when the receipt says nothing changed (a failure is owed whatever
2844
- * the receipt), and never handed over again.
3871
+ * deployment did not move is not delivered at all. The #2016 tenant-record asks are the owner's too
3872
+ * (`owedTenantAsk`): the sweep hands over the scopes its rotation lists and asks none, and a delivery
3873
+ * that lands without the record hands its next ask over a re-look on. `retry` is the owner's own run:
3874
+ * only a scope owed one of the four, delivered even when the receipt says nothing changed (a failure
3875
+ * is owed whatever the receipt), and never handed over again.
2845
3876
  */
2846
3877
  private deliverLifecycles;
2847
3878
  /** One directory row as the lifecycle a delivery carries (#1713), or null for a status this code does not know. */
@@ -2851,20 +3882,22 @@ export declare class CloudflareScopeHost implements ScopeHost {
2851
3882
  * acknowledged state differs from the directory, and again to every scope held now — which is
2852
3883
  * what puts a hold back on a store a carry or a restore landed without it. Bounded per pass
2853
3884
  * (`limit`), drifted scopes first. Run from the shared control plane's cron. With a
2854
- * `lifecycleRetryOwner` (K-69, #3540), the retries, the first deliveries after a restore and the
2855
- * acknowledged holds whose deployment moved are handed to it, undelivered, and an acknowledged hold
2856
- * whose deployment did not move is delivered no more.
3885
+ * `lifecycleRetryOwner` (K-69, #3540), the retries, the first deliveries after a restore, the
3886
+ * acknowledged holds whose deployment moved and the #2016 tenant-record asks are handed to it,
3887
+ * undelivered, and an acknowledged hold whose deployment did not move is delivered no more.
2857
3888
  */
2858
3889
  healLifecycles(actor: PlatformActorId, opts?: {
2859
3890
  limit?: number;
2860
3891
  }): Promise<LifecycleDeliveryReport>;
2861
3892
  /**
2862
3893
  * K-69 (#3540): one retry of a scope's failed lifecycle delivery, its first delivery after a
2863
- * directory restore, or an acknowledged hold's delivery to the deployment that now serves it, for
2864
- * its `lifecycleRetryOwner`. Re-reads the directory and delivers only when the scope is still owed
2865
- * one of the three (a later transition that landed owes none), with the
3894
+ * directory restore, an acknowledged hold's delivery to the deployment that now serves it, or its
3895
+ * #2016 tenant-record ask, for its `lifecycleRetryOwner`. Re-reads the directory and delivers only
3896
+ * when the scope is still owed one of the four (a later transition that landed owes none), with the
2866
3897
  * delivery's own epoch handling and failure count; a first delivery that fails is a retry from then.
2867
- * Answers when to look again (epoch ms), or null when nothing more is owed. Throws only when the
3898
+ * Answers when to look again (epoch ms): the directory's back-off after a failure, a re-look on
3899
+ * ({@link LIFECYCLE_TENANT_ASK_RELOOK_MS}) after a delivery that landed without the tenant's record,
3900
+ * or null when nothing more is owed. Throws only when the
2868
3901
  * directory cannot be read, so the owner keeps the retry.
2869
3902
  */
2870
3903
  retryLifecycle(actor: PlatformActorId, tenantId: TenantId, scopeId: ScopeId): Promise<number | null>;
@@ -2904,6 +3937,8 @@ export declare class CloudflareScopeHost implements ScopeHost {
2904
3937
  * Record a staff read (K-24). `params` is a bounded summary, capped so one query
2905
3938
  * cannot write an unbounded row.
2906
3939
  */
3940
+ /** #3464: the directory's SecretBox canary, kept by the ControlPlaneDO. Read at seal time, never before. */
3941
+ private secretBoxCanaryRecords;
2907
3942
  private recordAccess;
2908
3943
  private recordAdmin;
2909
3944
  /**
@@ -3083,6 +4118,11 @@ export declare class CloudflareScopeHost implements ScopeHost {
3083
4118
  * bound to no vertical — which then seals to nothing, the fail-closed direction.
3084
4119
  */
3085
4120
  private connectionKeyRows;
4121
+ /**
4122
+ * Whether a scope of `vertical` is this host's to project into (`projectsVerticals`). Both
4123
+ * callers pass the vertical from the directory's own row (`listScopes`, `getScopeRecord`).
4124
+ */
4125
+ private projectsInto;
3086
4126
  /** Project the tenant's current state into ONE scope + flip it to local. */
3087
4127
  private projectScope;
3088
4128
  /**