Skip to content

docs(email): add EVALUATION.md guide + make the scorecard reproducible - #1989

Merged
kovtcharov-amd merged 5 commits into
mainfrom
docs/email-scorecard-repro
Jul 10, 2026
Merged

kovtcharov-amd merged 5 commits into
mainfrom
docs/email-scorecard-repro

Conversation

@kovtcharov-amd

@kovtcharov-amd kovtcharov-amd commented Jul 10, 2026 •

Copy link
Copy Markdown
Collaborator

Why this matters

The email agent's published SCORECARD.md (shipped in @amd-gaia/agent-email) pointed readers at a reproduction recipe that failed on a fresh checkout — it ran the benchmark against synthetic_inbox.mbox / ground_truth.json, which are generated, gitignored artifacts, so a new user hit file-not-found before their first run. There was also no intro to what the eval measures, no dataset pointers, and no worked example — "reproduce this" effectively meant "read the harness source."

This splits the two concerns so each file does one job:

  • SCORECARD.md (generated) — stays lean: score, metrics, per-category breakdown, environment, and the exact reproduction command, now fixed to install deps and build the corpus from the committed seed (generate_mbox.py) before running the benchmark. Scores unchanged (docs only).
  • EVALUATION.md (new, hand-authored) — the evaluation guide: what the agent does and what's measured (local, offline, no LLM judge), the dataset + provenance + schema pointers, a worked example (input seed record → agent output → ground-truth entry → scoring row), the metric definitions, and step-by-step reproduction. Ships in the npm package alongside README/SCORECARD/SPEC and is linked from the README.

Keeping the guide out of the generated card also means the shared core generator (release_scorecard.py) is unchanged vs main — an earlier iteration added generic notes/marker/carry-forward machinery to embed the prose in the generated file; the split makes that unnecessary and it's reverted.

Test plan

  • pytest tests/unit/eval/test_release_scorecard.py tests/unit/eval/test_scorecard_gate.py — 98 pass (adapter test asserts the repro command includes generate_mbox.py, the install line, and the EVALUATION.md pointer). On Windows, run with PYTHONUTF8=1 — pre-existing carry_forward tests write UTF-8 without an explicit encoding.
  • python -m gaia.eval.scorecard_gate --scorecard hub/agents/npm/agent-email/SCORECARD.md — passes, aggregate.value = 83.4 (unchanged); front matter byte-identical vs main.
  • black --check / isort --check clean; package.json valid JSON with EVALUATION.md added to files.

Note: two commits (the first added the guide content to SCORECARD.md; the second split it into EVALUATION.md and reverted the core changes). The net diff is the final design — squash-merge recommended.

The email agent's SCORECARD.md documented a reproduction recipe that failed on
a fresh checkout: it ran the benchmark against synthetic_inbox.mbox /
ground_truth.json, which are generated (gitignored) artifacts, so a new user hit
file-not-found before the first run. It also had no dataset pointers, no example,
and no explanation of what the metrics mean.

The card is generator-produced, so the fix lands in the generators:
- gen_scorecard.py: the reproduction recipe now installs the eval extras, starts
  Lemonade, and builds the corpus from the committed seed (generate_mbox.py)
  before running the benchmark; a new Dataset appendix adds source-of-truth
  pointers, a worked example (seed record -> ground-truth entry -> scoring), and
  a plain-language metric glossary.
- release_scorecard.py: adds a generic, agent-agnostic optional notes block
  (marker-wrapped so carry_forward preserves it across patch releases).
- SCORECARD.md regenerated deterministically from existing front matter; scores
  unchanged, only docs added.
@github-actions github-actions Bot added eval Evaluation framework changes tests Test changes performance Performance-critical changes agent::email Email agent changes labels Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve ✅

This PR makes the email agent's published SCORECARD.md actually reproducible from a fresh checkout: the recipe now installs the eval extras and builds the gitignored corpus from its committed seed before running the benchmark (previously it hit file-not-found on the very first step), and adds a dataset map, a worked example, and a plain-language metric glossary. Because the card is generator-produced, the fix correctly lives in the generators — a hand-edit would be overwritten on the next release.

I checked the substance, not just the prose: the worked-example record matches the committed seed, the ordinal priority ladder documented in the card (URGENT > NEEDS_RESPONSE > FYI > PROMOTIONAL, PERSONAL off-scale) matches the real scoring code, the relative doc links resolve, and the new notes field is optional/backward-compatible with round-trip and carry-forward test coverage. Scores are unchanged. No blocking issues — two trivial nits below, both optional.

🔍 Technical details

Strengths

  • Fix lives at the right layer: _build_notes / _build_reproduction_command in gen_scorecard.py:270,116 plus the generic marker-wrapped notes block in release_scorecard.py — a hand-edit to SCORECARD.md would be lost on the next release, so this is the correct place. The notes block reuses the exact carry-forward pattern already proven for breakdown/environment.
  • Accuracy verified against source, not just internally consistent:
    • Worked-example seed (004d89d1-…) is byte-verified present in tests/fixtures/email/vendor_corpus_seed.jsonl with the documented category/suggestedAction/source_dataset.
    • The ordinal ladder in the card matches ORDINAL_PRIORITY in src/gaia/eval/quality_metrics.py:77 (urgent=3, needs_response=2, fyi=1, promotional=0), and the "PERSONAL is off-scale / exact-only" simplification is faithful to the comment there.
    • The four ../ in the doc links resolve from hub/agents/npm/agent-email/ to repo root; targets exist.
  • Backward-compatible: notes: Optional[str] = None (release_scorecard.py:98), body-only, test_notes_not_in_required_fields + test_notes_does_not_break_front_matter_or_validation prove it never leaks into the machine-readable YAML or shifts the aggregate. Good, targeted 12-test addition.
  • carry_forward now reads the text once and passes it to parse_scorecard (which accepts str), reusing the same buffer for _extract_notes — no double read, no signature break.

🟢 Minor / nits (optional)

🟢 Provenance line names select_vendor_subset.py without a path (gen_scorecard.py:299 / SCORECARD.md:50). Every other artifact in the section is a resolvable link, but this script is a bare name — and it actually lives at tests/fixtures/email/select_vendor_subset.py, not the packaging/ dir a reader might assume from context. A link (or inline path) would keep the provenance chain fully traceable.

🟢 The worked-example subject in the doc uses an ASCII hyphen (Lineup - Data Request) while the committed seed record uses an en-dash (Lineup – Data Request). Trivial, and it's an illustrative block, but since it's introduced as "A seed record (source of truth)" a purist copy would match the seed exactly.

…esults

Separates concerns: SCORECARD.md is a generated results artifact (score,
metrics, breakdown, environment) and stays lean; EVALUATION.md is a
hand-authored guide covering what's measured, the dataset + provenance, a
worked example (input -> agent output -> ground truth -> scoring), the metric
definitions, and full reproduction steps.

This reverts the generic notes/marker/carry-forward machinery previously added
to release_scorecard.py (no longer needed once the guide is its own file), so
the shared core generator is unchanged vs main. What stays on the card: the
exact reproduction command (now installs deps and builds the corpus from the
committed seed before running the benchmark, so it works on a fresh checkout)
plus a pointer to EVALUATION.md.

EVALUATION.md ships in the npm package (package.json files) alongside README /
SCORECARD / SPEC, and is linked from the README.
@kovtcharov-amd kovtcharov-amd changed the title docs(email): make the eval scorecard reproducible from scratch docs(email): add EVALUATION.md guide + make the scorecard reproducible Jul 10, 2026
The triage scoring behind SCORECARD.md is deterministic label-matching
(predicted == expected in quality_metrics.py) — no Claude, no ANTHROPIC_API_KEY.
The email agent's separate voice-drafting quality eval (#1269) IS judge-scored by
Claude and needs ANTHROPIC_API_KEY; it is report-mode and independent of the
scorecard. The prior wording implied the whole email eval was judge-free.
…D.md

The reproduction recipe lived in two places: the auto-generated Reproduction
section of SCORECARD.md and a hand-copied block in EVALUATION.md. Since both now
render as separate tabs on the hub agent page, the duplication is visible to
readers and the hand-copy drifts from the generated (version-stamped) command.

EVALUATION.md now points at SCORECARD.md's Reproduction section and keeps only
its unique conceptual notes (timeout rationale, serial-eval, variance). The
generated SCORECARD.md still cross-links back to EVALUATION.md for background, so
each fact has exactly one home.
kovtcharov-amd added a commit that referenced this pull request Jul 10, 2026
)

## Why this matters

An email-agent release could previously ship even if the judge-based
evals regressed, the perf bars were missed, or the unit/spec tests were
red. #1983 wired the eval suite (triage / drafting / action-item /
briefing) into the release as a gate, but the drafting + perf gates were
**report-only**, and the release did **not** run the unit or
spec/contract tests at all.

After this change, a release of `@amd-gaia/agent-email` is blocked
unless, at the release commit:
- **Every eval passes** — triage acceptance bar, **drafting** approval,
**perf** bars, plus the already-enforcing action-item + briefing judge
evals.
- **A missing `ANTHROPIC_API_KEY` blocks** — the action-item + briefing
evals hard-require the judge and fail loudly (no fuzzy-only fallback),
so a release can't ship an un-judged suite.
- **All email tests pass**, including the **REST-sidecar contract** and
**OpenAPI-conformance (spec)** tests — now part of the release gate, not
just PR CI.
- The **judge-scored drafting result is folded into `SCORECARD.md`**
(`draft_approval_rate`, reported metric).

## What changed

- **Enforce drafting + perf gates**
(`tests/fixtures/email/{drafting,perf}_gate_thresholds.json` → `enforce:
true`). ⚠️ The perf bars are not yet independently hardware-confirmed —
if the stx pool proves noisy, widen them in the manifest (data, not
code) rather than reverting to report mode.
- **`release_agent_email.yml`**: `publish` now also needs a new
`email-tests` gate (`uses: test_email_agent_unit.yml`).
- **`test_email_agent_unit.yml`**: installs the email hub package and
also runs `hub/agents/python/email/tests/` (REST contract) +
`tests/test_email_openapi_conformance.py` (spec) — fully mocked, no
Lemonade.
- **`gen_scorecard.py`**: new `--drafting-report`; folds
`draft_approval_rate` as a reported metric (weight 0) so the aggregate
stays `100 × within_one_bucket_accuracy`. Loud-skip report → metric
omitted; malformed non-skip → hard error.
- **`email_scorecard_refresh.yml`**: runs the drafting eval and passes
`--drafting-report`, so the committed/shipped scorecard carries the
drafting metric.
- **`test_email_agent_eval.yml`**: nightly → **weekly** (Mondays 07:17
UTC) — the run now spends Claude judge tokens, and the release re-runs
the suite as a hard gate.

## Design note (deviation from the original plan preview)

The approved preview envisioned a bespoke `eval-gate` job that
regenerates + ships a runner-fresh scorecard. #1983 had already landed a
reusable `email-eval` gate, so this adapts to that structure instead:
the eval runs (and now enforces) via `email-eval`; the committed
scorecard is kept honest — and gains the drafting metric — by
`email_scorecard_refresh.yml`. Net effect matches the requirement.

## Test plan

- [x] `pytest tests/unit/eval/test_release_scorecard.py` — 76 pass (3
new: drafting metric folded/reported/aggregate-unchanged; loud-skip
omits; malformed fails loud). *Windows: `PYTHONUTF8=1`.*
- [x] `black --check` / `isort --check` clean on the changed Python.
- [x] All four edited workflows YAML-parse; both manifests are valid
JSON with `enforce: true`.
- [ ] **CI-only (cannot run locally):** the `email-eval` gate +
`email_scorecard_refresh` run on the self-hosted **stx** pool with
Lemonade + `ANTHROPIC_API_KEY`. Verify via a `workflow_dispatch` dry-run
on hardware before cutting a real tag — especially that the
newly-enforced **perf** bars pass on the pool.

## Dependency
Overlaps PR #1989 (docs) on `gen_scorecard.py`. Trivial to resolve;
recommend landing #1989 first.

---------

Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
# Conflicts:
#	hub/agents/python/email/packaging/gen_scorecard.py
@kovtcharov-amd
kovtcharov-amd disabled auto-merge July 10, 2026 22:14
@kovtcharov-amd
kovtcharov-amd merged commit 6fb95ea into main Jul 10, 2026
34 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the docs/email-scorecard-repro branch July 10, 2026 22:14
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Jul 11, 2026
…lent skip) (amd#2023)

## Why this matters

Follow-up to amd#1990 (already merged), which flipped the drafting + perf
gates to `enforce:true` but left two accuracy defects on main:

1. **A fail-loudly violation.** `eval_drafting_report.py` still
*silently loud-skipped* when `ANTHROPIC_API_KEY` was absent — it wrote
`{"skipped": true, "should_fail": false}` and returned 0, and
`gen_scorecard.py` then quietly dropped the `draft_approval_rate`
metric. So a keyless run shipped an **un-judged drafting gate** while
the manifest claimed `enforce:true`. That contradicts CLAUDE.md's "No
Silent Fallbacks — Fail Loudly" hard rule. Now a missing key is a hard
failure (exit 1) with an actionable error naming the key; there is no
skip report and no invented pass.

2. **Stale docs from the enforce flip.** `test_email_agent_eval.yml`,
`release_agent_email.yml`, and the drafting-eval docstrings still
described the perf/drafting gates as `enforce:false` / "report mode" /
"loud-skip". Swept to match shipped behavior: perf + drafting + briefing
enforce; only the FP/FN quality gate remains report-mode.

No gating **logic** changed beyond the missing-key path — the manifests
still own the enforce switch (data, not code).

**Fork/nightly safety:** the three workflows that run the judged eval
trigger only on `schedule` / `workflow_call` / tag-push / base-branch
push — never `pull_request` from a fork — so `secrets.ANTHROPIC_API_KEY`
is always present in a legitimate run and the hard-fail can't spuriously
break CI.

## Test plan

- [x] `pytest tests/unit/eval tests/unit/email -q` → 605 passed
- [x] New: missing key → `main()` returns 1 + stderr names
`ANTHROPIC_API_KEY`, writes no skip report
(`test_drafting_eval_missing_key_hard_fails`)
- [x] Changed: a `skipped`-marked report now raises instead of silently
omitting the metric (`test_drafting_report_skip_marker_fails_loud`)
- [x] `python util/lint.py --all` clean; all three workflow YAMLs parse
- [x] `gen_scorecard.py` retains amd#1989's `_build_reproduction_command`
alongside the fail-loudly change (clean 3-way merge)
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Jul 11, 2026
…md#2020)

The email agent ships an `EVALUATION.md` eval guide (added in amd#1989) and
links it from its README via github.com URLs, but the hub page only
renders readme/changelog/spec/skill/scorecard from the catalog — so
**EVALUATION.md never appears on amd-gaia.ai/hub/email**. This adds a
new catalog `evaluation` field carrying the agent's EVALUATION.md
markdown and surfaces it as its own **Evaluation** tab. It mirrors the
existing spec/skill doc-field pipeline exactly — plain embedded
markdown, no front matter, no score, no URL (unlike the score-carrying
scorecard field).

**Dependency:** `hub/agents/npm/agent-email/EVALUATION.md` currently
exists only on the amd#1989 branch (`docs/email-scorecard-repro`), not on
main. The release workflow's `--evaluation` flag is guarded by a
file-presence check, so releases cut before amd#1989 merges still publish
cleanly; the tab lights up once EVALUATION.md lands on main and the next
email release republishes.

## Test plan

- [x] Worker: `cd workers/agent-hub && npx vitest run` → **70 passed**
(incl. new evaluation store/serve/index assertions + the
`entry.evaluation === ""` default) and `npx tsc --noEmit` clean.
- [x] Website: `cd website && npx vitest run` → **26 passed**;
`HUB_CATALOG_URL=https://hub.amd-gaia.ai npm run build` (astro check +
build) clean.
- [x] **Render proof**: injected `"evaluation": "# Eval Guide\n\nHello
**newcomer**.\n"` into a local copy of the live catalog, served it on a
non-4001 port, rebuilt, and grepped `dist/hub/email/index.html`:
  - Tab button → `data-doc-tab="evaluation" ...>Evaluation<`
  - Panel → `data-doc-panel="evaluation"`
  - Rendered body → `Eval Guide</h1>` and `<strong>newcomer</strong>`
- [x] Python: `publish_to_r2.py` parses and `--evaluation` appears in
`--help`; the `hub/` packaging dir is outside `util/lint.py`'s scope
(`src/gaia` + `tests` only), and the new line is black-clean regardless.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent::email Email agent changes eval Evaluation framework changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants