RegoMender: A Multi-agent Framework for Automated Rego Policy Repair
Authors: Ruijie Zhang, Huaxiao Yin, Li Hu, Fanqi Kong, Haozhe Liang, Shaoyin Cheng, Kun Zhang, Bibo Tu
Organizations: Institute of Information Engineering, Chinese Academy of Sciences Beijing, China School of Cyber Security, University of Chinese Academy of Sciences Beijing, China · University of Science and Technology of China Hefei, China · Peking University Beijing, China · University of Chinese Academy of Sciences Beijing, China · Anhui Province Key Laboratory of Digital Security, Hefei, China
Policy-as-Code (PaC) has emerged as a foundational paradigm in cloud-native systems. However, repairing Rego policies remains challenging due to their strict syntax, declarative semantics, and specific verification requirements. Existing automated program repair (APR) methods are mainly designed for mainstream languages and struggle to accommodate the unique policy logic and repair workflows of Rego. Thus, Rego policy repair remains a manual process driven by trial and error. To address this, we introduce RegoBench, the first automated Rego policy benchmark comprising 1,159 real-world defects, and propose RegoMender, a feedback-guided multi-agent framework. Collaborating via a shared blackboard and an atomic toolkit, RegoMender dynamically executes patching, rewriting, or rolling back, to resolve complex repair scenarios. Evaluated on RegoBench, RegoMender achieves syntactic and test-based semantic success rates of 82.9% and 77.9%, respectively, outperforming the strongest baseline by 13.4%. Unlike other approaches whose performance drops in complex scenarios, RegoMender maintains effectiveness across single-step and chained repair tasks. Furthermore, it generalizes strongly across HCL and SQL and achieves an 86.4% repair rate on 132 real-world CVE vulnerabilities, proving its robustness and practical utility for security.
Figures & tables
Figure 1. An Example for Rego Policy Repair.
Figure 2. Overview of RegoBench Construction and RegoMender Workflow.
Defect Type
Symptom
Number
PARSE
parse error / rule-head / Rego.v1
348
BIND
binding operator / scope
93
REF
unsafe var / undefined ref / import mismatch
162
TYPE
type error / arity / built-in / helper contract
209
PATH
missing path / input shape
81
RULE
recursion / conflicting rules / defaults
70
Table 1. Defect Taxonomy of RegoBench.
Method
Pass@Tier-1 (%)
Pass@Tier-2 (%)
JudgePass (%)
Cost / Effort
Easy
Medium
Hard
Overall
Easy
Medium
Hard
Overall
Easy
Medium
Hard
Overall
Budget ($)
Time (h)
LLM Calls
Regr.%
Standalone Methods
Agentless ( Xia et al., 2024 )
66.7 ± 1.8
60.0 ± 1.6
46.7 ± 1.9
59.9 ± 1.5
61.4 ± 1.7
54.0 ± 1.5
41.1 ± 1.8
54.3 ± 1.4
58.0 ± 1.6
50.2 ± 1.5
37.0 ± 1.6
50.6 ± 1.3
4.8 ± 0.2
2.6 ± 0.2
2,614 ± 74
17.5 ± 1.6
ThinkRepair ( Yin et al., 2024 )
71.1 ± 2.0
46.9 ± 1.8
27.8 ± 1.6
53.3 ± 1.4
65.1 ± 1.9
42.0 ± 1.6
24.1 ± 1.4
48.2 ± 1.1
60.2 ± 1.9
37.9 ± 1.5
20.9 ± 1.5
43.9 ± 1.2
3.9 ± 0.2
2.2 ± 0.1
1,998 ± 61
26.3 ± 1.8
APR-MCTS ( Hu et al., 2025a )
73.3 ± 1.9
54.5 ± 1.7
46.7 ± 1.8
61.1 ± 1.5
67.4 ± 1.8
49.1 ± 1.6
41.1 ± 1.7
55.4 ± 1.7
64.0 ± 1.7
45.9 ± 1.5
37.0 ± 1.7
51.9 ± 1.6
6.2 ± 0.3
2.7 ± 0.2
4,995 ± 118
15.8 ± 1.4
RepairAgent ( Bouzenia et al., 2025 )
84.6 ± 1.6
64.2 ± 1.4
51.5 ± 1.5
70.4 ± 1.3
78.5 ± 1.5
58.4 ± 1.3
45.8 ± 1.4
64.5 ± 1.2
75.9 ± 1.4
55.4 ± 1.5
42.4 ± 1.4
61.5 ± 1.3
5.2 ± 0.2
2.9 ± 0.2
2,664 ± 72
14.8 ± 1.2
Table 2. Performance Comparison of Repair Methods on RegoBench.
Figure 3. Repair Success Rates for Different Defect Types.
Models
Size
ThinkRepair
RepairAgent
RegoMender
Easy
Medium
Hard
Overall
Budget
Time
Easy
Medium
Hard
Overall
Budget
Time
Easy
Medium
Hard
Overall
Budget
Time
Closed-Source LLMs
GPT-4.1 ( OpenAI, 2025 )
-
72.3
47.1
28.4
54.0
21.0
3.2
58.7
40.2
32.1
46.6
26.4
4.1
89.2
72.4
58.3
76.6
47.3
7.3
Claude-3.5-Sonnet ( Anthropic, 2024 )
-
82.1
55.3
33.2
62.1
27.0
2.4
72.4
58.1
48.3
62.2
33.8
3.0
92.3
76.2
60.1
79.7
60.8
5.4
Gemini-2.5-Flash ( Comanici et al., 2025 )
-
35.2
22.1
12.3
25.7
10.0
2.7
80.3
62.1
52.2
67.9
12.6
3.4
90.1
70.3
57.2
76.1
22.5
6.1
GPT-5.4 ( OpenAI, 2026b )
–
81.5
58.4
38.6
64.2
17.8
3.0
84.6
65.8
53.4
71.5
22.5
3.6
95.2
76.5
61.0
81.1
41.2
6.4
Table 3. Performance Comparison of Repair Methods on RegoBench across Different Backbones.
Figure 4. Repair Success: Single-step vs. Chained.
Figure 5. Chained Repair Process. RegoMender resolves syntax errors then passes semantic tests to produce a verified patch.
Tool
RepairAgent (%)
RegoMender (%)
Full Toolkit
64.5
77.9
w/o Context Scan
49.2 (↓15.3)
61.2 (↓16.7)
w/o Patch
51.7 (↓12.8)
64.1 (↓13.8)
w/o Rollback
—
66.4 (↓11.5)
w/o Rewrite
56.4 (↓8.1)
68.6 (↓9.3)
w/o Error Triage
55.1 (↓9.4)
67.2 (↓10.7)
Table 4. Ablation Study on Tool Effectiveness.
DSL
N
Avg.Errors
RepairAgent (%)
RegoMender (%)
Rego
1,159
6.2
64.5
77.9
HCL
300
4.6
78.2
82.3
SQL
100
1.0
84.0
84.0
Table 5. Cross-DSL Generalization Performance.
CWE
Description
N
ThinkRepair
RepairAgent
RegoMender
CWE-284
Access Control
31
28.1%
71.9%
87.5%
CWE-250
Excess Privilege
28
27.6%
72.4%
89.7%
CWE-269
Privilege Mgmt
25
26.9%
69.2%
88.5%
CWE-732
Permission Assign
21
27.3%
68.2%
82.0%
CWE-863
Incorrect Authz
19
20.0%
60.0%
80.0%
Other
Mixed Types
9
30.0%
50.0%
90.0%
Table 6. Security Policies Repair Rates by CWE Category.
Prose2Policy (P2P) is a LLM-based practical tool that translates natural-language access control policies (NLACPs) into executable Rego code (the policy language of Open Policy Agent, OPA). It provides a modular, end-to-end pipeline that performs policy detection, component extraction, schema validation, linting, compilation, automatic test generation and execution. Prose2Policy is designed to bridge the gap between human-readable access requirements and machine-enforceable policy-as-code (PaC) while emphasizing deployment reliability and auditability. We evaluated Prose2Policy on the ACRE dataset and demonstrated a 95.3% compile rate for accepted policies, with automated testing achieving a 82.2% positive-test pass rate and a 98.9% negative-test pass rate. These results indicate that Prose2Policy produces syntactically robust and behaviorally consistent Rego policies suitable for Zero Trust and compliance-driven environments.
Large language models are increasingly deployed as autonomous agents for automated program repair, patching software vulnerabilities through multi-step reasoning and tool use. Yet these systems typically validate a patch against the same evidence used to construct it -- a static alert, sanitizer trace, published exploit, or test suite. A patch that blocks that one piece of evidence can therefore look successful while remaining vulnerable to the same vulnerability with some variation. We present P2Patch, a generative adversarial repair system that treats each patch as a new attack target. Starting from a normalized vulnerability finding, an exploitation agent constructs a reproducing proof of vulnerability (PoV), a patching agent repairs the program, and the exploitation agent then attacks the patched program for a distinct same-vulnerability exploit. Every successful exploit becomes a permanent repair requirement, and the final patch must block all PoVs accumulated during the patching process, with construction-time PoVs kept strictly separate from held-out evaluation oracles. Across 101 C/C++ and Java CVE subjects, this adversarial loop surfaces a distinct confirmed exploit in 41% of runs after the patch has already blocked its original construction-time PoV. Against single-pass repair from the same finding using Claude Code, P2Patch raises held-out fix-closed coverage from 78.1% to 84.7% and beyond-upstream coverage from 42.1% to 62.5%. Under the same held-out oracles, it also certifies more attack paths as blocked than recent state-of-the-art agentic repair systems on overlapping subjects. These results show that adversarial testing and independent security oracles expose repair gaps that one-shot validation misses.
Mohsen Iranmanesh, Sina Moradi Sabet, Sina Marefat +7
Simon Fraser University, Canada · Amirkabir University of Technology, Iran · K. N. Toosi University of Technology, Iran +1
The transition from neural machine translation to agentic workflows has revolutionized Automated Program Repair (APR). However, existing agents, despite their advanced reasoning capabilities, frequently suffer from the Intent Gap'' -- the misalignment between the generated patch and the developer's original intent. Current solutions relying on natural language summaries or adversarial sampling often fail to provide the deterministic constraints required for surgical repairs. In this paper, we introduce Prometheus, a novel framework that bridges this gap by prioritizing *Specification Inference* over code generation. We employ Behavior-Driven Development (BDD) as an executable contract, utilizing a multi-agent architecture to reverse-engineer Gherkin specifications from runtime failure reports. To resolve the Hallucination of Intent,'' we propose a Requirement Quality Assurance (RQA) Loop, a mechanism that leverages ground-truth code as a proxy oracle to validate inferred specifications. We evaluated Prometheus on 680 defects from the Defects4J benchmark. The results are transformative: our framework achieved a total correct patch rate of 93.97% (639/680). More significantly, it demonstrated a Rescue Rate of 74.4%, successfully repairing 119 complex bugs that a strong blind agent failed to resolve. Qualitative analysis reveals that explicit intent guides agents away from structurally invasive over-engineering toward precise, minimal corrections. Our findings suggest that the future of APR lies not in larger models, but in the capability to align code with verified, Executable Specifications -- whether pre-existing or reverse-engineered.
Yongchao Wang, Zhiqiu Huang
Nanjing University of Aeronautics and Astronautics