From 40da407e8e63f659fd3a1d1fe877914daad7ac1f Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 19 May 2026 08:55:55 +0000 Subject: [PATCH] refactor(triage): share INTERNAL_ASSOCIATIONS with sibling triage script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop the locally-redefined INTERNAL_AUTHOR_ASSOCIATIONS frozenset in close_low_quality_prs.py and import INTERNAL_ASSOCIATIONS from triage_with_llm.py instead — the same pattern already used for AGENT_SHIN_AUTO_CLOSE_MARKER. Eliminates the drift risk where one script's exempt-author set could diverge from the other's without any test noticing. --- .github/scripts/close_low_quality_prs.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/scripts/close_low_quality_prs.py b/.github/scripts/close_low_quality_prs.py index 26bd6e44cb2..476e9dde646 100644 --- a/.github/scripts/close_low_quality_prs.py +++ b/.github/scripts/close_low_quality_prs.py @@ -44,15 +44,19 @@ import sys from pathlib import Path from typing import Iterable -# Share the auto-close marker with the sibling Agent Shin script instead of -# duplicating the literal — the reconsider provenance check -# (`was_auto_closed_by_agent_shin`) keys off this exact phrase, so a drift -# between the two files would silently break reconsider for Greptile-closed -# PRs without any test catching it. +# Share constants with the sibling Agent Shin script instead of duplicating +# them. `AGENT_SHIN_AUTO_CLOSE_MARKER` is the literal phrase the reconsider +# provenance check keys off, and `INTERNAL_ASSOCIATIONS` is the exempt-author +# set; drift between the two files would silently break reconsider for +# Greptile-closed PRs (marker) or let one script close a PR the other would +# skip (associations), with no test catching it. _SCRIPTS_DIR = Path(__file__).resolve().parent if str(_SCRIPTS_DIR) not in sys.path: sys.path.insert(0, str(_SCRIPTS_DIR)) -from triage_with_llm import AGENT_SHIN_AUTO_CLOSE_MARKER # noqa: E402 +from triage_with_llm import ( # noqa: E402 + AGENT_SHIN_AUTO_CLOSE_MARKER, + INTERNAL_ASSOCIATIONS, +) # Greptile's GitHub App appears as `greptile-apps[bot]` in REST API comments # and `greptile-apps` in `gh pr view --json` output. Accept either form. @@ -67,10 +71,6 @@ SCORE_PATTERN = re.compile( re.IGNORECASE, ) -# `author_association` values for internal BerriAI contributors who should be -# exempt from auto-triage. -INTERNAL_AUTHOR_ASSOCIATIONS = frozenset({"OWNER", "MEMBER", "COLLABORATOR"}) - # Default labels that exempt a PR from auto-close. Defined at module scope (not # as a mutable argparse default) so that `--optout-label foo` REPLACES the # defaults instead of appending to them — the argparse `action="append"` + @@ -159,7 +159,7 @@ def is_external_pr_author(pr: dict, repo: str | None) -> bool: # Fail-safe: if the API lookup failed (empty string), treat the author as # internal so we don't auto-close their PR. Auto-close is destructive, so # an unknown association should never make a PR eligible for closing. - if not association or association in INTERNAL_AUTHOR_ASSOCIATIONS: + if not association or association in INTERNAL_ASSOCIATIONS: return False return True