fix(maestro): preserve dismissed recovery cleanup

This commit is contained in:
Miguel Palhas
2026-09-05 00:57:36 +01:00
parent fde1954eac
commit 3a68c1dd2f
2 changed files with 62 additions and 4 deletions
+6 -4
View File
@@ -1752,15 +1752,16 @@ async fn mark_session_dead(inner: &Arc<Inner>, id: Uuid) {
/// A daemon restart terminates ACP children, but it is not a natural adapter
/// exit: the sidecar is the recovery inventory, including its worktree.
async fn mark_session_dead_after_shutdown(inner: &Arc<Inner>, id: Uuid) {
mark_session_dead_with_worktree_settlement(inner, id, false).await;
let _ = inner.sidecar.mark_for_recovery(id);
if mark_session_dead_with_worktree_settlement(inner, id, false).await {
let _ = inner.sidecar.mark_for_recovery(id);
}
}
async fn mark_session_dead_with_worktree_settlement(
inner: &Arc<Inner>,
id: Uuid,
settle_worktree: bool,
) {
) -> bool {
let flipped = {
let mut sessions = inner.sessions.lock().await;
match sessions.get_mut(&id) {
@@ -1780,7 +1781,7 @@ async fn mark_session_dead_with_worktree_settlement(
}
};
let Some((mut session, worktree)) = flipped else {
return;
return false;
};
tracing::info!(%id, "session process gone — marking dead");
@@ -1811,6 +1812,7 @@ async fn mark_session_dead_with_worktree_settlement(
let _ = inner.sidecar.write(&session);
let _ = inner.events.send(CatalogEvent::SessionUpdated { session });
true
}
/// Apply the exit rule (#82) to a vanished session's worktree: probe what