The patchwork problem in LLM-generated code
The Patchwork Problem in LLM-Generated Code
The researchers propose the patchwork problem in LLM-generated code: such code compiles and passes tests, yet fails after deployment because each patch holds locally while the global structure is inconsistent—for example, referencing a configuration key not declared in the project, importing a package that no registered library has, or a new route omitting an authentication guard that all sibling endpoints have. The paper formalizes structural consistency as consistency invariants over repository graph representations such as imports, calls, dependencies, and configuration, proposes a taxonomy of eight failure classes to distinguish defects specific to LLMs from those merely amplified by them, and presents a hybrid verification framework that deploys specialized detectors for cross-cutting invariants that existing toolchains cover insufficiently. Empirical evaluation on two frontier models under four prompting strategies shows that the vast majority of structural failures completely escape type checking, tests, and SAST, and that failure modes differ qualitatively across models; external validation on real-world AI-generated code repositories confirms that these failures are prevalent.