SNAPKITTYWEST commited on
Commit
22d670b
Β·
verified Β·
1 Parent(s): 1a4a0d8

Add docs/ARCHITECTURE.md

Browse files
Files changed (1) hide show
  1. docs/ARCHITECTURE.md +261 -0
docs/ARCHITECTURE.md ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SnapKitty Architecture
2
+
3
+ **Status:** Research project β€” inventory-driven design, September 2026.
4
+
5
+ ---
6
+
7
+ ## What Problem Are We Solving?
8
+
9
+ Existing AI systems produce outputs with no verifiable provenance. A model asserts a fact. There is no chain of custody from assertion back to evidence, proof, or authorization. Outputs are probabilistic, unauditable, and non-deterministic across runs.
10
+
11
+ SnapKitty asks: can an AI system be built where every output traces back through a formal graph of evidence β†’ proof β†’ decision, sealed with a cryptographic receipt?
12
+
13
+ A secondary question (under active investigation): can the conventional softmax attention mechanism be replaced with an integer-arithmetic routing mechanism that produces deterministic routing decisions and admits formal verification?
14
+
15
+ ---
16
+
17
+ ## What The Conventional Approach Does
18
+
19
+ ```
20
+ Input
21
+ ↓
22
+ Q/K/V projections (matrix multiply Γ— 3)
23
+ ↓
24
+ QKα΅€ (matrix multiply, O(nΒ²))
25
+ ↓
26
+ Scale by 1/√d
27
+ ↓
28
+ Softmax (exponentials, normalization)
29
+ ↓
30
+ Attention weights Γ— V (matrix multiply)
31
+ ↓
32
+ Output
33
+ ```
34
+
35
+ Characteristics: floating-point throughout, non-deterministic at scale, exponential operations, no formal specification of what the routing decision means.
36
+
37
+ ---
38
+
39
+ ## What SnapKitty Does Differently
40
+
41
+ ### Layer 1: Governance DAG (IMPLEMENTED)
42
+
43
+ Every claim, proof, decision, and execution is a node in a formally specified directed acyclic graph.
44
+
45
+ ```
46
+ EVIDENCE ──────────────────┐
47
+ ↓
48
+ [CONSTRAINT checks]
49
+ ↓
50
+ CLAIM ──────→ PROOF ──────→ DECISION(authorized) ──→ EXECUTION ──→ AUDIT
51
+ ↑
52
+ POLICY enforces
53
+ CONSTRAINT
54
+ ```
55
+
56
+ **Implemented in two layers:**
57
+ - `ICP-DAG.m` (MUMPS): imperative runtime, stores nodes/edges in global arrays, enforces 10 integrity invariants
58
+ - `ICP-DAG.lp` (ASP): declarative constraint specification, 7 hard constraints. SAT = governance holds; UNSAT = HALT.
59
+
60
+ Nothing executes without passing this graph. This is not a convention β€” it is enforced by the ASP solver and the MUMPS gate check.
61
+
62
+ ### Layer 2: SUBLEQ Attention (EXPERIMENTAL)
63
+
64
+ **Hypothesis:** Softmax attention's probability distribution over relationships can be replaced with integer-comparison-based deterministic routing using the SUBLEQ one-instruction machine.
65
+
66
+ ```
67
+ Activation vector (floats)
68
+ ↓
69
+ Quantize: floor(256 Γ— |x|) β†’ integers in [0, 255]
70
+ ↓
71
+ Reshape into [A, B, C] SUBLEQ triads
72
+ ↓
73
+ Load into 256-cell integer memory
74
+ ↓
75
+ SUBLEQ: mem[B] -= mem[A]; if mem[B] ≀ 0: jump to C
76
+ (run max 500 steps)
77
+ ↓
78
+ Collect output addresses
79
+ ↓
80
+ Born collapse: floor(256 mod Ξ£ Ο†^(-i) Β· output_i) β†’ scalar address
81
+ ↓
82
+ Selected context / routing result
83
+ ```
84
+
85
+ **What this eliminates:** matrix multiplication in the routing phase, softmax exponentials.
86
+ **What this does NOT eliminate:** float operations at the quantization step.
87
+ **What is not yet measured:** whether this produces equivalent attention-like routing quality on any benchmark.
88
+
89
+ **Evidence:** `j-matrix-twin/subleq_attention.ijs` (J language, runnable). Rust/WASM VM: `DEVFLOW-FINANCE/snapkitty-wasm/src/subleq_vm.rs` (production-ready, 4 tests).
90
+
91
+ ### Layer 3: Entropy Governance (PROVED)
92
+
93
+ Every inference step is gated by a formally proved entropy bound.
94
+
95
+ **Theorem (proved in Lean 4, zero sorry):**
96
+ ```
97
+ F β‰₯ 1 β†’ T(F) ≀ 0.2218 β†’ s = exp(d/T(F)) β‰₯ 90.75 β†’ H < 0.20 nats
98
+ ```
99
+
100
+ **Implementation:** `snapkitty_entropy.EntropyGovernor(LogitsProcessor)` β€” drop-in for any HuggingFace model.
101
+
102
+ ### Layer 4: Formal Algebraic Foundation (PARTIAL)
103
+
104
+ **Jordan Fixed-Point Commutativity (proved):**
105
+ For the Jordan operator T(ρ) = φ⁻¹·U·ρ·U† + φ⁻²·ρ, any fixed point ρ* satisfies [U, ρ*] = 0.
106
+
107
+ This means: if an agent's state converges under Jordan iteration, the converged state commutes with the unitary evolution operator. The agent cannot be driven out of its converged state by the same unitary that drove it there.
108
+
109
+ **Jacobian Conjecture formalization:** `sov-kernel-monster/jacobian-formal/JACOBIAN_BRIDGES_COMPLETE.lean` β€” 10 peer-review gap closures, self-declared zero-sorry.
110
+
111
+ **Grey-hat quantum defense:** `sov-kernel-monster/src/jordan_block.f90` β€” four invariants enforced in Fortran: side-channel resistance (βˆ‚U/βˆ‚t=0), fault injection impossibility (ρ*=ΟˆΟˆβ€ ), coherence ([U,ρ*]=0), entropy bound (φ⁻²).
112
+
113
+ ---
114
+
115
+ ## The Canonical SnapKitty DAG
116
+
117
+ Derived from code (not imposed):
118
+
119
+ ```
120
+ Node
121
+ β”œβ”€β”€ id: string (unique identifier)
122
+ β”œβ”€β”€ type: EVIDENCE | CLAIM | CONSTRAINT | PROOF | POLICY | DECISION | EXECUTION | AUDIT
123
+ β”œβ”€β”€ state: UNKNOWN | OBSERVED | VERIFIED | PROVEN | AUTHORIZED | ACTIVE | PENDING | SEALED
124
+ └── payload: type-specific data
125
+
126
+ Edge
127
+ β”œβ”€β”€ source: node id
128
+ β”œβ”€β”€ destination: node id
129
+ └── relation: decides | executes | proves | enforces | proven-by | derived-from | supports
130
+ ```
131
+
132
+ **Integrity invariants (enforced by both ASP and MUMPS):**
133
+ 1. Every edge requires both endpoint nodes to exist
134
+ 2. No self-edges
135
+ 3. Unknown claims cannot reach decisions
136
+ 4. Contradicted claims cannot reach decisions
137
+ 5. Authorization requires proof
138
+ 6. Execution requires authorized decision
139
+ 7. Unknown and verified are mutually exclusive
140
+
141
+ ---
142
+
143
+ ## Is The DAG The Right Common Intermediate Representation?
144
+
145
+ **For governance:** YES. The ICP-DAG is the clearest, most implemented piece of the architecture. It already works.
146
+
147
+ **For SUBLEQ attention:** PARTIALLY. The SUBLEQ execution graph is NOT a DAG (it can branch backward). The dependency graph of how activation vectors produce routing results IS a DAG. The correct representation is:
148
+ - DAG for the dependency structure (which activations produced which routing decision)
149
+ - Directed graph (potentially cyclic) for the SUBLEQ execution trace itself
150
+
151
+ **For quantum structures:** NO β€” not all of them.
152
+ - Quantum circuit composition: DAG (always)
153
+ - Braid group operations: NOT a DAG β€” braids are reversible and can undo themselves
154
+ - Vortex lattice (quantum-wasm): undirected grid graph
155
+ - Quantum walk graph: undirected adjacency graph
156
+
157
+ **Correct distinction:**
158
+ ```
159
+ Use DAG for: dependency ordering, governance, provenance, execution ordering
160
+ Use directed graph for: SUBLEQ execution trace, state machines with loops
161
+ Use undirected graph for: coupling maps, vortex lattices, quantum walk substrates
162
+ Use braid for: topological quantum evolution (Οƒα΅’, σᡒ⁻¹ operations)
163
+ ```
164
+
165
+ Forcing braids or quantum walks into the DAG abstraction would be technically incorrect.
166
+
167
+ ---
168
+
169
+ ## Repository Structure (Proposed)
170
+
171
+ Based on what actually exists:
172
+
173
+ ```
174
+ snapkitty/
175
+ β”œβ”€β”€ core/
176
+ β”‚ β”œβ”€β”€ icp_dag.m # ICP governance DAG (MUMPS) β€” CORE, WORKING
177
+ β”‚ β”œβ”€β”€ icp_dag.lp # ICP ASP constraints β€” CORE, WORKING
178
+ β”‚ └── icp_gov.m # Governance extension β€” CORE, WORKING
179
+ β”œβ”€β”€ subleq/
180
+ β”‚ β”œβ”€β”€ vm.rs # SUBLEQ VM (Rust/WASM) β€” PRODUCTION
181
+ β”‚ β”œβ”€β”€ attention.ijs # SUBLEQ attention (J) β€” EXPERIMENTAL
182
+ β”‚ └── python_port.py # Python port for visualization
183
+ β”œβ”€β”€ resonance/
184
+ β”‚ β”œβ”€β”€ vm/ # Resonance ISA VM (Rust, 8 opcodes) β€” WORKING
185
+ β”‚ β”œβ”€β”€ assembler/ # .rasm β†’ bytecode β€” WORKING
186
+ β”‚ β”œβ”€β”€ word.ijs # Resonance Word GF(p) format (J) β€” WORKING (bug fixed)
187
+ β”‚ └── abjad/ # Abjad tokenizer β€” WORKING
188
+ β”œβ”€β”€ algebra/
189
+ β”‚ β”œβ”€β”€ JordanMatrixProof.lean # PROVED (0 sorry)
190
+ β”‚ β”œβ”€β”€ EntropyBound.lean # PROVED (0 sorry)
191
+ β”‚ β”œβ”€β”€ jordan_block.f90 # Fortran grey-hat layer
192
+ β”‚ └── jacobian_bridges.lean # Jacobian Conjecture formalization
193
+ β”œβ”€β”€ quantum/
194
+ β”‚ β”œβ”€β”€ formal/
195
+ β”‚ β”‚ β”œβ”€β”€ FibonacciAnyon.lean # Fusion category (partial proof)
196
+ β”‚ β”‚ β”œβ”€β”€ BraidCompilation.lean # Braid β†’ gate synthesis (skeleton, sorry)
197
+ β”‚ β”‚ └── LogicalQubits.lean # Anyon encoding structures
198
+ β”‚ β”œβ”€β”€ simulation/
199
+ β”‚ β”‚ β”œβ”€β”€ quantum_wasm.rs # WASM simulation (vortex lattice) β€” WORKING
200
+ β”‚ β”‚ └── topological.rs # Fibonacci anyon sim β€” WORKING
201
+ β”‚ └── entropy/
202
+ β”‚ └── quantum.mjs # ANU QRNG integration β€” WORKING
203
+ β”œβ”€β”€ swarm/
204
+ β”‚ β”œβ”€β”€ quantum-swarm.mjs # PRIMARY swarm engine β€” WORKING
205
+ β”‚ β”œβ”€β”€ swarm_coordinator.mjs # 5-agent named roles β€” WORKING
206
+ β”‚ └── sovereign_crew/ # Python CrewAI with entropy gate β€” WORKING
207
+ β”œβ”€β”€ visualization/
208
+ β”‚ β”œβ”€β”€ app.py # Gradio algorithmic art Space
209
+ β”‚ β”œβ”€β”€ subleq_engine.py # Python SUBLEQ port
210
+ β”‚ └── resonance_word.py # Python Resonance Word port
211
+ β”œβ”€β”€ formal/
212
+ β”‚ β”œβ”€β”€ lean/ # All Lean 4 proofs
213
+ β”‚ β”œβ”€β”€ agda/ # Agda invariants
214
+ β”‚ └── prolog/ # ERE.pl, GJW traversability
215
+ β”œβ”€β”€ benchmarks/ # EMPTY β€” needs building
216
+ β”œβ”€β”€ tests/
217
+ β”‚ β”œβ”€β”€ subleq_vm/ # 4 Rust tests (working)
218
+ β”‚ β”œβ”€β”€ resonance_isa/ # 3 Rust tests (working)
219
+ β”‚ └── braid/ # 4 Rust tests (working)
220
+ └── docs/
221
+ β”œβ”€β”€ REPOSITORY_INVENTORY.md
222
+ β”œβ”€β”€ ARCHITECTURE.md
223
+ β”œβ”€β”€ DAG.md
224
+ β”œβ”€β”€ QUANTUM_SWARM.md
225
+ └── RESEARCHER_EXPLANATION.md
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Algorithm Implementation Status
231
+
232
+ | Algorithm | File | Working | Tested | Benchmarked |
233
+ |-----------|------|:-------:|:------:|:-----------:|
234
+ | SUBLEQ VM | `subleq_vm.rs` | βœ“ | βœ“ | βœ— |
235
+ | SUBLEQ Attention | `subleq_attention.ijs` | βœ“ | βœ— | βœ— |
236
+ | Resonance ISA VM | `vm/src/lib.rs` | βœ“ | βœ“ | βœ— |
237
+ | ICP Governance DAG | `ICP-DAG.m` | βœ“ | βœ“ | βœ— |
238
+ | Entropy Governor | `governor.py` | βœ“ | βœ— | βœ— |
239
+ | Jordan proof | `JordanMatrixProof.lean` | βœ“ (proved) | βœ“ | N/A |
240
+ | Entropy bound | `EntropyBound.lean` | βœ“ (proved) | βœ“ | N/A |
241
+ | Fibonacci anyon sim | `topological.rs` | βœ“ | βœ“ | βœ— |
242
+ | Quantum WASM | `quantum_wasm.rs` | βœ“ (binary) | βœ— | βœ— |
243
+ | ANU QRNG | `quantum.mjs` | βœ“ | βœ— | βœ— |
244
+ | Braid gate synthesis | `BraidCompilation.lean` | βœ— (sorry) | βœ— | N/A |
245
+ | Grover search | `GroverSearch.lean` | partial | βœ— | N/A |
246
+
247
+ ---
248
+
249
+ ## What Is The Main Open-Source Product?
250
+
251
+ **Product name:** `snapkitty-dag` β€” The SnapKitty Integrity DAG
252
+
253
+ **One-sentence definition:** A formally specified directed acyclic graph that gates every claim, proof, decision, and execution in an AI pipeline, enforced simultaneously by Answer Set Programming constraints and an imperative MUMPS runtime, with cryptographic WORM sealing at every node.
254
+
255
+ **Why this over the other candidates:**
256
+ - SUBLEQ attention is experimental and unbenched β€” cannot be a product yet
257
+ - The Jordan proof is a building block, not a standalone product
258
+ - The ICP-DAG is complete, working, tested, and directly usable by anyone building an auditable AI pipeline
259
+ - It is the only component that enforces constraints on ALL the other components
260
+
261
+ The SUBLEQ attention and quantum swarm work are the **research tracks** that feed into a future version of this product.