Keep thread storage available when diagnostic logs fail (#60466)

## Why

Failure to open the diagnostic logs database should not disable thread storage or database-only history listing. Thread deletion must still preserve saved conversations when diagnostic log cleanup cannot complete.

## What changed

- Allow state initialization to continue after non-corruption errors opening the logs database, while preserving corruption recovery.
- Report the original diagnostic database error after tracing is installed in the TUI and app server, and return it from log operations.
- Reject thread deletion before destructive cleanup when diagnostic storage failed to initialize.
- Continue periodic cleanup of legacy logs when the current logs database is unavailable.

## Testing

Extend coverage for unavailable log directories, database-only history listing, startup diagnostics, deletion preserving saved conversations, corrupt log headers, and periodic legacy log cleanup during a diagnostic storage outage.

GitOrigin-RevId: a5184580ae6c39ed0c4eefa8cb48ee7731a991c3
This commit is contained in:
Dmitriy Kovalenko
2026-11-09 23:22:08 +00:00
committed by copyberry
parent e1cc96712f
commit caae161dd0
11 changed files with 257 additions and 90 deletions
+8 -1
View File
@@ -88,11 +88,18 @@ async fn configured_log_directory_is_initialized_on_use_and_retries_after_failur
// Opening unrelated state must not require the configured logs directory.
let pool = sqlite.open_read_write_pool(&sqlite.state_db_path()).await?;
pool.close().await;
let runtime = crate::StateRuntime::init(sqlite.clone(), "openai".to_string()).await?;
runtime.get_backfill_state().await?;
assert!(
crate::StateRuntime::init(sqlite.clone(), "openai".to_string())
runtime
.max_log_id(&crate::LogQuery::default())
.await
.is_err()
);
assert!(sqlite.goals_db_path().is_file());
assert!(sqlite.memories_db_path().is_file());
assert!(sqlite.queue_db_path().is_file());
runtime.close().await;
assert!(!fallback_logs_path.exists());
// A failed initialization must remain retryable without replacing the config.