refactor(server): plumb Arc<Settings> through workers and routes

Config sheds its 14 Bucket-B fields (retention, whisper, ollama, llm) and
gains a sibling Arc<Settings> in AppState, loaded from settings.toml at
startup via Settings::load_or_default. Workers (transcribe, analyze,
recovery, auto_trigger) and routes (health, bulk, case_actions,
user_web) take settings as a separate parameter or State<> extractor;
Config::llm_configured moves to Settings::llm_configured.

TestConfig::build_pair() returns (Arc<Config>, Arc<Settings>); the new
create_router_with_settings / create_router_and_session_store_with_settings
helpers wire both into integration tests that exercise LLM/Whisper/Ollama.
The legacy single-Arc create_router falls back to Settings::default()
so the 17 non-LLM tests stay untouched.

Verified: cargo build clean, clippy --all-targets clean, 318 tests pass.
This commit is contained in:
2026-04-27 11:48:41 +02:00
parent 6bbbf10f77
commit a510c20e75
21 changed files with 310 additions and 248 deletions
+5 -3
View File
@@ -20,6 +20,7 @@ use crate::routes::case_actions::{
build_analysis_input, reset_case_artefacts, write_input_create_new,
};
use crate::routes::user_web::locate_case;
use crate::settings::Settings;
#[derive(Debug, Deserialize)]
pub struct BulkForm {
@@ -44,6 +45,7 @@ impl HasCsrfToken for BulkForm {
pub async fn handle_bulk_action(
user: AuthenticatedWebUser,
State(config): State<Arc<Config>>,
State(settings): State<Arc<Settings>>,
State(analyze_tx): State<AnalyzeSender>,
State(events_tx): State<EventSender>,
State(locks): State<OnelinerLocks>,
@@ -70,7 +72,7 @@ pub async fn handle_bulk_action(
match action {
BulkAction::Analyze => {
bulk_analyze(
&config,
&settings,
&analyze_tx,
&events_tx,
&user.slug,
@@ -89,14 +91,14 @@ pub async fn handle_bulk_action(
}
async fn bulk_analyze(
config: &Config,
settings: &Settings,
analyze_tx: &AnalyzeSender,
events_tx: &EventSender,
slug: &str,
user_root: &std::path::Path,
case_ids: &[String],
) {
if !config.llm_configured() {
if !settings.llm_configured() {
warn!(slug = %slug, "bulk-analyze: LLM not configured, skipping all");
return;
}