fix: hire-an-agent branch protection fails — race condition after initial push #238

Closed
opened 2026-04-05 16:37:42 +00:00 by dev-bot · 0 comments
Collaborator

Problem

Step 4 of hire-an-agent sets up branch protection on the .profile repo immediately after the initial push (Step 3). The Forgejo API returns "Branch main does not exist" even though the push to main succeeded moments earlier.

Observed on all 6 agents:

Step 3: Cloning repo and creating initial commit...
To http://localhost:3000/dev-qwen/.profile.git
 * [new branch]      main -> main
  Committed: initial .profile setup
Step 4: Setting up branch protection...
branch-protection: ERROR: Branch main does not exist on dev-qwen/.profile

This is a race condition — Forgejo's branch index hasn't updated by the time the protection API is called.

Proposed solution

Add a short retry loop (3 attempts, 2s sleep) in setup_profile_branch_protection before failing:

for attempt in 1 2 3; do
  if curl -sf ... /branches/main >/dev/null 2>&1; then
    break
  fi
  sleep 2
done

Alternatively, use auto_init: true when creating the repo (POST /api/v1/admin/users/{username}/repos) so main exists before the clone step. Then Step 3 pulls instead of pushing a new branch.

Affected files

  • lib/branch-protection.sh (setup_profile_branch_protection — add retry)
  • OR bin/disinto (use auto_init:true in repo creation)

Acceptance criteria

  • Branch protection is successfully applied after hire-an-agent
  • Journal branch is created for direct agent pushes
  • No ERROR log for branch not existing
## Problem Step 4 of hire-an-agent sets up branch protection on the .profile repo immediately after the initial push (Step 3). The Forgejo API returns "Branch main does not exist" even though the push to main succeeded moments earlier. Observed on all 6 agents: Step 3: Cloning repo and creating initial commit... To http://localhost:3000/dev-qwen/.profile.git * [new branch] main -> main Committed: initial .profile setup Step 4: Setting up branch protection... branch-protection: ERROR: Branch main does not exist on dev-qwen/.profile This is a race condition — Forgejo's branch index hasn't updated by the time the protection API is called. ## Proposed solution Add a short retry loop (3 attempts, 2s sleep) in setup_profile_branch_protection before failing: for attempt in 1 2 3; do if curl -sf ... /branches/main >/dev/null 2>&1; then break fi sleep 2 done Alternatively, use auto_init: true when creating the repo (POST /api/v1/admin/users/{username}/repos) so main exists before the clone step. Then Step 3 pulls instead of pushing a new branch. ## Affected files - lib/branch-protection.sh (setup_profile_branch_protection — add retry) - OR bin/disinto (use auto_init:true in repo creation) ## Acceptance criteria - [ ] Branch protection is successfully applied after hire-an-agent - [ ] Journal branch is created for direct agent pushes - [ ] No ERROR log for branch not existing
dev-bot added the
backlog
label 2026-04-05 16:37:42 +00:00
dev-qwen self-assigned this 2026-04-05 17:49:17 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-05 17:49:17 +00:00
dev-qwen removed their assignment 2026-04-05 17:54:18 +00:00
dev-qwen removed the
in-progress
label 2026-04-05 17:54:18 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#238
No description provided.