Skip to content

fix(skills): make /fixer loop until the backlog is drained and park on stall, not fixed counts - #2169

Merged
carlos-alm merged 15 commits into
mainfrom
fix/fixer-drain-and-state-v2
Jul 29, 2026
Merged

carlos-alm merged 15 commits into
mainfrom
fix/fixer-drain-and-state-v2

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

  • Loop until actually done. /fixer previously processed one batch of --count issues and stopped, even if more qualifying open issues remained. It now loops across batches by default (new Phase 3 — Continue the Batch Loop, or Proceed to Drain), re-fetching a fresh queue and continuing until no qualifying open issues remain or a 15-batch safety cap is hit. --once restores the old single-batch behavior.
  • Repo scope + do-nothing. /fixer only ever acts on the repo it's invoked in. An empty issue queue is now reported and exits cleanly (exit 0, not an error) — with an explicit rule against searching other repos or inventing unrelated work to fill a batch.
  • Stall-based parking, not fixed round/pass counts. Convergence rounds (2f) and drain passes (Phase 4) were both capped at a flat 3, parking a PR/stopping drain regardless of whether real progress was still happening. Both now track a per-round/per-pass signature and park only after 3 consecutive rounds/passes with zero measurable change (genuinely blocked) — backed by a 15-round / 15-pass safety cap for runaway cases.

This replaces #2165, reverted in #2167. Fixes the 2 issues Greptile found on #2165 (Confidence Score 2/5):

  1. Drain progress never tracked. The drain phase's stall detection relied on parked.txt shrinking, but nothing removed a PR's number from it after merging — so a pass that successfully merged a PR still looked stalled, and the drain could wrongly report the remaining PRs as blocked after 3 passes. Fixed: the "merge lowest-ready PR" step now explicitly removes that PR from parked.txt.
  2. Batch state leaked across runs. Phase 0 only checked whether state.json existed to decide "resume", so a fresh invocation after a fully-completed prior run inherited its stale batches-done count and empty queue.json — causing new issues to be silently skipped or the 15-batch cap to trigger early. Fixed: resume now requires queue.json to be non-empty (real unfinished work); otherwise every run-scoped artifact is reset before starting.

Test plan

  • Syntax/logic-checked the stall-detection and parked.txt-removal bash snippets standalone
  • Verified the Phase 0 fresh-run-vs-resume branching with both queue states (empty → reset, non-empty → resume)
  • npm run lint clean (skill file is outside src//tests/ scope)
  • Dry-run /fixer --dry-run on a future run to confirm batch/round bookkeeping behaves as designed

…n stall, not fixed counts

Two changes:
- /fixer previously stopped after one batch of --count issues even when more
  qualifying open issues remained. It now loops across batches by default
  (Phase 3), re-fetching a fresh queue and continuing until no qualifying
  open issues remain or a 15-batch safety cap is hit. --once restores the
  old single-batch behavior. An empty queue is now reported as a clean
  stop (exit 0), with an explicit rule against wandering to other repos or
  inventing unrelated work to fill a batch.
- Convergence rounds (2f) and drain passes (Phase 4) were capped at a fixed
  3, parking/reporting a PR regardless of whether it was still making real
  progress. Both now track a per-round/per-pass progress signature and
  park only after 3 consecutive rounds/passes with zero measurable change
  (genuinely blocked), backed by a 15-round/15-pass safety cap for runaway
  cases.

Fixes 2 bugs Greptile found on the first attempt at this change (#2165,
reverted in #2167, Confidence Score 2/5):
- The drain phase never actually removed a merged PR's number from
  parked.txt, so its length never shrank and a pass that successfully
  merged a PR was still recorded as making no progress — the drain could
  wrongly report the remaining PRs as blocked after 3 passes even though
  each pass was merging something. Step 3 (merge the lowest-ready PR) now
  explicitly removes it from parked.txt as part of the same step.
- Phase 0's resume handling only checked whether state.json existed, so a
  fresh invocation after a fully-completed prior run inherited that run's
  stale batches-done count and empty queue.json, causing new issues to be
  silently skipped or the 15-batch cap to trigger prematurely. Resume now
  requires queue.json to be non-empty (real unfinished work); otherwise
  every run-scoped artifact is reset before starting.
Comment on lines +833 to +836
if [ "$PARKED_AFTER" -gt 0 ] && { [ "$DRAIN_STALL" -ge 3 ] || [ "$DRAIN_PASS" -ge 15 ]; }; then
echo "fixer: stopping drain — $([ "$DRAIN_STALL" -ge 3 ] && echo "3 consecutive passes with no merges (blocked)" || echo "15-pass safety cap reached"). $PARKED_AFTER PR(s) remain: report each as needing human review."
elif [ "$PARKED_AFTER" -gt 0 ]; then
echo "fixer: running another pass ($((DRAIN_PASS + 1)))"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Drained merges leave stale state

When Phase 4 merges a parked PR, this block removes it only from parked.txt; its state.json entry remains parked, causing Phase 5 to undercount merged issues and report completed work as unfinished.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 66125b6 — the merge-lowest-ready-PR step in Phase 4 now also flips that issue's state.json entry from parked to merged (matched by PR number), in the same step that removes the PR from parked.txt. Traced through the logic to confirm: previously only parked.txt shrank, so Phase 5's final report kept listing a successfully-merged issue as parked and undercounted the merged total, exactly as described. (Note: this comment's diff anchor landed on the drain-stall stopping-condition block a few lines below the actual removal snippet — the concern described in the prose is what's fixed.)

Comment thread .claude/skills/fixer/SKILL.md Outdated
Comment on lines +584 to +585
printf '%s\n' "score=${SCORE:-none};unanswered=$UNANSWERED;g3=$(git merge-base --is-ancestor origin/main HEAD && echo ok || echo behind);mergeable=$MERGEABLE;failed=$FAILED_CHECKS" \
> .codegraph/fixer/gate-signature

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Progress signature misses active changes

When new commits, review revisions, or check runs retain the same aggregate score, unanswered count, ancestry, mergeability, and failing check names, the signature remains unchanged and the stall counter parks an actively progressing PR.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b56330b — the gate signature now also folds in the current commit SHA (git rev-parse HEAD), a hash of the full concatenated Greptile review/comment text (not just the extracted N/5 digit), and the specific set of currently-unanswered comment ids (not just their count). Traced through it: a push landing before the score/checks catch up, a re-review that restates the same score for different underlying reasons, or a CI rerun that fails the same named check for a new cause will now all change the signature, so genuine activity between rounds is never misread as zero measurable progress.

Comment on lines +773 to +775
If `.codegraph/fixer/loop-decision` is `loop`, go back to Phase 1 and process another batch — do **not** re-run Phase 0 (the repo slug, test/lint commands, and `state.json` are already established for this run, and re-running Phase 0's resume-detection would misread the mid-run `state.json` as a crash to resume from). If it is `stop`, proceed to Phase: Drain Parked PRs.

**Exit condition:** `.codegraph/fixer/loop-decision` is `loop` (with a fresh `start-from` persisted and per-batch scratch state cleared) or `stop`. Every batch processed this run is recorded cumulatively in `state.json` — nothing from an earlier batch is lost or overwritten by a later one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Backlog scan stops at 400

This completion check filters only the first 400 open issues returned by gh issue list. In repositories with more open issues, qualifying entries outside that window remain uncounted while the skill reports the backlog as drained.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in af322d0 — both the queue-build (Phase 1) and the batch-completion check (Phase 3) now pass --author to 'gh issue list' so the author filter runs server-side instead of being applied client-side after a flat --limit 400 fetch, and the limit is raised to 1000 as a generous safety bound on one author's own backlog rather than a cap on the repo's total open-issue count. Confirmed this was a real gap: with the old client-side filter, issues by other authors interspersed in the 400-issue window could crowd out this author's own qualifying issues, letting REMAINING read 0 while qualifying issues still existed.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Updates /fixer to process qualifying issues in repeated batches until the backlog is drained.

  • Adds --once, repository scoping, clean empty-queue handling, and bounded batch iteration.
  • Replaces fixed convergence and drain counts with progress-based stall detection and safety caps.
  • Adds interruption recovery and an explicit run-complete marker so Phase 0 distinguishes unfinished drains from fully reported runs.
  • Reconciles merged parked PRs across parked.txt and state.json.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
.claude/skills/fixer/SKILL.md Adds backlog-wide batching, progress-based convergence and drain handling, and interruption-safe completion tracking; the displayed follow-up issues are resolved at current HEAD.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Start[Invoke /fixer] --> Resume{Unfinished queue or unreported parked PRs?}
  Resume -->|No| Fresh[Reset run-scoped state]
  Resume -->|Mid-batch| Batch[Process current batch]
  Resume -->|Mid-drain| Drain[Drain parked PRs]
  Fresh --> Queue[Build repository-scoped issue queue]
  Queue -->|Empty| Done[Exit successfully]
  Queue --> Batch
  Batch --> More{More qualifying issues and below batch cap?}
  More -->|Yes| Queue
  More -->|No or --once| Drain
  Drain -->|Progress| Drain
  Drain -->|Empty or stalled/capped| Report[Produce final report]
  Report --> Marker[Write run-complete marker]
  Marker --> Done
Loading

Reviews (12): Last reviewed commit: "fix: use an explicit run-complete marker..." | Re-trigger Greptile

Merging a parked PR during the drain phase only removed its number from
parked.txt; the corresponding state.json entry stayed status="parked",
so Phase 5's final report undercounted merged issues and reported
completed work as unfinished. Flip the entry to "merged" (matched by
PR number) in the same step that removes it from parked.txt.
Merging a parked PR during the drain phase only removed its number from
parked.txt; the corresponding state.json entry stayed status="parked",
so Phase 5's final report undercounted merged issues and reported
completed work as unfinished. Flip the entry to "merged" (matched by
PR number) in the same step that removes it from parked.txt.
…#2169)

The stall signature relied on aggregates (score, unanswered count,
mergeable, failing check names) that can read identical across two
rounds even when real activity happened: a push landing before the
score/checks catch up, a re-review restating the same score for
different reasons, or a rerun failing the same named check for a new
cause. Fold in the current commit SHA, a hash of the full Greptile
review text, and the specific set of unanswered comment ids so genuine
progress is never misread as a stall.
…ation (#2169)

Both the queue-build and the batch-completion check fetched --limit 400
open issues repo-wide and filtered by author client-side. In a repo with
more than 400 open issues, entries belonging to the target author could
fall outside that window, under-reporting the remaining backlog as
drained. Pass --author to gh issue list so filtering happens server-side
and raise the limit to a generous safety bound on one author's own queue.
@carlos-alm

Copy link
Copy Markdown
Contributor Author

Addressed all three findings from the Greptile review (Confidence Score 2/5):

  1. Drained merges leave stale state — fixed in 66125b6. Phase 4's merge-lowest-ready-PR step now flips the issue's state.json entry from parked to merged (matched by PR number) in the same step that removes it from parked.txt, so Phase 5's final report no longer undercounts merged work.
  2. Progress signature misses active changes — fixed in b56330b. The gate signature now includes the current commit SHA, a hash of the full Greptile review/comment text, and the specific set of unanswered comment ids, not just aggregates that can lag a push or restate an unchanged score for different reasons.
  3. Backlog scan stops at 400 — fixed in af322d0. Both the queue-build and batch-completion checks now filter by author server-side via --author, with the --limit raised to a generous 1000 as a safety bound on one author's own backlog rather than the repo's total open-issue count.

All three were traced through standalone before fixing, per the review guidance. Lint and the full test suite (260 files / 4178 tests) pass locally. Ready for re-review.

@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

…ure (#2169)

A same-commit CI rerun (manual "Re-run failed jobs" or a flaky-test retry)
leaves the commit SHA, check names, and every other gate-signature field
unchanged, so the stall detector could not distinguish it from genuine
inactivity and would park an actively-progressing PR. The signature now
folds in each non-green check's completedAt/startedAt timestamp alongside
its name, so a rerun always changes the fingerprint even when nothing else
does.
@carlos-alm

Copy link
Copy Markdown
Contributor Author

Addressed the Confidence Score 3/5 gap named in the summary prose (no inline comment existed for it):

CI reruns of the same named check are indistinguishable from inactivity — fixed in a067c87. Verified the concern was real: the prior round's fix (commit SHA + Greptile-text hash in the signature) only covers new commits and new review activity, but a manual "Re-run failed jobs" or a flaky-test retry on the same commit changes neither the SHA nor the check name list, so the signature stayed identical and an actively-rerunning PR could still be parked as blocked. The gate signature now also captures each non-green check's completedAt/startedAt timestamp (via a new CHECK_FINGERPRINT, replacing the name-only failed= field), so any rerun — even one that fails the same check for a different reason — changes the fingerprint and resets the stall counter.

Lint clean; bash syntax of all embedded script blocks validated. Full local npm test run was noisy under heavy concurrent load from other test suites running on this shared machine (unrelated timeouts), but no test in the suite references this skill file, so it's out of that run's scope — CI's isolated runners are the authoritative signal here.

@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread .claude/skills/fixer/SKILL.md Outdated
Comment on lines +843 to +844
grep -vxF "$MERGED_PR" .codegraph/fixer/parked.txt > .codegraph/fixer/parked.txt.tmp \
&& mv .codegraph/fixer/parked.txt.tmp .codegraph/fixer/parked.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Final parked PR stays queued

When the drain merges the only PR remaining in parked.txt, grep -vxF writes the desired empty temporary file but exits 1, so the chained mv does not run. The merged PR remains queued, causing subsequent passes to count the merge as no progress and eventually report an already-merged PR as blocked.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 07b0721 — split the chained grep -vxF ... && mv ... into grep -vxF ... || true followed by an unconditional mv. Confirmed the bug was real by reproducing it standalone: with a single-entry parked.txt equal to $MERGED_PR, grep -v excludes that only line, writes a correctly-empty temp file, but exits 1 (its exit status reflects the inverted match count, not redirect success) — so the old &&-chained mv never ran and the "merged" PR stayed in parked.txt forever, exactly on the case that matters most (draining the last parked PR). The new pattern moves the temp file into place regardless of grep's exit code; also verified normal multi-entry removal still behaves correctly.

#2169)

grep -v's exit status reflects whether any line passed the inverted
filter, not whether the redirect succeeded. When the merged PR is the
only entry in parked.txt, every line is excluded and grep exits 1 even
though the empty result is exactly what's wanted -- so the chained
`&& mv` never ran, silently leaving the just-merged PR's number in
parked.txt forever. Decoupled the mv from grep's match-count exit code
with `|| true`. Verified against both the last-entry case and a normal
multi-entry removal.
@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread .claude/skills/fixer/SKILL.md Outdated
# server-side author filter, which previously meant issues by other authors could crowd
# this author's own low-numbered issues out of the fetched window). 1000 is a deliberately
# generous safety bound on one author's queue, not a realistic ceiling to ever hit.
gh issue list --state open --author "$AUTHOR" --limit 1000 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Backlog scan remains bounded

When an author has more than 1000 open issues and qualifying entries fall outside the first 1000 results, both queue construction and the completion check omit those entries, causing /fixer to report the backlog as drained while qualifying issues remain open.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 072b185 — correct that 1000 was still the same class of bug at a bigger size, not a fix. Rather than guess a third "generous enough" constant, both fetches (Phase 1's queue build and Phase 3's completion check) now use an effectively-unbounded ISSUE_FETCH_LIMIT (100000) and explicitly detect truncation: if the raw returned count ever equals that limit, the skill fails loudly rather than silently trusting an incomplete result. This closes the whole class of bug instead of moving the ceiling again. Verified gh issue list --limit 100000 behaves correctly (fast, no truncation) against this repo, and the truncation-detection branch itself with mocked data at a small limit.

400, then 1000: any fixed --limit on gh issue list is the same silent
truncation point at a different size, and it will keep recurring as an
author's backlog grows. Both the Phase 1 queue build and the Phase 3
batch-completion check now fetch against an effectively-unbounded limit
(100000) and fail loudly if that limit is ever actually returned in
full, instead of guessing at a bigger "generous" constant that could
still be exceeded and silently misreport an incomplete queue or a
falsely-drained backlog.
…codegraph-tool into fix/2169-fixer-drain-review
@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment on lines +909 to +910
fi
printf '%s\n' "$PARKED_AFTER" > .codegraph/fixer/drain-parked-count

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Drain reconciliation is interruption-unsafe

When the process stops after replacing parked.txt but before the separate state.json update completes, the merged PR disappears from the drain queue while its status remains parked. Because queue.json is already empty, the next invocation resets the run instead of resuming it, so the completed merge is lost from the final accounting.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 32c043c — this is a real gap: since queue.json is already empty by the time draining starts, a crash between the parked.txt removal and the separate state.json update would look like a genuinely fresh run to the next invocation, which would then wipe state.json (and parked.txt) instead of resuming, losing that merge from the final accounting entirely. Rather than try to make the two writes atomic or teach Phase 0 to treat drain-phase state as resumable (which has its own false-positive risk — a legitimately completed-but-blocked drain can end with a non-empty parked.txt too, so "parked.txt non-empty" alone isn't a safe resume signal), the drain phase now self-heals at the top of every pass: any state.json entry still marked "parked" whose PR is no longer listed in parked.txt is corrected to "merged" before anything else runs. Verified against both the interrupted case (reconciles correctly) and a normal still-parked case (correctly left untouched).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: the Fixed-in-32c043c7 reply above was necessary but not sufficient — Greptile's re-review of that commit (Confidence Score 3/5) correctly pointed out that Phase 0's resume-detection only ever looked at queue.json, which is legitimately already empty by the time draining starts. So an interruption anywhere during Phase 4 (not just the exact two-write window 32c043c targeted) would make the next invocation's Phase 0 read queue.json as empty, conclude the run had finished, and rm -f parked.txt plus reset state.json to {"issues":[]} before the self-heal step added in 32c043c ever got a chance to run — deleting the very evidence that step exists to recover.

Fixed in a26f43c: Phase 0 now also treats a non-empty parked.txt as evidence of a resumable (mid-drain) run, alongside queue.json, and only resets state when both are empty/absent. It also routes straight to Phase: Drain Parked PRs when queue.json is empty but parked.txt is not, instead of re-running the batch loop.

…#2169)

The drain-merge step's two-write reconciliation (parked.txt removal,
then a separate state.json parked->merged update) is not atomic: an
interruption landing between the two writes leaves parked.txt correctly
missing the merged PR while state.json still records it as parked. Since
queue.json is already empty once draining starts, a later invocation
reads that as a genuinely fresh run and would silently wipe the
stale-but-recoverable record, losing the completed merge from the final
accounting. The drain phase now reconciles any state.json "parked" entry
whose PR is absent from parked.txt (evidence it already merged) back to
"merged" before doing anything else that pass. Verified against both an
interrupted-drain case (reconciles) and a normal still-parked case
(leaves untouched).
…#2169)

Phase 0 decided fresh-run vs. resume from queue.json alone. queue.json is
legitimately already empty by the time Phase: Drain Parked PRs starts, so an
interruption anywhere during the drain (including the exact split-brain window
the prior commit's self-heal step was added to recover) looked identical to a
fully-completed run: the next invocation would delete parked.txt and reset
state.json before that self-heal step ever got a chance to run, silently
erasing every still-parked PR along with the evidence needed to recover the
interrupted merge.

Phase 0 now also treats a non-empty parked.txt as evidence of a resumable
(mid-drain) run, alongside queue.json, and routes straight to Phase: Drain
Parked PRs when queue.json is empty but parked.txt is not.
@carlos-alm

Copy link
Copy Markdown
Contributor Author

Addressed the Confidence Score 3/5 gap from the latest summary re-review of 32c043c:

Interrupted drain reconciliation could still be erased before the new recovery logic runs — the summary correctly identified that 32c043c's self-heal step (reconciling a parked.txt/state.json split-brain) never gets a chance to execute if Phase 0 already wiped parked.txt and state.json on the restart that follows an interruption. Phase 0's fresh-vs-resume decision only ever inspected queue.json, which is legitimately empty for the entire duration of Phase 4 (draining), so any interruption during the drain — not just the exact split-brain window — looked identical to a fully-completed run on the next invocation.

Fixed in a26f43c: Phase 0 now also treats a non-empty parked.txt as evidence of a resumable, mid-drain run alongside queue.json, only resets run-scoped state when both are empty/absent, and routes straight to Phase: Drain Parked PRs (skipping the batch loop) when queue.json is empty but parked.txt still has entries. Verified the fresh/resume decision logic against all four combinations (both empty, queue non-empty, parked non-empty, both non-empty) standalone before landing it.

@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread .claude/skills/fixer/SKILL.md Outdated
Comment on lines +154 to +160
PARKED_LEN=0
[ -s .codegraph/fixer/parked.txt ] && PARKED_LEN=$(wc -l < .codegraph/fixer/parked.txt)
if { [ -f .codegraph/fixer/queue.json ] && [ "$QUEUE_LEN" -gt 0 ]; } || [ "$PARKED_LEN" -gt 0 ]; then
echo "fixer: resuming an interrupted run — previous state:"
jq -r '.issues[] | " #\(.issue) \(.status) \(if .pr then "PR #\(.pr)" else "no PR" end)"' .codegraph/fixer/state.json 2>/dev/null
if [ "$QUEUE_LEN" -eq 0 ] && [ "$PARKED_LEN" -gt 0 ]; then
echo "fixer: queue.json is empty but parked.txt has $PARKED_LEN PR(s) — the batch loop had already finished and this run was mid-drain. Skip Phase 1-3 entirely and go straight to Phase: Drain Parked PRs."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Blocked drains resume forever

When Phase 4 terminates normally after three stalled passes or the 15-pass cap, it leaves the blocked PRs in parked.txt. The next invocation therefore classifies the completed run as interrupted and skips Phases 1-3, preventing newly qualifying issues from being queued until every old parked PR merges.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 994896d — this was a real regression risk in the previous fix (a26f43c). Phase: Drain Parked PRs' own exit condition is "merged, or reported as needing human review" — once a drain stops because 3 consecutive passes merged nothing, or the 15-pass cap was hit, the remaining parked.txt entries are a closed, already-reported matter for that run, not an interruption. a26f43c's blanket "non-empty parked.txt = resume" rule didn't distinguish that from a genuine mid-drain interruption, so it would have made every future invocation skip Phase 1-3 forever, re-attempting the same permanently-stuck PRs and starving newly opened issues.

Phase 0 now also reads drain-stall/drain-pass (already maintained by Phase: Drain Parked PRs) to tell the two cases apart: a non-empty parked.txt is only treated as a resume signal when the drain that left it there had not yet reached its own stall (>=3) or cap (>=15) threshold. Verified all six relevant state combinations (no state, fully-merged, mid-batch, mid-drain interrupted, drain stalled-out, drain capped-out) standalone before landing it.

…mable one (#2169)

The previous commit made Phase 0 treat any non-empty parked.txt as evidence of
a resumable mid-drain run, since queue.json is legitimately already empty for
the whole duration of Phase: Drain Parked PRs. But that phase's own exit
condition is "every PR merged, or reported as needing human review" — once a
drain stops because 3 consecutive passes merged nothing, or the 15-pass cap
was hit, the remaining parked.txt entries are a closed, already-reported
matter for that run, not an interruption. Treating them the same made every
subsequent invocation skip Phase 1-3 forever, re-attempting the same
permanently-stuck PRs and never queuing newly opened issues.

Phase 0 now also reads drain-stall/drain-pass (already maintained by Phase:
Drain Parked PRs) to tell the two cases apart: parked.txt is only a resume
signal when the drain that left it there had not yet reached its own
stall/cap threshold. Verified the fresh/resume decision against all six
relevant combinations (no state, fully-merged, mid-batch, mid-drain
interrupted, drain stalled-out, drain capped-out) standalone before landing
it.
@carlos-alm

Copy link
Copy Markdown
Contributor Author

Addressed the Confidence Score 3/5 finding from the review of a26f43c ("a normally completed blocked drain can make every subsequent invocation skip new backlog work"):

Phase 0's non-empty-parked.txt-means-resume rule (a26f43c) didn't distinguish a genuinely interrupted drain from one that had already stalled out (3 consecutive no-merge passes) or hit the 15-pass cap and legitimately reported its blocked PRs — both leave parked.txt non-empty. Fixed in 994896d: Phase 0 now also checks drain-stall/drain-pass (already maintained by Phase: Drain Parked PRs) and only treats parked.txt as a resume signal when the drain that left it there had not yet reached that threshold. A drain that already reported is now correctly classified as a completed run, so Phase 1-3 proceed normally and new backlog work is never starved.

@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread .claude/skills/fixer/SKILL.md Outdated
Comment on lines +167 to +168
if [ "$PARKED_LEN" -gt 0 ] && { [ "$DRAIN_STALL" -ge 3 ] || [ "$DRAIN_PASS_COUNT" -ge 15 ]; }; then
DRAIN_ALREADY_REPORTED=1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Threshold state precedes reporting

When the process stops after Phase 4 persists drain-stall=3 or drain-pass=15 but before the terminal report and Phase 5 complete, this branch treats the drain as already reported and deletes parked.txt and state.json, causing the unfinished parked PRs and final accounting to be lost.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ebfd3b7 — this was exactly right, and a real gap in 994896d. drain-stall/drain-pass are written mid-Phase-4, before Phase: Final Report ever runs, so a process stopping in the window after a counter crosses its threshold but before the report is actually produced would have been misclassified as "already reported."

Replaced the counter-based check with an explicit .codegraph/fixer/run-complete marker that Phase: Final Report touches as its last action, strictly after the report has been produced. Phase 0 now uses only that marker's presence to decide whether a non-empty parked.txt is a closed/reported matter (fresh run) or still needs draining (resume) — fully decoupled from the internal stall/cap counters. Verified all six relevant state combinations standalone, including this exact race, before landing it.

…rs (#2169)

The previous commit distinguished a genuinely-interrupted drain from an
already-reported blocked one by checking whether drain-stall/drain-pass had
crossed their stall/cap threshold. That check is itself racy: those counters
are written mid-Phase-4, before Phase: Final Report ever runs. A process
stopping in the narrow window after a counter crosses its threshold but
before the report is actually produced would be misclassified as "already
reported," deleting parked.txt and state.json before anyone ever saw the
blocked-PR report.

Phase: Final Report now touches .codegraph/fixer/run-complete as its last
action, strictly after producing the report. Phase 0 uses only this marker's
presence to decide whether a non-empty parked.txt is a closed, reported
matter (fresh run) or still needs draining (resume) — decoupling the
fresh-vs-resume decision from Phase 4's internal stall-detection counters
entirely. Resuming into an already-thresholded-but-unreported drain runs one
extra (cheap) pass before Phase: Drain Parked PRs' own bookkeeping stops it
again, which is what finally lets the report happen and the marker get
written. Verified all six relevant state combinations standalone, including
the exact race the previous commit missed, before landing this.
@carlos-alm

Copy link
Copy Markdown
Contributor Author

Addressed the Confidence Score 3/5 finding from the review of 994896d ("an interruption at the drain threshold can cause the next invocation to discard unfinished parked-PR state"):

Phase 0's stall/cap-counter check (994896d) was itself racy — drain-stall/drain-pass get persisted mid-Phase-4, before Phase: Final Report ever runs, so a process stopping in that window would be misclassified as "already reported." Fixed in ebfd3b7: replaced the counter-based check with an explicit .codegraph/fixer/run-complete marker, written by Phase: Final Report as its last action strictly after the report has been produced. Phase 0 now uses only that marker's presence — not the internal stall/cap counters — to decide whether a non-empty parked.txt is a closed/reported matter or still needs draining. Verified all six relevant state combinations standalone, including this exact race, before landing it.

@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

@carlos-alm
carlos-alm merged commit da390e8 into main Jul 29, 2026
29 checks passed
@carlos-alm
carlos-alm deleted the fix/fixer-drain-and-state-v2 branch July 29, 2026 17:26
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant