@shapeshift-labs/frontier-lang-compiler 0.2.65 → 0.2.67

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.
Files changed (67) hide show
  1. package/README.md +37 -8
  2. package/bench/smoke.mjs +15 -1
  3. package/bench/universal-fixture-suite.mjs +183 -0
  4. package/dist/declarations/import-adapter-core.d.ts +3 -0
  5. package/dist/declarations/native-project-admission.d.ts +133 -0
  6. package/dist/declarations/roundtrip-audit.d.ts +177 -0
  7. package/dist/declarations/roundtrip.d.ts +2 -53
  8. package/dist/declarations/semantic-history-records.d.ts +277 -0
  9. package/dist/declarations/semantic-history.d.ts +45 -92
  10. package/dist/declarations/semantic-merge-candidates.d.ts +200 -0
  11. package/dist/declarations/semantic-merge-conflicts.d.ts +12 -0
  12. package/dist/declarations/semantic-sidecar.d.ts +8 -3
  13. package/dist/declarations/semantic-slice-admission.d.ts +111 -0
  14. package/dist/declarations/semantic-slice.d.ts +36 -1
  15. package/dist/declarations/universal-conversion-plan.d.ts +59 -0
  16. package/dist/declarations/universal-runtime-capabilities.d.ts +171 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.js +2 -0
  19. package/dist/internal/index-impl/attachExternalOwnership.js +18 -10
  20. package/dist/internal/index-impl/createNativeRoundtripEvidence.js +54 -49
  21. package/dist/internal/index-impl/createSemanticImportSidecar.js +6 -0
  22. package/dist/internal/index-impl/createSemanticSlice.js +4 -3
  23. package/dist/internal/index-impl/createSemanticSliceAdmissionRecord.js +10 -1
  24. package/dist/internal/index-impl/diffNativeSourceImports.js +3 -2
  25. package/dist/internal/index-impl/expandSemanticSliceSelection.js +0 -1
  26. package/dist/internal/index-impl/externalSemanticBase.js +1 -0
  27. package/dist/internal/index-impl/importExternalSemanticIndex.js +4 -0
  28. package/dist/internal/index-impl/nativeRoundtripAudit.js +217 -0
  29. package/dist/internal/index-impl/projectImportAdmissionImportEvidence.js +160 -0
  30. package/dist/internal/index-impl/projectImportAdmissionLanguageSummaries.js +247 -0
  31. package/dist/internal/index-impl/projectImportAdmissionRanks.js +52 -0
  32. package/dist/internal/index-impl/projectImportAdmissionSummaries.js +77 -117
  33. package/dist/internal/index-impl/projectImportAdmissionTasks.js +239 -0
  34. package/dist/internal/index-impl/semanticHistoryRecordNormalizers.js +151 -0
  35. package/dist/internal/index-impl/semanticHistoryRecordOverlaps.js +113 -0
  36. package/dist/internal/index-impl/semanticHistoryRecords.js +210 -149
  37. package/dist/internal/index-impl/semanticMergeCandidateRecordInternals.js +314 -0
  38. package/dist/internal/index-impl/semanticMergeCandidateRecords.js +241 -0
  39. package/dist/internal/index-impl/semanticSliceAdmissionSurface.js +142 -0
  40. package/dist/internal/index-impl/semanticSliceExpectationAssertions.js +100 -0
  41. package/dist/internal/index-impl/semanticSliceExpectationRecords.js +75 -0
  42. package/dist/internal/index-impl/semanticSliceExpectedAssertions.js +5 -2
  43. package/dist/internal/index-impl/testSemanticSlice.js +4 -1
  44. package/dist/internal/index-impl/withExternalEmptyLoss.js +1 -0
  45. package/dist/language-adapter-package-contracts.js +12 -57
  46. package/dist/language-adapter-package-rows.js +116 -0
  47. package/dist/lightweight-dependency-language.js +8 -0
  48. package/dist/native-region-scanner-core.js +42 -10
  49. package/dist/native-region-scanner-js-helpers.js +2 -0
  50. package/dist/native-region-scanner-js-imports.js +111 -0
  51. package/dist/native-region-scanner-js.js +111 -28
  52. package/dist/universal-conversion-plan-summary.js +42 -0
  53. package/dist/universal-conversion-plan.js +46 -40
  54. package/dist/universal-runtime-capabilities.js +92 -0
  55. package/dist/universal-runtime-host-selectors.js +192 -0
  56. package/dist/universal-runtime-profiles.js +109 -0
  57. package/dist/universal-runtime-route-records.js +162 -0
  58. package/examples/js-frontier-rust-workbench-adapters.mjs +89 -0
  59. package/examples/js-frontier-rust-workbench-bounds.mjs +4 -3
  60. package/examples/js-frontier-rust-workbench-client.mjs +135 -59
  61. package/examples/js-frontier-rust-workbench-convert.mjs +161 -0
  62. package/examples/js-frontier-rust-workbench-html.mjs +20 -13
  63. package/examples/js-frontier-rust-workbench-route-styles.mjs +126 -0
  64. package/examples/js-frontier-rust-workbench-route.mjs +190 -0
  65. package/examples/js-frontier-rust-workbench-styles.mjs +12 -54
  66. package/examples/js-frontier-rust-workbench.mjs +54 -214
  67. package/package.json +1 -1
package/README.md CHANGED
@@ -36,17 +36,19 @@ npm run build
36
36
  node examples/native-js-to-rust-demo.mjs
37
37
  ```
38
38
 
39
- Run the interactive Frontier-style workbench with editable TypeScript and Rust panes:
39
+ Run the interactive Frontier-style workbench with a submitted TypeScript source pane,
40
+ Frontier graph/JSON pane, and independent Rust/Python projection panes:
40
41
 
41
42
  ```sh
42
43
  npm run demo:ts-rust -- --port 4177
43
44
  ```
44
45
 
45
46
  The workbench converts only when `Run` is pressed. TypeScript edits project through
46
- the Frontier semantic graph into Rust scaffolding; Rust edits project back through
47
- the graph into TypeScript scaffolding. The middle pane shows symbols, relations,
48
- source maps, readiness, losses, patch hints, and the explicit supported/review-only/
49
- unsupported bounds for the current direction.
47
+ the Frontier semantic graph into Rust and Python scaffolding. The middle pane shows
48
+ symbols, relations, source maps, readiness, losses, patch hints, and the explicit
49
+ supported/review-only/unsupported bounds for the projection. Run
50
+ `npm run demo:ts-rust:smoke` to verify the conversion output and layout scaffold
51
+ without starting the server.
50
52
 
51
53
  The demo prints JavaScript source, the Frontier universal AST/semantic-index summary,
52
54
  Rust declaration stubs, a host-adapter Rust projection, and a direct Frontier-source
@@ -117,11 +119,12 @@ const importedIndex = importExternalSemanticIndex({
117
119
  });
118
120
 
119
121
  console.log(importedIndex.semanticIndex.symbols.length);
122
+ console.log(importedIndex.ownershipRegions[0]?.key);
120
123
  console.log(importedIndex.summary.sourceMapMappings);
121
124
  console.log(importedIndex.readiness.readiness); // "ready-with-losses" or review-required
122
125
  ```
123
126
 
124
- External semantic-index imports create Frontier `SemanticIndexRecord`, `SourceMapRecord`, evidence, losses, ownership facts, and a universal AST envelope. They are a bridge from existing language servers/indexers into semantic merge tooling; they do not claim full parser AST coverage, macro expansion, type checking, comments/trivia preservation, or lossless cross-language code generation by themselves.
127
+ External semantic-index imports create Frontier `SemanticIndexRecord`, `SourceMapRecord`, evidence, losses, ownership facts, first-class `ownershipRegions`, and a universal AST envelope. They are a bridge from existing language servers/indexers into semantic merge tooling; they do not claim full parser AST coverage, macro expansion, type checking, comments/trivia preservation, or lossless cross-language code generation by themselves.
125
128
 
126
129
  Native imports include source maps, semantic merge candidates, and a loss summary for admission queues and dashboards. Informational losses produce `ready-with-losses`, warning losses produce `needs-review`, and error losses or failed import evidence produce `blocked`:
127
130
 
@@ -137,6 +140,28 @@ console.log(readiness.readiness);
137
140
 
138
141
  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.
139
142
 
143
+ Semantic merge candidates also expose compiler-normalized admission records for coordinator queues:
144
+
145
+ ```js
146
+ import {
147
+ createSemanticMergeCandidateAdmissionRecord,
148
+ querySemanticMergeCandidateAdmissionOverlaps,
149
+ sortSemanticMergeCandidateAdmissionRecords
150
+ } from '@shapeshift-labs/frontier-lang-compiler';
151
+
152
+ const record = createSemanticMergeCandidateAdmissionRecord(changeSet);
153
+
154
+ console.log(record.changedSemanticRegions);
155
+ console.log(record.sourceHashes.baseHash, record.sourceHashes.targetHash);
156
+ console.log(record.conflictKeys, record.evidenceIds);
157
+ console.log(record.projectionRisk, record.readiness, record.readinessSortKey);
158
+
159
+ const queue = sortSemanticMergeCandidateAdmissionRecords([record, otherRecord]);
160
+ const overlaps = querySemanticMergeCandidateAdmissionOverlaps(queue);
161
+ ```
162
+
163
+ These candidate records are compact merge-admission evidence. They preserve changed semantic regions, source/base/target hashes, conflict keys, evidence IDs, projection risk, readiness, and overlap pairs so swarm coordinators can sort likely-ready candidates first and detect conflicting regions before patch review.
164
+
140
165
  High-risk native features also have explicit evidence policies. These policies are advisory in this package: they tell a swarm or admission queue what evidence is missing without silently changing the existing readiness classification.
141
166
 
142
167
  ```js
@@ -414,6 +439,8 @@ const imported = importNativeSource({
414
439
  const slice = createSemanticSlice(imported, {
415
440
  entryRefs: ['symbol:parseExpression'],
416
441
  includeDependencies: true,
442
+ expectedSymbols: ['parseExpression'],
443
+ expectedSourceHashes: { 'src/parser.ts': imported.nativeSource.sourceHash },
417
444
  focusedCommands: ['npm test -- parser-expression'],
418
445
  fixtureHints: ['operator precedence corpus']
419
446
  });
@@ -423,17 +450,19 @@ console.log(slice.mergeAdmission.conflictKeys); // semantic ownership keys
423
450
  console.log(slice.sourceFiles[0].sourceHash); // stale-check input for admission
424
451
 
425
452
  const gate = testSemanticSlice(slice, {
426
- currentSources: { 'src/parser.ts': sourceText }
453
+ currentSources: { 'src/parser.ts': sourceText },
454
+ expectedRegions: [slice.ownershipRegions[0].key]
427
455
  });
428
456
 
429
457
  console.log(gate.status); // "passed", "needs-review", or "failed"
430
458
  const admission = createSemanticSliceAdmissionRecord(slice, { testResult: gate });
431
459
  console.log(admission.mergeScore.value); // sortable 0-100 semantic merge score
460
+ console.log(admission.selectedSurface.sourceHashes); // compact selected-surface evidence
432
461
  console.log(admission.autoMergeClaim); // always false
433
462
  console.log(writeSemanticSliceJson(slice)); // stable JSON for worker inputs
434
463
  ```
435
464
 
436
- A semantic slice is the small unit a swarm can hand to a worker instead of copying a full repository. It carries the selected symbols, ownership regions, native nodes, relations, occurrences, source-map links, source spans, source excerpts, source hashes, focused verification commands, fixture hints, and merge-admission metadata. It does not claim the patch is correct; it makes the context and conflicts machine-readable so admission scoring can combine changed ownership, focused test status, stale/source-hash checks, evidence, and semantic risk in one sortable record.
465
+ A semantic slice is the small unit a swarm can hand to a worker instead of copying a full repository. It carries the selected symbols, ownership regions, native nodes, relations, occurrences, source-map links, source spans, source excerpts, source hashes, focused verification commands, fixture hints, and merge-admission metadata. Slice tests can assert exact selected symbols, regions, source-file hashes, and expected counts; admission records also include a compact `selectedSurface` plus `semantic-slice-selected-surface` evidence with hashes and spans but no whole-repository source copy. It does not claim the patch is correct; it makes the context and conflicts machine-readable so admission scoring can combine changed ownership, focused test status, stale/source-hash checks, evidence, and semantic risk in one sortable record.
437
466
 
438
467
  Slice admission records add a compact `frontier.lang.semanticMergeScore.v1` score with semantic-selection, source-freshness, ownership-isolation, verification-evidence, and review-risk components. They are built for coordinator queues and dashboards: sort likely useful slices first, reject stale or empty slices early, and keep correctness proof separate from merge metadata.
439
468
 
package/bench/smoke.mjs CHANGED
@@ -3,12 +3,14 @@ import { collectNativeImports } from './native-import-suite.mjs';
3
3
  import { measureNativeMatrices } from './native-matrix-suite.mjs';
4
4
  import { measureNativeTransformations } from './native-transform-suite.mjs';
5
5
  import { measureSourceChangeSuites } from './source-change-suite.mjs';
6
+ import { measureUniversalFixtureSuite } from './universal-fixture-suite.mjs';
6
7
 
7
8
  const compileMetrics = measureFrontierCompile();
8
9
  const importMetrics = await collectNativeImports();
9
10
  const matrixMetrics = measureNativeMatrices(importMetrics.nativeImportResults, importMetrics.adapters);
10
11
  const transformMetrics = measureNativeTransformations(importMetrics.nativeImportResults);
11
12
  const sourceChangeMetrics = measureSourceChangeSuites();
13
+ const universalFixtureMetrics = measureUniversalFixtureSuite(importMetrics.adapters);
12
14
 
13
15
  console.log(JSON.stringify({
14
16
  compiles: 250,
@@ -107,5 +109,17 @@ console.log(JSON.stringify({
107
109
  externalSemanticImports: sourceChangeMetrics.externalSemanticImports,
108
110
  externalSemanticSymbols: sourceChangeMetrics.externalSemanticSymbols,
109
111
  externalSemanticMappings: sourceChangeMetrics.externalSemanticMappings,
110
- externalSemanticDurationMs: Number(sourceChangeMetrics.externalSemanticDurationMs.toFixed(2))
112
+ externalSemanticDurationMs: Number(sourceChangeMetrics.externalSemanticDurationMs.toFixed(2)),
113
+ universalFixtureImports: universalFixtureMetrics.imports,
114
+ universalFixtureLanguages: universalFixtureMetrics.languages,
115
+ universalFixtureRoutes: universalFixtureMetrics.routes,
116
+ universalFixtureTargetAdapterRoutes: universalFixtureMetrics.targetAdapterRoutes,
117
+ universalFixtureSemanticIndexOnlyRoutes: universalFixtureMetrics.semanticIndexOnlyRoutes,
118
+ universalFixtureRouteScoreMin: universalFixtureMetrics.routeScoreMin,
119
+ universalFixtureRouteScoreMax: universalFixtureMetrics.routeScoreMax,
120
+ universalFixtureLossSummaries: universalFixtureMetrics.lossSummaries,
121
+ universalFixtureLossCategories: universalFixtureMetrics.lossCategories,
122
+ universalFixtureCandidateRecords: universalFixtureMetrics.candidateRecords,
123
+ universalFixtureBestCandidateSortKey: universalFixtureMetrics.bestCandidateSortKey,
124
+ universalFixtureDurationMs: Number(universalFixtureMetrics.durationMs.toFixed(2))
111
125
  }));
@@ -0,0 +1,183 @@
1
+ import { performance } from 'node:perf_hooks';
2
+ import {
3
+ createSemanticMergeCandidateAdmissionRecord,
4
+ createUniversalCapabilityMatrix,
5
+ createUniversalConversionArtifacts,
6
+ createUniversalConversionPlan,
7
+ diffNativeSources,
8
+ importNativeSource,
9
+ sortSemanticMergeCandidateAdmissionRecords,
10
+ summarizeNativeImportLosses
11
+ } from '../dist/index.js';
12
+ import { createBenchMatrixAdapters } from './native-adapters.mjs';
13
+
14
+ const requiredFeatures = ['syntax', 'semantic', 'sourcePreservation'];
15
+ const targets = ['javascript', 'python', 'rust', 'c'];
16
+ const handledHighRiskLossKinds = [
17
+ 'conditionalCompilation',
18
+ 'dynamicDispatch',
19
+ 'dynamicRuntime',
20
+ 'generatedCode',
21
+ 'macroExpansion',
22
+ 'macroHygiene',
23
+ 'metaprogramming',
24
+ 'overloadResolution',
25
+ 'preprocessor',
26
+ 'reflection',
27
+ 'typeInference',
28
+ 'unsupportedSemantic',
29
+ 'unsupportedSyntax'
30
+ ];
31
+
32
+ export function measureUniversalFixtureSuite(adapters) {
33
+ const start = performance.now();
34
+ const imports = createImports();
35
+ const targetAdapters = createTargetAdapters();
36
+ const matrix = createUniversalCapabilityMatrix({
37
+ generatedAt: 1201,
38
+ imports,
39
+ adapters: createBenchMatrixAdapters(adapters),
40
+ targetAdapters,
41
+ targets,
42
+ requiredFeatures
43
+ });
44
+ const plan = createUniversalConversionPlan({
45
+ generatedAt: 1202,
46
+ imports,
47
+ adapters: createBenchMatrixAdapters(adapters),
48
+ targetAdapters,
49
+ targets,
50
+ requiredFeatures,
51
+ evidence: [{
52
+ id: 'bench_universal_fixture_replay',
53
+ kind: 'conversion-replay-proof',
54
+ status: 'passed'
55
+ }]
56
+ });
57
+ const artifacts = createUniversalConversionArtifacts(plan, { generatedAt: 1203 });
58
+ const lossSummaries = imports.map((imported) => summarizeNativeImportLosses(imported.losses, {
59
+ evidence: imported.evidence,
60
+ exactAst: imported.metadata?.nativeImportLossSummary?.exactAst
61
+ }));
62
+ const candidateRecords = sortSemanticMergeCandidateAdmissionRecords(createCandidateRecords());
63
+ const routeScores = plan.routes.map((route) => route.mergeScore.value);
64
+ return {
65
+ imports: imports.length,
66
+ languages: matrix.summary.languages,
67
+ routes: plan.routes.length,
68
+ targetAdapterRoutes: plan.summary.targetAdapterRoutes,
69
+ semanticIndexOnlyRoutes: plan.summary.semanticIndexOnlyRoutes,
70
+ routeScoreMin: Math.min(...routeScores),
71
+ routeScoreMax: Math.max(...routeScores),
72
+ lossSummaries: lossSummaries.length,
73
+ lossCategories: lossSummaries.reduce((sum, summary) => sum + summary.categories.length, 0),
74
+ candidateRecords: candidateRecords.length,
75
+ bestCandidateSortKey: candidateRecords[0]?.readinessSortKey ?? 0,
76
+ artifactAdmissionRecords: artifacts.summary.admissionRecords,
77
+ durationMs: performance.now() - start
78
+ };
79
+ }
80
+
81
+ function createImports() {
82
+ return [{
83
+ language: 'javascript',
84
+ sourcePath: 'src/bench-universal.js',
85
+ sourceText: 'export function benchUniversal(value) { return value + 1; }\n'
86
+ }, {
87
+ language: 'python',
88
+ sourcePath: 'bench_universal.py',
89
+ sourceText: 'def bench_universal(value):\n return value + 1\n'
90
+ }, {
91
+ language: 'rust',
92
+ sourcePath: 'src/bench_universal.rs',
93
+ sourceText: 'pub fn bench_universal(value: i32) -> i32 { value + 1 }\nmacro_rules! bench_universal_macro { () => {} }\n'
94
+ }, {
95
+ language: 'c',
96
+ sourcePath: 'bench_universal.h',
97
+ sourceText: '#define BENCH_UNIVERSAL 1\ntypedef struct BenchUniversal { int value; } BenchUniversal;\nint bench_universal(void);\n'
98
+ }, {
99
+ language: 'go',
100
+ sourcePath: 'bench_universal.go',
101
+ sourceText: 'package bench\nfunc BenchUniversal(value int) int { return value + 1 }\n'
102
+ }, {
103
+ language: 'swift',
104
+ sourcePath: 'BenchUniversal.swift',
105
+ sourceText: 'struct BenchUniversal { var value: Int }\nfunc benchUniversal(_ value: Int) -> Int { value + 1 }\n'
106
+ }, {
107
+ language: 'r',
108
+ sourcePath: 'bench_universal.R',
109
+ sourceText: 'bench_universal <- function(value) { value + 1 }\neval(parse(text = "generated <- TRUE"))\n'
110
+ }].map((fixture) => importNativeSource(fixture));
111
+ }
112
+
113
+ function createTargetAdapters() {
114
+ return [{
115
+ id: 'bench-js-to-rust-universal-fixture',
116
+ sourceLanguage: 'javascript',
117
+ target: 'rust',
118
+ coverage: { readiness: 'ready', handledLossKinds: handledHighRiskLossKinds },
119
+ project() {
120
+ return { output: 'pub fn bench_js_to_rust() {}\n', readiness: 'ready' };
121
+ }
122
+ }, {
123
+ id: 'bench-python-to-rust-universal-fixture',
124
+ sourceLanguage: 'python',
125
+ target: 'rust',
126
+ coverage: { readiness: 'ready', handledLossKinds: handledHighRiskLossKinds },
127
+ project() {
128
+ return { output: 'pub fn bench_python_to_rust() {}\n', readiness: 'ready' };
129
+ }
130
+ }, {
131
+ id: 'bench-c-to-rust-universal-fixture',
132
+ sourceLanguage: 'c',
133
+ target: 'rust',
134
+ coverage: { readiness: 'ready', handledLossKinds: handledHighRiskLossKinds },
135
+ project() {
136
+ return { output: 'pub fn bench_c_to_rust() {}\n', readiness: 'ready' };
137
+ }
138
+ }];
139
+ }
140
+
141
+ function createCandidateRecords() {
142
+ return [{
143
+ language: 'javascript',
144
+ sourcePath: 'src/bench-candidate.js',
145
+ beforeSourceText: 'export function benchCandidate(value) { return value + 1; }\n',
146
+ afterSourceText: 'export function benchCandidate(value) { return value + 2; }\n',
147
+ readiness: 'ready'
148
+ }, {
149
+ language: 'python',
150
+ sourcePath: 'bench_candidate.py',
151
+ beforeSourceText: 'def bench_candidate(value):\n return value + 1\n',
152
+ afterSourceText: 'def bench_candidate(value):\n return value + 2\n',
153
+ readiness: 'ready-with-losses'
154
+ }, {
155
+ language: 'rust',
156
+ sourcePath: 'src/bench_candidate.rs',
157
+ beforeSourceText: 'pub fn bench_candidate(value: i32) -> i32 { value + 1 }\n',
158
+ afterSourceText: 'pub fn bench_candidate(value: i32) -> i32 { value + 2 }\n',
159
+ readiness: 'needs-review'
160
+ }, {
161
+ language: 'c',
162
+ sourcePath: 'bench_candidate.c',
163
+ beforeSourceText: 'int bench_candidate(int value) { return value + 1; }\n',
164
+ afterSourceText: 'int bench_candidate(int value) { return value + 2; }\n',
165
+ readiness: 'blocked'
166
+ }].map((spec, index) => createSemanticMergeCandidateAdmissionRecord(diffNativeSources({
167
+ id: `bench_candidate_change_${index}`,
168
+ language: spec.language,
169
+ sourcePath: spec.sourcePath,
170
+ beforeSourceText: spec.beforeSourceText,
171
+ afterSourceText: spec.afterSourceText,
172
+ evidenceId: `bench_candidate_evidence_${index}`,
173
+ patchId: `bench_candidate_patch_${index}`,
174
+ mergeCandidateId: `bench_candidate_${index}`
175
+ }), {
176
+ readiness: spec.readiness,
177
+ evidence: [{
178
+ id: `bench_candidate_verification_${index}`,
179
+ kind: 'candidate-verification-proof',
180
+ status: 'passed'
181
+ }]
182
+ }));
183
+ }
@@ -154,6 +154,8 @@ export interface ExternalSemanticIndexImportSummary {
154
154
  readonly occurrences: number;
155
155
  readonly relations: number;
156
156
  readonly facts: number;
157
+ readonly ownershipRegions: number;
158
+ readonly ownershipRegionKinds: readonly string[];
157
159
  readonly sourceMapMappings: number;
158
160
  readonly losses: number;
159
161
  readonly readiness: SemanticMergeReadiness;
@@ -170,6 +172,7 @@ export interface ExternalSemanticIndexImportResult {
170
172
  readonly semanticIndex: SemanticIndexRecord;
171
173
  readonly universalAst: FrontierUniversalAstEnvelope;
172
174
  readonly sourceMaps: readonly SourceMapRecord[];
175
+ readonly ownershipRegions: readonly SemanticImportOwnershipRegion[];
173
176
  readonly losses: readonly NativeAstLossRecord[];
174
177
  readonly evidence: readonly EvidenceRecord[];
175
178
  readonly readiness: NativeImportReadinessClassification;
@@ -2,12 +2,114 @@ import type { FrontierSourceLanguage, SemanticMergeReadiness } from '@shapeshift
2
2
  import type { NativeImportLossSummary } from './native-import-losses.js';
3
3
  import type { NativeImportResultContract } from './native-import-contracts.js';
4
4
  import type { NativeProjectImportResult } from './native-project.js';
5
+ import type { SemanticMergeCandidateAdmissionRecord, SemanticMergeCandidateOverlapRecord, SemanticMergeCandidateProjectionRisk } from './semantic-merge-candidates.js';
5
6
 
6
7
  export type NativeProjectImportAdmissionAction = 'admit' | 'prioritize' | 'reject';
7
8
  export type NativeProjectImportAdmissionPriority = 'low' | 'normal' | 'high' | 'critical' | 'blocker';
8
9
  export type NativeProjectImportAdmissionRisk = 'low' | 'medium' | 'high' | 'unknown';
9
10
  export type NativeProjectSourcePreservationQuality = 'exact' | 'lossy' | 'missing' | 'stale' | 'empty';
10
11
 
12
+ export interface NativeProjectAdmissionParserEvidence {
13
+ readonly parser?: string;
14
+ readonly astFormat?: string;
15
+ readonly exactness?: string;
16
+ readonly semanticCoverageLevel?: string;
17
+ readonly exactAst: boolean;
18
+ readonly tokens: boolean;
19
+ readonly trivia: boolean;
20
+ readonly diagnostics: boolean;
21
+ readonly diagnosticCount: number;
22
+ readonly sourceRanges: boolean;
23
+ readonly generatedRanges: boolean;
24
+ readonly evidenceRecords: number;
25
+ readonly missing: boolean;
26
+ }
27
+
28
+ export interface NativeProjectAdmissionParserEvidenceSummary {
29
+ readonly parsers: readonly string[];
30
+ readonly byParser: Readonly<Record<string, number>>;
31
+ readonly byExactness: Readonly<Record<string, number>>;
32
+ readonly semanticCoverageLevels: readonly string[];
33
+ readonly exactAstSources: number;
34
+ readonly tokenSources: number;
35
+ readonly triviaSources: number;
36
+ readonly sourceRangeSources: number;
37
+ readonly generatedRangeSources: number;
38
+ readonly diagnosticsSources: number;
39
+ readonly missingParserSources: number;
40
+ readonly evidenceRecords: number;
41
+ }
42
+
43
+ export interface NativeProjectAdmissionSemanticMergeScoreSummary {
44
+ readonly sourceCount: number;
45
+ readonly min: number;
46
+ readonly max: number;
47
+ readonly average: number;
48
+ readonly sortKey: number;
49
+ readonly lowestSourcePaths: readonly string[];
50
+ }
51
+
52
+ export interface NativeProjectAdmissionMissingEvidenceHint {
53
+ readonly evidenceKey?: string;
54
+ readonly task: string;
55
+ readonly count: number;
56
+ readonly sourcePaths: readonly string[];
57
+ readonly languages: readonly string[];
58
+ readonly lossIds: readonly string[];
59
+ readonly lossKinds: readonly string[];
60
+ readonly lossClasses: readonly string[];
61
+ readonly readiness: SemanticMergeReadiness;
62
+ }
63
+
64
+ export interface NativeProjectAdmissionTaskHint {
65
+ readonly id?: string;
66
+ readonly task: string;
67
+ readonly reason?: string;
68
+ readonly priority: NativeProjectImportAdmissionPriority;
69
+ readonly readiness: SemanticMergeReadiness;
70
+ readonly count: number;
71
+ readonly sourcePaths: readonly string[];
72
+ readonly languages: readonly string[];
73
+ readonly lossClasses: readonly string[];
74
+ readonly evidenceKeys: readonly string[];
75
+ }
76
+
77
+ export interface NativeProjectAdmissionSourceSummary {
78
+ readonly id?: string;
79
+ readonly language: FrontierSourceLanguage | string;
80
+ readonly sourcePath?: string;
81
+ readonly sourceHash?: string;
82
+ readonly readiness: SemanticMergeReadiness;
83
+ readonly parser?: string;
84
+ readonly parserEvidence: NativeProjectAdmissionParserEvidence;
85
+ readonly semanticCounts: {
86
+ readonly symbols: number;
87
+ readonly occurrences: number;
88
+ readonly relations: number;
89
+ readonly facts: number;
90
+ };
91
+ readonly semanticSymbols: number;
92
+ readonly emptySemanticEvidence: boolean;
93
+ readonly sourcePreservationQuality: NativeProjectSourcePreservationQuality;
94
+ readonly lossClasses: readonly string[];
95
+ readonly semanticMergeScore: number;
96
+ readonly missingEvidence: readonly NativeProjectAdmissionMissingEvidenceHint[];
97
+ readonly nextMissingTask?: NativeProjectAdmissionTaskHint;
98
+ readonly nextMissingTasks: readonly NativeProjectAdmissionTaskHint[];
99
+ }
100
+
101
+ export interface NativeProjectAdmissionLanguageReadinessSummary {
102
+ readonly language: FrontierSourceLanguage | string;
103
+ readonly readiness: SemanticMergeReadiness;
104
+ readonly sourceCount: number;
105
+ readonly sourcePaths: readonly string[];
106
+ readonly byLossClass: Readonly<Record<string, number>>;
107
+ readonly parserEvidence: NativeProjectAdmissionParserEvidenceSummary;
108
+ readonly semanticMergeScore: NativeProjectAdmissionSemanticMergeScoreSummary;
109
+ readonly topMissingEvidence: readonly NativeProjectAdmissionMissingEvidenceHint[];
110
+ readonly nextMissingTasks: readonly NativeProjectAdmissionTaskHint[];
111
+ }
112
+
11
113
  export interface NativeProjectAdmissionLanguageSummary {
12
114
  readonly language: FrontierSourceLanguage | string;
13
115
  readonly sourceCount: number;
@@ -19,12 +121,26 @@ export interface NativeProjectAdmissionLanguageSummary {
19
121
  readonly staleSourcePaths: readonly string[];
20
122
  readonly mergeCandidates: number;
21
123
  readonly highestRisk: NativeProjectImportAdmissionRisk;
124
+ readonly byReadiness: Readonly<Record<string, number>>;
125
+ readonly byLossClass: Readonly<Record<string, number>>;
126
+ readonly parserEvidence: NativeProjectAdmissionParserEvidenceSummary;
127
+ readonly semanticMergeScore: NativeProjectAdmissionSemanticMergeScoreSummary;
128
+ readonly topMissingEvidence: readonly NativeProjectAdmissionMissingEvidenceHint[];
129
+ readonly nextMissingTasks: readonly NativeProjectAdmissionTaskHint[];
22
130
  }
23
131
 
24
132
  export interface NativeProjectAdmissionLanguages {
25
133
  readonly total: number;
26
134
  readonly byReadiness: Readonly<Record<string, number>>;
135
+ readonly bySourceReadiness: Readonly<Record<string, number>>;
136
+ readonly byLossClass: Readonly<Record<string, number>>;
27
137
  readonly bySourcePreservationQuality: Readonly<Record<string, number>>;
138
+ readonly parserEvidence: NativeProjectAdmissionParserEvidenceSummary;
139
+ readonly semanticMergeScore: NativeProjectAdmissionSemanticMergeScoreSummary;
140
+ readonly topMissingEvidence: readonly NativeProjectAdmissionMissingEvidenceHint[];
141
+ readonly nextMissingTasks: readonly NativeProjectAdmissionTaskHint[];
142
+ readonly sourceRows: readonly NativeProjectAdmissionSourceSummary[];
143
+ readonly readinessRows: readonly NativeProjectAdmissionLanguageReadinessSummary[];
28
144
  readonly rows: readonly NativeProjectAdmissionLanguageSummary[];
29
145
  }
30
146
 
@@ -78,10 +194,27 @@ export interface NativeProjectAdmissionMergeCandidates {
78
194
  readonly highestRisk: NativeProjectImportAdmissionRisk;
79
195
  readonly byRisk: Readonly<Record<string, number>>;
80
196
  readonly byReadiness: Readonly<Record<string, number>>;
197
+ readonly byProjectionRisk: Readonly<Record<string, number>>;
81
198
  readonly highRiskCandidateIds: readonly string[];
82
199
  readonly reviewCandidateIds: readonly string[];
83
200
  readonly blockedCandidateIds: readonly string[];
201
+ readonly highProjectionRiskCandidateIds: readonly string[];
84
202
  readonly conflictKeys: readonly string[];
203
+ readonly readinessOrderCandidateIds: readonly string[];
204
+ readonly changedSemanticRegions: {
205
+ readonly total: number;
206
+ readonly byKind: Readonly<Record<string, number>>;
207
+ readonly conflictKeys: readonly string[];
208
+ };
209
+ readonly overlaps: {
210
+ readonly total: number;
211
+ readonly candidateIds: readonly string[];
212
+ readonly conflictKeys: readonly string[];
213
+ readonly sourcePaths: readonly string[];
214
+ readonly pairs: readonly SemanticMergeCandidateOverlapRecord[];
215
+ };
216
+ readonly records: readonly SemanticMergeCandidateAdmissionRecord[];
217
+ readonly projectionRisk?: SemanticMergeCandidateProjectionRisk;
85
218
  readonly patchRisk?: NativeProjectImportAdmissionRisk;
86
219
  }
87
220
 
@@ -0,0 +1,177 @@
1
+ export type NativeRoundtripSourceMapPrecision = SourceMapMappingRecord['precision'] | 'line' | 'declaration' | 'estimated' | 'unknown' | 'none' | string;
2
+
3
+ export type NativeRoundtripAuditDisposition =
4
+ | 'reversible'
5
+ | 'preserved-source'
6
+ | 'stub-only'
7
+ | 'adapter-projected'
8
+ | 'review-required';
9
+
10
+ export type NativeRoundtripAuditClaim =
11
+ | 'source-text-reversible'
12
+ | 'source-preserved'
13
+ | 'declaration-stubs-only'
14
+ | 'host-adapter-projected'
15
+ | 'review-required';
16
+
17
+ export interface NativeRoundtripSourceMapEvidence {
18
+ readonly total: number;
19
+ readonly ids: readonly string[];
20
+ readonly mappings: number;
21
+ readonly precision: NativeRoundtripSourceMapPrecision;
22
+ readonly byPrecision: Readonly<Record<string, number>>;
23
+ readonly byOrigin: Readonly<Record<string, number>>;
24
+ readonly withSourceSpan: number;
25
+ readonly withGeneratedSpan: number;
26
+ readonly withSemanticSymbol: number;
27
+ readonly targetPaths: readonly string[];
28
+ }
29
+
30
+ export interface NativeRoundtripRoutePathSignal {
31
+ readonly selected: boolean;
32
+ readonly available: boolean;
33
+ readonly reasonCodes: readonly string[];
34
+ }
35
+
36
+ export interface NativeRoundtripRoutePathsAudit {
37
+ readonly reversible: NativeRoundtripRoutePathSignal;
38
+ readonly preservedSource: NativeRoundtripRoutePathSignal;
39
+ readonly stubOnly: NativeRoundtripRoutePathSignal;
40
+ readonly adapterProjected: NativeRoundtripRoutePathSignal;
41
+ }
42
+
43
+ export interface NativeRoundtripSourcePreservationAudit {
44
+ readonly id?: string;
45
+ readonly exactSourceAvailable: boolean;
46
+ readonly sourceTextAvailable: boolean;
47
+ readonly recordCount: number;
48
+ readonly byLevel: Readonly<Record<string, number>>;
49
+ readonly exactRecords: number;
50
+ readonly declarationRecords: number;
51
+ readonly estimatedRecords: number;
52
+ readonly blockedRecords: number;
53
+ readonly sourcePaths: readonly string[];
54
+ readonly sourceMapIds: readonly string[];
55
+ readonly mappingPreservation: Readonly<Record<string, number>>;
56
+ readonly comments: number;
57
+ readonly trivia: number;
58
+ readonly directives: number;
59
+ readonly tokens: number;
60
+ readonly whitespace: number;
61
+ readonly truncated: boolean;
62
+ }
63
+
64
+ export interface NativeRoundtripGeneratedStubsAudit {
65
+ readonly available: boolean;
66
+ readonly selected: boolean;
67
+ readonly projectionMode?: NativeSourceProjectionMode;
68
+ readonly outputMode?: NativeSourceCompileOutputMode;
69
+ readonly declarationCount: number;
70
+ readonly emittedDeclarationCount: number;
71
+ readonly declarationKinds: Readonly<Record<string, number>>;
72
+ readonly declarationsWithSourceSpan: number;
73
+ readonly symbolIds: readonly string[];
74
+ readonly nativeAstNodeIds: readonly string[];
75
+ readonly lossCount: number;
76
+ }
77
+
78
+ export interface NativeRoundtripAdapterProjectionAudit {
79
+ readonly available: boolean;
80
+ readonly selected: boolean;
81
+ readonly id?: string;
82
+ readonly adapterId?: string;
83
+ readonly adapterVersion?: string;
84
+ readonly outputMode?: 'target-adapter';
85
+ readonly readiness?: SemanticMergeReadiness;
86
+ readonly lossCount: number;
87
+ readonly evidenceIds: readonly string[];
88
+ readonly sourceMaps: NativeRoundtripSourceMapEvidence;
89
+ }
90
+
91
+ export interface NativeRoundtripRouteSourceMapsAudit {
92
+ readonly hasOutputSourceMaps: boolean;
93
+ readonly output: NativeRoundtripSourceMapEvidence;
94
+ readonly universal: NativeRoundtripSourceMapEvidence;
95
+ readonly outputExact: boolean;
96
+ readonly outputEstimated: boolean;
97
+ readonly universalEstimated: boolean;
98
+ }
99
+
100
+ export interface NativeRoundtripHashChecksAudit {
101
+ readonly sourceHashPresent: boolean;
102
+ readonly declaredSourceHashPresent: boolean;
103
+ readonly declaredSourceHashVerified?: boolean;
104
+ readonly expectedSourceHashPresent: boolean;
105
+ readonly outputHashPresent: boolean;
106
+ readonly projectionOutputHashPresent: boolean;
107
+ readonly targetOutputHashPresent: boolean;
108
+ readonly sourceHashVerified: boolean;
109
+ readonly projectionOutputMatchesSourceHash: boolean;
110
+ readonly targetOutputMatchesSourceHash: boolean;
111
+ readonly outputMatchesSourceHash: boolean;
112
+ }
113
+
114
+ export interface NativeRoundtripCommentsTriviaAudit {
115
+ readonly comments: number;
116
+ readonly trivia: number;
117
+ readonly directives: number;
118
+ readonly tokens: number;
119
+ readonly whitespace: number;
120
+ readonly truncated: boolean;
121
+ readonly exactSourceAvailable: boolean;
122
+ readonly sourceTextAvailable: boolean;
123
+ }
124
+
125
+ export interface NativeRoundtripTargetCoverageAudit {
126
+ readonly target?: CompileTarget | string;
127
+ readonly supported?: boolean;
128
+ readonly readiness?: SemanticMergeReadiness;
129
+ readonly lossClass?: ProjectionTargetLossClass | string;
130
+ readonly adapterId?: string;
131
+ readonly adapterKind?: string;
132
+ readonly adapterVersion?: string;
133
+ readonly lossKinds: readonly string[];
134
+ readonly categories: readonly string[];
135
+ readonly reason?: string;
136
+ readonly notes: readonly string[];
137
+ }
138
+
139
+ export interface NativeRoundtripSemanticEquivalenceAudit {
140
+ readonly claimed: false;
141
+ readonly proofAdapterId?: string;
142
+ readonly evidenceIds: readonly string[];
143
+ readonly reasonCode: string;
144
+ }
145
+
146
+ export interface NativeRoundtripAuditSignal {
147
+ readonly schema: 'frontier.lang.nativeRoundtripAuditSignal';
148
+ readonly version: 1;
149
+ readonly disposition: NativeRoundtripAuditDisposition;
150
+ readonly claim: NativeRoundtripAuditClaim;
151
+ readonly sourceLanguage?: FrontierSourceLanguage | string;
152
+ readonly target?: CompileTarget | string;
153
+ readonly sameLanguage: boolean;
154
+ readonly outputMode?: NativeSourceCompileOutputMode;
155
+ readonly projectionMode?: NativeSourceProjectionMode;
156
+ readonly sourceHashVerified: boolean;
157
+ readonly outputSourceMapPrecision: NativeRoundtripSourceMapPrecision;
158
+ readonly universalSourceMapPrecision: NativeRoundtripSourceMapPrecision;
159
+ readonly targetProjectionAdapterId?: string;
160
+ readonly targetCoverageLossClass?: ProjectionTargetLossClass | string;
161
+ readonly reviewRequired: boolean;
162
+ readonly semanticMergeReadiness: SemanticMergeReadiness;
163
+ readonly semanticEquivalenceClaim: false;
164
+ readonly autoMergeClaim: false;
165
+ readonly paths: NativeRoundtripRoutePathsAudit;
166
+ readonly sourcePreservation: NativeRoundtripSourcePreservationAudit;
167
+ readonly generatedStubs: NativeRoundtripGeneratedStubsAudit;
168
+ readonly adapterProjection: NativeRoundtripAdapterProjectionAudit;
169
+ readonly sourceMaps: NativeRoundtripRouteSourceMapsAudit;
170
+ readonly hashChecks: NativeRoundtripHashChecksAudit;
171
+ readonly commentsTrivia: NativeRoundtripCommentsTriviaAudit;
172
+ readonly targetCoverage: NativeRoundtripTargetCoverageAudit;
173
+ readonly semanticEquivalence: NativeRoundtripSemanticEquivalenceAudit;
174
+ readonly blockingLossCount: number;
175
+ readonly reviewLossCount: number;
176
+ readonly reasonCodes: readonly string[];
177
+ }