from app.scorer import score_with_trace from app.trace_view import shape_trace def test_shape_basic(): _s, _raw, trace = score_with_trace("i hate you so much") out = shape_trace(trace) assert out["words"] and "role" in out["words"][0] assert isinstance(out["structures"], list) assert isinstance(out["contributors"], list) assert "unknown_tokens" in out and isinstance(out["unknown_tokens"], list) assert "suspected_gap" in out def test_structures_are_clean_names(): # structures must be short pattern names, not the StructureMatch(...) repr _s, _raw, trace = score_with_trace("i hate you so much, you are worthless garbage") out = shape_trace(trace) for name in out["structures"]: assert isinstance(name, str) assert "StructureMatch(" not in name and "(" not in name assert name == name.strip() and name def test_unknown_flagged(): _s, _raw, trace = score_with_trace("ngl this kinda mid lowkey") out = shape_trace(trace) assert isinstance(out["unknown_tokens"], list)