fix(reconciler): branch-fallback Phase 2 so features without prNumber reconcile#3642
Conversation
… still reconcile Closes #3613. Every PR in this session's dogfood loop (#3636, #3637, #3638, #3639) sat in [review] until manual re-dispatch — even though the 60-second PostMergeReconciler poll was firing on schedule (44+ executions, 2ms each, no failures). Root cause: three of the original stuck features (#3593, #3611, #3612) had `prNumber: null` and `prUrl: null` on disk, because the PR-creation write path (PostAgentHook recovery or normal REVIEW) didn't always persist the metadata back to feature.json. The reconciler's filter required both fields, so those features were silently skipped every tick. Fix: PostMergeReconcilerCheck now runs in two phases. Phase 1 (existing): features with `prNumber` + `prUrl` → `gh pr view` direct lookup, transitions to done if merged. Phase 2 (new): features with `branchName` but missing `prNumber` or `prUrl` → `gh pr list --head <branch> --state merged --limit 1`. When a merged PR is found, writes `prNumber`/`prUrl`/`prMergedAt` back to the feature so subsequent ticks short-circuit through Phase 1. This is a safety-net fix — it doesn't remove the underlying need to plug the write-path gap that drops PR metadata, but it eliminates the permanent-stuck case where a feature has no way to be picked up by the reconciler. Tests: 15/15 passing. The two original "skips features without prNumber/prUrl" tests are now "falls back to branchName lookup" covering the new path. The "zero counts" test now requires *also* missing branchName to assert the skip path. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Warning Review limit reached
Your plan currently allows 2 reviews/hour. Refill in 21 minutes and 36 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Code Review — ? finding(s)
protoLabs Code Review Report
No findings recorded. |
) The Post-Merge reconciler check called `gh pr view --json state,merged` but `merged` is not a valid field on `gh pr view` (the available boolean-ish field is `mergedAt` — null when unmerged, ISO string when merged). Every call exited non-zero with "Unknown JSON field: merged", the catch handler logged at debug level (effectively /dev/null), and the feature was silently skipped every tick. Observed in this session: the 60-second reconciler timer fired 1168 times with 0 failures (because the catch swallows them) and 0 reconciliations across two PRs that had been merged for hours. The WebhookHealthCheck flagged "PR has been in review for 1023 min with no CI events" but nothing tied it back to the reconciler being broken. Fix: - gh args: `--json state,mergedAt` instead of `state,merged` - isMerged predicate: `state === 'MERGED' || mergedAt != null` - catch handler: bumped from `debug` to `warn` so this class of bug surfaces immediately if it happens again - updated tests + interface type The Phase 2 (branch-fallback) path I shipped in #3642 was correct on its own merits — but Phase 1 silently failing is what made Phase 2 appear necessary in the first place. Both paths now work as intended. Co-authored-by: Automaker <automaker@localhost> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Closes #3613.
Summary
Every PR in this session's dogfood loop (#3636, #3637, #3638, #3639) sat in `[review]` until manual re-dispatch — even though the 60-second `PostMergeReconciler` poll was firing on schedule (44+ executions, 2ms each, no failures).
Root cause: three of the original stuck features (#3593, #3611, #3612) had `prNumber: null` and `prUrl: null` on disk, because the PR-creation write path (PostAgentHook recovery or normal REVIEW phase) didn't always persist the metadata back to `feature.json`. The reconciler's filter required both fields, so those features were silently skipped every tick.
Fix
`PostMergeReconcilerCheck` now runs in two phases:
Phase 1 (existing): features with `prNumber` + `prUrl` → `gh pr view` direct lookup. Transitions to `done` if merged.
Phase 2 (new): features with `branchName` but missing `prNumber` or `prUrl` → `gh pr list --head --state merged --limit 1`. When a merged PR is found, writes `prNumber`/`prUrl`/`prMergedAt` back to the feature so subsequent ticks short-circuit through Phase 1.
This is a safety-net fix — it doesn't remove the underlying need to plug the write-path gap that drops PR metadata, but it eliminates the permanent-stuck case where a feature has no way to be picked up by the reconciler.
Verification
Test plan
🤖 Generated with Claude Code