Skip to content

"Vibe-Trading: Your Personal Trading Agent"

test(market-data): ledger-level search_symbol('GBP/USD') -> get_market_data('GBPUSD=X') cycle

cgycorey7994254898aa
diff --git a/agent/tests/test_agent_grounding.py b/agent/tests/test_agent_grounding.py
index d885843de..96d7d66e6 100644
--- a/agent/tests/test_agent_grounding.py
+++ b/agent/tests/test_agent_grounding.py
@@ -2513,3 +2513,63 @@ class TestFiatPairAndIndexNormalization:
chosen = _normalize_symbol("GBPUSD=X")
asserted = _scan_symbols("GBP/USD")
assert chosen in asserted
+
+
+def test_fx_pair_resolution_authorizes_market_data_consumer(tmp_path: Path) -> None:
+ """Issue: search_symbol('GBP/USD') must lock, and get_market_data('GBPUSD=X')
+ must be authorized — the slashed query used to normalize to the crypto
+ spelling (GBP-USD), disagreeing with the chosen GBPUSD=X candidate and
+ creating a conflicting identity that outranked every later lock.
+ """
+ ledger = GroundingLedger(
+ run_dir=tmp_path,
+ user_message="Get me the GBP/USD spot rate.",
+ )
+ before_resolution = ledger.authorized_symbols
+ resolver = ledger.authorize_tool_call(
+ "search_symbol",
+ {"query": "GBP/USD"},
+ batch_authorized_symbols=before_resolution,
+ call_id="resolve-fx",
+ )
+ assert resolver.allowed is True
+
+ ledger.ingest_tool_result(
+ tool_name="search_symbol",
+ arguments={"query": "GBP/USD"},
+ result=json.dumps(
+ {
+ "ok": True,
+ "source": "symbol_search",
+ "data": {
+ "query": "GBP/USD",
+ "count": 1,
+ "sources": {"yahoo": "ok", "fx_normalizer": "ok"},
+ "candidates": [
+ {
+ "symbol": "GBPUSD=X",
+ "name": "GBP/USD",
+ "market": "fx",
+ "type": "currency",
+ "exchange": "CCY",
+ "source": "fx_normalizer",
+ },
+ ],
+ },
+ }
+ ),
+ call_id="resolve-fx",
+ success=True,
+ )
+
+ authorization = ledger.authorize_tool_call(
+ "get_market_data",
+ {"codes": ["GBPUSD=X"]},
+ batch_authorized_symbols=ledger.authorized_symbols,
+ batch_identity_status=ledger.identity_status,
+ call_id="fx-prices",
+ )
+
+ assert ledger.identity_status == "locked"
+ assert ledger.authorized_symbols == {"GBPUSD=X"}
+ assert authorization.allowed is True