@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,317 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { compactRecord, createMergeContext, sameStatementText, uniqueStrings } from './js-ts-safe-merge-context.js';
|
|
3
|
+
import { scanJsTsTopLevelLedger } from './js-ts-safe-merge-ledger.js';
|
|
4
|
+
import { hashText } from './js-ts-safe-project-merge-core.js';
|
|
5
|
+
import {
|
|
6
|
+
entriesByKey,
|
|
7
|
+
escapeRegExp,
|
|
8
|
+
membersByName,
|
|
9
|
+
normalizeTypeText,
|
|
10
|
+
rejected,
|
|
11
|
+
renameTypesEqual,
|
|
12
|
+
safeId,
|
|
13
|
+
stalePropertyAccessReasons,
|
|
14
|
+
typedPropertyRenameRebaseEvidence,
|
|
15
|
+
unsafePropertyAccessReasons
|
|
16
|
+
} from './js-ts-safe-project-merge-typed-property-rename-rebase-utils.js';
|
|
17
|
+
|
|
18
|
+
const positiveReasonCode = 'typed-property-rename-rebase-admitted';
|
|
19
|
+
const diagnosticsRequiredReasonCode = 'typed-property-rename-rebase-requires-output-diagnostics';
|
|
20
|
+
const gateId = 'project-typed-property-rename-rebase';
|
|
21
|
+
|
|
22
|
+
function maybeMergeTypedPropertyRenameRebaseFile(file, context, blockedResult, input = {}) {
|
|
23
|
+
const analysis = analyzeTypedPropertyRenameRebase(file, input);
|
|
24
|
+
if (!analysis.ok) return undefined;
|
|
25
|
+
const outputSourceText = analysis.outputSourceText;
|
|
26
|
+
const evidence = typedPropertyRenameRebaseEvidence(file, analysis);
|
|
27
|
+
const reasonCodes = uniqueStrings([positiveReasonCode, diagnosticsRequiredReasonCode, ...analysis.reasonCodes]);
|
|
28
|
+
const core = {
|
|
29
|
+
kind: 'frontier.lang.jsTsProjectSafeMergeFile',
|
|
30
|
+
version: 1,
|
|
31
|
+
sourcePath: file.sourcePath,
|
|
32
|
+
language: context.language,
|
|
33
|
+
status: 'merged',
|
|
34
|
+
operation: 'merged-typed-property-rename-rebase',
|
|
35
|
+
outputSourceText,
|
|
36
|
+
outputHash: hashText(outputSourceText),
|
|
37
|
+
baseHash: hashText(file.baseSourceText),
|
|
38
|
+
workerHash: hashText(file.workerSourceText),
|
|
39
|
+
headHash: hashText(file.headSourceText),
|
|
40
|
+
result: blockedResult,
|
|
41
|
+
semanticArtifacts: blockedResult?.semanticArtifacts,
|
|
42
|
+
conflicts: [],
|
|
43
|
+
admission: {
|
|
44
|
+
status: 'auto-merge-candidate',
|
|
45
|
+
action: 'apply-typed-property-rename-rebase',
|
|
46
|
+
reviewRequired: false,
|
|
47
|
+
autoApplyCandidate: true,
|
|
48
|
+
autoMergeClaim: false,
|
|
49
|
+
semanticEquivalenceClaim: false,
|
|
50
|
+
reasonCodes,
|
|
51
|
+
conflictKeys: [`typed-property-rename-rebase#${file.sourcePath}#${analysis.ownerName}#${analysis.fromName}#${analysis.toName}`],
|
|
52
|
+
evidenceIds: [evidence.id]
|
|
53
|
+
},
|
|
54
|
+
summary: {
|
|
55
|
+
conflicts: 0,
|
|
56
|
+
typedPropertyRenameRebases: 1,
|
|
57
|
+
typedPropertyRenameRebaseAdmissionEvidence: [evidence],
|
|
58
|
+
changedExistingDeclarations: blockedResult?.summary?.changedExistingDeclarations,
|
|
59
|
+
semanticEditOperations: blockedResult?.summary?.semanticEditOperations,
|
|
60
|
+
semanticEditReplayStatus: blockedResult?.summary?.semanticEditReplayStatus
|
|
61
|
+
},
|
|
62
|
+
metadata: {
|
|
63
|
+
typedPropertyRenameRebaseAdmissions: [evidence],
|
|
64
|
+
typedPropertyRenameRebase: compactRecord({
|
|
65
|
+
ownerName: analysis.ownerName,
|
|
66
|
+
ownerKind: analysis.ownerKind,
|
|
67
|
+
fromName: analysis.fromName,
|
|
68
|
+
toName: analysis.toName,
|
|
69
|
+
typeText: analysis.typeText,
|
|
70
|
+
workerAddedMembers: analysis.workerAddedMembers.map((member) => member.name),
|
|
71
|
+
workerAddedDeclarations: analysis.workerAddedDeclarations.map((entry) => entry.names?.[0]).filter(Boolean),
|
|
72
|
+
rebasedDeclarations: analysis.rebasedDeclarations,
|
|
73
|
+
diagnosticsRequired: true,
|
|
74
|
+
autoMergeClaim: false,
|
|
75
|
+
semanticEquivalenceClaim: false
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
conflictKeys: [`source#${file.sourcePath}`]
|
|
79
|
+
};
|
|
80
|
+
return { ...core, hash: hashSemanticValue(core) };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function analyzeTypedPropertyRenameRebase(file, input = {}) {
|
|
84
|
+
const baseSourceText = file.baseSourceText;
|
|
85
|
+
const workerSourceText = file.workerSourceText ?? baseSourceText;
|
|
86
|
+
const headSourceText = file.headSourceText ?? baseSourceText;
|
|
87
|
+
if (!file.sourcePath || typeof baseSourceText !== 'string' || typeof workerSourceText !== 'string' || typeof headSourceText !== 'string') {
|
|
88
|
+
return rejected('typed-property-rename-rebase-missing-source-text');
|
|
89
|
+
}
|
|
90
|
+
const ledgers = projectLedgers(file, input, baseSourceText, workerSourceText, headSourceText);
|
|
91
|
+
if (!ledgers.ok) return rejected('typed-property-rename-rebase-ledger-unavailable', ledgers.reasonCodes);
|
|
92
|
+
const rename = findSinglePropertyRename(ledgers);
|
|
93
|
+
if (!rename.ok) return rename;
|
|
94
|
+
const assembled = assembleRebasedSource(ledgers, rename.value);
|
|
95
|
+
if (!assembled.ok) return assembled;
|
|
96
|
+
return {
|
|
97
|
+
ok: true,
|
|
98
|
+
reasonCodes: assembled.reasonCodes,
|
|
99
|
+
outputSourceText: assembled.outputSourceText,
|
|
100
|
+
...rename.value,
|
|
101
|
+
workerAddedDeclarations: assembled.workerAddedDeclarations,
|
|
102
|
+
rebasedDeclarations: assembled.rebasedDeclarations
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function projectLedgers(file, input, baseSourceText, workerSourceText, headSourceText) {
|
|
107
|
+
const context = createMergeContext({
|
|
108
|
+
id: `typed_property_rename_rebase_${safeId(file.sourcePath)}`,
|
|
109
|
+
sourcePath: file.sourcePath,
|
|
110
|
+
language: file.language ?? input.language ?? 'typescript'
|
|
111
|
+
});
|
|
112
|
+
const base = scanJsTsTopLevelLedger(baseSourceText, 'base', context);
|
|
113
|
+
const worker = scanJsTsTopLevelLedger(workerSourceText, 'worker', context);
|
|
114
|
+
const head = scanJsTsTopLevelLedger(headSourceText, 'head', context);
|
|
115
|
+
return context.conflicts.length
|
|
116
|
+
? { ok: false, reasonCodes: context.conflicts.map((conflict) => conflict.code) }
|
|
117
|
+
: { ok: true, base, worker, head };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function findSinglePropertyRename(ledgers) {
|
|
121
|
+
const baseObjects = objectDeclarationsByName(ledgers.base);
|
|
122
|
+
const workerObjects = objectDeclarationsByName(ledgers.worker);
|
|
123
|
+
const headObjects = objectDeclarationsByName(ledgers.head);
|
|
124
|
+
const candidates = [];
|
|
125
|
+
for (const [name, baseObject] of baseObjects) {
|
|
126
|
+
const workerObject = workerObjects.get(name);
|
|
127
|
+
const headObject = headObjects.get(name);
|
|
128
|
+
if (!workerObject || !headObject) continue;
|
|
129
|
+
const candidate = propertyRenameCandidate(name, baseObject, workerObject, headObject);
|
|
130
|
+
if (candidate.ok) candidates.push(candidate.value);
|
|
131
|
+
else if (candidate.reasonCodes.some((reason) => reason !== 'typed-property-rename-rebase-no-rename')) return candidate;
|
|
132
|
+
}
|
|
133
|
+
if (candidates.length !== 1) return rejected(candidates.length ? 'typed-property-rename-rebase-ambiguous' : 'typed-property-rename-rebase-no-rename');
|
|
134
|
+
return { ok: true, value: candidates[0] };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function propertyRenameCandidate(ownerName, baseObject, workerObject, headObject) {
|
|
138
|
+
const baseMembers = membersByName(baseObject.members);
|
|
139
|
+
const workerMembers = membersByName(workerObject.members);
|
|
140
|
+
const headMembers = membersByName(headObject.members);
|
|
141
|
+
const removedFromHead = [...baseMembers.keys()].filter((name) => !headMembers.has(name));
|
|
142
|
+
const addedToHead = [...headMembers.keys()].filter((name) => !baseMembers.has(name));
|
|
143
|
+
if (removedFromHead.length === 0 && addedToHead.length === 0) return rejected('typed-property-rename-rebase-no-rename');
|
|
144
|
+
if (removedFromHead.length !== 1 || addedToHead.length !== 1) return rejected('typed-property-rename-rebase-not-single-property');
|
|
145
|
+
const fromName = removedFromHead[0];
|
|
146
|
+
const toName = addedToHead[0];
|
|
147
|
+
const baseMember = baseMembers.get(fromName);
|
|
148
|
+
const headMember = headMembers.get(toName);
|
|
149
|
+
if (!workerMembers.has(fromName) || workerMembers.has(toName)) return rejected('typed-property-rename-rebase-worker-shape-changed');
|
|
150
|
+
if (!renameTypesEqual(baseMember, headMember)) return rejected('typed-property-rename-rebase-type-changed');
|
|
151
|
+
const stableReasons = stableMemberReasons(baseMembers, workerMembers, headMembers, fromName, toName);
|
|
152
|
+
if (stableReasons.length) return rejected(stableReasons[0], stableReasons);
|
|
153
|
+
const workerAddedMembers = workerObject.members.filter((member) => !baseMembers.has(member.name));
|
|
154
|
+
const outputObjectText = renderObjectDeclaration(headObject, workerAddedMembers);
|
|
155
|
+
return {
|
|
156
|
+
ok: true,
|
|
157
|
+
value: {
|
|
158
|
+
ownerName,
|
|
159
|
+
ownerKind: baseObject.kind,
|
|
160
|
+
fromName,
|
|
161
|
+
toName,
|
|
162
|
+
typeText: normalizeTypeText(baseMember.typeText),
|
|
163
|
+
baseObject,
|
|
164
|
+
workerObject,
|
|
165
|
+
headObject,
|
|
166
|
+
workerAddedMembers,
|
|
167
|
+
outputObjectText
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function assembleRebasedSource(ledgers, rename) {
|
|
173
|
+
const baseByKey = entriesByKey(ledgers.base.entries);
|
|
174
|
+
const headByKey = entriesByKey(ledgers.head.entries);
|
|
175
|
+
const outputEntries = [];
|
|
176
|
+
const workerAddedDeclarations = [];
|
|
177
|
+
const rebasedDeclarations = [];
|
|
178
|
+
const reasonCodes = [];
|
|
179
|
+
for (const workerEntry of ledgers.worker.entries) {
|
|
180
|
+
if (isTargetObjectEntry(workerEntry, rename)) {
|
|
181
|
+
outputEntries.push(rename.outputObjectText);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const baseEntry = baseByKey.get(workerEntry.key);
|
|
185
|
+
const headEntry = headByKey.get(workerEntry.key);
|
|
186
|
+
if (!baseEntry) {
|
|
187
|
+
const added = rebaseWorkerEntry(workerEntry, rename);
|
|
188
|
+
if (!added.ok) return added;
|
|
189
|
+
workerAddedDeclarations.push(workerEntry);
|
|
190
|
+
rebasedDeclarations.push(...added.rebasedDeclarations);
|
|
191
|
+
outputEntries.push(added.text);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (!headEntry) return rejected('typed-property-rename-rebase-head-removed-declaration');
|
|
195
|
+
const merged = mergeExistingEntry(baseEntry, workerEntry, headEntry, rename);
|
|
196
|
+
if (!merged.ok) return merged;
|
|
197
|
+
rebasedDeclarations.push(...merged.rebasedDeclarations);
|
|
198
|
+
outputEntries.push(merged.text);
|
|
199
|
+
}
|
|
200
|
+
for (const headEntry of ledgers.head.entries) {
|
|
201
|
+
if (baseByKey.has(headEntry.key) || ledgers.worker.entries.some((entry) => entry.key === headEntry.key)) continue;
|
|
202
|
+
outputEntries.push(headEntry.text);
|
|
203
|
+
}
|
|
204
|
+
reasonCodes.push(`typed-property-rename-rebase-owner:${rename.ownerName}`);
|
|
205
|
+
return {
|
|
206
|
+
ok: true,
|
|
207
|
+
reasonCodes,
|
|
208
|
+
outputSourceText: `${outputEntries.join('\n')}\n`,
|
|
209
|
+
workerAddedDeclarations,
|
|
210
|
+
rebasedDeclarations: uniqueStrings(rebasedDeclarations)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function mergeExistingEntry(baseEntry, workerEntry, headEntry, rename) {
|
|
215
|
+
if (isTargetObjectEntry(baseEntry, rename)) return { ok: true, text: rename.outputObjectText, rebasedDeclarations: [] };
|
|
216
|
+
const headIsRenameOnly = sameStatementText(headEntry.text, rebasePropertyReads(baseEntry.text, rename));
|
|
217
|
+
if (sameStatementText(workerEntry.text, baseEntry.text)) return { ok: true, text: headEntry.text, rebasedDeclarations: [] };
|
|
218
|
+
if (sameStatementText(headEntry.text, baseEntry.text) || headIsRenameOnly) {
|
|
219
|
+
const rebased = rebaseWorkerEntry(workerEntry, rename);
|
|
220
|
+
if (!rebased.ok) return rebased;
|
|
221
|
+
return rebased;
|
|
222
|
+
}
|
|
223
|
+
return rejected('typed-property-rename-rebase-existing-declaration-conflict');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function rebaseWorkerEntry(entry, rename) {
|
|
227
|
+
const unsafe = unsafePropertyAccessReasons(entry.text, rename.fromName);
|
|
228
|
+
if (unsafe.length) return rejected(unsafe[0], unsafe);
|
|
229
|
+
const text = rebasePropertyReads(entry.text, rename);
|
|
230
|
+
const remains = stalePropertyAccessReasons(text, rename.fromName);
|
|
231
|
+
if (remains.length) return rejected(remains[0], remains);
|
|
232
|
+
return {
|
|
233
|
+
ok: true,
|
|
234
|
+
text,
|
|
235
|
+
rebasedDeclarations: sameStatementText(text, entry.text) ? [] : [entry.names?.[0] ?? entry.key]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function objectDeclarationsByName(ledger) {
|
|
240
|
+
const result = new Map();
|
|
241
|
+
for (const entry of ledger.entries) {
|
|
242
|
+
const info = entry.declarationInfo;
|
|
243
|
+
if (!info || !['interface', 'type'].includes(info.declarationKind) || info.names.length !== 1) continue;
|
|
244
|
+
const object = parseObjectDeclaration(entry);
|
|
245
|
+
if (object) result.set(info.names[0], object);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function parseObjectDeclaration(entry) {
|
|
251
|
+
const kind = entry.declarationInfo.declarationKind;
|
|
252
|
+
const text = entry.text;
|
|
253
|
+
const open = text.indexOf('{');
|
|
254
|
+
const close = text.lastIndexOf('}');
|
|
255
|
+
if (open < 0 || close <= open) return undefined;
|
|
256
|
+
if (kind === 'type' && !/=\s*\{/.test(text.slice(0, open + 1))) return undefined;
|
|
257
|
+
const body = text.slice(open + 1, close);
|
|
258
|
+
const members = parseObjectMembers(body);
|
|
259
|
+
if (!members.ok) return undefined;
|
|
260
|
+
return { entry, kind, name: entry.declarationInfo.names[0], text, open, close, body, members: members.members };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function parseObjectMembers(body) {
|
|
264
|
+
const members = [];
|
|
265
|
+
let offset = 0;
|
|
266
|
+
for (const line of body.split('\n')) {
|
|
267
|
+
const start = offset;
|
|
268
|
+
offset += line.length + 1;
|
|
269
|
+
if (!line.trim()) continue;
|
|
270
|
+
const match = line.match(/^(\s*)(?:readonly\s+)?([A-Za-z_$][\w$]*)(\?)?\s*:\s*([^;,]+)\s*[;,]?\s*$/);
|
|
271
|
+
if (!match) return { ok: false };
|
|
272
|
+
members.push({
|
|
273
|
+
name: match[2],
|
|
274
|
+
optional: Boolean(match[3]),
|
|
275
|
+
typeText: match[4].trim(),
|
|
276
|
+
text: line,
|
|
277
|
+
indent: match[1],
|
|
278
|
+
start,
|
|
279
|
+
end: start + line.length
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return { ok: true, members };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function renderObjectDeclaration(object, addedMembers) {
|
|
286
|
+
if (!addedMembers.length) return object.entry.text;
|
|
287
|
+
const insert = addedMembers.map((member) => member.text).join('\n');
|
|
288
|
+
const beforeClose = object.text.slice(0, object.close);
|
|
289
|
+
const afterClose = object.text.slice(object.close);
|
|
290
|
+
const needsNewline = beforeClose.endsWith('\n') ? '' : '\n';
|
|
291
|
+
return `${beforeClose}${needsNewline}${insert}\n${afterClose}`;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function stableMemberReasons(baseMembers, workerMembers, headMembers, fromName, toName) {
|
|
295
|
+
const reasons = [];
|
|
296
|
+
for (const [name, baseMember] of baseMembers) {
|
|
297
|
+
if (name === fromName) continue;
|
|
298
|
+
const workerMember = workerMembers.get(name);
|
|
299
|
+
const headMember = headMembers.get(name);
|
|
300
|
+
if (!workerMember || !headMember) reasons.push('typed-property-rename-rebase-stable-member-missing');
|
|
301
|
+
else if (!renameTypesEqual(baseMember, workerMember) || !renameTypesEqual(baseMember, headMember)) {
|
|
302
|
+
reasons.push('typed-property-rename-rebase-stable-member-changed');
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
for (const [name] of headMembers) {
|
|
306
|
+
if (!baseMembers.has(name) && name !== toName) reasons.push('typed-property-rename-rebase-head-added-extra-property');
|
|
307
|
+
}
|
|
308
|
+
return uniqueStrings(reasons);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function rebasePropertyReads(text, rename) {
|
|
312
|
+
const property = escapeRegExp(rename.fromName);
|
|
313
|
+
return String(text ?? '').replace(new RegExp(`(\\?\\.|\\.)${property}\\b`, 'g'), `$1${rename.toName}`);
|
|
314
|
+
}
|
|
315
|
+
function isTargetObjectEntry(entry, rename) { return entry.key === rename.baseObject.entry.key; }
|
|
316
|
+
|
|
317
|
+
export { maybeMergeTypedPropertyRenameRebaseFile };
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
2
|
+
import { maskNonCode } from './js-ts-semantic-scope-use-def-scan.js';
|
|
3
|
+
|
|
4
|
+
const DecoratorRuntimeExecutionRoute = Object.freeze({
|
|
5
|
+
routeId: 'prove-decorator-runtime-execution-equivalence',
|
|
6
|
+
routeLane: 'decorator-runtime-boundaries',
|
|
7
|
+
routeNext: 'supply-decorator-runtime-execution-proof',
|
|
8
|
+
failClosed: true,
|
|
9
|
+
blocksSemanticEquivalence: true
|
|
10
|
+
});
|
|
11
|
+
const GeneratorRuntimeProtocolRoute = Object.freeze({
|
|
12
|
+
routeId: 'prove-generator-runtime-protocol-equivalence',
|
|
13
|
+
routeLane: 'generator-runtime-boundaries',
|
|
14
|
+
routeNext: 'supply-generator-runtime-protocol-proof',
|
|
15
|
+
failClosed: true,
|
|
16
|
+
blocksSemanticEquivalence: true
|
|
17
|
+
});
|
|
18
|
+
const AsyncGeneratorRuntimeProtocolRoute = Object.freeze({
|
|
19
|
+
routeId: 'prove-async-generator-runtime-protocol-equivalence',
|
|
20
|
+
routeLane: 'generator-runtime-boundaries',
|
|
21
|
+
routeNext: 'supply-async-generator-runtime-protocol-proof',
|
|
22
|
+
failClosed: true,
|
|
23
|
+
blocksSemanticEquivalence: true
|
|
24
|
+
});
|
|
25
|
+
const ClassPrivateAccessorRuntimeRoute = Object.freeze({ routeId: 'prove-class-private-accessor-runtime-equivalence', routeLane: 'class-private-accessor-runtime-boundaries', routeNext: 'supply-class-private-accessor-runtime-proof', failClosed: true, blocksSemanticEquivalence: true });
|
|
26
|
+
|
|
27
|
+
const surfaceChecks = [
|
|
28
|
+
{ kind: 'explicit-resource-management', pattern: /\b(?:await\s+)?using\s+[A-Za-z_$][\w$]*\s*=/g },
|
|
29
|
+
{ kind: 'decorator', pattern: /^[ \t]*@[A-Za-z_$][\w$]*(?:[.(\s]|$)/gm, startOffset: (match) => match[0].indexOf('@') },
|
|
30
|
+
{ kind: 'accessor-field', pattern: /\baccessor\s+#?[A-Za-z_$][\w$]*/g },
|
|
31
|
+
{ kind: 'private-class-element', pattern: /#[A-Za-z_$][\w$]*/g },
|
|
32
|
+
{ kind: 'class-static-block', pattern: /\bstatic\s*\{/g },
|
|
33
|
+
{ kind: 'enum-declaration', pattern: /\b(?:const\s+)?enum\s+[A-Za-z_$][\w$]*\s*\{/g },
|
|
34
|
+
{ kind: 'namespace-declaration', pattern: /\b(?:namespace|module)\s+[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*\{/g },
|
|
35
|
+
{ kind: 'ambient-module-declaration', pattern: /\bdeclare\s+module\s+(?:(?:['"][^'"\n]+['"]\s*)|(?:[A-Za-z_$][\w$]*\s*))?\{/g },
|
|
36
|
+
{ kind: 'global-augmentation', pattern: /\bdeclare\s+global\s*\{/g },
|
|
37
|
+
{ kind: 'export-assignment', pattern: /\bexport\s*=\s*[A-Za-z_$][\w$]*/g },
|
|
38
|
+
{ kind: 'import-meta-expression', pattern: /\bimport\s*\.\s*meta\b/g },
|
|
39
|
+
{ kind: 'satisfies-expression', pattern: /(?:[A-Za-z_$][\w$.)\]]|\})\s+satisfies\b/g },
|
|
40
|
+
{ kind: 'as-const-assertion', pattern: /\bas\s+const\b/g },
|
|
41
|
+
{ kind: 'const-type-parameter', pattern: /<\s*const\s+[A-Za-z_$][\w$]*/g },
|
|
42
|
+
{ kind: 'async-generator-function', pattern: /\basync\s+function\s*\*\s*(?:[A-Za-z_$][\w$]*\s*)?\(/g },
|
|
43
|
+
{ kind: 'generator-function', pattern: /(?<!async\s)\bfunction\s*\*\s*(?:[A-Za-z_$][\w$]*\s*)?\(/g }
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const focusedSurfaceReviewEntries = [
|
|
47
|
+
['explicit-resource-management', 'explicit-resource-management-acquisition-disposal-order-evidence', 'control-flow-effect-graph', 'using and await using acquisition plus reverse lexical disposal-order evidence can bound ordering.', 'resource-management-disposal-effect-equivalence-not-claimed', 'Disposal side effects and executable effect equivalence remain unproved.', { routeId: 'prove-resource-management-disposal-effect-equivalence', routeLane: 'control-flow-effect-graph-runtime-resource-management', routeNext: 'supply-resource-management-disposal-proof', failClosed: true, blocksSemanticEquivalence: true }],
|
|
48
|
+
['decorator', 'typescript-decorator-static-metadata-evidence', 'type-public-api-graph', 'TypeScript compiler-backed decorator target and expression metadata can bound static shape.', 'decorator-execution-equivalence-not-claimed', 'Decorator execution, side effects, and runtime ordering remain unproved.', DecoratorRuntimeExecutionRoute],
|
|
49
|
+
['accessor-field', 'typescript-accessor-field-static-shape-evidence', 'type-public-api-graph', 'TypeScript compiler-backed accessor-field static shape records and proof hashes can bound public shape.', 'accessor-field-runtime-equivalence-not-claimed', 'Accessor initialization and getter/setter runtime behavior remain unproved.', ClassPrivateAccessorRuntimeRoute],
|
|
50
|
+
['private-class-element', 'typescript-private-class-member-static-shape-evidence', 'type-public-api-graph', 'TypeScript compiler-backed private class member static shape records and proof hashes can bound class shape.', 'private-class-member-runtime-equivalence-not-claimed', 'Private member initialization, access, and runtime behavior remain unproved.', ClassPrivateAccessorRuntimeRoute],
|
|
51
|
+
['class-static-block', 'class-static-block-initialization-order-evidence', 'control-flow-effect-graph', 'Class static block initialization-order evidence can bound public runtime-region ordering.', 'class-static-block-executable-runtime-equivalence-not-claimed', 'Executable static initialization side effects and runtime equivalence remain unproved.'],
|
|
52
|
+
['enum-declaration', 'typescript-enum-runtime-shape-evidence', 'type-public-api-graph', 'TypeScript compiler-backed enum runtime-shape, member-value, and source-bound computed-value proof evidence can bound emitted enum shape.', 'enum-runtime-evaluation-equivalence-not-claimed', 'Broad executable enum runtime evaluation remains unproved beyond source-bound computed-value traces.'],
|
|
53
|
+
['namespace-declaration', 'typescript-namespace-static-module-shape-evidence', 'module-export-import-graph', 'Namespace static module-shape records and proof hashes can bound declaration shape.', 'namespace-runtime-evaluation-equivalence-not-claimed', 'Namespace runtime evaluation and merging semantics remain unproved.'],
|
|
54
|
+
['ambient-module-declaration', 'typescript-ambient-module-static-shape-evidence', 'module-export-import-graph', 'Ambient module static shape records and proof hashes can bound declaration shape.', 'ambient-module-compatibility-equivalence-not-claimed', 'Ambient module compatibility across external consumers remains unproved.'],
|
|
55
|
+
['global-augmentation', 'typescript-global-augmentation-static-shape-evidence', 'module-export-import-graph', 'Global augmentation static shape records can bound declared global surface changes.', 'global-augmentation-compatibility-equivalence-not-claimed', 'Global compatibility and host/runtime interaction remain unproved.', { routeId: 'prove-global-augmentation-compatibility', routeLane: 'module-runtime-global-augmentation', routeNext: 'supply-source-bound-global-augmentation-compatibility-proof', failClosed: true, blocksSemanticEquivalence: true }],
|
|
56
|
+
['export-assignment', 'typescript-export-assignment-static-module-shape-evidence', 'module-export-import-graph', 'Export-assignment static module-shape records can bound CommonJS-style export shape.', 'export-assignment-runtime-interop-equivalence-not-claimed', 'CommonJS/ESM runtime interop behavior remains unproved.'],
|
|
57
|
+
['import-meta-expression', 'import-meta-host-context-member-evidence', 'control-flow-effect-graph', 'Static import.meta member and host-context evidence can bound observed host-dependent reads.', 'import-meta-host-context-equivalence-not-claimed', 'Host runtime resolution and executable import.meta equivalence remain unproved.'],
|
|
58
|
+
['satisfies-expression', 'typescript-satisfies-static-inference-syntax-evidence', 'type-public-api-graph', 'Static compiler-backed inference syntax evidence can bound satisfies-expression syntax participation.', 'satisfies-inference-semantics-equivalence-not-claimed', 'Broad inference semantics and executable behavior remain unproved.'],
|
|
59
|
+
['as-const-assertion', 'typescript-as-const-static-inference-syntax-evidence', 'type-public-api-graph', 'Static compiler-backed inference syntax evidence can bound as const assertion participation.', 'as-const-inference-semantics-equivalence-not-claimed', 'Broad literal inference semantics and executable behavior remain unproved.'],
|
|
60
|
+
['const-type-parameter', 'typescript-const-type-parameter-static-inference-syntax-evidence', 'type-public-api-graph', 'Static compiler-backed inference syntax evidence can bound const type-parameter participation.', 'const-type-parameter-inference-semantics-equivalence-not-claimed', 'Broad generic inference semantics and executable behavior remain unproved.'],
|
|
61
|
+
['async-generator-function', 'async-generator-await-yield-order-evidence', 'control-flow-effect-graph', 'Async generator await/yield order evidence can bound suspension ordering.', 'async-generator-runtime-protocol-equivalence-not-claimed', 'Async iterator protocol behavior, cancellation, backpressure, and executable scheduling remain unproved.', AsyncGeneratorRuntimeProtocolRoute],
|
|
62
|
+
['generator-function', 'generator-yield-order-evidence', 'control-flow-effect-graph', 'Generator yield order evidence can bound iterator suspension ordering.', 'generator-runtime-protocol-equivalence-not-claimed', 'Iterator protocol behavior, delegation, cancellation, and executable scheduling remain unproved.', GeneratorRuntimeProtocolRoute],
|
|
63
|
+
['top-level-await', 'top-level-await-module-runtime-scope-evidence', 'control-flow-effect-graph', 'Module-scope top-level await runtime-scope evidence can bound await suspension-order participation.', 'top-level-await-executable-suspension-order-equivalence-not-claimed', 'Executable suspension order and host module-loading behavior remain unproved.']
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const focusedSurfaceReviews = Object.freeze(Object.fromEntries(
|
|
67
|
+
focusedSurfaceReviewEntries.map(([kind, evidenceKind, evidenceScope, evidenceSummary, proofGapCode, proofGapSummary, proofGapRoute]) => [
|
|
68
|
+
kind,
|
|
69
|
+
focusedSurfaceReview(evidenceKind, evidenceScope, evidenceSummary, proofGapCode, proofGapSummary, proofGapRoute)
|
|
70
|
+
])
|
|
71
|
+
));
|
|
72
|
+
|
|
73
|
+
const surfaceEvidenceLimit = 50;
|
|
74
|
+
|
|
75
|
+
function unsupportedJsTsSurfaceEvidence(id, files = [], fileResults = []) {
|
|
76
|
+
const surfaces = unsupportedSurfaceRecords(files, fileResults);
|
|
77
|
+
return evidenceRecord({
|
|
78
|
+
id,
|
|
79
|
+
suffix: 'unsupported_js_ts_surface_review',
|
|
80
|
+
level: 'unsupported-js-ts-surface-review',
|
|
81
|
+
status: 'unknown',
|
|
82
|
+
scope: 'project',
|
|
83
|
+
claimKind: 'unsupported-surface-upper-bound',
|
|
84
|
+
summary: surfaces.length
|
|
85
|
+
? `Observed ${surfaces.length} unsupported or focused-evidence-only JS/TS surface marker(s); remaining proof gaps must be closed before any broad semantic equivalence claim.`
|
|
86
|
+
: 'Unsupported or focused-evidence-only JS/TS semantic surfaces require explicit external evidence before any broad semantic equivalence claim.',
|
|
87
|
+
metadata: {
|
|
88
|
+
partialMatrixRowsRemain: true,
|
|
89
|
+
requiresHumanOrExternalProof: true,
|
|
90
|
+
missingSignal: 'unsupported-js-ts-surface-proof-not-available',
|
|
91
|
+
nextAction: 'Supply the remaining focused unsupported-surface proof gaps or keep semanticEquivalenceClaim false.',
|
|
92
|
+
executableSemanticEquivalence: 'not-claimed',
|
|
93
|
+
surfaceReviewClaim: 'bounded-evidence-only',
|
|
94
|
+
surfaceEvidenceStatus: surfaces.length ? 'observed' : 'not-observed-by-lightweight-scan',
|
|
95
|
+
observedUnsupportedSurfaces: uniqueStrings(surfaces.map((surface) => surface.observedSurfaceKind)),
|
|
96
|
+
surfaceFocusedEvidenceKinds: uniqueStrings(surfaces.map((surface) => surface.boundedEvidence?.kind)),
|
|
97
|
+
surfaceProofGapCodes: uniqueStrings(surfaces.map((surface) => surface.remainingProofGap?.code)),
|
|
98
|
+
surfaceProofGapRouteIds: nonEmptyArray(uniqueStrings(surfaces.map((surface) => surface.remainingProofGap?.routeId))),
|
|
99
|
+
surfaceProofGapRouteLanes: nonEmptyArray(uniqueStrings(surfaces.map((surface) => surface.remainingProofGap?.routeLane))),
|
|
100
|
+
surfaceReasonCodes: uniqueStrings(surfaces.map((surface) => surface.reasonCode)),
|
|
101
|
+
surfaceEvidenceCount: surfaces.length || undefined,
|
|
102
|
+
surfaceEvidenceLimit: surfaces.length ? surfaceEvidenceLimit : undefined,
|
|
103
|
+
surfaceEvidenceTruncated: surfaces.length > surfaceEvidenceLimit || undefined,
|
|
104
|
+
surfaceEvidence: surfaces.length ? surfaces.slice(0, surfaceEvidenceLimit) : undefined
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function unsupportedSurfaceRecords(files, fileResults) {
|
|
110
|
+
const sources = [...sourceEntries(files), ...resultEntries(fileResults)];
|
|
111
|
+
const seen = new Set();
|
|
112
|
+
return sources.flatMap((entry) => unsupportedSurfaceRecordsForEntry(entry, seen));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function unsupportedSurfaceRecordsForEntry(entry, seen) {
|
|
116
|
+
const masked = maskNonCode(entry.sourceText).code;
|
|
117
|
+
const lineStarts = lineStartsFor(entry.sourceText);
|
|
118
|
+
return [
|
|
119
|
+
...surfaceChecks.flatMap((check) => {
|
|
120
|
+
check.pattern.lastIndex = 0;
|
|
121
|
+
return [...masked.matchAll(check.pattern)].flatMap((match) => {
|
|
122
|
+
const start = match.index + Math.max(0, Number(check.startOffset?.(match) ?? 0));
|
|
123
|
+
const end = match.index + match[0].length;
|
|
124
|
+
const key = `${entry.sourcePath}\0${entry.stage}\0${check.kind}\0${start}\0${end}`;
|
|
125
|
+
if (seen.has(key)) return [];
|
|
126
|
+
seen.add(key);
|
|
127
|
+
const location = lineColumnAt(lineStarts, start);
|
|
128
|
+
return [compactRecord({
|
|
129
|
+
sourcePath: entry.sourcePath,
|
|
130
|
+
stage: entry.stage,
|
|
131
|
+
kind: check.kind,
|
|
132
|
+
...focusedSurfaceRecordFields(check.kind),
|
|
133
|
+
start,
|
|
134
|
+
end,
|
|
135
|
+
line: location.line,
|
|
136
|
+
column: location.column,
|
|
137
|
+
excerpt: excerptFor(entry.sourceText, start, end)
|
|
138
|
+
})];
|
|
139
|
+
});
|
|
140
|
+
}),
|
|
141
|
+
...topLevelAwaitSurfaceRecords(entry, masked, lineStarts, seen)
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function topLevelAwaitSurfaceRecords(entry, masked, lineStarts, seen) {
|
|
146
|
+
const records = [];
|
|
147
|
+
let offset = 0;
|
|
148
|
+
let braceDepth = 0;
|
|
149
|
+
for (const line of masked.split(/(?<=\n)/)) {
|
|
150
|
+
const depthBeforeLine = braceDepth;
|
|
151
|
+
if (depthBeforeLine === 0) {
|
|
152
|
+
const awaitMatch = topLevelAwaitMatch(line);
|
|
153
|
+
if (awaitMatch) {
|
|
154
|
+
const record = unsupportedSurfaceRecord(
|
|
155
|
+
entry,
|
|
156
|
+
seen,
|
|
157
|
+
lineStarts,
|
|
158
|
+
'top-level-await',
|
|
159
|
+
offset + awaitMatch.index,
|
|
160
|
+
offset + awaitMatch.index + awaitMatch.length
|
|
161
|
+
);
|
|
162
|
+
if (record) records.push(record);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
braceDepth = nextBraceDepth(braceDepth, line);
|
|
166
|
+
offset += line.length;
|
|
167
|
+
}
|
|
168
|
+
return records;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function topLevelAwaitMatch(line) {
|
|
172
|
+
const match = /(?:^|[^\w$])await\b/.exec(line);
|
|
173
|
+
if (!match) return undefined;
|
|
174
|
+
const index = match.index + match[0].indexOf('await');
|
|
175
|
+
const before = line.slice(0, index).trim();
|
|
176
|
+
if (before.includes('=>')) return undefined;
|
|
177
|
+
if (!before || /^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*:\s*[^=]+)?\s*=$/.test(before) || /^export\s+default$/.test(before)) {
|
|
178
|
+
return { index, length: 'await'.length };
|
|
179
|
+
}
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function nextBraceDepth(depth, line) {
|
|
184
|
+
let current = depth;
|
|
185
|
+
for (const char of line) {
|
|
186
|
+
if (char === '{') current += 1;
|
|
187
|
+
else if (char === '}') current = Math.max(0, current - 1);
|
|
188
|
+
}
|
|
189
|
+
return current;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function unsupportedSurfaceRecord(entry, seen, lineStarts, kind, start, end) {
|
|
193
|
+
const key = `${entry.sourcePath}\0${entry.stage}\0${kind}\0${start}\0${end}`;
|
|
194
|
+
if (seen.has(key)) return undefined;
|
|
195
|
+
seen.add(key);
|
|
196
|
+
const location = lineColumnAt(lineStarts, start);
|
|
197
|
+
return compactRecord({
|
|
198
|
+
sourcePath: entry.sourcePath,
|
|
199
|
+
stage: entry.stage,
|
|
200
|
+
kind,
|
|
201
|
+
...focusedSurfaceRecordFields(kind),
|
|
202
|
+
start,
|
|
203
|
+
end,
|
|
204
|
+
line: location.line,
|
|
205
|
+
column: location.column,
|
|
206
|
+
excerpt: excerptFor(entry.sourceText, start, end)
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function focusedSurfaceReview(evidenceKind, evidenceScope, evidenceSummary, proofGapCode, proofGapSummary, proofGapRoute = undefined) {
|
|
211
|
+
return {
|
|
212
|
+
boundedEvidence: {
|
|
213
|
+
kind: evidenceKind,
|
|
214
|
+
status: 'bounded-evidence-available',
|
|
215
|
+
scope: evidenceScope,
|
|
216
|
+
summary: evidenceSummary
|
|
217
|
+
},
|
|
218
|
+
remainingProofGap: compactRecord({
|
|
219
|
+
code: proofGapCode,
|
|
220
|
+
status: 'not-claimed',
|
|
221
|
+
summary: proofGapSummary,
|
|
222
|
+
...(proofGapRoute ?? {})
|
|
223
|
+
})
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function focusedSurfaceRecordFields(kind) {
|
|
228
|
+
const review = focusedSurfaceReviews[kind] ?? focusedSurfaceReview(
|
|
229
|
+
'unsupported-js-ts-surface-focused-evidence-unmapped',
|
|
230
|
+
'unsupported-js-ts-surface-review',
|
|
231
|
+
'No focused evidence descriptor is mapped for this observed surface.',
|
|
232
|
+
'unsupported-js-ts-surface-proof-gap-not-claimed',
|
|
233
|
+
'The remaining proof gap is unmapped and semantic equivalence remains unproved.'
|
|
234
|
+
);
|
|
235
|
+
return {
|
|
236
|
+
observedSurfaceKind: kind,
|
|
237
|
+
boundedEvidence: review.boundedEvidence,
|
|
238
|
+
remainingProofGap: {
|
|
239
|
+
...review.remainingProofGap,
|
|
240
|
+
proofClaim: false,
|
|
241
|
+
autoMergeClaim: false,
|
|
242
|
+
semanticEquivalenceClaim: false
|
|
243
|
+
},
|
|
244
|
+
proofGapCode: review.remainingProofGap.code,
|
|
245
|
+
reasonCode: review.remainingProofGap.code
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function sourceEntries(files = []) {
|
|
250
|
+
return files.flatMap((file) => [
|
|
251
|
+
sourceEntry(file, 'base', file.baseSourceText),
|
|
252
|
+
sourceEntry(file, 'worker', file.workerSourceText),
|
|
253
|
+
sourceEntry(file, 'head', file.headSourceText)
|
|
254
|
+
].filter(Boolean));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function resultEntries(fileResults = []) {
|
|
258
|
+
return fileResults.map((file) => sourceEntry(file, 'output', file.outputSourceText)).filter(Boolean);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function sourceEntry(file, stage, sourceText) {
|
|
262
|
+
return typeof sourceText === 'string'
|
|
263
|
+
? { sourcePath: file.sourcePath, stage, sourceText }
|
|
264
|
+
: undefined;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function lineStartsFor(sourceText) {
|
|
268
|
+
const starts = [0];
|
|
269
|
+
for (let index = 0; index < sourceText.length; index += 1) {
|
|
270
|
+
if (sourceText[index] === '\n') starts.push(index + 1);
|
|
271
|
+
}
|
|
272
|
+
return starts;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function lineColumnAt(lineStarts, offset) {
|
|
276
|
+
let low = 0;
|
|
277
|
+
let high = lineStarts.length - 1;
|
|
278
|
+
while (low <= high) {
|
|
279
|
+
const mid = Math.floor((low + high) / 2);
|
|
280
|
+
if (lineStarts[mid] <= offset) low = mid + 1;
|
|
281
|
+
else high = mid - 1;
|
|
282
|
+
}
|
|
283
|
+
const lineIndex = Math.max(0, high);
|
|
284
|
+
return { line: lineIndex + 1, column: offset - lineStarts[lineIndex] + 1 };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function excerptFor(sourceText, start, end) {
|
|
288
|
+
const text = sourceText.slice(start, Math.min(sourceText.length, Math.max(end, start + 80)));
|
|
289
|
+
return text.replace(/\s+/g, ' ').trim() || undefined;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function evidenceRecord(input) {
|
|
293
|
+
return {
|
|
294
|
+
id: `${input.id}_proof_${input.suffix}`,
|
|
295
|
+
kind: 'js-ts-project-merge-proof-evidence',
|
|
296
|
+
level: input.level,
|
|
297
|
+
status: input.status,
|
|
298
|
+
scope: input.scope,
|
|
299
|
+
claimKind: input.claimKind ?? 'evidence',
|
|
300
|
+
evidenceOnly: true,
|
|
301
|
+
proofClaim: false,
|
|
302
|
+
autoMergeClaim: false,
|
|
303
|
+
semanticEquivalenceClaim: false,
|
|
304
|
+
summary: input.summary,
|
|
305
|
+
metadata: compactRecord({
|
|
306
|
+
...(input.metadata ?? {}),
|
|
307
|
+
proofClaim: false,
|
|
308
|
+
autoMergeClaim: false,
|
|
309
|
+
semanticEquivalenceClaim: false
|
|
310
|
+
})
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function uniqueStrings(values) {
|
|
315
|
+
return [...new Set((values ?? []).filter((value) => typeof value === 'string' && value.length > 0))];
|
|
316
|
+
}
|
|
317
|
+
function nonEmptyArray(value) { return Array.isArray(value) && value.length ? value : undefined; }
|
|
318
|
+
|
|
319
|
+
export { unsupportedJsTsSurfaceEvidence };
|