You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extended is_dependency() method to accept optional crate_name parameter,
enabling crate-specific dependency filtering while maintaining backward
compatibility. Updated CrateService to use global filter instance for
improved performance.
- Extended method signature: is_dependency(module_path, crate_name=None)
- Utilizes existing _crate_dependencies dict for targeted filtering
- Falls back to global _dependencies set when crate_name not provided
- CrateService now uses get_dependency_filter() for singleton instance
- Corrected parameter order in service calls to (item_path, crate_name)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Copy file name to clipboardExpand all lines: Architecture.md
+23-8Lines changed: 23 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -234,7 +234,7 @@ The docsrs-mcp server implements a service layer pattern that decouples business
234
234
235
235
#### Core Services
236
236
237
-
-**CrateService**: Handles all crate-related operations including search, documentation retrieval, and version management. **Phase 2 Enhancement**: Automatically populates `is_stdlib` and `is_dependency` fields in SearchResult and GetItemDocResponse models using DependencyFilter integration. **Critical Fix Applied**: Implements `_build_module_tree()` helper method that transforms flat database results into hierarchical ModuleTreeNode structures, resolving Pydantic validation errors by properly fulfilling service layer data transformation responsibility. **Service Layer Fix**: Fixed search_examples method to properly handle dictionary results from search_example_embeddings, correctly mapping fields to CodeExample model requirements.
237
+
-**CrateService**: Handles all crate-related operations including search, documentation retrieval, and version management. **Phase 2 Enhancement**: Automatically populates `is_stdlib` and `is_dependency` fields in SearchResult and GetItemDocResponse models using DependencyFilter integration via `get_dependency_filter()` global instance for improved performance and cache utilization. **Critical Fix Applied**: Implements `_build_module_tree()` helper method that transforms flat database results into hierarchical ModuleTreeNode structures, resolving Pydantic validation errors by properly fulfilling service layer data transformation responsibility. **Service Layer Fix**: Fixed search_examples method to properly handle dictionary results from search_example_embeddings, correctly mapping fields to CodeExample model requirements.
238
238
-**IngestionService**: Manages the complete ingestion pipeline, pre-ingestion workflows, and cargo file processing
239
239
-**CrossReferenceService**: **Phase 6 Enhancement**: Provides advanced cross-reference operations including import resolution, dependency graph analysis, migration suggestions, and re-export tracing. Implements circuit breaker pattern for resilience, LRU cache with 5-minute TTL for performance, and DFS algorithms for cycle detection in dependency graphs.
240
240
-**Transport Layer Decoupling**: Business logic is independent of whether accessed via MCP or REST
@@ -8892,23 +8892,30 @@ The new `dependency_filter.py` module provides efficient dependency tracking and
8892
8892
The `DependencyFilter` class implements set-based dependency management with persistent caching:
8893
8893
8894
8894
**Core Implementation**:
8895
-
-**Set-Based Storage**: Uses Python `set()` for O(1) lookup performance
8895
+
-**Set-Based Storage**: Uses Python `set()` for O(1) lookup performance
8896
+
-**Dual Storage Architecture**: Maintains both global `_dependencies` set and crate-specific `_crate_dependencies` mapping
8896
8897
-**JSON Persistence**: Caches dependency list at `/tmp/docsrs_deps.json`
8897
8898
-**Lazy Loading**: Dependencies loaded on first access to minimize startup overhead
8898
8899
-**Thread Safety**: Designed for concurrent access in async environment
8899
8900
8901
+
**Data Structures**:
8902
+
-**`_dependencies`**: Global set of all known dependencies for fallback lookup
8903
+
-**`_crate_dependencies`**: Dict mapping crate names to their specific dependency sets for targeted filtering
Copy file name to clipboardExpand all lines: UsefulInformation.json
+26-1Lines changed: 26 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"projectName": "docsrs-mcp",
3
-
"lastUpdated": "2025-09-04",
3
+
"lastUpdated": "2025-09-05",
4
4
"purpose": "Track errors, solutions, and lessons learned during development",
5
5
"categories": {
6
6
"errorSolutions": {
@@ -2000,6 +2000,31 @@
2000
2000
"Recovery scaling is conservative to prevent memory pressure oscillation"
2001
2001
],
2002
2002
"measuredImpact": "Prevented OOM conditions and maintained processing throughput under memory constraints"
2003
+
},
2004
+
{
2005
+
"error": "DependencyFilter.is_dependency() Parameter Mismatch - TypeError: is_dependency() takes 2 positional arguments but 3 were given",
2006
+
"rootCause": "Method signature expected only module_path parameter but CrateService was calling with both crate_name and item_path. Original method signature was is_dependency(self, module_path: str) but CrateService calls were passing (item_path, crate_name) parameters in crate_service.py lines 224 and 288.",
2007
+
"solution": "Extended is_dependency method to accept optional crate_name parameter for backward compatibility. New signature: is_dependency(self, module_path: str, crate_name: str | None = None) -> bool. Method now properly utilizes _crate_dependencies dict for crate-specific filtering. CrateService updated to use get_dependency_filter() global instance instead of creating new instances. Parameter order corrected to (item_path, crate_name).",
2008
+
"context": "TypeError preventing MCP server startup when CrateService attempted to filter dependencies during item processing",
2009
+
"lesson": "Method signatures must match caller expectations, especially for global instances accessed across modules. Always validate parameter order and count when refactoring method signatures.",
2010
+
"pattern": "Use optional parameters with default values for backward compatibility when extending method signatures. Ensure global instances are accessed through proper getter functions.",
"codeExample": "# BEFORE (causing TypeError):\ndef is_dependency(self, module_path: str) -> bool:\n return module_path in self._dependency_paths\n\n# CrateService calling:\nif self.dependency_filter.is_dependency(item_path, crate_name): # TypeError\n\n# AFTER (Bug fix):\ndef is_dependency(self, module_path: str, crate_name: str | None = None) -> bool:\n if crate_name and crate_name in self._crate_dependencies:\n return module_path in self._crate_dependencies[crate_name]\n return module_path in self._dependency_paths\n\n# CrateService updated to use global instance:\nif get_dependency_filter().is_dependency(item_path, crate_name):",
2014
+
"debuggingTechnique": "Run unit tests to verify both method signatures work correctly. Test MCP server startup to confirm TypeError is resolved.",
2015
+
"testingConfirmed": [
2016
+
"Unit tests confirm both signatures work: is_dependency(path) and is_dependency(path, crate)",
2017
+
"MCP server runs without TypeError during initialization",
2018
+
"CrateService properly filters dependencies using global instance",
2019
+
"Backward compatibility maintained for existing code"
2020
+
],
2021
+
"preventionStrategy": "Always run unit tests after method signature changes. Validate all calling sites when modifying method parameters. Use optional parameters to maintain backward compatibility.",
2022
+
"implementationDetails": [
2023
+
"Added optional crate_name parameter with default None value",
2024
+
"Method now checks _crate_dependencies dict for crate-specific filtering",
2025
+
"CrateService uses get_dependency_filter() instead of creating instances",
0 commit comments