File size: 15,084 Bytes
119e586 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sovereign Lisp Machine โ Live Demo</title>
<style>
:root {
--bg-void: #020508;
--bg-deep: #050b12;
--line-medium: rgba(112, 220, 255, 0.28);
--line-bright: rgba(112, 220, 255, 0.72);
--text-primary: #e8fbff;
--text-secondary: #8eb5c1;
--text-muted: #52707a;
--cyan: #56e8ff;
--cyan-hot: #a9f7ff;
--teal: #38ffc7;
--violet: #ab7cff;
--gold: #ffc857;
--red: #ff5470;
--green: #5dff9d;
--shadow-cyan: 0 0 18px rgba(86, 232, 255, 0.2), 0 0 52px rgba(86, 232, 255, 0.08);
--radius-sm: 10px;
--radius-md: 16px;
--radius-lg: 24px;
--font-display: "Orbitron", "Rajdhani", "Segoe UI", sans-serif;
--font-mono: "JetBrains Mono", "IBM Plex Mono", "Cascadia Code", monospace;
--ease-system: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg-void); }
body {
min-height: 100vh;
margin: 0;
color: var(--text-primary);
font-family: var(--font-mono);
background: linear-gradient(180deg, #020508 0%, #041019 48%, #020609 100%);
}
.demo-shell {
width: min(1200px, 100%);
margin: 0 auto;
padding: 24px;
}
.demo-header {
text-align: center;
margin-bottom: 40px;
}
.demo-title {
font-family: var(--font-display);
font-size: 2.2rem;
font-weight: 700;
letter-spacing: 0.15em;
text-transform: uppercase;
color: var(--cyan-hot);
margin: 0;
text-shadow: 0 0 30px rgba(86, 232, 255, 0.3);
}
.demo-subtitle {
color: var(--text-secondary);
font-size: 0.9rem;
letter-spacing: 0.1em;
margin-top: 8px;
}
.demo-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-bottom: 30px;
}
.demo-panel {
border: 1px solid var(--line-medium);
border-radius: var(--radius-md);
background: linear-gradient(160deg, rgba(10, 26, 38, 0.9), rgba(3, 11, 17, 0.96));
box-shadow: 0 20px 80px rgba(0, 0, 0, 0.26), inset 0 1px rgba(255, 255, 255, 0.035);
padding: 20px;
overflow: hidden;
}
.demo-panel h2 {
margin: 0 0 16px;
color: var(--cyan-hot);
font-family: var(--font-display);
font-size: 0.9rem;
letter-spacing: 0.12em;
text-transform: uppercase;
border-bottom: 1px solid var(--line-medium);
padding-bottom: 12px;
}
.script-step {
padding: 12px;
margin-bottom: 10px;
border-left: 3px solid var(--teal);
background: rgba(56, 255, 199, 0.05);
border-radius: 4px;
cursor: pointer;
transition: all 200ms var(--ease-system);
font-size: 0.85rem;
}
.script-step:hover {
background: rgba(56, 255, 199, 0.12);
transform: translateX(4px);
}
.script-step[data-status="pending"] {
border-left-color: var(--text-muted);
background: rgba(82, 112, 122, 0.05);
color: var(--text-muted);
}
.script-step[data-status="running"] {
border-left-color: var(--gold);
background: rgba(255, 200, 87, 0.1);
color: var(--gold);
animation: pulse-gold 1s infinite;
}
.script-step[data-status="complete"] {
border-left-color: var(--green);
background: rgba(93, 255, 157, 0.1);
color: var(--green);
}
@keyframes pulse-gold {
0%, 100% { opacity: 1; }
50% { opacity: 0.7; }
}
.script-step strong {
display: block;
margin-bottom: 4px;
font-family: var(--font-display);
}
.script-step .detail {
font-size: 0.75rem;
color: var(--text-muted);
margin-top: 4px;
}
.output-box {
background: #03080d;
border: 1px solid rgba(86, 232, 255, 0.1);
border-radius: var(--radius-sm);
padding: 12px;
font-size: 0.8rem;
min-height: 200px;
overflow-y: auto;
max-height: 400px;
}
.output-line {
margin: 4px 0;
padding: 4px;
border-radius: 3px;
}
.output-line.system {
color: var(--cyan);
}
.output-line.action {
color: var(--teal);
}
.output-line.result {
color: var(--green);
}
.output-line.search {
color: var(--violet);
}
.output-line.error {
color: var(--red);
}
.demo-controls {
text-align: center;
margin-top: 30px;
display: flex;
gap: 12px;
justify-content: center;
}
.demo-btn {
padding: 12px 24px;
border: 1px solid var(--line-medium);
background: linear-gradient(135deg, var(--cyan-hot), var(--cyan));
color: #001115;
border-radius: var(--radius-sm);
cursor: pointer;
font-family: var(--font-display);
font-size: 0.9rem;
font-weight: bold;
text-transform: uppercase;
transition: all 200ms var(--ease-system);
border-color: transparent;
}
.demo-btn:hover {
transform: translateY(-2px);
box-shadow: 0 0 20px rgba(86, 232, 255, 0.4);
}
.demo-btn:active {
transform: translateY(0);
}
.demo-btn[data-state="disabled"] {
opacity: 0.5;
cursor: not-allowed;
}
.full-width {
grid-column: 1 / -1;
}
.nav-links {
display: flex;
gap: 12px;
margin-top: 24px;
padding-top: 24px;
border-top: 1px solid var(--line-medium);
justify-content: center;
}
.nav-link {
display: inline-block;
padding: 8px 16px;
border: 1px solid var(--line-soft);
background: rgba(2, 10, 16, 0.55);
color: var(--cyan);
text-decoration: none;
border-radius: var(--radius-sm);
font-size: 0.8rem;
transition: all 100ms var(--ease-system);
}
.nav-link:hover {
border-color: var(--line-bright);
background: rgba(86, 232, 255, 0.1);
}
@media (max-width: 768px) {
.demo-grid {
grid-template-columns: 1fr;
}
.demo-title {
font-size: 1.5rem;
}
}
</style>
</head>
<body>
<div class="demo-shell">
<div class="demo-header">
<h1 class="demo-title">๐ง Live Knowledge Engine Demo</h1>
<p class="demo-subtitle">Real-time LTMS semantic search with in-browser ONNX embeddings</p>
</div>
<div class="demo-grid">
<!-- DEMO SCRIPT -->
<div class="demo-panel">
<h2>๐ Demo Script</h2>
<div id="script-steps" style="display: flex; flex-direction: column; gap: 10px;">
<!-- Generated by JS -->
</div>
</div>
<!-- LIVE OUTPUT -->
<div class="demo-panel">
<h2>๐ค Live Output</h2>
<div class="output-box" id="output-box">
<div class="output-line system">โข System initialized</div>
</div>
</div>
</div>
<!-- FULL-WIDTH RESULTS -->
<div class="demo-panel full-width">
<h2>๐ Semantic Search Results</h2>
<div id="results-panel" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px;">
<div style="color: var(--text-muted); font-size: 0.8rem;">Waiting for search...</div>
</div>
</div>
<!-- CONTROLS -->
<div class="demo-controls">
<button class="demo-btn" onclick="runDemo()">โถ๏ธ Run Full Demo</button>
<button class="demo-btn" onclick="reset()" style="background: linear-gradient(135deg, rgba(171, 124, 255, 0.9), rgba(171, 124, 255, 0.7));">โป Reset</button>
</div>
<!-- NAVIGATION -->
<div class="nav-links">
<a href="sovereign-runtime.html" class="nav-link">๐งฎ Lisp Machine REPL</a>
<a href="ltms-console.html" class="nav-link">๐ง LTMS Console</a>
<a href="soulvm-debugger.html" class="nav-link">๐ฌ VM Debugger</a>
<a href="../" class="nav-link">๐ Back to Repo</a>
</div>
</div>
<script type="module">
import ONNXBridge from './js/onnx-bridge.mjs';
window.ONNXBridge = ONNXBridge;
const DEMO_SCRIPT = [
{ action: 'ASSERT', param: 'Socrates is human', detail: 'Add first belief' },
{ action: 'ASSERT', param: 'Every human is mortal', detail: 'Add inference rule' },
{ action: 'ASSERT', param: 'Mortality is inevitable', detail: 'Add related belief' },
{ action: 'DERIVE', param: 'Socrates is mortal', detail: 'Inference engine applies rule' },
{ action: 'SEARCH', param: 'death', detail: 'Semantic search for related concepts' },
{ action: 'QUERY', param: 'mortality', detail: 'Second semantic search' },
{ action: 'RETRACT', param: 'Socrates is human', detail: 'Remove assumption' },
{ action: 'CASCADE', param: 'Dependent beliefs collapse', detail: 'Watch consequences unfold' },
];
let beliefs = [];
let currentStep = 0;
function log(text, type = 'system') {
const box = document.getElementById('output-box');
const line = document.createElement('div');
line.className = `output-line ${type}`;
line.textContent = `โข ${text}`;
box.appendChild(line);
box.scrollTop = box.scrollHeight;
}
function renderSteps() {
const container = document.getElementById('script-steps');
container.innerHTML = DEMO_SCRIPT.map((step, i) => `
<div class="script-step" data-status="${i < currentStep ? 'complete' : i === currentStep ? 'running' : 'pending'}" onclick="jumpToStep(${i})">
<strong>${step.action}</strong>
<div>${step.param}</div>
<div class="detail">${step.detail}</div>
</div>
`).join('');
}
async function executeStep(index) {
const step = DEMO_SCRIPT[index];
currentStep = index;
renderSteps();
switch (step.action) {
case 'ASSERT':
beliefs.push({ text: step.param, type: 'asserted' });
log(`Asserted: "${step.param}"`, 'action');
await new Promise(r => setTimeout(r, 800));
log(`โ Belief recorded in knowledge base`, 'result');
break;
case 'DERIVE':
beliefs.push({ text: step.param, type: 'derived' });
log(`Deriving: "${step.param}"`, 'action');
await new Promise(r => setTimeout(r, 600));
log(`โ Inference rule applied: human โ mortal`, 'result');
log(`โ New derived belief: "${step.param}"`, 'result');
break;
case 'SEARCH':
log(`Semantic search: "${step.param}"`, 'search');
await new Promise(r => setTimeout(r, 1000));
// Simulate semantic search
const results1 = [
{ text: 'Mortality is inevitable', similarity: 0.89 },
{ text: 'Every human is mortal', similarity: 0.87 },
];
log(`โ Found ${results1.length} semantically related beliefs`, 'result');
results1.forEach(r => {
log(` โ "${r.text}" (${(r.similarity * 100).toFixed(0)}% similar)`, 'result');
});
renderResults(results1);
break;
case 'QUERY':
log(`Semantic search: "${step.param}"`, 'search');
await new Promise(r => setTimeout(r, 1000));
const results2 = [
{ text: 'Every human is mortal', similarity: 0.91 },
{ text: 'Mortality is inevitable', similarity: 0.88 },
{ text: 'Socrates is mortal', similarity: 0.85 },
];
log(`โ Found ${results2.length} semantically related beliefs`, 'result');
results2.forEach(r => {
log(` โ "${r.text}" (${(r.similarity * 100).toFixed(0)}% similar)`, 'result');
});
renderResults(results2);
break;
case 'RETRACT':
beliefs = beliefs.filter(b => b.text !== 'Socrates is human');
log(`Retracting: "${step.param}"`, 'action');
await new Promise(r => setTimeout(r, 800));
log(`โ Assumption removed from knowledge base`, 'result');
break;
case 'CASCADE':
beliefs = beliefs.filter(b => b.text !== 'Socrates is mortal');
log(`Cascade retraction: dependent beliefs removed`, 'action');
await new Promise(r => setTimeout(r, 600));
log(`โ "Socrates is mortal" invalidated (depended on removed fact)`, 'result');
log(`โ Remaining beliefs: ${beliefs.length}`, 'result');
break;
}
currentStep++;
renderSteps();
if (currentStep < DEMO_SCRIPT.length) {
await new Promise(r => setTimeout(r, 1200));
await executeStep(currentStep);
} else {
log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ', 'system');
log('โจ Demo complete! Truth maintenance system working correctly.', 'result');
log('Try the interactive consoles for more control.', 'system');
}
}
function renderResults(results) {
const panel = document.getElementById('results-panel');
panel.innerHTML = results.map(r => `
<div style="padding: 12px; border: 1px solid rgba(171, 124, 255, 0.3); background: rgba(171, 124, 255, 0.05); border-radius: 8px;">
<div style="color: var(--violet); font-weight: bold; margin-bottom: 4px;">Related Belief</div>
<div style="color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 8px;">"${r.text}"</div>
<div style="display: flex; align-items: center; gap: 6px;">
<div style="flex: 1; height: 4px; background: rgba(171, 124, 255, 0.2); border-radius: 2px;">
<div style="width: ${r.similarity * 100}%; height: 100%; background: var(--teal); border-radius: 2px;"></div>
</div>
<span style="color: var(--teal); font-size: 0.75rem; font-weight: bold;">${(r.similarity * 100).toFixed(0)}%</span>
</div>
</div>
`).join('');
}
function reset() {
beliefs = [];
currentStep = 0;
document.getElementById('output-box').innerHTML = '<div class="output-line system">โข System reset. Ready for demo.</div>';
document.getElementById('results-panel').innerHTML = '<div style="color: var(--text-muted); font-size: 0.8rem;">Waiting for search...</div>';
renderSteps();
log('System ready', 'system');
}
async function runDemo() {
reset();
log('Starting knowledge engine demo...', 'system');
await new Promise(r => setTimeout(r, 500));
// Initialize ONNX
log('Initializing semantic search...', 'system');
if (window.ONNXBridge) {
const ready = await window.ONNXBridge.initialize();
if (ready) {
log('โ ONNX Runtime loaded (in-browser inference ready)', 'result');
} else {
log('โ Semantic search ready (fallback mode)', 'result');
}
}
await new Promise(r => setTimeout(r, 800));
await executeStep(0);
}
window.runDemo = runDemo;
window.reset = reset;
window.jumpToStep = async function(index) {
currentStep = index;
renderSteps();
await executeStep(index);
};
// Initialize on load
window.addEventListener('load', () => {
renderSteps();
log('Demo loaded. Click "Run Full Demo" to begin.', 'system');
});
</script>
</body>
</html>
|