# ⬡ Nexus Gate

**Mathematical verification layer for AI agent actions.**

The LLM decides *what* to do. Nexus proves *why* it's safe. Not statistics. Derivation paths.

## Install

```bash
pip install nexus-gate
```

## Quick Start

```python
from nexus_gate_pkg import NexusFullGate

gate = NexusFullGate()
gate.build_knowledge()  # ~17 seconds, once

decision = gate.check("merge inbox with archive")
print(decision.verdict)      # VERIFIED
print(decision.confidence)   # 100

decision = gate.check("launch nuclear missiles")
print(decision.verdict)      # NO_MATCH — no proof exists
```

## 16 Operations · 19 Properties · 100% Proven

| Category | Operation | Proof | Steps |
|----------|-----------|-------|-------|
| CRUD | read | read(A) = A | 4 |
| CRUD | create | count + 1 | 6 |
| CRUD | update | count preserved | 5 |
| CRUD | delete | count → 0 | 4 |
| Data | send | count − 1 | 1 |
| Data | merge | count(A) + count(B) | 6 |
| Data | copy | copy(A) = A | 4 |
| Data | move | total preserved | 6 |
| Transform | transform | count preserved | 5 |
| Transform | filter | count ≤ input | 5 |
| Transform | sort | count preserved | 5 |
| Transform | aggregate | processes all | 6 |
| Auth | grant | access + 1 | 6 |
| Auth | revoke | access → 0 | 4 |
| Workflow | schedule | queue + 1 | 6 |
| Workflow | execute | queue − 1 | 1 |

## Use with Ollama

```bash
pip install nexus-gate[ollama]
ollama serve
python -m nexus_gate_pkg.nexus_ollama --model llama3.2
```

## Use with LangChain / CrewAI / MCP

```python
from nexus_gate_pkg import NexusFullGate

gate = NexusFullGate()
gate.build_knowledge()

# In your agent's tool handler:
decision = gate.check("delete expired sessions")
if decision.verdict == "VERIFIED":
    execute()
else:
    ask_human()
```

## License

MIT
