#!/bin/bash

# Clear any messy terminal trails and initialize parameters
clear
TARGET_DIR="/Users/bpa/ForesixaQuant"
cd "$TARGET_DIR" || exit 1

show_menu() {
    echo "============================================================"
    echo "     QZOTIC CONSIGLIERE CENTRAL HUB: MASTER EXECUTIVE DESK"
    echo "============================================================"
    echo " Host Timeline Clock: $(date '+%A, %B %d, %Y')"
    echo " Project Repository : $TARGET_DIR"
    echo "------------------------------------------------------------"
    echo " [1] RUN AUTHENTICATION LIFECYCLE AUDIT (Verify Live Handshake)"
    echo " [2] EXECUTE ENTERPRISE DIR SYNC & TRIAGE LOOP (Proactive Solver)"
    echo " [3] VIEW FLIGHT ACCELERATION SCOREBOARD (Active Multi-Project Status)"
    echo " [4] PROCESS CONVERSATIONAL ROOM AUDIT (Behavioral Tactical Scan)"
    echo " [5] TRIGGER SECURE DATABASE SNAPSHOTS (Manual Relational Backup)"
    echo " [6] SYSTEM COMPLIANCE EXIT"
    echo "------------------------------------------------------------"
    echo -n " ENTER SELECTION REGISTRY SECTOR (1-6): "
}

while true; do
    show_menu
    read -r choice
    echo "------------------------------------------------------------"
    
    case $choice in
        1)
            echo "[INFO] Launching Foresixa Verification Core..."
            if [ -f "verify_live_feeds.py" ]; then
                python3 verify_live_feeds.py --config worker_config.json --credentials-file credentials.env
            else
                echo "[ERROR] verify_live_feeds.py not located in core folder."
            fi
            ;;
        2)
            echo "[INFO] Initializing Ingress Scan & Proactive Problem Solver..."
            if [ -f "consigliere_supervisor.py" ]; then
                python3 consigliere_supervisor.py
            else
                echo "[ERROR] consigliere_supervisor.py not located in core folder."
            fi
            ;;
        3)
            echo "[INFO] Compiling Unified Multi-Project Relational Scoreboard..."
            sqlite3 qzotic_pure_sandbox.db "SELECT '   • Project: ' || project_name || ' | Vertical: ' || industry_vertical || ' | Retention: ' || lifecycle_state || ' | Target: ' || supervisor_deadline FROM enterprise_portfolio;"
            ;;
        4)
            echo "[INFO] Processing Contextual Linguistic Room Audit..."
            if [ -f "interaction_auditor.py" ]; then
                python3 interaction_auditor.py
            else
                echo "[ERROR] interaction_auditor.py not located in core folder."
            fi
            ;;
        5)
            echo "[INFO] Executing Safe Online Backup Handshake..."
            if [ -f "generated/secure_backup_vault.py" ]; then
                python3 generated/secure_backup_vault.py
            else
                echo "[ERROR] secure_backup_vault.py not located inside generated/ directory."
            fi
            ;;
        6)
            echo "[INFO] Exiting Consigliere Hub. Data parameters remain secured."
            echo "============================================================"
            exit 0
            ;;
        *)
            echo "[WARNING] Invalid selection row index. Choose a target sector from 1 to 6."
            ;;
    esac
    echo "------------------------------------------------------------"
    echo -n "Press [ENTER] to return to the Master Executive Desk..."
    read -r
    clear
done
