jmisak's picture
Update engine/drift.py
6f32d24 verified
from engine.utils import clamp
def apply_objection_effects(persona, objection):
"""
objection: {"objection": str, "tags": [...], "effects": {trait: delta}}
Applies deltas to persona["dynamic_state"] and clamps values to [0.0, 1.0].
"""
state = persona.setdefault("dynamic_state", {})
effects = objection.get("effects", {})
for trait, delta in effects.items():
current = float(state.get(trait, 0.0))
state[trait] = clamp(current + float(delta), 0.0, 1.0)
return persona