@substrat-run/adapter-cloudflare 0.179.0 → 0.183.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/host.d.ts +34 -18
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +83 -59
- package/dist/host.js.map +1 -1
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +95 -22
- package/dist/scope-do.js.map +1 -1
- package/package.json +12 -12
package/dist/scope-do.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-do.d.ts","sourceRoot":"","sources":["../src/scope-do.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"scope-do.d.ts","sourceRoot":"","sources":["../src/scope-do.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAwDL,KAAK,QAAQ,EAmBd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EA+DL,KAAK,mBAAmB,EASxB,KAAK,SAAS,EA2Bd,KAAK,kBAAkB,EAEvB,KAAK,gBAAgB,EA+HtB,MAAM,sBAAsB,CAAC;AAsD9B,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAwBL,kBAAkB,EAoFnB,MAAM,sBAAsB,CAAC;AA2B9B;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC;AAoFD,oFAAoF;AACpF,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAgB5E;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AASnE,iDAAiD;AACjD,KAAK,gBAAgB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAA;CAAE,CAAC;AAEvH;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;IACtH,YAAY,EAAE;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;IAClH,UAAU,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;IACvG,cAAc,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAClG,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AA0kBjG,kGAAkG;AAClG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAQxD;AAuPD;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AAmBtD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CAOxD;AAED,gHAAgH;AAChH,OAAO,EAAE,kBAAkB,EAAE,CAAC;AA2B9B,wBAAgB,aAAa,CAC3B,OAAO,EAAE,kBAAkB,EAAE,EAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACzD;;;;GAIG;AACH,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,mBAAmB,CAAA;CAAO,GAClD,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,UAAU,KAAK,aAAa,CAAC,UAAU,CAAC,CAkqR7E"}
|
package/dist/scope-do.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { REWIND_REFUSED } from './rewind-refusal.js';
|
|
2
2
|
import { SYSTEM_DOOR_MOVED } from './system-door.js';
|
|
3
3
|
import { DurableObject } from 'cloudflare:workers';
|
|
4
|
-
import { ATTACHMENT_ADDED, ATTACHMENT_REMOVED, CAPTURE_REFUSALS, attachmentRecord, domainEvent, domainEventInput, eventId, instant, objectRef, entityObjectRef, assertModuleEmittableType, assertKernelAuthoredType, toWireFailure, grantRefFromProof, principalId, principalBecomeCapabilityInput, scopeId as scopeIdOf, tenantId as tenantIdOf, platformRequestInput, platformRequestId, MAX_PENDING_PLATFORM_REQUESTS, MAX_PENDING_SWEEP_RUNS, SWEEP_RUNS_KIND, SCOPE_DUMP_PAGE_MAX_BYTES, SCOPE_TABLE_PAGE_MAX, SCOPE_QUERY_ROW_MAX, listLimitOf, pageOf, countedPageOf, requestFingerprint, substratError, errorCodeOf, assertReplayableDump, DUMP_OBJECTS_QUERY, dumpObjectsOf, replayDumpObjects, dumpObjectsAudit, REDRAIN_BATCH, } from '@substrat-run/contracts';
|
|
5
|
-
import { ulid, DO_SQL_LIMITS, unknownRoleError, createUlid, assertAllowed, ConnectionSealingKeyUnavailableError, noSealingKeyMessage, sealTo, assertReadOnlyQuery, entitlementDenial, platformRequestHistoryQuery, platformRequestOf, PLATFORM_REQUEST_COLUMNS, PLATFORM_REQUEST_REDACTION_SQL, platformRequestRedactionParams, platformRequestRedactionQuery, intentPayloadCarriesSubject, redactSubjectJobRuns, eraseSubjectFromModules, moduleErasurePlan, redactSubjectScopeText, assertRowLimit, assertRowOffset, 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_LEASE_EXPIRED_NOTE, JOB_STEP_RECORD_SQL, DELIVERY_ERROR_REDACTION_SQL, REDACTED_DELIVERY_NOTE, seatScopeTuple, delegatedRevokeSql, writeExplicitTupleIn, grantEntityShapeIn, topUpEntityGrantShapes, applyScopeRoleChange, changeScopeRole, revokeScopeRoles, scopeRoleHolders, assertModuleDeclared, noteDeclaredKeys, noteReservedKeys, SCOPE_SEATED_ROLES_SQL, inUnitRoleRefusal, loadedRoleSetRefusedRole, reservedRoleSetRefusedRole, reservedGrantRefusal, reservedRoleRefusal, reservedShapeRefusal, effectiveRoleGrantQuery, switchRecordedOff, switchSystemSchedules, peerGrantsStatus, systemGrantsStatus, systemScheduleState, systemSwitchedOff, OUTBOX_PRUNED_DDL, outboxSubscribersOf, pruneDrainedOutbox, denialListQuery, refusalListQuery, mapRefusalRow, denialSummaryQuery, denialTotalsQuery, DENIAL_WINDOW_QUERY, mapDenialRow, mapDenialSummaryBuckets, PermissionDenied, assertImpersonationAdmitted, assertImpersonationWrites, assertModuleEnqueueableKind, impersonationStampOf, createAtomic, NotSearchable, isSearchIndexTable, searchIndexPlans, NotListable, listIndexPlans, moduleMigrations, REGISTERED_MIGRATIONS, registeredMigrationsOf, MIGRATION_DIGEST_FENCE_DDL, MIGRATION_DIGEST_MARK_LEGACY, assertJournalDumpCoherent, assertMigrationSql, migrationDivergence, migrationFailedError, migrationSetDivergence, migrationSteps, planMigrations, listQuery, cursorOf, searchLimit, searchMatchExpression, searchQuery, ATTACHMENT_TEXT_DDL, ATTACHMENT_BYTES_SQL, ATTACHMENT_CONDEMNED_DDL, ATTACHMENT_SWEEP_LICENCE_DDL, ATTACHMENT_SWEEP_LICENCE_TABLE, WIRE_NONCE_DDL, WIRE_NONCE_FULL, claimWireNonceIn, isWireNonceTable, isWireNonceWrite, clearOrphanSweepLicence, condemnLicensedOrphanAttachments, consumeOrphanSweepLicence, licensedOrphanIds, recordOrphanSweepLicence, refuseUnlicensedOrphanSweep, refuseCondemnedAttachment, refuseCondemnedInDump, rowlessAttachmentIds, attachmentRecordOfRow, enqueueAttachmentText, reconcileAttachmentText, queueAttachmentTextBackfill, startAttachmentTextBackfill, recordAttachmentText, searchAttachments, IDEMPOTENCY_DDL, REFUSALS_TABLE_DDL, REFUSALS_INDEX, refusalInsert, refusalOf, markGuardRefusal, REFUSALS_REBUILD, refusalsAdmitGuards, assertIdempotencyKey, assertPermissionKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, 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, exportedSinceQuery, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, noteTransitionInto, withTransitions, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, JOB_RUN_DDL, JOB_RUN_DUE_AT, jobRunListLimit, SYSTEM_DOOR_WAIT, ancestorsWithin, } from '@substrat-run/kernel';
|
|
4
|
+
import { ATTACHMENT_ADDED, ATTACHMENT_REMOVED, CAPTURE_REFUSALS, attachmentRecord, domainEvent, domainEventInput, eventId, instant, objectRef, entityObjectRef, assertModuleEmittableType, assertKernelAuthoredType, toWireFailure, grantRefFromProof, principalId, principalBecomeCapabilityInput, principalBindLinkInput, scopeId as scopeIdOf, tenantId as tenantIdOf, platformRequestInput, platformRequestId, MAX_PENDING_PLATFORM_REQUESTS, MAX_PENDING_SWEEP_RUNS, SWEEP_RUNS_KIND, SCOPE_DUMP_PAGE_MAX_BYTES, SCOPE_TABLE_PAGE_MAX, SCOPE_QUERY_ROW_MAX, listLimitOf, pageOf, countedPageOf, requestFingerprint, substratError, errorCodeOf, assertReplayableDump, DUMP_OBJECTS_QUERY, dumpObjectsOf, replayDumpObjects, dumpObjectsAudit, REDRAIN_BATCH, } from '@substrat-run/contracts';
|
|
5
|
+
import { ulid, DO_SQL_LIMITS, unknownRoleError, createUlid, assertAllowed, ConnectionSealingKeyUnavailableError, noSealingKeyMessage, sealTo, assertReadOnlyQuery, entitlementDenial, platformRequestHistoryQuery, platformRequestOf, PLATFORM_REQUEST_COLUMNS, PLATFORM_REQUEST_REDACTION_SQL, platformRequestRedactionParams, platformRequestRedactionQuery, intentPayloadCarriesSubject, redactSubjectJobRuns, eraseSubjectFromModules, moduleErasurePlan, redactSubjectScopeText, assertRowLimit, assertRowOffset, 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_LEASE_EXPIRED_NOTE, JOB_STEP_RECORD_SQL, DELIVERY_ERROR_REDACTION_SQL, REDACTED_DELIVERY_NOTE, seatScopeTuple, delegatedRevokeSql, writeExplicitTupleIn, grantEntityShapeIn, topUpEntityGrantShapes, applyScopeRoleChange, changeScopeRole, revokeScopeRoles, scopeRoleHolders, assertModuleDeclared, noteDeclaredKeys, noteReservedKeys, SCOPE_SEATED_ROLES_SQL, inUnitRoleRefusal, loadedRoleSetRefusedRole, reservedRoleSetRefusedRole, reservedGrantRefusal, reservedRoleRefusal, reservedShapeRefusal, effectiveRoleGrantQuery, switchRecordedOff, switchSystemSchedules, peerGrantsStatus, systemGrantsStatus, systemScheduleState, systemSwitchedOff, OUTBOX_PRUNED_DDL, outboxSubscribersOf, pruneDrainedOutbox, denialListQuery, refusalListQuery, mapRefusalRow, denialSummaryQuery, denialTotalsQuery, DENIAL_WINDOW_QUERY, mapDenialRow, mapDenialSummaryBuckets, PermissionDenied, assertImpersonationAdmitted, assertImpersonationWrites, assertModuleEnqueueableKind, impersonationStampOf, createAtomic, NotSearchable, isSearchIndexTable, rowCountTable, searchIndexPlans, NotListable, listIndexPlans, moduleMigrations, REGISTERED_MIGRATIONS, registeredMigrationsOf, MIGRATION_DIGEST_FENCE_DDL, MIGRATION_DIGEST_MARK_LEGACY, assertJournalDumpCoherent, assertMigrationSql, migrationDivergence, migrationFailedError, migrationSetDivergence, migrationSteps, planMigrations, listQuery, cursorOf, searchLimit, searchMatchExpression, searchQuery, ATTACHMENT_TEXT_DDL, ATTACHMENT_BYTES_SQL, ATTACHMENT_CONDEMNED_DDL, ATTACHMENT_SWEEP_LICENCE_DDL, ATTACHMENT_SWEEP_LICENCE_TABLE, WIRE_NONCE_DDL, WIRE_NONCE_FULL, claimWireNonceIn, isWireNonceTable, isWireNonceWrite, clearOrphanSweepLicence, condemnLicensedOrphanAttachments, consumeOrphanSweepLicence, licensedOrphanIds, recordOrphanSweepLicence, refuseUnlicensedOrphanSweep, refuseCondemnedAttachment, refuseCondemnedInDump, rowlessAttachmentIds, attachmentRecordOfRow, enqueueAttachmentText, reconcileAttachmentText, queueAttachmentTextBackfill, startAttachmentTextBackfill, recordAttachmentText, searchAttachments, IDEMPOTENCY_DDL, REFUSALS_TABLE_DDL, REFUSALS_INDEX, refusalInsert, refusalOf, markGuardRefusal, REFUSALS_REBUILD, refusalsAdmitGuards, assertIdempotencyKey, assertPermissionKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, 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, exportedSinceQuery, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, noteTransitionInto, withTransitions, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, JOB_RUN_DDL, JOB_RUN_DUE_AT, jobRunListLimit, SYSTEM_DOOR_WAIT, ancestorsWithin, } from '@substrat-run/kernel';
|
|
6
6
|
import { isUpgradeRequest, readSubscription, LIVE_DECIDE_ATTEMPTS, LIVE_FANOUT_LIMIT, LIVE_PRINCIPAL_HEADER, LIVE_SCOPE_HEADER, LIVE_SUBSCRIBE_PATH, LIVE_TENANT_HEADER, LIVE_WITHIN_HEADER, LIVE_EXPIRES_HEADER, LIVE_CLOSE, LIVE_SOCKETS_PER_PRINCIPAL, decodeLiveWithin, liveInstant, liveRefusal, liveRefusalStatus, } from './live-reads.js';
|
|
7
7
|
import { replyOf } from './do-reply.js';
|
|
8
8
|
import { OperationQueue } from './serialization.js';
|
|
9
9
|
import { assertNoWorkerdStorage, doScopedSql, doBuiltColumnsOf, doRedactionSql, doSpineSql } from './sql.js';
|
|
10
|
-
import { actorOf, admitPeer, boundToPeerDeclarations, collectPeers, switchPeer, peerSubjectRef, subjectGrantState, assertNoSecret, CAPABILITY_DDL, UPLOAD_LINK_DDL, createAttachmentVerbs, inspectUploadLink, redeemUploadLinkInTransaction, COPY_ORIGIN_DDL, ENTITY_STATE_MOVES_DDL, SWITCH_FENCES_DDL, TABLE_OWNERS_DDL, assertMigrationLeavesLedgerAlone, recordOwnershipSteps, runMigrationStatements, splitSqlStatements, executableSqlStatements, blankSqlComments, CAPABILITY_EXCHANGE_OPERATION, CAPABILITY_BECOME_MINT_OPERATION, becomeMintCheck, mintBecomeCapabilityAsPrincipal, revokeBecomeCapabilityAsPrincipal, readBecomeLinkStates, ENTITY_UNBIND_OPERATION, allowedFor, unbindEntityHolderBounded, capabilityAttachmentWriteRefused, createCapabilityVerbs, createEntityEdgeVerbs, createEntityStateVerbs, createTrashedReads, CONTINUATION_POSITION_CAP, visibleContinuation, searchStateWhere, uncheckedView, addStatePlans, addUpdatedStampPlans, watchUpdatedStamps, assertNoCallerPurge, isUnreachableParent, PURGE_BATCH, heldPurgePass, lifecycleRefusal, purgeHeldBy, assertPlatformRequestRoom, purgeDueOf, purgeOnlyKeysOf, runPurgePass, refuseTrashedTarget, assertBoundOperations, checkHeldOperationsOf, countChecks, noteUncheckedCompletion, registerTrashTargets, withheldKeysFor, statefulTablesOf, afterMigration, afterRuntimeDdl, derivesAnything, repairDerivedObjects, StateColumnLost, exchangeCapability, guardSecrets, mintBecomeCapability, redactSecrets, redactSecretText, moduleLog, asyncInvocationId, asyncLinePass, resolveCapabilitySession, revokeCapabilityAsPlatform, readCapabilityPage, domainEventOf, facetEvents, readDeadLetters, readLifecycleFlow, readOperationSeries, readHistory, readInvocation, readUndrainedOutbox, walkEventCause, walkEventEffects, } from '@substrat-run/kernel';
|
|
10
|
+
import { actorOf, admitPeer, boundToPeerDeclarations, collectPeers, switchPeer, peerSubjectRef, subjectGrantState, assertNoSecret, CAPABILITY_DDL, UPLOAD_LINK_DDL, createAttachmentVerbs, inspectUploadLink, redeemUploadLinkInTransaction, COPY_ORIGIN_DDL, ENTITY_STATE_MOVES_DDL, SWITCH_FENCES_DDL, TABLE_OWNERS_DDL, assertMigrationLeavesLedgerAlone, recordOwnershipSteps, runMigrationStatements, splitSqlStatements, executableSqlStatements, blankSqlComments, CAPABILITY_EXCHANGE_OPERATION, CAPABILITY_BECOME_MINT_OPERATION, becomeMintCheck, mintBecomeCapabilityAsPrincipal, CAPABILITY_BIND_MINT_OPERATION, bindLinkMintCheck, mintBindLinkAsPrincipal, revokeBecomeCapabilityAsPrincipal, readBecomeLinkStates, ENTITY_UNBIND_OPERATION, allowedFor, unbindEntityHolderBounded, capabilityAttachmentWriteRefused, createCapabilityVerbs, createEntityEdgeVerbs, createEntityStateVerbs, createTrashedReads, CONTINUATION_POSITION_CAP, visibleContinuation, searchStateWhere, uncheckedView, addStatePlans, addUpdatedStampPlans, watchUpdatedStamps, assertNoCallerPurge, isUnreachableParent, PURGE_BATCH, heldPurgePass, lifecycleRefusal, purgeHeldBy, assertPlatformRequestRoom, purgeDueOf, purgeOnlyKeysOf, runPurgePass, refuseTrashedTarget, assertBoundOperations, checkHeldOperationsOf, countChecks, noteUncheckedCompletion, registerTrashTargets, withheldKeysFor, statefulTablesOf, afterMigration, afterRuntimeDdl, derivesAnything, repairDerivedObjects, StateColumnLost, exchangeCapability, guardSecrets, mintBecomeCapability, redactSecrets, redactSecretText, moduleLog, asyncInvocationId, asyncLinePass, resolveCapabilitySession, revokeCapabilityAsPlatform, readCapabilityPage, domainEventOf, facetEvents, readDeadLetters, readLifecycleFlow, readOperationSeries, readHistory, readInvocation, readUndrainedOutbox, walkEventCause, walkEventEffects, } from '@substrat-run/kernel';
|
|
11
11
|
import { COPY_RESTORE_FENCE_LAPSED, copyRestoreFenceLapsed, orphanSweepVersionRefusal } from '@substrat-run/kernel';
|
|
12
12
|
import { createDoTupleChecker, createLocalControlPlaneReader, scopeTupleReader } from './checker.js';
|
|
13
13
|
import { settlePlatformRequestIn } from '@substrat-run/kernel';
|
|
@@ -1523,6 +1523,27 @@ options = {}) {
|
|
|
1523
1523
|
const { verdict } = this.tenantVerdict(tenantId);
|
|
1524
1524
|
return verdict === 'recorded' || verdict === 'inferred';
|
|
1525
1525
|
}
|
|
1526
|
+
/**
|
|
1527
|
+
* #2035: whether the ownerless reconcile may seat this scope for `tenantId` — it serves it, or
|
|
1528
|
+
* the platform's word may record it where a lifecycle delivery's would (`backfills`). False for a
|
|
1529
|
+
* foreign scope and for a DO nothing provisioned or loaded here. Read only, without migrating:
|
|
1530
|
+
* the receipt is written by `seatTuplesFor`, which judges this rule again in the unit that
|
|
1531
|
+
* applies the seat and the recorded-off positions, so no door admits the scope before they
|
|
1532
|
+
* hold, and a failed seat records nothing.
|
|
1533
|
+
*/
|
|
1534
|
+
seatsTenant(tenantId) {
|
|
1535
|
+
const { verdict } = this.tenantVerdict(tenantId);
|
|
1536
|
+
return verdict === 'recorded' || this.backfills(verdict);
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* #2016: whether the platform's word may record the tenant on a scope with no receipt — one
|
|
1540
|
+
* provisioned before the receipt (its role rows agree), or one whose tenant nothing recorded
|
|
1541
|
+
* although it holds data (a load from a world that keeps its roles elsewhere). A DO never
|
|
1542
|
+
* provisioned here records nothing, or `servesTenant` would answer for a scope it does not hold.
|
|
1543
|
+
*/
|
|
1544
|
+
backfills(verdict) {
|
|
1545
|
+
return verdict === 'inferred' || (verdict === 'unknown' && this.holdsData());
|
|
1546
|
+
}
|
|
1526
1547
|
/**
|
|
1527
1548
|
* #2541: this scope's database size, or null when the deployment does not hold it. The held
|
|
1528
1549
|
* check and the read are ONE call: a reap or wipe cannot land between them, so a scope that
|
|
@@ -1613,8 +1634,8 @@ options = {}) {
|
|
|
1613
1634
|
/**
|
|
1614
1635
|
* #2016: what one door into this scope needs from its storage on a CP-less host, in ONE call —
|
|
1615
1636
|
* how `tenantId` reads against the scope (`tenantVerdict`), and the lifecycle the platform
|
|
1616
|
-
* delivered (#1713). The coordinator refuses a foreign pair before any guard,
|
|
1617
|
-
* lookup runs, and
|
|
1637
|
+
* delivered (#1713). The coordinator refuses a foreign or an `unknown` pair before any guard,
|
|
1638
|
+
* handler or store lookup runs, and logs the `unknown` refusal (#2035). Read without migrating, like
|
|
1618
1639
|
* `servesTenant`.
|
|
1619
1640
|
*/
|
|
1620
1641
|
admission(tenantId) {
|
|
@@ -2062,13 +2083,36 @@ options = {}) {
|
|
|
2062
2083
|
* and the re-assert in which a sweep could run the grants just seated.
|
|
2063
2084
|
*/
|
|
2064
2085
|
async seatTuples(tuples, switchOff) {
|
|
2065
|
-
return this.queue.enqueue(() => this.revision.transactionSync(() =>
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2086
|
+
return this.queue.enqueue(() => this.revision.transactionSync(() => this.seatIn(tuples, switchOff)));
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* #2035: the ownerless reconcile's seat — `seatTuples`' unit, with the tenant recorded LAST in
|
|
2090
|
+
* it. The receipt opens every door, so it lands with the seat and the recorded-off positions or
|
|
2091
|
+
* not at all. `seatsTenant`'s rule is judged again before the unit's first write (the seat's
|
|
2092
|
+
* own tuples would read as state), against what holds now: a scope reaped or recorded for
|
|
2093
|
+
* another tenant since the host asked is refused untouched, as data, so the host answers K-3's
|
|
2094
|
+
* uniform refusal and no other tenant is named.
|
|
2095
|
+
*/
|
|
2096
|
+
async seatTuplesFor(tenantId, tuples, switchOff) {
|
|
2097
|
+
return this.queue.enqueue(async () => {
|
|
2098
|
+
// Read before the unit, as `projectInUnit` reads it.
|
|
2099
|
+
const reaped = await this.isReaped();
|
|
2100
|
+
return this.revision.transactionSync(() => {
|
|
2101
|
+
if (reaped || !this.seatsTenant(tenantId))
|
|
2102
|
+
return { refused: 'tenant' };
|
|
2103
|
+
const switchedOff = this.seatIn(tuples, switchOff);
|
|
2104
|
+
this.sql.exec(`INSERT OR IGNORE INTO _substrat_meta (key, value) VALUES (?, ?)`, PROVISIONED_FOR_KEY, tenantId);
|
|
2105
|
+
return { switchedOff };
|
|
2106
|
+
});
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
/** The seat and the recorded-off positions, in the caller's unit. */
|
|
2110
|
+
seatIn(tuples, switchOff) {
|
|
2111
|
+
for (const t of tuples) {
|
|
2112
|
+
const seat = seatScopeTuple(t.subject, t.relation, t.object, t.expires_at);
|
|
2113
|
+
this.sql.exec(seat.sql, ...seat.params);
|
|
2114
|
+
}
|
|
2115
|
+
return switchOff ? switchRecordedOff(this.switchSql(), switchOff) : [];
|
|
2072
2116
|
}
|
|
2073
2117
|
/** A declared entity-grant shape's grant to one person on one entity (#2071), as ONE unit. */
|
|
2074
2118
|
async grantEntityShape(principal, entity, permissions) {
|
|
@@ -4334,7 +4378,9 @@ options = {}) {
|
|
|
4334
4378
|
* The secret itself reaches this DO — it must, to be hashed and looked up — and goes
|
|
4335
4379
|
* no further: nothing here stores or returns it.
|
|
4336
4380
|
*/
|
|
4337
|
-
async exchangeCapability(secret, tenantId, scopeId, mode
|
|
4381
|
+
async exchangeCapability(secret, tenantId, scopeId, mode,
|
|
4382
|
+
/** #2817: a `bind` link's presenter, as the caller's own authentication resolved it. */
|
|
4383
|
+
presenter) {
|
|
4338
4384
|
await this.ensureMigrations();
|
|
4339
4385
|
return await this.queue.enqueue(async () => {
|
|
4340
4386
|
const liveSince = this.liveHighWaterMark();
|
|
@@ -4354,7 +4400,7 @@ options = {}) {
|
|
|
4354
4400
|
? (principal) => this.checker.holdings({ kind: 'principal', id: principal }, { tenantId, scopeId })
|
|
4355
4401
|
: undefined,
|
|
4356
4402
|
allowed: (principal, permission, entity) => allowedFor(this.checker, principal, { tenantId, scopeId })(permission, entity),
|
|
4357
|
-
}, secret, mode);
|
|
4403
|
+
}, secret, mode, presenter === undefined ? undefined : principalId.parse(presenter));
|
|
4358
4404
|
});
|
|
4359
4405
|
if (outcome)
|
|
4360
4406
|
await this.settleCommitted(tenantId, scopeId, liveSince, null);
|
|
@@ -4389,6 +4435,33 @@ options = {}) {
|
|
|
4389
4435
|
return { ok: true, minted: minted };
|
|
4390
4436
|
});
|
|
4391
4437
|
}
|
|
4438
|
+
/**
|
|
4439
|
+
* A principal's `bind` link mint (#2817) — binding an existing member to a record. The kernel's
|
|
4440
|
+
* `bindLinkMintCheck` and the write in ONE queued body and one storage transaction; a refusal
|
|
4441
|
+
* writes nothing. On the spine as `capability.bind-minted` on the record, the caller its actor.
|
|
4442
|
+
*/
|
|
4443
|
+
async mintBindLinkBoundedFor(tenantId, scopeId, caller, input) {
|
|
4444
|
+
await this.ensureMigrations();
|
|
4445
|
+
const minter = principalId.parse(caller);
|
|
4446
|
+
const parsed = principalBindLinkInput.parse(input);
|
|
4447
|
+
return await this.queue.enqueue(async () => {
|
|
4448
|
+
const checked = await bindLinkMintCheck({ sql: doSpineSql(this.sql), checker: this.checker }, minter, parsed.principal, { tenantId, scopeId }, parsed.entity);
|
|
4449
|
+
if (!checked.ok)
|
|
4450
|
+
return checked;
|
|
4451
|
+
const liveSince = this.liveHighWaterMark();
|
|
4452
|
+
const now = instant.parse(new Date().toISOString());
|
|
4453
|
+
let minted;
|
|
4454
|
+
await this.revision.transaction(async () => {
|
|
4455
|
+
minted = await mintBindLinkAsPrincipal({
|
|
4456
|
+
sql: doSpineSql(this.sql),
|
|
4457
|
+
now,
|
|
4458
|
+
emit: (event) => kernelEmit(this.operationContext(minter, tenantId, scopeId, undefined, undefined, undefined, undefined, undefined, CAPABILITY_BIND_MINT_OPERATION, undefined, [], now), event),
|
|
4459
|
+
}, minter, parsed);
|
|
4460
|
+
});
|
|
4461
|
+
await this.settleCommitted(tenantId, scopeId, liveSince, null);
|
|
4462
|
+
return { ok: true, minted: minted };
|
|
4463
|
+
});
|
|
4464
|
+
}
|
|
4392
4465
|
/**
|
|
4393
4466
|
* Unbind a binding shape's record (#1686) — its column cleared and the shape its person held
|
|
4394
4467
|
* there through it taken back — as `caller`, who must hold the binding's key on the record. The
|
|
@@ -4527,10 +4600,11 @@ options = {}) {
|
|
|
4527
4600
|
/**
|
|
4528
4601
|
* #119: the purge gate's facts (`PurgeGateFacts`), from this scope's own storage: the module's
|
|
4529
4602
|
* switch, the lifecycle the platform delivered (#1713), the copy classification (#2009) and the
|
|
4530
|
-
* tenant receipt (`tenantVerdict` — `
|
|
4603
|
+
* tenant receipt (`tenantVerdict` — only `foreign` is refused here). A directory-backed
|
|
4531
4604
|
* deployment records no receipt and delivers neither a lifecycle nor a copy classification here,
|
|
4532
|
-
* so on one those read clear: this object enforces the kill
|
|
4533
|
-
* is the authority for tenant, lifecycle, copy and the rewind
|
|
4605
|
+
* so on one those read clear and `unknown` is its every scope: this object enforces the kill
|
|
4606
|
+
* switch, and the coordinator's gate is the authority for tenant, lifecycle, copy and the rewind
|
|
4607
|
+
* hold. On a CP-less host that gate has already refused an `unknown` pair at the door (#2035).
|
|
4534
4608
|
*/
|
|
4535
4609
|
purgeGateFacts(moduleId, tenantId) {
|
|
4536
4610
|
const now = new Date().toISOString();
|
|
@@ -5097,10 +5171,8 @@ options = {}) {
|
|
|
5097
5171
|
if (verdict === 'foreign') {
|
|
5098
5172
|
return { refused: 'tenant', message: `lifecycle delivery ${foreignTenant(held, tenantId)}` };
|
|
5099
5173
|
}
|
|
5100
|
-
// The back-fill:
|
|
5101
|
-
|
|
5102
|
-
// elsewhere). The directory's word records it; a DO never provisioned here records nothing.
|
|
5103
|
-
const backfill = verdict === 'inferred' || (verdict === 'unknown' && this.holdsData());
|
|
5174
|
+
// The back-fill (`backfills`): the directory's word records the tenant.
|
|
5175
|
+
const backfill = verdict !== null && this.backfills(verdict);
|
|
5104
5176
|
let out;
|
|
5105
5177
|
this.revision.transactionSync(() => {
|
|
5106
5178
|
// A write the carry fences on, not bookkeeping: it happens once per legacy scope, and
|
|
@@ -5398,10 +5470,11 @@ options = {}) {
|
|
|
5398
5470
|
const names = this.sql
|
|
5399
5471
|
.exec(`SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT GLOB '_cf_*' ORDER BY name`)
|
|
5400
5472
|
.toArray().map((r) => r.name);
|
|
5473
|
+
const known = new Set(names);
|
|
5401
5474
|
const count = (sql) => Number(this.sql.exec(sql).toArray()[0].c);
|
|
5402
5475
|
return names.map((name) => ({
|
|
5403
5476
|
name,
|
|
5404
|
-
rowCount: count(`SELECT COUNT(*) AS c FROM "${name}"`),
|
|
5477
|
+
rowCount: count(`SELECT COUNT(*) AS c FROM "${rowCountTable(name, known)}"`),
|
|
5405
5478
|
system: isSystemTable(name),
|
|
5406
5479
|
// #2531: rows whose `revoked_at` is null, for any table with that column (`ScopeTable.liveRowCount`).
|
|
5407
5480
|
// Scope health reads it for `_substrat_roles`, where a dropped role is kept revoked.
|