@codyswann/lisa 4.106.0 → 4.106.2
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/core/lisa.d.ts +21 -0
- package/dist/core/lisa.d.ts.map +1 -1
- package/dist/core/lisa.js +48 -0
- package/dist/core/lisa.js.map +1 -1
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +36 -11
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/dist/sonar/sonar-shim-fs.d.ts +32 -0
- package/dist/sonar/sonar-shim-fs.d.ts.map +1 -0
- package/dist/sonar/sonar-shim-fs.js +70 -0
- package/dist/sonar/sonar-shim-fs.js.map +1 -0
- package/dist/sonar/sonar-shim-repoint.d.ts +71 -0
- package/dist/sonar/sonar-shim-repoint.d.ts.map +1 -0
- package/dist/sonar/sonar-shim-repoint.js +221 -0
- package/dist/sonar/sonar-shim-repoint.js.map +1 -0
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +9 -3
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/workers.mjs +10 -5
- package/plugins/lisa/skills/lisa-session-manager/SKILL.md +9 -3
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
- package/plugins/lisa/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
- package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
- package/plugins/lisa/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/workers.mjs +10 -5
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +9 -3
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/workers.mjs +10 -5
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +9 -3
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/workers.mjs +10 -5
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +9 -3
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/workers.mjs +10 -5
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +9 -3
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/workers.mjs +10 -5
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/skills/lisa-session-manager/SKILL.md +9 -3
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
- package/plugins/src/base/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
- package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
- package/plugins/src/base/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/workers.mjs +10 -5
- package/scripts/check-shell-guard-refusal-coverage.mjs +9 -3
- package/scripts/lib/shell-guard-shard-runner.mjs +40 -35
- package/scripts/lib/shell-guard-shards.mjs +176 -11
|
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
|
|
|
3
3
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
4
4
|
import {
|
|
5
5
|
closeSync,
|
|
6
|
+
existsSync,
|
|
6
7
|
lstatSync,
|
|
7
8
|
mkdirSync,
|
|
8
9
|
openSync,
|
|
@@ -19,9 +20,10 @@ import {
|
|
|
19
20
|
} from "./shell-guard-refusal-coverage.mjs";
|
|
20
21
|
import {
|
|
21
22
|
identityHash,
|
|
22
|
-
|
|
23
|
+
mergeShardDirectories,
|
|
23
24
|
nativeArgv,
|
|
24
25
|
parseShard,
|
|
26
|
+
RERUN_ALL,
|
|
25
27
|
sha256,
|
|
26
28
|
validateBundle,
|
|
27
29
|
validateSnapshot,
|
|
@@ -300,6 +302,28 @@ export function collectShard(root, discover, args) {
|
|
|
300
302
|
);
|
|
301
303
|
}
|
|
302
304
|
|
|
305
|
+
/**
|
|
306
|
+
* Read one downloaded shard directory. Null when it holds no manifest.json:
|
|
307
|
+
* a failed shard still uploads its logs and execution.json for diagnosis.
|
|
308
|
+
*/
|
|
309
|
+
function readBundle(base) {
|
|
310
|
+
assert(realpathSync(base) === base, "symlinked shard bundle directory");
|
|
311
|
+
const manifestPath = path.join(base, "manifest.json");
|
|
312
|
+
if (!existsSync(manifestPath)) return null;
|
|
313
|
+
const manifestRaw = bytes(manifestPath).toString("utf8");
|
|
314
|
+
return {
|
|
315
|
+
manifest: JSON.parse(manifestRaw),
|
|
316
|
+
manifestRaw,
|
|
317
|
+
traceRaw: bytes(path.join(base, "trace.jsonl")).toString("utf8"),
|
|
318
|
+
reportRaw: bytes(path.join(base, "results.json")).toString("utf8"),
|
|
319
|
+
terminalRaw: bytes(path.join(base, "terminal.json")).toString("utf8"),
|
|
320
|
+
indexRaw: bytes(path.join(base, INDEX_FILE)).toString("utf8"),
|
|
321
|
+
executionRaw: bytes(path.join(base, EXECUTION_FILE)).toString("utf8"),
|
|
322
|
+
stdoutRaw: bytes(path.join(base, STDOUT_FILE)),
|
|
323
|
+
stderrRaw: bytes(path.join(base, STDERR_FILE)),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
303
327
|
export function mergeCollected(root, discover, args) {
|
|
304
328
|
assert(
|
|
305
329
|
!args.includes("--collect-only") &&
|
|
@@ -313,42 +337,21 @@ export function mergeCollected(root, discover, args) {
|
|
|
313
337
|
lstatSync(directory).isDirectory(),
|
|
314
338
|
"explicit owned download directory required"
|
|
315
339
|
);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
entries.length === 3 &&
|
|
321
|
-
entries.every(
|
|
322
|
-
entry =>
|
|
323
|
-
entry.isDirectory() &&
|
|
324
|
-
[1, 2, 3].some(index => entry.name === prefix + index)
|
|
325
|
-
),
|
|
326
|
-
"missing/extra/nonowned/stale-attempt shard bundle"
|
|
327
|
-
);
|
|
328
|
-
const bundles = entries.map(entry => {
|
|
329
|
-
const base = path.join(directory, entry.name);
|
|
330
|
-
assert(realpathSync(base) === base);
|
|
331
|
-
const manifestRaw = bytes(path.join(base, "manifest.json")).toString(
|
|
332
|
-
"utf8"
|
|
333
|
-
);
|
|
334
|
-
const manifest = JSON.parse(manifestRaw);
|
|
340
|
+
// #4634: the download holds every attempt of this run. A failed-jobs re-run
|
|
341
|
+
// rebuilds only the failed shard, so the newest complete bundle per shard is
|
|
342
|
+
// merged; selection and every refusal live in mergeShardDirectories.
|
|
343
|
+
const entries = readdirSync(directory, { withFileTypes: true }).map(entry => {
|
|
335
344
|
assert(
|
|
336
|
-
entry.
|
|
337
|
-
|
|
345
|
+
entry.isDirectory(),
|
|
346
|
+
`download entry ${JSON.stringify(entry.name)} is not a shard bundle directory. ${RERUN_ALL}`
|
|
338
347
|
);
|
|
339
348
|
return {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
traceRaw: bytes(path.join(base, "trace.jsonl")).toString("utf8"),
|
|
343
|
-
reportRaw: bytes(path.join(base, "results.json")).toString("utf8"),
|
|
344
|
-
terminalRaw: bytes(path.join(base, "terminal.json")).toString("utf8"),
|
|
345
|
-
indexRaw: bytes(path.join(base, INDEX_FILE)).toString("utf8"),
|
|
346
|
-
executionRaw: bytes(path.join(base, EXECUTION_FILE)).toString("utf8"),
|
|
347
|
-
stdoutRaw: bytes(path.join(base, STDOUT_FILE)),
|
|
348
|
-
stderrRaw: bytes(path.join(base, STDERR_FILE)),
|
|
349
|
+
name: entry.name,
|
|
350
|
+
read: () => readBundle(path.join(directory, entry.name)),
|
|
349
351
|
};
|
|
350
352
|
});
|
|
351
|
-
const
|
|
353
|
+
const current = snapshot(root, discover);
|
|
354
|
+
const { trace, selected } = mergeShardDirectories(current, entries);
|
|
352
355
|
const target = path.resolve(root, value(args, "--trace-out"));
|
|
353
356
|
mkdirSync(path.dirname(target), { recursive: true });
|
|
354
357
|
// Aggregate provenance says complete shards were validated, not that guards passed.
|
|
@@ -357,14 +360,16 @@ export function mergeCollected(root, discover, args) {
|
|
|
357
360
|
snapshot: current,
|
|
358
361
|
traceSha256: sha256(trace),
|
|
359
362
|
reportedFileCount: current.candidates.length,
|
|
360
|
-
shards:
|
|
361
|
-
index
|
|
363
|
+
shards: selected.map(({ index, attempt, name, bundle }) => ({
|
|
364
|
+
index,
|
|
365
|
+
attempt,
|
|
366
|
+
artifact: name,
|
|
362
367
|
manifestSha256: sha256(bundle.manifestRaw),
|
|
363
368
|
producerJob: bundle.manifest.producerJob,
|
|
364
369
|
child: bundle.manifest.child,
|
|
365
370
|
})),
|
|
366
371
|
scope:
|
|
367
|
-
"complete current
|
|
372
|
+
"newest complete native shard per index of the current run validated; ONE existing guard judgment remains required",
|
|
368
373
|
providerArtifactDigestVerified: false,
|
|
369
374
|
};
|
|
370
375
|
writeFileSync(target, trace);
|
|
@@ -229,6 +229,56 @@ export function nativeArgv(root, artifactRoot, shard, candidates) {
|
|
|
229
229
|
];
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
/*
|
|
233
|
+
* #4634: a failed-jobs re-run is a new Actions attempt that rebuilds only the
|
|
234
|
+
* failed shard, so a valid merge may combine bundles from different attempts
|
|
235
|
+
* of ONE run. Every refusal names the shard and attempt it judged and the
|
|
236
|
+
* re-run that recovers it, because the operator reading a red check has no
|
|
237
|
+
* other way to know a failed-jobs re-run would be wasted.
|
|
238
|
+
*/
|
|
239
|
+
/** Every recovery hint starts with this; recoverable() keys on it alone. */
|
|
240
|
+
export const RECOVERY_PREFIX = "Recovery: ";
|
|
241
|
+
export const RERUN_FAILED = `${RECOVERY_PREFIX}"Re-run failed jobs" rebuilds only that shard and is enough.`;
|
|
242
|
+
export const RERUN_ALL = `${RECOVERY_PREFIX}"Re-run all jobs" is needed; re-running only failed jobs cannot fix this.`;
|
|
243
|
+
const BUNDLE_NAME = /^lisa-shell-guard-(\d+)-([1-9]\d*)-shard-([1-9]\d*)$/u;
|
|
244
|
+
const RUN_IDENTITY = ["runId", "sourceSha", "prHead", "workflowRef"];
|
|
245
|
+
const shardName = index => `shard ${index}`;
|
|
246
|
+
const label = (index, attempt) => `${shardName(index)} attempt ${attempt}`;
|
|
247
|
+
const bundleLabel = manifest =>
|
|
248
|
+
label(manifest?.shard?.index, manifest?.snapshot?.provider?.attempt);
|
|
249
|
+
/** The snapshot minus the one field a failed-jobs re-run legitimately changes. */
|
|
250
|
+
const withoutAttempt = value => {
|
|
251
|
+
const { attempt: _attempt, ...provider } = value?.provider ?? {};
|
|
252
|
+
return { ...value, provider };
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Bind a bundle to the current run. The attempt may be older than the merge
|
|
257
|
+
* job's own (a re-run keeps earlier attempts' complete shards), never newer;
|
|
258
|
+
* everything else — run, source, PR head, workflow, runtime, roster — must be
|
|
259
|
+
* identical, because a re-run of the same run cannot change any of it.
|
|
260
|
+
*/
|
|
261
|
+
function assertCurrentRun(snapshot, manifest) {
|
|
262
|
+
const where = bundleLabel(manifest);
|
|
263
|
+
const recorded = manifest?.snapshot?.provider ?? {};
|
|
264
|
+
for (const field of RUN_IDENTITY) {
|
|
265
|
+
assert(
|
|
266
|
+
recorded[field] === snapshot.provider[field],
|
|
267
|
+
`${where} records ${field} ${JSON.stringify(recorded[field])}, but the current run has ${JSON.stringify(snapshot.provider[field])}; a foreign or stale bundle cannot be merged. ${RERUN_ALL}`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
assert(
|
|
271
|
+
/^\d+$/u.test(recorded.attempt ?? "") &&
|
|
272
|
+
Number(recorded.attempt) <= Number(snapshot.provider.attempt),
|
|
273
|
+
`${where} is not an attempt at or before the merge job's attempt ${snapshot.provider.attempt}. ${RERUN_ALL}`
|
|
274
|
+
);
|
|
275
|
+
assert.deepEqual(
|
|
276
|
+
withoutAttempt(manifest.snapshot),
|
|
277
|
+
withoutAttempt(snapshot),
|
|
278
|
+
`${where} was built from a different source/runtime/roster identity than the current merge job. ${RERUN_ALL}`
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
232
282
|
export function validateBundle({
|
|
233
283
|
snapshot,
|
|
234
284
|
manifest,
|
|
@@ -241,18 +291,17 @@ export function validateBundle({
|
|
|
241
291
|
stderrRaw,
|
|
242
292
|
}) {
|
|
243
293
|
validateSnapshot(snapshot);
|
|
244
|
-
assert(
|
|
245
|
-
|
|
246
|
-
manifest.
|
|
247
|
-
snapshot,
|
|
248
|
-
"stale source/run/attempt/runtime/roster identity"
|
|
294
|
+
assert(
|
|
295
|
+
manifest && manifest.schema === 1 && manifest.complete === true,
|
|
296
|
+
`${bundleLabel(manifest)} has an incomplete manifest. ${RERUN_FAILED}`
|
|
249
297
|
);
|
|
298
|
+
assertCurrentRun(snapshot, manifest);
|
|
250
299
|
parseShard(`${manifest.shard.index}/${manifest.shard.total}`);
|
|
251
300
|
assert(
|
|
252
301
|
manifest.child.status === 0 &&
|
|
253
302
|
manifest.child.signal === null &&
|
|
254
303
|
manifest.child.error === null,
|
|
255
|
-
|
|
304
|
+
`${bundleLabel(manifest)} child failed/killed/not started. ${RERUN_FAILED}`
|
|
256
305
|
);
|
|
257
306
|
assert(manifest.producerJob === "guard-trace", "wrong native producer job");
|
|
258
307
|
assert(
|
|
@@ -353,17 +402,26 @@ export function mergeBundles(snapshot, bundles) {
|
|
|
353
402
|
validateSnapshot(snapshot);
|
|
354
403
|
assert(
|
|
355
404
|
Array.isArray(bundles) && bundles.length === 3,
|
|
356
|
-
|
|
405
|
+
`all three complete shards required. ${RERUN_FAILED}`
|
|
357
406
|
);
|
|
358
407
|
const seen = new Set(),
|
|
359
408
|
files = new Set(),
|
|
360
409
|
validated = [];
|
|
361
410
|
for (const bundle of bundles) {
|
|
362
|
-
const value =
|
|
363
|
-
|
|
411
|
+
const value = recoverable(bundleLabel(bundle.manifest), () =>
|
|
412
|
+
validateBundle({ ...bundle, snapshot })
|
|
413
|
+
);
|
|
414
|
+
const where = bundleLabel(bundle.manifest);
|
|
415
|
+
assert(
|
|
416
|
+
!seen.has(value.shard.index),
|
|
417
|
+
`duplicate shard identity: ${where}. ${RERUN_ALL}`
|
|
418
|
+
);
|
|
364
419
|
seen.add(value.shard.index);
|
|
365
420
|
for (const file of value.files) {
|
|
366
|
-
assert(
|
|
421
|
+
assert(
|
|
422
|
+
!files.has(file),
|
|
423
|
+
`duplicate reported file across shards: ${where} reports ${file} again. ${RERUN_ALL}`
|
|
424
|
+
);
|
|
367
425
|
files.add(file);
|
|
368
426
|
}
|
|
369
427
|
validated.push(value);
|
|
@@ -372,7 +430,7 @@ export function mergeBundles(snapshot, bundles) {
|
|
|
372
430
|
assert.deepEqual(
|
|
373
431
|
[...files].sort((a, b) => a.localeCompare(b)),
|
|
374
432
|
snapshot.candidates.map(row => row.path),
|
|
375
|
-
|
|
433
|
+
`missing/extra candidate files across ${bundles.map(bundle => bundleLabel(bundle.manifest)).join(", ")}. ${RERUN_ALL}`
|
|
376
434
|
);
|
|
377
435
|
// ONE existing judge receives this trace. Empty individual traces are valid.
|
|
378
436
|
return `${validated
|
|
@@ -381,3 +439,110 @@ export function mergeBundles(snapshot, bundles) {
|
|
|
381
439
|
.filter(Boolean)
|
|
382
440
|
.join("\n")}\n`;
|
|
383
441
|
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* A receipt-integrity refusal deep inside validateBundle (digest, argv,
|
|
445
|
+
* roster) or a missing artifact file does not know which bundle it judged.
|
|
446
|
+
* Name it, and say a full re-run is needed: the bundle's own job succeeded,
|
|
447
|
+
* so a failed-jobs re-run would not rebuild it.
|
|
448
|
+
*/
|
|
449
|
+
function recoverable(where, validate) {
|
|
450
|
+
try {
|
|
451
|
+
return validate();
|
|
452
|
+
} catch (error) {
|
|
453
|
+
if (String(error?.message ?? "").includes(RECOVERY_PREFIX)) throw error;
|
|
454
|
+
throw new Error(
|
|
455
|
+
`${where}: ${error?.message ?? String(error)}. ${RERUN_ALL}`,
|
|
456
|
+
{ cause: error }
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** Parse `lisa-shell-guard-<run>-<attempt>-shard-<index>` against this run. */
|
|
462
|
+
function parseBundleName(name, provider) {
|
|
463
|
+
const match = BUNDLE_NAME.exec(name);
|
|
464
|
+
assert(
|
|
465
|
+
match,
|
|
466
|
+
`download directory ${JSON.stringify(name)} is not a shell-guard shard bundle of run ${provider.runId}. ${RERUN_ALL}`
|
|
467
|
+
);
|
|
468
|
+
const [, runId, attemptText, indexText] = match;
|
|
469
|
+
const attempt = Number(attemptText),
|
|
470
|
+
index = Number(indexText);
|
|
471
|
+
const where = label(index, attempt);
|
|
472
|
+
assert(
|
|
473
|
+
runId === provider.runId,
|
|
474
|
+
`${where} (${name}) belongs to run ${runId}, not the current run ${provider.runId}. ${RERUN_ALL}`
|
|
475
|
+
);
|
|
476
|
+
assert(
|
|
477
|
+
index <= 3,
|
|
478
|
+
`${where} (${name}) is not one of shards 1-3. ${RERUN_ALL}`
|
|
479
|
+
);
|
|
480
|
+
assert(
|
|
481
|
+
attempt <= Number(provider.attempt),
|
|
482
|
+
`${where} (${name}) is newer than the merge job's attempt ${provider.attempt}. ${RERUN_ALL}`
|
|
483
|
+
);
|
|
484
|
+
return { index, attempt, where };
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** Keep the highest attempt per shard; two directories may not claim one slot. */
|
|
488
|
+
function newestPerShard(entries, provider) {
|
|
489
|
+
const newest = new Map(),
|
|
490
|
+
seen = new Set();
|
|
491
|
+
for (const entry of entries) {
|
|
492
|
+
const { index, attempt, where } = parseBundleName(entry.name, provider);
|
|
493
|
+
assert(
|
|
494
|
+
!seen.has(where),
|
|
495
|
+
`duplicate download directories claim ${where}. ${RERUN_ALL}`
|
|
496
|
+
);
|
|
497
|
+
seen.add(where);
|
|
498
|
+
if ((newest.get(index)?.attempt ?? 0) < attempt)
|
|
499
|
+
newest.set(index, { index, attempt, where, entry });
|
|
500
|
+
}
|
|
501
|
+
const missing = [1, 2, 3].filter(index => !newest.has(index));
|
|
502
|
+
assert(
|
|
503
|
+
missing.length === 0,
|
|
504
|
+
`missing shard bundle for ${missing.map(shardName).join(", ")}: no attempt 1-${provider.attempt} of run ${provider.runId} uploaded one. ${RECOVERY_PREFIX}"Re-run failed jobs" if that shard's job failed or was cancelled; "Re-run all jobs" if it succeeded without uploading.`
|
|
505
|
+
);
|
|
506
|
+
return [...newest.values()].sort((a, b) => a.index - b.index);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Merge downloaded shard directories from EVERY attempt of the current run
|
|
511
|
+
* (#4634). For each shard the newest attempt wins; its bundle must be
|
|
512
|
+
* complete, because falling back to an older attempt would silently judge a
|
|
513
|
+
* shard the operator just re-ran. `entries` are `{ name, read }`, where
|
|
514
|
+
* `read()` returns the bundle or null when the directory holds no
|
|
515
|
+
* manifest.json (a failed shard uploads diagnostics only). Only the chosen
|
|
516
|
+
* directories are read.
|
|
517
|
+
*/
|
|
518
|
+
export function mergeShardDirectories(snapshot, entries) {
|
|
519
|
+
validateSnapshot(snapshot);
|
|
520
|
+
assert(Array.isArray(entries), "shard directory entries required");
|
|
521
|
+
const selected = newestPerShard(entries, snapshot.provider).map(choice => {
|
|
522
|
+
const bundle = recoverable(choice.where, () => choice.entry.read());
|
|
523
|
+
assert(
|
|
524
|
+
bundle,
|
|
525
|
+
`${choice.where} did not complete: its bundle has no manifest.json, and an older attempt is never used in its place. ${RERUN_FAILED}`
|
|
526
|
+
);
|
|
527
|
+
const recordedShard = bundle.manifest?.shard?.index,
|
|
528
|
+
recordedAttempt = bundle.manifest?.snapshot?.provider?.attempt;
|
|
529
|
+
assert(
|
|
530
|
+
recordedShard === choice.index &&
|
|
531
|
+
recordedAttempt === String(choice.attempt),
|
|
532
|
+
`${choice.where} (${choice.entry.name}) records shard ${recordedShard}, records attempt ${recordedAttempt} in its manifest. ${RERUN_ALL}`
|
|
533
|
+
);
|
|
534
|
+
return {
|
|
535
|
+
index: choice.index,
|
|
536
|
+
attempt: choice.attempt,
|
|
537
|
+
name: choice.entry.name,
|
|
538
|
+
bundle,
|
|
539
|
+
};
|
|
540
|
+
});
|
|
541
|
+
return {
|
|
542
|
+
trace: mergeBundles(
|
|
543
|
+
snapshot,
|
|
544
|
+
selected.map(choice => choice.bundle)
|
|
545
|
+
),
|
|
546
|
+
selected,
|
|
547
|
+
};
|
|
548
|
+
}
|