Datasets:
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- models/champion_gen42.py +3 -0
- models/requirements.txt +9 -0
- models/tests/cascade_deep_dive.py +115 -0
- models/tests/deep_dive_bridge.py +50 -0
- models/tests/deep_dive_export.py +86 -0
- models/tests/deep_dive_forward_hold.py +99 -0
- models/tests/deep_dive_genesis.py +86 -0
- models/tests/deep_dive_hold.py +104 -0
- models/tests/deep_dive_hold_async.py +120 -0
- models/tests/deep_dive_interface.py +37 -0
- models/tests/deep_dive_observations.py +68 -0
- models/tests/inspect_champion.py +57 -0
- models/tests/test_champion_full.py +65 -0
- models/tests/test_module_level.py +15 -0
- models/tests/verify_champion.py +44 -0
.gitattributes
CHANGED
|
@@ -59,3 +59,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 59 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 60 |
logs/comm_events.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 61 |
models/champion_gen1000.py filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 59 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 60 |
logs/comm_events.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 61 |
models/champion_gen1000.py filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
models/champion_gen42.py filter=lfs diff=lfs merge=lfs -text
|
models/champion_gen42.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6703534715ee36f3f28d4c7e65f4824e7f31c2b37cea94c1408e95d3165e8835
|
| 3 |
+
size 504619403
|
models/requirements.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy>=1.21.0,<2.0
|
| 2 |
+
cascade-lattice>=0.1.3
|
| 3 |
+
rerun-sdk>=0.28.0
|
| 4 |
+
jax>=0.4.20
|
| 5 |
+
jaxlib>=0.4.20
|
| 6 |
+
ninjax>=3.5.0
|
| 7 |
+
elements>=3.19.0
|
| 8 |
+
einops>=0.8.0
|
| 9 |
+
portal>=0.2.0
|
models/tests/cascade_deep_dive.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""CASCADE-LATTICE Deep Dive Summary"""
|
| 2 |
+
from cascade import store, genesis, Hold, HoldPoint, CausationGraph, Receipt
|
| 3 |
+
|
| 4 |
+
print("=" * 70)
|
| 5 |
+
print("CASCADE-LATTICE v0.6.0 - DEEP DIVE SUMMARY")
|
| 6 |
+
print("=" * 70)
|
| 7 |
+
|
| 8 |
+
print("""
|
| 9 |
+
CORE PHILOSOPHY:
|
| 10 |
+
"Universal AI provenance layer — cryptographic receipts for every call,
|
| 11 |
+
HOLD inference halt protocol, and code diagnostics"
|
| 12 |
+
|
| 13 |
+
BY: Jeff Towers
|
| 14 |
+
|
| 15 |
+
ARCHITECTURE:
|
| 16 |
+
┌─────────────────────────────────────────────────────────────────────┐
|
| 17 |
+
│ CASCADE-LATTICE │
|
| 18 |
+
├─────────────────────────────────────────────────────────────────────┤
|
| 19 |
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
| 20 |
+
│ │ HOLD │ │ CAUSATION │ │ METRICS │ │ FORENSICS │ │
|
| 21 |
+
│ │ System │ │ Graph │ │ Engine │ │ + GhostLog │ │
|
| 22 |
+
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
|
| 23 |
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
| 24 |
+
│ │ STORE │ │ GENESIS │ │ IDENTITY │ │ DIAGNOSTICS │ │
|
| 25 |
+
│ │ (SQLite+CID)│ │ (Provenance)│ │(Fingerprint)│ │ (BugDetect) │ │
|
| 26 |
+
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
|
| 27 |
+
└─────────────────────────────────────────────────────────────────────┘
|
| 28 |
+
↓ Sync
|
| 29 |
+
┌─────────────────────┐
|
| 30 |
+
│ HuggingFace Hub │
|
| 31 |
+
│ tostido/cascade-obs │
|
| 32 |
+
└─────────────────────┘
|
| 33 |
+
""")
|
| 34 |
+
|
| 35 |
+
s = store.stats()
|
| 36 |
+
|
| 37 |
+
print("LOCAL LATTICE STATS:")
|
| 38 |
+
print(f" Genesis Root: {s['genesis_root']}")
|
| 39 |
+
print(f" Total Observations: {s['total_observations']:,}")
|
| 40 |
+
print(f" Lattice Dir: {s['lattice_dir']}")
|
| 41 |
+
print()
|
| 42 |
+
print("MODELS TRACKED:")
|
| 43 |
+
for model, count in s['models'].items():
|
| 44 |
+
print(f" {model}: {count:,} observations")
|
| 45 |
+
|
| 46 |
+
print()
|
| 47 |
+
print("=" * 70)
|
| 48 |
+
print("KEY COMPONENTS")
|
| 49 |
+
print("=" * 70)
|
| 50 |
+
|
| 51 |
+
print("""
|
| 52 |
+
1. HOLD SYSTEM - Inference-level halt protocol
|
| 53 |
+
├── Hold.yield_point() - Brain pauses, yields decision
|
| 54 |
+
├── HoldPoint - Freeze-frame with merkle chain
|
| 55 |
+
├── Hold.resolve() - External resolution (human/Ghost)
|
| 56 |
+
└── HoldResolution - Final action + override info
|
| 57 |
+
|
| 58 |
+
2. HOLDPOINT FIELDS (the decision snapshot):
|
| 59 |
+
├── action_probs - Probability distribution
|
| 60 |
+
├── value - Predicted value
|
| 61 |
+
├── observation - What brain saw
|
| 62 |
+
├── imagination - Dict[int, Dict] future trajectories
|
| 63 |
+
├── attention - Where brain focused
|
| 64 |
+
├── reasoning - Optional reasoning chain
|
| 65 |
+
├── merkle_root - Cryptographic hash
|
| 66 |
+
└── parent_merkle - Link to previous decision
|
| 67 |
+
|
| 68 |
+
3. CAUSATION GRAPH - Bidirectional event tracing
|
| 69 |
+
├── add_event(Event) - Record event
|
| 70 |
+
├── get_causes(id) - What caused this?
|
| 71 |
+
├── get_effects(id) - What did this cause?
|
| 72 |
+
└── Tracer.trace_backwards/forwards
|
| 73 |
+
|
| 74 |
+
4. STORE - SQLite + Content-Addressable (CID)
|
| 75 |
+
├── observe(model_id, data) - Record observation
|
| 76 |
+
├── query(model_id, since) - Query observations
|
| 77 |
+
├── Receipt - CID + merkle + parent chain
|
| 78 |
+
└── sync_all() - Push to HuggingFace
|
| 79 |
+
|
| 80 |
+
5. GENESIS - Provenance root
|
| 81 |
+
├── create_genesis() - Start new chain
|
| 82 |
+
├── get_genesis_root() - Get chain root hash
|
| 83 |
+
└── verify_lineage_to_genesis() - Verify full chain
|
| 84 |
+
|
| 85 |
+
6. IDENTITY - Model fingerprinting
|
| 86 |
+
├── ModelIdentity - Base model + variant + fingerprint
|
| 87 |
+
├── BehavioralFingerprint - Probe responses hash
|
| 88 |
+
└── detect_format/quantization
|
| 89 |
+
|
| 90 |
+
7. FORENSICS - Post-hoc analysis
|
| 91 |
+
├── GhostLog - Operation narrative
|
| 92 |
+
├─�� DataForensics - Artifact detection
|
| 93 |
+
└── TechFingerprinter - Technology identification
|
| 94 |
+
|
| 95 |
+
8. DIAGNOSTICS - Code analysis
|
| 96 |
+
├── BugDetector - Pattern-based bug scanning
|
| 97 |
+
├── CodeTracer - Execution tracing
|
| 98 |
+
└── DiagnosticEngine - Full diagnostic report
|
| 99 |
+
""")
|
| 100 |
+
|
| 101 |
+
print("=" * 70)
|
| 102 |
+
print("HUGGINGFACE INTEGRATION")
|
| 103 |
+
print("=" * 70)
|
| 104 |
+
print("""
|
| 105 |
+
Your dataset: tostido/cascade-observations
|
| 106 |
+
- 556 downloads
|
| 107 |
+
- Created: 2026-01-07
|
| 108 |
+
- Last modified: 2026-01-17
|
| 109 |
+
|
| 110 |
+
Commands:
|
| 111 |
+
cascade.pull_from_hf('tostido/cascade-observations') # Pull
|
| 112 |
+
cascade.sync_all() # Push
|
| 113 |
+
""")
|
| 114 |
+
|
| 115 |
+
print("=" * 70)
|
models/tests/deep_dive_bridge.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deep dive into BridgeFaculty and Kleene fixed-point matching."""
|
| 2 |
+
import sys
|
| 3 |
+
sys.path.insert(0, 'F:/End-Game/glassboxgames/children')
|
| 4 |
+
import champion_gen1000 as champ
|
| 5 |
+
|
| 6 |
+
print("=" * 70)
|
| 7 |
+
print("🌉 BRIDGE FACULTY - Kleene Fixed-Point Data Bridging")
|
| 8 |
+
print("=" * 70)
|
| 9 |
+
|
| 10 |
+
# Check BridgeFaculty class
|
| 11 |
+
print("\n=== BridgeFaculty Class ===")
|
| 12 |
+
BridgeFaculty = champ.BridgeFaculty
|
| 13 |
+
print(f"Type: {BridgeFaculty}")
|
| 14 |
+
print(f"Methods: {[m for m in dir(BridgeFaculty) if not m.startswith('_')]}")
|
| 15 |
+
|
| 16 |
+
# Get docstring
|
| 17 |
+
if BridgeFaculty.__doc__:
|
| 18 |
+
print(f"\nDocstring:\n{BridgeFaculty.__doc__}")
|
| 19 |
+
|
| 20 |
+
# Look at the source if possible
|
| 21 |
+
import inspect
|
| 22 |
+
try:
|
| 23 |
+
source = inspect.getsource(BridgeFaculty)
|
| 24 |
+
print(f"\n=== Source Code ===")
|
| 25 |
+
print(source[:3000])
|
| 26 |
+
except Exception as e:
|
| 27 |
+
print(f"Can't get source: {e}")
|
| 28 |
+
|
| 29 |
+
# Try to instantiate
|
| 30 |
+
print("\n=== Instantiate Bridge ===")
|
| 31 |
+
try:
|
| 32 |
+
bridge = BridgeFaculty()
|
| 33 |
+
print(f"Bridge instance: {bridge}")
|
| 34 |
+
print(f"Instance methods: {[m for m in dir(bridge) if not m.startswith('_')]}")
|
| 35 |
+
|
| 36 |
+
# Try the bridge method
|
| 37 |
+
print("\n=== Test Bridge Transformation ===")
|
| 38 |
+
old_form = {"position": [1, 2, 3], "health": 100}
|
| 39 |
+
new_form = {"pos_x": None, "pos_y": None, "pos_z": None, "hp": None}
|
| 40 |
+
|
| 41 |
+
print(f"Old form: {old_form}")
|
| 42 |
+
print(f"New form template: {new_form}")
|
| 43 |
+
|
| 44 |
+
result = bridge.bridge(old_form, new_form)
|
| 45 |
+
print(f"Bridged result: {result}")
|
| 46 |
+
|
| 47 |
+
except Exception as e:
|
| 48 |
+
print(f"Error: {e}")
|
| 49 |
+
import traceback
|
| 50 |
+
traceback.print_exc()
|
models/tests/deep_dive_export.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Deep Dive: Export Capabilities
|
| 3 |
+
|
| 4 |
+
Testing the capsule agent's self-export capabilities:
|
| 5 |
+
1. export_pt() - PyTorch format
|
| 6 |
+
2. export_onnx() - ONNX for deployment
|
| 7 |
+
3. export_capsule() - Self-replicating quine!
|
| 8 |
+
|
| 9 |
+
The quine capability is special - the model can export itself
|
| 10 |
+
as a complete, self-contained Python module!
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import os
|
| 14 |
+
import champion_gen1000 as ch
|
| 15 |
+
|
| 16 |
+
print("=" * 60)
|
| 17 |
+
print("📦 Capsule Export Capabilities")
|
| 18 |
+
print("=" * 60)
|
| 19 |
+
|
| 20 |
+
# Create agent
|
| 21 |
+
agent = ch.CapsuleAgent()
|
| 22 |
+
|
| 23 |
+
# Show current quine info
|
| 24 |
+
print(f"\n=== Current Quine Info ===")
|
| 25 |
+
print(f"Quine hash: {ch.get_quine_hash()}")
|
| 26 |
+
print(f"Integrity: {ch.verify_quine_integrity()}")
|
| 27 |
+
|
| 28 |
+
# Create export directory
|
| 29 |
+
export_dir = "exports"
|
| 30 |
+
os.makedirs(export_dir, exist_ok=True)
|
| 31 |
+
|
| 32 |
+
# Test export_capsule (the quine self-replication!)
|
| 33 |
+
print(f"\n=== Testing export_capsule() ===")
|
| 34 |
+
print("This creates a self-contained Python module...")
|
| 35 |
+
|
| 36 |
+
capsule_path = agent.export_capsule(os.path.join(export_dir, "child_capsule.py"))
|
| 37 |
+
print(f"Exported to: {capsule_path}")
|
| 38 |
+
|
| 39 |
+
# Check the file
|
| 40 |
+
if capsule_path and os.path.exists(capsule_path):
|
| 41 |
+
size = os.path.getsize(capsule_path)
|
| 42 |
+
print(f"File size: {size / 1024 / 1024:.2f} MB")
|
| 43 |
+
|
| 44 |
+
# Read first few lines
|
| 45 |
+
with open(capsule_path, 'r', encoding='utf-8', errors='ignore') as f:
|
| 46 |
+
lines = f.readlines()[:30]
|
| 47 |
+
|
| 48 |
+
print("\n=== First 30 lines of exported capsule ===")
|
| 49 |
+
for i, line in enumerate(lines, 1):
|
| 50 |
+
print(f"{i:3d}: {line.rstrip()[:80]}")
|
| 51 |
+
|
| 52 |
+
print(f"\n... ({len(lines)} of total lines shown)")
|
| 53 |
+
|
| 54 |
+
# Verify it's a valid quine
|
| 55 |
+
print("\n=== Verifying exported capsule ===")
|
| 56 |
+
try:
|
| 57 |
+
import importlib.util
|
| 58 |
+
spec = importlib.util.spec_from_file_location("child", capsule_path)
|
| 59 |
+
child = importlib.util.module_from_spec(spec)
|
| 60 |
+
spec.loader.exec_module(child)
|
| 61 |
+
|
| 62 |
+
if hasattr(child, 'get_quine_hash'):
|
| 63 |
+
child_hash = child.get_quine_hash()
|
| 64 |
+
print(f"Child quine hash: {child_hash}")
|
| 65 |
+
print(f"Parent quine hash: {ch.get_quine_hash()}")
|
| 66 |
+
print(f"Hashes match: {child_hash == ch.get_quine_hash()}")
|
| 67 |
+
|
| 68 |
+
if hasattr(child, 'verify_quine_integrity'):
|
| 69 |
+
print(f"Child integrity: {child.verify_quine_integrity()}")
|
| 70 |
+
|
| 71 |
+
except Exception as e:
|
| 72 |
+
print(f"Could not verify child: {e}")
|
| 73 |
+
else:
|
| 74 |
+
print("Export may not have created a file")
|
| 75 |
+
|
| 76 |
+
# Test replicate_quine directly
|
| 77 |
+
print("\n=== Testing replicate_quine() ===")
|
| 78 |
+
replica_path = ch.replicate_quine(os.path.join(export_dir, "replica.py"))
|
| 79 |
+
print(f"Replicated to: {replica_path}")
|
| 80 |
+
|
| 81 |
+
if replica_path and os.path.exists(replica_path):
|
| 82 |
+
replica_size = os.path.getsize(replica_path)
|
| 83 |
+
original_size = os.path.getsize("champion_gen1000.py")
|
| 84 |
+
print(f"Original size: {original_size / 1024 / 1024:.2f} MB")
|
| 85 |
+
print(f"Replica size: {replica_size / 1024 / 1024:.2f} MB")
|
| 86 |
+
print(f"Size match: {abs(replica_size - original_size) < 1000}")
|
models/tests/deep_dive_forward_hold.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Deep Dive: forward_hold() - HOLD-aware inference
|
| 3 |
+
|
| 4 |
+
The CapsuleAgent.forward_hold() method is the production API
|
| 5 |
+
for HOLD-aware inference. It:
|
| 6 |
+
1. Runs the brain forward pass
|
| 7 |
+
2. Yields a HOLD point automatically
|
| 8 |
+
3. Returns the final action (possibly overridden)
|
| 9 |
+
|
| 10 |
+
This is what the arcade stream uses for Twitch chat control!
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import numpy as np
|
| 14 |
+
import threading
|
| 15 |
+
import time
|
| 16 |
+
|
| 17 |
+
# Load the champion
|
| 18 |
+
import champion_gen1000 as ch
|
| 19 |
+
|
| 20 |
+
print("=" * 60)
|
| 21 |
+
print("🎮 forward_hold() - HOLD-aware Arcade Inference")
|
| 22 |
+
print("=" * 60)
|
| 23 |
+
|
| 24 |
+
# Create agent
|
| 25 |
+
agent = ch.CapsuleAgent()
|
| 26 |
+
print(f"\nAgent: {agent}")
|
| 27 |
+
print(f"Genesis: {ch.get_genesis_root()}")
|
| 28 |
+
|
| 29 |
+
# Get the HOLD singleton
|
| 30 |
+
hold = ch.get_hold()
|
| 31 |
+
print(f"Hold: {hold}")
|
| 32 |
+
print(f"Hold enabled: {hold.enabled}")
|
| 33 |
+
print(f"Available: {[x for x in dir(hold) if not x.startswith('_')]}")
|
| 34 |
+
|
| 35 |
+
# Add a listener via the listeners list
|
| 36 |
+
def on_hold(hp):
|
| 37 |
+
print(f"\n🔴 HOLD POINT from forward_hold()!")
|
| 38 |
+
print(f" Brain ID: {hp.brain_id}")
|
| 39 |
+
print(f" Action probs: {hp.action_probs}")
|
| 40 |
+
if hp.action_labels:
|
| 41 |
+
print(f" Labels: {hp.action_labels}")
|
| 42 |
+
print(f" Value: {hp.value:.3f}")
|
| 43 |
+
|
| 44 |
+
hold.listeners.append(on_hold)
|
| 45 |
+
|
| 46 |
+
# Simulate arcade observation
|
| 47 |
+
observation = {
|
| 48 |
+
"screen": np.random.rand(84, 84, 3).astype(np.float32),
|
| 49 |
+
"lives": 3,
|
| 50 |
+
"score": 1500
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
print("\n=== Test 1: Non-blocking forward_hold ===")
|
| 54 |
+
result = agent.forward_hold(
|
| 55 |
+
inputs={"observation": observation},
|
| 56 |
+
blocking=False # Don't block, just return AI choice
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
print(f"\nResult keys: {result.keys()}")
|
| 60 |
+
print(f"Action: {result.get('action')}")
|
| 61 |
+
print(f"Was override: {result.get('was_override', False)}")
|
| 62 |
+
print(f"Merkle: {result.get('merkle_root', 'N/A')}")
|
| 63 |
+
|
| 64 |
+
print("\n=== Test 2: Blocking with Override ===")
|
| 65 |
+
|
| 66 |
+
def override_thread():
|
| 67 |
+
"""Simulates chat override"""
|
| 68 |
+
time.sleep(0.3)
|
| 69 |
+
print("\n💬 Chat: !override 0")
|
| 70 |
+
hold.override(0) # Embedded hold state only takes action
|
| 71 |
+
|
| 72 |
+
# Start override thread
|
| 73 |
+
t = threading.Thread(target=override_thread)
|
| 74 |
+
t.start()
|
| 75 |
+
|
| 76 |
+
# This will block until override or timeout
|
| 77 |
+
result2 = agent.forward_hold(
|
| 78 |
+
inputs={"observation": observation},
|
| 79 |
+
blocking=True
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
t.join()
|
| 83 |
+
|
| 84 |
+
print(f"\nResult 2:")
|
| 85 |
+
print(f" Action: {result2.get('action')}")
|
| 86 |
+
print(f" Was override: {result2.get('was_override', False)}")
|
| 87 |
+
print(f" Override source: {result2.get('override_source', 'N/A')}")
|
| 88 |
+
|
| 89 |
+
# Check provenance
|
| 90 |
+
print("\n=== Provenance Check ===")
|
| 91 |
+
prov = agent.get_full_provenance()
|
| 92 |
+
print(f"Quine hash: {prov.get('quine_hash', 'N/A')[:16]}...")
|
| 93 |
+
print(f"Genesis: {prov.get('genesis_root', 'N/A')}")
|
| 94 |
+
print(f"Observation count: {prov.get('observation_count', 0)}")
|
| 95 |
+
|
| 96 |
+
print("\n=== Hold Stats ===")
|
| 97 |
+
print(f"Hold count: {hold.hold_count}")
|
| 98 |
+
print(f"Override count: {hold.override_count}")
|
| 99 |
+
print(f"Last merkle: {hold.last_merkle}")
|
models/tests/deep_dive_genesis.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deep dive into genesis lineage and provenance chain."""
|
| 2 |
+
import sys
|
| 3 |
+
sys.path.insert(0, 'F:/End-Game/glassboxgames/children')
|
| 4 |
+
sys.path.insert(0, 'F:/End-Game/key')
|
| 5 |
+
|
| 6 |
+
print("=" * 70)
|
| 7 |
+
print("🔐 GENESIS LINEAGE - Tracing the Champion's Origins")
|
| 8 |
+
print("=" * 70)
|
| 9 |
+
|
| 10 |
+
# Check CASCADE genesis
|
| 11 |
+
print("\n=== CASCADE Genesis Root ===")
|
| 12 |
+
try:
|
| 13 |
+
from cascade import genesis
|
| 14 |
+
root = genesis.get_genesis_root()
|
| 15 |
+
print(f"Genesis root: {root}")
|
| 16 |
+
|
| 17 |
+
# Get full genesis info
|
| 18 |
+
if hasattr(genesis, 'get_genesis_info'):
|
| 19 |
+
info = genesis.get_genesis_info()
|
| 20 |
+
print(f"Genesis info: {info}")
|
| 21 |
+
except Exception as e:
|
| 22 |
+
print(f"Error: {e}")
|
| 23 |
+
|
| 24 |
+
# Check SwarmLattice
|
| 25 |
+
print("\n=== SwarmLattice ===")
|
| 26 |
+
try:
|
| 27 |
+
from swarm_lattice import SwarmLattice
|
| 28 |
+
lattice = SwarmLattice(link_to_genesis=True)
|
| 29 |
+
print(f"Lattice genesis root: {lattice.genesis_root}")
|
| 30 |
+
print(f"Lattice merkle root: {lattice.merkle_root}")
|
| 31 |
+
stats = lattice.get_stats()
|
| 32 |
+
print(f"Stats: {stats}")
|
| 33 |
+
except Exception as e:
|
| 34 |
+
print(f"Error: {e}")
|
| 35 |
+
|
| 36 |
+
# Check champion's view of genesis
|
| 37 |
+
print("\n=== Champion's Genesis View ===")
|
| 38 |
+
try:
|
| 39 |
+
import champion_gen1000 as champ
|
| 40 |
+
|
| 41 |
+
# Get genesis root from champion
|
| 42 |
+
print(f"Champion quine hash: {champ.get_quine_hash()}")
|
| 43 |
+
|
| 44 |
+
# Check if champion can verify lineage
|
| 45 |
+
if hasattr(champ, 'verify_lineage_to_genesis'):
|
| 46 |
+
valid = champ.verify_lineage_to_genesis()
|
| 47 |
+
print(f"Lineage to genesis valid: {valid}")
|
| 48 |
+
|
| 49 |
+
# Check genesis from cascade module
|
| 50 |
+
if hasattr(champ, 'genesis'):
|
| 51 |
+
print(f"Champion's genesis module: {champ.genesis}")
|
| 52 |
+
if hasattr(champ.genesis, 'get_genesis_root'):
|
| 53 |
+
print(f"Genesis root: {champ.genesis.get_genesis_root()}")
|
| 54 |
+
except Exception as e:
|
| 55 |
+
print(f"Error: {e}")
|
| 56 |
+
import traceback
|
| 57 |
+
traceback.print_exc()
|
| 58 |
+
|
| 59 |
+
# Explore the provenance chain structure
|
| 60 |
+
print("\n=== CASCADE ProvenanceChain ===")
|
| 61 |
+
try:
|
| 62 |
+
from cascade.core.provenance import ProvenanceChain, ProvenanceRecord
|
| 63 |
+
|
| 64 |
+
# Create a test chain
|
| 65 |
+
chain = ProvenanceChain()
|
| 66 |
+
print(f"Chain type: {type(chain)}")
|
| 67 |
+
print(f"Chain methods: {[m for m in dir(chain) if not m.startswith('_')]}")
|
| 68 |
+
|
| 69 |
+
# Check if we can trace back
|
| 70 |
+
if hasattr(chain, 'verify'):
|
| 71 |
+
print(f"Has verify: True")
|
| 72 |
+
if hasattr(chain, 'get_lineage'):
|
| 73 |
+
print(f"Has get_lineage: True")
|
| 74 |
+
except Exception as e:
|
| 75 |
+
print(f"Error: {e}")
|
| 76 |
+
|
| 77 |
+
# Check CASCADE store stats
|
| 78 |
+
print("\n=== CASCADE Store Stats ===")
|
| 79 |
+
try:
|
| 80 |
+
from cascade import store
|
| 81 |
+
stats = store.stats()
|
| 82 |
+
print(f"Store stats:")
|
| 83 |
+
for k, v in stats.items():
|
| 84 |
+
print(f" {k}: {v}")
|
| 85 |
+
except Exception as e:
|
| 86 |
+
print(f"Error: {e}")
|
models/tests/deep_dive_hold.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deep dive into HOLD system and real-time inference interception."""
|
| 2 |
+
import sys
|
| 3 |
+
sys.path.insert(0, 'F:/End-Game/glassboxgames/children')
|
| 4 |
+
|
| 5 |
+
import cascade
|
| 6 |
+
from cascade import Hold, HoldPoint, HoldState
|
| 7 |
+
import numpy as np
|
| 8 |
+
import threading
|
| 9 |
+
import time
|
| 10 |
+
|
| 11 |
+
print("=" * 70)
|
| 12 |
+
print("⏸️ CASCADE HOLD SYSTEM - Real-time Inference Interception")
|
| 13 |
+
print("=" * 70)
|
| 14 |
+
|
| 15 |
+
# Get the Hold singleton
|
| 16 |
+
hold = Hold.get()
|
| 17 |
+
print(f"\nHold singleton: {hold}")
|
| 18 |
+
print(f"Current hold: {hold.current_hold}")
|
| 19 |
+
print(f"Stats: {hold.stats}")
|
| 20 |
+
|
| 21 |
+
# Register a listener to see hold points
|
| 22 |
+
hold_points_received = []
|
| 23 |
+
|
| 24 |
+
def my_listener(hold_point: HoldPoint):
|
| 25 |
+
print(f"\n🛑 HOLD POINT RECEIVED!")
|
| 26 |
+
print(f" Brain: {hold_point.brain_id}")
|
| 27 |
+
print(f" AI choice: {hold_point.ai_choice}")
|
| 28 |
+
print(f" Confidence: {hold_point.ai_confidence:.2%}")
|
| 29 |
+
print(f" Merkle: {hold_point.merkle_root}")
|
| 30 |
+
print(f" State: {hold_point.state}")
|
| 31 |
+
hold_points_received.append(hold_point)
|
| 32 |
+
|
| 33 |
+
# Auto-accept after 0.1s for demo
|
| 34 |
+
time.sleep(0.1)
|
| 35 |
+
hold.accept()
|
| 36 |
+
|
| 37 |
+
hold.register_listener(my_listener)
|
| 38 |
+
print("\n✅ Listener registered")
|
| 39 |
+
|
| 40 |
+
# Simulate a brain yielding a hold point
|
| 41 |
+
print("\n=== Simulating Hold Point (non-blocking) ===")
|
| 42 |
+
|
| 43 |
+
def simulate_brain():
|
| 44 |
+
# Simulate what happens inside a brain's forward()
|
| 45 |
+
action_probs = np.array([0.1, 0.15, 0.5, 0.25]) # 4 actions
|
| 46 |
+
value = 0.73
|
| 47 |
+
observation = {'game': 'test', 'frame': 42}
|
| 48 |
+
|
| 49 |
+
print(f"Brain: yielding hold point...")
|
| 50 |
+
resolution = hold.yield_point(
|
| 51 |
+
action_probs=action_probs,
|
| 52 |
+
value=value,
|
| 53 |
+
observation=observation,
|
| 54 |
+
brain_id="test_brain_001",
|
| 55 |
+
action_labels=["UP", "DOWN", "FIRE", "STAY"],
|
| 56 |
+
blocking=False # Non-blocking for demo
|
| 57 |
+
)
|
| 58 |
+
print(f"Brain: got resolution -> action={resolution.action}, override={resolution.was_override}, source={resolution.override_source}")
|
| 59 |
+
return resolution
|
| 60 |
+
|
| 61 |
+
result = simulate_brain()
|
| 62 |
+
|
| 63 |
+
print(f"\n=== Result ===")
|
| 64 |
+
print(f"Action taken: {result.action}")
|
| 65 |
+
print(f"Was override: {result.was_override}")
|
| 66 |
+
print(f"Override source: {result.override_source}")
|
| 67 |
+
print(f"Hold duration: {result.hold_duration:.4f}s")
|
| 68 |
+
print(f"Merkle root: {result.merkle_root}")
|
| 69 |
+
|
| 70 |
+
# Try override scenario
|
| 71 |
+
print("\n=== Testing Override Scenario ===")
|
| 72 |
+
|
| 73 |
+
override_received = None
|
| 74 |
+
|
| 75 |
+
def override_listener(hp: HoldPoint):
|
| 76 |
+
global override_received
|
| 77 |
+
override_received = hp
|
| 78 |
+
print(f"\n🛑 HOLD for override test")
|
| 79 |
+
print(f" AI wants action {hp.ai_choice} ({hp.ai_confidence:.0%} confident)")
|
| 80 |
+
# Simulate human override
|
| 81 |
+
time.sleep(0.05)
|
| 82 |
+
hold.override(action=0, source="human_player")
|
| 83 |
+
|
| 84 |
+
hold.unregister_listener(my_listener)
|
| 85 |
+
hold.register_listener(override_listener)
|
| 86 |
+
|
| 87 |
+
action_probs = np.array([0.1, 0.8, 0.05, 0.05]) # AI strongly prefers action 1
|
| 88 |
+
resolution = hold.yield_point(
|
| 89 |
+
action_probs=action_probs,
|
| 90 |
+
value=0.9,
|
| 91 |
+
observation={'test': 'override'},
|
| 92 |
+
brain_id="test_brain_002",
|
| 93 |
+
action_labels=["CONSERVATIVE", "AGGRESSIVE", "RETREAT", "WAIT"],
|
| 94 |
+
blocking=False
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
print(f"\n Final action: {resolution.action}")
|
| 98 |
+
print(f" Was override: {resolution.was_override}")
|
| 99 |
+
print(f" Override source: {resolution.override_source}")
|
| 100 |
+
print(f" AI wanted: 1 (AGGRESSIVE)")
|
| 101 |
+
print(f" Human chose: 0 (CONSERVATIVE)")
|
| 102 |
+
|
| 103 |
+
print("\n=== Hold Stats After Test ===")
|
| 104 |
+
print(hold.stats)
|
models/tests/deep_dive_hold_async.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Deep Dive: HOLD System with Async Override
|
| 3 |
+
|
| 4 |
+
Testing the full HOLD flow:
|
| 5 |
+
1. Brain yields a hold point (blocking)
|
| 6 |
+
2. Human/chat overrides before timeout
|
| 7 |
+
3. See how the override propagates through
|
| 8 |
+
|
| 9 |
+
This is how Twitch chat can control AI decisions in real-time!
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
import threading
|
| 14 |
+
import time
|
| 15 |
+
from cascade import Hold, HoldResolution
|
| 16 |
+
|
| 17 |
+
print("=" * 60)
|
| 18 |
+
print("⏸️ CASCADE HOLD - Async Override Demo")
|
| 19 |
+
print("=" * 60)
|
| 20 |
+
|
| 21 |
+
# Get the singleton
|
| 22 |
+
hold = Hold()
|
| 23 |
+
|
| 24 |
+
# Track what happened
|
| 25 |
+
events = []
|
| 26 |
+
|
| 27 |
+
def listener(hp):
|
| 28 |
+
"""Called when a hold point is created"""
|
| 29 |
+
events.append(f"[LISTENER] Hold point created: brain={hp.brain_id}")
|
| 30 |
+
print(f"\n🔴 HOLD POINT: {hp.brain_id}")
|
| 31 |
+
print(f" Action probs: {hp.action_probs}")
|
| 32 |
+
print(f" Labels: {hp.action_labels}")
|
| 33 |
+
print(f" Value estimate: {hp.value:.3f}")
|
| 34 |
+
|
| 35 |
+
# Show what AI wants to do
|
| 36 |
+
ai_choice = np.argmax(hp.action_probs)
|
| 37 |
+
print(f" AI wants: {ai_choice} ({hp.action_labels[ai_choice] if hp.action_labels else '?'})")
|
| 38 |
+
|
| 39 |
+
hold.register_listener(listener)
|
| 40 |
+
|
| 41 |
+
def brain_thread():
|
| 42 |
+
"""Simulates the AI brain yielding a hold point and waiting"""
|
| 43 |
+
events.append("[BRAIN] Starting inference...")
|
| 44 |
+
print("\n🧠 Brain: Starting inference...")
|
| 45 |
+
|
| 46 |
+
# Fake observations
|
| 47 |
+
observation = {
|
| 48 |
+
"health": 0.3, # Low health!
|
| 49 |
+
"enemies": 2,
|
| 50 |
+
"ammo": 5
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
# AI thinks: "Low health, should retreat!"
|
| 54 |
+
# But maybe human knows better...
|
| 55 |
+
action_probs = np.array([0.05, 0.85, 0.05, 0.05]) # RETREAT strongly preferred
|
| 56 |
+
value = -0.3 # AI thinks situation is bad
|
| 57 |
+
|
| 58 |
+
events.append("[BRAIN] Yielding hold point (blocking)...")
|
| 59 |
+
print("🧠 Brain: Yielding hold point, waiting for resolution...")
|
| 60 |
+
|
| 61 |
+
# This blocks until resolved!
|
| 62 |
+
resolution = hold.yield_point(
|
| 63 |
+
action_probs=action_probs,
|
| 64 |
+
value=value,
|
| 65 |
+
observation=observation,
|
| 66 |
+
brain_id="arcade_brain_007",
|
| 67 |
+
action_labels=["ATTACK", "RETREAT", "HEAL", "DODGE"],
|
| 68 |
+
blocking=True # BLOCKING - will wait
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
events.append(f"[BRAIN] Resolution received: action={resolution.action}")
|
| 72 |
+
print(f"\n🧠 Brain: Got resolution!")
|
| 73 |
+
print(f" Final action: {resolution.action} ({['ATTACK', 'RETREAT', 'HEAL', 'DODGE'][resolution.action]})")
|
| 74 |
+
print(f" Was override: {resolution.was_override}")
|
| 75 |
+
if resolution.was_override:
|
| 76 |
+
print(f" Override from: {resolution.override_source}")
|
| 77 |
+
print(f" Hold duration: {resolution.hold_duration:.3f}s")
|
| 78 |
+
print(f" Merkle: {resolution.merkle_root}")
|
| 79 |
+
|
| 80 |
+
return resolution
|
| 81 |
+
|
| 82 |
+
def human_thread():
|
| 83 |
+
"""Simulates human (Twitch chat) overriding the decision"""
|
| 84 |
+
time.sleep(0.5) # Wait for hold point to be created
|
| 85 |
+
events.append("[HUMAN] Deciding to override...")
|
| 86 |
+
print("\n👤 Human: AI wants to RETREAT but I see an opportunity!")
|
| 87 |
+
print("👤 Human: Overriding to ATTACK!")
|
| 88 |
+
|
| 89 |
+
# Human overrides: "No, attack! I see a power-up!"
|
| 90 |
+
hold.override(0, source="twitch_chat:xX_ProGamer_Xx")
|
| 91 |
+
events.append("[HUMAN] Override injected: ATTACK")
|
| 92 |
+
print("👤 Human: Override injected!")
|
| 93 |
+
|
| 94 |
+
print("\n=== Starting Async Hold Test ===")
|
| 95 |
+
print("Brain will want to RETREAT (low health)")
|
| 96 |
+
print("Human will override to ATTACK")
|
| 97 |
+
print("-" * 40)
|
| 98 |
+
|
| 99 |
+
# Start brain in a thread
|
| 100 |
+
brain = threading.Thread(target=brain_thread)
|
| 101 |
+
brain.start()
|
| 102 |
+
|
| 103 |
+
# Start human in another thread (with delay)
|
| 104 |
+
human = threading.Thread(target=human_thread)
|
| 105 |
+
human.start()
|
| 106 |
+
|
| 107 |
+
# Wait for both
|
| 108 |
+
brain.join()
|
| 109 |
+
human.join()
|
| 110 |
+
|
| 111 |
+
print("\n=== Event Log ===")
|
| 112 |
+
for i, event in enumerate(events, 1):
|
| 113 |
+
print(f" {i}. {event}")
|
| 114 |
+
|
| 115 |
+
print("\n=== Final Stats ===")
|
| 116 |
+
stats = hold.stats # Property not method!
|
| 117 |
+
print(f" Total holds: {stats['total_holds']}")
|
| 118 |
+
print(f" Overrides: {stats['overrides']}")
|
| 119 |
+
print(f" Override rate: {stats['override_rate']:.1%}")
|
| 120 |
+
print(f" Last merkle: {stats['last_merkle']}")
|
models/tests/deep_dive_interface.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deep dive into champion's advanced capabilities."""
|
| 2 |
+
import sys
|
| 3 |
+
sys.path.insert(0, 'F:/End-Game/glassboxgames/children')
|
| 4 |
+
import champion_gen1000 as champ
|
| 5 |
+
import os
|
| 6 |
+
import tempfile
|
| 7 |
+
|
| 8 |
+
print("=" * 70)
|
| 9 |
+
print("🎮 EXPORT_INTERFACE - Self-Spawning HTTP Server")
|
| 10 |
+
print("=" * 70)
|
| 11 |
+
|
| 12 |
+
# Create temp directory for interface export
|
| 13 |
+
output_dir = tempfile.mkdtemp(prefix="champion_interface_")
|
| 14 |
+
print(f"Output dir: {output_dir}")
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
result = champ.export_interface(output_dir)
|
| 18 |
+
print(f"Result: {result}")
|
| 19 |
+
|
| 20 |
+
# List what was created
|
| 21 |
+
print("\nGenerated files:")
|
| 22 |
+
for f in os.listdir(output_dir):
|
| 23 |
+
filepath = os.path.join(output_dir, f)
|
| 24 |
+
size = os.path.getsize(filepath)
|
| 25 |
+
print(f" {f} ({size} bytes)")
|
| 26 |
+
|
| 27 |
+
# Show content of small files
|
| 28 |
+
if size < 5000:
|
| 29 |
+
print(f" --- Content of {f} ---")
|
| 30 |
+
with open(filepath, 'r') as file:
|
| 31 |
+
content = file.read()
|
| 32 |
+
print(content[:2000])
|
| 33 |
+
print(" ---")
|
| 34 |
+
except Exception as e:
|
| 35 |
+
print(f"Error: {e}")
|
| 36 |
+
import traceback
|
| 37 |
+
traceback.print_exc()
|
models/tests/deep_dive_observations.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deep dive into CASCADE observations - what's being recorded."""
|
| 2 |
+
import sys
|
| 3 |
+
sys.path.insert(0, 'F:/End-Game/glassboxgames/children')
|
| 4 |
+
|
| 5 |
+
from cascade import store
|
| 6 |
+
|
| 7 |
+
print("=" * 70)
|
| 8 |
+
print("📊 CASCADE OBSERVATIONS - 8,224 Records")
|
| 9 |
+
print("=" * 70)
|
| 10 |
+
|
| 11 |
+
# Get stats
|
| 12 |
+
stats = store.stats()
|
| 13 |
+
print(f"\nGenesis root: {stats['genesis_root']}")
|
| 14 |
+
print(f"Total observations: {stats['total_observations']}")
|
| 15 |
+
|
| 16 |
+
print("\n=== Observations by Model ===")
|
| 17 |
+
for model, count in sorted(stats['models'].items(), key=lambda x: -x[1]):
|
| 18 |
+
print(f" {model}: {count:,}")
|
| 19 |
+
|
| 20 |
+
# Query recent observations
|
| 21 |
+
print("\n=== Recent Arcade Steps ===")
|
| 22 |
+
try:
|
| 23 |
+
recent = store.query(model_id="arcade_step", limit=5)
|
| 24 |
+
for r in recent:
|
| 25 |
+
print(f"\n CID: {r.cid[:20]}...")
|
| 26 |
+
print(f" Merkle: {r.merkle_root}")
|
| 27 |
+
print(f" Data keys: {list(r.data.keys())}")
|
| 28 |
+
if 'event' in r.data:
|
| 29 |
+
print(f" Event: {r.data.get('event')}")
|
| 30 |
+
if 'agent' in r.data:
|
| 31 |
+
print(f" Agent: {r.data.get('agent')}")
|
| 32 |
+
except Exception as e:
|
| 33 |
+
print(f"Error: {e}")
|
| 34 |
+
|
| 35 |
+
# Query SC2 transitions
|
| 36 |
+
print("\n=== SC2 Transitions ===")
|
| 37 |
+
try:
|
| 38 |
+
sc2 = store.query(model_id="sc2_transition", limit=5)
|
| 39 |
+
for r in sc2:
|
| 40 |
+
print(f"\n CID: {r.cid[:20]}...")
|
| 41 |
+
print(f" Data: {r.data}")
|
| 42 |
+
except Exception as e:
|
| 43 |
+
print(f"Error: {e}")
|
| 44 |
+
|
| 45 |
+
# Query episode ends
|
| 46 |
+
print("\n=== Episode Ends ===")
|
| 47 |
+
try:
|
| 48 |
+
episodes = store.query(model_id="episode_end", limit=5)
|
| 49 |
+
for r in episodes:
|
| 50 |
+
print(f"\n CID: {r.cid[:20]}...")
|
| 51 |
+
data = r.data
|
| 52 |
+
print(f" Game: {data.get('game', 'N/A')}")
|
| 53 |
+
print(f" Reward: {data.get('episode_reward', 'N/A')}")
|
| 54 |
+
print(f" Steps: {data.get('episode_steps', 'N/A')}")
|
| 55 |
+
except Exception as e:
|
| 56 |
+
print(f"Error: {e}")
|
| 57 |
+
|
| 58 |
+
# Check the provenance chain
|
| 59 |
+
print("\n=== Provenance Chain Sample ===")
|
| 60 |
+
try:
|
| 61 |
+
sample = store.query(limit=3)
|
| 62 |
+
for r in sample:
|
| 63 |
+
print(f"\n CID: {r.cid}")
|
| 64 |
+
print(f" Model: {r.model_id}")
|
| 65 |
+
print(f" Merkle: {r.merkle_root}")
|
| 66 |
+
print(f" Parent CID: {r.parent_cid or 'None (root)'}")
|
| 67 |
+
except Exception as e:
|
| 68 |
+
print(f"Error: {e}")
|
models/tests/inspect_champion.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Inspect champion model capabilities."""
|
| 2 |
+
import sys
|
| 3 |
+
sys.path.insert(0, 'F:/End-Game/glassboxgames/children')
|
| 4 |
+
|
| 5 |
+
try:
|
| 6 |
+
import champion_gen1000 as champ
|
| 7 |
+
|
| 8 |
+
print('=== MODULE ATTRIBUTES ===')
|
| 9 |
+
print(f'_QUINE_HASH: {getattr(champ, "_QUINE_HASH", "N/A")}')
|
| 10 |
+
print(f'_GENERATION: {getattr(champ, "_GENERATION", "N/A")}')
|
| 11 |
+
print(f'_FITNESS: {getattr(champ, "_FITNESS", "N/A")}')
|
| 12 |
+
|
| 13 |
+
traits = getattr(champ, '_TRAITS', {})
|
| 14 |
+
print(f'_TRAITS keys: {list(traits.keys())[:10]}')
|
| 15 |
+
|
| 16 |
+
print('\n=== MODULE EXPORTS ===')
|
| 17 |
+
exports = [x for x in dir(champ) if not x.startswith('_')]
|
| 18 |
+
for e in exports:
|
| 19 |
+
obj = getattr(champ, e)
|
| 20 |
+
print(f' {e}: {type(obj).__name__}')
|
| 21 |
+
|
| 22 |
+
print('\n=== CAPSULEAGENT CLASS ===')
|
| 23 |
+
if hasattr(champ, 'CapsuleAgent'):
|
| 24 |
+
CapsuleAgent = champ.CapsuleAgent
|
| 25 |
+
methods = [m for m in dir(CapsuleAgent) if not m.startswith('_') and callable(getattr(CapsuleAgent, m, None))]
|
| 26 |
+
print(f'Methods: {methods}')
|
| 27 |
+
|
| 28 |
+
print('\n=== TRYING TO INSTANTIATE ===')
|
| 29 |
+
if hasattr(champ, 'CapsuleAgent'):
|
| 30 |
+
agent = champ.CapsuleAgent(observe=False, observe_visual=False)
|
| 31 |
+
print(f'Agent created: {type(agent).__name__}')
|
| 32 |
+
|
| 33 |
+
# Check what methods the instance has
|
| 34 |
+
instance_methods = [m for m in dir(agent) if not m.startswith('_') and callable(getattr(agent, m, None))]
|
| 35 |
+
print(f'Instance methods: {instance_methods}')
|
| 36 |
+
|
| 37 |
+
# Check specific capabilities
|
| 38 |
+
print('\n=== CAPABILITIES ===')
|
| 39 |
+
print(f'has forward: {hasattr(agent, "forward")}')
|
| 40 |
+
print(f'has imagine: {hasattr(agent, "imagine") or (hasattr(agent, "brain") and hasattr(agent.brain, "imagine"))}')
|
| 41 |
+
print(f'has export_pt: {hasattr(agent, "export_pt")}')
|
| 42 |
+
print(f'has export_onnx: {hasattr(agent, "export_onnx")}')
|
| 43 |
+
print(f'has replicate_quine: {hasattr(agent, "replicate_quine")}')
|
| 44 |
+
print(f'has get_quine_brain: {hasattr(agent, "get_quine_brain")}')
|
| 45 |
+
print(f'has verify_quine_integrity: {hasattr(agent, "verify_quine_integrity")}')
|
| 46 |
+
|
| 47 |
+
# Check brain
|
| 48 |
+
if hasattr(agent, 'brain'):
|
| 49 |
+
print(f'\n=== BRAIN ===')
|
| 50 |
+
print(f'Brain type: {type(agent.brain).__name__}')
|
| 51 |
+
brain_methods = [m for m in dir(agent.brain) if not m.startswith('_') and callable(getattr(agent.brain, m, None))]
|
| 52 |
+
print(f'Brain methods: {brain_methods[:15]}...')
|
| 53 |
+
|
| 54 |
+
except Exception as e:
|
| 55 |
+
import traceback
|
| 56 |
+
print(f'Error: {e}')
|
| 57 |
+
traceback.print_exc()
|
models/tests/test_champion_full.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Test champion forward inference and HOLD."""
|
| 2 |
+
import sys
|
| 3 |
+
sys.path.insert(0, 'F:/End-Game/glassboxgames/children')
|
| 4 |
+
import champion_gen1000 as champ
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
agent = champ.CapsuleAgent(observe=False, observe_visual=False)
|
| 8 |
+
|
| 9 |
+
print('=== FORWARD INFERENCE TEST ===')
|
| 10 |
+
inputs = {
|
| 11 |
+
'obs': np.random.randn(384).astype(np.float32),
|
| 12 |
+
'prev_action': 0,
|
| 13 |
+
'reset': True,
|
| 14 |
+
'frame': 0
|
| 15 |
+
}
|
| 16 |
+
result = agent.forward(inputs)
|
| 17 |
+
print(f'Result keys: {list(result.keys())}')
|
| 18 |
+
print(f'Action: {result.get("action")}')
|
| 19 |
+
print(f'Action probs: {result.get("action_probs")}')
|
| 20 |
+
print(f'Value: {result.get("value")}')
|
| 21 |
+
|
| 22 |
+
latent = result.get('latent')
|
| 23 |
+
if latent is not None:
|
| 24 |
+
print(f'Latent shape: {np.array(latent).shape}')
|
| 25 |
+
|
| 26 |
+
print('\n=== FORWARD_HOLD TEST ===')
|
| 27 |
+
try:
|
| 28 |
+
hold_result = agent.forward_hold(inputs)
|
| 29 |
+
print(f'Hold result keys: {list(hold_result.keys())}')
|
| 30 |
+
if 'hold_point' in hold_result:
|
| 31 |
+
hp = hold_result['hold_point']
|
| 32 |
+
print(f'Hold point type: {type(hp).__name__}')
|
| 33 |
+
if hasattr(hp, 'ai_choice'):
|
| 34 |
+
print(f'AI choice: {hp.ai_choice}')
|
| 35 |
+
if hasattr(hp, 'ai_confidence'):
|
| 36 |
+
print(f'AI confidence: {hp.ai_confidence}')
|
| 37 |
+
if hasattr(hp, 'merkle_root'):
|
| 38 |
+
print(f'Merkle root: {hp.merkle_root}')
|
| 39 |
+
except Exception as e:
|
| 40 |
+
print(f'Hold test error: {e}')
|
| 41 |
+
|
| 42 |
+
print('\n=== CASCADE IDENTITY ===')
|
| 43 |
+
try:
|
| 44 |
+
identity = agent.get_cascade_identity()
|
| 45 |
+
print(f'Identity: {identity}')
|
| 46 |
+
except Exception as e:
|
| 47 |
+
print(f'Identity error: {e}')
|
| 48 |
+
|
| 49 |
+
print('\n=== README (first 500 chars) ===')
|
| 50 |
+
readme = agent.get_readme()
|
| 51 |
+
print(readme[:500] if readme else 'No readme')
|
| 52 |
+
|
| 53 |
+
print('\n=== REPLICATE QUINE ===')
|
| 54 |
+
try:
|
| 55 |
+
new_quine = champ.replicate_quine()
|
| 56 |
+
print(f'Replicated: {new_quine}')
|
| 57 |
+
except Exception as e:
|
| 58 |
+
print(f'Replicate error: {e}')
|
| 59 |
+
|
| 60 |
+
print('\n=== VERIFY INTEGRITY ===')
|
| 61 |
+
try:
|
| 62 |
+
valid = champ.verify_quine_integrity()
|
| 63 |
+
print(f'Integrity valid: {valid}')
|
| 64 |
+
except Exception as e:
|
| 65 |
+
print(f'Verify error: {e}')
|
models/tests/test_module_level.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Quick module-level test without loading brain."""
|
| 2 |
+
import sys
|
| 3 |
+
sys.path.insert(0, 'F:/End-Game/glassboxgames/children')
|
| 4 |
+
import champion_gen1000 as champ
|
| 5 |
+
|
| 6 |
+
print('=== MODULE LEVEL (no brain load) ===')
|
| 7 |
+
print(f'Quine hash: {champ.get_quine_hash()}')
|
| 8 |
+
print(f'Verify integrity: {champ.verify_quine_integrity()}')
|
| 9 |
+
print(f'Action manifest: {champ.get_action_manifest()}')
|
| 10 |
+
|
| 11 |
+
# Get brain directly
|
| 12 |
+
print('\n=== GET QUINE BRAIN ===')
|
| 13 |
+
brain = champ.get_quine_brain()
|
| 14 |
+
print(f'Brain type: {type(brain).__name__}')
|
| 15 |
+
print(f'Brain methods: {[m for m in dir(brain) if not m.startswith("_")]}')
|
models/tests/verify_champion.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Verify champion export capabilities."""
|
| 2 |
+
import sys
|
| 3 |
+
sys.path.insert(0, 'f:/End-Game/key')
|
| 4 |
+
|
| 5 |
+
# Import the champion
|
| 6 |
+
import champion_gen1000 as champ
|
| 7 |
+
|
| 8 |
+
print('=== CHAMPION CAPABILITIES ===')
|
| 9 |
+
print(f'Quine Hash: {champ._QUINE_HASH}')
|
| 10 |
+
print(f'Generation: {champ._GENERATION}')
|
| 11 |
+
print(f'Fitness: {champ._FITNESS}')
|
| 12 |
+
|
| 13 |
+
# Try CapsuleAgent (the wrapper with exports)
|
| 14 |
+
print('\n=== CAPSULE AGENT ===')
|
| 15 |
+
agent = champ.CapsuleAgent()
|
| 16 |
+
print(f'Agent type: {type(agent).__name__}')
|
| 17 |
+
|
| 18 |
+
print('\n=== EXPORT CAPABILITIES ===')
|
| 19 |
+
has_pt = hasattr(agent, 'export_pt')
|
| 20 |
+
has_onnx = hasattr(agent, 'export_onnx')
|
| 21 |
+
has_capsule = hasattr(agent, 'export_capsule')
|
| 22 |
+
has_quine = hasattr(agent, 'get_quine_brain')
|
| 23 |
+
has_replicate = hasattr(agent, 'replicate_quine')
|
| 24 |
+
has_verify = hasattr(agent, 'verify_quine_integrity')
|
| 25 |
+
|
| 26 |
+
print(f'Has export_pt: {has_pt}')
|
| 27 |
+
print(f'Has export_onnx: {has_onnx}')
|
| 28 |
+
print(f'Has export_capsule: {has_capsule}')
|
| 29 |
+
print(f'Has get_quine_brain: {has_quine}')
|
| 30 |
+
print(f'Has replicate_quine: {has_replicate}')
|
| 31 |
+
print(f'Has verify_quine_integrity: {has_verify}')
|
| 32 |
+
|
| 33 |
+
# Try to list all methods
|
| 34 |
+
print('\n=== ALL PUBLIC METHODS ===')
|
| 35 |
+
methods = [m for m in dir(agent) if not m.startswith('_') and callable(getattr(agent, m, None))]
|
| 36 |
+
for m in methods:
|
| 37 |
+
print(f' - {m}')
|
| 38 |
+
|
| 39 |
+
# Also check module-level quine functions
|
| 40 |
+
print('\n=== MODULE-LEVEL QUINE FUNCTIONS ===')
|
| 41 |
+
print(f'get_quine_brain: {hasattr(champ, "get_quine_brain")}')
|
| 42 |
+
print(f'replicate_quine: {hasattr(champ, "replicate_quine")}')
|
| 43 |
+
print(f'verify_quine_integrity: {hasattr(champ, "verify_quine_integrity")}')
|
| 44 |
+
print(f'load_quine_brain: {hasattr(champ, "load_quine_brain")}')
|