JosephStoneCellAI commited on
Commit
fe343d7
·
verified ·
1 Parent(s): da86478

Delete README.md

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