@dbsp/adapter-pgsql 3.5.1 → 5.0.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,11 +1,14 @@
1
1
  import * as _dbsp_core from '@dbsp/core';
2
- import { IndexInfo, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, ExpressionRef, ModelIR as ModelIR$1, TransitionRunPersister, ExecutionCoordinator, CapabilityDescriptor } from '@dbsp/core';
2
+ import { IndexInfo, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, ExpressionRef, ModelIR as ModelIR$1, ValidatedManagedStepManifest, ExecutionCoordinator, CapabilityDescriptor } from '@dbsp/core';
3
3
  export { normalizeSQL } from '@dbsp/core';
4
4
  import * as _dbsp_types from '@dbsp/types';
5
- import { DialectCapabilities, ModelIR, ColumnListInput, ParamIntent, JsonAggOrderByEntry, IndexIR, HierarchyIR, Adapter, DbCasing, AdapterLogger, AdapterCapabilities, ConnectionAvailability, PlanReport, CompiledNqlQuery, CompileOptions, CompiledQuery, CompileResultWithIncludes, SubqueryIncludeInfo, ExpressionIntent, InsertIntent, InsertFromIntent, UpdateIntent, BatchUpdateIntent, DeleteIntent, UpsertIntent, UpsertFromIntent, RecursivePlanReport, CteQueryIntent, SetOperationIntent, DumpMeta, Dump, AdapterStreamOptions, PinnedConnectionOptions, TransactionOptions, ColumnIR, MutationReturningItem, WhereIntent, OutputDescriptor, QueryIntent, OperationKindRef, SemanticArtifactRef, ProvenPlanShape, PostgreSqlObservationTargetIdentity, ExecutionContract, TransitionSessionClient, TransitionRunJournal, TransitionLessor, ObservationIssuer, ObservationRequest, ObservationContext, EvidenceObservation, TypeRef, ExpressionValue, CollationRef, LogicalIdentity, PhysicalOperation, OperationEffectAssessment, FingerprintManifest, DurableIntentRecord, IssuedObservation, ApplyGuard, AdvisoryObservation, TransactionalCompletionRecord, StepJournal, UnsafeNativeFragment, ResourceAddress, ExecutableAssertion, Assumption, TransitionRule, TransitionCompositionFact, TrustRoot, RequiredEnumLabelIR } from '@dbsp/types';
5
+ import { DialectCapabilities, ModelIR, ColumnListInput, ParamIntent, JsonAggOrderByEntry, IndexIR, HierarchyIR, Adapter, DbCasing, AdapterLogger, AdapterCapabilities, ConnectionAvailability, PlanReport, CompiledNqlQuery, CompileOptions, CompiledQuery, CompileResultWithIncludes, SubqueryIncludeInfo, ExpressionIntent, InsertIntent, InsertFromIntent, UpdateIntent, BatchUpdateIntent, DeleteIntent, UpsertIntent, UpsertFromIntent, RecursivePlanReport, CteQueryIntent, SetOperationIntent, DumpMeta, Dump, AdapterStreamOptions, PinnedConnectionOptions, TransactionOptions, ColumnIR, MutationReturningItem, WhereIntent, OutputDescriptor, QueryIntent, LedgerHome, LedgerAddress, LedgerPayload, ScopedApprovalSet, NormalizedManagedStep, LedgerChainMember, OperationKindRef, SemanticArtifactRef, ProvenPlanShape, PostgreSqlObservationTargetIdentity, ExecutionContract, TransitionSessionClient, TransitionLessor, ExclusiveTransitionTarget, ObservationIssuer, ObservationRequest, ObservationContext, EvidenceObservation, TypeRef, ExpressionValue, CollationRef, LogicalIdentity, PhysicalOperation, OperationEffectAssessment, FingerprintManifest, DurableIntentRecord, IssuedObservation, ApplyGuard, AdvisoryObservation, TransactionalCompletionRecord, StepJournal, UnsafeNativeFragment, ResourceAddress, ExecutableAssertion, Assumption, TransitionRule, TransitionCompositionFact, TrustRoot, RequiredEnumLabelIR, TableReaddressDeclaration, LedgerReservationRow, LedgerRefusal, ContainmentClosureDestructiveOutcome, LedgerClaimKind } from '@dbsp/types';
6
6
  import * as _pgsql_types from '@pgsql/types';
7
7
  import { Node, OnConflictClause, ParamRef } from '@pgsql/types';
8
+ import { C as ChangeKind, a as CompareSchemataOptions, S as SchemaDiff, T as TransitionJournalQueryable, P as PgLockedRun, b as PgOutcomeCheckpointObserver } from './outcome-protocol-CACJDzli.js';
9
+ export { D as DiffSummary, E as ExpressionCanonicalizationUnavailableError, G as GeneratedPostcondition, c as GeneratedPostconditionBindingAddress, d as GeneratedPostconditionBindingResolutionError, e as GeneratedPostconditionProofInFlightError, f as GeneratedPostconditionReplanRequiredError, g as GeneratedPostconditionSession, h as GeneratedPostconditionSessionDeactivatedError, i as GeneratedPostconditionWorkInFlightError, j as PG_LEDGER_SHAPE_VERSION, k as PgAdmittedOperation, l as PgAdmittedOperationResult, m as PgCatalogueIdentityQueryable, n as PgLedgerLockResult, o as PgLedgerScopeCurrency, p as PgLedgerStorageUnsupportedError, q as PgLedgerTarget, r as PgOutcomeCheckpoint, s as PgOutcomeClaimRequest, t as PgOutcomeExecutionRequest, u as PgOutcomeNonTransactionalRequest, v as PgOutcomeReadBackFactory, w as PgOutcomeRecoveryRequest, x as PgOutcomeRecoveryResult, y as PgOutcomeResolution, z as PgOutcomeResolutionAppendResult, A as PgOutcomeResult, B as PgOutcomeTransactionalRequest, F as PgReinitializePreflightOptions, H as PgReinitializePreflightPool, I as SchemaChange, J as TransitionRunIdentityMismatchError, K as acquirePgLedgerLocks, L as appendIntentJournal, M as appendTransitionAuthorization, N as assertDeclarableChangeKind, O as assertGeneratedPostconditionSession, Q as compareSchemata, R as createPgTransitionRunPersister, U as createPgsqlGeneratedManagedStep, V as decodeGeneratedPostcondition, W as decodeGeneratedPostconditionPayload, X as ensureDbspMetaLedger, Y as ensurePgLedger, Z as ensurePgLedgerStorageVersion, _ as ensureTransitionJournal, $ as executePgAdmittedOperation, a0 as generatedPostconditionDigest, a1 as generatedPostconditionForChange, a2 as readPgCatalogueIdentity, a3 as readPgLedgerMarker, a4 as readPgLedgerReservationsForExecution, a5 as readPgLedgerScopeCurrency, a6 as readPgOutcomeRecoveryReadBack, a7 as readTransitionJournal, a8 as readVerifiedPgLedgerReservationsForPair, a9 as recordPgLedgerIdentity, aa as renderCreateDbspMetaSchemaSql, ab as renderCreateLedgerEventTableSql, ac as renderCreateLedgerIdentityTableSql, ad as renderCreateLedgerImmutabilityFunctionSql, ae as renderCreateLedgerImmutabilityTriggerSql, af as renderCreateLedgerMarkerTableSql, ag as renderCreateLedgerReservationTableSql, ah as renderCreateLedgerTerminalMemberIndexSql, ai as renderCreateTransitionAuthorizationTableSql, aj as renderCreateTransitionJournalTableSql, ak as renderCreateTransitionRunPlanTableSql, al as renderCreateTransitionRunTableSql, am as runPgReinitializePreflight, an as toGeneratedPostconditionBindingAddress, ao as validatePgLedgerRuntimeIntegrity, ap as verifyGeneratedCheckPostcondition, aq as verifyGeneratedColumnPostcondition, ar as verifyGeneratedIdentityPostcondition, as as verifyGeneratedIndexPostcondition, at as verifyGeneratedTablePostcondition, au as withGeneratedPostconditionSession } from './outcome-protocol-CACJDzli.js';
8
10
  import { Pool, PoolClient } from 'pg';
11
+ import '@dbsp/core/internal';
9
12
 
10
13
  /**
11
14
  * Default primary key column name used as convention fallback
@@ -290,6 +293,8 @@ interface WhereHandler {
290
293
  }
291
294
  /**
292
295
  * Dispatcher for recursive WHERE compilation.
296
+ * The same function object may be passed to every level of a recursive compilation, so it is an opaque callback.
297
+ * Handlers must not use its identity to distinguish frames or carry frame-local state.
293
298
  */
294
299
  type WhereDispatcher = (decision: Decision, ctx: CompilerContext, state: CompilerState) => Node;
295
300
  /**
@@ -728,6 +733,8 @@ declare class PlanCompiler {
728
733
  */
729
734
  declare function compilePlan(plan: SimplifiedPlanReport, options?: CompilerOptions): CompiledResult;
730
735
 
736
+ declare function dbTypesEqual(a: string, b: string): boolean;
737
+
731
738
  type IndexRenderKey = {
732
739
  readonly column?: string | undefined;
733
740
  readonly expression?: string | undefined;
@@ -744,6 +751,8 @@ type IndexRenderSpec = {
744
751
  readonly nullsNotDistinct?: boolean | undefined;
745
752
  readonly with?: Readonly<Record<string, unknown>> | undefined;
746
753
  readonly where?: string | undefined;
754
+ /** The in-process index value that owns a deparsed `where` predicate. */
755
+ readonly whereSource?: IndexIR | undefined;
747
756
  readonly concurrently?: boolean | undefined;
748
757
  readonly ifNotExists?: boolean | undefined;
749
758
  };
@@ -803,7 +812,7 @@ interface GenerateDDLOptions {
803
812
  * @returns Array of DDL statements in dependency order
804
813
  */
805
814
  declare function generateDDL(schema: ModelIR, options?: GenerateDDLOptions): string[];
806
- declare function generateCreateIndex(tableName: string, idx: IndexIR, schemaName: string | undefined, naming: NamingPlugin, context?: IndexCapabilityContext): string;
815
+ declare function generateCreateIndex(tableName: string, idx: IndexIR, schemaName: string | undefined, naming: NamingPlugin, context?: IndexCapabilityContext, ifNotExists?: boolean): string;
807
816
  /**
808
817
  * Returns whether the PostgreSQL DDL generator can emit this IndexIR.
809
818
  *
@@ -813,6 +822,25 @@ declare function generateCreateIndex(tableName: string, idx: IndexIR, schemaName
813
822
  */
814
823
  declare function canGenerateCreateIndex(tableName: string, idx: IndexIR, schemaName?: string | undefined, naming?: NamingPlugin): boolean;
815
824
 
825
+ /** EFF-04's closed generated-mutation result domain. */
826
+ type GeneratedMutationClassification = 'non-destructive' | 'removal' | 'data-destructive'
827
+ /** A table rename is executed only by the paired re-address protocol. */
828
+ | 'paired-readdress';
829
+ /**
830
+ * Total, fail-closed classifier for generator mutations. `string` is deliberate:
831
+ * a newly-added ChangeKind cannot silently become safe before this table names it.
832
+ */
833
+ declare function classifyGeneratedMutation(kind: ChangeKind | string, change?: {
834
+ readonly destructive?: boolean;
835
+ }): GeneratedMutationClassification;
836
+ declare function isGeneratedMutationDestructive(kind: ChangeKind | string, change?: {
837
+ readonly destructive?: boolean;
838
+ }): boolean;
839
+ /** All removal statements remain generator-only; no transition operation maps one. */
840
+ declare function refusesRecordedPlanRemoval(kind: ChangeKind | string, change?: {
841
+ readonly destructive?: boolean;
842
+ }): boolean;
843
+
816
844
  /**
817
845
  * PostgreSQL Schema Introspection (ADAPTER-006)
818
846
  *
@@ -957,6 +985,23 @@ declare class PgsqlTransactionTimeoutError extends Error {
957
985
  readonly dbspTransactionTimeout = true;
958
986
  constructor(cause: unknown, timeout: PgsqlTransactionTimeoutParameter);
959
987
  }
988
+ /**
989
+ * Raised when the single safe unnamed replay after a prepared-statement
990
+ * infrastructure failure also fails. `message` is always the safe constant
991
+ * `Prepared statement recovery replay failed.`; `cause` is the replay error;
992
+ * `infrastructureError` is the original infrastructure error; and
993
+ * `admissionFingerprint` identifies the admitted statement. DBSP-authored
994
+ * messages carry no parameter values; preserved upstream errors, including the
995
+ * standard Error `cause`, are unsanitized.
996
+ */
997
+ declare class PgsqlPreparedStatementReplayError extends Error {
998
+ readonly admissionFingerprint: string;
999
+ readonly infrastructureError: unknown;
1000
+ readonly dbspPreparedStatementReplay = true;
1001
+ readonly originalInfrastructureError: unknown;
1002
+ readonly originalError: unknown;
1003
+ constructor(admissionFingerprint: string, infrastructureError: unknown, cause: unknown);
1004
+ }
960
1005
  /**
961
1006
  * Options for PgsqlAdapter.
962
1007
  */
@@ -988,10 +1033,45 @@ interface PgsqlAdapterOptions {
988
1033
  */
989
1034
  readonly preparedStatements?: boolean | PgsqlPreparedStatementsOptions;
990
1035
  }
991
- interface PgsqlPoolAdapterOptions extends PgsqlAdapterOptions {
1036
+ interface PgsqlPoolAdapterOptionsBase extends PgsqlAdapterOptions {
992
1037
  readonly borrowedClient?: false;
993
1038
  }
1039
+ type PgsqlPoolAdapterOptions = (PgsqlPoolAdapterOptionsBase & {
1040
+ readonly replayInvalidatedPlans?: false | undefined;
1041
+ }) | (Omit<PgsqlPoolAdapterOptionsBase, 'preparedStatements'> & {
1042
+ readonly preparedStatements: true | PgsqlPreparedStatementsOptions;
1043
+ /**
1044
+ * Enable one unnamed replay after `0A000`/`RevalidateCachedQuery` only when
1045
+ * you assert that your statements do not invoke functions performing
1046
+ * effectful work before nested prepared-statement operations. This requires
1047
+ * `preparedStatements: true` (or a prepared-statements options object).
1048
+ *
1049
+ * Replay snapshots JSON-like values (finite numbers, strings, booleans,
1050
+ * `null`, arrays, plain or null-prototype objects) and clean `Date`/`Buffer`
1051
+ * instances. It excludes non-finite numbers, `undefined`, `bigint`, functions,
1052
+ * proxies, cycles, sparse arrays, accessors, symbol-valued
1053
+ * parameters, symbol keys on plain objects, exotic prototypes, custom built-ins,
1054
+ * and values with their own node-postgres
1055
+ * `toPostgres` behavior.
1056
+ * Serialization-irrelevant symbol metadata on arrays and Buffers is ignored.
1057
+ * The detached snapshot covers later mutations to the supplied value graph,
1058
+ * not built-in prototypes, timezone state, or node-postgres serialization
1059
+ * configuration; a process-global `toPostgres` or `toJSON` installed while
1060
+ * the call is in flight is outside the guarantee. Each capture or replay copy
1061
+ * is independently limited to 64 Ki visited values, 16 MiB of UTF-8 strings,
1062
+ * and 16 MiB of Buffer data. An ineligible or over-budget value still receives
1063
+ * the initial named submission, but disables transparent replay.
1064
+ * These budgets bound copied nodes and payload bytes; enumerating a plain
1065
+ * object's existing property table is proportional to the caller's own object.
1066
+ *
1067
+ * Replay needs the adapter-owned serialized physical client available from a
1068
+ * pool; it is therefore not supported by borrowed or compile-only adapters.
1069
+ */
1070
+ readonly replayInvalidatedPlans: true;
1071
+ });
994
1072
  interface PgsqlBorrowedClientAdapterOptions extends PgsqlAdapterOptions {
1073
+ /** Replay is only available to a pool-owned pinned scope. */
1074
+ readonly replayInvalidatedPlans?: never;
995
1075
  /** This connection belongs to the caller. dbsp never releases it. */
996
1076
  readonly borrowedClient: true;
997
1077
  /**
@@ -1021,6 +1101,10 @@ interface PgsqlBorrowedClientAdapterOptions extends PgsqlAdapterOptions {
1021
1101
  */
1022
1102
  readonly managedTransactions?: true;
1023
1103
  }
1104
+ /** Options for a connectionless adapter, which cannot own replay serialization. */
1105
+ interface PgsqlCompileOnlyAdapterOptions extends PgsqlAdapterOptions {
1106
+ readonly replayInvalidatedPlans?: never;
1107
+ }
1024
1108
  /**
1025
1109
  * Adapter implementation for PostgreSQL using native pg driver.
1026
1110
  *
@@ -1051,6 +1135,7 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1051
1135
  private readonly naming;
1052
1136
  private readonly model;
1053
1137
  private readonly logger;
1138
+ private readonly replayInvalidatedPlans;
1054
1139
  private readonly preparedStatements;
1055
1140
  private readonly preparedStatementRegistry;
1056
1141
  private readonly _capabilities;
@@ -1068,10 +1153,9 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1068
1153
  * or nothing at all for compile-only mode
1069
1154
  * @param options - configuration; declares connection ownership
1070
1155
  */
1071
- constructor(pool?: Pool | undefined, options?: PgsqlPoolAdapterOptions);
1072
1156
  constructor(pool: Pool, options?: PgsqlPoolAdapterOptions);
1073
1157
  constructor(client: PoolClient, options: PgsqlBorrowedClientAdapterOptions);
1074
- constructor(pool: undefined, options?: PgsqlAdapterOptions);
1158
+ constructor(pool?: undefined, options?: PgsqlCompileOnlyAdapterOptions);
1075
1159
  /**
1076
1160
  * Shared compilation dependencies — built lazily from adapter fields.
1077
1161
  * Passed to compiler sub-modules instead of `this`.
@@ -1096,6 +1180,8 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1096
1180
  get capabilities(): AdapterCapabilities;
1097
1181
  /** Per-instance connection state, distinct from PostgreSQL capabilities. */
1098
1182
  get connectionAvailability(): ConnectionAvailability;
1183
+ /** Side-effect-free execution availability for core feature detection. */
1184
+ executionAvailable(): boolean;
1099
1185
  /** PostgreSQL dialect capabilities for planner strategy selection */
1100
1186
  get dialectCapabilities(): DialectCapabilities;
1101
1187
  /**
@@ -1104,6 +1190,13 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1104
1190
  get dbCasing(): DbCasing;
1105
1191
  /**
1106
1192
  * Get the underlying pg Pool or borrowed PoolClient instance.
1193
+ *
1194
+ * Exposing raw access from a pool-owned dbsp-managed scope permanently taints that
1195
+ * physical client: external callers can queue commands outside dbsp's statement
1196
+ * lock, so replay is disabled and dbsp destroys the client at scope release.
1197
+ * Expect pool churn; session state on that exposed connection does not survive the
1198
+ * release. A borrowed client remains caller-owned: dbsp never releases it, and the
1199
+ * caller decides its fate after raw exposure.
1107
1200
  */
1108
1201
  getPoolInstance(): Pool | PoolClient;
1109
1202
  /**
@@ -1210,8 +1303,8 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1210
1303
  * Execute a query and return rows plus PostgreSQL result metadata.
1211
1304
  * Results are transformed to use model naming convention (e.g., snake_case → camelCase)
1212
1305
  */
1213
- executeWithMeta<T = unknown>(query: CompiledQuery<T>): Promise<{
1214
- readonly rows: T[];
1306
+ executeWithMeta(query: CompiledQuery): Promise<{
1307
+ readonly rows: readonly unknown[];
1215
1308
  readonly rowCount: number;
1216
1309
  readonly command?: string;
1217
1310
  }>;
@@ -1425,6 +1518,13 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1425
1518
  get inTransaction(): boolean;
1426
1519
  private adapterManagedScopeIsLive;
1427
1520
  private shouldProtectBorrowedClientTransaction;
1521
+ /**
1522
+ * An idle ReadyForQuery status says nothing about commands another owner has
1523
+ * already queued on a PoolClient. Only a dbsp-created pinned scope both owns
1524
+ * the checked-out physical client and holds its statement lock across the
1525
+ * failed named execution and any unnamed replay.
1526
+ */
1527
+ private ownsSerializedClientForPreparedStatementReplay;
1428
1528
  private executeQueryProtectingOpenTransaction;
1429
1529
  private executeConnectionStatement;
1430
1530
  private executeConnectionStatementUnlocked;
@@ -1539,7 +1639,7 @@ declare function createPgsqlAdapter<DB = unknown>(client: PoolClient, options: P
1539
1639
  * console.log(dump.sql);
1540
1640
  * ```
1541
1641
  */
1542
- declare function createPgsqlCompileOnlyAdapter<DB = unknown>(options?: PgsqlAdapterOptions): PgsqlAdapter<DB>;
1642
+ declare function createPgsqlCompileOnlyAdapter<DB = unknown>(options?: PgsqlCompileOnlyAdapterOptions): PgsqlAdapter<DB>;
1543
1643
 
1544
1644
  interface CheckConstraintCanonicalizationWarning {
1545
1645
  readonly table: string;
@@ -1561,7 +1661,18 @@ interface ColumnDefaultCanonicalizationWarning {
1561
1661
  /** Present when the default could not be paired with the opposite model side. */
1562
1662
  readonly side?: 'desired' | 'database';
1563
1663
  }
1564
- type ExpressionCanonicalizationWarning = CheckConstraintCanonicalizationWarning | ColumnDefaultCanonicalizationWarning;
1664
+ interface IndexPredicateCanonicalizationWarning {
1665
+ readonly table: string;
1666
+ readonly kind: 'index_predicate';
1667
+ readonly name: string;
1668
+ readonly message: string;
1669
+ readonly cause: unknown;
1670
+ readonly outcome: 'unavailable' | 'rejected' | 'refused';
1671
+ /** Predicate fallback always compares both complete models raw. */
1672
+ readonly comparison: 'raw';
1673
+ readonly side?: 'desired' | 'database';
1674
+ }
1675
+ type ExpressionCanonicalizationWarning = CheckConstraintCanonicalizationWarning | ColumnDefaultCanonicalizationWarning | IndexPredicateCanonicalizationWarning;
1565
1676
  interface CanonicalizeCheckConstraintsOptions {
1566
1677
  /** Database schema that owns the target tables and target-scoped enum types. */
1567
1678
  readonly schemaName?: string;
@@ -1573,6 +1684,8 @@ interface CanonicalizeCheckConstraintsOptions {
1573
1684
  readonly requireCanonicalization?: boolean;
1574
1685
  /** Skip CHECK scratch work when the caller's dialect does not support CHECK DDL. */
1575
1686
  readonly canonicalizeCheckConstraints?: boolean;
1687
+ /** Capabilities used to generate the migration this scope is staging for. */
1688
+ readonly dialectCapabilities?: DialectCapabilities;
1576
1689
  }
1577
1690
  declare class CheckConstraintCanonicalizationError extends Error {
1578
1691
  readonly table: string;
@@ -1591,108 +1704,11 @@ declare class ColumnDefaultCanonicalizationError extends Error {
1591
1704
  */
1592
1705
  declare function canonicalizeCheckConstraints(adapter: RollbackOnlyPgsqlScope, desired: ModelIR, dbModel: ModelIR, options?: CanonicalizeCheckConstraintsOptions): Promise<ModelIR>;
1593
1706
 
1594
- /**
1595
- * Schema Comparison Engine (DDL-PROV Block 1)
1596
- *
1597
- * Compares two ModelIRs (schema definition vs database state)
1598
- * and produces a structured diff of changes needed.
1599
- *
1600
- * @module schema-diff
1601
- */
1602
-
1603
- type ChangeKind = 'create_table' | 'drop_table' | 'add_column' | 'drop_column' | 'alter_column_type' | 'alter_column_nullable' | 'alter_column_default' | 'alter_column_unique' | 'add_primary_key' | 'drop_primary_key' | 'add_foreign_key' | 'drop_foreign_key' | 'alter_foreign_key' | 'validate_constraint' | 'create_index' | 'drop_index' | 'add_check_constraint' | 'drop_check_constraint' | 'create_enum' | 'alter_enum_add_value' | 'drop_enum' | 'alter_column_collation' | 'alter_column_identity' | 'add_comment' | 'drop_comment' | 'create_extension' | 'drop_extension' | 'create_sequence' | 'alter_sequence' | 'drop_sequence' | 'enable_rls' | 'disable_rls' | 'create_policy' | 'drop_policy';
1604
- interface SchemaChange {
1605
- readonly kind: ChangeKind;
1606
- readonly table: string;
1607
- readonly column?: string;
1608
- readonly destructive: boolean;
1609
- readonly details: string;
1610
- /** Additional metadata for SQL generation */
1611
- readonly meta?: Readonly<Record<string, unknown>>;
1612
- }
1613
- interface DiffSummary {
1614
- readonly tables: {
1615
- readonly added: number;
1616
- readonly dropped: number;
1617
- };
1618
- readonly columns: {
1619
- readonly added: number;
1620
- readonly dropped: number;
1621
- readonly altered: number;
1622
- };
1623
- readonly indexes: {
1624
- readonly added: number;
1625
- readonly dropped: number;
1626
- };
1627
- readonly constraints: {
1628
- readonly added: number;
1629
- readonly dropped: number;
1630
- readonly altered: number;
1631
- };
1632
- }
1633
- interface SchemaDiff {
1634
- readonly changes: readonly SchemaChange[];
1635
- readonly hasDestructive: boolean;
1636
- readonly summary: DiffSummary;
1637
- }
1638
- interface CompareSchemataOptions {
1639
- /**
1640
- * Database naming convention.
1641
- * When set, schema model names (camelCase) are converted to DB format
1642
- * (e.g. snake_case) before comparison with the introspected model.
1643
- */
1644
- dbCasing?: DbCasing;
1645
- /** Dialect capabilities — comparisons for unsupported features will be skipped */
1646
- readonly dialectCapabilities?: DialectCapabilities;
1647
- /**
1648
- * When `true`, extensions present in the live DB but absent from the model
1649
- * schema are silently ignored — no `drop_extension` change is emitted for them.
1650
- * Only extensions explicitly declared in the model are managed (created if missing).
1651
- *
1652
- * Use this when the database image pre-installs extensions that the application
1653
- * schema does not own (e.g. pgvector, pg_search bundled in a custom Postgres image).
1654
- * Default: `false` (full-sync behaviour — unmanaged DB extensions produce a
1655
- * `drop_extension` entry).
1656
- */
1657
- readonly ignoreUnmanagedExtensions?: boolean;
1658
- /**
1659
- * Strict compile-only mode for callers that require convergence guarantees.
1660
- *
1661
- * `compareSchemata()` is intentionally pure and cannot ask PostgreSQL to
1662
- * canonicalise raw-SQL expression surfaces. By default it keeps the historic
1663
- * best-effort verbatim comparison for column defaults, CHECK expressions,
1664
- * partial-index predicates, and index expressions. Set this flag to throw when either model
1665
- * contains one of those surfaces so a caller cannot accidentally rely on a
1666
- * compile-only diff for a convergence-sensitive check.
1667
- *
1668
- * Live PostgreSQL callers should use `comparePgsqlDatabaseSchema()`, which
1669
- * canonicalises CHECK constraint expressions and column defaults before calling this function.
1670
- * Under that live mode, every default surface considered under this option is
1671
- * either canonicalised as a pair or explicitly refused. This does not prove
1672
- * that the resulting migration is executable.
1673
- * Partial-index predicates and index expressions are not canonicalised by the
1674
- * live helper and are rejected there when this strict flag is set.
1675
- */
1676
- readonly requireExpressionCanonicalization?: boolean;
1677
- }
1678
- declare class ExpressionCanonicalizationUnavailableError extends Error {
1679
- readonly surfaces: readonly string[];
1680
- constructor(surfaces: readonly string[]);
1681
- }
1682
- /**
1683
- * Compare two ModelIRs and produce a structured diff.
1684
- *
1685
- * @param schema - The desired schema (from definition)
1686
- * @param db - The current database state (from introspection)
1687
- * @param options - Optional comparison settings (e.g. dbCasing)
1688
- * @returns SchemaDiff with all changes needed to bring DB in sync with schema
1689
- */
1690
- declare function compareSchemata(schema: ModelIR, db: ModelIR, options?: CompareSchemataOptions): SchemaDiff;
1691
-
1692
1707
  interface ComparePgsqlDatabaseSchemaOptions extends CompareSchemataOptions, SchemaScopeOptions {
1693
1708
  /**
1694
- * Whether to canonicalise PostgreSQL CHECK constraint expressions and column defaults before
1695
- * comparing. Defaults to `true`. Set to `false` only for compatibility with
1709
+ * Whether to canonicalise PostgreSQL CHECK constraint expressions, column defaults, and predicates on column-keyed
1710
+ * partial indexes before comparing. Defaults to `true`. Expression-keyed
1711
+ * partial-index predicates are reported as unavailable. Set to `false` only for compatibility with
1696
1712
  * legacy raw-string live diffs.
1697
1713
  *
1698
1714
  * Live canonicalisation creates temporary scratch tables inside an adapter
@@ -1710,7 +1726,7 @@ interface ComparePgsqlDatabaseSchemaOptions extends CompareSchemataOptions, Sche
1710
1726
  readonly onExpressionCanonicalizationWarning?: (warning: ExpressionCanonicalizationWarning) => void;
1711
1727
  /**
1712
1728
  * Diff that the caller just applied before this live re-diff. Used only when
1713
- * CHECK expressions or column defaults are compared by raw text to fail loudly if the exact same
1729
+ * expression surfaces are compared by raw text to fail loudly if the exact same
1714
1730
  * expression-surface drift appears again after re-introspection.
1715
1731
  */
1716
1732
  readonly previouslyAppliedDiff?: SchemaDiff;
@@ -1739,12 +1755,61 @@ declare class CheckConstraintNewEnumValueError extends Error {
1739
1755
  readonly table: string;
1740
1756
  readonly constraint: string;
1741
1757
  readonly addedEnumValues: readonly AddedEnumValue[];
1742
- readonly surfaceKind: 'CHECK constraint' | 'column default';
1743
- constructor(table: string, constraint: string, addedEnumValues: readonly AddedEnumValue[], surfaceKind?: 'CHECK constraint' | 'column default');
1758
+ constructor(table: string, constraint: string, addedEnumValues: readonly AddedEnumValue[]);
1759
+ }
1760
+ /** A raw partial-index predicate and added enum values cannot share one migration. */
1761
+ declare class PartialIndexPredicateNewEnumValueError extends Error {
1762
+ readonly addedEnumValues: readonly AddedEnumValue[];
1763
+ constructor(addedEnumValues: readonly AddedEnumValue[]);
1764
+ }
1765
+ /** #454: Predicate canonicalization is not implemented for indexes with expression keys. */
1766
+ declare class ExpressionKeyedIndexPredicateCanonicalizationUnsupportedError extends Error {
1767
+ readonly predicates: readonly {
1768
+ readonly side: 'desired' | 'database';
1769
+ readonly table: string;
1770
+ readonly index: string;
1771
+ }[];
1772
+ constructor(predicates: readonly {
1773
+ readonly side: 'desired' | 'database';
1774
+ readonly table: string;
1775
+ readonly index: string;
1776
+ }[]);
1777
+ }
1778
+ /**
1779
+ * A raw partial-index predicate cannot be proven to converge after PostgreSQL
1780
+ * deparses it, so emitting its CREATE statement is unsafe.
1781
+ */
1782
+ declare class RawIndexPredicateFallbackError extends Error {
1783
+ constructor(cause?: unknown);
1784
+ }
1785
+ declare class IndexPredicateCanonicalizationError extends Error {
1786
+ readonly rejectedPredicates: readonly {
1787
+ readonly side: 'desired' | 'database';
1788
+ readonly table: string;
1789
+ readonly index: string;
1790
+ readonly reason?: unknown;
1791
+ }[];
1792
+ /**
1793
+ * Enum values added by this migration are diagnostic candidates only. They
1794
+ * are collected from the schema diff, never matched to a rejected index.
1795
+ */
1796
+ readonly addedEnumValues: readonly AddedEnumValue[];
1797
+ constructor(rejectedPredicates: readonly {
1798
+ readonly side: 'desired' | 'database';
1799
+ readonly table: string;
1800
+ readonly index: string;
1801
+ readonly reason?: unknown;
1802
+ }[],
1803
+ /**
1804
+ * Enum values added by this migration are diagnostic candidates only. They
1805
+ * are collected from the schema diff, never matched to a rejected index.
1806
+ */
1807
+ addedEnumValues?: readonly AddedEnumValue[]);
1744
1808
  }
1745
1809
  /**
1746
1810
  * Live PostgreSQL schema diff: introspect, canonicalise desired CHECK
1747
- * constraint expressions and column defaults through PostgreSQL, then call the pure synchronous
1811
+ * constraint expressions, column defaults, and predicates on column-keyed
1812
+ * partial indexes through PostgreSQL, then call the pure synchronous
1748
1813
  * schema comparator.
1749
1814
  *
1750
1815
  * If CHECK canonicalisation falls back while the same diff adds a plausibly
@@ -1754,9 +1819,9 @@ declare class CheckConstraintNewEnumValueError extends Error {
1754
1819
  * that cannot run. Apply the enum addition by itself first, then add or update
1755
1820
  * the CHECK constraint in a later migration.
1756
1821
  *
1757
- * Partial-index predicates and index expressions are intentionally not
1758
- * canonicalised here; non-strict diffs compare them by raw string, and strict
1759
- * diffs reject them.
1822
+ * Index expressions are intentionally not canonicalised here; partial-index
1823
+ * predicates on expression-keyed indexes are reported as unavailable and are
1824
+ * therefore rejected by strict mode. They need their own key-shape substrate.
1760
1825
  */
1761
1826
  declare function comparePgsqlDatabaseSchema(adapter: PgsqlAdapter, desired: ModelIR, options?: ComparePgsqlDatabaseSchemaOptions): Promise<SchemaDiff>;
1762
1827
  declare function assertNoRepeatedExpressionSurfaceDrift(previouslyAppliedDiff: SchemaDiff, currentDiff: SchemaDiff, rawExpressionSurfaces?: ReadonlySet<string>): void;
@@ -1816,101 +1881,6 @@ declare function generateMigrationSQL(diff: SchemaDiff, options?: MigrationSQLOp
1816
1881
  */
1817
1882
  declare function generateDownSQL(diff: SchemaDiff, options?: MigrationSQLOptions): readonly string[];
1818
1883
 
1819
- /**
1820
- * Migration File Format v2 — UP + DOWN sections.
1821
- *
1822
- * File format:
1823
- * -- dbsp:destructive: true|false
1824
- * <UP statements>;
1825
- * -- DOWN
1826
- * <DOWN statements>;
1827
- *
1828
- * The separator `-- DOWN` must be on its own line (SC-25).
1829
- *
1830
- * @module ddl/migration-file
1831
- */
1832
-
1833
- /**
1834
- * Result of parsing a migration file's UP/DOWN sections.
1835
- */
1836
- interface ParsedMigrationFile {
1837
- readonly upStatements: readonly string[];
1838
- readonly downStatements: readonly string[];
1839
- readonly hasDown: boolean;
1840
- readonly destructive?: boolean | undefined;
1841
- }
1842
- /**
1843
- * Generate a migration file content with UP and DOWN sections.
1844
- */
1845
- declare function generateMigrationFile(diff: SchemaDiff, options?: MigrationSQLOptions & {
1846
- name?: string;
1847
- }): string;
1848
- /**
1849
- * Parse a migration file into UP and DOWN sections.
1850
- * Separator: `^\s*-- DOWN\s*$` (strict regex, own line only — SC-25)
1851
- */
1852
- declare function parseMigrationFile(content: string): ParsedMigrationFile;
1853
- /**
1854
- * Check if SQL statements contain destructive operations.
1855
- * Destructive: DROP TABLE, DROP COLUMN, lossy ALTER COLUMN TYPE
1856
- */
1857
- declare function isDestructiveDown(downStatements: readonly string[]): boolean;
1858
-
1859
- /**
1860
- * Migration Tracker — `_dbsp_migrations` table CRUD.
1861
- *
1862
- * Manages the tracking table that records which migrations
1863
- * have been applied to a database.
1864
- */
1865
-
1866
- interface MigrationRecord {
1867
- /** Migration filename (e.g., "0001_create_users.sql") */
1868
- readonly name: string;
1869
- /** SHA-256 checksum of the migration file content */
1870
- readonly checksum: string;
1871
- /** When the migration was applied */
1872
- readonly appliedAt: Date;
1873
- /** Schema version at time of this migration */
1874
- readonly schemaVersion: number;
1875
- /** Whether this migration contains destructive changes */
1876
- readonly destructive: boolean;
1877
- }
1878
- /**
1879
- * Execute a callback under the migration advisory lock using a pinned client.
1880
- * The lock is held for the duration of the callback.
1881
- *
1882
- * Intentional latent-bug fix: session-level advisory locks are not freed by
1883
- * returning a PoolClient to pg's pool. If unlock fails, PgsqlAdapter destroys the
1884
- * session instead of returning a possibly lock-holding connection to the pool.
1885
- */
1886
- declare function withMigrationLock<T>(pool: Pool, fn: (client: PoolClient) => Promise<T>): Promise<T>;
1887
- /**
1888
- * Ensure the migrations tracking table exists.
1889
- * Auto-migrates existing tables that lack `schema_version`/`destructive` columns,
1890
- * and backfills `schema_version` by `applied_at` order for rows still at 0.
1891
- */
1892
- declare function ensureMigrationsTable(pool: Pool): Promise<void>;
1893
- /**
1894
- * Get all applied migrations, ordered by name.
1895
- */
1896
- declare function getAppliedMigrations(pool: Pool): Promise<readonly MigrationRecord[]>;
1897
- /**
1898
- * Record a migration as applied.
1899
- */
1900
- declare function recordMigration(pool: Pool, name: string, checksum: string, schemaVersion: number, destructive: boolean): Promise<void>;
1901
- /**
1902
- * Check if a specific migration has been applied.
1903
- */
1904
- declare function isMigrationApplied(pool: Pool, name: string): Promise<boolean>;
1905
- /**
1906
- * Get the next schema version number (max + 1, or 1 if no migrations).
1907
- */
1908
- declare function getNextSchemaVersion(pool: Pool): Promise<number>;
1909
- /**
1910
- * Remove a migration record (for rollback).
1911
- */
1912
- declare function removeMigrationRecord(pool: Pool, name: string): Promise<void>;
1913
-
1914
1884
  /**
1915
1885
  * Type Mapping - Maps ModelIR ColumnType to PostgreSQL data types
1916
1886
  *
@@ -2779,6 +2749,91 @@ declare function buildStreamingStatements(query: Node, config?: StreamConfig): {
2779
2749
  close: Node;
2780
2750
  };
2781
2751
 
2752
+ type PgAdoptionResult = {
2753
+ readonly outcome: 'completed';
2754
+ } | {
2755
+ readonly outcome: 'no-op';
2756
+ } | {
2757
+ readonly outcome: 'adoption-refused';
2758
+ readonly detail: string;
2759
+ } | {
2760
+ readonly outcome: 'execution-failed';
2761
+ readonly detail: string;
2762
+ } | {
2763
+ readonly outcome: 'recovery-required';
2764
+ readonly claimId: string;
2765
+ readonly detail: string;
2766
+ } | {
2767
+ readonly outcome: 'transport-ambiguous';
2768
+ readonly detail: string;
2769
+ };
2770
+ type PgAdoptionPreflightResult = {
2771
+ readonly outcome: 'ready';
2772
+ } | {
2773
+ readonly outcome: 'no-op';
2774
+ } | {
2775
+ readonly outcome: 'adoption-refused';
2776
+ readonly detail: string;
2777
+ } | {
2778
+ readonly outcome: 'execution-failed';
2779
+ readonly detail: string;
2780
+ };
2781
+ interface PgDeclaredAdoptionInput {
2782
+ readonly executor: TransitionJournalQueryable;
2783
+ readonly home: LedgerHome;
2784
+ readonly address: LedgerAddress;
2785
+ readonly declaration: LedgerPayload;
2786
+ /** Identity observed while the digest-covered adoption plan was reviewed. */
2787
+ readonly expectedCatalogueIdentity: NonNullable<LedgerAddress['catalogueIdentity']>;
2788
+ readonly shapeMatches: (executor: TransitionJournalQueryable) => Promise<boolean>;
2789
+ }
2790
+ interface PgPersistedDeclaredAdoptionInput extends PgDeclaredAdoptionInput {
2791
+ /** Locked durable identity and its full reviewed manifest from apply. */
2792
+ readonly run: PgLockedRun;
2793
+ readonly manifest: ValidatedManagedStepManifest;
2794
+ readonly recomputedPlanDigest: string;
2795
+ readonly approval: ScopedApprovalSet;
2796
+ /** Attempt namespace journaled before this lifecycle can open a claim. */
2797
+ readonly executionId: string;
2798
+ /** Exact digest-covered step; adoption never constructs a standalone plan. */
2799
+ readonly step: NormalizedManagedStep;
2800
+ /** Test-only admitted-path observation; absent from normal callers. */
2801
+ readonly observer?: PgOutcomeCheckpointObserver;
2802
+ }
2803
+ /**
2804
+ * Inspect a declared adoption without opening its adopt-intent claim.
2805
+ *
2806
+ * The generator executes this pass for every declared adoption before it opens
2807
+ * any claim for ordinary schema work. A changed shape or physical identity is
2808
+ * therefore reported as the actionable adoption refusal, rather than being
2809
+ * hidden behind an unrelated destructive-authority refusal.
2810
+ */
2811
+ declare function preflightPgDeclaredAdoption(input: PgDeclaredAdoptionInput): Promise<PgAdoptionPreflightResult>;
2812
+ /**
2813
+ * The caller supplies the already-established live shape comparison. This
2814
+ * adapter owns the identity read and the only append path, so a matching shape
2815
+ * can never be turned into an adoption without a live catalogue identity.
2816
+ */
2817
+ declare function executePgDeclaredAdoption(input: PgPersistedDeclaredAdoptionInput): Promise<PgAdoptionResult>;
2818
+
2819
+ interface PgLedgerAddressChain {
2820
+ readonly ledger: LedgerHome;
2821
+ readonly address: LedgerAddress;
2822
+ /** Every member is returned so the core projector can diagnose malformed chains. */
2823
+ readonly events: readonly LedgerChainMember[];
2824
+ /** Undefined means there is no unique terminal member; it is never inferred by row order. */
2825
+ readonly terminalMember?: LedgerChainMember;
2826
+ }
2827
+ /** Finds a terminal by predecessor topology only; callers must not use row position. */
2828
+ declare function findPgLedgerTerminalMember(events: readonly LedgerChainMember[]): LedgerChainMember | undefined;
2829
+ /**
2830
+ * Reads one address without imposing an insertion order. The resulting full
2831
+ * chain feeds the core projection, which owns all lifecycle interpretation.
2832
+ */
2833
+ declare function readPgLedgerAddressChain(executor: TransitionJournalQueryable, ledger: LedgerHome, address: LedgerAddress): Promise<PgLedgerAddressChain>;
2834
+ /** Read the durable PostgreSQL role identity for the selected terminal event. */
2835
+ declare function readPgLedgerControllerOid(executor: TransitionJournalQueryable, ledger: LedgerHome, address: LedgerAddress, eventId: string): Promise<string>;
2836
+
2782
2837
  declare const PG_OPERATION_PACK_ARTIFACT: SemanticArtifactRef;
2783
2838
  declare const PG_RULE_PACK_ARTIFACT: SemanticArtifactRef;
2784
2839
  declare const PG_INTROSPECTION_ARTIFACT: SemanticArtifactRef;
@@ -2794,6 +2849,11 @@ declare const DBSP_META_SCHEMA = "dbsp_meta";
2794
2849
  declare const DBSP_TRANSITION_RUN_TABLE = "dbsp_transition_run";
2795
2850
  declare const DBSP_TRANSITION_RUN_PLAN_TABLE = "dbsp_transition_run_plan";
2796
2851
  declare const DBSP_TRANSITION_JOURNAL_TABLE = "dbsp_transition_journal";
2852
+ declare const DBSP_TRANSITION_AUTHORIZATION_TABLE = "dbsp_transition_authorization";
2853
+ declare const DBSP_LEDGER_EVENT_TABLE = "dbsp_ledger_event";
2854
+ declare const DBSP_LEDGER_RESERVATION_TABLE = "dbsp_ledger_reservation";
2855
+ declare const DBSP_LEDGER_IDENTITY_TABLE = "dbsp_ledger_identity";
2856
+ declare const DBSP_LEDGER_MARKER_TABLE = "dbsp_ledger_marker";
2797
2857
  declare const DBSP_LOGICAL_IDENTITY_TABLE = "dbsp_logical_identity";
2798
2858
  declare const COLUMN_EXISTS_OBSERVATION = "postgresql.column.exists";
2799
2859
  declare const ENUM_TYPE_EXISTS_OBSERVATION = "postgresql.enum-type.exists";
@@ -2803,6 +2863,33 @@ declare const ENGINE_VERSION_OBSERVATION = "postgresql.engine.version-supported"
2803
2863
  declare const LOGICAL_IDENTITY_CARRIER_OBSERVATION = "postgresql.logical-identity.carrier-state";
2804
2864
  declare const NO_NULLS_GUARD = "NO_NULLS";
2805
2865
 
2866
+ /** The stable command outcome for a PostgreSQL target that cannot accept writes. */
2867
+ declare const DATABASE_READ_ONLY_OUTCOME: "database-read-only";
2868
+ declare class PgDatabaseReadOnlyError extends Error {
2869
+ readonly code: "database-read-only";
2870
+ constructor(detail: string);
2871
+ }
2872
+ declare function isPgDatabaseReadOnlyError(error: unknown): error is PgDatabaseReadOnlyError;
2873
+ type PgDatabaseWritability = {
2874
+ readonly kind: 'writable';
2875
+ } | {
2876
+ readonly kind: typeof DATABASE_READ_ONLY_OUTCOME;
2877
+ readonly detail: string;
2878
+ } | {
2879
+ readonly kind: 'unavailable';
2880
+ readonly detail: string;
2881
+ };
2882
+ /**
2883
+ * One PostgreSQL writability classification for every managed mutation. Both
2884
+ * a physical standby and a session made read-only by default reach the same
2885
+ * outcome; an unreadable response is deliberately not treated as writable.
2886
+ */
2887
+ declare function classifyPgDatabaseWritability(executor: TransitionJournalQueryable): Promise<PgDatabaseWritability>;
2888
+ /** Fail closed without replacing a PostgreSQL query failure's own words. */
2889
+ declare function assertPgDatabaseWritable(executor: TransitionJournalQueryable): Promise<void>;
2890
+ /** Preserve PostgreSQL's own failure words while normalizing SQLSTATE 25006. */
2891
+ declare function classifyPgWrite<T>(write: () => Promise<T>): Promise<T>;
2892
+
2806
2893
  /**
2807
2894
  * A proven operation may still be ineligible for a durable execution contract
2808
2895
  * when its reviewed requirements cannot be derived. The CLI renders this as a
@@ -2827,7 +2914,7 @@ declare function readPgExecutionTargetFromClient(target: TransitionSessionClient
2827
2914
  readonly sessionProvenance: Readonly<Record<'search_path' | 'client_encoding' | 'TimeZone', string>>;
2828
2915
  }>;
2829
2916
  /** Build the versioned canonical document once, while the plan is minted. */
2830
- declare function createPgExecutionContract(plan: ProvenPlanShape, identity: PostgreSqlObservationTargetIdentity, _sessionProvenance: Readonly<Record<'search_path' | 'client_encoding' | 'TimeZone', string>>): ExecutionContract;
2917
+ declare function createPgExecutionContract(plan: ProvenPlanShape, identity: PostgreSqlObservationTargetIdentity, sessionProvenance: Readonly<Record<'search_path' | 'client_encoding' | 'TimeZone', string>>): ExecutionContract;
2831
2918
  /** Evaluate the stored document on the leased executor, before it renders SQL. */
2832
2919
  declare function evaluatePgExecutionContract(target: TransitionSessionClient, contract: ExecutionContract): Promise<{
2833
2920
  readonly ok: true;
@@ -2836,23 +2923,39 @@ declare function evaluatePgExecutionContract(target: TransitionSessionClient, co
2836
2923
  readonly clause: string;
2837
2924
  readonly detail: string;
2838
2925
  }>;
2839
-
2840
- type QueryResultLike = {
2841
- readonly rows: readonly Record<string, unknown>[];
2842
- };
2843
- type TransitionJournalQueryable = {
2844
- query(sql: string, params?: readonly unknown[]): Promise<QueryResultLike>;
2845
- };
2846
- declare function renderCreateDbspMetaSchemaSql(): string;
2847
- declare function renderCreateTransitionRunTableSql(): string;
2848
- declare function renderCreateTransitionJournalTableSql(): string;
2849
- declare function renderCreateTransitionRunPlanTableSql(): string;
2850
- declare function ensureTransitionJournal(executor: TransitionJournalQueryable): Promise<void>;
2851
- declare function createPgTransitionRunPersister(executor: TransitionJournalQueryable): TransitionRunPersister;
2852
- declare function readTransitionJournal(executor: TransitionJournalQueryable, runId: string): Promise<TransitionRunJournal & {
2853
- readonly plan: ProvenPlanShape;
2926
+ /**
2927
+ * The durable preflight boundary. This intentionally receives a core-minted
2928
+ * leased session, so SET/SHOW and the context used by the renderer are on the
2929
+ * exact connection that subsequently records intent and executes DDL.
2930
+ */
2931
+ declare function preparePgExecutionSession(target: TransitionSessionClient, contract: ExecutionContract, plan: ProvenPlanShape): Promise<{
2932
+ readonly ok: true;
2933
+ readonly context: _dbsp_types.ObservationContext;
2934
+ } | {
2935
+ readonly ok: false;
2936
+ readonly kind: 'refused' | 'failed' | 'read-only';
2937
+ readonly detail: string;
2938
+ }>;
2939
+ /**
2940
+ * Recovery admission is intentionally narrower than apply preflight: it proves
2941
+ * only that recovery is reading the planned cluster, database and namespaces.
2942
+ * Target state may have changed, and revoked DDL authority is irrelevant to
2943
+ * classification.
2944
+ */
2945
+ declare function preparePgRecoveryAdmission(target: TransitionSessionClient, contract: ExecutionContract): Promise<{
2946
+ readonly ok: true;
2947
+ readonly context: _dbsp_types.ObservationContext;
2948
+ } | {
2949
+ readonly ok: false;
2950
+ readonly detail: string;
2854
2951
  }>;
2855
2952
 
2953
+ type PgTransitionRunLockResult<T> = {
2954
+ readonly kind: 'acquired';
2955
+ readonly value: T;
2956
+ } | {
2957
+ readonly kind: 'busy';
2958
+ };
2856
2959
  type PgTransitionClientLease = {
2857
2960
  readonly client: PoolClient;
2858
2961
  query(sql: string, params?: unknown): Promise<{
@@ -2880,8 +2983,33 @@ type PgTransitionClientLease = {
2880
2983
  * worth spending that.
2881
2984
  */
2882
2985
  declare function createPgTransitionLessor(pool: Pool): TransitionLessor;
2883
- /** Acquire a UTF-8-configured PostgreSQL client for direct planning paths. */
2986
+ /**
2987
+ * Acquire a configured PostgreSQL transition client.
2988
+ *
2989
+ * Callers that use the native adapter must pass this checked-out client with
2990
+ * `borrowedClient: true` and return it through `release()` when finished.
2991
+ */
2884
2992
  declare function acquirePgTransitionClient(pool: Pool): Promise<PgTransitionClientLease>;
2993
+ /**
2994
+ * Hold a session advisory lock on the same checked-out session used for every
2995
+ * transition segment. `pg_try_advisory_lock` makes contention an explicit
2996
+ * `busy` result rather than a hidden queue; releasing the client also releases
2997
+ * the lock if an unlock attempt itself fails.
2998
+ */
2999
+ declare function withPgTransitionRunLock<T>(pool: Pool, runId: string, callback: (target: ExclusiveTransitionTarget) => Promise<T>): Promise<PgTransitionRunLockResult<T>>;
3000
+
3001
+ type Queryable$2 = {
3002
+ query(sql: string, params?: readonly unknown[]): Promise<{
3003
+ readonly rows: readonly Record<string, unknown>[];
3004
+ }>;
3005
+ };
3006
+ /**
3007
+ * Check every existing managed ledger before ordinary apply reaches the
3008
+ * execution-contract comparison. A restored plan's physical-target clause is
3009
+ * necessarily different too, but the ledger's fresh-ledger path is the
3010
+ * actionable refusal and must win that ordering.
3011
+ */
3012
+ declare function validatePgManagedLedgerCurrency(executor: Queryable$2, plan: ProvenPlanShape): Promise<string | undefined>;
2885
3013
 
2886
3014
  type ObservationTarget = {
2887
3015
  readonly table: string;
@@ -2897,8 +3025,20 @@ type EnumObservationTarget = {
2897
3025
  };
2898
3026
  /** Acquire one lease, issue the observation, then release that lease. */
2899
3027
  declare function executePgObservationFromLessor(lessor: TransitionLessor, request: ObservationRequest, context: ObservationContext): Promise<EvidenceObservation>;
3028
+ /**
3029
+ * Read context through a caller-owned lease.
3030
+ *
3031
+ * A lease rather than anything with `query()`, for the reason given on
3032
+ * {@link executePgObservationFromClient}: this reads the server version,
3033
+ * database, role and `search_path` in sequence, and a pool would answer each
3034
+ * from a different connection.
3035
+ *
3036
+ * Internal: the supported entry point is
3037
+ * {@link readPgObservationContextFromLessor}.
3038
+ */
3039
+ declare function readPgObservationContextFromClient(target: TransitionSessionClient, schema?: string, observationTarget?: ObservationTarget | EnumObservationTarget, expectedTargetIdentity?: ObservationContext['postgresqlTargetIdentity']): Promise<ObservationContext>;
2900
3040
  /** Acquire one lease, read context, then release that lease. */
2901
- declare function readPgObservationContextFromLessor(lessor: TransitionLessor, schema?: string, observationTarget?: ObservationTarget | EnumObservationTarget, expectedTargetIdentity?: ObservationContext['postgresqlTargetIdentity']): Promise<ObservationContext>;
3041
+ declare function readPgObservationContextFromLessor(lessor: TransitionLessor | ExclusiveTransitionTarget, schema?: string, observationTarget?: ObservationTarget | EnumObservationTarget, expectedTargetIdentity?: ObservationContext['postgresqlTargetIdentity']): Promise<ObservationContext>;
2902
3042
  declare function createPgObservationIssuer(): ObservationIssuer;
2903
3043
 
2904
3044
  interface SetNotNullColumnShapeExpectation {
@@ -3084,6 +3224,19 @@ declare function createAttachLogicalIdentityOperationRuntime(): {
3084
3224
  isLockTimeout(error: unknown): boolean;
3085
3225
  };
3086
3226
 
3227
+ type QueryResultLike = {
3228
+ readonly rows: readonly Record<string, unknown>[];
3229
+ };
3230
+ type Queryable$1 = {
3231
+ query(sql: string, params?: readonly unknown[]): Promise<QueryResultLike>;
3232
+ };
3233
+ /**
3234
+ * Recovery has no authority to turn an interrupted concurrent build into an
3235
+ * outcome unless its postcondition is established. An invalid retained target
3236
+ * is deliberately reported in the operation's own admission words.
3237
+ */
3238
+ declare function assertCreateUniqueIndexConcurrentlyRecoveryNotInvalid(executor: Queryable$1, operation: PhysicalOperation): Promise<void>;
3239
+
3087
3240
  type ManualSqlPayload = {
3088
3241
  readonly statement: UnsafeNativeFragment;
3089
3242
  readonly blastRadius: readonly ResourceAddress[];
@@ -3522,6 +3675,201 @@ declare function createPgTransitionPack(options?: PgTransitionPackOptions): {
3522
3675
  satisfiesCompositionFact: typeof satisfiesPgEnumLabelVisibleCompositionFact;
3523
3676
  };
3524
3677
 
3678
+ type ReaddressRecoveryAnswer = {
3679
+ readonly kind: 'refused-pair';
3680
+ } | {
3681
+ readonly kind: 'pending-pair';
3682
+ } | {
3683
+ readonly kind: 'indeterminate-pair';
3684
+ };
3685
+ type PgReaddressPairRecoveryResult = {
3686
+ readonly kind: 'readdress-recovery-refused-pair';
3687
+ readonly pairId: string;
3688
+ } | {
3689
+ readonly kind: 'readdress-recovery-pending-pair';
3690
+ readonly pairId: string;
3691
+ readonly reason: string;
3692
+ } | {
3693
+ readonly kind: 'readdress-recovery-indeterminate-pair';
3694
+ readonly pairId: string;
3695
+ readonly reason: string;
3696
+ } | {
3697
+ readonly kind: 'readdress-recovery-transport-ambiguous-pair';
3698
+ readonly pairId: string;
3699
+ readonly reason: string;
3700
+ };
3701
+ /**
3702
+ * The pair recovery decision is deliberately tiny and exhaustive: it never
3703
+ * completes a DDL operation. A readable shape other than the original,
3704
+ * complete source closure is outside interference.
3705
+ */
3706
+ declare function classifyPgReaddressRecovery(input: {
3707
+ readonly unreadable: boolean;
3708
+ readonly completeSourceClosure: boolean;
3709
+ }): ReaddressRecoveryAnswer;
3710
+ type PgReaddressResult = {
3711
+ readonly outcome: 'completed';
3712
+ readonly pairId: string;
3713
+ } | {
3714
+ readonly outcome: 'no-op';
3715
+ } | {
3716
+ readonly outcome: 'readdress-unsupported';
3717
+ readonly detail: string;
3718
+ } | {
3719
+ readonly outcome: 'readdress-refused';
3720
+ readonly detail: string;
3721
+ } | {
3722
+ readonly outcome: 'recovery-required';
3723
+ readonly claimId: string;
3724
+ readonly detail: string;
3725
+ } | {
3726
+ readonly outcome: 'transport-ambiguous';
3727
+ readonly detail: string;
3728
+ };
3729
+ interface PgPersistedReaddressInput {
3730
+ readonly executor: TransitionJournalQueryable;
3731
+ /** The durable-run witness is locked by apply before this lifecycle starts. */
3732
+ readonly run: PgLockedRun;
3733
+ readonly manifest: ValidatedManagedStepManifest;
3734
+ readonly recomputedPlanDigest: string;
3735
+ readonly approval: ScopedApprovalSet;
3736
+ /** Attempt namespace journaled before this lifecycle can open a claim. */
3737
+ readonly executionId: string;
3738
+ /** Exact digest-covered normalized step; this is the only operation source. */
3739
+ readonly step: NormalizedManagedStep;
3740
+ readonly database: string;
3741
+ readonly targetSchema: string;
3742
+ /** Test-only admitted-path observation; absent from normal callers. */
3743
+ readonly observer?: PgOutcomeCheckpointObserver;
3744
+ }
3745
+ /**
3746
+ * The immutable DDL material attributed to one paired table re-address.
3747
+ * Recovery fixtures use this same construction when they open a real
3748
+ * readdress-intent through outcome admission.
3749
+ */
3750
+ declare function renderPgTableReaddressStatements(source: LedgerAddress, target: LedgerAddress): readonly string[];
3751
+ declare function classifyPgReaddressSupport(request: {
3752
+ readonly database: string;
3753
+ readonly targetSchema?: string;
3754
+ readonly executionId?: string;
3755
+ readonly declaration: TableReaddressDeclaration;
3756
+ }): PgReaddressResult | undefined;
3757
+ /**
3758
+ * Reconciles one interrupted re-address as one closure. Every live read is
3759
+ * complete before an append is considered, and the only closing outcome is a
3760
+ * verified refusal of the untouched source closure. Neither path issues DDL.
3761
+ */
3762
+ declare function recoverPgReaddressPair(executor: TransitionJournalQueryable, input: {
3763
+ readonly pairId: string;
3764
+ readonly executionId: string;
3765
+ readonly reservations: readonly LedgerReservationRow[];
3766
+ }): Promise<PgReaddressPairRecoveryResult>;
3767
+ /**
3768
+ * Execute the ADR 0006 pair from one exact, persisted normalized step.
3769
+ *
3770
+ * This deliberately has no direct-request form: the durable run, validated
3771
+ * manifest, digest and reviewed lifecycle material all arrive together from
3772
+ * the apply lock boundary.
3773
+ */
3774
+ declare function executePgPersistedTableReaddress(input: PgPersistedReaddressInput): Promise<PgReaddressResult>;
3775
+
3776
+ type PgReleaseResult = {
3777
+ readonly outcome: 'released';
3778
+ } | {
3779
+ /** A managed mutation must name a non-writable target before any release read. */
3780
+ readonly outcome: 'database-read-only';
3781
+ readonly detail: string;
3782
+ readonly address: LedgerAddress;
3783
+ } | {
3784
+ /** Transport/query/read-only failure; never mislabel it malformed chain. */
3785
+ readonly outcome: 'release-unavailable';
3786
+ readonly detail: string;
3787
+ readonly address: LedgerAddress;
3788
+ } | {
3789
+ readonly outcome: 'release-refused';
3790
+ readonly detail: string;
3791
+ readonly address: LedgerAddress;
3792
+ readonly refusal: LedgerRefusal;
3793
+ };
3794
+ declare function releasePgManagedAddress(input: {
3795
+ readonly executor: TransitionJournalQueryable;
3796
+ readonly home: LedgerHome;
3797
+ readonly address: LedgerAddress;
3798
+ }): Promise<PgReleaseResult>;
3799
+
3800
+ type Queryable = {
3801
+ query(sql: string, params?: readonly unknown[]): Promise<{
3802
+ readonly rows: readonly Record<string, unknown>[];
3803
+ }>;
3804
+ };
3805
+ interface PgRemovalEffectAddress {
3806
+ readonly address: LedgerAddress;
3807
+ /** Physical pg_depend identity retained for the reviewed closure digest. */
3808
+ readonly physicalIdentity?: {
3809
+ readonly classId?: string;
3810
+ readonly objectId?: string;
3811
+ readonly objectSubId?: string;
3812
+ readonly parentClassId?: string;
3813
+ readonly parentObjectId?: string;
3814
+ readonly parentObjectSubId?: string;
3815
+ readonly dependencyType?: string;
3816
+ };
3817
+ /** Extension members are accounted by their adopted extension parent only. */
3818
+ readonly extensionMember?: boolean;
3819
+ /**
3820
+ * An `i` dependency to an artifact owned by the referenced relation (row
3821
+ * type, its array type, toast relation, index, or constraint). It remains
3822
+ * cascade evidence, but is accounted by that relation rather than requiring
3823
+ * a separate ledger ownership lookup.
3824
+ */
3825
+ readonly internalOwned?: boolean;
3826
+ }
3827
+ type PgRemovalEffectsClosure = {
3828
+ readonly kind: 'all-contained-or-managed';
3829
+ readonly root: LedgerAddress;
3830
+ readonly effects: readonly PgRemovalEffectAddress[];
3831
+ readonly managedDependents: readonly LedgerAddress[];
3832
+ /** Exact, canonical cascade set admitted under the ledger locks. */
3833
+ readonly closureDigest: string;
3834
+ } | {
3835
+ readonly kind: 'reaches-unmanaged';
3836
+ readonly root: LedgerAddress;
3837
+ readonly effects: readonly PgRemovalEffectAddress[];
3838
+ readonly unmanaged: LedgerAddress;
3839
+ } | {
3840
+ readonly kind: 'undecidable';
3841
+ readonly reason: string;
3842
+ };
3843
+ /**
3844
+ * Classifies a fully enumerated cascade. Non-declarable dependent kinds refuse
3845
+ * before SQL; adopted-extension members are the sole parent-accounted carveout.
3846
+ */
3847
+ declare function classifyRemovalEffectsClosure(input: {
3848
+ readonly root: LedgerAddress;
3849
+ readonly effects: readonly PgRemovalEffectAddress[];
3850
+ readonly isManaged: (address: LedgerAddress) => boolean;
3851
+ }): PgRemovalEffectsClosure;
3852
+ /** Map closure results directly into the core authority's closed vocabulary. */
3853
+ declare function containmentAuthorityOutcome(closure: PgRemovalEffectsClosure): ContainmentClosureDestructiveOutcome;
3854
+ declare function reservationsForRemovalClosure(input: {
3855
+ readonly closure: Extract<PgRemovalEffectsClosure, {
3856
+ readonly kind: 'all-contained-or-managed';
3857
+ }>;
3858
+ readonly executionId: string;
3859
+ readonly rootClaimId: string;
3860
+ readonly claimKind?: LedgerClaimKind;
3861
+ readonly homeLedger: LedgerHome;
3862
+ }): readonly LedgerReservationRow[];
3863
+ /**
3864
+ * Enumerates PostgreSQL's dependency cascade before any destructive DDL. The
3865
+ * caller supplies ledger ownership; an unreadable catalogue is never evidence.
3866
+ */
3867
+ declare function readPgRemovalEffectsClosure(input: {
3868
+ readonly executor: Queryable;
3869
+ readonly root: LedgerAddress;
3870
+ readonly isManaged: (address: LedgerAddress) => Promise<boolean>;
3871
+ }): Promise<PgRemovalEffectsClosure>;
3872
+
3525
3873
  /**
3526
3874
  * Identifier Validation for adapter-pgsql
3527
3875
  *
@@ -3596,4 +3944,4 @@ declare function escapeDiagnosticText(value: string): string;
3596
3944
  */
3597
3945
  declare function validateSqlExpression(sql: string, context: string): void;
3598
3946
 
3599
- export { ADD_CHECK_RULE_ID, ALTER_AUTHORITY_OBSERVATION, ALTER_COLUMN_SET_NOT_NULL_OPERATION_KIND, ALTER_TYPE_ADD_VALUE_OPERATION_KIND, ATTACH_LOGICAL_IDENTITY_OPERATION_KIND, type AddedEnumValue, type AlterColumnSetNotNullPayload, type AlterTypeAddValuePayload, type AttachLogicalIdentityPayload, type BatchValuesJoinDecision, COLUMN_EXISTS_OBSERVATION, CamelCaseNamingPlugin, type CanonicalizeCheckConstraintsOptions, type ChangeKind, CheckConstraintCanonicalizationError, type CheckConstraintCanonicalizationWarning, CheckConstraintNewEnumValueError, ColumnDefaultCanonicalizationError, type ColumnDefaultCanonicalizationWarning, type ComparePgsqlDatabaseSchemaOptions, type CompareSchemataOptions, type CompiledResult, type CompilerContext, type CompilerOptions, type CompilerState, type ConflictAction, type ConflictTarget, type CursorHoldOption, type CursorOptions, type CursorScrollOption, DBSP_LOGICAL_IDENTITY_TABLE, DBSP_META_SCHEMA, DBSP_TRANSITION_JOURNAL_TABLE, DBSP_TRANSITION_RUN_PLAN_TABLE, DBSP_TRANSITION_RUN_TABLE, DEFAULT_PK_COLUMN, DEFAULT_REDACTION_PATTERNS, type Decision, type DeleteConfig, type DetectedHierarchy, type DiffSummary, ENGINE_VERSION_OBSERVATION, ENUM_ADD_VALUE_RULE_ID, ENUM_LABEL_VISIBLE_OBSERVATION, ENUM_TYPE_EXISTS_OBSERVATION, type EnumAddValueMatch, type EnumAddValueRuleOptions, type ExplainFormat, type ExplainOptions, type ExplainPlan, ExpressionCanonicalizationUnavailableError, type ExpressionCanonicalizationWarning, type ExpressionHandler, type FetchDirection, type FetchOptions, type FkColumnDerivation, type GenerateDDLOptions, type IdentityAdoptionAsserter, IdentityNamingPlugin, type IncludeHandler, type IncludeResult, type IndexCapabilityContext, IndexFeatureUnsupportedError, type IndexRenderSpec, type InsertConfig, type IntrospectedModelIR, type IntrospectionOptions, InvalidIdentifierError, type JoinDecision, LOGICAL_IDENTITY_ADOPTION_RULE_ID, LOGICAL_IDENTITY_CARRIER_OBSERVATION, type LeafCompileFn, type LogicalIdentityAdoptionMatch, type LogicalIdentityAdoptionRuleOptions, MANUAL_SQL_OPERATION_KIND, type ManualSqlPayload, type MigrationRecord, type MigrationSQLOptions, NO_NULLS_GUARD, type NamingPlugin, NonConvergentSchemaDiffError, type NonConvergentSchemaDiffSurface, PG_INTROSPECTION_ARTIFACT, PG_OPERATION_PACK_ARTIFACT, PG_RULE_PACK_ARTIFACT, type ParamRefValidationResult, type ParsedMigrationFile, type PgAdvisoryLockKey, type PgAdvisoryLockResult, PgExecutionContractDerivationError, type PgTransitionClientLease, type PgTransitionPackOptions, PgsqlAdapter, type PgsqlAdapterOptions, PgsqlAdvisoryLockOptionsError, type PgsqlBorrowedClientAdapterOptions, PgsqlPinnedConnectionAbortSignalError, type PgsqlPoolAdapterOptions, type PgsqlPreparedStatementsOptions, PgsqlRawSqlTransactionControlError, PgsqlTransactionAbortSignalError, PgsqlTransactionAbortedCommitError, PgsqlTransactionAbortedError, PgsqlTransactionOptionsError, PgsqlTransactionTimeoutError, PlanCompiler, type PlanDecision, type PrecompiledJoinDecision, type RedactionConfig, type RedactionPattern, type RollbackOnlyPgsqlScope, SET_NOT_NULL_RULE_ID, type SchemaChange, type SchemaDiff, type SchemaScopeOptions, type SetNotNullMatch, type SetNotNullRuleOptions, type SetOperationResult, type SimplifiedPlanReport, type StreamConfig, type UpdateConfig, type UpsertConfig, type WhereDispatcher, type WhereHandler, acquirePgTransitionClient, assertCreateIndexSupported, assertCreateIndexesSupported, assertNoRepeatedExpressionSurfaceDrift, bm25Search, booleanSearch, boost, buildCloseCursor, buildDeclareCursor, buildExplain, buildExplainAnalyzeJson, buildExplainPlan, buildExplainVerbose, buildFetch, buildFetchAll, buildFetchFirst, buildFetchForward, buildFetchNext, buildOnConflictClause, buildStreamingStatements, camelCaseNaming, canGenerateCreateIndex, canonicalizeCheckConstraints, collectAndValidateParamRefs, comparePgsqlDatabaseSchema, compareSchemata, compileDelete, compileInsert, compileMutation, compilePlan, compileSetOperation, compileUpdate, compileUpsert, conditionalUpdate, cosineDistance, createAlterColumnSetNotNullOperationRuntime, createAlterTypeAddValueOperationRuntime, createAnyExpr, createAttachLogicalIdentityOperationRuntime, createEnumAddValueRule, createEqualityExpr, createLeafCompileFn, createLogicalIdentityAdoptionRule, createManualSqlOperationRuntime, createParamRef, createPgExecutionContract, createPgObservationIssuer, createPgTransitionLessor, createPgTransitionPack, createPgTransitionRunPersister, createPgsqlAdapter, createPgsqlCompileOnlyAdapter, createSetNotNullRule, createTypeCastParamRef, defaultFkDerivation, derivePostgresqlCapabilitiesForVersion, ensureMigrationsTable, ensureTransitionJournal, escapeDiagnosticText, evaluatePgExecutionContract, excludedRef, executePgObservationFromLessor, generateCreateIndex, generateCursorName, generateDDL, generateDownSQL, generateMigrationFile, generateMigrationSQL, generateSeries, getAppliedMigrations, getNamingPluginForDbCasing, getNextSchemaVersion, getRowEstimates, getTotalExecutionTime, identityNaming, innerProduct, introspect, isBatchValuesJoinDecision, isDestructiveDown, isJoinDecision, isMigrationApplied, isPrecompiledJoinDecision, isReservedKeyword, l2Distance, mapColumnType, mapOnDeleteAction, nextval, normalizeManualSqlPayload, parse, parseExplainJson, parseMigrationFile, pgTargetIdentityMismatch, rawDistance, readPgExecutionTargetFromClient, readPgObservationContextFromLessor, readTransitionJournal, recordMigration, redactParams, removeMigrationRecord, renderAlterColumnSetNotNullSql, renderAlterTypeAddValueSql, renderAttachLogicalIdentityLockSql, renderCreateDbspMetaSchemaSql, renderCreateIndex, renderCreateLogicalIdentityIndexesSql, renderCreateLogicalIdentitySideTableSql, renderCreateTransitionJournalTableSql, renderCreateTransitionRunPlanTableSql, renderCreateTransitionRunTableSql, renderInsertLogicalIdentitySql, renderNoNullsCheckSql, renderSetNotNullLockSql, resolveLogicalName, sanitizeForDisplay, score, validateIdentifier, validateIdentifiers, validateParamRef, validateQualifiedIdentifier, validateSqlExpression, vectorDims, withMigrationLock };
3947
+ export { ADD_CHECK_RULE_ID, ALTER_AUTHORITY_OBSERVATION, ALTER_COLUMN_SET_NOT_NULL_OPERATION_KIND, ALTER_TYPE_ADD_VALUE_OPERATION_KIND, ATTACH_LOGICAL_IDENTITY_OPERATION_KIND, type AddedEnumValue, type AlterColumnSetNotNullPayload, type AlterTypeAddValuePayload, type AttachLogicalIdentityPayload, type BatchValuesJoinDecision, COLUMN_EXISTS_OBSERVATION, CamelCaseNamingPlugin, type CanonicalizeCheckConstraintsOptions, ChangeKind, CheckConstraintCanonicalizationError, type CheckConstraintCanonicalizationWarning, CheckConstraintNewEnumValueError, ColumnDefaultCanonicalizationError, type ColumnDefaultCanonicalizationWarning, type ComparePgsqlDatabaseSchemaOptions, CompareSchemataOptions, type CompiledResult, type CompilerContext, type CompilerOptions, type CompilerState, type ConflictAction, type ConflictTarget, type CursorHoldOption, type CursorOptions, type CursorScrollOption, DATABASE_READ_ONLY_OUTCOME, DBSP_LEDGER_EVENT_TABLE, DBSP_LEDGER_IDENTITY_TABLE, DBSP_LEDGER_MARKER_TABLE, DBSP_LEDGER_RESERVATION_TABLE, DBSP_LOGICAL_IDENTITY_TABLE, DBSP_META_SCHEMA, DBSP_TRANSITION_AUTHORIZATION_TABLE, DBSP_TRANSITION_JOURNAL_TABLE, DBSP_TRANSITION_RUN_PLAN_TABLE, DBSP_TRANSITION_RUN_TABLE, DEFAULT_PK_COLUMN, DEFAULT_REDACTION_PATTERNS, type Decision, type DeleteConfig, type DetectedHierarchy, ENGINE_VERSION_OBSERVATION, ENUM_ADD_VALUE_RULE_ID, ENUM_LABEL_VISIBLE_OBSERVATION, ENUM_TYPE_EXISTS_OBSERVATION, type EnumAddValueMatch, type EnumAddValueRuleOptions, type ExplainFormat, type ExplainOptions, type ExplainPlan, type ExpressionCanonicalizationWarning, type ExpressionHandler, ExpressionKeyedIndexPredicateCanonicalizationUnsupportedError, type FetchDirection, type FetchOptions, type FkColumnDerivation, type GenerateDDLOptions, type GeneratedMutationClassification, type IdentityAdoptionAsserter, IdentityNamingPlugin, type IncludeHandler, type IncludeResult, type IndexCapabilityContext, IndexFeatureUnsupportedError, IndexPredicateCanonicalizationError, type IndexRenderSpec, type InsertConfig, type IntrospectedModelIR, type IntrospectionOptions, InvalidIdentifierError, type JoinDecision, LOGICAL_IDENTITY_ADOPTION_RULE_ID, LOGICAL_IDENTITY_CARRIER_OBSERVATION, type LeafCompileFn, type LogicalIdentityAdoptionMatch, type LogicalIdentityAdoptionRuleOptions, MANUAL_SQL_OPERATION_KIND, type ManualSqlPayload, type MigrationSQLOptions, NO_NULLS_GUARD, type NamingPlugin, NonConvergentSchemaDiffError, type NonConvergentSchemaDiffSurface, PG_INTROSPECTION_ARTIFACT, PG_OPERATION_PACK_ARTIFACT, PG_RULE_PACK_ARTIFACT, type ParamRefValidationResult, PartialIndexPredicateNewEnumValueError, type PgAdoptionPreflightResult, type PgAdoptionResult, type PgAdvisoryLockKey, type PgAdvisoryLockResult, PgDatabaseReadOnlyError, type PgDatabaseWritability, type PgDeclaredAdoptionInput, PgExecutionContractDerivationError, type PgLedgerAddressChain, PgLockedRun, PgOutcomeCheckpointObserver, type PgPersistedDeclaredAdoptionInput, type PgPersistedReaddressInput, type PgReaddressPairRecoveryResult, type PgReleaseResult, type PgRemovalEffectAddress, type PgRemovalEffectsClosure, type PgTransitionClientLease, type PgTransitionPackOptions, PgsqlAdapter, type PgsqlAdapterOptions, PgsqlAdvisoryLockOptionsError, type PgsqlBorrowedClientAdapterOptions, type PgsqlCompileOnlyAdapterOptions, PgsqlPinnedConnectionAbortSignalError, type PgsqlPoolAdapterOptions, PgsqlPreparedStatementReplayError, type PgsqlPreparedStatementsOptions, PgsqlRawSqlTransactionControlError, PgsqlTransactionAbortSignalError, PgsqlTransactionAbortedCommitError, PgsqlTransactionAbortedError, PgsqlTransactionOptionsError, PgsqlTransactionTimeoutError, PlanCompiler, type PlanDecision, type PrecompiledJoinDecision, RawIndexPredicateFallbackError, type RedactionConfig, type RedactionPattern, type RollbackOnlyPgsqlScope, SET_NOT_NULL_RULE_ID, SchemaDiff, type SchemaScopeOptions, type SetNotNullMatch, type SetNotNullRuleOptions, type SetOperationResult, type SimplifiedPlanReport, type StreamConfig, type UpdateConfig, type UpsertConfig, type WhereDispatcher, type WhereHandler, acquirePgTransitionClient, assertCreateIndexSupported, assertCreateIndexesSupported, assertCreateUniqueIndexConcurrentlyRecoveryNotInvalid, assertNoRepeatedExpressionSurfaceDrift, assertPgDatabaseWritable, bm25Search, booleanSearch, boost, buildCloseCursor, buildDeclareCursor, buildExplain, buildExplainAnalyzeJson, buildExplainPlan, buildExplainVerbose, buildFetch, buildFetchAll, buildFetchFirst, buildFetchForward, buildFetchNext, buildOnConflictClause, buildStreamingStatements, camelCaseNaming, canGenerateCreateIndex, canonicalizeCheckConstraints, classifyGeneratedMutation, classifyPgDatabaseWritability, classifyPgReaddressRecovery, classifyPgReaddressSupport, classifyPgWrite, classifyRemovalEffectsClosure, collectAndValidateParamRefs, comparePgsqlDatabaseSchema, compileDelete, compileInsert, compileMutation, compilePlan, compileSetOperation, compileUpdate, compileUpsert, conditionalUpdate, containmentAuthorityOutcome, cosineDistance, createAlterColumnSetNotNullOperationRuntime, createAlterTypeAddValueOperationRuntime, createAnyExpr, createAttachLogicalIdentityOperationRuntime, createEnumAddValueRule, createEqualityExpr, createLeafCompileFn, createLogicalIdentityAdoptionRule, createManualSqlOperationRuntime, createParamRef, createPgExecutionContract, createPgObservationIssuer, createPgTransitionLessor, createPgTransitionPack, createPgsqlAdapter, createPgsqlCompileOnlyAdapter, createSetNotNullRule, createTypeCastParamRef, dbTypesEqual, defaultFkDerivation, derivePostgresqlCapabilitiesForVersion, escapeDiagnosticText, evaluatePgExecutionContract, excludedRef, executePgDeclaredAdoption, executePgObservationFromLessor, executePgPersistedTableReaddress, findPgLedgerTerminalMember, generateCreateIndex, generateCursorName, generateDDL, generateDownSQL, generateMigrationSQL, generateSeries, getNamingPluginForDbCasing, getRowEstimates, getTotalExecutionTime, identityNaming, innerProduct, introspect, isBatchValuesJoinDecision, isGeneratedMutationDestructive, isJoinDecision, isPgDatabaseReadOnlyError, isPrecompiledJoinDecision, isReservedKeyword, l2Distance, mapColumnType, mapOnDeleteAction, nextval, normalizeManualSqlPayload, parse, parseExplainJson, pgTargetIdentityMismatch, preflightPgDeclaredAdoption, preparePgExecutionSession, preparePgRecoveryAdmission, rawDistance, readPgExecutionTargetFromClient, readPgLedgerAddressChain, readPgLedgerControllerOid, readPgObservationContextFromClient, readPgObservationContextFromLessor, readPgRemovalEffectsClosure, recoverPgReaddressPair, redactParams, refusesRecordedPlanRemoval, releasePgManagedAddress, renderAlterColumnSetNotNullSql, renderAlterTypeAddValueSql, renderAttachLogicalIdentityLockSql, renderCreateIndex, renderCreateLogicalIdentityIndexesSql, renderCreateLogicalIdentitySideTableSql, renderInsertLogicalIdentitySql, renderNoNullsCheckSql, renderPgTableReaddressStatements, renderSetNotNullLockSql, reservationsForRemovalClosure, resolveLogicalName, sanitizeForDisplay, score, validateIdentifier, validateIdentifiers, validateParamRef, validatePgManagedLedgerCurrency, validateQualifiedIdentifier, validateSqlExpression, vectorDims, withPgTransitionRunLock };