@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,310 @@
|
|
|
1
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
2
|
+
|
|
3
|
+
function projectSourceSpanDeltaConflicts(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
|
+
if (!baseGraph || !workerGraph || !headGraph) return [];
|
|
9
|
+
const ownershipBlockers = projectSourceOwnershipBlockerConflicts(projectGraphDelta);
|
|
10
|
+
const base = sourceSpanRecordsByIdentityKey(baseGraph.sourceSpanRecords);
|
|
11
|
+
const worker = sourceSpanRecordsByIdentityKey(workerGraph.sourceSpanRecords);
|
|
12
|
+
const head = sourceSpanRecordsByIdentityKey(headGraph.sourceSpanRecords);
|
|
13
|
+
const output = sourceSpanRecordsByIdentityKey(outputGraph?.sourceSpanRecords);
|
|
14
|
+
const keys = uniqueStrings([...base.keys(), ...worker.keys(), ...head.keys()]);
|
|
15
|
+
const deltaConflicts = keys.flatMap((identityKey) => {
|
|
16
|
+
const baseRecord = base.get(identityKey);
|
|
17
|
+
const workerRecord = worker.get(identityKey);
|
|
18
|
+
const headRecord = head.get(identityKey);
|
|
19
|
+
const fingerprints = [sourceSpanFingerprint(baseRecord), sourceSpanFingerprint(workerRecord), sourceSpanFingerprint(headRecord)];
|
|
20
|
+
if (fingerprints[0] === fingerprints[1] || fingerprints[0] === fingerprints[2] || fingerprints[1] === fingerprints[2]) return [];
|
|
21
|
+
return [sourceSpanConflict(identityKey, baseRecord, workerRecord, headRecord, output.get(identityKey))];
|
|
22
|
+
});
|
|
23
|
+
return [...ownershipBlockers, ...deltaConflicts];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function sourceSpanConflict(identityKey, baseRecord, workerRecord, headRecord, outputRecord) {
|
|
27
|
+
const sourcePath = workerRecord?.sourcePath ?? headRecord?.sourcePath ?? baseRecord?.sourcePath;
|
|
28
|
+
return {
|
|
29
|
+
code: 'project-source-span-delta-conflict',
|
|
30
|
+
gateId: 'project-graph-delta',
|
|
31
|
+
message: `Worker and head both changed source span ${JSON.stringify(identityKey)} in incompatible ways.`,
|
|
32
|
+
sourcePath,
|
|
33
|
+
details: compactRecord({
|
|
34
|
+
reasonCode: 'project-source-span-delta-conflict',
|
|
35
|
+
conflictKey: `project-graph-delta#source-span#${identityKey}`,
|
|
36
|
+
identityKey,
|
|
37
|
+
sourcePath,
|
|
38
|
+
base: sourceSpanDetails(baseRecord),
|
|
39
|
+
worker: sourceSpanDetails(workerRecord),
|
|
40
|
+
head: sourceSpanDetails(headRecord),
|
|
41
|
+
output: sourceSpanDetails(outputRecord)
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function sourceSpanRecordsByIdentityKey(records = []) {
|
|
47
|
+
const result = new Map();
|
|
48
|
+
for (const record of records ?? []) {
|
|
49
|
+
if (!isTrackedSourceSpan(record)) continue;
|
|
50
|
+
const key = sourceSpanIdentityKey(record);
|
|
51
|
+
if (!key || result.has(key)) continue;
|
|
52
|
+
result.set(key, record);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isTrackedSourceSpan(record) {
|
|
58
|
+
return record?.directive || record?.protected || record?.role === 'comment' || isCommentKind(record?.kind) || record?.kind === 'source-map-comment' || record?.kind === 'shebang';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function sourceSpanIdentityKey(record) {
|
|
62
|
+
return record?.identityKey
|
|
63
|
+
?? record?.ownershipAnchorKey
|
|
64
|
+
?? record?.stableId
|
|
65
|
+
?? stableKey(['source-span', record?.sourcePath, record?.role, record?.kind, sourceSpanIdentityAnchor(record)]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function sourceSpanFingerprint(record) {
|
|
69
|
+
return record ? stableKey([
|
|
70
|
+
record.stableHash,
|
|
71
|
+
record.textHash,
|
|
72
|
+
record.textLength,
|
|
73
|
+
record.directive,
|
|
74
|
+
record.protected,
|
|
75
|
+
record.trivia,
|
|
76
|
+
record.ownershipAnchorKey,
|
|
77
|
+
record.ownershipAnchorStatus,
|
|
78
|
+
record.parserTriviaExactnessStatus,
|
|
79
|
+
...(record.parserTriviaExactnessBlockReasonCodes ?? []),
|
|
80
|
+
record.parserTriviaOwnershipStatus,
|
|
81
|
+
record.parserTriviaOwnershipRelation,
|
|
82
|
+
...(record.parserTriviaOwnershipBlockReasonCodes ?? []),
|
|
83
|
+
record.sourceMapGeneratedBoundaryStatus,
|
|
84
|
+
record.sourceMapGeneratedBoundaryOwnershipStatus,
|
|
85
|
+
...(record.sourceMapGeneratedBoundaryOwnershipKeys ?? []),
|
|
86
|
+
...(record.sourceMapGeneratedBoundaryBlockReasonCodes ?? []),
|
|
87
|
+
generatedBoundaryPositionFingerprint(record)
|
|
88
|
+
]) : undefined;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function sourceSpanDetails(record) {
|
|
92
|
+
if (!record) return undefined;
|
|
93
|
+
return compactRecord({
|
|
94
|
+
sourcePath: record.sourcePath,
|
|
95
|
+
stableId: record.stableId,
|
|
96
|
+
key: sourceSpanIdentityKey(record),
|
|
97
|
+
identityKey: record.identityKey,
|
|
98
|
+
role: record.role,
|
|
99
|
+
kind: record.kind,
|
|
100
|
+
ordinal: record.ordinal,
|
|
101
|
+
identityOccurrence: record.identityOccurrence,
|
|
102
|
+
startLine: record.sourceSpan?.startLine,
|
|
103
|
+
startColumn: record.sourceSpan?.startColumn,
|
|
104
|
+
textHash: record.textHash,
|
|
105
|
+
stableHash: record.stableHash,
|
|
106
|
+
signatureHash: record.signatureHash,
|
|
107
|
+
ownershipAnchorKey: record.ownershipAnchorKey,
|
|
108
|
+
ownershipAnchorHash: record.ownershipAnchorHash,
|
|
109
|
+
ownershipAnchorStatus: record.ownershipAnchorStatus,
|
|
110
|
+
ownershipBlockReasonCodes: record.ownershipBlockReasonCodes,
|
|
111
|
+
parserEvidence: record.parserEvidence,
|
|
112
|
+
losslessCst: record.losslessCst,
|
|
113
|
+
parserTriviaExactnessStatus: record.parserTriviaExactnessStatus,
|
|
114
|
+
exactParserTrivia: record.exactParserTrivia,
|
|
115
|
+
parserTriviaExactnessReasonCodes: record.parserTriviaExactnessReasonCodes,
|
|
116
|
+
parserTriviaExactnessBlockReasonCodes: record.parserTriviaExactnessBlockReasonCodes,
|
|
117
|
+
parserTriviaOwnershipStatus: record.parserTriviaOwnershipStatus,
|
|
118
|
+
parserTriviaOwnershipRelation: record.parserTriviaOwnershipRelation,
|
|
119
|
+
parserTriviaOwnershipReasonCodes: record.parserTriviaOwnershipReasonCodes,
|
|
120
|
+
parserTriviaOwnershipBlockReasonCodes: record.parserTriviaOwnershipBlockReasonCodes,
|
|
121
|
+
...sourceMapGeneratedBoundaryDetails(record),
|
|
122
|
+
generatedBoundaryPositionKey: generatedBoundaryPositionFingerprint(record),
|
|
123
|
+
sourceHash: record.sourceHash,
|
|
124
|
+
start: record.start,
|
|
125
|
+
end: record.end,
|
|
126
|
+
directive: record.directive,
|
|
127
|
+
protected: record.protected,
|
|
128
|
+
trivia: record.trivia
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function generatedBoundaryPositionFingerprint(record) {
|
|
133
|
+
if (record?.kind !== 'source-map-comment' && record?.ownershipAnchor?.anchorKind !== 'generated-source-boundary') return undefined;
|
|
134
|
+
const span = record.sourceSpan;
|
|
135
|
+
return stableKey(['generated-boundary-position', span?.startLine, span?.startColumn, span?.endLine, span?.endColumn]);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function sourceMapGeneratedBoundaryDetails(record) {
|
|
139
|
+
return compactRecord({
|
|
140
|
+
sourceMapGeneratedBoundaryStatus: record.sourceMapGeneratedBoundaryStatus,
|
|
141
|
+
sourceMapGeneratedBoundaryReadiness: record.sourceMapGeneratedBoundaryReadiness,
|
|
142
|
+
sourceMapGeneratedBoundaryAction: record.sourceMapGeneratedBoundaryAction,
|
|
143
|
+
sourceMapGeneratedBoundaryReviewRequired: record.sourceMapGeneratedBoundaryReviewRequired,
|
|
144
|
+
sourceMapGeneratedBoundaryExactBoundary: record.sourceMapGeneratedBoundaryExactBoundary,
|
|
145
|
+
sourceMapGeneratedBoundaryOwnershipStatus: record.sourceMapGeneratedBoundaryOwnershipStatus,
|
|
146
|
+
sourceMapGeneratedBoundaryOwnershipKeys: record.sourceMapGeneratedBoundaryOwnershipKeys,
|
|
147
|
+
sourceMapGeneratedBoundaryReasonCodes: record.sourceMapGeneratedBoundaryReasonCodes,
|
|
148
|
+
sourceMapGeneratedBoundaryBlockReasonCodes: record.sourceMapGeneratedBoundaryBlockReasonCodes,
|
|
149
|
+
sourceMapGeneratedBoundaryMissingInvariant: record.sourceMapGeneratedBoundaryMissingInvariant,
|
|
150
|
+
sourceMapRecordCount: record.sourceMapRecordCount,
|
|
151
|
+
sourceMapMappingCount: record.sourceMapMappingCount,
|
|
152
|
+
sourceMapIds: record.sourceMapIds,
|
|
153
|
+
sourceMapMappingIds: record.sourceMapMappingIds
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function projectSourceOwnershipBlockerConflicts(projectGraphDelta) {
|
|
158
|
+
return uniqueSourceOwnershipBlockers([
|
|
159
|
+
['base', projectGraphDelta?.stages?.base?.projectSymbolGraph],
|
|
160
|
+
['worker', projectGraphDelta?.stages?.worker?.projectSymbolGraph],
|
|
161
|
+
['head', projectGraphDelta?.stages?.head?.projectSymbolGraph],
|
|
162
|
+
['output', projectGraphDelta?.stages?.output?.projectSymbolGraph]
|
|
163
|
+
].flatMap(([stage, graph]) => [
|
|
164
|
+
...sourceFileOwnershipBlockers(stage, graph?.sourceFileRecords),
|
|
165
|
+
...sourceSpanOwnershipBlockers(stage, graph?.sourceSpanRecords),
|
|
166
|
+
...sourceMapGeneratedBoundaryBlockers(stage, graph?.sourceFileRecords, graph?.sourceSpanRecords)
|
|
167
|
+
]));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function sourceFileOwnershipBlockers(stage, records = []) {
|
|
171
|
+
return (records ?? [])
|
|
172
|
+
.filter((record) => record?.triviaOwnershipStatus === 'blocked' || (record?.triviaOwnershipBlockReasonCodes ?? []).length)
|
|
173
|
+
.map((record) => ({
|
|
174
|
+
code: 'project-source-trivia-ownership-blocked',
|
|
175
|
+
gateId: 'project-graph-delta',
|
|
176
|
+
message: `Project ${stage} source ${JSON.stringify(record.sourcePath ?? 'unknown')} lacks deterministic trivia ownership evidence.`,
|
|
177
|
+
sourcePath: record.sourcePath,
|
|
178
|
+
details: compactRecord({
|
|
179
|
+
reasonCode: 'project-source-trivia-ownership-blocked',
|
|
180
|
+
conflictKey: `project-graph-delta#source-trivia-ownership#${stage}#${record.sourcePath ?? record.id}`,
|
|
181
|
+
stage,
|
|
182
|
+
sourcePath: record.sourcePath,
|
|
183
|
+
sourceHash: record.sourceHash,
|
|
184
|
+
triviaOwnershipStatus: record.triviaOwnershipStatus,
|
|
185
|
+
triviaOwnershipReasonCodes: record.triviaOwnershipReasonCodes,
|
|
186
|
+
triviaOwnershipBlockReasonCodes: record.triviaOwnershipBlockReasonCodes,
|
|
187
|
+
parserEvidence: record.parserEvidence,
|
|
188
|
+
losslessCst: record.losslessCst,
|
|
189
|
+
parserTriviaExactnessStatus: record.parserTriviaExactnessStatus,
|
|
190
|
+
exactParserTrivia: record.exactParserTrivia,
|
|
191
|
+
parserTriviaExactnessReasonCodes: record.parserTriviaExactnessReasonCodes,
|
|
192
|
+
parserTriviaExactnessBlockReasonCodes: record.parserTriviaExactnessBlockReasonCodes,
|
|
193
|
+
parserTriviaOwnershipStatus: record.parserTriviaOwnershipStatus,
|
|
194
|
+
parserTriviaOwnershipRelation: record.parserTriviaOwnershipRelation,
|
|
195
|
+
parserTriviaOwnershipReasonCodes: record.parserTriviaOwnershipReasonCodes,
|
|
196
|
+
parserTriviaOwnershipBlockReasonCodes: record.parserTriviaOwnershipBlockReasonCodes,
|
|
197
|
+
...sourceMapGeneratedBoundaryDetails(record),
|
|
198
|
+
roundtripHash: record.roundtripHash
|
|
199
|
+
})
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function sourceSpanOwnershipBlockers(stage, records = []) {
|
|
204
|
+
return (records ?? [])
|
|
205
|
+
.filter((record) => record?.ownershipAnchorStatus === 'blocked' || (record?.ownershipBlockReasonCodes ?? []).length)
|
|
206
|
+
.map((record) => ({
|
|
207
|
+
code: 'project-source-span-ownership-blocked',
|
|
208
|
+
gateId: 'project-graph-delta',
|
|
209
|
+
message: `Project ${stage} source span ${JSON.stringify(sourceSpanIdentityKey(record) ?? record.id ?? 'unknown')} lacks deterministic ownership evidence.`,
|
|
210
|
+
sourcePath: record.sourcePath,
|
|
211
|
+
details: compactRecord({
|
|
212
|
+
reasonCode: 'project-source-span-ownership-blocked',
|
|
213
|
+
conflictKey: `project-graph-delta#source-span-ownership#${stage}#${sourceSpanIdentityKey(record) ?? record.id}`,
|
|
214
|
+
stage,
|
|
215
|
+
identityKey: sourceSpanIdentityKey(record),
|
|
216
|
+
sourcePath: record.sourcePath,
|
|
217
|
+
role: record.role,
|
|
218
|
+
kind: record.kind,
|
|
219
|
+
ownershipAnchorStatus: record.ownershipAnchorStatus,
|
|
220
|
+
ownershipAnchorKey: record.ownershipAnchorKey,
|
|
221
|
+
ownershipAnchorHash: record.ownershipAnchorHash,
|
|
222
|
+
ownershipBlockReasonCodes: record.ownershipBlockReasonCodes,
|
|
223
|
+
parserEvidence: record.parserEvidence,
|
|
224
|
+
losslessCst: record.losslessCst,
|
|
225
|
+
parserTriviaExactnessStatus: record.parserTriviaExactnessStatus,
|
|
226
|
+
exactParserTrivia: record.exactParserTrivia,
|
|
227
|
+
parserTriviaExactnessReasonCodes: record.parserTriviaExactnessReasonCodes,
|
|
228
|
+
parserTriviaExactnessBlockReasonCodes: record.parserTriviaExactnessBlockReasonCodes,
|
|
229
|
+
...sourceMapGeneratedBoundaryDetails(record),
|
|
230
|
+
roundtripHash: record.roundtripHash
|
|
231
|
+
})
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function sourceMapGeneratedBoundaryBlockers(stage, fileRecords = [], spanRecords = []) {
|
|
236
|
+
return [
|
|
237
|
+
...(fileRecords ?? [])
|
|
238
|
+
.filter(hasBlockedSourceMapGeneratedBoundary)
|
|
239
|
+
.map((record) => sourceMapGeneratedBoundaryBlocker(stage, record, 'source-file')),
|
|
240
|
+
...(spanRecords ?? [])
|
|
241
|
+
.filter((record) => record?.kind === 'source-map-comment' || record?.ownershipAnchor?.anchorKind === 'generated-source-boundary')
|
|
242
|
+
.filter(hasBlockedSourceMapGeneratedBoundary)
|
|
243
|
+
.map((record) => sourceMapGeneratedBoundaryBlocker(stage, record, 'source-span'))
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function hasBlockedSourceMapGeneratedBoundary(record) {
|
|
248
|
+
return record?.sourceMapGeneratedBoundaryStatus === 'blocked'
|
|
249
|
+
|| record?.sourceMapGeneratedBoundaryOwnershipStatus === 'blocked'
|
|
250
|
+
|| (record?.sourceMapGeneratedBoundaryBlockReasonCodes ?? []).length > 0;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function sourceMapGeneratedBoundaryBlocker(stage, record, recordKind) {
|
|
254
|
+
const identityKey = recordKind === 'source-span' ? sourceSpanIdentityKey(record) : record.sourcePath ?? record.id;
|
|
255
|
+
return {
|
|
256
|
+
code: 'project-generated-source-boundary-ownership-blocked',
|
|
257
|
+
gateId: 'project-graph-delta',
|
|
258
|
+
message: `Project ${stage} generated source boundary ${JSON.stringify(identityKey ?? 'unknown')} lacks deterministic source-map ownership evidence.`,
|
|
259
|
+
sourcePath: record.sourcePath,
|
|
260
|
+
details: compactRecord({
|
|
261
|
+
reasonCode: 'project-generated-source-boundary-ownership-blocked',
|
|
262
|
+
conflictKey: `project-graph-delta#generated-source-boundary-ownership#${stage}#${recordKind}#${identityKey ?? record.id}`,
|
|
263
|
+
stage,
|
|
264
|
+
recordKind,
|
|
265
|
+
identityKey,
|
|
266
|
+
sourcePath: record.sourcePath,
|
|
267
|
+
role: record.role,
|
|
268
|
+
kind: record.kind,
|
|
269
|
+
sourceHash: record.sourceHash,
|
|
270
|
+
...sourceMapGeneratedBoundaryDetails(record),
|
|
271
|
+
roundtripHash: record.roundtripHash
|
|
272
|
+
})
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function uniqueSourceOwnershipBlockers(conflicts) {
|
|
277
|
+
const seen = new Set();
|
|
278
|
+
return conflicts.filter((conflict) => {
|
|
279
|
+
const key = conflict.details?.conflictKey ?? JSON.stringify(conflict);
|
|
280
|
+
if (seen.has(key)) return false;
|
|
281
|
+
seen.add(key);
|
|
282
|
+
return true;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function sourceSpanIdentityAnchor(record) {
|
|
287
|
+
if (record?.directive) {
|
|
288
|
+
if (record.kind === 'runtime-directive') return 'runtime-directive-prologue';
|
|
289
|
+
if (record.kind === 'source-map-comment') return 'source-map-comment';
|
|
290
|
+
if (record.kind === 'typescript-reference') return 'typescript-reference';
|
|
291
|
+
return record.textHash ?? record.kind ?? 'directive';
|
|
292
|
+
}
|
|
293
|
+
if (record?.kind === 'source-map-comment') return 'source-map-comment';
|
|
294
|
+
if (record?.protected) return stableKey(['protected', record.textHash ?? record.kind]);
|
|
295
|
+
if (record?.trivia || record?.role === 'comment') return stableKey(['trivia', record.textHash ?? record.kind]);
|
|
296
|
+
return record?.textHash ?? record?.kind ?? record?.role;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function isCommentKind(kind) {
|
|
300
|
+
return kind === 'comment' || kind === 'jsdoc-comment' || kind === 'block-comment';
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function stableKey(parts) {
|
|
304
|
+
const values = parts.map((part) => part === undefined || part === null ? '' : String(part));
|
|
305
|
+
return values.some(Boolean) ? values.join('#') : undefined;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
309
|
+
|
|
310
|
+
export { projectSourceSpanDeltaConflicts };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { createParserTriviaExactnessRecord } from './native-source-preservation-ownership.js';
|
|
2
|
+
|
|
3
|
+
function sourceSpanRoundtripEvidence(id, fileResults, level, legacyLevel) {
|
|
4
|
+
const outputFiles = fileResults.filter((file) => typeof file.outputSourceText === 'string');
|
|
5
|
+
const changedOutputFiles = outputFiles.filter((file) => !hashMatchesBase(file));
|
|
6
|
+
const changedSourceResults = changedOutputFiles.filter((file) => file.result);
|
|
7
|
+
const facts = changedSourceResults.map(sourceSpanRoundtripFacts);
|
|
8
|
+
const failed = facts.filter((fact) => fact.status === 'failed');
|
|
9
|
+
const missing = facts.filter((fact) => fact.status === 'missing');
|
|
10
|
+
const admissionBlockingFailed = failed.filter((fact) => fact.roundtripProofAdmissionBlocker);
|
|
11
|
+
const requiredMissing = missing.filter((fact) => fact.roundtripProofRequired);
|
|
12
|
+
const parserTriviaExactness = parserTriviaExactnessSummary(facts);
|
|
13
|
+
const changedWithoutSourceResults = changedOutputFiles.filter((file) => !file.result && sourceSpanRoundtripRequired(file)).length;
|
|
14
|
+
const status = admissionBlockingFailed.length ? 'failed'
|
|
15
|
+
: changedWithoutSourceResults || requiredMissing.length ? 'skipped'
|
|
16
|
+
: changedOutputFiles.length ? 'passed' : 'skipped';
|
|
17
|
+
const missingSignal = status === 'skipped' && changedOutputFiles.length > 0 ? 'source-span-roundtrip-evidence-not-produced' : undefined;
|
|
18
|
+
return evidenceRecord({
|
|
19
|
+
id,
|
|
20
|
+
suffix: 'source_span_roundtrip',
|
|
21
|
+
level,
|
|
22
|
+
status,
|
|
23
|
+
scope: 'source-files',
|
|
24
|
+
summary: summaryFor(status, facts, changedOutputFiles),
|
|
25
|
+
metadata: {
|
|
26
|
+
legacyProofLevel: legacyLevel,
|
|
27
|
+
outputFiles: outputFiles.length,
|
|
28
|
+
changedOutputFiles: changedOutputFiles.length,
|
|
29
|
+
changedSourceResults: changedSourceResults.length,
|
|
30
|
+
passedSourceResults: facts.filter((fact) => fact.status === 'passed').length,
|
|
31
|
+
failedSourceResults: failed.length,
|
|
32
|
+
admissionBlockingFailedSourceResults: admissionBlockingFailed.length,
|
|
33
|
+
sourceSpanRoundtripAdmissionBlockerSourcePaths: admissionBlockingFailed.map((fact) => fact.sourcePath),
|
|
34
|
+
missingSourceResults: missing.length + Math.max(0, changedWithoutSourceResults),
|
|
35
|
+
missingRequiredSourceResults: requiredMissing.length + Math.max(0, changedWithoutSourceResults),
|
|
36
|
+
semanticReplayVerifiedFiles: facts.filter((fact) => fact.semanticArtifactsStatus === 'verified').length,
|
|
37
|
+
sourceSpanOperations: sumBy(facts, (fact) => fact.sourceSpanOperations),
|
|
38
|
+
projectionEdits: sumBy(facts, (fact) => fact.projectionEdits),
|
|
39
|
+
spanLinkedProjectionEdits: sumBy(facts, (fact) => fact.spanLinkedProjectionEdits),
|
|
40
|
+
replayVerifiedFiles: facts.filter((fact) => fact.replayOutputMatchesMerged).length,
|
|
41
|
+
parserTriviaExactnessStatus: parserTriviaExactness.status,
|
|
42
|
+
exactParserTriviaFiles: parserTriviaExactness.exact,
|
|
43
|
+
approximateParserTriviaFiles: parserTriviaExactness.approximate,
|
|
44
|
+
blockedParserTriviaFiles: parserTriviaExactness.blocked,
|
|
45
|
+
parserTriviaExactnessReasonCodes: parserTriviaExactness.reasonCodes,
|
|
46
|
+
parserTriviaExactnessBlockReasonCodes: parserTriviaExactness.blockReasonCodes,
|
|
47
|
+
missingSignal,
|
|
48
|
+
nextAction: missingSignal ? 'Supply verified semantic artifacts with source spans, projected edits, and clean replay output for every changed source file.' : undefined
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function sourceSpanRoundtripFacts(file) {
|
|
54
|
+
const artifacts = file.semanticArtifacts ?? file.result?.semanticArtifacts;
|
|
55
|
+
const operations = Array.isArray(artifacts?.script?.operations) ? artifacts.script.operations : [];
|
|
56
|
+
const projectionEdits = Array.isArray(artifacts?.projection?.edits) ? artifacts.projection.edits : [];
|
|
57
|
+
const sourceSpanOperations = operations.filter(operationHasSourceSpan).length;
|
|
58
|
+
const spanLinkedProjectionEdits = projectionEdits.filter(editHasSourceSpan).length;
|
|
59
|
+
const gatesPassed = (file.result?.gates ?? []).every((gate) => gate.status === 'passed');
|
|
60
|
+
const projectedSourceMatchesMerged = artifacts?.summary?.projectedSourceMatchesMerged === true;
|
|
61
|
+
const replayOutputMatchesMerged = artifacts?.summary?.replayOutputMatchesMerged === true;
|
|
62
|
+
const parserTriviaExactness = parserTriviaExactnessForFile(file, artifacts);
|
|
63
|
+
const roundtripProofRequired = sourceSpanRoundtripRequired(file);
|
|
64
|
+
const status = parserTriviaExactness.status === 'blocked' || file.result?.status !== 'merged' || artifacts?.status === 'blocked'
|
|
65
|
+
? 'failed'
|
|
66
|
+
: !artifacts || artifacts.status !== 'verified' || !gatesPassed || !projectedSourceMatchesMerged || !replayOutputMatchesMerged || !sourceSpanOperations || !spanLinkedProjectionEdits
|
|
67
|
+
? 'missing'
|
|
68
|
+
: 'passed';
|
|
69
|
+
return {
|
|
70
|
+
sourcePath: file.sourcePath,
|
|
71
|
+
status,
|
|
72
|
+
semanticArtifactsStatus: artifacts?.status,
|
|
73
|
+
gatesPassed,
|
|
74
|
+
operations: operations.length,
|
|
75
|
+
sourceSpanOperations,
|
|
76
|
+
projectionEdits: projectionEdits.length,
|
|
77
|
+
spanLinkedProjectionEdits,
|
|
78
|
+
roundtripProofRequired,
|
|
79
|
+
roundtripProofAdmissionBlocker: roundtripProofRequired && status === 'failed',
|
|
80
|
+
projectedSourceMatchesMerged,
|
|
81
|
+
replayOutputMatchesMerged,
|
|
82
|
+
parserTriviaExactnessStatus: parserTriviaExactness.status,
|
|
83
|
+
exactParserTrivia: parserTriviaExactness.exactParserTrivia,
|
|
84
|
+
parserTriviaExactnessReasonCodes: parserTriviaExactness.reasonCodes,
|
|
85
|
+
parserTriviaExactnessBlockReasonCodes: parserTriviaExactness.blockReasonCodes
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function parserTriviaExactnessForFile(file, artifacts) {
|
|
90
|
+
return createParserTriviaExactnessRecord(
|
|
91
|
+
file.parserTriviaExactness
|
|
92
|
+
?? file.parserTriviaEvidence
|
|
93
|
+
?? file.metadata?.parserTriviaExactness
|
|
94
|
+
?? file.result?.metadata?.parserTriviaExactness
|
|
95
|
+
?? artifacts?.metadata?.parserTriviaExactness,
|
|
96
|
+
{
|
|
97
|
+
sourcePath: file.sourcePath,
|
|
98
|
+
sourceHash: file.outputHash,
|
|
99
|
+
parserEvidence: artifacts?.metadata?.parserEvidence
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function parserTriviaExactnessSummary(facts) {
|
|
105
|
+
const exact = facts.filter((fact) => fact.parserTriviaExactnessStatus === 'exact').length;
|
|
106
|
+
const blocked = facts.filter((fact) => fact.parserTriviaExactnessStatus === 'blocked').length;
|
|
107
|
+
const approximate = facts.filter((fact) => fact.parserTriviaExactnessStatus === 'approximate').length;
|
|
108
|
+
const reasonCodes = uniqueStrings(facts.flatMap((fact) => fact.parserTriviaExactnessReasonCodes ?? []));
|
|
109
|
+
const blockReasonCodes = uniqueStrings(facts.flatMap((fact) => fact.parserTriviaExactnessBlockReasonCodes ?? []));
|
|
110
|
+
return {
|
|
111
|
+
status: blocked ? 'blocked' : exact && exact === facts.length ? 'exact' : facts.length ? 'approximate' : 'absent',
|
|
112
|
+
exact,
|
|
113
|
+
approximate,
|
|
114
|
+
blocked,
|
|
115
|
+
reasonCodes,
|
|
116
|
+
blockReasonCodes
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function summaryFor(status, facts, changedOutputFiles) {
|
|
121
|
+
if (status === 'passed') return `Verified source-span projection and replay roundtrip evidence for ${facts.filter((fact) => fact.status === 'passed').length} changed source file(s).`;
|
|
122
|
+
if (status === 'failed') return `Source-span projection or replay roundtrip evidence failed for ${facts.filter((fact) => fact.status === 'failed').length} changed source file(s).`;
|
|
123
|
+
return changedOutputFiles.length
|
|
124
|
+
? 'Changed project output is missing source-span projection or replay roundtrip evidence.'
|
|
125
|
+
: 'No changed source output required source-span roundtrip evidence.';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function evidenceRecord(input) {
|
|
129
|
+
return {
|
|
130
|
+
id: `${input.id}_proof_${input.suffix}`,
|
|
131
|
+
kind: 'js-ts-project-merge-proof-evidence',
|
|
132
|
+
level: input.level,
|
|
133
|
+
status: input.status,
|
|
134
|
+
scope: input.scope,
|
|
135
|
+
claimKind: 'evidence',
|
|
136
|
+
evidenceOnly: true,
|
|
137
|
+
proofClaim: false,
|
|
138
|
+
autoMergeClaim: false,
|
|
139
|
+
semanticEquivalenceClaim: false,
|
|
140
|
+
summary: input.summary,
|
|
141
|
+
metadata: compactRecord({ ...(input.metadata ?? {}), proofClaim: false, autoMergeClaim: false, semanticEquivalenceClaim: false })
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function operationHasSourceSpan(operation) {
|
|
146
|
+
return isSpan(operation?.anchor?.sourceSpan) || isSpan(operation?.spans?.worker) || isSpan(operation?.spans?.head) || isSpan(operation?.spans?.base);
|
|
147
|
+
}
|
|
148
|
+
function editHasSourceSpan(edit) {
|
|
149
|
+
return Number.isFinite(edit?.workerStart) && Number.isFinite(edit?.workerEnd)
|
|
150
|
+
|| Number.isFinite(edit?.headStart) && Number.isFinite(edit?.headEnd)
|
|
151
|
+
|| Number.isFinite(edit?.start) && Number.isFinite(edit?.end);
|
|
152
|
+
}
|
|
153
|
+
function hashMatchesBase(file) { return Boolean(file.baseHash) && file.outputHash === file.baseHash; }
|
|
154
|
+
function sourceSpanRoundtripRequired(file) { return !preservesSingleChangedInput(file); }
|
|
155
|
+
function preservesSingleChangedInput(file) {
|
|
156
|
+
const workerChanged = file.workerHash !== file.baseHash;
|
|
157
|
+
const headChanged = file.headHash !== file.baseHash;
|
|
158
|
+
if (workerChanged && !headChanged && file.outputHash === file.workerHash) return true;
|
|
159
|
+
if (headChanged && !workerChanged && file.outputHash === file.headHash) return true;
|
|
160
|
+
return workerChanged && headChanged && file.workerHash === file.headHash && file.outputHash === file.workerHash;
|
|
161
|
+
}
|
|
162
|
+
function isSpan(value) { return isOffsetSpan(value) || isLineColumnSpan(value); }
|
|
163
|
+
function isOffsetSpan(value) { return Number.isFinite(value?.start) && Number.isFinite(value?.end); }
|
|
164
|
+
function isLineColumnSpan(value) {
|
|
165
|
+
return Number.isFinite(value?.startLine) && Number.isFinite(value?.endLine)
|
|
166
|
+
&& Number.isFinite(value?.startColumn) && Number.isFinite(value?.endColumn);
|
|
167
|
+
}
|
|
168
|
+
function sumBy(values, valueFor) { return values.reduce((total, value) => total + Number(valueFor(value) ?? 0), 0); }
|
|
169
|
+
function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
|
|
170
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
171
|
+
|
|
172
|
+
export { sourceSpanRoundtripEvidence };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createExactBranchProjectSemanticEditAdmissionFile,
|
|
3
|
+
summarizeProjectSemanticEditAdmissions
|
|
4
|
+
} from './js-ts-safe-project-merge-admission.js';
|
|
5
|
+
import { generatedProjectSourcePath } from './js-ts-safe-project-merge-split-merge-shapes.js';
|
|
6
|
+
|
|
7
|
+
const splitMergeKinds = new Set(['module-split', 'module-merge', 'class-split', 'class-merge']);
|
|
8
|
+
|
|
9
|
+
function maybeAdmitProjectSplitMergeFile(fileResult, file, input, classifications) {
|
|
10
|
+
if (!classifications.every((classification) => allowsProjectSplitMerge(input, classification))) return undefined;
|
|
11
|
+
if (!hasProjectSplitMergeAdmissionEvidence(input)) return undefined;
|
|
12
|
+
if (classifications.some((classification) => classification.details?.exactStructuralPartition === false)) return undefined;
|
|
13
|
+
if (classifications.some(classificationTouchesGeneratedOutputBoundary)) return undefined;
|
|
14
|
+
return createExactBranchProjectSemanticEditAdmissionFile({
|
|
15
|
+
fileResult,
|
|
16
|
+
file,
|
|
17
|
+
classifications,
|
|
18
|
+
admissionKind: 'js-ts-project-split-merge-admission',
|
|
19
|
+
action: 'apply-project-split-merge',
|
|
20
|
+
operation: 'merged-project-split-merge',
|
|
21
|
+
summaryKey: 'projectSplitMergeAdmissions',
|
|
22
|
+
evidenceKey: 'projectSplitMergeAdmissionEvidence',
|
|
23
|
+
metadataKey: 'projectSplitMergeAdmissions',
|
|
24
|
+
requireOtherBranchUnchanged: true,
|
|
25
|
+
requireBaseForOtherBranchUnchanged: false,
|
|
26
|
+
allowDeletedBranchOutput: true,
|
|
27
|
+
classificationFilter: (classification) => splitMergeKinds.has(classification.kind),
|
|
28
|
+
admissionFields: (classification) => ({ structuralEditKind: classification.kind }),
|
|
29
|
+
details: admittedSplitMergeDetails
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function projectSplitMergeAdmissionSummary(admissions = []) {
|
|
34
|
+
return summarizeProjectSemanticEditAdmissions(admissions, {
|
|
35
|
+
totalKey: 'splitMergeAdmissions',
|
|
36
|
+
byKind: [
|
|
37
|
+
{ key: 'moduleSplitAdmissions', property: 'structuralEditKind', value: 'module-split' },
|
|
38
|
+
{ key: 'moduleMergeAdmissions', property: 'structuralEditKind', value: 'module-merge' },
|
|
39
|
+
{ key: 'classSplitAdmissions', property: 'structuralEditKind', value: 'class-split' },
|
|
40
|
+
{ key: 'classMergeAdmissions', property: 'structuralEditKind', value: 'class-merge' }
|
|
41
|
+
],
|
|
42
|
+
evidenceIdsKey: 'splitMergeAdmissionEvidenceIds'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function allowsProjectSplitMerge(input, classification) {
|
|
47
|
+
if (input?.allowProjectSplitMerges === true || input?.allowSplitMerges === true) return true;
|
|
48
|
+
if (classification?.kind === 'module-split') return input?.allowProjectModuleSplits === true || input?.allowModuleSplits === true;
|
|
49
|
+
if (classification?.kind === 'module-merge') return input?.allowProjectModuleMerges === true || input?.allowModuleMerges === true;
|
|
50
|
+
if (classification?.kind === 'class-split') return input?.allowProjectClassSplits === true || input?.allowClassSplits === true;
|
|
51
|
+
if (classification?.kind === 'class-merge') return input?.allowProjectClassMerges === true || input?.allowClassMerges === true;
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function hasProjectSplitMergeAdmissionEvidence(input = {}) {
|
|
56
|
+
return hasOutputProjectGraphEvidence(input)
|
|
57
|
+
&& hasOutputDiagnosticsEvidence(input)
|
|
58
|
+
&& hasOutputDeclarationEvidence(input);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function hasOutputProjectGraphEvidence(input = {}) {
|
|
62
|
+
return input.includeOutputProjectSymbolGraph === true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function hasOutputDiagnosticsEvidence(input = {}) {
|
|
66
|
+
return input.requireOutputDiagnostics === true
|
|
67
|
+
|| Object.hasOwn(input, 'outputDiagnostics')
|
|
68
|
+
|| Boolean(input.typescript ?? input.ts ?? input.typescriptModule);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function hasOutputDeclarationEvidence(input = {}) {
|
|
72
|
+
return input.requireDeclarationOutput === true
|
|
73
|
+
|| input.includeDeclarationOutput === true
|
|
74
|
+
|| input.outputDeclarations !== undefined
|
|
75
|
+
|| input.outputDeclarationFiles !== undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function classificationTouchesGeneratedOutputBoundary(classification) {
|
|
79
|
+
return classification.details?.generatedOutputBoundary === true
|
|
80
|
+
|| (classification.sourcePaths ?? []).some(generatedProjectSourcePath);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function admittedSplitMergeDetails(classification) {
|
|
84
|
+
return {
|
|
85
|
+
...(classification.details ?? {}),
|
|
86
|
+
presentRequiredEvidence: classification.details?.requiredEvidence,
|
|
87
|
+
missingRequiredEvidence: []
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
allowsProjectSplitMerge,
|
|
93
|
+
hasProjectSplitMergeAdmissionEvidence,
|
|
94
|
+
maybeAdmitProjectSplitMergeFile,
|
|
95
|
+
projectSplitMergeAdmissionSummary
|
|
96
|
+
};
|