@shapeshift-labs/frontier-lang-compiler 0.2.150 → 0.2.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -9
- package/bench/real-repo-corpus-checkout-identity.mjs +134 -0
- package/bench/real-repo-corpus-checkout-proof.mjs +263 -0
- package/bench/real-repo-corpus-command-execution.mjs +314 -0
- package/bench/real-repo-corpus-evidence.mjs +165 -0
- package/bench/real-repo-corpus-suite.mjs +273 -0
- package/bench/smoke.mjs +109 -7
- package/dist/declarations/import-adapter-core.d.ts +4 -3
- package/dist/declarations/import-adapter-options-native.d.ts +21 -0
- package/dist/declarations/js-ts-project-merge-admission-routes.d.ts +35 -0
- package/dist/declarations/js-ts-project-merge-commonjs-interop.d.ts +29 -0
- package/dist/declarations/js-ts-project-merge-confidence.d.ts +64 -0
- package/dist/declarations/js-ts-project-merge-declaration-emit-parity.d.ts +37 -0
- package/dist/declarations/js-ts-project-merge-declarations.d.ts +65 -0
- package/dist/declarations/js-ts-project-merge-diagnostics.d.ts +97 -0
- package/dist/declarations/js-ts-project-merge-global-augmentation.d.ts +30 -0
- package/dist/declarations/js-ts-project-merge-jsx-render-branch.d.ts +48 -0
- package/dist/declarations/js-ts-project-merge-proof-levels.d.ts +109 -0
- package/dist/declarations/js-ts-project-merge-quality-gates.d.ts +38 -0
- package/dist/declarations/js-ts-project-merge-semantic-equivalence-proof.d.ts +45 -0
- package/dist/declarations/js-ts-project-merge-tsconfig.d.ts +43 -0
- package/dist/declarations/js-ts-safe-merge.d.ts +47 -0
- package/dist/declarations/js-ts-safe-project-merge.d.ts +120 -38
- package/dist/declarations/native-project-compiler-assignability-oracle.d.ts +41 -0
- package/dist/declarations/native-project-compiler-callable-signatures.d.ts +31 -0
- package/dist/declarations/native-project-compiler-class-member-runtime-proof.d.ts +87 -0
- package/dist/declarations/native-project-compiler-composite-types.d.ts +23 -0
- package/dist/declarations/native-project-compiler-enum-proof.d.ts +58 -0
- package/dist/declarations/native-project-compiler-index-signature.d.ts +7 -0
- package/dist/declarations/native-project-compiler-public-api-source-binding.d.ts +8 -0
- package/dist/declarations/native-project-compiler-scope.d.ts +37 -0
- package/dist/declarations/native-project-compiler-type-reference-targets.d.ts +38 -0
- package/dist/declarations/native-project-css-modules.d.ts +90 -0
- package/dist/declarations/native-project-decorator-metadata.d.ts +126 -0
- package/dist/declarations/native-project-jsx-graph.d.ts +313 -0
- package/dist/declarations/native-project-module-declarations.d.ts +52 -0
- package/dist/declarations/native-project-module-resolution.d.ts +76 -1
- package/dist/declarations/native-project-runtime-effect-target.d.ts +29 -0
- package/dist/declarations/native-project-runtime-executable-effect-evidence.d.ts +107 -0
- package/dist/declarations/native-project-runtime-mutation-target.d.ts +33 -0
- package/dist/declarations/native-project-runtime-promise-chain.d.ts +30 -0
- package/dist/declarations/native-project-runtime-promise-combinator.d.ts +22 -0
- package/dist/declarations/native-project-runtime-reachability.d.ts +30 -0
- package/dist/declarations/native-project-runtime-resource-management.d.ts +27 -0
- package/dist/declarations/native-project-runtime-yield-delegation.d.ts +10 -0
- package/dist/declarations/native-project-scope-template-reference.d.ts +13 -0
- package/dist/declarations/native-project-source-evidence.d.ts +8 -0
- package/dist/declarations/native-project.d.ts +40 -39
- package/dist/declarations/semantic-edit-script.d.ts +10 -8
- package/dist/declarations/semantic-graph-layers.d.ts +79 -0
- package/dist/declarations/semantic-sidecar.d.ts +3 -2
- package/dist/declarations/semantic-structural-diff.d.ts +94 -0
- package/dist/declarations/source-preservation.d.ts +32 -1
- package/dist/declarations/target-adapters.d.ts +22 -2
- package/dist/index.d.ts +31 -0
- package/dist/index.js +5 -0
- package/dist/internal/index-impl/compileNativeSource.js +53 -5
- package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
- package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
- package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
- package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
- package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
- package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
- package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
- package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
- package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
- package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
- package/dist/internal/index-impl/importNativeSource.js +2 -3
- package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
- package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
- package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
- package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
- package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
- package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
- package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
- package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
- package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
- package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
- package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
- package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
- package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
- package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
- package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
- package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
- package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
- package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
- package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
- package/dist/internal/index-impl/semanticEditScripts.js +42 -5
- package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
- package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
- package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
- package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
- package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
- package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
- package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
- package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
- package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
- package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
- package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
- package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
- package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
- package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
- package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
- package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
- package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
- package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
- package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
- package/dist/js-ts-safe-member-class-invariants.js +247 -0
- package/dist/js-ts-safe-member-merge-result.js +23 -3
- package/dist/js-ts-safe-member-merge.js +28 -4
- package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
- package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +151 -157
- package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
- package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
- package/dist/js-ts-safe-merge-parse-statements.js +8 -0
- package/dist/js-ts-safe-merge-semantic-edit-fallback.js +13 -5
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +3 -1
- package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
- package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
- package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
- package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
- package/dist/js-ts-safe-merge.js +136 -0
- package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
- package/dist/js-ts-safe-project-merge-admission.js +161 -0
- package/dist/js-ts-safe-project-merge-ambient.js +110 -0
- package/dist/js-ts-safe-project-merge-core.js +85 -0
- package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
- package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
- package/dist/js-ts-safe-project-merge-declarations.js +227 -0
- package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
- package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
- package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
- package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
- package/dist/js-ts-safe-project-merge-files.js +70 -0
- package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
- package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
- package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
- package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
- package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
- package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
- package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
- package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
- package/dist/js-ts-safe-project-merge-graph.js +37 -5
- package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
- package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
- package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
- package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
- package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
- package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
- package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
- package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
- package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
- package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
- package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
- package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
- package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
- package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
- package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
- package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
- package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
- package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
- package/dist/js-ts-safe-project-merge-summary.js +320 -0
- package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
- package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
- package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
- package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
- package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
- package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
- package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
- package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
- package/dist/js-ts-safe-project-merge.js +170 -171
- package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
- package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
- package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
- package/dist/js-ts-semantic-scope-use-def.js +217 -0
- package/dist/lightweight-dependency-effects.js +28 -4
- package/dist/lightweight-dependency-relations.js +13 -7
- package/dist/lightweight-dependency-top-level.js +63 -0
- package/dist/native-import-language-profiles.js +27 -1
- package/dist/native-js-ts-importers.js +9 -5
- package/dist/native-parser-ast-format-profiles.js +12 -0
- package/dist/native-parser-html-css-format-profiles.js +85 -0
- package/dist/native-region-scanner-core.js +5 -3
- package/dist/native-region-scanner-js-commonjs.js +155 -0
- package/dist/native-region-scanner-js-imports.js +51 -13
- package/dist/native-region-scanner-js-reexports.js +79 -0
- package/dist/native-region-scanner-js-ts-helpers.js +23 -0
- package/dist/native-source-ledger-helpers.js +1 -1
- package/dist/native-source-ledger.js +24 -10
- package/dist/native-source-maps-ecma426.js +316 -0
- package/dist/native-source-maps.js +36 -6
- package/dist/native-source-preservation-ownership.js +292 -0
- package/dist/native-source-preservation-scanner.js +63 -25
- package/dist/native-source-preservation-types.d.ts +3 -0
- package/dist/semantic-import-effect-occurrences.js +242 -0
- package/dist/semantic-import-effect-regions.js +95 -58
- package/dist/semantic-import-graph-layers.js +224 -0
- package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
- package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
- package/dist/semantic-import-runtime-exit-evidence.js +32 -0
- package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
- package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
- package/dist/semantic-import-runtime-order-evidence.js +318 -0
- package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
- package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
- package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
- package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
- package/dist/semantic-import-runtime-switch-evidence.js +304 -0
- package/dist/semantic-import-runtime-throw-evidence.js +44 -0
- package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
- package/dist/semantic-import-sidecar-entry.js +4 -0
- package/dist/semantic-import-source-preservation.js +6 -2
- package/package.json +1 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { countBy, uniqueStrings } from './native-import-utils.js';
|
|
2
|
+
import { summarizeImportSourcePreservation } from './semantic-import-source-preservation.js';
|
|
3
|
+
|
|
4
|
+
export const SemanticGraphLayerKinds = Object.freeze([
|
|
5
|
+
'parser-source-span-trivia',
|
|
6
|
+
'scope-use-def',
|
|
7
|
+
'module-export-import',
|
|
8
|
+
'type-public-api',
|
|
9
|
+
'control-flow-effect',
|
|
10
|
+
'generic-semantic-edit-admission'
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export function createSemanticGraphLayerSummary(input = {}) {
|
|
14
|
+
const imports = input.imports ?? [];
|
|
15
|
+
const symbols = input.symbols ?? [];
|
|
16
|
+
const ownershipRegions = input.ownershipRegions ?? [];
|
|
17
|
+
const dependencies = input.dependencies ?? {};
|
|
18
|
+
const sourceMaps = input.sourceMaps ?? [];
|
|
19
|
+
const sourceMapMappings = input.sourceMapMappings ?? [];
|
|
20
|
+
const sourcePreservationDetails = input.sourcePreservationDetails
|
|
21
|
+
?? (imports.length ? summarizeImportSourcePreservation(input.importResult, imports) : emptySourcePreservationDetails());
|
|
22
|
+
const sourcePreservation = input.sourcePreservation ?? {};
|
|
23
|
+
const layers = {
|
|
24
|
+
parserSourceSpanTrivia: parserSourceSpanTriviaLayer({ sourcePreservation, sourcePreservationDetails, sourceMapMappings, sourceMaps, universalAstLayers: input.universalAstLayers }),
|
|
25
|
+
scopeUseDef: scopeUseDefLayer({ symbols, dependencies, paradigmSemantics: input.paradigmSemantics }),
|
|
26
|
+
moduleExportImport: moduleExportImportLayer({ symbols, dependencies }),
|
|
27
|
+
typePublicApi: typePublicApiLayer({ symbols, ownershipRegions, proofSpec: input.proofSpec }),
|
|
28
|
+
controlFlowEffect: controlFlowEffectLayer({ ownershipRegions, dependencies, paradigmSemantics: input.paradigmSemantics, semanticImpact: input.semanticImpact }),
|
|
29
|
+
genericSemanticEditAdmission: genericSemanticEditAdmissionLayer({ patchHints: input.patchHints, quality: input.quality, admission: input.admission, mergeCandidates: input.mergeCandidates, readiness: input.readiness })
|
|
30
|
+
};
|
|
31
|
+
const layerList = Object.values(layers);
|
|
32
|
+
const byStatus = countBy(layerList.map((layer) => layer.status));
|
|
33
|
+
return {
|
|
34
|
+
kind: 'frontier.lang.semanticGraphLayers',
|
|
35
|
+
version: 1,
|
|
36
|
+
schema: 'frontier.lang.semanticGraphLayers.v1',
|
|
37
|
+
status: summaryStatus(layerList),
|
|
38
|
+
layerKinds: SemanticGraphLayerKinds,
|
|
39
|
+
layers,
|
|
40
|
+
summary: {
|
|
41
|
+
total: layerList.length,
|
|
42
|
+
strong: byStatus.strong ?? 0,
|
|
43
|
+
partial: byStatus.partial ?? 0,
|
|
44
|
+
missing: byStatus.missing ?? 0,
|
|
45
|
+
blocked: byStatus.blocked ?? 0,
|
|
46
|
+
usable: layerList.filter((layer) => layer.status === 'strong' || layer.status === 'partial').length,
|
|
47
|
+
reasonCodes: uniqueStrings(layerList.flatMap((layer) => layer.reasonCodes ?? [])),
|
|
48
|
+
evidenceIds: uniqueStrings(layerList.flatMap((layer) => layer.evidenceIds ?? []))
|
|
49
|
+
},
|
|
50
|
+
metadata: {
|
|
51
|
+
note: 'Graph layers summarize available semantic evidence for admission. They are not semantic-equivalence proof.'
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function parserSourceSpanTriviaLayer(input) {
|
|
57
|
+
const exact = input.sourcePreservation?.exact ?? 0;
|
|
58
|
+
const declaration = input.sourcePreservation?.declaration ?? 0;
|
|
59
|
+
const estimated = input.sourcePreservation?.estimated ?? 0;
|
|
60
|
+
const blocked = input.sourcePreservation?.blocked ?? 0;
|
|
61
|
+
const sourceMapMappings = input.sourceMapMappings?.length ?? input.sourcePreservation?.sourceMapMappingIds?.length ?? 0;
|
|
62
|
+
const trivia = input.sourcePreservationDetails?.trivia ?? 0;
|
|
63
|
+
const comments = input.sourcePreservationDetails?.comments ?? 0;
|
|
64
|
+
const directives = input.sourcePreservationDetails?.directives ?? 0;
|
|
65
|
+
return graphLayer({
|
|
66
|
+
id: 'parser-source-span-trivia',
|
|
67
|
+
title: 'Parser, source span, and trivia evidence',
|
|
68
|
+
status: blocked ? 'blocked' : exact && sourceMapMappings ? 'strong' : exact || declaration || estimated || sourceMapMappings || trivia ? 'partial' : 'missing',
|
|
69
|
+
summary: { exact, declaration, estimated, blocked, sourceMaps: input.sourceMaps?.length ?? 0, sourceMapMappings, trivia, comments, directives, universalAstLayers: input.universalAstLayers?.total ?? 0 },
|
|
70
|
+
reasonCodes: [
|
|
71
|
+
...(!exact ? ['missing-exact-source-preservation'] : []),
|
|
72
|
+
...(!sourceMapMappings ? ['missing-source-map-mappings'] : []),
|
|
73
|
+
...(!trivia ? ['missing-token-trivia-evidence'] : []),
|
|
74
|
+
...(blocked ? ['blocked-source-preservation'] : [])
|
|
75
|
+
],
|
|
76
|
+
evidenceIds: input.sourcePreservation?.ids
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function scopeUseDefLayer(input) {
|
|
81
|
+
const bindings = input.paradigmSemantics?.bindings ?? 0;
|
|
82
|
+
const bindingScopes = input.paradigmSemantics?.bindingScopes ?? 0;
|
|
83
|
+
const uses = input.dependencies?.uses ?? 0;
|
|
84
|
+
const references = input.dependencies?.references ?? 0;
|
|
85
|
+
const calls = input.dependencies?.calls ?? 0;
|
|
86
|
+
return graphLayer({
|
|
87
|
+
id: 'scope-use-def',
|
|
88
|
+
title: 'Scope and use-def graph evidence',
|
|
89
|
+
status: bindings && (uses || references || calls) ? 'strong' : bindings || bindingScopes || uses || references || calls ? 'partial' : 'missing',
|
|
90
|
+
summary: { bindingScopes, bindings, uses, references, calls, sourceSymbols: input.dependencies?.sourceSymbolIds?.length ?? 0, targetSymbols: input.dependencies?.targetSymbolIds?.length ?? 0, symbols: input.symbols?.length ?? 0 },
|
|
91
|
+
reasonCodes: [
|
|
92
|
+
...(!bindings ? ['missing-binding-graph'] : []),
|
|
93
|
+
...(!(uses || references || calls) ? ['missing-use-def-relations'] : [])
|
|
94
|
+
],
|
|
95
|
+
evidenceIds: input.paradigmSemantics?.ids
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function moduleExportImportLayer(input) {
|
|
100
|
+
const moduleSymbols = input.symbols.filter((symbol) => moduleSymbol(symbol));
|
|
101
|
+
const importSymbols = moduleSymbols.filter((symbol) => importSymbol(symbol));
|
|
102
|
+
const exportSymbols = moduleSymbols.filter((symbol) => exportSymbol(symbol));
|
|
103
|
+
const importEdges = input.dependencies?.imports ?? 0;
|
|
104
|
+
const requireEdges = input.dependencies?.requires ?? 0;
|
|
105
|
+
return graphLayer({
|
|
106
|
+
id: 'module-export-import',
|
|
107
|
+
title: 'Module, export, and import graph evidence',
|
|
108
|
+
status: (importEdges || requireEdges || importSymbols.length) && exportSymbols.length ? 'strong' : importEdges || requireEdges || moduleSymbols.length ? 'partial' : 'missing',
|
|
109
|
+
summary: { importEdges, requireEdges, moduleSymbols: moduleSymbols.length, importSymbols: importSymbols.length, exportSymbols: exportSymbols.length, predicates: input.dependencies?.predicates ?? [] },
|
|
110
|
+
reasonCodes: [
|
|
111
|
+
...(!(importEdges || requireEdges || importSymbols.length) ? ['missing-import-graph'] : []),
|
|
112
|
+
...(!exportSymbols.length ? ['missing-export-graph'] : [])
|
|
113
|
+
],
|
|
114
|
+
evidenceIds: input.dependencies?.ids
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function typePublicApiLayer(input) {
|
|
119
|
+
const typeSymbols = input.symbols.filter((symbol) => typeSymbol(symbol));
|
|
120
|
+
const publicSymbols = input.symbols.filter((symbol) => exportSymbol(symbol) || publicRegion(input.ownershipRegions, symbol));
|
|
121
|
+
const contracts = input.proofSpec?.contracts ?? 0;
|
|
122
|
+
const invariants = input.proofSpec?.invariants ?? 0;
|
|
123
|
+
return graphLayer({
|
|
124
|
+
id: 'type-public-api',
|
|
125
|
+
title: 'Type and public API graph evidence',
|
|
126
|
+
status: typeSymbols.length && (publicSymbols.length || contracts || invariants) ? 'strong' : typeSymbols.length || publicSymbols.length || contracts || invariants ? 'partial' : 'missing',
|
|
127
|
+
summary: { typeSymbols: typeSymbols.length, publicSymbols: publicSymbols.length, contracts, invariants, proofObligations: input.proofSpec?.obligations ?? 0, proofOpen: input.proofSpec?.open ?? 0 },
|
|
128
|
+
reasonCodes: [
|
|
129
|
+
...(!typeSymbols.length ? ['missing-type-graph'] : []),
|
|
130
|
+
...(!(publicSymbols.length || contracts || invariants) ? ['missing-public-api-contract-graph'] : [])
|
|
131
|
+
],
|
|
132
|
+
evidenceIds: input.proofSpec?.ids
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function controlFlowEffectLayer(input) {
|
|
137
|
+
const runtimeRegions = input.ownershipRegions.filter((region) => runtimeRegion(region));
|
|
138
|
+
const effectRegions = runtimeRegions.filter((region) => region.regionKind === 'effect').length + (input.paradigmSemantics?.effectRegions ?? 0);
|
|
139
|
+
const controlRegions = runtimeRegions.filter((region) => region.regionKind === 'controlFlow').length + (input.paradigmSemantics?.controlRegions ?? 0);
|
|
140
|
+
const mutationRegions = runtimeRegions.filter((region) => region.regionKind === 'mutation').length;
|
|
141
|
+
const callRegions = runtimeRegions.filter((region) => region.regionKind === 'call').length + (input.dependencies?.calls ?? 0);
|
|
142
|
+
const highRisk = input.semanticImpact?.summary?.byRisk?.high ?? 0;
|
|
143
|
+
return graphLayer({
|
|
144
|
+
id: 'control-flow-effect',
|
|
145
|
+
title: 'Control-flow and effect graph evidence',
|
|
146
|
+
status: runtimeRegions.length || effectRegions || controlRegions || mutationRegions || callRegions ? 'partial' : 'missing',
|
|
147
|
+
summary: { runtimeRegions: runtimeRegions.length, effectRegions, controlRegions, mutationRegions, callRegions, highRiskImpacts: highRisk },
|
|
148
|
+
reasonCodes: [
|
|
149
|
+
...(!controlRegions ? ['missing-control-flow-graph'] : []),
|
|
150
|
+
...(!effectRegions ? ['missing-effect-graph'] : [])
|
|
151
|
+
],
|
|
152
|
+
evidenceIds: input.semanticImpact?.evidenceIds
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function genericSemanticEditAdmissionLayer(input) {
|
|
157
|
+
const patchHints = input.patchHints?.length ?? 0;
|
|
158
|
+
const mergeCandidates = input.mergeCandidates?.length ?? 0;
|
|
159
|
+
const admissionStatus = input.admission?.status ?? input.quality?.record?.classification;
|
|
160
|
+
const blocked = String(input.admission?.action ?? '').startsWith('reject') || input.readiness === 'blocked';
|
|
161
|
+
return graphLayer({
|
|
162
|
+
id: 'generic-semantic-edit-admission',
|
|
163
|
+
title: 'Generic semantic edit admission evidence',
|
|
164
|
+
status: blocked ? 'blocked' : admissionStatus && patchHints ? 'strong' : admissionStatus || patchHints || mergeCandidates ? 'partial' : 'missing',
|
|
165
|
+
summary: { patchHints, mergeCandidates, admissionStatus, admissionAction: input.admission?.action, readiness: input.readiness, qualityClassification: input.quality?.record?.classification },
|
|
166
|
+
reasonCodes: uniqueStrings([
|
|
167
|
+
...(!patchHints ? ['missing-semantic-patch-hints'] : []),
|
|
168
|
+
...(!admissionStatus ? ['missing-admission-record'] : []),
|
|
169
|
+
...(input.quality?.expectedMissingReasonCodes ?? [])
|
|
170
|
+
]),
|
|
171
|
+
evidenceIds: input.admission?.evidenceIds
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function graphLayer(input) {
|
|
176
|
+
return {
|
|
177
|
+
kind: 'frontier.lang.semanticGraphLayer',
|
|
178
|
+
version: 1,
|
|
179
|
+
id: input.id,
|
|
180
|
+
title: input.title,
|
|
181
|
+
status: input.status,
|
|
182
|
+
summary: input.summary ?? {},
|
|
183
|
+
reasonCodes: uniqueStrings(input.reasonCodes ?? []),
|
|
184
|
+
evidenceIds: uniqueStrings(input.evidenceIds ?? [])
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function summaryStatus(layers) {
|
|
189
|
+
if (layers.some((layer) => layer.status === 'blocked')) return 'blocked';
|
|
190
|
+
if (layers.some((layer) => layer.status === 'strong' || layer.status === 'partial')) return 'partial';
|
|
191
|
+
return 'missing';
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function emptySourcePreservationDetails() {
|
|
195
|
+
return { total: 0, trivia: 0, comments: 0, directives: 0 };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function symbolText(symbol) {
|
|
199
|
+
return `${symbol?.id ?? ''} ${symbol?.name ?? ''} ${symbol?.kind ?? ''} ${symbol?.ownershipRegionKind ?? ''}`.toLowerCase();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function moduleSymbol(symbol) {
|
|
203
|
+
return /\b(import|export|module|namespace|commonjs|require)\b/.test(symbolText(symbol));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function importSymbol(symbol) {
|
|
207
|
+
return /\b(import|require)\b/.test(symbolText(symbol));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function exportSymbol(symbol) {
|
|
211
|
+
return /\b(export|public)\b/.test(symbolText(symbol));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function typeSymbol(symbol) {
|
|
215
|
+
return /\b(type|interface|class|enum|namespace|module|alias|generic|constraint)\b/.test(symbolText(symbol));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function runtimeRegion(region) {
|
|
219
|
+
return ['call', 'controlFlow', 'effect', 'mutation'].includes(region?.regionKind);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function publicRegion(regions, symbol) {
|
|
223
|
+
return regions.some((region) => region.symbolId === symbol.id && /\b(export|public)\b/.test(`${region.key ?? ''} ${region.mergePolicy ?? ''}`.toLowerCase()));
|
|
224
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
function conditionalExpressionEvidenceRecords(line, start, end) {
|
|
2
|
+
const text = String(line ?? '');
|
|
3
|
+
return conditionalExpressionPairs(text)
|
|
4
|
+
.map((pair) => conditionalExpressionRecord(text, pair, start, end))
|
|
5
|
+
.filter(Boolean)
|
|
6
|
+
.sort((left, right) => right.questionIndex - left.questionIndex)
|
|
7
|
+
.slice(0, 1)
|
|
8
|
+
.map(({ questionIndex: _questionIndex, ...record }) => record);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function conditionalExpressionPairs(text) {
|
|
12
|
+
const pairs = [];
|
|
13
|
+
const stack = [];
|
|
14
|
+
const state = scanState();
|
|
15
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
16
|
+
const char = text[index];
|
|
17
|
+
const next = text[index + 1];
|
|
18
|
+
if (advanceIgnoredState(state, char, next)) { if (state.skipNext) { state.skipNext = false; index += 1; } continue; }
|
|
19
|
+
if (char === '(') { state.parenDepth += 1; continue; }
|
|
20
|
+
if (char === ')') { state.parenDepth = Math.max(0, state.parenDepth - 1); continue; }
|
|
21
|
+
if (char === '[') { state.bracketDepth += 1; continue; }
|
|
22
|
+
if (char === ']') { state.bracketDepth = Math.max(0, state.bracketDepth - 1); continue; }
|
|
23
|
+
if (char === '{') { state.braceDepth += 1; continue; }
|
|
24
|
+
if (char === '}') { state.braceDepth = Math.max(0, state.braceDepth - 1); continue; }
|
|
25
|
+
if (char === '?' && conditionalQuestionMark(text, index)) stack.push({ questionIndex: index, ...depthSnapshot(state) });
|
|
26
|
+
else if (char === ':') {
|
|
27
|
+
const stackIndex = lastMatchingQuestionIndex(stack, state);
|
|
28
|
+
if (stackIndex >= 0) pairs.push({ ...stack.splice(stackIndex, 1)[0], colonIndex: index });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return pairs;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function conditionalExpressionRecord(text, pair, start, end) {
|
|
35
|
+
const expressionEnd = conditionalExpressionEnd(text, pair.colonIndex);
|
|
36
|
+
const branch = conditionalBranch(pair, expressionEnd, start, end);
|
|
37
|
+
if (!branch) return undefined;
|
|
38
|
+
const guardStart = conditionalGuardStart(text, pair);
|
|
39
|
+
const guardText = normalizeConditionalGuardText(text.slice(guardStart, pair.questionIndex));
|
|
40
|
+
if (!guardText) return undefined;
|
|
41
|
+
return compactRecord({
|
|
42
|
+
kind: 'conditional-expression',
|
|
43
|
+
branch,
|
|
44
|
+
guardText,
|
|
45
|
+
text: normalizeOrderEvidenceText(text.slice(guardStart, expressionEnd)),
|
|
46
|
+
questionColumn: pair.questionIndex + 1,
|
|
47
|
+
colonColumn: pair.colonIndex + 1,
|
|
48
|
+
questionIndex: pair.questionIndex
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function conditionalBranch(pair, expressionEnd, start, end) {
|
|
53
|
+
if (start >= pair.questionIndex + 1 && end <= pair.colonIndex) return 'consequent';
|
|
54
|
+
if (start >= pair.colonIndex + 1 && end <= expressionEnd) return 'alternate';
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function conditionalGuardStart(text, pair) {
|
|
59
|
+
let start = 0;
|
|
60
|
+
const state = scanState();
|
|
61
|
+
for (let index = 0; index < pair.questionIndex; index += 1) {
|
|
62
|
+
const char = text[index];
|
|
63
|
+
const next = text[index + 1];
|
|
64
|
+
if (advanceIgnoredState(state, char, next)) { if (state.skipNext) { state.skipNext = false; index += 1; } continue; }
|
|
65
|
+
if (char === '(') { state.parenDepth += 1; if (sameDepth(state, pair)) start = index + 1; continue; }
|
|
66
|
+
if (char === '[') { state.bracketDepth += 1; if (sameDepth(state, pair)) start = index + 1; continue; }
|
|
67
|
+
if (char === '{') { state.braceDepth += 1; if (sameDepth(state, pair)) start = index + 1; continue; }
|
|
68
|
+
if (sameDepth(state, pair) && (char === ';' || char === ',' || char === ':')) start = index + 1;
|
|
69
|
+
if (sameDepth(state, pair) && char === '=' && assignmentBoundary(text, index)) start = index + 1;
|
|
70
|
+
if (char === ')') state.parenDepth = Math.max(0, state.parenDepth - 1);
|
|
71
|
+
else if (char === ']') state.bracketDepth = Math.max(0, state.bracketDepth - 1);
|
|
72
|
+
else if (char === '}') state.braceDepth = Math.max(0, state.braceDepth - 1);
|
|
73
|
+
}
|
|
74
|
+
return start;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function conditionalExpressionEnd(text, colonIndex) {
|
|
78
|
+
const semicolon = text.indexOf(';', colonIndex);
|
|
79
|
+
return semicolon === -1 ? text.length : semicolon + 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function advanceIgnoredState(state, char, next) {
|
|
83
|
+
if (state.lineComment) return true;
|
|
84
|
+
if (state.blockComment) {
|
|
85
|
+
if (char === '*' && next === '/') { state.blockComment = false; state.skipNext = true; }
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
if (state.quote) {
|
|
89
|
+
if (state.escaped) state.escaped = false;
|
|
90
|
+
else if (char === '\\') state.escaped = true;
|
|
91
|
+
else if (char === state.quote) state.quote = undefined;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
if (char === '/' && next === '/') { state.lineComment = true; return true; }
|
|
95
|
+
if (char === '/' && next === '*') { state.blockComment = true; state.skipNext = true; return true; }
|
|
96
|
+
if (char === '\'' || char === '"' || char === '`') { state.quote = char; return true; }
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function lastMatchingQuestionIndex(stack, state) {
|
|
101
|
+
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
102
|
+
if (sameDepth(state, stack[index])) return index;
|
|
103
|
+
}
|
|
104
|
+
return -1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function conditionalQuestionMark(text, index) {
|
|
108
|
+
return text[index - 1] !== '?' && text[index + 1] !== '?' && text[index + 1] !== '.';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function assignmentBoundary(text, index) {
|
|
112
|
+
return text[index - 1] !== '=' && text[index + 1] !== '=' && text[index - 1] !== '!'
|
|
113
|
+
&& text[index - 1] !== '<' && text[index - 1] !== '>' && text[index + 1] !== '>'
|
|
114
|
+
&& text[index - 1] !== '&' && text[index - 1] !== '|' && text[index - 1] !== '?';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function sameDepth(left, right) {
|
|
118
|
+
return left.parenDepth === right.parenDepth && left.bracketDepth === right.bracketDepth
|
|
119
|
+
&& left.braceDepth === right.braceDepth;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function depthSnapshot(state) {
|
|
123
|
+
return { parenDepth: state.parenDepth, bracketDepth: state.bracketDepth, braceDepth: state.braceDepth };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function scanState() { return { parenDepth: 0, bracketDepth: 0, braceDepth: 0 }; }
|
|
127
|
+
function normalizeConditionalGuardText(value) {
|
|
128
|
+
return normalizeOrderEvidenceText(String(value ?? '').replace(/^(?:return|throw|yield|await)\s+/, ''));
|
|
129
|
+
}
|
|
130
|
+
function normalizeOrderEvidenceText(value) { return String(value ?? '').replace(/\s+/g, ' ').trim(); }
|
|
131
|
+
function compactRecord(record) {
|
|
132
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined && (!Array.isArray(value) || value.length > 0)));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { conditionalExpressionEvidenceRecords };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
function effectTargetOrderEvidence(line, lineNumber, group, start = 0, end = String(line ?? '').length, lines = []) {
|
|
2
|
+
if (group?.regionKind !== 'effect') return [];
|
|
3
|
+
const expression = String(line ?? '').slice(Math.max(0, start), Math.max(start, end));
|
|
4
|
+
const context = { literalBindings: sameScopeLiteralBindings(lines, lineNumber, line, start) };
|
|
5
|
+
const record = effectTargetRecord(expression, context) ?? effectTokenRecord(expression, context);
|
|
6
|
+
return record ? [compactRecord({
|
|
7
|
+
kind: 'effect-target',
|
|
8
|
+
effectKind: effectFactKind(group),
|
|
9
|
+
line: lineNumber,
|
|
10
|
+
...record,
|
|
11
|
+
staticEffectTargetEvidence: true,
|
|
12
|
+
runtimeEquivalenceClaim: false,
|
|
13
|
+
semanticEquivalenceClaim: false
|
|
14
|
+
})] : [];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function effectTargetSignatureEvidence(record) {
|
|
18
|
+
return compactRecord({
|
|
19
|
+
effectKind: record?.effectKind,
|
|
20
|
+
targetText: record?.targetText,
|
|
21
|
+
targetRoot: record?.targetRoot,
|
|
22
|
+
receiverText: record?.receiverText,
|
|
23
|
+
taggedTemplate: record?.taggedTemplate,
|
|
24
|
+
calleeName: record?.calleeName,
|
|
25
|
+
constructorCall: record?.constructorCall,
|
|
26
|
+
optionalCall: record?.optionalCall,
|
|
27
|
+
computedProperty: record?.computedProperty,
|
|
28
|
+
computedPropertyKeys: record?.computedPropertyKeys,
|
|
29
|
+
computedPropertyStatic: record?.computedPropertyStatic,
|
|
30
|
+
computedPropertyDynamic: record?.computedPropertyDynamic,
|
|
31
|
+
computedPropertyBoundLiteral: record?.computedPropertyBoundLiteral,
|
|
32
|
+
computedPropertyBindingNames: record?.computedPropertyBindingNames,
|
|
33
|
+
computedPropertyBindingKinds: record?.computedPropertyBindingKinds
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function effectTargetContextReasonCodes(record) {
|
|
38
|
+
return uniqueStrings([
|
|
39
|
+
'runtime-order-effect-target-merge-requires-effect-target-evidence',
|
|
40
|
+
record?.calleeName ? 'runtime-order-effect-target-merge-requires-callee-evidence' : undefined,
|
|
41
|
+
record?.taggedTemplate ? 'runtime-order-effect-target-merge-requires-tagged-template-target-evidence' : undefined,
|
|
42
|
+
record?.receiverText ? 'runtime-order-effect-target-merge-requires-receiver-evidence' : undefined,
|
|
43
|
+
record?.constructorCall ? 'runtime-order-effect-target-merge-requires-constructor-evidence' : undefined,
|
|
44
|
+
record?.computedPropertyBoundLiteral ? 'runtime-order-effect-target-merge-requires-bound-computed-literal-key-evidence' : undefined,
|
|
45
|
+
record?.computedPropertyStatic ? 'runtime-order-effect-target-merge-requires-computed-literal-key-evidence' : undefined,
|
|
46
|
+
record?.computedPropertyDynamic ? 'runtime-order-effect-target-merge-requires-dynamic-computed-key-evidence' : undefined,
|
|
47
|
+
record?.computedProperty ? 'runtime-order-effect-target-merge-requires-computed-key-evidence' : undefined,
|
|
48
|
+
record?.optionalCall ? 'runtime-order-effect-target-merge-requires-nullish-boundary-evidence' : undefined
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function effectFactKind(group) { return (group?.factKinds ?? []).find(Boolean) ?? 'effect'; }
|
|
53
|
+
|
|
54
|
+
function effectTargetRecord(expression, context = {}) {
|
|
55
|
+
const text = String(expression ?? '');
|
|
56
|
+
const tagged = taggedTemplateTarget(text, context);
|
|
57
|
+
if (tagged) return tagged;
|
|
58
|
+
const call = /\b(new\s+)?([A-Za-z_$][\w$]*(?:(?:\s*(?:\.|\?\.)\s*[A-Za-z_$][\w$]*)|\s*(?:\?\.)?\[[^\]]+\])*)\s*(\?\.)?\s*\(/.exec(text);
|
|
59
|
+
if (!call) return undefined;
|
|
60
|
+
const targetText = normalizeTargetText(call[2]);
|
|
61
|
+
const parts = targetParts(targetText, context.literalBindings);
|
|
62
|
+
return targetRecord(statementText(text, call.index), targetText, {
|
|
63
|
+
calleeName: parts.calleeName,
|
|
64
|
+
receiverText: parts.receiverText,
|
|
65
|
+
constructorCall: Boolean(call[1]),
|
|
66
|
+
optionalCall: Boolean(call[3]) || /\?\./.test(targetText)
|
|
67
|
+
}, context);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function effectTokenRecord(expression, context = {}) {
|
|
71
|
+
const match = /\b(import\s*\.\s*meta|localStorage|sessionStorage|indexedDB|caches|cookie|console|process|Deno|Bun|document|window|navigator|location|history)(?:(?:\s*(?:\.|\?\.)\s*[A-Za-z_$][\w$]*)|\s*(?:\?\.)?\[[^\]]+\])*/.exec(String(expression ?? ''));
|
|
72
|
+
return match ? targetRecord(statementText(expression, match.index), normalizeTargetText(match[0]), {}, context) : undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function taggedTemplateTarget(expression, context = {}) {
|
|
76
|
+
const match = /([A-Za-z_$][\w$]*(?:(?:\s*\.\s*[A-Za-z_$][\w$]*)|\s*\[[^\]]+\])*)\s*`/.exec(String(expression ?? ''));
|
|
77
|
+
if (!match) return undefined;
|
|
78
|
+
const targetText = normalizeTargetText(match[1]);
|
|
79
|
+
const parts = targetParts(targetText, context.literalBindings);
|
|
80
|
+
return targetRecord(statementText(expression, match.index), targetText, {
|
|
81
|
+
taggedTemplate: true,
|
|
82
|
+
calleeName: parts.calleeName,
|
|
83
|
+
receiverText: parts.receiverText
|
|
84
|
+
}, context);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function targetRecord(text, targetText, extra = {}, context = {}) {
|
|
88
|
+
const computedProperties = computedPropertySegments(targetText, context.literalBindings);
|
|
89
|
+
const literalComputedProperties = computedProperties.filter((entry) => entry.static);
|
|
90
|
+
const boundLiteralComputedProperties = computedProperties.filter((entry) => entry.boundLiteral);
|
|
91
|
+
return compactRecord({
|
|
92
|
+
text: normalizeOrderEvidenceText(text),
|
|
93
|
+
targetText,
|
|
94
|
+
targetRoot: targetRoot(targetText),
|
|
95
|
+
computedProperty: computedProperties.length > 0 || undefined,
|
|
96
|
+
computedPropertyKeys: literalComputedProperties.map((entry) => entry.key),
|
|
97
|
+
computedPropertyStatic: computedProperties.length > 0 && literalComputedProperties.length === computedProperties.length || undefined,
|
|
98
|
+
computedPropertyDynamic: computedProperties.length > literalComputedProperties.length || undefined,
|
|
99
|
+
computedPropertyCount: computedProperties.length || undefined,
|
|
100
|
+
computedPropertyStaticCount: literalComputedProperties.length || undefined,
|
|
101
|
+
computedPropertyBoundLiteral: boundLiteralComputedProperties.length > 0 || undefined,
|
|
102
|
+
computedPropertyBindingNames: boundLiteralComputedProperties.map((entry) => entry.bindingName),
|
|
103
|
+
computedPropertyBindingKinds: uniqueStrings(boundLiteralComputedProperties.map((entry) => entry.bindingKind)),
|
|
104
|
+
computedPropertyRuntimeEquivalenceClaim: computedProperties.length > 0 ? false : undefined,
|
|
105
|
+
...extra
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function targetParts(targetText, literalBindings = new Map()) {
|
|
110
|
+
const normalized = String(targetText ?? '');
|
|
111
|
+
const computedTarget = /^(.*?)(?:\?\.)?\[([^\]]+)\]$/.exec(normalized);
|
|
112
|
+
if (computedTarget) return { calleeName: computedPropertyKey(computedTarget[2], literalBindings)?.key, receiverText: computedTarget[1] || undefined };
|
|
113
|
+
const memberTarget = /^(.*?)(?:\.|\?\.)?([A-Za-z_$][\w$]*)$/.exec(normalized);
|
|
114
|
+
return memberTarget ? { calleeName: memberTarget[2], receiverText: memberTarget[1] || undefined } : {};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function statementText(line, start) { return String(line ?? '').slice(Math.max(0, start), statementEnd(line, start)); }
|
|
118
|
+
function statementEnd(line, start) { const semicolon = String(line ?? '').indexOf(';', start); return semicolon === -1 ? String(line ?? '').length : semicolon + 1; }
|
|
119
|
+
function normalizeTargetText(value) { return normalizeOrderEvidenceText(String(value ?? '').replace(/\s*(?:\.|\?\.)\s*/g, (match) => match.includes('?.') ? '?.' : '.').replace(/\s*\[\s*/g, '[').replace(/\s*\]\s*/g, ']')); }
|
|
120
|
+
function targetRoot(targetText) { return /^[A-Za-z_$][\w$]*/.exec(targetText)?.[0]; }
|
|
121
|
+
function computedPropertySegments(targetText, literalBindings = new Map()) { return [...String(targetText ?? '').matchAll(/\[([^\]]+)\]/g)].map((match) => { const expression = normalizeOrderEvidenceText(match[1]); const key = computedPropertyKey(expression, literalBindings); return compactRecord({ expression, key: key?.key, static: key?.key !== undefined || undefined, boundLiteral: key?.boundLiteral, bindingName: key?.bindingName, bindingKind: key?.bindingKind }); }); }
|
|
122
|
+
function computedPropertyKey(expression, literalBindings) { const literal = literalComputedPropertyKey(expression); if (literal !== undefined) return { key: literal }; const bound = literalBindings.get(expression); return bound ? { key: bound.value, boundLiteral: true, bindingName: expression, bindingKind: bound.kind } : undefined; }
|
|
123
|
+
function literalComputedPropertyKey(expression) { const quoted = /^(['"`])((?:\\.|(?!\1)[\s\S])*)\1$/.exec(String(expression ?? '')); if (quoted && !quoted[2].includes('${')) return quoted[2].replace(/\\([\\'"`])/g, '$1'); return /^(?:0|[1-9]\d*)$/.test(expression) ? expression : undefined; }
|
|
124
|
+
function sameScopeLiteralBindings(lines, lineNumber, line, start) {
|
|
125
|
+
const before = Array.isArray(lines) ? sameBlockPrefix(lines, lineNumber, line, start) : String(line ?? '').slice(0, start);
|
|
126
|
+
const bindings = new Map();
|
|
127
|
+
for (const match of before.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*(['"`])((?:\\.|(?!\2)[\s\S])*)\2\s*;?/g)) {
|
|
128
|
+
if (!match[3].includes('${')) bindings.set(match[1], { value: match[3].replace(/\\([\\'"`])/g, '$1'), kind: 'same-scope-const-literal' });
|
|
129
|
+
}
|
|
130
|
+
return bindings;
|
|
131
|
+
}
|
|
132
|
+
function sameBlockPrefix(lines, lineNumber, line, start) {
|
|
133
|
+
const prefix = [String(line ?? '').slice(0, start)];
|
|
134
|
+
for (let index = lineNumber - 2; index >= 0 && prefix.length < 20; index -= 1) {
|
|
135
|
+
const previous = String(lines[index] ?? '');
|
|
136
|
+
if (/^\s*}/.test(previous)) break;
|
|
137
|
+
prefix.unshift(previous);
|
|
138
|
+
if (previous.includes('{')) break;
|
|
139
|
+
}
|
|
140
|
+
return prefix.join('\n');
|
|
141
|
+
}
|
|
142
|
+
function normalizeOrderEvidenceText(value) { return String(value ?? '').replace(/\s+/g, ' ').trim(); }
|
|
143
|
+
function uniqueStrings(values) { return [...new Set((values ?? []).filter(Boolean).map(String))]; }
|
|
144
|
+
function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined && (!Array.isArray(value) || value.length > 0))); }
|
|
145
|
+
export { effectTargetContextReasonCodes, effectTargetOrderEvidence, effectTargetSignatureEvidence };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function exitCompletionOrderEvidence(lines, lineNumber) {
|
|
2
|
+
if (!Array.isArray(lines) || !Number.isFinite(Number(lineNumber))) return [];
|
|
3
|
+
const line = String(lines[Number(lineNumber) - 1] ?? '');
|
|
4
|
+
const record = exitCompletionRecord(line, Number(lineNumber));
|
|
5
|
+
return record ? [record] : [];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function exitCompletionRecord(line, lineNumber) {
|
|
9
|
+
const match = /\b(return|yield)\b\s*(\*)?/.exec(String(line ?? ''));
|
|
10
|
+
if (!match) return undefined;
|
|
11
|
+
const text = normalizeOrderEvidenceText(line.slice(match.index, statementEnd(line, match.index)));
|
|
12
|
+
const expressionStart = match.index + match[0].length;
|
|
13
|
+
const delegated = match[1] === 'yield' && Boolean(match[2]);
|
|
14
|
+
const expressionText = normalizeOrderEvidenceText(line.slice(expressionStart, statementEnd(line, match.index)).replace(/;$/, ''));
|
|
15
|
+
return compactRecord({
|
|
16
|
+
kind: match[1],
|
|
17
|
+
line: lineNumber,
|
|
18
|
+
delegated: delegated || undefined,
|
|
19
|
+
delegationKind: delegated ? 'iterator-delegation' : undefined,
|
|
20
|
+
text,
|
|
21
|
+
expressionText,
|
|
22
|
+
delegatedIterableText: delegated ? expressionText : undefined,
|
|
23
|
+
iteratorProtocolEquivalenceClaim: delegated ? false : undefined,
|
|
24
|
+
delegatedCompletionPropagationClaim: delegated ? false : undefined
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function normalizeOrderEvidenceText(value) { return String(value ?? '').replace(/\s+/g, ' ').trim(); }
|
|
29
|
+
function statementEnd(line, start) { const semicolon = String(line ?? '').indexOf(';', start); return semicolon === -1 ? String(line ?? '').length : semicolon + 1; }
|
|
30
|
+
function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined && value !== '')); }
|
|
31
|
+
|
|
32
|
+
export { exitCompletionOrderEvidence };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { uniqueStrings } from './native-import-utils.js';
|
|
2
|
+
|
|
3
|
+
function importMetaHostContextEvidence(expressionText, evidence = {}) {
|
|
4
|
+
const importMetaHostContext = importMetaHostContextRecords(expressionText);
|
|
5
|
+
if (!importMetaHostContext.length) return evidence;
|
|
6
|
+
return compactRecord({
|
|
7
|
+
...evidence,
|
|
8
|
+
hostContext: 'import.meta',
|
|
9
|
+
importMetaHostContext,
|
|
10
|
+
importMetaMemberNames: uniqueStrings(importMetaHostContext.map((record) => record.memberName))
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function importMetaHostContextRecords(expressionText) {
|
|
15
|
+
return [...String(expressionText ?? '').matchAll(/\bimport\s*\.\s*meta((?:\s*\.\s*[A-Za-z_$][\w$]*)*)/g)]
|
|
16
|
+
.map((match, ordinal) => {
|
|
17
|
+
const memberPath = uniqueStrings([...String(match[1] ?? '').matchAll(/\.\s*([A-Za-z_$][\w$]*)/g)]
|
|
18
|
+
.map((item) => item[1]));
|
|
19
|
+
return compactRecord({
|
|
20
|
+
kind: 'import-meta',
|
|
21
|
+
ordinal: ordinal + 1,
|
|
22
|
+
text: match[0].replace(/\s+/g, ' ').trim(),
|
|
23
|
+
memberName: memberPath[0],
|
|
24
|
+
memberPath
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function compactRecord(record) {
|
|
30
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined && (!Array.isArray(value) || value.length > 0)));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { importMetaHostContextEvidence, importMetaHostContextRecords };
|