@substrat-run/adapter-cloudflare 0.206.0 → 0.208.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.
@@ -1 +1 @@
1
- {"version":3,"file":"scope-do.d.ts","sourceRoot":"","sources":["../src/scope-do.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAwDL,KAAK,QAAQ,EAmBd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAiEL,KAAK,mBAAmB,EASxB,KAAK,SAAS,EA2Bd,KAAK,kBAAkB,EAEvB,KAAK,gBAAgB,EA+HtB,MAAM,sBAAsB,CAAC;AAsD9B,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,EA0BL,kBAAkB,EA4FnB,MAAM,sBAAsB,CAAC;AA6B9B;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,0BAA0B,CAAC;IACjD,gGAAgG;IAChG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oGAAoG;IACpG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAsFD,oFAAoF;AACpF,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAgB5E;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;A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KAAK,aAAa,CAAC,UAAU,CAAC,CA84R7E"}
package/dist/scope-do.js CHANGED
@@ -2,7 +2,7 @@ import { REWIND_REFUSED } from './rewind-refusal.js';
2
2
  import { SYSTEM_DOOR_MOVED } from './system-door.js';
3
3
  import { DurableObject } from 'cloudflare:workers';
4
4
  import { ATTACHMENT_ADDED, ATTACHMENT_REMOVED, CAPTURE_REFUSALS, attachmentRecord, domainEvent, domainEventInput, eventId, instant, objectRef, entityObjectRef, assertModuleEmittableType, assertKernelAuthoredType, toWireFailure, grantRefFromProof, principalId, principalBecomeCapabilityInput, principalBindLinkInput, scopeId as scopeIdOf, tenantId as tenantIdOf, platformRequestInput, platformRequestId, MAX_PENDING_PLATFORM_REQUESTS, MAX_PENDING_SWEEP_RUNS, SWEEP_RUNS_KIND, SCOPE_DUMP_PAGE_MAX_BYTES, SCOPE_TABLE_PAGE_MAX, SCOPE_QUERY_ROW_MAX, listLimitOf, pageOf, countedPageOf, requestFingerprint, substratError, errorCodeOf, assertReplayableDump, DUMP_OBJECTS_QUERY, dumpObjectsOf, replayDumpObjects, dumpObjectsAudit, REDRAIN_BATCH, } from '@substrat-run/contracts';
5
- import { ulid, DO_SQL_LIMITS, unknownRoleError, createUlid, assertAllowed, ConnectionSealingKeyUnavailableError, noSealingKeyMessage, sealTo, assertReadOnlyQuery, refuseEntitlement, platformRequestHistoryQuery, platformRequestOf, PLATFORM_REQUEST_COLUMNS, PLATFORM_REQUEST_REDACTION_SQL, platformRequestRedactionParams, platformRequestRedactionQuery, intentPayloadCarriesSubject, redactSubjectJobRuns, eraseSubjectFromModules, readSubjectPage, moduleErasurePlan, redactSubjectScopeText, assertRowLimit, assertRowOffset, JOB_RUN_PATCH_SQL, JOB_RUN_CLAIM_SQL, JOB_RUN_RENEW_SQL, JOB_RUN_BEGIN_SQL, JOB_RUN_MISS_SQL, JOB_RUN_MISS_SETTLE_SQL, admissionMissOutcome, JOB_LEASE_EXPIRED_NOTE, JOB_STEP_RECORD_SQL, DELIVERY_ERROR_REDACTION_SQL, REDACTED_DELIVERY_NOTE, seatScopeTuple, delegatedRevokeSql, writeExplicitTupleIn, grantEntityShapeIn, grantEntityShapeOnceIn, topUpEntityGrantShapes, applyScopeRoleChange, changeScopeRole, revokeScopeRoles, scopeRoleHolders, assertModuleDeclared, noteDeclaredKeys, noteReservedKeys, SCOPE_SEATED_ROLES_SQL, inUnitRoleRefusal, loadedRoleSetRefusedRole, reservedRoleSetRefusedRole, reservedGrantRefusal, reservedRoleRefusal, reservedShapeRefusal, effectiveRoleGrantQuery, switchRecordedOff, switchSystemSchedules, peerGrantsStatus, systemGrantsStatus, systemScheduleState, systemSwitchedOff, OUTBOX_PRUNED_DDL, outboxSubscribersOf, pruneDrainedOutbox, denialListQuery, refusalListQuery, mapRefusalRow, denialSummaryQuery, denialTotalsQuery, DENIAL_WINDOW_QUERY, mapDenialRow, mapDenialSummaryBuckets, PermissionDenied, assertImpersonationAdmitted, assertImpersonationWrites, assertModuleEnqueueableKind, impersonationStampOf, createAtomic, NotSearchable, isSearchIndexTable, rowCountTable, searchIndexPlans, NotListable, listIndexPlans, moduleMigrations, REGISTERED_MIGRATIONS, registeredMigrationsOf, MIGRATION_DIGEST_FENCE_DDL, MIGRATION_DIGEST_MARK_LEGACY, assertJournalDumpCoherent, assertMigrationSql, migrationDivergence, migrationFailedError, migrationSetDivergence, migrationSteps, planMigrations, listQuery, cursorOf, searchLimit, searchMatchExpression, searchQuery, ATTACHMENT_TEXT_DDL, ATTACHMENT_BYTES_SQL, ATTACHMENT_CONDEMNED_DDL, ATTACHMENT_SWEEP_LICENCE_DDL, ATTACHMENT_SWEEP_LICENCE_TABLE, WIRE_NONCE_DDL, WIRE_NONCE_FULL, claimWireNonceIn, isWireNonceTable, isWireNonceWrite, clearOrphanSweepLicence, condemnLicensedOrphanAttachments, consumeOrphanSweepLicence, licensedOrphanIds, recordOrphanSweepLicence, refuseUnlicensedOrphanSweep, refuseCondemnedAttachment, refuseCondemnedInDump, rowlessAttachmentIds, attachmentRecordOfRow, enqueueAttachmentText, reconcileAttachmentText, queueAttachmentTextBackfill, startAttachmentTextBackfill, recordAttachmentText, searchAttachments, IDEMPOTENCY_DDL, REFUSALS_TABLE_DDL, REFUSALS_INDEX, refusalInsert, refusalOf, markGuardRefusal, REFUSALS_REBUILD, refusalsAdmitGuards, assertIdempotencyKey, assertPermissionKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, entityVersionQuery, entityVersionOf, assertIfMatch, OUTBOX_ENTITY_INDEX, SCHEDULE_STATE_DDL, SCHEDULE_STATE_REBUILD, scheduleStateHasKind, VERTICAL_EVENTS_DDL, EXPORT_HOPS_SQL, emptyImportResult, IMPORT_CURSORS_SQL, IMPORT_CURSOR_OF_SQL, OUTBOX_MARK_SQL, exportedSinceQuery, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, noteTransitionInto, withTransitions, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, JOB_RUN_DDL, JOB_RUN_DUE_AT, jobRunListLimit, SYSTEM_DOOR_WAIT, ancestorsWithin, } from '@substrat-run/kernel';
5
+ import { ulid, DO_SQL_LIMITS, unknownRoleError, createUlid, assertAllowed, ConnectionSealingKeyUnavailableError, noSealingKeyMessage, sealTo, assertReadOnlyQuery, refuseEntitlement, platformRequestHistoryQuery, platformRequestOf, PLATFORM_REQUEST_COLUMNS, PLATFORM_REQUEST_REDACTION_SQL, platformRequestRedactionParams, platformRequestRedactionQuery, intentPayloadCarriesSubject, redactSubjectJobRuns, eraseSubjectFromModules, readSubjectPage, moduleErasurePlan, redactSubjectScopeText, assertRowLimit, assertRowOffset, JOB_RUN_PATCH_SQL, JOB_RUN_CLAIM_SQL, JOB_RUN_RENEW_SQL, JOB_RUN_BEGIN_SQL, JOB_RUN_MISS_SQL, JOB_RUN_MISS_SETTLE_SQL, admissionMissOutcome, JOB_LEASE_EXPIRED_NOTE, JOB_STEP_RECORD_SQL, DELIVERY_ERROR_REDACTION_SQL, REDACTED_DELIVERY_NOTE, seatScopeTuple, delegatedRevokeSql, writeExplicitTupleIn, grantEntityShapeIn, grantEntityShapeOnceIn, topUpEntityGrantShapes, applyScopeRoleChange, changeScopeRole, revokeScopeRoles, scopeRoleHolders, assertModuleDeclared, noteDeclaredKeys, noteReservedKeys, SCOPE_SEATED_ROLES_SQL, inUnitRoleRefusal, loadedRoleSetRefusedRole, reservedRoleSetRefusedRole, reservedGrantRefusal, reservedRoleRefusal, reservedShapeRefusal, effectiveRoleGrantQuery, switchRecordedOff, switchSystemSchedules, peerGrantsStatus, systemGrantsStatus, systemScheduleState, systemSwitchedOff, OUTBOX_PRUNED_DDL, outboxSubscribersOf, pruneDrainedOutbox, denialListQuery, refusalListQuery, mapRefusalRow, denialSummaryQuery, denialTotalsQuery, DENIAL_WINDOW_QUERY, mapDenialRow, mapDenialSummaryBuckets, PermissionDenied, assertImpersonationAdmitted, assertImpersonationWrites, assertModuleEnqueueableKind, impersonationStampOf, createAtomic, NotSearchable, isSearchIndexTable, countDumpRows, planDumpSample, sampleFilters, sampleGraph, rowCountTable, searchIndexPlans, NotListable, listIndexPlans, moduleMigrations, REGISTERED_MIGRATIONS, registeredMigrationsOf, MIGRATION_DIGEST_FENCE_DDL, MIGRATION_DIGEST_MARK_LEGACY, assertJournalDumpCoherent, assertMigrationSql, migrationDivergence, migrationFailedError, migrationSetDivergence, migrationSteps, planMigrations, listQuery, cursorOf, searchLimit, searchMatchExpression, searchQuery, ATTACHMENT_TEXT_DDL, ATTACHMENT_BYTES_SQL, ATTACHMENT_CONDEMNED_DDL, ATTACHMENT_SWEEP_LICENCE_DDL, ATTACHMENT_SWEEP_LICENCE_TABLE, WIRE_NONCE_DDL, WIRE_NONCE_FULL, claimWireNonceIn, isWireNonceTable, isWireNonceWrite, clearOrphanSweepLicence, condemnLicensedOrphanAttachments, consumeOrphanSweepLicence, licensedOrphanIds, recordOrphanSweepLicence, refuseUnlicensedOrphanSweep, refuseCondemnedAttachment, refuseCondemnedInDump, rowlessAttachmentIds, attachmentRecordOfRow, enqueueAttachmentText, reconcileAttachmentText, queueAttachmentTextBackfill, startAttachmentTextBackfill, recordAttachmentText, searchAttachments, IDEMPOTENCY_DDL, REFUSALS_TABLE_DDL, REFUSALS_INDEX, refusalInsert, refusalOf, markGuardRefusal, REFUSALS_REBUILD, refusalsAdmitGuards, assertIdempotencyKey, assertPermissionKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, entityVersionQuery, entityVersionOf, assertIfMatch, OUTBOX_ENTITY_INDEX, SCHEDULE_STATE_DDL, SCHEDULE_STATE_REBUILD, scheduleStateHasKind, VERTICAL_EVENTS_DDL, EXPORT_HOPS_SQL, emptyImportResult, IMPORT_CURSORS_SQL, IMPORT_CURSOR_OF_SQL, OUTBOX_MARK_SQL, exportedSinceQuery, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, noteTransitionInto, withTransitions, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, JOB_RUN_DDL, JOB_RUN_DUE_AT, jobRunListLimit, SYSTEM_DOOR_WAIT, ancestorsWithin, } from '@substrat-run/kernel';
6
6
  import { isUpgradeRequest, readSubscription, LIVE_DECIDE_ATTEMPTS, LIVE_FANOUT_LIMIT, LIVE_PRINCIPAL_HEADER, LIVE_SCOPE_HEADER, LIVE_SUBSCRIBE_PATH, LIVE_TENANT_HEADER, LIVE_WITHIN_HEADER, LIVE_EXPIRES_HEADER, LIVE_CLOSE, LIVE_SOCKETS_PER_PRINCIPAL, decodeLiveWithin, liveInstant, liveRefusal, liveRefusalStatus, } from './live-reads.js';
7
7
  import { replyOf } from './do-reply.js';
8
8
  import { OperationQueue } from './serialization.js';
@@ -562,6 +562,12 @@ const ROWID_NAMES = new Set(['rowid', '_rowid_', 'oid']);
562
562
  * the stamp over beside one); every load writes its own. #2350: the orphan sweep's licence is this
563
563
  * store's own, so its rows never leave either.
564
564
  */
565
+ /** `dumpRowFilter`, narrowed by a sample's filter for the table when it has one (#3232). */
566
+ function sampledRowFilter(name, filters) {
567
+ const base = dumpRowFilter(name);
568
+ const sampled = filters?.get(name);
569
+ return sampled ? { where: `(${base.where}) AND (${sampled})`, bindings: base.bindings } : base;
570
+ }
565
571
  function dumpRowFilter(name) {
566
572
  if (name === '_substrat_meta') {
567
573
  return { where: `key NOT IN (${STORE_LOCAL_META_KEYS.map(() => '?').join(', ')})`, bindings: [...STORE_LOCAL_META_KEYS] };
@@ -5767,7 +5773,7 @@ options = {}) {
5767
5773
  // Answered as data, so a refusal's code survives the hop (#113).
5768
5774
  return replyOf(() => this.dumpPage(cursor, opts));
5769
5775
  }
5770
- dumpPage(cursor, { stamp = false, maxBytes = SCOPE_DUMP_PAGE_MAX_BYTES, capture }) {
5776
+ dumpPage(cursor, { stamp = false, maxBytes = SCOPE_DUMP_PAGE_MAX_BYTES, capture, sample }) {
5771
5777
  let loadStamp = this.loadStamp();
5772
5778
  if (stamp && cursor === null && !loadStamp && !this.carriedAwayCopy) {
5773
5779
  loadStamp = ulid();
@@ -5782,6 +5788,8 @@ options = {}) {
5782
5788
  this.heldCapture(capture, defs);
5783
5789
  }
5784
5790
  const at = cursor === null ? null : decodeDumpCursor(cursor);
5791
+ // #3232: a sampled copy reads every page, and every change batch, under the plan its first page made.
5792
+ const sampling = sample ? this.samplingOf(defs, sample) : null;
5785
5793
  const tables = [];
5786
5794
  let bytes = 0;
5787
5795
  let next = null;
@@ -5791,7 +5799,7 @@ options = {}) {
5791
5799
  if (at && name < at.table)
5792
5800
  continue;
5793
5801
  const after = at && name === at.table ? at.after : null;
5794
- const { where, bindings } = dumpRowFilter(name);
5802
+ const { where, bindings } = sampledRowFilter(name, sampling?.filters);
5795
5803
  const { columns, byRowid } = this.tableShape(name, sql);
5796
5804
  // In batches, each read to its end: a cursor left part-read keeps its table locked, and
5797
5805
  // the next statement that drops or alters it fails with SQLITE_LOCKED.
@@ -5828,7 +5836,40 @@ options = {}) {
5828
5836
  break;
5829
5837
  }
5830
5838
  }
5831
- return { tables, next, loadStamp, revision: this.metaValue(WRITE_REVISION_KEY), ...(capture !== undefined ? { captured: true } : {}) };
5839
+ return {
5840
+ tables, next, loadStamp, revision: this.metaValue(WRITE_REVISION_KEY),
5841
+ ...(capture !== undefined ? { captured: true } : {}),
5842
+ ...(sampling ? { sample: sampling.plan } : {}),
5843
+ };
5844
+ }
5845
+ /**
5846
+ * #3232: the sample a copy reads under. Asked for by size alone (its first page), it is planned
5847
+ * here, reading each table's floor; asked for with its floors (every later page and change
5848
+ * batch), it is read as planned, so the whole copy reads one sample however the scope moved.
5849
+ */
5850
+ samplingOf(defs, sample) {
5851
+ const reader = { all: (sql, ...params) => this.sql.exec(sql, ...params).toArray() };
5852
+ const graph = sampleGraph(reader, defs.map(({ name, sql }) => ({ name, byRowid: this.tableShape(name, sql).byRowid })));
5853
+ const plan = sample.floors ? { rows: sample.rows, floors: sample.floors } : planDumpSample(reader, graph, sample.rows);
5854
+ return { plan, filters: sampleFilters(graph, plan) };
5855
+ }
5856
+ /**
5857
+ * How many rows a copy of this scope would move (#3232), whole or under a sample of `rows`, read
5858
+ * before the copy starts so a fork too costly to copy is refused before it writes anything.
5859
+ * Reads only, in one turn; a large table read under a sample's filter is counted on a probe.
5860
+ */
5861
+ estimateDump(opts = {}) {
5862
+ return replyOf(() => {
5863
+ const defs = this.dumpTableDefs();
5864
+ const reader = { all: (sql, ...params) => this.sql.exec(sql, ...params).toArray() };
5865
+ const tables = defs.map(({ name, sql }) => ({ name, byRowid: this.tableShape(name, sql).byRowid }));
5866
+ const sampling = opts.sample ? this.samplingOf(defs, { rows: opts.sample.rows }) : null;
5867
+ const counted = countDumpRows(reader, tables, {
5868
+ base: (name) => dumpRowFilter(name),
5869
+ ...(sampling ? { filters: sampling.filters, sample: sampling.plan } : {}),
5870
+ });
5871
+ return { ...counted, ...(sampling ? { sample: sampling.plan } : {}) };
5872
+ });
5832
5873
  }
5833
5874
  /** A dumped table's columns, and whether its rows are read, and named, by rowid. */
5834
5875
  tableShape(name, sql) {
@@ -5966,13 +6007,17 @@ options = {}) {
5966
6007
  * ends with it (its triggers too, when it was the last).
5967
6008
  */
5968
6009
  exportDumpChanges(copyId, seq, opts = {}) {
5969
- return replyOf(() => this.captureChanges(copyId, seq, opts.maxBytes ?? SCOPE_DUMP_PAGE_MAX_BYTES));
6010
+ return replyOf(() => this.captureChanges(copyId, seq, opts.maxBytes ?? SCOPE_DUMP_PAGE_MAX_BYTES, opts.sample));
5970
6011
  }
5971
- captureChanges(copyId, seq, maxBytes) {
6012
+ captureChanges(copyId, seq, maxBytes, sample) {
5972
6013
  if (!Number.isSafeInteger(seq) || seq < 0)
5973
6014
  throw substratError('validation_failed', 'a change batch is numbered from 0');
5974
6015
  const defs = this.dumpTableDefs();
5975
6016
  this.heldCapture(copyId, defs);
6017
+ // #3232: a row the sample does not keep reads as gone, so a row that left it is deleted there.
6018
+ if (sample && !sample.floors)
6019
+ throw substratError('validation_failed', 'a sampled copy catches up under the floors its first page answered');
6020
+ const filters = sample ? this.samplingOf(defs, sample).filters : undefined;
5976
6021
  const sqlOf = new Map(defs.map((d) => [d.name, d.sql]));
5977
6022
  return this.revision.untracked(() => {
5978
6023
  this.sql.exec(`DELETE FROM _substrat_capture_changes WHERE copy_id = ? AND batch < ?`, copyId, seq);
@@ -5993,7 +6038,7 @@ options = {}) {
5993
6038
  break;
5994
6039
  const ddl = sqlOf.get(name);
5995
6040
  const { columns, byRowid } = this.tableShape(name, ddl);
5996
- const { where, bindings } = dumpRowFilter(name);
6041
+ const { where, bindings } = sampledRowFilter(name, filters);
5997
6042
  const served = [];
5998
6043
  if (!byRowid) {
5999
6044
  const rows = Array.from(this.sql.exec(`SELECT * FROM ${quoteIdent(name)} WHERE ${where}`, ...bindings).raw(), (r) => r);