Skip to content

Commit e9aeb58

Browse files
committed
fix(drift-check): resolve default config from meta repo
The default drift-check config was resolved against the process cwd, so running the checker from a tool repo silently used permissive defaults while CI enforced required workflows. Resolve it from meta_repo_path and warn when the default file is missing. Regression tests run the CLI from a different cwd with and without a meta config. Full suite: 354 passed, 2 skipped. Sabotage run of the fix made both tests fail. Closes #153 Signed-off-by: Abhishek Deepak <abhicodes-007@users.noreply.github.com>
1 parent 2c7a7fe commit e9aeb58

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎scripts/drift_check/cli.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,14 @@ def _build_snapshots(
231231
required_refs_path: Optional[Path],
232232
gh_token: Optional[str],
233233
) -> List[RepoSnapshot]:
234+
if config_path is None:
235+
config_path = meta_repo_path / "standards" / "drift-checker.config.json"
236+
if not config_path.is_file():
237+
print(
238+
f"warning: config not found at {config_path}; using permissive defaults",
239+
file=sys.stderr,
240+
)
241+
234242
try:
235243
cfg = load_config(config_path)
236244
except ConfigError as exc:

‎tests/test_issue_153_config_cwd.py‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""Regression tests for #153: drift_check must resolve its default config from
2+
the meta repo, not from the process cwd."""
3+
import json
4+
from pathlib import Path
5+
6+
from scripts.drift_check import cli
7+
from tests.conftest import FIXTURES
8+
9+
10+
def _meta_repo(root: Path, with_config: bool) -> Path:
11+
meta = root / "meta"
12+
meta.mkdir()
13+
(meta / "STANDARDS_VERSION").write_text("1.6.3", encoding="utf-8")
14+
(meta / "standards").mkdir()
15+
(meta / "standards" / "required-refs.json").write_text(
16+
'{"version":1,"requirements":{"cursor-plugin":{},"mcp-server":{}}}',
17+
encoding="utf-8",
18+
)
19+
if with_config:
20+
(meta / "standards" / "drift-checker.config.json").write_text(
21+
json.dumps({
22+
"version": 1,
23+
"globals": {"signal_policy": "same-major-minor", "skip_checks": []},
24+
"types": {
25+
"cursor-plugin": {
26+
"skip_checks": [],
27+
"required_workflows": ["validate.yml", "release.yml"],
28+
}
29+
},
30+
"repos": {},
31+
}),
32+
encoding="utf-8",
33+
)
34+
return meta
35+
36+
37+
def test_default_config_is_resolved_from_meta_repo_not_cwd(tmp_path, monkeypatch, capsys):
38+
meta = _meta_repo(tmp_path, with_config=True)
39+
monkeypatch.chdir(tmp_path)
40+
41+
rc = cli.main(["--local", str(FIXTURES / "clean_repo"), "--meta-repo", str(meta)])
42+
43+
captured = capsys.readouterr()
44+
assert rc == 1, captured.err
45+
assert "required workflow 'validate.yml' is absent" in captured.out + captured.err
46+
47+
48+
def test_missing_default_config_warns(tmp_path, monkeypatch, capsys):
49+
meta = _meta_repo(tmp_path, with_config=False)
50+
monkeypatch.chdir(tmp_path)
51+
52+
rc = cli.main(["--local", str(FIXTURES / "clean_repo"), "--meta-repo", str(meta)])
53+
54+
captured = capsys.readouterr()
55+
assert rc == 0, captured.err
56+
assert "config not found" in captured.err
57+
assert str(meta / "standards" / "drift-checker.config.json") in captured.err

0 commit comments

Comments
 (0)