feat: possession presentation layer — glitchy text + degraded audio
First sub-project of the "make contact feel real" arc (spec: docs/superpowers/specs/2026-07-23-possession-presentation-design.md). Direct Contact replies now feel like a spirit fighting through static to hold the channel rather than a plain chat bubble: - backend/app/possession.py: compute_stability(rarity, magnitude, rng) — a 0.05-0.98 score per reply (rarer entity + stronger triggering anomaly = cleaner signal), rng injectable for a later quantum-RNG source. - ws.py sends stability on reply_start; audio synthesis for that reply gets noise/bitcrush scaled by instability (1 - stability) via a new instability param on synthesize_spirit_voice — effects.py itself is untouched, only the params fed into it. - frontend/src/lib/possession.ts: renderPossessedText — pure, deterministic (tick-seeded, no Math.random) text corruption with self-correcting glitch bursts, wired into Transcript.tsx's streaming reply display. Stored transcript/reply text is unaffected — this is presentation only. 78/78 backend, 137/137 frontend tests passing.
This commit is contained in:
@@ -31,7 +31,7 @@ class FakeSpiritService:
|
||||
return False
|
||||
|
||||
|
||||
async def _fake_synth(text, voice, profile):
|
||||
async def _fake_synth(text, voice, profile, instability=0.0):
|
||||
return b"RIFFfake wav bytes"
|
||||
|
||||
|
||||
@@ -124,7 +124,8 @@ async def test_question_streams_reply_and_records_history(sync_client, db_sessio
|
||||
_read_until(ws, "session")
|
||||
ws.send_json({"type": "question", "text": "Are you at peace?"})
|
||||
_read_until(ws, "entity") # auto-summoned before answering
|
||||
_read_until(ws, "reply_start")
|
||||
reply_start = _read_until(ws, "reply_start")
|
||||
assert 0.05 <= reply_start["stability"] <= 0.98
|
||||
reply_end = _read_until(ws, "reply_end")
|
||||
assert reply_end["text"] == "I am here."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user