File size: 4,267 Bytes
29788be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# dual-runtime-start.sh β€” Orchestrate the full sovereign dual runtime
# Layer 1: WASM agent sandbox (browser/iPython)
# Layer 2: 6502 sovereign VM (control plane)
# Layer 3: M5 compatibility bridge (API layer)
# All connected through ORTHO-32-T doorbell mechanism

set -e

echo "╔══════════════════════════════════════════════════════════╗"
echo "β•‘  SOVEREIGN DUAL RUNTIME                                  β•‘"
echo "β•‘  6502 VM Β· M5 Bridge Β· WASM Sandbox Β· WORM Chain        β•‘"
echo "β•‘  ΞΈ = 89/2462 Β· Bel Esprit D'Accord Irrevocable Trust   β•‘"
echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•"

# Create required directories
mkdir -p /sovereign/{worm,doorbell,data,qemu/images}

# Seal genesis block
GENESIS_HASH=$(echo "genesis:$(date -u +%s)" | sha256sum | cut -c1-16)
echo "{\"hash\":\"${GENESIS_HASH}\",\"prev\":\"0000000000000000\",\"agent\":\"system\",\"event\":\"dual_runtime_start\"}" \
    >> /sovereign/worm/chain.jsonl
echo "[boot] WORM genesis sealed: ${GENESIS_HASH}"

# ── Start 6502 VM (background) ────────────────────────────
if [ -f /sovereign/vm6502/target/release/sovereign-vm6502 ]; then
    echo "[boot] Starting 6502 sovereign VM..."
    /sovereign/vm6502/target/release/sovereign-vm6502 &
    VM6502_PID=$!
    echo "[boot] 6502 VM PID: ${VM6502_PID}"
else
    echo "[boot] 6502 VM not compiled β€” running heartbeat stub..."
    (
        phases=("T0 RESET" "T1 NAND" "T2 SASS" "T3 IR" "T4 MMA" "T5 MMA" "T6 MMA" "T7 MMA" "T8 ROOF" "T9 WORM" "T10 SOVEREIGN_ACTIVE")
        i=0
        while true; do
            echo "[6502] ${phases[$((i % 11))]}"
            i=$((i+1))
            sleep 1.2
        done
    ) &
fi

# ── Start M5 bridge (background) ─────────────────────────
if [ -f /sovereign/m5-bridge/target/release/sovereign-m5-bridge ]; then
    echo "[boot] Starting M5 compatibility bridge..."
    /sovereign/m5-bridge/target/release/sovereign-m5-bridge &
    M5_PID=$!
    echo "[boot] M5 bridge PID: ${M5_PID}"
else
    echo "[boot] M5 bridge not compiled β€” running Python stub..."
    python3 -c "
import http.server, json, threading

class Handler(http.server.BaseHTTPRequestHandler):
    def log_message(self, *a): pass
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-Type','application/json')
        self.send_header('Access-Control-Allow-Origin','*')
        self.end_headers()
        self.wfile.write(json.dumps({'m5':'Running','docker':'Containerized','vm6502':'SOVEREIGN_ACTIVE'}).encode())

server = http.server.HTTPServer(('0.0.0.0', 9091), Handler)
print('[M5] Python stub on :9091')
server.serve_forever()
" &
fi

# ── Start WASM sandbox web server ────────────────────────
echo "[boot] Starting WASM agent sandbox on :8788..."
python3 -m http.server 8788 --directory /sovereign/wasm &
WASM_PID=$!

echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "β•‘  SOVEREIGN DUAL RUNTIME β€” ALL SYSTEMS GO                β•‘"
echo "β•‘                                                          β•‘"
echo "β•‘  WASM Sandbox:   http://localhost:8788/agent-sandbox.htmlβ•‘"
echo "β•‘  M5 Bridge API:  http://localhost:9091/api/runtime-statusβ•‘"
echo "β•‘  6502 Telemetry: http://localhost:9090 (if compiled)     β•‘"
echo "β•‘  WORM Chain:     /sovereign/worm/chain.jsonl             β•‘"
echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•"

# Tail WORM chain to stdout
echo ""
echo "[worm] Tailing WORM chain..."
tail -f /sovereign/worm/chain.jsonl 2>/dev/null | while read line; do
    echo "[worm] $line"
done &

# Keep container alive
wait