@substrat-run/adapter-sqlite 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/delivery-broker.d.ts +8 -0
- package/dist/delivery-broker.d.ts.map +1 -1
- package/dist/delivery-broker.js +7 -1
- package/dist/delivery-broker.js.map +1 -1
- package/dist/index.d.ts +24 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +178 -29
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ 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 { PRODUCTION_ENVIRONMENT, 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, assertScopeTypesKept, 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, environmentServeAcknowledgement, bindAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding,
|
|
6
|
-
import { actorOf, asPrincipal, assertAllowed, assertNoSecret, assertPermissionKey, CAPABILITY_DDL, UPLOAD_LINK_DDL, DOWNLOAD_LINK_DDL, STORE_PROOF_DDL, mintStoreProof, redeemStoreProof, 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, consumeScheduleDue, dueByEventSchedulesOf, noteScheduleDue, readScheduleDue, scheduleDueAt, 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, claimEnvironmentServeIn, defineEnvironmentIn, ENVIRONMENT_SCRIPT_JOIN_SQL, environmentsOf, homeParentOf, homeScopeIn, secondHomeRefusal, releaseEnvironmentServeIn, removeEnvironmentIn, setEnvironmentServingIn, setEnvironmentEffectsIn, connectionReachIn, sealingKeysForReach, deliveryEnvironmentIn, environmentOfScopeIn, SWITCH_OWED_DDL, DEPENDENT_ERASURES_DDL, DEPENDENT_ERASURE_DUE_SQL, DEPENDENT_ERASURE_HOLD_SQL, DEPENDENT_ERASURE_OWE_SQL, DEPENDENT_ERASURE_SETTLE_SQL, nextDependentErasureAt, 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, proofCheckedStoreInvoke, replayStoreErasures, scopeStoreLifecycleOf, scopeStoreRunnersOf, } from '@substrat-run/kernel';
|
|
5
|
+
import { PRODUCTION_ENVIRONMENT, 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, assertScopeTypesKept, 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, environmentServeAcknowledgement, bindAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding, storedVersionInput, AUTO_ADMISSION_NOTE, admittedBundleAudit, 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, storeOperationKeyOf, } from '@substrat-run/contracts';
|
|
6
|
+
import { actorOf, asPrincipal, assertAllowed, assertNoSecret, assertPermissionKey, CAPABILITY_DDL, UPLOAD_LINK_DDL, DOWNLOAD_LINK_DDL, STORE_PROOF_DDL, mintStoreProof, redeemStoreProof, 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, consumeScheduleDue, dueByEventSchedulesOf, noteScheduleDue, readScheduleDue, scheduleDueAt, 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, claimEnvironmentServeIn, defineEnvironmentIn, ENVIRONMENT_SCRIPT_JOIN_SQL, environmentPeerResolutionIn, environmentsOf, homeParentOf, homeScopeIn, secondHomeRefusal, releaseEnvironmentServeIn, removeEnvironmentIn, setEnvironmentServingIn, environmentBindRefusalIn, setEnvironmentEffectsIn, connectionReachIn, sealingKeysForReach, deliveryEnvironmentIn, environmentOfScopeIn, SWITCH_OWED_DDL, DEPENDENT_ERASURES_DDL, DEPENDENT_ERASURE_DUE_SQL, DEPENDENT_ERASURE_HOLD_SQL, DEPENDENT_ERASURE_OWE_SQL, DEPENDENT_ERASURE_SETTLE_SQL, nextDependentErasureAt, 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, createJobVerbs, declaredJobsOf, jobRunEndedOutbox, 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, proofCheckedStoreInvoke, replayStoreErasures, scopeStoreLifecycleOf, scopeStoreRunnersOf, } from '@substrat-run/kernel';
|
|
7
7
|
import { handoffOutcome, reportHandoff, traceIdOf } from '@substrat-run/kernel';
|
|
8
8
|
// #2993: the modules a scope of each declared type runs, and the type a provision fixes.
|
|
9
9
|
import { childDoorRefusal, childScopeRefusal, directAccessRefusal, HOME_SCOPE_TYPE, operationNotInScopeType, parentlessScopeRefusal, provisionedParent, provisionedScopeType, scopeTypePlanOf, scopeTypePlanOfManifest, scopeTypeRoleRefusal, scopeTypeRuns, } from '@substrat-run/kernel';
|
|
@@ -13,9 +13,9 @@ import { assertSameAttachmentGate, attachmentGateOf, decideAttachmentRemove, } f
|
|
|
13
13
|
import { DIRECTORY_CLAIMS_DDL, DIRECTORY_CROSSINGS_DDL, oneDatabaseDirectoryObjects, } from '@substrat-run/kernel';
|
|
14
14
|
import { canonicalInstant } from '@substrat-run/kernel';
|
|
15
15
|
import { advanceMarks, handoffQueries, messagesOf, senderDeliveryOf, } from '@substrat-run/kernel';
|
|
16
|
-
import { intentStateOf, intentStateQuery, witnessesOf, witnessQueries, } from '@substrat-run/kernel';
|
|
16
|
+
import { intentStateOf, intentStateQuery, eventLakeStateOf, eventLakeStateQuery, witnessesOf, witnessQueries, } from '@substrat-run/kernel';
|
|
17
17
|
import { MARKUP_INSERT_SQL, MARKUP_SELECT_FOR_TENANT_SQL, MARKUP_SELECT_SQL, markupRecordValues, markupScheduleOf, newMarkupRow, } from '@substrat-run/kernel';
|
|
18
|
-
import { prePromoteSnapshotExpiresAt } from '@substrat-run/kernel';
|
|
18
|
+
import { prePromoteSnapshotExpiresAt, jobSystemKeysOf, containerPassRegistration } from '@substrat-run/kernel';
|
|
19
19
|
import { breakingWithinMajorRefusal, earlierMajorReleaseTarget, earlierMajorsOf, releasedEarlierMajorJson, releaseWithinMajorRefusal, SCRIPT_SERVING_VERSION_SQL, supersededMajorsJson } from '@substrat-run/kernel';
|
|
20
20
|
import { classify as classifyRelease } from '@substrat-run/model-view/bump';
|
|
21
21
|
import { ADMIN_LOG_INDEXES_SQL, SETTLE_INTENT_SQL, SETTLE_OUTCOME_SQL, settleOutcomeParamsOf, readAuditedOperations, unknownOutcomeOf, } from '@substrat-run/kernel';
|
|
@@ -995,6 +995,8 @@ export class SqliteScopeHost {
|
|
|
995
995
|
secretBox;
|
|
996
996
|
/** The parsers attachment text is extracted with (K-43); the host's own, never imported here. */
|
|
997
997
|
attachmentExtractors;
|
|
998
|
+
/** D-85 (#3752): `SqliteScopeHostOptions.containerPasses`. */
|
|
999
|
+
containerPasses;
|
|
998
1000
|
wrapBlobStore;
|
|
999
1001
|
attachmentTextBounds;
|
|
1000
1002
|
fetchImpl;
|
|
@@ -1008,6 +1010,9 @@ export class SqliteScopeHost {
|
|
|
1008
1010
|
* may name, and the operations whose every run clears their date in its own transaction.
|
|
1009
1011
|
*/
|
|
1010
1012
|
dueSchedules = new Map();
|
|
1013
|
+
/** D-85: the modules that declare jobs, and every declared job by name (`declaredJobsOf`). */
|
|
1014
|
+
jobDeclarers = [];
|
|
1015
|
+
declaredJobs = new Map();
|
|
1011
1016
|
versionId;
|
|
1012
1017
|
/** K-74: the broker each scope hands off to, or null (off). */
|
|
1013
1018
|
deliveryBroker;
|
|
@@ -1018,6 +1023,7 @@ export class SqliteScopeHost {
|
|
|
1018
1023
|
handoffEnvironments = new Map();
|
|
1019
1024
|
/** A5: `deliveryHandoff`, and each scope's mode with its window start (in memory, as the marks are). */
|
|
1020
1025
|
deliveryHandoff;
|
|
1026
|
+
/** A5: each scope's delivery mode; `lake` (A6, #3472) when the lake is its broker's, only beside live. */
|
|
1021
1027
|
deliveryModes = new Map();
|
|
1022
1028
|
migrationsDigest;
|
|
1023
1029
|
/** #1746: where `ctx.log` lines go — the console unless a caller (a test) says otherwise. */
|
|
@@ -1033,6 +1039,7 @@ export class SqliteScopeHost {
|
|
|
1033
1039
|
this.secretBox = options.secretBox ?? unconfiguredSecretBox;
|
|
1034
1040
|
assertAttachmentExtractors(options.attachmentExtractors ?? []);
|
|
1035
1041
|
this.attachmentExtractors = options.attachmentExtractors ?? [];
|
|
1042
|
+
this.containerPasses = options.containerPasses;
|
|
1036
1043
|
this.wrapBlobStore = options.wrapBlobStore ?? ((store) => store);
|
|
1037
1044
|
this.attachmentTextBounds = resolveAttachmentTextBounds(options.attachmentTextBounds);
|
|
1038
1045
|
// #2498: whatever fetch is injected, a sized stream body reaches it converted (`fetchLikeOf`).
|
|
@@ -1362,6 +1369,8 @@ export class SqliteScopeHost {
|
|
|
1362
1369
|
migration_digest_derived INTEGER,
|
|
1363
1370
|
-- #2351: the digest of the migrations read from the version's bundle. NULL = never read.
|
|
1364
1371
|
migrations_extracted TEXT,
|
|
1372
|
+
-- #3612: the sha256 the control plane took of the module bytes it stored. NULL = pushed before.
|
|
1373
|
+
bundle_digest TEXT,
|
|
1365
1374
|
created_at TEXT NOT NULL,
|
|
1366
1375
|
UNIQUE (vertical_slug, version)
|
|
1367
1376
|
);
|
|
@@ -1890,6 +1899,7 @@ export class SqliteScopeHost {
|
|
|
1890
1899
|
this.ensureColumn(this.directory, 'vertical_versions', 'migrations_split', 'migrations_split INTEGER');
|
|
1891
1900
|
this.ensureColumn(this.directory, 'vertical_versions', 'migration_digest_derived', 'migration_digest_derived INTEGER');
|
|
1892
1901
|
this.ensureColumn(this.directory, 'vertical_versions', 'migrations_extracted', 'migrations_extracted TEXT');
|
|
1902
|
+
this.ensureColumn(this.directory, 'vertical_versions', 'bundle_digest', 'bundle_digest TEXT');
|
|
1893
1903
|
}
|
|
1894
1904
|
this.applyDirectorySchema();
|
|
1895
1905
|
// #2322: a migration's declared moves and discards, on a table created before they were carried.
|
|
@@ -2075,6 +2085,8 @@ export class SqliteScopeHost {
|
|
|
2075
2085
|
// #2068: refused here, before anything is recorded, when the module claims an erasure it
|
|
2076
2086
|
// cannot deliver (a hook with no reach declared, a `custom` entity with no hook).
|
|
2077
2087
|
const erasure = moduleErasurePlan(registration);
|
|
2088
|
+
// D-85: the module's jobs, refused before anything is recorded (a name taken, an undeclared key).
|
|
2089
|
+
const jobs = declaredJobsOf([...this.jobDeclarers, { manifest, jobs: registration.jobs }]);
|
|
2078
2090
|
const migrations = registration.migrations ?? [];
|
|
2079
2091
|
const seen = new Set();
|
|
2080
2092
|
for (const m of migrations) {
|
|
@@ -2175,9 +2187,13 @@ export class SqliteScopeHost {
|
|
|
2175
2187
|
freshness: manifest.freshness ?? [],
|
|
2176
2188
|
peers: manifest.peers ?? [],
|
|
2177
2189
|
purgeOnlyKeys: purgeOnlyKeysOf(manifest.schedules ?? []),
|
|
2190
|
+
jobKeys: jobSystemKeysOf(registration.jobs),
|
|
2178
2191
|
});
|
|
2179
2192
|
for (const [operation, schedule] of dueByEventSchedulesOf(manifest.schedules))
|
|
2180
2193
|
this.dueSchedules.set(operation, schedule);
|
|
2194
|
+
if (registration.jobs)
|
|
2195
|
+
this.jobDeclarers.push({ manifest, jobs: registration.jobs });
|
|
2196
|
+
this.declaredJobs = jobs;
|
|
2181
2197
|
noteReservedKeys(this.reservedKeys, manifest);
|
|
2182
2198
|
noteDeclaredKeys(this.declaredKeys, manifest);
|
|
2183
2199
|
if (erasure)
|
|
@@ -2418,6 +2434,9 @@ export class SqliteScopeHost {
|
|
|
2418
2434
|
for (const s of mod.schedules)
|
|
2419
2435
|
for (const p of s.permissions)
|
|
2420
2436
|
perms.add(p);
|
|
2437
|
+
// #3752: and the keys its declared jobs' passes hold, seated the same way.
|
|
2438
|
+
for (const p of mod.jobKeys)
|
|
2439
|
+
perms.add(p);
|
|
2421
2440
|
for (const perm of perms) {
|
|
2422
2441
|
// A module switched off (#1666) gets nothing seated — see `seatScopeTuple`.
|
|
2423
2442
|
const seat = seatScopeTuple(`system:${mod.id}`, `granted:${perm}`, `scope:${input.scopeId}`, null);
|
|
@@ -2835,7 +2854,9 @@ export class SqliteScopeHost {
|
|
|
2835
2854
|
.prepare('SELECT vertical FROM scopes WHERE scope_id = ?')
|
|
2836
2855
|
.get(scopeId);
|
|
2837
2856
|
const surface = this.buildAttachments(rt, { kind: 'system', id: moduleId }, this.attachmentStore(tenantId, row?.vertical ?? null));
|
|
2838
|
-
|
|
2857
|
+
// #3752: `openStream` and `upload` for a container pass; the upload is the module's own file,
|
|
2858
|
+
// checked against the target's write key as system:<moduleId> like every verb here.
|
|
2859
|
+
return { open: surface.open, openStream: surface.openStream, remove: surface.remove, upload: surface.upload };
|
|
2839
2860
|
}
|
|
2840
2861
|
/**
|
|
2841
2862
|
* The attachment surface (#473) — `attachmentTargets` consumed at last. Metadata facts
|
|
@@ -2986,7 +3007,8 @@ export class SqliteScopeHost {
|
|
|
2986
3007
|
filename: input.filename,
|
|
2987
3008
|
contentType: input.contentType,
|
|
2988
3009
|
visibility: input.visibility,
|
|
2989
|
-
|
|
3010
|
+
// #3752: a module's own file is authored by its actor, as the contract spells one.
|
|
3011
|
+
createdBy: creator.kind === 'system' ? JSON.stringify({ system: creator.id }) : creator.id,
|
|
2990
3012
|
createdAt: new Date().toISOString(),
|
|
2991
3013
|
};
|
|
2992
3014
|
// Bytes first, row second: a crash between the two leaves an orphaned object that no
|
|
@@ -6040,9 +6062,39 @@ export class SqliteScopeHost {
|
|
|
6040
6062
|
* a pass makes through `pass.scope()` take their own separate turns — so there is
|
|
6041
6063
|
* no path by which this can deadlock against itself.
|
|
6042
6064
|
*/
|
|
6043
|
-
|
|
6065
|
+
/**
|
|
6066
|
+
* `onEnded`: called after a write that ended a declared run committed its `job.run-ended` event
|
|
6067
|
+
* (D-85), so the drive delivers it once it is done.
|
|
6068
|
+
*/
|
|
6069
|
+
jobStore(rt, onEnded) {
|
|
6044
6070
|
const db = rt.db;
|
|
6045
6071
|
const row = (v) => v ?? null;
|
|
6072
|
+
// D-85: a declared run's end goes to the outbox in the transaction of the write that ended it.
|
|
6073
|
+
const runById = db.prepare('SELECT * FROM _substrat_job_runs WHERE id = ?');
|
|
6074
|
+
let endedHere = false;
|
|
6075
|
+
const announceEnd = (id) => {
|
|
6076
|
+
const ended = row(runById.get(id));
|
|
6077
|
+
const st = ended &&
|
|
6078
|
+
jobRunEndedOutbox(ended, {
|
|
6079
|
+
tenantId: rt.tenantId,
|
|
6080
|
+
scopeId: rt.scopeId,
|
|
6081
|
+
now: now(),
|
|
6082
|
+
mintEventId: (ms) => rt.mintEventId(ms),
|
|
6083
|
+
version: this.versionId,
|
|
6084
|
+
});
|
|
6085
|
+
if (st) {
|
|
6086
|
+
db.prepare(st.sql).run(...st.params);
|
|
6087
|
+
endedHere = true;
|
|
6088
|
+
}
|
|
6089
|
+
};
|
|
6090
|
+
// The flag is read after the transaction commits, so a rolled-back end announces nothing.
|
|
6091
|
+
const afterCommit = (fn) => {
|
|
6092
|
+
endedHere = false;
|
|
6093
|
+
const out = fn();
|
|
6094
|
+
if (endedHere)
|
|
6095
|
+
onEnded?.();
|
|
6096
|
+
return out;
|
|
6097
|
+
};
|
|
6046
6098
|
const findLive = db.prepare(`SELECT * FROM _substrat_job_runs
|
|
6047
6099
|
WHERE module_id = ? AND job = ? AND instance = ? AND status = 'running'
|
|
6048
6100
|
ORDER BY id DESC LIMIT 1`);
|
|
@@ -6085,6 +6137,15 @@ export class SqliteScopeHost {
|
|
|
6085
6137
|
if (patchRun.run(...patchArgs(id, p, owner)).changes === 0)
|
|
6086
6138
|
return false;
|
|
6087
6139
|
dropSteps.run(id);
|
|
6140
|
+
if (p.status !== 'running')
|
|
6141
|
+
announceEnd(id);
|
|
6142
|
+
return true;
|
|
6143
|
+
});
|
|
6144
|
+
const patchTx = db.transaction((id, p, owner) => {
|
|
6145
|
+
if (patchRun.run(...patchArgs(id, p, owner)).changes === 0)
|
|
6146
|
+
return false;
|
|
6147
|
+
if (p.status !== 'running')
|
|
6148
|
+
announceEnd(id);
|
|
6088
6149
|
return true;
|
|
6089
6150
|
});
|
|
6090
6151
|
// #2034: the claim, and whether it took over a lease, read in the same transaction.
|
|
@@ -6102,7 +6163,9 @@ export class SqliteScopeHost {
|
|
|
6102
6163
|
if (!counted)
|
|
6103
6164
|
return null;
|
|
6104
6165
|
const o = admissionMissOutcome(counted.admission_misses, at, note);
|
|
6105
|
-
missSettle.run(o.status, o.nextAttemptAt, o.endedAt, o.lastError, id, counted.admission_misses);
|
|
6166
|
+
const settled = missSettle.run(o.status, o.nextAttemptAt, o.endedAt, o.lastError, id, counted.admission_misses).changes > 0;
|
|
6167
|
+
if (settled && o.status === 'failed')
|
|
6168
|
+
announceEnd(id);
|
|
6106
6169
|
return { misses: counted.admission_misses, failed: o.status === 'failed' };
|
|
6107
6170
|
});
|
|
6108
6171
|
const recordStepTx = db.transaction((runId, name, result, attempts, lastError, at, owner, leaseMs) => {
|
|
@@ -6123,7 +6186,7 @@ export class SqliteScopeHost {
|
|
|
6123
6186
|
const at = now();
|
|
6124
6187
|
return beginRun.run(at, id, owner, plus(at, marginMs)).changes > 0;
|
|
6125
6188
|
}),
|
|
6126
|
-
miss: (id, owner, note) => turn(() => missTx(id, owner, note)),
|
|
6189
|
+
miss: (id, owner, note) => turn(() => afterCommit(() => missTx(id, owner, note))),
|
|
6127
6190
|
// #1834: the drive's one snapshot — keys only, in the order runs became due.
|
|
6128
6191
|
dueKeys: (now, max) => turn(() => db
|
|
6129
6192
|
.prepare(`SELECT id, module_id, job FROM _substrat_job_runs
|
|
@@ -6151,8 +6214,8 @@ export class SqliteScopeHost {
|
|
|
6151
6214
|
ORDER BY id DESC LIMIT ?`)
|
|
6152
6215
|
.all(...params);
|
|
6153
6216
|
}),
|
|
6154
|
-
patch: (id, p, owner) => turn(() =>
|
|
6155
|
-
commitPass: (id, p, owner) => turn(() => commitPassTx(id, p, owner)),
|
|
6217
|
+
patch: (id, p, owner) => turn(() => afterCommit(() => patchTx(id, p, owner))),
|
|
6218
|
+
commitPass: (id, p, owner) => turn(() => afterCommit(() => commitPassTx(id, p, owner))),
|
|
6156
6219
|
// #2034: a step boundary renews the lease; a pass that lost it reads nothing.
|
|
6157
6220
|
beginStep: (runId, name, owner, leaseMs) => turn(() => {
|
|
6158
6221
|
if (renewRun.run(plus(now(), leaseMs), runId, owner).changes === 0)
|
|
@@ -6212,9 +6275,32 @@ export class SqliteScopeHost {
|
|
|
6212
6275
|
requeue: (ids) => rt.actor.enqueue(() => rt.db.transaction(() => requeueUnsupportedAttachmentText(spineSql(rt.db), ids, ulid, this.clock()))()),
|
|
6213
6276
|
}, this.attachmentExtractors),
|
|
6214
6277
|
};
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6278
|
+
let ended = false;
|
|
6279
|
+
const report = await runDueJobRuns({
|
|
6280
|
+
store: this.jobStore(rt, () => {
|
|
6281
|
+
ended = true;
|
|
6282
|
+
}),
|
|
6283
|
+
handlerFor: (run) => kernelJobFor(run, kernelJobs) ??
|
|
6284
|
+
// D-85 (#3752): a container placement hands the pass off; its end comes back through the door.
|
|
6285
|
+
containerPassRegistration(this.containerPasses, run, {
|
|
6286
|
+
tenantId,
|
|
6287
|
+
scopeId,
|
|
6288
|
+
door: async (ticket) => ({
|
|
6289
|
+
store: this.jobStore(rt, () => {
|
|
6290
|
+
void rt.actor.enqueue(async () => {
|
|
6291
|
+
await this.dispatch(rt, null);
|
|
6292
|
+
await this.dispatchExecutors(rt, null);
|
|
6293
|
+
await this.handOffCommitted(rt);
|
|
6294
|
+
});
|
|
6295
|
+
}),
|
|
6296
|
+
ticket,
|
|
6297
|
+
now: this.clock,
|
|
6298
|
+
files: () => this.getSystemAttachments(ticket.moduleId, tenantId, scopeId),
|
|
6299
|
+
}),
|
|
6300
|
+
}) ??
|
|
6301
|
+
this.jobs.get(`${run.module_id}/${run.job}`),
|
|
6302
|
+
// D-85: a declared job's run with no handler here fails on its record instead of waiting forever.
|
|
6303
|
+
declared: (run) => this.declaredJobs.get(run.job)?.moduleId === run.module_id,
|
|
6218
6304
|
now: this.clock,
|
|
6219
6305
|
openScope: (run) => this.getSystemScope(run.module_id, tenantId, scopeId),
|
|
6220
6306
|
// #3443: the run's module's files, through the same gate `getSystemAttachments` opens.
|
|
@@ -6222,6 +6308,16 @@ export class SqliteScopeHost {
|
|
|
6222
6308
|
maxPasses: options?.maxPasses,
|
|
6223
6309
|
limit: options?.limit,
|
|
6224
6310
|
});
|
|
6311
|
+
// D-85: a run that ended wrote `job.run-ended`; it reaches this scope's consumers now, as a
|
|
6312
|
+
// settle's outcome event does.
|
|
6313
|
+
if (ended) {
|
|
6314
|
+
await rt.actor.enqueue(async () => {
|
|
6315
|
+
await this.dispatch(rt, null);
|
|
6316
|
+
await this.dispatchExecutors(rt, null);
|
|
6317
|
+
await this.handOffCommitted(rt);
|
|
6318
|
+
});
|
|
6319
|
+
}
|
|
6320
|
+
return report;
|
|
6225
6321
|
}
|
|
6226
6322
|
async jobRuns(tenantId, scopeId, filter) {
|
|
6227
6323
|
const rt = this.runtime(tenantId, scopeId);
|
|
@@ -6424,7 +6520,12 @@ export class SqliteScopeHost {
|
|
|
6424
6520
|
return;
|
|
6425
6521
|
this.handoffEnvironments.set(key, environment);
|
|
6426
6522
|
const options = mode
|
|
6427
|
-
? {
|
|
6523
|
+
? {
|
|
6524
|
+
mode: mode.mode,
|
|
6525
|
+
// A6 (#3472): the lake is the broker's, so each event is also owed the lake receiver.
|
|
6526
|
+
...(mode.mode === 'live' && mode.lake ? { lake: true } : {}),
|
|
6527
|
+
...(mode.startPending ? { start: { ...ids, after: mode.start } } : {}),
|
|
6528
|
+
}
|
|
6428
6529
|
: {};
|
|
6429
6530
|
/** #3474: the round now with the broker, so a throw reports what it tried. */
|
|
6430
6531
|
let inFlight = null;
|
|
@@ -6501,9 +6602,12 @@ export class SqliteScopeHost {
|
|
|
6501
6602
|
* is handed off, and a new comparison window starts there. Off stops the handoff. Only under
|
|
6502
6603
|
* `deliveryHandoff: 'by-mode'` does it decide what is handed off; it is recorded either way.
|
|
6503
6604
|
*/
|
|
6504
|
-
async applyDeliveryMode(tenantId, scopeId, mode
|
|
6605
|
+
async applyDeliveryMode(tenantId, scopeId, mode,
|
|
6606
|
+
/** A6 (#3472): the lake is the broker's for this scope (`DELIVERY_BROKER_LAKE`); kept only beside live. */
|
|
6607
|
+
lake) {
|
|
6505
6608
|
const key = `${tenantId}/${scopeId}`;
|
|
6506
6609
|
const rt = await this.openActiveScope(tenantId, scopeId);
|
|
6610
|
+
const owned = mode === 'live' && lake === true;
|
|
6507
6611
|
await rt.actor.enqueue(async () => {
|
|
6508
6612
|
const prior = this.deliveryModes.get(key);
|
|
6509
6613
|
if (mode === 'off') {
|
|
@@ -6512,6 +6616,7 @@ export class SqliteScopeHost {
|
|
|
6512
6616
|
}
|
|
6513
6617
|
if (prior) {
|
|
6514
6618
|
prior.mode = mode;
|
|
6619
|
+
prior.lake = owned;
|
|
6515
6620
|
return;
|
|
6516
6621
|
}
|
|
6517
6622
|
const newest = (sql) => rt.db.prepare(sql).get()?.id;
|
|
@@ -6527,7 +6632,7 @@ export class SqliteScopeHost {
|
|
|
6527
6632
|
...((known.event ?? '') > (seed.event ?? '') ? { event: known.event } : seed.event ? { event: seed.event } : {}),
|
|
6528
6633
|
...((known.intent ?? '') > (seed.intent ?? '') ? { intent: known.intent } : seed.intent ? { intent: seed.intent } : {}),
|
|
6529
6634
|
});
|
|
6530
|
-
this.deliveryModes.set(key, { mode, start: seed, startPending: true });
|
|
6635
|
+
this.deliveryModes.set(key, { mode, start: seed, startPending: true, lake: owned });
|
|
6531
6636
|
await this.handOffCommitted(rt);
|
|
6532
6637
|
});
|
|
6533
6638
|
}
|
|
@@ -6545,6 +6650,12 @@ export class SqliteScopeHost {
|
|
|
6545
6650
|
const q = intentStateQuery(id);
|
|
6546
6651
|
return intentStateOf(rt.db.prepare(q.sql).all(...q.params));
|
|
6547
6652
|
}
|
|
6653
|
+
/** A6 (#3472): whether one event is in the lake yet, for a broker's lake receiver. */
|
|
6654
|
+
async eventLakeState(tenantId, scopeId, id) {
|
|
6655
|
+
const rt = await this.openActiveScope(tenantId, scopeId);
|
|
6656
|
+
const q = eventLakeStateQuery(id);
|
|
6657
|
+
return eventLakeStateOf(rt.db.prepare(q.sql).all(...q.params));
|
|
6658
|
+
}
|
|
6548
6659
|
/**
|
|
6549
6660
|
* K-74: hand off again whatever a scope's earlier handoff left unacknowledged — the pure host's
|
|
6550
6661
|
* stand-in for the scope alarm that retries it on the Durable Object. Runs in the scope's actor.
|
|
@@ -7184,6 +7295,7 @@ export class SqliteScopeHost {
|
|
|
7184
7295
|
origin: r.origin_json ? JSON.parse(r.origin_json) : null,
|
|
7185
7296
|
outbound: outboundOfManifestJson(r.manifest_json),
|
|
7186
7297
|
calls: callsOfManifestJson(r.manifest_json),
|
|
7298
|
+
bundleDigest: r.bundle_digest ?? null,
|
|
7187
7299
|
createdAt: r.created_at,
|
|
7188
7300
|
});
|
|
7189
7301
|
// #2339: a version stored before the server derived migration digests is derived on its
|
|
@@ -7199,7 +7311,7 @@ export class SqliteScopeHost {
|
|
|
7199
7311
|
};
|
|
7200
7312
|
/** A version's admission, read synchronously so a transaction can judge it (#2528). */
|
|
7201
7313
|
const versionAdmission = (id) => {
|
|
7202
|
-
const v = this.directory.prepare('SELECT admission, admission_note FROM vertical_versions WHERE id = ?')
|
|
7314
|
+
const v = this.directory.prepare('SELECT admission, admission_note, bundle_digest FROM vertical_versions WHERE id = ?')
|
|
7203
7315
|
.get(id);
|
|
7204
7316
|
if (!v)
|
|
7205
7317
|
throw substratError('not_found', `unknown version ${id}`);
|
|
@@ -8332,8 +8444,12 @@ export class SqliteScopeHost {
|
|
|
8332
8444
|
return resolveVerticalInstanceFrom(this.peerCandidates(tenant, vertical), tenant, vertical);
|
|
8333
8445
|
},
|
|
8334
8446
|
resolvePeerInstance: async (tenantId, callerScopeId, vertical) => {
|
|
8335
|
-
|
|
8447
|
+
// D-83 (#3530 step 5): a caller that is not an install is answered per environment.
|
|
8336
8448
|
const tenant = this.peerTenant(tenantId);
|
|
8449
|
+
const perEnvironment = environmentPeerResolutionIn(switchSqlOf(this.directory), tenant, callerScopeId, vertical);
|
|
8450
|
+
if (perEnvironment)
|
|
8451
|
+
return perEnvironment;
|
|
8452
|
+
const binding = this.directory.prepare('SELECT target_scope_id, invalidated FROM peer_bindings WHERE tenant_id = ? AND caller_scope_id = ? AND vertical = ?').get(tenantId, callerScopeId, vertical);
|
|
8337
8453
|
return resolvePeerInstanceFrom(this.peerCandidates(tenant, vertical), tenant, vertical, binding?.target_scope_id ?? null, binding?.invalidated === 1);
|
|
8338
8454
|
},
|
|
8339
8455
|
peerBinding: async (actor, tenantId, callerScopeId, vertical) => {
|
|
@@ -8571,7 +8687,8 @@ export class SqliteScopeHost {
|
|
|
8571
8687
|
return rows.map(mapVertical);
|
|
8572
8688
|
},
|
|
8573
8689
|
publishVersion: async (actor, input) => {
|
|
8574
|
-
|
|
8690
|
+
// #3612: the stored input, whose `bundleDigest` only the control plane's own push sets.
|
|
8691
|
+
const parsed = storedVersionInput.parse(input);
|
|
8575
8692
|
const unknownVertical = () => substratError('not_found', `unknown vertical '${parsed.verticalSlug}'`);
|
|
8576
8693
|
if (!readVertical(parsed.verticalSlug))
|
|
8577
8694
|
throw unknownVertical();
|
|
@@ -8600,9 +8717,9 @@ export class SqliteScopeHost {
|
|
|
8600
8717
|
.prepare(`INSERT INTO vertical_versions
|
|
8601
8718
|
(id, vertical_slug, version, manifest_digest, permission_digest,
|
|
8602
8719
|
migration_digest, deployment_ref, admission, admission_note, manifest_json,
|
|
8603
|
-
origin_json, migration_count, migrations_split, migration_digest_derived, created_at)
|
|
8604
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 1, ?)`)
|
|
8605
|
-
.run(audited.id, audited.verticalSlug, audited.version, audited.manifestDigest, audited.permissionDigest, migrationDigest, audited.deploymentRef, selfAdmits ? 'admitted' : 'pending', selfAdmits ? AUTO_ADMISSION_NOTE : null, split.manifestJson, origin ? JSON.stringify(origin) : null, split.migrations?.length ?? null, new Date().toISOString());
|
|
8720
|
+
origin_json, migration_count, migrations_split, migration_digest_derived, bundle_digest, created_at)
|
|
8721
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 1, ?, ?)`)
|
|
8722
|
+
.run(audited.id, audited.verticalSlug, audited.version, audited.manifestDigest, audited.permissionDigest, migrationDigest, audited.deploymentRef, selfAdmits ? 'admitted' : 'pending', selfAdmits ? AUTO_ADMISSION_NOTE : null, split.manifestJson, origin ? JSON.stringify(origin) : null, split.migrations?.length ?? null, audited.bundleDigest ?? null, new Date().toISOString());
|
|
8606
8723
|
writeVersionMigrations(switchSqlOf(this.directory), audited.id, split.migrations);
|
|
8607
8724
|
// #2286: the version's scope-store bindings, refusing one moved to another driver, in the insert's transaction.
|
|
8608
8725
|
indexVersionScopeStores(switchSqlOf(this.directory), audited.verticalSlug, audited.id, split.manifestJson);
|
|
@@ -8737,13 +8854,13 @@ export class SqliteScopeHost {
|
|
|
8737
8854
|
// manual vouch by clearing the note (what the publish seam requires).
|
|
8738
8855
|
if (v.admission_note !== AUTO_ADMISSION_NOTE)
|
|
8739
8856
|
return false;
|
|
8740
|
-
row = { before: { admission: v.admission, note: v.admission_note }, after: { admission: 'admitted', note: null } };
|
|
8857
|
+
row = { before: { admission: v.admission, note: v.admission_note }, after: { admission: 'admitted', note: null, ...admittedBundleAudit(versionId, v.bundle_digest) } };
|
|
8741
8858
|
return this.directory.prepare('UPDATE vertical_versions SET admission_note = NULL WHERE id = ?').run(versionId).changes > 0;
|
|
8742
8859
|
}
|
|
8743
8860
|
if (v.admission === 'rejected') {
|
|
8744
8861
|
throw substratError('conflict', `version ${versionId} was rejected — publish a new one`);
|
|
8745
8862
|
}
|
|
8746
|
-
row = { before: { admission: v.admission }, after: { admission: 'admitted' } };
|
|
8863
|
+
row = { before: { admission: v.admission }, after: { admission: 'admitted', ...admittedBundleAudit(versionId, v.bundle_digest) } };
|
|
8747
8864
|
return this.directory.prepare("UPDATE vertical_versions SET admission = 'admitted' WHERE id = ?").run(versionId).changes > 0;
|
|
8748
8865
|
}, () => this.recordAdmin(actor, 'admitVersion', { tenantId: null }, row.before, row.after));
|
|
8749
8866
|
},
|
|
@@ -9054,6 +9171,10 @@ export class SqliteScopeHost {
|
|
|
9054
9171
|
throw substratError('precondition_failed', 'scope erasure changed; reload the scope and retry');
|
|
9055
9172
|
}
|
|
9056
9173
|
const ack = bindAcknowledgement.parse(opts?.acknowledge ?? {});
|
|
9174
|
+
// #3638: what this bind acknowledges if the scope is a named environment's preview.
|
|
9175
|
+
const envAck = opts?.environmentAcknowledge === undefined
|
|
9176
|
+
? undefined
|
|
9177
|
+
: environmentServeAcknowledgement.parse(opts.environmentAcknowledge);
|
|
9057
9178
|
// #2347: a route moving in the same write is judged with it, as `bindingImpact` is.
|
|
9058
9179
|
const servingRef = opts?.servingRef;
|
|
9059
9180
|
// #2178 first: no acknowledgement passes it, so none should be asked for ahead of it.
|
|
@@ -9082,11 +9203,20 @@ export class SqliteScopeHost {
|
|
|
9082
9203
|
...(servingRef !== undefined ? { servingRef } : {}),
|
|
9083
9204
|
...(opts?.expectedVersionId !== undefined ? { expectedVersionId: opts.expectedVersionId } : {}),
|
|
9084
9205
|
...(opts?.expectedServing ? { expectedServing: opts.expectedServing } : {}),
|
|
9085
|
-
|
|
9206
|
+
// #3638: an environment's acknowledgement is recorded with this bind, as a serve's is with its record.
|
|
9207
|
+
...(ack.exportBreak || envAck ? { acknowledged: { ...ack, ...envAck } } : {}),
|
|
9086
9208
|
});
|
|
9209
|
+
// #3638 (D-83): a bind of a named environment's preview is judged against what that environment
|
|
9210
|
+
// serves, in the write that moves it, so a push carried onto it before its first own-script serve
|
|
9211
|
+
// is held to the checkpoints too.
|
|
9212
|
+
const judge = () => {
|
|
9213
|
+
const refusal = environmentBindRefusalIn(switchSqlOf(this.directory), tenantId, scopeId, versionId, envAck);
|
|
9214
|
+
if (refusal)
|
|
9215
|
+
throw refusal;
|
|
9216
|
+
};
|
|
9087
9217
|
const moved = servingRef === undefined
|
|
9088
|
-
? this.moveScopeRow('vertical_version_id = ?, vertical = ?', [versionId, v.verticalSlug], tenantId, scopeId, opts, audit)
|
|
9089
|
-
: this.moveScopeRow('vertical_version_id = ?, vertical = ?, serving_ref = ?', [versionId, v.verticalSlug, servingRef], tenantId, scopeId, opts, audit);
|
|
9218
|
+
? this.moveScopeRow('vertical_version_id = ?, vertical = ?', [versionId, v.verticalSlug], tenantId, scopeId, opts, audit, judge)
|
|
9219
|
+
: this.moveScopeRow('vertical_version_id = ?, vertical = ?, serving_ref = ?', [versionId, v.verticalSlug, servingRef], tenantId, scopeId, opts, audit, judge);
|
|
9090
9220
|
if (!moved) {
|
|
9091
9221
|
// The erasure and copy-move conditions keep their own refusal: only a moved binding or a
|
|
9092
9222
|
// moved serving version is the race a rebind's review answers.
|
|
@@ -11972,9 +12102,12 @@ export class SqliteScopeHost {
|
|
|
11972
12102
|
* claimed, and on its copy move still owning a live lease. The move's confirmation commits in
|
|
11973
12103
|
* the same transaction as the row. False when any condition failed and nothing was written.
|
|
11974
12104
|
*/
|
|
11975
|
-
moveScopeRow(set, setArgs, tenantId, scopeId, cond, audit
|
|
12105
|
+
moveScopeRow(set, setArgs, tenantId, scopeId, cond, audit,
|
|
12106
|
+
/** Judged first, in the write's own transaction: a throw refuses the move with nothing written. */
|
|
12107
|
+
judge) {
|
|
11976
12108
|
const now = new Date().toISOString();
|
|
11977
12109
|
return this.directoryWriteAndAudit(() => {
|
|
12110
|
+
judge?.();
|
|
11978
12111
|
const moved = this.directory.prepare(`UPDATE scopes SET ${set} WHERE scope_id = ?
|
|
11979
12112
|
${cond?.expectedVersionId === undefined ? '' : 'AND vertical_version_id IS ?'}
|
|
11980
12113
|
${cond?.expectedErasureEpoch === undefined ? '' : 'AND COALESCE(erasure_epoch, 0) = ? AND reap_claimed_at IS NULL'}
|
|
@@ -12847,6 +12980,20 @@ export class SqliteScopeHost {
|
|
|
12847
12980
|
}),
|
|
12848
12981
|
// Upload links: mint / revoke / list, written once in the kernel — the same four things
|
|
12849
12982
|
// `capabilities` is handed, and the same consumer-is-system-actor rule.
|
|
12983
|
+
// D-85: start or join a declared job's run, in this transaction, checked as the caller.
|
|
12984
|
+
jobs: createJobVerbs({
|
|
12985
|
+
sql: spineSql(rt.db),
|
|
12986
|
+
// #2993: only the jobs of the modules this scope's type runs; the drive keeps the whole map.
|
|
12987
|
+
jobs: this.scopeTypePlan.declared
|
|
12988
|
+
? new Map([...this.declaredJobs].filter(([, j]) => this.runsOn(rt.scopeId, j.moduleId)))
|
|
12989
|
+
: this.declaredJobs,
|
|
12990
|
+
check: (permission) => runCheck(permission),
|
|
12991
|
+
now: at,
|
|
12992
|
+
mintId: ulid,
|
|
12993
|
+
assertWrites: (verb) => assertImpersonationWrites(impersonation, verb),
|
|
12994
|
+
subject: overrideActor ? { kind: 'system', id: overrideActor.system } : subject,
|
|
12995
|
+
minted,
|
|
12996
|
+
}),
|
|
12850
12997
|
attachments: createAttachmentVerbs({
|
|
12851
12998
|
sql: spineSql(rt.db),
|
|
12852
12999
|
subject: overrideActor ? { kind: 'system', id: overrideActor.system } : subject,
|
|
@@ -13371,6 +13518,8 @@ export class SqliteScopeHost {
|
|
|
13371
13518
|
this.ensureColumn(db, '_substrat_job_runs', 'lease_began_at', 'lease_began_at TEXT');
|
|
13372
13519
|
// #2042 r3: consecutive admission misses. NULL = none, right for every run already there.
|
|
13373
13520
|
this.ensureColumn(db, '_substrat_job_runs', 'admission_misses', 'admission_misses INTEGER');
|
|
13521
|
+
// D-85: the declared job's definition version. NULL = a run of an undeclared job, or one before it.
|
|
13522
|
+
this.ensureColumn(db, '_substrat_job_runs', 'definition_version', 'definition_version INTEGER');
|
|
13374
13523
|
// #2009: the copy classification on a scope DB built before it (NULL reads as a copy; see
|
|
13375
13524
|
// `COPY_ORIGIN_DDL`).
|
|
13376
13525
|
this.ensureColumn(db, '_substrat_copy_origin', 'is_copy', 'is_copy INTEGER');
|