| 90 | } |
| 91 | |
| 92 | async write(taskSpec: TaskSpec, rubric: Rubric): Promise<void> { |
| 93 | await fs.mkdir(this.cacheDir, { recursive: true }); |
| 94 | const entry: CacheEntry = { |
| 95 | taskId: taskSpec.id, |
| 96 | instructionHash: hashInstruction(taskSpec.instruction), |
| 97 | generatedAt: new Date().toISOString(), |
| 98 | rubric, |
| 99 | }; |
| 100 | await fs.writeFile( |
| 101 | this.entryPath(taskSpec.id), |
| 102 | JSON.stringify(entry, null, 2), |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | /** Wipe the cache directory (used by tests / `bench cache clear`). */ |
| 107 | async clear(): Promise<void> { |