F3 SLICE-3 host fixes: disk-compare sync detection + self-minimized seam edits (INV-9) (#6)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ben Stull
2026-06-10 10:50:07 -07:00
parent fe23ffa100
commit 2604ab4925
3 changed files with 89 additions and 9 deletions
+20 -1
View File
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
import { PendingEditRegistry } from "../src/pendingEdits";
import { minimizeReplace, PendingEditRegistry } from "../src/pendingEdits";
import type { Provenance } from "../src/model";
const AGENT: Provenance = {
@@ -30,3 +30,22 @@ describe("PendingEditRegistry (INV-9)", () => {
expect(reg.match("d.md", { start: 0, end: 0, text: "x" })).toBeNull();
});
});
describe("minimizeReplace (host diff-minimization mirror)", () => {
it("trims a common suffix (the E2E-observed case)", () => {
expect(minimizeReplace("target sentence", "REWRITTEN-BY-CLAUDE sentence")).toEqual({ prefix: 0, suffix: 9 });
});
it("trims a common prefix", () => {
expect(minimizeReplace("Hello world", "Hello there")).toEqual({ prefix: 6, suffix: 0 });
});
it("trims both, never overlapping", () => {
expect(minimizeReplace("aba", "aa")).toEqual({ prefix: 1, suffix: 1 });
expect(minimizeReplace("aaaa", "aa")).toEqual({ prefix: 2, suffix: 0 });
});
it("identical texts minimize to nothing", () => {
expect(minimizeReplace("same", "same")).toEqual({ prefix: 4, suffix: 0 });
});
it("disjoint texts trim nothing", () => {
expect(minimizeReplace("abc", "xyz")).toEqual({ prefix: 0, suffix: 0 });
});
});