Skip to content

[3598 by Claude Opus 5.5] MCP: contradictory state fields and mixed timestamp formats in results - #3637

Merged
integry merged 2 commits into
3595-epic-0-9-h9lfrom
3598/claude-opus-5-5-mcp-contradictory-state-f-20261117-0248-lqk
Nov 17, 2026
Merged

integry merged 2 commits into
3595-epic-0-9-h9lfrom
3598/claude-opus-5-5-mcp-contradictory-state-f-20261117-0248-lqk

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3598

Branch: 3598/claude-opus-5-5-mcp-contradictory-state-f-20261117-0248-lqk
Commits: ✅ Changes committed (eb70e17)


AI Processing Completed

Execution Details:

Summary:
I've fixed all five points from issue #3598. Every packages/api/test/mcp* and goal* suite passes when run from the repo root. Lint and the API typecheck are clean.

1. Goal artifacts agree with the goal's pull requests (services/goalProjection.ts)

  • The goal projection that get_goal and the REST goal routes both use now checks the stored artifact list against recorded merges.
  • A pull request whose merge ProPR has seen is reported as merged with draft: false, and artifactStats.openPullRequests drops by one for it.
  • The REST response shape is unchanged; only these values are corrected. Nothing stored is rewritten.

2. Submission state matches the task (mcp/toolsTaskSubmissions.ts)

  • The stored submission row stops at queued once dispatched. get_task_submission and list_task_submissions now report state and submissionState from the task's stage once it is running, completed, failed or cancelled.
  • The create_task receipt and operation polling are unchanged, so operation tracking behaves as before.

3. One timestamp format (mcp/resultTimestamps.ts, wired into mcp/toolExecution.ts)

  • One recursive pass runs on every tool result. It rewrites fields whose names mark a time (*_at, *At, timestamp, *Time, since, until) to ISO 8601 UTC with Z.
  • That covers SQLite YYYY-MM-DD HH:MM:SS text, ISO strings with no zone or with an offset, and epoch milliseconds.
  • Values that are already UTC ISO strings are left exactly as they are. Durations, cursors, free text and other fields are not touched, and field names stay the same.

4. Plans and tasks

  • list_plans rows now have pull_requests_truncated, which is true when the short pull_requests list leaves some out.
  • In list_tasks, a missing agent_alias is filled from the agent recorded during execution, using the same source as the REST task status the CLI reads (loadTaskModelIdentities). A task with no such record still shows null.

5. list_followup_handoffs (mcp/toolsMaintenance.ts)

  • By default it returns only handoffs that are held for an operator or in automatic recovery.
  • New inputs: includeReleased (default false), offset, and limit (default 20, max 100). The result has a nextOffset for the next page.

Tests and docs

  • New tests cover each point:
    • goal artifacts: goalProjection.test.ts
    • submission state: mcpTaskSubmissions.test.ts
    • timestamps (unit and through executeTool): mcpResultTimestamps.test.ts
    • plan truncation: mcpPresentation.test.ts
    • task agent: mcpTaskLineage.test.ts
    • handoff filter and paging: mcpMaintenance.test.ts
  • I changed the expected values in mcpGoalTaskDepth and mcpTaskLineage, which asserted the old zone-less timestamps in MCP results.
  • I added the new field names that docs/mcp.md now mentions to the doc-word allowlist in mcpObservableSurface.
  • docs/mcp.md describes the timestamp rule, the agreeing state fields, the truncation flag, the agent fallback and the handoff options.

mcpResultTimestamps.test.ts exits normally when run from the repo root, as CI runs it. Run from inside packages/api, importing the tool catalog opens a second database connection that is never closed, so the process doesn't exit. That also happens on unchanged HEAD.

This changes MCP results only, nothing in the UI, so there are no previews.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (7 files)
    • packages/api/mcp/listSummaries.ts (+2/−0)
    • packages/api/mcp/resultTimestamps.ts (added, +64/−0)
    • packages/api/mcp/taskListing.ts (+19/−2)
    • packages/api/mcp/toolExecution.ts (+3/−1)
    • packages/api/mcp/toolsMaintenance.ts (+12/−3)
    • packages/api/mcp/toolsTaskSubmissions.ts (+19/−4)
    • packages/api/services/goalProjection.ts (+35/−2)
  • Low risk (9 files)
    • docs/mcp.md (+22/−3)
    • packages/api/test/goalProjection.test.ts (+30/−0)
    • packages/api/test/mcpGoalTaskDepth.test.ts (+11/−11)
    • packages/api/test/mcpMaintenance.test.ts (+53/−0)
    • packages/api/test/mcpObservableSurface.test.ts (+3/−0)
    • packages/api/test/mcpPresentation.test.ts (+7/−0)
    • packages/api/test/mcpResultTimestamps.test.ts (added, +108/−0)
    • packages/api/test/mcpTaskLineage.test.ts (+34/−2)
    • packages/api/test/mcpTaskSubmissions.test.ts (+41/−0)

Validation evidence

  • No repository validation commands ran.

Diff size: 16 files changed, +463/−28 lines

Detailed Logs:

  • Conversation: 348 messages
  • Session: c6a89214-351f-4c0f-9467-18e49b9ff1de

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3598-2026-11-17T03-27-03-561Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3598-2026-11-17T03-27-03-561Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: I've fixed all five points from issue #3598. Every `packages/api/test/mcp*` and `goal*` suite passes when run from the repo root. Lint and the API typecheck are clean.

**1. Goal artifacts agree with ...


This PR was created automatically by ProPR after processing issue #3598.


💡 Need changes?

Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!

…/mcp*` and `goal*` suite passes when run from the repo root. Lint and the API typecheck are clean.

1. Goal artifacts agree with the goal's pull requests (`services/goalProjection.ts`)
- The goal projection that `get_goal` and the REST goal routes both use now checks the stored artifact list against recorded merges.
- A pull request whose merge ProPR has seen is reported as `merged` with `draft: false`, and `artifactStats.openPullRequests` drops by one for it.
- The REST response shape is unchanged; only these values are corrected. Nothing stored is rewritten.

2. Submission state matches the task (`mcp/toolsTaskSubmissions.ts`)
- The stored submission row stops at `queued` once dispatched. `get_task_submission` and `list_task_submissions` now report `state` and `submissionState` from the task's stage once it is running, completed, failed or cancelled.
- The `create_task` receipt and operation polling are unchanged, so operation tracking behaves as before.

3. One timestamp format (`mcp/resultTimestamps.ts`, wired into `mcp/toolExecution.ts`)
- One recursive pass runs on every tool result. It rewrites fields whose names mark a time (`*_at`, `*At`, `timestamp`, `*Time`, `since`, `until`) to ISO 8601 UTC with `Z`.
- That covers SQLite `YYYY-MM-DD HH:MM:SS` text, ISO strings with no zone or with an offset, and epoch milliseconds.
- Values that are already UTC ISO strings are left exactly as they are. Durations, cursors, free text and other fields are not touched, and field names stay the same.

4. Plans and tasks
- `list_plans` rows now have `pull_requests_truncated`, which is true when the short `pull_requests` list leaves some out.
- In `list_tasks`, a missing `agent_alias` is filled from the agent recorded during execution, using the same source as the REST task status the CLI reads (`loadTaskModelIdentities`). A task with no such record still shows `null`.

5. `list_followup_handoffs` (`mcp/toolsMaintenance.ts`)
- By default it returns only handoffs that are held for an operator or in automatic recovery.
- New inputs: `includeReleased` (default false), `offset`, and `limit` (default 20, max 100). The result has a `nextOffset` for the next page.

Tests and docs
- New tests cover each point:
  - goal artifacts: `goalProjection.test.ts`
  - submission state: `mcpTaskSubmissions.test.ts`
  - timestamps (unit and through `executeTool`): `mcpResultTimestamps.test.ts`
  - plan truncation: `mcpPresentation.test.ts`
  - task agent: `mcpTaskLineage.test.ts`
  - handoff filter and paging: `mcpMaintenance.test.ts`
- I changed the expected values in `mcpGoalTaskDepth` and `mcpTaskLineage`, which asserted the old zone-less timestamps in MCP results.
- I added the new field names that `docs/mcp.md` now mentions to the doc-word allowlist in `mcpObservableSurface`.
- `docs/mcp.md` describes the timestamp rule, the agreeing state fields, the truncation flag, the agent fallback and the handoff options.

`mcpResultTimestamps.test.ts` exits normally when run from the repo root, as CI runs it. Run from inside `packages/api`, importing the tool catalog opens a second database connection that is never closed, so the process doesn't exit. That also happens on unchanged HEAD.

This changes MCP results only, nothing in the UI, so there are no previews.
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/ultrafix goal=8 max=6
Triggered automatically by the requested execution settings.

@propr-dev propr-dev Bot added the ultrafix label Nov 17, 2026
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 6)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR addresses the five presentation inconsistencies with focused changes and targeted tests. It needs a localized correction before merge: the new agent fallback can pair an execution agent with a stale submission model.

✅ Submission lifecycle isolation — Read responses follow task progress while mutation receipts retain their existing tracking behavior.

✅ Repository-scoped merge evidence — Goal artifacts use observed merges from the goal’s repository and adjust the open count without rewriting storage.

✅ Authorized handoff pagination — Repository access filtering occurs before pagination, so inaccessible records do not occupy returned pages.

This review used static analysis of the supplied code only; no commands were run. The authoritative check summary reports no failures and four pending checks.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Keep fallback agent and model consistent

  • Category: correctness

  • Required behavior: Task summaries must report a consistent agent/model identity when incorporating execution evidence.

  • Evidence: packages/api/mcp/taskListing.ts:fillExecutionAgents

    1. A task has no submission agent alias, but its job records a model such as opus. Execution routing subsequently records { model: 'gpt-5.6', agentAlias: 'codex' }, with matching execution model evidence.
    2. summarizeTask retains the submission model as model_name: 'opus' when the task row has no newer model.
    3. loadTaskModelIdentities correctly resolves the execution identity to gpt-5.6 and codex.
    4. The new fallback copies only agentAlias, producing agent_alias: 'codex' alongside model_name: 'opus'. Clients receive an agent/model combination that was never executed.

    static trace: The supplied taskModelIdentity implementation explicitly prioritizes execution evidence because submission routing can predate label resolution, and returns the model and agent together. Its pairing protection is lost when this caller discards modelName. The new test uses identical submission and execution models, so it does not cover this sequence.

  • Minimum fix: When filling an agent from execution identity, also populate model_name from that same identity, applying the existing text bound. Add a regression with different submission and execution models.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Qualify plan detail completeness

The new comment and documentation say get_plan lists every issue with its pull request, but the supplied toolsPlanning.ts:99 limits issues to 100. Qualify that guidance or address detail pagination separately. The retrieval limit predates this PR, so expanding it is optional.

Score

The changes are focused and have useful regression coverage, but the execution identity fallback introduces a contradictory result requiring correction. Current checks show no failures, with four still pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 43s
  • Tokens: 64,461 (63,692 in / 769 out)
  • Cost: $0.57

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit fb80750

Addressed 1 AI review comment (IDs: 6937327614)

Addressed finding F1

Summary of Changes

I fixed F1. When list_tasks fills in a missing agent from what the execution recorded, it now takes the model from that same record, so a task can't show an agent paired with a model it never ran.

What changed

  • packages/api/mcp/taskListing.ts (fillExecutionAgents): when the execution record supplies agentAlias, model_name is now set from that record's modelName too, with the same 100-character limit. In your example the task now reports codex/gpt-5.6 instead of codex/opus. Tasks that already had an agent from submission are unchanged.
  • packages/api/mcp/listSummaries.ts: MODEL_LIMIT is now exported so the fill uses the same limit as summarizeTask.
  • Test (packages/api/test/mcpTaskLineage.test.ts): a new case where submission recorded only opus and execution ran gpt-5.6 with codex. It asserts the pair ['codex', 'gpt-5.6']. With the old code put back, it fails with ['codex', 'opus'].
  • docs/mcp.md: the fallback sentence now says the task reports the model that agent ran. A docs test rejects the literal model_name there, so I reworded rather than adding it to that test's allowed-word list.

Other callers: fillExecutionAgents is the only place in the PR's changes that copies an agent out of the execution record. The REST task status path in routes/taskHelpers.ts reads agent and model from the same record together, so it doesn't have this bug.

Checks: mcpTaskLineage, mcpPresentation and mcpObservableSurface pass (18 tests). Lint (zero warnings) and the API typecheck are clean.

Disk ran out: the workspace disk filled to 100% partway through, and the failed write left packages/api/mcp/listSummaries.ts empty. I restored it from HEAD and checked it matched before editing again. To make room I deleted /tmp/node-compile-cache, which is only a cache. Free space then rose to about 20G, more than that deletion accounts for, so something else also released space. Most of the disk is in /tmp/git-processor (93G), so it may fill up again.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (2 files)
    • packages/api/mcp/listSummaries.ts (+1/−1)
    • packages/api/mcp/taskListing.ts (+9/−4)
  • Low risk (2 files)
    • docs/mcp.md (+1/−1)
    • packages/api/test/mcpTaskLineage.test.ts (+18/−0)

Validation evidence

  • No repository validation commands ran.

Diff size: 4 files changed, +29/−6 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 8m 47s
  • Tokens: 1,096,997 (1,090,568 in / 6,429 out)
  • Cost: $0.60

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

… what the execution recorded, it now takes the model from that same record, so a task can't show an agent paired with a model it never ran.

I fixed F1. When `list_tasks` fills in a missing agent from what the execution recorded, it now takes the model from that same record, so a task can't show an agent paired with a model it never ran.

**What changed**
- **`packages/api/mcp/taskListing.ts` (`fillExecutionAgents`)**: when the execution record supplies `agentAlias`, `model_name` is now set from that record's `modelName` too, with the same 100-character limit. In your example the task now reports `codex`/`gpt-5.6` instead of `codex`/`opus`. Tasks that already had an agent from submission are unchanged.
- **`packages/api/mcp/listSummaries.ts`**: `MODEL_LIMIT` is now exported so the fill uses the same limit as `summarizeTask`.
- **Test** (`packages/api/test/mcpTaskLineage.test.ts`): a new case where submission recorded only `opus` and execution ran `gpt-5.6` with `codex`. It asserts the pair `['codex', 'gpt-5.6']`. With the old code put back, it fails with `['codex', 'opus']`.
- **`docs/mcp.md`**: the fallback sentence now says the task reports the model that agent ran. A docs test rejects the literal `model_name` there, so I reworded rather than adding it to that test's allowed-word list.

**Other callers:** `fillExecutionAgents` is the only place in the PR's changes that copies an agent out of the execution record. The REST task status path in `routes/taskHelpers.ts` reads agent and model from the same record together, so it doesn't have this bug.

**Checks:** `mcpTaskLineage`, `mcpPresentation` and `mcpObservableSurface` pass (18 tests). Lint (zero warnings) and the API typecheck are clean.

**Disk ran out:** the workspace disk filled to 100% partway through, and the failed write left `packages/api/mcp/listSummaries.ts` empty. I restored it from HEAD and checked it matched before editing again. To make room I deleted `/tmp/node-compile-cache`, which is only a cache. Free space then rose to about 20G, more than that deletion accounts for, so something else also released space. Most of the disk is in `/tmp/git-processor` (93G), so it may fill up again.

PR: #3637
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

❌ ProPR could not start on /review

The job failed 3 times before processing began:

API rate limit exceeded for installation ID 68212616. If you reach out to GitHub Support for help, please include the request ID 8510:3A5AC:5E8FD80:8E55EDC:6AFBCD70 and timestamp 2026-11-17 03:43:45 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

Post the command again once the cause is resolved.

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

❌ 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.

1 similar comment
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

❌ 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.

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Ultrafix stopped before reaching its goal. Requested goal: 8/10. Last score: unknown. Max cycles were exhausted, so manual review and merge are now required.

@propr-dev propr-dev Bot changed the title 🔨 [3598 by Claude Opus 5.5] MCP: contradictory state fields and mixed timestamp formats in results ⚠️⑥ [3598 by Claude Opus 5.5] MCP: contradictory state fields and mixed timestamp formats in results Nov 17, 2026

integry commented Nov 17, 2026

Copy link
Copy Markdown
Owner

/ultrafix goal=8 max=4

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 4)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev propr-dev Bot changed the title ⚠️⑥ [3598 by Claude Opus 5.5] MCP: contradictory state fields and mixed timestamp formats in results 🔨 [3598 by Claude Opus 5.5] MCP: contradictory state fields and mixed timestamp formats in results Nov 17, 2026
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

This PR is ready to merge within the reviewed scope. It addresses the five consistency issues with focused projection changes, matching documentation, and regression coverage. Review was static; no commands were run. The supplied current-head checks show 16 passed, none failed or pending, and 23 neutral/skipped.

✅ Submission lifecycle consistency — Reads derive running and terminal states from task progress while preserving mutation receipt tracking.

✅ Repository-scoped merge reconciliation — Goal artifacts use observed merges from the matching repository, clear draft status, and adjust the open count without rewriting storage.

✅ Shared timestamp boundary — Normalization covers nested results while preserving non-timestamp fields, with both unit and executor-level coverage.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S2: 🟢 Stabilize handoff pagination order

list_followup_handoffs slices the inspection result, while the supplied store query has no explicit ordering. A deterministic order with a unique tie-breaker would make paging more predictable. This is optional hardening: the supplied code does not establish an actual skipped or duplicated record sequence.

S3: 🟢 Cover cancellation and replacement reads

The new submission tests cover queued, running, completed, and failed states. Adding cancellation and a completed-to-replacement transition would strengthen coverage of reads following the latest attempt. This is optional because the shared stage mapping and latest-task selection support those paths in the supplied code.

Score

The implementation is focused, has substantial relevant coverage, and has no verified merge blockers. Current-head checks are successful; validation here was limited to the supplied code and context.

Score: 9/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 23s
  • Tokens: 64,559 (64,121 in / 438 out)
  • Cost: $0.53

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S2 S3

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 17, 2026
@propr-dev propr-dev Bot changed the title 🔨 [3598 by Claude Opus 5.5] MCP: contradictory state fields and mixed timestamp formats in results ✅⑨ [3598 by Claude Opus 5.5] MCP: contradictory state fields and mixed timestamp formats in results Nov 17, 2026
@integry
integry merged commit 9060702 into 3595-epic-0-9-h9l Nov 17, 2026
42 checks passed
@propr-dev propr-dev Bot changed the title ✅⑨ [3598 by Claude Opus 5.5] MCP: contradictory state fields and mixed timestamp formats in results [3598 by Claude Opus 5.5] MCP: contradictory state fields and mixed timestamp formats in results Nov 17, 2026
propr-dev Bot pushed a commit that referenced this pull request Nov 17, 2026
…e worker refuses an Ultrafix step for disk pressure, the loop now waits and retries that step, and it posts one waiting notice instead of a refusal comment per attempt. If space doesn't come back, it stops with a notice that gives the real reason, last score and cycle. Everything already in the PR is kept, and the new regression tests pass.

I've implemented the Correction section from #3642. When the worker refuses an Ultrafix step for disk pressure, the loop now waits and retries that step, and it posts one waiting notice instead of a refusal comment per attempt. If space doesn't come back, it stops with a notice that gives the real reason, last score and cycle. Everything already in the PR is kept, and the new regression tests pass.

**Waiting instead of failing**
- When a step's job has used up its attempts and the error is `WorktreeDiskPressureError`, the refusal is recorded on the loop as a wait (new `src/jobs/ultrafixDiskPressureWait.ts`, wired in through `ultrafixExhaustedStep.ts`). It does not count toward the "failed N times in a row" limit.
- The same step is retried after 2, 5, 10, 20 and 20 minutes, 57 minutes in total. The re-arm code itself enforces this, so neither the daemon sweep nor a check event can retry sooner. If a fix was refused, the fix is retried, not swapped for a review.
- The first refusal posts "⏳ Ultrafix is waiting for free disk space on the worker" once. Later refusals post nothing, and the per-attempt "could not start" comment from `prCommentUnstartedFailure.ts` is skipped for these steps.
- Once a step is admitted and completes, the wait ends and the loop carries on as usual.

**Stop notice when space doesn't return**
- After the sixth refusal (about an hour), the loop finishes as failed with the reason "The worker had no free disk space". The notice says how long it waited, how many times the step was refused and that the loop stopped at cycle N of M, and the `ultrafix` label is removed.
- "Last score: unknown" on #3637 happened because an active loop has no final score until it finishes. The loop now keeps its latest review score as it goes, and the stop notice uses it. This also fixes the score on the recovery-limit stop notice.

**Tests**
- In `test/ultrafixCiFailureRecovery.test.ts`:
  - Two refusals then a successful admission: the loop continues, posts one notice and no refusal comments, and nothing is counted as failed.
  - Persistent refusals: the loop ends with one stop notice ("Last score: 5", "no free disk space", "stopped at cycle 1 of 5"), and the label is removed.
  - A refusal for a job that is no longer the loop's current step still gets the ordinary refusal comment.
- In `test/prCommentTaskStateFinalizers.test.ts`, a new test checks that the per-attempt comment is skipped.
- I temporarily broke five parts of the fix one at a time; the new tests caught each one.
- All 33 Ultrafix-related suites, `checkRunHandler` and the docs manifest test pass. Typecheck and zero-warning lint on the changed files are clean.
- The real-Redis integration suite was skipped because there's no Redis in this container, and nothing was tried against a real worker with a full disk.

**Docs:** `docs/docs/features/pr-commands.md` now describes the disk-space wait.

Decision for you: the wait is 57 minutes, short of the full hour. Your example gaps (2, 5, 10, 20) add up to 37 minutes, so I added a second 20-minute wait; the schedule is one constant, `ULTRAFIX_DISK_PRESSURE_RETRY_DELAYS_MS`, if you want it changed.

Limitation: if the job for the `/ultrafix` command itself is refused, it still gets the ordinary "post the command again" comment. That is the existing behaviour, and only the loop's own review and fix steps wait for space.

No previews, since nothing visible in the UI changed.

PR: #3649
Comment by: @integry (ID: 6941588329)
Model: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant