refactor(triage): share INTERNAL_ASSOCIATIONS with sibling triage script
Some checks failed
Unit Tests: Security / security (push) Has been cancelled
Unit Tests: Proxy DB Operations / assert-shard-coverage (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-utils (push) Has been cancelled
Unit Tests: Proxy DB Operations / auth-checks (push) Has been cancelled
Unit Tests: Proxy DB Operations / budgets (push) Has been cancelled
Unit Tests: Proxy DB Operations / custom-logging (push) Has been cancelled
Unit Tests: Proxy DB Operations / db-and-spend (push) Has been cancelled
Unit Tests: Proxy DB Operations / endpoints-and-responses (push) Has been cancelled
Unit Tests: Proxy DB Operations / guardrails-hooks (push) Has been cancelled
Unit Tests: Proxy DB Operations / jwt-and-keys (push) Has been cancelled
Unit Tests: Proxy DB Operations / key-generation (push) Has been cancelled
Unit Tests: Proxy DB Operations / logging-misc (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-runtime (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-server-core (push) Has been cancelled
Unit Tests: Proxy DB Operations / schema-migration (push) Has been cancelled

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.
This commit is contained in:
mateo-berri 2026-05-19 08:55:55 +00:00
parent dc80aa8290
commit 40da407e8e
No known key found for this signature in database

View file

@ -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