# Task ID: 64 **Title:** Add unit tests for tag matching algorithm **Status:** done **Dependencies:** 45 ✓ **Priority:** high **Description:** Create comprehensive unit tests for the deterministic tag matching algorithm covering score calculation, byte budget, and priority handling. **Details:** 1. Add tests in `/src/mcplocal/tests/services/tag-matcher.test.ts`: ```typescript describe('TagMatcherService', () => { describe('score calculation', () => { it('priority 10 prompts have infinite score', () => { const score = matcher.computeScore(['any'], { priority: 10, ... }); expect(score).toBe(Infinity); }); it('score = matching_tags * priority', () => { const score = matcher.computeScore( ['tag1', 'tag2'], { priority: 5, summary: 'tag1 tag2', chapters: [] } ); expect(score).toBe(10); // 2 tags * 5 priority }); }); describe('matching', () => { it('matches case-insensitively', () => { const matches = matcher.matchesPrompt('ZIGBEE', { summary: 'zigbee setup' }); expect(matches).toBe(true); }); it('matches substring in summary', () => { ... }); it('matches substring in chapters', () => { ... }); }); describe('byte budget', () => { it('includes full content until budget exhausted', () => { ... }); it('matched prompts beyond budget become index entries', () => { ... }); it('non-matched prompts listed as names only', () => { ... }); }); }); ``` **Test Strategy:** This task IS the test implementation. Verify: - Score calculation tests pass - Matching tests cover all cases - Byte budget tests verify allocation - Edge cases handled (empty tags, no prompts, etc.) - Tests are deterministic