@powerhousedao/reactor 6.1.0-dev.3 → 6.1.0-dev.5

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.
Files changed (37) hide show
  1. package/dist/build-worker-executor-DDVXB921.js +83 -0
  2. package/dist/build-worker-executor-DDVXB921.js.map +1 -0
  3. package/dist/document-indexer-B2iLRB0o.js +917 -0
  4. package/dist/document-indexer-B2iLRB0o.js.map +1 -0
  5. package/dist/drive-container-types-BNpMlgT_.js +2964 -0
  6. package/dist/drive-container-types-BNpMlgT_.js.map +1 -0
  7. package/dist/entry.d.ts +1 -0
  8. package/dist/entry.js +313 -0
  9. package/dist/entry.js.map +1 -0
  10. package/dist/error-info-Cpu4OY3o.js +62 -0
  11. package/dist/error-info-Cpu4OY3o.js.map +1 -0
  12. package/dist/errors-D3S6Eysd.js +56 -0
  13. package/dist/errors-D3S6Eysd.js.map +1 -0
  14. package/dist/forwarding-logger-BBkMSxuJ.js +85 -0
  15. package/dist/forwarding-logger-BBkMSxuJ.js.map +1 -0
  16. package/dist/index.d.ts +990 -75
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +889 -3890
  19. package/dist/index.js.map +1 -1
  20. package/dist/projection-entry.d.ts +1 -0
  21. package/dist/projection-entry.js +406 -0
  22. package/dist/projection-entry.js.map +1 -0
  23. package/dist/projection-shard-manager-_c7orNo5.js +313 -0
  24. package/dist/projection-shard-manager-_c7orNo5.js.map +1 -0
  25. package/dist/projection-worker-wI4PwcV2.js +13 -0
  26. package/dist/projection-worker-wI4PwcV2.js.map +1 -0
  27. package/dist/transport-ByGviWdZ.js +33 -0
  28. package/dist/transport-ByGviWdZ.js.map +1 -0
  29. package/dist/transport-CuogVKN_.js +23 -0
  30. package/dist/transport-CuogVKN_.js.map +1 -0
  31. package/dist/types-CxSpmNGK.js +32 -0
  32. package/dist/types-CxSpmNGK.js.map +1 -0
  33. package/dist/worker-SUoDhurA.js +22 -0
  34. package/dist/worker-SUoDhurA.js.map +1 -0
  35. package/dist/worker-handle-B1w03nRA.js +383 -0
  36. package/dist/worker-handle-B1w03nRA.js.map +1 -0
  37. package/package.json +6 -4
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import { ILogger } from "document-model";
4
4
  import * as kysely from "kysely";
5
5
  import { Generated, Insertable, Kysely, Transaction } from "kysely";
6
6
  import { IProcessor, IProcessorHostModule, IProcessorManager, IProcessorManager as IProcessorManager$1, IRelationalDb, ProcessorApp, ProcessorFactory, ProcessorFactory as ProcessorFactory$1, ProcessorFactoryBuilder, ProcessorFilter, ProcessorRecord, ProcessorStatus, RelationalDbProcessor, TrackedProcessor, TrackedProcessor as TrackedProcessor$1, createRelationalDb } from "@powerhousedao/shared/processors";
7
+ import { Pool } from "pg";
7
8
 
8
9
  //#region src/attachments/types.d.ts
9
10
  /**
@@ -76,7 +77,7 @@ interface IJobExecutionHandle {
76
77
  readonly state: JobQueueState;
77
78
  start(): void;
78
79
  complete(): void;
79
- fail(error: ErrorInfo): void;
80
+ fail(error: ErrorInfo$1): void;
80
81
  defer(): void;
81
82
  }
82
83
  /**
@@ -94,8 +95,8 @@ type Job = {
94
95
  queueHint: string[]; /** Number of retry attempts */
95
96
  retryCount?: number; /** Maximum number of retries allowed */
96
97
  maxRetries?: number; /** Last error if job failed */
97
- lastError?: ErrorInfo; /** History of all errors from each attempt (ordered) */
98
- errorHistory: ErrorInfo[]; /** Metadata that flows through the job lifecycle */
98
+ lastError?: ErrorInfo$1; /** History of all errors from each attempt (ordered) */
99
+ errorHistory: ErrorInfo$1[]; /** Metadata that flows through the job lifecycle */
99
100
  meta: JobMeta;
100
101
  };
101
102
  /**
@@ -104,6 +105,16 @@ type Job = {
104
105
  declare const QueueEventTypes: {
105
106
  readonly JOB_AVAILABLE: 10000;
106
107
  };
108
+ /**
109
+ * Minimal projection of a Job used by IQueue.dequeueNextMatching predicates.
110
+ * Exposes only the routing-relevant fields so routing logic (e.g. hash(documentId) % numWorkers)
111
+ * can live outside the queue without leaking the full Job.
112
+ */
113
+ type JobRoutingMeta = {
114
+ documentId: string;
115
+ scope: string;
116
+ branch: string;
117
+ };
107
118
  /**
108
119
  * Event data for job available events
109
120
  */
@@ -118,7 +129,7 @@ type JobAvailableEvent = {
118
129
  /**
119
130
  * Information about an error including message and stack trace.
120
131
  */
121
- type ErrorInfo = {
132
+ type ErrorInfo$1 = {
122
133
  message: string;
123
134
  stack: string;
124
135
  };
@@ -179,8 +190,8 @@ type JobInfo = {
179
190
  status: JobStatus;
180
191
  createdAtUtcIso: string;
181
192
  completedAtUtcIso?: string;
182
- error?: ErrorInfo;
183
- errorHistory?: ErrorInfo[];
193
+ error?: ErrorInfo$1;
194
+ errorHistory?: ErrorInfo$1[];
184
195
  result?: any;
185
196
  /**
186
197
  * A token for coordinating reads, only valid once a job reaches COMPLETED.
@@ -305,6 +316,16 @@ interface IReadModelCoordinator {
305
316
  * Stop listening and clean up subscriptions.
306
317
  */
307
318
  stop(): void;
319
+ /**
320
+ * Resolves when every per-queueKey projection chain has flushed.
321
+ * Intended for test fixtures and explicit shutdown.
322
+ */
323
+ drain(): Promise<void>;
324
+ /**
325
+ * Current number of in-flight per-queueKey projection chains.
326
+ * Used as a backpressure signal by observability gauges.
327
+ */
328
+ getChainDepth(): number;
308
329
  }
309
330
  //#endregion
310
331
  //#region src/sync/types.d.ts
@@ -538,6 +559,14 @@ interface IOperationStore {
538
559
  * The provided revision must match the current head; otherwise a
539
560
  * {@link RevisionMismatchError} is thrown.
540
561
  *
562
+ * Returns the stored {@link Operation} rows for the operations that were
563
+ * appended. On an idempotent replay — detected when a
564
+ * {@link RevisionMismatchError} or {@link DuplicateOperationError} occurs and
565
+ * a stored row at the same `(documentId, scope, branch, index)` already has
566
+ * a matching `opId`, `index`, and `skip` — the previously-stored rows are
567
+ * returned instead of throwing. If no matching stored row is found, the
568
+ * original error is propagated unchanged.
569
+ *
541
570
  * @param documentId - The document id
542
571
  * @param documentType - The document type identifier
543
572
  * @param scope - The operation scope (e.g. "global", "local")
@@ -545,8 +574,9 @@ interface IOperationStore {
545
574
  * @param revision - Expected current revision (optimistic lock)
546
575
  * @param fn - Callback that stages operations via {@link AtomicTxn}
547
576
  * @param signal - Optional abort signal to cancel the request
577
+ * @returns The stored operations; empty array when no operations were staged
548
578
  */
549
- apply(documentId: string, documentType: string, scope: string, branch: string, revision: number, fn: (txn: AtomicTxn) => void | Promise<void>, signal?: AbortSignal): Promise<void>;
579
+ apply(documentId: string, documentType: string, scope: string, branch: string, revision: number, fn: (txn: AtomicTxn) => void | Promise<void>, signal?: AbortSignal): Promise<Operation[]>;
550
580
  /**
551
581
  * Returns operations for a document/scope/branch whose index is greater
552
582
  * than the given revision.
@@ -1211,7 +1241,19 @@ declare const ReactorEventTypes: {
1211
1241
  readonly JOB_WRITE_READY: 10003;
1212
1242
  readonly JOB_READ_READY: 10004;
1213
1243
  readonly JOB_FAILED: 10005;
1244
+ readonly READMODEL_BATCH_COMPLETED: 10006;
1245
+ readonly READMODEL_INDEXED: 10007;
1214
1246
  };
1247
+ /**
1248
+ * Stage within ReadModelCoordinator.runChain. Used as a dimension on
1249
+ * stage-attribution events and histograms.
1250
+ */
1251
+ type ReadModelStage = "pre_ready" | "emit" | "post_ready";
1252
+ /**
1253
+ * Stage in which an individual read model ran. The emit stage does not
1254
+ * involve a read model so it is excluded from this discriminant.
1255
+ */
1256
+ type ReadModelIndexingStage = "pre_ready" | "post_ready";
1215
1257
  /**
1216
1258
  * Event emitted when a job is registered and waiting to be executed.
1217
1259
  */
@@ -1267,6 +1309,33 @@ type JobFailedEvent$1 = {
1267
1309
  error: Error;
1268
1310
  job?: Job;
1269
1311
  };
1312
+ /**
1313
+ * Event emitted once per batch processed by ReadModelCoordinator.runChain,
1314
+ * after all three projection stages complete. Carries per-stage wall times,
1315
+ * the chain wait time, and the batch size so projection cost can be
1316
+ * attributed by an observer.
1317
+ */
1318
+ type ReadModelBatchCompletedEvent = {
1319
+ jobId: string;
1320
+ batchSize: number;
1321
+ chainWaitDurationMs: number;
1322
+ preReadyDurationMs: number;
1323
+ emitDurationMs: number;
1324
+ postReadyDurationMs: number;
1325
+ };
1326
+ /**
1327
+ * Event emitted once per individual read model per batch and stage, after
1328
+ * that read model's indexOperations call resolves (or rejects). Lets
1329
+ * observers attribute projection cost to a specific read model.
1330
+ */
1331
+ type ReadModelIndexedEvent = {
1332
+ jobId: string;
1333
+ readModelName: string;
1334
+ stage: ReadModelIndexingStage;
1335
+ durationMs: number;
1336
+ operationCount: number;
1337
+ success: boolean;
1338
+ };
1270
1339
  //#endregion
1271
1340
  //#region src/events/interfaces.d.ts
1272
1341
  /**
@@ -1917,16 +1986,25 @@ declare const JobExecutorEventTypes: {
1917
1986
  type JobStartedEvent = {
1918
1987
  job: Job;
1919
1988
  startedAt: string;
1989
+ /**
1990
+ * Identifier of the executor that took the job. For the worker pool this is
1991
+ * the thread-worker id (e.g. "reactor-worker-3"); for the in-process simple
1992
+ * manager it is "in-process-<index>". Optional for backwards compatibility
1993
+ * with consumers built before the field was added.
1994
+ */
1995
+ workerId?: string;
1920
1996
  };
1921
1997
  type JobCompletedEvent = {
1922
1998
  job: Job;
1923
- result: JobResult;
1999
+ result: JobResult; /** See {@link JobStartedEvent.workerId}. */
2000
+ workerId?: string;
1924
2001
  };
1925
2002
  type JobFailedEvent = {
1926
2003
  job: Job;
1927
2004
  error: string;
1928
2005
  willRetry: boolean;
1929
- retryCount: number;
2006
+ retryCount: number; /** See {@link JobStartedEvent.workerId}. */
2007
+ workerId?: string;
1930
2008
  };
1931
2009
  type ExecutorStartedEvent = {
1932
2010
  config: JobExecutorConfig;
@@ -1946,7 +2024,422 @@ type ExecutorManagerStatus = {
1946
2024
  totalJobsProcessed: number;
1947
2025
  };
1948
2026
  //#endregion
2027
+ //#region src/executor/worker/protocol.d.ts
2028
+ /**
2029
+ * A JSON-clonable value safe to send across the worker IPC boundary.
2030
+ *
2031
+ * The shape mirrors the structured-clone subset used by the parent's
2032
+ * sanitizer: primitives, arrays, plain objects, plus the explicit
2033
+ * {@link ErrorInfo} shape for marshalled Errors.
2034
+ *
2035
+ * @see Wire Protocol Reference wiki page
2036
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2037
+ */
2038
+ type SanitizedArg = null | boolean | number | string | ErrorInfo | SanitizedArg[] | {
2039
+ [key: string]: SanitizedArg;
2040
+ };
2041
+ /**
2042
+ * Structured representation of an Error for IPC transport.
2043
+ *
2044
+ * Class instances cannot be structured-cloned across worker boundaries,
2045
+ * so Errors are flattened into this shape on the worker side and
2046
+ * reconstructed on the parent side.
2047
+ *
2048
+ * @see Wire Protocol Reference wiki page
2049
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2050
+ */
2051
+ type ErrorInfo = {
2052
+ name: string;
2053
+ message: string;
2054
+ stack?: string;
2055
+ cause?: ErrorInfo;
2056
+ };
2057
+ /**
2058
+ * Reference to a module that the worker should `import()` at runtime,
2059
+ * along with the named export to pluck out as the factory.
2060
+ *
2061
+ * Exactly one of `packageName` or `filePath` is provided.
2062
+ *
2063
+ * @see Wire Protocol Reference wiki page
2064
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2065
+ */
2066
+ type ModuleRef = {
2067
+ /** Bare-specifier package name (resolved by the worker's module loader). */packageName: string; /** Named export within the module to invoke as the factory. */
2068
+ exportName: string;
2069
+ } | {
2070
+ /** Absolute or worker-resolvable file path to import. */filePath: string; /** Named export within the module to invoke as the factory. */
2071
+ exportName: string;
2072
+ };
2073
+ /**
2074
+ * Factory specification shared by the signature verifier and document
2075
+ * model spec channels. The worker imports `module.exportName` and invokes
2076
+ * it with `initArgs` to obtain the actual instance.
2077
+ *
2078
+ * `initArgs` must be JSON-clonable.
2079
+ *
2080
+ * @see Wire Protocol Reference wiki page
2081
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2082
+ */
2083
+ type FactorySpec = {
2084
+ module: ModuleRef;
2085
+ initArgs?: SanitizedArg;
2086
+ };
2087
+ /**
2088
+ * Factory spec for the signature verifier the worker should instantiate.
2089
+ *
2090
+ * Structurally identical to {@link FactorySpec}; the alias exists so call
2091
+ * sites read intent-fully.
2092
+ *
2093
+ * @see Wire Protocol Reference wiki page
2094
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2095
+ */
2096
+ type SignatureVerifierSpec = FactorySpec;
2097
+ /**
2098
+ * Factory spec for a document model module the worker should instantiate.
2099
+ *
2100
+ * Structurally identical to {@link FactorySpec}; the alias exists so call
2101
+ * sites read intent-fully.
2102
+ *
2103
+ * @see Wire Protocol Reference wiki page
2104
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2105
+ */
2106
+ type DocumentModelSpec = FactorySpec;
2107
+ /**
2108
+ * One entry in the document model manifest the worker materializes on
2109
+ * startup (or extends lazily via `load-model`).
2110
+ *
2111
+ * @see Wire Protocol Reference wiki page
2112
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2113
+ */
2114
+ type ModelManifestEntry = {
2115
+ /** Document type identifier (e.g. "ph/account"). */documentType: string; /** Document model version this entry registers. */
2116
+ version: string; /** Factory spec the worker imports and invokes to obtain the model. */
2117
+ spec: DocumentModelSpec;
2118
+ };
2119
+ /**
2120
+ * JSON-clonable Postgres connection info passed to the worker so it can
2121
+ * open its own pool. Storage-specific wiring may extend this shape in
2122
+ * later phases.
2123
+ *
2124
+ * @see Wire Protocol Reference wiki page
2125
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2126
+ */
2127
+ type DbConfig = {
2128
+ host: string;
2129
+ port: number;
2130
+ database: string;
2131
+ user: string;
2132
+ password: string;
2133
+ ssl?: boolean;
2134
+ applicationName?: string;
2135
+ poolSize?: number;
2136
+ /**
2137
+ * Maximum time (ms) a caller will wait to acquire a connection from the
2138
+ * pool before pg.Pool throws. When omitted, pg defaults to 0 (unlimited
2139
+ * wait), which hides acquire-starvation as silent latency.
2140
+ */
2141
+ connectionTimeoutMillis?: number;
2142
+ /**
2143
+ * How long (ms) an idle connection stays open before pg closes it. When
2144
+ * omitted, pg defaults to 10000.
2145
+ */
2146
+ idleTimeoutMillis?: number;
2147
+ };
2148
+ /**
2149
+ * Configuration for the executor worker pool.
2150
+ *
2151
+ * Mirrors the `workerPool` sub-config on {@link JobExecutorConfig};
2152
+ * a later card wires this into the executor config.
2153
+ *
2154
+ * @see Wire Protocol Reference wiki page
2155
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2156
+ */
2157
+ type WorkerPoolConfig = {
2158
+ /** Whether the worker pool is active; when false the executor runs in-process. */enabled: boolean; /** Number of worker instances to spawn. */
2159
+ numWorkers: number; /** Worker isolation mode. */
2160
+ workerType: "thread" | "process"; /** Optional heartbeat interval in milliseconds. */
2161
+ heartbeatMs?: number; /** Optional per-worker Postgres pool size override. */
2162
+ workerPgPoolSize?: number;
2163
+ };
2164
+ /**
2165
+ * Payload the worker reports back when a job's write phase is complete.
2166
+ *
2167
+ * Parent fills `collectionMemberships` at emission time, so it is
2168
+ * intentionally absent from the worker -> parent message.
2169
+ *
2170
+ * @see Wire Protocol Reference wiki page
2171
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2172
+ */
2173
+ type JobWriteReadyPayload = {
2174
+ operations: OperationWithContext$1[];
2175
+ jobMeta: JobMeta;
2176
+ };
2177
+ /**
2178
+ * Initializes a freshly spawned worker with the configuration and
2179
+ * factories it needs to start executing jobs.
2180
+ *
2181
+ * @see Wire Protocol Reference wiki page
2182
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2183
+ */
2184
+ type InitMessage = {
2185
+ type: "init";
2186
+ correlationId: string;
2187
+ workerId: string;
2188
+ poolConfig: WorkerPoolConfig;
2189
+ db: DbConfig;
2190
+ signatureVerifier: SignatureVerifierSpec;
2191
+ models: ModelManifestEntry[];
2192
+ };
2193
+ /**
2194
+ * Dispatches a job to the worker for execution.
2195
+ *
2196
+ * @see Wire Protocol Reference wiki page
2197
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2198
+ */
2199
+ type ExecuteMessage = {
2200
+ type: "execute";
2201
+ correlationId: string;
2202
+ job: Job;
2203
+ };
2204
+ /**
2205
+ * Requests cancellation of an in-flight job.
2206
+ *
2207
+ * @see Wire Protocol Reference wiki page
2208
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2209
+ */
2210
+ type AbortMessage = {
2211
+ type: "abort";
2212
+ correlationId: string; /** correlationId of the `execute` message being aborted. */
2213
+ targetCorrelationId: string;
2214
+ reason?: string;
2215
+ };
2216
+ /**
2217
+ * Asks the worker to drain in-flight work and exit.
2218
+ *
2219
+ * @see Wire Protocol Reference wiki page
2220
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2221
+ */
2222
+ type ShutdownMessage = {
2223
+ type: "shutdown";
2224
+ correlationId: string; /** Optional grace period before the parent force-terminates the worker. */
2225
+ graceMs?: number;
2226
+ };
2227
+ /**
2228
+ * Lazily registers an additional document model on a running worker.
2229
+ *
2230
+ * @see Wire Protocol Reference wiki page
2231
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2232
+ */
2233
+ type LoadModelMessage = {
2234
+ type: "load-model";
2235
+ correlationId: string;
2236
+ model: ModelManifestEntry;
2237
+ };
2238
+ /**
2239
+ * Union of all messages the parent may send to a worker.
2240
+ *
2241
+ * @see Wire Protocol Reference wiki page
2242
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2243
+ */
2244
+ type ParentMessage = InitMessage | ExecuteMessage | AbortMessage | ShutdownMessage | LoadModelMessage;
2245
+ /**
2246
+ * Announces that the worker has finished `init` and is ready to accept
2247
+ * `execute` messages.
2248
+ *
2249
+ * @see Wire Protocol Reference wiki page
2250
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2251
+ */
2252
+ type ReadyMessage = {
2253
+ type: "ready"; /** correlationId of the originating `init` message. */
2254
+ correlationId: string;
2255
+ workerId: string;
2256
+ };
2257
+ /**
2258
+ * Final result for an `execute` job.
2259
+ *
2260
+ * On success, `writeReady` carries the operations and job meta the
2261
+ * parent needs to emit `JOB_WRITE_READY`. On failure, `error` is set
2262
+ * and `result.success` is false.
2263
+ *
2264
+ * @see Wire Protocol Reference wiki page
2265
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2266
+ */
2267
+ type ResultMessage = {
2268
+ type: "result"; /** correlationId of the originating `execute` message. */
2269
+ correlationId: string;
2270
+ result: JobResult;
2271
+ writeReady?: JobWriteReadyPayload;
2272
+ error?: ErrorInfo;
2273
+ };
2274
+ /**
2275
+ * Acknowledges that a `load-model` request succeeded.
2276
+ *
2277
+ * @see Wire Protocol Reference wiki page
2278
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2279
+ */
2280
+ type ModelLoadedMessage = {
2281
+ type: "model-loaded"; /** correlationId of the originating `load-model` message. */
2282
+ correlationId: string;
2283
+ documentType: string;
2284
+ version: string;
2285
+ };
2286
+ /**
2287
+ * Reports that a `load-model` request failed.
2288
+ *
2289
+ * @see Wire Protocol Reference wiki page
2290
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2291
+ */
2292
+ type ModelLoadFailedMessage = {
2293
+ type: "model-load-failed"; /** correlationId of the originating `load-model` message. */
2294
+ correlationId: string;
2295
+ documentType: string;
2296
+ version: string;
2297
+ error: ErrorInfo;
2298
+ };
2299
+ /**
2300
+ * Forwarded log line from the worker. `args` is constrained to
2301
+ * {@link SanitizedArg} so callers cannot accidentally ship non-clonable
2302
+ * values across the boundary.
2303
+ *
2304
+ * The sanitizer in `./sanitize.ts` enforces the {@link SanitizedArg}
2305
+ * invariant on the producer side before each message is posted.
2306
+ *
2307
+ * @see Wire Protocol Reference wiki page
2308
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2309
+ */
2310
+ type LogMessage = {
2311
+ type: "log";
2312
+ level: "debug" | "info" | "warn" | "error";
2313
+ message: string;
2314
+ args: SanitizedArg[]; /** Epoch milliseconds at which the worker generated the log line. */
2315
+ timestamp: number;
2316
+ };
2317
+ /**
2318
+ * Periodic liveness signal. Included now to unblock Phase-3 scaffolding;
2319
+ * the wiki marks heartbeats as a Phase-5 future extension.
2320
+ *
2321
+ * @see Wire Protocol Reference wiki page
2322
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2323
+ */
2324
+ type HeartbeatMessage = {
2325
+ type: "heartbeat";
2326
+ workerId: string; /** Epoch milliseconds the worker generated the heartbeat. */
2327
+ timestamp: number; /** Optional snapshot of in-flight job correlation ids. */
2328
+ inFlightCorrelationIds?: string[];
2329
+ };
2330
+ /**
2331
+ * Periodic counters / gauges the worker reports for observability.
2332
+ *
2333
+ * @see Wire Protocol Reference wiki page
2334
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2335
+ */
2336
+ type MetricsMessage = {
2337
+ type: "metrics";
2338
+ workerId: string; /** Epoch milliseconds the worker generated the metrics snapshot. */
2339
+ timestamp: number;
2340
+ counters: {
2341
+ [name: string]: number;
2342
+ };
2343
+ gauges: {
2344
+ [name: string]: number;
2345
+ };
2346
+ };
2347
+ /**
2348
+ * Snapshot of one worker pool's acquire-wait samples and pool-stat counters,
2349
+ * forwarded periodically so the host can re-record into the shared
2350
+ * pg.Pool histogram and observable gauges. The worker owns the real
2351
+ * pg.Pool; the host's {@link PoolInstrumentation} is a forwarder driven
2352
+ * by these messages.
2353
+ */
2354
+ type PoolAcquireSamplesMessage = {
2355
+ type: "pool-acquire-samples";
2356
+ workerId: string; /** Stable identifier matching the host-side instrumentation name (e.g. "worker-0"). */
2357
+ poolName: string; /** Epoch milliseconds the worker generated the batch. */
2358
+ timestamp: number; /** Acquire-wait durations (ms) accumulated since the previous batch. */
2359
+ durations: number[]; /** Most recent pg.Pool counter snapshot at batch send time. */
2360
+ size: number;
2361
+ idle: number;
2362
+ waiting: number;
2363
+ };
2364
+ /**
2365
+ * Union of all messages a worker may send to the parent.
2366
+ *
2367
+ * @see Wire Protocol Reference wiki page
2368
+ * (Powerhouse board wiki id: 64c03e51-1aa4-4fa9-93d8-daa45642484d)
2369
+ */
2370
+ type WorkerMessage = ReadyMessage | ResultMessage | ModelLoadedMessage | ModelLoadFailedMessage | LogMessage | HeartbeatMessage | MetricsMessage | PoolAcquireSamplesMessage;
2371
+ //#endregion
1949
2372
  //#region src/executor/interfaces.d.ts
2373
+ /**
2374
+ * Snapshot of the single in-flight slot maintained by an {@link IExecutorWorker}.
2375
+ */
2376
+ type WorkerInFlightSnapshot = {
2377
+ correlationId: string;
2378
+ jobId: string;
2379
+ };
2380
+ /**
2381
+ * Outcome of a worker-side job execution.
2382
+ *
2383
+ * `result` mirrors the in-process `JobResult` exactly. `writeReady` carries
2384
+ * the operations + jobMeta the parent needs to emit `JOB_WRITE_READY`, and is
2385
+ * present only when the worker produced operations. It is absent on failure
2386
+ * and on success-with-no-operations.
2387
+ */
2388
+ type WorkerExecutionOutcome = {
2389
+ result: JobResult;
2390
+ writeReady?: JobWriteReadyPayload;
2391
+ };
2392
+ /**
2393
+ * Parent-side handle for a single executor worker.
2394
+ *
2395
+ * Implementations wrap an IPC transport (worker_threads, child_process, or a
2396
+ * test fake) and expose a transport-agnostic surface that the worker-pool
2397
+ * manager uses to dispatch jobs. The handle owns one worker's lifecycle
2398
+ * (`start` -> `execute`* -> `shutdown`) and bounds its in-flight map to a
2399
+ * single entry; `SimpleJobExecutor` is single-threaded inside the worker, so
2400
+ * concurrent dispatches would race its caches.
2401
+ */
2402
+ interface IExecutorWorker {
2403
+ /** Stable identifier of the worker (mirrors `InitMessage.workerId`). */
2404
+ readonly workerId: string;
2405
+ /** Zero-based index within the pool, used for sticky routing. */
2406
+ readonly index: number;
2407
+ /**
2408
+ * Spawn the worker (if not already started), send the `init` payload and
2409
+ * resolve when the worker replies with `ready`.
2410
+ */
2411
+ start(): Promise<void>;
2412
+ /**
2413
+ * Dispatch a job to the worker and resolve with its outcome — the
2414
+ * `JobResult` and, on success-with-operations, a `writeReady` payload
2415
+ * the parent will enrich and re-emit. Rejects with a transport-level
2416
+ * error if the worker exits, aborts, or times out before producing a
2417
+ * result.
2418
+ */
2419
+ execute(job: Job, signal?: AbortSignal): Promise<WorkerExecutionOutcome>;
2420
+ /**
2421
+ * Request cancellation of the in-flight job (if any). The handle posts an
2422
+ * `abort` message; if the worker fails to reply within its grace window it
2423
+ * is force-terminated.
2424
+ */
2425
+ abort(correlationId: string, reason?: string): void;
2426
+ /**
2427
+ * Stop the worker. When `graceful` is true the handle waits for the
2428
+ * in-flight job to settle (up to `graceMs`) before terminating; otherwise
2429
+ * the worker is terminated immediately.
2430
+ */
2431
+ shutdown(graceful: boolean, graceMs?: number): Promise<void>;
2432
+ /**
2433
+ * Register an additional document model on the running worker. Resolves
2434
+ * when the worker replies with `model-loaded`; rejects when it replies
2435
+ * with `model-load-failed` or the worker exits before answering.
2436
+ */
2437
+ loadModel(entry: ModelManifestEntry, signal?: AbortSignal): Promise<void>;
2438
+ /** True when no job is currently in flight. */
2439
+ isIdle(): boolean;
2440
+ /** Snapshot of the in-flight slot, or null when idle. */
2441
+ getInFlight(): WorkerInFlightSnapshot | null;
2442
+ }
1950
2443
  /**
1951
2444
  * Simple interface for executing a job.
1952
2445
  * A JobExecutor simply takes a job and executes it - nothing more.
@@ -2019,7 +2512,7 @@ interface IJobTracker {
2019
2512
  * @param error - Error information including message and stack trace
2020
2513
  * @param job - Optional full job object for debugging purposes
2021
2514
  */
2022
- markFailed(jobId: string, error: ErrorInfo, job?: Job): void;
2515
+ markFailed(jobId: string, error: ErrorInfo$1, job?: Job): void;
2023
2516
  /**
2024
2517
  * Retrieve the current status of a job.
2025
2518
  *
@@ -2064,6 +2557,18 @@ interface IQueue {
2064
2557
  * @returns Promise that resolves to the next job execution handle or null if no jobs available
2065
2558
  */
2066
2559
  dequeueNext(signal?: AbortSignal): Promise<IJobExecutionHandle | null>;
2560
+ /**
2561
+ * Get the next available job whose routing metadata satisfies the predicate.
2562
+ * Walks ready sub-queue heads in queue insertion order, skips heads whose document
2563
+ * is currently executing (same isDocumentExecuting gate as dequeueNext), and returns
2564
+ * the first head for which predicate returns true.
2565
+ * Returns null when paused, when nothing matches, or when the queue is empty.
2566
+ * Rejects if signal is already aborted.
2567
+ * @param predicate - Filter applied to JobRoutingMeta of each candidate head
2568
+ * @param signal - Optional abort signal to cancel the request
2569
+ * @returns Promise that resolves to the first matching job execution handle or null
2570
+ */
2571
+ dequeueNextMatching(predicate: (meta: JobRoutingMeta) => boolean, signal?: AbortSignal): Promise<IJobExecutionHandle | null>;
2067
2572
  /**
2068
2573
  * Get the current size of the queue for a specific document/scope/branch.
2069
2574
  * @param documentId - The document ID
@@ -2113,14 +2618,14 @@ interface IQueue {
2113
2618
  * @param error - Optional error information
2114
2619
  * @returns Promise that resolves when the job is marked as failed
2115
2620
  */
2116
- failJob(jobId: string, error?: ErrorInfo): Promise<void>;
2621
+ failJob(jobId: string, error?: ErrorInfo$1): Promise<void>;
2117
2622
  /**
2118
2623
  * Retry a failed job.
2119
2624
  * @param jobId - The ID of the job to retry
2120
2625
  * @param error - Optional error information from the failure
2121
2626
  * @returns Promise that resolves when the job is requeued for retry
2122
2627
  */
2123
- retryJob(jobId: string, error?: ErrorInfo): Promise<void>;
2628
+ retryJob(jobId: string, error?: ErrorInfo$1): Promise<void>;
2124
2629
  /**
2125
2630
  * Returns true if and only if all jobs have been resolved.
2126
2631
  */
@@ -2201,9 +2706,15 @@ type RegistrationResult<T> = {
2201
2706
  * Loader that can asynchronously resolve and return a document model module
2202
2707
  * for a given document type. Used by the queue to gate CREATE_DOCUMENT jobs
2203
2708
  * until the required model is available in the registry.
2709
+ *
2710
+ * `resolveSpec` is an optional companion that returns the IPC-clonable spec
2711
+ * for the same document type. Implementations that integrate with the worker
2712
+ * pool must provide it so the parent can broadcast `load-model` to workers
2713
+ * after registering the model on the parent.
2204
2714
  */
2205
2715
  interface IDocumentModelLoader {
2206
2716
  load(documentType: string): Promise<DocumentModelModule<any>>;
2717
+ resolveSpec?(documentType: string): Promise<ModelManifestEntry | null>;
2207
2718
  }
2208
2719
  /**
2209
2720
  * Registry for managing document model modules.
@@ -2488,6 +2999,53 @@ interface DocumentIndexerDatabase {
2488
2999
  IndexerState: IndexerStateTable;
2489
3000
  }
2490
3001
  //#endregion
3002
+ //#region src/storage/pool-instrumentation.d.ts
3003
+ /**
3004
+ * Snapshot of a pg.Pool's internal counters at a point in time.
3005
+ */
3006
+ type PoolStats = {
3007
+ /** Connections currently open (idle + in-use). pg.Pool.totalCount. */size: number; /** Open connections not currently checked out. pg.Pool.idleCount. */
3008
+ idle: number; /** Callers queued waiting for a connection. pg.Pool.waitingCount. */
3009
+ waiting: number;
3010
+ };
3011
+ /**
3012
+ * Observable handle over an instrumented pg.Pool. Surfaces acquire-wait
3013
+ * timing and pool-stat counters without coupling the consumer to the
3014
+ * underlying pg.Pool type.
3015
+ */
3016
+ type PoolInstrumentation = {
3017
+ /** Stable identifier for the pool (e.g. "host", "worker"). Used as a metric label. */readonly name: string; /** Current pool counters. Cheap, synchronous read off pg.Pool. */
3018
+ getStats(): PoolStats;
3019
+ /**
3020
+ * Subscribe to per-acquire wait durations. Listener fires once per
3021
+ * resolved pool.connect() call with the time spent waiting for a client.
3022
+ * Returns an unsubscribe function.
3023
+ */
3024
+ onAcquire(listener: (durationMs: number) => void): () => void;
3025
+ };
3026
+ /**
3027
+ * Wraps an existing pg.Pool with acquire-wait timing and an event
3028
+ * subscription surface. The pool is mutated in place: pool.connect()
3029
+ * is replaced with a timing wrapper so all callers (Kysely included)
3030
+ * pick up the instrumentation transparently.
3031
+ */
3032
+ declare function instrumentPgPool(pool: Pool, name: string): PoolInstrumentation;
3033
+ /**
3034
+ * Host-side {@link PoolInstrumentation} that re-emits acquire-wait samples
3035
+ * and pool-stat snapshots forwarded from a worker thread. The worker owns
3036
+ * the real pg.Pool; this object lets the host's OpenTelemetry instrumentation
3037
+ * subscribe to those events as if the pool were local.
3038
+ *
3039
+ * The host wires one of these per worker (one per executor worker, one per
3040
+ * projection shard). The worker batches acquire-wait durations and periodic
3041
+ * stats over its existing transport; the host pumps them in via
3042
+ * {@link pushSamples} / {@link updateStats}.
3043
+ */
3044
+ type ForwardingPoolInstrumentation = PoolInstrumentation & {
3045
+ pushSamples(durations: number[]): void;
3046
+ updateStats(stats: PoolStats): void;
3047
+ };
3048
+ //#endregion
2491
3049
  //#region src/sync/errors.d.ts
2492
3050
  declare class PollingChannelError extends Error {
2493
3051
  constructor(message: string);
@@ -3113,6 +3671,13 @@ interface ReactorModule {
3113
3671
  processorManagerConsistencyTracker: IConsistencyTracker;
3114
3672
  syncModule: SyncModule | undefined;
3115
3673
  reactor: IReactor;
3674
+ /**
3675
+ * Instrumented pg.Pool handles registered with the builder, either by
3676
+ * createPostgresDatabase or by withInstrumentedPool. Empty when no pg
3677
+ * pool is in use (e.g. PGlite tests). Observers iterate the array to
3678
+ * record per-pool acquire-wait and stat metrics.
3679
+ */
3680
+ pools: PoolInstrumentation[];
3116
3681
  }
3117
3682
  /**
3118
3683
  * Container for all reactor client dependencies created during the build process.
@@ -3159,6 +3724,63 @@ declare class DriveClient implements IDriveClient {
3159
3724
  private removeFileNode;
3160
3725
  }
3161
3726
  //#endregion
3727
+ //#region src/cache/collection-membership-cache.d.ts
3728
+ interface ICollectionMembershipCache {
3729
+ getCollectionsForDocuments(documentIds: string[]): Promise<Record<string, string[]>>;
3730
+ invalidate(documentId: string): void;
3731
+ }
3732
+ //#endregion
3733
+ //#region src/registry/document-model-resolver.d.ts
3734
+ interface IDocumentModelResolver {
3735
+ ensureModelLoaded(documentType: string): Promise<void>;
3736
+ }
3737
+ /**
3738
+ * Post-success hook called after the resolver registers a newly loaded
3739
+ * model on the parent's registry. Used to broadcast `load-model` to the
3740
+ * worker pool so workers can register the same model locally.
3741
+ */
3742
+ type ModelLoadedBroadcastHook = (entry: ModelManifestEntry) => Promise<void>;
3743
+ /**
3744
+ * Encapsulates the logic for resolving document model modules on demand.
3745
+ * Shared between the queue (CREATE_DOCUMENT gate) and the executor manager
3746
+ * (post-failure recovery) so that both paths use the same deduplication
3747
+ * and failure-caching state.
3748
+ */
3749
+ declare class DocumentModelResolver implements IDocumentModelResolver {
3750
+ private registry;
3751
+ private loader;
3752
+ private loadingModels;
3753
+ private failedModelTypes;
3754
+ private broadcastHook;
3755
+ constructor(registry: IDocumentModelRegistry, loader: IDocumentModelLoader);
3756
+ /**
3757
+ * Install a post-success hook called after the resolver registers a
3758
+ * newly loaded model. ReactorBuilder uses this to wire the worker-pool
3759
+ * `load-model` broadcast without touching the resolver's constructor.
3760
+ */
3761
+ setBroadcastHook(hook: ModelLoadedBroadcastHook): void;
3762
+ ensureModelLoaded(documentType: string): Promise<void>;
3763
+ private broadcastIfPossible;
3764
+ }
3765
+ /**
3766
+ * No-op resolver used when no document model loader is configured.
3767
+ * Checks the registry for the model and returns if found; throws if not.
3768
+ * Since there is no loader, missing models cannot be recovered.
3769
+ */
3770
+ declare class NullDocumentModelResolver implements IDocumentModelResolver {
3771
+ private registry?;
3772
+ constructor(registry?: IDocumentModelRegistry | undefined);
3773
+ ensureModelLoaded(documentType: string): Promise<void>;
3774
+ }
3775
+ //#endregion
3776
+ //#region src/executor/worker-pool-job-executor-manager.d.ts
3777
+ /**
3778
+ * Factory invoked once per worker at `start()` time. The index is the
3779
+ * worker's position in the pool and the same value the manager will use
3780
+ * for sticky routing (`bucketFor(documentId) === index`).
3781
+ */
3782
+ type WorkerFactory = (index: number) => IExecutorWorker;
3783
+ //#endregion
3162
3784
  //#region src/cache/write-cache-types.d.ts
3163
3785
  /**
3164
3786
  * Configuration options for the write cache
@@ -3191,6 +3813,207 @@ type KeyframeSnapshot = {
3191
3813
  document: string;
3192
3814
  };
3193
3815
  //#endregion
3816
+ //#region src/projection/protocol.d.ts
3817
+ /**
3818
+ * Identifier for a built-in read model the projection worker materializes
3819
+ * on init. The host names which models each shard should run; the worker
3820
+ * constructs them itself against its local Kysely instance.
3821
+ */
3822
+ type BuiltInReadModelKind = "document-view" | "document-indexer";
3823
+ /**
3824
+ * Initializes a freshly spawned projection worker. The worker uses
3825
+ * `db` to open its own pg.Pool + Kysely, loads `models` into a local
3826
+ * `DocumentModelRegistry`, materializes each `readModelKinds` entry as a
3827
+ * concrete read model bound to the local DB, and starts a local
3828
+ * `ReadModelCoordinator` that consumes the JOB_WRITE_READY relays.
3829
+ */
3830
+ type ProjectionInitMessage = {
3831
+ type: "init";
3832
+ correlationId: string;
3833
+ shardId: string;
3834
+ shardIndex: number;
3835
+ shardCount: number;
3836
+ db: DbConfig;
3837
+ models: ModelManifestEntry[];
3838
+ preReadyKinds: BuiltInReadModelKind[];
3839
+ postReadyKinds: BuiltInReadModelKind[];
3840
+ chainDepthReportIntervalMs: number;
3841
+ };
3842
+ /**
3843
+ * Relays a JOB_WRITE_READY event from the host bus into the worker's
3844
+ * local bus, where the in-worker `ReadModelCoordinator` picks it up.
3845
+ *
3846
+ * The host fans messages to shards via `bucketFor(documentId, shardCount)`
3847
+ * — the worker does not re-hash and assumes the message landed on it
3848
+ * because the host already chose this shard.
3849
+ */
3850
+ type ProjectionWriteReadyMessage = {
3851
+ type: "write-ready";
3852
+ jobId: string;
3853
+ operations: OperationWithContext$1[];
3854
+ jobMeta: JobMeta;
3855
+ collectionMemberships?: Record<string, string[]>;
3856
+ };
3857
+ /**
3858
+ * Asks the worker to drain its in-flight chains and respond with
3859
+ * {@link ProjectionDrainedMessage}.
3860
+ */
3861
+ type ProjectionDrainMessage = {
3862
+ type: "drain";
3863
+ correlationId: string;
3864
+ };
3865
+ /**
3866
+ * Asks the worker to drain in-flight work, close its DB pool, and exit.
3867
+ */
3868
+ type ProjectionShutdownMessage = {
3869
+ type: "shutdown";
3870
+ correlationId: string;
3871
+ graceMs?: number;
3872
+ };
3873
+ type ProjectionParentMessage = ProjectionInitMessage | ProjectionWriteReadyMessage | ProjectionDrainMessage | ProjectionShutdownMessage;
3874
+ /**
3875
+ * Announces that the worker has finished `init` and is ready to accept
3876
+ * `write-ready` relays.
3877
+ */
3878
+ type ProjectionReadyMessage = {
3879
+ type: "ready";
3880
+ correlationId: string;
3881
+ shardId: string;
3882
+ };
3883
+ /**
3884
+ * Forwarded JOB_READ_READY event from the worker's local bus. The host
3885
+ * re-emits this on the host bus so observers (sync manager, awaiters,
3886
+ * tests) see it exactly once per job.
3887
+ */
3888
+ type ProjectionReadReadyMessage = {
3889
+ type: "read-ready";
3890
+ shardId: string;
3891
+ jobId: string;
3892
+ operations: OperationWithContext$1[];
3893
+ };
3894
+ /**
3895
+ * Forwarded READMODEL_INDEXED event from the worker's local bus.
3896
+ */
3897
+ type ProjectionReadModelIndexedMessage = {
3898
+ type: "readmodel-indexed";
3899
+ shardId: string;
3900
+ jobId: string;
3901
+ readModelName: string;
3902
+ stage: ReadModelIndexingStage;
3903
+ durationMs: number;
3904
+ operationCount: number;
3905
+ success: boolean;
3906
+ };
3907
+ /**
3908
+ * Forwarded READMODEL_BATCH_COMPLETED event from the worker's local bus.
3909
+ */
3910
+ type ProjectionBatchCompletedMessage = {
3911
+ type: "readmodel-batch-completed";
3912
+ shardId: string;
3913
+ jobId: string;
3914
+ batchSize: number;
3915
+ chainWaitDurationMs: number;
3916
+ preReadyDurationMs: number;
3917
+ emitDurationMs: number;
3918
+ postReadyDurationMs: number;
3919
+ };
3920
+ /**
3921
+ * Periodic chain-depth report. Workers post this on a fixed cadence so
3922
+ * the host can aggregate per-shard depths without polling.
3923
+ */
3924
+ type ProjectionChainDepthMessage = {
3925
+ type: "chain-depth";
3926
+ shardId: string;
3927
+ depth: number;
3928
+ timestamp: number;
3929
+ };
3930
+ /**
3931
+ * Snapshot of one shard's pg.Pool acquire-wait samples and pool-stat
3932
+ * counters. The shard owns its real pg.Pool; the host's
3933
+ * {@link PoolInstrumentation} is a forwarder driven by these messages.
3934
+ */
3935
+ type ProjectionPoolAcquireSamplesMessage = {
3936
+ type: "pool-acquire-samples";
3937
+ shardId: string; /** Stable identifier matching the host-side instrumentation name. */
3938
+ poolName: string; /** Epoch milliseconds the worker generated the batch. */
3939
+ timestamp: number; /** Acquire-wait durations (ms) accumulated since the previous batch. */
3940
+ durations: number[]; /** Most recent pg.Pool counter snapshot at batch send time. */
3941
+ size: number;
3942
+ idle: number;
3943
+ waiting: number;
3944
+ };
3945
+ /**
3946
+ * Acknowledges that a `drain` request has flushed all in-flight chains.
3947
+ */
3948
+ type ProjectionDrainedMessage = {
3949
+ type: "drained";
3950
+ correlationId: string;
3951
+ shardId: string;
3952
+ };
3953
+ /**
3954
+ * Forwarded log line from the worker. Mirrors the executor worker's
3955
+ * sanitized log envelope so callers can route both through the same
3956
+ * host-side logger.
3957
+ */
3958
+ type ProjectionLogMessage = {
3959
+ type: "log";
3960
+ shardId: string;
3961
+ level: "debug" | "info" | "warn" | "error";
3962
+ message: string;
3963
+ args: SanitizedArg[];
3964
+ timestamp: number;
3965
+ };
3966
+ type ProjectionWorkerMessage = ProjectionReadyMessage | ProjectionReadReadyMessage | ProjectionReadModelIndexedMessage | ProjectionBatchCompletedMessage | ProjectionChainDepthMessage | ProjectionPoolAcquireSamplesMessage | ProjectionDrainedMessage | ProjectionLogMessage;
3967
+ //#endregion
3968
+ //#region src/projection/transport.d.ts
3969
+ type ProjectionTransportEventMap = {
3970
+ message: ProjectionWorkerMessage;
3971
+ error: Error;
3972
+ exit: number;
3973
+ };
3974
+ type ProjectionTransportEvent = keyof ProjectionTransportEventMap;
3975
+ type ProjectionTransportListener<E extends ProjectionTransportEvent> = (payload: ProjectionTransportEventMap[E]) => void;
3976
+ /**
3977
+ * Minimal subset of `worker_threads.Worker` the {@link ProjectionShardManager}
3978
+ * relies on. The host writes against this interface so tests can swap in
3979
+ * a fake transport without spawning real worker threads.
3980
+ */
3981
+ interface IProjectionTransport {
3982
+ postMessage(message: ProjectionParentMessage): void;
3983
+ on<E extends ProjectionTransportEvent>(event: E, listener: ProjectionTransportListener<E>): void;
3984
+ off<E extends ProjectionTransportEvent>(event: E, listener: ProjectionTransportListener<E>): void;
3985
+ terminate(): Promise<number>;
3986
+ }
3987
+ //#endregion
3988
+ //#region src/projection/projection-shard-manager.d.ts
3989
+ /**
3990
+ * Factory that builds one projection-worker transport. Mirrors
3991
+ * `WorkerFactory` from the executor pool: lets tests inject fake
3992
+ * transports without spawning real worker threads.
3993
+ */
3994
+ type ProjectionWorkerFactory = (shardIndex: number, shardId: string) => IProjectionTransport;
3995
+ type ProjectionShardManagerConfig = {
3996
+ shardCount: number;
3997
+ db: DbConfig;
3998
+ models: ModelManifestEntry[];
3999
+ preReadyKinds: BuiltInReadModelKind[];
4000
+ postReadyKinds: BuiltInReadModelKind[];
4001
+ factory: ProjectionWorkerFactory;
4002
+ logger: ILogger;
4003
+ hostBus: IEventBus;
4004
+ initTimeoutMs?: number;
4005
+ shutdownGraceMs?: number;
4006
+ drainTimeoutMs?: number;
4007
+ chainDepthReportIntervalMs?: number;
4008
+ /**
4009
+ * Host-side forwarding instrumentations indexed by shard index. The
4010
+ * manager routes each shard's `pool-acquire-samples` message to the
4011
+ * matching forwarder so the host's OpenTelemetry instrumentation records
4012
+ * acquire-wait latencies as if each shard's pg.Pool were local.
4013
+ */
4014
+ poolInstrumentations?: ForwardingPoolInstrumentation[];
4015
+ };
4016
+ //#endregion
3194
4017
  //#region src/signer/types.d.ts
3195
4018
  /**
3196
4019
  * Configuration for signing and verification.
@@ -3249,6 +4072,36 @@ interface ReadModelFactoryDeps {
3249
4072
  * dependencies once they are available. Awaited during `buildModule()`.
3250
4073
  */
3251
4074
  type ReadModelFactory = (deps: ReadModelFactoryDeps) => IReadModel | Promise<IReadModel>;
4075
+ /**
4076
+ * Describes a document-model package the worker should import at runtime.
4077
+ * Either a bare-specifier package or an absolute file path.
4078
+ */
4079
+ type DocumentModelSpecInput = {
4080
+ packageName: string;
4081
+ version: string;
4082
+ } | {
4083
+ filePath: string;
4084
+ };
4085
+ /**
4086
+ * Caller-facing config for {@link ReactorBuilder.withProjectionShards}.
4087
+ * When set, the builder replaces the in-process
4088
+ * {@link ReadModelCoordinator} with a {@link ProjectionShardManager} that
4089
+ * fans JOB_WRITE_READY events to N projection workers sharded by
4090
+ * documentId.
4091
+ *
4092
+ * @see Sharded projection workers sub-feature brief
4093
+ * (Powerhouse board wiki id: eb26f01f-8f68-4918-a6f6-ac7a4679b533)
4094
+ */
4095
+ type ProjectionShardBuilderConfig = {
4096
+ shardCount: number;
4097
+ preReadyKinds: BuiltInReadModelKind[];
4098
+ postReadyKinds: BuiltInReadModelKind[];
4099
+ poolSize?: number;
4100
+ initTimeoutMs?: number;
4101
+ shutdownGraceMs?: number;
4102
+ drainTimeoutMs?: number;
4103
+ chainDepthReportIntervalMs?: number;
4104
+ };
3252
4105
  declare class ReactorBuilder {
3253
4106
  private logger?;
3254
4107
  private documentModels;
@@ -3272,6 +4125,15 @@ declare class ReactorBuilder {
3272
4125
  private documentModelLoader?;
3273
4126
  private shutdownHooks;
3274
4127
  private driveContainerTypes;
4128
+ private documentModelSpecs;
4129
+ private workerPoolConfig?;
4130
+ private resolvedModelManifest?;
4131
+ private workerDbConfig?;
4132
+ private workerSignatureVerifierSpec?;
4133
+ private workerFactory?;
4134
+ private projectionShardConfig?;
4135
+ private projectionWorkerFactory?;
4136
+ private instrumentedPools;
3275
4137
  withLogger(logger: ILogger): this;
3276
4138
  withDocumentModels(models: DocumentModelModule<any>[]): this;
3277
4139
  withUpgradeManifests(manifests: UpgradeManifest<readonly number[]>[]): this;
@@ -3295,6 +4157,14 @@ declare class ReactorBuilder {
3295
4157
  withEventBus(eventBus: IEventBus): this;
3296
4158
  withSignatureVerifier(verifier: SignatureVerificationHandler): this;
3297
4159
  withKysely(kysely: Kysely<Database>): this;
4160
+ /**
4161
+ * Register an externally-constructed pg.Pool's {@link PoolInstrumentation}
4162
+ * so it surfaces through {@link ReactorModule.pools}. Use this when the
4163
+ * caller built the pool itself (e.g. the in-process bench host wiring) so
4164
+ * pool acquire-wait and pool-stat metrics still emit. The builder also
4165
+ * registers any pool it constructs internally via {@link createPostgresDatabase}.
4166
+ */
4167
+ withInstrumentedPool(instrumentation: PoolInstrumentation): this;
3298
4168
  withQueue(queue: IQueue): this;
3299
4169
  withChannelScheme(scheme: ChannelScheme): this;
3300
4170
  withJwtHandler(handler: JwtHandler): this;
@@ -3309,8 +4179,79 @@ declare class ReactorBuilder {
3309
4179
  * shutdown chain.
3310
4180
  */
3311
4181
  withShutdownHook(hook: () => Promise<void>): this;
4182
+ withDocumentModelSpecs(specs: DocumentModelSpecInput[]): this;
4183
+ /**
4184
+ * Stores the worker-pool configuration. When `config.enabled === true` the
4185
+ * builder constructs a {@link WorkerPoolJobExecutorManager} in place of the
4186
+ * in-process {@link SimpleJobExecutorManager}.
4187
+ */
4188
+ withWorkerPool(config: WorkerPoolConfig): this;
4189
+ /**
4190
+ * Postgres connection info forwarded to each worker so it can open its own
4191
+ * pool. Required when `workerPool.enabled === true` unless a custom
4192
+ * `withWorkerFactory` or `withExecutor` is provided.
4193
+ */
4194
+ withWorkerDbConfig(db: DbConfig): this;
4195
+ /**
4196
+ * Factory spec the worker imports to instantiate its signature verifier.
4197
+ * Required when `workerPool.enabled === true` unless a custom
4198
+ * `withWorkerFactory` or `withExecutor` is provided.
4199
+ */
4200
+ withWorkerSignatureVerifierSpec(spec: SignatureVerifierSpec): this;
4201
+ /**
4202
+ * Inject a custom {@link WorkerFactory}. When set, the builder skips
4203
+ * default thread-transport wiring and hands the factory directly to the
4204
+ * pool manager. Use this in tests or to plug in a different transport
4205
+ * (e.g. a child-process adapter).
4206
+ */
4207
+ withWorkerFactory(factory: WorkerFactory): this;
4208
+ /**
4209
+ * Configure N sharded projection workers. When set, the builder replaces
4210
+ * the default in-process {@link ReadModelCoordinator} with a
4211
+ * {@link ProjectionShardManager}. The same `DbConfig` registered via
4212
+ * {@link withWorkerDbConfig} is reused for the projection workers'
4213
+ * connection info; only the `poolSize` is overridden by
4214
+ * {@link ProjectionShardBuilderConfig.poolSize}.
4215
+ *
4216
+ * Requires {@link withWorkerDbConfig} (the projection workers need
4217
+ * connection info to open their own pools). The same model manifest
4218
+ * resolved from {@link withDocumentModelSpecs} is forwarded.
4219
+ */
4220
+ withProjectionShards(config: ProjectionShardBuilderConfig): this;
4221
+ /**
4222
+ * Inject a custom {@link ProjectionWorkerFactory}. When set, the builder
4223
+ * skips default thread-transport wiring for the projection shards and
4224
+ * hands the factory directly to {@link ProjectionShardManager}.
4225
+ */
4226
+ withProjectionWorkerFactory(factory: ProjectionWorkerFactory): this;
4227
+ getResolvedModelManifest(): ModelManifestEntry[] | undefined;
3312
4228
  build(): Promise<IReactor>;
3313
4229
  buildModule(): Promise<ReactorModule>;
4230
+ /**
4231
+ * Constructs a {@link ProjectionShardManager} bound to the host event
4232
+ * bus. Builds the default thread-transport factory unless one was
4233
+ * injected via {@link withProjectionWorkerFactory}. Calls
4234
+ * `manager.startup()` so all N workers reach READY before the reactor
4235
+ * is returned to the caller.
4236
+ */
4237
+ private createProjectionShardManager;
4238
+ private createDefaultProjectionWorkerFactory;
4239
+ /**
4240
+ * Default {@link WorkerFactory} used when `workerPool.enabled` is set and
4241
+ * the caller did not inject `withWorkerFactory`. Each worker spawns a real
4242
+ * `node:worker_threads` Worker pointing at the compiled `worker/entry.js`.
4243
+ */
4244
+ private createDefaultWorkerFactory;
4245
+ /**
4246
+ * Builds the parent Kysely instance against a real Postgres server using
4247
+ * the same {@link DbConfig} the workers receive at init. Used in the
4248
+ * worker-pool path so the parent reactor and each worker thread share
4249
+ * storage; PGlite cannot be shared across threads. The constructed pool
4250
+ * is wrapped with {@link instrumentPgPool} and the resulting
4251
+ * {@link PoolInstrumentation} is pushed onto {@link instrumentedPools} so
4252
+ * the reactor module exposes acquire-wait and pool-stat surfaces.
4253
+ */
4254
+ private createPostgresDatabase;
3314
4255
  private attachSignalHandlers;
3315
4256
  }
3316
4257
  //#endregion
@@ -3505,35 +4446,6 @@ declare class EventBus implements IEventBus {
3505
4446
  emit(type: number, data: any): Promise<void>;
3506
4447
  }
3507
4448
  //#endregion
3508
- //#region src/registry/document-model-resolver.d.ts
3509
- interface IDocumentModelResolver {
3510
- ensureModelLoaded(documentType: string): Promise<void>;
3511
- }
3512
- /**
3513
- * Encapsulates the logic for resolving document model modules on demand.
3514
- * Shared between the queue (CREATE_DOCUMENT gate) and the executor manager
3515
- * (post-failure recovery) so that both paths use the same deduplication
3516
- * and failure-caching state.
3517
- */
3518
- declare class DocumentModelResolver implements IDocumentModelResolver {
3519
- private registry;
3520
- private loader;
3521
- private loadingModels;
3522
- private failedModelTypes;
3523
- constructor(registry: IDocumentModelRegistry, loader: IDocumentModelLoader);
3524
- ensureModelLoaded(documentType: string): Promise<void>;
3525
- }
3526
- /**
3527
- * No-op resolver used when no document model loader is configured.
3528
- * Checks the registry for the model and returns if found; throws if not.
3529
- * Since there is no loader, missing models cannot be recovered.
3530
- */
3531
- declare class NullDocumentModelResolver implements IDocumentModelResolver {
3532
- private registry?;
3533
- constructor(registry?: IDocumentModelRegistry | undefined);
3534
- ensureModelLoaded(documentType: string): Promise<void>;
3535
- }
3536
- //#endregion
3537
4449
  //#region src/queue/queue.d.ts
3538
4450
  /**
3539
4451
  * In-memory implementation of the IQueue interface.
@@ -3593,6 +4505,7 @@ declare class InMemoryQueue implements IQueue {
3593
4505
  enqueue(job: Job): Promise<void>;
3594
4506
  dequeue(documentId: string, scope: string, branch: string, signal?: AbortSignal): Promise<IJobExecutionHandle | null>;
3595
4507
  dequeueNext(signal?: AbortSignal): Promise<IJobExecutionHandle | null>;
4508
+ dequeueNextMatching(predicate: (meta: JobRoutingMeta) => boolean, signal?: AbortSignal): Promise<IJobExecutionHandle | null>;
3596
4509
  size(documentId: string, scope: string, branch: string): Promise<number>;
3597
4510
  totalSize(): Promise<number>;
3598
4511
  remove(jobId: string): Promise<boolean>;
@@ -3600,9 +4513,9 @@ declare class InMemoryQueue implements IQueue {
3600
4513
  clearAll(): Promise<void>;
3601
4514
  hasJobs(): Promise<boolean>;
3602
4515
  completeJob(jobId: string): Promise<void>;
3603
- failJob(jobId: string, error?: ErrorInfo): Promise<void>;
4516
+ failJob(jobId: string, error?: ErrorInfo$1): Promise<void>;
3604
4517
  deferJob(jobId: string): void;
3605
- retryJob(jobId: string, error?: ErrorInfo): Promise<void>;
4518
+ retryJob(jobId: string, error?: ErrorInfo$1): Promise<void>;
3606
4519
  /**
3607
4520
  * Check if the queue is drained and call the callback if it is
3608
4521
  */
@@ -3664,7 +4577,7 @@ declare class InMemoryJobTracker implements IJobTracker {
3664
4577
  shutdown(): void;
3665
4578
  registerJob(jobInfo: JobInfo): void;
3666
4579
  markRunning(jobId: string): void;
3667
- markFailed(jobId: string, error: ErrorInfo, job?: Job): void;
4580
+ markFailed(jobId: string, error: ErrorInfo$1, job?: Job): void;
3668
4581
  getJobStatus(jobId: string): JobInfo | null;
3669
4582
  }
3670
4583
  //#endregion
@@ -3687,6 +4600,7 @@ declare class SimpleJobExecutorManager implements IJobExecutorManager {
3687
4600
  private totalJobsProcessed;
3688
4601
  private unsubscribe?;
3689
4602
  private deferredJobs;
4603
+ private resultHandler;
3690
4604
  private jobTimeoutMs;
3691
4605
  constructor(executorFactory: JobExecutorFactory, eventBus: IEventBus, queue: IQueue, jobTracker: IJobTracker, logger: ILogger, resolver: IDocumentModelResolver, jobTimeoutMs?: number);
3692
4606
  start(numExecutors: number): Promise<void>;
@@ -3696,16 +4610,7 @@ declare class SimpleJobExecutorManager implements IJobExecutorManager {
3696
4610
  private processNextJob;
3697
4611
  private checkForMoreJobs;
3698
4612
  private processExistingJobs;
3699
- private toErrorInfo;
3700
- private hasCreateDocumentAction;
3701
4613
  private flushDeferredJobs;
3702
- private formatErrorHistory;
3703
- }
3704
- //#endregion
3705
- //#region src/cache/collection-membership-cache.d.ts
3706
- interface ICollectionMembershipCache {
3707
- getCollectionsForDocuments(documentIds: string[]): Promise<Record<string, string[]>>;
3708
- invalidate(documentId: string): void;
3709
4614
  }
3710
4615
  //#endregion
3711
4616
  //#region src/cache/document-meta-cache-types.d.ts
@@ -3993,8 +4898,10 @@ declare class KyselyOperationStore implements IOperationStore {
3993
4898
  constructor(db: Kysely<Database$1>);
3994
4899
  private get queryExecutor();
3995
4900
  withTransaction(trx: Transaction<Database$1>): KyselyOperationStore;
3996
- apply(documentId: string, documentType: string, scope: string, branch: string, revision: number, fn: (txn: AtomicTxn) => void | Promise<void>, signal?: AbortSignal): Promise<void>;
4901
+ apply(documentId: string, documentType: string, scope: string, branch: string, revision: number, fn: (txn: AtomicTxn) => void | Promise<void>, signal?: AbortSignal): Promise<Operation[]>;
4902
+ private resolveUniqueConstraint;
3997
4903
  private executeApply;
4904
+ private findIdempotentReplay;
3998
4905
  getSince(documentId: string, scope: string, branch: string, revision: number, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
3999
4906
  getSinceId(id: number, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<OperationWithContext$1>>;
4000
4907
  getConflicting(documentId: string, scope: string, branch: string, minTimestamp: string, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
@@ -4067,6 +4974,17 @@ declare class SimpleJobExecutor implements IJobExecutor {
4067
4974
  private accumulateResultOrReturnError;
4068
4975
  }
4069
4976
  //#endregion
4977
+ //#region src/executor/worker/forwarding-logger.d.ts
4978
+ declare function createForwardingLogger(post: (msg: LogMessage) => void, level?: ILogger["level"], tags?: string[]): ILogger;
4979
+ //#endregion
4980
+ //#region src/executor/worker/sanitize.d.ts
4981
+ declare function errorToInfo(err: unknown): ErrorInfo;
4982
+ declare function sanitizeArg(value: unknown, depth?: number, seen?: WeakSet<object>): SanitizedArg;
4983
+ //#endregion
4984
+ //#region src/executor/worker/index.d.ts
4985
+ /** Absolute path to the worker entry script for use with `new Worker(workerEntryPath)`. */
4986
+ declare const workerEntryPath: string;
4987
+ //#endregion
4070
4988
  //#region src/registry/errors.d.ts
4071
4989
  /**
4072
4990
  * Error thrown when a document model module is not found in the registry.
@@ -4199,16 +5117,10 @@ declare class KyselyDocumentIndexer extends BaseReadModel implements IDocumentIn
4199
5117
  //#region src/read-models/coordinator.d.ts
4200
5118
  /**
4201
5119
  * Coordinates read model synchronization by listening to operation write events
4202
- * and updating all registered read models in parallel.
4203
- *
4204
- * This coordinator is responsible for:
4205
- * - Subscribing to OPERATION_WRITTEN events from the event bus
4206
- * - Distributing operation updates to all registered read models
4207
- * - Managing the lifecycle of read model subscriptions
4208
- *
4209
- * Read models are updated asynchronously and in parallel to avoid blocking
4210
- * the write path. Errors in read model updates are propagated through the
4211
- * event bus but do not affect the write operation success.
5120
+ * and updating all registered read models on per-`documentId:scope:branch`
5121
+ * serial chains. Cross-key projection runs in parallel; same-key projection is
5122
+ * serialized so the executor can return to dispatch without holding ordering
5123
+ * implicitly.
4212
5124
  */
4213
5125
  declare class ReadModelCoordinator implements IReadModelCoordinator {
4214
5126
  private eventBus;
@@ -4216,23 +5128,26 @@ declare class ReadModelCoordinator implements IReadModelCoordinator {
4216
5128
  readonly postReady: IReadModel[];
4217
5129
  private unsubscribe?;
4218
5130
  private isRunning;
5131
+ private readonly chains;
5132
+ private readonly logger;
4219
5133
  readonly readModels: IReadModel[];
4220
5134
  constructor(eventBus: IEventBus, preReady: IReadModel[], postReady: IReadModel[]);
4221
- /**
4222
- * Start listening for operation events and updating read models.
4223
- * Can be called multiple times safely (subsequent calls are no-ops).
4224
- */
4225
5135
  start(): void;
4226
- /**
4227
- * Stop listening and clean up subscriptions.
4228
- * Can be called multiple times safely (subsequent calls are no-ops).
4229
- */
4230
5136
  stop(): void;
4231
5137
  /**
4232
- * Handle write ready events by updating all read models in parallel.
4233
- * Errors from individual read models are collected and re-thrown as an aggregate.
5138
+ * Resolves when every per-queueKey projection chain has flushed. Intended
5139
+ * for test fixtures and explicit shutdown; production callers use
5140
+ * consistency tokens instead.
4234
5141
  */
5142
+ drain(): Promise<void>;
5143
+ getChainDepth(): number;
4235
5144
  private handleWriteReady;
5145
+ private emitEmptyReadReady;
5146
+ private runChain;
5147
+ private indexWithTiming;
5148
+ private emitReadModelIndexed;
5149
+ private emitBatchCompleted;
5150
+ private queueKeyFor;
4236
5151
  }
4237
5152
  //#endregion
4238
5153
  //#region src/read-models/document-view.d.ts
@@ -4663,5 +5578,5 @@ declare class ProcessorManager extends BaseReadModel implements IProcessorManage
4663
5578
  private deleteProcessorCursors;
4664
5579
  }
4665
5580
  //#endregion
4666
- export { type AtomicTxn, type AttachmentHash, type AttachmentRef, BaseReadModel, type BatchExecutionRequest, type BatchExecutionResult, type BatchLoadRequest, type BatchLoadResult, type CachedSnapshot, type ChannelConfig, ChannelError, ChannelErrorSource, type ChannelHealth, type ChannelMeta, ChannelScheme, type ConnectionState, type ConnectionStateChangeCallback, type ConnectionStateChangedEvent, type ConnectionStateSnapshot, type ConsistencyCoordinate, type ConsistencyKey, type ConsistencyToken, ConsistencyTracker, DEFAULT_DRIVE_CONTAINER_TYPES, type Database, type DeadLetterAddedEvent, DefaultSubscriptionErrorHandler, type DocumentChangeEvent, DocumentChangeType, type DocumentGraphEdge, type DocumentIndexerDatabase, DocumentIntegrityService, DocumentModelRegistry, DocumentModelResolver, type DocumentRelationship, type DocumentRevisions, type DocumentStreamKey, type DocumentViewDatabase, DriveClient, DuplicateManifestError, DuplicateModuleError, DuplicateOperationError, EventBus, EventBusAggregateError, type ExecutionJobPlan, type ExecutorStartedEvent, type ExecutorStoppedEvent, type GqlChannelConfig, GqlRequestChannel, GqlRequestChannelFactory, GqlResponseChannel, GqlResponseChannelFactory, type IChannel, type IChannelFactory, type IConsistencyTracker, type IDocumentGraph, type IDocumentIndexer, type IDocumentIntegrityService, type IDocumentModelLoader, type IDocumentModelRegistry, type IDocumentModelResolver, type IDocumentView, type IDriveClient, type IEventBus, type IJobAwaiter, type IJobExecutor, type IJobExecutorManager, type IJobTracker, type IKeyframeStore, type IOperationIndex, type IOperationStore, type IPollTimer, type IProcessor, type IProcessorHostModule, type IProcessorManager, type IQueue, type IReactor, type IReactorClient, type IReactorSubscriptionManager, type IReadModel, type IReadModelCoordinator, type IRelationalDb, type ISubscriptionErrorHandler, type ISyncCursorStorage, type ISyncManager, type ISyncRemoteStorage, type ISyncStatusTracker, type IWriteCache, SimpleJobExecutor as InMemoryJobExecutor, SimpleJobExecutor, InMemoryJobTracker, InMemoryQueue, type InsertableDocumentSnapshot, IntervalPollTimer, InvalidModuleError, type Job, type JobAvailableEvent, JobAwaiter, type JobCompletedEvent, type JobExecutorConfig, JobExecutorEventTypes, type JobExecutorFactory, type JobFailedEvent, type JobInfo, type JobPendingEvent, type JobReadReadyEvent, type JobResult, type JobRunningEvent, type JobStartedEvent, JobStatus, type JobWriteReadyEvent, type JwtHandler, type KeyframeSnapshot, type KeyframeValidationIssue, KyselyDocumentIndexer, KyselyDocumentView, KyselyKeyframeStore, KyselyOperationStore, KyselySyncCursorStorage, KyselySyncRemoteStorage, KyselyWriteCache, type LoadJobPlan, Mailbox, ModuleNotFoundError, NullDocumentModelResolver, type OperationBatch, type OperationContext, type OperationFilter, type OperationIndexEntry, type OperationTable, type OperationWithContext, OptimisticLockError, type PagedResults, type PagingOptions, type ParsedDriveUrl, type ParsedPaging, PollBehavior, PollingChannelError, type ProcessorApp, type ProcessorFactory, type ProcessorFactoryBuilder, type ProcessorFilter, ProcessorManager, type ProcessorRecord, type ProcessorStatus, PropagationMode, QueueEventTypes, REACTOR_SCHEMA, Reactor, ReactorBuilder, ReactorClient, ReactorClientBuilder, type ReactorClientModule, ReactorEventTypes, type ReactorFeatures, type JobFailedEvent$1 as ReactorJobFailedEvent, type ReactorModule, ReactorSubscriptionManager, ReadModelCoordinator, type ReadModelFactory, type ReadModelFactoryDeps, type RebuildResult, RelationalDbProcessor, RelationshipChangeType, type Remote, type RemoteCursor, type RemoteFilter, type RemoteOptions, type RemoteRecord, type RemoteStatus, RevisionMismatchError, type SearchFilter, type ShutdownStatus, type SignatureVerificationHandler, type SignerConfig, SimpleJobExecutorManager, type SnapshotValidationIssue, type Database$1 as StorageDatabase, type SubscriptionErrorContext, SyncBuilder, type SyncEnvelope, type SyncEnvelopeType, SyncEventTypes, type SyncFailedEvent, type SyncModule, SyncOperation, SyncOperationAggregateError, type SyncOperationErrorType, SyncOperationStatus, type SyncPendingEvent, SyncStatus, type SyncStatusChangeCallback, SyncStatusTracker, type SyncSucceededEvent, type TrackedProcessor, type Unsubscribe, type ValidationResult, type ViewFilter, type WriteCacheConfig, addRelationshipAction, batchOperationsByDocument, consolidateSyncOperations, createDocumentAction, createMutableShutdownStatus, createRelationalDb, deleteDocumentAction, documentActions, driveCollectionId, driveIdFromUrl, envelopesToSyncOperations, getMigrationStatus, makeConsistencyKey, parseDriveUrl, parsePagingOptions, removeRelationshipAction, runMigrations, trimMailboxFromAckOrdinal, updateRelationshipAction, upgradeDocumentAction };
5581
+ export { type AbortMessage, type AtomicTxn, type AttachmentHash, type AttachmentRef, BaseReadModel, type BatchExecutionRequest, type BatchExecutionResult, type BatchLoadRequest, type BatchLoadResult, type BuiltInReadModelKind, type CachedSnapshot, type ChannelConfig, ChannelError, ChannelErrorSource, type ChannelHealth, type ChannelMeta, ChannelScheme, type ConnectionState, type ConnectionStateChangeCallback, type ConnectionStateChangedEvent, type ConnectionStateSnapshot, type ConsistencyCoordinate, type ConsistencyKey, type ConsistencyToken, ConsistencyTracker, DEFAULT_DRIVE_CONTAINER_TYPES, type Database, type DbConfig, type DeadLetterAddedEvent, DefaultSubscriptionErrorHandler, type DocumentChangeEvent, DocumentChangeType, type DocumentGraphEdge, type DocumentIndexerDatabase, DocumentIntegrityService, DocumentModelRegistry, DocumentModelResolver, type DocumentModelSpec, type DocumentModelSpecInput, type DocumentRelationship, type DocumentRevisions, type DocumentStreamKey, type DocumentViewDatabase, DriveClient, DuplicateManifestError, DuplicateModuleError, DuplicateOperationError, EventBus, EventBusAggregateError, type ExecuteMessage, type ExecutionJobPlan, type ExecutorStartedEvent, type ExecutorStoppedEvent, type FactorySpec, type GqlChannelConfig, GqlRequestChannel, GqlRequestChannelFactory, GqlResponseChannel, GqlResponseChannelFactory, type HeartbeatMessage, type IChannel, type IChannelFactory, type IConsistencyTracker, type IDocumentGraph, type IDocumentIndexer, type IDocumentIntegrityService, type IDocumentModelLoader, type IDocumentModelRegistry, type IDocumentModelResolver, type IDocumentView, type IDriveClient, type IEventBus, type IJobAwaiter, type IJobExecutor, type IJobExecutorManager, type IJobTracker, type IKeyframeStore, type IOperationIndex, type IOperationStore, type IPollTimer, type IProcessor, type IProcessorHostModule, type IProcessorManager, type IProjectionTransport, type IQueue, type IReactor, type IReactorClient, type IReactorSubscriptionManager, type IReadModel, type IReadModelCoordinator, type IRelationalDb, type ISubscriptionErrorHandler, type ISyncCursorStorage, type ISyncManager, type ISyncRemoteStorage, type ISyncStatusTracker, type IWriteCache, SimpleJobExecutor as InMemoryJobExecutor, SimpleJobExecutor, InMemoryJobTracker, InMemoryQueue, type InitMessage, type InsertableDocumentSnapshot, IntervalPollTimer, InvalidModuleError, type Job, type JobAvailableEvent, JobAwaiter, type JobCompletedEvent, type JobExecutorConfig, JobExecutorEventTypes, type JobExecutorFactory, type JobFailedEvent, type JobInfo, type JobPendingEvent, type JobReadReadyEvent, type JobResult, type JobRunningEvent, type JobStartedEvent, JobStatus, type JobWriteReadyEvent, type JobWriteReadyPayload, type JwtHandler, type KeyframeSnapshot, type KeyframeValidationIssue, KyselyDocumentIndexer, KyselyDocumentView, KyselyKeyframeStore, KyselyOperationStore, KyselySyncCursorStorage, KyselySyncRemoteStorage, KyselyWriteCache, type LoadJobPlan, type LoadModelMessage, type LogMessage, Mailbox, type MetricsMessage, type ModelLoadFailedMessage, type ModelLoadedMessage, type ModelManifestEntry, ModuleNotFoundError, type ModuleRef, NullDocumentModelResolver, type OperationBatch, type OperationContext, type OperationFilter, type OperationIndexEntry, type OperationTable, type OperationWithContext, OptimisticLockError, type PagedResults, type PagingOptions, type ParentMessage, type ParsedDriveUrl, type ParsedPaging, PollBehavior, PollingChannelError, type PoolInstrumentation, type PoolStats, type ProcessorApp, type ProcessorFactory, type ProcessorFactoryBuilder, type ProcessorFilter, ProcessorManager, type ProcessorRecord, type ProcessorStatus, type ProjectionShardBuilderConfig, type ProjectionShardManagerConfig, type ProjectionWorkerFactory, PropagationMode, QueueEventTypes, REACTOR_SCHEMA, Reactor, ReactorBuilder, ReactorClient, ReactorClientBuilder, type ReactorClientModule, ReactorEventTypes, type ReactorFeatures, type JobFailedEvent$1 as ReactorJobFailedEvent, type ReactorModule, ReactorSubscriptionManager, type ReadModelBatchCompletedEvent, ReadModelCoordinator, type ReadModelFactory, type ReadModelFactoryDeps, type ReadModelIndexedEvent, type ReadModelIndexingStage, type ReadModelStage, type ReadyMessage, type RebuildResult, RelationalDbProcessor, RelationshipChangeType, type Remote, type RemoteCursor, type RemoteFilter, type RemoteOptions, type RemoteRecord, type RemoteStatus, type ResultMessage, RevisionMismatchError, type SanitizedArg, type SearchFilter, type ShutdownMessage, type ShutdownStatus, type SignatureVerificationHandler, type SignatureVerifierSpec, type SignerConfig, SimpleJobExecutorManager, type SnapshotValidationIssue, type Database$1 as StorageDatabase, type SubscriptionErrorContext, SyncBuilder, type SyncEnvelope, type SyncEnvelopeType, SyncEventTypes, type SyncFailedEvent, type SyncModule, SyncOperation, SyncOperationAggregateError, type SyncOperationErrorType, SyncOperationStatus, type SyncPendingEvent, SyncStatus, type SyncStatusChangeCallback, SyncStatusTracker, type SyncSucceededEvent, type TrackedProcessor, type Unsubscribe, type ValidationResult, type ViewFilter, type ErrorInfo as WorkerErrorInfo, type WorkerMessage, type WorkerPoolConfig, type WriteCacheConfig, addRelationshipAction, batchOperationsByDocument, consolidateSyncOperations, createDocumentAction, createForwardingLogger, createMutableShutdownStatus, createRelationalDb, deleteDocumentAction, documentActions, driveCollectionId, driveIdFromUrl, envelopesToSyncOperations, errorToInfo, getMigrationStatus, instrumentPgPool, makeConsistencyKey, parseDriveUrl, parsePagingOptions, removeRelationshipAction, runMigrations, sanitizeArg, trimMailboxFromAckOrdinal, updateRelationshipAction, upgradeDocumentAction, workerEntryPath };
4667
5582
  //# sourceMappingURL=index.d.ts.map