修正筛选入口位置:五项条件在表头就地选择,保持完整集筛选与无感续载。 统一固定规则:未覆盖一律待确认,原问答/人工模型证据不改写,已覆盖仍保留点踩优先。 验证:行为红绿、前端/Go全套及隔离PostgreSQL全mirror竞态通过;完整本地门禁与原生备份真实恢复通过。
This commit is contained in:
+51
-58
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { editableFieldKeys, fetchFieldOptions } from './qaInlineFields'
|
||||
import type { FieldOptions } from './qaInlineFields'
|
||||
import { fetchFieldOptions } from './qaInlineFields'
|
||||
import type { EditableField, FieldOptions } from './qaInlineFields'
|
||||
import type { QAQuery } from './qaOps'
|
||||
export const qualityFilterLabels = {
|
||||
coverage: '是否覆盖',
|
||||
@@ -9,69 +9,62 @@ export const qualityFilterLabels = {
|
||||
problem_type: '问题类型',
|
||||
root_cause: '根因分析',
|
||||
}
|
||||
export function QAFieldFilters({
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
value: NonNullable<QAQuery['filters']>
|
||||
onChange: (value: NonNullable<QAQuery['filters']>) => void
|
||||
}) {
|
||||
const [options, setOptions] = useState<FieldOptions | null>(null),
|
||||
[error, setError] = useState(''),
|
||||
[revision, setRevision] = useState(0)
|
||||
export function useQAFieldFilterOptions(enabled: boolean) {
|
||||
const [options, setOptions] = useState<FieldOptions | null>(null)
|
||||
const [error, setError] = useState('')
|
||||
const [revision, setRevision] = useState(0)
|
||||
useEffect(() => {
|
||||
if (!enabled) return
|
||||
const abort = new AbortController()
|
||||
setError('')
|
||||
void fetchFieldOptions(abort.signal)
|
||||
.then((v) => {
|
||||
if (!abort.signal.aborted) setOptions(v)
|
||||
.then((value) => {
|
||||
if (!abort.signal.aborted) setOptions(value)
|
||||
})
|
||||
.catch((e) => {
|
||||
if (!abort.signal.aborted) setError(e instanceof Error ? e.message : '筛选选项读取失败')
|
||||
.catch((reason) => {
|
||||
if (!abort.signal.aborted) setError(reason instanceof Error ? reason.message : '筛选选项读取失败')
|
||||
})
|
||||
return () => abort.abort()
|
||||
}, [revision])
|
||||
}, [enabled, revision])
|
||||
return { options, error, retry: () => setRevision((value) => value + 1) }
|
||||
}
|
||||
export function QAHeaderFieldFilter({
|
||||
field,
|
||||
value,
|
||||
options,
|
||||
onChange,
|
||||
}: {
|
||||
field: EditableField
|
||||
value: NonNullable<QAQuery['filters']>
|
||||
options: FieldOptions | null
|
||||
onChange: (value: NonNullable<QAQuery['filters']>) => void
|
||||
}) {
|
||||
return (
|
||||
<div className="qa-field-filters" aria-label="质量字段筛选">
|
||||
{editableFieldKeys.map((key) => (
|
||||
<label key={key}>
|
||||
{qualityFilterLabels[key]}
|
||||
<select
|
||||
aria-label={'筛选' + qualityFilterLabels[key]}
|
||||
value={value[key] ?? ''}
|
||||
disabled={!options}
|
||||
onChange={(e) => {
|
||||
const next = { ...value }
|
||||
if (e.target.value) next[key] = e.target.value
|
||||
else delete next[key]
|
||||
onChange(next)
|
||||
}}
|
||||
>
|
||||
<option value="">全部</option>
|
||||
<option value="__empty__">未设置</option>
|
||||
{options?.[key].map((option) => (
|
||||
<option key={option} value={option}>
|
||||
{key === 'is_correct'
|
||||
? ({ 是: '正确', 否: '错误', 待确认: '待确认' }[option] ?? option)
|
||||
: key === 'coverage'
|
||||
? ({ 是: '已覆盖', 否: '未覆盖', 否但不计入: '不计入' }[option] ?? option)
|
||||
: option}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
))}
|
||||
<button type="button" disabled={!Object.keys(value).length} onClick={() => onChange({})}>
|
||||
清除字段筛选
|
||||
</button>
|
||||
{error ? (
|
||||
<span role="alert">
|
||||
{error}{' '}
|
||||
<button type="button" onClick={() => setRevision((v) => v + 1)}>
|
||||
重试选项
|
||||
</button>
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<label className="qa-header-field-filter">
|
||||
<span>{qualityFilterLabels[field]}</span>
|
||||
<select
|
||||
aria-label={'筛选' + qualityFilterLabels[field]}
|
||||
value={value[field] ?? ''}
|
||||
disabled={!options}
|
||||
onChange={(event) => {
|
||||
const next = { ...value }
|
||||
if (event.target.value) next[field] = event.target.value
|
||||
else delete next[field]
|
||||
onChange(next)
|
||||
}}
|
||||
>
|
||||
<option value="">全部</option>
|
||||
<option value="__empty__">未设置</option>
|
||||
{options?.[field].map((option) => (
|
||||
<option key={option} value={option}>
|
||||
{field === 'is_correct'
|
||||
? ({ 是: '正确', 否: '错误', 待确认: '待确认' }[option] ?? option)
|
||||
: field === 'coverage'
|
||||
? ({ 是: '已覆盖', 否: '未覆盖', 否但不计入: '不计入' }[option] ?? option)
|
||||
: option}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ export function QAInlineFields({
|
||||
const value = pending?.field === field ? pending.value : editableFieldValue(record, field)
|
||||
const choices = fieldChoices(field, options?.[field] ?? [], editableFieldValue(record, 'coverage'))
|
||||
const rootNotNeeded = field === 'root_cause' && editableFieldValue(record, 'is_correct') === '是'
|
||||
const uncoveredLocked = field === 'is_correct' && editableFieldValue(record, 'coverage') === '否'
|
||||
const downvoteLocked = field === 'is_correct' && record.quality?.feedback_rule === 'downvote-is-incorrect-v1'
|
||||
return (
|
||||
<div key={field} data-quality-field={field}>
|
||||
@@ -79,7 +80,13 @@ export function QAInlineFields({
|
||||
<span>{qaColumns.find((c) => c.key === field)!.label}</span>
|
||||
<select
|
||||
aria-label={`修改${qaColumns.find((c) => c.key === field)!.label}`}
|
||||
title={downvoteLocked ? '已点踩,是否正确固定为否' : '选择后自动保存'}
|
||||
title={
|
||||
uncoveredLocked
|
||||
? '未覆盖,是否正确固定为待确认'
|
||||
: downvoteLocked
|
||||
? '已点踩,是否正确固定为否'
|
||||
: '选择后自动保存'
|
||||
}
|
||||
value={rootNotNeeded ? '' : value}
|
||||
disabled={
|
||||
saving ||
|
||||
@@ -88,7 +95,8 @@ export function QAInlineFields({
|
||||
!record.record_origin ||
|
||||
!record.quality ||
|
||||
rootNotNeeded ||
|
||||
downvoteLocked
|
||||
downvoteLocked ||
|
||||
uncoveredLocked
|
||||
}
|
||||
style={qaFieldColors(field, value || '—')}
|
||||
onChange={(e) => {
|
||||
@@ -121,6 +129,9 @@ export function QAInlineFields({
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
{editableFieldValue(record, 'coverage') === '否' ? (
|
||||
<p className="qa-inline-save">未覆盖,是否正确固定为待确认</p>
|
||||
) : null}
|
||||
{record.quality?.feedback_rule === 'downvote-is-incorrect-v1' ? (
|
||||
<p className="qa-inline-save">已点踩,是否正确固定为否</p>
|
||||
) : null}
|
||||
|
||||
@@ -52,6 +52,18 @@ const props = {
|
||||
}
|
||||
|
||||
describe('QA operations workbench', () => {
|
||||
it('puts all five selectors in their own table header cells, including empty filtered results', () => {
|
||||
const filtering = { filters: { coverage: '否' }, onFiltersChange: vi.fn() }
|
||||
for (const value of [page, { ...page, items: [], total: 0, has_more: false }]) {
|
||||
const html = renderToStaticMarkup(<QAOperationsView {...props} {...filtering} page={value} />)
|
||||
const head = html.slice(html.indexOf('<thead>'), html.indexOf('</thead>'))
|
||||
expect((head.match(/<select/g) ?? []).length).toBe(5)
|
||||
for (const label of ['是否覆盖', '是否正确', '产品分类', '问题类型', '根因分析'])
|
||||
expect(head).toContain('aria-label="筛选' + label + '"')
|
||||
expect(html).toContain('清除字段筛选')
|
||||
}
|
||||
})
|
||||
|
||||
it('keeps the first rows interactive while later batches load or fail', () => {
|
||||
const prefix = { ...page, total: 2, has_more: true, next_cursor: 'next' }
|
||||
const loading = renderToStaticMarkup(<QAOperationsView {...props} page={prefix} loading={true} />)
|
||||
@@ -235,10 +247,10 @@ it('names the ledger explicitly as 问题流水表', () => {
|
||||
expect(html).toContain('>问题流水表</button>')
|
||||
})
|
||||
|
||||
it('keeps five field filters in a dedicated wrapped row after all primary query actions', () => {
|
||||
it('styles filters inside the header instead of reserving a separate query row', () => {
|
||||
const css = readFileSync(new URL('./qaOps.css', import.meta.url), 'utf8')
|
||||
expect(css).not.toMatch(/\.qa-ops-query\s*\{[^}]*flex-wrap:\s*nowrap/)
|
||||
expect(css).toMatch(/\.qa-field-filters\s*\{[^}]*order:\s*1/)
|
||||
expect(css).toContain('.qa-header-field-filter select')
|
||||
expect(css).not.toContain('.qa-field-filters')
|
||||
})
|
||||
|
||||
it('uses matching query/sync action sizing and keeps synchronization status outside the button baseline', () => {
|
||||
|
||||
@@ -9,7 +9,9 @@ import { QARegionalStatistics } from './QADepartmentStatistics'
|
||||
import { QADashboard } from './QADashboard'
|
||||
import { QAWeekly } from './QAWeekly'
|
||||
import { QAInlineFields } from './QAInlineFields'
|
||||
import { QAFieldFilters } from './QAFieldFilters'
|
||||
import { QAHeaderFieldFilter, useQAFieldFilterOptions } from './QAFieldFilters'
|
||||
import { editableFieldKeys } from './qaInlineFields'
|
||||
import type { EditableField } from './qaInlineFields'
|
||||
import { buildQAWeeklyCSV, downloadQAWeekly } from './qaWeekly'
|
||||
import { qaFieldColors, qaTagColumns } from './qaFieldColors'
|
||||
import { qualityLabels } from './qaQuality'
|
||||
@@ -40,6 +42,8 @@ export function QAOperationsTabs({ view, onChange }: { view: QAOpsView; onChange
|
||||
)
|
||||
}
|
||||
interface ViewProps {
|
||||
filters?: QAQuery['filters']
|
||||
onFiltersChange?: (value: NonNullable<QAQuery['filters']>) => void
|
||||
taskUpdates?: AIWorkState[]
|
||||
onQualitySaved?: (record: QARecord) => void
|
||||
onReloadDetail?: () => void
|
||||
@@ -143,6 +147,8 @@ const ledgerColumnWidth = (key: string) =>
|
||||
: 125
|
||||
export function QAOperationsView(props: ViewProps) {
|
||||
const page = props.page
|
||||
const items = page?.items ?? []
|
||||
const filterOptions = useQAFieldFilterOptions(Boolean(props.onFiltersChange))
|
||||
const scrollRef = useRef<HTMLDivElement>(null)
|
||||
const [viewport, setViewport] = useState({ top: 0, height: 600 })
|
||||
const visible = ledgerWindow(page?.items.length ?? 0, viewport.top, viewport.height)
|
||||
@@ -150,7 +156,10 @@ export function QAOperationsView(props: ViewProps) {
|
||||
const element = scrollRef.current
|
||||
if (!element) return
|
||||
const observer = new ResizeObserver(() =>
|
||||
setViewport({ top: Math.max(0, element.scrollTop - 40), height: element.clientHeight })
|
||||
setViewport({
|
||||
top: Math.max(0, element.scrollTop - (element.querySelector('thead')?.getBoundingClientRect().height ?? 40)),
|
||||
height: element.clientHeight,
|
||||
})
|
||||
)
|
||||
observer.observe(element)
|
||||
return () => observer.disconnect()
|
||||
@@ -178,6 +187,11 @@ export function QAOperationsView(props: ViewProps) {
|
||||
: '尚未读取问答'}
|
||||
</span>
|
||||
<small className="qa-ops-muted">双击行查看详情</small>
|
||||
{props.onFiltersChange && Object.keys(props.filters ?? {}).length ? (
|
||||
<button type="button" onClick={() => props.onFiltersChange?.({})}>
|
||||
清除字段筛选
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{props.status?.warnings
|
||||
@@ -187,6 +201,14 @@ export function QAOperationsView(props: ViewProps) {
|
||||
{warningLabels[warning] ?? '数据源有待审核的安全告警'}
|
||||
</p>
|
||||
))}
|
||||
{filterOptions.error ? (
|
||||
<p className="error-banner" role="alert">
|
||||
{filterOptions.error}{' '}
|
||||
<button type="button" onClick={filterOptions.retry}>
|
||||
重试选项
|
||||
</button>
|
||||
</p>
|
||||
) : null}
|
||||
{props.error ? (
|
||||
<div className="error-banner" role="alert">
|
||||
{props.error}{' '}
|
||||
@@ -195,7 +217,7 @@ export function QAOperationsView(props: ViewProps) {
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
{page && page.items.length > 0 ? (
|
||||
{items.length > 0 || props.onFiltersChange ? (
|
||||
<div
|
||||
ref={scrollRef}
|
||||
className="qa-ops-table-scroll"
|
||||
@@ -203,12 +225,18 @@ export function QAOperationsView(props: ViewProps) {
|
||||
tabIndex={0}
|
||||
onScroll={(event) => {
|
||||
const element = event.currentTarget
|
||||
setViewport({ top: Math.max(0, element.scrollTop - 40), height: element.clientHeight })
|
||||
setViewport({
|
||||
top: Math.max(
|
||||
0,
|
||||
element.scrollTop - (element.querySelector('thead')?.getBoundingClientRect().height ?? 40)
|
||||
),
|
||||
height: element.clientHeight,
|
||||
})
|
||||
}}
|
||||
>
|
||||
<table
|
||||
className="qa-ops-table"
|
||||
aria-rowcount={page.items.length + 1}
|
||||
aria-rowcount={items.length + 1}
|
||||
style={{ width: qaColumns.reduce((sum, c) => sum + ledgerColumnWidth(c.key), 160) }}
|
||||
>
|
||||
<colgroup>
|
||||
@@ -220,18 +248,36 @@ export function QAOperationsView(props: ViewProps) {
|
||||
<thead>
|
||||
<tr>
|
||||
{columns.map(({ key, label }) => (
|
||||
<th key={key}>{label}</th>
|
||||
<th key={key}>
|
||||
{props.onFiltersChange && editableFieldKeys.includes(key as EditableField) ? (
|
||||
<QAHeaderFieldFilter
|
||||
field={key as EditableField}
|
||||
options={filterOptions.options}
|
||||
value={props.filters ?? {}}
|
||||
onChange={props.onFiltersChange}
|
||||
/>
|
||||
) : (
|
||||
label
|
||||
)}
|
||||
</th>
|
||||
))}
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{!items.length && page && !props.loading && !props.error ? (
|
||||
<tr>
|
||||
<td colSpan={columns.length + 1} className="qa-ops-empty">
|
||||
没有符合条件的问答,请调整表头筛选、时间范围或关键词。
|
||||
</td>
|
||||
</tr>
|
||||
) : null}
|
||||
{visible.padTop > 0 ? (
|
||||
<tr aria-hidden="true" className="qa-ledger-spacer">
|
||||
<td colSpan={columns.length + 1} style={{ height: visible.padTop }} />
|
||||
</tr>
|
||||
) : null}
|
||||
{page.items.slice(visible.start, visible.end).map((item, index) => {
|
||||
{items.slice(visible.start, visible.end).map((item, index) => {
|
||||
const tasks = tasksFor(item, updates.get(item.id))
|
||||
return (
|
||||
<QARow
|
||||
@@ -490,6 +536,10 @@ export function QAOperations() {
|
||||
setError(reason instanceof Error ? reason.message : '时间格式无效')
|
||||
}
|
||||
}
|
||||
const changeFilters = useCallback((next: NonNullable<QAQuery['filters']>) => {
|
||||
setFilters(next)
|
||||
setQuery((current) => (current ? { ...current, cursor: '', filters: { ...next } } : current))
|
||||
}, [])
|
||||
const select = useCallback(async (id: string) => {
|
||||
detailRequest.current?.abort()
|
||||
returnFocus.current = document.activeElement as HTMLElement | null
|
||||
@@ -611,7 +661,6 @@ export function QAOperations() {
|
||||
<button className="qa-query-action" type="submit">
|
||||
查询
|
||||
</button>
|
||||
<QAFieldFilters value={filters} onChange={setFilters} />
|
||||
<QAMirrorSync
|
||||
onChanged={() => {
|
||||
if (detail || detailLoading) {
|
||||
@@ -666,6 +715,8 @@ export function QAOperations() {
|
||||
/>
|
||||
) : (
|
||||
<QAOperationsView
|
||||
filters={query?.filters ?? filters}
|
||||
onFiltersChange={changeFilters}
|
||||
page={page}
|
||||
status={status}
|
||||
taskUpdates={aiStatus?.recent_tasks}
|
||||
|
||||
@@ -33,6 +33,27 @@ it('does not accept a fabricated downvote rule or use it to change unrelated hum
|
||||
})
|
||||
).toThrow()
|
||||
})
|
||||
it('accepts only the explicit uncovered-pending rule while preserving older human correctness', () => {
|
||||
const original = { ...fields, coverage: 'uncovered', correctness: 'incorrect' }
|
||||
const wire = {
|
||||
...downvoted,
|
||||
master_fields: { coverage: '否', is_correct: '待确认' },
|
||||
quality: {
|
||||
...qualityFixture,
|
||||
effective_source: 'master-effective-fields-v1',
|
||||
correctness_rule: 'coverage-correctness-v1',
|
||||
latest_review: { ...qualityFixture.latest_review, fields: original },
|
||||
effective: { ...original, correctness: 'pending' },
|
||||
},
|
||||
}
|
||||
const row = parseQARecord(wire)
|
||||
expect(qaCellValue(row, 'is_correct')).toBe('待确认')
|
||||
expect(row.quality?.latest_review?.fields.correctness).toBe('incorrect')
|
||||
expect(() => parseQARecord({ ...wire, quality: { ...wire.quality, correctness_rule: 'unknown' } })).toThrow()
|
||||
expect(() =>
|
||||
parseQARecord({ ...wire, quality: { ...wire.quality, effective: { ...original, correctness: 'correct' } } })
|
||||
).toThrow()
|
||||
})
|
||||
it('explains the fixed negative correctness without restoring the removed review form', () => {
|
||||
const row = parseQARecord(downvoted)
|
||||
const html = renderToStaticMarkup(
|
||||
|
||||
@@ -4,7 +4,7 @@ describe('correctness choices follow effective coverage', () => {
|
||||
it('allows pending only for uncovered, without changing coverage options', () => {
|
||||
for (const coverage of ['是', '部分覆盖', '待确认', '否但不计入', ''])
|
||||
expect(fieldChoices('is_correct', ['是', '否', '待确认'], coverage)).toEqual(['是', '否'])
|
||||
expect(fieldChoices('is_correct', ['是', '否', '待确认'], '否')).toEqual(['是', '否', '待确认'])
|
||||
expect(fieldChoices('is_correct', ['是', '否', '待确认'], '否')).toEqual(['待确认'])
|
||||
expect(fieldChoices('coverage', ['是', '否', '待确认'], '是')).toEqual(['是', '否', '待确认'])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,7 +4,10 @@ export const editableFieldKeys = ['coverage', 'is_correct', 'product_category',
|
||||
export type EditableField = (typeof editableFieldKeys)[number]
|
||||
export type FieldOptions = Record<EditableField, string[]>
|
||||
export function fieldChoices(field: EditableField, choices: string[], coverage: string): string[] {
|
||||
return field === 'is_correct' && coverage !== '否' ? choices.filter((value) => value !== '待确认') : choices
|
||||
if (field !== 'is_correct') return choices
|
||||
return coverage === '否'
|
||||
? choices.filter((value) => value === '待确认')
|
||||
: choices.filter((value) => value !== '待确认')
|
||||
}
|
||||
export function parseFieldOptions(raw: unknown): FieldOptions {
|
||||
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) throw Error('主表选项读取失败')
|
||||
|
||||
+7
-18
@@ -705,28 +705,22 @@
|
||||
border: 1px solid var(--border-base);
|
||||
}
|
||||
|
||||
.qa-field-filters {
|
||||
.qa-header-field-filter {
|
||||
display: flex;
|
||||
order: 1;
|
||||
flex: 1 0 100%;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 10px;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
}
|
||||
.qa-ops-query .qa-field-filters label {
|
||||
flex: 1 1 140px;
|
||||
min-width: 0;
|
||||
}
|
||||
.qa-field-filters select {
|
||||
.qa-header-field-filter select {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
height: 36px;
|
||||
padding: 6px 9px;
|
||||
height: 28px;
|
||||
padding: 3px 5px;
|
||||
color: var(--ink-strong);
|
||||
background: var(--bg-panel);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--r-sm);
|
||||
font: inherit;
|
||||
}
|
||||
.qa-ledger-export {
|
||||
display: flex;
|
||||
@@ -738,8 +732,3 @@
|
||||
color: var(--danger-ink);
|
||||
font-size: 12px;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.qa-ops-query .qa-field-filters label {
|
||||
flex: 1 1 120px;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-2
@@ -27,6 +27,7 @@ export interface QualityReview {
|
||||
export interface QAQuality {
|
||||
effective_source?: 'master-effective-fields-v1'
|
||||
feedback_rule?: 'downvote-is-incorrect-v1'
|
||||
correctness_rule?: 'coverage-correctness-v1'
|
||||
input_hash: string
|
||||
input_epoch: number
|
||||
revision: number
|
||||
@@ -220,6 +221,15 @@ export function parseQAQuality(value: unknown, allowMasterProjection = false, ha
|
||||
state === 'reviewed' ? latest_review!.fields : { ...emptyQualityFields, coverage: automatic.result.verdict || '' }
|
||||
const master = v.effective_source === 'master-effective-fields-v1'
|
||||
if (v.effective_source !== undefined && (!master || !allowMasterProjection)) return bad()
|
||||
const coverageRule = v.correctness_rule === 'coverage-correctness-v1'
|
||||
if (
|
||||
v.correctness_rule !== undefined &&
|
||||
(!coverageRule ||
|
||||
!master ||
|
||||
!allowMasterProjection ||
|
||||
(effective.coverage === 'uncovered' ? effective.correctness !== 'pending' : effective.correctness !== ''))
|
||||
)
|
||||
return bad()
|
||||
const downvoteRule = v.feedback_rule === 'downvote-is-incorrect-v1'
|
||||
if (
|
||||
v.feedback_rule !== undefined &&
|
||||
@@ -227,11 +237,15 @@ export function parseQAQuality(value: unknown, allowMasterProjection = false, ha
|
||||
)
|
||||
return bad()
|
||||
for (const key of Object.keys(expected) as (keyof QualityFields)[]) {
|
||||
// Only the explicit feedback rule may override correctness; the human evidence stays intact.
|
||||
// Explicit fixed rules may replace effective correctness, never the historical review.
|
||||
if (master) {
|
||||
if (
|
||||
state === 'reviewed' &&
|
||||
!(downvoteRule && key === 'correctness') &&
|
||||
!(
|
||||
(downvoteRule ||
|
||||
(coverageRule && (effective.coverage === 'uncovered' || expected.correctness === 'pending'))) &&
|
||||
key === 'correctness'
|
||||
) &&
|
||||
(expected[key] !== '' || (key === 'root_cause' && expected.correctness === 'correct')) &&
|
||||
expected[key] !== effective[key]
|
||||
)
|
||||
@@ -248,6 +262,7 @@ export function parseQAQuality(value: unknown, allowMasterProjection = false, ha
|
||||
effective,
|
||||
...(master ? { effective_source: 'master-effective-fields-v1' as const } : {}),
|
||||
...(downvoteRule ? { feedback_rule: 'downvote-is-incorrect-v1' as const } : {}),
|
||||
...(coverageRule ? { correctness_rule: 'coverage-correctness-v1' as const } : {}),
|
||||
}
|
||||
}
|
||||
function qualityRate(value: unknown): QualityRate {
|
||||
|
||||
Reference in New Issue
Block a user