@substrat-run/adapter-sqlite 0.228.0 → 0.229.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 +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +128 -16
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readdirSync, rea
|
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
5
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, 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, 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, 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';
|
|
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, 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,7 +13,7 @@ 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
18
|
import { prePromoteSnapshotExpiresAt } from '@substrat-run/kernel';
|
|
19
19
|
import { breakingWithinMajorRefusal, earlierMajorReleaseTarget, earlierMajorsOf, releasedEarlierMajorJson, releaseWithinMajorRefusal, SCRIPT_SERVING_VERSION_SQL, supersededMajorsJson } from '@substrat-run/kernel';
|
|
@@ -1008,6 +1008,9 @@ export class SqliteScopeHost {
|
|
|
1008
1008
|
* may name, and the operations whose every run clears their date in its own transaction.
|
|
1009
1009
|
*/
|
|
1010
1010
|
dueSchedules = new Map();
|
|
1011
|
+
/** D-85: the modules that declare jobs, and every declared job by name (`declaredJobsOf`). */
|
|
1012
|
+
jobDeclarers = [];
|
|
1013
|
+
declaredJobs = new Map();
|
|
1011
1014
|
versionId;
|
|
1012
1015
|
/** K-74: the broker each scope hands off to, or null (off). */
|
|
1013
1016
|
deliveryBroker;
|
|
@@ -1018,6 +1021,7 @@ export class SqliteScopeHost {
|
|
|
1018
1021
|
handoffEnvironments = new Map();
|
|
1019
1022
|
/** A5: `deliveryHandoff`, and each scope's mode with its window start (in memory, as the marks are). */
|
|
1020
1023
|
deliveryHandoff;
|
|
1024
|
+
/** A5: each scope's delivery mode; `lake` (A6, #3472) when the lake is its broker's, only beside live. */
|
|
1021
1025
|
deliveryModes = new Map();
|
|
1022
1026
|
migrationsDigest;
|
|
1023
1027
|
/** #1746: where `ctx.log` lines go — the console unless a caller (a test) says otherwise. */
|
|
@@ -2075,6 +2079,8 @@ export class SqliteScopeHost {
|
|
|
2075
2079
|
// #2068: refused here, before anything is recorded, when the module claims an erasure it
|
|
2076
2080
|
// cannot deliver (a hook with no reach declared, a `custom` entity with no hook).
|
|
2077
2081
|
const erasure = moduleErasurePlan(registration);
|
|
2082
|
+
// D-85: the module's jobs, refused before anything is recorded (a name taken, an undeclared key).
|
|
2083
|
+
const jobs = declaredJobsOf([...this.jobDeclarers, { manifest, jobs: registration.jobs }]);
|
|
2078
2084
|
const migrations = registration.migrations ?? [];
|
|
2079
2085
|
const seen = new Set();
|
|
2080
2086
|
for (const m of migrations) {
|
|
@@ -2178,6 +2184,9 @@ export class SqliteScopeHost {
|
|
|
2178
2184
|
});
|
|
2179
2185
|
for (const [operation, schedule] of dueByEventSchedulesOf(manifest.schedules))
|
|
2180
2186
|
this.dueSchedules.set(operation, schedule);
|
|
2187
|
+
if (registration.jobs)
|
|
2188
|
+
this.jobDeclarers.push({ manifest, jobs: registration.jobs });
|
|
2189
|
+
this.declaredJobs = jobs;
|
|
2181
2190
|
noteReservedKeys(this.reservedKeys, manifest);
|
|
2182
2191
|
noteDeclaredKeys(this.declaredKeys, manifest);
|
|
2183
2192
|
if (erasure)
|
|
@@ -6040,9 +6049,39 @@ export class SqliteScopeHost {
|
|
|
6040
6049
|
* a pass makes through `pass.scope()` take their own separate turns — so there is
|
|
6041
6050
|
* no path by which this can deadlock against itself.
|
|
6042
6051
|
*/
|
|
6043
|
-
|
|
6052
|
+
/**
|
|
6053
|
+
* `onEnded`: called after a write that ended a declared run committed its `job.run-ended` event
|
|
6054
|
+
* (D-85), so the drive delivers it once it is done.
|
|
6055
|
+
*/
|
|
6056
|
+
jobStore(rt, onEnded) {
|
|
6044
6057
|
const db = rt.db;
|
|
6045
6058
|
const row = (v) => v ?? null;
|
|
6059
|
+
// D-85: a declared run's end goes to the outbox in the transaction of the write that ended it.
|
|
6060
|
+
const runById = db.prepare('SELECT * FROM _substrat_job_runs WHERE id = ?');
|
|
6061
|
+
let endedHere = false;
|
|
6062
|
+
const announceEnd = (id) => {
|
|
6063
|
+
const ended = row(runById.get(id));
|
|
6064
|
+
const st = ended &&
|
|
6065
|
+
jobRunEndedOutbox(ended, {
|
|
6066
|
+
tenantId: rt.tenantId,
|
|
6067
|
+
scopeId: rt.scopeId,
|
|
6068
|
+
now: now(),
|
|
6069
|
+
mintEventId: (ms) => rt.mintEventId(ms),
|
|
6070
|
+
version: this.versionId,
|
|
6071
|
+
});
|
|
6072
|
+
if (st) {
|
|
6073
|
+
db.prepare(st.sql).run(...st.params);
|
|
6074
|
+
endedHere = true;
|
|
6075
|
+
}
|
|
6076
|
+
};
|
|
6077
|
+
// The flag is read after the transaction commits, so a rolled-back end announces nothing.
|
|
6078
|
+
const afterCommit = (fn) => {
|
|
6079
|
+
endedHere = false;
|
|
6080
|
+
const out = fn();
|
|
6081
|
+
if (endedHere)
|
|
6082
|
+
onEnded?.();
|
|
6083
|
+
return out;
|
|
6084
|
+
};
|
|
6046
6085
|
const findLive = db.prepare(`SELECT * FROM _substrat_job_runs
|
|
6047
6086
|
WHERE module_id = ? AND job = ? AND instance = ? AND status = 'running'
|
|
6048
6087
|
ORDER BY id DESC LIMIT 1`);
|
|
@@ -6085,6 +6124,15 @@ export class SqliteScopeHost {
|
|
|
6085
6124
|
if (patchRun.run(...patchArgs(id, p, owner)).changes === 0)
|
|
6086
6125
|
return false;
|
|
6087
6126
|
dropSteps.run(id);
|
|
6127
|
+
if (p.status !== 'running')
|
|
6128
|
+
announceEnd(id);
|
|
6129
|
+
return true;
|
|
6130
|
+
});
|
|
6131
|
+
const patchTx = db.transaction((id, p, owner) => {
|
|
6132
|
+
if (patchRun.run(...patchArgs(id, p, owner)).changes === 0)
|
|
6133
|
+
return false;
|
|
6134
|
+
if (p.status !== 'running')
|
|
6135
|
+
announceEnd(id);
|
|
6088
6136
|
return true;
|
|
6089
6137
|
});
|
|
6090
6138
|
// #2034: the claim, and whether it took over a lease, read in the same transaction.
|
|
@@ -6102,7 +6150,9 @@ export class SqliteScopeHost {
|
|
|
6102
6150
|
if (!counted)
|
|
6103
6151
|
return null;
|
|
6104
6152
|
const o = admissionMissOutcome(counted.admission_misses, at, note);
|
|
6105
|
-
missSettle.run(o.status, o.nextAttemptAt, o.endedAt, o.lastError, id, counted.admission_misses);
|
|
6153
|
+
const settled = missSettle.run(o.status, o.nextAttemptAt, o.endedAt, o.lastError, id, counted.admission_misses).changes > 0;
|
|
6154
|
+
if (settled && o.status === 'failed')
|
|
6155
|
+
announceEnd(id);
|
|
6106
6156
|
return { misses: counted.admission_misses, failed: o.status === 'failed' };
|
|
6107
6157
|
});
|
|
6108
6158
|
const recordStepTx = db.transaction((runId, name, result, attempts, lastError, at, owner, leaseMs) => {
|
|
@@ -6123,7 +6173,7 @@ export class SqliteScopeHost {
|
|
|
6123
6173
|
const at = now();
|
|
6124
6174
|
return beginRun.run(at, id, owner, plus(at, marginMs)).changes > 0;
|
|
6125
6175
|
}),
|
|
6126
|
-
miss: (id, owner, note) => turn(() => missTx(id, owner, note)),
|
|
6176
|
+
miss: (id, owner, note) => turn(() => afterCommit(() => missTx(id, owner, note))),
|
|
6127
6177
|
// #1834: the drive's one snapshot — keys only, in the order runs became due.
|
|
6128
6178
|
dueKeys: (now, max) => turn(() => db
|
|
6129
6179
|
.prepare(`SELECT id, module_id, job FROM _substrat_job_runs
|
|
@@ -6151,8 +6201,8 @@ export class SqliteScopeHost {
|
|
|
6151
6201
|
ORDER BY id DESC LIMIT ?`)
|
|
6152
6202
|
.all(...params);
|
|
6153
6203
|
}),
|
|
6154
|
-
patch: (id, p, owner) => turn(() =>
|
|
6155
|
-
commitPass: (id, p, owner) => turn(() => commitPassTx(id, p, owner)),
|
|
6204
|
+
patch: (id, p, owner) => turn(() => afterCommit(() => patchTx(id, p, owner))),
|
|
6205
|
+
commitPass: (id, p, owner) => turn(() => afterCommit(() => commitPassTx(id, p, owner))),
|
|
6156
6206
|
// #2034: a step boundary renews the lease; a pass that lost it reads nothing.
|
|
6157
6207
|
beginStep: (runId, name, owner, leaseMs) => turn(() => {
|
|
6158
6208
|
if (renewRun.run(plus(now(), leaseMs), runId, owner).changes === 0)
|
|
@@ -6212,9 +6262,14 @@ export class SqliteScopeHost {
|
|
|
6212
6262
|
requeue: (ids) => rt.actor.enqueue(() => rt.db.transaction(() => requeueUnsupportedAttachmentText(spineSql(rt.db), ids, ulid, this.clock()))()),
|
|
6213
6263
|
}, this.attachmentExtractors),
|
|
6214
6264
|
};
|
|
6215
|
-
|
|
6216
|
-
|
|
6265
|
+
let ended = false;
|
|
6266
|
+
const report = await runDueJobRuns({
|
|
6267
|
+
store: this.jobStore(rt, () => {
|
|
6268
|
+
ended = true;
|
|
6269
|
+
}),
|
|
6217
6270
|
handlerFor: (run) => kernelJobFor(run, kernelJobs) ?? this.jobs.get(`${run.module_id}/${run.job}`),
|
|
6271
|
+
// D-85: a declared job's run with no handler here fails on its record instead of waiting forever.
|
|
6272
|
+
declared: (run) => this.declaredJobs.get(run.job)?.moduleId === run.module_id,
|
|
6218
6273
|
now: this.clock,
|
|
6219
6274
|
openScope: (run) => this.getSystemScope(run.module_id, tenantId, scopeId),
|
|
6220
6275
|
// #3443: the run's module's files, through the same gate `getSystemAttachments` opens.
|
|
@@ -6222,6 +6277,16 @@ export class SqliteScopeHost {
|
|
|
6222
6277
|
maxPasses: options?.maxPasses,
|
|
6223
6278
|
limit: options?.limit,
|
|
6224
6279
|
});
|
|
6280
|
+
// D-85: a run that ended wrote `job.run-ended`; it reaches this scope's consumers now, as a
|
|
6281
|
+
// settle's outcome event does.
|
|
6282
|
+
if (ended) {
|
|
6283
|
+
await rt.actor.enqueue(async () => {
|
|
6284
|
+
await this.dispatch(rt, null);
|
|
6285
|
+
await this.dispatchExecutors(rt, null);
|
|
6286
|
+
await this.handOffCommitted(rt);
|
|
6287
|
+
});
|
|
6288
|
+
}
|
|
6289
|
+
return report;
|
|
6225
6290
|
}
|
|
6226
6291
|
async jobRuns(tenantId, scopeId, filter) {
|
|
6227
6292
|
const rt = this.runtime(tenantId, scopeId);
|
|
@@ -6424,7 +6489,12 @@ export class SqliteScopeHost {
|
|
|
6424
6489
|
return;
|
|
6425
6490
|
this.handoffEnvironments.set(key, environment);
|
|
6426
6491
|
const options = mode
|
|
6427
|
-
? {
|
|
6492
|
+
? {
|
|
6493
|
+
mode: mode.mode,
|
|
6494
|
+
// A6 (#3472): the lake is the broker's, so each event is also owed the lake receiver.
|
|
6495
|
+
...(mode.mode === 'live' && mode.lake ? { lake: true } : {}),
|
|
6496
|
+
...(mode.startPending ? { start: { ...ids, after: mode.start } } : {}),
|
|
6497
|
+
}
|
|
6428
6498
|
: {};
|
|
6429
6499
|
/** #3474: the round now with the broker, so a throw reports what it tried. */
|
|
6430
6500
|
let inFlight = null;
|
|
@@ -6501,9 +6571,12 @@ export class SqliteScopeHost {
|
|
|
6501
6571
|
* is handed off, and a new comparison window starts there. Off stops the handoff. Only under
|
|
6502
6572
|
* `deliveryHandoff: 'by-mode'` does it decide what is handed off; it is recorded either way.
|
|
6503
6573
|
*/
|
|
6504
|
-
async applyDeliveryMode(tenantId, scopeId, mode
|
|
6574
|
+
async applyDeliveryMode(tenantId, scopeId, mode,
|
|
6575
|
+
/** A6 (#3472): the lake is the broker's for this scope (`DELIVERY_BROKER_LAKE`); kept only beside live. */
|
|
6576
|
+
lake) {
|
|
6505
6577
|
const key = `${tenantId}/${scopeId}`;
|
|
6506
6578
|
const rt = await this.openActiveScope(tenantId, scopeId);
|
|
6579
|
+
const owned = mode === 'live' && lake === true;
|
|
6507
6580
|
await rt.actor.enqueue(async () => {
|
|
6508
6581
|
const prior = this.deliveryModes.get(key);
|
|
6509
6582
|
if (mode === 'off') {
|
|
@@ -6512,6 +6585,7 @@ export class SqliteScopeHost {
|
|
|
6512
6585
|
}
|
|
6513
6586
|
if (prior) {
|
|
6514
6587
|
prior.mode = mode;
|
|
6588
|
+
prior.lake = owned;
|
|
6515
6589
|
return;
|
|
6516
6590
|
}
|
|
6517
6591
|
const newest = (sql) => rt.db.prepare(sql).get()?.id;
|
|
@@ -6527,7 +6601,7 @@ export class SqliteScopeHost {
|
|
|
6527
6601
|
...((known.event ?? '') > (seed.event ?? '') ? { event: known.event } : seed.event ? { event: seed.event } : {}),
|
|
6528
6602
|
...((known.intent ?? '') > (seed.intent ?? '') ? { intent: known.intent } : seed.intent ? { intent: seed.intent } : {}),
|
|
6529
6603
|
});
|
|
6530
|
-
this.deliveryModes.set(key, { mode, start: seed, startPending: true });
|
|
6604
|
+
this.deliveryModes.set(key, { mode, start: seed, startPending: true, lake: owned });
|
|
6531
6605
|
await this.handOffCommitted(rt);
|
|
6532
6606
|
});
|
|
6533
6607
|
}
|
|
@@ -6545,6 +6619,12 @@ export class SqliteScopeHost {
|
|
|
6545
6619
|
const q = intentStateQuery(id);
|
|
6546
6620
|
return intentStateOf(rt.db.prepare(q.sql).all(...q.params));
|
|
6547
6621
|
}
|
|
6622
|
+
/** A6 (#3472): whether one event is in the lake yet, for a broker's lake receiver. */
|
|
6623
|
+
async eventLakeState(tenantId, scopeId, id) {
|
|
6624
|
+
const rt = await this.openActiveScope(tenantId, scopeId);
|
|
6625
|
+
const q = eventLakeStateQuery(id);
|
|
6626
|
+
return eventLakeStateOf(rt.db.prepare(q.sql).all(...q.params));
|
|
6627
|
+
}
|
|
6548
6628
|
/**
|
|
6549
6629
|
* K-74: hand off again whatever a scope's earlier handoff left unacknowledged — the pure host's
|
|
6550
6630
|
* stand-in for the scope alarm that retries it on the Durable Object. Runs in the scope's actor.
|
|
@@ -9054,6 +9134,10 @@ export class SqliteScopeHost {
|
|
|
9054
9134
|
throw substratError('precondition_failed', 'scope erasure changed; reload the scope and retry');
|
|
9055
9135
|
}
|
|
9056
9136
|
const ack = bindAcknowledgement.parse(opts?.acknowledge ?? {});
|
|
9137
|
+
// #3638: what this bind acknowledges if the scope is a named environment's preview.
|
|
9138
|
+
const envAck = opts?.environmentAcknowledge === undefined
|
|
9139
|
+
? undefined
|
|
9140
|
+
: environmentServeAcknowledgement.parse(opts.environmentAcknowledge);
|
|
9057
9141
|
// #2347: a route moving in the same write is judged with it, as `bindingImpact` is.
|
|
9058
9142
|
const servingRef = opts?.servingRef;
|
|
9059
9143
|
// #2178 first: no acknowledgement passes it, so none should be asked for ahead of it.
|
|
@@ -9082,11 +9166,20 @@ export class SqliteScopeHost {
|
|
|
9082
9166
|
...(servingRef !== undefined ? { servingRef } : {}),
|
|
9083
9167
|
...(opts?.expectedVersionId !== undefined ? { expectedVersionId: opts.expectedVersionId } : {}),
|
|
9084
9168
|
...(opts?.expectedServing ? { expectedServing: opts.expectedServing } : {}),
|
|
9085
|
-
|
|
9169
|
+
// #3638: an environment's acknowledgement is recorded with this bind, as a serve's is with its record.
|
|
9170
|
+
...(ack.exportBreak || envAck ? { acknowledged: { ...ack, ...envAck } } : {}),
|
|
9086
9171
|
});
|
|
9172
|
+
// #3638 (D-83): a bind of a named environment's preview is judged against what that environment
|
|
9173
|
+
// serves, in the write that moves it, so a push carried onto it before its first own-script serve
|
|
9174
|
+
// is held to the checkpoints too.
|
|
9175
|
+
const judge = () => {
|
|
9176
|
+
const refusal = environmentBindRefusalIn(switchSqlOf(this.directory), tenantId, scopeId, versionId, envAck);
|
|
9177
|
+
if (refusal)
|
|
9178
|
+
throw refusal;
|
|
9179
|
+
};
|
|
9087
9180
|
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);
|
|
9181
|
+
? this.moveScopeRow('vertical_version_id = ?, vertical = ?', [versionId, v.verticalSlug], tenantId, scopeId, opts, audit, judge)
|
|
9182
|
+
: this.moveScopeRow('vertical_version_id = ?, vertical = ?, serving_ref = ?', [versionId, v.verticalSlug, servingRef], tenantId, scopeId, opts, audit, judge);
|
|
9090
9183
|
if (!moved) {
|
|
9091
9184
|
// The erasure and copy-move conditions keep their own refusal: only a moved binding or a
|
|
9092
9185
|
// moved serving version is the race a rebind's review answers.
|
|
@@ -11972,9 +12065,12 @@ export class SqliteScopeHost {
|
|
|
11972
12065
|
* claimed, and on its copy move still owning a live lease. The move's confirmation commits in
|
|
11973
12066
|
* the same transaction as the row. False when any condition failed and nothing was written.
|
|
11974
12067
|
*/
|
|
11975
|
-
moveScopeRow(set, setArgs, tenantId, scopeId, cond, audit
|
|
12068
|
+
moveScopeRow(set, setArgs, tenantId, scopeId, cond, audit,
|
|
12069
|
+
/** Judged first, in the write's own transaction: a throw refuses the move with nothing written. */
|
|
12070
|
+
judge) {
|
|
11976
12071
|
const now = new Date().toISOString();
|
|
11977
12072
|
return this.directoryWriteAndAudit(() => {
|
|
12073
|
+
judge?.();
|
|
11978
12074
|
const moved = this.directory.prepare(`UPDATE scopes SET ${set} WHERE scope_id = ?
|
|
11979
12075
|
${cond?.expectedVersionId === undefined ? '' : 'AND vertical_version_id IS ?'}
|
|
11980
12076
|
${cond?.expectedErasureEpoch === undefined ? '' : 'AND COALESCE(erasure_epoch, 0) = ? AND reap_claimed_at IS NULL'}
|
|
@@ -12847,6 +12943,20 @@ export class SqliteScopeHost {
|
|
|
12847
12943
|
}),
|
|
12848
12944
|
// Upload links: mint / revoke / list, written once in the kernel — the same four things
|
|
12849
12945
|
// `capabilities` is handed, and the same consumer-is-system-actor rule.
|
|
12946
|
+
// D-85: start or join a declared job's run, in this transaction, checked as the caller.
|
|
12947
|
+
jobs: createJobVerbs({
|
|
12948
|
+
sql: spineSql(rt.db),
|
|
12949
|
+
// #2993: only the jobs of the modules this scope's type runs; the drive keeps the whole map.
|
|
12950
|
+
jobs: this.scopeTypePlan.declared
|
|
12951
|
+
? new Map([...this.declaredJobs].filter(([, j]) => this.runsOn(rt.scopeId, j.moduleId)))
|
|
12952
|
+
: this.declaredJobs,
|
|
12953
|
+
check: (permission) => runCheck(permission),
|
|
12954
|
+
now: at,
|
|
12955
|
+
mintId: ulid,
|
|
12956
|
+
assertWrites: (verb) => assertImpersonationWrites(impersonation, verb),
|
|
12957
|
+
subject: overrideActor ? { kind: 'system', id: overrideActor.system } : subject,
|
|
12958
|
+
minted,
|
|
12959
|
+
}),
|
|
12850
12960
|
attachments: createAttachmentVerbs({
|
|
12851
12961
|
sql: spineSql(rt.db),
|
|
12852
12962
|
subject: overrideActor ? { kind: 'system', id: overrideActor.system } : subject,
|
|
@@ -13371,6 +13481,8 @@ export class SqliteScopeHost {
|
|
|
13371
13481
|
this.ensureColumn(db, '_substrat_job_runs', 'lease_began_at', 'lease_began_at TEXT');
|
|
13372
13482
|
// #2042 r3: consecutive admission misses. NULL = none, right for every run already there.
|
|
13373
13483
|
this.ensureColumn(db, '_substrat_job_runs', 'admission_misses', 'admission_misses INTEGER');
|
|
13484
|
+
// D-85: the declared job's definition version. NULL = a run of an undeclared job, or one before it.
|
|
13485
|
+
this.ensureColumn(db, '_substrat_job_runs', 'definition_version', 'definition_version INTEGER');
|
|
13374
13486
|
// #2009: the copy classification on a scope DB built before it (NULL reads as a copy; see
|
|
13375
13487
|
// `COPY_ORIGIN_DDL`).
|
|
13376
13488
|
this.ensureColumn(db, '_substrat_copy_origin', 'is_copy', 'is_copy INTEGER');
|