Repository navigation
feat(evalbench): native agent_events snapshot writer (#463) - #464
haiyuan-eng-google merged 8 commits into
Conversation
…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.
…n rows (GoogleCloudPlatform#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.
…AgentForensics idea (GoogleCloudPlatform#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.
…v0.1 (GoogleCloudPlatform#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.
…1 freeze (GoogleCloudPlatform#435/GoogleCloudPlatform#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 GoogleCloudPlatform#461 and now emits the frozen names (task/planning, finalization, tool blockers). The pack stays illustrative; fixtures and script output are unchanged.
…er exit ramp) (GoogleCloudPlatform#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 (GoogleCloudPlatform#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.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
Include: verdict (LGTM/APPROVE or REQUEST_CHANGES), P0 count, P1 count, P2 count (informational), HEAD SHA e438c0e, findings with file:line, what can wait.
Also print the full review body to stdout.
Do NOT run gh pr review yourself. Do not push. Do not post to GitHub.
warning: Skill descriptions were shortened to fit the skills context budget. Codex can still see every skill, but some descriptions are shorter. Disable unused skills or plugins to leave more room for the rest.
codex
I’m using the structured code-review skill because this is a diff-scoped PR review. I’ll inspect only 2c4804b..e438c0e, verify the specified P0/P1 invariants with offline checks, and write plus print the requested review—without touching GitHub or any branch state.
exec
/bin/zsh -lc 'cat /Users/haiyuancao/.codex/plugins/cache/compound-engineering-plugin/compound-engineering/3.23.4/skills/ce-code-review/SKILL.md' in /Users/haiyuancao/BigQuery-Agent-Analytics-SDK/.worktrees/issue-435-native-writer
succeeded in 1ms:
name: ce-code-review
description: "Structured code review for bugs, regressions, tests, and standards. Use before PRs or when asked to review code. Use when the user asks to apply this review's findings locally. Not for resolving feedback already left on a PR; that is ce-resolve-pr-feedback."
argument-hint: "[mode:agent] [apply:local] [blank to review current branch, or provide PR link]"
Code Review
Artifact Root
Resolve the CE artifact root <root> before composing any artifact path.
- Read
docs_rootfrom<repo-root>/.compound-engineering/config.yamlonly (<repo-root>=git rev-parse --show-toplevel). Do not read it fromconfig.local.yaml. Unset -><root>isdocs, exactly as before. - Validate a set value: a repo-relative directory whose real, symlink-resolved path stays inside the repo and is neither the repo root nor under
.git/. Otherwise stop with an error namingdocs_rootand the value -- never fall back todocs. - Use
<root>as the sole artifact location: create it if absent, compose each path as<root>/<subdir>with this skill's own subdirectory, and never also readdocs.
Execution spine
Follow these steps in order; the references supply the detail but never change the order. Each reference named below is a required read for its step: load it before doing that step's work.
- Read
references/modes-and-output.mdfirst. It settles what the arguments mean, which argument conflicts stop the run before any reviewer is dispatched, whether the quick-review short-circuit applies, and what this invocation returns. - Stage 1. Read
references/scope.mdand resolve the reviewed diff, the scope mode, and the deterministic scope signals. - Stage 2. Read
references/intent-and-plan.md, write the intent summary every reviewer receives, and discover the plan Stage 6 verifies requirements against. - Stage 3. Read
references/persona-catalog.mdandreferences/select-and-route.md, then select the risk-driven reviewer roster, discover applicable standards paths, and bind the adversarial route. - Stage 3d. When adversarial is selected for a local reviewed tree, start and persist the sanctioned cross-model job that
references/cross-model-review.mddefines, before any local persona dispatch. Invoking this skill is itself the authorization for its configured or allowlisted peer route, once you have made the required disclosure of the recipient and of the code that leaves the machine. Do not ask the user to confirm a second time, and do not skip the peer because the user did not repeat that authorization. An explicit user prohibition on external review overrides it, as does a checkout that setscross_model_review_mode: offwith no live opt-in; both are resolved before you bind a route. This pass's skip and target-selection keys arecross_model_review_modeandcross_model_peer. Missing files or unset keys take the default auto route; they are not a skip. Another skill's engine preference is not this gate. Model and effort overrides stay with the bound target as the reference states. A started peer replaces the local adversarial persona at this stage, and only a real failure to scope, allowlist, reach, authenticate, or start it leaves the local fallback in the roster; a later stage may still restore the local reviewer under the conditions that reference states. - Stage 4. Read
references/dispatch-reviewers.md. Dispatch the materialized local roster as one foreground concurrent batch sized to the host's active-agent cap. Every successful launch is collected when its terminal outcome is in hand: consume valid compact returns, classify a terminal tool error or malformed output as a failed reviewer, and keep launch receipts uncollected. Use the host's blocking collection capability for asynchronous receipts, and do not synthesize until every successful launch is collected. If launched work cannot be collected reliably, stop it, discharge any persisted peer through its owning cleanup before returning the failure result, and never emit progress or wait for a notification. Detaching local review into a polled background job is forbidden. The cross-model peer is the only detached work, and it may overlap this batch. - Stages 5 and 6. Once the reviewer returns are ready, read
references/finish-review.md. Fold in the peer once, run the documented findings mechanics, and run every validator the reference selects; only then return the report. Never synthesize directly from raw reviewer artifacts. In the multi-agent path, emit only this skill's report: do not also invoke a harness-native findings or reporting tool, which belongs to the quick-review short-circuit alone.
Operating principles
- Report-only by default; never push. A bare
ce-code-reviewinvocation produces findings and does not apply them. Entering the apply stage requiresapply:local, or an explicit user request in the invoking prompt to apply or fix this review's findings; a deprecatedmode:autofixtoken is neither.mode:agentnever mutates the tree, even when nested inside a workflow that later applies findings. Never push, open PRs, or file tickets in any mode. - No blocking prompts. Never use
AskUserQuestion,request_user_input,ask_user, or other blocking question tools. Infer intent, plan, and scope from explicit tokens, git state, PR metadata, and conversation. Note uncertainty in Coverage or the verdict — do not stop to ask. - Explicit mutations only. Never run
gh pr checkout,git checkout,git switch, or similar branch-switch commands. Passing a PR number, URL, or branch name selects review scope, not permission to mutate the working tree. Uncommitted work can only be reviewed from the checkout that holds it, so to review it on a feature branch, stay on that branch (or check it out yourself) and passbase:or no target. - Report outcomes, not machinery. What you show the user is about the review: what is being examined, which coverage is included and the one-line reason for each conditional lens, the independent cross-model pass, and the findings. Name what the user would recognize — a PR number, a reviewer's concern, a peer model — rather than this skill's plumbing, whose internal labels, dispatch bookkeeping, and setup narration stay out of user-facing text. Never claim more about the peer than its receipt attests. This governs what you surface and suppress, not the wording; use your own voice.
Task Visibility
For the multi-agent path, once the review scope is resolved, use the platform's task-tracking capability when available to show a short user-facing view derived from the execution spine. Track review outcomes, not individual personas, setup mechanics, or tool calls; add conditional work only when its gate fires, and update the view at meaningful transitions. If no task-tracking capability is available, continue with the normal progress and final report without simulating a task list in chat.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Kimi
Review: PR #464 — Native agent_events snapshot writer (EvalBench-adapter exit ramp)
- Verdict: LGTM / APPROVE
- HEAD reviewed:
e438c0e84709bc8ac0a76c65353b774f250584fe(unique commit; range2c4804b..e438c0e, stacked on #461 freeze HEAD2c4804b) - P0 count: 0
- P1 count: 0
- P2 count (informational): 3
- Scope note: Diff reviewed is
git diff 2c4804b..HEADonly — 6 files, +1368/-0, fully additive. GitHub's 455–461 file display is stacking, not a defect. #462 (post-freeze e2e) is correctly absent.
Verification performed
git log 2c4804b..HEAD— exactly one commit,e438c0e.- Full diff read:
src/bigquery_agent_analytics/native_events.py(new, 549 lines),cli.py(+155, additive),tests/test_native_events_writer.py(new, 467),tests/test_cli_evalbench_native_import.py(new, 167),CHANGELOG.md(+21, additive),docs/agentforensics_mvp_plan.md(+9, additive). - Offline tests run:
pytest tests/test_native_events_writer.py tests/test_cli_evalbench_native_import.py— 19 passed; regressionpytest tests/test_evalbench_importer.py tests/test_cli_evalbench_import.py— 144 passed. No live BigQuery touched (all fake clients / in-memory fixtures). - Conflict-marker scan on all touched files: clean.
g1_frozen: Truestill set infailure_taxonomy.py:145. No 456/457/462-branch files modified.
P0 checklist — all clear
- Production
agent_eventsnever written. The native read path is SELECT-only (native_events.py:204from_bigquerybuilds a singleSELECT ... FROM {source_table}withFOR SYSTEM_TIME AS OF/ session filter; testtest_from_bigquery_reads_only_the_agent_events_tablepins this). The reserved-name guard_validate_destination_tablerejectsagent_eventsbefore any BigQuery call in the inheritedmaterialize(evalbench.py:984-987, guard atevalbench.py:3108-3120), and the CLI pre-validates all three destination names before even reading the source (cli.py:2547-2550). Teststest_reserved_agent_events_destination_is_rejected,test_nothing_is_written_into_an_agent_events_table, andtest_publish_never_touches_the_source_datasetcover the guard from three angles. evalbench-importintact. The #97 on-ramp command is untouched (cli.py:2430region unchanged; the diff only appendsevalbench-native-importatcli.py:2433). Nothing deleted anywhere in the range.- Clock not started. No Week 1 / preregistration / six-week-clock code.
test_native_publication_does_not_start_the_clockasserts the result payload contains no "clock" and the frozen rubric still hasclock_started: false. - No live BQ requirement.
from_agent_eventsis pure/in-memory;from_bigqueryis opt-in and injectable (bq_client=). CLI has no--synthdefault that would hit production. All tests run against_FakeWriteClient/_FakeReadClient. - Taxonomy v0.1.0 names.
test_widget_stock_session_fails_with_all_three_g1_namesasserts session7e352c34yields exactly("task/planning", "finalization", "tool blockers")in frozen order againstfailure_taxonomy.TAXONOMY_VERSION == "0.1.0". Freeze flag untouched. - No conflict markers; no cross-branch files; taxonomy not unfrozen.
P1 checklist — all clear
- Inheritance, not rewrite.
NativeAgentEventsRun(EvalBenchRun)(native_events.py:125) inheritsmaterializeverbatim — pin identity, lock, publish transaction, manifest withview_policy, view sync all come fromevalbench.py:874and are polymorphic overself.fingerprints()/self.to_agent_event_rows()/self.to_score_rows()(evalbench.py:1003,1024,1026). Only inputs are overridden (native_events.py:280,325,355) plus the replaced readerfrom_bigquery(native_events.py:204). - No EvalBench source tables, fail-closed. Constructor
__post_init__(native_events.py:148-158) raises ifresults/scores/config_rowsare passed;test_native_run_refuses_evalbench_source_rowspins it. The read query provably contains no.configs/.results/.scoresreference. - Deterministic session-derived scores.
goal_completionis 1.0 iffAGENT_COMPLETED(native_events.py:325-352, facts at_score_facts_with_prompts), explicitly completed, not passed. Never-completed sessions publish their first prompt row asstatus=ERRORwith the original status preserved inattributes.bqaa_native_source_status(native_events.py:315-321), which the acceptance test shows drivesprocess_failed=Truethrough the realfailed_sessionsview path. - Identity.
_native_scenario_ids(native_events.py:461-476) is first-8 with full-id fallback on prefix collision; published event and score rows keep the real ADKsession_id(test_events_scores_and_manifest_all_carry_the_pin,test_identity_is_first_8_with_collision_fallback_to_full_id). - Required tests all present: widget-stock three G1 names; pin identity on events/scores/manifest; view pinned to latest successful publication (
test_view_is_pinned_to_the_latest_successful_native_publication, v1→v2 advance); no-agent_events-writes guard; clock-not-started; evalbench-import still present (144 importer/CLI tests green). - CHANGELOG kept all 455/460/461 bullets (diff is +21/-0) and adds the #463 entry with the clock-still-off statement.
plan.mdadds a nine-line note describing the native writer as an exit ramp; it does not reopen parked partner/D4/clock work. - CLI
evalbench-native-import(cli.py:2433) mirrorsevalbench-importoptions, defaults destinations toevalbench_agent_events/evalbench_scores_imported, and does not mutate the existing command. Reserved-destination and bad---snapshot-atrejections exit 2 before any client call (CLI tests confirmcalls == []).
P2 (informational, non-blocking — can wait)
native_events.py:305-312—marker_indexfalls back to0when no prompt event exists, but_kept_and_skippedguarantees every kept session has a prompt, so the fallback is unreachable. Harmless dead branch; could be an assertion for documentation value.native_events.py:483-496—_prompt_textgives up on the firstUSER_MESSAGE_RECEIVEDwhose content mapping lackstext/text_summarykeys instead of scanning later prompt events in the same session. Only affects the informationalsource_row.promptfield, never the score or the failure marker.native_events.py:125-145— the inherited field namesevalbench_dataset/ manifestresults_count=0, configs_count=0are EvalBench-shaped labels carrying native-source meaning. Documented in the class docstring, and renaming would forfeit the frozen manifest contract; noted only so future readers aren't surprised.
What can wait
- All three P2s above.
- Any live-BQ smoke of
from_bigquery/ the CLI against the realtest-project-0728-467323table — correctly out of scope here; belongs with post-freeze e2e (#462 lineage), not this PR.
Recommendation: APPROVE. The exit ramp lands the frozen contract with zero EvalBench tables in the path, zero writes to production agent_events, the clock still off, and the adapter on-ramp intact. 19 new + 144 existing tests pass offline.
|
Scratch review 5062853153 — that was a premature Codex stdout dump (skill text), not a review of e438c0e. Real Codex/Kimi COMMENTED reviews of this HEAD are still running and will post when they finish. Ignore that dump. |
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
Code Review Results
PR: 464
Verdict: REQUEST_CHANGES
HEAD SHA: e438c0e (e438c0e84709bc8ac0a76c65353b774f250584fe)
Counts: P0: 0 | P1: 2 | P2: 1 (informational)
Scope: Only git diff 2c4804b..e438c0e and git log 2c4804b..e438c0e; one commit, six files. The stacked GitHub diff and #462 are excluded as directed.
Intent: Add an offline-testable native agent_events snapshot writer that reuses EvalBenchRun.materialize, preserves the optional evalbench-import path, retains real ADK session IDs, and leaves the Week 1 clock off.
Mode: markdown report-only. No fixes, pushes, GitHub writes, live BigQuery calls, or branch mutations.
Reviewers: correctness, testing, maintainability, API contract, reliability, and an independent Claude adversarial pass. Testing covered the new offline fixtures and CLI. API-contract review covered version pins and published identities. Reliability covered fail-fast and inherited publication behavior.
P1 -- High
| # | File | Issue | Reviewer | Confidence |
|---|---|---|---|---|
| 1 | src/bigquery_agent_analytics/native_events.py:117 |
Native source boundary accepts prohibited tables | correctness, adversarial-claude | 100 |
| 2 | src/bigquery_agent_analytics/native_events.py:443 |
Native versions lose consumer snapshot isolation | api-contract | 75 |
-
#1 - Fail closed on the source table before any query.
_parse_source_tablechecks only identifier syntax, sop.d.configs,p.d.results, andp.d.scoresreach the SELECT atnative_events.py:255-261. This directly violates the no-EvalBench-source-table contract. The same gap also allows a non-reserved source such asp.d.evalbench_agent_eventsto resolve to the inherited default destination and feed retained rows back into itself (evalbench.py:981,1009-1011). Require the source basename to beagent_events. If alternate production event-table names are intentional, explicitly reject the three EvalBench basenames and compare every fully qualified destination withsource_table. Add fake-client tests that assert zero queries and zero writes. -
#2 - Add
import_versionto inherited trace/evaluation selectors. Native event rows correctly preserve the real ADKsession_id, but retained v1 and v2 rows therefore share bothsession_idand the job-scopedexperiment_id.EvalBenchSession.trace_selector()uses only those fields (evalbench.py:2207), andEvalBenchImportSessions.trace_filter()also omits the top-level version pin (evalbench.py:2446-2450). A caller that selects v2 can replay or score rows from v1 and v2 together. Keep the real session ID, add animport_versionpredicate to the trace/filter query paths, and add a two-publication isolation test.
P2 -- Moderate (informational)
| # | File | Issue | Reviewer | Confidence |
|---|---|---|---|---|
| 3 | src/bigquery_agent_analytics/native_events.py:103 |
Whole-table native reads are unbounded when no session filter is supplied | adversarial-claude | 75 |
Actionable Findings
| # | File | Issue | Route | Notes |
|---|---|---|---|---|
| 1 | src/bigquery_agent_analytics/native_events.py:117 |
Constrain native sources and reject source/destination overlap | gated_auto -> downstream-resolver |
Suggested fix present; add zero-query/zero-write tests |
| 2 | src/bigquery_agent_analytics/native_events.py:443 |
Preserve snapshot isolation in trace and evaluation consumers | manual -> downstream-resolver |
Suggested fix present; requires a shared filter-contract change and a two-version test |
What Can Wait
- #3 is not a merge blocker for this offline, pre-clock PR. Before any production-scale rollout, require a session or time-window bound, or make whole-table import an explicit opt-in with a row-count guard. The current query otherwise loads the complete source into memory at
native_events.py:260-262. - Other adversarial suggestions about grace periods and G1 flag correlation were not counted. They conflict with the frozen rule that a snapshot session scores
1.0iff it containsAGENT_COMPLETED, and that a never-completed snapshot session receives the ERROR prompt marker.
Coverage
- P0 checks passed: the reserved
agent_eventsdestination guard remains;evalbench-importand its adapter tests remain; no Week 1 or clock-start action was added; G1 stays frozen at v0.1.0 withtask/planning,finalization,tool blockersin frozen order; no conflict markers or #456/#457/#462 files are in scope. - The constructor rejects non-empty inherited
results,scores, andconfig_rows. The native class inheritsEvalBenchRun.materializeunchanged. - Widget-stock G1 output, event/score/manifest pins, latest-successful view pinning, real session IDs, collision fallback, no-source-write guards, clock-off state, and the old
evalbench-importCLI are covered by offline tests. - Independent validation accepted the source-boundary, self-feeding, and cross-version-isolation defects. These became two findings after semantic deduplication. It rejected one proposed P1 about in-flight sessions because that proposal contradicted the frozen completion contract.
- Cross-model pass: route
claude; requested/served modelclaude-opus-5; requested efforthigh; actual effort unverified; receipt supported; independence verified. - Verification: focused suite
29 passed; full intended-environment suite4430 passed, 72 skipped;git diff --checkpassed; Pyink and isort checks passed. No live BigQuery was used. - Two anchor-50 peer observations were suppressed. No reviewer failed. The only worktree item outside the reviewed diff was the pre-existing untracked
.venvsymlink.
Verdict
REQUEST_CHANGES
P0: 0 | P1: 2 | P2: 1 informational. Fix #1 and #2 before approval. The required source-table boundary is not fail-closed, and retained native versions are not isolated in inherited trace/evaluation consumers. #3 can wait until production rollout planning. The six-week clock remains off.
Actionable Findings (recap)
- #1 - P1 -
src/bigquery_agent_analytics/native_events.py:117- gated auto: restrict the native source boundary and prove prohibited tables cause zero reads/writes. - #2 - P1 -
src/bigquery_agent_analytics/native_events.py:443- manual: add version-aware trace/evaluation filtering while retaining the real ADK session ID, then prove v1/v2 isolation.
Run artifacts: /tmp/compound-engineering-501/ce-code-review/20260830-201749-9ba2c7ca
… on traces (GoogleCloudPlatform#464) Reject non-agent_events native sources (including EvalBench configs/results/scores) before any query, and isolate retained native versions in trace/filter consumers.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
Verdict: APPROVE (LGTM)
P0 count: 0
P1 count: 0
HEAD SHA: f5c6109
Findings
No P0 or P1 findings remain on this HEAD.
- The first prior P1 is closed.
src/bigquery_agent_analytics/native_events.py:128validates the fully qualified source before client creation;src/bigquery_agent_analytics/native_events.py:139explicitly rejectsconfigs,results, andscores; andsrc/bigquery_agent_analytics/native_events.py:145admits only the exactagent_eventsbasename.src/bigquery_agent_analytics/native_events.py:200also rejects any source/destination identity before delegating to publication. The fake-client regressions attests/test_native_events_writer.py:403,tests/test_native_events_writer.py:425, andtests/test_native_events_writer.py:441assert zero queries and writes on these failures. - The second prior P1 is closed.
src/bigquery_agent_analytics/evalbench.py:2197addsimport_versionto each failed session's trace selector, whilesrc/bigquery_agent_analytics/evalbench.py:2439pins it in the import'sTraceFilter.src/bigquery_agent_analytics/trace.py:860emits the candidate predicate andsrc/bigquery_agent_analytics/trace.py:1008reapplies it to fetched rows.src/bigquery_agent_analytics/client.py:976exposes the pin onget_session_trace, and the selector-discovery and scoped/mixed fetch paths carry it through, including the authoritative scoped fetch atsrc/bigquery_agent_analytics/client.py:1825. Native publication still preserves the real source session ID atsrc/bigquery_agent_analytics/native_events.py:522. The retained-v1/v2 regressions attests/test_native_events_writer.py:603andtests/test_native_events_writer.py:655prove v2 selector and filter reads do not widen into v1. - The P0 guardrails remain intact. The inherited reserved-destination check at
src/bigquery_agent_analytics/evalbench.py:3124prevents writes to productionagent_events; the existing adapter command remains registered atsrc/bigquery_agent_analytics/cli.py:2285; the native command is additive atsrc/bigquery_agent_analytics/cli.py:2433; the frozen taxonomy order includestask/planning,finalization, andtool blockersatsrc/bigquery_agent_analytics/failure_taxonomy.py:71; andsrc/bigquery_agent_analytics/native_events.py:55keeps the six-week clock and Week 1 off. The full delta has no conflict markers. - The reviewed stack is exactly
e438c0efollowed byf5c6109; the expected stacked history is not treated as a P0, and #462 is not part of this two-commit delta.
Verification
- Targeted offline regression suite: 729 passed.
- Full offline suite: 4,435 passed, 72 skipped. Live BigQuery tests stayed skipped; no live BigQuery access was used.
git diff --check 2c4804b..HEADpassed.- The worktree was not modified; the pre-existing untracked
.venvremained the only status entry.
What can wait
P2 documentation polish or additional non-blocking edge-case coverage can wait. Nothing found at P0/P1 severity blocks merge.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Kimi
Re-review: PR #464 @ f5c6109 — native agent_events snapshot writer (P1 fix round)
- Verdict: LGTM / APPROVE
- P0 count: 0
- P1 count: 0 (both prior P1s from the e438c0e review are closed; no new merge-blocking defects found)
- HEAD SHA reviewed: f5c6109
- Fix delta reviewed:
git diff e438c0e..f5c6109; full native-writer delta:git diff 2c4804b..f5c6109 - Prior Kimi review on e438c0e does not count for this HEAD; this is a fresh per-SHA review.
- Stacking note: GitHub's PR-vs-main view shows the #455–#461 ancestor chain; that is expected stacking on this branch, not a P0. The delta does not include #462.
Prior P1s — resolution check
Prior P1-1: _parse_source_table fail-open (CLOSED)
Confirmed fixed:
src/bigquery_agent_analytics/native_events.py:122-125—_SOURCE_TABLE_BASENAME = "agent_events"and_EVALBENCH_SOURCE_BASENAMES = frozenset({"configs", "results", "scores"}).src/bigquery_agent_analytics/native_events.py:139-150—_parse_source_tablerejects EvalBench basenames by name, then rejects any basename other thanagent_events, raising before any BigQuery client is created or any query is built. Both constructors (from_agent_events,from_bigquery) and__post_init__route through it.src/bigquery_agent_analytics/native_events.py:200-247—NativeAgentEventsRun.materializeoverride compares every fully-qualified destination (events, scores, manifest, lock, failed-sessions view) againstsource_tableand refuses source==destination before any BigQuery call — defense in depth over the inherited reserved-agent_events-destination check.- Fake-client tests prove zero queries / zero writes on every rejection path:
tests/test_native_events_writer.py:403-423(configs/results/scoresfail closed on both read and offline paths),:426-439(non-agent_eventsbasename e.g.evalbench_agent_eventsrefused at parse),:442-457(destination == source refused, all fake stores empty).
Prior P1-2: retained-version mixing on trace reads (CLOSED)
Confirmed fixed:
src/bigquery_agent_analytics/evalbench.py:2197-2217—EvalBenchSession.trace_selector()now returnsimport_versionalongside the realsession_idand job-scopedexperiment_id; docstring correctly states the pin is redundant on the adapter path but load-bearing on the native path.src/bigquery_agent_analytics/evalbench.py:2439-2468—EvalBenchImportSessions.trace_filter()pinsimport_versionon theTraceFilter.src/bigquery_agent_analytics/trace.py:468-479, 579, 606-610, 857-869, 1001-1009—TraceFilter.import_versionfield with two-state validation (_validated_import_version_pin, revalidated at the SQL boundary againstvars()bypass), added to bothto_sql_conditions()(import_version = @import_version) androw_scope_where()({alias}.import_version = @import_version) with an explicit no-shared-row-escape-hatch comment.src/bigquery_agent_analytics/client.py:987-1060, 1109-1113, 1300-1330, 1392-1410, 1453-1570, 1667-1690, 1797-1834—import_versionplumbed throughget_session_trace→get_trace_by_selector→_selector_pushdown_pins,_discover_session_identities,_fetch_mixed_scope_trace(metadata AND row fetch viaversion_where),_real_candidates_for_identities, and_fetch_resolved_trace(anchored row fetch appendse.import_version = @pin_import_version). Every discovery and fetch statement of a pinned lookup carries the predicate; non-string values raiseTypeError. Realsession_idis kept — native rows publish the real ADK id (native_events.py:522).- Isolation tests prove v2 cannot see v1:
tests/test_native_events_writer.py:516-688._publish_v1_and_v2retains both versions under one real session id;test_two_publications_v2_trace_selector_returns_no_v1_rowsruns the realClient.get_session_traceagainst_VersionPredicateFake, which returns BOTH versions' rows if the SQL omits the pin — so the assertion{span.span_id} == {"v2-span"}proves the pin is honored in emitted SQL, not merely forwarded.test_two_publications_v2_trace_filter_cannot_widen_to_v1showssession_idsalone match both retained versions and the version pin is what isolates v2.
P0 checklist — all clear
- Writes production
agent_events: No. Read-only source enforced at parse (native_events.py:145-150); reserved destination name rejected by inherited_validate_destination_table; destination==source rejected atnative_events.py:228-235; CLI validates destination names before any BQ call (cli.pynewevalbench-native-importcommand). - Deletes evalbench-import: No. Adapter stays as optional on-ramp (
native_events.py:22-23, CLI docstring, CHANGELOG). - Starts clock / Week 1: No. Explicitly documented as not starting (
native_events.py:55-56, CHANGELOG: "the six-week clock has still NOT started"). No cron/schedule/snapshot-job code anywhere in the delta. - Live BQ required: No.
from_agent_eventsis pure/offline; all new tests use fakes. Full offline suite: 4429 passed, 24 skipped, 0 failed. - Taxonomy G1 frozen names: Yes —
task/planning,finalization,tool blockersasserted via the unchangedclassify_sessions/failed_sessionsconsumers (tests/test_native_events_writer.py:178-180, 212-214). - Conflict markers: None in any changed file.
What can wait (non-blocking, P2)
- CHANGELOG entry (#463) still cites only the "reserved-name guard"; f5c6109 adds the parse-time basename guard and the destination==source guard — worth a one-line doc touch-up later, not a blocker.
TraceFilter.import_versionis documented as mirror-only and fails loudly on the production table (no such column) rather than silently widening — the intended fail-closed behavior, but the error surface is a raw BigQueryNOT FOUNDcolumn error; a friendlier message can wait._VersionPredicateFakeis intentionally minimal (honors only the predicates the reader actually emits). That is good test design for this contract; extending it is optional.- Parameter naming uses two distinct names (
@pin_import_versionin the selector pushdown path,@import_versioninTraceFilter); no collision today since the anchored fetch's filter never carries the pin. Fine as-is.
Verification performed
git diff e438c0e..f5c6109andgit diff 2c4804b..HEADread in full.pytest tests/test_native_events_writer.py tests/test_evalbench_importer.py— 155 passed.pytest tests/test_cli_evalbench_native_import.py tests/test_trace_filter_factory.py tests/test_trace_identity_u2.py tests/test_client_labels.py— 179 passed.- Full offline suite (live tests excluded) — 4429 passed, 24 skipped, 0 failed.
- Worktree unmodified; no pushes, no posts, no git mutations.
04dcadb
into
GoogleCloudPlatform:main
…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.
…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.
… import_version pin Review round (Fable P1): two UNCHANGED sentences in the passages PR GoogleCloudPlatform#508 edits contradicted the new import_version text. - trace_filter() refusal: dropped the stale consequence 'silently widen the evaluation to every retained version of the job'. The filter carries import_version (applied to both the candidate WHERE and the row scope, trace.py), so an empty session set would still stay inside the pinned version. The refusal itself (ValueError, nothing to score) is unchanged. - Drill-down opening paragraph: scoped the version-specific evalbench-import:{job_id}:{import_version}:{scenario_id} identity to rows converted from EvalBench source tables. Native agent_events imports (GoogleCloudPlatform#463) keep the real ADK session_id/trace_id (native_events.py _native_event_row), so the selector's import_version pin is what isolates one version there. Docs only; no code change.
…s (nightly docs drift) (#508) * audit: document the import_version pin in EvalBench drill-down helpers (nightly docs drift) docs/evalbench.md still described the pre-#464 return shapes of the two EvalBench drill-down helpers: - trace_selector() was documented as returning only session_id and experiment_id ("the session id already pins the import version"). EvalBenchSession.trace_selector() (src/bigquery_agent_analytics/ evalbench.py:2427-2431) also returns import_version. - EvalBenchImportSessions.trace_filter() was documented as returning TraceFilter(experiment_id, session_ids, limit) because "TraceFilter has no import-version dimension". TraceFilter has an import_version field (trace.py:578), and trace_filter() sets it (evalbench.py:2674-2679). Both paragraphs now list the import_version pin and, following the helpers' docstrings, say why it is redundant for imports converted from EvalBench source tables but load-bearing for native agent_events imports (#463), whose retained versions share the real ADK session ids. Docs only; no code change. * docs: fix two pre-#464 sentences contradicting the import_version pin Review round (Fable P1): two UNCHANGED sentences in the passages PR #508 edits contradicted the new import_version text. - trace_filter() refusal: dropped the stale consequence 'silently widen the evaluation to every retained version of the job'. The filter carries import_version (applied to both the candidate WHERE and the row scope, trace.py), so an empty session set would still stay inside the pinned version. The refusal itself (ValueError, nothing to score) is unchanged. - Drill-down opening paragraph: scoped the version-specific evalbench-import:{job_id}:{import_version}:{scenario_id} identity to rows converted from EvalBench source tables. Native agent_events imports (#463) keep the real ADK session_id/trace_id (native_events.py _native_event_row), so the selector's import_version pin is what isolates one version there. Docs only; no code change.
Implements #463 (parent: #435): a native
agent_eventssnapshot writer — the EvalBench-adapter exit ramp. Theevalbench-importadapter (#97) stays as an optional on-ramp; nothing is deleted.Stacking (do not merge; review only)
2c4804bso the frozen G1 taxonomy v0.1.0 (src/bigquery_agent_analytics/failure_taxonomy.py,g1_frozen: true) is importable. Base is merged docs(evalbench): recordable MVP e2e demo of import → failed-sessions → score (#435, #97) #455 plus the 461 freeze stack (458–461), so GitHub shows those commits vsmain— expected.e438c0eon top of2c4804b.What it does
bigquery_agent_analytics.native_events.NativeAgentEventsRun(plus thin CLIbq-agent-sdk evalbench-native-import) starts from production ADKagent_eventsrows and publishes the same BQAA-owned contractEvalBenchRun.materializealready produces — it subclassesEvalBenchRunand inheritsmaterializeverbatim (staging, lock, publish transaction, manifest, view sync), overriding only the inputs:(job_id, import_version)tuple on snapshot event rows, score rows, and the manifest row; thefailed_sessionsview body isfailed_sessions_sqlwith the pin rendered as literals for the latest successful native publication (newest committed manifest row;generation_id+view_policypin the body exactly as the adapter does). Job for this slice:mvp-e2e-real-traces.configs/results/scoresreads anywhere; the constructor fail-closes if EvalBench source rows are passed.evalbench-importremains untouched.eval_idis the first eight characters of the ADKsession_id(7e352c34from7e352c34-4c1c-4395-acd5-fb3c8f215346), falling back to the full id on collision; published rows keep the real ADKsession_id, so the same session is the same object with or without the adapter.goal_completionis1.0iff the session loggedAGENT_COMPLETED,0.0otherwise (completed, not passed). The gate is the existingEvalScorePolicy—goal_completion/min_score1.0 /missing_score_fails: trueper the frozen rubric (examples/fixtures/week0_real_rubric.json) — persisted as canonical JSON on the manifestview_policy. A never-completed session publishes the same ERROR-status prompt-row marker the adapter publishes forreturncode != 0, soprocess_failedholds.missing_completion→finalization,process_failed→tool blockers,score_failed→task/planning; names come back in frozen order. The widget-stock silence session7e352c34yieldstask/planning,finalization,tool blockers, and the deterministic punchline next-action names the missing answer and the never-calledcheck_inventory.agent_events: the source table is only read (SELECT-only), and the inherited reserved-name guard rejectsagent_eventsas a destination before any BigQuery call.Tests
Fixture-only, offline —
tests/test_native_events_writer.py+tests/test_cli_evalbench_native_import.py(19 new tests; 331 pass across the evalbench suites). No live BigQuery, no jobs, no IAM, no live/LLM judge, no--synth. Covered: the widget-stock acceptance (all three G1 names), pin identity on events/scores/manifest, view pinned to the latest successful native publication, the frozen policy pin, first-8 identity with collision fallback, no-EvalBench-tables and no-agent_events-writes guards, skipped promptless sessions, and clock-not-started.Boundaries
docs/agentforensics_mvp_plan.md; CHANGELOG bullet at the top of Unreleased → Added.