diff --git a/changelog.d/added-18718-canonical-model-spend-runstats.md b/changelog.d/added-18718-canonical-model-spend-runstats.md
new file mode 100644
index 0000000000..1edab6f024
--- /dev/null
+++ b/changelog.d/added-18718-canonical-model-spend-runstats.md
@@ -0,0 +1 @@
+- Spend by model and contributor run stats by model now carry `canonical_model`, the same folded model id the Governor's PRs-by-model card uses, so `claude-opus-5-5`, `anthropic/claude-opus-5-5` and `claude-opus-5.5` can be lined up across all three views. `/api/cost` `estimated.by_model[]` and every `/api/contribute/run-stats` and `/api/contribute/run-stats/models` row gain the field; spend stays one row per raw model, since prices are per raw model. Both run-stats endpoints accept an optional `group=canonical` that merges spellings into one row (runs summed, rates recomputed from the summed counts) with `raw_models[]` keeping each spelling's run count; without it the rows are unchanged. The Cost card's by-model list and the contributor wall's model evidence show the canonical id, with the reported spelling in a tooltip (#18718).
diff --git a/dashboard/openapi.json b/dashboard/openapi.json
index 20b0fd2483..b9a9112c93 100644
--- a/dashboard/openapi.json
+++ b/dashboard/openapi.json
@@ -22826,6 +22826,18 @@
"default": 7
},
"description": "Trailing window in days; 0 aggregates everything in the live log."
+ },
+ {
+ "name": "group",
+ "in": "query",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "enum": [
+ "canonical"
+ ]
+ },
+ "description": "canonical merges model rows by canonical_model (modelfamily.Canonical): runs summed, rates recomputed from summed counts, model set to the canonical id, raw_models[] listing each raw spelling with its runs. Omitted: one row per raw model, each with canonical_model (#18718)."
}
],
"responses": {
@@ -38083,7 +38095,21 @@
"Contribute"
],
"summary": "Contributor run stats by model",
- "description": "Returns per-model run counts, verified-PR share, and failure rate for contributor-wall evidence, plus why runs ended (#18721): `abandoned` (count), `scenarios` (scenario -> count, the same keys as /api/contribute/run-stats backends[].scenarios, summing to runs) and `failure_kinds` ({environment, task, unspecified}, summing to the failed runs behind failure_rate).",
+ "description": "Returns per-model run counts, verified-PR share, failure rate and canonical_model for contributor-wall evidence, plus why runs ended (#18721): `abandoned` (count), `scenarios` (scenario -> count, the same keys as /api/contribute/run-stats backends[].scenarios, summing to runs) and `failure_kinds` ({environment, task, unspecified}, summing to the failed runs behind failure_rate). group=canonical merges rows by canonical model id.",
+ "parameters": [
+ {
+ "name": "group",
+ "in": "query",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "enum": [
+ "canonical"
+ ]
+ },
+ "description": "canonical merges model rows by canonical_model (modelfamily.Canonical): runs, abandoned, scenarios and failure_kinds summed, rates recomputed from summed counts, model set to the canonical id, raw_models[] listing each raw spelling with its runs. Omitted: one row per raw model, each with canonical_model (#18718)."
+ }
+ ],
"responses": {
"200": {
"description": "OK"
diff --git a/dashboard/test/canonical-model-ui.test.js b/dashboard/test/canonical-model-ui.test.js
new file mode 100644
index 0000000000..fbe82c4dc9
--- /dev/null
+++ b/dashboard/test/canonical-model-ui.test.js
@@ -0,0 +1,70 @@
+'use strict';
+
+// #18718: the Cost card's by-model list and the contributor wall's model
+// evidence name the canonical model id (modelfamily.Canonical, the id the
+// Governor's PRs-by-model card groups by), with the raw spelling in a tooltip.
+
+const { test } = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const vm = require('node:vm');
+
+const dashboardDir = path.join(__dirname, '..', '..', 'src', 'pkg', 'dashboard');
+const indexHtml = fs.readFileSync(path.join(dashboardDir, 'static', 'index.html'), 'utf8');
+const costJs = fs.readFileSync(path.join(dashboardDir, 'static-src', 'js', 'cost.js'), 'utf8');
+const landingGo = fs.readFileSync(path.join(dashboardDir, 'contribute_landing.go'), 'utf8');
+
+function extractCostHelpers(src) {
+ const start = src.indexOf('const costModelCanonical = m =>');
+ const end = src.indexOf('const costModelTitle = m =>', start);
+ assert.ok(start >= 0 && end > start, 'cost.js canonical helpers not found');
+ const lineEnd = src.indexOf('\n', end);
+ return src.slice(start, lineEnd);
+}
+
+function costHelpers() {
+ const ctx = {
+ esc: s => String(s).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'),
+ };
+ vm.createContext(ctx);
+ vm.runInContext(`${extractCostHelpers(costJs)}\nthis.label = costModelLabel; this.title = costModelTitle;`, ctx);
+ return ctx;
+}
+
+test('Cost card by-model row shows the canonical id with the raw name in the tooltip', () => {
+ const h = costHelpers();
+ const row = { name: 'anthropic/claude-opus-5-5', canonical_model: 'claude-opus-5.5' };
+ assert.equal(h.label(row), 'claude-opus-5.5');
+ assert.equal(h.title(row), ' title="Reported as anthropic/claude-opus-5-5"');
+});
+
+test('Cost card keeps the raw name when there is no distinct canonical id', () => {
+ const h = costHelpers();
+ assert.equal(h.label({ name: 'claude-opus-5.5', canonical_model: 'claude-opus-5.5' }), 'claude-opus-5.5');
+ assert.equal(h.title({ name: 'claude-opus-5.5', canonical_model: 'claude-opus-5.5' }), '');
+ assert.equal(h.label({ name: 'old-model' }), 'old-model');
+ assert.equal(h.title({ name: 'old-model' }), '');
+ assert.equal(h.label({ name: 'auto', canonical_model: 'unknown' }), 'auto');
+ assert.equal(h.label({}), 'unknown');
+});
+
+test('Cost card wiring is in both static-src and the generated index.html', () => {
+ for (const expected of [
+ 'const costModelCanonical = m =>',
+ '
${esc(costModelLabel(m))}
',
+ ]) {
+ assert.ok(costJs.includes(expected), `cost.js missing ${expected}`);
+ assert.ok(indexHtml.includes(expected), `index.html missing ${expected}`);
+ }
+});
+
+test('Contributor wall model evidence names the canonical model with the raw spelling in a tooltip', () => {
+ for (const expected of [
+ 'p.model_evidence.canonical_model',
+ 'class="wall-canonical-model" title="Reported as \'+esc(evRaw)+\'">\'+esc(evCanon)+\'',
+ "evidence='
model evidence'+evName+': '",
+ ]) {
+ assert.ok(landingGo.includes(expected), `contribute_landing.go missing ${expected}`);
+ }
+});
diff --git a/src/docs/api-reference/contribute.md b/src/docs/api-reference/contribute.md
index 2de912ceeb..044a063f77 100644
--- a/src/docs/api-reference/contribute.md
+++ b/src/docs/api-reference/contribute.md
@@ -21,7 +21,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f
| `GET` | `/api/contribute/limits` | Public | Contribute Limits | `pkg/dashboard/api_contribute.go:275` |
| `GET` | `/api/contribute/metrics` | Public | Contribute Metrics | `pkg/dashboard/api_contribute.go:281` |
| `GET` | `/api/contribute/me` | Public path; caller identity resolved server-side (401 anonymous; a signed-in caller with no profile on this hive gets 200 with `has_profile:false` and no counters, [#12111](https://github.com/hivecommons/hive/issues/12111)) | The caller's OWN contribution stats — issues worked (24h and all-time), completions that produced a verified PR (24h and all-time, [#7894](https://github.com/hivecommons/hive/issues/7894)), and failures. No username parameter, so it only ever answers for its caller ([#6543](https://github.com/hivecommons/hive/issues/6543)) | `pkg/dashboard/api_contribute.go:291` |
-| `GET` | `/api/contribute/run-stats/models` | Public | Per-model run evidence for the contributor wall: runs, verified-PR share, and failure rate over the selected window, plus why runs ended ([#18721](https://github.com/hivecommons/hive/issues/18721)): `abandoned`, `scenarios` (same keys as `/api/contribute/run-stats` `backends[].scenarios`, summing to `runs`) and `failure_kinds` (`environment`/`task`/`unspecified`, summing to the failed runs). `/api/contribute/run-stats` returns the same rows as `models`. | `pkg/dashboard/api_contribute.go` |
+| `GET` | `/api/contribute/run-stats/models` | Public | Per-model run evidence for the contributor wall: runs, verified-PR share, and failure rate over the selected window, plus why runs ended ([#18721](https://github.com/hivecommons/hive/issues/18721)): `abandoned`, `scenarios` (same keys as `/api/contribute/run-stats` `backends[].scenarios`, summing to `runs`) and `failure_kinds` (`environment`/`task`/`unspecified`, summing to the failed runs). `/api/contribute/run-stats` returns the same rows as `models`. Each row also carries `canonical_model`, the id the Governor's PRs-by-model card groups by (`modelfamily.Canonical`). `group=canonical` merges rows by that id: `runs`, `abandoned`, `scenarios` and `failure_kinds` summed, rates recomputed from the summed counts, `model` set to the canonical id, and `raw_models[]` listing each raw spelling with its own `runs` ([#18718](https://github.com/hivecommons/hive/issues/18718)). Without `group` the rows are unchanged apart from the added `canonical_model`. | `pkg/dashboard/api_contribute.go` |
| `GET` | `/api/contribute/wall` | Public | Contributor wall posts when the hive-wide wall switch is enabled; anonymous readers see visible posts, authors can still see their own hidden posts. | `pkg/dashboard/api_contribute.go` |
| `POST` | `/api/contribute/wall` | Signed-in contributor | Create a 500-character plain-text wall post or one-level reply, with optional `model`, `backend`, and `repo` tags. Returns 401 anonymous, 403 when disabled/revoked/muted, and 429 when rate-limited. | `pkg/dashboard/api_contribute.go` |
| `DELETE` | `/api/contribute/wall/{id}` | Post author | Author deletes their own wall post; action is audit logged. | `pkg/dashboard/api_contribute.go` |
@@ -43,7 +43,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f
| `POST` | `/api/contributors/{id}/requeue` | Dashboard auth/session | Contributor Requeue | `pkg/dashboard/api_contribute.go:347` |
| `DELETE` | `/api/contributors/{id}` | Owner only | Contributor Delete | `pkg/dashboard/api_contribute.go:348` |
| `GET` | `/contribute/dossier/{username}` | Public | Contributor Dossier Page (HTML) | `pkg/dashboard/api_contribute.go:240` |
-| `GET` | `/api/contribute/run-stats` | Public | Contribute Run Stats | `pkg/dashboard/api_contribute.go:299` |
+| `GET` | `/api/contribute/run-stats` | Public | Contribute Run Stats; its `models` array takes the same optional `group=canonical` as `/api/contribute/run-stats/models` and carries `canonical_model` on every row ([#18718](https://github.com/hivecommons/hive/issues/18718)) | `pkg/dashboard/api_contribute.go:299` |
| `GET` | `/api/contribute/runs` | Public | Contribute Per-Run History | `pkg/dashboard/api_contribute.go:389` |
| `GET` | `/api/contribute/decisions` | Owner/read-write | Contribute Hub Decisions | `pkg/dashboard/api_contribute.go:399` |
| `GET` | `/api/contribute/dossier` | Public | Contribute Dossier Get | `pkg/dashboard/api_contribute.go:336` |
diff --git a/src/docs/api-reference/cost-tokens-telemetry.md b/src/docs/api-reference/cost-tokens-telemetry.md
index ee842ada0b..b538efcb7a 100644
--- a/src/docs/api-reference/cost-tokens-telemetry.md
+++ b/src/docs/api-reference/cost-tokens-telemetry.md
@@ -8,7 +8,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f
| `GET` | `/api/trends` | Dashboard auth/session | Trends | `pkg/dashboard/api.go:87` |
| `GET` | `/api/token-access` | Dashboard auth/session | Token Access | `pkg/dashboard/api.go:142` |
| `GET` | `/api/tokens` | Dashboard auth/session | Tokens | `pkg/dashboard/api.go:143` |
-| `GET` | `/api/cost` | Dashboard auth/session | Cost; `merged_prs` / `closed_issues` come from the webhook-incremented ForgeState counters reconciled hourly against search, with `count_stale`, `count_stale_since` and `count_source` (`forgestate` / `search`) when last-good counts are being served (#13376), `count_partial` when only some configured repos have an attributed baseline yet, and `count_error` naming why the latest attributed refresh failed or was partial (the reconcile asks GitHub about a budgeted slice of repos per pass so a many-repo hive stays inside search's rate limit); `daily_rollup` lists per-UTC-day estimated spend (`day`, `cost_usd`, `input_tokens`, `output_tokens`, `samples`) kept for ~2 years so the Cost chart can reach past the 30-day snapshot ring; `recording` reports `agent_models`, `unrecorded_models`, `recent_models`, `last_priced_growth_at`, `last_agent_model_growth_at`, `stale_after_ms` and `stale` so the card can flag stale live usage recording (#13485) | `pkg/dashboard/api.go:144` |
+| `GET` | `/api/cost` | Dashboard auth/session | Cost; `merged_prs` / `closed_issues` come from the webhook-incremented ForgeState counters reconciled hourly against search, with `count_stale`, `count_stale_since` and `count_source` (`forgestate` / `search`) when last-good counts are being served (#13376), `count_partial` when only some configured repos have an attributed baseline yet, and `count_error` naming why the latest attributed refresh failed or was partial (the reconcile asks GitHub about a budgeted slice of repos per pass so a many-repo hive stays inside search's rate limit); `daily_rollup` lists per-UTC-day estimated spend (`day`, `cost_usd`, `input_tokens`, `output_tokens`, `samples`) kept for ~2 years so the Cost chart can reach past the 30-day snapshot ring; `recording` reports `agent_models`, `unrecorded_models`, `recent_models`, `last_priced_growth_at`, `last_agent_model_growth_at`, `stale_after_ms` and `stale` so the card can flag stale live usage recording (#13485); every `estimated.by_model[]` row carries `canonical_model` (`modelfamily.Canonical` of its `name`, the id PRs-by-model and run stats group by), while spend stays one row per raw model because prices are per raw model (#18718) | `pkg/dashboard/api.go:144` |
| `GET` | `/api/repo-activity` | Dashboard auth/session | Per-repo audited activity | `pkg/dashboard/api.go` |
| `GET` | `/api/repo-cost` | Dashboard auth/session | Per-repo estimated token cost (interval join, cached) | `pkg/dashboard/api.go` |
| `GET` | `/api/launch-cost` | Dashboard auth/session | Per-issue / PR / head-SHA estimated token cost from kick launch attribution (cached; `?ref=owner/repo#N` narrows) | `pkg/dashboard/api.go` |
diff --git a/src/docs/backend-smoke.md b/src/docs/backend-smoke.md
index 29c421de55..ad4e902cf2 100644
--- a/src/docs/backend-smoke.md
+++ b/src/docs/backend-smoke.md
@@ -147,6 +147,12 @@ the failed runs). That is the split that tells "this model's contributors have
broken environments" from "this model gets the work wrong". The contributor
wall shows it as the tooltip on a post's "failed" model-evidence figure.
+Each `models` row also carries `canonical_model`, the id the Governor's
+PRs-by-model card uses. Add `group=canonical` to fold spellings such as
+`claude-opus-5-5` and `anthropic/claude-opus-5-5` into one row (counts and the
+#18721 splits summed, rates recomputed); `raw_models[]` keeps each spelling's
+run count (#18718).
+
This is DECLARE-only telemetry, per the boundary
`src/pkg/dashboard/contribute_protocol.go` documents: nothing routes,
cooldowns, or gates on any of it, and a telemetry write failure never fails a
diff --git a/src/pkg/dashboard/contribute_landing.go b/src/pkg/dashboard/contribute_landing.go
index e1dfa99933..907c2c3338 100644
--- a/src/pkg/dashboard/contribute_landing.go
+++ b/src/pkg/dashboard/contribute_landing.go
@@ -6078,8 +6078,12 @@ function ccWallPostHTML(p){
var tags=p.tags||{};
var evidence='';
if(p.model_evidence){
+ // Name the canonical model id (the one the Governor's PRs-by-model card
+ // groups by, #18718) when it differs from the tag, raw spelling in the tooltip.
+ var evCanon=String(p.model_evidence.canonical_model||''),evRaw=String(p.model_evidence.model||tags.model||'');
+ var evName=(evCanon&&evCanon!=='unknown'&&evCanon.toLowerCase()!==evRaw.toLowerCase())?' for '+esc(evCanon)+'':'';
var failTip=ccModelEvidenceFailTip(p.model_evidence);
- evidence='
return counts;
})();
+ // A by_model row shows the canonical model id (the one the Governor's
+ // PRs-by-model card and run stats group by, #18718) with the raw name the
+ // token collector recorded in its tooltip. Rows are still one per raw
+ // name: spend is priced per raw model and is not regrouped.
+ const costModelCanonical = m => {
+ const c = String(m.canonical_model || '');
+ return c && c !== 'unknown' && c !== m.name ? c : '';
+ };
+ const costModelLabel = m => costModelCanonical(m) || m.name || 'unknown';
+ const costModelTitle = m => costModelCanonical(m) ? ` title="Reported as ${esc(m.name)}"` : '';
+
// Per-model estimated cost table. Every model shows a $ estimate now —
// exact list price where known, a coarse tier estimate (~) otherwise.
const models = sortCostRows((est.by_model || []).map(m => {
@@ -41057,7 +41068,7 @@