Background
Based on the case study in #1214, we identified that cross-repository fork PRs can be unexpectedly closed by GitHub during push operations. This is a GitHub platform issue, but we can implement mitigations in hive-mind.
Related
Proposed Enhancements
1. PR State Validation After Push
Add validation after every push to detect unexpected PR closures:
async function validatePRState(owner, repo, prNumber) {
const state = await gh(`api repos/${owner}/${repo}/pulls/${prNumber} --jq .state`);
if (state !== 'open') {
throw new Error(`PR #${prNumber} is ${state}, expected 'open'`);
}
}
// After push
await sleep(5000); // Wait for GitHub to sync
await validatePRState(owner, repo, prNumber);
2. Auto-Reopen Mechanism
Implement automatic PR reopening when an unexpected close is detected:
async function ensurePROpen(owner, repo, prNumber) {
const pr = await getPRDetails(owner, repo, prNumber);
if (pr.state === 'closed' && !pr.merged) {
console.log(`PR #${prNumber} was unexpectedly closed, attempting to reopen...`);
await gh(`pr reopen ${prNumber} --repo ${owner}/${repo}`);
await notifyOwner(owner, repo, prNumber, 'PR was automatically reopened after unexpected closure');
}
}
3. Periodic State Monitoring
During long-running AI sessions, periodically check PR state (every 2-3 minutes):
const stateCheckInterval = setInterval(async () => {
await validatePRState(owner, repo, prNumber);
}, 120000); // Every 2 minutes
4. Cross-Repository Awareness
Add special handling for isCrossRepository: true PRs:
- Extra delay after push operations (5-10 seconds) for GitHub sync
- More frequent state validation
- Automatic reopen attempts with backoff
Acceptance Criteria
Priority
Medium - The issue is rare but disruptive when it occurs.
Generated from case study analysis
Background
Based on the case study in #1214, we identified that cross-repository fork PRs can be unexpectedly closed by GitHub during push operations. This is a GitHub platform issue, but we can implement mitigations in hive-mind.
Related
docs/case-studies/issue-1214/CASE-STUDY.mdProposed Enhancements
1. PR State Validation After Push
Add validation after every push to detect unexpected PR closures:
2. Auto-Reopen Mechanism
Implement automatic PR reopening when an unexpected close is detected:
3. Periodic State Monitoring
During long-running AI sessions, periodically check PR state (every 2-3 minutes):
4. Cross-Repository Awareness
Add special handling for
isCrossRepository: truePRs:Acceptance Criteria
Priority
Medium - The issue is rare but disruptive when it occurs.
Generated from case study analysis