Skip to content

(MOT-4338) fix(dashboard): make efficiency cards read one coherent population - #689

Merged
ytallo merged 3 commits into
mainfrom
fix/efficiency-cohort-cards
Aug 4, 2026
Merged

(MOT-4338) fix(dashboard): make efficiency cards read one coherent population#689
ytallo merged 3 commits into
mainfrom
fix/efficiency-cohort-cards

Conversation

@ytallo

@ytallo ytallo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The efficiency overview cards on the harness E2E dashboard were unreadable because each card mixed three different populations:

  • the headline value summed every reported scenario in the latest run,
  • the delta chip compared only the comparable cohort against its baseline,
  • the sparkline plotted raw sums across history — so a missing report produced a −79% visual cliff next to an honest −3% chip on the same card.

Two commits:

  1. Cherry-pick 83966dc6 (orphaned from (MOT-4305) feat(harness): discriminative judge-backed scenarios and scored hard-gate failures #672 — the PR was merged before this commit was pushed, so the cohort sparkline filter never reached main): cohortMetricSparkline() sums only the comparable-cohort contracts and skips executions missing any of them, with unit tests.
  2. Card coherence: value, delta, and trend now all read the comparable cohort — the headline equals the sparkline's last point exactly (verified against live data on all four metrics). The sparkline gains a dashed baseline-median reference line and native per-point hover values (Run <id>: <value>), the delta chip names its baseline ("↓ 22% vs baseline median"), the section copy states the population once, and "Suite cost" is renamed "Cost" since the figure is no longer the full suite. While no cohort exists yet, cards fall back to full-suite totals with the existing "Collecting comparable baseline" chip.

Test plan

  • node --test .github/benchmark-site/*.test.cjs — 24/24
  • Simulated against live published data: card value == last sparkline point on all four metrics; baseline within sparkline scale
  • After merge + next daily publish: confirm cards read coherently on the live page

Fixes MOT-4338

Summary by CodeRabbit

  • New Features

    • Added cohort-based efficiency comparisons using unchanged scenarios with passing runs.
    • Added baseline markers and run-specific hover details to efficiency sparklines.
    • Improved efficiency cards with comparable current and baseline values.
  • Improvements

    • Clarified efficiency metric definitions and simplified cost labeling.
    • Updated accessibility labeling for the efficiency card grid.

ytallo added 2 commits August 3, 2026 21:49
The sparklines summed raw per-scenario averages across every reported
scenario, so a missing report or a newly added scenario moved the line for
structural reasons while the delta chip on the same card honestly compared
only the comparable cohort. Sum the same cohort the chip uses and skip
executions that lack any cohort contract instead of fabricating a dip.
The stat tiles mixed three quantities: the headline summed every reported
scenario, the delta chip compared only the comparable cohort, and the
sparkline plotted raw sums, so the three elements of one card could
contradict each other. Value, delta, and trend now all read the comparable
cohort; the sparkline gains a dashed baseline-median reference and
per-point hover values, the delta names its baseline, and the section copy
states the population once.
@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview Aug 4, 2026 1:10am
workers-tech-spec Ready Ready Preview Aug 4, 2026 1:10am

Request Review

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 52 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ytallo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fd431bf3-885c-4716-a3bf-de29fd3caba8

📥 Commits

Reviewing files that changed from the base of the PR and between 019c253 and c21aa60.

📒 Files selected for processing (5)
  • .github/benchmark-site/execution-data.js
  • .github/benchmark-site/execution-data.test.cjs
  • .github/benchmark-site/index.html
  • .github/benchmark-site/overview.js
  • .github/benchmark-site/styles.css
📝 Walkthrough

Walkthrough

The benchmark site now calculates efficiency values and trends from unchanged scenarios with passing latest runs. It adds cohort-filtered metric sparklines, baseline guides, execution tooltips, and updated accessibility and metric labels.

Changes

Comparable efficiency reporting

Layer / File(s) Summary
Cohort metric aggregation
.github/benchmark-site/execution-data.js, .github/benchmark-site/execution-data.test.cjs
Adds and tests cohortMetricSparkline, which filters matching complete executions, skips missing metrics, limits results, and returns chronological points.
Efficiency cards and sparklines
.github/benchmark-site/overview.js, .github/benchmark-site/index.html, .github/benchmark-site/styles.css
Uses comparable cohort values and baseline medians when available. Sparklines show baseline guides and execution-specific tooltips. Labels and accessibility text describe comparable cohort metrics.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EfficiencyCards
  participant cohortMetricSparkline
  participant Executions
  participant Sparkline
  EfficiencyCards->>cohortMetricSparkline: Request comparable metric points
  cohortMetricSparkline->>Executions: Match complete cohort executions
  Executions-->>cohortMetricSparkline: Return metric values
  cohortMetricSparkline-->>EfficiencyCards: Return chronological points
  EfficiencyCards->>Sparkline: Render points and baseline
  Sparkline-->>EfficiencyCards: Show execution tooltips
Loading

Possibly related PRs

  • iii-hq/workers#644: Defines the scenario-metric and contract data model used by the cohort filtering.

Poem

A rabbit checks the cohort chart,
With matching runs from start to start.
Baselines guide the dotted line,
Tooltips show each point in time.
Passed trends now hop in view—
Clean metrics, crisp and true.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the dashboard change that makes efficiency cards represent one coherent comparable population.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/efficiency-cohort-cards

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/benchmark-site/execution-data.test.cjs (1)

418-448: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a multi-row cohort fixture.

This test uses one cohort row. It cannot detect a failure to sum multiple cohort contracts. It also cannot detect an execution that has one cohort contract but misses another required contract.

Add two cohort rows. Verify the combined total. Add one execution that lacks the second contract and verify that the helper excludes it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/benchmark-site/execution-data.test.cjs around lines 418 - 448,
Update the cohortMetricSparkline test to define two cohort rows with distinct
contract fingerprints, include matching metrics for both, and assert their
combined value per execution. Add an execution containing only one required
cohort contract and verify it is excluded, while retaining coverage for partial
metrics and unrelated contracts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/benchmark-site/execution-data.js:
- Around line 900-923: Update cohortMetricSparkline to sort executions by
completed_at, falling back to started_at, in descending chronological order
before the limit-controlled loop; preserve the existing complete-metric
filtering and reverse the selected points only after selection for rendering.
Add coverage for executions whose array order differs from timestamp order.

In @.github/benchmark-site/overview.js:
- Around line 466-478: Update the card rendering flow around
renderEfficiencySparkline so cards using metric.operational when cohortRows is
empty receive a visible and accessible full-suite fallback label, while
comparable-cohort cards retain their existing wording. In
.github/benchmark-site/index.html lines 67-70, revise the section description to
cover both populations; in lines 80-80, replace or dynamically update the static
accessible label so it remains accurate during fallback.

---

Nitpick comments:
In @.github/benchmark-site/execution-data.test.cjs:
- Around line 418-448: Update the cohortMetricSparkline test to define two
cohort rows with distinct contract fingerprints, include matching metrics for
both, and assert their combined value per execution. Add an execution containing
only one required cohort contract and verify it is excluded, while retaining
coverage for partial metrics and unrelated contracts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 21f774e5-e929-4eb4-b842-f883356c6175

📥 Commits

Reviewing files that changed from the base of the PR and between 4c0401a and 019c253.

📒 Files selected for processing (5)
  • .github/benchmark-site/execution-data.js
  • .github/benchmark-site/execution-data.test.cjs
  • .github/benchmark-site/index.html
  • .github/benchmark-site/overview.js
  • .github/benchmark-site/styles.css

Comment on lines +900 to +923
for (const execution of executions || []) {
if (points.length >= limit) break;
const metrics = execution?.scenario_metrics || [];
if (!metrics.length) continue;
let total = 0;
let complete = true;
for (const item of basket) {
const scenario = metrics.find(
(candidate) =>
`${candidate?.subject_id || ""}::${candidate?.scenario_id || ""}` ===
item.key &&
(candidate?.contract_fingerprint || "") === item.fingerprint,
);
const value = numberOrNull(scenario?.averages?.[metricId]);
if (value === null) {
complete = false;
break;
}
total += value;
}
if (!complete) continue;
points.push({ executionId: execution.id, value: total });
}
return points.reverse();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Sort executions before applying limit.

cohortMetricSparkline uses caller order, stops at limit, and then reverses the points. This only returns the latest chronological points when executions is already newest-first. Ascending or unsorted input can render a reversed trend and omit newer executions.

Sort by completed_at or started_at in descending order before the loop. Then reverse the selected complete points for rendering. Add a test where array order differs from timestamp order.

Proposed fix
 function cohortMetricSparkline(executions, cohortRows, metricId, limit = 14) {
+  const orderedExecutions = [...(executions || [])].sort((left, right) => {
+    const leftDate = Date.parse(left?.completed_at || left?.started_at || "") || 0;
+    const rightDate =
+      Date.parse(right?.completed_at || right?.started_at || "") || 0;
+    return rightDate - leftDate;
+  });
   const basket = (cohortRows || [])
     .filter((row) => row && row.scenarioId)
     .map((row) => ({
       key: `${row.subjectId || ""}::${row.scenarioId}`,
       fingerprint: row.fingerprint || "",
     }));
   if (!basket.length) return [];
   const points = [];
-  for (const execution of executions || []) {
+  for (const execution of orderedExecutions) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/benchmark-site/execution-data.js around lines 900 - 923, Update
cohortMetricSparkline to sort executions by completed_at, falling back to
started_at, in descending chronological order before the limit-controlled loop;
preserve the existing complete-metric filtering and reverse the selected points
only after selection for rendering. Add coverage for executions whose array
order differs from timestamp order.

Comment on lines +466 to +478
card.value.textContent = card.format(
cohortRows.length ? metric?.comparableCurrent : metric?.operational,
);
const meta = deltaMeta(metric?.delta);
card.delta.textContent = meta.label;
card.delta.className = `efficiency-delta delta-${meta.css}`;
renderEfficiencySparkline(card.sparkline, card.metricId, card.color);
renderEfficiencySparkline(
card.sparkline,
card.metricId,
card.color,
cohortRows,
cohortRows.length ? metric?.comparableBaseline : null,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Disclose the full-suite fallback.

When cohortRows.length is zero, metric.operational is a full-suite total. The section text and accessible label still state that every card is a comparable-cohort total. This gives users the wrong population during baseline collection.

  • .github/benchmark-site/overview.js#L466-L478: Set a visible and accessible fallback label when the card uses metric.operational.
  • .github/benchmark-site/index.html#L67-L70: Change the description so it accurately describes both comparable-cohort and full-suite fallback states.
  • .github/benchmark-site/index.html#L80-L80: Replace the static accessible label with wording that remains accurate during fallback, or update it dynamically.
📍 Affects 2 files
  • .github/benchmark-site/overview.js#L466-L478 (this comment)
  • .github/benchmark-site/index.html#L67-L70
  • .github/benchmark-site/index.html#L80-L80
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/benchmark-site/overview.js around lines 466 - 478, Update the card
rendering flow around renderEfficiencySparkline so cards using
metric.operational when cohortRows is empty receive a visible and accessible
full-suite fallback label, while comparable-cohort cards retain their existing
wording. In .github/benchmark-site/index.html lines 67-70, revise the section
description to cover both populations; in lines 80-80, replace or dynamically
update the static accessible label so it remains accurate during fallback.

Each efficiency card now prints its baseline median under the delta chip,
the dashed baseline line carries a tooltip explaining the 7-run median, and
each sparkline point's hover shows run id, date, value, and its delta
against the baseline.
@ytallo
ytallo merged commit 722d896 into main Aug 4, 2026
17 checks passed
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