feat: isNewerMajor + store write-refusal backstop (F5 SLICE-2, INV-16, #14)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -107,3 +107,20 @@ describe("CoauthorStore", () => {
|
||||
expect(store.consumeSelfWrite(p)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("newer-major write refusal (F5 SLICE-2, INV-16 backstop)", () => {
|
||||
it("update REFUSES to write a sidecar from a newer major, leaving bytes untouched", () => {
|
||||
const store = new CoauthorStore(root);
|
||||
const p = store.sidecarPath("docs/v2.md");
|
||||
fs.mkdirSync(path.dirname(p), { recursive: true });
|
||||
const v2 = { ...emptyArtifact("docs/v2.md"), schemaVersion: 2 };
|
||||
fs.writeFileSync(p, serializeArtifact(v2), "utf8");
|
||||
const before = fs.readFileSync(p, "utf8");
|
||||
expect(() =>
|
||||
store.update("docs/v2.md", (a) => {
|
||||
a.threads = [];
|
||||
}),
|
||||
).toThrow(/INV-16/);
|
||||
expect(fs.readFileSync(p, "utf8")).toBe(before);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user