@substrat-run/adapter-cloudflare 0.209.0 → 0.211.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.
@@ -27,7 +27,17 @@ export interface KickCoalescerConfig<Env> {
27
27
  * authority lives: the deployment runs `runCrossVerticalFrom` here with the same reach and
28
28
  * gates as its sweep, so this object decides only WHEN, never what or for whom.
29
29
  */
30
- run(env: Env, producer: KickProducer): Promise<void>;
30
+ run(env: Env, producer: KickProducer): Promise<void | {
31
+ more?: boolean;
32
+ }>;
33
+ /**
34
+ * #3365: every pass runs from the alarm, never inside the kick. A kick only marks the producer
35
+ * dirty and arms the alarm (at once when no pass started within the window), so a pass is never
36
+ * bound by its caller's lifetime — a router's `waitUntil`, which cut a drain off at ~30 s and
37
+ * cancelled the connector call in flight. Default false: the kick runs the pass it starts, as the
38
+ * cross-vertical kick always has.
39
+ */
40
+ passesFromAlarm?: boolean;
31
41
  /** A pass that threw. Never rethrown: a lost kick costs latency, and the sweep is the backstop. */
32
42
  onError?(err: unknown, env: Env): void;
33
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"kick-coalescer-do.d.ts","sourceRoot":"","sources":["../src/kick-coalescer-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,OAAQ,CAAC;AAEnD,kGAAkG;AAClG,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,WAAW,GAAG,UAAU,CAAC;AAE3D,8FAA8F;AAC9F,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,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O,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAClE;AAED,MAAM,WAAW,mBAAmB,CAAC,GAAG;IACtC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,GAAG;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC1E;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mGAAmG;IACnG,OAAO,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;CACxC;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAE9E;AAUD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EACvC,MAAM,EAAE,mBAAmB,CAAC,GAAG,CAAC,GAC/B,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,KAAK,aAAa,CAAC,GAAG,CAAC,GAAG,eAAe,CA8EjF"}
@@ -43,7 +43,7 @@ export function defineKickCoalescerDO(config) {
43
43
  return 'coalesced';
44
44
  }
45
45
  const now = Date.now();
46
- if (now - state.lastStartedAt < windowMs) {
46
+ if (config.passesFromAlarm || now - state.lastStartedAt < windowMs) {
47
47
  await this.ctx.storage.put('state', { ...state, dirty: true });
48
48
  await this.#armFor(state.lastStartedAt);
49
49
  return 'deferred';
@@ -78,7 +78,14 @@ export function defineKickCoalescerDO(config) {
78
78
  await this.ctx.storage.put('state', { ...state, lastStartedAt: startedAt, dirty: false });
79
79
  this.#running = (async () => {
80
80
  try {
81
- await config.run(this.env, state.producer);
81
+ const outcome = await config.run(this.env, state.producer);
82
+ // #3365: the pass stopped with work left (a deadline, its last round). Dirty again, so
83
+ // the alarm at this window's end runs the next one, and so on until a pass finishes.
84
+ if (outcome && outcome.more) {
85
+ const now = await this.ctx.storage.get('state');
86
+ if (now)
87
+ await this.ctx.storage.put('state', { ...now, dirty: true });
88
+ }
82
89
  }
83
90
  catch (err) {
84
91
  config.onError?.(err, this.env);
@@ -1 +1 @@
1
- {"version":3,"file":"kick-coalescer-do.js","sourceRoot":"","sources":["../src/kick-coalescer-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,KAAK,CAAC;AA8BnD,oGAAoG;AACpG,MAAM,UAAU,iBAAiB,CAAC,QAAkB,EAAE,OAAgB;IACpE,OAAO,GAAG,QAAQ,IAAI,OAAO,EAAE,CAAC;AAClC,CAAC;AAUD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAAgC;IAEhC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,6BAA6B,CAAC;IAClE,OAAO,MAAM,eAAgB,SAAQ,aAAkB;QACrD,+CAA+C;QAC/C,QAAQ,GAAyB,IAAI,CAAC;QAEtC,KAAK,CAAC,IAAI,CAAC,QAAkB,EAAE,OAAgB;YAC7C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAY,OAAO,CAAC,CAAC;YAC7D,MAAM,KAAK,GAAc,KAAK,IAAI,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;YACtG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,IAAI,E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G,IAAI,CAAA;KAAE,EAAE,CAAC;IACvG,cAAc,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAClG,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AA8lBjG,kGAAkG;AAClG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAQxD;AAgQD;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AAmBtD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CAOxD;AAED,gHAAgH;AAChH,OAAO,EAAE,kBAAkB,EAAE,CAAC;AA2B9B,wBAAgB,aAAa,CAC3B,OAAO,EAAE,kBAAkB,EAAE,EAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACzD;;;;GAIG;AACH,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,mBAAmB,CAAA;CAAO,GAClD,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,UAAU,KAAK,aAAa,CAAC,UAAU,CAAC,CAu9R7E"}
package/dist/scope-do.js CHANGED
@@ -8,7 +8,7 @@ import { replyOf } from './do-reply.js';
8
8
  import { OperationQueue } from './serialization.js';
9
9
  import { meterScopeWorkEntries, ScopeWorkMeter } from './scope-work.js';
10
10
  import { assertNoWorkerdStorage, doScopedSql, doBuiltColumnsOf, doRedactionSql, doSpineSql } from './sql.js';
11
- import { actorOf, admitPeer, boundToPeerDeclarations, collectPeers, switchPeer, peerSubjectRef, subjectGrantState, assertNoSecret, CAPABILITY_DDL, UPLOAD_LINK_DDL, DOWNLOAD_LINK_DDL, createAttachmentVerbs, inspectUploadLink, resolveDownloadLink, redeemUploadLinkInTransaction, COPY_ORIGIN_DDL, ENTITY_STATE_MOVES_DDL, SWITCH_FENCES_DDL, TABLE_OWNERS_DDL, assertMigrationLeavesLedgerAlone, recordOwnershipSteps, runMigrationStatements, splitSqlStatements, executableSqlStatements, blankSqlComments, CAPABILITY_EXCHANGE_OPERATION, CAPABILITY_BECOME_MINT_OPERATION, becomeMintCheck, mintBecomeCapabilityAsPrincipal, CAPABILITY_BIND_MINT_OPERATION, bindLinkMintCheck, mintBindLinkAsPrincipal, revokeBecomeCapabilityAsPrincipal, readBecomeLinkStates, ENTITY_UNBIND_OPERATION, allowedFor, unbindEntityHolderBounded, capabilityAttachmentWriteRefused, createCapabilityVerbs, createEntityEdgeVerbs, createEntityStateVerbs, createTrashedReads, CONTINUATION_POSITION_CAP, visibleContinuation, searchStateWhere, uncheckedView, addStatePlans, addUpdatedStampPlans, watchUpdatedStamps, assertNoCallerPurge, isUnreachableParent, PURGE_BATCH, heldPurgePass, lifecycleRefusal, purgeHeldBy, assertPlatformRequestRoom, purgeDueOf, purgeOnlyKeysOf, runPurgePass, refuseTrashedTarget, assertBoundOperations, checkHeldOperationsOf, countChecks, noteUncheckedCompletion, registerTrashTargets, withheldKeysFor, capCoverage, delegationCeilingOf, delegationStampOf, outsideCeiling, parseScopeDelegation, statefulTablesOf, afterMigration, afterRuntimeDdl, derivesAnything, repairDerivedObjects, StateColumnLost, exchangeCapability, exchangeBecomeLinkById, guardSecrets, mintBecomeCapability, redactSecrets, redactSecretText, moduleLog, asyncInvocationId, asyncLinePass, resolveCapabilitySession, revokeCapabilityAsPlatform, readCapabilityPage, domainEventOf, facetEvents, readDeadLetters, readLifecycleFlow, readOperationSeries, readHistory, readInvocation, readUndrainedOutbox, walkEventCause, walkEventEffects, } from '@substrat-run/kernel';
11
+ import { actorOf, admitPeer, boundToPeerDeclarations, collectPeers, switchPeer, peerSubjectRef, subjectGrantState, assertNoSecret, CAPABILITY_DDL, UPLOAD_LINK_DDL, DOWNLOAD_LINK_DDL, createAttachmentVerbs, inspectUploadLink, resolveDownloadLink, redeemUploadLinkInTransaction, COPY_ORIGIN_DDL, ENTITY_STATE_MOVES_DDL, SWITCH_FENCES_DDL, TABLE_OWNERS_DDL, assertMigrationLeavesLedgerAlone, recordOwnershipSteps, runMigrationStatements, splitSqlStatements, executableSqlStatements, blankSqlComments, CAPABILITY_EXCHANGE_OPERATION, CAPABILITY_BECOME_MINT_OPERATION, becomeMintCheck, mintBecomeCapabilityAsPrincipal, CAPABILITY_BIND_MINT_OPERATION, bindLinkMintCheck, mintBindLinkAsPrincipal, revokeBecomeCapabilityAsPrincipal, readBecomeLinkStates, ENTITY_UNBIND_OPERATION, allowedFor, unbindEntityHolderBounded, capabilityAttachmentWriteRefused, createCapabilityVerbs, createEntityEdgeVerbs, createEntityStateVerbs, createTrashedReads, CONTINUATION_POSITION_CAP, visibleContinuation, searchStateWhere, uncheckedView, addStatePlans, addUpdatedStampPlans, watchUpdatedStamps, assertNoCallerPurge, isUnreachableParent, PURGE_BATCH, heldPurgePass, lifecycleRefusal, purgeHeldBy, assertPlatformRequestRoom, CONNECTOR_DISPATCH_REQUESTED_BY, MAX_PENDING_CONNECTOR_DISPATCHES, purgeDueOf, purgeOnlyKeysOf, runPurgePass, refuseTrashedTarget, assertBoundOperations, checkHeldOperationsOf, countChecks, noteUncheckedCompletion, registerTrashTargets, withheldKeysFor, capCoverage, delegationCeilingOf, delegationStampOf, outsideCeiling, parseScopeDelegation, statefulTablesOf, afterMigration, afterRuntimeDdl, derivesAnything, repairDerivedObjects, StateColumnLost, exchangeCapability, exchangeBecomeLinkById, guardSecrets, mintBecomeCapability, redactSecrets, redactSecretText, moduleLog, asyncInvocationId, asyncLinePass, resolveCapabilitySession, revokeCapabilityAsPlatform, readCapabilityPage, domainEventOf, facetEvents, readDeadLetters, readLifecycleFlow, readOperationSeries, readHistory, readInvocation, readUndrainedOutbox, walkEventCause, walkEventEffects, } from '@substrat-run/kernel';
12
12
  import { COPY_RESTORE_FENCE_LAPSED, copyRestoreFenceLapsed, orphanSweepVersionRefusal } from '@substrat-run/kernel';
13
13
  import { createDoTupleChecker, createLocalControlPlaneReader, scopeTupleReader } from './checker.js';
14
14
  import { settlePlatformRequestIn } from '@substrat-run/kernel';
@@ -4465,6 +4465,18 @@ options = {}) {
4465
4465
  }
4466
4466
  });
4467
4467
  }
4468
+ /**
4469
+ * What a principal holds in this scope (#3360): the checker's own `holdings`, so it reads the
4470
+ * tuples a check walks, tenant-level ones included. `null` when the checker cannot answer.
4471
+ * Queued like a check, so it never sees a half-applied operation. A read for presentation
4472
+ * (which tools `mountMcp` lists); every invoke still checks.
4473
+ */
4474
+ async principalHoldings(principal, tenantId, scopeId) {
4475
+ if (!this.checker.holdings)
4476
+ return null;
4477
+ await this.ensureMigrations();
4478
+ return this.queue.enqueue(() => this.checker.holdings({ kind: 'principal', id: principal }, { tenantId, scopeId }));
4479
+ }
4468
4480
  /**
4469
4481
  * Where every peer this scope holds or has held grants for stands (#1706) — the
4470
4482
  * kernel's `peerGrantsStatus`, over this DO's own storage, and the same plain
@@ -5510,9 +5522,15 @@ options = {}) {
5510
5522
  * One verb, not two, so the intent insert and the delivery journal commit together:
5511
5523
  * everything here is synchronous SQL in a single RPC, so a crash leaves either both
5512
5524
  * writes or neither, never an intent without its journal row (which would re-route
5513
- * the event on the next drain). Backpressure throws BEFORE any write — the caller
5514
- * records a failed attempt and the delivery retries on its own backoff, exactly as
5515
- * a throwing handler would.
5525
+ * the event on the next drain).
5526
+ *
5527
+ * #3365: a full journal answers `null` BEFORE any write, and that is not an attempt: the
5528
+ * delivery stays due (no journal row moves), the caller stops routing for its pass and asks
5529
+ * for a drain, and the next pass after the drain has made room routes it. It used to throw,
5530
+ * and the caller recorded a failed attempt with backoff, so under the default policy a
5531
+ * backlog behind 32 pending intents was dead-lettered in seconds, before any drain ran. Room
5532
+ * is counted over the routed deliveries alone (`MAX_PENDING_CONNECTOR_DISPATCHES`): module
5533
+ * intents and `sweep-runs` reports no longer take a delivery's slot, nor it theirs.
5516
5534
  *
5517
5535
  * `invocationId` is LAST, and defaulted, for the RPC-skew reason `recordExecutorAttempt`
5518
5536
  * states at length.
@@ -5525,10 +5543,8 @@ options = {}) {
5525
5543
  * so leaving it null would make the column read "no call" for the common case.
5526
5544
  */
5527
5545
  invocationId = null) {
5528
- const pending = Number(this.sql
5529
- .exec(`SELECT COUNT(*) AS c FROM _substrat_platform_requests WHERE status = 'pending'`)
5530
- .toArray()[0].c);
5531
- assertPlatformRequestRoom(pending, 'the delivery retries once some have drained');
5546
+ if (this.pendingConnectorDispatches() >= MAX_PENDING_CONNECTOR_DISPATCHES)
5547
+ return null;
5532
5548
  const id = platformRequestId.parse(ulid());
5533
5549
  // K-42: the intent inherits the SOURCE EVENT's stamp rather than being written
5534
5550
  // unstamped. Nobody is impersonating at this moment — the drain runs long after
@@ -5545,6 +5561,40 @@ options = {}) {
5545
5561
  this.recordExecutorAttempt(eventId, deliveryId, null, null, invocationId);
5546
5562
  return id;
5547
5563
  }
5564
+ /** #3365: the routed connector deliveries this scope holds pending — their own room. */
5565
+ pendingConnectorDispatches() {
5566
+ return Number(this.sql
5567
+ .exec(`SELECT COUNT(*) AS c FROM _substrat_platform_requests WHERE status = 'pending' AND requested_by = ?`, CONNECTOR_DISPATCH_REQUESTED_BY)
5568
+ .toArray()[0].c);
5569
+ }
5570
+ /**
5571
+ * #3365: re-drive one connector intent the drain settled `failed` — a give-up at the attempt
5572
+ * ceiling, or a refusal the cause of which has since been fixed (a connection connected, a
5573
+ * provider's 4xx answered). Back to `pending` with its attempts at zero, so the ceiling is a
5574
+ * fresh one; its last error stays until the next settle replaces it. Only a `connector:`
5575
+ * kind: re-running another kind's intent (a provision, an archive) is not a retry a person
5576
+ * can judge from a journal row. Answers whether a row moved.
5577
+ */
5578
+ retryPlatformRequest(id) {
5579
+ return (this.sql.exec(`UPDATE _substrat_platform_requests
5580
+ SET status = 'pending', attempts = 0, settled_at = NULL
5581
+ WHERE id = ? AND status = 'failed' AND kind LIKE 'connector:%'`, id).rowsWritten > 0);
5582
+ }
5583
+ /**
5584
+ * #3365: re-drive one executor delivery that is dead-lettered — exhausted, or journaled before
5585
+ * a full intent journal stopped counting as an attempt. Due now with its attempts at zero, so
5586
+ * the next drain of this scope runs (or routes) it under a fresh policy. Only an executor's
5587
+ * row, and only a dead one: a pending delivery is already due, and a delivered one is not
5588
+ * repeated. A refusal (#1184) and an inert row (#2005) are dead letters too, and re-driving
5589
+ * one asks its handler again, which is what a person pressing it means. Answers whether a row moved.
5590
+ */
5591
+ retryExecutorDelivery(eventId, deliveryId) {
5592
+ if (!deliveryId.startsWith('executor:'))
5593
+ return false;
5594
+ return (this.sql.exec(`UPDATE _substrat_deliveries
5595
+ SET attempts = 0, next_attempt_at = ?
5596
+ WHERE event_id = ? AND consumer_module = ? AND error IS NOT NULL AND next_attempt_at IS NULL`, new Date().toISOString(), eventId, deliveryId).rowsWritten > 0);
5597
+ }
5548
5598
  /**
5549
5599
  * #1232: a CP-less pass's ONLY exit for its schedule outcomes — `admin.recordSweepRun`
5550
5600
  * is a control-plane write the null-CP proxy refuses. One batched intent per pass,
@@ -5555,7 +5605,9 @@ options = {}) {
5555
5605
  enqueueSweepRuns(payload, requestedBy) {
5556
5606
  const counts = this.sql
5557
5607
  .exec(`SELECT COUNT(*) AS c, SUM(CASE WHEN kind = ? THEN 1 ELSE 0 END) AS k
5558
- FROM _substrat_platform_requests WHERE status = 'pending'`, SWEEP_RUNS_KIND)
5608
+ FROM _substrat_platform_requests WHERE status = 'pending' AND requested_by != ?`, SWEEP_RUNS_KIND,
5609
+ // #3365: routed connector deliveries have a room of their own.
5610
+ CONNECTOR_DISPATCH_REQUESTED_BY)
5559
5611
  .toArray()[0];
5560
5612
  if (counts.c >= MAX_PENDING_PLATFORM_REQUESTS || (counts.k ?? 0) >= MAX_PENDING_SWEEP_RUNS) {
5561
5613
  return null;
@@ -7788,8 +7840,10 @@ options = {}) {
7788
7840
  assertModuleEnqueueableKind(input.kind);
7789
7841
  // Backpressure (platform-intents.md): refuse when the scope already holds too many pending
7790
7842
  // intents, so a stuck or runaway vertical cannot flood the platform drain.
7843
+ // #3365: routed connector deliveries are not counted — they have a room of their own
7844
+ // (`MAX_PENDING_CONNECTOR_DISPATCHES`), so a connector backlog never refuses this call.
7791
7845
  const pending = Number(sql
7792
- .exec(`SELECT COUNT(*) AS c FROM _substrat_platform_requests WHERE status = 'pending'`)
7846
+ .exec(`SELECT COUNT(*) AS c FROM _substrat_platform_requests WHERE status = 'pending' AND requested_by != ?`, CONNECTOR_DISPATCH_REQUESTED_BY)
7793
7847
  .toArray()[0].c);
7794
7848
  assertPlatformRequestRoom(pending);
7795
7849
  const id = platformRequestId.parse(ulid());