Skip to content

A local plugin for image-heavy chats in Codex, Claude Code and other agents: earlier images stop going out with every message, and the model fetches the one it needs by its ID, also after compaction.

test(children): isolate retry regression from classification tests

lin-coco25dfb87d8c63
diff --git a/spike/src/children-retry.test.ts b/spike/src/children-retry.test.ts
new file mode 100644
index 0000000..1c42842
--- /dev/null
+++ b/spike/src/children-retry.test.ts
@@ -0,0 +1,22 @@
+// A transient write failure must not poison the engine's process-local child deduplication cache.
+import assert from "node:assert/strict";
+import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import test from "node:test";
+import { readChildren, recordChild } from "../../plugin/src/children.ts";
+
+test("a child can be recorded again after its first write fails", (t) => {
+ const root = mkdtempSync(join(tmpdir(), "cam-children-retry-"));
+ t.after(() => rmSync(root, { recursive: true, force: true }));
+ const dir = join(root, "blocked-children");
+ const task = "11111111-1111-4111-8111-111111111111";
+ const id = "22222222-2222-4222-8222-222222222222";
+ const child = { kind: "side" as const, from: task, at: "2026-10-15T10:00:00Z" };
+ writeFileSync(dir, "temporarily blocks mkdir");
+ assert.throws(() => recordChild(task, id, child, dir));
+ rmSync(dir);
+ assert.equal(recordChild(task, id, child, dir), true, "retry after recovery must persist the child");
+ assert.deepEqual(readChildren(task, dir), { [id]: child });
+ assert.equal(recordChild(task, id, child, dir), false, "successful writes are still deduplicated");
+});
diff --git a/spike/src/children.test.ts b/spike/src/children.test.ts
index 4ad1f92..5e581bc 100644
--- a/spike/src/children.test.ts
+++ b/spike/src/children.test.ts
@@ -3,7 +3,7 @@
// Input: synthetic rollouts and temporary folders; output: Node test assertions only.
import assert from "node:assert/strict";
-import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import test from "node:test";
@@ -59,16 +59,3 @@ test("each child is recorded once under its task; later requests leave the recor
assert.equal(recordChild("../escape", SIDE, { kind: "side", from: MAIN, at: "x" }, dir), false);
assert.deepEqual(readChildren("../escape", dir), {});
});
-
-// A transient write failure must not poison the engine's process-local deduplication cache.
-test("a child can be recorded again after its first write fails", () => {
- const { root } = sessions();
- const dir = join(root, "blocked-children");
- const child = { kind: "side" as const, from: MAIN, at: "2026-10-15T10:00:00Z" };
- writeFileSync(dir, "temporarily blocks mkdir");
- assert.throws(() => recordChild(MAIN, SIDE, child, dir));
- rmSync(dir);
- assert.equal(recordChild(MAIN, SIDE, child, dir), true, "retry after recovery must persist the child");
- assert.deepEqual(readChildren(MAIN, dir), { [SIDE]: child });
- assert.equal(recordChild(MAIN, SIDE, child, dir), false, "successful writes are still deduplicated");
-});