diff --git a/.gitignore b/.gitignore index baa31a543..71958d693 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,4 @@ mini-swe-agent/ # Nix .direnv/ result +.aider* diff --git a/scripts/syntax_guard.py b/scripts/syntax_guard.py index 7c41dc9b4..a6dbf9595 100755 --- a/scripts/syntax_guard.py +++ b/scripts/syntax_guard.py @@ -2,9 +2,22 @@ """Syntax guard — compile all Python files to catch syntax errors before merge.""" import py_compile import sys +import importlib.util +import re +import requests +import psutil from pathlib import Path errors = [] + +# Check for missing dependencies +required_modules = ["llama_cpp", "requests", "psutil", "jinja2", "papermill"] +for module in required_modules: + if not importlib.util.find_spec(module): + errors.append(f"Missing required module: {module}") + print(f"MISSING DEPENDENCY: {module}", file=sys.stderr) + +# Check for external API calls in test files for p in Path(".").rglob("*.py"): if ".venv" in p.parts or "__pycache__" in p.parts: continue @@ -14,7 +27,30 @@ for p in Path(".").rglob("*.py"): errors.append(f"{p}: {e}") print(f"SYNTAX ERROR: {p}: {e}", file=sys.stderr) + # Check for HTTP API calls + if "test_" in p.name or "smoke_test" in p.name: + with open(p, "r") as f: + content = f.read() + if re.search(r'requests\.(get|post|put|delete)', content): + errors.append(f"External API call detected in {p}") + print(f"API CALL DETECTED: {p}", file=sys.stderr) + +# Check local model server health +try: + response = requests.get("http://localhost:8080/v1", timeout=5) + if response.status_code != 200: + errors.append("Local model server not responding") + print("MODEL SERVER ERROR: Not responding", file=sys.stderr) +except requests.exceptions.RequestException: + errors.append("Local model server not reachable") + print("MODEL SERVER ERROR: Not reachable", file=sys.stderr) + +# Check RAM usage +if psutil.virtual_memory().available < 500 * 1024 * 1024: # 500MB free + errors.append("Insufficient RAM for model and system") + print("RAM ERROR: Less than 500MB available", file=sys.stderr) + if errors: - print(f"\n{len(errors)} file(s) with syntax errors", file=sys.stderr) + print(f"\n{len(errors)} issue(s) detected", file=sys.stderr) sys.exit(1) -print("All Python files compile successfully") +print("All Python files compile successfully and dependencies are satisfied")