MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / can_reach

Function can_reach

api/dependency_resolver.py:176–194  ·  view source on GitHub ↗
(current_id: int, depth: int = 0)

Source from the content-addressed store, hash-verified

174 visited: set[int] = set()
175
176 def can_reach(current_id: int, depth: int = 0) -> bool:
177 # Security: Prevent stack overflow with depth limit
178 if depth > MAX_DEPENDENCY_DEPTH:
179 return True # Assume cycle if too deep (fail-safe)
180 if current_id == source_id:
181 return True
182 if current_id in visited:
183 return False
184 visited.add(current_id)
185
186 current = feature_map.get(current_id)
187 if not current:
188 return False
189
190 deps = current.get("dependencies") or []
191 for dep_id in deps:
192 if can_reach(dep_id, depth + 1):
193 return True
194 return False
195
196 return can_reach(target_id)
197

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected