pi-lens 4.4.3 → 4.4.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 (185) hide show
  1. package/CHANGELOG.md +721 -0
  2. package/README.md +25 -3
  3. package/config/dependency-cruiser-eager-allowlist.json +1 -0
  4. package/dist/chunk-22Y2BM7H.js +23 -0
  5. package/dist/{chunk-WU567RSC.js → chunk-27VWVB23.js} +16 -14
  6. package/dist/{chunk-FLKWCIZH.js → chunk-2FYKETQJ.js} +10 -6
  7. package/dist/{chunk-MQLUAEOC.js → chunk-2LDMXL2M.js} +2 -2
  8. package/dist/{chunk-YSZNHOBY.js → chunk-2SDHYHHO.js} +17 -17
  9. package/dist/chunk-2Y6OJRSI.js +38 -0
  10. package/dist/chunk-3SNDVPOR.js +507 -0
  11. package/dist/{chunk-EJIUXPBX.js → chunk-3WCEHYOI.js} +1 -1
  12. package/dist/chunk-44X7VIKR.js +73 -0
  13. package/dist/{chunk-Q7DUK4LX.js → chunk-4FHUGDKU.js} +16 -14
  14. package/dist/{chunk-H6MF6EVN.js → chunk-4ODSZ35Z.js} +1498 -534
  15. package/dist/{chunk-ZGDGW2V3.js → chunk-4U7GDSZQ.js} +2 -2
  16. package/dist/chunk-54NIOJJZ.js +25 -0
  17. package/dist/{chunk-ZWFS3OEF.js → chunk-5DKE4HGX.js} +38 -37
  18. package/dist/{chunk-VRZP76YM.js → chunk-5LRUKYFA.js} +34 -4
  19. package/dist/{chunk-QOBUHWHX.js → chunk-63NMUNYP.js} +12 -16
  20. package/dist/{chunk-VWCXW2E7.js → chunk-6XSESGWD.js} +13 -6
  21. package/dist/{chunk-QGQ5CCCG.js → chunk-72J27ICO.js} +2 -3
  22. package/dist/{chunk-CSHFH5IN.js → chunk-7FLRUH6B.js} +1 -1
  23. package/dist/chunk-7IYC4ENJ.js +297 -0
  24. package/dist/chunk-7WWQAW5P.js +30 -0
  25. package/dist/{chunk-EU63SDCG.js → chunk-7ZS7MC24.js} +885 -451
  26. package/dist/{chunk-KBG47GHP.js → chunk-AHWA4AKM.js} +18 -12
  27. package/dist/{chunk-FMSO6RDZ.js → chunk-AI3GP74G.js} +17 -19
  28. package/dist/chunk-APFJKOP6.js +67 -0
  29. package/dist/{chunk-RXCOMYPY.js → chunk-ASRAO7KG.js} +31 -33
  30. package/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
  31. package/dist/{chunk-QILIYSJF.js → chunk-CG5V25HX.js} +1 -1
  32. package/dist/chunk-CKEQFGLT.js +32 -0
  33. package/dist/{chunk-RPLINGVB.js → chunk-COOUUC5W.js} +6 -6
  34. package/dist/{chunk-GBPP5P7X.js → chunk-CPZ5JJW6.js} +4 -4
  35. package/dist/{chunk-OCAGUNBC.js → chunk-DS2USX5G.js} +13 -15
  36. package/dist/chunk-EA2ZRG44.js +27 -0
  37. package/dist/{chunk-ZHFZWTZV.js → chunk-EDMLIW6W.js} +13 -14
  38. package/dist/{chunk-2EECBNC5.js → chunk-EIKRZ32J.js} +75 -0
  39. package/dist/chunk-EKNWOL2I.js +27 -0
  40. package/dist/{chunk-CMMHNUZ2.js → chunk-ELZRSR5N.js} +65 -43
  41. package/dist/{chunk-BKE7E7TC.js → chunk-EN5AM7PX.js} +11 -12
  42. package/dist/{chunk-N2H3ZPZY.js → chunk-EWXXLS26.js} +227 -24
  43. package/dist/chunk-EX4EXBW7.js +37 -0
  44. package/dist/{chunk-YYOIQFRS.js → chunk-EXVXBSGN.js} +130 -52
  45. package/dist/{chunk-6GFRNVYR.js → chunk-F7BO6FWH.js} +12 -13
  46. package/dist/chunk-FEDWAYDS.js +2485 -0
  47. package/dist/{chunk-JAU72XNY.js → chunk-FWZRGGGY.js} +73 -9
  48. package/dist/{chunk-GXW6K4YJ.js → chunk-G224FADB.js} +1 -1
  49. package/dist/chunk-G5UCJFT7.js +26 -0
  50. package/dist/{chunk-67WMNWEE.js → chunk-GLW3YDZZ.js} +22 -13
  51. package/dist/{chunk-724UL2TJ.js → chunk-GTDSYEA2.js} +72 -39
  52. package/dist/{chunk-PHDMFAKM.js → chunk-GYRZ72R4.js} +10 -4
  53. package/dist/chunk-HYVXA3BB.js +49 -0
  54. package/dist/{chunk-SAEFPSB6.js → chunk-IEBJF3PN.js} +23 -15
  55. package/dist/chunk-IJYGIDF4.js +186 -0
  56. package/dist/{chunk-ACXEQZOU.js → chunk-IL7K66ZQ.js} +101 -109
  57. package/dist/{chunk-ZXYDQ3TZ.js → chunk-JWOVP5BL.js} +50 -19
  58. package/dist/{chunk-OXXKQCSV.js → chunk-K2GUZ4DN.js} +4 -4
  59. package/dist/{chunk-AW7R2GWG.js → chunk-K4SZB56V.js} +39 -39
  60. package/dist/{chunk-WOA4LN2R.js → chunk-KCBRHV5E.js} +3 -3
  61. package/dist/{chunk-3W7IEVVL.js → chunk-KFXCL4OV.js} +47 -45
  62. package/dist/{chunk-2BBLFX75.js → chunk-KJJAVH3X.js} +81 -15
  63. package/dist/{chunk-VCHXCQFG.js → chunk-KPVLQHCZ.js} +4 -6
  64. package/dist/{chunk-P7266HLM.js → chunk-KX56K73G.js} +10 -13
  65. package/dist/{chunk-VSSBEUFT.js → chunk-LMCTHJ2H.js} +19 -19
  66. package/dist/{chunk-IBGIOBEE.js → chunk-MEFLGBCS.js} +69 -8
  67. package/dist/{chunk-TYM6OUIT.js → chunk-MKPCELNI.js} +17 -17
  68. package/dist/{chunk-XTMJ7XDT.js → chunk-N3PLNNCW.js} +1 -1
  69. package/dist/chunk-N5FBM25N.js +22 -0
  70. package/dist/{chunk-CHOW74WE.js → chunk-NFNVDDGB.js} +7 -12
  71. package/dist/{chunk-52FUZI6K.js → chunk-NLIVE7L6.js} +2 -30
  72. package/dist/{chunk-SS36ZX4J.js → chunk-OMJ3OFBJ.js} +6 -6
  73. package/dist/{chunk-4W4VLAPJ.js → chunk-OZNCKLOX.js} +13 -14
  74. package/dist/chunk-P5XUGPIX.js +31 -0
  75. package/dist/{chunk-5UCAH366.js → chunk-PJXNTPB2.js} +253 -33
  76. package/dist/chunk-PKOXJIVT.js +88 -0
  77. package/dist/{chunk-6C7JWPCP.js → chunk-PP2A5V2T.js} +27 -26
  78. package/dist/{chunk-L3BLXZG7.js → chunk-Q42LJANT.js} +31 -70
  79. package/dist/{chunk-AB3YYG6N.js → chunk-Q4BKKOVC.js} +8 -8
  80. package/dist/{chunk-3EFKIGZN.js → chunk-QT66NEYN.js} +4 -4
  81. package/dist/{chunk-3VPVG5SU.js → chunk-RCHO5W7M.js} +19 -18
  82. package/dist/{chunk-77M37OKR.js → chunk-RG3MXTRI.js} +7 -7
  83. package/dist/chunk-RG7OODGM.js +57 -0
  84. package/dist/{chunk-T6CPIZNT.js → chunk-RU34BA4D.js} +44 -39
  85. package/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
  86. package/dist/{chunk-5NGR67U5.js → chunk-S55TEC7I.js} +33 -5
  87. package/dist/{chunk-M6HSLBWY.js → chunk-SJHC3BCZ.js} +7956 -8047
  88. package/dist/{chunk-XCJN5IJU.js → chunk-SNEUMLM7.js} +4 -4
  89. package/dist/{chunk-UZ3TUTRV.js → chunk-T4NGVFYI.js} +2 -2
  90. package/dist/{chunk-2VUQMUMT.js → chunk-THEXI2QO.js} +49 -43
  91. package/dist/{chunk-R3PCY3YS.js → chunk-TL2TCJYL.js} +15 -16
  92. package/dist/{chunk-C34ZXZ7O.js → chunk-TPYYEDP5.js} +838 -352
  93. package/dist/{chunk-AOHZU2BM.js → chunk-TVZRLTG6.js} +8 -1
  94. package/dist/{chunk-XMSXXAHW.js → chunk-UCVMSOXF.js} +2 -2
  95. package/dist/chunk-UL5SXQVX.js +32 -0
  96. package/dist/{chunk-GAEGEPOC.js → chunk-UO66IMVP.js} +2 -2
  97. package/dist/{chunk-N3X6Q4YT.js → chunk-UVY4TOJH.js} +3 -3
  98. package/dist/{chunk-2CD5RS6M.js → chunk-VIDEKABZ.js} +23 -2
  99. package/dist/{chunk-JSQFTSC6.js → chunk-VITFDI3O.js} +13 -14
  100. package/dist/{chunk-YIUAVF7E.js → chunk-VUAVE3QC.js} +42 -42
  101. package/dist/{chunk-QOZXJ4NA.js → chunk-WUY4BZEP.js} +21 -20
  102. package/dist/{chunk-VCO24T4L.js → chunk-X3UTCXAA.js} +43 -53
  103. package/dist/chunk-XHDBJODR.js +45 -0
  104. package/dist/{chunk-MXGY6KPT.js → chunk-XHLK33VM.js} +28 -21
  105. package/dist/{chunk-RWWYJ623.js → chunk-XI34NWDI.js} +2 -2
  106. package/dist/{chunk-QQNQ7SJW.js → chunk-XWFIHYCH.js} +12 -4
  107. package/dist/{chunk-6SDEP3AJ.js → chunk-Y2TPADJR.js} +10 -11
  108. package/dist/{chunk-MRXKYPCS.js → chunk-Y5KTA2OB.js} +17 -17
  109. package/dist/{chunk-7DYBLXYA.js → chunk-YKVDBNPO.js} +11 -5
  110. package/dist/{chunk-2B73ZPOK.js → chunk-YSDPVDFC.js} +3 -3
  111. package/dist/chunk-YWNO5Q4R.js +44 -0
  112. package/dist/{chunk-QHJ6DQ2R.js → chunk-YWWG4AQA.js} +165 -32
  113. package/dist/{chunk-3JNKMP3B.js → chunk-YXDCRUKQ.js} +4 -4
  114. package/dist/{chunk-UXGETRP4.js → chunk-YXGRRORB.js} +16 -17
  115. package/dist/{chunk-SQ4TVJBR.js → chunk-ZAPSUBLU.js} +13 -7
  116. package/dist/{chunk-76MWC2K6.js → chunk-ZPJM7DID.js} +90 -97
  117. package/dist/{chunk-XVF2VVXP.js → chunk-ZSUX7KEM.js} +16 -15
  118. package/dist/index.js +31038 -20893
  119. package/dist/mcp/analyze-cli.js +11 -11
  120. package/dist/mcp/cli.js +47 -43
  121. package/dist/mcp/server.js +2188 -906
  122. package/dist/mcp/worker.js +66 -63
  123. package/dist/probes/installer.js +21 -23
  124. package/dist/workers/project-snapshot-persist-worker.js +28 -9
  125. package/dist/workers/review-graph-persist-worker.js +1 -1
  126. package/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
  127. package/docs/adr/README.md +1 -0
  128. package/docs/ast-grep_rules_catalog.md +5 -3
  129. package/docs/configuration.md +20 -0
  130. package/docs/engineering-principles.md +44 -0
  131. package/docs/environment-variables.md +20 -0
  132. package/docs/features.md +16 -1
  133. package/docs/globalconfig.md +37 -8
  134. package/docs/lsp-capability-matrix.md +105 -12
  135. package/docs/lsp-idle-eviction.md +44 -36
  136. package/docs/pi-lens-fixer.md +139 -14
  137. package/docs/pi-lens-investigator.md +14 -0
  138. package/docs/pi-lens-merge-policy.md +120 -17
  139. package/docs/pi-lens-monitor.md +71 -9
  140. package/docs/pi-lens-retro.md +6 -3
  141. package/docs/pi-lens-reviewer.md +160 -5
  142. package/docs/pi-lens-subagent.md +29 -14
  143. package/docs/release-qa-baseline.md +21 -7
  144. package/docs/servercapabilities.md +53 -63
  145. package/docs/settings.md +9 -5
  146. package/docs/subagent-compat.md +1 -1
  147. package/docs/usage.md +1 -0
  148. package/package.json +9 -5
  149. package/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
  150. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
  151. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
  152. package/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
  153. package/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
  154. package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
  155. package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
  156. package/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
  157. package/rules/rule-catalog.json +25 -1
  158. package/scripts/analyze-pi-lens-logs.mjs +15 -5
  159. package/scripts/download-grammars.js +40 -7
  160. package/scripts/lib/is-main-module.mjs +27 -0
  161. package/scripts/lib/latency-log-phases.mjs +95 -0
  162. package/scripts/lib/scratch-home-env.mjs +21 -0
  163. package/scripts/rpc-load-check.mjs +568 -81
  164. package/scripts/warm-loader-cache.mjs +2 -5
  165. package/dist/chunk-23WOO7TX.js +0 -23
  166. package/dist/chunk-3YN6V5TV.js +0 -85
  167. package/dist/chunk-466Z26MG.js +0 -30
  168. package/dist/chunk-4UNXBNE2.js +0 -24
  169. package/dist/chunk-6STA6Z7I.js +0 -47
  170. package/dist/chunk-ABBOA7UD.js +0 -157
  171. package/dist/chunk-BRGDSBJE.js +0 -28
  172. package/dist/chunk-EC47DWFA.js +0 -56
  173. package/dist/chunk-FCSOVF55.js +0 -273
  174. package/dist/chunk-IZSHAIJ7.js +0 -26
  175. package/dist/chunk-KDERNTCQ.js +0 -28
  176. package/dist/chunk-KSX3TXSZ.js +0 -69
  177. package/dist/chunk-LOP6GRPH.js +0 -31
  178. package/dist/chunk-PNQDPDRC.js +0 -184
  179. package/dist/chunk-UOPVJQ4N.js +0 -103
  180. package/dist/chunk-XAGLWMJ4.js +0 -51
  181. package/dist/chunk-XIJZVPD5.js +0 -39
  182. package/dist/chunk-Z3CCVDUB.js +0 -76
  183. package/dist/chunk-Z527N6YQ.js +0 -28
  184. package/dist/chunk-ZANLILYD.js +0 -79
  185. /package/dist/{chunk-FC4RP4I2.js → chunk-6HWVI6MI.js} +0 -0
@@ -3,64 +3,71 @@ import {
3
3
  buildSymbolId
4
4
  } from "./chunk-3MED75HT.js";
5
5
  import {
6
- RUNTIME_CONFIG,
7
- TreeSitterSymbolExtractor,
8
6
  buildReverseDependencyIndexFromGraph,
9
7
  getLSPService,
10
- jsTsCandidatePaths,
11
- rankFilesByReverseDependencyCentrality,
12
- resolveAliasedImport,
13
- resolveImportToFiles,
14
- resolveProjectReferenceImport,
15
- resolveWorkspacePackageImport,
16
- symbolExtractionGrammar
17
- } from "./chunk-M6HSLBWY.js";
18
- import {
19
- createGitIdentityResolver,
20
- resolveGitIdentity
21
- } from "./chunk-PNQDPDRC.js";
8
+ rankFilesByReverseDependencyCentrality
9
+ } from "./chunk-SJHC3BCZ.js";
22
10
  import {
11
+ notePersistWorkerMessageFault,
23
12
  readWorkerHeapStatistics
24
- } from "./chunk-ZXYDQ3TZ.js";
13
+ } from "./chunk-JWOVP5BL.js";
25
14
  import {
26
15
  buildQualifiedName,
27
16
  findOwnerName
28
17
  } from "./chunk-5W3R6LFT.js";
18
+ import {
19
+ RUNTIME_CONFIG,
20
+ TreeSitterSymbolExtractor,
21
+ fileAnswerNames,
22
+ importSourceNameParts,
23
+ jsTsCandidatePaths,
24
+ resolveAliasedImport,
25
+ resolveImportToFiles,
26
+ resolveProjectReferenceImport,
27
+ resolveWorkspacePackageImport,
28
+ symbolExtractionGrammar
29
+ } from "./chunk-FEDWAYDS.js";
29
30
  import {
30
31
  classifyTreeSitterWasmError,
31
32
  getSharedTreeSitterClient,
32
33
  logTreeSitterCacheStats,
33
34
  withTreeSitterRoot
34
- } from "./chunk-QHJ6DQ2R.js";
35
+ } from "./chunk-YWWG4AQA.js";
35
36
  import {
36
37
  getReviewGraphMaxFilesDerived
37
- } from "./chunk-GAEGEPOC.js";
38
+ } from "./chunk-UO66IMVP.js";
39
+ import {
40
+ readGzipStageWorkerResult,
41
+ reapStageFile
42
+ } from "./chunk-IJYGIDF4.js";
38
43
  import {
39
44
  collectSourceFilesWithBudgetAsync
40
- } from "./chunk-6C7JWPCP.js";
45
+ } from "./chunk-PP2A5V2T.js";
41
46
  import {
42
47
  collectUntrackedIgnoredIds,
48
+ createGitIdentityResolver,
43
49
  getProjectDataDir,
44
- isStaleStageFile
45
- } from "./chunk-C34ZXZ7O.js";
50
+ isStaleStageFile,
51
+ resolveGitIdentity
52
+ } from "./chunk-TPYYEDP5.js";
46
53
  import {
47
54
  KIND_EXTENSIONS,
48
55
  detectFileKind
49
- } from "./chunk-PHDMFAKM.js";
56
+ } from "./chunk-GYRZ72R4.js";
50
57
  import {
51
58
  detectFileRole
52
- } from "./chunk-2BBLFX75.js";
59
+ } from "./chunk-KJJAVH3X.js";
53
60
  import {
54
61
  writeFileAtomic
55
- } from "./chunk-2EECBNC5.js";
62
+ } from "./chunk-EIKRZ32J.js";
56
63
  import {
57
64
  compareOrdinal,
58
65
  escapeRegExp,
59
66
  incrementDegradationCount
60
- } from "./chunk-JAU72XNY.js";
67
+ } from "./chunk-FWZRGGGY.js";
61
68
  import {
62
69
  logLatency
63
- } from "./chunk-QQNQ7SJW.js";
70
+ } from "./chunk-XWFIHYCH.js";
64
71
  import {
65
72
  createNdjsonLogger,
66
73
  getGlobalPiLensLogDir,
@@ -68,21 +75,19 @@ import {
68
75
  getTurnId,
69
76
  isTestMode,
70
77
  lazyEnvNumber
71
- } from "./chunk-AOHZU2BM.js";
78
+ } from "./chunk-TVZRLTG6.js";
72
79
  import {
73
80
  FactStore
74
- } from "./chunk-CHOW74WE.js";
81
+ } from "./chunk-NFNVDDGB.js";
75
82
  import {
76
83
  BoundedFifoMap,
77
- BoundedLruCache
78
- } from "./chunk-ABBOA7UD.js";
79
- import {
84
+ BoundedLruCache,
80
85
  isAtOrAboveHomeDir,
81
86
  isUnderDir,
82
87
  normalizeFilePath,
83
88
  normalizeMapKey,
84
89
  toProjectRelativePath
85
- } from "./chunk-N2H3ZPZY.js";
90
+ } from "./chunk-EWXXLS26.js";
86
91
 
87
92
  // dist/clients/review-graph/builder.js
88
93
  import { createHash as createHash2 } from "node:crypto";
@@ -414,6 +419,9 @@ function normalizeGraphSourcePath(memo, raw) {
414
419
  memo.normalizeCalls.value++;
415
420
  return normalized;
416
421
  }
422
+ function _resetReviewGraphExtractorCacheForTests() {
423
+ extractorCache.clear();
424
+ }
417
425
  function _resetReviewGraphSourcePathMemoForTests() {
418
426
  _sourcePathMemos.clear();
419
427
  }
@@ -1046,7 +1054,8 @@ async function getGraphSourceFiles(cwd) {
1046
1054
  const sourceMemo = sourcePathMemo(cwd);
1047
1055
  const normalizeCallsBefore = sourceMemo.normalizeCalls.value;
1048
1056
  const maxGraphFiles = getReviewGraphMaxFiles(cwd);
1049
- const { files: collected, entryBudgetExceeded } = await collectProjectSourceFilesWithBudgetAsync(cwd, {
1057
+ const walkStartedAt = Date.now();
1058
+ const { files: collected, entryBudgetExceeded, entriesVisited } = await collectProjectSourceFilesWithBudgetAsync(cwd, {
1050
1059
  // Only walk graph-relevant extensions so the cap counts what the graph
1051
1060
  // keeps (post-filter), not JSON/YAML/MD noise it would discard anyway.
1052
1061
  extensions: MAIN_KIND_EXTENSIONS,
@@ -1054,6 +1063,7 @@ async function getGraphSourceFiles(cwd) {
1054
1063
  ..._reviewGraphEntryBudgetForTests === void 0 ? {} : { maxScanEntries: _reviewGraphEntryBudgetForTests },
1055
1064
  ..._reviewGraphEntryCounterForTests === void 0 ? {} : { onEntryVisited: _reviewGraphEntryCounterForTests }
1056
1065
  });
1066
+ const walkMs = Date.now() - walkStartedAt;
1057
1067
  if (entryBudgetExceeded) {
1058
1068
  logLatency({
1059
1069
  type: "phase",
@@ -1069,7 +1079,9 @@ async function getGraphSourceFiles(cwd) {
1069
1079
  pathNormalizeCalls: sourceMemo.normalizeCalls.value - normalizeCallsBefore,
1070
1080
  sourceFileCount: collected.length,
1071
1081
  maxFileCount: maxGraphFiles,
1072
- entryBudgetExceeded
1082
+ entryBudgetExceeded,
1083
+ entriesVisited,
1084
+ walkMs
1073
1085
  };
1074
1086
  }
1075
1087
  const result = [];
@@ -1090,7 +1102,9 @@ async function getGraphSourceFiles(cwd) {
1090
1102
  pathNormalizeCalls: sourceMemo.normalizeCalls.value - normalizeCallsBefore,
1091
1103
  sourceFileCount: result.length,
1092
1104
  maxFileCount: maxGraphFiles,
1093
- entryBudgetExceeded
1105
+ entryBudgetExceeded,
1106
+ entriesVisited,
1107
+ walkMs
1094
1108
  };
1095
1109
  }
1096
1110
  function addNode(graph, node) {
@@ -1546,6 +1560,18 @@ function writePendingOnMainThread(key, pending, reason, workerState = { started:
1546
1560
  recordPersistFailure(key, "cache_write_failed", message, pending, workerState);
1547
1561
  }
1548
1562
  }
1563
+ function handleWorkerMessage(message) {
1564
+ try {
1565
+ const result = readGzipStageWorkerResult(message);
1566
+ if (typeof result === "string") {
1567
+ notePersistWorkerMessageFault("review-graph", "rejected", result);
1568
+ return;
1569
+ }
1570
+ handleWorkerResult(result);
1571
+ } catch (err) {
1572
+ notePersistWorkerMessageFault("review-graph", "threw", err);
1573
+ }
1574
+ }
1549
1575
  function handleWorkerResult(result) {
1550
1576
  const checkpoint = _checkpointWorkerRequests.get(result.id);
1551
1577
  if (checkpoint) {
@@ -1554,17 +1580,18 @@ function handleWorkerResult(result) {
1554
1580
  }
1555
1581
  const request = _workerRequests.get(result.id);
1556
1582
  if (!request) {
1557
- fs2.rm(result.stagePath, { force: true }, () => {
1558
- });
1583
+ if (typeof result.stagePath === "string") {
1584
+ fs2.rm(result.stagePath, { force: true }, () => {
1585
+ });
1586
+ }
1559
1587
  return;
1560
1588
  }
1561
1589
  _workerRequests.delete(result.id);
1562
1590
  const { key, pending } = request;
1563
1591
  const currentGeneration = _persistGenerations.get(key);
1564
1592
  if (currentGeneration !== result.generation) {
1565
- try {
1566
- fs2.rmSync(result.stagePath, { force: true });
1567
- } catch (reapErr) {
1593
+ const reapErr = reapStageFile(request.stagePath);
1594
+ if (reapErr !== void 0) {
1568
1595
  logReviewGraph({
1569
1596
  cwd: key,
1570
1597
  phase: "persist_failed",
@@ -1586,7 +1613,7 @@ function handleWorkerResult(result) {
1586
1613
  return;
1587
1614
  }
1588
1615
  if (result.error || result.rawBytes === void 0 || result.gzBytes === void 0 || result.serializeMs === void 0 || result.writeMs === void 0 || result.durationMs === void 0) {
1589
- fs2.rm(result.stagePath, { force: true }, () => {
1616
+ fs2.rm(request.stagePath, { force: true }, () => {
1590
1617
  });
1591
1618
  writePendingOnMainThread(key, pending, result.error ?? "invalid worker result", {
1592
1619
  started: true,
@@ -1596,7 +1623,7 @@ function handleWorkerResult(result) {
1596
1623
  return;
1597
1624
  }
1598
1625
  try {
1599
- fs2.renameSync(result.stagePath, pending.cachePath);
1626
+ fs2.renameSync(request.stagePath, pending.cachePath);
1600
1627
  fs2.rmSync(path2.join(pending.cacheDir, LEGACY_GRAPH_CACHE_FILENAME), {
1601
1628
  force: true
1602
1629
  });
@@ -1609,7 +1636,7 @@ function handleWorkerResult(result) {
1609
1636
  offloaded: true
1610
1637
  }, { started: true, completed: true });
1611
1638
  } catch (err) {
1612
- fs2.rm(result.stagePath, { force: true }, () => {
1639
+ fs2.rm(request.stagePath, { force: true }, () => {
1613
1640
  });
1614
1641
  writePendingOnMainThread(key, pending, err instanceof Error ? err.message : String(err), {
1615
1642
  started: true,
@@ -1627,17 +1654,17 @@ function handleCheckpointWorkerResult(cp, result) {
1627
1654
  reason: "worker_error",
1628
1655
  error: result.error ?? "worker returned no gz metrics"
1629
1656
  });
1630
- fs2.rm(result.stagePath, { force: true }, () => {
1657
+ fs2.rm(cp.stagePath, { force: true }, () => {
1631
1658
  });
1632
1659
  return;
1633
1660
  }
1634
1661
  if (_checkpointGenerations.get(cp.cwd) !== cp.generation) {
1635
- fs2.rm(result.stagePath, { force: true }, () => {
1662
+ fs2.rm(cp.stagePath, { force: true }, () => {
1636
1663
  });
1637
1664
  return;
1638
1665
  }
1639
1666
  try {
1640
- fs2.renameSync(result.stagePath, cp.checkpointPath);
1667
+ fs2.renameSync(cp.stagePath, cp.checkpointPath);
1641
1668
  logReviewGraph({
1642
1669
  cwd: cp.cwd,
1643
1670
  phase: "checkpoint_written",
@@ -1654,7 +1681,7 @@ function handleCheckpointWorkerResult(cp, result) {
1654
1681
  reason: "promote_failed",
1655
1682
  error: err instanceof Error ? err.message : String(err)
1656
1683
  });
1657
- fs2.rm(result.stagePath, { force: true }, () => {
1684
+ fs2.rm(cp.stagePath, { force: true }, () => {
1658
1685
  });
1659
1686
  }
1660
1687
  }
@@ -1728,7 +1755,7 @@ function getPersistWorker() {
1728
1755
  return void 0;
1729
1756
  }
1730
1757
  const worker = new Worker(workerPath);
1731
- worker.on("message", handleWorkerResult);
1758
+ worker.on("message", handleWorkerMessage);
1732
1759
  worker.on("error", (err) => handleWorkerDeath(err.message));
1733
1760
  worker.on("exit", (code) => {
1734
1761
  if (_persistWorker !== worker)
@@ -1780,7 +1807,7 @@ function writePending(key) {
1780
1807
  elements: pending.elementCount,
1781
1808
  testDelayMs: process.env.NODE_ENV === "test" ? Number(process.env.PI_LENS_TEST_PERSIST_WORKER_DELAY_MS) || void 0 : void 0
1782
1809
  };
1783
- _workerRequests.set(id, { key, pending });
1810
+ _workerRequests.set(id, { key, pending, stagePath });
1784
1811
  worker.postMessage(request);
1785
1812
  }
1786
1813
  var _persistExitHookInstalled = false;
@@ -2451,8 +2478,8 @@ async function ensureReviewGraphFacts(filePath, cwd, facts, contentOverride) {
2451
2478
  }
2452
2479
  try {
2453
2480
  const [{ importFactProvider }, { functionFactProvider }] = await Promise.all([
2454
- import("./chunk-466Z26MG.js"),
2455
- import("./chunk-LOP6GRPH.js")
2481
+ import("./chunk-7WWQAW5P.js"),
2482
+ import("./chunk-P5XUGPIX.js")
2456
2483
  ]);
2457
2484
  await importFactProvider.run(ctx, facts);
2458
2485
  await functionFactProvider.run(ctx, facts);
@@ -3131,7 +3158,8 @@ var _rebuildCounters = {
3131
3158
  restoreComparisons: 0,
3132
3159
  importTargetEdgeScans: 0,
3133
3160
  removeOwnedEdgeVisits: 0,
3134
- removeOwnedEdgePositions: 0
3161
+ removeOwnedEdgePositions: 0,
3162
+ createdImportResolutions: 0
3135
3163
  };
3136
3164
  function _getReviewGraphRebuildCountersForTests() {
3137
3165
  return { ..._rebuildCounters };
@@ -3141,6 +3169,7 @@ function _resetReviewGraphRebuildCountersForTests() {
3141
3169
  _rebuildCounters.importTargetEdgeScans = 0;
3142
3170
  _rebuildCounters.removeOwnedEdgeVisits = 0;
3143
3171
  _rebuildCounters.removeOwnedEdgePositions = 0;
3172
+ _rebuildCounters.createdImportResolutions = 0;
3144
3173
  }
3145
3174
  function edgeIdentityKey(edge) {
3146
3175
  _rebuildCounters.restoreComparisons++;
@@ -3213,6 +3242,34 @@ function importTargetsForFile(graph, filePath) {
3213
3242
  }
3214
3243
  return [...targets].sort((a, b) => compareOrdinal(a, b));
3215
3244
  }
3245
+ function importersResolvingTo(graph, cwd, created, ignoredIds) {
3246
+ const names = new Set([...created].flatMap(fileAnswerNames));
3247
+ const importers = /* @__PURE__ */ new Set();
3248
+ for (const node of graph.nodes.values()) {
3249
+ if (node.kind !== "module" && node.kind !== "external")
3250
+ continue;
3251
+ const source = node.metadata?.source;
3252
+ if (typeof source !== "string")
3253
+ continue;
3254
+ if (!importSourceNameParts(source).some((part) => names.has(part))) {
3255
+ continue;
3256
+ }
3257
+ for (const edge of graph.edgesByTo.get(node.id) ?? []) {
3258
+ if (edge.kind !== "imports")
3259
+ continue;
3260
+ const importer = graph.nodes.get(edge.from);
3261
+ const importerPath = importer?.filePath;
3262
+ if (!importer || !importerPath || importers.has(importerPath))
3263
+ continue;
3264
+ _rebuildCounters.createdImportResolutions++;
3265
+ const targets = importer.language === "jsts" ? [localImportToFile(cwd, importerPath, source, ignoredIds)] : resolveImportToFiles(cwd, importerPath, importer.language ?? "", source);
3266
+ if (targets.some((target) => target !== void 0 && !ignoredIds?.has(target) && created.has(normalizeMapKey(target)))) {
3267
+ importers.add(importerPath);
3268
+ }
3269
+ }
3270
+ }
3271
+ return [...importers];
3272
+ }
3216
3273
  async function updateGraphFiles(graph, cwd, files, facts, ignoredIds) {
3217
3274
  rebuildIndexes(graph);
3218
3275
  const prior = files.map((file) => ({
@@ -3226,6 +3283,22 @@ async function updateGraphFiles(graph, cwd, files, facts, ignoredIds) {
3226
3283
  preservedIncoming.push(...removeFileOwnedGraphData(graph, file, removedEdges));
3227
3284
  await addFileToGraph(graph, cwd, file, ignoredIds);
3228
3285
  }
3286
+ const created = new Set(prior.filter((entry) => !entry.existedBefore).map((entry) => entry.filePath).filter((file) => graph.fileNodes.has(file)));
3287
+ if (created.size > 0) {
3288
+ const batch = new Set(prior.map((entry) => entry.filePath));
3289
+ for (const importer of importersResolvingTo(graph, cwd, created, ignoredIds)) {
3290
+ if (batch.has(importer))
3291
+ continue;
3292
+ batch.add(importer);
3293
+ prior.push({
3294
+ filePath: importer,
3295
+ existedBefore: true,
3296
+ priorTargets: importTargetsForFile(graph, importer)
3297
+ });
3298
+ preservedIncoming.push(...removeFileOwnedGraphData(graph, importer, removedEdges));
3299
+ await addFileToGraph(graph, cwd, importer, ignoredIds);
3300
+ }
3301
+ }
3229
3302
  if (removedEdges.size > 0) {
3230
3303
  unindexEdges(graph, removedEdges);
3231
3304
  graph.edges = graph.edges.filter((edge) => !removedEdges.has(edge));
@@ -3581,7 +3654,11 @@ async function _doBuildGraph(cwd, changedFiles, facts, seqHint, buildId) {
3581
3654
  sourceFileCount,
3582
3655
  maxFileCount: maxGraphFiles,
3583
3656
  sourceFileCountLabel: `more than ${maxGraphFiles} files`,
3584
- sourceFileCountTruncated: true
3657
+ sourceFileCountTruncated: true,
3658
+ // #1979: the walk's interior, so a slow over-cap first build reads as
3659
+ // many ms per entry (cold filesystem) or many entries (big tree).
3660
+ entriesVisited: sourceCollection.entriesVisited,
3661
+ walkMs: sourceCollection.walkMs
3585
3662
  }
3586
3663
  });
3587
3664
  if (isReviewGraphSizeNearMiss(sourceFileCount, maxGraphFiles)) {
@@ -4084,6 +4161,7 @@ export {
4084
4161
  reviewGraphIrContentHash,
4085
4162
  publishReviewGraphFileIr,
4086
4163
  REVIEW_GRAPH_VERSION,
4164
+ _resetReviewGraphExtractorCacheForTests,
4087
4165
  _resetReviewGraphSourcePathMemoForTests,
4088
4166
  graphWasmTrapDetail,
4089
4167
  getGraphBuildInfoForGraph,
@@ -1,23 +1,22 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  parseSymbolKey
4
- } from "./chunk-WOA4LN2R.js";
4
+ } from "./chunk-KCBRHV5E.js";
5
5
  import {
6
6
  isTestRoleCollateral
7
- } from "./chunk-EJIUXPBX.js";
7
+ } from "./chunk-3WCEHYOI.js";
8
8
  import "./chunk-3MED75HT.js";
9
- import "./chunk-C34ZXZ7O.js";
10
- import "./chunk-2BBLFX75.js";
11
- import "./chunk-XVF2VVXP.js";
12
- import "./chunk-2EECBNC5.js";
13
- import "./chunk-JAU72XNY.js";
14
- import "./chunk-XTMJ7XDT.js";
15
- import "./chunk-JMYYOTQG.js";
16
- import "./chunk-QQNQ7SJW.js";
17
- import "./chunk-AOHZU2BM.js";
9
+ import "./chunk-TPYYEDP5.js";
10
+ import "./chunk-KJJAVH3X.js";
11
+ import "./chunk-ZSUX7KEM.js";
12
+ import "./chunk-EIKRZ32J.js";
13
+ import "./chunk-FWZRGGGY.js";
14
+ import "./chunk-N3PLNNCW.js";
15
+ import "./chunk-S26LC76R.js";
16
+ import "./chunk-XWFIHYCH.js";
17
+ import "./chunk-TVZRLTG6.js";
18
18
  import "./chunk-LJDODBBZ.js";
19
- import "./chunk-ABBOA7UD.js";
20
- import "./chunk-N2H3ZPZY.js";
19
+ import "./chunk-EWXXLS26.js";
21
20
  import "./chunk-NXL4FFQQ.js";
22
21
 
23
22
  // dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js