Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`.**
Expand Down
8 changes: 6 additions & 2 deletions codegraph/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Any

import yaml
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field


class DeadCodeConfig(BaseModel):
Expand All @@ -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"]
Expand All @@ -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)
Expand Down
43 changes: 43 additions & 0 deletions tests/test_config_mcp_removal.py
Original file line number Diff line number Diff line change
@@ -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
Loading