Skip to content

Sort GH_AW_RATE_LIMIT_EVENTS alphabetically#15018

Merged
pelikhan merged 5 commits intomainfrom
copilot/sort-gh-aw-rate-limit-events
Feb 11, 2026
Merged

Sort GH_AW_RATE_LIMIT_EVENTS alphabetically#15018
pelikhan merged 5 commits intomainfrom
copilot/sort-gh-aw-rate-limit-events

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

The GH_AW_RATE_LIMIT_EVENTS environment variable in generated workflow lock files had non-deterministic ordering due to Go map iteration. This makes diffs noisy and configuration harder to review.

Changes

  • Sorted programmaticTriggers map in pkg/workflow/role_checks.go alphabetically for code readability
  • Added runtime sorting in inferEventsFromTriggers() to ensure inferred events are consistently ordered
  • Added pre-write sorting in generateMembershipCheck() before serializing to lock files
  • Updated tests to assert sorted order instead of using ElementsMatch

Example

Before:

GH_AW_RATE_LIMIT_EVENTS: "issue_comment,workflow_dispatch,issues"

After:

GH_AW_RATE_LIMIT_EVENTS: "issue_comment,issues,workflow_dispatch"

All workflow lock files now emit rate limit events in alphabetical order regardless of source (explicit config or inferred from triggers).


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot stopped work on behalf of pelikhan due to an error February 11, 2026 22:29
Copilot stopped work on behalf of pelikhan due to an error February 11, 2026 22:29
Copilot AI and others added 2 commits February 11, 2026 22:32
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review February 11, 2026 22:38
Copilot AI review requested due to automatic review settings February 11, 2026 22:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request aims to alphabetically sort the list of events in GH_AW_RATE_LIMIT_EVENTS by ordering the programmaticTriggers map in pkg/workflow/role_checks.go and updating test expectations to reflect this alphabetical ordering. The changes are intended to make the event list more maintainable and predictable.

Changes:

  • Alphabetically sorted the programmaticTriggers map keys in pkg/workflow/role_checks.go
  • Updated test expectations in pkg/workflow/role_checks_test.go to reflect alphabetical order for the "all programmatic triggers" test case
  • Modified GH_AW_RATE_LIMIT_EVENTS in .github/workflows/ai-moderator.lock.yml (though not correctly sorted)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/workflow/role_checks.go Alphabetically sorted the programmaticTriggers map keys
pkg/workflow/role_checks_test.go Updated expected array to reflect alphabetical order of all programmatic triggers
.github/workflows/ai-moderator.lock.yml Attempted to sort GH_AW_RATE_LIMIT_EVENTS (but incorrectly)

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

GH_AW_RATE_LIMIT_MAX: "5"
GH_AW_RATE_LIMIT_WINDOW: "60"
GH_AW_RATE_LIMIT_EVENTS: "workflow_dispatch,issues,issue_comment"
GH_AW_RATE_LIMIT_EVENTS: "issue_comment,workflow_dispatch,issues"
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The events in GH_AW_RATE_LIMIT_EVENTS are not in alphabetical order. The current order is "issue_comment,workflow_dispatch,issues" but it should be "issue_comment,issues,workflow_dispatch" to match the alphabetical sorting pattern applied to the programmaticTriggers map and test expectations.

Suggested change
GH_AW_RATE_LIMIT_EVENTS: "issue_comment,workflow_dispatch,issues"
GH_AW_RATE_LIMIT_EVENTS: "issue_comment,issues,workflow_dispatch"

Copilot uses AI. Check for mistakes.
Comment on lines 213 to 223
programmaticTriggers := map[string]string{
"workflow_dispatch": "workflow_dispatch",
"repository_dispatch": "repository_dispatch",
"issues": "issues",
"discussion": "discussion",
"discussion_comment": "discussion_comment",
"issue_comment": "issue_comment",
"issues": "issues",
"pull_request": "pull_request",
"pull_request_review": "pull_request_review",
"pull_request_review_comment": "pull_request_review_comment",
"discussion": "discussion",
"discussion_comment": "discussion_comment",
"repository_dispatch": "repository_dispatch",
"workflow_dispatch": "workflow_dispatch",
}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

Alphabetizing the programmaticTriggers map in the source code does not make the events slice deterministically ordered. Go map iteration order is non-deterministic - when iterating over the input 'on' map (lines 227-230 in the full function), events will be appended in random order. The test now expects alphabetical order, but the implementation doesn't sort. You need to add sort.Strings(events) before returning the events slice (after line 244 in the full function) and import the "sort" package.

Copilot uses AI. Check for mistakes.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Sort the list of events in GH_AW_RATE_LIMIT_EVENTS Sort GH_AW_RATE_LIMIT_EVENTS alphabetically Feb 11, 2026
Copilot AI requested a review from pelikhan February 11, 2026 22:43
@pelikhan pelikhan merged commit 0b4c240 into main Feb 11, 2026
48 checks passed
@pelikhan pelikhan deleted the copilot/sort-gh-aw-rate-limit-events branch February 11, 2026 22:46
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.

3 participants