|
| 1 | +## 🐛 v1.2.1 - Critical Bug Fix: docs_root Resolution |
| 2 | + |
| 3 | +**Status:** Patch Release |
| 4 | +**Date:** 2026-01-12 |
| 5 | +**Branch:** main |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 🚨 Critical Fix: Issue #9 |
| 10 | + |
| 11 | +This patch release fixes a **critical bug** where users were loading the wrong documentation files. |
| 12 | + |
| 13 | +### The Problem |
| 14 | + |
| 15 | +Users reported seeing unrelated documentation files (like `orin.md`, `asus.md`, `pipe-to-orin.md`) that didn't exist in their project. These files were being loaded from the global `~/.claude/` directory instead of their project-local `.claude/` directory. |
| 16 | + |
| 17 | +**Example User Report (Issue #9):** |
| 18 | +> "Non of these files are files that are in my codebase and are not in my keywords.json. Unsure if it's a bug or if my installation is incorrect." |
| 19 | +
|
| 20 | +### Root Cause |
| 21 | + |
| 22 | +The `context-router-v2.py` script was **not checking project-local .claude/ directories** at all. It only implemented: |
| 23 | + |
| 24 | +1. `CONTEXT_DOCS_ROOT` environment variable |
| 25 | +2. Global `~/.claude/` fallback |
| 26 | + |
| 27 | +This meant **project-local documentation was completely ignored**, causing users to accidentally load documentation from other projects that happened to be in their global directory. |
| 28 | + |
| 29 | +### The Fix |
| 30 | + |
| 31 | +Implemented proper **3-tier priority order**: |
| 32 | + |
| 33 | +```python |
| 34 | +def resolve_docs_root() -> Path: |
| 35 | + """ |
| 36 | + Priority order: |
| 37 | + 1. CONTEXT_DOCS_ROOT environment variable (explicit override) |
| 38 | + 2. Project-local .claude/ directory (if exists with .md files) ← NEW |
| 39 | + 3. Global ~/.claude/ directory (fallback) |
| 40 | + """ |
| 41 | +``` |
| 42 | + |
| 43 | +**Key improvements:** |
| 44 | +- ✅ Project-local `.claude/` now correctly takes priority |
| 45 | +- ✅ Explicit validation: Checks for `.md` files, not just directory existence |
| 46 | +- ✅ Helpful error messages if no documentation found |
| 47 | +- ✅ Debug output to stderr showing which docs_root was chosen |
| 48 | +- ✅ Fails loudly (not silently) if no valid docs directory exists |
| 49 | + |
| 50 | +### Validation Tests |
| 51 | + |
| 52 | +All three priority levels tested and working: |
| 53 | + |
| 54 | +```bash |
| 55 | +# Test 1: Project-local detection |
| 56 | +$ cd /tmp/test-project |
| 57 | +$ echo '{"prompt": "test"}' | python3 context-router-v2.py 2>&1 | grep "Using" |
| 58 | +ℹ Using project-local .claude: /tmp/test-project/.claude |
| 59 | + Found 1 .md files |
| 60 | + |
| 61 | +# Test 2: Global fallback (no project .claude/) |
| 62 | +$ cd /tmp/no-local-docs |
| 63 | +$ echo '{"prompt": "test"}' | python3 context-router-v2.py 2>&1 | grep "Using" |
| 64 | +ℹ Using global ~/.claude: /home/user/.claude |
| 65 | + Found 64 .md files |
| 66 | + |
| 67 | +# Test 3: Explicit override |
| 68 | +$ CONTEXT_DOCS_ROOT=/custom/path echo '{"prompt": "test"}' | python3 context-router-v2.py 2>&1 | grep "Using" |
| 69 | +ℹ Using CONTEXT_DOCS_ROOT: /custom/path |
| 70 | +``` |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## 📝 Changes |
| 75 | + |
| 76 | +### Added |
| 77 | +- `resolve_docs_root()` function with explicit 3-tier priority logic |
| 78 | +- Content validation: Verifies `.md` files exist, not just directory |
| 79 | +- Debug output to stderr showing which docs_root was selected |
| 80 | +- Comprehensive error message when no documentation found |
| 81 | + |
| 82 | +### Fixed |
| 83 | +- **Issue #9**: Project-local `.claude/` now correctly prioritized over global `~/.claude/` |
| 84 | +- Prevents accidental loading of wrong project's documentation |
| 85 | +- Users no longer see files from unrelated projects |
| 86 | + |
| 87 | +### Files Modified |
| 88 | +- `scripts/context-router-v2.py` (lines 39-107, 626-630) |
| 89 | + - Added `resolve_docs_root()` function |
| 90 | + - Replaced hardcoded global fallback with priority logic |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## 🚀 Upgrade Instructions |
| 95 | + |
| 96 | +### For All Users (Automatic Fix) |
| 97 | + |
| 98 | +**No action required!** Just update to v1.2.1: |
| 99 | + |
| 100 | +```bash |
| 101 | +cd ~/claude-cognitive-package |
| 102 | +git pull origin main |
| 103 | +``` |
| 104 | + |
| 105 | +The fix is automatic. Your project-local `.claude/` will now be correctly detected. |
| 106 | + |
| 107 | +### For Users Who Applied Workaround |
| 108 | + |
| 109 | +If you were using this workaround: |
| 110 | + |
| 111 | +```bash |
| 112 | +# OLD workaround (no longer needed) |
| 113 | +export CONTEXT_DOCS_ROOT=.claude |
| 114 | +``` |
| 115 | + |
| 116 | +You can now **remove it**. The project-local `.claude/` will be detected automatically. |
| 117 | + |
| 118 | +### Verification |
| 119 | + |
| 120 | +After updating, verify the fix is working: |
| 121 | + |
| 122 | +```bash |
| 123 | +# Run in your project directory |
| 124 | +echo '{"prompt": "test"}' | python3 ~/.claude/scripts/context-router-v2.py 2>&1 | grep "Using" |
| 125 | + |
| 126 | +# Should show: |
| 127 | +# ℹ Using project-local .claude: /path/to/your/project/.claude |
| 128 | +# Found N .md files |
| 129 | +``` |
| 130 | + |
| 131 | +If you see "Using global ~/.claude", check: |
| 132 | +1. Does `.claude/` exist in your project root? |
| 133 | +2. Does it contain `.md` files? |
| 134 | +3. Run `ls .claude/*.md` to verify |
| 135 | + |
| 136 | +--- |
| 137 | + |
| 138 | +## 🎯 Impact |
| 139 | + |
| 140 | +### Before v1.2.1 (Broken Behavior) |
| 141 | +``` |
| 142 | +User's project/ |
| 143 | +├── .claude/ |
| 144 | +│ ├── auth.md ← IGNORED (never loaded) |
| 145 | +│ └── database.md ← IGNORED (never loaded) |
| 146 | +
|
| 147 | +~/.claude/ |
| 148 | +├── orin.md ← LOADED (wrong project!) |
| 149 | +├── asus.md ← LOADED (wrong project!) |
| 150 | +└── pipe-to-orin.md ← LOADED (wrong project!) |
| 151 | +``` |
| 152 | + |
| 153 | +**Result:** User sees MirrorBot CVMP docs instead of their own auth/database docs. |
| 154 | + |
| 155 | +### After v1.2.1 (Fixed Behavior) |
| 156 | +``` |
| 157 | +User's project/ |
| 158 | +├── .claude/ |
| 159 | +│ ├── auth.md ← LOADED ✅ (correct) |
| 160 | +│ └── database.md ← LOADED ✅ (correct) |
| 161 | +
|
| 162 | +~/.claude/ |
| 163 | +├── orin.md ← IGNORED (fallback only) |
| 164 | +├── asus.md ← IGNORED (fallback only) |
| 165 | +└── pipe-to-orin.md ← IGNORED (fallback only) |
| 166 | +``` |
| 167 | + |
| 168 | +**Result:** User sees their own project documentation. |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +## 📊 Test Results |
| 173 | + |
| 174 | +| Test Case | Result | Output | |
| 175 | +|-----------|--------|--------| |
| 176 | +| **Project-local detection** | ✅ PASS | Found project `.claude/` with 1 file | |
| 177 | +| **Global fallback (no project)** | ✅ PASS | Used global `~/.claude/` with 64 files | |
| 178 | +| **Explicit env var override** | ✅ PASS | Used `CONTEXT_DOCS_ROOT` path | |
| 179 | +| **Empty directory error** | ✅ PASS | Helpful error message shown | |
| 180 | + |
| 181 | +--- |
| 182 | + |
| 183 | +## 🐛 Known Issues |
| 184 | + |
| 185 | +None. This is a patch release addressing a single critical bug. |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +## 🙏 Credits |
| 190 | + |
| 191 | +**Reported by:** GitHub user via [Issue #9](https://github.com/GMaN1911/claude-cognitive/issues/9) |
| 192 | +**Fixed by:** Garret Sutherland ([@GMaN1911](https://github.com/GMaN1911)) |
| 193 | +**Company:** MirrorEthic LLC |
| 194 | + |
| 195 | +--- |
| 196 | + |
| 197 | +## 🔗 Links |
| 198 | + |
| 199 | +- **Repository:** [github.com/GMaN1911/claude-cognitive](https://github.com/GMaN1911/claude-cognitive) |
| 200 | +- **Issue #9:** [Wrong documentation loading](https://github.com/GMaN1911/claude-cognitive/issues/9) |
| 201 | +- **CHANGELOG:** [CHANGELOG.md](CHANGELOG.md) |
| 202 | +- **Previous Release:** [v1.2.0 (Usage Tracking)](https://github.com/GMaN1911/claude-cognitive/releases/tag/v1.2.0) |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | +## 📅 Release Timeline |
| 207 | + |
| 208 | +| Version | Date | Description | |
| 209 | +|---------|------|-------------| |
| 210 | +| v1.2.0 | 2026-01-12 | Phase 1 complete (usage tracking) | |
| 211 | +| **v1.2.1** | **2026-01-12** | **Critical bug fix (docs_root priority)** | |
| 212 | +| v2.0.0-rc | 2026-01-12 | Hologram integration (pre-release) | |
| 213 | + |
| 214 | +--- |
| 215 | + |
| 216 | +**This fix ensures your project-local documentation is always loaded correctly. Thank you for reporting Issue #9!** 🙏 |
0 commit comments