@dbsp/core 3.4.0 → 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,6 +1,8 @@
1
1
  import * as _dbsp_types from '@dbsp/types';
2
- import { PseudoColumnMetadata, RecursiveMetadata, RelationIR, RelationKind, AdapterCapabilities, Adapter, BaseAdapter, DDLGeneratingAdapter, ExecutingAdapter, IntrospectingAdapter, RawSqlAdapter, StreamingAdapter, TransactionalAdapter, ColumnType, ColumnJsReadType as ColumnJsReadType$1, WhereIntent, OnDeleteAction, ModelIR, DbCasing, QueryIntent, PlanOptions, PlanReport, RecursiveIntent, RecursivePlanOptions, RecursivePlanReport, ObservationContext, TransitionSessionClient, IssuedObservation, RecoveryArtefact, FingerprintManifest, OperationSemantics, OperationKindRef, PhysicalOperation, EvidenceObservation, DurableIntentRecord, OperationEffectAssessment, ObservationIssuer, ApplyGuard, OperationExecutionOutcome, TransactionalCompletionRecord, StepJournal, TransitionRule, EquivalenceCapability, CapabilityDescriptor, TransitionCompositionFact, RuleRef, SemanticArtifactRef, TransitionRunJournal, ProvenPlanShape, TransitionLessor, ApplyPolicy, CheckConstraintIR, Comparator, EnumIR, ObservationRequest, EvidenceView, ProofObligation, ExecutionContract, ExecutionRequirement, AdvisoryObservationId, AssumptionId, ClaimId, EvidenceId, SemanticArtifactId, IndexIR, Assumption, ResourceAddress, ResourceSelector, TransitionRunMetadata, ApplyResult, TransitionCandidate, TransitionFragmentComposition, PlanAssessment, CompareOutcome, TransitionQueryClient, TransitionFragment, ProofClaim, ApplicableAssessment, InapplicableAssessment, TableIR, SequenceIR, AmbiguityCheckResult, DialectCapabilities, DDLFeature, DDLFeatureVersionRange, SelectIntent, IncludeIntent, AggregateIntent, OrderByIntent, SortDirection, InsertIntent, InsertFromIntent, UpdateIntent, BatchUpdateIntent, DeleteIntent, UpsertIntent, UpsertFromIntent, TransactionBeginOptions, Dump, SetOperationIntent, LockStrength, LockWaitPolicy, DumpMeta, JoinIntent, UnnestCteIntent, CteQueryIntent, CompileOptions, CompiledQuery, MutationIntent as MutationIntent$1, DumpSequenceStep, UpsertConflictTarget, UpsertConflictAction, RawCteIntent, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, IndexInfo, TransactionOptions, PinnedConnectionOptions, ExpressionIntent, ComparisonOperator, WhereSubqueryIntent, SubqueryRefIntent, WhereAndIntent, WhereAnyIntent, WhereComparisonIntent, WhereRelationFilterIntent, RecursiveExistsOptions, WhereExistsIntent, WhereInIntent, WhereNullIntent, WhereLikeIntent, WhereNotIntent, WhereNotExistsIntent, WhereOrIntent, WhereRawExistsIntent, WhereRawNotExistsIntent, WhereExpressionIntent, AggOrderByArg, RelationType as RelationType$1, Cardinality, FeatureWarning, UnsupportedFeatureBehavior, FeatureBehaviorConfig, RangeValue, WhereRangeIntent, RangeOperand, SubqueryIncludeInfo, JsonValue as JsonValue$1 } from '@dbsp/types';
3
- export { Adapter, AdapterCapabilities, AdapterLogger, AdapterStreamOptions, AdjacencyTraversal, AggregateExpressionIntent, AggregateFunction, AggregateIntent, AggregateWindowFunction, AliasIncludedColumnsMode, AlterColumnOptions, AmbiguityCheckResult, ApplicableAssessment, ApplicableEvaluation, ApplyPolicy, ArrayOperator, Assumption, BaseAdapter, CTEDefinition, CapabilityDescriptor, Cardinality, CaseExpressionIntent, CoalesceExpressionIntent, ColumnAliasIntent, ColumnExpressionIntent, ColumnIR, ColumnJsReadType, ColumnType, CommonColumnType, Comparator, CompareOutcome, ComparisonExpressionIntent, ComparisonOperator, CompileOnlyAdapter, CompileOptions, CompileResultWithIncludes, CompiledQuery, CompilingAdapter, ConnectionAvailability, CreateIndexOptions, CustomTraversal, DDLGeneratingAdapter, DbCasing, DecisionType, DeleteIntent, DialectCapabilities, DialectName, DropIndexOptions, DuckDBColumnType, Dump, DumpMeta, DurableIntentRecord, EdgeTableTraversal, EmitJoinClause, ExecutingAdapter, ExpressionIntent, FilterStrategy, FingerprintManifest, ForeignKeyIR, InapplicableAssessment, IncludeIntent, IncludeStrategy, IndexColumnDef, IndexIR, IndexInfo, IndexMethod, InsertFromIntent, InsertIntent, IntrospectingAdapter, IsTypeSupported, JoinDefault, JoinIntent, LiteralExpressionIntent, LogicalIdentity, LogicalIdentityCarrier, LogicalOperator, MSSQLColumnType, ModelIR, MutationIntent, MySQLColumnType, NullOperator, NullsPosition, ObservationContext, ObservationIssuer, ObservationRequest, OffsetWindowFunction, OnDeleteAction, OperationEffectAssessment, OperationSemantics, Optionality, OrderByIntent, PartitionIR, PhysicalOperation, PlanDecision, PlanOptions, PlanReport, PlanWarning, PlanWarningCode, PostgresColumnType, PostgresOnlyColumnType, ProvenApplyGuard, ProvenGuardProtocol, ProvenPlanShape, ProvenPlanStep, PseudoColumnExpressionIntent, PseudoColumnMetadata, PseudoColumnTraversal, QueryIntent, RangeOperator, RangeValue, RankingWindowFunction, RawExpressionIntent, RawSqlAdapter, RecognitionResult, RecursiveAdvancedOptions, RecursiveDedupe, RecursiveDirection, RecursiveEmitOptions, RecursiveExistsOptions, RecursiveIntent, RecursiveMetadata, RecursiveNodeIdExpr, RecursivePlanOptions, RecursivePlanReport, RecursiveTrackOptions, RecursiveTraversal, RelationColumnIntent, RelationIR, RelationKind, RelationOperator, RelationType, RequiredEnumLabelIR, ResolvedIncludeStrategy, ResourceAddress, RuleEvaluation, RuleSupport, SQLiteColumnType, SelectAggregateIntent, SelectAllIntent, SelectFieldsIntent, SelectIntent, SelectWithExpressionsIntent, SerializedProvenPlan, SortDirection, StepJournal, StreamingAdapter, StringOperator, SubqueryIncludeInfo, SubqueryRefIntent, SupportedColumnTypes, TableIR, TransactionOptions, TransactionalAdapter, TransactionalCompletionRecord, TransitionCandidate, TransitionLessor, TransitionQueryClient, TransitionRule, TransitionRunMetadata, TransitionSessionClient, TruncateOptions, UpdateIntent, UpsertConflictAction, UpsertConflictTarget, UpsertFromIntent, UpsertIntent, VacuumOptions, WhereAndIntent, WhereAnyIntent, WhereComparisonIntent, WhereExistsIntent, WhereInIntent, WhereIntent, WhereLikeIntent, WhereNotExistsIntent, WhereNotIntent, WhereNullIntent, WhereOrIntent, WhereRangeIntent, WhereRelationFilterIntent, WhereSubqueryIntent, WindowFunction, WindowIntent, WindowOrderBy, getNodeIdAlias, isAdjacencyTraversal, isAggregateWindowFunction, isCoalesceExpression, isColumnAliasExpression, isCustomTraversal, isDeleteIntent, isEdgeTableTraversal, isInsertIntent, isMutationIntent, isRankingWindowFunction, isRawExpression, isRecursiveIntent, isRelationColumnExpression, isSelectAggregate, isSelectAll, isSelectFields, isSelectWithExpressions, isSubqueryRef, isUpdateIntent, isUpsertIntent, isWhereAnd, isWhereAny, isWhereComparison, isWhereExists, isWhereIn, isWhereLike, isWhereLogical, isWhereNot, isWhereNotExists, isWhereNull, isWhereOr, isWhereRange, isWhereRelationBased, isWhereRelationFilter, isWhereSubquery, isWindowIntent } from '@dbsp/types';
2
+ import { PseudoColumnMetadata, RecursiveMetadata, RelationIR, RelationKind, AdapterCapabilities, Adapter, BaseAdapter, ExecutingAdapter, IntrospectingAdapter, RawSqlAdapter, StreamingAdapter, TransactionalAdapter, ColumnType, ColumnJsReadType as ColumnJsReadType$1, WhereIntent, OnDeleteAction, TableReaddressDeclaration, ModelIR, DbCasing, QueryIntent, PlanOptions, PlanReport, RecursiveIntent, RecursivePlanOptions, RecursivePlanReport, ObservationContext, TransitionSessionClient, TransitionRunMetadata, IssuedObservation, RecoveryArtefact, ManagedStepClaimMaterial, LedgerPayload, FingerprintManifest, OperationSemantics, OperationKindRef, PhysicalOperation, EvidenceObservation, DurableIntentRecord, OperationEffectAssessment, ObservationIssuer, ApplyGuard, OperationExecutionOutcome, TransactionalCompletionRecord, StepJournal, TransitionRule, EquivalenceCapability, CapabilityDescriptor, TransitionCompositionFact, RuleRef, SemanticArtifactRef, TransitionRunJournal, ProvenPlanShape, ApplyPolicy, CheckConstraintIR, Comparator, ResourceAddress, JsonValue as JsonValue$1, DeclarationSet, EnumIR, ObservationRequest, EvidenceView, ProofObligation, ExecutionContract, ExecutionRequirement, AdvisoryObservationId, AssumptionId, ClaimId, EvidenceId, SemanticArtifactId, IndexIR, LedgerClaimKind, LedgerLifecycleGrammarColumn, LedgerHome, LedgerAddress, LedgerChainMember, LedgerStableState, LedgerOpenClaim, LedgerChainProjection, Assumption, ResourceSelector, TransitionLessor, ApplyResult, TransitionCandidate, TransitionFragmentComposition, PlanAssessment, CompareOutcome, TransitionFragment, ProofClaim, NormalizedManagedStep, ApplicableAssessment, ExclusiveTransitionTarget, DurableApplyOutcome, InapplicableAssessment, TableIR, SequenceIR, AmbiguityCheckResult, DialectCapabilities, DDLFeature, DDLFeatureVersionRange, SelectIntent, IncludeIntent, AggregateIntent, OrderByIntent, SortDirection, InsertIntent, InsertFromIntent, UpdateIntent, BatchUpdateIntent, DeleteIntent, UpsertIntent, UpsertFromIntent, TransactionBeginOptions, Dump, SetOperationIntent, LockStrength, LockWaitPolicy, DumpMeta, JoinIntent, UnnestCteIntent, CteQueryIntent, CompileOptions, CompiledQuery, MutationIntent as MutationIntent$1, DumpSequenceStep, UpsertConflictTarget, UpsertConflictAction, RawCteIntent, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, IndexInfo, TransactionOptions, PinnedConnectionOptions, ExpressionIntent, ComparisonOperator, WhereSubqueryIntent, SubqueryRefIntent, WhereAndIntent, WhereAnyIntent, WhereComparisonIntent, WhereRelationFilterIntent, RecursiveExistsOptions, WhereExistsIntent, WhereInIntent, WhereNullIntent, WhereLikeIntent, WhereNotIntent, WhereNotExistsIntent, WhereOrIntent, WhereRawExistsIntent, WhereRawNotExistsIntent, WhereExpressionIntent, StandaloneWhereExpressionIntent, AggOrderByArg, PredicateOperator, RelationType as RelationType$1, Cardinality, FeatureWarning, UnsupportedFeatureBehavior, FeatureBehaviorConfig, RangeValue, WhereRangeIntent, RangeOperand, SubqueryIncludeInfo } from '@dbsp/types';
3
+ export { Adapter, AdapterCapabilities, AdapterLogger, AdapterStreamOptions, AdjacencyTraversal, AggregateExpressionIntent, AggregateFunction, AggregateIntent, AggregateWindowFunction, AliasIncludedColumnsMode, AlterColumnOptions, AmbiguityCheckResult, ApplicableAssessment, ApplicableEvaluation, ApplyPolicy, ArrayOperator, Assumption, BaseAdapter, CTEDefinition, CapabilityDescriptor, Cardinality, CaseExpressionIntent, CoalesceExpressionIntent, ColumnAliasIntent, ColumnExpressionIntent, ColumnIR, ColumnJsReadType, ColumnType, CommonColumnType, Comparator, CompareOutcome, ComparisonExpressionIntent, ComparisonOperator, CompileOnlyAdapter, CompileOptions, CompileResultWithIncludes, CompiledQuery, CompilingAdapter, ConnectionAvailability, CreateIndexOptions, CustomTraversal, DbCasing, DecisionType, DeleteIntent, DialectCapabilities, DialectName, DropIndexOptions, DuckDBColumnType, Dump, DumpMeta, DurableIntentRecord, EdgeTableTraversal, EmitJoinClause, ExclusiveTransitionTarget, ExecutingAdapter, ExpressionIntent, FilterStrategy, FingerprintManifest, ForeignKeyIR, InapplicableAssessment, IncludeIntent, IncludeStrategy, IndexColumnDef, IndexIR, IndexInfo, IndexMethod, InsertFromIntent, InsertIntent, IntrospectingAdapter, IsTypeSupported, JoinDefault, JoinIntent, LiteralExpressionIntent, LogicalIdentity, LogicalIdentityCarrier, LogicalOperator, MSSQLColumnType, ModelIR, MutationIntent, MySQLColumnType, NullOperator, NullsPosition, ObservationContext, ObservationIssuer, ObservationRequest, OffsetWindowFunction, OnDeleteAction, OperationEffectAssessment, OperationSemantics, Optionality, OrderByIntent, PartitionIR, PhysicalOperation, PlanDecision, PlanOptions, PlanReport, PlanWarning, PlanWarningCode, PostgresColumnType, PostgresOnlyColumnType, PredicateOperator, ProvenApplyGuard, ProvenGuardProtocol, ProvenPlanShape, ProvenPlanStep, PseudoColumnExpressionIntent, PseudoColumnMetadata, PseudoColumnTraversal, QueryIntent, RangeOperator, RangeValue, RankingWindowFunction, RawExpressionIntent, RawSqlAdapter, RecognitionResult, RecursiveAdvancedOptions, RecursiveDedupe, RecursiveDirection, RecursiveEmitOptions, RecursiveExistsOptions, RecursiveIntent, RecursiveMetadata, RecursiveNodeIdExpr, RecursivePlanOptions, RecursivePlanReport, RecursiveTrackOptions, RecursiveTraversal, RelationColumnIntent, RelationIR, RelationKind, RelationOperator, RelationType, RequiredEnumLabelIR, ResolvedIncludeStrategy, ResourceAddress, RuleEvaluation, RuleSupport, SQLiteColumnType, SelectAggregateIntent, SelectAllIntent, SelectFieldsIntent, SelectIntent, SelectWithExpressionsIntent, SerializedProvenPlan, SortDirection, StepJournal, StreamingAdapter, StringOperator, SubqueryIncludeInfo, SubqueryRefIntent, SupportedColumnTypes, TableIR, TableReaddressAddress, TableReaddressDeclaration, TransactionOptions, TransactionalAdapter, TransactionalCompletionRecord, TransitionCandidate, TransitionLessor, TransitionQueryClient, TransitionRule, TransitionRunMetadata, TransitionSessionClient, TruncateOptions, UpdateIntent, UpsertConflictAction, UpsertConflictTarget, UpsertFromIntent, UpsertIntent, VacuumOptions, WhereAndIntent, WhereAnyIntent, WhereComparisonIntent, WhereExistsIntent, WhereInIntent, WhereIntent, WhereLikeIntent, WhereNotExistsIntent, WhereNotIntent, WhereNullIntent, WhereOrIntent, WhereRangeIntent, WhereRelationFilterIntent, WhereSubqueryIntent, WindowFunction, WindowIntent, WindowOrderBy, getNodeIdAlias, isAdjacencyTraversal, isAggregateWindowFunction, isCoalesceExpression, isColumnAliasExpression, isCustomTraversal, isDeleteIntent, isEdgeTableTraversal, isInsertIntent, isMutationIntent, isRankingWindowFunction, isRawExpression, isRecursiveIntent, isRelationColumnExpression, isSelectAggregate, isSelectAll, isSelectFields, isSelectWithExpressions, isSubqueryRef, isUpdateIntent, isUpsertIntent, isWhereAnd, isWhereAny, isWhereComparison, isWhereExists, isWhereIn, isWhereLike, isWhereLogical, isWhereNot, isWhereNotExists, isWhereNull, isWhereOr, isWhereRange, isWhereRelationBased, isWhereRelationFilter, isWhereSubquery, isWindowIntent } from '@dbsp/types';
4
+ import { D as DurablyLoadedRun, T as TransitionReadTarget } from './outcome-protocol-CNjWzMNe.js';
5
+ export { A as AdmittedDestructiveOutcomeClaim, a as TRANSITION_LESSOR_REJECTION, b as TransitionLeaseFailure, c as acquireExclusiveTransitionLease, d as acquireTransitionLease, e as acquireTransitionTargetLease, f as classifyOutcomeRecovery, g as createExclusiveTransitionTarget, h as createTransitionLessor, i as findUniqueLedgerTerminal, j as isExclusiveTransitionTarget, k as isTransitionLessor, o as outcomeClaimEventId, l as outcomeClaimId, p as planOperationSession } from './outcome-protocol-CNjWzMNe.js';
4
6
  import { NqlCompilerOptions } from '@dbsp/nql';
5
7
 
6
8
  /**
@@ -74,10 +76,6 @@ declare function supportsTransactions<DB>(adapter: BaseAdapter): adapter is Tran
74
76
  * Check if adapter supports raw SQL execution.
75
77
  */
76
78
  declare function supportsRawSql(adapter: BaseAdapter): adapter is RawSqlAdapter;
77
- /**
78
- * Check if adapter supports DDL generation.
79
- */
80
- declare function supportsDDLGeneration(adapter: BaseAdapter): adapter is DDLGeneratingAdapter;
81
79
  /**
82
80
  * Error thrown when an operation requires an adapter but none was provided.
83
81
  */
@@ -487,7 +485,7 @@ type InferColumnTypes<TColumns extends Record<string, ColumnRef<string, string,
487
485
  * // { id: number; name: string; email: string }
488
486
  * ```
489
487
  */
490
- type InferTableRow<T> = T extends TableRef<string, infer TColumns, infer _TRelations> ? InferColumnTypes<TColumns> : never;
488
+ type InferTableRow<T> = T extends TableRef<infer _TName, infer TColumns> ? InferColumnTypes<TColumns> : never;
491
489
  /**
492
490
  * Type guard to check if a value is a TableRef.
493
491
  *
@@ -927,6 +925,12 @@ interface SchemaTableOptions {
927
925
  }>;
928
926
  /** Composite foreign keys for this table (use ref() with columns/references) */
929
927
  foreignKeys?: RefDefinition[];
928
+ /** Explicit rename or schema move for this desired table. */
929
+ readdress?: TableReaddressDeclaration;
930
+ /** Explicitly bring this existing table under managed state. */
931
+ adopt?: true;
932
+ /** Request a reviewed retire-and-create replacement of this table. */
933
+ replace?: true;
930
934
  }
931
935
  /**
932
936
  * Per-table constraint options, keyed by table name.
@@ -938,13 +942,18 @@ type SchemaConstraints = Record<string, SchemaTableOptions>;
938
942
  interface SchemaExtras {
939
943
  /** PostgreSQL extensions to ensure (CREATE EXTENSION IF NOT EXISTS "name") */
940
944
  extensions?: string[];
941
- /** Sequences to create (CREATE SEQUENCE). Key = sequence name */
945
+ /**
946
+ * Sequences to create (CREATE SEQUENCE), or, with `adopt: true`, an existing standalone
947
+ * sequence for `convergePg` to take into management. Key = sequence name
948
+ */
942
949
  sequences?: Record<string, {
943
- startWith?: number;
944
- incrementBy?: number;
945
- minValue?: number;
946
- maxValue?: number;
950
+ startWith?: number | string;
951
+ incrementBy?: number | string;
952
+ minValue?: number | string;
953
+ maxValue?: number | string;
947
954
  cycle?: boolean;
955
+ /** Explicitly bring an existing standalone sequence under managed state. */
956
+ adopt?: true;
948
957
  }>;
949
958
  }
950
959
  /**
@@ -1019,6 +1028,10 @@ interface Schema<T extends SchemaDefinition> {
1019
1028
  readonly definition: T;
1020
1029
  /** Table-level constraints supplied to schema() or reconstructed from introspection */
1021
1030
  readonly constraints?: SchemaConstraints;
1031
+ /** Schema-wide objects supplied to schema(); retained for durable declarations. */
1032
+ readonly extras?: SchemaExtras;
1033
+ /** Planning inputs supplied to schema(); retained without changing model semantics. */
1034
+ readonly options?: SchemaOptions;
1022
1035
  /** Converted ModelIR for use with ORM */
1023
1036
  readonly model: ModelIR;
1024
1037
  /** Table names */
@@ -1453,7 +1466,9 @@ interface OperationObservation {
1453
1466
  interface ComparatorNameNormalizer {
1454
1467
  /**
1455
1468
  * Normalize identifiers from the observed/current model into the namespace
1456
- * used by authored desired models before comparator matching runs.
1469
+ * used by authored desired models before comparator matching runs. Enum
1470
+ * names are not normalized: a declared enum name is the physical catalog type
1471
+ * name that columns reference in `originalDbType` (#825).
1457
1472
  */
1458
1473
  normalizeCurrentIdentifier(identifier: string): string;
1459
1474
  }
@@ -1473,12 +1488,47 @@ interface GuardExecutionResult {
1473
1488
  }
1474
1489
  interface TransitionExecutionClient {
1475
1490
  readonly opaqueClient: TransitionSessionClient;
1491
+ /** Mark the checked-out client unsafe to return to its pool. */
1492
+ markClientCompromised(): void;
1476
1493
  }
1477
1494
  interface NonRollbackableExecutionTracker {
1478
1495
  markNonRollbackableOperationExecuted(): void;
1479
1496
  }
1497
+ /**
1498
+ * Adapter boundary for a plan-carried managed statement bundle. Core owns the
1499
+ * immutable material and the run link; the adapter owns claim admission,
1500
+ * token-gated SQL, and the INV-07 transaction composition.
1501
+ */
1502
+ interface ManagedOutcomeExecutionRequest {
1503
+ readonly claim: ManagedStepClaimMaterial;
1504
+ readonly run: TransitionRunMetadata;
1505
+ /** Core-minted proof that this run crossed a verified execution boundary. */
1506
+ readonly durablyLoadedRun: DurablyLoadedRun;
1507
+ /** Minted once by apply(), never reused when a recorded run is applied again. */
1508
+ readonly executionId: string;
1509
+ readonly transactional: boolean;
1510
+ readonly lockTimeoutMs: number;
1511
+ /** The operation's own live postcondition observation, never a generic identity probe. */
1512
+ readBack(): Promise<LedgerPayload>;
1513
+ }
1514
+ /** The plan and session facts an adapter may inspect before the step intent. */
1515
+ type ManagedOutcomePreflightRequest = Pick<ManagedOutcomeExecutionRequest, 'claim' | 'run' | 'transactional' | 'lockTimeoutMs'>;
1480
1516
  interface ExecutionCoordinator {
1481
1517
  readonly transactionDomain: string;
1518
+ /**
1519
+ * When supplied, core calls this after `begin` and before application locks
1520
+ * for transactional segments. It may reserve the durable run journal on the
1521
+ * same session so later intent writes keep journal-then-application lock
1522
+ * order. Generic runtimes without an operation/journal reservation protocol
1523
+ * leave this absent; in particular a non-transactional segment cannot retain
1524
+ * a transaction-scoped journal row lock across application locking.
1525
+ *
1526
+ * Before an intent exists, core can invoke `begin`, `setLockTimeout`, this
1527
+ * optional reservation, `rollback`, and `isLockTimeout`. They must
1528
+ * not perform operation DDL or any external effect. `executeOperation` is
1529
+ * the first callback allowed to do so.
1530
+ */
1531
+ reserveJournalRun?(client: TransitionExecutionClient, run: TransitionRunMetadata): Promise<void>;
1482
1532
  begin(client: TransitionExecutionClient): Promise<void>;
1483
1533
  setLockTimeout(client: TransitionExecutionClient, maxWaitMs: number): Promise<void>;
1484
1534
  commit(client: TransitionExecutionClient): Promise<void>;
@@ -1490,6 +1540,19 @@ interface TransactionCoordinatorBinding {
1490
1540
  readonly transactionDomain: string;
1491
1541
  }
1492
1542
  interface OperationRuntime extends RegisteredOperationSemantics {
1543
+ /**
1544
+ * Before `writeIntentJournal`, core can invoke `effectsOf`, `begin`,
1545
+ * `setLockTimeout`, optional `reserveJournalRun`, `acquireLocks`,
1546
+ * `observeContext`,
1547
+ * `observeOperation`, `buildFingerprints`, `rollback`, and `isLockTimeout`.
1548
+ * All must perform no operation DDL or external effect. The only
1549
+ * pre-intent diagnostic exception is `writeObservedJournal` after a
1550
+ * fingerprint-construction failure: it may append that immutable failure
1551
+ * event, but may not perform operation DDL or an external effect. This lets a
1552
+ * refusal before the intent leave the run pristine; `executeOperation` is the
1553
+ * first callback allowed to perform the operation's DDL or external effect.
1554
+ */
1555
+ reserveJournalRun?(client: TransitionExecutionClient, run: TransitionRunMetadata): Promise<void>;
1493
1556
  writeIntentJournal(client: TransitionExecutionClient, record: DurableIntentRecord): Promise<void>;
1494
1557
  begin(client: TransitionExecutionClient): Promise<void>;
1495
1558
  setLockTimeout(client: TransitionExecutionClient, maxWaitMs: number): Promise<void>;
@@ -1498,6 +1561,17 @@ interface OperationRuntime extends RegisteredOperationSemantics {
1498
1561
  observeOperation(client: TransitionExecutionClient, operation: PhysicalOperation, context: ObservationContext, phase: 'before' | 'after', issuer: ObservationIssuer): Promise<OperationObservation>;
1499
1562
  checkGuard(client: TransitionExecutionClient, operation: PhysicalOperation, guard: ApplyGuard, context: ObservationContext): Promise<GuardExecutionResult>;
1500
1563
  executeOperation(client: TransitionExecutionClient, operation: PhysicalOperation, context: ObservationContext, duringGuards?: readonly ApplyGuard[], executionTracker?: NonRollbackableExecutionTracker): Promise<OperationExecutionOutcome>;
1564
+ /**
1565
+ * Required when a plan step carries managed claim material. The applier
1566
+ * never falls back to `executeOperation` for such a step.
1567
+ */
1568
+ executeManagedOutcome?(client: TransitionExecutionClient, request: ManagedOutcomeExecutionRequest): Promise<OperationExecutionOutcome>;
1569
+ /**
1570
+ * Refuses a managed outcome before its durable step intent is recorded.
1571
+ * This boundary is for adapter-owned prerequisites such as an incompatible
1572
+ * ledger marker; it must not execute DDL or append ledger members.
1573
+ */
1574
+ preflightManagedOutcome?(client: TransitionExecutionClient, request: ManagedOutcomePreflightRequest): Promise<string | undefined>;
1501
1575
  writeCompletionJournal(client: TransitionExecutionClient, operation: PhysicalOperation, record: TransactionalCompletionRecord): Promise<void>;
1502
1576
  commit(client: TransitionExecutionClient): Promise<void>;
1503
1577
  rollback(client: TransitionExecutionClient): Promise<void>;
@@ -1564,17 +1638,47 @@ declare class PackRegistry {
1564
1638
  declare function createPackRegistry(packs: readonly TransitionPack[]): PackRegistry;
1565
1639
 
1566
1640
  interface ResumeTransitionInput {
1567
- readonly runId: string;
1568
- readonly loadCurrent: (runId: string) => Promise<TransitionRunJournal & {
1569
- readonly plan: ProvenPlanShape;
1570
- }>;
1571
- readonly readContext: (target: TransitionLessor, run: TransitionRunJournal['run']) => Promise<ObservationContext>;
1572
- readonly policy: ApplyPolicy;
1573
- readonly target: TransitionLessor;
1641
+ readonly journal: VerifiedRecoveryJournal;
1642
+ readonly readContext: (target: TransitionReadTarget, run: TransitionRunJournal['run']) => Promise<ObservationContext>;
1643
+ readonly policy?: ApplyPolicy;
1644
+ readonly target: TransitionReadTarget;
1645
+ readonly admitRecovery?: TransitionRecoveryAdmission;
1574
1646
  }
1647
+ /**
1648
+ * A frozen journal whose run identity, durable digest, external review digest,
1649
+ * and plan structure were verified together. The WeakSet is the runtime brand:
1650
+ * callers may cast a lookalike, but recovery will not accept it.
1651
+ */
1652
+ type VerifiedRecoveryJournal = TransitionRunJournal & {
1653
+ readonly plan: ProvenPlanShape;
1654
+ };
1655
+ type RecoveryJournalLoadResult = {
1656
+ readonly ok: true;
1657
+ readonly journal: VerifiedRecoveryJournal;
1658
+ } | {
1659
+ readonly ok: false;
1660
+ readonly code: 'load-failed' | 'run-id-mismatch' | 'plan-digest-mismatch' | 'plan-invalid' | 'event-invalid';
1661
+ readonly detail: string;
1662
+ };
1663
+ /** Load exactly once, snapshot and freeze the complete durable evidence set. */
1664
+ declare function loadVerifiedRecoveryJournal(runId: string, expectedPlanDigest: string, loadCurrent: (runId: string) => Promise<TransitionRunJournal & {
1665
+ readonly plan: ProvenPlanShape;
1666
+ }>): Promise<RecoveryJournalLoadResult>;
1575
1667
 
1576
1668
  declare function createApplier(registry: PackRegistry, persister: TransitionRunPersister): Applier;
1577
1669
 
1670
+ /** Raised when a value cannot cross the durable JSON payload boundary. */
1671
+ declare class CanonicalJsonError extends TypeError {
1672
+ constructor(path: string, detail: string, options?: ErrorOptions);
1673
+ }
1674
+ /**
1675
+ * Encodes a JSON value with lexically sorted object keys and preserved array
1676
+ * order. Unlike JSON.stringify, this refuses values it would omit or coerce.
1677
+ */
1678
+ declare function canonicalJson(value: unknown): string;
1679
+ /** Hashes the canonical durable representation of a JSON payload. */
1680
+ declare function canonicalJsonDigest(value: unknown): string;
1681
+
1578
1682
  type CheckSetEntry = Pick<CheckConstraintIR, 'name' | 'expression' | 'notValid'>;
1579
1683
  type CheckDelta = {
1580
1684
  readonly kind: 'none';
@@ -1598,6 +1702,37 @@ declare function createComparator(registry: PackRegistry): Comparator;
1598
1702
 
1599
1703
  declare function observationContextDigest(context: ObservationContext): string;
1600
1704
 
1705
+ interface DeclarationAddressContext {
1706
+ readonly engine: string;
1707
+ readonly database: string;
1708
+ readonly schema: string;
1709
+ }
1710
+ /**
1711
+ * Reject every JavaScript value whose JSON representation is lossy or
1712
+ * host-dependent. JSON.stringify alone is unsuitable because it silently drops
1713
+ * functions and undefined object members, exactly the ColumnDef.default case.
1714
+ */
1715
+ declare function assertCanonicalizableJson(value: unknown, path?: string, seen?: WeakSet<object>): asserts value is JsonValue$1;
1716
+ /**
1717
+ * Slice only the declarable part of ModelIR. Deliberately absent are
1718
+ * logicalIdentity, pseudoColumns, comment, partition, rlsEnabled and policies;
1719
+ * their omission is encoded here once, rather than re-checked at every caller.
1720
+ * The supplied model is already physical: declaration binding never derives an
1721
+ * identifier spelling.
1722
+ */
1723
+ declare function declarationSetFromModel(model: ModelIR, context: DeclarationAddressContext): DeclarationSet;
1724
+ /** Validate the complete declarable surface before comparison can short-circuit plan time. */
1725
+ declare function validateDeclarationModel(model: ModelIR): void;
1726
+ /** Compare only the recorded/live identity and retain the precise mismatch reason. */
1727
+ declare function admitRecordedIdentity(recorded: ResourceAddress, live: ResourceAddress): {
1728
+ readonly ok: true;
1729
+ } | {
1730
+ readonly ok: false;
1731
+ readonly detail: string;
1732
+ };
1733
+ /** Attach the canonical declaration artifact before metadata/digest minting. */
1734
+ declare function bindDeclarationSet(plan: InProcessProvenPlan, declarations: DeclarationSet): InProcessProvenPlan;
1735
+
1601
1736
  type EnumAddDelta = {
1602
1737
  readonly kind: 'none';
1603
1738
  } | {
@@ -1679,6 +1814,38 @@ type IndexPerspective = 'desired' | 'current';
1679
1814
  declare function normalizedIndex(tableName: string, index: IndexIR, perspective?: IndexPerspective): IndexSetEntry;
1680
1815
  declare function indexDelta(tableName: string, desiredIndexes: readonly IndexIR[], currentIndexes: readonly IndexIR[]): IndexDelta;
1681
1816
 
1817
+ /** Bump whenever the malformed-chain vocabulary or interpretation changes. */
1818
+ declare const LEDGER_PROJECTION_CODE_VERSION: 1;
1819
+ /**
1820
+ * The one closed grammar matrix. Later claim and token producers consume this
1821
+ * interpreter; they do not reconstruct lifecycle state from ledger spellings.
1822
+ */
1823
+ declare const LEDGER_LIFECYCLE_GRAMMAR: Readonly<Record<LedgerClaimKind, LedgerLifecycleGrammarColumn>>;
1824
+ interface LifecycleFrame {
1825
+ readonly stableState: LedgerStableState;
1826
+ readonly openClaim?: LedgerOpenClaim;
1827
+ }
1828
+ type LifecycleStep = {
1829
+ readonly kind: 'ok';
1830
+ readonly frame: LifecycleFrame;
1831
+ } | {
1832
+ readonly kind: 'invalid';
1833
+ readonly detail: string;
1834
+ };
1835
+ interface LedgerChainProjectionInput {
1836
+ readonly ledger: LedgerHome;
1837
+ readonly address: LedgerAddress;
1838
+ readonly events: readonly LedgerChainMember[];
1839
+ }
1840
+ /** Interprets exactly one terminal-to-next lifecycle edge. */
1841
+ declare function interpretLedgerLifecycle(frame: LifecycleFrame, event: LedgerChainMember): LifecycleStep;
1842
+ /**
1843
+ * Projects a whole address chain without using insertion order. Malformed
1844
+ * chains deliberately return a structured value so mutation callers fail
1845
+ * closed while readers retain the evidence needed to diagnose it.
1846
+ */
1847
+ declare function projectLedgerChain(input: LedgerChainProjectionInput): LedgerChainProjection;
1848
+
1682
1849
  /**
1683
1850
  * Canonical digest used to bind a durable transition run to its proven plan.
1684
1851
  */
@@ -1698,6 +1865,8 @@ declare function assumptionAccepted(assumption: Assumption, policy: ApplyPolicy)
1698
1865
  * caller-supplied snapshot. That is the exact context resume verifies.
1699
1866
  */
1700
1867
  declare function createTransitionRunMetadata(plan: InProcessProvenPlan): TransitionRunMetadata;
1868
+ /** Label a generator removal before persistence; it can never become replayable. */
1869
+ declare function markGeneratorRemovalNonReplayable(run: TransitionRunMetadata): TransitionRunMetadata;
1701
1870
 
1702
1871
  interface StagedTransitionInput {
1703
1872
  readonly desired: ModelIR;
@@ -1741,48 +1910,6 @@ declare function chooseReadyCandidate(preflight: Extract<StagedCompositionPrefli
1741
1910
  }>): StagedCompositionCandidate;
1742
1911
  declare function projectCompareToSingleCandidate(compare: TransitionCompare, entry: StagedCompositionCandidate): TransitionCompare;
1743
1912
 
1744
- declare const TRANSITION_LESSOR_REJECTION = "transition target must be a core-minted lessor";
1745
- /** A core-owned lease: packs receive its session, while core retains release. */
1746
- type TransitionLease = {
1747
- readonly session: TransitionSessionClient;
1748
- readonly release: (failure?: TransitionLeaseFailure) => Promise<void>;
1749
- };
1750
- /**
1751
- * Cross the engine's acquisition boundary.
1752
- *
1753
- * A lessor brand is a declaration, not a security boundary, so every
1754
- * acquisition is checked here even when a caller forged that declaration.
1755
- */
1756
- declare function acquireTransitionLease(target: TransitionLessor): Promise<TransitionLease>;
1757
- /**
1758
- * Mint a declared source of transition leases.
1759
- *
1760
- * This declares a source of leases; it does not inspect individual
1761
- * acquisitions. Every acquisition crosses `acquireTransitionLease`, the
1762
- * runtime boundary that validates and captures it exactly once.
1763
- *
1764
- * The wrapper is allocated and frozen by core. Its non-writable,
1765
- * non-configurable `Symbol.for('dbsp.transition.lessor')` brand carries this
1766
- * protocol version, so independently installed incompatible core versions do
1767
- * not accept one another's lessors. The global symbol is intentionally not a
1768
- * security boundary: code already running in this realm can forge it. This
1769
- * protects callers from passing the wrong connection object by accident.
1770
- */
1771
- declare function createTransitionLessor(acquire: () => Promise<TransitionQueryClient>): TransitionLessor;
1772
- /**
1773
- * Recognize a core-minted transition lessor. The shape check only rejects a
1774
- * contradictory declaration (a branded object without acquire()); the brand
1775
- * and protocol version are the declaration.
1776
- */
1777
- declare function isTransitionLessor(value: unknown): value is TransitionLessor;
1778
- /**
1779
- * Carries the error that ended a lease's use. Its presence — not the value it
1780
- * holds — is what says the lease is being returned after a failure.
1781
- */
1782
- type TransitionLeaseFailure = {
1783
- readonly error: unknown;
1784
- };
1785
-
1786
1913
  type TransitionRelationalValidationInput = {
1787
1914
  readonly kind: 'fragment';
1788
1915
  readonly fragment: TransitionFragment;
@@ -1799,6 +1926,25 @@ type TransitionRelationalValidationResult = {
1799
1926
  readonly ok: false;
1800
1927
  readonly detail: string;
1801
1928
  };
1929
+ declare const validatedManagedStepManifestBrand: unique symbol;
1930
+ /** A manifest normalized and accepted by the managed lifecycle boundary. */
1931
+ interface ValidatedManagedStepManifest {
1932
+ readonly steps: readonly NormalizedManagedStep[];
1933
+ readonly [validatedManagedStepManifestBrand]: 'dbsp-validated-managed-step-manifest';
1934
+ }
1935
+ type ValidatedManagedStepManifestResult = {
1936
+ readonly ok: true;
1937
+ readonly manifest: ValidatedManagedStepManifest;
1938
+ } | {
1939
+ readonly ok: false;
1940
+ readonly detail: string;
1941
+ };
1942
+ /**
1943
+ * Generic lifecycle invariants for adapter-produced normalized managed steps.
1944
+ * Mapping a concrete DDL kind remains adapter work; core only validates the
1945
+ * durable protocol shape before it becomes digest-covered plan material.
1946
+ */
1947
+ declare function validateNormalizedManagedStepManifest(steps: readonly NormalizedManagedStep[]): ValidatedManagedStepManifestResult;
1802
1948
  /**
1803
1949
  * Diagnostic consistency check for transition fragments and already-trusted,
1804
1950
  * in-process plans. For plan inputs this is not an untrusted serialized-plan
@@ -1850,8 +1996,65 @@ interface Applier {
1850
1996
  readonly plan: InProcessProvenPlan;
1851
1997
  readonly assessment: ApplicableAssessment;
1852
1998
  }, policy: ApplyPolicy, target: TransitionLessor): Promise<ApplyResult>;
1853
- resume(runId: string, loadCurrent: ResumeTransitionInput['loadCurrent'], readContext: ResumeTransitionInput['readContext'], policy: ApplyPolicy, target: TransitionLessor): Promise<ApplyResult>;
1999
+ applyDurable(input: DurableApplyInput): Promise<DurableApplyResult>;
2000
+ resume(journal: VerifiedRecoveryJournal, readContext: ResumeTransitionInput['readContext'], policy: ApplyPolicy | undefined, target: TransitionReadTarget, admitRecovery?: TransitionRecoveryAdmission): Promise<ApplyResult>;
2001
+ }
2002
+ /** Durable-run entry point; it snapshots and verifies serialized evidence. */
2003
+ interface DurableApplyInput {
2004
+ readonly runId: string;
2005
+ /**
2006
+ * Content hash the operator reviewed outside the target database. Durable
2007
+ * apply refuses unless it is the hash of the loaded plan itself.
2008
+ */
2009
+ readonly expectedPlanDigest: string;
2010
+ readonly loadCurrent: TransitionResumeJournalLoader;
2011
+ readonly policy: ApplyPolicy;
2012
+ readonly target: ExclusiveTransitionTarget;
2013
+ /** Runs on the held execution lease before authorization, a transaction, intent, or DDL. */
2014
+ readonly prepareExecutionSession: (target: TransitionSessionClient, contract: ExecutionContract, plan: ProvenPlanShape) => Promise<{
2015
+ readonly ok: true;
2016
+ readonly context: ObservationContext;
2017
+ } | {
2018
+ readonly ok: false;
2019
+ /** Omitted by legacy adapters; treated as a contract refusal. */
2020
+ readonly kind?: 'refused' | 'failed' | 'read-only';
2021
+ readonly detail: string;
2022
+ }>;
2023
+ /** Called on that same preflight lease, after admission and before any step attempt. */
2024
+ readonly authorize: (run: TransitionRunJournal['run'], plan: ProvenPlanShape, target: TransitionSessionClient) => Promise<void>;
1854
2025
  }
2026
+ type DurableApplyResult = (ApplyResult & {
2027
+ readonly unresolvedOutcome: {
2028
+ readonly kind: 'recovery-required';
2029
+ readonly claimId: string;
2030
+ readonly detail: string;
2031
+ };
2032
+ readonly durableOutcome: 'recovery-required';
2033
+ }) | (ApplyResult & {
2034
+ readonly unresolvedOutcome: {
2035
+ readonly kind: 'transport-ambiguous';
2036
+ readonly detail: string;
2037
+ };
2038
+ readonly durableOutcome: 'transport-ambiguous';
2039
+ }) | (Omit<ApplyResult, 'unresolvedOutcome' | 'durableOutcome'> & {
2040
+ readonly unresolvedOutcome?: never;
2041
+ readonly durableOutcome: Exclude<DurableApplyOutcome, 'recovery-required' | 'transport-ambiguous'>;
2042
+ });
2043
+ type TransitionResumeJournalLoader = (runId: string) => Promise<TransitionRunJournal & {
2044
+ readonly plan: ProvenPlanShape;
2045
+ }>;
2046
+ /**
2047
+ * Recovery admission identifies the physical PostgreSQL target before any
2048
+ * classification journal can be written. It deliberately does not re-check
2049
+ * apply authority or the historic observation-context digest.
2050
+ */
2051
+ type TransitionRecoveryAdmission = (target: TransitionReadTarget, contract: ExecutionContract) => Promise<{
2052
+ readonly ok: true;
2053
+ readonly context: ObservationContext;
2054
+ } | {
2055
+ readonly ok: false;
2056
+ readonly detail: string;
2057
+ }>;
1855
2058
 
1856
2059
  /**
1857
2060
  * @module model-impl
@@ -2418,7 +2621,7 @@ declare class IntentBuilder<TResult = unknown> {
2418
2621
  */
2419
2622
 
2420
2623
  /** Query execution result types for afterQuery generics */
2421
- type QueryResultType = 'all' | 'first' | 'count' | 'exists' | 'aggregate';
2624
+ type QueryResultType = 'all' | 'first' | 'exists';
2422
2625
  /**
2423
2626
  * Context passed to query hooks (beforeQuery/afterQuery).
2424
2627
  * Frozen via Object.freeze — hooks must return new objects to modify.
@@ -2477,11 +2680,16 @@ type ErrorHookContext = {
2477
2680
  };
2478
2681
  /** Hook invoked before query execution. Can modify intent via return. */
2479
2682
  type BeforeQueryHook = (ctx: QueryHookContext) => QueryHookContext | Promise<QueryHookContext> | undefined;
2480
- /** Hook invoked after query execution. Can transform results via return. */
2683
+ /** Observer invoked after query execution. Its return value is ignored. */
2684
+ type AfterQueryObserver = (ctx: QueryHookContext, result: unknown) => void | Promise<void>;
2685
+ /** Hook invoked after query execution. Can transform results without changing their shape. */
2481
2686
  type AfterQueryHook = <R>(ctx: QueryHookContext, result: R) => R | Promise<R> | undefined;
2482
2687
  /** Hook invoked before mutation execution. Can modify context via return. */
2483
2688
  type BeforeMutationHook = <T>(ctx: MutationHookContext<T>) => MutationHookContext<T> | Promise<MutationHookContext<T>> | undefined;
2484
- /** Hook invoked after mutation execution. Can transform RETURNING results. */
2689
+ /** Observer invoked after mutation execution. Its return value is ignored. */
2690
+ type AfterMutationObserver = (ctx: MutationHookContext, result: unknown) => void | Promise<void>;
2691
+ type ObserverRegistration<T extends (...args: never[]) => unknown, TObserver extends (...args: never[]) => unknown> = ReturnType<T> extends ReturnType<TObserver> ? unknown : never;
2692
+ /** Hook invoked after mutation execution. Can transform RETURNING results without changing their shape. */
2485
2693
  type AfterMutationHook = <T>(ctx: MutationHookContext<T>, result: T[]) => T[] | Promise<T[]> | undefined;
2486
2694
  /** Hook invoked on query/mutation errors. Can transform the error. */
2487
2695
  type OnErrorHook = (ctx: ErrorHookContext) => undefined | Error | Promise<undefined | Error>;
@@ -2490,11 +2698,21 @@ type OnErrorHook = (ctx: ErrorHookContext) => undefined | Error | Promise<undefi
2490
2698
  * Returns 'continue' to skip failed hook, 'abort' to propagate error.
2491
2699
  */
2492
2700
  type HookErrorHandler = (error: Error, hookName: string, ctx: QueryHookContext | MutationHookContext, phase: string) => 'continue' | 'abort';
2701
+ /**
2702
+ * Diagnostic sink for observer failures and snapshot skips.
2703
+ *
2704
+ * Unlike {@link HookErrorHandler}, this handler has no control-flow return:
2705
+ * observer diagnostics always go to a void sink and can never abort work that
2706
+ * has already executed.
2707
+ */
2708
+ type ObserverErrorHandler = (error: Error, observerName: string, phase: 'afterQuery' | 'afterMutation') => void | Promise<void>;
2493
2709
  /** Immutable builder interface for registering hooks */
2494
2710
  interface HookManager {
2495
2711
  beforeQuery(hook: BeforeQueryHook): HookManager;
2712
+ observeAfterQuery<T extends AfterQueryObserver>(observer: T & ObserverRegistration<T, AfterQueryObserver>): HookManager;
2496
2713
  afterQuery(hook: AfterQueryHook): HookManager;
2497
2714
  beforeMutation(hook: BeforeMutationHook): HookManager;
2715
+ observeAfterMutation<T extends AfterMutationObserver>(observer: T & ObserverRegistration<T, AfterMutationObserver>): HookManager;
2498
2716
  afterMutation(hook: AfterMutationHook): HookManager;
2499
2717
  onError(hook: OnErrorHook): HookManager;
2500
2718
  freeze(): HookManager;
@@ -2502,8 +2720,10 @@ interface HookManager {
2502
2720
  /** @internal Hook storage — exposed for runner access */
2503
2721
  type HookStore = {
2504
2722
  readonly beforeQuery: readonly BeforeQueryHook[];
2723
+ readonly afterQueryObservers: readonly AfterQueryObserver[];
2505
2724
  readonly afterQuery: readonly AfterQueryHook[];
2506
2725
  readonly beforeMutation: readonly BeforeMutationHook[];
2726
+ readonly afterMutationObservers: readonly AfterMutationObserver[];
2507
2727
  readonly afterMutation: readonly AfterMutationHook[];
2508
2728
  readonly onError: readonly OnErrorHook[];
2509
2729
  readonly frozen: boolean;
@@ -2535,6 +2755,7 @@ interface QueryBuilderContext {
2535
2755
  readonly defaultFilters?: DefaultFilters | undefined;
2536
2756
  readonly hookStore?: HookStore | undefined;
2537
2757
  readonly onHookError?: HookErrorHandler | undefined;
2758
+ readonly onObserverError?: ObserverErrorHandler | undefined;
2538
2759
  readonly inTransaction?: boolean | undefined;
2539
2760
  }
2540
2761
 
@@ -3140,7 +3361,7 @@ interface QueryBuilder<TResult = unknown> {
3140
3361
  * orm.select('users').where({ active: true, role: 'admin' })
3141
3362
  * ```
3142
3363
  */
3143
- where(condition: WhereIntent | WhereFilter<TResult>): QueryBuilder<TResult>;
3364
+ where(condition: WhereIntent | PredicateRef | WhereFilter<TResult>): QueryBuilder<TResult>;
3144
3365
  /**
3145
3366
  * Add an explicit SQL JOIN clause to the query (non-hydrating, flat result).
3146
3367
  *
@@ -3682,7 +3903,7 @@ declare class QueryBuilderImpl<TResult = unknown> implements QueryBuilder<TResul
3682
3903
  }): QueryBuilder<TResult>;
3683
3904
  limit(count: number): QueryBuilder<TResult>;
3684
3905
  offset(count: number): QueryBuilder<TResult>;
3685
- where(condition: WhereIntent | WhereFilter<TResult>): QueryBuilder<TResult>;
3906
+ where(condition: WhereIntent | PredicateRef | WhereFilter<TResult>): QueryBuilder<TResult>;
3686
3907
  join(relationOrTableOrBatch: string | BatchValuesRef, opts?: {
3687
3908
  type?: 'inner' | 'left';
3688
3909
  on?: WhereIntent;
@@ -3921,6 +4142,39 @@ declare class CteQueryBuilder<TResult = unknown> {
3921
4142
  * Part of DX-010: Mutations.
3922
4143
  */
3923
4144
 
4145
+ /**
4146
+ * A row shape accepted by INSERT and UPSERT values().
4147
+ *
4148
+ * The public ORM type carries row types, but not the per-column default or
4149
+ * serial metadata needed to make only generated columns optional. Until that
4150
+ * schema metadata is threaded through the mutation builders (#449), every row
4151
+ * column is optional here. Keys and value types remain constrained to the row
4152
+ * type; the database enforces required columns.
4153
+ */
4154
+ type Insertable<T> = T extends object ? Partial<T> : Record<string, unknown>;
4155
+ /** A partial row shape accepted by UPDATE and UPSERT update operations. */
4156
+ type Updateable<T> = T extends object ? {
4157
+ [K in keyof T]?: T[K] | SqlRawExpression;
4158
+ } : Record<string, unknown>;
4159
+ /** A scalar-only partial row shape accepted by batchSet(). */
4160
+ type BatchUpdateable<T> = T extends object ? Partial<T> : Record<string, unknown>;
4161
+ /**
4162
+ * Reject keys outside a mutation payload's row shape, including when callers
4163
+ * pass an object through a variable rather than an object literal.
4164
+ */
4165
+ type ExactMutationPayload<TInput, TShape> = TInput & Record<Exclude<keyof TInput, keyof TShape>, never>;
4166
+ type ExactMutationRows<TInput extends readonly unknown[], TShape> = TInput & {
4167
+ readonly [K in keyof TInput]: ExactMutationPayload<TInput[K], TShape>;
4168
+ };
4169
+ /**
4170
+ * Column names accepted by a mutation on a row shape.
4171
+ *
4172
+ * The tuple prevents conditional-type distribution: a mutation whose table is
4173
+ * a union may only name columns shared by every possible target table.
4174
+ */
4175
+ type MutationKey<T> = [T] extends [object] ? Extract<keyof T, string> : string;
4176
+ type MutationReturningRow<T, K extends MutationKey<T>> = T extends object ? Pick<T, Extract<K, keyof T>> : Record<string, unknown>;
4177
+ type MutationWhereCondition = WhereIntent | PredicateRef;
3924
4178
  /**
3925
4179
  * Dump output for mutations.
3926
4180
  * Similar to query Dump but without plan (mutations don't use the planner).
@@ -3945,6 +4199,7 @@ type MutationBaseOpts = {
3945
4199
  schemaName?: string | undefined;
3946
4200
  hookStore?: HookStore | undefined;
3947
4201
  onHookError?: HookErrorHandler | undefined;
4202
+ onObserverError?: ObserverErrorHandler | undefined;
3948
4203
  inTransaction?: boolean | undefined;
3949
4204
  };
3950
4205
  /**
@@ -3964,6 +4219,7 @@ declare abstract class MutationBuilderBase<T, TIntent extends InsertIntent | Upd
3964
4219
  protected readonly returningColumns: readonly string[] | undefined;
3965
4220
  protected readonly hookStore: HookStore | undefined;
3966
4221
  protected readonly onHookError: HookErrorHandler | undefined;
4222
+ protected readonly onObserverError: ObserverErrorHandler | undefined;
3967
4223
  protected readonly inTransaction: boolean | undefined;
3968
4224
  protected constructor(opts: MutationBaseOpts & {
3969
4225
  returning?: readonly string[] | undefined;
@@ -3986,7 +4242,7 @@ declare abstract class MutationBuilderBase<T, TIntent extends InsertIntent | Upd
3986
4242
  * Builder for INSERT operations.
3987
4243
  * Immutable - each method returns a new builder instance.
3988
4244
  */
3989
- declare class InsertBuilder<T = void> extends MutationBuilderBase<T, InsertIntent> {
4245
+ declare class InsertBuilder<TRow = unknown, TResult = void> extends MutationBuilderBase<TResult, InsertIntent> {
3990
4246
  private readonly valuesData;
3991
4247
  protected readonly operationName = "insert";
3992
4248
  constructor(opts: MutationBaseOpts & {
@@ -3997,7 +4253,7 @@ declare class InsertBuilder<T = void> extends MutationBuilderBase<T, InsertInten
3997
4253
  * Set values to insert.
3998
4254
  * Accepts a single object or an array for bulk insert.
3999
4255
  */
4000
- values(data: Record<string, unknown> | readonly Record<string, unknown>[]): InsertBuilder<T>;
4256
+ values<TInput extends Insertable<TRow> | readonly Insertable<TRow>[]>(data: TInput & (TInput extends readonly Insertable<TRow>[] ? ExactMutationRows<TInput, Insertable<TRow>> : ExactMutationPayload<TInput, Insertable<TRow>>)): InsertBuilder<TRow, TResult>;
4001
4257
  /**
4002
4258
  * Specify columns to return after insert (DX-026).
4003
4259
  * Requires adapter support for RETURNING clause.
@@ -4011,7 +4267,7 @@ declare class InsertBuilder<T = void> extends MutationBuilderBase<T, InsertInten
4011
4267
  * // inserted = [{ id: 1, created_at: '2024-01-01T00:00:00Z' }]
4012
4268
  * ```
4013
4269
  */
4014
- returning<R = Record<string, unknown>>(columns: readonly (keyof R & string)[]): InsertBuilder<R[]>;
4270
+ returning<K extends MutationKey<TRow>>(columns: readonly K[]): InsertBuilder<TRow, MutationReturningRow<TRow, K>[]>;
4015
4271
  protected buildIntent(): InsertIntent;
4016
4272
  protected compileIntent(adapter: Adapter, intent: InsertIntent, options?: CompileOptions): CompiledQuery;
4017
4273
  }
@@ -4019,7 +4275,7 @@ declare class InsertBuilder<T = void> extends MutationBuilderBase<T, InsertInten
4019
4275
  * Builder for UPDATE operations.
4020
4276
  * Immutable - each method returns a new builder instance.
4021
4277
  */
4022
- declare class UpdateBuilder<T = void> extends MutationBuilderBase<T, UpdateIntent | BatchUpdateIntent> {
4278
+ declare class UpdateBuilder<TRow = unknown, TResult = void> extends MutationBuilderBase<TResult, UpdateIntent | BatchUpdateIntent> {
4023
4279
  private readonly setData;
4024
4280
  private readonly whereIntent;
4025
4281
  private readonly allowAllFlag;
@@ -4039,11 +4295,11 @@ declare class UpdateBuilder<T = void> extends MutationBuilderBase<T, UpdateInten
4039
4295
  * Multiple calls merge fields (last value wins).
4040
4296
  * When combined with batchSet(), these become scalar SET assignments applied to all rows.
4041
4297
  */
4042
- set(data: Record<string, unknown>): UpdateBuilder<T>;
4298
+ set<TInput extends Updateable<TRow>>(data: ExactMutationPayload<TInput, Updateable<TRow>>): UpdateBuilder<TRow, TResult>;
4043
4299
  /**
4044
4300
  * Add WHERE condition.
4045
4301
  */
4046
- where(condition: WhereIntent): UpdateBuilder<T>;
4302
+ where(condition: MutationWhereCondition): UpdateBuilder<TRow, TResult>;
4047
4303
  /**
4048
4304
  * Specify columns to return after update (DX-026).
4049
4305
  * Requires adapter support for RETURNING clause.
@@ -4057,7 +4313,7 @@ declare class UpdateBuilder<T = void> extends MutationBuilderBase<T, UpdateInten
4057
4313
  * .execute();
4058
4314
  * ```
4059
4315
  */
4060
- returning<R = Record<string, unknown>>(columns: readonly (keyof R & string)[]): UpdateBuilder<R[]>;
4316
+ returning<K extends MutationKey<TRow>>(columns: readonly K[]): UpdateBuilder<TRow, MutationReturningRow<TRow, K>[]>;
4061
4317
  /**
4062
4318
  * Batch update multiple rows using unnest FROM strategy (BATCH-001).
4063
4319
  *
@@ -4078,7 +4334,7 @@ declare class UpdateBuilder<T = void> extends MutationBuilderBase<T, UpdateInten
4078
4334
  * .execute();
4079
4335
  * ```
4080
4336
  */
4081
- batchSet(matchColumn: string | string[], data: Record<string, unknown>[]): UpdateBuilder<T>;
4337
+ batchSet<TInput extends BatchUpdateable<TRow>>(matchColumn: MutationKey<TRow> | MutationKey<TRow>[], data: readonly ExactMutationPayload<TInput, BatchUpdateable<TRow>>[]): UpdateBuilder<TRow, TResult>;
4082
4338
  protected buildIntent(): UpdateIntent | BatchUpdateIntent;
4083
4339
  protected compileIntent(adapter: Adapter, intent: UpdateIntent | BatchUpdateIntent, options?: CompileOptions): CompiledQuery;
4084
4340
  }
@@ -4086,7 +4342,7 @@ declare class UpdateBuilder<T = void> extends MutationBuilderBase<T, UpdateInten
4086
4342
  * Builder for DELETE operations.
4087
4343
  * Immutable - each method returns a new builder instance.
4088
4344
  */
4089
- declare class DeleteBuilder<T = void> extends MutationBuilderBase<T, DeleteIntent> {
4345
+ declare class DeleteBuilder<TRow = unknown, TResult = void> extends MutationBuilderBase<TResult, DeleteIntent> {
4090
4346
  private readonly whereIntent;
4091
4347
  private readonly allowAllFlag;
4092
4348
  private readonly cascadeRelations;
@@ -4100,13 +4356,13 @@ declare class DeleteBuilder<T = void> extends MutationBuilderBase<T, DeleteInten
4100
4356
  /**
4101
4357
  * Add WHERE condition.
4102
4358
  */
4103
- where(condition: WhereIntent): DeleteBuilder<T>;
4359
+ where(condition: MutationWhereCondition): DeleteBuilder<TRow, TResult>;
4104
4360
  /**
4105
4361
  * Enable cascade delete.
4106
4362
  * Without arguments: deletes ALL related records.
4107
4363
  * With array: deletes only specified relations.
4108
4364
  */
4109
- cascade(relations?: readonly string[]): DeleteBuilder<T>;
4365
+ cascade(relations?: readonly string[]): DeleteBuilder<TRow, TResult>;
4110
4366
  /**
4111
4367
  * Specify columns to return after delete (DX-026).
4112
4368
  * Requires adapter support for RETURNING clause.
@@ -4119,7 +4375,7 @@ declare class DeleteBuilder<T = void> extends MutationBuilderBase<T, DeleteInten
4119
4375
  * .execute();
4120
4376
  * ```
4121
4377
  */
4122
- returning<R = Record<string, unknown>>(columns: readonly (keyof R & string)[]): DeleteBuilder<R[]>;
4378
+ returning<K extends MutationKey<TRow>>(columns: readonly K[]): DeleteBuilder<TRow, MutationReturningRow<TRow, K>[]>;
4123
4379
  protected buildIntent(): DeleteIntent;
4124
4380
  protected compileIntent(adapter: Adapter, intent: DeleteIntent, options?: CompileOptions): CompiledQuery;
4125
4381
  }
@@ -4152,7 +4408,7 @@ declare class DeleteBuilder<T = void> extends MutationBuilderBase<T, DeleteInten
4152
4408
  * .execute();
4153
4409
  * ```
4154
4410
  */
4155
- declare class UpsertBuilder<T = void> extends MutationBuilderBase<T, UpsertIntent> {
4411
+ declare class UpsertBuilder<TRow = unknown, TResult = void> extends MutationBuilderBase<TResult, UpsertIntent> {
4156
4412
  private readonly valuesData;
4157
4413
  private readonly conflictTarget;
4158
4414
  private readonly conflictAction;
@@ -4167,17 +4423,17 @@ declare class UpsertBuilder<T = void> extends MutationBuilderBase<T, UpsertInten
4167
4423
  * Set values to insert.
4168
4424
  * Accepts a single object or an array for bulk upsert.
4169
4425
  */
4170
- values(data: Record<string, unknown> | readonly Record<string, unknown>[]): UpsertBuilder<T>;
4426
+ values<TInput extends Insertable<TRow> | readonly Insertable<TRow>[]>(data: TInput & (TInput extends readonly Insertable<TRow>[] ? ExactMutationRows<TInput, Insertable<TRow>> : ExactMutationPayload<TInput, Insertable<TRow>>)): UpsertBuilder<TRow, TResult>;
4171
4427
  /**
4172
4428
  * Specify conflict target by column names.
4173
4429
  * These columns determine conflict detection.
4174
4430
  */
4175
- onConflict(columns: readonly string[]): UpsertBuilder<T>;
4431
+ onConflict(columns: readonly MutationKey<TRow>[]): UpsertBuilder<TRow, TResult>;
4176
4432
  /**
4177
4433
  * Specify conflict target by constraint name.
4178
4434
  * Alternative to onConflict() for named constraints.
4179
4435
  */
4180
- onConflictConstraint(constraintName: string): UpsertBuilder<T>;
4436
+ onConflictConstraint(constraintName: string): UpsertBuilder<TRow, TResult>;
4181
4437
  /**
4182
4438
  * On conflict, update the specified fields.
4183
4439
  * If no fields specified, auto-updates all non-conflict columns.
@@ -4185,16 +4441,16 @@ declare class UpsertBuilder<T = void> extends MutationBuilderBase<T, UpsertInten
4185
4441
  * @param set - Optional fields to update on conflict
4186
4442
  * @param where - Optional condition for the update
4187
4443
  */
4188
- doUpdate(set?: Record<string, unknown>, where?: WhereIntent): UpsertBuilder<T>;
4444
+ doUpdate<TInput extends Updateable<TRow>>(set?: ExactMutationPayload<TInput, Updateable<TRow>>, where?: MutationWhereCondition): UpsertBuilder<TRow, TResult>;
4189
4445
  /**
4190
4446
  * On conflict, do nothing (skip the insert).
4191
4447
  */
4192
- doNothing(): UpsertBuilder<T>;
4448
+ doNothing(): UpsertBuilder<TRow, TResult>;
4193
4449
  /**
4194
4450
  * Specify columns to return after upsert (DX-026).
4195
4451
  * Requires adapter support for RETURNING clause.
4196
4452
  */
4197
- returning<R = Record<string, unknown>>(columns: readonly (keyof R & string)[]): UpsertBuilder<R[]>;
4453
+ returning<K extends MutationKey<TRow>>(columns: readonly K[]): UpsertBuilder<TRow, MutationReturningRow<TRow, K>[]>;
4198
4454
  protected buildIntent(): UpsertIntent;
4199
4455
  protected compileIntent(adapter: Adapter, intent: UpsertIntent, options?: CompileOptions): CompiledQuery;
4200
4456
  }
@@ -4229,9 +4485,9 @@ interface NqlBuilder<T> {
4229
4485
  run(): Promise<void>;
4230
4486
  /** Execute query and return first result or null */
4231
4487
  first(): Promise<T | null>;
4232
- /** Get the IntentIR for debugging */
4488
+ /** Get the IntentIR for debugging. Throws for CTE and set-operation queries. */
4233
4489
  toIntentIR(): QueryIntent | MutationIntent$1;
4234
- /** Get the execution plan */
4490
+ /** Get the execution plan. Throws for mutations and CTE and set-operation queries. */
4235
4491
  plan(): PlanReport;
4236
4492
  /** Get full dump. Mutations return MutationDump without a plan. */
4237
4493
  dump(meta?: DumpMetaInput): Dump | MutationDump;
@@ -4276,9 +4532,13 @@ declare function nqlRaw(fragment: string): NqlRawFragment;
4276
4532
  * @param model - ModelIR for plan execution
4277
4533
  * @param adapter - Optional adapter for query execution
4278
4534
  * @param schemaName - Optional schema name for multi-tenant queries
4535
+ * @param hookStore - Optional hook storage for query and mutation hooks
4536
+ * @param onHookError - Optional control-flow handler for hook failures
4537
+ * @param inTransaction - Whether execution is already within a transaction
4538
+ * @param onObserverError - Optional non-fatal diagnostic sink for observer failures
4279
4539
  * @returns NQL template tag function
4280
4540
  */
4281
- declare function createNqlTag(_schemaDefinition: unknown, model: ModelIR, adapter?: Adapter<unknown>, schemaName?: string, hookStore?: HookStore, onHookError?: HookErrorHandler, inTransaction?: boolean): NqlTag;
4541
+ declare function createNqlTag(_schemaDefinition: unknown, model: ModelIR, adapter?: Adapter<unknown>, schemaName?: string, hookStore?: HookStore, onHookError?: HookErrorHandler, inTransaction?: boolean, onObserverError?: ObserverErrorHandler): NqlTag;
4282
4542
  /**
4283
4543
  * Extract pseudo-column keywords from model configuration.
4284
4544
  * Collects all configured roles and recursive keywords from all tables'
@@ -4542,11 +4802,12 @@ interface OrmOptionsWithAdapter<DB = unknown> extends OrmOptionsBase<DB> {
4542
4802
  * - `orm.select(name)` - concise table-name form
4543
4803
  * - `orm.from(table)` - TableRef form with column-level types
4544
4804
  *
4545
- * Mutations use the typed TableRef-based methods:
4546
- * - `orm.into(table)` - INSERT
4547
- * - `orm.modify(table)` - UPDATE
4548
- * - `orm.removeFrom(table)` - DELETE
4549
- * - `orm.upsertInto(table)` - UPSERT (INSERT ... ON CONFLICT)
4805
+ * Mutations have two schema-keyed surfaces:
4806
+ * - `orm.insert(name)`, `orm.update(name)`, `orm.delete(name)`, and
4807
+ * `orm.upsert(name)` are concise when the table name is already available.
4808
+ * - `orm.into(table)`, `orm.modify(table)`, `orm.removeFrom(table)`, and
4809
+ * `orm.upsertInto(table)` take a TableRef and fit flows that also use its
4810
+ * column references for typed filters and queries.
4550
4811
  *
4551
4812
  * @typeParam DB - Database row map type.
4552
4813
  * Keys are table names, values are row types.
@@ -4649,6 +4910,14 @@ interface OrmInstance<DB = Record<string, unknown>> {
4649
4910
  * @returns A QueryBuilder for constructing the select
4650
4911
  */
4651
4912
  select<K extends keyof DB & string, TResult = DB[K]>(from: K): QueryBuilder<TResult>;
4913
+ /** Start a type-safe INSERT operation from a schema table name. */
4914
+ insert<K extends keyof DB & string>(table: K): InsertBuilder<DB[K]>;
4915
+ /** Start a type-safe UPDATE operation from a schema table name. */
4916
+ update<K extends keyof DB & string>(table: K): UpdateBuilder<DB[K]>;
4917
+ /** Start a type-safe DELETE operation from a schema table name. */
4918
+ delete<K extends keyof DB & string>(table: K): DeleteBuilder<DB[K]>;
4919
+ /** Start a type-safe UPSERT operation from a schema table name. */
4920
+ upsert<K extends keyof DB & string>(table: K): UpsertBuilder<DB[K]>;
4652
4921
  /**
4653
4922
  * Start building a SELECT query from a typed TableRef.
4654
4923
  *
@@ -4855,7 +5124,7 @@ interface OrmInstance<DB = Record<string, unknown>> {
4855
5124
  * .execute();
4856
5125
  * ```
4857
5126
  */
4858
- updateAll(table: string): UpdateBuilder;
5127
+ updateAll<K extends keyof DB & string>(table: K): UpdateBuilder<DB[K]>;
4859
5128
  /**
4860
5129
  * Start building a DELETE operation that affects all rows.
4861
5130
  * Use with caution - this explicitly allows deletes without WHERE.
@@ -4868,7 +5137,7 @@ interface OrmInstance<DB = Record<string, unknown>> {
4868
5137
  * await orm.deleteAll('tempData').execute();
4869
5138
  * ```
4870
5139
  */
4871
- deleteAll(table: string): DeleteBuilder;
5140
+ deleteAll<K extends keyof DB & string>(table: K): DeleteBuilder<DB[K]>;
4872
5141
  /**
4873
5142
  * Execute a callback within a database transaction.
4874
5143
  * Auto-commits on success, auto-rolls back on exception.
@@ -6094,10 +6363,14 @@ declare function raw(sqlFragment: string, as: string): ExpressionSpec;
6094
6363
  declare function col(column: string, alias: string): ExpressionSpec;
6095
6364
  /**
6096
6365
  * Creates a relation column expression for selecting a column from a related table.
6097
- * Auto-creates JOINs via the include mechanism and selects with custom alias.
6098
6366
  *
6099
- * Uses structured relation-column intent - no raw SQL. The compiler resolves the
6100
- * relation to its join alias and renders a dialect-specific aliased column.
6367
+ * Names a relation whose JOIN the query has already emitted. The compiler resolves
6368
+ * that relation to its emitted SQL alias and renders a dialect-specific aliased
6369
+ * column. Without an emitted alias, it reports
6370
+ * `relation column "<relation>"."<column>" has no emitted alias in this query`.
6371
+ *
6372
+ * It does not derive a join: choosing its type, null behavior, and row
6373
+ * multiplication is a separate caller-owned query decision.
6101
6374
  *
6102
6375
  * @param relation - Relation path to traverse (dot-separated for multi-level)
6103
6376
  * @param column - Column name to select from the target relation
@@ -6106,19 +6379,17 @@ declare function col(column: string, alias: string): ExpressionSpec;
6106
6379
  *
6107
6380
  * @example
6108
6381
  * ```typescript
6109
- * // Select from direct relation
6110
- * relationColumn('category', 'name', 'categoryName')
6111
- * // → SELECT t1."name" AS "categoryName" (with JOIN to categories)
6112
- *
6113
- * // Select from nested relation (multi-level path)
6114
- * relationColumn('category.parent', 'name', 'parentName')
6115
- * // → SELECT t2."name" AS "parentName" (with JOINs through category to parent)
6116
- *
6117
- * // In a query
6118
- * orm.select('products').columns([
6119
- * 'name',
6120
- * relationColumn('category', 'name', 'categoryName'),
6121
- * ])
6382
+ * // A relation join supplies the emitted alias.
6383
+ * orm.select('products')
6384
+ * .join('category')
6385
+ * .columns(['name', relationColumn('category', 'name', 'categoryName')])
6386
+ *
6387
+ * // An include with an explicit outer join supplies the alias too. A bare
6388
+ * // include aggregates the relation instead, so the column lands inside
6389
+ * // `<relation>_json` rather than at the top level under its own alias (#793).
6390
+ * orm.select('products')
6391
+ * .include('category', { join: 'left' })
6392
+ * .columns(['name', relationColumn('category', 'name', 'categoryName')])
6122
6393
  * ```
6123
6394
  */
6124
6395
  declare function relationColumn<A extends string>(relation: string, column: string, as: A): AliasedExprColumn<A>;
@@ -6158,7 +6429,7 @@ interface SqlRawExpression {
6158
6429
  * ```typescript
6159
6430
  * orm.upsert('files')
6160
6431
  * .values({ id: 1, name: 'test' })
6161
- * .onConflict({ columns: ['id'] })
6432
+ * .onConflict(['id'])
6162
6433
  * .doUpdate({ last_parsed: sql('now()'), count: sql('excluded.count + 1') })
6163
6434
  * .execute();
6164
6435
  *
@@ -6222,6 +6493,9 @@ declare function isSqlRaw(value: unknown): value is SqlRawExpression;
6222
6493
  * not a column name → use `literal()` instead).
6223
6494
  */
6224
6495
  type ExprInput = ExpressionRef | ExpressionSpec | AggOrderByArg | string | number | boolean | readonly unknown[];
6496
+
6497
+ type BinaryPredicateOperator = Exclude<PredicateOperator, 'AND' | 'OR' | 'NOT'>;
6498
+ type NonPredicateOperator<TOperator extends string> = TOperator extends PredicateOperator ? never : TOperator;
6225
6499
  /**
6226
6500
  * A chainable wrapper around an ExpressionIntent.
6227
6501
  *
@@ -6275,6 +6549,47 @@ declare class ExpressionRef {
6275
6549
  */
6276
6550
  filter(condition: WhereIntent): ExpressionRef;
6277
6551
  }
6552
+ /** Marker used to identify an invalid predicate from a different core copy. */
6553
+ declare const PREDICATE_REF_DISCRIMINATOR: "dbsp.predicate.v1";
6554
+ /**
6555
+ * A predicate that is also a scalar expression.
6556
+ *
6557
+ * Its one canonical representation is the expression intent inherited from
6558
+ * `ExpressionRef`; the WHERE form is derived when a builder consumes it.
6559
+ */
6560
+ declare class ExpressionPredicateRef extends ExpressionRef {
6561
+ readonly __predicateRef: "dbsp.predicate.v1";
6562
+ readonly intent: StandaloneWhereExpressionIntent;
6563
+ constructor(intent: StandaloneWhereExpressionIntent);
6564
+ as(alias: string): PredicateExpressionRef;
6565
+ }
6566
+ /** A scalar predicate created by `op()`, `boolFn()`, or `unsafeAsPredicate()`. */
6567
+ type PredicateExpressionRef = ExpressionPredicateRef;
6568
+ /**
6569
+ * A composed predicate has no scalar-expression representation in this API.
6570
+ * Its canonical representation is the complete WHERE intent.
6571
+ */
6572
+ declare class WhereOnlyPredicateRef {
6573
+ readonly intent: WhereIntent;
6574
+ readonly __predicateRef: "dbsp.predicate.v1";
6575
+ constructor(intent: WhereIntent);
6576
+ }
6577
+ /** A composed predicate that is accepted only in `.where()`. */
6578
+ type WhereOnlyPredicate = WhereOnlyPredicateRef;
6579
+ /**
6580
+ * A value accepted by `.where()` as a predicate.
6581
+ *
6582
+ * The constructors are intentionally module-private. Use `op()`, predicate
6583
+ * helpers, or `unsafeAsPredicate()` instead.
6584
+ */
6585
+ type PredicateRef = PredicateExpressionRef | WhereOnlyPredicate;
6586
+ /**
6587
+ * Recognize only predicate instances constructed by this installed core copy.
6588
+ *
6589
+ * A predicate from another installed copy is unsupported: reconstruct it with
6590
+ * this module's predicate factories before passing it to a builder.
6591
+ */
6592
+ declare function isPredicateRef(value: unknown): value is PredicateRef;
6278
6593
  /**
6279
6594
  * Column reference — refers to a named column (or table.column).
6280
6595
  *
@@ -6304,7 +6619,21 @@ declare function cast(expr: ExpressionRef, typeName: string): ExpressionRef;
6304
6619
  * @example op('<=>', 'embedding', [0.1, 0.2]) // implicit conversions
6305
6620
  * @throws Error if operator fails validation (injection guard)
6306
6621
  */
6307
- declare function op(operator: string, left: ExprInput, right: ExprInput): ExpressionRef;
6622
+ /** Logical AND / OR — both operands must be predicates. */
6623
+ declare function op(operator: 'AND' | 'OR', left: PredicateRef, right: PredicateRef): WhereOnlyPredicate;
6624
+ /** Logical NOT — its sole operand must be a predicate. */
6625
+ declare function op(operator: 'NOT', operand: PredicateRef): WhereOnlyPredicate;
6626
+ /** Predicate binary operators accept expression operands. */
6627
+ declare function op(operator: BinaryPredicateOperator, left: ExprInput, right: ExprInput): ExpressionPredicateRef;
6628
+ /** Any non-predicate operator remains an ordinary expression. */
6629
+ declare function op<TOperator extends string>(operator: NonPredicateOperator<TOperator>, left: ExprInput, right: ExprInput): ExpressionRef;
6630
+ /**
6631
+ * Assert that an arbitrary expression is boolean for use in WHERE.
6632
+ *
6633
+ * Use this only for a user-defined operator whose boolean result cannot be
6634
+ * represented by the closed PredicateOperator union.
6635
+ */
6636
+ declare function unsafeAsPredicate(expr: ExpressionRef): PredicateExpressionRef;
6308
6637
  /**
6309
6638
  * Custom function call — name(args...).
6310
6639
  * Supports schema-qualified names (e.g., 'paradedb.score', 'ST_Distance').
@@ -6330,6 +6659,18 @@ declare function op(operator: string, left: ExprInput, right: ExprInput): Expres
6330
6659
  * @throws Error if name fails validation (injection guard)
6331
6660
  */
6332
6661
  declare function fn(name: string, ...args: (ExprInput | DistinctField)[]): ExpressionRef;
6662
+ /**
6663
+ * Declare that a custom function call is boolean-valued for use in WHERE.
6664
+ *
6665
+ * This has the same trust boundary as the SQL function name and arguments the
6666
+ * caller writes: use it only when the declared function returns boolean.
6667
+ * Unlike `fn()`, which builds a scalar expression, `boolFn()` builds a
6668
+ * predicate that can be passed directly to `.where()`.
6669
+ *
6670
+ * @example boolFn('jsonb_exists', ref('data'), literal('phone'))
6671
+ * @throws Error if name fails validation (injection guard)
6672
+ */
6673
+ declare function boolFn(name: string, ...args: (ExprInput | DistinctField)[]): PredicateExpressionRef;
6333
6674
  /**
6334
6675
  * Literal value — inlined directly in SQL (not bound as parameter).
6335
6676
  * Use to distinguish SQL string literals from column references.
@@ -6995,7 +7336,7 @@ type FullTextSearchOptions = {
6995
7336
  * }))
6996
7337
  * ```
6997
7338
  */
6998
- declare function fullTextSearch({ query, fields, tableAlias, }: FullTextSearchOptions): ExpressionRef;
7339
+ declare function fullTextSearch({ query, fields, tableAlias, }: FullTextSearchOptions): PredicateExpressionRef;
6999
7340
  /**
7000
7341
  * BM25 relevance score expression for ParadeDB.
7001
7342
  *
@@ -7531,6 +7872,11 @@ interface SimplifiedOrmOptions<T extends SchemaDefinition = SchemaDefinition> {
7531
7872
  * or 'abort' to propagate the error.
7532
7873
  */
7533
7874
  readonly onHookError?: HookErrorHandler;
7875
+ /**
7876
+ * Non-fatal diagnostic sink for observer failures and snapshot skips.
7877
+ * Its return value is ignored and it can never abort query or mutation work.
7878
+ */
7879
+ readonly onObserverError?: ObserverErrorHandler;
7534
7880
  /**
7535
7881
  * Behavior when schema uses features the adapter doesn't support.
7536
7882
  * Default: 'warning' (emit warning + skip).
@@ -7657,7 +8003,7 @@ type RangeType = 'int4range' | 'int8range' | 'numrange' | 'tsrange' | 'tstzrange
7657
8003
  * @example rangeOverlaps('span', [1, 100], 'int4range')
7658
8004
  * → "span" && int4range($1, $2)
7659
8005
  */
7660
- declare function rangeOverlaps(column: string, range: readonly [unknown, unknown], rangeType?: RangeType): ExpressionRef;
8006
+ declare function rangeOverlaps(column: string, range: readonly [unknown, unknown], rangeType?: RangeType): PredicateExpressionRef;
7661
8007
  /**
7662
8008
  * Range OVERLAPS — object API: delegates to WhereRangeIntent (planner path)
7663
8009
  *
@@ -7670,7 +8016,7 @@ declare function rangeOverlaps(field: string, value: RangeValue): WhereRangeInte
7670
8016
  * @example rangeContains('dateRange', ['2024-06-15', '2024-06-15'])
7671
8017
  * → "dateRange" @> daterange($1, $2)
7672
8018
  */
7673
- declare function rangeContains(column: string, range: readonly [unknown, unknown], rangeType?: RangeType): ExpressionRef;
8019
+ declare function rangeContains(column: string, range: readonly [unknown, unknown], rangeType?: RangeType): PredicateExpressionRef;
7674
8020
  /**
7675
8021
  * Range CONTAINS — object API: delegates to WhereRangeIntent (planner path)
7676
8022
  *
@@ -7683,7 +8029,7 @@ declare function rangeContains(field: string, value: RangeOperand): WhereRangeIn
7683
8029
  * @example rangeContainedBy('dateRange', ['2024-01-01', '2024-12-31'])
7684
8030
  * → "dateRange" <@ daterange($1, $2)
7685
8031
  */
7686
- declare function rangeContainedBy(column: string, range: readonly [unknown, unknown], rangeType?: RangeType): ExpressionRef;
8032
+ declare function rangeContainedBy(column: string, range: readonly [unknown, unknown], rangeType?: RangeType): PredicateExpressionRef;
7687
8033
  /**
7688
8034
  * Range CONTAINED BY — object API: delegates to WhereRangeIntent (planner path)
7689
8035
  *
@@ -8186,4 +8532,4 @@ declare const assertIntentHasOrderBy: (result: AssertionQueryResult, expected: b
8186
8532
  */
8187
8533
  declare function runAssertions(blocks: AssertionBlock[], results: AssertionQueryResult[], queries: string[], hasDb?: boolean): AssertionSummary;
8188
8534
 
8189
- export { ASSERTION_TYPES, AdapterRequiredError, type AdjacencyOptions, type AfterMutationHook, type AfterQueryHook, type AggregateOptions, type AliasedColumn, type AliasedExprColumn, type AllColumns, AmbiguousPlanError, AmbiguousRelationError, type Applier, type Assertion, type AssertionBlock, type AssertionOutcome, type AssertionQueryResult, type AssertionSummary, type AssertionType, BRAND, type BatchValuesOptions, type BatchValuesRef, type BeforeMutationHook, type BeforeQueryHook, type BrandKey, COLUMN_META, type CardinalityShorthand, CaseBuilder, type CaseValue, type CheckDelta, type ColumnDef, type ColumnMetaKey, ColumnNotFoundError, type ColumnRef, type ColumnSpec, CteBuilder, type CteDump, CteQueryBuilder, type CursorPaginateOptions, type CursorPaginatedResult, DEFAULT_FEATURE_CHECKERS, DUCKDB_CAPABILITIES, type DefaultFilters, type DefineModelOptions, DeleteBuilder, type DistinctField, type DumpMetaInput, type EdgeTableOptions, type EmitWarningOptions, type EnumAddDelta, ErrorCode, type ErrorHookContext, Errors, type EstablishedProofClaim, type ExecutionCoordinator, ExecutionError, type ExprInput, ExpressionRef, type ExpressionSpec, type FeatureChecker, type FeatureUsage, type FilterOperators, type FilterValue, type FullTextSearchField, type FullTextSearchOptions, type GetSchemaFromDbOptions, type GuardExecutionResult, type HierarchyOptions, type HookErrorHandler, type HookManager, type HookPriority, type HydrateOptions, IRREGULAR_PLURALS, type InProcessProvenPlan, type IncludeOptions, type IncludeOptionsWithRecursive, type IndexDelta, type IndexSetEntry, type InferColumn, type InferColumnNonNull, type InferColumnType, type InferColumnTypes, type InferDB, type InferRefColumn, type InferRow, type InferSchemaDB, type InferTableRow, type InferTables, type InferredRangeValue, InsertBuilder, IntentBuilder, type IntentBuilderState, type IntentSummary, InvalidOperationError, InvalidRelationDefinitionError, type JoinOptions, type JsonValue, type LightweightRelationsDef, type ListHierarchyOptions, type ListIndexOptions, type Logger, MSSQL_CAPABILITIES, MYSQL_CAPABILITIES, ModelIRImpl, type MutationDump, type MutationHookContext, type MutationOperation, NamingConventionMismatchError, type NegotiationResult, type NestedInclude, type SchemaColumnType as NewSchemaColumnType, type NonRollbackableExecutionTracker, NotFoundError, type NqlBuilder, type NqlRawFragment, type NqlTag, type OnErrorHook, type OperationFingerprints, type OperationObservation, type OperationRuntime, type OrderByInput, type OrderByRecord, type OrderBySpec, type OrmInstance, type OrmOf, type OrmOptions, type OrmOptionsWithAdapter, type OrmOptionsWithModel, POSTGRESQL_CAPABILITIES, PackRegistry, type PaginateOptions, type PaginatedResult, type ParseError, type ParseResult, type ParsedRelationDef, type ParsedRelationKey, type PathOptions, type PrioritizedHook, type ProveOutcome, type Prover, type QueryAssertionResult, type QueryBuilder, type QueryHookContext, type QueryResultType, RELATION_META, type RangeType, RawCteQueryBuilder, type RecursiveDump, type RecursiveIncludeConfig, type RecursiveOptions, RecursiveShapeMismatchError, type RefDefinition, type RefOptions, type RegisteredOperationSemantics, type RelationHints, type RelationKey, type RelationMetaKey, RelationNotFoundError, type RelationObjectDef, type RelationPathIncludeNode, type RelationPathUsage, type RelationRef, type RelationShorthand, type RelationTupleDef, ResultHydrator, type RulePrecedenceFact, SQLITE_CAPABILITIES, SQL_RAW_MARKER, type Schema, type SchemaColumnType, type SchemaConstraints, type SchemaDefinition, SchemaValidationError as SchemaError, type SchemaExtras, type SchemaIndexOptions, type SchemaIndexValidationInput, type SchemaOptions, type SchemaTableOptions, SchemaValidationError, type SelectField, type SelfRefRoles, type SetOperationBuilder, type SimplifiedOrmOptions, type SqlRawExpression, type StagedCompositionCandidate, type StagedCompositionPreflight, type StagedCompositionPreflightInput, type StagedTransitionInput, type StagedTransitionOrchestrator, type StreamOptions, SubqueryBuilder, SubqueryExpression, TABLE_META, TRANSITION_LESSOR_REJECTION, type TableAssertionData, type TableDDL, type TableDef, type TableIndexes, type TableMetaKey, TableNotFoundError, type TableRef, type TransactionCoordinatorBinding, type TransitionExecutionClient, type TransitionLeaseFailure, type TransitionPack, type TransitionRelationalValidationInput, type TransitionRelationalValidationResult, type TransitionRunPersister, type TraversalDirection, UnhandledTypeInDialect, UnknownDialectError, UnsafeOperationError, UnsupportedCapabilityError, UnsupportedFeatureError, UnsupportedStrategyError, UpdateBuilder, UpsertBuilder, type WarningCategory, type WhereFilter, WindowBuilder, acquireTransitionLease, advisoryObservationId, aggOrderBy, and, any, array, arrayAgg, assertCapability, assertConnectionAvailable, assertContains, assertDbColumnExists, assertDbOutput, assertDbRowsEquals, assertDbRowsMax, assertDbRowsMin, assertDbValueEquals, assertEquals, assertIntentHasGroupBy, assertIntentHasOrderBy, assertIntentHasWhere, assertIntentTable, assertIntentType, assertIntentWith, assertMatches, assertParamsEquals, assertParamsLength, assertParamsType, assertParamsValue, assertSQLColumn, assertSQLEquals, assertSQLJoin, assertSQLTable, assertSuccess, assertTypeSupported, assumptionAccepted, assumptionId, batchValues, bindExecutionContract, capitalize, caseWhen, cast, checkDelta, chooseReadyCandidate, claimId, coalesce, col, composeAfterMutationHooks, composeAfterQueryHooks, composeBeforeMutationHooks, composeBeforeQueryHooks, composeOnErrorHooks, concludeEvidenceForObligation, countDistinctRelationPathsByName, createApplier, createComparator, createDialectCapabilities, createEvidenceView, createExecutionContract, createHookManager, createNqlTag, createOrm, createPackRegistry, createProver, createPseudoColumnMetadata, createRawCteBuilder, createRecursiveMetadata, createStagedTransitionOrchestrator, createTransitionLessor, createTransitionRunMetadata, decapitalize, defaultIndexName, defaultLogger, defineModel, denseRank, deriveRelationPathFromIntentPath, distinct, emitWarning, enumAddDelta, eq, every, evidenceId, exists, ref as exprRef, extendDialect, extractPseudoColumnKeywords, findClosestMatch, fn, fullTextSearch, getAvailableDialects, getDialectCapabilities, getLogger, getRelationKind, getSchemaFromDb, gt, gte, inArray, inSubquery, indexDelta, inferForeignKey, isAliasedColumn, isAllColumns, isBatchValuesRef, isCardinalityShorthand, isColumnRef, isDistinctField, isDistinctFrom, isExpressionSpec, isKnownDialect, isNotNull, isNull, isOperationRuntime, isOverallSuccess, isRecursiveIncludeOptions, isRecursiveRelation, isRef, isRelationObjectDef, isRelationRef, isRelationTupleDef, isSelfReferential, isSqlRaw, isSubqueryExpression, isTableRef, isTransitionLessor, isWhereIntent, lag, lead, like, literal, lt, lte, namedArg, negotiateFeatures, neq, none, normalizeSQL, normalizedIndex, not, notExists, nqlRaw, objectToWhereIntent, observationContextDigest, op, or, outerRef, param, parseAssertionFile, parseRelationDef, parseRelationKey, pipeAfterMutationHooks, pipeAfterQueryHooks, pipeBeforeMutationHooks, pipeBeforeQueryHooks, pipeOnErrorHooks, plan, planRecursive, pluralize, preflightStagedComposition, projectCompareToSingleCandidate, rangeContainedBy, rangeContains, rangeOverlaps, rank, raw, rawExists, rawNotExists, ref$1 as ref, registerDialect, relationColumn, requiresDatabase, resetLogger, resolveEnumSchemaForComparison, resolveQueryIndex, resourceIsWithin, resourceScopeCovers, rowNumber, runAssertions, schema, schemaToModelIR, selectorMatchesResource, semanticArtifactId, serverVersionNum, setLogger, silentLogger, singularize, some, sortByPriority, sql, star, stringAgg, subquery, supportsDDLGeneration, supportsExecution, supportsIntrospection, supportsRawSql, supportsStreaming, supportsTransactions, textScore, transitionPlanDigest, unary, validateAssertionBlocks, validateExecutionContract, validateRecursiveInclude, validateRecursiveShape, validateSchemaIndexOptions, validateTransitionRelationalInvariants, validateTypeName, wAvg, wCount, wMax, wMin, wSum, withPriority };
8535
+ export { ASSERTION_TYPES, AdapterRequiredError, type AdjacencyOptions, type AfterMutationHook, type AfterMutationObserver, type AfterQueryHook, type AfterQueryObserver, type AggregateOptions, type AliasedColumn, type AliasedExprColumn, type AllColumns, AmbiguousPlanError, AmbiguousRelationError, type Applier, type Assertion, type AssertionBlock, type AssertionOutcome, type AssertionQueryResult, type AssertionSummary, type AssertionType, BRAND, type BatchValuesOptions, type BatchValuesRef, type BeforeMutationHook, type BeforeQueryHook, type BrandKey, COLUMN_META, CanonicalJsonError, type CardinalityShorthand, CaseBuilder, type CaseValue, type CheckDelta, type ColumnDef, type ColumnMetaKey, ColumnNotFoundError, type ColumnRef, type ColumnSpec, CteBuilder, type CteDump, CteQueryBuilder, type CursorPaginateOptions, type CursorPaginatedResult, DEFAULT_FEATURE_CHECKERS, DUCKDB_CAPABILITIES, type DefaultFilters, type DefineModelOptions, DeleteBuilder, type DistinctField, type DumpMetaInput, type EdgeTableOptions, type EmitWarningOptions, type EnumAddDelta, ErrorCode, type ErrorHookContext, Errors, type EstablishedProofClaim, type ExecutionCoordinator, ExecutionError, type ExprInput, ExpressionRef, type ExpressionSpec, type FeatureChecker, type FeatureUsage, type FilterOperators, type FilterValue, type FullTextSearchField, type FullTextSearchOptions, type GetSchemaFromDbOptions, type GuardExecutionResult, type HierarchyOptions, type HookErrorHandler, type HookManager, type HookPriority, type HydrateOptions, IRREGULAR_PLURALS, type InProcessProvenPlan, type IncludeOptions, type IncludeOptionsWithRecursive, type IndexDelta, type IndexSetEntry, type InferColumn, type InferColumnNonNull, type InferColumnType, type InferColumnTypes, type InferDB, type InferRefColumn, type InferRow, type InferSchemaDB, type InferTableRow, type InferTables, type InferredRangeValue, InsertBuilder, type Insertable, IntentBuilder, type IntentBuilderState, type IntentSummary, InvalidOperationError, InvalidRelationDefinitionError, type JoinOptions, type JsonValue, LEDGER_LIFECYCLE_GRAMMAR, LEDGER_PROJECTION_CODE_VERSION, type LedgerChainProjectionInput, type LightweightRelationsDef, type ListHierarchyOptions, type ListIndexOptions, type Logger, MSSQL_CAPABILITIES, MYSQL_CAPABILITIES, type ManagedOutcomeExecutionRequest, type ManagedOutcomePreflightRequest, ModelIRImpl, type MutationDump, type MutationHookContext, type MutationOperation, NamingConventionMismatchError, type NegotiationResult, type NestedInclude, type SchemaColumnType as NewSchemaColumnType, type NonRollbackableExecutionTracker, NotFoundError, type NqlBuilder, type NqlRawFragment, type NqlTag, type ObserverErrorHandler, type OnErrorHook, type OperationFingerprints, type OperationObservation, type OperationRuntime, type OrderByInput, type OrderByRecord, type OrderBySpec, type OrmInstance, type OrmOf, type OrmOptions, type OrmOptionsWithAdapter, type OrmOptionsWithModel, POSTGRESQL_CAPABILITIES, PREDICATE_REF_DISCRIMINATOR, PackRegistry, type PaginateOptions, type PaginatedResult, type ParseError, type ParseResult, type ParsedRelationDef, type ParsedRelationKey, type PathOptions, type PredicateExpressionRef, type PredicateRef, type PrioritizedHook, type ProveOutcome, type Prover, type QueryAssertionResult, type QueryBuilder, type QueryHookContext, type QueryResultType, RELATION_META, type RangeType, RawCteQueryBuilder, type RecursiveDump, type RecursiveIncludeConfig, type RecursiveOptions, RecursiveShapeMismatchError, type RefDefinition, type RefOptions, type RegisteredOperationSemantics, type RelationHints, type RelationKey, type RelationMetaKey, RelationNotFoundError, type RelationObjectDef, type RelationPathIncludeNode, type RelationPathUsage, type RelationRef, type RelationShorthand, type RelationTupleDef, ResultHydrator, type RulePrecedenceFact, SQLITE_CAPABILITIES, SQL_RAW_MARKER, type Schema, type SchemaColumnType, type SchemaConstraints, type SchemaDefinition, SchemaValidationError as SchemaError, type SchemaExtras, type SchemaIndexOptions, type SchemaIndexValidationInput, type SchemaOptions, type SchemaTableOptions, SchemaValidationError, type SelectField, type SelfRefRoles, type SetOperationBuilder, type SimplifiedOrmOptions, type SqlRawExpression, type StagedCompositionCandidate, type StagedCompositionPreflight, type StagedCompositionPreflightInput, type StagedTransitionInput, type StagedTransitionOrchestrator, type StreamOptions, SubqueryBuilder, SubqueryExpression, TABLE_META, type TableAssertionData, type TableDDL, type TableDef, type TableIndexes, type TableMetaKey, TableNotFoundError, type TableRef, type TransactionCoordinatorBinding, type TransitionExecutionClient, type TransitionPack, TransitionReadTarget, type TransitionRelationalValidationInput, type TransitionRelationalValidationResult, type TransitionRunPersister, type TraversalDirection, UnhandledTypeInDialect, UnknownDialectError, UnsafeOperationError, UnsupportedCapabilityError, UnsupportedFeatureError, UnsupportedStrategyError, UpdateBuilder, type Updateable, UpsertBuilder, type ValidatedManagedStepManifest, type ValidatedManagedStepManifestResult, type WarningCategory, type WhereFilter, WindowBuilder, admitRecordedIdentity, advisoryObservationId, aggOrderBy, and, any, array, arrayAgg, assertCanonicalizableJson, assertCapability, assertConnectionAvailable, assertContains, assertDbColumnExists, assertDbOutput, assertDbRowsEquals, assertDbRowsMax, assertDbRowsMin, assertDbValueEquals, assertEquals, assertIntentHasGroupBy, assertIntentHasOrderBy, assertIntentHasWhere, assertIntentTable, assertIntentType, assertIntentWith, assertMatches, assertParamsEquals, assertParamsLength, assertParamsType, assertParamsValue, assertSQLColumn, assertSQLEquals, assertSQLJoin, assertSQLTable, assertSuccess, assertTypeSupported, assumptionAccepted, assumptionId, batchValues, bindDeclarationSet, bindExecutionContract, boolFn, canonicalJson, canonicalJsonDigest, capitalize, caseWhen, cast, checkDelta, chooseReadyCandidate, claimId, coalesce, col, composeAfterMutationHooks, composeAfterQueryHooks, composeBeforeMutationHooks, composeBeforeQueryHooks, composeOnErrorHooks, concludeEvidenceForObligation, countDistinctRelationPathsByName, createApplier, createComparator, createDialectCapabilities, createEvidenceView, createExecutionContract, createHookManager, createNqlTag, createOrm, createPackRegistry, createProver, createPseudoColumnMetadata, createRawCteBuilder, createRecursiveMetadata, createStagedTransitionOrchestrator, createTransitionRunMetadata, decapitalize, declarationSetFromModel, defaultIndexName, defaultLogger, defineModel, denseRank, deriveRelationPathFromIntentPath, distinct, emitWarning, enumAddDelta, eq, every, evidenceId, exists, ref as exprRef, extendDialect, extractPseudoColumnKeywords, findClosestMatch, fn, fullTextSearch, getAvailableDialects, getDialectCapabilities, getLogger, getRelationKind, getSchemaFromDb, gt, gte, inArray, inSubquery, indexDelta, inferForeignKey, interpretLedgerLifecycle, isAliasedColumn, isAllColumns, isBatchValuesRef, isCardinalityShorthand, isColumnRef, isDistinctField, isDistinctFrom, isExpressionSpec, isKnownDialect, isNotNull, isNull, isOperationRuntime, isOverallSuccess, isPredicateRef, isRecursiveIncludeOptions, isRecursiveRelation, isRef, isRelationObjectDef, isRelationRef, isRelationTupleDef, isSelfReferential, isSqlRaw, isSubqueryExpression, isTableRef, isWhereIntent, lag, lead, like, literal, loadVerifiedRecoveryJournal, lt, lte, markGeneratorRemovalNonReplayable, namedArg, negotiateFeatures, neq, none, normalizeSQL, normalizedIndex, not, notExists, nqlRaw, objectToWhereIntent, observationContextDigest, op, or, outerRef, param, parseAssertionFile, parseRelationDef, parseRelationKey, pipeAfterMutationHooks, pipeAfterQueryHooks, pipeBeforeMutationHooks, pipeBeforeQueryHooks, pipeOnErrorHooks, plan, planRecursive, pluralize, preflightStagedComposition, projectCompareToSingleCandidate, projectLedgerChain, rangeContainedBy, rangeContains, rangeOverlaps, rank, raw, rawExists, rawNotExists, ref$1 as ref, registerDialect, relationColumn, requiresDatabase, resetLogger, resolveEnumSchemaForComparison, resolveQueryIndex, resourceIsWithin, resourceScopeCovers, rowNumber, runAssertions, schema, schemaToModelIR, selectorMatchesResource, semanticArtifactId, serverVersionNum, setLogger, silentLogger, singularize, some, sortByPriority, sql, star, stringAgg, subquery, supportsExecution, supportsIntrospection, supportsRawSql, supportsStreaming, supportsTransactions, textScore, transitionPlanDigest, unary, unsafeAsPredicate, validateAssertionBlocks, validateDeclarationModel, validateExecutionContract, validateNormalizedManagedStepManifest, validateRecursiveInclude, validateRecursiveShape, validateSchemaIndexOptions, validateTransitionRelationalInvariants, validateTypeName, wAvg, wCount, wMax, wMin, wSum, withPriority };