@codeyam/codeyam-cli 0.1.0-staging.323686 → 0.1.0-staging.4813bf3

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 (444) hide show
  1. package/analyzer-template/.build-info.json +7 -7
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +5 -5
  4. package/analyzer-template/packages/ai/index.ts +7 -1
  5. package/analyzer-template/packages/ai/package.json +2 -2
  6. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +62 -18
  7. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +67 -9
  8. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
  9. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +409 -50
  10. package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
  11. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +21 -6
  12. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +992 -249
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
  14. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
  15. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
  16. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +31 -3
  17. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +37 -15
  18. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
  19. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +126 -11
  20. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
  21. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +367 -96
  23. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +33 -15
  24. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
  25. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +315 -6
  26. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +9 -5
  27. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +49 -5
  28. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
  29. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +649 -142
  30. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +1 -1
  31. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +51 -3
  32. package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
  33. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +90 -96
  34. package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
  35. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
  36. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +24 -4
  37. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +25 -13
  38. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +4 -3
  39. package/analyzer-template/packages/analyze/index.ts +2 -0
  40. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +65 -59
  41. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
  42. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
  43. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
  44. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
  45. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
  46. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
  47. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
  48. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +89 -9
  49. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +19 -4
  50. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
  51. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +0 -3
  52. package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
  53. package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
  54. package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
  55. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +61 -13
  56. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +37 -0
  57. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +229 -19
  58. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +117 -9
  59. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +459 -39
  60. package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
  61. package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
  62. package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
  63. package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
  64. package/analyzer-template/packages/aws/package.json +1 -1
  65. package/analyzer-template/packages/database/package.json +1 -1
  66. package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
  67. package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
  68. package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
  69. package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
  70. package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
  71. package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
  72. package/analyzer-template/packages/database/src/lib/kysely/db.ts +6 -0
  73. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +1 -1
  74. package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
  75. package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
  76. package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
  77. package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
  78. package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
  79. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
  80. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
  81. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
  82. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
  83. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
  84. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
  85. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
  86. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
  87. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
  88. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
  89. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
  90. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
  91. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -0
  92. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  93. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +3 -0
  94. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  95. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +1 -1
  96. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
  97. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
  98. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  99. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  100. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
  101. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
  102. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
  103. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
  104. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
  105. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
  106. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +7 -0
  107. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  108. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +5 -5
  109. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  110. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  111. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  112. package/analyzer-template/packages/github/package.json +1 -1
  113. package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
  114. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +6 -5
  115. package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
  116. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +7 -0
  117. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  118. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +5 -5
  119. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  120. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  121. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  122. package/analyzer-template/project/constructMockCode.ts +90 -10
  123. package/analyzer-template/project/writeMockDataTsx.ts +181 -8
  124. package/analyzer-template/project/writeScenarioComponents.ts +60 -12
  125. package/analyzer-template/project/writeSimpleRoot.ts +21 -11
  126. package/background/src/lib/local/createLocalAnalyzer.js +1 -1
  127. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  128. package/background/src/lib/virtualized/project/constructMockCode.js +75 -4
  129. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  130. package/background/src/lib/virtualized/project/writeMockDataTsx.js +162 -4
  131. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  132. package/background/src/lib/virtualized/project/writeScenarioComponents.js +60 -15
  133. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  134. package/background/src/lib/virtualized/project/writeSimpleRoot.js +21 -11
  135. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  136. package/codeyam-cli/scripts/apply-setup.js +180 -0
  137. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  138. package/codeyam-cli/src/cli.js +2 -0
  139. package/codeyam-cli/src/cli.js.map +1 -1
  140. package/codeyam-cli/src/codeyam-cli.js +18 -2
  141. package/codeyam-cli/src/codeyam-cli.js.map +1 -1
  142. package/codeyam-cli/src/commands/analyze.js +4 -2
  143. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  144. package/codeyam-cli/src/commands/baseline.js +2 -0
  145. package/codeyam-cli/src/commands/baseline.js.map +1 -1
  146. package/codeyam-cli/src/commands/debug.js +9 -5
  147. package/codeyam-cli/src/commands/debug.js.map +1 -1
  148. package/codeyam-cli/src/commands/default.js +31 -20
  149. package/codeyam-cli/src/commands/default.js.map +1 -1
  150. package/codeyam-cli/src/commands/detect-universal-mocks.js +2 -0
  151. package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
  152. package/codeyam-cli/src/commands/init.js +49 -257
  153. package/codeyam-cli/src/commands/init.js.map +1 -1
  154. package/codeyam-cli/src/commands/memory.js +17 -26
  155. package/codeyam-cli/src/commands/memory.js.map +1 -1
  156. package/codeyam-cli/src/commands/recapture.js +2 -0
  157. package/codeyam-cli/src/commands/recapture.js.map +1 -1
  158. package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
  159. package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
  160. package/codeyam-cli/src/commands/setup-simulations.js +284 -0
  161. package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
  162. package/codeyam-cli/src/commands/test-startup.js +2 -0
  163. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  164. package/codeyam-cli/src/commands/verify.js +14 -2
  165. package/codeyam-cli/src/commands/verify.js.map +1 -1
  166. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +128 -86
  167. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  168. package/codeyam-cli/src/utils/analyzer.js +7 -0
  169. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  170. package/codeyam-cli/src/utils/backgroundServer.js +5 -0
  171. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  172. package/codeyam-cli/src/utils/generateReport.js +2 -2
  173. package/codeyam-cli/src/utils/install-skills.js +70 -45
  174. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  175. package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
  176. package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
  177. package/codeyam-cli/src/utils/progress.js +7 -0
  178. package/codeyam-cli/src/utils/progress.js.map +1 -1
  179. package/codeyam-cli/src/utils/queue/job.js +4 -0
  180. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  181. package/codeyam-cli/src/utils/requireSimulations.js +10 -0
  182. package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
  183. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
  184. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
  185. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +230 -0
  186. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
  187. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
  188. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
  189. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
  190. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
  191. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
  192. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
  193. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
  194. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
  195. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
  196. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
  197. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +378 -0
  198. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
  199. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +115 -0
  200. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
  201. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
  202. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
  203. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
  204. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
  205. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
  206. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
  207. package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
  208. package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
  209. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
  210. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
  211. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
  212. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
  213. package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
  214. package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
  215. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
  216. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
  217. package/codeyam-cli/src/utils/rules/index.js +1 -0
  218. package/codeyam-cli/src/utils/rules/index.js.map +1 -1
  219. package/codeyam-cli/src/utils/rules/parser.js +2 -25
  220. package/codeyam-cli/src/utils/rules/parser.js.map +1 -1
  221. package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
  222. package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
  223. package/codeyam-cli/src/utils/rules/staleness.js +16 -11
  224. package/codeyam-cli/src/utils/rules/staleness.js.map +1 -1
  225. package/codeyam-cli/src/utils/serverState.js +37 -10
  226. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  227. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +21 -44
  228. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  229. package/codeyam-cli/src/webserver/app/lib/database.js +15 -3
  230. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  231. package/codeyam-cli/src/webserver/backgroundServer.js +24 -0
  232. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  233. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CA3JxPb7.js +1 -0
  234. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-DsN1wKrm.js → EntityItem-B86KKU7e.js} +1 -1
  235. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DLqD3qNt.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
  236. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-Ba2JVPzP.js → EntityTypeIcon-BqY8gDAW.js} +1 -1
  237. package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-C8lyxW9k.js → InlineSpinner-ClaLpuOo.js} +1 -1
  238. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-aht4aafF.js → InteractivePreview-BDhPilK7.js} +2 -2
  239. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CVtiBnY5.js → LibraryFunctionPreview-VeqEBv9v.js} +1 -1
  240. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-B0GLXMsr.js → LoadingDots-Bs7Nn1Jr.js} +1 -1
  241. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-xgeCVgSM.js → LogViewer-Bm3PmcCz.js} +1 -1
  242. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-OApQuNyq.js → ReportIssueModal-CgMEzchJ.js} +3 -8
  243. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DuDvi0jm.js → SafeScreenshot-Gq3Ocjo6.js} +1 -1
  244. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DzccYyI8.js → ScenarioViewer-CBui0id_.js} +2 -2
  245. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-DyFZkK0l.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
  246. package/codeyam-cli/src/webserver/build/client/assets/{_index-BwqWJOgH.js → _index-B3TDXxnk.js} +1 -1
  247. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BwavGCpm.js → activity.(_tab)-BtBFH820.js} +6 -11
  248. package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-CN61MOMa.js +11 -0
  249. package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
  250. package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
  251. package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
  252. package/codeyam-cli/src/webserver/build/client/assets/book-open-PttOB2SF.js +6 -0
  253. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-Cx24_aWc.js → chevron-down-TJp6ofnp.js} +1 -1
  254. package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-CXRTFQ3F.js → chunk-JZWAC4HX-JE9ZIoBl.js} +12 -12
  255. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BOARzkeR.js → circle-check-CXhHQYrI.js} +1 -1
  256. package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
  257. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-BdhJEx6B.js → createLucideIcon-Ca9fAY46.js} +1 -1
  258. package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BBnGWYga.js → dev.empty-C0epRiVn.js} +1 -1
  259. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BJUiQqZF.js → entity._sha._-BVnB8a9L.js} +10 -10
  260. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js → entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js} +1 -1
  261. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D1T4TGjf.js → entity._sha_.create-scenario-DGgZjdFg.js} +1 -1
  262. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CTBG2mmz.js → entity._sha_.edit._scenarioId-38yPijoD.js} +1 -1
  263. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CS2cb_eZ.js → entry.client-BSHEfydn.js} +1 -1
  264. package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DMJ7zii9.js → fileTableUtils-DCPhhSMo.js} +1 -1
  265. package/codeyam-cli/src/webserver/build/client/assets/{files-CJ6lTdTA.js → files-0N0YJQv7.js} +1 -1
  266. package/codeyam-cli/src/webserver/build/client/assets/{git-CPTZZ-JZ.js → git-DXnyr8uP.js} +1 -1
  267. package/codeyam-cli/src/webserver/build/client/assets/globals-CKT08Djd.css +1 -0
  268. package/codeyam-cli/src/webserver/build/client/assets/{index-lzqtyFU8.js → index-CcsFv748.js} +1 -1
  269. package/codeyam-cli/src/webserver/build/client/assets/{index-B1h680n5.js → index-ChN9-fAY.js} +1 -1
  270. package/codeyam-cli/src/webserver/build/client/assets/labs-BLJ7HxOC.js +1 -0
  271. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-B7B9V-bu.js → loader-circle-CTqLEAGU.js} +1 -1
  272. package/codeyam-cli/src/webserver/build/client/assets/manifest-b171b9d3.js +1 -0
  273. package/codeyam-cli/src/webserver/build/client/assets/memory-CCQd4aZA.js +78 -0
  274. package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
  275. package/codeyam-cli/src/webserver/build/client/assets/root-CHhiHoo_.js +62 -0
  276. package/codeyam-cli/src/webserver/build/client/assets/{search-CxXUmBSd.js → search-B8VUL8nl.js} +1 -1
  277. package/codeyam-cli/src/webserver/build/client/assets/settings-BejnUJ6R.js +1 -0
  278. package/codeyam-cli/src/webserver/build/client/assets/{simulations-DwFIBT09.js → simulations-CPoAg7Zo.js} +1 -1
  279. package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
  280. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-B6LgvRJg.js → triangle-alert-BZz2NjYa.js} +1 -1
  281. package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-C1v1PQzo.js → useCustomSizes-DNwUduNu.js} +1 -1
  282. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-aSv48UbS.js → useLastLogLine-COky1GVF.js} +1 -1
  283. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DYxHZQuP.js → useReportContext-CpZgwliL.js} +1 -1
  284. package/codeyam-cli/src/webserver/build/client/assets/{useToast-mBRpZPiu.js → useToast-Bv9JFvUO.js} +1 -1
  285. package/codeyam-cli/src/webserver/build/server/assets/{index-DVzYx8PN.js → index-8Fv-lH1-.js} +1 -1
  286. package/codeyam-cli/src/webserver/build/server/assets/server-build-Akn3iYFP.js +257 -0
  287. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  288. package/codeyam-cli/src/webserver/build-info.json +5 -5
  289. package/codeyam-cli/templates/{codeyam:debug.md → codeyam-debug.md} +1 -1
  290. package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
  291. package/codeyam-cli/templates/codeyam-memory-hook.sh +19 -20
  292. package/codeyam-cli/templates/codeyam-memory.md +392 -0
  293. package/codeyam-cli/templates/codeyam-new-rule.md +13 -0
  294. package/codeyam-cli/templates/{codeyam:setup.md → codeyam-setup.md} +13 -1
  295. package/codeyam-cli/templates/{codeyam:sim.md → codeyam-sim.md} +1 -1
  296. package/codeyam-cli/templates/{codeyam:test.md → codeyam-test.md} +1 -1
  297. package/codeyam-cli/templates/{codeyam:verify.md → codeyam-verify.md} +1 -1
  298. package/codeyam-cli/templates/rule-notification-hook.py +56 -0
  299. package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
  300. package/codeyam-cli/templates/rules-instructions.md +132 -0
  301. package/package.json +2 -2
  302. package/packages/ai/index.js +3 -2
  303. package/packages/ai/index.js.map +1 -1
  304. package/packages/ai/src/lib/analyzeScope.js +50 -13
  305. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  306. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +54 -8
  307. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  308. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
  309. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
  310. package/packages/ai/src/lib/astScopes/processExpression.js +317 -44
  311. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  312. package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
  313. package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
  314. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +763 -171
  315. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  316. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
  317. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  318. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
  319. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
  320. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
  321. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
  322. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +33 -3
  323. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  324. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +36 -11
  325. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  326. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
  327. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
  328. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +113 -11
  329. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  330. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
  331. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
  332. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
  333. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
  334. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +309 -84
  335. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  336. package/packages/ai/src/lib/dataStructureChunking.js +26 -11
  337. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -1
  338. package/packages/ai/src/lib/generateEntityDataStructure.js +46 -2
  339. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  340. package/packages/ai/src/lib/generateEntityScenarioData.js +227 -4
  341. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  342. package/packages/ai/src/lib/generateEntityScenarios.js +7 -1
  343. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  344. package/packages/ai/src/lib/generateExecutionFlows.js +26 -4
  345. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
  346. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +447 -80
  347. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
  348. package/packages/ai/src/lib/isolateScopes.js +39 -3
  349. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  350. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
  351. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
  352. package/packages/ai/src/lib/mergeStatements.js +70 -51
  353. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  354. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
  355. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
  356. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +10 -4
  357. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  358. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +17 -2
  359. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  360. package/packages/ai/src/lib/resolvePathToControllable.js +24 -14
  361. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
  362. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  363. package/packages/analyze/index.js +1 -0
  364. package/packages/analyze/index.js.map +1 -1
  365. package/packages/analyze/src/lib/FileAnalyzer.js +60 -36
  366. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  367. package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
  368. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  369. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
  370. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
  371. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
  372. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
  373. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
  374. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
  375. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
  376. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
  377. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
  378. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
  379. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
  380. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
  381. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +65 -7
  382. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  383. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +17 -4
  384. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  385. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
  386. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  387. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +0 -3
  388. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  389. package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
  390. package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
  391. package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
  392. package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
  393. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
  394. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
  395. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +56 -10
  396. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
  397. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +33 -8
  398. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  399. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +150 -17
  400. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  401. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +56 -8
  402. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
  403. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +399 -31
  404. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  405. package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
  406. package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
  407. package/packages/analyze/src/lib/index.js +1 -0
  408. package/packages/analyze/src/lib/index.js.map +1 -1
  409. package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
  410. package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
  411. package/packages/database/src/lib/analysisBranchToDb.js +1 -1
  412. package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
  413. package/packages/database/src/lib/analysisToDb.js +1 -1
  414. package/packages/database/src/lib/analysisToDb.js.map +1 -1
  415. package/packages/database/src/lib/branchToDb.js +1 -1
  416. package/packages/database/src/lib/branchToDb.js.map +1 -1
  417. package/packages/database/src/lib/commitBranchToDb.js +1 -1
  418. package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
  419. package/packages/database/src/lib/commitToDb.js +1 -1
  420. package/packages/database/src/lib/commitToDb.js.map +1 -1
  421. package/packages/database/src/lib/fileToDb.js +1 -1
  422. package/packages/database/src/lib/fileToDb.js.map +1 -1
  423. package/packages/database/src/lib/kysely/db.js +3 -0
  424. package/packages/database/src/lib/kysely/db.js.map +1 -1
  425. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  426. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  427. package/packages/database/src/lib/projectToDb.js +1 -1
  428. package/packages/database/src/lib/projectToDb.js.map +1 -1
  429. package/packages/database/src/lib/saveFiles.js +1 -1
  430. package/packages/database/src/lib/saveFiles.js.map +1 -1
  431. package/packages/database/src/lib/scenarioToDb.js +1 -1
  432. package/packages/database/src/lib/scenarioToDb.js.map +1 -1
  433. package/scripts/finalize-analyzer.cjs +8 -76
  434. package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +0 -6
  435. package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +0 -6
  436. package/codeyam-cli/src/webserver/build/client/assets/globals-D3yhhV8x.css +0 -1
  437. package/codeyam-cli/src/webserver/build/client/assets/manifest-7522edd4.js +0 -1
  438. package/codeyam-cli/src/webserver/build/client/assets/memory-yxFcrxBX.js +0 -92
  439. package/codeyam-cli/src/webserver/build/client/assets/root-eVAaavTS.js +0 -62
  440. package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +0 -1
  441. package/codeyam-cli/src/webserver/build/server/assets/server-build-4Cr0uToj.js +0 -257
  442. package/codeyam-cli/templates/codeyam:diagnose.md +0 -803
  443. package/codeyam-cli/templates/codeyam:memory.md +0 -462
  444. package/codeyam-cli/templates/codeyam:new-rule.md +0 -13
@@ -4,6 +4,7 @@ import {
4
4
  } from '~codeyam/ai';
5
5
  import { cleanKnownObjectFunctionsFromMapping } from '~codeyam/ai';
6
6
  import { DataStructure, Entity, ReadonlyAnalysis } from '~codeyam/types';
7
+ import { transformationTracer } from './TransformationTracer';
7
8
 
8
9
  export interface DataStructureInfo {
9
10
  signatureSchema: { [key: string]: string };
@@ -40,6 +41,59 @@ function getTypeParameter(functionName: string): string | null {
40
41
  return null;
41
42
  }
42
43
 
44
+ // Primitive types that should not have child paths
45
+ const PRIMITIVE_TYPES = new Set([
46
+ 'number',
47
+ 'string',
48
+ 'boolean',
49
+ 'null',
50
+ 'undefined',
51
+ ]);
52
+
53
+ // Check if a type string represents a primitive type
54
+ // Handles union types like "string | undefined" or "number | null"
55
+ function isPrimitiveType(typeStr: string): boolean {
56
+ if (PRIMITIVE_TYPES.has(typeStr)) {
57
+ return true;
58
+ }
59
+ // Check union types - if ALL parts of the union are primitives, it's primitive
60
+ // e.g., "string | undefined" -> ["string", "undefined"] -> both are primitive -> true
61
+ // e.g., "object | null" -> ["object", "null"] -> object is not primitive -> false
62
+ if (typeStr.includes('|')) {
63
+ const parts = typeStr.split('|').map((p) => p.trim());
64
+ return parts.every((part) => PRIMITIVE_TYPES.has(part));
65
+ }
66
+ return false;
67
+ }
68
+
69
+ // Extract signature index from a path like "signature[0]" or "signature[0].foo"
70
+ // Returns the index number or undefined if not a signature path
71
+ function extractSignatureIndex(path: string): number | undefined {
72
+ const match = path.match(/^signature\[(\d+)\]/);
73
+ return match ? parseInt(match[1], 10) : undefined;
74
+ }
75
+
76
+ // Check if a new schema path would go through a primitive type
77
+ // e.g., if schema has 'entities[].scenarioCount': 'number', then
78
+ // 'entities[].scenarioCount.sha' would go through a primitive and should be rejected
79
+ function wouldGoThroughPrimitive(
80
+ newPath: string,
81
+ schema: { [key: string]: string },
82
+ ): boolean {
83
+ const pathParts = splitOutsideParenthesesAndArrays(newPath);
84
+
85
+ // Check each prefix of the path (excluding the full path itself)
86
+ for (let i = 1; i < pathParts.length; i++) {
87
+ const prefixPath = joinParenthesesAndArrays(pathParts.slice(0, i));
88
+ const prefixType = schema[prefixPath];
89
+ if (prefixType && isPrimitiveType(prefixType)) {
90
+ return true;
91
+ }
92
+ }
93
+
94
+ return false;
95
+ }
96
+
43
97
  // Check if schemaPathPart matches or is a function call variant of pathPart
44
98
  // e.g., 'isEntityBeingAnalyzed(entity.sha)' matches 'isEntityBeingAnalyzed'
45
99
  function pathPartMatches(pathPart: string, schemaPathPart: string): boolean {
@@ -57,10 +111,14 @@ function bestValueFromOptions(options: Array<string | undefined>) {
57
111
  options = options.filter(Boolean) as string[];
58
112
 
59
113
  const known = options.find((o) => !o.includes('unknown'));
60
- if (known) return known;
114
+ if (known) {
115
+ return known;
116
+ }
61
117
 
62
118
  const notUnknown = options.find((o) => o !== 'unknown');
63
- if (notUnknown) return notUnknown;
119
+ if (notUnknown) {
120
+ return notUnknown;
121
+ }
64
122
 
65
123
  return options[0] ?? 'unknown';
66
124
  }
@@ -152,10 +210,21 @@ export default function mergeInDependentDataStructure({
152
210
  equivalentPostfixes: Record<string, string>;
153
211
  }[] = [];
154
212
 
213
+ // Pre-build a lookup map from cleaned function name to dependency for O(1) lookups.
214
+ // This avoids O(n) linear search in findRelevantDependency which was causing O(n²) performance.
215
+ const dependencyByCleanedName = new Map<
216
+ string,
217
+ (typeof importedExports)[0]
218
+ >();
219
+ for (const dep of importedExports) {
220
+ const cleanedName = cleanFunctionName(dep.name);
221
+ if (!dependencyByCleanedName.has(cleanedName)) {
222
+ dependencyByCleanedName.set(cleanedName, dep);
223
+ }
224
+ }
225
+
155
226
  const findRelevantDependency = (functionName: any) => {
156
- return importedExports.find(
157
- (d) => cleanFunctionName(d.name) === cleanFunctionName(functionName),
158
- );
227
+ return dependencyByCleanedName.get(cleanFunctionName(functionName));
159
228
  };
160
229
 
161
230
  const findRelevantDependentDataStructure = (functionName: any) => {
@@ -192,8 +261,17 @@ export default function mergeInDependentDataStructure({
192
261
  return mergedDataStructure.dependencySchemas[filePath][name];
193
262
  };
194
263
 
195
- const cleanSchema = (schema: { [key: string]: string }) => {
196
- cleanKnownObjectFunctionsFromMapping(schema);
264
+ const cleanSchema = (
265
+ schema: { [key: string]: string },
266
+ context?: Record<string, any>,
267
+ ) => {
268
+ transformationTracer.traceSchemaTransform(
269
+ rootScopeName,
270
+ 'cleanKnownObjectFunctionsFromMapping',
271
+ schema,
272
+ cleanKnownObjectFunctionsFromMapping,
273
+ context,
274
+ );
197
275
  };
198
276
 
199
277
  const translatePath = (path: string, dependencyName: string) => {
@@ -266,10 +344,21 @@ export default function mergeInDependentDataStructure({
266
344
  let equivalentSchemaPathsEntry:
267
345
  | (typeof equivalentSchemaPaths)[0]
268
346
  | undefined;
347
+
348
+ // Collect the signature indices from the new roots we want to add
349
+ const newRootSignatureIndices = new Set<number>();
350
+ for (const root of equivalentRoots) {
351
+ const idx = extractSignatureIndex(root.schemaRootPath);
352
+ if (idx !== undefined) {
353
+ newRootSignatureIndices.add(idx);
354
+ }
355
+ }
356
+
269
357
  for (const pathInfo of allPaths) {
270
358
  if (!equivalentSchemaPathsEntry) {
271
- equivalentSchemaPathsEntry = equivalentSchemaPaths.find((esp) =>
272
- esp.equivalentRoots.some(
359
+ equivalentSchemaPathsEntry = equivalentSchemaPaths.find((esp) => {
360
+ // First check: does this entry have a matching root?
361
+ const hasMatchingRoot = esp.equivalentRoots.some(
273
362
  (er) =>
274
363
  er.schemaRootPath === pathInfo.path &&
275
364
  (er.function?.name ===
@@ -277,30 +366,106 @@ export default function mergeInDependentDataStructure({
277
366
  (!er.function &&
278
367
  cleanFunctionName(pathInfo.functionName) ===
279
368
  rootScopeName)),
280
- ),
281
- );
369
+ );
370
+ if (!hasMatchingRoot) return false;
371
+
372
+ // Second check: would adding our new roots create a signature index conflict?
373
+ // An entry should NOT contain roots with different signature indices from the same function.
374
+ if (newRootSignatureIndices.size > 0) {
375
+ // Get all signature indices in the existing entry (grouped by function)
376
+ const existingIndicesByFunction = new Map<string, Set<number>>();
377
+ for (const er of esp.equivalentRoots) {
378
+ const funcKey = er.function
379
+ ? `${er.function.name}::${er.function.filePath}`
380
+ : '__self__';
381
+ const idx = extractSignatureIndex(er.schemaRootPath);
382
+ if (idx !== undefined) {
383
+ if (!existingIndicesByFunction.has(funcKey)) {
384
+ existingIndicesByFunction.set(funcKey, new Set());
385
+ }
386
+ existingIndicesByFunction.get(funcKey)!.add(idx);
387
+ }
388
+ }
389
+
390
+ // Check if adding our new roots would create a conflict
391
+ for (const newRoot of equivalentRoots) {
392
+ const funcKey = newRoot.function
393
+ ? `${newRoot.function.name}::${newRoot.function.filePath}`
394
+ : '__self__';
395
+ const newIdx = extractSignatureIndex(newRoot.schemaRootPath);
396
+ if (newIdx !== undefined) {
397
+ const existingIndices =
398
+ existingIndicesByFunction.get(funcKey);
399
+ if (existingIndices && existingIndices.size > 0) {
400
+ // If this function already has signature indices, check for conflict
401
+ if (!existingIndices.has(newIdx)) {
402
+ // Conflict: entry has indices like [1] but we want to add [2]
403
+ return false;
404
+ }
405
+ }
406
+ }
407
+ }
408
+ }
409
+
410
+ return true;
411
+ });
282
412
  }
283
413
  }
284
414
 
285
415
  if (!equivalentSchemaPathsEntry) {
416
+ // Before creating a new entry, filter out roots that have conflicting
417
+ // signature indices from the same function. An entry should never contain
418
+ // roots with different signature indices from the same function.
419
+ // This prevents the bug where signature[1], signature[2], signature[4]
420
+ // all get merged together due to incorrect sourceEquivalencies.
421
+ let filteredRoots = equivalentRoots;
422
+ if (newRootSignatureIndices.size > 1) {
423
+ // There are multiple signature indices - we need to filter to keep only
424
+ // one consistent set. We'll keep the roots that match the PRIMARY index
425
+ // (the first signature index we encounter from self, or the lowest index).
426
+
427
+ // First, determine the primary index - prefer the self root's index
428
+ let primaryIndex: number | undefined;
429
+ for (const root of equivalentRoots) {
430
+ if (!root.function) {
431
+ // This is a self root
432
+ const idx = extractSignatureIndex(root.schemaRootPath);
433
+ if (idx !== undefined) {
434
+ primaryIndex = idx;
435
+ break;
436
+ }
437
+ }
438
+ }
439
+ // If no self root has a signature index, use the lowest index
440
+ if (primaryIndex === undefined) {
441
+ primaryIndex = Math.min(...newRootSignatureIndices);
442
+ }
443
+
444
+ // Filter roots: keep if no signature index OR signature index matches primary
445
+ filteredRoots = equivalentRoots.filter((root) => {
446
+ const idx = extractSignatureIndex(root.schemaRootPath);
447
+ return idx === undefined || idx === primaryIndex;
448
+ });
449
+ }
450
+
286
451
  equivalentSchemaPathsEntry = {
287
- equivalentRoots,
452
+ equivalentRoots: filteredRoots,
288
453
  equivalentPostfixes: {},
289
454
  };
290
455
  equivalentSchemaPaths.push(equivalentSchemaPathsEntry);
291
456
  } else {
292
457
  equivalentSchemaPathsEntry.equivalentRoots.push(...equivalentRoots);
293
458
  }
459
+
460
+ // Deduplicate roots using a Set for O(n) instead of O(n²)
461
+ const seenRoots = new Set<string>();
294
462
  equivalentSchemaPathsEntry.equivalentRoots =
295
- equivalentSchemaPathsEntry.equivalentRoots.filter(
296
- (er, index, self) =>
297
- index ===
298
- self.findIndex(
299
- (e) =>
300
- e.schemaRootPath === er.schemaRootPath &&
301
- e.function?.name === er.function?.name,
302
- ),
303
- );
463
+ equivalentSchemaPathsEntry.equivalentRoots.filter((er) => {
464
+ const key = er.schemaRootPath + '::' + (er.function?.name ?? '');
465
+ if (seenRoots.has(key)) return false;
466
+ seenRoots.add(key);
467
+ return true;
468
+ });
304
469
 
305
470
  return equivalentSchemaPathsEntry;
306
471
  };
@@ -476,6 +641,26 @@ export default function mergeInDependentDataStructure({
476
641
  allPaths.push(...derivedBasePaths);
477
642
 
478
643
  const entry = findOrCreateEquivalentSchemaPathsEntry(allPaths);
644
+
645
+ // Trace equivalency gathering - helps debug why paths may not be connected
646
+ if (allPaths.length > 1) {
647
+ transformationTracer.operation(rootScopeName, {
648
+ operation: 'gatherEquivalency',
649
+ stage: 'gathering',
650
+ path: translatedPath,
651
+ context: {
652
+ sourceFunction: functionName,
653
+ equivalentPaths: allPaths.map((p) => ({
654
+ path: p.path,
655
+ function: p.functionName,
656
+ })),
657
+ equivalentRoots: entry.equivalentRoots.map((r) => ({
658
+ path: r.schemaRootPath,
659
+ function: r.function?.name,
660
+ })),
661
+ },
662
+ });
663
+ }
479
664
  for (const equivalentRoot of entry.equivalentRoots) {
480
665
  const dataStructures =
481
666
  equivalentRoot.function &&
@@ -606,13 +791,29 @@ export default function mergeInDependentDataStructure({
606
791
  schemaPathParts.slice(matchedUpToIndex),
607
792
  );
608
793
 
609
- entry.equivalentPostfixes[postfix] = entry
610
- .equivalentPostfixes[postfix]
611
- ? bestValueFromOptions([
612
- entry.equivalentPostfixes[postfix],
613
- schema[schemaPath],
614
- ])
615
- : schema[schemaPath];
794
+ const previousValue = entry.equivalentPostfixes[postfix];
795
+ const newValue = schema[schemaPath];
796
+ entry.equivalentPostfixes[postfix] = previousValue
797
+ ? bestValueFromOptions([previousValue, newValue])
798
+ : newValue;
799
+
800
+ // Trace postfix gathering - shows where type info comes from
801
+ if (entry.equivalentPostfixes[postfix] !== previousValue) {
802
+ transformationTracer.operation(rootScopeName, {
803
+ operation: 'gatherPostfix',
804
+ stage: 'gathering',
805
+ path: postfix || '(root)',
806
+ before: previousValue,
807
+ after: entry.equivalentPostfixes[postfix],
808
+ context: {
809
+ sourceSchemaPath: schemaPath,
810
+ sourceFunction:
811
+ equivalentRoot.function?.name || rootScopeName,
812
+ equivalentRootPath: equivalentRoot.schemaRootPath,
813
+ rawValue: newValue,
814
+ },
815
+ });
816
+ }
616
817
  }
617
818
  }
618
819
  }
@@ -672,14 +873,14 @@ export default function mergeInDependentDataStructure({
672
873
  const postfix = joinParenthesesAndArrays(
673
874
  schemaPathParts.slice(basePathParts.length),
674
875
  );
675
- entry.equivalentPostfixes[postfix] = entry.equivalentPostfixes[
676
- postfix
677
- ]
876
+ const newValue = entry.equivalentPostfixes[postfix]
678
877
  ? bestValueFromOptions([
679
878
  entry.equivalentPostfixes[postfix],
680
879
  dataStructure.returnValueSchema[schemaPath],
681
880
  ])
682
881
  : dataStructure.returnValueSchema[schemaPath];
882
+
883
+ entry.equivalentPostfixes[postfix] = newValue;
683
884
  }
684
885
  }
685
886
  }
@@ -734,6 +935,10 @@ export default function mergeInDependentDataStructure({
734
935
  equivalentRootFunction: (typeof equivalentSchemaPaths)[0]['equivalentRoots'][0]['function'],
735
936
  ) => {
736
937
  let postfix: string | undefined;
938
+
939
+ // Get the signature index we're looking for (if any)
940
+ const lookingForSignatureIndex = extractSignatureIndex(schemaSubPath);
941
+
737
942
  const equivalentEntry = mergedEquivalentSchemaPaths.find((esp) =>
738
943
  esp.equivalentRoots.some((er) => {
739
944
  if (
@@ -746,6 +951,35 @@ export default function mergeInDependentDataStructure({
746
951
  }
747
952
 
748
953
  if (schemaSubPath === er.schemaRootPath) {
954
+ // Additional check: if we're looking for a signature path, make sure
955
+ // the entry doesn't already have DIFFERENT signature indices.
956
+ // This prevents entries with signature[1], signature[2], signature[4]
957
+ // from all being merged together.
958
+ if (lookingForSignatureIndex !== undefined) {
959
+ const hasConflictingSignatureIndex = esp.equivalentRoots.some(
960
+ (otherRoot) => {
961
+ // Only check roots from the same function
962
+ if (
963
+ otherRoot.function?.name !== equivalentRootFunction?.name ||
964
+ otherRoot.function?.filePath !==
965
+ equivalentRootFunction?.filePath
966
+ ) {
967
+ return false;
968
+ }
969
+ const otherIndex = extractSignatureIndex(
970
+ otherRoot.schemaRootPath,
971
+ );
972
+ return (
973
+ otherIndex !== undefined &&
974
+ otherIndex !== lookingForSignatureIndex
975
+ );
976
+ },
977
+ );
978
+ if (hasConflictingSignatureIndex) {
979
+ return false;
980
+ }
981
+ }
982
+
749
983
  postfix = er.postfix;
750
984
  return true;
751
985
  }
@@ -880,7 +1114,44 @@ export default function mergeInDependentDataStructure({
880
1114
  equivalentSchemaPaths = mergeAllEquivalentSchemaPaths();
881
1115
 
882
1116
  for (const esp of equivalentSchemaPaths) {
883
- for (const equivalentRoot of esp.equivalentRoots) {
1117
+ // Pre-compute which postfixes have children to avoid O(n²) lookups in the inner loop.
1118
+ // A postfix "has children" if there are other postfixes that extend it.
1119
+ const postfixesWithChildren = new Set<string>();
1120
+ const postfixKeys = Object.keys(esp.equivalentPostfixes);
1121
+
1122
+ // Check for empty postfix having children (any other postfixes exist)
1123
+ if (postfixKeys.length > 1 && '' in esp.equivalentPostfixes) {
1124
+ postfixesWithChildren.add('');
1125
+ }
1126
+
1127
+ // Check for array element postfixes having children using a prefix set.
1128
+ // This avoids O(n²) scans across large postfix lists.
1129
+ // e.g., 'currentEntities[]' has children if a path like 'currentEntities[].sha' exists.
1130
+ const postfixPrefixSet = new Set<string>();
1131
+ for (const postfixPath of postfixKeys) {
1132
+ if (!postfixPath) continue;
1133
+ const parts = splitOutsideParenthesesAndArrays(postfixPath);
1134
+ for (let i = 1; i < parts.length; i++) {
1135
+ postfixPrefixSet.add(joinParenthesesAndArrays(parts.slice(0, i)));
1136
+ }
1137
+ }
1138
+ for (const postfixPath of postfixKeys) {
1139
+ if (postfixPath.endsWith('[]') && postfixPrefixSet.has(postfixPath)) {
1140
+ postfixesWithChildren.add(postfixPath);
1141
+ }
1142
+ }
1143
+
1144
+ // Deduplicate equivalentRoots that would write to the same schema paths.
1145
+ // Roots with the same (function, schemaRootPath, postfix) are redundant.
1146
+ const seenRootKeys = new Set<string>();
1147
+ const uniqueRoots = esp.equivalentRoots.filter((root) => {
1148
+ const key = `${root.function?.filePath ?? ''}::${root.function?.name ?? ''}::${root.schemaRootPath}::${root.postfix ?? ''}`;
1149
+ if (seenRootKeys.has(key)) return false;
1150
+ seenRootKeys.add(key);
1151
+ return true;
1152
+ });
1153
+
1154
+ for (const equivalentRoot of uniqueRoots) {
884
1155
  let merged:
885
1156
  | {
886
1157
  signatureSchema: { [key: string]: string };
@@ -905,9 +1176,21 @@ export default function mergeInDependentDataStructure({
905
1176
  )) {
906
1177
  let relevantPostfix = postfixPath;
907
1178
  if (equivalentRoot.postfix) {
1179
+ // Check if postfixPath starts with equivalentRoot.postfix at a path boundary.
1180
+ // Must ensure exact path part match - "entityCode" should NOT match "entity" prefix.
1181
+ // Valid: "entity.foo" starts with "entity" (boundary at '.')
1182
+ // Valid: "entity[0]" starts with "entity" (boundary at '[')
1183
+ // Invalid: "entityCode" starts with "entity" (no boundary, different property)
908
1184
  if (!postfixPath.startsWith(equivalentRoot.postfix)) {
909
1185
  continue;
910
1186
  }
1187
+ // Additional check: ensure the match is at a path boundary
1188
+ const nextChar = postfixPath[equivalentRoot.postfix.length];
1189
+ if (nextChar !== undefined && nextChar !== '.' && nextChar !== '[') {
1190
+ // The postfixPath continues with more characters that aren't a path separator.
1191
+ // This means "entity" matched "entityCode" which is wrong - they're different properties.
1192
+ continue;
1193
+ }
911
1194
 
912
1195
  const postFixPathParts =
913
1196
  splitOutsideParenthesesAndArrays(postfixPath);
@@ -924,10 +1207,90 @@ export default function mergeInDependentDataStructure({
924
1207
  relevantPostfix,
925
1208
  ]);
926
1209
 
1210
+ // Skip paths that would go through a primitive type
1211
+ // e.g., if schema has 'entities[].scenarioCount': 'number', skip 'entities[].scenarioCount.sha'
1212
+ if (wouldGoThroughPrimitive(newSchemaPath, schema)) {
1213
+ transformationTracer.operation(rootScopeName, {
1214
+ operation: 'skipPrimitivePath',
1215
+ stage: 'merged',
1216
+ path: newSchemaPath,
1217
+ context: {
1218
+ reason: 'would go through primitive type',
1219
+ postfixValue,
1220
+ },
1221
+ });
1222
+ continue;
1223
+ }
1224
+
1225
+ // Skip setting primitive type when there are child postfixes that indicate structure.
1226
+ // This prevents downgrading an object/array element to a primitive type.
1227
+ // Uses pre-computed postfixesWithChildren Set for O(1) lookup instead of O(n) iteration.
1228
+ const hasChildPostfixes =
1229
+ (relevantPostfix === '' || relevantPostfix.endsWith('[]')) &&
1230
+ postfixesWithChildren.has(postfixPath);
1231
+ if (PRIMITIVE_TYPES.has(postfixValue) && hasChildPostfixes) {
1232
+ continue;
1233
+ }
1234
+
1235
+ // Don't overwrite a more specific type with a less specific one
1236
+ // This can happen when nested roots share entries with their parent roots
1237
+ const existingType = schema[newSchemaPath];
1238
+ if (existingType) {
1239
+ // Don't overwrite a primitive type with 'object' or 'array'
1240
+ // e.g., if schema has 'entities[].scenarioCount': 'number', don't overwrite with 'object'
1241
+ if (
1242
+ PRIMITIVE_TYPES.has(existingType) &&
1243
+ (postfixValue === 'object' || postfixValue === 'array')
1244
+ ) {
1245
+ transformationTracer.operation(rootScopeName, {
1246
+ operation: 'skipTypeDowngrade',
1247
+ stage: 'merged',
1248
+ path: newSchemaPath,
1249
+ context: {
1250
+ reason: 'would overwrite primitive with object/array',
1251
+ existingType,
1252
+ newType: postfixValue,
1253
+ },
1254
+ });
1255
+ continue;
1256
+ }
1257
+ // Don't overwrite a complex/union type with a primitive
1258
+ // e.g., if schema has 'scenarios[]': 'Scenario | null', don't overwrite with 'string'
1259
+ if (
1260
+ !PRIMITIVE_TYPES.has(existingType) &&
1261
+ PRIMITIVE_TYPES.has(postfixValue)
1262
+ ) {
1263
+ transformationTracer.operation(rootScopeName, {
1264
+ operation: 'skipTypeDowngrade',
1265
+ stage: 'merged',
1266
+ path: newSchemaPath,
1267
+ context: {
1268
+ reason: 'would overwrite complex type with primitive',
1269
+ existingType,
1270
+ newType: postfixValue,
1271
+ },
1272
+ });
1273
+ continue;
1274
+ }
1275
+ }
1276
+
1277
+ // Log the successful postfix merge
1278
+ transformationTracer.operation(rootScopeName, {
1279
+ operation: 'mergePostfix',
1280
+ stage: 'merged',
1281
+ path: newSchemaPath,
1282
+ before: existingType,
1283
+ after: postfixValue,
1284
+ context: {
1285
+ schemaRootPath: equivalentRoot.schemaRootPath,
1286
+ postfix: relevantPostfix,
1287
+ dependency: equivalentRoot.function?.name,
1288
+ },
1289
+ });
927
1290
  schema[newSchemaPath] = postfixValue;
928
1291
  }
929
1292
 
930
- cleanSchema(schema);
1293
+ cleanSchema(schema, { stage: 'afterMergePostfix' });
931
1294
  }
932
1295
  }
933
1296
 
@@ -1049,6 +1412,14 @@ export default function mergeInDependentDataStructure({
1049
1412
  `${dependency.name}().functionCallReturnValue`,
1050
1413
  );
1051
1414
  }
1415
+ transformationTracer.operation(rootScopeName, {
1416
+ operation: 'normalizeReturnValuePath',
1417
+ stage: 'merged',
1418
+ path: normalizedPath,
1419
+ before: path,
1420
+ after: normalizedPath,
1421
+ context: { dependency: dependency.name, value },
1422
+ });
1052
1423
  depSchema.returnValueSchema[normalizedPath] = value;
1053
1424
  }
1054
1425
 
@@ -1133,7 +1504,10 @@ export default function mergeInDependentDataStructure({
1133
1504
  }
1134
1505
  }
1135
1506
 
1136
- cleanSchema(depSchema.returnValueSchema);
1507
+ cleanSchema(depSchema.returnValueSchema, {
1508
+ stage: 'afterMockedDependencyMerge',
1509
+ dependency: dependency.name,
1510
+ });
1137
1511
 
1138
1512
  // Pull signature requirements from downstream functions into the mocked return value.
1139
1513
  // When a mocked function's return flows into another function's signature (via usageEquivalencies),
@@ -1210,7 +1584,10 @@ export default function mergeInDependentDataStructure({
1210
1584
  }
1211
1585
  }
1212
1586
 
1213
- cleanSchema(depSchema.returnValueSchema);
1587
+ cleanSchema(depSchema.returnValueSchema, {
1588
+ stage: 'afterSignatureRequirementsMerge',
1589
+ dependency: dependency.name,
1590
+ });
1214
1591
  }
1215
1592
 
1216
1593
  // Process the input dependencySchemas FIRST (before child dependentAnalyses).
@@ -1251,7 +1628,45 @@ export default function mergeInDependentDataStructure({
1251
1628
  // from the copied schema. Without this, method call paths on primitives like
1252
1629
  // "projectSlug.replace(...)" would cause convertDotNotation to create nested
1253
1630
  // object structures instead of preserving the primitive type.
1254
- cleanSchema(depSchema.returnValueSchema);
1631
+ cleanSchema(depSchema.returnValueSchema, {
1632
+ stage: 'afterDependencySchemaCopy',
1633
+ filePath,
1634
+ dependency: name,
1635
+ });
1636
+ }
1637
+
1638
+ // TYPE REFINEMENT: Check if dependentAnalyses has a more specific type for this dependency.
1639
+ // When a parent passes `entity.filePath` (string | undefined) to a child component
1640
+ // that requires `filePath: string`, we should use the child's more specific type.
1641
+ // This prevents mock data from having undefined values for required props.
1642
+ //
1643
+ // This runs REGARDLESS of whether equivalencies already processed the schema,
1644
+ // because equivalencies copy the parent's type (string | undefined), not the child's
1645
+ // required type (string).
1646
+ const depSchema = findOrCreateDependentSchemas({ filePath, name });
1647
+ const childAnalysis = dependentAnalyses[filePath]?.[name];
1648
+ const childSignatureSchema =
1649
+ childAnalysis?.metadata?.mergedDataStructure?.signatureSchema;
1650
+
1651
+ if (childSignatureSchema) {
1652
+ for (const path in depSchema.signatureSchema) {
1653
+ const parentType = depSchema.signatureSchema[path];
1654
+ const childType = childSignatureSchema[path];
1655
+
1656
+ if (parentType && childType) {
1657
+ // Check if parent has optional type and child has required type
1658
+ const parentIsOptional =
1659
+ parentType.includes('| undefined') ||
1660
+ parentType.includes('| null');
1661
+ const childIsOptional =
1662
+ childType.includes('| undefined') || childType.includes('| null');
1663
+
1664
+ // If child requires a more specific type (not optional), use it
1665
+ if (parentIsOptional && !childIsOptional) {
1666
+ depSchema.signatureSchema[path] = childType;
1667
+ }
1668
+ }
1669
+ }
1255
1670
  }
1256
1671
 
1257
1672
  // For functions with multiple different type parameters, also create separate entries
@@ -1288,7 +1703,12 @@ export default function mergeInDependentDataStructure({
1288
1703
  srcSchema.returnValueSchema[path];
1289
1704
  }
1290
1705
  }
1291
- cleanSchema(variantSchema.returnValueSchema);
1706
+ cleanSchema(variantSchema.returnValueSchema, {
1707
+ stage: 'afterTypeVariantCopy',
1708
+ filePath,
1709
+ dependency: name,
1710
+ variant,
1711
+ });
1292
1712
  }
1293
1713
  }
1294
1714
  }
@@ -1352,8 +1772,8 @@ export default function mergeInDependentDataStructure({
1352
1772
  // Merge in the nested dependency schemas
1353
1773
  for (const path in nestedDepSchema.returnValueSchema) {
1354
1774
  if (!(path in targetDepSchema.returnValueSchema)) {
1355
- targetDepSchema.returnValueSchema[path] =
1356
- nestedDepSchema.returnValueSchema[path];
1775
+ const value = nestedDepSchema.returnValueSchema[path];
1776
+ targetDepSchema.returnValueSchema[path] = value;
1357
1777
  }
1358
1778
  }
1359
1779