@shapeshift-labs/frontier-swarm 0.5.2 → 0.5.3
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 +89 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +81 -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,81 @@ 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
|
+
readiness: normalizeCounterRecord(object.readiness),
|
|
3174
|
+
...(metadata ? { metadata } : {})
|
|
3175
|
+
};
|
|
3176
|
+
}
|
|
3177
|
+
function normalizeSemanticIndexSummary(input) {
|
|
3178
|
+
const object = toJsonObject(input);
|
|
3179
|
+
return {
|
|
3180
|
+
documents: nonNegativeCount(object?.documents),
|
|
3181
|
+
symbols: nonNegativeCount(object?.symbols),
|
|
3182
|
+
occurrences: nonNegativeCount(object?.occurrences),
|
|
3183
|
+
relations: nonNegativeCount(object?.relations),
|
|
3184
|
+
facts: nonNegativeCount(object?.facts)
|
|
3185
|
+
};
|
|
3186
|
+
}
|
|
3187
|
+
function normalizeSemanticSidecarSummary(input) {
|
|
3188
|
+
const object = toJsonObject(input);
|
|
3189
|
+
return {
|
|
3190
|
+
total: nonNegativeCount(object?.total),
|
|
3191
|
+
symbols: nonNegativeCount(object?.symbols),
|
|
3192
|
+
ownershipRegions: nonNegativeCount(object?.ownershipRegions),
|
|
3193
|
+
patchHints: nonNegativeCount(object?.patchHints),
|
|
3194
|
+
empty: nonNegativeCount(object?.empty)
|
|
3195
|
+
};
|
|
3196
|
+
}
|
|
3197
|
+
function normalizeSourceProjectionSummary(input) {
|
|
3198
|
+
const object = toJsonObject(input);
|
|
3199
|
+
return {
|
|
3200
|
+
total: nonNegativeCount(object?.total),
|
|
3201
|
+
preserved: nonNegativeCount(object?.preserved),
|
|
3202
|
+
stubs: nonNegativeCount(object?.stubs),
|
|
3203
|
+
ready: nonNegativeCount(object?.ready),
|
|
3204
|
+
needsReview: nonNegativeCount(object?.needsReview),
|
|
3205
|
+
blocked: nonNegativeCount(object?.blocked)
|
|
3206
|
+
};
|
|
3207
|
+
}
|
|
3208
|
+
function normalizeCounterRecord(input) {
|
|
3209
|
+
const object = toJsonObject(input);
|
|
3210
|
+
if (!object)
|
|
3211
|
+
return {};
|
|
3212
|
+
const entries = Object.entries(object)
|
|
3213
|
+
.map(([key, value]) => [key, nonNegativeCount(value)])
|
|
3214
|
+
.filter(([, value]) => value > 0)
|
|
3215
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
3216
|
+
return Object.fromEntries(entries);
|
|
3217
|
+
}
|
|
3218
|
+
function nonNegativeCount(value) {
|
|
3219
|
+
const number = typeof value === 'number' ? value : Number(value);
|
|
3220
|
+
return Number.isFinite(number) && number > 0 ? Math.floor(number) : 0;
|
|
3221
|
+
}
|
|
3146
3222
|
function normalizeResult(input) {
|
|
3147
3223
|
const startedAt = input.startedAt;
|
|
3148
3224
|
const finishedAt = input.finishedAt;
|
|
3149
3225
|
const status = input.status ?? (input.exitCode === 0 || input.exitCode === undefined ? 'completed' : 'failed');
|
|
3226
|
+
const inputMetadata = toJsonObject(input.metadata);
|
|
3227
|
+
const semanticImport = normalizeSemanticImportSummary(input.semanticImport ?? inputMetadata?.semanticImport);
|
|
3150
3228
|
return {
|
|
3151
3229
|
jobId: input.jobId,
|
|
3152
3230
|
status,
|
|
@@ -3165,9 +3243,10 @@ function normalizeResult(input) {
|
|
|
3165
3243
|
riskLevel: input.riskLevel ?? 'unknown',
|
|
3166
3244
|
mergeDisposition: input.mergeDisposition ?? classifySwarmMergeDisposition({ ...input, status }),
|
|
3167
3245
|
verification: (input.verification ?? []).map(normalizeVerificationResult),
|
|
3246
|
+
...(semanticImport ? { semanticImport } : {}),
|
|
3168
3247
|
...(input.lastMessage ? { lastMessage: input.lastMessage } : {}),
|
|
3169
3248
|
...(input.error !== undefined ? { error: stringifyError(input.error) } : {}),
|
|
3170
|
-
...(
|
|
3249
|
+
...(inputMetadata ? { metadata: inputMetadata } : {})
|
|
3171
3250
|
};
|
|
3172
3251
|
}
|
|
3173
3252
|
function isSwarmJobResult(value) {
|