Skip to content

Dispatch deferred commands directly instead of reposting the comment body - #189

Merged
nebril merged 6 commits into
cilium:mainfrom
HadrienPatte:pr/HadrienPatte/dispatch
Oct 27, 2026
Merged

nebril merged 6 commits into
cilium:mainfrom
HadrienPatte:pr/HadrienPatte/dispatch

Conversation

@HadrienPatte

Copy link
Copy Markdown
Member

Fixes #181
Followup to #182

When a command's depends_on triggers were not yet satisfied, Ariane deferred it and later re-posted the full original comment body on the PR so that its own issue_comment handler would pick it up again. That is what makes Ariane look like it is parroting contributors back at them, and it is also an unbounded replay: the only thing gating the repost was a 3 hour comment window, with no record of whether the command was still awaited.

This PR removes the repost entirely:

  • Dispatch directly: processDependantWorkflows now resolves the pending command from the PR comments and calls processWorkflowsForTrigger itself, so nothing is written back to the PR. Comment listing is also skipped unless the completed run is a dependency of at least one trigger.
  • Track pending commands with a reaction marker: The thumbs up the issue_comment handler already adds when it defers a command becomes the record that the command is pending. The workflow_run handler requires that marker before dispatching, then swaps it for a rocket. A failed dispatch leaves the marker in place so the command is retried on the next dependency completion. This also fixes commands from unauthorized users which previously declined but stayed on the PR, being dispatched once a dependency turned green.
  • Invalidate on push: A synchronize event clears pending markers, since dependencies are checked against the PR's current head and a deferred command was never requested for the new commits. The command has to be requested again.

@HadrienPatte
HadrienPatte marked this pull request as ready for review September 16, 2026 13:56
@HadrienPatte
HadrienPatte requested a review from a team as a code owner September 16, 2026 13:56
@HadrienPatte
HadrienPatte requested review from sekhar-isovalent and removed request for a team September 16, 2026 13:56
@sekhar-isovalent
sekhar-isovalent requested review from nebril and removed request for sekhar-isovalent September 16, 2026 13:58
@nebril

nebril commented Oct 13, 2026

Copy link
Copy Markdown
Member

Sorry for long wait on that, I will reserve time next week to review and merge this one.

@HadrienPatte
HadrienPatte force-pushed the pr/HadrienPatte/dispatch branch from 049a7d2 to 296faa5 Compare October 13, 2026 09:45

@nebril nebril left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work, LGTM overall!

We recently merged feedback.reactions option , which will mess with this code, I will think about how to integrate it best.

I think feedback.reactions shouldn't touch the "+1" comment reactions. Will add this to this PR.

Comment thread internal/handlers/workflow_processor.go Outdated
Comment thread internal/handlers/workflow_processor.go Outdated
When a trigger's dependencies completed, processDependantWorkflows
re-posted the user's original command as a new PR comment. That comment
existed only to re-enter the issue_comment handler, which parsed it and
dispatched the workflows. Every input that path needs is already in scope
at the point the comment was posted: the command body gives the trigger
and its extra arguments, and the pull request gives the refs.

Call processWorkflowsForTrigger directly instead. This removes the
duplicate command comment users see on every deferred trigger, halves the
round trip, and stops the dispatch from being re-authorized as the bot
that posted the comment.

Dependencies end up checked twice, once by the caller to decide whether
to dispatch at all and once by processWorkflowsForTrigger immediately
before dispatching. The second check is the authoritative one and also
covers the window between the two.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
GithubCommenter could only create reactions. Managing a reaction as
durable state needs to find an existing one and to remove it once it has
been acted on.

Add findReaction, which filters an issue comment's reactions by emoji
server-side and returns the ID of the one left by a given login, and
removeReaction, which deletes it. findReaction distinguishes an absent
reaction (0, nil) from a failed lookup so callers do not treat an API
error as "no marker present".

Identifying our own reaction cannot reuse the "organization name prefix
plus [bot] suffix" convention the handlers apply to comment and PR
authors: that convention deliberately admits any bot of the organization,
Renovate included, whereas a pending-trigger marker is only meaningful if
Ariane left it. The login is a property of the app and never changes while
the process runs, so it is resolved once at startup and handed to the
handlers that need it, in the same way the run delay is.

Both helpers are unused until dependent triggers start being gated on a
pending reaction marker.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
@HadrienPatte
HadrienPatte force-pushed the pr/HadrienPatte/dispatch branch from 296faa5 to 9deb008 Compare October 22, 2026 20:15
processDependantWorkflows dispatched any command it found in the last
three hours of PR comments matching a trigger. The time window was the
only thing bounding replay, and it knew nothing about whether the command
was actually still awaited. In particular a command an unauthorized user
posted, which the issue_comment handler declined and left on the PR, was
dispatched all the same once a dependency turned green.

Use the thumbs up the issue_comment handler already adds when it defers a
command as the record that the command is pending. The workflow_run
handler now requires that marker before dispatching, removes it once the
dispatch succeeds, and reacts with a rocket in its place. A failed
dispatch leaves the marker so the command is retried on the next
dependency completion instead of being dropped.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
A command deferred while its dependencies were running carries a marker
until those dependencies complete. The dispatcher checks dependencies
against the pull request's current head, so once new commits are pushed
the command would be dispatched against code it was never requested for.

Remove the marker from pending commands when a synchronize event arrives.
The command has to be requested again to apply to the new head.

Only comments that are a command on their own are considered, matching
what the dispatcher will act on, so no reaction lookup is spent on
comments that merely mention one. Nor is one spent on a command the
listing already reports as carrying no thumbs up; an absent reaction
summary proves nothing, so there the lookup still decides. Clearing runs
before the allowed team check, because a push invalidates pending commands
regardless of who pushed it, and a failure to clear does not prevent the
default testsuite from running.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
@HadrienPatte
HadrienPatte force-pushed the pr/HadrienPatte/dispatch branch from 9deb008 to 60d9461 Compare October 22, 2026 20:40
@HadrienPatte
HadrienPatte requested a review from nebril October 22, 2026 20:41
Signed-off-by: Maciej Kwiek <mkwiek@cisco.com>
Signed-off-by: Maciej Kwiek <mkwiek@cisco.com>

@nebril nebril left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks! I tested it locally and it seems to be working fine.

@nebril
nebril merged commit 2527a2b into cilium:main Oct 27, 2026
2 checks passed
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.

Avoid reposting full comments from contributors back to the PR

2 participants