Skip to content

Commit a800d1e

Browse files
Refactor PatchManager and enhance validation infrastructure
- Refactored `PatchManager` to reduce complexity and improve readability. - Implemented `RollbackManager` for Git-based safe patching and rollback capabilities. - Added `SandboxValidator` for isolated code validation (syntax, tests). - Enhanced `PatchManager` with fuzzy matching (Exact, Semantic) and text-based replacement driven by AST location to preserve comments. - Updated `JulesBridge` to include `extract_patch_context` helper. - Added comprehensive tests for new functionalities.
1 parent de74c83 commit a800d1e

File tree

5 files changed

+702
-86
lines changed

5 files changed

+702
-86
lines changed

codesage/governance/jules_bridge.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22
import os
33
from pydantic import BaseModel
4-
from typing import Optional, List, Tuple
4+
from typing import Optional, List, Tuple, Dict
55

66
from codesage.config.jules import JulesPromptConfig
77
from codesage.governance.task_models import GovernanceTask
@@ -96,3 +96,26 @@ def build_view_and_template_for_task(
9696
template = get_template_for_rule(task.rule_id, task.language)
9797

9898
return view, template
99+
100+
class JulesBridge:
101+
def extract_patch_context(self, jules_suggestion: Dict) -> Dict:
102+
"""
103+
Extracts patch context from Jules' suggestion.
104+
105+
Args:
106+
jules_suggestion: {
107+
"issue_id": "...",
108+
"suggested_fix": {
109+
"function": "calculate_risk",
110+
"location": {"file": "...", "line": 45},
111+
"new_code": "...",
112+
"context_snippet": "..."
113+
}
114+
}
115+
"""
116+
fix = jules_suggestion.get("suggested_fix", {})
117+
return {
118+
"function_name": fix.get("function"),
119+
"line_number": fix.get("location", {}).get("line"),
120+
"code_snippet": fix.get("context_snippet")
121+
}

0 commit comments

Comments
 (0)