# Test Log: v0.1.14 — `connect` Source Memories Fix

**Ngày:** 2026-02-28
**Tester:** Claude Code (Opus 4.5)
**Version tested:** 0.1.14 (from source, `.venv`)
**Profile:** `connect-verify-test` (isolated, cleaned up sau test)
**Environment:** macOS Darwin 25.1.0, Python 3.13.4, venv

---

## 1. Bug Fixed in This Version

### BUG-1 — `connect` Luôn Trả Về `source_memories: []`

**Version found:** 0.1.3 (phát hiện lần đầu trong E2E test 2026-02-28)
**Fixed:** 0.1.14
**Severity:** High (P1)

**Two-part root cause:**

**Part 1:** `find_path()` trong `graph_store.py` không fetch `source_hash` từ DB:
```sql
-- BEFORE (broken):
SELECT source, target, rel_type, evidence FROM kg_edges

-- AFTER (fixed):
SELECT source, target, rel_type, evidence, source_hash FROM kg_edges
```

Không có `source_hash` trong tuple → `GraphEdge.source_hash = ""` → không hydrate được.

**Part 2:** `explain_connection()` trong `service.py` iterate `.values()` thay vì `.items()`:
```python
# BEFORE (broken) — mất hash key:
"source_memories": [{"content": v["text"], "date": v.get("date", "")} for v in hydrated.values()]

# AFTER (fixed) — có đủ cả hash:
"source_memories": [{"content": v["text"], "date": v.get("date", ""), "mood": v.get("mood", ""), "content_hash": k} for k, v in hydrated.items()]
```

---

## 2. Test Results

### 2.1 Unit Tests

```bash
source .venv/bin/activate
python -m pytest tests/ -q
```

**Result:** `149 passed, 28 warnings in 21.27s` ✅ (0 regressions)

---

### 2.2 E2E Test — `connect` Full Flow

**Setup:**
```bash
kioku-lite users --use connect-verify-test
HASH=$(kioku-lite save "Phúc builds kioku-lite using Python and SQLite as the database." \
  --mood work | python3 -c "import sys,json; print(json.load(sys.stdin)['content_hash'])")

kioku-lite kg-index "$HASH" \
  --entities '[{"name":"Phúc","type":"PERSON"},{"name":"kioku-lite","type":"PROJECT"},{"name":"SQLite","type":"TOOL"}]' \
  --relationships '[
    {"source":"Phúc","rel_type":"WORKS_ON","target":"kioku-lite","evidence":"Phúc builds kioku-lite"},
    {"source":"kioku-lite","rel_type":"USED_BY","target":"SQLite","evidence":"kioku-lite using SQLite as database"}
  ]'
```

**Test: `connect "Phúc" "SQLite"` (2-hop path)**

| Check | Expected | Actual | Pass |
|-------|----------|--------|------|
| `connected` | `true` | `true` | ✅ |
| `paths[0]` | `["Phúc", "kioku-lite", "SQLite"]` | `["Phúc", "kioku-lite", "SQLite"]` | ✅ |
| `source_memories` count | 1 | 1 | ✅ |
| `source_memories[0].content` | "Phúc builds kioku-lite..." | "Phúc builds kioku-lite..." | ✅ |
| `source_memories[0].date` | "2026-02-28" | "2026-02-28" | ✅ |
| `source_memories[0].mood` | "work" | "work" | ✅ |
| `source_memories[0].content_hash` | hash prefix `d1a470e7` | `d1a470e7...` | ✅ |

**Full output:**
```json
{
    "from": "Phúc",
    "to": "SQLite",
    "connected": true,
    "paths": [["Phúc", "kioku-lite", "SQLite"]],
    "nodes": [
        {"name": "Phúc", "type": ""},
        {"name": "kioku-lite", "type": ""},
        {"name": "SQLite", "type": ""}
    ],
    "source_memories": [
        {
            "content": "Phúc builds kioku-lite using Python and SQLite as the database.",
            "date": "2026-02-28",
            "mood": "work",
            "content_hash": "d1a470e7cd3cf9205292142e9c0115c2e93f63ea4e56a3571499ac74cb8e67b5"
        }
    ]
}
```

---

### 2.3 Regression Tests — Các Feature Đã Fix Trước Đó

Kiểm tra nhanh các bug đã fix ở v0.1.11–v0.1.13 vẫn hoạt động:

| Feature | Test | Pass |
|---------|------|------|
| BM25 term search | `search "Techbase Việt Nam"` → `source: bm25` (không còn 0 results) | ✅ |
| `content_hash` trong `search` | Output có `content_hash` field | ✅ |
| `content_hash` trong `recall` | `recall "Phúc"` → `source_memories[].content_hash` | ✅ |
| `content_hash` trong `timeline` | `timeline` → entries có `content_hash` | ✅ |
| Profile management | `users --use <id>` ghi `.active_user`, lệnh tiếp theo auto dùng | ✅ |
| SKILL.md `connect` command | Đúng tên lệnh (không còn `explain-connection`) | ✅ |

---

## 3. Cleanup

```bash
kioku-lite users --use personal
rm -rf ~/.kioku-lite/users/connect-verify-test
```

✅ Không có residual test data trong `personal` profile.

---

## 4. Open Items

**None.** Tất cả bugs đã được fix tính đến v0.1.14.

| Version | Bug Fixed |
|---------|-----------|
| 0.1.11 | BUG-01: BM25 phrase → term search |
| 0.1.11 | BUG-02: `content_hash` missing từ search/recall/timeline |
| 0.1.11 | BUG-04: FastEmbed warning spam |
| 0.1.13 | BUG-03: SKILL.md `explain-connection` → `connect` |
| **0.1.14** | **BUG-1: `connect` source_memories luôn rỗng (two-part fix)** |

---

*Test Log by Claude Code — 2026-02-28*
