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

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
@@ -197,6 +197,7 @@ const sidecar = createSemanticImportSidecar(imported);
197
197
  console.log(sidecar.summary.emptySemanticIndex); // false when symbols were found
198
198
  console.log(sidecar.ownershipRegions[0].key); // source#src/runtime.ts#type#Runtime
199
199
  console.log(sidecar.patchHints[0].supportedOperations); // source-region patch operations
200
+ console.log(sidecar.proofSpec.obligations); // proof/spec obligations when the import carries a universal AST proof layer
200
201
  ```
201
202
 
202
203
  The built-in JavaScript/TypeScript lightweight scanner also emits review-required ownership regions for clear route/config/content/property shapes in exported objects and arrays:
package/dist/index.d.ts CHANGED
@@ -20,7 +20,9 @@ import type {
20
20
  SourceMapRecord,
21
21
  SourcePreservationLevel,
22
22
  SourcePreservationRecord,
23
- SourceSpan
23
+ SourceSpan,
24
+ UniversalAstLayerMap,
25
+ UniversalAstLayerRecord
24
26
  } from '@shapeshift-labs/frontier-lang-kernel';
25
27
  import type { Diagnostic } from '@shapeshift-labs/frontier-lang-checker';
26
28
  import type { EmitTypeScriptOptions, TypeScriptAstModule, TypeScriptDocumentSourceMapResult, TypeScriptGeneratedSourceMapResult } from '@shapeshift-labs/frontier-lang-typescript';
@@ -963,6 +965,10 @@ export interface SemanticImportSidecarImportEntry {
963
965
  readonly sourceMapMappingCount: number;
964
966
  readonly sourcePreservationRecordCount: number;
965
967
  readonly sourcePreservationLevels: readonly SourcePreservationLevel[];
968
+ readonly universalAstLayerCount: number;
969
+ readonly universalAstLayerNames: readonly string[];
970
+ readonly universalAstLayerIds: readonly string[];
971
+ readonly proofSpec: SemanticImportSidecarProofSpecSummary;
966
972
  readonly readiness: SemanticMergeReadiness;
967
973
  readonly emptySemanticIndex: boolean;
968
974
  readonly regionTaxonomy?: SemanticImportRegionTaxonomySummary;
@@ -986,6 +992,40 @@ export interface SemanticImportSidecarSourcePreservationRecord {
986
992
  readonly reasons: readonly string[];
987
993
  }
988
994
 
995
+ export interface SemanticImportSidecarUniversalAstLayerSummary {
996
+ readonly total: number;
997
+ readonly names: readonly string[];
998
+ readonly ids: readonly string[];
999
+ readonly byName: Readonly<Record<string, number>>;
1000
+ readonly empty: boolean;
1001
+ }
1002
+
1003
+ export interface SemanticImportSidecarProofSpecSummary {
1004
+ readonly total: number;
1005
+ readonly ids: readonly string[];
1006
+ readonly contracts: number;
1007
+ readonly refinements: number;
1008
+ readonly invariants: number;
1009
+ readonly termination: number;
1010
+ readonly temporal: number;
1011
+ readonly obligations: number;
1012
+ readonly artifacts: number;
1013
+ readonly assumptions: number;
1014
+ readonly evidence: number;
1015
+ readonly discharged: number;
1016
+ readonly failed: number;
1017
+ readonly open: number;
1018
+ readonly unknown: number;
1019
+ readonly stale: number;
1020
+ readonly assumed: number;
1021
+ readonly contractKinds: readonly string[];
1022
+ readonly artifactKinds: readonly string[];
1023
+ readonly byStatus: Readonly<Record<string, number>>;
1024
+ readonly byContractKind: Readonly<Record<string, number>>;
1025
+ readonly byArtifactKind: Readonly<Record<string, number>>;
1026
+ readonly empty: boolean;
1027
+ }
1028
+
989
1029
  export interface SemanticImportSidecar {
990
1030
  readonly kind: 'frontier.lang.semanticImportSidecar';
991
1031
  readonly version: 1;
@@ -1014,6 +1054,8 @@ export interface SemanticImportSidecar {
1014
1054
  readonly sourceMapMappingIds: readonly string[];
1015
1055
  readonly records: readonly SemanticImportSidecarSourcePreservationRecord[];
1016
1056
  };
1057
+ readonly universalAstLayers: SemanticImportSidecarUniversalAstLayerSummary;
1058
+ readonly proofSpec: SemanticImportSidecarProofSpecSummary;
1017
1059
  readonly patchHints: readonly SemanticImportPatchHint[];
1018
1060
  readonly mergeCandidates: readonly {
1019
1061
  readonly id?: string;
@@ -1043,6 +1085,11 @@ export interface SemanticImportSidecar {
1043
1085
  readonly regionKinds: number;
1044
1086
  readonly sourceMapMappings: number;
1045
1087
  readonly sourcePreservationRecords: number;
1088
+ readonly universalAstLayers: number;
1089
+ readonly universalAstLayerNames: readonly string[];
1090
+ readonly proofSpecRecords: number;
1091
+ readonly proofSpecObligations: number;
1092
+ readonly proofSpecFailedObligations: number;
1046
1093
  readonly readiness: SemanticMergeReadiness;
1047
1094
  readonly emptySemanticIndex: boolean;
1048
1095
  };
@@ -2190,9 +2237,13 @@ export declare function diffNativeSourceImports(input: DiffNativeSourceImportsOp
2190
2237
  export declare function importNativeProject(input: ImportNativeProjectOptions): Promise<NativeProjectImportResult>;
2191
2238
  export declare function createUniversalAstFromDocument(document: FrontierLangDocument, input?: {
2192
2239
  readonly id?: string;
2240
+ readonly nativeSources?: readonly NativeSourceNode[];
2193
2241
  readonly semanticIndex?: SemanticIndexRecord;
2194
2242
  readonly sourceMaps?: readonly SourceMapRecord[];
2243
+ readonly losses?: readonly NativeAstLossRecord[];
2195
2244
  readonly evidence?: readonly EvidenceRecord[];
2245
+ readonly mergeCandidates?: readonly SemanticMergeCandidateRecord[];
2246
+ readonly layers?: UniversalAstLayerMap | readonly UniversalAstLayerRecord[];
2196
2247
  readonly metadata?: Record<string, unknown>;
2197
2248
  }): FrontierUniversalAstEnvelope;
2198
2249
  export declare function readUniversalAstJson(source: string): FrontierUniversalAstEnvelope;
package/dist/index.js CHANGED
@@ -2565,6 +2565,8 @@ export function createSemanticImportSidecar(importResult, options = {}) {
2565
2565
  const lossSummary = summarizeNativeImportLosses(losses, { evidence });
2566
2566
  const regionTaxonomy = summarizeSemanticImportRegionTaxonomy(ownershipRegions);
2567
2567
  const sourcePreservation = summarizeKernelSourcePreservation(importResult, imports);
2568
+ const universalAstLayers = summarizeSemanticImportSidecarUniversalAstLayers(importEntries);
2569
+ const proofSpec = summarizeSemanticImportSidecarProofSpec(importEntries);
2568
2570
  const readiness = mergeCandidates.reduce(
2569
2571
  (current, candidate) => maxSemanticMergeReadiness(current, candidate.readiness),
2570
2572
  lossSummary.semanticMergeReadiness
@@ -2586,6 +2588,8 @@ export function createSemanticImportSidecar(importResult, options = {}) {
2586
2588
  ids: sourceMaps.map((sourceMap) => sourceMap.id).filter(Boolean)
2587
2589
  },
2588
2590
  sourcePreservation,
2591
+ universalAstLayers,
2592
+ proofSpec,
2589
2593
  patchHints,
2590
2594
  mergeCandidates: mergeCandidates.map((candidate) => ({
2591
2595
  id: candidate.id,
@@ -2615,6 +2619,11 @@ export function createSemanticImportSidecar(importResult, options = {}) {
2615
2619
  regionKinds: regionTaxonomy.presentKinds.length,
2616
2620
  sourceMapMappings: sourceMapMappings.length,
2617
2621
  sourcePreservationRecords: sourcePreservation.total,
2622
+ universalAstLayers: universalAstLayers.total,
2623
+ universalAstLayerNames: universalAstLayers.names,
2624
+ proofSpecRecords: proofSpec.total,
2625
+ proofSpecObligations: proofSpec.obligations,
2626
+ proofSpecFailedObligations: proofSpec.failed,
2618
2627
  readiness,
2619
2628
  emptySemanticIndex: symbols.length === 0
2620
2629
  },
@@ -8577,6 +8586,8 @@ function semanticImportSidecarEntry(imported, index, options) {
8577
8586
  const sourceMaps = imported?.sourceMaps ?? imported?.universalAst?.sourceMaps ?? [];
8578
8587
  const sourceMapMappings = sourceMaps.flatMap((sourceMap) => sourceMap?.mappings ?? []);
8579
8588
  const sourcePreservationRecords = collectKernelSourcePreservationFromImport(imported);
8589
+ const universalAstLayers = summarizeUniversalAstLayers(imported?.universalAst);
8590
+ const proofSpec = summarizeProofSpecLayer(imported?.universalAst?.proof ?? imported?.proof);
8580
8591
  const mappingsBySymbolId = new Map();
8581
8592
  for (const mapping of sourceMapMappings) {
8582
8593
  if (mapping.semanticSymbolId && !mappingsBySymbolId.has(mapping.semanticSymbolId)) {
@@ -8623,6 +8634,10 @@ function semanticImportSidecarEntry(imported, index, options) {
8623
8634
  sourceMapMappingCount: sourceMapMappings.length,
8624
8635
  sourcePreservationRecordCount: sourcePreservationRecords.length,
8625
8636
  sourcePreservationLevels: uniqueStrings(sourcePreservationRecords.map((record) => record.level).filter(Boolean)),
8637
+ universalAstLayerCount: universalAstLayers.total,
8638
+ universalAstLayerNames: universalAstLayers.names,
8639
+ universalAstLayerIds: universalAstLayers.ids,
8640
+ proofSpec,
8626
8641
  readiness: imported?.metadata?.semanticMergeReadiness ?? imported?.mergeCandidates?.[0]?.readiness ?? 'needs-review',
8627
8642
  emptySemanticIndex: symbols.length === 0,
8628
8643
  regionTaxonomy,
@@ -8631,6 +8646,167 @@ function semanticImportSidecarEntry(imported, index, options) {
8631
8646
  };
8632
8647
  }
8633
8648
 
8649
+ function summarizeSemanticImportSidecarProofSpec(importEntries) {
8650
+ const byStatus = {};
8651
+ const byContractKind = {};
8652
+ const byArtifactKind = {};
8653
+ const ids = [];
8654
+ const contractKinds = [];
8655
+ const artifactKinds = [];
8656
+ const totals = {
8657
+ total: 0,
8658
+ contracts: 0,
8659
+ refinements: 0,
8660
+ invariants: 0,
8661
+ termination: 0,
8662
+ temporal: 0,
8663
+ obligations: 0,
8664
+ artifacts: 0,
8665
+ assumptions: 0,
8666
+ evidence: 0,
8667
+ discharged: 0,
8668
+ failed: 0,
8669
+ open: 0,
8670
+ unknown: 0,
8671
+ stale: 0,
8672
+ assumed: 0
8673
+ };
8674
+ for (const entry of importEntries) {
8675
+ const proof = entry.proofSpec ?? summarizeProofSpecLayer();
8676
+ ids.push(...(proof.ids ?? []));
8677
+ contractKinds.push(...(proof.contractKinds ?? []));
8678
+ artifactKinds.push(...(proof.artifactKinds ?? []));
8679
+ for (const key of Object.keys(totals)) {
8680
+ totals[key] += proof[key] ?? 0;
8681
+ }
8682
+ for (const [status, count] of Object.entries(proof.byStatus ?? {})) {
8683
+ byStatus[status] = (byStatus[status] ?? 0) + count;
8684
+ }
8685
+ for (const [kind, count] of Object.entries(proof.byContractKind ?? {})) {
8686
+ byContractKind[kind] = (byContractKind[kind] ?? 0) + count;
8687
+ }
8688
+ for (const [kind, count] of Object.entries(proof.byArtifactKind ?? {})) {
8689
+ byArtifactKind[kind] = (byArtifactKind[kind] ?? 0) + count;
8690
+ }
8691
+ }
8692
+ return {
8693
+ ...totals,
8694
+ ids: uniqueStrings(ids),
8695
+ contractKinds: uniqueStrings(contractKinds),
8696
+ artifactKinds: uniqueStrings(artifactKinds),
8697
+ byStatus,
8698
+ byContractKind,
8699
+ byArtifactKind,
8700
+ empty: totals.total === 0
8701
+ };
8702
+ }
8703
+
8704
+ function summarizeProofSpecLayer(proof = {}) {
8705
+ const contracts = proof?.contracts ?? [];
8706
+ const refinements = proof?.refinements ?? [];
8707
+ const invariants = proof?.invariants ?? [];
8708
+ const termination = proof?.termination ?? [];
8709
+ const temporal = proof?.temporal ?? [];
8710
+ const obligations = proof?.obligations ?? [];
8711
+ const artifacts = proof?.artifacts ?? [];
8712
+ const assumptions = proof?.assumptions ?? [];
8713
+ const evidence = proof?.evidence ?? [];
8714
+ const allContracts = [...contracts, ...refinements, ...invariants, ...termination, ...temporal];
8715
+ const byStatus = {};
8716
+ for (const obligation of obligations) {
8717
+ const status = obligation?.status ?? 'unknown';
8718
+ byStatus[status] = (byStatus[status] ?? 0) + 1;
8719
+ }
8720
+ const byContractKind = {};
8721
+ for (const contract of allContracts) {
8722
+ const kind = contract?.kind ?? 'unknown';
8723
+ byContractKind[kind] = (byContractKind[kind] ?? 0) + 1;
8724
+ }
8725
+ const byArtifactKind = {};
8726
+ for (const artifact of artifacts) {
8727
+ const kind = artifact?.kind ?? 'unknown';
8728
+ byArtifactKind[kind] = (byArtifactKind[kind] ?? 0) + 1;
8729
+ }
8730
+ const recordGroups = [allContracts, obligations, artifacts, assumptions];
8731
+ const ids = uniqueStrings([
8732
+ proof?.id,
8733
+ ...recordGroups.flatMap((records) => records.map((record) => record?.id)),
8734
+ ...evidence.map((record) => record?.id)
8735
+ ].filter(Boolean));
8736
+ const total = allContracts.length + obligations.length + artifacts.length + assumptions.length;
8737
+ return {
8738
+ total,
8739
+ ids,
8740
+ contracts: contracts.length,
8741
+ refinements: refinements.length,
8742
+ invariants: invariants.length,
8743
+ termination: termination.length,
8744
+ temporal: temporal.length,
8745
+ obligations: obligations.length,
8746
+ artifacts: artifacts.length,
8747
+ assumptions: assumptions.length,
8748
+ evidence: evidence.length,
8749
+ discharged: byStatus.discharged ?? 0,
8750
+ failed: byStatus.failed ?? 0,
8751
+ open: byStatus.open ?? 0,
8752
+ unknown: byStatus.unknown ?? 0,
8753
+ stale: byStatus.stale ?? 0,
8754
+ assumed: byStatus.assumed ?? 0,
8755
+ contractKinds: uniqueStrings(allContracts.map((record) => record?.kind).filter(Boolean)),
8756
+ artifactKinds: uniqueStrings(artifacts.map((record) => record?.kind).filter(Boolean)),
8757
+ byStatus,
8758
+ byContractKind,
8759
+ byArtifactKind,
8760
+ empty: total === 0
8761
+ };
8762
+ }
8763
+
8764
+ function summarizeSemanticImportSidecarUniversalAstLayers(importEntries) {
8765
+ const names = [];
8766
+ const ids = [];
8767
+ const byName = {};
8768
+ for (const entry of importEntries) {
8769
+ names.push(...(entry.universalAstLayerNames ?? []));
8770
+ ids.push(...(entry.universalAstLayerIds ?? []));
8771
+ for (const name of entry.universalAstLayerNames ?? []) {
8772
+ byName[name] = (byName[name] ?? 0) + 1;
8773
+ }
8774
+ }
8775
+ const uniqueNames = uniqueStrings(names);
8776
+ return {
8777
+ total: ids.length,
8778
+ names: uniqueNames,
8779
+ ids: uniqueStrings(ids),
8780
+ byName,
8781
+ empty: ids.length === 0
8782
+ };
8783
+ }
8784
+
8785
+ function summarizeUniversalAstLayers(universalAst) {
8786
+ const layers = collectUniversalAstLayerRecords(universalAst?.layers);
8787
+ const names = uniqueStrings(layers.map((layer) => layer.layer).filter(Boolean));
8788
+ const ids = uniqueStrings(layers.map((layer) => layer.id).filter(Boolean));
8789
+ const byName = {};
8790
+ for (const layer of layers) {
8791
+ if (!layer?.layer) continue;
8792
+ byName[layer.layer] = (byName[layer.layer] ?? 0) + 1;
8793
+ }
8794
+ return {
8795
+ total: layers.length,
8796
+ names,
8797
+ ids,
8798
+ byName,
8799
+ empty: layers.length === 0
8800
+ };
8801
+ }
8802
+
8803
+ function collectUniversalAstLayerRecords(layers) {
8804
+ if (!layers) return [];
8805
+ if (Array.isArray(layers)) return layers.filter(Boolean);
8806
+ if (typeof layers !== 'object') return [];
8807
+ return Object.values(layers).flatMap((value) => Array.isArray(value) ? value : [value]).filter(Boolean);
8808
+ }
8809
+
8634
8810
  function semanticOwnershipRegionForSymbol(imported, symbol, mapping, nativeNode, options = {}) {
8635
8811
  const sourcePath = mapping?.sourceSpan?.path ?? symbol.definitionSpan?.path ?? nativeNode?.span?.path ?? imported?.sourcePath ?? imported?.nativeSource?.sourcePath ?? imported?.nativeAst?.sourcePath;
8636
8812
  const language = symbol.language ?? imported?.language ?? imported?.nativeAst?.language ?? imported?.nativeSource?.language;
@@ -9359,9 +9535,13 @@ export function createUniversalAstFromDocument(document, input = {}) {
9359
9535
  return createUniversalAstEnvelope({
9360
9536
  id: input.id ?? `universal_ast_${idFragment(document.id)}`,
9361
9537
  document,
9538
+ nativeSources: input.nativeSources,
9362
9539
  semanticIndex: input.semanticIndex,
9363
9540
  sourceMaps: input.sourceMaps ?? [],
9541
+ losses: input.losses,
9364
9542
  evidence: input.evidence ?? [],
9543
+ mergeCandidates: input.mergeCandidates,
9544
+ layers: input.layers,
9365
9545
  metadata: input.metadata
9366
9546
  });
9367
9547
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
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.5",
62
+ "@shapeshift-labs/frontier-lang-kernel": "0.3.7",
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",