đź§  Building the Patch Engine Loop
1 min read

đź§  Building the Patch Engine Loop

Today was one of those long hauls where you look up and the sun’s down and your brain’s still trying to untangle the same loop it woke up thinking about. Most of the day was spent inside the patch engine: specifically trying to get a working prototype that could support a full feature flow, layer by layer, with controlled, verifiable file mutations. I think I finally have something close.

The core shift is this: instead of the LLM emitting raw diffs or unstructured edits, it now emits a structured sequence of commands, things like create_file, modify_file, delete_file, rename_file. These commands mutate an in-memory representation of the file system, not the disk directly.

That indirection means we can intercept and validate the changes (even say “no”) before they touch real files. If the command is valid, we acknowledge it, and the LLM continues chaining changes to fulfill the current layer’s requirements. Once the LLM signals completion, it sends back a full change set in a final “apply” command, and only then do we commit to disk.

That split (speculative edits in memory, final commit as a unified payload) gives us two big wins:

  1. Better feedback: We can immediately flag broken commands or constraint violations without guesswork.
  2. LLM accountability: The model is still responsible for producing a coherent, complete change set. We're not patching behind it — we’re validating and applying what it owns.

The prototype worked for a test feature with five layers. That’s not nothing.

But…there’s a catch.

All my tests so far have been silently routed through GPT-4o — not the o3 model I intended to test. That’s a problem. 4o just doesn’t handle this workload as well. Even when testing in Cursor, It drops context, writes less structured code, and generally feels more like a chatty assistant than a precise build partner. It’s not a real test until o3 is in the loop.

So that’s next: route correction. Until I know the patch engine runs cleanly through the full agent-runner loop using the right model, I can’t call this closed.