"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(goal): reject goal evidence artifacts from outside the claimed run
Lanre Shittua973319cfd90
diff --git a/agent/src/tools/goal_tool.py b/agent/src/tools/goal_tool.pyindex f607a6ac8..c9b37bca3 100644--- a/agent/src/tools/goal_tool.py+++ b/agent/src/tools/goal_tool.py@@ -94,7 +94,13 @@ def _trace_fields_from_runtime(kwargs: dict[str, Any]) -> tuple[str | None, strartifact_candidate = resolvedartifact_path = str(resolved)elif raw_path.is_absolute():- artifact_candidate = raw_path.resolve()+ resolved = raw_path.resolve()+ if run_dir is not None:+ try:+ resolved.relative_to(run_dir)+ except ValueError as exc:+ raise ValueError("artifact_path escapes the current run_dir") from exc+ artifact_candidate = resolvedif artifact_candidate is not None and artifact_candidate.is_file() and not artifact_hash:artifact_hash = _sha256_file(artifact_candidate)diff --git a/agent/tests/test_goal_tools.py b/agent/tests/test_goal_tools.pyindex b2d982c2e..2120cae43 100644--- a/agent/tests/test_goal_tools.py+++ b/agent/tests/test_goal_tools.py@@ -163,6 +163,56 @@ def test_goal_evidence_tool_binds_runtime_artifact(assert evidence["verification_status"] == "verified"+def test_goal_evidence_rejects_absolute_artifact_path_from_another_run(+ tmp_path: Path,+ monkeypatch,+) -> None:+ """An absolute artifact_path from a different run must not be recorded+ under the current run_dir's claimed run_id.++ The relative-path branch already rejects a path that escapes run_dir;+ an absolute path pointing at a sibling run's artifact must be rejected+ the same way, not accepted with the current run's id attached to a hash+ that actually belongs to the other run.+ """+ run_root = tmp_path / "runs"+ current_run_dir = run_root / "current-run"+ other_run_dir = run_root / "other-run"+ current_artifact = current_run_dir / "artifacts" / "metrics.csv"+ other_artifact = other_run_dir / "artifacts" / "metrics.csv"+ current_artifact.parent.mkdir(parents=True)+ other_artifact.parent.mkdir(parents=True)+ current_artifact.write_text("symbol,return\nNVDA,0.12\n", encoding="utf-8")+ other_artifact.write_text("symbol,return\nAAPL,0.34\n", encoding="utf-8")+ monkeypatch.setenv("VIBE_TRADING_ALLOWED_RUN_ROOTS", str(run_root))+ monkeypatch.setenv("VIBE_TRADING_ALLOWED_FILE_ROOTS", str(run_root))++ store = GoalStore(tmp_path / "goals.db")+ start = StartResearchGoalTool(default_session_id="session-1", store=store)+ add = AddGoalEvidenceTool(default_session_id="session-1", store=store)+ created = json.loads(+ start.execute(+ objective="Evaluate NVDA momentum as a research-only thesis.",+ criteria=["Check price action"],+ )+ )++ result = json.loads(+ add.execute(+ goal_id=created["snapshot"]["goal"]["goal_id"],+ criterion_index=1,+ text="Generated metrics artifact for NVDA momentum.",+ source_provider="pytest",+ source_type="market_data",+ artifact_path=str(other_artifact.resolve()),+ run_dir=str(current_run_dir),+ )+ )++ assert result["status"] == "error"+ assert "escapes" in result["error"]++def test_goal_evidence_preserves_exact_tool_call_provenance(tmp_path: Path) -> None:"""Tool-backed goal evidence keeps the exact source call id beside its own evidence id."""store = GoalStore(tmp_path / "goals.db")