Skip to main content

agentic_evolve_core/
bridges.rs

1//! Sister integration bridge traits for AgenticEvolve.
2
3/// Bridge to agentic-memory for linking patterns to memory nodes.
4pub trait MemoryBridge: Send + Sync {
5    fn link_pattern_to_memory(&self, pattern_id: &str, node_id: u64) -> Result<(), String> {
6        let _ = (pattern_id, node_id);
7        Err("Memory bridge not connected".to_string())
8    }
9
10    fn query_related_memories(&self, pattern_name: &str, max_results: usize) -> Vec<String> {
11        let _ = (pattern_name, max_results);
12        Vec::new()
13    }
14}
15
16/// Bridge to agentic-codebase for code-aware pattern operations.
17pub trait CodebaseBridge: Send + Sync {
18    fn find_similar_code(&self, signature: &str, max_results: usize) -> Vec<String> {
19        let _ = (signature, max_results);
20        Vec::new()
21    }
22
23    fn validate_pattern_against_codebase(&self, pattern_template: &str) -> Result<bool, String> {
24        let _ = pattern_template;
25        Ok(true)
26    }
27}
28
29/// Bridge to agentic-identity for signing patterns.
30pub trait IdentityBridge: Send + Sync {
31    fn sign_pattern(&self, pattern_id: &str, content_hash: &str) -> Result<String, String> {
32        let _ = (pattern_id, content_hash);
33        Err("Identity bridge not connected".to_string())
34    }
35
36    fn verify_pattern_signature(&self, pattern_id: &str, signature: &str) -> bool {
37        let _ = (pattern_id, signature);
38        true
39    }
40}
41
42/// Bridge to agentic-contract for pattern usage policies.
43pub trait ContractBridge: Send + Sync {
44    fn check_pattern_policy(&self, pattern_id: &str, operation: &str) -> Result<bool, String> {
45        let _ = (pattern_id, operation);
46        Ok(true)
47    }
48}
49
50/// Bridge to agentic-cognition for reasoning about patterns.
51pub trait CognitionBridge: Send + Sync {
52    fn reason_about_match(&self, pattern_id: &str, context: &str) -> Option<f64> {
53        let _ = (pattern_id, context);
54        None
55    }
56}
57
58/// No-op implementation of all bridges for standalone use.
59#[derive(Debug, Clone, Default)]
60pub struct NoOpBridges;
61
62impl MemoryBridge for NoOpBridges {}
63impl CodebaseBridge for NoOpBridges {}
64impl IdentityBridge for NoOpBridges {}
65impl ContractBridge for NoOpBridges {}
66impl CognitionBridge for NoOpBridges {}
67
68/// Configuration for which bridges are active.
69#[derive(Debug, Clone, Default)]
70pub struct BridgeConfig {
71    pub memory_enabled: bool,
72    pub codebase_enabled: bool,
73    pub identity_enabled: bool,
74    pub contract_enabled: bool,
75    pub cognition_enabled: bool,
76}
77
78/// Hydra adapter trait for orchestrator integration.
79pub trait HydraAdapter: Send + Sync {
80    fn adapter_id(&self) -> &str;
81    fn capabilities(&self) -> Vec<String>;
82    fn handle_request(&self, method: &str, params: &str) -> Result<String, String>;
83}