From 21bb0791079620c7bf9ea778553123cb922363de Mon Sep 17 00:00:00 2001 From: mochan Date: Sat, 30 May 2026 19:19:42 +0530 Subject: [PATCH] chore(config): remove vestigial mcp.enabled block The `mcp:` field in `.codegraph.yml` was never read by any code path. Sitting next to the active `register_mcp: true`, it confused users into thinking it had to be flipped on manually. Removed from `CodegraphConfig`. `model_config = {"extra": "ignore"}` keeps forward-compat: existing 0.1.x configs that still carry the field load without error. v0.1.2 backlog item #7. --- CHANGELOG.md | 8 ++++++ codegraph/config.py | 8 ++++-- tests/test_config_mcp_removal.py | 43 ++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tests/test_config_mcp_removal.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fe963c..42bc3bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Removed + +- **Dead `mcp.enabled` config block.** `.codegraph.yml` carried an + `mcp.enabled: false` default that no code path ever read — confusing + next to the active `register_mcp: true`. Removed from `CodegraphConfig`; + the model is set to silently ignore the field so existing 0.1.x configs + still load without error. New configs no longer emit it. + ### Added - **`codegraph clean` subcommand + auto-prune of `.codegraph/explore/`.** diff --git a/codegraph/config.py b/codegraph/config.py index fa416cb..ca5f774 100644 --- a/codegraph/config.py +++ b/codegraph/config.py @@ -5,7 +5,7 @@ from typing import Any import yaml -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class DeadCodeConfig(BaseModel): @@ -29,6 +29,11 @@ class DeadCodeConfig(BaseModel): class CodegraphConfig(BaseModel): + # `mcp:` was a vestigial block in 0.1.x configs (`mcp.enabled: false`) + # that no code path ever read. Removed in 0.1.2. `extra="ignore"` keeps + # forward-compat: old configs containing it still load without error. + model_config = ConfigDict(extra="ignore") + version: int = 1 languages: list[str] = Field( default_factory=lambda: ["python", "typescript", "javascript"] @@ -39,7 +44,6 @@ class CodegraphConfig(BaseModel): default_factory=lambda: {"backend": "local"} ) critical_paths: list[dict[str, Any]] = Field(default_factory=list) - mcp: dict[str, Any] = Field(default_factory=lambda: {"enabled": False}) install_hook: bool = False register_mcp: bool = False dead_code: DeadCodeConfig = Field(default_factory=DeadCodeConfig) diff --git a/tests/test_config_mcp_removal.py b/tests/test_config_mcp_removal.py new file mode 100644 index 0000000..167df60 --- /dev/null +++ b/tests/test_config_mcp_removal.py @@ -0,0 +1,43 @@ +"""Tests for the `mcp:` block removal (v0.1.2 #7). + +Pre-0.1.2 configs carried a vestigial ``mcp.enabled: false`` block that +no code path read. The field was removed in 0.1.2; the model is set to +silently ignore it so existing configs still load. +""" +from __future__ import annotations + +from pathlib import Path + +import yaml + +from codegraph.config import CodegraphConfig, load_config, save_config + + +def test_old_config_with_mcp_block_still_loads(tmp_path: Path) -> None: + cfg_path = tmp_path / ".codegraph.yml" + cfg_path.write_text(yaml.dump({ + "version": 1, + "register_mcp": True, + "mcp": {"enabled": False}, # old vestigial field + })) + cfg = load_config(tmp_path) + assert cfg.register_mcp is True + # The vestigial field should NOT appear as an attribute. + assert not hasattr(cfg, "mcp") + + +def test_fresh_config_does_not_emit_mcp_block(tmp_path: Path) -> None: + cfg = CodegraphConfig() + save_config(tmp_path, cfg) + dumped = yaml.safe_load((tmp_path / ".codegraph.yml").read_text()) + assert "mcp" not in dumped + assert "register_mcp" in dumped + + +def test_other_unknown_fields_also_ignored(tmp_path: Path) -> None: + (tmp_path / ".codegraph.yml").write_text(yaml.dump({ + "version": 1, + "future_field_we_havent_added_yet": "ok", + })) + cfg = load_config(tmp_path) + assert cfg.version == 1