| 115 | |
| 116 | /** Atomic mkdir — returns true if created, false if already exists, dies on other errors. */ |
| 117 | const atomicMkdir = (dir: string) => |
| 118 | fs.makeDirectory(dir, { mode: 0o700 }).pipe( |
| 119 | Effect.as(true), |
| 120 | Effect.catchIf( |
| 121 | (e) => e.reason._tag === "AlreadyExists", |
| 122 | () => Effect.succeed(false), |
| 123 | ), |
| 124 | Effect.orDie, |
| 125 | ) |
| 126 | |
| 127 | /** Write with exclusive create — compromised error if file already exists. */ |
| 128 | const exclusiveWrite = (filePath: string, content: string, lockDir: string, detail: string) => |