yf176 commited on
Commit ·
82c1c56
1
Parent(s): 3bcbb4d
fix: align market-event components with evidence paths
Browse files
src/polyhedra/agents/quant/io_registry.py
CHANGED
|
@@ -56,6 +56,9 @@ _TASKS: dict[AgentName, str] = {
|
|
| 56 |
"Set external_event_feed_status to NOT_CONFIGURED, external_event_feed_provider to null, "
|
| 57 |
"and include a DataIssue with component EVENT_FEED and code "
|
| 58 |
"EXTERNAL_EVENT_FEED_NOT_CONFIGURED because no separate external event provider is approved. "
|
|
|
|
|
|
|
|
|
|
| 59 |
"Copy every evidence reference used by observed_changes or relevant_catalysts into the "
|
| 60 |
"context's source_refs list. "
|
| 61 |
"Do not invent events, providers, data, or trading conclusions."
|
|
|
|
| 56 |
"Set external_event_feed_status to NOT_CONFIGURED, external_event_feed_provider to null, "
|
| 57 |
"and include a DataIssue with component EVENT_FEED and code "
|
| 58 |
"EXTERNAL_EVENT_FEED_NOT_CONFIGURED because no separate external event provider is approved. "
|
| 59 |
+
"For each observed change, choose component from the cited JSON path exactly: OHLCV only "
|
| 60 |
+
"for /ohlcv/ paths, INDICATORS only for /indicators/points/ paths, NEWS only for /news/ "
|
| 61 |
+
"paths, and EARNINGS only for /earnings/ paths. Do not classify a path by the prose topic. "
|
| 62 |
"Copy every evidence reference used by observed_changes or relevant_catalysts into the "
|
| 63 |
"context's source_refs list. "
|
| 64 |
"Do not invent events, providers, data, or trading conclusions."
|
tests/test_market_event_typed.py
CHANGED
|
@@ -285,6 +285,7 @@ async def test_typed_market_event_uses_structured_llm_and_publishes(tmp_path: Pa
|
|
| 285 |
assert llm.complete.await_count == 1
|
| 286 |
prompt = llm.complete.call_args.args[0]
|
| 287 |
assert "external_event_feed_status to NOT_CONFIGURED" in prompt
|
|
|
|
| 288 |
assert "next_role" not in prompt
|
| 289 |
assert state["quant_state"]["token_log"][0]["prompt_tokens"] == 13
|
| 290 |
output = MarketEventWatcherOutput.model_validate_json(
|
|
@@ -312,6 +313,23 @@ async def test_typed_market_event_rejects_invented_catalyst(tmp_path: Path):
|
|
| 312 |
assert not (session / "quant/runs/run1/market_events.json").exists()
|
| 313 |
|
| 314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
@pytest.mark.asyncio
|
| 316 |
async def test_typed_market_event_rejects_unapproved_external_feed(tmp_path: Path):
|
| 317 |
_, _, _, files, publisher, inputs, raw_ref = publish_dependencies(tmp_path)
|
|
|
|
| 285 |
assert llm.complete.await_count == 1
|
| 286 |
prompt = llm.complete.call_args.args[0]
|
| 287 |
assert "external_event_feed_status to NOT_CONFIGURED" in prompt
|
| 288 |
+
assert "INDICATORS only for /indicators/points/ paths" in prompt
|
| 289 |
assert "next_role" not in prompt
|
| 290 |
assert state["quant_state"]["token_log"][0]["prompt_tokens"] == 13
|
| 291 |
output = MarketEventWatcherOutput.model_validate_json(
|
|
|
|
| 313 |
assert not (session / "quant/runs/run1/market_events.json").exists()
|
| 314 |
|
| 315 |
|
| 316 |
+
@pytest.mark.asyncio
|
| 317 |
+
async def test_typed_market_event_rejects_component_path_mismatch(tmp_path: Path):
|
| 318 |
+
session, _, _, files, publisher, inputs, raw_ref = publish_dependencies(tmp_path)
|
| 319 |
+
data = event_payload(raw_ref).model_dump(mode="json")
|
| 320 |
+
data["ticker_contexts"][0]["observed_changes"][0]["component"] = "INDICATORS"
|
| 321 |
+
llm = ControlledLLM(MarketEventPayload.model_validate(data))
|
| 322 |
+
|
| 323 |
+
with pytest.raises(ValueError, match="component contradicts"):
|
| 324 |
+
await MarketEventWatcher(llm).execute_typed(
|
| 325 |
+
inputs,
|
| 326 |
+
files=files,
|
| 327 |
+
publisher=publisher,
|
| 328 |
+
now=lambda: AT,
|
| 329 |
+
)
|
| 330 |
+
assert not (session / "quant/runs/run1/market_events.json").exists()
|
| 331 |
+
|
| 332 |
+
|
| 333 |
@pytest.mark.asyncio
|
| 334 |
async def test_typed_market_event_rejects_unapproved_external_feed(tmp_path: Path):
|
| 335 |
_, _, _, files, publisher, inputs, raw_ref = publish_dependencies(tmp_path)
|