Skip to content

Enhancement: Harden Review Sync infrastructure before Phase 2 (Caching, CI Rollback, Testing) #2260

Description

@darshit2308

Problem

As we prepare to implement more complex routing logic (Phase 2), the current review-sync script has a few structural vulnerabilities that need to be addressed to ensure scalability and reliability:

  1. API Rate Limiting: The script currently calls getPermissionLevel for every approver sequentially. If a maintainer approves multiple PRs, the redundant API calls burn through the GitHub API budget guarded by RATE_LIMIT_FLOOR.

  2. Silent Failures: If the sync encounters an error, it logs to the action runner but exits with a success code, hiding broken syncs from immediate view.

  3. Wasted Reviewer Time (No CI Rollback): Currently, if a PR fails its required CI checks (formatting, linting), it remains in the active review queues (queue:committers, etc.). This can mislead reviewers into spending time on broken code.

  4. Lack of Test Coverage: There is no automated workflow to ensure the routing math stays green when future contributors modify the script.

  5. Logical Routing Bug: The current approval logic separates maintainers and committers too strictly. This creates a logical flaw where a PR approved by two maintainers could be blocked because it lacks a standard committer approval.

  6. Missing Community Visibility: A persistent "Open to community review" label on all PRs across all phases to encourage community participation.

Solution

I propose a "Pre-Phase 2" infrastructure update to harden the script. This PR will include 5 atomic fixes:

  1. Add API Caching: Implement a module-level Map<username, role> cache in permissions.js to store role data during the cron run, drastically reducing API spend.

  2. Add Action Error Handling: Update index.js to use core.setFailed() if the error count is greater than zero, ensuring silent passes do not hide broken syncs.

  3. Implement CI Failure Rollback: Add a helper to check the GitHub Checks API (github.rest.checks.listForRef). If a PR has a failing CI conclusion, the script will override all approvals and actively demote the PR back to queue:junior-committer.

  4. Add CI Testing Workflow: Create .github/workflows/test-review-sync.yml to trigger npm test specifically on changes touching the .github/scripts/review-sync/ directory.

  5. Semantic Approval Logic: Refactor the approval counters in permissions.js to use "coreApprovals" (combining all users with write access or above) and update the determineLabel gate to ensure maintainers inherently count toward the core requirement.

  6. Global Community Label: Define the "open to community review" label in constants and update syncLabel to ensure it is permanently attached to every open PR alongside the standard queue labels.

If anyone want suggest some more enhancements, they are more then welcome

Alternatives

No response

Metadata

Metadata

Assignees

Labels

skill: beginnerAchievable by a fairly new comer that has already completed a couple of good first issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions