@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,292 @@
|
|
|
1
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
2
|
+
|
|
3
|
+
function projectScopeUseDefDeltaConflicts(projectGraphDelta) {
|
|
4
|
+
const baseGraph = projectGraphDelta?.stages?.base?.projectSymbolGraph;
|
|
5
|
+
const workerGraph = projectGraphDelta?.stages?.worker?.projectSymbolGraph;
|
|
6
|
+
const headGraph = projectGraphDelta?.stages?.head?.projectSymbolGraph;
|
|
7
|
+
const outputGraph = projectGraphDelta?.stages?.output?.projectSymbolGraph;
|
|
8
|
+
const ambiguousOutputConflicts = projectScopeUseDefAmbiguousEvidenceConflicts(outputGraph);
|
|
9
|
+
if (!baseGraph || !workerGraph || !headGraph) return ambiguousOutputConflicts;
|
|
10
|
+
const base = publicScopeBindings(baseGraph.scopeBindingRecords);
|
|
11
|
+
const worker = publicScopeBindings(workerGraph.scopeBindingRecords);
|
|
12
|
+
const head = publicScopeBindings(headGraph.scopeBindingRecords);
|
|
13
|
+
const output = publicScopeBindings(outputGraph?.scopeBindingRecords);
|
|
14
|
+
const referenceDeltaConflicts = projectScopeReferenceDeltaConflicts(baseGraph, workerGraph, headGraph, outputGraph);
|
|
15
|
+
const deltaConflicts = uniqueStrings([...base.keys(), ...worker.keys(), ...head.keys()]).flatMap((identityKey) => {
|
|
16
|
+
const baseRecord = base.get(identityKey);
|
|
17
|
+
const workerRecord = worker.get(identityKey);
|
|
18
|
+
const headRecord = head.get(identityKey);
|
|
19
|
+
const fingerprints = [scopeFingerprint(baseRecord), scopeFingerprint(workerRecord), scopeFingerprint(headRecord)];
|
|
20
|
+
if (fingerprints[0] === fingerprints[1] || fingerprints[0] === fingerprints[2] || fingerprints[1] === fingerprints[2]) return [];
|
|
21
|
+
return [projectScopeUseDefDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, output.get(identityKey))];
|
|
22
|
+
});
|
|
23
|
+
return [...ambiguousOutputConflicts, ...referenceDeltaConflicts, ...deltaConflicts];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function projectScopeUseDefDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, outputRecord) {
|
|
27
|
+
const sourcePath = workerRecord?.sourcePath ?? headRecord?.sourcePath ?? baseRecord?.sourcePath;
|
|
28
|
+
return {
|
|
29
|
+
code: 'project-public-scope-use-def-delta-conflict',
|
|
30
|
+
gateId: 'project-graph-delta',
|
|
31
|
+
message: `Worker and head both changed public scope/use-def binding ${JSON.stringify(identityKey)} in incompatible ways.`,
|
|
32
|
+
sourcePath,
|
|
33
|
+
details: compactRecord({
|
|
34
|
+
reasonCode: 'project-public-scope-use-def-delta-conflict',
|
|
35
|
+
conflictKey: `project-graph-delta#scope-use-def#${identityKey}`,
|
|
36
|
+
identityKey,
|
|
37
|
+
sourcePath,
|
|
38
|
+
base: scopeDetails(baseRecord),
|
|
39
|
+
worker: scopeDetails(workerRecord),
|
|
40
|
+
head: scopeDetails(headRecord),
|
|
41
|
+
output: scopeDetails(outputRecord)
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function publicScopeBindings(records = []) {
|
|
47
|
+
const result = new Map();
|
|
48
|
+
for (const record of records) {
|
|
49
|
+
if (!record?.publicContract) continue;
|
|
50
|
+
const key = scopeIdentityKey(record);
|
|
51
|
+
if (key && !result.has(key)) result.set(key, record);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function projectScopeUseDefAmbiguousEvidenceConflicts(graph) {
|
|
57
|
+
const bindingConflicts = [...publicScopeBindings(graph?.scopeBindingRecords).entries()]
|
|
58
|
+
.filter(([, record]) => record?.scopeUseDefStatus === 'blocked' && record.scopeUseDefReasonCodes?.length)
|
|
59
|
+
.map(([identityKey, record]) => projectScopeUseDefAmbiguousEvidenceConflict(identityKey, record));
|
|
60
|
+
const referenceConflicts = [...publicScopeReferences(graph?.scopeReferenceRecords).entries()]
|
|
61
|
+
.filter(([, record]) => (record.status === 'blocked' || record.status === 'unresolved') && record.reasonCodes?.length)
|
|
62
|
+
.map(([identityKey, record]) => projectScopeReferenceAmbiguousEvidenceConflict(identityKey, record));
|
|
63
|
+
return [...bindingConflicts, ...referenceConflicts];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function projectScopeUseDefAmbiguousEvidenceConflict(identityKey, record) {
|
|
67
|
+
return {
|
|
68
|
+
code: 'project-public-scope-use-def-ambiguous-evidence',
|
|
69
|
+
gateId: 'project-graph-delta',
|
|
70
|
+
message: `Output public scope/use-def binding ${JSON.stringify(identityKey)} has unsupported or ambiguous use-def evidence.`,
|
|
71
|
+
sourcePath: record.sourcePath,
|
|
72
|
+
details: compactRecord({
|
|
73
|
+
reasonCode: 'project-public-scope-use-def-ambiguous-evidence',
|
|
74
|
+
conflictKey: `project-graph-delta#scope-use-def-ambiguous#${identityKey}`,
|
|
75
|
+
identityKey,
|
|
76
|
+
sourcePath: record.sourcePath,
|
|
77
|
+
reasonCodes: record.scopeUseDefReasonCodes,
|
|
78
|
+
output: scopeDetails(record)
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function scopeIdentityKey(record) {
|
|
84
|
+
return stableKey(['scope-binding', record?.sourcePath, record?.publicOwnerName, record?.name, record?.bindingKind, record?.namespaces?.join('|'), record?.ordinal]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function projectScopeReferenceDeltaConflicts(baseGraph, workerGraph, headGraph, outputGraph) {
|
|
88
|
+
const base = publicScopeReferences(baseGraph.scopeReferenceRecords);
|
|
89
|
+
const worker = publicScopeReferences(workerGraph.scopeReferenceRecords);
|
|
90
|
+
const head = publicScopeReferences(headGraph.scopeReferenceRecords);
|
|
91
|
+
const output = publicScopeReferences(outputGraph?.scopeReferenceRecords);
|
|
92
|
+
return uniqueStrings([...base.keys(), ...worker.keys(), ...head.keys()]).flatMap((identityKey) => {
|
|
93
|
+
const baseRecord = base.get(identityKey);
|
|
94
|
+
const workerRecord = worker.get(identityKey);
|
|
95
|
+
const headRecord = head.get(identityKey);
|
|
96
|
+
const fingerprints = [scopeReferenceFingerprint(baseRecord), scopeReferenceFingerprint(workerRecord), scopeReferenceFingerprint(headRecord)];
|
|
97
|
+
if (fingerprints[0] === fingerprints[1] || fingerprints[0] === fingerprints[2] || fingerprints[1] === fingerprints[2]) return [];
|
|
98
|
+
return [projectScopeReferenceDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, output.get(identityKey))];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function projectScopeReferenceDeltaConflict(identityKey, baseRecord, workerRecord, headRecord, outputRecord) {
|
|
103
|
+
const sourcePath = workerRecord?.sourcePath ?? headRecord?.sourcePath ?? baseRecord?.sourcePath;
|
|
104
|
+
return {
|
|
105
|
+
code: 'project-public-scope-reference-delta-conflict',
|
|
106
|
+
gateId: 'project-graph-delta',
|
|
107
|
+
message: `Worker and head both changed public scope/use-def reference ${JSON.stringify(identityKey)} in incompatible ways.`,
|
|
108
|
+
sourcePath,
|
|
109
|
+
details: compactRecord({
|
|
110
|
+
reasonCode: 'project-public-scope-reference-delta-conflict',
|
|
111
|
+
conflictKey: `project-graph-delta#scope-reference#${identityKey}`,
|
|
112
|
+
identityKey,
|
|
113
|
+
sourcePath,
|
|
114
|
+
base: scopeReferenceDetails(baseRecord),
|
|
115
|
+
worker: scopeReferenceDetails(workerRecord),
|
|
116
|
+
head: scopeReferenceDetails(headRecord),
|
|
117
|
+
output: scopeReferenceDetails(outputRecord)
|
|
118
|
+
})
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function projectScopeReferenceAmbiguousEvidenceConflict(identityKey, record) {
|
|
123
|
+
return {
|
|
124
|
+
code: 'project-public-scope-reference-ambiguous-evidence',
|
|
125
|
+
gateId: 'project-graph-delta',
|
|
126
|
+
message: `Output public scope/use-def reference ${JSON.stringify(identityKey)} has unsupported or ambiguous evidence.`,
|
|
127
|
+
sourcePath: record.sourcePath,
|
|
128
|
+
details: compactRecord({
|
|
129
|
+
reasonCode: 'project-public-scope-reference-ambiguous-evidence',
|
|
130
|
+
conflictKey: `project-graph-delta#scope-reference-ambiguous#${identityKey}`,
|
|
131
|
+
identityKey,
|
|
132
|
+
sourcePath: record.sourcePath,
|
|
133
|
+
reasonCodes: record.reasonCodes,
|
|
134
|
+
output: scopeReferenceDetails(record)
|
|
135
|
+
})
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function publicScopeReferences(records = []) {
|
|
140
|
+
const result = new Map();
|
|
141
|
+
for (const record of records) {
|
|
142
|
+
if (!record?.publicContract) continue;
|
|
143
|
+
const key = scopeReferenceIdentityKey(record);
|
|
144
|
+
if (key && !result.has(key)) result.set(key, record);
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function scopeReferenceIdentityKey(record) {
|
|
150
|
+
return stableKey(['scope-reference', record?.sourcePath, record?.publicOwnerName, record?.bindingName ?? record?.name, record?.namespace, record?.ordinal ?? record?.start]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function scopeFingerprint(record) {
|
|
154
|
+
return record ? stableKey([
|
|
155
|
+
record.signatureHash,
|
|
156
|
+
record.useHash,
|
|
157
|
+
record.localUseHash,
|
|
158
|
+
record.resolvedUseHash,
|
|
159
|
+
record.publicOwnerUseHash,
|
|
160
|
+
record.closureUseHash,
|
|
161
|
+
record.aliasHash,
|
|
162
|
+
record.scopeUseDefStatus,
|
|
163
|
+
record.scopeUseDefReasonCodes?.join('|'),
|
|
164
|
+
record.referenceCount,
|
|
165
|
+
record.closureReferenceCount
|
|
166
|
+
]) : undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function scopeReferenceFingerprint(record) {
|
|
170
|
+
return record ? stableKey([
|
|
171
|
+
record.signatureHash,
|
|
172
|
+
record.resolvedUseHash,
|
|
173
|
+
record.resolvedBindingUseHash,
|
|
174
|
+
record.moduleSpecifier,
|
|
175
|
+
record.importedName,
|
|
176
|
+
record.resolvedSourcePath,
|
|
177
|
+
record.resolvedExportName,
|
|
178
|
+
record.closureCaptureHash,
|
|
179
|
+
record.templateExpressionHash,
|
|
180
|
+
record.templateLiteralKind,
|
|
181
|
+
record.taggedTemplate,
|
|
182
|
+
record.templateTagText,
|
|
183
|
+
record.templateTagRoot,
|
|
184
|
+
record.templateTagMemberName,
|
|
185
|
+
record.memberName,
|
|
186
|
+
record.memberComputed,
|
|
187
|
+
record.memberOptional,
|
|
188
|
+
record.writeOperation,
|
|
189
|
+
record.status,
|
|
190
|
+
record.reasonCodes?.join('|'),
|
|
191
|
+
record.aliasResolutionStatus,
|
|
192
|
+
record.originSourcePath,
|
|
193
|
+
record.resolvedBindingName,
|
|
194
|
+
record.compilerReferenceStatus,
|
|
195
|
+
record.compilerReferenceReasonCodes?.join('|'),
|
|
196
|
+
record.compilerReferenceSymbolId,
|
|
197
|
+
record.compilerReferenceIdentityHash,
|
|
198
|
+
record.compilerReferenceProofHash
|
|
199
|
+
]) : undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function scopeDetails(record) {
|
|
203
|
+
if (!record) return undefined;
|
|
204
|
+
return compactRecord({
|
|
205
|
+
sourcePath: record.sourcePath,
|
|
206
|
+
name: record.name,
|
|
207
|
+
bindingKind: record.bindingKind,
|
|
208
|
+
publicOwnerName: record.publicOwnerName,
|
|
209
|
+
namespaces: record.namespaces,
|
|
210
|
+
ordinal: record.ordinal,
|
|
211
|
+
referenceCount: record.referenceCount,
|
|
212
|
+
closureReferenceCount: record.closureReferenceCount,
|
|
213
|
+
signatureHash: record.signatureHash,
|
|
214
|
+
useHash: record.useHash,
|
|
215
|
+
localUseHash: record.localUseHash,
|
|
216
|
+
resolvedUseHash: record.resolvedUseHash,
|
|
217
|
+
publicOwnerUseHash: record.publicOwnerUseHash,
|
|
218
|
+
closureUseHash: record.closureUseHash,
|
|
219
|
+
aliasHash: record.aliasHash,
|
|
220
|
+
scopeUseDefStatus: record.scopeUseDefStatus,
|
|
221
|
+
scopeUseDefReasonCodes: record.scopeUseDefReasonCodes,
|
|
222
|
+
importedName: record.importedName,
|
|
223
|
+
moduleSpecifier: record.moduleSpecifier,
|
|
224
|
+
resolvedSourcePath: record.resolvedSourcePath,
|
|
225
|
+
originSourcePath: record.originSourcePath,
|
|
226
|
+
resolvedBindingName: record.resolvedBindingName,
|
|
227
|
+
resolvedBindingUseHash: record.resolvedBindingUseHash,
|
|
228
|
+
exportedNames: record.exportedNames,
|
|
229
|
+
reExportedNames: record.reExportedNames,
|
|
230
|
+
sourceHash: record.sourceHash
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function scopeReferenceDetails(record) {
|
|
235
|
+
if (!record) return undefined;
|
|
236
|
+
return compactRecord({
|
|
237
|
+
sourcePath: record.sourcePath,
|
|
238
|
+
name: record.name,
|
|
239
|
+
namespace: record.namespace,
|
|
240
|
+
bindingName: record.bindingName,
|
|
241
|
+
bindingKind: record.bindingKind,
|
|
242
|
+
bindingOrdinal: record.bindingOrdinal,
|
|
243
|
+
publicOwnerName: record.publicOwnerName,
|
|
244
|
+
referenceKind: record.referenceKind,
|
|
245
|
+
memberName: record.memberName,
|
|
246
|
+
memberComputed: record.memberComputed,
|
|
247
|
+
memberOptional: record.memberOptional,
|
|
248
|
+
writeOperation: record.writeOperation,
|
|
249
|
+
closure: record.closure,
|
|
250
|
+
closureDepthDelta: record.closureDepthDelta,
|
|
251
|
+
closureCaptureHash: record.closureCaptureHash,
|
|
252
|
+
templateExpressionHash: record.templateExpressionHash,
|
|
253
|
+
templateLiteralKind: record.templateLiteralKind,
|
|
254
|
+
taggedTemplate: record.taggedTemplate,
|
|
255
|
+
templateTagText: record.templateTagText,
|
|
256
|
+
templateTagRoot: record.templateTagRoot,
|
|
257
|
+
templateTagMemberName: record.templateTagMemberName,
|
|
258
|
+
signatureHash: record.signatureHash,
|
|
259
|
+
resolvedUseHash: record.resolvedUseHash,
|
|
260
|
+
importAlias: record.importAlias,
|
|
261
|
+
moduleSpecifier: record.moduleSpecifier,
|
|
262
|
+
importedName: record.importedName,
|
|
263
|
+
resolvedSourcePath: record.resolvedSourcePath,
|
|
264
|
+
resolvedExportName: record.resolvedExportName,
|
|
265
|
+
resolvedBindingId: record.resolvedBindingId,
|
|
266
|
+
resolvedBindingUseHash: record.resolvedBindingUseHash,
|
|
267
|
+
status: record.status,
|
|
268
|
+
reasonCodes: record.reasonCodes,
|
|
269
|
+
aliasResolutionStatus: record.aliasResolutionStatus,
|
|
270
|
+
originSourcePath: record.originSourcePath,
|
|
271
|
+
resolvedBindingName: record.resolvedBindingName,
|
|
272
|
+
compilerReferenceStatus: record.compilerReferenceStatus,
|
|
273
|
+
compilerReferenceReasonCodes: record.compilerReferenceReasonCodes,
|
|
274
|
+
compilerReferenceSymbolId: record.compilerReferenceSymbolId,
|
|
275
|
+
compilerReferenceIdentityHash: record.compilerReferenceIdentityHash,
|
|
276
|
+
compilerReferenceFullyQualifiedName: record.compilerReferenceFullyQualifiedName,
|
|
277
|
+
compilerReferenceLocalName: record.compilerReferenceLocalName,
|
|
278
|
+
compilerReferenceTargetName: record.compilerReferenceTargetName,
|
|
279
|
+
compilerReferenceAliased: record.compilerReferenceAliased,
|
|
280
|
+
compilerReferenceProofHash: record.compilerReferenceProofHash,
|
|
281
|
+
compilerReferenceCandidates: record.compilerReferenceCandidates,
|
|
282
|
+
sourceHash: record.sourceHash
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function stableKey(parts) {
|
|
287
|
+
const values = parts.map((part) => part === undefined || part === null ? '' : String(part));
|
|
288
|
+
return values.some(Boolean) ? values.join('#') : undefined;
|
|
289
|
+
}
|
|
290
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
291
|
+
|
|
292
|
+
export { projectScopeUseDefDeltaConflicts };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
3
|
+
|
|
4
|
+
const ExternalSemanticEquivalenceLevel = 'semantic-equivalence-external';
|
|
5
|
+
const ExternalSemanticEquivalenceSchema = 'frontier.lang.jsTsProjectSemanticEquivalenceProof.v1';
|
|
6
|
+
const ExternalSemanticEquivalenceKind = 'frontier.lang.jsTsProjectSemanticEquivalenceProof';
|
|
7
|
+
const ExternalSemanticEquivalenceClaimBoundary = 'exact-js-ts-project-source-output-and-gates';
|
|
8
|
+
|
|
9
|
+
function semanticEquivalenceExternalEvidence(id, input = {}) {
|
|
10
|
+
const proof = input.externalSemanticEquivalenceProof ?? input.semanticEquivalenceProof;
|
|
11
|
+
if (proof === undefined) return undefined;
|
|
12
|
+
const expected = jsTsProjectSemanticEquivalenceExpectedBinding(id, input);
|
|
13
|
+
const reasonCodes = semanticEquivalenceProofReasonCodes(proof, expected);
|
|
14
|
+
const status = reasonCodes.length === 0 ? 'passed' : 'failed';
|
|
15
|
+
return {
|
|
16
|
+
id: `${id}_proof_semantic_equivalence_external`,
|
|
17
|
+
kind: 'js-ts-project-merge-proof-evidence',
|
|
18
|
+
level: ExternalSemanticEquivalenceLevel,
|
|
19
|
+
status,
|
|
20
|
+
scope: 'project',
|
|
21
|
+
claimKind: 'external-semantic-equivalence',
|
|
22
|
+
evidenceOnly: false,
|
|
23
|
+
proofClaim: status === 'passed',
|
|
24
|
+
autoMergeClaim: false,
|
|
25
|
+
semanticEquivalenceClaim: status === 'passed',
|
|
26
|
+
summary: status === 'passed'
|
|
27
|
+
? 'External semantic equivalence proof is source/output/gate-bound and passed.'
|
|
28
|
+
: 'External semantic equivalence proof was supplied but did not validate against the project binding.',
|
|
29
|
+
metadata: compactRecord({
|
|
30
|
+
proofId: proof?.id,
|
|
31
|
+
evidenceId: proof?.evidenceId,
|
|
32
|
+
verifier: proof?.verifier,
|
|
33
|
+
command: proof?.command,
|
|
34
|
+
artifactHash: proof?.artifactHash,
|
|
35
|
+
expected,
|
|
36
|
+
reasonCodes,
|
|
37
|
+
proofHash: proof?.proofHash,
|
|
38
|
+
expectedProofHash: proof && typeof proof === 'object' ? jsTsProjectSemanticEquivalenceProofHash(proof) : undefined,
|
|
39
|
+
proofClaim: status === 'passed',
|
|
40
|
+
autoMergeClaim: false,
|
|
41
|
+
semanticEquivalenceClaim: status === 'passed'
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function jsTsProjectSemanticEquivalenceExpectedBinding(id, input = {}) {
|
|
47
|
+
const sourceFileBindings = normalizeSourceFileBindings(input.fileResults ?? []);
|
|
48
|
+
const sourceSetHash = hashSemanticValue({ kind: 'frontier.lang.jsTsProjectSemanticEquivalenceSourceSet.v1', sourceFileBindings: sourceFileBindings.map(sourceBinding) });
|
|
49
|
+
const outputSetHash = hashSemanticValue({ kind: 'frontier.lang.jsTsProjectSemanticEquivalenceOutputSet.v1', sourceFileBindings: sourceFileBindings.map(outputBinding) });
|
|
50
|
+
return compactRecord({
|
|
51
|
+
schema: 'frontier.lang.jsTsProjectSemanticEquivalenceExpectedBinding.v1',
|
|
52
|
+
projectId: String(id),
|
|
53
|
+
language: firstLanguage(input),
|
|
54
|
+
sourceFileBindings,
|
|
55
|
+
sourceSetHash,
|
|
56
|
+
outputSetHash,
|
|
57
|
+
gates: {
|
|
58
|
+
diagnostics: gateBinding(input.outputDiagnosticsGate, 'diagnostics'),
|
|
59
|
+
declarations: gateBinding(input.outputDeclarationGate, 'declarations'),
|
|
60
|
+
quality: gateBinding(input.outputQualityGate, 'quality')
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function semanticEquivalenceProofReasonCodes(proof, expected) {
|
|
66
|
+
if (!proof || typeof proof !== 'object' || Array.isArray(proof)) return ['semantic-equivalence-proof-structured-record-required'];
|
|
67
|
+
const reasons = [];
|
|
68
|
+
if (proof.schema !== ExternalSemanticEquivalenceSchema) reasons.push('semantic-equivalence-proof-schema-missing');
|
|
69
|
+
if (proof.kind !== ExternalSemanticEquivalenceKind) reasons.push('semantic-equivalence-proof-kind-missing');
|
|
70
|
+
if (!['passed', 'verified'].includes(proof.status)) reasons.push('semantic-equivalence-proof-status-not-passed');
|
|
71
|
+
if (proof.projectId !== expected.projectId) reasons.push('semantic-equivalence-proof-project-id-mismatch');
|
|
72
|
+
if (proof.language !== undefined && expected.language !== undefined && proof.language !== expected.language) reasons.push('semantic-equivalence-proof-language-mismatch');
|
|
73
|
+
reasons.push(...sourceBindingReasonCodes(proof.sourceFileBindings, expected.sourceFileBindings));
|
|
74
|
+
if (proof.sourceSetHash !== expected.sourceSetHash) reasons.push('semantic-equivalence-proof-source-set-hash-mismatch');
|
|
75
|
+
if (proof.outputSetHash !== expected.outputSetHash) reasons.push('semantic-equivalence-proof-output-set-hash-mismatch');
|
|
76
|
+
reasons.push(...gateReasonCodes('diagnostics', proof.gates?.diagnostics, expected.gates.diagnostics));
|
|
77
|
+
reasons.push(...gateReasonCodes('declaration', proof.gates?.declarations, expected.gates.declarations));
|
|
78
|
+
reasons.push(...gateReasonCodes('quality', proof.gates?.quality, expected.gates.quality));
|
|
79
|
+
if (!proof.proofHash) reasons.push('semantic-equivalence-proof-proof-hash-missing');
|
|
80
|
+
else if (proof.proofHash !== jsTsProjectSemanticEquivalenceProofHash(proof)) reasons.push('semantic-equivalence-proof-proof-hash-mismatch');
|
|
81
|
+
if (proof.claimKind !== 'external-semantic-equivalence' || proof.claimBoundary !== ExternalSemanticEquivalenceClaimBoundary || proof.semanticEquivalenceClaim !== true) reasons.push('semantic-equivalence-proof-claim-boundary-mismatch');
|
|
82
|
+
if (proof.autoMergeClaim !== false) reasons.push('semantic-equivalence-proof-auto-merge-claim-not-false');
|
|
83
|
+
return uniqueStrings(reasons);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function sourceBindingReasonCodes(proofBindings, expectedBindings) {
|
|
87
|
+
if (!Array.isArray(proofBindings) || proofBindings.length !== expectedBindings.length) return ['semantic-equivalence-proof-source-file-set-mismatch'];
|
|
88
|
+
const expectedByPath = new Map(expectedBindings.map((binding) => [binding.sourcePath, binding]));
|
|
89
|
+
const reasons = [];
|
|
90
|
+
for (const binding of normalizeSourceFileBindings(proofBindings)) {
|
|
91
|
+
const expected = expectedByPath.get(binding.sourcePath);
|
|
92
|
+
if (!expected) reasons.push('semantic-equivalence-proof-source-path-mismatch');
|
|
93
|
+
else for (const field of ['operation', 'baseHash', 'workerHash', 'headHash', 'outputHash', 'deletedOutput']) {
|
|
94
|
+
if (binding[field] !== expected[field]) reasons.push(`semantic-equivalence-proof-${field.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}-mismatch`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return reasons;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function gateReasonCodes(label, proofGate, expectedGate) {
|
|
101
|
+
if (!proofGate || !expectedGate) return [`semantic-equivalence-proof-${label}-gate-missing`];
|
|
102
|
+
const reasons = [];
|
|
103
|
+
if (proofGate.status !== 'passed' || expectedGate.status !== 'passed') reasons.push(`semantic-equivalence-proof-${label}-gate-status-not-passed`);
|
|
104
|
+
if (proofGate.id !== expectedGate.id || proofGate.hash !== expectedGate.hash) reasons.push(`semantic-equivalence-proof-${label}-gate-hash-mismatch`);
|
|
105
|
+
return reasons;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function jsTsProjectSemanticEquivalenceProofHash(proof = {}) {
|
|
109
|
+
return hashSemanticValue({
|
|
110
|
+
kind: 'frontier.lang.jsTsProjectSemanticEquivalenceProofHash.v1',
|
|
111
|
+
schema: proof.schema,
|
|
112
|
+
kindName: proof.kind,
|
|
113
|
+
status: proof.status,
|
|
114
|
+
verifier: proof.verifier,
|
|
115
|
+
command: proof.command,
|
|
116
|
+
artifactHash: proof.artifactHash,
|
|
117
|
+
projectId: proof.projectId,
|
|
118
|
+
language: proof.language,
|
|
119
|
+
sourceFileBindings: normalizeSourceFileBindings(proof.sourceFileBindings ?? []),
|
|
120
|
+
sourceSetHash: proof.sourceSetHash,
|
|
121
|
+
outputSetHash: proof.outputSetHash,
|
|
122
|
+
gates: normalizeProofGates(proof.gates),
|
|
123
|
+
claimKind: proof.claimKind,
|
|
124
|
+
claimBoundary: proof.claimBoundary,
|
|
125
|
+
semanticEquivalenceClaim: proof.semanticEquivalenceClaim,
|
|
126
|
+
autoMergeClaim: proof.autoMergeClaim
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function normalizeSourceFileBindings(bindings = []) {
|
|
131
|
+
return bindings.map((file) => compactRecord({
|
|
132
|
+
sourcePath: file.sourcePath,
|
|
133
|
+
operation: file.operation,
|
|
134
|
+
baseHash: file.baseHash,
|
|
135
|
+
workerHash: file.workerHash,
|
|
136
|
+
headHash: file.headHash,
|
|
137
|
+
outputHash: file.outputHash,
|
|
138
|
+
deletedOutput: file.deletedOutput === true || (file.outputHash === undefined && file.status === 'merged') || undefined
|
|
139
|
+
})).sort((a, b) => String(a.sourcePath).localeCompare(String(b.sourcePath)));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function gateBinding(gate, kind) {
|
|
143
|
+
if (!gate) return undefined;
|
|
144
|
+
return compactRecord({
|
|
145
|
+
id: gate.id,
|
|
146
|
+
status: gate.status,
|
|
147
|
+
hash: gate.hash ?? hashSemanticValue({ kind: `frontier.lang.jsTsProjectSemanticEquivalenceGateHash.${kind}.v1`, id: gate.id, status: gate.status, summary: gate.summary, gates: gate.gates }),
|
|
148
|
+
gateIds: Array.isArray(gate.gates) ? gate.gates.map((entry) => entry.id).filter(Boolean) : undefined
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function normalizeProofGates(gates = {}) {
|
|
153
|
+
return compactRecord({
|
|
154
|
+
diagnostics: compactGate(gates.diagnostics),
|
|
155
|
+
declarations: compactGate(gates.declarations),
|
|
156
|
+
quality: compactGate(gates.quality)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function compactGate(gate) { return gate ? compactRecord({ id: gate.id, status: gate.status, hash: gate.hash, gateIds: gate.gateIds }) : undefined; }
|
|
161
|
+
function sourceBinding(binding) { return compactRecord({ sourcePath: binding.sourcePath, operation: binding.operation, baseHash: binding.baseHash, workerHash: binding.workerHash, headHash: binding.headHash }); }
|
|
162
|
+
function outputBinding(binding) { return compactRecord({ sourcePath: binding.sourcePath, operation: binding.operation, outputHash: binding.outputHash, deletedOutput: binding.deletedOutput }); }
|
|
163
|
+
function firstLanguage(input) { return input.language ?? (input.fileResults ?? []).find((file) => file.language)?.language ?? (input.files ?? []).find((file) => file.language)?.language; }
|
|
164
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
ExternalSemanticEquivalenceClaimBoundary,
|
|
168
|
+
ExternalSemanticEquivalenceKind,
|
|
169
|
+
ExternalSemanticEquivalenceLevel,
|
|
170
|
+
ExternalSemanticEquivalenceSchema,
|
|
171
|
+
jsTsProjectSemanticEquivalenceExpectedBinding,
|
|
172
|
+
jsTsProjectSemanticEquivalenceProofHash,
|
|
173
|
+
semanticEquivalenceExternalEvidence,
|
|
174
|
+
semanticEquivalenceProofReasonCodes
|
|
175
|
+
};
|