mirror of
https://github.com/openai/codex.git
synced 2026-04-26 07:35:29 +00:00
## Why Guardian review analytics needs a Rust event shape that matches the backend schema while avoiding unnecessary PII exposure from reviewed tool calls. This PR narrows the analytics payload to the fields we intend to emit and keeps shared Guardian assessment enums in protocol instead of duplicating equivalent analytics-only enums. ## What changed - Uses protocol Guardian enums directly for `risk_level`, `user_authorization`, `outcome`, and command source values. - Removes high-risk reviewed-action fields from the analytics payload, including raw commands, display strings, working directories, file paths, network targets/hosts, justification text, retry reason, and rationale text. - Makes `target_item_id` and `tool_call_count` nullable so the Codex event can represent cases where the app-server protocol or producer does not have those values. - Keeps lower-risk structured reviewed-action metadata such as sandbox permissions, permission profile, `tty`, `execve` source/program, network protocol/port, and MCP connector/tool labels. - Adds an analytics reducer/client test covering `codex_guardian_review` serialization with an optional `target_item_id` and absent removed fields. ## Verification - `cargo test -p codex-analytics guardian_review_event_ingests_custom_fact_with_optional_target_item` - `cargo fmt --check` --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/17692). * #17696 * #17695 * #17693 * __->__ #17692
52 lines
1.5 KiB
Rust
52 lines
1.5 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::GuardianReviewDecision;
|
|
pub use events::GuardianReviewEventParams;
|
|
pub use events::GuardianReviewFailureReason;
|
|
pub use events::GuardianReviewSessionKind;
|
|
pub use events::GuardianReviewTerminalStatus;
|
|
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()
|
|
}
|