Taming the Drift: Context-aware Repair of Dockerfile Drift during Software Evolution
This paper presents Cadre, a context-aware framework that leverages static analysis to construct a Context-aware Dependency Graph (CDG) for generating targeted patches that effectively repair Dockerfile drift, outperforming existing rule-based and LLM-based baselines on the newly introduced benchmark of 1,040 real-world drift instances.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you're building a robot in your garage. You've written a perfect instruction manual (the Dockerfile) that tells your robot exactly what parts to grab, where to put them, and how to assemble them. But then, you decide to upgrade the robot's brain (the source code) and swap out a few wires. You forget to update the manual to match these new parts.
Now, when you try to build the robot, it sputters and dies. The manual isn't "broken" in a grammatical sense; the words are fine. But the manual is drifting away from reality. It's trying to grab a part that no longer exists or use a tool that's been replaced. In the world of software, this is called Dockerfile drift, and it causes computers to fail silently, leaving developers scratching their heads for days.
The Old Way: Guessing in the Dark
Previous tools tried to fix this by just reading the manual and the error message. It's like trying to fix a car engine by only looking at the "Check Engine" light and the owner's manual, without ever opening the hood to see the actual wires.
Some tools used rigid rules (like a checklist), while others used super-smart AI (Large Language Models) to guess the fix. But here's the problem: these AI tools were drowning in information. They were handed the entire garage—every single screw, every old manual, and every box of junk—along with the error message. The AI got so overwhelmed by the noise that it either gave up or hallucinated a crazy fix that didn't work. In fact, in about 41 to 58 out of every batch of problems, these AI tools simply failed to produce any answer because the "instruction list" was too long for them to read.
The New Hero: Cadre (The Detective)
Enter Cadre, a new framework that acts like a brilliant detective. The authors, Chengjie Wang and his team, realized that the secret to fixing the robot isn't giving the detective more stuff to read, but giving them the right map.
Their big idea is simple: Structure matters more than volume. Knowing which specific wire connects to which specific screw is way more important than reading a thousand pages of unrelated text.
Cadre does this in three magical steps:
- The Context Profiler (The Time Traveler): Before trying to fix anything, Cadre simulates the entire building process step-by-step. It watches exactly which files are copied, which variables are set, and which tools are called. It builds a mental model of the "state" of the project at every single moment.
- The CDG (The Dependency Map): Using that simulation, Cadre draws a Context-aware Dependency Graph (CDG). Think of this as a subway map for your software. It shows exactly how the "FROM" instruction (the base) connects to the "COPY" instruction (the parts) and finally to the "RUN" instruction (the assembly). If a file changes, the map shows exactly which instructions will trip over it.
- The Two-Step Fix (The Smart Filter): Instead of dumping the whole garage on the AI, Cadre asks the AI a smart question first: "Based on this map and the error, which specific files do you actually need to see?"
- Step 1: The AI picks only the relevant files (the "Key Files").
- Step 2: The AI reads only those files and writes the fix.
This keeps the AI's "brain" from overflowing. While other methods failed to generate a patch in 41–58 cases because the prompt was too huge, Cadre produced a patch for every single one of its attempts.
The Results: Does it Work?
The team tested Cadre on 1,040 real-world examples they dug out of GitHub's history (a dataset they called 𝐷3). These weren't fake problems; they were actual failures that happened in real software projects, complete with the exact settings needed to reproduce them.
Here is how Cadre stacked up:
- Cadre fixed 35.22% of the problems.
- The best previous AI method (without this smart mapping) fixed 28.48%.
- The old rule-based checklist method only fixed 9.34%.
That means Cadre is 1.24 times better than the best AI competitor and nearly 3 times better than the old rule-based tools.
But the real magic happens when the problem gets "stale." Imagine a broken build that nobody fixed for five or six updates. The recent code changes look totally unrelated to the original error. Most tools get confused and give up. But because Cadre uses the CDG map, it can trace the broken wire back to its origin, even if it's buried deep in history. At five or more updates away, Cadre fixed 25.9% of the problems, while the next best tool only managed 19.7%. The gap actually grew wider as the problems got older, proving that the map is a durable signal.
What It's NOT
It's important to know what Cadre doesn't do. It's not a magic wand that fixes everything.
- It can't fix problems caused by the internet being down or a server running out of disk space.
- It can't fix bugs inside the actual code logic (like a math error in the program itself); it only fixes the build instructions.
- In about 65% of the cases where it failed, the issue was a complex build-tool constraint that simply couldn't be solved by changing the manual (like a missing package in a private registry).
The Takeaway
The authors suggest that for the future of software maintenance, we need to stop just throwing more data at AI and start teaching it how to understand the structure of dependencies. By building a map of how files and instructions connect, Cadre proved that a little bit of smart context goes a long way. It's not about reading the whole library; it's about knowing exactly which page to turn to.
All the code and the dataset of 1,040 real-world drifts are open for anyone to check, ensuring that this isn't just a theory, but a tool built on real, reproducible evidence.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.