@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,161 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { compactRecord } from './js-ts-safe-merge-context.js';
3
+ import { projectAdmissionRouteFromExactAdmission } from './js-ts-safe-project-merge-admission-routes.js';
4
+
5
+ function createExactBranchProjectSemanticEditAdmissionFile(options) {
6
+ const {
7
+ fileResult,
8
+ file,
9
+ classifications = [],
10
+ admissionKind,
11
+ action,
12
+ operation,
13
+ summaryKey,
14
+ evidenceKey,
15
+ metadataKey,
16
+ requireOtherBranchUnchanged = true,
17
+ requireBaseForOtherBranchUnchanged = true,
18
+ allowDeletedBranchOutput = false,
19
+ allowExistingExactOutput = false,
20
+ classificationFilter = () => true,
21
+ admissionFields = () => ({}),
22
+ details = (classification) => classification.details
23
+ } = options;
24
+ if (!classifications.length || !classifications.every(classificationFilter)) return undefined;
25
+ const branches = uniqueStrings(classifications.map((classification) => classification.branch));
26
+ if (branches.length !== 1) return undefined;
27
+ const branch = branches[0];
28
+ const admissions = classifications
29
+ .map((classification) => exactBranchProjectSemanticEditAdmission({
30
+ fileResult,
31
+ file,
32
+ classification,
33
+ admissionKind,
34
+ requireOtherBranchUnchanged,
35
+ requireBaseForOtherBranchUnchanged,
36
+ allowDeletedBranchOutput,
37
+ allowExistingExactOutput,
38
+ admissionFields,
39
+ details
40
+ }))
41
+ .filter(Boolean);
42
+ if (admissions.length !== classifications.length) return undefined;
43
+ const branchText = branchSourceText(file, branch);
44
+ const outputHash = hashProjectSourceText(branchText);
45
+ return {
46
+ admissions,
47
+ fileResult: compactRecord({
48
+ ...fileResult,
49
+ status: 'merged',
50
+ operation: typeof operation === 'function' ? operation(fileResult) : operation,
51
+ outputSourceText: branchText,
52
+ outputHash,
53
+ baseHash: hashProjectSourceText(file.baseSourceText),
54
+ workerHash: hashProjectSourceText(branchSourceText(file, 'worker')),
55
+ headHash: hashProjectSourceText(branchSourceText(file, 'head')),
56
+ result: fileResult.status === 'merged' ? fileResult.result : undefined,
57
+ semanticArtifacts: fileResult.status === 'merged' ? fileResult.semanticArtifacts : undefined,
58
+ conflicts: [],
59
+ admission: exactBranchProjectSemanticEditFileAdmission(action),
60
+ summary: compactRecord({
61
+ ...(isPlainObject(fileResult.summary) ? fileResult.summary : {}),
62
+ conflicts: 0,
63
+ [summaryKey]: admissions.length,
64
+ [evidenceKey]: admissions
65
+ }),
66
+ metadata: metadataKey ? compactRecord({
67
+ ...(isPlainObject(fileResult.metadata) ? fileResult.metadata : {}),
68
+ [metadataKey]: admissions
69
+ }) : fileResult.metadata
70
+ })
71
+ };
72
+ }
73
+
74
+ function exactBranchProjectSemanticEditAdmission(options) {
75
+ const { fileResult, file, classification, admissionKind, requireOtherBranchUnchanged, requireBaseForOtherBranchUnchanged, allowDeletedBranchOutput, allowExistingExactOutput, admissionFields, details } = options;
76
+ const branchText = branchSourceText(file, classification.branch);
77
+ if (typeof branchText !== 'string' && !allowDeletedBranchOutput) return undefined;
78
+ const exactMergedOutput = fileResult.status === 'merged' && fileResult.outputSourceText === branchText;
79
+ if (!exactMergedOutput || !allowExistingExactOutput) {
80
+ if (requireOtherBranchUnchanged && !otherProjectBranchUnchanged(file, classification.branch, { requireBase: requireBaseForOtherBranchUnchanged })) return undefined;
81
+ }
82
+ const outputHash = hashProjectSourceText(branchText);
83
+ const admission = {
84
+ id: safeProjectEvidenceId(`${classification.details?.conflictKey ?? classification.code}_${file.sourcePath}`),
85
+ kind: admissionKind,
86
+ status: 'passed',
87
+ branch: classification.branch,
88
+ ...(admissionFields(classification) ?? {}),
89
+ sourcePath: file.sourcePath,
90
+ outputHash,
91
+ sourceHash: outputHash,
92
+ summary: `Project ${classification.branch} semantic edit output matched branch ${typeof branchText === 'string' ? 'source' : 'deletion'} for ${file.sourcePath}.`,
93
+ details: compactRecord({
94
+ ...(details(classification) ?? {}),
95
+ sourcePath: file.sourcePath,
96
+ outputHash,
97
+ exactBranchOutput: true,
98
+ deletedOutput: typeof branchText !== 'string' || undefined,
99
+ autoMergeClaim: false,
100
+ semanticEquivalenceClaim: false
101
+ })
102
+ };
103
+ return { ...admission, admissionRoute: projectAdmissionRouteFromExactAdmission(admission, { action: options.action }) };
104
+ }
105
+
106
+ function exactBranchProjectSemanticEditFileAdmission(action) {
107
+ return {
108
+ status: 'auto-merge-candidate',
109
+ action,
110
+ reviewRequired: false,
111
+ autoApplyCandidate: true,
112
+ autoMergeClaim: false,
113
+ semanticEquivalenceClaim: false,
114
+ reasonCodes: []
115
+ };
116
+ }
117
+
118
+ function summarizeProjectSemanticEditAdmissions(admissions = [], fields = {}) {
119
+ const unique = uniqueProjectSemanticEditAdmissions(admissions);
120
+ const summary = { [fields.totalKey ?? 'admissions']: unique.length };
121
+ for (const field of fields.byKind ?? []) {
122
+ summary[field.key] = unique.filter((admission) => admission[field.property] === field.value).length;
123
+ }
124
+ if (fields.evidenceIdsKey) summary[fields.evidenceIdsKey] = unique.map((admission) => admission.id);
125
+ return summary;
126
+ }
127
+
128
+ function uniqueProjectSemanticEditAdmissions(admissions) {
129
+ const seen = new Set();
130
+ return admissions.filter((admission) => {
131
+ const key = admission.details?.conflictKey ?? admission.id;
132
+ if (!key || seen.has(key)) return false;
133
+ seen.add(key);
134
+ return true;
135
+ });
136
+ }
137
+
138
+ function branchSourceText(file, branch) {
139
+ if (branch === 'worker') return file.workerDeleted ? undefined : file.workerSourceText ?? file.baseSourceText;
140
+ return file.headDeleted ? undefined : file.headSourceText ?? file.baseSourceText;
141
+ }
142
+
143
+ function otherProjectBranchUnchanged(file, branch, options = {}) {
144
+ const other = branch === 'worker' ? branchSourceText(file, 'head') : branchSourceText(file, 'worker');
145
+ return (options.requireBase === false || typeof file.baseSourceText === 'string') && other === file.baseSourceText;
146
+ }
147
+
148
+ function hashProjectSourceText(text) { return typeof text === 'string' ? hashSemanticValue(text) : undefined; }
149
+ function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
150
+ function isPlainObject(value) { return Boolean(value && typeof value === 'object' && !Array.isArray(value)); }
151
+ function safeProjectEvidenceId(value) { return String(value ?? 'unknown').replace(/[^a-zA-Z0-9]+/g, '_').replace(/^_+|_+$/g, '') || 'evidence'; }
152
+
153
+ export {
154
+ branchSourceText,
155
+ createExactBranchProjectSemanticEditAdmissionFile,
156
+ hashProjectSourceText,
157
+ otherProjectBranchUnchanged,
158
+ safeProjectEvidenceId,
159
+ summarizeProjectSemanticEditAdmissions,
160
+ uniqueProjectSemanticEditAdmissions
161
+ };
@@ -0,0 +1,110 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { compactRecord } from './js-ts-safe-merge-context.js';
3
+ import { globalAugmentationCompatibilityAssessment } from './js-ts-safe-project-merge-global-augmentation-compatibility.js';
4
+
5
+ const ambientRequiredEvidence = [
6
+ 'typescript-program-symbol-evidence',
7
+ 'declaration-output-gate',
8
+ 'consumer-diagnostics-gate',
9
+ 'global-augmentation-compatibility-evidence'
10
+ ];
11
+
12
+ function maybeBlockAmbientProjectFile(file, context, input = {}) {
13
+ const changed = changedProjectTexts(file);
14
+ if (!changed.length) return undefined;
15
+ const sourceText = changed.map((entry) => entry.sourceText).join('\n');
16
+ const ambient = ambientReason(file.sourcePath, sourceText);
17
+ if (!ambient) return undefined;
18
+ const compatibility = ambient.surface === 'global-augmentation'
19
+ ? globalAugmentationCompatibilityAssessment({
20
+ sourcePath: file.sourcePath,
21
+ sourceHashes: uniqueStrings(changed.map((entry) => hashText(entry.sourceText))),
22
+ moduleName: 'global',
23
+ surfaceKind: 'global-augmentation'
24
+ }, input)
25
+ : undefined;
26
+ if (compatibility?.status === 'passed') return undefined;
27
+ return blockedAmbientFile(file, context, ambient, compatibility);
28
+ }
29
+
30
+ function changedProjectTexts(file) {
31
+ const entries = [];
32
+ if (typeof file.workerSourceText === 'string' && file.workerSourceText !== file.baseSourceText) {
33
+ entries.push({ branch: 'worker', sourceText: file.workerSourceText });
34
+ }
35
+ if (typeof file.headSourceText === 'string' && file.headSourceText !== file.baseSourceText) {
36
+ entries.push({ branch: 'head', sourceText: file.headSourceText });
37
+ }
38
+ if (file.workerDeleted || file.headDeleted) entries.push({ branch: file.workerDeleted ? 'worker' : 'head', sourceText: file.baseSourceText ?? '' });
39
+ return entries;
40
+ }
41
+
42
+ function ambientReason(sourcePath, sourceText) {
43
+ if (/\.d\.[cm]?ts$/i.test(String(sourcePath ?? ''))) {
44
+ return { code: 'project-ambient-declaration-merge-blocked', operation: 'blocked-ambient-declaration', surface: 'declaration-file' };
45
+ }
46
+ if (/\bdeclare\s+global\b|\bdeclare\s+module\s+['"]|\bglobalThis\b/.test(String(sourceText ?? ''))) {
47
+ return { code: 'project-global-augmentation-merge-blocked', operation: 'blocked-global-augmentation', surface: 'global-augmentation' };
48
+ }
49
+ return undefined;
50
+ }
51
+
52
+ function blockedAmbientFile(file, context, ambient, compatibility = undefined) {
53
+ const conflict = {
54
+ code: ambient.code,
55
+ gateId: 'project-ambient-declaration-classifier',
56
+ message: `Project ${ambient.surface} changes require TypeScript program, declaration, and consumer diagnostics evidence.`,
57
+ sourcePath: file.sourcePath,
58
+ details: compactRecord({
59
+ reasonCode: ambient.code,
60
+ conflictKey: `project-ambient#${ambient.surface}#${file.sourcePath}`,
61
+ sourcePath: file.sourcePath,
62
+ surface: ambient.surface,
63
+ baseHash: hashText(file.baseSourceText),
64
+ workerHash: hashText(file.workerSourceText),
65
+ headHash: hashText(file.headSourceText),
66
+ requiredEvidence: ambientRequiredEvidence,
67
+ routeId: compatibility?.routeId,
68
+ routeLane: compatibility?.routeLane,
69
+ routeNext: compatibility?.routeNext,
70
+ reasonCodes: compatibility?.reasonCodes,
71
+ globalAugmentationCompatibilityProof: compatibility?.record,
72
+ autoMergeClaim: false,
73
+ semanticEquivalenceClaim: false
74
+ })
75
+ };
76
+ return compactRecord({
77
+ kind: 'frontier.lang.jsTsProjectSafeMergeFile',
78
+ version: 1,
79
+ sourcePath: file.sourcePath,
80
+ language: context.language,
81
+ status: 'blocked',
82
+ operation: ambient.operation,
83
+ baseHash: hashText(file.baseSourceText),
84
+ workerHash: hashText(file.workerSourceText),
85
+ headHash: hashText(file.headSourceText),
86
+ conflicts: [conflict],
87
+ admission: {
88
+ status: 'blocked',
89
+ action: 'human-review',
90
+ reviewRequired: true,
91
+ autoApplyCandidate: false,
92
+ autoMergeClaim: false,
93
+ semanticEquivalenceClaim: false,
94
+ reasonCodes: [ambient.code],
95
+ conflictKeys: [conflict.details.conflictKey]
96
+ },
97
+ summary: { conflicts: 1, projectAmbientDeclarationClassification: true },
98
+ conflictKeys: [conflict.details.conflictKey]
99
+ });
100
+ }
101
+
102
+ function hashText(text) {
103
+ return typeof text === 'string' ? hashSemanticValue(text) : undefined;
104
+ }
105
+
106
+ function uniqueStrings(values) {
107
+ return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))];
108
+ }
109
+
110
+ export { maybeBlockAmbientProjectFile };
@@ -0,0 +1,85 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { compactRecord } from './js-ts-safe-merge-context.js';
3
+
4
+ function syntheticFile(file, context, sourceText, operation) {
5
+ return compactRecord({
6
+ kind: 'frontier.lang.jsTsProjectSafeMergeFile',
7
+ version: 1,
8
+ sourcePath: file.sourcePath,
9
+ language: context.language,
10
+ status: 'merged',
11
+ operation,
12
+ outputSourceText: sourceText,
13
+ outputHash: hashText(sourceText),
14
+ baseHash: hashText(file.baseSourceText),
15
+ workerHash: hashText(file.workerSourceText),
16
+ headHash: hashText(file.headSourceText),
17
+ conflicts: [],
18
+ admission: admittedSyntheticAdmission(operation),
19
+ summary: { conflicts: 0, synthetic: true },
20
+ conflictKeys: [`source#${file.sourcePath}`]
21
+ });
22
+ }
23
+
24
+ function blockedFile(file, context, reasonCode) {
25
+ const conflict = {
26
+ code: reasonCode,
27
+ gateId: 'project-file-presence',
28
+ message: `Project file cannot be safely merged: ${reasonCode}.`,
29
+ sourcePath: file.sourcePath,
30
+ details: { sourcePath: file.sourcePath }
31
+ };
32
+ return compactRecord({
33
+ kind: 'frontier.lang.jsTsProjectSafeMergeFile',
34
+ version: 1,
35
+ sourcePath: file.sourcePath,
36
+ language: context.language,
37
+ status: 'blocked',
38
+ operation: 'blocked-file-presence',
39
+ conflicts: [conflict],
40
+ admission: blockedAdmission(reasonCode),
41
+ summary: { conflicts: 1, synthetic: true },
42
+ conflictKeys: [`source#${file.sourcePath ?? 'unknown'}`]
43
+ });
44
+ }
45
+
46
+ function policyForFile(input, sourcePath) {
47
+ if (input.policyByPath?.[sourcePath]) return input.policyByPath[sourcePath];
48
+ if (input.mergePolicyByPath?.[sourcePath]) return input.mergePolicyByPath[sourcePath];
49
+ return input.policy ?? input.mergePolicy;
50
+ }
51
+
52
+ function sourceLedgersForFile(input, sourcePath) {
53
+ const byPath = input.sourceLedgersByPath?.[sourcePath] ?? input.sourceLedgers?.[sourcePath];
54
+ return byPath ?? (input.sourceLedgers?.base || input.sourceLedgers?.worker || input.sourceLedgers?.head ? input.sourceLedgers : undefined);
55
+ }
56
+
57
+ function admittedSyntheticAdmission(operation) {
58
+ return {
59
+ status: 'auto-merge-candidate',
60
+ action: operation === 'head-only' ? 'preserve-head' : 'apply',
61
+ reviewRequired: false,
62
+ autoApplyCandidate: true,
63
+ autoMergeClaim: false,
64
+ semanticEquivalenceClaim: false,
65
+ reasonCodes: []
66
+ };
67
+ }
68
+
69
+ function blockedAdmission(reasonCode) {
70
+ return {
71
+ status: 'blocked',
72
+ action: 'human-review',
73
+ reviewRequired: true,
74
+ autoApplyCandidate: false,
75
+ autoMergeClaim: false,
76
+ semanticEquivalenceClaim: false,
77
+ reasonCodes: [reasonCode]
78
+ };
79
+ }
80
+
81
+ function hashText(text) { return typeof text === 'string' ? hashSemanticValue(text) : undefined; }
82
+ function safeId(value) { return String(value ?? 'unknown').replace(/[^a-zA-Z0-9]+/g, '_').replace(/^_+|_+$/g, '') || 'file'; }
83
+ function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
84
+
85
+ export { blockedFile, hashText, policyForFile, safeId, sourceLedgersForFile, syntheticFile, uniqueStrings };
@@ -0,0 +1,60 @@
1
+ import { compactRecord } from './js-ts-safe-merge-context.js';
2
+
3
+ function cssModuleUseSiteBlockerConflicts(blockers = []) {
4
+ return blockers.map(cssModuleUseSiteBlockerConflict);
5
+ }
6
+
7
+ function cssModuleUseSiteBlockerConflict(blocker) {
8
+ const reasonCode = blocker.reasonCode ?? 'css-module-use-site-proof-blocked';
9
+ return {
10
+ code: 'project-css-module-use-site-proof-blocked',
11
+ gateId: 'project-css-module-use-site-graph',
12
+ message: `Output project graph has unproved CSS Module use-site evidence: ${reasonCode}.`,
13
+ sourcePath: blocker.sourcePath,
14
+ details: compactRecord({
15
+ reasonCode,
16
+ conflictKey: cssModuleUseSiteBlockerConflictKey(blocker),
17
+ sourcePath: blocker.sourcePath,
18
+ sourceSpan: blocker.sourceSpan,
19
+ moduleSpecifier: blocker.moduleSpecifier,
20
+ localName: blocker.localName,
21
+ cssModuleImportBindingId: blocker.cssModuleImportBindingId,
22
+ cssModuleSourcePath: blocker.cssModuleSourcePath,
23
+ expressionText: blocker.expressionText,
24
+ writeOperation: blocker.writeOperation,
25
+ jsxPropRecordId: blocker.jsxPropRecordId,
26
+ failClosed: blocker.failClosed === true,
27
+ semanticEquivalenceClaim: blocker.semanticEquivalenceClaim === true
28
+ })
29
+ };
30
+ }
31
+
32
+ function cssModuleUseSiteBlockerConflictKey(blocker) {
33
+ return [
34
+ 'css-module-use-site',
35
+ blocker.cssModuleSourcePath ?? blocker.moduleSpecifier ?? 'unknown-module',
36
+ blocker.sourcePath ?? 'unknown-source',
37
+ blocker.localName ?? 'unknown-local',
38
+ blocker.reasonCode ?? 'unknown-reason',
39
+ spanKey(blocker.sourceSpan),
40
+ blocker.expressionText
41
+ ].map((part) => String(part ?? '')).join('#');
42
+ }
43
+
44
+ function isResolvedCssModuleImportEdge(edge) {
45
+ return isCssModulePath(edge?.resolvedModulePath ?? edge?.moduleSpecifier)
46
+ && Boolean(edge?.targetDocumentId)
47
+ && typeof edge?.resolutionKind === 'string'
48
+ && edge.resolutionKind.endsWith('-source');
49
+ }
50
+
51
+ function isCssModulePath(path) {
52
+ return /\.module\.css(?:[?#].*)?$/i.test(String(path ?? ''));
53
+ }
54
+
55
+ function spanKey(span) {
56
+ if (!span) return '';
57
+ return [span.path, span.start, span.end].map((part) => String(part ?? '')).join(':');
58
+ }
59
+
60
+ export { cssModuleUseSiteBlockerConflicts, isResolvedCssModuleImportEdge };
@@ -0,0 +1,186 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { compactRecord, uniqueStrings } from './js-ts-safe-merge-context.js';
3
+ import { createJsTsProjectMergeDeclarationGate } from './js-ts-safe-project-merge-declarations.js';
4
+
5
+ const DeclarationEmitParityKind = 'typescript-checker-public-api-declaration-emit-parity';
6
+ const DeclarationEmitParityProofLevel = 'typescript-checker-public-api-declaration-output-boundary';
7
+
8
+ function createJsTsProjectMergeDeclarationEmitParityProof(input = {}, files = [], outputFiles = [], id = 'js_ts_project_safe_merge') {
9
+ const suppliedProof = input.declarationEmitParityProof ?? input.outputDeclarationEmitParityProof;
10
+ if (suppliedProof) return normalizeDeclarationEmitParityProof(suppliedProof, id);
11
+ if (!shouldCreateDeclarationEmitParityProof(input)) return undefined;
12
+ const stageFiles = declarationParityStageFiles(files, outputFiles, input);
13
+ const gateInput = declarationParityGateInput(input);
14
+ const gates = Object.fromEntries(Object.entries(stageFiles).map(([stage, stageOutputFiles]) => [
15
+ stage,
16
+ createJsTsProjectMergeDeclarationGate(gateInput, stageOutputFiles, `${id}_${stage}`)
17
+ ]));
18
+ return declarationEmitParityProof(input, id, gates);
19
+ }
20
+
21
+ function shouldCreateDeclarationEmitParityProof(input) {
22
+ return input.includeDeclarationOutput === true
23
+ || input.requireDeclarationOutput === true
24
+ || input.requirePublicApiDeclarationEmitParity === true;
25
+ }
26
+
27
+ function declarationParityStageFiles(files, outputFiles, input) {
28
+ return {
29
+ worker: files.map((file) => stageFile(file, workerStageSourceText(file), input)).filter(Boolean),
30
+ head: files.map((file) => stageFile(file, headStageSourceText(file), input)).filter(Boolean),
31
+ output: outputFiles
32
+ };
33
+ }
34
+
35
+ function declarationParityGateInput(input) {
36
+ return {
37
+ ...input,
38
+ includeDeclarationOutput: true,
39
+ requireDeclarationOutput: true,
40
+ outputDeclarations: undefined,
41
+ outputDeclarationFiles: undefined
42
+ };
43
+ }
44
+
45
+ function declarationEmitParityProof(input, id, gates) {
46
+ const boundaries = Object.fromEntries(Object.entries(gates).map(([stage, gate]) => [stage, declarationBoundary(gate)]));
47
+ const reasonCodes = declarationEmitParityReasonCodes(gates, boundaries);
48
+ const status = reasonCodes.length ? 'failed' : 'passed';
49
+ const outputFiles = boundaries.output?.files ?? [];
50
+ const core = {
51
+ kind: DeclarationEmitParityKind,
52
+ version: 1,
53
+ schema: 'frontier.lang.typescriptDeclarationEmitParityProof.v1',
54
+ id: `${id}_declaration_emit_parity`,
55
+ status,
56
+ proofLevel: DeclarationEmitParityProofLevel,
57
+ workerDeclarationBoundaryHash: boundaries.worker?.hash,
58
+ headDeclarationBoundaryHash: boundaries.head?.hash,
59
+ outputDeclarationBoundaryHash: boundaries.output?.hash,
60
+ declarationFileCount: outputFiles.length,
61
+ declarationFiles: outputFiles,
62
+ compilerOptionsHash: compilerOptionsHash(input),
63
+ diagnosticsHash: diagnosticsHash(gates),
64
+ missingSignals: reasonCodes,
65
+ reasonCodes,
66
+ autoMergeClaim: false,
67
+ semanticEquivalenceClaim: false
68
+ };
69
+ return { ...compactRecord(core), hash: hashSemanticValue(core) };
70
+ }
71
+
72
+ function declarationEmitParityReasonCodes(gates, boundaries) {
73
+ const reasonCodes = [];
74
+ for (const [stage, gate] of Object.entries(gates)) {
75
+ if (!gate) reasonCodes.push(`typescript-public-api-declaration-emit-${stage}-missing`);
76
+ if (gate?.status !== 'passed') reasonCodes.push(stage === 'output'
77
+ ? 'typescript-public-api-declaration-emit-output-missing'
78
+ : 'typescript-public-api-declaration-emit-proof-missing');
79
+ if ((gate?.diagnostics ?? []).some((diagnostic) => diagnostic.severity === 'error')) {
80
+ reasonCodes.push('typescript-public-api-declaration-emit-diagnostics-blocked');
81
+ }
82
+ }
83
+ if (!boundaries.worker?.hash || !boundaries.head?.hash || !boundaries.output?.hash) {
84
+ reasonCodes.push('typescript-compiler-declaration-output-public-boundary-hash-missing');
85
+ } else if (boundaries.worker.hash !== boundaries.head.hash || boundaries.worker.hash !== boundaries.output.hash) {
86
+ reasonCodes.push('typescript-public-api-declaration-emit-parity-mismatch');
87
+ }
88
+ return uniqueStrings(reasonCodes);
89
+ }
90
+
91
+ function declarationBoundary(gate) {
92
+ if (!gate || gate.status !== 'passed') return undefined;
93
+ const files = [...(gate.declarationFiles ?? [])]
94
+ .map((file) => compactRecord({
95
+ sourcePath: file.sourcePath,
96
+ sourceHash: file.sourceHash,
97
+ bytes: file.bytes,
98
+ source: file.source
99
+ }))
100
+ .sort((a, b) => String(a.sourcePath).localeCompare(String(b.sourcePath)));
101
+ return {
102
+ files,
103
+ hash: hashSemanticValue({ kind: 'frontier.lang.typescriptDeclarationBoundary', files })
104
+ };
105
+ }
106
+
107
+ function missingDeclarationEmitParityEvidence(proof, options = {}) {
108
+ if (options.requireDeclarationEmitParity !== true) return undefined;
109
+ if (!proof) {
110
+ return {
111
+ reasonCode: 'typescript-public-api-declaration-emit-proof-missing',
112
+ requiredEvidence: DeclarationEmitParityKind,
113
+ proofLevel: DeclarationEmitParityProofLevel,
114
+ missingSignals: ['typescript-public-api-declaration-emit-proof-missing']
115
+ };
116
+ }
117
+ if (proof.status === 'passed') return undefined;
118
+ const missingSignals = uniqueStrings(proof.reasonCodes ?? proof.missingSignals ?? ['typescript-public-api-declaration-emit-parity-mismatch']);
119
+ return compactRecord({
120
+ reasonCode: missingSignals[0],
121
+ requiredEvidence: DeclarationEmitParityKind,
122
+ proofLevel: DeclarationEmitParityProofLevel,
123
+ status: proof.status,
124
+ missingSignals,
125
+ workerDeclarationBoundaryHash: proof.workerDeclarationBoundaryHash,
126
+ headDeclarationBoundaryHash: proof.headDeclarationBoundaryHash,
127
+ outputDeclarationBoundaryHash: proof.outputDeclarationBoundaryHash,
128
+ declarationFileCount: proof.declarationFileCount,
129
+ compilerOptionsHash: proof.compilerOptionsHash,
130
+ diagnosticsHash: proof.diagnosticsHash,
131
+ autoMergeClaim: false,
132
+ semanticEquivalenceClaim: false
133
+ });
134
+ }
135
+
136
+ function normalizeDeclarationEmitParityProof(proof, id) {
137
+ const core = compactRecord({
138
+ ...proof,
139
+ kind: proof.kind ?? DeclarationEmitParityKind,
140
+ version: proof.version ?? 1,
141
+ id: proof.id ?? `${id}_declaration_emit_parity`,
142
+ proofLevel: proof.proofLevel ?? DeclarationEmitParityProofLevel,
143
+ status: proof.status ?? 'failed',
144
+ reasonCodes: uniqueStrings(proof.reasonCodes ?? proof.missingSignals ?? []),
145
+ missingSignals: uniqueStrings(proof.missingSignals ?? proof.reasonCodes ?? []),
146
+ autoMergeClaim: false,
147
+ semanticEquivalenceClaim: false
148
+ });
149
+ return { ...core, hash: proof.hash ?? hashSemanticValue(core) };
150
+ }
151
+
152
+ function workerStageSourceText(file) {
153
+ if (file.workerDeleted) return undefined;
154
+ return file.workerSourceText ?? file.baseSourceText;
155
+ }
156
+
157
+ function headStageSourceText(file) {
158
+ if (file.headDeleted) return undefined;
159
+ return file.headSourceText ?? file.baseSourceText;
160
+ }
161
+
162
+ function stageFile(file, sourceText, input) {
163
+ if (typeof sourceText !== 'string' || !file.sourcePath) return undefined;
164
+ return compactRecord({ sourcePath: file.sourcePath, language: file.language ?? input.language, sourceText });
165
+ }
166
+
167
+ function compilerOptionsHash(input) {
168
+ return hashSemanticValue({
169
+ compilerOptions: input.compilerOptions,
170
+ typescriptCompilerOptions: input.typescriptCompilerOptions,
171
+ declarationCompilerOptions: input.declarationCompilerOptions,
172
+ typescriptDeclarationCompilerOptions: input.typescriptDeclarationCompilerOptions,
173
+ tsconfig: input.tsconfig,
174
+ moduleResolution: input.moduleResolution,
175
+ projectReferences: input.projectReferences ?? input.typescriptProjectReferences ?? input.tsconfigProjectReferences
176
+ });
177
+ }
178
+
179
+ function diagnosticsHash(gates) {
180
+ return hashSemanticValue(Object.fromEntries(Object.entries(gates).map(([stage, gate]) => [stage, gate?.diagnostics ?? []])));
181
+ }
182
+
183
+ export {
184
+ createJsTsProjectMergeDeclarationEmitParityProof,
185
+ missingDeclarationEmitParityEvidence
186
+ };