Build one entry for an already-resolved path and known file key. ``_load_graph`` is also used by the CLI, where invalid input terminates the process. A client-supplied ``project_path`` must instead become a tool error, so the shared MCP server can continue serving other grap
(self, resolved_path: str, key: tuple[int, int])
| 153 | self._loading: dict[tuple[str, bool], threading.Event] = {} |
| 154 | |
| 155 | def _load_entry(self, resolved_path: str, key: tuple[int, int]) -> dict: |
| 156 | """Build one entry for an already-resolved path and known file key. |
| 157 | |
| 158 | ``_load_graph`` is also used by the CLI, where invalid input terminates |
| 159 | the process. A client-supplied ``project_path`` must instead become a |
| 160 | tool error, so the shared MCP server can continue serving other graphs. |
| 161 | """ |
| 162 | try: |
| 163 | graph = _load_graph(resolved_path) |
| 164 | except SystemExit as exc: |
| 165 | raise RuntimeError(f"could not load graph.json at {resolved_path}") from exc |
| 166 | # Warm the index before exposing the graph so its first query does not |
| 167 | # pay the expensive build cost. |
| 168 | _get_trigram_index(graph) |
| 169 | communities = _communities_from_graph(graph) |
| 170 | entry = { |
| 171 | "key": key, |
| 172 | "G": graph, |
| 173 | "communities": communities, |
| 174 | } |
| 175 | return entry |
| 176 | |
| 177 | def load(self, resolved_path: str, *, pinned: bool = False) -> tuple[nx.Graph, dict[int, list[str]]]: |
| 178 | """Return a fresh context, retaining project contexts by LRU order. |
no test coverage detected