@substrat-run/adapter-cloudflare 0.111.0 → 0.113.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/host.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type AttachmentRecord, type BlobStoreHandle, type ImpersonationSessionId, type ConnectionId, type ModuleId, type EntityHistoryInput, type EventCauseInput, type EventEffectsInput, type EffectsTree, 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 PrincipalId, type ResolvedIdentity, type QueryScopeInput, type ReadScopeTableInput, type RoleDefinition, type ScopeDump, type ScopeDumpTable, type ScopeId, type PlatformRequest, type PlatformRequestFilter, type PlatformRequestId, type PlatformRequestStatus, type PlatformRequestFailure, type ScopeTable, type DenialFilter, type DenialSummary, type PermissionDenial, type ScopeQueryResult, type ScopeTablePage, type TenantId, type TenantStoreHandle } from '@substrat-run/contracts';
1
+ import { type AttachmentRecord, type BlobStoreHandle, type ImpersonationSessionId, type ConnectionId, type ModuleId, type DrainedEvent, type EntityHistoryInput, type EventCauseInput, type EventEffectsInput, type EffectsTree, type InvocationEventsInput, type InvocationEvents, 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 PrincipalId, type ResolvedIdentity, type QueryScopeInput, type ReadScopeTableInput, type RoleDefinition, type ScopeDump, type ScopeDumpTable, type ScopeId, type PlatformRequest, type PlatformRequestFilter, type PlatformRequestId, type PlatformRequestStatus, type PlatformRequestFailure, type ScopeTable, type DenialFilter, type DenialSummary, type PermissionDenial, type ScopeQueryResult, type ScopeTablePage, type TenantId, type TenantStoreHandle } from '@substrat-run/contracts';
2
2
  import { type AppliedMigration, type BlobStoreProvisionInput, type ScopeAttachments, type AttachmentUploadInput, type OpenedAttachment, 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 ScopeHost, type ScopeStub, type ScopeStubOptions, type TenantRelationalStore, type TenantStoreProvisionInput, type FreshnessRegistration, type FreshnessReport } from '@substrat-run/kernel';
3
3
  import { type D1TenantStores } from './d1.js';
4
4
  import { type R2BlobStores } from './r2.js';
@@ -71,6 +71,48 @@ export interface ConnectorDelegation {
71
71
  expiresAt?: string;
72
72
  }): Promise<void>;
73
73
  }
74
+ /**
75
+ * The Tier-2 drain's reach into the deployment actually serving a scope (#1334).
76
+ *
77
+ * The same problem `ConnectorDelegation` solves, for the other direction: on the shared
78
+ * control plane `env.SCOPE` is the module-less placeholder namespace, and a hosted
79
+ * scope's outbox lives in its vertical's dispatch deployment. Without this, the sweep's
80
+ * drain phase would construct one empty placeholder DO per active scope per tick, log
81
+ * an access row for each, and ship nothing — which from the lake's side is
82
+ * indistinguishable from a fleet with no events. The two verbs are the two the drain
83
+ * is made of, deliberately kept apart (read, ship, then stamp); the audit rows for
84
+ * both stay on the host's own `readUndrainedEvents` / `markEventsDrained`, whichever
85
+ * branch served them — K-24's rule that an auditor cannot tell from the row.
86
+ */
87
+ export interface EventDrainDelegation {
88
+ /** The oldest not-yet-drained events of one scope, from the deployment serving it. */
89
+ readUndrained(args: {
90
+ tenantId: TenantId;
91
+ scopeId: ScopeId;
92
+ vertical: string;
93
+ limit: number;
94
+ }): Promise<DrainedEvent[]>;
95
+ /** Stamp `drained_at` on shipped events in the serving deployment; returns how many changed. */
96
+ markDrained(args: {
97
+ tenantId: TenantId;
98
+ scopeId: ScopeId;
99
+ vertical: string;
100
+ eventIds: readonly string[];
101
+ drainedAt: string;
102
+ }): Promise<number>;
103
+ /**
104
+ * Reopen rows stamped before `drainedBefore` in the serving deployment, so the drain
105
+ * ships them again; returns how many (#1334). The third verb, and it must be delegated
106
+ * for the same reason as the stamp it undoes: the rows live there, and clearing stamps
107
+ * in the placeholder namespace would report success while reopening nothing.
108
+ */
109
+ redrain(args: {
110
+ tenantId: TenantId;
111
+ scopeId: ScopeId;
112
+ vertical: string;
113
+ drainedBefore: string;
114
+ }): Promise<number>;
115
+ }
74
116
  export interface CloudflareScopeHostOptions {
75
117
  scope: DurableObjectNamespace;
76
118
  /**
@@ -142,6 +184,13 @@ export interface CloudflareScopeHostOptions {
142
184
  * locally.
143
185
  */
144
186
  connectorDelegation?: ConnectorDelegation;
187
+ /**
188
+ * #1334: route the Tier-2 drain's read and stamp to the deployment actually serving
189
+ * the scope. Set only on the shared control plane's host, exactly like
190
+ * `connectorDelegation` and for the same reason — its own `SCOPE` namespace holds no
191
+ * hosted scope's outbox. A vertical's own host leaves it unset and reads locally.
192
+ */
193
+ eventDrainDelegation?: EventDrainDelegation;
145
194
  /**
146
195
  * **There is deliberately no `clock` here** (#956), and the absence is the fact.
147
196
  *
@@ -222,6 +271,8 @@ export declare class CloudflareScopeHost implements ScopeHost {
222
271
  private readonly operationEntitlement;
223
272
  /** #574: remote connector write-back for scopes served by another deployment. */
224
273
  private readonly connectorDelegation?;
274
+ /** #1334: the Tier-2 drain's reach into the deployment serving a scope. */
275
+ private readonly eventDrainDelegation?;
225
276
  /**
226
277
  * MUST be constructed per request. Never cache an instance across requests.
227
278
  *
@@ -368,12 +419,32 @@ export declare class CloudflareScopeHost implements ScopeHost {
368
419
  facetEventsLocal(scopeId: ScopeId, input: EventFacetInput): Promise<EventFacetResult>;
369
420
  /** What one event set off (#1237) on this host's own scope — the vertical-host read. */
370
421
  eventEffectsLocal(scopeId: ScopeId, input: EventEffectsInput): Promise<EffectsTree>;
422
+ /** Everything one call emitted (#1237) on this host's own scope — the vertical-host read. */
423
+ invocationEventsLocal(scopeId: ScopeId, input: InvocationEventsInput): Promise<InvocationEvents>;
371
424
  /** One event's causal chain (#1237) on this host's own scope — the vertical-host read. */
372
425
  eventCauseLocal(scopeId: ScopeId, input: EventCauseInput): Promise<CauseChain>;
373
426
  /** One record's event history (#1235) on this host's own scope — the vertical-host read. */
374
427
  entityHistoryLocal(scopeId: ScopeId, input: EntityHistoryInput): Promise<Page<HistoryEntry>>;
375
428
  /** When this host's own scope applied each migration (#1236) — the vertical-host read. */
376
429
  appliedMigrationsLocal(scopeId: ScopeId): Promise<AppliedMigration[]>;
430
+ /**
431
+ * The oldest not-yet-drained events of this host's own scope (#1334) — the far end of
432
+ * the control plane's `EventDrainDelegation`. Bounded the same way the audited verb is,
433
+ * so a caller cannot ask this side for more than the other would.
434
+ */
435
+ undrainedEventsLocal(scopeId: ScopeId, limit: number): Promise<DrainedEvent[]>;
436
+ /**
437
+ * Stamp `drained_at` on this host's own scope (#1334) — the delegation's other half.
438
+ * The instant is the control plane's, carried through, so the receipt it writes
439
+ * beside its admin row names the same time the rows hold. No audit here: the
440
+ * platform's `markEventsDrained` is the door, and this is what stands behind it.
441
+ */
442
+ markEventsDrainedLocal(scopeId: ScopeId, eventIds: readonly string[], drainedAt: string): Promise<number>;
443
+ /**
444
+ * Reopen this host's own scope's drained rows (#1334) — the delegation's third half.
445
+ * No audit here, as with the stamp: the platform's `redrainEvents` is the door.
446
+ */
447
+ redrainEventsLocal(scopeId: ScopeId, drainedBefore: string): Promise<number>;
377
448
  /**
378
449
  * The PITR bookmarks one scope recorded before its migration passes (#286) — the
379
450
  * rewind points a backout UI offers. Behind the vertical's platform-gated
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAaL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EA2CpB,KAAK,sBAAsB,EAI3B,KAAK,YAAY,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EAAE,WAAW,EACtB,UAAU,EAAE,aAAa,EACzB,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,IAAI,CAAC,CAOf;IAYD,sEAAsE;IAChE,oBAAoB,CACxB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,OAAO,GACd,OAAO,CAAC,OAAO,CAAC,CAGlB;IAED,qFAAqF;IAC/E,8BAA8B,CAClC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAI3B;IAED;;;;;;OAMG;IACG,4BAA4B,CAChC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAYlC;IAED;;;;;;OAMG;IACG,mBAAmB,CACvB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,aAAa,EACzB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAQf;CACF"}
package/dist/host.js CHANGED
@@ -1,6 +1,6 @@
1
- import { fromWireFailure, accessLogEntry, adminLogEntry, opsFailureEntry, opsFailureFingerprint, issueEntry, sweepRunEntry, FRESHNESS_HEARTBEAT_MINUTES, sweepRunsPayload, modelUsageEntry, attachmentRecord, createTenantInput, identityLink, identityPool, createOrgInput, promotionAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding, publishVersionInput, AUTO_ADMISSION_NOTE, registerVerticalInput, vertical as verticalSchema, verticalServingState, verticalChannel, verticalVersion, connection, capabilityGrant, connectionGrant, connectionGrantRecord, connectionSecret, systemGrant, entitlementGrant, entitlementGrantInput, instant, meterReading, subjectRef, createConnectionInput, projectedConnectionGrant, projectedConnectionKey, moduleManifest, org as orgSchema, orgMembership, resolvedIdentity, roleDefinition, scope as scopeSchema, tenant as tenantSchema, tenantRole, subjectShredReceipt, platformRequest, connectorDispatchKind, outboundOfManifestJson, substratError, } from '@substrat-run/contracts';
1
+ import { fromWireFailure, accessLogEntry, adminLogEntry, opsFailureEntry, opsFailureFingerprint, issueEntry, sweepRunEntry, FRESHNESS_HEARTBEAT_MINUTES, sweepRunsPayload, modelUsageEntry, attachmentRecord, createTenantInput, identityLink, identityPool, createOrgInput, promotionAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding, publishVersionInput, AUTO_ADMISSION_NOTE, registerVerticalInput, vertical as verticalSchema, verticalServingState, verticalChannel, verticalVersion, connection, capabilityGrant, connectionGrant, connectionGrantRecord, connectionSecret, systemGrant, entitlementGrant, entitlementGrantInput, instant, meterReading, subjectRef, createConnectionInput, projectedConnectionGrant, projectedConnectionKey, moduleManifest, org as orgSchema, orgMembership, resolvedIdentity, roleDefinition, scope as scopeSchema, tenant as tenantSchema, tenantRole, delegatedReadRecord, subjectShredReceipt, platformRequest, connectorDispatchKind, outboundOfManifestJson, substratError, redrainEventsInput, } from '@substrat-run/contracts';
2
2
  import { normalizeHostname, toRouteTarget } from './route-resolver.js';
3
- import { attachmentBlobKey, entitlementDenial, foldMeterReading, parseValidationRecords, resolveScopeRecord, ulid, foldModelUsage, backoffAt, resolveRetryPolicy, isSecretBoxConfigured, unconfiguredSecretBox, createSubjectKeys, generateSealingKeyPair, openSealed, ImpersonationRefused, assertSessionUsable, impersonationRowValues, mapImpersonationRow, newImpersonationSession, globalFetch, } from '@substrat-run/kernel';
3
+ import { attachmentBlobKey, entitlementDenial, foldMeterReading, parseValidationRecords, resolveScopeRecord, ulid, foldModelUsage, backoffAt, resolveRetryPolicy, isSecretBoxConfigured, unconfiguredSecretBox, createSubjectKeys, generateSealingKeyPair, openSealed, ImpersonationRefused, assertSessionUsable, impersonationRowValues, mapImpersonationRow, newImpersonationSession, globalFetch, assertRedrainWindow, } from '@substrat-run/kernel';
4
4
  import { tenantStoreDatabaseName } from './d1.js';
5
5
  import { blobStoreBucketName, r2TenantBlobStore } from './r2.js';
6
6
  /** DO row → contract shape. Never reads the secrets table — that is the split. */
@@ -110,6 +110,8 @@ export class CloudflareScopeHost {
110
110
  operationEntitlement = new Map();
111
111
  /** #574: remote connector write-back for scopes served by another deployment. */
112
112
  connectorDelegation;
113
+ /** #1334: the Tier-2 drain's reach into the deployment serving a scope. */
114
+ eventDrainDelegation;
113
115
  /**
114
116
  * MUST be constructed per request. Never cache an instance across requests.
115
117
  *
@@ -134,6 +136,7 @@ export class CloudflareScopeHost {
134
136
  ? options.controlPlane.get(options.controlPlane.idFromName('control-plane'))
135
137
  : nullControlPlane();
136
138
  this.connectorDelegation = options.connectorDelegation;
139
+ this.eventDrainDelegation = options.eventDrainDelegation;
137
140
  this.admin = this.buildAdmin();
138
141
  }
139
142
  // -- registration mechanics (validation only) -----------------------------
@@ -505,6 +508,10 @@ export class CloudflareScopeHost {
505
508
  async eventEffectsLocal(scopeId, input) {
506
509
  return this.scopeStub(scopeId).eventEffects(input);
507
510
  }
511
+ /** Everything one call emitted (#1237) on this host's own scope — the vertical-host read. */
512
+ async invocationEventsLocal(scopeId, input) {
513
+ return this.scopeStub(scopeId).invocationEvents(input);
514
+ }
508
515
  /** One event's causal chain (#1237) on this host's own scope — the vertical-host read. */
509
516
  async eventCauseLocal(scopeId, input) {
510
517
  return this.scopeStub(scopeId).eventCause(input);
@@ -517,6 +524,30 @@ export class CloudflareScopeHost {
517
524
  async appliedMigrationsLocal(scopeId) {
518
525
  return this.scopeStub(scopeId).appliedMigrations();
519
526
  }
527
+ /**
528
+ * The oldest not-yet-drained events of this host's own scope (#1334) — the far end of
529
+ * the control plane's `EventDrainDelegation`. Bounded the same way the audited verb is,
530
+ * so a caller cannot ask this side for more than the other would.
531
+ */
532
+ async undrainedEventsLocal(scopeId, limit) {
533
+ return this.scopeStub(scopeId).undrainedEvents(Math.min(Math.max(limit, 1), 1000));
534
+ }
535
+ /**
536
+ * Stamp `drained_at` on this host's own scope (#1334) — the delegation's other half.
537
+ * The instant is the control plane's, carried through, so the receipt it writes
538
+ * beside its admin row names the same time the rows hold. No audit here: the
539
+ * platform's `markEventsDrained` is the door, and this is what stands behind it.
540
+ */
541
+ async markEventsDrainedLocal(scopeId, eventIds, drainedAt) {
542
+ return this.scopeStub(scopeId).markEventsDrained(eventIds, drainedAt);
543
+ }
544
+ /**
545
+ * Reopen this host's own scope's drained rows (#1334) — the delegation's third half.
546
+ * No audit here, as with the stamp: the platform's `redrainEvents` is the door.
547
+ */
548
+ async redrainEventsLocal(scopeId, drainedBefore) {
549
+ return this.scopeStub(scopeId).redrainEvents(drainedBefore);
550
+ }
520
551
  /**
521
552
  * The PITR bookmarks one scope recorded before its migration passes (#286) — the
522
553
  * rewind points a backout UI offers. Behind the vertical's platform-gated
@@ -2256,19 +2287,42 @@ export class CloudflareScopeHost {
2256
2287
  return tables;
2257
2288
  },
2258
2289
  readUndrainedEvents: async (actor, tenantId, scopeId, limit) => {
2259
- await this.scopeRecordForRead(tenantId, scopeId);
2260
- const events = await this.scopeStub(scopeId).undrainedEvents(Math.min(Math.max(limit ?? 200, 1), 1000));
2290
+ const record = await this.scopeRecordForRead(tenantId, scopeId);
2291
+ const bounded = Math.min(Math.max(limit ?? 200, 1), 1000);
2292
+ // #1334: on the shared control plane the scope's outbox is in its vertical's
2293
+ // deployment, and this host's own namespace is the module-less placeholder —
2294
+ // reading it would construct an empty DO and answer "nothing to ship". The
2295
+ // delegation is the reach; the access row below is written either way, so
2296
+ // the branch is invisible to an auditor (K-24).
2297
+ const events = this.eventDrainDelegation && record.vertical
2298
+ ? await this.eventDrainDelegation.readUndrained({
2299
+ tenantId,
2300
+ scopeId,
2301
+ vertical: record.vertical,
2302
+ limit: bounded,
2303
+ })
2304
+ : await this.scopeStub(scopeId).undrainedEvents(bounded);
2261
2305
  await this.recordAccess(actor, 'readUndrainedEvents', { tenantId, scopeId }, { limit }, events.length);
2262
2306
  return events;
2263
2307
  },
2264
2308
  markEventsDrained: async (actor, tenantId, scopeId, eventIds) => {
2265
2309
  // The same refusal the reads carry: a reaped scope's storage is gone, and
2266
2310
  // addressing its DO would construct an empty one to stamp nothing in.
2267
- await this.scopeRecordForRead(tenantId, scopeId);
2311
+ const record = await this.scopeRecordForRead(tenantId, scopeId);
2268
2312
  if (eventIds.length === 0)
2269
2313
  return 0;
2270
2314
  const drainedAt = new Date().toISOString();
2271
- const drained = await this.scopeStub(scopeId).markEventsDrained(eventIds, drainedAt);
2315
+ // Delegated on the same rule as the read above: the stamp has to land where
2316
+ // the rows are, or the next tick reads and ships the same batch again.
2317
+ const drained = this.eventDrainDelegation && record.vertical
2318
+ ? await this.eventDrainDelegation.markDrained({
2319
+ tenantId,
2320
+ scopeId,
2321
+ vertical: record.vertical,
2322
+ eventIds,
2323
+ drainedAt,
2324
+ })
2325
+ : await this.scopeStub(scopeId).markEventsDrained(eventIds, drainedAt);
2272
2326
  // K-24's rule, one tier down (#1334): declaring domain payloads shipped is an
2273
2327
  // EGRESS, and the admin log is where "these events left the platform, at this
2274
2328
  // time, on this actor's say-so" is recorded. `drainAccessLog` audits the same
@@ -2280,6 +2334,44 @@ export class CloudflareScopeHost {
2280
2334
  }
2281
2335
  return drained;
2282
2336
  },
2337
+ redrainEvents: async (actor, tenantId, scopeId, input) => {
2338
+ // The same refusal the stamp carries: a reaped scope's storage is gone, and
2339
+ // addressing its DO would construct an empty one and report nothing reopened.
2340
+ const record = await this.scopeRecordForRead(tenantId, scopeId);
2341
+ const { drainedBefore } = redrainEventsInput.parse(input);
2342
+ // The window rule at the HostAdmin boundary, not only at the control-plane door:
2343
+ // this verb is public, so an in-process caller reaches it without that route. Host
2344
+ // code, so the real clock is the right one to read (the DO host injects none).
2345
+ assertRedrainWindow(drainedBefore, new Date().toISOString());
2346
+ // Audit FIRST, on `rewindScope`'s rule (K-33), because this has the same shape: the
2347
+ // mutation commits in a DO and the row is a separate write afterwards, so a failure
2348
+ // between them left a reopen that had happened with no receipt — and the retry could
2349
+ // not repair it, because the stamps were already clear and a second call returns 0
2350
+ // and writes nothing. The intent row is what cannot be lost that way; the outcome row
2351
+ // below still records how much actually moved. A second egress of a tenant's payloads
2352
+ // is exactly the thing K-24 must not lose track of.
2353
+ await this.recordAdmin(actor, 'redrainEvents', { tenantId, scopeId }, null, {
2354
+ intent: 'redrain',
2355
+ drainedBefore,
2356
+ delegated: Boolean(this.eventDrainDelegation && record.vertical),
2357
+ });
2358
+ // Delegated on the stamp's rule: the rows live in the vertical's deployment, and
2359
+ // clearing stamps in the placeholder namespace would succeed while reopening nothing.
2360
+ const redrained = this.eventDrainDelegation && record.vertical
2361
+ ? await this.eventDrainDelegation.redrain({
2362
+ tenantId,
2363
+ scopeId,
2364
+ vertical: record.vertical,
2365
+ drainedBefore,
2366
+ })
2367
+ : await this.scopeStub(scopeId).redrainEvents(drainedBefore);
2368
+ // The outcome beside the intent above — only when something changed, so a re-run over
2369
+ // a window already reopened adds no row claiming it moved anything.
2370
+ if (redrained > 0) {
2371
+ await this.recordAdmin(actor, 'redrainEvents', { tenantId, scopeId }, null, { redrained, drainedBefore });
2372
+ }
2373
+ return redrained;
2374
+ },
2283
2375
  facetEvents: async (actor, tenantId, scopeId, input) => {
2284
2376
  await this.scopeRecordForRead(tenantId, scopeId);
2285
2377
  const result = await this.scopeStub(scopeId).facetEvents(input);
@@ -2307,6 +2399,13 @@ export class CloudflareScopeHost {
2307
2399
  await this.recordAccess(actor, 'eventEffects', { tenantId, scopeId }, { eventId: input.eventId }, tree.count);
2308
2400
  return tree;
2309
2401
  },
2402
+ invocationEvents: async (actor, tenantId, scopeId, input) => {
2403
+ // K-3 cross-check on the directory BEFORE the scope DO, like every read here.
2404
+ await this.scopeRecordForRead(tenantId, scopeId);
2405
+ const read = await this.scopeStub(scopeId).invocationEvents(input);
2406
+ await this.recordAccess(actor, 'invocationEvents', { tenantId, scopeId }, { invocationId: input.invocationId }, read.events.length);
2407
+ return read;
2408
+ },
2310
2409
  readScopeTable: async (actor, tenantId, scopeId, input) => {
2311
2410
  await this.scopeRecordForRead(tenantId, scopeId);
2312
2411
  const page = await this.scopeStub(scopeId).introspectTable(input.table, input.limit, input.offset);
@@ -2381,7 +2480,34 @@ export class CloudflareScopeHost {
2381
2480
  // Also from `provisioning`: a scope whose provisioning never completed (a failed
2382
2481
  // create) must be abandonable, or its slug is stranded forever.
2383
2482
  transitionScope(actor, 'archiveScope', tenantId, scopeId, ['provisioning', 'active', 'suspended'], 'archived'),
2384
- unarchiveScope: async (actor, tenantId, scopeId) => transitionScope(actor, 'unarchiveScope', tenantId, scopeId, ['archived'], 'active'),
2483
+ unarchiveScope: async (actor, tenantId, scopeId) => {
2484
+ // An archived scope is outside `fanOut`'s status filter (#1386), so every
2485
+ // tenant-level revoke that landed while it sat archived never reached its local
2486
+ // projection — and a bare flip would put that stale projection back on duty:
2487
+ // a principal removed from the tenant meanwhile keeps their access on the
2488
+ // unarchived scope until the next fan-out or sweep (#1473). So the flip is
2489
+ // preceded by a push of the tenant's CURRENT state into this one scope.
2490
+ //
2491
+ // Push BEFORE the flip, deliberately. A push that throws then leaves the scope
2492
+ // archived — where the coordinator already fails closed and the operator simply
2493
+ // retries — rather than active behind a projection nobody refreshed. And the
2494
+ // order is safe in every state the flip would refuse: on a live scope the push
2495
+ // is one idempotent write, and on a reaped scope the DO drops it (the reaped
2496
+ // marker survives `deleteAll()`), so nothing is resurrected.
2497
+ await this.projectScope(tenantId, scopeId);
2498
+ await transitionScope(actor, 'unarchiveScope', tenantId, scopeId, ['archived'], 'active');
2499
+ // And push AGAIN after it. The first push is a snapshot, and the directory does
2500
+ // not stop for it: a revoke that commits between that snapshot's read and the
2501
+ // flip fans out to every scope that is live at that moment — which this one is
2502
+ // not yet — so its own fan-out misses this scope and the flip puts the older
2503
+ // snapshot on duty. Once flipped, the scope is inside every later fan-out's
2504
+ // set, and a read taken now holds everything that committed before it; the
2505
+ // two together close the window, the way `fanOut` includes `provisioning`
2506
+ // scopes beside their own pull rather than leaving a gap between the two.
2507
+ // What remains is the race every pair of concurrent fan-outs has — snapshots
2508
+ // can land out of order — and the reconciliation sweep is what repairs that.
2509
+ await this.projectScope(tenantId, scopeId);
2510
+ },
2385
2511
  reapScope: async (actor, tenantId, scopeId, opts) => {
2386
2512
  // Reap an ARCHIVED scope's DO storage (Cloudflare never GCs a DO) while keeping
2387
2513
  // the directory row as a tombstone (§4.4). Storage BEFORE the status flip, the
@@ -2769,6 +2895,18 @@ export class CloudflareScopeHost {
2769
2895
  return undefined;
2770
2896
  return resolvedIdentity.parse({ principal: row.principal, scopeId: row.scopeId });
2771
2897
  },
2898
+ /**
2899
+ * #1357: the K-24 row for a read this control plane delegated to a vertical.
2900
+ *
2901
+ * Routed through the SAME `recordAccess` the co-located branch uses rather than
2902
+ * writing the table directly — the id, the timestamp and the param truncation are
2903
+ * that helper's, so a delegated row and a co-located one are indistinguishable,
2904
+ * which is the point of the seam.
2905
+ */
2906
+ recordDelegatedRead: async (actor, record) => {
2907
+ const parsed = delegatedReadRecord.parse(record);
2908
+ await this.recordAccess(actor, parsed.method, { tenantId: parsed.tenantId, scopeId: parsed.scopeId }, parsed.params, parsed.resultCount);
2909
+ },
2772
2910
  accessLog: async (actor, filter) => {
2773
2911
  const rows = await this.cp.accessLog({
2774
2912
  actor: filter?.actor,
@@ -3004,6 +3142,7 @@ export class CloudflareScopeHost {
3004
3142
  if (row.status === 'reaped') {
3005
3143
  throw new Error(`scope ${scopeId} is reaped — its storage is gone and cannot be read`);
3006
3144
  }
3145
+ return row;
3007
3146
  }
3008
3147
  /**
3009
3148
  * This scope's per-subject keys (#37). The crypto lives in the kernel