F3 SLICE-1: typed attributions[] model (spec §6.3, INV-4) (#6)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -56,3 +56,35 @@ describe("serializeArtifact", () => {
|
||||
expect(e.proposals).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("attributions[] (F3 SLICE-1)", () => {
|
||||
it("round-trips an attribution record through serialize → parse", () => {
|
||||
const a = emptyArtifact("docs/x.md");
|
||||
a.anchors["a_1"] = { fingerprint: { text: "alpha", before: "", after: " beta", lineHint: 0 } };
|
||||
a.attributions.push({
|
||||
id: "at_1",
|
||||
anchorId: "a_1",
|
||||
author: { kind: "agent", id: "claude", agent: { sdk: "@cline/sdk", model: "sonnet", sessionId: "run-1" } },
|
||||
createdAt: "2026-06-10T00:00:00.000Z",
|
||||
updatedAt: "2026-06-10T00:00:00.000Z",
|
||||
turnId: "turn-1",
|
||||
});
|
||||
const parsed = JSON.parse(serializeArtifact(a)) as Artifact;
|
||||
expect(parsed.attributions).toEqual(a.attributions);
|
||||
});
|
||||
|
||||
it("omits turnId when undefined and serializes stably", () => {
|
||||
const a = emptyArtifact("docs/x.md");
|
||||
a.attributions.push({
|
||||
id: "at_2",
|
||||
anchorId: "a_2",
|
||||
author: { kind: "human", id: "ben" },
|
||||
createdAt: "2026-06-10T00:00:00.000Z",
|
||||
updatedAt: "2026-06-10T00:00:00.000Z",
|
||||
});
|
||||
const s1 = serializeArtifact(a);
|
||||
expect(s1.includes("turnId")).toBe(false);
|
||||
const s2 = serializeArtifact(JSON.parse(s1) as Artifact);
|
||||
expect(s2).toBe(s1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user