Project both semantic Mind partitions
This commit is contained in:
parent
ab4e6e9889
commit
2ba6b9dc7e
2 changed files with 49 additions and 9 deletions
|
|
@ -2764,7 +2764,7 @@ fn validate_semantic_projection_health(
|
|||
let has_receipt = row.receipt_id.is_some()
|
||||
&& row.indexed_document_count.is_some()
|
||||
&& row.vector_dimensions.is_some();
|
||||
if row.query_eligible_display_only != (row.status == "ready")
|
||||
if (row.query_eligible_display_only && row.status != "ready")
|
||||
|| has_receipt != (row.status == "ready")
|
||||
{
|
||||
return Err(anyhow!(
|
||||
|
|
@ -8421,6 +8421,11 @@ mod tests {
|
|||
)?;
|
||||
assert_eq!(ready.status, "ready");
|
||||
assert!(ready.query_eligible_display_only);
|
||||
let mut empty_ready = ready.clone();
|
||||
empty_ready.indexed_document_count = Some(0);
|
||||
empty_ready.vector_dimensions = Some(0);
|
||||
empty_ready.query_eligible_display_only = false;
|
||||
validate_semantic_projection_health(&empty_ready)?;
|
||||
|
||||
let repair =
|
||||
crate::memory_graph::semantic_projector::idunn_acquire_memory_semantic_projection(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::memory_graph::{
|
|||
};
|
||||
use crate::{
|
||||
MemorySemanticIndexConfig, MemorySemanticProjectionInput,
|
||||
agent_memory_semantic_projection_input,
|
||||
agent_memory_semantic_projection_input, runtime_modeling_semantic_projection_input,
|
||||
};
|
||||
use anyhow::{Result, anyhow};
|
||||
use chrono::{SecondsFormat, Utc};
|
||||
|
|
@ -189,7 +189,6 @@ impl SemanticProjectorServiceBody {
|
|||
config: MemorySemanticIndexConfig,
|
||||
) -> Result<Self> {
|
||||
let singleton = acquire_semantic_projector_singleton(&mind_store, &modeling_store)?;
|
||||
agent_memory_semantic_projection_input(&mind_store)?;
|
||||
let session = LocalIdunnSemanticProjectorSession::new(
|
||||
mind_store,
|
||||
modeling_store,
|
||||
|
|
@ -210,12 +209,10 @@ impl SemanticProjectorServiceBody {
|
|||
|
||||
pub fn pulse(&self, fairness_cursor: Option<&str>) -> SemanticProjectorServicePulse {
|
||||
let session = &self.pulser.port;
|
||||
let mut source_fault_count = 0;
|
||||
let mut inputs = Vec::with_capacity(1);
|
||||
match agent_memory_semantic_projection_input(&session.mind_store) {
|
||||
Ok(input) => inputs.push(input),
|
||||
Err(_) => source_fault_count += 1,
|
||||
}
|
||||
let (inputs, source_fault_count) = collect_semantic_projection_inputs(
|
||||
agent_memory_semantic_projection_input(&session.mind_store),
|
||||
runtime_modeling_semantic_projection_input(&session.modeling_store),
|
||||
);
|
||||
let outcome = self.pulser.pulse(&inputs, fairness_cursor);
|
||||
SemanticProjectorServicePulse {
|
||||
outcome,
|
||||
|
|
@ -225,6 +222,23 @@ impl SemanticProjectorServiceBody {
|
|||
}
|
||||
}
|
||||
|
||||
fn collect_semantic_projection_inputs(
|
||||
mind: Result<MemorySemanticProjectionInput>,
|
||||
modeling: Result<MemorySemanticProjectionInput>,
|
||||
) -> (Vec<MemorySemanticProjectionInput>, u32) {
|
||||
match (mind, modeling) {
|
||||
(Ok(mind), Ok(modeling))
|
||||
if validate_semantic_projector_source_pair(&mind, &modeling).is_ok() =>
|
||||
{
|
||||
(vec![mind, modeling], 0)
|
||||
}
|
||||
(Ok(_), Ok(_)) => (Vec::new(), 2),
|
||||
(Ok(mind), Err(_)) => (vec![mind], 1),
|
||||
(Err(_), Ok(modeling)) => (vec![modeling], 1),
|
||||
(Err(_), Err(_)) => (Vec::new(), 2),
|
||||
}
|
||||
}
|
||||
|
||||
impl MemorySemanticProjectorPulsePort for LocalIdunnSemanticProjectorSession {
|
||||
fn classify(
|
||||
&self,
|
||||
|
|
@ -371,6 +385,27 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pulse_source_collection_keeps_both_partitions_and_does_not_hide_one_survivor() {
|
||||
let (both, faults) =
|
||||
collect_semantic_projection_inputs(Ok(input("a", "mind")), Ok(input("a", "modeling")));
|
||||
assert_eq!(both.len(), 2);
|
||||
assert_eq!(faults, 0);
|
||||
|
||||
let (modeling, faults) = collect_semantic_projection_inputs(
|
||||
Err(anyhow!("Mind source failed")),
|
||||
Ok(input("a", "modeling")),
|
||||
);
|
||||
assert_eq!(modeling.len(), 1);
|
||||
assert_eq!(modeling[0].obligation().partition, "modeling");
|
||||
assert_eq!(faults, 1);
|
||||
|
||||
let (foreign_pair, faults) =
|
||||
collect_semantic_projection_inputs(Ok(input("a", "mind")), Ok(input("b", "modeling")));
|
||||
assert!(foreign_pair.is_empty());
|
||||
assert_eq!(faults, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn session_refuses_one_physical_store_as_two_owners() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
|
|
|
|||
Reference in a new issue