@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.
- 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-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 +31 -0
- package/dist/index.js +5 -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/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-jsx-attribute-fallback.js +151 -157
- 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-semantic-edit-fallback.js +13 -5
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +3 -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 +170 -171
- 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
|
@@ -16,8 +16,13 @@ function createVariableDeclaratorSemanticFallbackResult(input, topLevelResult, s
|
|
|
16
16
|
headSourceText: input.headSourceText,
|
|
17
17
|
currentSourceText
|
|
18
18
|
});
|
|
19
|
-
if (!merge.ok || merge.sourceText === currentSourceText) return undefined;
|
|
20
19
|
const resultBase = stagedFallback?.stagedTopLevelResult ?? topLevelResult;
|
|
20
|
+
if (!merge.ok) {
|
|
21
|
+
return merge.sourceShapeBlocked
|
|
22
|
+
? variableDeclaratorBlockedResult(input, topLevelResult, resultBase, stagedFallback, merge)
|
|
23
|
+
: undefined;
|
|
24
|
+
}
|
|
25
|
+
if (merge.sourceText === currentSourceText) return undefined;
|
|
21
26
|
const language = input.language ?? topLevelResult.language ?? 'typescript';
|
|
22
27
|
const sourcePath = input.sourcePath ?? topLevelResult.sourcePath ?? 'inline.ts';
|
|
23
28
|
const phase = stagedFallback
|
|
@@ -142,17 +147,28 @@ function mergeVariableStatement(base, worker, head, current) {
|
|
|
142
147
|
const workerDeclarator = worker.declarators[index];
|
|
143
148
|
const headDeclarator = head.declarators[index];
|
|
144
149
|
const currentDeclarator = current.declarators[index];
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
const bindingPatternReasonCodes = classifyDeclaratorBindingPattern(baseDeclarator, workerDeclarator, headDeclarator, currentDeclarator);
|
|
151
|
+
if (bindingPatternReasonCodes.length) return blockedStatement(...bindingPatternReasonCodes);
|
|
152
|
+
if (![workerDeclarator, headDeclarator, currentDeclarator].every((entry) => entry?.key === baseDeclarator.key)) {
|
|
153
|
+
return blockedStatement(
|
|
154
|
+
...declaratorKeyChangeReasonCodes(baseDeclarator, workerDeclarator, headDeclarator, currentDeclarator),
|
|
155
|
+
'variable-declarator-name-order-changed'
|
|
156
|
+
);
|
|
147
157
|
}
|
|
148
158
|
const workerChanged = !sameVariableDeclaratorText(baseDeclarator.text, workerDeclarator.text);
|
|
149
159
|
const headChanged = !sameVariableDeclaratorText(baseDeclarator.text, headDeclarator.text);
|
|
150
160
|
if (workerChanged && headChanged && !sameVariableDeclaratorText(workerDeclarator.text, headDeclarator.text)) {
|
|
151
|
-
return blockedStatement(
|
|
161
|
+
return blockedStatement(
|
|
162
|
+
...bindingDeclaratorConflictReasonCodes(baseDeclarator),
|
|
163
|
+
'variable-declarator-conflict'
|
|
164
|
+
);
|
|
152
165
|
}
|
|
153
166
|
if (!sameVariableDeclaratorText(currentDeclarator.text, headDeclarator.text)
|
|
154
167
|
&& !sameVariableDeclaratorText(currentDeclarator.text, workerDeclarator.text)) {
|
|
155
|
-
return blockedStatement(
|
|
168
|
+
return blockedStatement(
|
|
169
|
+
...bindingDeclaratorConflictReasonCodes(baseDeclarator),
|
|
170
|
+
'variable-declarator-current-diverged'
|
|
171
|
+
);
|
|
156
172
|
}
|
|
157
173
|
const replacement = workerChanged ? workerDeclarator.text : currentDeclarator.text;
|
|
158
174
|
if (!sameVariableDeclaratorText(replacement, currentDeclarator.text)) changed = true;
|
|
@@ -164,6 +180,46 @@ function mergeVariableStatement(base, worker, head, current) {
|
|
|
164
180
|
};
|
|
165
181
|
}
|
|
166
182
|
|
|
183
|
+
function classifyDeclaratorBindingPattern(base, worker, head, current) {
|
|
184
|
+
const declarators = [base, worker, head, current].filter(Boolean);
|
|
185
|
+
if (!declarators.some((entry) => entry.binding?.kind === 'binding-pattern')) return [];
|
|
186
|
+
const reasonCodes = uniqueStrings(declarators.flatMap((entry) => entry.binding?.reasonCodes ?? []));
|
|
187
|
+
if (reasonCodes.length) return reasonCodes;
|
|
188
|
+
if (!declarators.every((entry) => entry.binding?.kind === base.binding?.kind && entry.binding?.patternKind === base.binding?.patternKind)) {
|
|
189
|
+
return [
|
|
190
|
+
'binding-pattern-kind-changed',
|
|
191
|
+
'binding-pattern-merge-requires-binding-use-evidence'
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
const patternTexts = declarators.map((entry) => entry.binding?.patternText);
|
|
195
|
+
if (patternTexts.some((text) => !sameVariableDeclaratorText(text, patternTexts[0]))) {
|
|
196
|
+
return [
|
|
197
|
+
'binding-pattern-shape-changed',
|
|
198
|
+
'binding-pattern-merge-requires-binding-use-evidence'
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
const bindingNames = declarators.map((entry) => (entry.binding?.bindingNames ?? []).join('\0'));
|
|
202
|
+
if (bindingNames.some((names) => names !== bindingNames[0])) {
|
|
203
|
+
return [
|
|
204
|
+
'binding-pattern-binding-set-changed',
|
|
205
|
+
'binding-pattern-merge-requires-binding-use-evidence'
|
|
206
|
+
];
|
|
207
|
+
}
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function declaratorKeyChangeReasonCodes(base, worker, head, current) {
|
|
212
|
+
return [base, worker, head, current].some((entry) => entry?.binding?.kind === 'binding-pattern')
|
|
213
|
+
? ['binding-pattern-kind-changed', 'binding-pattern-merge-requires-binding-use-evidence']
|
|
214
|
+
: [];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function bindingDeclaratorConflictReasonCodes(base) {
|
|
218
|
+
return base?.binding?.kind === 'binding-pattern'
|
|
219
|
+
? ['binding-pattern-merge-requires-binding-use-evidence']
|
|
220
|
+
: [];
|
|
221
|
+
}
|
|
222
|
+
|
|
167
223
|
function semanticArtifactGates(artifacts) {
|
|
168
224
|
return [
|
|
169
225
|
gate('semantic-edit-script', artifacts.script?.admission?.status === 'auto-merge-candidate', artifacts.script?.admission?.reasonCodes),
|
|
@@ -177,8 +233,70 @@ function gate(id, passed, reasonCodes = []) {
|
|
|
177
233
|
return { id, status: passed ? 'passed' : 'blocked', reasonCodes: passed ? [] : uniqueStrings(reasonCodes) };
|
|
178
234
|
}
|
|
179
235
|
|
|
236
|
+
function variableDeclaratorBlockedResult(input, topLevelResult, resultBase, stagedFallback, merge) {
|
|
237
|
+
const reasonCodes = merge.reasonCodes;
|
|
238
|
+
const language = input.language ?? topLevelResult.language ?? 'typescript';
|
|
239
|
+
const sourcePath = input.sourcePath ?? topLevelResult.sourcePath ?? 'inline.ts';
|
|
240
|
+
return {
|
|
241
|
+
...resultBase,
|
|
242
|
+
id: String(input.id ?? resultBase.id ?? topLevelResult.id),
|
|
243
|
+
status: JsTsSafeMergeStatuses.blocked,
|
|
244
|
+
mergedSourceText: undefined,
|
|
245
|
+
outputSourceText: undefined,
|
|
246
|
+
conflicts: [{
|
|
247
|
+
code: reasonCodes[0] ?? 'binding-pattern-merge-blocked',
|
|
248
|
+
gateId: 'variable-declarator-binding-pattern',
|
|
249
|
+
message: 'JS/TS variable declarator binding pattern requires binding/use evidence before automatic merge.',
|
|
250
|
+
side: 'worker',
|
|
251
|
+
sourcePath,
|
|
252
|
+
details: {
|
|
253
|
+
reasonCodes,
|
|
254
|
+
originalReasonCodes: topLevelResult.admission?.reasonCodes ?? []
|
|
255
|
+
}
|
|
256
|
+
}],
|
|
257
|
+
admission: {
|
|
258
|
+
status: 'blocked',
|
|
259
|
+
action: 'human-review',
|
|
260
|
+
reviewRequired: true,
|
|
261
|
+
autoApplyCandidate: false,
|
|
262
|
+
autoMergeClaim: false,
|
|
263
|
+
semanticEquivalenceClaim: false,
|
|
264
|
+
reasonCodes
|
|
265
|
+
},
|
|
266
|
+
summary: {
|
|
267
|
+
...resultBase.summary,
|
|
268
|
+
changedExistingDeclarations: semanticFallbackChangedExistingDeclarations(topLevelResult, resultBase, stagedFallback),
|
|
269
|
+
conflicts: 1,
|
|
270
|
+
variableDeclaratorBindingPatternBlocks: 1,
|
|
271
|
+
composedPhases: stagedFallback ? 2 : 1
|
|
272
|
+
},
|
|
273
|
+
metadata: {
|
|
274
|
+
...resultBase.metadata,
|
|
275
|
+
composed: {
|
|
276
|
+
phase: stagedFallback
|
|
277
|
+
? 'staged-top-level-variable-declarator-binding-pattern-classification'
|
|
278
|
+
: 'variable-declarator-binding-pattern-classification',
|
|
279
|
+
phases: stagedFallback
|
|
280
|
+
? ['top-level-neutralization', 'top-level-ledger', 'variable-declarator-binding-pattern']
|
|
281
|
+
: ['top-level-ledger', 'variable-declarator-binding-pattern'],
|
|
282
|
+
originalReasonCodes: topLevelResult.admission?.reasonCodes ?? [],
|
|
283
|
+
stagedTopLevelSummary: stagedFallback?.stagedTopLevelResult?.summary,
|
|
284
|
+
neutralization: stagedFallback?.neutralization?.summary,
|
|
285
|
+
variableDeclaratorFallback: merge.summary,
|
|
286
|
+
language
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
180
292
|
function blocked(...reasonCodes) {
|
|
181
|
-
|
|
293
|
+
const normalized = uniqueStrings(reasonCodes);
|
|
294
|
+
return {
|
|
295
|
+
ok: false,
|
|
296
|
+
reasonCodes: normalized,
|
|
297
|
+
sourceShapeBlocked: normalized.some((reasonCode) => reasonCode.startsWith('binding-pattern-')),
|
|
298
|
+
summary: { reasonCodes: normalized }
|
|
299
|
+
};
|
|
182
300
|
}
|
|
183
301
|
|
|
184
302
|
function blockedStatement(...reasonCodes) {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
analyzeJsTsBindingPattern,
|
|
3
|
+
leadingJsTsBindingPatternText
|
|
4
|
+
} from './js-ts-safe-merge-binding-patterns.js';
|
|
1
5
|
import { normalizeLineEndings, uniqueStrings } from './js-ts-safe-merge-context.js';
|
|
2
6
|
|
|
3
7
|
function variableStatementsByKey(sourceText) {
|
|
@@ -27,14 +31,14 @@ function parseVariableStatement(statement) {
|
|
|
27
31
|
const declaratorText = text.slice(prefixEnd, suffixStart);
|
|
28
32
|
if (/[\r\n]/.test(declaratorText)) return undefined;
|
|
29
33
|
const declarators = splitDeclarators(declaratorText, prefixEnd);
|
|
30
|
-
if (declarators.length < 2 || declarators.some((entry) => !entry.
|
|
34
|
+
if (declarators.length < 2 || declarators.some((entry) => !entry.key)) return undefined;
|
|
31
35
|
return {
|
|
32
36
|
start: statement.start,
|
|
33
37
|
end: statement.end,
|
|
34
38
|
text,
|
|
35
39
|
prefix: text.slice(0, prefixEnd),
|
|
36
40
|
suffix: text.slice(suffixStart),
|
|
37
|
-
names: declarators.map((entry) => entry.
|
|
41
|
+
names: declarators.map((entry) => entry.key),
|
|
38
42
|
declarators
|
|
39
43
|
};
|
|
40
44
|
}
|
|
@@ -104,15 +108,41 @@ function declaratorPart(text, start, end, offset) {
|
|
|
104
108
|
while (localStart < localEnd && /\s/u.test(text[localStart])) localStart += 1;
|
|
105
109
|
while (localEnd > localStart && /\s/u.test(text[localEnd - 1])) localEnd -= 1;
|
|
106
110
|
const value = text.slice(localStart, localEnd);
|
|
107
|
-
const
|
|
111
|
+
const binding = declaratorBinding(value);
|
|
108
112
|
return {
|
|
109
|
-
name: name
|
|
113
|
+
name: binding?.name,
|
|
114
|
+
key: binding?.key,
|
|
115
|
+
binding,
|
|
110
116
|
text: value,
|
|
111
117
|
start: offset + localStart,
|
|
112
118
|
end: offset + localEnd
|
|
113
119
|
};
|
|
114
120
|
}
|
|
115
121
|
|
|
122
|
+
function declaratorBinding(value) {
|
|
123
|
+
const identifier = /^[A-Za-z_$][\w$]*/u.exec(value)?.[0];
|
|
124
|
+
if (identifier && value[identifier.length] !== '?') {
|
|
125
|
+
return { kind: 'identifier', patternKind: 'identifier', name: identifier, key: identifier, reasonCodes: [] };
|
|
126
|
+
}
|
|
127
|
+
let start = 0;
|
|
128
|
+
while (start < value.length && /\s/u.test(value[start])) start += 1;
|
|
129
|
+
const open = value[start];
|
|
130
|
+
if (open !== '{' && open !== '[') return undefined;
|
|
131
|
+
const patternKind = open === '{' ? 'object' : 'array';
|
|
132
|
+
const patternText = leadingJsTsBindingPatternText(value.slice(start), patternKind);
|
|
133
|
+
if (!patternText) return undefined;
|
|
134
|
+
const pattern = analyzeJsTsBindingPattern(patternText, patternKind);
|
|
135
|
+
return {
|
|
136
|
+
kind: 'binding-pattern',
|
|
137
|
+
patternKind: pattern.patternKind,
|
|
138
|
+
name: `binding-pattern:${pattern.patternKind}`,
|
|
139
|
+
key: `binding-pattern:${pattern.patternKind}`,
|
|
140
|
+
patternText,
|
|
141
|
+
bindingNames: pattern.bindingNames,
|
|
142
|
+
reasonCodes: pattern.reasonCodes
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
116
146
|
function topLevelStatements(sourceText) {
|
|
117
147
|
const statements = [];
|
|
118
148
|
let start = 0;
|
package/dist/js-ts-safe-merge.js
CHANGED
|
@@ -12,6 +12,9 @@ import { createJsTsSafeMergeSemanticArtifacts } from './js-ts-safe-merge-semanti
|
|
|
12
12
|
|
|
13
13
|
export { JsTsSafeMergeConflictCodes, JsTsSafeMergeGateIds, JsTsSafeMergeStatuses };
|
|
14
14
|
|
|
15
|
+
const mergedOutputSyntaxDiagnosticCode = 'merged-output-syntax-diagnostic';
|
|
16
|
+
const mergedOutputSyntaxDiagnosticsUnavailableCode = 'merged-output-syntax-diagnostics-unavailable';
|
|
17
|
+
|
|
15
18
|
export function safeMergeJsTsImportsAndDeclarations(input = {}) {
|
|
16
19
|
const context = createMergeContext(input);
|
|
17
20
|
const baseSourceText = input.baseSourceText;
|
|
@@ -60,6 +63,7 @@ export function safeMergeJsTsImportsAndDeclarations(input = {}) {
|
|
|
60
63
|
const mergedSourceText = applySourceMergePlan(headSourceText, mergePlan);
|
|
61
64
|
const merged = scanJsTsTopLevelLedger(mergedSourceText, 'merged', context);
|
|
62
65
|
if (!context.conflicts.length) validateLedgerUniqueness(merged, context);
|
|
66
|
+
if (!context.conflicts.length) validateMergedOutputSyntaxGate(input, context);
|
|
63
67
|
if (context.conflicts.length) return blockedResult(context, { base, worker, head, merged });
|
|
64
68
|
|
|
65
69
|
const result = {
|
|
@@ -179,3 +183,135 @@ function hasLedgerSpan(entry) {
|
|
|
179
183
|
const hasLines = Number.isFinite(span.startLine) && Number.isFinite(span.endLine);
|
|
180
184
|
return hasOffsets || hasLines;
|
|
181
185
|
}
|
|
186
|
+
|
|
187
|
+
function validateMergedOutputSyntaxGate(input, context) {
|
|
188
|
+
const diagnostics = normalizeMergedOutputSyntaxDiagnostics(input, context.sourcePath);
|
|
189
|
+
if (!diagnostics) {
|
|
190
|
+
if (requiresMergedOutputSyntaxDiagnostics(input)) {
|
|
191
|
+
addConflict(context, {
|
|
192
|
+
code: mergedOutputSyntaxDiagnosticsUnavailableCode,
|
|
193
|
+
gateId: JsTsSafeMergeGateIds.parseLedger,
|
|
194
|
+
side: 'merged',
|
|
195
|
+
message: 'Merged JS/TS output syntax diagnostics are required but were not provided.',
|
|
196
|
+
details: { required: true, diagnosticSource: 'missing' }
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
for (const diagnostic of diagnostics) {
|
|
202
|
+
if (diagnostic.severity !== 'error' || !isSyntaxDiagnostic(diagnostic)) continue;
|
|
203
|
+
addConflict(context, {
|
|
204
|
+
code: mergedOutputSyntaxDiagnosticCode,
|
|
205
|
+
gateId: JsTsSafeMergeGateIds.parseLedger,
|
|
206
|
+
side: 'merged',
|
|
207
|
+
message: `Merged JS/TS output syntax diagnostic ${diagnostic.code}: ${diagnostic.message}`,
|
|
208
|
+
details: { diagnostic }
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function requiresMergedOutputSyntaxDiagnostics(input) {
|
|
214
|
+
return input.requireMergedOutputSyntaxDiagnostics === true
|
|
215
|
+
|| input.requireOutputSyntaxDiagnostics === true
|
|
216
|
+
|| input.requireOutputSyntaxGate === true
|
|
217
|
+
|| input.requireSyntaxGate === true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function normalizeMergedOutputSyntaxDiagnostics(input, sourcePath) {
|
|
221
|
+
const values = [
|
|
222
|
+
input.mergedOutputSyntaxDiagnostics,
|
|
223
|
+
input.outputSyntaxDiagnostics,
|
|
224
|
+
input.syntaxDiagnostics?.merged,
|
|
225
|
+
input.syntaxDiagnostics?.output,
|
|
226
|
+
input.outputDiagnostics
|
|
227
|
+
];
|
|
228
|
+
if (!values.some((value) => value !== undefined)) return undefined;
|
|
229
|
+
const expectedPath = normalizeDiagnosticPath(sourcePath);
|
|
230
|
+
const diagnostics = values
|
|
231
|
+
.flatMap((value) => normalizeDiagnosticList(value))
|
|
232
|
+
.filter((diagnostic) => {
|
|
233
|
+
const diagnosticPath = normalizeDiagnosticPath(diagnostic.sourcePath);
|
|
234
|
+
return !expectedPath || !diagnosticPath || expectedPath === diagnosticPath;
|
|
235
|
+
});
|
|
236
|
+
return diagnostics;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function normalizeDiagnosticList(value) {
|
|
240
|
+
if (value === undefined) return [];
|
|
241
|
+
const values = Array.isArray(value) ? value : [value].filter(Boolean);
|
|
242
|
+
return values.map((diagnostic, index) => compactRecord({
|
|
243
|
+
id: diagnostic.id ?? `diagnostic_${index + 1}`,
|
|
244
|
+
source: diagnostic.source ?? diagnostic.tool ?? diagnostic.name,
|
|
245
|
+
code: String(diagnostic.code ?? diagnostic.diagnosticCode ?? diagnostic.name ?? 'syntax-diagnostic'),
|
|
246
|
+
severity: normalizeDiagnosticSeverity(diagnostic.severity ?? diagnostic.category),
|
|
247
|
+
message: String(diagnostic.message ?? diagnostic.messageText ?? ''),
|
|
248
|
+
sourcePath: normalizeDiagnosticPath(diagnostic.sourcePath ?? diagnostic.fileName ?? diagnostic.file?.fileName),
|
|
249
|
+
start: numberOrUndefined(diagnostic.start),
|
|
250
|
+
end: numberOrUndefined(diagnostic.end),
|
|
251
|
+
line: numberOrUndefined(diagnostic.line),
|
|
252
|
+
column: numberOrUndefined(diagnostic.column),
|
|
253
|
+
phase: normalizeDiagnosticPhase(diagnostic.phase ?? diagnostic.diagnosticPhase ?? diagnostic.kind ?? diagnostic.type),
|
|
254
|
+
syntax: diagnostic.syntax === true ? true : undefined
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function isSyntaxDiagnostic(diagnostic) {
|
|
259
|
+
if (diagnostic.syntax === true) return true;
|
|
260
|
+
const text = [
|
|
261
|
+
diagnostic.phase,
|
|
262
|
+
diagnostic.kind,
|
|
263
|
+
diagnostic.category,
|
|
264
|
+
diagnostic.type,
|
|
265
|
+
diagnostic.source,
|
|
266
|
+
diagnostic.ruleId,
|
|
267
|
+
diagnostic.name,
|
|
268
|
+
diagnostic.code
|
|
269
|
+
].filter(Boolean).join(' ').toLowerCase();
|
|
270
|
+
return /\bsyntax\b|\bsyntactic\b|\bparse\b|\bparser\b/.test(text) || isTypeScriptSyntaxDiagnosticCode(diagnostic.code);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function isTypeScriptSyntaxDiagnosticCode(code) {
|
|
274
|
+
const match = /^TS(\d+)$/.exec(String(code ?? ''));
|
|
275
|
+
if (!match) return false;
|
|
276
|
+
const numeric = Number(match[1]);
|
|
277
|
+
return numeric >= 1000 && numeric < 2000;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function normalizeDiagnosticSeverity(value) {
|
|
281
|
+
if (typeof value === 'string') {
|
|
282
|
+
const lowered = value.toLowerCase();
|
|
283
|
+
if (lowered.includes('error')) return 'error';
|
|
284
|
+
if (lowered.includes('warn')) return 'warning';
|
|
285
|
+
if (lowered.includes('suggest')) return 'suggestion';
|
|
286
|
+
if (lowered.includes('message')) return 'message';
|
|
287
|
+
}
|
|
288
|
+
if (value === 1) return 'error';
|
|
289
|
+
if (value === 0) return 'warning';
|
|
290
|
+
if (value === 2) return 'suggestion';
|
|
291
|
+
if (value === 3) return 'message';
|
|
292
|
+
return 'error';
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function normalizeDiagnosticPhase(value) {
|
|
296
|
+
if (typeof value !== 'string') return undefined;
|
|
297
|
+
const lowered = value.toLowerCase();
|
|
298
|
+
if (lowered.includes('syntax') || lowered.includes('syntactic') || lowered.includes('parse')) return 'syntax';
|
|
299
|
+
if (lowered.includes('semantic') || lowered.includes('type')) return 'semantic';
|
|
300
|
+
return value;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function normalizeDiagnosticPath(value) {
|
|
304
|
+
if (value === undefined || value === null) return undefined;
|
|
305
|
+
const raw = String(value).replace(/\\/g, '/').replace(/\/+/g, '/');
|
|
306
|
+
const parts = [];
|
|
307
|
+
for (const part of raw.split('/')) {
|
|
308
|
+
if (!part || part === '.') continue;
|
|
309
|
+
if (part === '..' && parts.length) parts.pop();
|
|
310
|
+
else if (part !== '..') parts.push(part);
|
|
311
|
+
}
|
|
312
|
+
return parts.join('/');
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function numberOrUndefined(value) {
|
|
316
|
+
return Number.isFinite(value) ? value : undefined;
|
|
317
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
const exactAdmissionRouteSpecs = Object.freeze({
|
|
2
|
+
'js-ts-project-symbol-rename-admission': routeSpec('apply-cross-file-symbol-rename', 'cross-file-symbol-rename', 'apply-project-symbol-rename'),
|
|
3
|
+
'js-ts-project-symbol-move-admission': routeSpec('apply-symbol-move-between-files', 'symbol-move-between-files', 'apply-project-symbol-move'),
|
|
4
|
+
'js-ts-project-split-merge-admission': routeSpec('apply-project-split-merge', 'split-merge-modules-classes', 'apply-project-split-merge')
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const classificationRouteSpecs = Object.freeze({
|
|
8
|
+
'cross-file-symbol-rename': routeSpec('review-cross-file-symbol-rename', 'cross-file-symbol-rename', 'supply-import-export-rewrite-diagnostics-and-declarations'),
|
|
9
|
+
'exported-symbol-move': routeSpec('review-symbol-move-between-files', 'symbol-move-between-files', 'supply-symbol-lineage-rewrite-diagnostics-and-declarations'),
|
|
10
|
+
'imported-symbol-move': routeSpec('review-symbol-move-between-files', 'symbol-move-between-files', 'supply-symbol-lineage-rewrite-diagnostics-and-declarations'),
|
|
11
|
+
'file-move-rename': routeSpec('review-file-move-rename', 'file-move-rename', 'supply-path-lineage-rewrite-diagnostics-and-declarations'),
|
|
12
|
+
'module-split': routeSpec('review-project-split-merge', 'split-merge-modules-classes', 'supply-structural-partition-diagnostics-and-declarations'),
|
|
13
|
+
'module-merge': routeSpec('review-project-split-merge', 'split-merge-modules-classes', 'supply-structural-partition-diagnostics-and-declarations'),
|
|
14
|
+
'class-split': routeSpec('review-project-split-merge', 'split-merge-modules-classes', 'supply-structural-partition-diagnostics-and-declarations'),
|
|
15
|
+
'class-merge': routeSpec('review-project-split-merge', 'split-merge-modules-classes', 'supply-structural-partition-diagnostics-and-declarations')
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function createProjectAdmissionRoutes(input = {}) {
|
|
19
|
+
return uniqueProjectAdmissionRoutes([
|
|
20
|
+
...(input.fileResults ?? []).flatMap(fileAdmissionRoutes),
|
|
21
|
+
...(input.missingEvidence ?? []).map(projectAdmissionRouteFromMissingEvidence),
|
|
22
|
+
...(input.conflicts ?? []).map(projectAdmissionRouteFromConflict)
|
|
23
|
+
].filter(Boolean));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function projectAdmissionRouteSummary(routes = []) {
|
|
27
|
+
return compactRecord({
|
|
28
|
+
total: routes.length,
|
|
29
|
+
byKind: countField(routes, 'routeKind'),
|
|
30
|
+
byAction: countField(routes, 'action'),
|
|
31
|
+
byLane: countField(routes, 'routeLane'),
|
|
32
|
+
byStatus: countField(routes, 'status'),
|
|
33
|
+
byRoute: countField(routes, 'routeId'),
|
|
34
|
+
nextRoute: routes.find((route) => route.status !== 'passed') ?? routes[0]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function projectAdmissionRouteFromExactAdmission(admission, options = {}) {
|
|
39
|
+
const spec = exactAdmissionRouteSpecs[admission?.kind] ?? routeSpec(`apply-${safeToken(admission?.kind ?? 'project-admission')}`, 'project-admission', options.action ?? 'apply-project');
|
|
40
|
+
return routeRecord({
|
|
41
|
+
routeId: spec.routeId,
|
|
42
|
+
routeKind: 'apply',
|
|
43
|
+
routeLane: spec.routeLane,
|
|
44
|
+
routeNext: spec.routeNext,
|
|
45
|
+
action: 'apply',
|
|
46
|
+
status: 'passed',
|
|
47
|
+
source: 'file-admission',
|
|
48
|
+
subjectKind: admission?.kind,
|
|
49
|
+
branch: admission?.branch,
|
|
50
|
+
sourcePath: admission?.sourcePath,
|
|
51
|
+
sourcePaths: admission?.details?.sourcePaths,
|
|
52
|
+
evidenceId: admission?.id,
|
|
53
|
+
conflictKey: admission?.details?.conflictKey,
|
|
54
|
+
reasonCodes: admission?.details?.reasonCode ? [admission.details.reasonCode] : [],
|
|
55
|
+
requiredEvidence: admission?.details?.requiredEvidence,
|
|
56
|
+
presentEvidence: admission?.details?.presentRequiredEvidence,
|
|
57
|
+
details: admission?.details
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function projectAdmissionRouteFromClassification(classification, options = {}) {
|
|
62
|
+
const details = classification?.details ?? {};
|
|
63
|
+
const spec = classificationRouteSpecs[classification?.kind] ?? routeSpec(`review-${safeToken(classification?.kind ?? classification?.code ?? 'project-admission')}`, 'project-admission', 'review-structural-admission-evidence');
|
|
64
|
+
const explicitRouteId = details.routeId ?? details.proofRouteId;
|
|
65
|
+
const staleRouteId = details.structuralProofRouteId;
|
|
66
|
+
const stale = details.staleStructuralEditProof === true || details.otherBranchChanged === true;
|
|
67
|
+
return routeRecord({
|
|
68
|
+
routeId: options.routeId ?? explicitRouteId ?? staleRouteId ?? spec.routeId,
|
|
69
|
+
routeKind: stale ? 'rebase' : 'review',
|
|
70
|
+
routeLane: stale ? 'split-merge-modules-classes' : details.routeLane ?? spec.routeLane,
|
|
71
|
+
routeNext: stale ? 'prove-current-branch-output-before-admission' : details.routeNext ?? spec.routeNext,
|
|
72
|
+
action: stale ? 'rebase' : 'review',
|
|
73
|
+
status: options.status ?? 'blocked',
|
|
74
|
+
source: options.source ?? 'classification',
|
|
75
|
+
subjectKind: classification?.kind,
|
|
76
|
+
branch: classification?.branch,
|
|
77
|
+
sourcePath: options.sourcePath,
|
|
78
|
+
sourcePaths: classification?.sourcePaths,
|
|
79
|
+
conflictKey: details.conflictKey,
|
|
80
|
+
reasonCodes: uniqueStrings([classification?.code, details.reasonCode, ...(details.missingRequiredEvidence ?? [])]),
|
|
81
|
+
requiredEvidence: details.requiredEvidence,
|
|
82
|
+
missingEvidence: details.missingRequiredEvidence,
|
|
83
|
+
details
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function projectAdmissionRouteFromConflict(conflict) {
|
|
88
|
+
const details = conflict?.details ?? {};
|
|
89
|
+
const classification = {
|
|
90
|
+
kind: classificationKindFromConflict(conflict, details),
|
|
91
|
+
code: conflict?.code,
|
|
92
|
+
branch: details.branch,
|
|
93
|
+
sourcePaths: uniqueStrings([...(details.sourcePaths ?? []), details.fromSourcePath, details.toSourcePath, details.exportSourcePath, details.importSourcePath, conflict?.sourcePath]),
|
|
94
|
+
details: { ...details, reasonCode: details.reasonCode ?? conflict?.code }
|
|
95
|
+
};
|
|
96
|
+
const route = projectAdmissionRouteFromClassification(classification, {
|
|
97
|
+
source: 'conflict',
|
|
98
|
+
sourcePath: conflict?.sourcePath,
|
|
99
|
+
status: conflict?.severity === 'error' ? 'failed' : 'blocked'
|
|
100
|
+
});
|
|
101
|
+
return route?.subjectKind === 'project-admission' && !structuralConflictCode(conflict?.code) && !details.routeId ? undefined : route;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function projectAdmissionRouteFromMissingEvidence(item) {
|
|
105
|
+
const route = item?.route ?? {};
|
|
106
|
+
const routeId = item?.routeId ?? route.id;
|
|
107
|
+
if (!routeId) return undefined;
|
|
108
|
+
const action = normalizedRouteAction(item?.action);
|
|
109
|
+
return routeRecord({
|
|
110
|
+
routeId,
|
|
111
|
+
routeKind: action,
|
|
112
|
+
routeLane: item?.routeLane ?? route.lane,
|
|
113
|
+
routeNext: item?.routeNext ?? route.next,
|
|
114
|
+
action,
|
|
115
|
+
status: item?.status ?? 'missing',
|
|
116
|
+
source: 'missing-evidence',
|
|
117
|
+
subjectKind: item?.kind,
|
|
118
|
+
proofLevel: item?.proofLevel,
|
|
119
|
+
evidenceId: item?.evidenceId,
|
|
120
|
+
reasonCodes: uniqueStrings([item?.code, ...(item?.relatedSignals ?? [])]),
|
|
121
|
+
details: item
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function fileAdmissionRoutes(file) {
|
|
126
|
+
return [
|
|
127
|
+
...(file?.admission?.routes ?? []),
|
|
128
|
+
...fileAdmissionEvidence(file).map((record) => record.admissionRoute)
|
|
129
|
+
].filter(Boolean);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function fileAdmissionEvidence(file) {
|
|
133
|
+
const records = [file?.summary, file?.metadata].filter(isPlainObject);
|
|
134
|
+
return records.flatMap((record) => Object.entries(record)
|
|
135
|
+
.filter(([key, value]) => /Admission(?:Evidence|s)$/.test(key) && Array.isArray(value))
|
|
136
|
+
.flatMap(([, value]) => value));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function classificationKindFromConflict(conflict, details) {
|
|
140
|
+
if (details.symbolRenameKind) return 'cross-file-symbol-rename';
|
|
141
|
+
if (details.symbolMoveKind === 'exported') return 'exported-symbol-move';
|
|
142
|
+
if (details.symbolMoveKind === 'imported') return 'imported-symbol-move';
|
|
143
|
+
if (details.movementKind && String(conflict?.code).includes('file-move-rename')) return 'file-move-rename';
|
|
144
|
+
for (const kind of ['module-split', 'module-merge', 'class-split', 'class-merge']) {
|
|
145
|
+
if (String(conflict?.code).includes(kind)) return kind;
|
|
146
|
+
}
|
|
147
|
+
return structuralConflictCode(conflict?.code) ? 'project-admission' : undefined;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function structuralConflictCode(code) {
|
|
151
|
+
return /^project-(worker|head)-/.test(String(code ?? ''))
|
|
152
|
+
|| ['project-typescript-refactor-evidence-missing', 'project-source-span-roundtrip-proof-failed'].includes(String(code ?? ''));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function routeRecord(input) {
|
|
156
|
+
if (!input.routeId) return undefined;
|
|
157
|
+
return compactRecord({
|
|
158
|
+
kind: 'frontier.lang.jsTsProjectMergeAdmissionRoute',
|
|
159
|
+
version: 1,
|
|
160
|
+
routeId: input.routeId,
|
|
161
|
+
routeKind: input.routeKind,
|
|
162
|
+
routeLane: input.routeLane,
|
|
163
|
+
routeNext: input.routeNext,
|
|
164
|
+
action: input.action,
|
|
165
|
+
status: input.status,
|
|
166
|
+
source: input.source,
|
|
167
|
+
subjectKind: input.subjectKind,
|
|
168
|
+
branch: input.branch,
|
|
169
|
+
sourcePath: input.sourcePath,
|
|
170
|
+
sourcePaths: input.sourcePaths?.length ? uniqueStrings(input.sourcePaths) : undefined,
|
|
171
|
+
proofLevel: input.proofLevel,
|
|
172
|
+
evidenceId: input.evidenceId,
|
|
173
|
+
conflictKey: input.conflictKey,
|
|
174
|
+
reasonCodes: input.reasonCodes?.length ? uniqueStrings(input.reasonCodes) : undefined,
|
|
175
|
+
requiredEvidence: input.requiredEvidence,
|
|
176
|
+
presentEvidence: input.presentEvidence,
|
|
177
|
+
missingEvidence: input.missingEvidence,
|
|
178
|
+
details: input.details,
|
|
179
|
+
autoMergeClaim: false,
|
|
180
|
+
semanticEquivalenceClaim: false
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function uniqueProjectAdmissionRoutes(routes) {
|
|
185
|
+
const seen = new Set();
|
|
186
|
+
return routes.filter((route) => {
|
|
187
|
+
const key = [route.routeId, route.source, route.sourcePath, route.conflictKey, route.evidenceId, route.status].filter(Boolean).join('#');
|
|
188
|
+
if (!key || seen.has(key)) return false;
|
|
189
|
+
seen.add(key);
|
|
190
|
+
return true;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function normalizedRouteAction(action) {
|
|
195
|
+
if (action === 'rerun' || action === 'rerun-gate') return 'rerun';
|
|
196
|
+
if (action === 'reject-proof' || action === 'reject') return 'reject';
|
|
197
|
+
if (action === 'block') return 'block';
|
|
198
|
+
if (action === 'apply') return 'apply';
|
|
199
|
+
if (action === 'rebase') return 'rebase';
|
|
200
|
+
return 'review';
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function routeSpec(routeId, routeLane, routeNext) { return Object.freeze({ routeId, routeLane, routeNext }); }
|
|
204
|
+
function countField(values, field) { const result = {}; for (const value of values) if (value?.[field]) result[value[field]] = (result[value[field]] ?? 0) + 1; return result; }
|
|
205
|
+
function uniqueStrings(values) { return [...new Set((values ?? []).filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
206
|
+
function safeToken(value) { return String(value ?? 'project-admission').replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'project-admission'; }
|
|
207
|
+
function isPlainObject(value) { return Boolean(value && typeof value === 'object' && !Array.isArray(value)); }
|
|
208
|
+
function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined && (!Array.isArray(value) || value.length > 0))); }
|
|
209
|
+
|
|
210
|
+
export {
|
|
211
|
+
createProjectAdmissionRoutes,
|
|
212
|
+
projectAdmissionRouteFromClassification,
|
|
213
|
+
projectAdmissionRouteFromExactAdmission,
|
|
214
|
+
projectAdmissionRouteFromMissingEvidence,
|
|
215
|
+
projectAdmissionRouteSummary
|
|
216
|
+
};
|