Skip to content

fix(#409): fetch before force-with-lease retry in post-scripts - #414

Open
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/409-fetch-before-force-with-lease
Open

fix(#409): fetch before force-with-lease retry in post-scripts#414
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/409-fetch-before-force-with-lease

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

Adds git fetch origin "${BRANCH}" before the --force-with-lease retry in the push logic of both post-fix.src.sh and post-code.src.sh.

Without the fetch, the local remote-tracking ref is stale from clone time. When another process pushes to the branch during a long agent run, the subsequent --force-with-lease retry compares against this stale ref and rejects the push — even when the agent's changes don't conflict with the concurrent push. This wastes entire agent runs and can cause multi-hour delays before a manual retry succeeds.

Changed files:

  • scripts/post-fix.src.sh — Added git fetch before force-with-lease retry in section 4 (push branch). Updated inline comment to describe the new behavior.
  • scripts/post-code.src.sh — Added git fetch before force-with-lease retry in section 7b (push branch).
  • scripts/post-fix.sh, scripts/post-code.sh — Rebuilt bundled scripts via make script-build.
  • scripts/post-fix-test.sh, scripts/post-code-test.sh — Added grep-based test verifying the bundled script contains the git fetch call.

Testing

  • All tests in post-fix-test.sh pass (13/13), including the new bundled-script-fetches-before-force-with-lease test.
  • All tests in post-code-test.sh pass (66/66), including the new bundled-script-fetches-before-force-with-lease test.
  • make check-bundle confirms bundled scripts match source.
  • One pre-existing test failure in post-triage-test.sh (prerequisites-creates-allowed-issue) is unrelated — confirmed it fails identically on the base branch.

Closes #409

Post-script verification

  • Branch is not main/master (agent/409-fetch-before-force-with-lease)
  • Secret scan passed (gitleaks — e7a3660d8d2dffb418d747883540f78588c8c60f..HEAD)
  • PR body secret scan passed (gitleaks — no-git)
  • Pre-commit hooks passed (authoritative run on runner)
  • Tests ran inside sandbox

The push retry logic in post-fix.src.sh and post-code.src.sh used
--force-with-lease after a non-fast-forward rejection but did not
run git fetch first. Without a fetch, the local tracking ref is
stale from clone time, so the lease check rejects the push even
when the agent's changes don't conflict with a concurrent push.

Add git fetch origin "${BRANCH}" between the non-fast-forward
detection and the --force-with-lease retry in both scripts. This
ensures the tracking ref is current so force-with-lease accurately
distinguishes a safe rebase divergence from a genuinely conflicting
concurrent push.

Note: pre-commit could not run in sandbox (network blocked, exit 3).
The post-script runs an authoritative pre-commit on the runner.

Closes #409
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team as a code owner July 23, 2026 19:31
@rh-hemartin

Copy link
Copy Markdown
Member

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Jul 24, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 6:43 AM UTC · Completed 6:59 AM UTC
Commit: 68fc310 · View workflow run →

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Medium

  • [protected-path] scripts/ — All 6 changed files are under the protected scripts/ path: post-code-test.sh, post-code.sh, post-code.src.sh, post-fix-test.sh, post-fix.sh, post-fix.src.sh. The PR links to issue Post-fix/post-code push scripts should fetch before force-with-lease retry #409 and provides clear rationale for the change (fixing stale tracking refs causing --force-with-lease push failures). Human approval is always required for protected-path changes, regardless of context.

Labels: PR modifies both fix-agent and code-agent post-scripts and is a bug fix

@fullsend-ai-review fullsend-ai-review Bot added requires-manual-review Review requires human judgment fix-agent code-agent bug Something isn't working labels Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working code-agent fix-agent requires-manual-review Review requires human judgment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post-fix/post-code push scripts should fetch before force-with-lease retry

1 participant