@shapeshift-labs/frontier-lang-compiler 0.2.8 → 0.2.10

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
@@ -50,6 +50,97 @@ console.log(summary.categories);
50
50
  console.log(readiness.readiness);
51
51
  ```
52
52
 
53
+ The loss taxonomy separates broad scanner limits from specific round-trip risks such as conditional compilation, reflection, overload/type-inference gaps, comments/trivia preservation, source-map approximation, parser diagnostics, and target projection loss. These records are evidence labels for merge admission; they are not claims that the lightweight scanner expanded macros, evaluated inactive branches, resolved overloads, or ran a type checker.
54
+
55
+ Ask the compiler what is actually covered before sending native imports into a merge queue:
56
+
57
+ ```js
58
+ import {
59
+ createNativeImportCoverageMatrix,
60
+ importNativeSource
61
+ } from '@shapeshift-labs/frontier-lang-compiler';
62
+
63
+ const imported = importNativeSource({
64
+ language: 'python',
65
+ sourcePath: 'todo.py',
66
+ sourceText: 'def add_todo(title):\n return title\n'
67
+ });
68
+
69
+ const matrix = createNativeImportCoverageMatrix({ imports: [imported] });
70
+ const python = matrix.languages.find((entry) => entry.language === 'python');
71
+
72
+ console.log(python.imports.readiness); // scanner imports are intentionally review-required
73
+ console.log(python.parserAdapters); // host-owned exact parsers such as LibCST can be injected
74
+ ```
75
+
76
+ 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:
77
+
78
+ ```js
79
+ import {
80
+ createNativeSourcePreservation,
81
+ importNativeSource
82
+ } from '@shapeshift-labs/frontier-lang-compiler';
83
+
84
+ const sourceText = '// kept\nexport function step(frame) { return frame + 1; }\n';
85
+ const preservation = createNativeSourcePreservation({
86
+ language: 'javascript',
87
+ sourcePath: 'src/runtime.js',
88
+ sourceText
89
+ });
90
+ const imported = importNativeSource({ language: 'javascript', sourcePath: 'src/runtime.js', sourceText });
91
+
92
+ console.log(preservation.summary.comments); // comments and whitespace are tracked
93
+ console.log(imported.metadata.sourcePreservation.sourceHash);
94
+ ```
95
+
96
+ When `sourceText` is present, hashes are computed from the actual text. Caller-provided hashes are recorded as declared metadata and cannot make stale text project as exact source. Use `includeTokens`, `includeTrivia`, `includeDirectives`, and `max*` options to keep preservation records compact for large files.
97
+
98
+ Create a compact semantic sidecar for swarm merge admission. This is the artifact a coordinator can index instead of reading a worker directory by hand:
99
+
100
+ ```js
101
+ import {
102
+ createSemanticImportSidecar,
103
+ importNativeSource
104
+ } from '@shapeshift-labs/frontier-lang-compiler';
105
+
106
+ const imported = importNativeSource({
107
+ language: 'typescript',
108
+ sourcePath: 'src/runtime.ts',
109
+ sourceText: `
110
+ export class Runtime {
111
+ step(frame: number) { return frame + 1; }
112
+ }
113
+ `
114
+ });
115
+
116
+ const sidecar = createSemanticImportSidecar(imported);
117
+
118
+ console.log(sidecar.summary.emptySemanticIndex); // false when symbols were found
119
+ console.log(sidecar.ownershipRegions[0].key); // source#src/runtime.ts#class#Runtime
120
+ console.log(sidecar.patchHints[0].supportedOperations); // source-region patch operations
121
+ ```
122
+
123
+ Project a native import back to source. Exact source is preserved when the import carries matching source-preservation evidence or when supplied text matches the import hash; otherwise the compiler emits declaration stubs with review-required loss evidence:
124
+
125
+ ```js
126
+ import {
127
+ importNativeSource,
128
+ projectNativeImportToSource
129
+ } from '@shapeshift-labs/frontier-lang-compiler';
130
+
131
+ const sourceText = 'export function step(frame) { return frame + 1; }\n';
132
+ const imported = importNativeSource({
133
+ language: 'javascript',
134
+ sourcePath: 'src/runtime.js',
135
+ sourceText
136
+ });
137
+
138
+ const projection = projectNativeImportToSource(imported);
139
+
140
+ console.log(projection.mode); // "preserved-source"
141
+ console.log(projection.readiness.readiness); // "ready"
142
+ ```
143
+
53
144
  Use injected parser adapters when a real language parser is available but should not become a compiler runtime dependency:
54
145
 
55
146
  ```js
@@ -79,6 +170,9 @@ const project = await importNativeProject({
79
170
 
80
171
  console.log(imported.universalAst.sourceMaps.length);
81
172
  console.log(project.semanticIndex.symbols.length);
173
+ console.log(imported.adapter.coverage.exactness);
174
+ console.log(imported.adapter.coverage.semanticCoverage.level);
175
+ console.log(project.metadata.sourcePreservationSummary.total);
82
176
  ```
83
177
 
84
178
  The built-in adapter factories are dependency-light wrappers for caller-owned parsers or ASTs:
@@ -88,6 +182,8 @@ The built-in adapter factories are dependency-light wrappers for caller-owned pa
88
182
  - `createTypeScriptCompilerNativeImporterAdapter`
89
183
  - `createTreeSitterNativeImporterAdapter`
90
184
 
185
+ Adapter summaries include a structured `coverage` record so merge queues can distinguish exact parser AST imports from declaration scans. The record declares exactness, parser token/trivia support, diagnostics support, source-range and generated-range support, and semantic coverage. Built-in wrappers normalize native AST/CST nodes and declaration-level semantic indexes; they do not claim resolved references, types, control flow, generated ranges, or token/trivia fidelity unless the host adapter supplies that evidence.
186
+
91
187
  ## Related Packages
92
188
 
93
189
  The published Frontier package family is generated from one shared package catalog so READMEs stay in sync across packages:
package/bench/smoke.mjs CHANGED
@@ -2,7 +2,11 @@ import { performance } from 'node:perf_hooks';
2
2
  import {
3
3
  compileFrontierSource,
4
4
  createEstreeNativeImporterAdapter,
5
+ createNativeImportCoverageMatrix,
6
+ createNativeSourcePreservation,
7
+ createSemanticImportSidecar,
5
8
  importNativeSource,
9
+ projectNativeImportToSource,
6
10
  runNativeImporterAdapter
7
11
  } from '../dist/index.js';
8
12
 
@@ -32,6 +36,7 @@ const compileDurationMs = performance.now() - start;
32
36
  const importStart = performance.now();
33
37
  const estreeAdapter = createEstreeNativeImporterAdapter();
34
38
  let nativeSymbols = 0;
39
+ const nativeImportResults = [];
35
40
  for (let index = 0; index < 150; index += 1) {
36
41
  const imported = index % 2 === 0
37
42
  ? importNativeSource({
@@ -55,14 +60,50 @@ for (let index = 0; index < 150; index += 1) {
55
60
  }
56
61
  });
57
62
  nativeSymbols += imported.semanticIndex?.symbols?.length ?? 0;
63
+ nativeImportResults.push(imported);
58
64
  }
59
65
  const importDurationMs = performance.now() - importStart;
60
66
 
67
+ const matrixStart = performance.now();
68
+ const coverageMatrix = createNativeImportCoverageMatrix({ imports: nativeImportResults });
69
+ const matrixDurationMs = performance.now() - matrixStart;
70
+
71
+ const preservationStart = performance.now();
72
+ const preservationRecords = nativeImportResults.map((imported) => imported.metadata.sourcePreservation ?? createNativeSourcePreservation({
73
+ language: imported.language,
74
+ sourcePath: imported.sourcePath,
75
+ sourceText: imported.metadata.sourcePreservation?.sourceText ?? ''
76
+ }));
77
+ const preservationDurationMs = performance.now() - preservationStart;
78
+ const preservationTokens = preservationRecords.reduce((sum, record) => sum + record.tokens.length + record.trivia.length, 0);
79
+
80
+ const sidecarStart = performance.now();
81
+ const semanticSidecars = nativeImportResults.map((imported) => createSemanticImportSidecar(imported));
82
+ const sidecarDurationMs = performance.now() - sidecarStart;
83
+ const sidecarOwnershipRegions = semanticSidecars.reduce((sum, sidecar) => sum + sidecar.ownershipRegions.length, 0);
84
+
85
+ const projectionStart = performance.now();
86
+ const nativeProjections = nativeImportResults.map((imported) => projectNativeImportToSource(imported));
87
+ const projectionDurationMs = performance.now() - projectionStart;
88
+ const projectionBytes = nativeProjections.reduce((sum, projection) => sum + projection.sourceText.length, 0);
89
+
61
90
  console.log(JSON.stringify({
62
91
  compiles: 250,
63
92
  bytes,
64
93
  compileDurationMs: Number(compileDurationMs.toFixed(2)),
65
94
  nativeImports: 150,
66
95
  nativeSymbols,
67
- nativeImportDurationMs: Number(importDurationMs.toFixed(2))
96
+ nativeImportDurationMs: Number(importDurationMs.toFixed(2)),
97
+ coverageMatrixLanguages: coverageMatrix.summary.languages,
98
+ coverageMatrixImports: coverageMatrix.summary.imports,
99
+ coverageMatrixDurationMs: Number(matrixDurationMs.toFixed(2)),
100
+ sourcePreservationRecords: preservationRecords.length,
101
+ sourcePreservationTokens: preservationTokens,
102
+ sourcePreservationDurationMs: Number(preservationDurationMs.toFixed(2)),
103
+ semanticSidecars: semanticSidecars.length,
104
+ sidecarOwnershipRegions,
105
+ sidecarDurationMs: Number(sidecarDurationMs.toFixed(2)),
106
+ nativeProjections: nativeProjections.length,
107
+ projectionBytes,
108
+ projectionDurationMs: Number(projectionDurationMs.toFixed(2))
68
109
  }));
package/dist/index.d.ts CHANGED
@@ -79,27 +79,42 @@ export type NativeImportTaxonomyKind =
79
79
  | 'opaqueBodies'
80
80
  | 'macroExpansion'
81
81
  | 'preprocessor'
82
+ | 'conditionalCompilation'
82
83
  | 'metaprogramming'
84
+ | 'reflection'
83
85
  | 'generatedCode'
86
+ | 'overloadTypeInference'
84
87
  | 'sourcePreservation'
88
+ | 'commentsTrivia'
85
89
  | 'parserDiagnostics'
86
90
  | 'unsupportedSyntax'
87
91
  | 'partialSemanticIndex'
88
92
  | 'sourceMapApproximation'
93
+ | 'targetProjectionLoss'
89
94
  | string;
90
95
 
91
96
  export type NativeImportKnownLossKind =
92
97
  | 'declarationOnlyCoverage'
93
98
  | 'opaqueNative'
94
99
  | 'macroExpansion'
100
+ | 'macroHygiene'
95
101
  | 'preprocessor'
102
+ | 'conditionalCompilation'
96
103
  | 'metaprogramming'
104
+ | 'reflection'
105
+ | 'dynamicRuntime'
106
+ | 'dynamicDispatch'
97
107
  | 'generatedCode'
108
+ | 'overloadResolution'
109
+ | 'typeInference'
98
110
  | 'sourcePreservation'
111
+ | 'commentsTrivia'
99
112
  | 'parserDiagnostic'
100
113
  | 'unsupportedSyntax'
114
+ | 'unsupportedSemantic'
101
115
  | 'partialSemanticIndex'
102
116
  | 'sourceMapApproximation'
117
+ | 'targetProjectionLoss'
103
118
  | string;
104
119
 
105
120
  export interface NativeImportLossSummaryOptions {
@@ -135,6 +150,315 @@ export interface NativeImportReadinessClassification {
135
150
  readonly summary: NativeImportLossSummary;
136
151
  }
137
152
 
153
+ export interface NativeImportLanguageProfile {
154
+ readonly language: FrontierSourceLanguage;
155
+ readonly aliases: readonly string[];
156
+ readonly extensions: readonly string[];
157
+ readonly supportsLightweightScan: boolean;
158
+ readonly parserAdapters: readonly string[];
159
+ readonly projectionTargets: readonly FrontierCompileTarget[];
160
+ readonly knownLossKinds: readonly NativeImportKnownLossKind[];
161
+ readonly defaultReadiness: SemanticMergeReadiness;
162
+ readonly notes: readonly string[];
163
+ }
164
+
165
+ export interface NativeImportCoverageLanguage {
166
+ readonly language: FrontierSourceLanguage;
167
+ readonly aliases: readonly string[];
168
+ readonly extensions: readonly string[];
169
+ readonly supportsLightweightScan: boolean;
170
+ readonly parserAdapters: readonly string[];
171
+ readonly projectionTargets: readonly FrontierCompileTarget[];
172
+ readonly knownLossKinds: readonly NativeImportKnownLossKind[];
173
+ readonly defaultReadiness: SemanticMergeReadiness;
174
+ readonly notes: readonly string[];
175
+ readonly imports: {
176
+ readonly total: number;
177
+ readonly parsers: readonly string[];
178
+ readonly readiness: SemanticMergeReadiness;
179
+ readonly readinessReasons: readonly string[];
180
+ readonly symbols: number;
181
+ readonly sourceMaps: number;
182
+ readonly sourceMapMappings: number;
183
+ readonly losses: number;
184
+ readonly lossKinds: Readonly<Record<string, number>>;
185
+ readonly lossCategories: readonly NativeImportTaxonomyKind[];
186
+ };
187
+ }
188
+
189
+ export interface NativeImportCoverageMatrix {
190
+ readonly kind: 'frontier.lang.nativeImportCoverageMatrix';
191
+ readonly version: 1;
192
+ readonly generatedAt: number;
193
+ readonly languages: readonly NativeImportCoverageLanguage[];
194
+ readonly summary: {
195
+ readonly languages: number;
196
+ readonly lightweightScanners: number;
197
+ readonly parserAdapterSlots: number;
198
+ readonly imports: number;
199
+ readonly symbols: number;
200
+ readonly sourceMaps: number;
201
+ readonly sourceMapMappings: number;
202
+ readonly losses: number;
203
+ readonly byReadiness: Readonly<Record<string, number>>;
204
+ readonly lossKinds: Readonly<Record<string, number>>;
205
+ };
206
+ readonly metadata: {
207
+ readonly compileTargets: readonly FrontierCompileTarget[];
208
+ readonly note: string;
209
+ };
210
+ }
211
+
212
+ export interface NativeImportCoverageMatrixOptions {
213
+ readonly languages?: readonly NativeImportLanguageProfile[];
214
+ readonly imports?: readonly NativeSourceImportResult[];
215
+ readonly adapters?: readonly NativeImporterAdapter[];
216
+ readonly generatedAt?: number;
217
+ }
218
+
219
+ export type NativeSourceTokenKind =
220
+ | 'identifier'
221
+ | 'keyword'
222
+ | 'number'
223
+ | 'string'
224
+ | 'operator'
225
+ | 'punctuation'
226
+ | 'comment'
227
+ | 'whitespace'
228
+ | 'newline'
229
+ | 'directive'
230
+ | 'unknown'
231
+ | string;
232
+
233
+ export interface NativeSourcePreservedToken {
234
+ readonly id: string;
235
+ readonly kind: NativeSourceTokenKind;
236
+ readonly text?: string;
237
+ readonly textHash: string;
238
+ readonly span: SourceSpan;
239
+ readonly metadata?: Record<string, unknown>;
240
+ }
241
+
242
+ export interface NativeSourcePreservedDirective {
243
+ readonly id: string;
244
+ readonly kind: string;
245
+ readonly text?: string;
246
+ readonly textHash: string;
247
+ readonly span: SourceSpan;
248
+ readonly metadata?: Record<string, unknown>;
249
+ }
250
+
251
+ export interface NativeSourcePreservation {
252
+ readonly kind: 'frontier.lang.nativeSourcePreservation';
253
+ readonly version: 1;
254
+ readonly id: string;
255
+ readonly language: FrontierSourceLanguage | string;
256
+ readonly sourcePath?: string;
257
+ readonly sourceHash: string;
258
+ readonly sourceBytes: number;
259
+ readonly lineCount: number;
260
+ readonly newline: 'lf' | 'crlf' | 'mixed' | 'none';
261
+ readonly encoding: string;
262
+ readonly sourceText?: string;
263
+ readonly tokens: readonly NativeSourcePreservedToken[];
264
+ readonly trivia: readonly NativeSourcePreservedToken[];
265
+ readonly directives: readonly NativeSourcePreservedDirective[];
266
+ readonly summary: {
267
+ readonly tokens: number;
268
+ readonly trivia: number;
269
+ readonly directives: number;
270
+ readonly comments: number;
271
+ readonly whitespace: number;
272
+ readonly exactSourceAvailable: boolean;
273
+ readonly truncated: boolean;
274
+ };
275
+ readonly metadata?: Record<string, unknown>;
276
+ }
277
+
278
+ export interface CreateNativeSourcePreservationOptions {
279
+ readonly id?: string;
280
+ readonly language?: FrontierSourceLanguage | string;
281
+ readonly sourcePath?: string;
282
+ readonly sourceHash?: string;
283
+ readonly sourceText: string;
284
+ readonly encoding?: string;
285
+ readonly includeSourceText?: boolean;
286
+ readonly includeTokens?: boolean;
287
+ readonly includeTrivia?: boolean;
288
+ readonly includeDirectives?: boolean;
289
+ readonly maxTokens?: number;
290
+ readonly maxTrivia?: number;
291
+ readonly maxDirectives?: number;
292
+ readonly metadata?: Record<string, unknown>;
293
+ }
294
+
295
+ export interface SemanticImportOwnershipRegion {
296
+ readonly id: string;
297
+ readonly key: string;
298
+ readonly granularity: 'symbol' | string;
299
+ readonly language?: FrontierSourceLanguage | string;
300
+ readonly sourcePath?: string;
301
+ readonly sourceHash?: string;
302
+ readonly symbolId?: string;
303
+ readonly symbolName?: string;
304
+ readonly symbolKind?: string;
305
+ readonly nativeAstNodeId?: string;
306
+ readonly sourceSpan?: SourceSpan;
307
+ readonly precision?: 'exact' | 'declaration' | 'line' | 'estimated' | 'unknown' | string;
308
+ readonly mergePolicy?: string;
309
+ }
310
+
311
+ export interface SemanticImportSidecarSymbol {
312
+ readonly id: string;
313
+ readonly name?: string;
314
+ readonly kind?: string;
315
+ readonly language?: FrontierSourceLanguage | string;
316
+ readonly nativeAstNodeId?: string;
317
+ readonly semanticOccurrenceId?: string;
318
+ readonly sourceMapMappingId?: string;
319
+ readonly sourceSpan?: SourceSpan;
320
+ readonly signatureHash?: string;
321
+ readonly ownershipRegionId: string;
322
+ readonly ownershipKey: string;
323
+ readonly readiness: SemanticMergeReadiness;
324
+ }
325
+
326
+ export interface SemanticImportPatchHint {
327
+ readonly id: string;
328
+ readonly kind: 'source-region-patch' | string;
329
+ readonly ownershipRegionId: string;
330
+ readonly ownershipKey: string;
331
+ readonly sourcePath?: string;
332
+ readonly sourceHash?: string;
333
+ readonly sourceSpan?: SourceSpan;
334
+ readonly readiness: SemanticMergeReadiness;
335
+ readonly precision?: string;
336
+ readonly supportedOperations: readonly string[];
337
+ readonly projection: {
338
+ readonly sourceLanguage?: FrontierSourceLanguage | string;
339
+ readonly targetPath?: string;
340
+ readonly requiresSourceMap: boolean;
341
+ };
342
+ }
343
+
344
+ export interface SemanticImportSidecarImportEntry {
345
+ readonly id: string;
346
+ readonly language?: FrontierSourceLanguage | string;
347
+ readonly sourcePath?: string;
348
+ readonly sourceHash?: string;
349
+ readonly parser?: string;
350
+ readonly nativeSourceId?: string;
351
+ readonly nativeAstId?: string;
352
+ readonly semanticIndexId?: string;
353
+ readonly universalAstId?: string;
354
+ readonly symbolCount: number;
355
+ readonly sourceMapCount: number;
356
+ readonly sourceMapMappingCount: number;
357
+ readonly readiness: SemanticMergeReadiness;
358
+ readonly emptySemanticIndex: boolean;
359
+ }
360
+
361
+ export interface SemanticImportSidecar {
362
+ readonly kind: 'frontier.lang.semanticImportSidecar';
363
+ readonly version: 1;
364
+ readonly id: string;
365
+ readonly generatedAt: number;
366
+ readonly language?: FrontierSourceLanguage | 'mixed' | string;
367
+ readonly projectRoot?: string;
368
+ readonly imports: readonly SemanticImportSidecarImportEntry[];
369
+ readonly symbols: readonly SemanticImportSidecarSymbol[];
370
+ readonly ownershipRegions: readonly SemanticImportOwnershipRegion[];
371
+ readonly sourceMaps: {
372
+ readonly total: number;
373
+ readonly mappings: number;
374
+ readonly ids: readonly string[];
375
+ };
376
+ readonly patchHints: readonly SemanticImportPatchHint[];
377
+ readonly mergeCandidates: readonly {
378
+ readonly id?: string;
379
+ readonly readiness?: SemanticMergeReadiness;
380
+ readonly reasons: readonly string[];
381
+ readonly risk?: string;
382
+ readonly operationCount: number;
383
+ }[];
384
+ readonly losses: {
385
+ readonly total: number;
386
+ readonly byKind: Readonly<Record<string, number>>;
387
+ readonly bySeverity: Readonly<Record<string, number>>;
388
+ readonly categories: readonly NativeImportTaxonomyKind[];
389
+ readonly blockingLossIds: readonly string[];
390
+ readonly reviewLossIds: readonly string[];
391
+ };
392
+ readonly evidence: {
393
+ readonly total: number;
394
+ readonly failed: readonly string[];
395
+ readonly ids: readonly string[];
396
+ };
397
+ readonly summary: {
398
+ readonly imports: number;
399
+ readonly symbols: number;
400
+ readonly ownershipRegions: number;
401
+ readonly sourceMapMappings: number;
402
+ readonly readiness: SemanticMergeReadiness;
403
+ readonly emptySemanticIndex: boolean;
404
+ };
405
+ readonly metadata?: Record<string, unknown>;
406
+ }
407
+
408
+ export interface SemanticImportSidecarOptions {
409
+ readonly id?: string;
410
+ readonly generatedAt?: number;
411
+ readonly regionPrefix?: string;
412
+ readonly targetPath?: string;
413
+ readonly metadata?: Record<string, unknown>;
414
+ }
415
+
416
+ export type NativeImporterAdapterExactness =
417
+ | 'exact-parser-ast'
418
+ | 'parser-tree'
419
+ | 'adapter-reported-native-ast'
420
+ | 'loss-aware-native-ast'
421
+ | 'unknown'
422
+ | string;
423
+
424
+ export interface NativeImporterAdapterSemanticCoverage {
425
+ readonly level: 'native-ast' | 'declaration-index' | 'semantic-index' | string;
426
+ readonly declarations: boolean;
427
+ readonly symbols: boolean;
428
+ readonly references: boolean;
429
+ readonly types: boolean;
430
+ readonly controlFlow: boolean;
431
+ }
432
+
433
+ export interface NativeImporterAdapterCoverageObserved {
434
+ readonly diagnostics: number;
435
+ readonly losses: number;
436
+ readonly nativeAstNodes: number;
437
+ readonly semanticSymbols: number;
438
+ readonly sourceMapMappings: number;
439
+ readonly sourceRanges: boolean;
440
+ readonly generatedRanges: boolean;
441
+ }
442
+
443
+ export interface NativeImporterAdapterCoverageSummary {
444
+ readonly exactness: NativeImporterAdapterExactness;
445
+ readonly exactAst: boolean;
446
+ readonly tokens: boolean;
447
+ readonly trivia: boolean;
448
+ readonly diagnostics: boolean;
449
+ readonly sourceRanges: boolean;
450
+ readonly generatedRanges: boolean;
451
+ readonly semanticCoverage: NativeImporterAdapterSemanticCoverage;
452
+ readonly notes: readonly string[];
453
+ readonly observed?: NativeImporterAdapterCoverageObserved;
454
+ }
455
+
456
+ export type NativeImporterAdapterCoverageInput =
457
+ Omit<Partial<NativeImporterAdapterCoverageSummary>, 'semanticCoverage' | 'observed'> & {
458
+ readonly semanticCoverage?: Partial<NativeImporterAdapterSemanticCoverage>;
459
+ readonly observed?: Partial<NativeImporterAdapterCoverageObserved>;
460
+ };
461
+
138
462
  export interface NativeImporterAdapterDiagnostic {
139
463
  readonly id?: string;
140
464
  readonly severity?: 'info' | 'warning' | 'error';
@@ -175,6 +499,7 @@ export interface ImportNativeSourceOptions {
175
499
  readonly losses?: readonly NativeAstLossRecord[];
176
500
  readonly evidence?: readonly EvidenceRecord[];
177
501
  readonly evidenceId?: string;
502
+ readonly sourcePreservation?: NativeSourcePreservation;
178
503
  readonly patch?: SemanticPatchBundle;
179
504
  readonly patchId?: string;
180
505
  readonly author?: string;
@@ -218,6 +543,7 @@ export interface NativeImporterAdapter {
218
543
  readonly parser: string;
219
544
  readonly version?: string;
220
545
  readonly capabilities?: readonly string[];
546
+ readonly coverage?: NativeImporterAdapterCoverageInput;
221
547
  readonly supportedExtensions?: readonly string[];
222
548
  readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
223
549
  readonly parse: (input: NativeImporterAdapterParseInput) => NativeImporterAdapterParseResult | Promise<NativeImporterAdapterParseResult>;
@@ -229,6 +555,7 @@ export interface JavaScriptNativeImporterAdapterOptions {
229
555
  readonly parser?: string;
230
556
  readonly version?: string;
231
557
  readonly capabilities?: readonly string[];
558
+ readonly coverage?: NativeImporterAdapterCoverageInput;
232
559
  readonly supportedExtensions?: readonly string[];
233
560
  readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
234
561
  readonly ast?: unknown;
@@ -245,6 +572,7 @@ export interface TypeScriptCompilerNativeImporterAdapterOptions {
245
572
  readonly parser?: string;
246
573
  readonly version?: string;
247
574
  readonly capabilities?: readonly string[];
575
+ readonly coverage?: NativeImporterAdapterCoverageInput;
248
576
  readonly supportedExtensions?: readonly string[];
249
577
  readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
250
578
  readonly typescript?: unknown;
@@ -264,6 +592,7 @@ export interface TreeSitterNativeImporterAdapterOptions {
264
592
  readonly parserName?: string;
265
593
  readonly version?: string;
266
594
  readonly capabilities?: readonly string[];
595
+ readonly coverage?: NativeImporterAdapterCoverageInput;
267
596
  readonly supportedExtensions?: readonly string[];
268
597
  readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
269
598
  readonly parserInstance?: { readonly parse: (sourceText: string) => unknown };
@@ -279,6 +608,7 @@ export interface NativeImporterAdapterSummary {
279
608
  readonly parser: string;
280
609
  readonly version?: string;
281
610
  readonly capabilities: readonly string[];
611
+ readonly coverage: NativeImporterAdapterCoverageSummary;
282
612
  readonly supportedExtensions: readonly string[];
283
613
  readonly diagnostics: readonly NativeImporterAdapterDiagnostic[];
284
614
  }
@@ -343,10 +673,62 @@ export interface NativeProjectImportResult {
343
673
  readonly metadata?: Record<string, unknown>;
344
674
  }
345
675
 
676
+ export type NativeSourceProjectionMode = 'preserved-source' | 'native-source-stubs';
677
+
678
+ export interface ProjectNativeImportToSourceOptions {
679
+ readonly id?: string;
680
+ readonly language?: FrontierSourceLanguage | string;
681
+ readonly sourcePath?: string;
682
+ readonly expectedSourceHash?: string;
683
+ readonly sourceText?: string;
684
+ readonly preservedSourceText?: string;
685
+ readonly exactSourceText?: string;
686
+ readonly sourceHash?: string;
687
+ readonly verifySourceHash?: boolean;
688
+ readonly preferPreservedSource?: boolean;
689
+ readonly stubBanner?: string | false;
690
+ readonly evidenceId?: string;
691
+ readonly parser?: string;
692
+ readonly semanticStatus?: string;
693
+ readonly nativeSource?: NativeSourceNode;
694
+ readonly nativeAst?: NativeAstRecord;
695
+ readonly semanticIndex?: SemanticIndexRecord;
696
+ readonly metadata?: Record<string, unknown>;
697
+ }
698
+
699
+ export interface NativeSourceProjectionDeclaration {
700
+ readonly name: string;
701
+ readonly kind: string;
702
+ readonly symbolId?: string;
703
+ readonly nativeAstNodeId?: string;
704
+ readonly sourceSpan?: SourceSpan;
705
+ readonly ownershipRegionId?: string;
706
+ readonly metadata?: Record<string, unknown>;
707
+ }
708
+
709
+ export interface NativeSourceProjectionResult {
710
+ readonly kind: 'frontier.lang.nativeSourceProjection';
711
+ readonly version: 1;
712
+ readonly id: string;
713
+ readonly language: FrontierSourceLanguage | string;
714
+ readonly sourcePath?: string;
715
+ readonly sourceHash?: string;
716
+ readonly mode: NativeSourceProjectionMode;
717
+ readonly sourceText: string;
718
+ readonly outputHash: string;
719
+ readonly declarations: readonly NativeSourceProjectionDeclaration[];
720
+ readonly losses: readonly NativeAstLossRecord[];
721
+ readonly lossSummary: NativeImportLossSummary;
722
+ readonly readiness: NativeImportReadinessClassification;
723
+ readonly evidence: readonly EvidenceRecord[];
724
+ readonly metadata: Record<string, unknown>;
725
+ }
726
+
346
727
  export declare const FrontierCompileTargets: readonly FrontierCompileTarget[];
347
728
  export declare const NativeImportTaxonomyKinds: readonly NativeImportTaxonomyKind[];
348
729
  export declare const NativeImportLossKinds: readonly NativeImportKnownLossKind[];
349
730
  export declare const NativeImportReadinessBySeverity: Readonly<Record<NativeImportLossSummary['highestSeverity'], SemanticMergeReadiness>>;
731
+ export declare const NativeImportLanguageProfiles: readonly NativeImportLanguageProfile[];
350
732
  export declare function normalizeCompileTarget(target?: string): FrontierCompileTarget;
351
733
  export declare function compileFrontierSource(source: string, options?: FrontierCompileOptions): FrontierCompileResult;
352
734
  export declare function compileFrontierDocument(document: FrontierLangDocument, options?: FrontierCompileOptions): FrontierCompileResult;
@@ -355,11 +737,15 @@ export declare function renderTargetAst(ast: FrontierTargetAst, target?: Frontie
355
737
  export declare function resolveCapabilityAdapters(document: FrontierLangDocument, target?: FrontierCompileOptions['target'], options?: { readonly platform?: string }): readonly CapabilityResolution[];
356
738
  export declare function summarizeNativeImportLosses(losses?: readonly NativeAstLossRecord[], options?: NativeImportLossSummaryOptions): NativeImportLossSummary;
357
739
  export declare function classifyNativeImportReadiness(losses?: readonly NativeAstLossRecord[], options?: NativeImportLossSummaryOptions): NativeImportReadinessClassification;
740
+ export declare function createNativeImportCoverageMatrix(options?: NativeImportCoverageMatrixOptions): NativeImportCoverageMatrix;
741
+ export declare function createNativeSourcePreservation(options: CreateNativeSourcePreservationOptions): NativeSourcePreservation;
742
+ export declare function createSemanticImportSidecar(importResult: NativeSourceImportResult | NativeProjectImportResult, options?: SemanticImportSidecarOptions): SemanticImportSidecar;
358
743
  export declare function createEstreeNativeImporterAdapter(options?: JavaScriptNativeImporterAdapterOptions): NativeImporterAdapter;
359
744
  export declare function createBabelNativeImporterAdapter(options?: JavaScriptNativeImporterAdapterOptions): NativeImporterAdapter;
360
745
  export declare function createTypeScriptCompilerNativeImporterAdapter(options?: TypeScriptCompilerNativeImporterAdapterOptions): NativeImporterAdapter;
361
746
  export declare function createTreeSitterNativeImporterAdapter(options?: TreeSitterNativeImporterAdapterOptions): NativeImporterAdapter;
362
747
  export declare function runNativeImporterAdapter(adapter: NativeImporterAdapter, input: RunNativeImporterAdapterOptions): Promise<NativeImporterAdapterImportResult>;
748
+ export declare function projectNativeImportToSource(importResult: NativeSourceImportResult | NativeProjectImportResult, options?: ProjectNativeImportToSourceOptions): NativeSourceProjectionResult;
363
749
  export declare function importNativeSource(input: ImportNativeSourceOptions): NativeSourceImportResult;
364
750
  export declare function importNativeProject(input: ImportNativeProjectOptions): Promise<NativeProjectImportResult>;
365
751
  export declare function createUniversalAstFromDocument(document: FrontierLangDocument, input?: {