@shapeshift-labs/frontier-lang-compiler 0.2.114 → 0.2.115
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
|
@@ -242,6 +242,8 @@ Named re-export identities also include symbol links when the project graph has
|
|
|
242
242
|
enough evidence. For `export { thing as renamedThing } from './thing.js'`,
|
|
243
243
|
`reExportIdentities[]` records the source module, imported/exported names,
|
|
244
244
|
`originSymbolId`, `exportedSymbolId`, and `localSymbolId`.
|
|
245
|
+
Public contract regions include `apiSurfaceKind`, `signatureHash`, and
|
|
246
|
+
`contractHash`, giving merge admission a stable API surface fingerprint.
|
|
245
247
|
|
|
246
248
|
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.
|
|
247
249
|
|
|
@@ -82,9 +82,6 @@ export type NativeProjectSymbolGraphRemainingField =
|
|
|
82
82
|
| 'reExportIdentities[].originSymbolId'
|
|
83
83
|
| 'reExportIdentities[].exportedSymbolId'
|
|
84
84
|
| 'reExportIdentities[].localSymbolId'
|
|
85
|
-
| 'publicContractRegions[].apiSurfaceKind'
|
|
86
|
-
| 'publicContractRegions[].signatureHash'
|
|
87
|
-
| 'publicContractRegions[].contractHash'
|
|
88
85
|
| string;
|
|
89
86
|
|
|
90
87
|
export interface NativeProjectSymbolGraphFileHashRecord {
|
|
@@ -158,6 +155,9 @@ export interface NativeProjectSymbolGraphPublicContractRegionRecord {
|
|
|
158
155
|
readonly symbolId?: string;
|
|
159
156
|
readonly symbolName?: string;
|
|
160
157
|
readonly symbolKind?: string;
|
|
158
|
+
readonly apiSurfaceKind?: string;
|
|
159
|
+
readonly signatureHash?: string;
|
|
160
|
+
readonly contractHash?: string;
|
|
161
161
|
readonly nativeAstNodeId?: string;
|
|
162
162
|
readonly sourceSpan?: SourceSpan;
|
|
163
163
|
readonly precision?: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import{idFragment,uniqueByEvidenceId,uniqueByLossId,uniqueStrings}from'../../native-import-utils.js';import{createDocument,createPatch,createUniversalAstEnvelope}from'@shapeshift-labs/frontier-lang-kernel';
|
|
2
2
|
import{createNativeImportResultContract}from'./createNativeImportResultContract.js';import{createProjectImportAdmissionRecord}from'./createProjectImportAdmissionRecord.js';import{mergeSemanticIndexes}from'./mergeSemanticIndexes.js';import{summarizeNativeImportLosses}from'./summarizeNativeImportLosses.js';import{summarizeProjectSourcePreservation}from'./summarizeProjectSourcePreservation.js';
|
|
3
3
|
import{createProjectDocumentExportSymbolResolver,createProjectModuleSymbolResolver,resolveProjectModule}from'./projectSymbolGraphModuleResolution.js';
|
|
4
|
+
import{publicContractRegionRecord}from'./projectSymbolGraphPublicContracts.js';
|
|
4
5
|
import{isReExportImportEdge,reExportIdentityInputFromEdge,reExportIdentityRecord}from'./projectSymbolGraphReExports.js';
|
|
5
6
|
export function createNativeProjectImportResult(input, imports) {
|
|
6
7
|
const idPart = idFragment(input.id ?? input.projectRoot ?? 'native_project');
|
|
@@ -144,10 +145,7 @@ export function createNativeProjectImportResult(input, imports) {
|
|
|
144
145
|
const PROJECT_SYMBOL_GRAPH_REMAINING_FIELDS = Object.freeze([
|
|
145
146
|
'reExportIdentities[].originSymbolId',
|
|
146
147
|
'reExportIdentities[].exportedSymbolId',
|
|
147
|
-
'reExportIdentities[].localSymbolId'
|
|
148
|
-
'publicContractRegions[].apiSurfaceKind',
|
|
149
|
-
'publicContractRegions[].signatureHash',
|
|
150
|
-
'publicContractRegions[].contractHash'
|
|
148
|
+
'reExportIdentities[].localSymbolId'
|
|
151
149
|
]);
|
|
152
150
|
|
|
153
151
|
function createProjectSymbolGraphSummary(semanticIndex, imports, input) {
|
|
@@ -182,7 +180,7 @@ function createProjectSymbolGraphSummary(semanticIndex, imports, input) {
|
|
|
182
180
|
]);
|
|
183
181
|
const publicContractRegions = uniqueRecords(facts
|
|
184
182
|
.filter((fact) => fact.predicate === 'publicContractRegion' && fact.value)
|
|
185
|
-
.map((fact) => (
|
|
183
|
+
.map((fact) => publicContractRegionRecord(objectValue(fact.value), fact, symbolsById.get(fact.subjectId))));
|
|
186
184
|
const fileHashes = uniqueRecords([
|
|
187
185
|
...documents.map((document) => fileHashRecord(document)),
|
|
188
186
|
...facts
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import{hashSemanticValue}from'@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
|
|
3
|
+
export function publicContractRegionRecord(value, fact, symbol) {
|
|
4
|
+
const record = {
|
|
5
|
+
...value,
|
|
6
|
+
factId: fact.id,
|
|
7
|
+
symbolId: fact.subjectId,
|
|
8
|
+
apiSurfaceKind: value.apiSurfaceKind ?? apiSurfaceKind(value, symbol),
|
|
9
|
+
signatureHash: value.signatureHash ?? symbol?.signatureHash
|
|
10
|
+
};
|
|
11
|
+
return compactRecord({
|
|
12
|
+
...record,
|
|
13
|
+
contractHash: value.contractHash ?? publicContractHash(record)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function apiSurfaceKind(region, symbol) {
|
|
18
|
+
if (region.edgeKind === 're-export') return 'module-re-export';
|
|
19
|
+
if (region.edgeKind === 'export') return 'module-export';
|
|
20
|
+
if (symbol?.kind === 'export') return 'named-export';
|
|
21
|
+
return region.symbolKind ?? symbol?.kind ?? region.regionKind;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function publicContractHash(region) {
|
|
25
|
+
return hashSemanticValue({
|
|
26
|
+
kind: 'frontier.lang.publicContractRegionHash',
|
|
27
|
+
sourceHash: region.sourceHash,
|
|
28
|
+
symbolId: region.symbolId,
|
|
29
|
+
symbolName: region.symbolName,
|
|
30
|
+
symbolKind: region.symbolKind,
|
|
31
|
+
signatureHash: region.signatureHash,
|
|
32
|
+
moduleSpecifier: region.moduleSpecifier,
|
|
33
|
+
exportedName: region.exportedName,
|
|
34
|
+
edgeKind: region.edgeKind,
|
|
35
|
+
apiSurfaceKind: region.apiSurfaceKind
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function compactRecord(record) {
|
|
40
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
41
|
+
}
|
package/package.json
CHANGED