@shapeshift-labs/frontier-lang-compiler 0.2.49 → 0.2.51
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 +9 -0
- package/bench/native-transform-suite.mjs +8 -0
- package/bench/smoke.mjs +4 -0
- package/dist/declarations/runtime.d.ts +6 -0
- package/dist/declarations/semantic-patch-bundle.d.ts +7 -0
- package/dist/declarations/universal-conversion-artifacts.d.ts +156 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/index-impl/semanticPatchBundleRecords.js +7 -3
- package/dist/universal-conversion-artifact-query.js +64 -0
- package/dist/universal-conversion-artifacts.js +293 -0
- package/dist/universal-conversion-route-operations.js +57 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -129,6 +129,7 @@ import {
|
|
|
129
129
|
createNativeParserAstFormatMatrix,
|
|
130
130
|
createProjectionTargetLossMatrix,
|
|
131
131
|
createUniversalCapabilityMatrix,
|
|
132
|
+
createUniversalConversionArtifacts,
|
|
132
133
|
createUniversalConversionPlan,
|
|
133
134
|
queryUniversalConversionPlan,
|
|
134
135
|
importNativeSource
|
|
@@ -178,6 +179,12 @@ const pythonToRust = queryUniversalConversionPlan(conversionPlan, {
|
|
|
178
179
|
console.log(pythonToRust.mode); // "semantic-index-only", "target-adapter", "stub-only", etc.
|
|
179
180
|
console.log(pythonToRust.missingEvidence); // adapter/proof/source-map gaps for swarm workers
|
|
180
181
|
console.log(pythonToRust.mergeScore.value); // sortable merge-review score, not a proof
|
|
182
|
+
|
|
183
|
+
const conversionArtifacts = createUniversalConversionArtifacts(conversionPlan);
|
|
184
|
+
console.log(conversionArtifacts.historyRecords[0].kind); // "frontier.lang.semanticHistoryRecord"
|
|
185
|
+
console.log(conversionArtifacts.patchBundleRecords[0].admission.autoMergeClaim); // false
|
|
186
|
+
console.log(conversionArtifacts.index.semanticOperationKinds); // sourcePreservation/projection/merge
|
|
187
|
+
console.log(conversionArtifacts.routeArtifacts[0].semanticOperations.summary.conflictKeys);
|
|
181
188
|
```
|
|
182
189
|
|
|
183
190
|
The projection target matrix separates five runtime/API classes:
|
|
@@ -192,6 +199,8 @@ The projection target matrix separates five runtime/API classes:
|
|
|
192
199
|
|
|
193
200
|
`createUniversalConversionPlan` turns that capability evidence into coordinator tasks: preserve exact source, run a target adapter, emit stubs, attach semantic-index evidence, or block the route until missing parser/adapter/proof evidence exists. Every route carries `autoMergeClaim: false`, `semanticEquivalenceClaim: false`, missing evidence, task hints, and a `frontier.lang.semanticMergeScore.v1` score for swarm merge admission.
|
|
194
201
|
|
|
202
|
+
`createUniversalConversionArtifacts` materializes those route refs into compact `SemanticHistoryRecord`, `SemanticPatchBundleRecord`, and semantic-operation artifacts that swarm collectors can index by route, history ID, patch-bundle ID, operation kind, source path, ownership key, conflict key, evidence, proof, readiness, and admission status. It is still review evidence, not target-code proof: blocked and semantic-index-only routes stay blocked/needs-review, and every artifact keeps `autoMergeClaim: false` plus `semanticEquivalenceClaim: false`.
|
|
203
|
+
|
|
195
204
|
Preserve exact native source text, token/trivia hashes, comments, whitespace, and source directives as evidence. This does not claim full semantic understanding; it keeps round-trip material available while exact parser adapters catch up:
|
|
196
205
|
|
|
197
206
|
```js
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
createSemanticImportSidecar,
|
|
6
6
|
createSemanticSlice,
|
|
7
7
|
createSemanticSliceAdmissionRecord,
|
|
8
|
+
createUniversalConversionArtifacts,
|
|
8
9
|
createUniversalConversionPlan,
|
|
9
10
|
projectNativeImportToSource,
|
|
10
11
|
summarizeNativeImportFeatureEvidence,
|
|
@@ -54,6 +55,9 @@ export function measureNativeTransformations(nativeImportResults) {
|
|
|
54
55
|
targets: ['javascript', 'rust', 'python']
|
|
55
56
|
});
|
|
56
57
|
const conversionPlanDurationMs = performance.now() - conversionPlanStart;
|
|
58
|
+
const conversionArtifactsStart = performance.now();
|
|
59
|
+
const conversionArtifacts = createUniversalConversionArtifacts(conversionPlan);
|
|
60
|
+
const conversionArtifactsDurationMs = performance.now() - conversionArtifactsStart;
|
|
57
61
|
|
|
58
62
|
const featureEvidenceStart = performance.now();
|
|
59
63
|
const featureEvidenceSummaries = nativeImportResults.map((imported) => summarizeNativeImportFeatureEvidence(imported.losses, {
|
|
@@ -88,6 +92,10 @@ export function measureNativeTransformations(nativeImportResults) {
|
|
|
88
92
|
conversionPlanRoutes: conversionPlan.routes.length,
|
|
89
93
|
conversionPlanBlocked: conversionPlan.summary.blockedRoutes,
|
|
90
94
|
conversionPlanDurationMs,
|
|
95
|
+
conversionArtifacts: conversionArtifacts.summary.routes,
|
|
96
|
+
conversionArtifactHistories: conversionArtifacts.summary.histories,
|
|
97
|
+
conversionArtifactPatchBundles: conversionArtifacts.summary.patchBundles,
|
|
98
|
+
conversionArtifactsDurationMs,
|
|
91
99
|
featureEvidencePolicyMatches,
|
|
92
100
|
featureEvidenceDurationMs,
|
|
93
101
|
nativeProjections: nativeProjections.length,
|
package/bench/smoke.mjs
CHANGED
|
@@ -60,6 +60,10 @@ console.log(JSON.stringify({
|
|
|
60
60
|
conversionPlanRoutes: transformMetrics.conversionPlanRoutes,
|
|
61
61
|
conversionPlanBlocked: transformMetrics.conversionPlanBlocked,
|
|
62
62
|
conversionPlanDurationMs: Number(transformMetrics.conversionPlanDurationMs.toFixed(2)),
|
|
63
|
+
conversionArtifacts: transformMetrics.conversionArtifacts,
|
|
64
|
+
conversionArtifactHistories: transformMetrics.conversionArtifactHistories,
|
|
65
|
+
conversionArtifactPatchBundles: transformMetrics.conversionArtifactPatchBundles,
|
|
66
|
+
conversionArtifactsDurationMs: Number(transformMetrics.conversionArtifactsDurationMs.toFixed(2)),
|
|
63
67
|
featureEvidencePolicyMatches: transformMetrics.featureEvidencePolicyMatches,
|
|
64
68
|
featureEvidenceDurationMs: Number(transformMetrics.featureEvidenceDurationMs.toFixed(2)),
|
|
65
69
|
nativeProjections: transformMetrics.nativeProjections,
|
|
@@ -37,6 +37,7 @@ import type { NativeParserFeatureCategory, NativeParserFeatureCoverageStatus, Na
|
|
|
37
37
|
import type { NativeImportCoverageLanguage, NativeImportCoverageMatrix, NativeImportCoverageMatrixOptions } from './native-import-coverage.js';
|
|
38
38
|
import type { ProjectionTargetLossClass, ProjectionSourceProjectionCoverage, ProjectionTargetCoverageEntry, ProjectionTargetLanguageCoverage, ProjectionTargetLossMatrix, ProjectionTargetLossMatrixOptions } from './projection-coverage.js';
|
|
39
39
|
import type { UniversalCapabilityLanguageRow, UniversalCapabilityMatrix, UniversalCapabilityMatrixOptions } from './universal-capability.js';
|
|
40
|
+
import type { CreateUniversalConversionArtifactsInput, CreateUniversalConversionArtifactsOptions, UniversalConversionArtifactQuery, UniversalConversionArtifacts, UniversalConversionRouteArtifact } from './universal-conversion-artifacts.js';
|
|
40
41
|
import type { UniversalConversionPlan, UniversalConversionPlanOptions, UniversalConversionPlanQuery, UniversalConversionPlanQueryResult } from './universal-conversion-plan.js';
|
|
41
42
|
import type { UniversalDialectRegistry, UniversalDialectRegistryInput, UniversalDialectRecordInput, UniversalExternRecordInput } from './universal-dialects.js';
|
|
42
43
|
import type { NativeImportContractSource, NativeImportSourcePreservationRecordSummary, NativeImportSourcePreservationContract, NativeImportAdapterCoverageRecordSummary, NativeImportAdapterCoverageContract, NativeImportRegionSummary, NativeImportSourceMapSummary, NativeImportReadinessContract, NativeImportResultContract, NativeImportResultContractOptions } from './native-import-contracts.js';
|
|
@@ -88,7 +89,12 @@ export declare function createNativeParserFeatureMatrix(options?: NativeParserFe
|
|
|
88
89
|
export declare function queryNativeParserFeatureMatrix(matrixOrOptions?: NativeParserFeatureMatrix | NativeParserFeatureMatrixOptions, query?: NativeParserFeatureMatrixQuery): NativeParserFeatureMatrixQueryResult;
|
|
89
90
|
export declare function createProjectionTargetLossMatrix(options?: ProjectionTargetLossMatrixOptions): ProjectionTargetLossMatrix;
|
|
90
91
|
export declare function createUniversalCapabilityMatrix(options?: UniversalCapabilityMatrixOptions): UniversalCapabilityMatrix;
|
|
92
|
+
export declare function createUniversalConversionArtifacts(input?: CreateUniversalConversionArtifactsInput, options?: CreateUniversalConversionArtifactsOptions): UniversalConversionArtifacts;
|
|
91
93
|
export declare function createUniversalConversionPlan(options?: UniversalConversionPlanOptions): UniversalConversionPlan;
|
|
94
|
+
export declare function queryUniversalConversionArtifacts(
|
|
95
|
+
records: UniversalConversionArtifacts | UniversalConversionRouteArtifact | readonly (UniversalConversionArtifacts | UniversalConversionRouteArtifact)[],
|
|
96
|
+
query?: UniversalConversionArtifactQuery
|
|
97
|
+
): readonly UniversalConversionRouteArtifact[];
|
|
92
98
|
export declare function queryUniversalConversionPlan(
|
|
93
99
|
planOrOptions?: UniversalConversionPlan | UniversalConversionPlanOptions,
|
|
94
100
|
query?: UniversalConversionPlanQuery
|
|
@@ -101,6 +101,7 @@ export interface SemanticPatchBundleRecordIndex {
|
|
|
101
101
|
readonly evidenceIds: readonly string[];
|
|
102
102
|
readonly proofIds: readonly string[];
|
|
103
103
|
readonly historyIds: readonly string[];
|
|
104
|
+
readonly semanticOperationIds: readonly string[];
|
|
104
105
|
readonly patchIds: readonly string[];
|
|
105
106
|
readonly mergeCandidateIds: readonly string[];
|
|
106
107
|
readonly readinesses: readonly string[];
|
|
@@ -125,6 +126,7 @@ export interface SemanticPatchBundleRecord {
|
|
|
125
126
|
readonly evidenceIds: readonly string[];
|
|
126
127
|
readonly proofIds: readonly string[];
|
|
127
128
|
readonly historyIds: readonly string[];
|
|
129
|
+
readonly semanticOperationIds: readonly string[];
|
|
128
130
|
readonly admission: SemanticPatchBundleAdmission;
|
|
129
131
|
readonly index: SemanticPatchBundleRecordIndex;
|
|
130
132
|
readonly summary: {
|
|
@@ -133,6 +135,7 @@ export interface SemanticPatchBundleRecord {
|
|
|
133
135
|
readonly evidenceIds: number;
|
|
134
136
|
readonly proofIds: number;
|
|
135
137
|
readonly historyIds: number;
|
|
138
|
+
readonly semanticOperations: number;
|
|
136
139
|
readonly reviewRequired: boolean;
|
|
137
140
|
readonly autoMergeClaim: false;
|
|
138
141
|
};
|
|
@@ -159,6 +162,8 @@ export interface CreateSemanticPatchBundleRecordOptions {
|
|
|
159
162
|
readonly proofIds?: readonly string[] | string;
|
|
160
163
|
readonly historyId?: string;
|
|
161
164
|
readonly historyIds?: readonly string[] | string;
|
|
165
|
+
readonly semanticOperationId?: string;
|
|
166
|
+
readonly semanticOperationIds?: readonly string[] | string;
|
|
162
167
|
readonly conflictKeys?: readonly string[] | string;
|
|
163
168
|
readonly admission?: Partial<SemanticPatchBundleAdmission>;
|
|
164
169
|
readonly metadata?: Record<string, unknown>;
|
|
@@ -199,6 +204,8 @@ export interface SemanticPatchBundleRecordQuery {
|
|
|
199
204
|
readonly proofIds?: readonly string[];
|
|
200
205
|
readonly historyId?: string | readonly string[];
|
|
201
206
|
readonly historyIds?: readonly string[];
|
|
207
|
+
readonly semanticOperationId?: string | readonly string[];
|
|
208
|
+
readonly semanticOperationIds?: readonly string[];
|
|
202
209
|
readonly readiness?: SemanticMergeReadiness | string | readonly string[];
|
|
203
210
|
readonly readinesses?: readonly string[];
|
|
204
211
|
readonly admissionStatus?: SemanticPatchBundleAdmissionStatus | readonly string[];
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FrontierSourceLanguage,
|
|
3
|
+
SemanticOperationSet,
|
|
4
|
+
SemanticMergeReadiness
|
|
5
|
+
} from '@shapeshift-labs/frontier-lang-kernel';
|
|
6
|
+
import type { FrontierCompileTarget } from './compile.js';
|
|
7
|
+
import type { SemanticHistoryRecord } from './semantic-history.js';
|
|
8
|
+
import type { SemanticPatchBundleRecord } from './semantic-patch-bundle.js';
|
|
9
|
+
import type {
|
|
10
|
+
UniversalConversionAdmissionAction,
|
|
11
|
+
UniversalConversionPlan,
|
|
12
|
+
UniversalConversionPlanOptions,
|
|
13
|
+
UniversalConversionPriority,
|
|
14
|
+
UniversalConversionRoute,
|
|
15
|
+
UniversalConversionRouteAction,
|
|
16
|
+
UniversalConversionRouteMode,
|
|
17
|
+
UniversalConversionMergeScore
|
|
18
|
+
} from './universal-conversion-plan.js';
|
|
19
|
+
|
|
20
|
+
export type UniversalConversionArtifactAdmissionStatus = 'queued' | 'needs-review' | 'blocked' | string;
|
|
21
|
+
export type UniversalConversionArtifactMaterializationStatus = 'materialized' | 'planned-only' | 'missing' | 'failed' | string;
|
|
22
|
+
|
|
23
|
+
export interface UniversalConversionArtifactMaterialization {
|
|
24
|
+
readonly status: UniversalConversionArtifactMaterializationStatus;
|
|
25
|
+
readonly plannedHistoryIds: readonly string[];
|
|
26
|
+
readonly materializedHistoryIds: readonly string[];
|
|
27
|
+
readonly patchBundleIds: readonly string[];
|
|
28
|
+
readonly sourceMapLinkIds: readonly string[];
|
|
29
|
+
readonly semanticOperationIds: readonly string[];
|
|
30
|
+
readonly evidenceIds: readonly string[];
|
|
31
|
+
readonly proofIds: readonly string[];
|
|
32
|
+
readonly autoMergeClaim: false;
|
|
33
|
+
readonly semanticEquivalenceClaim: false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface UniversalConversionRouteArtifact {
|
|
37
|
+
readonly kind: 'frontier.lang.universalConversionRouteArtifact';
|
|
38
|
+
readonly version: 1;
|
|
39
|
+
readonly schema: 'frontier.lang.universalConversionRouteArtifact.v1';
|
|
40
|
+
readonly routeId: string;
|
|
41
|
+
readonly planId?: string;
|
|
42
|
+
readonly sourceLanguage?: FrontierSourceLanguage | string;
|
|
43
|
+
readonly target?: FrontierCompileTarget | string;
|
|
44
|
+
readonly mode: UniversalConversionRouteMode;
|
|
45
|
+
readonly routeAction: UniversalConversionRouteAction;
|
|
46
|
+
readonly priority: UniversalConversionPriority;
|
|
47
|
+
readonly readiness: SemanticMergeReadiness | string;
|
|
48
|
+
readonly admissionAction: UniversalConversionAdmissionAction;
|
|
49
|
+
readonly admissionStatus: UniversalConversionArtifactAdmissionStatus;
|
|
50
|
+
readonly reviewRequired: true;
|
|
51
|
+
readonly history: SemanticHistoryRecord;
|
|
52
|
+
readonly patchBundle: SemanticPatchBundleRecord;
|
|
53
|
+
readonly semanticOperations: SemanticOperationSet;
|
|
54
|
+
readonly materialization: UniversalConversionArtifactMaterialization;
|
|
55
|
+
readonly mergeScore?: UniversalConversionMergeScore;
|
|
56
|
+
readonly autoMergeClaim: false;
|
|
57
|
+
readonly semanticEquivalenceClaim: false;
|
|
58
|
+
readonly metadata: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface UniversalConversionArtifactIndex {
|
|
62
|
+
readonly routeIds: readonly string[];
|
|
63
|
+
readonly historyIds: readonly string[];
|
|
64
|
+
readonly patchBundleIds: readonly string[];
|
|
65
|
+
readonly languages: readonly string[];
|
|
66
|
+
readonly targets: readonly string[];
|
|
67
|
+
readonly modes: readonly string[];
|
|
68
|
+
readonly readinesses: readonly string[];
|
|
69
|
+
readonly admissionStatuses: readonly string[];
|
|
70
|
+
readonly sourcePaths: readonly string[];
|
|
71
|
+
readonly sourceHashes: readonly string[];
|
|
72
|
+
readonly ownershipKeys: readonly string[];
|
|
73
|
+
readonly conflictKeys: readonly string[];
|
|
74
|
+
readonly evidenceIds: readonly string[];
|
|
75
|
+
readonly proofIds: readonly string[];
|
|
76
|
+
readonly semanticOperationIds: readonly string[];
|
|
77
|
+
readonly semanticOperationKinds: readonly string[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface UniversalConversionArtifacts {
|
|
81
|
+
readonly kind: 'frontier.lang.universalConversionArtifacts';
|
|
82
|
+
readonly version: 1;
|
|
83
|
+
readonly schema: 'frontier.lang.universalConversionArtifacts.v1';
|
|
84
|
+
readonly id: string;
|
|
85
|
+
readonly planId?: string;
|
|
86
|
+
readonly generatedAt: number | string;
|
|
87
|
+
readonly routeArtifacts: readonly UniversalConversionRouteArtifact[];
|
|
88
|
+
readonly historyRecords: readonly SemanticHistoryRecord[];
|
|
89
|
+
readonly patchBundleRecords: readonly SemanticPatchBundleRecord[];
|
|
90
|
+
readonly index: UniversalConversionArtifactIndex;
|
|
91
|
+
readonly summary: {
|
|
92
|
+
readonly routes: number;
|
|
93
|
+
readonly histories: number;
|
|
94
|
+
readonly patchBundles: number;
|
|
95
|
+
readonly semanticOperations: number;
|
|
96
|
+
readonly reviewRequired: number;
|
|
97
|
+
readonly blocked: number;
|
|
98
|
+
readonly autoMergeClaims: 0;
|
|
99
|
+
readonly semanticEquivalenceClaims: 0;
|
|
100
|
+
};
|
|
101
|
+
readonly metadata: {
|
|
102
|
+
readonly autoMergeClaim: false;
|
|
103
|
+
readonly semanticEquivalenceClaim: false;
|
|
104
|
+
readonly note: string;
|
|
105
|
+
} & Record<string, unknown>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface CreateUniversalConversionArtifactsOptions {
|
|
109
|
+
readonly id?: string;
|
|
110
|
+
readonly planId?: string;
|
|
111
|
+
readonly generatedAt?: number | string;
|
|
112
|
+
readonly routeId?: string;
|
|
113
|
+
readonly sourceLanguage?: FrontierSourceLanguage | string;
|
|
114
|
+
readonly target?: FrontierCompileTarget | string;
|
|
115
|
+
readonly mode?: UniversalConversionRouteMode;
|
|
116
|
+
readonly readiness?: SemanticMergeReadiness | string;
|
|
117
|
+
readonly admissionAction?: UniversalConversionAdmissionAction;
|
|
118
|
+
readonly maxRoutes?: number;
|
|
119
|
+
readonly metadata?: Record<string, unknown>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type CreateUniversalConversionArtifactsInput =
|
|
123
|
+
| UniversalConversionPlan
|
|
124
|
+
| UniversalConversionRoute
|
|
125
|
+
| UniversalConversionPlanOptions;
|
|
126
|
+
|
|
127
|
+
export interface UniversalConversionArtifactQuery {
|
|
128
|
+
readonly routeId?: string | readonly string[];
|
|
129
|
+
readonly historyId?: string | readonly string[];
|
|
130
|
+
readonly patchBundleId?: string | readonly string[];
|
|
131
|
+
readonly sourceLanguage?: FrontierSourceLanguage | string | readonly string[];
|
|
132
|
+
readonly target?: FrontierCompileTarget | string | readonly string[];
|
|
133
|
+
readonly mode?: UniversalConversionRouteMode | readonly string[];
|
|
134
|
+
readonly readiness?: SemanticMergeReadiness | string | readonly string[];
|
|
135
|
+
readonly admissionAction?: UniversalConversionAdmissionAction | readonly string[];
|
|
136
|
+
readonly admissionStatus?: UniversalConversionArtifactAdmissionStatus | readonly string[];
|
|
137
|
+
readonly priority?: UniversalConversionPriority | readonly string[];
|
|
138
|
+
readonly routeAction?: UniversalConversionRouteAction | readonly string[];
|
|
139
|
+
readonly sourcePath?: string | readonly string[];
|
|
140
|
+
readonly sourceHash?: string | readonly string[];
|
|
141
|
+
readonly ownershipKey?: string | readonly string[];
|
|
142
|
+
readonly conflictKey?: string | readonly string[];
|
|
143
|
+
readonly evidenceId?: string | readonly string[];
|
|
144
|
+
readonly proofId?: string | readonly string[];
|
|
145
|
+
readonly semanticOperationId?: string | readonly string[];
|
|
146
|
+
readonly semanticOperationKind?: string | readonly string[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export declare function createUniversalConversionArtifacts(
|
|
150
|
+
input?: CreateUniversalConversionArtifactsInput,
|
|
151
|
+
options?: CreateUniversalConversionArtifactsOptions
|
|
152
|
+
): UniversalConversionArtifacts;
|
|
153
|
+
export declare function queryUniversalConversionArtifacts(
|
|
154
|
+
records: UniversalConversionArtifacts | UniversalConversionRouteArtifact | readonly (UniversalConversionArtifacts | UniversalConversionRouteArtifact)[],
|
|
155
|
+
query?: UniversalConversionArtifactQuery
|
|
156
|
+
): readonly UniversalConversionRouteArtifact[];
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './declarations/native-import-coverage.js';
|
|
|
6
6
|
export * from './declarations/projection-coverage.js';
|
|
7
7
|
export * from './declarations/projection-readiness.js';
|
|
8
8
|
export * from './declarations/universal-capability.js';
|
|
9
|
+
export * from './declarations/universal-conversion-artifacts.js';
|
|
9
10
|
export * from './declarations/universal-conversion-plan.js';
|
|
10
11
|
export * from './declarations/universal-dialects.js';
|
|
11
12
|
export * from './declarations/language-adapter-package-contracts.js';
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { createTreeSitterNativeImporterAdapter } from './internal/index-impl/cre
|
|
|
29
29
|
export { createTypeScriptCompilerNativeImporterAdapter } from './internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js';
|
|
30
30
|
export { createUniversalAstFromDocument } from './internal/index-impl/createUniversalAstFromDocument.js';
|
|
31
31
|
export { createUniversalCapabilityMatrix } from './internal/index-impl/createUniversalCapabilityMatrix.js';
|
|
32
|
+
export { createUniversalConversionArtifacts, queryUniversalConversionArtifacts } from './universal-conversion-artifacts.js';
|
|
32
33
|
export { createUniversalConversionPlan } from './internal/index-impl/createUniversalConversionPlan.js';
|
|
33
34
|
export { attachUniversalDialectRegistry, createUniversalDialectRecord, createUniversalDialectRegistry, createUniversalExternRecord, summarizeUniversalDialectRegistry, UniversalDialectConstructKinds, UniversalDialectProjectionDispositions } from './universal-dialect-registry.js';
|
|
34
35
|
export { diffNativeSourceImports } from './internal/index-impl/diffNativeSourceImports.js';
|
|
@@ -27,6 +27,7 @@ export function createSemanticPatchBundleRecord(input={},options={}){
|
|
|
27
27
|
const evidenceIds=uniqueStrings([...strings(options.evidenceIds),...strings(source.evidenceIds),...evidenceRecords.map((record)=>record?.id),...strings(mergeCandidate?.evidenceIds)]);
|
|
28
28
|
const proofIds=uniqueStrings([...strings(options.proofIds),...strings(source.proofIds),...evidenceRecords.filter((record)=>record?.kind==='proof').map((record)=>record.id),...strings(mergeCandidate?.proofIds)]);
|
|
29
29
|
const historyIds=uniqueStrings([...strings(options.historyIds),...strings(options.historyId),...strings(source.historyIds),...strings(source.historyId)]);
|
|
30
|
+
const semanticOperationIds=uniqueStrings([...strings(options.semanticOperationIds),...strings(options.semanticOperationId),...strings(source.semanticOperationIds),...strings(source.semanticOperationId),...strings(patch?.semanticOperationIds),...strings(mergeCandidate?.semanticOperationIds)]);
|
|
30
31
|
const conflictKeys=uniqueStrings([
|
|
31
32
|
...strings(options.conflictKeys),
|
|
32
33
|
...strings(source.conflictKeys),
|
|
@@ -39,7 +40,7 @@ export function createSemanticPatchBundleRecord(input={},options={}){
|
|
|
39
40
|
??`semantic_patch_bundle_${idFragment(firstString(source.id,patchId,mergeCandidateId,source.sourcePath,source.language,'record'))}`;
|
|
40
41
|
const language=options.language??source.language??mergeCandidate?.language??sources.find((item)=>item.language)?.language;
|
|
41
42
|
const sourcePath=options.sourcePath??source.sourcePath??mergeCandidate?.sourcePath??sources.find((item)=>item.sourcePath)?.sourcePath;
|
|
42
|
-
const index=recordIndex({baseHash,targetHash,sources,changedRegions,sourceMapLinks,evidenceIds,proofIds,historyIds,patchId,mergeCandidateId,admission});
|
|
43
|
+
const index=recordIndex({baseHash,targetHash,sources,changedRegions,sourceMapLinks,evidenceIds,proofIds,historyIds,semanticOperationIds,patchId,mergeCandidateId,admission});
|
|
43
44
|
return{
|
|
44
45
|
kind:'frontier.lang.semanticPatchBundleRecord',
|
|
45
46
|
version:1,
|
|
@@ -58,9 +59,10 @@ export function createSemanticPatchBundleRecord(input={},options={}){
|
|
|
58
59
|
evidenceIds,
|
|
59
60
|
proofIds,
|
|
60
61
|
historyIds,
|
|
62
|
+
semanticOperationIds,
|
|
61
63
|
admission,
|
|
62
64
|
index,
|
|
63
|
-
summary:{changedRegions:changedRegions.length,sourceMapLinks:sourceMapLinks.length,evidenceIds:evidenceIds.length,proofIds:proofIds.length,historyIds:historyIds.length,reviewRequired:admission.reviewRequired,autoMergeClaim:admission.autoMergeClaim},
|
|
65
|
+
summary:{changedRegions:changedRegions.length,sourceMapLinks:sourceMapLinks.length,evidenceIds:evidenceIds.length,proofIds:proofIds.length,historyIds:historyIds.length,semanticOperations:semanticOperationIds.length,reviewRequired:admission.reviewRequired,autoMergeClaim:admission.autoMergeClaim},
|
|
64
66
|
metadata:compactRecord({
|
|
65
67
|
sourceChangeSetId:source.kind==='frontier.lang.nativeSourceChangeSet'?source.id:undefined,
|
|
66
68
|
patchRisk:patch?.risk,
|
|
@@ -202,6 +204,7 @@ function recordIndex(parts){
|
|
|
202
204
|
evidenceIds:parts.evidenceIds,
|
|
203
205
|
proofIds:parts.proofIds,
|
|
204
206
|
historyIds:parts.historyIds,
|
|
207
|
+
semanticOperationIds:uniqueStrings(parts.semanticOperationIds),
|
|
205
208
|
patchIds:uniqueStrings([parts.patchId]),
|
|
206
209
|
mergeCandidateIds:uniqueStrings([parts.mergeCandidateId]),
|
|
207
210
|
readinesses:uniqueStrings([parts.admission.readiness,...parts.changedRegions.map((region)=>region.admission?.readiness)]),
|
|
@@ -210,7 +213,7 @@ function recordIndex(parts){
|
|
|
210
213
|
}
|
|
211
214
|
|
|
212
215
|
function matchesRecord(record,query){
|
|
213
|
-
const index=record.index??recordIndex({...record,baseHash:record.baseHash,targetHash:record.targetHash,sources:record.sources??[],changedRegions:record.changedRegions??[],sourceMapLinks:record.sourceMapLinks??[],evidenceIds:record.evidenceIds??[],proofIds:record.proofIds??[],historyIds:record.historyIds??[],patchId:record.patchId,mergeCandidateId:record.mergeCandidateId,admission:record.admission??{}});
|
|
216
|
+
const index=record.index??recordIndex({...record,baseHash:record.baseHash,targetHash:record.targetHash,sources:record.sources??[],changedRegions:record.changedRegions??[],sourceMapLinks:record.sourceMapLinks??[],evidenceIds:record.evidenceIds??[],proofIds:record.proofIds??[],historyIds:record.historyIds??[],semanticOperationIds:record.semanticOperationIds??[],patchId:record.patchId,mergeCandidateId:record.mergeCandidateId,admission:record.admission??{}});
|
|
214
217
|
return matchAny(queryValues(query.id,query.ids),[record.id])
|
|
215
218
|
&&matchAny(queryValues(query.patchId,query.patchIds),index.patchIds)
|
|
216
219
|
&&matchAny(queryValues(query.mergeCandidateId,query.mergeCandidateIds),index.mergeCandidateIds)
|
|
@@ -227,6 +230,7 @@ function matchesRecord(record,query){
|
|
|
227
230
|
&&matchAny(queryValues(query.evidenceId,query.evidenceIds),index.evidenceIds)
|
|
228
231
|
&&matchAny(queryValues(query.proofId,query.proofIds),index.proofIds)
|
|
229
232
|
&&matchAny(queryValues(query.historyId,query.historyIds),index.historyIds)
|
|
233
|
+
&&matchAny(queryValues(query.semanticOperationId,query.semanticOperationIds),index.semanticOperationIds)
|
|
230
234
|
&&matchAny(queryValues(query.readiness,query.readinesses),index.readinesses)
|
|
231
235
|
&&matchAny(queryValues(query.admissionStatus,query.admissionStatuses),index.admissionStatuses);
|
|
232
236
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { uniqueStrings } from './native-import-utils.js';
|
|
2
|
+
|
|
3
|
+
export function queryUniversalConversionArtifacts(records, query = {}) {
|
|
4
|
+
return artifactRecords(records)
|
|
5
|
+
.filter((record) => matchesArtifact(record, query))
|
|
6
|
+
.sort((left, right) => Number(right.mergeScore?.sortKey ?? 0) - Number(left.mergeScore?.sortKey ?? 0)
|
|
7
|
+
|| String(left.routeId).localeCompare(String(right.routeId)));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function artifactIndex(routeArtifacts) {
|
|
11
|
+
return {
|
|
12
|
+
routeIds: uniqueStrings(routeArtifacts.map((artifact) => artifact.routeId)),
|
|
13
|
+
historyIds: uniqueStrings(routeArtifacts.map((artifact) => artifact.history.id)),
|
|
14
|
+
patchBundleIds: uniqueStrings(routeArtifacts.map((artifact) => artifact.patchBundle.id)),
|
|
15
|
+
languages: uniqueStrings(routeArtifacts.map((artifact) => artifact.sourceLanguage)),
|
|
16
|
+
targets: uniqueStrings(routeArtifacts.map((artifact) => artifact.target)),
|
|
17
|
+
modes: uniqueStrings(routeArtifacts.map((artifact) => artifact.mode)),
|
|
18
|
+
readinesses: uniqueStrings(routeArtifacts.map((artifact) => artifact.readiness)),
|
|
19
|
+
admissionStatuses: uniqueStrings(routeArtifacts.map((artifact) => artifact.admissionStatus)),
|
|
20
|
+
sourcePaths: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.index.sourcePaths)),
|
|
21
|
+
sourceHashes: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.index.sourceHashes)),
|
|
22
|
+
ownershipKeys: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.index.ownershipKeys)),
|
|
23
|
+
conflictKeys: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.index.conflictKeys)),
|
|
24
|
+
evidenceIds: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.evidenceIds)),
|
|
25
|
+
proofIds: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.proofIds)),
|
|
26
|
+
semanticOperationIds: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.semanticOperations?.operations ?? []).map((operation) => operation.id)),
|
|
27
|
+
semanticOperationKinds: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.semanticOperations?.operations ?? []).map((operation) => operation.operationKind))
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function artifactRecords(records) {
|
|
32
|
+
if (Array.isArray(records)) return records.flatMap(artifactRecords);
|
|
33
|
+
if (records?.kind === 'frontier.lang.universalConversionArtifacts') return records.routeArtifacts ?? [];
|
|
34
|
+
if (records?.kind === 'frontier.lang.universalConversionRouteArtifact') return [records];
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function matchesArtifact(record, query) {
|
|
39
|
+
return match(query.routeId, [record.routeId])
|
|
40
|
+
&& match(query.historyId, [record.history.id])
|
|
41
|
+
&& match(query.patchBundleId, [record.patchBundle.id])
|
|
42
|
+
&& match(query.sourceLanguage, [record.sourceLanguage])
|
|
43
|
+
&& match(query.target, [record.target])
|
|
44
|
+
&& match(query.mode, [record.mode])
|
|
45
|
+
&& match(query.routeAction, [record.routeAction])
|
|
46
|
+
&& match(query.priority, [record.priority])
|
|
47
|
+
&& match(query.readiness, [record.readiness])
|
|
48
|
+
&& match(query.admissionStatus, [record.admissionStatus])
|
|
49
|
+
&& match(query.sourcePath, record.history.index.sourcePaths)
|
|
50
|
+
&& match(query.sourceHash, record.history.index.sourceHashes)
|
|
51
|
+
&& match(query.ownershipKey, record.history.index.ownershipKeys)
|
|
52
|
+
&& match(query.conflictKey, record.history.index.conflictKeys)
|
|
53
|
+
&& match(query.evidenceId, record.history.evidenceIds)
|
|
54
|
+
&& match(query.proofId, record.history.proofIds)
|
|
55
|
+
&& match(query.semanticOperationId, (record.semanticOperations?.operations ?? []).map((operation) => operation.id))
|
|
56
|
+
&& match(query.semanticOperationKind, (record.semanticOperations?.operations ?? []).map((operation) => operation.operationKind));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function match(filter, values) {
|
|
60
|
+
const filters = Array.isArray(filter) ? filter : filter === undefined ? [] : [filter];
|
|
61
|
+
if (filters.length === 0) return true;
|
|
62
|
+
const valueSet = new Set((values ?? []).map(String));
|
|
63
|
+
return filters.some((item) => valueSet.has(String(item)));
|
|
64
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { idFragment, uniqueStrings } from './native-import-utils.js';
|
|
2
|
+
import { createUniversalConversionPlan } from './universal-conversion-plan.js';
|
|
3
|
+
import { artifactIndex } from './universal-conversion-artifact-query.js';
|
|
4
|
+
import { routeSemanticOperations } from './universal-conversion-route-operations.js';
|
|
5
|
+
import { createSemanticHistoryRecord } from './internal/index-impl/semanticHistoryRecords.js';
|
|
6
|
+
import { createSemanticPatchBundleRecord } from './internal/index-impl/semanticPatchBundleRecords.js';
|
|
7
|
+
|
|
8
|
+
export { queryUniversalConversionArtifacts } from './universal-conversion-artifact-query.js';
|
|
9
|
+
|
|
10
|
+
export function createUniversalConversionArtifacts(input = {}, options = {}) {
|
|
11
|
+
const generatedAt = options.generatedAt ?? input.generatedAt ?? Date.now();
|
|
12
|
+
const plan = input?.kind === 'frontier.lang.universalConversionPlan'
|
|
13
|
+
? input
|
|
14
|
+
: input?.target && input?.sourceLanguage
|
|
15
|
+
? undefined
|
|
16
|
+
: createUniversalConversionPlan(input);
|
|
17
|
+
const routes = selectRoutes(plan?.routes ?? (input?.target && input?.sourceLanguage ? [input] : []), options);
|
|
18
|
+
const routeArtifacts = routes.map((route) => createRouteArtifact(route, {
|
|
19
|
+
generatedAt,
|
|
20
|
+
planId: options.planId ?? plan?.id ?? route.mergeRefs?.planId,
|
|
21
|
+
metadata: options.metadata
|
|
22
|
+
}));
|
|
23
|
+
const historyRecords = routeArtifacts.map((artifact) => artifact.history);
|
|
24
|
+
const patchBundleRecords = routeArtifacts.map((artifact) => artifact.patchBundle);
|
|
25
|
+
const index = artifactIndex(routeArtifacts);
|
|
26
|
+
return {
|
|
27
|
+
kind: 'frontier.lang.universalConversionArtifacts',
|
|
28
|
+
version: 1,
|
|
29
|
+
schema: 'frontier.lang.universalConversionArtifacts.v1',
|
|
30
|
+
id: options.id ?? `universal_conversion_artifacts_${idFragment(index.routeIds.join('_') || plan?.id || 'routes')}`,
|
|
31
|
+
planId: plan?.id ?? options.planId,
|
|
32
|
+
generatedAt,
|
|
33
|
+
routeArtifacts,
|
|
34
|
+
historyRecords,
|
|
35
|
+
patchBundleRecords,
|
|
36
|
+
index,
|
|
37
|
+
summary: {
|
|
38
|
+
routes: routeArtifacts.length,
|
|
39
|
+
histories: historyRecords.length,
|
|
40
|
+
patchBundles: patchBundleRecords.length,
|
|
41
|
+
semanticOperations: routeArtifacts.reduce((sum, artifact) => sum + artifact.semanticOperations.operations.length, 0),
|
|
42
|
+
reviewRequired: routeArtifacts.filter((artifact) => artifact.reviewRequired).length,
|
|
43
|
+
blocked: routeArtifacts.filter((artifact) => artifact.admissionStatus === 'blocked').length,
|
|
44
|
+
autoMergeClaims: 0,
|
|
45
|
+
semanticEquivalenceClaims: 0
|
|
46
|
+
},
|
|
47
|
+
metadata: {
|
|
48
|
+
autoMergeClaim: false,
|
|
49
|
+
semanticEquivalenceClaim: false,
|
|
50
|
+
note: 'Materialized conversion artifacts are merge-review records. They preserve provenance and admission state but do not prove target semantic equivalence.',
|
|
51
|
+
...options.metadata
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function createRouteArtifact(route, options) {
|
|
57
|
+
const refs = route.mergeRefs ?? {};
|
|
58
|
+
const planId = options.planId ?? refs.planId;
|
|
59
|
+
const sources = normalizeSources(refs.sources, route);
|
|
60
|
+
const regions = routeRegions(route, refs, sources);
|
|
61
|
+
const sourceMapLinks = routeSourceMapLinks(route, refs, sources, regions);
|
|
62
|
+
const semanticOperations = routeSemanticOperations(route, refs, sources, regions, sourceMapLinks);
|
|
63
|
+
const admissionStatus = routeAdmissionStatus(route);
|
|
64
|
+
const reasonCodes = routeReasonCodes(route);
|
|
65
|
+
const historyId = refs.historyIds?.[0] ?? `history_${route.id}`;
|
|
66
|
+
const patchBundleId = refs.patchBundleIds?.[0] ?? `semantic_patch_bundle_${route.id}`;
|
|
67
|
+
const history = createSemanticHistoryRecord({
|
|
68
|
+
id: historyId,
|
|
69
|
+
createdAt: options.generatedAt,
|
|
70
|
+
language: route.sourceLanguage,
|
|
71
|
+
sourcePath: sources[0]?.sourcePath,
|
|
72
|
+
sources,
|
|
73
|
+
ownershipRegions: regions,
|
|
74
|
+
semanticCandidates: routeSemanticCandidates(route, refs),
|
|
75
|
+
evidenceIds: refs.evidenceIds,
|
|
76
|
+
proofIds: refs.proofIds,
|
|
77
|
+
replayLinks: refs.replayLinks,
|
|
78
|
+
admission: {
|
|
79
|
+
status: admissionStatus,
|
|
80
|
+
readiness: route.readiness,
|
|
81
|
+
reasonCodes,
|
|
82
|
+
evidenceIds: refs.evidenceIds,
|
|
83
|
+
metadata: routeAdmissionMetadata(route, planId)
|
|
84
|
+
},
|
|
85
|
+
metadata: routeRecordMetadata(route, planId, options.metadata)
|
|
86
|
+
}, { id: historyId, createdAt: options.generatedAt });
|
|
87
|
+
const patchBundle = createSemanticPatchBundleRecord({
|
|
88
|
+
id: patchBundleId,
|
|
89
|
+
language: route.sourceLanguage,
|
|
90
|
+
sourcePath: sources[0]?.sourcePath,
|
|
91
|
+
sources,
|
|
92
|
+
changedRegions: regions,
|
|
93
|
+
sourceMapLinks,
|
|
94
|
+
semanticOperationIds: semanticOperations.operations.map((operation) => operation.id),
|
|
95
|
+
evidenceIds: refs.evidenceIds,
|
|
96
|
+
proofIds: refs.proofIds,
|
|
97
|
+
historyIds: [history.id],
|
|
98
|
+
readiness: route.readiness,
|
|
99
|
+
conflictKeys: refs.conflictKeys,
|
|
100
|
+
admission: {
|
|
101
|
+
status: admissionStatus,
|
|
102
|
+
readiness: route.readiness,
|
|
103
|
+
reviewRequired: true,
|
|
104
|
+
reasonCodes,
|
|
105
|
+
conflictKeys: refs.conflictKeys,
|
|
106
|
+
evidenceIds: refs.evidenceIds,
|
|
107
|
+
metadata: routeAdmissionMetadata(route, planId)
|
|
108
|
+
},
|
|
109
|
+
metadata: routeRecordMetadata(route, planId, options.metadata)
|
|
110
|
+
}, { id: patchBundleId, createdAt: options.generatedAt });
|
|
111
|
+
const materialization = {
|
|
112
|
+
status: 'materialized',
|
|
113
|
+
plannedHistoryIds: refs.historyIds ?? [],
|
|
114
|
+
materializedHistoryIds: [history.id],
|
|
115
|
+
patchBundleIds: [patchBundle.id],
|
|
116
|
+
sourceMapLinkIds: patchBundle.index.sourceMapLinkIds,
|
|
117
|
+
semanticOperationIds: semanticOperations.operations.map((operation) => operation.id),
|
|
118
|
+
evidenceIds: history.evidenceIds,
|
|
119
|
+
proofIds: history.proofIds,
|
|
120
|
+
autoMergeClaim: false,
|
|
121
|
+
semanticEquivalenceClaim: false
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
kind: 'frontier.lang.universalConversionRouteArtifact',
|
|
125
|
+
version: 1,
|
|
126
|
+
schema: 'frontier.lang.universalConversionRouteArtifact.v1',
|
|
127
|
+
routeId: route.id,
|
|
128
|
+
planId,
|
|
129
|
+
sourceLanguage: route.sourceLanguage,
|
|
130
|
+
target: route.target,
|
|
131
|
+
mode: route.mode,
|
|
132
|
+
routeAction: route.routeAction,
|
|
133
|
+
priority: route.priority,
|
|
134
|
+
readiness: route.readiness,
|
|
135
|
+
admissionAction: route.admissionAction,
|
|
136
|
+
admissionStatus,
|
|
137
|
+
reviewRequired: true,
|
|
138
|
+
history,
|
|
139
|
+
patchBundle,
|
|
140
|
+
semanticOperations,
|
|
141
|
+
materialization,
|
|
142
|
+
mergeScore: route.mergeScore,
|
|
143
|
+
autoMergeClaim: false,
|
|
144
|
+
semanticEquivalenceClaim: false,
|
|
145
|
+
metadata: { ...routeRecordMetadata(route, planId, options.metadata), materialization }
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function selectRoutes(routes, options) {
|
|
150
|
+
const selected = (routes ?? []).filter((route) => {
|
|
151
|
+
if (options.routeId && route.id !== options.routeId) return false;
|
|
152
|
+
if (options.sourceLanguage && route.sourceLanguage !== options.sourceLanguage) return false;
|
|
153
|
+
if (options.target && route.target !== options.target) return false;
|
|
154
|
+
if (options.mode && route.mode !== options.mode) return false;
|
|
155
|
+
if (options.readiness && route.readiness !== options.readiness) return false;
|
|
156
|
+
if (options.admissionAction && route.admissionAction !== options.admissionAction) return false;
|
|
157
|
+
return true;
|
|
158
|
+
});
|
|
159
|
+
return Number.isFinite(options.maxRoutes) ? selected.slice(0, Math.max(0, Number(options.maxRoutes))) : selected;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function normalizeSources(sources, route) {
|
|
163
|
+
return (sources?.length ? sources : [{}]).map((source, index) => ({
|
|
164
|
+
id: source.sourceId ?? source.id ?? `route_source_${idFragment(route.id)}_${index + 1}`,
|
|
165
|
+
importId: source.importId,
|
|
166
|
+
language: route.sourceLanguage,
|
|
167
|
+
sourcePath: source.sourcePath,
|
|
168
|
+
sourceHash: source.sourceHash,
|
|
169
|
+
baseHash: source.baseHash,
|
|
170
|
+
targetHash: source.targetHash,
|
|
171
|
+
metadata: {
|
|
172
|
+
routeId: route.id,
|
|
173
|
+
target: route.target,
|
|
174
|
+
mode: route.mode
|
|
175
|
+
}
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function routeRegions(route, refs, sources) {
|
|
180
|
+
const source = sources[0] ?? {};
|
|
181
|
+
const keys = refs.semanticOwnershipKeys?.length
|
|
182
|
+
? refs.semanticOwnershipKeys
|
|
183
|
+
: [`conversion#${route.sourceLanguage ?? 'source'}#${route.target ?? 'target'}#${route.id}`];
|
|
184
|
+
return uniqueStrings(keys).map((key, index) => ({
|
|
185
|
+
id: `route_region_${idFragment(route.id)}_${index + 1}`,
|
|
186
|
+
key,
|
|
187
|
+
conflictKey: refs.conflictKeys?.[index] ?? refs.conflictKeys?.[0] ?? key,
|
|
188
|
+
changeKind: 'conversion-route',
|
|
189
|
+
regionKind: route.mode,
|
|
190
|
+
granularity: 'conversion-route',
|
|
191
|
+
precision: route.mode === 'preserve-source' ? 'exact-source' : 'semantic-route',
|
|
192
|
+
language: route.sourceLanguage,
|
|
193
|
+
sourcePath: source.sourcePath,
|
|
194
|
+
sourceHash: source.sourceHash,
|
|
195
|
+
sourceMapIds: refs.sourceMapIds,
|
|
196
|
+
sourceMapMappingIds: refs.sourceMapMappingIds,
|
|
197
|
+
admission: {
|
|
198
|
+
readiness: route.readiness,
|
|
199
|
+
action: route.admissionAction,
|
|
200
|
+
conflictKeys: refs.conflictKeys
|
|
201
|
+
},
|
|
202
|
+
metadata: {
|
|
203
|
+
routeId: route.id,
|
|
204
|
+
target: route.target,
|
|
205
|
+
mode: route.mode,
|
|
206
|
+
autoMergeClaim: false,
|
|
207
|
+
semanticEquivalenceClaim: false
|
|
208
|
+
}
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function routeSourceMapLinks(route, refs, sources, regions) {
|
|
213
|
+
const source = sources[0] ?? {};
|
|
214
|
+
const max = Math.max(refs.sourceMapIds?.length ?? 0, refs.sourceMapMappingIds?.length ?? 0);
|
|
215
|
+
return Array.from({ length: max }, (_, index) => ({
|
|
216
|
+
id: refs.sourceMapLinkIds?.[index] ?? `route_source_map_link_${idFragment(route.id)}_${index + 1}`,
|
|
217
|
+
sourceMapId: refs.sourceMapIds?.[index] ?? refs.sourceMapIds?.[0],
|
|
218
|
+
sourceMapMappingId: refs.sourceMapMappingIds?.[index],
|
|
219
|
+
sourcePath: source.sourcePath,
|
|
220
|
+
sourceHash: source.sourceHash,
|
|
221
|
+
targetPath: `${route.target}:${source.sourcePath ?? route.id}`,
|
|
222
|
+
precision: route.mode === 'preserve-source' ? 'exact-source' : 'semantic-route',
|
|
223
|
+
regionKey: regions[index % Math.max(1, regions.length)]?.key,
|
|
224
|
+
regionKind: route.mode
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function routeSemanticCandidates(route, refs) {
|
|
229
|
+
const ids = refs.mergeCandidateIds?.length ? refs.mergeCandidateIds : [`candidate_${route.id}`];
|
|
230
|
+
return uniqueStrings(ids).map((id) => ({
|
|
231
|
+
id,
|
|
232
|
+
sourcePath: refs.sources?.[0]?.sourcePath,
|
|
233
|
+
baseHash: refs.sources?.[0]?.baseHash,
|
|
234
|
+
targetHash: refs.sources?.[0]?.targetHash,
|
|
235
|
+
readiness: route.readiness,
|
|
236
|
+
conflictKeys: refs.conflictKeys ?? [],
|
|
237
|
+
ownershipKeys: refs.semanticOwnershipKeys ?? [],
|
|
238
|
+
evidenceIds: refs.evidenceIds ?? [],
|
|
239
|
+
proofIds: refs.proofIds ?? [],
|
|
240
|
+
replayIds: (refs.replayLinks ?? []).map((link) => link?.id).filter(Boolean),
|
|
241
|
+
metadata: {
|
|
242
|
+
routeId: route.id,
|
|
243
|
+
target: route.target,
|
|
244
|
+
mode: route.mode,
|
|
245
|
+
risk: route.mergeScore?.risk
|
|
246
|
+
}
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function routeAdmissionStatus(route) {
|
|
251
|
+
if (route.readiness === 'blocked' || route.admissionAction === 'reject') return 'blocked';
|
|
252
|
+
if (route.readiness === 'ready' && route.missingEvidence?.length === 0) return 'queued';
|
|
253
|
+
return 'needs-review';
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function routeReasonCodes(route) {
|
|
257
|
+
return uniqueStrings([
|
|
258
|
+
`mode:${route.mode}`,
|
|
259
|
+
`action:${route.routeAction}`,
|
|
260
|
+
...(route.missingEvidence ?? []).map((item) => `missing:${item}`),
|
|
261
|
+
...(route.blockers ?? []).map((item) => `blocker:${item}`),
|
|
262
|
+
...(route.review ?? []).map((item) => `review:${item}`)
|
|
263
|
+
]);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function routeAdmissionMetadata(route, planId) {
|
|
267
|
+
return {
|
|
268
|
+
planId,
|
|
269
|
+
routeId: route.id,
|
|
270
|
+
routeAction: route.routeAction,
|
|
271
|
+
admissionAction: route.admissionAction,
|
|
272
|
+
priority: route.priority,
|
|
273
|
+
mergeScore: route.mergeScore,
|
|
274
|
+
autoMergeClaim: false,
|
|
275
|
+
semanticEquivalenceClaim: false
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function routeRecordMetadata(route, planId, metadata) {
|
|
280
|
+
return {
|
|
281
|
+
planId,
|
|
282
|
+
routeId: route.id,
|
|
283
|
+
target: route.target,
|
|
284
|
+
mode: route.mode,
|
|
285
|
+
routeAction: route.routeAction,
|
|
286
|
+
missingEvidence: route.missingEvidence ?? [],
|
|
287
|
+
blockers: route.blockers ?? [],
|
|
288
|
+
review: route.review ?? [],
|
|
289
|
+
autoMergeClaim: false,
|
|
290
|
+
semanticEquivalenceClaim: false,
|
|
291
|
+
...metadata
|
|
292
|
+
};
|
|
293
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createSemanticOperationSet } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { uniqueStrings } from './native-import-utils.js';
|
|
3
|
+
|
|
4
|
+
export function routeSemanticOperations(route, refs, sources, regions, sourceMapLinks) {
|
|
5
|
+
const source = sources[0] ?? {};
|
|
6
|
+
return createSemanticOperationSet({
|
|
7
|
+
id: `semantic_operations_${route.id}`,
|
|
8
|
+
operations: [{
|
|
9
|
+
id: `semantic_operation_${route.id}`,
|
|
10
|
+
operationKind: routeOperationKind(route),
|
|
11
|
+
language: route.sourceLanguage,
|
|
12
|
+
name: route.routeAction,
|
|
13
|
+
target: typeof route.target === 'string' ? { language: route.target } : route.target,
|
|
14
|
+
nativeSourceId: source.id,
|
|
15
|
+
sourceMapIds: refs.sourceMapIds,
|
|
16
|
+
sourceMapMappingIds: refs.sourceMapMappingIds,
|
|
17
|
+
evidenceIds: refs.evidenceIds,
|
|
18
|
+
proofArtifactIds: refs.proofIds,
|
|
19
|
+
resources: routeOperationResources(route),
|
|
20
|
+
ownershipKeys: regions.map((region) => region.key),
|
|
21
|
+
conflictKeys: refs.conflictKeys,
|
|
22
|
+
readiness: route.readiness,
|
|
23
|
+
dynamic: route.mode === 'target-adapter' && route.readiness !== 'ready',
|
|
24
|
+
opaque: route.readiness === 'blocked' || route.mode === 'semantic-index-only',
|
|
25
|
+
metadata: routeOperationMetadata(route, source, sourceMapLinks)
|
|
26
|
+
}]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function routeOperationKind(route) {
|
|
31
|
+
if (route.mode === 'preserve-source') return 'sourcePreservation';
|
|
32
|
+
if (route.mode === 'target-adapter' || route.mode === 'stub-only') return 'projection';
|
|
33
|
+
if (route.mode === 'semantic-index-only') return 'merge';
|
|
34
|
+
return 'opaque';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function routeOperationResources(route) {
|
|
38
|
+
return uniqueStrings([route.adapter, route.adapterKind, route.target].filter(Boolean).map(String));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function routeOperationMetadata(route, source, sourceMapLinks) {
|
|
42
|
+
return {
|
|
43
|
+
routeId: route.id,
|
|
44
|
+
routeAction: route.routeAction,
|
|
45
|
+
admissionAction: route.admissionAction,
|
|
46
|
+
priority: route.priority,
|
|
47
|
+
sourcePath: source.sourcePath,
|
|
48
|
+
sourceHash: source.sourceHash,
|
|
49
|
+
sourceMapLinkIds: sourceMapLinks.map((link) => link.id),
|
|
50
|
+
targetLossKinds: route.evidence?.targetLossKinds ?? [],
|
|
51
|
+
missingEvidence: route.missingEvidence ?? [],
|
|
52
|
+
blockers: route.blockers ?? [],
|
|
53
|
+
review: route.review ?? [],
|
|
54
|
+
autoMergeClaim: false,
|
|
55
|
+
semanticEquivalenceClaim: false
|
|
56
|
+
};
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshift-labs/frontier-lang-compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.51",
|
|
4
4
|
"description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@shapeshift-labs/frontier-lang-c": "0.2.8",
|
|
61
61
|
"@shapeshift-labs/frontier-lang-checker": "0.3.7",
|
|
62
62
|
"@shapeshift-labs/frontier-lang-javascript": "0.2.8",
|
|
63
|
-
"@shapeshift-labs/frontier-lang-kernel": "0.3.
|
|
63
|
+
"@shapeshift-labs/frontier-lang-kernel": "0.3.12",
|
|
64
64
|
"@shapeshift-labs/frontier-lang-parser": "0.3.7",
|
|
65
65
|
"@shapeshift-labs/frontier-lang-python": "0.2.8",
|
|
66
66
|
"@shapeshift-labs/frontier-lang-rust": "0.2.8",
|