Skip to content

fix(email-eval): drafting eval hard-fails on missing judge key (no silent skip) - #2023

Merged
kovtcharov-amd merged 1 commit into
mainfrom
fix/email-eval-fail-loudly
Jul 10, 2026
Merged

kovtcharov-amd merged 1 commit into
mainfrom
fix/email-eval-fail-loudly

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Why this matters

Follow-up to #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

  • pytest tests/unit/eval tests/unit/email -q → 605 passed
  • New: missing key → main() returns 1 + stderr names ANTHROPIC_API_KEY, writes no skip report (test_drafting_eval_missing_key_hard_fails)
  • Changed: a skipped-marked report now raises instead of silently omitting the metric (test_drafting_report_skip_marker_fails_loud)
  • python util/lint.py --all clean; all three workflow YAMLs parse
  • gen_scorecard.py retains docs(email): add EVALUATION.md guide + make the scorecard reproducible #1989's _build_reproduction_command alongside the fail-loudly change (clean 3-way merge)

…lent skip)

CLAUDE.md's "No Silent Fallbacks — Fail Loudly" is a hard rule, and the
drafting eval's missing-key path violated it: it wrote a `{"skipped": true,
"should_fail": false}` report and returned 0, so a keyless run silently shipped
an un-judged drafting gate and gen_scorecard just dropped the metric.

- eval_drafting_report.py: delete the skip branch. A missing ANTHROPIC_API_KEY
  now prints an actionable error (what failed / what to do / where) to stderr and
  exits 1, regardless of enforce. No skip report, no invented pass.
- gen_scorecard.py `_load_draft_approval_rate`: drop the silent `skipped -> None`
  omit; a `skipped` marker or a missing rate now raises. Return type is `float`,
  and build_payload always folds the metric (no None guard).
- Docs swept for the enforce:false->true flip and the new fail-loudly behavior:
  eval_drafting_report.py docstring, gen_scorecard --drafting-report help,
  release_agent_email.yml key comment (attributed to the drafting eval's exit 1),
  and test_email_agent_eval.yml (report-mode/loud-skip text for perf + drafting).
- Tests: missing key -> exit 1 + actionable error; a `skipped` report -> raises.

Verified none of the three workflows that run the judged eval trigger on fork
PRs (schedule / workflow_call / tag-push / branch push only), so the key is
always present in a legitimate run — the hard-fail never spuriously breaks CI.
@github-actions github-actions Bot added devops DevOps/infrastructure changes tests Test changes agent::email Email agent changes labels Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve ✅

This closes a real fail-loudly hole in the email drafting eval: a keyless run used to write a skipped report, return 0, and let gen_scorecard quietly drop the drafting metric — so a gate the manifest declares enforce:true could ship un-judged. Now a missing ANTHROPIC_API_KEY is a hard exit-1 with an actionable error, and the scorecard raises rather than omit. The rest is a doc/comment sweep so the three workflows and docstrings stop describing the (already-flipped, per #1990) perf/drafting/briefing gates as "report mode."

I checked the change end-to-end and it's consistent: the manifests really do ship drafting/perf/briefing = enforce:true and quality = enforce:false, matching every updated comment; the refresh and eval workflow steps both throw on the non-zero exit (no continue-on-error swallowing it); and the sibling action-item/briefing reports already hard-fail on a missing key, so the workflow's updated "REQUIRED" secret description is accurate. New tests cover both the hard-fail and the legacy-marker-raises paths. Well done — the tests are the right shape and the scope is tight.

One optional, out-of-scope follow-up below; not blocking.

🔍 Technical details

🟢 Minor / optional (out of scope — pre-existing, not in this diff)

The doc sweep updated test_email_agent_eval.yml's header to call the perf gate ENFORCING, but the actual reader that processes it, hub/agents/python/email/packaging/eval_gate_report.py, still labels itself "report mode" in its module docstring (line 4) and its runtime prints (EMAIL EVAL GATE REPORT (report mode) ~line 94, [GATE] report mode ... ~line 148). Since perf now enforces, those labels are stale in exactly the way this PR is fixing elsewhere. Folding a one-line relabel into this sweep would keep the reader consistent with its own workflow header — but the mechanism it describes (should_fail = enforce ∧ breached) is still correct, so it's purely cosmetic and fine as a separate cleanup.

Verification performed

  • tests/fixtures/email/{drafting,perf,briefing}_gate_thresholds.json → enforce:true; quality → enforce:false — matches all updated comments and docstrings.
  • email_scorecard_refresh.yml drafting-eval step guards if ($LASTEXITCODE -ne 0) { throw ... }, so the new exit-1 propagates before gen_scorecard runs — no half-committed card.
  • default_drafting_thresholds_path() resolves via Path(__file__).resolve().parents[3], not cwd, so test_drafting_eval_missing_key_hard_fails's monkeypatch.chdir(tmp_path) doesn't break threshold loading before the key check (eval_drafting_report.py:47-52).
  • _load_draft_approval_rate return type tightened Optional[float] → float; Optional is still imported and used elsewhere in gen_scorecard.py — no dead import.

Strengths

  • The test_drafting_eval_missing_key_hard_fails test loads the CI helper by file path and asserts the shape of the failure — exit 1, ANTHROPIC_API_KEY named in stderr, and no report file written — which is exactly the contract gen_scorecard depends on, not just "it returned non-zero."
  • _load_draft_approval_rate doesn't just drop the None branch — it raises on the legacy skipped marker with a message that tells the operator to re-run with the key set, so an old report can't silently degrade a fresh card.
  • Doc/comment sweep is genuinely cross-checked against the manifests rather than asserted, and the fork-safety note (judged evals never run on pull_request from a fork) correctly explains why the hard-fail can't spuriously break CI.

@kovtcharov-amd
kovtcharov-amd enabled auto-merge July 10, 2026 22:27
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Jul 10, 2026
Merged via the queue into main with commit 339443f Jul 10, 2026
33 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/email-eval-fail-loudly branch July 10, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent::email Email agent changes devops DevOps/infrastructure changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants