From 79c0af527318d5360955e7b1b070a4fc2cbb8737 Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:29:12 +0100 Subject: [PATCH] Honor GitHub CLI config directory overrides Architecture-Review: unchanged; the existing subprocess allowlist passes two operator profile selectors while explicit and App token precedence and publisher gates stay the same. Co-Authored-By: Codex --- src/loopzero/github.py | 2 +- tests/fake_gh.py | 2 +- tests/test_github.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/loopzero/github.py b/src/loopzero/github.py index 45fb8ce2..a1ab4ea6 100644 --- a/src/loopzero/github.py +++ b/src/loopzero/github.py @@ -23,7 +23,7 @@ from loopzero.runners import review_settings from loopzero.types import BLOCKING, Finding, ReviewResult -GH_ENV = ("PATH", "HOME", "LANG", "LC_ALL", "TERM", "GH_TOKEN", "GITHUB_TOKEN", "GH_HOST") +GH_ENV = ("PATH", "HOME", "LANG", "LC_ALL", "TERM", "GH_TOKEN", "GITHUB_TOKEN", "GH_HOST", "GH_CONFIG_DIR", "XDG_CONFIG_HOME") APP_TOKEN_HELPER = Path.home() / ".config/loopzero/app-token" _app_token_cache = ("", 0.0) MISSING_REVIEW_REASON = "no review recorded for the current head" diff --git a/tests/fake_gh.py b/tests/fake_gh.py index 6fa55295..5f1b102b 100644 --- a/tests/fake_gh.py +++ b/tests/fake_gh.py @@ -7,7 +7,7 @@ def replay( argv: list[str], calls: str, scenario: str, cwd: str, token: str | None, ) -> tuple[int, str, str]: - record = {"argv": argv, "token": token} + record = dict(argv=argv, token=token, config=[os.getenv(k) for k in ("GH_CONFIG_DIR", "XDG_CONFIG_HOME")]) input_files = {} for flag in ("--input", "--body-file"): if flag in argv: diff --git a/tests/test_github.py b/tests/test_github.py index c961f43e..3ee88ac9 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -738,6 +738,8 @@ def test_app_identity_selection_and_cache(gh: FakeGh, tmp_path: Path, monkeypatc monkeypatch.setattr(github.time, "CLOCK_BOOTTIME", 7, raising=False) monkeypatch.setattr(github.time, "clock_gettime", lambda _: boot_time) monkeypatch.setattr(github.time, "monotonic", lambda: 100.0) # stopped during host suspend + monkeypatch.setenv("GH_CONFIG_DIR", "/fixture/gh") + monkeypatch.setenv("XDG_CONFIG_HOME", "/fixture/xdg") monkeypatch.setenv("GH_TOKEN", "operator-token") gh.respond("api repos/acme/widgets", {}) gh.respond("api graphql viewer", {"data": {"viewer": {"login": "app[bot]"}}}) @@ -751,10 +753,8 @@ def test_app_identity_selection_and_cache(gh: FakeGh, tmp_path: Path, monkeypatc github._gh("api", "repos/acme/widgets/issues/7/comments", "--method", "POST") github._gh("api", "graphql", "-f", "query=mutation { resolveReviewThread(input: {}) { clientMutationId } }") assert github.auth_token() == "operator-token" - assert [c["token"] for c in gh.calls] == [ - "synthetic-app-token", "synthetic-app-token", "synthetic-app-token", - "operator-token", "operator-token", "operator-token", - ] + assert [c["token"] for c in gh.calls] == ["synthetic-app-token"] * 3 + ["operator-token"] * 3 + assert all(call["config"] == ["/fixture/gh", "/fixture/xdg"] for call in gh.calls) assert counter.read_text().splitlines() == ["called"] boot_time += 3_620 wall_time += 2_620 # The wall clock stepped back by a thousand seconds.