TUI: enforce core boundary (#17399)

Problem: The TUI still depended on `codex-core` directly in a number of
places, and we had no enforcement from keeping this problem from getting
worse.

Solution: Route TUI core access through
`codex-app-server-client::legacy_core`, add CI enforcement for that
boundary, and re-export this legacy bridge inside the TUI as
`crate::legacy_core` so the remaining call sites stay readable. There is
no functional change in this PR — just changes to import targets.

Over time, we can whittle away at the remaining symbols in this legacy
namespace with the eventual goal of removing them all. In the meantime,
this linter rule will prevent us from inadvertently importing new
symbols from core.
This commit is contained in:
Eric Traut
2026-04-10 20:25:31 -07:00
committed by GitHub
parent 37aac89a6d
commit 66e13efd9c
35 changed files with 414 additions and 225 deletions

View File

@@ -3,6 +3,22 @@
// alternatescreen mode starts; that file optsout locally via `allow`.
#![deny(clippy::print_stdout, clippy::print_stderr)]
#![deny(clippy::disallowed_methods)]
use crate::legacy_core::check_execpolicy_for_warnings;
use crate::legacy_core::config::Config;
use crate::legacy_core::config::ConfigBuilder;
use crate::legacy_core::config::ConfigOverrides;
use crate::legacy_core::config::find_codex_home;
use crate::legacy_core::config::load_config_as_toml_with_cli_overrides;
use crate::legacy_core::config::resolve_oss_provider;
use crate::legacy_core::config_loader::CloudRequirementsLoader;
use crate::legacy_core::config_loader::ConfigLoadError;
use crate::legacy_core::config_loader::LoaderOverrides;
use crate::legacy_core::config_loader::format_config_error_with_source;
use crate::legacy_core::find_thread_meta_by_name_str;
use crate::legacy_core::format_exec_policy_error_with_source;
use crate::legacy_core::path_utils;
use crate::legacy_core::read_session_meta_line;
use crate::legacy_core::windows_sandbox::WindowsSandboxLevelExt;
use additional_dirs::add_dir_warning_message;
use app::App;
pub use app::AppExitInfo;
@@ -22,22 +38,6 @@ use codex_app_server_protocol::ThreadListParams;
use codex_app_server_protocol::ThreadSortKey as AppServerThreadSortKey;
use codex_app_server_protocol::ThreadSourceKind;
use codex_cloud_requirements::cloud_requirements_loader_for_storage;
use codex_core::check_execpolicy_for_warnings;
use codex_core::config::Config;
use codex_core::config::ConfigBuilder;
use codex_core::config::ConfigOverrides;
use codex_core::config::find_codex_home;
use codex_core::config::load_config_as_toml_with_cli_overrides;
use codex_core::config::resolve_oss_provider;
use codex_core::config_loader::CloudRequirementsLoader;
use codex_core::config_loader::ConfigLoadError;
use codex_core::config_loader::LoaderOverrides;
use codex_core::config_loader::format_config_error_with_source;
use codex_core::find_thread_meta_by_name_str;
use codex_core::format_exec_policy_error_with_source;
use codex_core::path_utils;
use codex_core::read_session_meta_line;
use codex_core::windows_sandbox::WindowsSandboxLevelExt;
use codex_exec_server::EnvironmentManager;
use codex_login::AuthConfig;
use codex_login::default_client::set_default_client_residency_requirement;
@@ -74,6 +74,8 @@ use tracing_subscriber::prelude::*;
use url::Url;
use uuid::Uuid;
pub(crate) use codex_app_server_client::legacy_core;
mod additional_dirs;
mod app;
mod app_backtrack;
@@ -166,7 +168,7 @@ mod voice;
#[allow(dead_code)]
mod voice {
use crate::app_event_sender::AppEventSender;
use codex_core::config::Config;
use crate::legacy_core::config::Config;
use codex_protocol::protocol::RealtimeAudioFrame;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
@@ -751,9 +753,11 @@ pub async fn run_main(
}
};
if let Err(err) =
codex_core::personality_migration::maybe_migrate_personality(&codex_home, &config_toml)
.await
if let Err(err) = crate::legacy_core::personality_migration::maybe_migrate_personality(
&codex_home,
&config_toml,
)
.await
{
tracing::warn!(error = %err, "failed to run personality migration");
}
@@ -870,7 +874,7 @@ pub async fn run_main(
}
}
let log_dir = codex_core::config::log_dir(&config)?;
let log_dir = crate::legacy_core::config::log_dir(&config)?;
std::fs::create_dir_all(&log_dir)?;
// Open (or create) your log file, appending to it.
let mut log_file_opts = OpenOptions::new();
@@ -931,7 +935,7 @@ pub async fn run_main(
}
let otel = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
codex_core::otel_init::build_provider(
crate::legacy_core::otel_init::build_provider(
&config,
env!("CARGO_PKG_VERSION"),
/*service_name_override*/ None,
@@ -1732,13 +1736,13 @@ fn should_show_login_screen(login_status: LoginStatus, config: &Config) -> bool
#[cfg(test)]
mod tests {
use super::*;
use crate::legacy_core::config::ConfigBuilder;
use crate::legacy_core::config::ConfigOverrides;
use codex_app_server_protocol::ClientRequest;
use codex_app_server_protocol::RequestId;
use codex_app_server_protocol::ThreadStartParams;
use codex_app_server_protocol::ThreadStartResponse;
use codex_config::config_toml::ProjectConfig;
use codex_core::config::ConfigBuilder;
use codex_core::config::ConfigOverrides;
use codex_features::Feature;
use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::RolloutItem;