Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(runtime): make recovery identity tests filesystem-aware

cauliflower5f8dfac9f3ba
diff --git a/docs/spec/03-runtime/18-line-anchored-edit-contract.md b/docs/spec/03-runtime/18-line-anchored-edit-contract.md
index 39b51e807..bb885f449 100644
--- a/docs/spec/03-runtime/18-line-anchored-edit-contract.md
+++ b/docs/spec/03-runtime/18-line-anchored-edit-contract.md
@@ -484,6 +484,9 @@ is unavailable (for example, a missing target), the normalized absolute path is
the bookkeeping fallback. This identity never changes the submitted tool path
or replaces Host permission and workspace checks; delegate budgets remain
isolated from the parent and from other delegate runs.
+If a target later becomes canonicalizable (for example, after creation under a
+symlinked root), its identity may change from the lexical fallback; counts are
+not guaranteed to carry across that transition.
Counts and per-code graces belong to the executing parent turn or delegate
run. Parallel delegates working on the same path do not share failures or
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 7887eebd0..4de06c29c 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -16988,7 +16988,8 @@ host-created files. The full app's file-preview viewer is covered separately.
- Successfully Edit or Write through an alias and retry: the count and grace
reset. Removing the file through a linked path clears its pre-mutation identity.
- Repeat relative/absolute aliases in a temporary session: its scratch root is
- the relative base. Case-distinct POSIX files remain separate.
+ the relative base. Probe the directory's actual case sensitivity: distinct
+ case-sensitive files remain separate, while case aliases share an identity.
- Automated filesystem/runtime boundary coverage: `runtime.test.ts` and
`mutation-recovery.test.ts`; no UI, production profile or real provider is used.
diff --git a/packages/agent-runtime/src/mutation-recovery.test.ts b/packages/agent-runtime/src/mutation-recovery.test.ts
index 56086e5a4..ec3b34680 100644
--- a/packages/agent-runtime/src/mutation-recovery.test.ts
+++ b/packages/agent-runtime/src/mutation-recovery.test.ts
@@ -1,4 +1,4 @@
-import { mkdtemp, rm, writeFile } from "node:fs/promises";
+import { mkdtemp, realpath, rm, stat, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { describe, expect, it } from "vitest";
@@ -17,12 +17,23 @@ describe("mutationFailureKey", () => {
}
});
- it.skipIf(process.platform === "win32")("keeps existing case-distinct files independent", async () => {
+ it("respects the directory's actual case sensitivity", async () => {
const root = await mkdtemp(join(tmpdir(), "pi-case-edit-"));
try {
await writeFile(join(root, "a.ts"), "lower\n");
- await writeFile(join(root, "A.ts"), "upper\n");
- expect(await mutationFailureKey("a.ts", root)).not.toBe(await mutationFailureKey("A.ts", root));
+ const caseSensitive = await stat(join(root, "A.ts")).then(
+ () => false,
+ (error: NodeJS.ErrnoException) => {
+ if (error.code === "ENOENT") return true;
+ throw error;
+ },
+ );
+ if (caseSensitive) {
+ await writeFile(join(root, "A.ts"), "upper\n");
+ expect(await mutationFailureKey("a.ts", root)).not.toBe(await mutationFailureKey("A.ts", root));
+ } else {
+ expect(await mutationFailureKey("a.ts", root)).toBe(await mutationFailureKey("A.ts", root));
+ }
} finally {
await rm(root, { recursive: true, force: true });
}
@@ -32,7 +43,7 @@ describe("mutationFailureKey", () => {
const root = await mkdtemp(join(tmpdir(), "pi-backslash-edit-"));
try {
await writeFile(join(root, "a\\b.ts"), "literal\n");
- expect(await mutationFailureKey("a\\b.ts", root)).toBe(join(root, "a\\b.ts"));
+ expect(await mutationFailureKey("a\\b.ts", root)).toBe(join(await realpath(root), "a\\b.ts"));
} finally {
await rm(root, { recursive: true, force: true });
}