@shapeshift-labs/frontier-lang-compiler 0.2.50 → 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 CHANGED
@@ -183,6 +183,8 @@ console.log(pythonToRust.mergeScore.value); // sortable merge-review score, not
183
183
  const conversionArtifacts = createUniversalConversionArtifacts(conversionPlan);
184
184
  console.log(conversionArtifacts.historyRecords[0].kind); // "frontier.lang.semanticHistoryRecord"
185
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);
186
188
  ```
187
189
 
188
190
  The projection target matrix separates five runtime/API classes:
@@ -197,7 +199,7 @@ The projection target matrix separates five runtime/API classes:
197
199
 
198
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.
199
201
 
200
- `createUniversalConversionArtifacts` materializes those route refs into compact `SemanticHistoryRecord` and `SemanticPatchBundleRecord` artifacts that swarm collectors can index by route, history ID, patch-bundle ID, 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`.
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`.
201
203
 
202
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:
203
205
 
@@ -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[];
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  FrontierSourceLanguage,
3
+ SemanticOperationSet,
3
4
  SemanticMergeReadiness
4
5
  } from '@shapeshift-labs/frontier-lang-kernel';
5
6
  import type { FrontierCompileTarget } from './compile.js';
@@ -25,6 +26,7 @@ export interface UniversalConversionArtifactMaterialization {
25
26
  readonly materializedHistoryIds: readonly string[];
26
27
  readonly patchBundleIds: readonly string[];
27
28
  readonly sourceMapLinkIds: readonly string[];
29
+ readonly semanticOperationIds: readonly string[];
28
30
  readonly evidenceIds: readonly string[];
29
31
  readonly proofIds: readonly string[];
30
32
  readonly autoMergeClaim: false;
@@ -48,6 +50,7 @@ export interface UniversalConversionRouteArtifact {
48
50
  readonly reviewRequired: true;
49
51
  readonly history: SemanticHistoryRecord;
50
52
  readonly patchBundle: SemanticPatchBundleRecord;
53
+ readonly semanticOperations: SemanticOperationSet;
51
54
  readonly materialization: UniversalConversionArtifactMaterialization;
52
55
  readonly mergeScore?: UniversalConversionMergeScore;
53
56
  readonly autoMergeClaim: false;
@@ -70,6 +73,8 @@ export interface UniversalConversionArtifactIndex {
70
73
  readonly conflictKeys: readonly string[];
71
74
  readonly evidenceIds: readonly string[];
72
75
  readonly proofIds: readonly string[];
76
+ readonly semanticOperationIds: readonly string[];
77
+ readonly semanticOperationKinds: readonly string[];
73
78
  }
74
79
 
75
80
  export interface UniversalConversionArtifacts {
@@ -87,6 +92,7 @@ export interface UniversalConversionArtifacts {
87
92
  readonly routes: number;
88
93
  readonly histories: number;
89
94
  readonly patchBundles: number;
95
+ readonly semanticOperations: number;
90
96
  readonly reviewRequired: number;
91
97
  readonly blocked: number;
92
98
  readonly autoMergeClaims: 0;
@@ -136,6 +142,8 @@ export interface UniversalConversionArtifactQuery {
136
142
  readonly conflictKey?: string | readonly string[];
137
143
  readonly evidenceId?: string | readonly string[];
138
144
  readonly proofId?: string | readonly string[];
145
+ readonly semanticOperationId?: string | readonly string[];
146
+ readonly semanticOperationKind?: string | readonly string[];
139
147
  }
140
148
 
141
149
  export declare function createUniversalConversionArtifacts(
@@ -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
  }
@@ -22,7 +22,9 @@ export function artifactIndex(routeArtifacts) {
22
22
  ownershipKeys: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.index.ownershipKeys)),
23
23
  conflictKeys: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.index.conflictKeys)),
24
24
  evidenceIds: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.evidenceIds)),
25
- proofIds: uniqueStrings(routeArtifacts.flatMap((artifact) => artifact.history.proofIds))
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))
26
28
  };
27
29
  }
28
30
 
@@ -49,7 +51,9 @@ function matchesArtifact(record, query) {
49
51
  && match(query.ownershipKey, record.history.index.ownershipKeys)
50
52
  && match(query.conflictKey, record.history.index.conflictKeys)
51
53
  && match(query.evidenceId, record.history.evidenceIds)
52
- && match(query.proofId, record.history.proofIds);
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));
53
57
  }
54
58
 
55
59
  function match(filter, values) {
@@ -1,6 +1,7 @@
1
1
  import { idFragment, uniqueStrings } from './native-import-utils.js';
2
2
  import { createUniversalConversionPlan } from './universal-conversion-plan.js';
3
3
  import { artifactIndex } from './universal-conversion-artifact-query.js';
4
+ import { routeSemanticOperations } from './universal-conversion-route-operations.js';
4
5
  import { createSemanticHistoryRecord } from './internal/index-impl/semanticHistoryRecords.js';
5
6
  import { createSemanticPatchBundleRecord } from './internal/index-impl/semanticPatchBundleRecords.js';
6
7
 
@@ -37,6 +38,7 @@ export function createUniversalConversionArtifacts(input = {}, options = {}) {
37
38
  routes: routeArtifacts.length,
38
39
  histories: historyRecords.length,
39
40
  patchBundles: patchBundleRecords.length,
41
+ semanticOperations: routeArtifacts.reduce((sum, artifact) => sum + artifact.semanticOperations.operations.length, 0),
40
42
  reviewRequired: routeArtifacts.filter((artifact) => artifact.reviewRequired).length,
41
43
  blocked: routeArtifacts.filter((artifact) => artifact.admissionStatus === 'blocked').length,
42
44
  autoMergeClaims: 0,
@@ -57,6 +59,7 @@ function createRouteArtifact(route, options) {
57
59
  const sources = normalizeSources(refs.sources, route);
58
60
  const regions = routeRegions(route, refs, sources);
59
61
  const sourceMapLinks = routeSourceMapLinks(route, refs, sources, regions);
62
+ const semanticOperations = routeSemanticOperations(route, refs, sources, regions, sourceMapLinks);
60
63
  const admissionStatus = routeAdmissionStatus(route);
61
64
  const reasonCodes = routeReasonCodes(route);
62
65
  const historyId = refs.historyIds?.[0] ?? `history_${route.id}`;
@@ -88,6 +91,7 @@ function createRouteArtifact(route, options) {
88
91
  sources,
89
92
  changedRegions: regions,
90
93
  sourceMapLinks,
94
+ semanticOperationIds: semanticOperations.operations.map((operation) => operation.id),
91
95
  evidenceIds: refs.evidenceIds,
92
96
  proofIds: refs.proofIds,
93
97
  historyIds: [history.id],
@@ -110,6 +114,7 @@ function createRouteArtifact(route, options) {
110
114
  materializedHistoryIds: [history.id],
111
115
  patchBundleIds: [patchBundle.id],
112
116
  sourceMapLinkIds: patchBundle.index.sourceMapLinkIds,
117
+ semanticOperationIds: semanticOperations.operations.map((operation) => operation.id),
113
118
  evidenceIds: history.evidenceIds,
114
119
  proofIds: history.proofIds,
115
120
  autoMergeClaim: false,
@@ -132,6 +137,7 @@ function createRouteArtifact(route, options) {
132
137
  reviewRequired: true,
133
138
  history,
134
139
  patchBundle,
140
+ semanticOperations,
135
141
  materialization,
136
142
  mergeScore: route.mergeScore,
137
143
  autoMergeClaim: false,
@@ -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.50",
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.11",
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",