Skip to content

Commit 95aa6b1

Browse files
MaxLinCodeclaude
andcommitted
feat: add parentTargetRef to clarification entity schema
Back-pointer from clarification entity to original write target. Uses .optional().default(null) for backward compatibility with stored entities. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9bf333c commit 95aa6b1

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { describe, expect, it } from "vitest";
2+
import { conversationClarificationEntitySchema } from "./index";
3+
4+
describe("clarification parentTargetRef schema", () => {
5+
const baseClarification = {
6+
id: "clar-1",
7+
conversationId: "conv-1",
8+
kind: "clarification",
9+
label: "Need a time",
10+
status: "active",
11+
createdAt: "2026-04-09T10:00:00.000Z",
12+
updatedAt: "2026-04-09T10:00:00.000Z",
13+
};
14+
15+
it("accepts parentTargetRef: null", () => {
16+
const entity = conversationClarificationEntitySchema.parse({
17+
...baseClarification,
18+
data: { prompt: "What time?", reason: "scheduleFields.time", open: true, parentTargetRef: null },
19+
});
20+
expect(entity.data.parentTargetRef).toBeNull();
21+
});
22+
23+
it("accepts parentTargetRef with entityId", () => {
24+
const entity = conversationClarificationEntitySchema.parse({
25+
...baseClarification,
26+
data: { prompt: "What time?", reason: "scheduleFields.time", open: true, parentTargetRef: { entityId: "task-1" } },
27+
});
28+
expect(entity.data.parentTargetRef).toEqual({ entityId: "task-1" });
29+
});
30+
31+
it("defaults parentTargetRef to null when omitted (backward compat)", () => {
32+
const entity = conversationClarificationEntitySchema.parse({
33+
...baseClarification,
34+
data: { prompt: "What time?", reason: "scheduleFields.time", open: true },
35+
});
36+
expect(entity.data.parentTargetRef).toBeNull();
37+
});
38+
});

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ export const conversationClarificationEntitySchema =
852852
prompt: z.string().min(1),
853853
reason: z.string().min(1).nullable(),
854854
open: z.boolean(),
855+
parentTargetRef: targetRefSchema.optional().default(null),
855856
}),
856857
});
857858

0 commit comments

Comments
 (0)