Reinforcement Ingredient Fixer (ReInFix) has reasoning and solution phases.
In the reasoning phase, ReInFix integrates static analysis tools to retrieve internal ingredients, such as variable definitions, to assist the LLM in root cause analysis when it encounters difficulty understanding the context. During the solution phase, when the LLM lacks experience in fixing specific bugs, ReInFix searches for external ingredients from historical bug fixes with similar bug patterns, leveraging both the buggy code and its root cause to guide the LLM in identifying appropriate repair actions, thereby increasing the likelihood of generating correct patches.
Performance of ReInFix on Defects4J and RWB dataset comparing to other works
Time measurements of ReInFix
Bug-fixing Venn diagram of ReInfix_3.5 on Defects4J V1.2&2.0
Source code, dataset & correct patches are available on Google drive. Figshare: https://figshare.com/s/cd5687faae182abff95c
Checkout Defects4J projects and load into Joern by running src/repo_d4j.py and src/repo_joern.py, replace content of list from bug_list/bug_list_d4j.txt or bug_list/bug_list_rwb.txt to select specific project bug id.
Download and prepare RWB dataset from here and put it to RWB_dataset folder.
Put embedded_cause_97k.csv file to retrieval_base folder.
Set your OpenAI API key and Joern server IP address in src/config.py.
Start the Joern server by running src/joern.sh
Start the RAG server by running src/rag_search_server.py
Generate patches
For single-function patches, run src/agent/react_sf_gen_patch.py, it will generate solutions and patches in src/output/sf_solution & src/output/sf_patches
For multi-function patches, run src/agent/react_mf_gen_patch.py, it will generate solutions and patches in src/output/mf_solution & src/output/mf_patches
Validate patches
For Defects4J patches, run src/validation/D4J/sf_run.py for single_function, and src/validation/D4J/mf_run.py for multi_function
For RWB patches, run src/validation/RWB/validate_RWB.py
Use separate servers for Joern query and RAG/patch generation/validation for better performance
Ensure sufficient memory is available for the Joern server
Replace the list of each file to focus some ceratian bug id.
Defects4J: https://github.com/rjust/defects4j
Joern: https://github.com/joernio/joern
LangChain: https://github.com/langchain-ai/langchain
ThinkRepair: https://github.com/vinci-grape/ThinkRepair
SRepair: https://github.com/GhabiX/SRepair