snapkitty-open-source / docs /ARCHITECTURE.md
SNAPKITTYWEST's picture
Add docs/ARCHITECTURE.md
22d670b verified
|
Raw
History Blame Contribute Delete
11.4 kB

SnapKitty Architecture

Status: Research project β€” inventory-driven design, September 2026.


What Problem Are We Solving?

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.

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?

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?


What The Conventional Approach Does

Input
  ↓
Q/K/V projections (matrix multiply Γ— 3)
  ↓
QKα΅€ (matrix multiply, O(nΒ²))
  ↓
Scale by 1/√d
  ↓
Softmax (exponentials, normalization)
  ↓
Attention weights Γ— V (matrix multiply)
  ↓
Output

Characteristics: floating-point throughout, non-deterministic at scale, exponential operations, no formal specification of what the routing decision means.


What SnapKitty Does Differently

Layer 1: Governance DAG (IMPLEMENTED)

Every claim, proof, decision, and execution is a node in a formally specified directed acyclic graph.

EVIDENCE ──────────────────┐
                            ↓
            [CONSTRAINT checks]
                            ↓
CLAIM ──────→ PROOF ──────→ DECISION(authorized) ──→ EXECUTION ──→ AUDIT
                                    ↑
                            POLICY enforces
                            CONSTRAINT

Implemented in two layers:

  • ICP-DAG.m (MUMPS): imperative runtime, stores nodes/edges in global arrays, enforces 10 integrity invariants
  • ICP-DAG.lp (ASP): declarative constraint specification, 7 hard constraints. SAT = governance holds; UNSAT = HALT.

Nothing executes without passing this graph. This is not a convention β€” it is enforced by the ASP solver and the MUMPS gate check.

Layer 2: SUBLEQ Attention (EXPERIMENTAL)

Hypothesis: Softmax attention's probability distribution over relationships can be replaced with integer-comparison-based deterministic routing using the SUBLEQ one-instruction machine.

Activation vector (floats)
  ↓
Quantize: floor(256 Γ— |x|) β†’ integers in [0, 255]
  ↓
Reshape into [A, B, C] SUBLEQ triads
  ↓
Load into 256-cell integer memory
  ↓
SUBLEQ: mem[B] -= mem[A]; if mem[B] ≀ 0: jump to C
         (run max 500 steps)
  ↓
Collect output addresses
  ↓
Born collapse: floor(256 mod Ξ£ Ο†^(-i) Β· output_i) β†’ scalar address
  ↓
Selected context / routing result

What this eliminates: matrix multiplication in the routing phase, softmax exponentials. What this does NOT eliminate: float operations at the quantization step. What is not yet measured: whether this produces equivalent attention-like routing quality on any benchmark.

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

Layer 3: Entropy Governance (PROVED)

Every inference step is gated by a formally proved entropy bound.

Theorem (proved in Lean 4, zero sorry):

F β‰₯ 1 β†’ T(F) ≀ 0.2218 β†’ s = exp(d/T(F)) β‰₯ 90.75 β†’ H < 0.20 nats

Implementation: snapkitty_entropy.EntropyGovernor(LogitsProcessor) β€” drop-in for any HuggingFace model.

Layer 4: Formal Algebraic Foundation (PARTIAL)

Jordan Fixed-Point Commutativity (proved): For the Jordan operator T(ρ) = φ⁻¹·U·ρ·U† + φ⁻²·ρ, any fixed point ρ* satisfies [U, ρ*] = 0.

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.

Jacobian Conjecture formalization: sov-kernel-monster/jacobian-formal/JACOBIAN_BRIDGES_COMPLETE.lean β€” 10 peer-review gap closures, self-declared zero-sorry.

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 (φ⁻²).


The Canonical SnapKitty DAG

Derived from code (not imposed):

Node
β”œβ”€β”€ id: string (unique identifier)
β”œβ”€β”€ type: EVIDENCE | CLAIM | CONSTRAINT | PROOF | POLICY | DECISION | EXECUTION | AUDIT
β”œβ”€β”€ state: UNKNOWN | OBSERVED | VERIFIED | PROVEN | AUTHORIZED | ACTIVE | PENDING | SEALED
└── payload: type-specific data

Edge
β”œβ”€β”€ source: node id
β”œβ”€β”€ destination: node id
└── relation: decides | executes | proves | enforces | proven-by | derived-from | supports

Integrity invariants (enforced by both ASP and MUMPS):

  1. Every edge requires both endpoint nodes to exist
  2. No self-edges
  3. Unknown claims cannot reach decisions
  4. Contradicted claims cannot reach decisions
  5. Authorization requires proof
  6. Execution requires authorized decision
  7. Unknown and verified are mutually exclusive

Is The DAG The Right Common Intermediate Representation?

For governance: YES. The ICP-DAG is the clearest, most implemented piece of the architecture. It already works.

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:

  • DAG for the dependency structure (which activations produced which routing decision)
  • Directed graph (potentially cyclic) for the SUBLEQ execution trace itself

For quantum structures: NO β€” not all of them.

  • Quantum circuit composition: DAG (always)
  • Braid group operations: NOT a DAG β€” braids are reversible and can undo themselves
  • Vortex lattice (quantum-wasm): undirected grid graph
  • Quantum walk graph: undirected adjacency graph

Correct distinction:

Use DAG for:           dependency ordering, governance, provenance, execution ordering
Use directed graph for: SUBLEQ execution trace, state machines with loops
Use undirected graph for: coupling maps, vortex lattices, quantum walk substrates
Use braid for:          topological quantum evolution (Οƒα΅’, σᡒ⁻¹ operations)

Forcing braids or quantum walks into the DAG abstraction would be technically incorrect.


Repository Structure (Proposed)

Based on what actually exists:

snapkitty/
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ icp_dag.m             # ICP governance DAG (MUMPS) β€” CORE, WORKING
β”‚   β”œβ”€β”€ icp_dag.lp            # ICP ASP constraints β€” CORE, WORKING
β”‚   └── icp_gov.m             # Governance extension β€” CORE, WORKING
β”œβ”€β”€ subleq/
β”‚   β”œβ”€β”€ vm.rs                 # SUBLEQ VM (Rust/WASM) β€” PRODUCTION
β”‚   β”œβ”€β”€ attention.ijs         # SUBLEQ attention (J) β€” EXPERIMENTAL
β”‚   └── python_port.py        # Python port for visualization
β”œβ”€β”€ resonance/
β”‚   β”œβ”€β”€ vm/                   # Resonance ISA VM (Rust, 8 opcodes) β€” WORKING
β”‚   β”œβ”€β”€ assembler/            # .rasm β†’ bytecode β€” WORKING
β”‚   β”œβ”€β”€ word.ijs              # Resonance Word GF(p) format (J) β€” WORKING (bug fixed)
β”‚   └── abjad/                # Abjad tokenizer β€” WORKING
β”œβ”€β”€ algebra/
β”‚   β”œβ”€β”€ JordanMatrixProof.lean    # PROVED (0 sorry)
β”‚   β”œβ”€β”€ EntropyBound.lean         # PROVED (0 sorry)
β”‚   β”œβ”€β”€ jordan_block.f90          # Fortran grey-hat layer
β”‚   └── jacobian_bridges.lean     # Jacobian Conjecture formalization
β”œβ”€β”€ quantum/
β”‚   β”œβ”€β”€ formal/
β”‚   β”‚   β”œβ”€β”€ FibonacciAnyon.lean   # Fusion category (partial proof)
β”‚   β”‚   β”œβ”€β”€ BraidCompilation.lean # Braid β†’ gate synthesis (skeleton, sorry)
β”‚   β”‚   └── LogicalQubits.lean    # Anyon encoding structures
β”‚   β”œβ”€β”€ simulation/
β”‚   β”‚   β”œβ”€β”€ quantum_wasm.rs       # WASM simulation (vortex lattice) β€” WORKING
β”‚   β”‚   └── topological.rs        # Fibonacci anyon sim β€” WORKING
β”‚   └── entropy/
β”‚       └── quantum.mjs           # ANU QRNG integration β€” WORKING
β”œβ”€β”€ swarm/
β”‚   β”œβ”€β”€ quantum-swarm.mjs         # PRIMARY swarm engine β€” WORKING
β”‚   β”œβ”€β”€ swarm_coordinator.mjs     # 5-agent named roles β€” WORKING
β”‚   └── sovereign_crew/           # Python CrewAI with entropy gate β€” WORKING
β”œβ”€β”€ visualization/
β”‚   β”œβ”€β”€ app.py                    # Gradio algorithmic art Space
β”‚   β”œβ”€β”€ subleq_engine.py          # Python SUBLEQ port
β”‚   └── resonance_word.py         # Python Resonance Word port
β”œβ”€β”€ formal/
β”‚   β”œβ”€β”€ lean/                     # All Lean 4 proofs
β”‚   β”œβ”€β”€ agda/                     # Agda invariants
β”‚   └── prolog/                   # ERE.pl, GJW traversability
β”œβ”€β”€ benchmarks/                   # EMPTY β€” needs building
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ subleq_vm/                # 4 Rust tests (working)
β”‚   β”œβ”€β”€ resonance_isa/            # 3 Rust tests (working)
β”‚   └── braid/                    # 4 Rust tests (working)
└── docs/
    β”œβ”€β”€ REPOSITORY_INVENTORY.md
    β”œβ”€β”€ ARCHITECTURE.md
    β”œβ”€β”€ DAG.md
    β”œβ”€β”€ QUANTUM_SWARM.md
    └── RESEARCHER_EXPLANATION.md

Algorithm Implementation Status

Algorithm File Working Tested Benchmarked
SUBLEQ VM subleq_vm.rs βœ“ βœ“ βœ—
SUBLEQ Attention subleq_attention.ijs βœ“ βœ— βœ—
Resonance ISA VM vm/src/lib.rs βœ“ βœ“ βœ—
ICP Governance DAG ICP-DAG.m βœ“ βœ“ βœ—
Entropy Governor governor.py βœ“ βœ— βœ—
Jordan proof JordanMatrixProof.lean βœ“ (proved) βœ“ N/A
Entropy bound EntropyBound.lean βœ“ (proved) βœ“ N/A
Fibonacci anyon sim topological.rs βœ“ βœ“ βœ—
Quantum WASM quantum_wasm.rs βœ“ (binary) βœ— βœ—
ANU QRNG quantum.mjs βœ“ βœ— βœ—
Braid gate synthesis BraidCompilation.lean βœ— (sorry) βœ— N/A
Grover search GroverSearch.lean partial βœ— N/A

What Is The Main Open-Source Product?

Product name: snapkitty-dag β€” The SnapKitty Integrity DAG

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.

Why this over the other candidates:

  • SUBLEQ attention is experimental and unbenched β€” cannot be a product yet
  • The Jordan proof is a building block, not a standalone product
  • The ICP-DAG is complete, working, tested, and directly usable by anyone building an auditable AI pipeline
  • It is the only component that enforces constraints on ALL the other components

The SUBLEQ attention and quantum swarm work are the research tracks that feed into a future version of this product.