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 crates/ladybug-contract/src/wide_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl WideContainer {
return items[0].clone();
}
let threshold = items.len() / 2;
let even = items.len() % 2 == 0;
let even = items.len().is_multiple_of(2);
let mut result = WideContainer::zero();
for word in 0..WIDE_WORDS {
let mut out = 0u64;
Expand Down
8 changes: 3 additions & 5 deletions crates/ladybug-contract/src/wide_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ impl<'a> WideMetaView<'a> {
/// Read all 10 layer activations.
pub fn layer_activations(&self) -> [f64; 10] {
let mut out = [0.0f64; 10];
for i in 0..10 {
out[i] = f64::from_bits(self.words[W_LAYER10_BASE + i]);
for (i, slot) in out.iter_mut().enumerate() {
*slot = f64::from_bits(self.words[W_LAYER10_BASE + i]);
}
out
}
Expand Down Expand Up @@ -632,9 +632,7 @@ impl<'a> WideMetaViewMut<'a> {
self.words[W_SPINE_BASE + i] = 0;
}
let n = ancestors.len().min(MAX_SPINE_DEPTH);
for i in 0..n {
self.words[W_SPINE_BASE + i] = ancestors[i];
}
self.words[W_SPINE_BASE..W_SPINE_BASE + n].copy_from_slice(&ancestors[..n]);
}

// ====================================================================
Expand Down
3 changes: 2 additions & 1 deletion src/core/rustynum_accel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ pub fn container_bundle(items: &[&Container]) -> Container {
.map(|c| view_u64_as_bytes(&c.words))
.collect();

let result_bytes = rustynum_rs::NumArrayU8::bundle_byte_slices(&slices);
let result_bytes = rustynum_rs::NumArrayU8::try_bundle_byte_slices(&slices)
.expect("bundle_byte_slices: all slices same length");

// Convert back to Container
let mut container = Container::zero();
Expand Down
6 changes: 2 additions & 4 deletions src/cypher_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ fn properties_to_fingerprint(
let mut content = label.to_string();
// Sort properties for determinism
let mut sorted: Vec<_> = properties.iter().collect();
sorted.sort_by_key(|(k, _)| k.clone());
sorted.sort_by_key(|(k, _)| *k);
for (k, v) in sorted {
content.push(':');
content.push_str(k);
Expand Down Expand Up @@ -618,12 +618,10 @@ fn parse_where_clause(s: &str) -> Result<WhereClause, String> {
/// Extract label from a MATCH/MERGE/CREATE pattern like "(n:System {...})"
fn extract_label(cypher: &str) -> Option<String> {
// Find first (variable:Label pattern
let mut in_parens = false;
let chars: Vec<char> = cypher.chars().collect();
let mut i = 0;
while i < chars.len() {
if chars[i] == '(' {
in_parens = true;
i += 1;
// Skip whitespace
while i < chars.len() && chars[i].is_whitespace() { i += 1; }
Expand Down Expand Up @@ -661,7 +659,7 @@ fn parse_node_pattern(cypher: &str) -> Result<(Vec<String>, HashMap<String, Cyph
let label_part = &inner[..brace_start];

for part in label_part.split(':').skip(1) {
let label = part.trim().split_whitespace().next().unwrap_or("").to_string();
let label = part.split_whitespace().next().unwrap_or("").to_string();
if !label.is_empty() {
labels.push(label);
}
Expand Down
2 changes: 1 addition & 1 deletion src/flight/crew_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ pub fn execute_crew_action(
"persona.attach_yaml" => {
let yaml = std::str::from_utf8(body).map_err(|e| format!("Invalid UTF-8: {}", e))?;

let persona = crate::orchestration::persona::Persona::from_yaml(yaml)?;
let _persona = crate::orchestration::persona::Persona::from_yaml(yaml)?;
// Extract agent_slot from first line comment or separate field
// For now, require JSON wrapper with agent_slot
#[derive(serde::Deserialize)]
Expand Down
6 changes: 3 additions & 3 deletions src/flight/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ fn build_search_result_data(
) -> Vec<(u16, [u64; FINGERPRINT_WORDS], Option<String>, u32, f32, u8)> {
results
.iter()
.filter_map(|(idx, dist)| {
.map(|(idx, dist)| {
// Get fingerprint from HDR index
// Note: We don't have direct address mapping, so we use index as pseudo-address
// In a real implementation, HDR index would store (addr, fingerprint) pairs
Expand All @@ -1272,14 +1272,14 @@ fn build_search_result_data(
};

// Return placeholder fingerprint - real impl would look up from index
Some((
(
addr,
[0u64; FINGERPRINT_WORDS],
None,
*dist,
similarity,
cascade_level,
))
)
})
.collect()
}
Expand Down
6 changes: 3 additions & 3 deletions src/orchestration/crew_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@

use super::a2a::{A2AMessage, A2AProtocol, DeliveryStatus};
use super::agent_card::{AgentCard, AgentRegistry};
use super::blackboard_agent::{AgentBlackboard, BlackboardRegistry};
use super::blackboard_agent::BlackboardRegistry;
use super::handover::{HandoverDecision, HandoverPolicy};
use super::kernel_extensions::{
FilterPipeline, KernelGuardrail, MemoryBank, ObservabilityManager, VerificationEngine,
};
use super::meta_orchestrator::MetaOrchestrator;
use super::persona::{Persona, PersonaRegistry};
use super::persona::PersonaRegistry;
use super::semantic_kernel::SemanticKernel;
use super::thinking_template::{ThinkingTemplate, ThinkingTemplateRegistry};
use crate::storage::bind_space::{Addr, BindSpace, FINGERPRINT_WORDS};
use crate::storage::bind_space::{Addr, BindSpace};
use serde::{Deserialize, Serialize};

/// Task status in the dispatch pipeline
Expand Down
2 changes: 1 addition & 1 deletion src/orchestration/handover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//! 4. **Dunning-Kruger guard** — agents with low coherence but high
//! confidence are flagged for metacognitive review

use crate::cognitive::{GateState, ThinkingStyle};
use crate::cognitive::GateState;
use serde::{Deserialize, Serialize};

// =============================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/orchestration/kernel_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
//! └───────────────────────────────────────────────────────────────────────┘
//! ```

use super::semantic_kernel::{CausalRung, KernelTruth, KernelZone};
use super::semantic_kernel::{KernelTruth, KernelZone};
use crate::storage::bind_space::{Addr, BindSpace, FINGERPRINT_WORDS};
use serde::{Deserialize, Serialize};

Expand Down
8 changes: 4 additions & 4 deletions src/spo/causal_trajectory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

use rustynum_bnn::causal_trajectory::{
CausalArrow, CausalChain, CausalDirection, CausalLink, CausalRelation, CausalSaliency,
CausalTrajectory, DominantPlane, EwmCorrection, EwmTier, HaloTransition,
NarsCausalStatement, NarsTruth, ResonatorSnapshot, RifDiff, SigmaEdge, SigmaNode,
CausalTrajectory, DominantPlane,
NarsCausalStatement, NarsTruth, ResonatorSnapshot, SigmaEdge,
};
use rustynum_bnn::{GrowthPath, HaloType, InferenceMode, MutationOp};
use rustynum_bnn::{GrowthPath, InferenceMode, MutationOp};
use rustynum_core::{CollapseGate, SigmaGate, SignificanceLevel};

use crate::nars::TruthValue;
Expand Down Expand Up @@ -201,7 +201,7 @@ impl TrajectoryHydrator {
edge: edge.clone(),
truth: nars_to_truth(&edge.truth),
growth_path: Some(growth_path),
gestalt: gestalt.clone(),
gestalt,
})
.collect();

Expand Down
6 changes: 3 additions & 3 deletions src/spo/codebook_hydration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use crate::core::Fingerprint;
use crate::FINGERPRINT_BITS;

use super::cognitive_codebook::{CognitiveCodebook, CognitiveAddress, CognitiveDomain, CodebookEntry, fold_to_48};
use super::cognitive_codebook::{CognitiveCodebook, CognitiveAddress, CognitiveDomain, fold_to_48};
use super::jina_cache::fingerprint_from_jina_embedding;

// =============================================================================
Expand Down Expand Up @@ -387,7 +387,7 @@ fn generate_embedding(text: &str) -> Vec<f32> {
// Domain-specific bias: same domain names cluster
// This gives intra-domain concepts shared structure
let domain_tag = if text.contains(':') {
text.split(':').last().unwrap_or("").trim()
text.split(':').next_back().unwrap_or("").trim()
} else {
""
};
Expand Down Expand Up @@ -683,7 +683,7 @@ pub fn print_quintenzirkel(feelings: &[DarkFeeling]) {
for pair in feelings.chunks(2) {
if pair.len() == 2 {
println!("║ Axis: {} ←→ {}", pair[0].name, pair[1].name);
println!("║ ({}: {})", pair[0].axis, "dark ←→ light");
println!("║ ({}: dark ←→ light)", pair[0].axis);
pair[0].print();
pair[1].print();

Expand Down
3 changes: 1 addition & 2 deletions src/spo/codebook_training.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@
//! └─────────────────────────────────────────┘
//! ```

use super::nsm_substrate::{MetacognitiveSubstrate, NSM_CATEGORIES, NsmCodebook, ROLES};
use super::nsm_substrate::MetacognitiveSubstrate;
use crate::core::Fingerprint;
use crate::nars::TruthValue;
use std::collections::HashMap;

// =============================================================================
Expand Down
1 change: 0 additions & 1 deletion src/spo/context_crystal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
//! - Context Crystal: (SPO + Qualia) × 5 sentences → resonance field

use crate::core::Fingerprint;
use std::collections::HashMap;

// =============================================================================
// Constants
Expand Down
3 changes: 1 addition & 2 deletions src/spo/crystal_lm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@

use crate::core::Fingerprint;
use crate::spo::cognitive_codebook::{
CognitiveAddress, CognitiveCodebook, CognitiveDomain, NarsCopula, QualiaChannel, ThematicRole,
YamlTemplate, fold_to_48,
CognitiveCodebook, CognitiveDomain, fold_to_48,
};
use std::collections::HashMap;

Expand Down
12 changes: 8 additions & 4 deletions src/spo/deepnsm_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ impl ExplicationParser {
for word in ["place", "places", "where", "somewhere"] {
surface_to_prime.insert(word.to_string(), "PLACE".to_string());
}
for word in ["here"] {
{
let word = "here";
surface_to_prime.insert(word.to_string(), "HERE".to_string());
}
for word in ["above", "over"] {
Expand Down Expand Up @@ -416,7 +417,8 @@ impl ExplicationParser {
for word in ["two", "2"] {
surface_to_prime.insert(word.to_string(), "TWO".to_string());
}
for word in ["some"] {
{
let word = "some";
surface_to_prime.insert(word.to_string(), "SOME".to_string());
}
for word in ["all", "every", "everything"] {
Expand All @@ -430,15 +432,17 @@ impl ExplicationParser {
for word in ["very", "really"] {
surface_to_prime.insert(word.to_string(), "VERY".to_string());
}
for word in ["more"] {
{
let word = "more";
surface_to_prime.insert(word.to_string(), "MORE".to_string());
}

// Similarity
for word in ["like", "similar"] {
surface_to_prime.insert(word.to_string(), "LIKE".to_string());
}
for word in ["same"] {
{
let word = "same";
surface_to_prime.insert(word.to_string(), "THE_SAME".to_string());
}
for word in ["other", "another", "else"] {
Expand Down
4 changes: 1 addition & 3 deletions src/spo/jina_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//!
//! Actual API integration for jina-embeddings-v3

use std::io::{Read, Write};
use std::net::TcpStream;

const JINA_API_URL: &str = "api.jina.ai";
const JINA_EMBED_ENDPOINT: &str = "/v1/embeddings";
Expand Down Expand Up @@ -43,7 +41,7 @@ impl JinaClient {
);

// HTTP request (simplified - in production use reqwest or similar)
let request = format!(
let _request = format!(
"POST {} HTTP/1.1\r\n\
Host: {}\r\n\
Authorization: Bearer {}\r\n\
Expand Down
1 change: 0 additions & 1 deletion src/spo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ mod spo;

pub use jina_api::{JinaClient, jina_embed_curl};
pub use jina_cache::JinaCache;
pub use spo::*;
4 changes: 2 additions & 2 deletions src/spo/nsm_substrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl NsmCodebook {
let mut result = fp.clone();

// Project out each prime that has high correlation
for (_, prime_fp) in &self.primes {
for prime_fp in self.primes.values() {
let sim = result.similarity(prime_fp);
if sim > 0.7 {
// Flip overlapping bits probabilistically
Expand All @@ -399,7 +399,7 @@ impl NsmCodebook {
}

// Project out learned concepts too
for (_, (learned_fp, _)) in &self.learned {
for (learned_fp, _) in self.learned.values() {
let sim = result.similarity(learned_fp);
if sim > 0.7 {
result = project_out(&result, learned_fp, 0.3);
Expand Down
2 changes: 1 addition & 1 deletion src/spo/sentence_crystal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
//! ```

use super::context_crystal::QualiaVector;
use super::nsm_substrate::{MetacognitiveSubstrate, NsmCodebook};
use super::nsm_substrate::NsmCodebook;
use crate::core::Fingerprint;
use crate::storage::bind_space::{Addr, BindSpace, dn_path_to_addr};
use std::collections::HashMap;
Expand Down
4 changes: 2 additions & 2 deletions src/spo/shift_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
use rustynum_bnn::causal_trajectory::{
ShiftDetector as BnnShiftDetector, ShiftDirection, ShiftSignal, StripeHistogram,
};
use rustynum_core::{CollapseGate, SigmaGate, SignificanceLevel};
use rustynum_core::{CollapseGate, SigmaGate};

use super::spo_harvest::{Plane, SpoDistanceResult};
use super::spo_harvest::SpoDistanceResult;

// =============================================================================
// SPO SHIFT DETECTOR — wraps BNN ShiftDetector with SPO-specific logic
Expand Down
12 changes: 5 additions & 7 deletions src/spo/spo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
//! - 3D cubic popcount for tensor similarity

use rand::prelude::*;
use rayon::prelude::*;
use std::collections::HashMap;
use std::time::Instant;

// ============================================================================
// Constants
Expand Down Expand Up @@ -40,7 +38,7 @@ impl Fingerprint {
let mut rng = rand::rng();
let mut data = [0u64; N64];
for w in &mut data {
*w = rng.r#gen();
*w = rng.random();
}
Self { data }
}
Expand All @@ -49,7 +47,7 @@ impl Fingerprint {
let mut rng = rand::rngs::StdRng::seed_from_u64(seed);
let mut data = [0u64; N64];
for w in &mut data {
*w = rng.r#gen();
*w = rng.random();
}
Self { data }
}
Expand Down Expand Up @@ -131,7 +129,7 @@ impl Fingerprint {
let mut rng = rand::rng();
for i in 0..N64 {
for bit in 0..64 {
if (overlap.data[i] >> bit) & 1 == 1 && rng.r#gen::<f64>() < flip_prob {
if (overlap.data[i] >> bit) & 1 == 1 && rng.random::<f64>() < flip_prob {
result.data[i] ^= 1 << bit;
}
}
Expand Down Expand Up @@ -406,7 +404,7 @@ impl TruthValue {

/// Expectation: weighted frequency
fn expectation(&self) -> f64 {
(self.confidence * self.frequency + (1.0 - self.confidence) * 0.5)
self.confidence * self.frequency + (1.0 - self.confidence) * 0.5
}

/// Revision: combine two truth values about same statement
Expand Down Expand Up @@ -1558,7 +1556,7 @@ fn test_jina_cache() {
println!();

// Show efficiency
let unique_count = 12; // Actual unique base entities
let _unique_count = 12; // Actual unique base entities
let total_lookups = entities.len();
println!(" Without cache: {} API calls", total_lookups);
println!(" With cache: {} API calls", cache.stats.api_calls);
Expand Down
2 changes: 1 addition & 1 deletion src/spo/spo_harvest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use rustynum_bnn::{
use rustynum_bnn::causal_trajectory::{
CausalRelation, SigmaEdge, SigmaNode,
};
use rustynum_core::{CollapseGate, SigmaGate, SignificanceLevel};
use rustynum_core::{SigmaGate, SignificanceLevel};

use crate::nars::TruthValue;

Expand Down
3 changes: 2 additions & 1 deletion src/storage/bind_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,8 @@ impl BindSpace {
let slices: Vec<&[u8]> = nodes.iter()
.map(|n| crate::core::rustynum_accel::view_u64_as_bytes(&n.fingerprint))
.collect();
let result_bytes = rustynum_rs::NumArrayU8::bundle_byte_slices(&slices);
let result_bytes = rustynum_rs::NumArrayU8::try_bundle_byte_slices(&slices)
.expect("bundle_byte_slices: all slices same length");
let mut fp = [0u64; FINGERPRINT_WORDS];
for (i, chunk) in result_bytes.chunks_exact(8).enumerate() {
fp[i] = u64::from_ne_bytes(chunk.try_into().unwrap());
Expand Down
Loading
Loading