[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-82127-en":3,"doc-seo-82127-105":29,"detail-sidebar-cat-0-en-105":90},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":4,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":13,"seo_description":14,"update_tm":27,"read_time":28},82127,1099514067415,"Rowan","https://ap-avatar.wpscdn.com/avatar/100002539d78ffe74a7?x-image-process=image/resize,m_fixed,w_180,h_180&k=1779092875211072502",8,"Research & Report","The Patchwork Problem in LLM-Generated Code","LLM-generated code can compile, pass tests, and look correct, yet fail in deployment due to structural issues rather than logical ones. Examples include endpoints referencing undeclared configuration keys, imports targeting non-existent packages, and missing authentication guards for new routes. The work formalizes structural coherence as consistency invariants over graph representations spanning imports, calls, dependencies, configuration, schemas, resources, control-flow, and routing. It proposes an eight-category failure taxonomy and a hybrid verification framework that combines mature static analysis with cross-graph detectors, supported by empirical and external evaluations.","arXiv :2607 .0898 1v 1 [ cs . SE] 9 Jul 2026  \nThe Patchwork Problem in LLM-Generated Code  \nViraaji Mothukuri, Reza M. Parizi  \nDecentralized Science Lab, College of Computing and Software Engineering Kennesaw State University, GA, USA  \n[vmothuku@students. kennesaw. edu](vmothuku@students. kennesaw. edu) [rparizi1@kennesaw. edu](rparizi1@kennesaw. edu)  \nAbstract  \nLLM-generated code often compiles, passes tests, and appears correct, yet breaks once deployed. The root cause is frequently structural rather than logical. A generated endpoint references configuration keys never declared in the project, an import targets a package that does not exist in any registry, or a new route omits the authentication guard applied to every sibling endpoint. Each patch is locally valid but globally incoherent, and standard CI toolchains rarely surface these failures. As LLM-powered coding tools see widespread adoption, this blind spot poses a growing risk to software quality. We call this the patchwork problem. This paper formalizes structural coherence as consistency invariants over graph representations of repository artifacts, including import, call, dependency, configuration, schema, resource, control-flow, and routing graphs, and introduces an eight-category failure taxonomy distinguishing defects specific to LLM generation from those merely amplified by it. We present a hybrid verification framework that delegates to mature static analysis tools where they already excel and deploys purpose-built detectors for cross-cutting invariants underserved by existing toolchains, targeting provable constraint violations rather than heuristic pattern matching. Empirical evaluation across two frontier models under four prompting strategies reveals that the vast majority of structural failures evade type checking, testing, and SAST entirely, and that failure patterns diverge qualitatively between models in ways that challenge model-agnostic mitigation strategies. External validation on real-world AI-generated repositories confirms that these failures are not artifacts of controlled experimentation but are prevalent wherever LLMs write code with minimal human oversight.  \nKeywords: LLM code generation, structural coherence, static analysis, graph invariants, code quality, neural code synthesis.  \n1 Introduction  \nCode generation from Large Language Models has achieved remarkable results on isolated programming tasks [1–4], driving rapid adoption, with millions of engineers using LLM-powered assistants daily. Yet a gap persists between benchmark performance and production utility [5] . Code that appears correct in isolation frequently fails when integrated into real software systems [6], and the dominant failure mode is structural rather than functional. A generated patch may compile, pass type checking, and satisfy local tests while violating invariants that span the repository. Consider a FastAPI endpoint referencing a Pydantic model with hallucinated field names, or a Django view assuming environment variables that are never declared in the project configuration. Such patches exhibit local correctness but global incoherence: they pass the checks developers rely on and fail only when exercised in the context of the full system.  \nCurrent evaluation methodologies do not surface these failures systematically. Type checking and linting often miss semantic inconsistencies that cross file boundaries. Test suites cannot cover every integration point. SAST  \ntools typically focus on taint flows rather than structural coherence. The result is a blind spot in which generated code enters codebases carrying latent defects that remain invisible to standard toolchains. We term this the patchwork problem. LLM-generated patches maybe individually well-formed yet fail to cohere into a consistent whole, particularly at repository scale, where consistency constraints span imports, dependencies, configurations, schemas, and security contracts [7] .  \nOur approach for","cbCaifWH762G9Eo5","https://ap.wps.com/l/cbCaifWH762G9Eo5","pdf",1075525,1,11,"English","en",105,"# Introduction\n# Related Work","[{\"question\":\"What is the “patchwork problem” in LLM-generated code?\",\"answer\":\"It is the failure mode where generated patches are locally valid (compile and pass checks) but become globally inconsistent when integrated into the full repository, because structural invariants are violated.\"},{\"question\":\"How does the paper formalize structural coherence?\",\"answer\":\"It models repository artifacts as graphs and defines structural coherence via consistency invariants across multiple graph types, including imports, calls, dependencies, configuration, schemas, resources, control-flow, and routing graphs.\"},{\"question\":\"What verification approach does the paper propose?\",\"answer\":\"It uses a hybrid framework: mature static analysis tools handle invariant classes they already cover, while purpose-built cross-graph detectors target constraint violations that existing toolchains do not capture well.\"}]",1784178356,28,{"code":4,"msg":30,"data":31},"ok",{"site_id":24,"language":23,"slug":32,"title":13,"keywords":33,"description":14,"schema_data":34,"social_meta":85,"head_meta":87,"extra_data":89,"updated_unix":27},"the-patchwork-problem-in-llm-generated-code","",{"@graph":35,"@context":84},[36,53,67],{"@type":37,"itemListElement":38},"BreadcrumbList",[39,43,47,50],{"item":40,"name":41,"@type":42,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":44,"name":45,"@type":42,"position":46},"https://docshare.wps.com/document/","Document",2,{"item":48,"name":12,"@type":42,"position":49},"https://docshare.wps.com/document/research-report/",3,{"item":51,"name":13,"@type":42,"position":52},"https://docshare.wps.com/document/the-patchwork-problem-in-llm-generated-code/82127/",4,{"url":51,"name":13,"@type":54,"author":55,"headline":13,"publisher":57,"fileFormat":60,"inLanguage":23,"description":14,"dateModified":61,"datePublished":61,"encodingFormat":60,"isAccessibleForFree":62,"interactionStatistic":63},"DigitalDocument",{"name":9,"@type":56},"Person",{"url":40,"name":58,"@type":59},"DocShare","Organization","application/pdf","2026-07-16",true,{"@type":64,"interactionType":65,"userInteractionCount":4},"InteractionCounter",{"@type":66},"ViewAction",{"@type":68,"mainEntity":69},"FAQPage",[70,76,80],{"name":71,"@type":72,"acceptedAnswer":73},"What is the “patchwork problem” in LLM-generated code?","Question",{"text":74,"@type":75},"It is the failure mode where generated patches are locally valid (compile and pass checks) but become globally inconsistent when integrated into the full repository, because structural invariants are violated.","Answer",{"name":77,"@type":72,"acceptedAnswer":78},"How does the paper formalize structural coherence?",{"text":79,"@type":75},"It models repository artifacts as graphs and defines structural coherence via consistency invariants across multiple graph types, including imports, calls, dependencies, configuration, schemas, resources, control-flow, and routing graphs.",{"name":81,"@type":72,"acceptedAnswer":82},"What verification approach does the paper propose?",{"text":83,"@type":75},"It uses a hybrid framework: mature static analysis tools handle invariant classes they already cover, while purpose-built cross-graph detectors target constraint violations that existing toolchains do not capture well.","https://schema.org",{"og:url":51,"og:type":86,"og:title":13,"og:site_name":58,"og:description":14},"article",{"robots":88,"canonical":51},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":91},[92,96,100,104,109,114,119,122,127,130,134],{"id":20,"doc_module":4,"doc_module_name":45,"category_name":93,"show_sort_weight":94,"slug":95},"Story & Novel",90,"story-novel",{"id":46,"doc_module":4,"doc_module_name":45,"category_name":97,"show_sort_weight":98,"slug":99},"Literature",80,"literature",{"id":52,"doc_module":4,"doc_module_name":45,"category_name":101,"show_sort_weight":102,"slug":103},"Exam",70,"exam",{"id":105,"doc_module":4,"doc_module_name":45,"category_name":106,"show_sort_weight":107,"slug":108},5,"Comic",60,"comic",{"id":110,"doc_module":4,"doc_module_name":45,"category_name":111,"show_sort_weight":112,"slug":113},6,"Technology",50,"technology",{"id":115,"doc_module":4,"doc_module_name":45,"category_name":116,"show_sort_weight":117,"slug":118},7,"Healthcare",40,"healthcare",{"id":11,"doc_module":4,"doc_module_name":45,"category_name":12,"show_sort_weight":120,"slug":121},30,"research-report",{"id":123,"doc_module":4,"doc_module_name":45,"category_name":124,"show_sort_weight":125,"slug":126},9,"Religion & Spirituality",20,"religion-spirituality",{"id":125,"doc_module":4,"doc_module_name":45,"category_name":128,"show_sort_weight":125,"slug":129},"World Cup","world-cup",{"id":131,"doc_module":4,"doc_module_name":45,"category_name":132,"show_sort_weight":131,"slug":133},10,"Lifestyle","lifestyle",{"id":135,"doc_module":4,"doc_module_name":45,"category_name":136,"show_sort_weight":105,"slug":137},19,"General","general"]