yf176 commited on
Commit ·
fc6c92e
1
Parent(s): 0c711d8
Surface YOLO pipeline diagnostics
Browse files- src/polyhedra/agents/quant/publisher.py +8 -2
- src/polyhedra/app.py +129 -1
- src/polyhedra/web/static/index.html +42 -0
- tests/test_v611_web_ui.py +42 -0
- tests/test_yolo_context.py +16 -0
src/polyhedra/agents/quant/publisher.py
CHANGED
|
@@ -26,6 +26,10 @@ logger = logging.getLogger(__name__)
|
|
| 26 |
|
| 27 |
_DISCLAIMER = "⚠️ This is a paper trading simulation. Not financial advice."
|
| 28 |
_NOT_AVAILABLE = "_not available_"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
_SYSTEM_PROMPT = """\
|
| 31 |
You are Finley, a financial market commentator who writes short, \
|
|
@@ -200,7 +204,7 @@ class PublisherAgent(Agent):
|
|
| 200 |
proposals_section = (
|
| 201 |
proposals_md[:3000]
|
| 202 |
if proposals_md
|
| 203 |
-
else
|
| 204 |
)
|
| 205 |
trend_section = trend_md[:2000] if trend_md else _NOT_AVAILABLE
|
| 206 |
|
|
@@ -249,7 +253,9 @@ Write a short market post following this exact structure:
|
|
| 249 |
If trade proposals exist, list them all (one per line):
|
| 250 |
📊 Signal (paper trade): [direction] [entry condition] | Target [TP] | Stop [SL]
|
| 251 |
If no proposals exist, write:
|
| 252 |
-
|
|
|
|
|
|
|
| 253 |
|
| 254 |
**DISCLAIMER** (always, verbatim, final line):
|
| 255 |
⚠️ This is a paper trading simulation. Not financial advice.
|
|
|
|
| 26 |
|
| 27 |
_DISCLAIMER = "⚠️ This is a paper trading simulation. Not financial advice."
|
| 28 |
_NOT_AVAILABLE = "_not available_"
|
| 29 |
+
_NO_PROPOSAL_NOTE = (
|
| 30 |
+
"No approved paper trade proposal is available from QuantStrategist. "
|
| 31 |
+
"Use the watch/no-trade rationale and confirmation conditions in the analysis above."
|
| 32 |
+
)
|
| 33 |
|
| 34 |
_SYSTEM_PROMPT = """\
|
| 35 |
You are Finley, a financial market commentator who writes short, \
|
|
|
|
| 204 |
proposals_section = (
|
| 205 |
proposals_md[:3000]
|
| 206 |
if proposals_md
|
| 207 |
+
else _NO_PROPOSAL_NOTE
|
| 208 |
)
|
| 209 |
trend_section = trend_md[:2000] if trend_md else _NOT_AVAILABLE
|
| 210 |
|
|
|
|
| 253 |
If trade proposals exist, list them all (one per line):
|
| 254 |
📊 Signal (paper trade): [direction] [entry condition] | Target [TP] | Stop [SL]
|
| 255 |
If no proposals exist, write:
|
| 256 |
+
No approved paper trade proposal is available. State whether the upstream
|
| 257 |
+
outcome is NO_TRADE or WATCH_FOR_CONFIRMATION when the inputs say so, and
|
| 258 |
+
briefly name the missing confirmation or failed evidence gate.
|
| 259 |
|
| 260 |
**DISCLAIMER** (always, verbatim, final line):
|
| 261 |
⚠️ This is a paper trading simulation. Not financial advice.
|
src/polyhedra/app.py
CHANGED
|
@@ -248,6 +248,13 @@ def _session_payload(session_id: str) -> dict[str, Any] | None:
|
|
| 248 |
"label": _ROLE_LABELS.get(blocked_role, blocked_role),
|
| 249 |
}
|
| 250 |
committee = _strategist_committee_payload(session.session_dir, quant_state)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
blocked_payload = {}
|
| 252 |
if blocker:
|
| 253 |
blocked_payload = {
|
|
@@ -281,7 +288,8 @@ def _session_payload(session_id: str) -> dict[str, Any] | None:
|
|
| 281 |
"messages": messages,
|
| 282 |
"finley": finley,
|
| 283 |
"committee": committee,
|
| 284 |
-
"options_context":
|
|
|
|
| 285 |
"run_status_message": run.get("status_message", ""),
|
| 286 |
"error": run.get("error", "") or (blocker.get("message", "") if blocker else ""),
|
| 287 |
}
|
|
@@ -346,6 +354,125 @@ def _is_unavailable_llm_content(content: str) -> bool:
|
|
| 346 |
)
|
| 347 |
|
| 348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
def _latest_artifact_text(session_dir: Path, prefix: str) -> str:
|
| 350 |
quant_dir = session_dir / "quant"
|
| 351 |
if not quant_dir.exists():
|
|
@@ -667,6 +794,7 @@ def create_app():
|
|
| 667 |
"finley": payload["finley"],
|
| 668 |
"committee": payload["committee"],
|
| 669 |
"options_context": payload["options_context"],
|
|
|
|
| 670 |
"run_status_message": payload["run_status_message"],
|
| 671 |
"error": payload["error"],
|
| 672 |
})
|
|
|
|
| 248 |
"label": _ROLE_LABELS.get(blocked_role, blocked_role),
|
| 249 |
}
|
| 250 |
committee = _strategist_committee_payload(session.session_dir, quant_state)
|
| 251 |
+
options_context = _summarize_options_artifact(options_artifact)
|
| 252 |
+
diagnostics = _yolo_diagnostics(
|
| 253 |
+
session.session_dir,
|
| 254 |
+
path_messages,
|
| 255 |
+
blocker=blocker,
|
| 256 |
+
options_context=options_context,
|
| 257 |
+
)
|
| 258 |
blocked_payload = {}
|
| 259 |
if blocker:
|
| 260 |
blocked_payload = {
|
|
|
|
| 288 |
"messages": messages,
|
| 289 |
"finley": finley,
|
| 290 |
"committee": committee,
|
| 291 |
+
"options_context": options_context,
|
| 292 |
+
"diagnostics": diagnostics,
|
| 293 |
"run_status_message": run.get("status_message", ""),
|
| 294 |
"error": run.get("error", "") or (blocker.get("message", "") if blocker else ""),
|
| 295 |
}
|
|
|
|
| 354 |
)
|
| 355 |
|
| 356 |
|
| 357 |
+
def _yolo_diagnostics(
|
| 358 |
+
session_dir: Path,
|
| 359 |
+
messages: list[dict[str, Any]],
|
| 360 |
+
*,
|
| 361 |
+
blocker: dict[str, str] | None,
|
| 362 |
+
options_context: dict[str, Any],
|
| 363 |
+
) -> dict[str, Any]:
|
| 364 |
+
issues: list[dict[str, str]] = []
|
| 365 |
+
if blocker:
|
| 366 |
+
role = blocker.get("role", "")
|
| 367 |
+
issues.append({
|
| 368 |
+
"agent": role,
|
| 369 |
+
"label": _diagnostic_label(role),
|
| 370 |
+
"severity": "blocked",
|
| 371 |
+
"status": "blocked",
|
| 372 |
+
"detail": blocker.get("message", ""),
|
| 373 |
+
})
|
| 374 |
+
|
| 375 |
+
data_issue = _latest_raw_data_quality_issue(session_dir)
|
| 376 |
+
if data_issue:
|
| 377 |
+
issues.append(data_issue)
|
| 378 |
+
|
| 379 |
+
if options_context.get("status") == "data_gap":
|
| 380 |
+
issues.append({
|
| 381 |
+
"agent": "optionsflowwatcher",
|
| 382 |
+
"label": _diagnostic_label("optionsflowwatcher"),
|
| 383 |
+
"severity": "warning",
|
| 384 |
+
"status": "data_gap",
|
| 385 |
+
"detail": _first_meaningful_line(
|
| 386 |
+
str(options_context.get("summary") or ""),
|
| 387 |
+
fallback="Options evidence was excluded or incomplete.",
|
| 388 |
+
),
|
| 389 |
+
})
|
| 390 |
+
|
| 391 |
+
for message in messages:
|
| 392 |
+
content = str(message.get("content", ""))
|
| 393 |
+
role = str(message.get("from_role", "agent"))
|
| 394 |
+
if _is_unavailable_llm_content(content):
|
| 395 |
+
issues.append({
|
| 396 |
+
"agent": role,
|
| 397 |
+
"label": _diagnostic_label(role),
|
| 398 |
+
"severity": "blocked",
|
| 399 |
+
"status": "llm_unavailable",
|
| 400 |
+
"detail": f"@{role} could not complete because the configured LLM was unavailable.",
|
| 401 |
+
})
|
| 402 |
+
|
| 403 |
+
deduped: list[dict[str, str]] = []
|
| 404 |
+
seen: set[tuple[str, str, str]] = set()
|
| 405 |
+
for issue in issues:
|
| 406 |
+
key = (issue.get("agent", ""), issue.get("status", ""), issue.get("detail", ""))
|
| 407 |
+
if key in seen:
|
| 408 |
+
continue
|
| 409 |
+
seen.add(key)
|
| 410 |
+
deduped.append(issue)
|
| 411 |
+
|
| 412 |
+
summary = "No YOLO pipeline issues detected."
|
| 413 |
+
if deduped:
|
| 414 |
+
first = deduped[0]
|
| 415 |
+
summary = f"{first['label']}: {first['detail']}"
|
| 416 |
+
return {"summary": summary, "issues": deduped}
|
| 417 |
+
|
| 418 |
+
|
| 419 |
+
def _latest_raw_data_quality_issue(session_dir: Path) -> dict[str, str] | None:
|
| 420 |
+
raw_dir = session_dir / "quant" / "raw"
|
| 421 |
+
if not raw_dir.exists():
|
| 422 |
+
return None
|
| 423 |
+
summaries = sorted(raw_dir.glob("*_summary.md"))
|
| 424 |
+
for path in reversed(summaries):
|
| 425 |
+
text = path.read_text(encoding="utf-8", errors="replace")
|
| 426 |
+
if "## Data Quality" not in text:
|
| 427 |
+
continue
|
| 428 |
+
section = text.split("## Data Quality", 1)[1].split("\n## ", 1)[0]
|
| 429 |
+
lines = [line.strip(" -") for line in section.splitlines() if line.strip()]
|
| 430 |
+
status_line = next((line for line in lines if line.startswith("OHLCV status:")), "")
|
| 431 |
+
if "provider_partial_data" not in status_line:
|
| 432 |
+
continue
|
| 433 |
+
detail_parts = [line for line in lines if not line.startswith("OHLCV status:")][:4]
|
| 434 |
+
detail = "; ".join(detail_parts) or "Provider returned partial OHLCV rows; invalid rows were excluded."
|
| 435 |
+
return {
|
| 436 |
+
"agent": "datafetcher",
|
| 437 |
+
"label": _diagnostic_label("datafetcher"),
|
| 438 |
+
"severity": "warning",
|
| 439 |
+
"status": "provider_partial_data",
|
| 440 |
+
"detail": detail,
|
| 441 |
+
}
|
| 442 |
+
return None
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
def _first_meaningful_line(text: str, *, fallback: str) -> str:
|
| 446 |
+
for line in text.splitlines():
|
| 447 |
+
stripped = line.strip()
|
| 448 |
+
if stripped and not stripped.startswith("#"):
|
| 449 |
+
return stripped
|
| 450 |
+
return fallback
|
| 451 |
+
|
| 452 |
+
|
| 453 |
+
def _diagnostic_label(role: str) -> str:
|
| 454 |
+
labels = {
|
| 455 |
+
"datafetcher": "DataFetcher",
|
| 456 |
+
"trendanalyst": "TrendAnalyst",
|
| 457 |
+
"sentimentanalyst": "SentimentAnalyst",
|
| 458 |
+
"marketeventwatcher": "MarketEventWatcher",
|
| 459 |
+
"optionsflowwatcher": "OptionsFlowWatcher",
|
| 460 |
+
"macrocontextwatcher": "MacroContextWatcher",
|
| 461 |
+
"unusualeventdetector": "UnusualEventDetector",
|
| 462 |
+
"eventrouter": "EventRouter",
|
| 463 |
+
"btcanalyst": "BTCAnalyst",
|
| 464 |
+
"spyanalyst": "SPYAnalyst",
|
| 465 |
+
"qqqanalyst": "QQQAnalyst",
|
| 466 |
+
"gldanalyst": "GLDAnalyst",
|
| 467 |
+
"quantresearcher": "QuantResearcher",
|
| 468 |
+
"backtester": "Backtester",
|
| 469 |
+
"riskanalyst": "RiskAnalyst",
|
| 470 |
+
"quantstrategist": "QuantStrategist",
|
| 471 |
+
"publisher": "Finley",
|
| 472 |
+
}
|
| 473 |
+
return labels.get(role, role or "YOLO")
|
| 474 |
+
|
| 475 |
+
|
| 476 |
def _latest_artifact_text(session_dir: Path, prefix: str) -> str:
|
| 477 |
quant_dir = session_dir / "quant"
|
| 478 |
if not quant_dir.exists():
|
|
|
|
| 794 |
"finley": payload["finley"],
|
| 795 |
"committee": payload["committee"],
|
| 796 |
"options_context": payload["options_context"],
|
| 797 |
+
"diagnostics": payload["diagnostics"],
|
| 798 |
"run_status_message": payload["run_status_message"],
|
| 799 |
"error": payload["error"],
|
| 800 |
})
|
src/polyhedra/web/static/index.html
CHANGED
|
@@ -147,6 +147,27 @@
|
|
| 147 |
line-height: 1.35;
|
| 148 |
}
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
.progress {
|
| 151 |
display: grid;
|
| 152 |
gap: 8px;
|
|
@@ -281,6 +302,7 @@
|
|
| 281 |
<div id="currentAgent" class="current-agent">Current agent: idle</div>
|
| 282 |
<div id="blockedDetail" class="blocked-detail"></div>
|
| 283 |
<div id="statusPill" class="status-pill">idle</div>
|
|
|
|
| 284 |
<div id="progress" class="progress"></div>
|
| 285 |
<div class="actions">
|
| 286 |
<a id="downloadLink" class="download" href="#" style="display:none">Download Run Package</a>
|
|
@@ -322,6 +344,7 @@
|
|
| 322 |
const statusPill = document.getElementById("statusPill");
|
| 323 |
const currentAgent = document.getElementById("currentAgent");
|
| 324 |
const blockedDetail = document.getElementById("blockedDetail");
|
|
|
|
| 325 |
const progress = document.getElementById("progress");
|
| 326 |
const finleyOutput = document.getElementById("finleyOutput");
|
| 327 |
const optionsOutput = document.getElementById("optionsOutput");
|
|
@@ -352,6 +375,7 @@
|
|
| 352 |
: "";
|
| 353 |
statusPill.textContent = payload.status || "running";
|
| 354 |
statusPill.className = `status-pill ${payload.status || ""}`;
|
|
|
|
| 355 |
downloadLink.href = `/api/sessions/${payload.session_id}/export`;
|
| 356 |
downloadLink.style.display = "inline-flex";
|
| 357 |
runAgainButton.style.display = "inline-flex";
|
|
@@ -379,6 +403,24 @@
|
|
| 379 |
}
|
| 380 |
}
|
| 381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
function renderCommittee(committee) {
|
| 383 |
const votes = committee.votes || [];
|
| 384 |
const weights = committee.weights || {};
|
|
|
|
| 147 |
line-height: 1.35;
|
| 148 |
}
|
| 149 |
|
| 150 |
+
.diagnostics {
|
| 151 |
+
display: grid;
|
| 152 |
+
gap: 8px;
|
| 153 |
+
margin-top: 12px;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.diagnostic-row {
|
| 157 |
+
border: 1px solid var(--line);
|
| 158 |
+
border-left: 4px solid #a8b2bc;
|
| 159 |
+
border-radius: 7px;
|
| 160 |
+
padding: 10px;
|
| 161 |
+
background: #fbfcfd;
|
| 162 |
+
font-size: 13px;
|
| 163 |
+
line-height: 1.35;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.diagnostic-row.warning { border-left-color: var(--warn); background: #fffdf6; }
|
| 167 |
+
.diagnostic-row.blocked { border-left-color: var(--bad); background: #fff8f7; }
|
| 168 |
+
.diagnostic-row strong { display: block; }
|
| 169 |
+
.diagnostic-row span { color: var(--muted); display: block; margin-top: 4px; }
|
| 170 |
+
|
| 171 |
.progress {
|
| 172 |
display: grid;
|
| 173 |
gap: 8px;
|
|
|
|
| 302 |
<div id="currentAgent" class="current-agent">Current agent: idle</div>
|
| 303 |
<div id="blockedDetail" class="blocked-detail"></div>
|
| 304 |
<div id="statusPill" class="status-pill">idle</div>
|
| 305 |
+
<div id="diagnostics" class="diagnostics"></div>
|
| 306 |
<div id="progress" class="progress"></div>
|
| 307 |
<div class="actions">
|
| 308 |
<a id="downloadLink" class="download" href="#" style="display:none">Download Run Package</a>
|
|
|
|
| 344 |
const statusPill = document.getElementById("statusPill");
|
| 345 |
const currentAgent = document.getElementById("currentAgent");
|
| 346 |
const blockedDetail = document.getElementById("blockedDetail");
|
| 347 |
+
const diagnosticsEl = document.getElementById("diagnostics");
|
| 348 |
const progress = document.getElementById("progress");
|
| 349 |
const finleyOutput = document.getElementById("finleyOutput");
|
| 350 |
const optionsOutput = document.getElementById("optionsOutput");
|
|
|
|
| 375 |
: "";
|
| 376 |
statusPill.textContent = payload.status || "running";
|
| 377 |
statusPill.className = `status-pill ${payload.status || ""}`;
|
| 378 |
+
renderDiagnostics(payload.diagnostics || {});
|
| 379 |
downloadLink.href = `/api/sessions/${payload.session_id}/export`;
|
| 380 |
downloadLink.style.display = "inline-flex";
|
| 381 |
runAgainButton.style.display = "inline-flex";
|
|
|
|
| 403 |
}
|
| 404 |
}
|
| 405 |
|
| 406 |
+
function renderDiagnostics(diagnostics) {
|
| 407 |
+
const issues = diagnostics.issues || [];
|
| 408 |
+
if (!issues.length) {
|
| 409 |
+
diagnosticsEl.innerHTML = "";
|
| 410 |
+
return;
|
| 411 |
+
}
|
| 412 |
+
diagnosticsEl.innerHTML = issues.slice(0, 5).map((issue) => {
|
| 413 |
+
const severity = escapeHtml(issue.severity || "warning");
|
| 414 |
+
const label = escapeHtml(issue.label || issue.agent || "YOLO");
|
| 415 |
+
const status = escapeHtml(issue.status || "issue");
|
| 416 |
+
const detail = escapeHtml(issue.detail || "");
|
| 417 |
+
return `<div class="diagnostic-row ${severity}">
|
| 418 |
+
<strong>${label} - ${status}</strong>
|
| 419 |
+
<span>${detail}</span>
|
| 420 |
+
</div>`;
|
| 421 |
+
}).join("");
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
function renderCommittee(committee) {
|
| 425 |
const votes = committee.votes || [];
|
| 426 |
const weights = committee.weights || {};
|
tests/test_v611_web_ui.py
CHANGED
|
@@ -100,6 +100,7 @@ def test_v611_session_api_surfaces_finley_options_and_export(tmp_path: Path, mon
|
|
| 100 |
assert payload["workflow"] == "V6 specialized quant path"
|
| 101 |
assert payload["finley"]["content"] == "Finley final market read."
|
| 102 |
assert payload["options_context"]["status"] == "ok"
|
|
|
|
| 103 |
assert export_response.status_code == 200
|
| 104 |
assert export_response.headers["content-type"] == "application/zip"
|
| 105 |
|
|
@@ -122,10 +123,50 @@ def test_v611_session_api_marks_llm_fallback_as_blocked(tmp_path: Path, monkeypa
|
|
| 122 |
"label": "TrendAnalyst",
|
| 123 |
"reason": "@trendanalyst could not run because the configured LLM service is unavailable.",
|
| 124 |
}
|
|
|
|
|
|
|
| 125 |
trend_step = next(step for step in payload["path"] if step["role"] == "trendanalyst")
|
| 126 |
assert trend_step["status"] == "blocked"
|
| 127 |
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
def test_v611_session_api_shows_v5_path_for_non_v6_ticker(tmp_path: Path, monkeypatch) -> None:
|
| 130 |
client = _client(tmp_path, monkeypatch)
|
| 131 |
session = SessionManager().create(goal="YOLO & AAPL Analysis Session", platform="web")
|
|
@@ -215,6 +256,7 @@ def test_v7_ui_contains_current_agent_and_committee_panels(
|
|
| 215 |
assert response.status_code == 200
|
| 216 |
assert 'id="currentAgent"' in html
|
| 217 |
assert 'id="blockedDetail"' in html
|
|
|
|
| 218 |
assert 'id="committeeVotes"' in html
|
| 219 |
assert "QuantStrategists" in html
|
| 220 |
assert "Paper trading simulation only." in html
|
|
|
|
| 100 |
assert payload["workflow"] == "V6 specialized quant path"
|
| 101 |
assert payload["finley"]["content"] == "Finley final market read."
|
| 102 |
assert payload["options_context"]["status"] == "ok"
|
| 103 |
+
assert payload["diagnostics"]["issues"] == []
|
| 104 |
assert export_response.status_code == 200
|
| 105 |
assert export_response.headers["content-type"] == "application/zip"
|
| 106 |
|
|
|
|
| 123 |
"label": "TrendAnalyst",
|
| 124 |
"reason": "@trendanalyst could not run because the configured LLM service is unavailable.",
|
| 125 |
}
|
| 126 |
+
assert payload["diagnostics"]["issues"][0]["agent"] == "trendanalyst"
|
| 127 |
+
assert payload["diagnostics"]["issues"][0]["status"] == "blocked"
|
| 128 |
trend_step = next(step for step in payload["path"] if step["role"] == "trendanalyst")
|
| 129 |
assert trend_step["status"] == "blocked"
|
| 130 |
|
| 131 |
|
| 132 |
+
def test_v7_session_api_surfaces_datafetcher_partial_data_warning(
|
| 133 |
+
tmp_path: Path,
|
| 134 |
+
monkeypatch,
|
| 135 |
+
) -> None:
|
| 136 |
+
client = _client(tmp_path, monkeypatch)
|
| 137 |
+
session = SessionManager().create(goal="YOLO & SPY Analysis Session", platform="web")
|
| 138 |
+
session.post("publisher", "Finley final market read.")
|
| 139 |
+
raw_dir = session.session_dir / "quant" / "raw"
|
| 140 |
+
raw_dir.mkdir(parents=True)
|
| 141 |
+
(raw_dir / "SPY_2026-09-04_summary.md").write_text(
|
| 142 |
+
"# Raw Market Data Summary: SPY\n\n"
|
| 143 |
+
"## Data Quality\n"
|
| 144 |
+
"OHLCV status: provider_partial_data\n"
|
| 145 |
+
"- Rows with invalid OHLC prices were excluded.\n"
|
| 146 |
+
"- Excluded provider rows:\n"
|
| 147 |
+
" - 2026-09-03: invalid price fields: 1. open, 2. high, 3. low, 4. close; "
|
| 148 |
+
"reported volume=42648446\n",
|
| 149 |
+
encoding="utf-8",
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
response = client.get(f"/api/sessions/{session.session_id}")
|
| 153 |
+
|
| 154 |
+
payload = response.json()
|
| 155 |
+
assert response.status_code == 200
|
| 156 |
+
assert payload["status"] == "completed"
|
| 157 |
+
assert payload["diagnostics"]["issues"][0] == {
|
| 158 |
+
"agent": "datafetcher",
|
| 159 |
+
"label": "DataFetcher",
|
| 160 |
+
"severity": "warning",
|
| 161 |
+
"status": "provider_partial_data",
|
| 162 |
+
"detail": (
|
| 163 |
+
"Rows with invalid OHLC prices were excluded.; Excluded provider rows:; "
|
| 164 |
+
"2026-09-03: invalid price fields: 1. open, 2. high, 3. low, 4. close; "
|
| 165 |
+
"reported volume=42648446"
|
| 166 |
+
),
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
|
| 170 |
def test_v611_session_api_shows_v5_path_for_non_v6_ticker(tmp_path: Path, monkeypatch) -> None:
|
| 171 |
client = _client(tmp_path, monkeypatch)
|
| 172 |
session = SessionManager().create(goal="YOLO & AAPL Analysis Session", platform="web")
|
|
|
|
| 256 |
assert response.status_code == 200
|
| 257 |
assert 'id="currentAgent"' in html
|
| 258 |
assert 'id="blockedDetail"' in html
|
| 259 |
+
assert 'id="diagnostics"' in html
|
| 260 |
assert 'id="committeeVotes"' in html
|
| 261 |
assert "QuantStrategists" in html
|
| 262 |
assert "Paper trading simulation only." in html
|
tests/test_yolo_context.py
CHANGED
|
@@ -211,6 +211,22 @@ def test_finley_delta_brief_prompt_requires_change_categories() -> None:
|
|
| 211 |
assert "confirmation/invalidation conditions" in prompt
|
| 212 |
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
@pytest.mark.asyncio
|
| 215 |
async def test_finley_publishes_readable_delta_brief(tmp_path: Path) -> None:
|
| 216 |
files = FileWriter(tmp_path)
|
|
|
|
| 211 |
assert "confirmation/invalidation conditions" in prompt
|
| 212 |
|
| 213 |
|
| 214 |
+
def test_finley_no_trade_prompt_uses_product_language() -> None:
|
| 215 |
+
prompt = PublisherAgent()._build_prompt(
|
| 216 |
+
proposals_md=None,
|
| 217 |
+
trend_md="Trend is inconclusive.",
|
| 218 |
+
sentiment_md="_not available_",
|
| 219 |
+
risk_md="Risk rejected all setups.",
|
| 220 |
+
asset_analysis_md="SPY outcome: NO_TRADE.",
|
| 221 |
+
macro_context_md="Macro mixed.",
|
| 222 |
+
is_rewrite=False,
|
| 223 |
+
)
|
| 224 |
+
|
| 225 |
+
assert "No approved paper trade proposal is available from QuantStrategist." in prompt
|
| 226 |
+
assert "No trade proposals available yet" not in prompt
|
| 227 |
+
assert "signal footnote omitted" not in prompt
|
| 228 |
+
|
| 229 |
+
|
| 230 |
@pytest.mark.asyncio
|
| 231 |
async def test_finley_publishes_readable_delta_brief(tmp_path: Path) -> None:
|
| 232 |
files = FileWriter(tmp_path)
|