@@ -173,7 +173,9 @@ export type TaskRegistryMaintenanceTaskDiagnostic = {
173173 | "backing_session_missing"
174174 | "backing_session_present"
175175 | "cron_runtime_not_authoritative"
176- | "lost_grace_pending" ;
176+ | "lost_grace_pending"
177+ | "subagent_recovery_wedged" ;
178+ detail ?: string ;
177179 ageMs : number ;
178180 childSessionKey ?: string ;
179181 runId ?: string ;
@@ -981,10 +983,20 @@ function explainActiveTaskRetention(params: {
981983 task : TaskRecord ;
982984 now : number ;
983985 context : BackingSessionLookupContext ;
984- } ) : Pick < TaskRegistryMaintenanceTaskDiagnostic , "decision" | "reason" > {
986+ } ) : Pick < TaskRegistryMaintenanceTaskDiagnostic , "decision" | "reason" | "detail" > {
985987 if ( ! hasLostGraceExpired ( params . task , params . now ) ) {
986988 return { decision : "retained" , reason : "lost_grace_pending" } ;
987989 }
990+ if ( params . task . runtime === "subagent" ) {
991+ const entry = findTaskSessionEntry ( params . task , params . context ) ;
992+ if ( entry && isSubagentRecoveryWedgedEntry ( entry ) ) {
993+ return {
994+ decision : "would_reconcile" ,
995+ reason : "subagent_recovery_wedged" ,
996+ detail : formatSubagentRecoveryWedgedReason ( entry ) ,
997+ } ;
998+ }
999+ }
9881000 if ( ! hasBackingSession ( params . task , params . context ) ) {
9891001 return { decision : "would_reconcile" , reason : "backing_session_missing" } ;
9901002 }
@@ -1025,6 +1037,7 @@ export function getTaskRegistryMaintenanceDiagnostics(): TaskRegistryMaintenance
10251037 decision : decision . decision ,
10261038 reason : decision . reason ,
10271039 ageMs,
1040+ ...( decision . detail ? { detail : decision . detail } : { } ) ,
10281041 ...( task . childSessionKey ? { childSessionKey : task . childSessionKey } : { } ) ,
10291042 ...( task . runId ? { runId : task . runId } : { } ) ,
10301043 } ) ;
0 commit comments