From ed391af2e8b494a25572d7e043b9041b57fddca1 Mon Sep 17 00:00:00 2001 From: kyeongmin Date: Tue, 26 May 2026 14:30:21 +0900 Subject: [PATCH] fix(orchestrator): P7a NameError in P7 KEEP_OPEN guard P7 Patch B used `comments[-1]` at line 1868 but `comments` is defined inside run_stage, not run_issue scope. The KEEP_OPEN guard runs after run_stage returns, where `comments` is no longer in scope, causing NameError crash after Stage 6 YES was already accepted and exit report generated. Fix: fetch comments fresh via get_comments(n) at the guard entry. exit_path file check (fallback) still works as designed. Refs: #84 (Stage 6 crash during normal close path) --- orchestrator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/orchestrator.py b/orchestrator.py index e0c6d0e..4e48405 100644 --- a/orchestrator.py +++ b/orchestrator.py @@ -1865,7 +1865,12 @@ def run_issue(n, until=None): r"NO\s+close\s+signal", ] keep_open = False - last_body = comments[-1].get("body", "") if comments else "" + # P7a (2026-05-26) — fetch comments fresh; `comments` is loop-local in stage block + # and not in scope at run_issue post-stage update. NameError fix. + try: + _cs = get_comments(n) + last_body = _cs[-1].get("body", "") if _cs else "" + except: last_body = "" for p in keep_open_patterns: if re.search(p, last_body, re.IGNORECASE | re.MULTILINE): keep_open = True; break