Ensure list_threads drops stale rollout files (#11572)

Summary
- trim `state_db::list_threads_db` results to entries whose rollout
files still exist, logging and recording a discrepancy for dropped rows
- delete stale metadata rows from the SQLite store so future calls don’t
surface invalid paths
- add regression coverage in `recorder.rs` to verify stale DB paths are
dropped when the file is missing
This commit is contained in:
jif-oai
2026-02-12 12:49:31 +00:00
committed by GitHub
parent befe4fbb02
commit adad23f743
3 changed files with 95 additions and 1 deletions

View File

@@ -650,6 +650,15 @@ ON CONFLICT(thread_id, position) DO NOTHING
self.upsert_thread(&metadata).await
}
/// Delete a thread metadata row by id.
pub async fn delete_thread(&self, thread_id: ThreadId) -> anyhow::Result<u64> {
let result = sqlx::query("DELETE FROM threads WHERE id = ?")
.bind(thread_id.to_string())
.execute(self.pool.as_ref())
.await?;
Ok(result.rows_affected())
}
async fn ensure_backfill_state_row(&self) -> anyhow::Result<()> {
sqlx::query(
r#"