# Independent Memory Testing Plan

**Goal:** Create a comprehensive test suite for the knowledge plane memory components that can run independently without requiring external services (Ollama, LanceDB running).

**Scope:**
- Unit tests for knowledge plane components that work without external dependencies
- Integration tests using mock data
- Contract tests for data models
- Tests that can be run with `pytest -q` as part of CI gate

**Components Testable Without External Services:**

1. **TextChunker** (`chunker.py`) - splits text, no embedding needed
2. **DeduplicationEngine** (`deduplication.py`) - hash-based duplicate detection
3. **KnowledgeNavigator** (`navigation.py`) - topic/tag navigation, in-memory
4. **SQLiteKnowledgeRepository** (`repository.py`) - metadata operations with SQLite
5. **Contracts/data models** (`contracts.py`) - DocumentRegistration, KnowledgeDocument, etc.
6. **EmbeddingConfig** (`embedding_config.py`) - configuration validation

**Components Requiring External Services (skip in CI):**

1. **EmbeddingService** - needs Ollama running
2. **KnowledgeVectorStore** - needs LanceDB running
3. **MemoryService.full pipeline** - needs both above

**Test Structure:**

```
tests/
├── test_knowledge_plane.py        ← contract tests (already exists)
├── test_knowledge_embedding.py    ← unit tests for chunker/config (already exists)
├── test_knowledge_deepweb.py      ← dedup + navigator tests (already exists)
├── test_knowledge_integration.py  ← integration (requires Ollama, skip in CI)
└── test_independent_memory.py     ← NEW: standalone memory tests
```

**New Test File: `test_independent_memory.py`**

Tests for components that work without Ollama/LanceDB:

- `test_chunker_splits_text_correctly` - TextChunker functionality
- `test_deduplication_exact_match` - DeduplicationEngine hash detection
- `test_deduplication_no_duplicate` - Non-duplicate detection
- `test_navigator_topic_management` - KnowledgeNavigator topic/tag ops
- `test_repository_contract` - SQLiteKnowledgeRepository idempotency
- `test_document_contracts` - Data model validation

**Validation:**

Run: `python -m pytest tests/test_independent_memory.py -q`
Expected: All tests pass without Ollama/LanceDB

**How to Run:**

```bash
# Run only independent memory tests (no external deps)
python -m pytest tests/test_independent_memory.py -q

# Run full suite, skipping Ollama-dependent tests
python -m pytest tests/ -q --ignore=tests/test_knowledge_integration.py

# Run with coverage
python -m pytest tests/test_independent_memory.py --cov=src/cyberbrain26/knowledge_plane