This commit is contained in:
PT 2026-10-19 22:12:58 +00:00 • committed by GitHub
commit f535e3ae4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -3,9 +3,9 @@
Every pull request whose diff against its merge base touches one of the two cost map files gets the file
checks: the files parse and the backup copy matches the root file. A pull request that leaves both untouched
skips them, since merging it keeps the base branch's copies and its head tree only carries whatever state the
branch was cut from. Pull requests from the cost map sync bot (branches named litellm_cost_map_sync_*) always
get the file checks and additionally may only touch those two files or the legacy schema
path and may only add or update models.
branch was cut from. Pull requests from the cost map sync bots (branches named litellm-providers/price-sync* or
litellm_cost_map_sync_*) always get the file checks and additionally may only touch those two files or the
legacy schema path and may only add or update models.
"""
from __future__ import annotations
@ -23,7 +23,7 @@ COST_MAP_PATH: Final = "model_prices_and_context_window.json"
BACKUP_PATH: Final = "litellm/model_prices_and_context_window_backup.json"
LEGACY_SCHEMA_PATH: Final = "model_prices_and_context_window.schema.json"
GUARDED_PATHS: Final = (COST_MAP_PATH, BACKUP_PATH)
BOT_BRANCH_PREFIX: Final = "litellm_cost_map_sync_"
BOT_BRANCH_PREFIXES: Final = ("litellm-providers/price-sync", "litellm_cost_map_sync_")
SPECIAL_ROOT_KEYS: Final = frozenset({"sample_spec", "fallback_generalizations"})
EVALUATION_OUTPUT_PRICE_SOURCES: Final[Mapping[str, str]] = MappingProxyType({})
@ -173,7 +173,7 @@ def main(argv: Sequence[str]) -> int:
parser.add_argument("--head", required=True, help="head commit of the pull request")
parser.add_argument("--head-ref", required=True, help="head branch name of the pull request")
args: Final = parser.parse_args(argv)
bot: Final = args.head_ref.startswith(BOT_BRANCH_PREFIX)
bot: Final = args.head_ref.startswith(BOT_BRANCH_PREFIXES)
changed: Final = changed_files(args.base, args.head)
if changed is None:
print(f"cost map guard failed: git diff {args.base} {args.head} failed, so the changed files are unknown")

View file

@ -251,7 +251,10 @@ def _run_guard(repo: Path, base: str, head: str, head_ref: str) -> subprocess.Co
("head_ref", "expected_code", "expected_line"),
[
(BOT_REF, 1, "- bot PRs may not remove models: openrouter/b"),
("litellm-providers/price-sync-openrouter", 1, "- bot PRs may not remove models: openrouter/b"),
("litellm-providers/price-sync", 1, "- bot PRs may not remove models: openrouter/b"),
("litellm_fix_pricing", 0, "cost map guard passed (human PR, file checks only)"),
("fix-openrouter-price-sync", 0, "cost map guard passed (human PR, file checks only)"),
],
)
def test_main_reads_both_revisions_from_git(