@optave/codegraph 3.9.3 → 3.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +10 -10
  2. package/dist/ast-analysis/visitor.d.ts.map +1 -1
  3. package/dist/ast-analysis/visitor.js +14 -0
  4. package/dist/ast-analysis/visitor.js.map +1 -1
  5. package/dist/cli/commands/watch.d.ts.map +1 -1
  6. package/dist/cli/commands/watch.js +2 -0
  7. package/dist/cli/commands/watch.js.map +1 -1
  8. package/dist/cli.js +24 -1
  9. package/dist/cli.js.map +1 -1
  10. package/dist/domain/graph/builder/context.d.ts +17 -0
  11. package/dist/domain/graph/builder/context.d.ts.map +1 -1
  12. package/dist/domain/graph/builder/context.js +7 -0
  13. package/dist/domain/graph/builder/context.js.map +1 -1
  14. package/dist/domain/graph/builder/helpers.d.ts +13 -2
  15. package/dist/domain/graph/builder/helpers.d.ts.map +1 -1
  16. package/dist/domain/graph/builder/helpers.js +30 -4
  17. package/dist/domain/graph/builder/helpers.js.map +1 -1
  18. package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
  19. package/dist/domain/graph/builder/pipeline.js +221 -51
  20. package/dist/domain/graph/builder/pipeline.js.map +1 -1
  21. package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
  22. package/dist/domain/graph/builder/stages/build-edges.js +67 -6
  23. package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
  24. package/dist/domain/graph/builder/stages/build-structure.js +2 -2
  25. package/dist/domain/graph/builder/stages/collect-files.d.ts.map +1 -1
  26. package/dist/domain/graph/builder/stages/collect-files.js +58 -26
  27. package/dist/domain/graph/builder/stages/collect-files.js.map +1 -1
  28. package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -1
  29. package/dist/domain/graph/builder/stages/detect-changes.js +105 -55
  30. package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -1
  31. package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -1
  32. package/dist/domain/graph/builder/stages/finalize.js +27 -4
  33. package/dist/domain/graph/builder/stages/finalize.js.map +1 -1
  34. package/dist/domain/graph/builder/stages/run-analyses.d.ts.map +1 -1
  35. package/dist/domain/graph/builder/stages/run-analyses.js +5 -20
  36. package/dist/domain/graph/builder/stages/run-analyses.js.map +1 -1
  37. package/dist/domain/graph/journal.d.ts +15 -0
  38. package/dist/domain/graph/journal.d.ts.map +1 -1
  39. package/dist/domain/graph/journal.js +283 -28
  40. package/dist/domain/graph/journal.js.map +1 -1
  41. package/dist/domain/graph/watcher.d.ts +17 -0
  42. package/dist/domain/graph/watcher.d.ts.map +1 -1
  43. package/dist/domain/graph/watcher.js +23 -7
  44. package/dist/domain/graph/watcher.js.map +1 -1
  45. package/dist/domain/parser.d.ts +13 -4
  46. package/dist/domain/parser.d.ts.map +1 -1
  47. package/dist/domain/parser.js +174 -80
  48. package/dist/domain/parser.js.map +1 -1
  49. package/dist/domain/search/generator.d.ts.map +1 -1
  50. package/dist/domain/search/generator.js +28 -2
  51. package/dist/domain/search/generator.js.map +1 -1
  52. package/dist/domain/wasm-worker-entry.d.ts +24 -0
  53. package/dist/domain/wasm-worker-entry.d.ts.map +1 -0
  54. package/dist/domain/wasm-worker-entry.js +643 -0
  55. package/dist/domain/wasm-worker-entry.js.map +1 -0
  56. package/dist/domain/wasm-worker-pool.d.ts +59 -0
  57. package/dist/domain/wasm-worker-pool.d.ts.map +1 -0
  58. package/dist/domain/wasm-worker-pool.js +312 -0
  59. package/dist/domain/wasm-worker-pool.js.map +1 -0
  60. package/dist/domain/wasm-worker-protocol.d.ts +65 -0
  61. package/dist/domain/wasm-worker-protocol.d.ts.map +1 -0
  62. package/dist/domain/wasm-worker-protocol.js +13 -0
  63. package/dist/domain/wasm-worker-protocol.js.map +1 -0
  64. package/dist/extractors/javascript.js +265 -1
  65. package/dist/extractors/javascript.js.map +1 -1
  66. package/dist/features/boundaries.d.ts +2 -2
  67. package/dist/features/boundaries.d.ts.map +1 -1
  68. package/dist/features/boundaries.js +2 -31
  69. package/dist/features/boundaries.js.map +1 -1
  70. package/dist/features/snapshot.d.ts.map +1 -1
  71. package/dist/features/snapshot.js +99 -13
  72. package/dist/features/snapshot.js.map +1 -1
  73. package/dist/features/structure.d.ts.map +1 -1
  74. package/dist/features/structure.js +14 -1
  75. package/dist/features/structure.js.map +1 -1
  76. package/dist/graph/algorithms/louvain.d.ts.map +1 -1
  77. package/dist/graph/algorithms/louvain.js +2 -4
  78. package/dist/graph/algorithms/louvain.js.map +1 -1
  79. package/dist/infrastructure/config.d.ts.map +1 -1
  80. package/dist/infrastructure/config.js +12 -2
  81. package/dist/infrastructure/config.js.map +1 -1
  82. package/dist/shared/globs.d.ts +40 -0
  83. package/dist/shared/globs.d.ts.map +1 -0
  84. package/dist/shared/globs.js +126 -0
  85. package/dist/shared/globs.js.map +1 -0
  86. package/dist/types.d.ts +26 -1
  87. package/dist/types.d.ts.map +1 -1
  88. package/grammars/tree-sitter-c_sharp.wasm +0 -0
  89. package/package.json +7 -7
  90. package/src/ast-analysis/visitor.ts +15 -0
  91. package/src/cli/commands/watch.ts +2 -0
  92. package/src/cli.ts +31 -8
  93. package/src/domain/graph/builder/context.ts +19 -0
  94. package/src/domain/graph/builder/helpers.ts +53 -3
  95. package/src/domain/graph/builder/pipeline.ts +235 -49
  96. package/src/domain/graph/builder/stages/build-edges.ts +80 -6
  97. package/src/domain/graph/builder/stages/build-structure.ts +2 -2
  98. package/src/domain/graph/builder/stages/collect-files.ts +56 -26
  99. package/src/domain/graph/builder/stages/detect-changes.ts +118 -61
  100. package/src/domain/graph/builder/stages/finalize.ts +27 -4
  101. package/src/domain/graph/builder/stages/run-analyses.ts +5 -26
  102. package/src/domain/graph/journal.ts +284 -27
  103. package/src/domain/graph/watcher.ts +29 -9
  104. package/src/domain/parser.ts +166 -73
  105. package/src/domain/search/generator.ts +34 -2
  106. package/src/domain/wasm-worker-entry.ts +788 -0
  107. package/src/domain/wasm-worker-pool.ts +330 -0
  108. package/src/domain/wasm-worker-protocol.ts +81 -0
  109. package/src/extractors/javascript.ts +290 -1
  110. package/src/features/boundaries.ts +2 -27
  111. package/src/features/snapshot.ts +93 -14
  112. package/src/features/structure.ts +17 -1
  113. package/src/graph/algorithms/louvain.ts +2 -4
  114. package/src/infrastructure/config.ts +12 -2
  115. package/src/shared/globs.ts +121 -0
  116. package/src/types.ts +26 -1
@@ -0,0 +1,59 @@
1
+ /**
2
+ * WASM parse worker pool with crash recovery.
3
+ *
4
+ * The WASM grammar can trigger uncatchable V8 fatal errors (#965) that kill
5
+ * whichever thread is running it. Running parses in a worker_thread means the
6
+ * crash kills only the worker — the pool detects the exit, marks the in-flight
7
+ * file as skipped, respawns the worker, and continues with the rest.
8
+ *
9
+ * This is a single-worker pool; dispatch is sequential. Multi-worker parallelism
10
+ * is a future optimization — correctness of crash isolation does not depend on
11
+ * it. Sequential dispatch also simplifies attribution of a crash to a single
12
+ * "in-flight" file.
13
+ */
14
+ import type { ExtractorOutput } from '../types.js';
15
+ import type { WorkerAnalysisOpts } from './wasm-worker-protocol.js';
16
+ export declare class WasmWorkerPool {
17
+ private worker;
18
+ private nextId;
19
+ private queue;
20
+ private inFlight;
21
+ private disposed;
22
+ /** filePaths that already caused one worker crash — skipped rather than retried. */
23
+ private crashedFiles;
24
+ /**
25
+ * Tracks the id of the job whose timeout fired and triggered `terminate()`.
26
+ * Node timers are delivered before poll-phase I/O, so `onTimeout` can fire in
27
+ * the same loop iteration that already has the worker's response queued. In
28
+ * that race, `onMessage` resolves the timed-out job and starts the next one
29
+ * BEFORE `onExit` arrives for the earlier `terminate()` — so the `inFlight`
30
+ * job `onExit` sees is the innocent next job, not the one that actually hung.
31
+ * `onExit` uses this field to detect the mismatch and re-queue the new job
32
+ * instead of silently discarding it.
33
+ */
34
+ private timedOutJobId;
35
+ /**
36
+ * Parse a single file via the worker. Returns the fully pre-computed
37
+ * ExtractorOutput, or `null` if the worker crashed on this file or
38
+ * reported a soft error.
39
+ */
40
+ parse(filePath: string, code: string, opts: WorkerAnalysisOpts): Promise<ExtractorOutput | null>;
41
+ /** Terminate the worker and drain pending jobs with null results. */
42
+ dispose(): Promise<void>;
43
+ private pump;
44
+ /**
45
+ * Called when the per-job watchdog fires. Terminate the worker so the
46
+ * hang stops consuming CPU; `onExit` will then resolve the in-flight job
47
+ * with `null` and blacklist the file via `crashedFiles`.
48
+ */
49
+ private onTimeout;
50
+ private ensureWorker;
51
+ private onMessage;
52
+ private onError;
53
+ private onExit;
54
+ }
55
+ /** Shared pool instance for the process. Callers share the worker across builds. */
56
+ export declare function getWasmWorkerPool(): WasmWorkerPool;
57
+ /** Dispose the shared pool (used by tests + `disposeParsers`). */
58
+ export declare function disposeWasmWorkerPool(): Promise<void>;
59
+ //# sourceMappingURL=wasm-worker-pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm-worker-pool.d.ts","sourceRoot":"","sources":["../../src/domain/wasm-worker-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,KAAK,EAAc,eAAe,EAAgB,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAEV,kBAAkB,EAGnB,MAAM,2BAA2B,CAAC;AAsFnC,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,QAAQ,CAAS;IACzB,oFAAoF;IACpF,OAAO,CAAC,YAAY,CAAqB;IACzC;;;;;;;;;OASG;IACH,OAAO,CAAC,aAAa,CAAuB;IAE5C;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAiBhG,qEAAqE;IAC/D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB9B,OAAO,CAAC,IAAI;IAmBZ;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAoBjB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,SAAS;IA0BjB,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,MAAM;CAmDf;AAID,oFAAoF;AACpF,wBAAgB,iBAAiB,IAAI,cAAc,CAGlD;AAED,kEAAkE;AAClE,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAK3D"}
@@ -0,0 +1,312 @@
1
+ /**
2
+ * WASM parse worker pool with crash recovery.
3
+ *
4
+ * The WASM grammar can trigger uncatchable V8 fatal errors (#965) that kill
5
+ * whichever thread is running it. Running parses in a worker_thread means the
6
+ * crash kills only the worker — the pool detects the exit, marks the in-flight
7
+ * file as skipped, respawns the worker, and continues with the rest.
8
+ *
9
+ * This is a single-worker pool; dispatch is sequential. Multi-worker parallelism
10
+ * is a future optimization — correctness of crash isolation does not depend on
11
+ * it. Sequential dispatch also simplifies attribution of a crash to a single
12
+ * "in-flight" file.
13
+ */
14
+ import fs from 'node:fs';
15
+ import path from 'node:path';
16
+ import { fileURLToPath, pathToFileURL } from 'node:url';
17
+ import { Worker } from 'node:worker_threads';
18
+ import { debug, warn } from '../infrastructure/logger.js';
19
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
20
+ /**
21
+ * Resolve the path to the compiled worker entry script.
22
+ *
23
+ * The worker is always loaded from compiled `.js` — Node's worker_threads
24
+ * loader does not apply vitest/ts-node transforms or rewrite `.js` specifiers
25
+ * to `.ts`, so even under `--experimental-strip-types` the worker's
26
+ * relative `.js` imports (e.g. `../ast-analysis/metrics.js`) would fail to
27
+ * resolve inside the src/ tree.
28
+ *
29
+ * Resolution order:
30
+ * 1. Sibling `.js` (dist build — `dist/domain/wasm-worker-entry.js`).
31
+ * 2. Corresponding `dist/` file when running from `src/` (tests/dev).
32
+ * If neither exists, surface a clear error instead of silently exiting the
33
+ * worker with "module not found".
34
+ */
35
+ function resolveWorkerEntry() {
36
+ const selfUrl = import.meta.url;
37
+ const selfPath = fileURLToPath(selfUrl);
38
+ // Prefer the sibling .js first (dist build — fast path).
39
+ const siblingJs = path.join(path.dirname(selfPath), 'wasm-worker-entry.js');
40
+ if (fs.existsSync(siblingJs))
41
+ return pathToFileURL(siblingJs);
42
+ // Running from src/ — fall back to the compiled dist/ copy. Walk up to the
43
+ // package root (parent of `src/`) and look for `dist/domain/wasm-worker-entry.js`.
44
+ // This lets vitest import parser.ts while the worker still runs real .js.
45
+ const srcIdx = selfPath.lastIndexOf(`${path.sep}src${path.sep}`);
46
+ if (srcIdx !== -1) {
47
+ const repoRoot = selfPath.slice(0, srcIdx);
48
+ const distJs = path.join(repoRoot, 'dist', 'domain', 'wasm-worker-entry.js');
49
+ if (fs.existsSync(distJs))
50
+ return pathToFileURL(distJs);
51
+ }
52
+ throw new Error(`wasm-worker-entry.js not found — run \`npm run build\` to generate dist/. Searched: ${siblingJs}`);
53
+ }
54
+ /**
55
+ * Per-file watchdog deadline. A parse that takes longer than this is assumed
56
+ * to be hung (e.g. WASM grammar stuck in an infinite loop rather than
57
+ * crashing). We terminate the worker, skip the file, and continue.
58
+ *
59
+ * 60s is comfortably above worst-case real parses seen in CI (~12s for the
60
+ * slowest fixture) while still giving the build a definite upper bound
61
+ * instead of stalling forever.
62
+ */
63
+ const WORKER_PARSE_TIMEOUT_MS = 60_000;
64
+ function deserializeResult(ser) {
65
+ if (!ser)
66
+ return null;
67
+ const typeMap = new Map();
68
+ for (const [k, v] of ser.typeMap)
69
+ typeMap.set(k, v);
70
+ const out = {
71
+ definitions: ser.definitions,
72
+ calls: ser.calls,
73
+ imports: ser.imports,
74
+ classes: ser.classes,
75
+ exports: ser.exports,
76
+ typeMap,
77
+ };
78
+ if (ser._langId !== undefined)
79
+ out._langId = ser._langId;
80
+ if (ser._lineCount !== undefined)
81
+ out._lineCount = ser._lineCount;
82
+ if (ser.dataflow !== undefined)
83
+ out.dataflow = ser.dataflow;
84
+ // Pre-existing type mismatch: ExtractorOutput.astNodes is typed ASTNodeRow[]
85
+ // (DB-row shape with node_id), but all producers/consumers use the simpler
86
+ // {line, kind, name, text?, receiver?} shape — see engine.ts:822 where the
87
+ // visitor output is cast the same way.
88
+ if (ser.astNodes !== undefined)
89
+ out.astNodes = ser.astNodes;
90
+ return out;
91
+ }
92
+ export class WasmWorkerPool {
93
+ worker = null;
94
+ nextId = 1;
95
+ queue = [];
96
+ inFlight = null;
97
+ disposed = false;
98
+ /** filePaths that already caused one worker crash — skipped rather than retried. */
99
+ crashedFiles = new Set();
100
+ /**
101
+ * Tracks the id of the job whose timeout fired and triggered `terminate()`.
102
+ * Node timers are delivered before poll-phase I/O, so `onTimeout` can fire in
103
+ * the same loop iteration that already has the worker's response queued. In
104
+ * that race, `onMessage` resolves the timed-out job and starts the next one
105
+ * BEFORE `onExit` arrives for the earlier `terminate()` — so the `inFlight`
106
+ * job `onExit` sees is the innocent next job, not the one that actually hung.
107
+ * `onExit` uses this field to detect the mismatch and re-queue the new job
108
+ * instead of silently discarding it.
109
+ */
110
+ timedOutJobId = null;
111
+ /**
112
+ * Parse a single file via the worker. Returns the fully pre-computed
113
+ * ExtractorOutput, or `null` if the worker crashed on this file or
114
+ * reported a soft error.
115
+ */
116
+ parse(filePath, code, opts) {
117
+ if (this.disposed)
118
+ return Promise.resolve(null);
119
+ if (this.crashedFiles.has(filePath))
120
+ return Promise.resolve(null);
121
+ return new Promise((resolve) => {
122
+ const job = {
123
+ id: this.nextId++,
124
+ filePath,
125
+ code,
126
+ opts,
127
+ resolve,
128
+ timeoutHandle: null,
129
+ };
130
+ this.queue.push(job);
131
+ this.pump();
132
+ });
133
+ }
134
+ /** Terminate the worker and drain pending jobs with null results. */
135
+ async dispose() {
136
+ this.disposed = true;
137
+ const pending = this.queue.splice(0);
138
+ const inFlight = this.inFlight;
139
+ this.inFlight = null;
140
+ this.timedOutJobId = null;
141
+ for (const j of pending)
142
+ j.resolve(null);
143
+ if (inFlight) {
144
+ if (inFlight.timeoutHandle)
145
+ clearTimeout(inFlight.timeoutHandle);
146
+ inFlight.resolve(null);
147
+ }
148
+ if (this.worker) {
149
+ try {
150
+ await this.worker.terminate();
151
+ }
152
+ catch (e) {
153
+ debug(`WasmWorkerPool dispose: terminate failed: ${e.message}`);
154
+ }
155
+ this.worker = null;
156
+ }
157
+ }
158
+ pump() {
159
+ if (this.disposed)
160
+ return;
161
+ if (this.inFlight)
162
+ return;
163
+ const next = this.queue.shift();
164
+ if (!next)
165
+ return;
166
+ this.inFlight = next;
167
+ const worker = this.ensureWorker();
168
+ const req = {
169
+ type: 'parse',
170
+ id: next.id,
171
+ filePath: next.filePath,
172
+ code: next.code,
173
+ opts: next.opts,
174
+ };
175
+ // Arm the hang watchdog BEFORE posting so we can't race a fast reply.
176
+ next.timeoutHandle = setTimeout(() => this.onTimeout(next.id), WORKER_PARSE_TIMEOUT_MS);
177
+ worker.postMessage(req);
178
+ }
179
+ /**
180
+ * Called when the per-job watchdog fires. Terminate the worker so the
181
+ * hang stops consuming CPU; `onExit` will then resolve the in-flight job
182
+ * with `null` and blacklist the file via `crashedFiles`.
183
+ */
184
+ onTimeout(jobId) {
185
+ const job = this.inFlight;
186
+ if (!job || job.id !== jobId)
187
+ return; // already resolved
188
+ warn(`WASM worker parse timed out after ${WORKER_PARSE_TIMEOUT_MS}ms on ${job.filePath} — terminating worker and skipping file`);
189
+ this.crashedFiles.add(job.filePath);
190
+ // Record which job we're terminating so onExit can distinguish this
191
+ // terminate-induced exit from a crash on a different (innocent) job that
192
+ // got pumped in between — see `timedOutJobId` field comment.
193
+ this.timedOutJobId = jobId;
194
+ const w = this.worker;
195
+ if (w) {
196
+ w.terminate().catch((e) => {
197
+ debug(`WasmWorkerPool onTimeout: terminate failed: ${e.message}`);
198
+ });
199
+ // onExit will fire and clean up `inFlight` + resolve the job.
200
+ }
201
+ }
202
+ ensureWorker() {
203
+ if (this.worker)
204
+ return this.worker;
205
+ const w = new Worker(resolveWorkerEntry());
206
+ this.worker = w;
207
+ w.on('message', (msg) => this.onMessage(msg));
208
+ w.on('error', (err) => this.onError(err));
209
+ w.on('exit', (code) => this.onExit(code));
210
+ return w;
211
+ }
212
+ onMessage(msg) {
213
+ const job = this.inFlight;
214
+ if (!job || job.id !== msg.id) {
215
+ debug(`WasmWorkerPool: stale or unmatched response id=${msg.id}`);
216
+ return;
217
+ }
218
+ if (job.timeoutHandle) {
219
+ clearTimeout(job.timeoutHandle);
220
+ job.timeoutHandle = null;
221
+ }
222
+ // If a terminate() is pending for this same job (response + timeout raced
223
+ // in the same loop tick — timers fire before poll-phase I/O), delay
224
+ // pumping the next job until `onExit` runs. Otherwise the upcoming exit
225
+ // would land on an innocent follow-up job. `onExit` clears
226
+ // `timedOutJobId` and calls pump() itself once the worker is fully gone.
227
+ const terminatePending = this.timedOutJobId === job.id;
228
+ this.inFlight = null;
229
+ if (msg.ok) {
230
+ job.resolve(deserializeResult(msg.result));
231
+ }
232
+ else {
233
+ warn(`WASM worker soft error on ${job.filePath}: ${msg.error}`);
234
+ job.resolve(null);
235
+ }
236
+ if (!terminatePending)
237
+ this.pump();
238
+ }
239
+ onError(err) {
240
+ // 'error' fires for uncaught exceptions inside the worker — not always fatal
241
+ // (Node may still follow with 'exit'). Log and let 'exit' handle cleanup.
242
+ const msg = err instanceof Error ? err.message : String(err);
243
+ debug(`WASM worker 'error' event: ${msg}`);
244
+ }
245
+ onExit(code) {
246
+ const crashed = this.inFlight;
247
+ this.worker = null;
248
+ const timedOutJobId = this.timedOutJobId;
249
+ this.timedOutJobId = null;
250
+ if (!crashed) {
251
+ // Clean exit with no in-flight job — e.g. shutdown, or the race where
252
+ // `onMessage` already resolved the timed-out job (and deferred pump()
253
+ // because a terminate was in flight). Nothing to crash; just pump the
254
+ // queue so any waiting jobs get dispatched on a fresh worker.
255
+ if (code !== 0) {
256
+ debug(`WASM worker exited with code ${code}, no job in flight`);
257
+ }
258
+ if (timedOutJobId !== null)
259
+ this.pump();
260
+ return;
261
+ }
262
+ if (timedOutJobId !== null && crashed.id !== timedOutJobId) {
263
+ // Defensive: a terminate() we issued for a different (earlier) job is
264
+ // what triggered this exit, but somehow an innocent follow-up job ended
265
+ // up in-flight. `onMessage` normally defers pumping when a terminate is
266
+ // pending, so this path should not trigger — but if it does, re-queue
267
+ // the follow-up rather than silently discarding a valid parse.
268
+ if (crashed.timeoutHandle) {
269
+ clearTimeout(crashed.timeoutHandle);
270
+ crashed.timeoutHandle = null;
271
+ }
272
+ this.inFlight = null;
273
+ this.queue.unshift(crashed);
274
+ this.pump();
275
+ return;
276
+ }
277
+ if (crashed.timeoutHandle) {
278
+ clearTimeout(crashed.timeoutHandle);
279
+ crashed.timeoutHandle = null;
280
+ }
281
+ this.inFlight = null;
282
+ if (code === 0) {
283
+ // Clean exit mid-job — could be our own terminate() from onTimeout,
284
+ // or an unexpected worker shutdown. In either case the file is
285
+ // skipped (crashedFiles was already set in onTimeout if that was the cause).
286
+ warn(`WASM worker exited cleanly mid-job on ${crashed.filePath} — skipping`);
287
+ }
288
+ else {
289
+ warn(`WASM worker crashed (exit ${code}) parsing ${crashed.filePath} — skipping file and restarting worker`);
290
+ }
291
+ this.crashedFiles.add(crashed.filePath);
292
+ crashed.resolve(null);
293
+ // Respawn lazily on the next pump()
294
+ this.pump();
295
+ }
296
+ }
297
+ let _sharedPool = null;
298
+ /** Shared pool instance for the process. Callers share the worker across builds. */
299
+ export function getWasmWorkerPool() {
300
+ if (!_sharedPool)
301
+ _sharedPool = new WasmWorkerPool();
302
+ return _sharedPool;
303
+ }
304
+ /** Dispose the shared pool (used by tests + `disposeParsers`). */
305
+ export async function disposeWasmWorkerPool() {
306
+ if (!_sharedPool)
307
+ return;
308
+ const p = _sharedPool;
309
+ _sharedPool = null;
310
+ await p.dispose();
311
+ }
312
+ //# sourceMappingURL=wasm-worker-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm-worker-pool.js","sourceRoot":"","sources":["../../src/domain/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QAAQ,aAAa,CAAC,CAAC;QAC/E,CAAC;aAAM,CAAC;YACN,IAAI,CACF,6BAA6B,IAAI,aAAa,OAAO,CAAC,QAAQ,wCAAwC,CACvG,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtB,oCAAoC;QACpC,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;CACF;AAED,IAAI,WAAW,GAA0B,IAAI,CAAC;AAE9C,oFAAoF;AACpF,MAAM,UAAU,iBAAiB;IAC/B,IAAI,CAAC,WAAW;QAAE,WAAW,GAAG,IAAI,cAAc,EAAE,CAAC;IACrD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,IAAI,CAAC,WAAW;QAAE,OAAO;IACzB,MAAM,CAAC,GAAG,WAAW,CAAC;IACtB,WAAW,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AACpB,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Message protocol between the main thread and the WASM parse worker.
3
+ *
4
+ * The worker owns every tree-sitter WASM call. Fatal V8 aborts from the
5
+ * grammar (#965) kill only the worker — the main thread respawns it and
6
+ * skips the file that crashed.
7
+ *
8
+ * The worker returns fully pre-computed ExtractorOutput — matching what the
9
+ * native engine's parseFilesFull emits — so the main thread never holds a
10
+ * live Tree. The `_tree` field is never populated by this pipeline.
11
+ */
12
+ import type { Call, ClassRelation, DataflowResult, Definition, Export, Import, LanguageId, TypeMapEntry } from '../types.js';
13
+ export interface WorkerAnalysisOpts {
14
+ ast: boolean;
15
+ complexity: boolean;
16
+ cfg: boolean;
17
+ dataflow: boolean;
18
+ }
19
+ export interface WorkerParseRequest {
20
+ type: 'parse';
21
+ id: number;
22
+ filePath: string;
23
+ code: string;
24
+ opts: WorkerAnalysisOpts;
25
+ }
26
+ export type WorkerRequest = WorkerParseRequest;
27
+ /**
28
+ * Serialized ExtractorOutput shape. Identical to ExtractorOutput except:
29
+ * - `_tree` is never set (cannot cross worker boundary).
30
+ * - `typeMap` is encoded as an array of [key, value] tuples. Structured
31
+ * clone supports Map natively in Node 22, but the tuple form keeps the
32
+ * wire format language-agnostic and matches the native engine's form.
33
+ */
34
+ export interface SerializedExtractorOutput {
35
+ definitions: Definition[];
36
+ calls: Call[];
37
+ imports: Import[];
38
+ classes: ClassRelation[];
39
+ exports: Export[];
40
+ typeMap: Array<[string, TypeMapEntry]>;
41
+ _langId?: LanguageId;
42
+ _lineCount?: number;
43
+ dataflow?: DataflowResult;
44
+ astNodes?: Array<{
45
+ line: number;
46
+ kind: string;
47
+ name: string;
48
+ text?: string;
49
+ receiver?: string;
50
+ }>;
51
+ }
52
+ export interface WorkerParseResponseOk {
53
+ type: 'result';
54
+ id: number;
55
+ ok: true;
56
+ result: SerializedExtractorOutput | null;
57
+ }
58
+ export interface WorkerParseResponseErr {
59
+ type: 'result';
60
+ id: number;
61
+ ok: false;
62
+ error: string;
63
+ }
64
+ export type WorkerResponse = WorkerParseResponseOk | WorkerParseResponseErr;
65
+ //# sourceMappingURL=wasm-worker-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm-worker-protocol.d.ts","sourceRoot":"","sources":["../../src/domain/wasm-worker-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,UAAU,EACV,MAAM,EACN,MAAM,EACN,UAAU,EACV,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WA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1
+ /**
2
+ * Message protocol between the main thread and the WASM parse worker.
3
+ *
4
+ * The worker owns every tree-sitter WASM call. Fatal V8 aborts from the
5
+ * grammar (#965) kill only the worker — the main thread respawns it and
6
+ * skips the file that crashed.
7
+ *
8
+ * The worker returns fully pre-computed ExtractorOutput — matching what the
9
+ * native engine's parseFilesFull emits — so the main thread never holds a
10
+ * live Tree. The `_tree` field is never populated by this pipeline.
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=wasm-worker-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm-worker-protocol.js","sourceRoot":"","sources":["../../src/domain/wasm-worker-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}