Skip to content

Conversation

@RichardHightower
Copy link
Contributor

Summary

  • StorageBackendProtocol — async-first Protocol (PEP 544) with 11 methods defining all storage operations (vector search, keyword search, upsert, reset, embedding metadata, etc.)
  • ChromaBackend adapter — wraps existing VectorStoreManager + BM25IndexManager behind the protocol using composition and asyncio.to_thread()
  • Backend factory — config-driven selection with env var (AGENT_BRAIN_STORAGE_BACKEND) > YAML (storage.backend) > default (chroma) precedence
  • Service refactor — QueryService and IndexingService now depend on StorageBackendProtocol, not concrete backend classes
  • BM25 score normalization — per-query max normalization to 0-1 range for consistent hybrid search fusion

What this enables

Phase 6 (PostgreSQL backend) can now implement StorageBackendProtocol and plug in via the factory — zero changes to services required.

Test plan

  • 559 tests passing (54 new), 0 regressions
  • 70% coverage maintained
  • Black, Ruff, mypy all clean
  • Verification passed: 11/11 must-haves, 5/5 success criteria, 7/7 requirements (STOR-01..04, CONF-01..03)
  • CI PR QA Gate passes

Requirements covered

STOR-01, STOR-02, STOR-03, STOR-04, CONF-01, CONF-02, CONF-03

🤖 Generated with Claude Code

RichardHightower and others added 17 commits February 10, 2026 21:48
- Add StorageBackendProtocol with 11 async methods
- Define SearchResult, EmbeddingMetadata, StorageError types
- All scores normalized to 0-1 range (higher=better)
- Protocol is runtime_checkable for isinstance checks
- Passes mypy strict type checking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add StorageConfig to ProviderSettings with backend validation
- Add AGENT_BRAIN_STORAGE_BACKEND env var override
- Create get_storage_backend() factory with precedence: env > YAML > default
- Add storage backend validation to validate_provider_config()
- Log active storage backend in load_provider_settings()
- NotImplementedError placeholders for ChromaBackend and PostgresBackend

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- test_protocol.py: 12 tests for SearchResult, EmbeddingMetadata, StorageError, protocol compliance
- test_factory.py: 6 tests for backend factory resolution and cache management
- test_storage_config.py: 15 tests for StorageConfig validation and integration
- All 538 tests pass (33 new tests added)
- Zero regressions in existing test suite

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove unused Any import from factory.py
- Remove unused ProviderMismatchError import from protocol.py
- Fix pytest.raises(Exception) to pytest.raises(StorageError)
- All linting and type checking passes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- StorageBackendProtocol with 11 async methods (100% coverage)
- StorageConfig validates chroma/postgres backends
- Factory resolves backend: env > YAML > default
- 33 new tests added (538 total, 100% pass rate)
- Zero regressions, 70% overall coverage maintained
- Duration: 8 minutes (476 seconds)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Protocol

- ChromaBackend wraps VectorStoreManager and BM25IndexManager
- All protocol methods delegate to existing managers
- BM25 scores normalized to 0-1 range (per-query max normalization)
- Factory creates ChromaBackend for "chroma" config
- 20 new tests covering all ChromaBackend operations
- Protocol compliance verified via isinstance check
- All 559 tests pass, no regressions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- QueryService and IndexingService accept storage_backend parameter
- Backward-compatible: still accept vector_store + bm25_manager
- Legacy params wrapped in ChromaBackend automatically
- Services maintain .vector_store and .bm25_manager aliases
- VectorManagerRetriever updated to use storage_backend.vector_search
- Server startup initializes and logs storage backend type
- Updated conftest to mock bm25_manager.search_with_filters
- Updated test_bm25_api to mock search_with_filters
- 555/559 tests pass (4 tests need search_with_filters mocks)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Updated test_graph_query.py multi-query test with search_with_filters
- Updated test_rrf_fusion.py with search_with_filters for BM25 results
- 557/559 tests pass (99.6% pass rate)
- 2 tests need additional search_with_filters setup (documented in SUMMARY)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use getattr() instead of direct attribute access for type safety
- Use storage_backend.get_count() instead of vector_store
- All 60 source files pass mypy strict mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- ChromaBackend adapter wraps VectorStoreManager + BM25IndexManager
- Services refactored to use StorageBackendProtocol
- Backward compatibility maintained for 505+ existing tests
- 557/559 tests pass (99.6%), 70% coverage, mypy strict clean
- 4 commits, 11 minutes execution time

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…earch path

Tests for multi-mode RRF and graph query were missing search_with_filters
mocks on bm25_manager, causing BM25 results to be empty when routed
through ChromaBackend.keyword_search() instead of the old retriever path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 5 Storage Abstraction complete:
- StorageBackendProtocol with 11 async methods
- ChromaBackend adapter wrapping VectorStoreManager + BM25IndexManager
- Backend factory with env var > YAML > default precedence
- 559 tests passing (54 new), 70% coverage, 0 regressions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add 'from e' to all raise StorageError blocks (B904)
- Fix line-too-long in docstrings and comments (E501)
- Fix import ordering in test files (I001)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove unused MagicMock import in test_bm25_api.py
- Fix long import lines in main.py and storage/__init__.py
- Collapse single-line mock assignment in test_rrf_fusion.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create GitHub environment 'ci-testing' with OPENAI_API_KEY,
  ANTHROPIC_API_KEY, and COHERE_API_KEY secrets
- Wire pr-qa-gate.yml to ci-testing environment with env vars
- Wire provider-e2e.yml to ci-testing environment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@RichardHightower RichardHightower added the test-providers Trigger provider E2E tests on PR label Feb 11, 2026
OpenAIEmbeddingProvider has embed_text, not embed_batch. Call
embed_text per item to test batch embedding behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@RichardHightower RichardHightower merged commit 2b2297d into main Feb 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test-providers Trigger provider E2E tests on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant