@substrat-run/adapter-cloudflare 0.228.0 → 0.230.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/broker-lake.d.ts +26 -2
- package/dist/broker-lake.d.ts.map +1 -1
- package/dist/broker-lake.js +56 -3
- package/dist/broker-lake.js.map +1 -1
- package/dist/control-plane-do.d.ts +50 -13
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +128 -52
- package/dist/control-plane-do.js.map +1 -1
- package/dist/delivery-broker-do.d.ts +26 -1
- package/dist/delivery-broker-do.d.ts.map +1 -1
- package/dist/delivery-broker-do.js +50 -3
- package/dist/delivery-broker-do.js.map +1 -1
- package/dist/delivery-broker-platform.d.ts +24 -2
- package/dist/delivery-broker-platform.d.ts.map +1 -1
- package/dist/delivery-broker-platform.js +43 -2
- package/dist/delivery-broker-platform.js.map +1 -1
- package/dist/delivery-handoff.d.ts +8 -1
- package/dist/delivery-handoff.d.ts.map +1 -1
- package/dist/delivery-handoff.js +8 -5
- package/dist/delivery-handoff.js.map +1 -1
- package/dist/directory-cutover.d.ts +93 -1
- package/dist/directory-cutover.d.ts.map +1 -1
- package/dist/directory-cutover.js +85 -2
- package/dist/directory-cutover.js.map +1 -1
- package/dist/directory-objects.d.ts +12 -0
- package/dist/directory-objects.d.ts.map +1 -1
- package/dist/directory-objects.js +8 -1
- package/dist/directory-objects.js.map +1 -1
- package/dist/directory-placement.d.ts.map +1 -1
- package/dist/directory-placement.js +1 -0
- package/dist/directory-placement.js.map +1 -1
- package/dist/directory-tenant-identities.d.ts +30 -0
- package/dist/directory-tenant-identities.d.ts.map +1 -0
- package/dist/directory-tenant-identities.js +64 -0
- package/dist/directory-tenant-identities.js.map +1 -0
- package/dist/directory-tenant-tuples.d.ts +30 -3
- package/dist/directory-tenant-tuples.d.ts.map +1 -1
- package/dist/directory-tenant-tuples.js +27 -0
- package/dist/directory-tenant-tuples.js.map +1 -1
- package/dist/host.d.ts +35 -5
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +110 -19
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/peer-call-target.d.ts +16 -2
- package/dist/peer-call-target.d.ts.map +1 -1
- package/dist/peer-call-target.js +36 -6
- package/dist/peer-call-target.js.map +1 -1
- package/dist/reconcile-on-wake.d.ts +17 -1
- package/dist/reconcile-on-wake.d.ts.map +1 -1
- package/dist/reconcile-on-wake.js +84 -12
- package/dist/reconcile-on-wake.js.map +1 -1
- package/dist/route-read-model-publisher.d.ts.map +1 -1
- package/dist/route-read-model-publisher.js +4 -0
- package/dist/route-read-model-publisher.js.map +1 -1
- package/dist/route-resolver.d.ts +19 -2
- package/dist/route-resolver.d.ts.map +1 -1
- package/dist/route-resolver.js +25 -5
- package/dist/route-resolver.js.map +1 -1
- package/dist/scope-do.d.ts +19 -0
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +398 -25
- package/dist/scope-do.js.map +1 -1
- package/dist/scope-facets.d.ts +121 -0
- package/dist/scope-facets.d.ts.map +1 -0
- package/dist/scope-facets.js +98 -0
- package/dist/scope-facets.js.map +1 -0
- package/dist/scope-supervisor-do.d.ts +93 -0
- package/dist/scope-supervisor-do.d.ts.map +1 -0
- package/dist/scope-supervisor-do.js +504 -0
- package/dist/scope-supervisor-do.js.map +1 -0
- package/dist/scope-sweeper-do.d.ts +7 -1
- package/dist/scope-sweeper-do.d.ts.map +1 -1
- package/dist/scope-sweeper-do.js +17 -1
- package/dist/scope-sweeper-do.js.map +1 -1
- package/dist/scope-wake.d.ts +5 -0
- package/dist/scope-wake.d.ts.map +1 -1
- package/dist/scope-wake.js +2 -0
- package/dist/scope-wake.js.map +1 -1
- package/dist/scope-work.d.ts +1 -1
- package/dist/scope-work.js +1 -1
- package/dist/scope-work.js.map +1 -1
- package/dist/supplied-pass-box.d.ts +77 -0
- package/dist/supplied-pass-box.d.ts.map +1 -0
- package/dist/supplied-pass-box.js +265 -0
- package/dist/supplied-pass-box.js.map +1 -0
- package/dist/tenant-due-index-do.d.ts +76 -0
- package/dist/tenant-due-index-do.d.ts.map +1 -0
- package/dist/tenant-due-index-do.js +90 -0
- package/dist/tenant-due-index-do.js.map +1 -0
- package/dist/tenant-due-nudge.d.ts +66 -0
- package/dist/tenant-due-nudge.d.ts.map +1 -0
- package/dist/tenant-due-nudge.js +77 -0
- package/dist/tenant-due-nudge.js.map +1 -0
- package/dist/tenant-due-work-do.d.ts +26 -0
- package/dist/tenant-due-work-do.d.ts.map +1 -1
- package/dist/tenant-due-work-do.js +69 -5
- package/dist/tenant-due-work-do.js.map +1 -1
- package/package.json +12 -12
package/dist/host.js
CHANGED
|
@@ -3,9 +3,9 @@ import { env as ambientEnv } from 'cloudflare:workers';
|
|
|
3
3
|
import { isRewindRefusal, REWIND_REFUSED } from './rewind-refusal.js';
|
|
4
4
|
import { isSystemDoorMoved, SYSTEM_DOOR_MOVED, SYSTEM_DOOR_REGATES } from './system-door.js';
|
|
5
5
|
import { EXECUTOR_ROUTE_NOT_DUE } from './executor-route.js';
|
|
6
|
-
import { delegatedReadParams, operationSeriesCount, fromWireFailure, isSubstratError, exportReadInput, exportedBatch, importBatch, importResult, pushedImport, importState, importsOfManifestJson, connectionLandingsOfManifestJson, connectorsOfManifestJson, exportsOfManifestJson, assertNoBindingShapeBreak, assertScopeTypesKept, importCursorMove, importCursorMoveAt, importCursorMoved, accessLogEntry, adminLogEntry, opsFailureEntry, opsFailureFingerprint, issueEntry, findingEntry, findingRuleEntry, sweepRunEntry, FRESHNESS_HEARTBEAT_MINUTES, sweepRunsPayload, modelUsageEntry, createTenantInput, identityLink, identityPool, createOrgInput, promotionAcknowledgement, bindAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding,
|
|
6
|
+
import { delegatedReadParams, operationSeriesCount, fromWireFailure, isSubstratError, exportReadInput, exportedBatch, importBatch, importResult, pushedImport, importState, importsOfManifestJson, connectionLandingsOfManifestJson, connectorsOfManifestJson, exportsOfManifestJson, assertNoBindingShapeBreak, assertScopeTypesKept, importCursorMove, importCursorMoveAt, importCursorMoved, accessLogEntry, adminLogEntry, opsFailureEntry, opsFailureFingerprint, issueEntry, findingEntry, findingRuleEntry, sweepRunEntry, FRESHNESS_HEARTBEAT_MINUTES, sweepRunsPayload, modelUsageEntry, createTenantInput, identityLink, identityPool, createOrgInput, promotionAcknowledgement, bindAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding, storedVersionInput, AUTO_ADMISSION_NOTE, registerVerticalInput, vertical as verticalSchema, verticalServingState, verticalTraceSampling, deploymentWireAuth, verticalChannel, verticalVersion, connection, capabilityExchange, mintedCapability, boundedBecomeMint, boundedBindLinkMint, boundedBecomeRevoke, boundedUnbind, entityRef, becomeLinkState, principalBecomeCapabilityInput, principalBindLinkInput, capabilityGrant, principalId, connectionGrant, connectionRevoke, connectionGrantRecord, connectionSecret, systemGrant, systemSwitch, systemSwitchOutcome, systemScheduleEntry, systemSwitchRecord, entitlementGrant, entitlementGrantInput, capabilityFilter, instant, meterReading, scopeStorageSample, requestDay, requestRollupDay, costDay, meterDay, meterDayTake, staleScope, staleScopeTake, verticalOwnerPeriod, subjectRef, createConnectionInput, connectLinkFilter, connectLinkKey, consumeConnectLinkInput, mintConnectLinkInput, projectedConnectionGrant, projectedConnectionKey, moduleManifest, org as orgSchema, orgMembership, resolvedIdentity, identityMembership, roleDefinition, scope as scopeSchema, tenant as tenantSchema, tenantRole, delegatedReadRecord, ownerTransferAudit, memberChangeAudit, peerBindingAudit, connectionBindingAudit, copyMarkAudit, orphanSweepAudit, deliveryRedriveAudit, brokerDeadLetterAudit, subjectShredReceipt, subjectAccessReceipt, connectorDispatchKind, callsOfManifestJson, outboundOfManifestJson, SCOPE_GATE_REASONS, substratError, MODULE_OBJECTS_NOT_CARRIED, errorCodeOf, redrainEventsInput, coverage, peerCoverage, peerGrantsEntry, peerSwitch, peerSwitchOutcome, verticalCaller, verticalResolution, peerInstanceResolution, peerBinding as peerBindingSchema, appEnvironment as appEnvironmentSchema, environmentServeAcknowledgement, environmentEffects as environmentEffectsSchema, connectionReach as connectionReachSchema, verticalSlug, entityObjectRef, ATTACHMENT_BLOB_BINDING, blobStoreBindingName, lifecycleDelivery, scopeLifecycle, storeDriverDumpPageBytes, } from '@substrat-run/contracts';
|
|
7
7
|
import { normalizeHostname, toRouteTarget } from './route-resolver.js';
|
|
8
|
-
import { prePromoteSnapshotExpiresAt } from '@substrat-run/kernel';
|
|
8
|
+
import { prePromoteSnapshotExpiresAt, jobSystemKeysOf, containerPassRegistration, registeredContainerPasses, serveContainerPassDoor, passDoorRequestOf, } from '@substrat-run/kernel';
|
|
9
9
|
import { breakingWithinMajorRefusal, earlierMajorReleaseTarget, earlierMajorsOf, releaseWithinMajorRefusal } from '@substrat-run/kernel';
|
|
10
10
|
import { classify as classifyRelease } from '@substrat-run/model-view/bump';
|
|
11
11
|
import { ACCESS_SUMMARY_METHOD, AccessSummary, openAccessSummary } from '@substrat-run/kernel';
|
|
@@ -14,7 +14,7 @@ import { attachmentBlobKey, normalizeUploadMediaType, redeemOrReplayUploadLink,
|
|
|
14
14
|
// #2995: the parent link a provision-child writes, and the doors it decides.
|
|
15
15
|
childDoorRefusal, childScopeRefusal, claimsHome, directAccessRefusal, parentlessScopeRefusal, provisionedParent,
|
|
16
16
|
// #2993 part 3: the modules (and seats) a scope of each declared type has.
|
|
17
|
-
HOME_SCOPE_TYPE, scopeTypePlanOf, scopeTypePlanOfManifest, scopeTypeRuns, ulid, withheldOpsFailure, KEPT_COPY_REFUSAL, capabilityTokenHash, checkBecomeInput, assertBecomeLinkStateIds, plausibleSessionToken, foldModelUsage, backoffAt, resolveRetryPolicy, executorOutcomeOf, isDeliveryRefusal, refusalJournalText, isSecretBoxConfigured, unconfiguredSecretBox, createSubjectKeys, generateSealingKeyPair, openSealed, ImpersonationRefused, assertSessionUsable, impersonationRowValues, mapImpersonationRow, newImpersonationSession, jobRunOf, assertLeaseMs, runDueJobRuns, SYSTEM_DOOR_WAIT, startJobRun, attachmentTextJob, assertAttachmentExtractors, resolveAttachmentTextBounds, assertJobRegistrable, ATTACHMENT_TEXT_BACKFILL_JOB, ATTACHMENT_TEXT_JOB, ATTACHMENT_TEXT_RECHECK_JOB, kernelJobFor, attachmentTextBackfillJob, attachmentExtractorSetKey, attachmentTextRecheckJob, searchLimit, searchMatchExpression, globalFetch, fetchLikeOf, deadlineFetch, assertRedrainWindow, platformRequestOf, undrainedEventsOf, outboxSubscribersOf, pruneInputOf, inUnitMovesToAudit, staleCarryRevertRow, staleCarryReverts, recordedOffFromWire, peerSubjectRef, SWITCH_KINDS, reassertActionOf, reassertEntry, reassertOffRow, reassertOnRow, switchActionOf, switchAuditSubject, recordAuditOutcome, auditedCapabilityRevoke, auditedScopePermissionWrite, auditWarningOf, switchNotFoundMessage, recordWriteSuperseded, switchSubjectOf, switchSupersededMessage, withRecorded, systemSwitchedOffMessage, tenantSystemSwitchedOffMessage, CrossVerticalRegistry, importCursorSourceOf, exportBreaksOf, exportBreakRefusal, assertPromoteReviewCurrent, promoteRaceRefusal, servingRaceRefusal, migratesFrom, servedFromRow, rebindRaceRefusal, bindExportBreaksOf, bindExportBreakRefusal, scopeMoveOf, runningVersionOf, strandJudgmentsOf, boundShapesOfColumn, installReconciled, collectPeers, peerCallerAt, peerSeats, connectorCallRecord, noopConnectorCallRecorder, recordConnectorCall, settleConnectionUse, splitManifestMigrations, publishedMigrationDigest, migrationChangeRefusal, unknownRoleError, assertRowLimit, assertRowOffset, emptyImportResult, INERT_SCOPE_REASON, lifecycleReceipt, lifecycleRefusal, scopeNotHeldRefusal, isPrimaryScope, isPrimaryScopeRow, sealingKeysForReach, asyncInvocationId, asyncLinePass, assertNoCallerPurge, parseScopeDelegation, delegationCeilingOf, heldKeysOf, purgeReportOf, purgeStillDue, assertBoundOperations, registerTrashTargets, assertModuleDeclared, noteDeclaredKeys, noteReservedKeys, reservedGrantRefusal, reservedRoleRefusal, reservedRoleSetRefusal, loadedFromScopeNote, reservedShapeRefusal, SEAT_HOLDING_SCOPE_STATUSES, dumpRoleRefusal, dumpRoleState, memberAddedAudit, shapeTopUpBatch, verticalOwnerNow, } from '@substrat-run/kernel';
|
|
17
|
+
HOME_SCOPE_TYPE, scopeTypePlanOf, scopeTypePlanOfManifest, scopeTypeRuns, ulid, withheldOpsFailure, KEPT_COPY_REFUSAL, capabilityTokenHash, checkBecomeInput, assertBecomeLinkStateIds, plausibleSessionToken, foldModelUsage, backoffAt, resolveRetryPolicy, executorOutcomeOf, isDeliveryRefusal, refusalJournalText, isSecretBoxConfigured, unconfiguredSecretBox, createSubjectKeys, generateSealingKeyPair, openSealed, ImpersonationRefused, assertSessionUsable, impersonationRowValues, mapImpersonationRow, newImpersonationSession, jobRunOf, assertLeaseMs, runDueJobRuns, SYSTEM_DOOR_WAIT, startJobRun, declaredJobsOf, attachmentTextJob, assertAttachmentExtractors, resolveAttachmentTextBounds, assertJobRegistrable, ATTACHMENT_TEXT_BACKFILL_JOB, ATTACHMENT_TEXT_JOB, ATTACHMENT_TEXT_RECHECK_JOB, kernelJobFor, attachmentTextBackfillJob, attachmentExtractorSetKey, attachmentTextRecheckJob, searchLimit, searchMatchExpression, globalFetch, fetchLikeOf, deadlineFetch, assertRedrainWindow, platformRequestOf, undrainedEventsOf, outboxSubscribersOf, pruneInputOf, inUnitMovesToAudit, staleCarryRevertRow, staleCarryReverts, recordedOffFromWire, peerSubjectRef, SWITCH_KINDS, reassertActionOf, reassertEntry, reassertOffRow, reassertOnRow, switchActionOf, switchAuditSubject, recordAuditOutcome, auditedCapabilityRevoke, auditedScopePermissionWrite, auditWarningOf, switchNotFoundMessage, recordWriteSuperseded, switchSubjectOf, switchSupersededMessage, withRecorded, systemSwitchedOffMessage, tenantSystemSwitchedOffMessage, CrossVerticalRegistry, importCursorSourceOf, exportBreaksOf, exportBreakRefusal, assertPromoteReviewCurrent, promoteRaceRefusal, servingRaceRefusal, migratesFrom, servedFromRow, rebindRaceRefusal, bindExportBreaksOf, bindExportBreakRefusal, scopeMoveOf, runningVersionOf, strandJudgmentsOf, boundShapesOfColumn, installReconciled, collectPeers, peerCallerAt, peerSeats, connectorCallRecord, noopConnectorCallRecorder, recordConnectorCall, settleConnectionUse, splitManifestMigrations, publishedMigrationDigest, migrationChangeRefusal, unknownRoleError, assertRowLimit, assertRowOffset, emptyImportResult, INERT_SCOPE_REASON, lifecycleReceipt, lifecycleRefusal, scopeNotHeldRefusal, isPrimaryScope, isPrimaryScopeRow, sealingKeysForReach, asyncInvocationId, asyncLinePass, assertNoCallerPurge, parseScopeDelegation, delegationCeilingOf, heldKeysOf, purgeReportOf, purgeStillDue, assertBoundOperations, registerTrashTargets, assertModuleDeclared, noteDeclaredKeys, noteReservedKeys, reservedGrantRefusal, reservedRoleRefusal, reservedRoleSetRefusal, loadedFromScopeNote, reservedShapeRefusal, SEAT_HOLDING_SCOPE_STATUSES, dumpRoleRefusal, dumpRoleState, memberAddedAudit, shapeTopUpBatch, verticalOwnerNow, } from '@substrat-run/kernel';
|
|
18
18
|
import { fenceAttachmentSweep, missingAttachmentStore, sweepOrphanAttachments, unsettledCopyRefusal } from '@substrat-run/kernel';
|
|
19
19
|
import { ConnectorRevokeUnsupported } from '@substrat-run/kernel';
|
|
20
20
|
import { assertWireAuthFilter, wireAuthAccessTarget, COPY_RESTORE_FENCE_LAPSED, scopeScriptCopyOf } from '@substrat-run/kernel';
|
|
@@ -465,6 +465,8 @@ export class CloudflareScopeHost {
|
|
|
465
465
|
crossVertical = new CrossVerticalRegistry();
|
|
466
466
|
/** Module id → its declared recurring schedules (#383), for `registeredSchedules`/`runDueSchedules`. */
|
|
467
467
|
moduleSchedules = new Map();
|
|
468
|
+
/** #3752: the keys each module's declared jobs hold as its system principal (`jobSystemKeysOf`). */
|
|
469
|
+
moduleJobKeys = new Map();
|
|
468
470
|
/** #1706: every registered module's `peers`, as declared — read as one union per peer. */
|
|
469
471
|
peerSources = [];
|
|
470
472
|
/** #1232: declared freshness per module. Registered UNCONDITIONALLY — the schedule
|
|
@@ -489,6 +491,8 @@ export class CloudflareScopeHost {
|
|
|
489
491
|
orphanSweepClock;
|
|
490
492
|
/** The parsers attachment text is extracted with (K-43); the host's own, never imported here. */
|
|
491
493
|
attachmentExtractors;
|
|
494
|
+
/** D-85 (#3752): `CloudflareScopeHostOptions.containerPasses`. */
|
|
495
|
+
containerPasses;
|
|
492
496
|
attachmentTextBounds;
|
|
493
497
|
executors = new Map();
|
|
494
498
|
/**
|
|
@@ -499,6 +503,9 @@ export class CloudflareScopeHost {
|
|
|
499
503
|
* and calls the internet, which is why the DO never sees it.
|
|
500
504
|
*/
|
|
501
505
|
jobs = new Map();
|
|
506
|
+
/** D-85: the modules that declare jobs, and every declared job by name (`declaredJobsOf`). */
|
|
507
|
+
jobDeclarers = [];
|
|
508
|
+
declaredJobs = new Map();
|
|
502
509
|
/**
|
|
503
510
|
* The event an executor is effecting, stamped onto the admin rows it writes (K-22). Like
|
|
504
511
|
* `onBehalfOf`, only ever set on a VIEW (`causedByView`, or `attributed` with a
|
|
@@ -572,6 +579,7 @@ export class CloudflareScopeHost {
|
|
|
572
579
|
this.orphanSweepClock = options.orphanSweepClock ?? (() => new Date().toISOString());
|
|
573
580
|
assertAttachmentExtractors(options.attachmentExtractors ?? []);
|
|
574
581
|
this.attachmentExtractors = options.attachmentExtractors ?? [];
|
|
582
|
+
this.containerPasses = options.containerPasses;
|
|
575
583
|
this.attachmentTextBounds = resolveAttachmentTextBounds(options.attachmentTextBounds);
|
|
576
584
|
// #2498: whatever fetch is injected, a sized stream body reaches it converted (`fetchLikeOf`).
|
|
577
585
|
this.fetchImpl = fetchLikeOf(options.fetch ?? globalFetch);
|
|
@@ -943,17 +951,19 @@ export class CloudflareScopeHost {
|
|
|
943
951
|
* write at the end would be cheaper and would lose exactly the work an eviction
|
|
944
952
|
* mid-pass is supposed to keep — and a DO is evicted and revived constantly.
|
|
945
953
|
*/
|
|
946
|
-
jobStore(scopeId) {
|
|
954
|
+
jobStore(tenantId, scopeId) {
|
|
947
955
|
const stub = this.scopeStub(scopeId);
|
|
956
|
+
// D-85: what the DO stamps a declared run's `job.run-ended` event with.
|
|
957
|
+
const scope = { tenantId, scopeId };
|
|
948
958
|
return {
|
|
949
959
|
startOrJoin: (key, row) => stub.jobRunStartOrJoin(key.moduleId, key.job, key.instance, row),
|
|
950
960
|
dueKeys: (now, max) => stub.jobRunsDueKeys(now, max),
|
|
951
961
|
claim: (id, owner, leaseMs) => stub.jobRunClaim(id, owner, leaseMs),
|
|
952
962
|
begin: (id, owner, marginMs) => stub.jobRunBegin(id, owner, marginMs),
|
|
953
|
-
miss: (id, owner, note) => stub.jobRunMiss(id, owner, note),
|
|
963
|
+
miss: (id, owner, note) => stub.jobRunMiss(id, owner, note, scope),
|
|
954
964
|
list: (filter) => stub.jobRunList(filter),
|
|
955
|
-
patch: (id, patch, owner) => stub.jobRunPatch(id, patch, owner),
|
|
956
|
-
commitPass: (id, patch, owner) => stub.jobCommitPass(id, patch, owner),
|
|
965
|
+
patch: (id, patch, owner) => stub.jobRunPatch(id, patch, owner, scope),
|
|
966
|
+
commitPass: (id, patch, owner) => stub.jobCommitPass(id, patch, owner, scope),
|
|
957
967
|
beginStep: (runId, name, owner, leaseMs) => stub.jobStepBegin(runId, name, owner, leaseMs),
|
|
958
968
|
recordStep: (runId, name, result, attempts, lastError, at, owner, leaseMs) => stub.jobStepRecord(runId, name, result, attempts, lastError, at, owner, leaseMs),
|
|
959
969
|
};
|
|
@@ -978,7 +988,7 @@ export class CloudflareScopeHost {
|
|
|
978
988
|
async startJobRun(tenantId, scopeId, input) {
|
|
979
989
|
await this.assertLive(tenantId, scopeId, 'startJobRun');
|
|
980
990
|
await this.migrateAndRecord(scopeId);
|
|
981
|
-
return jobRunOf(await startJobRun(this.jobStore(scopeId), input, ulid, () => new Date().toISOString()));
|
|
991
|
+
return jobRunOf(await startJobRun(this.jobStore(tenantId, scopeId), input, ulid, () => new Date().toISOString()));
|
|
982
992
|
}
|
|
983
993
|
async runDueJobs(tenantId, scopeId, options) {
|
|
984
994
|
// Same lifecycle gate as `drainDue`: a suspended scope's runs wait rather than
|
|
@@ -1012,8 +1022,18 @@ export class CloudflareScopeHost {
|
|
|
1012
1022
|
return door;
|
|
1013
1023
|
};
|
|
1014
1024
|
return runDueJobRuns({
|
|
1015
|
-
store: this.jobStore(scopeId),
|
|
1016
|
-
handlerFor: (run) => kernelJobFor(run, kernelJobs) ??
|
|
1025
|
+
store: this.jobStore(tenantId, scopeId),
|
|
1026
|
+
handlerFor: (run) => kernelJobFor(run, kernelJobs) ??
|
|
1027
|
+
// D-85 (#3752): a container placement hands the pass off; its end comes back through the door,
|
|
1028
|
+
// and the scope announces it (`job.run-ended`) in the transaction that writes it.
|
|
1029
|
+
containerPassRegistration(this.containerPasses ?? registeredContainerPasses(), run, {
|
|
1030
|
+
tenantId,
|
|
1031
|
+
scopeId,
|
|
1032
|
+
door: async (ticket) => this.containerPassDoorDeps(tenantId, scopeId, ticket),
|
|
1033
|
+
}) ??
|
|
1034
|
+
this.jobs.get(`${run.module_id}/${run.job}`),
|
|
1035
|
+
// D-85: a declared job's run with no handler here fails on its record instead of waiting forever.
|
|
1036
|
+
declared: (run) => this.declaredJobs.get(run.job)?.moduleId === run.module_id,
|
|
1017
1037
|
now: () => new Date().toISOString(),
|
|
1018
1038
|
openScope: async (run, pass) => this.buildStub(tenantId, scopeId, undefined, undefined, await doorFor(run, pass)),
|
|
1019
1039
|
openAttachments: async (run, pass) => this.systemAttachmentsThrough(await doorFor(run, pass), run.module_id, tenantId, scopeId),
|
|
@@ -1023,10 +1043,35 @@ export class CloudflareScopeHost {
|
|
|
1023
1043
|
limit: options?.limit,
|
|
1024
1044
|
});
|
|
1025
1045
|
}
|
|
1046
|
+
/** D-85 (#3752): what one detached container pass's door works with: its run's store and its module's files. */
|
|
1047
|
+
containerPassDoorDeps(tenantId, scopeId, ticket) {
|
|
1048
|
+
return {
|
|
1049
|
+
store: this.jobStore(tenantId, scopeId),
|
|
1050
|
+
ticket,
|
|
1051
|
+
now: () => new Date().toISOString(),
|
|
1052
|
+
files: () => this.getSystemAttachments(ticket.moduleId, tenantId, scopeId),
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* D-85 (#3752): the door one detached container pass reaches its run through, served by this
|
|
1057
|
+
* (the vertical's own) host, so the pass runs against the kernel the vertical shipped. The platform's
|
|
1058
|
+
* pass box calls it for every request its container makes to `run.substrat.internal`, with the
|
|
1059
|
+
* ticket the launch carried; `bundle` is the pass's code and `ended` tells the box the pass is over.
|
|
1060
|
+
* Every write is conditional on the ticket's lease, so a box that serves a stale ticket changes
|
|
1061
|
+
* nothing (`lease_lost`, 409).
|
|
1062
|
+
*/
|
|
1063
|
+
async serveContainerPass(tenantId, scopeId, ticket, request, options = {}) {
|
|
1064
|
+
const reply = await serveContainerPassDoor(passDoorRequestOf(request), {
|
|
1065
|
+
...this.containerPassDoorDeps(tenantId, scopeId, ticket),
|
|
1066
|
+
...options,
|
|
1067
|
+
});
|
|
1068
|
+
const body = reply.body === null || typeof reply.body === 'string' ? reply.body : reply.body.stream;
|
|
1069
|
+
return new Response(body, { status: reply.status, headers: reply.headers });
|
|
1070
|
+
}
|
|
1026
1071
|
async jobRuns(tenantId, scopeId, filter) {
|
|
1027
1072
|
await this.validateScopeAccess(tenantId, scopeId, 'jobRuns');
|
|
1028
1073
|
await this.migrateAndRecord(scopeId);
|
|
1029
|
-
return (await this.jobStore(scopeId).list(filter ?? {})).map(jobRunOf);
|
|
1074
|
+
return (await this.jobStore(tenantId, scopeId).list(filter ?? {})).map(jobRunOf);
|
|
1030
1075
|
}
|
|
1031
1076
|
async dispatchConnector(tenantId, scopeId, handler, event, options) {
|
|
1032
1077
|
// The platform half of a routed delivery (#574 phase 3). The same lifecycle gate as
|
|
@@ -1903,6 +1948,8 @@ export class CloudflareScopeHost {
|
|
|
1903
1948
|
// #2068: the same refusal the ScopeDO applies at code time, here at registration, so a
|
|
1904
1949
|
// misdeclared erasure fails where it is registered on both hosts.
|
|
1905
1950
|
moduleErasurePlan(registration);
|
|
1951
|
+
// D-85: the module's jobs, refused here as the scope object refuses them (a name taken, an undeclared key).
|
|
1952
|
+
const jobs = declaredJobsOf([...this.jobDeclarers, { manifest, jobs: registration.jobs }]);
|
|
1906
1953
|
const migrations = registration.migrations ?? [];
|
|
1907
1954
|
const seen = new Set();
|
|
1908
1955
|
for (const m of migrations) {
|
|
@@ -1933,6 +1980,12 @@ export class CloudflareScopeHost {
|
|
|
1933
1980
|
// #1705: after the checks above, so a refused module leaves nothing registered here.
|
|
1934
1981
|
this.crossVertical.register(manifest, registration.imports);
|
|
1935
1982
|
this.moduleIds.add(manifest.id);
|
|
1983
|
+
if (registration.jobs)
|
|
1984
|
+
this.jobDeclarers.push({ manifest, jobs: registration.jobs });
|
|
1985
|
+
this.declaredJobs = jobs;
|
|
1986
|
+
const jobKeys = jobSystemKeysOf(registration.jobs);
|
|
1987
|
+
if (jobKeys.length > 0)
|
|
1988
|
+
this.moduleJobKeys.set(manifest.id, jobKeys);
|
|
1936
1989
|
noteReservedKeys(this.reservedKeys, manifest);
|
|
1937
1990
|
noteDeclaredKeys(this.declaredKeys, manifest);
|
|
1938
1991
|
if (manifest.schedules && manifest.schedules.length > 0) {
|
|
@@ -2096,14 +2149,17 @@ export class CloudflareScopeHost {
|
|
|
2096
2149
|
// not a grant, so no reconcile can seat it away; `restoreToSystem` is the only way back.
|
|
2097
2150
|
// (`grantToSystem` still clears a tuple's tombstone, but it does not move the switch.)
|
|
2098
2151
|
const seats = [];
|
|
2099
|
-
for (const
|
|
2152
|
+
for (const moduleId of new Set([...this.moduleSchedules.keys(), ...this.moduleJobKeys.keys()])) {
|
|
2100
2153
|
// #2993 part 3: only the modules this scope's type runs seat their schedules' grants.
|
|
2101
2154
|
if (!scopeTypeRuns(this.scopeTypePlan, scopeType, moduleId))
|
|
2102
2155
|
continue;
|
|
2103
2156
|
const perms = new Set();
|
|
2104
|
-
for (const s of
|
|
2157
|
+
for (const s of this.moduleSchedules.get(moduleId) ?? [])
|
|
2105
2158
|
for (const p of s.permissions)
|
|
2106
2159
|
perms.add(p);
|
|
2160
|
+
// #3752: and the keys its declared jobs' passes hold, seated the same way.
|
|
2161
|
+
for (const p of this.moduleJobKeys.get(moduleId) ?? [])
|
|
2162
|
+
perms.add(p);
|
|
2107
2163
|
for (const perm of perms) {
|
|
2108
2164
|
seats.push({ subject: `system:${moduleId}`, relation: `granted:${perm}`, object: `scope:${input.scopeId}`, expires_at: null });
|
|
2109
2165
|
}
|
|
@@ -2358,11 +2414,34 @@ export class CloudflareScopeHost {
|
|
|
2358
2414
|
async systemAttachmentsThrough(door, moduleId, tenantId, scopeId) {
|
|
2359
2415
|
const store = await this.resolveAttachmentStore(tenantId);
|
|
2360
2416
|
const stub = this.scopeStub(scopeId);
|
|
2417
|
+
const authorize = (attachmentId) => door.through(async (instance) => unwrapReply(await stub.systemAttachmentAuthorizeReply(attachmentId, moduleId, tenantId, scopeId, instance)));
|
|
2361
2418
|
return {
|
|
2362
2419
|
open: async (attachmentId) => {
|
|
2363
|
-
const record = await
|
|
2420
|
+
const record = await authorize(attachmentId);
|
|
2364
2421
|
return record ? this.openAttachmentBytes(store, scopeId, record) : null;
|
|
2365
2422
|
},
|
|
2423
|
+
// #3752: a container pass reads a file as it is read, never whole into the worker.
|
|
2424
|
+
openStream: async (attachmentId, options) => {
|
|
2425
|
+
const record = await authorize(attachmentId);
|
|
2426
|
+
return record ? openAttachmentByteStream(store, attachmentBlobKey(scopeId, record.id), record, workerdSha256, options?.range) : null;
|
|
2427
|
+
},
|
|
2428
|
+
// #3752: a module's own file (a container pass's output). Bytes first, row second, as every
|
|
2429
|
+
// upload: an answered refusal compensates the object away (`compensatingRefusal`).
|
|
2430
|
+
upload: async (input) => {
|
|
2431
|
+
const id = ulid();
|
|
2432
|
+
const key = attachmentBlobKey(scopeId, id);
|
|
2433
|
+
const fields = {
|
|
2434
|
+
id,
|
|
2435
|
+
entity: input.entity,
|
|
2436
|
+
filename: input.filename,
|
|
2437
|
+
contentType: input.contentType,
|
|
2438
|
+
visibility: input.visibility,
|
|
2439
|
+
createdBy: JSON.stringify({ system: moduleId }),
|
|
2440
|
+
createdAt: new Date().toISOString(),
|
|
2441
|
+
};
|
|
2442
|
+
const record = await putAttachmentBytes(store, key, fields, input.body, workerdSha256);
|
|
2443
|
+
return door.through(async (instance) => unwrapReply(await compensatingRefusal(store, key, () => stub.systemAttachmentAddReply(record, moduleId, tenantId, scopeId, instance))));
|
|
2444
|
+
},
|
|
2366
2445
|
remove: async (attachmentId) => {
|
|
2367
2446
|
const removed = await door.through(async (instance) => unwrapReply(await stub.systemAttachmentRemoveReply(attachmentId, moduleId, tenantId, scopeId, instance)));
|
|
2368
2447
|
// Row (and event) first, bytes second: at worst an orphaned object, never a dangling row.
|
|
@@ -4400,6 +4479,7 @@ export class CloudflareScopeHost {
|
|
|
4400
4479
|
origin: r.origin_json ? JSON.parse(r.origin_json) : null,
|
|
4401
4480
|
outbound,
|
|
4402
4481
|
calls,
|
|
4482
|
+
bundleDigest: r.bundle_digest ?? null,
|
|
4403
4483
|
createdAt: r.created_at,
|
|
4404
4484
|
});
|
|
4405
4485
|
const mapOrg = (r) => orgSchema.parse({
|
|
@@ -5659,7 +5739,8 @@ export class CloudflareScopeHost {
|
|
|
5659
5739
|
return rows.map(mapVertical);
|
|
5660
5740
|
},
|
|
5661
5741
|
publishVersion: async (actor, input) => {
|
|
5662
|
-
|
|
5742
|
+
// #3612: the stored input, whose `bundleDigest` only the control plane's own push sets.
|
|
5743
|
+
const parsed = storedVersionInput.parse(input);
|
|
5663
5744
|
const owning = await this.cp.readVertical(parsed.verticalSlug);
|
|
5664
5745
|
if (!owning) {
|
|
5665
5746
|
throw substratError('not_found', `unknown vertical '${parsed.verticalSlug}'`);
|
|
@@ -5992,6 +6073,11 @@ export class CloudflareScopeHost {
|
|
|
5992
6073
|
throw substratError('precondition_failed', 'scope erasure changed; reload the scope and retry');
|
|
5993
6074
|
}
|
|
5994
6075
|
const ack = bindAcknowledgement.parse(opts?.acknowledge ?? {});
|
|
6076
|
+
// #3638: what this bind acknowledges if the scope is a named environment's preview, judged in
|
|
6077
|
+
// the directory's write that moves it (kernel `environmentBindRefusalIn`).
|
|
6078
|
+
const envAck = opts?.environmentAcknowledge === undefined
|
|
6079
|
+
? undefined
|
|
6080
|
+
: environmentServeAcknowledgement.parse(opts.environmentAcknowledge);
|
|
5995
6081
|
// #2347: a route moving in the same write is judged with it, as `bindingImpact` is.
|
|
5996
6082
|
const servingRef = opts?.servingRef;
|
|
5997
6083
|
// #2178 first: no acknowledgement passes it, so none should be asked for ahead of it.
|
|
@@ -6017,9 +6103,11 @@ export class CloudflareScopeHost {
|
|
|
6017
6103
|
...(servingRef !== undefined ? { servingRef } : {}),
|
|
6018
6104
|
...(opts?.expectedVersionId !== undefined ? { expectedVersionId: opts.expectedVersionId } : {}),
|
|
6019
6105
|
...(opts?.expectedServing ? { expectedServing: opts.expectedServing } : {}),
|
|
6020
|
-
|
|
6106
|
+
// #3638: an environment's acknowledgement is recorded with this bind, as a serve's is with its record.
|
|
6107
|
+
...(ack.exportBreak || envAck ? { acknowledged: { ...ack, ...envAck } } : {}),
|
|
6021
6108
|
});
|
|
6022
|
-
|
|
6109
|
+
// #3638: through `reply`, so an environment's checkpoint refusal arrives with its code and reason.
|
|
6110
|
+
if (!await this.directory('bindScopeVersionJudged', scopeId, versionId, v.vertical_slug, opts?.expectedVersionId, opts?.expectedErasureEpoch, opts?.confirmMove, servingRef, opts?.expectedServing, audit, envAck)) {
|
|
6023
6111
|
// The erasure and copy-move conditions keep their own refusal: only a moved binding or a
|
|
6024
6112
|
// moved serving version is the race a rebind's review answers.
|
|
6025
6113
|
const now = await this.cp.getScopeRecord(tenantId, scopeId);
|
|
@@ -9448,11 +9536,14 @@ export class CloudflareScopeHost {
|
|
|
9448
9536
|
/** #2993 part 3: only the modules this type runs seat their schedule and peer grants. */
|
|
9449
9537
|
scopeType) {
|
|
9450
9538
|
return [
|
|
9451
|
-
...[...this.moduleSchedules].filter((
|
|
9539
|
+
...[...new Set([...this.moduleSchedules.keys(), ...this.moduleJobKeys.keys()])].filter((modId) => scopeTypeRuns(this.scopeTypePlan, scopeType, modId)).flatMap((modId) => {
|
|
9452
9540
|
const perms = new Set();
|
|
9453
|
-
for (const s of
|
|
9541
|
+
for (const s of this.moduleSchedules.get(modId) ?? [])
|
|
9454
9542
|
for (const p of s.permissions)
|
|
9455
9543
|
perms.add(p);
|
|
9544
|
+
// #3752: and the keys its declared jobs' passes hold.
|
|
9545
|
+
for (const p of this.moduleJobKeys.get(modId) ?? [])
|
|
9546
|
+
perms.add(p);
|
|
9456
9547
|
return [...perms].map((perm) => ({ subject: `system:${modId}`, relation: `granted:${perm}`, object: `scope:${scopeId}`, expires_at: null }));
|
|
9457
9548
|
}),
|
|
9458
9549
|
...peerSeats(collectPeers(this.peerSourcesOf(scopeType)), scopeId).map((seat) => ({ ...seat, expires_at: null })),
|