Skip to content

Commit df7f8fe

Browse files
JihaoXinclaude
andcommitted
Page enforcement: 5 attempts + Telegram alert if still out of range
- Increased max attempts from 3 to 5 - If still out of range after 5 attempts, send Telegram notification for manual intervention instead of silently continuing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 707242f commit df7f8fe

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ark/execution.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,8 @@ def _enforce_page_count(self, context: str = "post-writing") -> bool:
647647
self.log(f"[{context}] Page check: {page_count:.1f} body pages "
648648
f"(target: {min_pages:.2f}{max_pages:.1f}, {columns}-col)", "INFO")
649649

650-
# Loop until page count is in range or max attempts exhausted
651-
MAX_ATTEMPTS = 3
650+
# Loop until page count is in range (safety limit to avoid infinite loop)
651+
MAX_ATTEMPTS = 5
652652
for attempt in range(MAX_ATTEMPTS):
653653
in_range = min_pages <= page_count <= max_pages
654654
if in_range:
@@ -700,10 +700,17 @@ def _enforce_page_count(self, context: str = "post-writing") -> bool:
700700
self.log(f"[{context}] Could not determine page count after {action}", "WARN")
701701
return True
702702

703-
# After all attempts
703+
# After all attempts — notify user if still out of range
704704
in_range = page_count and min_pages <= page_count <= max_pages
705-
self.log(f"[{context}] Final page count: {page_count:.1f}/{venue_pages} body pages "
706-
f"({'OK' if in_range else 'OUT OF RANGE'} after {MAX_ATTEMPTS} attempts)", "INFO" if in_range else "ERROR")
705+
if not in_range:
706+
msg = (f"⚠️ Page count still out of range after {MAX_ATTEMPTS} attempts: "
707+
f"{page_count:.1f} pages (target: {min_pages:.2f}{max_pages:.1f}). "
708+
f"Manual adjustment may be needed.")
709+
self.log(f"[{context}] {msg}", "ERROR")
710+
if self.telegram.is_configured:
711+
self.telegram.send(msg)
712+
else:
713+
self.log(f"[{context}] Final page count: {page_count:.1f}/{venue_pages} body pages OK", "INFO")
707714
return in_range
708715

709716
def _ensure_clearpage_before_bibliography(self):

0 commit comments

Comments
 (0)