true, 'results' => $results]); break; case 'run_governance_scan': // Run scan in background $scriptPath = __DIR__ . '/scripts/runGovernanceScan.php'; $logPath = __DIR__ . '/logs/governance-scan.log'; exec("php " . escapeshellarg($scriptPath) . " > " . escapeshellarg($logPath) . " 2>&1 &"); echo json_encode(['success' => true, 'message' => 'Governance scan started']); break; case 'save_governance_rules': $rules = json_decode($_POST['rules'] ?? '[]', true); if (!is_array($rules)) throw new Exception('Invalid rules format'); file_put_contents(GOVERNANCE_RULES, json_encode($rules, JSON_PRETTY_PRINT), LOCK_EX); echo json_encode(['success' => true, 'message' => 'Rules saved']); break; case 'get_governance_status': $status = ''; if (file_exists(GOVERNANCE_STATUS)) { $status = file_get_contents(GOVERNANCE_STATUS); } echo json_encode(['success' => true, 'status' => $status]); break; default: echo json_encode(['success' => false, 'error' => 'Invalid action']); } } catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); } exit; } // Load governance data for initial render $governanceData = []; $hasResults = false; $scanDate = ''; if (file_exists(GOVERNANCE_CACHE)) { $governanceData = json_decode(file_get_contents(GOVERNANCE_CACHE), true) ?: []; if (!empty($governanceData['timestamp'])) { $hasResults = true; $scanDate = date('M j, Y g:i A', $governanceData['timestamp']); } } $rules = []; if (file_exists(GOVERNANCE_RULES)) { $rules = json_decode(file_get_contents(GOVERNANCE_RULES), true) ?: []; } $overallScore = $governanceData['overall_score'] ?? 0; $totalSpaces = $governanceData['total_spaces'] ?? 0; $healthy = $governanceData['summary']['healthy'] ?? 0; $warning = $governanceData['summary']['warning'] ?? 0; $critical = $governanceData['summary']['critical'] ?? 0; $violations = $governanceData['violations'] ?? []; $severityCounts = $governanceData['severity_counts'] ?? ['critical' => 0, 'warning' => 0, 'info' => 0]; ?>
Last scan:
Click "Run Scan" to analyze your spaces against governance rules.
| Space | Type | Rule | Severity | Details | Action |
|---|---|---|---|---|---|
| No violations found - all spaces are healthy! | |||||