From e811e862ae0f886198faf5664b272ddcc6c372db Mon Sep 17 00:00:00 2001 From: alkatrazz Date: Fri, 19 Jun 2026 21:12:56 +0200 Subject: [PATCH] fix(rag): exclure hermes/builtin de l'index funk-docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les rapports auto-générés par hermes-auto-improve (admin/hermes/builtin/, "ne pas éditer") représentaient ~84% des points de la collection et noyaient la vraie doc → rag-query remontait du bruit. On les élague à l'ingestion (os.walk), surchargeable via RAG_EXCLUDE. Collection re-bâtie : 403 points propres (0 builtin), rag-query remonte de nouveau les bons documents. Co-Authored-By: Claude Opus 4.8 --- ansible/roles/rag/files/rag-ingest | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ansible/roles/rag/files/rag-ingest b/ansible/roles/rag/files/rag-ingest index 8c5e4e3..10a102a 100644 --- a/ansible/roles/rag/files/rag-ingest +++ b/ansible/roles/rag/files/rag-ingest @@ -19,6 +19,13 @@ COLLECTION = os.environ.get("RAG_COLLECTION", "funk-docs") VECTOR_DIM = 4096 CHUNK_MAX = 2000 +# Dossiers (relatifs à docs_dir) exclus de l'index : rapports auto-générés par +# hermes-auto-improve (méta-commentaires sur la doc, pas de la connaissance) — ils +# noyaient la vraie doc (~84% des points). Surchargeable via RAG_EXCLUDE (séparé par ":"). +EXCLUDE_DIRS = [ + p for p in os.environ.get("RAG_EXCLUDE", "hermes/builtin").split(":") if p +] + def _request(method, url, data=None): body = json.dumps(data).encode() if data is not None else None @@ -95,9 +102,15 @@ def point_id(file_path, section): def ingest(docs_dir): ensure_collection() + excluded = {os.path.normpath(os.path.join(docs_dir, p)) for p in EXCLUDE_DIRS} md_files = [] for root, dirs, files in os.walk(docs_dir): - dirs[:] = sorted(d for d in dirs if not d.startswith('.')) + # élague les dossiers cachés et exclus (ex. hermes/builtin) + dirs[:] = sorted( + d for d in dirs + if not d.startswith('.') + and os.path.normpath(os.path.join(root, d)) not in excluded + ) for f in sorted(files): if f.endswith('.md'): md_files.append(os.path.join(root, f))