refactor(core): consolidate tool architecture
This commit is contained in:
parent
0fd73a2976
commit
8db7487c89
466 changed files with 9405 additions and 11071 deletions
|
|
@ -84,14 +84,14 @@ describe("contract hygiene", () => {
|
|||
test("model defaults and provider overlays preserve public invariants", () => {
|
||||
const id = Model.ID.make("model")
|
||||
expect(Model.Info.default(Provider.ID.make("provider"), id)).toMatchObject({ modelID: id, variants: [] })
|
||||
expect(() =>
|
||||
expect(
|
||||
Schema.decodeUnknownSync(Provider.Info)({
|
||||
id: "provider",
|
||||
name: "Provider",
|
||||
package: "native",
|
||||
settings: { invalid: 1n },
|
||||
}),
|
||||
).toThrow()
|
||||
settings: { arbitrary: 1n },
|
||||
}).settings,
|
||||
).toEqual({ arbitrary: 1n })
|
||||
})
|
||||
|
||||
test("current ID constructors expose create", () => {
|
||||
|
|
@ -137,15 +137,19 @@ describe("contract hygiene", () => {
|
|||
expect(new Set(identifiers).size).toBe(identifiers.length)
|
||||
})
|
||||
|
||||
test("current source avoids Any and mutable contract wrappers", async () => {
|
||||
test("current source limits Any to provider options and avoids mutable contract wrappers", async () => {
|
||||
const files = [...new Bun.Glob("*.ts").scanSync(new URL("../src", import.meta.url).pathname)].filter(
|
||||
(file) => !file.endsWith("-v1.ts"),
|
||||
)
|
||||
const source = await Promise.all(
|
||||
files.map((file) => Bun.file(new URL(`../src/${file}`, import.meta.url)).text()),
|
||||
).then((values) => values.join("\n"))
|
||||
const sources = await Promise.all(
|
||||
files.map(async (file) => ({ file, source: await Bun.file(new URL(`../src/${file}`, import.meta.url)).text() })),
|
||||
)
|
||||
const source = sources.map((item) => item.source).join("\n")
|
||||
|
||||
expect(source).not.toContain("Schema.Any")
|
||||
expect(sources.filter((item) => item.file !== "provider.ts").map((item) => item.source).join("\n")).not.toContain(
|
||||
"Schema.Any",
|
||||
)
|
||||
expect(sources.find((item) => item.file === "provider.ts")?.source.match(/Schema\.Any/g)).toHaveLength(4)
|
||||
expect(source).not.toContain("Schema.mutable")
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import { LegacyEvent } from "../src/legacy-event.js"
|
||||
import { LegacyEventV1 } from "../src/legacy-event.js"
|
||||
import { PermissionV1 } from "../src/permission-v1.js"
|
||||
import { QuestionV1 } from "../src/question-v1.js"
|
||||
import { Project } from "../src/project.js"
|
||||
|
|
@ -36,7 +36,7 @@ describe("legacy public event schemas", () => {
|
|||
QuestionV1.Event.Replied.type,
|
||||
QuestionV1.Event.Rejected.type,
|
||||
Project.Event.Updated.type,
|
||||
LegacyEvent.CommandExecuted.type,
|
||||
LegacyEventV1.CommandExecuted.type,
|
||||
]).toEqual([
|
||||
"message.part.delta",
|
||||
"session.diff",
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { LegacyEvent } from "../src/legacy-event.js"
|
||||
import { LegacyEventV1 } from "../src/legacy-event.js"
|
||||
import { PermissionV1 } from "../src/permission-v1.js"
|
||||
import { QuestionV1 } from "../src/question-v1.js"
|
||||
import { SessionV1 } from "../src/session-v1.js"
|
||||
import { LegacyEvent as IsolatedLegacyEvent } from "../src/v1/legacy-event.js"
|
||||
import { PermissionV1 as IsolatedPermissionV1 } from "../src/v1/permission.js"
|
||||
import { QuestionV1 as IsolatedQuestionV1 } from "../src/v1/question.js"
|
||||
import { SessionV1 as IsolatedSessionV1 } from "../src/v1/session.js"
|
||||
const isolatedLegacyEvent = await import("../src/v1/legacy-event.js")
|
||||
const isolatedPermission = await import("../src/v1/permission.js")
|
||||
const isolatedQuestion = await import("../src/v1/question.js")
|
||||
const isolatedSession = await import("../src/v1/session.js")
|
||||
|
||||
test("compatibility entrypoints preserve isolated V1 schema identity", () => {
|
||||
expect(LegacyEvent).toBe(IsolatedLegacyEvent)
|
||||
expect(PermissionV1).toBe(IsolatedPermissionV1)
|
||||
expect(QuestionV1).toBe(IsolatedQuestionV1)
|
||||
expect(SessionV1).toBe(IsolatedSessionV1)
|
||||
expect(LegacyEventV1).toBe(isolatedLegacyEvent.LegacyEventV1)
|
||||
expect(PermissionV1).toBe(isolatedPermission.PermissionV1)
|
||||
expect(QuestionV1).toBe(isolatedQuestion.QuestionV1)
|
||||
expect(SessionV1).toBe(isolatedSession.SessionV1)
|
||||
})
|
||||
|
||||
test("current source does not import the V1 subtree directly", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue