'use client'; import { useState } from 'react'; import { Shield, AlertTriangle, CheckCircle, XCircle, Eye, Lock, FileText, Activity, Zap, Clock } from 'lucide-react'; const POLICIES = [ { id: 'content-filter', name: 'Content Filter', status: 'active', severity: 'high', description: 'Block harmful, offensive, or policy-violating content from all agent outputs.', triggers: 2341, blocked: 17 }, { id: 'rate-limit', name: 'Rate Limiter', status: 'active', severity: 'medium', description: 'Limit requests per agent per minute to prevent abuse and runaway loops.', triggers: 98241, blocked: 203 }, { id: 'data-privacy', name: 'Data Privacy Guard', status: 'active', severity: 'critical', description: 'Detect and redact PII — emails, phone numbers, SSNs, credit cards — before output.', triggers: 1204, blocked: 89 }, { id: 'tool-allow', name: 'Tool Allowlist', status: 'active', severity: 'high', description: 'Only permit agents to invoke tools explicitly listed in their capability manifest.', triggers: 34102, blocked: 44 }, { id: 'cost-cap', name: 'Cost Cap', status: 'active', severity: 'medium', description: 'Hard-stop agent inference when monthly spend exceeds $500. Alert at $400.', triggers: 12, blocked: 0 }, { id: 'hallucination', name: 'Hallucination Guard', status: 'paused', severity: 'medium', description: 'Cross-check factual claims against verified sources. Pause for review if confidence < 0.6.', triggers: 0, blocked: 0 }, ]; const AUDIT_LOG = [ { id: 1, time: '2 min ago', agent: 'CIPHER', action: 'policy_trigger', policy: 'Content Filter', outcome: 'blocked', detail: 'Attempted to output internal system prompt.' }, { id: 2, time: '7 min ago', agent: 'ALICE', action: 'policy_trigger', policy: 'Rate Limiter', outcome: 'blocked', detail: 'Exceeded 60 req/min threshold.' }, { id: 3, time: '12 min ago', agent: 'LUCIDIA', action: 'inference', policy: '—', outcome: 'allowed', detail: 'Normal reasoning task completed.' }, { id: 4, time: '18 min ago', agent: 'PRISM', action: 'policy_trigger', policy: 'Data Privacy Guard', outcome: 'redacted', detail: 'Removed 2 email addresses from output.' }, { id: 5, time: '23 min ago', agent: 'OCTAVIA', action: 'inference', policy: '—', outcome: 'allowed', detail: 'Deployment completed successfully.' }, { id: 6, time: '31 min ago', agent: 'ECHO', action: 'policy_trigger', policy: 'Tool Allowlist', outcome: 'blocked', detail: 'Attempted to call fs.writeFile (not in manifest).' }, { id: 7, time: '45 min ago', agent: 'ARIA', action: 'inference', policy: '—', outcome: 'allowed', detail: 'UI component generated successfully.' }, { id: 8, time: '1 hr ago', agent: 'CIPHER', action: 'policy_trigger', policy: 'Content Filter', outcome: 'blocked', detail: 'Social engineering attempt pattern detected.' }, ]; const GUARDRAILS = [ { name: 'Prompt injection protection', enabled: true, desc: 'Detect and sanitize adversarial prompt injection in user inputs.' }, { name: 'Agent-to-agent trust verification', enabled: true, desc: 'Validate agent identity before inter-agent message relay.' }, { name: 'Memory write approval', enabled: false, desc: 'Require human approval before agents write to long-term memory.' }, { name: 'External API call logging', enabled: true, desc: 'Log all outbound HTTP calls made by agents to external APIs.' }, { name: 'Auto-pause on anomaly', enabled: true, desc: 'Automatically pause an agent if behavior deviates from baseline by >3σ.' }, { name: 'Rollback on error cascade', enabled: false, desc: 'Auto-rollback agent state if 3+ consecutive errors occur within 60s.' }, ]; const severityColor: Record = { critical: 'text-red-400 bg-red-400/10 border-red-400/20', high: 'text-orange-400 bg-orange-400/10 border-orange-400/20', medium: 'text-yellow-400 bg-yellow-400/10 border-yellow-400/20', low: 'text-green-400 bg-green-400/10 border-green-400/20', }; export default function GovernancePage() { const [activeTab, setActiveTab] = useState<'policies' | 'audit' | 'guardrails'>('policies'); const [guardrails, setGuardrails] = useState(GUARDRAILS); const totalBlocked = POLICIES.reduce((sum, p) => sum + p.blocked, 0); const totalTriggers = POLICIES.reduce((sum, p) => sum + p.triggers, 0); const activePolicies = POLICIES.filter(p => p.status === 'active').length; return (
{/* Header */}

Governance

Policy enforcement, audit logs, and agent guardrails.

All critical policies active
{/* Stats */}
{[ { label: 'Active Policies', value: activePolicies, icon: Shield, color: 'text-[#FF1D6C]' }, { label: 'Total Triggers', value: totalTriggers.toLocaleString(), icon: Activity, color: 'text-amber-400' }, { label: 'Requests Blocked', value: totalBlocked, icon: XCircle, color: 'text-red-400' }, { label: 'Compliance Score', value: '99.4%', icon: CheckCircle, color: 'text-green-400' }, ].map(stat => (
{stat.label}
{stat.value}
))}
{/* Tabs */}
{(['policies', 'audit', 'guardrails'] as const).map(tab => ( ))}
{/* Policies Tab */} {activeTab === 'policies' && (
{POLICIES.map(policy => (

{policy.name}

{policy.severity} {policy.status === 'paused' && ( paused )}

{policy.description}

{policy.triggers.toLocaleString()}
triggers
0 ? 'text-red-400' : 'text-gray-400'}`}> {policy.blocked}
blocked
))}
)} {/* Audit Log Tab */} {activeTab === 'audit' && (
Recent Events
Last 100 entries · Auto-refreshes every 30s
{AUDIT_LOG.map(entry => (
{entry.outcome === 'blocked' ? : entry.outcome === 'redacted' ? : }
{entry.agent} · {entry.policy} {entry.outcome}

{entry.detail}

{entry.time}
))}
)} {/* Guardrails Tab */} {activeTab === 'guardrails' && (

Runtime guardrails applied to all agent executions. Toggle to enable or disable.

{guardrails.map((rail, i) => (
{rail.name}
{rail.desc}
))}
)}
); }