Commit Graph

47 Commits

Author SHA1 Message Date
47e4846270 chore(config): sync env example and context for ±3 defaults
Why:
- d5ccec2 locked ±3 in code; env template and domain glossary were still at 0/0.

Changes:
- NEIGHBOR_PREV/NEXT=3 in .env.example
- CONTEXT.md Neighbor Expansion defaults updated to 3/3

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-22 15:32:29 +03:30
dc76ca67b8 docs: lock fixed_size ±3 in decision record and lld
Why:
- Close the open ±N follow-up from the strategy finalization memo.

Changes:
- Add addendum with ±0…±3 evidence and binding ±3/3 default.
- Sync LLD config table with new neighbor expansion defaults.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-22 13:27:18 +03:30
d5ccec2f2c feat(config): apply fixed_size ±3 as stabilized defaults
Why:
- Final benchmark selected fixed_size with neighbor expansion ±3 as the winning Candidate.

Changes:
- Set neighbor_prev/neighbor_next defaults to 3 in Settings.
- Default Query tab to fixed_size ±3/3 and Benchmarks to single-strategy fixed_size.

Impact:
- API and Dashboard runs use ±3 unless explicitly overridden.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-22 13:27:15 +03:30
640691b8ab docs: record fixed_size as the winning strategy family
Why:
- Close the benchmark with a written family decision backed by Experiment composites.

Changes:
- Add the decision memo and SVG charts generated from SQLite.

Impact:
- Documents fixed_size over semantic under text-embedding-3-large; ±N remains follow-up.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-17 14:22:38 +03:30
6261bc0a23 docs: add high- and low-level design
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-17 14:22:35 +03:30
2ac69c9944 docs: record decision board language and adr-0026
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-17 14:22:28 +03:30
56b8d9401a feat(dashboard): add decision board for strategy selection
Why:
- Compare is the wrong surface for two-stage family selection over the 10-doc set.

Changes:
- Add the Decision Tab; raise GET /experiments default/max so the board can load the grid client-side.

Impact:
- Operators pick fixed_size ±N vs semantic@Boundary from existing Experiments.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-17 14:22:21 +03:30
e2c7fdc059 chore(scripts): add neighbor expansion benchmark sweep
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:13:07 +03:30
1401e46c9a docs: record embedding, neighbor, and inspect decisions
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:13:07 +03:30
bdf0c36e20 feat(dashboard): add embedding controls, neighbor ui, and retrieval inspect
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:13:07 +03:30
f562b91f83 feat(benchmarking): add model-scoped query and neighbor expansion
Why:
- Queries and Experiments must hit the Corpus Embedding Model's collections and optionally widen fixed_size context.

Changes:
- Resolve corpus model per request; apply Neighbor Expansion with Expansion Tree; persist and report expansion provenance.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:13:07 +03:30
4dd3125318 feat(documents): snapshot boundary and corpus models on process
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:13:07 +03:30
aa5838fadc feat(admin): add embedding model role and threshold APIs
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:13:07 +03:30
16c918538b fix(chunking): require semantic boundary detection
Why:
- Semantic strategies were silently falling back to fixed-count grouping when boundary embeds were missing.

Changes:
- Fail hard without aligned unit embeddings; orchestrator supplies Boundary embeds; Farsi-aware sentence split with line/paragraph fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:12:45 +03:30
736391b137 feat(embedding): support boundary and corpus model roles
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:12:45 +03:30
0ff9d8dd21 feat(storage): add app settings and model-scoped collections
Why:
- Different Embedding Models must not share Qdrant collections; Admin needs persisted role defaults and Experiment provenance.

Changes:
- Scope collection names by model id; add app_settings, embedding provenance columns, and queries.expansion_tree.

Impact:
- Process/query write only Model Corpus collections; legacy unscoped names are read-only for Admin labeling.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:12:45 +03:30
5fd19c12d9 feat(chunking): add embedding model registry and ollama config
Why:
- Operators need Cloud and Local Embedding Models with stable ids, dimensions, and defaults.

Changes:
- Add Embedding Model Registry; Ollama client; env defaults for model, Ollama host, and Neighbor Expansion knobs.

Impact:
- New installs default to text-embedding-3-large; OLLAMA_BASE_URL required for Local provider.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:12:36 +03:30
118255acdc docs: capture pdf domain language and deferred ingestion backlog
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-02 16:59:42 +03:30
987b0493ac feat(reports): add answer compare modal and source format badge
Why:
- Make per-question strategy answers inspectable and show DOCX vs Text PDF source.

Changes:
- Side-by-side compare modal with HTML escaping; header source badge from filename.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-02 16:59:42 +03:30
9ce2072c23 feat(dashboard): add pdf workspace via shared format filter
Why:
- Avoid a forked PDF UI while scoping Word vs PDF workflows.

Changes:
- formatFilter on shared tabs, PDF Workspace accordion tab, word-only defaults elsewhere.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-02 16:59:42 +03:30
55907a8dec feat(documents): add text pdf ingestion with heading reconstruction
Why:
- Support Text PDFs in the same DocumentTree/markdown contract as DOCX.

Changes:
- PyMuPDF parser, text-layer gate, shared heading heuristics, upload dispatch for .pdf.

Impact:
- Scanned/image PDFs are rejected at upload; requires pymupdf installed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-02 16:59:42 +03:30
afc20200f7 build(deps): add pymupdf for text pdf extraction
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-02 16:59:42 +03:30
d3f8a9a5e5 docs: add project documentation and task tracking
Why:
- Need to track domain model, ADRs, task progress, and feature planning

Changes:
- CONTEXT.md: domain model with ADRs 0001-0014
- docs/tasks.md: updated task list with Phase 6 (Dashboard)
- docs/cant-do-yet.md: backend-ready but no UI features
- docs/out-of-scope-v1.md: intentionally excluded features

Impact:
- Project documentation centralized for reference
2026-07-29 17:55:01 +03:30
a49795e5eb feat(dashboard): add full React dashboard with dark blue theme
Why:
- Swagger UI is not user-friendly for non-technical users
- Need a proper web app for document management, querying, benchmarking, and administration

Changes:
- Babel-in-browser React dashboard with 5 tabs (Home, Documents, Query, Benchmarks, Admin)
- Dark blue theme matching benchmark report pages (#0F1419, #1A2332, #F59E0B)
- Comparison view for strategy analysis across documents
- Expandable experiment details with delete
- Admin panel with collapsible sections (Health, Qdrant, Chunk Preview, Questions, Cost Estimator)
- Document upload, processing, and strategy selection
- Query interface with chunk inspection

Impact:
- Dashboard served at /app/ via FastAPI StaticFiles
- All Swagger functionality available through web UI
2026-07-29 17:54:51 +03:30
b10a5706f4 feat(reports): add overall scores to strategy cards and average row in technical report
Why:
- Users need to see each strategy's overall score at a glance in the report
- Technical report should show average metrics across all strategies

Changes:
- Each strategy card now shows its overall score below the metric bars
- Technical report aggregate table includes an AVERAGE row across all strategies

Impact:
- Managerial report: strategy cards now show overall score
- Technical report: aggregate table has a new AVERAGE row at the bottom
2026-07-29 17:54:26 +03:30
a277672444 feat(benchmarking): add document filename and delete experiment endpoint
Why:
- Experiment list and detail responses showed raw IDs instead of filenames
- No way to delete experiments from the UI

Changes:
- Add document_filename field to ExperimentDetailResponse
- Enrich list endpoint with filenames and calculated best_strategy from aggregate_metrics
- Add DELETE /experiments/{id} endpoint

Impact:
- API responses now include document_filename for all experiment endpoints
- Frontend can display filenames instead of IDs
2026-07-29 17:54:07 +03:30
a309e64841 feat(admin): add admin backend endpoints and service layer
Why:
- Dashboard needs system health, Qdrant management, chunk preview, questions, and cost estimation endpoints

Changes:
- Add admin router with 11 endpoints (health, Qdrant CRUD, chunk preview, questions management, cost estimation)
- Add delete_experiment to SQLite storage
- Mount admin router and dashboard static files at /app

Impact:
- New /admin/* API routes available
- Dashboard served at /app/ via StaticFiles
2026-07-29 17:53:43 +03:30
754da323ff docs: add comprehensive project documentation
Why:
- Need documentation for team onboarding and reference
- Need technical details for strategy implementations
- Need API reference for developers

Changes:
- README.md: Documentation index and quick start guide
- api-reference.md: All 10 endpoints with examples
- architecture.md: System structure and design decisions
- configuration.md: All environment variables and parameters
- data-flow.md: How data moves through the system
- evaluation-metrics.md: How scoring works with weights
- strategy-technical-details.md: Deep dive into each strategy's implementation
2026-07-27 14:15:28 +03:30
4e76203e27 feat(api): add request logging middleware
Why:
- Need visibility into API usage and performance
- Need to track request method, path, status, and duration
- Helps debugging production issues

Changes:
- Added RequestLoggingMiddleware class
- Logs at appropriate level (INFO/WARNING/ERROR)
- Non-invasive, no logic changes
2026-07-27 14:15:19 +03:30
0bb3086289 feat(benchmarking): add benchmark models and routes with view parameter
Why:
- Need request/response models for benchmark endpoints
- Need routes for creating and retrieving benchmarks
- Need view parameter for managerial vs technical report views

Changes:
- models.py: Added BenchmarkRequest, BenchmarkResponse, StrategyMetrics, ExperimentDetailResponse
- routes.py: Added POST /benchmarks, GET /benchmarks/{id}, GET /experiments, view parameter for reports
2026-07-27 14:14:59 +03:30
ef8bab5962 feat(benchmarking): add evaluation, benchmark service, and report
Why:
- Need LLM-as-Judge evaluation for automated scoring
- Need benchmark orchestration to run questions × strategies
- Need HTML report generation with two views (managerial/technical)

Changes:
- evaluation.py: LLM-as-Judge scoring on 4 metrics (context, similarity, faithfulness, hallucination)
- benchmark_service.py: Orchestration with per-strategy failure isolation
- report.py: Dual-view HTML reports with dark mode, charts, and strategy cards
2026-07-27 14:14:40 +03:30
d572724115 docs(data): add 21-question evaluation dataset for benchmarking
Why:
- Need standardized questions to evaluate chunking strategies
- Questions cover easy/medium/hard difficulty levels
- Golden answers enable automated scoring

Changes:
- 21 questions about engineering insurance (بیمه‌های مهندسی)
- 7 easy, 7 medium, 7 hard questions
- Categories: factual, procedural, comparative, complex
- Each question includes golden answer and expected keywords
2026-07-26 13:48:36 +03:30
b18ecdcd0c feat(api): add logging configuration and mount routers
Why:
- Need structured logging for debugging query pipeline
- Need to mount benchmarking router

Changes:
- Added logging.basicConfig() with INFO level
- Mounted benchmarking router
- Registered QueryError exception handler
2026-07-26 12:06:25 +03:30
cbaa72b420 feat(documents): add GET /documents endpoint and improve models
Why:
- Need to list documents to get document IDs for queries
- ProcessRequest should default to all 5 strategies
- paragraph_count should be optional (not always stored)

Changes:
- Added GET /documents endpoint with pagination
- Added DocumentListResponse model
- ProcessRequest now defaults to all 5 strategies
- DocumentResponse.paragraph_count now defaults to 0
2026-07-26 12:06:14 +03:30
496a58c62a feat(benchmarking): add query pipeline with logging and tracing
Why:
- Need query pipeline to ask questions against chunked documents
- Need comprehensive logging for debugging

Changes:
- Query service: embed question → vector search → LLM answer
- Query routes: POST /queries, GET /queries/{id}
- Query models: QueryRequest, QueryResponse, RetrievedChunk
- Added QueryError exception class
- Added STEP 1-6 logging for full traceability
2026-07-26 12:06:04 +03:30
b75fde8185 fix(models): add text field to ChunkMetadata for Qdrant storage
Why:
- Qdrant was storing only metadata, not chunk text
- Queries returned empty text in retrieved chunks
- Scores were low (~0.25) because embeddings were on empty strings

Changes:
- Added 'text' field to ChunkMetadata model
- Updated chunk_to_metadata() to copy text
2026-07-26 12:05:52 +03:30
292ae17cfa docs: add phases, tasks, and chunking strategies documentation
Why:
- Need implementation plan and task tracking documentation
- Need strategy explanations for reference

Changes:
- phases.md: 5-phase implementation plan with status tracking
- tasks.md: 25 tasks mapped to phases and steps
- chunking_strategies.md: detailed explanations of all 5 strategies
2026-07-26 09:38:08 +03:30
29edbf57c4 feat(api): wire documents router and SQLite init in app factory
Why:
- App factory needs to mount document routes and initialize SQLite at startup

Changes:
- Import and mount documents_router
- Call init_db() on app creation
2026-07-26 09:38:02 +03:30
8715d9c186 feat(strategies): implement all 5 chunking strategies
Why:
- Core evaluation targets — each strategy chunks differently for comparison

Changes:
- fixed_size: token-based splitting with overlap (baseline)
- recursive: cascade splitting (headers → newlines → sentences → words)
- semantic: sentence-level embeddings with similarity-based boundaries
- contextual_retrieval: LLM-generated context prefixes per chunk (Anthropic research)
- semantic_parent_child: paragraph clustering into parent-child hierarchy
2026-07-26 09:37:56 +03:30
143351b96b feat(chunking): add base strategy interface, embedding service, and orchestration
Why:
- Need abstract base class for all chunking strategies
- Need OpenAI embedding service (text-embedding-3-small)
- Need orchestration to run chunk → embed → store pipeline

Changes:
- Base: ChunkingStrategy ABC, token counting, chunk ID generation, sentence splitting
- Embedding: batch embedding with 2048 text limit per call
- Service: strategy registry, single/multi-strategy runners with per-strategy failure isolation
2026-07-26 09:37:46 +03:30
fdc21e3316 feat(documents): add document parser, service, and API routes
Why:
- Need to parse .docx/.doc files into DocumentTree + markdown
- Need API endpoints for document upload, processing, and deletion

Changes:
- Parser: .doc→.docx conversion via LibreOffice, XML-level extraction for table-heavy docs, heuristic heading detection
- Service: upload, process (delegates to chunking), delete orchestration
- Routes: POST /documents, POST /documents/{id}/process, DELETE /documents/{id}, GET /strategies
2026-07-26 09:37:40 +03:30
4aaaccec49 feat(storage): add SQLite and Qdrant storage layers
Why:
- SQLite stores structured data (documents, queries, experiments)
- Qdrant stores vector embeddings for similarity search

Changes:
- SQLite: schema init, document/query/experiment CRUD, JSON field parsing
- Qdrant: collection management, vector upsert, similarity search, delete operations
2026-07-26 09:37:32 +03:30
4f205a7ef7 feat(core): add StrategyName enum, DocumentTree models, and pagination helper
Why:
- StrategyName enum needed proper values for all 5 strategies
- DocumentTree models needed for document parser output
- PaginatedResponse needed for list endpoints

Changes:
- Renamed StrategyName values to match implementation (fixed_size, contextual_retrieval, semantic_parent_child)
- Added NodeType, DocumentTreeNode, DocumentTree models
- Added PaginatedResponse helper model
2026-07-26 09:37:24 +03:30
4edc355ae5 feat(core): add core layer with config, clients, exceptions, models, and app factory 2026-07-21 18:51:57 +03:30
c5bf8d5e1e build: add project configuration and environment template 2026-07-21 18:51:51 +03:30
09f9bb53bf docs: add domain glossary and architectural decision records
15 ADRs covering chunk model, failure handling, evaluation, parsing, directory structure, REST design, and strategy-specific decisions. 62 domain terms across 7 sections.
2026-07-21 18:51:46 +03:30
247ea0a16e Initial commit 2026-07-21 11:27:49 +03:30