diff --git a/backend/app/api/evidence.py b/backend/app/api/evidence.py index 2b6a4a2e..552e7a18 100644 --- a/backend/app/api/evidence.py +++ b/backend/app/api/evidence.py @@ -789,8 +789,7 @@ async def evidence_segment(run_id: str, segment_id: str, report: str | None = No chain = await _chain(seg, doc, sealed, chosen.node_id) covered = sealed.trusted and all(step.get("sealed") for step in chain if "sealed" in step) # 遮罩列:查询步骤里遮着的,加上指标步骤里取自遮罩列的输入(按位置取的那一格可能没有对应的查询步骤) - masked = list(dict.fromkeys(c for step in chain if step.get("step") in ("query", "input") - for c in step.get("masked") or [])) + masked = _chain_masked(chain) verdict = _effective_verdicts(chosen, sealed)[0].get(str(unit.get("id"))) challenged = _challenge_of(sealed, chosen, str(unit.get("id"))) # 口径账本(next-round 02 做法 3):这个数来自哪一份口径。比对在封存之后做、不在封存范围内,标签里写明;没比对过的运行 @@ -823,6 +822,14 @@ async def evidence_segment(run_id: str, segment_id: str, report: str | None = No METRIC_NOT_FOUND = "evidence_metric_not_found" +def _chain_masked(chain: list[dict[str, Any]]) -> list[str]: + """出处链里遮着的列:查询步骤里遮着的,指标步骤里取自遮罩列的输入(按位置取的那一格可能没有对应的查询步骤),转抄的 + 上游指标那几步的输入(跨卡往下追的,见 _upstream_steps)。""" + steps = [*chain, *(i for step in chain if step.get("step") == "upstream" for i in step.get("inputs") or [])] + return list(dict.fromkeys(c for step in steps if step.get("step") in ("query", "input") + for c in step.get("masked") or [])) + + @router.get("/{run_id}/evidence/metrics/{node}/{metric}") async def evidence_metric(run_id: str, node: str, metric: str) -> dict[str, Any]: """点开应用页上的一个指标(应用平台 §3.6):指标 → 输入 → 查询快照的出处链,和报告片段的指标链同一套(_metric_chain)。 @@ -847,8 +854,7 @@ async def evidence_metric(run_id: str, node: str, metric: str) -> dict[str, Any] chain = await _metric_chain({"text": shown}, {"kind": "metric", "locator": {"metric": metric}, "eid": eid}, entry, {"catalog": {}}, sealed, masks) covered = sealed.trusted and all(step.get("sealed") for step in chain if "sealed" in step) - masked = list(dict.fromkeys(c for step in chain if step.get("step") in ("query", "input") - for c in step.get("masked") or [])) + masked = _chain_masked(chain) return {"run_id": run_id, "node": node, "metric": metric, "rendered": shown, "eid": eid, "chain": chain, "seal": {"sealed": sealed.sealed, "ok": sealed.seal["ok"], "covered": covered}, "redacted": {"columns": masked, "note": MASK_NOTE} if masked else {"columns": []}} @@ -992,6 +998,8 @@ async def _metric_chain(seg: dict[str, Any], cite: dict[str, Any], entry: dict[s if (found := held.get(str(item.get("path")))) is not None: one = _withheld(one, found) inputs.append(one) + # 转抄另一张口径卡的指标(对账卡、召回卡的「口径」那一项):跨卡往下追,接上那个指标自己的一段出处,一直到查询格子 + upstream = await _upstream_steps(metric or {}, sealed, masks, catalog, wanted, {(artifact, str(metric_id))}) if withheld := {path: _held_word(found) for path, found in held.items() if found.kind != "table"}: # 代入式里那几处同样写「已遮罩」(遮没遮核对不了的写「无法核对」):不然标签里遮着、代入式里亮着,同一个值换个 # 地方照样看得到。整份结果当输入的不换:代入式里本来就只留着它的路径 @@ -1002,7 +1010,77 @@ async def _metric_chain(seg: dict[str, Any], cite: dict[str, Any], entry: dict[s # 目录、正文里本来就是「已遮罩」。文档记着不给、这里却认不出的(数据源事后撤了遮罩),照文档不给 step["value"] = word or MASKED queries = [s for a, cells in wanted.items() for s in await _query_steps(a, cells, doc, sealed, masks)] - return [step, *inputs, *queries] + return [step, *inputs, *upstream, *queries] + + +async def _upstream_steps(metric: dict[str, Any], sealed: _Sealed, masks: "_Masks", catalog: dict[str, Any], + wanted: dict[str, list[tuple[Any, Any]]], seen: set[tuple[str, str]], + depth: int = 1) -> list[dict[str, Any]]: + """指标的输入里转抄另一张口径卡的指标的(nodes.<卡>.metrics[i].value,卡上记着 upstream),每个接一步 upstream:那张 + 卡的那个指标(名字、值、式子、代入式、核对状态,取值按同一套遮罩),它自己的输入(同指标步骤的输入;落在查询快照上的 + 并进 wanted,后面照常给查询步骤),追没追到原始数据。转抄的转抄一层层接着追(防环:同一个指标只接一次;最多 + MAX_COPY_DEPTH 层)。of 是这一步接在哪个输入后面(输入的路径)。""" + from app.engine.lineage import MAX_COPY_DEPTH, SNAPSHOT_VIAS + + out: list[dict[str, Any]] = [] + if depth > MAX_COPY_DEPTH: + return out + for item in metric.get("inputs") or []: + up = item.get("upstream") if isinstance(item, dict) and item.get("via") == "metric" else None + if not isinstance(up, dict) or not up.get("artifact"): + continue + artifact, metric_id = str(up["artifact"]), str(up.get("metric") or "") + if (artifact, metric_id) in seen: + continue + seen.add((artifact, metric_id)) + node = str(item.get("node_id") or "") + card, hash_ok = _load_card(artifact) + found = _metric_in(card, metric_id) + step: dict[str, Any] = { + "step": "upstream", "of": item.get("path"), "node_id": node or None, + "label": _node_label(sealed, node) if node else None, "artifact": artifact, "metric": metric_id, + "traced": up.get("traced") is True, "depth": depth, "hash_ok": hash_ok and found is not None, + "sealed": sealed.trusted and (node, artifact) in sealed.ledger, + } + if found is None: + out.append(step) + continue + held, word = await _metric_masks(found, node, artifact, sealed, masks, card=card) + try: + rendered = word or render_metric(found) + except RenderError: + rendered = MISSING + step.update({ + "name": found.get("name") or metric_id, "value": word if word is not None else found.get("value"), + "unit": found.get("unit") or "", "rendered": rendered, "caliber": (card or {}).get("caliber"), + "version": (card or {}).get("caliber_version"), "source": await _caliber_source((card or {}).get("source")), + "expression": found.get("expression"), "substituted": found.get("substituted"), + "recompute_ok": found.get("recompute_ok"), "status": found.get("status"), + **({"incomplete": True, "incomplete_reason": found.get("incomplete_reason") or ""} + if found.get("incomplete") else {}), + **({"sql_check_failed": True, "sql_check_reason": found.get("sql_check_reason") or ""} + if found.get("sql_check_failed") else {}), + "untraced": _untraced_steps(found, sealed), + }) + if withheld := {path: _held_word(h) for path, h in held.items() if h.kind != "table"}: + step["substituted"] = recompute.substituted_without(found, withheld) + inputs: list[dict[str, Any]] = [] + for sub in found.get("inputs") or []: + if not isinstance(sub, dict): + continue + one = {"step": "input", **sub} + if sub.get("artifact") and sub.get("via") in SNAPSHOT_VIAS: + one["query"] = _query_alias(catalog, sub["artifact"]) + if cell := _input_cell(sub, catalog): + one["cell"] = cell + wanted.setdefault(str(sub["artifact"]), []).extend(_located(sub.get("locator") or {})) + if (h := held.get(str(sub.get("path")))) is not None: + one = _withheld(one, h) + inputs.append(one) + step["inputs"] = inputs + out.append(step) + out += await _upstream_steps(found, sealed, masks, catalog, wanted, seen, depth + 1) + return out def _node_label(sealed: _Sealed, node_id: Any) -> str: diff --git a/backend/app/engine/lineage.py b/backend/app/engine/lineage.py index fd9bd004..21302fd5 100644 --- a/backend/app/engine/lineage.py +++ b/backend/app/engine/lineage.py @@ -6,7 +6,9 @@ - 运行时(nodes/metrics._input_of):「只是把调用工具节点的结果原样按 JSON 解析」的数据整形节点(parsed_tool)不改动任何 一格,vars..rows[i][j](row_cell)确定地对到那份查询快照的第 i 行第 j 列,和 cell() 一样按快照核对,记下穿过的整形 - 节点(through); + 节点(through);转抄另一张口径卡的指标(nodes.<卡>.metrics[i].value,metric_copy:对账卡、召回卡的「口径」那一项就是 + 这么写的)跨卡往下追——接上那个指标自己的出处,那个指标的输入都追到了原始数据,这一项才算追到(upstream.traced); + 转抄的转抄一层层接着追,最多 MAX_COPY_DEPTH 层(循环里抄自己上一轮的卡每一轮多一层,到了上限就算没追到); - 证据面板(api/evidence 的指标步骤):卡上记的输入里追不到原始数据的(untraced),照实说出处追到哪个节点为止; - 应用检查(apps/lint):受管级应用里绑定的指标,按 static_stops 静态地认(只有图、没有运行),追不到的给提示。 """ @@ -81,12 +83,38 @@ def row_cell(path: str) -> RowCell | None: return RowCell(rows.value.value.id, rows.value.attr, row.value, column.value) +#: 转抄另一张口径卡的指标时跨卡往下追的层数上限 +MAX_COPY_DEPTH = 8 + + +def metric_copy(path: str) -> tuple[str, str, int] | None: + """路径正好是 nodes.<卡>.metrics[i].value、vars.<卡的 assign_to>.metrics[i].value 这种转抄一个指标的值的样子时拆开: + (root, 名字, 第几个指标)。下标是非负整数字面量;别的样子(整张卡、清单文字、指标的名称单位、下标是变量)为 None。""" + try: + tree = ast.parse(path, mode="eval").body + except SyntaxError: + return None + if not (isinstance(tree, ast.Attribute) and tree.attr == "value" and isinstance(tree.value, ast.Subscript)): + return None + index, metrics = tree.value.slice, tree.value.value + if not (isinstance(metrics, ast.Attribute) and metrics.attr == "metrics" and isinstance(metrics.value, ast.Attribute) + and isinstance(metrics.value.value, ast.Name) and metrics.value.value.id in ("vars", "nodes")): + return None + if not (isinstance(index, ast.Constant) and type(index.value) is int and index.value >= 0): + return None + return metrics.value.value.id, metrics.value.attr, index.value + + def traced(item: Mapping[str, Any]) -> bool: """卡上记的一个输入追没追到原始数据:落在查询快照的一格上、核对得了快照(cell() 取的格、穿过 JSON 解析按位置取的格、 - Agent 按出处交来的字段),或者是运行输入。""" + Agent 按出处交来的字段),或者是运行输入;转抄另一张口径卡的指标的,那个指标的输入都追到了(运行时跨卡追好记在 + upstream 里:traced 为真、那张卡的指标集落了工件)。""" via = item.get("via") if via in SNAPSHOT_VIAS: return bool(item.get("artifact")) and item.get("status") in _CHECKED + if via == "metric": + up = item.get("upstream") + return isinstance(up, Mapping) and up.get("traced") is True and bool(up.get("artifact")) return via == "input" diff --git a/backend/app/engine/nodes/metrics.py b/backend/app/engine/nodes/metrics.py index c289fdc9..f19799ea 100644 --- a/backend/app/engine/nodes/metrics.py +++ b/backend/app/engine/nodes/metrics.py @@ -132,12 +132,18 @@ async def run_metrics(state: GraphState, ctx: NodeContext) -> dict[str, Any]: decimals = display["decimals"] value = round_metric(value, decimals) substituted = substitute(tree, values) - incomplete: dict[str, Any] = {} - if use.sources: - sources = list(use.sources.values()) - incomplete = {"incomplete": True, "incomplete_reason": _incomplete_reason(sources), - "truncated_sources": sources} inputs = [_input_of(path, values[path], state, ctx, tctx) for path in paths] + # 转抄另一张口径卡的指标:那个指标不完整、所依据的查询没通过 SQL 检查的,这一个照样不完整、存疑(出处是跨卡追下去 + # 的,判档也按追到底的结果,见 engine/lineage.metric_copy) + carried = [m for item in inputs if (m := _copied_metric(item, tctx)) is not None] + truncated = list(use.sources.values()) + for source in (s for m in carried if m.get("incomplete") for s in m.get("truncated_sources") or []): + if isinstance(source, dict) and source not in truncated: + truncated.append(source) + incomplete: dict[str, Any] = {} + if truncated: + incomplete = {"incomplete": True, "incomplete_reason": _incomplete_reason(truncated), + "truncated_sources": truncated} for path, item in zip(paths, inputs): # 容器型的 vars.* 输入(列表、字典)另存一份完整值:卡里只记了「[12 项]」这样的大概,事后推演 # (engine/recompute.py)要拿完整的值重算。nodes.*、input.* 的完整值在那个节点封存的产出工件里, @@ -146,7 +152,9 @@ async def run_metrics(state: GraphState, ctx: NodeContext) -> dict[str, Any]: if _container_var(path, values[path]) and (stored := await _store_value(path, values[path], ctx)): item["value_artifact"] = stored sql_check: dict[str, Any] = {} - if failed := _failed_queries(inputs, list(use.sources.values()), paths, tctx, checked): + copied_checks = [str(c.get("artifact")) for m in carried for c in m.get("sql_check_sources") or [] + if isinstance(c, dict) and c.get("artifact")] + if failed := _failed_queries(inputs, truncated, paths, tctx, checked, extra=copied_checks): sql_check = {"sql_check_failed": True, "sql_check_reason": _sql_check_reason(failed), "sql_check_sources": [{"artifact": artifact, "codes": list(dict.fromkeys( code for p in found for code in p.codes))} for artifact, found in failed]} @@ -456,18 +464,20 @@ _LAST_STEP = re.compile(r"(?:\.[^.\[\]]+|\[[^\[\]]*\])$") def _failed_queries(inputs: list[dict[str, Any]], truncated: list[dict[str, Any]], paths: list[str], - tctx: dict[str, Any], checked: dict[str, list[QueryProblem]], - ) -> list[tuple[str, list[QueryProblem]]]: + tctx: dict[str, Any], checked: dict[str, list[QueryProblem]], *, + extra: list[str] | tuple[str, ...] = ()) -> list[tuple[str, list[QueryProblem]]]: """这个指标用到的查询里,SQL 检查有 error 的:[(查询快照工件 id, 没通过检查的查询)]。合并查询的快照对应它出问题的 那几个输入(sql_problems.query_problems)。 - 用到了哪些查询,三处来历合起来认:输入的出处(cell() 取的格、Agent 经 cite_fields 交来的字段都带着快照 id)、 + 用到了哪些查询,四处来历合起来认:输入的出处(cell() 取的格、Agent 经 cite_fields 交来的字段都带着快照 id)、 截断跟踪记下的整组、取值链上的查询结果本身(数据整形解析过的 vars.res.rows[0][0],往上找到 vars.res 那份 - 带 artifact 的结果)。检查结果从快照里读,不信内存里那份:快照按哈希寻址,就是查询当时存下的那份。 + 带 artifact 的结果),以及 extra:转抄的指标所依据、没通过检查的那几条(跨卡追下去的)。检查结果从快照里读,不信内存里那份:快照按哈希寻址,就是查询当时存下的那份。 读不出来的快照不算(另有别的检查报快照的问题)。Agent 没开 cite_fields 时说不清数出自哪次查询,不算。 """ artifacts = [item.get("artifact") for item in inputs] + [s.get("artifact") for s in truncated] artifacts += [_result_artifact(path, tctx) for path in paths if cell_parts(path) is None] + # 转抄的指标所依据、没通过检查的查询(extra,跨卡追下去的那几条) + artifacts += list(extra) out = [] for artifact in dict.fromkeys(a for a in artifacts if isinstance(a, str) and a): if artifact not in checked: @@ -646,6 +656,8 @@ def _input_of(path: str, value: Any, state: GraphState, ctx: NodeContext, # 沙箱算出来的数喂给口径卡:记下它自认是「取数」还是「计算」,治理规则按它判 entry["role"] = str(producer.config.get("evidence_role") or "compute") entry["status"] = "ok" if value is not None else "missing" + if producer is not None and str(producer.type) == "metrics" and (up := _upstream(path, tctx or template_context(state))): + entry["upstream"] = up if producer is not None and str(producer.type) == "agent" and field: cited = _agent_field(state, producer.id, root if head else "", field) if cited is not None: @@ -653,6 +665,48 @@ def _input_of(path: str, value: Any, state: GraphState, ctx: NodeContext, return entry +def _copied_card(path: str, tctx: dict[str, Any]) -> tuple[dict[str, Any], dict[str, Any]] | None: + """转抄另一张口径卡一个指标的输入(engine/lineage.metric_copy 认的写法):(那张卡这一次的产出, 那个指标)。不是这种 + 写法、产出不是指标集、下标越界的为 None。""" + from app.engine.lineage import metric_copy + + found = metric_copy(path) + if found is None: + return None + root, name, index = found + card = _value_of(f"{root}.{name}", tctx) + metrics = card.get("metrics") if isinstance(card, dict) and card.get("kind") == "metric_set" else None + if not isinstance(metrics, list) or index >= len(metrics) or not isinstance(metrics[index], dict): + return None + return card, metrics[index] + + +def _upstream(path: str, tctx: dict[str, Any]) -> dict[str, Any] | None: + """转抄另一张口径卡的指标时,跨卡往下追的出处:{node_id?, metric, artifact, depth, traced}。那张卡的指标集落了工件、 + 那个指标的输入都追到了原始数据(engine/lineage.untraced 为空;它自己转抄的再往下一层层追过了,记在它的输入上)、 + 层数没超过 MAX_COPY_DEPTH,才算追到。不是转抄指标的为 None(照旧停在那张卡)。""" + from app.engine.lineage import MAX_COPY_DEPTH, untraced + + found = _copied_card(path, tctx) + if found is None: + return None + card, metric = found + inputs = [i for i in metric.get("inputs") or [] if isinstance(i, dict)] + depth = 1 + max([int((i.get("upstream") or {}).get("depth") or 0) for i in inputs + if isinstance(i.get("upstream"), dict)] or [0]) + artifact = card.get("artifact") if isinstance(card.get("artifact"), str) else None + return {"metric": metric.get("id"), "artifact": artifact, "depth": depth, + "traced": bool(artifact) and depth <= MAX_COPY_DEPTH and not untraced(inputs)} + + +def _copied_metric(item: dict[str, Any], tctx: dict[str, Any]) -> dict[str, Any] | None: + """卡上的一个输入转抄了另一张口径卡的哪个指标(这一次的产出里那一项);不是转抄的为 None。""" + if item.get("via") != "metric" or not isinstance(item.get("upstream"), dict): + return None + found = _copied_card(str(item.get("path") or ""), tctx) + return found[1] if found is not None else None + + def _field_key(field: str) -> str: """vars.kpi['gmv'] 和 vars.kpi.gmv 是同一个字段:下标写法换成点号。""" return re.sub(r"\[\s*['\"]([^'\"\]]+)['\"]\s*\]", r".\1", field).strip(".") diff --git a/backend/tests/test_metric_copy_lineage.py b/backend/tests/test_metric_copy_lineage.py new file mode 100644 index 00000000..33b683a4 --- /dev/null +++ b/backend/tests/test_metric_copy_lineage.py @@ -0,0 +1,196 @@ +"""转抄另一张口径卡的指标时,出处链跨卡往下追(engine/lineage.metric_copy、engine/nodes/metrics._upstream、 +api/evidence._upstream_steps)。 + +对账卡的「口径」、召回卡的「旧版 / 新版」都写成 nodes.<口径卡>.metrics[i].value。以前出处停在「来自口径卡指标」,对账运行、 +召回运行一律降档出具(「输入没追到原始数据」);口径卡自己的指标明明追得到取数查询。现在: +- 运行时接上那个指标自己的出处(upstream):那个指标的输入都追到了原始数据,这一项才算追到,判档按追到底的结果; + 那个指标不完整、所依据的查询没通过 SQL 检查的,转抄出来的同样不完整、存疑;转抄的转抄一层层往下追,到了层数上限 + 就算没追到; +- 证据接口:转抄的输入后面接一步 upstream(那张卡的那个指标、它的输入),一直到口径的取数查询(查询步骤照常给); +- 真跑对账、召回:完整出具,三个数都点得到口径的取数查询。 +数据是虚构店铺库。 +""" +from __future__ import annotations + +import pytest +from httpx import ASGITransport, AsyncClient + +from app.engine.lineage import MAX_COPY_DEPTH, traced, untraced +from app.engine.runner import run_manager +from app.ledger import match as ledger_match +from app.ledger import recall +from tests import ledger_samples as S + +WINDOW = "status = 'paid' AND paid_at >= '2026-09-01' AND paid_at < '2026-09-08'" + + +@pytest.fixture(autouse=True) +async def engine_up(tmp_path): + await run_manager.setup() + await S.fresh_source(tmp_path / "shop.db") + yield + await ledger_match.drain() + await recall.drain() + await run_manager.shutdown() + + +@pytest.fixture +async def client(): + from app.main import app + + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as c: + yield c + + +def metric(mid: str, expression: str, name: str = "") -> dict: + return {"id": mid, "name": name or mid, "unit": "元", "decimals": 2, "expression": expression} + + +async def run_chain(*middle: dict, contract_from: str) -> object: + graph = S.chain(S.node("start", "input"), *middle, + S.node("out", "output", fields=[{"name": "数", "value": f"{{{{ nodes.{contract_from}.metrics[0].value }}}}"}], + contract={"metrics_from": contract_from})) + run = await run_manager.start(graph=graph, input_payload={}) + row = await S.wait(run.id) + assert row.status == "succeeded", row.error + return row + + +async def card(run_id: str, node_id: str) -> dict: + from app.api.evidence import _sealed, _sealed_cards + + sealed = await _sealed(run_id) + [(_, found)] = [(a, c) for n, a, c in _sealed_cards(sealed) if n == node_id] + return {m["id"]: m for m in found["metrics"]} + + +# -------------------------------------------------------------------------- +# 运行时 +# -------------------------------------------------------------------------- + + +async def test_a_copied_metric_traces_through_the_card_and_issues_formally(): + fetch = S.node("fetch", "tool", tool=S.tool(), args={"sql": f"SELECT SUM(amount) AS gmv FROM orders WHERE {WINDOW}"}) + a = S.node("a", "metrics", caliber="口径", caliber_version="v1", metrics=[metric("gmv", "cell(nodes.fetch, 0, 'gmv')")]) + b = S.node("b", "metrics", caliber="转抄", caliber_version="v1", metrics=[ + metric("cal", "nodes.a.metrics[0].value"), metric("half", "(nodes.a.metrics[0].value) / 2")]) + c = S.node("c", "metrics", caliber="再转抄", caliber_version="v1", metrics=[metric("again", "nodes.b.metrics[0].value")]) + row = await run_chain(fetch, a, b, c, contract_from="c") + first, second = await card(row.id, "b"), await card(row.id, "c") + [item] = first["cal"]["inputs"] + assert item["via"] == "metric" and item["node_id"] == "a" + assert item["upstream"]["traced"] is True and item["upstream"]["depth"] == 1 and item["upstream"]["metric"] == "gmv" + assert traced(item) and untraced(first["half"]["inputs"]) == [] + [deep] = second["again"]["inputs"] + assert deep["upstream"]["traced"] is True and deep["upstream"]["depth"] == 2 + issuance = row.output["_issuance"] + assert issuance["tier"] == "formal", issuance["gaps"] + + +async def test_copying_a_metric_that_is_not_traced_still_stops_there(): + calc = S.node("calc", "transform", mode="json", template='{"v": 5}', assign_to="calc") + a = S.node("a", "metrics", caliber="口径", caliber_version="v1", metrics=[metric("five", "vars.calc.v")]) + b = S.node("b", "metrics", caliber="转抄", caliber_version="v1", metrics=[metric("cal", "nodes.a.metrics[0].value")]) + row = await run_chain(calc, a, b, contract_from="b") + [item] = (await card(row.id, "b"))["cal"]["inputs"] + assert item["upstream"]["traced"] is False and not traced(item) + issuance = row.output["_issuance"] + assert issuance["tier"] == "degraded" + assert any("指标「cal」的输入没追到原始数据" in g for g in issuance["gaps"]), issuance["gaps"] + + +async def test_an_incomplete_upstream_metric_makes_the_copy_incomplete_too(): + fetch = S.node("fetch", "tool", tool=S.tool(), args={"sql": "SELECT id, amount FROM orders ORDER BY id", "limit": 2}) + parse = S.node("parse", "transform", mode="json", template="{{ nodes.fetch }}", assign_to="rows") + a = S.node("a", "metrics", caliber="口径", caliber_version="v1", metrics=[metric("n", "len(vars.rows.rows)")]) + b = S.node("b", "metrics", caliber="转抄", caliber_version="v1", metrics=[metric("cal", "nodes.a.metrics[0].value")]) + row = await run_chain(fetch, parse, a, b, contract_from="b") + upstream, copied = (await card(row.id, "a"))["n"], (await card(row.id, "b"))["cal"] + assert upstream["incomplete"] is True + assert copied["incomplete"] is True and copied["truncated_sources"] == upstream["truncated_sources"] + assert copied["incomplete_reason"] == upstream["incomplete_reason"] + issuance = row.output["_issuance"] + assert issuance["tier"] == "degraded" + assert any(g.startswith("指标「cal」基于被截断的查询结果计算") for g in issuance["gaps"]), issuance["gaps"] + + +def test_copies_of_copies_stop_at_the_depth_limit(): + from app.engine.nodes.metrics import _upstream + + def card_with(depth: int) -> dict: + inputs = [{"path": "nodes.x.metrics[0].value", "value": 1, "via": "metric", "node_id": "x", + "upstream": {"metric": "m", "artifact": "a" * 64, "depth": depth, "traced": True}}] + return {"kind": "metric_set", "artifact": "b" * 64, "metrics": [{"id": "m", "value": 1, "inputs": inputs}]} + + ok = _upstream("nodes.y.metrics[0].value", {"nodes": {"y": card_with(MAX_COPY_DEPTH - 1)}}) + assert ok is not None and ok["traced"] is True and ok["depth"] == MAX_COPY_DEPTH + too_deep = _upstream("nodes.y.metrics[0].value", {"nodes": {"y": card_with(MAX_COPY_DEPTH)}}) + assert too_deep is not None and too_deep["traced"] is False and too_deep["depth"] == MAX_COPY_DEPTH + 1 + # 整张卡、清单文字、指标的名称这类不是转抄一个指标的值:不往下追 + assert _upstream("nodes.y.metrics", {"nodes": {"y": card_with(0)}}) is None + assert _upstream("nodes.y.metrics[0].name", {"nodes": {"y": card_with(0)}}) is None + + +# -------------------------------------------------------------------------- +# 真跑对账、召回:完整出具,证据面板一路点到口径的取数查询 +# -------------------------------------------------------------------------- + + +def _steps(chain: list[dict], kind: str) -> list[dict]: + return [s for s in chain if s["step"] == kind] + + +async def test_a_reconcile_run_traces_the_caliber_side_down_to_its_fetch(client, monkeypatch): + wf = await S.publish() + row = await S.explore(monkeypatch, S.WITH_REFUNDS) + body = (await client.get(f"/api/runs/{row.id}/ledger")).json() + [action] = [a for a in body["actions"] if a["kind"] == "reconcile"] + res = await client.post(f"/api/ledger/answers/{row.id}/reconcile", json={ + "query": action["query"], "workflow_id": wf, "version": 1, "confirm": True, + "inputs": {"start": "2026-09-01", "end": "2026-09-08"}}) + assert res.status_code == 201, res.text + done = await S.wait(res.json()["run_id"]) + assert done.status == "succeeded", done.error + issuance = done.output["_issuance"] + assert issuance["tier"] == "formal", issuance + metrics = await card(done.id, "reconcile") + [cal] = metrics["cal_0"]["inputs"] + assert cal["node_id"] == "card" and cal["upstream"]["traced"] is True + + for mid in ("cal_0", "diff_0"): + res = await client.get(f"/api/runs/{done.id}/evidence/metrics/reconcile/{mid}") + assert res.status_code == 200, res.text + chain = res.json()["chain"] + assert chain[0]["untraced"] == [], "转抄的口径那一项跨卡追到了原始数据" + [up] = _steps(chain, "upstream") + assert up["of"] == "nodes.card.metrics[0].value" and up["node_id"] == "card" and up["metric"] == "gmv" + assert up["traced"] is True and up["sealed"] is True and up["hash_ok"] is True and up["value"] == 170.5 + [read] = up["inputs"] + assert read["path"] == "cell(nodes.fetch, 0, 'gmv')" and read["via"] == "tool_cell" + # 口径的取数查询的那一步照常给(点得到) + fetches = [q for q in _steps(chain, "query") if q.get("artifact") == read["artifact"]] + assert len(fetches) == 1 and fetches[0]["node_id"] == "fetch" + # 「这次」那一项不是转抄的,没有 upstream 这一步 + ours = (await client.get(f"/api/runs/{done.id}/evidence/metrics/reconcile/ours_0")).json()["chain"] + assert _steps(ours, "upstream") == [] + + +async def test_a_recall_run_traces_both_versions_down_to_their_fetches(client, monkeypatch): + from tests.test_ledger_recall import WITH_REFUNDED, answer, ledger_settings, publish_v2, run_recall + + await ledger_settings(auto_issue=False, issue_daily_limit=100_000) + wf = await S.publish() + await answer(monkeypatch) + await publish_v2(wf, WITH_REFUNDED) + [done] = await run_recall(wf) + assert done.status == "succeeded", done.error + assert done.output["_issuance"]["tier"] == "formal", done.output["_issuance"] + res = await client.get(f"/api/runs/{done.id}/evidence/metrics/recall/diff_0") + assert res.status_code == 200, res.text + chain = res.json()["chain"] + ups = {u["node_id"]: u for u in _steps(chain, "upstream")} + assert set(ups) == {"old_card", "new_card"} + assert all(u["traced"] for u in ups.values()) + reads = {u["node_id"]: u["inputs"][0]["artifact"] for u in ups.values()} + queried = {q["node_id"] for q in _steps(chain, "query") if q.get("artifact") in reads.values()} + assert queried == {"old_fetch", "new_fetch"} diff --git a/frontend/src/lib/evidence.ts b/frontend/src/lib/evidence.ts index 18f32faf..36cb0e71 100644 --- a/frontend/src/lib/evidence.ts +++ b/frontend/src/lib/evidence.ts @@ -436,13 +436,20 @@ export function inputSource(input: EvidenceInput): { tone: SourceTone; text: str ? { tone: 'warn', text: EVIDENCE_TEXT.codeSource(input.node_id ?? '') } : { tone: 'alert', text: EVIDENCE_TEXT.codeCompute(input.node_id ?? '') } } + if (input.via === 'metric' && input.upstream) { + // 转抄另一张口径卡的指标:出处跨卡追下去了(服务端记在 upstream 上),追没追到照实说 + return input.upstream.traced === true + ? { tone: 'ok', text: EVIDENCE_TEXT.upstreamTraced } + : { tone: 'warn', text: EVIDENCE_TEXT.upstreamStop } + } if (status === 'missing' || input.value == null) return { tone: 'warn', text: EVIDENCE_TEXT.inputMissing } return { tone: 'muted', text: '' } } -/** 值得在「输入来源」里单独列一行的输入:能核对到快照的、代码节点的、缺的 */ +/** 值得在「输入来源」里单独列一行的输入:能核对到快照的、代码节点的、转抄另一张口径卡的指标(跨卡追下去的)、缺的 */ export const notableInput = (input: EvidenceInput): boolean => input.via === 'agent_field' || input.via === 'tool_cell' || input.via === 'code' + || (input.via === 'metric' && !!input.upstream) || input.status === 'missing' || input.value == null /** diff --git a/frontend/src/lib/terms.ts b/frontend/src/lib/terms.ts index cd426a7a..aa1d4356 100644 --- a/frontend/src/lib/terms.ts +++ b/frontend/src/lib/terms.ts @@ -313,6 +313,15 @@ export const EVIDENCE_TEXT = { originChipHint: '这个数由口径卡确定性算出、复算一致,但算式用到的输入没有一路追到查询快照', /** 按位置取的格穿过了原样解析查询结果的整形节点 */ through: (label: string) => `经「${label}」原样解析`, + /** + * 转抄另一张口径卡的指标(对账卡、召回卡的「口径」那一项):出处跨卡往下追,接上那个指标自己的一段,一直到查询格子 + */ + upstream: '转抄的口径卡指标', + upstreamFrom: (card: string, metric: string) => `取自口径卡「${card}」的指标「${metric}」`, + gotoUpstream: (card: string) => `查看口径卡「${card}」的这个指标`, + upstreamTraced: '取自另一张口径卡的指标,那个指标的输入都追到了原始数据', + upstreamStop: '取自另一张口径卡的指标,那个指标的输入没有都追到原始数据', + upstreamUnreadable: '读不到那张口径卡的指标集(文件缺失或与哈希不一致),这一步不能作为证据', input: '运行输入', seal: '封存', sealOk: '已封存 · 核对一致', diff --git a/frontend/src/run/EvidencePanel.tsx b/frontend/src/run/EvidencePanel.tsx index 87df5131..a1a27d27 100644 --- a/frontend/src/run/EvidencePanel.tsx +++ b/frontend/src/run/EvidencePanel.tsx @@ -365,7 +365,25 @@ function SegmentBody({ panelId, doc, artifact, runId, runClass, seg, unit, block head.scrollIntoView({ block: 'nearest' }) flashOnce(part) }, [panelId]) - const linkOf = (inp: EvidenceInput) => { + // 转抄另一张口径卡的指标(对账卡、召回卡的「口径」那一项):服务端跨卡接上的那几步,输入点一下跳到对应的那一步 + const upstreams = chain.filter((s) => s.step === 'upstream') + const upstreamId = (i: number) => `${panelId}-u${i}` + const jumpToUpstream = useCallback((i: number) => { + const part = document.getElementById(`${panelId}-u${i}`) + const head = part?.querySelector('[data-ev-upstream-head]') + if (!part || !head) return + head.focus({ preventScroll: true }) + head.scrollIntoView({ block: 'nearest' }) + flashOnce(part) + }, [panelId]) + /** depth:这个输入在第几层(指标自己的输入是 1,转抄的那一步里的输入是那一步的 depth + 1) */ + const linkOf = (inp: EvidenceInput, depth = 1): InputLink => { + const u = inp.via === 'metric' && inp.upstream + ? upstreams.findIndex((s) => s.of === inp.path && (s.depth ?? 1) === depth) : -1 + if (u >= 0) { + const card = host.nodeLabel?.(upstreams[u].node_id ?? '') || upstreams[u].label || upstreams[u].node_id || '' + return { index: u, alias: card, text: EVIDENCE_TEXT.gotoUpstream(card), go: () => jumpToUpstream(u) } + } const i = queryOf(inp, queries) return i >= 0 ? { index: i, alias: queries[i].alias ?? '', go: () => jumpTo(i) } : undefined } @@ -492,9 +510,14 @@ function SegmentBody({ panelId, doc, artifact, runId, runClass, seg, unit, block )} {isMetric && inputs.some(notableInput) && ( - + linkOf(inp)} /> )} + {isMetric && upstreams.map((u, i) => ( + linkOf(inp, (u.depth ?? 1) + 1)} /> + ))} + {isInput && !isMetric && (

@@ -983,7 +1006,8 @@ function askError(error: unknown): string { return JUDGE_TEXT.failed(humanizeError(error).title) } -type InputLink = { index: number; alias: string; go: () => void } | undefined +/** 输入点一下跳到哪:查询步骤(alias 是查询编号),或者转抄的那一步(text 是按钮上的字,alias 是那张卡的名字) */ +type InputLink = { index: number; alias: string; go: () => void; text?: string } | undefined /** * 面板里提到的节点。画布右栏里是按钮:点一下在画布上选中并对准它(画布上已经没有这个节点 @@ -1557,8 +1581,8 @@ function InputChip({ input, link }: { input: EvidenceInput; link?: InputLink }) {link ? ( @@ -1591,6 +1615,86 @@ const TONE: Record InputLink +}) { + const host = useEvidenceHost() + const card = host.nodeLabel?.(step.node_id ?? '') || step.label || step.node_id || NONE + const inputs = (step.inputs ?? []).filter((i) => i && typeof i === 'object') + const unreadable = step.hash_ok === false || step.name == null + const untraced = Array.isArray(step.untraced) ? step.untraced.filter((u) => u && typeof u === 'object') : null + const stopAt = (u: EvidenceUntraced) => (u.node_id + ? EVIDENCE_TEXT.originStop(u.path, + EVIDENCE_TEXT.originNode(host.nodeLabel?.(u.node_id) || u.label || u.node_id, u.type ? nodeTypeLabel(u.type) : '')) + : EVIDENCE_TEXT.originUnknown(u.path)) + return ( +

+
{EVIDENCE_TEXT.upstream}
+
+ + {EVIDENCE_TEXT.upstreamFrom(card, step.name || step.metric || NONE)} + + {!unreadable && step.rendered && {step.rendered}} + {step.incomplete && ( + {EVIDENCE_TEXT.incomplete} + )} + {step.sql_check_failed && ( + {EVIDENCE_TEXT.sqlCheckFailed} + )} + {host.onNode && } +
+ + {unreadable ? ( +

+ {EVIDENCE_TEXT.upstreamUnreadable} +

+ ) : ( +
+
+
{EVIDENCE_TEXT.expression}
+
+ {step.expression || NONE} +
+
+
+
{EVIDENCE_TEXT.substituted}
+
+ + {step.substituted || NONE} + + {!!inputs.length && ( +
    + {inputs.map((inp, i) => )} +
+ )} +
+
+ {untraced && ( +
+
{EVIDENCE_TEXT.origin}
+
+ {untraced.length ? ( +
    {untraced.map((u, i) =>
  • {stopAt(u)}
  • )}
+ ) : EVIDENCE_TEXT.originTraced} +
+
+ )} +
+ )} +
+ ) +} + /** * 输入来源:每个能核对到快照的输入(agent 字段、cell() 取数)、代码节点的输入、缺的输入各一行—— * 路径、从哪个节点哪一格来、核对结果。能对到查询步骤的给「看查询 Qn」 @@ -1606,7 +1710,8 @@ function SourcesPart({ inputs, linkOf }: { inputs: EvidenceInput[]; linkOf: (inp const link = linkOf(inp) // 查询编号写报告目录里的全局编号(接口补的 query、对上的查询步骤);agent 字段自己的 ref 是 // 那个节点内部的编号,和面板里的「查询 Qn」不是一回事,不拿来写 - const alias = link?.alias || inp.query || (typeof inp.cell === 'string' ? inp.cell.split('.')[0] : '') + const alias = (link && !link.text ? link.alias : '') || inp.query + || (typeof inp.cell === 'string' ? inp.cell.split('.')[0] : '') const where = [ inp.field && (inp.via === 'agent_field' ? `字段 ${inp.field}` : inp.field), throughText(inp, host.nodeLabel), @@ -1621,7 +1726,7 @@ function SourcesPart({ inputs, linkOf }: { inputs: EvidenceInput[]; linkOf: (inp {inp.path ?? NONE} {link && ( )} diff --git a/frontend/src/types.ts b/frontend/src/types.ts index a84652e4..cce85f52 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -2171,6 +2171,19 @@ export interface EvidenceInput { * 不进 masked:面板底下「这些列设置了遮罩」不把它们算进去 */ mask_unverified?: string + /** + * via 为 metric、转抄另一张口径卡的指标(nodes.<卡>.metrics[i].value)时,运行时跨卡往下追的出处:那个指标的 id、那张卡的 + * 指标集工件、转抄了几层、那个指标的输入是不是都追到了原始数据(服务端 engine/lineage.metric_copy)。老运行、别的输入没有 + */ + upstream?: EvidenceUpstreamRef | null +} + +/** 转抄的输入跨卡往下追的出处(EvidenceInput.upstream) */ +export interface EvidenceUpstreamRef { + metric?: string + artifact?: string | null + depth?: number + traced?: boolean } // --------------------------------------------------------------------------- @@ -2319,6 +2332,14 @@ export interface EvidenceUntraced { export interface EvidenceStep extends Omit { step: string + /** + * upstream:转抄另一张口径卡的指标时跨卡接上的那一步(api/evidence._upstream_steps)。of 是接在哪个输入后面(输入的路径), + * label 是那张卡在图里的名字,traced 是那个指标的输入都追到了原始数据,depth 是转抄了几层 + */ + of?: string + label?: string | null + traced?: boolean + depth?: number metric?: string decimals?: number | null format?: string diff --git a/scripts/check-ledger.mjs b/scripts/check-ledger.mjs index 1ac25b3c..e72fa721 100644 --- a/scripts/check-ledger.mjs +++ b/scripts/check-ledger.mjs @@ -8,6 +8,8 @@ // - 口径对账:核对参数(推断的参数要先核对)→ 发起(认不出列怎么配时照 409 带回的选项选对照的指标,再发起)→ 结果卡片: // 这次 / 口径 / 差值 / 相对差四个数各自取值、点开是出处链;请求体逐项核对;做完的卡片上问「差在哪」的说明有没有帮助 // (说明有用 / 看不懂,统计 E2):请求体只有 verdict,选过的按下、写各几个人,能改主意;没做完的不问; +// - 「按口径」那个数转抄口径卡的指标:出处链跨卡接上口径卡那个指标的一步,输入来源里点一下跳到那一步,那一步的输入 +// 点一下跳到口径的取数查询; // - 可沉淀的问题:工作流列表弹窗里的抽屉,三类来源分开写;「固化成口径草稿」走 from-run 的 freeze(带同组的别的运行)、 // 打开画布;聚类按人挑的那一轮固化;「不是口径」要写理由; // - 使用者看到的入口照服务端的动作:不能出具的写原因(请搭建者出具)、不摆出具按钮,能对账的照样对账;出具过的正式运行 @@ -22,7 +24,7 @@ import { readFileSync } from 'node:fs' import { chromium } from '../frontend/node_modules/playwright-core/index.mjs' import { - ISSUE, QUEUE, RECONCILE, RECONCILE_VALUES, WHOLE, WHOLE_LABELS, ledgerOf, metricDetail, reconciledOf, + ISSUE, QUEUE, RECONCILE, RECONCILE_VALUES, WHOLE, WHOLE_LABELS, copiedMetricDetail, ledgerOf, metricDetail, reconciledOf, } from './ledger-fixtures.mjs' const WEB = process.env.AGENTLAB_WEB ?? 'http://localhost:5273' @@ -278,6 +280,52 @@ await section('口径对账:核对参数 → 发起 → 选对照的指标 → check('没有运行时报错', errors.length === 0, errors.join(' | ')) }) +// ---------------------------------------------------------------- 「按口径」那个数的出处跨卡追到取数查询 + +await section('对账结果里「按口径」那个数:出处跨卡追到口径的取数查询', async () => { + const extra = (method, p) => { + const m = p.match(/^\/runs\/run-rec-1\/evidence\/metrics\/reconcile\/([^/]+)$/) + if (method === 'GET' && m) { + return { json: m[1] === 'cal_0' ? copiedMetricDetail('run-rec-1', m[1]) : metricDetail('run-rec-1', m[1]) } + } + return null + } + const { page, errors } = await open('/ui-harness.html?evidence=1', { + reply: evidenceReply(() => ledgerOf(RUN, { reconciled: [reconciledOf('succeeded')] }), extra) }) + await page.waitForSelector('#evidence-wide [data-seg="s8"]', { timeout: 10000 }) + await openSeg(page, 's8') + const card = page.locator('[data-evidence-panel] [data-ledger-reconciled="run-rec-1"]') + await card.waitFor({ timeout: 6000 }) + await until(async () => (await card.innerText()).includes(RECONCILE_VALUES.cal_0), 5000) + await card.locator('[data-ledger-value="cal_0"]').click() + const drawer = page.locator('[data-evidence-panel="side"]').last() + const up = drawer.locator('[data-ev-upstream="card"]') + const shown = await up.waitFor({ timeout: 5000 }).then(() => true, () => false) + const upText = shown ? (await up.innerText()).replace(/\s+/g, ' ') : '' + check('点「按口径」:出处链接上口径卡的那个指标(转抄的口径卡指标)', shown && upText.includes('转抄的口径卡指标') + && upText.includes('取自口径卡「口径卡」的指标「订单数」') && upText.includes('1,180单'), upText) + check('……写那个指标的原式、它的输入追到了原始数据', upText.includes("cell(nodes.fetch, 0, 'orders')") + && await up.locator('[data-ev-upstream-origin="traced"]').count() === 1, upText) + check('指标这一步:输入都追到了原始数据,不挂「未追到原始数据」', await drawer.locator('[data-ev-untraced-chip]').count() === 0 + && await drawer.locator('[data-ev-metric] [data-ev-origin="traced"]').count() === 1) + const src = drawer.locator('[data-ev-source="nodes.card.metrics[0].value"]') + const srcText = await src.innerText().catch(() => '') + check('输入来源:转抄的那一项说清取自另一张口径卡、那个指标的输入都追到了原始数据', + srcText.includes('取自另一张口径卡的指标,那个指标的输入都追到了原始数据') + && srcText.includes('查看口径卡「口径卡」的这个指标'), srcText) + await src.locator('[data-ev-goto]').click() + const focused = await until(() => page.evaluate(() => document.activeElement?.hasAttribute('data-ev-upstream-head') === true), 3000) + check('点「查看口径卡「口径卡」的这个指标」:焦点落到那一步、描一下边', focused + && await up.getAttribute('data-flash') === 'focus') + await up.locator(`[data-ev-input="cell(nodes.fetch, 0, 'orders')"]`).click() + const query = drawer.locator('[data-ev-query="q-cal-fetch"]') + const jumped = await until(async () => await query.getAttribute('data-flash') === 'focus', 3000) + check('那个指标的输入点一下:跳到口径的取数查询(SQL、被引用的那一格都在)', jumped + && (await query.innerText()).includes('SELECT COUNT(*) AS orders FROM orders') + && await query.locator('td[data-highlight="cell"]').count() === 1) + check('没有运行时报错', errors.length === 0, errors.join(' | ')) +}) + // ---------------------------------------------------------------- 可沉淀的问题 const WF = { id: 'wf-led-check', name: '检查用工作流', description: '', version: 1, status: 'draft', tags: [], is_template: false, diff --git a/scripts/ledger-fixtures.mjs b/scripts/ledger-fixtures.mjs index 049e7b35..ef3d7bf9 100644 --- a/scripts/ledger-fixtures.mjs +++ b/scripts/ledger-fixtures.mjs @@ -112,6 +112,31 @@ export const metricDetail = (runId, metric) => ({ seal: { sealed: true, ok: true, covered: true }, redacted: { columns: [] }, }) +/** + * 对账卡上「按口径」那个数的出处(服务端 api/evidence._upstream_steps 的形状):它转抄口径卡的指标 + * (nodes.card.metrics[0].value),出处跨卡接上口径卡「订单数」那一步,再到口径的取数查询(q-cal-fetch) + */ +export const copiedMetricDetail = (runId, metric) => ({ + run_id: runId, node: 'reconcile', metric, rendered: RECONCILE_VALUES[metric] ?? '—', eid: `ev:metric:${metric}`, + chain: [ + { step: 'metric', alias: 'm', metric, name: '订单数 · 口径', value: 1180, rendered: RECONCILE_VALUES[metric], node_id: 'reconcile', + caliber: '口径对账', version: 'v1', expression: 'nodes.card.metrics[0].value', substituted: '1180', recompute_ok: true, + sealed: true, hash_ok: true, untraced: [], + inputs: [{ path: 'nodes.card.metrics[0].value', value: 1180, node_id: 'card', via: 'metric', field: 'metrics[0].value', + status: 'ok', upstream: { metric: 'orders', artifact: 'ms-card', depth: 1, traced: true } }] }, + { step: 'upstream', of: 'nodes.card.metrics[0].value', node_id: 'card', label: '口径卡', artifact: 'ms-card', metric: 'orders', + traced: true, depth: 1, hash_ok: true, sealed: true, name: '订单数', value: 1180, unit: '单', rendered: '1,180单', + caliber: '订单口径', version: 'v1', expression: "cell(nodes.fetch, 0, 'orders')", substituted: '1180', recompute_ok: true, + status: 'ok', untraced: [], + inputs: [{ step: 'input', path: "cell(nodes.fetch, 0, 'orders')", value: 1180, node_id: 'fetch', via: 'tool_cell', + status: 'verified', artifact: 'q-cal-fetch', locator: { row: 0, column: 'orders' }, eid: 'ev:cell:q-cal-fetch' }] }, + { step: 'query', alias: null, artifact: 'q-cal-fetch', node_id: 'fetch', tool: 'db_query__shop', source: 'shop', + sql: "SELECT COUNT(*) AS orders FROM orders WHERE status = 'paid'", columns: ['orders'], rows: [[1180]], row_offset: 0, + row_index: [0], total_rows: 1, highlight: { rows: [0], cols: ['orders'], cells: [[0, 'orders']] }, sealed: true, hash_ok: true }, + ], + seal: { sealed: true, ok: true, covered: true }, redacted: { columns: [] }, +}) + /** 认证队列:三类来源各一项 */ export const QUEUE = { items: [