Skip to content

feat(git-trigger): drop a queued MR/PR run superseded by a newer one - #131

Open
tatelilith wants to merge 1 commit into
mainfrom
feat/git-trigger-supersede-queued
Open

tatelilith wants to merge 1 commit into
mainfrom
feat/git-trigger-supersede-queued

Conversation

@tatelilith

Copy link
Copy Markdown
Contributor

Problem

A busy merge request fires opened plus one updated per push. Behind a concurrency of 1 they queue together, and each would review the request's head at execution time, so every run but the newest is a duplicate. On a production deployment (MR review Agent, ~45 days): 2.44 runs per merge request, with two runs queued for the same request at once.

Change

The existing staleness preflight in executeChatRun (queued git-trigger runs only) now runs one more check before the merged/closed forge probe:

  • A queued opened / updated run is cancelled if a newer opened / updated run of the same Agent for the same request (provider, host, project, number) is pending / queued / running / completed. The cancel reason names the newer run.
  • One DB query on the (initiator_agent_id, created_at) index, capped at 200 newer rows. No forge call.
  • A newer failed / cancelled run does not count, since it reviewed nothing.
  • commented runs neither supersede nor get superseded: each comment is its own question.
  • Fails open: a lookup error falls through to the existing forge probe.

Docs: docs/agent/git-trigger-channels.md has a new "Superseded by a newer Run" subsection.

Tests

  • git-trigger-run-preflight.test.ts: 10 new cases (supersede, completed newer run, failed/cancelled ignored, other request/host/provider ignored, commented on either side, self row, DB error fails open, no identity means no lookup).
  • execute-chat-run.test.ts: the preflight receives the run identity.
  • pnpm typecheck passes. pnpm lint has 0 errors. API suite: 7557 passed.
  • The web suite had 5 timeouts under parallel load in unrelated publish-* tests; they pass when run on their own.
  • scripts/e2e/restart-recovery.sh not run locally.

A busy merge request fires `opened` plus one `updated` per push, and behind a
concurrency of 1 they queue together. Each would review the request's head at
execution time, so all but the newest are duplicates: a production deployment
measured 2.4 runs per merge request, with two queued for the same request at
once.

The staleness preflight now also cancels a queued `opened` / `updated` run
when a newer `opened` / `updated` run of the same Agent for the same request
is pending, queued, running or completed. One DB query, no forge call, and it
fails open into the existing merged/closed probe. `commented` runs are left
out on both sides: each comment is its own question.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant