---
name: grader-replay
description: >-
  Validates changes to graders, grading fixtures, and CSS/DOM/AST helpers by replaying saved agent solutions from historical eval jobs and triaging before/after diffs. Use when modifying grader.ts, test-fixture.ts, run-grader.ts, or parser helpers used by graders. Don't use for flagging or investigating eval jobs (use nightly-eval-investigation) or validating gd dev prompt generation (dev-prompt-canary).
title: grader-replay
canonical_url: https://skilld.dev/gh/googlechrome/modern-web-guidance-src/grader-replay
last_updated: 2026-11-14T23:01:01.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [scripts/replay.ts](https://skilld.dev/api/skills-raw/googlechrome/modern-web-guidance-src/grader-replay/scripts/replay.ts).
>
> If the user asked to install this Skill, run `npx skilld install googlechrome/modern-web-guidance-src/grader-replay`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/grader-replay`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/googlechrome/modern-web-guidance-src/grader-replay) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/grader-replay`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/grader-replay --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/grader-replay --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Historical Eval Replay for Grader Changes

Golden calibration (`gd dev <guide> --test-grader`) only tests three locked solution patches and `zero-passrate.patch` (which is empty on almost every guide, i.e., the untouched starting app). Historical eval runs contain diverse, imperfect agent implementations that expose broken assumptions, parser edge cases, and false positives.

Because replay applies today's graders against yesterday's saved outputs, before/after mismatches are expected — treat them as signals to triage, not an automatic pass/fail gate.

## 1. Run Calibration First

Run the repo's golden + zero-passrate calibration on each modified guide:

```bash
gd dev <guide> --test-grader
```

Never run `gd dev` without `--test-grader` during validation, or write mode may overwrite manual `grader.ts` edits.

## 2. Pull Jobs (if Missing or Stale) & Replay

[`scripts/replay.ts`](https://skilld.dev/api/skills-raw/googlechrome/modern-web-guidance-src/grader-replay/scripts/replay.ts) checks `results/suites/` and `~/guidance-evals/` and picks the newest `nightly-*` job per configured agent using `suite_config.json`.

If local jobs are missing or drifted behind current base apps, pull recent nightlies while skipping trace archives and screenshots:

```bash
gcloud storage ls gs://guidance-evals/
gcloud storage rsync gs://guidance-evals/<suite_id> ~/guidance-evals/<suite_id> \
  --recursive --exclude ".*\.zip$|.*\.png$"
```

Then run [`scripts/replay.ts`](https://skilld.dev/api/skills-raw/googlechrome/modern-web-guidance-src/grader-replay/scripts/replay.ts):

```bash
# Auto-scope to target graders changed against origin/main
node .agents/skills/grader-replay/scripts/replay.ts

# Scope to specific guides or target keys
node .agents/skills/grader-replay/scripts/replay.ts --guides css-layout,menu

# Replay all tasks (required when modifying test-fixture.ts, run-grader.ts, or parser deps)
node .agents/skills/grader-replay/scripts/replay.ts --all --concurrency 6

# Pin specific jobs, cap runs, or emit JSON
node .agents/skills/grader-replay/scripts/replay.ts \
  --suites nightly-2026-11-02_03-04-27-codex_cli,nightly-2026-10-31_23-00-02-antigravity_cli \
  --limit 12 \
  --json
```

**Why never run `grade.mjs` inside a job folder?** Saved `grade.mjs` files hardcode the original runner's home directory, use an older `runPlaywright` signature, and overwrite the saved `*_results.json` baseline you are comparing against.

**Why stacking matters on Gen 2 targets:** Eval runs apply `zero-passrate.patch` before invoking the agent, so `agent.patch` is diffed on top of `base-apps/<app> + zero-passrate.patch`. `runPlaywright` stacks both patches in a throwaway workspace and throws `PatchApplyError` (reported as `PATCH_CONFLICT`) if either fails to apply, while passing each task's `baselineTarget` (`widely`, `newly`, or `limited`).

## 3. Triage Every `DIFF`, `PATCH_CONFLICT`, or `ERROR`

Inspect the saved `agent.patch` (or `index.html` for Gen 1 tasks), the modified `grader.ts`, and `expectations.md` to classify each mismatch:

- **Real regression (fix required):** Saved `pass -> fail` where the saved output legitimately satisfies `guide.md` and `expectations.md`, or a check stopped matching valid syntax after a refactor.
- **Intentional grader fix (expected diff):**
  - `pass -> fail` when tightening a check that previously false-passed on unrelated CSS/markup. Confirm in `agent.patch` that the saved solution missed the requirement.
  - `fail -> pass` when fixing an overly strict check that rejected a pattern `guide.md` allows. Confirm in `agent.patch` that the saved solution complies with `guide.md` and `expectations.md`; never loosen a check speculatively when the rejected pattern is not allowed by the guide (or when no valid solution failed it).
- **Timeout flakiness:** Checks involving `timedOut` (`pass -> timedOut` or `timedOut -> pass`) point to worker contention rather than grader changes — re-run at lower `--concurrency`.
- **Title or structure drift (expected diff):** Check titles appear as `saved -> <missing>` and `<missing> -> now` because tests were renamed or consolidated on `main`. Check `git log -p -n 3 -- <grader>` and compare pass/fail totals.
- **Base-app drift (`PATCH_CONFLICT`):** An older `agent.patch` fails to apply against current `src/harness/base-apps/` or `zero-passrate.patch`. Not a grader bug — re-run against a newer nightly job from GCS.

If you edit a `grader.ts` after triaging, re-run `gd dev <guide> --test-grader` and `scripts/replay.ts`, then finish with `pnpm run preflight`.

## Related Skills

- [`project-evals`](../project-evals/SKILL.md) — rules for writing and reviewing `expectations.md`, `task.md`, and `grader.ts`.
- [`dev-prompt-canary`](../dev-prompt-canary/SKILL.md) — empirical validation for edits to `gd dev` prompts and grader generation templates.
- [`nightly-eval-investigation`](../nightly-eval-investigation/SKILL.md) — triaging low-performing tasks across nightly jobs in GCS.
