Skip to content

bug: orchestrator dispatches quality gate before rebase — race condition #211

@microsasa

Description

@microsasa

Problem

The orchestrator dispatches the quality gate (step 4) BEFORE rebasing the PR (rebase step). Both happen in the same run. This creates a race condition:

Current sequence (single orchestrator run)

  1. Check CI ✅, check threads ✅, check Copilot review ✅
  2. Dispatch quality gate — quality gate agent starts (takes 2-4 minutes)
  3. Rebasegit push --force-with-lease completes in seconds

The race

The quality gate agent was dispatched at step 2 but takes minutes to clone, evaluate, and approve. Meanwhile the rebase at step 3 pushes a new commit in seconds.

  • If quality gate checks out AFTER rebase lands (common case): It evaluates the rebased code and approves the rebased commit. Works by coincidence.
  • If quality gate checks out BEFORE rebase lands (possible): It evaluates pre-rebase code, approves the old commit. Then rebase pushes → dismiss_stale_reviews dismisses the approval. PR stuck until next orchestrator cycle re-dispatches.

Observed on PR #200 (2026-03-21)

  • 14:49:00 — Quality gate dispatched
  • 14:49:03 — Rebase pushed
  • 14:53:33 — Quality gate approved (happened to evaluate rebased code)
  • 14:53:35 — Auto-merged

Worked by coincidence — quality gate was slow enough to see rebased code.

Fix

Move rebase BEFORE the quality gate dispatch. If a rebase is needed, do it and continue — let the next orchestrator cycle (triggered by CI/Copilot workflow_run completing) handle the quality gate dispatch after all checks pass on the rebased commit.

Correct sequence

  1. Orchestrator cycle 1: Rebase needed → rebase → continue
  2. CI runs on rebased commit, Copilot reviews rebased commit
  3. Orchestrator cycle 2 (triggered by CI/Copilot completing): CI ✅, threads ✅, Copilot review ✅ → dispatch quality gate
  4. Quality gate approves → auto-merge

No race — quality gate only runs after the final commit is settled.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions