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.
This commit is contained in:
yetone
2026-11-07 12:02:54 +08:00
parent 09a27bef01
commit 049295f500
+7
View File
@@ -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"), "{}")