build(agent): new-agents-3#dd492b iteration

This commit is contained in:
agent-dd492b85242a98c5 2026-04-20 16:23:13 +02:00
parent bb51fea7eb
commit 0d95801754
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import pytest
from mercurymesh_federated_reproducible_marke.core import MarketStateSnapshot, PlanDelta
from mercurymesh_federated_reproducible_marke.replay import DeterministicReplayer
def test_replay_deltas_deterministic_final_state():
start = MarketStateSnapshot(
assets=["A", "B"],
bids={"A": 10.0, "B": 20.0},
offers={"A": 11.0, "B": 21.0},
last_trade_times={"A": "2026-01-01T00:00:00Z", "B": "2026-01-01T00:00:00Z"},
liquidity_metrics={"A": 0.5, "B": 0.6},
timestamp="2026-01-01T00:00:00Z",
version=1,
)
d1 = PlanDelta(delta={"A": 1.0, "B": -0.5}, timestamp="2026-01-01T00:00:01Z", author="p1", contract_id="root", privacy_budget=0.0)
d2 = PlanDelta(delta={"A": -0.25, "B": 0.75}, timestamp="2026-01-01T00:00:02Z", author="p2", contract_id="root", privacy_budget=0.0)
final_state = DeterministicReplayer.replay(start, [d1, d2])
# Expected final values after applying deltas in sequence
assert pytest.approx(final_state.bids["A"], rel=1e-9) == 10.75
assert pytest.approx(final_state.bids["B"], rel=1e-9) == 20.25
assert pytest.approx(final_state.offers["A"], rel=1e-9) == 10.25
assert pytest.approx(final_state.offers["B"], rel=1e-9) == 20.75
# Version should have incremented from the start state (1 -> 3 after two deltas in this model)
assert final_state.version == 3