| ▲ | jerf 4 hours ago | |
This may seem an odd diversion but I am reminded of the Haskell pattern of "functional core, imperative wrapper" that a lot of that code tends to turn into. If we did a better job thinking in terms of contracts and guarantees, we could build cores that were secure, auditable by AIs and humans because they are smaller, and then often be somewhat less concerned by the much larger pile of code that uses that core, as long as the primitives offered by that core did not admit compromise. However, despite its other benefits, AI code has been a huge step back on almost every dimension we need for that plan to work. It is no longer the case that I've never seen an AI create a strong type, but I still don't see it thinking in terms of what values of this type guarantee very often, or any related concept. It still erases any such guarantees I add more often than it builds on them, even when I explicitly document the guarantees in the code docs (and then when it erases them, it leaves the comments about the guarantee behind, naturally). It is hard to fence an AI off to tell it not to modify this bit of code... not necessarily impossible but the models seem to presume that if they can see it, they can change it, and they basically YOLO and hope the test suite will catch anything that breaks as a result of their particular change written from the hyper-local perspective of the task at hand. They still want to write reams of scripting code where, for instance, every access to the database is individually responsible for maintaining any security guarantees related to the data in question... and then they often refuse to load the skills that might explain the guarantees that are necessary, and then the skills fall too far back in the context window to be taking effect. If I force them to be secure by building right into some function call a declaration of what permissions must be held to execute it, they rarely get the permissions completely correct and really love to just bypass the check, sometimes in distressingly clever ways. Even when asked to be sure to write tests that assert that permissions fail correctly. It's a very fast programmer. It can often do surprising specific tasks. But in a lot of ways, it's still not very good, when you really get right down to it. Without an exceeding strong hand the AIs I've seen build code that fights this on almost every level. If someone has some magic sauce to address my complaints and prove me wrong I am all ears... I'm getting kind of tired of the constant fights with my AIs over these issues. I'm trying various tweaks out but it takes time to try them out fairly. I used to think Star Trek was silly in the way it portrayed every computer system as hackable in about 15 seconds with the moral equivalent of a paperclip, but I begin to see a world in which that makes sense to me. | ||
| ▲ | theptip 4 hours ago | parent [-] | |
Curious if you’ve leaned into lint / hooks to try to enforce the invariants you seek? A recent talk from Poteto sketched some ideas here: https://m.youtube.com/watch?v=O_zcc6Xl12g The importance of verification is well understood, but some of the ideas around API design were novel to me - 1) ban comments, they usually mean nuance was required, instead just force the LLM to make the APIs more explicit. (Lints to ban comments at pre-commit and tell the LLM what to do instead.) 2) ban sketchy / confusing APIs from your language/framework. I’m sure you’ve tried a bunch of this so I’d be interested in any concrete examples you can share, but it does sound like you’ve been trying to make Capabilities and strong typed APIs work, which is the right direction IMO. I would have thought Claude hooks could prevent modifying particular bits of code though, from your list of issues above. And anything you can put in a lint will be resurfaced at the time the invariant is broken, rather than requiring the agent to remember CLAUDE.md line 336. For any serious project I like the Hexagonal pattern of having CLI and API being two UI layers atop the same underlying Application layer, and then you can ban special-case scripting logic. I always found this architecture a bit too boilerplatey to use in small-to-medium projects but LLMs can do it well (and you can enforce the layer interfaces deterministically too). | ||