Skip to content

Fix Autoloop creating a new branch+PR per iteration instead of reusing one per program#60

Merged
mrjf merged 4 commits into
mainfrom
copilot/fix-autoloop-multiple-prs
Apr 7, 2026
Merged

Fix Autoloop creating a new branch+PR per iteration instead of reusing one per program#60
mrjf merged 4 commits into
mainfrom
copilot/fix-autoloop-multiple-prs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Autoloop was appending random hashes to branch names (e.g. autoloop/coverage-deadbeef1234) and creating a new draft PR each iteration, violating the one-branch-one-PR-per-program invariant.

Agent instruction fixes (autoloop.md)

  • Branch naming: Added explicit ⚠️ CRITICAL callout — branch must be EXACTLY autoloop/{program-name}, no suffixes/hashes/run-IDs. Includes concrete ❌ counter-examples and a git snippet for the check-out-or-create pattern.
  • PR lookup before creation: Step 1 now explicitly reads the PR field from the state file's Machine State table. Step 5 now has a 4-step lookup procedure:
    1. Check PR field in state file
    2. If missing, query GitHub API for open PRs with head=autoloop/{program-name}
    3. If found → push-to-pull-request-branch (never create-pull-request)
    4. If not found → create-pull-request with the explicit branch name
  • Common Mistakes to Avoid: New section with ❌/✅ rules covering branch naming, duplicate PRs, and auto-generated branch names.

Safety constraint changes

Reduced max for both create-pull-request and push-to-pull-request-branch from 21 in both autoloop.md frontmatter and the compiled autoloop.lock.yml, preventing the framework from allowing more than one PR creation per run as a hard backstop.

Copilot AI changed the title [WIP] Fix autoloop creating multiple PRs instead of one Fix Autoloop creating a new branch+PR per iteration instead of reusing one per program Apr 7, 2026
Copilot AI requested a review from mrjf April 7, 2026 13:47
Copilot finished work on behalf of mrjf April 7, 2026 13:47
@mrjf mrjf marked this pull request as ready for review April 7, 2026 14:05
@mrjf
Copy link
Copy Markdown
Contributor

mrjf commented Apr 7, 2026

@copilot fix CI

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 7, 2026

@copilot fix CI

Fixed in 4103970. Two TypeScript errors in tests/stats/nlargest.test.ts and tests/stats/rank.test.ts were causing the CI failure — both helper functions passed undefined for optional name/index properties, which is invalid with exactOptionalPropertyTypes: true. Changed to use conditional spread (...(x !== undefined ? { x } : {})) to omit the property entirely when undefined.

Copilot finished work on behalf of mrjf April 7, 2026 17:14
@mrjf
Copy link
Copy Markdown
Contributor

mrjf commented Apr 7, 2026

@copilot resolve conflicts

…multiple-prs

# Conflicts:
#	tests/stats/nlargest.test.ts
#	tests/stats/rank.test.ts

Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 7, 2026

@copilot resolve conflicts

Resolved in ce97623. Merged origin/main into the branch — the only conflicts were in tests/stats/nlargest.test.ts and tests/stats/rank.test.ts, where I kept the exactOptionalPropertyTypes fixes. Typecheck passes cleanly.

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.

Autoloop creating multiple PRs, instead of using one long-running branch and updating a single PR per program

2 participants