"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
test: stabilize local suite on Windows
Miranda4551fa2f08a6
diff --git a/agent/src/factors/bench_runner.py b/agent/src/factors/bench_runner.pyindex 1f26627f2..7dea8d697 100644--- a/agent/src/factors/bench_runner.py+++ b/agent/src/factors/bench_runner.py@@ -210,18 +210,17 @@ def run_bench(logger.warning("invalid VIBE_TRADING_BENCH_WORKERS; falling back to sequential")n_workers = 1n_workers = max(1, min(n_workers, n_total))+ ctx_kwargs: dict[str, Any] = {}use_parallel = registry is None and n_workers > 1 and n_total > 1-if use_parallel:- ctx_kwargs: dict[str, Any] = {}try:import multiprocessing- ctx = multiprocessing.get_context("fork")- ctx_kwargs["mp_context"] = ctx+ ctx_kwargs["mp_context"] = multiprocessing.get_context("fork")except (ImportError, ValueError):- pass+ use_parallel = False+ if use_parallel:future_to_id: dict[Any, str] = {}with ProcessPoolExecutor(max_workers=n_workers,diff --git a/agent/src/tools/mcp.py b/agent/src/tools/mcp.pyindex 31cf7ff26..e426f76d6 100644--- a/agent/src/tools/mcp.py+++ b/agent/src/tools/mcp.py@@ -11,6 +11,7 @@ import reimport threadingfrom copy import deepcopyfrom dataclasses import dataclass+from pathlib import Pathfrom typing import Any, Awaitable, Callable, Coroutine, Iterable, Protocol, TypeVarfrom fastmcp.client import Client@@ -297,9 +298,7 @@ def _build_token_store(cache_dir: str) -> FileTreeStore:Returns:A ``FileTreeStore`` rooted at the resolved cache directory."""- from pathlib import Path-- path = Path(cache_dir).expanduser()+ path = _expand_cache_dir(cache_dir)path.mkdir(parents=True, exist_ok=True)# 0700: owner-only. Tokens are secrets; no group/other access.os.chmod(path, 0o700)@@ -309,6 +308,20 @@ def _build_token_store(cache_dir: str) -> FileTreeStore:)+def _expand_cache_dir(cache_dir: str) -> Path:+ """Expand cache roots while honoring HOME for test isolation on Windows."""+ value = str(cache_dir)+ if value == "~":+ raw_home = os.getenv("HOME")+ if raw_home:+ return Path(raw_home)+ if value.startswith("~/") or value.startswith("~\\"):+ raw_home = os.getenv("HOME")+ if raw_home:+ return Path(raw_home) / value[2:]+ return Path(value).expanduser()++class MCPServerAdapter:"""Synchronous wrapper around the async FastMCP client."""diff --git a/agent/tests/test_oauth_token_cache.py b/agent/tests/test_oauth_token_cache.pyindex dd7de6537..204873343 100644--- a/agent/tests/test_oauth_token_cache.py+++ b/agent/tests/test_oauth_token_cache.py@@ -26,11 +26,13 @@ from src.tools.mcp import _build_token_storepytestmark = pytest.mark.unit-def _assert_owner_only_mode_on_posix(cache: Path) -> None:- assert cache.is_dir()+def _assert_owner_only_mode(path: Path) -> None:if os.name == "nt":+ # Windows exposes ACLs through a different API and reports directories+ # as 0777 via stat.S_IMODE even after os.chmod(0o700).+ assert path.is_dir()return- mode = stat.S_IMODE(os.stat(cache).st_mode)+ mode = stat.S_IMODE(os.stat(path).st_mode)assert mode == 0o700, f"expected owner-only 0700, got {oct(mode)}"@@ -40,7 +42,8 @@ def test_build_token_store_creates_dir_0700(tmp_path: Path) -> None:_build_token_store(str(cache))- _assert_owner_only_mode_on_posix(cache)+ assert cache.is_dir()+ _assert_owner_only_mode(cache)def test_build_token_store_expands_user(monkeypatch, tmp_path: Path) -> None:@@ -60,7 +63,7 @@ def test_build_token_store_idempotent_on_existing_dir(tmp_path: Path) -> None:_build_token_store(str(cache))# Second call must not raise on an already-existing directory._build_token_store(str(cache))- _assert_owner_only_mode_on_posix(cache)+ _assert_owner_only_mode(cache)def test_token_persists_across_store_instances(tmp_path: Path) -> None: