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:
Ben Stull
2026-06-10 22:59:04 -07:00
parent a6b16f0d9c
commit 746071a585
4 changed files with 41 additions and 1 deletions
+8
View File
@@ -2,6 +2,7 @@ import { describe, it, expect } from "vitest";
import {
SCHEMA_VERSION,
emptyArtifact,
isNewerMajor,
serializeArtifact,
type Artifact,
} from "../src/model";
@@ -103,6 +104,13 @@ describe("cross-rung identity (F5 SLICE-2)", () => {
});
});
describe("isNewerMajor (F5 SLICE-2, INV-16)", () => {
it("is false for v1 and true for a newer major", () => {
expect(isNewerMajor(emptyArtifact("d.md"))).toBe(false);
expect(isNewerMajor({ schemaVersion: 2 })).toBe(true);
});
});
describe("unknown-field preservation (F5 SLICE-2, INV-15)", () => {
it("a rewrite preserves unknown fields at every level, after known keys, sorted", () => {
const foreign = {