Summary
schemas/tests.schema.json 的 example_cases items 不要求 setup 字段,但 src/lash/test-runner.ts 的 EXAMPLE_CASE_REQUIRED 集合包含 'setup'。两个校验入口标准不一致。
Evidence
JSON Schema (schemas/tests.schema.json:22-23):
"required": ["id", "suite_type", "module_ref", "requirement_refs",
"description", "category", "ears_ref", "derivation",
"input", "expected_output"]
// ← 没有 "setup"
代码 (src/lash/test-runner.ts:21-33):
const EXAMPLE_CASE_REQUIRED = new Set([
'id', 'suite_type', 'module_ref', 'requirement_refs',
'description', 'category', 'ears_ref', 'derivation',
'input', 'expected_output',
'setup', // ← 多了这个
]);
Impact
通过 JSON Schema 校验的 tests.json 可能被 validateTestsJson() 运行时拒绝:
- AI agent 读 schema 生成 tests.json → JSON Schema 校验通过 →
lash test 运行时报 missing required field: 'setup'
- 外部工具(IDE 插件、CI 检查)基于 JSON Schema 做校验不会检查
setup
Fix
推荐选项 A:Schema 对齐代码
将 setup 加入 schemas/tests.schema.json:23 的 required 数组:
"required": ["id", "suite_type", "module_ref", "requirement_refs",
"description", "category", "ears_ref", "derivation",
"input", "expected_output", "setup"]
Schema 已经定义了 setup 的类型 ("setup": { "type": "string" }, line 53),只是漏了标记为 required。
Summary
schemas/tests.schema.json的example_casesitems 不要求setup字段,但src/lash/test-runner.ts的EXAMPLE_CASE_REQUIRED集合包含'setup'。两个校验入口标准不一致。Evidence
JSON Schema (
schemas/tests.schema.json:22-23):代码 (
src/lash/test-runner.ts:21-33):Impact
通过 JSON Schema 校验的
tests.json可能被validateTestsJson()运行时拒绝:lash test运行时报missing required field: 'setup'setupFix
推荐选项 A:Schema 对齐代码
将
setup加入schemas/tests.schema.json:23的required数组:Schema 已经定义了
setup的类型 ("setup": { "type": "string" }, line 53),只是漏了标记为 required。