Skip to content

Ultrafix: the loop ends as "failed" seconds after CI passes, because the daemon sweep re-arms a loop whose next review was just enqueued; no stop notice is posted #3642

Closed

Description

@integry

Problem

After a fix push, Ultrafix posts "⏳ Ultrafix is waiting for CI before the next /review." When CI passes, the loop should run the next review. On 2026-11-17 three loops instead ended as failed within a minute, with no comment on the pull request: #3615 (head da590e9), #3629 (head 461e6fe), #3637 (head fb80750). Afterwards:

  • get_pull_request_readiness reports ultrafix: { active: false, completionStatus: "failed", labelPresent: true }, ai_review: review_stale_head (the new head was never reviewed);
  • the PR title keeps the previous head's score (⚠️⑥) and the ultrafix label stays on the PR;
  • the last ProPR comment on the PR is still the "waiting for CI" notice, which says the loop continues automatically.
    The user has to notice the stall and start Ultrafix again by hand.

Daemon log for #3637 (UTC):

03:58:03.996 Ultrafix deferred resume: readiness re-check   pr 3637 ready: true
03:58:04.004 Ultrafix loop: enqueued next review step        jobId …3637-ultrafix-review-2-2-… delayMs: 5000
03:58:04.004 Ultrafix deferred resume: enqueued next step    nextAction: review
03:58:22.030 Ultrafix loop: enqueued next review step        jobId …3637-ultrafix-review-3-2-… delayMs: 5000
03:58:22.030 Ultrafix re-arm: enqueued review for stranded loop   workEpoch: 3 previousWorkEpoch: 2
03:58:22.030 [ultrafix] continuation resumed by daemon sweep  reason: stranded_loop_rearmed cycleCount: 1
03:58:45.932 Ultrafix re-arm: circuit breaker tripped, finishing loop  completionStatus: failed
             reason: "Ultrafix steps failed 3 times in a row without completing (recovery limit 2)"
03:58:46.730 Ultrafix loop: loop finished  cycleCount: 1 goalReached: false

So 18 seconds after the deferred resume enqueued the review (with a 5 s delay, and the review job may also wait for agent capacity when several loops run at once), the daemon sweep judged the loop "stranded", re-armed it under a new work epoch (which supersedes the review that was just enqueued), did so again about 20 s later, and the recovery limit ended the loop. Nothing had actually failed.

Expected / acceptance criteria

  • A loop whose next step was enqueued and is still delayed, waiting or running is not "stranded": the sweep does not re-arm it. Re-arming happens only when no job for the loop's current work epoch exists in any live queue state and a grace period (longer than the enqueue delay plus normal capacity waits) has passed since the last enqueue.
  • A re-arm that supersedes a job which had not failed does not count toward "steps failed N times in a row".
  • With several Ultrafix loops waiting for CI and for agent capacity at the same time (the situation above: about seven loops, three stalled), every loop continues to its next review after CI passes.
  • Whenever a loop ends without reaching its goal, for any reason including the recovery limit, the stop notice is posted on the pull request with the reason in plain words, the ultrafix label is removed, and the PR status no longer says Ultrafix is in progress.
  • Regression tests: (1) deferred resume enqueues a delayed review, the sweep runs before the job starts, the loop is not re-armed and the review runs; (2) the same with the review job waiting for capacity; (3) a loop ended by the recovery limit posts the stop notice and removes the label.

Implementation

Search src/jobs for the log messages quoted above: Ultrafix deferred resume, Ultrafix re-arm: enqueued review for stranded loop, continuation resumed by daemon sweep, circuit breaker tripped (ultrafixLoopContinuation.ts, ultrafixLoopContinuationHelpers.ts, ultrafixCiWait.ts, ultrafixOrchestrationService.ts, ultrafixStopNotice.ts and the daemon sweep that calls them). Find how the sweep decides a loop is stranded and why a just-enqueued delayed job for the current epoch is not seen.

Notes

ProPR runs on SQLite only: do not add code or tests for other databases. Ordinary task runs are one-shot: no mid-run interaction. Another open change in this release (issue #3593, merged into branch 3589-epic-0-9-y3w) edits the same Ultrafix files for stop-notice scores and cycle numbering; keep this change small so the two merge cleanly.

Correction (2026-11-17 04:55 UTC): what actually failed

The review steps did fail, and the daemon sweep is not the first cause. Between the log lines above, the worker refused each enqueued review at admission because free disk space on the worktree filesystem was below the reserve (WorktreeDiskPressureError, packages/core/src/storage/lifecycle.ts), and posted on the pull request (#3637, 03:58:16 and 03:58:35 UTC):

❌ ProPR could not start on /review — The ProPR worker refused the job because the disk that holds its working copies is nearly full. Nothing was changed on this pull request. Once space has been freed on the worker host, post the command again.

The host frees space with an hourly cleanup, and five minutes later there was room again. Two refusals 19 seconds apart were enough to reach "steps failed 3 times in a row (recovery limit 2)" and end the loop. On #3637 the stop notice then said "Last score: unknown. Max cycles were exhausted", which is not what happened (cycle 1 of 6, last score 6/10); on #3615 no stop notice was posted at all.

Revised acceptance criteria (these replace the first two bullets above; the stop-notice bullet stays):

  • A step refused at admission for disk pressure (or any other "could not start, nothing was changed" refusal) is a transient condition for Ultrafix: the loop waits and retries the same step with backoff (for example 2, 5, 10, 20 minutes, up to about an hour in total) instead of counting it toward the consecutive-failure limit. It posts one notice saying it is waiting for disk space, not one refusal comment per attempt.
  • If space does not return within that time, the loop stops with a stop notice that names the real reason ("the worker had no free disk space"), the real last score and the real cycle count.
  • The daemon sweep does not re-arm a loop faster than this backoff.
  • Regression tests: two consecutive disk-pressure refusals followed by a successful admission continue the loop; persistent refusals end it with the correct notice.

Activity

  1. propr-dev commented on Nov 17, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 3642/claude-opus-5-5-ultrafix-the-loop-ends-as-20261117-0428-tl8
    • Base Branch: 3642-epic-0-9-y57
    • Worktree: issue-3642-20261117-0428-claude-opus-5-5-tl8

    🔍 Track Task Execution

  2. propr-dev commented on Nov 17, 2026

    @propr-dev
    Contributor

    ⚠️ Post-processing encountered an error, but ProPR analysis was completed.

    Post-processing Error:
    API rate limit exceeded for installation ID 68212616. If you reach out to GitHub Support for help, please include the request ID 811E:25ECF5:6614E5C:99AD873:6AFBDB46 and timestamp 2026-11-17 04:42:46 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting

    AI Processing Completed

    Execution Details:

    Summary:
    I fixed both halves of the issue. The sweep no longer re-arms a loop whose next review was just enqueued. When a loop ends without reaching its goal, it now posts the reason in plain words and removes the ultrafix label.

    Why the sweep saw a "stranded" loop. The sweep decided a loop was stranded with a single queue scan. That scan looked only at waiting, active and delayed jobs, and nothing recorded that a step had just been enqueued. So any scan that missed the review meant the loop looked idle and got re-armed under a new epoch, which supersedes that review. A miss can happen while the job moves between queue states during a capacity or PR-lock wait, or when the job sits in a state the scan didn't list, such as prioritized. An existing test (a re-arm that misses a pending review in the queue scan supersedes it) had pinned this as intended behaviour; I replaced it. I couldn't prove from the logs which of these happened in the three stalled loops.

    What changed

    • New src/jobs/ultrafixStepEnqueueMarker.ts: every enqueued step now records its job ID, epoch, time and delay in Redis.
    • Re-arm check (ultrafixStrandedLoopRearm.ts): before re-arming, the sweep looks that job up directly. If it is in any live state, or it can't be found and less than its delay plus 10 minutes has passed, the loop is left alone. The sweep then schedules a later check instead of acting. A job that failed or completed is not held, so a step that really failed is still recovered at once (failed jobs are kept for 7 days, so they stay visible).
    • Queue scan: it now covers all live states, including prioritized, waiting-children and paused.
    • Failure count: re-arming never added to the "failed N times in a row" count; only jobs that exhaust their attempts do. Since the sweep no longer supersedes live jobs, that count can no longer grow without real failures. I didn't change the counting itself.
    • Stop notice: for the recovery limit it used to say "Max cycles were exhausted". It now says the steps failed 3 times in a row and to restart with /ultrafix.
    • Label: it is now removed on every failed finish, including the "CI did not settle" stop. This reverses the documented behaviour, which left the label on the PR. Removing the label clears the loop state, so the PR status stops showing Ultrafix as in progress.
    • Docs: docs/docs/features/pr-commands.md is updated to match.

    Tests. The three regression tests are in test/ultrafixCiFailureRecovery.test.ts:

    1. A delayed review was just enqueued, the sweep runs before it starts, and the scan misses it: no re-arm, same epoch, the review then runs, and nothing is counted as failed.
    2. The review is waiting for agent capacity (moved back to delayed): no re-arm. A prioritized job is also seen by the scan.
    3. The recovery-limit test now checks that one stop notice is posted with the failure reason and that the label is removed.

    I added a fourth test showing a job that has vanished is re-armed only after the grace period, and a label-removal check to the CI-timeout test.

    Results. All 24 Ultrafix suites and checkRunHandler pass, and so does the docs manifest test. Root typecheck and lint with --max-warnings 0 on the changed files are clean. The four new or changed tests fail when the fix is temporarily disabled. The real-Redis integration suite didn't run because there's no Redis in this container.

    The scenario with about seven loops running at once was tested only through these simulated queue states, not under real load. The change touches the stop-notice code that #3593 also edits, though only with a few added lines.

    There are no visual previews because nothing visible in the UI changed.

    Detailed Logs:

    • Conversation: 183 messages
    • Session: cc85cfee-0d12-4ec1-9843-43a58bdf6a07

    Log files stored at:

    • conversation: /usr/src/app/logs/executions/issue-3642-2026-11-17T04-42-49-762Z-conversation.json
    • output: /usr/src/app/logs/executions/issue-3642-2026-11-17T04-42-49-762Z-output.txt
    Latest Conversation Messages
    ASSISTANT: [content unavailable]
    
    ASSISTANT: I fixed both halves of the issue. The sweep no longer re-arms a loop whose next review was just enqueued. When a loop ends without reaching its goal, it now posts the reason in plain words and removes...
    
    

    This processing report was generated automatically by ProPR for issue #3642.

  3. added a commit that references this issue on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions