feat: 重构配置生命周期为 Authoring/Normalized/Resolved 三层
将变量替换和 expect 简写展开统一放入 Normalized 阶段, 运行时 AJV 使用 Normalized schema,导出 schema 面向 Authoring Config。 主要变更: - 新增 normalizer.ts 实现 normalizeAuthoringConfig() - 拆分 Authoring/Normalized 双 schema,checker 接口支持 authoring/normalized 片段 - config-loader 流程:normalize → Normalized AJV → semantic → resolve - validator 兼容层自动分派 raw/normalized expect 形态 - 删除 rawExpect,store.expect 列写入 null - Authoring schema 对 integer/boolean/enum 字段接受变量引用 - 修复 DB/HTTP validate 入口守卫和 LLM options integer 变量引用 - 优化 compact() 避免 undefined 覆盖隐患 - 移除 content.ts 恒为 true 的前置条件 - 同步 5 个主规范并归档 change
This commit is contained in:
@@ -60,9 +60,11 @@ describe("LlmChecker schema", () => {
|
||||
expect(checker?.configKey).toBe("llm");
|
||||
});
|
||||
|
||||
test("schemas 包含 config、expect", () => {
|
||||
test("schemas 包含 authoring 和 normalized config/expect", () => {
|
||||
expect(checker).toBeDefined();
|
||||
expect(Object.keys(checker!.schemas).sort()).toEqual(["config", "expect"].sort());
|
||||
expect(Object.keys(checker!.schemas).sort()).toEqual(["authoring", "normalized"].sort());
|
||||
expect(checker!.schemas.authoring.config).toBeDefined();
|
||||
expect(checker!.schemas.normalized.expect).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -249,13 +251,13 @@ describe("LlmChecker resolve", () => {
|
||||
expect(resolved.group).toBe("default");
|
||||
expect(resolved.intervalMs).toBe(30000);
|
||||
expect(resolved.timeoutMs).toBe(10000);
|
||||
expect(resolved.rawExpect).toBeUndefined();
|
||||
expect("rawExpect" in resolved).toBe(false);
|
||||
expect(resolved.expect).toEqual({ status: [200] });
|
||||
});
|
||||
|
||||
test("stream mode 未配置 expect.stream 时不物化 completed", () => {
|
||||
const raw = makeRawTarget({
|
||||
expect: { output: [{ contains: "OK" }] },
|
||||
expect: { output: [{ kind: "value", matcher: { contains: "OK" } }] },
|
||||
llm: {
|
||||
mode: "stream",
|
||||
model: "gpt-4o-mini",
|
||||
@@ -267,13 +269,13 @@ describe("LlmChecker resolve", () => {
|
||||
|
||||
const resolved = asLlm(checker.resolve(raw, makeResolveContext()));
|
||||
|
||||
expect(resolved.rawExpect).toEqual({ output: [{ contains: "OK" }] });
|
||||
expect("rawExpect" in resolved).toBe(false);
|
||||
expect(resolved.expect?.stream).toBeUndefined();
|
||||
});
|
||||
|
||||
test("配置 expect.stream 但省略 completed 时默认 true", () => {
|
||||
const raw = makeRawTarget({
|
||||
expect: { stream: { firstTokenMs: 100 } },
|
||||
expect: { stream: { firstTokenMs: { equals: 100 } } },
|
||||
llm: {
|
||||
mode: "stream",
|
||||
model: "gpt-4o-mini",
|
||||
@@ -285,7 +287,7 @@ describe("LlmChecker resolve", () => {
|
||||
|
||||
const resolved = asLlm(checker.resolve(raw, makeResolveContext()));
|
||||
|
||||
expect(resolved.rawExpect).toEqual({ stream: { firstTokenMs: 100 } });
|
||||
expect("rawExpect" in resolved).toBe(false);
|
||||
expect(resolved.expect?.stream).toEqual({ completed: true, firstTokenMs: { equals: 100 } });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user