Explorar el Código

Merge pull request #1164 from GoldJohnKing/chore/orchestrator-wake-dead-checks

chore: remove provably-dead checks in orchestrator-wake scheduler
Alvin hace 4 días
padre
commit
59032da772
Se han modificado 1 ficheros con 11 adiciones y 22 borrados
  1. 11 22
      src/hooks/orchestrator-wake/index.ts

+ 11 - 22
src/hooks/orchestrator-wake/index.ts

@@ -1094,13 +1094,10 @@ export function createOrchestratorWakeScheduler(
 
       // Reserve before promptAsync so a failed call cannot storm retries and
       // concurrent hook instances cannot double-wake.
-      if (applyArchiveState(sessionID, state, latest.archiveState)) return;
       if (!commitWakeReservation(sessionID, owner, latestFingerprint)) {
         return;
       }
 
-      if (!capabilities.ready) return;
-
       const wakeText = recoveryWake
         ? ORCHESTRATOR_STOPPED_JOB_WAKE_TEXT
         : wakeMode === 'children'
@@ -1232,18 +1229,16 @@ export function createOrchestratorWakeScheduler(
     ) {
       return;
     }
+    pendingStoppedRecoveries.add(sessionID);
     if (localSessions.get(sessionID)?.archived) {
-      pendingStoppedRecoveries.add(sessionID);
       return;
     }
-    pendingStoppedRecoveries.add(sessionID);
     rearmWakeProgress(sessionID);
     if (!canSchedule(sessionID)) return;
     const state = touchLocal(sessionID);
     clearTimer(state);
     bumpGeneration(state);
     state.continuousIdle = true;
-    rearmWakeProgress(sessionID);
     void evaluate(sessionID, state.generation, true);
   }
 
@@ -1355,18 +1350,16 @@ export function createOrchestratorWakeScheduler(
       return;
     }
 
-    if (type === 'session.error' || type === 'session.status') {
-      if (
-        type === 'session.error' ||
-        (type === 'session.status' &&
-          properties?.status?.type !== 'idle' &&
-          properties?.status?.type !== 'busy')
-      ) {
-        if (options.shouldManageSession(sessionID)) {
-          // Errors / retry are external lifecycle — rearm.
-          clearExpectingWakeBusy(sessionID);
-          endIdleSpell(sessionID, true);
-        }
+    if (
+      type === 'session.error' ||
+      (type === 'session.status' &&
+        properties?.status?.type !== 'idle' &&
+        properties?.status?.type !== 'busy')
+    ) {
+      if (options.shouldManageSession(sessionID)) {
+        // Errors / retry are external lifecycle — rearm.
+        clearExpectingWakeBusy(sessionID);
+        endIdleSpell(sessionID, true);
       }
     }
   }
@@ -1397,7 +1390,3 @@ export function createOrchestratorWakeScheduler(
     },
   };
 }
-
-export type OrchestratorWakeScheduler = ReturnType<
-  typeof createOrchestratorWakeScheduler
->;