feat(id): brand WorkspaceID through Drizzle and Zod schemas (#16964)

This commit is contained in:
Kit Langton
2026-03-11 19:30:17 -04:00
committed by GitHub
parent f1c3a44190
commit 16a6d6feba
49 changed files with 205 additions and 157 deletions

View File

@@ -11,7 +11,7 @@ import { Filesystem } from "../../src/util/filesystem"
import { tmpdir } from "../fixture/fixture"
import type { Agent } from "../../src/agent/agent"
import type { MessageV2 } from "../../src/session/message-v2"
import { SessionID } from "../../src/session/schema"
import { SessionID, MessageID } from "../../src/session/schema"
describe("session.llm.hasToolCalls", () => {
test("returns false for empty messages array", () => {
@@ -277,7 +277,7 @@ describe("session.llm.stream", () => {
} satisfies Agent.Info
const user = {
id: "user-1",
id: MessageID.make("user-1"),
sessionID,
role: "user",
time: { created: Date.now() },
@@ -406,7 +406,7 @@ describe("session.llm.stream", () => {
} satisfies Agent.Info
const user = {
id: "user-2",
id: MessageID.make("user-2"),
sessionID,
role: "user",
time: { created: Date.now() },
@@ -529,7 +529,7 @@ describe("session.llm.stream", () => {
} satisfies Agent.Info
const user = {
id: "user-3",
id: MessageID.make("user-3"),
sessionID,
role: "user",
time: { created: Date.now() },
@@ -630,7 +630,7 @@ describe("session.llm.stream", () => {
} satisfies Agent.Info
const user = {
id: "user-4",
id: MessageID.make("user-4"),
sessionID,
role: "user",
time: { created: Date.now() },

View File

@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test"
import { APICallError } from "ai"
import { MessageV2 } from "../../src/session/message-v2"
import type { Provider } from "../../src/provider/provider"
import { SessionID } from "../../src/session/schema"
import { SessionID, MessageID } from "../../src/session/schema"
const sessionID = SessionID.make("session")
const model: Provider.Model = {
@@ -100,7 +100,7 @@ function basePart(messageID: string, id: string) {
return {
id,
sessionID,
messageID,
messageID: MessageID.make(messageID),
}
}

View File

@@ -7,6 +7,7 @@ import { MessageV2 } from "../../src/session/message-v2"
import { Log } from "../../src/util/log"
import { Instance } from "../../src/project/instance"
import { Identifier } from "../../src/id/id"
import { MessageID } from "../../src/session/schema"
import { tmpdir } from "../fixture/fixture"
const projectRoot = path.join(__dirname, "../..")
@@ -24,7 +25,7 @@ describe("revert + compact workflow", () => {
// Create a user message
const userMsg1 = await Session.updateMessage({
id: Identifier.ascending("message"),
id: MessageID.ascending(),
role: "user",
sessionID,
agent: "default",
@@ -48,7 +49,7 @@ describe("revert + compact workflow", () => {
// Create an assistant response message
const assistantMsg1: MessageV2.Assistant = {
id: Identifier.ascending("message"),
id: MessageID.ascending(),
role: "assistant",
sessionID,
mode: "default",
@@ -85,7 +86,7 @@ describe("revert + compact workflow", () => {
// Create another user message
const userMsg2 = await Session.updateMessage({
id: Identifier.ascending("message"),
id: MessageID.ascending(),
role: "user",
sessionID,
agent: "default",
@@ -108,7 +109,7 @@ describe("revert + compact workflow", () => {
// Create another assistant response
const assistantMsg2: MessageV2.Assistant = {
id: Identifier.ascending("message"),
id: MessageID.ascending(),
role: "assistant",
sessionID,
mode: "default",
@@ -200,7 +201,7 @@ describe("revert + compact workflow", () => {
// Create initial messages
const userMsg = await Session.updateMessage({
id: Identifier.ascending("message"),
id: MessageID.ascending(),
role: "user",
sessionID,
agent: "default",
@@ -222,7 +223,7 @@ describe("revert + compact workflow", () => {
})
const assistantMsg: MessageV2.Assistant = {
id: Identifier.ascending("message"),
id: MessageID.ascending(),
role: "assistant",
sessionID,
mode: "default",

View File

@@ -6,6 +6,7 @@ import { Log } from "../../src/util/log"
import { Instance } from "../../src/project/instance"
import { MessageV2 } from "../../src/session/message-v2"
import { Identifier } from "../../src/id/id"
import { MessageID } from "../../src/session/schema"
const projectRoot = path.join(__dirname, "../..")
Log.init({ print: false })
@@ -81,7 +82,7 @@ describe("step-finish token propagation via Bus event", () => {
fn: async () => {
const session = await Session.create({})
const messageID = Identifier.ascending("message")
const messageID = MessageID.ascending()
await Session.updateMessage({
id: messageID,
sessionID: session.id,

View File

@@ -1,7 +1,7 @@
import { describe, expect, test } from "bun:test"
import { MessageV2 } from "../../src/session/message-v2"
import { SessionPrompt } from "../../src/session/prompt"
import { SessionID } from "../../src/session/schema"
import { SessionID, MessageID } from "../../src/session/schema"
describe("structured-output.OutputFormat", () => {
test("parses text format", () => {
@@ -96,7 +96,7 @@ describe("structured-output.StructuredOutputError", () => {
describe("structured-output.UserMessage", () => {
test("user message accepts outputFormat", () => {
const result = MessageV2.User.safeParse({
id: "test-id",
id: MessageID.ascending(),
sessionID: SessionID.descending(),
role: "user",
time: { created: Date.now() },
@@ -112,7 +112,7 @@ describe("structured-output.UserMessage", () => {
test("user message works without outputFormat (optional)", () => {
const result = MessageV2.User.safeParse({
id: "test-id",
id: MessageID.ascending(),
sessionID: SessionID.descending(),
role: "user",
time: { created: Date.now() },
@@ -125,10 +125,10 @@ describe("structured-output.UserMessage", () => {
describe("structured-output.AssistantMessage", () => {
const baseAssistantMessage = {
id: "test-id",
id: MessageID.ascending(),
sessionID: SessionID.descending(),
role: "assistant" as const,
parentID: "parent-id",
parentID: MessageID.ascending(),
modelID: "claude-3",
providerID: "anthropic",
mode: "default",