Ask HN: How to deal with shipping AI-written code you don't understand?
630 pointshttps://www.linkedin.com/posts/ali-hamie_im-an-engineer-at-m...
> I'm an engineer at Meta and I never felt this uncomfortable doing my job. I'm writing code these days and it all feels like a black box. This new standard of shipping with AI is moving so fast that if we're going to spend our time checking each line of code, it's going to take forever. That means you can end up with systems you've built where you don't truly understand how all the code works. You understand the high level, but not every detail. And maybe this is becoming the new standard. It goes against every instinct of being a software engineer. I'm used to understanding what I'm building. Now I'm trying to figure out how much I need to understand before I'm comfortable moving forward. Are other engineers feeling this too?
How are you handling this?
Comments (767) 238 threads
Earlier commentsI think a useful perspective is "How does engineering management control software quality?" You will know the answers to this question: testing practices, design documents, SLAs, release management. You will know this because you almost certainly have to comply with some of these as a SWE. All of those practices exist because code produced by humans is not perfectly reliable and thus there need to be checks and risk reduction steps to manage the software that is shipped.
The way I view agents is that all of us have become engineering managers now. So those tools are now your tools. You set up the practices and frameworks and make the agents use them. If you set them up right you can be very confident in what the agents wrote without ever reading it.
Now you're not going to go from nothing to "Hey I ship code I've never read" overnight. It takes work. You have to set up your project carefully so that the agents can’t make mistakes. But all you have to do is be systematic about it. Every time the agents do something stupid or they ship a bug, you think, "How do I put something in place to prevent this entire class of bugs from happening again?" As you iterate this process, you will continuously be ruling out entire classes of bugs and eventually you'll be able to trust the agents.
Example: I had a bug, or a class of bugs, where agents would write a database migration and it would be wrong. It would get rolled out and the database would be broken. I fixed this by putting in a migration testing framework where there was data written in an old schema, then the migrations would run on that data. Then you could write tests on the expected result at any point after any migrations. Then, I put in place a rule: if you write a database migration you have to write a migration test. That fixed the problem. I have never had a migration failure since.
So this is not some magical process. It's going to take you hard work to set up your system with all of this infrastructure to make the agents maximally productive. But as you iteratively improve your system, you can reach a place where you can have agents ship code without reading it. It's not just about making the system work but it's also about building your trust in the system that you have. I routinely ship code without reading it now and I think I've shipped about two bugs in the past two months (and I’ve written ~500k LOC in that time). And one of those bugs was very explicitly my fault for telling the agents they could violate one of the frameworks in place (oops).
Models and harnesses have gotten really good, but they still are hard-capped by the operators that use them. The sycophancy of models is perhaps their greatest weakness, as when a user who might be experienced in one area attempts to use AI to build within an area they are less familiar with, the model does not take a step back and examine the "why" of what is being built from an architectural standpoint, it simply performs the expected task in a direct manner, ultimately creating sloppy work that may be easy to ship but difficult to maintain.
A good example of this was a recent interaction I had with a Dev who was very familiar with how to develop embedded and system level applications. He and every other dev are being asked for increasingly more due to AI, and he had to bring something he had built as a single-user desktop application into a distributed cloud environment. He ended up rsyncing a copy of his working directories including multiple credentials and sensitive internal project documents to a virtual machine binding it to a public ip address. Thankfully our tooling detected this before he could get any farther but it illustrates how the AI model isn't doing any real thinking or engineering at the end of the day. Unless the operator knew to instruct the model about proper cloud architecture and understood best practices around deployment of public systems, the model simply did what it was being told to do by a user who didn't know any better.
Another example of this is the sheer amount of unsophisticated users we've been detecting using Javascript injection into their web browser sessions as a form of automation for web services they may use. These users would never know to ask how to request an API token which may allow them to accomplish things in a much easier and approved way, and instead are relying on the frailest possible automations that expose them to risks of credential exposure.
We've got to be careful with how we engineer things with AI models. Just because we've made boilerplate easier to generate doesn't mean that we can avoid the actual engineering of what we do. And I can't help but think that firms which are fully committed to AI code generation, won't just be introducing an avalanche of slop into their product which will explode the costs of maintenance over time.
Which is fine, usually. Depends on what you are doing.
The things that always mattered were the core system, the trunk of a tree if you will. The branches less so, and the leaves not at all (though that is what people see and appreciate! The irony!).
All comments shown.
Couldn't load more comments. Check your connection and try again.