docs: update TODO.md and FINDINGS.md for Phase 1 completion

Mark all Phase 1 pure-function test tasks as complete with commit
reference acb987a. Document coverage improvement (18.4% -> 38.8%),
per-function coverage breakdown, and discoveries about testability
of remaining functions.

Co-Authored-By: Charon <developers@lethean.io>
This commit is contained in:
Claude 2026-02-20 00:03:47 +00:00
parent acb987a01d
commit 49e9669419
No known key found for this signature in database
GPG key ID: AF404715446AEB41
2 changed files with 63 additions and 8 deletions

View file

@ -55,3 +55,58 @@ go-rag: 18.4% coverage (only chunk.go tested)
### Recommendation
Phase 1 should focus on pure-function tests (FormatResults*, EmbedDimension, defaults, valueToGo). Phase 2 extracts `Embedder` and `VectorStore` interfaces to enable mocked testing for ingest/query. Phase 3+ needs live services.
---
## 2026-02-20: Phase 1 Pure-Function Tests Complete (go-rag agent)
### Coverage Improvement
```
Before: 18.4% (8 tests in chunk_test.go only)
After: 38.8% (66 tests across 4 test files)
```
### Per-Function Coverage
All targeted pure functions now at 100% coverage:
| Function | File | Coverage |
|----------|------|----------|
| FormatResultsText | query.go | 100% |
| FormatResultsContext | query.go | 100% |
| FormatResultsJSON | query.go | 100% |
| DefaultQueryConfig | query.go | 100% |
| DefaultOllamaConfig | ollama.go | 100% |
| DefaultQdrantConfig | qdrant.go | 100% |
| DefaultChunkConfig | chunk.go | 100% |
| DefaultIngestConfig | ingest.go | 100% |
| EmbedDimension | ollama.go | 100% |
| Model | ollama.go | 100% |
| valueToGo | qdrant.go | 100% |
| ChunkID | chunk.go | 100% |
| ChunkMarkdown | chunk.go | 97.6% |
| pointIDToString | qdrant.go | 83.3% |
### Discoveries
1. **OllamaClient can be constructed with nil `client` field** for testing pure methods (EmbedDimension, Model). The struct fields are unexported but accessible within the same package.
2. **Qdrant protobuf constructors** (`NewValueString`, `NewValueInt`, etc.) make it straightforward to build test values for `valueToGo` without needing a live Qdrant connection.
3. **pointIDToString default branch** (83.3%) — the uncovered path is a `PointId` with `PointIdOptions` set to an unknown type. This cannot be constructed via the public API (`NewIDNum` and `NewIDUUID` are the only constructors), so the 83.3% is the practical maximum without reflection hacks.
4. **FormatResultsJSON output is valid JSON** — confirmed by round-tripping through `json.Unmarshal` in tests. The hand-crafted JSON builder in `query.go` correctly handles escaping of special characters.
5. **ChunkMarkdown rune safety** — the overlap logic in `chunk.go` correctly uses `[]rune` slicing, confirmed by CJK text tests that would corrupt if byte-level slicing were used.
6. **Remaining 61.2% untested** is entirely in functions that require live Qdrant or Ollama: `NewQdrantClient`, `Search`, `UpsertPoints`, `Embed`, `EmbedBatch`, `Ingest`, `IngestFile`, and the helper wrappers. These are Phase 2 (mock interfaces) and Phase 3 (integration) targets.
### Test Files Created
| File | Tests | What It Covers |
|------|-------|----------------|
| query_test.go | 18 | FormatResultsText, FormatResultsContext, FormatResultsJSON, DefaultQueryConfig |
| ollama_test.go | 8 | DefaultOllamaConfig, EmbedDimension (5 models), Model |
| qdrant_test.go | 24 | DefaultQdrantConfig, pointIDToString, valueToGo (all types + nesting), Point, SearchResult |
| chunk_test.go (extended) | 16 new | Empty input, headers-only, unicode/emoji, long paragraphs, config boundaries, ChunkID edge cases, DefaultChunkConfig, DefaultIngestConfig |

16
TODO.md
View file

@ -11,18 +11,18 @@ Dispatched from core/go orchestration. Pick up tasks in phase order.
- [ ] **Install Ollama**`curl -fsSL https://ollama.com/install.sh | sh`. Pull embedding model: `ollama pull nomic-embed-text`.
- [ ] **Verify both services**`go test -v -run TestQdrant ./...` and `go test -v -run TestOllama ./...` (write these tests in Phase 1).
## Phase 1: Unit Tests (currently 18.4% coverage)
## Phase 1: Unit Tests (18.4% -> 38.8% coverage)
Only `chunk.go` has tests. Everything else is untested.
All pure-function tests complete. Remaining untested functions require live services (Phase 2/3).
### Testable Without External Services
- [ ] **FormatResults tests** — FormatResultsText, FormatResultsContext, FormatResultsJSON with known QueryResult inputs. Pure string formatting, no deps.
- [ ] **DefaultConfig tests** — Verify DefaultQdrantConfig, DefaultOllamaConfig, DefaultQueryConfig, DefaultChunkConfig, DefaultIngestConfig return expected values.
- [ ] **EmbedDimension tests** — OllamaClient.EmbedDimension() for each model name (nomic-embed-text=768, mxbai-embed-large=1024, all-minilm=384, unknown=768).
- [ ] **Point/SearchResult types** — Round-trip tests for Point struct and pointIDToString helper.
- [ ] **valueToGo tests** — Qdrant value conversion for string, int, double, bool, list, struct, nil.
- [ ] **Additional chunk tests** — Empty input, only headers no content, unicode/emoji, very long paragraph.
- [x] **FormatResults tests** — FormatResultsText, FormatResultsContext, FormatResultsJSON with known QueryResult inputs. Pure string formatting, no deps. (acb987a)
- [x] **DefaultConfig tests** — Verify DefaultQdrantConfig, DefaultOllamaConfig, DefaultQueryConfig, DefaultChunkConfig, DefaultIngestConfig return expected values. (acb987a)
- [x] **EmbedDimension tests** — OllamaClient.EmbedDimension() for each model name (nomic-embed-text=768, mxbai-embed-large=1024, all-minilm=384, unknown=768). (acb987a)
- [x] **Point/SearchResult types** — Round-trip tests for Point struct and pointIDToString helper. (acb987a)
- [x] **valueToGo tests** — Qdrant value conversion for string, int, double, bool, list, struct, nil. (acb987a)
- [x] **Additional chunk tests** — Empty input, only headers no content, unicode/emoji, very long paragraph. (acb987a)
### Require External Services (use build tag `//go:build rag`)