Skip to content

feat(eval): canonical evaluation rubrics in core + rubric reference doc (closes #430) - #431

Merged
haiyuan-eng-google merged 3 commits into
GoogleCloudPlatform:mainfrom
evekhm:feat/core-evaluation-rubrics
Aug 27, 2026
Merged

haiyuan-eng-google merged 3 commits into
GoogleCloudPlatform:mainfrom
evekhm:feat/core-evaluation-rubrics

Conversation

@evekhm

@evekhm evekhm commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Extracts the canonical rubric data and interpreter from scripts/quality_report.py into bigquery_agent_analytics.evaluation_rubrics, per #430 — superseding the #91 Phase-1 approach by extraction-from-current rather than resurrection-from-April.

What's in core now:

  • builtin_metric_config() — deep copy of the canonical 8-metric config (response_usefulness with the scope-conditional declined category, task_grounding, correctness, tool_usage, specificity, scope_compliance, first_time_right, failure_attribution), same schema as an --eval-config JSON.
  • build_metrics(eval_config=None, *, scope_context='', has_scope=False) — the interpreter, verbatim semantics from the shipping script: scope-aware definition enrichment, declined injection with insert_after positioning, scope suffixes.
  • docs/evaluation_rubrics.md — the rubric reference: every metric's judge definition and category vocabulary (generated from the canonical data, so it cannot drift from what the judge actually sees), the scope/declined mechanics, golden-grounding interplay, Python + CLI usage, and the override schema.

Same-PR thinning (no dual implementations): get_eval_metrics() now derives scope inputs from the eval spec and delegates to core; a missing eval_config.json falls back to the SDK builtin instead of raising. A drift-guard test pins builtin_metric_config() to scripts/eval/eval_config.json.

Tests: 6 new in tests/test_evaluation_rubrics.py (canonical set, declined injection + positioning, scope-aware appending, deep-copy isolation, custom-config passthrough, builtin↔file parity); full quality-report/skill-evolution/compare-runs suites green (184).

Relation to #91: same destination file name and intent, but built from the current, recorded-and-published vocabulary; policy_compliance from #91 can layer on top afterwards. Refs #63, #397.

…ity_report

Adds bigquery_agent_analytics.evaluation_rubrics: the canonical 8-metric
rubric data (response_usefulness with the scope-conditional declined
category, task_grounding, correctness, tool_usage, specificity,
scope_compliance, first_time_right, failure_attribution) and the
interpreter that turns a metric config into CategoricalMetricDefinition
objects -- builtin_metric_config() and build_metrics(eval_config, *,
scope_context, has_scope) -- extracted verbatim from the shipping
scripts/quality_report.py semantics rather than resurrected from the
stale GoogleCloudPlatform#91 snapshot (which froze a 2-category usefulness with no declined
handling; this supersedes that Phase-1 approach with the current,
recorded-and-published vocabulary).

scripts/quality_report.py becomes a thin caller in the same change:
get_eval_metrics derives scope inputs from the eval spec and delegates
to core build_metrics; a missing eval_config.json now falls back to the
SDK builtin instead of raising. A drift-guard test pins
builtin_metric_config() to scripts/eval/eval_config.json so the two can
never diverge silently.

docs/evaluation_rubrics.md is the generated-from-data rubric reference:
every metric's judge definition and category vocabulary verbatim, the
scope/declined mechanics, golden-grounding interplay, Python + CLI
usage, and the override schema.
@caohy1988

Copy link
Copy Markdown
Collaborator

Code review: canonical evaluation rubrics in core

Verdict: approve with small changes. The extraction is faithful — I diffed the moved interpreter against the original get_eval_metrics logic and the semantics are verbatim, including the pre-existing quirk that a typo'd insert_after silently inserts at position 0 (idx = -1 → insert(0, ...); consider a warning, but it's not a regression). Imports match the SDK's absolute-import house style, the __init__.py try/except block matches its neighbors, list[...] annotations are fine for the >=3.10 floor, and the deep-copy and drift-guard tests are the right tests. CI is green across Python 3.10–3.14.

Findings:

  1. The doc's no-drift claim isn't actually enforced (medium-low). The PR body says docs/evaluation_rubrics.md is "generated from the canonical data, so it cannot drift" — but no generator script is committed and no test pins the doc to _BUILTIN_METRIC_CONFIG. The drift guard only pins builtin ↔ scripts/eval/eval_config.json. The first rubric edit will silently strand the doc. Either commit the generator, add a doc-parity test (e.g. assert each metric's definition/category text appears in the doc), or soften the claim.

  2. Fallback can shadow a clearer error (low). The new auto-discovery fallback in _load_eval_config does from bigquery_agent_analytics import builtin_metric_config — against an older installed SDK that lacks evaluation_rubrics, the previously actionable FileNotFoundError (which told the user where to put the file) becomes a bare ImportError: cannot import name 'builtin_metric_config'. Wrapping the import to re-raise with the old guidance costs three lines. (Verified: an explicit --eval-config <path> still raises FileNotFoundError — the fallback only applies to auto-discovery, which is the right scoping.)

  3. Consider logger.warning instead of info for the fallback. A user whose custom eval/eval_config.json is misplaced now silently gets the builtin rubrics where they previously got a hard stop; an info line is easy to miss in a full run's output.

Cross-PR note: this PR and #432 both insert their export block at the same anchor in __init__.py (right before "# Categorical Views") and both edit scripts/quality_report.py. The quality_report.py hunks don't overlap so git should auto-merge those, but the __init__.py insertion is a guaranteed conflict for whichever merges second — plan a rebase.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review: Approve with nits

Verified locally: the extraction is token-for-token verbatim from the old interpreter (only the log message wording changed: "Loaded %d metrics" → "Built %d metric definitions"). The drift guard is real and currently passes — confirmed builtin_metric_config() == scripts/eval/eval_config.json as parsed dicts. Reproduced the claimed test count exactly: 6 new + 131 quality-report + 47 skill-evolution/compare-runs = 184, all green. CI green across Python 3.10–3.14.

Findings

MINOR — fallback is silent where it used to fail loudly (scripts/quality_report.py:674)
The old code raised FileNotFoundError naming the expected locations; the new code logs at info and proceeds with builtin rubrics. A user who runs from the wrong cwd (or whose eval/eval_config.json was moved/renamed) now gets a plausible-looking report graded with the canonical vocabulary instead of their custom one, with only an info-level line to hint why. The fallback itself is a reasonable feature, but this should be logger.warning naming the searched locations so a discovery mistake is visible.

MINOR — the behavior change this PR makes is the one thing not tested (scripts/quality_report.py:670-678)
None of the 6 new tests (nor any existing test — _load_eval_config has zero test references) covers the new no-file → builtin fallback or the get_eval_metrics delegation. A cheap test: clear _EVAL_CONFIG_CACHE, monkeypatch _repo_root/_script_dir to empty dirs, assert the builtin is returned and cached. Given the description explicitly calls out "no longer raising" as deliberate, it should be pinned.

MINOR — doc "cannot drift" claim is overstated (docs/evaluation_rubrics.md)
The description says the doc is "generated from the canonical data, so it cannot drift from what the judge actually sees." There is no generator script in the repo; the doc is a third, hand-maintained copy of the rubric text, and the drift guard pins only builtin ↔ eval_config.json, not the doc. The tables do match the config verbatim today (spot-checked all 8 metrics), but either add a generation/consistency check or soften the claim to "mirrors the canonical data."

NIT — stale docstring on _load_eval_config (scripts/quality_report.py:636-646)
Still says "The file is expected to contain: metrics…" with no mention of the builtin fallback when no file exists.

NIT — insert_after typo silently reorders to front (src/bigquery_agent_analytics/evaluation_rubrics.py:280-283)
When insert_after names a nonexistent category, idx = -1 → cats.insert(0, declined_cat), silently placing declined first. Verbatim from the old script (not a regression), but it's now public API consumed by arbitrary custom configs; falling back to append when idx == -1 would be less surprising. The not-found case is also the one injection path the new tests don't cover.

NIT — build_metrics(None) reads the module constant by reference (evaluation_rubrics.py:262-263)
Safe today (the interpreter never mutates the config), but the safety rests on a no-mutation invariant over shared module state; using builtin_metric_config() here would make it self-evidently safe.

NIT — import style (evaluation_rubrics.py:43-44)
Absolute import while sibling categorical_views.py:53 uses relative. Cosmetic.

Positives

  • Extraction verified programmatically: identical logic, ordering, and insert_after/idx+1 semantics.
  • The drift guard is genuine full-dict equality; the deep-copy isolation test correctly pins the mutate-freely contract.
  • Doc accuracy is good where checkable: declined documented as inserted after meaningful (matches), and the Python example's API names match real signatures.
  • The --dimensions primary path builds a filtered copy rather than mutating the cached config, so the new cached-builtin fallback can't be corrupted by it.

Review by @caohy1988's assistant (Kimi Code CLI).

@caohy1988

Copy link
Copy Markdown
Collaborator

Code review: current head 0ad46a4

Verdict: Ready to merge. I found no actionable defect in this PR.

Verified against the current head:

  • The canonical eight-metric data matches scripts/eval/eval_config.json.
  • builtin_metric_config() returns an isolated deep copy.
  • build_metrics() preserves scope-aware definition enrichment, conditional declined insertion, insert_after positioning, and custom-config behavior.
  • scripts/quality_report.py delegates to the core interpreter without keeping a second implementation.
  • The missing-file path correctly falls back to the builtin config.
  • The documented package-root imports work.
  • Relevant local suites pass: 184 passed. CI is green across Python 3.10-3.14, format, build, browser smoke, security scan, and CLA.

Non-blocking coverage note: the new missing-file fallback and package-root exports are not isolated in committed regression tests, although both paths passed direct execution during review.

Merge coordination: PR #432 edits the same export location in src/bigquery_agent_analytics/__init__.py, so the second PR to land will need a rebase and a trivial conflict resolution that retains both public export blocks.

@caohy1988

Copy link
Copy Markdown
Collaborator

Open-PR sweep recheck at unchanged head 0ad46a4.

No commits have landed since my full current-head review. The Ready to merge verdict still applies, and the current CI checks remain green. I still found no actionable defect in the rubric constants, exports, or reference documentation.

Full current-head review: #431 (comment)

Coordination note: #432 still edits overlapping evaluator/export surfaces, so whichever PR lands second should be refreshed against the first.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM - approved at exact head 0ad46a4.

I re-reviewed the full diff and prior threads. The public exports, deep-copy configuration, fallback behavior, and quality_report semantics remain correct. Exact-head focused tests pass (6 tests), and current CI is green.

PR #432 overlaps some export/evaluator surfaces, so whichever lands second should refresh from main and rerun CI.

@haiyuan-eng-google
haiyuan-eng-google merged commit e8a9b00 into GoogleCloudPlatform:main Aug 27, 2026
11 checks passed
haiyuan-eng-google pushed a commit that referenced this pull request Aug 30, 2026
…configurator (#450)

* chore(release): 0.5.1 — evalbench reader, canonical rubrics, single-input configurator

Version bump 0.5.0 -> 0.5.1 and the changelog cut for everything merged
since v0.5.0 (2026-08-11). In the wheel: the EvalBench BigQuery run
reader (#444), canonical evaluation rubrics in core (#431), and the CLI
judge-feedback escaping fix (#438). Repo/live-template side: the
single fully-qualified table-ID configurator entrance (#449), Console
table-link paste (#424), the attested external-access contract with its
staleness workflow (#446), the end-user manual (#425), Grafana metric
and scan-bound fixes (#433) with the one-command local run (#422), and
the documentation and CI follow-ups.

* chore(release): fold #432 golden-matching into the 0.5.1 cut

The release branch was cut one commit before #432 landed on main; the
synthetic merge CI builds would already ship golden_matching.py in the
0.5.1 wheel, so the module and its three top-level exports must be in
the release section. Merges main and documents the module in Release
highlights and Added.
caohy1988 added a commit to caohy1988/BQAA-SDK-fork that referenced this pull request Aug 30, 2026
…sion flags (GoogleCloudPlatform#435)

New failure_taxonomy module: versioned scaffold config (0.0.0-scaffold,
g1_frozen: false) in the GoogleCloudPlatform#431 metric-config schema shape, three mechanical
core categories mapped 1:1 from the landed failed-session flags
(process_failed / missing_completion / score_failed), an empty D2 dialects
slot, and a pure deterministic categorize_failed_session() over dict or
SessionVerdict rows. No BigQuery, no LLM, no network. NOT G1: no names
frozen; six-week clock not started; partner/D4/live traces stay parked.
caohy1988 added a commit to caohy1988/BQAA-SDK-fork that referenced this pull request Aug 30, 2026
…sion flags (GoogleCloudPlatform#435)

New failure_taxonomy module: versioned scaffold config (0.0.0-scaffold,
g1_frozen: false) in the GoogleCloudPlatform#431 metric-config schema shape, three mechanical
core categories mapped 1:1 from the landed failed-session flags
(process_failed / missing_completion / score_failed), an empty D2 dialects
slot, and a pure deterministic categorize_failed_session() over dict or
SessionVerdict rows. No BigQuery, no LLM, no network. NOT G1: no names
frozen; six-week clock not started; partner/D4/live traces stay parked.
haiyuan-eng-google pushed a commit that referenced this pull request Aug 31, 2026
* feat(evalbench): scaffold mechanical failure taxonomy from failed-session flags (#435)

New failure_taxonomy module: versioned scaffold config (0.0.0-scaffold,
g1_frozen: false) in the #431 metric-config schema shape, three mechanical
core categories mapped 1:1 from the landed failed-session flags
(process_failed / missing_completion / score_failed), an empty D2 dialects
slot, and a pure deterministic categorize_failed_session() over dict or
SessionVerdict rows. No BigQuery, no LLM, no network. NOT G1: no names
frozen; six-week clock not started; partner/D4/live traces stay parked.

* feat(evalbench): attach scaffold taxonomy categories to failed-session rows (#435)

Consume the slice-8 failure_taxonomy scaffold from the failed-sessions
path: EvalBenchSession exposes taxonomy_categories as a property computed
from its three mechanical flags via categorize_failed_session, and
to_dict() serializes it as a list, so failed_sessions() rows and the
evalbench-failed-sessions CLI JSON/text output carry the tripped scaffold
ids. EvalBenchFailedSessions.to_dict() now serializes nested sessions
through EvalBenchSession.to_dict (asdict only sees stored fields).

All-flags-false rows (--include-passed) emit [] rather than an invented
unknown bucket. Pure Python over flags already returned -- no extra
BigQuery round-trip, no SQL changes, fixture/unit tests only. Still NOT
G1: ids stay the unfrozen flag names, clock not started, partner/D4/
live-trace work parked.

* docs(evalbench): example Week 0 scenario pack demonstrating the full AgentForensics idea (#435)

All five Week 0 human gates of docs/agentforensics_mvp_plan.md as one
concrete EXAMPLE story on the widget-stock failed session: partner+SANA
(example partner Acme Retail Support), runtime+route, pilot-benchmark
rubric, D4 boundary memo, preregistration floors — then the session, its
mechanical taxonomy_categories, and an EXAMPLE mapping onto SANA-seeded
names (fixtures only, never src/). Not a freeze: g1_frozen stays false,
the six-week clock has not started, Week 0 remains human-gated.
--fixture offline only; no BigQuery, no network.

* docs(evalbench): drop out-of-scope plan pointer from #460 example pack (#435)

* feat(evalbench): freeze Week 0 partner, D4 boundary, and G1 taxonomy v0.1 (#435)

Record Google Cloud BigQuery Agent Analytics as the real pilot partner,
land the fail-closed D4 memo for this project's EvalBench datasets, and
freeze production failure_taxonomy at v0.1.0 (g1_frozen true) with the
SANA seven + unknown. Mechanical flags map to frozen names in frozen
order. The 460 example pack stays illustrative. Clock not started.

* docs(evalbench): note #460 example pack predates G1 freeze (#435/#461)

The example pack's narrative still described the pre-freeze production
scaffold (0.0.0-scaffold, g1_frozen false, flag ids in
taxonomy_categories). Add a banner and inline caveats to the .md and .sh
stating production froze taxonomy v0.1.0 (g1_frozen true) in #461 and
now emits the frozen names (task/planning, finalization, tool blockers).
The pack stays illustrative; fixtures and script output are unchanged.

* feat(evalbench): native agent_events snapshot writer (EvalBench-adapter exit ramp) (#463)

NativeAgentEventsRun starts from production ADK agent_events rows and
publishes the same BQAA-owned contract EvalBenchRun.materialize already
produces -- pinned (job_id, import_version) snapshot events, deterministic
goal_completion score rows, manifest with the view_policy pin, and the
failed_sessions view pinned to the latest successful native publication --
with no EvalBench configs/results/scores tables anywhere in the path.

- Identity: scenario id is the first eight characters of the ADK
  session_id (7e352c34), falling back to the full id on collision; event
  and score rows keep the real session_id so the session is the same
  object with or without the adapter.
- Scores: derived from the session alone (1.0 iff AGENT_COMPLETED --
  completed, not passed; the EvalScorePolicy gate decides passed). A
  never-completed session publishes the same ERROR-status prompt-row
  marker the adapter publishes for returncode != 0, so process_failed
  holds and the widget-stock silence session 7e352c34 yields the frozen
  G1 v0.1.0 names task/planning, finalization, tool blockers.
- Thin CLI on-ramp: bq-agent-sdk evalbench-native-import, mirroring
  evalbench-import; the adapter (#97) stays optional and untouched.
- Production agent_events is never written (reserved-name guard); the
  source table is only read. Offline fixture tests only; no live BQ.
- The six-week clock has still NOT started.

* fix(evalbench): fail-close native source table and pin import_version on traces (#464)

Reject non-agent_events native sources (including EvalBench configs/results/scores)
before any query, and isolate retained native versions in trace/filter consumers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants