@shapeshift-labs/frontier-lang-parser 0.3.31 → 0.3.32
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 +1 -1
- package/dist/index.js +3 -3
- package/dist/metadata.js +9 -5
- package/dist/target-projection-aggregate.js +75 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -367,7 +367,7 @@ target rust @id("target_rust") {
|
|
|
367
367
|
}
|
|
368
368
|
```
|
|
369
369
|
|
|
370
|
-
The parser stores these rows on the target node metadata as `projectionContracts` and `projectionLayers
|
|
370
|
+
The parser stores these rows on the target node metadata as `projectionContracts` and `projectionLayers`, then aggregates them into `metadata.targetProjections` and mirrors that aggregate under `metadata.universalAst.targetProjections` with target ids, target languages, emit paths, adapter ids, represented/missing layers, evidence ids, proof evidence ids, loss ids, and missing evidence. They are target-lowering evidence, not proof of equivalence: `autoMergeClaim` and `semanticEquivalenceClaim` remain false on rows and aggregates.
|
|
371
371
|
|
|
372
372
|
## Authored decision graph syntax
|
|
373
373
|
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ export function parseFrontierSource(source, options = {}) {
|
|
|
32
32
|
const packageManifestBlocks = [];
|
|
33
33
|
const canvasSurfaceBlocks = [];
|
|
34
34
|
const applicationSurfaceBlocks = [];
|
|
35
|
-
const runtimeCapabilityBlocks = [];
|
|
35
|
+
const runtimeCapabilityBlocks = [], targetProjectionTargets = [];
|
|
36
36
|
const documentId = options.id ?? readId(source) ?? 'mod_frontier';
|
|
37
37
|
const documentName = options.name ?? readName(source) ?? 'FrontierModule';
|
|
38
38
|
for (const block of readBlocks(source)) {
|
|
@@ -51,7 +51,7 @@ export function parseFrontierSource(source, options = {}) {
|
|
|
51
51
|
nodes.push(parsed.node);
|
|
52
52
|
nativeSourceBlocks.push(parsed);
|
|
53
53
|
}
|
|
54
|
-
if (block.kind === 'target') nodes.push(
|
|
54
|
+
if (block.kind === 'target') { const parsed = parseTarget(block); nodes.push(parsed); if (parsed.metadata?.authoredTargetProjection) targetProjectionTargets.push(parsed); }
|
|
55
55
|
if (block.kind === 'proof') proofBlocks.push(parseProofBlock(block));
|
|
56
56
|
if (block.kind === 'paradigm' || block.kind === 'paradigmSemantics') paradigmBlocks.push(parseParadigmBlock(block));
|
|
57
57
|
if (block.kind === 'operations' || block.kind === 'semanticOperations') operationBlocks.push(parseSemanticOperationsBlock(block));
|
|
@@ -66,7 +66,7 @@ export function parseFrontierSource(source, options = {}) {
|
|
|
66
66
|
if (block.kind === 'applicationSurface' || block.kind === 'appHost' || block.kind === 'plugin' || block.kind === 'pluginSurface' || block.kind === 'pluginContract') applicationSurfaceBlocks.push(parseApplicationSurfaceBlock(block));
|
|
67
67
|
if (block.kind === 'runtimeCapabilities' || block.kind === 'runtimeCapabilityMatrix' || block.kind === 'runtimeHosts') runtimeCapabilityBlocks.push(parseRuntimeCapabilityBlock(block));
|
|
68
68
|
}
|
|
69
|
-
const metadata = createParsedMetadata({ proofBlocks, paradigmBlocks, operationBlocks, conversionBlocks, constraintSpaceBlocks, decisionGraphBlocks, dialectRegistryBlocks, interlinguaBlocks, resourceGraphBlocks, nativeSourceBlocks, packageManifestBlocks, canvasSurfaceBlocks, applicationSurfaceBlocks, runtimeCapabilityBlocks });
|
|
69
|
+
const metadata = createParsedMetadata({ proofBlocks, paradigmBlocks, operationBlocks, conversionBlocks, constraintSpaceBlocks, decisionGraphBlocks, dialectRegistryBlocks, interlinguaBlocks, resourceGraphBlocks, nativeSourceBlocks, packageManifestBlocks, canvasSurfaceBlocks, applicationSurfaceBlocks, runtimeCapabilityBlocks, targetProjectionTargets });
|
|
70
70
|
return createDocument({ id: documentId, name: documentName, nodes, ...(metadata ? { metadata } : {}) });
|
|
71
71
|
}
|
|
72
72
|
|
package/dist/metadata.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mergeDialectRegistryBlocks } from './dialect-registry.js';
|
|
2
2
|
import { mergeApplicationSurfaceBlocks } from './application-surface.js';
|
|
3
3
|
import { mergeRuntimeCapabilityBlocks } from './runtime-capability.js';
|
|
4
|
+
import { mergeTargetProjectionTargets } from './target-projection-aggregate.js';
|
|
4
5
|
|
|
5
6
|
const PROOF_GROUPS = ['contracts', 'refinements', 'invariants', 'termination', 'temporal', 'obligations', 'artifacts', 'assumptions'];
|
|
6
7
|
const PARADIGM_GROUPS = [
|
|
@@ -9,7 +10,7 @@ const PARADIGM_GROUPS = [
|
|
|
9
10
|
'clockModels', 'objectModels', 'macroExpansions', 'reflectionBoundaries', 'loweringRecords'
|
|
10
11
|
];
|
|
11
12
|
|
|
12
|
-
export function createParsedMetadata({ proofBlocks = [], paradigmBlocks = [], operationBlocks = [], conversionBlocks = [], constraintSpaceBlocks = [], decisionGraphBlocks = [], dialectRegistryBlocks = [], interlinguaBlocks = [], resourceGraphBlocks = [], nativeSourceBlocks = [], packageManifestBlocks = [], canvasSurfaceBlocks = [], applicationSurfaceBlocks = [], runtimeCapabilityBlocks = [] } = {}) {
|
|
13
|
+
export function createParsedMetadata({ proofBlocks = [], paradigmBlocks = [], operationBlocks = [], conversionBlocks = [], constraintSpaceBlocks = [], decisionGraphBlocks = [], dialectRegistryBlocks = [], interlinguaBlocks = [], resourceGraphBlocks = [], nativeSourceBlocks = [], packageManifestBlocks = [], canvasSurfaceBlocks = [], applicationSurfaceBlocks = [], runtimeCapabilityBlocks = [], targetProjectionTargets = [] } = {}) {
|
|
13
14
|
const metadata = {};
|
|
14
15
|
if (proofBlocks.length) metadata.proof = mergeProofBlocks(proofBlocks);
|
|
15
16
|
if (paradigmBlocks.length) metadata.paradigmSemantics = mergeParadigmBlocks(paradigmBlocks);
|
|
@@ -27,8 +28,9 @@ export function createParsedMetadata({ proofBlocks = [], paradigmBlocks = [], op
|
|
|
27
28
|
metadata.runtimeCapabilities = mergeRuntimeCapabilityBlocks(runtimeCapabilityBlocks);
|
|
28
29
|
metadata.runtimeCapabilityMatrix = metadata.runtimeCapabilities;
|
|
29
30
|
}
|
|
30
|
-
if (
|
|
31
|
-
|
|
31
|
+
if (targetProjectionTargets.length) metadata.targetProjections = mergeTargetProjectionTargets(targetProjectionTargets);
|
|
32
|
+
if (nativeSourceBlocks.some((block) => block.sourceMaps.length || block.mergeCandidates.length || block.evidence.length) || packageManifestBlocks.length || canvasSurfaceBlocks.length || applicationSurfaceBlocks.length || runtimeCapabilityBlocks.length || targetProjectionTargets.length) {
|
|
33
|
+
metadata.universalAst = mergeUniversalAstBlocks(nativeSourceBlocks, packageManifestBlocks, canvasSurfaceBlocks, applicationSurfaceBlocks, runtimeCapabilityBlocks, metadata.targetProjections);
|
|
32
34
|
}
|
|
33
35
|
return Object.keys(metadata).length ? metadata : undefined;
|
|
34
36
|
}
|
|
@@ -99,7 +101,7 @@ function mergeConstraintSpaceBlocks(blocks) {
|
|
|
99
101
|
};
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
function mergeUniversalAstBlocks(blocks, packageManifestBlocks = [], canvasSurfaceBlocks = [], applicationSurfaceBlocks = [], runtimeCapabilityBlocks = []) {
|
|
104
|
+
function mergeUniversalAstBlocks(blocks, packageManifestBlocks = [], canvasSurfaceBlocks = [], applicationSurfaceBlocks = [], runtimeCapabilityBlocks = [], targetProjections) {
|
|
103
105
|
return {
|
|
104
106
|
id: blocks.length === 1 ? `universalAst:${blocks[0].node.id}` : 'universalAst:source',
|
|
105
107
|
nativeSourceIds: blocks.map((block) => block.node.id),
|
|
@@ -111,6 +113,7 @@ function mergeUniversalAstBlocks(blocks, packageManifestBlocks = [], canvasSurfa
|
|
|
111
113
|
canvasSurfaces: canvasSurfaceBlocks,
|
|
112
114
|
applicationSurfaces: applicationSurfaceBlocks,
|
|
113
115
|
runtimeCapabilities: runtimeCapabilityBlocks,
|
|
116
|
+
...(targetProjections ? { targetProjections, targetProjectionTargetIds: targetProjections.targetIds, targetProjectionContractIds: targetProjections.projectionContractIds, targetProjectionLayerIds: targetProjections.projectionLayerIds } : {}),
|
|
114
117
|
packageManifestIds: ids(packageManifestBlocks),
|
|
115
118
|
canvasSurfaceIds: ids(canvasSurfaceBlocks),
|
|
116
119
|
applicationSurfaceIds: ids(applicationSurfaceBlocks),
|
|
@@ -120,7 +123,8 @@ function mergeUniversalAstBlocks(blocks, packageManifestBlocks = [], canvasSurfa
|
|
|
120
123
|
authoredPackageManifestIds: ids(packageManifestBlocks),
|
|
121
124
|
authoredCanvasSurfaceIds: ids(canvasSurfaceBlocks),
|
|
122
125
|
authoredApplicationSurfaceIds: ids(applicationSurfaceBlocks),
|
|
123
|
-
authoredRuntimeCapabilityIds: ids(runtimeCapabilityBlocks)
|
|
126
|
+
authoredRuntimeCapabilityIds: ids(runtimeCapabilityBlocks),
|
|
127
|
+
...(targetProjections ? { authoredTargetProjectionTargetIds: targetProjections.targetIds } : {})
|
|
124
128
|
}
|
|
125
129
|
};
|
|
126
130
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export function mergeTargetProjectionTargets(targets = []) {
|
|
2
|
+
const entries = targets.map(targetProjectionEntry).filter(Boolean);
|
|
3
|
+
if (!entries.length) return undefined;
|
|
4
|
+
const contracts = entries.flatMap((entry) => entry.projectionContracts ?? []);
|
|
5
|
+
const layers = entries.flatMap((entry) => entry.projectionLayers ?? []);
|
|
6
|
+
return {
|
|
7
|
+
id: entries.length === 1 ? `targetProjections:${entries[0].id}` : 'targetProjections:source',
|
|
8
|
+
targets: entries,
|
|
9
|
+
targetIds: ids(entries),
|
|
10
|
+
targetLanguages: uniqueStrings(entries.map((entry) => entry.target?.language)),
|
|
11
|
+
emitPaths: uniqueStrings(entries.map((entry) => entry.target?.emitPath)),
|
|
12
|
+
projectionContracts: contracts,
|
|
13
|
+
projectionLayers: layers,
|
|
14
|
+
projectionContractIds: ids(contracts),
|
|
15
|
+
projectionLayerIds: ids(layers),
|
|
16
|
+
representedLayerKinds: uniqueStrings(contracts.flatMap((entry) => entry.representedLayerKinds ?? [])),
|
|
17
|
+
missingLayerKinds: uniqueStrings(contracts.flatMap((entry) => entry.missingLayerKinds ?? [])),
|
|
18
|
+
evidenceIds: uniqueStrings(entries.flatMap((entry) => entry.evidenceIds ?? [])),
|
|
19
|
+
proofEvidenceIds: uniqueStrings(entries.flatMap((entry) => entry.proofEvidenceIds ?? [])),
|
|
20
|
+
lossIds: uniqueStrings(entries.flatMap((entry) => entry.lossIds ?? [])),
|
|
21
|
+
missingEvidence: uniqueStrings(entries.flatMap((entry) => entry.missingEvidence ?? [])),
|
|
22
|
+
summary: {
|
|
23
|
+
targetCount: entries.length,
|
|
24
|
+
projectionContractCount: contracts.length,
|
|
25
|
+
projectionLayerCount: layers.length,
|
|
26
|
+
missingEvidenceCount: uniqueStrings(entries.flatMap((entry) => entry.missingEvidence ?? [])).length,
|
|
27
|
+
lossCount: uniqueStrings(entries.flatMap((entry) => entry.lossIds ?? [])).length
|
|
28
|
+
},
|
|
29
|
+
claims: { semanticEquivalenceClaim: false, autoMergeClaim: false },
|
|
30
|
+
metadata: { authoredTargetProjectionTargetIds: ids(entries) }
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function targetProjectionEntry(node = {}) {
|
|
35
|
+
const metadata = node.metadata;
|
|
36
|
+
if (!metadata?.authoredTargetProjection) return undefined;
|
|
37
|
+
const projectionContracts = enrichRows(metadata.projectionContracts, node);
|
|
38
|
+
const projectionLayers = enrichRows(metadata.projectionLayers, node);
|
|
39
|
+
return cleanObject({
|
|
40
|
+
id: node.id,
|
|
41
|
+
kind: 'frontier.lang.targetProjectionTarget',
|
|
42
|
+
name: node.name,
|
|
43
|
+
target: node.target,
|
|
44
|
+
projectionContracts,
|
|
45
|
+
projectionLayers,
|
|
46
|
+
projectionContractIds: ids(projectionContracts),
|
|
47
|
+
projectionLayerIds: ids(projectionLayers),
|
|
48
|
+
representedLayerKinds: uniqueStrings(projectionContracts.flatMap((entry) => entry.representedLayerKinds ?? [])),
|
|
49
|
+
missingLayerKinds: uniqueStrings(projectionContracts.flatMap((entry) => entry.missingLayerKinds ?? [])),
|
|
50
|
+
evidenceIds: metadata.evidenceIds,
|
|
51
|
+
proofEvidenceIds: metadata.proofEvidenceIds,
|
|
52
|
+
lossIds: metadata.lossIds,
|
|
53
|
+
missingEvidence: metadata.missingEvidence,
|
|
54
|
+
claims: { semanticEquivalenceClaim: false, autoMergeClaim: false },
|
|
55
|
+
metadata: { authoredTargetProjection: true, targetNodeId: node.id, targetLanguage: node.target?.language ?? node.name }
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function enrichRows(rows = [], node = {}) {
|
|
60
|
+
return rows.map((row) => cleanObject({
|
|
61
|
+
targetId: node.id,
|
|
62
|
+
targetName: node.name,
|
|
63
|
+
targetLanguage: node.target?.language ?? node.name,
|
|
64
|
+
packageName: node.target?.packageName,
|
|
65
|
+
emitPath: node.target?.emitPath,
|
|
66
|
+
moduleFormat: node.target?.moduleFormat,
|
|
67
|
+
...row,
|
|
68
|
+
semanticEquivalenceClaim: false,
|
|
69
|
+
autoMergeClaim: false
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function ids(records = []) { return records.map((record) => record?.id).filter(Boolean); }
|
|
74
|
+
function uniqueStrings(values = []) { return [...new Set(values.filter(Boolean))]; }
|
|
75
|
+
function cleanObject(object) { return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined && (!Array.isArray(value) || value.length > 0))); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshift-labs/frontier-lang-parser",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"description": "Parser for the first Frontier Lang .frontier syntax slice.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "node scripts/build.mjs",
|
|
25
|
-
"test": "npm run build && node test/smoke.mjs && node test/conversion-constraint-fields-smoke.mjs && node test/package-canvas-surface-smoke.mjs && node test/view-render-graph-smoke.mjs && node test/resource-graph-smoke.mjs && node test/interlingua-smoke.mjs && node test/dialect-registry-smoke.mjs",
|
|
25
|
+
"test": "npm run build && node test/smoke.mjs && node test/target-projection-aggregate-smoke.mjs && node test/conversion-constraint-fields-smoke.mjs && node test/package-canvas-surface-smoke.mjs && node test/view-render-graph-smoke.mjs && node test/resource-graph-smoke.mjs && node test/interlingua-smoke.mjs && node test/dialect-registry-smoke.mjs",
|
|
26
26
|
"typecheck": "node ./node_modules/typescript/bin/tsc --noEmit -p test/tsconfig.json",
|
|
27
27
|
"fuzz": "npm run build && node fuzz/smoke.mjs",
|
|
28
28
|
"bench": "npm run build && node bench/smoke.mjs",
|