@shapeshift-labs/frontier-lang-compiler 0.2.66 → 0.2.68
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 +6 -2
- package/bench/smoke.mjs +15 -1
- package/bench/universal-fixture-suite.mjs +183 -0
- package/dist/declarations/native-project-admission.d.ts +115 -0
- package/dist/declarations/roundtrip-audit.d.ts +186 -0
- package/dist/declarations/roundtrip.d.ts +2 -53
- package/dist/declarations/runtime.d.ts +0 -11
- package/dist/declarations/semantic-history-records.d.ts +277 -0
- package/dist/declarations/semantic-history.d.ts +45 -92
- package/dist/declarations/semantic-slice-admission.d.ts +111 -0
- package/dist/declarations/semantic-slice.d.ts +36 -1
- package/dist/declarations/universal-conversion-plan.d.ts +59 -0
- package/dist/declarations/universal-runtime-capabilities.d.ts +171 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/index-impl/createNativeRoundtripEvidence.js +54 -49
- package/dist/internal/index-impl/createSemanticSlice.js +1 -1
- package/dist/internal/index-impl/createSemanticSliceAdmissionRecord.js +10 -1
- package/dist/internal/index-impl/expandSemanticSliceSelection.js +0 -1
- package/dist/internal/index-impl/nativeRoundtripAudit.js +217 -0
- package/dist/internal/index-impl/projectImportAdmissionImportEvidence.js +160 -0
- package/dist/internal/index-impl/projectImportAdmissionLanguageSummaries.js +247 -0
- package/dist/internal/index-impl/projectImportAdmissionRanks.js +52 -0
- package/dist/internal/index-impl/projectImportAdmissionSummaries.js +46 -111
- package/dist/internal/index-impl/projectImportAdmissionTasks.js +239 -0
- package/dist/internal/index-impl/semanticHistoryRecordNormalizers.js +151 -0
- package/dist/internal/index-impl/semanticHistoryRecordOverlaps.js +113 -0
- package/dist/internal/index-impl/semanticHistoryRecords.js +210 -149
- package/dist/internal/index-impl/semanticSliceAdmissionSurface.js +142 -0
- package/dist/internal/index-impl/semanticSliceExpectationAssertions.js +100 -0
- package/dist/internal/index-impl/semanticSliceExpectationRecords.js +75 -0
- package/dist/internal/index-impl/semanticSliceExpectedAssertions.js +5 -2
- package/dist/internal/index-impl/testSemanticSlice.js +4 -1
- package/dist/language-adapter-package-contracts.js +12 -57
- package/dist/language-adapter-package-rows.js +116 -0
- package/dist/universal-conversion-plan-summary.js +42 -0
- package/dist/universal-conversion-plan.js +46 -40
- package/dist/universal-runtime-capabilities.js +92 -0
- package/dist/universal-runtime-host-selectors.js +192 -0
- package/dist/universal-runtime-profiles.js +109 -0
- package/dist/universal-runtime-route-records.js +162 -0
- package/examples/js-frontier-rust-workbench-client.mjs +58 -1
- package/examples/js-frontier-rust-workbench-convert.mjs +161 -0
- package/examples/js-frontier-rust-workbench-route-styles.mjs +126 -0
- package/examples/js-frontier-rust-workbench-route.mjs +190 -0
- package/examples/js-frontier-rust-workbench-styles.mjs +3 -38
- package/examples/js-frontier-rust-workbench.mjs +22 -128
- package/package.json +1 -1
|
@@ -9,6 +9,13 @@ import type { NativeParserFeatureCategory } from './native-parser-features.js';
|
|
|
9
9
|
import type { ProjectionSourceProjectionCoverage, ProjectionTargetCoverageEntry } from './projection-coverage.js';
|
|
10
10
|
import type { ProjectionReadinessTargetCell } from './projection-readiness.js';
|
|
11
11
|
import type { UniversalCapabilityMatrix, UniversalCapabilityMatrixOptions } from './universal-capability.js';
|
|
12
|
+
import type {
|
|
13
|
+
UniversalRuntimeAdapterRequirement,
|
|
14
|
+
UniversalRuntimeCapabilityKind,
|
|
15
|
+
UniversalRuntimeCapabilityMatrix,
|
|
16
|
+
UniversalRuntimeCapabilityRoute,
|
|
17
|
+
UniversalRuntimeHostProfile
|
|
18
|
+
} from './universal-runtime-capabilities.js';
|
|
12
19
|
|
|
13
20
|
export type UniversalConversionRouteMode =
|
|
14
21
|
| 'preserve-source'
|
|
@@ -76,6 +83,19 @@ export interface UniversalConversionRouteEvidence {
|
|
|
76
83
|
readonly targetLossKinds: readonly NativeImportKnownLossKind[];
|
|
77
84
|
}
|
|
78
85
|
|
|
86
|
+
export interface UniversalConversionRouteRuntime {
|
|
87
|
+
readonly routeId?: string;
|
|
88
|
+
readonly source?: UniversalRuntimeCapabilityRoute['source'];
|
|
89
|
+
readonly target?: UniversalRuntimeCapabilityRoute['target'];
|
|
90
|
+
readonly requiredCapabilities: readonly UniversalRuntimeCapabilityKind[];
|
|
91
|
+
readonly satisfiedCapabilities: readonly UniversalRuntimeCapabilityKind[];
|
|
92
|
+
readonly adapterRequirements: readonly UniversalRuntimeAdapterRequirement[];
|
|
93
|
+
readonly missingCapabilities: readonly UniversalRuntimeCapabilityKind[];
|
|
94
|
+
readonly readiness: SemanticMergeReadiness;
|
|
95
|
+
readonly blockers: readonly string[];
|
|
96
|
+
readonly review: readonly string[];
|
|
97
|
+
}
|
|
98
|
+
|
|
79
99
|
export interface UniversalConversionRouteMergeRefs {
|
|
80
100
|
readonly planId: string;
|
|
81
101
|
readonly routeId: string;
|
|
@@ -122,6 +142,8 @@ export interface UniversalConversionRoute {
|
|
|
122
142
|
readonly stubs: ProjectionSourceProjectionCoverage;
|
|
123
143
|
};
|
|
124
144
|
readonly projectionReadiness?: ProjectionReadinessTargetCell;
|
|
145
|
+
readonly runtime: UniversalConversionRouteRuntime;
|
|
146
|
+
readonly runtimeAdapterRequirements: readonly UniversalRuntimeAdapterRequirement[];
|
|
125
147
|
readonly evidence: UniversalConversionRouteEvidence;
|
|
126
148
|
readonly missingEvidence: readonly string[];
|
|
127
149
|
readonly blockers: readonly string[];
|
|
@@ -153,6 +175,8 @@ export interface UniversalConversionPlan {
|
|
|
153
175
|
readonly stubOnlyRoutes: number;
|
|
154
176
|
readonly semanticIndexOnlyRoutes: number;
|
|
155
177
|
readonly missingEvidence: number;
|
|
178
|
+
readonly runtimeAdapterRequirements: number;
|
|
179
|
+
readonly runtimeRoutesWithAdapters: number;
|
|
156
180
|
readonly blockers: number;
|
|
157
181
|
readonly reviewReasons: number;
|
|
158
182
|
readonly autoMergeClaims: 0;
|
|
@@ -160,6 +184,7 @@ export interface UniversalConversionPlan {
|
|
|
160
184
|
};
|
|
161
185
|
readonly matrices: {
|
|
162
186
|
readonly universalCapability: UniversalCapabilityMatrix;
|
|
187
|
+
readonly runtimeCapabilities: UniversalRuntimeCapabilityMatrix;
|
|
163
188
|
readonly projectionReadiness?: UniversalCapabilityMatrix['matrices']['projectionReadiness'];
|
|
164
189
|
readonly projectionTargets?: UniversalCapabilityMatrix['matrices']['projectionTargets'];
|
|
165
190
|
};
|
|
@@ -175,6 +200,40 @@ export interface UniversalConversionPlan {
|
|
|
175
200
|
export interface UniversalConversionPlanOptions extends UniversalCapabilityMatrixOptions {
|
|
176
201
|
readonly id?: string;
|
|
177
202
|
readonly universalCapabilityMatrix?: UniversalCapabilityMatrix;
|
|
203
|
+
readonly universalRuntimeCapabilityMatrix?: UniversalRuntimeCapabilityMatrix;
|
|
204
|
+
readonly hostProfiles?: readonly UniversalRuntimeHostProfile[];
|
|
205
|
+
readonly runtimeHosts?: readonly UniversalRuntimeHostProfile[];
|
|
206
|
+
readonly sourceHosts?: readonly (string | UniversalRuntimeHostProfile)[] | Readonly<Record<string, string | UniversalRuntimeHostProfile>>;
|
|
207
|
+
readonly sourceRuntimeHosts?: readonly (string | UniversalRuntimeHostProfile)[] | Readonly<Record<string, string | UniversalRuntimeHostProfile>>;
|
|
208
|
+
readonly targetHosts?: readonly (string | UniversalRuntimeHostProfile)[] | Readonly<Record<string, string | UniversalRuntimeHostProfile>>;
|
|
209
|
+
readonly targetRuntimeHosts?: readonly (string | UniversalRuntimeHostProfile)[] | Readonly<Record<string, string | UniversalRuntimeHostProfile>>;
|
|
210
|
+
readonly sourceRuntime?: string;
|
|
211
|
+
readonly targetRuntime?: string;
|
|
212
|
+
readonly sourceRuntimes?: Readonly<Record<string, string>>;
|
|
213
|
+
readonly targetRuntimes?: Readonly<Record<string, string>>;
|
|
214
|
+
readonly runtimeRequirements?: readonly (
|
|
215
|
+
| UniversalRuntimeCapabilityKind
|
|
216
|
+
| {
|
|
217
|
+
readonly capability?: UniversalRuntimeCapabilityKind;
|
|
218
|
+
readonly kind?: UniversalRuntimeCapabilityKind;
|
|
219
|
+
readonly capabilities?: readonly UniversalRuntimeCapabilityKind[];
|
|
220
|
+
readonly requiredCapabilities?: readonly UniversalRuntimeCapabilityKind[];
|
|
221
|
+
readonly sourceLanguage?: FrontierSourceLanguage | string;
|
|
222
|
+
readonly language?: FrontierSourceLanguage | string;
|
|
223
|
+
readonly sourceRuntime?: string;
|
|
224
|
+
readonly runtime?: string;
|
|
225
|
+
readonly sourceHost?: string | UniversalRuntimeHostProfile;
|
|
226
|
+
readonly sourceRuntimeHost?: string | UniversalRuntimeHostProfile;
|
|
227
|
+
readonly target?: FrontierCompileTarget | string;
|
|
228
|
+
readonly targetRuntime?: string;
|
|
229
|
+
readonly targetHost?: string | UniversalRuntimeHostProfile;
|
|
230
|
+
readonly targetRuntimeHost?: string | UniversalRuntimeHostProfile;
|
|
231
|
+
readonly reason?: string;
|
|
232
|
+
readonly evidenceIds?: readonly string[];
|
|
233
|
+
}
|
|
234
|
+
)[];
|
|
235
|
+
readonly requiredRuntimeCapabilities?: UniversalConversionPlanOptions['runtimeRequirements'];
|
|
236
|
+
readonly effects?: UniversalConversionPlanOptions['runtimeRequirements'];
|
|
178
237
|
readonly evidence?: readonly EvidenceRecord[];
|
|
179
238
|
}
|
|
180
239
|
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FrontierSourceLanguage,
|
|
3
|
+
SemanticMergeReadiness
|
|
4
|
+
} from '@shapeshift-labs/frontier-lang-kernel';
|
|
5
|
+
import type { FrontierCompileTarget } from './compile.js';
|
|
6
|
+
import type { NativeImportLanguageProfile } from './native-import-losses.js';
|
|
7
|
+
import type { NativeSourceImportResult } from './import-adapter-core.js';
|
|
8
|
+
|
|
9
|
+
export type UniversalRuntimeCapabilityKind =
|
|
10
|
+
| 'fetch'
|
|
11
|
+
| 'timers'
|
|
12
|
+
| 'storage'
|
|
13
|
+
| 'filesystem'
|
|
14
|
+
| 'threading'
|
|
15
|
+
| 'dom'
|
|
16
|
+
| 'async'
|
|
17
|
+
| 'ffi'
|
|
18
|
+
| string;
|
|
19
|
+
|
|
20
|
+
export type UniversalRuntimeCapabilitySupport = 'native' | 'adapter' | 'unavailable' | string;
|
|
21
|
+
|
|
22
|
+
export interface UniversalRuntimeCapabilitySupportRecord {
|
|
23
|
+
readonly kind: UniversalRuntimeCapabilityKind;
|
|
24
|
+
readonly support: UniversalRuntimeCapabilitySupport;
|
|
25
|
+
readonly binding: string;
|
|
26
|
+
readonly notes: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface UniversalRuntimeHostProfile {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly language: FrontierSourceLanguage | string;
|
|
32
|
+
readonly aliases?: readonly string[];
|
|
33
|
+
readonly languageIds?: readonly string[];
|
|
34
|
+
readonly runtime: string;
|
|
35
|
+
readonly host: string;
|
|
36
|
+
readonly target: FrontierCompileTarget | string;
|
|
37
|
+
readonly capabilities: Readonly<Record<UniversalRuntimeCapabilityKind, UniversalRuntimeCapabilitySupportRecord>>;
|
|
38
|
+
readonly notes?: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface UniversalRuntimeHostSummary extends UniversalRuntimeHostProfile {
|
|
42
|
+
readonly aliases: readonly string[];
|
|
43
|
+
readonly languageIds: readonly string[];
|
|
44
|
+
readonly notes?: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface UniversalRuntimeRequirementInput {
|
|
48
|
+
readonly capability?: UniversalRuntimeCapabilityKind;
|
|
49
|
+
readonly kind?: UniversalRuntimeCapabilityKind;
|
|
50
|
+
readonly capabilities?: readonly UniversalRuntimeCapabilityKind[];
|
|
51
|
+
readonly requiredCapabilities?: readonly UniversalRuntimeCapabilityKind[];
|
|
52
|
+
readonly sourceLanguage?: FrontierSourceLanguage | string;
|
|
53
|
+
readonly language?: FrontierSourceLanguage | string;
|
|
54
|
+
readonly sourceRuntime?: string;
|
|
55
|
+
readonly runtime?: string;
|
|
56
|
+
readonly sourceHost?: string | UniversalRuntimeHostProfile;
|
|
57
|
+
readonly sourceRuntimeHost?: string | UniversalRuntimeHostProfile;
|
|
58
|
+
readonly target?: FrontierCompileTarget | string;
|
|
59
|
+
readonly targetRuntime?: string;
|
|
60
|
+
readonly targetHost?: string | UniversalRuntimeHostProfile;
|
|
61
|
+
readonly targetRuntimeHost?: string | UniversalRuntimeHostProfile;
|
|
62
|
+
readonly reason?: string;
|
|
63
|
+
readonly evidenceIds?: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface UniversalRuntimeAdapterRequirement {
|
|
67
|
+
readonly id: string;
|
|
68
|
+
readonly capability: UniversalRuntimeCapabilityKind;
|
|
69
|
+
readonly adapterKind: string;
|
|
70
|
+
readonly sourceHost: string;
|
|
71
|
+
readonly targetHost: string;
|
|
72
|
+
readonly sourceBinding: string;
|
|
73
|
+
readonly targetBinding: string;
|
|
74
|
+
readonly required: true;
|
|
75
|
+
readonly reason: string;
|
|
76
|
+
readonly evidenceIds: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface UniversalRuntimeCapabilityRoute {
|
|
80
|
+
readonly id: string;
|
|
81
|
+
readonly source: UniversalRuntimeHostSummary;
|
|
82
|
+
readonly target: UniversalRuntimeHostSummary;
|
|
83
|
+
readonly requiredCapabilities: readonly UniversalRuntimeCapabilityKind[];
|
|
84
|
+
readonly satisfiedCapabilities: readonly UniversalRuntimeCapabilityKind[];
|
|
85
|
+
readonly adapterRequirements: readonly UniversalRuntimeAdapterRequirement[];
|
|
86
|
+
readonly missingCapabilities: readonly UniversalRuntimeCapabilityKind[];
|
|
87
|
+
readonly readiness: SemanticMergeReadiness;
|
|
88
|
+
readonly blockers: readonly string[];
|
|
89
|
+
readonly review: readonly string[];
|
|
90
|
+
readonly metadata: Record<string, unknown>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface UniversalRuntimeCapabilityMatrix {
|
|
94
|
+
readonly kind: 'frontier.lang.universalRuntimeCapabilityMatrix';
|
|
95
|
+
readonly version: 1;
|
|
96
|
+
readonly generatedAt: number;
|
|
97
|
+
readonly hostProfiles: readonly UniversalRuntimeHostProfile[];
|
|
98
|
+
readonly routes: readonly UniversalRuntimeCapabilityRoute[];
|
|
99
|
+
readonly summary: {
|
|
100
|
+
readonly routes: number;
|
|
101
|
+
readonly routesWithAdapters: number;
|
|
102
|
+
readonly adapterRequirements: number;
|
|
103
|
+
readonly missingCapabilities: number;
|
|
104
|
+
readonly byReadiness: Readonly<Record<SemanticMergeReadiness, number>>;
|
|
105
|
+
readonly byCapability: Readonly<Record<UniversalRuntimeCapabilityKind, number>>;
|
|
106
|
+
readonly byAdapterKind: Readonly<Record<string, number>>;
|
|
107
|
+
};
|
|
108
|
+
readonly metadata: {
|
|
109
|
+
readonly capabilityKinds: readonly UniversalRuntimeCapabilityKind[];
|
|
110
|
+
readonly sourceHosts: readonly string[];
|
|
111
|
+
readonly targetHosts: readonly string[];
|
|
112
|
+
readonly note: string;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface UniversalRuntimeCapabilityMatrixOptions {
|
|
117
|
+
readonly generatedAt?: number;
|
|
118
|
+
readonly imports?: readonly NativeSourceImportResult[];
|
|
119
|
+
readonly languages?: readonly (NativeImportLanguageProfile | FrontierSourceLanguage | string)[];
|
|
120
|
+
readonly sourceLanguages?: readonly (NativeImportLanguageProfile | FrontierSourceLanguage | string)[];
|
|
121
|
+
readonly targets?: readonly (FrontierCompileTarget | string)[];
|
|
122
|
+
readonly hostProfiles?: readonly UniversalRuntimeHostProfile[];
|
|
123
|
+
readonly runtimeHosts?: readonly UniversalRuntimeHostProfile[];
|
|
124
|
+
readonly sourceHosts?: readonly (string | UniversalRuntimeHostProfile)[] | Readonly<Record<string, string | UniversalRuntimeHostProfile>>;
|
|
125
|
+
readonly sourceRuntimeHosts?: readonly (string | UniversalRuntimeHostProfile)[] | Readonly<Record<string, string | UniversalRuntimeHostProfile>>;
|
|
126
|
+
readonly targetHosts?: readonly (string | UniversalRuntimeHostProfile)[] | Readonly<Record<string, string | UniversalRuntimeHostProfile>>;
|
|
127
|
+
readonly targetRuntimeHosts?: readonly (string | UniversalRuntimeHostProfile)[] | Readonly<Record<string, string | UniversalRuntimeHostProfile>>;
|
|
128
|
+
readonly sourceRuntime?: string;
|
|
129
|
+
readonly targetRuntime?: string;
|
|
130
|
+
readonly sourceRuntimes?: Readonly<Record<string, string>>;
|
|
131
|
+
readonly targetRuntimes?: Readonly<Record<string, string>>;
|
|
132
|
+
readonly runtimeRequirements?:
|
|
133
|
+
| readonly (UniversalRuntimeCapabilityKind | UniversalRuntimeRequirementInput)[]
|
|
134
|
+
| Readonly<Record<string, readonly UniversalRuntimeCapabilityKind[]>>;
|
|
135
|
+
readonly requiredRuntimeCapabilities?:
|
|
136
|
+
| readonly (UniversalRuntimeCapabilityKind | UniversalRuntimeRequirementInput)[]
|
|
137
|
+
| Readonly<Record<string, readonly UniversalRuntimeCapabilityKind[]>>;
|
|
138
|
+
readonly effects?:
|
|
139
|
+
| readonly (UniversalRuntimeCapabilityKind | UniversalRuntimeRequirementInput)[]
|
|
140
|
+
| Readonly<Record<string, readonly UniversalRuntimeCapabilityKind[]>>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface UniversalRuntimeCapabilityMatrixQuery {
|
|
144
|
+
readonly sourceLanguage?: FrontierSourceLanguage | string;
|
|
145
|
+
readonly language?: FrontierSourceLanguage | string;
|
|
146
|
+
readonly target?: FrontierCompileTarget | string;
|
|
147
|
+
readonly sourceRuntime?: string;
|
|
148
|
+
readonly targetRuntime?: string;
|
|
149
|
+
readonly runtime?: string;
|
|
150
|
+
readonly capability?: UniversalRuntimeCapabilityKind;
|
|
151
|
+
readonly requiresAdapter?: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface UniversalRuntimeCapabilityMatrixQueryResult {
|
|
155
|
+
readonly kind: 'frontier.lang.universalRuntimeCapabilityMatrixQuery';
|
|
156
|
+
readonly version: 1;
|
|
157
|
+
readonly found: boolean;
|
|
158
|
+
readonly routes: readonly UniversalRuntimeCapabilityRoute[];
|
|
159
|
+
readonly bestRoute?: UniversalRuntimeCapabilityRoute;
|
|
160
|
+
readonly reasons: readonly string[];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export declare const UniversalRuntimeCapabilityKinds: readonly UniversalRuntimeCapabilityKind[];
|
|
164
|
+
export declare const UniversalRuntimeHostProfiles: readonly UniversalRuntimeHostProfile[];
|
|
165
|
+
export declare function createUniversalRuntimeCapabilityMatrix(
|
|
166
|
+
options?: UniversalRuntimeCapabilityMatrixOptions
|
|
167
|
+
): UniversalRuntimeCapabilityMatrix;
|
|
168
|
+
export declare function queryUniversalRuntimeCapabilityMatrix(
|
|
169
|
+
matrixOrOptions?: UniversalRuntimeCapabilityMatrix | UniversalRuntimeCapabilityMatrixOptions,
|
|
170
|
+
query?: UniversalRuntimeCapabilityMatrixQuery
|
|
171
|
+
): UniversalRuntimeCapabilityMatrixQueryResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './declarations/projection-readiness.js';
|
|
|
8
8
|
export * from './declarations/universal-capability.js';
|
|
9
9
|
export * from './declarations/universal-conversion-artifacts.js';
|
|
10
10
|
export * from './declarations/universal-conversion-plan.js';
|
|
11
|
+
export * from './declarations/universal-runtime-capabilities.js';
|
|
11
12
|
export * from './declarations/universal-dialects.js';
|
|
12
13
|
export * from './declarations/language-adapter-package-contracts.js';
|
|
13
14
|
export * from './declarations/native-import-contracts.js';
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export { createUniversalCapabilityMatrix } from './internal/index-impl/createUni
|
|
|
32
32
|
export { createUniversalConversionArtifacts } from './internal/index-impl/createUniversalConversionArtifacts.js';
|
|
33
33
|
export { queryUniversalConversionArtifacts } from './universal-conversion-artifacts.js';
|
|
34
34
|
export { createUniversalConversionPlan } from './internal/index-impl/createUniversalConversionPlan.js';
|
|
35
|
+
export { createUniversalRuntimeCapabilityMatrix, queryUniversalRuntimeCapabilityMatrix, UniversalRuntimeCapabilityKinds, UniversalRuntimeHostProfiles } from './universal-runtime-capabilities.js';
|
|
35
36
|
export { attachUniversalDialectRegistry, createUniversalDialectRecord, createUniversalDialectRegistry, createUniversalExternRecord, summarizeUniversalDialectRegistry, UniversalDialectConstructKinds, UniversalDialectProjectionDispositions } from './universal-dialect-registry.js';
|
|
36
37
|
export { diffNativeSourceImports } from './internal/index-impl/diffNativeSourceImports.js';
|
|
37
38
|
export { diffNativeSources } from './internal/index-impl/diffNativeSources.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import{validateUniversalAstEnvelope}from'@shapeshift-labs/frontier-lang-kernel';
|
|
2
2
|
import{countBy,idFragment,maxSemanticMergeReadiness,uniqueStrings}from'../../native-import-utils.js';
|
|
3
3
|
import{nativeImportEntries}from'./nativeImportEntries.js';import{nativeImportHasExactAstCoverage}from'./nativeImportHasExactAstCoverage.js';
|
|
4
|
+
import{createRoundtripAudit}from'./nativeRoundtripAudit.js';
|
|
4
5
|
const precisionRank=Object.freeze({exact:0,line:1,declaration:2,estimated:3,unknown:4,none:5});
|
|
5
6
|
export function createNativeRoundtripEvidence(importResult,options={}) {
|
|
6
7
|
if(!importResult||typeof importResult!=='object') throw new Error('createNativeRoundtripEvidence requires a native import result');
|
|
@@ -28,6 +29,8 @@ export function createNativeRoundtripEvidence(importResult,options={}) {
|
|
|
28
29
|
const sourceMapEvidence=summarizeSourceMaps(hasOutputSourceMaps?outputSourceMaps:universalSourceMaps);
|
|
29
30
|
const sourceLanguage=projection?.language??importResult.language;
|
|
30
31
|
const target=options.target??options.targetCoverage?.target??options.targetProjection?.target;
|
|
32
|
+
const sourcePreservation=summarizeSourcePreservation(importResult,universalSourceMaps);
|
|
33
|
+
const hashChecks=summarizeHashChecks({importResult,projection,targetProjection:options.targetProjection,sourceHashVerified});
|
|
31
34
|
const audit=createRoundtripAudit({
|
|
32
35
|
status,
|
|
33
36
|
semanticMerge,
|
|
@@ -35,6 +38,7 @@ export function createNativeRoundtripEvidence(importResult,options={}) {
|
|
|
35
38
|
target,
|
|
36
39
|
sameLanguage:Boolean(sourceLanguage&&target&&String(sourceLanguage)===String(target)),
|
|
37
40
|
outputMode,
|
|
41
|
+
projection,
|
|
38
42
|
projectionMode:projection?.mode,
|
|
39
43
|
sourceHashVerified,
|
|
40
44
|
hasOutputSourceMaps,
|
|
@@ -42,7 +46,9 @@ export function createNativeRoundtripEvidence(importResult,options={}) {
|
|
|
42
46
|
universalSourceMapEvidence,
|
|
43
47
|
targetProjection:options.targetProjection,
|
|
44
48
|
targetCoverage:options.targetCoverage,
|
|
45
|
-
lossSummary
|
|
49
|
+
lossSummary,
|
|
50
|
+
sourcePreservation,
|
|
51
|
+
hashChecks
|
|
46
52
|
});
|
|
47
53
|
const metadata={
|
|
48
54
|
schema:'frontier.lang.nativeRoundtripEvidence',
|
|
@@ -135,55 +141,54 @@ function summarizeSourceMaps(sourceMaps){
|
|
|
135
141
|
}
|
|
136
142
|
function normalizePrecision(value){const precision=String(value??'unknown');return Object.prototype.hasOwnProperty.call(precisionRank,precision)?precision:'unknown';}
|
|
137
143
|
function worstPrecision(precisions){if(!precisions.length)return'none';return precisions.reduce((worst,next)=>precisionRank[next]>precisionRank[worst]?next:worst,'exact');}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
144
|
+
function summarizeSourcePreservation(importResult,sourceMaps){
|
|
145
|
+
const preservation=importResult.metadata?.sourcePreservation??importResult.nativeSource?.metadata?.sourcePreservation??importResult.nativeAst?.metadata?.sourcePreservation??importResult.universalAst?.metadata?.sourcePreservation;
|
|
146
|
+
const summary=preservation?.summary??importResult.metadata?.sourcePreservationSummary??importResult.nativeSource?.metadata?.sourcePreservationSummary??importResult.nativeAst?.metadata?.sourcePreservationSummary??importResult.universalAst?.metadata?.sourcePreservationSummary??{};
|
|
147
|
+
const kernelSummary=importResult.metadata?.kernelSourcePreservationSummary??importResult.universalAst?.metadata?.kernelSourcePreservationSummary??{};
|
|
148
|
+
const records=asArray(importResult.metadata?.kernelSourcePreservationRecords??importResult.metadata?.sourcePreservationRecords??importResult.universalAst?.metadata?.kernelSourcePreservationRecords??importResult.universalAst?.metadata?.sourcePreservationRecords);
|
|
149
|
+
const mappings=(sourceMaps??[]).flatMap((sourceMap)=>sourceMap?.mappings??[]);
|
|
140
150
|
return{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
blockingLossCount:input.lossSummary.blockingLossIds.length,
|
|
160
|
-
reviewLossCount:input.lossSummary.reviewLossIds.length,
|
|
161
|
-
reasonCodes:uniqueStrings([
|
|
162
|
-
`status:${input.status}`,
|
|
163
|
-
`semantic:${input.semanticMerge}`,
|
|
164
|
-
`output:${input.outputMode??'unknown'}`,
|
|
165
|
-
`projection:${input.projectionMode??'unknown'}`,
|
|
166
|
-
input.sourceHashVerified?'source-hash:verified':'source-hash:unverified',
|
|
167
|
-
`output-source-map:${input.sourceMapEvidence.precision}`,
|
|
168
|
-
`universal-source-map:${input.universalSourceMapEvidence.precision}`,
|
|
169
|
-
input.targetCoverage?.lossClass?`target-loss:${input.targetCoverage.lossClass}`:undefined,
|
|
170
|
-
input.targetProjection?.adapter?.id?`target-adapter:${input.targetProjection.adapter.id}`:undefined,
|
|
171
|
-
input.lossSummary.blockingLossIds.length?'losses:blocking':undefined,
|
|
172
|
-
input.lossSummary.reviewLossIds.length?'losses:review':undefined
|
|
173
|
-
])
|
|
151
|
+
id:preservation?.id??importResult.metadata?.sourcePreservationId??importResult.nativeSource?.metadata?.sourcePreservationId??importResult.universalAst?.metadata?.sourcePreservationId,
|
|
152
|
+
exactSourceAvailable:Boolean(summary.exactSourceAvailable??preservation?.summary?.exactSourceAvailable??preservation?.sourceText),
|
|
153
|
+
sourceTextAvailable:typeof preservation?.sourceText==='string',
|
|
154
|
+
recordCount:numeric(kernelSummary.total,records.length||(preservation?1:0)),
|
|
155
|
+
byLevel:kernelSummary.byLevel??countBy(records.map((record)=>record?.level??'unknown')),
|
|
156
|
+
exactRecords:numeric(kernelSummary.exact),
|
|
157
|
+
declarationRecords:numeric(kernelSummary.declaration),
|
|
158
|
+
estimatedRecords:numeric(kernelSummary.estimated),
|
|
159
|
+
blockedRecords:numeric(kernelSummary.blocked),
|
|
160
|
+
sourcePaths:uniqueStrings([...(asArray(kernelSummary.sourcePaths)),preservation?.sourcePath,importResult.sourcePath]),
|
|
161
|
+
sourceMapIds:uniqueStrings([...(asArray(kernelSummary.sourceMapIds)),...(sourceMaps??[]).map((sourceMap)=>sourceMap?.id)]),
|
|
162
|
+
mappingPreservation:countBy(mappings.map((mapping)=>mapping?.preservation??'unknown')),
|
|
163
|
+
comments:numeric(summary.comments),
|
|
164
|
+
trivia:numeric(summary.trivia),
|
|
165
|
+
directives:numeric(summary.directives),
|
|
166
|
+
tokens:numeric(summary.tokens),
|
|
167
|
+
whitespace:numeric(summary.whitespace),
|
|
168
|
+
truncated:Boolean(summary.truncated)
|
|
174
169
|
};
|
|
175
170
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
171
|
+
function summarizeHashChecks(input){
|
|
172
|
+
const importResult=input.importResult;
|
|
173
|
+
const sourceHash=importResult.nativeSource?.sourceHash??importResult.nativeAst?.sourceHash??importResult.sourceHash;
|
|
174
|
+
const declaredSourceHash=importResult.metadata?.declaredSourceHash??importResult.nativeSource?.metadata?.declaredSourceHash??importResult.nativeAst?.metadata?.declaredSourceHash;
|
|
175
|
+
const expectedSourceHash=input.projection?.sourceHash??sourceHash;
|
|
176
|
+
const projectionOutputHash=input.projection?.outputHash;
|
|
177
|
+
const targetOutputHash=input.targetProjection?.outputHash;
|
|
178
|
+
const outputHash=targetOutputHash??projectionOutputHash;
|
|
179
|
+
return{
|
|
180
|
+
sourceHashPresent:Boolean(sourceHash),
|
|
181
|
+
declaredSourceHashPresent:Boolean(declaredSourceHash),
|
|
182
|
+
declaredSourceHashVerified:declaredSourceHash?declaredSourceHash===sourceHash&&importResult.metadata?.sourceHashVerified!==false:undefined,
|
|
183
|
+
expectedSourceHashPresent:Boolean(expectedSourceHash),
|
|
184
|
+
outputHashPresent:Boolean(outputHash),
|
|
185
|
+
projectionOutputHashPresent:Boolean(projectionOutputHash),
|
|
186
|
+
targetOutputHashPresent:Boolean(targetOutputHash),
|
|
187
|
+
sourceHashVerified:input.sourceHashVerified,
|
|
188
|
+
projectionOutputMatchesSourceHash:Boolean(projectionOutputHash&&expectedSourceHash&&projectionOutputHash===expectedSourceHash),
|
|
189
|
+
targetOutputMatchesSourceHash:Boolean(targetOutputHash&&expectedSourceHash&&targetOutputHash===expectedSourceHash),
|
|
190
|
+
outputMatchesSourceHash:Boolean(outputHash&&expectedSourceHash&&outputHash===expectedSourceHash)
|
|
191
|
+
};
|
|
189
192
|
}
|
|
193
|
+
function asArray(value){return Array.isArray(value)?value:[];}
|
|
194
|
+
function numeric(value,fallback=0){const number=Number(value);return Number.isFinite(number)?number:fallback;}
|
|
@@ -100,7 +100,7 @@ export function createSemanticSlice(input, options = {}) {
|
|
|
100
100
|
verification: {
|
|
101
101
|
focusedCommands: readStringArray(options.focusedCommands),
|
|
102
102
|
fixtureHints: readStringArray(options.fixtureHints),
|
|
103
|
-
expectedAssertions: semanticSliceExpectedAssertions(selection, unresolvedEntryRefs)
|
|
103
|
+
expectedAssertions: semanticSliceExpectedAssertions(selection, unresolvedEntryRefs, options)
|
|
104
104
|
},
|
|
105
105
|
summary: {
|
|
106
106
|
symbols: selection.symbols.length,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import{idFragment,maxSemanticMergeReadiness,uniqueStrings}from'../../native-import-utils.js';
|
|
1
|
+
import{idFragment,maxSemanticMergeReadiness,uniqueByEvidenceId,uniqueStrings}from'../../native-import-utils.js';
|
|
2
2
|
import{testSemanticSlice}from'./testSemanticSlice.js';
|
|
3
|
+
import{semanticSliceAdmissionSelectedSurface,semanticSliceSelectedSurfaceEvidence}from'./semanticSliceAdmissionSurface.js';
|
|
3
4
|
|
|
4
5
|
const readinessScore=Object.freeze({ready:100,'ready-with-losses':78,'needs-review':48,blocked:0});
|
|
5
6
|
const readinessRank=Object.freeze({ready:3,'ready-with-losses':2,'needs-review':1,blocked:0});
|
|
@@ -19,6 +20,12 @@ export function createSemanticSliceAdmissionRecord(slice,options={}){
|
|
|
19
20
|
const value=mergeScoreValue(components,readiness);
|
|
20
21
|
const action=admissionAction(slice,readiness,components,testResult);
|
|
21
22
|
const risk=admissionRisk(readiness,components,testResult);
|
|
23
|
+
const selectedSurface=semanticSliceAdmissionSelectedSurface(slice);
|
|
24
|
+
const evidence=uniqueByEvidenceId([
|
|
25
|
+
...(slice?.evidence??[]),
|
|
26
|
+
...(options.evidence??[]),
|
|
27
|
+
semanticSliceSelectedSurfaceEvidence(slice,selectedSurface,testResult,readiness,action)
|
|
28
|
+
]);
|
|
22
29
|
return{
|
|
23
30
|
kind:'frontier.lang.semanticSliceAdmission',
|
|
24
31
|
version:1,
|
|
@@ -61,6 +68,8 @@ export function createSemanticSliceAdmissionRecord(slice,options={}){
|
|
|
61
68
|
conflictKeys:uniqueStrings(slice?.mergeAdmission?.conflictKeys??[]),
|
|
62
69
|
ownershipKeys:uniqueStrings(slice?.mergeAdmission?.ownershipKeys??[]),
|
|
63
70
|
sourceHashes:slice?.mergeAdmission?.sourceHashes??[],
|
|
71
|
+
selectedSurface,
|
|
72
|
+
evidence,
|
|
64
73
|
testResult,
|
|
65
74
|
reasons:uniqueStrings([
|
|
66
75
|
...(slice?.mergeAdmission?.reasons??[]),
|
|
@@ -41,7 +41,6 @@ export function expandSemanticSliceSelection(records, selection) {
|
|
|
41
41
|
}
|
|
42
42
|
for (const node of records.nativeNodes) {
|
|
43
43
|
if (!selection.selectedNativeNodes.has(node.id)) continue;
|
|
44
|
-
for (const child of node.children ?? []) changed = addSet(selection.selectedNativeNodes, child) || changed;
|
|
45
44
|
const parent = childToParent.get(node.id);
|
|
46
45
|
if (parent) changed = addSet(selection.selectedNativeNodes, parent) || changed;
|
|
47
46
|
}
|