@datafn/server 0.1.1 → 0.2.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.cts CHANGED
@@ -1,9 +1,11 @@
1
- import { DatafnPlugin, DatafnSchema as DatafnSchema$1 } from '@datafn/core';
1
+ import { DatafnRouteScope, DatafnPlugin, DatafnRequestAction, DatafnSchema as DatafnSchema$1, NamespaceStorageOperation, NamespaceStorageLogicalRole, NamespaceStorageOwnership, DATAFN_NAMESPACE_STORAGE_MANIFEST_VERSION, DATAFN_NAMESPACE_STORAGE_SCHEMA_VERSION } from '@datafn/core';
2
+ export { DATAFN_REQUEST_ACTIONS, DATAFN_REQUEST_PROTOCOL_VERSION, DATAFN_REQUEST_PROTOCOL_VERSIONS, DATAFN_STRUCTURAL_SELECTOR_POSITIONS, DatafnRequestAction, DatafnRequestProtocolVersion, DatafnResourceSelector, ParsedDatafnMutation, ParsedDatafnQuery, ParsedDatafnRequest, ParsedDatafnTransactStep, StructuralResourceSelection, collectStructuralResourceSelectors, extractStructuralResourceSelectors, isDatafnRequestAction, parseDatafnRequest } from '@datafn/core';
2
3
  import { ObservationEvent, ObservabilityInput, ObservabilityConfigInput } from '@superfunctions/observability';
3
4
  import { DatafnSchema, DatafnPlugin as DatafnPlugin$1 } from '@datafn/core/types';
4
5
  import { Route, Router } from '@superfunctions/http';
5
6
  import { ConditionalKVStoreAdapter, IndexedDirectoryStoreAdapter, Adapter, AtomicKVStoreAdapter, RuntimeStores, RowLevelNamespaceConfig } from '@superfunctions/db';
6
7
  import { DatafnError } from '@datafn/core/errors';
8
+ import { KeyObject } from 'node:crypto';
7
9
  export { DatafnPlacementConstraint, DatafnPlacementConstraintContext, DatafnPlacementDecision, DatafnPlacementDecisionSource, DatafnPlacementLocation, DatafnPlacementRankingInput, DatafnPlacementRegionCandidate, DatafnPlacementSelectionInput, rankDatafnPlacementRegions, readDatafnCloudflarePlacementLocation, selectDatafnPlacementRegion } from './placement.cjs';
8
10
 
9
11
  /**
@@ -68,6 +70,116 @@ interface DatafnLogger {
68
70
  debug(message: string, context?: Record<string, unknown>): void;
69
71
  }
70
72
 
73
+ interface DatafnRouteIdentity {
74
+ /** Opaque authenticated subject; never derived from routing headers. */
75
+ subject: string;
76
+ namespace: string;
77
+ sessionBinding?: string;
78
+ /** Optional upstream session deadline bounds the grant. */
79
+ expiresAt?: number;
80
+ }
81
+ interface DatafnRouteTicketClaims {
82
+ version: 1;
83
+ issuer: string;
84
+ audience: string;
85
+ subject: string;
86
+ namespace: string;
87
+ regionId: string;
88
+ epoch: number;
89
+ scopes: DatafnRouteScope[];
90
+ issuedAt: number;
91
+ notBefore: number;
92
+ expiresAt: number;
93
+ ticketId: string;
94
+ sessionBinding?: string;
95
+ }
96
+ interface DatafnRouteTicketSigner {
97
+ sign(claims: DatafnRouteTicketClaims): Promise<string> | string;
98
+ }
99
+ interface DatafnRouteTicketVerifier {
100
+ verify(ticket: string): Promise<DatafnRouteTicketClaims> | DatafnRouteTicketClaims;
101
+ }
102
+ interface DatafnRouteTicketEvent {
103
+ type: "issued" | "accepted" | "rejected" | "renewal_failed";
104
+ code?: string;
105
+ }
106
+ declare function routeTicketError(code: "DATAFN_ROUTE_TICKET_INVALID" | "DATAFN_ROUTE_TICKET_EXPIRED" | "DATAFN_ROUTE_TICKET_REVOKED" | "DATAFN_ROUTE_FORBIDDEN" | "DATAFN_ROUTE_RATE_LIMITED"): DatafnRoutingError;
107
+ /** Separate signing domain and key ring from DATA-1 internal request assertions. */
108
+ declare function createDatafnHmacRouteTickets(input: {
109
+ activeKeyId: string;
110
+ /** At least 32 bytes of cryptographically random key material per key. */
111
+ keys: Record<string, string | Uint8Array>;
112
+ }): DatafnRouteTicketSigner & DatafnRouteTicketVerifier;
113
+ /** Gateway-only Ed25519 signer. Keep the private key out of regional deployments. */
114
+ declare function createDatafnEd25519RouteTicketSigner(input: {
115
+ activeKeyId: string;
116
+ privateKey: string | KeyObject;
117
+ }): DatafnRouteTicketSigner;
118
+ /** Region-only Ed25519 verifier. A public key cannot mint route tickets. */
119
+ declare function createDatafnEd25519RouteTicketVerifier(input: {
120
+ publicKeys: Record<string, string | KeyObject>;
121
+ }): DatafnRouteTicketVerifier;
122
+ interface DatafnRegionalEndpoint {
123
+ httpUrl: string;
124
+ wsUrl?: string;
125
+ /** Unique audience per environment/cell endpoint. */
126
+ audience: string;
127
+ }
128
+ interface DatafnRouteBootstrapConfig {
129
+ directory: DatafnPlacementDirectoryAdapter;
130
+ authenticate(request: Request): Promise<DatafnRouteIdentity> | DatafnRouteIdentity;
131
+ resolveEndpoint(placement: DatafnNamespacePlacement): Promise<DatafnRegionalEndpoint> | DatafnRegionalEndpoint;
132
+ /** Application-owned authorization selects operations; never accept requested scopes verbatim. */
133
+ authorize(identity: DatafnRouteIdentity): Promise<readonly DatafnRouteScope[]> | readonly DatafnRouteScope[];
134
+ signer: DatafnRouteTicketSigner;
135
+ issuer: string;
136
+ ttlMs?: number;
137
+ now?: () => number;
138
+ onEvent?(event: DatafnRouteTicketEvent): void;
139
+ }
140
+ /** Mount at one canonical, authenticated POST endpoint. Request body/region headers are ignored. */
141
+ declare function createDatafnRouteBootstrap(config: DatafnRouteBootstrapConfig): (request: Request) => Promise<Response>;
142
+ interface DatafnRegionalTicketRuntime {
143
+ /** Browser HTTP/WS origins. An Origin header is rejected unless explicitly allowed. */
144
+ allowedOrigins?: readonly string[];
145
+ verifier: DatafnRouteTicketVerifier;
146
+ issuer: string;
147
+ audience: string;
148
+ /** Optional second credential. Omit when a verified ticket is the sole regional bearer credential. */
149
+ authenticate?(request: Request): Promise<DatafnRouteIdentity> | DatafnRouteIdentity;
150
+ /** Checks ticket/session revocation on each HTTP request and WS admission. False rejects. */
151
+ isActive?(claims: DatafnRouteTicketClaims): Promise<boolean> | boolean;
152
+ /** Optional provider-neutral limiter before plugin authorization/execution. */
153
+ allowRequest?(claims: DatafnRouteTicketClaims): Promise<boolean> | boolean;
154
+ now?: () => number;
155
+ /** Future issuance/not-before tolerance only. Expiry is never extended. Default 5 seconds. */
156
+ clockSkewMs?: number;
157
+ onEvent?(event: DatafnRouteTicketEvent): void;
158
+ }
159
+ /** The adapter must negotiate only datafn-sync-v1, never echo the ticket subprotocol. */
160
+ declare function readDatafnRouteTicket(request: Request, websocket?: boolean): string | undefined;
161
+ /** Verify a ticket before using its subject/namespace to build application context.
162
+ * Route scope, placement epoch, revocation, and rate limits are checked again at admission.
163
+ */
164
+ declare function verifyDatafnRegionalTicketIdentity(input: {
165
+ request: Request;
166
+ regionId: string;
167
+ runtime: DatafnRegionalTicketRuntime;
168
+ websocket?: boolean;
169
+ }): Promise<DatafnRouteTicketClaims>;
170
+ declare function validateDatafnRouteTicket(input: {
171
+ request: Request;
172
+ namespace: string;
173
+ regionId: string;
174
+ scope: DatafnRouteScope;
175
+ runtime: DatafnRegionalTicketRuntime;
176
+ }): Promise<DatafnRouteTicketClaims>;
177
+ /** Wrap regional HTTP ingress, including preflight. No credentials/cookies or wildcard origins. */
178
+ declare function withDatafnRegionalCors(handler: (request: Request) => Promise<Response>, options: {
179
+ origins: readonly string[];
180
+ headers?: readonly string[];
181
+ }): (request: Request) => Promise<Response>;
182
+
71
183
  type DatafnPlacementState = "active" | "moving" | "tombstoned";
72
184
  interface DatafnNamespacePlacement {
73
185
  namespace: string;
@@ -158,6 +270,8 @@ interface DatafnRoutingEvent {
158
270
  }
159
271
  interface DatafnPlacementRuntimeConfig {
160
272
  directory: DatafnPlacementDirectoryAdapter;
273
+ /** Opt-in public ingress: requires a route ticket or a valid internal assertion. */
274
+ routeTickets?: DatafnRegionalTicketRuntime;
161
275
  requireRoutingAssertion?: boolean;
162
276
  assertionVerifier?: DatafnRoutingAssertionVerifier;
163
277
  replayStore?: DatafnRoutingReplayStore;
@@ -171,8 +285,12 @@ interface DatafnPlacementRuntimeConfig {
171
285
  declare const DATAFN_ROUTING_ASSERTION_HEADER = "x-datafn-routing-assertion";
172
286
  declare const DATAFN_ROUTING_INTERNAL_HEADERS: readonly ["x-datafn-routing-assertion", "x-datafn-routing-namespace", "x-datafn-routing-region", "x-datafn-routing-epoch"];
173
287
  declare class DatafnRoutingError extends Error {
174
- readonly code: "DATAFN_PLACEMENT_NOT_FOUND" | "DATAFN_PLACEMENT_UNAVAILABLE" | "DATAFN_REGION_MISMATCH" | "DATAFN_NAMESPACE_MOVING" | "DATAFN_CELL_UNAVAILABLE" | "DATAFN_ROUTING_ASSERTION_INVALID" | "DATAFN_ROUTING_RETRY_EXHAUSTED" | "DATAFN_PAYLOAD_TOO_LARGE";
288
+ readonly code: "DATAFN_ROUTE_TICKET_INVALID" | "DATAFN_ROUTE_TICKET_EXPIRED" | "DATAFN_ROUTE_TICKET_REVOKED" | "DATAFN_ROUTE_FORBIDDEN" | "DATAFN_ROUTE_RATE_LIMITED" | "DATAFN_PLACEMENT_NOT_FOUND" | "DATAFN_PLACEMENT_UNAVAILABLE" | "DATAFN_REGION_MISMATCH" | "DATAFN_NAMESPACE_MOVING" | "DATAFN_CELL_UNAVAILABLE" | "DATAFN_ROUTING_ASSERTION_INVALID" | "DATAFN_ROUTING_RETRY_EXHAUSTED" | "DATAFN_PAYLOAD_TOO_LARGE";
175
289
  readonly status: number;
290
+ /** HTTP-shaped metadata so framework routers map an uncaught routing error to its status
291
+ * (e.g. a ticket-only context provider rejection) instead of a generic 500. */
292
+ readonly isHttpError = true;
293
+ readonly statusCode: number;
176
294
  readonly retryable: boolean;
177
295
  readonly executionStarted: boolean;
178
296
  readonly placement?: DatafnNamespacePlacement;
@@ -208,12 +326,15 @@ declare function claimDatafnNamespacePlacement(input: {
208
326
  interface DatafnPlacementValidationResult {
209
327
  placement: DatafnNamespacePlacement;
210
328
  assertion?: DatafnRoutingAssertionClaims;
329
+ ticket?: DatafnRouteTicketClaims;
211
330
  }
212
331
  declare function validateDatafnPlacement(input: {
213
332
  namespace: string;
214
333
  regionId: string;
215
334
  runtime: DatafnPlacementRuntimeConfig;
216
335
  request?: Request;
336
+ /** Server-selected operation; custom routes default to the custom scope. */
337
+ scope?: DatafnRouteScope;
217
338
  /** Trusted in-process execution has no externally supplied assertion. */
218
339
  trustedInternal?: boolean;
219
340
  }): Promise<DatafnPlacementValidationResult>;
@@ -393,7 +514,7 @@ interface ExecutionTimingEvent {
393
514
  }
394
515
 
395
516
  type DataFnEventType = 'datafn.authorization.denied' | 'datafn.payload.rejected' | 'datafn.rate_limited' | 'datafn.request.failed' | 'datafn.retention.pruned' | 'datafn.retention.prune_failed';
396
- type DataFnAction = 'status' | 'query' | 'mutation' | 'transact' | 'seed' | 'clone' | 'pull' | 'push' | 'reconcile' | 'search';
517
+ type DataFnAction = DatafnRequestAction;
397
518
  interface DataFnRequestEventMetadata extends Record<string, unknown> {
398
519
  action?: DataFnAction;
399
520
  path?: string;
@@ -599,6 +720,12 @@ interface WebSocketClient {
599
720
  */
600
721
  interface WsAuthContext {
601
722
  namespace: string;
723
+ /** Set only by the validated regional handshake. */
724
+ routeTicket?: {
725
+ id: string;
726
+ expiresAt: number;
727
+ now?: () => number;
728
+ };
602
729
  /** Optional actor identity for principal-targeted invalidation. */
603
730
  actorId?: string;
604
731
  /** Optional resolved principal IDs for principal-targeted invalidation. */
@@ -824,7 +951,9 @@ interface DatafnServerConfig<TContext = any> {
824
951
  /** Public-link plugin instance used to register share-link routes and resolve link principals. */
825
952
  publicLinks?: DatafnPublicLinksPlugin;
826
953
  /** Authorizes each DataFn action after context creation and before route execution. */
827
- authorize?: (ctx: TContext, action: "status" | "query" | "mutation" | "transact" | "seed" | "clone" | "pull" | "push" | "reconcile" | "search", payload: unknown) => Promise<boolean> | boolean;
954
+ authorize?: (ctx: TContext & {
955
+ parsedBody?: unknown;
956
+ }, action: "status" | "query" | "mutation" | "transact" | "seed" | "clone" | "pull" | "push" | "reconcile" | "search", payload: unknown) => Promise<boolean> | boolean;
828
957
  /** Static context or request-scoped context factory passed to authorization, namespace resolution, route handlers, and hooks. */
829
958
  context?: TContext | ((request: Request) => Promise<TContext> | TContext);
830
959
  /** Request, query, mutation, and validation limits enforced by DataFn routes. */
@@ -943,6 +1072,8 @@ interface DatafnServer<TContext = any> {
943
1072
  addRoutedClient(client: WebSocketClient, authContext: WsAuthContext, handshakeRequest?: Request): Promise<boolean>;
944
1073
  /** Closes stale sessions so clients reconnect through the canonical gateway. */
945
1074
  fenceNamespace(namespace: string, minimumEpoch?: number): number;
1075
+ /** Immediately revoke an admitted route ticket across this process. */
1076
+ revokeRouteTicket(ticketId: string): number;
946
1077
  removeClient(client: WebSocketClient): void;
947
1078
  handleMessage(client: WebSocketClient, data: string): void;
948
1079
  /** REL-007: Called by WS transport on native pong frame receipt. */
@@ -997,6 +1128,105 @@ interface DatafnApp {
997
1128
  */
998
1129
  declare function datafn(config: DatafnAppConfig): DatafnApp;
999
1130
 
1131
+ /**
1132
+ * Adapter-resolved namespace storage plan.
1133
+ *
1134
+ * The logical contract lives in `@datafn/core`. This module binds that
1135
+ * contract to the installed PostgreSQL schema and fails closed when the
1136
+ * catalog contains unknown DataFn-owned namespace storage.
1137
+ */
1138
+
1139
+ declare const POSTGRES_NAMESPACE_STORAGE_CATALOG_SQL: string;
1140
+ type DatafnNamespaceStorageErrorCode = "DATAFN_NAMESPACE_STORAGE_UNSUPPORTED" | "DATAFN_NAMESPACE_STORAGE_VERSION_MISMATCH" | "DATAFN_NAMESPACE_STORAGE_INCOMPLETE" | "DATAFN_NAMESPACE_STORAGE_UNKNOWN" | "DATAFN_NAMESPACE_STORAGE_INVALID";
1141
+ declare class DatafnNamespaceStorageError extends Error {
1142
+ readonly code: DatafnNamespaceStorageErrorCode;
1143
+ readonly details?: unknown;
1144
+ constructor(input: {
1145
+ code: DatafnNamespaceStorageErrorCode;
1146
+ message: string;
1147
+ details?: unknown;
1148
+ });
1149
+ }
1150
+ interface NamespaceStorageCatalogRelation {
1151
+ readonly name: string;
1152
+ readonly columns: readonly string[];
1153
+ /** Valid, non-partial indexes, with expression and INCLUDE columns excluded. */
1154
+ readonly indexes?: readonly {
1155
+ columns: readonly string[];
1156
+ unique: boolean;
1157
+ primary?: boolean;
1158
+ }[];
1159
+ }
1160
+ interface NamespaceStorageCatalog {
1161
+ readonly dialect: "postgres";
1162
+ readonly relations: readonly NamespaceStorageCatalogRelation[];
1163
+ }
1164
+ interface NamespaceStorageEntry {
1165
+ readonly logicalRole: NamespaceStorageLogicalRole | "application";
1166
+ readonly ownership: NamespaceStorageOwnership;
1167
+ readonly relation: string;
1168
+ readonly quotedRelation: string;
1169
+ readonly namespaceColumn: string;
1170
+ readonly quotedNamespaceColumn: string;
1171
+ readonly operations: readonly NamespaceStorageOperation[];
1172
+ readonly copyOrder: number;
1173
+ readonly present: boolean;
1174
+ }
1175
+ interface NamespaceStoragePlan {
1176
+ readonly manifestVersion: typeof DATAFN_NAMESPACE_STORAGE_MANIFEST_VERSION;
1177
+ readonly schemaVersion: typeof DATAFN_NAMESPACE_STORAGE_SCHEMA_VERSION;
1178
+ readonly dialect: "postgres";
1179
+ readonly entries: readonly NamespaceStorageEntry[];
1180
+ }
1181
+ interface ApplicationNamespaceStorageEntry {
1182
+ readonly relation: string;
1183
+ readonly namespaceColumn: string;
1184
+ readonly operations?: readonly NamespaceStorageOperation[];
1185
+ readonly copyOrder?: number;
1186
+ }
1187
+ declare function quotePostgresIdentifier(identifier: string): string;
1188
+ declare function namespacedInternalTableRoles(): Readonly<Record<string, NamespaceStorageLogicalRole>>;
1189
+ declare function resolveNamespaceStoragePlan(input: {
1190
+ schema: DatafnSchema$1;
1191
+ catalog: NamespaceStorageCatalog;
1192
+ manifestVersion?: string;
1193
+ schemaVersion?: string;
1194
+ }): NamespaceStoragePlan;
1195
+ declare function selectNamespaceStorageEntries(plan: NamespaceStoragePlan, operation: NamespaceStorageOperation): readonly NamespaceStorageEntry[];
1196
+ declare function composeNamespaceStoragePlan(plan: NamespaceStoragePlan, applicationEntries: readonly ApplicationNamespaceStorageEntry[]): NamespaceStoragePlan;
1197
+ declare const POSTGRES_NAMESPACE_STORAGE_INDEX_SQL: string;
1198
+ type PostgresNamespaceStorageQuery = (sql: string) => Promise<readonly {
1199
+ table_name: string;
1200
+ column_name?: string;
1201
+ index_columns?: readonly string[];
1202
+ index_unique?: boolean;
1203
+ index_primary?: boolean;
1204
+ }[]>;
1205
+ declare function inspectPostgresNamespaceStorage(query: PostgresNamespaceStorageQuery): Promise<NamespaceStorageCatalog>;
1206
+ declare function assertInternalNamespaceStorageMetadataComplete(): void;
1207
+ declare function drainNamespaceStorage(input: {
1208
+ adapter: Adapter;
1209
+ plan: NamespaceStoragePlan;
1210
+ namespace: string;
1211
+ runtime: DatafnMultiRegionRuntimeConfig;
1212
+ logger?: DatafnLogger;
1213
+ }): Promise<{
1214
+ processed: number;
1215
+ pending: number;
1216
+ }>;
1217
+
1218
+ /**
1219
+ * Drain every permission-directory outbox row for one namespace.
1220
+ * Used by tenant move/backup tooling after writes are fenced.
1221
+ */
1222
+ declare function drainNamespacePermissionDirectoryOutbox(db: Adapter, namespace: string, runtime: DatafnMultiRegionRuntimeConfig, logger?: DatafnLogger, options?: {
1223
+ limit?: number;
1224
+ maxRounds?: number;
1225
+ }): Promise<{
1226
+ processed: number;
1227
+ pending: number;
1228
+ }>;
1229
+
1000
1230
  /**
1001
1231
  * GET /datafn/status endpoint
1002
1232
  * Returns server metadata, capabilities, limits, and schema hash
@@ -1014,4 +1244,60 @@ interface StatusResult {
1014
1244
  serverTimeMs: number;
1015
1245
  }
1016
1246
 
1017
- export { AtomicSequenceStore, ChainedSequenceStore, type CreateDatafnPublicLinkInput, type CrossResourceSearchParams, DATAFN_MULTI_REGION_CAPABILITY, DATAFN_ROUTING_ASSERTION_HEADER, DATAFN_ROUTING_INTERNAL_HEADERS, type DataFnAction, type DataFnAuthorizationDeniedEvent, type DataFnAuthorizationDeniedMetadata, type DataFnEvent, type DataFnEventMap, type DataFnEventType, type DataFnPayloadRejectedEvent, type DataFnPayloadRejectedMetadata, type DataFnRateLimitedEvent, type DataFnRateLimitedMetadata, type DataFnRequestEventMetadata, type DataFnRequestFailedEvent, type DataFnRequestFailedMetadata, type DataFnRetentionPruneFailedEvent, type DataFnRetentionPruneFailedMetadata, type DataFnRetentionPrunedEvent, type DataFnRetentionPrunedMetadata, DatabaseSequenceStore, type DatafnApp, type DatafnAppConfig, type DatafnAppServerConfig, type DatafnComposableRoute, type DatafnExecutor, type DatafnExecutorAction, DatafnExecutorError, type DatafnGatewayCellRegistry, type DatafnGatewayDispatcher, type DatafnGatewayRouter, type DatafnGatewayRouterConfig, type DatafnMultiRegionDirectory, type DatafnMultiRegionPluginConfig, type DatafnMultiRegionRuntimeConfig, type DatafnNamespaceMigrationContext, type DatafnNamespaceMigrationHooks, type DatafnNamespaceMigrationState, type DatafnNamespacePlacement, type DatafnPermissionDirectoryGrant, type DatafnPlacementDirectoryAdapter, type DatafnPlacementRuntimeConfig, type DatafnPlacementState, type DatafnPluginAuthorizationInput, type DatafnPluginAuthorizationResult, type DatafnPluginRoutePlacement, type DatafnPluginRoutePlacementResult, type DatafnPublicLinkAuthorizationInput, type DatafnPublicLinkGrant, DatafnPublicLinkInputError, type DatafnPublicLinkPrincipal, type DatafnPublicLinkRecord, type DatafnPublicLinkShareLevel, type DatafnPublicLinkShareScope, type DatafnPublicLinksPlugin, type DatafnPublicLinksPluginConfig, type DatafnRouteHeaderEntries, type DatafnRouteHeaderInput, type DatafnRouteHeaders, type DatafnRouteHookInput, type DatafnRouteHooks, type DatafnRouteResponseHook, type DatafnRoutingAssertionClaims, type DatafnRoutingAssertionSigner, type DatafnRoutingAssertionVerifier, DatafnRoutingError, type DatafnRoutingEvent, type DatafnRoutingEventType, type DatafnRoutingReplayStore, type DatafnServer, type DatafnServerConfig, type RateLimitConfig, type SearchProvider, type SearchResult, type SearchResultItem, type SequenceStore, type SequenceStorePolicy, type StatusResult, claimDatafnNamespacePlacement, createConditionalKvDatafnPlacementDirectory, createDatafnGatewayRouter, createDatafnHmacRoutingAssertions, createDatafnMultiRegionPlugin, createDatafnPublicLinksPlugin, createDatafnServer, createMemoryDatafnPlacementDirectory, createMemoryDatafnRoutingReplayStore, createSequenceStore, datafn, datafnMultiRegionPlugin, migrateDatafnNamespace, readDatafnPublicLinkToken, resolveDatafnPublicLink, validateDatafnPlacement, validateDatafnRoutingBodyLimit, withDatafnPublicLinksSchema, withDatafnRoutingAssertion };
1247
+ /** Resumable position within a namespace sweep. */
1248
+ interface AncestorInactiveCursor {
1249
+ resource: string;
1250
+ afterId: string | null;
1251
+ }
1252
+ interface RecomputeAncestorInactiveOptions {
1253
+ namespace: string;
1254
+ batchSize?: number;
1255
+ /** Maximum ancestor nodes visited per row; exceeding the bound fails explicitly. */
1256
+ maxGraphNodes?: number;
1257
+ cursor?: AncestorInactiveCursor | null;
1258
+ dryRun?: boolean;
1259
+ logger?: DatafnLogger;
1260
+ }
1261
+ interface RecomputeAncestorInactiveResult {
1262
+ scanned: number;
1263
+ updated: number;
1264
+ /** Mismatches not written because their compare-and-set lost a race. */
1265
+ skipped: number;
1266
+ /** Null once every dependent resource in the namespace has been visited. */
1267
+ nextCursor: AncestorInactiveCursor | null;
1268
+ }
1269
+ /**
1270
+ * Ordered list of resources that own the runtime-maintained
1271
+ * `isAncestorInactive` field for `schema`.
1272
+ */
1273
+ declare function ancestorInactiveResources(schema: DatafnSchema$1): string[];
1274
+ /**
1275
+ * Recomputes `isAncestorInactive` for one batch of records in `namespace`,
1276
+ * resolving each record against the current state of its parents. Rows are
1277
+ * visited in ascending id order per resource so the sweep is deterministic and
1278
+ * resumable via `nextCursor`. Ancestor flags are derived from primary state,
1279
+ * with bounded traversal and explicit cycle/malformed-link errors. Quiesce
1280
+ * ancestor/link mutations during repair; compare-and-set guards only the
1281
+ * derived value on each row, not an atomic snapshot of the entire graph.
1282
+ */
1283
+ declare function recomputeAncestorInactive(adapter: Adapter, schema: DatafnSchema$1, options: RecomputeAncestorInactiveOptions): Promise<RecomputeAncestorInactiveResult>;
1284
+ interface RecomputeAncestorInactiveAllResult {
1285
+ scanned: number;
1286
+ updated: number;
1287
+ /** Mismatches not written because their compare-and-set lost a race. */
1288
+ skipped: number;
1289
+ sweeps: number;
1290
+ /** False when `maxSweeps` was reached while the last sweep changed or skipped rows. */
1291
+ converged: boolean;
1292
+ }
1293
+ /**
1294
+ * Runs full namespace sweeps of {@link recomputeAncestorInactive} until a
1295
+ * sweep produces no updates or skipped writes, verifying the prior sweep.
1296
+ * Bounded by `maxSweeps`; check `converged`
1297
+ * and rerun if it is false. Dry runs perform a single sweep.
1298
+ */
1299
+ declare function recomputeAncestorInactiveAll(adapter: Adapter, schema: DatafnSchema$1, options: Omit<RecomputeAncestorInactiveOptions, "cursor"> & {
1300
+ maxSweeps?: number;
1301
+ }): Promise<RecomputeAncestorInactiveAllResult>;
1302
+
1303
+ export { type AncestorInactiveCursor, type ApplicationNamespaceStorageEntry, AtomicSequenceStore, ChainedSequenceStore, type CreateDatafnPublicLinkInput, type CrossResourceSearchParams, DATAFN_MULTI_REGION_CAPABILITY, DATAFN_ROUTING_ASSERTION_HEADER, DATAFN_ROUTING_INTERNAL_HEADERS, type DataFnAction, type DataFnAuthorizationDeniedEvent, type DataFnAuthorizationDeniedMetadata, type DataFnEvent, type DataFnEventMap, type DataFnEventType, type DataFnPayloadRejectedEvent, type DataFnPayloadRejectedMetadata, type DataFnRateLimitedEvent, type DataFnRateLimitedMetadata, type DataFnRequestEventMetadata, type DataFnRequestFailedEvent, type DataFnRequestFailedMetadata, type DataFnRetentionPruneFailedEvent, type DataFnRetentionPruneFailedMetadata, type DataFnRetentionPrunedEvent, type DataFnRetentionPrunedMetadata, DatabaseSequenceStore, type DatafnApp, type DatafnAppConfig, type DatafnAppServerConfig, type DatafnComposableRoute, type DatafnExecutor, type DatafnExecutorAction, DatafnExecutorError, type DatafnGatewayCellRegistry, type DatafnGatewayDispatcher, type DatafnGatewayRouter, type DatafnGatewayRouterConfig, type DatafnMultiRegionDirectory, type DatafnMultiRegionPluginConfig, type DatafnMultiRegionRuntimeConfig, type DatafnNamespaceMigrationContext, type DatafnNamespaceMigrationHooks, type DatafnNamespaceMigrationState, type DatafnNamespacePlacement, DatafnNamespaceStorageError, type DatafnNamespaceStorageErrorCode, type DatafnPermissionDirectoryGrant, type DatafnPlacementDirectoryAdapter, type DatafnPlacementRuntimeConfig, type DatafnPlacementState, type DatafnPluginAuthorizationInput, type DatafnPluginAuthorizationResult, type DatafnPluginRoutePlacement, type DatafnPluginRoutePlacementResult, type DatafnPublicLinkAuthorizationInput, type DatafnPublicLinkGrant, DatafnPublicLinkInputError, type DatafnPublicLinkPrincipal, type DatafnPublicLinkRecord, type DatafnPublicLinkShareLevel, type DatafnPublicLinkShareScope, type DatafnPublicLinksPlugin, type DatafnPublicLinksPluginConfig, type DatafnRegionalEndpoint, type DatafnRegionalTicketRuntime, type DatafnRouteBootstrapConfig, type DatafnRouteHeaderEntries, type DatafnRouteHeaderInput, type DatafnRouteHeaders, type DatafnRouteHookInput, type DatafnRouteHooks, type DatafnRouteIdentity, type DatafnRouteResponseHook, type DatafnRouteTicketClaims, type DatafnRouteTicketEvent, type DatafnRouteTicketSigner, type DatafnRouteTicketVerifier, type DatafnRoutingAssertionClaims, type DatafnRoutingAssertionSigner, type DatafnRoutingAssertionVerifier, DatafnRoutingError, type DatafnRoutingEvent, type DatafnRoutingEventType, type DatafnRoutingReplayStore, type DatafnServer, type DatafnServerConfig, type NamespaceStorageCatalog, type NamespaceStorageCatalogRelation, type NamespaceStorageEntry, type NamespaceStoragePlan, POSTGRES_NAMESPACE_STORAGE_CATALOG_SQL, POSTGRES_NAMESPACE_STORAGE_INDEX_SQL, type PostgresNamespaceStorageQuery, type RateLimitConfig, type RecomputeAncestorInactiveAllResult, type RecomputeAncestorInactiveOptions, type RecomputeAncestorInactiveResult, type SearchProvider, type SearchResult, type SearchResultItem, type SequenceStore, type SequenceStorePolicy, type StatusResult, ancestorInactiveResources, assertInternalNamespaceStorageMetadataComplete, claimDatafnNamespacePlacement, composeNamespaceStoragePlan, createConditionalKvDatafnPlacementDirectory, createDatafnEd25519RouteTicketSigner, createDatafnEd25519RouteTicketVerifier, createDatafnGatewayRouter, createDatafnHmacRouteTickets, createDatafnHmacRoutingAssertions, createDatafnMultiRegionPlugin, createDatafnPublicLinksPlugin, createDatafnRouteBootstrap, createDatafnServer, createMemoryDatafnPlacementDirectory, createMemoryDatafnRoutingReplayStore, createSequenceStore, datafn, datafnMultiRegionPlugin, drainNamespacePermissionDirectoryOutbox, drainNamespaceStorage, inspectPostgresNamespaceStorage, migrateDatafnNamespace, namespacedInternalTableRoles, quotePostgresIdentifier, readDatafnPublicLinkToken, readDatafnRouteTicket, recomputeAncestorInactive, recomputeAncestorInactiveAll, resolveDatafnPublicLink, resolveNamespaceStoragePlan, routeTicketError, selectNamespaceStorageEntries, validateDatafnPlacement, validateDatafnRouteTicket, validateDatafnRoutingBodyLimit, verifyDatafnRegionalTicketIdentity, withDatafnPublicLinksSchema, withDatafnRegionalCors, withDatafnRoutingAssertion };