@substrat-run/adapter-sqlite 0.127.0 → 0.129.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/index.d.ts CHANGED
@@ -5,6 +5,16 @@ import { type ModuleLogSink, type FreshnessReport, type FreshnessRegistration, t
5
5
  * The #1764 backfill logs and opens past a failed batch, but never past one of these.
6
6
  */
7
7
  export declare function isStorageFault(err: unknown): boolean;
8
+ /**
9
+ * The spine tables a Durable Object's scope builds and this adapter's scope does not (#1883):
10
+ * the roles, tenant-level tuples, entitlements, identity links and connection keys a node
11
+ * scope keeps in its DIRECTORY, and the DO's own `_substrat_meta` and PITR bookmarks. A DO's
12
+ * dump restored here skips them rather than refusing: every one is a projection the directory
13
+ * already holds, or a record only a DO has a use for. Any OTHER spine table this kernel does
14
+ * not build is still refused. The list is the difference between the two `KERNEL_DDL`s, and
15
+ * `pnpm lint:spine-ddl` holds it to that, so a table added on one side cannot slip past.
16
+ */
17
+ export declare const DO_SCOPE_ONLY_SPINE_TABLES: ReadonlySet<string>;
8
18
  export interface SqliteScopeHostOptions {
9
19
  /** Directory holding one SQLite file per scope plus the directory database. */
10
20
  dir: string;
@@ -194,12 +204,19 @@ export declare class SqliteScopeHost implements ScopeHost {
194
204
  * recorded answer to #969; `docs/architecture/kernel-design.md` §8 says why.
195
205
  */
196
206
  private applyDirectorySchema;
207
+ /**
208
+ * The directory's tables as this code builds them, carrying whatever the directory already
209
+ * holds forward to that shape: a cold start's pass, and a restore's (#1898), which runs it
210
+ * after replaying the dump's non-spine tables and before loading any row.
211
+ */
212
+ private buildDirectorySchema;
197
213
  /**
198
214
  * `applyDirectorySchema`, plus the backfill of the schedule switch's record (#1674) from
199
215
  * the admin log. Whether the table exists is asked BEFORE the DDL creates it, so the
200
216
  * backfill runs only on an application that creates the table: once on a directory that
201
- * never had it, and again after a directory restore whose dump predates it (from that
202
- * dump's own log). A directory that already holds the table is never backfilled over.
217
+ * never had it. A directory that already holds the table is never backfilled over. (A
218
+ * restore whose dump predates the table builds it and backfills it inside its own
219
+ * transaction, #1898, so this pass finds it there.)
203
220
  *
204
221
  * One transaction (Copilot review, #1674): the table and its backfill commit together, so
205
222
  * a backfill that fails leaves no table behind, and the next start tries again rather than
@@ -616,8 +633,10 @@ export declare class SqliteScopeHost implements ScopeHost {
616
633
  *
617
634
  * `db.transaction` nests as a SAVEPOINT, as `ensureScheduleStateKind` (#1571) relies
618
635
  * on. Each script leads with `DROP TABLE IF EXISTS <table>_new` to absorb a scratch
619
- * table arriving from BELOW the transaction (a torn copy of the file, a backup that
620
- * captured one mid-rebuild) — belt, not the fix.
636
+ * table arriving from BELOW the transaction (a torn copy of the file) — belt, not the
637
+ * fix. A restore no longer brings one: since #1898 a dump's `_substrat_*_new` is an unbuilt
638
+ * spine table, and refused, and since this rebuild became atomic a consistent dump cannot
639
+ * capture one.
621
640
  */
622
641
  private rebuildAtomically;
623
642
  /**
@@ -745,10 +764,10 @@ export declare class SqliteScopeHost implements ScopeHost {
745
764
  /**
746
765
  * The additive spine-column migrations, shared by `runtime()` and the dump replay.
747
766
  * KERNEL_DDL is all IF NOT EXISTS, so a scope DB created before a column keeps the
748
- * old shape — and so does a table a DUMP replay just recreated from legacy DDL,
749
- * which is why `loadDump` re-runs this after its replay: `runtime()` already ran
750
- * for that scope, and without the re-run the very next emit in this process fails
751
- * with `no such column`.
767
+ * old shape until this runs on its next wake. `loadDump` runs it too, after rebuilding
768
+ * the spine from KERNEL_DDL: there it adds no column, since a restore never brings a
769
+ * legacy spine table (#1883), but it also creates `_substrat_outbox_invocation`, which
770
+ * KERNEL_DDL deliberately does not and the restore's DROP of the outbox took with it.
752
771
  */
753
772
  private ensureSpineColumns;
754
773
  private runtime;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAeL,KAAK,eAAe,EAcpB,KAAK,WAAW,EAEhB,KAAK,YAAY,EAu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AejB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;YAyfV,sBAAsB;IAyDpC;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAyB5B;;;;;OAKG;IACH;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,UAAU;IAKlB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,cAAc;IAKtB;;;;;OAKG;IACH,OAAO,CAAC,MAAM;IAuBd;;;OAGG;IACH,OAAO,CAAC,YAAY;IAUpB;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IA4E1B,OAAO,CAAC,OAAO;CA6ChB"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
3
  import Database from 'better-sqlite3';
4
- import { accessLogEntry, adminLogEntry, delegatedReadParams, opsFailureEntry, opsFailureFingerprint, issueEntry, FRESHNESS_HEARTBEAT_MINUTES, sweepRunEntry, modelUsageEntry, ATTACHMENT_ADDED, ATTACHMENT_REMOVED, attachmentRecord, createTenantInput, domainEvent, domainEventInput, exportReadInput, importBatch, importCursorMove, exportsOfManifestJson, importsOfManifestJson, entitlementGrant, entitlementGrantInput, eventId, meterReading, platformRequestInput, platformRequestId, MAX_PENDING_PLATFORM_REQUESTS, identityLink, identityPool, instant, connection, capabilityGrant, connectionGrant, connectionGrantRecord, connectionSecret, systemGrant, systemSwitch, systemSwitchRecord, peerSwitch, verticalCaller, verticalSlug as verticalSlugOf, subjectRef, requestFingerprint, createConnectionInput, projectedConnectionGrant, projectedConnectionKey, moduleManifest, createOrgInput, promotionAcknowledgement, bindAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding, publishVersionInput, AUTO_ADMISSION_NOTE, routeTarget, 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, subjectShredReceipt, SCOPE_TABLE_PAGE_DEFAULT, SCOPE_TABLE_PAGE_MAX, SCOPE_QUERY_ROW_MAX, verticalServingState, callsOfManifestJson, outboundOfManifestJson, listLimitOf, substratError, assertReplayableDump, delegatedReadRecord, redrainEventsInput, REDRAIN_BATCH, } from '@substrat-run/contracts';
5
- import { actorOf, asPrincipal, assertAllowed, assertNoSecret, assertPermissionKey, CAPABILITY_DDL, CAPABILITY_EXCHANGE_OPERATION, capabilityAttachmentWriteRefused, capabilityTokenHash, createCapabilityVerbs, createEntityEdgeVerbs, exchangeCapability as exchangeCapabilitySecret, guardSecrets, mintBecomeCapability, plausibleSessionToken, redactSecrets, redactSecretText, moduleLog, consoleLogSink, resolveCapabilitySession, revokeCapabilityAsPlatform, assertReadOnlyQuery, attachmentBlobKey, entitlementDenial, foldMeterReading, guardSpine, guardSqlLimits, DO_SQL_LIMITS, tooManyResultColumns, tooManyTableColumns, parseValidationRecords, resolveScopeRecord, ulid, ISSUE_RETENTION_DAYS, OPS_FAILURE_RETENTION_DAYS, SWEEP_RUN_RETENTION_DAYS, SWEEP_RUNS_INTENT_INDEX, sweepRunsIntentHasKind, MODEL_USAGE_RETENTION_DAYS, foldModelUsage, backoffAt, platformRequestHistoryQuery, platformRequestOf, PLATFORM_REQUEST_COLUMNS, PLATFORM_REQUEST_REDACTION_SQL, platformRequestRedactionParams, platformRequestRedactionQuery, intentPayloadCarriesSubject, redactSubjectJobRuns, JOB_RUN_PATCH_SQL, JOB_STEP_RECORD_SQL, DELIVERY_ERROR_REDACTION_SQL, REDACTED_DELIVERY_NOTE, seatScopeTuple, switchSystemSchedules, admitPeer, collectPeers, peerSeats, resolveVerticalInstanceFrom, switchPeer, peerGrantsStatus, systemGrantsStatus, systemScheduleState, systemSwitchedOff, systemSwitchedOffMessage, tenantSystemSwitchedOffMessage, SYSTEM_SWITCHES_BACKFILL_SQL, SYSTEM_SWITCHES_DDL, forgetSystemSwitchesOf, listSystemSwitchRecords, recordSystemSwitchedOff, recordSystemSwitchedOn, restoreSystemSwitchRecord, scopesSwitchedOffFor, switchedOffModulesOf, inUnitMovesToAudit, staleCarryRevertRow, staleCarryReverts, systemSwitchRecordsOf, systemSwitchesTableExists, withRecorded, VERSION_MIGRATIONS_DDL, splitManifestMigrations, splitVersionMigrationsBatch, versionMigrationsOf, writeVersionMigrations, denialListQuery, denialSummaryQuery, denialTotalsQuery, DENIAL_WINDOW_QUERY, mapDenialRow, mapDenialSummaryBuckets, IMPERSONATION_COLUMNS, IMPERSONATION_DDL, ImpersonationRefused, assertImpersonationWrites, assertModuleEnqueueableKind, assertSessionUsable, impersonationByIdQuery, impersonationListQuery, impersonationRowValues, impersonationStampOf, mapImpersonationRow, newImpersonationSession, resolveRetryPolicy, isSecretBoxConfigured, unconfiguredSecretBox, createSubjectKeys, generateSealingKeyPair, noSealingKeyMessage, openSealed, sealTo, ConnectionSealingKeyUnavailableError, PermissionDenied, createAtomic, NotSearchable, NotListable, listIndexMigrations, listIndexPlans, listQuery, cursorOf, moduleMigrations, isSearchIndexTable, searchIndexDdl, searchIndexMigrations, searchIndexPlans, searchLimit, searchMatchExpression, searchQuery, entityVersionQuery, entityVersionOf, assertIfMatch, OUTBOX_ENTITY_INDEX, SCHEDULE_STATE_DDL, SCHEDULE_STATE_REBUILD, scheduleStateHasKind, VERTICAL_EVENTS_DDL, EXPORT_HOPS_SQL, IMPORT_CURSORS_SQL, IMPORT_CURSOR_OF_SQL, OUTBOX_MARK_SQL, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, exportedSinceQuery, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, importCursorSourceOf, exportBreaksOf, exportBreakRefusal, bindExportBreaksOf, bindExportBreakRefusal, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, JOB_RUN_DDL, jobRunListLimit, jobRunOf, runDueJobRuns, startJobRun, IDEMPOTENCY_DDL, assertIdempotencyKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, globalFetch, createUlid, facetEvents, readHistory, walkEventCause, walkEventEffects, assertRedrainWindow, readInvocation, readDeadLetters, domainEventOf, readUndrainedOutbox, undrainedEventsOf, connectorCallRecord, noopConnectorCallRecorder, recordConnectorCall, settleConnectionUse, } from '@substrat-run/kernel';
6
- import { repointScopeGrants } from '@substrat-run/kernel';
4
+ import { accessLogEntry, adminLogEntry, delegatedReadParams, opsFailureEntry, opsFailureFingerprint, issueEntry, FRESHNESS_HEARTBEAT_MINUTES, sweepRunEntry, modelUsageEntry, ATTACHMENT_ADDED, ATTACHMENT_REMOVED, attachmentRecord, createTenantInput, domainEvent, domainEventInput, exportReadInput, importBatch, importCursorMove, exportsOfManifestJson, importsOfManifestJson, entitlementGrant, entitlementGrantInput, eventId, meterReading, platformRequestInput, platformRequestId, MAX_PENDING_PLATFORM_REQUESTS, identityLink, identityPool, instant, connection, capabilityGrant, connectionGrant, connectionGrantRecord, connectionSecret, systemGrant, systemSwitch, systemSwitchRecord, peerSwitch, verticalCaller, verticalSlug as verticalSlugOf, subjectRef, requestFingerprint, createConnectionInput, projectedConnectionGrant, projectedConnectionKey, moduleManifest, createOrgInput, promotionAcknowledgement, bindAcknowledgement, bindHostnameInput, channelHistoryEntry, hostnameBinding, publishVersionInput, AUTO_ADMISSION_NOTE, routeTarget, 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, subjectShredReceipt, SCOPE_TABLE_PAGE_DEFAULT, SCOPE_TABLE_PAGE_MAX, SCOPE_QUERY_ROW_MAX, verticalServingState, callsOfManifestJson, outboundOfManifestJson, listLimitOf, substratError, assertReplayableDump, namesSpineTable, delegatedReadRecord, ownerTransferAudit, redrainEventsInput, REDRAIN_BATCH, } from '@substrat-run/contracts';
5
+ import { actorOf, asPrincipal, assertAllowed, assertNoSecret, assertPermissionKey, CAPABILITY_DDL, CAPABILITY_EXCHANGE_OPERATION, capabilityAttachmentWriteRefused, capabilityTokenHash, createCapabilityVerbs, createEntityEdgeVerbs, exchangeCapability as exchangeCapabilitySecret, guardSecrets, mintBecomeCapability, plausibleSessionToken, redactSecrets, redactSecretText, moduleLog, consoleLogSink, resolveCapabilitySession, revokeCapabilityAsPlatform, assertReadOnlyQuery, attachmentBlobKey, entitlementDenial, foldMeterReading, guardSpine, guardSqlLimits, DO_SQL_LIMITS, tooManyResultColumns, tooManyTableColumns, parseValidationRecords, resolveScopeRecord, ulid, ISSUE_RETENTION_DAYS, OPS_FAILURE_RETENTION_DAYS, SWEEP_RUN_RETENTION_DAYS, SWEEP_RUNS_INTENT_INDEX, sweepRunsIntentHasKind, MODEL_USAGE_RETENTION_DAYS, foldModelUsage, backoffAt, platformRequestHistoryQuery, platformRequestOf, PLATFORM_REQUEST_COLUMNS, PLATFORM_REQUEST_REDACTION_SQL, platformRequestRedactionParams, platformRequestRedactionQuery, intentPayloadCarriesSubject, redactSubjectJobRuns, JOB_RUN_PATCH_SQL, JOB_STEP_RECORD_SQL, DELIVERY_ERROR_REDACTION_SQL, REDACTED_DELIVERY_NOTE, seatScopeTuple, switchSystemSchedules, admitPeer, collectPeers, peerSeats, resolveVerticalInstanceFrom, switchPeer, peerGrantsStatus, systemGrantsStatus, systemScheduleState, systemSwitchedOff, systemSwitchedOffMessage, tenantSystemSwitchedOffMessage, SYSTEM_SWITCHES_BACKFILL_SQL, dumpCarriesSystemSwitches, SYSTEM_SWITCHES_DDL, forgetSystemSwitchesOf, listSystemSwitchRecords, recordSystemSwitchedOff, recordSystemSwitchedOn, restoreSystemSwitchRecord, scopesSwitchedOffFor, switchedOffModulesOf, inUnitMovesToAudit, staleCarryRevertRow, staleCarryReverts, systemSwitchRecordsOf, systemSwitchesTableExists, withRecorded, VERSION_MIGRATIONS_DDL, splitManifestMigrations, splitVersionMigrationsBatch, versionMigrationsOf, writeVersionMigrations, denialListQuery, denialSummaryQuery, denialTotalsQuery, DENIAL_WINDOW_QUERY, mapDenialRow, mapDenialSummaryBuckets, IMPERSONATION_COLUMNS, IMPERSONATION_DDL, ImpersonationRefused, assertImpersonationWrites, assertModuleEnqueueableKind, assertSessionUsable, impersonationByIdQuery, impersonationListQuery, impersonationRowValues, impersonationStampOf, mapImpersonationRow, newImpersonationSession, resolveRetryPolicy, isSecretBoxConfigured, unconfiguredSecretBox, createSubjectKeys, generateSealingKeyPair, noSealingKeyMessage, openSealed, sealTo, ConnectionSealingKeyUnavailableError, PermissionDenied, createAtomic, NotSearchable, NotListable, listIndexMigrations, listIndexPlans, listQuery, cursorOf, moduleMigrations, isSearchIndexTable, searchIndexDdl, searchIndexMigrations, searchIndexPlans, searchLimit, searchMatchExpression, searchQuery, entityVersionQuery, entityVersionOf, assertIfMatch, OUTBOX_ENTITY_INDEX, SCHEDULE_STATE_DDL, SCHEDULE_STATE_REBUILD, scheduleStateHasKind, VERTICAL_EVENTS_DDL, EXPORT_HOPS_SQL, IMPORT_CURSORS_SQL, IMPORT_CURSOR_OF_SQL, OUTBOX_MARK_SQL, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, exportedSinceQuery, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, importCursorSourceOf, exportBreaksOf, exportBreakRefusal, bindExportBreaksOf, bindExportBreakRefusal, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, JOB_RUN_DDL, jobRunListLimit, jobRunOf, runDueJobRuns, startJobRun, IDEMPOTENCY_DDL, assertIdempotencyKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, globalFetch, createUlid, facetEvents, readHistory, walkEventCause, walkEventEffects, assertRedrainWindow, readInvocation, readDeadLetters, readLifecycleFlow, domainEventOf, readUndrainedOutbox, undrainedEventsOf, connectorCallRecord, noopConnectorCallRecorder, recordConnectorCall, settleConnectionUse, } from '@substrat-run/kernel';
6
+ import { assertNoSpineReference, assertSpineTablesBuilt, dumpRowsInsert, isSpineTable, repointScopeGrants, spineColumnAdditions } from '@substrat-run/kernel';
7
7
  import { ScopeActor } from './actor.js';
8
8
  import { createTupleChecker } from './checker.js';
9
9
  /**
@@ -27,6 +27,33 @@ function kernelEmit(ctx, event) {
27
27
  throw new Error('kernelEmit: not an operation context this host built');
28
28
  write(event);
29
29
  }
30
+ /**
31
+ * The spine tables a Durable Object's scope builds and this adapter's scope does not (#1883):
32
+ * the roles, tenant-level tuples, entitlements, identity links and connection keys a node
33
+ * scope keeps in its DIRECTORY, and the DO's own `_substrat_meta` and PITR bookmarks. A DO's
34
+ * dump restored here skips them rather than refusing: every one is a projection the directory
35
+ * already holds, or a record only a DO has a use for. Any OTHER spine table this kernel does
36
+ * not build is still refused. The list is the difference between the two `KERNEL_DDL`s, and
37
+ * `pnpm lint:spine-ddl` holds it to that, so a table added on one side cannot slip past.
38
+ */
39
+ export const DO_SCOPE_ONLY_SPINE_TABLES = new Set([
40
+ '_substrat_connection_keys',
41
+ '_substrat_entitlements',
42
+ '_substrat_identity_links',
43
+ '_substrat_meta',
44
+ '_substrat_migration_bookmarks',
45
+ '_substrat_roles',
46
+ '_substrat_tenant_tuples',
47
+ ]);
48
+ /**
49
+ * The columns of spine table `name` as this scope's kernel (or the directory's schema) built it,
50
+ * or `undefined` when it built no such table — what a restore judges a dump's spine tables
51
+ * against (#1883, #1898).
52
+ */
53
+ const spineColumnsOf = (db, name) => {
54
+ const cols = db.prepare(`SELECT name FROM pragma_table_info(?)`).all(name);
55
+ return cols.length === 0 ? undefined : cols.map((c) => c.name);
56
+ };
30
57
  /** The kernel's schedule-switch SQL (#1666), over one scope's database handle. */
31
58
  const switchSqlOf = (db) => ({
32
59
  all: (sql, ...params) => db.prepare(sql).all(...params),
@@ -1136,12 +1163,27 @@ export class SqliteScopeHost {
1136
1163
  `);
1137
1164
  this.ensureDirectoryColumns();
1138
1165
  }
1166
+ /**
1167
+ * The directory's tables as this code builds them, carrying whatever the directory already
1168
+ * holds forward to that shape: a cold start's pass, and a restore's (#1898), which runs it
1169
+ * after replaying the dump's non-spine tables and before loading any row.
1170
+ */
1171
+ buildDirectorySchema() {
1172
+ // #1764: `VERSION_MIGRATIONS_DDL` indexes these two columns, so a directory created
1173
+ // before them needs them before `applyDirectorySchema` reaches that statement.
1174
+ if (this.directory.prepare('PRAGMA table_info(vertical_versions)').all().length > 0) {
1175
+ this.ensureColumn(this.directory, 'vertical_versions', 'migration_count', 'migration_count INTEGER');
1176
+ this.ensureColumn(this.directory, 'vertical_versions', 'migrations_split', 'migrations_split INTEGER');
1177
+ }
1178
+ this.applyDirectorySchema();
1179
+ }
1139
1180
  /**
1140
1181
  * `applyDirectorySchema`, plus the backfill of the schedule switch's record (#1674) from
1141
1182
  * the admin log. Whether the table exists is asked BEFORE the DDL creates it, so the
1142
1183
  * backfill runs only on an application that creates the table: once on a directory that
1143
- * never had it, and again after a directory restore whose dump predates it (from that
1144
- * dump's own log). A directory that already holds the table is never backfilled over.
1184
+ * never had it. A directory that already holds the table is never backfilled over. (A
1185
+ * restore whose dump predates the table builds it and backfills it inside its own
1186
+ * transaction, #1898, so this pass finds it there.)
1145
1187
  *
1146
1188
  * One transaction (Copilot review, #1674): the table and its backfill commit together, so
1147
1189
  * a backfill that fails leaves no table behind, and the next start tries again rather than
@@ -1150,13 +1192,7 @@ export class SqliteScopeHost {
1150
1192
  ensureDirectorySchema() {
1151
1193
  this.directory.transaction(() => {
1152
1194
  const switchRecordIsNew = !systemSwitchesTableExists(switchSqlOf(this.directory));
1153
- // #1764: `VERSION_MIGRATIONS_DDL` indexes these two columns, so a directory created
1154
- // before them needs them before `applyDirectorySchema` reaches that statement.
1155
- if (this.directory.prepare('PRAGMA table_info(vertical_versions)').all().length > 0) {
1156
- this.ensureColumn(this.directory, 'vertical_versions', 'migration_count', 'migration_count INTEGER');
1157
- this.ensureColumn(this.directory, 'vertical_versions', 'migrations_split', 'migrations_split INTEGER');
1158
- }
1159
- this.applyDirectorySchema();
1195
+ this.buildDirectorySchema();
1160
1196
  if (switchRecordIsNew)
1161
1197
  this.directory.exec(SYSTEM_SWITCHES_BACKFILL_SQL);
1162
1198
  })();
@@ -2085,48 +2121,60 @@ export class SqliteScopeHost {
2085
2121
  // rows are gone and the new ones are in. It also covers what a topological sort
2086
2122
  // cannot express: FK cycles, and self-referencing rows within one table.
2087
2123
  db.pragma('defer_foreign_keys = ON');
2088
- // Drop the current schema — the dump's schema is authoritative. Only real
2089
- // tables (never `sqlite_*` internals, which are auto-managed and un-droppable).
2124
+ // Drop the current schema: a vertical's tables are rebuilt from the dump's DDL, the
2125
+ // spine from KERNEL_DDL (below). Only real tables (never `sqlite_*` internals, which
2126
+ // are auto-managed and un-droppable).
2090
2127
  const existing = db
2091
- .prepare(`SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`)
2128
+ .prepare(`SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT GLOB 'sqlite_*'`)
2092
2129
  .all();
2093
2130
  // Search index tables are left alone here and rebuilt below (#827). Dropping a
2094
2131
  // shadow table directly is an error, and dropping them in `sqlite_master` order
2095
2132
  // would reach one before its virtual table.
2096
2133
  for (const { name } of existing) {
2097
- if (isSearchIndexTable(name))
2134
+ if (isSearchIndexTable(name.toLowerCase()))
2098
2135
  continue;
2099
2136
  db.exec(`DROP TABLE IF EXISTS "${name}"`);
2100
2137
  }
2101
2138
  // A dump written before indexes were excluded may still carry them; skip those
2102
2139
  // too rather than failing a restore over data that is about to be recomputed.
2103
- const replayable = dumped.filter((t) => !isSearchIndexTable(t.name));
2140
+ // Matched without case, as SQLite resolves a table name (#1883 review).
2141
+ const replayable = dumped.filter((t) => !isSearchIndexTable(t.name.toLowerCase()));
2104
2142
  // The dump is untrusted input (#1143): its names reach SQL as identifiers, and
2105
2143
  // `db.exec` would run every statement its `ddl` contains, not just the CREATE
2106
2144
  // TABLE. Judged as a whole before any of it executes — a check interleaved with
2107
2145
  // the replay has already let the earlier tables happen.
2108
2146
  assertReplayableDump(replayable);
2109
- for (const t of replayable)
2110
- db.prepare(t.ddl).run();
2111
- for (const t of replayable) {
2147
+ // A vertical's tables take the dump's own DDL. The spine never does (#1883): its tables
2148
+ // come from KERNEL_DDL, which also fills in any the dump omits (#321) — e.g.
2149
+ // `_substrat_migrations`, which the frontier refresh below reads — and the dump
2150
+ // contributes only rows, by column name (`dumpRowsInsert`). Otherwise a dump could
2151
+ // declare a column the checker compares on as COLLATE NOCASE. The column pass follows,
2152
+ // for the one outbox index KERNEL_DDL leaves to it.
2153
+ // A Durable Object's dump carries spine tables this adapter keeps in its directory, or does
2154
+ // not keep at all; they are skipped by name, and any other unknown spine table is refused.
2155
+ const loadable = replayable.filter((t) => !DO_SCOPE_ONLY_SPINE_TABLES.has(t.name.toLowerCase()));
2156
+ for (const t of loadable)
2157
+ if (!isSpineTable(t.name))
2158
+ db.prepare(t.ddl).run();
2159
+ db.exec(KERNEL_DDL);
2160
+ this.ensureSpineColumns(db);
2161
+ const columnsOf = (name) => spineColumnsOf(db, name);
2162
+ assertSpineTablesBuilt(loadable.map((t) => t.name), columnsOf);
2163
+ // A spine column this kernel does not know (a dump from a newer one) is kept, as a plain
2164
+ // untyped column the checker never reads.
2165
+ for (const t of loadable) {
2166
+ if (isSpineTable(t.name))
2167
+ for (const alter of spineColumnAdditions(t, columnsOf(t.name)))
2168
+ db.exec(alter);
2169
+ }
2170
+ for (const t of loadable) {
2171
+ const insert = dumpRowsInsert(t, columnsOf);
2112
2172
  if (t.rows.length === 0)
2113
2173
  continue;
2114
- const cols = t.columns.map((c) => `"${c}"`).join(', ');
2115
- const placeholders = t.columns.map(() => '?').join(', ');
2116
- const stmt = db.prepare(`INSERT INTO "${t.name}" (${cols}) VALUES (${placeholders})`);
2174
+ const stmt = db.prepare(insert);
2117
2175
  for (const row of t.rows)
2118
2176
  stmt.run(...row);
2119
2177
  }
2120
- // Re-assert the per-scope kernel spine (#321): a partial dump (or one from a world
2121
- // that stores some `_substrat_*` tables elsewhere) may omit spine tables this scope
2122
- // must have — e.g. `_substrat_migrations`, which the frontier refresh below reads.
2123
- // KERNEL_DDL is all IF NOT EXISTS, so it fills only the gaps and never disturbs a
2124
- // table the dump carried.
2125
- db.exec(KERNEL_DDL);
2126
- // …and the additive columns, for the same reason: a dump captured before a
2127
- // column existed replays DDL WITHOUT it, and IF NOT EXISTS cannot widen a
2128
- // table the dump did bring.
2129
- this.ensureSpineColumns(db);
2130
2178
  // Rebuild the derived search indexes over the rows just loaded (#827). The DDL
2131
2179
  // drops and recreates, so this also repairs an index the dump left stale, and
2132
2180
  // the triggers it recreates are what keep the restored scope in step from here.
@@ -2144,9 +2192,10 @@ export class SqliteScopeHost {
2144
2192
  // so `/me` reports a role while every `ctx.check` denies. Entity-level grants
2145
2193
  // (`object = customer:<id>`) are untouched: those ids travel with the dump.
2146
2194
  // Which rows move is `repointScopeGrants`'s (#1869): the dump's source scope, exactly.
2147
- // `UPDATE OR REPLACE` because (subject, relation, object) is the primary key — a
2148
- // rewritten row collapses onto an existing one rather than failing the restore.
2149
- repointScopeGrants(switchSqlOf(db), scopeId, { scopeId: dump.scopeId, exact: dump.exact });
2195
+ // (subject, relation, object) is the primary key, so a moved row can meet one the dump
2196
+ // already holds here; which one survives is that function's rule too (#1882), judged
2197
+ // at this host's clock as the checker judges expiry.
2198
+ repointScopeGrants(switchSqlOf(db), scopeId, { scopeId: dump.scopeId, exact: dump.exact }, this.clock());
2150
2199
  // #1742: inside the replay's transaction, so a failure here rolls the whole load back and
2151
2200
  // the dump's grants never commit without the switch that should cover them.
2152
2201
  afterLoad?.(rt);
@@ -5842,6 +5891,13 @@ export class SqliteScopeHost {
5842
5891
  this.recordAccess(actor, 'deadLetters', { tenantId, scopeId }, null, page.entries.length);
5843
5892
  return page;
5844
5893
  },
5894
+ lifecycleFlow: async (actor, tenantId, scopeId, input) => {
5895
+ // #1744: one entity's lifecycle replayed over the outbox, for the process map.
5896
+ const db = this.scopeReadDbFor(tenantId, scopeId);
5897
+ const flow = readLifecycleFlow({ sql: scopedSql(db) }, input);
5898
+ this.recordAccess(actor, 'lifecycleFlow', { tenantId, scopeId }, delegatedReadParams.lifecycleFlow(input), flow.observation.events);
5899
+ return flow;
5900
+ },
5845
5901
  scopeAppliedMigrations: async (actor, tenantId, scopeId) => {
5846
5902
  const db = this.scopeReadDbFor(tenantId, scopeId);
5847
5903
  const rows = db
@@ -6213,7 +6269,7 @@ export class SqliteScopeHost {
6213
6269
  // tables it just loaded. A dump carries the rows, never the index over them.
6214
6270
  const defs = db
6215
6271
  .prepare(`SELECT name, sql FROM sqlite_master
6216
- WHERE type = 'table' AND name NOT LIKE 'sqlite_%' AND sql IS NOT NULL
6272
+ WHERE type = 'table' AND name NOT GLOB 'sqlite_*' AND sql IS NOT NULL
6217
6273
  ORDER BY name`)
6218
6274
  .all().filter(({ name }) => !isSearchIndexTable(name));
6219
6275
  const tables = defs.map(({ name, sql }) => {
@@ -6238,7 +6294,7 @@ export class SqliteScopeHost {
6238
6294
  // blobs kept as bytes.
6239
6295
  const defs = this.directory
6240
6296
  .prepare(`SELECT name, sql FROM sqlite_master
6241
- WHERE type = 'table' AND name NOT LIKE 'sqlite_%' AND sql IS NOT NULL
6297
+ WHERE type = 'table' AND name NOT GLOB 'sqlite_*' AND sql IS NOT NULL
6242
6298
  ORDER BY name`)
6243
6299
  .all();
6244
6300
  const tables = defs.map(({ name, sql }) => {
@@ -6268,23 +6324,47 @@ export class SqliteScopeHost {
6268
6324
  this.directory.pragma('defer_foreign_keys = ON');
6269
6325
  this.directory.transaction(() => {
6270
6326
  const existing = this.directory
6271
- .prepare(`SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`)
6327
+ .prepare(`SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT GLOB 'sqlite_*'`)
6272
6328
  .all();
6273
6329
  for (const { name } of existing)
6274
6330
  this.directory.exec(`DROP TABLE IF EXISTS "${name}"`);
6275
6331
  // `prepare` compiles only the first statement, as in `loadDump`. The check above
6276
6332
  // has pinned that one to this table's CREATE TABLE.
6333
+ // The directory's non-spine tables take the dump's own DDL. Its spine never does
6334
+ // (#1898, as #1883 for a scope): `_substrat_tenant_tuples` and `_substrat_roles` are
6335
+ // what the permission checker reads, and a dump declaring one of their columns
6336
+ // COLLATE NOCASE would decide how tenant-level grants match. The spine is built by
6337
+ // the same pass a cold start runs, before any row goes in, and the dump contributes
6338
+ // only rows, by column name (`dumpRowsInsert`).
6277
6339
  for (const t of dump.tables)
6278
- this.directory.prepare(t.ddl).run();
6340
+ if (!namesSpineTable(t.name))
6341
+ this.directory.prepare(t.ddl).run();
6342
+ this.buildDirectorySchema();
6343
+ const columnsOf = (name) => spineColumnsOf(this.directory, name);
6344
+ // Every `_substrat*` name, the search index's namespace included: a directory has no index.
6345
+ // So every spine table that gets past this is one `isSpineTable` below also calls spine.
6346
+ assertSpineTablesBuilt(dump.tables.map((t) => t.name), columnsOf);
6347
+ // A spine column this code does not know (a dump from a newer one) is kept, as a plain
6348
+ // untyped column nothing here reads.
6349
+ for (const t of dump.tables) {
6350
+ if (isSpineTable(t.name)) {
6351
+ for (const alter of spineColumnAdditions(t, columnsOf(t.name)))
6352
+ this.directory.exec(alter);
6353
+ }
6354
+ }
6279
6355
  for (const t of dump.tables) {
6280
6356
  if (t.rows.length === 0)
6281
6357
  continue;
6282
- const cols = t.columns.map((c) => `"${c}"`).join(', ');
6283
- const placeholders = t.columns.map(() => '?').join(', ');
6284
- const insert = this.directory.prepare(`INSERT INTO "${t.name}" (${cols}) VALUES (${placeholders})`);
6358
+ const insert = this.directory.prepare(dumpRowsInsert(t, columnsOf));
6285
6359
  for (const row of t.rows)
6286
6360
  insert.run(...row);
6287
6361
  }
6362
+ // #1674: the switch record is built above whether or not the dump carried it. A dump
6363
+ // from before it gets the one-time backfill from its own admin log, now that those
6364
+ // rows are in; one that carried it keeps its rows and is never backfilled over.
6365
+ if (!dumpCarriesSystemSwitches(dump.tables.map((t) => t.name))) {
6366
+ this.directory.exec(SYSTEM_SWITCHES_BACKFILL_SQL);
6367
+ }
6288
6368
  })();
6289
6369
  // Carry a copy taken before a directory migration forward to the running
6290
6370
  // code's shape — the same assertion a cold start makes.
@@ -7003,6 +7083,15 @@ export class SqliteScopeHost {
7003
7083
  const parsed = delegatedReadRecord.parse(record);
7004
7084
  this.recordAccess(actor, parsed.method, { tenantId: parsed.tenantId, scopeId: parsed.scopeId }, parsed.params, parsed.resultCount);
7005
7085
  },
7086
+ /**
7087
+ * #1665: one phase of an owner hand-over the control plane ran against the vertical that
7088
+ * holds the scope's owner seat. Parsed, then written as an ordinary `transferOwner` row:
7089
+ * the id and instant are stamped here, the actor is the request's.
7090
+ */
7091
+ recordOwnerTransfer: async (actor, entry) => {
7092
+ const { tenantId, scopeId, ...after } = ownerTransferAudit.parse(entry);
7093
+ this.recordAdmin(actor, 'transferOwner', { tenantId, scopeId }, null, after);
7094
+ },
7006
7095
  accessLog: async (actor, filter) => {
7007
7096
  const where = [];
7008
7097
  const params = [];
@@ -7410,7 +7499,9 @@ export class SqliteScopeHost {
7410
7499
  * has to attempt-and-tolerate instead — see its `ensureDirectoryColumns`).
7411
7500
  */
7412
7501
  ensureColumn(db, table, column, ddl) {
7413
- const existing = db.prepare(`PRAGMA table_info(${table})`).all().some((c) => c.name === column);
7502
+ // Without case, as SQLite resolves a column name: a restore may have added this column
7503
+ // already, untyped and spelled as a newer kernel's dump spelled it (#1883).
7504
+ const existing = db.prepare(`PRAGMA table_info(${table})`).all().some((c) => c.name.toLowerCase() === column.toLowerCase());
7414
7505
  if (!existing)
7415
7506
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${ddl}`);
7416
7507
  }
@@ -7446,8 +7537,10 @@ export class SqliteScopeHost {
7446
7537
  *
7447
7538
  * `db.transaction` nests as a SAVEPOINT, as `ensureScheduleStateKind` (#1571) relies
7448
7539
  * on. Each script leads with `DROP TABLE IF EXISTS <table>_new` to absorb a scratch
7449
- * table arriving from BELOW the transaction (a torn copy of the file, a backup that
7450
- * captured one mid-rebuild) — belt, not the fix.
7540
+ * table arriving from BELOW the transaction (a torn copy of the file) — belt, not the
7541
+ * fix. A restore no longer brings one: since #1898 a dump's `_substrat_*_new` is an unbuilt
7542
+ * spine table, and refused, and since this rebuild became atomic a consistent dump cannot
7543
+ * capture one.
7451
7544
  */
7452
7545
  rebuildAtomically(script) {
7453
7546
  this.directory.transaction(() => this.directory.exec(script))();
@@ -8124,6 +8217,9 @@ export class SqliteScopeHost {
8124
8217
  .prepare('SELECT 1 FROM _substrat_migrations WHERE module_id = ? AND version = ?')
8125
8218
  .get(moduleId, migration.version);
8126
8219
  if (!already) {
8220
+ // #1898: a migration runs on the scope's own handle, not `ctx.sql`, so the
8221
+ // spine guard's REFERENCES rule is applied here.
8222
+ assertNoSpineReference(migration.sql, `migration ${key}`);
8127
8223
  rt.db.exec(migration.sql);
8128
8224
  assertTablesWithinColumnLimit(rt.db);
8129
8225
  rt.db
@@ -8299,12 +8395,15 @@ export class SqliteScopeHost {
8299
8395
  /**
8300
8396
  * The additive spine-column migrations, shared by `runtime()` and the dump replay.
8301
8397
  * KERNEL_DDL is all IF NOT EXISTS, so a scope DB created before a column keeps the
8302
- * old shape — and so does a table a DUMP replay just recreated from legacy DDL,
8303
- * which is why `loadDump` re-runs this after its replay: `runtime()` already ran
8304
- * for that scope, and without the re-run the very next emit in this process fails
8305
- * with `no such column`.
8398
+ * old shape until this runs on its next wake. `loadDump` runs it too, after rebuilding
8399
+ * the spine from KERNEL_DDL: there it adds no column, since a restore never brings a
8400
+ * legacy spine table (#1883), but it also creates `_substrat_outbox_invocation`, which
8401
+ * KERNEL_DDL deliberately does not and the restore's DROP of the outbox took with it.
8306
8402
  */
8307
8403
  ensureSpineColumns(db) {
8404
+ // Every column here is nullable with no DEFAULT (`attempts` is grandfathered): a restore may
8405
+ // have added it bare already, and then `ensureColumn` finds it and adds nothing (#1883).
8406
+ // `lint:spine-ddl` refuses one that is not.
8308
8407
  // KERNEL_DDL is all IF NOT EXISTS, so a scope DB created before K-21 keeps the
8309
8408
  // old shape — ALTER the tombstone in.
8310
8409
  this.ensureColumn(db, '_substrat_tuples', 'revoked_at', 'revoked_at TEXT');