Files
ruvnet--RuView/v2/crates/homecore-assist/src/lib.rs
T
ruv 7c80711454 feat(homecore-assist,homecore-recorder): replace stubs with real impls (ADR-132/133)
Implements the three placeholder paths with real, tested behaviour and an
honest typed result wherever a capability is genuinely data-gated.

homecore-assist:
- runner.rs: add LocalRunner — runs the real IntentRecognizer pipeline and
  returns a fully-formed RufloResponse (resolved intent + speech). NoopRunner
  is now honest: typed NotStarted before spawn, explicit empty after (never a
  silent fabricated response). A live ruflo-agent.js subprocess remains the
  data-gated future path.
- recognizer.rs / semantic_recognizer.rs: real SemanticIntentRecognizer — embeds
  the utterance (deterministic feature-hash embedding, new embedding.rs) and runs
  ruvector-core HNSW nearest-neighbour search over enrolled exemplars, accepting
  matches above a configurable cosine-similarity threshold (default 0.75) and
  falling back to regex below it. Measured: paraphrase "turn on the kitchen
  light" vs exemplar "turn on the light" -> sim 0.855 (match); "schedule a
  dentist appointment" -> sim 0.106 (no-match). `semantic` feature on by default.

homecore-recorder:
- db.rs: search_states_by_text — real SQL LIKE query over entity_id/state/attrs
  returning real rows (newest-first, k-capped, LIKE-escaped). search_semantic now
  falls back to it when the vector index yields no hits, so it is no longer
  always-empty under the default NullSemanticIndex.

Tests (real behaviour; each fails on the old always-empty stub, verified):
- homecore-assist: 39 passed / 0 failed
- homecore-recorder (P1, no features): 19 passed / 0 failed
- homecore-recorder (P2, --features ruvector): 25 passed / 0 failed
All files < 500 lines; homecore-server consumer still builds.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-06-11 21:40:20 -04:00

60 lines
2.6 KiB
Rust

//! HOMECORE-ASSIST — Voice/intent pipeline + ruflo agent bridge.
//!
//! Implements [ADR-133](../../../docs/adr/ADR-133-homecore-assist-ruflo.md):
//! the Assist pipeline that takes a voice utterance through intent
//! recognition, intent handling, and response synthesis.
//!
//! ## Module layout
//!
//! - [`intent`] — `IntentName`, `Intent`, `IntentResponse`, `Card`
//! - [`recognizer`] — `IntentRecognizer` trait + `RegexIntentRecognizer`
//! - [`semantic_recognizer`] — `SemanticIntentRecognizer`: real embedding +
//! ruvector-core HNSW search over enrolled intent exemplars (`semantic` feature)
//! - [`embedding`] — deterministic feature-hash text embedding (`semantic` feature)
//! - [`handler`] — `IntentHandler` trait + 5 built-in HA-mirroring handlers
//! - [`runner`] — `RufloRunner` trait + `LocalRunner` (real recognizer-backed
//! resolution) + honest `NoopRunner`
//! - [`pipeline`] — `AssistPipeline`: wires recognizer → handler → response
//!
//! ## Implemented capability
//!
//! - Regex-based intent recognition (HA classic intent matching).
//! - Semantic intent recognition: utterance embedding + HNSW nearest-neighbour
//! match against enrolled exemplars, with a configurable similarity threshold
//! and regex fallback below it.
//! - Built-in handlers: `HassTurnOn`, `HassTurnOff`, `HassLightSet`,
//! `HassNevermind`, `HassCancelAll`.
//! - `LocalRunner`: resolves intents locally and returns a real `RufloResponse`
//! with no external process. `NoopRunner` is an explicit, honest no-op (typed
//! `NotStarted` before spawn; explicit empty-response after).
//!
//! ## Data-gated / future
//!
//! - A live `node ruflo-agent.js` LLM subprocess runner (Windows-safe teardown
//! per ADR-133 §Q3) is gated on that script existing; `LocalRunner` is the
//! honest path until it ships.
//! - STT/TTS bridge and satellite protocol (P3).
pub mod intent;
pub mod recognizer;
pub mod semantic_recognizer;
pub mod handler;
pub mod runner;
pub mod pipeline;
/// Deterministic text embedding used by [`semantic_recognizer::SemanticIntentRecognizer`].
#[cfg(feature = "semantic")]
pub mod embedding;
pub use intent::{Card, Intent, IntentName, IntentResponse};
pub use recognizer::{IntentRecognizer, RecognizerError, RegexIntentRecognizer};
pub use semantic_recognizer::{SemanticIntentRecognizer, DEFAULT_SIMILARITY_THRESHOLD};
pub use handler::{
HandlerError, HassCancelAll, HassLightSet, HassNevermind, HassTurnOff, HassTurnOn,
IntentHandler,
};
pub use runner::{
AssistError, LocalRunner, NoopRunner, RufloResponse, RufloRunner, RufloRunnerOpts,
};
pub use pipeline::AssistPipeline;