Skip to content

fix: guard workers against a stray origin/main branch - #5175

Merged
dezren39 merged 4 commits into
mainfrom
queue/8595-4862-origin-main-guard
Nov 3, 2026
Merged

dezren39 merged 4 commits into
mainfrom
queue/8595-4862-origin-main-guard

Conversation

@dezren39

@dezren39 dezren39 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #4862

Summary

  • Add scripts/worker-preflight.sh to stop a worker if the exact local branch refs/heads/origin/main exists, with an explicit shadow warning and fail-closed handling for inspection errors.
  • Require the preflight at the start of each task in AGENTS.md.
  • Add synthetic-ref/clean-repo contract coverage and configure scripts-test to run it on PRs touching the guard.

Cause hunt

The creator remains unidentified and unreproducible. The laptop primary has no surviving refs/heads/origin/main or branch reflog; its HEAD reflog shows checkouts to origin/main/remotes/origin/main, which cannot distinguish detached checkout from switching to a local branch. The audited automation did not create this branch: repo-keeper and pm-git-sync consume the ambiguous origin/main name, worktree-reaper only fetches/removes refs, and queue tooling does not perform Git operations. The only exact local-ref creation found is the new test fixture, isolated to a temporary repository. An interactive or agent-issued Git command is possible but not evidenced.

Verification

  • TMPDIR=/home/user/.local/share/opencode/tmp/opencode python3 -m unittest discover -s scripts/tests -p 'test_worker_preflight.py' -v — passed (synthetic ref is rejected with exit 1; clean repo passes).
  • Ran the guard from the clean laptop primary /home/user/git/code — passed.

CI note

No Actions checks ran for this PR. The default-branch nix-ci.yml and scripts-test.yml definitions are push-to-main only; the newly added PR trigger in this branch cannot trigger itself. The local contract test above passed. The policy-listed basic: proxy port fallbacks check was also absent, so this PR has no CI result to report.

@dezren39
dezren39 requested a review from a team as a code owner November 3, 2026 21:55
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a9443bc9-5193-4f33-aa53-b6b5cafd851f
Commits

Reviewing files that changed from the base of the PR and between e41dabd and 65954ea.

Files selected for processing: 4
  • .github/workflows/scripts-test.yml
  • AGENTS.md
  • scripts/tests/test_worker_preflight.py
  • scripts/worker-preflight.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T21:57:07.683952Z 65954ea PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit dd08cde into main Nov 3, 2026
1 check passed
@dezren39
dezren39 deleted the queue/8595-4862-origin-main-guard branch November 3, 2026 21:58
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.

laptop clone: a stray local branch named 'origin/main' shadows the remote-tracking ref (silent stale main for every worker)

1 participant