@@ -1077,10 +1077,7 @@ def _sync_cycle_internal(self, target_abs_id=None):
10771077
10781078 try :
10791079 # -----------------------------------------------------------------
1080- # SPARSE MAP DETECTOR (Self-Healing)
1081- # If a book was aligned under the old N=12 logic, it might have
1082- # sparse anchors. This forces them back to the background queue
1083- # to get a dense Pass 3/4 map without blocking the UI cycle.
1080+ # MIGRATION UPGRADE
10841081 # -----------------------------------------------------------------
10851082 if self .alignment_service :
10861083 alignment = self .alignment_service ._get_alignment (abs_id )
@@ -1091,24 +1088,6 @@ def _sync_cycle_internal(self, target_abs_id=None):
10911088 book .transcript_file = 'DB_MANAGED'
10921089 self .database_service .save_book (book )
10931090
1094- if len (alignment ) > 2 :
1095- last_ts = float (alignment [- 1 ].get ('ts' , 0 ))
1096- anchor_count = len (alignment )
1097- avg_gap = last_ts / anchor_count if anchor_count > 0 else 0
1098-
1099- if avg_gap > 45.0 :
1100- logger .info (f" 🩹 Self-Healing: Sparse alignment map detected (avg gap { avg_gap :.1f} s). Queuing for dense re-processing." )
1101- book .status = 'pending'
1102- self .database_service .save_book (book )
1103- continue
1104- else :
1105- # Alignment map is completely missing
1106- if getattr (book , 'sync_mode' , 'audiobook' ) != 'ebook_only' :
1107- logger .info (f" 🩹 Self-Healing: Missing alignment map detected for '{ title_snip } '. Queuing for deep anchoring." )
1108- book .status = 'pending'
1109- self .database_service .save_book (book )
1110- continue
1111-
11121091 # Get previous state for this book from database
11131092 previous_states = self .database_service .get_states_for_book (abs_id )
11141093
@@ -1262,6 +1241,15 @@ def _sync_cycle_internal(self, target_abs_id=None):
12621241 # At this point we have a significant change to act on
12631242 logger .info (f"🔄 '{ abs_id } ' '{ title_snip } ' Change detected" )
12641243
1244+ # [NEW] Missing Map Check (Deep Anchoring)
1245+ # Only heal if progress is actively happening to avoid unnecessary processing
1246+ if getattr (book , 'sync_mode' , 'audiobook' ) != 'ebook_only' :
1247+ if self .alignment_service and not self .alignment_service ._get_alignment (abs_id ):
1248+ logger .info (f" 🩹 Self-Healing: Missing deep anchoring map detected after progress on '{ title_snip } '. Queuing for processing." )
1249+ book .status = 'pending'
1250+ self .database_service .save_book (book )
1251+ continue
1252+
12651253 # Status block - show only changed lines
12661254 status_lines = []
12671255 for key , cfg in config .items ():
0 commit comments