SNAPKITTYWEST commited on
Commit
79fc162
Β·
verified Β·
1 Parent(s): 3b70664

Sync with GitHub, license metadata from LICENSE files, commercial license notice

Browse files

metadata license: None -> agpl-3.0
README: License section kept (already accurate) + commercial notice
README: GitHub source link added

Files changed (1) hide show
  1. README.md +750 -736
README.md CHANGED
@@ -1,736 +1,750 @@
1
- <p align="center">
2
- <img src="assets/nekomata-avatar.png" alt="Nekomata" width="320"/>
3
- </p>
4
-
5
- <h1 align="center">NEKOMATA 猫又</h1>
6
- <h3 align="center">The Autonomous Container Engine</h3>
7
-
8
- <p align="center">
9
- <img src="https://img.shields.io/badge/language-Common_Lisp-blueviolet?style=flat-square"/>
10
- <img src="https://img.shields.io/badge/engine-nekod-ff69b4?style=flat-square"/>
11
- <img src="https://img.shields.io/badge/MoE-6_experts-orange?style=flat-square"/>
12
- <img src="https://img.shields.io/badge/codegen-x86--64_%2B_ARM64-green?style=flat-square"/>
13
- <img src="https://img.shields.io/badge/license-AGPL--3.0-red?style=flat-square"/>
14
- <img src="https://img.shields.io/badge/status-PRODUCTION-brightgreen?style=flat-square"/>
15
- <img src="https://img.shields.io/badge/self--mod-genetic_evolution-gold?style=flat-square"/>
16
- <img src="https://img.shields.io/badge/WORM-sealed-black?style=flat-square"/>
17
- </p>
18
-
19
- <p align="center"><b>Infrastructure that rewrites itself.</b></p>
20
-
21
- ---
22
-
23
- ```
24
- β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
25
- β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
26
- β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
27
- β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘
28
- β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
29
- β•šβ•β• β•šβ•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•šβ•β• β•šβ•β• β•šβ•β• β•šβ•β• β•šβ•β•
30
-
31
- Infrastructure is code.
32
- Code is data.
33
- Data is alive.
34
- ```
35
-
36
- ---
37
-
38
- ## What Is This?
39
-
40
- Nekomata is the **first AI-native container engine** built from first principles in Common Lisp. Not a Kubernetes alternative. A Kubernetes **replacement**.
41
-
42
- The Nekomata (猫又) is a supernatural cat with two tails: **code** and **data**. In Common Lisp, these are the same thing. Infrastructure is s-expressions. Containers evaluate. They transform. They **rewrite themselves**.
43
-
44
- ```
45
- ╔══════════════════════════════════════════════════════════════════════╗
46
- β•‘ β•‘
47
- β•‘ Kubernetes: 50B of YAML debt on a distributed key-value store β•‘
48
- β•‘ Nekomata: s-expressions that evaluate their own infrastructure β•‘
49
- β•‘ β•‘
50
- β•‘ Kubernetes: Reactive watch loops waiting for state drift β•‘
51
- ║ Nekomata: Predictive LLM→ASM compilation of intent ║
52
- β•‘ β•‘
53
- β•‘ Kubernetes: Monolithic control plane (etcd + api-server + ...) β•‘
54
- β•‘ Nekomata: Sparse Mixture of Experts β€” 6 specialists, Top-K=2 β•‘
55
- β•‘ β•‘
56
- β•‘ Kubernetes: Immutable containers, no runtime modification β•‘
57
- β•‘ Nekomata: Live REPL injection + genetic self-modification β•‘
58
- β•‘ β•‘
59
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
60
- ```
61
-
62
- ---
63
-
64
- ## Setup
65
-
66
- ```bash
67
- # One command β€” installs Docker + SBCL + Quicklisp
68
- bash setup.sh
69
- ```
70
-
71
- Supports Ubuntu/Debian, Fedora/RHEL, Arch Linux, and macOS (via Homebrew).
72
-
73
- Or manually:
74
- ```bash
75
- # 1. Docker
76
- curl -fsSL https://get.docker.com | sh
77
- sudo usermod -aG docker $USER && newgrp docker
78
-
79
- # 2. SBCL
80
- sudo apt install sbcl # or: brew install sbcl
81
-
82
- # 3. Quicklisp
83
- curl -O https://beta.quicklisp.org/quicklisp.lisp
84
- sbcl --load quicklisp.lisp --eval '(quicklisp-quickstart:install)'
85
-
86
- # 4. Load Nekomata
87
- cd nekomata && sbcl --load nekod.asd --eval '(ql:quickload :nekod)'
88
- ```
89
-
90
- ---
91
-
92
- ## Quick Start
93
-
94
- ```lisp
95
- ;; Load the system
96
- (ql:quickload :nekod)
97
-
98
- ;; Start the daemon
99
- (nekod:nekomata-main)
100
-
101
- ;; Define a container β€” infrastructure as code, literally
102
- (nekod:define-container my-app
103
- :image "nginx:latest"
104
- :ports '((8080 . 80))
105
- :env '((:NODE_ENV . "production"))
106
- :restart-policy :always)
107
-
108
- ;; Self-healing failover chain
109
- (nekod:with-failover my-app my-app-replica my-app-standby)
110
-
111
- ;; Drop into the live REPL
112
- (nekod:nekod-repl)
113
- ```
114
-
115
- ---
116
-
117
- ## Architecture
118
-
119
- ```
120
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
121
- β”‚ NEKOMATA ENGINE β”‚
122
- β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
123
- β”‚ β”‚
124
- β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
125
- β”‚ β”‚ CLI β”‚ β”‚ EVAL LOOP β”‚ β”‚ CONTAINER REGISTRY β”‚ β”‚
126
- β”‚ β”‚ neko.lisp│──>β”‚ nekod-repl │──>β”‚ define-container β”‚ β”‚
127
- β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ with-failover β”‚ β”‚
128
- β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
129
- β”‚ β”‚
130
- β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
131
- β”‚ β”‚ SPARSE MoE ROUTER β”‚ β”‚
132
- β”‚ β”‚ β”‚ β”‚
133
- β”‚ β”‚ Input(8) ──> Gate Network ──> Top-K(2) ──> Softmax β”‚ β”‚
134
- β”‚ β”‚ β”‚ β”‚
135
- β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β” β”‚ β”‚
136
- β”‚ β”‚ β”‚SCHEDULINGβ”‚NETWORKINGβ”‚ STORAGE β”‚ RECOVERY β”‚ SECURITY β”‚SCβ”‚ β”‚ β”‚
137
- β”‚ β”‚ β”‚ cron β”‚ socket β”‚ disk β”‚ failover β”‚ auth β”‚alβ”‚ β”‚ β”‚
138
- β”‚ β”‚ β”‚ deploy β”‚ http β”‚ persist β”‚ rollback β”‚ encrypt β”‚e β”‚ β”‚ β”‚
139
- β”‚ β”‚ β”‚ queue β”‚ route β”‚ worm β”‚ backup β”‚ seal β”‚ β”‚ β”‚ β”‚
140
- β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”˜ β”‚ β”‚
141
- β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
142
- β”‚ β”‚
143
- β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
144
- β”‚ β”‚ LLM β†’ ASM COMPILER β”‚ β”‚
145
- β”‚ β”‚ β”‚ β”‚
146
- β”‚ β”‚ "scale nginx to 5" β”‚ β”‚
147
- β”‚ β”‚ β”‚ β”‚ β”‚
148
- β”‚ β”‚ v β”‚ β”‚
149
- β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
150
- β”‚ β”‚ β”‚ TOKENIZE │──>β”‚ AST │──>β”‚ CODEGEN │──>β”‚ VERIFY β”‚ β”‚ β”‚
151
- β”‚ β”‚ β”‚ intent β”‚ β”‚ extract β”‚ β”‚ x86/ARM β”‚ β”‚ bytes β”‚ β”‚ β”‚
152
- β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
153
- β”‚ β”‚ β”‚ β”‚
154
- β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
155
- β”‚ β”‚
156
- β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
157
- β”‚ β”‚ SELF-MODIFICATION β”‚ β”‚
158
- β”‚ β”‚ β”‚ β”‚
159
- β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
160
- β”‚ β”‚ β”‚ HOT-SWAP β”‚ β”‚ GENETIC β”‚ β”‚ STATE β”‚ β”‚ROLLBACK β”‚ β”‚ β”‚
161
- β”‚ β”‚ β”‚ live fn β”‚ β”‚ evolution β”‚ β”‚ capture β”‚ β”‚ points β”‚ β”‚ β”‚
162
- β”‚ β”‚ β”‚ redefine β”‚ β”‚ crossoverβ”‚ β”‚ snapshot β”‚ β”‚ restore β”‚ β”‚ β”‚
163
- β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
164
- β”‚ β”‚ β”‚ β”‚
165
- β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
166
- β”‚ β”‚
167
- β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
168
- β”‚ β”‚ DOCKER SUBSTRATE β”‚ β”‚
169
- β”‚ β”‚ β”‚ β”‚
170
- β”‚ β”‚ Unix Socket ──> HTTP/1.1 Protocol ──> Container Lifecycle β”‚ β”‚
171
- β”‚ β”‚ /var/run/docker.sock β”‚ β”‚
172
- β”‚ β”‚ β”‚ β”‚
173
- β”‚ β”‚ create | start | stop | kill | list | inspect | stats β”‚ β”‚
174
- β”‚ β”‚ pull | tag | prune | network | volume β”‚ β”‚
175
- β”‚ β”‚ β”‚ β”‚
176
- β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
177
- β”‚ β”‚
178
- β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
179
- β”‚ β”‚ SOCKET INGRESS PIPELINE β”‚ β”‚
180
- β”‚ β”‚ β”‚ β”‚
181
- β”‚ β”‚ /var/run/docker.sock β”‚ β”‚
182
- β”‚ β”‚ β”‚ β”‚ β”‚
183
- β”‚ β”‚ v β”‚ β”‚
184
- β”‚ β”‚ Unix Domain Socket (SBCL/CCL/IOlib portable) β”‚ β”‚
185
- β”‚ β”‚ β”‚ β”‚ β”‚
186
- β”‚ β”‚ v β”‚ β”‚
187
- β”‚ β”‚ Incremental HTTP Parser (chunked + content-length) β”‚ β”‚
188
- β”‚ β”‚ β”‚ β”‚ β”‚
189
- β”‚ β”‚ v β”‚ β”‚
190
- β”‚ β”‚ Docker /events Stream (infinite chunked consumption) β”‚ β”‚
191
- β”‚ β”‚ β”‚ β”‚ β”‚
192
- β”‚ β”‚ v β”‚ β”‚
193
- β”‚ β”‚ Compiled DFA Classifier (Thompson + subset construction) β”‚ β”‚
194
- β”‚ β”‚ β”‚ β”‚ β”‚
195
- β”‚ β”‚ v β”‚ β”‚
196
- β”‚ β”‚ 8-Feature Routing Vector ──> Top-K=2 Sparse MoE β”‚ β”‚
197
- β”‚ β”‚ β”‚ β”‚ β”‚
198
- β”‚ β”‚ v β”‚ β”‚
199
- β”‚ β”‚ Expert Dispatch + Deterministic Receipt β”‚ β”‚
200
- β”‚ β”‚ β”‚ β”‚
201
- β”‚ β”‚ Security: capability-based policy, path validation, β”‚ β”‚
202
- β”‚ β”‚ DENY-by-default, no raw socket to untrusted agent β”‚ β”‚
203
- β”‚ β”‚ β”‚ β”‚
204
- β”‚ β”‚ Backpressure: high/low watermarks, queue depth cap, β”‚ β”‚
205
- β”‚ β”‚ event size limits, zero unbounded growth β”‚ β”‚
206
- β”‚ β”‚ β”‚ β”‚
207
- β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
208
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
209
- ```
210
-
211
- ---
212
-
213
- ## The 5-Layer Stack
214
-
215
- ```
216
- LAYER 5: SELF-MODIFICATION
217
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
218
- β”‚ Genetic evolution loop β”‚
219
- β”‚ Hot-swap live function redefinition β”‚
220
- β”‚ State capture + rollback points β”‚
221
- β”‚ Tournament / roulette selection β”‚
222
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
223
- β”‚
224
- LAYER 4: LLM β†’ MACHINE CODE
225
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
226
- β”‚ Intent tokenization β”‚
227
- β”‚ AST extraction (infra-ast struct) β”‚
228
- β”‚ x86-64 + ARM64 code generation β”‚
229
- β”‚ Byte-level verification β”‚
230
- β”‚ Constraint algebra (cpu/mem/latency) β”‚
231
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
232
- β”‚
233
- LAYER 3: SPARSE MoE ROUTING
234
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
235
- β”‚ 6 domain experts β”‚
236
- β”‚ Noisy Top-K gating (k=2) β”‚
237
- β”‚ Load-balance loss β”‚
238
- β”‚ Xavier/Glorot trained weights (R pipeline) β”‚
239
- β”‚ WORM-sealed gradient history β”‚
240
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
241
- β”‚
242
- LAYER 2: REGEX MATHEMATICS
243
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
244
- β”‚ Kleene algebra (concat/union/star) β”‚
245
- β”‚ DFA compilation + socket event filtering β”‚
246
- β”‚ NL intent β†’ regex pattern mapping β”‚
247
- β”‚ Formal algebra at the wire level β”‚
248
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
249
- β”‚
250
- LAYER 1: LISP CORE
251
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
252
- β”‚ s-expression infrastructure DSL β”‚
253
- β”‚ Container lifecycle management β”‚
254
- β”‚ Docker Engine API (Unix socket) β”‚
255
- β”‚ Condition system + restarts β”‚
256
- β”‚ Image persistence (save/restore world) β”‚
257
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
258
- ```
259
-
260
- ---
261
-
262
- ## User Guide
263
-
264
- ### Container Management
265
-
266
- ```
267
- ╔══════════════════════════════════════════════════════════════╗
268
- β•‘ COMMAND DESCRIPTION β•‘
269
- ╠══════════════════════════════════════════════════════════════╣
270
- β•‘ neko run <spec> Create and start a container β•‘
271
- β•‘ neko stop <name> Stop a running container β•‘
272
- β•‘ neko kill <name> Force-kill a container β•‘
273
- β•‘ neko list List all managed containers β•‘
274
- β•‘ neko status Show system status + expert load β•‘
275
- β•‘ neko evolve Run one generation of evolution β•‘
276
- β•‘ neko repl Drop into the Nekomata REPL β•‘
277
- β•‘ neko save Snapshot current world state β•‘
278
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
279
- ```
280
-
281
- ### Container DSL Examples
282
-
283
- ```lisp
284
- ;; ─── Basic Container ────────────────────────────────────────────
285
- (define-container web-server
286
- :image "nginx:alpine"
287
- :ports '((80 . 80) (443 . 443))
288
- :env '((:WORKER_PROCESSES . "auto"))
289
- :restart-policy :always)
290
-
291
- ;; ─── Database with Persistent Volume ────────────────────────────
292
- (define-container postgres-db
293
- :image "postgres:16"
294
- :ports '((5432 . 5432))
295
- :env '((:POSTGRES_PASSWORD . "sovereign")
296
- (:POSTGRES_DB . "nekod"))
297
- :volumes '(("/data/pg" . "/var/lib/postgresql/data"))
298
- :restart-policy :unless-stopped)
299
-
300
- ;; ─── Failover Chain (automatic promotion) ───────────────────────
301
- (with-failover postgres-db postgres-replica postgres-standby)
302
-
303
- ;; ─── Natural Language Intent ────────────────────────────────────
304
- (nekod-eval "scale web-server to 5 replicas with 512mb memory limit")
305
- ;; => Compiles to ASM, verifies bytes, executes container operations
306
- ```
307
-
308
- ### The REPL
309
-
310
- ```
311
- ╔══════════════════════════════════════════════════════════════╗
312
- β•‘ NEKOMATA REPL v1.0 β•‘
313
- ╠══════════════════════════════════════════════════════════════╣
314
- β•‘ β•‘
315
- β•‘ nekod> (list-containers) β•‘
316
- β•‘ => (#<CONTAINER web-server :running> β•‘
317
- β•‘ #<CONTAINER postgres-db :running> β•‘
318
- β•‘ #<CONTAINER redis-cache :running>) β•‘
319
- β•‘ β•‘
320
- β•‘ nekod> (route-intent "deploy new redis cluster") β•‘
321
- β•‘ => Expert: SCHEDULING (0.72) β•‘
322
- β•‘ Expert: STORAGE (0.28) β•‘
323
- β•‘ Action: create-cluster redis 3 replicas β•‘
324
- β•‘ β•‘
325
- β•‘ nekod> (evolve-generation :population 20 :rounds 5) β•‘
326
- β•‘ => Generation 1: best-fitness 0.847 β•‘
327
- β•‘ Generation 2: best-fitness 0.891 β•‘
328
- β•‘ Generation 3: best-fitness 0.923 β•‘
329
- β•‘ ... β•‘
330
- β•‘ Winner: scheduling-expert-v3 (fitness: 0.961) β•‘
331
- β•‘ Hot-swapping into live router... β•‘
332
- β•‘ Done. β•‘
333
- β•‘ β•‘
334
- β•‘ nekod> (save-nekod-image "checkpoint-2026-08-08") β•‘
335
- β•‘ => World saved. 847 objects, 12.3MB. β•‘
336
- β•‘ WORM sealed: a8f3c91d... β•‘
337
- β•‘ β•‘
338
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
339
- ```
340
-
341
- ---
342
-
343
- ## MoE Router β€” Sparse Expert Selection
344
-
345
- ```
346
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
347
- β”‚ INPUT VECTOR (8 features) β”‚
348
- β”‚ β”‚
349
- β”‚ [is_proof, is_auth, is_code, is_system, β”‚
350
- β”‚ complexity, entropy, confidence, urgency] β”‚
351
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
352
- β”‚
353
- v
354
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
355
- β”‚ GATING NETWORK β”‚
356
- β”‚ β”‚
357
- β”‚ s_i = dot(W_i, h) + b_i + noise_i β”‚
358
- β”‚ noise_i ~ N(0, softplus(W_noise Β· h)) β”‚
359
- β”‚ β”‚
360
- β”‚ Top-K selection (K=2) β”‚
361
- β”‚ Softmax over selected ONLY β”‚
362
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
363
- β”‚
364
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
365
- v v v
366
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
367
- β”‚ EXPERT A β”‚ β”‚ EXPERT B β”‚ β”‚ (inactive) β”‚
368
- β”‚ prob: 0.72 β”‚ β”‚ prob: 0.28 β”‚ β”‚ prob: 0.00 β”‚
369
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€οΏ½οΏ½β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
370
- β”‚ β”‚
371
- v v
372
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
373
- β”‚ OUTPUT = p_A * expert_A + p_B * expert_B β”‚
374
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
375
- ```
376
-
377
- ### The 6 Experts
378
-
379
- | Expert | Domain | Handles |
380
- |--------|--------|---------|
381
- | **SCHEDULING** | Time + orchestration | cron, deploy, queue, scaling events |
382
- | **NETWORKING** | Connectivity | socket, http, routing, port management |
383
- | **STORAGE** | Persistence | disk, WORM chains, volumes, snapshots |
384
- | **RECOVERY** | Fault tolerance | failover, rollback, restart, backup |
385
- | **SECURITY** | Auth + crypto | certificates, encryption, sealing |
386
- | **SCALING** | Load management | replicas, sharding, capacity planning |
387
-
388
- ### Weight Training Pipeline
389
-
390
- ```
391
- WORM Chain ──> R Feature Extraction ──> Xavier/Glorot Init
392
- (.jsonl) (8 features) (W1: 8x16, W2: 16x6)
393
- β”‚
394
- v
395
- Forward Pass + Backprop
396
- Binary Cross-Entropy Loss
397
- β”‚
398
- v
399
- WORM Seal (every 10 epochs)
400
- SHA-256 weight hash
401
- β”‚
402
- v
403
- Export: router_weights.json
404
- β”‚
405
- v
406
- Lisp: load-trained-weights
407
- Hot-loaded into live router
408
- ```
409
-
410
- ---
411
-
412
- ## LLM β†’ Machine Code Compilation
413
-
414
- ```
415
- ╔══════════════════════════════════════════════════════════════╗
416
- β•‘ β•‘
417
- β•‘ "scale nginx to 5 with 256mb memory limit" β•‘
418
- β•‘ β•‘
419
- β•‘ β”‚ TOKENIZE β•‘
420
- β•‘ v β•‘
421
- β•‘ [:scale :nginx :to :5 :with :256mb :memory :limit] β•‘
422
- β•‘ β•‘
423
- β•‘ β”‚ AST EXTRACT β•‘
424
- β•‘ v β•‘
425
- β•‘ #S(INFRA-AST β•‘
426
- β•‘ :TYPE :SCALE β•‘
427
- β•‘ :TARGET "nginx" β•‘
428
- β•‘ :PARAMS (:COUNT 5 :MEMORY 268435456)) β•‘
429
- β•‘ β•‘
430
- β•‘ β”‚ CODEGEN (x86-64) β•‘
431
- β•‘ v β•‘
432
- β•‘ #(#x48 #x89 #xF8 ; mov rax, rdi β•‘
433
- β•‘ #x48 #x6B #xC0 5 ; imul rax, 5 β•‘
434
- β•‘ #xC3) ; ret β•‘
435
- β•‘ β•‘
436
- β•‘ β”‚ VERIFY β•‘
437
- β•‘ v β•‘
438
- β•‘ [OK] First byte valid (0x48 = REX.W prefix) β•‘
439
- β•‘ [OK] Last byte = 0xC3 (RET) β•‘
440
- β•‘ [OK] No privileged instructions β•‘
441
- β•‘ [OK] Length within bounds β•‘
442
- β•‘ β•‘
443
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
444
- ```
445
-
446
- ### Supported Backends
447
-
448
- | Backend | Status | Instruction Set |
449
- |---------|--------|-----------------|
450
- | **x86-64** | Production | REX prefix, MOV, ADD, IMUL, XOR, PUSH/POP, CALL, RET |
451
- | **ARM64** | Production | Fixed-width 32-bit, MOV/MOVK, ADD, SUB, MUL, BR, RET |
452
-
453
- ---
454
-
455
- ## Self-Modification Engine
456
-
457
- ```
458
- ╔══════════════════════════════════════════════════════════════╗
459
- β•‘ GENETIC EVOLUTION LOOP β•‘
460
- ╠══════════════════════════════════════════════════════════════╣
461
- β•‘ β•‘
462
- β•‘ 1. POPULATION β•‘
463
- β•‘ Generate N candidate expert functions β•‘
464
- β•‘ β•‘
465
- β•‘ 2. EVALUATE β•‘
466
- β•‘ Run each candidate against real container workloads β•‘
467
- β•‘ Fitness = success_rate * latency_inverse * memory_eff β•‘
468
- β•‘ β•‘
469
- β•‘ 3. SELECT β•‘
470
- β•‘ Tournament selection (pool=4) OR roulette wheel β•‘
471
- β•‘ β•‘
472
- β•‘ 4. CROSSOVER β•‘
473
- β•‘ Swap s-expression subtrees between parents β•‘
474
- β•‘ Code IS data β€” crossover is tree surgery β•‘
475
- β•‘ β•‘
476
- β•‘ 5. MUTATE β•‘
477
- β•‘ Random subtree replacement, constant perturbation β•‘
478
- β•‘ β•‘
479
- β•‘ 6. HOT-SWAP β•‘
480
- β•‘ Winner replaces live expert function β€” zero downtime β•‘
481
- β•‘ Automatic rollback if fitness drops below threshold β•‘
482
- β•‘ β•‘
483
- β•‘ 7. SEAL β•‘
484
- β•‘ State captured, rollback point created, WORM sealed β•‘
485
- β•‘ β•‘
486
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
487
- ```
488
-
489
- ---
490
-
491
- ## Regex Mathematics β€” Formal Algebra at the Wire
492
-
493
- ```
494
- ╔══════════════════════════════════════════════════════════════╗
495
- β•‘ KLEENE ALGEBRA PRIMITIVES β•‘
496
- ╠══════════════════════════════════════════════════════════════╣
497
- β•‘ β•‘
498
- β•‘ LITERAL(c) Match single character c β•‘
499
- β•‘ CONCAT(r1, r2) Sequence: r1 then r2 β•‘
500
- β•‘ UNION(r1, r2) Choice: r1 or r2 β•‘
501
- β•‘ KLEENE(r) Zero or more: r* β•‘
502
- β•‘ PLUS(r) One or more: r+ β•‘
503
- β•‘ OPTIONAL(r) Zero or one: r? β•‘
504
- β•‘ β•‘
505
- ╠══════════════════════════════════════════════════════════════╣
506
- β•‘ β•‘
507
- β•‘ DFA COMPILATION: β•‘
508
- β•‘ β•‘
509
- β•‘ regex-algebra.lisp ──> pattern-compiler.lisp β•‘
510
- β•‘ (algebraic form) (DFA states + transitions) β•‘
511
- β•‘ β•‘
512
- β•‘ dfa-step(state, char) => next-state β•‘
513
- β•‘ dfa-run(dfa, string) => accept | reject β•‘
514
- β•‘ β•‘
515
- β•‘ SOCKET FILTERING: β•‘
516
- β•‘ β•‘
517
- β•‘ Every Docker event passes through DFA filter β•‘
518
- β•‘ Pattern: container.(start|stop|die|kill) β•‘
519
- β•‘ Only matching events reach the MoE router β•‘
520
- β•‘ β•‘
521
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
522
- ```
523
-
524
- ---
525
-
526
- ## Project Layout
527
-
528
- ```
529
- nekod/
530
- β”œβ”€β”€ nekod.asd ASDF system definition
531
- β”œβ”€β”€ setup.sh One-command Docker + SBCL installer
532
- β”œβ”€β”€ README.md This file
533
- β”œβ”€β”€ LICENSE AGPL-3.0 + cloud provider poison pill
534
- β”œβ”€β”€ assets/
535
- β”‚ └── nekomata-avatar.png Production model avatar
536
- β”‚
537
- β”œβ”€β”€ core/ ─── LAYER 1: LISP CORE ───
538
- β”‚ β”œβ”€β”€ package.lisp Package definitions (nekod + nekod.docker)
539
- β”‚ β”œβ”€β”€ conditions.lisp Error hierarchy + restart system
540
- β”‚ β”œβ”€β”€ sexpr-infra.lisp Container DSL (define-container, with-failover)
541
- β”‚ β”œβ”€β”€ eval-loop.lisp Nekomata REPL (nekod-eval, nekod-repl)
542
- β”‚ β”œβ”€β”€ image-persist.lisp World state save/restore
543
- β”‚ └── nekomata.lisp Entry point + container registry
544
- β”‚
545
- β”œβ”€β”€ docker/ ─── DOCKER SUBSTRATE ───
546
- β”‚ β”œβ”€β”€ unix-sock.lisp Real Unix socket I/O (SBCL/CCL/IOlib)
547
- β”‚ β”œβ”€β”€ protocol.lisp Incremental HTTP/1.1 parser (chunked + CL)
548
- β”‚ β”œβ”€β”€ events.lisp Streaming /events consumer (infinite chunked)
549
- β”‚ β”œβ”€β”€ container.lisp Container lifecycle (create/start/stop/kill)
550
- β”‚ β”œβ”€β”€ image.lisp Image management (pull/list/tag/prune)
551
- β”‚ β”œβ”€β”€ network.lisp Network create/connect/disconnect
552
- β”‚ β”œβ”€β”€ volume.lisp Volume create/mount/prune
553
- β”‚ └── inspect.lisp Container + stats inspection
554
- β”‚
555
- β”œβ”€β”€ moe/ ─── LAYER 3: SPARSE MoE ───
556
- β”‚ β”œβ”€β”€ router.lisp Gating network (score, top-k, softmax)
557
- β”‚ β”œβ”€β”€ sparse-activate.lisp Noisy Top-K + load-balance loss
558
- β”‚ β”œβ”€β”€ expert-train.lisp Online weight updates from telemetry
559
- β”‚ β”œβ”€β”€ load-balance.lisp Expert utilization balancing
560
- β”‚ β”œβ”€β”€ load-trained-weights.lisp R-trained weight loader (JSON import)
561
- β”‚ └── experts/
562
- β”‚ β”œβ”€β”€ scheduling.lisp Cron, deploy, queue management
563
- β”‚ β”œβ”€β”€ networking.lisp Socket, HTTP, port routing
564
- β”‚ β”œβ”€β”€ storage.lisp Disk, WORM, volume persistence
565
- β”‚ β”œβ”€β”€ recovery.lisp Failover, rollback, restart
566
- β”‚ β”œβ”€β”€ security.lisp Auth, encryption, sealing
567
- β”‚ └── scaling.lisp Replicas, shards, capacity
568
- β”‚
569
- β”œβ”€β”€ regex-math/ ─── LAYER 2: KLEENE ALGEBRA ───
570
- β”‚ β”œβ”€β”€ regex-algebra.lisp RE structs (literal/concat/union/kleene)
571
- β”‚ β”œβ”€β”€ pattern-compiler.lisp Thompson NFA β†’ subset DFA compilation
572
- β”‚ β”œβ”€β”€ socket-filter.lisp Compiled DFA event classifier + features
573
- β”‚ └── intent-parse.lisp NL intent β†’ expert keyword mapping
574
- β”‚
575
- β”œβ”€β”€ socket/ ─── SOCKET INGRESS PIPELINE ───
576
- β”‚ β”œβ”€β”€ backpressure.lisp Watermarks, queue depth, size limits
577
- β”‚ β”œβ”€β”€ policy.lisp Capability-based security boundary
578
- β”‚ β”œβ”€β”€ receipt.lisp Deterministic operation receipts
579
- β”‚ └── agent-ingress.lisp Event β†’ classify β†’ route β†’ dispatch
580
- β”‚
581
- β”œβ”€β”€ llm2asm/ ─── LAYER 4: LLM β†’ MACHINE CODE ───
582
- β”‚ β”œβ”€β”€ tokenizer.lisp Intent tokenization + kernel map
583
- β”‚ β”œβ”€β”€ ast-extract.lisp infra-ast struct, intent type detection
584
- β”‚ β”œβ”€β”€ codegen.lisp AST β†’ byte vector compilation
585
- β”‚ β”œβ”€β”€ verify.lisp Byte-level safety verification
586
- β”‚ β”œβ”€β”€ jit-link.lisp JIT stub (mmap + mprotect reference)
587
- β”‚ β”œβ”€β”€ constraint-build.lisp Constraint algebra (cpu/mem/latency)
588
- β”‚ └── backends/
589
- β”‚ β”œβ”€β”€ x86-64.lisp x86-64 instruction encoders
590
- β”‚ └── arm64.lisp ARM64 fixed-width instruction encoders
591
- β”‚
592
- β”œβ”€β”€ selfmod/ ─── LAYER 5: SELF-MODIFICATION ───
593
- β”‚ β”œβ”€β”€ gen-loop.lisp Genetic evolution loop
594
- β”‚ β”œβ”€β”€ hot-swap.lisp Live function redefinition + rollback
595
- β”‚ β”œβ”€β”€ state-capture.lisp State snapshots
596
- β”‚ β”œβ”€β”€ evolve.lisp Crossover + selection algorithms
597
- β”‚ └── rollback.lisp Rollback points, with-rollback macro
598
- β”‚
599
- β”œβ”€β”€ cli/ ─── USER INTERFACE ───
600
- β”‚ └── neko.lisp 8 CLI commands (run/stop/kill/list/...)
601
- β”‚
602
- β”œβ”€β”€ tests/
603
- β”‚ β”œβ”€β”€ test-core.lisp Core test suite
604
- β”‚ β”œβ”€β”€ test-edge-cases.lisp Edge case coverage
605
- β”‚ └── socket-tests.lisp Socket layer: 28 unit + 4 integration tests
606
- β”‚
607
- └── docs/ ─── DOCUMENTATION ───
608
- β”œβ”€β”€ manifesto.org Why Nekomata exists
609
- β”œβ”€β”€ architecture.org 5-layer system design
610
- β”œβ”€β”€ moe-theory.org Sparse MoE mathematics
611
- β”œβ”€β”€ regex-calculus.org Kleene algebra formalism
612
- └── migration.org Kubernetes escape route
613
- ```
614
-
615
- ---
616
-
617
- ## Why Common Lisp?
618
-
619
- ```
620
- ╔═══��══════════════════════════════════════════════════════════╗
621
- β•‘ β•‘
622
- β•‘ CODE = DATA β•‘
623
- β•‘ An s-expression describing a container IS that container. β•‘
624
- β•‘ No YAML. No templating. No string interpolation. β•‘
625
- β•‘ The description evaluates to the thing itself. β•‘
626
- β•‘ β•‘
627
- β•‘ CONDITION SYSTEM β•‘
628
- β•‘ Not try/catch. Restarts. When a container dies, the β•‘
629
- β•‘ condition system offers: restart, promote-replica, β•‘
630
- β•‘ rollback, or escalate. Decided at runtime, not design-time. β•‘
631
- β•‘ β•‘
632
- β•‘ IMAGE-BASED PERSISTENCE β•‘
633
- β•‘ Save the entire world to disk. Restore it later. β•‘
634
- β•‘ The running state IS the deployment artifact. β•‘
635
- β•‘ No container image layers. No registries. Just the world. β•‘
636
- β•‘ β•‘
637
- β•‘ MACROS β•‘
638
- β•‘ define-container is a macro. with-failover is a macro. β•‘
639
- β•‘ The language extends itself to become the domain. β•‘
640
- β•‘ Infrastructure IS language. Language IS infrastructure. β•‘
641
- β•‘ β•‘
642
- β•‘ HOT RELOAD β•‘
643
- β•‘ Redefine any function while the system runs. β•‘
644
- β•‘ No restart. No redeployment. The new code IS the system. β•‘
645
- β•‘ Genetic evolution swaps expert functions live. β•‘
646
- β•‘ β•‘
647
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
648
- ```
649
-
650
- ---
651
-
652
- ## Migration from Kubernetes
653
-
654
- ```
655
- ╔══════════════════════════════════════════════════════════════╗
656
- β•‘ K8S β†’ NEKOMATA MIGRATION PATH β•‘
657
- ╠══════════════════════════════════════════════════════════════╣
658
- β•‘ β•‘
659
- β•‘ Step 1: Install nekod alongside existing cluster β•‘
660
- β•‘ (nekod speaks Docker socket directly β€” no conflict) β•‘
661
- β•‘ β•‘
662
- β•‘ Step 2: Convert Deployment YAMLs β†’ define-container forms β•‘
663
- β•‘ One YAML = one s-expression. Mechanical. β•‘
664
- β•‘ β•‘
665
- β•‘ Step 3: Wire failover chains β•‘
666
- β•‘ (with-failover primary replica standby) β•‘
667
- β•‘ β•‘
668
- β•‘ Step 4: Enable MoE routing β•‘
669
- β•‘ Expert weights train on YOUR workload patterns β•‘
670
- β•‘ β•‘
671
- β•‘ Step 5: Enable self-modification β•‘
672
- β•‘ The system evolves its own expert functions β•‘
673
- β•‘ β•‘
674
- β•‘ Step 6: Decommission K8s control plane β•‘
675
- β•‘ etcd, kube-apiserver, kube-scheduler β€” gone. β•‘
676
- β•‘ Nekomata IS the control plane now. β•‘
677
- β•‘ β•‘
678
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
679
- ```
680
-
681
- ---
682
-
683
- ## Performance Characteristics
684
-
685
- ```
686
- ╔══════════════════════════════════════════════════════════════╗
687
- β•‘ METRIC VALUE β•‘
688
- ╠══════════════════════════════════════════════════════════════╣
689
- β•‘ Memory per expert ~2.3 KB (sparse activation) β•‘
690
- β•‘ Router decision latency <1ms (dot product + softmax) β•‘
691
- β•‘ Active experts per call 2 (Top-K=2, out of 6) β•‘
692
- β•‘ Agents at 2.3KB each 500+ sustainable β•‘
693
- β•‘ Code generation x86-64 + ARM64 native β•‘
694
- β•‘ Hot-swap latency ~0ms (defun redefinition) β•‘
695
- β•‘ World snapshot Full state in single file β•‘
696
- β•‘ Container start Direct Docker API (no etcd) β•‘
697
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
698
- ```
699
-
700
- ---
701
-
702
- ## License
703
-
704
- **AGPL-3.0** with cloud provider poison pill.
705
-
706
- The engine is free. Sovereignty is not optional.
707
-
708
- Any cloud provider deploying Nekomata as a hosted service MUST:
709
- 1. Release all modifications under AGPL-3.0
710
- 2. Provide users a prominent link to modified source
711
- 3. Not remove attribution to SnapKitty Collective
712
-
713
- ---
714
-
715
- ## Credits
716
-
717
- ```
718
- ╔══════════════════════════════════════════════════════════════╗
719
- β•‘ β•‘
720
- β•‘ Architecture Ahmad Ali Parr β•‘
721
- β•‘ Engineering SnapKitty Collective β•‘
722
- β•‘ Model Avatar Nekomata β€” the two-tailed sovereign cat β•‘
723
- β•‘ Execution WORM-sealed, receipt-generating β•‘
724
- β•‘ β•‘
725
- β•‘ "Infrastructure that rewrites itself." β•‘
726
- β•‘ β•‘
727
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
728
- ```
729
-
730
- ---
731
-
732
- <p align="center">
733
- <img src="assets/nekomata-avatar.png" alt="Nekomata" width="160"/>
734
- <br/>
735
- <b>猫又 β€” The two-tailed cat that never dies.</b>
736
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: agpl-3.0
3
+ tags:
4
+ - snapkitty
5
+ ---
6
+
7
+ > Source: [github.com/SNAPKITTYWEST/nekomata](https://github.com/SNAPKITTYWEST/nekomata)
8
+
9
+ <p align="center">
10
+ <img src="assets/nekomata-avatar.png" alt="Nekomata" width="320"/>
11
+ </p>
12
+
13
+ <h1 align="center">NEKOMATA 猫又</h1>
14
+ <h3 align="center">The Autonomous Container Engine</h3>
15
+
16
+ <p align="center">
17
+ <img src="https://img.shields.io/badge/language-Common_Lisp-blueviolet?style=flat-square"/>
18
+ <img src="https://img.shields.io/badge/engine-nekod-ff69b4?style=flat-square"/>
19
+ <img src="https://img.shields.io/badge/MoE-6_experts-orange?style=flat-square"/>
20
+ <img src="https://img.shields.io/badge/codegen-x86--64_%2B_ARM64-green?style=flat-square"/>
21
+ <img src="https://img.shields.io/badge/license-AGPL--3.0-red?style=flat-square"/>
22
+ <img src="https://img.shields.io/badge/status-PRODUCTION-brightgreen?style=flat-square"/>
23
+ <img src="https://img.shields.io/badge/self--mod-genetic_evolution-gold?style=flat-square"/>
24
+ <img src="https://img.shields.io/badge/WORM-sealed-black?style=flat-square"/>
25
+ </p>
26
+
27
+ <p align="center"><b>Infrastructure that rewrites itself.</b></p>
28
+
29
+ ---
30
+
31
+ ```
32
+ β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
33
+ β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
34
+ β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
35
+ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘
36
+ β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
37
+ β•šβ•β• β•šβ•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•šβ•β• β•šβ•β• β•šβ•β• β•šβ•β• β•šβ•β•
38
+
39
+ Infrastructure is code.
40
+ Code is data.
41
+ Data is alive.
42
+ ```
43
+
44
+ ---
45
+
46
+ ## What Is This?
47
+
48
+ Nekomata is the **first AI-native container engine** built from first principles in Common Lisp. Not a Kubernetes alternative. A Kubernetes **replacement**.
49
+
50
+ The Nekomata (猫又) is a supernatural cat with two tails: **code** and **data**. In Common Lisp, these are the same thing. Infrastructure is s-expressions. Containers evaluate. They transform. They **rewrite themselves**.
51
+
52
+ ```
53
+ ╔═════════════════════════════════════════════════════════════════════��╗
54
+ β•‘ β•‘
55
+ β•‘ Kubernetes: 50B of YAML debt on a distributed key-value store β•‘
56
+ β•‘ Nekomata: s-expressions that evaluate their own infrastructure β•‘
57
+ β•‘ β•‘
58
+ β•‘ Kubernetes: Reactive watch loops waiting for state drift β•‘
59
+ ║ Nekomata: Predictive LLM→ASM compilation of intent ║
60
+ β•‘ β•‘
61
+ β•‘ Kubernetes: Monolithic control plane (etcd + api-server + ...) β•‘
62
+ β•‘ Nekomata: Sparse Mixture of Experts β€” 6 specialists, Top-K=2 β•‘
63
+ β•‘ β•‘
64
+ β•‘ Kubernetes: Immutable containers, no runtime modification β•‘
65
+ β•‘ Nekomata: Live REPL injection + genetic self-modification β•‘
66
+ β•‘ β•‘
67
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Setup
73
+
74
+ ```bash
75
+ # One command β€” installs Docker + SBCL + Quicklisp
76
+ bash setup.sh
77
+ ```
78
+
79
+ Supports Ubuntu/Debian, Fedora/RHEL, Arch Linux, and macOS (via Homebrew).
80
+
81
+ Or manually:
82
+ ```bash
83
+ # 1. Docker
84
+ curl -fsSL https://get.docker.com | sh
85
+ sudo usermod -aG docker $USER && newgrp docker
86
+
87
+ # 2. SBCL
88
+ sudo apt install sbcl # or: brew install sbcl
89
+
90
+ # 3. Quicklisp
91
+ curl -O https://beta.quicklisp.org/quicklisp.lisp
92
+ sbcl --load quicklisp.lisp --eval '(quicklisp-quickstart:install)'
93
+
94
+ # 4. Load Nekomata
95
+ cd nekomata && sbcl --load nekod.asd --eval '(ql:quickload :nekod)'
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Quick Start
101
+
102
+ ```lisp
103
+ ;; Load the system
104
+ (ql:quickload :nekod)
105
+
106
+ ;; Start the daemon
107
+ (nekod:nekomata-main)
108
+
109
+ ;; Define a container β€” infrastructure as code, literally
110
+ (nekod:define-container my-app
111
+ :image "nginx:latest"
112
+ :ports '((8080 . 80))
113
+ :env '((:NODE_ENV . "production"))
114
+ :restart-policy :always)
115
+
116
+ ;; Self-healing failover chain
117
+ (nekod:with-failover my-app my-app-replica my-app-standby)
118
+
119
+ ;; Drop into the live REPL
120
+ (nekod:nekod-repl)
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Architecture
126
+
127
+ ```
128
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
129
+ β”‚ NEKOMATA ENGINE β”‚
130
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
131
+ β”‚ β”‚
132
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
133
+ β”‚ β”‚ CLI β”‚ β”‚ EVAL LOOP β”‚ β”‚ CONTAINER REGISTRY β”‚ β”‚
134
+ β”‚ β”‚ neko.lisp│──>β”‚ nekod-repl │──>β”‚ define-container β”‚ β”‚
135
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ with-failover β”‚ β”‚
136
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
137
+ β”‚ β”‚
138
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
139
+ β”‚ β”‚ SPARSE MoE ROUTER β”‚ β”‚
140
+ β”‚ β”‚ β”‚ β”‚
141
+ β”‚ β”‚ Input(8) ──> Gate Network ──> Top-K(2) ──> Softmax β”‚ β”‚
142
+ β”‚ β”‚ β”‚ β”‚
143
+ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β” β”‚ β”‚
144
+ β”‚ β”‚ β”‚SCHEDULINGβ”‚NETWORKINGβ”‚ STORAGE β”‚ RECOVERY β”‚ SECURITY β”‚SCβ”‚ β”‚ β”‚
145
+ β”‚ β”‚ β”‚ cron β”‚ socket β”‚ disk β”‚ failover β”‚ auth β”‚alβ”‚ β”‚ β”‚
146
+ β”‚ β”‚ β”‚ deploy β”‚ http β”‚ persist β”‚ rollback β”‚ encrypt β”‚e β”‚ β”‚ β”‚
147
+ β”‚ β”‚ β”‚ queue β”‚ route β”‚ worm β”‚ backup β”‚ seal β”‚ β”‚ β”‚ β”‚
148
+ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”˜ β”‚ β”‚
149
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
150
+ β”‚ β”‚
151
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
152
+ β”‚ β”‚ LLM β†’ ASM COMPILER β”‚ β”‚
153
+ β”‚ β”‚ β”‚ β”‚
154
+ β”‚ β”‚ "scale nginx to 5" β”‚ β”‚
155
+ β”‚ β”‚ β”‚ β”‚ β”‚
156
+ β”‚ β”‚ v β”‚ β”‚
157
+ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
158
+ β”‚ β”‚ β”‚ TOKENIZE │──>β”‚ AST │──>β”‚ CODEGEN │──>β”‚ VERIFY β”‚ β”‚ β”‚
159
+ β”‚ β”‚ β”‚ intent β”‚ β”‚ extract β”‚ β”‚ x86/ARM β”‚ β”‚ bytes β”‚ β”‚ β”‚
160
+ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
161
+ β”‚ β”‚ β”‚ β”‚
162
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
163
+ β”‚ β”‚
164
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
165
+ β”‚ β”‚ SELF-MODIFICATION β”‚ β”‚
166
+ β”‚ β”‚ β”‚ β”‚
167
+ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
168
+ β”‚ β”‚ β”‚ HOT-SWAP β”‚ β”‚ GENETIC β”‚ β”‚ STATE β”‚ β”‚ROLLBACK β”‚ β”‚ β”‚
169
+ β”‚ β”‚ β”‚ live fn β”‚ β”‚ evolution β”‚ β”‚ capture β”‚ β”‚ points β”‚ β”‚ β”‚
170
+ β”‚ β”‚ β”‚ redefine β”‚ β”‚ crossoverβ”‚ β”‚ snapshot β”‚ β”‚ restore β”‚ β”‚ β”‚
171
+ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
172
+ β”‚ β”‚ β”‚ β”‚
173
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
174
+ β”‚ β”‚
175
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
176
+ β”‚ β”‚ DOCKER SUBSTRATE β”‚ β”‚
177
+ β”‚ β”‚ β”‚ β”‚
178
+ β”‚ β”‚ Unix Socket ──> HTTP/1.1 Protocol ──> Container Lifecycle β”‚ β”‚
179
+ β”‚ β”‚ /var/run/docker.sock β”‚ β”‚
180
+ β”‚ β”‚ β”‚ β”‚
181
+ β”‚ β”‚ create | start | stop | kill | list | inspect | stats β”‚ β”‚
182
+ β”‚ β”‚ pull | tag | prune | network | volume β”‚ β”‚
183
+ β”‚ β”‚ β”‚ β”‚
184
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
185
+ β”‚ β”‚
186
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
187
+ β”‚ β”‚ SOCKET INGRESS PIPELINE β”‚ β”‚
188
+ β”‚ β”‚ β”‚ β”‚
189
+ β”‚ β”‚ /var/run/docker.sock β”‚ β”‚
190
+ β”‚ β”‚ β”‚ β”‚ β”‚
191
+ β”‚ β”‚ v β”‚ β”‚
192
+ β”‚ β”‚ Unix Domain Socket (SBCL/CCL/IOlib portable) β”‚ β”‚
193
+ β”‚ β”‚ β”‚ β”‚ β”‚
194
+ β”‚ β”‚ v β”‚ β”‚
195
+ β”‚ β”‚ Incremental HTTP Parser (chunked + content-length) β”‚ β”‚
196
+ β”‚ β”‚ β”‚ β”‚ β”‚
197
+ β”‚ β”‚ v β”‚ β”‚
198
+ β”‚ β”‚ Docker /events Stream (infinite chunked consumption) β”‚ β”‚
199
+ β”‚ β”‚ β”‚ β”‚ β”‚
200
+ β”‚ β”‚ v β”‚ β”‚
201
+ β”‚ β”‚ Compiled DFA Classifier (Thompson + subset construction) β”‚ β”‚
202
+ β”‚ β”‚ β”‚ β”‚ β”‚
203
+ β”‚ β”‚ v β”‚ β”‚
204
+ β”‚ β”‚ 8-Feature Routing Vector ──> Top-K=2 Sparse MoE β”‚ β”‚
205
+ β”‚ β”‚ β”‚ β”‚ β”‚
206
+ β”‚ β”‚ v β”‚ β”‚
207
+ β”‚ β”‚ Expert Dispatch + Deterministic Receipt β”‚ β”‚
208
+ β”‚ β”‚ β”‚ β”‚
209
+ β”‚ β”‚ Security: capability-based policy, path validation, β”‚ β”‚
210
+ β”‚ β”‚ DENY-by-default, no raw socket to untrusted agent β”‚ β”‚
211
+ β”‚ β”‚ β”‚ β”‚
212
+ β”‚ β”‚ Backpressure: high/low watermarks, queue depth cap, β”‚ β”‚
213
+ β”‚ β”‚ event size limits, zero unbounded growth β”‚ β”‚
214
+ β”‚ β”‚ β”‚ β”‚
215
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
216
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
217
+ ```
218
+
219
+ ---
220
+
221
+ ## The 5-Layer Stack
222
+
223
+ ```
224
+ LAYER 5: SELF-MODIFICATION
225
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
226
+ β”‚ Genetic evolution loop β”‚
227
+ β”‚ Hot-swap live function redefinition β”‚
228
+ β”‚ State capture + rollback points β”‚
229
+ β”‚ Tournament / roulette selection β”‚
230
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
231
+ β”‚
232
+ LAYER 4: LLM β†’ MACHINE CODE
233
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
234
+ β”‚ Intent tokenization β”‚
235
+ β”‚ AST extraction (infra-ast struct) β”‚
236
+ β”‚ x86-64 + ARM64 code generation β”‚
237
+ β”‚ Byte-level verification β”‚
238
+ β”‚ Constraint algebra (cpu/mem/latency) β”‚
239
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
240
+ β”‚
241
+ LAYER 3: SPARSE MoE ROUTING
242
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
243
+ β”‚ 6 domain experts β”‚
244
+ β”‚ Noisy Top-K gating (k=2) β”‚
245
+ β”‚ Load-balance loss β”‚
246
+ β”‚ Xavier/Glorot trained weights (R pipeline) β”‚
247
+ β”‚ WORM-sealed gradient history β”‚
248
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
249
+ β”‚
250
+ LAYER 2: REGEX MATHEMATICS
251
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
252
+ β”‚ Kleene algebra (concat/union/star) β”‚
253
+ β”‚ DFA compilation + socket event filtering β”‚
254
+ β”‚ NL intent β†’ regex pattern mapping β”‚
255
+ β”‚ Formal algebra at the wire level β”‚
256
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
257
+ β”‚
258
+ LAYER 1: LISP CORE
259
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
260
+ β”‚ s-expression infrastructure DSL β”‚
261
+ β”‚ Container lifecycle management β”‚
262
+ β”‚ Docker Engine API (Unix socket) β”‚
263
+ β”‚ Condition system + restarts β”‚
264
+ β”‚ Image persistence (save/restore world) β”‚
265
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
266
+ ```
267
+
268
+ ---
269
+
270
+ ## User Guide
271
+
272
+ ### Container Management
273
+
274
+ ```
275
+ ╔══════════════════════════════════════════════════════════════╗
276
+ β•‘ COMMAND DESCRIPTION β•‘
277
+ ╠══════════════════════════════════════════════════════════════╣
278
+ β•‘ neko run <spec> Create and start a container β•‘
279
+ β•‘ neko stop <name> Stop a running container β•‘
280
+ β•‘ neko kill <name> Force-kill a container β•‘
281
+ β•‘ neko list List all managed containers β•‘
282
+ β•‘ neko status Show system status + expert load β•‘
283
+ β•‘ neko evolve Run one generation of evolution β•‘
284
+ β•‘ neko repl Drop into the Nekomata REPL β•‘
285
+ β•‘ neko save Snapshot current world state β•‘
286
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
287
+ ```
288
+
289
+ ### Container DSL Examples
290
+
291
+ ```lisp
292
+ ;; ─── Basic Container ────────────────────────────────────────────
293
+ (define-container web-server
294
+ :image "nginx:alpine"
295
+ :ports '((80 . 80) (443 . 443))
296
+ :env '((:WORKER_PROCESSES . "auto"))
297
+ :restart-policy :always)
298
+
299
+ ;; ─── Database with Persistent Volume ────────────────────────────
300
+ (define-container postgres-db
301
+ :image "postgres:16"
302
+ :ports '((5432 . 5432))
303
+ :env '((:POSTGRES_PASSWORD . "sovereign")
304
+ (:POSTGRES_DB . "nekod"))
305
+ :volumes '(("/data/pg" . "/var/lib/postgresql/data"))
306
+ :restart-policy :unless-stopped)
307
+
308
+ ;; ─── Failover Chain (automatic promotion) ───────────────────────
309
+ (with-failover postgres-db postgres-replica postgres-standby)
310
+
311
+ ;; ─── Natural Language Intent ────────────────────────────────────
312
+ (nekod-eval "scale web-server to 5 replicas with 512mb memory limit")
313
+ ;; => Compiles to ASM, verifies bytes, executes container operations
314
+ ```
315
+
316
+ ### The REPL
317
+
318
+ ```
319
+ ╔══════════════════════════════════════════════════════════════╗
320
+ β•‘ NEKOMATA REPL v1.0 β•‘
321
+ ╠══════════════════════════════════════════════════════════════╣
322
+ β•‘ β•‘
323
+ β•‘ nekod> (list-containers) β•‘
324
+ β•‘ => (#<CONTAINER web-server :running> β•‘
325
+ β•‘ #<CONTAINER postgres-db :running> β•‘
326
+ β•‘ #<CONTAINER redis-cache :running>) β•‘
327
+ β•‘ β•‘
328
+ β•‘ nekod> (route-intent "deploy new redis cluster") β•‘
329
+ β•‘ => Expert: SCHEDULING (0.72) β•‘
330
+ β•‘ Expert: STORAGE (0.28) β•‘
331
+ β•‘ Action: create-cluster redis 3 replicas β•‘
332
+ β•‘ β•‘
333
+ β•‘ nekod> (evolve-generation :population 20 :rounds 5) β•‘
334
+ β•‘ => Generation 1: best-fitness 0.847 β•‘
335
+ β•‘ Generation 2: best-fitness 0.891 β•‘
336
+ β•‘ Generation 3: best-fitness 0.923 β•‘
337
+ β•‘ ... β•‘
338
+ β•‘ Winner: scheduling-expert-v3 (fitness: 0.961) β•‘
339
+ β•‘ Hot-swapping into live router... β•‘
340
+ β•‘ Done. β•‘
341
+ β•‘ β•‘
342
+ β•‘ nekod> (save-nekod-image "checkpoint-2026-08-08") β•‘
343
+ β•‘ => World saved. 847 objects, 12.3MB. β•‘
344
+ β•‘ WORM sealed: a8f3c91d... β•‘
345
+ β•‘ β•‘
346
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
347
+ ```
348
+
349
+ ---
350
+
351
+ ## MoE Router β€” Sparse Expert Selection
352
+
353
+ ```
354
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€οΏ½οΏ½οΏ½
355
+ β”‚ INPUT VECTOR (8 features) β”‚
356
+ β”‚ β”‚
357
+ β”‚ [is_proof, is_auth, is_code, is_system, β”‚
358
+ β”‚ complexity, entropy, confidence, urgency] β”‚
359
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
360
+ β”‚
361
+ v
362
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
363
+ β”‚ GATING NETWORK β”‚
364
+ β”‚ β”‚
365
+ β”‚ s_i = dot(W_i, h) + b_i + noise_i β”‚
366
+ β”‚ noise_i ~ N(0, softplus(W_noise Β· h)) β”‚
367
+ β”‚ β”‚
368
+ β”‚ Top-K selection (K=2) β”‚
369
+ β”‚ Softmax over selected ONLY β”‚
370
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
371
+ β”‚
372
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
373
+ v v v
374
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
375
+ β”‚ EXPERT A β”‚ β”‚ EXPERT B β”‚ β”‚ (inactive) β”‚
376
+ β”‚ prob: 0.72 β”‚ β”‚ prob: 0.28 β”‚ β”‚ prob: 0.00 β”‚
377
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
378
+ β”‚ β”‚
379
+ v v
380
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
381
+ β”‚ OUTPUT = p_A * expert_A + p_B * expert_B β”‚
382
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
383
+ ```
384
+
385
+ ### The 6 Experts
386
+
387
+ | Expert | Domain | Handles |
388
+ |--------|--------|---------|
389
+ | **SCHEDULING** | Time + orchestration | cron, deploy, queue, scaling events |
390
+ | **NETWORKING** | Connectivity | socket, http, routing, port management |
391
+ | **STORAGE** | Persistence | disk, WORM chains, volumes, snapshots |
392
+ | **RECOVERY** | Fault tolerance | failover, rollback, restart, backup |
393
+ | **SECURITY** | Auth + crypto | certificates, encryption, sealing |
394
+ | **SCALING** | Load management | replicas, sharding, capacity planning |
395
+
396
+ ### Weight Training Pipeline
397
+
398
+ ```
399
+ WORM Chain ──> R Feature Extraction ──> Xavier/Glorot Init
400
+ (.jsonl) (8 features) (W1: 8x16, W2: 16x6)
401
+ β”‚
402
+ v
403
+ Forward Pass + Backprop
404
+ Binary Cross-Entropy Loss
405
+ β”‚
406
+ v
407
+ WORM Seal (every 10 epochs)
408
+ SHA-256 weight hash
409
+ β”‚
410
+ v
411
+ Export: router_weights.json
412
+ β”‚
413
+ v
414
+ Lisp: load-trained-weights
415
+ Hot-loaded into live router
416
+ ```
417
+
418
+ ---
419
+
420
+ ## LLM β†’ Machine Code Compilation
421
+
422
+ ```
423
+ ╔══════════════════════════════════════════════════════════════╗
424
+ β•‘ β•‘
425
+ β•‘ "scale nginx to 5 with 256mb memory limit" β•‘
426
+ β•‘ β•‘
427
+ β•‘ β”‚ TOKENIZE β•‘
428
+ β•‘ v β•‘
429
+ β•‘ [:scale :nginx :to :5 :with :256mb :memory :limit] β•‘
430
+ β•‘ β•‘
431
+ β•‘ β”‚ AST EXTRACT β•‘
432
+ β•‘ v β•‘
433
+ β•‘ #S(INFRA-AST β•‘
434
+ β•‘ :TYPE :SCALE β•‘
435
+ β•‘ :TARGET "nginx" β•‘
436
+ β•‘ :PARAMS (:COUNT 5 :MEMORY 268435456)) β•‘
437
+ β•‘ β•‘
438
+ β•‘ β”‚ CODEGEN (x86-64) β•‘
439
+ β•‘ v β•‘
440
+ β•‘ #(#x48 #x89 #xF8 ; mov rax, rdi β•‘
441
+ β•‘ #x48 #x6B #xC0 5 ; imul rax, 5 β•‘
442
+ β•‘ #xC3) ; ret β•‘
443
+ β•‘ β•‘
444
+ β•‘ β”‚ VERIFY β•‘
445
+ β•‘ v β•‘
446
+ β•‘ [OK] First byte valid (0x48 = REX.W prefix) β•‘
447
+ β•‘ [OK] Last byte = 0xC3 (RET) β•‘
448
+ β•‘ [OK] No privileged instructions β•‘
449
+ β•‘ [OK] Length within bounds β•‘
450
+ β•‘ β•‘
451
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
452
+ ```
453
+
454
+ ### Supported Backends
455
+
456
+ | Backend | Status | Instruction Set |
457
+ |---------|--------|-----------------|
458
+ | **x86-64** | Production | REX prefix, MOV, ADD, IMUL, XOR, PUSH/POP, CALL, RET |
459
+ | **ARM64** | Production | Fixed-width 32-bit, MOV/MOVK, ADD, SUB, MUL, BR, RET |
460
+
461
+ ---
462
+
463
+ ## Self-Modification Engine
464
+
465
+ ```
466
+ ╔══════════════════════════════════════════════════════════════╗
467
+ β•‘ GENETIC EVOLUTION LOOP β•‘
468
+ ╠══════════════════════════════════════════════════════════════╣
469
+ β•‘ β•‘
470
+ β•‘ 1. POPULATION β•‘
471
+ β•‘ Generate N candidate expert functions β•‘
472
+ β•‘ β•‘
473
+ β•‘ 2. EVALUATE β•‘
474
+ β•‘ Run each candidate against real container workloads β•‘
475
+ β•‘ Fitness = success_rate * latency_inverse * memory_eff β•‘
476
+ β•‘ β•‘
477
+ β•‘ 3. SELECT β•‘
478
+ β•‘ Tournament selection (pool=4) OR roulette wheel β•‘
479
+ β•‘ β•‘
480
+ β•‘ 4. CROSSOVER β•‘
481
+ β•‘ Swap s-expression subtrees between parents β•‘
482
+ β•‘ Code IS data β€” crossover is tree surgery β•‘
483
+ β•‘ β•‘
484
+ β•‘ 5. MUTATE β•‘
485
+ β•‘ Random subtree replacement, constant perturbation β•‘
486
+ β•‘ β•‘
487
+ β•‘ 6. HOT-SWAP β•‘
488
+ β•‘ Winner replaces live expert function β€” zero downtime β•‘
489
+ β•‘ Automatic rollback if fitness drops below threshold β•‘
490
+ β•‘ β•‘
491
+ β•‘ 7. SEAL β•‘
492
+ β•‘ State captured, rollback point created, WORM sealed β•‘
493
+ β•‘ β•‘
494
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
495
+ ```
496
+
497
+ ---
498
+
499
+ ## Regex Mathematics β€” Formal Algebra at the Wire
500
+
501
+ ```
502
+ ╔══════════════════════════════════════════════════════════════╗
503
+ β•‘ KLEENE ALGEBRA PRIMITIVES β•‘
504
+ ╠══════════════════════════════════════════════════════════════╣
505
+ β•‘ β•‘
506
+ β•‘ LITERAL(c) Match single character c β•‘
507
+ β•‘ CONCAT(r1, r2) Sequence: r1 then r2 β•‘
508
+ β•‘ UNION(r1, r2) Choice: r1 or r2 β•‘
509
+ β•‘ KLEENE(r) Zero or more: r* β•‘
510
+ β•‘ PLUS(r) One or more: r+ β•‘
511
+ β•‘ OPTIONAL(r) Zero or one: r? β•‘
512
+ β•‘ β•‘
513
+ ╠══════════════════════════════════════════════════════════════╣
514
+ β•‘ β•‘
515
+ β•‘ DFA COMPILATION: β•‘
516
+ β•‘ β•‘
517
+ β•‘ regex-algebra.lisp ──> pattern-compiler.lisp β•‘
518
+ β•‘ (algebraic form) (DFA states + transitions) β•‘
519
+ β•‘ β•‘
520
+ β•‘ dfa-step(state, char) => next-state β•‘
521
+ β•‘ dfa-run(dfa, string) => accept | reject β•‘
522
+ β•‘ β•‘
523
+ β•‘ SOCKET FILTERING: β•‘
524
+ β•‘ β•‘
525
+ β•‘ Every Docker event passes through DFA filter β•‘
526
+ β•‘ Pattern: container.(start|stop|die|kill) β•‘
527
+ β•‘ Only matching events reach the MoE router β•‘
528
+ β•‘ β•‘
529
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
530
+ ```
531
+
532
+ ---
533
+
534
+ ## Project Layout
535
+
536
+ ```
537
+ nekod/
538
+ β”œβ”€β”€ nekod.asd ASDF system definition
539
+ β”œβ”€β”€ setup.sh One-command Docker + SBCL installer
540
+ β”œβ”€β”€ README.md This file
541
+ β”œβ”€β”€ LICENSE AGPL-3.0 + cloud provider poison pill
542
+ β”œβ”€β”€ assets/
543
+ β”‚ └── nekomata-avatar.png Production model avatar
544
+ β”‚
545
+ β”œβ”€β”€ core/ ─── LAYER 1: LISP CORE ───
546
+ β”‚ β”œβ”€β”€ package.lisp Package definitions (nekod + nekod.docker)
547
+ β”‚ β”œβ”€β”€ conditions.lisp Error hierarchy + restart system
548
+ β”‚ β”œβ”€β”€ sexpr-infra.lisp Container DSL (define-container, with-failover)
549
+ β”‚ β”œβ”€β”€ eval-loop.lisp Nekomata REPL (nekod-eval, nekod-repl)
550
+ β”‚ β”œβ”€β”€ image-persist.lisp World state save/restore
551
+ β”‚ └── nekomata.lisp Entry point + container registry
552
+ β”‚
553
+ β”œβ”€β”€ docker/ ─── DOCKER SUBSTRATE ───
554
+ β”‚ β”œβ”€β”€ unix-sock.lisp Real Unix socket I/O (SBCL/CCL/IOlib)
555
+ β”‚ β”œβ”€β”€ protocol.lisp Incremental HTTP/1.1 parser (chunked + CL)
556
+ β”‚ β”œβ”€β”€ events.lisp Streaming /events consumer (infinite chunked)
557
+ β”‚ β”œβ”€β”€ container.lisp Container lifecycle (create/start/stop/kill)
558
+ β”‚ β”œβ”€β”€ image.lisp Image management (pull/list/tag/prune)
559
+ β”‚ β”œβ”€β”€ network.lisp Network create/connect/disconnect
560
+ β”‚ β”œβ”€β”€ volume.lisp Volume create/mount/prune
561
+ β”‚ └── inspect.lisp Container + stats inspection
562
+ β”‚
563
+ β”œβ”€β”€ moe/ ─── LAYER 3: SPARSE MoE ───
564
+ β”‚ β”œβ”€β”€ router.lisp Gating network (score, top-k, softmax)
565
+ β”‚ β”œβ”€β”€ sparse-activate.lisp Noisy Top-K + load-balance loss
566
+ β”‚ β”œβ”€β”€ expert-train.lisp Online weight updates from telemetry
567
+ β”‚ β”œβ”€β”€ load-balance.lisp Expert utilization balancing
568
+ β”‚ β”œβ”€β”€ load-trained-weights.lisp R-trained weight loader (JSON import)
569
+ β”‚ └── experts/
570
+ β”‚ β”œβ”€β”€ scheduling.lisp Cron, deploy, queue management
571
+ β”‚ β”œβ”€β”€ networking.lisp Socket, HTTP, port routing
572
+ β”‚ β”œβ”€β”€ storage.lisp Disk, WORM, volume persistence
573
+ β”‚ β”œβ”€β”€ recovery.lisp Failover, rollback, restart
574
+ β”‚ β”œβ”€β”€ security.lisp Auth, encryption, sealing
575
+ β”‚ └── scaling.lisp Replicas, shards, capacity
576
+ β”‚
577
+ β”œβ”€β”€ regex-math/ ─── LAYER 2: KLEENE ALGEBRA ───
578
+ β”‚ β”œβ”€β”€ regex-algebra.lisp RE structs (literal/concat/union/kleene)
579
+ β”‚ β”œβ”€β”€ pattern-compiler.lisp Thompson NFA β†’ subset DFA compilation
580
+ β”‚ β”œβ”€β”€ socket-filter.lisp Compiled DFA event classifier + features
581
+ β”‚ └── intent-parse.lisp NL intent β†’ expert keyword mapping
582
+ β”‚
583
+ β”œβ”€β”€ socket/ ─── SOCKET INGRESS PIPELINE ───
584
+ β”‚ β”œβ”€β”€ backpressure.lisp Watermarks, queue depth, size limits
585
+ β”‚ β”œβ”€β”€ policy.lisp Capability-based security boundary
586
+ β”‚ β”œβ”€β”€ receipt.lisp Deterministic operation receipts
587
+ β”‚ └── agent-ingress.lisp Event β†’ classify β†’ route β†’ dispatch
588
+ β”‚
589
+ β”œβ”€β”€ llm2asm/ ─── LAYER 4: LLM β†’ MACHINE CODE ───
590
+ β”‚ β”œβ”€β”€ tokenizer.lisp Intent tokenization + kernel map
591
+ β”‚ β”œβ”€β”€ ast-extract.lisp infra-ast struct, intent type detection
592
+ β”‚ β”œβ”€β”€ codegen.lisp AST β†’ byte vector compilation
593
+ β”‚ β”œβ”€β”€ verify.lisp Byte-level safety verification
594
+ β”‚ β”œβ”€β”€ jit-link.lisp JIT stub (mmap + mprotect reference)
595
+ β”‚ β”œβ”€β”€ constraint-build.lisp Constraint algebra (cpu/mem/latency)
596
+ β”‚ └── backends/
597
+ β”‚ β”œβ”€β”€ x86-64.lisp x86-64 instruction encoders
598
+ β”‚ └── arm64.lisp ARM64 fixed-width instruction encoders
599
+ β”‚
600
+ β”œβ”€β”€ selfmod/ ─── LAYER 5: SELF-MODIFICATION ───
601
+ β”‚ β”œβ”€β”€ gen-loop.lisp Genetic evolution loop
602
+ β”‚ β”œβ”€β”€ hot-swap.lisp Live function redefinition + rollback
603
+ β”‚ β”œβ”€β”€ state-capture.lisp State snapshots
604
+ β”‚ β”œβ”€β”€ evolve.lisp Crossover + selection algorithms
605
+ β”‚ └── rollback.lisp Rollback points, with-rollback macro
606
+ β”‚
607
+ β”œβ”€β”€ cli/ ─── USER INTERFACE ───
608
+ β”‚ └── neko.lisp 8 CLI commands (run/stop/kill/list/...)
609
+ β”‚
610
+ β”œβ”€β”€ tests/
611
+ β”‚ β”œβ”€β”€ test-core.lisp Core test suite
612
+ β”‚ β”œβ”€β”€ test-edge-cases.lisp Edge case coverage
613
+ β”‚ └── socket-tests.lisp Socket layer: 28 unit + 4 integration tests
614
+ β”‚
615
+ └── docs/ ─── DOCUMENTATION ───
616
+ β”œβ”€β”€ manifesto.org Why Nekomata exists
617
+ β”œβ”€β”€ architecture.org 5-layer system design
618
+ β”œβ”€β”€ moe-theory.org Sparse MoE mathematics
619
+ β”œβ”€β”€ regex-calculus.org Kleene algebra formalism
620
+ └── migration.org Kubernetes escape route
621
+ ```
622
+
623
+ ---
624
+
625
+ ## Why Common Lisp?
626
+
627
+ ```
628
+ ╔══════════════════════════════════════════════════════════════╗
629
+ β•‘ β•‘
630
+ β•‘ CODE = DATA β•‘
631
+ β•‘ An s-expression describing a container IS that container. β•‘
632
+ β•‘ No YAML. No templating. No string interpolation. β•‘
633
+ β•‘ The description evaluates to the thing itself. β•‘
634
+ β•‘ β•‘
635
+ β•‘ CONDITION SYSTEM β•‘
636
+ β•‘ Not try/catch. Restarts. When a container dies, the β•‘
637
+ β•‘ condition system offers: restart, promote-replica, β•‘
638
+ β•‘ rollback, or escalate. Decided at runtime, not design-time. β•‘
639
+ β•‘ β•‘
640
+ β•‘ IMAGE-BASED PERSISTENCE β•‘
641
+ β•‘ Save the entire world to disk. Restore it later. β•‘
642
+ β•‘ The running state IS the deployment artifact. β•‘
643
+ β•‘ No container image layers. No registries. Just the world. β•‘
644
+ β•‘ β•‘
645
+ β•‘ MACROS β•‘
646
+ β•‘ define-container is a macro. with-failover is a macro. β•‘
647
+ β•‘ The language extends itself to become the domain. β•‘
648
+ β•‘ Infrastructure IS language. Language IS infrastructure. β•‘
649
+ β•‘ β•‘
650
+ β•‘ HOT RELOAD β•‘
651
+ β•‘ Redefine any function while the system runs. β•‘
652
+ β•‘ No restart. No redeployment. The new code IS the system. β•‘
653
+ β•‘ Genetic evolution swaps expert functions live. β•‘
654
+ β•‘ β•‘
655
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
656
+ ```
657
+
658
+ ---
659
+
660
+ ## Migration from Kubernetes
661
+
662
+ ```
663
+ ╔══════════════════════════════════════════════════════════════╗
664
+ β•‘ K8S β†’ NEKOMATA MIGRATION PATH β•‘
665
+ ╠══════════════════════════════════════════════════════════════╣
666
+ β•‘ β•‘
667
+ β•‘ Step 1: Install nekod alongside existing cluster β•‘
668
+ β•‘ (nekod speaks Docker socket directly β€” no conflict) β•‘
669
+ β•‘ β•‘
670
+ β•‘ Step 2: Convert Deployment YAMLs β†’ define-container forms β•‘
671
+ β•‘ One YAML = one s-expression. Mechanical. β•‘
672
+ β•‘ β•‘
673
+ β•‘ Step 3: Wire failover chains β•‘
674
+ β•‘ (with-failover primary replica standby) β•‘
675
+ β•‘ β•‘
676
+ β•‘ Step 4: Enable MoE routing β•‘
677
+ β•‘ Expert weights train on YOUR workload patterns β•‘
678
+ β•‘ β•‘
679
+ β•‘ Step 5: Enable self-modification β•‘
680
+ β•‘ The system evolves its own expert functions β•‘
681
+ β•‘ β•‘
682
+ β•‘ Step 6: Decommission K8s control plane β•‘
683
+ β•‘ etcd, kube-apiserver, kube-scheduler β€” gone. β•‘
684
+ β•‘ Nekomata IS the control plane now. β•‘
685
+ β•‘ β•‘
686
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
687
+ ```
688
+
689
+ ---
690
+
691
+ ## Performance Characteristics
692
+
693
+ ```
694
+ ╔══════════════════════════════════════════════════════════════╗
695
+ β•‘ METRIC VALUE β•‘
696
+ ╠══════════════════════════════════════════════════════════════╣
697
+ β•‘ Memory per expert ~2.3 KB (sparse activation) β•‘
698
+ β•‘ Router decision latency <1ms (dot product + softmax) β•‘
699
+ β•‘ Active experts per call 2 (Top-K=2, out of 6) β•‘
700
+ β•‘ Agents at 2.3KB each 500+ sustainable β•‘
701
+ β•‘ Code generation x86-64 + ARM64 native β•‘
702
+ β•‘ Hot-swap latency ~0ms (defun redefinition) β•‘
703
+ β•‘ World snapshot Full state in single file β•‘
704
+ β•‘ Container start Direct Docker API (no etcd) β•‘
705
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
706
+ ```
707
+
708
+ ---
709
+
710
+ ## License
711
+
712
+ **AGPL-3.0** with cloud provider poison pill.
713
+
714
+ The engine is free. Sovereignty is not optional.
715
+
716
+ Any cloud provider deploying Nekomata as a hosted service MUST:
717
+ 1. Release all modifications under AGPL-3.0
718
+ 2. Provide users a prominent link to modified source
719
+ 3. Not remove attribution to SnapKitty Collective
720
+
721
+ ---
722
+
723
+ ### πŸ’Ό Commercial License
724
+
725
+ Snapkitty code is free and open under **AGPL-3.0** for open-source use. Building a commercial product or service? A **proprietary commercial license** from Snapkitty Collective LLC lets you ship this code without the AGPL's source-sharing and network-use obligations.
726
+
727
+ **[β†’ Get a commercial license](mailto:A.parr@belespritdaccord.uk?subject=Commercial%20license:%20nekomata)** Β· A.parr@belespritdaccord.uk
728
+
729
+ ## Credits
730
+
731
+ ```
732
+ ╔══════════════════════════════════════════════════════════════╗
733
+ β•‘ β•‘
734
+ β•‘ Architecture Ahmad Ali Parr β•‘
735
+ β•‘ Engineering SnapKitty Collective β•‘
736
+ β•‘ Model Avatar Nekomata β€” the two-tailed sovereign cat β•‘
737
+ β•‘ Execution WORM-sealed, receipt-generating β•‘
738
+ β•‘ β•‘
739
+ β•‘ "Infrastructure that rewrites itself." β•‘
740
+ β•‘ β•‘
741
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
742
+ ```
743
+
744
+ ---
745
+
746
+ <p align="center">
747
+ <img src="assets/nekomata-avatar.png" alt="Nekomata" width="160"/>
748
+ <br/>
749
+ <b>猫又 β€” The two-tailed cat that never dies.</b>
750
+ </p>