@shapeshift-labs/frontier-lang-compiler 0.2.34 → 0.2.35

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/dist/index.d.ts CHANGED
@@ -18,6 +18,8 @@ import type {
18
18
  SemanticPatchBundle,
19
19
  SourceMapMappingRecord,
20
20
  SourceMapRecord,
21
+ SourcePreservationLevel,
22
+ SourcePreservationRecord,
21
23
  SourceSpan
22
24
  } from '@shapeshift-labs/frontier-lang-kernel';
23
25
  import type { Diagnostic } from '@shapeshift-labs/frontier-lang-checker';
@@ -959,11 +961,31 @@ export interface SemanticImportSidecarImportEntry {
959
961
  readonly symbolCount: number;
960
962
  readonly sourceMapCount: number;
961
963
  readonly sourceMapMappingCount: number;
964
+ readonly sourcePreservationRecordCount: number;
965
+ readonly sourcePreservationLevels: readonly SourcePreservationLevel[];
962
966
  readonly readiness: SemanticMergeReadiness;
963
967
  readonly emptySemanticIndex: boolean;
964
968
  readonly regionTaxonomy?: SemanticImportRegionTaxonomySummary;
965
969
  }
966
970
 
971
+ export interface SemanticImportSidecarSourcePreservationRecord {
972
+ readonly id: string;
973
+ readonly level: SourcePreservationLevel;
974
+ readonly precision?: string;
975
+ readonly sourceMapId?: string;
976
+ readonly sourceMapMappingId?: string;
977
+ readonly semanticNodeId?: string;
978
+ readonly nativeSourceId?: string;
979
+ readonly nativeAstNodeId?: string;
980
+ readonly semanticSymbolId?: string;
981
+ readonly semanticOccurrenceId?: string;
982
+ readonly sourcePath?: string;
983
+ readonly generatedPath?: string;
984
+ readonly lossIds: readonly string[];
985
+ readonly evidenceIds: readonly string[];
986
+ readonly reasons: readonly string[];
987
+ }
988
+
967
989
  export interface SemanticImportSidecar {
968
990
  readonly kind: 'frontier.lang.semanticImportSidecar';
969
991
  readonly version: 1;
@@ -979,6 +1001,19 @@ export interface SemanticImportSidecar {
979
1001
  readonly mappings: number;
980
1002
  readonly ids: readonly string[];
981
1003
  };
1004
+ readonly sourcePreservation: {
1005
+ readonly total: number;
1006
+ readonly ids: readonly string[];
1007
+ readonly byLevel: Readonly<Record<string, number>>;
1008
+ readonly exact: number;
1009
+ readonly declaration: number;
1010
+ readonly estimated: number;
1011
+ readonly blocked: number;
1012
+ readonly sourcePaths: readonly string[];
1013
+ readonly sourceMapIds: readonly string[];
1014
+ readonly sourceMapMappingIds: readonly string[];
1015
+ readonly records: readonly SemanticImportSidecarSourcePreservationRecord[];
1016
+ };
982
1017
  readonly patchHints: readonly SemanticImportPatchHint[];
983
1018
  readonly mergeCandidates: readonly {
984
1019
  readonly id?: string;
@@ -1007,6 +1042,7 @@ export interface SemanticImportSidecar {
1007
1042
  readonly ownershipRegions: number;
1008
1043
  readonly regionKinds: number;
1009
1044
  readonly sourceMapMappings: number;
1045
+ readonly sourcePreservationRecords: number;
1010
1046
  readonly readiness: SemanticMergeReadiness;
1011
1047
  readonly emptySemanticIndex: boolean;
1012
1048
  };
@@ -1392,10 +1428,14 @@ export interface ImportNativeSourceOptions {
1392
1428
  readonly metadata?: Record<string, unknown>;
1393
1429
  }
1394
1430
 
1395
- export type NativeSourceImportResult = LanguageImportResult & {
1431
+ export type NativeSourceImportResult = Omit<LanguageImportResult, 'metadata'> & {
1396
1432
  readonly nativeSource: NativeSourceNode;
1397
1433
  readonly semanticIndex?: SemanticIndexRecord;
1398
1434
  readonly universalAst: FrontierUniversalAstEnvelope;
1435
+ readonly metadata?: Record<string, unknown> & {
1436
+ readonly sourcePreservationRecords?: readonly SourcePreservationRecord[];
1437
+ readonly kernelSourcePreservationRecords?: readonly SourcePreservationRecord[];
1438
+ };
1399
1439
  };
1400
1440
 
1401
1441
  export type ExternalSemanticIndexFormat =
package/dist/index.js CHANGED
@@ -6,7 +6,9 @@ import {
6
6
  createSemanticIndexRecord,
7
7
  createSemanticMergeCandidateRecord,
8
8
  createSourceMapRecord,
9
+ createSourcePreservationRecord,
9
10
  createUniversalAstEnvelope,
11
+ explainSourcePreservation,
10
12
  hashDocumentBase,
11
13
  hashSemanticValue,
12
14
  nativeSourceNode,
@@ -2562,6 +2564,7 @@ export function createSemanticImportSidecar(importResult, options = {}) {
2562
2564
  const mergeCandidates = imports.flatMap((imported) => imported?.mergeCandidates ?? []);
2563
2565
  const lossSummary = summarizeNativeImportLosses(losses, { evidence });
2564
2566
  const regionTaxonomy = summarizeSemanticImportRegionTaxonomy(ownershipRegions);
2567
+ const sourcePreservation = summarizeKernelSourcePreservation(importResult, imports);
2565
2568
  const readiness = mergeCandidates.reduce(
2566
2569
  (current, candidate) => maxSemanticMergeReadiness(current, candidate.readiness),
2567
2570
  lossSummary.semanticMergeReadiness
@@ -2582,6 +2585,7 @@ export function createSemanticImportSidecar(importResult, options = {}) {
2582
2585
  mappings: sourceMapMappings.length,
2583
2586
  ids: sourceMaps.map((sourceMap) => sourceMap.id).filter(Boolean)
2584
2587
  },
2588
+ sourcePreservation,
2585
2589
  patchHints,
2586
2590
  mergeCandidates: mergeCandidates.map((candidate) => ({
2587
2591
  id: candidate.id,
@@ -2610,6 +2614,7 @@ export function createSemanticImportSidecar(importResult, options = {}) {
2610
2614
  ownershipRegions: ownershipRegions.length,
2611
2615
  regionKinds: regionTaxonomy.presentKinds.length,
2612
2616
  sourceMapMappings: sourceMapMappings.length,
2617
+ sourcePreservationRecords: sourcePreservation.total,
2613
2618
  readiness,
2614
2619
  emptySemanticIndex: symbols.length === 0
2615
2620
  },
@@ -3809,6 +3814,7 @@ export function importNativeSource(input) {
3809
3814
  nativeSource,
3810
3815
  evidence,
3811
3816
  losses,
3817
+ sourcePreservation,
3812
3818
  target: input.target,
3813
3819
  targetPath,
3814
3820
  targetHash
@@ -3843,6 +3849,7 @@ export function importNativeSource(input) {
3843
3849
  semanticIndex,
3844
3850
  evidence,
3845
3851
  losses,
3852
+ sourcePreservation,
3846
3853
  target: input.target,
3847
3854
  targetPath: inferredTargetPath,
3848
3855
  targetHash,
@@ -3850,6 +3857,20 @@ export function importNativeSource(input) {
3850
3857
  sourceHash,
3851
3858
  defaultSourceMapId: `source_map_${importIdPart}`
3852
3859
  });
3860
+ const sourcePreservationRecords = createKernelSourcePreservationRecords({
3861
+ idPart: importIdPart,
3862
+ language,
3863
+ sourcePath,
3864
+ sourceHash,
3865
+ sourcePreservation,
3866
+ sourceMaps,
3867
+ losses,
3868
+ evidence,
3869
+ nativeSource,
3870
+ nativeAst,
3871
+ semanticIndex
3872
+ });
3873
+ const kernelSourcePreservationSummary = summarizeKernelSourcePreservationRecords(sourcePreservationRecords);
3853
3874
  const resultSourceMapMappings = sourceMaps.flatMap((sourceMap) => sourceMap.mappings ?? []);
3854
3875
  const universalAst = createUniversalAstEnvelope({
3855
3876
  id: input.universalAstId ?? `universal_ast_${importIdPart}`,
@@ -3868,6 +3889,11 @@ export function importNativeSource(input) {
3868
3889
  sourcePreservationId: sourcePreservation.id,
3869
3890
  sourcePreservation
3870
3891
  } : {}),
3892
+ ...(sourcePreservationRecords.length ? {
3893
+ sourcePreservationRecords,
3894
+ kernelSourcePreservationRecords: sourcePreservationRecords,
3895
+ kernelSourcePreservationSummary
3896
+ } : {}),
3871
3897
  ...(declaredSourceHash && declaredSourceHash !== sourceHash ? {
3872
3898
  declaredSourceHash,
3873
3899
  sourceHashVerified: false
@@ -3895,6 +3921,10 @@ export function importNativeSource(input) {
3895
3921
  sourcePreservationId: sourcePreservation.id,
3896
3922
  sourcePreservationSummary: sourcePreservation.summary
3897
3923
  } : {}),
3924
+ ...(sourcePreservationRecords.length ? {
3925
+ kernelSourcePreservationRecordIds: sourcePreservationRecords.map((record) => record.id),
3926
+ kernelSourcePreservationSummary
3927
+ } : {}),
3898
3928
  ...(declaredSourceHash && declaredSourceHash !== sourceHash ? {
3899
3929
  declaredSourceHash,
3900
3930
  sourceHashVerified: false
@@ -3925,6 +3955,11 @@ export function importNativeSource(input) {
3925
3955
  sourcePreservationId: sourcePreservation.id,
3926
3956
  sourcePreservation
3927
3957
  } : {}),
3958
+ ...(sourcePreservationRecords.length ? {
3959
+ sourcePreservationRecords,
3960
+ kernelSourcePreservationRecords: sourcePreservationRecords,
3961
+ kernelSourcePreservationSummary
3962
+ } : {}),
3928
3963
  ...(declaredSourceHash && declaredSourceHash !== sourceHash ? {
3929
3964
  declaredSourceHash,
3930
3965
  sourceHashVerified: false
@@ -6571,6 +6606,8 @@ function normalizeSourceMapMappings(mappings, context) {
6571
6606
  const sourceSpan = mapping.sourceSpan ?? occurrence?.span ?? nativeNode?.span;
6572
6607
  const target = mapping.target ?? mapping.generatedSpan?.target ?? context.target;
6573
6608
  const generatedSpan = normalizeGeneratedSpan(mapping.generatedSpan, target, context.targetPath, context.targetHash);
6609
+ const mappingLossIds = normalizeReferenceIds(mapping.lossIds, lossIdsForNativeNode(context.losses ?? nativeAst?.losses ?? [], nativeAstNodeId));
6610
+ const precision = normalizeSourceMapPrecision(mapping.precision, sourceSpan, generatedSpan);
6574
6611
  if (
6575
6612
  !nativeAstNodeId &&
6576
6613
  !mapping.semanticNodeId &&
@@ -6593,11 +6630,17 @@ function normalizeSourceMapMappings(mappings, context) {
6593
6630
  generatedSpan,
6594
6631
  target,
6595
6632
  evidenceIds: normalizeReferenceIds(mapping.evidenceIds, evidenceIds),
6596
- lossIds: normalizeReferenceIds(mapping.lossIds, lossIdsForNativeNode(context.losses ?? nativeAst?.losses ?? [], nativeAstNodeId)),
6633
+ lossIds: mappingLossIds,
6597
6634
  ownershipRegionId: mapping.ownershipRegionId ?? symbol?.metadata?.ownershipRegionId,
6598
6635
  ownershipRegionKey: mapping.ownershipRegionKey ?? symbol?.metadata?.ownershipRegionKey,
6599
6636
  ownershipRegionKind: mapping.ownershipRegionKind ?? symbol?.metadata?.ownershipRegionKind,
6600
- precision: normalizeSourceMapPrecision(mapping.precision, sourceSpan, generatedSpan)
6637
+ precision,
6638
+ preservation: normalizeSourcePreservationLevel(mapping.preservation, {
6639
+ precision,
6640
+ lossIds: mappingLossIds,
6641
+ losses: context.losses ?? nativeAst?.losses ?? [],
6642
+ sourcePreservation: context.sourcePreservation
6643
+ })
6601
6644
  };
6602
6645
  return {
6603
6646
  ...normalizedMapping,
@@ -6678,10 +6721,19 @@ function normalizeSourceMapPrecision(value, sourceSpan, generatedSpan) {
6678
6721
  const explicit = value === undefined || value === null ? '' : String(value).trim();
6679
6722
  if (explicit) {
6680
6723
  const normalized = explicit.toLowerCase();
6681
- if (normalized === 'exact' || normalized === 'declaration' || normalized === 'line' || normalized === 'estimated' || normalized === 'unknown') return normalized;
6724
+ if (normalized === 'exact') {
6725
+ return hasExactSpan(sourceSpan) && hasExactSpan(generatedSpan)
6726
+ ? 'exact'
6727
+ : inferSourceMapPrecisionFromSpans(sourceSpan, generatedSpan);
6728
+ }
6729
+ if (normalized === 'declaration' || normalized === 'line' || normalized === 'estimated' || normalized === 'unknown') return normalized;
6682
6730
  if (normalized === 'estimate' || normalized === 'approx' || normalized === 'approximate' || normalized === 'approximated') return 'estimated';
6683
6731
  return explicit;
6684
6732
  }
6733
+ return inferSourceMapPrecisionFromSpans(sourceSpan, generatedSpan);
6734
+ }
6735
+
6736
+ function inferSourceMapPrecisionFromSpans(sourceSpan, generatedSpan) {
6685
6737
  if (hasExactSpan(sourceSpan) && hasExactSpan(generatedSpan)) return 'exact';
6686
6738
  if (sourceSpan?.startLine && generatedSpan?.startLine) return 'line';
6687
6739
  if (sourceSpan?.startLine) return 'declaration';
@@ -6689,6 +6741,25 @@ function normalizeSourceMapPrecision(value, sourceSpan, generatedSpan) {
6689
6741
  return 'unknown';
6690
6742
  }
6691
6743
 
6744
+ function normalizeSourcePreservationLevel(value, context = {}) {
6745
+ const explicit = value === undefined || value === null ? '' : String(value).trim();
6746
+ if (explicit) {
6747
+ const normalized = explicit.toLowerCase();
6748
+ if (normalized === 'exact' || normalized === 'declaration' || normalized === 'estimated' || normalized === 'blocked') return normalized;
6749
+ if (normalized === 'estimate' || normalized === 'approx' || normalized === 'approximate' || normalized === 'approximated' || normalized === 'line') return 'estimated';
6750
+ return explicit;
6751
+ }
6752
+
6753
+ const lossIds = new Set(context.lossIds ?? []);
6754
+ const linkedLosses = (context.losses ?? []).filter((loss) => lossIds.has(loss.id));
6755
+ if (linkedLosses.some((loss) => loss.severity === 'error')) return 'blocked';
6756
+ if (context.precision === 'exact') return 'exact';
6757
+ if (context.precision === 'declaration') return 'declaration';
6758
+ if (context.precision === 'line' || context.precision === 'estimated' || context.precision === 'unknown') return 'estimated';
6759
+ if (context.sourcePreservation?.summary?.exactSourceAvailable === true) return 'estimated';
6760
+ return 'estimated';
6761
+ }
6762
+
6692
6763
  function hasExactSpan(span) {
6693
6764
  return Boolean(span && (
6694
6765
  (typeof span.start === 'number' && typeof span.end === 'number') ||
@@ -7402,6 +7473,12 @@ function nativeSourceCompilePreservedMappings(input) {
7402
7473
  ownershipRegionKey: mapping.ownershipRegionKey,
7403
7474
  ownershipRegionKind: mapping.ownershipRegionKind,
7404
7475
  precision: exact ? 'exact' : mapping.precision === 'exact' ? 'line' : mapping.precision ?? 'line',
7476
+ preservation: exact ? 'exact' : normalizeSourcePreservationLevel(mapping.preservation, {
7477
+ precision: mapping.precision === 'exact' ? 'line' : mapping.precision ?? 'line',
7478
+ lossIds: mapping.lossIds,
7479
+ losses: input.losses ?? [],
7480
+ sourcePreservation: input.importResult.metadata?.sourcePreservation
7481
+ }),
7405
7482
  metadata: {
7406
7483
  ...mapping.metadata,
7407
7484
  compileResultId: input.compileResultId,
@@ -7429,6 +7506,7 @@ function nativeSourceCompileDeclarationMappings(input) {
7429
7506
  ownershipRegionKey: declaration.metadata?.ownershipRegionKey,
7430
7507
  ownershipRegionKind: declaration.metadata?.ownershipRegionKind,
7431
7508
  precision: generated.exactName ? 'declaration' : 'estimated',
7509
+ preservation: generated.exactName ? 'declaration' : 'estimated',
7432
7510
  metadata: {
7433
7511
  ...declaration.metadata,
7434
7512
  compileResultId: input.compileResultId,
@@ -7451,6 +7529,7 @@ function nativeSourceCompileFileMapping(input) {
7451
7529
  target: input.target,
7452
7530
  evidenceIds: (input.evidence ?? []).map((record) => record.id).filter(Boolean),
7453
7531
  precision: input.projection.mode === 'preserved-source' && input.outputHash === input.projection.sourceHash ? 'line' : 'estimated',
7532
+ preservation: input.losses?.some((loss) => loss.severity === 'error') ? 'blocked' : 'estimated',
7454
7533
  metadata: {
7455
7534
  compileResultId: input.compileResultId,
7456
7535
  sourceMapOrigin: 'file-fallback'
@@ -8497,6 +8576,7 @@ function semanticImportSidecarEntry(imported, index, options) {
8497
8576
  const nativeAst = imported?.nativeAst ?? imported?.nativeSource?.ast;
8498
8577
  const sourceMaps = imported?.sourceMaps ?? imported?.universalAst?.sourceMaps ?? [];
8499
8578
  const sourceMapMappings = sourceMaps.flatMap((sourceMap) => sourceMap?.mappings ?? []);
8579
+ const sourcePreservationRecords = collectKernelSourcePreservationFromImport(imported);
8500
8580
  const mappingsBySymbolId = new Map();
8501
8581
  for (const mapping of sourceMapMappings) {
8502
8582
  if (mapping.semanticSymbolId && !mappingsBySymbolId.has(mapping.semanticSymbolId)) {
@@ -8541,6 +8621,8 @@ function semanticImportSidecarEntry(imported, index, options) {
8541
8621
  symbolCount: symbols.length,
8542
8622
  sourceMapCount: sourceMaps.length,
8543
8623
  sourceMapMappingCount: sourceMapMappings.length,
8624
+ sourcePreservationRecordCount: sourcePreservationRecords.length,
8625
+ sourcePreservationLevels: uniqueStrings(sourcePreservationRecords.map((record) => record.level).filter(Boolean)),
8544
8626
  readiness: imported?.metadata?.semanticMergeReadiness ?? imported?.mergeCandidates?.[0]?.readiness ?? 'needs-review',
8545
8627
  emptySemanticIndex: symbols.length === 0,
8546
8628
  regionTaxonomy,
@@ -8935,6 +9017,127 @@ function summarizeImportRegions(importResult, imports, options = {}) {
8935
9017
  };
8936
9018
  }
8937
9019
 
9020
+ function createKernelSourcePreservationRecords(input) {
9021
+ const records = [];
9022
+ if (input.sourcePreservation) {
9023
+ const exactSource = input.sourcePreservation.summary?.exactSourceAvailable === true &&
9024
+ (!input.sourceHash || input.sourcePreservation.sourceHash === input.sourceHash);
9025
+ const hashMismatch = input.sourceHash &&
9026
+ input.sourcePreservation.sourceHash &&
9027
+ input.sourcePreservation.sourceHash !== input.sourceHash;
9028
+ records.push(createSourcePreservationRecord({
9029
+ id: `source_preservation_${idFragment(input.idPart ?? input.sourcePath ?? input.language)}_file`,
9030
+ level: hashMismatch ? 'blocked' : exactSource ? 'exact' : 'estimated',
9031
+ precision: exactSource ? 'exact' : 'estimated',
9032
+ nativeSourceId: input.nativeSource?.id,
9033
+ nativeAstNodeId: input.nativeAst?.rootId,
9034
+ sourceSpan: {
9035
+ sourceId: input.sourceHash,
9036
+ path: input.sourcePath,
9037
+ startLine: 1,
9038
+ startColumn: 1
9039
+ },
9040
+ lossIds: (input.losses ?? []).filter((loss) => loss.kind === 'sourcePreservation' || loss.sourceMapId).map((loss) => loss.id),
9041
+ evidenceIds: (input.evidence ?? []).map((record) => record.id).filter(Boolean),
9042
+ losses: input.losses ?? [],
9043
+ evidence: input.evidence ?? [],
9044
+ reasons: hashMismatch
9045
+ ? [`Preserved source hash ${input.sourcePreservation.sourceHash} does not match import hash ${input.sourceHash}.`]
9046
+ : exactSource
9047
+ ? ['Exact native source text is preserved for source-level replay and semantic merge review.']
9048
+ : ['Native source preservation metadata exists, but exact source text is unavailable or unverified.'],
9049
+ metadata: {
9050
+ compilerRecord: 'nativeSourcePreservation',
9051
+ nativeSourcePreservationId: input.sourcePreservation.id,
9052
+ sourceBytes: input.sourcePreservation.sourceBytes,
9053
+ lineCount: input.sourcePreservation.lineCount,
9054
+ tokens: input.sourcePreservation.summary?.tokens ?? 0,
9055
+ trivia: input.sourcePreservation.summary?.trivia ?? 0,
9056
+ directives: input.sourcePreservation.summary?.directives ?? 0,
9057
+ comments: input.sourcePreservation.summary?.comments ?? 0,
9058
+ whitespace: input.sourcePreservation.summary?.whitespace ?? 0,
9059
+ truncated: input.sourcePreservation.summary?.truncated === true
9060
+ }
9061
+ }));
9062
+ }
9063
+
9064
+ for (const sourceMap of input.sourceMaps ?? []) {
9065
+ for (const mapping of sourceMap.mappings ?? []) {
9066
+ records.push(explainSourcePreservation({
9067
+ id: `source_preservation_${idFragment(sourceMap.id)}_${idFragment(mapping.id)}`,
9068
+ sourceMap,
9069
+ mapping,
9070
+ level: mapping.preservation,
9071
+ losses: input.losses ?? [],
9072
+ evidence: uniqueRecordsById([...(input.evidence ?? []), ...(sourceMap.evidence ?? [])]),
9073
+ metadata: {
9074
+ compilerRecord: 'sourceMapMapping',
9075
+ language: input.language,
9076
+ semanticIndexId: input.semanticIndex?.id,
9077
+ sourceMapId: sourceMap.id,
9078
+ sourceMapMappingId: mapping.id
9079
+ }
9080
+ }));
9081
+ }
9082
+ }
9083
+
9084
+ return uniqueRecordsById(records);
9085
+ }
9086
+
9087
+ function summarizeKernelSourcePreservationRecords(records) {
9088
+ const compactRecords = records.map(compactKernelSourcePreservationRecord);
9089
+ const byLevel = countBy(compactRecords.map((record) => record.level ?? 'unknown'));
9090
+ return {
9091
+ total: compactRecords.length,
9092
+ ids: compactRecords.map((record) => record.id).filter(Boolean),
9093
+ byLevel,
9094
+ exact: byLevel.exact ?? 0,
9095
+ declaration: byLevel.declaration ?? 0,
9096
+ estimated: byLevel.estimated ?? 0,
9097
+ blocked: byLevel.blocked ?? 0,
9098
+ sourcePaths: uniqueStrings(compactRecords.map((record) => record.sourcePath).filter(Boolean)),
9099
+ sourceMapIds: uniqueStrings(compactRecords.map((record) => record.sourceMapId).filter(Boolean)),
9100
+ sourceMapMappingIds: uniqueStrings(compactRecords.map((record) => record.sourceMapMappingId).filter(Boolean)),
9101
+ records: compactRecords
9102
+ };
9103
+ }
9104
+
9105
+ function collectKernelSourcePreservationFromImport(imported) {
9106
+ return uniqueRecordsById([
9107
+ ...(imported?.metadata?.kernelSourcePreservationRecords ?? []),
9108
+ ...(imported?.metadata?.sourcePreservationRecords ?? []),
9109
+ ...(imported?.universalAst?.metadata?.kernelSourcePreservationRecords ?? []),
9110
+ ...(imported?.universalAst?.metadata?.sourcePreservationRecords ?? [])
9111
+ ].filter((record) => record?.kind === 'frontier.lang.sourcePreservation'));
9112
+ }
9113
+
9114
+ function summarizeKernelSourcePreservation(importResult, imports) {
9115
+ return summarizeKernelSourcePreservationRecords(uniqueRecordsById([
9116
+ ...collectKernelSourcePreservationFromImport(importResult),
9117
+ ...imports.flatMap((imported) => collectKernelSourcePreservationFromImport(imported))
9118
+ ]));
9119
+ }
9120
+
9121
+ function compactKernelSourcePreservationRecord(record) {
9122
+ return {
9123
+ id: record.id,
9124
+ level: record.level,
9125
+ precision: record.precision,
9126
+ sourceMapId: record.sourceMapId,
9127
+ sourceMapMappingId: record.sourceMapMappingId,
9128
+ semanticNodeId: record.semanticNodeId,
9129
+ nativeSourceId: record.nativeSourceId,
9130
+ nativeAstNodeId: record.nativeAstNodeId,
9131
+ semanticSymbolId: record.semanticSymbolId,
9132
+ semanticOccurrenceId: record.semanticOccurrenceId,
9133
+ sourcePath: record.sourceSpan?.path,
9134
+ generatedPath: record.generatedSpan?.path ?? record.generatedSpan?.targetPath,
9135
+ lossIds: record.lossIds ?? [],
9136
+ evidenceIds: record.evidenceIds ?? [],
9137
+ reasons: record.reasons ?? []
9138
+ };
9139
+ }
9140
+
8938
9141
  function summarizeImportSourcePreservation(importResult, imports) {
8939
9142
  const records = uniqueSourcePreservationRecords([
8940
9143
  ...collectSourcePreservationFromImport(importResult),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -59,7 +59,7 @@
59
59
  "@shapeshift-labs/frontier-lang-c": "0.2.5",
60
60
  "@shapeshift-labs/frontier-lang-checker": "0.3.4",
61
61
  "@shapeshift-labs/frontier-lang-javascript": "0.2.5",
62
- "@shapeshift-labs/frontier-lang-kernel": "0.3.4",
62
+ "@shapeshift-labs/frontier-lang-kernel": "0.3.5",
63
63
  "@shapeshift-labs/frontier-lang-parser": "0.3.4",
64
64
  "@shapeshift-labs/frontier-lang-python": "0.2.5",
65
65
  "@shapeshift-labs/frontier-lang-rust": "0.2.5",