口径卡、报告、出具、复核认「查询区间里这张表没有数据」:口径卡按输入的快照 id + 列认(cell()、按位置取的格、Agent 经 cite_fields 交来的字段,按列,同一条查询里有数的列不受影响;转抄的指标照抄),给指标标 no_data 并写明原因,清单注明「这段时间表里没有数据:不要当成 0 解读」,发一条 metric_no_data;有出具契约的成果按缺口降档(契约收来的指标,和报告直接引用的这样的格)。写作目录里这样的指标、查询格子里这样的列都写清,写作规则加一句(目录里有这样的项才加)。证据面板的指标标「区间内无数据」并写明原因,查询步骤列出这几列。复核把 query_no_data、metric_no_data 记成缺口(DEGRADED),归进新的 REBUILD:是缺口、却值得换一张有这段数据的表重建一次,should_retry 和 chat/turn.retry_after_review 都认,问数据据此给出「按复核重来」的指示

This commit is contained in:
ThearchyHelios
2026-10-20 10:29:01 +08:00
parent 8ba95c0252
commit 6fa2e297db
12 changed files with 411 additions and 8 deletions
+16
View File
@@ -994,6 +994,8 @@ async def _metric_chain(seg: dict[str, Any], cite: dict[str, Any], entry: dict[s
if source.get("sql_check_failed") else {}),
# 输入都齐、计算式自己算不出来(分母为 0):面板说「算不出来」,不说「缺少输入」。有值的没有这个键
**({"undefined": True} if source.get("undefined") and source.get("value") is None else {}),
# 输入取自「查询区间里这张表没有数据」的列(data/coverage.py):面板标出来并写明原因。没问题的没有这两个键
**({"no_data": True, "no_data_reason": source.get("no_data_reason") or ""} if source.get("no_data") else {}),
"node_id": entry.get("node_id"), "artifact": artifact or None, "eid": cite.get("eid"),
"eid_ok": cite.get("eid") == entry.get("eid") == make_eid("metric", artifact or None, {"metric": metric_id}),
"hash_ok": hash_ok and metric is not None,
@@ -1094,6 +1096,7 @@ async def _upstream_steps(metric: dict[str, Any], sealed: _Sealed, masks: "_Mask
**({"sql_check_failed": True, "sql_check_reason": found.get("sql_check_reason") or ""}
if found.get("sql_check_failed") else {}),
**({"undefined": True} if found.get("undefined") and found.get("value") is None else {}),
**({"no_data": True, "no_data_reason": found.get("no_data_reason") or ""} if found.get("no_data") else {}),
"untraced": _untraced_steps(found, sealed, node),
})
if withheld := {path: _held_word(h) for path, h in held.items() if h.kind != "table"}:
@@ -2574,6 +2577,8 @@ async def _query_step(artifact: str, cells: list[tuple[Any, Any]], doc: dict[str
column_types=snap.get("column_types") if isinstance(snap.get("column_types"), dict) else {},
**({"provenance": True} if hint and snap.get("data_version") and not merged else {}),
**({"checks": shown.checks(checks)} if (checks := _query_checks(snap)) else {}),
# 查询区间里这张表没有数据的那几列(data/coverage.py,查询时记进快照)。没有就不加这个键
**({"no_data": gaps} if (gaps := _no_data_view(snap)) else {}),
**_catalog_of(snap))
if shown.changed:
notes.append(SQL_MASKED_NOTE)
@@ -2588,6 +2593,17 @@ async def _query_step(artifact: str, cells: list[tuple[Any, Any]], doc: dict[str
return step
#: 查询步骤上 no_data 每一条给面板的字段(data/coverage.result_gaps 的形状)
_NO_DATA_FIELDS = ("columns", "table", "column", "window", "data_range", "basis", "basis_at", "message")
def _no_data_view(snap: dict[str, Any]) -> list[dict[str, Any]]:
"""快照里记的「查询区间里这张表没有数据」(no_data):只给面板要的那几个字段,认不出的条目不给。"""
items = snap.get("no_data") if isinstance(snap.get("no_data"), list) else []
return [{k: item[k] for k in _NO_DATA_FIELDS if k in item} for item in items
if isinstance(item, dict) and isinstance(item.get("message"), str)]
class _Shown:
"""查询步骤上要展示的 SQL、合并 SQL、SQL 检查的片段、合并警告:里面写着的遮罩值(secrets,这次运行查到过的,
masking._Secrets)换成「已遮罩」,换了写法的长号码也认。secrets 为 None 时原样交回。changed:换过东西,查询步骤