返回 Papers
AI 底层逻辑 / 经典论文

AI Runtime Evidence:可观测证据架构

一句话:

266ai-foundations/papers/101-ai-runtime-evidence-observability-architecture.md

AI Runtime Evidence / Observability Architecture 解读

面向对象: AI Product Architect / Platform PM / EvalOps Lead / SRE / Senior BA / Audit Evidence Owner。 核心问题: AI 系统上线后, 不能只靠聊天记录和用户投诉判断质量。生产级 AI 需要 runtime evidence architecture, 覆盖 prompt、context、retrieval、tool call、policy decision、human approval、output、feedback、cost、latency 和 incident。 学习目标: 用 OpenTelemetry、OpenLineage、W3C PROV、CloudEvents 和 AI RMF 思维, 设计可观测、可审计、可复盘、可持续改进的 AI evidence plane。


Source Anchors

SourceLink用途
OpenTelemetryhttps://opentelemetry.io/docs/参考 trace、span、metrics、logs 的可观测性模型
OpenLineagehttps://openlineage.io/docs/参考 lineage event、job、dataset、run 的数据血缘思维
W3C PROVhttps://www.w3.org/TR/prov-overview/参考 entity、activity、agent 的 provenance 图谱
CloudEventshttps://cloudevents.io/参考事件 envelope、source、type、id、time、subject
NIST AI RMFhttps://www.nist.gov/itl/ai-risk-management-framework把 measure/manage 变成运行时证据和风险反馈
NIST CSFhttps://www.nist.gov/cyberframework参考 identify/protect/detect/respond/recover 的运营控制思维

一句话:

Runtime evidence is the AI product's black box, audit trail and learning loop.


1. 为什么 AI Observability 不等于 Logging

普通 logging 常回答:

request time, status code, error

AI runtime evidence 要回答:

  • 用户问了什么。
  • 系统给了什么指令。
  • 检索到了哪些来源。
  • 哪些 context 被放进 prompt。
  • 模型和参数是什么。
  • 调用了哪些工具。
  • 哪个 policy gate 允许或拒绝。
  • 人类是否审批。
  • 输出是否被用户采纳。
  • 后续是否产生投诉、错误、损失或返工。

如果没有这些证据, 事故复盘会停留在:

AI 好像答错了, 但我们不知道为什么。

2. Evidence Object Taxonomy

Evidence object示例字段
Requestuser_id, role, tenant, channel, purpose
Prompt/configsystem prompt version, policy profile, model, temperature
Contextmemory keys, retrieved chunks, tool observations
Retrievalquery, index version, top_k, source ids, scores
Tool calltool name, args hash, policy decision, result summary
Human approvalapprover, decision, rationale, timestamp
Outputresponse hash, citation ids, schema validation
Feedbackthumbs, edit distance, reviewer score, override
Cost/latencytoken count, model cost, wall time, queue delay
Safety signalrefusal, escalation, red-team hit, policy violation
Incident linkincident id, severity, containment action

不是所有内容都要原文保存。高风险字段可以 hash、mask、tokenize 或按 retention policy 保存。


3. Reference Architecture

AI app / agent
  -> instrumentation SDK
  -> trace/span/events
  -> policy/eval annotations
  -> evidence lake
  -> dashboards + audit queries + incident workbench

核心平面:

Plane作用
Trace plane串起一次 AI run 的步骤
Event plane记录关键业务/风险事件
Provenance plane解释 output 来源和生成链路
Metrics plane监控 SLO/KRI 和趋势
Evidence plane支撑审计、监管、validation 和复盘
Retention plane控制保留、删除、隐私和访问

4. AI Span Model

一次 agent run 可以拆成:

root span: ai.workflow.run
  child span: ai.policy.precheck
  child span: ai.retrieval.query
  child span: ai.model.generate
  child span: ai.tool.call
  child span: ai.human.approval
  child span: ai.policy.postcheck
  child span: ai.output.deliver

Span attributes:

Attribute用途
ai.use_caseuse case 分类
ai.risk_tier风险等级
ai.agent_idagent 身份
ai.model_id模型
ai.prompt_versionprompt 版本
ai.index_versionRAG index 版本
ai.tool_scope工具权限
ai.policy_decisionallow/deny/escalate
ai.human_decisionapprove/reject/edit
ai.output_schema_valid是否通过 schema
ai.citation_support引用支撑
ai.cost_usd成本
ai.latency_ms延迟

5. 金融零售案例

5.1 AML copilot trace

需要证据:

  • 被总结的交易和 alert。
  • 使用的 typology / policy source。
  • 生成 narrative 的 prompt/config。
  • analyst 修改内容。
  • final case disposition。
  • 后续 QA finding。

5.2 Payment dispute agent trace

需要证据:

  • 交易数据来源。
  • dispute reason code。
  • agent 推荐的下一步。
  • 人类是否批准客户通知。
  • 退款/拒绝动作是否由人执行。
  • 客户投诉是否回流到 monitoring。

5.3 Lending policy RAG trace

需要证据:

  • policy repository version。
  • retrieved policy sections。
  • citation support。
  • low-confidence escalation。
  • reviewer override。
  • fair lending / adverse action boundary。

6. Metrics / SLO / KRI

CategoryMetric
Qualitytask success, expert score, correction rate
Groundingcitation support, unsupported claim rate
Safetyrefusal quality, policy violation, harmful completion
Human controlapproval rate, override rate, escalation miss
Reliabilityerror rate, retry, timeout, fallback usage
Costcost per case, token per workflow, cache hit
Latencyp50/p95/p99 end-to-end and per span
Riskincident rate, complaint linkage, drift alert
Adoptionactive users, accepted suggestions, review load
Auditevidence completeness, missing trace rate

高级产品指标要避免只看:

DAU, message count, token usage

这些不能证明 AI 系统安全、有效或可审计。


7. Failure Modes

Failure后果控制
Missing trace出事无法复盘required instrumentation gate
PII in logs隐私和合规风险masking, classification, retention
Broken lineage不知道 output 来源source ids + index version
Unverifiable tool action无法证明谁做了什么tool event contract
Dashboard theater图很多但不支持决策audit query catalog
Non-replayable incident无法重建上下文config/version capture
Over-retention保存过多敏感数据retention matrix

8. Evidence Event Contract

{
  "id": "event_id",
  "source": "ai.customer_service_agent",
  "type": "ai.tool.call.completed",
  "time": "timestamp",
  "subject": "case_id",
  "data": {
    "run_id": "run_id",
    "agent_id": "agent_id",
    "human_actor": "user_id",
    "risk_tier": "high",
    "tool": "crm.case.note.create",
    "policy_decision": "allow",
    "approval_id": "approval_id",
    "evidence_hash": "hash"
  }
}

CloudEvents 思维的好处是: 事件先有稳定 envelope, 再扩展 data schema。


9. 面试表达

30 秒版本:

我会把 AI observability 设计成 runtime evidence architecture, 不只是日志。每次 AI run 都要有 trace, 记录 prompt/config、retrieval、tool call、policy decision、human approval、output、feedback、cost、latency 和 incident link。这样上线后可以做 SLO/KRI 监控、审计查询、事故复盘和持续改进。

2 分钟版本:

对金融零售 AI, 我不会只看聊天记录或模型分数。我要能回答一次输出从哪里来、基于哪些 source、用了哪个 prompt 和模型、调用了什么工具、谁批准了动作、是否触发 policy gate、最后是否产生客户影响。 架构上我会参考 OpenTelemetry 的 trace/span, 用 CloudEvents 做关键事件 envelope, 用 W3C PROV / OpenLineage 思维组织来源和转换链路。证据进入 evidence lake, 但要有隐私分级、masking、retention 和 access control。 运营上 dashboard 要覆盖 quality、grounding、safety、human control、latency、cost、incident 和 evidence completeness。这样 AI 产品才能被治理、被审计、被持续优化。


10. Portfolio Exercise

为 lending policy assistant 设计:

  1. AI span tree。
  2. evidence event contract。
  3. dashboard spec。
  4. audit query catalog。
  5. retention matrix。
  6. incident replay checklist。

最终输出:

  • 一张 runtime evidence architecture 图。
  • 一张 SLO/KRI dashboard 草图。
  • 一个事故复盘查询例子。