mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-17 13:11:58 +00:00
数据目录 F2b / B7:剖析报告里关系的结论按实际变化说——原本就是已验证、这次照样核实的写「仍为已验证,覆盖率 x」,从推断升上来的才写「升为已验证」,已验证降回推断的写「降为推断」;服务端最小改动:关系结论多带 previous_status(剖析前的状态),summary 同步写「仍为有确证」;补后端测试和检查脚本的断言
This commit is contained in:
@@ -910,10 +910,13 @@ async def _check_dates(cx: _Context, table: str, columns: list[str], total: int,
|
||||
|
||||
|
||||
def _relation_finding(o: _RelationOutcome, rel: dict[str, Any], *, status: str, confirmed: bool) -> dict[str, Any]:
|
||||
"""一条关系的核实结论。previous_status 是剖析之前目录里这条关系的状态:报告按它说「升为已验证」还是「仍为已验证」
|
||||
(重新剖析、目录没变时不能说升了)。"""
|
||||
previous = rel.get("status")
|
||||
if confirmed:
|
||||
summary = "已人工确认,只补充覆盖率和基数"
|
||||
elif status == "verified":
|
||||
summary = f"覆盖率 {_percent(o.coverage)},升为有确证"
|
||||
summary = f"覆盖率 {_percent(o.coverage)}," + ("仍为有确证" if previous == "verified" else "升为有确证")
|
||||
elif o.coverage < catalog.PROFILE_VERIFY_COVERAGE:
|
||||
summary = f"抽样覆盖率 {_percent(o.coverage)},保持推断"
|
||||
else:
|
||||
@@ -921,8 +924,8 @@ def _relation_finding(o: _RelationOutcome, rel: dict[str, Any], *, status: str,
|
||||
return {"kind": "relation", "path": f"relations.{o.rid}", "target": o.target,
|
||||
"columns": list(rel.get("columns") or []), "to_table": rel.get("to_table"),
|
||||
"to_columns": list(rel.get("to_columns") or []), "status": status, "confirmed": confirmed,
|
||||
"coverage": o.coverage, "cardinality": o.cardinality, "sample": o.sample, "matched": o.matched,
|
||||
"summary": summary}
|
||||
"previous_status": previous, "coverage": o.coverage, "cardinality": o.cardinality, "sample": o.sample,
|
||||
"matched": o.matched, "summary": summary}
|
||||
|
||||
|
||||
def _codes_value(c: _CodesOutcome, item: dict[str, Any] | None) -> dict[str, str]:
|
||||
|
||||
@@ -277,6 +277,11 @@ async def test_rerun_with_same_data_changes_nothing(client, make_source, scenic_
|
||||
a, b = _table(first, "visits"), _table(second, "visits")
|
||||
assert (b["added"], b["updated"], b["removed"]) == (0, 0, 0)
|
||||
assert b["version"] == a["version"]
|
||||
# 逐条结论按实际变化说:第一次是从推断升上来的,第二次原本就是已验证,不能再说「升为」
|
||||
gate_a = next(f for f in a["findings"] if f.get("columns") == ["gate_id"])
|
||||
gate_b = next(f for f in b["findings"] if f.get("columns") == ["gate_id"])
|
||||
assert (gate_a["previous_status"], gate_a["status"]) == ("proposed", "verified") and "升为有确证" in gate_a["summary"]
|
||||
assert (gate_b["previous_status"], gate_b["status"]) == ("verified", "verified") and "仍为有确证" in gate_b["summary"]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 安全约束
|
||||
|
||||
@@ -2517,6 +2517,9 @@ export const CATALOG_UI_TEXT = {
|
||||
editMeanings: '修改含义',
|
||||
editMeaningsLabel: (col: string) => `修改含义:列 ${col} 的码值`,
|
||||
fillWhileEditing: '正在编辑这张表,保存或取消后再填写码值的含义',
|
||||
// ---- 剖析报告里关系的结论:按这次的实际变化说(原本就是已验证的不说「升为」)
|
||||
relationStillVerified: (coverage: string) => `仍为已验证,覆盖率 ${coverage}`,
|
||||
relationLowered: (reason: string) => `降为推断:${reason}`,
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { ArrowUpRight, CircleCheck, OctagonX, ScanSearch, ShieldAlert, TriangleAlert } from 'lucide-react'
|
||||
import { ArrowDown, ArrowUp, ArrowUpRight, CircleCheck, Equal, Minus, OctagonX, ScanSearch, ShieldAlert, TriangleAlert, UserCheck } from 'lucide-react'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
import clsx from 'clsx'
|
||||
import type {
|
||||
CatalogProfileCodesFinding, CatalogProfileDateFinding, CatalogProfileOut, CatalogProfileRelationFinding, CatalogProfileSettings,
|
||||
@@ -386,12 +387,27 @@ function Group({ title, children }: { title: string; children: ReactNode }) {
|
||||
)
|
||||
}
|
||||
|
||||
type RelationOutcome = 'confirmed' | 'raised' | 'same' | 'lowered' | 'kept'
|
||||
|
||||
/**
|
||||
* 一条关系这次剖析的结论,按实际变化说:原本就是已验证、这次照样核实的写「仍为已验证,覆盖率 x」,不能说「升为」——
|
||||
* 重新剖析、目录没变时报告头写「目录没有变化」,下面却说升了,自相矛盾。老服务端不给剖析前的状态,按升级说
|
||||
*/
|
||||
function relationOutcome(f: CatalogProfileRelationFinding): { kind: RelationOutcome; text: string; tone: string; icon: LucideIcon } {
|
||||
const reason = f.coverage < 0.95 ? PT.relationLowCoverage : PT.relationNotUnique
|
||||
if (f.confirmed) return { kind: 'confirmed', text: PT.relationConfirmed, tone: STATUS_TONE.confirmed, icon: UserCheck }
|
||||
if (f.status === 'verified') {
|
||||
return f.previous_status === 'verified'
|
||||
? { kind: 'same', text: UT.relationStillVerified(coverageText(f.coverage)), tone: STATUS_TONE.verified, icon: Equal }
|
||||
: { kind: 'raised', text: PT.relationVerified, tone: STATUS_TONE.verified, icon: ArrowUp }
|
||||
}
|
||||
return f.previous_status === 'verified'
|
||||
? { kind: 'lowered', text: UT.relationLowered(reason), tone: STATUS_TONE.proposed, icon: ArrowDown }
|
||||
: { kind: 'kept', text: `${PT.relationKept}:${reason}`, tone: STATUS_TONE.proposed, icon: Minus }
|
||||
}
|
||||
|
||||
function RelationLine({ f }: { f: CatalogProfileRelationFinding }) {
|
||||
const outcome = f.confirmed
|
||||
? { text: PT.relationConfirmed, tone: 'var(--text-dim)' }
|
||||
: f.status === 'verified'
|
||||
? { text: PT.relationVerified, tone: STATUS_TONE.verified }
|
||||
: { text: `${PT.relationKept}:${f.coverage < 0.95 ? PT.relationLowCoverage : PT.relationNotUnique}`, tone: STATUS_TONE.proposed }
|
||||
const outcome = relationOutcome(f)
|
||||
return (
|
||||
<li className="text-xs" data-profile-finding="relation" data-status={f.status} data-path={f.path}>
|
||||
<div className="flex flex-wrap items-center gap-x-1.5 gap-y-0.5">
|
||||
@@ -405,7 +421,7 @@ function RelationLine({ f }: { f: CatalogProfileRelationFinding }) {
|
||||
{' · '}
|
||||
{PT.sampled(f.sample, f.matched)}
|
||||
</div>
|
||||
<div className="mt-0.5 text-2xs" style={{ color: outcome.tone }} data-profile-outcome="">{outcome.text}</div>
|
||||
<div className="mt-0.5 text-2xs" style={{ color: outcome.tone }} data-profile-outcome={outcome.kind}>{outcome.text}</div>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2850,6 +2850,8 @@ export interface CatalogProfileRelationFinding {
|
||||
to_columns: string[]
|
||||
status: CatalogStatus
|
||||
confirmed: boolean
|
||||
/** 剖析之前目录里这条关系的状态:报告按它说「升为已验证」还是「仍为已验证」。老服务端不给 */
|
||||
previous_status?: CatalogStatus | null
|
||||
coverage: number
|
||||
cardinality: CatalogCardinality | null
|
||||
/** 抽了几个不同的键值、在被指向表里对上几个 */
|
||||
|
||||
@@ -1248,6 +1248,9 @@ function profileReply(state, { ms = 0, extraCodes = false } = {}) {
|
||||
const visits = state.tables[S1].find((t) => t.name === 'visits')
|
||||
const notes = clone(visits.notes)
|
||||
const at = `${PROFILE_DAY}T03:00:00+00:00`
|
||||
// 剖析之前这两条关系的状态(服务端 previous_status):第一次闸机关系是命名推断,再剖析一次时已经是已验证
|
||||
const before = (id) => visits.notes.relations.find((r) => r.id === id)?.status ?? null
|
||||
const previous = { gate: before(GATE_REL), member: before(MEMBER_REL) }
|
||||
notes.relations = notes.relations.map((r) => (r.id === GATE_REL ? {
|
||||
...r, source: 'profile', status: 'verified', coverage: 0.987, cardinality: 'many_to_one', updated_at: at,
|
||||
note: `数据剖析(${PROFILE_DAY}):子表抽样 300 个不同键值,父表对上 296 个,覆盖率 98.7%;被指向列是主键;子表一侧有重复值,多对一。`,
|
||||
@@ -1266,9 +1269,11 @@ function profileReply(state, { ms = 0, extraCodes = false } = {}) {
|
||||
table_name: 'visits', queries: 38, row_estimate: { rows: 182000, method: 'stats', at_least: null },
|
||||
findings: [
|
||||
{ kind: 'relation', path: `relations.${GATE_REL}`, target: 'gate_id → gates.id', columns: ['gate_id'], to_table: 'gates', to_columns: ['id'],
|
||||
status: 'verified', confirmed: false, coverage: 0.987, cardinality: 'many_to_one', sample: 300, matched: 296, summary: '覆盖率 98.7%,升为有确证' },
|
||||
status: 'verified', confirmed: false, previous_status: previous.gate, coverage: 0.987, cardinality: 'many_to_one', sample: 300, matched: 296,
|
||||
summary: previous.gate === 'verified' ? '覆盖率 98.7%,仍为有确证' : '覆盖率 98.7%,升为有确证' },
|
||||
{ kind: 'relation', path: `relations.${MEMBER_REL}`, target: 'member_id → members.id', columns: ['member_id'], to_table: 'members',
|
||||
to_columns: ['id'], status: 'proposed', confirmed: false, coverage: 0.62, cardinality: 'many_to_one', sample: 200, matched: 124,
|
||||
to_columns: ['id'], status: 'proposed', confirmed: false, previous_status: previous.member, coverage: 0.62, cardinality: 'many_to_one',
|
||||
sample: 200, matched: 124,
|
||||
summary: '抽样覆盖率 62%,保持推断' },
|
||||
{ kind: 'codes', path: 'columns.status.codes', column: 'status', values: [{ value: '1', rows: 171080 }, { value: '9', rows: 9100 },
|
||||
{ value: '2', rows: 1820 }], rows: 182000, status: 'proposed', summary: '3 个取值,1 个含义待填写' },
|
||||
@@ -1558,6 +1563,13 @@ await section('数据目录 · 数据剖析', async () => {
|
||||
await page.locator('[data-profile-start]').click()
|
||||
await until(async () => (await profilePhase(page)) === 'done')
|
||||
check('窗口开着时完成:直接看报告,不另弹提示', (await toastBox.count()) <= 1)
|
||||
// 重新剖析:闸机关系上一次已经核实成已验证,这次照样核实——写「仍为已验证」,不说「升为已验证」
|
||||
const gateAgain = profileBox(page).locator(`[data-profile-finding="relation"][data-path="relations.${GATE_REL}"] [data-profile-outcome]`)
|
||||
check('重新剖析:原本就是已验证的关系写「仍为已验证,覆盖率 98.7%」,不说「升为」', (await gateAgain.innerText()) === '仍为已验证,覆盖率 98.7%'
|
||||
&& (await gateAgain.getAttribute('data-profile-outcome')) === 'same', await gateAgain.innerText())
|
||||
const memberAgain = profileBox(page).locator(`[data-profile-finding="relation"][data-path="relations.${MEMBER_REL}"] [data-profile-outcome]`)
|
||||
check('……原本就是推断、这次仍不够的写「保持推断」', (await memberAgain.innerText()) === '保持推断:覆盖率不足,可能不是这条关系'
|
||||
&& (await memberAgain.getAttribute('data-profile-outcome')) === 'kept')
|
||||
// 点「填写含义」:报告收起、弹出那一列的码值;保存或取消之后回到报告,这一列改写成「含义已填写」,焦点落在下一列上
|
||||
const fillLine = (col) => profileBox(page).locator(`[data-profile-finding="codes"][data-column="${col}"]`)
|
||||
await fillLine('status').locator('[data-profile-fill]').click()
|
||||
|
||||
Reference in New Issue
Block a user