Skip to content

Fix PR head checkout remote in fork continuation - #1857

Open
konard wants to merge 3 commits into
mainfrom
issue-1856-2780740e6f67
Open

Fix PR head checkout remote in fork continuation#1857
konard wants to merge 3 commits into
mainfrom
issue-1856-2780740e6f67

Conversation

@konard

@konard konard commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1856 by documenting what happened in ProverCoderAI/docker-git#381 and fixing the Hive Mind checkout bug exposed by that case.

  • Added a full case study under docs/case-studies/issue-1856, including raw PR metadata, comments, CI logs, session logs, extracted evidence, timeline, root causes, and UX follow-ups.
  • Fixed continue-mode branch checkout so upstream-owned PRs solved through a fork prefer upstream/<pr-branch> instead of a stale same-named fork branch.
  • Added a reproducing test for the stale fork branch topology and a changeset for the patch.

Findings From PR 381

  • The historical external CI failure was a Renovate artifact/lockfile problem: bun install --frozen-lockfile failed on missing @fedify/* 2.2.5 artifacts.
  • The first Hive Mind run stopped before solving because the solver fork default branch diverged and the force-with-lease opt-in was not enabled.
  • The second run used --allow-fork-divergence-resolution-using-force-push-with-lease; that successfully resolved the solver fork main divergence.
  • The remaining publication blocker was GitHub authorization: the authenticated account could not push to ProverCoderAI:renovate/all or mutate that PR.
  • The Hive Mind bug was separate: in fork mode, it could check out origin/renovate/all from the solver fork even when the PR head was upstream/renovate/all.

The full written analysis is in docs/case-studies/issue-1856/README.md. Opaque encrypted_content payloads from the second session log were redacted; operational commands, errors, comments, and timestamps were preserved.

Reproduction And Fix

The new test tests/test-issue-1856-pr-head-remote-preference.mjs creates an upstream repository and a fork that both contain renovate/all, with the fork branch intentionally stale. Before the fix, checkout could select the stale fork branch. With the fix, checkoutPrBranch() lands on the upstream PR head and logs the preferred PR-head remote.

Implementation touched:

  • src/solve.mjs: records PR head owner and chooses upstream as the preferred remote for upstream-owned PRs solved via a fork.
  • src/solve.branch.lib.mjs: threads the preferred PR remote into checkout.
  • src/solve.repository.lib.mjs: fetches/checks out the preferred remote first and uses it for PR-ref fallback.

Verification

  • node tests/test-issue-1856-pr-head-remote-preference.mjs
  • node tests/test-issue-1772-fork-custom-base-branch.mjs
  • node tests/test-issue-1772-proactive-base-sync.mjs
  • node tests/test-pre-pr-failure-notifier-1640.mjs
  • node tests/test-issue-1332-fork-name-from-pr-data.mjs
  • npm run format:check
  • npm run lint
  • git diff --check
  • npm test passed all 230 selected default test files

No UI changes; screenshots are not applicable.

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #1856
@konard konard self-assigned this Jun 7, 2026
@konard konard changed the title [WIP] Research what exactly happening in https://github.com/ProverCoderAI/docker-git/pull/381 Fix PR head checkout remote in fork continuation Jun 7, 2026
@konard
konard marked this pull request as ready for review June 7, 2026 22:57
@konard

konard commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

Implemented and pushed the fix to PR 1857: #1857

The root cause was that fork-continuation mode could correctly resolve the solver fork divergence, but then checkout the same-named PR branch from the solver fork remote instead of the upstream PR-head remote. The new code prefers the upstream remote when the PR head owner is the upstream repo, adds clearer debug logging, and keeps existing fallbacks intact. This is committed as fcfd33ad.

I also added the full case study and archived data under docs/case-studies/issue-1856, including the PR 381 timeline, downloaded logs, root cause analysis, and references. The reproducing test is tests/test-issue-1856-pr-head-remote-preference.mjs.

Verification passed:

References used in the case study: Git --force-with-lease docs, GitHub fork sync docs, GitHub fork PR permission docs, and Renovate artifactErrors docs.


This summary was automatically extracted from the AI working session output.

@konard

konard commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.5
  • Provider: OpenAI
  • Public pricing estimate: $22.536662

📊 Context and tokens usage:

  • 780.9K / 1.1M (74%) input tokens, 57.0K / 128K (45%) output tokens

Total: (780.9K + 12.2M cached) input tokens, 57.0K output tokens, $22.536662 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.5
  • Model: GPT-5.5 (gpt-5.5)

📎 Log file uploaded as Repository (49830KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

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.

Research what exactly happening in https://github.com/ProverCoderAI/docker-git/pull/381

1 participant