@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/control-plane-do.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tenantDueWorkName } from './tenant-due-work-do.js';
|
|
2
2
|
import { DurableObject } from 'cloudflare:workers';
|
|
3
|
-
import { membershipFencesBackfillSql, MEMBERSHIP_FENCES_DDL, MEMBERSHIP_FENCES_TABLE, membershipFencesTableExists, IMPERSONATION_COLUMNS, IMPERSONATION_DDL, impersonationByIdQuery, impersonationListQuery, impersonationRowValues, ISSUE_RETENTION_DAYS, telemetryRetentionStatements, FINDINGS_DDL, SCOPE_STORAGE_DDL, forgetScopeStorage, retireScopeStorage, listScopeStorageAttemptRows, listScopeStorageRows, listScopeAttachmentStorageRows, listScopeStoreStorageRows, pruneScopeStorageRows, recordScopeStorageRows, readBoundedTenantStorageGauge, REQUEST_ROLLUP_DDL, listRequestDayRows, listRequestRollupDayRows, pruneRequestDayRows, recordRequestDayRows, readTenantRequestMeterRows, readRequestMeterDayRows, COST_ROLLUP_DDL, listCostDayRows, listCostRollupDayRows, sumCostDayRows, pruneCostDayRows, recordCostDayRows, recordCostContainerRows, recordScopeObjectRow, scopeObjectsDueRows, METER_DAYS_DDL, STALE_SCOPES_DDL, listStaleScopeRows, listStaleScopeTakeRows, recordStaleScopeRows, VERTICAL_OWNERS_BACKFILL, VERTICAL_OWNERS_DDL, closeVerticalOwnerRow, listVerticalOwnerRows, openVerticalOwnerRow, verticalOwnerNow, listMeterDayRows, listMeterDayTakeRows, pruneMeterDayRows, recordMeterDayRows, DIRECTORY_LAKE_DDL, ackDirectoryOutbox, ensureDirectoryLakeTriggers, advanceDirectoryLakeBackfill, pruneDirectoryLakeWindow, readDirectoryLakeBackfill, readDirectoryLakeCapture, readDirectoryOutbox, setDirectoryLakeCapture, CONNECT_LINKS_DDL, consumeConnectLinkRow, insertConnectLink as insertConnectLinkRow, listConnectLinks as listConnectLinkRows, readConnectLink as readConnectLinkRow, restoreConnectLinkRow, revokeConnectLinkRow, createFindingRule, findingOfOpsFailure, findingOfSweepRun, pruneFindings, listFindingRules, listFindings, observeFinding, revokeFindingRule, setFindingStatus, assertRowLimit, OPS_FAILURE_RETENTION_DAYS, SWEEP_RUN_RETENTION_DAYS, SWEEP_RUNS_INTENT_INDEX, sweepRunsIntentHasKind, CONNECTIONS_LIVE_INDEX, connectionsLiveIndexHasOwner, PEER_SWITCHES_DDL, PEER_BINDINGS_DDL, APP_ENVIRONMENTS_DDL, claimEnvironmentServeIn, defineEnvironmentIn, ENVIRONMENT_SCRIPT_JOIN_SQL, environmentsOf, HOME_SCOPE_TYPE, homeScopeIn, secondHomeRefusal, releaseEnvironmentServeIn, removeEnvironmentIn, setEnvironmentServingIn, setEnvironmentEffectsIn, connectionReachIn, SWITCH_OWED_DDL, DEPENDENT_ERASURES_DDL, DEPENDENT_ERASURE_DUE_SQL, DEPENDENT_ERASURE_HOLD_SQL, DEPENDENT_ERASURE_OWE_SQL, DEPENDENT_ERASURE_SETTLE_SQL, nextDependentErasureAt, clearSwitchOwed, markSwitchOwed, scopeOwesSwitch, switchesOwedOf, SWITCH_KINDS, SYSTEM_SWITCHES_DDL, forgetSwitchesOf, listSystemSwitchRecords, recordSwitchedOff, recordSwitchedOn, recordWriteSuperseded, restoreSwitchRecord, scopesSwitchedOffFor, switchRecordStatesOf, switchRecordsOf, switchesBackfillSqlOf, switchesDdlOf, switchesTableExists, switchesTableOf, tenantHeldOf, VERSION_MIGRATIONS_DDL, VERTICAL_SCOPE_STORES_DDL, DEPLOYMENT_WIRE_AUTH_DDL, deploymentWireAuthOf, forgetVerticalWireAuth, writeDeploymentWireAuth, STORE_DRIVER_RELEASES_DDL, approveStoreDriverReleaseIn, legacyStoreDriverConflict, legacyStoreDriverRenames, beginStoreDriverRolloutIn, finishStoreDriverRolloutIn, holdStoreDriverIn, advanceStoreDriverRebuildIn, claimStoreDriverRebuildIn, storeDriverRebuildIn, driverDeclarationsOf, recordStoreDriverReleaseIn, recordStoreDriverRevokeWalkIn, releaseStoreDriverHoldIn, revokeStoreDriverReleaseIn, liveStoreDriverApprovalIn, storeDriverApprovalsIn, storeDriverRevokeWalkIn, storeDriverReleaseIn, storeDriverStateIn, storeDriverRolloutPendingIn, storeDriverRolloutWalkedIn, forgetVerticalScopeStores, indexVersionScopeStores, verticalScopeStoresOf, splitVersionMigrationsBatch, versionMigrationsOf, versionMigrationsExtractedOf, recordVersionMigrationsExtracted, versionsAwaitSplit, versionsAwaitDigest, deriveMigrationDigestsBatch, deriveVersionMigrationDigest, writeVersionMigrations, MODEL_USAGE_RETENTION_DAYS, BUILD_USAGE_RETENTION_DAYS, DO_SQL_LIMITS, ulid, isPrimaryScopeRow, samePeerVertical, peerVerticalSpellings, resolveVerticalInstanceFrom, resolvePeerInstanceFrom, LEGACY_SCOPE_ROWS_BACKFILL, loadDirectoryDump, storesFencedRefusal, redactSubjectDirectoryText, ISSUE_EXEMPLAR_OWNER_BACKFILL_SQL, issueExemplarOwner, SETTLE_INTENT_SQL, SETTLE_OUTCOME_SQL, settleOutcomeParamsOf, unknownOutcomeOf, ADMIN_LOG_INDEX_DDL, ADMIN_LOG_INDEXES_SQL, readAuditedOperations, } from '@substrat-run/kernel';
|
|
3
|
+
import { membershipFencesBackfillSql, MEMBERSHIP_FENCES_DDL, MEMBERSHIP_FENCES_TABLE, membershipFencesTableExists, IMPERSONATION_COLUMNS, IMPERSONATION_DDL, impersonationByIdQuery, impersonationListQuery, impersonationRowValues, ISSUE_RETENTION_DAYS, telemetryRetentionStatements, FINDINGS_DDL, SCOPE_STORAGE_DDL, forgetScopeStorage, retireScopeStorage, listScopeStorageAttemptRows, listScopeStorageRows, listScopeAttachmentStorageRows, listScopeStoreStorageRows, pruneScopeStorageRows, recordScopeStorageRows, readBoundedTenantStorageGauge, REQUEST_ROLLUP_DDL, listRequestDayRows, listRequestRollupDayRows, pruneRequestDayRows, recordRequestDayRows, readTenantRequestMeterRows, readRequestMeterDayRows, COST_ROLLUP_DDL, listCostDayRows, listCostRollupDayRows, sumCostDayRows, pruneCostDayRows, recordCostDayRows, recordCostContainerRows, recordScopeObjectRow, scopeObjectsDueRows, METER_DAYS_DDL, STALE_SCOPES_DDL, listStaleScopeRows, listStaleScopeTakeRows, recordStaleScopeRows, VERTICAL_OWNERS_BACKFILL, VERTICAL_OWNERS_DDL, closeVerticalOwnerRow, listVerticalOwnerRows, openVerticalOwnerRow, verticalOwnerNow, listMeterDayRows, listMeterDayTakeRows, pruneMeterDayRows, recordMeterDayRows, DIRECTORY_LAKE_DDL, ackDirectoryOutbox, ensureDirectoryLakeTriggers, advanceDirectoryLakeBackfill, pruneDirectoryLakeWindow, readDirectoryLakeBackfill, readDirectoryLakeCapture, readDirectoryOutbox, setDirectoryLakeCapture, CONNECT_LINKS_DDL, consumeConnectLinkRow, insertConnectLink as insertConnectLinkRow, listConnectLinks as listConnectLinkRows, readConnectLink as readConnectLinkRow, restoreConnectLinkRow, revokeConnectLinkRow, createFindingRule, findingOfOpsFailure, findingOfSweepRun, pruneFindings, listFindingRules, listFindings, observeFinding, revokeFindingRule, setFindingStatus, assertRowLimit, OPS_FAILURE_RETENTION_DAYS, SWEEP_RUN_RETENTION_DAYS, SWEEP_RUNS_INTENT_INDEX, sweepRunsIntentHasKind, CONNECTIONS_LIVE_INDEX, connectionsLiveIndexHasOwner, PEER_SWITCHES_DDL, PEER_BINDINGS_DDL, APP_ENVIRONMENTS_DDL, claimEnvironmentServeIn, defineEnvironmentIn, ENVIRONMENT_SCRIPT_JOIN_SQL, environmentPeerResolutionIn, environmentsOf, HOME_SCOPE_TYPE, homeScopeIn, secondHomeRefusal, releaseEnvironmentServeIn, removeEnvironmentIn, setEnvironmentServingIn, environmentBindRefusalIn, setEnvironmentEffectsIn, connectionReachIn, SWITCH_OWED_DDL, DEPENDENT_ERASURES_DDL, DEPENDENT_ERASURE_DUE_SQL, DEPENDENT_ERASURE_HOLD_SQL, DEPENDENT_ERASURE_OWE_SQL, DEPENDENT_ERASURE_SETTLE_SQL, nextDependentErasureAt, clearSwitchOwed, markSwitchOwed, scopeOwesSwitch, switchesOwedOf, SWITCH_KINDS, SYSTEM_SWITCHES_DDL, forgetSwitchesOf, listSystemSwitchRecords, recordSwitchedOff, recordSwitchedOn, recordWriteSuperseded, restoreSwitchRecord, scopesSwitchedOffFor, switchRecordStatesOf, switchRecordsOf, switchesBackfillSqlOf, switchesDdlOf, switchesTableExists, switchesTableOf, tenantHeldOf, VERSION_MIGRATIONS_DDL, VERTICAL_SCOPE_STORES_DDL, DEPLOYMENT_WIRE_AUTH_DDL, deploymentWireAuthOf, forgetVerticalWireAuth, writeDeploymentWireAuth, STORE_DRIVER_RELEASES_DDL, approveStoreDriverReleaseIn, legacyStoreDriverConflict, legacyStoreDriverRenames, beginStoreDriverRolloutIn, finishStoreDriverRolloutIn, holdStoreDriverIn, advanceStoreDriverRebuildIn, claimStoreDriverRebuildIn, storeDriverRebuildIn, driverDeclarationsOf, recordStoreDriverReleaseIn, recordStoreDriverRevokeWalkIn, releaseStoreDriverHoldIn, revokeStoreDriverReleaseIn, liveStoreDriverApprovalIn, storeDriverApprovalsIn, storeDriverRevokeWalkIn, storeDriverReleaseIn, storeDriverStateIn, storeDriverRolloutPendingIn, storeDriverRolloutWalkedIn, forgetVerticalScopeStores, indexVersionScopeStores, verticalScopeStoresOf, splitVersionMigrationsBatch, versionMigrationsOf, versionMigrationsExtractedOf, recordVersionMigrationsExtracted, versionsAwaitSplit, versionsAwaitDigest, deriveMigrationDigestsBatch, deriveVersionMigrationDigest, writeVersionMigrations, MODEL_USAGE_RETENTION_DAYS, BUILD_USAGE_RETENTION_DAYS, DO_SQL_LIMITS, ulid, isPrimaryScopeRow, samePeerVertical, peerVerticalSpellings, resolveVerticalInstanceFrom, resolvePeerInstanceFrom, LEGACY_SCOPE_ROWS_BACKFILL, loadDirectoryDump, storesFencedRefusal, redactSubjectDirectoryText, ISSUE_EXEMPLAR_OWNER_BACKFILL_SQL, issueExemplarOwner, SETTLE_INTENT_SQL, SETTLE_OUTCOME_SQL, settleOutcomeParamsOf, unknownOutcomeOf, ADMIN_LOG_INDEX_DDL, ADMIN_LOG_INDEXES_SQL, readAuditedOperations, } from '@substrat-run/kernel';
|
|
4
4
|
import { MARKUP_INSERT_SQL, MARKUP_SELECT_FOR_TENANT_SQL, MARKUP_SELECT_SQL, } from '@substrat-run/kernel';
|
|
5
5
|
import { replyOf } from './do-reply.js';
|
|
6
6
|
import { rowBytes, switchSqlOver } from './scope-do.js';
|
|
@@ -18,16 +18,18 @@ import { durableMirrorSender } from './directory-objects.js';
|
|
|
18
18
|
import { directoryBackfillFor } from './directory-mirror-backfill.js';
|
|
19
19
|
import { directoryVerifyFor } from './directory-mirror-verify.js';
|
|
20
20
|
// K-68 step 3e: a tenant's role definitions read from, and first written to, its own object (off by default).
|
|
21
|
-
import { cutoverLive, directoryCutoverFor } from './directory-cutover.js';
|
|
21
|
+
import { cutoverFlagsPage, cutoverLive, cutoverParityPage, directoryCutoverFor, PARITY_PAGE_MAX } from './directory-cutover.js';
|
|
22
22
|
// K-68 step 3e, the second family: a tenant's tuples and removal fences (directory-tenant-tuples.ts).
|
|
23
23
|
import { applyMembershipIn, assignTenantRoleIn, dumpTenantTupleRows, listMemberRows, revokeAndFenceIn, revokeTenantTupleIn, TENANT_TUPLES, tenantTupleRows, writeTenantTupleIn, } from './directory-tenant-tuples.js';
|
|
24
24
|
// K-68 step 3e, the third family: a tenant's organizations (directory-tenant-orgs.ts).
|
|
25
25
|
import { createOrgIn, listOrgRows, ORGS, readOrgRow } from './directory-tenant-orgs.js';
|
|
26
26
|
// K-68 step 3e, the fourth family: a tenant's entitlements (directory-tenant-entitlements.ts).
|
|
27
27
|
import { ENTITLEMENTS, entitlementAuditOf, grantEntitlementIn, holdsEntitlement, listEntitlementRows, revokeEntitlementIn, } from './directory-tenant-entitlements.js';
|
|
28
|
-
|
|
28
|
+
// K-68 step 3e, the fifth family: a tenant's identity links (directory-tenant-identities.ts).
|
|
29
|
+
import { dumpIdentityRows, IDENTITIES, linkIdentityIn, resolveIdentityIn, unlinkIdentityIn } from './directory-tenant-identities.js';
|
|
30
|
+
import { durableCutoverSender, registryStub } from './directory-objects.js';
|
|
29
31
|
import { defineRoleRow, listRoleRows, readRole } from './directory-tenant-roles.js';
|
|
30
|
-
import { assertReplayableDump, AUTO_ADMISSION_NOTE, instant, isRuntimeTable, opsFailureFingerprint, ROUTE_SCOPE_HOSTNAMES_MAX, SCOPE_DUMP_PAGE_MAX_BYTES, SCOPE_GATE_REASONS, substratError } from '@substrat-run/contracts';
|
|
32
|
+
import { admittedBundleAudit, assertReplayableDump, AUTO_ADMISSION_NOTE, instant, isRuntimeTable, opsFailureFingerprint, ROUTE_SCOPE_HOSTNAMES_MAX, SCOPE_DUMP_PAGE_MAX_BYTES, SCOPE_GATE_REASONS, substratError } from '@substrat-run/contracts';
|
|
31
33
|
/**
|
|
32
34
|
* The router's per-request directory read (`readRoute`), lifted out so its plan can be asked for
|
|
33
35
|
* (#2005): the scope's hostname set is a correlated subquery on the hot path every request takes,
|
|
@@ -363,6 +365,8 @@ const DIRECTORY_DDL = `
|
|
|
363
365
|
migration_digest_derived INTEGER,
|
|
364
366
|
-- #2351: the digest of the migrations read from the version's bundle. NULL = never read.
|
|
365
367
|
migrations_extracted TEXT,
|
|
368
|
+
-- #3612: the sha256 the control plane took of the module bytes it stored. NULL = pushed before.
|
|
369
|
+
bundle_digest TEXT,
|
|
366
370
|
created_at TEXT NOT NULL,
|
|
367
371
|
UNIQUE (vertical_slug, version)
|
|
368
372
|
);
|
|
@@ -970,6 +974,9 @@ export const REPLIED_METHODS = [
|
|
|
970
974
|
// before the audit unit must refuse the name, not drop a trailing audit argument and commit.
|
|
971
975
|
'putTenantStoreAndAudit',
|
|
972
976
|
'putBlobStoreAndAudit',
|
|
977
|
+
// #3638: a bind judged by a named environment's checkpoints in its write. New, so a DO from before
|
|
978
|
+
// refuses it rather than commit the bind unjudged with the acknowledgement dropped.
|
|
979
|
+
'bindScopeVersionJudged',
|
|
973
980
|
'recordStoreDriverReleaseAndAudit',
|
|
974
981
|
'beginStoreDriverRolloutAndAudit',
|
|
975
982
|
'finishStoreDriverRolloutAndAudit',
|
|
@@ -1255,6 +1262,32 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
1255
1262
|
await this.directoryCutover.retry();
|
|
1256
1263
|
return this.directoryCutover.status();
|
|
1257
1264
|
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Whether the registry's record of each tenant's flag agrees with this directory's, which is the one
|
|
1267
|
+
* acted on in 3e (`directory-cutover.ts`, `cutoverParityOf`): a page of tenants in id order after
|
|
1268
|
+
* `after`, the drift among them, and where the next page starts. Staff only, and only when asked: it
|
|
1269
|
+
* runs on no alarm, writes nothing on either side, and changes no dispatch, so a disagreement is
|
|
1270
|
+
* reported here and nowhere acted on. Works whatever `DIRECTORY_CUTOVER` says, since a flag flipped
|
|
1271
|
+
* off stays on record; refused only where the registry is not bound.
|
|
1272
|
+
*/
|
|
1273
|
+
async directoryCutoverParity(query = {}) {
|
|
1274
|
+
const registry = Reflect.get(this.env, 'DIRECTORY_REGISTRY');
|
|
1275
|
+
if (!registry || typeof Reflect.get(registry, 'idFromName') !== 'function')
|
|
1276
|
+
return { enabled: false, reason: 'DIRECTORY_REGISTRY is not bound' };
|
|
1277
|
+
const limit = Math.max(1, Math.min(Math.trunc(query.limit ?? 100) || 100, PARITY_PAGE_MAX));
|
|
1278
|
+
const after = query.after ?? '';
|
|
1279
|
+
const flags = cutoverFlagsPage(this.sql, after, limit);
|
|
1280
|
+
// The same range on both sides: up to this page's last flag, or to the end when the page is the last.
|
|
1281
|
+
const upTo = flags.length === limit ? flags.at(-1).tenantId : null;
|
|
1282
|
+
const { records, truncated } = await registryStub(registry).tenantCutoversIn({ after, upTo, limit });
|
|
1283
|
+
if (truncated) {
|
|
1284
|
+
// The registry holds more in the range than one read carries: the page ends at its last record, so
|
|
1285
|
+
// no flag past it is judged against a record not read.
|
|
1286
|
+
const boundary = records.at(-1).tenantId;
|
|
1287
|
+
return cutoverParityPage(flags.filter((f) => f.tenantId <= boundary), records, boundary, true);
|
|
1288
|
+
}
|
|
1289
|
+
return cutoverParityPage(flags, records, upTo, false);
|
|
1290
|
+
}
|
|
1258
1291
|
// -- the routing read model (#3395) -------------------------------------------
|
|
1259
1292
|
/** Set where a `ROUTES` KV namespace is bound; null otherwise, and the read model is off. */
|
|
1260
1293
|
routePublisher = null;
|
|
@@ -1860,6 +1893,8 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
1860
1893
|
this.addColumn('vertical_versions', 'migration_digest_derived INTEGER');
|
|
1861
1894
|
// #2351: the digest of the migrations read from the bundle; NULL = never read.
|
|
1862
1895
|
this.addColumn('vertical_versions', 'migrations_extracted TEXT');
|
|
1896
|
+
// #3612: the sha256 the control plane took of the module bytes; NULL = pushed before.
|
|
1897
|
+
this.addColumn('vertical_versions', 'bundle_digest TEXT');
|
|
1863
1898
|
// #33: the SKU flag learns to express a plan. All nullable — a legacy row
|
|
1864
1899
|
// reads as a perpetual boolean flag, exactly its pre-widening semantics.
|
|
1865
1900
|
this.addColumn('_substrat_entitlements', 'expires_at TEXT');
|
|
@@ -3289,6 +3324,10 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
3289
3324
|
entitlementsCutOver(tenantId) {
|
|
3290
3325
|
return this.directoryCutover?.cutOverFor(tenantId, ENTITLEMENTS) ?? false;
|
|
3291
3326
|
}
|
|
3327
|
+
/** Whether the tenant's identity links are read from, and first written to, its own object (the fifth family). */
|
|
3328
|
+
identitiesCutOver(tenantId) {
|
|
3329
|
+
return this.directoryCutover?.cutOverFor(tenantId, IDENTITIES) ?? false;
|
|
3330
|
+
}
|
|
3292
3331
|
/** This directory as a `TupleStore`: its rows, its admin log, its orgs. */
|
|
3293
3332
|
tupleStore() {
|
|
3294
3333
|
return {
|
|
@@ -3459,8 +3498,12 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
3459
3498
|
}
|
|
3460
3499
|
/** Binding is read at call execution, so a queued invoke follows the current explicit choice. */
|
|
3461
3500
|
resolvePeerInstance(tenantId, callerScopeId, vertical) {
|
|
3462
|
-
const binding = this.peerBinding(tenantId, callerScopeId, vertical);
|
|
3463
3501
|
const tenant = this.peerTenant(tenantId);
|
|
3502
|
+
// D-83 (#3530 step 5): a caller that is not an install is answered per environment.
|
|
3503
|
+
const perEnvironment = environmentPeerResolutionIn(this.kernelSql, tenant, callerScopeId, vertical);
|
|
3504
|
+
if (perEnvironment)
|
|
3505
|
+
return perEnvironment;
|
|
3506
|
+
const binding = this.peerBinding(tenantId, callerScopeId, vertical);
|
|
3464
3507
|
return resolvePeerInstanceFrom(this.peerCandidates(tenant, vertical), tenant, vertical, binding?.target_scope_id ?? null, binding?.invalidated === 1);
|
|
3465
3508
|
}
|
|
3466
3509
|
peerBinding(tenantId, callerScopeId, vertical) {
|
|
@@ -3595,9 +3638,14 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
3595
3638
|
* `publish` (#3395, K-72) is the router's read-model miss: a dispatchable answer is queued for
|
|
3596
3639
|
* publishing unless it is published already. A directory that predates it ignores the argument.
|
|
3597
3640
|
* The answer is the same either way.
|
|
3641
|
+
*
|
|
3642
|
+
* `environments` (D-83, #3530 step 5) is a router that dispatches a named environment's pair as a
|
|
3643
|
+
* scope that is no install: only it is answered with the pair (`readPeerCallTarget`).
|
|
3598
3644
|
*/
|
|
3599
3645
|
peerCallTarget(tenantId, callerScopeId, callerVertical, vertical, opts) {
|
|
3600
|
-
const read = readPeerCallTarget(this.sql, tenantId, callerScopeId, callerVertical, vertical
|
|
3646
|
+
const read = readPeerCallTarget(this.sql, tenantId, callerScopeId, callerVertical, vertical, {
|
|
3647
|
+
environments: opts?.environments === true,
|
|
3648
|
+
});
|
|
3601
3649
|
if (opts?.publish === true && this.routePublisher) {
|
|
3602
3650
|
// Optional, as `readRoute`'s: a fill that cannot be queued must not fail a read that succeeded.
|
|
3603
3651
|
// This method's own return starts the flush (`kickRouteReadModelAfterEveryCall`).
|
|
@@ -3978,8 +4026,8 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
3978
4026
|
this.sql.exec(`INSERT INTO vertical_versions
|
|
3979
4027
|
(id, vertical_slug, version, manifest_digest, permission_digest,
|
|
3980
4028
|
migration_digest, deployment_ref, admission, admission_note, manifest_json,
|
|
3981
|
-
origin_json, migration_count, migrations_split, migration_digest_derived, created_at)
|
|
3982
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 1, ?)`, v.id, v.verticalSlug, v.version, v.manifestDigest, v.permissionDigest, v.migrationDigest, v.deploymentRef, admission, selfAdmits ? AUTO_ADMISSION_NOTE : null, v.manifestJson, v.originJson, v.migrations?.length ?? null, v.createdAt);
|
|
4029
|
+
origin_json, migration_count, migrations_split, migration_digest_derived, bundle_digest, created_at)
|
|
4030
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 1, ?, ?)`, v.id, v.verticalSlug, v.version, v.manifestDigest, v.permissionDigest, v.migrationDigest, v.deploymentRef, admission, selfAdmits ? AUTO_ADMISSION_NOTE : null, v.manifestJson, v.originJson, v.migrations?.length ?? null, v.bundleDigest ?? null, v.createdAt);
|
|
3983
4031
|
writeVersionMigrations(this.kernelSql, v.id, v.migrations);
|
|
3984
4032
|
// #2286: the version's scope-store bindings, refusing one moved to another driver, in the insert's transaction.
|
|
3985
4033
|
indexVersionScopeStores(this.kernelSql, v.verticalSlug, v.id, v.manifestJson);
|
|
@@ -4115,7 +4163,7 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
4115
4163
|
// failing the whole page on `->`.
|
|
4116
4164
|
const read = () => this.sql
|
|
4117
4165
|
.exec(`SELECT id, vertical_slug, version, manifest_digest, permission_digest, migration_digest,
|
|
4118
|
-
migration_digest_derived, deployment_ref, admission, admission_note, origin_json, created_at,
|
|
4166
|
+
migration_digest_derived, deployment_ref, admission, admission_note, origin_json, bundle_digest, created_at,
|
|
4119
4167
|
CASE WHEN json_valid(manifest_json) THEN manifest_json -> '$.outbound' END AS outbound_json,
|
|
4120
4168
|
CASE WHEN json_valid(manifest_json) THEN manifest_json -> '$.calls' END AS calls_json
|
|
4121
4169
|
FROM vertical_versions WHERE ${where.join(' AND ')}${tail}`, ...params)
|
|
@@ -4145,13 +4193,13 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
4145
4193
|
if (v.admission === 'admitted') {
|
|
4146
4194
|
if (v.admission_note !== AUTO_ADMISSION_NOTE)
|
|
4147
4195
|
return false;
|
|
4148
|
-
row = { before: { admission: v.admission, note: v.admission_note }, after: { admission: 'admitted', note: null } };
|
|
4196
|
+
row = { before: { admission: v.admission, note: v.admission_note }, after: { admission: 'admitted', note: null, ...admittedBundleAudit(id, v.bundle_digest) } };
|
|
4149
4197
|
}
|
|
4150
4198
|
else if (v.admission === 'rejected') {
|
|
4151
4199
|
throw substratError('conflict', `version ${id} was rejected — publish a new one`);
|
|
4152
4200
|
}
|
|
4153
4201
|
else {
|
|
4154
|
-
row = { before: { admission: v.admission }, after: { admission: 'admitted' } };
|
|
4202
|
+
row = { before: { admission: v.admission }, after: { admission: 'admitted', ...admittedBundleAudit(id, v.bundle_digest) } };
|
|
4155
4203
|
}
|
|
4156
4204
|
return this.sql.exec("UPDATE vertical_versions SET admission = 'admitted', admission_note = NULL WHERE id = ?", id)
|
|
4157
4205
|
.rowsWritten > 0;
|
|
@@ -4172,7 +4220,7 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
4172
4220
|
}, audit && (() => ({ ...audit, before, after: { admission: 'rejected', note } })));
|
|
4173
4221
|
}
|
|
4174
4222
|
versionAdmission(id) {
|
|
4175
|
-
const v = this.sql.exec('SELECT admission, admission_note FROM vertical_versions WHERE id = ?', id)
|
|
4223
|
+
const v = this.sql.exec('SELECT admission, admission_note, bundle_digest FROM vertical_versions WHERE id = ?', id)
|
|
4176
4224
|
.toArray()[0];
|
|
4177
4225
|
if (!v)
|
|
4178
4226
|
throw substratError('not_found', `unknown version ${id}`);
|
|
@@ -4183,10 +4231,28 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
4183
4231
|
* `servingRef` moves the route in the same write, and `expectedServing` holds it to what the
|
|
4184
4232
|
* target lineage's serving script runs, read in this same synchronous transaction.
|
|
4185
4233
|
*/
|
|
4186
|
-
|
|
4234
|
+
bindScopeVersionJudged(...args) {
|
|
4235
|
+
return this.bindScopeVersion(...args);
|
|
4236
|
+
}
|
|
4237
|
+
/**
|
|
4238
|
+
* The bind itself. A coordinator from before #3638 calls it directly; the current one calls
|
|
4239
|
+
* `bindScopeVersionJudged` through `reply`, so an environment's checkpoint refusal reaches it typed.
|
|
4240
|
+
*/
|
|
4241
|
+
bindScopeVersion(scopeId, versionId, verticalSlug, expectedVersionId, expectedErasureEpoch, confirmMove, servingRef, expectedServing, audit,
|
|
4242
|
+
/** #3638: what this bind acknowledges if the scope is a named environment's preview. */
|
|
4243
|
+
environmentAcknowledge) {
|
|
4244
|
+
// #3638 (D-83): a bind of a named environment's preview is judged against what that environment
|
|
4245
|
+
// serves, in this write, so a push carried onto it before its first own-script serve is held to the
|
|
4246
|
+
// checkpoints too. Every bind is judged, whatever the caller sent: an older coordinator's sends none.
|
|
4247
|
+
const judge = () => {
|
|
4248
|
+
const tenant = this.sql.exec('SELECT tenant_id FROM scopes WHERE scope_id = ?', scopeId).toArray()[0];
|
|
4249
|
+
const refusal = tenant ? environmentBindRefusalIn(this.kernelSql, tenant.tenant_id, scopeId, versionId, environmentAcknowledge) : null;
|
|
4250
|
+
if (refusal)
|
|
4251
|
+
throw refusal;
|
|
4252
|
+
};
|
|
4187
4253
|
return servingRef === undefined
|
|
4188
|
-
? this.moveScopeRow('vertical_version_id = ?, vertical = ?', [versionId, verticalSlug], scopeId, { expectedVersionId, expectedErasureEpoch, confirmMove, expectedServing }, audit)
|
|
4189
|
-
: this.moveScopeRow('vertical_version_id = ?, vertical = ?, serving_ref = ?', [versionId, verticalSlug, servingRef], scopeId, { expectedVersionId, expectedErasureEpoch, confirmMove, expectedServing }, audit);
|
|
4254
|
+
? this.moveScopeRow('vertical_version_id = ?, vertical = ?', [versionId, verticalSlug], scopeId, { expectedVersionId, expectedErasureEpoch, confirmMove, expectedServing }, audit, judge)
|
|
4255
|
+
: this.moveScopeRow('vertical_version_id = ?, vertical = ?, serving_ref = ?', [versionId, verticalSlug, servingRef], scopeId, { expectedVersionId, expectedErasureEpoch, confirmMove, expectedServing }, audit, judge);
|
|
4190
4256
|
}
|
|
4191
4257
|
/** #2347: whether a lineage's serving script still runs the version a rebind was judged against. */
|
|
4192
4258
|
servesNow(expected) {
|
|
@@ -4198,10 +4264,13 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
4198
4264
|
* claimed, and on its copy move still owning a live lease. The move's confirmation commits in
|
|
4199
4265
|
* the same transaction as the row. False when any condition failed and nothing was written.
|
|
4200
4266
|
*/
|
|
4201
|
-
moveScopeRow(set, setArgs, scopeId, cond, audit
|
|
4267
|
+
moveScopeRow(set, setArgs, scopeId, cond, audit,
|
|
4268
|
+
/** Judged first, in the write's own transaction: a throw refuses the move with nothing written. */
|
|
4269
|
+
judge) {
|
|
4202
4270
|
const now = new Date().toISOString();
|
|
4203
4271
|
let confirmedTenant;
|
|
4204
4272
|
const written = this.writeAndAudit(() => {
|
|
4273
|
+
judge?.();
|
|
4205
4274
|
const moved = this.sql.exec(`UPDATE scopes SET ${set} WHERE scope_id = ?
|
|
4206
4275
|
${cond.expectedVersionId === undefined ? '' : 'AND vertical_version_id IS ?'}
|
|
4207
4276
|
${cond.expectedErasureEpoch === undefined ? '' : 'AND COALESCE(erasure_epoch, 0) = ? AND reap_claimed_at IS NULL'}
|
|
@@ -5494,44 +5563,51 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
5494
5563
|
.filter((r) => !prefix || r.state_key.startsWith(prefix))
|
|
5495
5564
|
.map((r) => ({ key: r.state_key, value: r.value }));
|
|
5496
5565
|
}
|
|
5566
|
+
// -- identity links (K-22/K-23) ----------------------------------------------
|
|
5567
|
+
// K-68 step 3e (the fifth family): a tenant whose flip froze its identity links in reads them from,
|
|
5568
|
+
// and links and unlinks them first in, its own object (`directory-tenant-identities.ts`, the same
|
|
5569
|
+
// code in either store). The cross-tenant login reads above stay here: no tenant's object holds them.
|
|
5570
|
+
/**
|
|
5571
|
+
* Bind `provider:externalId` to `principal` in the tenant. False when the same binding is already
|
|
5572
|
+
* held (no admin row); a conflict when another principal holds it. With `audit`, a new link commits
|
|
5573
|
+
* with its admin row.
|
|
5574
|
+
*/
|
|
5497
5575
|
linkIdentity(provider, externalId, principal, tenantId, scopeId, createdAt, audit) {
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
return true;
|
|
5512
|
-
}, audit);
|
|
5576
|
+
if (this.identitiesCutOver(tenantId)) {
|
|
5577
|
+
return this.directoryCutover.tupleWrite(tenantId, {
|
|
5578
|
+
kind: 'linkIdentity', provider, externalId, principal, scopeId, createdAt, audit: (audit ?? null),
|
|
5579
|
+
}).then((r) => {
|
|
5580
|
+
if (r && 'conflict' in r)
|
|
5581
|
+
throw substratError('conflict', r.conflict);
|
|
5582
|
+
// An object from before this family answers nothing, having written nothing.
|
|
5583
|
+
if (!r || !('linked' in r))
|
|
5584
|
+
throw new Error(`tenant object did not link ${provider}:${externalId}: it predates the identity cut-over`);
|
|
5585
|
+
return r.linked;
|
|
5586
|
+
});
|
|
5587
|
+
}
|
|
5588
|
+
return this.writeAndAudit(() => linkIdentityIn({ sql: this.sql }, provider, externalId, principal, tenantId, scopeId, createdAt), audit);
|
|
5513
5589
|
}
|
|
5514
5590
|
/** Remove a principal's identity link(s) in a tenant. Returns whether a row was
|
|
5515
5591
|
* deleted so a no-op stays silent (idempotent). */
|
|
5516
5592
|
unlinkIdentity(tenantId, principal, audit) {
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
}
|
|
5593
|
+
if (this.identitiesCutOver(tenantId)) {
|
|
5594
|
+
return this.directoryCutover.tupleWrite(tenantId, {
|
|
5595
|
+
kind: 'unlinkIdentity', principal, audit: (audit ?? null),
|
|
5596
|
+
}).then((r) => {
|
|
5597
|
+
if (!r || !('unlinked' in r))
|
|
5598
|
+
throw new Error(`tenant object did not unlink ${principal}: it predates the identity cut-over`);
|
|
5599
|
+
return r.unlinked;
|
|
5600
|
+
});
|
|
5601
|
+
}
|
|
5602
|
+
return this.writeAndAudit(() => unlinkIdentityIn({ sql: this.sql }, tenantId, principal), audit);
|
|
5526
5603
|
}
|
|
5527
5604
|
resolveIdentity(tenantId, provider, externalId) {
|
|
5528
|
-
|
|
5529
|
-
.
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
return { principal: row.principal_id, scopeId: row.scope_id };
|
|
5605
|
+
if (this.identitiesCutOver(tenantId)) {
|
|
5606
|
+
return this.directoryCutover
|
|
5607
|
+
.tupleRead(tenantId, { kind: 'identity', provider, externalId })
|
|
5608
|
+
.then((r) => r ?? undefined);
|
|
5609
|
+
}
|
|
5610
|
+
return resolveIdentityIn(this.sql, tenantId, provider, externalId);
|
|
5535
5611
|
}
|
|
5536
5612
|
/**
|
|
5537
5613
|
* ALL of a tenant's identity links — the read behind identity-link projection
|
|
@@ -5539,13 +5615,13 @@ export class ControlPlaneDO extends DurableObject {
|
|
|
5539
5615
|
* `unlinkIdentity` hard-deletes (the admin log is the audit), so the projection
|
|
5540
5616
|
* is a full replace and a removed link is simply absent from the next snapshot.
|
|
5541
5617
|
* Not on the request hot path — this runs on the admin write path, projecting
|
|
5542
|
-
* into a tenant's scopes, and at provision/reconcile gathering.
|
|
5618
|
+
* into a tenant's scopes, and at provision/reconcile gathering. A cut-over
|
|
5619
|
+
* tenant's are its object's (3e).
|
|
5543
5620
|
*/
|
|
5544
5621
|
dumpTenantIdentities(tenantId) {
|
|
5545
|
-
|
|
5546
|
-
.
|
|
5547
|
-
|
|
5548
|
-
.toArray();
|
|
5622
|
+
if (this.identitiesCutOver(tenantId))
|
|
5623
|
+
return this.directoryCutover.tupleRead(tenantId, { kind: 'identities' });
|
|
5624
|
+
return dumpIdentityRows(this.sql, tenantId);
|
|
5549
5625
|
}
|
|
5550
5626
|
// -- admin audit log (control-plane.md §4.4) --------------------------------
|
|
5551
5627
|
/** Append one audit row. before/after are arbitrary JSON, stringified here. */
|