Files
knowledge-governance/web/src/qaAILocalDerivation.test.tsx
T
姚章浩 1580ebd826
build / build (push) Successful in 1m8s
feat(qaops): 增加第40至43周实时累计趋势及受控回填依据
按北京时间各自然周截止对整张统计总表累计计数,字段取当前有效结论。
覆盖和正确各按周报是除以是加否,保留历史上报与冻结并优先展示动态累计。
新增30秒顺序刷新、本地规则和历史复用非模型依据,保护当前原问答与人工字段。

验证:完整make verify通过;隔离PostgreSQL全量mirror race通过;
恢复库与真实周报calc_metrics四点对拍、源点踩自然刷新、桌面/390px及PNG通过。
新增源同步成员变化、人工版本保护及跨策略标签间距回归已通过。
模型全量语义风险审核及正式业务回填尚未完成,未部署本版本。
2026-10-20 11:09:47 +08:00

49 lines
1.9 KiB
TypeScript

import { expect, it } from 'vitest'
import { renderToStaticMarkup } from 'react-dom/server'
import { parseAIEvidence } from './qaAITypes'
import { QAAIEvidenceView } from './QAAI'
const wire = {
id: 'fixture-local-proof',
record_id: 'fixture-record',
kind: 'evaluation',
state: 'succeeded',
stage: 'local_imported',
attempt: 1,
error_code: '',
skip_reason: '',
started_at: null,
updated_at: '2026-10-20T00:00:00Z',
input_hash: 'a'.repeat(64),
config_revision: 0,
prompt_version: 'qa-local-derivation-v1',
dictionary_version: 'qa-approved-labels-v1',
actual_model: 'local-rule-history-v1',
result: {
local_derivations: {
language: { value: '中文', kind: 'local_rule', reason: '原问题本地语言规则,不调用模型' },
question_chinese: { value: 'MG400如何连接?', kind: 'original_chinese_copy', reason: '原始中文逐字保留' },
product_category: { value: 'MG400', kind: 'unique_history_question_label', reason: '历史同问题标签唯一一致' },
},
},
applied_fields: { language: '中文', question_chinese: 'MG400如何连接?', product_category: 'MG400' },
skipped_fields: {},
}
it('renders field-level local and history provenance without pretending it is model output', () => {
const result = parseAIEvidence(wire)
expect(result.result).toHaveProperty('local_derivations')
const html = renderToStaticMarkup(<QAAIEvidenceView evidence={[result]} />)
for (const text of [
'本地规则/历史复用(非模型)',
'原问题本地语言规则,不调用模型',
'原始中文逐字保留',
'历史同问题标签唯一一致',
'中文',
'MG400',
])
expect(html).toContain(text)
expect(html).not.toContain('实际返回模型')
})
it('rejects local provenance falsely attached to a GPT response', () => {
expect(() => parseAIEvidence({ ...wire, actual_model: 'gpt-6.1-sol' })).toThrow()
})