MCPcopy Create free account
hub / github.com/cli/cli / cleanupTrial

Function cleanupTrial

evals/src/core/trial-cleanup.ts:14–36  ·  view source on GitHub ↗
(actions: CleanupActions, primary: unknown, journalPath: string)

Source from the content-addressed store, hash-verified

12
13/** Attempts every cleanup step while retaining the original execution failure. */
14export async function cleanupTrial(actions: CleanupActions, primary: unknown, journalPath: string): Promise<void> {
15 const failures: string[] = [];
16 let resourceFailure = false;
17 for (const [step, label] of [
18 ["actor", "Second actor execution"],
19 ["agent", "Copilot executor shutdown"],
20 ["observer", "Command observer cleanup"],
21 ["resources", "Resource cleanup"],
22 ["local", "Local cleanup"],
23 ] as const) {
24 try { await actions[step](); }
25 catch (error) {
26 if (step === "actor" && primary !== undefined && error === primary) continue;
27 failures.push(`${label}: ${String(error)}`);
28 if (step === "resources") resourceFailure = true;
29 }
30 }
31 if (failures.length) {
32 const original = primary === undefined ? "" : `${primary instanceof Error ? primary.message : String(primary)}; `;
33 const retry = resourceFailure ? `. Retry with: evals/cleanup ${journalPath}` : "";
34 throw new TrialCleanupError(`${original}${failures.join("; ")}${retry}`, { cause: primary });
35 }
36}

Callers 3

trialFunction · 0.85
cleanup.test.tsFile · 0.85
trialMethod · 0.85

Calls 1

pushMethod · 0.80

Tested by 1

trialFunction · 0.68