PEP-297: время в очереди на агента — не молчание агента в шаге конфликта
All checks were successful
peppa/lint lint: success за 3с
peppa/typecheck typecheck: success за 53с
peppa/build build: success за 36с
peppa/test test: success за 1546с
peppa-ci / ci (pull_request) Successful in 29m2s

После выкатки PEP-269 задача с конфликтом, которая стояла в очереди на агента
(предел задач на код), через 90 минут эскалировалась суперадмину как «агент не
обновил изменения», хотя агент ещё не стартовал: 15 ложных сообщений за полтора
часа. Пока задача ждёт места (isWaitingForCapacity), шаг — «ждём», а время
агента отсчитывается с момента, когда он получил место.

Тест в conflict-step.test.ts падал до исправления.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
peppa-bot 2026-11-25 20:53:41 +05:00
parent 468eefba3d
commit ec1d042b0a
2 changed files with 31 additions and 0 deletions

View File

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

View File

@ -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();