Skip to content

GH#18815: fix(pulse-merge): file-overlap verification before auto-closing conflicting worker PRs#18820

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/close-conflicting-pr-overlap-check
Apr 14, 2026
Merged

GH#18815: fix(pulse-merge): file-overlap verification before auto-closing conflicting worker PRs#18820
marcusquinn merged 1 commit intomainfrom
bugfix/close-conflicting-pr-overlap-check

Conversation

@marcusquinn
Copy link
Copy Markdown
Owner

@marcusquinn marcusquinn commented Apr 14, 2026

Summary

Fixes the false-positive in _close_conflicting_pr that closed PR #18760 (t2060 task-complete-helper implementation) by claiming the work had landed on main via PR #18749 — when in fact #18749 was a planning-only PR. Implementation files were never touched on main. The fix adds file-overlap verification: a matching commit must share at least one non-planning file with the closing PR before the auto-close fires. On overlap miss or file lookup error, fail CLOSED (leave PR open, post rebase nudge). Recovery for the existing victim is in PR #18760 (reopened).

Files Changed

.agents/scripts/pulse-merge.sh,.agents/scripts/tests/test-close-conflicting-pr-wording.sh

Runtime Testing

  • Risk level: Low (agent prompts / infrastructure scripts)
  • Verification: shellcheck clean on pulse-merge.sh and test-close-conflicting-pr-wording.sh; 7/7 assertions pass in test-close-conflicting-pr-wording.sh including 4 new GH#18815 regressions; 6/6 pass in test-pulse-merge-rebase-nudge.sh; 26/26 pass in test-pulse-wrapper-characterization.sh; 8/8 pass in test-pulse-wrapper-main-commit-check.sh

Resolves #18815


aidevops.sh v3.8.18 plugin for OpenCode v1.4.3 with claude-opus-4-6 spent 21m and 64,602 tokens on this with the user in an interactive session.

Summary by CodeRabbit

  • Bug Fixes
    • PR auto-close logic now distinguishes between planning-file overlaps and implementation conflicts. Planning files (README, TODO, VERSION, configs) no longer trigger auto-closure. Workers receive a rebase nudge comment instead. Added fail-closed error handling to prevent false-positive closures.

…icting worker PRs

The deterministic merge pass closed PR #18760 with a false 'work has
already landed on main' claim, citing PR #18749 as the merging PR.
PR #18749 was a planning-only PR (added briefs, modified TODO.md) —
it touched zero implementation files. The closing PR's task ID
appeared in #18749's commit subject ('plan(t2059, t2060): file
follow-ups...') and the task-ID grep matched, but no implementation
work had landed.

Fix: require non-planning file overlap between the closing PR and
the matching commit before claiming 'work landed on main'. On
overlap miss OR file-lookup failure, fail CLOSED — leave the PR
open and post a one-time rebase nudge instead of discarding work.

Three new helpers:
- _is_planning_path_for_overlap: classifies TODO.md, README.md,
  CHANGELOG.md, VERSION, todo/**, and simplification-state.json as
  planning paths that cannot satisfy the duplicate-work signal.
- _verify_pr_overlaps_commit: fetches the closing PR's files and
  the matching commit's files, returns 0 only on non-planning
  intersection; returns 1 on lookup failure (fail-CLOSED).
- _post_rebase_nudge_on_worker_conflicting: idempotent rebase nudge
  modelled on _post_rebase_nudge_on_interactive_conflicting,
  posted exactly once per affected worker PR.

Refactored _close_conflicting_pr to fetch (sha, subject) JSON
from gh api commits and use jq for word-boundary matching, so
the matching commit's files can be looked up by SHA.

Test coverage: extends test-close-conflicting-pr-wording.sh from 3
to 7 assertions covering 4 new GH#18815 regressions:
- Planning-only match leaves PR open (the #18760 incident exactly)
- Real implementation overlap still closes PR
- commit-files lookup failure → fail-CLOSED
- PR-files lookup failure → fail-CLOSED
@marcusquinn marcusquinn added the origin:interactive Auto-created from TODO.md tag label Apr 14, 2026
@marcusquinn
Copy link
Copy Markdown
Owner Author

Completion Summary

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • no-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a8063830-7b6c-404b-bbb5-5ca06c7f8205

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Enhanced the conflicting-PR auto-close heuristic to exclude planning-only paths (docs, config files) from overlap verification. Added file-overlap validation requiring matching commits to share non-planning files with the PR. When overlap fails, the PR remains open and a rebase nudge comment is posted instead of auto-closing.

Changes

Cohort / File(s) Summary
Core merge logic
.agents/scripts/pulse-merge.sh
Added _is_planning_path_for_overlap() to classify paths as planning-only (TODO.md, README.md, CHANGELOG.md, VERSION, todo/*, .agents/configs/simplification-state.json). Introduced _verify_pr_overlaps_commit() to fetch and compare file lists from PR and matching main-branch commit, returning success only on non-planning file intersection. Modified _close_conflicting_pr() to gate auto-close on overlap verification and post idempotent rebase nudge via _post_rebase_nudge_on_worker_conflicting() when task-ID match occurs but overlap fails.
Test coverage expansion
.agents/scripts/tests/test-close-conflicting-pr-wording.sh
Replaced simple commit-subject stub with comprehensive sandboxed harness (setup_sandbox/teardown_sandbox, write_stub_gh). Introduced load_functions_under_test() and set_responses() for response-file-based stubbing of gh api and gh pr view calls. Existing wording tests now validate formatting under new overlap-aware contract. Added GH#18815-specific test cases: planning-file-only commits prevent auto-close, implementation-file overlap enables auto-close, and lookup failures trigger fail-closed behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

Planning paths step back with grace, ✨
File overlaps now claim their place,
False positives fade away,
Rebase nudges save the day,
Zero debt, A-grade for play! 🚀

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/close-conflicting-pr-overlap-check

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@marcusquinn marcusquinn merged commit a394f73 into main Apr 14, 2026
32 of 36 checks passed
@marcusquinn marcusquinn deleted the bugfix/close-conflicting-pr-overlap-check branch April 14, 2026 03:04
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

SonarCloud: 0 bugs, 0 vulnerabilities, 231 code smells

Tue Apr 14 03:04:30 UTC 2026: Code review monitoring started
Tue Apr 14 03:04:31 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 231

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 231
  • VULNERABILITIES: 0

Generated on: Tue Apr 14 03:04:33 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link
Copy Markdown

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag origin:interactive Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: _close_conflicting_pr auto-closes implementation PRs when a planning PR with the same task ID has merged

1 participant