@shapeshift-labs/frontier-lang-compiler 0.2.149 → 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 (280) 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-patch-bundle-composition.d.ts +62 -0
  52. package/dist/declarations/semantic-sidecar.d.ts +3 -2
  53. package/dist/declarations/semantic-structural-diff.d.ts +94 -0
  54. package/dist/declarations/source-preservation.d.ts +32 -1
  55. package/dist/declarations/target-adapters.d.ts +22 -2
  56. package/dist/index.d.ts +32 -0
  57. package/dist/index.js +6 -0
  58. package/dist/internal/index-impl/compileNativeSource.js +53 -5
  59. package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
  60. package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
  61. package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
  62. package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
  63. package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
  64. package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
  65. package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
  66. package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
  67. package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
  68. package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
  69. package/dist/internal/index-impl/importNativeSource.js +2 -3
  70. package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
  71. package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
  72. package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
  73. package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
  74. package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
  75. package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
  76. package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
  77. package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
  78. package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
  79. package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
  80. package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
  81. package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
  82. package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
  83. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
  84. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
  85. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
  86. package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
  87. package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
  88. package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
  89. package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
  90. package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
  91. package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
  92. package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
  93. package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
  94. package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
  95. package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
  96. package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
  97. package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
  98. package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
  99. package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
  100. package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
  101. package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
  102. package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
  103. package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
  104. package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
  105. package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
  106. package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
  107. package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
  108. package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
  109. package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
  110. package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
  111. package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
  112. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
  113. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
  114. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
  115. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
  116. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
  117. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
  118. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
  119. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
  120. package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
  121. package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
  122. package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
  123. package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
  124. package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
  125. package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
  126. package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
  127. package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
  128. package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
  129. package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
  130. package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
  131. package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
  132. package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
  133. package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
  134. package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
  135. package/dist/internal/index-impl/semanticEditScripts.js +42 -5
  136. package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
  137. package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
  138. package/dist/internal/index-impl/semanticPatchBundleComposition.js +166 -0
  139. package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
  140. package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
  141. package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
  142. package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
  143. package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
  144. package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
  145. package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
  146. package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
  147. package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
  148. package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
  149. package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
  150. package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
  151. package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
  152. package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
  153. package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
  154. package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
  155. package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
  156. package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
  157. package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
  158. package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
  159. package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
  160. package/dist/js-ts-safe-member-class-invariants.js +247 -0
  161. package/dist/js-ts-safe-member-merge-result.js +23 -3
  162. package/dist/js-ts-safe-member-merge.js +28 -4
  163. package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
  164. package/dist/js-ts-safe-merge-context.js +1 -0
  165. package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +314 -0
  166. package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
  167. package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
  168. package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
  169. package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
  170. package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
  171. package/dist/js-ts-safe-merge-parse-statements.js +8 -0
  172. package/dist/js-ts-safe-merge-plan.js +3 -1
  173. package/dist/js-ts-safe-merge-semantic-edit-fallback.js +49 -0
  174. package/dist/js-ts-safe-merge-source-shape-fallbacks.js +5 -1
  175. package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
  176. package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
  177. package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
  178. package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
  179. package/dist/js-ts-safe-merge.js +136 -0
  180. package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
  181. package/dist/js-ts-safe-project-merge-admission.js +161 -0
  182. package/dist/js-ts-safe-project-merge-ambient.js +110 -0
  183. package/dist/js-ts-safe-project-merge-core.js +85 -0
  184. package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
  185. package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
  186. package/dist/js-ts-safe-project-merge-declarations.js +227 -0
  187. package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
  188. package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
  189. package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
  190. package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
  191. package/dist/js-ts-safe-project-merge-files.js +70 -0
  192. package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
  193. package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
  194. package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
  195. package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
  196. package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
  197. package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
  198. package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
  199. package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
  200. package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
  201. package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
  202. package/dist/js-ts-safe-project-merge-graph.js +37 -5
  203. package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
  204. package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
  205. package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
  206. package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
  207. package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
  208. package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
  209. package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
  210. package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
  211. package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
  212. package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
  213. package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
  214. package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
  215. package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
  216. package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
  217. package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
  218. package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
  219. package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
  220. package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
  221. package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
  222. package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
  223. package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
  224. package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
  225. package/dist/js-ts-safe-project-merge-summary.js +320 -0
  226. package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
  227. package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
  228. package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
  229. package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
  230. package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
  231. package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
  232. package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
  233. package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
  234. package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
  235. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
  236. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
  237. package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
  238. package/dist/js-ts-safe-project-merge.js +171 -172
  239. package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
  240. package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
  241. package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
  242. package/dist/js-ts-semantic-scope-use-def.js +217 -0
  243. package/dist/lightweight-dependency-effects.js +28 -4
  244. package/dist/lightweight-dependency-relations.js +13 -7
  245. package/dist/lightweight-dependency-top-level.js +63 -0
  246. package/dist/native-import-language-profiles.js +27 -1
  247. package/dist/native-js-ts-importers.js +9 -5
  248. package/dist/native-parser-ast-format-profiles.js +12 -0
  249. package/dist/native-parser-html-css-format-profiles.js +85 -0
  250. package/dist/native-region-scanner-core.js +5 -3
  251. package/dist/native-region-scanner-js-commonjs.js +155 -0
  252. package/dist/native-region-scanner-js-imports.js +51 -13
  253. package/dist/native-region-scanner-js-reexports.js +79 -0
  254. package/dist/native-region-scanner-js-ts-helpers.js +23 -0
  255. package/dist/native-source-ledger-helpers.js +1 -1
  256. package/dist/native-source-ledger.js +24 -10
  257. package/dist/native-source-maps-ecma426.js +316 -0
  258. package/dist/native-source-maps.js +36 -6
  259. package/dist/native-source-preservation-ownership.js +292 -0
  260. package/dist/native-source-preservation-scanner.js +63 -25
  261. package/dist/native-source-preservation-types.d.ts +3 -0
  262. package/dist/semantic-import-effect-occurrences.js +242 -0
  263. package/dist/semantic-import-effect-regions.js +95 -58
  264. package/dist/semantic-import-graph-layers.js +224 -0
  265. package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
  266. package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
  267. package/dist/semantic-import-runtime-exit-evidence.js +32 -0
  268. package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
  269. package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
  270. package/dist/semantic-import-runtime-order-evidence.js +318 -0
  271. package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
  272. package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
  273. package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
  274. package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
  275. package/dist/semantic-import-runtime-switch-evidence.js +304 -0
  276. package/dist/semantic-import-runtime-throw-evidence.js +44 -0
  277. package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
  278. package/dist/semantic-import-sidecar-entry.js +4 -0
  279. package/dist/semantic-import-source-preservation.js +6 -2
  280. package/package.json +1 -1
@@ -0,0 +1,209 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { compactRecord } from './js-ts-safe-merge-context.js';
3
+ import {
4
+ TypeScriptRefactorEvidenceMissingCode,
5
+ typeScriptRefactorEvidenceRecordsFromClassifications,
6
+ withTypeScriptRefactorEvidence
7
+ } from './internal/index-impl/typeScriptCompilerFacts.js';
8
+ import { classifyProjectSymbolMoves } from './js-ts-safe-project-merge-symbol-move.js';
9
+ import { maybeAdmitProjectSymbolMoveFile, projectSymbolMoveAdmissionSummary } from './js-ts-safe-project-merge-symbol-move-admission.js';
10
+
11
+ const requiredEvidence = [
12
+ 'path-lineage-evidence',
13
+ 'import-export-rewrite-evidence',
14
+ 'output-diagnostics-gate',
15
+ 'output-declaration-gate'
16
+ ];
17
+
18
+ function classifyProjectMoveRenames(files, input = {}, projectId = 'js_ts_project_safe_merge') {
19
+ const fileMoveRenames = [
20
+ ...classifyBranchMoveRenames(files, 'worker'),
21
+ ...classifyBranchMoveRenames(files, 'head')
22
+ ];
23
+ const classifications = [
24
+ ...fileMoveRenames,
25
+ ...classifyProjectSymbolMoves(input, files, projectId, fileMoveRenames)
26
+ ];
27
+ const byPath = new Map();
28
+ for (const classification of classifications) {
29
+ for (const sourcePath of classification.sourcePaths) {
30
+ const entries = byPath.get(sourcePath) ?? [];
31
+ entries.push(classification);
32
+ byPath.set(sourcePath, entries);
33
+ }
34
+ }
35
+ return { classifications, byPath, summary: projectMoveRenameSummary(classifications) };
36
+ }
37
+
38
+ function applyProjectMoveRenameClassifications(fileResults, projectMoveRenames, files = [], input = {}) {
39
+ if (!projectMoveRenames?.byPath?.size) return fileResults;
40
+ const filesByPath = new Map(files.map((file) => [file.sourcePath, file]));
41
+ const admissions = [];
42
+ const applied = fileResults.map((fileResult) => {
43
+ const classifications = projectMoveRenames.byPath.get(fileResult.sourcePath);
44
+ const file = filesByPath.get(fileResult.sourcePath);
45
+ const evidenceClassifications = classifications?.length
46
+ ? withTypeScriptRefactorEvidence(input, classifications, files)
47
+ : classifications;
48
+ const admission = evidenceClassifications?.length && file
49
+ ? maybeAdmitProjectSymbolMoveFile(fileResult, file, input, evidenceClassifications)
50
+ : undefined;
51
+ if (admission) admissions.push(...admission.admissions);
52
+ return admission?.fileResult ?? (evidenceClassifications?.length ? blockedMoveRenameFile(fileResult, evidenceClassifications) : fileResult);
53
+ });
54
+ projectMoveRenames.admissionSummary = projectSymbolMoveAdmissionSummary(admissions);
55
+ return applied;
56
+ }
57
+
58
+ function classifyBranchMoveRenames(files, branch) {
59
+ const sourceField = branch === 'worker' ? 'workerSourceText' : 'headSourceText';
60
+ const deletedFlag = branch === 'worker' ? 'workerDeleted' : 'headDeleted';
61
+ const otherSourceField = branch === 'worker' ? 'headSourceText' : 'workerSourceText';
62
+ const deleted = files
63
+ .filter((file) => typeof file.baseSourceText === 'string' && file[deletedFlag] === true)
64
+ .map((file) => ({ file, hash: hashText(file.baseSourceText) }))
65
+ .sort((left, right) => comparePath(left.file.sourcePath, right.file.sourcePath));
66
+ const addedByHash = new Map();
67
+ for (const file of files) {
68
+ if (typeof file.baseSourceText === 'string' || typeof file[sourceField] !== 'string') continue;
69
+ if (typeof file[otherSourceField] === 'string') continue;
70
+ const hash = hashText(file[sourceField]);
71
+ const entries = addedByHash.get(hash) ?? [];
72
+ entries.push(file);
73
+ addedByHash.set(hash, entries);
74
+ }
75
+ const used = new Set();
76
+ const results = [];
77
+ for (const deletion of deleted) {
78
+ const candidates = (addedByHash.get(deletion.hash) ?? []).filter((file) => !used.has(file.sourcePath));
79
+ if (candidates.length !== 1) continue;
80
+ const added = candidates[0];
81
+ used.add(added.sourcePath);
82
+ results.push(fileMoveRenameClassification(branch, deletion.file, added, deletion.hash));
83
+ }
84
+ return results;
85
+ }
86
+
87
+ function fileMoveRenameClassification(branch, fromFile, toFile, sourceHash) {
88
+ const code = `project-${branch}-file-move-rename-blocked`;
89
+ return {
90
+ kind: 'file-move-rename',
91
+ branch,
92
+ code,
93
+ operation: `blocked-${branch}-file-move-rename`,
94
+ sourcePaths: uniqueStrings([fromFile.sourcePath, toFile.sourcePath]),
95
+ details: compactRecord({
96
+ reasonCode: code,
97
+ conflictKey: `project-file-move-rename#${branch}#${fromFile.sourcePath}#${toFile.sourcePath}#${sourceHash}`,
98
+ branch,
99
+ fromSourcePath: fromFile.sourcePath,
100
+ toSourcePath: toFile.sourcePath,
101
+ movementKind: movementKind(fromFile.sourcePath, toFile.sourcePath),
102
+ sourceHash,
103
+ requiredEvidence
104
+ })
105
+ };
106
+ }
107
+
108
+ function blockedMoveRenameFile(fileResult, classifications) {
109
+ const typeScriptRefactorAdmissionEvidence = typeScriptRefactorEvidenceRecordsFromClassifications(classifications);
110
+ const conflicts = classifications.map((classification) => ({
111
+ code: classification.code,
112
+ gateId: 'project-move-rename-classifier',
113
+ message: classifierMessage(classification),
114
+ sourcePath: fileResult.sourcePath,
115
+ details: compactRecord({
116
+ ...classification.details,
117
+ sourcePath: fileResult.sourcePath,
118
+ pathRole: classification.pathRoles?.[fileResult.sourcePath]
119
+ })
120
+ }));
121
+ const reasonCodes = uniqueStrings(classifications.map((classification) => classification.code));
122
+ const conflictKeys = uniqueStrings([
123
+ ...(fileResult.conflictKeys ?? []),
124
+ ...conflicts.map((conflict) => conflict.details?.conflictKey)
125
+ ]);
126
+ return compactRecord({
127
+ kind: 'frontier.lang.jsTsProjectSafeMergeFile',
128
+ version: 1,
129
+ sourcePath: fileResult.sourcePath,
130
+ language: fileResult.language,
131
+ status: 'blocked',
132
+ operation: blockedOperation(classifications),
133
+ baseHash: fileResult.baseHash,
134
+ workerHash: fileResult.workerHash,
135
+ headHash: fileResult.headHash,
136
+ result: fileResult.result,
137
+ conflicts,
138
+ admission: {
139
+ status: 'blocked',
140
+ action: 'human-review',
141
+ reviewRequired: true,
142
+ autoApplyCandidate: false,
143
+ autoMergeClaim: false,
144
+ semanticEquivalenceClaim: false,
145
+ reasonCodes,
146
+ conflictKeys
147
+ },
148
+ summary: compactRecord({
149
+ ...(isPlainObject(fileResult.summary) ? fileResult.summary : {}),
150
+ conflicts: conflicts.length,
151
+ typeScriptRefactorAdmissionEvidence: nonEmptyArray(typeScriptRefactorAdmissionEvidence),
152
+ projectMoveRenameClassifications: classifications.map((classification) => classification.details)
153
+ }),
154
+ conflictKeys
155
+ });
156
+ }
157
+
158
+ function projectMoveRenameSummary(classifications) {
159
+ return {
160
+ classifications: classifications.length,
161
+ fileMoveRenames: classifications.filter((classification) => classification.kind === 'file-move-rename').length,
162
+ symbolMoves: classifications.filter((classification) => classification.kind === 'exported-symbol-move' || classification.kind === 'imported-symbol-move').length,
163
+ exportedSymbolMoves: classifications.filter((classification) => classification.kind === 'exported-symbol-move').length,
164
+ importedSymbolMoves: classifications.filter((classification) => classification.kind === 'imported-symbol-move').length,
165
+ reasonCodes: uniqueStrings(classifications.map((classification) => classification.code))
166
+ };
167
+ }
168
+
169
+ function classifierMessage(classification) {
170
+ if (classification.code === TypeScriptRefactorEvidenceMissingCode) {
171
+ return `Project ${classification.branch} symbol move requires caller-supplied TypeScript refactor reference evidence.`;
172
+ }
173
+ if (classification.kind === 'exported-symbol-move') {
174
+ return `Project ${classification.branch} exported symbol move requires lineage, import/export rewrite, diagnostics, and declaration evidence.`;
175
+ }
176
+ if (classification.kind === 'imported-symbol-move') {
177
+ return `Project ${classification.branch} imported symbol move requires lineage, import/export rewrite, diagnostics, and declaration evidence.`;
178
+ }
179
+ return `Project ${classification.branch} file move/rename requires path lineage, rewrite, diagnostics, and declaration evidence.`;
180
+ }
181
+
182
+ function blockedOperation(classifications) {
183
+ const operations = uniqueStrings(classifications.map((classification) => classification.operation));
184
+ return operations.length === 1 ? operations[0] : 'blocked-project-move-rename';
185
+ }
186
+
187
+ function movementKind(fromPath, toPath) {
188
+ const fromName = String(fromPath ?? '').split('/').pop();
189
+ const toName = String(toPath ?? '').split('/').pop();
190
+ if (fromName === toName) return 'move';
191
+ if (dirname(fromPath) === dirname(toPath)) return 'rename';
192
+ return 'move-rename';
193
+ }
194
+
195
+ function dirname(path) {
196
+ const text = String(path ?? '');
197
+ const slash = text.lastIndexOf('/');
198
+ return slash === -1 ? '' : text.slice(0, slash);
199
+ }
200
+
201
+ function hashText(text) { return typeof text === 'string' ? hashSemanticValue(text) : undefined; }
202
+ function comparePath(left, right) { return String(left ?? '').localeCompare(String(right ?? '')); }
203
+ function isPlainObject(value) { return Boolean(value && typeof value === 'object' && !Array.isArray(value)); }
204
+ function nonEmptyArray(value) { return Array.isArray(value) && value.length ? value : undefined; }
205
+ function uniqueStrings(values) {
206
+ return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))];
207
+ }
208
+
209
+ export { applyProjectMoveRenameClassifications, classifyProjectMoveRenames };
@@ -0,0 +1,44 @@
1
+ function projectProofEvidenceConflicts(proofEvidence) {
2
+ return (proofEvidence?.records ?? [])
3
+ .filter((record) => record?.status === 'failed' && record.level === 'source-span-roundtrip' && Number(record.metadata?.admissionBlockingFailedSourceResults ?? 0) > 0)
4
+ .map(sourceSpanRoundtripProofConflict);
5
+ }
6
+
7
+ function sourceSpanRoundtripProofConflict(record) {
8
+ return {
9
+ code: 'project-source-span-roundtrip-proof-failed',
10
+ gateId: 'project-proof-evidence',
11
+ message: 'Project source-span roundtrip proof failed; output source admission requires review.',
12
+ sourcePath: record.metadata?.sourcePath,
13
+ severity: 'error',
14
+ details: compactRecord({
15
+ reasonCode: 'project-source-span-roundtrip-proof-failed',
16
+ conflictKey: `project-proof#${record.level}`,
17
+ proofLevel: record.level,
18
+ evidenceId: record.id,
19
+ scope: record.scope,
20
+ status: record.status,
21
+ summary: record.summary,
22
+ outputFiles: record.metadata?.outputFiles,
23
+ changedOutputFiles: record.metadata?.changedOutputFiles,
24
+ changedSourceResults: record.metadata?.changedSourceResults,
25
+ failedSourceResults: record.metadata?.failedSourceResults,
26
+ admissionBlockingFailedSourceResults: record.metadata?.admissionBlockingFailedSourceResults,
27
+ sourceSpanRoundtripAdmissionBlockerSourcePaths: record.metadata?.sourceSpanRoundtripAdmissionBlockerSourcePaths,
28
+ missingSourceResults: record.metadata?.missingSourceResults,
29
+ missingRequiredSourceResults: record.metadata?.missingRequiredSourceResults,
30
+ sourceSpanOperations: record.metadata?.sourceSpanOperations,
31
+ projectionEdits: record.metadata?.projectionEdits,
32
+ spanLinkedProjectionEdits: record.metadata?.spanLinkedProjectionEdits,
33
+ parserTriviaExactnessStatus: record.metadata?.parserTriviaExactnessStatus,
34
+ parserTriviaExactnessReasonCodes: record.metadata?.parserTriviaExactnessReasonCodes,
35
+ parserTriviaExactnessBlockReasonCodes: record.metadata?.parserTriviaExactnessBlockReasonCodes,
36
+ autoMergeClaim: false,
37
+ semanticEquivalenceClaim: false
38
+ })
39
+ };
40
+ }
41
+
42
+ function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined && (!Array.isArray(value) || value.length > 0))); }
43
+
44
+ export { projectProofEvidenceConflicts };
@@ -0,0 +1,320 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { compactRecord } from './js-ts-safe-merge-context.js';
3
+ import { missingEvidenceRouteForSignal } from './js-ts-safe-project-merge-missing-evidence.js';
4
+ import { semanticEditReplayCleanEvidence } from './js-ts-safe-project-merge-semantic-replay-proof.js';
5
+ import { ExternalSemanticEquivalenceLevel, semanticEquivalenceExternalEvidence } from './js-ts-safe-project-merge-semantic-equivalence-proof.js';
6
+ import { sourceSpanRoundtripEvidence } from './js-ts-safe-project-merge-source-span-roundtrip-proof.js';
7
+ import { unsupportedJsTsSurfaceEvidence } from './js-ts-safe-project-merge-unsupported-surfaces.js';
8
+
9
+ const JsTsProjectMergeProofLevels = Object.freeze({
10
+ syntaxIdentity: 'syntax-identity',
11
+ sourceSpanRoundtrip: 'source-span-roundtrip',
12
+ semanticEditReplayClean: 'semantic-edit-replay-clean',
13
+ parserRoundtrip: 'parser-roundtrip',
14
+ diagnosticsClean: 'diagnostics-clean',
15
+ declarationOutputStable: 'declaration-output-stable',
16
+ focusedTestPassed: 'focused-test-passed',
17
+ unsupportedJsTsSurfaceReview: 'unsupported-js-ts-surface-review',
18
+ semanticEquivalenceExternal: ExternalSemanticEquivalenceLevel,
19
+ semanticEquivalenceUnknown: 'semantic-equivalence-unknown'
20
+ });
21
+
22
+ function createJsTsProjectMergeProofEvidence(input = {}) {
23
+ const id = String(input.id ?? 'js_ts_project_safe_merge');
24
+ const records = [
25
+ syntaxIdentityEvidence(id, input.fileResults ?? []),
26
+ sourceSpanRoundtripEvidence(id, input.fileResults ?? [], JsTsProjectMergeProofLevels.sourceSpanRoundtrip, JsTsProjectMergeProofLevels.parserRoundtrip),
27
+ semanticEditReplayCleanEvidence(id, input.fileResults ?? [], JsTsProjectMergeProofLevels.semanticEditReplayClean),
28
+ diagnosticsCleanEvidence(id, input.outputDiagnosticsGate),
29
+ declarationOutputStableEvidence(id, input.outputDeclarationGate),
30
+ focusedTestPassedEvidence(id, input.outputQualityGate),
31
+ unsupportedJsTsSurfaceEvidence(id, input.files ?? [], input.fileResults ?? []),
32
+ semanticEquivalenceExternalEvidence(id, input),
33
+ semanticEquivalenceExternalEvidence(id, input)?.status === 'passed' ? undefined : semanticEquivalenceUnknownEvidence(id)
34
+ ].filter(Boolean);
35
+ const summary = proofEvidenceSummary(records);
36
+ const core = {
37
+ kind: 'frontier.lang.jsTsProjectMergeProofEvidence',
38
+ version: 1,
39
+ schema: 'frontier.lang.jsTsProjectMergeProofEvidence.v1',
40
+ id: `${id}_proof_evidence`,
41
+ status: summary.failed ? 'failed-evidence' : summary.missingLevels.length ? 'review-evidence-missing' : 'evidence-only',
42
+ semanticEquivalenceLevel: summary.semanticEquivalenceLevel,
43
+ autoMergeClaim: false,
44
+ semanticEquivalenceClaim: summary.semanticEquivalenceClaim,
45
+ records,
46
+ summary,
47
+ metadata: {
48
+ evidenceOnly: true,
49
+ proofClaims: summary.proofClaims,
50
+ note: summary.semanticEquivalenceClaim ? 'External semantic equivalence proof is source/output/gate-bound; autoMergeClaim remains false.' : 'JS/TS project merge proof levels record bounded admission evidence only; executable semantic equivalence remains unknown.',
51
+ missingLevels: summary.missingLevels,
52
+ missingSignals: summary.missingSignals,
53
+ nextMissingEvidence: summary.nextMissingEvidence,
54
+ nextMissingSignal: summary.nextMissingSignal,
55
+ autoMergeClaim: false,
56
+ semanticEquivalenceClaim: summary.semanticEquivalenceClaim
57
+ }
58
+ };
59
+ return { ...core, hash: hashSemanticValue(core) };
60
+ }
61
+
62
+ function syntaxIdentityEvidence(id, fileResults) {
63
+ const outputFiles = fileResults.filter((file) => typeof file.outputSourceText === 'string');
64
+ const changedFiles = outputFiles.filter((file) => !hashMatchesAnyInput(file));
65
+ const allInputHashes = outputFiles.filter((file) => hashMatchesAnyInput(file)).length;
66
+ const status = outputFiles.length && allInputHashes === outputFiles.length ? 'passed' : 'skipped';
67
+ return evidenceRecord({
68
+ id,
69
+ suffix: 'syntax_identity',
70
+ level: JsTsProjectMergeProofLevels.syntaxIdentity,
71
+ status,
72
+ scope: 'project-source',
73
+ summary: status === 'passed'
74
+ ? `All ${outputFiles.length} output file(s) are byte-identical to an input side.`
75
+ : 'Project output changed source text, so syntax identity evidence is not asserted.',
76
+ metadata: {
77
+ outputFiles: outputFiles.length,
78
+ syntaxIdentityFiles: allInputHashes,
79
+ changedOutputFiles: changedFiles.length
80
+ }
81
+ });
82
+ }
83
+
84
+ function diagnosticsCleanEvidence(id, gate) {
85
+ if (!gate) {
86
+ return evidenceRecord({
87
+ id,
88
+ suffix: 'diagnostics_clean',
89
+ level: JsTsProjectMergeProofLevels.diagnosticsClean,
90
+ status: 'skipped',
91
+ scope: 'project-output',
92
+ summary: 'No output diagnostics gate was provided.',
93
+ metadata: {
94
+ diagnosticsGate: 'absent',
95
+ missingSignal: 'output-diagnostics-gate-not-run',
96
+ nextAction: 'Run or supply output diagnostics before treating project output as evidence-complete.'
97
+ }
98
+ });
99
+ }
100
+ const status = gate.status === 'passed' ? 'passed' : 'failed';
101
+ return evidenceRecord({
102
+ id,
103
+ suffix: 'diagnostics_clean',
104
+ level: JsTsProjectMergeProofLevels.diagnosticsClean,
105
+ status,
106
+ scope: 'project-output',
107
+ summary: status === 'passed'
108
+ ? `Output diagnostics gate passed with ${gate.summary?.diagnostics ?? gate.diagnostics?.length ?? 0} diagnostic record(s).`
109
+ : `Output diagnostics gate did not pass: ${gate.conflicts?.length ?? 0} conflict(s).`,
110
+ metadata: {
111
+ gateId: gate.id,
112
+ diagnostics: gate.summary?.diagnostics ?? gate.diagnostics?.length,
113
+ conflicts: gate.summary?.conflicts ?? gate.conflicts?.length,
114
+ diagnosticSource: gate.metadata?.diagnosticSource
115
+ }
116
+ });
117
+ }
118
+
119
+ function declarationOutputStableEvidence(id, gate) {
120
+ if (!gate) {
121
+ return evidenceRecord({
122
+ id,
123
+ suffix: 'declaration_output_stable',
124
+ level: JsTsProjectMergeProofLevels.declarationOutputStable,
125
+ status: 'skipped',
126
+ scope: 'project-output',
127
+ summary: 'No declaration output gate was provided.',
128
+ metadata: {
129
+ declarationGate: 'absent',
130
+ missingSignal: 'declaration-gate-not-run',
131
+ nextAction: 'Run or supply declaration output evidence before applying public API-sensitive project output.'
132
+ }
133
+ });
134
+ }
135
+ const status = gate.status === 'passed' ? 'passed' : gate.status === 'skipped' ? 'skipped' : 'failed';
136
+ return evidenceRecord({
137
+ id,
138
+ suffix: 'declaration_output_stable',
139
+ level: JsTsProjectMergeProofLevels.declarationOutputStable,
140
+ status,
141
+ scope: 'project-output',
142
+ summary: status === 'passed'
143
+ ? `Declaration output gate passed with ${gate.summary?.declarationFiles ?? gate.declarationFiles?.length ?? 0} declaration file(s).`
144
+ : status === 'failed'
145
+ ? `Declaration output gate did not pass: ${gate.conflicts?.length ?? 0} conflict(s).`
146
+ : 'Declaration output gate was skipped.',
147
+ metadata: {
148
+ gateId: gate.id,
149
+ declarationFiles: gate.summary?.declarationFiles ?? gate.declarationFiles?.length,
150
+ declarationBytes: gate.summary?.declarationBytes,
151
+ conflicts: gate.summary?.conflicts ?? gate.conflicts?.length
152
+ }
153
+ });
154
+ }
155
+
156
+ function focusedTestPassedEvidence(id, gate) {
157
+ const testGates = (gate?.gates ?? []).filter((entry) => entry.category === 'test');
158
+ if (!testGates.length) {
159
+ return evidenceRecord({
160
+ id,
161
+ suffix: 'focused_test_passed',
162
+ level: JsTsProjectMergeProofLevels.focusedTestPassed,
163
+ status: 'skipped',
164
+ scope: 'quality-gates',
165
+ summary: 'No focused test quality gate was supplied.',
166
+ metadata: {
167
+ testGates: 0,
168
+ missingSignal: 'focused-test-gate-not-run',
169
+ nextAction: 'Attach at least one passing focused test gate for the changed project behavior.'
170
+ }
171
+ });
172
+ }
173
+ const failed = testGates.filter((entry) => !isPassStatus(entry.status));
174
+ const status = failed.length ? 'failed' : 'passed';
175
+ return evidenceRecord({
176
+ id,
177
+ suffix: 'focused_test_passed',
178
+ level: JsTsProjectMergeProofLevels.focusedTestPassed,
179
+ status,
180
+ scope: 'quality-gates',
181
+ summary: status === 'passed'
182
+ ? `Focused test evidence passed for ${testGates.length} gate(s).`
183
+ : `Focused test evidence failed for ${failed.length} gate(s).`,
184
+ metadata: {
185
+ testGates: testGates.length,
186
+ failedTestGates: failed.length,
187
+ evidenceIds: testGates.map((entry) => entry.evidenceId).filter(Boolean),
188
+ commands: testGates.map((entry) => entry.command).filter(Boolean)
189
+ }
190
+ });
191
+ }
192
+ function semanticEquivalenceUnknownEvidence(id) {
193
+ return evidenceRecord({
194
+ id,
195
+ suffix: 'semantic_equivalence_unknown',
196
+ level: JsTsProjectMergeProofLevels.semanticEquivalenceUnknown,
197
+ status: 'unknown',
198
+ scope: 'project',
199
+ claimKind: 'semantic-equivalence-upper-bound',
200
+ summary: 'No universal semantic equivalence proof is claimed for JS/TS project merge admission.',
201
+ metadata: {
202
+ executableSemanticEquivalence: 'unknown',
203
+ requiresHumanOrExternalProof: true,
204
+ missingSignal: 'semantic-equivalence-proof-not-available',
205
+ nextAction: 'Keep semanticEquivalenceClaim false unless a human or external verifier supplies an executable equivalence proof.'
206
+ }
207
+ });
208
+ }
209
+
210
+ function evidenceRecord(input) {
211
+ return {
212
+ id: `${input.id}_proof_${input.suffix}`,
213
+ kind: 'js-ts-project-merge-proof-evidence',
214
+ level: input.level,
215
+ status: input.status,
216
+ scope: input.scope,
217
+ claimKind: input.claimKind ?? 'evidence',
218
+ evidenceOnly: true,
219
+ proofClaim: false,
220
+ autoMergeClaim: false,
221
+ semanticEquivalenceClaim: false,
222
+ summary: input.summary,
223
+ metadata: compactRecord({
224
+ ...(input.metadata ?? {}),
225
+ proofClaim: false,
226
+ autoMergeClaim: false,
227
+ semanticEquivalenceClaim: false
228
+ })
229
+ };
230
+ }
231
+
232
+ function proofEvidenceSummary(records) {
233
+ const counts = countBy(records, (record) => record.status);
234
+ const missingRecords = records.filter(isMissingProofRecord);
235
+ const missingEvidence = missingRecords.map(proofMissingEvidence);
236
+ const levelStatuses = Object.fromEntries(records.map((record) => [record.level, record.status]));
237
+ const recordIdsByLevel = Object.fromEntries(records.map((record) => [record.level, record.id]));
238
+ const missingSignals = uniqueStrings(missingEvidence.map((item) => item.code));
239
+ const unsupportedSurfaces = records.flatMap((record) => record.metadata?.surfaceEvidence ?? []);
240
+ const unsupportedSurfaceProofGaps = unsupportedSurfaces.map((surface) => surface.remainingProofGap).filter((gap) => gap?.routeId);
241
+ return {
242
+ records: records.length,
243
+ passed: counts.passed ?? 0,
244
+ failed: counts.failed ?? 0,
245
+ skipped: counts.skipped ?? 0,
246
+ unknown: counts.unknown ?? 0,
247
+ evidenceLevels: records.map((record) => record.level),
248
+ passedLevels: records.filter((record) => record.status === 'passed').map((record) => record.level),
249
+ failedLevels: records.filter((record) => record.status === 'failed').map((record) => record.level),
250
+ skippedLevels: records.filter((record) => record.status === 'skipped').map((record) => record.level),
251
+ unknownLevels: records.filter((record) => record.status === 'unknown').map((record) => record.level),
252
+ levelStatuses,
253
+ recordIdsByLevel,
254
+ missingLevels: uniqueStrings(missingRecords.map((record) => record.level)),
255
+ missingSignals,
256
+ unsupportedSurfaceEvidenceCount: unsupportedSurfaces.length,
257
+ unsupportedSurfaceKinds: uniqueStrings(unsupportedSurfaces.map((surface) => surface.kind)),
258
+ unsupportedSurfaceReasonCodes: uniqueStrings(unsupportedSurfaces.map((surface) => surface.reasonCode)),
259
+ unsupportedSurfaceProofGapRouteIds: uniqueStrings(unsupportedSurfaceProofGaps.map((gap) => gap.routeId)),
260
+ unsupportedSurfaceProofGapRouteLanes: uniqueStrings(unsupportedSurfaceProofGaps.map((gap) => gap.routeLane)),
261
+ unsupportedSurfaceProofGapRouteCounts: countPresent(unsupportedSurfaceProofGaps, (gap) => gap.routeId), unsupportedSurfaceProofGapRouteLaneCounts: countPresent(unsupportedSurfaceProofGaps, (gap) => gap.routeLane),
262
+ nextUnsupportedSurfaceProofGapRouteId: unsupportedSurfaceProofGaps[0]?.routeId, nextUnsupportedSurfaceProofGapRouteLane: unsupportedSurfaceProofGaps[0]?.routeLane, nextUnsupportedSurfaceProofGapCode: unsupportedSurfaceProofGaps[0]?.code,
263
+ missingEvidence,
264
+ nextMissingEvidence: missingEvidence[0],
265
+ nextMissingSignal: missingEvidence[0]?.code,
266
+ semanticEquivalenceLevel: levelStatuses[ExternalSemanticEquivalenceLevel] === 'passed' ? ExternalSemanticEquivalenceLevel : JsTsProjectMergeProofLevels.semanticEquivalenceUnknown,
267
+ semanticEquivalenceClaim: levelStatuses[ExternalSemanticEquivalenceLevel] === 'passed',
268
+ semanticEquivalenceUnknown: levelStatuses[ExternalSemanticEquivalenceLevel] !== 'passed',
269
+ evidenceOnly: true,
270
+ proofClaims: records.filter((record) => record.proofClaim === true || record.semanticEquivalenceClaim === true).length
271
+ };
272
+ }
273
+
274
+ function isMissingProofRecord(record) {
275
+ return Boolean(record?.metadata?.missingSignal);
276
+ }
277
+
278
+ function proofMissingEvidence(record) {
279
+ const route = missingEvidenceRouteForSignal(record.metadata?.missingSignal);
280
+ return compactRecord({
281
+ code: record.metadata?.missingSignal,
282
+ kind: 'proof-level',
283
+ scope: record.scope,
284
+ status: record.status === 'unknown' ? 'unknown' : 'missing',
285
+ proofLevel: record.level,
286
+ action: 'review',
287
+ route,
288
+ routeId: route?.id,
289
+ routeLane: route?.lane,
290
+ routeNext: route?.next,
291
+ evidenceId: record.id,
292
+ summary: record.summary,
293
+ nextAction: record.metadata?.nextAction,
294
+ autoMergeClaim: false,
295
+ semanticEquivalenceClaim: false
296
+ });
297
+ }
298
+
299
+ function hashMatchesAnyInput(file) {
300
+ return [file.baseHash, file.workerHash, file.headHash].filter(Boolean).includes(file.outputHash);
301
+ }
302
+
303
+ function isPassStatus(value) {
304
+ return ['passed', 'pass', 'ok', 'clean', 'accepted-clean', 'success'].includes(String(value ?? '').toLowerCase());
305
+ }
306
+
307
+ function countBy(values, keyFor) {
308
+ const result = {};
309
+ for (const value of values) {
310
+ const key = keyFor(value);
311
+ result[key] = (result[key] ?? 0) + 1;
312
+ }
313
+ return result;
314
+ }
315
+
316
+ function countPresent(values, keyFor) { const result = {}; for (const value of values) { const key = keyFor(value); if (typeof key === 'string' && key.length) result[key] = (result[key] ?? 0) + 1; } return result; }
317
+
318
+ function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
319
+
320
+ export { JsTsProjectMergeProofLevels, createJsTsProjectMergeProofEvidence };