Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test: the no-allow-protected guard tolerates scratch files other tests delete mid-walk
time-attack202918e1b41c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex bbd12ea4e5..4c8b855c41 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -49,6 +49,7 @@ Warm reads on a 4 vCPU box, Postgres 16 + pgvector 0.8.7, synthetic brains (5,00- `test/e2e/private-visibility-plan-postgres.test.ts` proves both spellings of the private-page rule hide exactly the same pages, and that the planner's cost per page now stays under `jit_above_cost / 500`. A precondition fails if the old spelling would also pass.- `test/e2e/vector-plan-real-column-postgres.test.ts` checks the walk uses `idx_chunks_embedding` for remote readers and 50- and 200-result windows. `test/held-read-signals.test.ts` checks the held-page read probes `pages_pkey` (it fails on the text-cast join). `test/page-snapshot-exact-first.test.ts` covers exact hits, alias fallback, an exact page in another source, deleted and private exact pages, the ambiguity check and a miss.- `test/bounded-child-exec.test.ts`: the SIGTERM test installs the child's trap before it writes the lockfile and waits for the lockfile instead of sleeping 200 ms; on a loaded runner the child had not started yet (forced probe: delaying the child 0.5 s fails the old test and passes the new one).+- `test/no-allow-protected-flag.test.ts` skips a file or directory that another test deletes while the guard walks `test/` (ENOENT), instead of failing the run (forced probe: a dangling `test/.probe-vanished.md` fails the old guard and passes the new one).## [0.60.123.0] - 2026-10-09diff --git a/test/no-allow-protected-flag.test.ts b/test/no-allow-protected-flag.test.tsindex d2009ceb54..2029e5d7f9 100644--- a/test/no-allow-protected-flag.test.ts+++ b/test/no-allow-protected-flag.test.ts@@ -14,8 +14,14 @@ const ROOT = join(import.meta.dir, '..');const FLAG = ['--allow', 'protected'].join('-');const FLAG_RE = new RegExp(`${FLAG}(?![\\w-])`);+/** Other test files create and delete scratch files under test/ while this walk runs; one that vanishes mid-walk is skipped. */+function vanishedOk<T>(read: () => T, fallback: T): T {+ try { return read(); }+ catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return fallback; throw error; }+}+function files(dir: string): string[] {- return readdirSync(dir, { withFileTypes: true }).flatMap(e => {+ return vanishedOk(() => readdirSync(dir, { withFileTypes: true }), []).flatMap(e => {const p = join(dir, e.name);if (e.isDirectory()) return e.name === 'node_modules' ? [] : files(p);return /\.(ts|tsx|mjs|js|md|json|sh)$/.test(e.name) ? [p] : [];@@ -25,7 +31,7 @@ function files(dir: string): string[] {describe(`no ${FLAG} flag references`, () => {it('src/, skills/ and test/ never mention the nonexistent flag', () => {const hits = ['src', 'skills', 'test'].flatMap(d => files(join(ROOT, d))).flatMap(file =>- readFileSync(file, 'utf8').split('\n').flatMap((line, i) => (FLAG_RE.test(line) ? [`${relative(ROOT, file)}:${i + 1}`] : [])));+ vanishedOk(() => readFileSync(file, 'utf8'), '').split('\n').flatMap((line, i) => (FLAG_RE.test(line) ? [`${relative(ROOT, file)}:${i + 1}`] : [])));expect(hits).toEqual([]);});});