@shapeshift-labs/frontier-lang-compiler 0.2.150 → 0.2.151

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 (276) hide show
  1. package/README.md +315 -9
  2. package/bench/real-repo-corpus-checkout-identity.mjs +134 -0
  3. package/bench/real-repo-corpus-checkout-proof.mjs +263 -0
  4. package/bench/real-repo-corpus-command-execution.mjs +314 -0
  5. package/bench/real-repo-corpus-evidence.mjs +165 -0
  6. package/bench/real-repo-corpus-suite.mjs +273 -0
  7. package/bench/smoke.mjs +109 -7
  8. package/dist/declarations/import-adapter-core.d.ts +4 -3
  9. package/dist/declarations/import-adapter-options-native.d.ts +21 -0
  10. package/dist/declarations/js-ts-project-merge-admission-routes.d.ts +35 -0
  11. package/dist/declarations/js-ts-project-merge-commonjs-interop.d.ts +29 -0
  12. package/dist/declarations/js-ts-project-merge-confidence.d.ts +64 -0
  13. package/dist/declarations/js-ts-project-merge-declaration-emit-parity.d.ts +37 -0
  14. package/dist/declarations/js-ts-project-merge-declarations.d.ts +65 -0
  15. package/dist/declarations/js-ts-project-merge-diagnostics.d.ts +97 -0
  16. package/dist/declarations/js-ts-project-merge-global-augmentation.d.ts +30 -0
  17. package/dist/declarations/js-ts-project-merge-jsx-render-branch.d.ts +48 -0
  18. package/dist/declarations/js-ts-project-merge-proof-levels.d.ts +109 -0
  19. package/dist/declarations/js-ts-project-merge-quality-gates.d.ts +38 -0
  20. package/dist/declarations/js-ts-project-merge-semantic-equivalence-proof.d.ts +45 -0
  21. package/dist/declarations/js-ts-project-merge-tsconfig.d.ts +43 -0
  22. package/dist/declarations/js-ts-safe-merge.d.ts +47 -0
  23. package/dist/declarations/js-ts-safe-project-merge.d.ts +120 -38
  24. package/dist/declarations/native-project-compiler-assignability-oracle.d.ts +41 -0
  25. package/dist/declarations/native-project-compiler-callable-signatures.d.ts +31 -0
  26. package/dist/declarations/native-project-compiler-class-member-runtime-proof.d.ts +87 -0
  27. package/dist/declarations/native-project-compiler-composite-types.d.ts +23 -0
  28. package/dist/declarations/native-project-compiler-enum-proof.d.ts +58 -0
  29. package/dist/declarations/native-project-compiler-index-signature.d.ts +7 -0
  30. package/dist/declarations/native-project-compiler-public-api-source-binding.d.ts +8 -0
  31. package/dist/declarations/native-project-compiler-scope.d.ts +37 -0
  32. package/dist/declarations/native-project-compiler-type-reference-targets.d.ts +38 -0
  33. package/dist/declarations/native-project-css-modules.d.ts +90 -0
  34. package/dist/declarations/native-project-decorator-metadata.d.ts +126 -0
  35. package/dist/declarations/native-project-jsx-graph.d.ts +313 -0
  36. package/dist/declarations/native-project-module-declarations.d.ts +52 -0
  37. package/dist/declarations/native-project-module-resolution.d.ts +76 -1
  38. package/dist/declarations/native-project-runtime-effect-target.d.ts +29 -0
  39. package/dist/declarations/native-project-runtime-executable-effect-evidence.d.ts +107 -0
  40. package/dist/declarations/native-project-runtime-mutation-target.d.ts +33 -0
  41. package/dist/declarations/native-project-runtime-promise-chain.d.ts +30 -0
  42. package/dist/declarations/native-project-runtime-promise-combinator.d.ts +22 -0
  43. package/dist/declarations/native-project-runtime-reachability.d.ts +30 -0
  44. package/dist/declarations/native-project-runtime-resource-management.d.ts +27 -0
  45. package/dist/declarations/native-project-runtime-yield-delegation.d.ts +10 -0
  46. package/dist/declarations/native-project-scope-template-reference.d.ts +13 -0
  47. package/dist/declarations/native-project-source-evidence.d.ts +8 -0
  48. package/dist/declarations/native-project.d.ts +40 -39
  49. package/dist/declarations/semantic-edit-script.d.ts +10 -8
  50. package/dist/declarations/semantic-graph-layers.d.ts +79 -0
  51. package/dist/declarations/semantic-sidecar.d.ts +3 -2
  52. package/dist/declarations/semantic-structural-diff.d.ts +94 -0
  53. package/dist/declarations/source-preservation.d.ts +32 -1
  54. package/dist/declarations/target-adapters.d.ts +22 -2
  55. package/dist/index.d.ts +31 -0
  56. package/dist/index.js +5 -0
  57. package/dist/internal/index-impl/compileNativeSource.js +53 -5
  58. package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
  59. package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
  60. package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
  61. package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
  62. package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
  63. package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
  64. package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
  65. package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
  66. package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
  67. package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
  68. package/dist/internal/index-impl/importNativeSource.js +2 -3
  69. package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
  70. package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
  71. package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
  72. package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
  73. package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
  74. package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
  75. package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
  76. package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
  77. package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
  78. package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
  79. package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
  80. package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
  81. package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
  82. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
  83. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
  84. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
  85. package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
  86. package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
  87. package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
  88. package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
  89. package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
  90. package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
  91. package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
  92. package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
  93. package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
  94. package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
  95. package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
  96. package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
  97. package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
  98. package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
  99. package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
  100. package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
  101. package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
  102. package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
  103. package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
  104. package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
  105. package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
  106. package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
  107. package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
  108. package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
  109. package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
  110. package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
  111. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
  112. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
  113. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
  114. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
  115. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
  116. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
  117. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
  118. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
  119. package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
  120. package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
  121. package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
  122. package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
  123. package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
  124. package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
  125. package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
  126. package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
  127. package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
  128. package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
  129. package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
  130. package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
  131. package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
  132. package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
  133. package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
  134. package/dist/internal/index-impl/semanticEditScripts.js +42 -5
  135. package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
  136. package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
  137. package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
  138. package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
  139. package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
  140. package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
  141. package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
  142. package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
  143. package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
  144. package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
  145. package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
  146. package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
  147. package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
  148. package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
  149. package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
  150. package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
  151. package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
  152. package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
  153. package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
  154. package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
  155. package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
  156. package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
  157. package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
  158. package/dist/js-ts-safe-member-class-invariants.js +247 -0
  159. package/dist/js-ts-safe-member-merge-result.js +23 -3
  160. package/dist/js-ts-safe-member-merge.js +28 -4
  161. package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
  162. package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +151 -157
  163. package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
  164. package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
  165. package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
  166. package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
  167. package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
  168. package/dist/js-ts-safe-merge-parse-statements.js +8 -0
  169. package/dist/js-ts-safe-merge-semantic-edit-fallback.js +13 -5
  170. package/dist/js-ts-safe-merge-source-shape-fallbacks.js +3 -1
  171. package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
  172. package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
  173. package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
  174. package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
  175. package/dist/js-ts-safe-merge.js +136 -0
  176. package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
  177. package/dist/js-ts-safe-project-merge-admission.js +161 -0
  178. package/dist/js-ts-safe-project-merge-ambient.js +110 -0
  179. package/dist/js-ts-safe-project-merge-core.js +85 -0
  180. package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
  181. package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
  182. package/dist/js-ts-safe-project-merge-declarations.js +227 -0
  183. package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
  184. package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
  185. package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
  186. package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
  187. package/dist/js-ts-safe-project-merge-files.js +70 -0
  188. package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
  189. package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
  190. package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
  191. package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
  192. package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
  193. package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
  194. package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
  195. package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
  196. package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
  197. package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
  198. package/dist/js-ts-safe-project-merge-graph.js +37 -5
  199. package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
  200. package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
  201. package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
  202. package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
  203. package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
  204. package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
  205. package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
  206. package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
  207. package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
  208. package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
  209. package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
  210. package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
  211. package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
  212. package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
  213. package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
  214. package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
  215. package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
  216. package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
  217. package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
  218. package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
  219. package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
  220. package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
  221. package/dist/js-ts-safe-project-merge-summary.js +320 -0
  222. package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
  223. package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
  224. package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
  225. package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
  226. package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
  227. package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
  228. package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
  229. package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
  230. package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
  231. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
  232. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
  233. package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
  234. package/dist/js-ts-safe-project-merge.js +170 -171
  235. package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
  236. package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
  237. package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
  238. package/dist/js-ts-semantic-scope-use-def.js +217 -0
  239. package/dist/lightweight-dependency-effects.js +28 -4
  240. package/dist/lightweight-dependency-relations.js +13 -7
  241. package/dist/lightweight-dependency-top-level.js +63 -0
  242. package/dist/native-import-language-profiles.js +27 -1
  243. package/dist/native-js-ts-importers.js +9 -5
  244. package/dist/native-parser-ast-format-profiles.js +12 -0
  245. package/dist/native-parser-html-css-format-profiles.js +85 -0
  246. package/dist/native-region-scanner-core.js +5 -3
  247. package/dist/native-region-scanner-js-commonjs.js +155 -0
  248. package/dist/native-region-scanner-js-imports.js +51 -13
  249. package/dist/native-region-scanner-js-reexports.js +79 -0
  250. package/dist/native-region-scanner-js-ts-helpers.js +23 -0
  251. package/dist/native-source-ledger-helpers.js +1 -1
  252. package/dist/native-source-ledger.js +24 -10
  253. package/dist/native-source-maps-ecma426.js +316 -0
  254. package/dist/native-source-maps.js +36 -6
  255. package/dist/native-source-preservation-ownership.js +292 -0
  256. package/dist/native-source-preservation-scanner.js +63 -25
  257. package/dist/native-source-preservation-types.d.ts +3 -0
  258. package/dist/semantic-import-effect-occurrences.js +242 -0
  259. package/dist/semantic-import-effect-regions.js +95 -58
  260. package/dist/semantic-import-graph-layers.js +224 -0
  261. package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
  262. package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
  263. package/dist/semantic-import-runtime-exit-evidence.js +32 -0
  264. package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
  265. package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
  266. package/dist/semantic-import-runtime-order-evidence.js +318 -0
  267. package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
  268. package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
  269. package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
  270. package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
  271. package/dist/semantic-import-runtime-switch-evidence.js +304 -0
  272. package/dist/semantic-import-runtime-throw-evidence.js +44 -0
  273. package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
  274. package/dist/semantic-import-sidecar-entry.js +4 -0
  275. package/dist/semantic-import-source-preservation.js +6 -2
  276. package/package.json +1 -1
@@ -0,0 +1,279 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { computedEnumRuntimeValueHash } from './projectSymbolGraphCompilerEnumEquivalence.js';
3
+
4
+ const EnumRuntimeShapeProofKind = 'typescript-checker-public-api-enum-runtime-shape-evidence';
5
+
6
+ function compilerEnumShapeRecord(checker, identitySymbol, location, ts, options = {}) {
7
+ const declarations = enumDeclarations(identitySymbol, ts);
8
+ if (!declarations.length) return {};
9
+ const baseMembers = declarations.flatMap((declaration, declarationOrdinal) => enumMemberRecords(checker, declaration, location, ts, declarationOrdinal));
10
+ if (!baseMembers.length) return {};
11
+ const constEnum = declarations.some((declaration) => hasModifier(declaration, ts, 'ConstKeyword'));
12
+ const declareEnum = declarations.some((declaration) => hasModifier(declaration, ts, 'DeclareKeyword'));
13
+ const enumRuntimeShapeHash = hashSemanticValue({
14
+ kind: 'frontier.lang.typescript.compilerEnumRuntimeShapeEvidence.v1',
15
+ constEnum,
16
+ declareEnum,
17
+ enumMembers: baseMembers.map(canonicalEnumMemberRecord)
18
+ });
19
+ const computedMemberCount = baseMembers.filter((member) => member.computed === true).length;
20
+ const proofBridge = computedEnumRuntimeValueProofBridge(baseMembers, {
21
+ sourcePath: options.sourcePath,
22
+ sourceHash: options.sourceHash,
23
+ enumName: stringValue(identitySymbol?.escapedName ?? identitySymbol?.name),
24
+ enumRuntimeShapeHash,
25
+ enumComputedMemberCount: computedMemberCount,
26
+ constEnum,
27
+ declareEnum
28
+ }, options);
29
+ const enumMembers = proofBridge.enumMembers;
30
+ const counts = enumShapeCounts(enumMembers);
31
+ const enumEmittedRuntimeShapeHash = emittedRuntimeShapeHash(enumMembers, { constEnum, declareEnum });
32
+ return compactRecord({
33
+ enumKind: constEnum ? 'const-enum' : 'enum',
34
+ constEnum: constEnum || undefined,
35
+ declareEnum: declareEnum || undefined,
36
+ enumDeclarationCount: declarations.length || undefined,
37
+ enumMemberCount: enumMembers.length,
38
+ enumNumericMemberCount: counts.enumNumericMemberCount || undefined,
39
+ enumStringMemberCount: counts.enumStringMemberCount || undefined,
40
+ enumAutoMemberCount: counts.enumAutoMemberCount || undefined,
41
+ enumComputedMemberCount: counts.enumComputedMemberCount || undefined,
42
+ enumRuntimeShapeHash,
43
+ enumEmittedRuntimeShapeHash,
44
+ enumMembers,
45
+ enumRuntimeShapeProof: {
46
+ kind: EnumRuntimeShapeProofKind,
47
+ status: 'passed',
48
+ proofLevel: 'typescript-checker-public-api-enum-runtime-shape',
49
+ checkerInvariant: 'enum member names, declaration order, initializer texts, and constant runtime values complete',
50
+ requiredSignals: [
51
+ 'compiler-enum-member-count',
52
+ 'compiler-enum-member-names',
53
+ 'compiler-enum-member-value-texts',
54
+ 'compiler-enum-member-initializer-texts'
55
+ ],
56
+ enumRuntimeShapeHash,
57
+ enumEmittedRuntimeShapeHash,
58
+ enumMemberCount: enumMembers.length,
59
+ computedEnumRuntimeValueHash: proofBridge.computedEnumRuntimeValueHash,
60
+ computedEnumRuntimeValueProof: proofBridge.computedEnumRuntimeValueProof,
61
+ ...counts,
62
+ autoMergeClaim: false,
63
+ semanticEquivalenceClaim: false,
64
+ runtimeEquivalenceClaim: false
65
+ }
66
+ });
67
+ }
68
+
69
+ function computedEnumRuntimeValueProofBridge(enumMembers, context, options) {
70
+ const computedMembers = enumMembers.filter((member) => member.computed === true);
71
+ if (!computedMembers.length) return { enumMembers };
72
+ const candidate = computedEnumRuntimeValueCandidate({ ...context, enumMembers, computedMembers }, options);
73
+ if (!candidate) return { enumMembers };
74
+ const provedMembers = enumMembers.map((member) => member.computed === true
75
+ ? { ...member, ...runtimeValueForMember(member, candidate) }
76
+ : member);
77
+ const computedValueHash = computedEnumRuntimeValueHash({
78
+ enumRuntimeShapeHash: context.enumRuntimeShapeHash,
79
+ enumMembers: provedMembers
80
+ }, context);
81
+ const emittedHash = emittedRuntimeShapeHash(provedMembers, context);
82
+ const proof = compactRecord({
83
+ id: candidate.id,
84
+ evidenceId: candidate.evidenceId,
85
+ evidenceIds: nonEmptyArray(arrayValue(candidate.evidenceIds)),
86
+ schema: candidate.schema ?? 'frontier.lang.typescript.computedEnumRuntimeValueProof.v1',
87
+ kind: candidate.kind,
88
+ status: candidate.status,
89
+ sourcePath: candidate.sourcePath ?? context.sourcePath,
90
+ sourceHash: candidate.sourceHash ?? context.sourceHash,
91
+ enumName: candidate.enumName ?? context.enumName,
92
+ enumRuntimeShapeHash: candidate.enumRuntimeShapeHash ?? context.enumRuntimeShapeHash,
93
+ enumEmittedRuntimeShapeHash: candidate.enumEmittedRuntimeShapeHash ?? emittedHash,
94
+ enumComputedMemberCount: candidate.enumComputedMemberCount ?? computedMembers.length,
95
+ computedMembers: nonEmptyArray(provedMembers.filter((member) => member.computed === true).map(runtimeValueProofMember)),
96
+ computedEnumRuntimeValueHash: candidate.computedEnumRuntimeValueHash ?? computedValueHash,
97
+ command: candidate.command,
98
+ traceHash: candidate.traceHash,
99
+ evidenceHash: candidate.evidenceHash,
100
+ autoMergeClaim: candidate.autoMergeClaim ?? false,
101
+ semanticEquivalenceClaim: candidate.semanticEquivalenceClaim ?? false,
102
+ runtimeEquivalenceClaim: candidate.runtimeEquivalenceClaim ?? false,
103
+ computedEnumRuntimeEvaluationEquivalenceClaim: candidate.computedEnumRuntimeEvaluationEquivalenceClaim ?? false
104
+ });
105
+ return {
106
+ enumMembers: provedMembers,
107
+ computedEnumRuntimeValueHash: computedValueHash,
108
+ computedEnumRuntimeValueProof: proof
109
+ };
110
+ }
111
+
112
+ function computedEnumRuntimeValueCandidate(context, options) {
113
+ const provider = options.computedEnumRuntimeValueProofProvider ?? options.computedEnumRuntimeValueTraceProvider;
114
+ const provided = typeof provider === 'function' ? safeCall(provider, undefined, {
115
+ ...context,
116
+ proofKind: 'frontier.lang.typescript.computedEnumRuntimeValueProof'
117
+ }) : undefined;
118
+ const candidates = [
119
+ ...candidateList(provided),
120
+ ...candidateList(options.computedEnumRuntimeValueProofs),
121
+ ...candidateList(options.computedEnumRuntimeValueProof),
122
+ ...candidateList(options.computedEnumRuntimeValueTraces)
123
+ ];
124
+ return candidates.find((candidate) => candidateMatches(candidate, context));
125
+ }
126
+
127
+ function candidateMatches(candidate, context) {
128
+ if (!candidate || typeof candidate !== 'object') return false;
129
+ if (candidate.sourcePath !== undefined && candidate.sourcePath !== context.sourcePath) return false;
130
+ const candidateName = candidate.enumName ?? candidate.publicOwnerName ?? candidate.symbolName;
131
+ if (candidateName !== undefined && candidateName !== context.enumName) return false;
132
+ return true;
133
+ }
134
+
135
+ function candidateList(value) {
136
+ if (Array.isArray(value)) return value.filter(objectValue);
137
+ const object = objectValue(value);
138
+ if (!object) return [];
139
+ if (object.status || object.schema || object.kind || object.computedMembers || object.runtimeValues || object.enumMembers) return [object];
140
+ return Object.values(object).filter(objectValue);
141
+ }
142
+
143
+ function runtimeValueForMember(member, candidate) {
144
+ const runtimeValues = objectValue(candidate.runtimeValues);
145
+ const directValue = runtimeValues?.[member.name];
146
+ const record = candidateMemberRecords(candidate).find((item) => memberRecordMatches(item, member));
147
+ return runtimeValueRecord(record ?? directValue);
148
+ }
149
+
150
+ function candidateMemberRecords(candidate) {
151
+ return [
152
+ ...arrayValue(candidate.computedMembers),
153
+ ...arrayValue(candidate.members),
154
+ ...arrayValue(candidate.enumMembers),
155
+ ...arrayValue(candidate.values)
156
+ ].filter((value) => value !== undefined && value !== null);
157
+ }
158
+
159
+ function memberRecordMatches(record, member) {
160
+ if (!objectValue(record)) return false;
161
+ if (record.declarationOrdinal !== undefined && record.ordinal !== undefined) {
162
+ return Number(record.declarationOrdinal) === Number(member.declarationOrdinal)
163
+ && Number(record.ordinal) === Number(member.ordinal);
164
+ }
165
+ if (record.ordinal !== undefined && Number(record.ordinal) === Number(member.ordinal)) return true;
166
+ return record.name !== undefined && String(record.name) === String(member.name);
167
+ }
168
+
169
+ function runtimeValueRecord(value) {
170
+ if (value === undefined || value === null) return {};
171
+ const record = objectValue(value);
172
+ if (!record) return { runtimeValueText: String(value), runtimeValueKind: typeof value };
173
+ const raw = record.runtimeValue ?? record.value;
174
+ return compactRecord({
175
+ runtimeValueText: stringValue(record.runtimeValueText ?? record.valueText ?? (raw === undefined ? undefined : String(raw))),
176
+ runtimeValueKind: stringValue(record.runtimeValueKind ?? record.valueKind ?? (raw === undefined ? undefined : typeof raw))
177
+ });
178
+ }
179
+
180
+ function runtimeValueProofMember(member) {
181
+ return compactRecord({
182
+ name: member.name,
183
+ ordinal: member.ordinal,
184
+ declarationOrdinal: member.declarationOrdinal,
185
+ initializerText: member.initializerText,
186
+ runtimeValueText: member.runtimeValueText,
187
+ runtimeValueKind: member.runtimeValueKind
188
+ });
189
+ }
190
+
191
+ function emittedRuntimeShapeHash(enumMembers, context) {
192
+ const erased = context.constEnum === true || context.declareEnum === true;
193
+ return hashSemanticValue({
194
+ kind: 'frontier.lang.typescript.enumEmittedRuntimeShape.v1',
195
+ erased,
196
+ entries: erased ? [] : enumMembers.flatMap(emittedRuntimeEntries)
197
+ });
198
+ }
199
+
200
+ function emittedRuntimeEntries(member) {
201
+ const valueText = member.runtimeValueText ?? member.valueText;
202
+ const valueKind = member.runtimeValueKind ?? member.valueKind;
203
+ const forward = compactRecord({ direction: 'forward', name: member.name, valueText, valueKind });
204
+ const reverse = valueKind === 'number' ? compactRecord({ direction: 'reverse', valueText, name: member.name }) : undefined;
205
+ return [forward, reverse].filter(Boolean);
206
+ }
207
+
208
+ function enumMemberRecords(checker, declaration, location, ts, declarationOrdinal) {
209
+ return arrayValue(declaration.members).map((member, ordinal) => {
210
+ const constantValue = safeCall(checker?.getConstantValue, checker, member);
211
+ const initializerText = nodeText(member.initializer);
212
+ const valueKind = constantValue === undefined ? undefined : typeof constantValue;
213
+ return compactRecord({
214
+ name: stringValue(member.name?.escapedText ?? member.name?.text ?? nodeText(member.name)),
215
+ ordinal,
216
+ declarationOrdinal,
217
+ initializerText,
218
+ valueText: constantValue === undefined ? undefined : String(constantValue),
219
+ valueKind,
220
+ auto: member.initializer ? undefined : true,
221
+ computed: member.initializer && constantValue === undefined ? true : undefined,
222
+ memberText: nodeText(member),
223
+ memberTypeText: typeTextAt(checker, member.name ?? member, location)
224
+ });
225
+ });
226
+ }
227
+
228
+ function enumShapeCounts(records) {
229
+ return {
230
+ enumNumericMemberCount: records.filter((record) => record.valueKind === 'number').length,
231
+ enumStringMemberCount: records.filter((record) => record.valueKind === 'string').length,
232
+ enumAutoMemberCount: records.filter((record) => record.auto).length,
233
+ enumComputedMemberCount: records.filter((record) => record.computed).length
234
+ };
235
+ }
236
+
237
+ function enumDeclarations(identitySymbol, ts) {
238
+ return arrayValue(identitySymbol?.declarations).filter((declaration) => declaration.kind === syntaxKind(ts, 'EnumDeclaration'));
239
+ }
240
+
241
+ function canonicalEnumMemberRecord(record) {
242
+ return compactRecord({
243
+ name: record.name,
244
+ ordinal: record.ordinal,
245
+ declarationOrdinal: record.declarationOrdinal,
246
+ initializerText: record.initializerText,
247
+ valueText: record.valueText,
248
+ valueKind: record.valueKind,
249
+ runtimeValueText: record.runtimeValueText,
250
+ runtimeValueKind: record.runtimeValueKind,
251
+ auto: record.auto,
252
+ computed: record.computed
253
+ });
254
+ }
255
+
256
+ function hasModifier(node, ts, kindName) {
257
+ const kind = syntaxKind(ts, kindName);
258
+ return kind !== undefined && arrayValue(node.modifiers).some((modifier) => modifier.kind === kind);
259
+ }
260
+
261
+ function typeTextAt(checker, node, location) {
262
+ const type = safeCall(checker?.getTypeAtLocation, checker, node ?? location);
263
+ return type ? stringValue(safeCall(checker?.typeToString, checker, type)) : nodeText(node);
264
+ }
265
+
266
+ function syntaxKind(ts, name) { return numberValue(ts?.SyntaxKind?.[name]); }
267
+ function nodeText(node) { return stringValue(safeCall(node?.getText, node)); }
268
+ function safeCall(fn, receiver, ...args) {
269
+ if (typeof fn !== 'function') return undefined;
270
+ try { return fn.apply(receiver, args); } catch { return undefined; }
271
+ }
272
+ function arrayValue(value) { return Array.isArray(value) ? value : []; }
273
+ function objectValue(value) { return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined; }
274
+ function stringValue(value) { return value === undefined || value === null || value === '' ? undefined : String(value); }
275
+ function numberValue(value) { return Number.isFinite(value) ? value : undefined; }
276
+ function nonEmptyArray(value) { return Array.isArray(value) && value.length ? value : undefined; }
277
+ function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
278
+
279
+ export { compilerEnumShapeRecord };
@@ -0,0 +1,294 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { idFragment } from '../../native-import-utils.js';
3
+
4
+ const TypeScriptRefactorEvidenceKey = 'typescript-language-service-refactor-evidence';
5
+ const TypeScriptRefactorEvidenceMissingCode = 'project-typescript-refactor-evidence-missing';
6
+
7
+ function withTypeScriptRefactorEvidence(input = {}, classifications = [], files = []) {
8
+ if (!requiresTypeScriptRefactorEvidence(input)) return classifications;
9
+ return classifications.map((classification) => {
10
+ const evidence = typeScriptRefactorEvidenceForClassification(input, classification, files);
11
+ if (!evidence) return classification;
12
+ const requiredEvidence = uniqueStrings([
13
+ ...(classification.details?.requiredEvidence ?? []),
14
+ TypeScriptRefactorEvidenceKey
15
+ ]);
16
+ const details = compactRecord({
17
+ ...(classification.details ?? {}),
18
+ requiredEvidence,
19
+ typeScriptRefactorEvidence: evidence
20
+ });
21
+ if (evidence.status !== 'failed') return { ...classification, details };
22
+ return {
23
+ ...classification,
24
+ code: TypeScriptRefactorEvidenceMissingCode,
25
+ operation: `blocked-${classification.branch}-typescript-refactor-evidence`,
26
+ details: compactRecord({
27
+ ...details,
28
+ reasonCode: TypeScriptRefactorEvidenceMissingCode,
29
+ originalReasonCode: classification.code,
30
+ originalConflictKey: classification.details?.conflictKey,
31
+ conflictKey: `project-typescript-refactor-evidence#${classification.details?.conflictKey ?? classification.code}`
32
+ })
33
+ };
34
+ });
35
+ }
36
+
37
+ function hasFailedTypeScriptRefactorEvidence(classifications = []) {
38
+ return classifications.some((classification) => classification.details?.typeScriptRefactorEvidence?.status === 'failed');
39
+ }
40
+
41
+ function typeScriptRefactorEvidenceRecordsFromClassifications(classifications = []) {
42
+ const records = classifications
43
+ .map((classification) => classification.details?.typeScriptRefactorEvidence)
44
+ .filter((record) => record?.id);
45
+ const seen = new Set();
46
+ return records.filter((record) => {
47
+ if (seen.has(record.id)) return false;
48
+ seen.add(record.id);
49
+ return true;
50
+ });
51
+ }
52
+
53
+ function typeScriptRefactorEvidenceForClassification(input, classification, files) {
54
+ const requirements = typeScriptRefactorEvidenceRequirements(classification);
55
+ if (!requirements.length) return undefined;
56
+ const observations = requirements.map((requirement) => observeTypeScriptRefactorEvidenceRequirement(input, files, requirement));
57
+ const missing = observations.filter((observation) => observation.status !== 'passed');
58
+ const id = `evidence_${idFragment(hashSemanticValue([
59
+ classification.details?.conflictKey ?? classification.code,
60
+ TypeScriptRefactorEvidenceKey
61
+ ]))}_typescript_refactor`;
62
+ return {
63
+ id,
64
+ kind: 'typescript-language-service-refactor-evidence-oracle',
65
+ status: missing.length ? 'failed' : 'passed',
66
+ scope: 'project-refactor',
67
+ branch: classification.branch,
68
+ sourcePaths: classification.sourcePaths ?? [],
69
+ summary: missing.length
70
+ ? `Missing TypeScript refactor evidence for ${missing.length} project rename/move requirement(s).`
71
+ : `TypeScript refactor evidence covered ${observations.length} project rename/move requirement(s).`,
72
+ metadata: compactRecord({
73
+ code: missing.length ? TypeScriptRefactorEvidenceMissingCode : undefined,
74
+ refactorKind: classification.kind,
75
+ branch: classification.branch,
76
+ requiredEvidence: TypeScriptRefactorEvidenceKey,
77
+ requirements: observations,
78
+ missing,
79
+ missingRequirements: missing.length,
80
+ autoMergeClaim: false,
81
+ semanticEquivalenceClaim: false
82
+ })
83
+ };
84
+ }
85
+
86
+ function typeScriptRefactorEvidenceRequirements(classification) {
87
+ const branch = classification?.branch;
88
+ const details = classification?.details ?? {};
89
+ if (!branch) return [];
90
+ if (classification.kind === 'cross-file-symbol-rename') {
91
+ return uniqueRequirements([
92
+ requirement('base', details.exportSourcePath, 'declaration', 'base-export-declaration', details.fromName),
93
+ requirement('base', details.importSourcePath, 'reference', 'base-import-reference', details.fromName),
94
+ requirement(branch, details.exportSourcePath, 'declaration', 'branch-export-declaration', details.toName),
95
+ requirement(branch, details.importSourcePath, 'reference', 'branch-import-reference', details.toName)
96
+ ]);
97
+ }
98
+ if (classification.kind === 'imported-symbol-move') {
99
+ return uniqueRequirements([
100
+ requirement('base', details.fromSourcePath, 'declaration', 'base-export-declaration', details.symbolName),
101
+ requirement('base', details.importerSourcePath, 'reference', 'base-import-reference', details.symbolName),
102
+ requirement(branch, details.toSourcePath, 'declaration', 'branch-export-declaration', details.symbolName),
103
+ requirement(branch, details.importerSourcePath, 'reference', 'branch-import-reference', details.symbolName)
104
+ ]);
105
+ }
106
+ if (classification.kind === 'exported-symbol-move') {
107
+ return uniqueRequirements([
108
+ requirement('base', details.fromSourcePath, 'declaration', 'base-export-declaration', details.symbolName ?? details.exportedName),
109
+ requirement(branch, details.toSourcePath, 'declaration', 'branch-export-declaration', details.symbolName ?? details.exportedName)
110
+ ]);
111
+ }
112
+ return [];
113
+ }
114
+
115
+ function observeTypeScriptRefactorEvidenceRequirement(input, files, requirement) {
116
+ const expectedSourceHash = expectedProjectSourceHash(files, requirement.stage, requirement.sourcePath);
117
+ const importResult = matchingProjectImport(input, requirement.stage, requirement.sourcePath, expectedSourceHash);
118
+ const signals = typeScriptCompilerEvidenceSignals(importResult);
119
+ const passed = requirement.requirement === 'reference'
120
+ ? signals.compilerReferences > 0
121
+ : signals.compilerSymbols > 0 || signals.compilerTypes > 0;
122
+ return compactRecord({
123
+ ...requirement,
124
+ status: passed ? 'passed' : 'missing',
125
+ code: passed ? undefined : missingRequirementCode(requirement, importResult, expectedSourceHash, signals),
126
+ expectedSourceHash,
127
+ sourceImportMatched: Boolean(importResult),
128
+ importSourceHash: sourceHashForImport(importResult),
129
+ parser: signals.parser,
130
+ astFormat: signals.astFormat,
131
+ compilerSymbols: signals.compilerSymbols,
132
+ compilerTypes: signals.compilerTypes,
133
+ compilerReferences: signals.compilerReferences,
134
+ referenceRelations: signals.referenceRelations,
135
+ referenceGraphReferences: signals.referenceGraphReferences,
136
+ evidenceIds: signals.evidenceIds
137
+ });
138
+ }
139
+
140
+ function matchingProjectImport(input, stage, sourcePath, expectedSourceHash) {
141
+ if (!sourcePath) return undefined;
142
+ return normalizeProjectImports(projectImportsForStage(input, stage)).find((importResult) => {
143
+ if (sourcePathForImport(importResult) !== sourcePath) return false;
144
+ if (!expectedSourceHash) return true;
145
+ return sourceHashForImport(importResult) === expectedSourceHash;
146
+ });
147
+ }
148
+
149
+ function typeScriptCompilerEvidenceSignals(importResult) {
150
+ const semanticIndex = importResult?.semanticIndex;
151
+ const facts = semanticIndex?.facts ?? [];
152
+ const relations = semanticIndex?.relations ?? [];
153
+ const evidence = uniqueEvidenceRecords([
154
+ ...(importResult?.evidence ?? []),
155
+ ...(semanticIndex?.evidence ?? [])
156
+ ]);
157
+ const compilerReferences = facts.filter((fact) => fact.predicate === 'compilerSymbolReference').length;
158
+ const referenceRelations = relations.filter((relation) => relation.predicate === 'references' && relation.metadata?.compilerReference === true).length;
159
+ const referenceGraphReferences = Number(
160
+ semanticIndex?.metadata?.compilerReferenceGraph?.references
161
+ ?? importResult?.metadata?.compilerReferenceGraph?.references
162
+ ?? 0
163
+ );
164
+ return {
165
+ parser: firstString(importResult?.adapter?.parser, importResult?.nativeAst?.parser, semanticIndex?.metadata?.parser),
166
+ astFormat: firstString(importResult?.metadata?.astFormat, semanticIndex?.metadata?.astFormat),
167
+ compilerSymbols: facts.filter((fact) => fact.predicate === 'compilerSymbol').length,
168
+ compilerTypes: facts.filter((fact) => fact.predicate === 'compilerType').length,
169
+ compilerReferences: compilerReferences + referenceRelations + referenceGraphReferences,
170
+ referenceRelations,
171
+ referenceGraphReferences,
172
+ evidenceIds: uniqueStrings([
173
+ ...evidence
174
+ .filter((record) => record.kind === 'typescript-compiler-reference-graph' || record.metadata?.graphRecords?.compilerSymbols || record.metadata?.references)
175
+ .map((record) => record.id),
176
+ ...facts.flatMap((fact) => fact.evidenceIds ?? [])
177
+ ])
178
+ };
179
+ }
180
+
181
+ function expectedProjectSourceHash(files, stage, sourcePath) {
182
+ const sourceText = stageSourceText(files.find((file) => file.sourcePath === sourcePath), stage);
183
+ return typeof sourceText === 'string' ? hashSemanticValue(sourceText) : undefined;
184
+ }
185
+
186
+ function stageSourceText(file, stage) {
187
+ if (!file) return undefined;
188
+ if (stage === 'base') return file.baseSourceText;
189
+ if (stage === 'worker') return file.workerDeleted ? undefined : file.workerSourceText ?? file.baseSourceText;
190
+ if (stage === 'head') return file.headDeleted ? undefined : file.headSourceText ?? file.baseSourceText;
191
+ return undefined;
192
+ }
193
+
194
+ function projectImportsForStage(input, stage) {
195
+ if (stage === 'base') return input.baseProjectImports ?? input.projectGraphImports?.base;
196
+ if (stage === 'worker') return input.workerProjectImports ?? input.projectGraphImports?.worker;
197
+ if (stage === 'head') return input.headProjectImports ?? input.projectGraphImports?.head;
198
+ if (stage === 'output') return input.outputProjectImports ?? input.projectGraphImports?.output;
199
+ return input.projectGraphImports?.[stage];
200
+ }
201
+
202
+ function sourcePathForImport(importResult) {
203
+ return firstString(
204
+ importResult?.sourcePath,
205
+ importResult?.nativeSource?.sourcePath,
206
+ importResult?.nativeAst?.sourcePath,
207
+ importResult?.semanticIndex?.documents?.[0]?.path
208
+ );
209
+ }
210
+
211
+ function sourceHashForImport(importResult) {
212
+ return firstString(
213
+ importResult?.sourceHash,
214
+ importResult?.nativeSource?.sourceHash,
215
+ importResult?.nativeAst?.sourceHash,
216
+ importResult?.semanticIndex?.documents?.[0]?.sourceHash
217
+ );
218
+ }
219
+
220
+ function missingRequirementCode(requirement, importResult, expectedSourceHash, signals) {
221
+ if (!importResult) return 'typescript-refactor-project-import-missing';
222
+ if (expectedSourceHash && sourceHashForImport(importResult) !== expectedSourceHash) return 'typescript-refactor-project-import-stale';
223
+ if (requirement.requirement === 'reference' && signals.compilerReferences === 0) return 'typescript-refactor-reference-evidence-missing';
224
+ return 'typescript-refactor-symbol-evidence-missing';
225
+ }
226
+
227
+ function requirement(stage, sourcePath, requirementKind, role, symbolName) {
228
+ return compactRecord({
229
+ stage,
230
+ sourcePath,
231
+ requirement: requirementKind,
232
+ role,
233
+ symbolName
234
+ });
235
+ }
236
+
237
+ function requiresTypeScriptRefactorEvidence(input = {}) {
238
+ return input.requireTypeScriptRefactorEvidence === true
239
+ || input.requireTypeScriptLanguageServiceRefactorEvidence === true
240
+ || input.requireCompilerRefactorEvidence === true;
241
+ }
242
+
243
+ function normalizeProjectImports(value) {
244
+ if (!value) return [];
245
+ if (Array.isArray(value)) return value.filter(Boolean);
246
+ if (value instanceof Map) return [...value.values()].filter(Boolean);
247
+ if (typeof value === 'object') return Object.values(value).filter(Boolean);
248
+ return [];
249
+ }
250
+
251
+ function uniqueRequirements(requirements) {
252
+ const seen = new Set();
253
+ return requirements.filter((item) => {
254
+ if (!item.sourcePath) return false;
255
+ const key = `${item.stage}\0${item.sourcePath}\0${item.requirement}\0${item.role}`;
256
+ if (seen.has(key)) return false;
257
+ seen.add(key);
258
+ return true;
259
+ });
260
+ }
261
+
262
+ function uniqueEvidenceRecords(records) {
263
+ const seen = new Set();
264
+ return records.filter((record) => {
265
+ const key = record?.id;
266
+ if (!key || seen.has(key)) return false;
267
+ seen.add(key);
268
+ return true;
269
+ });
270
+ }
271
+
272
+ function uniqueStrings(values) {
273
+ return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))];
274
+ }
275
+
276
+ function firstString(...values) {
277
+ for (const value of values) {
278
+ if (value !== undefined && value !== null && String(value)) return String(value);
279
+ }
280
+ return undefined;
281
+ }
282
+
283
+ function compactRecord(record) {
284
+ return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
285
+ }
286
+
287
+ export {
288
+ TypeScriptRefactorEvidenceKey,
289
+ TypeScriptRefactorEvidenceMissingCode,
290
+ hasFailedTypeScriptRefactorEvidence,
291
+ requiresTypeScriptRefactorEvidence,
292
+ typeScriptRefactorEvidenceRecordsFromClassifications,
293
+ withTypeScriptRefactorEvidence
294
+ };