<?php

define(
'BASE_PATH',
realpath(__DIR__.'/../..')
);

require_once BASE_PATH.'/config/autoload.php';
require_once BASE_PATH.'/config/bootstrap.php';

$db=\App\Core\Database::getInstance();

echo "AUTONOMOUS REVIEW ORCHESTRATION\n";

$db->exec(
"TRUNCATE TABLE autonomous_review_orchestration"
);

$decisions=
$db->query("
SELECT *
FROM ai_decision_board
")->fetchAll(PDO::FETCH_ASSOC);

foreach($decisions as $d){

    $action='';

    $priority='Medium';

    $confidence=70;

    if(
        $d['decision_type']
        ==
        'reviewer_failure_risk'
    ){

        $action=
        'Recommend reviewer substitution and immediate reminder';

        $priority='Critical';

        $confidence=95;
    }

    if(
        $d['decision_type']
        ==
        'conference_health_decline'
    ){

        $action=
        'Recommend reviewer expansion campaign';

        $priority='High';

        $confidence=85;
    }

    $db->prepare("
    INSERT INTO
    autonomous_review_orchestration
    (
        conference_id,
        action_type,
        priority_level,
        action_text,
        confidence_score
    )
    VALUES
    (
        ?,?,?,?,?
    )
    ")->execute([
        $d['conference_id'],
        $d['decision_type'],
        $priority,
        $action,
        $confidence
    ]);

}

echo "DONE\n";
