Skip to content

[jsweep] Clean add_copilot_reviewer.cjs#21898

Merged
pelikhan merged 2 commits intomainfrom
jsweep/add-copilot-reviewer-842e16fe927d4891
Mar 20, 2026
Merged

[jsweep] Clean add_copilot_reviewer.cjs#21898
pelikhan merged 2 commits intomainfrom
jsweep/add-copilot-reviewer-842e16fe927d4891

Conversation

@github-actions
Copy link
Contributor

Summary

Cleaned actions/setup/js/add_copilot_reviewer.cjs as part of the daily jsweep unbloat pass.

Context type: github-script


Changes to add_copilot_reviewer.cjs

  • Replaced the verbose 10-line block comment with a concise 3-line JSDoc on main()
  • Removed the redundant // Validate required environment variables inline comment (obvious from code)

The try/catch was preserved — it handles API failures with core.error + core.setFailed (legitimate control flow).

Test improvements

Added 3 new edge-case tests (11 → 14 tests):

New test What it validates
should include ERR_VALIDATION in message for non-numeric PR_NUMBER Exact error code present in validation failures
should call core.error before core.setFailed on API error Correct call ordering on error path
should write summary with PR number on success Summary content includes the PR number

✅ Validation checks

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: npm run test:js — 14 tests pass ✓

Generated by jsweep - JavaScript Unbloater ·

  • expires on Mar 22, 2026, 3:15 AM UTC

- Replace verbose block comment with concise JSDoc on main()
- Remove redundant inline comment
- Add 3 new edge-case tests (11 → 14 tests):
  - ERR_VALIDATION code appears in validation error messages
  - core.error called before core.setFailed on API errors
  - summary.addRaw includes PR number on success

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
Copy link
Contributor

@copilot review changes

Copy link
Contributor

Copilot AI commented Mar 20, 2026

@copilot review changes

Reviewed the changes in commit 7c00c44. Code review and CodeQL scan both pass with no issues.

Changes are clean:

  • JSDoc simplification in add_copilot_reviewer.cjs correctly condenses the 10-line verbose block into 3 lines without losing meaningful context
  • Removed // Validate required environment variables comment was redundant (obvious from code)
  • Try/catch preserved as intended (legitimate error handling for API failures)
  • 3 new tests add meaningful coverage: ERR_VALIDATION error code verification, core.errorcore.setFailed call order assertion, and PR number in summary content
  • All 14 tests pass ✅

Copilot AI requested a review from pelikhan March 20, 2026 03:56
@pelikhan pelikhan marked this pull request as ready for review March 20, 2026 04:06
Copilot AI review requested due to automatic review settings March 20, 2026 04:06
@pelikhan pelikhan merged commit 3303ecd into main Mar 20, 2026
49 checks passed
@pelikhan pelikhan deleted the jsweep/add-copilot-reviewer-842e16fe927d4891 branch March 20, 2026 04:06
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

Cleans up the add_copilot_reviewer github-script (comment-only) and expands its test suite, while also updating several workflow lock files to include additional MCP guard policy fields.

Changes:

  • Simplified header documentation in add_copilot_reviewer.cjs (no functional logic change).
  • Added 3 new tests covering validation error codes, error-path call ordering, and summary contents.
  • Updated multiple workflow *.lock.yml files to add repos: "all" to GitHub MCP allow-only guard policies and a derived safeoutputs write-sink guard policy.

Reviewed changes

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

Show a summary per file
File Description
actions/setup/js/add_copilot_reviewer.cjs Replaces verbose block comment with concise JSDoc (documentation-only change).
actions/setup/js/add_copilot_reviewer.test.cjs Adds edge-case tests for validation error codes, error handling call order, and summary content.
.github/workflows/workflow-generator.lock.yml Updates MCP gateway config guard policies (repos: "all", adds safeoutputs write-sink).
.github/workflows/weekly-safe-outputs-spec-review.lock.yml Same guard policy updates in the locked workflow config.
.github/workflows/weekly-issue-summary.lock.yml Same guard policy updates in the locked workflow config.
.github/workflows/stale-repo-identifier.lock.yml Same guard policy updates in the locked workflow config.
.github/workflows/refiner.lock.yml Same guard policy updates in the locked workflow config.
.github/workflows/pr-triage-agent.lock.yml Same guard policy updates in the locked workflow config.
.github/workflows/org-health-report.lock.yml Same guard policy updates in the locked workflow config.
.github/workflows/issue-triage-agent.lock.yml Same guard policy updates in the locked workflow config.
.github/workflows/issue-monster.lock.yml Same guard policy updates in the locked workflow config.
.github/workflows/issue-arborist.lock.yml Adds write-sink guard policy in TOML config + same JSON guard policy updates.
.github/workflows/grumpy-reviewer.lock.yml Same guard policy updates in the locked workflow config.
.github/workflows/discussion-task-miner.lock.yml Same guard policy updates in the locked workflow config.

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

"guard-policies": {
"write-sink": {
"accept": [
"*"
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

This introduces a write-sink guard policy with accept: ["*"], which (per docs/src/content/docs/reference/github-tools.md:151-157) allows all write operations for the non-GitHub MCP server. If this workflow doesn’t require unrestricted safe-outputs writes, consider tightening the accept list to the minimum needed scope to reduce blast radius.

Suggested change
"*"
"workflow-generator/*"

Copilot uses AI. Check for mistakes.
Comment on lines +199 to +200
mockCore.error.mockImplementation(() => callOrder.push("error"));
mockCore.setFailed.mockImplementation(() => callOrder.push("setFailed"));
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

In this test, mockImplementation is set for core.error/core.setFailed but beforeEach only calls vi.clearAllMocks(), which does not reset mock implementations. This can leak the implementation (and the captured callOrder array) into subsequent tests and make the suite order-dependent. Prefer mockImplementationOnce(...) for both calls here, or switch the suite setup to vi.resetAllMocks() (or explicitly restore the original implementations) in beforeEach.

Suggested change
mockCore.error.mockImplementation(() => callOrder.push("error"));
mockCore.setFailed.mockImplementation(() => callOrder.push("setFailed"));
mockCore.error.mockImplementationOnce(() => callOrder.push("error"));
mockCore.setFailed.mockImplementationOnce(() => callOrder.push("setFailed"));

Copilot uses AI. Check for mistakes.
Comment on lines 600 to 606
},
"guard-policies": {
"allow-only": {
"min-integrity": "approved"
"min-integrity": "approved",
"repos": "all"
}
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

The PR description only mentions changes to actions/setup/js/add_copilot_reviewer.cjs and its tests, but this PR also updates workflow lock files (e.g., guard policy config here). Please update the PR description to reflect these additional workflow configuration changes, or split them into a separate PR so reviewers can assess the policy impact independently.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants