Skip to content

"Vibe-Trading: Your Personal Trading Agent"

chore(gitignore): cover every broker config file the runtime writes at its root

Haozhe Wu21d8256db579
diff --git a/.gitignore b/.gitignore
index bd68e46f9..c0ca11f3a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,6 +40,9 @@ agent/uploads/
# (auth/ holds the Codex token, connectors/ and connections.json hold broker
# credentials) or tamper-evident state (live/ holds the hash-chained audit
# ledger), so a stray `git add -A` here is a credential leak, not just noise.
+# The per-broker config files below were missing until 2026-09-11 even though
+# this comment already claimed them; agent/tests/test_gitignore_runtime_files.py
+# now derives the filename constants from the code and fails on any gap.
/sessions.db
/sessions.db-shm
/sessions.db-wal
@@ -65,9 +68,24 @@ agent/uploads/
/history/
/pairing/
/connections.json
+/trading-connections.json
/portfolio.json
/config.yaml
-/strategy_evidence.sqlite3
+/swarm-agent.json
+/strategy_discovery.db
+/alpaca.json
+/binance.json
+/dhan.json
+/etoro.json
+/futu.json
+/ibkr-local.json
+/longbridge.json
+/mt5.json
+/okx.json
+/shoonya.json
+/tiger.json
+/trading212.json
+/zerodha.json
agent/tests/*_result.json
.ruff_cache/
frontend/dist/
diff --git a/agent/tests/test_gitignore_runtime_files.py b/agent/tests/test_gitignore_runtime_files.py
new file mode 100644
index 000000000..e0b75ca7a
--- /dev/null
+++ b/agent/tests/test_gitignore_runtime_files.py
@@ -0,0 +1,68 @@
+"""The repo-root .gitignore must cover every file the runtime writes at its root.
+
+The owner's shell exports ``VIBE_TRADING_HOME`` as the checkout, so anything
+``get_runtime_root()`` creates lands in the working tree. The .gitignore block
+for those paths says it is kept "closed against the connector CONFIG_FILENAME
+sites", but nothing checked that, and fourteen broker config files — API keys
+and secrets among them — were missing from it. This test derives the set from
+the code instead of from the list.
+"""
+
+from __future__ import annotations
+
+import ast
+import re
+from pathlib import Path
+
+_AGENT_ROOT = Path(__file__).resolve().parents[1]
+_REPO_ROOT = _AGENT_ROOT.parent
+_FILENAME_CONSTANT = re.compile(r"(^|_)(CONFIG_FILENAME|DB_FILENAME)$")
+
+
+def _runtime_root_filenames() -> dict[str, str]:
+ """Map each root-level filename constant to the module that defines it."""
+ found: dict[str, str] = {}
+ for path in sorted((_AGENT_ROOT / "src").rglob("*.py")):
+ source = path.read_text(encoding="utf-8")
+ if "get_runtime_root()" not in source:
+ continue
+ for node in ast.parse(source).body:
+ if not isinstance(node, ast.Assign) or len(node.targets) != 1:
+ continue
+ target = node.targets[0]
+ if (
+ isinstance(target, ast.Name)
+ and _FILENAME_CONSTANT.search(target.id)
+ and isinstance(node.value, ast.Constant)
+ and isinstance(node.value.value, str)
+ ):
+ found[node.value.value] = str(path.relative_to(_REPO_ROOT))
+ return found
+
+
+def _ignored_root_entries() -> set[str]:
+ lines = (_REPO_ROOT / ".gitignore").read_text(encoding="utf-8").splitlines()
+ return {line.strip() for line in lines if line.strip().startswith("/")}
+
+
+def test_discovery_sees_the_broker_config_files() -> None:
+ """Guard the guard: an empty scan would pass the coverage test vacuously."""
+ names = _runtime_root_filenames()
+
+ assert {"alpaca.json", "zerodha.json", "connections.json"} <= set(names)
+ assert len(names) >= 17
+
+
+def test_every_runtime_root_file_is_gitignored() -> None:
+ ignored = _ignored_root_entries()
+
+ missing = {
+ name: module
+ for name, module in _runtime_root_filenames().items()
+ if f"/{name}" not in ignored
+ }
+
+ assert not missing, (
+ "runtime-root files not covered by .gitignore (add a '/<name>' line to "
+ f"the runtime block): {missing}"
+ )