lexicalspace commited on
Commit
d67baa1
·
verified ·
1 Parent(s): 5a646ef

Upload 2 files

Browse files
phases/phase5_ai_review.py CHANGED
@@ -1,2 +1,39 @@
1
- def summarize():
2
- return "Artifacts ready for AI reasoning (external or local LLM)"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+
4
+ def ai_review(llm_callable=None):
5
+ """
6
+ llm_callable(text) -> text
7
+ """
8
+ if not llm_callable:
9
+ return "LLM disabled. Skipping AI review."
10
+
11
+ rules = json.load(open("artifacts/normalized_rules.json"))
12
+ findings = json.load(open("artifacts/rule_findings.json"))
13
+
14
+ prompt = f"""
15
+ You are a rule–code auditor.
16
+
17
+ RULES:
18
+ {json.dumps(rules, indent=2)}
19
+
20
+ FINDINGS:
21
+ {json.dumps(findings, indent=2)}
22
+
23
+ TASK:
24
+ - For each rule ID, classify:
25
+ COMPLIANT / VIOLATED / PARTIAL / UNKNOWN
26
+ - Cite evidence
27
+ - Never invent issues
28
+ - If runtime limits enforcement, say so
29
+
30
+ OUTPUT:
31
+ Markdown report.
32
+ """
33
+
34
+ report = llm_callable(prompt)
35
+
36
+ with open("artifacts/final_report.md", "w", encoding="utf-8") as f:
37
+ f.write(report)
38
+
39
+ return "AI review complete"
phases/phase6_patch.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from analyzers.patch_generator import generate_patch
3
+
4
+ def create_patches():
5
+ """
6
+ Placeholder: human or AI supplies fixed snippets
7
+ """
8
+ findings = json.load(open("artifacts/rule_findings.json"))
9
+
10
+ patches = []
11
+ for f in findings:
12
+ if f["status"] == "VIOLATED":
13
+ patches.append({
14
+ "rule": f["rule"],
15
+ "suggestion": "Manual or AI-assisted patch required"
16
+ })
17
+
18
+ with open("artifacts/patch_plan.json", "w") as f:
19
+ json.dump(patches, f, indent=2)
20
+
21
+ return patches