🏷️ Priorité : HAUTE | Type : Tests manquants
Contexte
apps/claude_code_rag.py (375 lignes) orchestre tout le pipeline RAG pour Claude Code : chargement, chunking, manifest incrémental, build/update d'index. ZÉRO test actuellement.
Fichiers concernés
- Module à tester :
apps/claude_code_rag.py
- Fichier test à créer :
tests/test_claude_code_rag.py
Architecture du module
ClaudeCodeRAG hérite de BaseRAGExample :
| Méthode |
Lignes |
Rôle |
load_data(args) |
128-156 |
Charge sessions via ClaudeCodeReader + chunking |
_manifest_path(index_dir) |
162-163 |
Chemin du fichier manifest JSON |
_load_manifest(index_dir) |
165-171 |
Charge manifest ou retourne {"sessions": {}} |
_save_manifest(...) |
173-186 |
Sauvegarde manifest avec timestamp + modèle |
_scan_current_sessions(...) |
188-211 |
Scanne le disque, retourne sessions + mtime |
_find_new_or_modified_sessions(...) |
213-224 |
Compare manifest vs disque |
_do_incremental_update(...) |
240-305 |
Charge et ajoute les nouveaux chunks à l'index |
run(args) |
311-362 |
Point d'entrée : full build vs incremental |
Tests à écrire (~15 tests)
1. Manifest
class TestManifest:
def test_load_returns_empty_when_missing()
def test_load_parses_valid_json()
def test_load_handles_corrupted_json()
def test_save_creates_correct_structure() # embedding_model, build_timestamp, sessions
def test_save_creates_parent_dirs()
def test_path_is_inside_index_dir()
2. Détection incrémentale
class TestIncrementalDetection:
def test_detects_new_session()
def test_detects_modified_session_by_mtime()
def test_skips_unchanged_session()
def test_scan_returns_mtime_dict()
def test_scan_respects_project_filter()
3. Update & Run
class TestUpdateAndRun:
def test_incremental_update_calls_update_index() # mock LeannBuilder
def test_incremental_updates_manifest_after_success()
def test_no_new_sessions_skips_update()
def test_run_full_build_when_no_index()
def test_run_incremental_when_index_exists()
Setup recommandé
@pytest.fixture
def tmp_index_dir(tmp_path):
d = tmp_path / "test-index"
d.mkdir()
return str(d)
@pytest.fixture
def sample_manifest():
return {
"embedding_model": "facebook/contriever",
"build_timestamp": "2026-02-07T10:00:00+00:00",
"sessions": {"session_abc": {"mtime": 1707300000, "doc_count": 5}}
}
Critères de succès
🏷️ Priorité : HAUTE | Type : Tests manquants
Contexte
apps/claude_code_rag.py(375 lignes) orchestre tout le pipeline RAG pour Claude Code : chargement, chunking, manifest incrémental, build/update d'index. ZÉRO test actuellement.Fichiers concernés
apps/claude_code_rag.pytests/test_claude_code_rag.pyArchitecture du module
ClaudeCodeRAGhérite deBaseRAGExample:load_data(args)_manifest_path(index_dir)_load_manifest(index_dir){"sessions": {}}_save_manifest(...)_scan_current_sessions(...)_find_new_or_modified_sessions(...)_do_incremental_update(...)run(args)Tests à écrire (~15 tests)
1. Manifest
2. Détection incrémentale
3. Update & Run
Setup recommandé
Critères de succès
pytest tests/test_claude_code_rag.pypasse à 100%