@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
|
@@ -6,6 +6,7 @@ import { normalizeNativeDiffImport } from './normalizeNativeDiffImport.js';
|
|
|
6
6
|
import { replayReplacementText } from './replaySemanticEditLineEndings.js';
|
|
7
7
|
import { replayDiagnostics, replayEditDiagnostics, replayEditsWithOverlapDiagnostics } from './semanticEditReplayDiagnostics.js';
|
|
8
8
|
import { explicitSourceReplacementReplayRange } from './semanticEditReplaySourceReplacement.js';
|
|
9
|
+
import { semanticReplayProofRoute } from '../../js-ts-safe-project-merge-semantic-replay-routes.js';
|
|
9
10
|
import {
|
|
10
11
|
findCurrentSymbol,
|
|
11
12
|
findInsertionAnchor,
|
|
@@ -14,6 +15,8 @@ import {
|
|
|
14
15
|
insertionRange
|
|
15
16
|
} from './semanticEditReplayAnchors.js';
|
|
16
17
|
import { bodyContentRange, removalRange, spanOffsets } from './semanticEditSourceRanges.js';
|
|
18
|
+
import { replayOutputBinding, replayOutputSource } from './semanticEditReplayOutputBinding.js';
|
|
19
|
+
import { isRerunnableStaleReasonCode, replayRerunRoute } from './semanticEditReplayRerunRoute.js';
|
|
17
20
|
|
|
18
21
|
export function replaySemanticEditProjection(input = {}) {
|
|
19
22
|
const projection = input.projection ?? input.semanticEditProjection;
|
|
@@ -21,9 +24,9 @@ export function replaySemanticEditProjection(input = {}) {
|
|
|
21
24
|
const currentSourceText = input.currentSourceText ?? input.headSourceText;
|
|
22
25
|
const sourcePath = input.currentSourcePath ?? input.headSourcePath ?? projection.sourcePath;
|
|
23
26
|
const language = normalizeNativeLanguageId(input.language ?? projection.language);
|
|
24
|
-
const
|
|
27
|
+
const baseReasons = baseReasonCodes(projection, currentSourceText);
|
|
25
28
|
const currentHash = typeof currentSourceText === 'string' ? hashSemanticValue(currentSourceText) : undefined;
|
|
26
|
-
if (input.currentSourceHash && currentHash !== input.currentSourceHash)
|
|
29
|
+
if (input.currentSourceHash && currentHash !== input.currentSourceHash) baseReasons.push('current-source-hash-mismatch');
|
|
27
30
|
const currentSymbols = currentSourceText && language
|
|
28
31
|
? currentSymbolIndex({ currentSourceText, sourcePath, language, parser: input.parser })
|
|
29
32
|
: [];
|
|
@@ -35,8 +38,28 @@ export function replaySemanticEditProjection(input = {}) {
|
|
|
35
38
|
}))
|
|
36
39
|
: [];
|
|
37
40
|
const edits = replayEditsWithOverlapDiagnostics(replayedEdits);
|
|
41
|
+
const replayedStatus = replayStatus(baseReasons, edits, projection);
|
|
42
|
+
const replayedOutputSourceText = replayOutputSource(replayedStatus, currentSourceText, edits);
|
|
43
|
+
const replayedOutputHash = replayedOutputSourceText === undefined ? undefined : hashSemanticValue(replayedOutputSourceText);
|
|
44
|
+
const outputBinding = replayOutputBinding(input, replayedOutputSourceText, replayedOutputHash, { replayStatus: replayedStatus });
|
|
45
|
+
const reasonCodes = reasonList([...baseReasons, ...(outputBinding.reasonCodes ?? [])]);
|
|
38
46
|
const status = replayStatus(reasonCodes, edits, projection);
|
|
39
|
-
const outputSourceText =
|
|
47
|
+
const outputSourceText = outputBinding.status === 'failed' ? undefined : replayedOutputSourceText;
|
|
48
|
+
const outputHash = outputSourceText === undefined ? undefined : hashSemanticValue(outputSourceText);
|
|
49
|
+
const rerunRoute = replayRerunRoute(status, reasonCodes, input, currentHash);
|
|
50
|
+
const proofRoute = semanticReplayProofRoute(status, reasonCodes, rerunRoute, {
|
|
51
|
+
sourcePath,
|
|
52
|
+
replayId: input.id,
|
|
53
|
+
currentSourceHash: input.currentSourceHash,
|
|
54
|
+
currentHash,
|
|
55
|
+
outputHash,
|
|
56
|
+
outputBinding,
|
|
57
|
+
outputBindingStatus: outputBinding.status,
|
|
58
|
+
expectedOutputHash: outputBinding.expectedOutputHash,
|
|
59
|
+
projectionOutputHash: projection.projectedHash,
|
|
60
|
+
replayOutputHash: outputHash,
|
|
61
|
+
appliedOperations: edits.filter((edit) => edit.status === 'applied').map((edit) => edit.operationId).filter(Boolean)
|
|
62
|
+
});
|
|
40
63
|
const diagnostics = replayDiagnostics({
|
|
41
64
|
status,
|
|
42
65
|
reasonCodes,
|
|
@@ -56,19 +79,30 @@ export function replaySemanticEditProjection(input = {}) {
|
|
|
56
79
|
language,
|
|
57
80
|
currentHash,
|
|
58
81
|
projectedHash: projection.projectedHash,
|
|
59
|
-
outputHash
|
|
82
|
+
outputHash,
|
|
60
83
|
status,
|
|
61
84
|
edits,
|
|
62
85
|
appliedOperations: edits.filter((edit) => edit.status === 'applied').map((edit) => edit.operationId).filter(Boolean),
|
|
63
86
|
skippedOperations: edits.filter((edit) => edit.status !== 'applied').map((edit) => edit.operationId).filter(Boolean),
|
|
64
87
|
diagnostics,
|
|
65
|
-
admission: replayAdmission(status, reasonCodes, edits),
|
|
88
|
+
admission: replayAdmission(status, reasonCodes, edits, rerunRoute, proofRoute),
|
|
66
89
|
outputSourceText,
|
|
67
90
|
summary: replaySummary(edits, reasonCodes),
|
|
68
91
|
metadata: compactRecord({
|
|
69
92
|
autoMergeClaim: false,
|
|
70
93
|
semanticEquivalenceClaim: false,
|
|
71
94
|
anchorMode: currentSymbols.length ? 'javascript-like-symbols' : 'offsets',
|
|
95
|
+
structuralDiffId: projection.metadata?.structuralDiffId,
|
|
96
|
+
structuralDiffStatus: projection.metadata?.structuralDiffStatus,
|
|
97
|
+
structuralDiffSummary: projection.metadata?.structuralDiffSummary,
|
|
98
|
+
currentSourceBindingStatus: baseReasons.includes('current-source-hash-mismatch') ? 'stale' : input.currentSourceHash ? 'bound' : undefined,
|
|
99
|
+
expectedCurrentHash: input.currentSourceHash,
|
|
100
|
+
observedCurrentHash: currentHash,
|
|
101
|
+
rerunRoute,
|
|
102
|
+
proofRoute,
|
|
103
|
+
outputBindingStatus: outputBinding.status,
|
|
104
|
+
expectedOutputHash: outputBinding.expectedOutputHash,
|
|
105
|
+
replayedOutputHash: outputBinding.replayedOutputHash,
|
|
72
106
|
...input.metadata
|
|
73
107
|
})
|
|
74
108
|
};
|
|
@@ -165,6 +199,10 @@ function replayEditRecord(edit, status, range, reasonCodes, sourceText) {
|
|
|
165
199
|
semanticIdentityHash: edit.semanticIdentityHash,
|
|
166
200
|
sourceIdentityHash: edit.sourceIdentityHash,
|
|
167
201
|
editContentHash: edit.editContentHash,
|
|
202
|
+
structuralEditId: edit.structuralEditId,
|
|
203
|
+
structuralEditHash: edit.structuralEditHash,
|
|
204
|
+
structuralKind: edit.structuralKind,
|
|
205
|
+
structuralActions: edit.structuralActions,
|
|
168
206
|
editKind: edit.editKind,
|
|
169
207
|
editOrder: edit.editOrder,
|
|
170
208
|
sourceRangeKind: edit.sourceRangeKind,
|
|
@@ -207,7 +245,7 @@ function currentSymbolRangeLabel(edit) {
|
|
|
207
245
|
}
|
|
208
246
|
|
|
209
247
|
function replayStatus(reasonCodes, edits, projection) {
|
|
210
|
-
if (reasonCodes.length) return 'blocked';
|
|
248
|
+
if (reasonCodes.length) return reasonCodes.every(isRerunnableStaleReasonCode) ? 'stale' : 'blocked';
|
|
211
249
|
if (!edits.length && !(projection.edits ?? []).length) return 'evidence-only';
|
|
212
250
|
if (edits.some((edit) => edit.status === 'blocked')) return 'blocked';
|
|
213
251
|
if (edits.some((edit) => edit.status === 'conflict')) return 'conflict';
|
|
@@ -216,18 +254,20 @@ function replayStatus(reasonCodes, edits, projection) {
|
|
|
216
254
|
return edits.every((edit) => edit.status === 'applied' || edit.status === 'already-applied') ? 'accepted-clean' : 'needs-port';
|
|
217
255
|
}
|
|
218
256
|
|
|
219
|
-
function replayAdmission(status, reasonCodes, edits) {
|
|
257
|
+
function replayAdmission(status, reasonCodes, edits, rerunRoute, proofRoute) {
|
|
220
258
|
const apply = status === 'accepted-clean';
|
|
221
259
|
const skip = status === 'already-applied';
|
|
222
|
-
return {
|
|
260
|
+
return compactRecord({
|
|
223
261
|
status,
|
|
224
262
|
action: apply ? 'apply' : skip ? 'skip' : status === 'stale' ? 'rerun-semantic-import' : status === 'blocked' ? 'block' : 'human-review',
|
|
225
263
|
reviewRequired: !(apply || skip),
|
|
226
264
|
autoApplyCandidate: apply,
|
|
227
265
|
autoMergeClaim: false,
|
|
228
266
|
semanticEquivalenceClaim: false,
|
|
229
|
-
reasonCodes: reasonList([...reasonCodes, ...edits.flatMap((edit) => edit.reasonCodes ?? [])])
|
|
230
|
-
|
|
267
|
+
reasonCodes: reasonList([...reasonCodes, ...edits.flatMap((edit) => edit.reasonCodes ?? [])]),
|
|
268
|
+
rerunRoute,
|
|
269
|
+
proofRoute
|
|
270
|
+
});
|
|
231
271
|
}
|
|
232
272
|
|
|
233
273
|
function replaySummary(edits, reasonCodes) {
|
|
@@ -242,19 +282,6 @@ function replaySummary(edits, reasonCodes) {
|
|
|
242
282
|
};
|
|
243
283
|
}
|
|
244
284
|
|
|
245
|
-
function replayOutputSource(status, sourceText, edits) {
|
|
246
|
-
if (typeof sourceText !== 'string') return undefined;
|
|
247
|
-
if (status === 'already-applied') return sourceText;
|
|
248
|
-
if (status !== 'accepted-clean') return undefined;
|
|
249
|
-
return edits.filter((edit) => edit.status === 'applied')
|
|
250
|
-
.sort(replaySourceEditSort)
|
|
251
|
-
.reduce((text, edit) => text.slice(0, edit.start) + editReplacement(edit, edits) + text.slice(edit.end), sourceText);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function replaySourceEditSort(left, right) {
|
|
255
|
-
return right.start - left.start || right.end - left.end || (right.editOrder ?? 0) - (left.editOrder ?? 0);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
285
|
function projectionEditWithOrder(edit, index) {
|
|
259
286
|
return {
|
|
260
287
|
...edit,
|
|
@@ -266,10 +293,6 @@ function projectionEditWithOrder(edit, index) {
|
|
|
266
293
|
};
|
|
267
294
|
}
|
|
268
295
|
|
|
269
|
-
function editReplacement(edit, edits) {
|
|
270
|
-
return edits.find((candidate) => candidate.operationId === edit.operationId)?.replacementText ?? '';
|
|
271
|
-
}
|
|
272
|
-
|
|
273
296
|
function baseReasonCodes(projection, currentSourceText) {
|
|
274
297
|
return reasonList([
|
|
275
298
|
projection.status !== 'projected' ? 'projection-not-projected' : undefined,
|
|
@@ -278,18 +301,9 @@ function baseReasonCodes(projection, currentSourceText) {
|
|
|
278
301
|
]);
|
|
279
302
|
}
|
|
280
303
|
|
|
281
|
-
function sameRange(left, right) {
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function rangesOverlap(left, right) {
|
|
286
|
-
return Boolean(left && right && left.start < right.end && right.start < left.end);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function containedRange(inner, outer) {
|
|
290
|
-
return Boolean(inner && outer && outer.start <= inner.start && inner.end <= outer.end);
|
|
291
|
-
}
|
|
292
|
-
|
|
304
|
+
function sameRange(left, right) { return left?.start === right?.start && left?.end === right?.end; }
|
|
305
|
+
function rangesOverlap(left, right) { return Boolean(left && right && left.start < right.end && right.start < left.end); }
|
|
306
|
+
function containedRange(inner, outer) { return Boolean(inner && outer && outer.start <= inner.start && inner.end <= outer.end); }
|
|
293
307
|
function reasonList(values) { return uniqueStrings((values ?? []).filter(Boolean)); }
|
|
294
308
|
function lineEndingStableText(value) {
|
|
295
309
|
if (typeof value !== 'string') return undefined;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { uniqueStrings } from '../../native-import-utils.js';
|
|
2
|
+
import {
|
|
3
|
+
runtimeOrderProofSurfaceReasonCodes,
|
|
4
|
+
runtimeOrderSurfaceExpectations
|
|
5
|
+
} from './runtimeOrderProofSurfaces.js';
|
|
6
|
+
|
|
7
|
+
const RuntimeOrderProofSchema = 'frontier.lang.runtimeOrderProofEvidence.v1';
|
|
8
|
+
const RuntimeOrderProofKind = 'frontier.lang.runtimeOrderProofEvidence';
|
|
9
|
+
const PassedStatuses = new Set(['passed', 'verified']);
|
|
10
|
+
|
|
11
|
+
function runtimeOrderEvidenceBinding(input) {
|
|
12
|
+
const candidates = runtimeOrderEvidenceCandidates(input?.scriptInput);
|
|
13
|
+
if (!candidates.length) return { passed: false, evidenceIds: [], reasonCodes: [] };
|
|
14
|
+
const results = candidates.map((candidate) => validateRuntimeOrderEvidence(candidate, input));
|
|
15
|
+
const passed = results.filter((result) => result.passed);
|
|
16
|
+
if (passed.length) {
|
|
17
|
+
return {
|
|
18
|
+
passed: true,
|
|
19
|
+
evidenceIds: uniqueStrings(passed.flatMap((result) => result.evidenceIds)),
|
|
20
|
+
reasonCodes: []
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
passed: false,
|
|
25
|
+
evidenceIds: [],
|
|
26
|
+
reasonCodes: uniqueStrings(results.flatMap((result) => result.reasonCodes))
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function validateRuntimeOrderEvidence(candidate, input) {
|
|
31
|
+
if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate)) {
|
|
32
|
+
return invalid(['runtime-order-explicit-evidence-structured-record-required']);
|
|
33
|
+
}
|
|
34
|
+
const expected = expectedRuntimeOrderBinding(input);
|
|
35
|
+
const reasonCodes = [];
|
|
36
|
+
if (!PassedStatuses.has(String(candidate.status ?? ''))) reasonCodes.push('runtime-order-explicit-evidence-status-not-passed');
|
|
37
|
+
if (candidate.schema !== RuntimeOrderProofSchema && candidate.kind !== RuntimeOrderProofKind) reasonCodes.push('runtime-order-explicit-evidence-schema-missing');
|
|
38
|
+
if (!fieldMatches(candidate.sourcePath, [expected.sourcePath])) reasonCodes.push('runtime-order-explicit-evidence-source-path-mismatch');
|
|
39
|
+
if (!sourceHashMatches(candidate, expected)) reasonCodes.push('runtime-order-explicit-evidence-source-hash-mismatch');
|
|
40
|
+
if (!regionIdentityMatches(candidate, expected)) reasonCodes.push('runtime-order-explicit-evidence-region-identity-mismatch');
|
|
41
|
+
if (!fieldMatches(candidate.regionKind, [expected.regionKind])) reasonCodes.push('runtime-order-explicit-evidence-region-kind-mismatch');
|
|
42
|
+
if (!runtimeKindMatches(candidate, expected)) reasonCodes.push('runtime-order-explicit-evidence-runtime-kind-mismatch');
|
|
43
|
+
if (expected.signatureHashes.length && !fieldMatches(candidate.signatureHash, expected.signatureHashes)) reasonCodes.push('runtime-order-explicit-evidence-signature-hash-mismatch');
|
|
44
|
+
if (candidate.autoMergeClaim !== false || candidate.semanticEquivalenceClaim !== false || candidate.runtimeEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
45
|
+
reasonCodes.push(...runtimeOrderProofSurfaceReasonCodes(candidate, expected));
|
|
46
|
+
if (reasonCodes.length) return invalid(reasonCodes);
|
|
47
|
+
return {
|
|
48
|
+
passed: true,
|
|
49
|
+
evidenceIds: uniqueStrings([candidate.id, candidate.evidenceId, ...(array(candidate.evidenceIds))]),
|
|
50
|
+
reasonCodes: []
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function expectedRuntimeOrderBinding(input) {
|
|
55
|
+
const region = input?.region ?? {};
|
|
56
|
+
const regionKey = region.key ?? stripRegionPrefix(region.conflictKey) ?? input?.anchorKey;
|
|
57
|
+
const sourcePath = region.sourcePath ?? region.sourceSpan?.path ?? input?.context?.workerChangeSet?.sourcePath;
|
|
58
|
+
return {
|
|
59
|
+
sourcePath,
|
|
60
|
+
sourceHashes: uniqueStrings([input?.context?.workerChangeSet?.afterHash, input?.context?.headChangeSet?.afterHash]),
|
|
61
|
+
stageHashes: {
|
|
62
|
+
baseSourceHash: input?.context?.workerChangeSet?.beforeHash,
|
|
63
|
+
workerSourceHash: input?.context?.workerChangeSet?.afterHash,
|
|
64
|
+
headSourceHash: input?.context?.headChangeSet?.afterHash
|
|
65
|
+
},
|
|
66
|
+
regionKeys: uniqueStrings([regionKey, region.key, stripRegionPrefix(region.conflictKey), input?.anchorKey, region.id]),
|
|
67
|
+
conflictKeys: uniqueStrings([region.conflictKey, regionKey ? `region:${regionKey}` : undefined]),
|
|
68
|
+
runtimeIdentityKeys: uniqueStrings([runtimeIdentityKey(region)]),
|
|
69
|
+
regionKind: runtimeRegionKind(region, input?.baseSymbol),
|
|
70
|
+
runtimeKinds: runtimeKinds(region),
|
|
71
|
+
...runtimeOrderSurfaceExpectations(region),
|
|
72
|
+
signatureHashes: uniqueStrings([
|
|
73
|
+
region.signatureHash,
|
|
74
|
+
input?.baseSymbol?.signatureHash,
|
|
75
|
+
input?.baseSymbol?.beforeSignatureHash,
|
|
76
|
+
input?.baseSymbol?.afterSignatureHash,
|
|
77
|
+
input?.workerSymbol?.signatureHash,
|
|
78
|
+
input?.workerSymbol?.beforeSignatureHash,
|
|
79
|
+
input?.workerSymbol?.afterSignatureHash,
|
|
80
|
+
input?.headSymbol?.signatureHash
|
|
81
|
+
])
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function runtimeOrderEvidenceCandidates(input = {}) {
|
|
86
|
+
return [
|
|
87
|
+
...array(input.runtimeOrderEvidence),
|
|
88
|
+
...array(input.effectOrderEvidence),
|
|
89
|
+
...array(input.metadata?.runtimeOrderEvidence),
|
|
90
|
+
...array(input.metadata?.effectOrderEvidence),
|
|
91
|
+
...array(input.evidence).filter(isRuntimeProofLike)
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function isRuntimeProofLike(value) {
|
|
96
|
+
return value === true || value?.schema === RuntimeOrderProofSchema || value?.kind === RuntimeOrderProofKind;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function sourceHashMatches(candidate, expected) {
|
|
100
|
+
const stageEntries = Object.entries(expected.stageHashes).filter(([, value]) => value);
|
|
101
|
+
const hasStageHashProof = stageEntries.length && stageEntries.every(([field, value]) => candidate[field] === value);
|
|
102
|
+
return hasStageHashProof || fieldMatches(candidate.sourceHash, expected.sourceHashes);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function regionIdentityMatches(candidate, expected) {
|
|
106
|
+
return fieldMatches(candidate.regionKey, expected.regionKeys)
|
|
107
|
+
|| fieldMatches(stripRegionPrefix(candidate.conflictKey), expected.regionKeys)
|
|
108
|
+
|| fieldMatches(candidate.conflictKey, expected.conflictKeys)
|
|
109
|
+
|| fieldMatches(candidate.runtimeIdentityKey, expected.runtimeIdentityKeys);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function runtimeKindMatches(candidate, expected) {
|
|
113
|
+
const candidateKinds = uniqueStrings([candidate.runtimeKind, ...array(candidate.runtimeKinds)]);
|
|
114
|
+
return candidateKinds.length > 0 && candidateKinds.some((kind) => expected.runtimeKinds.includes(kind));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function runtimeKinds(region) {
|
|
118
|
+
return uniqueStrings([
|
|
119
|
+
...array(region?.runtimeKinds),
|
|
120
|
+
...array(region?.runtimeKind),
|
|
121
|
+
...array(region?.metadata?.factKinds),
|
|
122
|
+
...array(region?.metadata?.factKind),
|
|
123
|
+
...array(factSignatureFromSymbolName(region?.symbolName, runtimeRegionKind(region)))
|
|
124
|
+
].flatMap((kind) => String(kind ?? '').split('+')).filter(Boolean));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function runtimeIdentityKey(region) {
|
|
128
|
+
return stableKey(['runtime-region', region?.sourcePath, region?.symbolName, region?.regionKind, region?.runtimeKind, region?.ordinal]);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function runtimeRegionKind(region, symbol) { return String(region?.regionKind ?? symbol?.ownershipRegionKind ?? ''); }
|
|
132
|
+
function factSignatureFromSymbolName(symbolName, regionKind) {
|
|
133
|
+
const marker = `:${regionKind}:`;
|
|
134
|
+
const text = String(symbolName ?? '');
|
|
135
|
+
const markerIndex = text.indexOf(marker);
|
|
136
|
+
if (markerIndex < 0) return undefined;
|
|
137
|
+
return text.slice(markerIndex + marker.length).replace(/#\d+$/, '') || undefined;
|
|
138
|
+
}
|
|
139
|
+
function fieldMatches(value, expectedValues) { return value !== undefined && value !== null && expectedValues.includes(String(value)); }
|
|
140
|
+
function stableKey(parts) {
|
|
141
|
+
const values = parts.map((part) => part === undefined || part === null ? '' : String(part));
|
|
142
|
+
return values.some(Boolean) ? values.join('#') : undefined;
|
|
143
|
+
}
|
|
144
|
+
function stripRegionPrefix(value) {
|
|
145
|
+
const text = String(value ?? '');
|
|
146
|
+
return text.startsWith('region:') ? text.slice('region:'.length) : text || undefined;
|
|
147
|
+
}
|
|
148
|
+
function invalid(reasonCodes) { return { passed: false, evidenceIds: [], reasonCodes }; }
|
|
149
|
+
function array(value) { return value === undefined || value === null ? [] : Array.isArray(value) ? value : [value]; }
|
|
150
|
+
|
|
151
|
+
export { runtimeOrderEvidenceBinding };
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { uniqueStrings } from '../../native-import-utils.js';
|
|
3
|
+
|
|
4
|
+
function runtimeOrderSurfaceExpectations(region) {
|
|
5
|
+
const resourceOrderRecords = resourceManagementOrderRecords(region);
|
|
6
|
+
const generatorRecords = generatorProtocolRecords(region);
|
|
7
|
+
const promiseCombinatorRecords = promiseCombinatorOrderRecords(region);
|
|
8
|
+
const promiseChainRecords = promiseChainOrderRecords(region);
|
|
9
|
+
const generatorKinds = runtimeKinds(region);
|
|
10
|
+
return {
|
|
11
|
+
importMetaHostContextHash: importMetaHostContextHash(region),
|
|
12
|
+
promiseCombinatorOrderHash: promiseCombinatorOrderHash(region, promiseCombinatorRecords),
|
|
13
|
+
promiseCombinatorNeedsElementTrace: promiseCombinatorRecords.some((record) => record.arrayElementOrdinal),
|
|
14
|
+
promiseCombinatorMethods: uniqueStrings(promiseCombinatorRecords.map((record) => record.methodName)),
|
|
15
|
+
promiseChainOrderHash: promiseChainOrderHash(region, promiseChainRecords),
|
|
16
|
+
promiseChainNeedsRejectionTrace: promiseChainRecords.some((record) => record.hasCatch),
|
|
17
|
+
promiseChainNeedsFinalizerTrace: promiseChainRecords.some((record) => record.hasFinally),
|
|
18
|
+
resourceManagementOrderHash: resourceManagementOrderHash(region, resourceOrderRecords),
|
|
19
|
+
resourceManagementNeedsAsyncTrace: resourceOrderRecords.some((record) => record.awaitUsing || record.declarationKind === 'await-using'),
|
|
20
|
+
generatorProtocolOrderHash: generatorProtocolOrderHash(region, generatorRecords),
|
|
21
|
+
generatorProtocolNeedsIteratorTrace: generatorRecords.some((record) => record.delegated),
|
|
22
|
+
generatorProtocolNeedsAsyncIteratorTrace: generatorKinds.includes('async') && (generatorKinds.includes('generator') || generatorRecords.length > 0),
|
|
23
|
+
classStaticBlockOrderHash: classStaticBlockOrderHash(region),
|
|
24
|
+
topLevelAwaitOrderHash: topLevelAwaitOrderHash(region)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function runtimeOrderProofSurfaceReasonCodes(candidate, expected) {
|
|
29
|
+
return uniqueStrings([
|
|
30
|
+
...importMetaHostContextProofReasonCodes(candidate, expected),
|
|
31
|
+
...promiseCombinatorProofReasonCodes(candidate, expected),
|
|
32
|
+
...promiseChainProofReasonCodes(candidate, expected),
|
|
33
|
+
...resourceManagementProofReasonCodes(candidate, expected),
|
|
34
|
+
...generatorProtocolProofReasonCodes(candidate, expected),
|
|
35
|
+
...classStaticBlockProofReasonCodes(candidate, expected),
|
|
36
|
+
...topLevelAwaitProofReasonCodes(candidate, expected)
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function importMetaHostContextProofReasonCodes(candidate, expected) {
|
|
41
|
+
if (!expected.runtimeKinds.includes('host-context') && !expected.importMetaHostContextHash) return [];
|
|
42
|
+
const reasonCodes = [];
|
|
43
|
+
if (candidate.importMetaHostContextEquivalenceClaim !== false || candidate.hostRuntimeResolutionEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
44
|
+
const contextHash = firstString(candidate.importMetaHostContextHash, candidate.hostContextMemberHash);
|
|
45
|
+
if (expected.importMetaHostContextHash && !contextHash) reasonCodes.push('runtime-order-explicit-evidence-import-meta-host-context-hash-missing');
|
|
46
|
+
else if (expected.importMetaHostContextHash && contextHash !== expected.importMetaHostContextHash) reasonCodes.push('runtime-order-explicit-evidence-import-meta-host-context-hash-mismatch');
|
|
47
|
+
if (!firstString(candidate.importMetaHostResolutionTraceHash, candidate.hostContextResolutionTraceHash, candidate.importMetaHostRuntimeTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-import-meta-host-context-trace-missing');
|
|
48
|
+
return reasonCodes;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function promiseCombinatorProofReasonCodes(candidate, expected) {
|
|
52
|
+
if (!expected.promiseCombinatorOrderHash) return [];
|
|
53
|
+
const reasonCodes = [];
|
|
54
|
+
if (candidate.promiseCombinatorRuntimeEquivalenceClaim !== false || candidate.promiseConcurrencyEquivalenceClaim !== false || candidate.promiseSettlementEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
55
|
+
if (expected.promiseCombinatorNeedsElementTrace && candidate.promiseElementOrderEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
56
|
+
const orderHash = firstString(candidate.promiseCombinatorOrderHash, candidate.promiseConcurrencyOrderHash);
|
|
57
|
+
if (!orderHash) reasonCodes.push('runtime-order-explicit-evidence-promise-combinator-order-hash-missing');
|
|
58
|
+
else if (orderHash !== expected.promiseCombinatorOrderHash) reasonCodes.push('runtime-order-explicit-evidence-promise-combinator-order-hash-mismatch');
|
|
59
|
+
if (!firstString(candidate.promiseCombinatorConcurrencyTraceHash, candidate.promiseConcurrencyTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-combinator-concurrency-trace-missing');
|
|
60
|
+
if (!firstString(candidate.promiseCombinatorSettlementTraceHash, candidate.promiseSettlementTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-combinator-settlement-trace-missing');
|
|
61
|
+
if (expected.promiseCombinatorNeedsElementTrace && !firstString(candidate.promiseCombinatorElementOrderTraceHash, candidate.promiseElementOrderTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-combinator-element-order-trace-missing');
|
|
62
|
+
if (expected.promiseCombinatorMethods.includes('all') && !firstString(candidate.promiseAllSettlementTraceHash, candidate.promiseCombinatorAllSettlementTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-all-settlement-trace-missing');
|
|
63
|
+
if (expected.promiseCombinatorMethods.includes('allSettled') && !firstString(candidate.promiseAllSettledRecordTraceHash, candidate.promiseCombinatorAllSettledRecordTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-all-settled-record-trace-missing');
|
|
64
|
+
if (expected.promiseCombinatorMethods.includes('race') && !firstString(candidate.promiseRaceFirstSettlementTraceHash, candidate.promiseCombinatorRaceFirstSettlementTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-race-first-settlement-trace-missing');
|
|
65
|
+
if (expected.promiseCombinatorMethods.includes('any') && !firstString(candidate.promiseAnyFirstFulfillmentTraceHash, candidate.promiseCombinatorAnyFirstFulfillmentTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-any-first-fulfillment-trace-missing');
|
|
66
|
+
return reasonCodes;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function promiseChainProofReasonCodes(candidate, expected) {
|
|
70
|
+
if (!expected.promiseChainOrderHash) return [];
|
|
71
|
+
const reasonCodes = [];
|
|
72
|
+
if (candidate.promiseChainRuntimeEquivalenceClaim !== false || candidate.promiseHandlerExecutionEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
73
|
+
if (expected.promiseChainNeedsRejectionTrace && candidate.promiseRejectionFlowEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
74
|
+
if (expected.promiseChainNeedsFinalizerTrace && candidate.promiseFinalizerEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
75
|
+
const orderHash = firstString(candidate.promiseChainOrderHash, candidate.promiseHandlerOrderHash);
|
|
76
|
+
if (!orderHash) reasonCodes.push('runtime-order-explicit-evidence-promise-chain-order-hash-missing');
|
|
77
|
+
else if (orderHash !== expected.promiseChainOrderHash) reasonCodes.push('runtime-order-explicit-evidence-promise-chain-order-hash-mismatch');
|
|
78
|
+
if (!firstString(candidate.promiseChainHandlerOrderTraceHash, candidate.promiseHandlerOrderTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-chain-handler-order-trace-missing');
|
|
79
|
+
if (expected.promiseChainNeedsRejectionTrace && !firstString(candidate.promiseChainRejectionFlowTraceHash, candidate.promiseRejectionFlowTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-chain-rejection-flow-trace-missing');
|
|
80
|
+
if (expected.promiseChainNeedsFinalizerTrace && !firstString(candidate.promiseChainFinalizerTraceHash, candidate.promiseFinalizerTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-promise-chain-finalizer-trace-missing');
|
|
81
|
+
return reasonCodes;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function resourceManagementProofReasonCodes(candidate, expected) {
|
|
85
|
+
if (!expected.runtimeKinds.includes('resource-management')) return [];
|
|
86
|
+
const reasonCodes = [];
|
|
87
|
+
if (candidate.disposalEffectEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
88
|
+
const orderHash = firstString(candidate.resourceManagementDisposalOrderHash, candidate.disposalOrderHash);
|
|
89
|
+
if (expected.resourceManagementOrderHash && !orderHash) reasonCodes.push('runtime-order-explicit-evidence-resource-management-disposal-order-hash-missing');
|
|
90
|
+
else if (expected.resourceManagementOrderHash && orderHash !== expected.resourceManagementOrderHash) reasonCodes.push('runtime-order-explicit-evidence-resource-management-disposal-order-hash-mismatch');
|
|
91
|
+
const asyncTraceHash = firstString(candidate.resourceManagementAsyncDisposalTraceHash, candidate.asyncDisposalTraceHash, candidate.disposalTraceHash);
|
|
92
|
+
if (expected.resourceManagementNeedsAsyncTrace && !asyncTraceHash) reasonCodes.push('runtime-order-explicit-evidence-resource-management-async-disposal-trace-missing');
|
|
93
|
+
return reasonCodes;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function generatorProtocolProofReasonCodes(candidate, expected) {
|
|
97
|
+
if (!expected.runtimeKinds.includes('generator') && !expected.generatorProtocolOrderHash) return [];
|
|
98
|
+
const reasonCodes = [];
|
|
99
|
+
if (candidate.generatorRuntimeEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
100
|
+
const orderHash = firstString(candidate.generatorProtocolOrderHash, candidate.iteratorProtocolOrderHash, candidate.asyncGeneratorProtocolOrderHash, candidate.asyncIteratorProtocolOrderHash);
|
|
101
|
+
if (expected.generatorProtocolOrderHash && !orderHash) reasonCodes.push('runtime-order-explicit-evidence-generator-protocol-order-hash-missing');
|
|
102
|
+
else if (expected.generatorProtocolOrderHash && orderHash !== expected.generatorProtocolOrderHash) reasonCodes.push('runtime-order-explicit-evidence-generator-protocol-order-hash-mismatch');
|
|
103
|
+
if (!firstString(candidate.generatorProtocolTraceHash, candidate.iteratorProtocolTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-generator-protocol-trace-missing');
|
|
104
|
+
if (expected.generatorProtocolNeedsAsyncIteratorTrace) {
|
|
105
|
+
if (!firstString(candidate.asyncGeneratorProtocolTraceHash, candidate.asyncIteratorProtocolTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-async-generator-protocol-trace-missing');
|
|
106
|
+
if (!firstString(candidate.asyncGeneratorCancellationTraceHash, candidate.asyncIteratorCancellationTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-async-generator-cancellation-trace-missing');
|
|
107
|
+
if (!firstString(candidate.asyncGeneratorBackpressureTraceHash, candidate.asyncIteratorBackpressureTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-async-generator-backpressure-trace-missing');
|
|
108
|
+
if (candidate.asyncGeneratorRuntimeEquivalenceClaim !== false || candidate.asyncIteratorProtocolEquivalenceClaim !== false || candidate.asyncIteratorCancellationEquivalenceClaim !== false || candidate.asyncIteratorBackpressureEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
109
|
+
}
|
|
110
|
+
if (expected.generatorProtocolNeedsIteratorTrace) {
|
|
111
|
+
if (!firstString(candidate.iteratorProtocolTraceHash, candidate.generatorIteratorTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-generator-iterator-protocol-trace-missing');
|
|
112
|
+
if (!firstString(candidate.delegatedCompletionTraceHash, candidate.generatorCompletionTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-generator-completion-trace-missing');
|
|
113
|
+
if (candidate.iteratorProtocolEquivalenceClaim !== false || candidate.delegatedCompletionPropagationClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
114
|
+
}
|
|
115
|
+
return reasonCodes;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function classStaticBlockProofReasonCodes(candidate, expected) {
|
|
119
|
+
if (!expected.runtimeKinds.includes('class-static-block') && !expected.classStaticBlockOrderHash) return [];
|
|
120
|
+
const reasonCodes = [];
|
|
121
|
+
if (candidate.classStaticBlockRuntimeEquivalenceClaim !== false || candidate.staticInitializationEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
122
|
+
const orderHash = firstString(candidate.classStaticBlockOrderHash, candidate.staticInitializationOrderHash);
|
|
123
|
+
if (expected.classStaticBlockOrderHash && !orderHash) reasonCodes.push('runtime-order-explicit-evidence-class-static-block-order-hash-missing');
|
|
124
|
+
else if (expected.classStaticBlockOrderHash && orderHash !== expected.classStaticBlockOrderHash) reasonCodes.push('runtime-order-explicit-evidence-class-static-block-order-hash-mismatch');
|
|
125
|
+
if (!firstString(candidate.classStaticBlockExecutionTraceHash, candidate.staticInitializationTraceHash, candidate.classStaticBlockEffectTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-class-static-block-execution-trace-missing');
|
|
126
|
+
return reasonCodes;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function topLevelAwaitProofReasonCodes(candidate, expected) {
|
|
130
|
+
if (!expected.topLevelAwaitOrderHash) return [];
|
|
131
|
+
const reasonCodes = [];
|
|
132
|
+
if (candidate.topLevelAwaitSuspensionEquivalenceClaim !== false || candidate.moduleEvaluationOrderEquivalenceClaim !== false) reasonCodes.push('runtime-order-explicit-evidence-claim-flags-missing');
|
|
133
|
+
const orderHash = firstString(candidate.topLevelAwaitOrderHash, candidate.topLevelAwaitSuspensionOrderHash);
|
|
134
|
+
if (!orderHash) reasonCodes.push('runtime-order-explicit-evidence-top-level-await-order-hash-missing');
|
|
135
|
+
else if (orderHash !== expected.topLevelAwaitOrderHash) reasonCodes.push('runtime-order-explicit-evidence-top-level-await-order-hash-mismatch');
|
|
136
|
+
if (!firstString(candidate.topLevelAwaitSuspensionTraceHash, candidate.moduleEvaluationTraceHash)) reasonCodes.push('runtime-order-explicit-evidence-top-level-await-suspension-trace-missing');
|
|
137
|
+
return reasonCodes;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function importMetaHostContextHash(region) {
|
|
141
|
+
const evidence = region?.metadata?.runtimeOrderEvidence ?? region?.runtimeOrderEvidence;
|
|
142
|
+
const records = array(evidence?.importMetaHostContext);
|
|
143
|
+
return records.length ? hashSemanticValue({
|
|
144
|
+
kind: 'frontier.lang.runtimeOrderProofEvidence.importMetaHostContext',
|
|
145
|
+
sourcePath: region?.sourcePath,
|
|
146
|
+
regionKind: runtimeRegionKind(region),
|
|
147
|
+
runtimeKind: region?.runtimeKind,
|
|
148
|
+
symbolName: region?.symbolName,
|
|
149
|
+
ordinal: region?.ordinal,
|
|
150
|
+
hostContext: evidence?.hostContext,
|
|
151
|
+
importMetaMemberNames: evidence?.importMetaMemberNames,
|
|
152
|
+
records: records.map(importMetaHostContextRecordForHash)
|
|
153
|
+
}) : undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function importMetaHostContextRecordForHash(record) {
|
|
157
|
+
return { kind: record?.kind, ordinal: record?.ordinal, text: record?.text, memberName: record?.memberName, memberPath: record?.memberPath };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function promiseCombinatorOrderHash(region, records = promiseCombinatorOrderRecords(region)) {
|
|
161
|
+
return records.length ? hashSemanticValue({ kind: 'frontier.lang.runtimeOrderProofEvidence.promiseCombinatorOrder', sourcePath: region?.sourcePath, regionKind: runtimeRegionKind(region), runtimeKind: region?.runtimeKind, symbolName: region?.symbolName, ordinal: region?.ordinal, records: records.map(promiseCombinatorRecordForHash) }) : undefined;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function promiseCombinatorRecordForHash(record) {
|
|
165
|
+
return { kind: record?.kind, methodName: record?.methodName, concurrencySemantics: record?.concurrencySemantics, settlementPolicy: record?.settlementPolicy, argumentOrdinal: record?.argumentOrdinal, argumentText: record?.argumentText, directArrayArgument: record?.directArrayArgument === true, arrayElementOrdinal: record?.arrayElementOrdinal, arrayElementCount: record?.arrayElementCount, arrayElementText: record?.arrayElementText, callText: record?.callText, runtimeEquivalenceClaim: record?.runtimeEquivalenceClaim, semanticEquivalenceClaim: record?.semanticEquivalenceClaim };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function promiseCombinatorOrderRecords(region) {
|
|
169
|
+
return array(region?.metadata?.runtimeOrderEvidence?.sameLinePromiseCombinator ?? region?.runtimeOrderEvidence?.sameLinePromiseCombinator);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function promiseChainOrderHash(region, records = promiseChainOrderRecords(region)) {
|
|
173
|
+
return records.length ? hashSemanticValue({ kind: 'frontier.lang.runtimeOrderProofEvidence.promiseChainOrder', sourcePath: region?.sourcePath, regionKind: runtimeRegionKind(region), runtimeKind: region?.runtimeKind, symbolName: region?.symbolName, ordinal: region?.ordinal, records: records.map(promiseChainRecordForHash) }) : undefined;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function promiseChainRecordForHash(record) {
|
|
177
|
+
return { kind: record?.kind, regionRole: record?.regionRole, handlerMethodName: record?.handlerMethodName, handlerStepOrdinal: record?.handlerStepOrdinal, chainMethods: array(record?.chainMethods), stepCount: record?.stepCount, hasThen: record?.hasThen === true, hasCatch: record?.hasCatch === true, hasFinally: record?.hasFinally === true, chainText: record?.chainText, steps: array(record?.steps).map(promiseChainStepForHash), handlerExecutionEquivalenceClaim: record?.handlerExecutionEquivalenceClaim, runtimeEquivalenceClaim: record?.runtimeEquivalenceClaim, semanticEquivalenceClaim: record?.semanticEquivalenceClaim };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function promiseChainStepForHash(step) {
|
|
181
|
+
return { ordinal: step?.ordinal, methodName: step?.methodName, handlerText: step?.handlerText, handlerOrdinal: step?.handlerOrdinal };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function promiseChainOrderRecords(region) {
|
|
185
|
+
return array(region?.metadata?.runtimeOrderEvidence?.sameLinePromiseChain ?? region?.runtimeOrderEvidence?.sameLinePromiseChain);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function classStaticBlockOrderHash(region) {
|
|
189
|
+
const records = classStaticBlockOrderRecords(region);
|
|
190
|
+
return records.length ? hashSemanticValue({ kind: 'frontier.lang.runtimeOrderProofEvidence.classStaticBlockOrder', sourcePath: region?.sourcePath, regionKind: runtimeRegionKind(region), runtimeKind: region?.runtimeKind, symbolName: region?.symbolName, ordinal: region?.ordinal, records: records.map(classStaticBlockOrderRecordForHash) }) : undefined;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function classStaticBlockOrderRecordForHash(record) {
|
|
194
|
+
return { kind: record?.kind, className: record?.className, ordinal: record?.ordinal, statementCount: record?.statementCount, line: record?.line, column: record?.column, text: record?.text };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function classStaticBlockOrderRecords(region) {
|
|
198
|
+
return array(region?.metadata?.runtimeOrderEvidence?.classStaticBlockOrder ?? region?.runtimeOrderEvidence?.classStaticBlockOrder);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function topLevelAwaitOrderHash(region) {
|
|
202
|
+
const records = topLevelAwaitOrderRecords(region);
|
|
203
|
+
return records.length ? hashSemanticValue({ kind: 'frontier.lang.runtimeOrderProofEvidence.topLevelAwaitOrder', sourcePath: region?.sourcePath, regionKind: runtimeRegionKind(region), runtimeKind: region?.runtimeKind, symbolName: region?.symbolName, ordinal: region?.ordinal, records }) : undefined;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function topLevelAwaitOrderRecords(region) {
|
|
207
|
+
const evidence = region?.metadata?.runtimeOrderEvidence ?? region?.runtimeOrderEvidence;
|
|
208
|
+
return evidence?.topLevelAwait ? [...array(evidence.sameLineAwaitOrder).map((record) => ({ kind: record?.kind, ordinal: record?.ordinal, text: record?.text })), { kind: 'top-level-await', runtimeScope: evidence.runtimeScope, line: evidence.line, runtimeOrderIndex: evidence.runtimeOrderIndex, previousRegionKind: evidence.previousRegionKind, previousRuntimeKind: evidence.previousRuntimeKind, previousRuntimeKinds: evidence.previousRuntimeKinds }] : [];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function generatorProtocolOrderHash(region, records = generatorProtocolRecords(region)) {
|
|
212
|
+
return records.length ? hashSemanticValue({ kind: 'frontier.lang.runtimeOrderProofEvidence.generatorProtocolOrder', sourcePath: region?.sourcePath, regionKind: runtimeRegionKind(region), runtimeKind: region?.runtimeKind, symbolName: region?.symbolName, ordinal: region?.ordinal, records: records.map(generatorProtocolRecordForHash) }) : undefined;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function generatorProtocolRecordForHash(record) {
|
|
216
|
+
return { kind: record?.kind, delegated: record?.delegated === true, delegationKind: record?.delegationKind, delegatedIterableText: record?.delegatedIterableText, line: record?.line, column: record?.column, targetText: record?.targetText, calleeName: record?.calleeName, effectKind: record?.effectKind, iteratorProtocolEquivalenceClaim: record?.iteratorProtocolEquivalenceClaim, delegatedCompletionPropagationClaim: record?.delegatedCompletionPropagationClaim };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function generatorProtocolRecords(region) {
|
|
220
|
+
const evidence = region?.metadata?.runtimeOrderEvidence ?? region?.runtimeOrderEvidence;
|
|
221
|
+
return [...array(evidence?.exitOrder), ...array(evidence?.effectTargetOrder), ...array(evidence?.sameLineYieldOrder)].filter(isGeneratorProtocolRecord);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function isGeneratorProtocolRecord(record) {
|
|
225
|
+
return record?.kind === 'yield' || record?.effectKind === 'generator' || record?.delegated === true || record?.delegationKind === 'iterator-delegation';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function runtimeKinds(region) {
|
|
229
|
+
return uniqueStrings([
|
|
230
|
+
...array(region?.runtimeKinds),
|
|
231
|
+
...array(region?.runtimeKind),
|
|
232
|
+
...array(region?.metadata?.factKinds),
|
|
233
|
+
...array(region?.metadata?.factKind)
|
|
234
|
+
].flatMap((kind) => String(kind ?? '').split('+')).filter(Boolean));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function resourceManagementOrderHash(region, records = resourceManagementOrderRecords(region)) {
|
|
238
|
+
return records.length ? hashSemanticValue({ kind: 'frontier.lang.runtimeOrderProofEvidence.resourceManagementDisposalOrder', sourcePath: region?.sourcePath, regionKind: runtimeRegionKind(region), runtimeKind: region?.runtimeKind, symbolName: region?.symbolName, ordinal: region?.ordinal, records: records.map(resourceManagementOrderRecordForHash) }) : undefined;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function resourceManagementOrderRecordForHash(record) {
|
|
242
|
+
return { name: record?.name, declarationKind: record?.declarationKind, awaitUsing: record?.awaitUsing === true, acquisitionOrderIndex: record?.acquisitionOrderIndex, disposalOrderIndex: record?.disposalOrderIndex, disposalOrder: record?.disposalOrder, scopeStartLine: record?.scopeStartLine, scopeExitLine: record?.scopeExitLine, declarationText: record?.declarationText, initializerText: record?.initializerText, disposalMethodPolicy: record?.disposalMethodPolicy };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function resourceManagementOrderRecords(region) {
|
|
246
|
+
return array(region?.metadata?.runtimeOrderEvidence?.resourceManagementOrder ?? region?.runtimeOrderEvidence?.resourceManagementOrder);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function runtimeRegionKind(region) { return String(region?.regionKind ?? ''); }
|
|
250
|
+
function firstString(...values) { return values.find((value) => typeof value === 'string' && value.length > 0); }
|
|
251
|
+
function array(value) { return value === undefined || value === null ? [] : Array.isArray(value) ? value : [value]; }
|
|
252
|
+
|
|
253
|
+
export { runtimeOrderProofSurfaceReasonCodes, runtimeOrderSurfaceExpectations };
|