The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(ci): keep earlier objections when the duplicate notice is re-posted
mateo-berried5761daef4a
diff --git a/scripts/auto-close-duplicates.test.ts b/scripts/auto-close-duplicates.test.tsindex 6a7a3a507bd..b49bf05cbc2 100644--- a/scripts/auto-close-duplicates.test.ts+++ b/scripts/auto-close-duplicates.test.ts@@ -14,6 +14,7 @@ import {type Comment,type GitHubApi,type Issue,+ type Reaction,type SweepConfig,} from "./auto-close-duplicates";@@ -78,6 +79,15 @@ describe("pendingNotice", () => {expect(reposted.kind).toBe("skip");});+ test("an objection posted before a re-posted notice still keeps the issue open", () => {+ const verdict = pendingNotice(+ issue(35, "t"),+ [notice([10], daysAgo(10)), humanComment(daysAgo(7)), notice([10], daysAgo(4), { id: 902 })],+ config,+ );+ expect(verdict).toEqual({ kind: "skip", reason: "someone replied after the notice" });+ });+test("a zero-day grace period acts on the notice at once", () => {const verdict = pendingNotice(issue(35, "t"), [notice([10], daysAgo(0.01))], { ...config, graceDays: 0 });expect(verdict.kind).toBe("pending");@@ -155,7 +165,10 @@ describe("sweepIssue", () => {const reporter = issue(35, "[Bug]: Gemma 4-e4b fails on Vertex");const original = issue(10, "[Bug]: Gemma 4-e4b fails on Vertex");- function fakeApi(): { readonly api: GitHubApi; readonly writes: readonly string[] } {+ function fakeApi(+ comments: readonly Comment[] = [notice([10], daysAgo(5))],+ reactionsByNotice: Readonly<Record<number, readonly Reaction[]>> = {},+ ): { readonly api: GitHubApi; readonly writes: readonly string[] } {const writes: string[] = [];const api: GitHubApi = {request: async <T>(method: string, path: string, body?: object): Promise<T> => {@@ -164,10 +177,11 @@ describe("sweepIssue", () => {return {} as T;}if (path.startsWith("/repos/BerriAI/litellm/issues/35/comments")) {- return [notice([10], daysAgo(5))] as T;+ return comments as T;}- if (path.startsWith("/repos/BerriAI/litellm/issues/comments/900/reactions")) {- return [] as T;+ const reactionsPath = path.match(/^\/repos\/BerriAI\/litellm\/issues\/comments\/(\d+)\/reactions/);+ if (reactionsPath) {+ return (reactionsByNotice[Number(reactionsPath[1])] ?? []) as T;}if (path === "/repos/BerriAI/litellm/issues/10") {return original as T;@@ -185,6 +199,13 @@ describe("sweepIssue", () => {expect(writes).toEqual([]);});+ test("a thumbs down on an earlier notice still keeps the issue open", async () => {+ const { api, writes } = fakeApi([notice([10], daysAgo(9)), notice([10], daysAgo(5), { id: 902 })], { 900: [{ content: "-1" }] });+ const verdict = await sweepIssue(api, config, reporter);+ expect(verdict).toEqual({ kind: "skip", reason: "someone gave the notice a thumbs down" });+ expect(writes).toEqual([]);+ });+test("a real run comments, labels, then closes with the duplicate reason", async () => {const { api, writes } = fakeApi();const verdict = await sweepIssue(api, config, reporter);diff --git a/scripts/auto-close-duplicates.ts b/scripts/auto-close-duplicates.tsindex 941f281efe6..c595104d886 100644--- a/scripts/auto-close-duplicates.ts+++ b/scripts/auto-close-duplicates.ts@@ -34,7 +34,7 @@ export interface SweepConfig {}export type NoticeVerdict =- | { readonly kind: "pending"; readonly notice: Comment; readonly candidates: readonly number[] }+ | { readonly kind: "pending"; readonly notices: readonly Comment[]; readonly candidates: readonly number[] }| { readonly kind: "skip"; readonly reason: string };export type CloseVerdict =@@ -91,23 +91,24 @@ export function pendingNotice(return skip("was reopened after an automatic close");}const notices = comments.filter((comment) => comment.user.type === "Bot" && NOTICE_MARKER.test(comment.body));- const notice = notices[notices.length - 1];- if (notice === undefined) {+ const first = notices[0];+ const latest = notices[notices.length - 1];+ if (first === undefined || latest === undefined) {return skip("carries no duplicate notice");}- const noticeAt = new Date(notice.created_at);- const ageDays = (config.now.getTime() - noticeAt.getTime()) / DAY_MS;+ const ageDays = (config.now.getTime() - new Date(latest.created_at).getTime()) / DAY_MS;if (ageDays < config.graceDays) {return skip(`notice is ${ageDays.toFixed(1)} days old, grace period is ${config.graceDays}`);}- if (comments.some((comment) => comment.user.type !== "Bot" && new Date(comment.created_at) > noticeAt)) {+ const firstNoticeAt = new Date(first.created_at);+ if (comments.some((comment) => comment.user.type !== "Bot" && new Date(comment.created_at) > firstNoticeAt)) {return skip("someone replied after the notice");}- const candidates = candidateNumbers(notice.body, issue.number);+ const candidates = candidateNumbers(latest.body, issue.number);if (candidates.length === 0) {return skip("no candidate is older than this issue");}- return { kind: "pending", notice, candidates };+ return { kind: "pending", notices, candidates };}export function duplicateTarget(@@ -197,7 +198,11 @@ export async function sweepIssue(api: GitHubApi, config: SweepConfig, issue: Issif (pending.kind === "skip") {return pending;}- const reactions = await listAll<Reaction>(api, `/repos/${config.repo}/issues/comments/${pending.notice.id}/reactions`);+ const reactions = (+ await Promise.all(+ pending.notices.map((notice) => listAll<Reaction>(api, `/repos/${config.repo}/issues/comments/${notice.id}/reactions`)),+ )+ ).flat();const candidates = await Promise.all(pending.candidates.map((candidate) => api.request<Issue>("GET", `/repos/${config.repo}/issues/${candidate}`)),);