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

Function unfinishedJournals

evals/src/core/sandbox.ts:121–146  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

119
120/** Finds resource journals under a results root whose cleanup has not completed. */
121export async function unfinishedJournals(root: string): Promise<string[]> {
122 // Vally nests each trial as <run>/<eval>/<stimulus>/<model>/<trial>/executor-artifacts/, so walk
123 // the tree rather than assume a depth. The cap stops a mistaken root from walking a whole disk.
124 const found: string[] = [];
125 const visit = async (directory: string, depth: number): Promise<void> => {
126 let entries: Dirent[];
127 try { entries = await readdir(directory, { withFileTypes: true }); }
128 catch (error) {
129 if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) return;
130 throw error;
131 }
132 for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
133 const path = join(directory, entry.name);
134 if (entry.isDirectory() && depth < 10) await visit(path, depth + 1);
135 else if (entry.isFile() && entry.name === "resources.json") {
136 try {
137 if (!(await parseJournalFile(path)).cleaned) found.push(path);
138 } catch {
139 found.push(path);
140 }
141 }
142 }
143 };
144 await visit(root, 0);
145 return found;
146}

Callers 2

harness.test.tsFile · 0.85
mainFunction · 0.85

Calls 1

visitFunction · 0.85

Tested by

no test coverage detected