83 lines
4.0 KiB
PHP
83 lines
4.0 KiB
PHP
<?php
|
|
/**
|
|
* WEVIA SELF-DIAGNOSTIC · Opus 20avr · Doctrine #2 ZERO simulation
|
|
*
|
|
* Triggers: "self diag", "self-diagnostic", "diagnostique toi", "lis toi",
|
|
* "ta propre doctrine", "affiche parser intents", "root cause dysfonctionnement"
|
|
*
|
|
* Exécute RÉELLEMENT:
|
|
* - Liste fichiers vault
|
|
* - Compte intents registrés (grep preg_match dans wevia-*-intents.php)
|
|
* - Liste 10 derniers événements log chat
|
|
* - Trace why un prompt donné ne matche (si fourni)
|
|
*/
|
|
|
|
if (!function_exists('wevia_self_diagnostic')) {
|
|
function wevia_self_diagnostic($msg) {
|
|
if (!$msg) return false;
|
|
if (!preg_match('/\b(self[\s-]?diag|diagnostique[\s-]?toi|lis[\s-]?toi|self[\s-]?knowledge|affiche\s+parser|root\s+cause\s+dysfonction|reporte.*root\s+cause|ta\s+propre\s+doctrine|ton\s+propre\s+code|ton\s+propre\s+vault|state\s+of\s+platform|etat\s+plateforme|etat\s+de\s+la\s+plateforme|platform\s+health|plateforme\s+sante|etat\s+systeme\s+complet)\b/iu', $msg)) return false;
|
|
|
|
$out = ['provider' => 'opus46', 'tool' => 'self_diagnostic', 'doctrine' => '#2 ZERO simulation · executed real shell'];
|
|
|
|
// 1. Vault content (real)
|
|
$vault = trim(@shell_exec('ls /opt/wevads/vault/ 2>/dev/null | head -20'));
|
|
$vault_count = (int)trim(@shell_exec('ls /opt/wevads/vault/ 2>/dev/null | wc -l'));
|
|
$out['vault'] = [
|
|
'path' => '/opt/wevads/vault/',
|
|
'file_count' => $vault_count,
|
|
'sample_files' => array_slice(explode("\n", $vault), 0, 10)
|
|
];
|
|
|
|
// 2. Intents registry (real count via preg_match occurrences)
|
|
$files = ['wevia-opus46-intents.php', 'wevia-opus-intents.php', 'wevia-fast-path-v3.php'];
|
|
$intents = [];
|
|
foreach ($files as $f) {
|
|
$p = "/var/www/html/api/$f";
|
|
if (is_readable($p)) {
|
|
$c = (int)trim(@shell_exec("grep -c 'preg_match\\|INTENT:' " . escapeshellarg($p)));
|
|
$intents[$f] = $c;
|
|
}
|
|
}
|
|
$out['intents_registry'] = $intents;
|
|
$out['intents_total'] = array_sum($intents);
|
|
|
|
// 3. Chat log last 10 (real)
|
|
$log = @shell_exec('tail -10 /var/log/weval/wevia-master-api.log 2>/dev/null || tail -10 /var/log/apache2/access.log 2>/dev/null | grep wevia-master');
|
|
$out['chat_log_last_10'] = substr(trim($log), 0, 800);
|
|
|
|
// 4. Self-code fingerprint
|
|
$out['master_api'] = [
|
|
'size' => filesize('/var/www/html/api/wevia-master-api.php'),
|
|
'last_modified' => date('c', filemtime('/var/www/html/api/wevia-master-api.php')),
|
|
'md5' => md5_file('/var/www/html/api/wevia-master-api.php')
|
|
];
|
|
|
|
// 5. Doctrine file real content
|
|
$doctrines_file = '/opt/wevads/vault/doctrines.md';
|
|
if (is_readable($doctrines_file)) {
|
|
$out['doctrines'] = [
|
|
'path' => $doctrines_file,
|
|
'size' => filesize($doctrines_file),
|
|
'first_500_chars' => substr(file_get_contents($doctrines_file), 0, 500)
|
|
];
|
|
} else {
|
|
$out['doctrines'] = ['status' => 'file_not_found', 'path' => $doctrines_file];
|
|
}
|
|
|
|
// 6. Explanation (doctrine #4 honesty)
|
|
$out['note'] = 'All values above are RESULTS OF REAL SHELL COMMANDS on S204 — no LLM simulation (doctrine #2). If a prompt does not match any intent, check wevia-master-api.php _is_content_req guard (line ~485) + V27-SURGICAL exclusion list (line ~489).';
|
|
|
|
$out['content'] = json_encode([
|
|
'vault_files' => $out['vault']['file_count'],
|
|
'intents_total' => $out['intents_total'],
|
|
'master_api_size' => $out['master_api']['size'],
|
|
'master_api_md5' => substr($out['master_api']['md5'], 0, 12),
|
|
'doctrine_file' => $out['doctrines']['status'] ?? 'live',
|
|
'log_preview' => substr($out['chat_log_last_10'] ?? '', 0, 200),
|
|
'full' => 'See structured fields for details'
|
|
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
|
|
|
return $out;
|
|
}
|
|
}
|