From db45511ff55b26900e66520dbb49c78b9f503500 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Thu, 9 Apr 2026 17:59:49 -0400 Subject: [PATCH] refactor(settings): stage 6.3b promote user runtime types into consumers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First consumer migration pass. Deletes `lib/crates/fabro-types/src/settings/user.rs` outright: - `OutputFormat`, `PermissionLevel`: moved into `fabro-agent/src/cli.rs` where they are actually consumed as `AgentArgs` fields. They carry clap `ValueEnum` derives so `fabro-cli` keeps importing them via the `fabro_agent::cli::{OutputFormat, PermissionLevel}` public path. - `ClientTlsSettings`: moved into `fabro-cli/src/user_config.rs` as a crate-private struct. Only `fabro-cli` references it (via `cli_target_from_v2` when building the HTTP client). - `ExecSettings`, legacy `ServerSettings` (from `settings::user`): deleted outright — no callers remained. Also removes the now-dead `From<&GitAuthorSettings> for GitAuthor` impl in `fabro-checkpoint/src/author.rs`. The v2 `GitAuthorLayer` conversion is the only path `fabro-workflow::git::git_author_from_settings` uses. Drops the `fabro_types::settings::server::GitAuthorSettings` import along with it. `settings/mod.rs` drops the `pub mod user` declaration and the `pub use user::*` re-export line. One of the seven legacy runtime type modules is now gone; six remain. 3,758 workspace tests pass. `cargo fmt --check --all` and `cargo clippy --workspace -- -D warnings` are clean. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/crates/fabro-agent/src/cli.rs | 21 ++++++++++- lib/crates/fabro-checkpoint/src/author.rs | 9 +---- lib/crates/fabro-cli/src/user_config.rs | 12 +++++- lib/crates/fabro-types/src/settings/mod.rs | 3 -- lib/crates/fabro-types/src/settings/user.rs | 41 --------------------- 5 files changed, 31 insertions(+), 55 deletions(-) delete mode 100644 lib/crates/fabro-types/src/settings/user.rs diff --git a/lib/crates/fabro-agent/src/cli.rs b/lib/crates/fabro-agent/src/cli.rs index a7aa862c6..f06d4c9cb 100644 --- a/lib/crates/fabro-agent/src/cli.rs +++ b/lib/crates/fabro-agent/src/cli.rs @@ -68,7 +68,26 @@ struct Cli { args: AgentArgs, } -pub use fabro_types::settings::user::{OutputFormat, PermissionLevel}; +/// Output format for the `fabro exec` / agent CLI. +#[derive( + Clone, Copy, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize, clap::ValueEnum, +)] +#[serde(rename_all = "kebab-case")] +pub enum OutputFormat { + Text, + Json, +} + +/// Agent tool permission level. +#[derive( + Clone, Copy, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize, clap::ValueEnum, +)] +#[serde(rename_all = "kebab-case")] +pub enum PermissionLevel { + ReadOnly, + ReadWrite, + Full, +} impl AgentArgs { /// Fill `None` fields from settings.toml values, then hardcoded defaults. diff --git a/lib/crates/fabro-checkpoint/src/author.rs b/lib/crates/fabro-checkpoint/src/author.rs index c493275d2..e85062f6b 100644 --- a/lib/crates/fabro-checkpoint/src/author.rs +++ b/lib/crates/fabro-checkpoint/src/author.rs @@ -1,7 +1,6 @@ use std::fmt::Write; -use fabro_types::settings::server::GitAuthorSettings; -use fabro_types::settings::v2::InterpString; +use fabro_types::settings::InterpString; use fabro_types::settings::v2::run::GitAuthorLayer; /// Resolved git author identity for checkpoint commits. @@ -51,12 +50,6 @@ impl GitAuthor { } } -impl From<&GitAuthorSettings> for GitAuthor { - fn from(value: &GitAuthorSettings) -> Self { - Self::from_options(value.name.clone(), value.email.clone()) - } -} - impl From<&GitAuthorLayer> for GitAuthor { fn from(value: &GitAuthorLayer) -> Self { Self::from_options( diff --git a/lib/crates/fabro-cli/src/user_config.rs b/lib/crates/fabro-cli/src/user_config.rs index 7a9d6d483..248979560 100644 --- a/lib/crates/fabro-cli/src/user_config.rs +++ b/lib/crates/fabro-cli/src/user_config.rs @@ -1,14 +1,22 @@ use std::path::{Path, PathBuf}; pub(crate) use fabro_config::user::*; -pub(crate) use fabro_types::settings::user::ClientTlsSettings; use anyhow::{Result, bail}; use fabro_config::ConfigLayer; -use fabro_types::settings::v2::SettingsFile; +use fabro_types::settings::SettingsFile; use fabro_util::version::FABRO_VERSION; +use serde::{Deserialize, Serialize}; use tracing::debug; +/// Client-side TLS material for the CLI's remote server target. +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +pub(crate) struct ClientTlsSettings { + pub cert: PathBuf, + pub key: PathBuf, + pub ca: PathBuf, +} + use crate::args::ServerTargetArgs; pub(crate) fn load_settings() -> anyhow::Result { diff --git a/lib/crates/fabro-types/src/settings/mod.rs b/lib/crates/fabro-types/src/settings/mod.rs index 5492f34be..a6830b050 100644 --- a/lib/crates/fabro-types/src/settings/mod.rs +++ b/lib/crates/fabro-types/src/settings/mod.rs @@ -25,7 +25,6 @@ pub mod project; pub mod run; pub mod sandbox; pub mod server; -pub mod user; pub mod v2; pub use hook::{HookDefinition, HookEvent, HookSettings, HookType, TlsMode}; @@ -47,8 +46,6 @@ pub use server::{ AuthSettings, FeaturesSettings, GitAuthorSettings, GitProvider, GitSettings, LogSettings, SlackSettings, TlsSettings, WebSettings, WebhookSettings, WebhookStrategy, }; -pub use user::{ClientTlsSettings, ExecSettings, OutputFormat, PermissionLevel, ServerSettings}; - // v2 top-level re-exports. Stage 6.5 of the settings TOML redesign // promoted the v2 namespaced parse tree to be the primary API surface; // consumers can now write `fabro_types::settings::SettingsFile` / diff --git a/lib/crates/fabro-types/src/settings/user.rs b/lib/crates/fabro-types/src/settings/user.rs deleted file mode 100644 index 1818e124a..000000000 --- a/lib/crates/fabro-types/src/settings/user.rs +++ /dev/null @@ -1,41 +0,0 @@ -use std::path::PathBuf; - -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize, crate::Combine)] -#[cfg_attr(feature = "clap", derive(clap::ValueEnum))] -#[serde(rename_all = "kebab-case")] -pub enum OutputFormat { - Text, - Json, -} - -#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize, crate::Combine)] -#[cfg_attr(feature = "clap", derive(clap::ValueEnum))] -#[serde(rename_all = "kebab-case")] -pub enum PermissionLevel { - ReadOnly, - ReadWrite, - Full, -} - -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -pub struct ClientTlsSettings { - pub cert: PathBuf, - pub key: PathBuf, - pub ca: PathBuf, -} - -#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] -pub struct ServerSettings { - pub target: Option, - pub tls: Option, -} - -#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] -pub struct ExecSettings { - pub provider: Option, - pub model: Option, - pub permissions: Option, - pub output_format: Option, -}