Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

test: bind ledger failure snapshots to file descriptors

haelyra6d0b8d4dcb4d
diff --git a/tests/docs/story-lifecycle-errors.test.js b/tests/docs/story-lifecycle-errors.test.js
index 2107ed186..42c9dc46b 100644
--- a/tests/docs/story-lifecycle-errors.test.js
+++ b/tests/docs/story-lifecycle-errors.test.js
@@ -15,8 +15,15 @@ function run(root, args, preload) {
function ok(result) { assert.equal(result.status, 0, result.stderr); return JSON.parse(result.stdout); }
function input(root, changes) { const file = path.join(root, 'input.json'); fs.writeFileSync(file, JSON.stringify(changes)); return file; }
function snapshot(dir) {
- return Object.fromEntries(fs.readdirSync(dir).sort().map(name => {
- const file = path.join(dir, name);return [name, fs.lstatSync(file).isDirectory() ? snapshot(file) : fs.readFileSync(file).toString('base64')];
+ return Object.fromEntries(fs.readdirSync(dir, { withFileTypes: true })
+ .sort((left, right) => left.name.localeCompare(right.name)).map(entry => {
+ const file = path.join(dir, entry.name);
+ if (entry.isDirectory()) return [entry.name, snapshot(file)];
+ const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
+ try {
+ assert.ok(fs.fstatSync(fd).isFile(), 'snapshot requires a regular file');
+ return [entry.name, fs.readFileSync(fd, 'base64')];
+ } finally { fs.closeSync(fd); }
}));
}
function fixture(update = false) {