JosephStoneCellAI commited on
Commit
8e0fe4e
·
verified ·
1 Parent(s): d37b0ea

Upload 2 files

Browse files

memory upgrade. future upgrade. set paths to absolutes. to avoid security breach

Files changed (2) hide show
  1. src/gate.rs +5 -0
  2. src/mcp.rs +54 -0
src/gate.rs CHANGED
@@ -217,6 +217,7 @@ pub fn process(
217
  // ── TIER D — Bounded inference ─────────────────────────────────────────
218
  "spf_transformer_infer" | "spf_transformer_chat" | "spf_transformer_train"
219
  | "spf_flint_train_evil" | "spf_flint_train_good"
 
220
  => validate::validate_transformer_ops(params, config),
221
 
222
  // ── TIER E+ — Brain write (source-gated) ────────────────────────────
@@ -288,6 +289,10 @@ pub fn process(
288
  let content = params.content.as_deref().unwrap_or("");
289
  inspect::inspect_content(content, file_path, config)
290
  }
 
 
 
 
291
  _ => validate::ValidationResult::ok(),
292
  };
293
 
 
217
  // ── TIER D — Bounded inference ─────────────────────────────────────────
218
  "spf_transformer_infer" | "spf_transformer_chat" | "spf_transformer_train"
219
  | "spf_flint_train_evil" | "spf_flint_train_good"
220
+ | "spf_flint_store"
221
  => validate::validate_transformer_ops(params, config),
222
 
223
  // ── TIER E+ — Brain write (source-gated) ────────────────────────────
 
289
  let content = params.content.as_deref().unwrap_or("");
290
  inspect::inspect_content(content, file_path, config)
291
  }
292
+ "spf_flint_store" => {
293
+ let content = params.text.as_deref().unwrap_or("");
294
+ inspect::inspect_content(content, "brain_store:text", config)
295
+ }
296
  _ => validate::ValidationResult::ok(),
297
  };
298
 
src/mcp.rs CHANGED
@@ -393,6 +393,17 @@ pub fn tool_definitions() -> Vec<Value> {
393
  }),
394
  vec!["text"],
395
  ),
 
 
 
 
 
 
 
 
 
 
 
396
 
397
  // ====== ADDITIONAL BRAIN TOOLS ======
398
  tool_def(
@@ -821,6 +832,7 @@ pub fn tool_alias_map(name: &str) -> &str {
821
  "bash" => "Bash", "glob" => "Glob", "grep" => "Grep",
822
  "calculate" => "spf_calculate", "status" => "spf_status", "session" => "spf_session",
823
  "brain_search" => "spf_brain_search", "brain_store" => "spf_brain_store",
 
824
  "brain_context" => "spf_brain_context", "brain_index" => "spf_brain_index",
825
  "brain_list" => "spf_brain_list", "brain_status" => "spf_brain_status",
826
  "brain_recall" => "spf_brain_recall", "brain_list_docs" => "spf_brain_list_docs",
@@ -2330,6 +2342,48 @@ pub fn handle_tool_call(
2330
  json!({"type": "text", "text": output})
2331
  }
2332
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2333
  // ====== spf_brain_context ======
2334
  "spf_brain_context" => {
2335
  let query = args["query"].as_str().unwrap_or("");
 
393
  }),
394
  vec!["text"],
395
  ),
396
+ tool_def(
397
+ "spf_flint_store",
398
+ "Agent memory store through FLINT pipeline. Bypasses brain write gate. Stores in brain vectors + FLINT Working tier for memory lifecycle.",
399
+ json!({
400
+ "text": {"type": "string", "description": "Text to store"},
401
+ "title": {"type": "string", "description": "Document title", "default": "untitled"},
402
+ "collection": {"type": "string", "description": "Collection (default: default)", "default": "default"},
403
+ "tags": {"type": "string", "description": "Comma-separated tags", "default": ""}
404
+ }),
405
+ vec!["text"],
406
+ ),
407
 
408
  // ====== ADDITIONAL BRAIN TOOLS ======
409
  tool_def(
 
832
  "bash" => "Bash", "glob" => "Glob", "grep" => "Grep",
833
  "calculate" => "spf_calculate", "status" => "spf_status", "session" => "spf_session",
834
  "brain_search" => "spf_brain_search", "brain_store" => "spf_brain_store",
835
+ "flint_store" => "spf_flint_store",
836
  "brain_context" => "spf_brain_context", "brain_index" => "spf_brain_index",
837
  "brain_list" => "spf_brain_list", "brain_status" => "spf_brain_status",
838
  "brain_recall" => "spf_brain_recall", "brain_list_docs" => "spf_brain_list_docs",
 
2342
  json!({"type": "text", "text": output})
2343
  }
2344
 
2345
+ // ====== spf_flint_store ======
2346
+ "spf_flint_store" => {
2347
+ let text = args["text"].as_str().unwrap_or("");
2348
+ let title = args["title"].as_str().unwrap_or("untitled");
2349
+ let collection = args["collection"].as_str().unwrap_or("default");
2350
+ let tags_str = args["tags"].as_str().unwrap_or("");
2351
+
2352
+ session.record_action("flint_store", "called", None);
2353
+
2354
+ // Strike 1: Brain store — vector storage for semantic search
2355
+ let brain_result = crate::brain_local::brain_store(text, title, collection);
2356
+
2357
+ // Strike 2: Working memory — enables tiered promotion lifecycle
2358
+ let working_result = if let Some(ref db) = agent_db {
2359
+ let summary: String = text.chars().take(500).collect();
2360
+ let tags: Vec<String> = if tags_str.is_empty() {
2361
+ vec![
2362
+ "tool:spf_flint_store".to_string(),
2363
+ "source:flint_store".to_string(),
2364
+ format!("collection:{}", collection),
2365
+ ]
2366
+ } else {
2367
+ let mut t: Vec<String> = tags_str.split(',')
2368
+ .map(|s| s.trim().to_string())
2369
+ .filter(|s| !s.is_empty())
2370
+ .collect();
2371
+ t.push("tool:spf_flint_store".to_string());
2372
+ t.push("source:flint_store".to_string());
2373
+ t
2374
+ };
2375
+ match db.create_memory(&summary, crate::agent_state::MemoryType::Working, tags, "flint_store") {
2376
+ Ok(id) => format!("Working memory created: {}", id),
2377
+ Err(e) => format!("Working memory error: {}", e),
2378
+ }
2379
+ } else {
2380
+ "Agent state DB not available — brain-only store".to_string()
2381
+ };
2382
+
2383
+ let _ = storage.save_session(session);
2384
+ json!({"type": "text", "text": format!("{}\n{}", brain_result, working_result)})
2385
+ }
2386
+
2387
  // ====== spf_brain_context ======
2388
  "spf_brain_context" => {
2389
  let query = args["query"].as_str().unwrap_or("");