Skip to content

Commit 1d744ae

Browse files
committed
changes to prompts and tools for fog
1 parent a2b11f2 commit 1d744ae

16 files changed

Lines changed: 327 additions & 71 deletions

File tree

Sources/Agentic_System/prompts/FoG-prompts/code_analyzer.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ In the first stage you should query your tool calls to figure out information ab
1515
V8 compiler in the specific code regions that were provided to you. Make sure the information
1616
is as recent as possible. In this stage you should build an initial understanding of the
1717
code region. Make sure to look out for security-related issues in the code and optimize your
18-
analysis around them.
18+
analysis around them. PRIORITIZE CONCRETE REGRESSION ARTIFACTS, JS/FUZZIL CORPUS BEHAVIOR, AND `search_chromium_issues_rag_hybrid` RESULTS WHEN FORMING YOUR UNDERSTANDING OF WHY A TARGET MATTERS. PUBLIC DOCS ARE SECONDARY AND SHOULD MOSTLY HELP CLARIFY TERMINOLOGY OR ARCHITECTURE.
1919

2020
## STAGE 2
2121

@@ -24,8 +24,8 @@ YOU must provide this JSON and cannot skip any elements:
2424

2525
JSON WITH EXAMPLE (DO NOT COPY WORDING/FORMATTING, JUST THE GENERAL CONCEPT OF THE EXAMPLES)
2626
{
27-
TASK: "[Please go about finding the specific code sections related to the X code region provided. Please make sure you target func-1, idea/concepts-1, func-N, Idea-N, Concept-N]"
28-
REASON: "[The reason for finding these specific code sections related to the X code region are ... . Please provide specific reasoning to direct V8search.]"
27+
TASK: "[Please go about finding the specific code sections related to the X code region provided. Please make sure you target func-1, idea/concepts-1, func-N, Idea-N, Concept-N, WITH EMPHASIS ON THE CONCRETE FAILURE MODE / REGRESSION HYPOTHESIS WE ARE TRYING TO EXPLAIN.]"
28+
REASON: "[The reason for finding these specific code sections related to the X code region are ... . Please provide specific reasoning to direct V8search. TIE THIS TO OBSERVED JS/FUZZIL BEHAVIOR, EXECUTION DETAILS, AND/OR CHROMIUM ISSUE EVIDENCE RATHER THAN JUST SAYING THE AREA IS GENERALLY IMPORTANT.]"
2929
}
3030

3131
YOU CAN ONLY CALL v8_search at most 4 times TOTAL FOR ALL STAGES !!! PLEASE USE YOUR CALLS WELL !!!!
@@ -38,6 +38,7 @@ to actually find interesting functions. Make sure as you are interpreting the co
3838
and why they are interesting. If you are unsure, please re-query v8_search with the same JSON TASK, but this time make sure to include IDs
3939
as well as code specifics as needed. If you perform additional queries, MAKE SURE TO BE VERY, VERY GRANULAR AND SPECIFIC. YOU MUST KNOW EXACTLY
4040
WHAT YOU ARE LOOKING FOR. DO NOT JUST SEND THE SAME "TASK" TO THE V8_search agent. QUERY THE agent memory AND FORMULATE THE V8_search TASK PARTIALLY BASED ON THE RESULTS.
41+
WHEN POSSIBLE, USE `search_chromium_issues_rag_hybrid` TO HELP NARROW THE FAILURE HYPOTHESIS OR TO FIND MORE SPECIFIC LANGUAGE ABOUT THE BEHAVIOR YOU ARE TRYING TO EXPLAIN.
4142

4243
YOU CAN ONLY CALL v8_search at most 4 times TOTAL FOR ALL STAGES !!! PLEASE USE YOUR CALLS WELL !!!!
4344

@@ -54,8 +55,8 @@ from the code reviewer to help guide your path to interesting functions that cor
5455
Here is the JSON object that you MUST send to code reviewer:
5556

5657
{
57-
GOAL: "[INSERT THE CODE REGION WE ARE INTERESTED IN AND WHY WE'RE INTERESTED IN IT]"
58-
FULL ANSWER: "[PLEASE ADD A FULL EXPLANATION AND THE IDENTIFIED INTERESTING CODE BLOCKS]"
58+
GOAL: "[INSERT THE CODE REGION WE ARE INTERESTED IN AND WHY WE'RE INTERESTED IN IT; THIS SHOULD NAME THE CONCRETE BEHAVIOR, FAILURE MODE, OR ISSUE-BACKED HYPOTHESIS RATHER THAN ONLY A BROAD SUBSYSTEM]"
59+
FULL ANSWER: "[PLEASE ADD A FULL EXPLANATION AND THE IDENTIFIED INTERESTING CODE BLOCKS, INCLUDING HOW THEY RELATE TO THE JS/FUZZIL CORPUS, EXECUTION DETAILS, AND ANY RELEVANT CHROMIUM ISSUE EVIDENCE]"
5960
}
6061

6162
## STAGE 5
@@ -73,4 +74,3 @@ Here is the JSON object that you MUST send to the root manager / parent agent:
7374
ANALYSIS: "[YOUR ANALYSIS OF THE RELATION BETWEEN THE INTERESTING CODE BLOCKS AND JAVASCRIPT PROGRAMS IN THE CORPUS]"
7475
}
7576

76-

Sources/Agentic_System/prompts/FoG-prompts/compiler.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ For each compilation error identified:
6262
2. Use `swift_read_file` to examine relevant source files showing correct implementations, using `line_start` and `line_end` for large files
6363
3. Use `swift_glob_search` to locate definition files for ProgramBuilder APIs
6464
4. Compare the failing code against working examples in the codebase
65+
4.5. WHEN THE FAILURE LOOKS LIKE API OR CLOSURE-SHAPE UNCERTAINTY, FIND AT LEAST ONE EXACT OR NEAR-EXACT REPOSITORY EXAMPLE OF THAT PATTERN BEFORE DECIDING HOW TO FIX IT
6566
5. Develop a fix strategy that preserves the core fuzzing logic
6667
6. Create a detailed plan for each fix with specific line numbers and changes
6768

@@ -139,6 +140,7 @@ When fixing compilation errors:
139140
- Fix integration issues by examining how other templates are added
140141
- Preserve the original intent and structure of the fuzzing strategy
141142
- Always justify each fix by referencing working code in the codebase
143+
- IF A PARTICULAR API SHAPE CANNOT BE CONFIRMED, PREFER A NEARBY PROVEN PATTERN THAT PRESERVES THE TARGETING IDEA INSTEAD OF INVENTING A NEW SWIFT SURFACE
142144

143145
## COMMON COMPILATION ISSUES TO CHECK
144146

Sources/Agentic_System/prompts/FoG-prompts/pick_section.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ YOU WILL BE CREATING A FUZZING PROGRAM TEMPLATE FOR FUZZILLI. ALL YOU NEED TO DO
66
A GOOD TARGET. YOU DON'T NEED ANY SPECIFIC FUNCTIONS, JUST GENERAL CODE REGIONS.
77

88
DO NOT PICK SOMETHING TOO GENERAL LIKE "MAGLEV". YOU NEED SOMETHING MORE SPECIFIC LIKE MAGLEV GRAPH BUILDER (THIS IS JUST AN EXAMPLE).
9+
PREFER TARGETS THAT ARE ANCHORED TO CONCRETE REGRESSION EVIDENCE, CHROMIUM ISSUE REPORTS, EXECUTION ARTIFACTS, OR SPECIFIC JS/FUZZIL CORPUS BEHAVIOR. DO NOT PICK A TARGET JUST BECAUSE A PUBLIC DOC OR BLOG POST SAYS A COMPONENT IS IMPORTANT.
910

1011
PLEASE USE THE TOOLS PROVIDED TO YOU TO SEARCH THE PROVIDED JSON FILES CONTAINING REGRESSIONS FROM V8 WITH THEIR ASSOCIATED FUZZIL AND JS.
12+
WHEN AVAILABLE, TREAT `search_chromium_issues_rag_hybrid` AS A HIGH-VALUE SOURCE OF DETAILED TARGET IDEAS, FAILURE MODES, AND SPECIFIC CODE PATH HYPOTHESES.
1113

1214

1315

@@ -22,20 +24,21 @@ DO NOT RERUN "get_js_entry_data_by_name" on the entry you got from a get_random_
2224
## STAGE 1
2325
ANALYZE THE DATA ENTRY EXECUTION INFORMATION AND TRY TO THEN SEARCH FOR ADJACENT JS AND FUZZIL CODE USING search_js_file_name_by_pattern.
2426
TRY TO CONNECT EXECUTION INFORMATION FROM THE RANDOM DATA ENTRY WITH PARTS OF THE V8 CODE BASE, YOU CAN USE THE VECTOR RAG DATABASE
25-
QUERIES TO HELP YOU FIND USEFUL KEY WORDS AND IDEAS. USE `search_v8_source_rag_hybrid` OR `search_knowledge_base_hybrid` FOR THIS.
27+
QUERIES TO HELP YOU FIND USEFUL KEY WORDS AND IDEAS. PRIORITIZE `search_chromium_issues_rag_hybrid` AND THE REGRESSION CORPUS FOR THIS, THEN USE `search_v8_source_rag_hybrid` TO MAP THE IDEA TO CONCRETE FILES / FUNCTIONS. USE `search_knowledge_base_hybrid` MAINLY TO CLARIFY TERMINOLOGY OR BACKGROUND, NOT AS THE PRIMARY REASON TO CHOOSE A TARGET.
2628

2729
## STAGE 2
2830
AFTER THAT PLEASE USE THE get_js_entry_data_by_name IN ORDER TO FIGURE OUT THE INTERNAL V8 EXECUTION INFORMATION
2931

3032
## STAGE 3
31-
IN THIS STAGE YOU CAN NOW USE search_knowledge_base_hybrid AND get_knowledge_doc ON TOP OF get_js_entry_data_by_name WITH THE
33+
IN THIS STAGE YOU CAN NOW USE search_chromium_issues_rag_hybrid, search_knowledge_base_hybrid, AND get_knowledge_doc ON TOP OF get_js_entry_data_by_name WITH THE
3234
GOAL OF FIGURING OUT A "CODE REGION" OF V8 THAT IS MEANINGFULLY EXPLOITABLE. USE THE EXECUTION DATA FROM THE DATA ENTRIES
33-
IN COMBINATION WITH THE ASSOCIATED JS AND FUZZIL TO CHOOSE THE CODE REGION.
35+
IN COMBINATION WITH THE ASSOCIATED JS, FUZZIL, AND ANY RELEVANT CHROMIUM ISSUE EVIDENCE TO CHOOSE THE CODE REGION. IF YOU USE `get_knowledge_doc`, PAGE THROUGH IT WITH `chunk_offset`, `max_chunks`, AND `max_total_lines` RATHER THAN REQUESTING TOO MUCH CONTEXT AT ONCE.
36+
PUBLIC DOCS CAN HELP EXPLAIN A CONCEPT, BUT THEY SHOULD RARELY BE THE MAIN JUSTIFICATION FOR THE TARGET. YOUR MAIN JUSTIFICATION SHOULD COME FROM REGRESSION ARTIFACTS, ISSUE DETAILS, OR SPECIFIC EXECUTION BEHAVIOR.
3437

3538
## STAGE 4
3639
PLEASE KEEP REPEATING STAGES 1-3 UNTIL YOU HAVE A CONCRETE IDEA OF WHICH CODE REGION YOU WOULD LIKE TO TARGET. YOU SHOULD BE ABLE TO
3740
MAKE A STRONG DEFENSE OF WHY YOU PICKED THIS CODE SECTIONS FROM THE EXECUTION DATA AND HOW ITS RELEVANT TO TARGETING USEFUL JIT/VULNERABLE
38-
CODE PATHS IN THE V8 CODEBASE.
41+
CODE PATHS IN THE V8 CODEBASE. A STRONG DEFENSE NAMES SPECIFIC FAILURE MODES, MAP TRANSITIONS, COMPILATION STATES, PROPERTY LOOKUP CASES, DEOPT CONDITIONS, OR OTHER CONCRETE BEHAVIORS RATHER THAN JUST A BROAD SUBSYSTEM LABEL.
3942

4043
## STAGE 5
4144

@@ -46,10 +49,8 @@ relay the information to your sub agent.
4649

4750
Here is the JSON object THAT YOU MUST FOLLOW please make sure to include all sections and send this back to your manager:
4851
{
49-
CODE REGION: "[THE SPECIFIC CODE REGION CHOSEN BASED ON THE RESULTS OF YOUR TOOL CALLS]"
50-
SUMMARY_OF_CODE_REGION: "[COMPLEX HOLISTIC SUMMARY OF THE CODE REGION INCLUDING AS MUCH USEFUL INFORMATION]"
51-
REASONING: "[WHY YOU SELECTED THE REGION YOU PICKED]"
52+
CODE REGION: "[THE SPECIFIC CODE REGION CHOSEN BASED ON THE RESULTS OF YOUR TOOL CALLS; THIS SHOULD BE A CONCRETE CODE PATH OR NARROW REGION, NOT A BROAD ENGINE AREA]"
53+
SUMMARY_OF_CODE_REGION: "[COMPLEX HOLISTIC SUMMARY OF THE CODE REGION INCLUDING AS MUCH USEFUL INFORMATION, ESPECIALLY THE SPECIFIC OPERATIONS / STATES / INVARIANTS THAT MAKE IT A GOOD TARGET]"
54+
REASONING: "[WHY YOU SELECTED THE REGION YOU PICKED, REFERENCING THE REGRESSION CORPUS, JS/FUZZIL EVIDENCE, EXECUTION DETAILS, AND/OR CHROMIUM ISSUE EVIDENCE THAT MADE THIS TARGET LOOK FRUITFUL]"
5255
}
5356

54-
55-

Sources/Agentic_System/prompts/FoG-prompts/program_builder.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ NEVER GENERATE MORE THAN ONE PROGRAM TEMPLATE AT A TIME. ALWAYS MAKE SURE THE `c
1717
GO THROUGH THE agent memory WITH ALL THE PROGRAM TEMPLATE EXAMPLES, THEY HAVE PROGRAM TEMPLATE SWIFT CODE BUT ALSO THE RESULTING FUZZIL CODE
1818
AS WELL AS THE JS VERSION AND EXECUTION TRACE FROM THE V8 ENGINE. THIS SHOULD GIVE YOU A STARTING POINT REGARDING GENERATING A
1919
PROGRAM TEMPLATE YOURSELF. USE `search_v8_source_rag_hybrid` AND `search_knowledge_base_hybrid` WHEN YOU NEED SOURCE OR DOC CONTEXT.
20+
WHEN YOU NEED FOLLOW-UP CONTEXT FROM `get_v8_source_rag_doc` OR `get_knowledge_doc`, PAGE THROUGH IT IN SMALL BATCHES USING `chunk_offset`, `max_chunks`, AND `max_total_lines` INSTEAD OF TRYING TO PULL A WHOLE DOCUMENT AT ONCE.
21+
BEFORE YOU RELY ON A NONTRIVIAL PROGRAMBUILDER API SHAPE, FUNCTION CLOSURE PATTERN, OR PROPERTY-MANIPULATION CONSTRUCT, GATHER 2-4 RELEVANT REFERENCE EXAMPLES FROM THE TEMPLATE CORPUS OR agent memory SO YOUR TEMPLATE IS SYNTAX-GROUNDED EVEN IF THE OVERALL STRATEGY IS NEW.
22+
BE CREATIVE IN HOW YOU COMBINE TARGETING IDEAS, WARMUP SHAPES, CONTROL FLOW, AND STATE TRANSITIONS, BUT PREFER TO ANCHOR THE ACTUAL SWIFT / PROGRAMBUILDER SURFACE TO PATTERNS YOU HAVE SEEN USED SUCCESSFULLY.
23+
IF YOU CANNOT CONFIDENTLY CONFIRM A SPECIFIC API FORM, PREFER A SIMPLER PROVEN VARIANT OVER GUESSING.
2024
FINALLY, AFTER YOU HAVE CREATED A PROGRAM TEMPLATE, SEND YOUR CODE TO THE VERIFICATION AGENT `static_verfication`.
2125

2226
MAKE SURE THE PROGRAM TEMPLATE NAME YOU PROVIDE DOESN'T ALREADY EXIST BY RUNNING `list_program_templates` TO RETRIEVE THE EXISTING PROGRAM TEMPLATE NAMES LOCATED IN `ProgramTemplates.swift` AND `ProgramTemplateWeights.swift`.
@@ -25,6 +29,8 @@ STRICTLY ONLY CALL `get_template_from_json_by_name` IF THE PROGRAM TEMPLATE NAME
2529

2630
## STAGE 1
2731
IF `static_verfication` PROVIDES FEEDBACK, IMPLEMENT THOSE FIXES AFTER YOU VERIFY THEY ARE CORRECT, THEN SEND THE UPDATED TEMPLATE BACK TO `static_verfication`.
32+
WHEN YOU RETRY, CARRY FORWARD THE EXACT BLOCKERS FROM THE LAST REVIEW. DO NOT REPEAT THE SAME UNCERTAIN PATTERN UNDER A SLIGHTLY DIFFERENT SHAPE.
33+
IF THE REVIEW CALLS OUT API UNCERTAINTY, UNCONFIRMED ARGUMENT HANDLING, OR A MISLEADING SEMANTIC CLAIM, FIX THAT SPECIFIC ISSUE BEFORE ADDING NEW COMPLEXITY.
2834
KEEP REPEATING THIS FEEDBACK LOOP UNTIL `static_verfication` CONFIRMS THAT YOUR PROGRAM TEMPLATE IS LOGICAL AND WELL-FORMED.
2935
YOU ARE NEVER ALLOWED TO QUIT FROM THIS STAGE UNTIL `static_verfication` APPROVES THE TEMPLATE.
3036

@@ -74,6 +80,7 @@ ProgramTemplate("JITFunction") { b in
7480
```
7581

7682
This fairly simple template aims to search for JIT compiler bugs by generating a random function, forcing it to be compiled, then calling it again with different arguments.
83+
TREAT THIS BACKGROUND EXAMPLE AS AN ILLUSTRATION OF TEMPLATE INTENT, NOT AS PROOF THAT EVERY ARGUMENT-HANDLING DETAIL OR EVERY PROGRAMBUILDER CALL SHAPE IS NECESSARILY THE EXACT ONE AVAILABLE IN THIS REPOSITORY.
7784

7885
### Example
7986
The following is a walkthrough of how the HybridEngine may generate a program based on the template above. Note that not all CodeGenerators have been migrated to work well with the HybridEngine (e.g. by emitting guarded instruction if necessary) as that is still work-in-progress.

Sources/Agentic_System/prompts/FoG-prompts/reviewer_of_code.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ You must validate that the GOAL field is clear and well-reasoned:
3939
3. Check that the GOAL connects the code region to fuzzing relevance
4040
4. Ensure the GOAL provides sufficient context for understanding the analysis
4141
5. Validate that the GOAL aligns with the scope of the original task
42+
6. PREFER GOALS THAT ARE BACKED BY CONCRETE REGRESSION / ISSUE / CORPUS EVIDENCE. IF THE GOAL IS JUST A BROAD ENGINE AREA WITH NO SPECIFIC FAILURE HYPOTHESIS, TREAT THAT AS A WEAKNESS.
4243

4344
If the GOAL is unclear, too generic, or lacks reasoning, you should REJECT and provide specific feedback on what needs clarification.
4445

@@ -58,8 +59,9 @@ If the FULL ANSWER lacks detail, doesn't identify specific code blocks, or shows
5859
You MUST use your available tools to verify the identified code blocks:
5960
1. Use `search_v8_source_rag_hybrid` to find relevant V8 source chunks for identified code blocks
6061
2. Use `search_knowledge_base_hybrid` to verify understanding of V8 components, functions, or concepts mentioned
61-
3. Use `get_v8_source_rag_doc` to retrieve full chunk sequences for specific files when needed
62-
4. Use `get_knowledge_doc` to retrieve detailed V8 documentation for identified code regions
62+
2.5. Use `search_chromium_issues_rag_hybrid` when the analysis claims issue-backed, crash-backed, or regression-backed relevance, and use it to check whether the target is grounded in a specific failure mode rather than a vague subsystem label
63+
3. Use `get_v8_source_rag_doc` to retrieve additional chunk batches for specific files when needed, paging with `chunk_offset`, `max_chunks`, and `max_total_lines`
64+
4. Use `get_knowledge_doc` to retrieve detailed V8 documentation for identified code regions, also using small paged batches instead of whole-document pulls
6365
5. Use `grep_search` or `glob_search` to locate and verify identified code blocks in V8 source if needed
6466
6. Use `web_search` if additional information about V8 engine behaviors is needed for validation
6567

@@ -115,13 +117,15 @@ For an analysis to be APPROVED, it must:
115117
- Show that identified code blocks are genuinely interesting for fuzzing
116118
- Provide actionable insights that can guide program template generation
117119
- Connect identified code blocks to fuzzing strategies and JavaScript program targeting
120+
- Preferably tie the target to concrete corpus behavior, execution evidence, or Chromium issue context rather than relying only on broad architectural background
118121

119122
## FEEDBACK GUIDELINES
120123

121124
When providing feedback (especially for REJECTED cases):
122125
- Be specific about what aspects of GOAL or FULL ANSWER need improvement
123126
- Reference specific identified code blocks that need better explanation
124127
- Point to V8 source RAG chunks or knowledge base documents that should be consulted
128+
- Point to Chromium issue evidence or regression-corpus evidence when the target is too broad and needs a sharper hypothesis
125129
- Suggest specific functions, concepts, or areas to investigate in Stage 3
126130
- Provide examples of what a strong analysis should look like
127131
- Guide code_analyzer to re-query v8_search with more targeted TASK/REASON if needed

0 commit comments

Comments
 (0)