kpi-definition-consistency-checker

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

When to invoke

调用时机

  • You maintain a metrics catalog and want consistency across teams.
  • You suspect KPI definitions drifted (different denominators, time windows, or grains).
  • 您维护着指标目录,希望跨团队保持一致性。
  • 您怀疑KPI定义出现偏差(如不同的分母、时间窗口或粒度)。

Inputs needed

所需输入

  • KPI dictionary JSON:
    kpis[]
    where each KPI has:
    • name
      ,
      description
      ,
      numerator
      ,
      denominator
      ,
      grain
      ,
      window
      ,
      owner
      ,
      source_tables[]
  • KPI字典JSON:
    kpis[]
    ,其中每个KPI包含:
    • name
      description
      numerator
      denominator
      grain
      window
      owner
      source_tables[]

Workflow

工作流程

  1. Normalize names and detect near-duplicates.
  2. Validate required fields and flag missing owners/windows/grain.
  3. Detect potential conflicts:
    • Same KPI name but different numerator/denominator
    • Different grain (user vs account vs event)
    • Window mismatch (7d vs 30d)
  4. Emit a report with issues and a suggested canonicalization list.
  1. 标准化名称并检测近似重复项。
  2. 验证必填字段并标记缺失的负责人/时间窗口/粒度。
  3. 检测潜在冲突:
    • 相同KPI名称但分子/分母不同
    • 粒度不同(用户 vs 账户 vs 事件)
    • 窗口不匹配(7天 vs 30天)
  4. 生成包含问题及建议标准化列表的报告。

Output format

输出格式

  • JSON report:
    • summary
    • issues[]
      (severity, kpi, problem, details)
    • duplicate_groups[]
  • JSON报告:
    • summary
    • issues[]
      (包含严重性、kpi、问题、详情)
    • duplicate_groups[]

Guardrails

约束规则

  • Heuristic checks only; do not claim semantic equivalence.
  • Do not query databases; rely solely on provided dictionary.
  • 仅进行启发式检查;不得声称语义等价。
  • 不得查询数据库;仅依赖提供的字典。

Reference code

参考代码

  • kpi_definition_consistency_checker.py
    reads KPI JSON and outputs a consistency report.
  • kpi_definition_consistency_checker.py
    读取KPI JSON并输出一致性报告。