Phase 1 tests and implementation#3
Merged
livelifelively merged 21 commits intomasterfrom Jan 14, 2026
Merged
Conversation
- Add @say2/mcp package structure with stub implementations - Add unit tests for McpClientRegistry, EventDetector, LoggingTransport - Add unit tests for McpClientManager orchestration - Add E2E integration tests with mock MCP server fixture - Add StateMachineMiddleware and StoreMiddleware tests in @say2/core - Document API assumptions in TEST_ASSUMPTIONS.md 77 TDD tests await implementation (186 existing tests pass)
Implement MCP client functionality for Say2's Built-in Client mode as per Phase 1 architecture specifications. @say2/mcp package: - McpClientRegistry: Map wrapper for Client instances keyed by sessionId - McpClientManager: Orchestrates connection lifecycle (STDIO transport) - LoggingTransport: Transport decorator that intercepts messages for observation - EventDetector: Static utils for detecting MCP protocol events @say2/core package: - StateMachineMiddleware: Detects protocol events and triggers state transitions - StoreMiddleware: Persists message events to MessageStore - Added 'mode' field to Session (client | proxy) for future proxy support Key design decisions: - LoggingTransport runs pipeline BEFORE forwarding (both directions) - Messages forwarded unchanged (byte-for-byte preservation) - StateMachineMiddleware logs warnings on transition failures but never throws - McpClientManager.disconnect() is idempotent Implements specs from: - v0-docs/say2/3-how/specs/05-phases/02-phase-1-builtin-client-core/ Tests written separately on phase-1-tests branch.
Coverage Gap Resolution: - Add pagination tests for tools/list and resources/list (6 tests) - Add version mismatch tests for protocol negotiation (5 tests) - Add property-based tests with fast-check (14 tests) Mock Server Enhancements: - Add configurable protocolVersion for version testing - Add toolsPageSize/resourcesPageSize for pagination testing - Add createMockTransport helper function Test Fixes: - Fix async handling in logging-transport tests - Add missing 'mode' property to test session fixtures - Fix regex pattern in manager.test.ts for error matching - Add method field to MessageEvent test objects Documentation: - Create TRACEABILITY_MATRIX.md mapping specs to tests - Create TEST_GAP_RESOLUTION.md summarizing work Results: - 288 tests passing (was 263) - Coverage: 74% fully covered (was 63%) - 1400+ scenarios via property testing
New Test File: - additional-coverage.test.ts (15 tests) Coverage Improvements: - Resources templates list: tests for resources/templates/list (3 tests) - Discovery errors per capability: tests for partial failures (3 tests) - Prompts list: explicit tests for prompts/list (3 tests) - Transport events: connected, close, error events (3 tests) - Initialize timeout: timeout simulation tests (3 tests) Mock Server Enhancements: - Add resourceTemplates config option - Add resources/templates/list handler - Add createResourceTemplatesListResponse function Results: - 303 tests passing (was 288) - Coverage: 83% fully covered (was 74%) - Coverage: 89% including partial (was 80%) - All high/medium priority gaps now COMPLETED - Only 4 out-of-scope gaps remain (server layer)
Improved mutation score from 75.47% to 78.02% (+2.55%) Key improvements: - manager.test.ts: Use mock() for close() verification, add getClient/isConnected positive tests - registry.test.ts: Assert exact error message for duplicate registration - detector.test.ts: Add edge case tests for primitive/non-object results - logging-transport.test.ts: Add tests for undefined handlers (optional chaining) Test count: 312 tests, 610 expect() calls Remaining gap to 80%: Need to address core package mutations (state-machine.ts, message-store.ts)
- Improve state-machine.test.ts coverage (86% mutation score) - Add TEST_QUALITY_REPORT.md - Auto-fix lint/formatting issues in test files
test: add client verification tests exposing gaps
Implements protocol version check in StateMachineMiddleware and auto-pagination in McpClientManager. Adds E2E tests for verification. Resolves client logic gaps.
Defines LATEST_PROTOCOL_VERSION in core/types and updates middleware and tests to use it. Ensures consistency and easier updates.
Updates core types, middleware, and tests to use the latest specification release. Fixes hardcoded version strings in middleware logic and test expectations.
Deletes additional-coverage.test.ts. Adds client-features.test.ts using real McpClientManager. Adds listResourceTemplates to Manager. Updates Traceability Matrix to accurately reflect missing Timeout feature coverage.
- Implement configurable connect/initialize timeouts in session machine - Refactor StateMachineMiddleware to use injected ProtocolDetector - Fix XState v5 after-transition syntax for delays - Harden McpProtocolDetector with robust type guards - Add backward compatibility alias for EventDetector in tests
- Replace mock.module() with clientFactory dependency injection in McpClientManager - Allow CLOSE event from created/connecting/initializing states - Add sessionManager.delete() after close in DELETE /sessions/:id endpoint - Clean up state-machine.test.ts mock detector (remove 'as any' cast) All 134 MCP tests pass with proper isolation.
🧪 Test Quality Report
Quality Checks
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.