Skip to content

[codex-analytics] guardian review TTFT plumbing and emission#17696

Merged
rhan-oai merged 1 commit intomainfrom
pr17696
Apr 22, 2026
Merged

[codex-analytics] guardian review TTFT plumbing and emission#17696
rhan-oai merged 1 commit intomainfrom
pr17696

Conversation

@rhan-oai
Copy link
Copy Markdown
Collaborator

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

Why

Guardian analytics includes time-to-first-token, but the Guardian reviewer runs as a normal Codex session and TurnCompleteEvent did not expose TTFT. The timing needs to flow through the standard turn-completion protocol so Guardian review analytics can consume the same value as the rest of the session machinery.

What changed

Adds optional time_to_first_token_ms to TurnCompleteEvent and populates it from TurnTiming. The value is carried through app-server thread history, rollout reconstruction, TUI/app-server adapters, and Guardian review session handling.

Guardian review analytics now captures TTFT from the reviewer turn-complete event when available. Existing tests and fixtures are updated to set the new optional field to None where TTFT is not relevant.

Verification

  • cargo clippy -p codex-tui --tests -- -D warnings
  • cargo clippy -p codex-core --lib --tests -- -D warnings

Stack created with Sapling. Best reviewed with ReviewStack.

@rhan-oai rhan-oai force-pushed the pr17696 branch 7 times, most recently from cb88f6d to 6d298bc Compare April 21, 2026 06:15
@rhan-oai rhan-oai changed the base branch from main to pr17695 April 21, 2026 06:43
@rhan-oai rhan-oai changed the base branch from pr17695 to main April 21, 2026 21:58
@rhan-oai rhan-oai changed the base branch from main to pr17695 April 21, 2026 23:38
@rhan-oai rhan-oai changed the base branch from pr17695 to main April 22, 2026 00:28
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d73e1d1e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@rhan-oai rhan-oai force-pushed the pr17696 branch 4 times, most recently from 115e856 to 07fe8ff Compare April 22, 2026 07:03
@openai openai deleted a comment from chatgpt-codex-connector Bot Apr 22, 2026
@rhan-oai rhan-oai changed the base branch from main to pr17695 April 22, 2026 07:26
rhan-oai added a commit that referenced this pull request Apr 22, 2026
## Why

Guardian approvals now run as review sessions, but Codex analytics did
not have a terminal event for those reviews. That made it hard to
measure approval outcomes, failure modes, Guardian session reuse, model
metadata, token usage, and timing separately from the parent turn.

## What changed

Adds `codex_guardian_review` analytics emission for Guardian approval
reviews. The event is emitted from the Guardian review path with review
identity, target item id, approval request source, a PII-minimized
reviewed-action shape, terminal decision/status, failure reason,
Guardian assessment fields, Guardian session metadata, token usage, and
timing metadata.

The reviewed-action payload intentionally omits high-risk fields such as
shell commands, working directories, argv, file paths, network
targets/hosts, rationale, retry reason, and permission justifications.
It also classifies prompt-build failures separately from Guardian
session/runtime failures so fail-closed cases are distinguishable in
analytics.

## Verification

- Guardian review analytics tests cover terminal success,
timeout/cancel/fail-closed paths, session metadata, and token usage
plumbing.
- `cargo clippy -p codex-core --lib --tests -- -D warnings`

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/17693).
* #17696
* #17695
* __->__ #17693
@rhan-oai rhan-oai changed the base branch from pr17695 to main April 22, 2026 08:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants