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>
This commit is contained in:
2026-04-28 08:29:37 +02:00
parent 43c4d270e6
commit 8688f632bf
44 changed files with 7664 additions and 100 deletions

67
Cargo.toml Normal file
View File

@@ -0,0 +1,67 @@
[workspace]
resolver = "2"
members = [
"crates/sophia-core",
"crates/sophia-sim",
"crates/sophia-llm",
"crates/sophia-store",
"crates/sophia-server",
"crates/sophia-bin",
]
[workspace.package]
version = "0.0.1"
edition = "2021"
license = "MIT"
rust-version = "1.80"
authors = ["Sophia"]
[workspace.dependencies]
# Internal
sophia-core = { path = "crates/sophia-core" }
sophia-sim = { path = "crates/sophia-sim" }
sophia-llm = { path = "crates/sophia-llm" }
sophia-store = { path = "crates/sophia-store" }
sophia-server = { path = "crates/sophia-server" }
# Errors / runtime
anyhow = "1"
thiserror = "1"
tokio = { version = "1.40", features = ["full"] }
async-trait = "0.1"
# Serde
serde = { version = "1", features = ["derive"] }
serde_json = "1"
# Logging
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
# Math, ids
glam = { version = "0.28", features = ["serde"] }
uuid = { version = "1", features = ["v7", "serde"] }
# HTTP/WS server (used by sophia-server only)
axum = { version = "0.7", features = ["ws", "macros"] }
tower = "0.5"
tower-http = { version = "0.6", features = ["fs", "trace", "cors"] }
# HTTP client (LM Studio)
reqwest = { version = "0.12", features = ["json", "stream"] }
# Sim
kiddo = "4"
rand = { version = "0.8", features = ["small_rng"] }
# Async helpers
futures-util = { version = "0.3", default-features = false, features = ["std", "sink"] }
bytes = "1"
# Config
toml = "0.8"
[profile.release]
lto = "thin"
codegen-units = 1
opt-level = 3