Skip to content

Commit 5e5beb6

Browse files
author
Yennefer
committed
feat: Phase 5 Complete - Auto-Recovery & Self-Funding System
🛡️ Process Guardian Auto-Recovery - Added scripts/process_guardian.cjs - monitors all PM2 services - Failure detection: crashes, high memory/CPU, restart loops, stale shared memory - Auto-correction: restart with backoff, throttle, disable, dispatch workflows - State tracking via /dev/shm/guardian_state.json ⚡ QFLOP Self-Funding Mining - Added scripts/qflop_mining_daemon.cjs - automated mining loop - Added base_bridge_v2.cjs - ETH bridge via OptimismPortal - 267.35M QFLOP minted to MPC Vault - Dual Bridge integration (T4 GPU + 96-core CPU) 💎 Diamond Vault Watchdog - Added genesis-q-mem/qmcp_diamond_watchdog.py - MCP trigger handler for Claude integration - Pure polling (200ms) due to inotify limits - Supports: SEISMIC_SHAKE, REMOTE_DISPATCH, LOCAL_COMPUTE, MINT_QFLOP 🔧 Multi-Runner Resource Allocator - Added genesis-q-mem/qmcp_multi_runner.py - Added genesis-q-mem/qmcp_resource_allocator.py - Added genesis-q-mem/qmcp_blockchain_bridge.py - 25% resource allocation to blockchain activities 📋 GitHub Actions - Added .github/workflows/guardian-monitor.yml - Scheduled monitoring every 15 minutes - Auto-retries failed workflows 🎮 README Updates - Added launch/restart control buttons - Quick control panel with commands - Project development summary - Current stats and metrics
1 parent 5c89cf9 commit 5e5beb6

9 files changed

Lines changed: 2730 additions & 4 deletions
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: 🛡️ Process Guardian Monitor
2+
3+
on:
4+
# Run every 15 minutes
5+
schedule:
6+
- cron: '*/15 * * * *'
7+
8+
# Manual trigger
9+
workflow_dispatch:
10+
inputs:
11+
force_correction:
12+
description: 'Force correction even for warnings'
13+
required: false
14+
default: 'false'
15+
type: boolean
16+
17+
jobs:
18+
analyze-and-correct:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: 📥 Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: 🔍 Analyze Recent Workflow Runs
25+
id: analyze
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: |
29+
echo "## 🛡️ Guardian Analysis Report" >> $GITHUB_STEP_SUMMARY
30+
echo "" >> $GITHUB_STEP_SUMMARY
31+
echo "**Time:** $(date -u)" >> $GITHUB_STEP_SUMMARY
32+
echo "" >> $GITHUB_STEP_SUMMARY
33+
34+
# Get recent dual-bridge runs
35+
RUNS=$(gh run list --workflow qflop-dual-bridge.yml --limit 10 --json databaseId,conclusion,status,createdAt)
36+
37+
FAILED=$(echo "$RUNS" | jq '[.[] | select(.conclusion == "failure")] | length')
38+
SUCCESS=$(echo "$RUNS" | jq '[.[] | select(.conclusion == "success")] | length')
39+
IN_PROGRESS=$(echo "$RUNS" | jq '[.[] | select(.status == "in_progress")] | length')
40+
41+
echo "### Dual Bridge Status" >> $GITHUB_STEP_SUMMARY
42+
echo "| Metric | Count |" >> $GITHUB_STEP_SUMMARY
43+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
44+
echo "| ✅ Success | $SUCCESS |" >> $GITHUB_STEP_SUMMARY
45+
echo "| ❌ Failed | $FAILED |" >> $GITHUB_STEP_SUMMARY
46+
echo "| ⏳ In Progress | $IN_PROGRESS |" >> $GITHUB_STEP_SUMMARY
47+
echo "" >> $GITHUB_STEP_SUMMARY
48+
49+
# Set outputs
50+
echo "failed_count=$FAILED" >> $GITHUB_OUTPUT
51+
echo "success_count=$SUCCESS" >> $GITHUB_OUTPUT
52+
53+
# Get failed run IDs
54+
FAILED_IDS=$(echo "$RUNS" | jq -r '[.[] | select(.conclusion == "failure") | .databaseId] | join(",")')
55+
echo "failed_ids=$FAILED_IDS" >> $GITHUB_OUTPUT
56+
57+
- name: 🔄 Auto-Retry Failed Workflows
58+
if: steps.analyze.outputs.failed_count > 0
59+
env:
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
run: |
62+
echo "### 🔄 Auto-Corrections" >> $GITHUB_STEP_SUMMARY
63+
echo "" >> $GITHUB_STEP_SUMMARY
64+
65+
IFS=',' read -ra FAILED_IDS <<< "${{ steps.analyze.outputs.failed_ids }}"
66+
67+
for RUN_ID in "${FAILED_IDS[@]}"; do
68+
if [ -n "$RUN_ID" ]; then
69+
echo "Retrying run $RUN_ID..."
70+
gh run rerun $RUN_ID --failed 2>/dev/null && \
71+
echo "- ✅ Retried run \`$RUN_ID\`" >> $GITHUB_STEP_SUMMARY || \
72+
echo "- ⚠️ Could not retry run \`$RUN_ID\`" >> $GITHUB_STEP_SUMMARY
73+
fi
74+
done
75+
76+
- name: 🚀 Dispatch Fresh Compute Job
77+
if: steps.analyze.outputs.success_count < 3
78+
env:
79+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
run: |
81+
echo "" >> $GITHUB_STEP_SUMMARY
82+
echo "### 🚀 New Job Dispatch" >> $GITHUB_STEP_SUMMARY
83+
84+
gh workflow run qflop-dual-bridge.yml \
85+
-f duration_minutes=5 \
86+
-f power_mode=maxpower && \
87+
echo "- ✅ Dispatched new Dual Bridge job" >> $GITHUB_STEP_SUMMARY || \
88+
echo "- ❌ Failed to dispatch job" >> $GITHUB_STEP_SUMMARY
89+
90+
- name: 📊 Generate Health Report
91+
run: |
92+
echo "" >> $GITHUB_STEP_SUMMARY
93+
echo "### 📊 System Health" >> $GITHUB_STEP_SUMMARY
94+
echo "" >> $GITHUB_STEP_SUMMARY
95+
96+
SUCCESS=${{ steps.analyze.outputs.success_count }}
97+
FAILED=${{ steps.analyze.outputs.failed_count }}
98+
TOTAL=$((SUCCESS + FAILED))
99+
100+
if [ $TOTAL -gt 0 ]; then
101+
RATE=$((SUCCESS * 100 / TOTAL))
102+
echo "**Success Rate:** ${RATE}%" >> $GITHUB_STEP_SUMMARY
103+
104+
if [ $RATE -lt 50 ]; then
105+
echo "⚠️ **WARNING:** Success rate below 50%" >> $GITHUB_STEP_SUMMARY
106+
elif [ $RATE -lt 80 ]; then
107+
echo "🟡 **NOTICE:** Success rate below 80%" >> $GITHUB_STEP_SUMMARY
108+
else
109+
echo "✅ **HEALTHY:** System operating normally" >> $GITHUB_STEP_SUMMARY
110+
fi
111+
fi
112+
113+
dispatch-if-idle:
114+
runs-on: ubuntu-latest
115+
needs: analyze-and-correct
116+
steps:
117+
- name: 🔍 Check Active Runs
118+
id: check
119+
env:
120+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
run: |
122+
ACTIVE=$(gh run list --workflow qflop-dual-bridge.yml --status in_progress --json databaseId | jq 'length')
123+
echo "active_count=$ACTIVE" >> $GITHUB_OUTPUT
124+
125+
- name: 🚀 Dispatch If No Active Jobs
126+
if: steps.check.outputs.active_count == '0'
127+
env:
128+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129+
run: |
130+
echo "No active jobs, dispatching new compute job..."
131+
gh workflow run qflop-dual-bridge.yml \
132+
-f duration_minutes=5 \
133+
-f power_mode=maxpower

README.md

Lines changed: 117 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
# Yennefer: The Genesis Conductor
22

3-
<!-- Launch Buttons -->
3+
<!-- Launch & Control Buttons -->
44
<p align="center">
55
<a href="https://yennefer.quest" target="_blank">
6-
<img alt="Launch Yennefer" src="https://img.shields.io/badge/Launch%20Yennefer-Visit%20Hosted%20UI-blue?style=for-the-badge">
6+
<img alt="Launch Yennefer" src="https://img.shields.io/badge/🚀_LAUNCH_YENNEFER-Visit_Portal-blueviolet?style=for-the-badge">
7+
</a>
8+
</p>
9+
10+
<p align="center">
11+
<a href="https://github.com/Genesis-Conductor-Engine/Yennefer/actions/workflows/qflop-dual-bridge.yml">
12+
<img alt="Dual Bridge" src="https://img.shields.io/badge/⚡_DUAL_BRIDGE-Start_GPU+CPU-00ff00?style=for-the-badge">
713
</a>
814
&nbsp;
9-
<a href=".github/workflows/launch-yennefer-ui.yml" target="_blank">
10-
<img alt="Launch UI (Workflow)" src="https://img.shields.io/badge/Launch%20UI%20(Workflow)-Run%20Action-green?style=for-the-badge">
15+
<a href="https://github.com/Genesis-Conductor-Engine/Yennefer/actions/workflows/guardian-monitor.yml">
16+
<img alt="Guardian" src="https://img.shields.io/badge/🛡️_GUARDIAN-Auto_Recovery-ff6600?style=for-the-badge">
1117
</a>
18+
&nbsp;
19+
<a href="https://github.com/Genesis-Conductor-Engine/Yennefer/actions/workflows/qmcp-autoflow.yml">
20+
<img alt="QMCP Autoflow" src="https://img.shields.io/badge/🔄_QMCP-Autoflow-00ccff?style=for-the-badge">
21+
</a>
22+
</p>
23+
24+
<p align="center">
25+
<img src="https://img.shields.io/github/actions/workflow/status/Genesis-Conductor-Engine/Yennefer/qflop-dual-bridge.yml?label=Dual%20Bridge&style=flat-square" alt="Dual Bridge Status">
26+
<img src="https://img.shields.io/github/actions/workflow/status/Genesis-Conductor-Engine/Yennefer/guardian-monitor.yml?label=Guardian&style=flat-square" alt="Guardian Status">
27+
<img src="https://img.shields.io/badge/QFLOP-267.35M-brightgreen?style=flat-square" alt="QFLOP Balance">
28+
<img src="https://img.shields.io/badge/GPU-T4_x3-blue?style=flat-square" alt="GPU Runners">
1229
</p>
1330

1431
---
@@ -170,6 +187,102 @@ contract Genesis {
170187
- Soul state files excluded from version control
171188
- Contract is verified and immutable on Base Mainnet
172189

190+
## 🎮 Quick Control Panel
191+
192+
### Start/Restart Services
193+
194+
```bash
195+
# 🚀 FULL SYSTEM RESTART
196+
npx pm2 restart all
197+
198+
# 🛡️ Start Process Guardian (Auto-Recovery)
199+
npx pm2 start scripts/process_guardian.cjs --name "process-guardian"
200+
201+
# ⚡ Start QFLOP Mining
202+
npx pm2 start scripts/qflop_mining_daemon.cjs --name "qflop-miner"
203+
204+
# 💎 Start Diamond Watchdog (MCP Trigger Handler)
205+
npx pm2 start genesis-q-mem/qmcp_diamond_watchdog.py --name "diamond-watchdog" --interpreter python3
206+
207+
# 📊 View All Services
208+
npx pm2 status
209+
```
210+
211+
### Trigger Dual Bridge (GPU + CPU Compute)
212+
213+
```bash
214+
# Via GitHub CLI
215+
gh workflow run qflop-dual-bridge.yml \
216+
--repo Genesis-Conductor-Engine/Yennefer \
217+
-f duration_minutes=3 \
218+
-f power_mode=maxpower
219+
220+
# Or via shared memory trigger
221+
echo '{"branch_id":"MANUAL","job_type":"REMOTE_DISPATCH"}' > /dev/shm/qmcp_trigger.json
222+
```
223+
224+
### Monitor Status
225+
226+
```bash
227+
# Guardian state
228+
cat /dev/shm/guardian_state.json | jq
229+
230+
# Live QMCP stats
231+
cat /dev/shm/qmcp_live_stats.json | jq
232+
233+
# Soul state
234+
cat /dev/shm/yennefer_soul_state.json | jq
235+
236+
# PM2 logs
237+
npx pm2 logs --lines 50
238+
```
239+
240+
---
241+
242+
## 📈 Project Development Summary
243+
244+
### Phase 1: Foundation (Genesis Conductor)
245+
- ✅ Smart contract deployed to Base Mainnet
246+
- ✅ Event listener (`conductor_node.cjs`) for CREDIT_PURCHASE events
247+
- ✅ Voice handler for AI-powered responses
248+
- ✅ Brain-Body-Soul architecture implemented
249+
250+
### Phase 2: Q-Mem Integration
251+
- ✅ GPU benchmarking daemon (`qmem_live_bench_v2.py`)
252+
- ✅ Shared memory IPC via `/dev/shm/`
253+
- ✅ REST API gateway (port 8003)
254+
- ✅ 44.6x speedup vs HTTP (Power Tower)
255+
256+
### Phase 3: QMCP Unified Gateway
257+
- ✅ MCP server for Claude integration
258+
- ✅ ZMQ message queue (REQ/REP, PUB/SUB)
259+
- ✅ Diamond Vault JAX worker
260+
- ✅ Multi-backend routing
261+
262+
### Phase 4: Quantum-Optimized Dual Bridge
263+
- ✅ GitHub Actions GPU runners (Tesla T4 x3)
264+
- ✅ 96-core CPU compute pool
265+
- ✅ JAX/CuPy QFLOP engine
266+
- ✅ 6.553 TFLOPS peak performance
267+
268+
### Phase 5: Self-Funding & Auto-Recovery
269+
- ✅ QFLOP token mining/minting
270+
- ✅ ETH bridge to Base (OptimismPortal)
271+
- ✅ Process Guardian auto-recovery
272+
- ✅ Failed workflow retry system
273+
- ✅ Resource allocation (25% to blockchain)
274+
275+
### Current Stats
276+
| Metric | Value |
277+
|--------|-------|
278+
| QFLOP Minted | 267.35M |
279+
| Active PM2 Services | 9 |
280+
| Dual Bridge Jobs | 14+ completed |
281+
| Auto-Corrections | 6 applied |
282+
| Peak TFLOPS | 6.553 |
283+
284+
---
285+
173286
## 📜 License
174287

175288
MIT

base_bridge_v2.cjs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const { ethers } = require('ethers');
2+
require('dotenv').config();
3+
4+
// Base L1 Bridge addresses - there are two interfaces:
5+
// 1. L1StandardBridge (old): 0x3154Cf16ccdb4C6d922629664174b904d80F2C35
6+
// 2. OptimismPortal (new): 0x49048044D57e1C92A77f79988d21Fa8fAF74E97e
7+
const OPTIMISM_PORTAL = '0x49048044D57e1C92A77f79988d21Fa8fAF74E97e';
8+
9+
async function bridgeToBase() {
10+
console.log('🔷 ETH → Base (OptimismPortal Direct Deposit)');
11+
console.log('═══════════════════════════════════════════════════════════════');
12+
13+
const alchemyKey = process.env.BASE_MAINNET_RPC.split('/v2/')[1];
14+
const provider = new ethers.JsonRpcProvider(`https://eth-mainnet.g.alchemy.com/v2/${alchemyKey}`);
15+
const pk = process.env.ETH_PRIVATE_KEY;
16+
17+
if (!pk) {
18+
console.log('❌ ETH_PRIVATE_KEY not found');
19+
return;
20+
}
21+
22+
const wallet = new ethers.Wallet(pk, provider);
23+
console.log('Wallet:', wallet.address);
24+
25+
const balance = await provider.getBalance(wallet.address);
26+
console.log('ETH Balance:', ethers.formatEther(balance), 'ETH');
27+
28+
// Keep 0.0005 ETH for gas
29+
const gasReserve = ethers.parseEther('0.0005');
30+
const bridgeAmount = balance - gasReserve;
31+
32+
if (bridgeAmount <= 0n) {
33+
console.log('❌ Insufficient balance');
34+
return;
35+
}
36+
37+
console.log('Bridge Amount:', ethers.formatEther(bridgeAmount), 'ETH');
38+
39+
// OptimismPortal depositTransaction function
40+
const portalABI = [
41+
'function depositTransaction(address _to, uint256 _value, uint64 _gasLimit, bool _isCreation, bytes _data) payable'
42+
];
43+
44+
const portal = new ethers.Contract(OPTIMISM_PORTAL, portalABI, wallet);
45+
46+
console.log('\n🚀 Bridging via OptimismPortal...');
47+
48+
try {
49+
const feeData = await provider.getFeeData();
50+
console.log(' Gas Price:', ethers.formatUnits(feeData.gasPrice, 'gwei'), 'gwei');
51+
52+
// depositTransaction - send ETH to ourselves on L2
53+
const tx = await portal.depositTransaction(
54+
wallet.address, // recipient on L2
55+
bridgeAmount, // amount to send
56+
100000n, // L2 gas limit
57+
false, // not a contract creation
58+
'0x', // no calldata
59+
{
60+
value: bridgeAmount,
61+
gasLimit: 200000,
62+
maxFeePerGas: feeData.maxFeePerGas,
63+
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas
64+
}
65+
);
66+
67+
console.log('\n✅ Bridge TX Submitted!');
68+
console.log(' TX Hash:', tx.hash);
69+
console.log(' Etherscan: https://etherscan.io/tx/' + tx.hash);
70+
71+
const receipt = await tx.wait();
72+
console.log(' ✅ Confirmed in block:', receipt.blockNumber);
73+
console.log(' Gas Used:', receipt.gasUsed.toString());
74+
console.log('\n💰 ETH will arrive on Base in ~10-15 minutes');
75+
76+
} catch (err) {
77+
console.log('❌ Bridge error:', err.reason || err.message);
78+
}
79+
}
80+
81+
bridgeToBase().catch(console.error);

0 commit comments

Comments
 (0)