@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.
- package/README.md +315 -9
- package/bench/real-repo-corpus-checkout-identity.mjs +134 -0
- package/bench/real-repo-corpus-checkout-proof.mjs +263 -0
- package/bench/real-repo-corpus-command-execution.mjs +314 -0
- package/bench/real-repo-corpus-evidence.mjs +165 -0
- package/bench/real-repo-corpus-suite.mjs +273 -0
- package/bench/smoke.mjs +109 -7
- package/dist/declarations/import-adapter-core.d.ts +4 -3
- package/dist/declarations/import-adapter-options-native.d.ts +21 -0
- package/dist/declarations/js-ts-project-merge-admission-routes.d.ts +35 -0
- package/dist/declarations/js-ts-project-merge-commonjs-interop.d.ts +29 -0
- package/dist/declarations/js-ts-project-merge-confidence.d.ts +64 -0
- package/dist/declarations/js-ts-project-merge-declaration-emit-parity.d.ts +37 -0
- package/dist/declarations/js-ts-project-merge-declarations.d.ts +65 -0
- package/dist/declarations/js-ts-project-merge-diagnostics.d.ts +97 -0
- package/dist/declarations/js-ts-project-merge-global-augmentation.d.ts +30 -0
- package/dist/declarations/js-ts-project-merge-jsx-render-branch.d.ts +48 -0
- package/dist/declarations/js-ts-project-merge-proof-levels.d.ts +109 -0
- package/dist/declarations/js-ts-project-merge-quality-gates.d.ts +38 -0
- package/dist/declarations/js-ts-project-merge-semantic-equivalence-proof.d.ts +45 -0
- package/dist/declarations/js-ts-project-merge-tsconfig.d.ts +43 -0
- package/dist/declarations/js-ts-safe-merge.d.ts +47 -0
- package/dist/declarations/js-ts-safe-project-merge.d.ts +120 -38
- package/dist/declarations/native-project-compiler-assignability-oracle.d.ts +41 -0
- package/dist/declarations/native-project-compiler-callable-signatures.d.ts +31 -0
- package/dist/declarations/native-project-compiler-class-member-runtime-proof.d.ts +87 -0
- package/dist/declarations/native-project-compiler-composite-types.d.ts +23 -0
- package/dist/declarations/native-project-compiler-enum-proof.d.ts +58 -0
- package/dist/declarations/native-project-compiler-index-signature.d.ts +7 -0
- package/dist/declarations/native-project-compiler-public-api-source-binding.d.ts +8 -0
- package/dist/declarations/native-project-compiler-scope.d.ts +37 -0
- package/dist/declarations/native-project-compiler-type-reference-targets.d.ts +38 -0
- package/dist/declarations/native-project-css-modules.d.ts +90 -0
- package/dist/declarations/native-project-decorator-metadata.d.ts +126 -0
- package/dist/declarations/native-project-jsx-graph.d.ts +313 -0
- package/dist/declarations/native-project-module-declarations.d.ts +52 -0
- package/dist/declarations/native-project-module-resolution.d.ts +76 -1
- package/dist/declarations/native-project-runtime-effect-target.d.ts +29 -0
- package/dist/declarations/native-project-runtime-executable-effect-evidence.d.ts +107 -0
- package/dist/declarations/native-project-runtime-mutation-target.d.ts +33 -0
- package/dist/declarations/native-project-runtime-promise-chain.d.ts +30 -0
- package/dist/declarations/native-project-runtime-promise-combinator.d.ts +22 -0
- package/dist/declarations/native-project-runtime-reachability.d.ts +30 -0
- package/dist/declarations/native-project-runtime-resource-management.d.ts +27 -0
- package/dist/declarations/native-project-runtime-yield-delegation.d.ts +10 -0
- package/dist/declarations/native-project-scope-template-reference.d.ts +13 -0
- package/dist/declarations/native-project-source-evidence.d.ts +8 -0
- package/dist/declarations/native-project.d.ts +40 -39
- package/dist/declarations/semantic-edit-script.d.ts +10 -8
- package/dist/declarations/semantic-graph-layers.d.ts +79 -0
- package/dist/declarations/semantic-patch-bundle-composition.d.ts +62 -0
- package/dist/declarations/semantic-sidecar.d.ts +3 -2
- package/dist/declarations/semantic-structural-diff.d.ts +94 -0
- package/dist/declarations/source-preservation.d.ts +32 -1
- package/dist/declarations/target-adapters.d.ts +22 -2
- package/dist/index.d.ts +32 -0
- package/dist/index.js +6 -0
- package/dist/internal/index-impl/compileNativeSource.js +53 -5
- package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
- package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
- package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
- package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
- package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
- package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
- package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
- package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
- package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
- package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
- package/dist/internal/index-impl/importNativeSource.js +2 -3
- package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
- package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
- package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
- package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
- package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
- package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
- package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
- package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
- package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
- package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
- package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
- package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
- package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
- package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
- package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
- package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
- package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
- package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
- package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
- package/dist/internal/index-impl/semanticEditScripts.js +42 -5
- package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
- package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
- package/dist/internal/index-impl/semanticPatchBundleComposition.js +166 -0
- package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
- package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
- package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
- package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
- package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
- package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
- package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
- package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
- package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
- package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
- package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
- package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
- package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
- package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
- package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
- package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
- package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
- package/dist/js-ts-safe-member-class-invariants.js +247 -0
- package/dist/js-ts-safe-member-merge-result.js +23 -3
- package/dist/js-ts-safe-member-merge.js +28 -4
- package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
- package/dist/js-ts-safe-merge-context.js +1 -0
- package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +314 -0
- package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
- package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
- package/dist/js-ts-safe-merge-parse-statements.js +8 -0
- package/dist/js-ts-safe-merge-plan.js +3 -1
- package/dist/js-ts-safe-merge-semantic-edit-fallback.js +49 -0
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +5 -1
- package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
- package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
- package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
- package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
- package/dist/js-ts-safe-merge.js +136 -0
- package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
- package/dist/js-ts-safe-project-merge-admission.js +161 -0
- package/dist/js-ts-safe-project-merge-ambient.js +110 -0
- package/dist/js-ts-safe-project-merge-core.js +85 -0
- package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
- package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
- package/dist/js-ts-safe-project-merge-declarations.js +227 -0
- package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
- package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
- package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
- package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
- package/dist/js-ts-safe-project-merge-files.js +70 -0
- package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
- package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
- package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
- package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
- package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
- package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
- package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
- package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
- package/dist/js-ts-safe-project-merge-graph.js +37 -5
- package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
- package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
- package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
- package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
- package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
- package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
- package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
- package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
- package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
- package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
- package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
- package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
- package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
- package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
- package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
- package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
- package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
- package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
- package/dist/js-ts-safe-project-merge-summary.js +320 -0
- package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
- package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
- package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
- package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
- package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
- package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
- package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
- package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
- package/dist/js-ts-safe-project-merge.js +171 -172
- package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
- package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
- package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
- package/dist/js-ts-semantic-scope-use-def.js +217 -0
- package/dist/lightweight-dependency-effects.js +28 -4
- package/dist/lightweight-dependency-relations.js +13 -7
- package/dist/lightweight-dependency-top-level.js +63 -0
- package/dist/native-import-language-profiles.js +27 -1
- package/dist/native-js-ts-importers.js +9 -5
- package/dist/native-parser-ast-format-profiles.js +12 -0
- package/dist/native-parser-html-css-format-profiles.js +85 -0
- package/dist/native-region-scanner-core.js +5 -3
- package/dist/native-region-scanner-js-commonjs.js +155 -0
- package/dist/native-region-scanner-js-imports.js +51 -13
- package/dist/native-region-scanner-js-reexports.js +79 -0
- package/dist/native-region-scanner-js-ts-helpers.js +23 -0
- package/dist/native-source-ledger-helpers.js +1 -1
- package/dist/native-source-ledger.js +24 -10
- package/dist/native-source-maps-ecma426.js +316 -0
- package/dist/native-source-maps.js +36 -6
- package/dist/native-source-preservation-ownership.js +292 -0
- package/dist/native-source-preservation-scanner.js +63 -25
- package/dist/native-source-preservation-types.d.ts +3 -0
- package/dist/semantic-import-effect-occurrences.js +242 -0
- package/dist/semantic-import-effect-regions.js +95 -58
- package/dist/semantic-import-graph-layers.js +224 -0
- package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
- package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
- package/dist/semantic-import-runtime-exit-evidence.js +32 -0
- package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
- package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
- package/dist/semantic-import-runtime-order-evidence.js +318 -0
- package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
- package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
- package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
- package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
- package/dist/semantic-import-runtime-switch-evidence.js +304 -0
- package/dist/semantic-import-runtime-throw-evidence.js +44 -0
- package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
- package/dist/semantic-import-sidecar-entry.js +4 -0
- package/dist/semantic-import-source-preservation.js +6 -2
- package/package.json +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
2
|
+
import { globalAugmentationCompatibilityAssessment, sourceSpanHash } from './js-ts-safe-project-merge-global-augmentation-compatibility.js';
|
|
3
|
+
|
|
4
|
+
function projectModuleDeclarationDeltaConflicts(projectGraphDelta, options = {}) {
|
|
5
|
+
return [
|
|
6
|
+
...changedShapeConflicts({
|
|
7
|
+
code: 'project-module-declaration-shape-delta-conflict',
|
|
8
|
+
label: 'module declaration shape',
|
|
9
|
+
baseRecords: projectGraphDelta?.stages?.base?.projectSymbolGraph?.moduleDeclarationRecords,
|
|
10
|
+
workerRecords: projectGraphDelta?.stages?.worker?.projectSymbolGraph?.moduleDeclarationRecords,
|
|
11
|
+
headRecords: projectGraphDelta?.stages?.head?.projectSymbolGraph?.moduleDeclarationRecords,
|
|
12
|
+
outputRecords: projectGraphDelta?.stages?.output?.projectSymbolGraph?.moduleDeclarationRecords,
|
|
13
|
+
identityKey: moduleDeclarationIdentityKey,
|
|
14
|
+
details: moduleDeclarationDetails,
|
|
15
|
+
proofAssessment: (identityKey, baseRecord, workerRecord, headRecord, outputRecord) => globalAugmentationDeltaProofAssessment(identityKey, baseRecord, workerRecord, headRecord, outputRecord, options)
|
|
16
|
+
}),
|
|
17
|
+
...changedShapeConflicts({
|
|
18
|
+
code: 'project-export-assignment-shape-delta-conflict',
|
|
19
|
+
label: 'export assignment shape',
|
|
20
|
+
baseRecords: projectGraphDelta?.stages?.base?.projectSymbolGraph?.exportAssignmentRecords,
|
|
21
|
+
workerRecords: projectGraphDelta?.stages?.worker?.projectSymbolGraph?.exportAssignmentRecords,
|
|
22
|
+
headRecords: projectGraphDelta?.stages?.head?.projectSymbolGraph?.exportAssignmentRecords,
|
|
23
|
+
outputRecords: projectGraphDelta?.stages?.output?.projectSymbolGraph?.exportAssignmentRecords,
|
|
24
|
+
identityKey: exportAssignmentIdentityKey,
|
|
25
|
+
details: exportAssignmentDetails
|
|
26
|
+
})
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function changedShapeConflicts(input) {
|
|
31
|
+
const base = recordsByIdentityKey(input.baseRecords, input.identityKey);
|
|
32
|
+
const worker = recordsByIdentityKey(input.workerRecords, input.identityKey);
|
|
33
|
+
const head = recordsByIdentityKey(input.headRecords, input.identityKey);
|
|
34
|
+
const output = recordsByIdentityKey(input.outputRecords, input.identityKey);
|
|
35
|
+
const keys = uniqueStrings([...base.keys(), ...worker.keys(), ...head.keys()]);
|
|
36
|
+
return keys.flatMap((identityKey) => {
|
|
37
|
+
const baseHash = base.get(identityKey)?.shapeHash;
|
|
38
|
+
const workerHash = worker.get(identityKey)?.shapeHash;
|
|
39
|
+
const headHash = head.get(identityKey)?.shapeHash;
|
|
40
|
+
if (baseHash === workerHash || baseHash === headHash || workerHash === headHash) return [];
|
|
41
|
+
const proof = input.proofAssessment?.(identityKey, base.get(identityKey), worker.get(identityKey), head.get(identityKey), output.get(identityKey));
|
|
42
|
+
if (proof?.status === 'passed') return [];
|
|
43
|
+
return [shapeConflict(input, identityKey, base.get(identityKey), worker.get(identityKey), head.get(identityKey), output.get(identityKey), proof)];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function shapeConflict(input, identityKey, baseRecord, workerRecord, headRecord, outputRecord, proof = undefined) {
|
|
48
|
+
const sourcePath = workerRecord?.sourcePath ?? headRecord?.sourcePath ?? baseRecord?.sourcePath;
|
|
49
|
+
const conflictKey = `project-graph-delta#${input.label.replace(/\s+/g, '-')}#${identityKey}`;
|
|
50
|
+
return {
|
|
51
|
+
code: input.code,
|
|
52
|
+
gateId: 'project-graph-delta',
|
|
53
|
+
message: `Worker and head both changed ${input.label} ${JSON.stringify(identityKey)} with incompatible static shape evidence.`,
|
|
54
|
+
sourcePath,
|
|
55
|
+
details: compactRecord({
|
|
56
|
+
reasonCode: input.code,
|
|
57
|
+
conflictKey,
|
|
58
|
+
identityKey,
|
|
59
|
+
sourcePath,
|
|
60
|
+
base: input.details(baseRecord),
|
|
61
|
+
worker: input.details(workerRecord),
|
|
62
|
+
head: input.details(headRecord),
|
|
63
|
+
output: input.details(outputRecord),
|
|
64
|
+
requiredProof: 'static-shape-evidence',
|
|
65
|
+
routeId: proof?.routeId,
|
|
66
|
+
routeLane: proof?.routeLane,
|
|
67
|
+
routeNext: proof?.routeNext,
|
|
68
|
+
reasonCodes: proof?.reasonCodes,
|
|
69
|
+
globalAugmentationCompatibilityProof: proof?.record,
|
|
70
|
+
semanticEquivalenceClaim: false
|
|
71
|
+
})
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function globalAugmentationDeltaProofAssessment(identityKey, baseRecord, workerRecord, headRecord, outputRecord, options) {
|
|
76
|
+
const record = outputRecord ?? workerRecord ?? headRecord ?? baseRecord;
|
|
77
|
+
if (record?.surfaceKind !== 'global-augmentation') return undefined;
|
|
78
|
+
return globalAugmentationCompatibilityAssessment({
|
|
79
|
+
identityKey,
|
|
80
|
+
sourcePath: record.sourcePath,
|
|
81
|
+
sourceHash: record.sourceHash,
|
|
82
|
+
moduleName: record.moduleName,
|
|
83
|
+
surfaceKind: record.surfaceKind,
|
|
84
|
+
moduleDeclarationRecordId: record.id,
|
|
85
|
+
moduleDeclarationShapeHash: record.shapeHash,
|
|
86
|
+
moduleDeclarationSignatureHash: record.signatureHash,
|
|
87
|
+
sourceSpanHash: sourceSpanHash(record.sourceSpan),
|
|
88
|
+
declarationOutputHash: options.declarationEmitParityProof?.outputDeclarationBoundaryHash,
|
|
89
|
+
...compatibilityGateContext(options)
|
|
90
|
+
}, options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function compatibilityGateContext(options = {}) {
|
|
94
|
+
return compactRecord({
|
|
95
|
+
consumerDiagnosticsPassed: options.outputDiagnosticsGate ? options.outputDiagnosticsGate.status === 'passed' : undefined
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function moduleDeclarationIdentityKey(record) {
|
|
100
|
+
return stableKey(['module-declaration', record?.sourcePath, record?.surfaceKind, record?.moduleName]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function exportAssignmentIdentityKey(record) {
|
|
104
|
+
return stableKey(['export-assignment', record?.sourcePath, record?.exportKind, record?.exportedName]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function moduleDeclarationDetails(record) {
|
|
108
|
+
if (!record) return undefined;
|
|
109
|
+
return compactRecord({
|
|
110
|
+
sourcePath: record.sourcePath,
|
|
111
|
+
moduleName: record.moduleName,
|
|
112
|
+
surfaceKind: record.surfaceKind,
|
|
113
|
+
declarationOnly: record.declarationOnly,
|
|
114
|
+
runtimeNamespace: record.runtimeNamespace,
|
|
115
|
+
shapeHash: record.shapeHash,
|
|
116
|
+
proofLevel: record.shapeProof?.proofLevel,
|
|
117
|
+
unsupportedSignals: record.shapeProof?.unsupportedSignals,
|
|
118
|
+
semanticEquivalenceClaim: false
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function exportAssignmentDetails(record) {
|
|
123
|
+
if (!record) return undefined;
|
|
124
|
+
return compactRecord({
|
|
125
|
+
sourcePath: record.sourcePath,
|
|
126
|
+
exportedName: record.exportedName,
|
|
127
|
+
localName: record.localName,
|
|
128
|
+
exportKind: record.exportKind,
|
|
129
|
+
shapeHash: record.shapeHash,
|
|
130
|
+
proofLevel: record.shapeProof?.proofLevel,
|
|
131
|
+
unsupportedSignals: record.shapeProof?.unsupportedSignals,
|
|
132
|
+
semanticEquivalenceClaim: false
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function recordsByIdentityKey(records, identityKey) {
|
|
137
|
+
const result = new Map();
|
|
138
|
+
for (const record of records ?? []) {
|
|
139
|
+
const key = identityKey(record);
|
|
140
|
+
if (!key || result.has(key)) continue;
|
|
141
|
+
result.set(key, record);
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function stableKey(parts) {
|
|
147
|
+
const values = parts.map((part) => part === undefined || part === null ? '' : String(part));
|
|
148
|
+
return values.some(Boolean) ? values.join('#') : undefined;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function uniqueStrings(values) {
|
|
152
|
+
return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { projectModuleDeclarationDeltaConflicts };
|
|
@@ -6,8 +6,13 @@ const PROJECT_GRAPH_INVALID_LIMIT_CODE = 'project-graph-limit-invalid';
|
|
|
6
6
|
const LIMIT_FIELDS = [
|
|
7
7
|
['maxFiles', 'source-files'],
|
|
8
8
|
['maxSourceBytes', 'source-bytes'],
|
|
9
|
+
['maxSourceSpans', 'source-spans'],
|
|
9
10
|
['maxImportEdges', 'import-edges'],
|
|
10
11
|
['maxExportEdges', 'export-edges'],
|
|
12
|
+
['maxScopeBindings', 'scope-bindings'],
|
|
13
|
+
['maxScopeReferences', 'scope-references'],
|
|
14
|
+
['maxJsxElements', 'jsx-elements'],
|
|
15
|
+
['maxJsxProps', 'jsx-props'],
|
|
11
16
|
['maxSerializedBytes', 'serialized-bytes']
|
|
12
17
|
];
|
|
13
18
|
|
|
@@ -58,10 +63,20 @@ function projectGraphInvalidLimitConflicts(limits, stage) {
|
|
|
58
63
|
|
|
59
64
|
function projectGraphEdgeLimitConflicts(limits, stage, projectSymbolGraph) {
|
|
60
65
|
const importEdges = Array.isArray(projectSymbolGraph?.importEdges) ? projectSymbolGraph.importEdges.length : 0;
|
|
66
|
+
const sourceSpans = Array.isArray(projectSymbolGraph?.sourceSpanRecords) ? projectSymbolGraph.sourceSpanRecords.length : 0;
|
|
61
67
|
const exportEdges = Array.isArray(projectSymbolGraph?.exportEdges) ? projectSymbolGraph.exportEdges.length : 0;
|
|
68
|
+
const scopeBindings = Array.isArray(projectSymbolGraph?.scopeBindingRecords) ? projectSymbolGraph.scopeBindingRecords.length : 0;
|
|
69
|
+
const scopeReferences = Array.isArray(projectSymbolGraph?.scopeReferenceRecords) ? projectSymbolGraph.scopeReferenceRecords.length : 0;
|
|
70
|
+
const jsxElements = Array.isArray(projectSymbolGraph?.jsxElementRecords) ? projectSymbolGraph.jsxElementRecords.length : 0;
|
|
71
|
+
const jsxProps = Array.isArray(projectSymbolGraph?.jsxPropRecords) ? projectSymbolGraph.jsxPropRecords.length : 0;
|
|
62
72
|
return [
|
|
63
73
|
limitConflict(limits.maxImportEdges, stage, 'import-edges', importEdges),
|
|
64
|
-
limitConflict(limits.
|
|
74
|
+
limitConflict(limits.maxSourceSpans, stage, 'source-spans', sourceSpans),
|
|
75
|
+
limitConflict(limits.maxExportEdges, stage, 'export-edges', exportEdges),
|
|
76
|
+
limitConflict(limits.maxScopeBindings, stage, 'scope-bindings', scopeBindings),
|
|
77
|
+
limitConflict(limits.maxScopeReferences, stage, 'scope-references', scopeReferences),
|
|
78
|
+
limitConflict(limits.maxJsxElements, stage, 'jsx-elements', jsxElements),
|
|
79
|
+
limitConflict(limits.maxJsxProps, stage, 'jsx-props', jsxProps)
|
|
65
80
|
].filter(Boolean);
|
|
66
81
|
}
|
|
67
82
|
|
|
@@ -32,10 +32,21 @@ function createJsTsProjectSafeMergeGraphDelta(input, files, outputFiles, mergeId
|
|
|
32
32
|
summary: {
|
|
33
33
|
stages: Object.keys(stages).length,
|
|
34
34
|
sourceFiles: sumStageSummary(stageSummaries, 'sourceFiles'),
|
|
35
|
+
sourceFileRecords: sumStageSummary(stageSummaries, 'sourceFileRecords'),
|
|
36
|
+
sourceSpanRecords: sumStageSummary(stageSummaries, 'sourceSpanRecords'),
|
|
35
37
|
publicContractRegions: sumStageSummary(stageSummaries, 'publicContractRegions'),
|
|
36
38
|
reExportIdentities: sumStageSummary(stageSummaries, 'reExportIdentities'),
|
|
39
|
+
moduleDeclarationRecords: sumStageSummary(stageSummaries, 'moduleDeclarationRecords'),
|
|
40
|
+
exportAssignmentRecords: sumStageSummary(stageSummaries, 'exportAssignmentRecords'),
|
|
37
41
|
importEdges: sumStageSummary(stageSummaries, 'importEdges'),
|
|
38
42
|
exportEdges: sumStageSummary(stageSummaries, 'exportEdges'),
|
|
43
|
+
compilerSymbolRecords: sumStageSummary(stageSummaries, 'compilerSymbolRecords'),
|
|
44
|
+
compilerTypeRecords: sumStageSummary(stageSummaries, 'compilerTypeRecords'),
|
|
45
|
+
runtimeRegionRecords: sumStageSummary(stageSummaries, 'runtimeRegionRecords'),
|
|
46
|
+
scopeBindingRecords: sumStageSummary(stageSummaries, 'scopeBindingRecords'),
|
|
47
|
+
scopeReferenceRecords: sumStageSummary(stageSummaries, 'scopeReferenceRecords'),
|
|
48
|
+
jsxElementRecords: sumStageSummary(stageSummaries, 'jsxElementRecords'),
|
|
49
|
+
jsxPropRecords: sumStageSummary(stageSummaries, 'jsxPropRecords'),
|
|
39
50
|
unresolvedImportEdges: sumStageSummary(stageSummaries, 'unresolvedImportEdges'),
|
|
40
51
|
suppliedImports: sumStageSummary(stageSummaries, 'suppliedImports'),
|
|
41
52
|
matchedSuppliedImports: sumStageSummary(stageSummaries, 'matchedSuppliedImports'),
|
|
@@ -68,6 +79,7 @@ function createProjectGraphStageArtifacts(input, files, mergeId, stageName, stag
|
|
|
68
79
|
sourcePath: file.sourcePath,
|
|
69
80
|
sourceText: file.sourceText,
|
|
70
81
|
sourceHash: file.sourceHash,
|
|
82
|
+
parserTriviaEvidence: file.parserTriviaEvidence,
|
|
71
83
|
metadata: { semanticImportExpected: true, projectSafeMergeStage: stageName, projectSafeMergeOutput: stageName === 'output' }
|
|
72
84
|
}));
|
|
73
85
|
const importSelections = sources.map((source) => {
|
|
@@ -164,10 +176,21 @@ function projectGraphStageSummary(stageName, projectSymbolGraph, importSource, s
|
|
|
164
176
|
documents: projectSymbolGraph?.documentCount ?? 0,
|
|
165
177
|
symbols: projectSymbolGraph?.symbolCount ?? 0,
|
|
166
178
|
fileHashes: projectSymbolGraph?.fileHashes?.length ?? 0,
|
|
179
|
+
sourceFileRecords: projectSymbolGraph?.sourceFileRecords?.length ?? 0,
|
|
180
|
+
sourceSpanRecords: projectSymbolGraph?.sourceSpanRecords?.length ?? 0,
|
|
167
181
|
importEdges: importEdges.length,
|
|
168
182
|
exportEdges: projectSymbolGraph?.exportEdges?.length ?? 0,
|
|
169
183
|
publicContractRegions: projectSymbolGraph?.publicContractRegions?.length ?? 0,
|
|
184
|
+
compilerSymbolRecords: projectSymbolGraph?.compilerSymbolRecords?.length ?? 0,
|
|
185
|
+
compilerTypeRecords: projectSymbolGraph?.compilerTypeRecords?.length ?? 0,
|
|
186
|
+
runtimeRegionRecords: projectSymbolGraph?.runtimeRegionRecords?.length ?? 0,
|
|
187
|
+
scopeBindingRecords: projectSymbolGraph?.scopeBindingRecords?.length ?? 0,
|
|
188
|
+
scopeReferenceRecords: projectSymbolGraph?.scopeReferenceRecords?.length ?? 0,
|
|
189
|
+
jsxElementRecords: projectSymbolGraph?.jsxElementRecords?.length ?? 0,
|
|
190
|
+
jsxPropRecords: projectSymbolGraph?.jsxPropRecords?.length ?? 0,
|
|
170
191
|
reExportIdentities: projectSymbolGraph?.reExportIdentities?.length ?? 0,
|
|
192
|
+
moduleDeclarationRecords: projectSymbolGraph?.moduleDeclarationRecords?.length ?? 0,
|
|
193
|
+
exportAssignmentRecords: projectSymbolGraph?.exportAssignmentRecords?.length ?? 0,
|
|
171
194
|
unresolvedImportEdges: importEdges.filter(isMissingProjectImportEdge).length,
|
|
172
195
|
suppliedImports: importSource.suppliedImports,
|
|
173
196
|
matchedSuppliedImports: importSource.matchedSuppliedImports,
|
|
@@ -188,13 +211,13 @@ function sumStageSummary(stageSummaries, field) {
|
|
|
188
211
|
function projectGraphDeltaStageFiles(files, outputFiles, input) {
|
|
189
212
|
return {
|
|
190
213
|
base: files
|
|
191
|
-
.map((file) => stageFile(file, file.baseSourceText, input))
|
|
214
|
+
.map((file) => stageFile(file, file.baseSourceText, input, 'base'))
|
|
192
215
|
.filter(Boolean),
|
|
193
216
|
worker: files
|
|
194
|
-
.map((file) => stageFile(file, workerStageSourceText(file), input))
|
|
217
|
+
.map((file) => stageFile(file, workerStageSourceText(file), input, 'worker'))
|
|
195
218
|
.filter(Boolean),
|
|
196
219
|
head: files
|
|
197
|
-
.map((file) => stageFile(file, headStageSourceText(file), input))
|
|
220
|
+
.map((file) => stageFile(file, headStageSourceText(file), input, 'head'))
|
|
198
221
|
.filter(Boolean),
|
|
199
222
|
output: outputFiles
|
|
200
223
|
};
|
|
@@ -210,16 +233,25 @@ function headStageSourceText(file) {
|
|
|
210
233
|
return file.headSourceText ?? file.baseSourceText;
|
|
211
234
|
}
|
|
212
235
|
|
|
213
|
-
function stageFile(file, sourceText, input) {
|
|
236
|
+
function stageFile(file, sourceText, input, stageName) {
|
|
214
237
|
if (typeof sourceText !== 'string' || !file.sourcePath) return undefined;
|
|
215
238
|
return compactRecord({
|
|
216
239
|
sourcePath: file.sourcePath,
|
|
217
240
|
language: file.language ?? input.language,
|
|
218
241
|
sourceText,
|
|
219
|
-
sourceHash: hashText(sourceText)
|
|
242
|
+
sourceHash: hashText(sourceText),
|
|
243
|
+
parserTriviaEvidence: parserTriviaEvidenceForStage(file, stageName)
|
|
220
244
|
});
|
|
221
245
|
}
|
|
222
246
|
|
|
247
|
+
function parserTriviaEvidenceForStage(file, stageName) {
|
|
248
|
+
if (stageName === 'base') return file.baseParserTriviaEvidence ?? file.parserTriviaEvidence;
|
|
249
|
+
if (stageName === 'worker') return file.workerParserTriviaEvidence ?? file.parserTriviaEvidence;
|
|
250
|
+
if (stageName === 'head') return file.headParserTriviaEvidence ?? file.parserTriviaEvidence;
|
|
251
|
+
if (stageName === 'output') return file.outputParserTriviaEvidence ?? file.parserTriviaEvidence;
|
|
252
|
+
return file.parserTriviaEvidence;
|
|
253
|
+
}
|
|
254
|
+
|
|
223
255
|
function attachProjectSymbolGraph(projectImport, projectSymbolGraph) {
|
|
224
256
|
return {
|
|
225
257
|
...projectImport,
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { JsTsSafeMergeConflictCodes, JsTsSafeMergeStatuses, jsTsSafeMergeGateOrder } from './js-ts-safe-merge-constants.js';
|
|
3
|
+
import { compactRecord, createMergeContext, sameStatementText, uniqueStrings } from './js-ts-safe-merge-context.js';
|
|
4
|
+
import { scanJsTsTopLevelLedger } from './js-ts-safe-merge-ledger.js';
|
|
5
|
+
import { analyzeImportRemovalUseDefEvidence, LexicalUseDefReasonCodes } from './js-ts-semantic-scope-use-def.js';
|
|
6
|
+
|
|
7
|
+
const ImportRemovalUsageProofConflictCode = 'project-import-removal-usage-proof-unavailable';
|
|
8
|
+
const ImportRemovalUsageProofGateId = 'project-import-removal-usage-proof';
|
|
9
|
+
const ImportRemovalUsageProofOperation = 'merged-import-removal-usage-proof';
|
|
10
|
+
const ImportRemovalLexicalUseDefConflictCode = 'project-import-removal-lexical-use-def-blocked';
|
|
11
|
+
const ImportRemovalLexicalUseDefGateId = 'project-import-removal-lexical-use-def';
|
|
12
|
+
|
|
13
|
+
function maybeMergeImportSpecifierRemovalFile(file, context, result, input) {
|
|
14
|
+
const usageProof = analyzeNarrowImportSpecifierRemoval(file, context, result);
|
|
15
|
+
if (!usageProof) return undefined;
|
|
16
|
+
if (usageProof.lexicalUseDefEvidence?.status === 'blocked') {
|
|
17
|
+
return blockedImportRemovalLexicalUseDefFile(file, context, result, usageProof);
|
|
18
|
+
}
|
|
19
|
+
if (!hasImportRemovalUsageProofInput(input)) return blockedImportRemovalUsageProofFile(file, context, result, usageProof);
|
|
20
|
+
const admission = admittedImportRemovalUsageProofAdmission();
|
|
21
|
+
const mergeResult = importRemovalUsageProofMergeResult(context, result, usageProof, input, admission);
|
|
22
|
+
return compactRecord({
|
|
23
|
+
kind: 'frontier.lang.jsTsProjectSafeMergeFile',
|
|
24
|
+
version: 1,
|
|
25
|
+
sourcePath: file.sourcePath,
|
|
26
|
+
language: context.language,
|
|
27
|
+
status: 'merged',
|
|
28
|
+
operation: ImportRemovalUsageProofOperation,
|
|
29
|
+
outputSourceText: usageProof.outputSourceText,
|
|
30
|
+
outputHash: hashText(usageProof.outputSourceText),
|
|
31
|
+
baseHash: hashText(file.baseSourceText),
|
|
32
|
+
workerHash: hashText(usageProof.outputSourceText),
|
|
33
|
+
headHash: hashText(file.headSourceText ?? file.baseSourceText),
|
|
34
|
+
result: mergeResult,
|
|
35
|
+
conflicts: [],
|
|
36
|
+
admission,
|
|
37
|
+
summary: mergeResult.summary,
|
|
38
|
+
conflictKeys: [`source#${file.sourcePath}`],
|
|
39
|
+
metadata: mergeResult.metadata
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function analyzeNarrowImportSpecifierRemoval(file, context, result) {
|
|
44
|
+
const conflicts = result.conflicts ?? [];
|
|
45
|
+
const removalConflicts = conflicts.filter((conflict) => conflict.code === JsTsSafeMergeConflictCodes.importSpecifierRemoved);
|
|
46
|
+
if (result.status !== JsTsSafeMergeStatuses.blocked || conflicts.length !== 1 || removalConflicts.length !== 1) return undefined;
|
|
47
|
+
const conflict = removalConflicts[0];
|
|
48
|
+
const missing = Array.isArray(conflict.details?.missing) ? conflict.details.missing : [];
|
|
49
|
+
if (conflict.side !== 'worker' || missing.length !== 1) return undefined;
|
|
50
|
+
const baseSourceText = file.baseSourceText;
|
|
51
|
+
const workerSourceText = file.workerDeleted ? undefined : file.workerSourceText ?? baseSourceText;
|
|
52
|
+
const headSourceText = file.headDeleted ? undefined : file.headSourceText ?? baseSourceText;
|
|
53
|
+
if (typeof baseSourceText !== 'string' || typeof workerSourceText !== 'string' || typeof headSourceText !== 'string') return undefined;
|
|
54
|
+
if (headSourceText !== baseSourceText) return undefined;
|
|
55
|
+
return analyzeLedgers(file, context, result, baseSourceText, workerSourceText, headSourceText, conflict, missing[0]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function analyzeLedgers(file, context, result, baseSourceText, workerSourceText, headSourceText, conflict, removedSpecifier) {
|
|
59
|
+
const scanContext = createMergeContext({
|
|
60
|
+
id: `${result.id}_import_removal_usage_probe`,
|
|
61
|
+
sourcePath: context.sourcePath,
|
|
62
|
+
language: context.language
|
|
63
|
+
});
|
|
64
|
+
const baseLedger = scanJsTsTopLevelLedger(baseSourceText, 'base', scanContext);
|
|
65
|
+
const workerLedger = scanJsTsTopLevelLedger(workerSourceText, 'worker', scanContext);
|
|
66
|
+
const headLedger = scanJsTsTopLevelLedger(headSourceText, 'head', scanContext);
|
|
67
|
+
if (scanContext.conflicts.length) return undefined;
|
|
68
|
+
if (baseLedger.entries.length !== workerLedger.entries.length || baseLedger.entries.length !== headLedger.entries.length) return undefined;
|
|
69
|
+
const importKey = conflict.details?.key;
|
|
70
|
+
let removal;
|
|
71
|
+
for (let index = 0; index < baseLedger.entries.length; index += 1) {
|
|
72
|
+
const baseEntry = baseLedger.entries[index];
|
|
73
|
+
const workerEntry = workerLedger.entries[index];
|
|
74
|
+
const headEntry = headLedger.entries[index];
|
|
75
|
+
if (!headEntryMatchesBase(baseEntry, headEntry) || baseEntry.kind !== workerEntry.kind || baseEntry.key !== workerEntry.key) return undefined;
|
|
76
|
+
if (baseEntry.kind === 'import' && baseEntry.key === importKey) {
|
|
77
|
+
removal = importSpecifierRemovalUsageProof(baseEntry, workerEntry, removedSpecifier);
|
|
78
|
+
if (!removal) return undefined;
|
|
79
|
+
} else if (!sameStatementText(baseEntry.text, workerEntry.text)) return undefined;
|
|
80
|
+
}
|
|
81
|
+
if (!removal) return undefined;
|
|
82
|
+
const lexicalUseDefEvidence = analyzeImportRemovalUseDefEvidence({
|
|
83
|
+
sourcePath: file.sourcePath,
|
|
84
|
+
sourceText: workerSourceText,
|
|
85
|
+
moduleSpecifier: removal.moduleSpecifier,
|
|
86
|
+
removedSpecifier: removal.removedSpecifier,
|
|
87
|
+
importedName: removal.importedName,
|
|
88
|
+
localName: removal.localName,
|
|
89
|
+
typeOnly: removal.typeOnly
|
|
90
|
+
});
|
|
91
|
+
return { ...removal, importKey, sourcePath: file.sourcePath, outputSourceText: workerSourceText, lexicalUseDefEvidence };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function importSpecifierRemovalUsageProof(baseEntry, workerEntry, removedSpecifier) {
|
|
95
|
+
const baseImport = baseEntry.importInfo;
|
|
96
|
+
const workerImport = workerEntry.importInfo;
|
|
97
|
+
if (!baseImport || !workerImport || baseImport.sideEffectOnly || workerImport.sideEffectOnly) return undefined;
|
|
98
|
+
if (baseImport.moduleSpecifier !== workerImport.moduleSpecifier
|
|
99
|
+
|| baseImport.typeOnly !== workerImport.typeOnly
|
|
100
|
+
|| baseImport.defaultLocalName !== workerImport.defaultLocalName
|
|
101
|
+
|| baseImport.namespaceLocalName !== workerImport.namespaceLocalName) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const baseSpecifiers = baseImport.specifiers.map((specifier) => specifier.canonical);
|
|
105
|
+
const workerSpecifiers = workerImport.specifiers.map((specifier) => specifier.canonical);
|
|
106
|
+
const expectedWorkerSpecifiers = baseSpecifiers.filter((specifier) => specifier !== removedSpecifier);
|
|
107
|
+
if (expectedWorkerSpecifiers.length !== baseSpecifiers.length - 1) return undefined;
|
|
108
|
+
if (!arraysEqual(workerSpecifiers, expectedWorkerSpecifiers)) return undefined;
|
|
109
|
+
const removed = baseImport.specifiers.find((specifier) => specifier.canonical === removedSpecifier);
|
|
110
|
+
if (!removed) return undefined;
|
|
111
|
+
return {
|
|
112
|
+
removedSpecifier,
|
|
113
|
+
importedName: removed.importedName,
|
|
114
|
+
localName: removed.localName,
|
|
115
|
+
moduleSpecifier: baseImport.moduleSpecifier,
|
|
116
|
+
typeOnly: baseImport.typeOnly || removed.typeOnly,
|
|
117
|
+
remainingSpecifiers: workerSpecifiers
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function blockedImportRemovalLexicalUseDefFile(file, context, result, usageProof) {
|
|
122
|
+
const reasonCodes = usageProof.lexicalUseDefEvidence.reasonCodes
|
|
123
|
+
.filter((code) => code !== LexicalUseDefReasonCodes.noLiveReferences);
|
|
124
|
+
const conflict = {
|
|
125
|
+
code: ImportRemovalLexicalUseDefConflictCode,
|
|
126
|
+
gateId: ImportRemovalLexicalUseDefGateId,
|
|
127
|
+
message: 'Project import specifier removal has live lexical references or namespace conflicts.',
|
|
128
|
+
sourcePath: file.sourcePath,
|
|
129
|
+
details: compactRecord({
|
|
130
|
+
sourcePath: file.sourcePath,
|
|
131
|
+
importKey: usageProof.importKey,
|
|
132
|
+
moduleSpecifier: usageProof.moduleSpecifier,
|
|
133
|
+
removedSpecifier: usageProof.removedSpecifier,
|
|
134
|
+
localName: usageProof.localName,
|
|
135
|
+
reasonCodes,
|
|
136
|
+
lexicalUseDefEvidence: usageProof.lexicalUseDefEvidence,
|
|
137
|
+
originalReasonCodes: result.admission?.reasonCodes
|
|
138
|
+
})
|
|
139
|
+
};
|
|
140
|
+
const conflicts = [...(result.conflicts ?? []), conflict];
|
|
141
|
+
return compactRecord({
|
|
142
|
+
kind: 'frontier.lang.jsTsProjectSafeMergeFile',
|
|
143
|
+
version: 1,
|
|
144
|
+
sourcePath: file.sourcePath,
|
|
145
|
+
language: context.language,
|
|
146
|
+
status: 'blocked',
|
|
147
|
+
operation: 'blocked-import-removal-lexical-use-def',
|
|
148
|
+
result,
|
|
149
|
+
conflicts,
|
|
150
|
+
admission: {
|
|
151
|
+
status: 'blocked',
|
|
152
|
+
action: 'human-review',
|
|
153
|
+
reviewRequired: true,
|
|
154
|
+
autoApplyCandidate: false,
|
|
155
|
+
autoMergeClaim: false,
|
|
156
|
+
semanticEquivalenceClaim: false,
|
|
157
|
+
reasonCodes: uniqueStrings([...conflicts.map((item) => item.code), ...reasonCodes])
|
|
158
|
+
},
|
|
159
|
+
summary: importRemovalUsageProofSummary(usageProof, conflicts.length),
|
|
160
|
+
conflictKeys: [`source#${file.sourcePath}`],
|
|
161
|
+
metadata: importRemovalUsageProofMetadata({}, usageProof, 'blocked-lexical-use-def')
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function blockedImportRemovalUsageProofFile(file, context, result, usageProof) {
|
|
166
|
+
const conflict = {
|
|
167
|
+
code: ImportRemovalUsageProofConflictCode,
|
|
168
|
+
gateId: ImportRemovalUsageProofGateId,
|
|
169
|
+
message: 'Project import specifier removal requires caller-supplied TypeScript output diagnostics before automatic merge.',
|
|
170
|
+
sourcePath: file.sourcePath,
|
|
171
|
+
details: compactRecord({
|
|
172
|
+
sourcePath: file.sourcePath,
|
|
173
|
+
importKey: usageProof.importKey,
|
|
174
|
+
moduleSpecifier: usageProof.moduleSpecifier,
|
|
175
|
+
removedSpecifier: usageProof.removedSpecifier,
|
|
176
|
+
requiredEvidence: 'project-output-diagnostics',
|
|
177
|
+
originalReasonCodes: result.admission?.reasonCodes
|
|
178
|
+
})
|
|
179
|
+
};
|
|
180
|
+
const conflicts = [...(result.conflicts ?? []), conflict];
|
|
181
|
+
return compactRecord({
|
|
182
|
+
kind: 'frontier.lang.jsTsProjectSafeMergeFile',
|
|
183
|
+
version: 1,
|
|
184
|
+
sourcePath: file.sourcePath,
|
|
185
|
+
language: context.language,
|
|
186
|
+
status: 'blocked',
|
|
187
|
+
operation: 'blocked-import-removal-usage-proof',
|
|
188
|
+
result,
|
|
189
|
+
conflicts,
|
|
190
|
+
admission: {
|
|
191
|
+
status: 'blocked',
|
|
192
|
+
action: 'human-review',
|
|
193
|
+
reviewRequired: true,
|
|
194
|
+
autoApplyCandidate: false,
|
|
195
|
+
autoMergeClaim: false,
|
|
196
|
+
semanticEquivalenceClaim: false,
|
|
197
|
+
reasonCodes: uniqueStrings(conflicts.map((item) => item.code))
|
|
198
|
+
},
|
|
199
|
+
summary: importRemovalUsageProofSummary(usageProof, conflicts.length),
|
|
200
|
+
conflictKeys: [`source#${file.sourcePath}`],
|
|
201
|
+
metadata: importRemovalUsageProofMetadata({}, usageProof, 'unavailable')
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function importRemovalUsageProofMergeResult(context, result, usageProof, input, admission) {
|
|
206
|
+
return {
|
|
207
|
+
kind: 'frontier.lang.jsTsSafeMerge',
|
|
208
|
+
version: 1,
|
|
209
|
+
schema: 'frontier.lang.jsTsSafeMerge.v1',
|
|
210
|
+
id: result.id,
|
|
211
|
+
status: JsTsSafeMergeStatuses.merged,
|
|
212
|
+
sourcePath: context.sourcePath,
|
|
213
|
+
language: context.language,
|
|
214
|
+
mergedSourceText: usageProof.outputSourceText,
|
|
215
|
+
outputSourceText: usageProof.outputSourceText,
|
|
216
|
+
conflicts: [],
|
|
217
|
+
gates: jsTsSafeMergeGateOrder.map((id) => ({ id, status: 'passed', reasonCodes: [] })),
|
|
218
|
+
admission,
|
|
219
|
+
summary: importRemovalUsageProofSummary(usageProof, 0),
|
|
220
|
+
metadata: importRemovalUsageProofMetadata(input, usageProof, 'pending-project-output-diagnostics')
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function hasImportRemovalUsageProofInput(input) {
|
|
225
|
+
if (input.outputDiagnostics !== undefined && input.outputDiagnostics !== null) return true;
|
|
226
|
+
const diagnosticOptions = input.diagnosticOptions ?? input.typescriptDiagnosticOptions ?? {};
|
|
227
|
+
if (diagnosticOptions.semantic === false) return false;
|
|
228
|
+
const ts = input.typescript ?? input.ts ?? input.typescriptModule;
|
|
229
|
+
return Boolean(ts?.createProgram && ts?.createSourceFile);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function admittedImportRemovalUsageProofAdmission() {
|
|
233
|
+
return {
|
|
234
|
+
status: 'auto-merge-candidate',
|
|
235
|
+
action: 'apply',
|
|
236
|
+
reviewRequired: false,
|
|
237
|
+
autoApplyCandidate: true,
|
|
238
|
+
autoMergeClaim: false,
|
|
239
|
+
semanticEquivalenceClaim: false,
|
|
240
|
+
reasonCodes: []
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function importRemovalUsageProofSummary(usageProof, conflicts) {
|
|
245
|
+
return {
|
|
246
|
+
importSpecifierAdditions: 0,
|
|
247
|
+
importSpecifierRemovals: 1,
|
|
248
|
+
importDeclarationAdditions: 0,
|
|
249
|
+
topLevelDeclarationAdditions: 0,
|
|
250
|
+
changedExistingDeclarations: 0,
|
|
251
|
+
conflicts,
|
|
252
|
+
gatesPassed: conflicts ? 0 : jsTsSafeMergeGateOrder.length,
|
|
253
|
+
removedImportSpecifiers: [usageProof.removedSpecifier]
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function importRemovalUsageProofMetadata(input, usageProof, status) {
|
|
258
|
+
return {
|
|
259
|
+
importRemovalUsageProof: compactRecord({
|
|
260
|
+
status,
|
|
261
|
+
proof: 'project-output-diagnostics',
|
|
262
|
+
diagnosticSource: diagnosticProofSource(input),
|
|
263
|
+
sourcePath: usageProof.sourcePath,
|
|
264
|
+
importKey: usageProof.importKey,
|
|
265
|
+
moduleSpecifier: usageProof.moduleSpecifier,
|
|
266
|
+
removedSpecifier: usageProof.removedSpecifier,
|
|
267
|
+
localName: usageProof.localName,
|
|
268
|
+
typeOnly: usageProof.typeOnly || undefined,
|
|
269
|
+
lexicalUseDefEvidence: usageProof.lexicalUseDefEvidence,
|
|
270
|
+
autoMergeClaim: false,
|
|
271
|
+
semanticEquivalenceClaim: false
|
|
272
|
+
})
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function diagnosticProofSource(input) {
|
|
277
|
+
if (input.outputDiagnostics !== undefined && input.outputDiagnostics !== null) return 'supplied';
|
|
278
|
+
if (input.typescript || input.ts || input.typescriptModule) return 'typescript-compiler-api';
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function headEntryMatchesBase(baseEntry, headEntry) {
|
|
283
|
+
return baseEntry.kind === headEntry.kind && baseEntry.key === headEntry.key && sameStatementText(baseEntry.text, headEntry.text);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function arraysEqual(left, right) {
|
|
287
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function hashText(text) { return typeof text === 'string' ? hashSemanticValue(text) : undefined; }
|
|
291
|
+
|
|
292
|
+
export { ImportRemovalUsageProofOperation, maybeMergeImportSpecifierRemovalFile };
|