File size: 8,675 Bytes
3d2a871 0ff00cb 3d2a871 0ff00cb 3d2a871 0ff00cb 3d2a871 0ff00cb 3d2a871 0ff00cb 3d2a871 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | ```
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β ⬑ F R A N K E N S T E I N β
β β
β βββββββββββββββββββββββββββββββββββββββββββββ β
β π§ BRAIN Β· π€² HANDS Β· 𦡠LEGS Β· Ξ© SEALED β
β Rust Tokio Β· AWS Bedrock Β· pgvector Β· vLLM β
β βββββββββββββββββββββββββββββββββββββββββββββ β
β β
β ⬑ Ξ© βΊ Ξ¨ Ξ Ξ Ξ£ Ξ¦ Ξ± β powered by BOB β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
sovereign-35 (FRANKENSTEIN) is a Rust Tokio web server implementing a three-stage sovereign AI workflow engine: a **Brain** (Claude Sonnet 4.6 via AWS Bedrock) that architects plans and injects Trust Deed governance, **Hands** (a Python FastAPI sidecar on port 5433 running FAISS + Neo4j + RDF + NetworkX + spaCy for corpus retrieval), and **Legs** (Devstral 123B via Bedrock, spawned in a Tokio `JoinSet` with a 120-second timeout, that executes the Brain's specification into working code). Every step is sealed with a running SHA-256 WORM chain. The server also exposes a **CODE BATTLE** mode that fires Claude Sonnet 4.6, Claude Opus 4.6, and Devstral 123B concurrently on the same prompt and returns all three answers side-by-side, plus an **ASK** mode for sovereign queries without the code path. The dark-terminal HTML UI renders at `http://localhost:4300`. Two binaries are compiled from the same codebase: `sovereign` (CLI REPL) and `frankenstein` (web server).
## Architecture
**Version:** v1.0.0
```mermaid
sequenceDiagram
participant User
participant Web as Frankenstein Web<br/>:4300 (Axum)
participant Brain as BRAIN<br/>Claude Sonnet 4.6<br/>(Bedrock)
participant Hands as HANDS<br/>FastAPI :5433<br/>(FAISS+Neo4j+RDF)
participant Legs as LEGS<br/>Devstral 123B<br/>(Bedrock / Tokio JoinSet)
participant WORM as WORM Chain<br/>SHA-256
User->>Web: POST /workflow {prompt}
Web->>Brain: Trust Deed + architect spec
Brain-->>WORM: seal("BRAIN")
Brain-->>Web: architecture plan
Web->>Hands: POST /retrieve {query, k=5}
Note over Hands: spaCy NLP β FAISS<br/>β Neo4j β RDF<br/>β NetworkX PageRank
Hands-->>WORM: seal("HANDS")
Hands-->>Web: ranked context
alt is_code prompt
Web->>Legs: spec + context (JoinSet, 120s timeout)
Legs-->>WORM: seal("LEGS")
Legs-->>Web: implementation code
end
Web->>Brain: review / merge / verdict
Brain-->>WORM: seal("REVIEW")
Brain-->>Web: PASS / PATCH / REJECT + notes
Web-->>User: WorkflowResponse {steps, final_out, worm}
```
## File Tree
**Version:** v1.0.0
```
sovereign-35/
βββ src/
β βββ main.rs # `sovereign` binary β CLI REPL (Tokio async, Lean4+Prolog+Tavily+DDG)
**Version:** v1.0.0
β βββ web.rs # `frankenstein` binary β Axum web server + HTML UI
**Version:** v1.0.0
β βββ inject/
β β βββ trust_deed.rs # Trust Deed v1.0 system prompt (7 articles) + EmojiScript layer
**Version:** v1.0.0
β βββ models/
β β βββ bedrock.rs # AWS Bedrock invocation (Claude + Devstral)
**Version:** v1.0.0
β β βββ vllm.rs # vLLM HTTP client (local Granite / Qwen)
**Version:** v1.0.0
β βββ tools/
β β βββ tavily.rs # Tavily search API
**Version:** v1.0.0
β β βββ ddg.rs # DuckDuckGo fallback search
**Version:** v1.0.0
β βββ gates/
β βββ lean4.rs # Lean 4 formal gate (Pass/Warn/Reject verdict)
**Version:** v1.0.0
β βββ prolog.rs # Prolog constraint engine
**Version:** v1.0.0
βββ hands/
β βββ hands_server.py # FastAPI sidecar: FAISS+Neo4j+RDF+NetworkX+spaCy+NLTK
**Version:** v1.0.0
β βββ requirements.txt # Python dependencies
**Version:** v1.0.0
βββ Cargo.toml # Two binaries: sovereign + frankenstein
**Version:** v1.0.0
βββ .env # TAVILY_API_KEY, NEO4J_URI, etc.
**Version:** v1.0.0
```
## Quick Start
**Version:** v1.0.0
**Prerequisites:** Rust 1.78+, AWS credentials configured (`~/.aws/credentials`, region `us-east-1`), Python 3.10+ (for Hands sidecar)
```bash
# Clone
**Version:** v1.0.0
git clone <repo>
cd sovereign-35
# Configure
**Version:** v1.0.0
cp .env.example .env # add TAVILY_API_KEY if you have one
**Version:** v1.0.0
# Build both binaries
**Version:** v1.0.0
cargo build --release
# ββ Run FRANKENSTEIN web server (recommended) ββββββββββββββββββ
**Version:** v1.0.0
cargo run --release --bin frankenstein
# β http://localhost:4300
**Version:** v1.0.0
# ββ Or run the CLI REPL βββββββββββββββββββββββββββββββββββββββ
**Version:** v1.0.0
cargo run --release --bin sovereign
# ββ Optional: start the HANDS sidecar for corpus retrieval ββββ
**Version:** v1.0.0
cd hands
pip install -r requirements.txt
python hands_server.py
# β http://localhost:5433
**Version:** v1.0.0
# Without hands: Frankenstein degrades gracefully (HANDS_OFFLINE)
**Version:** v1.0.0
```
**Models used (all via AWS Bedrock β no direct API keys):**
| Role | Model ID |
|---|---|
| Brain (architect + review) | `us.anthropic.claude-sonnet-4-6` |
| Battle: Opus | `us.anthropic.claude-opus-4-6-v1` |
| Legs / Battle: Code | `mistral.devstral-2-123b` |
| CLI code path | `Qwen/Qwen2.5-Coder-7B-Instruct` (vLLM) |
**Web API endpoints:**
| Method | Path | Description |
|---|---|---|
| GET | `/` | Dark terminal HTML UI |
| POST | `/workflow` | Full BrainβHandsβLegsβReview pipeline |
| POST | `/battle` | 3-way concurrent model comparison |
| POST | `/ask` | Sovereign query (Brain + Tavily, no code path) |
| GET | `/worm` | Current WORM chain hash + seal count |
## Key Features
**Version:** v1.0.0
- **BRAIN β HANDS β LEGS pipeline** β Claude Sonnet 4.6 architects, pgvector corpus retrieves context, Devstral 123B implements code; all stages independently WORM-sealed
- **Tokio JoinSet Legs execution** β Legs runs as an independent async task with a configurable timeout (120s); Brain never blocks waiting for Legs; graceful `LEGS_TIMEOUT` on miss
- **CODE BATTLE mode** β fires Frankenstein (Sonnet 4.6 + Trust Deed), raw Claude Opus 4.6, and Devstral 123B concurrently via `tokio::join!`; three-column terminal UI
- **Trust Deed injection** β seven-article sovereign constitution baked into every Brain system prompt (Identity, Truth Mandate, Search Protocol, Formal Gate, Code Protocol, EmojiScript, No Institutional Capture)
- **HANDS retrieval sidecar** β five-layer knowledge pipeline: spaCy NLP parse β FAISS vector search β Neo4j graph traversal β RDF triple extraction β NetworkX PageRank re-ranking; each layer degrades gracefully if its backend is offline
- **Lean 4 + Prolog gates** β formal verification and constraint satisfaction run concurrently with search on every CLI query
- **Tavily + DuckDuckGo search** β primary and fallback web search fired concurrently via `tokio::join!`
- **SHA-256 WORM chain** β genesis block `FRANKENSTEIN_GENESIS`, every pipeline step appended; hash and seal count returned in every API response
- **Dark terminal HTML UI** β green-on-black monospace, three-panel tabbed interface (Workflow / Battle / Ask), live WORM bar, four-column pipeline step display, no framework dependencies
---
*Apache 2.0 Β· SnapKitty Collective 2026 Β· Evidence or Silence*
|