@substrat-run/adapter-sqlite 0.218.0 → 0.220.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/dev-connector-network.d.ts +21 -0
- package/dist/dev-connector-network.d.ts.map +1 -0
- package/dist/dev-connector-network.js +125 -0
- package/dist/dev-connector-network.js.map +1 -0
- package/dist/index.d.ts +63 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +300 -43
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -2,18 +2,22 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, realpathSync, rmSync, writeFileSync, writeSync } from 'node:fs';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
5
|
-
import { accessLogEntry, adminLogEntry, delegatedReadParams, operationSeriesCount, opsFailureEntry, opsFailureFingerprint, issueEntry, FRESHNESS_HEARTBEAT_MINUTES, sweepRunEntry, modelUsageEntry, ATTACHMENT_ADDED, ATTACHMENT_REMOVED, createTenantInput, domainEvent, domainEventInput, exportReadInput, importBatch, importCursorMove, exportsOfManifestJson, assertNoBindingShapeBreak, importsOfManifestJson, connectionLandingsOfManifestJson, connectorsOfManifestJson, entitlementGrant, entitlementGrantInput, eventId, meterReading, platformRequestInput, platformRequestId, identityLink, identityPool, instant, isSubstratError, connection, capabilityGrant, connectionGrant, connectionRevoke, connectionGrantRecord, connectionSecret, systemGrant, systemSwitch, systemSwitchRecord, peerSwitch, verticalCaller, verticalSlug as verticalSlugOf, subjectRef, requestFingerprint, createConnectionInput, connectLinkFilter, connectLinkKey, consumeConnectLinkInput, mintConnectLinkInput, projectedConnectionGrant, projectedConnectionKey, moduleManifest, createOrgInput, promotionAcknowledgement, bindAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding, publishVersionInput, AUTO_ADMISSION_NOTE, routeTarget, ROUTE_SCOPE_HOSTNAMES_MAX, registerVerticalInput, vertical as verticalSchema, verticalChannel, verticalVersion, objectRef, entityObjectRef, assertModuleEmittableType, assertKernelAuthoredType, grantRefFromProof, org as orgSchema, orgMembership, principalId, resolvedIdentity, identityMembership, roleDefinition, scope as scopeSchema, tenant as tenantSchema, tenantRole, principalBecomeCapabilityInput, principalBindLinkInput, mergeDumpPages, subjectShredReceipt, subjectAccessReceipt, SCOPE_TABLE_PAGE_DEFAULT, SCOPE_TABLE_PAGE_MAX, SCOPE_QUERY_ROW_MAX, verticalServingState, verticalTraceSampling, deploymentWireAuth, callsOfManifestJson, outboundOfManifestJson, listLimitOf, pageOf, countedPageOf, SCOPE_GATE_REASONS, substratError, assertReplayableDump, DUMP_OBJECTS_QUERY, dumpObjectsAudit, dumpObjectsOf, isRuntimeTable, replayDumpObjects, delegatedReadRecord, ownerTransferAudit, memberChangeAudit, peerBindingAudit, connectionBindingAudit, copyMarkAudit, orphanSweepAudit, deliveryRedriveAudit, brokerDeadLetterAudit, redrainEventsInput, REDRAIN_BATCH, errorCodeOf, storeDriverDumpPageBytes, } from '@substrat-run/contracts';
|
|
6
|
-
import { actorOf, asPrincipal, assertAllowed, assertNoSecret, assertPermissionKey, CAPABILITY_DDL, UPLOAD_LINK_DDL, DOWNLOAD_LINK_DDL, createAttachmentVerbs, inspectUploadLink, resolveDownloadLink, redeemUploadLinkInTransaction, redeemOrReplayUploadLink, COPY_ORIGIN_DDL, ENTITY_STATE_MOVES_DDL, CAPABILITY_EXCHANGE_OPERATION, CAPABILITY_BECOME_MINT_OPERATION, CAPABILITY_BIND_MINT_OPERATION, bindLinkMintCheck, mintBindLinkAsPrincipal, becomeMintCheck, mintBecomeCapabilityAsPrincipal, revokeBecomeCapabilityAsPrincipal, readBecomeLinkStates, ENTITY_UNBIND_OPERATION, allowedFor, unbindEntityHolderBounded, capabilityAttachmentWriteRefused, capabilityTokenHash, createCapabilityVerbs, createEntityEdgeVerbs, createEntityStateVerbs, createTrashedReads, CONTINUATION_POSITION_CAP, visibleContinuation, searchStateWhere, uncheckedView, addStatePlans, addUpdatedStampPlans, watchUpdatedStamps, entityStateMigrations, assertNoCallerPurge, assertPlatformRequestRoom, isUnreachableParent, heldPurgePass, purgeDueOf, purgeHeldBy, lifecycleRefusal, scopeNotHeldRefusal, purgeOnlyKeysOf, purgeReportOf, purgeStillDue, refuseTrashedTarget, assertBoundOperations, checkHeldOperationsOf, countChecks, noteUncheckedCompletion, registerTrashTargets, runPurgePass, withheldKeysFor, capCoverage, delegationCeilingOf, delegationStampOf, outsideCeiling, heldKeysOf, parseScopeDelegation, statefulTablesOf, afterMigration, afterRuntimeDdl, derivesAnything, repairDerivedObjects, StateColumnLost, exchangeCapability as exchangeCapabilitySecret, exchangeBecomeLinkById, guardSecrets, mintBecomeCapability, plausibleSessionToken, readCapabilityPage, redactSecrets, redactSecretText, moduleLog, consoleLogSink, asyncInvocationId, asyncLinePass, consoleInvocationLineSink, resolveCapabilitySession, revokeCapabilityAsPlatform, assertReadOnlyQuery, attachmentBlobKey, attachmentSha256, isSizedByteStream, knownLengthStream, openAttachmentByteStream, putAttachmentBytes, refuseEntitlement, requiredEntitlementFor, foldMeterReading, guardSpine, guardSqlLimits, DO_SQL_LIMITS, tooManyResultColumns, tooManyTableColumns, parseValidationRecords, readableScopes, resolveScopeRecord, ulid, ISSUE_RETENTION_DAYS, telemetryRetentionStatements, FINDINGS_DDL, ATTACHMENT_BYTES_SQL, SCOPE_STORAGE_DDL, forgetScopeStorage, listScopeAttachmentStorageRows, retireScopeStorage, listScopeStorageAttemptRows, listScopeStorageRows, 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, DIRECTORY_LAKE_DDL, ACCESS_SUMMARY_METHOD, AccessSummary, openAccessSummary, ackDirectoryOutbox, ensureDirectoryLakeTriggers, advanceDirectoryLakeBackfill, pruneDirectoryLakeWindow, readDirectoryLakeBackfill, readDirectoryLakeCapture, readDirectoryOutbox, setDirectoryLakeCapture, STALE_SCOPES_DDL, listStaleScopeRows, listStaleScopeTakeRows, recordStaleScopeRows, VERTICAL_OWNERS_BACKFILL, VERTICAL_OWNERS_DDL, closeVerticalOwnerRow, listVerticalOwnerRows, openVerticalOwnerRow, verticalOwnerNow, listMeterDayRows, listMeterDayTakeRows, pruneMeterDayRows, recordMeterDayRows, CONNECT_LINKS_DDL, consumeConnectLinkRow, insertConnectLink, listConnectLinks as listConnectLinkRows, readConnectLink, restoreConnectLinkRow, revokeConnectLinkRow, createFindingRule, findingOfOpsFailure, findingOfSweepRun, pruneFindings, listFindingRules, listFindings, observeFinding, revokeFindingRule, setFindingStatus, assertRowLimit, assertRowOffset, OPS_FAILURE_RETENTION_DAYS, SWEEP_RUN_RETENTION_DAYS, SWEEP_RUNS_INTENT_INDEX, sweepRunsIntentHasKind, CONNECTIONS_LIVE_INDEX, connectionsLiveIndexHasOwner, BUILD_USAGE_RETENTION_DAYS, MODEL_USAGE_RETENTION_DAYS, foldModelUsage, backoffAt, platformRequestHistoryQuery, platformRequestOf, PLATFORM_REQUEST_COLUMNS, PLATFORM_REQUEST_REDACTION_SQL, platformRequestRedactionParams, platformRequestRedactionQuery, intentPayloadCarriesSubject, redactSubjectJobRuns, eraseSubjectFromModules, readSubjectPage, moduleRowsErased, moduleErasurePlan, redactSubjectScopeText, redactSubjectDirectoryText, ISSUE_EXEMPLAR_OWNER_BACKFILL_SQL, issueExemplarOwner, 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_STEP_RECORD_SQL, JOB_LEASE_EXPIRED_NOTE, assertLeaseMs, DELIVERY_ERROR_REDACTION_SQL, REDACTED_DELIVERY_NOTE, seatScopeTuple, applyScopeRoleChange, changeScopeRole, revokeScopeRoles, scopeRoleHolders, assertModuleDeclared, noteDeclaredKeys, noteReservedKeys, dumpRoleRefusal, reservedGrantRefusal, reservedRoleDefinitionRefusal, reservedRoleRefusal, reservedShapeRefusal, SCOPE_SEATED_ROLES_SQL, SEAT_HOLDING_SCOPE_STATUSES, TENANT_SEATED_ROLES_SQL, admitPeer, boundToPeerDeclarations, peerCallerAt, collectPeers, peerSeats, resolveVerticalInstanceFrom, resolvePeerInstanceFrom, peerVerticalSpellings, samePeerVertical, peerGrantsStatus, systemGrantsStatus, systemScheduleState, systemSwitchedOff, systemSwitchedOffMessage, tenantSystemSwitchedOffMessage, PEER_SWITCHES_DDL, PEER_BINDINGS_DDL, SWITCH_OWED_DDL, SWITCH_FENCES_DDL, TABLE_OWNERS_DDL, assertMigrationLeavesLedgerAlone, recordOwnershipSteps, runMigrationStatements, executableSqlStatements, blankSqlComments, recordWriteSuperseded, switchFencesOf, switchSupersededMessage, SWITCH_KINDS, SYSTEM_SWITCHES_DDL, forgetSwitchesOf, listSystemSwitchRecords, moveSwitch, reassertActionOf, reassertEntry, reassertOffRow, recordSwitchedOff, recordSwitchedOn, restoreSwitchRecord, scopesSwitchedOffFor, switchActionOf, switchAuditSubject, recordAuditOutcome, auditedCapabilityRevoke, auditedScopePermissionWrite, auditWarningOf, switchNotFoundMessage, switchRecordsOf, switchedOffOf, switchesBackfillSqlOf, switchesTableExists, tenantHeldOf, tenantHoldsGrant, inUnitMovesToAudit, staleCarryRevertRow, staleCarryReverts, withRecorded, VERSION_MIGRATIONS_DDL, VERTICAL_SCOPE_STORES_DDL, forgetVerticalScopeStores, DEPLOYMENT_WIRE_AUTH_DDL, assertWireAuthFilter, deploymentWireAuthOf, forgetVerticalWireAuth, wireAuthAccessTarget, writeDeploymentWireAuth, indexVersionScopeStores, driverDeclarationsOf, verticalScopeStoresOf, STORE_DRIVER_RELEASES_DDL, approveStoreDriverReleaseIn, legacyStoreDriverConflict, legacyStoreDriverRenames, beginStoreDriverRolloutIn, finishStoreDriverRolloutIn, holdStoreDriverIn, advanceStoreDriverRebuildIn, claimStoreDriverRebuildIn, storeDriverRebuildIn, recordStoreDriverReleaseIn, recordStoreDriverRevokeWalkIn, releaseStoreDriverHoldIn, revokeStoreDriverReleaseIn, liveStoreDriverApprovalIn, storeDriverApprovalsIn, storeDriverRevokeWalkIn, storeDriverReleaseIn, storeDriverStateIn, storeDriverRolloutPendingIn, storeDriverRolloutWalkedIn, splitManifestMigrations, splitVersionMigrationsBatch, versionMigrationsOf, versionMigrationsExtractedOf, recordVersionMigrationsExtracted, deriveVersionMigrationDigest, publishedMigrationDigest, migrationChangeRefusal, writeVersionMigrations, OUTBOX_PRUNED_DDL, outboxSubscribersOf, pruneDrainedOutbox, pruneInputOf, denialListQuery, refusalListQuery, mapRefusalRow, denialSummaryQuery, denialTotalsQuery, DENIAL_WINDOW_QUERY, mapDenialRow, mapDenialSummaryBuckets, IMPERSONATION_COLUMNS, IMPERSONATION_DDL, ImpersonationRefused, assertImpersonationAdmitted, assertImpersonationWrites, assertModuleEnqueueableKind, assertSessionUsable, impersonationByIdQuery, impersonationListQuery, impersonationRowValues, impersonationStampOf, mapImpersonationRow, newImpersonationSession, resolveRetryPolicy, executorOutcomeOf, isDeliveryRefusal, refusalJournalText, membershipFencesBackfillSql, MEMBERSHIP_FENCES_DDL, membershipFencesTableExists, MEMBERSHIP_FENCE_SINCE_SQL, RAISE_MEMBERSHIP_FENCE_SQL, memberAddedAudit, orgChangeBound, tenantCoverage, isSecretBoxConfigured, unconfiguredSecretBox, createSubjectKeys, generateSealingKeyPair, noSealingKeyMessage, openSealed, sealTo, ConnectionSealingKeyUnavailableError, PermissionDenied, createAtomic, NotSearchable, NotListable, listIndexMigrations, listIndexPlans, listQuery, cursorOf, moduleMigrations, MIGRATION_DIGEST_FENCE_DDL, MIGRATION_DIGEST_MARK_LEGACY, assertJournalDumpCoherent, assertMigrationSql, migrationDivergence, migrationFailedError, migrationSetDivergence, migrationSteps, planMigrations, isSearchIndexTable, rowCountTable, searchIndexMigrations, searchIndexPlans, searchLimit, searchMatchExpression, searchQuery, ATTACHMENT_TEXT_DDL, ATTACHMENT_CONDEMNED_DDL, ATTACHMENT_SWEEP_LICENCE_DDL, ATTACHMENT_SWEEP_LICENCE_TABLE, clearOrphanSweepLicence, condemnLicensedOrphanAttachments, consumeOrphanSweepLicence, licensedOrphanIds, recordOrphanSweepLicence, refuseUnlicensedOrphanSweep, fenceAttachmentSweep, refuseCondemnedAttachment, refuseCondemnedInDump, rowlessAttachmentIds, sweepOrphanAttachments, missingAttachmentStore, SETTLED_COPY_STATES, unsettledCopyRefusal, assertAttachmentExtractors, resolveAttachmentTextBounds, assertJobRegistrable, attachmentRecordOfRow, attachmentTextJob, enqueueAttachmentText, ATTACHMENT_TEXT_BACKFILL_JOB, ATTACHMENT_TEXT_JOB, kernelJobFor, queueAttachmentTextBackfill, startAttachmentTextBackfill, attachmentTextBackfillJob, reconcileAttachmentText, recordAttachmentText, searchAttachments, 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, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, noteTransitionInto, withTransitions, exportedSinceQuery, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, importCursorSourceOf, exportBreaksOf, exportBreakRefusal, assertPromoteReviewCurrent, promoteRaceRefusal, servingRaceRefusal, autoAdmittedProdRefusal, listedPromoteRefusal, rebindRaceRefusal, SERVES_NOW_CONDITION, SERVES_NOW_PREDICATE, servesNowParams, migratesFrom, servedFromRow, servesAsFrom, bindExportBreaksOf, bindExportBreakRefusal, scopeMoveOf, runningVersionOf, isPrimaryScope, PROVISIONED_VERSIONS_SQL, installsReconciledOf, strandJudgmentsOf, provisionedVersionsParams, boundShapesColumn, boundShapesOfColumn, installReconciled, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, WIRE_NONCE_DDL, WIRE_NONCE_FULL, claimWireNonceIn, isWireNonceTable, JOB_RUN_DDL, JOB_RUN_DUE_AT, jobRunListLimit, jobRunOf, runDueJobRuns, startJobRun, IDEMPOTENCY_DDL, REFUSALS_TABLE_DDL, REFUSALS_INDEX, refusalInsert, refusalOf, markGuardRefusal, REFUSALS_REBUILD, refusalsAdmitGuards, assertIdempotencyKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, globalFetch, fetchLikeOf, deadlineFetch, createUlid, facetEvents, readHistory, walkEventCause, walkEventEffects, assertRedrainWindow, readInvocation, readDeadLetters, readLifecycleFlow, readOperationSeries, domainEventOf, readUndrainedOutbox, undrainedEventsOf, connectorCallRecord, noopConnectorCallRecorder, recordConnectorCall, settleConnectionUse, unknownRoleError, callReservedStoreOperation, storesFencedRefusal, readStoreDump, writeStoreDump, callScopeStore, observeStoreCall, replayStoreErasures, scopeStoreLifecycleOf, scopeStoreRunnersOf, } from '@substrat-run/kernel';
|
|
5
|
+
import { accessLogEntry, adminLogEntry, delegatedReadParams, operationSeriesCount, opsFailureEntry, opsFailureFingerprint, issueEntry, FRESHNESS_HEARTBEAT_MINUTES, sweepRunEntry, modelUsageEntry, ATTACHMENT_ADDED, ATTACHMENT_REMOVED, createTenantInput, domainEvent, domainEventInput, exportReadInput, importBatch, pushedImport, moduleId, importCursorMove, exportsOfManifestJson, assertNoBindingShapeBreak, importsOfManifestJson, connectionLandingsOfManifestJson, connectorsOfManifestJson, entitlementGrant, entitlementGrantInput, eventId, meterReading, platformRequestInput, platformRequestId, identityLink, identityPool, instant, isSubstratError, connection, capabilityGrant, connectionGrant, connectionRevoke, connectionGrantRecord, connectionSecret, systemGrant, systemSwitch, systemSwitchRecord, peerSwitch, verticalCaller, verticalSlug as verticalSlugOf, subjectRef, requestFingerprint, createConnectionInput, connectLinkFilter, connectLinkKey, consumeConnectLinkInput, mintConnectLinkInput, projectedConnectionGrant, projectedConnectionKey, moduleManifest, createOrgInput, promotionAcknowledgement, bindAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding, publishVersionInput, AUTO_ADMISSION_NOTE, routeTarget, ROUTE_SCOPE_HOSTNAMES_MAX, registerVerticalInput, vertical as verticalSchema, verticalChannel, verticalVersion, objectRef, entityObjectRef, assertModuleEmittableType, assertKernelAuthoredType, grantRefFromProof, org as orgSchema, orgMembership, principalId, resolvedIdentity, identityMembership, roleDefinition, scope as scopeSchema, tenant as tenantSchema, tenantRole, principalBecomeCapabilityInput, principalBindLinkInput, mergeDumpPages, subjectShredReceipt, subjectAccessReceipt, SCOPE_TABLE_PAGE_DEFAULT, SCOPE_TABLE_PAGE_MAX, SCOPE_QUERY_ROW_MAX, verticalServingState, verticalTraceSampling, deploymentWireAuth, callsOfManifestJson, outboundOfManifestJson, listLimitOf, pageOf, countedPageOf, SCOPE_GATE_REASONS, substratError, assertReplayableDump, DUMP_OBJECTS_QUERY, dumpObjectsAudit, dumpObjectsOf, isRuntimeTable, replayDumpObjects, delegatedReadRecord, ownerTransferAudit, memberChangeAudit, peerBindingAudit, connectionBindingAudit, copyMarkAudit, orphanSweepAudit, deliveryRedriveAudit, brokerDeadLetterAudit, redrainEventsInput, REDRAIN_BATCH, errorCodeOf, storeDriverDumpPageBytes, } from '@substrat-run/contracts';
|
|
6
|
+
import { actorOf, asPrincipal, assertAllowed, assertNoSecret, assertPermissionKey, CAPABILITY_DDL, UPLOAD_LINK_DDL, DOWNLOAD_LINK_DDL, createAttachmentVerbs, inspectUploadLink, resolveDownloadLink, redeemUploadLinkInTransaction, redeemOrReplayUploadLink, COPY_ORIGIN_DDL, ENTITY_STATE_MOVES_DDL, CAPABILITY_EXCHANGE_OPERATION, CAPABILITY_BECOME_MINT_OPERATION, CAPABILITY_BIND_MINT_OPERATION, bindLinkMintCheck, mintBindLinkAsPrincipal, becomeMintCheck, mintBecomeCapabilityAsPrincipal, revokeBecomeCapabilityAsPrincipal, readBecomeLinkStates, ENTITY_UNBIND_OPERATION, allowedFor, unbindEntityHolderBounded, capabilityAttachmentWriteRefused, capabilityTokenHash, createCapabilityVerbs, createEntityEdgeVerbs, createEntityStateVerbs, createTrashedReads, CONTINUATION_POSITION_CAP, visibleContinuation, searchStateWhere, uncheckedView, addStatePlans, addUpdatedStampPlans, watchUpdatedStamps, entityStateMigrations, assertNoCallerPurge, assertPlatformRequestRoom, isUnreachableParent, heldPurgePass, purgeDueAt, purgeDueOf, purgeHeldBy, lifecycleRefusal, scopeNotHeldRefusal, purgeOnlyKeysOf, purgeReportOf, purgeStillDue, refuseTrashedTarget, assertBoundOperations, checkHeldOperationsOf, countChecks, noteUncheckedCompletion, registerTrashTargets, runPurgePass, withheldKeysFor, capCoverage, delegationCeilingOf, delegationStampOf, outsideCeiling, heldKeysOf, parseScopeDelegation, statefulTablesOf, afterMigration, afterRuntimeDdl, derivesAnything, repairDerivedObjects, StateColumnLost, exchangeCapability as exchangeCapabilitySecret, exchangeBecomeLinkById, guardSecrets, mintBecomeCapability, plausibleSessionToken, readCapabilityPage, redactSecrets, redactSecretText, moduleLog, consoleLogSink, asyncInvocationId, asyncLinePass, consoleInvocationLineSink, resolveCapabilitySession, revokeCapabilityAsPlatform, assertReadOnlyQuery, attachmentBlobKey, attachmentSha256, isSizedByteStream, knownLengthStream, openAttachmentByteStream, putAttachmentBytes, refuseEntitlement, requiredEntitlementFor, foldMeterReading, guardSpine, guardSqlLimits, DO_SQL_LIMITS, tooManyResultColumns, tooManyTableColumns, parseValidationRecords, readableScopes, resolveScopeRecord, ulid, ISSUE_RETENTION_DAYS, telemetryRetentionStatements, FINDINGS_DDL, ATTACHMENT_BYTES_SQL, SCOPE_STORAGE_DDL, forgetScopeStorage, listScopeAttachmentStorageRows, retireScopeStorage, listScopeStorageAttemptRows, listScopeStorageRows, 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, DIRECTORY_LAKE_DDL, ACCESS_SUMMARY_METHOD, AccessSummary, openAccessSummary, ackDirectoryOutbox, ensureDirectoryLakeTriggers, advanceDirectoryLakeBackfill, pruneDirectoryLakeWindow, readDirectoryLakeBackfill, readDirectoryLakeCapture, readDirectoryOutbox, setDirectoryLakeCapture, STALE_SCOPES_DDL, listStaleScopeRows, listStaleScopeTakeRows, recordStaleScopeRows, VERTICAL_OWNERS_BACKFILL, VERTICAL_OWNERS_DDL, closeVerticalOwnerRow, listVerticalOwnerRows, openVerticalOwnerRow, verticalOwnerNow, listMeterDayRows, listMeterDayTakeRows, pruneMeterDayRows, recordMeterDayRows, CONNECT_LINKS_DDL, consumeConnectLinkRow, insertConnectLink, listConnectLinks as listConnectLinkRows, readConnectLink, restoreConnectLinkRow, revokeConnectLinkRow, createFindingRule, findingOfOpsFailure, findingOfSweepRun, pruneFindings, listFindingRules, listFindings, observeFinding, revokeFindingRule, setFindingStatus, assertRowLimit, assertRowOffset, OPS_FAILURE_RETENTION_DAYS, SWEEP_RUN_RETENTION_DAYS, SWEEP_RUNS_INTENT_INDEX, sweepRunsIntentHasKind, CONNECTIONS_LIVE_INDEX, connectionsLiveIndexHasOwner, BUILD_USAGE_RETENTION_DAYS, MODEL_USAGE_RETENTION_DAYS, foldModelUsage, backoffAt, platformRequestHistoryQuery, platformRequestOf, PLATFORM_REQUEST_COLUMNS, PLATFORM_REQUEST_REDACTION_SQL, platformRequestRedactionParams, platformRequestRedactionQuery, intentPayloadCarriesSubject, redactSubjectJobRuns, eraseSubjectFromModules, readSubjectPage, moduleRowsErased, moduleErasurePlan, redactSubjectScopeText, redactSubjectDirectoryText, ISSUE_EXEMPLAR_OWNER_BACKFILL_SQL, issueExemplarOwner, 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_STEP_RECORD_SQL, JOB_LEASE_EXPIRED_NOTE, assertLeaseMs, DELIVERY_ERROR_REDACTION_SQL, REDACTED_DELIVERY_NOTE, seatScopeTuple, applyScopeRoleChange, changeScopeRole, revokeScopeRoles, scopeRoleHolders, assertModuleDeclared, noteDeclaredKeys, noteReservedKeys, dumpRoleRefusal, reservedGrantRefusal, reservedRoleDefinitionRefusal, reservedRoleRefusal, reservedShapeRefusal, SCOPE_SEATED_ROLES_SQL, SEAT_HOLDING_SCOPE_STATUSES, TENANT_SEATED_ROLES_SQL, admitPeer, boundToPeerDeclarations, peerCallerAt, collectPeers, peerSeats, resolveVerticalInstanceFrom, resolvePeerInstanceFrom, peerVerticalSpellings, samePeerVertical, peerGrantsStatus, systemGrantsStatus, systemScheduleState, systemSwitchedOff, systemSwitchedOffMessage, tenantSystemSwitchedOffMessage, PEER_SWITCHES_DDL, PEER_BINDINGS_DDL, APP_ENVIRONMENTS_DDL, defineEnvironmentIn, environmentsOf, removeEnvironmentIn, SWITCH_OWED_DDL, SWITCH_FENCES_DDL, TABLE_OWNERS_DDL, assertMigrationLeavesLedgerAlone, recordOwnershipSteps, runMigrationStatements, executableSqlStatements, blankSqlComments, recordWriteSuperseded, switchFencesOf, switchSupersededMessage, SWITCH_KINDS, SYSTEM_SWITCHES_DDL, forgetSwitchesOf, listSystemSwitchRecords, moveSwitch, reassertActionOf, reassertEntry, reassertOffRow, recordSwitchedOff, recordSwitchedOn, restoreSwitchRecord, scopesSwitchedOffFor, switchActionOf, switchAuditSubject, recordAuditOutcome, auditedCapabilityRevoke, auditedScopePermissionWrite, auditWarningOf, switchNotFoundMessage, switchRecordsOf, switchedOffOf, switchesBackfillSqlOf, switchesTableExists, tenantHeldOf, tenantHoldsGrant, inUnitMovesToAudit, staleCarryRevertRow, staleCarryReverts, withRecorded, VERSION_MIGRATIONS_DDL, VERTICAL_SCOPE_STORES_DDL, forgetVerticalScopeStores, DEPLOYMENT_WIRE_AUTH_DDL, assertWireAuthFilter, deploymentWireAuthOf, forgetVerticalWireAuth, wireAuthAccessTarget, writeDeploymentWireAuth, indexVersionScopeStores, driverDeclarationsOf, verticalScopeStoresOf, STORE_DRIVER_RELEASES_DDL, approveStoreDriverReleaseIn, legacyStoreDriverConflict, legacyStoreDriverRenames, beginStoreDriverRolloutIn, finishStoreDriverRolloutIn, holdStoreDriverIn, advanceStoreDriverRebuildIn, claimStoreDriverRebuildIn, storeDriverRebuildIn, recordStoreDriverReleaseIn, recordStoreDriverRevokeWalkIn, releaseStoreDriverHoldIn, revokeStoreDriverReleaseIn, liveStoreDriverApprovalIn, storeDriverApprovalsIn, storeDriverRevokeWalkIn, storeDriverReleaseIn, storeDriverStateIn, storeDriverRolloutPendingIn, storeDriverRolloutWalkedIn, splitManifestMigrations, splitVersionMigrationsBatch, versionMigrationsOf, versionMigrationsExtractedOf, recordVersionMigrationsExtracted, deriveVersionMigrationDigest, publishedMigrationDigest, migrationChangeRefusal, writeVersionMigrations, OUTBOX_PRUNED_DDL, outboxSubscribersOf, pruneDrainedOutbox, pruneInputOf, denialListQuery, refusalListQuery, mapRefusalRow, denialSummaryQuery, denialTotalsQuery, DENIAL_WINDOW_QUERY, mapDenialRow, mapDenialSummaryBuckets, IMPERSONATION_COLUMNS, IMPERSONATION_DDL, ImpersonationRefused, assertImpersonationAdmitted, assertImpersonationWrites, assertModuleEnqueueableKind, assertSessionUsable, impersonationByIdQuery, impersonationListQuery, impersonationRowValues, impersonationStampOf, mapImpersonationRow, newImpersonationSession, resolveRetryPolicy, executorOutcomeOf, isDeliveryRefusal, refusalJournalText, membershipFencesBackfillSql, MEMBERSHIP_FENCES_DDL, membershipFencesTableExists, MEMBERSHIP_FENCE_SINCE_SQL, RAISE_MEMBERSHIP_FENCE_SQL, memberAddedAudit, orgChangeBound, tenantCoverage, isSecretBoxConfigured, unconfiguredSecretBox, createSubjectKeys, generateSealingKeyPair, noSealingKeyMessage, openSealed, sealTo, ConnectionSealingKeyUnavailableError, PermissionDenied, createAtomic, NotSearchable, NotListable, listIndexMigrations, listIndexPlans, listQuery, cursorOf, moduleMigrations, MIGRATION_DIGEST_FENCE_DDL, MIGRATION_DIGEST_MARK_LEGACY, assertJournalDumpCoherent, assertMigrationSql, migrationDivergence, migrationFailedError, migrationSetDivergence, migrationSteps, planMigrations, isSearchIndexTable, rowCountTable, searchIndexMigrations, searchIndexPlans, searchLimit, searchMatchExpression, searchQuery, ATTACHMENT_TEXT_DDL, ATTACHMENT_CONDEMNED_DDL, ATTACHMENT_SWEEP_LICENCE_DDL, ATTACHMENT_SWEEP_LICENCE_TABLE, clearOrphanSweepLicence, condemnLicensedOrphanAttachments, consumeOrphanSweepLicence, licensedOrphanIds, recordOrphanSweepLicence, refuseUnlicensedOrphanSweep, fenceAttachmentSweep, refuseCondemnedAttachment, refuseCondemnedInDump, rowlessAttachmentIds, sweepOrphanAttachments, missingAttachmentStore, SETTLED_COPY_STATES, unsettledCopyRefusal, assertAttachmentExtractors, resolveAttachmentTextBounds, assertJobRegistrable, attachmentRecordOfRow, attachmentTextJob, enqueueAttachmentText, ATTACHMENT_TEXT_BACKFILL_JOB, ATTACHMENT_TEXT_JOB, ATTACHMENT_TEXT_RECHECK_JOB, kernelJobFor, queueAttachmentTextBackfill, startAttachmentTextBackfill, attachmentTextBackfillJob, attachmentExtractorSetKey, attachmentTextRecheckJob, readAttachmentTextRecheckPage, requeueUnsupportedAttachmentText, startAttachmentTextRecheck, reconcileAttachmentText, recordAttachmentText, searchAttachments, 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, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, noteTransitionInto, withTransitions, exportedSinceQuery, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, importCursorSourceOf, exportBreaksOf, exportBreakRefusal, assertPromoteReviewCurrent, promoteRaceRefusal, servingRaceRefusal, autoAdmittedProdRefusal, listedPromoteRefusal, rebindRaceRefusal, SERVES_NOW_CONDITION, SERVES_NOW_PREDICATE, servesNowParams, migratesFrom, servedFromRow, servesAsFrom, bindExportBreaksOf, bindExportBreakRefusal, scopeMoveOf, runningVersionOf, isPrimaryScope, PROVISIONED_VERSIONS_SQL, installsReconciledOf, strandJudgmentsOf, provisionedVersionsParams, boundShapesColumn, boundShapesOfColumn, installReconciled, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, WIRE_NONCE_DDL, WIRE_NONCE_FULL, claimWireNonceIn, isWireNonceTable, JOB_RUN_DDL, JOB_RUN_DUE_AT, jobRunListLimit, jobRunOf, runDueJobRuns, startJobRun, IDEMPOTENCY_DDL, REFUSALS_TABLE_DDL, REFUSALS_INDEX, refusalInsert, refusalOf, markGuardRefusal, REFUSALS_REBUILD, refusalsAdmitGuards, assertIdempotencyKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, globalFetch, fetchLikeOf, deadlineFetch, createUlid, facetEvents, readHistory, walkEventCause, walkEventEffects, assertRedrainWindow, readInvocation, readDeadLetters, readLifecycleFlow, readOperationSeries, domainEventOf, readUndrainedOutbox, undrainedEventsOf, connectorCallRecord, noopConnectorCallRecorder, recordConnectorCall, settleConnectionUse, unknownRoleError, callReservedStoreOperation, storesFencedRefusal, readStoreDump, writeStoreDump, callScopeStore, observeStoreCall, replayStoreErasures, scopeStoreLifecycleOf, scopeStoreRunnersOf, } from '@substrat-run/kernel';
|
|
7
7
|
import { handoffOutcome, reportHandoff, traceIdOf } from '@substrat-run/kernel';
|
|
8
|
+
// #2993: the modules a scope of each declared type runs, and the type a provision fixes.
|
|
9
|
+
import { HOME_SCOPE_TYPE, operationNotInScopeType, provisionedScopeType, scopeTypePlanOf, scopeTypeRuns } from '@substrat-run/kernel';
|
|
8
10
|
import { currentTraceparent } from '@substrat-run/kernel/invocation-line';
|
|
9
11
|
import { attributedView, delegatedRevokeSql, writeExplicitTupleIn, grantEntityShapeIn, shapeTopUpBatch, topUpEntityGrantShapes, settlePlatformRequestIn, } from '@substrat-run/kernel';
|
|
10
12
|
import { assertSameAttachmentGate, attachmentGateOf, decideAttachmentRemove, } from '@substrat-run/kernel';
|
|
11
13
|
import { DIRECTORY_CLAIMS_DDL, DIRECTORY_CROSSINGS_DDL, oneDatabaseDirectoryObjects, } from '@substrat-run/kernel';
|
|
12
14
|
import { canonicalInstant } from '@substrat-run/kernel';
|
|
13
|
-
import { advanceMarks, handoffQueries, messagesOf } from '@substrat-run/kernel';
|
|
15
|
+
import { advanceMarks, handoffQueries, messagesOf, senderDeliveryOf, } from '@substrat-run/kernel';
|
|
14
16
|
import { intentStateOf, intentStateQuery, witnessesOf, witnessQueries, } from '@substrat-run/kernel';
|
|
15
17
|
import { MARKUP_INSERT_SQL, MARKUP_SELECT_FOR_TENANT_SQL, MARKUP_SELECT_SQL, markupRecordValues, markupScheduleOf, newMarkupRow, } from '@substrat-run/kernel';
|
|
16
18
|
import { prePromoteSnapshotExpiresAt } from '@substrat-run/kernel';
|
|
19
|
+
import { breakingWithinMajorRefusal, earlierMajorsOf, releaseWithinMajorRefusal, SCRIPT_SERVING_VERSION_SQL, supersededMajorsJson } from '@substrat-run/kernel';
|
|
20
|
+
import { classify as classifyRelease } from '@substrat-run/model-view/bump';
|
|
17
21
|
import { ADMIN_LOG_INDEXES_SQL, SETTLE_INTENT_SQL, SETTLE_OUTCOME_SQL, settleOutcomeParamsOf, readAuditedOperations, unknownOutcomeOf, } from '@substrat-run/kernel';
|
|
18
22
|
import { INERT_SCOPE_REASON, isPrimaryScopeRow, normalizeUploadMediaType } from '@substrat-run/kernel';
|
|
19
23
|
import { opsFailureReferenceWhere } from '@substrat-run/kernel';
|
|
@@ -26,6 +30,7 @@ import { decidedByOf, entityString, forgetInvocationTrace, invocationTrace, trac
|
|
|
26
30
|
export { scopeStoreRunnersFor } from './scope-store-runners.js';
|
|
27
31
|
export { InProcessDeliveryBroker } from './delivery-broker.js';
|
|
28
32
|
export { devMailOutbox, MAIL_OUTBOX_ENV } from './dev-mail-outbox.js';
|
|
33
|
+
export { devConnectorNetwork, DEV_RECORDING_FILE } from './dev-connector-network.js';
|
|
29
34
|
/**
|
|
30
35
|
* A fault in the database itself (full, corrupt, I/O), as opposed to one statement failing.
|
|
31
36
|
* The #1764 backfill logs and opens past a failed batch, but never past one of these.
|
|
@@ -40,6 +45,10 @@ export function isStorageFault(err) {
|
|
|
40
45
|
* by the context object and never exported, so module code — which can reach `ctx` but not
|
|
41
46
|
* this map — cannot write one. Registered as each context is built.
|
|
42
47
|
*/
|
|
48
|
+
/** #3540: what `purgeDueAt` needs of a purge schedule. Called only on a schedule that has `purge`. */
|
|
49
|
+
function purgeDueScheduleOf(schedule) {
|
|
50
|
+
return { operation: schedule.operation, entityType: schedule.purge.entityType, everyMinutes: schedule.cadence.everyMinutes };
|
|
51
|
+
}
|
|
43
52
|
const kernelEmitters = new WeakMap();
|
|
44
53
|
/**
|
|
45
54
|
* Node's running SHA-256 (#2498), for a streamed upload — the kernel's `putAttachmentBytes` takes
|
|
@@ -889,6 +898,10 @@ export class SqliteScopeHost {
|
|
|
889
898
|
declaredKeys = new Set();
|
|
890
899
|
/** #2430: the declared permission surface `registerModule` holds each module to, when given. */
|
|
891
900
|
permissions;
|
|
901
|
+
/** #2993: which modules a scope of each declared type runs; `declared: false` runs every module. */
|
|
902
|
+
scopeTypePlan;
|
|
903
|
+
/** #2993: a provisioned scope's type, read once from its directory row. A type never changes. */
|
|
904
|
+
scopeTypeCache = new Map();
|
|
892
905
|
/** #1705: what this deployment exports to other verticals and imports from them. */
|
|
893
906
|
crossVertical = new CrossVerticalRegistry();
|
|
894
907
|
/** operation name → guards declared before it, in registration order (K-17). */
|
|
@@ -985,6 +998,8 @@ export class SqliteScopeHost {
|
|
|
985
998
|
streamIdleMs;
|
|
986
999
|
connectorCalls;
|
|
987
1000
|
clock;
|
|
1001
|
+
/** #3540: whether purge schedules are due by their rows (`SqliteScopeHostOptions.purgeDue`). */
|
|
1002
|
+
purgeDueByEvent;
|
|
988
1003
|
versionId;
|
|
989
1004
|
/** K-74: the broker each scope hands off to, or null (off). */
|
|
990
1005
|
deliveryBroker;
|
|
@@ -1015,12 +1030,14 @@ export class SqliteScopeHost {
|
|
|
1015
1030
|
this.streamIdleMs = options.streamIdleTimeoutMs;
|
|
1016
1031
|
this.connectorCalls = options.connectorCalls ?? noopConnectorCallRecorder;
|
|
1017
1032
|
this.clock = options.clock ?? (() => instant.parse(new Date().toISOString()));
|
|
1033
|
+
this.purgeDueByEvent = options.purgeDue === 'event';
|
|
1018
1034
|
this.versionId = options.versionId ?? null;
|
|
1019
1035
|
this.deliveryBroker = options.deliveryBroker ?? null;
|
|
1020
1036
|
this.deliveryHandoff = options.deliveryHandoff ?? 'always';
|
|
1021
1037
|
this.brokerTelemetry = options.brokerTelemetry ?? null;
|
|
1022
1038
|
this.migrationsDigest = options.migrationsDigest;
|
|
1023
1039
|
this.permissions = options.permissions;
|
|
1040
|
+
this.scopeTypePlan = scopeTypePlanOf(options.permissions);
|
|
1024
1041
|
// #2430: what the declared surface reserves holds here too, whatever is registered under its ids.
|
|
1025
1042
|
for (const m of options.permissions?.modules ?? []) {
|
|
1026
1043
|
noteReservedKeys(this.reservedKeys, m.manifest);
|
|
@@ -1122,6 +1139,9 @@ export class SqliteScopeHost {
|
|
|
1122
1139
|
scope_id TEXT PRIMARY KEY,
|
|
1123
1140
|
tenant_id TEXT NOT NULL,
|
|
1124
1141
|
parent_scope_id TEXT,
|
|
1142
|
+
-- #2993: the declared type this scope was provisioned as, fixed for its life. NULL is
|
|
1143
|
+
-- 'home', which every row from before scope types is.
|
|
1144
|
+
scope_type TEXT,
|
|
1125
1145
|
slug TEXT,
|
|
1126
1146
|
kind TEXT,
|
|
1127
1147
|
name TEXT,
|
|
@@ -1198,6 +1218,8 @@ export class SqliteScopeHost {
|
|
|
1198
1218
|
CREATE INDEX IF NOT EXISTS private_continuation_positions_expiry
|
|
1199
1219
|
ON private_continuation_positions (expires_at);
|
|
1200
1220
|
${PEER_BINDINGS_DDL}
|
|
1221
|
+
-- D-83 (#3530 step 3): an app's named environments, each over its tagged, pinned preview.
|
|
1222
|
+
${APP_ENVIRONMENTS_DDL}
|
|
1201
1223
|
-- The hostname map (K-26). A single environment-wide router resolves against
|
|
1202
1224
|
-- this before dispatching to the vertical's worker.
|
|
1203
1225
|
--
|
|
@@ -1299,6 +1321,9 @@ export class SqliteScopeHost {
|
|
|
1299
1321
|
serving_version_id TEXT,
|
|
1300
1322
|
serving_do_classes TEXT,
|
|
1301
1323
|
serving_migration_tag TEXT,
|
|
1324
|
+
-- K-65 (#3539 part 2): each earlier major still served beside the current one, on a
|
|
1325
|
+
-- script of its own (JSON, oldest first: earlierMajor). NULL: one major, one script.
|
|
1326
|
+
earlier_majors TEXT,
|
|
1302
1327
|
created_at TEXT NOT NULL
|
|
1303
1328
|
);
|
|
1304
1329
|
-- admission: 'pending' until the gates pass. A push is not a deploy, and
|
|
@@ -2023,6 +2048,8 @@ export class SqliteScopeHost {
|
|
|
2023
2048
|
throw new Error(`module already registered: ${manifest.id}`);
|
|
2024
2049
|
}
|
|
2025
2050
|
assertModuleDeclared(this.permissions, manifest.id); // #2430
|
|
2051
|
+
// #3488: the sender's delivery declarations, refused before anything is kept when two disagree.
|
|
2052
|
+
const senders = senderDeliveryOf([...this.senderManifests, manifest]);
|
|
2026
2053
|
// #1835: the operations are the binder's own value, or the maps beside the handlers are a
|
|
2027
2054
|
// copy nothing bound to them.
|
|
2028
2055
|
assertBoundOperations(manifest.id, registration.operations);
|
|
@@ -2118,6 +2145,8 @@ export class SqliteScopeHost {
|
|
|
2118
2145
|
// #1705: validated whole and kept only if it passes, so a refused module leaves nothing.
|
|
2119
2146
|
this.crossVertical.register(manifest, registration.imports);
|
|
2120
2147
|
this.peerUnion = undefined; // #2263: the next check reads the new module set's declarations
|
|
2148
|
+
this.senderManifests.push(manifest);
|
|
2149
|
+
this.senders = senders;
|
|
2121
2150
|
this.modules.set(manifest.id, {
|
|
2122
2151
|
id: manifest.id,
|
|
2123
2152
|
// The order the kernel writes once (#1677): authored, then search, then list indexes.
|
|
@@ -2256,8 +2285,10 @@ export class SqliteScopeHost {
|
|
|
2256
2285
|
// Idempotency is on the scope_id (§3.3: provisioning is idempotent and
|
|
2257
2286
|
// journaled — safe to re-run), so an existing scope short-circuits before the
|
|
2258
2287
|
// slug check: re-provisioning does not collide with itself.
|
|
2259
|
-
const
|
|
2260
|
-
|
|
2288
|
+
const existingRow = this.directory.prepare('SELECT scope_type FROM scopes WHERE scope_id = ?').get(input.scopeId);
|
|
2289
|
+
const existing = existingRow !== undefined;
|
|
2290
|
+
// #2993: a declared type, and the one recorded if the scope exists. Refused before anything is written.
|
|
2291
|
+
const scopeType = provisionedScopeType(this.scopeTypePlan, input.scopeType, existingRow?.scope_type, input.scopeId);
|
|
2261
2292
|
if (!existing) {
|
|
2262
2293
|
// The `scopes_tenant_slug` UNIQUE index makes this fail closed either way;
|
|
2263
2294
|
// checking first is what turns a SQLITE_CONSTRAINT into a sentence naming
|
|
@@ -2274,7 +2305,7 @@ export class SqliteScopeHost {
|
|
|
2274
2305
|
}
|
|
2275
2306
|
this.directory
|
|
2276
2307
|
.prepare(`INSERT INTO scopes
|
|
2277
|
-
(scope_id, tenant_id, parent_scope_id, slug, kind, name, vertical,
|
|
2308
|
+
(scope_id, tenant_id, parent_scope_id, scope_type, slug, kind, name, vertical,
|
|
2278
2309
|
storage_shape, jurisdiction, status, forked_from, forked_at, expires_at,
|
|
2279
2310
|
serving_ref, created_at)
|
|
2280
2311
|
-- 'provisioning', not 'active' (K-31): the directory row exists before the
|
|
@@ -2286,9 +2317,12 @@ export class SqliteScopeHost {
|
|
|
2286
2317
|
-- inheriting serving_ref would route it to the prod serving script instead
|
|
2287
2318
|
-- (COALESCE(s.serving_ref, vv.deployment_ref)). A null slug matches no row,
|
|
2288
2319
|
-- so the sub-select is NULL and routing falls through to the bound version.
|
|
2289
|
-
VALUES (?, ?, NULL, ?, ?, ?, ?, ?, ?, 'provisioning', ?, ?, ?,
|
|
2320
|
+
VALUES (?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, 'provisioning', ?, ?, ?,
|
|
2290
2321
|
(SELECT serving_ref FROM verticals WHERE slug = ?), ?)`)
|
|
2291
|
-
.run(input.scopeId, input.tenantId,
|
|
2322
|
+
.run(input.scopeId, input.tenantId,
|
|
2323
|
+
// NULL for 'home', the reading every row from before scope types has, so a host that
|
|
2324
|
+
// declares no types writes exactly the row it always did.
|
|
2325
|
+
scopeType === HOME_SCOPE_TYPE ? null : scopeType, record.slug, record.kind, record.name, record.vertical, record.storageShape, record.jurisdiction, record.forkedFrom, record.forkedAt, record.expiresAt, record.kind === 'preview' ? null : record.vertical, new Date().toISOString());
|
|
2292
2326
|
}
|
|
2293
2327
|
const rt = this.runtime(input.tenantId, input.scopeId);
|
|
2294
2328
|
await this.applyPendingMigrations(rt);
|
|
@@ -2305,7 +2339,8 @@ export class SqliteScopeHost {
|
|
|
2305
2339
|
// invoke held its transaction open joined it, and a rollback un-seated the grant
|
|
2306
2340
|
// after provisioning had returned. The switch check lives inside the seat statement.
|
|
2307
2341
|
await rt.actor.turn(() => {
|
|
2308
|
-
|
|
2342
|
+
// #2993: only the modules this scope's type runs seat their schedules' grants here.
|
|
2343
|
+
for (const mod of this.modulesOf(input.scopeId)) {
|
|
2309
2344
|
const perms = new Set();
|
|
2310
2345
|
for (const s of mod.schedules)
|
|
2311
2346
|
for (const p of s.permissions)
|
|
@@ -2320,7 +2355,7 @@ export class SqliteScopeHost {
|
|
|
2320
2355
|
// call that makes "declared and installed" mean "live" (`peerSeats`). Same seat, same
|
|
2321
2356
|
// rules: a grant a switch tombstoned stays tombstoned, and a switched-off peer gets
|
|
2322
2357
|
// nothing seated.
|
|
2323
|
-
for (const peer of peerSeats(this.peerDeclarations(), input.scopeId)) {
|
|
2358
|
+
for (const peer of peerSeats(this.scopeTypePlan.declared ? collectPeers(this.modulesOf(input.scopeId)) : this.peerDeclarations(), input.scopeId)) {
|
|
2324
2359
|
const seat = seatScopeTuple(peer.subject, peer.relation, peer.object, null);
|
|
2325
2360
|
rt.db.prepare(seat.sql).run(...seat.params);
|
|
2326
2361
|
}
|
|
@@ -2330,7 +2365,9 @@ export class SqliteScopeHost {
|
|
|
2330
2365
|
});
|
|
2331
2366
|
// Audit a real provision only; an idempotent re-provision changed nothing.
|
|
2332
2367
|
if (!existing) {
|
|
2333
|
-
this.recordAdmin(actor, 'provisionScope', { tenantId: input.tenantId, scopeId: input.scopeId, vertical: record.vertical }, null,
|
|
2368
|
+
this.recordAdmin(actor, 'provisionScope', { tenantId: input.tenantId, scopeId: input.scopeId, vertical: record.vertical }, null,
|
|
2369
|
+
// #2993: a typed scope's audit row names its type; a home scope's reads as it always did.
|
|
2370
|
+
scopeType === HOME_SCOPE_TYPE ? record : { ...record, scopeType });
|
|
2334
2371
|
}
|
|
2335
2372
|
}
|
|
2336
2373
|
/**
|
|
@@ -3763,10 +3800,41 @@ export class SqliteScopeHost {
|
|
|
3763
3800
|
// Parsed at the door, like an operation's input: HostAdmin callers are trusted to be the
|
|
3764
3801
|
// platform, not to have built a well-formed batch.
|
|
3765
3802
|
const batch = importBatch.parse(raw);
|
|
3803
|
+
return this.applyImport(tenantId, scopeId, batch, { after: batch.after, next: batch.next });
|
|
3804
|
+
}
|
|
3805
|
+
/**
|
|
3806
|
+
* K-74 (#3492): an event another app's broker PUSHED here, as the receiving broker hands it
|
|
3807
|
+
* on. `deliverToPeer`'s door, row for row (the inert-copy pause, the peer admission, a journal
|
|
3808
|
+
* row per (event, module), a dead letter per withheld row, the tail), with no compare-and-set
|
|
3809
|
+
* and no watermark move: pushed ahead of an earlier event, a moved watermark would make the
|
|
3810
|
+
* pull path skip that one. The pull path finds what this journaled and counts it a duplicate.
|
|
3811
|
+
* `source` is the caller the router verified, as the receiving broker read it from the envelope.
|
|
3812
|
+
*/
|
|
3813
|
+
async deliverPushedToPeer(tenantId, scopeId, raw) {
|
|
3814
|
+
return this.applyImport(tenantId, scopeId, pushedImport.parse(raw), null);
|
|
3815
|
+
}
|
|
3816
|
+
/**
|
|
3817
|
+
* The relay's doors over this host (#3492), for `relayScopeEnds`: the export read as the pull
|
|
3818
|
+
* path reads it (audited under `actor`), the pushed import, and the system door a resume target
|
|
3819
|
+
* is invoked through. `requests` is what the app's host code does with a request it is sent.
|
|
3820
|
+
*/
|
|
3821
|
+
relayScopeDoors(actor, requests) {
|
|
3822
|
+
return {
|
|
3823
|
+
readExports: (t, s, input) => this.admin.readExportedEvents(actor, t, s, input),
|
|
3824
|
+
importPushed: (t, s, pushed) => this.deliverPushedToPeer(t, s, pushed),
|
|
3825
|
+
invokeAsSystem: async ({ module, tenantId: t, scopeId: s, operation, input, idempotencyKey }) => (await this.getSystemScope(moduleId.parse(module), t, s)).invoke(operation, input, { idempotencyKey }),
|
|
3826
|
+
...(requests ? { requests } : {}),
|
|
3827
|
+
};
|
|
3828
|
+
}
|
|
3829
|
+
/**
|
|
3830
|
+
* One import, pulled (`edge`: the compare-and-set and the advance) or pushed (`edge` null:
|
|
3831
|
+
* neither). Everything else is the same door.
|
|
3832
|
+
*/
|
|
3833
|
+
async applyImport(tenantId, scopeId, batch, edge) {
|
|
3766
3834
|
const source = batch.source;
|
|
3767
3835
|
const rt = await this.openActiveScope(tenantId, scopeId);
|
|
3768
3836
|
return rt.actor.enqueue(async () => {
|
|
3769
|
-
const result = emptyImportResult(
|
|
3837
|
+
const result = emptyImportResult({ after: edge?.after ?? null });
|
|
3770
3838
|
// #2004: a copy consumes no other vertical's events, at the door as in the sweep
|
|
3771
3839
|
// (`scope-copy.ts`). A pause: nothing runs and the watermark stays.
|
|
3772
3840
|
if (!this.isPrimaryInDirectory(scopeId))
|
|
@@ -3785,7 +3853,9 @@ export class SqliteScopeHost {
|
|
|
3785
3853
|
// The compare-and-set. Inside the actor, so nothing moves the watermark between this
|
|
3786
3854
|
// read and the advance at the end.
|
|
3787
3855
|
const current = rt.db.prepare(IMPORT_CURSOR_OF_SQL).get(source.scopeId)?.cursor ?? null;
|
|
3788
|
-
if (
|
|
3856
|
+
if (edge === null)
|
|
3857
|
+
result.cursor = current;
|
|
3858
|
+
else if (current !== edge.after)
|
|
3789
3859
|
return { ...result, cursor: current, stale: true };
|
|
3790
3860
|
const at = new Date().toISOString();
|
|
3791
3861
|
const record = rt.db.prepare(IMPORT_RECORD_SQL);
|
|
@@ -3870,14 +3940,19 @@ export class SqliteScopeHost {
|
|
|
3870
3940
|
result.duplicates += 1;
|
|
3871
3941
|
}
|
|
3872
3942
|
// LAST, in this scope's store: a crash before here redelivers the batch, and the journal
|
|
3873
|
-
// rows above absorb it.
|
|
3874
|
-
|
|
3875
|
-
|
|
3943
|
+
// rows above absorb it. A pushed event moves nothing (#3492).
|
|
3944
|
+
if (edge !== null) {
|
|
3945
|
+
rt.db.prepare(IMPORT_CURSOR_ADVANCE_SQL).run(source.scopeId, source.vertical, edge.next, at);
|
|
3946
|
+
result.cursor = edge.next;
|
|
3947
|
+
}
|
|
3876
3948
|
lines.end();
|
|
3877
3949
|
// What the handlers emitted reaches this scope's own consumers and executors in the same
|
|
3878
3950
|
// tail, under the ordinary cascade cap.
|
|
3879
3951
|
await this.dispatch(rt, null);
|
|
3880
3952
|
await this.dispatchExecutors(rt, null);
|
|
3953
|
+
// K-74: what the import's commits and their consumers emitted (never throws), as the
|
|
3954
|
+
// Durable Object's `settleCommitted` hands it off.
|
|
3955
|
+
await this.handOffCommitted(rt);
|
|
3881
3956
|
return result;
|
|
3882
3957
|
});
|
|
3883
3958
|
}
|
|
@@ -3920,9 +3995,31 @@ export class SqliteScopeHost {
|
|
|
3920
3995
|
/** What `slug` serves in place, or null when nothing is. */
|
|
3921
3996
|
servingPointerOfVertical(slug) {
|
|
3922
3997
|
const v = this.directory
|
|
3923
|
-
.prepare('SELECT serving_ref, serving_version_id FROM verticals WHERE slug = ?')
|
|
3998
|
+
.prepare('SELECT serving_ref, serving_version_id, earlier_majors FROM verticals WHERE slug = ?')
|
|
3924
3999
|
.get(slug);
|
|
3925
|
-
|
|
4000
|
+
if (!v?.serving_ref || !v.serving_version_id)
|
|
4001
|
+
return null;
|
|
4002
|
+
// K-65 (#3539 part 2): an install on an earlier major runs that major's version.
|
|
4003
|
+
const earlier = earlierMajorsOf(v.earlier_majors).map((m) => ({ ref: m.ref, versionId: m.versionId }));
|
|
4004
|
+
return { ref: v.serving_ref, versionId: v.serving_version_id, ...(earlier.length ? { earlier } : {}) };
|
|
4005
|
+
}
|
|
4006
|
+
/**
|
|
4007
|
+
* #3539 (K-65): the refusal promoting `incoming` over any of `bases` earns if the vertical is
|
|
4008
|
+
* listed, each distinct version judged once, or null. The first that refuses is the one named.
|
|
4009
|
+
*/
|
|
4010
|
+
releaseWithinMajor(vertical, bases, incoming, servesMajors = false) {
|
|
4011
|
+
const side = (v) => ({ id: v.id, version: v.version, manifestJson: this.manifestJsonOf(v.id) ?? null });
|
|
4012
|
+
const seen = new Set();
|
|
4013
|
+
const distinct = bases.filter((b) => !!b && !seen.has(b.id) && !!seen.add(b.id));
|
|
4014
|
+
if (distinct.length === 0)
|
|
4015
|
+
return null;
|
|
4016
|
+
const head = side(incoming);
|
|
4017
|
+
for (const base of distinct) {
|
|
4018
|
+
const refusal = releaseWithinMajorRefusal({ vertical, base: side(base), head, classify: classifyRelease, servesMajors });
|
|
4019
|
+
if (refusal)
|
|
4020
|
+
return refusal;
|
|
4021
|
+
}
|
|
4022
|
+
return null;
|
|
3926
4023
|
}
|
|
3927
4024
|
/**
|
|
3928
4025
|
* #2178: refuse running `incomingId` where any of `froms` ran, each distinct version judged once,
|
|
@@ -4152,6 +4249,9 @@ export class SqliteScopeHost {
|
|
|
4152
4249
|
return (this.peerUnion ??= collectPeers(this.modules.values()));
|
|
4153
4250
|
}
|
|
4154
4251
|
peerUnion;
|
|
4252
|
+
/** #3488: the registered manifests' sender declarations by type, which every handoff reads. */
|
|
4253
|
+
senders = new Map();
|
|
4254
|
+
senderManifests = [];
|
|
4155
4255
|
/**
|
|
4156
4256
|
* The peer door (#1706) — mirror of the connection, system and capability doors. The caller is
|
|
4157
4257
|
* the local broker's word (the platform's, on the pure host); the pair and lifecycle gate run
|
|
@@ -4619,7 +4719,7 @@ export class SqliteScopeHost {
|
|
|
4619
4719
|
// `last_status` are the last RECORDED at and verdict — nothing ran.
|
|
4620
4720
|
// Collapse duplicate event types to the tightest window, ACROSS modules.
|
|
4621
4721
|
const windows = new Map();
|
|
4622
|
-
for (const m of this.
|
|
4722
|
+
for (const m of this.modulesOf(scopeId)) {
|
|
4623
4723
|
for (const f of m.freshness) {
|
|
4624
4724
|
const prev = windows.get(f.eventType);
|
|
4625
4725
|
if (prev === undefined || f.within.hours < prev)
|
|
@@ -4683,6 +4783,9 @@ export class SqliteScopeHost {
|
|
|
4683
4783
|
const mod = this.modules.get(moduleId);
|
|
4684
4784
|
if (!mod || mod.schedules.length === 0)
|
|
4685
4785
|
return report;
|
|
4786
|
+
// #2993: a scope whose type does not run the module has nothing of it due.
|
|
4787
|
+
if (!this.runsOn(scopeId, moduleId))
|
|
4788
|
+
return report;
|
|
4686
4789
|
// The scope must be a live scope of this host. A non-active or missing scope is
|
|
4687
4790
|
// not this driver's problem to raise — it simply has nothing due (the sweep
|
|
4688
4791
|
// already enumerated `active` scopes; this guards a race where one archived
|
|
@@ -4713,14 +4816,24 @@ export class SqliteScopeHost {
|
|
|
4713
4816
|
const switched = systemScheduleState(switchSqlOf(rt.db), moduleId, nowIso);
|
|
4714
4817
|
const lastRuns = new Map();
|
|
4715
4818
|
if (switched !== 'on')
|
|
4716
|
-
return { state: switched, lastRuns };
|
|
4819
|
+
return { state: switched, lastRuns, purgeDue: new Map() };
|
|
4717
4820
|
const read = rt.db.prepare(`SELECT last_run_at FROM _substrat_schedule_state
|
|
4718
4821
|
WHERE kind = 'schedule' AND schedule_op = ?`);
|
|
4719
4822
|
for (const schedule of mod.schedules) {
|
|
4720
4823
|
const row = read.get(schedule.operation);
|
|
4721
4824
|
lastRuns.set(schedule.operation, row?.last_run_at ?? null);
|
|
4722
4825
|
}
|
|
4723
|
-
|
|
4826
|
+
// #3540: under `purgeDue: 'event'`, when each purge schedule is due by its own rows — read in
|
|
4827
|
+
// the same turn as the cadence rows, for the reason that turn gives.
|
|
4828
|
+
const purgeDue = new Map();
|
|
4829
|
+
if (this.purgeDueByEvent) {
|
|
4830
|
+
for (const schedule of mod.schedules) {
|
|
4831
|
+
if (!schedule.purge)
|
|
4832
|
+
continue;
|
|
4833
|
+
purgeDue.set(schedule.operation, purgeDueAt(spineSql(rt.db), this.statePlans, [purgeDueScheduleOf(schedule)], Date.parse(nowIso)));
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
return { state: switched, lastRuns, purgeDue };
|
|
4724
4837
|
});
|
|
4725
4838
|
const state = gate.state;
|
|
4726
4839
|
if (state === 'ungranted')
|
|
@@ -4757,9 +4870,15 @@ export class SqliteScopeHost {
|
|
|
4757
4870
|
},
|
|
4758
4871
|
};
|
|
4759
4872
|
for (const schedule of mod.schedules) {
|
|
4873
|
+
// #3540: the scope's alarm asks for its purges only (the Durable Object's `purgeAlarm`).
|
|
4874
|
+
if (tick?.purgeAlarm && !schedule.purge)
|
|
4875
|
+
continue;
|
|
4760
4876
|
const lastRunAt = gate.lastRuns.get(schedule.operation) ?? null;
|
|
4761
4877
|
const lastRun = lastRunAt ? Date.parse(lastRunAt) : null;
|
|
4762
|
-
|
|
4878
|
+
// #3540: a purge due by event is due when its earliest row is (null: nothing binned is ever due),
|
|
4879
|
+
// and its lateness is measured from that row's date rather than from the cadence.
|
|
4880
|
+
const byRows = schedule.purge && this.purgeDueByEvent ? (gate.purgeDue.get(schedule.operation) ?? null) : undefined;
|
|
4881
|
+
const dueAt = byRows !== undefined ? (byRows ?? Infinity) : lastRun === null ? -Infinity : lastRun + schedule.cadence.everyMinutes * 60_000;
|
|
4763
4882
|
if (now < dueAt) {
|
|
4764
4883
|
report.skipped += 1;
|
|
4765
4884
|
report.runs.push({ operation: schedule.operation, outcome: 'skipped' });
|
|
@@ -4834,8 +4953,8 @@ export class SqliteScopeHost {
|
|
|
4834
4953
|
outcome: status,
|
|
4835
4954
|
...failure,
|
|
4836
4955
|
// Against the host's clock, which is what decided the run was due.
|
|
4837
|
-
dueAt: lastRun === null ? null : new Date(dueAt).toISOString(),
|
|
4838
|
-
latenessMs: lastRun === null ? null : now - dueAt,
|
|
4956
|
+
dueAt: byRows != null ? new Date(byRows).toISOString() : lastRun === null || byRows !== undefined ? null : new Date(dueAt).toISOString(),
|
|
4957
|
+
latenessMs: byRows != null ? now - byRows : lastRun === null || byRows !== undefined ? null : now - dueAt,
|
|
4839
4958
|
...(emitted ? { emitted } : {}),
|
|
4840
4959
|
versionId: this.versionId,
|
|
4841
4960
|
});
|
|
@@ -4859,6 +4978,25 @@ export class SqliteScopeHost {
|
|
|
4859
4978
|
report.purgeRequests = purgeRequests;
|
|
4860
4979
|
return report;
|
|
4861
4980
|
}
|
|
4981
|
+
/**
|
|
4982
|
+
* #3540: the instant this scope's purge alarm would stand at — the Durable Object arms its one
|
|
4983
|
+
* alarm for exactly this (`purgeDueAt`) — or null when nothing in its bins will ever be due, or
|
|
4984
|
+
* purges are not due by event on this host (`purgeDue`). This host has no alarm of its own: a
|
|
4985
|
+
* harness that wants the hosted shape sleeps until this instant and runs the pass.
|
|
4986
|
+
*/
|
|
4987
|
+
async purgeAlarmAt(tenantId, scopeId) {
|
|
4988
|
+
if (!this.purgeDueByEvent)
|
|
4989
|
+
return null;
|
|
4990
|
+
if (this.scopeWorkRefusal(tenantId, scopeId))
|
|
4991
|
+
return null;
|
|
4992
|
+
const schedules = [...this.modules.values()].flatMap((m) => m.schedules.filter((s) => s.purge).map(purgeDueScheduleOf));
|
|
4993
|
+
if (schedules.length === 0)
|
|
4994
|
+
return null;
|
|
4995
|
+
const rt = this.runtime(tenantId, scopeId);
|
|
4996
|
+
await this.applyPendingMigrations(rt);
|
|
4997
|
+
const at = await rt.actor.turn(() => purgeDueAt(spineSql(rt.db), this.statePlans, schedules, Date.parse(this.clock())));
|
|
4998
|
+
return at === null ? null : new Date(at).toISOString();
|
|
4999
|
+
}
|
|
4862
5000
|
/**
|
|
4863
5001
|
* One pass of a purge horizon's schedule on one scope (#119) — the Durable Object's
|
|
4864
5002
|
* `runPurgeSweep`, mirrored. The caller names only which schedule: the module and the entity come
|
|
@@ -4982,6 +5120,11 @@ export class SqliteScopeHost {
|
|
|
4982
5120
|
// gives it, so a demo and a hosted vertical answer 404 for the same reason.
|
|
4983
5121
|
if (!handler)
|
|
4984
5122
|
return Promise.reject(substratError('not_found', `unknown operation: ${operation}`));
|
|
5123
|
+
// #2993: an operation of a module this scope's type does not run is unknown here.
|
|
5124
|
+
const declaredBy = this.operationEntitlement.get(operation)?.moduleId;
|
|
5125
|
+
if (declaredBy !== undefined && !this.runsOn(scopeId, declaredBy)) {
|
|
5126
|
+
return Promise.reject(operationNotInScopeType(operation, this.scopeTypeOf(scopeId)));
|
|
5127
|
+
}
|
|
4985
5128
|
// K-42: re-read the session on EVERY invoke, not once when the stub was
|
|
4986
5129
|
// minted. A stub is a capability and nothing takes it away, so a session
|
|
4987
5130
|
// checked only at the door would be a time box the one caller holding it
|
|
@@ -5832,12 +5975,22 @@ export class SqliteScopeHost {
|
|
|
5832
5975
|
// #1575: the kernel's extraction jobs are this host's own, bound to this scope — no
|
|
5833
5976
|
// deployment registers them, and none can shadow them. The backfill starts here, on
|
|
5834
5977
|
// the drive, so a scope's first request never pays for attachments that predate it.
|
|
5835
|
-
|
|
5978
|
+
// The recheck likewise, in the same turn, once per change of extractor set: what an older
|
|
5979
|
+
// set recorded `unsupported` and this one reads is queued again (`startAttachmentTextRecheck`).
|
|
5980
|
+
const extractorSet = attachmentExtractorSetKey(this.attachmentExtractors);
|
|
5981
|
+
await rt.actor.enqueue(() => {
|
|
5982
|
+
startAttachmentTextBackfill(spineSql(rt.db), ulid(), this.clock());
|
|
5983
|
+
startAttachmentTextRecheck(spineSql(rt.db), extractorSet, ulid(), this.clock());
|
|
5984
|
+
});
|
|
5836
5985
|
const kernelJobs = {
|
|
5837
5986
|
[ATTACHMENT_TEXT_JOB]: this.attachmentTextHandler(rt),
|
|
5838
5987
|
[ATTACHMENT_TEXT_BACKFILL_JOB]: attachmentTextBackfillJob({
|
|
5839
5988
|
queueBatch: (after) => rt.actor.enqueue(() => rt.db.transaction(() => queueAttachmentTextBackfill(spineSql(rt.db), after, ulid, this.clock()))()),
|
|
5840
5989
|
}),
|
|
5990
|
+
[ATTACHMENT_TEXT_RECHECK_JOB]: attachmentTextRecheckJob({
|
|
5991
|
+
page: (after) => rt.actor.enqueue(() => readAttachmentTextRecheckPage(spineSql(rt.db), after)),
|
|
5992
|
+
requeue: (ids) => rt.actor.enqueue(() => rt.db.transaction(() => requeueUnsupportedAttachmentText(spineSql(rt.db), ids, ulid, this.clock()))()),
|
|
5993
|
+
}, this.attachmentExtractors),
|
|
5841
5994
|
};
|
|
5842
5995
|
return runDueJobRuns({
|
|
5843
5996
|
store: this.jobStore(rt),
|
|
@@ -5940,7 +6093,7 @@ export class SqliteScopeHost {
|
|
|
5940
6093
|
// host that does not run the scope's modules must never clear (or overwrite)
|
|
5941
6094
|
// a failure recorded by the deployment that does.
|
|
5942
6095
|
// A scope that applied different SQL (#2066) is not a noop: the pass below fails it.
|
|
5943
|
-
const plan = await planMigrations(this.
|
|
6096
|
+
const plan = await planMigrations(this.modulesOf(rt.scopeId), rt.appliedMigrations);
|
|
5944
6097
|
const pending = plan.pending.length > 0 || plan.diverged !== undefined;
|
|
5945
6098
|
// #2090: with nothing pending, the pass still checks and repairs what the kernel derived —
|
|
5946
6099
|
// the one way a scope stripped before that check existed is ever put right.
|
|
@@ -6054,7 +6207,7 @@ export class SqliteScopeHost {
|
|
|
6054
6207
|
let marks = this.handoffMarks.get(key) ?? (await broker.marks(rt.tenantId, rt.scopeId));
|
|
6055
6208
|
// A backlog larger than one batch follows in the next round; bounded, so a commit never spins.
|
|
6056
6209
|
for (let round = 0; round < 20; round++) {
|
|
6057
|
-
const sent = handoffQueries(marks).flatMap((q) => messagesOf(q.kind, rt.db.prepare(q.sql).all(...q.params), ids, commit));
|
|
6210
|
+
const sent = handoffQueries(marks).flatMap((q) => messagesOf(q.kind, rt.db.prepare(q.sql).all(...q.params), ids, commit, this.senders));
|
|
6058
6211
|
if (sent.length === 0) {
|
|
6059
6212
|
// A5: a window's start the broker has not acknowledged goes on its own.
|
|
6060
6213
|
if (options.start) {
|
|
@@ -6176,7 +6329,7 @@ export class SqliteScopeHost {
|
|
|
6176
6329
|
async dispatchRounds(rt, invocationId, lines) {
|
|
6177
6330
|
for (let round = 0; round < 50; round++) {
|
|
6178
6331
|
let deliveredAny = false;
|
|
6179
|
-
for (const mod of this.
|
|
6332
|
+
for (const mod of this.modulesOf(rt.scopeId)) {
|
|
6180
6333
|
for (const consumer of mod.consumers) {
|
|
6181
6334
|
const rows = rt.db
|
|
6182
6335
|
.prepare(`SELECT * FROM _substrat_outbox o
|
|
@@ -6732,6 +6885,7 @@ export class SqliteScopeHost {
|
|
|
6732
6885
|
previewTraceSampling: r.preview_trace_sampling ?? 0,
|
|
6733
6886
|
...(r.serving_ref ? { servingRef: r.serving_ref } : {}),
|
|
6734
6887
|
...(r.serving_version_id ? { servingVersionId: r.serving_version_id } : {}),
|
|
6888
|
+
...(r.earlier_majors ? { earlierMajors: earlierMajorsOf(r.earlier_majors) } : {}),
|
|
6735
6889
|
createdAt: r.created_at,
|
|
6736
6890
|
});
|
|
6737
6891
|
const readVertical = (slugValue) => {
|
|
@@ -7860,6 +8014,26 @@ export class SqliteScopeHost {
|
|
|
7860
8014
|
this.recordAccess(actor, 'peerBindings', { tenantId, scopeId: callerScopeId }, null, rows.length);
|
|
7861
8015
|
return rows.map((r) => ({ tenantId, callerScopeId, vertical: r.vertical, targetScopeId: r.target_scope_id, invalidated: r.invalidated === 1 }));
|
|
7862
8016
|
},
|
|
8017
|
+
// D-83 (#3530 step 3): an app's environments. The rule is the kernel's (`app-environments.ts`).
|
|
8018
|
+
listEnvironments: async (actor, tenantId, vertical) => {
|
|
8019
|
+
const rows = environmentsOf(switchSqlOf(this.directory), tenantId, vertical);
|
|
8020
|
+
this.recordAccess(actor, 'listEnvironments', { tenantId }, { vertical }, rows.length);
|
|
8021
|
+
return rows;
|
|
8022
|
+
},
|
|
8023
|
+
defineEnvironment: async (actor, input) => this.directory.transaction(() => {
|
|
8024
|
+
const out = defineEnvironmentIn(switchSqlOf(this.directory), input, { at: new Date().toISOString(), by: actor });
|
|
8025
|
+
if (out.created) {
|
|
8026
|
+
this.recordAdmin(actor, 'defineEnvironment', { tenantId: input.tenantId, scopeId: out.scopeId, vertical: input.vertical }, null, { vertical: input.vertical, scopeId: out.scopeId });
|
|
8027
|
+
}
|
|
8028
|
+
return { environment: out.environment, created: out.created };
|
|
8029
|
+
})(),
|
|
8030
|
+
removeEnvironment: async (actor, input) => this.directory.transaction(() => {
|
|
8031
|
+
const out = removeEnvironmentIn(switchSqlOf(this.directory), input);
|
|
8032
|
+
if (out.removed) {
|
|
8033
|
+
this.recordAdmin(actor, 'removeEnvironment', { tenantId: input.tenantId, scopeId: out.scopeId, vertical: input.vertical }, { vertical: input.vertical, scopeId: out.scopeId }, null);
|
|
8034
|
+
}
|
|
8035
|
+
return { removed: out.removed };
|
|
8036
|
+
})(),
|
|
7863
8037
|
setPeerBinding: async (_actor, tenantId, callerScopeId, vertical, targetScopeId) => this.directory.transaction(() => {
|
|
7864
8038
|
const caller = this.directory.prepare('SELECT tenant_id, status, kind, forked_from FROM scopes WHERE scope_id = ?').get(callerScopeId);
|
|
7865
8039
|
if (!caller || caller.tenant_id !== tenantId || caller.status !== 'active' || !isPrimaryScopeRow(caller)) {
|
|
@@ -7918,7 +8092,8 @@ export class SqliteScopeHost {
|
|
|
7918
8092
|
JOIN tenants t ON t.tenant_id = s.tenant_id
|
|
7919
8093
|
LEFT JOIN vertical_versions vv ON vv.id = s.vertical_version_id
|
|
7920
8094
|
LEFT JOIN verticals vr ON vr.slug = s.vertical
|
|
7921
|
-
|
|
8095
|
+
-- K-65 (#3539 part 2): the version the scope's script runs, an earlier major's included.
|
|
8096
|
+
LEFT JOIN vertical_versions sv ON sv.id = ${SCRIPT_SERVING_VERSION_SQL}
|
|
7922
8097
|
WHERE h.hostname = ? AND h.status = 'active'
|
|
7923
8098
|
AND s.status = 'active' AND t.status = 'active'`)
|
|
7924
8099
|
.get(hostname);
|
|
@@ -8267,6 +8442,19 @@ export class SqliteScopeHost {
|
|
|
8267
8442
|
served?.versionId,
|
|
8268
8443
|
...owned.map((s) => runningVersionOf(mapScope(s), served)),
|
|
8269
8444
|
], versionId, served || owned.length > 0 ? this.provisionedVersionsOf(verticalSlug, served, owned.length > 0 ? owning.ownerTenant : null) : []);
|
|
8445
|
+
// #3539 (K-65): a listed app takes no breaking change within its major. Ranked against what
|
|
8446
|
+
// the channel names and what the serving script runs (a failed serve leaves it behind), by
|
|
8447
|
+
// the rules `substrat changeset` writes with. Ahead of the acknowledgements, because none of
|
|
8448
|
+
// them passes it. Refused here when the vertical is listed as read above, and judged again in
|
|
8449
|
+
// the unit that moves the channel, so a listing that lands meanwhile is seen (#2565).
|
|
8450
|
+
const breakingWithinMajor = channel === 'prod'
|
|
8451
|
+
? this.releaseWithinMajor(verticalSlug, [outgoing, served ? await readVersion(served.versionId) : undefined], incoming,
|
|
8452
|
+
// #3539 part 2: a new major is served beside the old one only by a caller that serves
|
|
8453
|
+
// in place, and only from a version with an archive script to serve from.
|
|
8454
|
+
options?.servesMajors === true && incoming.deploymentRef !== null)
|
|
8455
|
+
: null;
|
|
8456
|
+
if (breakingWithinMajor && owning?.listed)
|
|
8457
|
+
throw breakingWithinMajorRefusal(breakingWithinMajor);
|
|
8270
8458
|
// #2333: the acknowledgements answer the review they were given against, or none at all.
|
|
8271
8459
|
const reviewed = (v) => ({
|
|
8272
8460
|
...v,
|
|
@@ -8314,6 +8502,9 @@ export class SqliteScopeHost {
|
|
|
8314
8502
|
const listed = readVertical(verticalSlug)?.listed;
|
|
8315
8503
|
if (listed && options?.unlistedOnly)
|
|
8316
8504
|
throw listedPromoteRefusal();
|
|
8505
|
+
// #3539 (K-65): ranked above; whether the vertical is listed is this unit's to read.
|
|
8506
|
+
if (listed && channel === 'prod' && breakingWithinMajor)
|
|
8507
|
+
throw breakingWithinMajorRefusal(breakingWithinMajor);
|
|
8317
8508
|
// A re-promote of what prod already names, and what serves (if anything does), moves
|
|
8318
8509
|
// nothing, so it is not judged again. One whose serve would change what runs is.
|
|
8319
8510
|
const serving = this.servingPointerOfVertical(verticalSlug)?.versionId ?? versionId;
|
|
@@ -8656,10 +8847,15 @@ export class SqliteScopeHost {
|
|
|
8656
8847
|
versionId: r.serving_version_id,
|
|
8657
8848
|
doClasses: r.serving_do_classes ? JSON.parse(r.serving_do_classes) : [],
|
|
8658
8849
|
migrationTag: r.serving_migration_tag,
|
|
8850
|
+
// K-65 (#3539 part 2): what each earlier major's script runs.
|
|
8851
|
+
...(r.earlier_majors
|
|
8852
|
+
? { earlier: earlierMajorsOf(r.earlier_majors).map((m) => ({ ref: m.ref, versionId: m.versionId })) }
|
|
8853
|
+
: {}),
|
|
8659
8854
|
});
|
|
8660
8855
|
},
|
|
8661
|
-
setVerticalServing: async (actor, verticalSlug, state, expected) => {
|
|
8856
|
+
setVerticalServing: async (actor, verticalSlug, state, expected, opts) => {
|
|
8662
8857
|
const parsed = verticalServingState.parse(state);
|
|
8858
|
+
const supersede = opts?.supersede;
|
|
8663
8859
|
const r = this.directory
|
|
8664
8860
|
.prepare('SELECT * FROM verticals WHERE slug = ?')
|
|
8665
8861
|
.get(verticalSlug);
|
|
@@ -8668,8 +8864,14 @@ export class SqliteScopeHost {
|
|
|
8668
8864
|
// #2577: the caller's upload diffed its DO-class migration from `expected`'s class set and tag.
|
|
8669
8865
|
if (expected !== undefined && !migratesFrom(r, expected))
|
|
8670
8866
|
throw servingRaceRefusal(verticalSlug);
|
|
8671
|
-
// #
|
|
8672
|
-
|
|
8867
|
+
// K-65 (#3539 part 2): a new major supersedes exactly the serving state the caller read.
|
|
8868
|
+
if (supersede && (!expected || expected.ref !== r.serving_ref || expected.versionId !== r.serving_version_id)) {
|
|
8869
|
+
throw servingRaceRefusal(verticalSlug);
|
|
8870
|
+
}
|
|
8871
|
+
// #2178: every install on the serving script runs the new version from this moment. A new
|
|
8872
|
+
// major's first serve moves nobody onto its script: the installs stay on the earlier one.
|
|
8873
|
+
if (!supersede)
|
|
8874
|
+
this.assertNoStrandFrom([r.serving_version_id], parsed.versionId, r.serving_ref ? this.provisionedVersionsOf(verticalSlug, r.serving_version_id ? { ref: r.serving_ref, versionId: r.serving_version_id } : null, null) : []);
|
|
8673
8875
|
// #2528/#2577: a compare-and-set on the serving state the gate judged, its ref, version,
|
|
8674
8876
|
// class set and tag (a serve and a re-serve can bring the ref and version back over a grown
|
|
8675
8877
|
// class set), and the row's `before` read in the transaction that moves it, as the
|
|
@@ -8686,12 +8888,29 @@ export class SqliteScopeHost {
|
|
|
8686
8888
|
raced = !servesAsFrom(now, servedFromRow(r));
|
|
8687
8889
|
if (raced)
|
|
8688
8890
|
return false;
|
|
8891
|
+
const earlier = supersede
|
|
8892
|
+
? supersededMajorsJson({
|
|
8893
|
+
vertical: verticalSlug,
|
|
8894
|
+
earlierJson: now.earlier_majors,
|
|
8895
|
+
current: {
|
|
8896
|
+
ref: now.serving_ref,
|
|
8897
|
+
versionId: now.serving_version_id,
|
|
8898
|
+
doClasses: now.serving_do_classes ? JSON.parse(now.serving_do_classes) : [],
|
|
8899
|
+
migrationTag: now.serving_migration_tag,
|
|
8900
|
+
},
|
|
8901
|
+
nextRef: parsed.ref,
|
|
8902
|
+
supersede,
|
|
8903
|
+
})
|
|
8904
|
+
: (now.earlier_majors ?? null);
|
|
8689
8905
|
this.directory
|
|
8690
8906
|
.prepare(`UPDATE verticals SET serving_ref = ?, serving_version_id = ?,
|
|
8691
|
-
serving_do_classes = ?, serving_migration_tag = ? WHERE slug = ?`)
|
|
8692
|
-
.run(parsed.ref, parsed.versionId, JSON.stringify(parsed.doClasses), parsed.migrationTag, verticalSlug);
|
|
8907
|
+
serving_do_classes = ?, serving_migration_tag = ?, earlier_majors = ? WHERE slug = ?`)
|
|
8908
|
+
.run(parsed.ref, parsed.versionId, JSON.stringify(parsed.doClasses), parsed.migrationTag, earlier, verticalSlug);
|
|
8693
8909
|
return true;
|
|
8694
|
-
}, () => this.recordAdmin(actor, 'setVerticalServing', { tenantId: null }, before, {
|
|
8910
|
+
}, () => this.recordAdmin(actor, 'setVerticalServing', { tenantId: null }, before, {
|
|
8911
|
+
vertical: verticalSlug, ref: parsed.ref, versionId: parsed.versionId,
|
|
8912
|
+
...(supersede ? { supersedes: { major: supersede.major, endsAt: supersede.endsAt } } : {}),
|
|
8913
|
+
}));
|
|
8695
8914
|
if (raced)
|
|
8696
8915
|
throw servingRaceRefusal(verticalSlug);
|
|
8697
8916
|
},
|
|
@@ -8858,7 +9077,7 @@ export class SqliteScopeHost {
|
|
|
8858
9077
|
limit: input.limit,
|
|
8859
9078
|
due: input.due ?? true,
|
|
8860
9079
|
...(handedOffThrough === undefined ? {} : { handedOffThrough }),
|
|
8861
|
-
subscribers: outboxSubscribersOf(this.
|
|
9080
|
+
subscribers: outboxSubscribersOf(this.modulesOf(scopeId), this.executors),
|
|
8862
9081
|
exportTypes: this.crossVertical.exportTypes(),
|
|
8863
9082
|
}))());
|
|
8864
9083
|
// Deleting a tenant's events is a mutation, so it is audited, and only when something went.
|
|
@@ -9942,6 +10161,7 @@ export class SqliteScopeHost {
|
|
|
9942
10161
|
'_substrat_membership_fences', // #1184: the latest removal, per principal
|
|
9943
10162
|
'_substrat_peer_switches', // #2029: the peer switch's record, per scope
|
|
9944
10163
|
'peer_bindings', // #1720: a tenant's explicit caller-to-target choices
|
|
10164
|
+
'app_environments', // D-83: the names over the tenant's pinned previews
|
|
9945
10165
|
'_substrat_switch_owed', // #2045: subjects owed a re-assert, per scope
|
|
9946
10166
|
'_substrat_findings', // #1748: the tenant's findings
|
|
9947
10167
|
'_substrat_finding_rules', // #1748: the tenant's suppress rules
|
|
@@ -11516,6 +11736,8 @@ export class SqliteScopeHost {
|
|
|
11516
11736
|
this.ensureColumn(this.directory, 'scopes', 'erasure_epoch', 'erasure_epoch INTEGER');
|
|
11517
11737
|
this.ensureColumn(this.directory, 'scopes', 'reap_claimed_at', 'reap_claimed_at TEXT');
|
|
11518
11738
|
this.ensureColumn(this.directory, 'scopes', 'stores_fenced_at', 'stores_fenced_at TEXT');
|
|
11739
|
+
// #2993: null on every existing row, which reads as 'home', the one type a scope had before.
|
|
11740
|
+
this.ensureColumn(this.directory, 'scopes', 'scope_type', 'scope_type TEXT');
|
|
11519
11741
|
// §4.8's grace-window timestamp on tenants (mirrors scopes' archived_at).
|
|
11520
11742
|
this.ensureColumn(this.directory, 'tenants', 'deleting_at', 'deleting_at TEXT');
|
|
11521
11743
|
this.ensureColumn(this.directory, 'tenants', 'provisioned_by_tenant', 'provisioned_by_tenant TEXT REFERENCES tenants(tenant_id)');
|
|
@@ -11550,6 +11772,8 @@ export class SqliteScopeHost {
|
|
|
11550
11772
|
this.ensureColumn(this.directory, 'verticals', 'serving_version_id', 'serving_version_id TEXT');
|
|
11551
11773
|
this.ensureColumn(this.directory, 'verticals', 'serving_do_classes', 'serving_do_classes TEXT');
|
|
11552
11774
|
this.ensureColumn(this.directory, 'verticals', 'serving_migration_tag', 'serving_migration_tag TEXT');
|
|
11775
|
+
// K-65 (#3539 part 2): the earlier majors still served beside the current one.
|
|
11776
|
+
this.ensureColumn(this.directory, 'verticals', 'earlier_majors', 'earlier_majors TEXT');
|
|
11553
11777
|
this.ensureColumn(this.directory, 'vertical_versions', 'manifest_json', 'manifest_json TEXT');
|
|
11554
11778
|
// Push provenance (git CI vs a terminal) — null for a pre-tracking push.
|
|
11555
11779
|
this.ensureColumn(this.directory, 'vertical_versions', 'origin_json', 'origin_json TEXT');
|
|
@@ -11927,8 +12151,8 @@ export class SqliteScopeHost {
|
|
|
11927
12151
|
sql: tracedSql(guardSecrets(guardSqlLimits(scopedSql(rt.db, true, statefulTablesOf(statePlans),
|
|
11928
12152
|
// #119 / #2090: after runtime DDL, inside this operation's transaction, what the kernel
|
|
11929
12153
|
// derived onto any table is repaired — and a lost state column fails the operation.
|
|
11930
|
-
derivesAnything(this.derivedPlans())
|
|
11931
|
-
? () => afterRuntimeDdl(spineSql(rt.db), (ddl) => execSqlStatements(rt.db, ddl), this.derivedPlans())
|
|
12154
|
+
derivesAnything(this.derivedPlans(rt.scopeId))
|
|
12155
|
+
? () => afterRuntimeDdl(spineSql(rt.db), (ddl) => execSqlStatements(rt.db, ddl), this.derivedPlans(rt.scopeId))
|
|
11932
12156
|
: undefined)), minted), trace, (text) => redactSecretText(text, minted), (value) => redactSecrets(value, minted)),
|
|
11933
12157
|
now: () => at,
|
|
11934
12158
|
// #1746/#1747: the host stamps who and where; module code supplies only the template
|
|
@@ -12212,8 +12436,40 @@ export class SqliteScopeHost {
|
|
|
12212
12436
|
return ctxRef;
|
|
12213
12437
|
}
|
|
12214
12438
|
/** Every registered module's derivation plans — what `repairDerivedObjects` and its checks read. */
|
|
12215
|
-
derivedPlans() {
|
|
12216
|
-
|
|
12439
|
+
derivedPlans(scopeId) {
|
|
12440
|
+
const all = { state: this.statePlans, lists: this.listPlans, search: this.searchPlans };
|
|
12441
|
+
if (!this.scopeTypePlan.declared || scopeId === undefined)
|
|
12442
|
+
return all;
|
|
12443
|
+
// #2993: only what this scope's type runs was derived onto its tables.
|
|
12444
|
+
const own = (plans) => new Map([...plans].filter(([, plan]) => this.runsOn(scopeId, plan.moduleId)));
|
|
12445
|
+
return { state: own(all.state), lists: own(all.lists), search: own(all.search) };
|
|
12446
|
+
}
|
|
12447
|
+
/**
|
|
12448
|
+
* #2993: the declared type of a provisioned scope, from its directory row. `home` for a host that
|
|
12449
|
+
* declares no types, a row from before types, and a scope not provisioned yet (not cached, so its
|
|
12450
|
+
* provision decides). Cached once read, since a type never changes.
|
|
12451
|
+
*/
|
|
12452
|
+
scopeTypeOf(scopeId) {
|
|
12453
|
+
if (!this.scopeTypePlan.declared)
|
|
12454
|
+
return HOME_SCOPE_TYPE;
|
|
12455
|
+
const cached = this.scopeTypeCache.get(scopeId);
|
|
12456
|
+
if (cached !== undefined)
|
|
12457
|
+
return cached;
|
|
12458
|
+
const row = this.directory.prepare('SELECT scope_type FROM scopes WHERE scope_id = ?').get(scopeId);
|
|
12459
|
+
if (!row)
|
|
12460
|
+
return HOME_SCOPE_TYPE;
|
|
12461
|
+
const type = row.scope_type ?? HOME_SCOPE_TYPE;
|
|
12462
|
+
this.scopeTypeCache.set(scopeId, type);
|
|
12463
|
+
return type;
|
|
12464
|
+
}
|
|
12465
|
+
/** #2993: whether this scope's type runs the module. Every module runs on a host with no declared types. */
|
|
12466
|
+
runsOn(scopeId, moduleId) {
|
|
12467
|
+
return !this.scopeTypePlan.declared || scopeTypeRuns(this.scopeTypePlan, this.scopeTypeOf(scopeId), moduleId);
|
|
12468
|
+
}
|
|
12469
|
+
/** #2993: the registered modules this scope's type runs, in registration order. */
|
|
12470
|
+
modulesOf(scopeId) {
|
|
12471
|
+
const all = [...this.modules.values()];
|
|
12472
|
+
return this.scopeTypePlan.declared ? all.filter((m) => this.runsOn(scopeId, m.id)) : all;
|
|
12217
12473
|
}
|
|
12218
12474
|
/**
|
|
12219
12475
|
* #2090: a pass with nothing pending, once per runtime — check and repair what the kernel
|
|
@@ -12227,7 +12483,7 @@ export class SqliteScopeHost {
|
|
|
12227
12483
|
await rt.actor.enqueue(() => {
|
|
12228
12484
|
rt.db.exec('BEGIN IMMEDIATE');
|
|
12229
12485
|
try {
|
|
12230
|
-
repairDerivedObjects(spineSql(rt.db), (ddl) => execSqlStatements(rt.db, ddl), this.derivedPlans(), {
|
|
12486
|
+
repairDerivedObjects(spineSql(rt.db), (ddl) => execSqlStatements(rt.db, ddl), this.derivedPlans(rt.scopeId), {
|
|
12231
12487
|
after: 'an applied migration',
|
|
12232
12488
|
});
|
|
12233
12489
|
rt.db.exec('COMMIT');
|
|
@@ -12244,7 +12500,8 @@ export class SqliteScopeHost {
|
|
|
12244
12500
|
rt.derivedRepaired = true;
|
|
12245
12501
|
}
|
|
12246
12502
|
async applyPendingMigrations(rt, plan) {
|
|
12247
|
-
|
|
12503
|
+
// #2993: a scope applies only its type's modules' migrations, so it carries no other type's tables.
|
|
12504
|
+
const { pending, diverged } = plan ?? (await planMigrations(this.modulesOf(rt.scopeId), rt.appliedMigrations));
|
|
12248
12505
|
if (diverged) {
|
|
12249
12506
|
this.recordMigrationState(rt, diverged);
|
|
12250
12507
|
throw migrationFailedError(diverged.version, diverged.error);
|
|
@@ -12304,7 +12561,7 @@ export class SqliteScopeHost {
|
|
|
12304
12561
|
// #2090: the state columns this migration must have left, and after the last of the
|
|
12305
12562
|
// pass, the triggers and indexes a create-copy-rename rebuild dropped.
|
|
12306
12563
|
const last = i === pending.length - 1;
|
|
12307
|
-
afterMigration(spineSql(rt.db), (ddl) => execSqlStatements(rt.db, ddl), this.derivedPlans(), key, last);
|
|
12564
|
+
afterMigration(spineSql(rt.db), (ddl) => execSqlStatements(rt.db, ddl), this.derivedPlans(rt.scopeId), key, last);
|
|
12308
12565
|
const after = rt.db.prepare('SELECT total_changes() AS n').get().n;
|
|
12309
12566
|
// After the count: `rows_changed` is the migration's own, never the kernel's bookkeeping.
|
|
12310
12567
|
recordOwnershipSteps(spineSql(rt.db), moduleId, steps, this.clock());
|