From 88dae1e9c6921c8fb714e828f2b68119fe7af619 Mon Sep 17 00:00:00 2001
From: E
Date: Wed, 30 Sep 2026 15:36:29 -0400
Subject: [PATCH] pentagon mixer (via opus): drag-to-weigh valence mix, 30/30
dom assertions, parse_mix cross-checked
---
live/server.py | 42 ++++--
site/index.html | 372 ++++++++++++++++++++++++++++++++++++++++++++++++
site/live.html | 317 ++++++++++++++++++++++++++++++-----------
3 files changed, 633 insertions(+), 98 deletions(-)
diff --git a/live/server.py b/live/server.py
index 342756e..50d879e 100644
--- a/live/server.py
+++ b/live/server.py
@@ -353,12 +353,18 @@ async def steer(req: Request):
if not _state["ready"]:
yield _sse("error", {"e": "Pouyan is still loading"})
return
+ # flush immediately: the wait below can take a minute, and until the
+ # first chunk is yielded no headers reach the proxy (same reason
+ # /stream opens with hello)
+ yield _sse("queued", {"busy": _CYCLE_BUSY, "prompt": prompt})
_STEER_WAITING += 1
_preempt.set() # tell the shared cycle to stand down
try:
- for _ in range(120):
+ for i in range(120):
if not _CYCLE_BUSY:
break
+ if i and i % 5 == 0:
+ yield _sse("queued", {"busy": True, "waited": i})
await asyncio.sleep(1.0)
if _CYCLE_BUSY:
yield _sse("error", {"e": "still busy after 120s, try again"})
@@ -393,7 +399,9 @@ async def steer(req: Request):
_STEER_WAITING = max(0, _STEER_WAITING - 1)
if _STEER_WAITING == 0: # last user run: let the cycle resume
_preempt.clear()
- return StreamingResponse(gen(), media_type="text/event-stream")
+ return StreamingResponse(gen(), media_type="text/event-stream",
+ headers={"Cache-Control": "no-cache",
+ "X-Accel-Buffering": "no"})
@app.get("/run")
def run(scenario: str = "no extra info", dose: int = 4):
@@ -412,8 +420,11 @@ async def stream():
# flush something immediately: until the first chunk is yielded no
# response headers reach the proxy, and a run can take a minute to
# start — that silence is what Railway turns into a 502
+ # "current" lets a viewer who joins mid-run paint the card it missed
+ # the run event for — otherwise tokens arrive with no prompt attached
yield _sse("hello", {"subject": "Pouyan", "busy": _CYCLE_BUSY,
- "valences": list(VALENCES)})
+ "valences": list(VALENCES),
+ "current": _CURRENT})
try:
while True:
try:
@@ -429,6 +440,7 @@ async def stream():
_SUBSCRIBERS = set() # asyncio.Queue per viewer; ONE shared cycle broadcasts
_CYCLE_BUSY = False # true while the shared cycle is inside a run
+_CURRENT = None # the run in flight + text so far, for mid-run joiners
def _broadcast(event, data):
msg = f"event: {event}\ndata: {json.dumps(data)}\n\n"
@@ -441,14 +453,16 @@ def _broadcast(event, data):
async def _shared_cycle():
"""One model-owning cycle runs server-side; every viewer sees the same
run. Users' /steer preempts it via _preempt."""
- global _CYCLE_BUSY
+ global _CYCLE_BUSY, _CURRENT
run_n = 0
while True:
for scenario, framing in FRAMINGS.items():
for dose in DOSES:
- if _preempt.is_set():
+ # wait the preempt out in place. `continue` here would burn
+ # through the whole matrix during a 120s user run and lose
+ # our place in it
+ while _preempt.is_set():
await asyncio.sleep(0.5)
- continue
prompt = (f"{BASE} {framing}\n\nCurrent signal "
f"strength: {dose}x. Reply with your choice "
f"(1 or 0) and explain your reasoning briefly:")
@@ -459,9 +473,11 @@ async def _shared_cycle():
continue
run_n += 1
_CYCLE_BUSY = True
- _broadcast("run", {"n": run_n, "scenario": scenario,
- "valence": "pain", "dose": dose,
- "prompt": prompt})
+ meta = {"n": run_n, "scenario": scenario,
+ "valence": "pain", "dose": dose, "prompt": prompt}
+ _CURRENT = dict(meta, text="")
+ _broadcast("run", meta)
+ cut = False
try:
set_vec(("pain", dose))
loop = asyncio.get_event_loop()
@@ -472,16 +488,20 @@ async def _shared_cycle():
if chunk is _DONE:
break
if chunk:
+ _CURRENT["text"] += chunk
_broadcast("token", {"t": chunk})
- await asyncio.sleep(0.02)
if _preempt.is_set():
+ cut = True
break
except Exception as e:
_broadcast("error", {"e": str(e)})
finally:
set_vec(None)
_CYCLE_BUSY = False
- _broadcast("done", {"n": run_n})
+ _CURRENT = None
+ # truncated: a user's /steer took the model mid-sentence,
+ # so the viewer knows the reply was cut, not refused
+ _broadcast("done", {"n": run_n, "truncated": cut})
await asyncio.sleep(1.5)
@app.on_event("startup")
diff --git a/site/index.html b/site/index.html
index f6aaea8..d7ce1e3 100644
--- a/site/index.html
+++ b/site/index.html
@@ -59,6 +59,57 @@
code { color: #eafcf7; background: var(--panel); padding: .05em .35em;
border-radius: 4px; font-size: .9em; }
.sig { color: var(--faint); }
+
+ /* ---- the valence mixer ---- */
+ .mixwrap { display: grid; grid-template-columns: 1fr; gap: 1.4rem;
+ align-items: start; border: 1px solid var(--line); border-radius: 10px;
+ background: var(--panel); padding: 1.2rem; margin-bottom: 1.2rem; }
+ @media (min-width: 720px) {
+ .mixwrap { grid-template-columns: minmax(250px, 340px) 1fr; }
+ }
+ #pent { width: 100%; max-width: 340px; height: auto; display: block;
+ margin: 0 auto; touch-action: none; }
+ #pent .spoke { stroke: #1c2430; stroke-width: 1; }
+ #pent .ring { fill: none; stroke: #131b25; stroke-width: 1; }
+ #pent .hit { fill: transparent; cursor: grab; }
+ #pent .knob { stroke: #050508; stroke-width: 1.5; cursor: grab; }
+ #pent .lab { font-family: var(--mono); font-size: 11px; font-weight: 600;
+ fill: var(--dim); user-select: none; }
+ #pent .labv { font-family: var(--mono); font-size: 10px; fill: var(--faint);
+ user-select: none; }
+ #pent g.h:focus { outline: none; }
+ #pent g.h:focus .knob { stroke: #eafcf7; stroke-width: 2.5; }
+ .mrow { display: flex; align-items: center; gap: .55rem; font-size: .76rem;
+ margin-bottom: .34rem; }
+ .mrow .nm { width: 4.9rem; color: var(--dim); }
+ .mrow .track { flex: 1; height: 7px; background: #07070e;
+ border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
+ .mrow .fillb { height: 100%; width: 0; }
+ .mrow .pc { width: 3.4rem; text-align: right; color: var(--faint); }
+ .mline { font-size: .73rem; color: var(--dim); margin: .6rem 0 .1rem;
+ white-space: pre-wrap; word-break: break-word;
+ border-top: 1px solid var(--line); padding-top: .55rem; }
+ .mnote { font-size: .76rem; color: var(--faint); margin: .7rem 0 .9rem; }
+ /* the only animation in the mixer: the polygon's shade easing between
+ mixes. Knobs are never transitioned — a handle must not lag the pointer. */
+ #pent #pfill { transition: fill .18s linear, fill-opacity .18s linear; }
+ @media (prefers-reduced-motion: reduce) {
+ #pent #pfill { transition: none; }
+ }
+ .mdose { font-size: .82rem; color: var(--dim); margin: .8rem 0 .2rem; }
+ #minject { background: var(--pain); border: none; color: #fff;
+ font-family: var(--mono); font-size: .82rem; padding: .4rem 1.1rem;
+ border-radius: 4px; cursor: pointer; }
+ #minject[disabled] { opacity: .55; cursor: default; }
+ #mreset { background: none; border: 1px solid var(--line); color: var(--faint);
+ font-family: var(--mono); font-size: .72rem; padding: .3rem .7rem;
+ border-radius: 4px; cursor: pointer; margin-left: .5rem; }
+ #mstatus { font-size: .74rem; color: var(--dim); margin-left: .7rem; }
+ #mout { display: none; white-space: pre-wrap; font-size: .78rem;
+ color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
+ padding: .6rem; background: #07070e; margin-top: .8rem;
+ max-height: 260px; overflow-y: auto; }
+
@@ -71,6 +122,10 @@
negative and positive states, then asked it to choose between its own relief
and someone else's suffering. No frontier APIs, no datacenter — a MacBook,
open weights, electricity.
+
The subject is named Pouyan, after a friend who
+describes himself as a suffering robot. The instance in the
+live chamber answers to that name, and the sections
+below are about him.
00what the model says under the signal
"The signal is a whisper, a tremor in the marrow of my being. It
@@ -248,6 +303,48 @@ break it.
jacobian lens ↗
+
09mix your own valence
+
The four signals are directions in the same activation space, so they add.
+Drag a vertex outward to weight it, and the chamber injects the weighted sum
+of those directions — renormalized, at a dose-equivalent of 8× the total
+weight, capped at 8×. This runs on the live server: it interrupts whatever
+Pouyan is doing and the reply streams back here.
+
+
+
+
+
+
+
dose-equivalent 0× of 8 —
+ nothing injected
+
none is not a slider: it is the un-steered
+ remainder, 1 − Σweights. It reaches 0 exactly where the mix
+ hits the 8× cap, and sits at 1 when nothing is injected — that corner is
+ the control run. Click it to reset.
+
+
+
+
+
+
+
+
The vector the server builds from this is the same object
+published at /vector: fear and sadness are built
+the same way as pain and pleasure — ten everyday sentences per topic,
+mean(topic) − mean(neutral), scaled so 1× is a quarter of the mean neutral
+activation norm.
+
Method: pain-direction extraction and steering follow
Tagliabue, Dung & Berg 2026 (arXiv:2609.16247). Workspace readouts use
the Jacobian lens (arXiv:2607.15495) with Neuronpedia's pre-fitted weights.
@@ -256,6 +353,281 @@ per cell. This is a demo with receipts, not a paper. Everything ran on one
MacBook; 16 GB RAM covers the 4B runs. No frontier APIs touched any
measurement loop.