mirror of
https://github.com/openai/codex.git
synced 2026-04-27 08:05:51 +00:00
## 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
54 lines
1.6 KiB
Rust
54 lines
1.6 KiB
Rust
mod client;
|
|
mod events;
|
|
mod facts;
|
|
mod reducer;
|
|
|
|
use std::time::SystemTime;
|
|
use std::time::UNIX_EPOCH;
|
|
|
|
pub use client::AnalyticsEventsClient;
|
|
pub use events::AppServerRpcTransport;
|
|
pub use events::GuardianApprovalRequestSource;
|
|
pub use events::GuardianReviewAnalyticsResult;
|
|
pub use events::GuardianReviewDecision;
|
|
pub use events::GuardianReviewEventParams;
|
|
pub use events::GuardianReviewFailureReason;
|
|
pub use events::GuardianReviewSessionKind;
|
|
pub use events::GuardianReviewTerminalStatus;
|
|
pub use events::GuardianReviewTrackContext;
|
|
pub use events::GuardianReviewedAction;
|
|
pub use facts::AnalyticsJsonRpcError;
|
|
pub use facts::AppInvocation;
|
|
pub use facts::CodexCompactionEvent;
|
|
pub use facts::CodexTurnSteerEvent;
|
|
pub use facts::CompactionImplementation;
|
|
pub use facts::CompactionPhase;
|
|
pub use facts::CompactionReason;
|
|
pub use facts::CompactionStatus;
|
|
pub use facts::CompactionStrategy;
|
|
pub use facts::CompactionTrigger;
|
|
pub use facts::HookRunFact;
|
|
pub use facts::InputError;
|
|
pub use facts::InvocationType;
|
|
pub use facts::SkillInvocation;
|
|
pub use facts::SubAgentThreadStartedInput;
|
|
pub use facts::ThreadInitializationMode;
|
|
pub use facts::TrackEventsContext;
|
|
pub use facts::TurnResolvedConfigFact;
|
|
pub use facts::TurnStatus;
|
|
pub use facts::TurnSteerRejectionReason;
|
|
pub use facts::TurnSteerRequestError;
|
|
pub use facts::TurnSteerResult;
|
|
pub use facts::TurnTokenUsageFact;
|
|
pub use facts::build_track_events_context;
|
|
|
|
#[cfg(test)]
|
|
mod analytics_client_tests;
|
|
|
|
pub fn now_unix_seconds() -> u64 {
|
|
SystemTime::now()
|
|
.duration_since(UNIX_EPOCH)
|
|
.unwrap_or_default()
|
|
.as_secs()
|
|
}
|