Skip to content

docs: metrics.json consumption contract for dashboards (#96) - #104

Merged
tzhouam merged 2 commits into
mainfrom
docs/metrics-contract
Aug 25, 2026
Merged

docs: metrics.json consumption contract for dashboards (#96)#104
tzhouam merged 2 commits into
mainfrom
docs/metrics-contract

Conversation

@tzhouam

@tzhouam tzhouam commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

What

New page doc/guide/metrics.md: the stable consumption contract for the per-run
metrics.json that metrics.py::collect_run_metrics already writes beside every
RUN_REPORT.md — written for external consumers (the review-bot kanban of #96, statistics
scripts).

Documents, field by field for the schema: 1 payload:

  • Quality: q must always be shown with weight_coverage; partial/abstained
    semantics (abstain scores a baseline, not 0).
  • Cost trust rules: cost is complete only when source="spans" and
    cost_partial=false — and "complete" means fully priced at configured/table rates, not
    invoice-exact; source="events" renders as "≈" (estimate), cost_partial=true as "≥"
    (lower bound, with cost_index deliberately null — never fabricated). Harness
    (subscription) backends surface through the same two fields, no backend-specific check
    needed.
  • Nulls mean refused-to-fabricate, never zero — aggregation rules included.
  • Compatibility rule: additive-only within schema 1; breaking changes bump schema.
  • A minimal kanban consumption set (per-run row + aggregation guidance).

Indexed in doc/README.md's guide table.

Why

#96: "our review-bot kanban now does not show the metrics of the review task." The data
already exists per run; what was missing is a contract saying which fields a dashboard may
trust and how to read them. This is the copilot-side half of the split proposed in the
issue triage — the dashboard itself is omni-reviewbot work.

Verification

  • tools/check_doc_links.py (296 files OK), tools/check_doc_citations.py OK.
  • Content cross-checked against metrics.py (collect_run_metrics, cost_from_spans,
    quality_score, _phase_timings) at head.

Refs #96.

🤖 Generated with Claude Code

https://claude.ai/code/session_0165QsXAeLVPrKfj8Yk5zns3

#96 asked the review-bot kanban to show review metrics; the per-run data
already exists (metrics.py writes metrics.json beside RUN_REPORT.md) but
no page said which fields a consumer may trust or how to read them.

doc/guide/metrics.md documents the schema-1 payload field by field with
the trust rules a dashboard needs: q must be shown with weight_coverage,
null means refused-to-fabricate (never zero), usd is trustworthy only
when source="spans" and cost_partial=false, cost_index is deliberately
null on partial cost, and harness-backend runs surface through the same
cost_partial signal. Compatibility rule stated: additive-only within
schema 1, breaking changes bump schema. Indexed in doc/README.md.

Refs #96 (the dashboard itself is omni-reviewbot work).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0165QsXAeLVPrKfj8Yk5zns3

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ac32d11f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread doc/guide/metrics.md
Comment on lines +10 to +11
- 路径:`~/.infermatrix-copilot/runs/run-<ts>-<uuid6>/metrics.json`,与
`RUN_REPORT.md` 同目录。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve metrics from the configured run root

In deployments that set RUN_ROOT/Settings.run_root, runs are written beneath that configured directory rather than ~/.infermatrix-copilot/runs (config.py:183, with environment-backed settings at config.py:84-95). Presenting the default path as the contract can make an external dashboard watch the wrong directory; describe it as <run_root>/run-.../metrics.json and identify the current default separately.

Useful? React with 👍 / 👎.

Comment thread doc/guide/metrics.md
- 路径:`~/.infermatrix-copilot/runs/run-<ts>-<uuid6>/metrics.json`,与
`RUN_REPORT.md` 同目录。
- **尽力而为**:指标计算失败绝不打断 run —— 消费方必须容忍文件缺失。
- BLOCKED 的 run 也会产出 metrics(`status` 字段说明终态)。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Qualify the promise that blocked runs emit metrics

For MCP-reserved runs blocked during planning or tier preflight, _execute_reserved_locked marks the run BLOCKED and returns before _execute (cli/copilot.py:569-578), while metrics are only collected inside _execute at lines 412-418; metrics can also be disabled by metrics_enabled. Such blocked run directories therefore have no metrics.json, so the unconditional statement should be limited to blocked runs that reach metrics collection.

Useful? React with 👍 / 👎.

Comment thread doc/guide/metrics.md
| 字段 | 含义 |
|---|---|
| `risk.incidents` | 按严重级(catastrophic/severe/moderate/minor)的事件计数 |
| `risk.safety_multiplier` | S ∈ (0,1],乘进 CATQ |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include zero in the safety multiplier range

When any catastrophic incident is recorded, safety_multiplier explicitly returns 0.0 (metrics.py:172-175). Consumers validating against the documented S ∈ (0,1] range could reject or mishandle exactly these highest-risk runs, so the contract must state S ∈ [0,1] and note the catastrophic-zero case.

Useful? React with 👍 / 👎.

@tzhouam
tzhouam merged commit f3e7b48 into main Aug 25, 2026
2 checks passed
@tzhouam
tzhouam deleted the docs/metrics-contract branch August 25, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant