[codex] reduce module visibility (#16978)

## Summary
- reduce public module visibility across Rust crates, preferring private
or crate-private modules with explicit crate-root public exports
- update external call sites and tests to use the intended public crate
APIs instead of reaching through module trees
- add the module visibility guideline to AGENTS.md

## Validation
- `cargo check --workspace --all-targets --message-format=short` passed
before the final fix/format pass
- `just fix` completed successfully
- `just fmt` completed successfully
- `git diff --check` passed
This commit is contained in:
pakrym-oai
2026-04-07 08:03:35 -07:00
committed by GitHub
parent 89f1a44afa
commit 413c1e1fdf
129 changed files with 695 additions and 496 deletions
+5 -5
View File
@@ -85,13 +85,14 @@ use codex_app_server_protocol::TurnError as AppServerTurnError;
use codex_app_server_protocol::TurnStatus;
use codex_config::types::ApprovalsReviewer;
use codex_config::types::ModelAvailabilityNuxConfig;
use codex_core::append_message_history_entry;
use codex_core::config::Config;
use codex_core::config::ConfigBuilder;
use codex_core::config::ConfigOverrides;
use codex_core::config::edit::ConfigEdit;
use codex_core::config::edit::ConfigEditsBuilder;
use codex_core::config_loader::ConfigLayerStackOrdering;
use codex_core::message_history;
use codex_core::lookup_message_history_entry;
#[cfg(target_os = "windows")]
use codex_core::windows_sandbox::WindowsSandboxLevelExt;
use codex_features::Feature;
@@ -2159,8 +2160,7 @@ impl App {
let text = text.clone();
let config = self.chat_widget.config_ref().clone();
tokio::spawn(async move {
if let Err(err) =
message_history::append_entry(&text, &thread_id, &config).await
if let Err(err) = append_message_history_entry(&text, &thread_id, &config).await
{
tracing::warn!(
thread_id = %thread_id,
@@ -2178,7 +2178,7 @@ impl App {
let app_event_tx = self.app_event_tx.clone();
tokio::spawn(async move {
let entry_opt = tokio::task::spawn_blocking(move || {
message_history::lookup(log_id, offset, &config)
lookup_message_history_entry(log_id, offset, &config)
})
.await
.unwrap_or_else(|err| {
@@ -4693,7 +4693,7 @@ impl App {
tokio::task::spawn_blocking(move || {
let requested_path = PathBuf::from(path);
let event = match codex_core::windows_sandbox_read_grants::grant_read_root_non_elevated(
let event = match codex_core::grant_read_root_non_elevated(
&policy,
policy_cwd.as_path(),
command_cwd.as_path(),
+6 -4
View File
@@ -63,8 +63,10 @@ use codex_app_server_protocol::TurnStartParams;
use codex_app_server_protocol::TurnStartResponse;
use codex_app_server_protocol::TurnSteerParams;
use codex_app_server_protocol::TurnSteerResponse;
#[cfg(test)]
use codex_core::append_message_history_entry;
use codex_core::config::Config;
use codex_core::message_history;
use codex_core::message_history_metadata;
use codex_otel::TelemetryAuthMode;
use codex_protocol::ThreadId;
use codex_protocol::openai_models::ModelAvailabilityNux;
@@ -1076,7 +1078,7 @@ async fn thread_session_state_from_thread_response(
.map(ThreadId::from_string)
.transpose()
.map_err(|err| format!("forked_from_id is invalid: {err}"))?;
let (history_log_id, history_entry_count) = message_history::history_metadata(config).await;
let (history_log_id, history_entry_count) = message_history_metadata(config).await;
let history_entry_count = u64::try_from(history_entry_count).unwrap_or(u64::MAX);
Ok(ThreadSessionState {
@@ -1316,10 +1318,10 @@ mod tests {
let config = build_config(&temp_dir).await;
let thread_id = ThreadId::new();
message_history::append_entry("older", &thread_id, &config)
append_message_history_entry("older", &thread_id, &config)
.await
.expect("history append should succeed");
message_history::append_entry("newer", &thread_id, &config)
append_message_history_entry("newer", &thread_id, &config)
.await
.expect("history append should succeed");
@@ -1,5 +1,5 @@
use codex_feedback::feedback_diagnostics::FEEDBACK_DIAGNOSTICS_ATTACHMENT_FILENAME;
use codex_feedback::feedback_diagnostics::FeedbackDiagnostics;
use codex_feedback::FEEDBACK_DIAGNOSTICS_ATTACHMENT_FILENAME;
use codex_feedback::FeedbackDiagnostics;
use crossterm::event::KeyCode;
use crossterm::event::KeyEvent;
use crossterm::event::KeyModifiers;
@@ -556,7 +556,7 @@ mod tests {
use super::*;
use crate::app_event::AppEvent;
use crate::app_event_sender::AppEventSender;
use codex_feedback::feedback_diagnostics::FeedbackDiagnostic;
use codex_feedback::FeedbackDiagnostic;
use pretty_assertions::assert_eq;
fn render(view: &FeedbackNoteView, width: u16) -> String {
+2 -2
View File
@@ -76,7 +76,7 @@ pub(crate) struct MentionBinding {
mod chat_composer;
mod chat_composer_history;
mod command_popup;
pub mod custom_prompt_view;
pub(crate) mod custom_prompt_view;
mod experimental_features_view;
mod file_search_popup;
mod footer;
@@ -108,7 +108,7 @@ pub(crate) use title_setup::TerminalTitleSetupView;
mod paste_burst;
mod pending_input_preview;
mod pending_thread_approvals;
pub mod popup_consts;
pub(crate) mod popup_consts;
mod scroll_state;
mod selection_popup_common;
mod textarea;
+1 -1
View File
@@ -95,13 +95,13 @@ use codex_chatgpt::connectors;
use codex_config::types::ApprovalsReviewer;
use codex_config::types::Notifications;
use codex_config::types::WindowsSandboxModeToml;
use codex_core::DEFAULT_PROJECT_DOC_FILENAME;
use codex_core::config::Config;
use codex_core::config::Constrained;
use codex_core::config::ConstraintResult;
use codex_core::config_loader::ConfigLayerStackOrdering;
use codex_core::find_thread_name_by_id;
use codex_core::plugins::PluginsManager;
use codex_core::project_doc::DEFAULT_PROJECT_DOC_FILENAME;
use codex_core::skills::model::SkillMetadata;
#[cfg(target_os = "windows")]
use codex_core::windows_sandbox::WindowsSandboxLevelExt;
+1 -1
View File
@@ -13,8 +13,8 @@ use crate::bottom_pane::popup_consts::standard_popup_hint_line;
use crate::skills_helpers::skill_description;
use crate::skills_helpers::skill_display_name;
use codex_chatgpt::connectors::AppInfo;
use codex_core::TOOL_MENTION_SIGIL;
use codex_core::connectors::connector_mention_slug;
use codex_core::mention_syntax::TOOL_MENTION_SIGIL;
use codex_core::skills::model::SkillDependencies;
use codex_core::skills::model::SkillInterface;
use codex_core::skills::model::SkillMetadata;
@@ -1761,13 +1761,11 @@ async fn feedback_upload_consent_popup_snapshot() {
chat.app_event_tx.clone(),
crate::app_event::FeedbackCategory::Bug,
chat.current_rollout_path.clone(),
&codex_feedback::feedback_diagnostics::FeedbackDiagnostics::new(vec![
codex_feedback::feedback_diagnostics::FeedbackDiagnostic {
headline: "Proxy environment variables are set and may affect connectivity."
.to_string(),
details: vec!["HTTPS_PROXY = hello".to_string()],
},
]),
&codex_feedback::FeedbackDiagnostics::new(vec![codex_feedback::FeedbackDiagnostic {
headline: "Proxy environment variables are set and may affect connectivity."
.to_string(),
details: vec!["HTTPS_PROXY = hello".to_string()],
}]),
));
let popup = render_bottom_popup(&chat, /*width*/ 80);
@@ -1782,13 +1780,11 @@ async fn feedback_good_result_consent_popup_includes_connectivity_diagnostics_fi
chat.app_event_tx.clone(),
crate::app_event::FeedbackCategory::GoodResult,
chat.current_rollout_path.clone(),
&codex_feedback::feedback_diagnostics::FeedbackDiagnostics::new(vec![
codex_feedback::feedback_diagnostics::FeedbackDiagnostic {
headline: "Proxy environment variables are set and may affect connectivity."
.to_string(),
details: vec!["HTTPS_PROXY = hello".to_string()],
},
]),
&codex_feedback::FeedbackDiagnostics::new(vec![codex_feedback::FeedbackDiagnostic {
headline: "Proxy environment variables are set and may affect connectivity."
.to_string(),
details: vec!["HTTPS_PROXY = hello".to_string()],
}]),
));
let popup = render_bottom_popup(&chat, /*width*/ 80);
+5 -5
View File
@@ -42,14 +42,14 @@ use base64::Engine;
use codex_app_server_protocol::McpServerStatus;
use codex_app_server_protocol::McpServerStatusDetail;
use codex_config::types::McpServerTransportConfig;
#[cfg(test)]
use codex_core::McpManager;
use codex_core::config::Config;
#[cfg(test)]
use codex_core::mcp::McpManager;
#[cfg(test)]
use codex_core::plugins::PluginsManager;
use codex_core::web_search::web_search_detail;
use codex_core::web_search_detail;
#[cfg(test)]
use codex_mcp::mcp::qualified_mcp_tool_name_prefix;
use codex_mcp::qualified_mcp_tool_name_prefix;
use codex_otel::RuntimeMetricsSummary;
use codex_protocol::account::PlanType;
use codex_protocol::config_types::ServiceTier;
@@ -70,7 +70,7 @@ use codex_protocol::protocol::SessionConfiguredEvent;
use codex_protocol::request_user_input::RequestUserInputAnswer;
use codex_protocol::request_user_input::RequestUserInputQuestion;
use codex_protocol::user_input::TextElement;
use codex_utils_cli::format_env_display::format_env_display;
use codex_utils_cli::format_env_display;
use image::DynamicImage;
use image::ImageReader;
use ratatui::prelude::*;
+11 -7
View File
@@ -102,7 +102,8 @@ mod clipboard_paste;
mod clipboard_text;
mod collaboration_modes;
mod color;
pub mod custom_terminal;
pub(crate) mod custom_terminal;
pub use custom_terminal::Terminal;
mod cwd_prompt;
mod debug_config;
mod diff_render;
@@ -113,10 +114,12 @@ mod file_search;
mod frames;
mod get_git_diff;
mod history_cell;
pub mod insert_history;
pub(crate) mod insert_history;
pub use insert_history::insert_history_lines;
mod key_hint;
mod line_truncation;
pub mod live_wrap;
pub(crate) mod live_wrap;
pub use live_wrap::RowBuilder;
mod local_chatgpt_auth;
mod markdown;
mod markdown_render;
@@ -126,10 +129,10 @@ mod model_catalog;
mod model_migration;
mod multi_agents;
mod notifications;
pub mod onboarding;
pub(crate) mod onboarding;
mod oss_selection;
mod pager_overlay;
pub mod public_widgets;
pub(crate) mod public_widgets;
mod render;
mod resume_picker;
mod selection_list;
@@ -148,7 +151,8 @@ mod theme_picker;
mod tooltips;
mod tui;
mod ui_consts;
pub mod update_action;
pub(crate) mod update_action;
pub use update_action::UpdateAction;
mod update_prompt;
mod updates;
mod version;
@@ -212,7 +216,7 @@ mod voice {
mod wrapping;
#[cfg(test)]
pub mod test_backend;
pub(crate) mod test_backend;
#[cfg(test)]
pub(crate) mod test_support;
+2 -2
View File
@@ -1,8 +1,8 @@
use std::collections::HashMap;
use std::collections::VecDeque;
use codex_core::mention_syntax::PLUGIN_TEXT_MENTION_SIGIL;
use codex_core::mention_syntax::TOOL_MENTION_SIGIL;
use codex_core::PLUGIN_TEXT_MENTION_SIGIL;
use codex_core::TOOL_MENTION_SIGIL;
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct LinkedMention {
+1 -2
View File
@@ -1,6 +1,5 @@
mod auth;
pub mod onboarding_screen;
pub(crate) mod onboarding_screen;
mod trust_directory;
pub(crate) use auth::mark_url_hyperlink;
pub use trust_directory::TrustDirectorySelection;
mod welcome;
+1 -1
View File
@@ -1 +1 @@
pub mod composer_input;
pub(crate) mod composer_input;
+3 -3
View File
@@ -1,8 +1,8 @@
use ratatui::layout::Rect;
pub mod highlight;
pub mod line_utils;
pub mod renderable;
pub(crate) mod highlight;
pub(crate) mod line_utils;
pub(crate) mod renderable;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Insets {
+1 -1
View File
@@ -4,7 +4,7 @@ use crate::text_formatting;
use chrono::DateTime;
use chrono::Local;
use codex_core::config::Config;
use codex_core::project_doc::discover_project_doc_paths;
use codex_core::discover_project_doc_paths;
use codex_exec_server::LOCAL_FS;
use codex_protocol::account::PlanType;
use codex_utils_absolute_path::AbsolutePathBuf;