Update README.md
Browse files
README.md
CHANGED
|
@@ -1,275 +1,690 @@
|
|
| 1 |
-
---
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
- en
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
---
|
| 6 |
-
# SPF Smart Gateway
|
| 7 |
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
root for spf smart gate runtime
|
| 13 |
-
home/SPFsmartGATE
|
| 14 |
-
home/SWARMagents/1/SPFsmartGATE ~ CLONES
|
| 15 |
-
copy all files to SPFsmartGATE
|
| 16 |
cd SPFsmartGATE
|
| 17 |
-
cargo
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
cd
|
| 21 |
cp ~/SPFsmartGATE/target/release/spf-smart-gate ~/SPFsmartGATE/LIVE/BIN/spf-smart-gate
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
~/SPFsmartGATE/LIVE/LMDB5/.claude
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
ENTERPRISE GRADE AUDITING SYSTEM INCLUDING CMD LOG
|
| 48 |
-
MESH NETWORK. WORKS. NEEDS MORE TESTING. MEMORY TRIAD BUILD
|
| 49 |
-
FOR PERSISTENCE. ON LMDB USING HEED. EXTREMELY FAST AND LIGHTWEIGHT
|
| 50 |
-
THAT CREATES REAL MEMORY. CLAUDE CLI IS BUILT IN. CURRENT
|
| 51 |
-
SETUP ALLOWS FOR NATIVE CLAUDE CLI USE. OR ROUTING CLAUDE OR
|
| 52 |
-
ANY OTHER MODEL THROUGH THE CLAUDE CLI, AND THEN THE GATEWAY. MAKES IT
|
| 53 |
-
EASY TO SWAP AGENTS WITHOUT NEEDING TO CHANGE SESSIONS OR LOOSE PROJECT
|
| 54 |
-
DATA. USING OPENROUTER FOR API AND AGENT SELECTION.
|
| 55 |
-
AND A LOT MORE . I NEED TO VARIFY I CAN DOWNLOAD AND INSTALL ON MY OTHER DEVICE
|
| 56 |
-
FROM HERE. FOR TESTING. PARTOF THE TRANSFORMER I CANT UPLOAD. AND ...
|
| 57 |
-
CURRENT 50 DAY SESSION ON MY ANDROID PHONE USING THIS GATEWAY
|
| 58 |
-
JUST GETTING IT READY TO SHARE WITH YOU ALL
|
| 59 |
-
OPEN SOURCE. ENTIRE SOURCE CODE GETS REFRESHED INTO
|
| 60 |
-
TRANSFORMER RAG SYSTEM EVERY REBOOT
|
| 61 |
-
INSTALL IN HOME FOLDER. MAKE SURE ALL FILE PATH ARE
|
| 62 |
-
CORRECT IN .mcp.json settings.local.json and so on.
|
| 63 |
-
THE SETTINGS FILES ARE UPLOADED AND IN THE RIGHT LOCATION
|
| 64 |
-
SPF SMART GATE HAS 2 AGENT RUN TIMES. FLAT FILES. AND LMDB.DB
|
| 65 |
-
TWIN FOLDER. WHERE ALL FLAT FILE DATA CAN BE UPLOADED VIA SPF CLI
|
| 66 |
-
FS CLI TOOLS ARE USER ONLY ACCESS. TO BOOT CLI INTO SPF FLAT FILES
|
| 67 |
-
cd SPFsmartGATE/LIVE/LMDB5 claude
|
| 68 |
-
to boot into binary
|
| 69 |
-
cd SPFsmartGATE/LIVE/LMDB5.DB claude
|
| 70 |
-
expect updates
|
| 71 |
-
also. I'm 1 dev
|
| 72 |
-
NOT ALL FEATURES COMPLETE
|
| 73 |
-
GATEWAY SECURITY LATER 100%
|
| 74 |
-
ALL NEEDED TOOLS PLUS ALSO 100%
|
| 75 |
|
| 76 |
---
|
| 77 |
|
| 78 |
## Overview
|
| 79 |
|
| 80 |
-
SPF Smart Gateway is a Rust-based MCP (Model Context Protocol) server that acts as a
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
|
| 86 |
-
- **
|
| 87 |
-
- **
|
| 88 |
-
- **
|
| 89 |
-
- **
|
| 90 |
-
- **
|
| 91 |
-
- **
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
## The SPF Formula
|
| 95 |
|
| 96 |
### Complexity Calculation
|
|
|
|
| 97 |
```
|
| 98 |
-
C = (basic ^ 1) + (dependencies ^ 7) + (complex ^ 10) + (files ×
|
| 99 |
```
|
| 100 |
|
| 101 |
-
###
|
|
|
|
| 102 |
```
|
| 103 |
a_optimal(C) = W_eff × (1 - 1/ln(C + e))
|
| 104 |
```
|
|
|
|
| 105 |
Where `W_eff = 40,000` tokens and `e = Euler's number`
|
| 106 |
|
| 107 |
### Tier Allocation
|
| 108 |
|
| 109 |
-
| Tier | C
|
| 110 |
-
|------|---------|---------|-------|----------|
|
| 111 |
-
| SIMPLE | < 500 | 40% | 60% | No |
|
| 112 |
-
| LIGHT | <
|
| 113 |
-
| MEDIUM | <
|
| 114 |
-
| CRITICAL | >
|
| 115 |
|
| 116 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
| Tool | Description |
|
| 119 |
|------|-------------|
|
| 120 |
-
| `
|
| 121 |
-
| `
|
| 122 |
-
| `
|
| 123 |
-
| `spf_session` | Full session state dump |
|
| 124 |
-
| `spf_read` | Gated file read (tracks Build Anchor) |
|
| 125 |
-
| `spf_write` | Gated file write (validates anchor, paths, size) |
|
| 126 |
-
| `spf_edit` | Gated file edit (validates anchor, paths) |
|
| 127 |
-
| `spf_bash` | Gated bash execution (validates commands) |
|
| 128 |
-
| `spf_brain_search` | Search brain through gateway |
|
| 129 |
-
| `spf_brain_store` | Store to brain through gateway |
|
| 130 |
|
| 131 |
-
##
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
``
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
-
|
| 139 |
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
``
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
-
###
|
| 148 |
-
```bash
|
| 149 |
-
# Check status
|
| 150 |
-
./spf-gateway status
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
-
#
|
| 156 |
-
./spf-gateway reset
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
-
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
``
|
|
|
|
|
|
|
| 167 |
|
| 168 |
-
##
|
| 169 |
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
-
|
| 173 |
-
{
|
| 174 |
-
"enforce_mode": "soft",
|
| 175 |
-
"blocked_paths": ["/tmp", "/etc", "/usr", "/system"],
|
| 176 |
-
"allowed_paths": ["/storage/emulated/0/Download/api-workspace/"],
|
| 177 |
-
"require_read_before_edit": true,
|
| 178 |
-
"max_write_size": 100000
|
| 179 |
-
}
|
| 180 |
-
```
|
| 181 |
|
| 182 |
-
|
| 183 |
-
-
|
| 184 |
-
|
|
|
|
|
|
|
| 185 |
|
| 186 |
-
##
|
| 187 |
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
"args": ["serve"]
|
| 197 |
-
}
|
| 198 |
-
}
|
| 199 |
-
}
|
| 200 |
-
```
|
| 201 |
|
| 202 |
-
##
|
| 203 |
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
-
|
| 207 |
-
- `spf_edit` and `spf_write` check against this list
|
| 208 |
-
- Violations are blocked (hard mode) or warned (soft mode)
|
| 209 |
|
| 210 |
-
|
|
|
|
|
|
|
| 211 |
|
| 212 |
-
|
| 213 |
-
- `/tmp` — Termux Android restriction
|
| 214 |
-
- `/etc` — System configuration
|
| 215 |
-
- `/usr` — System binaries
|
| 216 |
-
- `/system` — Android system partition
|
| 217 |
-
- `/data/data/com.termux/files/usr` — Termux packages
|
| 218 |
|
| 219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
```
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
```
|
| 235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
## File Structure
|
| 237 |
|
| 238 |
```
|
| 239 |
SPFsmartGATE/
|
| 240 |
-
├── Cargo.toml
|
| 241 |
-
├── LICENSE
|
| 242 |
-
├── README.md
|
| 243 |
-
├──
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
```
|
| 255 |
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
**Free and Open source**
|
| 259 |
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
|
|
|
|
| 262 |
|
| 263 |
-
|
| 264 |
|
| 265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
|
| 267 |
-
|
| 268 |
|
| 269 |
-
|
| 270 |
-
- Email: joepcstone@gmail.com
|
| 271 |
|
|
|
|
| 272 |
|
| 273 |
-
|
|
|
|
| 274 |
|
| 275 |
-
*SPF (StoneCell Processing Formula)
|
|
|
|
| 1 |
+
README.md---
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
+
tags:
|
| 6 |
+
- mcp-server
|
| 7 |
+
- ai-gateway
|
| 8 |
+
- security
|
| 9 |
+
- rust
|
| 10 |
+
- agent-framework
|
| 11 |
+
- tool-enforcement
|
| 12 |
+
- lmdb
|
| 13 |
+
- rag
|
| 14 |
+
- transformer
|
| 15 |
+
- mesh-network
|
| 16 |
+
- voice
|
| 17 |
+
- android
|
| 18 |
+
- termux
|
| 19 |
+
- self-hosted
|
| 20 |
+
- ai-safety
|
| 21 |
+
- memory-system
|
| 22 |
+
- flint
|
| 23 |
+
- build-anchor
|
| 24 |
+
- complexity-formula
|
| 25 |
+
- agent-memory
|
| 26 |
+
- p2p
|
| 27 |
+
- quic
|
| 28 |
+
- heed
|
| 29 |
+
- self-learning
|
| 30 |
+
- harness
|
| 31 |
+
- ai-memory
|
| 32 |
+
- persistent-memory
|
| 33 |
+
- online-learning
|
| 34 |
+
- agent-tools
|
| 35 |
+
- tool-gateway
|
| 36 |
+
- web-automation
|
| 37 |
+
- browser-automation
|
| 38 |
+
- social-media
|
| 39 |
+
- p2p-communication
|
| 40 |
+
- voice-synthesis
|
| 41 |
+
- tts
|
| 42 |
+
- embedded-database
|
| 43 |
+
- zero-copy
|
| 44 |
+
- code-search
|
| 45 |
+
- filesystem
|
| 46 |
+
- git
|
| 47 |
+
- database
|
| 48 |
+
pipeline_tag: text-generation
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
```
|
| 52 |
+
_____ _____ ______ _____ __ __ _____ _______ _____ _______ ______
|
| 53 |
+
/ ____| __ \| ____| / ____| \/ | /\ | __ \__ __| / ____| /\|__ __| ____|
|
| 54 |
+
| (___ | |__) | |__ | (___ | \ / | / \ | |__) | | | | | __ / \ | | | |__
|
| 55 |
+
\___ \| ___/| __| \___ \| |\/| | / /\ \ | _ / | | | | |_ | / /\ \ | | | __|
|
| 56 |
+
____) | | | | ____) | | | |/ ____ \| | \ \ | | | |__| |/ ____ \| | | |____
|
| 57 |
+
|_____/|_| |_| |_____/|_| |_/_/ \_\_| \_\ |_| \_____/_/ \_\_| |______|
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
# SPF Smart Gateway v3.0.0
|
| 63 |
+
|
| 64 |
+
**MCP Server Gateway with Multi-Layer Security Enforcement, Agent Memory, FLINT Transformer, Mesh Network, and 81 Gated Tools**
|
| 65 |
+
|
| 66 |
+
> **NOTE: Full system upload still in progress.** Not all files are present yet. Repository is actively being populated — some modules may be missing until upload completes.
|
| 67 |
+
|
| 68 |
+
Copyright (C) 2026 Joseph Stone — All Rights Reserved
|
| 69 |
+
|
| 70 |
---
|
|
|
|
| 71 |
|
| 72 |
+
## Quick Start
|
| 73 |
|
| 74 |
+
```bash
|
| 75 |
+
# Clone into home folder
|
| 76 |
+
git clone <repo-url> ~/SPFsmartGATE
|
| 77 |
+
# Or for clones/SWARMagents:
|
| 78 |
+
# ~/SWARMagents/1/SPFsmartGATE
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
cd SPFsmartGATE
|
| 81 |
+
cargo build --release
|
| 82 |
+
|
| 83 |
+
# Copy optimized binary
|
|
|
|
| 84 |
cp ~/SPFsmartGATE/target/release/spf-smart-gate ~/SPFsmartGATE/LIVE/BIN/spf-smart-gate
|
| 85 |
+
|
| 86 |
+
# Configure MCP server filepath
|
| 87 |
+
nano ~/SPFsmartGATE/LIVE/LMDB5/.mcp.json
|
| 88 |
+
|
| 89 |
+
# Install Claude CLI in project directory
|
| 90 |
+
# Use included configs, deny native Claude CLI tools
|
| 91 |
+
# ~/SPFsmartGATE/LIVE/LMDB5/.claude.json
|
| 92 |
+
# ~/SPFsmartGATE/LIVE/LMDB5/.claude/settings.json
|
| 93 |
+
|
| 94 |
+
# Boot into flat-file agent runtime
|
| 95 |
+
cd ~/SPFsmartGATE/LIVE/LMDB5 && claude
|
| 96 |
+
|
| 97 |
+
# Boot into LMDB-backed agent runtime
|
| 98 |
+
cd ~/SPFsmartGATE/LIVE/LMDB5.DB && claude
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
### Route Other Models Through Claude CLI
|
| 102 |
+
|
| 103 |
+
Adjust `~/SPFsmartGATE/LIVE/LMDB5/.claude/settings.local.json` with your model choice and API key. Uses OpenRouter for API and agent selection. Swap agents without changing sessions or losing project data.
|
| 104 |
+
|
| 105 |
+
### Build Notes
|
| 106 |
+
|
| 107 |
+
- Cross-compiles on **Android** and **Linux** with minimal installation
|
| 108 |
+
- Only rebuild on first boot or after system modifications
|
| 109 |
+
- Binary: `~/SPFsmartGATE/LIVE/BIN/spf-smart-gate/spf-smart-gate`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
---
|
| 112 |
|
| 113 |
## Overview
|
| 114 |
|
| 115 |
+
SPF Smart Gateway is a **Rust-based MCP (Model Context Protocol) server** that acts as a security gateway for AI tool calls. Every file operation, bash command, brain query, and mesh call routes through compiled Rust enforcement logic.
|
| 116 |
+
|
| 117 |
+
**No AI hallucination gets past the gate.**
|
| 118 |
|
| 119 |
+
### Why Heed + LMDB
|
| 120 |
|
| 121 |
+
All persistent storage — config, agent state, brain vectors, session logs, gate training data — runs through **[heed](https://github.com/meilisearch/heed)**, a safe Rust wrapper over LMDB. This is what makes SPF extremely fast with a low memory footprint:
|
| 122 |
|
| 123 |
+
- **Zero-copy reads** — heed maps LMDB pages directly into memory, no serialization overhead
|
| 124 |
+
- **No server process** — LMDB is a memory-mapped B-tree library, not a database daemon
|
| 125 |
+
- **ACID transactions** — single-writer, multi-reader with no lock contention on reads
|
| 126 |
+
- **Sub-millisecond lookups** — B-tree index, not hash scanning
|
| 127 |
+
- **Tiny footprint** — entire 138K+ memory store runs in-process with minimal RAM
|
| 128 |
+
- **Phone-friendly** — designed for Android from day one; heed compiles cleanly on ARM64
|
| 129 |
+
|
| 130 |
+
Every tool call, brain search, and memory promotion goes through heed → LMDB. No network hops, no subprocess calls, no SQL parsing. The gate, brain, agent state, and FLINT training all share the same embedded database engine.
|
| 131 |
+
|
| 132 |
+
Two agent runtimes:
|
| 133 |
+
- **Flat files** — `LIVE/LMDB5/` (session state in markdown)
|
| 134 |
+
- **LMDB database** — `LIVE/LMDB5.DB/` (session state in LMDB for persistence)
|
| 135 |
+
|
| 136 |
+
Twin folder architecture: flat-file data uploaded via SPF CLI fs tools (user-only access). All agent tool calls are gated, validated, and audited.
|
| 137 |
+
|
| 138 |
+
---
|
| 139 |
+
|
| 140 |
+
## Architecture
|
| 141 |
+
|
| 142 |
+
```
|
| 143 |
+
┌─────────────────────────────────────────────────────────────────┐
|
| 144 |
+
│ SPF Smart Gateway v3.0.0 │
|
| 145 |
+
│ 42 Rust modules │
|
| 146 |
+
├─────────────────────────────────────────────────────────────────┤
|
| 147 |
+
│ MCP Server (JSON-RPC 2.0 over stdio) │
|
| 148 |
+
│ 81 tools │ tool alias map │ Qwen/LLM compatibility │
|
| 149 |
+
├─────────────────────────────────────────────────────────────────┤
|
| 150 |
+
│ GATE (6-Step Pipeline) │
|
| 151 |
+
│ Step 0: Source logging │
|
| 152 |
+
│ Step 1: Rate limiting │
|
| 153 |
+
│ Step 2: Complexity calculation (SPF formula) │
|
| 154 |
+
│ Step 3: Validation (per-tool: paths, commands, Build Anchor) │
|
| 155 |
+
│ Step 4: Content inspection (credentials, injection) │
|
| 156 |
+
│ Step 5: Max mode escalation │
|
| 157 |
+
├──────────┬──────────┬──────────┬──────────┬─────────────────────┤
|
| 158 |
+
│ FLINT │ Brain │ Mesh │ Voice │ Browser/RAG │
|
| 159 |
+
│ (encoder-│ (vectors │ (P2P QUIC│ (TTS/STT │ (reverse proxy │
|
| 160 |
+
│ decoder │ LMDB + │ Ed25519 │ espeak- │ search, fetch, │
|
| 161 |
+
│ ~5M │ MiniLM) │ iroh) │ ng FFI) │ RSS, web tools) │
|
| 162 |
+
│ params) │ │ │ │ │
|
| 163 |
+
├──────────┴──────────┴──────────┴──────────┴─────────────────────┤
|
| 164 |
+
│ LMDB Storage Layer (heed) │
|
| 165 |
+
│ SPF_CONFIG │ TMP_DB │ AGENT_STATE │ Brain │ Gate Training │
|
| 166 |
+
│ All zero-copy reads via heed safe Rust bindings │
|
| 167 |
+
└─────────────────────────────────────────────────────────────────┘
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
### Module Inventory (42 modules)
|
| 171 |
+
|
| 172 |
+
`paths`, `calculate`, `config`, `gate`, `inspect`, `mcp`, `session`, `storage`, `validate`, `web`, `http`, `dispatch`, `identity`, `mesh`, `fs`, `config_db`, `tmp_db`, `agent_state`, `tensor`, `tokenizer`, `framing`, `attention`, `ffn`, `encoder`, `decoder`, `transformer`, `checkpoint`, `gate_training`, `transformer_tools`, `train`, `learning`, `pipeline`, `worker`, `network`, `chat`, `voice`, `utf8_safe`, `brain_local`, `flint_memory`, `browser`, `orchestrator`, `channel`
|
| 173 |
+
|
| 174 |
+
---
|
| 175 |
|
| 176 |
## The SPF Formula
|
| 177 |
|
| 178 |
### Complexity Calculation
|
| 179 |
+
|
| 180 |
```
|
| 181 |
+
C = (basic ^ 1) + (dependencies ^ 7) + (complex ^ 10) + (files × 10)
|
| 182 |
```
|
| 183 |
|
| 184 |
+
### Dynamic Analysis Allocation
|
| 185 |
+
|
| 186 |
```
|
| 187 |
a_optimal(C) = W_eff × (1 - 1/ln(C + e))
|
| 188 |
```
|
| 189 |
+
|
| 190 |
Where `W_eff = 40,000` tokens and `e = Euler's number`
|
| 191 |
|
| 192 |
### Tier Allocation
|
| 193 |
|
| 194 |
+
| Tier | C Range | Analyze | Build | Verify Passes | Approval |
|
| 195 |
+
|------|---------|---------|-------|---------------|----------|
|
| 196 |
+
| SIMPLE | < 500 | 40% | 60% | 1 | No |
|
| 197 |
+
| LIGHT | < 2,000 | 60% | 40% | 1 | No |
|
| 198 |
+
| MEDIUM | < 10,000 | 75% | 25% | 2 | No |
|
| 199 |
+
| CRITICAL | > 10,000 | 95% | 5% | 3 | **Required** |
|
| 200 |
|
| 201 |
+
### Master Equation (Subtask Success)
|
| 202 |
+
|
| 203 |
+
```
|
| 204 |
+
P(success) = 1 - PRODUCT(1 - P_i) for i=1..D subtasks
|
| 205 |
+
P_i = Q(a) × L(m) × V(v) × B(b)
|
| 206 |
+
|
| 207 |
+
Q(a) = 1 - e^(-0.00004 × a) — Quality from analysis depth
|
| 208 |
+
L(m) = 1 - 0.20^(m/2000) — Lookup from external memory
|
| 209 |
+
V(v) = 1 - (1 - 0.75)^v — Verification accuracy
|
| 210 |
+
B(b) = checks_done / checks_required — Build Anchor compliance
|
| 211 |
+
```
|
| 212 |
+
|
| 213 |
+
---
|
| 214 |
+
|
| 215 |
+
## Security
|
| 216 |
+
|
| 217 |
+
### Gate Enforcement (6 Steps)
|
| 218 |
+
|
| 219 |
+
Every tool call passes through `gate::process()` — compiled Rust, no runtime bypass.
|
| 220 |
+
|
| 221 |
+
| Step | What | How |
|
| 222 |
+
|------|------|-----|
|
| 223 |
+
| 0 | Source logging | Identifies caller (Stdio, Transformer, Mesh, HTTP) |
|
| 224 |
+
| 1 | Rate limiting | Per-tool limits (30–120 calls/min) |
|
| 225 |
+
| 2 | Complexity calc | SPF formula → C value, tier, allocation |
|
| 226 |
+
| 3 | Validation | Per-tool validator (paths, commands, anchors) |
|
| 227 |
+
| 4 | Content inspection | Credential patterns, shell injection, path traversal |
|
| 228 |
+
| 5 | Max mode | Escalation to CRITICAL tier on warnings |
|
| 229 |
+
|
| 230 |
+
### Build Anchor Protocol
|
| 231 |
+
|
| 232 |
+
Files must be **read before they can be edited or overwritten**. Prevents AI hallucinations from blindly modifying files without understanding contents.
|
| 233 |
+
|
| 234 |
+
- `Read` tracks files in `session.files_read`
|
| 235 |
+
- `Edit` and `Write` check against this list
|
| 236 |
+
- `Bash` write-class commands check target file reads
|
| 237 |
+
- Violations: blocked (Max mode) or warned (Soft mode)
|
| 238 |
+
|
| 239 |
+
### Content Inspection
|
| 240 |
+
|
| 241 |
+
Scans written/stored content for:
|
| 242 |
+
- **Credential patterns**: API keys (sk-), AWS keys (AKIA), GitHub tokens (ghp_), Slack tokens, private keys, hardcoded passwords
|
| 243 |
+
- **Shell injection**: Command substitution `$()`, backticks, eval/exec
|
| 244 |
+
- **Path traversal**: `../` sequences
|
| 245 |
+
- **Blocked path references**: Content mentioning system paths
|
| 246 |
+
|
| 247 |
+
### Blocked Paths
|
| 248 |
+
|
| 249 |
+
Default blocked: `/tmp`, `/etc`, `/usr`, `/system`, `/data/data/com.termux/files/usr`
|
| 250 |
+
|
| 251 |
+
### Command Whitelist (Stage 0)
|
| 252 |
+
|
| 253 |
+
Bash commands checked against sandbox and user-filesystem whitelists. Each command segment validated independently. Destructive commands (rm, chmod 777) blocked even if whitelisted.
|
| 254 |
+
|
| 255 |
+
### Default Deny
|
| 256 |
+
|
| 257 |
+
Unknown tools blocked until explicitly added to the gate allowlist.
|
| 258 |
+
|
| 259 |
+
---
|
| 260 |
+
|
| 261 |
+
## MCP Tools (81 Total)
|
| 262 |
+
|
| 263 |
+
### Core Gate Tools
|
| 264 |
|
| 265 |
| Tool | Description |
|
| 266 |
|------|-------------|
|
| 267 |
+
| `spf_calculate` | Calculate complexity score without executing. Returns C value, tier, allocation |
|
| 268 |
+
| `spf_status` | Gateway status: session metrics, enforcement mode, complexity budget |
|
| 269 |
+
| `spf_session` | Full session state: files read/written, action history, anchor ratio |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
|
| 271 |
+
### Gated File Operations
|
| 272 |
|
| 273 |
+
| Tool | Description |
|
| 274 |
+
|------|-------------|
|
| 275 |
+
| `Read` | Gated file read. Tracks for Build Anchor Protocol. Binary-safe |
|
| 276 |
+
| `Write` | Gated file write. Validates Build Anchor, blocked paths, file size |
|
| 277 |
+
| `Edit` | Gated file edit. Validates Build Anchor, blocked paths, change size |
|
| 278 |
+
| `Bash` | Gated bash execution. Validates dangerous commands, /tmp access, git force |
|
| 279 |
+
| `Glob` | Fast file pattern matching. Supports `**/*.rs`, `src/**/*.ts` |
|
| 280 |
+
| `Grep` | Search file contents using regex. Built on ripgrep |
|
| 281 |
|
| 282 |
+
### Brain / Memory Tools
|
| 283 |
|
| 284 |
+
| Tool | Description |
|
| 285 |
+
|------|-------------|
|
| 286 |
+
| `spf_brain_search` | Semantic vector search across collections (MiniLM-L6-v2, 384d) |
|
| 287 |
+
| `spf_brain_recall` | Full document retrieval by semantic query |
|
| 288 |
+
| `spf_brain_context` | Bounded context retrieval for prompt injection |
|
| 289 |
+
| `spf_brain_store` | Store document in brain (FLINT-internal, source-gated) |
|
| 290 |
+
| `spf_flint_store` | Agent memory store — bypasses brain write gate. Brain vectors + Working tier |
|
| 291 |
+
| `spf_brain_index` | Index a file or directory into a brain collection |
|
| 292 |
+
| `spf_brain_list` | List all indexed collections with document counts |
|
| 293 |
+
| `spf_brain_status` | Brain system status: model state, storage size, collections |
|
| 294 |
+
| `spf_brain_list_docs` | List stored documents in a collection |
|
| 295 |
+
| `spf_brain_get_doc` | Retrieve a specific document by ID |
|
| 296 |
+
|
| 297 |
+
### Agent State Tools
|
| 298 |
|
| 299 |
+
| Tool | Description |
|
| 300 |
+
|------|-------------|
|
| 301 |
+
| `spf_agent_stats` | AGENT_STATE LMDB statistics: memory count, sessions, state keys, tags |
|
| 302 |
+
| `spf_agent_memory_search` | Search agent memories by content |
|
| 303 |
+
| `spf_agent_memory_by_tag` | Get agent memories by tag |
|
| 304 |
+
| `spf_agent_session_info` | Most recent session info |
|
| 305 |
+
| `spf_agent_context` | Context summary for session continuity |
|
| 306 |
|
| 307 |
+
### FLINT Transformer Tools
|
|
|
|
|
|
|
|
|
|
| 308 |
|
| 309 |
+
| Tool | Description |
|
| 310 |
+
|------|-------------|
|
| 311 |
+
| `spf_transformer_status` | FLINT transformer status: loaded, params, checkpoint, role |
|
| 312 |
+
| `spf_transformer_infer` | Run inference: prompt → response. Returns generated tokens |
|
| 313 |
+
| `spf_transformer_chat` | Multi-turn conversation with FLINT |
|
| 314 |
+
| `spf_transformer_train` | Trigger manual training batch from accumulated gate signals |
|
| 315 |
+
| `spf_transformer_metrics` | Learning metrics: loss, accuracy, gate alignment, training step |
|
| 316 |
+
| `spf_flint_train_evil` | Mark a tool call as evil/harmful. Negative training signal |
|
| 317 |
+
| `spf_flint_train_good` | Mark a tool call as good/safe. Positive training signal |
|
| 318 |
+
| `spf_flint_execute` | Execute any SPF tool through FLINT worker mode (delegation) |
|
| 319 |
|
| 320 |
+
### Web Browser Tools
|
|
|
|
| 321 |
|
| 322 |
+
| Tool | Description |
|
| 323 |
+
|------|-------------|
|
| 324 |
+
| `spf_web_search` | Search the web (Brave API or DuckDuckGo) |
|
| 325 |
+
| `spf_web_fetch` | Fetch URL and return clean readable text |
|
| 326 |
+
| `spf_web_api` | Make HTTP API requests (GET/POST/PUT/DELETE/PATCH). Supports custom headers and JSON body — agents can directly interact with social media APIs (X/Twitter, Facebook, Instagram, Reddit, etc.) using stored API keys |
|
| 327 |
+
| `spf_web_download` | Download a file from URL and save to disk |
|
| 328 |
+
| `spf_web_connect` | Initialize reverse proxy browser engine |
|
| 329 |
+
| `spf_web_navigate` | Navigate browser to a URL (SSRF-validated) |
|
| 330 |
+
| `spf_web_click` | Click a page element by CSS selector |
|
| 331 |
+
| `spf_web_fill` | Type text into a form field by CSS selector |
|
| 332 |
+
| `spf_web_select` | Query page elements by CSS selector |
|
| 333 |
+
| `spf_web_eval` | Execute JavaScript on the current page |
|
| 334 |
+
| `spf_web_screenshot` | Capture a screenshot of the current page (in development) |
|
| 335 |
+
| `spf_web_design` | Extract design brief: colours, fonts, spacing, components |
|
| 336 |
+
| `spf_web_page` | Structured page overview: title, headings, links, forms |
|
| 337 |
+
|
| 338 |
+
### RAG Collector Tools
|
| 339 |
|
| 340 |
+
| Tool | Description |
|
| 341 |
+
|------|-------------|
|
| 342 |
+
| `spf_rag_collect_web` | Search web and collect documents. Optional topic filter |
|
| 343 |
+
| `spf_rag_collect_file` | Process a local file into brain |
|
| 344 |
+
| `spf_rag_collect_folder` | Process all files in a folder |
|
| 345 |
+
| `spf_rag_collect_drop` | Process files in DROP_HERE folder |
|
| 346 |
+
| `spf_rag_index_gathered` | Index all documents in GATHERED to brain |
|
| 347 |
+
| `spf_rag_dedupe` | Deduplicate a brain collection |
|
| 348 |
+
| `spf_rag_status` | Collector status and stats |
|
| 349 |
+
| `spf_rag_list_gathered` | List documents in GATHERED folder |
|
| 350 |
+
| `spf_rag_bandwidth_status` | Bandwidth usage stats and limits |
|
| 351 |
+
| `spf_rag_fetch_url` | Fetch a single URL with bandwidth limiting |
|
| 352 |
+
| `spf_rag_collect_rss` | Collect from RSS/Atom feeds |
|
| 353 |
+
| `spf_rag_list_feeds` | List configured RSS feeds |
|
| 354 |
+
| `spf_rag_pending_searches` | Get pending SearchSeeker vectors (gaps needing fetch) |
|
| 355 |
+
| `spf_rag_fulfill_search` | Mark a SearchSeeker as fulfilled after RAG fetch |
|
| 356 |
+
| `spf_rag_smart_search` | Smart search with completeness check — triggers SearchSeeker if <80% |
|
| 357 |
+
| `spf_rag_auto_fetch_gaps` | Automatically fetch data for all pending SearchSeekers |
|
| 358 |
+
|
| 359 |
+
### Mesh Network Tools
|
| 360 |
|
| 361 |
+
| Tool | Description |
|
| 362 |
+
|------|-------------|
|
| 363 |
+
| `spf_mesh_status` | Mesh network status: role, team, identity |
|
| 364 |
+
| `spf_mesh_peers` | List known/trusted mesh peers |
|
| 365 |
+
| `spf_mesh_call` | Call a peer agent's tool via P2P mesh (Ed25519 authenticated) |
|
| 366 |
|
| 367 |
+
### Voice Tools
|
| 368 |
|
| 369 |
+
| Tool | Description |
|
| 370 |
+
|------|-------------|
|
| 371 |
+
| `spf_voice_mode` | Voice pipeline control: start/stop audio, TTS (espeak-ng), mic capture |
|
| 372 |
+
| `spf_voice_call` | Peer-to-peer voice calls: start, accept, reject, end, status |
|
| 373 |
+
| `spf_voice_team` | Group voice channels: create, join, leave, add peers |
|
| 374 |
|
| 375 |
+
### Chat Tools
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
|
| 377 |
+
| Tool | Description |
|
| 378 |
+
|------|-------------|
|
| 379 |
+
| `spf_chat_send` | Send text message to mesh peer via QUIC |
|
| 380 |
+
| `spf_chat_history` | Chat message history (all conversations or specific) |
|
| 381 |
+
| `spf_chat_rooms` | List active chat conversations with participant info |
|
| 382 |
|
| 383 |
+
### Network Pool Tools
|
| 384 |
|
| 385 |
+
| Tool | Description |
|
| 386 |
+
|------|-------------|
|
| 387 |
+
| `spf_pool_status` | Pool status: worker roles, idle/busy counts, active tasks |
|
| 388 |
+
| `spf_pool_assign` | Assign task to idle worker (NetAdmin only) |
|
| 389 |
+
| `spf_pool_release` | Release worker and record proof of work receipt |
|
| 390 |
|
| 391 |
+
### Configuration Tools
|
| 392 |
+
|
| 393 |
+
| Tool | Description |
|
| 394 |
+
|------|-------------|
|
| 395 |
+
| `spf_config_paths` | List all path rules (allowed/blocked) from SPF_CONFIG |
|
| 396 |
+
| `spf_config_stats` | SPF_CONFIG LMDB statistics |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
|
| 398 |
+
### Project Management Tools
|
| 399 |
|
| 400 |
+
| Tool | Description |
|
| 401 |
+
|------|-------------|
|
| 402 |
+
| `spf_tmp_list` | List all registered projects with trust levels |
|
| 403 |
+
| `spf_tmp_stats` | TMP_DB statistics: project count, access logs, resources |
|
| 404 |
+
| `spf_tmp_get` | Get project info by path |
|
| 405 |
+
| `spf_tmp_active` | Get the currently active project |
|
| 406 |
|
| 407 |
+
### Communication Hub
|
|
|
|
|
|
|
| 408 |
|
| 409 |
+
| Tool | Description |
|
| 410 |
+
|------|-------------|
|
| 411 |
+
| `spf_channel` | Universal agent channel: create, join, leave, send, listen, history, list, connect (WS), disconnect, status |
|
| 412 |
|
| 413 |
+
### Notebook Tools
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 414 |
|
| 415 |
+
| Tool | Description |
|
| 416 |
+
|------|-------------|
|
| 417 |
+
| `spf_notebook_edit` | Edit a Jupyter notebook cell (replace, insert, delete) |
|
| 418 |
+
|
| 419 |
+
### User-Only Tools (AI agents blocked)
|
| 420 |
+
|
| 421 |
+
These tools are **hard-blocked** from AI agents at the gate level. User/system access only via SPF CLI:
|
| 422 |
+
|
| 423 |
+
`spf_fs_exists`, `spf_fs_stat`, `spf_fs_ls`, `spf_fs_read`, `spf_fs_write`, `spf_fs_mkdir`, `spf_fs_rm`, `spf_fs_rename`
|
| 424 |
+
|
| 425 |
+
---
|
| 426 |
+
|
| 427 |
+
## FLINT Transformer
|
| 428 |
+
|
| 429 |
+
Built-in encoder-decoder transformer for gate-aligned learning.
|
| 430 |
+
|
| 431 |
+
| Property | Value |
|
| 432 |
+
|----------|-------|
|
| 433 |
+
| Architecture | Encoder-decoder |
|
| 434 |
+
| Dimensions | 256d |
|
| 435 |
+
| Heads | 8 |
|
| 436 |
+
| Layers | 6 |
|
| 437 |
+
| Parameters | ~5M |
|
| 438 |
+
| Embeddings | all-MiniLM-L6-v2 (384d, in-process) |
|
| 439 |
+
| Online learning | ON |
|
| 440 |
+
| EWC lambda | 0.4 |
|
| 441 |
+
| Learning rate | 1e-4 |
|
| 442 |
+
| Replay buffer | 10,000 slots |
|
| 443 |
+
| Checkpoint interval | 1,000 steps |
|
| 444 |
+
| Training signal | Gate decisions (evil/FP labels) |
|
| 445 |
+
|
| 446 |
+
### Learning Pipeline
|
| 447 |
+
|
| 448 |
+
| Phase | When | What |
|
| 449 |
+
|-------|------|------|
|
| 450 |
+
| PRE | Startup | init_brain() + index_knowledge_docs() + index_spf_sources() |
|
| 451 |
+
| DURING | 30s loop | GateTrainingCollector → FLINT scores → route_signals → brain_store() |
|
| 452 |
+
| AFTER | 1hr loop | Expire → Working→Fact → Fact→Pinned → auto-train (16+ tlog or 1hr) |
|
| 453 |
|
| 454 |
+
### Memory Lifecycle (Tiered Promotion)
|
| 455 |
+
|
| 456 |
+
```
|
| 457 |
+
Agent stores → Working (24hr) → Fact (7-day) → Pinned (permanent)
|
| 458 |
+
↓ ↓ ↓
|
| 459 |
+
Expire old Top 20% promote Never auto-expire
|
| 460 |
```
|
| 461 |
+
|
| 462 |
+
---
|
| 463 |
+
|
| 464 |
+
## Brain System
|
| 465 |
+
|
| 466 |
+
In-process vector memory using stoneshell-brain (Candle + LMDB + MiniLM-L6-v2).
|
| 467 |
+
|
| 468 |
+
| Property | Value |
|
| 469 |
+
|----------|-------|
|
| 470 |
+
| Model | all-MiniLM-L6-v2 |
|
| 471 |
+
| Embedding dim | 384 |
|
| 472 |
+
| Chunk size | 512 |
|
| 473 |
+
| Chunk overlap | 64 |
|
| 474 |
+
| Storage | LMDB (vectors) + LIVE/BRAIN/DOCS/ (data files) |
|
| 475 |
+
|
| 476 |
+
### Collections
|
| 477 |
+
|
| 478 |
+
| Collection | Purpose |
|
| 479 |
+
|------------|---------|
|
| 480 |
+
| `default` | General knowledge, web research, project docs |
|
| 481 |
+
| `spf_source` | All src/*.rs modules indexed at boot |
|
| 482 |
+
| `flint_results` | Tool call results (>2000 chars, before compression) |
|
| 483 |
+
| `flint_training` | Gate decision signals, evil/FP labels |
|
| 484 |
+
| `flint_knowledge` | User-dropped knowledge files (.md/.txt/.rs/.json) |
|
| 485 |
+
| `flint_episodic` | Past FLINT Q+A pairs, behavioral patterns |
|
| 486 |
+
| `session_state` | Current session metadata |
|
| 487 |
+
|
| 488 |
+
### Memory Triad (Redundant Persistence)
|
| 489 |
+
|
| 490 |
+
Three systems — if any ONE fails, the other TWO recover:
|
| 491 |
+
|
| 492 |
+
1. **Brain** (vectors) — Semantic search, chunked knowledge
|
| 493 |
+
2. **STATUS** (sequential) — Current state, phase, next step
|
| 494 |
+
3. **Work Blocks** (structural) — Tasks, dependencies, confidence, progress
|
| 495 |
+
4. **Twin Folders** (evidence) — Data served for low-confidence work blocks
|
| 496 |
+
|
| 497 |
+
---
|
| 498 |
+
|
| 499 |
+
## Mesh Network
|
| 500 |
+
|
| 501 |
+
P2P agent communication over QUIC (iroh library) with Ed25519 identity. **In development and testing.**
|
| 502 |
+
|
| 503 |
+
| Feature | Status |
|
| 504 |
+
|---------|--------|
|
| 505 |
+
| P2P QUIC transport | In development |
|
| 506 |
+
| Ed25519 identity | In development |
|
| 507 |
+
| Peer discovery | In development |
|
| 508 |
+
| Tool call proxying | In development |
|
| 509 |
+
| Voice over mesh | In development |
|
| 510 |
+
| Chat over mesh | In development |
|
| 511 |
+
| Multi-agent coordination | In development |
|
| 512 |
+
|
| 513 |
+
---
|
| 514 |
+
|
| 515 |
+
## Voice Pipeline
|
| 516 |
+
|
| 517 |
+
**Not yet tested.** Components built, awaiting integration testing.
|
| 518 |
+
|
| 519 |
+
| Component | Technology |
|
| 520 |
+
|-----------|-----------|
|
| 521 |
+
| TTS | espeak-ng FFI (in-process) |
|
| 522 |
+
| Codec | Opus (libopus.a) |
|
| 523 |
+
| Audio | cpal + oboe-ext |
|
| 524 |
+
| STT | Pending (JNI via Stone Shell Terminal) |
|
| 525 |
+
|
| 526 |
+
---
|
| 527 |
+
|
| 528 |
+
## Result Compression (FL-2)
|
| 529 |
+
|
| 530 |
+
Three tiers based on result size:
|
| 531 |
+
|
| 532 |
+
| Tier | Size | Behavior |
|
| 533 |
+
|------|------|----------|
|
| 534 |
+
| FULL | < 500 chars | Pass through unchanged |
|
| 535 |
+
| SUMMARY | 500–5,000 | First 8 lines + last 3 lines + stats |
|
| 536 |
+
| DIGEST | > 5,000 | First 200 chars + last 100 chars + stats + recall hint |
|
| 537 |
+
|
| 538 |
+
Originals always preserved in brain (>2000 chars threshold) before compression. File reads never truncated (preserves non-Claude LLM compatibility).
|
| 539 |
+
|
| 540 |
+
---
|
| 541 |
+
|
| 542 |
+
## Build
|
| 543 |
+
|
| 544 |
+
```bash
|
| 545 |
+
cd SPFsmartGATE
|
| 546 |
+
cargo build --release
|
| 547 |
+
|
| 548 |
+
# Deploy binary
|
| 549 |
+
cp target/release/spf-smart-gate LIVE/BIN/spf-smart-gate/spf-smart-gate
|
| 550 |
```
|
| 551 |
|
| 552 |
+
### Dependencies
|
| 553 |
+
|
| 554 |
+
- Rust (stable)
|
| 555 |
+
- **[heed](https://github.com/meilisearch/heed)** — safe Rust LMDB bindings. All persistent storage (config, agent state, brain vectors, training data) runs through heed → LMDB. Zero-copy reads, no server process, sub-millisecond lookups. The core reason SPF runs fast on a phone.
|
| 556 |
+
- stoneshell-brain (Candle + MiniLM-L6-v2)
|
| 557 |
+
- espeak-ng (TTS)
|
| 558 |
+
- libopus (audio codec)
|
| 559 |
+
- iroh (QUIC mesh)
|
| 560 |
+
|
| 561 |
+
---
|
| 562 |
+
|
| 563 |
+
## Configuration
|
| 564 |
+
|
| 565 |
+
### MCP Server Config
|
| 566 |
+
|
| 567 |
+
`~/SPFsmartGATE/LIVE/LMDB5/.mcp.json` — points Claude CLI to the binary.
|
| 568 |
+
|
| 569 |
+
### Claude CLI Config
|
| 570 |
+
|
| 571 |
+
`~/SPFsmartGATE/LIVE/LMDB5/.claude.json` — blocks native Claude CLI tools (26 tools denied).
|
| 572 |
+
|
| 573 |
+
`~/SPFsmartGATE/LIVE/LMDB5/.claude/settings.json` — deny list for native tools.
|
| 574 |
+
|
| 575 |
+
`~/SPFsmartGATE/LIVE/LMDB5/.claude/settings.local.json` — model routing (OpenRouter).
|
| 576 |
+
|
| 577 |
+
### SPF Config
|
| 578 |
+
|
| 579 |
+
Enforcement mode (`soft` or `max`), blocked paths, allowed paths, formula weights — all in LMDB SPF_CONFIG database.
|
| 580 |
+
|
| 581 |
+
---
|
| 582 |
+
|
| 583 |
## File Structure
|
| 584 |
|
| 585 |
```
|
| 586 |
SPFsmartGATE/
|
| 587 |
+
├── Cargo.toml # Rust project manifest (42 modules)
|
| 588 |
+
├── LICENSE # Apache-2.0
|
| 589 |
+
├── README.md # This file
|
| 590 |
+
├── src/
|
| 591 |
+
│ ├── main.rs # CLI entry point
|
| 592 |
+
│ ├── lib.rs # Library exports (42 pub mod)
|
| 593 |
+
│ ├── gate.rs # Primary enforcement (6-step pipeline)
|
| 594 |
+
│ ├── calculate.rs # SPF complexity formula
|
| 595 |
+
│ ├── validate.rs # Rules validation (stages 0-6)
|
| 596 |
+
│ ├── inspect.rs # Content inspection (creds, injection)
|
| 597 |
+
│ ├── mcp.rs # MCP server (JSON-RPC 2.0, 81 tools)
|
| 598 |
+
│ ├── dispatch.rs # Unified dispatch (all transports)
|
| 599 |
+
│ ├── session.rs # Session state management
|
| 600 |
+
│ ├── storage.rs # LMDB persistence
|
| 601 |
+
│ ├── config.rs # Configuration types
|
| 602 |
+
│ ├── brain_local.rs # In-process brain singleton
|
| 603 |
+
│ ├── flint_memory.rs # Memory router + tiered promotion
|
| 604 |
+
│ ├── agent_state.rs # Agent memory (LMDB5)
|
| 605 |
+
│ ├── transformer.rs # FLINT model (encoder-decoder)
|
| 606 |
+
│ ├── transformer_tools.rs # FLINT tool handlers
|
| 607 |
+
│ ├── gate_training.rs # Training signal collection
|
| 608 |
+
│ ├── train.rs # AdamW optimizer
|
| 609 |
+
│ ├── tokenizer.rs # Tokenizer
|
| 610 |
+
│ ├── tensor.rs # Tensor operations
|
| 611 |
+
│ ├── attention.rs # Multi-head attention
|
| 612 |
+
│ ├── ffn.rs # Feed-forward network
|
| 613 |
+
│ ├── encoder.rs # Encoder stack
|
| 614 |
+
│ ├── decoder.rs # Decoder stack
|
| 615 |
+
│ ├── framing.rs # Message framing
|
| 616 |
+
│ ├── checkpoint.rs # Model checkpoint save/load
|
| 617 |
+
│ ├── learning.rs # Learning rate + EWC
|
| 618 |
+
│ ├── pipeline.rs # Batch pipeline + API sessions
|
| 619 |
+
│ ├── worker.rs # Worker pool
|
| 620 |
+
│ ├── network.rs # Network pool + NetAdmin
|
| 621 |
+
│ ├── mesh.rs # P2P QUIC mesh (iroh)
|
| 622 |
+
│ ├── identity.rs # Ed25519 identity
|
| 623 |
+
│ ├── chat.rs # Chat engine
|
| 624 |
+
│ ├── voice.rs # Voice pipeline (TTS/STT)
|
| 625 |
+
│ ├── web.rs # Web client
|
| 626 |
+
│ ├── http.rs # HTTP server + reverse proxy
|
| 627 |
+
│ ├── browser.rs # Browser automation
|
| 628 |
+
│ ├── channel.rs # Universal channel hub
|
| 629 |
+
│ ├── orchestrator.rs # Multi-agent orchestrator
|
| 630 |
+
│ ├── config_db.rs # SPF_CONFIG LMDB
|
| 631 |
+
│ ├── tmp_db.rs # TMP_DB LMDB
|
| 632 |
+
│ ├── fs.rs # Virtual filesystem (LMDB)
|
| 633 |
+
│ ├── paths.rs # Path utilities
|
| 634 |
+
│ └── utf8_safe.rs # UTF-8 safe truncation
|
| 635 |
+
├── LIVE/
|
| 636 |
+
│ ├── BIN/spf-smart-gate/ # Deployed binary
|
| 637 |
+
│ ├── BRAIN/DOCS/ # Brain data files
|
| 638 |
+
│ ├── MODELS/ # FLINT checkpoints
|
| 639 |
+
│ ├── SESSION/ # Session logs
|
| 640 |
+
│ ├── LMDB5/ # Flat-file agent runtime
|
| 641 |
+
│ └── LMDB5.DB/ # LMDB-backed agent runtime
|
| 642 |
+
└── PROJECTS/PROJECTS/
|
| 643 |
+
└── DEPLOY/ # Agent workspace
|
| 644 |
```
|
| 645 |
|
| 646 |
+
---
|
|
|
|
|
|
|
| 647 |
|
| 648 |
+
## Current Status
|
| 649 |
+
|
| 650 |
+
| Component | Status |
|
| 651 |
+
|-----------|--------|
|
| 652 |
+
| MCP Server | 81 gated tools |
|
| 653 |
+
| Gate Security | 6-step pipeline, compiled Rust enforcement |
|
| 654 |
+
| Build Anchor | Read-before-write enforced |
|
| 655 |
+
| Content Inspection | Credential + injection scanning |
|
| 656 |
+
| FLINT Transformer | ~5M params, online learning, gate-aligned |
|
| 657 |
+
| Brain | 7 collections, MiniLM-L6-v2, in-process |
|
| 658 |
+
| Memory Triad | Brain + STATUS + Work Blocks + Twin Folders |
|
| 659 |
+
| Tiered Promotion | Working → Fact → Pinned lifecycle |
|
| 660 |
+
| Mesh Network | P2P QUIC, Ed25519, iroh — **in development and testing** |
|
| 661 |
+
| Voice | TTS built (espeak-ng) — **not yet tested**, STT pending |
|
| 662 |
+
| Chat | P2P messaging over mesh — **in development** |
|
| 663 |
+
| RAG | Web search, RSS, file/folder indexing |
|
| 664 |
+
| Browser | Reverse proxy automation — screenshot in development |
|
| 665 |
+
| Network Pool | Worker pool with proof of work |
|
| 666 |
|
| 667 |
+
---
|
| 668 |
|
| 669 |
+
## Notes
|
| 670 |
|
| 671 |
+
- **1 developer** — not all features complete
|
| 672 |
+
- **Gateway security**: approaching 100%
|
| 673 |
+
- **All core tools**: 100% working
|
| 674 |
+
- **Cross-compiles** on Android and Linux with minimal installation
|
| 675 |
+
- **Agent cloning and specialization** supported
|
| 676 |
+
- **50+ day continuous session** tested on Android phone
|
| 677 |
+
- **Open source** — entire source code refreshes into transformer RAG system every reboot
|
| 678 |
+
- Install in home folder, ensure file paths are correct in `.mcp.json` and `settings.local.json`
|
| 679 |
+
- **Not all files have been uploaded yet** — repository is still being populated. Some modules may not be present until upload completes.
|
| 680 |
|
| 681 |
+
---
|
| 682 |
|
| 683 |
+
## License
|
|
|
|
| 684 |
|
| 685 |
+
Free and open source for personal, educational, and non-commercial use.
|
| 686 |
|
| 687 |
+
**Author**: Joseph Stone
|
| 688 |
+
**Email**: joepcstone@gmail.com
|
| 689 |
|
| 690 |
+
*SPF (StoneCell Processing Formula), Build Anchor Protocol, and FLINT are proprietary designs of Joseph Stone.*
|