Files
Sophia/web/index.html
dtoro 8688f632bf Implement Sophia MVP scaffold (stages 0–3 + topology pivot)
Six-crate Rust workspace (core/sim/llm/store/server/bin) backing a
Three.js + WebGL frontend. Live at http://127.0.0.1:7777 via `cargo run`.

Sim
- Event-driven scheduler with min-heap, per-engram tick, staggered Spawn
  events (40 ms apart) so each engram's flight is visually readable.
- Solid-donut torus topology (replaces original spherical density-driven
  shell, see Topology Pivot in docs/system-analysis.md). Configurable
  major/minor radii in config.toml; live `POST /api/galaxy/:id/resize`.
- Physics: Verlet integration + friction; in-hole pull + galactic spin
  (CCW around +z) for spiral-ejection ejection from the donut centre;
  soft tube boundary with velocity-reflecting wall.
- Cosine-weighted gravity (kiddo k-NN within radius 25, threshold 0.50)
  and synapse formation (threshold 0.62) gated to inside-the-tube only.
- LM Studio integration via OpenAI-compatible REST: batched embeddings,
  optional Bearer auth, semaphore-bounded parallel ops per §13.5.

Server
- axum HTTP + WebSocket. Routes: /healthz, /api/galaxy CRUD, /seed,
  /ingest, /resize, /engrams/:id, /ws/galaxy/:id/events.
- Binary 12-byte-aligned position frames at ~20 Hz; JSON for sparse
  events (Hello, EngramCreated, SynapseCreated, TorusUpdated).
- Layered config: config.toml (defaults) + config.local.toml (secrets,
  gitignored) merged on startup.

Frontend
- Vite + vanilla TypeScript + three.js 0.169.
- Engrams render as additive bloom-friendly point sprites with a
  per-engram hash-driven hue rotation and breathing pulse.
- Comet-style velocity-aligned trails; additive ribbon synapses whose
  endpoints track engram positions every frame.
- UnrealBloomPass + ACES tone-mapping for the linked-particles look.
- HUD shows torus dims, engram + synapse counts, LM Studio status;
  controls for seed, ingest, and live torus resize.

Docs
- README replaced with docs/IDEA.md; system-analysis.md updated with
  the topology pivot decisions and Galaxy Ejection refinement notes
  (the implementation plan lives in ~/.claude/plans, gitignored).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 08:29:37 +02:00

132 lines
4.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sophia</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
background: #050608;
color: #cfd6df;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
overflow: hidden;
}
#stage {
position: fixed;
inset: 0;
}
#hud {
position: fixed;
top: 12px;
left: 12px;
font-size: 12px;
line-height: 1.5;
background: rgba(0,0,0,0.4);
padding: 8px 10px;
border-radius: 4px;
pointer-events: none;
}
#hud .k { opacity: 0.55; }
#controls {
position: fixed;
top: 12px;
right: 12px;
display: flex;
flex-direction: column;
gap: 6px;
font-size: 12px;
background: rgba(0,0,0,0.4);
padding: 8px 10px;
border-radius: 4px;
}
#controls .ctrl-row {
display: flex;
gap: 6px;
align-items: center;
}
#controls input, #controls button {
font: inherit;
background: #11151b;
color: #cfd6df;
border: 1px solid #2a323d;
padding: 3px 8px;
border-radius: 3px;
}
#controls input { width: 64px; }
#controls button { cursor: pointer; }
#controls button:hover { background: #1a2129; }
#controls button:disabled { opacity: 0.5; cursor: progress; }
#ingest {
position: fixed;
bottom: 12px;
right: 12px;
width: 340px;
background: rgba(0,0,0,0.55);
padding: 10px;
border-radius: 4px;
font-size: 12px;
}
#ingest textarea {
width: 100%;
height: 96px;
font: inherit;
resize: vertical;
background: #0c1014;
color: #cfd6df;
border: 1px solid #2a323d;
border-radius: 3px;
padding: 6px;
box-sizing: border-box;
}
#ingest .row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
#ingest .hint { opacity: 0.55; font-size: 11px; }
#ingest button {
font: inherit;
background: #1a2129;
color: #cfd6df;
border: 1px solid #2a323d;
padding: 4px 10px;
border-radius: 3px;
cursor: pointer;
}
#ingest button:hover { background: #232c36; }
#ingest button:disabled { opacity: 0.5; cursor: progress; }
</style>
</head>
<body>
<canvas id="stage"></canvas>
<div id="hud">
<div><span class="k">sophia</span> v0.0.1</div>
<div><span class="k">stage</span> <span id="hud-stage">2 — slate + lm studio</span></div>
<div><span class="k">galaxy</span> <span id="hud-galaxy"></span></div>
<div><span class="k">torus</span> <span id="hud-torus"></span></div>
<div><span class="k">engrams</span> <span id="hud-count">0</span></div>
<div><span class="k">synapses</span> <span id="hud-synapses">0</span></div>
<div><span class="k">lm studio</span> <span id="hud-lm"></span></div>
<div><span class="k">health</span> <span id="hud-health"></span></div>
</div>
<div id="controls">
<div class="ctrl-row">
<input id="seed-n" type="number" min="1" max="5000" value="200" title="number of synthetic engrams" />
<button id="seed-btn">seed</button>
</div>
<div class="ctrl-row">
<input id="resize-major" type="number" min="1" max="10000" step="10" value="100" title="major radius (donut hole)" />
<input id="resize-minor" type="number" min="1" max="2000" step="5" value="30" title="minor radius (tube)" />
<button id="resize-btn">resize</button>
</div>
</div>
<div id="ingest">
<textarea id="ingest-text" placeholder="One engram per line. Empty lines are skipped.&#10;e.g.&#10;Pasta carbonara uses guanciale, eggs, pecorino, and pepper.&#10;Backpropagation computes gradients of a loss with respect to weights.&#10;The fall of Constantinople occurred in 1453."></textarea>
<div class="row">
<span class="hint">embeds via LM Studio, then spawns at center</span>
<button id="ingest-btn">ingest</button>
</div>
</div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>