MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / test_on_feedback_updates_weights

Function test_on_feedback_updates_weights

tests/test_v2_lifecycle.py:81–102  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

79
80
81def test_on_feedback_updates_weights(tmp_path):
82 _reset_lifecycle()
83 lc.on_startup(tmp_path)
84 old_weights = list(lc._weight_tracker.weights)
85 # Simulate: Signal A predicted 0, Signal C predicted 2 (disagree)
86 lc.on_route_complete(
87 request_id="", tier_id=1, model="test", method="direct", confidence=0.8,
88 signal_a_tier=0, signal_a_conf=0.8,
89 signal_b_tier=1, signal_b_conf=0.7,
90 signal_c_tier=2, signal_c_conf=0.8,
91 )
92 lc.associate_request_id("req_feedback_test")
93 # Feedback: "weak" on SIMPLE → actual_tier = min(0+1,3) = 1
94 # Signal A predicted 0 (wrong), Signal C predicted 2 (wrong) → both penalized
95 # But different predictions → weight ratio changes after normalization
96 lc.on_feedback(request_id="req_feedback_test", signal="ok", routed_tier_v1="SIMPLE")
97 new_weights = lc._weight_tracker.weights
98 # Signal A predicted 0, actual=0 (ok→same) → rewarded
99 # Signal C predicted 2, actual=0 → penalized
100 # Weights should diverge
101 assert new_weights[0] > old_weights[0] # A rewarded
102 _reset_lifecycle()
103
104
105def test_persistence_roundtrip(tmp_path):

Callers

nothing calls this directly

Calls 1

_reset_lifecycleFunction · 0.85

Tested by

no test coverage detected