In this chapter
I describe this approach in the desktop-application rewrite story. The starting point is application code.
In brAIn, we collect domain knowledge. Here, we reconstruct how software works. In MiddleBrain, we join those two things.
Middleware: first the operating model
The agents’ first task is to extract from code a description of how the system works. It produces readable .md files and JSON with ordered connections that tools can use. This model is made available to agents through middleware — an intermediary layer. The model describes the system; middleware lets work use that description.
I explain it to myself as “flattening” code from 3D to 2D. This is my metaphor: rather than entering one class and function after another just to discover connections, the agent gets a map of behaviour. It can see how a slice connects to the rest and return to code for detail. It does not have to learn the system from zero for every task.
Preparing this model takes time. For us it paid off because the logic description could be used in later work. It is not tied to .NET or Java syntax, opening a path to reconstruct behaviour in another technology. The new implementation still needs to be built and compared with expected behaviour; the map alone does not rewrite an application.
If I started a similar rewrite today, I would do this:
- First, describe behaviour and dependencies. Give the agent code and available materials. Ask for the model, where each rule comes from in code, and what it still does not understand.
- Then check a known flow. Choose one user action. With an expert, compare its description, old-system result, and what the agent found. Differences must return to the model.
- Only then implement a new slice. The agent uses the checked description and we compare the result on the same data. On later changes, update the model so it does not describe stale code.
Return to rewriting the system — compare the old and new versions
What must be maintained with the model
The model describes a specific code version. Keep connections to implementation and tests, mark undescribed slices, and update the description after changes. Otherwise an agent will use a map of a different application version.
The .md files describe meaning and behaviour; JSON lets a tool read ordered connections. The format itself does not guarantee correctness or repeatable results. Check the description against code and application behaviour. Likewise, the presence of files does not yet mean a middleware service works.
Product creator
Marcin Zelek