Add core agent: main_pipeline.py
Browse files- main_pipeline.py +64 -0
main_pipeline.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import time
|
| 3 |
+
from typing import Dict, Any
|
| 4 |
+
|
| 5 |
+
from agents.vision_forensics import VisionForensicsAgent
|
| 6 |
+
from agents.graph_navigator import GraphNavigator
|
| 7 |
+
from agents.logic_auditor import LogicAuditor
|
| 8 |
+
from privacy_filter.local_slm_scrubber import LocalSLMScrubber
|
| 9 |
+
from core.mcp_protocol import mcp_call
|
| 10 |
+
|
| 11 |
+
class AegisGraphEngine:
|
| 12 |
+
"""
|
| 13 |
+
The High-Authority Orchestrator for Aegis-Graph.
|
| 14 |
+
Now 100% MCP-Native with verifiable reasoning traces.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
def __init__(self):
|
| 18 |
+
self.vision = VisionForensicsAgent()
|
| 19 |
+
self.navigator = GraphNavigator()
|
| 20 |
+
self.auditor = LogicAuditor()
|
| 21 |
+
self.scrubber = LocalSLMScrubber()
|
| 22 |
+
|
| 23 |
+
async def execute_audit(self, file_path: str) -> Dict[str, Any]:
|
| 24 |
+
# MCP Handshake
|
| 25 |
+
kernel_call = mcp_call("mcp_kernel_init", {"session_type": "sovereign_audit"})
|
| 26 |
+
|
| 27 |
+
print("\n" + ">>>" * 3 + f" INITIALIZING AEGIS-GRAPH [Trace: {kernel_call.trace_id[:8]}] " + "<<<" * 3)
|
| 28 |
+
print("-" * 60)
|
| 29 |
+
|
| 30 |
+
# 1. Vision Forensics (MCP: mcp_vision_analyze)
|
| 31 |
+
mcp_call("mcp_vision_analyze", {"uri": file_path})
|
| 32 |
+
raw_transcript = await self.vision.analyze(file_path)
|
| 33 |
+
|
| 34 |
+
# 2. Local Privacy Scrubbing (Shield)
|
| 35 |
+
print("[SHIELD] Applying local NPU mask to PII data...")
|
| 36 |
+
masked_name = self.scrubber.scrub(raw_transcript.institution_name)
|
| 37 |
+
|
| 38 |
+
# 3. Graph Navigation (MCP: mcp_resolve_ror)
|
| 39 |
+
mcp_call("mcp_resolve_ror", {"query": masked_name})
|
| 40 |
+
inst_profile = await self.navigator.navigate(raw_transcript.institution_name)
|
| 41 |
+
|
| 42 |
+
# 4. Deep Logic Audit (MCP: mcp_logic_audit)
|
| 43 |
+
mcp_call("mcp_logic_audit", {"cot": True})
|
| 44 |
+
resolution = await self.auditor.audit(raw_transcript.dict(), inst_profile.dict())
|
| 45 |
+
|
| 46 |
+
print("-" * 60)
|
| 47 |
+
print(f"REPORT: FINAL VERDICT: {resolution.verdict}")
|
| 48 |
+
print(f"REPORT: RISK SCORE: {resolution.risk_score:.1f}")
|
| 49 |
+
print(f"REPORT: TRACE ID: {resolution.mcp_trace}")
|
| 50 |
+
print("-" * 60)
|
| 51 |
+
|
| 52 |
+
return {
|
| 53 |
+
"verdict": resolution.verdict,
|
| 54 |
+
"risk_score": resolution.risk_score,
|
| 55 |
+
"trace_id": resolution.mcp_trace,
|
| 56 |
+
"reasoning": resolution.reasoning_steps
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
if __name__ == "__main__":
|
| 60 |
+
# Internal kernel test
|
| 61 |
+
async def main():
|
| 62 |
+
engine = AegisGraphEngine()
|
| 63 |
+
await engine.execute_audit("aclas_demo.pdf")
|
| 64 |
+
asyncio.run(main())
|