Skip to content
Open
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 scripts/drift_check/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ def _build_snapshots(
required_refs_path: Optional[Path],
gh_token: Optional[str],
) -> List[RepoSnapshot]:
if config_path is None:
config_path = meta_repo_path / "standards" / "drift-checker.config.json"
if not config_path.is_file():
print(
f"warning: config not found at {config_path}; using permissive defaults",
file=sys.stderr,
)

try:
cfg = load_config(config_path)
except ConfigError as exc:
Expand Down
57 changes: 57 additions & 0 deletions tests/test_issue_153_config_cwd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""Regression tests for #153: drift_check must resolve its default config from
the meta repo, not from the process cwd."""
import json
from pathlib import Path

from scripts.drift_check import cli
from tests.conftest import FIXTURES


def _meta_repo(root: Path, with_config: bool) -> Path:
meta = root / "meta"
meta.mkdir()
(meta / "STANDARDS_VERSION").write_text("1.6.3", encoding="utf-8")
(meta / "standards").mkdir()
(meta / "standards" / "required-refs.json").write_text(
'{"version":1,"requirements":{"cursor-plugin":{},"mcp-server":{}}}',
encoding="utf-8",
)
if with_config:
(meta / "standards" / "drift-checker.config.json").write_text(
json.dumps({
"version": 1,
"globals": {"signal_policy": "same-major-minor", "skip_checks": []},
"types": {
"cursor-plugin": {
"skip_checks": [],
"required_workflows": ["validate.yml", "release.yml"],
}
},
"repos": {},
}),
encoding="utf-8",
)
return meta


def test_default_config_is_resolved_from_meta_repo_not_cwd(tmp_path, monkeypatch, capsys):
meta = _meta_repo(tmp_path, with_config=True)
monkeypatch.chdir(tmp_path)

rc = cli.main(["--local", str(FIXTURES / "clean_repo"), "--meta-repo", str(meta)])

captured = capsys.readouterr()
assert rc == 1, captured.err
assert "required workflow 'validate.yml' is absent" in captured.out + captured.err


def test_missing_default_config_warns(tmp_path, monkeypatch, capsys):
meta = _meta_repo(tmp_path, with_config=False)
monkeypatch.chdir(tmp_path)

rc = cli.main(["--local", str(FIXTURES / "clean_repo"), "--meta-repo", str(meta)])

captured = capsys.readouterr()
assert rc == 0, captured.err
assert "config not found" in captured.err
assert str(meta / "standards" / "drift-checker.config.json") in captured.err
Loading