From ec1d042b0afe5d39b2f3e8f3401f0973b00e5c0b Mon Sep 17 00:00:00 2001 From: peppa-bot Date: Wed, 25 Nov 2026 20:53:41 +0500 Subject: [PATCH] =?UTF-8?q?PEP-297:=20=D0=B2=D1=80=D0=B5=D0=BC=D1=8F=20?= =?UTF-8?q?=D0=B2=20=D0=BE=D1=87=D0=B5=D1=80=D0=B5=D0=B4=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B0=D0=B3=D0=B5=D0=BD=D1=82=D0=B0=20=E2=80=94=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B0=D0=B3=D0=B5=D0=BD=D1=82=D0=B0=20=D0=B2=20=D1=88=D0=B0?= =?UTF-8?q?=D0=B3=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit После выкатки PEP-269 задача с конфликтом, которая стояла в очереди на агента (предел задач на код), через 90 минут эскалировалась суперадмину как «агент не обновил изменения», хотя агент ещё не стартовал: 15 ложных сообщений за полтора часа. Пока задача ждёт места (isWaitingForCapacity), шаг — «ждём», а время агента отсчитывается с момента, когда он получил место. Тест в conflict-step.test.ts падал до исправления. Co-Authored-By: Claude Fable 5.2 --- packages/runner/src/conflict-step.ts | 8 +++++++ packages/testkit/test/conflict-step.test.ts | 23 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/packages/runner/src/conflict-step.ts b/packages/runner/src/conflict-step.ts index d1c06df8..6065514a 100644 --- a/packages/runner/src/conflict-step.ts +++ b/packages/runner/src/conflict-step.ts @@ -16,6 +16,7 @@ import { getSetting, giteaForBot, isProjectPaused, + isWaitingForCapacity, listSessions, logEvent, platformDelay, @@ -44,6 +45,7 @@ export interface ConflictStep { /** Head of the result and of the main branch when the agent was last asked. */ headSha: string; baseSha: string | null; + /** When the agent was asked; while the story waits for a place among the agents — the last minute of that wait (PEP-297). */ at: number; attempts: number; /** A new head of the result first seen (Gitea re-checks mergeability in the background after a push). */ @@ -148,6 +150,12 @@ export async function conflictStep(db: Db, ref: TaskRef, pull: GiteaPull, o: { n if (!step) return (await ask(db, ref, pull, 1, now, log, o.force)) ? "requested" : "held"; if (step.escalated) return "escalated"; if (pull.head.sha === step.headSha) { + // PEP-297: the story waits for a place among the agents (the repository limit, the subscriptions) — + // its agent has not started, so it is not silent. The agent's time counts from the moment it gets the place. + if (await isWaitingForCapacity(db, ref.task.id)) { + if (now - step.at >= 60_000) await setSetting(db, stepKey(ref.task.id), { ...step, at: now } satisfies ConflictStep); + return "waiting"; + } // The agent has not pushed yet. if ((await working(db, ref.task.id)) || now - step.at < CONFLICT_WAIT_MIN * 60_000) return "waiting"; return escalate(db, ref, pull, step, m("агент не обновил изменения"), now, log); diff --git a/packages/testkit/test/conflict-step.test.ts b/packages/testkit/test/conflict-step.test.ts index 61d69efa..eca1028b 100644 --- a/packages/testkit/test/conflict-step.test.ts +++ b/packages/testkit/test/conflict-step.test.ts @@ -151,6 +151,29 @@ describe("Конфликт с основной веткой — отдельны assert.equal(await t.requests(), 1); }); + test("PEP-297: задача ждёт места среди агентов — это не молчание агента", async () => { + const t = await conflicted(); + const T = Date.now(); + await minute(T); + assert.equal(await t.requests(), 1); + // No room (the repository limit): the rebase waits in the queue for an agent. + await core.waitForCapacity(db, t.ref.task.id, "rebase", new Date(T)); + await minute(T + 91 * MIN); + await minute(T + 200 * MIN); + assert.equal(await core.getPlatformDelay(db, t.scope, "conflict"), null, "the agent has not even started"); + assert.equal((await toAdmin(t.tp.taskKey)).length, 0, "nobody is told «агент не обновил изменения»"); + assert.equal((await t.step())?.escalated, undefined); + // It gets the place and stays silent: 90 minutes from that moment, not from the request. + await core.clearCapacityWait(db, t.ref.task.id); + await minute(T + 201 * MIN); + await minute(T + 285 * MIN); + assert.equal(await core.getPlatformDelay(db, t.scope, "conflict"), null, "still the agent's time"); + await minute(T + 292 * MIN); + assert.equal((await core.getPlatformDelay(db, t.scope, "conflict"))?.exhausted, true); + assert.match((await toAdmin(t.tp.taskKey))[0]!, /агент не обновил изменения/); + assert.equal(await t.requests(), 1); + }); + test("Scenario: Агент разрешил конфликт — шаг снят", async () => { const t = await conflicted(); const T = Date.now();