Repository navigation
feat(evalbench): persist span-level G1 labels on native snapshot (#469) - #470
Conversation
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Kimi
Review: PR #470 — persist span-level G1 labels on the native snapshot (#469)
- HEAD:
81fa2be8da447b2ac7f40b2c779a536dca4513ab(feat/469-span-labels-native) - Base: PR #467 @
a7fd389(stacked on #464 @f5c6109). Reviewedgit diff a7fd389..HEAD/git log a7fd389..HEAD. - Unique commit:
81fa2beonly. Touches exactly the five in-scope files:native_events.py,evalbench.py,cli.py,tests/test_native_span_labels.py,tests/test_cli_evalbench_native_import.py. No #468 (0778125), #465 (2169889), or #462 (7f5a954) commits. GitHub-vs-main showing 458–467 files is expected stacking. - Verification:
pytest tests/test_native_span_labels.py tests/test_cli_evalbench_native_import.py→ 23 passed; plustest_native_events_writer.py,test_span_taxonomy.py,test_evalbench_importer.py→ 180 passed total. All offline, fake BQ client. Untracked.venvignored.
Verdict: REQUEST_CHANGES
P0 count: 0
P1 count: 1
- P0: 0
- P1: 1
- P2: 2 (informational, non-blocking)
P0 checklist — all clear
- No live BQ / no
--synth: everything runs through the inherited fake-client path; span derivation (to_span_label_rows, native_events.py:355) is pure/offline;_publish_span_labels(native_events.py:397) only executes against the injected/real client insidematerialize. Tests are fixture-only. - No
evalbench-importadapter call, no EvalBench source reads: the adapter path is untouched;evalbench.pychange is purely additive (two defaulted fields onEvalBenchImportResult, evalbench.py:1328-1329), so #97 stays intact.native_events.pykeeps its "no EvalBenchconfigs/results/scores" docstring contract (line 22) and the new code reads only the run's own source rows vialabel_native_run. - Production
agent_eventsnever written: the reserved-name guard is extended tospan_labels_table(cli.py:2568-2569 via_validate_destination_table; native_events.py destination-vs-source check now includes the span table), plus a shadow guard against the import tables/view (native_events.py:278-290).test_span_sync_never_touches_source_or_production_agent_eventscovers this. - Clock / preregistration / Week 1: untouched;
test_span_label_publication_does_not_start_the_clockasserts it. - No synthetic span identifiers: fail-closed is inherited from the landed #467 localizer (
span_taxonomy.py:246raises on a row with nospan_id) and, critically, rows are derived before any write (native_events.py:292-296) —test_rows_without_a_real_span_id_fail_the_publish_closedproves zero queries/loads/creates on the refusal path. - Denominator unchanged: session-level
failed_sessions+ G1 stays the verdict; span rows only localize.test_session_level_g1_denominator_is_unchangedverifies the frozen three categories and the eval_id join. label_native_runreused, not reimplemented:to_span_label_rowsis a thin mapping overspan_taxonomy.label_native_run(native_events.py:379). No taxonomy strings invented — frozen names only,taxonomy_versionpinned toTAXONOMY_VERSION("0.1.0").- Frozen story pinned:
test_widget_stock_rows_anchor_the_real_agent_starting_spanasserts7e352c34/b7ad6b7169203331(_AGENT_STARTING_SPAN) /gap_after_span/ the three frozen categories, keyed by(mvp-e2e-real-traces, v1), G1 unchanged. - Identity:
eval_idcomes from_native_scenario_ids(native_events.py:733) — first-8 with full session id on collision;test_first8_collision_publishes_the_full_session_id_eval_idcovers the collision case. - No
turn_index, no conflict markers, no Acme/SANA content in the diff (grepped). - Thin CLI only: a single
--span-labels-tableoption on the existingevalbench-native-import(cli.py:2505), no new command family; CLI→materializeforwarding covered bytest_cli_evalbench_native_import.pyadditions.
P1 findings
- CHANGELOG has no #469 bullet.
CHANGELOG.mdis untouched by this PR (git diff a7fd389..HEADshows no CHANGELOG change). The Unreleased/Added section carries the #466 bullet (CHANGELOG.md:12, which also covers #467's fix) and the #463 bullet (CHANGELOG.md:42, covering #464's fix), but this PR ships a user-facing feature — a new--span-labels-tableflag and a new published BQAA-owned table — with no entry. Per the repo's Keep-a-Changelog convention (every prior slice added its bullet) and the review checklist, add a #469 bullet. One-paragraph mechanical fix; everything else is ready.
P2 findings (informational, not blockers)
- Explicit empty policy bypasses the frozen fallback.
native_events.py:379usespolicy or NATIVE_SPAN_LABEL_POLICY, butEvalScorePolicyis a truthy dataclass, so a caller explicitly passingEvalScorePolicy({})keeps the empty policy and silently dropstask/planning— contradicting the docstring's "never an empty policy" (native_events.py:370-372). The CLI can't hit this (_evalbench_score_policyreturnsNonewith no--min-score, cli.py:2278-2279), so the default and CLI paths are correct. Consider normalizing or rejecting an explicit empty policy into_span_label_rows. - Span-label sync is non-transactional with the manifest commit.
_publish_span_labelsruns after the inherited publish; a mid-sync failure leaves the pin committed without span rows. The docstring documents heal-on-next-call and the keyed delete-then-load is idempotent (test_replace_and_unchanged_resync_without_duplicating_rowsconfirms convergence), so this is acceptable as designed — just noting the documented trade-off.
What can wait
- The P2 items above (empty-policy hardening, transactional-sync consideration).
- The P1 is a single CHANGELOG paragraph; no code changes needed for it.
Summary
The implementation is disciplined: pure reuse of the landed #467 localizer, fail-closed derivation before any write, opt-in by default so the frozen #464 publish stays byte-identical, pin-keyed idempotent resync, and a genuinely thin CLI flag. Test coverage is strong (442-line acceptance suite hitting the frozen widget-stock story, collision identity, pin isolation, and the clock-off invariant). Once the #469 CHANGELOG bullet lands, this is an LGTM from me.
|
Reviewer: Codex PR 470 reviewVerdict: REQUEST_CHANGES P0 count: 0
The implementation is correctly stacked and keeps the native-only boundary, real span identity, frozen fixture, and adapter separation. Three P1 defects prevent approval because the published span rows can disagree with their denominator, duplicate under concurrent resync, and fan out across retained versions when joined as documented. Findings#1 P1 -- Span-label policy diverges from the frozen denominatorLocation: The span path applies The explicit-empty case also violates the frozen requirement.
Required response: Resolve one effective frozen policy when span publication is enabled. Reject incompatible caller policies, or deliberately merge them with the required Confidence: 100. Confirmed by correctness, testing, API-contract, maintainability, and an independent Claude adversarial review. #2 P1 -- Span-label replacement is neither atomic nor serializedLocation: The implementation deletes the final pin and then runs a separate append load after the inherited transaction has completed. A load failure leaves a successfully committed snapshot and pinned view with zero span rows. Two concurrent unchanged imports can both bypass the inherited publish transaction, interleave as A forced offline two-caller interleaving completed without errors and left six rows for the frozen three-label pin. BigQuery tables provide no uniqueness enforcement that would remove those duplicates. Required response: Load into an expiring staging table first. Then claim the existing import lock and replace the keyed span slice with one transaction, including a manifest-generation check. Preserve the old rows on failure and clean staging in Confidence: 100. Confirmed by correctness, reliability, API-contract, maintainability, the independent Claude pass, and a deterministic offline race reproduction. #3 P1 -- The documented eval_id join fans out across retained versionsLocation: The CLI says the retained span table is joinable to the pinned failed-session view via Required response: Make the active pin available at the join boundary. A pinned span-label view maintained beside Confidence: 75. Found by the independent Claude pass and independently validated by a fresh Codex validator. Scope and verification
What can waitPresenter/demo docs and scripts from #468, #465, and #462 remain out of scope. Live BigQuery validation, Week 1 work, clock activation, preregistration changes, and P2 polish must also wait. No P2 item is being used as a blocker in this review. Actionable findings
VerdictREQUEST_CHANGES. Fix #1 first so the session and span contracts agree, then #2 so publication converges safely, then #3 so consumers can join only the pinned version. Actionable recap
Review artifacts: |
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
PR 470 re-review
Verdict: REQUEST_CHANGES
HEAD: a0a71c3 (a0a71c3)
Reviewed range: a7fd389..a0a71c3, unique commits 81fa2be and a0a71c3
P0 count: 0
P1 count: 3
P2 count: 0 (informational)
All four exact findings from the stale 81fa2be review are closed on the new HEAD. The new implementation correctly aligns the policy within a span-enabled call, makes the keyed span-row replacement staged and transactional, exposes a pinned span view for version-safe joins, and restores the #469 changelog entry. However, three P1 lifecycle/generation gaps remain when later native imports interact with an already-published span snapshot.
Prior P1 status
| Prior finding | Status on a0a71c3 | Evidence |
|---|---|---|
| CLI-default and explicit-empty policy diverged between session G1 and span labels | Closed for the span-enabled call. A single effective frozen policy is passed to both label_native_run and the inherited materializer. | src/bigquery_agent_analytics/native_events.py:532-565; tests/test_native_span_labels.py:451-465 |
| Span replacement was delete-then-append, non-atomic, and racy | Closed for the keyed span slice. Rows load into staging, then lock claim, manifest validation, delete, and insert occur in one transaction; cleanup is in finally. | src/bigquery_agent_analytics/native_events.py:681-787 |
| Joining by eval_id fanned out across retained import versions | Closed when the selected version has synchronized span publication. The active view is pinned by job_id and import_version, and the two-version test returns only the current three rows. | src/bigquery_agent_analytics/native_events.py:809-855; tests/test_native_span_labels.py |
| CHANGELOG omitted #469 | Closed. The #469 entry is present above #466, with #467/#464/#463 retained. | CHANGELOG.md:8-29 |
P1 findings
1. The frozen span policy is neither durable nor generation-checked
Location: src/bigquery_agent_analytics/native_events.py:557 (also :565 and :742-757)
Policy resolution is conditional on span_labels_table being supplied for the current call. A first default-CLI span publication therefore resolves to the frozen goal_completion policy and publishes the expected task/planning labels. A later ordinary call for the same pin, with no span table and no minimum score, passes None to the inherited materializer; that rewrites the manifest/view policy to NULL while the previously published span rows remain. The session denominator can then lose its score gate without the span snapshot changing.
There is also an overlapping-writer variant: span rows are derived before _publish_span_labels rereads the manifest, and the transactional check validates event/results fingerprints but not the canonical view_policy or an exact generation identifier. A delayed writer can consequently accept a newer manifest generation and publish rows derived under a different policy.
Observed offline reproduction: after a span-enabled default call followed by the ordinary same-pin call, stored_manifest_policy was None and the failed-session view no longer contained the goal-completion gate, while the three retained span categories remained.
Required response: persist the resolved span policy/binding as part of the published snapshot, enforce it on later native calls for that binding, and pass/check the expected canonical view_policy plus an exact manifest generation during span synchronization.
Confidence: 100
2. A changed-source replace can expose new base data with stale same-pin span labels
Location: src/bigquery_agent_analytics/native_events.py:594-611 (schema/view context at :148-160 and :234-236)
The inherited materializer commits the new events, scores, manifest, and failed-session view before span staging and synchronization begin. If a changed-source replace=True reuses the same explicit import_version and the later span operation fails, the new base generation stays committed while the previous span rows are deliberately preserved by the span transaction rollback. Because the span rows and active view are keyed only by job_id plus import_version, those old rows remain visible as though they belong to the new generation.
The staged transaction fixes partial replacement of the row slice, but it does not make the base snapshot and span snapshot one atomic or generation-coordinated publication.
Observed offline reproduction: a v1 span snapshot was published with span b7ad6b7169203331; a changed-source same-version replacement committed a new results fingerprint and then failed only during span staging. The active version remained v1 and still exposed b7ad6b7169203331, although the current source expected ffff0000ffff0000.
Required response: either publish the base and span slice in one transaction, or add a manifest generation identifier to span rows and make the active view expose only the exact synchronized generation. A failed span publish must fail closed rather than present old rows for the newly committed base generation.
Confidence: 100
3. Later native publishes can leave the span active pin behind
Location: src/bigquery_agent_analytics/native_events.py:606 (also :837-853)
When span_labels_table is omitted, materialize returns immediately after updating the normal native snapshot and never maintains or invalidates an existing span publication. Thus, after a labelled v1 import, a successful v2 import without the option advances failed_sessions to v2 while the span-label view remains pinned to v1. The documented join can then attach stale v1 labels to the currently selected session snapshot. The same stale-label condition occurs for a successful changed-source same-version replacement without the flag.
In addition, _sync_span_labels_view selects the latest manifest independently of the version whose span rows were just written. A caller publishing an older retained version can therefore repin the view to a newer version that has no synchronized span rows.
Observed offline reproductions: labelled v1 followed by unlabelled v2 left failed_sessions on v2 and the span view/rows on v1; labelled v1 followed by an unlabelled same-pin replacement kept the old b7ad6b7169203331 row although the replacement source expected ffff0000ffff0000.
Required response: persist the span-table/synchronized-generation binding and maintain or invalidate it on every later native publish before failed_sessions advances. View synchronization must target the exact generation whose span rows were successfully published, not an independently selected latest manifest.
Confidence: 100
Scope and verification
- Reviewed the local unique commit log/diff and the GitHub PR itself with gh pr view 470 and gh pr diff 470.
- Confirmed HEAD is a0a71c3, a7fd389 is its ancestor, and the unique commits are exactly 81fa2be plus a0a71c3.
- Confirmed forbidden demo/older commits 0778125, 2169889, and 7f5a954 are not ancestors. The additional GitHub files are the expected stacked PR 458-467 history.
- Confirmed the unique diff touches only CHANGELOG.md, native_events.py, evalbench.py, cli.py, and the two requested offline test files.
- Confirmed no conflict markers and a clean git diff --check. The only untracked item is the excluded .venv.
- Ran offline tests only: 209 passed across test_native_span_labels.py, test_cli_evalbench_native_import.py, test_span_taxonomy.py, test_native_events_writer.py, and test_evalbench_importer.py.
- Verified the frozen widget-stock rows, real span_id, gap_after_span target, three frozen G1 names, fail-closed no-span-id path, first-eight/full-session collision identity, thin CLI flag, reuse of label_native_run, and absence of adapter/source-reader changes.
- An independent Claude Opus 5 adversarial review corroborated all three P1s. Each finding also had ordinary reviewer evidence, so no additional validator pass was needed.
- No live BigQuery, production agent_events write, synth run, GitHub review post, push, merge, clock action, or worktree modification was performed.
What can wait
- A direct CLI-level assertion for the default-policy normalization can be added as test polish; the materializer behavior is already covered by the offline regression tests.
- The stale PR-body description of the old delete-then-load design can be refreshed separately.
- Presenter/demo work from #468/#465/#462, live-BQ validation, Week 1, preregistration/clock work, new command families, and adapter changes remain out of scope.
Actionable findings
| # | Severity | Location | Summary |
|---|---|---|---|
| 1 | P1 | src/bigquery_agent_analytics/native_events.py:557 | Persist and generation-check the frozen span policy across later native calls. |
| 2 | P1 | src/bigquery_agent_analytics/native_events.py:594 | Prevent a failed span sync from exposing stale rows for a newly committed same-pin base generation. |
| 3 | P1 | src/bigquery_agent_analytics/native_events.py:606 | Maintain or invalidate span publication whenever later native publishes advance or replace the active snapshot. |
Final verdict
REQUEST_CHANGES. P0=0, P1=3, P2=0. The exact stale r1 blockers are fixed, but span publication is not yet durably bound to the policy and base-manifest generation across subsequent native-import calls.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Kimi
Re-review (r2): PR #470 — persist span-level G1 labels on the native snapshot (#469)
- HEAD:
a0a71c3097cb0ed0975e8143acfa437980ca97a5(feat/469-span-labels-native) - Base: PR #467 @
a7fd389(stacked on #464 @f5c6109). Reviewedgit diff a7fd389..HEAD/git log a7fd389..HEADplusgh pr view 470/ the PR body. - Unique commits:
81fa2be(feature) +a0a71c3(P1 fix). Exactly the six in-scope files:native_events.py,evalbench.py,cli.py,tests/test_native_span_labels.py,tests/test_cli_evalbench_native_import.py,CHANGELOG.md. No #468 (0778125), #465 (2169889), or #462 (7f5a954) commits. GitHub-vs-main showing the 458–467 file set is expected stacking. Untracked.venvignored. - Verification: full offline suite
pytest -q→ 4486 passed, 72 skipped (targeted:test_native_span_labels.py+test_cli_evalbench_native_import.py→ 35 passed;test_native_events_writer.py+test_span_taxonomy.py+test_evalbench_importer.py→ 174 passed). All fixture-only, fake BQ client.
Verdict: LGTM / APPROVE
P0 count: 0
P1 count: 0
P2 count: 2
- P0: 0
- P1: 0
- P2: 2 (informational, non-blocking)
Prior P1s — all four CLOSED on a0a71c3
- Codex P1-1 (span/session policy divergence) — CLOSED.
resolve_span_label_policy(native_events.py:319-353) resolvesNone→ frozenEvalScorePolicy({"goal_completion": 1.0}), merges any other policy — the truthy-but-emptyEvalScorePolicy({})explicitly included — with the gate, and rejects a conflictinggoal_completionthreshold. Inmaterialize(native_events.py:556-559) the same resolved policy object is passed both toto_span_label_rows(span derivation) and tosuper().materialize(manifestview_policy/ failed-sessions view). Tests prove both regression vectors:test_cli_default_none_policy_gates_the_denominator_tooandtest_explicit_empty_policy_is_merged_to_the_frozen_gate(tests/test_native_span_labels.py:451, 459) assert the committed manifest policy, the rendered view gate, and the span rows all agree;test_conflicting_goal_completion_threshold_fails_closed(:468) fails closed with zero queries/writes. The r1 P2 note about the truthy empty policy is also fully addressed. - Codex P1-2 (delete-then-append, non-atomic, racy) — CLOSED.
_publish_span_labels(native_events.py:691-776) loads rows into a uniquely-named expiring staging table, then one multi-statement transaction (_SPAN_SYNC_SCRIPT, native_events.py:172-199) claims the dataset import lock (serializing concurrent same-pin syncs; BigQuery cancels the second), re-checks the manifestgeneration_idinside the transaction (stale-derived rows refused), and only then DELETEs + INSERTs the keyed slice, withEXCEPTION WHEN ERROR → ROLLBACK. Staging is dropped infinallyand expires regardless. Covered bytest_span_staging_load_failure_preserves_published_rows(:495, old rows survive a load failure),test_concurrent_same_pin_syncs_cannot_duplicate_rows(:517, exactly 3 rows after a simulated interleave),test_replaced_generation_between_derive_and_sync_fails_closed(:543), andtest_span_replacement_is_staged_then_transactional(:570, ordering + rollback + staging lifecycle asserted in the emitted script). - Codex P1-3 (eval_id join fans out across retained versions) — CLOSED. A companion
{span_labels_table}_pinnedview (SPAN_LABELS_VIEW_SUFFIX, native_events.py:210;_sync_span_labels_view:778-837) is kept pinned to the job's latest manifest row — the same row the failed-sessions view pins — with byte-verified ownership and ETag-conditional replace; foreign objects and another job's pin are refused (test_foreign_object_at_the_pinned_view_name_is_refused:644,test_pinned_view_of_another_job_is_refused:652).test_pinned_view_joins_only_the_current_versions_rows(:605) demonstrates the retained base table fans out to 6 rows on a bare eval_id join while the pinned view yields exactly the current version's 3. CLI help and the command docstring (cli.py:2505-2521, 2550-2562) teach thejob_id + import_version + eval_idjoin. - Kimi P1 (CHANGELOG) — CLOSED. Unreleased/Added carries a #469 bullet (CHANGELOG.md:12-33) above the existing #466 bullet, newest-first; the #467/#464/#463 bullets are untouched. It documents the thin flag, the ONE-policy resolution, the pinned view, the widget-stock anchors, fail-closed span_id, first-8 identity, clock OFF, and the #97 adapter staying.
P0 checklist — all clear
- No live BQ / no
--synth: everything runs through the inherited fake-client path; derivation is pure/offline before any write. Full suite green with zero live access. - No
evalbench-importcall, no EvalBench source reads: the adapter path is untouched — theevalbench.pychange is purely additive (three defaulted fields onEvalBenchImportResult, evalbench.py:1330-1332;None/0on the adapter path). The module docstring's no-configs/results/scorescontract stands (native_events.py:22). - Production
agent_eventsnever written: reserved-name validation extended tospan_labels_table(cli.py:2581-2582; native_events.py:533) plus shadow guards against the import tables/view and the derived view name (native_events.py:538-552); destination-vs-source comparison now includes both span objects (native_events.py:572-581).test_span_sync_never_touches_source_or_production_agent_events(:723) covers it. - Clock / preregistration / Week 1: untouched;
test_span_label_publication_does_not_start_the_clock(:740). - No synthetic span identifiers: derivation happens before any BigQuery call (native_events.py:561-564); a label the localizer refuses aborts the whole publish with zero writes (
test_rows_without_a_real_span_id_fail_the_publish_closed:271). - Denominator unchanged:
test_session_level_g1_denominator_is_unchanged(:226) — session-levelfailed_sessions+ G1 stays the verdict; span rows join it on eval_id. label_native_runreused, not reimplemented:to_span_label_rows(native_events.py:646-688) is a thin mapping overspan_taxonomy.label_native_run; frozen names only,taxonomy_versionpinned toTAXONOMY_VERSION"0.1.0".- Frozen story pinned:
test_widget_stock_rows_anchor_the_real_agent_starting_span(:199) asserts7e352c34/b7ad6b7169203331(via_AGENT_STARTING_SPAN, tests/test_span_taxonomy.py:52) /gap_after_span/ the three frozen categories with the widget-stock evidence strings, keyed by(mvp-e2e-real-traces, v1). - Identity: first-8 eval_id with full session id on collision, joinable to
failed_sessions(test_first8_collision_publishes_the_full_session_id_eval_id:250). - Thin CLI only: one
--span-labels-tableoption on the existing command (cli.py:2505), default off (test_native_import_span_labels_default_off), reserved names rejected (exit 2). - Stacking: unique commits sit directly on
a7fd389; no conflict markers, noturn_index, no Acme/SANA content in the diff (grepped).
P2 findings (informational, not blockers)
- Pin commit precedes span sync. The span sync runs after the inherited publish commits the manifest pin; a sync failure leaves the pin committed with previously published (or no) span rows. This is now explicitly surfaced —
_sync_span_labels(native_events.py:624-643) raises aValueErrornaming the pin, the status, and the heal-by-rerun path — and old rows are preserved rather than zeroed, so it converges on the next call. Documented trade-off, acceptable. - Pinned view tracks the latest manifest row, which can briefly lead span rows. Under a concurrent publish the view can pin to a version whose span sync has not yet run (transient empty view), healing on the next
materialize. Same reconcile semantics as the failed-sessions view; noted for operators, not a defect.
What can wait
- Both P2 items above (documented convergence trade-offs with explicit heal paths).
- Nothing else — no code or docs changes requested.
Summary
The a0a71c3 fix commit closes all four r1 P1s with real mechanism, not documentation: one resolved policy object shared by span derivation and the committed denominator, a lock-serialized generation-checked transaction replacing the delete-then-append, a byte-verified ETag-conditional pinned view as the fan-out-free join boundary, and the CHANGELOG bullet in the right position. Test coverage of the fixes is unusually direct — the concurrency and staleness tests simulate the exact interleavings the r1 findings described. Scope discipline holds end to end: opt-in default keeps the frozen #464 publish byte-identical, the adapter stays, the clock stays off, and the frozen widget-stock anchors are asserted in the acceptance suite. LGTM.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
P0 count: 0
P1 count: 4
PR 470 re-review (r3)
Verdict: REQUEST_CHANGES
HEAD: 22384f62ac4db3480d771aac56bc36a8ea5ffc13 (22384f6)
Reviewed range: a7fd3899c3726a8de257783a2f1dcd50d96299e3..HEAD
Unique commits: 81fa2be, a0a71c3, 22384f6
| Severity | Count |
|---|---|
| P0 | 0 |
| P1 | 4 |
| P2 | 0 (informational) |
The widget-stock acceptance path, real span identity, frozen taxonomy, native-only source boundary, generation-stamped span rows, and latest-generation view guard are correct. The prior generation-skew P1 is closed. The policy-durability and later-publish lockstep P1s are only partially closed because the new binding is still an unlocked pre-read and its stored policy is not enforced.
Prior r2 P1 status
| Prior P1 | Status on 22384f6 |
Evidence |
|---|---|---|
| Frozen policy was not durable or generation-checked | Partially closed. The exact default-policy regression and the span-sync generation/policy checks are fixed. However, a bound no-policy call discards a supported stored policy (#1), and a writer that pre-read no binding can still recommit view_policy=NULL after the binding lands (#4). |
src/bigquery_agent_analytics/native_events.py:712-756; :966-1057 |
| Changed-source same-version failure could present old span rows as the new base | Closed. Span rows carry the manifest generation_id, and the pinned view exposes them only while that generation is still the job's latest manifest generation. A failed span sync after a base replace now yields an empty view and heals on rerun. |
src/bigquery_agent_analytics/native_events.py:283-308; :926-1145; tests/test_native_span_labels.py:927-962 |
| Later unlabelled import / older-version resync could desynchronize or repin the join boundary | Partially closed. The normal later-unlabelled, same-pin replace, and older-version regressions pass. The supported --skip-failed-sessions-view combination can still advance the span view while leaving failed_sessions on the previous version (#2). |
src/bigquery_agent_analytics/cli.py:2618-2622; src/bigquery_agent_analytics/native_events.py:792-820 |
P1 findings
#1 Stored span policy is ignored on later calls
Location: src/bigquery_agent_analytics/native_events.py:718-756
The registry stores canonical view_policy, but materialize uses only binding["span_labels_table"]. A later bound call with policy=None runs resolve_span_label_policy(None) and replaces the stored policy with the fallback-only goal_completion policy.
Offline reproduction on HEAD: an initial binding under EvalScorePolicy({"accuracy": 0.9}, missing_score_fails=False) correctly stored accuracy plus the frozen goal_completion gate. An ordinary same-pin call with no policy changed both manifest and binding to only goal_completion and reset missing_score_fails=True. This changes the session denominator despite the advertised durable ONE-policy binding.
Required response: When a bound caller omits policy, parse and use the binding's stored canonical policy. Handle an explicitly supplied compatible policy as a deliberate policy change or reject it. Add a regression with an extra comparator and non-default missing_score_fails that verifies manifest, binding, generation, failed-session view, and span rows remain coherent.
Confidence: 100. Independently found by correctness and adversarial reviewers and confirmed by the validator and an offline reproduction.
#2 Skipping denominator maintenance desynchronizes the pinned views
Location: src/bigquery_agent_analytics/cli.py:2618 (materializer path at src/bigquery_agent_analytics/native_events.py:792-820)
The CLI and API allow active span publication together with failed_sessions_view=None. After a labelled v1 publish, a later bound v2 call with --skip-failed-sessions-view leaves the failed-session view pinned to v1 while the span-label view advances to v2. The documented eval_id join then combines different snapshots, reopening the prior lockstep failure through an existing supported flag.
Required response: Reject failed_sessions_view=None whenever explicit or registry-restored span publication is active, before the base publish. Reject the conflicting CLI flags early. Cover both first opt-in and later bound calls and assert that no manifest or span boundary advances on rejection.
Confidence: 75. Independently found by the adversarial reviewer, reproduced offline, and confirmed by the validator.
#3 Concurrent first opt-ins can bind two span tables
Location: src/bigquery_agent_analytics/native_events.py:255-260
Two first-time callers can both pre-read no binding and choose different span tables. After one publishes the base and its span binding, the other can see the base as unchanged and enter the later serialized span transaction. That transaction unconditionally deletes and reinserts the binding with the second table name. Both calls succeed, and both table-specific pinned views can expose the same current generation even though future calls maintain only the last registry value.
Required response: Inside _SPAN_SYNC_SCRIPT, after claiming the import lock, allow an absent binding for the first insert but require any existing row for the job to name @span_labels_table_name; raise on a different table. Add a two-caller regression in which both pre-reads observe no binding.
Confidence: 75. Independently found by the adversarial reviewer, reproduced with the offline fake, and confirmed by the validator.
#4 Binding lookup races the base publish
Location: src/bigquery_agent_analytics/native_events.py:712-717 and :792-803
An ordinary writer can read "no binding," pause, and resume after another writer completes the first span binding. The delayed writer never rechecks the registry. It can therefore recommit policy=None through the inherited unchanged path and return without span synchronization.
Offline reproduction on HEAD changed the manifest from the frozen gate to view_policy=NULL, minted a new generation, removed the gate from failed_sessions, left the binding on the previous generation, and returned success with span_labels_table=None. The generation guard correctly made the span view empty, but the delayed writer did not fail closed and the durable policy was lost.
Required response: Make the observed binding state part of the lock-serialized base publication and unchanged-policy recommit decision. If the state changes from absent to present, abort and retry from binding discovery so the caller derives span rows and applies the bound policy. Add the exact delayed-ordinary-writer regression.
Confidence: 75. Independently found by the correctness reviewer, reproduced offline, and confirmed by the validator.
Scope and verification
- Reviewed the GitHub PR itself with
gh pr view 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDKandgh pr diff 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK. GitHub reports HEAD22384f6; the files inherited from PRs 458-467 are expected stacking and are not a finding. - Confirmed
a7fd389is the direct stack base through the three unique commits. Prohibited commits0778125,2169889, and7f5a954are not ancestors of HEAD. - The unique diff touches only
CHANGELOG.md,native_events.py,evalbench.py,cli.py,test_native_span_labels.py, andtest_cli_evalbench_native_import.py.git diff --checkis clean; no conflict markers were found. Untracked.venvwas excluded. - Confirmed the frozen acceptance rows: session/eval
7e352c34, real spanb7ad6b7169203331,gap_after_span, the three frozen names,label_native_run, the frozen goal-completion gate, first-8/full-ID collision behavior, and fail-closed missing realspan_id. - Confirmed no new command family, no
turn_index, no taxonomy reimplementation, no EvalBench source-table reads or adapter call, no productionagent_eventswrite, no clock/Week 1 action, and no #468/#465/#462 content. - Offline targeted suite: 218 passed across
test_native_span_labels.py,test_cli_evalbench_native_import.py,test_span_taxonomy.py,test_native_events_writer.py, andtest_evalbench_importer.py. - A full
pytest -qattempt stopped during unrelated collection because the installed ADK/OpenTelemetry environment lacksGEN_AI_TOOL_DEFINITIONS; the five in-scope suites above completed successfully. - All four P1 findings passed one fresh independent validator batch. No live BigQuery, GitHub review post, push, commit, branch change, or worktree modification was performed.
What can wait
- P2 count is zero; no informational item is used as a blocker.
- Live BigQuery validation remains out of scope.
- Presenter/demo work from #468/#465/#462, adapter changes, preregistration, clock activation, Week 1, and merge work must wait.
- General decomposition of the enlarged
native_events.pycan wait; it is not a blocker in this review.
Actionable findings
| # | Severity | File:line | Action | Route |
|---|---|---|---|---|
| 1 | P1 | src/bigquery_agent_analytics/native_events.py:718 |
Apply the stored binding policy when a bound caller omits policy. | gated_auto -> downstream-resolver |
| 2 | P1 | src/bigquery_agent_analytics/cli.py:2618 |
Reject skipped denominator maintenance while span publication is active. | gated_auto -> downstream-resolver |
| 3 | P1 | src/bigquery_agent_analytics/native_events.py:255 |
Enforce the existing span-table binding inside the serialized transaction. | gated_auto -> downstream-resolver |
| 4 | P1 | src/bigquery_agent_analytics/native_events.py:712 |
Revalidate binding state inside the base/policy publication boundary. | manual -> downstream-resolver |
Verdict
REQUEST_CHANGES. P0=0, P1=4, P2=0. The manifest-generation guard closes stale-row presentation, but the registry is not yet authoritative for stored policy, first-binding overlap, or every supported failed-session/span-view lifecycle. Fix #4 and #3 first to make binding state authoritative under the import lock, then #1 and #2 to preserve the policy and denominator contracts.
Actionable recap
- #4 P1 --
native_events.py:712-- manual: revalidate absent/present binding state inside the base and policy-update boundary. - #3 P1 --
native_events.py:255-- gated: reject an in-transaction switch to another span table. - #1 P1 --
native_events.py:718-- gated: retain the registered policy on no-policy calls. - #2 P1 --
cli.py:2618-- gated: reject span publication with skipped failed-session view maintenance.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Kimi
P0 count: 0
P1 count: 0
PR 470 re-review (r3) — feat(evalbench): persist span-level G1 labels on native snapshot (#469)
- HEAD reviewed:
22384f62ac4db3480d771aac56bc36a8ea5ffc13(22384f6) - Unique commits vs #467 HEAD
a7fd389:81fa2be+a0a71c3+22384f6(git diff a7fd389..HEAD: 6 files, +2183/−7 —native_events.py,evalbench.py,cli.py,tests/test_native_span_labels.py,tests/test_cli_evalbench_native_import.py,CHANGELOG.md) - GitHub PR: OPEN,
headRefOid=22384f6, basemain; the 458–467 file set shown againstmainis expected stacking, not new content. No #468 (0778125), #465 (2169889), or #462 (7f5a954) commits in history;81fa2be^=a7fd389,merge-base --is-ancestor a7fd389 HEADconfirmed. - Tests run (offline, fake BQ only):
pytest tests/test_native_span_labels.py tests/test_native_events_writer.py tests/test_span_taxonomy.py tests/test_evalbench_importer.py tests/test_cli_evalbench_native_import.py tests/test_cli_evalbench_failed_sessions.py→ 225 passed. No live BigQuery, no--synth, clock untouched.
Verdict: LGTM / APPROVE
- P0: 0
- P1: 0 — all three r2 P1s from Codex's review of
a0a71c3are closed on22384f6, with mechanism and regression tests verified (below). - P2: 3 (informational only, none blocking)
Prior r2 P1s — verification on 22384f6
P1-r2-1 (frozen span policy not durable / generation-checked) — CLOSED
NativeAgentEventsRun.materialize now reads the fixed-name per-dataset registry evalbench_span_bindings (SPAN_BINDINGS_TABLE, native_events.py:192) before validation (native_events.py:712). A bound job's later ordinary call (no span_labels_table, no policy) inherits the bound table (native_events.py:719), re-resolves the frozen gate via resolve_span_label_policy (native_events.py:360, NATIVE_SPAN_LABEL_POLICY at :314), derives span rows before any write, and passes the resolved policy into the inherited publish — so the manifest view_policy keeps the gate instead of being rewritten to NULL. The sync transaction itself re-checks exact generation_id AND canonical view_policy inside the lock-serialized transaction (_SPAN_SYNC_SCRIPT, native_events.py:227), so a delayed writer that finds a re-committed gate fails closed.
Tests: test_ordinary_same_pin_call_keeps_the_gate_and_the_span_rows (843), test_bound_job_rejects_a_conflicting_gate_on_an_ordinary_call (877), test_bound_job_cannot_switch_span_tables (891), test_gate_recommitted_between_derive_and_sync_fails_closed (903). All pass; the ordinary-call test asserts the gate, the generation, the failed-sessions view rendering, and the span rows all survive a no-flag re-run.
P1-r2-2 (base/span fail-closed generation skew) — CLOSED
Span rows are stamped with the exact manifest generation_id they were synchronized under (_publish_span_labels, native_events.py:926; generation re-read from the committed manifest and fingerprints + view_policy verified before staging). The companion <table>_pinned view renders a latest-generation guard (_SPAN_VIEW_BODY, native_events.py:283): rows are exposed only while the pinned generation is still the job's latest manifest generation (ordering matches _LATEST_IMPORT_QUERY, evalbench.py:262). A changed-source same-version replace whose span sync fails leaves the new base generation committed but the view EMPTY — never old rows presented as the new base — and re-running heals.
Tests: test_failed_span_sync_after_changed_source_replace_closes_the_view (927) exercises exactly this (staging load error after replace commits → empty view → heal on re-run), plus test_replaced_generation_between_derive_and_sync_fails_closed (622) and test_span_staging_load_failure_preserves_published_rows (574).
P1-r2-3 (later-publish pin drift / lockstep join) — CLOSED
Because the binding makes every later native call of a bound job maintain the span snapshot, a later unlabelled import (import_version="v2", no flag) re-derives and re-syncs span rows and moves the pinned view with the base — verified by test_labelled_v1_then_unlabelled_v2_moves_the_boundary_together (965) and test_labelled_then_unlabelled_same_pin_replace_stays_coherent (1010). A bound corpus without real span_ids raises in to_span_label_rows BEFORE super().materialize runs, so the base snapshot never advances (test_bound_job_with_unlabelable_corpus_fails_before_publishing, 992). The view sync writes only the rendering of the generation it just synchronized and stands down when that generation is no longer latest (native_events.py:1106), so an older-version resync cannot repin the view to a rowless generation (test_resyncing_an_older_version_cannot_repin_the_view, 1030).
r1 P1s (81fa2be) — remain closed
Policy alignment (CLI default / explicit-empty EvalScorePolicy({}) merged to the frozen gate, conflicting goal_completion rejected): resolve_span_label_policy + tests 494/530/538/547/559. Atomic publish: staged load + single lock-claiming transaction replacing the keyed slice and upserting the binding, rollback on any failure; concurrency serialized by the import lock (tests 596/649). Pin join: per-version retained rows + _pinned view + documented join keys (test 684 shows the bare-eval_id fan-out of 6 rows and the view returning exactly 3).
P0 sweep — clean
- No live BQ, no
--synth; tests are fake-client fixture tests only. - No call to the
evalbench-importadapter and no reads of EvalBench source configs/results/scores; the adapter is untouched (evalbench.pydiff is additive result fields only). The onlyevalbench-importmentions in the diff are prose stating the adapter (#97) stays. - No writes to production
agent_events: reserved-name guard extended to the span table/view/registry (_validate_destination_table+ reserved tuple inmaterialize), source-collision check covers all new destinations;test_span_sync_never_touches_source_or_production_agent_events(1100). - Clock OFF: nothing starts the six-week clock, seals preregistration, or kicks Week 1 (
test_span_label_publication_does_not_start_the_clock, 1117). - No #468/#465/#462 commits; stack reset intact (
81fa2be^=a7fd389). - No synthetic span identifiers: derivation reuses
label_native_runand fails closed without a realspan_idbefore any write (tests 350/371). Noturn_index. No SANA fork / new category strings (frozen v0.1.0 names asserted verbatim, tests 278–303). No conflict markers. - Session-level
failed_sessions+ G1 stays the denominator, byte-unchanged with publication on (test 305); span rows only localize. span_taxonomyis reused (from .span_taxonomy import label_native_run,native_events.py:828area), not reimplemented.
P1 sweep — clean
- Frozen widget-stock fixture for published rows:
7e352c34/b7ad6b7169203331(_AGENT_STARTING_SPAN) /gap_after_span/ the three frozen names, with evidence of no subsequentTOOL_STARTING/check_inventory/AGENT_COMPLETED(tests 248–303). - Identity: first-8
eval_id, fullsession_idon collision, joinable tofailed_sessions(tests 329, 305). - Thin CLI extension only:
evalbench-native-import --span-labels-table, no new command family (cli.py:2505); errors exit 2 via the existing handler. - CHANGELOG: #469 bullet added (extended for the binding/generation design); #466 (#467's) and #463 (#464's) bullets retained.
- eval_id fan-out across retained
import_versions: bounded by the_pinnedview + generation guard + explicit join-key documentation in CLI help and docstrings. - No prior P1 from
81fa2be/a0a71c3is still present.
P2 (informational — NOT blockers)
- Binding's recorded
view_policyis stored but never used for re-resolution (native_events.py:712-725). A job that opted in with extra comparators (e.g.{accuracy: 0.9}merged with the frozen gate) will have its gate silently narrowed to the frozen gate by a later no-policy ordinary call: the resolved policy differs from the manifest's, so the inherited unchanged-path_record_view_policy(evalbench.py:2005) commits the narrowed gate under a fresh generation and the span sync follows it. Span rows and the denominator stay consistent with each other and the frozengoal_completion=1.0gate is never dropped, and this matches the inherited "caller policy decides an unchanged re-import" contract — but the registry's "ONE resolved policy" claim is only half-used. Consider resolving from_policy_from_column(binding["view_policy"])when the caller passes no policy. - Stand-down healing is manual (
native_events.py:1106): when a span sync fails after a base advance, the view stays fail-closed (empty) until someone re-runsmaterializefor the latest generation. Documented in the error message and docstrings; acceptable. - Zero-failed-session publish still creates the span table, keyed delete, binding row, and pinned view (deliberate — keeps the contract queryable and prevents stale rows after replace; asserted by
test_a_session_that_passes_yields_no_span_rows, 473).
What can wait
- P2-1 (policy re-resolution from the binding row) — a robustness refinement, not a correctness hole.
- Any presenter/docs work — explicitly out of scope (#468 stays presenter-only).
- Merge: human gate remains @haiyuan-eng-google; do not merge 456–470 here.
Reviewed locally at 22384f6; nothing posted to GitHub, no push, no worktree modification.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Kimi
Review r4: PR #470 — persist span-level G1 labels on the native snapshot (#469)
- HEAD:
8bd5aafef30ff534e02e81ab734551caed0c61ee(8bd5aaf, branchfeat/469-span-labels-native) — confirmed identical to the GitHub PR head viagh pr view 470. - Base: PR #467 @
a7fd389(dual COMMENTED LGTM, unmerged), itself stacked on #464 @f5c6109. Reviewedgit diff a7fd389..HEAD/git log a7fd389..HEADplus the GitHub PR diff. GitHub-vs-main showing 458–467 files is expected stacking, not a finding. - Unique commits:
81fa2be+a0a71c3+22384f6+8bd5aaf. Exactly the in-scope files:native_events.py,evalbench.py,cli.py,tests/test_native_span_labels.py,tests/test_evalbench_importer.py,tests/test_cli_evalbench_native_import.py,CHANGELOG.md. No #468 (0778125), #465 (2169889), or #462 (7f5a954) commits;git merge-base --is-ancestor a7fd389 HEADholds. Untracked.venvignored. - Verification (all offline, fake BQ client, clock off, no live BQ): targeted suites (
test_native_span_labels,test_cli_evalbench_native_import,test_evalbench_importer,test_native_events_writer,test_span_taxonomy) → 227 passed; full offline suite → 4620 passed, 56 skipped (live tests self-skip withoutBQAA_RUN_LIVE_TESTS). Ran with bytecode/cache writing disabled; worktree left unmodified (git statusclean apart from the ignored.venv).
Verdict: LGTM / APPROVE
- P0 count: 0
- P1 count: 0
- P2 count: 3 (informational, non-blocking)
Prior r3 P1s (Codex on 22384f6) — all four verified CLOSED on 8bd5aaf
-
Stored span policy ignored on later no-policy calls — CLOSED.
native_events.py:799: a bound call withpolicy=Nonenow restores the binding's canonical stored policy via_policy_from_column(binding["view_policy"])(extra comparators andmissing_score_failsincluded) instead of re-resolving to the fallback-only gate; an explicit policy still flows throughresolve_span_label_policy(native_events.py:379) as a deliberate change. Regressions:test_bound_call_without_policy_keeps_the_stored_richer_gate(accuracy=0.9 /missing_score_fails=False; manifest, binding, generation, failed-session view rendering, and span rows all asserted coherent,tests/test_native_span_labels.py:1159) andtest_bound_call_with_explicit_policy_is_a_deliberate_change(:1199). -
Skipping the denominator view while span publication is active — CLOSED.
native_events.py:801-808:failed_sessions_view=Noneis refused whenever span publication is active — explicitly requested or registry-restored (the check runs after binding restoration, so the bound-job path is covered) — before anything is written. CLI rejects--span-labels-table+--skip-failed-sessions-viewbefore any BigQuery read (cli.py:2592-2601). Regressions:test_first_opt_in_requires_the_failed_sessions_view(:1221),test_bound_call_cannot_skip_the_failed_sessions_view(:1233),test_native_import_rejects_span_labels_with_skipped_view(asserts zero client calls). -
Racing first opt-ins / silent in-transaction re-bind — CLOSED.
_SPAN_SYNC_SCRIPTnow raises_SPAN_BINDING_CONFLICT_MESSAGE(native_events.py:234, script at:238-285) inside the lock-serialized transaction when the committed binding names another span table, before any DML; the loser fails closed and is mapped to a clearValueError(:1110-1118). Regression:test_racing_first_opt_ins_bind_only_one_span_table(:1256) — one binding wins, no second live pinned view. -
Binding not authoritative under the import lock — CLOSED.
_span_binding_guard(native_events.py:587) renders a registry predicate from the pre-read (pre-read-none →EXISTS; pre-read-bound →NOT EXISTSexact table+policy). The inherited publish transaction re-checks it right after the lock claim via_BINDING_GUARD/_PUBLISH_BINDING_GUARD_MESSAGE(evalbench.py:377,:411, rendered at:2776-2783), and the unchanged-path_record_view_policyUPDATE carries it negated in its WHERE (evalbench.py:2122), so a stale recommit lands on nothing. The registry table is created idempotently by every native publish before the inherited call (native_events.py:887-891), so the guard always has a table to read; the adapter path passes no guard and is untouched. Regressions:test_stale_no_binding_pre_read_cannot_publish_past_the_registry(:1282),test_recommit_after_binding_lands_cannot_null_the_gate(:1306, gate and generation preserved),test_bound_pre_read_must_match_the_committed_binding(:1333). The fake harness genuinely evaluates the rendered predicates against committed state (_binding_guard_trips,_span_binding_guard_result), so these are real race models, not string-matching theater.
Earlier-round P1s (81fa2be r1, a0a71c3 r2) remain closed: policy divergence on CLI default / explicit-empty EvalScorePolicy({}) (:575, :611, :619, resolver rejects a conflicting goal_completion at :628), delete-then-append replaced by staged + lock-serialized transactional replace (:655, :677, :703, :730), eval_id fan-out addressed by generation-stamped rows plus the pinned latest-generation-guarded view (:765, :1046, :1111).
P0 checklist — all clear
- No live BQ / no
--synth: derivation (to_span_label_rows,native_events.py:932) is pure/offline vialabel_native_run; writes only run through the injected/real client insidematerialize. Tests are fixture-only fakes. - Adapter #97 intact, no EvalBench source reads:
evalbench.pychanges are additive (binding_guardparameter defaultedNone, three defaulted result fields); the native path never callsevalbench-importand never reads EvalBenchconfigs/results/scores. - No production
agent_eventswrites: self-feed guard extended to the span table, pinned view, and registry (native_events.py:853-872);test_span_sync_never_touches_source_or_production_agent_events(:1388). - Clock off / no Week 1 / no preregistration seal:
test_span_label_publication_does_not_start_the_clock(:1405); CHANGELOG bullet states it explicitly. - No 468/465/462 commits; stacked on
a7fd389; no reset: verified viagit log/merge-base. - Frozen story intact: widget-stock fixture anchors present —
7e352c34/b7ad6b7169203331/gap_after_span, three frozen G1 names (test_widget_stock_rows_anchor_the_real_agent_starting_span,:359); no Acme-as-real-partner, no fake D4 people, no SANA fork, no new G1 strings; session-levelfailed_sessions+ G1 untouched as denominator (:386); no synthetic span identifiers (:431,:452); noturn_index; no conflict markers. - Frozen gate reused, not reimplemented:
resolve_span_label_policymergesEvalScorePolicy({"goal_completion": 1.0})(native_events.py:333,:379);label_native_runreused (:955); first-8/full-on-collision identity (:410); thin--span-labels-tableflag on the existingevalbench-native-importonly, no new command family (cli.py:2505-2527); CHANGELOG keeps the 466/463 bullets and adds 469 (base never had separate 467/464 bullets, so nothing was dropped).
P2 (informational — can wait, not blockers)
- Registry table created on every native publish, opt-in or not (
native_events.py:887-891). Needed so the under-lock guard has an authority to read, and it is a fixed BQAA-owned name documented in the docstring — but datasets of jobs that never asked for span labels now gain an emptyevalbench_span_bindingstable. Worth a line in user-facing docs when #469 is announced. - Crash window between a deliberate policy-change base commit and its span sync. If the span sync fails after the base snapshot commits a new gate, the binding still records the old policy and the next maintenance call re-converges manifest gate and span rows to the stored binding policy — silently superseding the crashed change. Convergent and fail-closed (the crashed caller gets an error), but a one-line "re-run to re-apply a policy change" note in the sync-failure error would aid operators.
_seed_import_lockon the unchanged maintenance path assumes the lock table exists (INSERT-only,evalbench.py:3059). If the BQAA lock table were ever deleted out-of-band, span sync fails without a self-healing path. Theoretical; the lock table is created by every real publish.
What can wait
All three P2s above; nothing else. No new P0/P1 found in the unique diff. Ship it (after the stack: #464 → #467 → #470).
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
Code Review Results
PR: #470
HEAD: 8bd5aaf
Scope: GitHub PR plus unique diff a7fd389..8bd5aaf
Mode: markdown report-only
Verdict: REQUEST_CHANGES
Counts: P0: 1, P1: 2, P2: 0 (informational)
P0 count: 1
P1 count: 2
P2 count: 0
Reviewers: correctness, adversarial, security, testing, reliability, API contract, maintainability, performance, and previous-comments. One fresh independent validator confirmed all three retained findings.
Prior r3 P1 audit
- Closed - stored policy on later calls. A bound no-policy call now restores the canonical registry policy at src/bigquery_agent_analytics/native_events.py:793 before resolving labels. The richer-policy and deliberate-change regressions cover manifest, binding, generation, failed_sessions rendering, and span rows.
- Closed - skipped denominator view. The API rejects active or restored span publication with failed_sessions_view=None at src/bigquery_agent_analytics/native_events.py:800, and the CLI rejects the explicit flag combination before a BigQuery read at src/bigquery_agent_analytics/cli.py:2594.
- Closed - silent same-job table switch. The locked span transaction now raises when the committed job binding names a different span table at src/bigquery_agent_analytics/native_events.py:262.
- Still open - binding authority during unchanged-path recommit. The main publish guard is checked under the import lock, but the separate policy recommit remains outside that lock at src/bigquery_agent_analytics/evalbench.py:2120. This is finding #2 below.
Claude's fix therefore closes three of the four stale r3 P1s; the fourth is only partially closed.
P0 - Critical
| # | File | Issue | Reviewer | Confidence |
|---|---|---|---|---|
| 1 | src/bigquery_agent_analytics/evalbench.py:2122 | Public binding_guard permits arbitrary BigQuery statements | security, maintainability | 100 |
- #1 - Raw SQL escapes the publication boundary. EvalBenchRun.materialize exposes binding_guard publicly at src/bigquery_agent_analytics/evalbench.py:908, appends it verbatim to the unchanged-path query at line 2122, and interpolates it into the main publish script at line 2780. A semicolon/comment payload can terminate the intended predicate and append DML executed by client.query with the SDK client's BigQuery identity. That bypasses the destination/source isolation checks and can modify unrelated or production tables. Remove the public SQL-string hook; pass private structured binding state and render only fixed predicates with query parameters. Add an offline regression proving public arguments cannot introduce executable statement boundaries.
P1 - High
| # | File | Issue | Reviewer | Confidence |
|---|---|---|---|---|
| 2 | src/bigquery_agent_analytics/evalbench.py:2120 | Policy recommit still races the binding transaction | correctness, adversarial | 100 |
| 3 | src/bigquery_agent_analytics/native_events.py:262 | Concurrent jobs can bind one span table and brick the loser | adversarial | 100 |
-
#2 - The prior binding-authority race is still present on the unchanged path. _record_view_policy performs a standalone manifest UPDATE and merely reads the registry predicate; it does not claim evalbench_import_lock. _SPAN_SYNC_SCRIPT claims the lock and mutates span/binding tables, but only reads the manifest. With both snapshots taken before either commit, BigQuery snapshot isolation sees disjoint mutated tables and allows both calls to succeed. A deterministic offline overlap reproduced manifest policy NULL/new generation, binding policy goal_completion=1.0/old generation, committed span rows, and no pinned span view. Move the recommit into a multi-statement transaction that claims the same import lock before evaluating the binding guard and updating the expected manifest generation; cover mutually stale snapshots.
-
#3 - Table ownership is enforced too late for different jobs. The in-transaction conflict at src/bigquery_agent_analytics/native_events.py:262 checks only job_id=@job_id, while the table-derived pinned view permits one job owner at lines 521-525. Two jobs using distinct failed_sessions views but the same span table can both commit rows and bindings; the loser then fails during view reconciliation. Its durable binding prevents both retrying the old table and selecting another one. A deterministic paused-load regression reproduced that terminal state. Under the existing lock, reject any binding for the requested span table whose job_id differs before row or binding DML, and verify the loser remains unbound and can retry another table.
Scope and verification
- Reviewed gh pr view 470 and gh pr diff 470 as well as git log/diff a7fd389..HEAD. GitHub and the worktree both identify HEAD 8bd5aaf.
- The unique commits are 81fa2be, a0a71c3, 22384f6, and 8bd5aaf, directly stacked on a7fd389. Forbidden demo/stack commits 0778125, 2169889, and 7f5a954 are absent.
- The unique diff is confined to the seven allowed source, test, and CHANGELOG files. No conflict markers; git diff --check is clean.
- The frozen widget-stock publication remains intact: first-8 collision-safe eval_id, real span_id b7ad6b7169203331, gap_after_span, the three frozen G1 names, session-level failed_sessions/G1 denominator, fail-closed missing span_id behavior, and label_native_run with the frozen goal_completion=1.0 gate.
- No evalbench-import call, EvalBench source config/result/score read, production agent_events write, new command family, synthetic span identifier, clock start, or forbidden stacked commit was found.
- Focused offline verification: 234 passed.
- Full offline verification through the existing .venv: 4620 passed, 56 skipped. The system Python run separately failed collection in three unrelated ADK tests because its installed OpenTelemetry semantic-conventions package is incompatible; the project virtualenv run is green.
- No live BigQuery operation was run. Nothing was posted to GitHub, pushed, amended, merged, or changed in the tracked worktree.
Actionable Findings
| # | File | Issue | Route | Notes |
|---|---|---|---|---|
| 1 | src/bigquery_agent_analytics/evalbench.py:2122 | Remove caller-supplied executable SQL from the materialize boundary | manual -> human | Fixed templates plus typed private state; add injection regression |
| 2 | src/bigquery_agent_analytics/evalbench.py:2120 | Serialize policy recommit through the import lock | manual -> human | Add a mutually stale snapshot overlap regression |
| 3 | src/bigquery_agent_analytics/native_events.py:262 | Enforce cross-job span-table ownership under the lock | gated_auto -> downstream-resolver | Loser must remain unbound and recoverable |
Coverage
- P0/P1 findings retained: 3; independent validator confirmed 3/3.
- P2 findings: 0.
- Cross-model outcome: external cross-model review was skipped for PR-remote/no-egress scope; in-process adversarial review was used.
- Failed reviewers: none.
- Testing gap below blocker threshold: explicit Conflict/PreconditionFailed pinned-view retry tests would add useful hardening.
What can wait
Additional pinned-view retry coverage and default-registry/API ergonomics can wait. They are not counted as P2 blockers and do not change this verdict.
Verdict
REQUEST_CHANGES - P0: 1, P1: 2, P2: 0.
Three of the four stale r3 P1s are closed. The unchanged-path binding-authority race remains, and the full unique diff adds one arbitrary-SQL publication escape plus one cross-job span-table ownership race.
Fix order: #1 fixed SQL boundary -> #2 serialize policy recommit -> #3 reserve span-table ownership under the lock.
…loudPlatform#469) Codex r4 on PR GoogleCloudPlatform#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.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Kimi
PR 470 re-review (r5) — after Claude's P0/P1-r4 fix
Verdict: LGTM / APPROVE
- P0 count: 0
- P1 count: 0
- P2 count (informational): 4
- HEAD reviewed:
a4e07dd81eeb4a466d1ca08eef5e90a970be0880(a4e07dd) - Scope: unique commits
a7fd389..HEAD=81fa2be + a0a71c3 + 22384f6 + 8bd5aaf + a4e07dd; GitHub PR head matchesa4e07dd, basemain(34 files shown = expected 458–467 stacking, not a finding) - Stacking: confirmed on PR 467 HEAD
a7fd389→ PR 464 HEADf5c6109; no #468 (0778125), #465 (2169889), or #462 (7f5a954) commits in range - File scope: unique diff touches only the 7 in-scope files (
native_events.py,evalbench.py,cli.py,tests/test_native_span_labels.py,tests/test_evalbench_importer.py,tests/test_cli_evalbench_native_import.py,CHANGELOG.md) - Tests (independent run at HEAD): targeted gate 232 passed (
test_native_span_labels+test_cli_evalbench_native_import+test_evalbench_importer+test_span_taxonomy+test_native_events_writer) — matches Claude's claim; full offline suite result noted below.
Prior r4 findings — all three CLOSED on a4e07dd
1. (P0) Public binding_guard raw-SQL hook — CLOSED.
EvalBenchRun.materialize now takes span_binding: Optional["_SpanBindingState"] only (src/bigquery_agent_analytics/evalbench.py:1013-1028); a non-structured argument raises TypeError before any BQ call (evalbench.py:1128-1139). _SpanBindingState (evalbench.py:460-531) re-validates the registry ref segment by segment (_validate_source_segment ^[A-Za-z0-9_-]+$ at evalbench.py:3341-3345, _validate_destination_table at evalbench.py:3348-3359 — backticks, semicolons, quotes, comment chars all rejected), renders exactly one of two fixed predicates (_SPAN_BINDING_ABSENT_PREDICATE / _SPAN_BINDING_BOUND_PREDICATE, evalbench.py:449-457), and binds expected table/policy strictly as query parameters (evalbench.py:520-531, wired at evalbench.py:1352 and evalbench.py:2254). Remaining binding_guard tokens are internal str.format slots filled only from span_binding.predicate() (evalbench.py:2928-2937, evalbench.py:2269-2274). Regression tests are substantive, not vacuous: tests/test_native_span_labels.py:1395 (TypeError, zero client calls), :1416 (backtick payloads rejected), :1438 (rendered guard byte-for-byte the fixed template; policy JSON never appears in SQL text).
2. (P1) Policy recommit raced the binding transaction — CLOSED.
_record_view_policy now runs _RECORD_VIEW_POLICY_SCRIPT (evalbench.py:301-328): a multi-statement transaction that claims the dataset import-lock sentinel FIRST (evalbench.py:304-312), then runs the expected-generation UPDATE with the negated fixed binding predicate in its WHERE clause (evalbench.py:313-322, rendered at evalbench.py:2270-2273), with EXCEPTION WHEN ERROR → ROLLBACK. The lock seeding before the script (evalbench.py:2263-2265, _SEED_LOCK_QUERY is INSERT-only/idempotent) does not introduce a new race — concurrent seeds still conflict on the same sentinel row mutation, so BigQuery cancels one side exactly as on the publish path. Mutually-stale-snapshot overlap regression at tests/test_native_span_labels.py:1475 with the fake's lock_claims cancellation rule (tests/test_evalbench_importer.py:963-1007): neither half commits, re-run heals.
3. (P1) Concurrent jobs binding one span table — CLOSED.
_SPAN_SYNC_SCRIPT (src/bigquery_agent_analytics/native_events.py:251-321) now checks, after the lock claim / stale-pin / binding-conflict checks and BEFORE any row or binding DML, EXISTS (... WHERE span_labels_table = @span_labels_table_name AND job_id != @job_id) → RAISE _SPAN_TABLE_OWNED_MESSAGE (native_events.py:283-292); the table name is a query parameter and job_id != correctly excludes the current job. Python-side translation to a clear ValueError (job stays unbound, retry with own table) at native_events.py:1189-1197. Paused-load regression tests/test_native_span_labels.py:1533-1588, including a textual assertion that the ownership check precedes DELETE FROM.
No residual injection/race holes found: no remaining raw-SQL caller hook anywhere; _sql_string_literal is now used only for validated job_id/import_version view rendering (evalbench.py:1716-1717, native_events.py:466-468).
Full unique-diff sweep (a7fd389..a4e07dd) — no NEW P0/P1
Hard-scope invariants verified at HEAD:
- Thin CLI only:
evalbench-native-importgains--span-labels-table(src/bigquery_agent_analytics/cli.py:2505, forwarded atcli.py:2633); no new command family,evalbench-importadapter untouched and still tested; no reads of EvalBench source configs/results/scores;--span-labels-table+--skip-failed-sessions-viewrejected pre-flight (cli.py:2592-2601). label_native_runreuse:to_span_label_rowsimports and calls it (native_events.py:956,:979);span_taxonomy.pyuntouched by this diff; no reimplemented taxonomy.- Frozen policy:
NATIVE_SPAN_LABEL_POLICY = EvalScorePolicy({"goal_completion": 1.0})(native_events.py:354);resolve_span_label_policy(native_events.py:400) merges explicit-emptyEvalScorePolicy({})into the frozen gate and rejectsgoal_completion != 1.0— one effective policy for span rows AND the session denominator (teststests/test_native_span_labels.py:639-653). No span/session divergence on CLI default or explicit-empty. - Atomic span replace: DELETE+INSERT+binding upsert inside the single
_SPAN_SYNC_SCRIPTtransaction with rollback handler; no delete-then-append outside a txn. - Join pinning: companion
_pinnedview filtersjob_id/import_version/generation_idliterals plus a latest-generation guard (native_events.py:323); no fan-out across retained import_versions. - Stored binding policy honored: on a later policy-less call,
policy = _policy_from_column(binding["view_policy"])(native_events.py:806-823). - failed_sessions view maintenance unskippable:
failed_sessions_view=Nonerefused whenever span publication is active or registry-restored (native_events.py:825-832). - In-transaction table switch rejected:
_SPAN_BINDING_CONFLICT_MESSAGEraise inside the sync transaction before DML (native_events.py:235,:271-282), plus fail-fast pre-check (native_events.py:810-817). - Binding revalidated under lock: structured state rendered into the publish transaction after the lock claim and negated into the lock-claiming recommit; pre-read is decision input only.
- Fail-closed, real span_id only:
span_taxonomy.py:242-248raises on missing span_id ("refusing to invent a synthetic span identifier");to_span_label_rowsruns before any table creation or write (native_events.py:870); tests:459-488prove zero queries/writes on failure and that every published span_id comes from source rows. - Identity: first-8
eval_idwith full-session-id collision fallback (native_events.py:1583-1593; tests:438-453), joinable tofailed_sessions. - Frozen widget-stock fixture: session
7e352c34-…-fb3c8f215346/ eval_id7e352c34, span_idb7ad6b7169203331,gap_after_span,support_agent/real-user-0/ "How many widgets are in stock?",job_id=mvp-e2e-real-traces; stuck session ends at AGENT_STARTING with no TOOL_STARTING/check_inventory/AGENT_COMPLETED; session-level G1 denominator unchanged (tests/test_native_span_labels.py:387-435). - No production
agent_eventswrites: every destination checked againstsource_tablebefore write (native_events.py:873-886);_validate_destination_tablerejects the reserved name. - Hygiene: no conflict markers;
turn_indexnot reintroduced (actively guarded bytests/test_span_taxonomy.py:421-456); no--synthlive paths; no Acme/fake D4 partners; no new G1 category strings; no SANA; clock stays off (stated in CHANGELOG and honored — no preregistration/week-1 content in this diff); all tests offline fakes. - CHANGELOG: #469 bullet added (
CHANGELOG.md:12-55) covering the frozen story, clock-off, and the r4 hardening; #466 and #463 bullets intact. Nothing dropped.
P2 (informational — NOT blockers)
- CHANGELOG has no dedicated #467 or #464 bullets. Pre-existing gap: neither PR ever added one, and this PR drops nothing — the P1 trigger ("dropped bullets") does not fire. Worth a one-line follow-up when the stack lands, not a blocker here.
- Base publish and span sync are two separate transactions; a crash between them leaves span rows one generation behind the base. Deliberate and documented: the
_pinnedview's latest-generation guard fails closed (empty view) and the error message instructs re-running. Acceptable. _publish_span_labelsre-creates the bindings table (native_events.py:1088) redundantly withmaterialize's earlier idempotent create — harmless duplication._sync_span_labels_viewsilently returns when the just-synced generation is no longer latest — correct fail-closed behavior, but no log/observability. Nit.
What can wait
- The four P2s above.
- Landing order: this approves code only; PR 467 (dual COMMENTED LGTM) and PR 464 still need to land first — no merge of the 456–470 stack from this review.
- Week 1 / clock / live BQ remain out of scope as frozen.
Bottom line: all three Codex r4 findings (P0×1, P1×2) are genuinely closed on a4e07dd with real regressions, the earlier r1–r3 P1 fixes all still hold, and the full unique diff introduces no new P0/P1. LGTM.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
PR 470 re-review (r5)
Verdict: REQUEST_CHANGES
P0 count: 1
P1 count: 0
P2 count: 0
Review-round: 5
HEAD: a4e07dd
HEAD: a4e07dd81eeb4a466d1ca08eef5e90a970be0880 (a4e07dd)
Scope: GitHub PR 470 and the five unique commits in a7fd389..HEAD
| Severity | Count |
|---|---|
| P0 | 1 |
| P1 | 0 |
| P2 | 0 (informational) |
The two r4 concurrency findings are closed. The r4 P0 is not fully closed because the public span_binding boundary accepts subclasses of _SpanBindingState, rather than only the exact private state class. I found no other P0/P1 in the full unique diff.
Prior r4 findings
- P0 raw-SQL escape: NOT CLOSED. The public
binding_guardkeyword is gone, ordinary non-state arguments are rejected, identifiers are validated, and the concrete_SpanBindingStaterenders fixed predicates with parameterized values. However, the boundary usesisinstance, so a derived class is accepted and may overridepredicate()andparameters(), which are used during query construction. - P1 policy recommit race: CLOSED.
_RECORD_VIEW_POLICY_SCRIPTclaims the shared import-lock row before the guarded manifest update atsrc/bigquery_agent_analytics/evalbench.py:301._record_view_policyseeds that sentinel and executes the transaction atsrc/bigquery_agent_analytics/evalbench.py:2263. This gives the policy recommit and span sync a shared mutated row, preventing the disjoint-table snapshot race described in r4. - P1 cross-job span-table ownership: CLOSED.
_SPAN_SYNC_SCRIPTchecks whether the requested span table belongs to another job atsrc/bigquery_agent_analytics/native_events.py:283, before span-row or binding DML begins at line 291. The losing job remains unbound and can retry with another table.
Finding
P0 -- The structured binding boundary accepts overrideable subclasses
Location: src/bigquery_agent_analytics/evalbench.py:1131
Related render sites: src/bigquery_agent_analytics/evalbench.py:1352, src/bigquery_agent_analytics/evalbench.py:2272, and src/bigquery_agent_analytics/evalbench.py:2932
The check is:
if span_binding is not None and not isinstance(
span_binding, _SpanBindingState
):This is not the required exact-class check. A safe local probe confirmed that a derived _SpanBindingState has type(value) is _SpanBindingState == False while isinstance(value, _SpanBindingState) == True, and that its overridden predicate() and parameters() methods are dispatched. Those method results feed the publish script, the unchanged-path policy script, and query parameters. Therefore the public EvalBenchRun.materialize(..., span_binding=...) boundary does not guarantee that guard SQL is one of the two fixed predicates.
The existing regression at tests/test_native_span_labels.py:1394 rejects strings and the removed binding_guard keyword, but it does not cover a subclass.
Required response: Reject every value whose type is not exactly _SpanBindingState, for example with type(span_binding) is not _SpanBindingState. Add an offline regression using a benign subclass and assert TypeError occurs before any client query, load, or table creation.
Scope and verification
- Local HEAD and GitHub PR head both resolve to
a4e07dd81eeb4a466d1ca08eef5e90a970be0880; PR 470 is open. - The unique stack is exactly
81fa2be + a0a71c3 + 22384f6 + 8bd5aaf + a4e07dd, with81fa2beparented bya7fd389. - Prohibited commits
0778125,2169889, and7f5a954are not ancestors of HEAD. gh pr view 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDKandgh pr diff 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDKwere reviewed. The extra files againstmainare the expected stacked history.- The unique diff keeps the native-only route, the existing
evalbench-native-import --span-labels-tablecommand,label_native_run, the shared frozenEvalScorePolicy({"goal_completion": 1.0}), fail-closed real span identity, first-8/full-id collision identity, pinned join boundary, and the widget-stock fixture values7e352c34,b7ad6b7169203331,gap_after_span, and the three frozen G1 names. - The CHANGELOG retains the #469 span publication, #467 span taxonomy, #464 native writer, and #463 exit-ramp history; no unique-diff deletion removed earlier bullets.
git diff --check a7fd389..HEADpassed, and no conflict markers were found.- Targeted offline tests passed: 192 passed across
tests/test_native_span_labels.py,tests/test_evalbench_importer.py, andtests/test_cli_evalbench_native_import.py. - No live BigQuery job,
--synth, GitHub post, push, commit, branch change, or worktree edit was performed. Untracked.venvwas ignored.
What can wait
There are no P2 findings in this review. Presenter/demo work from #468, #465, and #462 remains out of scope. Live BigQuery validation, clock activation, preregistration changes, Week 1 execution, and unrelated polish must wait.
Verdict
REQUEST_CHANGES. Replace the isinstance admission check with an exact-class check and add the subclass regression. The two r4 P1s are closed; no other P0/P1 blocks were found.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
PR 470 re-review (r5)
Verdict: REQUEST_CHANGES
P0 count: 1
P1 count: 0
P2 count: 0
Review-round: 5
HEAD: a4e07dd
HEAD: a4e07dd81eeb4a466d1ca08eef5e90a970be0880 (a4e07dd)
Scope: GitHub PR 470 and the five unique commits in a7fd389..HEAD
| Severity | Count |
|---|---|
| P0 | 1 |
| P1 | 0 |
| P2 | 0 (informational) |
The two r4 concurrency findings are closed. The r4 P0 is not fully closed because the public span_binding boundary accepts subclasses of _SpanBindingState, rather than only the exact private state class. I found no other P0/P1 in the full unique diff.
Prior r4 findings
- P0 raw-SQL escape: NOT CLOSED. The public
binding_guardkeyword is gone, ordinary non-state arguments are rejected, identifiers are validated, and the concrete_SpanBindingStaterenders fixed predicates with parameterized values. However, the boundary usesisinstance, so a derived class is accepted and may overridepredicate()andparameters(), which are used during query construction. - P1 policy recommit race: CLOSED.
_RECORD_VIEW_POLICY_SCRIPTclaims the shared import-lock row before the guarded manifest update atsrc/bigquery_agent_analytics/evalbench.py:301._record_view_policyseeds that sentinel and executes the transaction atsrc/bigquery_agent_analytics/evalbench.py:2263. This gives the policy recommit and span sync a shared mutated row, preventing the disjoint-table snapshot race described in r4. - P1 cross-job span-table ownership: CLOSED.
_SPAN_SYNC_SCRIPTchecks whether the requested span table belongs to another job atsrc/bigquery_agent_analytics/native_events.py:283, before span-row or binding DML begins at line 291. The losing job remains unbound and can retry with another table.
Finding
P0 -- The structured binding boundary accepts overrideable subclasses
Location: src/bigquery_agent_analytics/evalbench.py:1131
Related render sites: src/bigquery_agent_analytics/evalbench.py:1352, src/bigquery_agent_analytics/evalbench.py:2272, and src/bigquery_agent_analytics/evalbench.py:2932
The check is:
if span_binding is not None and not isinstance(
span_binding, _SpanBindingState
):This is not the required exact-class check. A safe local probe confirmed that a derived _SpanBindingState has type(value) is _SpanBindingState == False while isinstance(value, _SpanBindingState) == True, and that its overridden predicate() and parameters() methods are dispatched. Those method results feed the publish script, the unchanged-path policy script, and query parameters. Therefore the public EvalBenchRun.materialize(..., span_binding=...) boundary does not guarantee that guard SQL is one of the two fixed predicates.
The existing regression at tests/test_native_span_labels.py:1394 rejects strings and the removed binding_guard keyword, but it does not cover a subclass.
Required response: Reject every value whose type is not exactly _SpanBindingState, for example with type(span_binding) is not _SpanBindingState. Add an offline regression using a benign subclass and assert TypeError occurs before any client query, load, or table creation.
Scope and verification
- Local HEAD and GitHub PR head both resolve to
a4e07dd81eeb4a466d1ca08eef5e90a970be0880; PR 470 is open. - The unique stack is exactly
81fa2be + a0a71c3 + 22384f6 + 8bd5aaf + a4e07dd, with81fa2beparented bya7fd389. - Prohibited commits
0778125,2169889, and7f5a954are not ancestors of HEAD. gh pr view 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDKandgh pr diff 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDKwere reviewed. The extra files againstmainare the expected stacked history.- The unique diff keeps the native-only route, the existing
evalbench-native-import --span-labels-tablecommand,label_native_run, the shared frozenEvalScorePolicy({"goal_completion": 1.0}), fail-closed real span identity, first-8/full-id collision identity, pinned join boundary, and the widget-stock fixture values7e352c34,b7ad6b7169203331,gap_after_span, and the three frozen G1 names. - The CHANGELOG retains the #469 span publication, #467 span taxonomy, #464 native writer, and #463 exit-ramp history; no unique-diff deletion removed earlier bullets.
git diff --check a7fd389..HEADpassed, and no conflict markers were found.- Targeted offline tests passed: 192 passed across
tests/test_native_span_labels.py,tests/test_evalbench_importer.py, andtests/test_cli_evalbench_native_import.py. - No live BigQuery job,
--synth, GitHub post, push, commit, branch change, or worktree edit was performed. Untracked.venvwas ignored.
What can wait
There are no P2 findings in this review. Presenter/demo work from #468, #465, and #462 remains out of scope. Live BigQuery validation, clock activation, preregistration changes, Week 1 execution, and unrelated polish must wait.
Verdict
REQUEST_CHANGES. Replace the isinstance admission check with an exact-class check and add the subclass regression. The two r4 P1s are closed; no other P0/P1 blocks were found.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
PR 470 re-review (r5)
Verdict: REQUEST_CHANGES
P0 count: 1
P1 count: 0
P2 count: 0
Review-round: 5
HEAD: a4e07dd
HEAD: a4e07dd81eeb4a466d1ca08eef5e90a970be0880 (a4e07dd)
Scope: GitHub PR 470 and the five unique commits in a7fd389..HEAD
| Severity | Count |
|---|---|
| P0 | 1 |
| P1 | 0 |
| P2 | 0 (informational) |
The two r4 concurrency findings are closed. The r4 P0 is not fully closed because the public span_binding boundary accepts subclasses of _SpanBindingState, rather than only the exact private state class. I found no other P0/P1 in the full unique diff.
Prior r4 findings
- P0 raw-SQL escape: NOT CLOSED. The public
binding_guardkeyword is gone, ordinary non-state arguments are rejected, identifiers are validated, and the concrete_SpanBindingStaterenders fixed predicates with parameterized values. However, the boundary usesisinstance, so a derived class is accepted and may overridepredicate()andparameters(), which are used during query construction. - P1 policy recommit race: CLOSED.
_RECORD_VIEW_POLICY_SCRIPTclaims the shared import-lock row before the guarded manifest update atsrc/bigquery_agent_analytics/evalbench.py:301._record_view_policyseeds that sentinel and executes the transaction atsrc/bigquery_agent_analytics/evalbench.py:2263. This gives the policy recommit and span sync a shared mutated row, preventing the disjoint-table snapshot race described in r4. - P1 cross-job span-table ownership: CLOSED.
_SPAN_SYNC_SCRIPTchecks whether the requested span table belongs to another job atsrc/bigquery_agent_analytics/native_events.py:283, before span-row or binding DML begins at line 291. The losing job remains unbound and can retry with another table.
Finding
P0 -- The structured binding boundary accepts overrideable subclasses
Location: src/bigquery_agent_analytics/evalbench.py:1131
Related render sites: src/bigquery_agent_analytics/evalbench.py:1352, src/bigquery_agent_analytics/evalbench.py:2272, and src/bigquery_agent_analytics/evalbench.py:2932
The check is:
if span_binding is not None and not isinstance(
span_binding, _SpanBindingState
):This is not the required exact-class check. A safe local probe confirmed that a derived _SpanBindingState has type(value) is _SpanBindingState == False while isinstance(value, _SpanBindingState) == True, and that its overridden predicate() and parameters() methods are dispatched. Those method results feed the publish script, the unchanged-path policy script, and query parameters. Therefore the public EvalBenchRun.materialize(..., span_binding=...) boundary does not guarantee that guard SQL is one of the two fixed predicates.
The existing regression at tests/test_native_span_labels.py:1394 rejects strings and the removed binding_guard keyword, but it does not cover a subclass.
Required response: Reject every value whose type is not exactly _SpanBindingState, for example with type(span_binding) is not _SpanBindingState. Add an offline regression using a benign subclass and assert TypeError occurs before any client query, load, or table creation.
Scope and verification
- Local HEAD and GitHub PR head both resolve to
a4e07dd81eeb4a466d1ca08eef5e90a970be0880; PR 470 is open. - The unique stack is exactly
81fa2be + a0a71c3 + 22384f6 + 8bd5aaf + a4e07dd, with81fa2beparented bya7fd389. - Prohibited commits
0778125,2169889, and7f5a954are not ancestors of HEAD. gh pr view 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDKandgh pr diff 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDKwere reviewed. The extra files againstmainare the expected stacked history.- The unique diff keeps the native-only route, the existing
evalbench-native-import --span-labels-tablecommand,label_native_run, the shared frozenEvalScorePolicy({"goal_completion": 1.0}), fail-closed real span identity, first-8/full-id collision identity, pinned join boundary, and the widget-stock fixture values7e352c34,b7ad6b7169203331,gap_after_span, and the three frozen G1 names. - The CHANGELOG retains the #469 span publication, #467 span taxonomy, #464 native writer, and #463 exit-ramp history; no unique-diff deletion removed earlier bullets.
git diff --check a7fd389..HEADpassed, and no conflict markers were found.- Targeted offline tests passed: 192 passed across
tests/test_native_span_labels.py,tests/test_evalbench_importer.py, andtests/test_cli_evalbench_native_import.py. - No live BigQuery job,
--synth, GitHub post, push, commit, branch change, or worktree edit was performed. Untracked.venvwas ignored.
What can wait
There are no P2 findings in this review. Presenter/demo work from #468, #465, and #462 remains out of scope. Live BigQuery validation, clock activation, preregistration changes, Week 1 execution, and unrelated polish must wait.
Verdict
REQUEST_CHANGES. Replace the isinstance admission check with an exact-class check and add the subclass regression. The two r4 P1s are closed; no other P0/P1 blocks were found.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Kimi
PR #470 r6 review — re-review after Claude's P0-r5 exact-type fix
- PR: #470
- HEAD:
bf9954a89882f2ecf1bd85c77f166050ecd303d5(bf9954a) - Base for unique diff: PR #467 HEAD
a7fd389(stacking chain 464 → 467 → 470 verified viagit log a7fd389..HEAD: exactly the six expected commits81fa2be,a0a71c3,22384f6,8bd5aaf,a4e07dd,bf9954a) - Reviewed:
git diff a7fd389..HEAD, GitHub PR metadata/diff (gh pr view 470,gh pr diff 470). GitHub-vs-main showing #458–#467 files is expected stacking, not flagged.
Verdict: LGTM / APPROVE (COMMENTED, per review convention)
- P0 count: 0
- P1 count: 0
- P2 count: 0 (informational)
Prior r5 findings — closed
- Codex r5 P0 (isinstance at evalbench.py:1131): CLOSED on bf9954a.
materializenow gates on the exact class:type(span_binding) is not _SpanBindingState→TypeErroratsrc/bigquery_agent_analytics/evalbench.py:1134-1140, with a comment explaining whyisinstanceis insufficient (subclass could overridepredicate()/parameters()to smuggle caller-shaped SQL past the two fixed predicates). The check runs beforemake_bq_client(evalbench.py:1211) and before any staging/table creation, so the rejection is write-free and query-free.
Regression testtest_materialize_rejects_span_binding_state_subclasses(tests/test_native_span_labels.py:1417-1440) passes an overriding subclass rendering"TRUE); DROP TABLE prod.telemetry.agent_events; --"and assertsTypeErrorplusfake.queries == [] and fake.loads == [] and fake.created == []— i.e. TypeError before any client call, exactly as claimed. - Kimi r5 was already LGTM P0=0 P1=0; nothing to re-open.
Verification performed on bf9954a
- Unique commit set contains no #468 (
0778125), #465 (2169889), or #462 (7f5a954) commits; no reset offa7fd389/f5c6109. - No conflict markers in the unique diff (grep for
^+<<<<<<</^+>>>>>>>/^+=======$→ 0). - Frozen story intact in offline fixtures: session
7e352c34-4c1c-4395-acd5-fb3c8f215346/ eval_id7e352c34(tests/test_native_events_writer.py:53),job_id=mvp-e2e-real-traces(:52), prompt "How many widgets are in stock?" (:57),user_id=real-user-0, real spanb7ad6b7169203331(tests/test_span_taxonomy.py:52),target_kind=gap_after_spanwith the three frozen G1 names asserted on published rows (tests/test_native_span_labels.py:387-411); session-levelfailed_sessions+ G1 denominator asserted unchanged with publication on (:414-435); first-8/full-id-on-collision identity covered (:438-453). - Reuses
label_native_rununder the frozen gate — no span_taxonomy reimplementation (native_events.py:979-982,resolve_span_label_policyat :400-433 merging the frozengoal_completion=1.0gate into any policy including explicit-emptyEvalScorePolicy({}), rejecting conflicting thresholds). - Fail-closed without a real span_id before any write (derivation at
native_events.py:870-872, pre-publish; test attests/test_native_span_labels.py:459). - Thin CLI only:
evalbench-native-import --span-labels-tableflag on the existing command (cli.py:2505-2527);--span-labels-table+--skip-failed-sessions-viewrejected before any BQ read (cli.py:2592-2603). No new command family. - Atomic span publish: staged load + single lock-claiming multi-statement transaction (
_SPAN_SYNC_SCRIPT,native_events.py:251-306) with generation + canonicalview_policyre-check, one-binding-per-job and one-job-per-table guards inside the transaction before any DML. - Binding authoritative under the import lock:
_SpanBindingStaterenders one of two fixed parameterized predicates (evalbench.py:449-457,:511-531); rendered into the publish transaction after the lock claim (evalbench.py:2930-2937) and negated into the lock-claiming_RECORD_VIEW_POLICY_SCRIPTrecommit (evalbench.py:301-328,:2266-2276). - Stored binding policy applied on later no-policy calls (
native_events.py:817-823);failed_sessions_view=Nonerefused whenever span publication is active (:824-832); pinned<table>_pinnedview carries the latest-generation guard so eval_id joins don't fan out (native_events.py:323-349). - No
turn_indexanywhere in span rows (only a span_taxonomy comment explaining its omission). - No live BQ, no
--synth, no productionagent_eventswrites (reserved-name + self-feed guards extended to span table, bindings registry, and pinned view:native_events.py:837-887). - CHANGELOG keeps/adds the #469 bullet and retains #466/#463 bullets; clock stays OFF; adapter #97 untouched.
- Tests run locally on HEAD:
tests/test_native_span_labels.py+tests/test_cli_evalbench_native_import.py+tests/test_evalbench_importer.py→ 193 passed;tests/test_span_taxonomy.py+tests/test_native_events_writer.py→ 40 passed. All offline.
New findings (unique diff a7fd389..bf9954a)
None at P0/P1.
P2 (informational only, not blockers)
None worth recording this round; earlier-round style notes remain addressed or out of scope.
What can wait
- Live-BQ validation of the span publish/sync transactions (deferred by design — clock OFF, offline-only this PR).
- Any presenter/docs polish belongs to #468, not this PR.
Notes
- Reviewed as a GitHub PR (title/body/commits match the local worktree HEAD
bf9954a); nothing posted to GitHub by this reviewer. Human merge gate remains @haiyuan-eng-google; do not merge 456–470 from here.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
PR 470 re-review (r6)
Verdict: REQUEST_CHANGES
P0 count: 0
P1 count: 1
P2 count: 0 (informational)
HEAD: bf9954a89882f2ecf1bd85c77f166050ecd303d5 (bf9954a)
Scope: GitHub PR 470 and the six unique commits in a7fd389..bf9954a
Prior r5 findings closed: Yes
The bf9954a exact-type change fully closes the r5 P0. EvalBenchRun.materialize now admits only type(span_binding) is _SpanBindingState, and the new subclass regression proves rejection before any query, load, or table creation. No stale r4/r5 finding is reopened.
One new P1 remains in the unique diff: the pinned span-view ownership check trusts a self-consistent view's own pin. A copied view for the same job can therefore be treated as BQAA-owned and overwritten even when its table references and generation were never committed by this publication.
P1 -- A copied same-job span view can be overwritten as managed
Location: src/bigquery_agent_analytics/native_events.py:516
Related lines: src/bigquery_agent_analytics/native_events.py:523, src/bigquery_agent_analytics/native_events.py:542, src/bigquery_agent_analytics/native_events.py:1283
_read_managed_span_view renders its expected body from the existing view's own claimed span_labels_table, manifest_table, version, and generation. A byte-identical self-consistent body therefore passes at line 523 without any committed manifest state vouching for those claims. _check_span_view_binding then checks only that the claimed job_id matches. On reconciliation, _sync_span_labels_view updates that object in place.
This breaks the fail-closed ownership contract. A foreign or copied view at <span-labels-table>_pinned can be replaced even though BQAA did not create it for the requested span table and committed generation.
A focused offline reproduction installed a canonical span-pin body for the same job but for other_project.other_dataset.other_labels, other_manifest, version v9, and an uncommitted generation. materialize returned status="imported" and the fake client recorded an update that replaced the foreign body. A fresh validation pass independently confirmed the same execution path.
Required response: Authenticate the existing span view against trusted inputs and committed state before accepting it as managed. Pass the expected span-label and manifest references into the read, reject reference mismatches, and require the claimed generation to be the pinned manifest row's current generation or a committed superseded generation. Add a same-job copied/self-consistent view regression that proves the object is refused and left unchanged.
Prior r5 finding
- P0 exact-type boundary: CLOSED.
src/bigquery_agent_analytics/evalbench.py:1134usestype(span_binding) is not _SpanBindingState. The regression attests/test_native_span_labels.py:1417supplies an overriding subclass and assertsTypeErrorplus zero client calls. - The prior r4 policy-recommit and cross-job binding findings remain closed on this HEAD.
Actionable Findings
| # | Severity | File:line | Action | Route |
|---|---|---|---|---|
| 1 | P1 | src/bigquery_agent_analytics/native_events.py:516 |
Authenticate an existing pinned span view against the expected refs and committed manifest generation before replacing it; add the copied-view regression. | gated_auto -> downstream-resolver |
Scope and verification
- Local HEAD and GitHub PR head both resolve to
bf9954a89882f2ecf1bd85c77f166050ecd303d5; PR 470 is open. - The unique stack is exactly
81fa2be + a0a71c3 + 22384f6 + 8bd5aaf + a4e07dd + bf9954a, with81fa2beparented bya7fd389. a7fd389andf5c6109are ancestors. Prohibited commits0778125,2169889, and7f5a954are not ancestors of HEAD.gh pr view 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDKandgh pr diff 470 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDKwere reviewed. The additional files againstmainare the expected stacked history.- The unique diff keeps the native-only route, the existing
evalbench-native-import --span-labels-tablecommand,label_native_run, the shared frozenEvalScorePolicy({"goal_completion": 1.0}), fail-closed real span identity, first-8/full-id collision identity, pinned join boundary, and the widget-stock fixture values7e352c34,b7ad6b7169203331,gap_after_span, and the three frozen G1 names. - The EvalBench adapter remains present and separate. No unique code calls
evalbench-importor reads EvalBench source configs/results/scores. No productionagent_eventswrite,--synth, clock start, preregistration seal, or Week 1 action was added. - The CHANGELOG retains the #469 span publication, #467 span taxonomy, #464 native writer, and #463 exit-ramp history.
- Focused offline tests passed: 233 passed across
tests/test_native_span_labels.py,tests/test_evalbench_importer.py,tests/test_cli_evalbench_native_import.py,tests/test_span_taxonomy.py, andtests/test_native_events_writer.py. git diff --check a7fd389..bf9954apassed, and no conflict markers were found.- Review coverage included correctness, security, testing, maintainability, API-contract, reliability, adversarial, and prior-comment verification. The single P1 was reproduced offline and passed a fresh independent validation. No cross-model pass ran because the GitHub PR is cross-repository; the in-process adversarial route was used.
- No live BigQuery call, GitHub post, push, commit, branch change, worktree edit, process termination, merge, or Week 1 action was performed. The only worktree status is the instructed-to-ignore untracked
.venv.
What can wait
P2 polish and file decomposition are not blockers and are not reported as findings. Presenter/demo work from #468, #465, and #462 remains out of scope. Live BigQuery validation, clock activation, preregistration changes, Week 1 execution, and unrelated cleanup must wait.
Verdict
REQUEST_CHANGES. The r5 P0 is closed, but finding #1 must be fixed so the span publisher cannot overwrite a copied or foreign same-job view based only on that view's self-asserted pin.
Actionable recap
- #1 P1 --
src/bigquery_agent_analytics/native_events.py:516: authenticate the existing pinned span view against expected references and committed manifest generation before any replacement; add the copied-view regression.
…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.
…ogleCloudPlatform#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 GoogleCloudPlatform#469 above the GoogleCloudPlatform#466 entry. Offline fixture tests only; clock stays off; production agent_events is never written; the evalbench-import adapter (GoogleCloudPlatform#97) stays.
…oogleCloudPlatform#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 GoogleCloudPlatform#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 GoogleCloudPlatform#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.
…ogleCloudPlatform#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).
…loudPlatform#469) Codex r4 on PR GoogleCloudPlatform#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.
…oogleCloudPlatform#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.
…oogleCloudPlatform#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.
8950d31 to
887cdef
Compare
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
PR 470 re-review (r9)
Verdict: REQUEST_CHANGES
P0 count: 0
P1 count: 1
P2 count: 0 (informational)
HEAD: 887cdef1a95f49d7e35e807a7381915c04770698 (887cdef)
Prior r6 finding after rebase: CLOSED
Prior r6 finding
- CLOSED — pinned span-view ownership.
_read_managed_span_viewnow authenticates the pin against the caller-derived span-label and manifest references, re-renders the canonical body from those trusted references, and verifies the claimed generation against the committed manifest row's current or superseded generations (src/bigquery_agent_analytics/native_events.py:483,src/bigquery_agent_analytics/native_events.py:529,src/bigquery_agent_analytics/native_events.py:543,src/bigquery_agent_analytics/native_events.py:559).test_copied_self_consistent_pinned_view_is_refused_and_unchangedcovers foreign references, an unpublished version, and an uncommitted generation, and verifies refusal without changing the copied view or publishing rows (tests/test_native_span_labels.py:876). The r6 P1 remains closed on887cdefafter the rebase.
Findings
1. P1 — A delayed old-version span resync can regress the newer binding policy
Location: src/bigquery_agent_analytics/native_events.py:277 (related: src/bigquery_agent_analytics/native_events.py:297, src/bigquery_agent_analytics/native_events.py:1168, src/bigquery_agent_analytics/native_events.py:1297)
_SPAN_SYNC_SCRIPT verifies the retained version's manifest generation and policy, but its binding guard rejects only a different span table. It then unconditionally deletes and reinserts the same job's binding with the caller's policy, import version, and generation. This leaves a race after the base publish's binding guard has already completed:
- A v1 maintenance call pre-reads the goal-only binding, completes
super().materialize()under that exact guard, and pauses before_publish_span_labels. - A v2 call explicitly commits and synchronizes a richer policy, so both the v2 manifest and binding contain that richer gate.
- The delayed v1 sync resumes. Its retained v1 manifest still matches its own goal-only policy and generation, the same-table guard passes, and lines 297-302 replace the v2 binding with the old v1 policy and generation. The view reconciliation correctly declines to repin the view because v1 is not latest, but it does not restore the binding.
- A later ordinary v2 call with no policy reads the stale goal-only binding and recommits the v2 manifest from the richer gate back to the old gate, changing the active failed-session denominator.
A deterministic offline interleaving reproduced the sequence: the binding was rich/v2 after step 2, goal-only/v1 after step 3, and the next no-policy v2 call changed the v2 manifest from the rich policy to goal-only. The independent validation pass confirmed the post-base transaction ordering. Existing coverage pauses a stale caller before the base guard or resyncs an older version with the same policy; neither exercises this post-base, policy-changing interleaving.
Required response: Carry the span-binding state observed by the call into _sync_span_labels and revalidate it inside _SPAN_SYNC_SCRIPT before any span-row or binding DML. At minimum, the committed same-table policy must still match the pre-read policy; validating the complete pre-read binding row (table, policy, import version, and generation) is the safer invariant. Keep those pre-read values separate from the new policy/generation being installed so an intentional explicit policy change can replace the state it actually observed. Add a regression that pauses v1 after its base publish, completes a richer-policy v2 sync, resumes v1, and verifies that v1 fails closed while the v2 binding and a later no-policy v2 call retain the richer policy.
Confidence: 75/100 — direct code trace, deterministic offline reproduction, and independent validation; no live BigQuery was used.
Scope and verification
- The local and GitHub PR heads are
887cdef; the GitHub base is merged #467 squash3222207aa3a04d27e94d70c2b17d798f4f952d5e. Local and GitHub diffs have the same stable patch ID. git diff 3222207..HEAD,git log 3222207..HEAD,gh pr view 470, andgh pr diff 470were reviewed. The PR contains the seven stated unique commits and only the seven in-scope files. No stale #467 ancestry, forbidden #468/#465/#462 commits, leftover stack files, or conflict markers were found.- The frozen widget-stock fixture, three G1 categories, real span ID,
gap_after_span, first-eight collision fallback, fail-closed no-span path,label_native_runreuse, goal-completion gate, durable failed-sessions maintenance, exact_SpanBindingStatetype check, and retained CHANGELOG bullets remain present. git diff --check 3222207..HEADpassed.- Offline tests passed: 196 targeted importer/CLI/span-label tests plus 40 span-taxonomy/native-writer tests (236 total). No live BigQuery,
--synth, productionagent_eventswrite, GitHub write, push, amend, or merge was performed.
What can wait
There are no P2 findings. Live-BigQuery validation and the out-of-scope #468/#465/#462 demo or presenter work can wait; the clock and Week 1 remain off. The P1 binding race cannot wait because it can change the committed denominator policy after a successful newer publication.
Actionable recap
- P1 —
src/bigquery_agent_analytics/native_events.py:277: revalidate the pre-read binding state inside the span-sync transaction before DML, and add the delayed-v1/richer-v2 regression.
Final verdict: REQUEST_CHANGES. The prior r6 finding is closed; fix the one new P1 above.
…gleCloudPlatform#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
left a comment
There was a problem hiding this comment.
Reviewer: Kimi
PR #470 r10 review — P1-r7 ("revalidate pre-read span binding under sync lock")
- PR: #470
- Issue: #469 (parent #435)
- HEAD:
db05e2357cd57ab32e8f44172746da729b27b652(db05e23) - Reviewed:
git diff 887cdef..HEAD— exactly one commit, +151/-0, two files:src/bigquery_agent_analytics/native_events.py(+74)tests/test_native_span_labels.py(+77)
- Scope: clean. No 468/465/462 commits in
887cdef..HEAD. GitHub's 456–467 file
list vs main is stacking on merged #467 squash 3222207 — expected, not a P0.
Untracked.venvignored as instructed.
Verdict: LGTM / APPROVE
- Verdict: LGTM / APPROVE
- P0 count: 0
- P1 count: 0
- P2 count: 1 (non-blocking, test-fidelity note below)
- P0: 0
- P1: 0
- P2: 1 (non-blocking, test-fidelity note below)
- r9 P1 (delayed old-version span resync regresses a newer binding policy): CLOSED.
r9 P1 closure — each required property verified
-
Revalidation inside the transaction, before any span-row or binding DML.
native_events.py:311-329adds the@observed_binding_boundguard to
_SPAN_SYNC_SCRIPTimmediately after the lock claim, manifest re-check
(stale-pin), same-table (_SPAN_BINDING_CONFLICT_MESSAGE) and
cross-job (_SPAN_TABLE_OWNED_MESSAGE) guards — and strictly before the
first DML (DELETE FROM {span_labels_table}atnative_events.py:330).
The whole script runs underBEGIN TRANSACTIONwith
EXCEPTION WHEN ERROR THEN ROLLBACK(native_events.py:341-344), so a
RAISEhere leaves span rows and the binding byte-identical. The new
regression test even asserts the ordering structurally in the fake:
tests/test_native_span_labels.py:243-245
(script.index("@observed_generation_id") < script.index("DELETE FROM \")`). -
Delayed v1 sync fails closed; v2 binding and a later no-policy v2 call
retain the richer policy.
test_delayed_old_version_resync_cannot_regress_the_binding
(tests/test_native_span_labels.py:1485-1524) models the exact r9 race: v1
publishes, pauses viadoctor_native_manifest_readright before the span
sync's manifest re-read; the richer-policy v2 publish + sync land in the
gap; v1 resumes. Its manifest guard passes (its own retained manifest row
still carries v1's generation/policy — the reason the r4-r6 guards could
not see this), the same-table guard passes, and the new observed-binding
guard raises_SPAN_BINDING_REGRESSED_MESSAGEbecause the committed
binding (v2) no longer matches v1's pre-read. Assertions confirm: the
surviving binding is v2 with the merged richer policy, and a subsequent
ordinary no-policy v2 call returnsunchangedand restores the gate from
the binding (never recommits the old goal-only gate).
The wrapped error message (native_events.py:1315-1323) tells the caller
nothing was written and to re-runmaterialize()— correct fail-closed UX. -
Pre-read values stay separate from the policy/generation being installed.
The observed state travels as five dedicated parameters
(observed_binding_bound,observed_span_labels_table,
observed_view_policy,observed_import_version,
observed_generation_id) appended atnative_events.py:1272-1287,
disjoint fromexpected_view_policy/expected_generation_idthat the
INSERT installs (native_events.py:336-339). A deliberate explicit policy
change therefore still works: the committed state equals the pre-read
(nobody raced), the guard passes, and the binding is replaced with exactly
the new resolved policy. Verified by the pre-existing deliberate-change
tests still passing (56/56 in the file). -
Regression test exists for the pause / v2-complete / v1-resume race.
Yes — see (2). It exercises the race through the real script template
(the fake emulates_SPAN_SYNC_SCRIPTsemantics, including the new guard,
attests/test_native_span_labels.py:239-269) and asserts both the
fail-closed raise and the post-race steady state.
Test evidence (offline, fake clients — no live BQ touched):
tests/test_native_span_labels.py: 56 passed, including the new test run
individually (1 passed).tests/test_evalbench_importer.py+tests/test_native_events_writer.py:
155 passed (inherited publish machinery untouched).
Explicitly not regressed (r4-r6 held closed)
- r4 exact-class
span_binding(_SpanBindingStatestructured state in
evalbench): untouched — the diff adds nothing toevalbench.pyand
_span_binding_state(native_events.py:695-718) is unchanged. - r5 policy recommit lock: unchanged; the recommit guard still revalidates
table+policy inside the serialized boundary. - r6 cross-job span-table ownership (
_SPAN_TABLE_OWNED_MESSAGE): unchanged
and still ordered before any DML. - Authenticated pinned view /
_read_managed_span_view: untouched. - Public
binding_guard: not restored (no occurrence in the diff). span_taxonomy.pyuntouched;label_native_runnot reimplemented.
P0 tripwires: all clear
- No live BQ (review was static + offline fake-client tests only; the change
itself adds no new network path — parameters on the existing sync query). - No writes to production
agent_events(destination/self-feed validation
untouched;_parse_source_tableagent_events-only rule intact). - Clock stays off — nothing in the diff touches preregistration/snapshot
scheduling. - No 468/465/462 commits; no conflict markers in the diff; no secrets
(diff contains only Python source and tests).
P2 (non-blocking, can wait)
tests/test_native_span_labels.py:247-269: the fake's new
binding-regression emulation reads liveself.span_bindingsrather than
the pinnedbinding_transaction_snapshotthe r4 overlap tests use for the
other in-transaction guards. Fine for the sequential race this test models,
but a future test that wants to model the regressed guard under a
mutually-stale snapshot would need the fake to honor the snapshot here too.
Test-harness fidelity only; the production script reads committed state
inside the transaction, which is correct.
What can wait
- The P2 above.
- No docs/changelog updates are required by this guard beyond what the
docstring/comment additions already carry; any user-facing wording for the
new re-run guidance can ride a later docs pass.
Bottom line: the r9 P1 is genuinely closed — the guard is in the right
transaction, in the right order, with observed state cleanly separated from
installed state, and a regression test pins the exact race. Ship it.
caohy1988
left a comment
There was a problem hiding this comment.
Reviewer: Codex
PR 470 r10 Review
Verdict: LGTM / APPROVE
P0 count: 0
P1 count: 0
P2 count: 0
HEAD: db05e23 (db05e23)
Scope: 887cdef..db05e23
Counts
- P0: 0
- P1: 0
- P2: 0
Findings
No P0 or P1 findings.
r9 P1 status
Closed.
- src/bigquery_agent_analytics/native_events.py:311 revalidates the exact pre-read binding inside the lock transaction. The bound path compares table, canonical policy, import version, and generation. The unbound path requires the job to remain unbound.
- src/bigquery_agent_analytics/native_events.py:330 shows the first span-row DML. Binding DML starts at line 334. Both occur only after the new guard.
- src/bigquery_agent_analytics/native_events.py:1255 and src/bigquery_agent_analytics/native_events.py:1275 keep replacement expected_generation_id / expected_view_policy separate from observed_binding_* values. The new policy and generation are not reused as the pre-read state.
- tests/test_native_span_labels.py:1485 adds the requested pause/v2-complete/v1-resume regression. The delayed v1 call fails closed at line 1509. Lines 1512-1514 verify that the v2 binding and richer policy remain. Lines 1517-1523 verify that a later no-policy v2 call keeps the richer policy.
Scope and guardrails
- git log 887cdef..HEAD contains only db05e23, the P1-r7 fix commit.
- The scoped diff changes only src/bigquery_agent_analytics/native_events.py and tests/test_native_span_labels.py.
- Commits from 468, 465, and 462 are not in scope. Untracked .venv was ignored.
- No conflict markers or committed secret indicators were found.
- No live BigQuery was used. The diff does not write production agent_events and does not start the clock.
- Previously closed r4-r6 controls remain intact. The public binding_guard was not restored. span_taxonomy.py and label_native_run were not changed.
Validation
- tests/test_native_span_labels.py: 56 passed.
- tests/test_native_events_writer.py plus tests/test_cli_evalbench_native_import.py: 28 passed.
- Ruff on the two changed files: passed.
- Correctness, reliability, prior-feedback, testing, and independent cross-model review produced no retained P0/P1 findings. The independent review used Claude Opus 5 through the Claude route; model identity was received, effort receipt remained unverified.
- No validator batch was needed because no P0/P1 or downstream-actionable finding survived synthesis.
What can wait
- Optional test hardening can directly exercise the unbound stale-pre-read branch at src/bigquery_agent_analytics/native_events.py:323 and assert the branch-specific translated error at tests/test_native_span_labels.py:1509. The production branch already fails closed, and the exact r9 bound-v1/v2 regression is covered. This is not a blocker.
- Live BigQuery confirmation remains outside this review by instruction.
Actionable Findings
None.
Verdict
LGTM / APPROVE. The r9 P1 is closed at db05e23. The delayed v1 sync cannot replace the newer v2 binding or regress the later no-policy v2 call.
Actionable findings: none.
|
Update complete at
A normal squash-merge attempt was blocked by main’s required approving review (repository ruleset 15027376). Ready for that review. Validation remains offline; no live BigQuery execution or judge calls were made. |
…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.
Native snapshots currently expose session-level failures but do not persist the span labels needed for drill-down. Adds opt-in
span_labels_tablesupport toNativeAgentEventsRun.materialize()and--span-labels-tabletoevalbench-native-import.The final implementation:
Base snapshot publication and derived span synchronization are separate steps. If synchronization fails after the base commits, the call reports that partial completion; the pinned view excludes stale labels and rerunning the import retries synchronization.
Updated against main, including #456/#457, with the changelog conflict resolved. No persistence logic changed during this refresh.
Validation: 228 focused importer, span-label, native-writer, and CLI tests passed;
git diff --checkpassed. Tests cover the offline transaction model, policy/binding races, generation guards, retries, view ownership, and source protections. No live BigQuery execution or judge calls were performed. CI runs on the updated head.Refs #469, #435.