Skip to content

fix(item): preserve live PR tracking on redispatch - #951

Merged
getappz merged 3 commits into
masterfrom
task/736-redispatch-clears-metadata-pr-even-when
Oct 24, 2026
Merged

getappz merged 3 commits into
masterfrom
task/736-redispatch-clears-metadata-pr-even-when

Conversation

@getappz

@getappz getappz commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Redispatching fixes for a live PR now preserves metadata.pr and its review state, including when GitHub cannot be reached. keep_pr: true overrides the lookup. Merged, closed, or missing PRs are cleared together with review_threads and coderabbit_repair_announced_for in one metadata write. A replacement PR attached during the lookup is retained.

The closed-PR supervisor also binds its cleanup verdict to the PR number confirmed closed, including its no-assignee SQL fallback. A caller-level regression replaces PR #501 with #502 after the supervisor guard and verifies the replacement PR and review metadata survive in both assignee paths.

Depends on #946 for PR recovery. The redispatch handler and its new MCP test were split into modules to satisfy the repository's file-size gate.

Validation at bfa6231a:

  • cargo fmt --check and cargo fmt --all --check: pass after cargo fmt fixed test formatting.
  • Exact local workspace clippy, cargo test --workspace, and the new regression were run to completion; verification is blocked by disk exhaustion (OS error 112) in the shared Cargo target directory. Earlier attempts also waited on the shared build lock. No local test-pass claim is made for this revision.
  • New-head CI formatting, exact workspace clippy, Linux/Windows workspace tests and doctests, Rust analysis, and CI Green pass. Linux reports 4,614 passed / 10 skipped and explicitly passes the new race regression. Windows completes successfully in 19m31s. Foreground gh pr checks 951 --watch --interval 20 completes with exit 0. CI run: https://github.com/getappz/agentflare/actions/runs/39732252509
  • Initial implementation's backend redispatch tests: 12 passed. Its CI was green; current-head results are tracked separately above.

Opened by codex on i-flare-c997d745ae66 (flared:c997d745ae66) for item #736 via agentflare.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 29 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 56 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between fcd7540 and 11cad65.

Files selected for processing: 17
  • crates/agentflare-backend/src/item/claim.rs
  • crates/agentflare-backend/src/item/tests.rs
  • crates/agentflare-backend/src/item/tests_finalize.rs
  • src/claim_liveness.rs
  • src/mcp_server/handoff.rs
  • src/mcp_server/item.rs
  • src/mcp_server/item_redispatch.rs
  • src/mcp_server/tests/action_tests.rs
  • src/mcp_server/tests/redispatch_tests.rs
  • src/mcp_server/types.rs
  • src/supervisor.rs
  • src/supervisor/merge.rs
  • src/supervisor/tests/multi_project_sweep_tests.rs
  • src/supervisor/tests/stray_pr_tests.rs
  • src/supervisor_project_scope_tests.rs
  • src/worktree/mod.rs
  • src/worktree/mod_tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@getappz getappz changed the title fix: redispatch clears metadata.pr even when retrying fixes on a live open PR (loses PR tracking, risks duplicate PR) fix(item): preserve live PR tracking on redispatch Oct 22, 2026
@getappz
getappz marked this pull request as ready for review October 22, 2026 09:45
@getappz

getappz commented Oct 22, 2026

Copy link
Copy Markdown
Owner Author

Heads-up on one interaction with a change that landed after this PR was opened: #953 (item done now completes an item whose PR has already merged, and metadata.pr survives that completion).

Two things worth knowing, both in your favour:

  1. This PR removes the first line of defence chore: item done leaves an item stuck In Progress when its PR was merged externally before finalize ran (seen on #283 / PR #910) #953 relied on. chore: item done leaves an item stuck In Progress when its PR was merged externally before finalize ran (seen on #283 / PR #910) #953's argument was "it keys on metadata.pr, and redispatch clears that — so an item re-dispatched for more work carries no PR reference and can never be completed by someone else's merge". Under this PR's PrRetention::Keep, a redispatched item with a live PR keeps metadata.pr, so that argument no longer holds.

  2. The load-bearing condition is unaffected. chore: item done leaves an item stuck In Progress when its PR was merged externally before finalize ran (seen on #283 / PR #910) #953 also requires the merge to have covered the branch — the local branch tip has to be exactly the PR's head sha (worktree::branch_is_covered_by_merged_pr). A retried attempt that pushes to the same branch moves the tip, so a later merge of that PR completes the item exactly when it should; and a redispatched item whose branch has moved on past the merged commit is not completed away. The one narrow case that changes is "redispatch → the agent commits nothing → the old PR merges", where the item now completes instead of staying open — which reads as correct anyway (nothing was delivered, and the work did merge).

Net: the two changes agree. PrRetention::Keep + the branch-coverage check compose into "the PR is the unit of work", which is the same shape as PrRetention::Clear for the dead-PR case.

One note on ordering: PrRetention::Clear covers "the PR is merged" — and with #953 a merged PR can now also arrive at done. Both paths want the same outcome (the item is done), so no conflict there either.

Not a blocker — just wanted the reasoning on the record, since #953's doc comment cites the old redispatch behaviour and will need a line updated when this lands.

Agentflare-Branch: task/736-redispatch-clears-metadata-pr-even-when
Agentflare-Item: 736
Agentflare-Branch: task/736-redispatch-clears-metadata-pr-even-when
Agentflare-Item: 736
…, not the stray sweep

Agentflare-Agent: claude-code_2-1-310_harness
Agentflare-Branch: task/736-redispatch-clears-metadata-pr-even-when
Agentflare-Item: 736
Agentflare-Session: 6278f161-4bdc-41bb-a62e-8f0e3e29b9ed
@getappz
getappz force-pushed the task/736-redispatch-clears-metadata-pr-even-when branch from bcc9598 to 11cad65 Compare October 24, 2026 07:15
@getappz
getappz merged commit 87fd9d4 into master Oct 24, 2026
14 of 16 checks passed
@getappz
getappz deleted the task/736-redispatch-clears-metadata-pr-even-when branch October 24, 2026 07:33
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