Client Request Console - Rev 38 (Governance Modal) RNI Agent Console
Tactical Layer — Active Zone
Operations: 24/160
Velocity: 3.2 ops/hr ↑ 12%
LLM Burst: 9 active models ⚡
Workers: 10/10 healthy ✓
Submit Request
All requests are evaluated for safety, compliance, and execution capacity before processing.
Reduced API response time by 40%. Implemented caching layer and optimized database queries.
HIPAA compliance verified. All encryption protocols validated. No vulnerabilities found.
- Connect Executive Portal to live KPI data
- Wire Chart.js visualizations
- Implement WebSocket real-time updates
- Rebuild 3-tier voting system (Express/Consult/Premier)
- Connect to Cloud Run endpoint
- Test multi-model consensus
- Kintsugi recovery journey visualization
- Crisis support always-visible panel
- Anonymous community counter
- Dr. Olivia chat integration
Waiting on signed Business Associate Agreement from Epic Systems before proceeding with FHIR integration.
Execution Pipeline: Council → Phoenix → Workers
→
Phoenix
Self-healing active
→
→
Assigned Doctor
${doctor}
Description
${description}
Timeline
⦿
In Progress: 2 days elapsed
○
Due: Nov 22, 2025 (2 days remaining)
Council Recommendations
Dr. Olivia: Prioritize user feedback integration before final testing.
Dr. Williams: Ensure API response time stays under 200ms threshold.
Dr. Taylor: Add Phoenix monitoring hooks for real-time error detection.
`;
document.body.appendChild(modal);
// Close on background click
modal.addEventListener('click', (e) => {
if (e.target === modal) modal.remove();
});
}
// Add click handlers to all task cards
document.querySelectorAll('.task-card').forEach(card => {
card.style.cursor = 'pointer';
card.addEventListener('click', function(e) {
// Don't trigger if clicking a button
if (e.target.closest('button')) return;
const title = this.querySelector('.task-title').textContent;
const pcode = this.querySelector('.task-code').textContent;
const doctor = this.querySelector('.task-meta-item:first-child span').textContent;
const status = this.querySelector('.task-meta-item:nth-child(2) span').textContent;
const description = this.querySelector('.task-description, .task-list')?.textContent || 'No description available';
openPcodeDetail(pcode, title, doctor, status, description);
});
});
// Add CSS animations
const style = document.createElement('style');
style.textContent = `
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes slideUp {
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
`;
document.head.appendChild(style);
/* ================================
REV 36 – LIVE P-CODE FEED + DETAIL PANE
================================ */const RECENT_PCODE_ENDPOINT = "https://pcode-issuer-248076137779.us-central1.run.app/pcode/recent";
/* Show Governance Modal for P-Code Authorization */function showGovernanceModal(pcode) {
const modal = document.getElementById('governance-modal');
const container = document.getElementById('modal-content');
if (!modal || !container) return;
const status = pcode.status || 'submitted';
const isAwaiting = status === 'awaiting-auth';
// Build meaningful title from domain + request
const domain = pcode.domain_class || pcode.domain || 'System';
const titleAction = extractActionFromRequest(pcode.origin_request) || 'Request';
container.innerHTML = `
🟡 Awaiting Human Authorization
Execution is paused until an Executive confirms or comments.
⏱ Waiting for authorization: calculating...
Domain:
${pcode.domain_class || pcode.domain || "—"}
Priority Level:
${pcode.urgency_class || "Standard"}
System Impact:
${pcode.impact_class || pcode.impact || "—"}
Authorization Holder:
${pcode.requested_by || "Executive"}
Requested Action:
${pcode.origin_request || "No details provided"}
If you authorize, the system will immediately:
Route the request to Phoenix for validation
Assign parallel review to Dr. Olivia and Dr. Williams
Begin live execution within ~3 seconds
Stream status updates into the execution feed
`;
// Show modal
modal.className = 'governance-modal active';
// Start timer
if (pcode.timestamp) {
startModalPauseTimer(pcode.timestamp);
}
// Close on background click
modal.onclick = (e) => {
if (e.target === modal) {
leavePaused();
}
};
}
/* Extract action from request text for title */function extractActionFromRequest(request) {
if (!request) return 'Request';
// Simple extraction - first few words or key verb
const words = request.trim().split(' ');
if (words.length <= 3) return words.join(' ');
// Look for action verbs
const actionVerbs = ['audit', 'create', 'update', 'analyze', 'review', 'build', 'deploy', 'configure'];
const firstVerb = words.find(w => actionVerbs.includes(w.toLowerCase()));
if (firstVerb) {
const verbIndex = words.indexOf(firstVerb);
return words.slice(verbIndex, Math.min(verbIndex + 3, words.length)).join(' ');
}
return words.slice(0, 3).join(' ') + '...';
}
/* Modal Pause Timer */function startModalPauseTimer(timestamp) {
const timerEl = document.getElementById('modal-pause-timer');
if (!timerEl) return;
let timerInterval = setInterval(() => {
const start = new Date(timestamp);
const now = new Date();
const diff = Math.floor((now - start) / 1000);
const minutes = Math.floor(diff / 60);
const seconds = diff % 60;
timerEl.textContent = `⏱ Waiting for authorization: ${minutes}m ${seconds}s`;
}, 1000);
// Store interval ID for cleanup
window.modalTimerInterval = timerInterval;
}
/* Authorization Actions */function authorizeAndContinue(id) {
console.log("✅ AUTHORIZED:", id);
// TODO: POST authorization to backend
// Update status to 'approved' or 'executing'
alert(`P-Code ${id} authorized. Execution proceeding...`);
// Close modal
closeGovernanceModal();
// Refresh feed to show updated status
setTimeout(() => {
if (typeof refreshPcodes === 'function') {
refreshPcodes();
}
}, 500);
}
function addCommentModify(id) {
console.log("💬 Adding comment to:", id);
const comment = prompt(`Add comment or modification request for P-Code ${id}:`);
if (comment) {
console.log(`Comment added to ${id}:`, comment);
// TODO: POST comment to backend
alert(`Comment added to P-Code ${id}`);
}
}
function leavePaused() {
console.log("⏸ Left paused - no action taken");
closeGovernanceModal();
}
function closeGovernanceModal() {
const modal = document.getElementById('governance-modal');
if (modal) {
modal.className = 'governance-modal';
}
// Clear timer
if (window.modalTimerInterval) {
clearInterval(window.modalTimerInterval);
window.modalTimerInterval = null;
}
}
/* Legacy detail pane function - now triggers modal for awaiting auth */function showPcodeDetail(pcode) {
const status = pcode.status || 'submitted';
const isAwaiting = status === 'awaiting-auth';
if (isAwaiting) {
// Show governance modal for awaiting authorization
showGovernanceModal(pcode);
} else {
// Show simple detail pane for other statuses
showSimpleDetail(pcode);
}
}
/* Simple detail pane for non-awaiting P-codes */function showSimpleDetail(pcode) {
const pane = document.getElementById("pcode-detail-pane");
if (!pane) return;
pane.className = "active";
pane.innerHTML = `
P-Code ${pcode.pcode || pcode.id || "Details"}
Status: ${getStatusLabel(pcode.status || 'submitted')}
Domain: ${pcode.domain_class || pcode.domain || "—"}
Urgency: ${pcode.urgency_class || "—"}
Impact: ${pcode.impact_class || pcode.impact || "—"}
Requested By: ${pcode.requested_by || "—"}
Request:
${pcode.origin_request || "—"}
`;
pane.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
/* Get Status Label */function getStatusLabel(status) {
const labels = {
'draft': 'Draft',
'submitted': 'Submitted',
'ai-review': 'In AI Review',
'awaiting-auth': 'Awaiting Human Authorization',
'approved': 'Approved',
'executed': 'Executed',
'escalated': 'Escalated',
'closed': 'Closed'
};
return labels[status] || 'Submitted';
}
/* Legacy Button Actions */function handleContinue(id) {
console.log("Continue on P-Code:", id);
alert(`Continue work on P-Code ${id}`);
}
function handleComment(id) {
console.log("Comment on P-Code:", id);
const comment = prompt(`Add comment for P-Code ${id}:`);
if (comment) {
console.log(`Comment added to ${id}:`, comment);
}
}
function closeDetail() {
const pane = document.getElementById("pcode-detail-pane");
if (pane) pane.className = "";
}
/* Sidebar + Main Feed Refresh */async function refreshPcodes() {
try {
const res = await fetch(RECENT_PCODE_ENDPOINT);
const data = await res.json();
if (!data || !data.pcodes) return;
const pcodes = data.pcodes.slice(0, 10);
// ---- SIDEBAR UPDATE ----
const sidebar = document.querySelector(".sidebar-content");
let dynamicBlock = document.getElementById("dynamic-pcodes");
if (!dynamicBlock) {
dynamicBlock = document.createElement("div");
dynamicBlock.id = "dynamic-pcodes";
sidebar.prepend(dynamicBlock);
}
// Count awaiting authorization
const awaitingCount = pcodes.filter(p => p.status === 'awaiting-auth').length;
dynamicBlock.innerHTML = `
${pcodes.map(p => {
const isAwaiting = p.status === 'awaiting-auth';
return `
`;
}).join("")}
`;
// ---- MAIN FEED UPDATE ----
const completed = document.querySelector(".task-section");
pcodes.forEach(p => {
if (!document.getElementById(p.pcode)) {
const status = p.status || 'submitted';
const isAwaiting = status === 'awaiting-auth';
const card = document.createElement("div");
card.className = `task-card blue ${isAwaiting ? 'awaiting' : ''}`;
card.id = p.pcode;
card.innerHTML = `
${isAwaiting ? '⏸' : ''}
${getStatusLabel(status)}
${p.origin_request || ""}
`;
// Make card clickable
card.style.cursor = 'pointer';
card.addEventListener('click', (e) => {
if (!e.target.closest('button')) {
showPcodeDetail(p);
}
});
completed.after(card);
}
});
} catch (err) {
console.error("Live P-code feed error:", err);
}
}
/* Auto-refresh every 3 seconds */setInterval(refreshPcodes, 3000);
/* Initial load */refreshPcodes();