sovereign-router / README-ROUTER.md
SNAPKITTYWEST's picture
Add sovereign-router source: router-server.mjs, kernel-registry, agent-registry, omega-field, MAGMA verbs
931572e verified
|
Raw
History Blame
15 kB

⬑ 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 Bedrock Mistral WORM


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

# 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

# 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

# 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

# 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.

{
  "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)

# 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

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