From 049295f500728d19f17cc39319ff8e4a1d79a411 Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 7 Nov 2026 12:02:54 +0800 Subject: [PATCH] autoclaw: the rot-away test sets the first dump's write time apart On WSL2 (magpie-desktop, Ubuntu 24.04) the test "a 406 dumps the system prompt, opt-in; the oldest dumps rot away by write time" was red 2 of 3 at 09a27bef: the first dump and the ten refusals were written within one mtime tick, so rotation by write time could drop a refusal instead of the first dump. The test now gives the first dump a write time older than every refusal (and newer than the pre-placed file). The plugin's rotation is unchanged; it still sorts by write time. Run: wsl-run bun test index.test.mjs 3x: old 1 of 3 green, new 3 of 3 green (62 pass); mote bun test 62 pass. --- packages/autoclaw/index.test.mjs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/autoclaw/index.test.mjs b/packages/autoclaw/index.test.mjs index 109a086..ba8f23b 100644 --- a/packages/autoclaw/index.test.mjs +++ b/packages/autoclaw/index.test.mjs @@ -434,6 +434,13 @@ test("a 406 dumps the system prompt, opt-in; the oldest dumps rot away by write writeFileSync(old, JSON.stringify({ model: "m", messages: [{ role: "system", content: "pre-existing" }] })) const past = new Date(Date.now() - 60_000) utimesSync(old, past, past) + // the first dump is older than every refusal below, by its write time: + // a file system whose times are coarser than these writes (WSL2's ext4 + // on a busy box) would otherwise tie it with them, and rotation could + // drop a refusal in its place + const firstDump = join(dir, files[0]) + const later = new Date(past.getTime() + 1_000) + utimesSync(firstDump, later, later) // the directory is the user's to point anywhere: foreign files — a // settings.json, a non-dump anything — survive every refusal untouched writeFileSync(join(dir, "settings.json"), "{}")