@shapeshift-labs/frontier-swarm 0.5.2 → 0.5.4
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 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -440,6 +440,8 @@ export function createSwarmMergeBundle(input) {
|
|
|
440
440
|
const generatedAt = input.generatedAt ?? Date.now();
|
|
441
441
|
const result = isSwarmJobResult(input.result) ? cloneJsonValue(input.result) : normalizeResult(input.result);
|
|
442
442
|
const job = input.job;
|
|
443
|
+
const inputMetadata = toJsonObject(input.metadata);
|
|
444
|
+
const semanticImport = normalizeSemanticImportSummary(input.semanticImport ?? result.semanticImport ?? inputMetadata?.semanticImport);
|
|
443
445
|
const changedPaths = uniqueStrings(result.changedPaths);
|
|
444
446
|
const changedRegions = uniqueStrings([
|
|
445
447
|
...result.changedRegions,
|
|
@@ -481,7 +483,8 @@ export function createSwarmMergeBundle(input) {
|
|
|
481
483
|
...(input.commit ? { commit: input.commit } : {}),
|
|
482
484
|
staleAgainstHead: input.staleAgainstHead ?? false,
|
|
483
485
|
reasons,
|
|
484
|
-
...(
|
|
486
|
+
...(semanticImport ? { semanticImport } : {}),
|
|
487
|
+
...(inputMetadata ? { metadata: inputMetadata } : {})
|
|
485
488
|
};
|
|
486
489
|
}
|
|
487
490
|
export function createSwarmQueueOverlay(input = {}) {
|
|
@@ -503,6 +506,7 @@ export function createSwarmQueueOverlay(input = {}) {
|
|
|
503
506
|
changedPaths: [...bundle.changedPaths],
|
|
504
507
|
changedRegions: [...bundle.changedRegions],
|
|
505
508
|
reasons: [...bundle.reasons],
|
|
509
|
+
...(bundle.semanticImport ? { semanticImport: cloneJsonValue(bundle.semanticImport) } : {}),
|
|
506
510
|
generatedAt: bundle.generatedAt
|
|
507
511
|
});
|
|
508
512
|
}
|
|
@@ -523,6 +527,7 @@ export function createSwarmQueueOverlay(input = {}) {
|
|
|
523
527
|
changedPaths: [...result.changedPaths],
|
|
524
528
|
changedRegions: [...result.changedRegions],
|
|
525
529
|
reasons: result.error ? [result.error] : [],
|
|
530
|
+
...(result.semanticImport ? { semanticImport: cloneJsonValue(result.semanticImport) } : {}),
|
|
526
531
|
generatedAt
|
|
527
532
|
});
|
|
528
533
|
}
|
|
@@ -571,6 +576,7 @@ export function deriveSwarmQueueStatus(input) {
|
|
|
571
576
|
overlayStatus: overlay.status,
|
|
572
577
|
mergeDisposition: overlay.disposition,
|
|
573
578
|
mergeReadiness: overlay.mergeReadiness,
|
|
579
|
+
...(overlay.semanticImport ? { semanticImport: overlay.semanticImport } : {}),
|
|
574
580
|
evidencePaths: overlay.evidencePaths
|
|
575
581
|
})
|
|
576
582
|
};
|
|
@@ -619,6 +625,7 @@ export function createSwarmMergeIndex(input) {
|
|
|
619
625
|
evidencePaths: [...bundle.evidencePaths],
|
|
620
626
|
queueItemIds: [...bundle.queueItemIds],
|
|
621
627
|
reasons: uniqueStrings([...bundle.reasons, ...(staleAgainstHead ? ['stale-against-head'] : [])]),
|
|
628
|
+
...(bundle.semanticImport ? { semanticImport: cloneJsonValue(bundle.semanticImport) } : {}),
|
|
622
629
|
generatedAt: bundle.generatedAt
|
|
623
630
|
};
|
|
624
631
|
});
|
|
@@ -3143,10 +3150,94 @@ function queueJobsFromPlan(plan, run, leases) {
|
|
|
3143
3150
|
});
|
|
3144
3151
|
});
|
|
3145
3152
|
}
|
|
3153
|
+
function normalizeSemanticImportSummary(input) {
|
|
3154
|
+
const object = toJsonObject(input);
|
|
3155
|
+
if (!object)
|
|
3156
|
+
return undefined;
|
|
3157
|
+
const metadata = toJsonObject(object.metadata);
|
|
3158
|
+
return {
|
|
3159
|
+
total: nonNegativeCount(object.total),
|
|
3160
|
+
selected: nonNegativeCount(object.selected),
|
|
3161
|
+
eligible: nonNegativeCount(object.eligible),
|
|
3162
|
+
omitted: nonNegativeCount(object.omitted),
|
|
3163
|
+
imported: nonNegativeCount(object.imported),
|
|
3164
|
+
skipped: nonNegativeCount(object.skipped),
|
|
3165
|
+
errors: nonNegativeCount(object.errors),
|
|
3166
|
+
sourceMapCount: nonNegativeCount(object.sourceMapCount),
|
|
3167
|
+
sourceMapMappingCount: nonNegativeCount(object.sourceMapMappingCount),
|
|
3168
|
+
lossCount: nonNegativeCount(object.lossCount),
|
|
3169
|
+
lossesBySeverity: normalizeCounterRecord(object.lossesBySeverity),
|
|
3170
|
+
semanticIndex: normalizeSemanticIndexSummary(object.semanticIndex),
|
|
3171
|
+
semanticSidecars: normalizeSemanticSidecarSummary(object.semanticSidecars),
|
|
3172
|
+
sourceProjections: normalizeSourceProjectionSummary(object.sourceProjections),
|
|
3173
|
+
nativeCompiles: normalizeNativeCompileSummary(object.nativeCompiles),
|
|
3174
|
+
readiness: normalizeCounterRecord(object.readiness),
|
|
3175
|
+
...(metadata ? { metadata } : {})
|
|
3176
|
+
};
|
|
3177
|
+
}
|
|
3178
|
+
function normalizeSemanticIndexSummary(input) {
|
|
3179
|
+
const object = toJsonObject(input);
|
|
3180
|
+
return {
|
|
3181
|
+
documents: nonNegativeCount(object?.documents),
|
|
3182
|
+
symbols: nonNegativeCount(object?.symbols),
|
|
3183
|
+
occurrences: nonNegativeCount(object?.occurrences),
|
|
3184
|
+
relations: nonNegativeCount(object?.relations),
|
|
3185
|
+
facts: nonNegativeCount(object?.facts)
|
|
3186
|
+
};
|
|
3187
|
+
}
|
|
3188
|
+
function normalizeSemanticSidecarSummary(input) {
|
|
3189
|
+
const object = toJsonObject(input);
|
|
3190
|
+
return {
|
|
3191
|
+
total: nonNegativeCount(object?.total),
|
|
3192
|
+
symbols: nonNegativeCount(object?.symbols),
|
|
3193
|
+
ownershipRegions: nonNegativeCount(object?.ownershipRegions),
|
|
3194
|
+
patchHints: nonNegativeCount(object?.patchHints),
|
|
3195
|
+
empty: nonNegativeCount(object?.empty)
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
function normalizeSourceProjectionSummary(input) {
|
|
3199
|
+
const object = toJsonObject(input);
|
|
3200
|
+
return {
|
|
3201
|
+
total: nonNegativeCount(object?.total),
|
|
3202
|
+
preserved: nonNegativeCount(object?.preserved),
|
|
3203
|
+
stubs: nonNegativeCount(object?.stubs),
|
|
3204
|
+
ready: nonNegativeCount(object?.ready),
|
|
3205
|
+
needsReview: nonNegativeCount(object?.needsReview),
|
|
3206
|
+
blocked: nonNegativeCount(object?.blocked)
|
|
3207
|
+
};
|
|
3208
|
+
}
|
|
3209
|
+
function normalizeNativeCompileSummary(input) {
|
|
3210
|
+
const object = toJsonObject(input);
|
|
3211
|
+
return {
|
|
3212
|
+
total: nonNegativeCount(object?.total),
|
|
3213
|
+
emitted: nonNegativeCount(object?.emitted),
|
|
3214
|
+
preserved: nonNegativeCount(object?.preserved),
|
|
3215
|
+
targetStubs: nonNegativeCount(object?.targetStubs),
|
|
3216
|
+
ready: nonNegativeCount(object?.ready),
|
|
3217
|
+
needsReview: nonNegativeCount(object?.needsReview),
|
|
3218
|
+
blocked: nonNegativeCount(object?.blocked)
|
|
3219
|
+
};
|
|
3220
|
+
}
|
|
3221
|
+
function normalizeCounterRecord(input) {
|
|
3222
|
+
const object = toJsonObject(input);
|
|
3223
|
+
if (!object)
|
|
3224
|
+
return {};
|
|
3225
|
+
const entries = Object.entries(object)
|
|
3226
|
+
.map(([key, value]) => [key, nonNegativeCount(value)])
|
|
3227
|
+
.filter(([, value]) => value > 0)
|
|
3228
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
3229
|
+
return Object.fromEntries(entries);
|
|
3230
|
+
}
|
|
3231
|
+
function nonNegativeCount(value) {
|
|
3232
|
+
const number = typeof value === 'number' ? value : Number(value);
|
|
3233
|
+
return Number.isFinite(number) && number > 0 ? Math.floor(number) : 0;
|
|
3234
|
+
}
|
|
3146
3235
|
function normalizeResult(input) {
|
|
3147
3236
|
const startedAt = input.startedAt;
|
|
3148
3237
|
const finishedAt = input.finishedAt;
|
|
3149
3238
|
const status = input.status ?? (input.exitCode === 0 || input.exitCode === undefined ? 'completed' : 'failed');
|
|
3239
|
+
const inputMetadata = toJsonObject(input.metadata);
|
|
3240
|
+
const semanticImport = normalizeSemanticImportSummary(input.semanticImport ?? inputMetadata?.semanticImport);
|
|
3150
3241
|
return {
|
|
3151
3242
|
jobId: input.jobId,
|
|
3152
3243
|
status,
|
|
@@ -3165,9 +3256,10 @@ function normalizeResult(input) {
|
|
|
3165
3256
|
riskLevel: input.riskLevel ?? 'unknown',
|
|
3166
3257
|
mergeDisposition: input.mergeDisposition ?? classifySwarmMergeDisposition({ ...input, status }),
|
|
3167
3258
|
verification: (input.verification ?? []).map(normalizeVerificationResult),
|
|
3259
|
+
...(semanticImport ? { semanticImport } : {}),
|
|
3168
3260
|
...(input.lastMessage ? { lastMessage: input.lastMessage } : {}),
|
|
3169
3261
|
...(input.error !== undefined ? { error: stringifyError(input.error) } : {}),
|
|
3170
|
-
...(
|
|
3262
|
+
...(inputMetadata ? { metadata: inputMetadata } : {})
|
|
3171
3263
|
};
|
|
3172
3264
|
}
|
|
3173
3265
|
function isSwarmJobResult(value) {
|