Include directly attached threads in diagnostic uploads (#57824)

## What changed

When a diagnostic upload includes logs, include saved threads attached directly to the reported thread in the existing bounded thread selection alongside spawned descendants. Query attached threads from the state database, including archived threads, so their rollouts, logs, and retained review failures can be collected. Log a warning and continue if the lookup fails.

## Testing

Extend the upload integration test to verify that the rollout archive includes the reported and directly attached threads, excludes unrelated threads, and is omitted when logs are disabled.

GitOrigin-RevId: 1bcd2794938339fb4b1c433c3731f507601cd8a4
This commit is contained in:
Brent Traut
2026-10-28 20:21:30 +00:00
committed by copyberry
parent 78a3185ecb
commit e6c5a83799
4 changed files with 66 additions and 28 deletions
@@ -161,7 +161,7 @@ impl FeedbackRequestProcessor {
let mut feedback_index = None;
let (snapshot, sqlite_feedback_logs, state_db_ctx) = if include_logs {
let state_db_ctx = self.state_db.clone();
let feedback_thread_ids = match conversation_id {
let mut feedback_thread_ids = match conversation_id {
Some(conversation_id) => match self
.thread_manager
.list_agent_subtree_thread_ids(conversation_id)
@@ -177,9 +177,16 @@ impl FeedbackRequestProcessor {
},
None => Vec::new(),
};
if let (Some(state_db), Some(thread_id)) = (&state_db_ctx, conversation_id) {
match state_db.list_attached_thread_ids(thread_id).await {
Ok(attached_ids) => feedback_thread_ids.extend(attached_ids),
Err(err) => {
warn!("failed to list attached threads for feedback on {thread_id}: {err}")
}
}
}
let failures =
guardian_review_failures(state_db_ctx.as_deref(), &feedback_thread_ids).await;
let mut feedback_thread_ids = feedback_thread_ids;
if let Some(conversation_id) = conversation_id {
let index =
FeedbackThreadIndex::new(conversation_id, feedback_thread_ids, &failures);