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

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
@@ -118,6 +118,7 @@ import {
118
118
  createNativeImportCoverageMatrix,
119
119
  createNativeParserAstFormatMatrix,
120
120
  createProjectionTargetLossMatrix,
121
+ createUniversalCapabilityMatrix,
121
122
  importNativeSource
122
123
  } from '@shapeshift-labs/frontier-lang-compiler';
123
124
 
@@ -142,6 +143,15 @@ const pythonProjection = projectionMatrix.languages.find((entry) => entry.langua
142
143
  console.log(pythonProjection.sourceProjection.exactSource.lossClass); // "exactSourceProjection"
143
144
  console.log(pythonProjection.sourceProjection.stubs.lossClass); // "nativeSourceStubs"
144
145
  console.log(pythonProjection.targets.find((entry) => entry.target === 'rust').lossClass); // "missingAdapter"
146
+
147
+ const universalMatrix = createUniversalCapabilityMatrix({
148
+ imports: [imported],
149
+ requiredFeatures: ['syntax', 'semantic', 'sourcePreservation']
150
+ });
151
+ const pythonUniversal = universalMatrix.languages.find((entry) => entry.language === 'python');
152
+
153
+ console.log(pythonUniversal.readiness); // combined import/parser/projection readiness
154
+ console.log(pythonUniversal.blockers); // missing evidence/adapters that prevent merge admission
145
155
  ```
146
156
 
147
157
  The projection target matrix separates five runtime/API classes:
@@ -152,6 +162,8 @@ The projection target matrix separates five runtime/API classes:
152
162
  - `targetAdapterProjection`: a host-owned native-to-target adapter is present and produced target output with its own evidence/readiness.
153
163
  - `missingAdapter`: no native-to-target projection adapter is declared; preserve or stub the original source language instead, or inject host-owned parser/semantic adapter evidence.
154
164
 
165
+ `createUniversalCapabilityMatrix` composes the import coverage, parser AST format, parser feature, and projection target matrices into a single language row per source language. It is the coordinator-facing view for universal-language work: it shows imports, symbols, source-map mappings, parser feature readiness, projection targets, missing adapters, unsupported target features, blockers, and review reasons without claiming lossless conversion where evidence is absent.
166
+
155
167
  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:
156
168
 
157
169
  ```js
@@ -198,6 +210,7 @@ console.log(sidecar.summary.emptySemanticIndex); // false when symbols were foun
198
210
  console.log(sidecar.ownershipRegions[0].key); // source#src/runtime.ts#type#Runtime
199
211
  console.log(sidecar.patchHints[0].supportedOperations); // source-region patch operations
200
212
  console.log(sidecar.proofSpec.obligations); // proof/spec obligations when the import carries a universal AST proof layer
213
+ console.log(sidecar.paradigmSemantics.hasLowering); // true when source import preserved lowering/paradigm records
201
214
  ```
202
215
 
203
216
  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/bench/smoke.mjs CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  createNativeParserAstFormatMatrix,
13
13
  createNativeParserFeatureMatrix,
14
14
  createProjectionTargetLossMatrix,
15
+ createUniversalCapabilityMatrix,
15
16
  createNativeSourcePreservation,
16
17
  createPythonAstNativeImporterAdapter,
17
18
  createRustSynNativeImporterAdapter,
@@ -140,6 +141,14 @@ const projectionMatrixStart = performance.now();
140
141
  const projectionLossMatrix = createProjectionTargetLossMatrix({ imports: nativeImportResults });
141
142
  const projectionMatrixDurationMs = performance.now() - projectionMatrixStart;
142
143
 
144
+ const universalMatrixStart = performance.now();
145
+ const universalCapabilityMatrix = createUniversalCapabilityMatrix({
146
+ imports: nativeImportResults,
147
+ adapters: [estreeAdapter, createPythonAstNativeImporterAdapter(), createRustSynNativeImporterAdapter(), createClangAstNativeImporterAdapter(), createGoAstNativeImporterAdapter(), createJavaAstNativeImporterAdapter(), kotlinPsiAdapter, createCSharpRoslynNativeImporterAdapter(), createSwiftSyntaxNativeImporterAdapter()],
148
+ requiredFeatures: ['syntax', 'semantic', 'sourcePreservation']
149
+ });
150
+ const universalMatrixDurationMs = performance.now() - universalMatrixStart;
151
+
143
152
  const preservationStart = performance.now();
144
153
  const preservationRecords = nativeImportResults.map((imported) => imported.metadata.sourcePreservation ?? createNativeSourcePreservation({
145
154
  language: imported.language,
@@ -304,6 +313,11 @@ console.log(JSON.stringify({
304
313
  projectionMatrixMissingAdapters: projectionLossMatrix.summary.missingAdapters,
305
314
  projectionMatrixUnsupportedTargetFeatures: projectionLossMatrix.summary.unsupportedTargetFeatures,
306
315
  projectionMatrixDurationMs: Number(projectionMatrixDurationMs.toFixed(2)),
316
+ universalMatrixLanguages: universalCapabilityMatrix.summary.languages,
317
+ universalMatrixImports: universalCapabilityMatrix.summary.imports,
318
+ universalMatrixBlockedLanguages: universalCapabilityMatrix.summary.blockedLanguages,
319
+ universalMatrixMissingAdapters: universalCapabilityMatrix.summary.missingAdapters,
320
+ universalMatrixDurationMs: Number(universalMatrixDurationMs.toFixed(2)),
307
321
  sourcePreservationRecords: preservationRecords.length,
308
322
  sourcePreservationTokens: preservationTokens,
309
323
  sourcePreservationDurationMs: Number(preservationDurationMs.toFixed(2)),
package/dist/index.d.ts CHANGED
@@ -652,6 +652,101 @@ export interface ProjectionTargetLossMatrixOptions {
652
652
  readonly generatedAt?: number;
653
653
  }
654
654
 
655
+ export interface UniversalCapabilityLanguageRow {
656
+ readonly language: FrontierSourceLanguage | string;
657
+ readonly aliases: readonly string[];
658
+ readonly extensions: readonly string[];
659
+ readonly readiness: SemanticMergeReadiness;
660
+ readonly imports: {
661
+ readonly total: number;
662
+ readonly readiness: SemanticMergeReadiness;
663
+ readonly symbols: number;
664
+ readonly sourceMaps: number;
665
+ readonly sourceMapMappings: number;
666
+ readonly losses: number;
667
+ readonly lossKinds: Readonly<Record<string, number>>;
668
+ readonly readinessReasons: readonly string[];
669
+ };
670
+ readonly parser: {
671
+ readonly readiness: SemanticMergeReadiness;
672
+ readonly rows: number;
673
+ readonly parsers: readonly string[];
674
+ readonly mergeReadyParsers: readonly string[];
675
+ readonly blockingFeatures: readonly NativeParserFeatureCategory[];
676
+ readonly reviewFeatures: readonly NativeParserFeatureCategory[];
677
+ readonly languageSummary?: NativeParserFeatureLanguageSummary;
678
+ };
679
+ readonly projection: {
680
+ readonly readiness: SemanticMergeReadiness;
681
+ readonly sourceProjection?: ProjectionTargetLanguageCoverage['sourceProjection'];
682
+ readonly targets: readonly ProjectionTargetCoverageEntry[];
683
+ readonly summary: ProjectionTargetLanguageCoverage['summary'];
684
+ readonly missingTargets: readonly (FrontierCompileTarget | string)[];
685
+ readonly unsupportedTargets: readonly (FrontierCompileTarget | string)[];
686
+ };
687
+ readonly evidence: {
688
+ readonly parserAdapters: number;
689
+ readonly adapterCoverageSummaries: number;
690
+ readonly adapterCoverageGaps: Readonly<Record<string, number>>;
691
+ readonly knownLossKinds: readonly NativeImportKnownLossKind[];
692
+ readonly sourceMapMappings: number;
693
+ };
694
+ readonly blockers: readonly string[];
695
+ readonly review: readonly string[];
696
+ }
697
+
698
+ export interface UniversalCapabilityMatrix {
699
+ readonly kind: 'frontier.lang.universalCapabilityMatrix';
700
+ readonly version: 1;
701
+ readonly generatedAt: number;
702
+ readonly languages: readonly UniversalCapabilityLanguageRow[];
703
+ readonly summary: {
704
+ readonly languages: number;
705
+ readonly imports: number;
706
+ readonly symbols: number;
707
+ readonly sourceMapMappings: number;
708
+ readonly losses: number;
709
+ readonly parserRows: number;
710
+ readonly parserMergeReady: number;
711
+ readonly targetEntries: number;
712
+ readonly missingAdapters: number;
713
+ readonly unsupportedTargetFeatures: number;
714
+ readonly exactSourceProjection: number;
715
+ readonly nativeSourceStubs: number;
716
+ readonly blockers: number;
717
+ readonly reviewReasons: number;
718
+ readonly readyLanguages: number;
719
+ readonly readyWithLossesLanguages: number;
720
+ readonly reviewLanguages: number;
721
+ readonly blockedLanguages: number;
722
+ readonly byReadiness: Readonly<Record<SemanticMergeReadiness, number>>;
723
+ readonly byImportReadiness: Readonly<Record<SemanticMergeReadiness, number>>;
724
+ readonly byParserReadiness: Readonly<Record<SemanticMergeReadiness, number>>;
725
+ readonly byProjectionReadiness: Readonly<Record<SemanticMergeReadiness, number>>;
726
+ };
727
+ readonly matrices: {
728
+ readonly importCoverage: NativeImportCoverageMatrix;
729
+ readonly parserFormats: NativeParserAstFormatMatrix;
730
+ readonly parserFeatures: NativeParserFeatureMatrix;
731
+ readonly projectionTargets: ProjectionTargetLossMatrix;
732
+ };
733
+ readonly metadata: {
734
+ readonly requiredFeatures: readonly NativeParserFeatureCategory[];
735
+ readonly minimumReadiness: SemanticMergeReadiness;
736
+ readonly compileTargets: readonly (FrontierCompileTarget | string)[];
737
+ readonly note: string;
738
+ };
739
+ }
740
+
741
+ export interface UniversalCapabilityMatrixOptions extends
742
+ NativeImportCoverageMatrixOptions,
743
+ NativeParserAstFormatMatrixOptions,
744
+ NativeParserFeatureMatrixOptions,
745
+ ProjectionTargetLossMatrixOptions {
746
+ readonly targetAdapters?: readonly NativeTargetProjectionAdapter[];
747
+ readonly targets?: readonly (FrontierCompileTarget | string)[];
748
+ }
749
+
655
750
  export interface NativeImportContractSource {
656
751
  readonly id: string;
657
752
  readonly language?: FrontierSourceLanguage | string;
@@ -969,6 +1064,7 @@ export interface SemanticImportSidecarImportEntry {
969
1064
  readonly universalAstLayerNames: readonly string[];
970
1065
  readonly universalAstLayerIds: readonly string[];
971
1066
  readonly proofSpec: SemanticImportSidecarProofSpecSummary;
1067
+ readonly paradigmSemantics: SemanticImportSidecarParadigmSemanticsSummary;
972
1068
  readonly readiness: SemanticMergeReadiness;
973
1069
  readonly emptySemanticIndex: boolean;
974
1070
  readonly regionTaxonomy?: SemanticImportRegionTaxonomySummary;
@@ -1026,6 +1122,42 @@ export interface SemanticImportSidecarProofSpecSummary {
1026
1122
  readonly empty: boolean;
1027
1123
  }
1028
1124
 
1125
+ export interface SemanticImportSidecarParadigmSemanticsSummary {
1126
+ readonly total: number;
1127
+ readonly ids: readonly string[];
1128
+ readonly groups: readonly string[];
1129
+ readonly kinds: readonly string[];
1130
+ readonly evidence: number;
1131
+ readonly bindingScopes: number;
1132
+ readonly bindings: number;
1133
+ readonly patterns: number;
1134
+ readonly typeConstraints: number;
1135
+ readonly evaluationModels: number;
1136
+ readonly memoryLocations: number;
1137
+ readonly effectRegions: number;
1138
+ readonly controlRegions: number;
1139
+ readonly logicPrograms: number;
1140
+ readonly actorSystems: number;
1141
+ readonly stackEffects: number;
1142
+ readonly arrayShapes: number;
1143
+ readonly numericKernels: number;
1144
+ readonly dataflowNetworks: number;
1145
+ readonly clockModels: number;
1146
+ readonly objectModels: number;
1147
+ readonly macroExpansions: number;
1148
+ readonly reflectionBoundaries: number;
1149
+ readonly loweringRecords: number;
1150
+ readonly byGroup: Readonly<Record<string, number>>;
1151
+ readonly byKind: Readonly<Record<string, number>>;
1152
+ readonly hasRuntimeSemantics: boolean;
1153
+ readonly hasLogicSemantics: boolean;
1154
+ readonly hasStackSemantics: boolean;
1155
+ readonly hasArraySemantics: boolean;
1156
+ readonly hasMacroOrReflection: boolean;
1157
+ readonly hasLowering: boolean;
1158
+ readonly empty: boolean;
1159
+ }
1160
+
1029
1161
  export interface SemanticImportSidecar {
1030
1162
  readonly kind: 'frontier.lang.semanticImportSidecar';
1031
1163
  readonly version: 1;
@@ -1056,6 +1188,7 @@ export interface SemanticImportSidecar {
1056
1188
  };
1057
1189
  readonly universalAstLayers: SemanticImportSidecarUniversalAstLayerSummary;
1058
1190
  readonly proofSpec: SemanticImportSidecarProofSpecSummary;
1191
+ readonly paradigmSemantics: SemanticImportSidecarParadigmSemanticsSummary;
1059
1192
  readonly patchHints: readonly SemanticImportPatchHint[];
1060
1193
  readonly mergeCandidates: readonly {
1061
1194
  readonly id?: string;
@@ -1090,6 +1223,9 @@ export interface SemanticImportSidecar {
1090
1223
  readonly proofSpecRecords: number;
1091
1224
  readonly proofSpecObligations: number;
1092
1225
  readonly proofSpecFailedObligations: number;
1226
+ readonly paradigmSemanticsRecords: number;
1227
+ readonly paradigmSemanticsGroups: number;
1228
+ readonly paradigmSemanticsLoweringRecords: number;
1093
1229
  readonly readiness: SemanticMergeReadiness;
1094
1230
  readonly emptySemanticIndex: boolean;
1095
1231
  };
@@ -2212,6 +2348,7 @@ export declare function createNativeParserAstFormatMatrix(options?: NativeParser
2212
2348
  export declare function createNativeParserFeatureMatrix(options?: NativeParserFeatureMatrixOptions): NativeParserFeatureMatrix;
2213
2349
  export declare function queryNativeParserFeatureMatrix(matrixOrOptions?: NativeParserFeatureMatrix | NativeParserFeatureMatrixOptions, query?: NativeParserFeatureMatrixQuery): NativeParserFeatureMatrixQueryResult;
2214
2350
  export declare function createProjectionTargetLossMatrix(options?: ProjectionTargetLossMatrixOptions): ProjectionTargetLossMatrix;
2351
+ export declare function createUniversalCapabilityMatrix(options?: UniversalCapabilityMatrixOptions): UniversalCapabilityMatrix;
2215
2352
  export declare function createNativeSourcePreservation(options: CreateNativeSourcePreservationOptions): NativeSourcePreservation;
2216
2353
  export declare function createSemanticImportSidecar(importResult: NativeSourceImportResult | NativeProjectImportResult, options?: SemanticImportSidecarOptions): SemanticImportSidecar;
2217
2354
  export declare function createNativeImportResultContract(importResult: NativeSourceImportResult | NativeProjectImportResult, options?: NativeImportResultContractOptions): NativeImportResultContract;
package/dist/index.js CHANGED
@@ -2488,6 +2488,62 @@ export function createProjectionTargetLossMatrix(input = {}) {
2488
2488
  };
2489
2489
  }
2490
2490
 
2491
+ export function createUniversalCapabilityMatrix(input = {}) {
2492
+ const generatedAt = input.generatedAt ?? Date.now();
2493
+ const imports = input.imports ?? [];
2494
+ const adapters = input.adapters ?? [];
2495
+ const targetAdapters = input.targetAdapters ?? [];
2496
+ const languages = input.languages ?? NativeImportLanguageProfiles;
2497
+ const targets = input.targets ?? FrontierCompileTargets;
2498
+ const importCoverage = createNativeImportCoverageMatrix({ languages, imports, adapters, generatedAt });
2499
+ const parserFormats = createNativeParserAstFormatMatrix({
2500
+ formats: input.formats,
2501
+ imports,
2502
+ adapters,
2503
+ generatedAt
2504
+ });
2505
+ const parserFeatures = createNativeParserFeatureMatrix({
2506
+ languages,
2507
+ imports,
2508
+ adapters,
2509
+ requiredFeatures: input.requiredFeatures,
2510
+ minimumReadiness: input.minimumReadiness,
2511
+ includeEmptyParsers: input.includeEmptyParsers,
2512
+ generatedAt
2513
+ });
2514
+ const projectionTargets = createProjectionTargetLossMatrix({
2515
+ languages,
2516
+ imports,
2517
+ adapters,
2518
+ targetAdapters,
2519
+ targets,
2520
+ generatedAt
2521
+ });
2522
+ const rows = importCoverage.languages.map((entry) => universalCapabilityLanguageRow(entry, {
2523
+ parserFeatures,
2524
+ projectionTargets
2525
+ }));
2526
+ return {
2527
+ kind: 'frontier.lang.universalCapabilityMatrix',
2528
+ version: 1,
2529
+ generatedAt,
2530
+ languages: rows,
2531
+ summary: universalCapabilityMatrixSummary(rows),
2532
+ matrices: {
2533
+ importCoverage,
2534
+ parserFormats,
2535
+ parserFeatures,
2536
+ projectionTargets
2537
+ },
2538
+ metadata: {
2539
+ requiredFeatures: parserFeatures.metadata.requiredFeatures,
2540
+ minimumReadiness: parserFeatures.metadata.minimumReadiness,
2541
+ compileTargets: projectionTargets.metadata.compileTargets,
2542
+ note: 'Universal capability coverage composes import, parser, source-preservation, and projection evidence. It identifies gaps; it is not a proof that every language feature is losslessly portable.'
2543
+ }
2544
+ };
2545
+ }
2546
+
2491
2547
  export function createNativeSourcePreservation(options) {
2492
2548
  if (!options || typeof options.sourceText !== 'string') {
2493
2549
  throw new Error('createNativeSourcePreservation requires sourceText');
@@ -2567,6 +2623,7 @@ export function createSemanticImportSidecar(importResult, options = {}) {
2567
2623
  const sourcePreservation = summarizeKernelSourcePreservation(importResult, imports);
2568
2624
  const universalAstLayers = summarizeSemanticImportSidecarUniversalAstLayers(importEntries);
2569
2625
  const proofSpec = summarizeSemanticImportSidecarProofSpec(importEntries);
2626
+ const paradigmSemantics = summarizeSemanticImportSidecarParadigmSemantics(importEntries);
2570
2627
  const readiness = mergeCandidates.reduce(
2571
2628
  (current, candidate) => maxSemanticMergeReadiness(current, candidate.readiness),
2572
2629
  lossSummary.semanticMergeReadiness
@@ -2590,6 +2647,7 @@ export function createSemanticImportSidecar(importResult, options = {}) {
2590
2647
  sourcePreservation,
2591
2648
  universalAstLayers,
2592
2649
  proofSpec,
2650
+ paradigmSemantics,
2593
2651
  patchHints,
2594
2652
  mergeCandidates: mergeCandidates.map((candidate) => ({
2595
2653
  id: candidate.id,
@@ -2624,6 +2682,9 @@ export function createSemanticImportSidecar(importResult, options = {}) {
2624
2682
  proofSpecRecords: proofSpec.total,
2625
2683
  proofSpecObligations: proofSpec.obligations,
2626
2684
  proofSpecFailedObligations: proofSpec.failed,
2685
+ paradigmSemanticsRecords: paradigmSemantics.total,
2686
+ paradigmSemanticsGroups: paradigmSemantics.groups.length,
2687
+ paradigmSemanticsLoweringRecords: paradigmSemantics.loweringRecords,
2627
2688
  readiness,
2628
2689
  emptySemanticIndex: symbols.length === 0
2629
2690
  },
@@ -7186,6 +7247,211 @@ function projectionTargetLossMatrixSummary(languages) {
7186
7247
  };
7187
7248
  }
7188
7249
 
7250
+ function universalCapabilityLanguageRow(importCoverage, context) {
7251
+ const languageIds = universalLanguageIds(importCoverage);
7252
+ const parserRows = (context.parserFeatures.parsers ?? []).filter((row) => universalLanguageIds(row).some((id) => languageIds.includes(id)));
7253
+ const parserLanguage = (context.parserFeatures.languages ?? []).find((row) => universalLanguageIds(row).some((id) => languageIds.includes(id)));
7254
+ const projection = (context.projectionTargets.languages ?? []).find((row) => universalLanguageIds(row).some((id) => languageIds.includes(id)));
7255
+ const parserReadiness = parserRows.length
7256
+ ? parserRows.reduce((current, row) => maxSemanticMergeReadiness(current, row.merge?.readiness ?? row.imports?.readiness ?? 'blocked'), 'ready')
7257
+ : 'blocked';
7258
+ const sourceProjectionReadiness = [projection?.sourceProjection?.exactSource, projection?.sourceProjection?.stubs]
7259
+ .filter(Boolean)
7260
+ .reduce((current, entry) => maxSemanticMergeReadiness(current, entry.readiness ?? 'blocked'), 'ready');
7261
+ const targetReadiness = (projection?.targets ?? []).length
7262
+ ? projection.targets.reduce((current, entry) => maxSemanticMergeReadiness(current, entry.readiness ?? 'blocked'), 'ready')
7263
+ : 'blocked';
7264
+ const projectionReadiness = maxSemanticMergeReadiness(sourceProjectionReadiness, targetReadiness);
7265
+ const readiness = maxSemanticMergeReadiness(importCoverage.imports.readiness, maxSemanticMergeReadiness(parserReadiness, projectionReadiness));
7266
+ const parserBlockingFeatures = uniqueStrings(parserRows.flatMap((row) => row.merge?.blockingFeatures ?? []));
7267
+ const parserReviewFeatures = uniqueStrings(parserRows.flatMap((row) => row.merge?.reviewFeatures ?? []));
7268
+ const missingTargets = (projection?.targets ?? []).filter((entry) => entry.lossClass === 'missingAdapter').map((entry) => entry.target);
7269
+ const unsupportedTargets = (projection?.targets ?? []).filter((entry) => entry.lossClass === 'unsupportedTargetFeatures').map((entry) => entry.target);
7270
+ const blockers = universalCapabilityBlockers({
7271
+ importCoverage,
7272
+ parserRows,
7273
+ parserReadiness,
7274
+ parserBlockingFeatures,
7275
+ projection,
7276
+ missingTargets,
7277
+ readiness
7278
+ });
7279
+ const review = universalCapabilityReviewReasons({
7280
+ importCoverage,
7281
+ parserRows,
7282
+ parserReviewFeatures,
7283
+ unsupportedTargets,
7284
+ readiness
7285
+ });
7286
+ return {
7287
+ language: importCoverage.language,
7288
+ aliases: importCoverage.aliases,
7289
+ extensions: importCoverage.extensions,
7290
+ readiness,
7291
+ imports: {
7292
+ total: importCoverage.imports.total,
7293
+ readiness: importCoverage.imports.readiness,
7294
+ symbols: importCoverage.imports.symbols,
7295
+ sourceMaps: importCoverage.imports.sourceMaps,
7296
+ sourceMapMappings: importCoverage.imports.sourceMapMappings,
7297
+ losses: importCoverage.imports.losses,
7298
+ lossKinds: importCoverage.imports.lossKinds,
7299
+ readinessReasons: importCoverage.imports.readinessReasons
7300
+ },
7301
+ parser: {
7302
+ readiness: parserReadiness,
7303
+ rows: parserRows.length,
7304
+ parsers: parserRows.map((row) => row.parser),
7305
+ mergeReadyParsers: parserRows.filter((row) => row.merge?.mergeReady).map((row) => row.parser),
7306
+ blockingFeatures: parserBlockingFeatures,
7307
+ reviewFeatures: parserReviewFeatures,
7308
+ languageSummary: parserLanguage
7309
+ },
7310
+ projection: {
7311
+ readiness: projectionReadiness,
7312
+ sourceProjection: projection?.sourceProjection,
7313
+ targets: projection?.targets ?? [],
7314
+ summary: projection?.summary ?? {
7315
+ imports: 0,
7316
+ parserAdapters: 0,
7317
+ targetEntries: 0,
7318
+ byLossClass: {},
7319
+ exactSourceImports: 0,
7320
+ stubDeclarationImports: 0
7321
+ },
7322
+ missingTargets,
7323
+ unsupportedTargets
7324
+ },
7325
+ evidence: {
7326
+ parserAdapters: importCoverage.parserAdapters.length,
7327
+ adapterCoverageSummaries: importCoverage.adapterCoverage.total,
7328
+ adapterCoverageGaps: importCoverage.adapterCoverage.gaps,
7329
+ knownLossKinds: importCoverage.knownLossKinds,
7330
+ sourceMapMappings: importCoverage.imports.sourceMapMappings
7331
+ },
7332
+ blockers,
7333
+ review
7334
+ };
7335
+ }
7336
+
7337
+ function universalCapabilityBlockers(input) {
7338
+ const blockers = [];
7339
+ if ((input.importCoverage.imports.total ?? 0) === 0) {
7340
+ blockers.push('No native import evidence observed for this language.');
7341
+ }
7342
+ if (!input.parserRows.length) {
7343
+ blockers.push('No parser feature row matched this language.');
7344
+ }
7345
+ if (input.parserReadiness === 'blocked') {
7346
+ blockers.push('Parser feature readiness is blocked.');
7347
+ }
7348
+ for (const feature of input.parserBlockingFeatures) {
7349
+ blockers.push(`Required parser feature is not merge-ready: ${feature}.`);
7350
+ }
7351
+ if (!input.projection) {
7352
+ blockers.push('No projection coverage row matched this language.');
7353
+ }
7354
+ for (const target of input.missingTargets) {
7355
+ blockers.push(`Missing native-to-target projection adapter for ${target}.`);
7356
+ }
7357
+ if (input.readiness === 'blocked' && blockers.length === 0) {
7358
+ blockers.push('Combined universal capability readiness is blocked.');
7359
+ }
7360
+ return uniqueStrings(blockers);
7361
+ }
7362
+
7363
+ function universalCapabilityReviewReasons(input) {
7364
+ const review = [];
7365
+ if ((input.importCoverage.imports.losses ?? 0) > 0) {
7366
+ review.push(`Native import evidence carries ${input.importCoverage.imports.losses} loss record(s).`);
7367
+ }
7368
+ for (const reason of input.importCoverage.imports.readinessReasons ?? []) {
7369
+ review.push(reason);
7370
+ }
7371
+ for (const feature of input.parserReviewFeatures) {
7372
+ review.push(`Parser feature needs review: ${feature}.`);
7373
+ }
7374
+ for (const target of input.unsupportedTargets) {
7375
+ review.push(`Target projection has unsupported feature losses for ${target}.`);
7376
+ }
7377
+ if (input.readiness === 'needs-review') {
7378
+ review.push('Combined universal capability readiness requires review.');
7379
+ } else if (input.readiness === 'ready-with-losses') {
7380
+ review.push('Combined universal capability readiness is ready with disclosed losses.');
7381
+ }
7382
+ return uniqueStrings(review);
7383
+ }
7384
+
7385
+ function universalCapabilityMatrixSummary(rows) {
7386
+ const byReadiness = {};
7387
+ const byImportReadiness = {};
7388
+ const byParserReadiness = {};
7389
+ const byProjectionReadiness = {};
7390
+ let imports = 0;
7391
+ let symbols = 0;
7392
+ let sourceMapMappings = 0;
7393
+ let losses = 0;
7394
+ let parserRows = 0;
7395
+ let parserMergeReady = 0;
7396
+ let targetEntries = 0;
7397
+ let missingAdapters = 0;
7398
+ let unsupportedTargetFeatures = 0;
7399
+ let exactSourceProjection = 0;
7400
+ let nativeSourceStubs = 0;
7401
+ let blockers = 0;
7402
+ let reviewReasons = 0;
7403
+ for (const row of rows) {
7404
+ byReadiness[row.readiness] = (byReadiness[row.readiness] ?? 0) + 1;
7405
+ byImportReadiness[row.imports.readiness] = (byImportReadiness[row.imports.readiness] ?? 0) + 1;
7406
+ byParserReadiness[row.parser.readiness] = (byParserReadiness[row.parser.readiness] ?? 0) + 1;
7407
+ byProjectionReadiness[row.projection.readiness] = (byProjectionReadiness[row.projection.readiness] ?? 0) + 1;
7408
+ imports += row.imports.total;
7409
+ symbols += row.imports.symbols;
7410
+ sourceMapMappings += row.imports.sourceMapMappings;
7411
+ losses += row.imports.losses;
7412
+ parserRows += row.parser.rows;
7413
+ parserMergeReady += row.parser.mergeReadyParsers.length;
7414
+ targetEntries += row.projection.targets.length;
7415
+ missingAdapters += row.projection.missingTargets.length;
7416
+ unsupportedTargetFeatures += row.projection.unsupportedTargets.length;
7417
+ exactSourceProjection += row.projection.summary.byLossClass?.exactSourceProjection ?? 0;
7418
+ nativeSourceStubs += row.projection.summary.byLossClass?.nativeSourceStubs ?? 0;
7419
+ blockers += row.blockers.length;
7420
+ reviewReasons += row.review.length;
7421
+ }
7422
+ return {
7423
+ languages: rows.length,
7424
+ imports,
7425
+ symbols,
7426
+ sourceMapMappings,
7427
+ losses,
7428
+ parserRows,
7429
+ parserMergeReady,
7430
+ targetEntries,
7431
+ missingAdapters,
7432
+ unsupportedTargetFeatures,
7433
+ exactSourceProjection,
7434
+ nativeSourceStubs,
7435
+ blockers,
7436
+ reviewReasons,
7437
+ readyLanguages: rows.filter((row) => row.readiness === 'ready').length,
7438
+ readyWithLossesLanguages: rows.filter((row) => row.readiness === 'ready-with-losses').length,
7439
+ reviewLanguages: rows.filter((row) => row.readiness === 'needs-review').length,
7440
+ blockedLanguages: rows.filter((row) => row.readiness === 'blocked').length,
7441
+ byReadiness,
7442
+ byImportReadiness,
7443
+ byParserReadiness,
7444
+ byProjectionReadiness
7445
+ };
7446
+ }
7447
+
7448
+ function universalLanguageIds(entry) {
7449
+ return uniqueStrings([
7450
+ entry?.language,
7451
+ ...(entry?.aliases ?? [])
7452
+ ].map(normalizeNativeLanguageId).filter(Boolean));
7453
+ }
7454
+
7189
7455
  function countProjectionLossClasses(entries) {
7190
7456
  const counts = {};
7191
7457
  for (const entry of entries ?? []) {
@@ -8588,6 +8854,7 @@ function semanticImportSidecarEntry(imported, index, options) {
8588
8854
  const sourcePreservationRecords = collectKernelSourcePreservationFromImport(imported);
8589
8855
  const universalAstLayers = summarizeUniversalAstLayers(imported?.universalAst);
8590
8856
  const proofSpec = summarizeProofSpecLayer(imported?.universalAst?.proof ?? imported?.proof);
8857
+ const paradigmSemantics = summarizeParadigmSemanticsLayer(imported?.universalAst?.paradigmSemantics ?? imported?.paradigmSemantics);
8591
8858
  const mappingsBySymbolId = new Map();
8592
8859
  for (const mapping of sourceMapMappings) {
8593
8860
  if (mapping.semanticSymbolId && !mappingsBySymbolId.has(mapping.semanticSymbolId)) {
@@ -8638,6 +8905,7 @@ function semanticImportSidecarEntry(imported, index, options) {
8638
8905
  universalAstLayerNames: universalAstLayers.names,
8639
8906
  universalAstLayerIds: universalAstLayers.ids,
8640
8907
  proofSpec,
8908
+ paradigmSemantics,
8641
8909
  readiness: imported?.metadata?.semanticMergeReadiness ?? imported?.mergeCandidates?.[0]?.readiness ?? 'needs-review',
8642
8910
  emptySemanticIndex: symbols.length === 0,
8643
8911
  regionTaxonomy,
@@ -8701,6 +8969,120 @@ function summarizeSemanticImportSidecarProofSpec(importEntries) {
8701
8969
  };
8702
8970
  }
8703
8971
 
8972
+ const ParadigmSemanticSummaryGroups = Object.freeze([
8973
+ 'bindingScopes',
8974
+ 'bindings',
8975
+ 'patterns',
8976
+ 'typeConstraints',
8977
+ 'evaluationModels',
8978
+ 'memoryLocations',
8979
+ 'effectRegions',
8980
+ 'controlRegions',
8981
+ 'logicPrograms',
8982
+ 'actorSystems',
8983
+ 'stackEffects',
8984
+ 'arrayShapes',
8985
+ 'numericKernels',
8986
+ 'dataflowNetworks',
8987
+ 'clockModels',
8988
+ 'objectModels',
8989
+ 'macroExpansions',
8990
+ 'reflectionBoundaries',
8991
+ 'loweringRecords'
8992
+ ]);
8993
+
8994
+ function summarizeSemanticImportSidecarParadigmSemantics(importEntries) {
8995
+ const totals = emptyParadigmSemanticsSummary();
8996
+ const ids = [];
8997
+ const kinds = [];
8998
+ const byGroup = {};
8999
+ const byKind = {};
9000
+ for (const entry of importEntries) {
9001
+ const summary = entry.paradigmSemantics ?? summarizeParadigmSemanticsLayer();
9002
+ ids.push(...(summary.ids ?? []));
9003
+ kinds.push(...(summary.kinds ?? []));
9004
+ totals.total += summary.total ?? 0;
9005
+ totals.evidence += summary.evidence ?? 0;
9006
+ for (const group of ParadigmSemanticSummaryGroups) {
9007
+ totals[group] += summary[group] ?? 0;
9008
+ }
9009
+ for (const [group, count] of Object.entries(summary.byGroup ?? {})) {
9010
+ byGroup[group] = (byGroup[group] ?? 0) + count;
9011
+ }
9012
+ for (const [kind, count] of Object.entries(summary.byKind ?? {})) {
9013
+ byKind[kind] = (byKind[kind] ?? 0) + count;
9014
+ }
9015
+ }
9016
+ return {
9017
+ ...totals,
9018
+ ids: uniqueStrings(ids),
9019
+ groups: uniqueStrings(Object.keys(byGroup).filter((group) => byGroup[group] > 0)),
9020
+ kinds: uniqueStrings(kinds),
9021
+ byGroup,
9022
+ byKind,
9023
+ hasRuntimeSemantics: hasAnyParadigmCount(totals, ['evaluationModels', 'memoryLocations', 'effectRegions', 'controlRegions', 'actorSystems', 'clockModels']),
9024
+ hasLogicSemantics: totals.logicPrograms > 0,
9025
+ hasStackSemantics: totals.stackEffects > 0,
9026
+ hasArraySemantics: totals.arrayShapes > 0 || totals.numericKernels > 0,
9027
+ hasMacroOrReflection: totals.macroExpansions > 0 || totals.reflectionBoundaries > 0,
9028
+ hasLowering: totals.loweringRecords > 0,
9029
+ empty: totals.total === 0
9030
+ };
9031
+ }
9032
+
9033
+ function summarizeParadigmSemanticsLayer(paradigmSemantics = {}) {
9034
+ const totals = emptyParadigmSemanticsSummary();
9035
+ const ids = [];
9036
+ const kinds = [];
9037
+ const byGroup = {};
9038
+ const byKind = {};
9039
+ ids.push(paradigmSemantics?.id);
9040
+ for (const group of ParadigmSemanticSummaryGroups) {
9041
+ const records = paradigmSemantics?.[group] ?? [];
9042
+ totals[group] = records.length;
9043
+ totals.total += records.length;
9044
+ if (records.length > 0) {
9045
+ byGroup[group] = records.length;
9046
+ }
9047
+ for (const record of records) {
9048
+ ids.push(record?.id);
9049
+ if (record?.kind) {
9050
+ kinds.push(record.kind);
9051
+ byKind[record.kind] = (byKind[record.kind] ?? 0) + 1;
9052
+ }
9053
+ }
9054
+ }
9055
+ totals.evidence = (paradigmSemantics?.evidence ?? []).length;
9056
+ ids.push(...(paradigmSemantics?.evidence ?? []).map((record) => record?.id));
9057
+ return {
9058
+ ...totals,
9059
+ ids: uniqueStrings(ids.filter(Boolean)),
9060
+ groups: uniqueStrings(Object.keys(byGroup)),
9061
+ kinds: uniqueStrings(kinds),
9062
+ byGroup,
9063
+ byKind,
9064
+ hasRuntimeSemantics: hasAnyParadigmCount(totals, ['evaluationModels', 'memoryLocations', 'effectRegions', 'controlRegions', 'actorSystems', 'clockModels']),
9065
+ hasLogicSemantics: totals.logicPrograms > 0,
9066
+ hasStackSemantics: totals.stackEffects > 0,
9067
+ hasArraySemantics: totals.arrayShapes > 0 || totals.numericKernels > 0,
9068
+ hasMacroOrReflection: totals.macroExpansions > 0 || totals.reflectionBoundaries > 0,
9069
+ hasLowering: totals.loweringRecords > 0,
9070
+ empty: totals.total === 0
9071
+ };
9072
+ }
9073
+
9074
+ function emptyParadigmSemanticsSummary() {
9075
+ return {
9076
+ total: 0,
9077
+ evidence: 0,
9078
+ ...Object.fromEntries(ParadigmSemanticSummaryGroups.map((group) => [group, 0]))
9079
+ };
9080
+ }
9081
+
9082
+ function hasAnyParadigmCount(summary, groups) {
9083
+ return groups.some((group) => (summary[group] ?? 0) > 0);
9084
+ }
9085
+
8704
9086
  function summarizeProofSpecLayer(proof = {}) {
8705
9087
  const contracts = proof?.contracts ?? [];
8706
9088
  const refinements = proof?.refinements ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.37",
3
+ "version": "0.2.39",
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.7",
62
+ "@shapeshift-labs/frontier-lang-kernel": "0.3.8",
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",