Skip to content
Scalpels home

Sign up now for $10 in credit on a new Laravel Cloud account.

Guide

Continuously improve your software with Scalpels and Solo

Remediation

· Ed Grosvenor

Everything up to now has been reading. Remediation is the first step that changes anything, and it is the one with no right answer for everyone. You decide how far an investigation goes, project by project. We decide it for each of ours based on several things, including client preferences and our own risk tolerance on that project.

Where an investigation can stop

Investigate only. The investigator finds the cause, writes a failing test that shows it, and proposes a fix in a comment on the issue. A person decides whether to make the change. Nothing leaves the investigator's worktree.

Draft pull request. The investigator makes the fix on its branch, gets the failing test passing, runs the project's full checks, and opens a draft pull request linked to the issue. A person marks it ready, reviews it, and merges it.

Pull request. The same, but the pull request is opened ready for review, so it goes straight into whatever review the project already has: a person, a review agent, or both.

Merge. The investigator merges its own pull request once the project's checks pass, and your normal deploy takes it from there.

None of these is the responsible choice and the others reckless. They are different amounts of trust, and the right amount depends on the project.

What decides it

Is a person still reading all of the code? If someone on the team reads every change that ships, a pull request costs them very little and catches the fix that is technically right and wrong for the codebase. If nobody reads every line any more, and on a lot of agent-built projects nobody does, be honest about that. A queue of pull requests nobody opens is worse than either end of the scale, because it looks like progress. Either let the comments pile up on the issues where you will at least read them, or let the checks decide and merge.

What happens if the fix is wrong? A marketing site that shows a stale price for an hour is not a billing system that charges someone twice. Think about the worst plausible bad fix. Does it lose data, leak data, take money, or lock people out?

How much would the checks catch? A pull request is exactly as informative as the gate it ran through, and a merge on green is exactly as safe. A project with a thorough test suite, static analysis, and a required review agent tells you something real with a green build. One with a few smoke tests tells you to read the whole diff yourself.

How easy is it to undo? A change you can roll back with one revert and one deploy is a different risk from a migration that rewrites a table. A common shape is to let the loop go further on code changes and tell it to stop and comment for anything that touches the schema, the infrastructure, or a dependency.

Who is affected? A change that breaks an internal tool is very different to a change that breaks a big customer-facing app with lots of paying users.

You can mix levels inside one project. A rule like "Merge performance fixes that only add an eager load or an index once CI is green, open a draft pull request for anything else, and never touch app/Billing" is perfectly good.

Write it down where agents look

Rules only work if every investigator reads the same ones. Put them in a file at the root of each repository, which the investigator brief on the previous page points to:

# REMEDIATION.md

Level: draft-pr

- Always start with a failing test that reproduces the problem.
- Run `composer ready` before opening the pull request. Do not open it
  if anything fails.
- Open the pull request as a draft, assigned to @your-github-handle.
- Performance fixes that only add an eager load or an index may be
  marked ready and merged once CI is green.
- Never change files under app/Billing, database/migrations or
  config/, and never add or upgrade a dependency. Stop and comment on
  the issue instead.
- Link the pull request to the issue with "Fixes #N".

The investigator does what this file says and goes no further. Every repository the loop can reach needs one before you turn the cron job on, even if all it says is "investigate only". An investigator that gets to step 4 of its brief and finds no REMEDIATION.md stops there and writes up what it found. That is correct behaviour, but it wastes an investigation you could have had.

Because the file lives in the repository, it changes through review like anything else, and the history shows when you decided to trust the loop with more.

What holds at every level

Whatever level you choose, a few things do not change:

  • The loop only reads Hone and Wake. No level of remediation needs the agent to change them, and the orders keep it on app_read. If the loop has a machine of its own, a token with only Read installed apps makes that a hard limit. See what you need.
  • Fixes go through the repository. No investigator deploys directly. Whether it stops at a comment or merges, the change goes through your normal branch, checks, and deploy. If a change cannot, it is not a change the loop should make.
  • People can always see what happened. Every finding has an issue, every investigation has a todo, and every fix has a pull request, merged or not. If the loop ever does something you cannot trace back through those three, turn off the cron job and find out why.

That last rule is the one that makes the rest safe to try. The loop is not asking you to trust an agent's judgment blindly. It is asking you to let it work in the open, and to give it more room only once you have watched it work.

Need help setting up automation to keep your Laravel app healthy?

These agencies and freelancers are standing by and ready to help.

  • Scott Keck-Warren

    Michigan

    PHP and Laravel developer with 13 years of experience building and maintaining production apps. US Eastern, English.

    Freelancer Ask for help
    Ask Scott Keck-Warren for help
  • Artisan Build

    USA

    We run Scalpels, as well as a suite of other tools for developers and development teams.

    Agency Ask for help
    Ask Artisan Build for help