Vitalis_Devcore / src /devcore /quad_flow_engine.py
FerrellSyntheticIntelligence
Fix architecture integration: remove duplicate mind class, add LFM-backed embeddings, wire SovereignLFMBridge with chat/process/generate
a1365f7
Raw
History Blame Contribute Delete
3.59 kB
import logging
from src.devcore.vitalis_cognitive_engine import VitalisCognitiveEngine
from src.cognition.working_memory import WorkingMemory
from src.cognition.predictive_engine import PredictiveEngine
from src.dream_engine.synthetic_helix import SyntheticHelixMemory
from vitalis_ide.math_core.kernel import VitalisKernel
log = logging.getLogger('QuadFlow')
class NexusHead:
def __init__(self):
self.kernel = VitalisKernel()
self.wm = WorkingMemory()
self.predictor = PredictiveEngine()
self.helix = SyntheticHelixMemory()
def pre(self, intent, mind_state):
resonance_w = {
k: v for k, v in
mind_state.get('resonance', {}).get('strongest', [])
}
prediction = self.predictor.predict_next(
intent,
mind_state.get('meta_rules', {}),
resonance_w,
)
if prediction.get('predicted_next'):
self.predictor.anticipate(prediction, self.wm)
vec = self.kernel.vectorize_tokens(intent.split(), positional=False)
self.wm.push(intent, vec, 1.0)
return {'prediction': prediction, 'wm_context': self.wm.context(3)}
def post(self, intent, result, success):
accuracy = self.predictor.score(intent)
mode = result.get('mode', 'unknown')
conf = result.get('confidence', 0.0)
status = 'success' if success else 'fail'
meaning = status + ' mode=' + mode + ' conf=' + str(round(conf, 3))
self.helix.encode(event=intent, meaning=meaning)
return {'accuracy': accuracy}
def report(self):
return {
'working_memory': self.wm.report(),
'predictor': self.predictor.report(),
'helix': self.helix.report(),
}
class NeurosynthticQuadFlowEngine(VitalisCognitiveEngine):
def __init__(self):
super().__init__()
self.nexus = NexusHead()
print('')
print(' ╔══════════════════════════════════════╗')
print(' β•‘ NEUROSYNTHETIC QUAD FLOW ENGINE β•‘')
print(' β•‘ Sensu | Ratio | Cor | Nexus β•‘')
print(' β•‘ WorkingMem + Foresight + Helix β•‘')
print(' β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•')
print('')
def think_and_act(self, intent, token, **kwargs):
if not self.auth.validate_request(token):
return {'success': False, 'error': 'UNAUTHORIZED'}
from src.cognition.mind import VitalisMind, _extend_mind
mind = VitalisMind()
ms = mind.introspect()
pre = self.nexus.pre(intent, ms)
predicted = pre['prediction'].get('predicted_next', '?')
wm_ctx = pre['wm_context']
log.info('[NEXUS] Predicted: ' + str(predicted))
log.info('[NEXUS] WM: ' + str(wm_ctx))
result = super().think_and_act(intent, token, **kwargs)
post = self.nexus.post(intent, result, result.get('success', False))
result['nexus'] = {
'predicted_next': predicted,
'wm_context': wm_ctx,
'prediction_accuracy': post['accuracy'],
}
return result
def status(self):
return {
'engine': 'NeurosynthticQuadFlowEngine v2.1',
'heads': ['Sensu', 'Ratio', 'Cor', 'Nexus'],
'nexus': self.nexus.report(),
}