@powerhousedao/reactor 6.2.3-dev.24 → 6.2.3-dev.26

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 (39) hide show
  1. package/dist/{build-worker-executor-DxmDJ4QQ.js → build-worker-executor-Bvoba-AV.js} +4 -4
  2. package/dist/{build-worker-executor-DxmDJ4QQ.js.map → build-worker-executor-Bvoba-AV.js.map} +1 -1
  3. package/dist/{document-indexer-Dn9RB0sg.js → document-indexer-BVTGbEB0.js} +22 -21
  4. package/dist/document-indexer-BVTGbEB0.js.map +1 -0
  5. package/dist/entry.d.ts +2 -1
  6. package/dist/entry.js +2 -3
  7. package/dist/entry.js.map +1 -1
  8. package/dist/{errors-D3S6Eysd.js → errors-BM_ULVWd.js} +9 -1
  9. package/dist/{errors-D3S6Eysd.js.map → errors-BM_ULVWd.js.map} +1 -1
  10. package/dist/{drive-container-types-Be5-EY9W.js → forwarding-logger-CnuVDVze.js} +303 -53
  11. package/dist/forwarding-logger-CnuVDVze.js.map +1 -0
  12. package/dist/index.d.ts +474 -307
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +700 -366
  15. package/dist/index.js.map +1 -1
  16. package/dist/projection-entry.d.ts +2 -1
  17. package/dist/projection-entry.js +7 -13
  18. package/dist/projection-entry.js.map +1 -1
  19. package/dist/{projection-shard-manager-mQhfVipO.js → projection-shard-manager-BpcqDtnQ.js} +2 -3
  20. package/dist/{projection-shard-manager-mQhfVipO.js.map → projection-shard-manager-BpcqDtnQ.js.map} +1 -1
  21. package/dist/{projection-worker-wI4PwcV2.js → projection-worker-D8uNFdwX.js} +1 -1
  22. package/dist/{projection-worker-wI4PwcV2.js.map → projection-worker-D8uNFdwX.js.map} +1 -1
  23. package/dist/{transport-CuogVKN_.js → transport-B3G50KVd.js} +1 -1
  24. package/dist/{transport-CuogVKN_.js.map → transport-B3G50KVd.js.map} +1 -1
  25. package/dist/{transport-ByGviWdZ.js → transport-CZDHzfvy.js} +1 -1
  26. package/dist/{transport-ByGviWdZ.js.map → transport-CZDHzfvy.js.map} +1 -1
  27. package/dist/{worker-handle-B3p-nuqG.js → worker-handle-C2rLUHwv.js} +9 -8
  28. package/dist/{worker-handle-B3p-nuqG.js.map → worker-handle-C2rLUHwv.js.map} +1 -1
  29. package/package.json +14 -7
  30. package/dist/document-indexer-Dn9RB0sg.js.map +0 -1
  31. package/dist/drive-container-types-Be5-EY9W.js.map +0 -1
  32. package/dist/error-info-Cpu4OY3o.js +0 -62
  33. package/dist/error-info-Cpu4OY3o.js.map +0 -1
  34. package/dist/forwarding-logger-BBkMSxuJ.js +0 -85
  35. package/dist/forwarding-logger-BBkMSxuJ.js.map +0 -1
  36. package/dist/types-DxDCmtId.js +0 -34
  37. package/dist/types-DxDCmtId.js.map +0 -1
  38. package/dist/worker-BDVzCtuf.js +0 -22
  39. package/dist/worker-BDVzCtuf.js.map +0 -1
@@ -1,62 +0,0 @@
1
- //#region src/executor/worker/error-info.ts
2
- const MAX_STACK_LENGTH = 8 * 1024;
3
- const MAX_CAUSE_DEPTH = 8;
4
- function toErrorInfo(err, depth = 0) {
5
- if (depth > MAX_CAUSE_DEPTH) return {
6
- name: "Error",
7
- message: "cause chain truncated"
8
- };
9
- if (err instanceof Error) {
10
- const info = {
11
- name: err.name || "Error",
12
- message: err.message
13
- };
14
- if (typeof err.stack === "string") info.stack = err.stack.length > MAX_STACK_LENGTH ? err.stack.slice(0, MAX_STACK_LENGTH) : err.stack;
15
- if (err.cause !== void 0) info.cause = toErrorInfo(err.cause, depth + 1);
16
- return info;
17
- }
18
- if (typeof err === "string") return {
19
- name: "Error",
20
- message: err
21
- };
22
- if (err && typeof err === "object") {
23
- const record = err;
24
- return {
25
- name: typeof record.name === "string" ? record.name : "Error",
26
- message: typeof record.message === "string" ? record.message : safeStringify(err)
27
- };
28
- }
29
- return {
30
- name: "Error",
31
- message: safeStringify(err)
32
- };
33
- }
34
- function safeStringify(value) {
35
- if (value === null || value === void 0) return String(value);
36
- if (typeof value === "string") return value;
37
- if (typeof value === "number" || typeof value === "boolean") return String(value);
38
- try {
39
- return JSON.stringify(value);
40
- } catch {
41
- return "[unserializable]";
42
- }
43
- }
44
- function fromErrorInfo(info) {
45
- const err = new Error(info.message);
46
- Object.defineProperty(err, "name", {
47
- value: info.name,
48
- configurable: true,
49
- writable: true
50
- });
51
- if (info.stack !== void 0) err.stack = info.stack;
52
- if (info.cause !== void 0) Object.defineProperty(err, "cause", {
53
- value: fromErrorInfo(info.cause),
54
- configurable: true,
55
- writable: true
56
- });
57
- return err;
58
- }
59
- //#endregion
60
- export { toErrorInfo as n, fromErrorInfo as t };
61
-
62
- //# sourceMappingURL=error-info-Cpu4OY3o.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-info-Cpu4OY3o.js","names":[],"sources":["../src/executor/worker/error-info.ts"],"sourcesContent":["/**\n * Helpers for marshalling `Error` instances across the worker IPC boundary.\n *\n * Class instances cannot be structured-cloned, so {@link ErrorInfo} is the\n * canonical wire shape (see `protocol.ts`). These helpers walk `cause`\n * chains, truncate stacks, and drop non-cloneable fields.\n */\n\nimport type { ErrorInfo } from \"./protocol.js\";\n\nconst MAX_STACK_LENGTH = 8 * 1024;\nconst MAX_CAUSE_DEPTH = 8;\n\nexport function toErrorInfo(err: unknown, depth = 0): ErrorInfo {\n if (depth > MAX_CAUSE_DEPTH) {\n return { name: \"Error\", message: \"cause chain truncated\" };\n }\n if (err instanceof Error) {\n const info: ErrorInfo = {\n name: err.name || \"Error\",\n message: err.message,\n };\n if (typeof err.stack === \"string\") {\n info.stack =\n err.stack.length > MAX_STACK_LENGTH\n ? err.stack.slice(0, MAX_STACK_LENGTH)\n : err.stack;\n }\n if (err.cause !== undefined) {\n info.cause = toErrorInfo(err.cause, depth + 1);\n }\n return info;\n }\n if (typeof err === \"string\") {\n return { name: \"Error\", message: err };\n }\n if (err && typeof err === \"object\") {\n const record = err as { name?: unknown; message?: unknown };\n return {\n name: typeof record.name === \"string\" ? record.name : \"Error\",\n message:\n typeof record.message === \"string\"\n ? record.message\n : safeStringify(err),\n };\n }\n return { name: \"Error\", message: safeStringify(err) };\n}\n\nfunction safeStringify(value: unknown): string {\n if (value === null || value === undefined) {\n return String(value);\n }\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n try {\n return JSON.stringify(value);\n } catch {\n return \"[unserializable]\";\n }\n}\n\nexport function fromErrorInfo(info: ErrorInfo): Error {\n const err = new Error(info.message);\n Object.defineProperty(err, \"name\", {\n value: info.name,\n configurable: true,\n writable: true,\n });\n if (info.stack !== undefined) {\n err.stack = info.stack;\n }\n if (info.cause !== undefined) {\n Object.defineProperty(err, \"cause\", {\n value: fromErrorInfo(info.cause),\n configurable: true,\n writable: true,\n });\n }\n return err;\n}\n"],"mappings":";AAUA,MAAM,mBAAmB,IAAI;AAC7B,MAAM,kBAAkB;AAExB,SAAgB,YAAY,KAAc,QAAQ,GAAc;AAC9D,KAAI,QAAQ,gBACV,QAAO;EAAE,MAAM;EAAS,SAAS;EAAyB;AAE5D,KAAI,eAAe,OAAO;EACxB,MAAM,OAAkB;GACtB,MAAM,IAAI,QAAQ;GAClB,SAAS,IAAI;GACd;AACD,MAAI,OAAO,IAAI,UAAU,SACvB,MAAK,QACH,IAAI,MAAM,SAAS,mBACf,IAAI,MAAM,MAAM,GAAG,iBAAiB,GACpC,IAAI;AAEZ,MAAI,IAAI,UAAU,KAAA,EAChB,MAAK,QAAQ,YAAY,IAAI,OAAO,QAAQ,EAAE;AAEhD,SAAO;;AAET,KAAI,OAAO,QAAQ,SACjB,QAAO;EAAE,MAAM;EAAS,SAAS;EAAK;AAExC,KAAI,OAAO,OAAO,QAAQ,UAAU;EAClC,MAAM,SAAS;AACf,SAAO;GACL,MAAM,OAAO,OAAO,SAAS,WAAW,OAAO,OAAO;GACtD,SACE,OAAO,OAAO,YAAY,WACtB,OAAO,UACP,cAAc,IAAI;GACzB;;AAEH,QAAO;EAAE,MAAM;EAAS,SAAS,cAAc,IAAI;EAAE;;AAGvD,SAAS,cAAc,OAAwB;AAC7C,KAAI,UAAU,QAAQ,UAAU,KAAA,EAC9B,QAAO,OAAO,MAAM;AAEtB,KAAI,OAAO,UAAU,SACnB,QAAO;AAET,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAChD,QAAO,OAAO,MAAM;AAEtB,KAAI;AACF,SAAO,KAAK,UAAU,MAAM;SACtB;AACN,SAAO;;;AAIX,SAAgB,cAAc,MAAwB;CACpD,MAAM,MAAM,IAAI,MAAM,KAAK,QAAQ;AACnC,QAAO,eAAe,KAAK,QAAQ;EACjC,OAAO,KAAK;EACZ,cAAc;EACd,UAAU;EACX,CAAC;AACF,KAAI,KAAK,UAAU,KAAA,EACjB,KAAI,QAAQ,KAAK;AAEnB,KAAI,KAAK,UAAU,KAAA,EACjB,QAAO,eAAe,KAAK,SAAS;EAClC,OAAO,cAAc,KAAK,MAAM;EAChC,cAAc;EACd,UAAU;EACX,CAAC;AAEJ,QAAO"}
@@ -1,85 +0,0 @@
1
- import { n as toErrorInfo } from "./error-info-Cpu4OY3o.js";
2
- //#region src/executor/worker/sanitize.ts
3
- const MAX_DEPTH = 8;
4
- function errorToInfo(err) {
5
- return toErrorInfo(err);
6
- }
7
- function sanitizeArg(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
8
- if (depth > MAX_DEPTH) return "[Truncated]";
9
- if (value === null || value === void 0) return null;
10
- if (typeof value === "boolean") return value;
11
- if (typeof value === "number") return value;
12
- if (typeof value === "string") return value;
13
- if (typeof value === "bigint") return value.toString();
14
- if (typeof value === "function" || typeof value === "symbol") return null;
15
- if (value instanceof Error) return toErrorInfo(value);
16
- if (value instanceof Date) return value.toISOString();
17
- if (value instanceof Map) {
18
- const obj = {};
19
- for (const [k, v] of value.entries()) obj[String(k)] = sanitizeArg(v, depth + 1, seen);
20
- return obj;
21
- }
22
- if (value instanceof Set) {
23
- const arr = [];
24
- for (const v of value.values()) arr.push(sanitizeArg(v, depth + 1, seen));
25
- return arr;
26
- }
27
- if (Array.isArray(value)) {
28
- if (seen.has(value)) return "[Circular]";
29
- seen.add(value);
30
- const result = value.map((v) => sanitizeArg(v, depth + 1, seen));
31
- seen.delete(value);
32
- return result;
33
- }
34
- if (typeof value === "object") {
35
- const proto = Object.getPrototypeOf(value);
36
- if (proto !== Object.prototype && proto !== null) return { __nonClonable: value.constructor?.name || "Unknown" };
37
- if (seen.has(value)) return "[Circular]";
38
- seen.add(value);
39
- const result = {};
40
- for (const [k, v] of Object.entries(value)) result[k] = sanitizeArg(v, depth + 1, seen);
41
- seen.delete(value);
42
- return result;
43
- }
44
- return null;
45
- }
46
- //#endregion
47
- //#region src/executor/worker/forwarding-logger.ts
48
- function createForwardingLogger(post, level = "info", tags = []) {
49
- function safePost(msg) {
50
- try {
51
- post(msg);
52
- } catch {
53
- try {
54
- process.stderr.write(`[forwarding-logger] postMessage failed: ${msg.level} ${msg.message}\n`);
55
- } catch {}
56
- }
57
- }
58
- function emit(wireLevel, message, args) {
59
- const sanitizedArgs = args.map((a) => sanitizeArg(a));
60
- safePost({
61
- type: "log",
62
- level: wireLevel,
63
- message,
64
- args: tags.length > 0 ? [sanitizeArg({ tags }), ...sanitizedArgs] : sanitizedArgs,
65
- timestamp: Date.now()
66
- });
67
- }
68
- return {
69
- level,
70
- verbose: (message, ...args) => emit("debug", message, args),
71
- debug: (message, ...args) => emit("debug", message, args),
72
- info: (message, ...args) => emit("info", message, args),
73
- warn: (message, ...args) => emit("warn", message, args),
74
- error: (message, ...args) => emit("error", message, args),
75
- errorHandler: ((...data) => {
76
- const first = data[0];
77
- emit("error", typeof first === "string" ? first : "", data.slice(1));
78
- }),
79
- child: (childTags) => createForwardingLogger(post, level, [...tags, ...childTags])
80
- };
81
- }
82
- //#endregion
83
- export { errorToInfo as n, sanitizeArg as r, createForwardingLogger as t };
84
-
85
- //# sourceMappingURL=forwarding-logger-BBkMSxuJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"forwarding-logger-BBkMSxuJ.js","names":[],"sources":["../src/executor/worker/sanitize.ts","../src/executor/worker/forwarding-logger.ts"],"sourcesContent":["import type { ErrorInfo, SanitizedArg } from \"./protocol.js\";\nimport { toErrorInfo } from \"./error-info.js\";\n\nconst MAX_DEPTH = 8;\n\nexport function errorToInfo(err: unknown): ErrorInfo {\n return toErrorInfo(err);\n}\n\nexport function sanitizeArg(\n value: unknown,\n depth = 0,\n seen = new WeakSet<object>(),\n): SanitizedArg {\n if (depth > MAX_DEPTH) {\n return \"[Truncated]\";\n }\n\n if (value === null || value === undefined) return null;\n if (typeof value === \"boolean\") return value;\n if (typeof value === \"number\") return value;\n if (typeof value === \"string\") return value;\n if (typeof value === \"bigint\") return value.toString();\n if (typeof value === \"function\" || typeof value === \"symbol\") return null;\n\n if (value instanceof Error) {\n return toErrorInfo(value);\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n if (value instanceof Map) {\n const obj: { [key: string]: SanitizedArg } = {};\n for (const [k, v] of value.entries()) {\n obj[String(k)] = sanitizeArg(v, depth + 1, seen);\n }\n return obj;\n }\n\n if (value instanceof Set) {\n const arr: SanitizedArg[] = [];\n for (const v of value.values()) {\n arr.push(sanitizeArg(v, depth + 1, seen));\n }\n return arr;\n }\n\n if (Array.isArray(value)) {\n if (seen.has(value)) return \"[Circular]\";\n seen.add(value);\n const result: SanitizedArg[] = value.map((v) =>\n sanitizeArg(v, depth + 1, seen),\n );\n seen.delete(value);\n return result;\n }\n\n if (typeof value === \"object\") {\n const proto: object | null = Object.getPrototypeOf(value) as object | null;\n if (proto !== Object.prototype && proto !== null) {\n const ctorName =\n (value as { constructor?: { name?: string } }).constructor?.name ||\n \"Unknown\";\n return { __nonClonable: ctorName };\n }\n\n if (seen.has(value as object)) return \"[Circular]\";\n seen.add(value as object);\n const result: { [key: string]: SanitizedArg } = {};\n for (const [k, v] of Object.entries(value as object)) {\n result[k] = sanitizeArg(v, depth + 1, seen);\n }\n seen.delete(value as object);\n return result;\n }\n\n return null;\n}\n","import type { ILogger, LoggerErrorHandler } from \"document-model\";\nimport type { LogMessage } from \"./protocol.js\";\nimport { sanitizeArg } from \"./sanitize.js\";\n\nexport function createForwardingLogger(\n post: (msg: LogMessage) => void,\n level: ILogger[\"level\"] = \"info\",\n tags: string[] = [],\n): ILogger {\n function safePost(msg: LogMessage): void {\n try {\n post(msg);\n } catch {\n try {\n process.stderr.write(\n `[forwarding-logger] postMessage failed: ${msg.level} ${msg.message}\\n`,\n );\n } catch {\n // nowhere left to report\n }\n }\n }\n\n function emit(\n wireLevel: LogMessage[\"level\"],\n message: string,\n args: unknown[],\n ): void {\n const sanitizedArgs = args.map((a) => sanitizeArg(a));\n const finalArgs =\n tags.length > 0\n ? [sanitizeArg({ tags }), ...sanitizedArgs]\n : sanitizedArgs;\n safePost({\n type: \"log\",\n level: wireLevel,\n message,\n args: finalArgs,\n timestamp: Date.now(),\n });\n }\n\n return {\n level,\n verbose: (message, ...args) => emit(\"debug\", message, args),\n debug: (message, ...args) => emit(\"debug\", message, args),\n info: (message, ...args) => emit(\"info\", message, args),\n warn: (message, ...args) => emit(\"warn\", message, args),\n error: (message, ...args) => emit(\"error\", message, args),\n errorHandler: ((...data: unknown[]) => {\n const first = data[0];\n const head = typeof first === \"string\" ? first : \"\";\n emit(\"error\", head, data.slice(1));\n }) as LoggerErrorHandler,\n child: (childTags) =>\n createForwardingLogger(post, level, [...tags, ...childTags]),\n };\n}\n"],"mappings":"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"}
@@ -1,34 +0,0 @@
1
- //#region src/events/types.ts
2
- /**
3
- * Custom error class that aggregates multiple errors from event subscribers.
4
- */
5
- var EventBusAggregateError = class extends Error {
6
- errors;
7
- constructor(errors) {
8
- const message = `EventBus emit failed with ${errors.length} error(s): ${errors.map((e) => {
9
- if (e && typeof e === "object" && "message" in e) return e.message;
10
- return String(e);
11
- }).join("; ")}`;
12
- super(message);
13
- this.name = "EventBusAggregateError";
14
- this.errors = errors;
15
- }
16
- };
17
- /**
18
- * Event types for reactor lifecycle events.
19
- */
20
- const ReactorEventTypes = {
21
- JOB_PENDING: 10001,
22
- JOB_RUNNING: 10002,
23
- JOB_WRITE_READY: 10003,
24
- JOB_READ_READY: 10004,
25
- JOB_FAILED: 10005,
26
- READMODEL_BATCH_COMPLETED: 10006,
27
- READMODEL_INDEXED: 10007,
28
- MODEL_LOADED: 10008,
29
- SIGNATURE_REFUSED: 10009
30
- };
31
- //#endregion
32
- export { ReactorEventTypes as n, EventBusAggregateError as t };
33
-
34
- //# sourceMappingURL=types-DxDCmtId.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-DxDCmtId.js","names":[],"sources":["../src/events/types.ts"],"sourcesContent":["import type { OperationWithContext } from \"@powerhousedao/shared/document-model\";\nimport type { Job } from \"../queue/types.js\";\nimport type { JobMeta } from \"../shared/types.js\";\nimport type {\n AdmissionPath,\n SignatureRefusalCode,\n SignatureScheme,\n} from \"../signer/types.js\";\n\n/**\n * Describes a function to unsubscribe from an event.\n */\nexport type Unsubscribe = () => void;\n\n/**\n * A subscriber is a function that is called when an event is emitted.\n *\n * It is passed the event type and the data.\n * It can return a promise or a value.\n * If it returns a promise, the event bus will wait for the promise to resolve before calling the next subscriber.\n * If it throws an error, the event bus will reject with an aggregate error of all errors.\n *\n * @param type - The type of event to emit.\n * @param data - The data to pass to the subscriber.\n */\nexport type Subscriber = (type: number, data: any) => void | Promise<void>;\n\n/**\n * Custom error class that aggregates multiple errors from event subscribers.\n */\nexport class EventBusAggregateError extends Error {\n public readonly errors: any[];\n\n constructor(errors: unknown[]) {\n const message = `EventBus emit failed with ${errors.length} error(s): ${errors\n .map((e) => {\n if (e && typeof e === \"object\" && \"message\" in e) {\n return (e as Error).message;\n }\n return String(e);\n })\n .join(\"; \")}`;\n super(message);\n\n this.name = \"EventBusAggregateError\";\n this.errors = errors;\n }\n}\n\n/**\n * Event types for reactor lifecycle events.\n */\nexport const ReactorEventTypes = {\n JOB_PENDING: 10001,\n JOB_RUNNING: 10002,\n JOB_WRITE_READY: 10003,\n JOB_READ_READY: 10004,\n JOB_FAILED: 10005,\n READMODEL_BATCH_COMPLETED: 10006,\n READMODEL_INDEXED: 10007,\n MODEL_LOADED: 10008,\n SIGNATURE_REFUSED: 10009,\n} as const;\n\n/**\n * Stage within ReadModelCoordinator.runChain. Used as a dimension on\n * stage-attribution events and histograms.\n */\nexport type ReadModelStage = \"pre_ready\" | \"emit\" | \"post_ready\";\n\n/**\n * Stage in which an individual read model ran. The emit stage does not\n * involve a read model so it is excluded from this discriminant.\n */\nexport type ReadModelIndexingStage = \"pre_ready\" | \"post_ready\";\n\n/**\n * Emitted after the resolver loads a model on demand, so peers load it too.\n */\nexport type ModelLoadedEvent = {\n documentType: string;\n};\n\n/**\n * Event emitted when a job is registered and waiting to be executed.\n */\nexport type JobPendingEvent = {\n jobId: string;\n jobMeta: JobMeta;\n};\n\n/**\n * Event emitted when a job starts executing.\n */\nexport type JobRunningEvent = {\n jobId: string;\n jobMeta: JobMeta;\n};\n\n/**\n * Event emitted when operations are written to IOperationStore.\n * Contains the operations directly to avoid round-trip queries.\n */\nexport type JobWriteReadyEvent = {\n jobId: string;\n operations: OperationWithContext[];\n jobMeta: JobMeta;\n /**\n * The ids of the actions the caller submitted with this job. `operations`\n * can also carry operations the job merely moved into a new position, so a\n * consumer reporting back to the caller needs this to tell the two apart.\n * Absent on jobs that carry no submitted actions.\n */\n submittedActionIds?: string[];\n /**\n * Maps documentId to the collection IDs it belongs to.\n * Used by SyncManager to route operations only to remotes\n * whose collection contains the document.\n */\n collectionMemberships?: Record<string, string[]>;\n};\n\n/**\n * Event emitted after all read models have finished processing operations.\n * This event fires after JOB_WRITE_READY and guarantees that:\n * - All read models (DocumentView, DocumentIndexer, etc.) have indexed the operations\n * - All consistency trackers have been updated with the new operation indices\n * - Queries without consistency tokens will now see the updated data\n *\n * This event is useful for:\n * - Test synchronization (knowing when read models are ready)\n * - Observability (measuring read model latency)\n * - Event-driven workflows (triggering downstream processes)\n */\nexport type JobReadReadyEvent = {\n jobId: string;\n operations: OperationWithContext[];\n};\n\n/**\n * Event emitted when a job fails with an unrecoverable error.\n * This event allows the JobAwaiter and other subscribers to react to job failures\n * without polling.\n */\nexport type JobFailedEvent = {\n jobId: string;\n error: Error;\n job?: Job;\n};\n\n/**\n * Event emitted once per batch processed by ReadModelCoordinator.runChain,\n * after all three projection stages complete. Carries per-stage wall times,\n * the chain wait time, and the batch size so projection cost can be\n * attributed by an observer.\n */\nexport type ReadModelBatchCompletedEvent = {\n jobId: string;\n batchSize: number;\n chainWaitDurationMs: number;\n preReadyDurationMs: number;\n emitDurationMs: number;\n postReadyDurationMs: number;\n};\n\n/**\n * Event emitted once per individual read model per batch and stage, after\n * that read model's indexOperations call resolves (or rejects). Lets\n * observers attribute projection cost to a specific read model.\n */\nexport type ReadModelIndexedEvent = {\n jobId: string;\n readModelName: string;\n stage: ReadModelIndexingStage;\n durationMs: number;\n operationCount: number;\n success: boolean;\n};\n\n/** A write failed admission; `enforced` is false in log mode, which admits it. */\nexport type SignatureRefusedEvent = {\n jobId: string;\n documentId: string;\n scope: string;\n branch: string;\n actionId: string;\n code: SignatureRefusalCode;\n scheme: SignatureScheme;\n path: AdmissionPath;\n enforced: boolean;\n reason: string;\n};\n"],"mappings":";;;;AA8BA,IAAa,yBAAb,cAA4C,MAAM;CAChD;CAEA,YAAY,QAAmB;EAC7B,MAAM,UAAU,6BAA6B,OAAO,OAAO,aAAa,OACrE,KAAK,MAAM;AACV,OAAI,KAAK,OAAO,MAAM,YAAY,aAAa,EAC7C,QAAQ,EAAY;AAEtB,UAAO,OAAO,EAAE;IAChB,CACD,KAAK,KAAK;AACb,QAAM,QAAQ;AAEd,OAAK,OAAO;AACZ,OAAK,SAAS;;;;;;AAOlB,MAAa,oBAAoB;CAC/B,aAAa;CACb,aAAa;CACb,iBAAiB;CACjB,gBAAgB;CAChB,YAAY;CACZ,2BAA2B;CAC3B,mBAAmB;CACnB,cAAc;CACd,mBAAmB;CACpB"}
@@ -1,22 +0,0 @@
1
- import { at as __exportAll } from "./drive-container-types-Be5-EY9W.js";
2
- import { n as errorToInfo, r as sanitizeArg, t as createForwardingLogger } from "./forwarding-logger-BBkMSxuJ.js";
3
- //#region src/executor/worker/index.ts
4
- var worker_exports = /* @__PURE__ */ __exportAll({
5
- createForwardingLogger: () => createForwardingLogger,
6
- errorToInfo: () => errorToInfo,
7
- sanitizeArg: () => sanitizeArg,
8
- workerEntryPath: () => workerEntryPath
9
- });
10
- function resolveWorkerEntryPath() {
11
- const url = new URL("./entry.js", import.meta.url);
12
- if (url.protocol !== "file:") return url.href;
13
- let pathname = decodeURIComponent(url.pathname);
14
- if (/^\/[A-Za-z]:[/\\]/.test(pathname)) pathname = pathname.slice(1);
15
- return pathname;
16
- }
17
- /** Absolute path to the worker entry script for use with `new Worker(workerEntryPath)`. */
18
- const workerEntryPath = resolveWorkerEntryPath();
19
- //#endregion
20
- export { worker_exports as n, workerEntryPath as t };
21
-
22
- //# sourceMappingURL=worker-BDVzCtuf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-BDVzCtuf.js","names":[],"sources":["../src/executor/worker/index.ts"],"sourcesContent":["export { createForwardingLogger } from \"./forwarding-logger.js\";\nexport { errorToInfo, sanitizeArg } from \"./sanitize.js\";\n\nfunction resolveWorkerEntryPath(): string {\n const url = new URL(\"./entry.js\", import.meta.url);\n if (url.protocol !== \"file:\") {\n return url.href;\n }\n let pathname = decodeURIComponent(url.pathname);\n if (/^\\/[A-Za-z]:[/\\\\]/.test(pathname)) {\n pathname = pathname.slice(1);\n }\n return pathname;\n}\n\n/** Absolute path to the worker entry script for use with `new Worker(workerEntryPath)`. */\nexport const workerEntryPath = resolveWorkerEntryPath();\n"],"mappings":";;;;;;;;;AAGA,SAAS,yBAAiC;CACxC,MAAM,MAAM,IAAI,IAAI,cAAc,OAAO,KAAK,IAAI;AAClD,KAAI,IAAI,aAAa,QACnB,QAAO,IAAI;CAEb,IAAI,WAAW,mBAAmB,IAAI,SAAS;AAC/C,KAAI,oBAAoB,KAAK,SAAS,CACpC,YAAW,SAAS,MAAM,EAAE;AAE9B,QAAO;;;AAIT,MAAa,kBAAkB,wBAAwB"}