- Engineering
- 5 min read
AI code fixes via pull request, without merging anything

Code Automation + Security Testing + AI Gateway
On this page
AI pull request automation is often sold as "the agent fixes it and opens the PR". The hard part is not generating the diff: it is making sure the diff does only what was asked, leaves alone what it should not touch and passes the tests before anyone spends time reviewing it. This post describes how AIUBY's Code Automation handles that, with the values checked against the platform code on November 27, 2026.
#The risk of letting AI open pull requests
An agent with write access to the repository can, by mistake or through a malicious instruction hidden in a ticket, change the CI workflow (which runs with the repository's secrets), add a key to the code or touch files nobody asked for. The platform's answer is to treat each step as a gate: plan before code, diff checked against rules, tests in an isolated runner and a decision by a person. The platform never merges.
#The path, from ticket to pull request
Ticket
The request starts on screen or from another product: a security finding, a test accepted in Test Automation, a flag to remove or infrastructure-as-code drift.
Plan approved by a person
The AI suggests a plan with the files it intends to change, 12 at most. A person with approval permission checks the plan by the hash shown on screen: if the plan changed after it was displayed, the approval is not valid.
Patch checked
The generated diff goes through the rules in the next section. Anything that violates one of them is rejected before it runs.
Tests in the isolated runner
The patch is applied and the repository's own tests run in a Cloud Run job, never on the platform server, with an image pinned by digest and a dedicated service account. There are up to 300 seconds for setup and 420 for tests. For a private repository, the runner receives only a read token.
Proposal reviewed by another person
The final proposal, with the tested diff, must be accepted by someone other than the person who requested the run.
Draft pull request, or patch
With PR creation enabled and a write credential in the workspace, the platform always opens the PR as a draft, on a new branch
aiuby/code-automation/..., without force-pushing or touching an existing branch. Otherwise, the deliverable is a patch forgit apply.
#What the diff cannot touch
| Rule | Response |
|---|---|
| File outside the approved plan | outside_plan |
| More than 20 files in the patch | too_many_files |
| Patch larger than 24 KB | too_large |
| New line that looks like a secret (private key, token or literal password) | secret_in_patch |
| GitHub workflows and actions, .git, .env, credential files, keys, .aws and .ssh | always rejected; examples such as .env.example are allowed |
| Binary file, rename, permission change or submodule | rejected |
After the tests, the final diff also goes through fixed security rules that look for, for example, disabled TLS verification, dynamic code execution, shell commands built from text, concatenated SQL and permissive CORS.
#Four eyes and the proposal hash
The proposal has a SHA-256 hash computed over its canonical content. Before opening the PR, the platform checks three times that what goes to the repository is exactly what was decided: the decision hash matches the proposal's, the final diff matches the proposal's, and the hash of the final diff matches the recorded one. A proposal that changed after it was displayed must be reopened before a decision.
Note
#Fixing a security finding with a PR
In Security Testing, an open finding can become a fix request. There is no shortcut: it becomes a Code Automation ticket and follows the same path above. Not every finding can be solved with code, and the screen explains why.
| Finding | Becomes a PR? |
|---|---|
| Vulnerable dependency with a published fixed version | Yes, as a version upgrade |
| Static analysis or configuration, with file and line | Yes, as a code change |
| Exposed secret | No: the credential must be revoked and rotated; removing it from the code does not erase Git history |
| Dependency with no fixed version | No: replacing the package or mitigating is the team's decision |
| License | No: it is a legal decision |
Only workspace administrators can request the fix, and only connected GitHub repositories become PRs.
#Cost and caps
Every model call goes through the AI Gateway, so it counts toward the workspace budget and shows up in usage like any other (see AI cost management). On top of that, each ticket has its own AI budget: 2 dollars by default, with a fixed cap of 20 in the code. When it runs out, the ticket stops with budget_exhausted.
- Plan, patch and test iterations: 3 by default; the approver can allow more, up to 5 in total.
- Runs per day: 20 by default, capped at 100. Concurrent: 2 by default, capped at 5.
#Limits
- Pull requests only on GitHub. Jira issues do not become tickets.
- The PR is always a draft, and the platform never merges: the final decision belongs to whoever reviews it on GitHub.
- The patch is capped at 24 KB and 20 files: a large refactor does not fit this flow.
- Broken or flaky tests are not fixed automatically. What exists is selector repair in Test Automation.
- Creating a PR requires, among other permissions, three things enabled in the workspace: the product, PR creation and a write credential (the GitHub App or a fine-grained token stored encrypted).
- Large proposals appear truncated on screen: 40,000 characters in total and 4,000 per file.
The full reference is in Code Automation, in the documentation. For the E2E tests that feed this flow, see E2E testing with AI.


