Skip to content

Re-Read a Deleted Ref Before Reporting DELETE_NOT_CONFIRMED - #3480

Merged
ptr727 merged 3 commits into
developfrom
fix/cleanup-reread-deleted-ref
Oct 25, 2026
Merged

ptr727 merged 3 commits into
developfrom
fix/cleanup-reread-deleted-ref

Conversation

@ptr727

@ptr727 ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Summary

Answers #3436. cleanup_remote_delete read the ref back once, right after deleteRef. GitHub's ref read can lag a delete that landed, so a landed delete could print status=DELETE_NOT_CONFIRMED and exit 2 before the local half ran.

  • A ref still at the deleted tip is now read again on DELETE_SETTLE_DELAYS = (1, 2, 4) through the existing core.backoff helper, so about seven seconds at most, before it is reported. Exit 2 still follows once that schedule is spent.
  • A read back at a tip other than the deleted one stops the loop and gets its own message ("a tip other than the one deleted, so something pushed to the branch"), since re-reading it settles nothing.
  • scripts/README.md's cleanup paragraph says so.
  • Tests: a read lagging then gone settles to DELETED and exit 0. A ref present on every read exits 2 after exactly the scheduled reads. A settle read that does not answer exits 2. A new tip stops the loop and names that tip. The first two fail against the unfixed source. The existing suite patches the schedule to (), which reproduces the old single read.

Known limits, not defects

  • A branch pushed back at the deleted tip inside the settle window cannot be told from lag. It ends still reads at <tip> after the delete, exit 2, which is the conservative outcome.
  • scripts/handoff.py reads state back once after a write in create_label, close, and edit_issue. No lag has been seen on label or issue reads, so these are the sites to name in one issue only if it is.

Verification

  • Full suite: uv run --no-project --with-requirements tests/requirements.txt python -m unittest discover -s tests, 2952 tests run, OK (7 skipped), at 278e49a. The commit after it changes message wording and a test name, and test_pr_*.py (628 tests) passes on it.
  • Local strict review: three passes. Round 1 raised three introduced findings (a README sentence over the length limit, no test for a settle read that does not answer, and the loop re-reading a ref at a new tip), all fixed in 278e49a. Round 2 raised three (an overclaiming message, a stale docstring, a long line), fixed in 2c71411. The third pass raised none.

Pre-existing findings, not filed

  • scripts/README.md:264, pre-existing: five sentences this change did not edit run over the 25-word sentence-length check.

🤖 Generated with Claude Code

ptr727 and others added 3 commits October 25, 2026 12:30
The ref read can lag a delete that landed, so cleanup reads a ref
still present again on a short schedule through the existing backoff
helper before reporting it. Exit 2 still follows once the schedule is
spent.

Closes #3436

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ref back at a new tip means the branch was pushed again, so the loop
stops there and says so rather than reporting the delete as unlanded.
A test now drives a settle read that does not answer, and the README
sentence is split under the length limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A delete that reported a failure can also read back at another tip, so
the message says only that something pushed to the branch. The
docstring now names the deleted tip as what is re-read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 25, 2026 19:40
@ptr727

ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 2c71411c1f2760a4064deddcdb56bc88a2594a07, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The reviewed changes have no unresolved blocking issues and include focused test coverage and documentation.

No open issues 🎉

What changed in this PR

This pull request improves remote branch deletion confirmation by retrying ref reads when GitHub’s response may lag after a successful deletion.

Changes:

  • Adds bounded confirmation retries using the existing backoff helper.
  • Distinguishes deleted refs, unreadable reads, and refs moved to a new tip.
  • Adds focused tests and documents the retry behavior.
File Description
tests/​test_pr_cleanup.py Tests delayed deletion visibility, exhausted retries, unreadable reads, and changed tips.
scripts/​README.md Documents eventual-consistency handling during remote deletion.
scripts/​pr_cleanup.py Implements bounded ref-confirmation retries and new-tip reporting.

Review effort: Lite

@codecov

codecov Bot commented Oct 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@5f5ea25). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #3480   +/-   ##
==========================================
  Coverage           ?   81.00%           
==========================================
  Files              ?       25           
  Lines              ?     8902           
  Branches           ?        0           
==========================================
  Hits               ?     7211           
  Misses             ?     1691           
  Partials           ?        0           
Flag Coverage Δ
python-3.13 81.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727
ptr727 merged commit c0ff838 into develop Oct 25, 2026
14 checks passed
@ptr727
ptr727 deleted the fix/cleanup-reread-deleted-ref branch October 25, 2026 19:52
ptr727 added a commit that referenced this pull request Oct 25, 2026
## Summary

Promotes the pull requests merged into develop since release 2.0.1181.

- [#3479](#3479):
`status=COVERAGE_IS_PARTIAL` no longer says the head's own review read
fewer files on the carry paths. It leads with the carried reason there
and names the remedy that clears it.
- [#3480](#3480):
`cleanup` re-reads a ref still at the deleted tip for a few seconds
before it reports `DELETE_NOT_CONFIRMED`, since the ref read can lag a
delete that landed.
- [#3481](#3481):
`pr_review.py cleanup` loads one copy of the gate rather than a second
one under the name `pr_review`.

Closes #3424
Closes #3436
Closes #3461

## Constituent coverage

Each change this promotion carries had coverage on its own pull request
into develop, at its merged head:

| Pull request | Merged head | Coverage |
| --- | --- | --- |
| [#3479](#3479) |
`81ca8d88` | attested local pass at the merged head, base `develop`, and
a Copilot table on the merged head naming exactly its 3 changed files,
no open findings |
| [#3480](#3480) |
`2c71411c` | attested local pass at the merged head, base `develop`, and
a Copilot table on the merged head naming exactly its 3 changed files,
no open findings |
| [#3481](#3481) |
`1747bd78` | attested local pass at the merged head, base `develop`, and
a Copilot table on the merged head naming exactly its 2 changed files,
no open findings |

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants