mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-16 18:31:59 +00:00
合入集成分支(阶段 2A 数据剖析、4B 剖析与 SQL 检查界面及修正)到 4A:两边功能都保留
冲突的解法: - 后端 api/catalog.py:同时导入 catalog_impact 和 catalog_profile、SnapshotTampered;data/catalog.py:__all__ 取两边的并集重排。 - 2A 放宽了码值校验(含义可以为空,剖析写进来的是「含义待填写」):目录修改提案的码值补充改为含义为空的码不覆盖已有含义、 只在原来没有这个码时加进去,补了测试;卡片和过程里的码值把空含义写成「含义待填写」,和目录页同一个说法。 - 前端 types.ts、terms.ts:两边各在同一处追加了新段落,按顺序都留下(提案、影响面、目录版本在前,剖析、码值、SQL 检查在后), 没有重复的键;client.ts、decode.ts、CatalogPage.tsx、TableDetail.tsx 的导入取并集。 - check-catalog.mjs:影响面和剖析、保存数据源三条假路由都留下,各节和最后核对真库数量的逻辑不变。 - 4A 的测试数据源改用 tests/fixtures/sources.py 的 drop_source 删除,顺带作废连接池。
This commit is contained in:
@@ -2147,6 +2147,12 @@ export interface EvidenceStep extends Omit<EvidenceInput, 'status'> {
|
||||
incomplete?: boolean
|
||||
/** metric:不完整的原因(人话,「基于被截断的查询结果计算(只取回了前 1000 行),结果不完整」) */
|
||||
incomplete_reason?: string
|
||||
/** metric:所依据的查询没通过 SQL 检查(有错误级的问题),值照算,出具已按缺口降档 */
|
||||
sql_check_failed?: boolean
|
||||
/** metric:没通过的原因(人话,「所依据的查询未通过 SQL 检查(…),结果不可靠」) */
|
||||
sql_check_reason?: string
|
||||
/** query:这次查询对照数据目录查出的问题。没查出问题时没有这个键 */
|
||||
checks?: SqlCheckItem[]
|
||||
inputs?: EvidenceInput[]
|
||||
/** 口径卡钉在哪个工作流的哪一版(metric;方案第 5 节的写法,接口实际给在 source 上) */
|
||||
caliber_from?: EvidenceCaliberSource | null
|
||||
@@ -2786,3 +2792,138 @@ export interface CatalogImpact {
|
||||
/** 直接引用的在前 */
|
||||
templates: CatalogImpactTemplate[]
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// 数据剖析(后端 app/data/catalog_profile.py):对业务库发少量只读查询,核实推断的关联关系、取码值候选、
|
||||
// 提议业务日期。默认关闭,按数据源在 options.catalog_profile 里开启。
|
||||
// ===========================================================================
|
||||
|
||||
/** 剖析设置里的数值项 */
|
||||
export type CatalogProfileNumberKey = 'max_queries' | 'query_timeout_s' | 'sample_size' | 'max_scan_rows' | 'max_total_s'
|
||||
|
||||
/** 一个数据源的剖析设置(服务端 ProfileSettings.to_dict) */
|
||||
export interface CatalogProfileSettings {
|
||||
enabled: boolean
|
||||
max_queries: number
|
||||
query_timeout_s: number
|
||||
sample_size: number
|
||||
/** 0 表示一律不做整表统计 */
|
||||
max_scan_rows: number
|
||||
max_total_s: number
|
||||
}
|
||||
|
||||
/** 整次剖析中途停下的原因:查询次数用完、总时长用完、连续多条查询失败 */
|
||||
export type CatalogProfileStop = 'budget' | 'deadline' | 'failed'
|
||||
|
||||
/** 一张表的行数:stats 数据库的统计信息(估算);count 数到上限为止;unknown 没能得到 */
|
||||
export interface CatalogProfileSize {
|
||||
rows: number | null
|
||||
method: 'stats' | 'count' | 'unknown' | (string & {})
|
||||
/** 数到上限也没数完:至少这么多行 */
|
||||
at_least: number | null
|
||||
}
|
||||
|
||||
/** 关系的核对结论:覆盖率、基数,升为已验证(verified)或保持推断(proposed);人工确认过的只补覆盖率和基数 */
|
||||
export interface CatalogProfileRelationFinding {
|
||||
kind: 'relation'
|
||||
path: string
|
||||
target: string
|
||||
columns: string[]
|
||||
to_table: string
|
||||
to_columns: string[]
|
||||
status: CatalogStatus
|
||||
confirmed: boolean
|
||||
coverage: number
|
||||
cardinality: CatalogCardinality | null
|
||||
/** 抽了几个不同的键值、在被指向表里对上几个 */
|
||||
sample: number
|
||||
matched: number
|
||||
summary: string
|
||||
}
|
||||
|
||||
/** 码值候选:观察到的取值和行数,含义留给人填 */
|
||||
export interface CatalogProfileCodesFinding {
|
||||
kind: 'codes'
|
||||
path: string
|
||||
column: string
|
||||
values: { value: string; rows: number }[]
|
||||
rows: number
|
||||
status: CatalogStatus
|
||||
summary: string
|
||||
}
|
||||
|
||||
/** 业务日期提议:表里只有一个日期类列 */
|
||||
export interface CatalogProfileDateFinding {
|
||||
kind: 'business_date'
|
||||
path: string
|
||||
column: string
|
||||
min: string
|
||||
max: string
|
||||
status: CatalogStatus
|
||||
summary: string
|
||||
}
|
||||
|
||||
export type CatalogProfileFinding = CatalogProfileRelationFinding | CatalogProfileCodesFinding | CatalogProfileDateFinding
|
||||
|
||||
/** 没做的一项。detail 是可以直接显示的整句 */
|
||||
export interface CatalogProfileSkip {
|
||||
/** relation / codes / date / row_estimate / table */
|
||||
kind: string
|
||||
target: string
|
||||
path: string | null
|
||||
/** budget / deadline / failed / timeout / error / rejected / masked / too_large / view / unsupported / no_data / missing / high_cardinality */
|
||||
reason: string
|
||||
detail: string
|
||||
}
|
||||
|
||||
export interface CatalogProfileTable {
|
||||
table_name: string
|
||||
queries: number
|
||||
row_estimate: CatalogProfileSize | null
|
||||
findings: CatalogProfileFinding[]
|
||||
skipped: CatalogProfileSkip[]
|
||||
/** 日期类列的取值范围 */
|
||||
date_ranges: { column: string; min: string; max: string }[]
|
||||
added: number
|
||||
updated: number
|
||||
removed: number
|
||||
version: number
|
||||
/** 这张表没剖析(表结构里没有)或结果没写进去(写入一直冲突) */
|
||||
error: string | null
|
||||
}
|
||||
|
||||
/** POST /datasources/{id}/catalog/profile */
|
||||
export interface CatalogProfileOut {
|
||||
profiled_at: string
|
||||
actor: string | null
|
||||
settings: CatalogProfileSettings
|
||||
queries_used: number
|
||||
stopped: CatalogProfileStop | null
|
||||
tables: CatalogProfileTable[]
|
||||
total: { added: number; updated: number; removed: number }
|
||||
/** 一张表都没有剖析时的说明 */
|
||||
note: string | null
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// 基于数据目录的 SQL 检查(后端 app/data/sqlcheck.py):七条规则,编号稳定
|
||||
// ===========================================================================
|
||||
|
||||
export type SqlCheckCode = 'fanout_sum' | 'stock_summed' | 'join_unconfirmed' | 'ratio_aggregated' | 'missing_valid_filter'
|
||||
| 'unknown_code' | 'wrong_date_column'
|
||||
|
||||
/** error:依据有确证、结果必然有误;warning:依据有确证、很可能有误;info:依据只是推断 */
|
||||
export type SqlCheckLevel = 'error' | 'warning' | 'info'
|
||||
|
||||
/** 一条检查结果(证据接口查询步骤里的 checks、助手自查和发布前检查的问题)。交回模型改写用的那句不上界面,这里不收 */
|
||||
export interface SqlCheckItem {
|
||||
code: SqlCheckCode | (string & {})
|
||||
level: SqlCheckLevel | (string & {})
|
||||
/** 给人看的说明 */
|
||||
message: string
|
||||
/** schema_cache 里的表名 */
|
||||
table: string
|
||||
column?: string
|
||||
relation_id?: string
|
||||
sql_excerpt?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user