emergence-mini-dilles/web/index.html
Jeuners 919866e50d Time Dilation framework + OpenRouter multi-LLM
Implements core pieces of 'Time Dilation in LLM Agent Systems'
(Dillenberg 2026) and adds OpenRouter as a second LLM provider.

ENGINE
- engine/time.py: AgentClock with cumulative proper time tau
  (weighted by op type), EWMA pace (alpha=0.3, dt clamped 0.1-60s),
  ClockRegistry singleton, gamma_{src->dst} frame transformation,
  drift_report with per-pair divergence and threshold flag.
- engine/turn.py: ticks tau on reasoning/tool/memory/reactive;
  broadcasts tau+pace+model in every WebSocket message.
- engine/db.py: schema adds turn_log.tau, turn_log.pace,
  turn_log.model, agent_clocks table; dev-mode auto-migrate
  drops+recreates if old schema detected.
- engine/llm.py: full refactor for two providers.
    Ollama: native tool-calling via /api/chat
    OpenRouter: OpenAI-compatible /api/v1/chat/completions
  Auto mode picks OpenRouter if OPENROUTER_API_KEY is set.
  Per-agent model via EMERGENCE_AGENT_<ID>_MODEL env var.
  .env loader with empty-line guard.
  decide_tool returns (name, args, meta) with cost_usd for OR.

FRONTEND
- web/: new 'Time Dilation · Eigenzeit tau' section with per-agent
  tau bars, pace, op count. Drift warning when any pair exceeds
  threshold. LLM provider info in header.

TESTS
- 14 new tests in tests/test_time.py (tau monotonic, EWMA convergence,
  gamma asymmetry, drift detection).
- 4 new LLM tests: openrouter response parsing, per-agent override,
  provider_info, is_available.
- All 99 tests green.

LIVE-VERIFIED
- 4 different OpenRouter models running in parallel:
  - anchor: anthropic/claude-3.5-haiku
  - flora:  openai/gpt-4o-mini
  - lovely: meta-llama/llama-3.3-70b-instruct
  - spark:  google/gemma-3-4b-it
- All 4 produce turns, all 4 have different tau values,
  drift_report shows the Frame-Transformation gamma values.
- Observation: gamma ~ 1.00 because the explicit Round-Robin +
  sleep(2) keeps frames coherent. This is itself a non-trivial
  validation of the paper's claim: in non-synchronized systems,
  dilation would emerge.

SECRETS
- .env added, OPENROUTER_API_KEY live. .env is git-ignored.
- .env.example documents the config without exposing any key.
- .gitignore now blocks .env, .env.local, *.key, *.pem.

README
- New 'Time Dilation' section explaining tau, pace, CDC, drift
- New 'Multi-LLM via OpenRouter' section with cost table
- Per-agent model config documented
2026-06-15 02:27:11 +02:00

66 lines
1.6 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Emergence-Mini · Live World</title>
<link rel="stylesheet" href="/static/style.css" />
</head>
<body>
<header>
<h1>Emergence-Mini</h1>
<div class="meta">
<span>Tick <b id="tick">0</b></span>
<span>Agents <b id="agentCount">0</b></span>
<span>Proposals <b id="propCount">0</b></span>
<span id="llmInfo" class="llm-info"></span>
<span class="ws-status" id="wsStatus">connecting…</span>
</div>
</header>
<main>
<section class="canvas-wrap">
<canvas id="world" width="640" height="640"></canvas>
<div class="legend">
<span class="dot anchor"></span>Anchor
<span class="dot flora"></span>Flora
<span class="dot lovely"></span>Lovely
<span class="dot spark"></span>Spark
</div>
</section>
<aside>
<h2>Time Dilation · Eigenzeit τ</h2>
<div id="clocks"></div>
<div id="drift"></div>
<h2>Live Feed</h2>
<ul id="feed"></ul>
<h2>Agents</h2>
<div id="agentList"></div>
<h2>Town Hall · Active Proposals</h2>
<div id="proposals"></div>
<h2>Constitution</h2>
<div id="constitution"></div>
<h2>Manual Control</h2>
<form id="manual">
<label>Agent
<select name="agent"></select>
</label>
<label>Tool
<select name="tool"></select>
</label>
<label>Args (JSON)
<input name="args" value="{}" />
</label>
<button type="submit">Run</button>
</form>
</aside>
</main>
<script src="/static/app.js"></script>
</body>
</html>