Skip to content

Serialise translation reviews to stop duplicate report comments#134

Merged
mmcky merged 1 commit into
mainfrom
fix/review-workflow-duplicate-reviews
Jul 16, 2026
Merged

Serialise translation reviews to stop duplicate report comments#134
mmcky merged 1 commit into
mainfrom
fix/review-workflow-duplicate-reviews

Conversation

@mmcky

@mmcky mmcky commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What

Ports QuantEcon/lecture-python-programming.fr#7 (merged) to the Farsi edition: adds a per-PR concurrency group to Review Translations, and stops labeled events for labels other than action-translation from triggering a review.

Why

The bug is already reproducing in this repo. #133 — the open numba.md sync from source PR #550 — carries two "Translation Quality Review" comments, scoring 9.2/10 and 8.8/10, both posted at 23:51:37. Both are genuine model output: the same diff reviewed twice.

The sync action creates the PR and then applies its labels in a separate call, so one sync fires opened plus a labeled event per label within a couple of seconds. Each starts its own run. The action's "update the existing comment, else create one" logic is a check-then-act with no lock, so concurrent runs all observe "no comment yet" and each create one. The run logs for #133 show exactly that:

Run Outcome logged
29459761998 Posted review comment on PR #133
29459762099 Posted review comment on PR #133
29459762464 Updated existing review comment on PR #133

Two runs won the create race; the third found a comment and updated it. Because each comment was then overwritten by a different run, neither necessarily reflects the run that created it.

Besides the duplicate report, this is a 3x model-spend multiplier on that PR, and it scales with the number of labels applied.

Why cancel-in-progress: false

Worth reviewing carefully, because true is the reflex and would be wrong here. Both labels are applied in a single addLabels call, so the order of the resulting labeled events is not guaranteed. With true, an automated event arriving last would cancel the in-flight review started by action-translation, then skip its own job via the new label filter — leaving no review at all. Cancellation happens when the run is queued, before the job-level if is evaluated, so the filter cannot protect against it.

Queuing is safe in every ordering: the first run to reach the comment step creates the comment, any later run updates it.

Scope

This fixes the symptom at the workflow layer. The unsynchronised upsert is a latent bug in the action itself, tracked as QuantEcon/action-translation#96 — any two concurrent review runs will duplicate again until that lands. lecture-python-programming.zh-cn triggers only on [opened, synchronize] and is much less exposed, so I have left it alone.

Note this does not retroactively clean up #133, which still has both comments on it.

Verification

YAML parses, and the action inputs are unchanged (source-language: en, target-language: fa, same action pin, same secrets) — the diff is the concurrency block plus the if filter and comments, nothing else. The behaviour itself can only be confirmed on the next Farsi sync PR; worth watching that it produces exactly one review comment.

🤖 Generated with Claude Code

Ports the fix from QuantEcon/lecture-python-programming.fr#7. This repo
has the identical trigger list and no concurrency guard, and the bug is
already reproducing here: PR #133 carries two "Translation Quality
Review" comments, scoring 9.2/10 and 8.8/10, both posted at 23:51:37.

A single translation sync fires `opened` plus one `labeled` event per
label applied, all within a couple of seconds. Each starts its own run of
this workflow, and the review action's "update existing comment, else
create" logic is a check-then-act with no lock: concurrent runs all see
"no comment yet" and each create one. On PR #133 three runs fired; two
logged `Posted review comment` and one logged `Updated existing review
comment`, leaving two independent reports of the same diff and three full
model calls where one was intended.

Add a per-PR concurrency group so runs queue instead of racing — the
first creates the comment, any later run updates it. cancel-in-progress
is left false on purpose: the labels are applied in one API call so event
order is not guaranteed, and cancelling would let a `labeled` event for
'automated' kill the in-flight review and then skip its own job, leaving
no review at all.

Also ignore `labeled` events for labels other than 'action-translation',
which removes the redundant review triggered by the 'automated' label.

The underlying unsynchronised upsert is tracked in
QuantEcon/action-translation#96.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 16, 2026 03:48
@netlify

netlify Bot commented Jul 16, 2026

Copy link
Copy Markdown

Deploy Preview for majestic-griffin-10b166 ready!

Name Link
🔨 Latest commit fdf83d7
🔍 Latest deploy log https://app.netlify.com/projects/majestic-griffin-10b166/deploys/6a58549f8ae00200089a8e3c
😎 Deploy Preview https://deploy-preview-134--majestic-griffin-10b166.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Review Translations GitHub Actions workflow to prevent duplicate “Translation Quality Review” comments (and redundant model runs) by serializing workflow runs per PR and filtering out irrelevant labeled triggers.

Changes:

  • Add a per-PR concurrency group to ensure only one review run executes at a time for a given PR.
  • Refine the job-level if so only the action-translation label’s labeled event can trigger the review job (ignoring other labels like automated).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request July 16, 2026 03:54 Inactive
@mmcky mmcky merged commit 37e78f2 into main Jul 16, 2026
8 checks passed
@mmcky mmcky deleted the fix/review-workflow-duplicate-reviews branch July 16, 2026 03:54
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.

2 participants