Policy-Class Confinement in LLM Code Repair: Why Explicit Test Contracts Fail Against Library Priors and How Feedback Topology Unlocks Resolution

Why do LLM repair agents rewrite code indefinitely yet fail a test that displays the expected output? We isolate and resolve this failure mode—policy-class confinement—in a coupled Python repository. One test (dot_short), requiring silent truncation on mismatched lengths, stalled two defect variants and absorbed 81–96% of edit traffic in stalled runs. Under contract-only feedback, 0/270 isolated emissions satisfied it (1/581 across all variants), although the assertion displayed both unequal-length inputs and the target value, and three one-line fixes exist. Confinement is semantic, not lexical: two censuses (150 and 120 emissions) yielded 21 and 17 syntactically distinct implementations sharing one prior-consistent policy—raise ValueError on mismatch—with the correct zip summation already present beneath the guard, and a no-op rate of 0.04 at 100 attempts. A 2×2 factorial (observed runtime error × strategy instruction; assertion constant; n=8/cell) separates two escape routes: observed consequence raises resolution 0/8→7/8 but requires 3–9 turns (13/108 emissions; Holm-adjusted p=0.0042), whereas one strategy sentence yields 8/8 first-attempt resolution with or without the error (28/28; p=0.0008; occlusion p=1.00). The resulting gradient—0.17%, 12.0%, 100%—separates specification, counter-evidence and prescription. Model-free substrate forensics independently expose anti-monotone repair (7→8 failures), serial-dependency inertness and behaviourally invisible defects. Pre-registered gates blocked confirmatory expenditure, leaving the parent hypothesis open; total cost <US$0.25. Scope: one repository, one served model alias; verification tiers declared.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-11-24
DOI
https://doi.org/10.5281/zenodo.24517170
Primary Topic
Software Testing and Debugging Techniques
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
article

Policy-Class Confinement in LLM Code Repair: Why Explicit Test Contracts Fail Against Library Priors and How Feedback Topology Unlocks Resolution

rogelio perez casadiego
2 links
Zenodo (CERN European Organization for Nuclear Research)
Software Testing and Debugging Techniques
article

Policy-Class Confinement in LLM Code Repair: Why Explicit Test Contracts Fail Against Library Priors and How Feedback Topology Unlocks Resolution

rogelio perez casadiego
article en

Abstract

Why do LLM repair agents rewrite code indefinitely yet fail a test that displays the expected output? We isolate and resolve this failure mode—policy-class confinement—in a coupled Python repository. One test (dot_short), requiring silent truncation on mismatched lengths, stalled two defect variants and absorbed 81–96% of edit traffic in stalled runs. Under contract-only feedback, 0/270 isolated emissions satisfied it (1/581 across all variants), although the assertion displayed both unequal-length inputs and the target value, and three one-line fixes exist. Confinement is semantic, not lexical: two censuses (150 and 120 emissions) yielded 21 and 17 syntactically distinct implementations sharing one prior-consistent policy—raise ValueError on mismatch—with the correct zip summation already present beneath the guard, and a no-op rate of 0.04 at 100 attempts. A 2×2 factorial (observed runtime error × strategy instruction; assertion constant; n=8/cell) separates two escape routes: observed consequence raises resolution 0/8→7/8 but requires 3–9 turns (13/108 emissions; Holm-adjusted p=0.0042), whereas one strategy sentence yields 8/8 first-attempt resolution with or without the error (28/28; p=0.0008; occlusion p=1.00). The resulting gradient—0.17%, 12.0%, 100%—separates specification, counter-evidence and prescription. Model-free substrate forensics independently expose anti-monotone repair (7→8 failures), serial-dependency inertness and behaviourally invisible defects. Pre-registered gates blocked confirmatory expenditure, leaving the parent hypothesis open; total cost <US$0.25. Scope: one repository, one served model alias; verification tiers declared.

Zenodo (CERN European Organization for Nuclear Research)
Software Testing and Debugging Techniques
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon