Skip to content

feat(evalbench): span-level G1 taxonomy on span_id (#466) - #467

Merged
haiyuan-eng-google merged 2 commits into
GoogleCloudPlatform:mainfrom
caohy1988:feat/466-span-g1-taxonomy
Aug 31, 2026
Merged

haiyuan-eng-google merged 2 commits into
GoogleCloudPlatform:mainfrom
caohy1988:feat/466-span-g1-taxonomy

Conversation

@caohy1988

@caohy1988 caohy1988 commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

Implements #466 (parent #435, AgentForensics RFC Phase 2: span-level trace auditing).

Based on merged #464 / latest main (squash 04dcadb — native agent_events writer + pin identity + G1 v0.1.0 freeze files). This PR is no longer stacked on an unmerged #464 head; the branch was rebased onto the #464 squash, so the diff vs main is exactly this slice's unique content. The unique commits remain the span G1 taxonomy slice (44d0499 feature + 0d37fcd review fix, formerly 35e40f2 + a7fd389). This PR still MUST NOT include or merge #456–#465, #468, or #470 — in particular it does not include #465 (native freeze e2e demo, head 2169889), #462, #468, or #470.

What this adds

A small span-level G1 localization layer, bigquery_agent_analytics/span_taxonomy.py:

  • SpanFailureLabel — one G1-frozen category localized to one real native span; as_tuple() is the RFC shape (trace_id, span_id, failure_category, evidence, confidence). Extra fields keep the label joinable (session_id, eval_id) and inspectable (target_kind, Promote correction/anti-parroting trace analysis to core (turn tagging + sub_trajectories) #429 turn_index).
  • label_failed_session_spans(session_events, verdict, *, eval_id, gold_events) — given one failed session's raw native agent_events-shaped rows plus the landed three-flag verdict, emits one label per tripped frozen category on the span where the failure is observable: the first raw status=ERROR row when one exists (target_kind="span", evidence carries its error_message), otherwise the last existing span as the silence boundary (target_kind="gap_after_span").
  • label_native_run(run, *, policy) — offline convenience over a NativeAgentEventsRun: computes the session-level denominator exactly as the landed contract does (classify_sessions + deterministic goal_completion facts) and localizes each failed session; completed siblings in the run supply the missing-tool evidence pool.

On the widget-stock silence session 7e352c34 (full id 7e352c34-4c1c-4395-acd5-fb3c8f215346): session-level G1 still yields task/planning, finalization, tool blockers (unchanged), and all three localize to the real AGENT_STARTING span — the last existing span — with evidence stating that no subsequent TOOL_STARTING occurred and check_inventory was never called (the completed sibling called it), and that no AGENT_COMPLETED followed. The AGENT_STARTING → silence punchline is now an inspectable localized row.

Contracts honored

  • Denominator unchanged: session-level failed_sessions + G1 remains the denominator; span labels localize, they never classify or replace it. classify_sessions / SessionVerdict / failure_taxonomy.categorize_failed_session are untouched.
  • Frozen G1 names only: taxonomy stays v0.1.0 / g1_frozen: true; SpanFailureLabel rejects any non-frozen category string at construction (test-pinned). No SANA fork, no new category names.
  • No synthetic span ids: every emitted span_id is drawn from the input agent_events rows; the gap marker is evidence anchored to the real last span; rows without a span_id fail closed with ValueError (test-pinned).
  • Frozen identity: eval_id = session_id[:8], full session_id on first-8 collision (reuses _native_scenario_ids); span labels join the same eval_id the failed_sessions / G1 contract uses (collision test included).
  • Promote correction/anti-parroting trace analysis to core (turn tagging + sub_trajectories) #429 reuse: the turn coordinate reuses the Promote correction/anti-parroting trace analysis to core (turn tagging + sub_trajectories) #429 turn-tagging / sub_trajectories anchoring (USER_MESSAGE_RECEIVED turns); no parallel span model — inputs are the same agent_events rows trace.Span reads.
  • Adapter stays: the evalbench-import adapter (Add EvalBench bridge: import EvalBench BigQuery runs into a BQAA-owned mirror table #97) is untouched; the native path remains source of truth. No CLI changes in this slice.
  • Never writes production agent_events: the module is pure/deterministic — no BigQuery client, no writes, no live/LLM judge, no --synth. Fixture-only offline tests (14 new; full suite 4524 passed).
  • Clock stays OFF: no preregistration seal, no Week 1 snapshot job.
  • D4 fail-closed: consumer remains Hai-Yuan Cao only.

Human gate

Review: @haiyuan-eng-google. Do not merge without the human gate; do not merge #456–#465 through this PR.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: Kimi

Review: PR #467 — span-level G1 taxonomy on span_id (#466)

  • HEAD: 35e40f2c21c28cee461e54ebfb6f86b68f57e9c2
  • Base: f5c6109 (PR #464 native writer HEAD) — verified git merge-base --is-ancestor; unique commit vs 464 is exactly 35e40f2.
  • Diff reviewed: git diff f5c6109..HEAD — 3 files, +774: src/bigquery_agent_analytics/span_taxonomy.py (394), tests/test_span_taxonomy.py (357), CHANGELOG.md (+23, additions only).
  • Tests: .venv/bin/python -m pytest tests/test_span_taxonomy.py -q → 14 passed (offline, 1.16s).

Verdict: LGTM / APPROVE

  • P0 count: 0
  • P1 count: 0
  • P2 count: 3 (informational only, none blocking)

P0 audit — none triggered

  • No live BQ / no --synth: span_taxonomy.py has no google.cloud / network imports; tests are in-memory fixtures built on test_native_events_writer helpers. Nothing reaches BigQuery.
  • No writes to production agent_events: module is pure functions over row mappings.
  • evalbench-import adapter (#97) untouched; evalbench.py, failure_taxonomy.py, native_events.py byte-identical to base (empty diff).
  • No clock start / preregistration sealing / Week 1 kickoff; CHANGELOG bullet explicitly keeps "the six-week clock has still NOT started".
  • No #465 (2169889) or #462 (7f5a954) commits in f5c6109..HEAD; no reset off f5c6109.
  • No Acme-as-partner, no fake D4 people, no SANA fork, no new G1 category strings — categories come from FROZEN_CATEGORY_NAMES and non-frozen names are rejected at construction (span_taxonomy.py:114-120).
  • No synthetic span identifiers: rows without a real span_id fail closed with ValueError (span_taxonomy.py:208-214); gap marker anchors to a real last span (target_kind="gap_after_span").
  • Session-level failed_sessions + G1 denominator preserved: the module never classifies; it consumes the landed verdict via categorize_failed_session and classify_sessions (span_taxonomy.py:175, 263-265). test_session_level_g1_is_unchanged_by_span_labels asserts the widget-stock verdict stays (True, True, True, True) → ("task/planning", "finalization", "tool blockers").
  • Identity rule intact: eval_id comes from _native_scenario_ids (first-8, full id on collision), span_taxonomy.py:258; no unconditional 8-char truncation.
  • No conflict markers in the diff.
  • No rewrites of NativeAgentEventsRun / failure_taxonomy / classify_sessions production paths.

P1 audit — none triggered

  • Widget-stock 7e352c34-4c1c-4395-acd5-fb3c8f215346 silence localizes to the real last span: test_silence_localizes_to_the_last_real_span_agent_starting anchors all three labels on the AGENT_STARTING span (_AGENT_STARTING_SPAN = "b7ad6b7169203331", drawn from the fixture rows) with target_kind="gap_after_span"; test_evidence_states_no_tool_starting_and_no_check_inventory asserts the evidence states "no TOOL_STARTING event follows", "check_inventory was never called", and "no AGENT_COMPLETED event follows". Session G1 unchanged. ✔
  • Required tuple present: SpanFailureLabel.as_tuple() returns (trace_id, span_id, failure_category, evidence, confidence) (span_taxonomy.py:132-142); test_rfc_tuple_shape_is_trace_span_category_evidence_confidence covers it. ✔
  • Frozen names only: used throughout; a fourth name is rejected at construction (__post_init__, span_taxonomy.py:115-120) and covered by test_a_fourth_category_string_is_rejected_at_construction. ✔
  • #429 reuse: no parallel span model — inputs are the same native agent_events rows; the turn coordinate reuses the #429 USER_MESSAGE_RECEIVED-anchored turn counting that sub_trajectories.start_turn/end_turn address (_turn_index, span_taxonomy.py:371-383; test_turn_index_counts_user_message_received_turns_like_429). See P2-2 for a nuance. ✔
  • Required tests all present: widget-stock punchline ✔, no-synthetic-span-id ✔ (test_rows_without_span_id_fail_closed_instead_of_inventing_one, test_every_emitted_span_id_comes_from_the_input_rows), first-8 collision identity ✔ (test_first8_collision_falls_back_to_the_full_session_id — twin 7e352c34-ffff-... forces full-id fallback for both), frozen-name reject ✔, session G1 unchanged ✔.
  • CHANGELOG keeps the 463/464 bullets: the diff is additions-only; the #463 native-writer bullet directly below the new one is untouched (verified against f5c6109:CHANGELOG.md). ✔
  • Stacking: unique commit is stacked on f5c6109. ✔

P2 (informational, not blockers)

  1. Silence wording in the direct-ERROR path can overstate. In _evidence (span_taxonomy.py:302-305, reused at 335-343), the finalization and task/planning evidence strings always append "the trace goes silent after {descriptor}: no subsequent agent_events row exists" / "no further plan step follows {descriptor}". For target_kind="span" the target is the first ERROR row, which need not be the last row — a trace can log an ERROR mid-stream and continue. In that case the evidence would assert a false "fact" at confidence=1.0 (which the module defines as a checkable fact of the stream, span_taxonomy.py:52-57). The existing ERROR test's span is the last row, so this is uncovered. Suggest gating the silence clause on target_index == len(ordered) - 1 or rewording for the mid-trace case. Can wait — no current fixture trips it.
  2. #429 turn anchoring is reimplemented, not shared. _turn_index re-counts USER_MESSAGE_RECEIVED events inline. The real #429 sub_trajectories turn tagging lives in scripts/quality_report.py (LLM-driven, not an importable library symbol), so there is nothing sensible to import today; the docstring's alignment claim (span_taxonomy.py:46-51) is accurate by convention. If a shared turn-index helper ever lands in the package, this should converge on it. Fine as-is.
  3. Protected-member access on NativeAgentEventsRun. label_native_run calls run._kept_and_skipped() and run._score_facts_with_prompts() with pylint disables (span_taxonomy.py:255, 260). Same-package and consistent with the run's contract, but a small public accessor would be tidier. Non-blocking.

What can wait

  • P2-1 mid-trace-ERROR evidence wording (plus a test with a non-terminal ERROR span).
  • P2-2 shared turn helper convergence; P2-3 public accessors on NativeAgentEventsRun.
  • Sub-1.0 confidences remain reserved for the labeler/judge study per the plan of record — correctly out of scope here.

Reviewed locally only; nothing posted to GitHub, no pushes, no merges, clock stays off, no live BQ, worktree unmodified.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: Codex

Code Review Results

PR: 467 - span-level G1 taxonomy on span_id for #466
Verdict: REQUEST_CHANGES
P0 count: 0
P1 count: 5
P2 count (informational): 0
HEAD SHA: 35e40f2
Scope: f5c6109..35e40f2 (unique commit 35e40f2 only; 3 files)
Mode: report-only; no worktree or GitHub mutation

The widget-stock acceptance path works, but five P1 contract defects remain. Four can emit labels that are valid-looking but false or unjoinable. The fifth allows forbidden span-level category names.

Triage Groups

Group Findings Context Preferred resolution Why
Frozen contract alignment #1, #4 The public label and turn coordinate are broader or different from the frozen contracts Restrict the category set, then consume the actual #429 coordinate This restores joinability before downstream consumers depend on the new rows
Evidence integrity #2, #3, #5 Evidence can contradict the same event stream or borrow tools from unrelated sessions Make targets category-specific, branch on observed calls, and match gold evidence per scenario These fixes keep confidence=1.0 evidence mechanically true

P1 -- High

# File Issue Reviewer Confidence
1 src/bigquery_agent_analytics/span_taxonomy.py:115 Span labels accept forbidden fourth G1 names correctness, testing, adversarial-claude 100
2 src/bigquery_agent_analytics/span_taxonomy.py:302 Mid-stream errors emit false end-of-trace evidence correctness, adversarial-claude 100
3 src/bigquery_agent_analytics/span_taxonomy.py:318 Started tools are reported as never started correctness, adversarial-claude 100
4 src/bigquery_agent_analytics/span_taxonomy.py:383 turn_index forks the #429 coordinate correctness, maintainability, adversarial-claude 100
5 src/bigquery_agent_analytics/span_taxonomy.py:270 Gold evidence leaks across unrelated sessions adversarial-claude; independently validated 75
  • #1 - Reject all fourth span-level names. The guard checks the eight-name failure_taxonomy.FROZEN_CATEGORY_NAMES tuple, not the three mechanically emittable names required for this layer. As a result, wrong source, execution/computation, incomplete evidence, turn-waste, and unknown are accepted. The existing test at tests/test_span_taxonomy.py:257 rejects only agent starvation, which is outside the broader vocabulary and does not prove the frozen three-name contract. Validate against exactly task/planning, finalization, and tool blockers, and test rejection with an in-vocabulary fourth name such as wrong source.

  • #2 - Keep absence labels on the real end boundary. The shared silence text at line 302 says that no subsequent row exists even when line 204 selected the first ERROR span and later native rows are present. Finalization and task/planning are then anchored to that mid-stream ERROR and carry false evidence at confidence 1.0. Keep tool blockers on the real ERROR span, but anchor finalization and end-of-trace planning evidence to the last real span. Add an ERROR-followed-by-later-rows regression.

  • #3 - Check called before claiming no tool ever started. When gold_events is empty, or when the failed and gold sessions called the same tools, missing_tools is empty and line 318 emits no tool was ever started without consulting the already-computed called set. A TOOL_STARTING-then-silence trace therefore contradicts its own label. Emit that sentence only when called is empty; otherwise describe the actual gap. Add a regression for a failed session that called a tool before silence.

  • #4 - Use the #429 full-conversation coordinate. The helper counts USER_MESSAGE_RECEIVED rows and returns a zero-based user-message ordinal. The #429 path indexes the full reconstructed conversation, including agent responses; for an interleaved user/agent/user trace, the second user is coordinate 2 while this code returns 1. This is a parallel turn model and cannot reliably join sub_trajectories.start_turn/end_turn. Pass or derive the existing #429 mapping. If that cannot be done faithfully in this slice, omit turn_index rather than publishing a falsely compatible value. Add an interleaved conversation test.

  • #5 - Match gold evidence per failed scenario. label_native_run appends every completed session into one gold_pool and gives that union to every failed session. In a normal multi-scenario run, a widget-stock failure can therefore claim that unrelated refund or translation tools were missing and were called by the completed sibling. Build gold evidence from an unambiguous same-scenario sibling, using the existing prompt as the available match key, and omit missing-tool claims when no match exists. Add a multi-scenario run test.

Actionable Findings

# File Route Required response
1 src/bigquery_agent_analytics/span_taxonomy.py:115 gated_auto -> downstream-resolver Restrict the constructor to the frozen mechanical three and harden the rejection test
2 src/bigquery_agent_analytics/span_taxonomy.py:302 gated_auto -> downstream-resolver Use category-specific targets and test a mid-stream ERROR
3 src/bigquery_agent_analytics/span_taxonomy.py:318 gated_auto -> downstream-resolver Branch on called and test TOOL_STARTING followed by silence
4 src/bigquery_agent_analytics/span_taxonomy.py:383 manual -> downstream-resolver Consume the actual #429 coordinate or omit the incompatible field
5 src/bigquery_agent_analytics/span_taxonomy.py:270 manual -> downstream-resolver Scope gold evidence to an unambiguous same-scenario sibling

What can wait

  • Direct-call robustness for unparseable timestamps and mismatched verdict/session inputs can be handled separately.
  • Selection among several raw ERROR spans can wait until production evidence establishes recovered-error behavior.
  • Private-helper coupling, naming, and other P2-level cleanup are not blockers for this review.

Coverage

  • Stack and scope verified: HEAD is 35e40f2; f5c6109 is its ancestor; the only unique commit is 35e40f2; the unique files are CHANGELOG.md, span_taxonomy.py, and test_span_taxonomy.py.
  • Prohibited commits 2169889 (#465) and 7f5a954 (#462) are absent from HEAD. There are no conflict markers.
  • No P0 trigger was found: no live BigQuery or --synth execution path was added, no production agent_events write was added, evalbench-import stays intact, the clock remains off, and NativeAgentEventsRun, failure_taxonomy.py, and classify_sessions were not rewritten.
  • Required positive fixtures are present for the widget-stock AGENT_STARTING silence punchline, real span IDs, collision-safe eval_id, tuple shape, frozen-name rejection attempt, and unchanged session G1. Findings #1 and #4 explain why two of those tests prove weaker contracts than required.
  • Offline verification: 71 focused tests passed across test_span_taxonomy.py, test_failure_taxonomy.py, and test_native_events_writer.py. Pyink and isort checks passed. No live BigQuery test ran.
  • Independent review: correctness, testing, maintainability, and an independent Claude adversarial pass. The Claude receipt reports claude-opus-5, requested effort high, actual effort unverified, and independence_verified=true. Findings #1-#4 had cross-model corroboration; finding #5 passed a separate fresh validator.
  • No reviewer failures, malformed findings, pre-existing blockers, or final confidence suppressions. All three preliminary fast-pass items survived and were merged into #1, #2, and #4.
  • No separate implementation plan was selected; issue #466 and the user-provided frozen contracts were the explicit requirements source.

Verdict

REQUEST_CHANGES

Five P1 defects must be fixed before approval. Fix #1 and #4 first to restore the frozen taxonomy and turn-coordinate contracts, then fix #2, #3, and #5 so every confidence=1.0 evidence string remains true for real multi-event, multi-session native runs.

Actionable Findings Summary

  • #1 - P1 - src/bigquery_agent_analytics/span_taxonomy.py:115 - restrict span labels to the three allowed names - gated_auto - suggested fix present - confidence 100
  • #2 - P1 - src/bigquery_agent_analytics/span_taxonomy.py:302 - prevent false silence evidence after a mid-stream ERROR - gated_auto - suggested fix present - confidence 100
  • #3 - P1 - src/bigquery_agent_analytics/span_taxonomy.py:318 - do not report started tools as never started - gated_auto - suggested fix present - confidence 100
  • #4 - P1 - src/bigquery_agent_analytics/span_taxonomy.py:383 - reuse the #429 full-conversation coordinate - manual - suggested fix present - confidence 100
  • #5 - P1 - src/bigquery_agent_analytics/span_taxonomy.py:270 - isolate gold evidence by scenario - manual - suggested fix present - confidence 75
caohy1988 added a commit to caohy1988/BQAA-SDK-fork that referenced this pull request Aug 31, 2026
…oogleCloudPlatform#467)

Restrict span labels to the frozen three names, keep silence evidence true
for mid-stream ERROR and started tools, omit a false GoogleCloudPlatform#429 turn_index, and
scope gold missing-tool evidence to the same-scenario sibling.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: Kimi

Re-review: PR #467 — Span-level G1 taxonomy on span_id (#466)

  • Verdict: LGTM / APPROVE
  • P0 count: 0
  • P1 count: 0
  • HEAD SHA reviewed: a7fd389 (a7fd389, "fix(evalbench): tighten span G1 names, evidence, and gold matching (#467)")
  • Range reviewed: git diff f5c6109..HEAD / git log f5c6109..HEAD (stacked on PR #464 HEAD f5c6109; the prior Kimi LGTM on 35e40f2 does not carry over — this is a fresh review of the new HEAD).
  • Diff shape: 3 files, +1007/−0 vs f5c6109: src/bigquery_agent_analytics/span_taxonomy.py (new, 432 lines), tests/test_span_taxonomy.py (new, 546 lines), CHANGELOG.md (+29). Purely additive localization layer; no rewrites of NativeAgentEventsRun, failure_taxonomy.py, or classify_sessions.
  • Tests: python -m pytest tests/test_span_taxonomy.py -q → 19 passed.

Stacking / scope hygiene (P0 screen — all clear)

  • git log f5c6109..HEAD shows exactly the two expected commits: 35e40f2 then a7fd389. No #465 demo commit (2169889) and no #462 commit (7f5a954) is an ancestor of HEAD (verified via git merge-base --is-ancestor). Branch feat/466-span-g1-taxonomy is properly stacked on f5c6109.
  • No conflict markers, no live BigQuery client / --synth, no network, no LLM judge anywhere in the new module (grep-verified). Module docstring (span_taxonomy.py:59-64) and CHANGELOG both state the six-week clock has not started; nothing seals preregistration.
  • Adapter #97 (evalbench-import) untouched; native agent_events remains the source of truth. No production agent_events writes, no Acme/fake-D4/SANA fork, no synthetic span ids (span_taxonomy.py:243-248 fails closed with ValueError when a target row lacks a real span_id).
  • Session-level failed_sessions + G1 remains the denominator: label_native_run (span_taxonomy.py:296-302) reads verdicts from the unchanged classify_sessions and only localizes categories the verdict already tripped (label_failed_session_spans, span_taxonomy.py:203-205 returns () when no category tripped).
  • Widget-stock 7e352c34 punchline preserved in the acceptance fixtures/tests (10 references in the test file) and in the CHANGELOG.

The five prior Codex P1s on 35e40f2 — all resolved in a7fd389

P1-1 — SpanFailureLabel must accept ONLY the three mechanically emittable names. RESOLVED.
SPAN_CATEGORY_NAMES (span_taxonomy.py:97-101) is derived from FLAG_TO_CATEGORY.values() (the three flags' frozen names: task/planning, finalization, tool blockers — confirmed against failure_taxonomy.py:90-94), and SpanFailureLabel.__post_init__ (span_taxonomy.py:134-141) now rejects everything else, including in-vocabulary frozen names. Regression coverage: tests/test_span_taxonomy.py test_a_fourth_category_string_is_rejected_at_construction now constructs dataclasses.replace(label, failure_category="wrong source") — an in-vocabulary fourth name — and asserts rejection, and test_span_labels_are_restricted_to_the_three_emittable_names pins the exact 3-tuple.

P1-2 — Mid-stream ERROR must not yield false end-of-trace evidence. RESOLVED.
Target selection is now per category (span_taxonomy.py:233-240): only tool blockers anchors to the first raw status == "ERROR" row with target_kind="span"; finalization and task/planning always anchor to the last existing span, the only span for which "no subsequent row exists" is true. The ERROR-anchored evidence (span_taxonomy.py:353-357) states only logged status ERROR — no silence claim. Regression: test_mid_stream_error_keeps_silence_evidence_on_the_last_span builds an ERROR-followed-by-a-later-LLM_RESPONSE trace and asserts the blocker carries no "goes silent" text while finalization anchors to the last span id and excludes the ERROR span id.

P1-3 — "no tool was ever started" only when no tool was started. RESOLVED.
_category_evidence (span_taxonomy.py:358-377) now branches: missing_tools from the same-scenario sibling → "never called"; else if the session did start tools (called non-empty) → "though <tools> was started earlier in the session"; only the empty-called case emits "no tool was ever started". Regression: test_a_started_tool_is_not_reported_as_never_started runs the TOOL_STARTING-then-silence shape both with and without gold and asserts the denial is absent and the actual started tool is named.

P1-4 — turn_index omitted rather than a false ordinal. RESOLVED.
The field, the _turn_index helper, and the _PROMPT_EVENT import are all removed; the docstring contract (span_taxonomy.py:50-58, 119-121) explains why: the #429 coordinate indexes the full reconstructed conversation and has no importable package mapping, so publishing a user-message ordinal under the same name would fork it. Regression: test_no_turn_index_is_published keeps the interleaved two-user-message conversation (exactly where the ordinals would diverge) and asserts "turn_index" is absent from both dataclasses.fields and the instance.

P1-5 — Gold evidence from a same-scenario sibling only. RESOLVED.
label_native_run (span_taxonomy.py:303-327) replaces the run-wide gold_pool with gold_by_prompt: a failed session's gold is the one completed sibling that asked the same prompt; ambiguous prompts (multiple completed siblings) are marked None and supply no gold; no match supplies no gold. Regressions: test_gold_evidence_is_scoped_to_the_same_prompt_sibling (multi-scenario run — the refund-policy sibling's lookup_policy must not leak into the widget-stock session's evidence) and test_missing_tool_claims_are_omitted_without_a_same_prompt_sibling (no same-prompt sibling → no "never called" claim at all).

Findings at this HEAD

None at P0/P1 severity.

What can wait (non-blocking, P2-tier — not blockers)

  • label_failed_session_spans with a raw-dict verdict relies on _verdict_field(verdict, "session_id") only as a fallback when rows lack session_id; a dict verdict without session_id and rows with session_id still labels fine, but the error paths assume one or the other is present. Documented well enough; no change needed now.
  • SPAN_CATEGORY_NAMES is computed dynamically from FLAG_TO_CATEGORY.values(). If a fourth mechanical flag is ever added upstream, this set silently widens. The pinning test (test_span_labels_are_restricted_to_the_three_emittable_names) would catch it in CI, so this is acceptable as-is.
  • The ambiguous-prompt case (two completed siblings, same prompt) silently drops gold evidence rather than surfacing the ambiguity to the caller. Conservative and safe; a future observability note could log/count it.
  • _prompt_text matching is exact-string; near-identical prompts across scenarios won't match. Conservative direction (under-matching gold is safe); fine for the mechanical layer.

Bottom line

All five prior Codex P1s are fixed at the root with targeted regression tests, the frozen contracts from #466 hold (denominator, frozen 3-name taxonomy, real span ids only, identity collision fallback, widget-stock punchline, offline, clock off), and the diff stays strictly inside the localization layer. LGTM / APPROVE at a7fd389. Skip-if-exists note: this approval is per-SHA and applies only to a7fd3899c3726a8de257783a2f1dcd50d96299e3; any new HEAD requires a fresh review.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: Codex

Code Review Results

PR: 467 — span-level G1 taxonomy on span_id for #466
Verdict: LGTM / APPROVE
P0 count: 0
P1 count: 0
HEAD SHA: a7fd389
Scope: f5c6109..a7fd389 (unique commits 35e40f2, a7fd389; three files)
Mode: report-only; no GitHub or worktree mutation

No P0 or P1 findings remain on this HEAD. The fix commit closes all five prior Codex P1s from 35e40f2, and the complete PR diff remains within the requested localization layer.

Findings and prior-P1 resolution

  1. Resolved — frozen span names: src/bigquery_agent_analytics/span_taxonomy.py:97 defines the mechanically emittable set as exactly task/planning, finalization, and tool blockers; src/bigquery_agent_analytics/span_taxonomy.py:133 rejects every other value. tests/test_span_taxonomy.py:256 now proves rejection with the in-vocabulary fourth name wrong source, as well as an out-of-vocabulary string.

  2. Resolved — mid-stream ERROR anchoring: src/bigquery_agent_analytics/span_taxonomy.py:223 finds the real ERROR row, while the category-specific selection at src/bigquery_agent_analytics/span_taxonomy.py:233 keeps tool blockers on that row and anchors finalization / end-of-trace task/planning evidence to the last real span. The ERROR-followed-by-later-rows regression at tests/test_span_taxonomy.py:328 verifies that no false end-of-trace claim is attached to the earlier ERROR span.

  3. Resolved — started-tool evidence: src/bigquery_agent_analytics/span_taxonomy.py:358 computes called, and the branches at src/bigquery_agent_analytics/span_taxonomy.py:360 emit “no tool was ever started” only when that set is empty. tests/test_span_taxonomy.py:381 covers TOOL_STARTING followed by silence and requires the evidence to describe the tool that started earlier.

  4. Resolved — #429 coordinate fork: SpanFailureLabel omits turn_index at src/bigquery_agent_analytics/span_taxonomy.py:124; no user-message-only ordinal is published. The interleaved user/agent conversation regression at tests/test_span_taxonomy.py:421 verifies the field is absent.

  5. Resolved — scenario-scoped gold evidence: src/bigquery_agent_analytics/span_taxonomy.py:305 builds completed-sibling evidence by exact prompt key and passes it only to the matching failed session at src/bigquery_agent_analytics/span_taxonomy.py:318; absent or ambiguous matches yield no gold tool claims. The multi-scenario and no-match regressions are at tests/test_span_taxonomy.py:462 and tests/test_span_taxonomy.py:504.

Frozen-contract check

  • Session-level classify_sessions plus G1 remains the denominator; span code only localizes categories (src/bigquery_agent_analytics/span_taxonomy.py:203, src/bigquery_agent_analytics/span_taxonomy.py:300).
  • Every emitted label uses a real input span_id and fails closed rather than inventing one (src/bigquery_agent_analytics/span_taxonomy.py:241).
  • Collision-safe identity still comes from _native_scenario_ids and is applied to labels (src/bigquery_agent_analytics/span_taxonomy.py:295, src/bigquery_agent_analytics/span_taxonomy.py:324).
  • as_tuple() preserves (trace_id, span_id, failure_category, evidence, confidence) (src/bigquery_agent_analytics/span_taxonomy.py:153).
  • The widget-stock 7e352c34 silence path still localizes all three labels to its real AGENT_STARTING span (tests/test_span_taxonomy.py:132).
  • CHANGELOG.md:42 retains the stacked native-writer / PR 464 entry, including the evalbench-import adapter guarantee; the new span-localization entry is additive.

Stack, scope, and safety

  • f5c6109 is an ancestor of HEAD; only 35e40f2 and a7fd389 are unique versus PR 464.
  • Prohibited commits 2169889 (#465) and 7f5a954 (#462) are not ancestors of HEAD.
  • The diff changes only CHANGELOG.md, src/bigquery_agent_analytics/span_taxonomy.py, and tests/test_span_taxonomy.py; it does not rewrite NativeAgentEventsRun, failure_taxonomy.py, or classify_sessions.
  • No conflict markers or git diff --check errors were found. No live BigQuery / --synth path ran, no production agent_events writer was added, the adapter remains present, and the six-week clock stays off.

Verification

  • Focused offline gate: 76 passed across test_span_taxonomy.py, test_native_events_writer.py, and test_failure_taxonomy.py.
  • Full offline suite: 4570 passed, 56 skipped.
  • Pyink and isort checks passed for both changed Python files.
  • Worktree remained unchanged apart from the pre-existing ignored/untracked .venv.

What can wait

  • A real turn_index can be added later when #429 exposes an importable full-conversation mapping; omission is correct for this slice.
  • Richer scenario identity than the existing prompt match key, selection policy for multiple raw ERROR spans, and private-helper/API cleanup can wait. None is a P0/P1 blocker for #466.

Verdict

LGTM / APPROVE. P0 count: 0. P1 count: 0.

…rm#466)

Localization layer over the native agent_events path (GoogleCloudPlatform#435 Phase 2):
span_taxonomy.label_failed_session_spans / label_native_run attach the
G1-frozen categories a failed session already tripped to the span where
the failure is observable, emitting (trace_id, span_id, failure_category,
evidence, confidence) rows. Session-level failed_sessions + G1 stays the
denominator; eval_id keeps the frozen first-8-on-collision identity; no
synthetic span ids (silence targets the last real span as
gap_after_span, rows without span_id fail closed); GoogleCloudPlatform#429 turn coordinate
reused; taxonomy stays frozen at v0.1.0. Offline fixture tests only;
clock still OFF.
…oogleCloudPlatform#467)

Restrict span labels to the frozen three names, keep silence evidence true
for mid-stream ERROR and started tools, omit a false GoogleCloudPlatform#429 turn_index, and
scope gold missing-tool evidence to the same-scenario sibling.
@caohy1988
caohy1988 force-pushed the feat/466-span-g1-taxonomy branch from a7fd389 to 0d37fcd Compare August 31, 2026 17:58
@haiyuan-eng-google
haiyuan-eng-google merged commit 3222207 into GoogleCloudPlatform:main Aug 31, 2026
15 checks passed

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: Kimi

Re-review: PR #467 — Span-level G1 taxonomy on span_id (#466)

Round: 467-rebase-after-464

  • PR: #467
  • HEAD reviewed: 0d37fcd14cf83aee85fdde8c7ba790106d10a378 (fix(evalbench): tighten span G1 names, evidence, and gold matching (#467))
  • Base: merged #464 squash 04dcadb739c366e1681f95014a44083867414d3c (verified: git merge-base upstream/main HEAD == upstream/main == 04dcadb). The earlier stacked-on-unmerged-464 base is gone; prior Kimi reviews of 35e40f2 / a7fd389 were not carried over — this is a fresh review of the rebased HEAD.
  • Unique commits vs main: 44d0499 (feat, formerly 35e40f2), 0d37fcd (P1 fix, formerly a7fd389) — exactly the expected pair.

Verdict: LGTM / APPROVE

  • P0 count: 0
  • P1 count: 0

Base / scope verification (P0 gates — all clear)

  • Diff slice is exactly the expected three files (git diff --stat upstream/main..HEAD, 1007 insertions, 0 deletions):
    • src/bigquery_agent_analytics/span_taxonomy.py (+432, new)
    • tests/test_span_taxonomy.py (+546, new)
    • CHANGELOG.md (+29, one new bullet block under Unreleased → Added)
      No 458–464 spillover files, no extra surface — the rebase onto the merged #464 squash is clean.
  • No forbidden PR content: git log upstream/main..HEAD contains only 44d0499 and 0d37fcd; no sign of #465 (2169889), #468 (0778125), #462 (7f5a954), #456, #457, or #470.
  • No conflict markers in any touched file.
  • Localization layer only: no changes to native_events.py, failure_taxonomy.py, evalbench.py / classify_sessions, or any production write path. The evalbench-import adapter (#97) is untouched and remains; native agent_events stays the source of truth for this layer's inputs.
  • No live BQ / no --synth / no clock start: span_taxonomy.py is pure and deterministic — imports only from evalbench / failure_taxonomy / native_events, no BigQuery client, no network, no LLM judge, no writes. The only "clock"/"synth" strings are docstring statements that the clock stays off and that no synthetic span ids are minted (span_taxonomy.py:39-45, :61, :289). CHANGELOG bullet restates "the six-week clock has still NOT started".
  • No synthetic span ids: SpanFailureLabel.__post_init__ rejects empty/non-str span ids (span_taxonomy.py:147-151), and label_failed_session_spans fails closed with ValueError when the target row has no real span_id (span_taxonomy.py:243-248). Covered by tests/test_span_taxonomy.py:233-250.
  • Session-level denominator intact: label_native_run computes verdicts via the unchanged classify_sessions(run.to_agent_event_rows(), score_rows, policy) (span_taxonomy.py:300-302); categories come from the unchanged failure_taxonomy.categorize_failed_session (span_taxonomy.py:203). test_session_level_g1_is_unchanged_by_span_labels (tests/test_span_taxonomy.py:112-129) pins the three-flag verdict, taxonomy version 0.1.0, and the frozen-order category tuple.
  • Identity rule honored: eval_id comes from native_events._native_scenario_ids (frozen first-8-with-full-id-on-collision) in label_native_run (span_taxonomy.py:295, :324), and label_failed_session_spans requires an eval_id or verdict scenario_id, failing closed otherwise (span_taxonomy.py:211-216). Collision fallback pinned by test_first8_collision_falls_back_to_the_full_session_id (tests/test_span_taxonomy.py:211-227).
  • Widget-stock punchline present: session 7e352c34 localizes all three tripped categories onto its real AGENT_STARTING span with target_kind="gap_after_span" and evidence that no TOOL_STARTING / check_inventory / AGENT_COMPLETED followed (tests/test_span_taxonomy.py:132-197).

The five prior Codex P1s — all still fixed after rebase

  1. Taxonomy restriction (fourth name rejected). SPAN_CATEGORY_NAMES is derived as FROZEN_CATEGORY_NAMES ∩ FLAG_TO_CATEGORY.values() = exactly ("task/planning", "finalization", "tool blockers") in frozen order (span_taxonomy.py:97-101; verified against failure_taxonomy.py:71-94). SpanFailureLabel.__post_init__ raises ValueError for anything else (span_taxonomy.py:134-141). test_a_fourth_category_string_is_rejected_at_construction rejects the in-vocabulary fourth name "wrong source" (and the out-of-vocabulary "agent starvation") via dataclasses.replace (tests/test_span_taxonomy.py:256-266), and test_span_labels_are_restricted_to_the_three_emittable_names pins the tuple (:269-274). ✅
  2. Mid-stream ERROR is not false end-of-trace evidence. Only tool blockers may anchor to the ERROR row (target_kind="span", span_taxonomy.py:235-236); finalization / task/planning always anchor to the last existing span with gap_after_span (:238-240). The ERROR-anchored evidence states only "logged status ERROR" — no silence claim (:353-357). Regression test test_mid_stream_error_keeps_silence_evidence_on_the_last_span uses an ERROR row followed by a later LLM_RESPONSE row and asserts the blocker stays on the ERROR span (no "goes silent") while finalization anchors to the last span (tests/test_span_taxonomy.py:328-378). ✅
  3. "No tool was ever started" only when nothing was started. _category_evidence branches: missing-tools-from-sibling → "was never called"; else if the session did start tools → "though X was started earlier in the session"; only the empty-called case says "no tool was ever started" (span_taxonomy.py:358-373). Regression test_a_started_tool_is_not_reported_as_never_started (TOOL_STARTING then silence, with and without gold) asserts the denial never appears (tests/test_span_taxonomy.py:381-418). ✅
  4. No forked #429 turn coordinate. SpanFailureLabel has no turn_index field and the module docstring explains why a lookalike ordinal would fork the coordinate (span_taxonomy.py:50-58, :119-121). test_no_turn_index_is_published uses the interleaved user/agent conversation — exactly where an ordinal would diverge — and asserts no turn_index field or attribute exists (tests/test_span_taxonomy.py:421-456). ✅
  5. Gold evidence scoped to same-scenario sibling only. label_native_run keys gold by prompt (the only same-scenario key the rows carry); ambiguous prompts (multiple completed siblings) are marked None and supply no gold, and missing-tool claims are omitted rather than pooled (span_taxonomy.py:303-313, :318-326). Multi-scenario regression test_gold_evidence_is_scoped_to_the_same_prompt_sibling proves lookup_policy from an unrelated completed scenario never leaks into the widget-stock evidence, and test_missing_tool_claims_are_omitted_without_a_same_prompt_sibling proves the no-sibling case emits no "never called" claim (tests/test_span_taxonomy.py:462-532). ✅

Test execution (offline, no worktree writes)

PYTHONDONTWRITEBYTECODE=1 python -m pytest tests/test_span_taxonomy.py \
  tests/test_failure_taxonomy.py tests/test_native_events_writer.py \
  tests/test_week0_real_freeze.py -p no:cacheprovider -q
→ 99 passed

All 22 new span-taxonomy tests plus the adjacent taxonomy/native-events/freeze suites pass at HEAD 0d37fcd.

What can wait (non-blocking, P2)

  • label_native_run reaches into protected members of NativeAgentEventsRun (_kept_and_skipped, _score_facts_with_prompts, with explicit pylint disables at span_taxonomy.py:292, :298). Same-package and tested, but a small public accessor on the run would remove the protected access if a third consumer ever appears.
  • The gold-sibling key is the raw prompt text; two semantically identical but textually different prompts will not share gold evidence. That is the documented, conservative choice (omit rather than borrow) — fine for the mechanical layer.
  • confidence is a constant MECHANICAL_CONFIDENCE = 1.0; the docstring already reserves sub-1.0 values for the labeler/judge study, so nothing to do now.

None of these block merge.

Bottom line: the rebase onto merged #464 (04dcadb) is correct, the diff is exactly the expected three-file slice, all five prior Codex P1s remain fixed with regression tests intact, every P0 gate passes, and the frozen contracts of #466 (session denominator, three-name freeze, no synthetic span ids, first-8 identity, widget-stock punchline, offline/clock-off) are all honored. Approve.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: Codex

Verdict: REQUEST_CHANGES

P0 count: 0

P1 count: 1

HEAD SHA: 0d37fcd

Findings

  1. [P1] The required terminal TOOL_STARTING regression is still open. src/bigquery_agent_analytics/span_taxonomy.py:365 unconditionally says a non-empty called set means the tool "was started earlier in the session." When the source trace ends on the TOOL_STARTING row itself, that row is also the gap anchor selected at span_taxonomy.py:240, so the emitted evidence is: no TOOL_STARTING event follows TOOL_STARTING ... though check_inventory was started earlier in the session. The tool was started on the anchor, not earlier, and the text does not describe the actual post-start gap. This is a reachable native case because an incomplete source session gets the landed process-failure marker for the denominator. The new test at tests/test_span_taxonomy.py:381 does not cover the requested TOOL_STARTING-then-silence trace: it adds a TOOL_COMPLETED row at tests/test_span_taxonomy.py:395, making that later row the anchor. Add the exact terminal-TOOL_STARTING regression and make its evidence say that the tool started on the anchor but no subsequent completion/event followed.

Prior P1 status

  • Closed: SpanFailureLabel accepts only task/planning, finalization, and tool blockers; the regression rejects in-vocabulary wrong source.
  • Closed: a real mid-stream ERROR owns only the tool blockers label, while finalization/end-of-trace evidence anchors to the last real row; an ERROR-followed-by-later-rows regression is present.
  • Still open: non-empty called no longer produces "no tool was ever started," but the exact TOOL_STARTING-then-silence path still emits inaccurate evidence and lacks the required regression, as described above.
  • Closed: turn_index is omitted, with an interleaved-conversation regression.
  • Closed: gold tool evidence is keyed to a unique completed same-prompt sibling, and missing-tool claims are omitted when no prompt match exists; both multi-scenario regressions are present.

Rebase and scope audit

  • merge-base(upstream/main, HEAD) is 04dcadb739c366e1681f95014a44083867414d3c; 44d0499 is directly parented by that merged #464 squash, followed only by 0d37fcd.
  • upstream/main..HEAD contains exactly the two expected commits and exactly the three expected files: CHANGELOG.md, src/bigquery_agent_analytics/span_taxonomy.py, and tests/test_span_taxonomy.py.
  • The forbidden known commits 2169889 (#465), 0778125 (#468), 7f5a954 (#462), and stacked-unmerged f5c6109 are not ancestors of HEAD; no #456, #457, or #470 commit appears in the two-commit unique log.
  • There are no changes to NativeAgentEventsRun, failure_taxonomy.py, classify_sessions, the CLI, or the evalbench-import adapter. The merged #463/#464 changelog content is preserved relative to upstream/main.
  • No conflict markers, synthetic span identifiers, live BigQuery execution, production agent_events writes, Week 1/clock action, or forbidden partner/taxonomy changes were introduced.

Verification

  • 105 passed across tests/test_span_taxonomy.py, tests/test_native_events_writer.py, tests/test_failure_taxonomy.py, and tests/test_evalbench_import_sessions.py, offline with pytest cache and bytecode writes disabled.
  • git diff --check, Pyink check, and isort check all pass.
  • A direct terminal-TOOL_STARTING probe reproduces the inaccurate "started earlier" evidence above.

What can wait

P2/nit-level cleanup can wait; none is required for this review. The single P1 evidence/regression defect is the only merge blocker found.

caohy1988 added a commit to caohy1988/BQAA-SDK-fork that referenced this pull request Aug 31, 2026
…gleCloudPlatform#469)

Publish the landed GoogleCloudPlatform#466/GoogleCloudPlatform#467 span-level localization as BQAA-owned
snapshot rows on the native path, so the widget-stock AGENT_STARTING
silence is queryable as data, not only a library return.

- NativeAgentEventsRun.materialize gains an opt-in span_labels_table:
  span rows are derived by reusing label_native_run (frozen fallback
  EvalScorePolicy({"goal_completion": 1.0}), never an empty policy per
  the GoogleCloudPlatform#468 P1 finding) BEFORE any write, so a failed session without a
  real span_id fails the whole publish closed - no synthetic span ids.
- Rows carry the RFC tuple (trace_id, span_id, failure_category,
  evidence, confidence), target_kind, the frozen first-8 eval_id join
  identity, taxonomy_version 0.1.0, and the (job_id, import_version)
  pin; sync is keyed delete-then-load per pin (derived state, same
  convergence rule as the failed-sessions view).
- Session-level failed_sessions + G1 stays the denominator, unchanged.
- Thin CLI extension: evalbench-native-import --span-labels-table.
- Offline fixture tests only; the EvalBench adapter (GoogleCloudPlatform#97) stays; clock
  stays off; production agent_events is never written.
caohy1988 added a commit that referenced this pull request Sep 4, 2026
… (#470)

* feat(evalbench): persist span-level G1 labels on native snapshot (#469)

Publish the landed #466/#467 span-level localization as BQAA-owned
snapshot rows on the native path, so the widget-stock AGENT_STARTING
silence is queryable as data, not only a library return.

- NativeAgentEventsRun.materialize gains an opt-in span_labels_table:
  span rows are derived by reusing label_native_run (frozen fallback
  EvalScorePolicy({"goal_completion": 1.0}), never an empty policy per
  the #468 P1 finding) BEFORE any write, so a failed session without a
  real span_id fails the whole publish closed - no synthetic span ids.
- Rows carry the RFC tuple (trace_id, span_id, failure_category,
  evidence, confidence), target_kind, the frozen first-8 eval_id join
  identity, taxonomy_version 0.1.0, and the (job_id, import_version)
  pin; sync is keyed delete-then-load per pin (derived state, same
  convergence rule as the failed-sessions view).
- Session-level failed_sessions + G1 stays the denominator, unchanged.
- Thin CLI extension: evalbench-native-import --span-labels-table.
- Offline fixture tests only; the EvalBench adapter (#97) stays; clock
  stays off; production agent_events is never written.

* fix(evalbench): align span-label policy, atomic publish, pin join (#469)

Address the Codex/Kimi P1 findings on the span-label publication:

- One frozen policy for span rows AND the session denominator:
  resolve_span_label_policy resolves the CLI default (None) to the
  frozen EvalScorePolicy({"goal_completion": 1.0}), merges any other
  policy (the truthy-but-empty EvalScorePolicy({}) included) with that
  gate, rejects a conflicting goal_completion threshold, and passes the
  SAME resolved policy to label_native_run and super().materialize, so
  the manifest view_policy / failed_sessions view and the published span
  rows can never disagree about the gate.
- Atomic, serialized span replacement: rows are staged into an expiring
  staging table, then one multi-statement transaction claims the
  dataset's import lock, re-checks the manifest generation the rows were
  derived from, and replaces the keyed slice. A load failure or a
  cancelled concurrent sync preserves the previously published rows
  (no more zero-row or duplicated slices); staging is cleaned in
  finally and expires regardless.
- Pin-aware join boundary: a companion <span_labels_table>_pinned view
  (byte-verified ownership, ETag-conditional replace) is kept pinned to
  the job's latest publication - the same manifest row failed_sessions
  pins - so eval_id joins no longer fan out across retained versions;
  CLI help and docstring teach the job_id + import_version + eval_id
  join. EvalBenchImportResult reports span_labels_view.
- CHANGELOG: Keep-a-Changelog bullet for #469 above the #466 entry.

Offline fixture tests only; clock stays off; production agent_events is
never written; the evalbench-import adapter (#97) stays.

* fix(evalbench): bind span labels to policy and manifest generation (#469)

Address the three Codex r2 P1 findings on the span-label publication by
making the opt-in a durable, generation-checked binding:

- Durable policy binding (P1 #1): a new fixed-name per-dataset registry
  (evalbench_span_bindings, one row per job) records the span table, the
  ONE resolved score policy, and the synchronized manifest generation.
  Every later native materialize of a bound job — span_labels_table
  passed or not — re-resolves the same frozen-gate policy (a conflicting
  goal_completion threshold is rejected) and re-derives and re-syncs the
  span rows, so an ordinary same-pin call can no longer rewrite the
  committed view_policy to NULL while the span rows stay behind. The
  span sync now also checks the expected canonical view_policy plus the
  exact generation, both in its pre-read and inside the lock-serialized
  transaction, so a delayed writer cannot adopt a newer generation
  committed under a different gate.

- Fail-closed base/span generation skew (P1 #2): span rows are stamped
  with the exact manifest generation_id they were synchronized under,
  the binding upsert rides the same transaction as the row replace, and
  the pinned view is rendered with a latest-generation guard: it exposes
  rows only while its pinned generation is still the job's latest
  manifest generation. A changed-source same-version replace whose span
  sync fails therefore yields an EMPTY active view instead of exposing
  the previous generation's rows as if they belonged to the new base
  snapshot; re-running materialize heals it.

- Lockstep join boundary (P1 #3): a later unlabelled import or same-pin
  replace of a bound job maintains the span snapshot (rows, binding, and
  view advance together with failed_sessions), and a bound corpus that
  cannot be span-labelled (no real span_id) fails the whole publish
  closed BEFORE the base snapshot or the denominator advances. View
  synchronization now targets only the generation whose span rows were
  just published and stands down when that generation is not the job's
  latest, so re-syncing an older retained version can no longer repin
  the view to a newer generation that has no synchronized span rows.

Regressions cover: span-enabled default then ordinary same-pin call
(gate and rows retained), gate re-committed between derive and sync,
failed span sync after a changed-source replace (active view empty,
heal on re-run), labelled v1 then unlabelled v2, labelled then
unlabelled same-pin replace, unlabelable bound corpus failing before
publish, bound-job span-table switch refusal, and older-version resync
not repinning the view. Offline fixture tests only; the six-week clock
stays off.

* fix(evalbench): make span binding authoritative under import lock (#469)

Apply the stored binding policy on no-policy bound calls (never re-resolve
to the fallback-only gate; explicit policies stay deliberate changes),
reject failed_sessions_view=None whenever span publication is active
(explicit or registry-restored, CLI flags included) before anything is
written, enforce one span table per job inside the span sync transaction
so racing first opt-ins cannot both bind, and re-validate the binding
state inside the base publish transaction and the unchanged-path policy
recommit via a registry guard predicate so a stale pre-read can neither
commit a snapshot nor rewrite view_policy around a binding that landed
meanwhile (the registry table is created idempotently by every native
publish so the guard always has an authority to read).

* fix(evalbench): close span binding SQL escape and lock races (#469)

Codex r4 on PR #470 (P0 x1, P1 x2):

- P0: remove the public raw-SQL binding_guard hook from
  EvalBenchRun.materialize. The native writer now passes private
  structured state (_SpanBindingState): the registry reference is
  re-validated segment by segment before it is rendered as an
  identifier, the expected table/policy travel only as query
  parameters, and the guard SQL is always one of two fixed predicates.
  Any non-structured span_binding argument is rejected with TypeError
  before anything runs; offline regressions prove no public argument
  can introduce an executable statement boundary.
- P1: run the unchanged-path policy recommit as its own multi-statement
  transaction that claims the dataset import lock before evaluating the
  binding guard and the expected-generation UPDATE
  (_RECORD_VIEW_POLICY_SCRIPT). A standalone manifest UPDATE and the
  span-binding transaction mutate disjoint tables, so two mutually
  stale snapshots could both commit under snapshot isolation; sharing
  the lock sentinel makes BigQuery cancel one. Deterministic offline
  overlap regression covers the mutually stale snapshots.
- P1: reject, inside the span sync transaction and before any row or
  binding DML, a requested span table already bound to another job
  (_SPAN_TABLE_OWNED_MESSAGE). The losing concurrent job stays unbound
  and can retry with its own table instead of bricking on the shared
  table's single-owner pinned view; paused-load regression included.

Offline gate: 232 passed (span labels, CLI native import, importer,
native writer, span taxonomy); full offline suite 4625 passed.

* fix(evalbench): require exact _SpanBindingState class at materialize (#469)

Codex r5 P0: the public materialize(span_binding=...) gate used
isinstance, so a _SpanBindingState subclass overriding predicate()/
parameters() could smuggle caller-shaped SQL past the two fixed guard
predicates. The admission is now an exact-class check
(type(span_binding) is _SpanBindingState); non-state arguments still
fail with TypeError before any BigQuery call.

Adds an offline regression that passes such an overriding subclass and
proves TypeError with zero client calls.

* fix(evalbench): authenticate pinned span view against committed refs (#469)

A copied, self-consistent span view at the managed name could pass
ownership: _read_managed_span_view re-rendered the expected body from the
view's OWN claimed span_labels_table / manifest_table / generation, so a
byte-canonical copy verified against nothing but itself, and the sync
would overwrite it as managed.

The read now authenticates the pin against trusted state before the view
is accepted (mirroring evalbench._read_managed_view): the pin's span and
manifest references must be exactly the refs this call derived (never the
view's claim), and the claimed generation must be one the pinned
(job_id, import_version) manifest row committed — its current
generation_id or one recorded in its superseded_generations history. The
authentication read is labeled _VIEW_FEATURE like the sync's own
latest-manifest read. Regression covers same-job canonical copies over
foreign refs, an uncommitted generation, and an unpublished version:
refused fail-fast, foreign body left byte-identical, nothing published.

* fix(evalbench): revalidate pre-read span binding under sync lock (#469)

A delayed resync of a retained older version passes the span sync's
manifest guard (its own manifest row still carries the policy and
generation it derived under) and the same-table binding guard, yet its
unconditional binding upsert could replace a binding a newer
richer-policy sync committed meanwhile with the old values — and the
next no-policy call would then recommit the newer manifest back to the
stale gate, moving the failed-session denominator (Codex r9 P1).

The span sync transaction now revalidates, before any span-row or
binding DML, the exact binding state this call pre-read: a pre-read row
must still be committed byte-for-byte (table, policy, import version,
generation), and a pre-read of 'no binding' requires the job to still be
unbound. The observed values travel as their own query parameters,
separate from the policy/generation being installed, so a deliberate
explicit policy change still replaces exactly the state it observed.

Regression: pause a v1 maintenance call after its base publish, land a
richer-policy v2 publish + sync, resume v1 — v1 fails closed, the v2
binding keeps the richer gate, and a later no-policy v2 call retains it.
caohy1988 added a commit that referenced this pull request Sep 5, 2026
…luators

Version bump 0.5.1 -> 0.5.2 and the changelog cut for everything merged
since v0.5.1 (2026-08-29), 19 commits.

In the wheel: the versioned EvalBench import pipeline (#451-#453: immutable
snapshots with the W0.4 failed-session contract, the version-pinned
failed_sessions view, evalbench-score), the native agent_events snapshot
writer (#464), the failure taxonomy frozen at G1 v0.1.0 and its span-level
localisation layer with persisted span labels (#467, #470), the evaluator
API unification behind PerformanceEvaluator with compatibility aliases
(#123), and the canonical metric factories plus opt-in policy scorecard
(#91). Repo side: skill-evolution host hooks and auditable patch provenance
(#395, #477), the scheduled skill-evolution Cloud Run Job (#472), the OKF
adapter example (#474), the AgentForensics Week 0 freeze and sealed
preregistration (#435, #473), and the EvalBench demo and CLI-discoverability
follow-ups.

Entries the Unreleased section lacked are added in this cut: #91, #123 (its
bullets move under Changed with the PR number), #395, #472, #474, #476.
haiyuan-eng-google pushed a commit that referenced this pull request Sep 5, 2026
…478)

* chore(release): 0.5.2 — EvalBench snapshots, G1 taxonomy, unified evaluators

Version bump 0.5.1 -> 0.5.2 and the changelog cut for everything merged
since v0.5.1 (2026-08-29), 19 commits.

In the wheel: the versioned EvalBench import pipeline (#451-#453: immutable
snapshots with the W0.4 failed-session contract, the version-pinned
failed_sessions view, evalbench-score), the native agent_events snapshot
writer (#464), the failure taxonomy frozen at G1 v0.1.0 and its span-level
localisation layer with persisted span labels (#467, #470), the evaluator
API unification behind PerformanceEvaluator with compatibility aliases
(#123), and the canonical metric factories plus opt-in policy scorecard
(#91). Repo side: skill-evolution host hooks and auditable patch provenance
(#395, #477), the scheduled skill-evolution Cloud Run Job (#472), the OKF
adapter example (#474), the AgentForensics Week 0 freeze and sealed
preregistration (#435, #473), and the EvalBench demo and CLI-discoverability
follow-ups.

Entries the Unreleased section lacked are added in this cut: #91, #123 (its
bullets move under Changed with the PR number), #395, #472, #474, #476.

* chore(release): file the skill-evolution bullets as repo-side

scripts/skill_evolution.py is not in the wheel (which ships only
src/bigquery_agent_analytics and src/bigquery_ontology), so the #395 and
#397 entries move from Added to their own repo-side section, matching the
Deploy section this cut already uses for #472.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants