Skip to content

fix: Resolve CI/CD linting issues and dependency warnings#12

Closed
aaronlippold wants to merge 3 commits into
ukkit:mainfrom
aaronlippold:fix/cicd-linting-and-dependencies
Closed

fix: Resolve CI/CD linting issues and dependency warnings#12
aaronlippold wants to merge 3 commits into
ukkit:mainfrom
aaronlippold:fix/cicd-linting-and-dependencies

Conversation

@aaronlippold
Copy link
Copy Markdown
Contributor

@aaronlippold aaronlippold commented Nov 9, 2025

Summary

Comprehensive CI/CD fixes and search functionality improvements with extensive testing.

Changes

🐛 Bug Fixes

Fix #1: Ruff B019 Linting Error

  • Issue: @functools.lru_cache on instance method can cause memory leaks
  • Location: src/memcord/server.py:906
  • Solution: Converted _get_mime_type to @staticmethod
  • Impact: CI checks now pass cleanly

Fix #2: Yanked Dependency

  • Issue: pypdfium2==4.30.1 yanked due to text extraction regression
  • Solution: Explicit pin pypdfium2>=5.0.0 in pyproject.toml
  • Impact: Dependency warnings resolved

Fix #3: Acronym Search Support

  • Issue: Search tokenizer filtered out words with length ≤ 2
  • Impact: Common acronyms (CI, CD, UI, UX, DB, API, AWS) were not searchable
  • Solution: Changed filter from len > 2 to len > 1 in search.py:178
  • Result: All 2-letter acronyms now fully searchable

Fix #4: Cross-Session Search

  • Issue: Search index not refreshing across MCP instances
  • Impact: Content saved in one session was not discoverable in another
  • Root Cause: Per-instance index initialized once without checking for disk changes
  • Solution: Added modification time (mtime) tracking and staleness detection
    • Track file mtimes in _index_mtime_snapshot
    • Check for changes via _is_search_index_stale()
    • Re-index when files modified externally
    • Invalidate search cache when index refreshes
  • Result: Cross-session search now works as expected

✅ Testing Improvements

New Test Suites

1. Search Index Tests (test_search_index_staleness.py - 10 tests)

  • Same-instance search validation
  • Cross-instance search validation
  • External modification detection
  • Concurrent multi-instance saves
  • Performance validation (< 50ms overhead)

2. E2E Workflow Tests (test_e2e_workflows.py - 22 tests)

  • Basic workflows (save→search, acronyms, cross-session)
  • Concurrent workflows (multi-instance operations)
  • Error recovery scenarios
  • Real-world use cases (multi-project, decision tracking)
  • Edge cases (unicode, special characters, case-insensitive)

Testing Philosophy:

  • User-perspective testing (not implementation details)
  • Cross-instance scenarios (realistic MCP usage)
  • Real-world workflows

📊 Test Results

Test Count: 250 → 282 tests (+32 new tests, +12.8%)

CI/CD Status:

  • ✅ All 282 tests passing
  • ruff check . clean
  • ruff format --check . clean (43 files)
  • ✅ All dependencies resolved

📈 Impact

Improvements:

  • ✅ CI/CD now passing
  • ✅ Search supports common acronyms
  • ✅ Cross-session search working
  • ✅ Comprehensive test coverage

Files Changed: 7 total

  • 5 source files (server, search, storage, pyproject, uv.lock)
  • 2 new test files (staleness + e2e)

🧪 Verification

uv sync --group dev
uv run pytest tests/ --tb=no -q
# Expected: 282 passed

All tests passing, ready for review!

- Remove @functools.lru_cache from instance method to prevent memory leak (B019)
- Convert _get_mime_type to static method (no state dependency)
- Pin pypdfium2>=5.0.0 to avoid yanked 4.30.1 version with text extraction regression
- Update uv.lock with pypdfium2 5.0.0

All 250 tests passing, ruff checks clean.

Authored by: Aaron Lippold <lippold@gmail.com>
**Bug #1: Acronym Tokenization (CRITICAL)**
- Problem: Search tokenizer filtered words with len <= 2
- Impact: CI, CD, UI, UX, DB, API, AWS and other acronyms were unsearchable
- Fix: Changed tokenizer from 'len > 2' to 'len > 1' (src/memcord/search.py:178)
- Result: All 2-letter acronyms now searchable

**Bug #2: Search Index Staleness (CRITICAL)**
- Problem: Search index never refreshed across MCP instances
- Impact: Content saved in one session was not searchable in another session
- Root Cause: Per-instance index initialized once, never checked for disk changes
- Fix: Added modification time (mtime) tracking and staleness detection
- Implementation:
  - Added _index_mtime_snapshot dict to track file mtimes
  - Added _is_search_index_stale() to detect changes
  - Updated search_memory() to check staleness before searching
  - Updated _save_slot() to maintain mtime snapshot on saves
  - Added cache invalidation when index refreshes
- Result: Cross-session search now works correctly

**Testing**
- Added comprehensive test suite: tests/test_search_index_staleness.py
- 10 tests covering same-instance, cross-instance, external modifications
- All 260 tests passing (250 existing + 10 new)
- Performance validated: staleness check adds < 50ms overhead

**Impact**
Fixes core search functionality that was completely broken for:
- Cross-session workflows
- Multi-instance collaboration
- External modifications
- Common acronym searches (CI/CD, API, UI, DB, AWS, etc.)

Authored by: Aaron Lippold <lippold@gmail.com>
**Coverage**: 22 end-to-end integration tests across 4 test classes

**Test Classes**:
1. TestBasicWorkflows (6 tests)
   - Save and search workflow
   - Acronym searches (CI/CD, API, UI, DB, AWS)
   - Cross-session discovery
   - Tag filtering
   - List and read workflows

2. TestConcurrentWorkflows (2 tests)
   - Concurrent multi-session saves
   - Update and search workflows

3. TestErrorRecoveryWorkflows (4 tests)
   - Empty database graceful handling
   - Empty content validation
   - Nonexistent slot handling
   - Tag operations workflow

4. TestRealWorldScenarios (3 tests)
   - Multi-project context switching
   - Decision tracking over time
   - Long-running project sessions

5. TestCommandInteractions (4 tests)
   - List tags after tagging
   - Slot switching and reading
   - Save overwrite behavior (manual_save replaces)
   - Save progress append behavior (auto_summary appends)

6. TestEdgeCasesAndRegression (3 tests)
   - Special characters in search
   - Case-insensitive search
   - Unicode content handling

**Why These Tests Matter**:
- Would have caught search index staleness bug
- Would have caught acronym tokenization bug
- Test from user perspective, not implementation details
- Cover cross-instance scenarios (realistic usage)
- Validate real-world workflows, not just individual commands

**Results**: All 282 tests passing (250 existing + 10 staleness + 22 E2E)

Authored by: Aaron Lippold <lippold@gmail.com>
@aaronlippold aaronlippold deleted the fix/cicd-linting-and-dependencies branch November 9, 2025 22:26
@aaronlippold aaronlippold restored the fix/cicd-linting-and-dependencies branch November 9, 2025 22:27
@aaronlippold aaronlippold deleted the fix/cicd-linting-and-dependencies branch November 9, 2025 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant