// brain_index_training — Index pruned training data to FLINT brain // Copyright 2026 Joseph Stone — All Rights Reserved // // Links against spf_smart_gate to use brain_local::brain_store() directly. // Indexes 3,908 training entries from brain_index_pruned.jsonl to brain. // // Usage: cargo run --bin brain_index_training use serde::Deserialize; use std::fs::File; use std::io::{BufRead, BufReader}; #[derive(Debug, Deserialize)] #[allow(dead_code)] struct BrainEntry { label: i32, source: String, text: String, tool: String, weight: f32, } fn main() { let collection = "flint_episodic"; let input_path = "/data/data/com.termux/files/home/SPFsmartGATE/LIVE/TMP/stoneshell-brain/training_data/raw/brain_index_pruned.jsonl"; println!("[*] brain_index_training — Index training data to brain"); println!("[*] Input: {}", input_path); println!("[*] Collection: {}", collection); println!(""); // Initialize brain (same as main SPF binary does) spf_smart_gate::brain_local::init_brain(); println!("[+] Brain initialized"); // Read JSONL let file = File::open(&input_path).expect("Failed to open input file"); let reader = BufReader::new(file); let mut count = 0; let mut success = 0; let mut error_count = 0; for line in reader.lines() { let line = line.expect("Failed to read line"); if line.trim().is_empty() { continue; } match serde_json::from_str::(&line) { Ok(entry) => { // Create title from label + tool let title = format!("[{:+}] {}", entry.label, entry.tool); // Call brain_store directly let result = spf_smart_gate::brain_local::brain_store(&entry.text, &title, collection); count += 1; if result.starts_with("Error") || result.starts_with("Failed") { error_count += 1; if error_count <= 5 { println!(" [!] Entry {} error: {}", count, result); } } else { success += 1; } if count % 500 == 0 { println!(" Processed: {}/{} (success: {}, errors: {})", count, count, success, error_count); } } Err(e) => { error_count += 1; if error_count <= 5 { println!(" [!] Parse error: {}", e); } } } } println!("\n[=] INDEXING COMPLETE"); println!(" Total entries: {}", count); println!(" Success: {}", success); println!(" Errors: {}", error_count); println!("\n Training data indexed to 'flint_episodic' collection"); println!(" FLINT can now recall these patterns on similar queries"); }