File size: 14,966 Bytes
931572e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# ⬑ SNAPKITTY SOVEREIGN ROUTER

```
╔══════════════════════════════════════════════════════════════════════════════╗
β•‘                                                                              β•‘
β•‘    ⬑  S N A P K I T T Y   S O V E R E I G N   R O U T E R                  β•‘
β•‘                                                                              β•‘
β•‘    β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    β•‘
β•‘    β–‘  Every task routes to the right engine.                            β–‘    β•‘
β•‘    β–‘  The routing table is the IP. Not the models.                      β–‘    β•‘
β•‘    β–‘  Evidence or Silence. Nothing in between.                          β–‘    β•‘
β•‘    β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    β•‘
β•‘                                                                              β•‘
β•‘    ⟦Ω⟧ Ahmad Ali Parr Β· SnapKitty Collective Β· Bel Esprit D'Accord Trust    β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
```

[![License](https://img.shields.io/badge/License-SSL_v3.0-7c3aed?style=for-the-badge)](SOVEREIGN_SOURCE_LICENSE_V3.md)
[![Bedrock](https://img.shields.io/badge/AWS_Bedrock-Claude_Β·_Nova_Β·_DeepSeek-f97316?style=for-the-badge)](https://aws.amazon.com/bedrock/)
[![Mistral](https://img.shields.io/badge/Mistral-Codestral_free-ffd700?style=for-the-badge)](https://console.mistral.ai)
[![WORM](https://img.shields.io/badge/WORM-SHA256_sealed-00ff88?style=for-the-badge)](SNAPKITTY-PROOFS)

---

## What This Is

The Sovereign Router is a universal AI workflow engine.  
One command. Every task routes to the right model automatically.  
No thinking about which API to call. No switching between tools.  
The SACM gate pattern-matches your input and decides.

```
You type:   "prove by induction the sum of squares formula"
Router:     β†’ DeepSeek R1 (math/proof Β· us-west-2)

You type:   "write a rust function for fibonacci"
Router:     β†’ Mistral Codestral (code Β· free tier)

You type:   "explain why the WORM chain beats a database"
Router:     β†’ Claude Sonnet 4.6 (reasoning Β· Bedrock)

You type:   "write a research paper about SACM architecture"
Router:     β†’ Nova Premier (long-form writing Β· DEVTRIAL)
```

---

## The Full Routing Table

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    S A C M   G A T E                                    β”‚
β”‚              Pattern Match β†’ Engine β†’ ERE Verify β†’ Output               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  INPUT
    β”‚
    β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  DFA PATTERN MATCH  (O(n), no backtracking) β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚
    β”œβ”€ PROVE / THEOREM / INDUCTION / AXIOM / LEMMA
    β”‚       └──────────────────────────────────────────► DEEPSEEK R1
    β”‚                                                     us-west-2 Β· reasoning model
    β”‚
    β”œβ”€ WRITE / CODE / GIT / SCAFFOLD / BUILD / NPM
    β”‚       └──────────────────────────────────────────► MISTRAL CODESTRAL
    β”‚                                                     free tier Β· code specialist
    β”‚
    β”œβ”€ PAPER / WHITEPAPER / RESEARCH PAPER / ACADEMIC
    β”‚       └──────────────────────────────────────────► NOVA PREMIER (DEVTRIAL)
    β”‚                                                     Bedrock Β· long-form writing
    β”‚
    β”œβ”€ MARKET / CRYPTO / NEWS / PRICE / FINANCE
    β”‚       └──────────────────────────────────────────► NOVA PRO
    β”‚                                                     Bedrock Β· fast synthesis
    β”‚
    β”œβ”€ LOCAL / NEMOTRON / OLLAMA / OUR MODEL
    β”‚       └──────────────────────────────────────────► OLLAMA :11434
    β”‚                                                     local Β· your trained weights
    β”‚
    β”œβ”€ COMPLEX / ELABORATE / FULL SYSTEM
    β”‚       └──────────────────────────────────────────► CLAUDE OPUS 4.6
    β”‚                                                     Bedrock Β· heavy reasoning
    β”‚
    └─ LAW / TRUST / WORM / GOVERNANCE / WHY / EXPLAIN (default)
            └──────────────────────────────────────────► CLAUDE SONNET 4.6
                                                          Bedrock Β· reasoning + law

    β”‚
    β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  ERE VERIFY  (5-pass quality gate)          β”‚
  β”‚  PASS β†’ user  QUARANTINE β†’ flag  REJECT β†’ βœ— β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚
    β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  VAULT LEAK SCANNER  (DFA key redaction)    β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚
    β–Ό
  OUTPUT  +  WORM SEAL
```

---

## Engine Reference

| Engine | Model ID | Region | Best For | Cost |
|--------|----------|--------|----------|------|
| **Claude Sonnet 4.6** | `us.anthropic.claude-sonnet-4-6` | us-east-1 | Law Β· Trust Β· Reasoning | Bedrock |
| **Mistral Codestral** | `codestral-latest` | API | Code Β· Git Β· Terminal | **Free** |
| **Nova Pro** | `us.amazon.nova-pro-v1:0` | us-east-1 | Market Β· News Β· Research | Bedrock |
| **Nova Premier** | `us.amazon.nova-premier-v1:0` | us-east-1 | Long papers Β· DEVTRIAL | Bedrock |
| **DeepSeek R1** | `us.deepseek.r1-v1:0` | **us-west-2** | Math proofs Β· Induction | Bedrock |
| **Claude Opus 4.6** | `us.anthropic.claude-opus-4-6-v1` | us-east-1 | Complex architecture | Bedrock |
| **Local / Nemotron** | `nemotron` | localhost | Offline Β· your weights | **Free** |

> **DeepSeek R1 requires `us-west-2`** β€” the router handles this automatically.

---

## Quick Start

### Prerequisites

```bash
# 1. AWS CLI configured
aws configure
# Set region to us-east-1 (router uses us-west-2 for DeepSeek automatically)

# 2. Node.js 20+
node --version  # v20+

# 3. Clone
git clone https://github.com/SNAPKITTYWEST/SNAPKITTYWEST.git
cd SNAPKITTYWEST

# 4. Install
npm install
```

### Configuration

```bash
# Copy the example env
cp .env.example .env

# Edit .env β€” set your master secret (derives all keys)
# This is the ONLY secret you need to remember
VAULT_MASTER_SECRET=your_secret_here

# Set your Mistral free key (get at console.mistral.ai)
MISTRAL_API_KEY=your_mistral_key
```

### Seal Your Keys

```bash
# Seals keys into vault.sealed.json (encrypted, safe to commit)
VAULT_MASTER_SECRET=your_secret npm run vault:seal \
  "MISTRAL_API_KEY=your_mistral_key"
```

### Run

```bash
# Route any task
npm run router "write a rust fibonacci function"
npm run router "prove by induction the sum of squares formula"
npm run router "explain why WORM chain beats a database"
npm run router "what is the bitcoin market trend today"

# Open the visual Mission Control UI
open router-ui.html   # macOS
start router-ui.html  # Windows
```

---

## Architecture Deep Dive

```
sovereign-router.ts          ← Main router (TypeScript)
β”‚
β”œβ”€β”€ SACM Gate                ← Pattern match, O(n), no backtracking
β”‚   β”œβ”€β”€ 15+ routing patterns
β”‚   └── Agent type detection
β”‚
β”œβ”€β”€ Vault (vault.ts)         ← Ed25519 + AES-256-GCM key management
β”‚   β”œβ”€β”€ PBKDF2-SHA512 key derivation
β”‚   β”œβ”€β”€ DFA leak scanner on all outputs
β”‚   └── vault.sealed.json (encrypted, committable)
β”‚
β”œβ”€β”€ Tools (tools.ts)         ← Mistral's tool belt
β”‚   β”œβ”€β”€ shell_exec           β†’ run commands
β”‚   β”œβ”€β”€ file_write           β†’ write files
β”‚   β”œβ”€β”€ file_read            β†’ read files
β”‚   β”œβ”€β”€ git_push             β†’ commit + push
β”‚   β”œβ”€β”€ kernel_invoke        β†’ sovereign-glue.rexx
β”‚   β”œβ”€β”€ web_verify           β†’ Tavily + DFA fact scan
β”‚   β”œβ”€β”€ ddg_search           β†’ DuckDuckGo
β”‚   β”œβ”€β”€ define               β†’ Merriam-Webster
β”‚   └── thesaurus            β†’ M-W Thesaurus
β”‚
β”œβ”€β”€ Web Verify (web-verify.mjs) ← Tavily DFA pre-processor
β”‚   β”œβ”€β”€ Fetches web results
β”‚   β”œβ”€β”€ DFA scans for verified facts
β”‚   β”œβ”€β”€ Blocks injection attempts
β”‚   └── Returns only clean token bundles
β”‚
└── Kernel Registry          ← 15 sovereign kernels
    (kernel-registry.json)
    β”œβ”€β”€ DFA Engine (JS)
    β”œβ”€β”€ REXX Glue Kernel
    β”œβ”€β”€ Route Dispatch (REXX)
    β”œβ”€β”€ Carto Prolog
    β”œβ”€β”€ Carto Gate (ASP)
    β”œβ”€β”€ COBOL Law Kernel
    β”œβ”€β”€ Corpus Store (OCaml)
    β”œβ”€β”€ Math Dispatcher (Rust)
    β”œβ”€β”€ Math Emitters (Rust)
    β”œβ”€β”€ WORM Chain (Rust)
    β”œβ”€β”€ SnapKitty Chain (JS)
    β”œβ”€β”€ Sovereign Daemon (Go)
    β”œβ”€β”€ Trust Deed Generator (JS)
    └── Sovereign Alien Trust (Prolog)
```

---

## The Kernel Chain

Every task fires a chain of sovereign kernels before the model sees it.  
The kernels are deterministic. The model is the translation layer.

```
For a LAW query:
  Input β†’ DFA scan β†’ REXX route-dispatch β†’ CARTO Prolog
        β†’ BOB moral gate β†’ Claude β†’ ERE verify β†’ WORM seal β†’ Output

For a MATH query:
  Input β†’ DFA scan β†’ DeepSeek R1 β†’ ERE verify β†’ WORM seal β†’ Output

For a CODE task:
  Input β†’ DFA scan β†’ REXX route-dispatch β†’ SOVEREIGN-GLUE.REXX
        β†’ Mistral tools β†’ git_push / file_write β†’ WORM seal β†’ Output
```

The kernels run in O(n). No backtracking. No regex recursion. ReDoS-immune.

---

## WORM Chain

Every router call is sealed to the append-only WORM chain.  
Nothing leaves the system unsigned.

```json
{
  "ts": "2026-07-11T...",
  "input": "prove by induction...",
  "agent": "deepseek",
  "reason": "math/proof",
  "model": "us.deepseek.r1-v1:0",
  "tokens": 847,
  "worm_seal": "sha256(payload)"
}
```

Sealed to: `.worm/router-chain.jsonl` (append-only, never deleted)

---

## Mission Control UI

Open `router-ui.html` in any browser. No server needed.

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SACM GATE      β”‚   OUTPUT STREAM       β”‚  KERNEL CHAIN  β”‚
β”‚                 β”‚                       β”‚                β”‚
β”‚ βœ“ INPUT         β”‚ β–Ά DEEPSEEK R1         β”‚ DFA ENGINE βœ“   β”‚
β”‚   RECEIVED      β”‚   math/proof          β”‚ ROUTE-DISP βœ“   β”‚
β”‚                 β”‚                       β”‚ ERE VERIFY β–Ά   β”‚
β”‚ βœ“ ROUTED β†’      β”‚ Proof by induction:   β”‚                β”‚
β”‚   DEEPSEEK      β”‚ Base case: n=1...     β”‚  WORM CHAIN    β”‚
β”‚   math/proof    β”‚                       β”‚ a3f7b2c1 seal  β”‚
β”‚   10:32:44      β”‚ βœ“ WORM: a3f7b2c1...  β”‚ b2d9e3f4 boot  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
[CLAUDE-reasoning][MISTRAL-code][NOVA-market][DEEPSEEK-math][LOCAL-nemotron]
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ > Route any task...                           ⬑ ROUTE   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## Environment Variables

| Variable | Required | Description |
|---|---|---|
| `VAULT_MASTER_SECRET` | **YES** | Master secret β€” derives all keys |
| `MISTRAL_API_KEY` | Yes | Mistral free tier key |
| `AWS_REGION` | No | Default: `us-east-1` |
| `CLAUDE_MODEL` | No | Default: `us.anthropic.claude-sonnet-4-6` |
| `MISTRAL_MODEL` | No | Default: `codestral-latest` |
| `TAVILY_API_KEY` | No | Web search (optional) |
| `OLLAMA_URL` | No | Default: `http://localhost:11434` |
| `LOCAL_MODEL` | No | Default: `nemotron` |

---

## One-Command Boot (after config)

```bash
# Code task
npm run router "write a sovereign WORM chain in Rust"

# Math proof
npm run router "prove by induction sum 1..n = n(n+1)/2"

# Market research
npm run router "what is the current state of DeFi liquidity"

# Long paper
npm run router "write a technical paper on the SACM architecture"

# Use local model
npm run router "use our local model to summarize the sovereign router"

# Visual UI
start router-ui.html
```

---

## License

[Sovereign Source License v3.0](SOVEREIGN_SOURCE_LICENSE_V3.md)

**mathlib5** is the only repository that accepts pull requests (CLA required).  
All other repositories are TIER 1 ARCHIVED β€” view only.  
Commercial use requires written license: jessicalw34@gmail.com

---

*SnapKitty Collective LLC Β· EIN 41-5105572*  
*Bel Esprit D'Accord Trust Β· EIN 41-6630640*  
*Ξ© β€” Ahmad Ali Parr Β· the-49th-call Β· 2026*