@powerhousedao/reactor 6.1.0-dev.1 → 6.1.0-dev.11

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 +991 -75
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +900 -3889
  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.
@@ -3156,9 +3721,67 @@ declare class DriveClient implements IDriveClient {
3156
3721
  copyNode(driveIdentifier: string, srcNodeId: string, targetParentFolderId: string | undefined, signal?: AbortSignal): Promise<DocumentDriveDocument>;
3157
3722
  getNode(driveIdentifier: string, nodeId: string, signal?: AbortSignal): Promise<Node>;
3158
3723
  listNodes(driveIdentifier: string, parentFolder?: string | null, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Node>>;
3724
+ private documentExists;
3159
3725
  private removeFileNode;
3160
3726
  }
3161
3727
  //#endregion
3728
+ //#region src/cache/collection-membership-cache.d.ts
3729
+ interface ICollectionMembershipCache {
3730
+ getCollectionsForDocuments(documentIds: string[]): Promise<Record<string, string[]>>;
3731
+ invalidate(documentId: string): void;
3732
+ }
3733
+ //#endregion
3734
+ //#region src/registry/document-model-resolver.d.ts
3735
+ interface IDocumentModelResolver {
3736
+ ensureModelLoaded(documentType: string): Promise<void>;
3737
+ }
3738
+ /**
3739
+ * Post-success hook called after the resolver registers a newly loaded
3740
+ * model on the parent's registry. Used to broadcast `load-model` to the
3741
+ * worker pool so workers can register the same model locally.
3742
+ */
3743
+ type ModelLoadedBroadcastHook = (entry: ModelManifestEntry) => Promise<void>;
3744
+ /**
3745
+ * Encapsulates the logic for resolving document model modules on demand.
3746
+ * Shared between the queue (CREATE_DOCUMENT gate) and the executor manager
3747
+ * (post-failure recovery) so that both paths use the same deduplication
3748
+ * and failure-caching state.
3749
+ */
3750
+ declare class DocumentModelResolver implements IDocumentModelResolver {
3751
+ private registry;
3752
+ private loader;
3753
+ private loadingModels;
3754
+ private failedModelTypes;
3755
+ private broadcastHook;
3756
+ constructor(registry: IDocumentModelRegistry, loader: IDocumentModelLoader);
3757
+ /**
3758
+ * Install a post-success hook called after the resolver registers a
3759
+ * newly loaded model. ReactorBuilder uses this to wire the worker-pool
3760
+ * `load-model` broadcast without touching the resolver's constructor.
3761
+ */
3762
+ setBroadcastHook(hook: ModelLoadedBroadcastHook): void;
3763
+ ensureModelLoaded(documentType: string): Promise<void>;
3764
+ private broadcastIfPossible;
3765
+ }
3766
+ /**
3767
+ * No-op resolver used when no document model loader is configured.
3768
+ * Checks the registry for the model and returns if found; throws if not.
3769
+ * Since there is no loader, missing models cannot be recovered.
3770
+ */
3771
+ declare class NullDocumentModelResolver implements IDocumentModelResolver {
3772
+ private registry?;
3773
+ constructor(registry?: IDocumentModelRegistry | undefined);
3774
+ ensureModelLoaded(documentType: string): Promise<void>;
3775
+ }
3776
+ //#endregion
3777
+ //#region src/executor/worker-pool-job-executor-manager.d.ts
3778
+ /**
3779
+ * Factory invoked once per worker at `start()` time. The index is the
3780
+ * worker's position in the pool and the same value the manager will use
3781
+ * for sticky routing (`bucketFor(documentId) === index`).
3782
+ */
3783
+ type WorkerFactory = (index: number) => IExecutorWorker;
3784
+ //#endregion
3162
3785
  //#region src/cache/write-cache-types.d.ts
3163
3786
  /**
3164
3787
  * Configuration options for the write cache
@@ -3191,6 +3814,207 @@ type KeyframeSnapshot = {
3191
3814
  document: string;
3192
3815
  };
3193
3816
  //#endregion
3817
+ //#region src/projection/protocol.d.ts
3818
+ /**
3819
+ * Identifier for a built-in read model the projection worker materializes
3820
+ * on init. The host names which models each shard should run; the worker
3821
+ * constructs them itself against its local Kysely instance.
3822
+ */
3823
+ type BuiltInReadModelKind = "document-view" | "document-indexer";
3824
+ /**
3825
+ * Initializes a freshly spawned projection worker. The worker uses
3826
+ * `db` to open its own pg.Pool + Kysely, loads `models` into a local
3827
+ * `DocumentModelRegistry`, materializes each `readModelKinds` entry as a
3828
+ * concrete read model bound to the local DB, and starts a local
3829
+ * `ReadModelCoordinator` that consumes the JOB_WRITE_READY relays.
3830
+ */
3831
+ type ProjectionInitMessage = {
3832
+ type: "init";
3833
+ correlationId: string;
3834
+ shardId: string;
3835
+ shardIndex: number;
3836
+ shardCount: number;
3837
+ db: DbConfig;
3838
+ models: ModelManifestEntry[];
3839
+ preReadyKinds: BuiltInReadModelKind[];
3840
+ postReadyKinds: BuiltInReadModelKind[];
3841
+ chainDepthReportIntervalMs: number;
3842
+ };
3843
+ /**
3844
+ * Relays a JOB_WRITE_READY event from the host bus into the worker's
3845
+ * local bus, where the in-worker `ReadModelCoordinator` picks it up.
3846
+ *
3847
+ * The host fans messages to shards via `bucketFor(documentId, shardCount)`
3848
+ * — the worker does not re-hash and assumes the message landed on it
3849
+ * because the host already chose this shard.
3850
+ */
3851
+ type ProjectionWriteReadyMessage = {
3852
+ type: "write-ready";
3853
+ jobId: string;
3854
+ operations: OperationWithContext$1[];
3855
+ jobMeta: JobMeta;
3856
+ collectionMemberships?: Record<string, string[]>;
3857
+ };
3858
+ /**
3859
+ * Asks the worker to drain its in-flight chains and respond with
3860
+ * {@link ProjectionDrainedMessage}.
3861
+ */
3862
+ type ProjectionDrainMessage = {
3863
+ type: "drain";
3864
+ correlationId: string;
3865
+ };
3866
+ /**
3867
+ * Asks the worker to drain in-flight work, close its DB pool, and exit.
3868
+ */
3869
+ type ProjectionShutdownMessage = {
3870
+ type: "shutdown";
3871
+ correlationId: string;
3872
+ graceMs?: number;
3873
+ };
3874
+ type ProjectionParentMessage = ProjectionInitMessage | ProjectionWriteReadyMessage | ProjectionDrainMessage | ProjectionShutdownMessage;
3875
+ /**
3876
+ * Announces that the worker has finished `init` and is ready to accept
3877
+ * `write-ready` relays.
3878
+ */
3879
+ type ProjectionReadyMessage = {
3880
+ type: "ready";
3881
+ correlationId: string;
3882
+ shardId: string;
3883
+ };
3884
+ /**
3885
+ * Forwarded JOB_READ_READY event from the worker's local bus. The host
3886
+ * re-emits this on the host bus so observers (sync manager, awaiters,
3887
+ * tests) see it exactly once per job.
3888
+ */
3889
+ type ProjectionReadReadyMessage = {
3890
+ type: "read-ready";
3891
+ shardId: string;
3892
+ jobId: string;
3893
+ operations: OperationWithContext$1[];
3894
+ };
3895
+ /**
3896
+ * Forwarded READMODEL_INDEXED event from the worker's local bus.
3897
+ */
3898
+ type ProjectionReadModelIndexedMessage = {
3899
+ type: "readmodel-indexed";
3900
+ shardId: string;
3901
+ jobId: string;
3902
+ readModelName: string;
3903
+ stage: ReadModelIndexingStage;
3904
+ durationMs: number;
3905
+ operationCount: number;
3906
+ success: boolean;
3907
+ };
3908
+ /**
3909
+ * Forwarded READMODEL_BATCH_COMPLETED event from the worker's local bus.
3910
+ */
3911
+ type ProjectionBatchCompletedMessage = {
3912
+ type: "readmodel-batch-completed";
3913
+ shardId: string;
3914
+ jobId: string;
3915
+ batchSize: number;
3916
+ chainWaitDurationMs: number;
3917
+ preReadyDurationMs: number;
3918
+ emitDurationMs: number;
3919
+ postReadyDurationMs: number;
3920
+ };
3921
+ /**
3922
+ * Periodic chain-depth report. Workers post this on a fixed cadence so
3923
+ * the host can aggregate per-shard depths without polling.
3924
+ */
3925
+ type ProjectionChainDepthMessage = {
3926
+ type: "chain-depth";
3927
+ shardId: string;
3928
+ depth: number;
3929
+ timestamp: number;
3930
+ };
3931
+ /**
3932
+ * Snapshot of one shard's pg.Pool acquire-wait samples and pool-stat
3933
+ * counters. The shard owns its real pg.Pool; the host's
3934
+ * {@link PoolInstrumentation} is a forwarder driven by these messages.
3935
+ */
3936
+ type ProjectionPoolAcquireSamplesMessage = {
3937
+ type: "pool-acquire-samples";
3938
+ shardId: string; /** Stable identifier matching the host-side instrumentation name. */
3939
+ poolName: string; /** Epoch milliseconds the worker generated the batch. */
3940
+ timestamp: number; /** Acquire-wait durations (ms) accumulated since the previous batch. */
3941
+ durations: number[]; /** Most recent pg.Pool counter snapshot at batch send time. */
3942
+ size: number;
3943
+ idle: number;
3944
+ waiting: number;
3945
+ };
3946
+ /**
3947
+ * Acknowledges that a `drain` request has flushed all in-flight chains.
3948
+ */
3949
+ type ProjectionDrainedMessage = {
3950
+ type: "drained";
3951
+ correlationId: string;
3952
+ shardId: string;
3953
+ };
3954
+ /**
3955
+ * Forwarded log line from the worker. Mirrors the executor worker's
3956
+ * sanitized log envelope so callers can route both through the same
3957
+ * host-side logger.
3958
+ */
3959
+ type ProjectionLogMessage = {
3960
+ type: "log";
3961
+ shardId: string;
3962
+ level: "debug" | "info" | "warn" | "error";
3963
+ message: string;
3964
+ args: SanitizedArg[];
3965
+ timestamp: number;
3966
+ };
3967
+ type ProjectionWorkerMessage = ProjectionReadyMessage | ProjectionReadReadyMessage | ProjectionReadModelIndexedMessage | ProjectionBatchCompletedMessage | ProjectionChainDepthMessage | ProjectionPoolAcquireSamplesMessage | ProjectionDrainedMessage | ProjectionLogMessage;
3968
+ //#endregion
3969
+ //#region src/projection/transport.d.ts
3970
+ type ProjectionTransportEventMap = {
3971
+ message: ProjectionWorkerMessage;
3972
+ error: Error;
3973
+ exit: number;
3974
+ };
3975
+ type ProjectionTransportEvent = keyof ProjectionTransportEventMap;
3976
+ type ProjectionTransportListener<E extends ProjectionTransportEvent> = (payload: ProjectionTransportEventMap[E]) => void;
3977
+ /**
3978
+ * Minimal subset of `worker_threads.Worker` the {@link ProjectionShardManager}
3979
+ * relies on. The host writes against this interface so tests can swap in
3980
+ * a fake transport without spawning real worker threads.
3981
+ */
3982
+ interface IProjectionTransport {
3983
+ postMessage(message: ProjectionParentMessage): void;
3984
+ on<E extends ProjectionTransportEvent>(event: E, listener: ProjectionTransportListener<E>): void;
3985
+ off<E extends ProjectionTransportEvent>(event: E, listener: ProjectionTransportListener<E>): void;
3986
+ terminate(): Promise<number>;
3987
+ }
3988
+ //#endregion
3989
+ //#region src/projection/projection-shard-manager.d.ts
3990
+ /**
3991
+ * Factory that builds one projection-worker transport. Mirrors
3992
+ * `WorkerFactory` from the executor pool: lets tests inject fake
3993
+ * transports without spawning real worker threads.
3994
+ */
3995
+ type ProjectionWorkerFactory = (shardIndex: number, shardId: string) => IProjectionTransport;
3996
+ type ProjectionShardManagerConfig = {
3997
+ shardCount: number;
3998
+ db: DbConfig;
3999
+ models: ModelManifestEntry[];
4000
+ preReadyKinds: BuiltInReadModelKind[];
4001
+ postReadyKinds: BuiltInReadModelKind[];
4002
+ factory: ProjectionWorkerFactory;
4003
+ logger: ILogger;
4004
+ hostBus: IEventBus;
4005
+ initTimeoutMs?: number;
4006
+ shutdownGraceMs?: number;
4007
+ drainTimeoutMs?: number;
4008
+ chainDepthReportIntervalMs?: number;
4009
+ /**
4010
+ * Host-side forwarding instrumentations indexed by shard index. The
4011
+ * manager routes each shard's `pool-acquire-samples` message to the
4012
+ * matching forwarder so the host's OpenTelemetry instrumentation records
4013
+ * acquire-wait latencies as if each shard's pg.Pool were local.
4014
+ */
4015
+ poolInstrumentations?: ForwardingPoolInstrumentation[];
4016
+ };
4017
+ //#endregion
3194
4018
  //#region src/signer/types.d.ts
3195
4019
  /**
3196
4020
  * Configuration for signing and verification.
@@ -3249,6 +4073,36 @@ interface ReadModelFactoryDeps {
3249
4073
  * dependencies once they are available. Awaited during `buildModule()`.
3250
4074
  */
3251
4075
  type ReadModelFactory = (deps: ReadModelFactoryDeps) => IReadModel | Promise<IReadModel>;
4076
+ /**
4077
+ * Describes a document-model package the worker should import at runtime.
4078
+ * Either a bare-specifier package or an absolute file path.
4079
+ */
4080
+ type DocumentModelSpecInput = {
4081
+ packageName: string;
4082
+ version: string;
4083
+ } | {
4084
+ filePath: string;
4085
+ };
4086
+ /**
4087
+ * Caller-facing config for {@link ReactorBuilder.withProjectionShards}.
4088
+ * When set, the builder replaces the in-process
4089
+ * {@link ReadModelCoordinator} with a {@link ProjectionShardManager} that
4090
+ * fans JOB_WRITE_READY events to N projection workers sharded by
4091
+ * documentId.
4092
+ *
4093
+ * @see Sharded projection workers sub-feature brief
4094
+ * (Powerhouse board wiki id: eb26f01f-8f68-4918-a6f6-ac7a4679b533)
4095
+ */
4096
+ type ProjectionShardBuilderConfig = {
4097
+ shardCount: number;
4098
+ preReadyKinds: BuiltInReadModelKind[];
4099
+ postReadyKinds: BuiltInReadModelKind[];
4100
+ poolSize?: number;
4101
+ initTimeoutMs?: number;
4102
+ shutdownGraceMs?: number;
4103
+ drainTimeoutMs?: number;
4104
+ chainDepthReportIntervalMs?: number;
4105
+ };
3252
4106
  declare class ReactorBuilder {
3253
4107
  private logger?;
3254
4108
  private documentModels;
@@ -3272,6 +4126,15 @@ declare class ReactorBuilder {
3272
4126
  private documentModelLoader?;
3273
4127
  private shutdownHooks;
3274
4128
  private driveContainerTypes;
4129
+ private documentModelSpecs;
4130
+ private workerPoolConfig?;
4131
+ private resolvedModelManifest?;
4132
+ private workerDbConfig?;
4133
+ private workerSignatureVerifierSpec?;
4134
+ private workerFactory?;
4135
+ private projectionShardConfig?;
4136
+ private projectionWorkerFactory?;
4137
+ private instrumentedPools;
3275
4138
  withLogger(logger: ILogger): this;
3276
4139
  withDocumentModels(models: DocumentModelModule<any>[]): this;
3277
4140
  withUpgradeManifests(manifests: UpgradeManifest<readonly number[]>[]): this;
@@ -3295,6 +4158,14 @@ declare class ReactorBuilder {
3295
4158
  withEventBus(eventBus: IEventBus): this;
3296
4159
  withSignatureVerifier(verifier: SignatureVerificationHandler): this;
3297
4160
  withKysely(kysely: Kysely<Database>): this;
4161
+ /**
4162
+ * Register an externally-constructed pg.Pool's {@link PoolInstrumentation}
4163
+ * so it surfaces through {@link ReactorModule.pools}. Use this when the
4164
+ * caller built the pool itself (e.g. the in-process bench host wiring) so
4165
+ * pool acquire-wait and pool-stat metrics still emit. The builder also
4166
+ * registers any pool it constructs internally via {@link createPostgresDatabase}.
4167
+ */
4168
+ withInstrumentedPool(instrumentation: PoolInstrumentation): this;
3298
4169
  withQueue(queue: IQueue): this;
3299
4170
  withChannelScheme(scheme: ChannelScheme): this;
3300
4171
  withJwtHandler(handler: JwtHandler): this;
@@ -3309,8 +4180,79 @@ declare class ReactorBuilder {
3309
4180
  * shutdown chain.
3310
4181
  */
3311
4182
  withShutdownHook(hook: () => Promise<void>): this;
4183
+ withDocumentModelSpecs(specs: DocumentModelSpecInput[]): this;
4184
+ /**
4185
+ * Stores the worker-pool configuration. When `config.enabled === true` the
4186
+ * builder constructs a {@link WorkerPoolJobExecutorManager} in place of the
4187
+ * in-process {@link SimpleJobExecutorManager}.
4188
+ */
4189
+ withWorkerPool(config: WorkerPoolConfig): this;
4190
+ /**
4191
+ * Postgres connection info forwarded to each worker so it can open its own
4192
+ * pool. Required when `workerPool.enabled === true` unless a custom
4193
+ * `withWorkerFactory` or `withExecutor` is provided.
4194
+ */
4195
+ withWorkerDbConfig(db: DbConfig): this;
4196
+ /**
4197
+ * Factory spec the worker imports to instantiate its signature verifier.
4198
+ * Required when `workerPool.enabled === true` unless a custom
4199
+ * `withWorkerFactory` or `withExecutor` is provided.
4200
+ */
4201
+ withWorkerSignatureVerifierSpec(spec: SignatureVerifierSpec): this;
4202
+ /**
4203
+ * Inject a custom {@link WorkerFactory}. When set, the builder skips
4204
+ * default thread-transport wiring and hands the factory directly to the
4205
+ * pool manager. Use this in tests or to plug in a different transport
4206
+ * (e.g. a child-process adapter).
4207
+ */
4208
+ withWorkerFactory(factory: WorkerFactory): this;
4209
+ /**
4210
+ * Configure N sharded projection workers. When set, the builder replaces
4211
+ * the default in-process {@link ReadModelCoordinator} with a
4212
+ * {@link ProjectionShardManager}. The same `DbConfig` registered via
4213
+ * {@link withWorkerDbConfig} is reused for the projection workers'
4214
+ * connection info; only the `poolSize` is overridden by
4215
+ * {@link ProjectionShardBuilderConfig.poolSize}.
4216
+ *
4217
+ * Requires {@link withWorkerDbConfig} (the projection workers need
4218
+ * connection info to open their own pools). The same model manifest
4219
+ * resolved from {@link withDocumentModelSpecs} is forwarded.
4220
+ */
4221
+ withProjectionShards(config: ProjectionShardBuilderConfig): this;
4222
+ /**
4223
+ * Inject a custom {@link ProjectionWorkerFactory}. When set, the builder
4224
+ * skips default thread-transport wiring for the projection shards and
4225
+ * hands the factory directly to {@link ProjectionShardManager}.
4226
+ */
4227
+ withProjectionWorkerFactory(factory: ProjectionWorkerFactory): this;
4228
+ getResolvedModelManifest(): ModelManifestEntry[] | undefined;
3312
4229
  build(): Promise<IReactor>;
3313
4230
  buildModule(): Promise<ReactorModule>;
4231
+ /**
4232
+ * Constructs a {@link ProjectionShardManager} bound to the host event
4233
+ * bus. Builds the default thread-transport factory unless one was
4234
+ * injected via {@link withProjectionWorkerFactory}. Calls
4235
+ * `manager.startup()` so all N workers reach READY before the reactor
4236
+ * is returned to the caller.
4237
+ */
4238
+ private createProjectionShardManager;
4239
+ private createDefaultProjectionWorkerFactory;
4240
+ /**
4241
+ * Default {@link WorkerFactory} used when `workerPool.enabled` is set and
4242
+ * the caller did not inject `withWorkerFactory`. Each worker spawns a real
4243
+ * `node:worker_threads` Worker pointing at the compiled `worker/entry.js`.
4244
+ */
4245
+ private createDefaultWorkerFactory;
4246
+ /**
4247
+ * Builds the parent Kysely instance against a real Postgres server using
4248
+ * the same {@link DbConfig} the workers receive at init. Used in the
4249
+ * worker-pool path so the parent reactor and each worker thread share
4250
+ * storage; PGlite cannot be shared across threads. The constructed pool
4251
+ * is wrapped with {@link instrumentPgPool} and the resulting
4252
+ * {@link PoolInstrumentation} is pushed onto {@link instrumentedPools} so
4253
+ * the reactor module exposes acquire-wait and pool-stat surfaces.
4254
+ */
4255
+ private createPostgresDatabase;
3314
4256
  private attachSignalHandlers;
3315
4257
  }
3316
4258
  //#endregion
@@ -3505,35 +4447,6 @@ declare class EventBus implements IEventBus {
3505
4447
  emit(type: number, data: any): Promise<void>;
3506
4448
  }
3507
4449
  //#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
4450
  //#region src/queue/queue.d.ts
3538
4451
  /**
3539
4452
  * In-memory implementation of the IQueue interface.
@@ -3593,6 +4506,7 @@ declare class InMemoryQueue implements IQueue {
3593
4506
  enqueue(job: Job): Promise<void>;
3594
4507
  dequeue(documentId: string, scope: string, branch: string, signal?: AbortSignal): Promise<IJobExecutionHandle | null>;
3595
4508
  dequeueNext(signal?: AbortSignal): Promise<IJobExecutionHandle | null>;
4509
+ dequeueNextMatching(predicate: (meta: JobRoutingMeta) => boolean, signal?: AbortSignal): Promise<IJobExecutionHandle | null>;
3596
4510
  size(documentId: string, scope: string, branch: string): Promise<number>;
3597
4511
  totalSize(): Promise<number>;
3598
4512
  remove(jobId: string): Promise<boolean>;
@@ -3600,9 +4514,9 @@ declare class InMemoryQueue implements IQueue {
3600
4514
  clearAll(): Promise<void>;
3601
4515
  hasJobs(): Promise<boolean>;
3602
4516
  completeJob(jobId: string): Promise<void>;
3603
- failJob(jobId: string, error?: ErrorInfo): Promise<void>;
4517
+ failJob(jobId: string, error?: ErrorInfo$1): Promise<void>;
3604
4518
  deferJob(jobId: string): void;
3605
- retryJob(jobId: string, error?: ErrorInfo): Promise<void>;
4519
+ retryJob(jobId: string, error?: ErrorInfo$1): Promise<void>;
3606
4520
  /**
3607
4521
  * Check if the queue is drained and call the callback if it is
3608
4522
  */
@@ -3664,7 +4578,7 @@ declare class InMemoryJobTracker implements IJobTracker {
3664
4578
  shutdown(): void;
3665
4579
  registerJob(jobInfo: JobInfo): void;
3666
4580
  markRunning(jobId: string): void;
3667
- markFailed(jobId: string, error: ErrorInfo, job?: Job): void;
4581
+ markFailed(jobId: string, error: ErrorInfo$1, job?: Job): void;
3668
4582
  getJobStatus(jobId: string): JobInfo | null;
3669
4583
  }
3670
4584
  //#endregion
@@ -3687,6 +4601,7 @@ declare class SimpleJobExecutorManager implements IJobExecutorManager {
3687
4601
  private totalJobsProcessed;
3688
4602
  private unsubscribe?;
3689
4603
  private deferredJobs;
4604
+ private resultHandler;
3690
4605
  private jobTimeoutMs;
3691
4606
  constructor(executorFactory: JobExecutorFactory, eventBus: IEventBus, queue: IQueue, jobTracker: IJobTracker, logger: ILogger, resolver: IDocumentModelResolver, jobTimeoutMs?: number);
3692
4607
  start(numExecutors: number): Promise<void>;
@@ -3696,16 +4611,7 @@ declare class SimpleJobExecutorManager implements IJobExecutorManager {
3696
4611
  private processNextJob;
3697
4612
  private checkForMoreJobs;
3698
4613
  private processExistingJobs;
3699
- private toErrorInfo;
3700
- private hasCreateDocumentAction;
3701
4614
  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
4615
  }
3710
4616
  //#endregion
3711
4617
  //#region src/cache/document-meta-cache-types.d.ts
@@ -3993,8 +4899,10 @@ declare class KyselyOperationStore implements IOperationStore {
3993
4899
  constructor(db: Kysely<Database$1>);
3994
4900
  private get queryExecutor();
3995
4901
  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>;
4902
+ apply(documentId: string, documentType: string, scope: string, branch: string, revision: number, fn: (txn: AtomicTxn) => void | Promise<void>, signal?: AbortSignal): Promise<Operation[]>;
4903
+ private resolveUniqueConstraint;
3997
4904
  private executeApply;
4905
+ private findIdempotentReplay;
3998
4906
  getSince(documentId: string, scope: string, branch: string, revision: number, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
3999
4907
  getSinceId(id: number, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<OperationWithContext$1>>;
4000
4908
  getConflicting(documentId: string, scope: string, branch: string, minTimestamp: string, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
@@ -4067,6 +4975,17 @@ declare class SimpleJobExecutor implements IJobExecutor {
4067
4975
  private accumulateResultOrReturnError;
4068
4976
  }
4069
4977
  //#endregion
4978
+ //#region src/executor/worker/forwarding-logger.d.ts
4979
+ declare function createForwardingLogger(post: (msg: LogMessage) => void, level?: ILogger["level"], tags?: string[]): ILogger;
4980
+ //#endregion
4981
+ //#region src/executor/worker/sanitize.d.ts
4982
+ declare function errorToInfo(err: unknown): ErrorInfo;
4983
+ declare function sanitizeArg(value: unknown, depth?: number, seen?: WeakSet<object>): SanitizedArg;
4984
+ //#endregion
4985
+ //#region src/executor/worker/index.d.ts
4986
+ /** Absolute path to the worker entry script for use with `new Worker(workerEntryPath)`. */
4987
+ declare const workerEntryPath: string;
4988
+ //#endregion
4070
4989
  //#region src/registry/errors.d.ts
4071
4990
  /**
4072
4991
  * Error thrown when a document model module is not found in the registry.
@@ -4199,16 +5118,10 @@ declare class KyselyDocumentIndexer extends BaseReadModel implements IDocumentIn
4199
5118
  //#region src/read-models/coordinator.d.ts
4200
5119
  /**
4201
5120
  * 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.
5121
+ * and updating all registered read models on per-`documentId:scope:branch`
5122
+ * serial chains. Cross-key projection runs in parallel; same-key projection is
5123
+ * serialized so the executor can return to dispatch without holding ordering
5124
+ * implicitly.
4212
5125
  */
4213
5126
  declare class ReadModelCoordinator implements IReadModelCoordinator {
4214
5127
  private eventBus;
@@ -4216,23 +5129,26 @@ declare class ReadModelCoordinator implements IReadModelCoordinator {
4216
5129
  readonly postReady: IReadModel[];
4217
5130
  private unsubscribe?;
4218
5131
  private isRunning;
5132
+ private readonly chains;
5133
+ private readonly logger;
4219
5134
  readonly readModels: IReadModel[];
4220
5135
  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
5136
  start(): void;
4226
- /**
4227
- * Stop listening and clean up subscriptions.
4228
- * Can be called multiple times safely (subsequent calls are no-ops).
4229
- */
4230
5137
  stop(): void;
4231
5138
  /**
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.
5139
+ * Resolves when every per-queueKey projection chain has flushed. Intended
5140
+ * for test fixtures and explicit shutdown; production callers use
5141
+ * consistency tokens instead.
4234
5142
  */
5143
+ drain(): Promise<void>;
5144
+ getChainDepth(): number;
4235
5145
  private handleWriteReady;
5146
+ private emitEmptyReadReady;
5147
+ private runChain;
5148
+ private indexWithTiming;
5149
+ private emitReadModelIndexed;
5150
+ private emitBatchCompleted;
5151
+ private queueKeyFor;
4236
5152
  }
4237
5153
  //#endregion
4238
5154
  //#region src/read-models/document-view.d.ts
@@ -4663,5 +5579,5 @@ declare class ProcessorManager extends BaseReadModel implements IProcessorManage
4663
5579
  private deleteProcessorCursors;
4664
5580
  }
4665
5581
  //#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 };
5582
+ 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
5583
  //# sourceMappingURL=index.d.ts.map