yf176 commited on
Commit ·
a3b84d5
1
Parent(s): 482ed6f
Clarify YOLO options diagnostics
Browse files- src/polyhedra/app.py +19 -1
- tests/test_v611_web_ui.py +30 -0
src/polyhedra/app.py
CHANGED
|
@@ -394,7 +394,7 @@ def _yolo_diagnostics(
|
|
| 394 |
"label": _diagnostic_label("optionsflowwatcher"),
|
| 395 |
"severity": "warning",
|
| 396 |
"status": "data_gap",
|
| 397 |
-
"detail":
|
| 398 |
str(options_context.get("summary") or ""),
|
| 399 |
fallback="Options evidence was excluded or incomplete.",
|
| 400 |
),
|
|
@@ -467,6 +467,24 @@ def _first_meaningful_line(text: str, *, fallback: str) -> str:
|
|
| 467 |
return fallback
|
| 468 |
|
| 469 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
def _diagnostic_label(role: str) -> str:
|
| 471 |
labels = {
|
| 472 |
"datafetcher": "DataFetcher",
|
|
|
|
| 394 |
"label": _diagnostic_label("optionsflowwatcher"),
|
| 395 |
"severity": "warning",
|
| 396 |
"status": "data_gap",
|
| 397 |
+
"detail": _options_issue_detail(
|
| 398 |
str(options_context.get("summary") or ""),
|
| 399 |
fallback="Options evidence was excluded or incomplete.",
|
| 400 |
),
|
|
|
|
| 467 |
return fallback
|
| 468 |
|
| 469 |
|
| 470 |
+
def _options_issue_detail(text: str, *, fallback: str) -> str:
|
| 471 |
+
for line in text.splitlines():
|
| 472 |
+
stripped = line.strip(" -")
|
| 473 |
+
upper = stripped.upper()
|
| 474 |
+
if "DATA_GAP" in upper or "ERROR" in upper or "UNAVAILABLE" in upper:
|
| 475 |
+
return stripped
|
| 476 |
+
for line in text.splitlines():
|
| 477 |
+
stripped = line.strip(" -")
|
| 478 |
+
if (
|
| 479 |
+
stripped
|
| 480 |
+
and not stripped.startswith("#")
|
| 481 |
+
and "paper trading simulation" not in stripped.lower()
|
| 482 |
+
and not stripped.lower().startswith("symbols:")
|
| 483 |
+
):
|
| 484 |
+
return stripped
|
| 485 |
+
return fallback
|
| 486 |
+
|
| 487 |
+
|
| 488 |
def _diagnostic_label(role: str) -> str:
|
| 489 |
labels = {
|
| 490 |
"datafetcher": "DataFetcher",
|
tests/test_v611_web_ui.py
CHANGED
|
@@ -188,6 +188,36 @@ def test_v7_session_api_surfaces_datafetcher_partial_data_warning(
|
|
| 188 |
}
|
| 189 |
|
| 190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
def test_v611_session_api_shows_v5_path_for_non_v6_ticker(tmp_path: Path, monkeypatch) -> None:
|
| 192 |
client = _client(tmp_path, monkeypatch)
|
| 193 |
session = SessionManager().create(goal="YOLO & AAPL Analysis Session", platform="web")
|
|
|
|
| 188 |
}
|
| 189 |
|
| 190 |
|
| 191 |
+
def test_v7_session_api_surfaces_actionable_options_data_gap(
|
| 192 |
+
tmp_path: Path,
|
| 193 |
+
monkeypatch,
|
| 194 |
+
) -> None:
|
| 195 |
+
client = _client(tmp_path, monkeypatch)
|
| 196 |
+
session = SessionManager().create(goal="YOLO & SPY Analysis Session", platform="web")
|
| 197 |
+
session.post("publisher", "Finley final market read.")
|
| 198 |
+
quant_dir = session.session_dir / "quant"
|
| 199 |
+
quant_dir.mkdir()
|
| 200 |
+
(quant_dir / "options_flow_2026-09-04.md").write_text(
|
| 201 |
+
"# Options Flow Watch - 2026-09-04\n"
|
| 202 |
+
"Paper trading simulation only. Not financial advice.\n"
|
| 203 |
+
"Symbols: SPY\n"
|
| 204 |
+
"## FLOW_CANDIDATE\n"
|
| 205 |
+
"- SPY: no candidate; options data unavailable.\n"
|
| 206 |
+
"## Routing Note\n"
|
| 207 |
+
"DATA_GAP. Options evidence is excluded from signal weighting.\n",
|
| 208 |
+
encoding="utf-8",
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
response = client.get(f"/api/sessions/{session.session_id}")
|
| 212 |
+
|
| 213 |
+
payload = response.json()
|
| 214 |
+
assert response.status_code == 200
|
| 215 |
+
issue = payload["diagnostics"]["issues"][0]
|
| 216 |
+
assert issue["agent"] == "optionsflowwatcher"
|
| 217 |
+
assert issue["status"] == "data_gap"
|
| 218 |
+
assert issue["detail"] == "DATA_GAP. Options evidence is excluded from signal weighting."
|
| 219 |
+
|
| 220 |
+
|
| 221 |
def test_v611_session_api_shows_v5_path_for_non_v6_ticker(tmp_path: Path, monkeypatch) -> None:
|
| 222 |
client = _client(tmp_path, monkeypatch)
|
| 223 |
session = SessionManager().create(goal="YOLO & AAPL Analysis Session", platform="web")
|