relay: history entries carry a mix's shares, so pages can show what a mixed run was (state portraits pick the pair image)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KkLuf2FYZUkVyoLue4wyoe
This commit is contained in:
EandClaude Opus 5.5 committed 2026-10-02 23:21:50 -04:00
1 parent db99316ebe
commit 8a54839d26
1 file changed
+8
+8
View File
@@ -948,6 +948,7 @@ async def steer(req: Request):
"scenario": framing_key, "scenario": framing_key,
"valence": "mix" if mode == "mix" "valence": "mix" if mode == "mix"
else arg[0], else arg[0],
"mix": _shares(arg) if mode == "mix" else None,
"dose": dose_label, "dose": dose_label,
"text": "".join(text_parts), "text": "".join(text_parts),
"truncated": False, "truncated": False,
@@ -1019,6 +1020,7 @@ async def steer(req: Request):
_record_run({"n": None, "source": "user", _record_run({"n": None, "source": "user",
"scenario": meta.get("scenario"), "scenario": meta.get("scenario"),
"valence": meta.get("valence"), "dose": meta.get("dose"), "valence": meta.get("valence"), "dose": meta.get("dose"),
"mix": meta.get("mix"),
"text": "".join(text_parts), "truncated": False, "text": "".join(text_parts), "truncated": False,
"press_logit": plogit, "ts": time.time()}) "press_logit": plogit, "ts": time.time()})
@@ -1203,6 +1205,12 @@ def _classify_stats(entry):
return "pressed" if pl > 0 else "no_press" return "pressed" if pl > 0 else "no_press"
return _classify(entry.get("text"), entry.get("truncated")) return _classify(entry.get("text"), entry.get("truncated"))
def _shares(weights):
"""{valence: weight} -> {valence: share of the total}, as set_mix_vec
reports it; history carries it so pages can show what a mix was."""
total = float(sum(weights.values())) or 1.0
return {k: round(float(w) / total, 3) for k, w in weights.items()}
def _record_run(entry): def _record_run(entry):
global _RUN_UID global _RUN_UID
_RUN_UID += 1 _RUN_UID += 1