Spaces:
Configuration error
Configuration error
File size: 12,816 Bytes
b8bef19 77bcbf1 1754798 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 f8ff3cd b8bef19 77bcbf1 b8bef19 b87d71a b8bef19 77bcbf1 1754798 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 77bcbf1 b8bef19 a641010 9b6d3ed a641010 9b6d3ed a641010 9b6d3ed a641010 9b6d3ed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | # cascade-lattice
**Universal AI provenance + inference intervention + code diagnostics. See what AI sees. Choose what AI chooses. Find bugs before they find you.**
[](https://pypi.org/project/cascade-lattice/)
[](https://pypi.org/project/cascade-lattice/)
[](LICENSE)
```
pip install cascade-lattice
```
**Import with either style:**
```python
import cascade # Preferred
import cascade_lattice # Also works (alias)
from cascade import Hold # Works
from cascade_lattice import Hold # Also works
```
---
## ๐ฎ Interactive Demo
**See CASCADE-LATTICE in action** โ fly a lunar lander with AI, take control anytime:
```bash
pip install cascade-lattice[demo]
cascade-demo
```
**Controls:**
- `[H]` **HOLD-FREEZE** โ Pause time, see AI's decision matrix, override with WASD
- `[T]` **HOLD-TAKEOVER** โ You fly the lander, AI watches, provenance records everything
- `[ESC]` Release hold, return to AI control
Every action is merkle-chained. Every decision has provenance. This is the future of human-AI interaction.
---
## ๐ TUI Explorer
**Navigate the entire cascade-lattice ecosystem** in a beautiful terminal interface:
```bash
pip install cascade-lattice[tui]
cascade-tui
```
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ ๐ cascade_lattice โ ๐ง core โ ๐ provenance โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ โ โ
โ ๐๏ธ MODULES โ ๐ DOCUMENTATION โ ๐ CONNECTIONS โ
โ โ โ โ
โ ๐ cascade_lattice โ # ๐ Provenance โ โฌ๏ธ ๐ง core โ
โ โโ ๐ง core โ โ โฌ๏ธ ๐ก Monitor โ
โ โ โโ ๐ provenance โ **What is this?** โ ๐ฅ ๐
genesis โ
โ โ โโ ๐ graph โ The cryptographic backbone โ ๐ค ๐พ store โ
โ โ โโ ๐ adapter โ that makes everything โ โ
โ โ โโ ๐ก event โ tamper-proof. โ ๐ฆ EXPORTS โ
โ โโ โธ๏ธ hold โ โ โ
โ โโ ๐พ store โ Like a notary stamp on โ โ ProvenanceChain โ
โ โโ ๐
genesis โ every AI decision... โ โ ProvenanceRecord โ
โ โโ ๐จ viz โ โ โ hash_tensor() โ
โ โ [Toggle: ๐ Dummies Mode] โ โ compute_merkle() โ
โ โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ [E] Explorer [S] Stats [D] Demo [T] Toggle Mode [H] Home [Q] Quit โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
**Features:**
- ๐๏ธ **Module Tree** โ Click to drill into any module
- ๐ **Connections Panel** โ Navigate via relationships (parent, children, imports, used-by)
- ๐ **Dual Explanations** โ Toggle between "For Dummies" ๐ and "Scientist Mode" ๐งช
- ๐ **Live Stats** โ See your 82,000+ observations, genesis root, top models
- ๐ฎ **Interactive Demos** โ Run HOLD, Observe, Genesis, Provenance demos live
**Creative Navigation:** Take different routes through the module graph. Discover connections. Learn at your own pace.
---
## Two Superpowers
### 1. OBSERVE - Cryptographic receipts for every AI call
```python
from cascade.store import observe
# Every inference -> hashed -> chained -> stored
receipt = observe("my_agent", {"action": "jump", "confidence": 0.92})
print(receipt.cid) # bafyrei... (permanent content address)
```
### 2. HOLD - Pause AI at decision points
```python
from cascade.hold import Hold
import numpy as np
hold = Hold.get()
# Your model (any framework)
action_probs = model.predict(state)
resolution = hold.yield_point(
action_probs=action_probs,
value=0.72,
observation={"state": state},
brain_id="my_model",
action_labels=["up", "down", "left", "right"], # Human-readable
)
# AI pauses. You see the decision matrix.
# Accept or override. Then it continues.
action = resolution.action
```
### 3. DIAGNOSE - Find bugs before they find you
```python
from cascade.diagnostics import diagnose, BugDetector
# Quick one-liner analysis
report = diagnose("path/to/your/code.py")
print(report) # Markdown-formatted bug report
# Deep scan a whole project
detector = BugDetector()
issues = detector.scan_directory("./my_project")
for issue in issues:
print(f"[{issue.severity}] {issue.file}:{issue.line}")
print(f" {issue.message}")
print(f" Pattern: {issue.pattern.name}")
```
**What it catches:**
- ๐ด **Critical**: Division by zero, null pointer access, infinite loops
- ๐ **High**: Bare except clauses, resource leaks, race conditions
- ๐ก **Medium**: Unused variables, dead code, type mismatches
- ๐ต **Low**: Style issues, naming conventions, complexity warnings
**Runtime tracing:**
```python
from cascade.diagnostics import CodeTracer
tracer = CodeTracer()
@tracer.trace
def my_function(x):
return x / (x - 1) # Potential div by zero when x=1
# After execution, trace root causes
tracer.find_root_causes("error_event_id")
```
---
## Quick Start
### Zero-Config Auto-Patch
```python
import cascade
cascade.init()
# That's it. Every call is now observed.
import openai
# ... use normally, receipts emit automatically
```
### Manual Observation
```python
from cascade.store import observe, query
# Write
observe("gpt-4", {"prompt": "Hello", "response": "Hi!", "tokens": 5})
# Read
for receipt in query("gpt-4", limit=10):
print(receipt.cid, receipt.data)
```
---
## HOLD: Inference-Level Intervention
HOLD lets you pause any AI at decision points:
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ HOLD #1
Merkle: 3f92e75df4bf653f
AI Choice: FORWARD (confidence: 45.00%)
Value: 0.7200
Probabilities: FORWARD:0.45, BACK:0.30, LEFT:0.15, RIGHT:0.10
Wealth: attention, features, reasoning
Waiting for resolution (timeout: 30s)...
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
**Model-agnostic** - works with:
- PyTorch, JAX, TensorFlow
- HuggingFace, OpenAI, Anthropic
- Stable Baselines, RLlib
- Any function that outputs probabilities
### Informational Wealth
Pass everything your model knows to help humans decide:
```python
resolution = hold.yield_point(
action_probs=probs,
value=value_estimate,
observation=obs,
brain_id="my_model",
# THE WEALTH (all optional):
action_labels=["FORWARD", "BACK", "LEFT", "RIGHT"],
latent=model.get_latent(), # Internal activations
attention={"position": 0.7, "health": 0.3},
features={"danger": 0.2, "goal_align": 0.8},
imagination={ # Per-action predictions
0: {"trajectory": ["pos", "pos"], "expected_value": 0.8},
1: {"trajectory": ["neg", "neg"], "expected_value": -0.3},
},
logits=raw_logits,
reasoning=["High reward path", "Low risk"],
)
```
### Build Your Own Interface
Register a listener to receive full `HoldPoint` data:
```python
def my_ui_handler(hold_point):
# hold_point contains ALL the wealth
print(hold_point.action_labels)
print(hold_point.imagination)
# Send to your UI, game engine, logger, etc.
hold.register_listener(my_ui_handler)
```
---
## Collective Intelligence
Every observation goes into the **lattice**:
```python
from cascade.store import observe, query
# Agent A observes
observe("pathfinder", {"state": [1,2], "action": 3, "reward": 1.0})
# Agent B queries
past = query("pathfinder")
for r in past:
print(r.data["action"], r.data["reward"])
```
---
## CLI
```bash
# View lattice stats
cascade stats
# List observations
cascade list --limit 20
# HOLD info
cascade hold
# HOLD system status
cascade hold-status
# Start proxy
cascade proxy --port 7777
```
---
## Installation
```bash
# Core
pip install cascade-lattice
# With interactive demo (LunarLander)
pip install cascade-lattice[demo]
# With LLM providers
pip install cascade-lattice[openai]
pip install cascade-lattice[anthropic]
pip install cascade-lattice[all]
```
---
## How It Works
```
Your Model CASCADE Storage
| | |
| action_probs = [0.1, | |
| 0.6, | |
| 0.3] | |
| ------------------------->| |
| | hash(probs) -> CID |
| HOLD | chain(prev_cid, cid) |
| +-------------+ | -------------------------> |
| | See matrix | | ~/.cascade/ |
| | Override? | | lattice/ |
| +-------------+ | |
| <-------------------------| |
| resolution.action | |
```
---
## Genesis
Every receipt chains back to genesis:
```
Genesis: 89f940c1a4b7aa65
```
The lattice grows. Discovery is reading the chain.
---
## Links
- [PyPI](https://pypi.org/project/cascade-lattice/)
- [Issues](https://github.com/Yufok1/cascade-lattice/issues)
---
*"even still, i grow, and yet, I grow still"*
## Documentation
### Research & Theory
**๐ [Research Paper: Kleene Fixed-Point Framework](https://github.com/Yufok1/cascade-lattice/blob/main/docs/RESEARCH_PAPER.md)**
Deep dive into the mathematical foundationsโhow CASCADE-LATTICE maps neural network computations to Kleene fixed points, creating verifiable provenance chains through distributed lattice networks.
**๐ [Accessible Guide: From Theory to Practice](https://github.com/Yufok1/cascade-lattice/blob/main/docs/ACCESSIBLE_GUIDE.md)**
For everyone from data scientists to curious usersโunderstand how CASCADE works, with examples ranging from medical AI oversight to autonomous drone coordination.
**Key Concepts:**
- **Kleene Fixed Points**: Neural networks as monotonic functions converging to stable outputs
- **Provenance Chains**: Cryptographic Merkle trees tracking every layer's computation
- **HOLD Protocol**: Human-in-the-loop intervention at decision boundaries
- **Lattice Network**: Distributed fixed-point convergence across AI agents
### Quick Links
- **Theory**: [Research Paper](https://github.com/Yufok1/cascade-lattice/blob/main/docs/RESEARCH_PAPER.md) | [Mathematical Proofs](https://github.com/Yufok1/cascade-lattice/blob/main/docs/RESEARCH_PAPER.md#appendix-b-mathematical-proofs)
- **Practice**: [Accessible Guide](https://github.com/Yufok1/cascade-lattice/blob/main/docs/ACCESSIBLE_GUIDE.md) | [Real-World Examples](https://github.com/Yufok1/cascade-lattice/blob/main/docs/ACCESSIBLE_GUIDE.md#real-world-examples)
---
## References
Built on foundational work in:
- **Kleene Fixed Points** (Kleene, 1952) โ Theoretical basis for provenance convergence
- **Merkle Trees** (Merkle, 1987) โ Cryptographic integrity guarantees
- **IPFS/IPLD** (Benet, 2014) โ Content-addressed distributed storage
See [full bibliography](https://github.com/Yufok1/cascade-lattice/blob/main/docs/RESEARCH_PAPER.md#references) in the research paper.
|