The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(api, web_chat): extract product tests and reorganize web chat ops
Steven Enamakel7e0dafeed2ff
diff --git a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/scheduler.rs b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/scheduler.rsnew file mode 100644index 0000000000..5929e8486d--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/scheduler.rs@@ -0,0 +1,101 @@+//! `dispatch` step of the phase loop: reload the run, honour cancellation,+//! and pick the next runnable phase.++use std::sync::atomic::{AtomicBool, Ordering};+use std::sync::Arc;++use anyhow::{anyhow, Result};++use tinyagents_session::run_ledger::{get_workflow_run, WorkflowRunStatus};++use super::super::types::{WorkflowDefinition, WorkflowPhase};+use super::cancel::lookup_cancel_signal_unused as _; // silence unused-module lints when reordered+use super::state::{+ all_phases_completed, next_runnable_phase, persist, synthesize_summary, LOG_TARGET,+};+use crate::config::Config;++/// What the scheduler's `dispatch` step decided.+pub(crate) enum PhaseSelection {+ /// Execute this phase next.+ Run(WorkflowPhase),+ /// The run reached a terminal status (already persisted) — route to `done`.+ Terminated,+}++/// `dispatch` step: reload the run, honour cancellation, and pick the next+/// runnable phase (pending, all deps `completed`). When none remains, persist the+/// terminal status (Completed / Failed) and return [`PhaseSelection::Terminated`].+pub(crate) async fn select_next_phase(+ config: &Config,+ run_id: &str,+ definition: &WorkflowDefinition,+ cancel: &Arc<AtomicBool>,+ session: &crate::agent::orchestration::AgentOrchestrationSession,+) -> Result<PhaseSelection> {+ // Reload so we read the latest phase_states (and a resume picks up persisted+ // progress).+ let run = get_workflow_run(&config.workspace_dir, run_id)?+ .ok_or_else(|| anyhow!("workflow run {run_id} vanished mid-loop"))?;+ let phase_states = run.phase_states.clone();+ let child_run_ids = run.child_run_ids.clone();++ // Cancellation check between phases.+ if cancel.load(Ordering::SeqCst) {+ log::debug!(+ target: LOG_TARGET,+ "[workflow_run_engine] loop.cancelled run={run_id}"+ );+ session.abort_all().await;+ persist(+ config,+ &run,+ phase_states,+ child_run_ids,+ WorkflowRunStatus::Interrupted,+ None,+ false,+ )?;+ return Ok(PhaseSelection::Terminated);+ }++ // Find the next runnable phase: pending, with all deps completed.+ let Some(phase) = next_runnable_phase(definition, &phase_states) else {+ // No runnable phase left. Either everything is done, or we're blocked+ // (which a validated DAG shouldn't be).+ if all_phases_completed(definition, &phase_states) {+ let summary = synthesize_summary(definition, &phase_states);+ log::debug!(+ target: LOG_TARGET,+ "[workflow_run_engine] loop.completed run={run_id} summary_chars={}",+ summary.as_deref().map(str::len).unwrap_or(0)+ );+ persist(+ config,+ &run,+ phase_states,+ child_run_ids,+ WorkflowRunStatus::Completed,+ summary,+ true,+ )?;+ } else {+ log::warn!(+ target: LOG_TARGET,+ "[workflow_run_engine] loop.stuck run={run_id} no_runnable_phase"+ );+ persist(+ config,+ &run,+ phase_states,+ child_run_ids,+ WorkflowRunStatus::Failed,+ Some("no runnable phase (dependency deadlock)".to_string()),+ true,+ )?;+ }+ return Ok(PhaseSelection::Terminated);+ };++ Ok(PhaseSelection::Run(phase.clone()))+}diff --git a/crates/openhuman-core/src/api/product.rs b/crates/openhuman-core/src/api/product.rsindex 3f02265e3c..ac10cf0f7b 100644--- a/crates/openhuman-core/src/api/product.rs+++ b/crates/openhuman-core/src/api/product.rs@@ -175,96 +175,7 @@ pub(crate) fn reset_product_identity_for_test() {set_product_identity(ProductIdentity::default());}-#[cfg(test)]-mod tests {- use super::*;-- #[test]- fn defaults_to_openhuman() {- let _guard = product_identity_test_lock();- reset_product_identity_for_test();- assert_eq!(product_identity().as_str(), "openhuman");- assert_eq!(- ProductIdentity::default().as_str(),- DEFAULT_PRODUCT_IDENTITY- );- }-- #[test]- fn override_is_respected_and_restorable() {- let _guard = product_identity_test_lock();- reset_product_identity_for_test();-- set_product_identity(ProductIdentity::new("opencompany").unwrap());- assert_eq!(product_identity().as_str(), "opencompany");-- reset_product_identity_for_test();- assert_eq!(product_identity().as_str(), "openhuman");- }-- #[test]- fn new_keeps_allowed_characters_and_trims() {- assert_eq!(- ProductIdentity::new(" opencompany ").unwrap().as_str(),- "opencompany"- );- assert_eq!(- ProductIdentity::new("open_company-2.0").unwrap().as_str(),- "open_company-2.0"- );- }-- #[test]- fn new_drops_header_unsafe_characters() {- // A newline would otherwise let a caller inject a second header.- assert_eq!(- ProductIdentity::new("medulla\r\nx-admin: 1")- .unwrap()- .as_str(),- "medullax-admin1"- );- assert_eq!(- ProductIdentity::new("med ulla").unwrap().as_str(),- "medulla"- );- }-- #[test]- fn new_lowercases_so_the_backend_enum_still_matches() {- assert_eq!(- ProductIdentity::new("OpenCompany").unwrap().as_str(),- "opencompany"- );- }-- #[test]- fn new_rejects_values_with_nothing_usable_left() {- assert!(ProductIdentity::new("").is_none());- assert!(ProductIdentity::new(" ").is_none());- assert!(ProductIdentity::new("!@#$%").is_none());- }-- #[test]- fn new_truncates_overlong_values() {- let identity = ProductIdentity::new(&"a".repeat(PRODUCT_IDENTITY_MAX_LEN * 2)).unwrap();- assert_eq!(identity.as_str().len(), PRODUCT_IDENTITY_MAX_LEN);- }- #[test]- fn header_carries_the_current_identity() {- let _guard = product_identity_test_lock();- reset_product_identity_for_test();-- let headers = product_identity_headers();- assert_eq!(- headers.get(PRODUCT_IDENTITY_HEADER).unwrap(),- DEFAULT_PRODUCT_IDENTITY- );-- set_product_identity(ProductIdentity::new("medulla").unwrap());- let headers = product_identity_headers();- assert_eq!(headers.get(PRODUCT_IDENTITY_HEADER).unwrap(), "medulla");-- reset_product_identity_for_test();- }-}+#[cfg(test)]+#[path = "product_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/api/product_tests.rs b/crates/openhuman-core/src/api/product_tests.rsnew file mode 100644index 0000000000..f84ca51a88--- /dev/null+++ b/crates/openhuman-core/src/api/product_tests.rs@@ -0,0 +1,90 @@+use super::*;++#[test]+fn defaults_to_openhuman() {+ let _guard = product_identity_test_lock();+ reset_product_identity_for_test();+ assert_eq!(product_identity().as_str(), "openhuman");+ assert_eq!(+ ProductIdentity::default().as_str(),+ DEFAULT_PRODUCT_IDENTITY+ );+}++#[test]+fn override_is_respected_and_restorable() {+ let _guard = product_identity_test_lock();+ reset_product_identity_for_test();++ set_product_identity(ProductIdentity::new("opencompany").unwrap());+ assert_eq!(product_identity().as_str(), "opencompany");++ reset_product_identity_for_test();+ assert_eq!(product_identity().as_str(), "openhuman");+}++#[test]+fn new_keeps_allowed_characters_and_trims() {+ assert_eq!(+ ProductIdentity::new(" opencompany ").unwrap().as_str(),+ "opencompany"+ );+ assert_eq!(+ ProductIdentity::new("open_company-2.0").unwrap().as_str(),+ "open_company-2.0"+ );+}++#[test]+fn new_drops_header_unsafe_characters() {+ // A newline would otherwise let a caller inject a second header.+ assert_eq!(+ ProductIdentity::new("medulla\r\nx-admin: 1")+ .unwrap()+ .as_str(),+ "medullax-admin1"+ );+ assert_eq!(+ ProductIdentity::new("med ulla").unwrap().as_str(),+ "medulla"+ );+}++#[test]+fn new_lowercases_so_the_backend_enum_still_matches() {+ assert_eq!(+ ProductIdentity::new("OpenCompany").unwrap().as_str(),+ "opencompany"+ );+}++#[test]+fn new_rejects_values_with_nothing_usable_left() {+ assert!(ProductIdentity::new("").is_none());+ assert!(ProductIdentity::new(" ").is_none());+ assert!(ProductIdentity::new("!@#$%").is_none());+}++#[test]+fn new_truncates_overlong_values() {+ let identity = ProductIdentity::new(&"a".repeat(PRODUCT_IDENTITY_MAX_LEN * 2)).unwrap();+ assert_eq!(identity.as_str().len(), PRODUCT_IDENTITY_MAX_LEN);+}++#[test]+fn header_carries_the_current_identity() {+ let _guard = product_identity_test_lock();+ reset_product_identity_for_test();++ let headers = product_identity_headers();+ assert_eq!(+ headers.get(PRODUCT_IDENTITY_HEADER).unwrap(),+ DEFAULT_PRODUCT_IDENTITY+ );++ set_product_identity(ProductIdentity::new("medulla").unwrap());+ let headers = product_identity_headers();+ assert_eq!(headers.get(PRODUCT_IDENTITY_HEADER).unwrap(), "medulla");++ reset_product_identity_for_test();+}diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rsnew file mode 100644index 0000000000..018c95bcdd--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs@@ -0,0 +1,145 @@+//! User-profile, identity-sync, and per-toolkit scope-preference handlers:+//! `get_user_profile`, `refresh_all_identities`, `sync`, `get_user_scopes`,+//! `set_user_scopes`.++use serde_json::{Map, Value};++use crate::config::rpc as config_rpc;+use crate::core::all::ControllerFuture;+use crate::integrations::composio::{ops, providers};++use super::util::{read_required, read_required_non_empty, to_json};++pub(super) fn handle_get_user_profile(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let connection_id = read_required_non_empty(¶ms, "connection_id")?;+ to_json(ops::composio_get_user_profile(&config, &connection_id).await?)+ })+}++pub(super) fn handle_refresh_all_identities(_params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ to_json(ops::composio_refresh_all_identities(&config).await?)+ })+}++pub(super) fn handle_sync(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let connection_id = read_required_non_empty(¶ms, "connection_id")?;+ let reason = read_optional_reason(¶ms)?;+ to_json(ops::composio_sync(&config, &connection_id, reason).await?)+ })+}++/// Local alias so this file needs only one extra import — `reason` is the+/// only optional-param read outside the connection-id/toolkit path here.+fn read_optional_reason(params: &Map<String, Value>) -> Result<Option<String>, String> {+ super::util::read_optional::<String>(params, "reason")+}++pub(super) fn handle_get_user_scopes(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let toolkit = match read_required_non_empty(¶ms, "toolkit") {+ Ok(v) => v,+ Err(e) => {+ tracing::warn!(+ method = "composio.get_user_scopes",+ error = %e,+ "[composio:scopes] missing required `toolkit` param"+ );+ return Err(e);+ }+ };+ tracing::debug!(+ method = "composio.get_user_scopes",+ toolkit = %toolkit,+ "[composio:scopes] handler entry"+ );+ // Reads through the bound memory driver's `Graph` family, not through+ // the engine's `load_or_default` (which resolved the in-process client+ // itself — openhuman#5560 deleted that client). The read still fails+ // OPEN onto the default pref for every failure mode, deliberately; see+ // `ops::user_scopes`.+ //+ // The config load is `?`-free for the same reason: this handler has+ // never had a failing path, and turning "settings file momentarily+ // unreadable" into an RPC error would make the scopes panel fail where+ // it used to render the defaults.+ let pref = match config_rpc::load_config_with_timeout().await {+ Ok(config) => ops::load_user_scope_pref(&config, &toolkit).await,+ Err(error) => {+ tracing::warn!(+ method = "composio.get_user_scopes",+ toolkit = %toolkit,+ %error,+ "[composio:scopes] config load failed, using default pref (read+write)"+ );+ providers::UserScopePref::default()+ }+ };+ tracing::debug!(+ method = "composio.get_user_scopes",+ toolkit = %toolkit,+ read = pref.read,+ write = pref.write,+ admin = pref.admin,+ "[composio:scopes] handler exit"+ );+ to_json(crate::rpc::RpcOutcome::new(pref, vec![]))+ })+}++pub(super) fn handle_set_user_scopes(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let toolkit = match read_required_non_empty(¶ms, "toolkit") {+ Ok(v) => v,+ Err(e) => {+ tracing::warn!(+ method = "composio.set_user_scopes",+ error = %e,+ "[composio:scopes] missing required `toolkit` param"+ );+ return Err(e);+ }+ };+ let read: bool = read_required(¶ms, "read")?;+ let write: bool = read_required(¶ms, "write")?;+ let admin: bool = read_required(¶ms, "admin")?;+ let pref = providers::UserScopePref { read, write, admin };+ tracing::debug!(+ method = "composio.set_user_scopes",+ toolkit = %toolkit,+ read = pref.read,+ write = pref.write,+ admin = pref.admin,+ "[composio:scopes] handler entry"+ );+ // Writes through the bound memory driver's `Graph` family. This half+ // fails CLOSED, as it did before: the old code refused with "memory+ // client not initialised" rather than reporting a save it had not+ // done, and `ops::user_scopes::save` refuses on the same three+ // grounds (no driver, no `Graph` family, backend write failure).+ let config = config_rpc::load_config_with_timeout().await?;+ if let Err(e) = ops::save_user_scope_pref(&config, &toolkit, pref).await {+ tracing::error!(+ method = "composio.set_user_scopes",+ toolkit = %toolkit,+ error = %e,+ "[composio:scopes] save failed"+ );+ return Err(e);+ }+ tracing::debug!(+ method = "composio.set_user_scopes",+ toolkit = %toolkit,+ read = pref.read,+ write = pref.write,+ admin = pref.admin,+ "[composio:scopes] handler exit"+ );+ to_json(crate::rpc::RpcOutcome::new(pref, vec![]))+ })+}diff --git a/crates/openhuman-core/src/memory/guard/test_support/retrieval_and_ingest_impls.rs b/crates/openhuman-core/src/memory/guard/test_support/retrieval_and_ingest_impls.rsnew file mode 100644index 0000000000..e66102c55d--- /dev/null+++ b/crates/openhuman-core/src/memory/guard/test_support/retrieval_and_ingest_impls.rs@@ -0,0 +1,578 @@+//! `RecordingProvider`'s `Episodic`, `Profile`, `Chunks`, `Retrieval`,+//! `People`, `Scoring`, `Answer`, and typed-ingestion (`DocumentIngest`,+//! `ConversationIngest`, `LearningIngest`, `EventIngest`) family+//! implementations — the read/query half plus the v1.13.7 ingestion round.+//!+//! Split out of the original `test_support.rs`; see [`super::fixtures`] for+//! `RecordingProvider`'s type and constructors. The write/tree/graph+//! families live in [`super::provider_and_sync_impls`] and+//! [`super::core_and_docs_impls`].++use crate::memory::api::chunks::Chunk;+use crate::memory::api::error::MemoryError;+use crate::memory::api::provider::chunks::{+ ChunkDetail, ChunkEmbedding, ChunkQuery, ChunkScore, SourceIngestQuery, SourceIngestStatus,+};+use crate::memory::api::provider::episodic::{ConversationSegment, EpisodicTurn};+use crate::memory::api::provider::operations::{+ AnswerRequest, AnswerResponse, MemoryAnswer, MemoryConversationIngest, MemoryDocumentIngest,+ MemoryEventIngest, MemoryLearningIngest, RawMemoryEvent,+};+use crate::memory::api::provider::people::{+ AddressBookSeedOutcome, PersonHandle, PersonInteraction, PersonRecord, PersonScore,+ RankedPerson, ResolvedPerson,+};+use crate::memory::api::provider::profile::{FacetType, ProfileFacet, UserState};+use crate::memory::api::provider::retrieval::{+ CoverWindowQuery, EntityMatch, FastRetrieveQuery, RetrievalHit, RetrievalResponse,+ SourceRetrievalQuery,+};+use crate::memory::api::provider::types::{IngestItem, IngestOutcome};+use crate::memory::api::provider::{+ EpisodicEvent, MemoryChunks, MemoryEpisodic, MemoryPeople, MemoryProfile, MemoryRetrieval,+ MemoryScoring,+};+use async_trait::async_trait;+use tinymemory_api::learning::LearningCandidate;++use super::fixtures::{rendered_scope, Call, RecordingProvider};++#[async_trait]+impl MemoryEpisodic for RecordingProvider {+ async fn insert_turn(+ &self,+ turn: &crate::memory::api::provider::episodic::EpisodicTurn,+ ) -> Result<i64, MemoryError> {+ // Records the turn text, so a guard that failed to redact one would be+ // visible here rather than only in a live store.+ self.record(Call {+ method: "episodic.insert_turn".into(),+ content: Some(turn.content.clone()),+ taint: None,+ scoped: None,+ });+ Ok(1)+ }++ async fn session_turns(+ &self,+ _session_id: &str,+ ) -> Result<Vec<crate::memory::api::provider::episodic::EpisodicTurn>, MemoryError>+ {+ self.record(Call::plain("episodic.session_turns"));+ Ok(self.session_turns.lock().unwrap().clone())+ }++ async fn open_segment(+ &self,+ _session_id: &str,+ ) -> Result<+ Option<crate::memory::api::provider::episodic::ConversationSegment>,+ MemoryError,+ > {+ self.record(Call::plain("episodic.open_segment"));+ Ok(None)+ }++ async fn segments_pending_summary(+ &self,+ limit: u32,+ ) -> Result<+ Vec<crate::memory::api::provider::episodic::ConversationSegment>,+ MemoryError,+ > {+ self.record(Call::plain("episodic.segments_pending_summary"));+ // Honour `limit` — a fake that ignored it would let a test drive more+ // segments than the caller asked for and hide a bounded-recovery bug.+ Ok(self+ .pending_segments+ .lock()+ .unwrap()+ .iter()+ .take(limit as usize)+ .cloned()+ .collect())+ }++ async fn create_segment(+ &self,+ _segment_id: &str,+ _session_id: &str,+ _namespace: &str,+ _start_episodic_id: i64,+ _start_seq: Option<u32>,+ _start_timestamp: f64,+ _now: f64,+ ) -> Result<(), MemoryError> {+ self.record(Call::plain("episodic.create_segment"));+ Ok(())+ }++ async fn append_turn(+ &self,+ _segment_id: &str,+ _episodic_id: i64,+ _seq: Option<u32>,+ _timestamp: f64,+ _now: f64,+ ) -> Result<(), MemoryError> {+ self.record(Call::plain("episodic.append_turn"));+ Ok(())+ }++ async fn close_segment(&self, _segment_id: &str, _now: f64) -> Result<(), MemoryError> {+ self.record(Call::plain("episodic.close_segment"));+ Ok(())+ }++ async fn insert_event(&self, event: &EpisodicEvent) -> Result<(), MemoryError> {+ // Records the event text for the same reason `insert_turn` does: a guard+ // that stopped redacting one would otherwise be invisible to every test,+ // and the redaction on this path has already been missing once.+ self.record(Call {+ method: "episodic.insert_event".into(),+ content: Some(event.content.clone()),+ taint: None,+ scoped: None,+ });+ Ok(())+ }++ async fn set_segment_summary(+ &self,+ _segment_id: &str,+ summary: &str,+ _now: f64,+ ) -> Result<(), MemoryError> {+ self.record(Call {+ method: "episodic.set_segment_summary".into(),+ content: Some(summary.to_string()),+ taint: None,+ scoped: None,+ });+ Ok(())+ }++ async fn upsert_segment_embedding(+ &self,+ _segment_id: &str,+ _model_signature: &str,+ _embedding: &[f32],+ _created_at: f64,+ ) -> Result<(), MemoryError> {+ self.record(Call::plain("episodic.upsert_segment_embedding"));+ Ok(())+ }+}+#[async_trait]+impl MemoryProfile for RecordingProvider {+ async fn list_active_facets(&self) -> Result<Vec<ProfileFacet>, MemoryError> {+ self.record(Call::plain("profile.list_active_facets"));+ Ok(vec![])+ }+ async fn list_all_facets(&self) -> Result<Vec<ProfileFacet>, MemoryError> {+ self.record(Call::plain("profile.list_all_facets"));+ Ok(vec![])+ }+ async fn get_facet(&self, _key: &str) -> Result<Option<ProfileFacet>, MemoryError> {+ self.record(Call::plain("profile.get_facet"));+ Ok(None)+ }+ async fn facets_by_type(+ &self,+ _facet_type: FacetType,+ ) -> Result<Vec<ProfileFacet>, MemoryError> {+ self.record(Call::plain("profile.facets_by_type"));+ Ok(vec![])+ }+ async fn upsert_facet(&self, _facet: &ProfileFacet) -> Result<(), MemoryError> {+ self.record(Call::plain("profile.upsert_facet"));+ Ok(())+ }+ async fn upsert_provider_facet(+ &self,+ _facet_id: &str,+ _facet_type: FacetType,+ _key: &str,+ _value: &str,+ _confidence: f64,+ _segment_id: Option<&str>,+ _observed_at: f64,+ ) -> Result<(), MemoryError> {+ self.record(Call::plain("profile.upsert_provider_facet"));+ Ok(())+ }+ async fn set_facet_user_state(+ &self,+ _key: &str,+ _user_state: UserState,+ ) -> Result<bool, MemoryError> {+ self.record(Call::plain("profile.set_facet_user_state"));+ Ok(false)+ }+ async fn delete_facet(&self, _key: &str) -> Result<bool, MemoryError> {+ self.record(Call::plain("profile.delete_facet"));+ Ok(false)+ }+ async fn delete_facet_by_id(&self, _facet_id: &str) -> Result<bool, MemoryError> {+ self.record(Call::plain("profile.delete_facet_by_id"));+ Ok(false)+ }+ async fn drop_facets_below(&self, _threshold: f64) -> Result<usize, MemoryError> {+ self.record(Call::plain("profile.drop_facets_below"));+ Ok(0)+ }+ async fn workflow_identity_matches(&self, _pattern: &str, _value: &str) -> bool {+ self.record(Call::plain("profile.workflow_identity_matches"));+ false+ }+}++#[async_trait]+impl MemoryChunks for RecordingProvider {+ async fn list_chunks(+ &self,+ _query: &ChunkQuery,+ scope: Option<&SourceScope>,+ ) -> Result<Vec<Chunk>, MemoryError> {+ self.record(Call {+ method: "chunks.list_chunks".into(),+ content: rendered_scope(scope),+ taint: None,+ scoped: Some(scope.is_some()),+ });+ Ok(vec![])+ }++ async fn get_chunk(&self, _chunk_id: &str) -> Result<Option<Chunk>, MemoryError> {+ self.record(Call::plain("chunks.get_chunk"));+ Ok(None)+ }++ async fn chunk_detail(&self, _chunk_id: &str) -> Result<Option<ChunkDetail>, MemoryError> {+ self.record(Call::plain("chunks.chunk_detail"));+ Ok(None)+ }++ async fn storage_kinds(&self) -> Result<Vec<String>, MemoryError> {+ self.record(Call::plain("chunks.storage_kinds"));+ Ok(vec![])+ }++ async fn chunk_embeddings(+ &self,+ _chunk_ids: &[String],+ _model_signature: &str,+ ) -> Result<Vec<ChunkEmbedding>, MemoryError> {+ self.record(Call::plain("chunks.chunk_embeddings"));+ Ok(vec![])+ }++ async fn chunk_score(+ &self,+ _chunk_id: &str,+ ) -> Result<Option<crate::memory::api::provider::chunks::ChunkScore>, MemoryError>+ {+ self.record(Call::plain("chunks.chunk_score"));+ Ok(None)+ }++ async fn source_ingest_status(+ &self,+ _source_prefixes: &[crate::memory::api::provider::chunks::SourceIngestQuery],+ ) -> Result<Vec<crate::memory::api::provider::chunks::SourceIngestStatus>, MemoryError>+ {+ self.record(Call::plain("chunks.source_ingest_status"));+ Ok(vec![])+ }+}++#[async_trait]+impl MemoryRetrieval for RecordingProvider {+ async fn fast_retrieve(+ &self,+ _query: &str,+ _options: FastRetrieveQuery,+ scope: Option<&SourceScope>,+ ) -> Result<RetrievalResponse, MemoryError> {+ self.record(Call {+ method: "retrieval.fast_retrieve".into(),+ content: rendered_scope(scope),+ taint: None,+ scoped: Some(scope.is_some()),+ });+ Ok(self.fast_retrieve_result.lock().unwrap().clone())+ }++ async fn cover_window(+ &self,+ _window: &CoverWindowQuery,+ scope: Option<&SourceScope>,+ ) -> Result<RetrievalResponse, MemoryError> {+ self.record(Call {+ method: "retrieval.cover_window".into(),+ content: rendered_scope(scope),+ taint: None,+ scoped: Some(scope.is_some()),+ });+ Ok(RetrievalResponse::default())+ }++ async fn retrieve_source(+ &self,+ _query: &SourceRetrievalQuery,+ scope: Option<&SourceScope>,+ ) -> Result<RetrievalResponse, MemoryError> {+ self.record(Call {+ method: "retrieval.retrieve_source".into(),+ content: rendered_scope(scope),+ taint: None,+ scoped: Some(scope.is_some()),+ });+ Ok(RetrievalResponse::default())+ }++ async fn retrieve_children(+ &self,+ _node_id: &str,+ _max_depth: u32,+ _query: Option<&str>,+ _limit: Option<usize>,+ scope: Option<&SourceScope>,+ ) -> Result<Vec<RetrievalHit>, MemoryError> {+ self.record(Call {+ method: "retrieval.retrieve_children".into(),+ content: rendered_scope(scope),+ taint: None,+ scoped: Some(scope.is_some()),+ });+ Ok(vec![])+ }++ async fn retrieve_leaves(+ &self,+ _chunk_ids: &[String],+ scope: Option<&SourceScope>,+ ) -> Result<Vec<RetrievalHit>, MemoryError> {+ self.record(Call {+ method: "retrieval.retrieve_leaves".into(),+ content: rendered_scope(scope),+ taint: None,+ scoped: Some(scope.is_some()),+ });+ Ok(vec![])+ }++ async fn recall_namespace_scored(+ &self,+ namespace: &str,+ _query: &str,+ limit: usize,+ _exclude_session_id: Option<&str>,+ ) -> Result<Vec<NamespaceMemoryHit>, MemoryError> {+ // Honours the two request parameters a caller can get wrong — the+ // namespace it asks for and the page it accepts — and records them,+ // so a test can assert both rather than only the content it got.+ self.record(Call {+ method: "retrieval.recall_namespace_scored".into(),+ content: Some(format!("namespace={namespace} limit={limit}")),+ taint: None,+ scoped: None,+ });+ Ok(self+ .namespace_hits+ .lock()+ .unwrap()+ .iter()+ .filter(|hit| hit.namespace == namespace)+ .take(limit)+ .cloned()+ .collect())+ }++ async fn recall_namespace_recent(+ &self,+ _namespace: &str,+ _limit: usize,+ ) -> Result<Vec<NamespaceMemoryHit>, MemoryError> {+ self.record(Call::plain("retrieval.recall_namespace_recent"));+ Ok(vec![])+ }++ async fn search_entities(+ &self,+ _query: &str,+ _kinds: Option<&[String]>,+ _limit: usize,+ ) -> Result<Vec<EntityMatch>, MemoryError> {+ self.record(Call::plain("retrieval.search_entities"));+ Ok(vec![])+ }+}++#[async_trait]+impl MemoryPeople for RecordingProvider {+ async fn list_people(&self, _limit: Option<usize>) -> Result<Vec<RankedPerson>, MemoryError> {+ self.record(Call::plain("people.list_people"));+ Ok(vec![])+ }++ async fn get_person(&self, _person_id: &str) -> Result<Option<PersonRecord>, MemoryError> {+ self.record(Call::plain("people.get_person"));+ Ok(None)+ }++ async fn resolve_handle(+ &self,+ _handle: &PersonHandle,+ _create_if_missing: bool,+ ) -> Result<Option<ResolvedPerson>, MemoryError> {+ self.record(Call::plain("people.resolve_handle"));+ Ok(None)+ }++ async fn add_handle_alias(+ &self,+ _person_id: &str,+ _handle: &PersonHandle,+ ) -> Result<(), MemoryError> {+ self.record(Call::plain("people.add_handle_alias"));+ Ok(())+ }++ async fn score_person(&self, _person_id: &str) -> Result<Option<PersonScore>, MemoryError> {+ self.record(Call::plain("people.score_person"));+ Ok(None)+ }++ async fn record_interaction(+ &self,+ _interaction: &PersonInteraction,+ ) -> Result<(), MemoryError> {+ self.record(Call::plain("people.record_interaction"));+ Ok(())+ }++ async fn seed_from_address_book(&self) -> Result<AddressBookSeedOutcome, MemoryError> {+ self.record(Call::plain("people.seed_from_address_book"));+ Ok(AddressBookSeedOutcome::default())+ }+}++#[async_trait]+impl MemoryScoring for RecordingProvider {+ async fn extract_entities(&self, query: &str) -> Result<Vec<String>, MemoryError> {+ self.record(Call {+ method: "scoring.extract_entities".into(),+ content: Some(query.to_string()),+ taint: None,+ scoped: None,+ });+ Ok(Vec::new())+ }++ async fn embed_text(&self, text: &str) -> Result<Vec<f32>, MemoryError> {+ self.record(Call {+ method: "scoring.embed_text".into(),+ content: Some(text.to_string()),+ taint: None,+ scoped: None,+ });+ Ok(Vec::new())+ }++ async fn embedder_slug(&self) -> Result<String, MemoryError> {+ self.record(Call::plain("scoring.embedder_slug"));+ Ok(String::new())+ }+}++// ── The v1.13.7 typed-ingestion round + Answer ──────────────────────────────+// Same contract as every family above: `capabilities()` answers all(), so the+// audit demands a live accessor and a recording impl for each.++#[async_trait]+impl MemoryDocumentIngest for RecordingProvider {+ async fn ingest_document(&self, document: IngestItem) -> Result<IngestOutcome, MemoryError> {+ self.record(Call {+ method: "document_ingest.ingest_document".into(),+ content: Some(document.content),+ taint: Some(document.taint),+ scoped: None,+ });+ Ok(IngestOutcome::default())+ }+}++#[async_trait]+impl MemoryConversationIngest for RecordingProvider {+ async fn ingest_conversation(+ &self,+ messages: Vec<IngestItem>,+ ) -> Result<IngestOutcome, MemoryError> {+ for message in messages {+ self.record(Call {+ method: "conversation_ingest.ingest_conversation".into(),+ content: Some(message.content),+ taint: Some(message.taint),+ scoped: None,+ });+ }+ Ok(IngestOutcome::default())+ }+}++#[async_trait]+impl MemoryLearningIngest for RecordingProvider {+ async fn ingest_learning(+ &self,+ _learning: tinymemory_api::learning::LearningCandidate,+ ) -> Result<IngestOutcome, MemoryError> {+ self.record(Call {+ method: "learning_ingest.ingest_learning".into(),+ content: None,+ taint: None,+ scoped: None,+ });+ Ok(IngestOutcome::default())+ }+}++#[async_trait]+impl MemoryEventIngest for RecordingProvider {+ async fn ingest_event(+ &self,+ _event: crate::memory::api::provider::operations::RawMemoryEvent,+ ) -> Result<IngestOutcome, MemoryError> {+ self.record(Call {+ method: "event_ingest.ingest_event".into(),+ content: None,+ taint: None,+ scoped: None,+ });+ Ok(IngestOutcome::default())+ }+}+++#[async_trait]+impl MemoryAnswer for RecordingProvider {+ async fn answer(+ &self,+ _request: crate::memory::api::provider::operations::AnswerRequest,+ ) -> Result<crate::memory::api::provider::operations::AnswerResponse, MemoryError>+ {+ self.record(Call {+ method: "answer.answer".into(),+ content: None,+ taint: None,+ scoped: None,+ });+ Ok(crate::memory::api::provider::operations::AnswerResponse {+ answer: String::new(),+ model: None,+ citations: Vec::new(),+ steps: Vec::new(),+ })+ }+}diff --git a/crates/openhuman-core/src/web_chat/ops.rs b/crates/openhuman-core/src/web_chat/ops.rsindex 4079bdf03e..1941a29d8a 100644--- a/crates/openhuman-core/src/web_chat/ops.rs+++ b/crates/openhuman-core/src/web_chat/ops.rs@@ -1,6 +1,49 @@+//! Web-channel chat dispatch: turn lifecycle (start/cancel/queue), the+//! primary and parallel turn bodies, the shared in-flight/session state they+//! coordinate over, and the guards (wall-clock backstop, budget correlation,+//! Sentry suppression) applied around every turn.++mod budget_correlation;+mod channel_ops;+mod parallel_turn;+mod start_chat;+mod state;+#[cfg(any(test, debug_assertions))]+mod test_hooks;+mod turn_guards;++pub(super) use budget_correlation::{classify_budget_correlation, BudgetCorrelation};#[cfg(test)]-#[path = "ops_budget_correlation_tests_tests.rs"]-mod budget_correlation_tests;-include!("ops_part_01.rs");-include!("ops_part_02.rs");-include!("ops_part_03.rs");+pub(super) use budget_correlation::{clear_budget_signal, has_fresh_budget_signal, record_budget_signal};+#[cfg(not(test))]+pub(super) use budget_correlation::{clear_budget_signal, has_fresh_budget_signal, record_budget_signal};++pub use channel_ops::{+ cancel_chat, cancel_chat_scoped, channel_web_cancel, channel_web_chat,+ channel_web_queue_clear, channel_web_queue_status,+};++#[cfg(any(test, debug_assertions))]+pub use parallel_turn::spawn_parallel_turn as _spawn_parallel_turn_for_test_visibility;++pub use start_chat::start_chat;++pub(super) use state::{cancel_in_flight_gracefully, event_session_id_for, key_for};+pub use state::{+ cancel_should_target, in_flight_entries_for_test, invalidate_thread_sessions,+};+#[cfg(any(test, debug_assertions))]+pub use state::parallel_in_flight_entries_for_test;+pub(super) use state::{IN_FLIGHT, PARALLEL_IN_FLIGHT, THREAD_SESSIONS};++#[cfg(any(test, debug_assertions))]+pub use test_hooks::set_test_forced_run_chat_task_error;+#[cfg(any(test, debug_assertions))]+pub use test_hooks::RUN_CHAT_TASK_TEST_LOCK;+#[cfg(any(test, debug_assertions))]+pub use test_hooks::{set_test_run_chat_task_block, TestRunChatTaskBlock};+#[cfg(any(test, debug_assertions))]+pub(super) use test_hooks::{TEST_FORCED_RUN_CHAT_TASK_ERROR, TEST_RUN_CHAT_TASK_BLOCK};++pub(super) use turn_guards::sentry_suppression_reason;+pub(super) use turn_guards::timeout_bound_tag;