From 82e536b058087d255d466c788aa11b6b44b382f4 Mon Sep 17 00:00:00 2001 From: jrphilo Date: Wed, 13 May 2026 10:15:50 -0400 Subject: [PATCH] chore(.dev): surface gh pr list errors and checkout main between iterations The Phase 2 queue check redirected stderr to /dev/null, so any transient gh failure (rate limit, network blip) silently returned empty and the loop printed "Queue empty" instead of the real error. Capture stderr to a temp file, exit non-zero with the real message when gh fails. Also: defensively `git checkout main` between iterations. The agent's session usually returns to BASE_BRANCH per the prompt, but if it doesn't (early exit, crash) the next iteration's gh pr checkout would layer onto stale state. Co-Authored-By: Claude Opus 4.7 (1M context) --- .dev/dependency.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.dev/dependency.sh b/.dev/dependency.sh index bba0360..94a0ef5 100755 --- a/.dev/dependency.sh +++ b/.dev/dependency.sh @@ -187,13 +187,29 @@ fi # ── Phase 2: Upgrade loop (one session per eligible PR — oldest first) ── DEPS_DONE=0 while [ $DEPS_DONE -lt $MAX_DEPS ]; do + # Defensive: return the wrapper's working tree to BASE_BRANCH between + # iterations. The agent's session usually ends on BASE_BRANCH per the + # prompt, but if it didn't (early exit, crash, missed step) subsequent + # iterations could checkout a PR on top of stale state. + git -C "$REPO_ROOT" checkout --quiet "$BASE_BRANCH" 2>/dev/null || true + # Queue: Dependabot PRs + Ralphie-opened security override PRs (chore/security-*), # excluding any with a terminal ralphie:* label. + QUEUE_ERR=$(mktemp) NEXT=$(gh pr list \ --state open \ --limit 100 \ --json number,labels,createdAt,headRefName,author \ - --jq '[.[] | select(.author.login == "app/dependabot" or (.headRefName | startswith("chore/security-"))) | select(.labels | map(.name) | any(startswith("ralphie:")) | not)] | sort_by(.createdAt) | .[0].number // empty' 2>/dev/null) + --jq '[.[] | select(.author.login == "app/dependabot" or (.headRefName | startswith("chore/security-"))) | select(.labels | map(.name) | any(startswith("ralphie:")) | not)] | sort_by(.createdAt) | .[0].number // empty' 2>"$QUEUE_ERR") + QUEUE_EXIT=$? + + if [ $QUEUE_EXIT -ne 0 ]; then + echo -e " ${RED}gh pr list failed (exit $QUEUE_EXIT) — surfacing stderr instead of silently treating queue as empty:${RESET}" >&2 + cat "$QUEUE_ERR" >&2 + rm -f "$QUEUE_ERR" + exit $QUEUE_EXIT + fi + rm -f "$QUEUE_ERR" if [ -z "$NEXT" ]; then echo -e "\n ${GREEN}✓${RESET} Queue empty. $DEPS_DONE PR(s) attempted. Exiting."