Skip to content

Commit 0910e5d

Browse files
JihaoXinclaude
andcommitted
Reorder: run citation verification before page enforcement
Previously, page enforcement ran first and then citation verification added [NEEDS-CHECK] markers that could push the paper over the limit. Swapping the order so page enforcement is the last step — citations are part of the budget — means we only need one enforcement pass. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent f5a6395 commit 0910e5d

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

ark/pipeline.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,15 @@ def run_paper_iteration(self) -> bool:
544544
self.record_score_to_memory(score)
545545

546546
# ── Pre-delivery checks (all hard guarantees) ──
547+
# Order matters: citation verification can add [NEEDS-CHECK] markers
548+
# that push the paper over the page limit, so enforce page count AFTER
549+
# citation verification.
547550
self.log_step("Pre-delivery checks...", "progress")
548551
self._ensure_clearpage_before_bibliography()
549552
self._ensure_float_barrier()
550553
self.compile_latex()
551554
self._fix_overfull(context="pre-delivery")
555+
self._run_citation_verification()
552556
try:
553557
self._enforce_page_count(context="pre-delivery")
554558
except QuotaExhaustedError as e:
@@ -570,14 +574,6 @@ def run_paper_iteration(self) -> bool:
570574
)
571575
RateLimitCountdown(wait_time).run()
572576
return True # continue to retry
573-
self._run_citation_verification()
574-
575-
# Re-enforce page count after citation verification:
576-
# [NEEDS-CHECK] markers can push the paper over the limit.
577-
try:
578-
self._enforce_page_count(context="post-citation")
579-
except QuotaExhaustedError:
580-
self.log("Post-citation page enforcement hit quota; delivering as-is", "WARN")
581577

582578
# Send iteration summary + PDF to Telegram
583579
self.send_iteration_summary(score, current_score, review_output)
@@ -2009,9 +2005,12 @@ def _deliver_dev_phase(self, dev_state: dict, max_dev_iters: int):
20092005
)
20102006

20112007
if draft_compiled:
2008+
# Order matters: run citation verification BEFORE page enforcement
2009+
# so [NEEDS-CHECK] markers are counted in the final page budget.
20122010
self._ensure_float_barrier()
20132011
self.compile_latex()
20142012
self._fix_overfull(context="dev-phase-delivery")
2013+
self._run_citation_verification()
20152014
try:
20162015
self._enforce_page_count(context="dev-phase-delivery")
20172016
except QuotaExhaustedError as e:
@@ -2029,12 +2028,6 @@ def _deliver_dev_phase(self, dev_state: dict, max_dev_iters: int):
20292028
RateLimitCountdown(wait_time).run()
20302029
self._quota_exhausted = False # Reset for retry
20312030
self._enforce_page_count(context="dev-phase-delivery-retry")
2032-
self._run_citation_verification()
2033-
# Re-enforce page count: citation [NEEDS-CHECK] markers can push over limit
2034-
try:
2035-
self._enforce_page_count(context="dev-phase-post-citation")
2036-
except QuotaExhaustedError:
2037-
self.log("Dev-phase post-citation page enforcement hit quota; delivering as-is", "WARN")
20382031

20392032
if draft_compiled and self.telegram.is_configured:
20402033
pdf_path = self.latex_dir / "main.pdf"

0 commit comments

Comments
 (0)