fix: Add NODE2 agent count check to prevent data loss
- Check for at least 45 NODE2 agents (out of 50 expected) - This prevents false positives when only core agents exist - Better detection of actual data loss
This commit is contained in:
@@ -31,13 +31,20 @@ if ! docker exec daarion-postgres psql -U postgres -lqt | cut -d \| -f 1 | grep
|
||||
fi
|
||||
|
||||
# Check data integrity
|
||||
MICRODAO_COUNT=$(docker exec daarion-postgres psql -U postgres -d daarion -t -c "SELECT COUNT(*) FROM microdaos;" 2>/dev/null | tr -d ' ' || echo "0")
|
||||
AGENT_COUNT=$(docker exec daarion-postgres psql -U postgres -d daarion -t -c "SELECT COUNT(*) FROM agents;" 2>/dev/null | tr -d ' ' || echo "0")
|
||||
MICRODAO_COUNT=$(docker exec daarion-postgres psql -U postgres -d daarion -t -c "SELECT COUNT(*) FROM microdaos;" 2>/dev/null | tr -d ' \n' || echo "0")
|
||||
AGENT_COUNT=$(docker exec daarion-postgres psql -U postgres -d daarion -t -c "SELECT COUNT(*) FROM agents;" 2>/dev/null | tr -d ' \n' || echo "0")
|
||||
NODE2_AGENT_COUNT=$(docker exec daarion-postgres psql -U postgres -d daarion -t -c "SELECT COUNT(*) FROM agents WHERE node_id = 'node-2-macbook-m4max';" 2>/dev/null | tr -d ' \n' || echo "0")
|
||||
|
||||
log "📊 Data check: MicroDAOs=$MICRODAO_COUNT, Agents=$AGENT_COUNT"
|
||||
# Ensure we have valid integers
|
||||
MICRODAO_COUNT=${MICRODAO_COUNT:-0}
|
||||
AGENT_COUNT=${AGENT_COUNT:-0}
|
||||
NODE2_AGENT_COUNT=${NODE2_AGENT_COUNT:-0}
|
||||
|
||||
log "📊 Data check: MicroDAOs=$MICRODAO_COUNT, Agents=$AGENT_COUNT, NODE2=$NODE2_AGENT_COUNT"
|
||||
|
||||
# If data is missing, try to restore
|
||||
if [ "$MICRODAO_COUNT" -lt 5 ] || [ "$AGENT_COUNT" -lt 10 ]; then
|
||||
# Need at least 5 MicroDAOs, 50 total agents, and 45+ NODE2 agents
|
||||
if [ "$MICRODAO_COUNT" -lt 5 ] || [ "$AGENT_COUNT" -lt 50 ] || [ "$NODE2_AGENT_COUNT" -lt 45 ]; then
|
||||
log "⚠️ Data loss detected! Attempting recovery..."
|
||||
|
||||
# Check for recent backup
|
||||
|
||||
Reference in New Issue
Block a user