@substrat-run/adapter-sqlite 0.122.1 → 0.125.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
@@ -1,5 +1,5 @@
1
1
  import { type BlobStoreHandle, type ImportBatch, type ImportResult, type PeerCoverage, type VerticalCaller, type CapabilityExchange, type ConnectionId, type ModuleId, type DomainEvent, type PlatformRequestId, type PlatformRequest, type PlatformRequestFilter, type PlatformRequestStatus, type PlatformRequestFailure, type ProjectedConnectionGrant, type PermissionKey, type PlatformActorId, type PrincipalId, type ScopeDump, type ScopeId, type ImpersonationSessionId, type TenantId, type TenantStoreHandle } from '@substrat-run/contracts';
2
- import { type FreshnessReport, type FreshnessRegistration, type BlobStoreProvisionInput, type ScopeAttachments, type ExecutorDeadLetter, type ExecutorDrainReport, type MigrateScopeOutcome, type MigrationFrontier, type ExecutorHandler, type ExecutorRetryPolicy, type ConnectorHandler, type ConnectorOptions, type Clock, type FetchLike, type SecretBox, type HostAdmin, type ModuleRegistration, type OperationHandler, type PermissionChecker, type ProvisionScopeInput, type ScheduleRegistration, type ScheduleRunReport, type ScopeHost, type ScopeStub, type ScopeStubOptions, type TenantRelationalStore, type TenantStoreProvisionInput, type JobDriveReport, type JobHandler, type JobRun, type JobRunFilter, type StartJobRunInput, type ConnectorCallRecorder } from '@substrat-run/kernel';
2
+ import { type ModuleLogSink, type FreshnessReport, type FreshnessRegistration, type BlobStoreProvisionInput, type ScopeAttachments, type ExecutorDeadLetter, type ExecutorDrainReport, type MigrateScopeOutcome, type MigrationFrontier, type ExecutorHandler, type ExecutorRetryPolicy, type ConnectorHandler, type ConnectorOptions, type Clock, type FetchLike, type SecretBox, type HostAdmin, type ModuleRegistration, type OperationHandler, type PermissionChecker, type ProvisionScopeInput, type ScheduleRegistration, type ScheduleRunReport, type ScopeHost, type ScopeStub, type ScopeStubOptions, type TenantRelationalStore, type TenantStoreProvisionInput, type JobDriveReport, type JobHandler, type JobRun, type JobRunFilter, type StartJobRunInput, type ConnectorCallRecorder } from '@substrat-run/kernel';
3
3
  /**
4
4
  * A fault in the database itself (full, corrupt, I/O), as opposed to one statement failing.
5
5
  * The #1764 backfill logs and opens past a failed batch, but never past one of these.
@@ -49,6 +49,11 @@ export interface SqliteScopeHostOptions {
49
49
  * admin-log entry) are untouched and stay on the real clock.
50
50
  */
51
51
  clock?: Clock;
52
+ /**
53
+ * #1746: where `ctx.log` lines go. Defaults to the console, one JSON line per call, which
54
+ * is what a deployment's log platform indexes. A test passes a collector.
55
+ */
56
+ logSink?: ModuleLogSink;
52
57
  /**
53
58
  * The version REGISTRY id of the vertical version this host runs (#1242) — stamped
54
59
  * into the outbox `version` column at emit, the signals dimension (#1231) that joins
@@ -161,6 +166,8 @@ export declare class SqliteScopeHost implements ScopeHost {
161
166
  private readonly connectorCalls;
162
167
  private readonly clock;
163
168
  private readonly versionId;
169
+ /** #1746: where `ctx.log` lines go — the console unless a caller (a test) says otherwise. */
170
+ private readonly logSink;
164
171
  constructor(options: SqliteScopeHostOptions);
165
172
  /**
166
173
  * The directory schema, applied on every open — and again after a restore (#40).
@@ -223,6 +230,11 @@ export declare class SqliteScopeHost implements ScopeHost {
223
230
  * holds on the scope's actor: every module the directory records OFF on the scope is
224
231
  * switched off again. Already off answers `changed: false` and writes nothing, and a
225
232
  * module the scope does not hold is left alone. Audited only when something moved.
233
+ *
234
+ * `audit` receives each row. By default it writes to the admin log at once. A caller running
235
+ * this inside a scope transaction that may still roll back (a restore's replay) collects
236
+ * the rows and writes them once the transaction commits. The admin log is another
237
+ * database, and a row must not outlive a move that was rolled back.
226
238
  */
227
239
  private reassertSwitchesInTurn;
228
240
  provisionTenantStore(actor: PlatformActorId, input: TenantStoreProvisionInput): Promise<TenantStoreHandle>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAcL,KAAK,eAAe,EAcpB,KAAK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CAAC,YAAY;IAUpB;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IAyE1B,OAAO,CAAC,OAAO;CA6ChB"}
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
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, 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, 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, exchangeCapability as exchangeCapabilitySecret, guardSecrets, mintBecomeCapability, plausibleSessionToken, redactSecrets, resolveCapabilitySession, revokeCapabilityAsPlatform, assertReadOnlyQuery, attachmentBlobKey, entitlementDenial, foldMeterReading, guardSpine, guardSqlLimits, 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, SYSTEM_SWITCHES_BACKFILL_SQL, SYSTEM_SWITCHES_DDL, forgetSystemSwitchesOf, listSystemSwitchRecords, recordSystemSwitchedOff, recordSystemSwitchedOn, restoreSystemSwitchRecord, switchedOffModulesOf, 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, 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';
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, 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, 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
6
  import { ScopeActor } from './actor.js';
7
7
  import { createTupleChecker } from './checker.js';
8
8
  /**
@@ -505,6 +505,8 @@ export class SqliteScopeHost {
505
505
  connectorCalls;
506
506
  clock;
507
507
  versionId;
508
+ /** #1746: where `ctx.log` lines go — the console unless a caller (a test) says otherwise. */
509
+ logSink;
508
510
  // The mint for event ids (#956) is NOT here: it lives on `ScopeRuntime`, one per
509
511
  // scope, seeded from that scope's persisted maximum (#1335). Its own monotonic
510
512
  // floor, because the timestamp it stamps comes from `this.clock` — a scripted
@@ -516,6 +518,7 @@ export class SqliteScopeHost {
516
518
  this.connectorCalls = options.connectorCalls ?? noopConnectorCallRecorder;
517
519
  this.clock = options.clock ?? (() => instant.parse(new Date().toISOString()));
518
520
  this.versionId = options.versionId ?? null;
521
+ this.logSink = options.logSink ?? consoleLogSink;
519
522
  this.dir = options.dir;
520
523
  mkdirSync(this.dir, { recursive: true });
521
524
  this.directory = new Database(join(this.dir, '_directory.sqlite'));
@@ -1078,6 +1081,9 @@ export class SqliteScopeHost {
1078
1081
  -- the operation column) and the newest matching evidence. NULL on other kinds.
1079
1082
  event_type TEXT,
1080
1083
  observed_at TEXT,
1084
+ -- #1840 platform-request rows: the drain pass's fleet-wide totals, as JSON.
1085
+ -- NULL on every other kind.
1086
+ platform_requests TEXT,
1081
1087
  at TEXT NOT NULL
1082
1088
  );
1083
1089
  CREATE INDEX IF NOT EXISTS _substrat_sweep_runs_unit ON _substrat_sweep_runs (kind, unit, id);
@@ -1557,13 +1563,35 @@ export class SqliteScopeHost {
1557
1563
  * holds on the scope's actor: every module the directory records OFF on the scope is
1558
1564
  * switched off again. Already off answers `changed: false` and writes nothing, and a
1559
1565
  * module the scope does not hold is left alone. Audited only when something moved.
1566
+ *
1567
+ * `audit` receives each row. By default it writes to the admin log at once. A caller running
1568
+ * this inside a scope transaction that may still roll back (a restore's replay) collects
1569
+ * the rows and writes them once the transaction commits. The admin log is another
1570
+ * database, and a row must not outlive a move that was rolled back.
1560
1571
  */
1561
- reassertSwitchesInTurn(rt, actor, tenantId, scopeId) {
1572
+ reassertSwitchesInTurn(rt, actor, tenantId, scopeId, opts, audit = (after) => this.recordAdmin(actor, 'reassertSystemSwitch', { tenantId, scopeId }, null, after)) {
1562
1573
  const at = new Date().toISOString();
1563
- return switchedOffModulesOf(switchSqlOf(this.directory), tenantId, scopeId).map((moduleId) => {
1574
+ // #1742 review: a move the deployment made from a stale list — the module was restored
1575
+ // ON after the list was read — is undone first, so the operator's ON stands.
1576
+ const recorded = systemSwitchRecordsOf(switchSqlOf(this.directory), tenantId, scopeId);
1577
+ // One synchronous turn: no switch can land between this read and the moves below.
1578
+ const reverted = new Set(staleCarryReverts(recorded, opts?.appliedInUnit));
1579
+ for (const moduleId of reverted) {
1580
+ const outcome = rt.db.transaction(() => switchSystemSchedules(switchSqlOf(rt.db), { moduleId, scopeId, to: 'on', at }))();
1581
+ if (outcome.changed)
1582
+ audit({ operationId: ulid(), ...staleCarryRevertRow(moduleId, outcome) });
1583
+ }
1584
+ const recordedOff = switchedOffModulesOf(switchSqlOf(this.directory), tenantId, scopeId);
1585
+ // #1742: what a deployment already switched off inside its own unit, audited here — the
1586
+ // switch below answers `changed: false` for it and would write no row.
1587
+ // A move the revert above undid is not credited as an in-unit OFF.
1588
+ const applied = opts?.appliedInUnit?.filter((a) => !reverted.has(a.moduleId));
1589
+ for (const row of inUnitMovesToAudit(recordedOff, applied))
1590
+ audit({ operationId: ulid(), ...row });
1591
+ return recordedOff.map((moduleId) => {
1564
1592
  const outcome = rt.db.transaction(() => switchSystemSchedules(switchSqlOf(rt.db), { moduleId, scopeId, to: 'off', at }))();
1565
1593
  if (outcome.changed) {
1566
- this.recordAdmin(actor, 'reassertSystemSwitch', { tenantId, scopeId }, null, {
1594
+ audit({
1567
1595
  operationId: ulid(),
1568
1596
  moduleId,
1569
1597
  schedules: 'off',
@@ -2015,7 +2043,10 @@ export class SqliteScopeHost {
2015
2043
  this.recordAdmin(actor, 'importScope', { tenantId: input.tenantId, scopeId: input.scopeId }, null, { sourceScopeId: dump.scopeId, tables: dump.tables.length, capturedAt: dump.capturedAt });
2016
2044
  }
2017
2045
  /** Drop-then-replay a dump into a scope's db, refreshing the migration frontier. */
2018
- async loadDump(tenantId, scopeId, tables) {
2046
+ async loadDump(tenantId, scopeId, tables,
2047
+ /** Run inside the load's own transaction, after the replay (#1742) — the restore's re-assert
2048
+ * of the switch. It throws to roll the load back. */
2049
+ afterLoad) {
2019
2050
  const rt = this.runtime(tenantId, scopeId);
2020
2051
  const db = rt.db;
2021
2052
  const load = db.transaction((dumped) => {
@@ -2098,6 +2129,9 @@ export class SqliteScopeHost {
2098
2129
  // rewritten row collapses onto an existing one rather than failing the restore.
2099
2130
  db.prepare(`UPDATE OR REPLACE _substrat_tuples SET object = ?
2100
2131
  WHERE object LIKE 'scope:%' AND object <> ?`).run(`scope:${scopeId}`, `scope:${scopeId}`);
2132
+ // #1742: inside the replay's transaction, so a failure here rolls the whole load back and
2133
+ // the dump's grants never commit without the switch that should cover them.
2134
+ afterLoad?.(rt);
2101
2135
  });
2102
2136
  // On the scope actor (#1678): issued while an invoke held its transaction open, the
2103
2137
  // load was a SAVEPOINT inside it, and that invoke's rollback undid the restore after
@@ -2117,7 +2151,14 @@ export class SqliteScopeHost {
2117
2151
  const existing = await this.admin.getScopeRecord(actor, tenantId, scopeId);
2118
2152
  if (!existing)
2119
2153
  throw substratError('not_found', `unknown scope ${scopeId} in tenant ${tenantId}`);
2120
- await this.loadDump(tenantId, scopeId, dump.tables);
2154
+ // #1742: a dump from before a switch was pulled brings the module's grants back live, so
2155
+ // the directory's recorded-off modules go back off in the load's own turn, as a
2156
+ // provision's seat does — no schedule pass can run in between.
2157
+ // The re-assert's audit rows are written only once the load has committed.
2158
+ const rows = [];
2159
+ await this.loadDump(tenantId, scopeId, dump.tables, (rt) => this.reassertSwitchesInTurn(rt, actor, tenantId, scopeId, undefined, (after) => rows.push(after)));
2160
+ for (const after of rows)
2161
+ this.recordAdmin(actor, 'reassertSystemSwitch', { tenantId, scopeId }, null, after);
2121
2162
  this.recordAdmin(actor, 'restoreScope', { tenantId, scopeId }, null, { sourceScopeId: dump.scopeId, tables: dump.tables.length, capturedAt: dump.capturedAt });
2122
2163
  }
2123
2164
  async snapshotScope(actor, tenantId, scopeId, opts) {
@@ -2865,10 +2906,14 @@ export class SqliteScopeHost {
2865
2906
  }
2866
2907
  // Due — invoke through the system door (a fresh stub per schedule keeps the
2867
2908
  // K-34 authorization accumulator clean, and the door re-checks the scope).
2909
+ // #1525: one id for THIS call, minted before the invoke so it is the same id
2910
+ // whether the operation succeeds or throws — an event or a denial the call
2911
+ // produces either way carries it, and so does the row below.
2912
+ const invocationId = ulid();
2868
2913
  let status = 'ok';
2869
2914
  try {
2870
2915
  const stub = await this.getSystemScope(moduleId, tenantId, scopeId);
2871
- await stub.invoke(schedule.operation, schedule.input);
2916
+ await stub.invoke(schedule.operation, schedule.input, { invocationId });
2872
2917
  report.fired += 1;
2873
2918
  }
2874
2919
  catch (err) {
@@ -2882,11 +2927,12 @@ export class SqliteScopeHost {
2882
2927
  // On the scope actor (#1678): the cadence row joined whatever transaction an invoke
2883
2928
  // held open, so its rollback forgot the run and the next pass fired it AGAIN.
2884
2929
  await rt.actor.turn(() => rt.db
2885
- .prepare(`INSERT INTO _substrat_schedule_state (kind, schedule_op, last_run_at, last_status)
2886
- VALUES ('schedule', ?, ?, ?)
2930
+ .prepare(`INSERT INTO _substrat_schedule_state (kind, schedule_op, last_run_at, last_status, invocation_id)
2931
+ VALUES ('schedule', ?, ?, ?, ?)
2887
2932
  ON CONFLICT(kind, schedule_op) DO UPDATE SET last_run_at = excluded.last_run_at,
2888
- last_status = excluded.last_status`)
2889
- .run(schedule.operation, new Date(now).toISOString(), status));
2933
+ last_status = excluded.last_status,
2934
+ invocation_id = excluded.invocation_id`)
2935
+ .run(schedule.operation, new Date(now).toISOString(), status, invocationId));
2890
2936
  report.runs.push({ operation: schedule.operation, outcome: status === 'ok' ? 'ok' : 'failed' });
2891
2937
  }
2892
2938
  return report;
@@ -2911,6 +2957,13 @@ export class SqliteScopeHost {
2911
2957
  return {
2912
2958
  tenantId,
2913
2959
  scopeId,
2960
+ // #1746: the door decided it. A capability session and a peer door each resolve to
2961
+ // their subject per invoke, but the KIND is fixed when the stub is minted.
2962
+ subjectKind: authority.kind === 'capability-session'
2963
+ ? 'capability'
2964
+ : authority.kind === 'vertical-peer'
2965
+ ? 'vertical'
2966
+ : authority.kind,
2914
2967
  invoke: async (operation, input, invokeOptions) => {
2915
2968
  const handler = operations.get(operation);
2916
2969
  // `not_found`, not a bare throw (#113) — the same code `adapter-cloudflare`
@@ -2978,6 +3031,8 @@ export class SqliteScopeHost {
2978
3031
  // #116: reported after the task, like the version — a replay is a fact
2979
3032
  // about the response, and the response is not one until it is returned.
2980
3033
  let replayed = false;
3034
+ // #1746: what this call itself emitted, for `onEmitted`. Set only after a commit.
3035
+ let emittedReport;
2981
3036
  const invoked = await rt.actor.enqueue(async () => {
2982
3037
  // #1237: the invocation this call belongs to, for the duration of it. Set
2983
3038
  // INSIDE the actor task — the actor serializes invoke and dispatch alike, so
@@ -2988,6 +3043,11 @@ export class SqliteScopeHost {
2988
3043
  // The outbox's insertion mark, inside the actor task so nothing else writes between it
2989
3044
  // and this invoke (`OUTBOX_MARK_SQL` says why rowid and not the id).
2990
3045
  const exportMark = exportTypes.length > 0 ? Number(rt.db.prepare(OUTBOX_MARK_SQL).get().mark) : null;
3046
+ // #1746: the same mark, taken only when the caller asked what this call emitted. A
3047
+ // read-only session commits nothing, so it has nothing to report and skips the read.
3048
+ const emittedMark = invokeOptions?.onEmitted !== undefined && session?.mode !== 'read-only'
3049
+ ? (exportMark ?? Number(rt.db.prepare(OUTBOX_MARK_SQL).get().mark))
3050
+ : null;
2991
3051
  try {
2992
3052
  // #1672: the capability door's session, re-resolved on EVERY invoke and inside the
2993
3053
  // actor task — so nothing can revoke between this read and the transaction below.
@@ -3122,6 +3182,12 @@ export class SqliteScopeHost {
3122
3182
  this.recordDenial(rt, subject, operation, err, rt.invocationId, session);
3123
3183
  throw err;
3124
3184
  }
3185
+ // #1746: read BEFORE the drain below, so the rows above the mark are this
3186
+ // operation's own emits and none of its consumers'. A replay committed nothing.
3187
+ if (emittedMark !== null && !replayed) {
3188
+ const q = emittedSinceQuery(emittedMark, EMITTED_REPORT_CAP);
3189
+ emittedReport = emittedReportOf(rt.db.prepare(q.sql).all(...q.params));
3190
+ }
3125
3191
  // Post-commit, still inside the actor task: drain outbox → consumers,
3126
3192
  // then → executors. Prompt dispatch (K-22 §4.2): the common case
3127
3193
  // completes inside this request, with the outbox as the retry backstop
@@ -3158,6 +3224,8 @@ export class SqliteScopeHost {
3158
3224
  invokeOptions?.onEntityVersion?.(committedVersion);
3159
3225
  if (replayed)
3160
3226
  invokeOptions?.onIdempotentReplay?.();
3227
+ if (emittedReport)
3228
+ invokeOptions?.onEmitted?.(emittedReport);
3161
3229
  return invoked;
3162
3230
  },
3163
3231
  };
@@ -4240,7 +4308,8 @@ export class SqliteScopeHost {
4240
4308
  };
4241
4309
  const writeGrant = (subject, permission, node, entity, expiresAt) => {
4242
4310
  if (entity) {
4243
- writeScopeTuple(node, subject, `granted:${permission}`, `${entity.entityType}:${entity.entityId}`, expiresAt);
4311
+ writeScopeTuple(node, subject, `granted:${permission}`, entityObjectRef(entity, 'HostAdmin'), // #1856: grant and grantToOrg both land here
4312
+ expiresAt);
4244
4313
  }
4245
4314
  else if (node.scopeId) {
4246
4315
  writeScopeTuple(node, subject, `granted:${permission}`, `scope:${node.scopeId}`, expiresAt);
@@ -4722,8 +4791,15 @@ export class SqliteScopeHost {
4722
4791
  });
4723
4792
  }
4724
4793
  else {
4725
- // Tenant-level: a directory write, which no scope's transaction can hold.
4726
- write();
4794
+ // Tenant-level: a directory write, which no scope's transaction can hold. #1743:
4795
+ // refused while the record holds the module off on any scope (`scopesSwitchedOffFor`);
4796
+ // the record and the tenant tuple share the directory, so this is one transaction.
4797
+ this.directory.transaction(() => {
4798
+ const off = scopesSwitchedOffFor(switchSqlOf(this.directory), grant.node.tenantId, grant.moduleId);
4799
+ if (off.length > 0)
4800
+ throw substratError('conflict', tenantSystemSwitchedOffMessage(grant.moduleId, off));
4801
+ write();
4802
+ })();
4727
4803
  }
4728
4804
  this.recordAdmin(actor, 'grantToSystem', { tenantId: grant.node.tenantId, scopeId: grant.node.scopeId }, null, { moduleId: grant.moduleId, permission: grant.permission, node: grant.node });
4729
4805
  },
@@ -4744,10 +4820,10 @@ export class SqliteScopeHost {
4744
4820
  this.recordAccess(actor, 'listSystemSwitches', { tenantId: filter?.tenantId ?? null }, filter ?? null, rows.length);
4745
4821
  return rows.map((r) => systemSwitchRecord.parse(r));
4746
4822
  },
4747
- reassertSystemSwitches: async (actor, node) => {
4823
+ reassertSystemSwitches: async (actor, node, opts) => {
4748
4824
  this.assertScope(node.tenantId, node.scopeId);
4749
4825
  const rt = this.runtime(node.tenantId, node.scopeId);
4750
- return rt.actor.turn(() => this.reassertSwitchesInTurn(rt, actor, node.tenantId, node.scopeId));
4826
+ return rt.actor.turn(() => this.reassertSwitchesInTurn(rt, actor, node.tenantId, node.scopeId, opts));
4751
4827
  },
4752
4828
  peerGrantsStatus: peerGrantsStatusOf,
4753
4829
  // #1672 — the platform's two capability verbs, both a turn on the scope actor
@@ -5701,7 +5777,7 @@ export class SqliteScopeHost {
5701
5777
  // NULL a missing field does, and only the helper counts them apart.
5702
5778
  const db = this.scopeReadDbFor(tenantId, scopeId);
5703
5779
  const result = facetEvents({ sql: scopedSql(db) }, input);
5704
- this.recordAccess(actor, 'facetEvents', { tenantId, scopeId }, input, result.buckets.length);
5780
+ this.recordAccess(actor, 'facetEvents', { tenantId, scopeId }, delegatedReadParams.facetEvents(input, result), result.buckets.length);
5705
5781
  return result;
5706
5782
  },
5707
5783
  entityHistory: async (actor, tenantId, scopeId, input) => {
@@ -6158,6 +6234,11 @@ export class SqliteScopeHost {
6158
6234
  // Counted before the replace — afterwards the old directory is gone, and
6159
6235
  // "restored over N tenants" is the fact the audit entry exists to carry.
6160
6236
  const before = this.directory.prepare('SELECT COUNT(*) AS n FROM tenants').get().n;
6237
+ // The dump is untrusted input, as it is on the DO path (#1143). Its names reach SQL
6238
+ // as identifiers, and `exec` runs every statement a `ddl` contains, so a CREATE
6239
+ // TABLE with anything appended used to run that too. Judged as a whole before the
6240
+ // first DROP, so a refused dump leaves the directory untouched.
6241
+ assertReplayableDump(dump.tables);
6161
6242
  // One transaction, foreign keys deferred to commit: the dump is ordered by
6162
6243
  // table NAME (which says nothing about references — `scopes` points at
6163
6244
  // `tenants`), and the DROPs themselves delete rows a populated child would
@@ -6170,8 +6251,10 @@ export class SqliteScopeHost {
6170
6251
  .all();
6171
6252
  for (const { name } of existing)
6172
6253
  this.directory.exec(`DROP TABLE IF EXISTS "${name}"`);
6254
+ // `prepare` compiles only the first statement, as in `loadDump`. The check above
6255
+ // has pinned that one to this table's CREATE TABLE.
6173
6256
  for (const t of dump.tables)
6174
- this.directory.exec(t.ddl);
6257
+ this.directory.prepare(t.ddl).run();
6175
6258
  for (const t of dump.tables) {
6176
6259
  if (t.rows.length === 0)
6177
6260
  continue;
@@ -7150,12 +7233,12 @@ export class SqliteScopeHost {
7150
7233
  this.directory
7151
7234
  .prepare(`INSERT OR IGNORE INTO _substrat_sweep_runs
7152
7235
  (id, kind, unit, outcome, tenant_id, scope_id, vertical, version, operation,
7153
- connection_id, error, elapsed_ms, request_id, event_type, observed_at, at)
7154
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
7236
+ connection_id, error, elapsed_ms, request_id, event_type, observed_at, platform_requests, at)
7237
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
7155
7238
  .run(ulid(), entry.kind, entry.unit, entry.outcome, entry.tenantId ?? null, entry.scopeId ?? null, entry.vertical ?? null, entry.version ?? null, entry.operation ?? null, entry.connectionId ?? null,
7156
7239
  // Bounded here, not trusted from the sweep: one runaway provider body
7157
7240
  // must not become a runaway directory row (the #559 rule).
7158
- entry.error == null ? null : entry.error.slice(0, 2000), entry.elapsedMs ?? null, entry.requestId ?? null, entry.eventType ?? null, entry.observedAt ?? null, entry.at ?? new Date().toISOString());
7241
+ entry.error == null ? null : entry.error.slice(0, 2000), entry.elapsedMs ?? null, entry.requestId ?? null, entry.eventType ?? null, entry.observedAt ?? null, entry.platformRequests == null ? null : JSON.stringify(entry.platformRequests), entry.at ?? new Date().toISOString());
7159
7242
  // Prune-on-write, like ops failures and for the same reason: the table stays
7160
7243
  // bounded even on a deployment whose scheduled pass is broken.
7161
7244
  const horizon = new Date(Date.now() - SWEEP_RUN_RETENTION_DAYS * 86_400_000).toISOString();
@@ -7216,6 +7299,7 @@ export class SqliteScopeHost {
7216
7299
  elapsedMs: r.elapsed_ms,
7217
7300
  eventType: r.event_type,
7218
7301
  observedAt: r.observed_at,
7302
+ platformRequests: r.platform_requests == null ? null : JSON.parse(r.platform_requests),
7219
7303
  at: r.at,
7220
7304
  }));
7221
7305
  },
@@ -7515,6 +7599,7 @@ export class SqliteScopeHost {
7515
7599
  this.ensureColumn(this.directory, '_substrat_sweep_runs', 'request_id', 'request_id TEXT');
7516
7600
  this.ensureColumn(this.directory, '_substrat_sweep_runs', 'event_type', 'event_type TEXT');
7517
7601
  this.ensureColumn(this.directory, '_substrat_sweep_runs', 'observed_at', 'observed_at TEXT');
7602
+ this.ensureColumn(this.directory, '_substrat_sweep_runs', 'platform_requests', 'platform_requests TEXT');
7518
7603
  this.ensureSweepRunsIntentKind();
7519
7604
  const existing = new Set(this.directory.prepare('PRAGMA table_info(scopes)').all().map((c) => c.name));
7520
7605
  for (const [column, ddl] of [
@@ -7713,8 +7798,22 @@ export class SqliteScopeHost {
7713
7798
  tenantId: rt.tenantId,
7714
7799
  scopeId: rt.scopeId,
7715
7800
  principal,
7716
- sql: guardSecrets(guardSqlLimits(scopedSql(rt.db)), minted),
7801
+ sql: guardSecrets(guardSqlLimits(scopedSql(rt.db, true)), minted),
7717
7802
  now: () => at,
7803
+ // #1746/#1747: the host stamps who and where; module code supplies only the template
7804
+ // and its fields. The invocation id is read per call — it is set for the duration of
7805
+ // the actor task this context runs in.
7806
+ log: moduleLog({
7807
+ tenantId: rt.tenantId,
7808
+ scopeId: rt.scopeId,
7809
+ operation: operation ?? null,
7810
+ invocationId: () => rt.invocationId,
7811
+ // A consumer runs under the system override, so it logs as `system`.
7812
+ principalKind: overrideActor ? 'system' : subject.kind,
7813
+ // The string-safe redaction: `redactSecrets` parses its serialization back, and a
7814
+ // log's text is not JSON.
7815
+ redact: (text) => redactSecretText(text, minted),
7816
+ }, this.logSink),
7718
7817
  emit: (event) => {
7719
7818
  assertImpersonationWrites(impersonation, 'ctx.emit');
7720
7819
  const input = domainEventInput.parse(event);
@@ -7865,6 +7964,7 @@ export class SqliteScopeHost {
7865
7964
  */
7866
7965
  grant: async (principal, permission, entity) => {
7867
7966
  assertImpersonationWrites(impersonation, 'ctx.grant');
7967
+ entityObjectRef(entity, 'ctx.grant'); // #1856: a tuple the walk can read back
7868
7968
  const held = await runCheck(permission, entity);
7869
7969
  if (!held.allowed) {
7870
7970
  throw new PermissionDenied(`cannot grant '${permission}' on ${entity.entityType}:${entity.entityId} — ` +
@@ -7875,7 +7975,11 @@ export class SqliteScopeHost {
7875
7975
  VALUES (?, ?, ?)`)
7876
7976
  .run(`principal:${principal}`, `granted:${permission}`, `${entity.entityType}:${entity.entityId}`);
7877
7977
  },
7878
- /** Withdraw a grant this caller could have made. Same guardrails, same reason. */
7978
+ /**
7979
+ * Withdraw a grant this caller could have made. Same guardrails, same reason — but NOT
7980
+ * the #1856 grammar check `grant` and `link` make: a revoke writes nothing the walk
7981
+ * must read back, and a grant stored before that check existed must stay removable.
7982
+ */
7879
7983
  revoke: async (principal, permission, entity) => {
7880
7984
  assertImpersonationWrites(impersonation, 'ctx.revoke');
7881
7985
  const held = await runCheck(permission, entity);
@@ -7905,6 +8009,8 @@ export class SqliteScopeHost {
7905
8009
  }),
7906
8010
  link: (child, parent) => {
7907
8011
  assertImpersonationWrites(impersonation, 'ctx.link');
8012
+ entityObjectRef(child, 'ctx.link'); // #1856: an edge the walk can read back
8013
+ entityObjectRef(parent, 'ctx.link');
7908
8014
  const allowed = relations.get(child.entityType);
7909
8015
  if (!allowed?.has(parent.entityType)) {
7910
8016
  throw new Error(`undeclared entity relation: ${child.entityType} → ${parent.entityType} ` +
@@ -7995,6 +8101,7 @@ export class SqliteScopeHost {
7995
8101
  .get(moduleId, migration.version);
7996
8102
  if (!already) {
7997
8103
  rt.db.exec(migration.sql);
8104
+ assertTablesWithinColumnLimit(rt.db);
7998
8105
  rt.db
7999
8106
  .prepare('INSERT INTO _substrat_migrations (module_id, version, applied_at) VALUES (?, ?, ?)')
8000
8107
  .run(moduleId, migration.version, this.clock());
@@ -8223,6 +8330,14 @@ export class SqliteScopeHost {
8223
8330
  // #1288: not an ensureColumn, because `kind` joins the schedule-state PRIMARY KEY
8224
8331
  // and no ALTER can widen a key. Rebuilt instead, from the kernel's statements.
8225
8332
  this.ensureScheduleStateKind(db);
8333
+ // #1525: the invocation a fired schedule ran in, on a scope DB created before the
8334
+ // column. Nullable, and the null is honestly "no call was carried" for every legacy
8335
+ // row — a past run's id cannot be recovered afterwards, exactly as the other #1525
8336
+ // columns above argued. AFTER `ensureScheduleStateKind`, not before: a pre-#1288
8337
+ // table has no `kind` column, and that call's rebuild already recreates the table
8338
+ // from the kernel's (now widened) DDL when it runs — so by the time this ALTER
8339
+ // executes, the table always already has `kind` in its key, never `invocation_id`.
8340
+ this.ensureColumn(db, '_substrat_schedule_state', 'invocation_id', 'invocation_id TEXT');
8226
8341
  // #1237: `readInvocation`'s lookup — WHERE invocation_id = ? ORDER BY id — over an outbox
8227
8342
  // that is never pruned. No index leads with invocation_id, so without this one SQLite
8228
8343
  // walks the PRIMARY KEY from the oldest event until it reaches the call, and reading a
@@ -8309,13 +8424,49 @@ function spineSql(db) {
8309
8424
  },
8310
8425
  };
8311
8426
  }
8312
- function scopedSql(db) {
8427
+ /**
8428
+ * Refuse a migration that left a table wider than a Durable Object allows (#1811). Judged on the
8429
+ * schema AFTER the migration ran, inside its transaction, so the throw rolls the migration back
8430
+ * and the scope fails closed as it would hosted — from `CREATE TABLE` and from `ADD COLUMN` alike,
8431
+ * with no parsing of the migration's text. `table_xinfo`, not `table_info`: the DO counts a
8432
+ * generated column and a virtual table's hidden columns, and `table_info` shows neither.
8433
+ */
8434
+ function assertTablesWithinColumnLimit(db) {
8435
+ const wide = db
8436
+ .prepare(`SELECT m.name AS name, COUNT(*) AS width FROM sqlite_master m, pragma_table_xinfo(m.name) c
8437
+ WHERE m.type = 'table' GROUP BY m.name HAVING COUNT(*) > ? ORDER BY m.name LIMIT 1`)
8438
+ .get(DO_SQL_LIMITS.columns);
8439
+ if (wide)
8440
+ throw new Error(tooManyTableColumns(wide.name, wide.width));
8441
+ }
8442
+ function scopedSql(db, judgeWidth = false) {
8443
+ // #1811: a Durable Object refuses a result set over its column cap, `exec` of a SELECT included.
8444
+ // The driver knows the width, so it is read off the prepared statement rather than parsed out
8445
+ // of the text (a `SELECT *` is as wide as the tables under it). Module SQL only, like the
8446
+ // other limits.
8447
+ const prepare = (sql) => {
8448
+ const stmt = db.prepare(sql);
8449
+ if (judgeWidth && stmt.reader) {
8450
+ const width = stmt.columns().length;
8451
+ if (width > DO_SQL_LIMITS.columns)
8452
+ throw new Error(tooManyResultColumns(width));
8453
+ }
8454
+ return stmt;
8455
+ };
8313
8456
  return guardSpine({
8314
- query: (sql, params = []) => db.prepare(sql).all(...params),
8457
+ query: (sql, params = []) => prepare(sql).all(...params),
8315
8458
  exec: (sql, params = []) => {
8316
- const info = db.prepare(sql).run(...params);
8459
+ const stmt = prepare(sql);
8460
+ // Runtime DDL (a module's own `CREATE TABLE` / `ADD COLUMN` outside a migration) is judged
8461
+ // the same way a migration is: by what the schema is afterwards. `schema_version` moves on
8462
+ // exactly the statements that change it, so a plain write costs two header reads and no scan.
8463
+ const before = judgeWidth && !stmt.reader ? schemaVersion(db) : 0;
8464
+ const info = stmt.run(...params);
8465
+ if (judgeWidth && !stmt.reader && schemaVersion(db) !== before)
8466
+ assertTablesWithinColumnLimit(db);
8317
8467
  return { changes: info.changes };
8318
8468
  },
8319
8469
  });
8320
8470
  }
8471
+ const schemaVersion = (db) => db.pragma('schema_version', { simple: true });
8321
8472
  //# sourceMappingURL=index.js.map