Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/continuum-cognition/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub use continuum_live::*;
pub use continuum_genome::genome;
pub use continuum_memory::memory;
pub use continuum_experience::{experience, recipe};
pub use continuum_perception::{perception, rag};
pub use continuum_perception::perception;

pub mod cognition;
pub mod commands;
1 change: 0 additions & 1 deletion core/continuum-core/src/ipc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use crate::modules::vision::VisionModule;
/// - Modular runtime routes commands through ServiceModule trait (Phase 1+)
use crate::persona::ChannelRegistry;
use crate::cognition::conversation::types::PersonaState;
use crate::rag::RagEngine;
use crate::runtime::{CommandResult, Runtime};
use crate::system_resources::SystemResourceMonitor;
use crate::{log_debug, log_error, log_info};
Expand Down
3 changes: 0 additions & 3 deletions core/continuum-core/src/ipc/prepare_unix_socket_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ pub(super) struct ServerState {
pub(super) voice_service: Arc<crate::live::session::voice_service::VoiceService>,
/// Per-persona channel registries + state — DashMap: hot-path ops are &mut self.
pub(super) channel_registries: Arc<DashMap<Uuid, (ChannelRegistry, PersonaState)>>,
pub(super) rag_engine: Arc<RagEngine>,
/// Server-side audio buffer pool for handle-based synthesis.
pub(super) audio_pool: Arc<crate::live::audio::buffer::AudioBufferPool>,
/// Tokio runtime handle for async operations from IPC threads.
Expand Down Expand Up @@ -108,7 +107,6 @@ impl ServerState {
memory_manager: Arc<crate::memory::PersonaMemoryManager>,
runtime: Arc<Runtime>,
channel_registries: Arc<DashMap<Uuid, (ChannelRegistry, PersonaState)>>,
rag_engine: Arc<RagEngine>,
voice_service: Arc<crate::live::session::voice_service::VoiceService>,
audio_pool: Arc<crate::live::audio::buffer::AudioBufferPool>,
file_engines: Arc<DashMap<String, FileEngine>>,
Expand All @@ -120,7 +118,6 @@ impl ServerState {
Self {
voice_service,
channel_registries,
rag_engine,
audio_pool,
rt_handle,
memory_manager,
Expand Down
2 changes: 0 additions & 2 deletions core/continuum-core/src/ipc/start_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ pub fn start_server(
inference_modules::register_inference_modules(&runtime);

let cognition_modules::CognitionHandles {
rag_engine,
channel_registries,
} = cognition_modules::register_cognition_and_memory_modules(
&runtime,
Expand Down Expand Up @@ -264,7 +263,6 @@ pub fn start_server(
memory_manager,
runtime,
channel_registries,
rag_engine,
call_plane.voice_service,
audio_pool,
file_engines,
Expand Down
7 changes: 2 additions & 5 deletions core/continuum-core/src/ipc/start_server/cognition_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

use super::*;

/// The two handles the IPC server state shares with these modules.
/// The handle the IPC server state shares with these modules.
pub(super) struct CognitionHandles {
pub(super) rag_engine: Arc<RagEngine>,
pub(super) channel_registries: Arc<DashMap<Uuid, (ChannelRegistry, PersonaState)>>,
}

Expand All @@ -16,9 +15,8 @@ pub(super) fn register_cognition_and_memory_modules(
serving_daemon: &Arc<crate::modules::serving_daemon::ServingDaemonModule>,
) -> CognitionHandles {
// Shared state for per-persona cognition (unified: engine + inbox + rate limiter + sleep + adapters + genome)
let rag_engine = Arc::new(RagEngine::new());
let cognition_state =
Arc::new(CognitionState::new(rag_engine.clone()).with_gpu_manager(gpu_manager.clone()));
Arc::new(CognitionState::new().with_gpu_manager(gpu_manager.clone()));
let personas = cognition_state.personas.clone();
runtime.register(Arc::new(CognitionModule::new(cognition_state)));

Expand Down Expand Up @@ -51,7 +49,6 @@ pub(super) fn register_cognition_and_memory_modules(
let rag_state = Arc::new(RagState::new(memory_manager.clone()));
runtime.register(Arc::new(RagModule::new(rag_state)));
CognitionHandles {
rag_engine,
channel_registries,
}
}
3 changes: 1 addition & 2 deletions core/continuum-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use continuum_engine::{ai, capacity, inference, inference_capability, model_
pub use continuum_hands::code;
pub use continuum_live::{live, media};
pub use continuum_mind::{
cognition, context, experience, genome, memory, perception, persona, rag, recipe, vdd,
cognition, context, experience, genome, memory, perception, persona, recipe, vdd,
};
pub use continuum_kernel::{
concurrency, docker_tier, docker_tier_pool, entity_schemas, governor, gpu, identity, logging, orm,
Expand Down Expand Up @@ -60,4 +60,3 @@ pub use persona::{CognitionDecision, PersonaCognitionEngine, PersonaInbox, Prior
// Usage: clog_info!("Session started"); clog_warn!("Warning"); etc.
pub use ipc::start_server;
pub use logging::{extract_component, module_path_to_category};
pub use rag::{LlmMessage, MessageRole, RagContext, RagEngine, RagOptions};
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ use continuum_core::persona::message_cache::RecentMessageCache;
use continuum_core::cognition::conversation::persona_identity::PersonaIdentity;
use continuum_core::cognition::conversation::types::{PersonaState, SenderType};
use continuum_core::persona::{analyze_burst, BurstEvaluateResult, RateLimiterState, SleepState};
use continuum_core::rag::RagEngine;

fn make_chat(room: Uuid, sender: &str, content: &str) -> Arc<dyn QueueItemBehavior> {
Arc::new(ChatQueueItem {
Expand Down Expand Up @@ -114,9 +113,8 @@ impl PersonaHarness {
fn new(name: &str) -> Self {
let persona_id = Uuid::new_v4();
let identity = PersonaIdentity::new(persona_id, name);
let rag_engine = Arc::new(RagEngine::new());
let (_tx, rx) = tokio::sync::watch::channel(false);
let engine = PersonaCognitionEngine::new(persona_id, name.into(), rag_engine, rx);
let engine = PersonaCognitionEngine::new(persona_id, name.into(), rx);
Self {
persona_id,
identity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ crate::action_command! {
let cognition = PersonaCognition::new(
p.persona_id,
p.persona_name.clone(),
this.state.rag_engine.clone(),
);
this.state.personas.insert(p.persona_id, cognition);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ mod tests {
use crate::cognition::workspace::TurnMetrics;
use crate::persona::PersonaCognition;
use crate::cognition::conversation::types::{InboxMessage, Modality, SenderType};
use crate::rag::RagEngine;
use crate::sdk_codegen::{AccessLevel, ActionCommand, Ctx};

// Build a TurnExecute command over a fresh CognitionState carrying one live persona
Expand All @@ -347,11 +346,10 @@ mod tests {
// (that needs a real adapter + model). So a turn WITH messages here exercises the
// not-hosted fail-loud path; the real settle_step outcome is validated live via `uu`.
fn command_with_persona(persona_id: Uuid) -> (TurnExecute, Arc<CognitionState>) {
let rag_engine = Arc::new(RagEngine::new());
let state = Arc::new(CognitionState::new(rag_engine.clone()));
let state = Arc::new(CognitionState::new());
state.personas.insert(
persona_id,
PersonaCognition::new(persona_id, "Test Persona".to_string(), rag_engine),
PersonaCognition::new(persona_id, "Test Persona".to_string()),
);
(
TurnExecute {
Expand Down Expand Up @@ -410,8 +408,7 @@ mod tests {
// BEFORE touching the brain — idle ticks are routine, never a caller error.
#[tokio::test]
async fn absent_persona_is_noop_not_error() {
let rag_engine = Arc::new(RagEngine::new());
let state = Arc::new(CognitionState::new(rag_engine));
let state = Arc::new(CognitionState::new());
let cmd = TurnExecute { state };

let out = cmd
Expand Down
2 changes: 1 addition & 1 deletion core/continuum-mind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub use continuum_live::*;
pub use continuum_genome::genome;
pub use continuum_memory::memory;
pub use continuum_experience::{experience, recipe};
pub use continuum_perception::{perception, rag};
pub use continuum_perception::perception;

pub use continuum_academy::cognition;
pub mod activity;
Expand Down
20 changes: 10 additions & 10 deletions core/continuum-mind/src/modules/cognition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use crate::gpu::GpuMemoryManager;
use continuum_text_analysis::LoopDetector;
use crate::persona::{PersonaCognition, PersonaInboxFrame, PersonaTurnFrame, PersonaTurnFrameReplayRecord};
use crate::rag::RagEngine;
use crate::runtime::{CommandResult, LateBound, ModuleConfig, ModuleContext, ModulePriority, ServiceModule};
use async_trait::async_trait;
use dashmap::DashMap;
Expand All @@ -50,23 +49,26 @@ use uuid::Uuid;
/// One lock acquisition gives atomic access to engine + inbox + rate limiter +
/// sleep state + adapter registry + genome engine.
///
/// `rag_engine` and `loop_detector` are shared across all personas.
/// `loop_detector` is shared across all personas.
pub struct CognitionState {
/// Unified per-persona state: 7 maps → 1.
pub personas: Arc<DashMap<Uuid, PersonaCognition>>,
/// Shared RAG engine (not per-persona).
pub rag_engine: Arc<RagEngine>,
/// Shared loop detector (not per-persona).
pub loop_detector: LoopDetector,
/// GPU memory manager — real VRAM budgets for genome paging.
pub gpu_manager: Option<Arc<GpuMemoryManager>>,
}

impl Default for CognitionState {
fn default() -> Self {
Self::new()
}
}

impl CognitionState {
pub fn new(rag_engine: Arc<RagEngine>) -> Self {
pub fn new() -> Self {
Self {
personas: Arc::new(DashMap::new()),
rag_engine,
loop_detector: LoopDetector::new(),
gpu_manager: None,
}
Expand Down Expand Up @@ -98,7 +100,7 @@ impl CognitionState {
// No lock is held across anything but the insert (a `len()` inside `or_insert_with`
// re-entered the shard lock and self-deadlocked the live core once).
self.personas.entry(persona_uuid).or_insert_with(|| {
PersonaCognition::new(persona_uuid, String::new(), self.rag_engine.clone())
PersonaCognition::new(persona_uuid, String::new())
})
}
}
Expand Down Expand Up @@ -401,7 +403,6 @@ mod turn_frame_recording_tests {
mod get_or_create_persona_locking {
use super::*;
use crate::gpu::GpuMemoryManager;
use crate::rag::RagEngine;
use std::sync::mpsc;
use std::time::Duration;

Expand All @@ -422,7 +423,6 @@ mod turn_frame_recording_tests {
fn create_with_gpu_manager_does_not_self_deadlock() {
let (done_tx, done_rx) = mpsc::channel();
std::thread::spawn(move || {
let rag = Arc::new(RagEngine::new());
let (ptx, prx) = tokio::sync::watch::channel(0.0f32);
let gpu = Arc::new(GpuMemoryManager::new_for_test(
24 * 1024 * 1024 * 1024, // total VRAM
Expand All @@ -434,7 +434,7 @@ mod turn_frame_recording_tests {
ptx,
prx,
));
let state = CognitionState::new(rag).with_gpu_manager(gpu);
let state = CognitionState::new().with_gpu_manager(gpu);
let id = Uuid::new_v4();
// First call runs the lazy-create closure (the budget read); the
// guard drops at the end of each statement, so the second call
Expand Down
12 changes: 2 additions & 10 deletions core/continuum-mind/src/persona/cognition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@

use super::inbox::PersonaInbox;
use crate::cognition::conversation::types::{InboxMessage, PersonaState, SenderType};
use crate::rag::RagEngine;
use dashmap::DashSet;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use std::time::Instant;
use tokio::sync::watch;
use tracing::debug;
Expand Down Expand Up @@ -80,8 +78,6 @@ pub struct PersonaCognitionEngine {
mention_marker: Box<str>,
state: PersonaState,
inbox: PersonaInbox,
#[allow(dead_code)] // Will be used for RAG context building
rag_engine: Arc<RagEngine>,

// Deduplication
evaluated_messages: DashSet<Uuid>,
Expand All @@ -95,7 +91,6 @@ impl PersonaCognitionEngine {
pub fn new(
persona_id: Uuid,
persona_name: String,
rag_engine: Arc<RagEngine>,
shutdown_rx: watch::Receiver<bool>,
) -> Self {
let name_lower = persona_name.to_lowercase().into_boxed_str();
Expand All @@ -106,7 +101,6 @@ impl PersonaCognitionEngine {
mention_marker,
state: PersonaState::new(),
inbox: PersonaInbox::new(persona_id),
rag_engine,
evaluated_messages: DashSet::new(),
shutdown_rx,
}
Expand Down Expand Up @@ -333,9 +327,8 @@ mod tests {
use tokio::sync::watch;

async fn create_test_engine() -> PersonaCognitionEngine {
let rag_engine = Arc::new(RagEngine::new());
let (_shutdown_tx, shutdown_rx) = watch::channel(false);
PersonaCognitionEngine::new(Uuid::new_v4(), "TestBot".into(), rag_engine, shutdown_rx)
PersonaCognitionEngine::new(Uuid::new_v4(), "TestBot".into(), shutdown_rx)
}

#[tokio::test]
Expand Down Expand Up @@ -427,10 +420,9 @@ mod tests {
async fn is_mentioned_uses_cached_lowercase_via_engine() {
// Constructs the engine with a mixed-case name; verifies all
// four casing variants resolve through the same cached state.
let rag_engine = Arc::new(RagEngine::new());
let (_tx, rx) = watch::channel(false);
let engine =
PersonaCognitionEngine::new(Uuid::new_v4(), "Helper AI".into(), rag_engine, rx);
PersonaCognitionEngine::new(Uuid::new_v4(), "Helper AI".into(), rx);
assert!(engine.is_mentioned("@helper ai please"));
assert!(engine.is_mentioned("@HELPER AI"));
assert!(engine.is_mentioned("Hey helper ai, can you..."));
Expand Down
5 changes: 1 addition & 4 deletions core/continuum-mind/src/persona/evaluator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
use super::*;
use continuum_base::time::EpochMs;
use crate::persona::message_cache::{CachedMessage, SenderCategory};
use crate::rag::RagEngine;
use std::sync::Arc;
use tokio::sync::watch;

fn test_engine(name: &str) -> (PersonaCognitionEngine, Uuid) {
let rag_engine = Arc::new(RagEngine::new());
let (_tx, rx) = watch::channel(false);
let id = Uuid::new_v4();
(
PersonaCognitionEngine::new(id, name.into(), rag_engine, rx),
PersonaCognitionEngine::new(id, name.into(), rx),
id,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ fn test_obligations(hosted: &HostedPersona) -> crate::persona::obligation::Oblig
cognition: Arc::new(crate::persona::unified::PersonaCognition::new(
persona_id,
"Paige".to_string(),
Arc::new(crate::rag::RagEngine::new()),
)),
// #195 slice 2: build via the same helper production
// uses, NOT a copy-pasted template. If a future PR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,9 @@ pub async fn materialize_adapters(
// set_airc_source so compose_for_turn has engram + airc both
// available the moment her service loop iterates (task #148).
// The runtime IS an AircTranscriptReader by trait bound.
let rag_engine = Arc::new(crate::rag::RagEngine::new());
let mut cognition = crate::persona::unified::PersonaCognition::new(
identity.peer_id.as_uuid(),
identity.agent_name.clone(),
rag_engine,
);
// One airc source: it delivers her rooms to cognition and takes the read receipt
// of every sent prompt (her cursor moves through what she was shown, never at delivery).
Expand Down
Loading
Loading