F3 SLICE-3: pending-edit registry + sidecar section-merge update (INV-9 groundwork) (#6)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { PendingEditRegistry } from "../src/pendingEdits";
|
||||
import type { Provenance } from "../src/model";
|
||||
|
||||
const AGENT: Provenance = {
|
||||
kind: "agent", id: "claude",
|
||||
agent: { sdk: "@cline/sdk", model: "sonnet", sessionId: "run-1" },
|
||||
};
|
||||
|
||||
describe("PendingEditRegistry (INV-9)", () => {
|
||||
it("matches and consumes an exact registration", () => {
|
||||
const reg = new PendingEditRegistry();
|
||||
reg.register({ docPath: "d.md", start: 3, end: 7, newText: "new", provenance: AGENT, turnId: "t1" });
|
||||
const hit = reg.match("d.md", { start: 3, end: 7, text: "new" });
|
||||
expect(hit?.turnId).toBe("t1");
|
||||
expect(reg.match("d.md", { start: 3, end: 7, text: "new" })).toBeNull();
|
||||
});
|
||||
it("does not match a different doc, range, or text (human typing stays human)", () => {
|
||||
const reg = new PendingEditRegistry();
|
||||
reg.register({ docPath: "d.md", start: 3, end: 7, newText: "new", provenance: AGENT });
|
||||
expect(reg.match("other.md", { start: 3, end: 7, text: "new" })).toBeNull();
|
||||
expect(reg.match("d.md", { start: 3, end: 8, text: "new" })).toBeNull();
|
||||
expect(reg.match("d.md", { start: 3, end: 7, text: "neww" })).toBeNull();
|
||||
});
|
||||
it("unregister removes a failed application", () => {
|
||||
const reg = new PendingEditRegistry();
|
||||
const p = { docPath: "d.md", start: 0, end: 0, newText: "x", provenance: AGENT };
|
||||
reg.register(p);
|
||||
reg.unregister(p);
|
||||
expect(reg.match("d.md", { start: 0, end: 0, text: "x" })).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user