@shapeshift-labs/frontier-lang-compiler 0.2.137 → 0.2.139
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
|
@@ -200,6 +200,10 @@ interface, type, class, or object member additions. Existing class/object method
|
|
|
200
200
|
or property body edits inside the declared member region are preserved for
|
|
201
201
|
semantic replay while added members are neutralized; object member additions are
|
|
202
202
|
re-emitted with safe commas when both sides add final properties.
|
|
203
|
+
If staged whole-declaration replay cannot verify because head changed a sibling
|
|
204
|
+
member inside the same declaration, `safeMergeJsTsSource` retries the direct
|
|
205
|
+
semantic edit projection and admits the merge only when replay still verifies
|
|
206
|
+
cleanly.
|
|
203
207
|
|
|
204
208
|
Project-level JS/TS safe merges compose the same file-level gates across a
|
|
205
209
|
base/worker/head file set. They preserve head-only files, admit worker-only
|
|
@@ -14,9 +14,17 @@ import { idFragment, uniqueStrings } from './native-import-utils.js';
|
|
|
14
14
|
function semanticEditFallbackResult(input, topLevelResult) {
|
|
15
15
|
if (!shouldTrySemanticEditFallback(topLevelResult)) return topLevelResult;
|
|
16
16
|
const stagedFallback = createStagedTopLevelSemanticFallback(input, topLevelResult);
|
|
17
|
-
|
|
17
|
+
let selectedFallback = stagedFallback;
|
|
18
|
+
let artifacts = createSemanticEditFallbackArtifacts(input, topLevelResult, stagedFallback);
|
|
19
|
+
if (stagedFallback && artifacts.status !== 'verified') {
|
|
20
|
+
const directArtifacts = createSemanticEditFallbackArtifacts(input, topLevelResult, undefined);
|
|
21
|
+
if (directArtifacts.status === 'verified') {
|
|
22
|
+
artifacts = directArtifacts;
|
|
23
|
+
selectedFallback = undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
18
26
|
if (artifacts.status !== 'verified') return semanticEditFallbackBlockedResult(input, topLevelResult, artifacts);
|
|
19
|
-
const resultBase =
|
|
27
|
+
const resultBase = selectedFallback?.stagedTopLevelResult ?? topLevelResult;
|
|
20
28
|
const mergedSourceText = artifacts.projection.sourceText;
|
|
21
29
|
const gates = semanticEditGates(artifacts);
|
|
22
30
|
return {
|
|
@@ -38,7 +46,7 @@ function semanticEditFallbackResult(input, topLevelResult) {
|
|
|
38
46
|
},
|
|
39
47
|
summary: {
|
|
40
48
|
...resultBase.summary,
|
|
41
|
-
changedExistingDeclarations: topLevelResult
|
|
49
|
+
changedExistingDeclarations: semanticFallbackChangedExistingDeclarations(topLevelResult, resultBase, selectedFallback),
|
|
42
50
|
conflicts: 0,
|
|
43
51
|
gatesPassed: gates.filter((gate) => gate.status === 'passed').length,
|
|
44
52
|
semanticEditOperations: artifacts.script.summary.operations,
|
|
@@ -49,11 +57,11 @@ function semanticEditFallbackResult(input, topLevelResult) {
|
|
|
49
57
|
metadata: {
|
|
50
58
|
...resultBase.metadata,
|
|
51
59
|
composed: {
|
|
52
|
-
phase:
|
|
53
|
-
phases:
|
|
60
|
+
phase: selectedFallback ? 'staged-top-level-semantic-edit-fallback' : 'semantic-edit-fallback',
|
|
61
|
+
phases: selectedFallback ? ['top-level-neutralization', 'top-level-ledger', 'semantic-edit'] : ['top-level-ledger', 'semantic-edit'],
|
|
54
62
|
originalReasonCodes: topLevelResult.admission?.reasonCodes ?? [],
|
|
55
|
-
stagedTopLevelSummary:
|
|
56
|
-
neutralization:
|
|
63
|
+
stagedTopLevelSummary: selectedFallback?.stagedTopLevelResult?.summary,
|
|
64
|
+
neutralization: selectedFallback?.neutralization?.summary
|
|
57
65
|
}
|
|
58
66
|
},
|
|
59
67
|
semanticArtifacts: artifacts
|
|
@@ -62,7 +70,28 @@ function semanticEditFallbackResult(input, topLevelResult) {
|
|
|
62
70
|
|
|
63
71
|
function shouldTrySemanticEditFallback(result) {
|
|
64
72
|
const conflicts = result.conflicts ?? [];
|
|
65
|
-
return conflicts.length > 0 && conflicts.every((conflict) => conflict.code
|
|
73
|
+
return conflicts.length > 0 && conflicts.every((conflict) => semanticFallbackConflictCodes.has(conflict.code));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const semanticFallbackConflictCodes = new Set([
|
|
77
|
+
JsTsSafeMergeConflictCodes.changedExistingDeclaration,
|
|
78
|
+
JsTsSafeMergeConflictCodes.typeAliasConflict
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
function semanticFallbackConflictCode(result) {
|
|
82
|
+
return result.conflicts?.find((conflict) => semanticFallbackConflictCodes.has(conflict.code))?.code
|
|
83
|
+
?? JsTsSafeMergeConflictCodes.changedExistingDeclaration;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function semanticFallbackChangedExistingDeclarations(topLevelResult, resultBase, stagedFallback) {
|
|
87
|
+
const conflictCount = (topLevelResult.conflicts ?? [])
|
|
88
|
+
.filter((conflict) => semanticFallbackConflictCodes.has(conflict.code)).length;
|
|
89
|
+
return Math.max(
|
|
90
|
+
topLevelResult.summary?.changedExistingDeclarations ?? 0,
|
|
91
|
+
resultBase?.summary?.changedExistingDeclarations ?? 0,
|
|
92
|
+
stagedFallback?.neutralization?.summary?.workerChangedExistingDeclarations ?? 0,
|
|
93
|
+
conflictCount
|
|
94
|
+
);
|
|
66
95
|
}
|
|
67
96
|
|
|
68
97
|
function createSemanticEditFallbackArtifacts(input, topLevelResult, stagedFallback) {
|
|
@@ -240,7 +269,7 @@ function semanticEditFallbackBlockedResult(input, topLevelResult, artifacts) {
|
|
|
240
269
|
: topLevelResult.admission?.reasonCodes ?? [];
|
|
241
270
|
const gates = semanticEditGates(artifacts);
|
|
242
271
|
const conflict = {
|
|
243
|
-
code:
|
|
272
|
+
code: semanticFallbackConflictCode(topLevelResult),
|
|
244
273
|
gateId: 'semantic-edit-replay',
|
|
245
274
|
message: 'JS/TS semantic edit fallback did not verify a clean replay.',
|
|
246
275
|
side: 'worker',
|
|
@@ -262,6 +291,7 @@ function semanticEditFallbackBlockedResult(input, topLevelResult, artifacts) {
|
|
|
262
291
|
},
|
|
263
292
|
summary: {
|
|
264
293
|
...topLevelResult.summary,
|
|
294
|
+
changedExistingDeclarations: semanticFallbackChangedExistingDeclarations(topLevelResult, topLevelResult),
|
|
265
295
|
conflicts: 1,
|
|
266
296
|
gatesPassed: gates.filter((gate) => gate.status === 'passed').length,
|
|
267
297
|
semanticEditOperations: artifacts.summary.operations,
|
package/package.json
CHANGED