Skip to content

[codex-analytics] prevent stale guardian events from satisfying reused reviews#20080

Merged
rhan-oai merged 1 commit intomainfrom
rhan/guardian-analytics-reuse-fix
Apr 30, 2026
Merged

[codex-analytics] prevent stale guardian events from satisfying reused reviews#20080
rhan-oai merged 1 commit intomainfrom
rhan/guardian-analytics-reuse-fix

Conversation

@rhan-oai
Copy link
Copy Markdown
Collaborator

@rhan-oai rhan-oai commented Apr 28, 2026

Why

Reused Guardian review trunks can still have older child-turn events queued when a later review starts. The review waiter currently accepts the first terminal event it sees from the shared child session, so a stale TurnComplete can be attributed to the new review. That produces impossible analytics combinations such as non-null TTFT with sub-10 ms completion latency and zero token deltas on trunk_reused reviews.

What changed

  • Preserve the child turn id returned by the Guardian review Op::UserTurn submission.
  • Restrict Guardian review waiting to events correlated with that submitted child turn.
  • Restrict timeout/abort draining to terminal events for the same child turn.
  • Add regression coverage for stale prior-turn completions, stale prior-turn errors, and interrupt draining in codex-rs/core/src/guardian/review_session.rs.

Verification

  • cargo test -p codex-core guardian::review_session::tests::
  • cargo clippy -p codex-core --tests -- -D warnings

@rhan-oai rhan-oai changed the title [codex-analytics] fix guardian reused review attribution [codex-analytics] prevent stale guardian events from satisfying reused reviews Apr 28, 2026
@rhan-oai rhan-oai force-pushed the rhan/guardian-analytics-reuse-fix branch from 52cb786 to d1d02d5 Compare April 28, 2026 20:43
@rhan-oai rhan-oai marked this pull request as ready for review April 28, 2026 21:02
@rhan-oai rhan-oai requested a review from a team as a code owner April 28, 2026 21:02
@rhan-oai rhan-oai requested a review from dylan-hurd-oai April 28, 2026 21:02
Copy link
Copy Markdown
Collaborator

@dylan-hurd-oai dylan-hurd-oai left a comment

Choose a reason for hiding this comment

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

Can we add an integration test for this?

@rhan-oai rhan-oai force-pushed the rhan/guardian-analytics-reuse-fix branch from d1d02d5 to 1bd6754 Compare April 29, 2026 21:14
@rhan-oai rhan-oai requested a review from dylan-hurd-oai April 29, 2026 21:40
@rhan-oai rhan-oai merged commit bb536d6 into main Apr 30, 2026
25 checks passed
@rhan-oai rhan-oai deleted the rhan/guardian-analytics-reuse-fix branch April 30, 2026 01:26
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants