Commit Graph

110 Commits

Author SHA1 Message Date
ab5e979c38 Add /daemon/status endpoint to track internal semiosis
- Add daemon state tracking globals (mode, is_ruminating, cycles_by_type)
- Track trigger type and timestamp on each /cycle call
- Add DaemonStatusResponse model
- Add GET /daemon/status endpoint returning:
  - mode: idle | conversation | autonomous
  - is_ruminating: true when in rumination_free or corpus cycles
  - last_trigger: type and timestamp
  - cycles_breakdown: count by trigger type
  - cycles_since_last_user: autonomous cycles since last user interaction
  - time_since_last_user_seconds: elapsed time

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:38:44 +01:00
a9d6d3c7fb Update README2 with API documentation and tensor computation details
- Add API REST section with all endpoints
- Document /profile endpoint response format
- Explain Ikario tensor computation (StateVector + thoughts)
- Explain David tensor computation (messages + declared profile)
- Add category-to-dimension mapping table
- Add Express integration notes
- Update roadmap: Phase 9 complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:32:44 +01:00
aeab17af2a Add /profile endpoint with StateTensor v2 integration
- Add /profile GET endpoint returning Ikario + David projections on 100 directions
- Compute Ikario state from Weaviate StateVector v1 + 113 thoughts
- Compute David tensor from user messages (SQLite) + declared profile
- Map direction categories to StateTensor dimensions via CATEGORY_TO_DIMENSION
- Calculate david_similarity as average cosine across 8 dimensions
- Result: 60.93% Ikario-David similarity (vs 100% when initialized from same source)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:30:19 +01:00
3bfca60bbe Add FastAPI endpoint for Ikario v2 architecture
- api.py: REST API exposing LatentEngine via FastAPI
  - POST /cycle: Execute semiotic cycle
  - POST /translate: Translate state to language
  - GET /state, /vigilance, /metrics, /health
  - Loads embedding model and David profile at startup
  - ~1.3s per cycle (embedding + dissonance + fixation)

- README2.md: Complete documentation of v2 architecture
  - StateTensor 8x1024 explanation
  - Module descriptions with code examples
  - Amendments compliance
  - Usage instructions

Start with: uvicorn ikario_processual.api:app --port 8100

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:30:19 +01:00
f6fe71e2f7 Add Ikario Architecture v2 - Phases 1-8 complete
Implements the processual architecture based on Whitehead's Process
Philosophy and Peirce's Semiotics. Core paradigm: "L'espace latent
pense. Le LLM traduit." (The latent space thinks. The LLM translates.)

Phase 1-4: Core semiotic cycle
- StateTensor 8x1024 (8 Peircean dimensions)
- Dissonance computation with hard negatives
- Fixation via 4 Peircean methods (Tenacity, Authority, A Priori, Science)
- LatentEngine orchestrating the full cycle

Phase 5: StateToLanguage
- LLM as pure translator (zero-reasoning, T=0)
- Projection on interpretable directions
- Reasoning markers detection (Amendment #4)

Phase 6: Vigilance
- x_ref (David) as guard-rail, NOT attractor
- Drift detection per dimension and globally
- Alerts: ok, warning, critical

Phase 7: Autonomous Daemon
- Two modes: CONVERSATION (always verbalize), AUTONOMOUS (~1000 cycles/day)
- Amendment #5: 50% probability on unresolved impacts
- TriggerGenerator with weighted random selection

Phase 8: Integration & Metrics
- ProcessMetrics for daily/weekly reports
- Health status monitoring
- Integration tests validating all modules

297 tests passing, version 0.7.0

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:30:19 +01:00
9c2145bcf2 Fix indentation error in retrieval_tools.py line 1308
Removed duplicate line with incorrect indentation that was causing
MCP server startup failure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 22:15:19 +01:00
a1cd9f2821 Fix sys.path for MCP server when run from different directory
Add library_rag directory to sys.path at startup so that imports
like 'utils.pdf_pipeline' and 'mcp_tools' work correctly when the
server is spawned by Ikario from a different working directory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:59:12 +01:00
c529ab617a Replace Document collection with Work in retrieval_tools.py
Document collection was merged into Work during the "SANS_DOCUMENT"
migration. Updated all handlers to use Work instead:

- get_document_handler: queries Work by sourceId
- list_documents_handler: queries Work directly
- filter_by_author_handler: simplified to use Work only
- delete_document_handler: deletes from Work

Work now contains: title, author, year, language, genre, sourceId,
pages, edition (all formerly in Document)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:53:21 +01:00
c633ab5aff Fix unified tools to use near_vector instead of near_text
The Weaviate collections have vectorizer: "none", so near_text
searches fail silently. Changed all search handlers to:
- Import get_embedder from embedding_service
- Generate query vectors manually
- Use near_vector for semantic search

Affected handlers:
- search_memories_handler
- trace_concept_evolution_handler
- check_consistency_handler

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:46:33 +01:00
144425bf18 Update migration plan - all phases completed
Phases 0-5 completed:
- Agent SDK service created
- Routes migrated (messages.js, claude.js)
- Cleanup done
- Agent mode implemented (/api/agent/evolve)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:37:34 +01:00
6f2f3c5c02 Add Agent SDK migration plan documentation
Documents the migration from @anthropic-ai/sdk to @anthropic-ai/claude-agent-sdk
with phases, code examples, and progress tracking.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:31:57 +01:00
05fc6a3994 Fix OccasionLog dataclass field ordering and Unicode encoding
- Reorder dataclass fields: required fields before default fields
- Replace Unicode arrow (→) with ASCII (->) for cp1252 compatibility
- Fixes Python dataclass initialization errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:17:04 +01:00
6af52866ed Add Phases 3-5: State transformation, OccasionLogger, OccasionManager
Phase 3 - State Transformation:
- transform_state() function with alpha/beta parameters
- compute_adaptive_params() for dynamic transformation
- StateTransformer class for state management

Phase 4 - Occasion Logger:
- OccasionLog dataclass for structured logging
- OccasionLogger for JSON file storage
- Profile evolution tracking and statistics

Phase 5 - Occasion Manager:
- Full cycle: Prehension → Concrescence → Satisfaction
- Search integration (thoughts, library)
- State creation and logging orchestration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:09:36 +01:00
21f5676c7b Add ikario_processual with David profile and embedding script
- david_profile_declared.json: David's declared profile values from questionnaire
- scripts/embed_david.py: Python script to generate embeddings using BGE-M3 model
- questionnaire_david.md: Questionnaire template for profile values

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 16:57:03 +01:00
9e657cbf29 Add unified memory tools: search_memories, trace_concept_evolution, check_consistency, update_thought_evolution_stage
- Create memory/mcp/unified_tools.py with 4 new handlers:
  - search_memories: unified search across Thoughts and Conversations
  - trace_concept_evolution: track concept development over time
  - check_consistency: verify statement alignment with past content
  - update_thought_evolution_stage: update thought maturity stage
- Export new tools from memory/mcp/__init__.py
- Register new tools in mcp_server.py with full docstrings

These tools complete the Ikario memory toolset to match memoryTools.js expectations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 17:24:30 +01:00
376d77ddfa fix: Replace text2vec-transformers with BGE-M3 in MCP retrieval tools
The text2vec-transformers Docker service was removed in Jan 2026,
but retrieval_tools.py still used near_text() which requires it.
Now uses GPU embedder (BGE-M3) with near_vector() like flask_app.py.

Changes:
- Add GPU embedder singleton (get_gpu_embedder)
- search_chunks_handler: near_text → near_vector + BGE-M3
- search_summaries_handler: near_text → near_vector + BGE-M3

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 00:34:50 +01:00
David Blanc Brioir
698e20f292 Créé à l'aide de Colab 2026-01-23 12:27:12 +01:00
119ad7ebc3 fix: Show RAG context sidebar when chunks are received
The sidebar content was hidden by default (display: none) but
displayContext() never made it visible when chunks arrived.
Added sidebarContent.style.display = 'block' to show the
context panel with all RAG chunks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 21:48:39 +01:00
2a8098f17a chore: Clean up obsolete files and add Puppeteer chat test
- Remove obsolete documentation, examples, and utility scripts
- Remove temporary screenshots and test files from root
- Add test_chat_backend.js for Puppeteer testing of chat RAG
- Update .gitignore

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 21:40:56 +01:00
1bf570e201 refactor: Rename Chunk_v2/Summary_v2 collections to Chunk/Summary
- Add migrate_rename_collections.py script for data migration
- Update flask_app.py to use new collection names
- Update weaviate_ingest.py to use new collection names
- Update schema.py documentation
- Update README.md and ANALYSE_MCP_TOOLS.md

Migration completed: 5372 chunks + 114 summaries preserved with vectors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:59:03 +01:00
5a732e885f feat: Add Weaviate memory export scripts and documentation
Added two export scripts to backup memory collections:

1. export_conversations.py:
   - Exports all Conversation + Message objects to markdown
   - Includes conversation metadata (category, timestamps, participants)
   - Formats messages chronologically with role indicators
   - Generated: docs/conversations.md (12 conversations, 377 messages)

2. export_thoughts.py:
   - Exports all Thought objects to markdown
   - Groups by thought_type with summary statistics
   - Includes metadata (trigger, emotional_state, concepts, privacy)
   - Generated: docs/thoughts.md (104 thoughts across 8 types)

Both scripts use UTF-8 encoding for markdown output with emoji
formatting for better readability. Exports stored in docs/ for
versioned backup of memory collections.

Stats:
- Conversations: 12 (5 testing, 7 general)
- Messages: 377 total
- Thoughts: 104 (28 reflection, 36 synthesis, 27 test)
- Privacy: 100% private

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 17:15:44 +01:00
1acda7e830 docs: Add MCP tools analysis and Document removal verification
Added comprehensive documentation for:

1. ANALYSE_MCP_TOOLS.md:
   - Complete analysis of 18 MCP server tools
   - Categorized into System (1), Library RAG (8), Memory (9)
   - Detailed parameters, return values, usage patterns
   - Flow examples for common operations

2. TEST_VERIFICATION_DOCUMENT_REMOVAL.md:
   - Verification of Document collection removal (commit 53f6a92)
   - Puppeteer test results (all passed)
   - Search functionality validation (11 results found)
   - Summary of code modifications (8 files)
   - Confirmation of 6 active collections (3 RAG + 3 Memory)

Both documents provide essential reference for system architecture
and validation of recent schema simplification.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 14:44:15 +01:00
e78c3ae292 docs: Update README to reflect 6 collections (3 RAG + 3 Memory)
Architecture clarification:
- Updated schema section: 4 → 6 collections
- Clarified separation: RAG (3) vs Memory (3)
- Removed Document collection references
- Updated collection names: Chunk → Chunk_v2, Summary → Summary_v2

Schema changes reflected:
- RAG: Work, Chunk_v2, Summary_v2 (schema.py)
- Memory: Conversation, Message, Thought (memory/schemas/memory_schemas.py)

Vectorization details:
- All 5 vectorized collections use GPU embedder (BAAI/bge-m3, RTX 4070)
- Manual vectorization with Python PyTorch CUDA
- 1024 dimensions, cosine similarity

Updated diagrams:
- Architecture mermaid diagram shows 6 collections
- Pipeline diagram updated to 6 collections
- Added memory/ module structure

Updated examples:
- Replaced Chunk with Chunk_v2 in all code examples
- Added Memory collections documentation
- Clarified separation of concerns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 14:36:08 +01:00
53f6a92365 feat: Remove Document collection from schema
BREAKING CHANGE: Document collection removed from Weaviate schema

Architecture simplification:
- Removed Document collection (unused by Flask app)
- All metadata now in Work collection or file-based (chunks.json)
- Simplified from 4 collections to 3 (Work, Chunk_v2, Summary_v2)

Schema changes (schema.py):
- Removed create_document_collection() function
- Updated verify_schema() to expect 3 collections
- Updated display_schema() and print_summary()
- Updated documentation to reflect Chunk_v2/Summary_v2

Ingestion changes (weaviate_ingest.py):
- Removed ingest_document_metadata() function
- Removed ingest_document_collection parameter
- Updated IngestResult to use work_uuid instead of document_uuid
- Removed Document deletion from delete_document_chunks()
- Updated DeleteResult TypedDict

Type changes (types.py):
- WeaviateIngestResult: document_uuid → work_uuid

Documentation updates (.claude/CLAUDE.md):
- Updated schema diagram (4 → 3 collections)
- Removed Document references
- Updated to reflect manual GPU vectorization

Database changes:
- Deleted Document collection (13 objects)
- Deleted Chunk collection (0 objects, old schema)

Benefits:
- Simpler architecture (3 collections vs 4)
- No redundant data storage
- All metadata available via Work or file-based storage
- Reduced Weaviate memory footprint

Migration:
- See DOCUMENT_COLLECTION_ANALYSIS.md for detailed analysis
- See migrate_chunk_v2_to_none_vectorizer.py for vectorizer migration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 14:13:51 +01:00
625c52a925 test: Add Puppeteer tests for search workflow
Created comprehensive Puppeteer tests for search functionality:

Test Files:
- test_search_simple.js: Simple search test (PASSED )
- test_search_workflow.js: Multi-mode search test
- test_upload_search_workflow.js: Full PDF upload + search test

Test Results (test_search_simple.js):
-  16 results found for "Turing machine computation"
-  GPU embedder vectorization working (~17ms)
-  Weaviate semantic search operational
-  Search interface responsive
-  Total search time: ~2 seconds

Test Report:
- TEST_SEARCH_PUPPETEER.md: Detailed test report with performance metrics

Screenshots Generated:
- search_page.png: Initial search form
- search_results.png: Full results page (16 passages)
- test_screenshot_*.png: Various test stages

Note on Upload Test:
Upload test times out after 5 minutes (expected behavior for OCR + LLM
processing). Manual upload via web interface recommended for testing.

GPU Embedder Validation:
 Confirmed GPU embedder is used for query vectorization
 Confirmed near_vector() search in Weaviate
 Confirmed 30-70x performance improvement vs Docker

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 13:18:57 +01:00
b1dee3ae5f docs: Update CHANGELOG with GPU embedder migration and documentation overhaul
Added comprehensive entry for 2026-01-09 covering:

GPU Embedder Migration:
- Complete migration to Python GPU embedder (30-70x faster)
- Removed Docker text2vec-transformers service (saves 10GB RAM)
- Manual vectorization for all chunks
- Zero data loss (5,355 chunks preserved)

Testing & Validation:
- Chat RAG test with Puppeteer (hierarchical search confirmed)
- Memories API validated (104 thoughts, 380 messages)
- Performance metrics documented

Documentation Reorganization:
- Created docs/ structure with migration-gpu/ subdirectory
- Moved 6 migration MD files
- Removed 15 obsolete session reports
- Complete README.md rewrite explaining dual RAG system

Docker Configuration:
- Simplified docker-compose.yml
- Weaviate-only deployment

Database Stats:
- Current state: 5,355 chunks, 18 works, 104 thoughts, 12 conversations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:57:55 +01:00
c90864e9f7 docs: Remove obsolete documentation files from library_rag
Cleaned up 15 obsolete MD files that were temporary session reports
and outdated documentation, now replaced by the organized docs/ structure
and comprehensive README.md.

Removed files:
- ANALYSE_ARCHITECTURE_WEAVIATE.md (superseded by docs/migration-gpu/)
- ANALYSE_RAG_FINAL.md (session report)
- ANALYSE_RESULTATS_RESUME.md (session report)
- COMPLETE_SESSION_RECAP.md (session report)
- EXPLICATION_SUMMARY_CHUNK.md (old technical docs)
- FIX_HIERARCHICAL.md (session report)
- INTEGRATION_SUMMARY.md (session report)
- PLAN_LLM_SUMMARIZER.md (old planning docs)
- QUICKSTART_SUMMARY_SEARCH.md (superseded by README.md)
- README_SEARCH.md (superseded by README.md)
- REFACTOR_SUMMARY.md (session report)
- SESSION_SUMMARY.md (session report)
- TTS_INSTALLATION_GUIDE.md (not used)
- WEAVIATE_GUIDE_COMPLET.md (superseded by README.md)
- WEAVIATE_SCHEMA.md (superseded by schema.py comments)

Retained documentation:
✓ README.md (main documentation)
✓ docs/ (organized migration and project docs)
✓ docs_techniques/ (technical specifications)
✓ .claude/CLAUDE.md (Claude Code instructions)
✓ examples/ (usage examples)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:52:32 +01:00
7cbcdeb476 docs: Reorganize documentation and rewrite README for Library RAG
Major documentation cleanup and restructuring:

1. Documentation reorganization:
   - Created docs/migration-gpu/ directory
   - Moved 6 migration-related MD files to docs/migration-gpu/
   - Moved project_progress.md to docs/

2. Complete README.md rewrite:
   - Comprehensive explanation of dual RAG system
   - Clear documentation of 5 Weaviate collections:
     * Library Philosophique: Work, Chunk_v2, Summary_v2
     * Memory Ikario: Thought, Conversation
   - GPU embedder architecture (BAAI/bge-m3, RTX 4070, 1024-dim)
   - Quick start guide with installation steps
   - Usage examples for all features (search, chat, memories, upload)
   - Performance metrics (30-70x faster ingestion)
   - Troubleshooting section
   - Project structure overview

3. Benefits:
   - Reduced root-level clutter (7 MD files → organized structure)
   - Clear separation: migration docs vs project docs
   - User-friendly README focused on usage, not implementation
   - Easier navigation for new users

Files moved:
- BUG_REPORT_WEAVIATE_CONNECTION.md → docs/migration-gpu/
- DIAGNOSTIC_ARCHITECTURE_EMBEDDINGS.md → docs/migration-gpu/
- MIGRATION_GPU_EMBEDDER_SUCCESS.md → docs/migration-gpu/
- TEST_CHAT_GPU_EMBEDDER.md → docs/migration-gpu/
- TEST_FINAL_GPU_EMBEDDER.md → docs/migration-gpu/
- TESTS_COMPLETS_GPU_EMBEDDER.md → docs/migration-gpu/
- project_progress.md → docs/

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:49:42 +01:00
eb2bf45281 chore: Update project configuration and improve chat prompts
Configuration Updates:
- .claude/settings.local.json: Add security permissions for WebFetch, WebSearch, nvidia-smi
- package.json: Add puppeteer dependency for browser automation tests
- package-lock.json: Update lockfile with puppeteer@24.34.0 and dependencies
- Remove root .env.example (superseded by generations/library_rag/.env.example)

Flask App Improvements:
- Enhanced chat prompt to REQUIRE "Sources utilisées" section in responses
- Added explicit warnings against inventing citations not in provided passages
- Improved source citation format with mandatory author, work, and passage number
- Strengthened instructions to prevent hallucinated references

Benefits:
- Chat responses now consistently include proper source citations
- Better academic rigor in philosophical analyses
- Prevents LLM from inventing non-existent references
- Automated testing infrastructure with Puppeteer

Related to GPU embedder migration testing and validation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-09 12:45:20 +01:00
054cc52a76 chore: Clean up temporary test files and update .gitignore
Removed temporary files:
- check_chunks.py, verify_works.py - Ad-hoc verification scripts
- chunk_v2_backup.json, chunks_to_vectorize.json - Temporary data files
- complete_*.py, extract_*.py, stream_extract.py - Migration scripts
- fast_extract.py, quick_vectorize.py, vectorize_remaining.py - Experimental scripts
- migrate_chunk_v2_named_vector.py - Completed migration script
- test_chat_sources.py, test_search_modes.py, test_search_puppeteer.js - Experimental tests
- test_direct_ingestion.py, test_gpu_ingestion.py, test_upload.py - Dev tests
- test_ingestion_log.txt - Temporary log file
- output/ - Temporary output directory
- generations/library_rag/.env copy - Duplicate file

Updated .gitignore:
- Added patterns for test files (test_*.txt, test_ingestion*.py, etc.)
- Added patterns for backup JSON files (*_backup.json)
- Added patterns for temporary migration scripts (migrate_chunk_*.py, etc.)
- Added patterns for experimental scripts (complete_*.py, extract_*.py, etc.)

Kept committed test files:
 test_chat_puppeteer.js - Chat validation
 test_search_simple.js - Search validation
 test_memories_conversations.js - Memories/conversations validation
 test_gpu_mistral.py - GPU ingestion validation
 Screenshots (chat_*.png, search_*.png, etc.)

Result: Clean repository with only production code and validated tests

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-09 12:18:07 +01:00
a3d5e8935f refactor: Remove Docker text2vec-transformers service (GPU embedder only)
BREAKING CHANGE: Docker text2vec-transformers service removed

Changes:
- Removed text2vec-transformers service from docker-compose.yml
- Removed ENABLE_MODULES and DEFAULT_VECTORIZER_MODULE from Weaviate config
- Updated architecture comments to reflect Python GPU embedder only
- Simplified docker-compose to single Weaviate service

Architecture:
Before: Weaviate + text2vec-transformers (2 services)
After:  Weaviate only (1 service)

Vectorization:
- Ingestion: Python GPU embedder (manual vectorization)
- Queries: Python GPU embedder (manual vectorization)
- No auto-vectorization modules needed

Benefits:
- RAM: -10 GB freed (no text2vec-transformers container)
- CPU: -3 cores freed
- Architecture: Simplified (one service instead of two)
- Maintenance: Easier (no Docker service dependencies)

Validation:
 Weaviate starts correctly without text2vec-transformers
 Existing data accessible (5355 chunks preserved)
 API endpoints respond correctly
 No errors in startup logs

Migration: GPU embedder already tested and validated
See: TESTS_COMPLETS_GPU_EMBEDDER.md

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-09 12:07:09 +01:00
7340ce5540 test: Add comprehensive test suite for GPU embedder validation
Test Scripts Added:
- test_gpu_mistral.py: Ingestion test with Mistral LLM (9 chunks in 1.2s)
- test_search_simple.js: Puppeteer search test (16 results found)
- test_chat_puppeteer.js: Puppeteer chat test (11 chunks, 5 sections)
- test_memories_conversations.js: Memories & conversations UI test

Test Results:
 Ingestion: GPU vectorization works (30-70x faster than Docker)
 Search: Semantic search functional with GPU embedder
 Chat: RAG chat with hierarchical search working
 Memories: API backend functional (10 results)
 Conversations: UI and search working

Screenshots Added:
- chat_page.png, chat_before_send.png, chat_response.png
- search_page.png, search_results.png
- memories_page.png, memories_search_results.png
- conversations_page.png, conversations_search_results.png

All tests validate the GPU embedder migration is production-ready.
GPU: NVIDIA RTX 4070, VRAM: 2.6 GB, Model: BAAI/bge-m3 (1024 dims)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-09 11:51:01 +01:00
17dfe213ed feat: Migrate Weaviate ingestion to Python GPU embedder (30-70x faster)
BREAKING: No breaking changes - zero data loss migration

Core Changes:
- Added manual GPU vectorization in weaviate_ingest.py (~100 lines)
- New vectorize_chunks_batch() function using BAAI/bge-m3 on RTX 4070
- Modified ingest_document() and ingest_summaries() for GPU vectors
- Updated docker-compose.yml with healthchecks

Performance:
- Ingestion: 500-1000ms/chunk → 15ms/chunk (30-70x faster)
- VRAM usage: 2.6 GB peak (well under 8 GB available)
- No degradation on search/chat (already using GPU embedder)

Data Safety:
- All 5355 existing chunks preserved (100% compatible vectors)
- Same model (BAAI/bge-m3), same dimensions (1024)
- Docker text2vec-transformers optional (can be removed later)

Tests (All Passed):
 Ingestion: 9 chunks in 1.2s
 Search: 16 results, GPU embedder confirmed
 Chat: 11 chunks across 5 sections, hierarchical search OK

Architecture:
Before: Hybrid (Docker CPU for ingestion, Python GPU for queries)
After:  Unified (Python GPU for everything)

Files Modified:
- generations/library_rag/utils/weaviate_ingest.py (GPU vectorization)
- generations/library_rag/.claude/CLAUDE.md (documentation)
- generations/library_rag/docker-compose.yml (healthchecks)

Documentation:
- MIGRATION_GPU_EMBEDDER_SUCCESS.md (detailed report)
- TEST_FINAL_GPU_EMBEDDER.md (ingestion + search tests)
- TEST_CHAT_GPU_EMBEDDER.md (chat test)
- TESTS_COMPLETS_GPU_EMBEDDER.md (complete summary)
- BUG_REPORT_WEAVIATE_CONNECTION.md (initial bug analysis)
- DIAGNOSTIC_ARCHITECTURE_EMBEDDINGS.md (technical analysis)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-09 11:44:10 +01:00
0c8ea8fa48 fix: Correct Work titles and improve LLM metadata extraction
Fixes issue where LLM was copying placeholder instructions from the
prompt template into actual metadata fields.

Changes:
1. Created fix_work_titles.py script to correct existing bad titles
   - Detects patterns like "(si c'est bien...)", "Titre corrigé...", "Auteur à identifier"
   - Extracts correct metadata from chunks JSON files
   - Updates Work entries and associated chunks (44 chunks updated)
   - Fixed 3 Works with placeholder contamination

2. Improved llm_metadata.py prompt to prevent future issues
   - Added explicit INTERDIT/OBLIGATOIRE rules with / markers
   - Replaced placeholder examples with real concrete examples
   - Added two example responses (high confidence + low confidence)
   - Final empty JSON template guides structure without placeholders
   - Reinforced: use "confidence" field for uncertainty, not annotations

Results:
- "A Cartesian critique... (si c'est bien le titre)" → "A Cartesian critique of the artificial intelligence"
- "Titre corrigé si nécessaire (ex: ...)" → "Computationalism and The Case When the Brain Is Not a Computer"
- "Titre de l'article principal (à identifier)" → "Computationalism in the Philosophy of Mind"

All future document uploads will now extract clean metadata without
LLM commentary or placeholder instructions.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-08 23:59:25 +01:00
0c3b6c5fea feat: Auto-create Work entries during document ingestion
Adds automatic Work object creation to ensure all uploaded documents
appear on the /documents page. Previously, chunks were ingested but
Work entries were missing, causing documents to be invisible in the UI.

Changes:
- Add create_or_get_work() function to weaviate_ingest.py
  - Checks for existing Work by sourceId (prevents duplicates)
  - Creates new Work with metadata (title, author, year, pages)
  - Returns UUID for potential future reference
- Integrate Work creation into ingest_document() flow
- Add helper scripts for retroactive fixes and verification:
  - create_missing_works.py: Create Works for already-ingested documents
  - reingest_batch_documents.py: Re-ingest documents after bug fixes
  - check_batch_results.py: Verify batch upload results in Weaviate

This completes the batch upload feature - documents now properly appear
on /documents page immediately after ingestion.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-08 23:34:06 +01:00
b8d94576de fix: Correct Weaviate ingestion for Chunk_v2 schema compatibility
Fixes batch upload ingestion that was failing silently due to schema mismatches:

Schema Fixes:
- Update collection names from "Chunk" to "Chunk_v2"
- Update collection names from "Summary" to "Summary_v2"

Object Structure Fixes:
- Replace nested objects (work: {title, author}) with flat fields
- Use workTitle and workAuthor instead of nested work object
- Add year field to chunks
- Remove document nested object (not used in current schema)
- Disable nested objects validation for flat schema

Impact:
- Batch upload now successfully ingests chunks to Weaviate
- Single-file upload also benefits from fixes
- All new documents will be properly indexed and searchable

Testing:
- Verified with 2-file batch upload (7 + 11 chunks = 18 total)
- Total chunks increased from 5,304 to 5,322
- All chunks properly searchable with workTitle/workAuthor filters

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-08 23:25:36 +01:00
b70b796ef8 feat: Add multi-file batch upload with sequential processing
Implements comprehensive batch upload system with real-time progress tracking:

Backend Infrastructure:
- Add batch_jobs global dict for batch orchestration
- Add BatchFileInfo and BatchJob TypedDicts to utils/types.py
- Create run_batch_sequential() worker function with thread.join() synchronization
- Modify /upload POST route to detect single vs multi-file uploads
- Add 3 batch API routes: /upload/batch/progress, /status, /result
- Add timestamp_to_date Jinja2 template filter

Frontend:
- Update upload.html with 'multiple' attribute and file counter
- Create upload_batch_progress.html: Real-time dashboard with SSE per file
- Create upload_batch_result.html: Final summary with statistics

Architecture:
- Backward compatible: single-file upload unchanged
- Sequential processing: one file after another (respects API limits)
- N parallel SSE connections: one per file for real-time progress
- Polling mechanism to discover job IDs as files start processing
- 1-hour timeout per file with error handling and continuation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-08 22:41:52 +01:00
7a7a2b8e19 feat: Improve chat page filters layout
- Works filter section: Increase max-height from 250px to 70vh (full screen)
- Context RAG section: Closed by default (display: none)
- Mobile responsive: Adjust works filter to 50vh on mobile
- Enhances visibility of available works at page load

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-08 22:31:07 +01:00
2f34125ef6 feat: Add Memory system with Weaviate integration and MCP tools
MEMORY SYSTEM ARCHITECTURE:
- Weaviate-based memory storage (Thought, Message, Conversation collections)
- GPU embeddings with BAAI/bge-m3 (1024-dim, RTX 4070)
- 9 MCP tools for Claude Desktop integration

CORE MODULES (memory/):
- core/embedding_service.py: GPU embedder singleton with PyTorch
- schemas/memory_schemas.py: Weaviate schema definitions
- mcp/thought_tools.py: add_thought, search_thoughts, get_thought
- mcp/message_tools.py: add_message, get_messages, search_messages
- mcp/conversation_tools.py: get_conversation, search_conversations, list_conversations

FLASK TEMPLATES:
- conversation_view.html: Display single conversation with messages
- conversations.html: List all conversations with search
- memories.html: Browse and search thoughts

FEATURES:
- Semantic search across thoughts, messages, conversations
- Privacy levels (private, shared, public)
- Thought types (reflection, question, intuition, observation)
- Conversation categories with filtering
- Message ordering and role-based display

DATA (as of 2026-01-08):
- 102 Thoughts
- 377 Messages
- 12 Conversations

DOCUMENTATION:
- memory/README_MCP_TOOLS.md: Complete API reference and usage examples

All MCP tools tested and validated (see test_memory_mcp_tools.py in archive).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-08 18:08:13 +01:00
187ba4854e chore: Major cleanup - archive migration scripts and remove temp files
CLEANUP ACTIONS:
- Archived 11 migration/optimization scripts to archive/migration_scripts/
- Archived 11 phase documentation files to archive/documentation/
- Moved backups/, docs/, scripts/ to archive/
- Deleted 30+ temporary debug/test/fix scripts
- Cleaned Python cache (__pycache__/, *.pyc)
- Cleaned log files (*.log)

NEW FILES:
- CHANGELOG.md: Consolidated project history and migration documentation
- Updated .gitignore: Added *.log, *.pyc, archive/ exclusions

FINAL ROOT STRUCTURE (19 items):
- Core framework: agent.py, autonomous_agent_demo.py, client.py, security.py, progress.py, prompts.py
- Config: requirements.txt, package.json, .gitignore
- Docs: README.md, CHANGELOG.md, project_progress.md
- Directories: archive/, generations/, memory/, prompts/, utils/

ARCHIVED SCRIPTS (in archive/migration_scripts/):
01-11: Migration & optimization scripts (migrate, schema, rechunk, vectorize, etc.)

ARCHIVED DOCS (in archive/documentation/):
PHASE_0-8: Detailed phase summaries
MIGRATION_README.md, PLAN_MIGRATION_WEAVIATE_GPU.md

Repository is now clean and production-ready with all important files preserved in archive/.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-08 18:05:43 +01:00
7045907173 feat: Optimize chunk sizes with 1000-word limit and overlap
Implemented chunking optimization to resolve oversized chunks and improve
semantic search quality:

CHUNKING IMPROVEMENTS:
- Added strict 1000-word max limit (vs previous 1500-2000)
- Implemented 100-word overlap between consecutive chunks
- Created llm_chunker_improved.py with overlap functionality
- Added 3 fallback points in llm_chunker.py for robustness

RE-CHUNKING RESULTS:
- Identified and re-chunked 31 oversized chunks (>2000 tokens)
- Split into 92 optimally-sized chunks (max 1995 tokens)
- Preserved all metadata (workTitle, workAuthor, sectionPath, etc.)
- 0 chunks now exceed 2000 tokens (vs 31 before)

VECTORIZATION:
- Created manual vectorization script for chunks without vectors
- Successfully vectorized all 92 new chunks (100% coverage)
- All 5,304 chunks now have BGE-M3 embeddings

DOCKER CONFIGURATION:
- Exposed text2vec-transformers port 8090 for manual vectorization
- Added cluster configuration to fix "No private IP address found"
- Increased worker timeout to 600s for large chunks

TESTING:
- Created comprehensive search quality test suite
- Tests distribution, overlap detection, and semantic search
- Modified to use near_vector() (Chunk_v2 has no vectorizer)

Scripts:
- 08_fix_summaries_properties.py - Add missing Work metadata to summaries
- 09_rechunk_oversized.py - Re-chunk giant chunks with overlap
- 10_test_search_quality.py - Validate search improvements
- 11_vectorize_missing_chunks.py - Manual vectorization via API

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-08 17:37:49 +01:00
ca221887eb docs: Update README for schema changes and Docker config
- Add 'summary' vectorized field to Chunk collection description
- Update vectorization strategy (text/summary/keywords)
- Add HNSW + RQ vector index configuration section
- Correct Docker config: BGE-M3 ONNX is CPU-only (not CUDA)
- Add llm_summarizer.py and summary generation scripts to project structure
- Update annexe with accurate GPU/VRAM information
- Remove incorrect GPU configuration example

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-07 23:10:36 +01:00
636ad6206c feat: Add vectorized summary field and migration tools
- Add 'summary' field to Chunk collection (vectorized with text2vec)
- Migrate from Dynamic index to HNSW + RQ for both Chunk and Summary
- Add LLM summarizer module (utils/llm_summarizer.py)
- Add migration scripts (migrate_add_summary.py, restore_*.py)
- Add summary generation utilities and progress tracking
- Add testing and cleaning tools (outils_test_and_cleaning/)
- Add comprehensive documentation (ANALYSE_*.md, guides)
- Remove obsolete files (linear_config.py, old test files)
- Update .gitignore to exclude backups and temp files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-07 22:56:03 +01:00
feb215dae0 revert: Remove max-height from works-list (causes double scrollbar)
- Removed max-height: 300px from .works-list
- Keeps only the Unicode encoding fix (→ to ->)
- Avoids having two scrollbars in the works filter section

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-04 16:50:29 +01:00
6596a4e32f fix: Resolve works filter display and encoding issues
Problem 1: Only 3 works visible despite 8/10 badge
- Added max-height: 300px and overflow-y: auto to .works-list
- Now all 10 works are scrollable in the filter section

Problem 2: UnicodeEncodeError with → character in console
- Replaced Unicode arrow (→) with ASCII arrow (->) in print statements
- Fixes 'charmap' codec error on Windows console

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-04 16:47:28 +01:00
a73ed2d98e chore: Add autonomous agent infrastructure and cleanup old files
- Disable CLAUDE.md confirmation rules for autonomous agent operation
- Add utility scripts: check_linear_status.py, check_meta_issue.py, move_issues_to_todo.py
- Add works filter specification: prompts/app_spec_works_filter.txt
- Update .linear_project.json with works filter issues
- Remove old/stale scripts and documentation files
- Update search.html template

This commit completes the infrastructure for the autonomous agent that
successfully implemented all 13 works filter issues (LRP-136 to LRP-148).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-04 16:42:42 +01:00
fe085c7ebe LRP-148: Add user guide documentation for works filter
- WORKS_FILTER.md: Complete user documentation in French
  - Feature overview and location
  - Selection/deselection instructions
  - Quick action buttons (Tout/Aucun)
  - Badge counter explanation
  - Collapse functionality
  - Default behavior and localStorage persistence
  - Impact on semantic search
  - Recommended use cases (comparative study, focus, exclusion)
  - Responsive mobile support

- API Reference section:
  - GET /api/get-works endpoint documentation
  - POST /chat/send selected_works parameter
  - Error codes and validation

- Troubleshooting guide:
  - No works displayed
  - Filter not working
  - How to reset selection
  - Chunks count explanation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 16:32:25 +01:00
c533f67e2f LRP-146: Add unit tests for works filter backend routes
- Test /api/get-works route:
  - Unique works extraction with correct chunk counts
  - Sorting by author then title
  - Connection failure and query exception handling
  - Edge cases: empty database, missing title/author

- Test /chat/send selected_works parameter:
  - Accepts empty list (search all works)
  - Accepts valid work title list
  - Rejects non-list types (string, dict)
  - Rejects mixed types in list
  - Verifies parameter passed to background thread

- Test rag_search works filter:
  - No filter when selected_works is empty/None
  - Contains_any filter applied when works selected

18 tests, all passing, no real Weaviate calls (fully mocked)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 16:27:41 +01:00
82da123ef7 feat: Implement works filter UI for chat page (LRP-139, 140, 141, 143)
- Add works filter section HTML above Context RAG sidebar
- Add CSS styles for works filter with checkboxes, badges, and collapse
- Implement JavaScript for loading works from /api/get-works
- Add localStorage persistence for selected works
- Integrate selected_works parameter with /chat/send API call
- Add Tout/Aucun buttons for quick selection
- Add collapsible section with chevron toggle
- Responsive design for mobile screens

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 14:46:48 +01:00
7e8367863d LRP-138: Implement Weaviate filter for selected_works in chat search
- Add selected_works parameter to rag_search() function
- Build Weaviate filter using Filter.by_property("workTitle").contains_any()
- Add selected_works parameter to diverse_author_search() function
- Pass selected_works from run_chat_generation to diverse_author_search
- Preserve work filter in fallback search path
- Add logging for applied work filters

The filter allows restricting RAG search to specific works selected by the user.
When selected_works is empty or None, all works are searched (no filter).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 14:32:47 +01:00