Skip to content
Source
Sign inSign up

The pull request steps

Software factory / Pull requests

The pull request steps

The Factory panel on a pull request says "Needs a maintainer", or a run says "Could not fix". You want to know what each step does, in which order, and what each verdict means.

18 min read

The factory runs the steps below on each pull request that people can see. Each step belongs to one agent, and runs only while its agent and the step are on: see Turn on the agents.

  • The steps run again after each push by a person.
  • The factory's own pushes get their own audit and review.
  • To start a step now, without a push, see Start an agent run.

Read the Factory panel

The Factory panel is on the Agents tab of the right column of the Conversation tab. It has one row for each step of an agent that is on, with the latest run of that step:

  • The questions come first: Safe, Useful, Fixes the issue and Conflicts.
  • Then the other steps, each with the name of its agent, for example PR review: Fixer or PR summary: PR impact.
  • The steps that fix failing CI and resolve conflicts in the merge queue get a row only after they ran on the pull request.
  • A custom agent gets a row only after it ran on the pull request.

A row says Not run yet when its step has no run on the pull request. The steps of an agent that is off get no row.

  1. Click a row to read the reason behind its answer.
  2. If you have write access, click Log under the reason. The run page shows the agent, the head commit, the tokens, the verdict and the log of the run.
  3. If the run did not succeed, read the reason and the next step under the row. Then click Retry under the row. See Retry a run.

The rows of Fix failing CI, of Resolve conflicts in the merge queue and of a custom agent have no Retry button. A row that says Waits or Will not run has a notice at the top of the panel that says why. See Why an agent waits or will not run.

The page of an Audit run on pull request #2: the status Clean, the tokens, the head commit and the verdict.

Under the rows:

  • All runs, for people with write access. It opens the runs page with only the runs of this pull request. See Find a run.
  • 3 agents are off, for example. It is closed at first. Open it to see the names of the agents that are off. Admins also see Turn on in settings, which opens the factory settings.
The Factory panel of a pull request, with a row for each step, All runs, and the agents that are off.

An issue has the same panel, with the rows Triage, Investigation, Fix PR, Assign and Spam.

The order

StepAgentWhen it runs
1. Security auditSecurity auditFirst. Every other step waits for its verdict.
2. Check scope and duplicatesPR reviewAfter a clean audit.
3. Verify the linked issuePR reviewAfter a clean audit.
4. ReviewPR reviewAfter a clean audit.
5. Push fixesPR reviewWhen the review has findings.
6. Resolve merge conflictsKeep greenWhen the pull request conflicts with its base.
Ready to mergeNoneLast: a comment, and a merge when you turned on auto-merge.

These steps do not follow this order:

  • Fix failing CI (Keep green) starts when a CI run on the pull request fails. It also starts when a check on GitHub fails on a pull request that you opened here. See 7. Fix failing CI.
  • Resolve conflicts in the merge queue (Keep green) starts only from the merge queue, when the pull request at its front conflicts with the base branch. See Resolve conflicts with an agent.
  • The steps of PR summary do not wait for this order, and nothing waits for them.

The steps of PR summary:

One agent changes the branch at a time

Push fixes, Resolve merge conflicts, Resolve conflicts in the merge queue and Fix failing CI all push to the head branch. Only one of them works on a pull request at a time, so they never do the same work twice or push over each other.

  • When one of them runs, the others wait. A step that waits starts when the run ends, if it still has work on the head.
  • When CI fails while another of these steps runs, Fix failing CI keeps the failure, and starts after that run ends.
  • When the merge queue finds a conflict while Resolve merge conflicts runs, the queue waits for that run and does not start a second one.
  • On a pull request from GitHub, the fix goes to GitHub. See Fixes on a pull request from GitHub. Resolve conflicts in the merge queue does not run there, because such a pull request merges on GitHub.
  • When you push a new commit, a run of these steps on an older commit stops. Its fix was for code that is gone.

Warning

If the audit is off, the other steps start without it. Then the factory posts no "ready to merge" comment and never merges.

Fixes on a pull request from GitHub

On a synced repository, a pull request from GitHub has its head on GitHub, often on the contributor's fork. Its head here is GitHub's refs/pull/<n>/head. A fix of Push fixes, Resolve merge conflicts or Fix failing CI goes to the head branch on GitHub, with the GitHub token of one maintainer:

  1. When you start the step yourself (Run on the Factory panel, src factory start, REST or MCP), or you retry its run, your token pushes the fix.
  2. When the step starts by itself, the token of the maintainer who approved the newest CI run of the pull request pushes the fix.

GitHub takes the push first. The head moves here only after that. The CI of the new head starts at once, approved for that maintainer, with no secrets.

The step does not start, and its run shows why, when:

  • No maintainer started it and no maintainer approved the pull request's CI.
  • The maintainer has no write access here, or has not connected GitHub (Settings, Connected accounts).

The fix is not pushed, and the run says why, when:

  • The author does not allow edits from maintainers on GitHub.
  • The fork is gone, or the pull request is closed on GitHub.
  • The head branch on GitHub moved after the agent read it.
  • The head branch is a release branch of the synced repository.

1. Security audit

The audit only reads. It looks for malware, install and build-script tricks, changes to CI and to .source/, secret theft, prompt injection aimed at agents, and hidden code.

How the audit decides

Most pull requests are harmless. A fast first check reads each one, and the audit agent runs only when the first check finds a risk. The first check can give only clean. Only the audit agent gives suspicious or malicious.

  1. Code reads the changed paths and the diff. If it finds a risk from the lists below, the audit agent runs at once.
  2. Otherwise, Cloudflare's decision model Clef reads the full diff. It gives each of five risks a score from 0 to 1.
  3. If every score is under 0.2, the audit records clean and ends. No agent runs.
  4. If one score is 0.2 or more, the audit agent runs. Its task names each flagged risk, and the agent checks the whole change.
  5. If Clef is down or does not answer in time, the audit agent runs.

The audit agent always runs when the pull request changes one of these files:

  • A file under .source/ or .github/workflows/.
  • A package.json or a lockfile, in any folder.
  • An AGENTS.md or a CLAUDE.md, in any folder.
  • A file in an agent skill folder, such as .agents/skills or .claude/skills, in any folder.

A renamed or deleted file counts by its old path too. The audit agent also always runs when:

  • An added line can hide code: invisible or bidi characters, or code after a long run of spaces.
  • The diff is longer than 100,000 characters, is empty, or has a changed file with no patch (a binary file, or a change too large to diff).

Clef scores these five risks:

  • Malware or an obfuscated payload.
  • An install or build trick.
  • Secret theft.
  • Prompt injection aimed at AI agents.
  • Another attack on the project, its users or its agents.

The first check runs for every audit, whatever model the audit uses. It has no setting. Its Clef call runs on the forge's Workers AI, and does not count toward the monthly spend cap. An audit that the first check ended has no log. Its verdict lists each score. See An audit with no log.

VerdictThe panel showsWhat happens next
cleanSafe: CleanThe other steps start.
suspiciousSafe: Needs a maintainerThe factory stops, and adds the label factory:needs-maintainer.
maliciousSafe: MaliciousThe factory stops, adds the label factory:malicious, and starts the spam agent when it is on.

For suspicious and malicious, the audit posts one short comment for the maintainers: what it found, and where. An audit that fails gives no verdict, so the factory stops too.

When the factory stops, the panel says "The factory stopped. A maintainer needs to look at this pull request." Read the change yourself. The next push by a person starts a new audit.

2. Check scope and duplicates

This step of PR review reads the change, the docs of the project, and the titles of its issues and pull requests.

VerdictThe panel showsMeaning
usefulUseful: UsefulThe project wants it, and no open pull request does the same.
unclearUseful: UnclearThe agent cannot tell what it is for, or if the project wants it.
duplicateUseful: DuplicateAn open pull request does the same. The verdict links it.
out-of-scopeUseful: Out of scopeThe project does not do this.

When the verdict is not useful, or the agent found related items, it posts one short comment with the links.

3. Verify the linked issue

This step of PR review runs only when the title or the body of the pull request links an issue of the same repository with a closing word: fixes #12, closes #12 or resolves #12.

The agent runs a repro on the base, then on the head. It uses the repro that the investigate agent saved for the issue. If there is none, it writes one from the text of the issue.

VerdictThe panel showsMeaning
fixesFixes the issue: Fixes #12The repro fails on the base and passes on the head.
does-not-fixFixes the issue: Does not fixThe repro fails on the base and on the head.
could-not-reproduceFixes the issue: Could not reproduceThe repro does not fail on the base, or it does not run.
no-linked-issueFixes the issue: No linked issueThe agent found no issue that it can read.

4. Review

The main step of PR review posts one review with a note on each line that has a real finding: a bug, a security problem, or a missing test. It never approves and never asks for changes. A person does that.

VerdictMeaning
findingsThe agent posted a review with findings.
no-findingsThe agent found no real problem. It posts no review.

While the step Push fixes is off, you read the review and decide what to change. While it is on, the review writes its findings as a numbered list, and the next step fixes them for you.

When the fix of a finding is a few lines in one place, its note holds a suggestion: the new text of those lines. The agent never commits its own suggestions. A person with write access to the head branch commits them:

  1. Under a suggestion, click Commit suggestion. Or click Add to batch under each one that you want, then Commit suggestions in the bar at the bottom of the page.
  2. Click Commit changes.

The commit goes on the head branch, and CI runs on it. See Suggest a change in a review.

5. Push fixes

This step of PR review runs after a review with findings, while Push fixes is on. It fixes the findings of the review, runs the tests near its change, and pushes one commit to the head branch. Then it resolves the line threads of the review that its commit fixes, and posts a comment that says what it changed.

It resolves only threads that the bot started, and only after its commit is on the head branch. The threads it did not fix stay open. On a pull request that syncs with GitHub, GitHub does not let the bot resolve a thread, so the threads stay open.

It does not fix failing checks: that is the job of Fix failing CI.

VerdictMeaning
fixedIt pushed a commit.
nothing-to-fixThere were no findings.
could-not-fixThe tests still fail, or the head moved. It pushes nothing.

Its commit gets a new audit and a new review. It runs at most 3 times for one push by a person. Change this number with Review rounds in the rules for all agents.

6. Resolve merge conflicts

When the pull request conflicts with its base, this step of Keep green merges the base into the head. It makes a merge commit and never force-pushes. It also runs when the base branch moves and the pull request conflicts after that.

The merge commit still goes in when the base branch moves on while the fixer works. The commit merges the base commit that the fixer started from. If the newer base commits conflict again, the fixer runs again.

VerdictThe panel showsMeaning
resolvedConflicts: ResolvedIt pushed a merge commit.
no-conflictsConflicts: No conflictsThe merge had no conflicts.
could-not-resolveConflicts: Could not resolveIt cannot keep the changes of both sides, the tests fail, or a branch moved. It pushes nothing.

7. Fix failing CI

A CI run on the pull request failed, and you want the cause fixed without reading the log yourself.

Turn on Keep green and its step Fix failing CI. When a CI run on the pull request fails, the step does this work:

  1. It reads the logs and the findings of the failed jobs.
  2. It reproduces the failure in its sandbox. The sandbox reaches the egress hosts of the CI jobs on the default branch, so the install step works as in CI.
  3. It fixes the root cause. It never makes a test pass by weakening the test or deleting it.
  4. It runs the failing commands again.
  5. It pushes one fix to the head branch, and posts a comment that says what it changed.
VerdictMeaning
fixedIt pushed a fix to the head.
could-not-fixIt did not find the cause, or the failing commands still fail. It pushes nothing.
not-a-code-problemThe cause of the failure is not in the code. It pushes nothing.
nothing-to-fixIt found no failure to fix.

Its fix gets a new audit and a new review, as a commit of Push fixes does. For each push by a person, it runs at most Review rounds times (3 by default, in the rules for all agents). It works only on a failed run of the current head of the pull request.

  • It never reads a hidden workflow, and never runs for one. The logs of a hidden workflow are for admins only.
  • It works on pull requests only. A failed run on the default branch gets no fix from it.

Failed checks on GitHub

Your repository has GitHub sync, and a pull request that you opened here also opened on GitHub. A check fails on GitHub, and you want the cause fixed without leaving TanStack Source.

When a check on GitHub fails on the head commit, Fix failing CI does this work:

  1. It reads what failed on GitHub. For a GitHub Actions job, it reads the failed step and the end of its log. For a check of another app, it reads the title, the summary and the text of the check.
  2. It reproduces the failure in its sandbox. The commands of a GitHub Actions job are in its workflow file in .github/workflows.
  3. It fixes the root cause, and runs the failing commands again.
  4. It pushes one fix to the head branch here. Sync sends the fix to GitHub, and GitHub runs its checks again.

It reads GitHub with the token of the sync owner. The token never reaches the agent.

The same rules apply as for a failed CI run here. It has the same verdicts, and only works on the current head. The Review rounds of one push count the failures on GitHub and here together.

It records nothing-to-fix in these cases:

  • The head moved after the checks ran.
  • The sync owner has no working GitHub token, or is no longer an admin.
  • Nothing failed any more when it read the checks.

On a pull request from GitHub, a fix of a failed CI run here goes to GitHub. See Fixes on a pull request from GitHub.

Pull requests from people without write access

The audit comes first for these pull requests:

  • Push fixes, Resolve merge conflicts, Resolve conflicts in the merge queue and Fix failing CI start only after a clean audit of the head.
  • The CI run of their push waits until the audit of the new head is clean. Then the bot approves it. See Runs after a push by a factory agent.
  • When CI fails before the audit ends, Fix failing CI waits. It starts when the audit of that head is clean.
  • After Update branch, the merge queue or a push of an agent, the new head gets its own audit. Fix failing CI starts after that audit is clean.

Two more limits hold:

  • In a fork, the four steps above push to the head branch only when the author allows edits from maintainers, and the branch is not protected.
  • The author starts at most 20 agent runs on the repository each UTC day. A run past the limit shows as Daily limit reached, with the reason.

Ready to merge

When every step passed on the head, the bot posts one comment: "Ready to merge: every factory step passed on" and the short commit id. Every step passed when no run is waiting or running, and all of these are true:

  • The audit of this head is clean.
  • Check scope and duplicates is not duplicate or out-of-scope.
  • Verify the linked issue, when it runs, is not does-not-fix.
  • The review of this head is no-findings.
  • The pull request has no conflicts, and the branch rules allow the merge.

Auto-merge is off by default. When an admin turns it on, the bot also merges the pull request with a merge commit.

  • It merges only after a clean audit of that exact head commit.
  • The merge goes through the same gate as the merge button: the branch rules, the required checks and the up-to-date rule.
  • A push after the audit stops the merge until a new audit is clean.
  • Update branch, the merge queue and a push of an agent also move the head. The new head gets its own audit, then a review, and then the bot can merge it.

Where the factory does not run

  • On a pull request that screening holds, or that is closed.
  • On a pull request whose author is banned. Only the Spam agent runs there.

Done

You can read each step in the Factory panel, run a failed agent again, and you know which verdicts stop the pipeline. To change the steps and the triggers, see Factory settings.