144 lines
7.2 KiB
PHP
144 lines
7.2 KiB
PHP
<?php
|
|
// OPUS5 — Autonomy Honest v2 (doctrine 94)
|
|
// Score composite RÉEL intégrant 9 dimensions vs doctrine 90 qui était trop optimiste
|
|
// Lecture seule, complémente doctrine 90 (ne l'écrase pas)
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
$t0 = microtime(true);
|
|
$R = ['ts'=>date('c'), 'source'=>'opus5-autonomy-honest-v2', 'doctrine'=>94];
|
|
|
|
// === PG counts ===
|
|
try {
|
|
$db = new PDO('pgsql:host=10.1.0.3;port=5432;dbname=adx_system;user=admin;password=admin123', null, null, [PDO::ATTR_TIMEOUT=>5, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);
|
|
} catch (Throwable $e) { $db = null; }
|
|
|
|
function pg_count_safe($db, $sql) { if(!$db) return 0; try { return (int)$db->query($sql)->fetchColumn(); } catch(Throwable $e) { return 0; } }
|
|
|
|
// === 1. AGENT FACTORY FILL (Mass Agent Factory V80) ===
|
|
$wired_dir = '/var/www/html/api/wired-pending/';
|
|
$stubs_total = is_dir($wired_dir) ? count(glob($wired_dir.'intent-opus4-*.php')) : 0;
|
|
$stubs_executed = 0;
|
|
foreach (glob($wired_dir.'intent-opus4-*.php') as $f) {
|
|
$c = @file_get_contents($f);
|
|
if ($c && strpos($c, "'status' => 'EXECUTED'") !== false) $stubs_executed++;
|
|
}
|
|
$agents_total_truth = 906;
|
|
$factory_fill_pct = round(min(100, $stubs_executed / $agents_total_truth * 100), 1);
|
|
$stubs_exec_pct = $stubs_total > 0 ? round($stubs_executed / $stubs_total * 100, 1) : 0;
|
|
|
|
// === 2. SKILL COVERAGE ===
|
|
$skills_total_truth = 4247; // skills truth registry
|
|
$v76_scripts = count(glob('/var/www/html/api/v76-scripts/*.sh'));
|
|
$skill_coverage_pct = round(min(100, $v76_scripts / $skills_total_truth * 100), 2);
|
|
|
|
// === 3. INTENTS WIRED CORE ===
|
|
$core_intents = ['implement_plan','plan_list','plan_status','plan_from_text','autonomy_kpi','orphans_audit','orphans_hub','kpi_feeder','recall_decision'];
|
|
$core_wired = 0;
|
|
foreach ($core_intents as $i) if (file_exists($wired_dir."intent-opus4-$i.php")) $core_wired++;
|
|
$core_intents_pct = round($core_wired / count($core_intents) * 100, 1);
|
|
|
|
// === 4. PHASES LIVE ===
|
|
$phases = [
|
|
'P0' => file_exists('/var/www/html/api/opus5-predictive-cache.php'),
|
|
'P1' => file_exists('/var/www/html/api/opus5-plugin-store.php'),
|
|
'P2' => file_exists('/var/www/html/api/opus5-ssh-tmux-stream.php'),
|
|
'Phase1' => file_exists('/var/www/html/api/opus5-plan-registry.php'),
|
|
'Phase2' => file_exists('/var/www/html/api/opus5-plan-from-text.php'),
|
|
'KPI_90' => file_exists('/var/www/html/api/opus5-autonomy-kpi.php'),
|
|
'Orphans_91' => file_exists('/var/www/html/api/opus5-orphans-classifier.php'),
|
|
'Hub_92' => file_exists('/var/www/html/api/opus5-orphans-hub.php'),
|
|
'Feeder_93' => file_exists('/var/www/html/api/opus5-kpi-feeder.php')
|
|
];
|
|
$phases_live = array_sum(array_map(fn($v)=>$v?1:0, $phases));
|
|
$phases_pct = round($phases_live / count($phases) * 100, 1);
|
|
|
|
// === 5. V24 COMPLETION (last session Opus WIRE) ===
|
|
$v24_items = [
|
|
'decisions_table' => pg_count_safe($db, "SELECT COUNT(*) FROM admin.wevia_decisions") > 0,
|
|
'safe_write_helper' => file_exists('/var/www/html/api/opus5-safe-write.php'),
|
|
'v85_meta_refresh' => strpos(@file_get_contents('/var/www/html/weval-portal.html') ?: '', 'http-equiv="refresh"') !== false,
|
|
'v81_kpi_poc' => file_exists('/var/www/html/api/opus5-kpi-feed.php') || file_exists('/var/www/html/api/v76-scripts/kpi-feeder-ops.sh'),
|
|
'v84_cron_integrity' => file_exists('/opt/wevia-integrity/wtp-integrity-daily.sh')
|
|
];
|
|
$v24_done = array_sum(array_map(fn($v)=>$v?1:0, $v24_items));
|
|
$v24_pct = round($v24_done / count($v24_items) * 100, 1);
|
|
|
|
// === 6. PLANS PG ===
|
|
$plans_total = pg_count_safe($db, "SELECT COUNT(*) FROM admin.wevia_plans");
|
|
$plans_done = pg_count_safe($db, "SELECT COUNT(*) FROM admin.wevia_plans WHERE status='done'");
|
|
$plans_success_pct = $plans_total > 0 ? round($plans_done / $plans_total * 100, 1) : 0;
|
|
|
|
// === 7. DECISIONS MEMORY ===
|
|
$decisions_count = pg_count_safe($db, "SELECT COUNT(*) FROM admin.wevia_decisions");
|
|
$decisions_categories = pg_count_safe($db, "SELECT COUNT(DISTINCT category) FROM admin.wevia_decisions");
|
|
$decisions_score = min(100, $decisions_count * 10); // 10 decisions = 100%
|
|
|
|
// === 8. KPI FEEDER COMPLETENESS (v83) ===
|
|
$feeder_raw = @file_get_contents('http://127.0.0.1/api/opus5-kpi-feeder.php');
|
|
$feeder = @json_decode($feeder_raw, true) ?: [];
|
|
$feeder_pct = $feeder['summary']['completeness_vs_v83']['post_feed_completeness_pct'] ?? 0;
|
|
|
|
// === 9. ORPHANS INTEGRATION ===
|
|
$hub_raw = @file_get_contents('http://127.0.0.1/api/opus5-orphans-hub.php');
|
|
$hub = @json_decode($hub_raw, true) ?: [];
|
|
$active_orphans = $hub['stats']['active_to_link'] ?? 21;
|
|
$orphans_integration_pct = max(0, 100 - ($active_orphans * 2)); // 50 actifs = 0%
|
|
|
|
// === COMPOSITE SCORE ===
|
|
$dimensions = [
|
|
'factory_fill' => ['pct' => $factory_fill_pct, 'weight' => 15, 'detail' => "$stubs_executed/$agents_total_truth agents wired+executed"],
|
|
'skill_coverage' => ['pct' => $skill_coverage_pct, 'weight' => 10, 'detail' => "$v76_scripts/$skills_total_truth skills scripted"],
|
|
'core_intents' => ['pct' => $core_intents_pct, 'weight' => 10, 'detail' => "$core_wired/".count($core_intents)." autonomy intents"],
|
|
'phases_live' => ['pct' => $phases_pct, 'weight' => 15, 'detail' => "$phases_live/".count($phases)." phases Opus5"],
|
|
'v24_completion' => ['pct' => $v24_pct, 'weight' => 15, 'detail' => "$v24_done/".count($v24_items)." V24 items"],
|
|
'plans_success' => ['pct' => $plans_success_pct, 'weight' => 10, 'detail' => "$plans_done/$plans_total plans done"],
|
|
'decisions_memory' => ['pct' => $decisions_score, 'weight' => 5, 'detail' => "$decisions_count decisions in $decisions_categories categories"],
|
|
'kpi_completeness' => ['pct' => $feeder_pct, 'weight' => 10, 'detail' => "v83 feeder post-fill"],
|
|
'orphans_integration' => ['pct' => $orphans_integration_pct, 'weight' => 10, 'detail' => "$active_orphans still to link"]
|
|
];
|
|
|
|
$total_weighted = 0;
|
|
$total_weight = 0;
|
|
foreach ($dimensions as $name => $d) {
|
|
$total_weighted += $d['pct'] * $d['weight'];
|
|
$total_weight += $d['weight'];
|
|
}
|
|
$composite_pct = round($total_weighted / $total_weight, 1);
|
|
|
|
// === Grade honnête ===
|
|
$grade = 'D INCOMPLETE';
|
|
if ($composite_pct >= 90) $grade = 'A+ GODMODE REAL';
|
|
else if ($composite_pct >= 75) $grade = 'A SOLID';
|
|
else if ($composite_pct >= 60) $grade = 'B ACCEPTABLE';
|
|
else if ($composite_pct >= 45) $grade = 'C PROGRESS';
|
|
else if ($composite_pct >= 30) $grade = 'D EARLY';
|
|
|
|
// === Gap analysis ===
|
|
$gaps_sorted = $dimensions;
|
|
uasort($gaps_sorted, fn($a,$b) => $a['pct'] <=> $b['pct']);
|
|
$top_3_gaps = array_slice($gaps_sorted, 0, 3, true);
|
|
$gap_recommendations = [];
|
|
foreach ($top_3_gaps as $name => $d) {
|
|
if ($d['pct'] < 50) {
|
|
$gap_recommendations[] = "PRIORITY: $name at {$d['pct']}% — {$d['detail']}";
|
|
}
|
|
}
|
|
|
|
$R['dimensions'] = $dimensions;
|
|
$R['composite'] = [
|
|
'autonomy_honest_pct' => $composite_pct,
|
|
'grade' => $grade,
|
|
'vs_doctrine_90' => '100% (doctrine 90 was too optimistic — measured only 4 dims)',
|
|
'improvement_from_audit' => '~32% initial → '.$composite_pct.'% post-V24',
|
|
'gain_points' => round($composite_pct - 32, 1)
|
|
];
|
|
$R['top_gaps'] = $gap_recommendations;
|
|
$R['comparison'] = [
|
|
'doctrine_90_optimistic' => 100,
|
|
'doctrine_94_honest' => $composite_pct,
|
|
'gap' => round(100 - $composite_pct, 1)
|
|
];
|
|
$R['total_ms'] = round((microtime(true) - $t0) * 1000);
|
|
|
|
echo json_encode($R, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|