fix(consistency): preserve repository domain in briefs
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a02b22-9638-76d2-bbff-b7ea1770b118
This commit is contained in:
tegwick 2026-08-23 13:57:22 +02:00
parent b91b8705d1
commit fae2816199
3 changed files with 72 additions and 4 deletions

View file

@ -41,6 +41,7 @@ from consistency_check import (
_patch_frontmatter_field,
_patch_task_status_in_file,
_report_needs_action,
_write_custodian_brief,
archive_closed_workplans,
canonical_workplan_filename,
check_repo,
@ -72,6 +73,63 @@ class TestResolveTopicDomainSlug:
assert resolve_topic_domain_slug("custodian", repo_market_domain="infotech") == "infotech"
class TestCustodianBriefDomain:
@staticmethod
def _install_common_mocks(monkeypatch, calls, repo_payload, topic_payload=None):
def fake_get(_api_base, path, params=None):
calls.append((path, params))
if path == "/repos/demo":
return repo_payload
if path == "/workplans":
return [{"id": "wp-1", "title": "Open", "topic_id": None}]
if path == "/tasks":
return []
if path == "/repo-goals":
return []
if path.startswith("/topics/"):
return topic_payload
if path == "/messages":
return []
return None
monkeypatch.setattr("consistency_check._api_get", fake_get)
monkeypatch.setattr(
"consistency_check._git_commit_writeback", lambda *args, **kwargs: True
)
def test_brief_prefers_repository_domain_when_workplan_topic_is_null(
self, tmp_path, monkeypatch
):
calls = []
self._install_common_mocks(
monkeypatch,
calls,
{"id": "repo-1", "domain_slug": "infotech"},
)
assert _write_custodian_brief("http://unused", "demo", str(tmp_path)) is True
brief = (tmp_path / ".custodian-brief.md").read_text(encoding="utf-8")
assert "**Domain:** infotech" in brief
assert '`get_domain_summary("infotech")`' in brief
assert not any(path.startswith("/topics/") for path, _params in calls)
def test_brief_retains_topic_fallback_for_legacy_repo_response(
self, tmp_path, monkeypatch
):
calls = []
self._install_common_mocks(
monkeypatch,
calls,
{"id": "repo-1"},
{"domain_slug": "financials"},
)
assert _write_custodian_brief("http://unused", "demo", str(tmp_path)) is True
brief = (tmp_path / ".custodian-brief.md").read_text(encoding="utf-8")
assert "**Domain:** financials" in brief
assert any(path.startswith("/topics/") for path, _params in calls)
class TestRepoManagerConformanceAdapter:
def test_surfaces_repo_manager_findings_without_reimplementing_rules(self, tmp_path, monkeypatch):
rmgr = tmp_path / "rmgr"