@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,320 @@
|
|
|
1
|
+
import { uniqueStrings } from '../../native-import-utils.js';
|
|
2
|
+
import { effectTargetContextReasonCodes } from '../../semantic-import-runtime-effect-target-evidence.js'; import { mutationTargetContextReasonCodes } from '../../semantic-import-runtime-mutation-evidence.js';
|
|
3
|
+
import { promiseCombinatorContextReasonCodes } from '../../semantic-import-runtime-promise-combinator-evidence.js';
|
|
4
|
+
import { promiseChainContextReasonCodes } from '../../semantic-import-runtime-promise-chain-evidence.js';
|
|
5
|
+
import { nativeImportSourceText } from './nativeImportSourceText.js';
|
|
6
|
+
import { runtimeOrderEvidenceBinding } from './runtimeOrderEvidenceBinding.js';
|
|
7
|
+
import { sourceTextForSpan } from './sourceTextForSpan.js';
|
|
8
|
+
const runtimeOrderSensitiveRegionKinds = new Set(['call', 'controlFlow', 'effect', 'mutation']);
|
|
9
|
+
|
|
10
|
+
export function orderSensitiveHeadPeerConflict(input) {
|
|
11
|
+
if (!isRuntimeOrderSensitiveRegion(input.region, input.baseSymbol)) return undefined;
|
|
12
|
+
const explicitEvidence = runtimeOrderEvidenceBinding(input);
|
|
13
|
+
if (explicitEvidence.passed) return undefined;
|
|
14
|
+
const sameAnchor = sameAnchorRuntimeOrderConflict(input);
|
|
15
|
+
if (sameAnchor) {
|
|
16
|
+
return {
|
|
17
|
+
peer: sameAnchor.region,
|
|
18
|
+
reasonCodes: uniqueStrings([
|
|
19
|
+
'head-runtime-order-evidence-changed-since-base',
|
|
20
|
+
'runtime-order-sensitive-merge-requires-explicit-evidence',
|
|
21
|
+
...explicitEvidence.reasonCodes,
|
|
22
|
+
...runtimeOrderReasonCodes(input),
|
|
23
|
+
...runtimeOrderReasonCodes({ ...input, region: sameAnchor.region })
|
|
24
|
+
]),
|
|
25
|
+
evidenceIds: explicitEvidence.evidenceIds
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const peer = (input.context.headChangeSet?.changedRegions ?? [])
|
|
29
|
+
.find((region) => orderSensitivePeerChanged(input.region, region, input.context));
|
|
30
|
+
if (!peer) return undefined;
|
|
31
|
+
return {
|
|
32
|
+
peer,
|
|
33
|
+
reasonCodes: uniqueStrings([
|
|
34
|
+
'head-order-sensitive-peer-changed-since-base',
|
|
35
|
+
'runtime-order-sensitive-merge-requires-explicit-evidence',
|
|
36
|
+
...explicitEvidence.reasonCodes,
|
|
37
|
+
...runtimeOrderReasonCodes(input),
|
|
38
|
+
...runtimeOrderReasonCodes({ ...input, region: peer })
|
|
39
|
+
]),
|
|
40
|
+
evidenceIds: explicitEvidence.evidenceIds
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function runtimeOrderReasonCodes(input) {
|
|
45
|
+
const regionKind = runtimeRegionKind(input.region, input.baseSymbol);
|
|
46
|
+
if (regionKind === 'call') return uniqueStrings([...callsiteOrderReasonCodes(input), ...runtimeOrderContextReasonCodes(input)]);
|
|
47
|
+
if (regionKind === 'controlFlow') return uniqueStrings([...controlFlowOrderReasonCodes(input), ...runtimeOrderContextReasonCodes(input)]);
|
|
48
|
+
if (regionKind === 'effect') return uniqueStrings([...effectOrderReasonCodes(input), ...runtimeOrderContextReasonCodes(input)]);
|
|
49
|
+
if (regionKind === 'mutation') return uniqueStrings([...mutationOrderReasonCodes(input), ...runtimeOrderContextReasonCodes(input)]);
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function templateLiteralBlockReasonCodes(input) {
|
|
54
|
+
const kinds = regionFactKinds(input.region);
|
|
55
|
+
if (!kinds.includes('tagged-template') && !kinds.includes('template-interpolation')) return [];
|
|
56
|
+
return uniqueStrings([
|
|
57
|
+
'template-literal-merge-requires-template-evidence',
|
|
58
|
+
...(kinds.includes('tagged-template') ? ['tagged-template-merge-requires-tag-effect-evidence'] : []),
|
|
59
|
+
...(kinds.includes('template-interpolation') ? ['template-interpolation-merge-requires-expression-order-evidence'] : []),
|
|
60
|
+
...effectOrderReasonCodes(input), ...runtimeOrderContextReasonCodes(input)
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function orderSensitivePeerChanged(workerRegion, headRegion, context) {
|
|
65
|
+
if (!isRuntimeOrderSensitiveRegion(headRegion)) return false;
|
|
66
|
+
if ((headRegion.conflictKey ?? headRegion.key) === (workerRegion.conflictKey ?? workerRegion.key)) return false;
|
|
67
|
+
if (!sameRegionSourcePath(workerRegion, headRegion)) return false;
|
|
68
|
+
if (!headRegionHasCoherentTextChange(headRegion, context)) return false;
|
|
69
|
+
const workerOwner = runtimeRegionOwner(workerRegion);
|
|
70
|
+
const headOwner = runtimeRegionOwner(headRegion);
|
|
71
|
+
return Boolean(workerOwner && headOwner && workerOwner === headOwner);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function sameAnchorRuntimeOrderConflict(input) {
|
|
75
|
+
const key = input.region?.key ?? stripRegionPrefix(input.region?.conflictKey);
|
|
76
|
+
if (!key) return undefined;
|
|
77
|
+
const changedSymbol = (input.context.headChangeSet?.changedSymbols ?? [])
|
|
78
|
+
.find((symbol) => symbolRuntimeOrderSignatureChangedForKey(symbol, key));
|
|
79
|
+
if (!changedSymbol) return undefined;
|
|
80
|
+
const region = (input.context.headChangeSet?.changedRegions ?? [])
|
|
81
|
+
.find((candidate) => (candidate.key ?? stripRegionPrefix(candidate.conflictKey)) === key)
|
|
82
|
+
?? input.region;
|
|
83
|
+
if (!runtimeOrderContextReasonCodes(input).length && !runtimeOrderContextReasonCodes({ ...input, region }).length) return undefined;
|
|
84
|
+
return { region, changedSymbol };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function symbolRuntimeOrderSignatureChangedForKey(symbol, key) {
|
|
88
|
+
if (![symbol?.beforeOwnershipKey, symbol?.afterOwnershipKey, symbol?.ownershipKey].includes(key)) return false;
|
|
89
|
+
if ((symbol.beforeSignatureHash ?? '') === (symbol.afterSignatureHash ?? '')) return false;
|
|
90
|
+
if (symbol.beforeSpanHash && symbol.afterSpanHash && symbol.beforeSpanHash !== symbol.afterSpanHash) return false;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function stripRegionPrefix(value) {
|
|
95
|
+
const text = String(value ?? '');
|
|
96
|
+
return text.startsWith('region:') ? text.slice('region:'.length) : text || undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function headRegionHasCoherentTextChange(region, context) {
|
|
100
|
+
const projection = region?.metadata?.changedRegionProjection;
|
|
101
|
+
const beforeSpan = projection?.before?.sourceSpan;
|
|
102
|
+
const afterSpan = projection?.after?.sourceSpan;
|
|
103
|
+
if (!beforeSpan || !afterSpan) return true;
|
|
104
|
+
|
|
105
|
+
const beforeHash = projection?.before?.sourceHash ?? context?.base?.nativeSource?.hash;
|
|
106
|
+
const afterHash = projection?.after?.sourceHash ?? context?.head?.nativeSource?.hash;
|
|
107
|
+
if (beforeSpan.sourceId && beforeHash && beforeSpan.sourceId !== beforeHash) return false;
|
|
108
|
+
if (afterSpan.sourceId && afterHash && afterSpan.sourceId !== afterHash) return false;
|
|
109
|
+
|
|
110
|
+
const beforeText = sourceTextForSpan(nativeImportSourceText(context?.base), beforeSpan);
|
|
111
|
+
const afterText = sourceTextForSpan(nativeImportSourceText(context?.head), afterSpan);
|
|
112
|
+
if (typeof beforeText === 'string' && typeof afterText === 'string') return beforeText !== afterText;
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function callsiteOrderReasonCodes(input) {
|
|
117
|
+
if (!stableCalleeCallsite(input)) return ['callsite-merge-requires-call-order-evidence'];
|
|
118
|
+
return [
|
|
119
|
+
'callsite-argument-merge-requires-callee-signature-evidence',
|
|
120
|
+
'callsite-argument-merge-requires-argument-effect-evidence',
|
|
121
|
+
'callsite-argument-merge-requires-argument-order-evidence'
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function controlFlowOrderReasonCodes(input) {
|
|
126
|
+
return uniqueStrings([
|
|
127
|
+
'control-flow-merge-requires-control-order-evidence',
|
|
128
|
+
...regionFactKinds(input.region).flatMap((kind) => {
|
|
129
|
+
if (kind === 'branch') return ['control-flow-branch-merge-requires-condition-order-evidence'];
|
|
130
|
+
if (kind === 'loop') return ['control-flow-loop-merge-requires-iteration-order-evidence'];
|
|
131
|
+
if (kind === 'exit') return ['control-flow-exit-merge-requires-return-yield-order-evidence'];
|
|
132
|
+
if (kind === 'transfer') return ['control-flow-transfer-merge-requires-break-continue-order-evidence'];
|
|
133
|
+
if (kind === 'exception') return ['control-flow-exception-merge-requires-throw-order-evidence'];
|
|
134
|
+
if (kind === 'async') return ['control-flow-async-merge-requires-await-order-evidence'];
|
|
135
|
+
return [];
|
|
136
|
+
})
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function effectOrderReasonCodes(input) {
|
|
141
|
+
return uniqueStrings([
|
|
142
|
+
'effect-merge-requires-side-effect-evidence',
|
|
143
|
+
'effect-merge-requires-effect-order-evidence',
|
|
144
|
+
...regionFactKinds(input.region).flatMap((kind) => {
|
|
145
|
+
if (kind === 'async') return ['effect-async-merge-requires-await-order-evidence'];
|
|
146
|
+
if (kind === 'network') return ['effect-network-merge-requires-io-order-evidence'];
|
|
147
|
+
if (kind === 'storage') return ['effect-storage-merge-requires-storage-order-evidence'];
|
|
148
|
+
if (kind === 'scheduler') return ['effect-scheduler-merge-requires-scheduler-order-evidence']; if (kind === 'class-static-block') return ['effect-class-static-block-merge-requires-static-initialization-order-evidence'];
|
|
149
|
+
if (kind === 'host-context') return ['effect-import-meta-merge-requires-host-context-evidence'];
|
|
150
|
+
if (kind === 'host') return ['effect-host-merge-requires-host-order-evidence'];
|
|
151
|
+
if (kind === 'browser') return ['effect-browser-merge-requires-browser-order-evidence'];
|
|
152
|
+
if (kind === 'getter') return ['effect-getter-merge-requires-getter-order-evidence'];
|
|
153
|
+
if (kind === 'generator') return ['effect-generator-merge-requires-yield-order-evidence'];
|
|
154
|
+
if (kind === 'resource-management' || kind === 'using' || kind === 'await-using') return ['effect-resource-management-merge-requires-acquisition-disposal-evidence'];
|
|
155
|
+
if (kind === 'template-literal') return ['effect-template-literal-merge-requires-template-token-evidence'];
|
|
156
|
+
if (kind === 'template-interpolation') return ['effect-template-interpolation-merge-requires-expression-order-evidence'];
|
|
157
|
+
if (kind === 'tagged-template') return ['effect-tagged-template-merge-requires-tag-effect-evidence'];
|
|
158
|
+
return [];
|
|
159
|
+
})
|
|
160
|
+
]);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function mutationOrderReasonCodes(input) {
|
|
164
|
+
return uniqueStrings([
|
|
165
|
+
'mutation-merge-requires-write-order-evidence',
|
|
166
|
+
...regionFactKinds(input.region).flatMap((kind) => {
|
|
167
|
+
if (kind === 'assignment') return ['mutation-assignment-merge-requires-assignment-order-evidence'];
|
|
168
|
+
if (kind === 'update') return ['mutation-update-merge-requires-update-order-evidence'];
|
|
169
|
+
if (kind === 'delete') return ['mutation-delete-merge-requires-delete-order-evidence'];
|
|
170
|
+
if (kind === 'mutating-call') return ['mutation-call-merge-requires-call-order-evidence'];
|
|
171
|
+
return [];
|
|
172
|
+
})
|
|
173
|
+
]);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function runtimeOrderContextReasonCodes(input) {
|
|
177
|
+
const evidence = runtimeOrderEvidence(input.region);
|
|
178
|
+
return uniqueStrings([
|
|
179
|
+
...array(evidence?.branchOrder).flatMap(controlFlowContextReasonCodes),
|
|
180
|
+
...array(evidence?.loopOrder).flatMap(controlFlowContextReasonCodes),
|
|
181
|
+
...array(evidence?.sameLineControlFlow).flatMap(controlFlowContextReasonCodes),
|
|
182
|
+
...array(evidence?.loopIterationOrder).flatMap(loopIterationContextReasonCodes),
|
|
183
|
+
...array(evidence?.controlTransferOrder).flatMap(controlTransferContextReasonCodes),
|
|
184
|
+
...array(evidence?.exitOrder).flatMap(exitContextReasonCodes),
|
|
185
|
+
...array(evidence?.reachabilityOrder).flatMap(reachabilityContextReasonCodes),
|
|
186
|
+
...(array(evidence?.sameLineShortCircuit).length ? ['runtime-order-short-circuit-merge-requires-expression-order-evidence'] : []),
|
|
187
|
+
...(array(evidence?.importMetaHostContext).length ? ['runtime-order-import-meta-merge-requires-host-context-evidence'] : []), ...(array(evidence?.classStaticBlockOrder).length ? ['runtime-order-class-static-block-merge-requires-static-initialization-evidence'] : []),
|
|
188
|
+
...(evidence?.sameLineAwait || array(evidence?.sameLineAwaitOrder).length
|
|
189
|
+
? ['runtime-order-await-merge-requires-suspension-order-evidence']
|
|
190
|
+
: []),
|
|
191
|
+
...(array(evidence?.sameLineOptionalChain).length
|
|
192
|
+
? ['runtime-order-optional-chain-merge-requires-nullish-boundary-evidence']
|
|
193
|
+
: []),
|
|
194
|
+
...(array(evidence?.sameLineConditionalExpression).length
|
|
195
|
+
? ['runtime-order-conditional-expression-merge-requires-branch-selection-evidence']
|
|
196
|
+
: []),
|
|
197
|
+
...array(evidence?.sameLinePromiseCombinator).flatMap(promiseCombinatorContextReasonCodes),
|
|
198
|
+
...array(evidence?.sameLinePromiseChain).flatMap(promiseChainContextReasonCodes),
|
|
199
|
+
...(array(evidence?.sameLineThrowOrder).length || evidence?.sameLineThrow
|
|
200
|
+
? ['runtime-order-throw-merge-requires-exception-path-evidence']
|
|
201
|
+
: []),
|
|
202
|
+
...array(evidence?.switchDispatchOrder).flatMap(switchDispatchContextReasonCodes),
|
|
203
|
+
...array(evidence?.tryCatchOrder).flatMap(tryCatchContextReasonCodes),
|
|
204
|
+
...array(evidence?.mutationTargetOrder).flatMap(mutationTargetContextReasonCodes), ...array(evidence?.effectTargetOrder).flatMap(effectTargetContextReasonCodes),
|
|
205
|
+
...array(evidence?.tryFinallyOrder).flatMap(tryFinallyContextReasonCodes),
|
|
206
|
+
...array(evidence?.resourceManagementOrder).flatMap(resourceManagementContextReasonCodes)
|
|
207
|
+
]);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function runtimeOrderEvidence(region) { return region?.metadata?.runtimeOrderEvidence ?? region?.runtimeOrderEvidence; }
|
|
211
|
+
function exitContextReasonCodes(record) { return uniqueStrings(['runtime-order-exit-merge-requires-completion-value-evidence', record?.delegated ? 'runtime-order-yield-star-merge-requires-iterator-delegation-evidence' : undefined, record?.iteratorProtocolEquivalenceClaim === false ? 'runtime-order-yield-star-iterator-protocol-equivalence-not-proven' : undefined, record?.delegatedCompletionPropagationClaim === false ? 'runtime-order-yield-star-completion-propagation-equivalence-not-proven' : undefined]); }
|
|
212
|
+
function controlFlowContextReasonCodes(record) { if (record?.kind === 'branch') return ['control-flow-branch-merge-requires-condition-order-evidence']; if (record?.kind === 'loop') return ['control-flow-loop-merge-requires-iteration-order-evidence']; if (record?.kind === 'exception') return ['control-flow-exception-merge-requires-throw-order-evidence']; return []; }
|
|
213
|
+
|
|
214
|
+
function loopIterationContextReasonCodes(record) {
|
|
215
|
+
return uniqueStrings([
|
|
216
|
+
'runtime-order-loop-iteration-merge-requires-loop-header-evidence',
|
|
217
|
+
['for-of', 'for-await-of', 'for-in'].includes(record?.loopKind)
|
|
218
|
+
? 'runtime-order-loop-iterator-merge-requires-iteration-source-evidence'
|
|
219
|
+
: undefined,
|
|
220
|
+
record?.loopKind === 'for' ? 'runtime-order-for-loop-merge-requires-init-condition-update-evidence' : undefined,
|
|
221
|
+
record?.loopKind === 'while' || record?.loopKind === 'do'
|
|
222
|
+
? 'runtime-order-while-loop-merge-requires-condition-evidence'
|
|
223
|
+
: undefined
|
|
224
|
+
]);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function controlTransferContextReasonCodes(record) {
|
|
228
|
+
return uniqueStrings([
|
|
229
|
+
'runtime-order-control-transfer-merge-requires-break-continue-evidence',
|
|
230
|
+
record?.transferKind === 'break' ? 'runtime-order-break-merge-requires-loop-switch-exit-evidence' : undefined,
|
|
231
|
+
record?.transferKind === 'continue' ? 'runtime-order-continue-merge-requires-next-iteration-evidence' : undefined,
|
|
232
|
+
record?.labelText ? 'runtime-order-labeled-transfer-merge-requires-label-target-evidence' : undefined,
|
|
233
|
+
record?.labelText ? (record?.labelTargetKind ? 'runtime-order-labeled-transfer-target-lexical-evidence' : 'runtime-order-labeled-transfer-target-unresolved-review') : undefined
|
|
234
|
+
]);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function reachabilityContextReasonCodes(record) {
|
|
238
|
+
const kind = record?.completionKind;
|
|
239
|
+
return uniqueStrings(['runtime-order-unreachable-region-merge-requires-reachability-evidence', 'runtime-order-reachability-merge-requires-completion-path-evidence', kind === 'return' ? 'runtime-order-return-reachability-merge-requires-completion-value-evidence' : undefined, kind === 'throw' ? 'runtime-order-throw-reachability-merge-requires-exception-path-evidence' : undefined, kind === 'break' ? 'runtime-order-break-reachability-merge-requires-loop-switch-exit-evidence' : undefined, kind === 'continue' ? 'runtime-order-continue-reachability-merge-requires-next-iteration-evidence' : undefined]);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function switchDispatchContextReasonCodes(record) {
|
|
243
|
+
return uniqueStrings([
|
|
244
|
+
'runtime-order-switch-dispatch-merge-requires-case-selection-evidence',
|
|
245
|
+
record?.caseKind === 'case' ? 'runtime-order-switch-case-merge-requires-case-arm-evidence' : undefined,
|
|
246
|
+
record?.caseKind === 'default' ? 'runtime-order-switch-default-merge-requires-default-arm-evidence' : undefined,
|
|
247
|
+
record?.caseKind ? undefined : 'runtime-order-switch-merge-requires-discriminant-evidence',
|
|
248
|
+
record?.fallthroughFromPrevious ? 'runtime-order-switch-fallthrough-merge-requires-prior-case-completion-evidence' : undefined
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function tryCatchContextReasonCodes(record) {
|
|
253
|
+
return uniqueStrings([
|
|
254
|
+
'runtime-order-try-catch-merge-requires-throw-catch-order-evidence',
|
|
255
|
+
record?.kind === 'catch-handler' ? 'runtime-order-catch-merge-requires-handler-order-evidence' : undefined,
|
|
256
|
+
record?.kind === 'try-catch' ? 'runtime-order-try-catch-merge-requires-handler-selection-evidence' : undefined
|
|
257
|
+
]);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function tryFinallyContextReasonCodes(record) {
|
|
261
|
+
return uniqueStrings([
|
|
262
|
+
'runtime-order-try-finally-merge-requires-completion-order-evidence',
|
|
263
|
+
record?.kind === 'finalizer' ? 'runtime-order-finally-merge-requires-finalizer-order-evidence' : undefined,
|
|
264
|
+
record?.kind === 'try-finally' && record?.enclosingLoop ? 'runtime-order-try-finally-loop-merge-requires-iteration-finalizer-order-evidence' : undefined
|
|
265
|
+
]);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function resourceManagementContextReasonCodes(record) { return uniqueStrings(['runtime-order-resource-management-merge-requires-disposal-order-evidence', record?.awaitUsing || record?.declarationKind === 'await-using' ? 'runtime-order-await-using-merge-requires-async-disposal-evidence' : 'runtime-order-using-merge-requires-dispose-evidence', record?.disposalEffectEquivalenceClaim === false ? 'runtime-order-resource-management-disposal-effect-equivalence-not-proven' : undefined]); }
|
|
269
|
+
|
|
270
|
+
function stableCalleeCallsite(input) {
|
|
271
|
+
if (runtimeRegionKind(input.region, input.baseSymbol) !== 'call') return false;
|
|
272
|
+
const baseName = input.baseSymbol?.name ?? input.region?.symbolName;
|
|
273
|
+
if (!baseName) return false;
|
|
274
|
+
return [input.workerSymbol?.name, input.headSymbol?.name].every((name) => name === baseName);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function isRuntimeOrderSensitiveRegion(region, symbol) { return runtimeOrderSensitiveRegionKinds.has(runtimeRegionKind(region, symbol)); }
|
|
278
|
+
|
|
279
|
+
function runtimeRegionKind(region, symbol) { return String(region?.regionKind ?? symbol?.ownershipRegionKind ?? ''); }
|
|
280
|
+
|
|
281
|
+
function regionFactKinds(region) {
|
|
282
|
+
const regionKind = runtimeRegionKind(region);
|
|
283
|
+
const signature = factSignatureFromSymbolName(region?.symbolName, regionKind);
|
|
284
|
+
return uniqueStrings([
|
|
285
|
+
...array(region?.metadata?.factKinds),
|
|
286
|
+
...array(region?.metadata?.factKind),
|
|
287
|
+
...array(region?.runtimeKinds),
|
|
288
|
+
...array(region?.runtimeKind),
|
|
289
|
+
...array(signature)
|
|
290
|
+
].flatMap((kind) => String(kind ?? '').split('+')).filter(Boolean));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function factSignatureFromSymbolName(symbolName, regionKind) {
|
|
294
|
+
const marker = `:${regionKind}:`;
|
|
295
|
+
const text = String(symbolName ?? '');
|
|
296
|
+
const markerIndex = text.indexOf(marker);
|
|
297
|
+
if (markerIndex < 0) return undefined;
|
|
298
|
+
const signature = text.slice(markerIndex + marker.length).replace(/#\d+$/, '');
|
|
299
|
+
return signature || undefined;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function runtimeRegionOwner(region) {
|
|
303
|
+
const subjectName = region?.metadata?.subjectName;
|
|
304
|
+
if (subjectName) return String(subjectName);
|
|
305
|
+
const symbolName = String(region?.symbolName ?? '');
|
|
306
|
+
const kind = runtimeRegionKind(region);
|
|
307
|
+
const marker = `:${kind}:`;
|
|
308
|
+
const markerIndex = symbolName.indexOf(marker);
|
|
309
|
+
if (markerIndex >= 0) return symbolName.slice(0, markerIndex);
|
|
310
|
+
if (kind === 'call' && symbolName.includes('->')) return symbolName.split('->')[0];
|
|
311
|
+
return '';
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function sameRegionSourcePath(left, right) {
|
|
315
|
+
const leftPath = left?.sourcePath ?? left?.sourceSpan?.path;
|
|
316
|
+
const rightPath = right?.sourcePath ?? right?.sourceSpan?.path;
|
|
317
|
+
return Boolean(leftPath && rightPath && leftPath === rightPath);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function array(value) { return value === undefined || value === null ? [] : Array.isArray(value) ? value : [value]; }
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { uniqueStrings } from '../../native-import-utils.js';
|
|
2
|
+
import { jsTsFunctionParameterBindingPatternReasonCodes } from '../../js-ts-safe-merge-binding-patterns.js';
|
|
3
|
+
import { attributeMap, parseJsxTags, sameAttrText } from '../../js-ts-safe-merge-jsx-attribute-parser.js';
|
|
4
|
+
import { nativeImportSourceText } from './nativeImportSourceText.js';
|
|
5
|
+
import { runtimeOrderEvidenceBinding } from './runtimeOrderEvidenceBinding.js';
|
|
2
6
|
import { resolveSemanticLineage } from './semanticLineageResolutionRecords.js';
|
|
7
|
+
import {
|
|
8
|
+
orderSensitiveHeadPeerConflict,
|
|
9
|
+
runtimeOrderReasonCodes,
|
|
10
|
+
templateLiteralBlockReasonCodes
|
|
11
|
+
} from './semanticEditRuntimeOrderReasons.js';
|
|
12
|
+
import { typeSyntaxEditClassification, typeSyntaxEditReasonCodes } from './semanticEditTypeSyntaxReasons.js';
|
|
13
|
+
import { sourceTextForSpan } from './sourceTextForSpan.js';
|
|
14
|
+
import { callsiteArgumentAppendMergeClassification } from './semanticEditCallsiteArgumentMerge.js';
|
|
3
15
|
|
|
4
16
|
export const SemanticEditScriptAdmissionStatuses = Object.freeze([
|
|
5
17
|
'auto-merge-candidate',
|
|
@@ -13,21 +25,41 @@ export const SemanticEditScriptAdmissionStatuses = Object.freeze([
|
|
|
13
25
|
export function classifySemanticEdit(input) {
|
|
14
26
|
if (!input.context.head) return editStatus('candidate', 'needs-review', 0.66, ['head-source-not-provided']);
|
|
15
27
|
if (!input.anchorKey) return editStatus('blocked', 'blocked', 0, ['missing-semantic-anchor']);
|
|
28
|
+
const templateReasonCodes = templateLiteralBlockReasonCodes(input);
|
|
29
|
+
if (templateReasonCodes.length) return editStatus('blocked', 'blocked', 0.1, templateReasonCodes);
|
|
16
30
|
if (input.context.workerChangeSet.beforeHash &&
|
|
17
31
|
input.context.headChangeSet?.afterHash === input.context.workerChangeSet.beforeHash &&
|
|
18
32
|
sameSourcePath(input.context.base, input.context.head)) {
|
|
19
|
-
|
|
33
|
+
const typeSyntax = typeSyntaxEditClassification(input);
|
|
34
|
+
if (typeSyntax?.status === 'blocked') return editStatus('blocked', 'blocked', 0.12, typeSyntax.reasonCodes, undefined, typeSyntax.evidenceIds);
|
|
35
|
+
return editStatus('portable', 'ready', typeSyntax ? 0.82 : 0.95,
|
|
36
|
+
uniqueStrings(['head-source-matches-base', ...(typeSyntax?.reasonCodes ?? [])]), undefined, typeSyntax?.evidenceIds ?? []);
|
|
20
37
|
}
|
|
21
38
|
if (input.region.changeKind === 'added') return classifyAddedRegion(input);
|
|
22
39
|
if (!input.baseSymbol) return classifyMissingBaseAnchor(input);
|
|
23
40
|
if (!input.headSymbol) return classifyMissingHeadAnchor(input);
|
|
24
41
|
if (input.headSymbol.spanHash && input.baseSymbol.spanHash && input.headSymbol.spanHash === input.baseSymbol.spanHash) {
|
|
25
|
-
|
|
42
|
+
const jsxAttributeReasonCodes = jsxAttributeChangeReasonCodes(input);
|
|
43
|
+
if (jsxAttributeReasonCodes.length) return editStatus('conflict', 'blocked', 0.2, jsxAttributeReasonCodes);
|
|
44
|
+
const typeSyntax = typeSyntaxEditClassification(input);
|
|
45
|
+
if (typeSyntax?.status === 'blocked') return editStatus('blocked', 'blocked', 0.12, typeSyntax.reasonCodes, undefined, typeSyntax.evidenceIds);
|
|
46
|
+
const peerConflict = orderSensitiveHeadPeerConflict(input);
|
|
47
|
+
if (peerConflict) return editStatus('conflict', 'blocked', 0.2, peerConflict.reasonCodes, undefined, peerConflict.evidenceIds);
|
|
48
|
+
const runtimeOrderEvidence = runtimeOrderEvidenceBinding(input);
|
|
49
|
+
return editStatus('portable', 'ready', typeSyntax ? 0.82 : 0.9,
|
|
50
|
+
uniqueStrings(['head-anchor-matches-base', ...(typeSyntax?.reasonCodes ?? [])]), undefined,
|
|
51
|
+
uniqueStrings([...(typeSyntax?.evidenceIds ?? []), ...runtimeOrderEvidence.evidenceIds]));
|
|
26
52
|
}
|
|
27
53
|
if (input.headSymbol.spanHash && input.workerSymbol?.spanHash && input.headSymbol.spanHash === input.workerSymbol.spanHash) {
|
|
28
54
|
return editStatus('already-applied', 'ready', 0.92, ['head-anchor-matches-worker']);
|
|
29
55
|
}
|
|
30
|
-
|
|
56
|
+
const callsiteArgumentAppend = callsiteArgumentAppendMergeClassification(input);
|
|
57
|
+
if (callsiteArgumentAppend) {
|
|
58
|
+
return editStatus('portable', 'ready', 0.78, callsiteArgumentAppend.reasonCodes, undefined, callsiteArgumentAppend.evidenceIds, {
|
|
59
|
+
sourceBackprojection: callsiteArgumentAppend.sourceBackprojection
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return editStatus('conflict', 'blocked', 0.2, headAnchorChangedSinceBaseReasonCodes(input));
|
|
31
63
|
}
|
|
32
64
|
|
|
33
65
|
export function summarizeSemanticEditOperations(operations) {
|
|
@@ -73,6 +105,8 @@ export function semanticEditAdmission(input) {
|
|
|
73
105
|
}
|
|
74
106
|
|
|
75
107
|
function classifyAddedRegion(input) {
|
|
108
|
+
const peerConflict = orderSensitiveHeadPeerConflict(input);
|
|
109
|
+
if (peerConflict) return editStatus('conflict', 'blocked', 0.2, peerConflict.reasonCodes, undefined, peerConflict.evidenceIds);
|
|
76
110
|
if (!input.headSymbol) return editStatus('portable', 'ready', 0.86, ['added-anchor-absent-from-head']);
|
|
77
111
|
if (input.headSymbol.spanHash && input.workerSymbol?.spanHash && input.headSymbol.spanHash === input.workerSymbol.spanHash) {
|
|
78
112
|
return editStatus('already-applied', 'ready', 0.88, ['added-anchor-already-present-in-head']);
|
|
@@ -112,8 +146,59 @@ function classifyMissingHeadAnchor(input) {
|
|
|
112
146
|
return editStatus('stale', 'needs-review', 0.25, ['head-anchor-missing']);
|
|
113
147
|
}
|
|
114
148
|
|
|
115
|
-
function
|
|
116
|
-
return
|
|
149
|
+
function headAnchorChangedSinceBaseReasonCodes(input) {
|
|
150
|
+
return uniqueStrings([
|
|
151
|
+
'head-anchor-changed-since-base',
|
|
152
|
+
...typeSyntaxEditReasonCodes(input),
|
|
153
|
+
...functionParameterBindingPatternReasonCodes(input),
|
|
154
|
+
...runtimeOrderReasonCodes(input)
|
|
155
|
+
]);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function jsxAttributeChangeReasonCodes(input) {
|
|
159
|
+
if (input.region?.regionKind !== 'controlFlow') return [];
|
|
160
|
+
const baseText = symbolSourceText(input.context.base, input.baseSymbol, input.region);
|
|
161
|
+
const workerText = symbolSourceText(input.context.worker, input.workerSymbol, input.region);
|
|
162
|
+
if (!jsxAttributeTextChanged(baseText, workerText)) return [];
|
|
163
|
+
return uniqueStrings([
|
|
164
|
+
'runtime-order-sensitive-merge-requires-explicit-evidence',
|
|
165
|
+
'jsx-attribute-merge-requires-jsx-attribute-evidence',
|
|
166
|
+
...runtimeOrderReasonCodes(input)
|
|
167
|
+
]);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function jsxAttributeTextChanged(baseText, workerText) {
|
|
171
|
+
if (typeof baseText !== 'string' || typeof workerText !== 'string') return false;
|
|
172
|
+
const baseTags = parseJsxTags(baseText);
|
|
173
|
+
const workerTags = parseJsxTags(workerText);
|
|
174
|
+
if (baseTags.reasonCodes.length || workerTags.reasonCodes.length) return false;
|
|
175
|
+
for (const baseTag of baseTags.tags) {
|
|
176
|
+
const workerTag = workerTags.byKey.get(baseTag.key);
|
|
177
|
+
if (!workerTag || workerTag.tagName !== baseTag.tagName) continue;
|
|
178
|
+
const baseAttrs = attributeMap(baseTag);
|
|
179
|
+
const workerAttrs = attributeMap(workerTag);
|
|
180
|
+
if (baseAttrs.reasonCodes.length || workerAttrs.reasonCodes.length) continue;
|
|
181
|
+
for (const baseAttr of baseAttrs.byName.values()) {
|
|
182
|
+
const workerAttr = workerAttrs.byName.get(baseAttr.name);
|
|
183
|
+
if (workerAttr && !sameAttrText(baseAttr, workerAttr)) return true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function functionParameterBindingPatternReasonCodes(input) {
|
|
190
|
+
const baseText = symbolSourceText(input.context.base, input.baseSymbol, input.region);
|
|
191
|
+
const workerText = symbolSourceText(input.context.worker, input.workerSymbol, input.region);
|
|
192
|
+
return jsTsFunctionParameterBindingPatternReasonCodes(baseText, workerText);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function symbolSourceText(imported, symbol, region) {
|
|
196
|
+
const span = symbol?.sourceSpan ?? region?.metadata?.changedRegionProjection?.before?.sourceSpan ?? region?.sourceSpan;
|
|
197
|
+
return sourceTextForSpan(nativeImportSourceText(imported), span);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function editStatus(status, readiness, confidence, reasonCodes, reanchor, evidenceIds = [], metadata = {}) {
|
|
201
|
+
return { status, readiness, confidence, reasonCodes, reanchor, evidenceIds, ...metadata };
|
|
117
202
|
}
|
|
118
203
|
|
|
119
204
|
function reanchorRecord(fromAnchorKey, target, resolved) {
|
|
@@ -16,6 +16,7 @@ import { semanticEditInsertionAnchor } from './semanticEditInsertionAnchors.js';
|
|
|
16
16
|
import { markCoveredSemanticEditOperations } from './semanticEditOperationCoverage.js';
|
|
17
17
|
import { sourceTextForSpan } from './sourceTextForSpan.js';
|
|
18
18
|
import { semanticEditIdentityFields, semanticEditOperationContentHash } from './semanticEditIdentityRecords.js';
|
|
19
|
+
import { semanticStructuralDiff, semanticStructuralEdit } from './semanticStructuralDiffRecords.js';
|
|
19
20
|
|
|
20
21
|
export { SemanticEditScriptAdmissionStatuses };
|
|
21
22
|
|
|
@@ -59,7 +60,8 @@ export function createSemanticEditScript(input = {}, options = {}) {
|
|
|
59
60
|
);
|
|
60
61
|
const summary = summarizeSemanticEditOperations(operations);
|
|
61
62
|
const admission = semanticEditAdmission({ operations, summary, head, workerChangeSet, headChangeSet, input });
|
|
62
|
-
const
|
|
63
|
+
const structuralDiff = semanticStructuralDiff({ input, language, sourcePath, workerChangeSet, headChangeSet, operations });
|
|
64
|
+
const evidence = semanticEditEvidence({ input, language, sourcePath, workerChangeSet, headChangeSet, headLineage, summary, admission, structuralDiff });
|
|
63
65
|
const core = {
|
|
64
66
|
kind: 'frontier.lang.semanticEditScript',
|
|
65
67
|
version: 1,
|
|
@@ -73,12 +75,14 @@ export function createSemanticEditScript(input = {}, options = {}) {
|
|
|
73
75
|
headChangeSetId: headChangeSet?.id,
|
|
74
76
|
lineageInferenceId: headLineage?.id,
|
|
75
77
|
operations,
|
|
76
|
-
summary,
|
|
78
|
+
summary: { ...summary, structural: structuralDiff.summary },
|
|
79
|
+
structuralDiff,
|
|
77
80
|
admission,
|
|
78
81
|
evidence,
|
|
79
82
|
metadata: compactRecord({
|
|
80
83
|
autoMergeClaim: false,
|
|
81
84
|
semanticEquivalenceClaim: false,
|
|
85
|
+
structuralDiffStatus: structuralDiff.admission.status,
|
|
82
86
|
workerReadiness: workerChangeSet.readiness,
|
|
83
87
|
headReadiness: headChangeSet?.readiness,
|
|
84
88
|
workerReasons: workerChangeSet.reasons,
|
|
@@ -134,11 +138,12 @@ function symbolsByAnchor(imported) {
|
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
function semanticEditOperation(region, index, context, input) {
|
|
141
|
+
const operationId = `semantic_edit_op_${idFragment([index, region.key ?? region.conflictKey ?? region.id, input.id ?? 'semantic_edit'].join(':'))}`;
|
|
137
142
|
const anchorKey = region.key ?? region.conflictKey ?? region.id;
|
|
138
143
|
const baseSymbol = context.baseSymbols.get(anchorKey);
|
|
139
144
|
const workerSymbol = context.workerSymbols.get(anchorKey);
|
|
140
145
|
const directHeadSymbol = context.headSymbols.get(anchorKey);
|
|
141
|
-
const classification = classifySemanticEdit({ region, anchorKey, baseSymbol, workerSymbol, headSymbol: directHeadSymbol, context });
|
|
146
|
+
const classification = classifySemanticEdit({ region, anchorKey, baseSymbol, workerSymbol, headSymbol: directHeadSymbol, context, scriptInput: input });
|
|
142
147
|
const headSymbol = directHeadSymbol ?? reanchoredHeadSymbol(context, classification);
|
|
143
148
|
const kind = semanticEditOperationKind(region);
|
|
144
149
|
const baseText = spanText(context.base, baseSymbol?.sourceSpan ?? region.metadata?.changedRegionProjection?.before?.sourceSpan ?? region.sourceSpan);
|
|
@@ -172,8 +177,24 @@ function semanticEditOperation(region, index, context, input) {
|
|
|
172
177
|
});
|
|
173
178
|
const identityRecord = semanticEditIdentityRecord({ kind, region, anchor });
|
|
174
179
|
const identity = semanticEditIdentityFields(identityRecord);
|
|
180
|
+
const structuralEdit = semanticStructuralEdit({
|
|
181
|
+
operationId,
|
|
182
|
+
kind,
|
|
183
|
+
changeKind: region.changeKind,
|
|
184
|
+
anchor,
|
|
185
|
+
spans: {
|
|
186
|
+
base: baseSymbol?.sourceSpan ?? region.metadata?.changedRegionProjection?.before?.sourceSpan,
|
|
187
|
+
worker: workerSymbol?.sourceSpan ?? region.metadata?.changedRegionProjection?.after?.sourceSpan ?? region.sourceSpan,
|
|
188
|
+
head: headSymbol?.sourceSpan
|
|
189
|
+
},
|
|
190
|
+
hashes,
|
|
191
|
+
status: classification.status,
|
|
192
|
+
confidence: classification.confidence,
|
|
193
|
+
reasonCodes: classification.reasonCodes,
|
|
194
|
+
reanchor: classification.reanchor
|
|
195
|
+
});
|
|
175
196
|
return compactRecord({
|
|
176
|
-
id:
|
|
197
|
+
id: operationId,
|
|
177
198
|
kind,
|
|
178
199
|
changeKind: region.changeKind,
|
|
179
200
|
anchor,
|
|
@@ -187,6 +208,7 @@ function semanticEditOperation(region, index, context, input) {
|
|
|
187
208
|
hashes,
|
|
188
209
|
status: classification.status,
|
|
189
210
|
operationContentHash: semanticEditOperationContentHash({ ...identityRecord, ...identity, ...hashes, status: classification.status }),
|
|
211
|
+
structuralEdit,
|
|
190
212
|
reanchor: classification.reanchor,
|
|
191
213
|
readiness: classification.readiness,
|
|
192
214
|
confidence: classification.confidence,
|
|
@@ -194,7 +216,8 @@ function semanticEditOperation(region, index, context, input) {
|
|
|
194
216
|
evidenceIds: classification.evidenceIds,
|
|
195
217
|
metadata: {
|
|
196
218
|
autoMergeClaim: false,
|
|
197
|
-
semanticEquivalenceClaim: false
|
|
219
|
+
semanticEquivalenceClaim: false,
|
|
220
|
+
sourceBackprojection: classification.sourceBackprojection
|
|
198
221
|
}
|
|
199
222
|
});
|
|
200
223
|
}
|
|
@@ -253,6 +276,20 @@ function semanticEditEvidence(input) {
|
|
|
253
276
|
autoMergeClaim: false,
|
|
254
277
|
semanticEquivalenceClaim: false
|
|
255
278
|
}
|
|
279
|
+
}, {
|
|
280
|
+
id: input.input.structuralEvidenceId ?? `evidence_${idFragment(input.input.id ?? input.sourcePath ?? 'semantic_edit')}_structural_diff`,
|
|
281
|
+
kind: 'semantic-structural-diff',
|
|
282
|
+
status: 'needs-review',
|
|
283
|
+
path: input.sourcePath,
|
|
284
|
+
summary: `Recorded ${input.structuralDiff.summary.edits} runtime-neutral structural edit(s); replay diagnostics remain required for safety.`,
|
|
285
|
+
metadata: {
|
|
286
|
+
structuralDiffId: input.structuralDiff.id,
|
|
287
|
+
structuralDiffHash: input.structuralDiff.hash,
|
|
288
|
+
summary: input.structuralDiff.summary,
|
|
289
|
+
admissionStatus: input.structuralDiff.admission.status,
|
|
290
|
+
autoMergeClaim: false,
|
|
291
|
+
semanticEquivalenceClaim: false
|
|
292
|
+
}
|
|
256
293
|
}];
|
|
257
294
|
}
|
|
258
295
|
|