fix(compute): enforce reasoning effort boundaries (#60)

This commit is contained in:
2026-07-19 21:47:10 +08:00
committed by GitHub
parent 55999ce633
commit 523e667b40
4 changed files with 47 additions and 2 deletions

View File

@@ -324,6 +324,14 @@ describe('provider schema 反例(防 PR #1 重演)', () => {
assert.equal(validate(duplicate), false) assert.equal(validate(duplicate), false)
}) })
it('拒绝不在 supportedEfforts 中的 defaultEffort', () => {
const data = makeValidProvider()
data.models[0].extra = {
reasoning: { supportedEfforts: ['low'], defaultEffort: 'high' },
}
assert.equal(validate(data), false)
})
it('接受 defaultTemperature: 0.7(合法 number', () => { it('接受 defaultTemperature: 0.7(合法 number', () => {
const data = makeValidProvider() const data = makeValidProvider()
data.models[0].defaultTemperature = 0.7 data.models[0].defaultTemperature = 0.7
@@ -373,6 +381,34 @@ describe('provider schema 反例(防 PR #1 重演)', () => {
}) })
}) })
describe('model-spec schema 接入面边界', () => {
const validate = compile('model-spec')
it('拒绝在模型内在规格中声明 reasoning effort', () => {
const data = {
specs: [{
id: 'gpt-test',
spec: {
extra: {
reasoning: {
supportedEfforts: ['low', 'high'],
defaultEffort: 'low',
},
},
},
}],
}
assert.equal(validate(data), false)
})
it('仍允许模型内在扩展参数', () => {
const data = {
specs: [{ id: 'gpt-test', spec: { extra: { intrinsicBudgetHint: 8192 } } }],
}
assert.equal(validate(data), true, JSON.stringify(validate.errors))
})
})
// ==================== Manifest schema ==================== // ==================== Manifest schema ====================
describe('manifest schema', () => { describe('manifest schema', () => {

View File

@@ -1,6 +1,6 @@
{ {
"version": "1.0.0", "version": "1.0.0",
"presetDataVersion": 76, "presetDataVersion": 77,
"updatedAt": "2026-07-19", "updatedAt": "2026-07-19",
"description": "DesireCore 官方配置中心" "description": "DesireCore 官方配置中心"
} }

View File

@@ -98,7 +98,8 @@
}, },
"extra": { "extra": {
"type": "object", "type": "object",
"description": "模型特定附加配置(如 apiModelId 全名、推理预算等)。不含价格。", "description": "模型内在附加配置(如 apiModelId 全名、推理预算等)。不含价格,也不得声明 Provider/接入面的 reasoning effort 能力。",
"not": { "required": ["reasoning"] },
"additionalProperties": true "additionalProperties": true
}, },
"releasedAt": { "releasedAt": {

View File

@@ -274,6 +274,14 @@
"description": "当前模型在此接入面的推荐显式默认档位,必须同时存在于 supportedEfforts。" "description": "当前模型在此接入面的推荐显式默认档位,必须同时存在于 supportedEfforts。"
} }
}, },
"allOf": [
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "minimal" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "minimal" } } } } },
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "low" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "low" } } } } },
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "medium" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "medium" } } } } },
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "high" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "high" } } } } },
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "xhigh" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "xhigh" } } } } },
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "max" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "max" } } } } }
],
"additionalProperties": false "additionalProperties": false
} }
}, },