@shapeshift-labs/frontier-lang-parser 0.3.73 → 0.3.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/metadata.js
CHANGED
|
@@ -269,6 +269,7 @@ function mergeResourceGraphBlocks(blocks) {
|
|
|
269
269
|
pointerEdgeIds: blocks.flatMap((block) => ids(block.graph?.pointerEdges)),
|
|
270
270
|
memoryAccessIds: blocks.flatMap((block) => ids(block.graph?.memoryAccesses)),
|
|
271
271
|
abiBoundaryIds: blocks.flatMap((block) => ids(block.graph?.abiBoundaries)),
|
|
272
|
+
synchronizationEdgeIds: blocks.flatMap((block) => ids(block.graph?.synchronizationEdges)),
|
|
272
273
|
trapIds: blocks.flatMap((block) => ids(block.graph?.traps)),
|
|
273
274
|
undefinedBehaviorIds: blocks.flatMap((block) => ids(block.graph?.undefinedBehaviors)),
|
|
274
275
|
conflictIds: blocks.flatMap((block) => ids(block.graph?.conflicts)),
|
|
@@ -287,17 +288,16 @@ function mergeResourceGraphBlocks(blocks) {
|
|
|
287
288
|
lifetimeRelationCount: sum(blocks, 'lifetimeRelations'),
|
|
288
289
|
borrowScopeCount: sum(blocks, 'borrowScopes'),
|
|
289
290
|
unsafeBoundaryCount: sum(blocks, 'unsafeBoundaries'),
|
|
290
|
-
memoryRegionCount: sum(blocks, 'memoryRegions'),
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
memoryAccessCount: sum(blocks, 'memoryAccesses'),
|
|
294
|
-
abiBoundaryCount: sum(blocks, 'abiBoundaries'),
|
|
291
|
+
memoryRegionCount: sum(blocks, 'memoryRegions'), dataLayoutCount: sum(blocks, 'dataLayouts'),
|
|
292
|
+
pointerEdgeCount: sum(blocks, 'pointerEdges'), memoryAccessCount: sum(blocks, 'memoryAccesses'),
|
|
293
|
+
abiBoundaryCount: sum(blocks, 'abiBoundaries'), synchronizationEdgeCount: sum(blocks, 'synchronizationEdges'),
|
|
295
294
|
trapCount: sum(blocks, 'traps'),
|
|
296
295
|
undefinedBehaviorCount: sum(blocks, 'undefinedBehaviors'),
|
|
297
296
|
lowLevelPrimitiveCount: sum(blocks, 'lowLevelPrimitives'),
|
|
298
297
|
conflictCount: sum(blocks, 'conflicts'),
|
|
299
298
|
proofObligationCount: sum(blocks, 'proofObligations'),
|
|
300
299
|
unsafeBoundariesWithoutProof: sum(blocks, 'unsafeBoundariesWithoutProof'),
|
|
300
|
+
synchronizationEdgeWithoutProofCount: sum(blocks, 'synchronizationEdgesWithoutProof'),
|
|
301
301
|
failClosedTrapCount: sum(blocks, 'failClosedTraps'),
|
|
302
302
|
trapWithoutProofCount: sum(blocks, 'trapsWithoutProof'),
|
|
303
303
|
undefinedBehaviorWithoutProofCount: sum(blocks, 'undefinedBehaviorsWithoutProof')
|
|
@@ -4,6 +4,7 @@ export function parseLowLevelResourceRecord(kind, common, name, text) {
|
|
|
4
4
|
if (kind === 'pointerEdge') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), targetResourceId: word('targetResource', text) ?? word('targetResourceId', text) ?? word('target', text), ownerId: word('owner', text) ?? word('ownerId', text), lifetimeRegionId: word('lifetime', text) ?? word('lifetimeRegion', text) ?? word('lifetimeRegionId', text), pointerKind: word('pointerKind', text) ?? word('kind', text) ?? 'pointer', addressSpace: word('addressSpace', text) ?? word('space', text), pointerWidth: number('pointerWidth', text), aliasKind: word('aliasKind', text), mode: word('mode', text), provenance: word('provenance', text), nullable: flag('nullable', text), mutable: flag('mutable', text) });
|
|
5
5
|
if (kind === 'memoryAccess') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), accessKind: word('accessKind', text) ?? word('kind', text) ?? name, operationKind: word('operation', text) ?? word('operationKind', text), memoryOrder: word('memoryOrder', text) ?? word('ordering', text), lockId: word('lock', text) ?? word('lockId', text), synchronizationKey: word('sync', text) ?? word('synchronizationKey', text), reads: list(text, 'read', 'reads'), writes: list(text, 'write', 'writes'), volatile: flag('volatile', text), atomic: flag('atomic', text), proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing' });
|
|
6
6
|
if (kind === 'abiBoundary') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), callableId: word('callable', text) ?? word('callableId', text), functionId: word('function', text) ?? word('functionId', text), boundaryKind: word('boundaryKind', text) ?? word('kind', text) ?? 'abi-boundary', abi: word('abi', text), abiKind: word('abiKind', text), callingConvention: word('callingConvention', text) ?? word('convention', text), pointerWidth: number('pointerWidth', text), endian: word('endian', text) ?? word('endianness', text), ffiBoundary: word('ffiBoundary', text), proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing' });
|
|
7
|
+
if (kind === 'synchronizationEdge') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), fromMemoryAccessId: word('fromAccess', text) ?? word('fromAccessId', text) ?? word('fromMemoryAccess', text) ?? word('fromMemoryAccessId', text) ?? word('from', text), toMemoryAccessId: word('toAccess', text) ?? word('toAccessId', text) ?? word('toMemoryAccess', text) ?? word('toMemoryAccessId', text) ?? word('to', text), edgeKind: word('edgeKind', text) ?? word('synchronizationKind', text) ?? word('syncKind', text) ?? word('kind', text) ?? name, synchronizationKind: word('synchronizationKind', text) ?? word('syncKind', text) ?? word('edgeKind', text) ?? word('kind', text) ?? name, fenceKind: word('fenceKind', text), memoryScope: word('memoryScope', text) ?? word('barrierScope', text) ?? word('scope', text), memoryOrder: word('memoryOrder', text) ?? word('ordering', text), lockId: word('lock', text) ?? word('lockId', text), synchronizationKey: word('sync', text) ?? word('synchronizationKey', text), channelId: word('channel', text) ?? word('channelId', text), actorId: word('actor', text) ?? word('actorId', text), operationKind: word('operation', text) ?? word('operationKind', text), reasonCode: word('reasonCode', text) ?? word('code', text), condition: quoted('condition', text) ?? word('condition', text), status: word('status', text) ?? 'needs-proof', severity: word('severity', text) ?? 'error', proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing', message: quoted('message', text), failClosed: common.failClosed ?? true, semanticEquivalenceClaim: false, runtimeEquivalenceClaim: false });
|
|
7
8
|
if (kind === 'trap') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), ownerId: word('owner', text) ?? word('ownerId', text), loanId: word('loan', text) ?? word('loanId', text), pointerEdgeId: word('pointer', text) ?? word('pointerEdge', text) ?? word('pointerEdgeId', text), memoryAccessId: word('memoryAccess', text) ?? word('memoryAccessId', text), unsafeBoundaryId: word('unsafeBoundary', text) ?? word('unsafeBoundaryId', text), operationKind: word('operation', text) ?? word('operationKind', text), instructionId: word('instruction', text) ?? word('instructionId', text), callableId: word('callable', text) ?? word('callableId', text), trapKind: word('trapKind', text) ?? word('kind', text) ?? name, trapCode: word('trapCode', text) ?? word('code', text), reasonCode: word('reasonCode', text) ?? word('code', text), condition: quoted('condition', text) ?? word('condition', text), status: word('status', text) ?? 'needs-proof', severity: word('severity', text) ?? 'error', proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing', message: quoted('message', text), failClosed: common.failClosed ?? true, semanticEquivalenceClaim: false, runtimeEquivalenceClaim: false });
|
|
8
9
|
if (kind === 'undefinedBehavior') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), ownerId: word('owner', text) ?? word('ownerId', text), loanId: word('loan', text) ?? word('loanId', text), pointerEdgeId: word('pointer', text) ?? word('pointerEdge', text) ?? word('pointerEdgeId', text), memoryAccessId: word('memoryAccess', text) ?? word('memoryAccessId', text), unsafeBoundaryId: word('unsafeBoundary', text) ?? word('unsafeBoundaryId', text), operationKind: word('operation', text) ?? word('operationKind', text), undefinedBehaviorKind: word('undefinedBehaviorKind', text) ?? word('behaviorKind', text) ?? word('kind', text) ?? name, language: word('language', text), reasonCode: word('reasonCode', text) ?? word('code', text), condition: quoted('condition', text) ?? word('condition', text), status: word('status', text) ?? 'needs-proof', severity: word('severity', text) ?? 'error', proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing', message: quoted('message', text), failClosed: common.failClosed ?? true, semanticEquivalenceClaim: false, runtimeEquivalenceClaim: false });
|
|
9
10
|
return undefined;
|
package/dist/resource-graph.js
CHANGED
|
@@ -18,6 +18,7 @@ const GROUPS = {
|
|
|
18
18
|
pointerEdge: 'pointerEdges',
|
|
19
19
|
memoryAccess: 'memoryAccesses',
|
|
20
20
|
abiBoundary: 'abiBoundaries',
|
|
21
|
+
synchronizationEdge: 'synchronizationEdges',
|
|
21
22
|
trap: 'traps',
|
|
22
23
|
undefinedBehavior: 'undefinedBehaviors',
|
|
23
24
|
conflict: 'conflicts',
|
|
@@ -54,6 +55,7 @@ export function parseResourceGraphBlock(block) {
|
|
|
54
55
|
pointerEdges: [],
|
|
55
56
|
memoryAccesses: [],
|
|
56
57
|
abiBoundaries: [],
|
|
58
|
+
synchronizationEdges: [],
|
|
57
59
|
traps: [],
|
|
58
60
|
undefinedBehaviors: [],
|
|
59
61
|
conflicts: [],
|
|
@@ -84,6 +86,7 @@ export function parseResourceGraphBlock(block) {
|
|
|
84
86
|
graph.outlives = graph.lifetimeRelations;
|
|
85
87
|
graph.borrowScopeRegions = graph.borrowScopes;
|
|
86
88
|
graph.summary = summarize(graph);
|
|
89
|
+
graph.status = deriveGraphStatus(graph.status, graph.summary);
|
|
87
90
|
graph.query = {
|
|
88
91
|
resourceIds: ids(graph.resources),
|
|
89
92
|
ownerIds: ids(graph.owners),
|
|
@@ -91,10 +94,11 @@ export function parseResourceGraphBlock(block) {
|
|
|
91
94
|
trapIds: ids(graph.traps),
|
|
92
95
|
undefinedBehaviorIds: ids(graph.undefinedBehaviors),
|
|
93
96
|
failClosedTrapIds: ids(graph.traps.filter((record) => record.failClosed)),
|
|
94
|
-
|
|
97
|
+
synchronizationEdgeIds: ids(graph.synchronizationEdges),
|
|
98
|
+
lowLevelPrimitiveIds: ids([...graph.memoryRegions, ...graph.dataLayouts, ...graph.pointerEdges, ...graph.memoryAccesses, ...graph.abiBoundaries, ...graph.synchronizationEdges, ...graph.traps, ...graph.undefinedBehaviors]),
|
|
95
99
|
sourcePaths: unique(allRecords(graph).map((record) => record.sourcePath)),
|
|
96
100
|
evidenceIds: unique([...graph.evidenceIds, ...allRecords(graph).flatMap((record) => record.evidenceIds ?? [])]),
|
|
97
|
-
blockerReasonCodes:
|
|
101
|
+
blockerReasonCodes: blockerReasonCodes(graph)
|
|
98
102
|
};
|
|
99
103
|
|
|
100
104
|
return {
|
|
@@ -168,9 +172,10 @@ function summarize(graph) {
|
|
|
168
172
|
pointerEdges: graph.pointerEdges.length,
|
|
169
173
|
memoryAccesses: graph.memoryAccesses.length,
|
|
170
174
|
abiBoundaries: graph.abiBoundaries.length,
|
|
175
|
+
synchronizationEdges: graph.synchronizationEdges.length,
|
|
171
176
|
traps: graph.traps.length,
|
|
172
177
|
undefinedBehaviors: graph.undefinedBehaviors.length,
|
|
173
|
-
lowLevelPrimitives: graph.memoryRegions.length + graph.dataLayouts.length + graph.pointerEdges.length + graph.memoryAccesses.length + graph.abiBoundaries.length + graph.traps.length + graph.undefinedBehaviors.length,
|
|
178
|
+
lowLevelPrimitives: graph.memoryRegions.length + graph.dataLayouts.length + graph.pointerEdges.length + graph.memoryAccesses.length + graph.abiBoundaries.length + graph.synchronizationEdges.length + graph.traps.length + graph.undefinedBehaviors.length,
|
|
174
179
|
conflicts: graph.conflicts.length,
|
|
175
180
|
proofObligations: graph.proofObligations.length,
|
|
176
181
|
unsafeBoundariesWithoutProof: graph.unsafeBoundaries.filter((record) => record.proofStatus !== 'passed').length,
|
|
@@ -178,10 +183,27 @@ function summarize(graph) {
|
|
|
178
183
|
trapsWithoutProof: graph.traps.filter((record) => record.proofStatus !== 'passed').length,
|
|
179
184
|
undefinedBehaviorsWithoutProof: graph.undefinedBehaviors.filter((record) => record.proofStatus !== 'passed').length,
|
|
180
185
|
parseErrors: graph.parser?.errors?.length ?? 0,
|
|
181
|
-
|
|
186
|
+
synchronizationEdgesWithoutProof: graph.synchronizationEdges.filter((record) => record.proofStatus !== 'passed').length,
|
|
187
|
+
reasonCodes: unique([...graph.conflicts, ...graph.synchronizationEdges, ...graph.traps, ...graph.undefinedBehaviors].map((record) => record.reasonCode))
|
|
182
188
|
};
|
|
183
189
|
}
|
|
184
190
|
|
|
191
|
+
function deriveGraphStatus(authoredStatus, summary) {
|
|
192
|
+
if (
|
|
193
|
+
summary.conflicts > 0 ||
|
|
194
|
+
summary.unsafeBoundariesWithoutProof > 0 ||
|
|
195
|
+
summary.synchronizationEdgesWithoutProof > 0 ||
|
|
196
|
+
summary.trapsWithoutProof > 0 ||
|
|
197
|
+
summary.undefinedBehaviorsWithoutProof > 0
|
|
198
|
+
) return 'blocked';
|
|
199
|
+
return authoredStatus ?? 'partial';
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function blockerReasonCodes(graph) {
|
|
203
|
+
const unprovedSynchronizationEdges = graph.synchronizationEdges.filter((record) => record.proofStatus !== 'passed');
|
|
204
|
+
return unique([...graph.conflicts, ...unprovedSynchronizationEdges, ...graph.traps, ...graph.undefinedBehaviors].map((record) => record.reasonCode));
|
|
205
|
+
}
|
|
206
|
+
|
|
185
207
|
function allRecords(graph) {
|
|
186
208
|
return [
|
|
187
209
|
...graph.resources,
|
|
@@ -200,6 +222,7 @@ function allRecords(graph) {
|
|
|
200
222
|
...graph.pointerEdges,
|
|
201
223
|
...graph.memoryAccesses,
|
|
202
224
|
...graph.abiBoundaries,
|
|
225
|
+
...graph.synchronizationEdges,
|
|
203
226
|
...graph.traps,
|
|
204
227
|
...graph.undefinedBehaviors,
|
|
205
228
|
...graph.conflicts,
|
|
@@ -217,6 +240,7 @@ function normalizeRowKind(kind) {
|
|
|
217
240
|
if (kind === 'pointer' || kind === 'ptr' || kind === 'address') return 'pointerEdge';
|
|
218
241
|
if (kind === 'access' || kind === 'memoryAccess' || kind === 'atomic' || kind === 'volatile') return 'memoryAccess';
|
|
219
242
|
if (kind === 'abi' || kind === 'abiBoundary' || kind === 'callBoundary') return 'abiBoundary';
|
|
243
|
+
if (kind === 'sync' || kind === 'synchronization' || kind === 'synchronisation' || kind === 'synchronizationEdge' || kind === 'synchronisationEdge' || kind === 'happensBefore' || kind === 'happens-before' || kind === 'hb' || kind === 'fence' || kind === 'fenceEdge' || kind === 'barrier' || kind === 'barrierEdge') return 'synchronizationEdge';
|
|
220
244
|
if (kind === 'traps') return 'trap';
|
|
221
245
|
if (kind === 'undefined' || kind === 'ub' || kind === 'undefinedBehavior' || kind === 'undefinedBehaviour') return 'undefinedBehavior';
|
|
222
246
|
if (kind === 'proof' || kind === 'obligation' || kind === 'proofObligation') return 'proofObligation';
|
|
@@ -233,6 +257,7 @@ function recordKind(kind) {
|
|
|
233
257
|
if (kind === 'pointerEdge') return 'pointer-edge';
|
|
234
258
|
if (kind === 'memoryAccess') return 'memory-access';
|
|
235
259
|
if (kind === 'abiBoundary') return 'abi-boundary';
|
|
260
|
+
if (kind === 'synchronizationEdge') return 'synchronization-edge';
|
|
236
261
|
if (kind === 'undefinedBehavior') return 'undefined-behavior';
|
|
237
262
|
if (kind === 'proofObligation') return 'proof-obligation';
|
|
238
263
|
return kind;
|
|
@@ -16,8 +16,8 @@ export const ROW_SYNTAX_CONFIG = Object.freeze({
|
|
|
16
16
|
runtimeCapabilities: rowConfig('runtimeCapabilityRow', 'runtime_capability_row', runtimeRows, normalizeRuntimeCapabilityRow),
|
|
17
17
|
runtimeCapabilityMatrix: rowConfig('runtimeCapabilityRow', 'runtime_capability_row', runtimeRows, normalizeRuntimeCapabilityRow),
|
|
18
18
|
runtimeHosts: rowConfig('runtimeCapabilityRow', 'runtime_capability_row', runtimeRows, normalizeRuntimeCapabilityRow),
|
|
19
|
-
resourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('resource owner loan alias move drop escape lifetime lifetimeRegion life outlives lifetimeRelation lifeRelation borrow borrowScope borrowRegion unsafe unsafeBoundary memory memoryRegion region layout dataLayout pointer ptr address access memoryAccess atomic volatile abi abiBoundary callBoundary trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
|
|
20
|
-
semanticResourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('resource owner loan alias move drop escape lifetime lifetimeRegion life outlives lifetimeRelation lifeRelation borrow borrowScope borrowRegion unsafe unsafeBoundary memory memoryRegion region layout dataLayout pointer ptr address access memoryAccess atomic volatile abi abiBoundary callBoundary trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
|
|
19
|
+
resourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('resource owner loan alias move drop escape lifetime lifetimeRegion life outlives lifetimeRelation lifeRelation borrow borrowScope borrowRegion unsafe unsafeBoundary memory memoryRegion region layout dataLayout pointer ptr address access memoryAccess atomic volatile abi abiBoundary callBoundary sync synchronization synchronisation synchronizationEdge synchronisationEdge happensBefore hb fence fenceEdge barrier barrierEdge trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
|
|
20
|
+
semanticResourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('resource owner loan alias move drop escape lifetime lifetimeRegion life outlives lifetimeRelation lifeRelation borrow borrowScope borrowRegion unsafe unsafeBoundary memory memoryRegion region layout dataLayout pointer ptr address access memoryAccess atomic volatile abi abiBoundary callBoundary sync synchronization synchronisation synchronizationEdge synchronisationEdge happensBefore hb fence fenceEdge barrier barrierEdge trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
|
|
21
21
|
applicationSurface: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow),
|
|
22
22
|
appHost: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow),
|
|
23
23
|
plugin: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow),
|
|
@@ -84,6 +84,7 @@ function normalizeResourceGraphRow(rowKind) {
|
|
|
84
84
|
if (rowKind === 'pointer' || rowKind === 'ptr' || rowKind === 'address') return 'pointerEdge';
|
|
85
85
|
if (rowKind === 'access' || rowKind === 'atomic' || rowKind === 'volatile') return 'memoryAccess';
|
|
86
86
|
if (rowKind === 'abi' || rowKind === 'callBoundary') return 'abiBoundary';
|
|
87
|
+
if (rowKind === 'sync' || rowKind === 'synchronization' || rowKind === 'synchronisation' || rowKind === 'synchronisationEdge' || rowKind === 'happensBefore' || rowKind === 'hb' || rowKind === 'fence' || rowKind === 'fenceEdge' || rowKind === 'barrier' || rowKind === 'barrierEdge') return 'synchronizationEdge';
|
|
87
88
|
if (rowKind === 'traps') return 'trap';
|
|
88
89
|
if (rowKind === 'undefined' || rowKind === 'undefinedBehaviour' || rowKind === 'ub') return 'undefinedBehavior';
|
|
89
90
|
if (rowKind === 'proof' || rowKind === 'proofObligation') return 'obligation';
|