Files
html/api/wiki-doctrine-53-audit.php

67 lines
2.5 KiB
PHP

<?php
header("Content-Type: application/json");
$api_names = array_filter(explode("\n", trim(@shell_exec('ls /var/www/html/api/*.php 2>/dev/null | xargs -n1 basename | sed "s/.php\$//"'))));
$html_files = array_filter(explode("\n", trim(@shell_exec('ls /var/www/html/*.html 2>/dev/null'))));
// Build referenced set
$referenced = [];
foreach ($html_files as $hf) {
$content = @file_get_contents($hf);
if (!$content) continue;
if (preg_match_all('#/api/([a-z0-9_.-]+)#i', $content, $m)) {
foreach ($m[1] as $r) {
$r = preg_replace('/\.(php|json)$/', '', $r);
$referenced[$r] = true;
}
}
}
// Exemption patterns: patchers internes + modules PHP du pipeline WEVIA
$exempt_prefixes = ['_', 'opus-', 'opus5-'];
$exempt_exact = [
'wevia-opus-intents', 'wevia-opus-write-intents', 'wevia-opus46-intents',
'wevia-wave114-intents', 'wevia-wave200-intents', 'wevia-gap-intents',
'wevia-dispatch-proxy', 'wevia-anthropic', 'wevia-master-dispatch',
'wevia-orchestrator-scan', 'wevia-run-tests', 'wevia-sse-orchestrator',
'wevia-master-router', 'arena-pre-intents', 'wevia-fast-path-v3',
'wevia-opus-autonomy', 'agents-context', // .json covered by data-hub
];
$violations = [];
$priorities = [];
foreach ($api_names as $api) {
if (isset($referenced[$api])) continue;
$base = preg_replace('/^(wv-|api-)/', '', $api);
$base = preg_replace('/(-api|_api)$/', '', $base);
if (isset($referenced[$base])) continue;
// Check HTML by name
$has_html = false;
foreach ($html_files as $hf) {
$hb = basename($hf, '.html');
if ($hb === $api || $hb === $base || (strlen($base) > 5 && stripos($hb, $base) !== false)) { $has_html = true; break; }
}
if ($has_html) continue;
// Exempt patchers
$exempted = false;
foreach ($exempt_prefixes as $p) { if (strpos($api, $p) === 0) { $exempted = true; break; } }
if (in_array($api, $exempt_exact)) $exempted = true;
if ($exempted) continue;
$violations[] = $api;
if (preg_match('/(api|admin|manager|dashboard|stat|monitor|audit|hub|center)/i', $api)) {
$priorities[] = $api;
}
}
echo json_encode([
'ts' => date('c'),
'doctrine' => 53,
'total_apis' => count($api_names),
'htmls' => count($html_files),
'referenced_by_html' => count($referenced),
'exempt_prefixes' => $exempt_prefixes,
'exempt_exact_count' => count($exempt_exact),
'violations_real' => count($violations),
'top_priorities' => array_slice($priorities, 0, 15),
'violations_all' => $violations,
], JSON_PRETTY_PRINT);