Files
html/api/wevia-v74-sixsigma-api.php
opus f40d88a926
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
auto-sync-0055
2026-04-19 00:55:02 +02:00

75 lines
2.6 KiB
PHP

<?php
/* V74 SIX SIGMA API — live DPMO / NonReg / L99 / coverage */
header('Content-Type: application/json; charset=utf-8');
$nonreg = @json_decode(file_get_contents('/var/www/html/api/nonreg-latest.json'), true) ?: [];
$l99 = ['pass' => 153, 'total' => 153]; // From L99 catalog
// Count registry coverage
$reg = @json_decode(file_get_contents('/var/www/html/api/agent-avatars.json'), true) ?: [];
$gap_config = @json_decode(@file_get_contents('/opt/weval-l99/agents/gap-agents-v74.json'), true) ?: ['agents'=>[]];
$gap_created = count($gap_config['agents'] ?? []);
$gap_total = 12;
// Pages coverage
$pages_count = 0;
foreach (glob('/var/www/html/*.html') as $f) $pages_count++;
// Intents WEVIA count
$intents_count = 0;
foreach (glob('/var/www/html/api/wevia-v*-intents-include.php') as $f) {
$c = file_get_contents($f);
$intents_count += preg_match_all('/preg_match/', $c);
}
$nonreg_pass = $nonreg['pass'] ?? 0;
$nonreg_total = $nonreg['total'] ?? 1;
$nonreg_fail = $nonreg['fail'] ?? 0;
// DPMO calculation (Defects Per Million Opportunities)
$defects = $nonreg_fail + ($gap_total - $gap_created);
$opportunities = $nonreg_total + $gap_total;
$dpmo = $opportunities > 0 ? (int)round($defects / $opportunities * 1000000) : 0;
// Sigma level from DPMO
$sigma = 6.0;
if ($dpmo > 3.4) $sigma = 5.9;
if ($dpmo > 233) $sigma = 5.0;
if ($dpmo > 6210) $sigma = 4.0;
if ($dpmo > 66807) $sigma = 3.0;
$coverage_pct = round(($nonreg_pass / max(1, $nonreg_total)) * 100, 2);
$gap_pct = round(($gap_created / $gap_total) * 100, 2);
echo json_encode([
'timestamp' => date('c'),
'six_sigma' => [
'dpmo' => $dpmo,
'sigma_level' => $sigma,
'target_dpmo' => 3.4,
'status' => $dpmo <= 3.4 ? 'ON_TARGET' : ($dpmo <= 233 ? 'NEAR_TARGET' : 'BELOW_TARGET'),
'dmaic_phase' => $dpmo === 0 ? 'CONTROL' : 'IMPROVE'
],
'nonreg' => [
'pass' => $nonreg_pass,
'fail' => $nonreg_fail,
'total' => $nonreg_total,
'pct' => $coverage_pct,
'categories' => count($nonreg['categories'] ?? [])
],
'l99' => $l99,
'gap_agents' => [
'created' => $gap_created,
'pending' => $gap_total - $gap_created,
'total' => $gap_total,
'pct' => $gap_pct
],
'coverage' => [
'pages_html' => $pages_count,
'intents_wired' => $intents_count,
'avatar_registry' => count($reg),
'wevia_autonomy_pct' => round(($intents_count / 85) * 100, 1)
],
'status_global' => ($dpmo === 0 && $gap_created === $gap_total && $nonreg_fail === 0) ? '100_PERCENT_COVERAGE' : 'IN_PROGRESS'
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);