@substrat-run/adapter-cloudflare 0.110.0 → 0.112.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 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 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,36 @@ 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
+ }
74
104
  export interface CloudflareScopeHostOptions {
75
105
  scope: DurableObjectNamespace;
76
106
  /**
@@ -142,6 +172,13 @@ export interface CloudflareScopeHostOptions {
142
172
  * locally.
143
173
  */
144
174
  connectorDelegation?: ConnectorDelegation;
175
+ /**
176
+ * #1334: route the Tier-2 drain's read and stamp to the deployment actually serving
177
+ * the scope. Set only on the shared control plane's host, exactly like
178
+ * `connectorDelegation` and for the same reason — its own `SCOPE` namespace holds no
179
+ * hosted scope's outbox. A vertical's own host leaves it unset and reads locally.
180
+ */
181
+ eventDrainDelegation?: EventDrainDelegation;
145
182
  /**
146
183
  * **There is deliberately no `clock` here** (#956), and the absence is the fact.
147
184
  *
@@ -222,6 +259,8 @@ export declare class CloudflareScopeHost implements ScopeHost {
222
259
  private readonly operationEntitlement;
223
260
  /** #574: remote connector write-back for scopes served by another deployment. */
224
261
  private readonly connectorDelegation?;
262
+ /** #1334: the Tier-2 drain's reach into the deployment serving a scope. */
263
+ private readonly eventDrainDelegation?;
225
264
  /**
226
265
  * MUST be constructed per request. Never cache an instance across requests.
227
266
  *
@@ -366,10 +405,27 @@ export declare class CloudflareScopeHost implements ScopeHost {
366
405
  exportScopeLocal(scopeId: ScopeId): Promise<ScopeDumpTable[]>;
367
406
  /** Facet this host's own scope's outbox (#1239) — the vertical-host read. */
368
407
  facetEventsLocal(scopeId: ScopeId, input: EventFacetInput): Promise<EventFacetResult>;
408
+ /** What one event set off (#1237) on this host's own scope — the vertical-host read. */
409
+ eventEffectsLocal(scopeId: ScopeId, input: EventEffectsInput): Promise<EffectsTree>;
410
+ /** One event's causal chain (#1237) on this host's own scope — the vertical-host read. */
411
+ eventCauseLocal(scopeId: ScopeId, input: EventCauseInput): Promise<CauseChain>;
369
412
  /** One record's event history (#1235) on this host's own scope — the vertical-host read. */
370
413
  entityHistoryLocal(scopeId: ScopeId, input: EntityHistoryInput): Promise<Page<HistoryEntry>>;
371
414
  /** When this host's own scope applied each migration (#1236) — the vertical-host read. */
372
415
  appliedMigrationsLocal(scopeId: ScopeId): Promise<AppliedMigration[]>;
416
+ /**
417
+ * The oldest not-yet-drained events of this host's own scope (#1334) — the far end of
418
+ * the control plane's `EventDrainDelegation`. Bounded the same way the audited verb is,
419
+ * so a caller cannot ask this side for more than the other would.
420
+ */
421
+ undrainedEventsLocal(scopeId: ScopeId, limit: number): Promise<DrainedEvent[]>;
422
+ /**
423
+ * Stamp `drained_at` on this host's own scope (#1334) — the delegation's other half.
424
+ * The instant is the control plane's, carried through, so the receipt it writes
425
+ * beside its admin row names the same time the rows hold. No audit here: the
426
+ * platform's `markEventsDrained` is the door, and this is what stands behind it.
427
+ */
428
+ markEventsDrainedLocal(scopeId: ScopeId, eventIds: readonly string[], drainedAt: string): Promise<number>;
373
429
  /**
374
430
  * The PITR bookmarks one scope recorded before its migration passes (#286) — the
375
431
  * 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,EAEjB,KAAK,QAAQ,EASb,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,IAAI,EAET,KAAK,gBAAgB,EAOrB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAKd,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAI1B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,EAQhB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAExB,KAAK,cAAc,EAGnB,KAAK,SAAS,EACd,KAAK,cAAc,EAGnB,KAAK,OAAO,EAIZ,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,i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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,4 +1,4 @@
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, } from '@substrat-run/contracts';
2
2
  import { normalizeHostname, toRouteTarget } from './route-resolver.js';
3
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';
4
4
  import { tenantStoreDatabaseName } from './d1.js';
@@ -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) -----------------------------
@@ -501,6 +504,14 @@ export class CloudflareScopeHost {
501
504
  async facetEventsLocal(scopeId, input) {
502
505
  return this.scopeStub(scopeId).facetEvents(input);
503
506
  }
507
+ /** What one event set off (#1237) on this host's own scope — the vertical-host read. */
508
+ async eventEffectsLocal(scopeId, input) {
509
+ return this.scopeStub(scopeId).eventEffects(input);
510
+ }
511
+ /** One event's causal chain (#1237) on this host's own scope — the vertical-host read. */
512
+ async eventCauseLocal(scopeId, input) {
513
+ return this.scopeStub(scopeId).eventCause(input);
514
+ }
504
515
  /** One record's event history (#1235) on this host's own scope — the vertical-host read. */
505
516
  async entityHistoryLocal(scopeId, input) {
506
517
  return this.scopeStub(scopeId).entityHistory(input);
@@ -509,6 +520,23 @@ export class CloudflareScopeHost {
509
520
  async appliedMigrationsLocal(scopeId) {
510
521
  return this.scopeStub(scopeId).appliedMigrations();
511
522
  }
523
+ /**
524
+ * The oldest not-yet-drained events of this host's own scope (#1334) — the far end of
525
+ * the control plane's `EventDrainDelegation`. Bounded the same way the audited verb is,
526
+ * so a caller cannot ask this side for more than the other would.
527
+ */
528
+ async undrainedEventsLocal(scopeId, limit) {
529
+ return this.scopeStub(scopeId).undrainedEvents(Math.min(Math.max(limit, 1), 1000));
530
+ }
531
+ /**
532
+ * Stamp `drained_at` on this host's own scope (#1334) — the delegation's other half.
533
+ * The instant is the control plane's, carried through, so the receipt it writes
534
+ * beside its admin row names the same time the rows hold. No audit here: the
535
+ * platform's `markEventsDrained` is the door, and this is what stands behind it.
536
+ */
537
+ async markEventsDrainedLocal(scopeId, eventIds, drainedAt) {
538
+ return this.scopeStub(scopeId).markEventsDrained(eventIds, drainedAt);
539
+ }
512
540
  /**
513
541
  * The PITR bookmarks one scope recorded before its migration passes (#286) — the
514
542
  * rewind points a backout UI offers. Behind the vertical's platform-gated
@@ -2248,19 +2276,42 @@ export class CloudflareScopeHost {
2248
2276
  return tables;
2249
2277
  },
2250
2278
  readUndrainedEvents: async (actor, tenantId, scopeId, limit) => {
2251
- await this.scopeRecordForRead(tenantId, scopeId);
2252
- const events = await this.scopeStub(scopeId).undrainedEvents(Math.min(Math.max(limit ?? 200, 1), 1000));
2279
+ const record = await this.scopeRecordForRead(tenantId, scopeId);
2280
+ const bounded = Math.min(Math.max(limit ?? 200, 1), 1000);
2281
+ // #1334: on the shared control plane the scope's outbox is in its vertical's
2282
+ // deployment, and this host's own namespace is the module-less placeholder —
2283
+ // reading it would construct an empty DO and answer "nothing to ship". The
2284
+ // delegation is the reach; the access row below is written either way, so
2285
+ // the branch is invisible to an auditor (K-24).
2286
+ const events = this.eventDrainDelegation && record.vertical
2287
+ ? await this.eventDrainDelegation.readUndrained({
2288
+ tenantId,
2289
+ scopeId,
2290
+ vertical: record.vertical,
2291
+ limit: bounded,
2292
+ })
2293
+ : await this.scopeStub(scopeId).undrainedEvents(bounded);
2253
2294
  await this.recordAccess(actor, 'readUndrainedEvents', { tenantId, scopeId }, { limit }, events.length);
2254
2295
  return events;
2255
2296
  },
2256
2297
  markEventsDrained: async (actor, tenantId, scopeId, eventIds) => {
2257
2298
  // The same refusal the reads carry: a reaped scope's storage is gone, and
2258
2299
  // addressing its DO would construct an empty one to stamp nothing in.
2259
- await this.scopeRecordForRead(tenantId, scopeId);
2300
+ const record = await this.scopeRecordForRead(tenantId, scopeId);
2260
2301
  if (eventIds.length === 0)
2261
2302
  return 0;
2262
2303
  const drainedAt = new Date().toISOString();
2263
- const drained = await this.scopeStub(scopeId).markEventsDrained(eventIds, drainedAt);
2304
+ // Delegated on the same rule as the read above: the stamp has to land where
2305
+ // the rows are, or the next tick reads and ships the same batch again.
2306
+ const drained = this.eventDrainDelegation && record.vertical
2307
+ ? await this.eventDrainDelegation.markDrained({
2308
+ tenantId,
2309
+ scopeId,
2310
+ vertical: record.vertical,
2311
+ eventIds,
2312
+ drainedAt,
2313
+ })
2314
+ : await this.scopeStub(scopeId).markEventsDrained(eventIds, drainedAt);
2264
2315
  // K-24's rule, one tier down (#1334): declaring domain payloads shipped is an
2265
2316
  // EGRESS, and the admin log is where "these events left the platform, at this
2266
2317
  // time, on this actor's say-so" is recorded. `drainAccessLog` audits the same
@@ -2285,6 +2336,20 @@ export class CloudflareScopeHost {
2285
2336
  await this.recordAccess(actor, 'entityHistory', { tenantId, scopeId }, { entityType: input.entityType, entityId: input.entityId }, page.entries.length);
2286
2337
  return page;
2287
2338
  },
2339
+ eventCause: async (actor, tenantId, scopeId, input) => {
2340
+ // K-3 cross-check on the directory BEFORE the scope DO, like every read here.
2341
+ await this.scopeRecordForRead(tenantId, scopeId);
2342
+ const result = await this.scopeStub(scopeId).eventCause(input);
2343
+ await this.recordAccess(actor, 'eventCause', { tenantId, scopeId }, { eventId: input.eventId }, result.chain.length);
2344
+ return result;
2345
+ },
2346
+ eventEffects: async (actor, tenantId, scopeId, input) => {
2347
+ // K-3 cross-check on the directory BEFORE the scope DO, like every read here.
2348
+ await this.scopeRecordForRead(tenantId, scopeId);
2349
+ const tree = await this.scopeStub(scopeId).eventEffects(input);
2350
+ await this.recordAccess(actor, 'eventEffects', { tenantId, scopeId }, { eventId: input.eventId }, tree.count);
2351
+ return tree;
2352
+ },
2288
2353
  readScopeTable: async (actor, tenantId, scopeId, input) => {
2289
2354
  await this.scopeRecordForRead(tenantId, scopeId);
2290
2355
  const page = await this.scopeStub(scopeId).introspectTable(input.table, input.limit, input.offset);
@@ -2359,7 +2424,34 @@ export class CloudflareScopeHost {
2359
2424
  // Also from `provisioning`: a scope whose provisioning never completed (a failed
2360
2425
  // create) must be abandonable, or its slug is stranded forever.
2361
2426
  transitionScope(actor, 'archiveScope', tenantId, scopeId, ['provisioning', 'active', 'suspended'], 'archived'),
2362
- unarchiveScope: async (actor, tenantId, scopeId) => transitionScope(actor, 'unarchiveScope', tenantId, scopeId, ['archived'], 'active'),
2427
+ unarchiveScope: async (actor, tenantId, scopeId) => {
2428
+ // An archived scope is outside `fanOut`'s status filter (#1386), so every
2429
+ // tenant-level revoke that landed while it sat archived never reached its local
2430
+ // projection — and a bare flip would put that stale projection back on duty:
2431
+ // a principal removed from the tenant meanwhile keeps their access on the
2432
+ // unarchived scope until the next fan-out or sweep (#1473). So the flip is
2433
+ // preceded by a push of the tenant's CURRENT state into this one scope.
2434
+ //
2435
+ // Push BEFORE the flip, deliberately. A push that throws then leaves the scope
2436
+ // archived — where the coordinator already fails closed and the operator simply
2437
+ // retries — rather than active behind a projection nobody refreshed. And the
2438
+ // order is safe in every state the flip would refuse: on a live scope the push
2439
+ // is one idempotent write, and on a reaped scope the DO drops it (the reaped
2440
+ // marker survives `deleteAll()`), so nothing is resurrected.
2441
+ await this.projectScope(tenantId, scopeId);
2442
+ await transitionScope(actor, 'unarchiveScope', tenantId, scopeId, ['archived'], 'active');
2443
+ // And push AGAIN after it. The first push is a snapshot, and the directory does
2444
+ // not stop for it: a revoke that commits between that snapshot's read and the
2445
+ // flip fans out to every scope that is live at that moment — which this one is
2446
+ // not yet — so its own fan-out misses this scope and the flip puts the older
2447
+ // snapshot on duty. Once flipped, the scope is inside every later fan-out's
2448
+ // set, and a read taken now holds everything that committed before it; the
2449
+ // two together close the window, the way `fanOut` includes `provisioning`
2450
+ // scopes beside their own pull rather than leaving a gap between the two.
2451
+ // What remains is the race every pair of concurrent fan-outs has — snapshots
2452
+ // can land out of order — and the reconciliation sweep is what repairs that.
2453
+ await this.projectScope(tenantId, scopeId);
2454
+ },
2363
2455
  reapScope: async (actor, tenantId, scopeId, opts) => {
2364
2456
  // Reap an ARCHIVED scope's DO storage (Cloudflare never GCs a DO) while keeping
2365
2457
  // the directory row as a tombstone (§4.4). Storage BEFORE the status flip, the
@@ -2747,6 +2839,18 @@ export class CloudflareScopeHost {
2747
2839
  return undefined;
2748
2840
  return resolvedIdentity.parse({ principal: row.principal, scopeId: row.scopeId });
2749
2841
  },
2842
+ /**
2843
+ * #1357: the K-24 row for a read this control plane delegated to a vertical.
2844
+ *
2845
+ * Routed through the SAME `recordAccess` the co-located branch uses rather than
2846
+ * writing the table directly — the id, the timestamp and the param truncation are
2847
+ * that helper's, so a delegated row and a co-located one are indistinguishable,
2848
+ * which is the point of the seam.
2849
+ */
2850
+ recordDelegatedRead: async (actor, record) => {
2851
+ const parsed = delegatedReadRecord.parse(record);
2852
+ await this.recordAccess(actor, parsed.method, { tenantId: parsed.tenantId, scopeId: parsed.scopeId }, parsed.params, parsed.resultCount);
2853
+ },
2750
2854
  accessLog: async (actor, filter) => {
2751
2855
  const rows = await this.cp.accessLog({
2752
2856
  actor: filter?.actor,
@@ -2982,6 +3086,7 @@ export class CloudflareScopeHost {
2982
3086
  if (row.status === 'reaped') {
2983
3087
  throw new Error(`scope ${scopeId} is reaped — its storage is gone and cannot be read`);
2984
3088
  }
3089
+ return row;
2985
3090
  }
2986
3091
  /**
2987
3092
  * This scope's per-subject keys (#37). The crypto lives in the kernel