From f3d6a2f94ee42d144a0f1913498c276da052386a Mon Sep 17 00:00:00 2001 From: laansdole Date: Mon, 16 Mar 2026 16:56:52 +0700 Subject: [PATCH] feat: make check-backend for quality checks --- Makefile | 19 ++++++++++++++++++- pyproject.toml | 14 ++++++++++++++ tests/test_memory_embedding_consistency.py | 11 ----------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 576aa7fc..1eb26133 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,23 @@ validate-yamls: ## Validate all YAML configuration files .PHONY: help help: ## Display this help message - @python -c "import re; \ + @uv run python -c "import re; \ p=r'$(firstword $(MAKEFILE_LIST))'.strip(); \ [print(f'{m[0]:<20} {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(p, encoding='utf-8').read(), re.M)]" | sort + +# ============================================================================== +# Quality Checks +# ============================================================================== + +.PHONY: check-backend +check-backend: ## Run backend quality checks (tests + linting) + @$(MAKE) backend-tests + @$(MAKE) backend-lint + +.PHONY: backend-tests +backend-tests: ## Run backend tests + @uv run pytest -v + +.PHONY: backend-lint +backend-lint: ## Run backend linting + @uvx ruff check . diff --git a/pyproject.toml b/pyproject.toml index e1dad706..e1f46ca0 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,5 +45,19 @@ dependencies = [ requires = ["hatchling"] build-backend = "hatchling.build" +[tool.pytest.ini_options] +pythonpath = ["."] +testpaths = ["tests"] +python_files = ["test_*.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] +addopts = "-v --tb=short" +filterwarnings = [ + # Upstream SWIG issue in faiss-cpu on Python 3.12; awaiting SWIG 4.4 fix. + "ignore:builtin type Swig.*:DeprecationWarning", + "ignore:builtin type swigvarlink.*:DeprecationWarning", +] + + [tool.uv] package = false diff --git a/tests/test_memory_embedding_consistency.py b/tests/test_memory_embedding_consistency.py index 2b7c7a91..6a52670e 100644 --- a/tests/test_memory_embedding_consistency.py +++ b/tests/test_memory_embedding_consistency.py @@ -3,11 +3,6 @@ from unittest.mock import MagicMock, patch from runtime.node.agent.memory.memory_base import MemoryContentSnapshot, MemoryItem from runtime.node.agent.memory.simple_memory import SimpleMemory - -# --------------------------------------------------------------------------- -# Helpers -# --------------------------------------------------------------------------- - def _make_store(memory_path=None): """Build a minimal MemoryStoreConfig mock for SimpleMemory.""" simple_cfg = MagicMock() @@ -37,12 +32,7 @@ def _make_memory_item(item_id: str, dim: int): ) -# --------------------------------------------------------------------------- -# Tests -# --------------------------------------------------------------------------- - class TestSimpleMemoryRetrieveMixedDimensions: - """Task 2.1: verify retrieve() handles mixed-dimension embeddings.""" def test_mixed_dimensions_does_not_crash(self): """Retrieve with mixed-dimensional embeddings MUST not raise.""" @@ -112,7 +102,6 @@ class TestSimpleMemoryRetrieveMixedDimensions: class TestOpenAIEmbeddingDynamicFallback: - """Task 2.2: verify dynamic fallback dimension caching.""" def test_fallback_uses_model_dimension_after_success(self): """After a successful call the fallback dimension MUST match the model."""