Skip to content

Consume BCQuality knowledge base for Copilot PR review#8700

Draft
WaelAbuSeada wants to merge 5 commits into
mainfrom
private/waabusea/bcquality-codereview
Draft

Consume BCQuality knowledge base for Copilot PR review#8700
WaelAbuSeada wants to merge 5 commits into
mainfrom
private/waabusea/bcquality-codereview

Conversation

@WaelAbuSeada

@WaelAbuSeada WaelAbuSeada commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

Migrates the Copilot PR reviewer from a self-maintained instructions/skill model to consuming the proven, centrally-maintained BCQuality knowledge base through a small, config-driven clone + filter integration layer.

The reviewer now pulls its review knowledge (performance, privacy, security, style, upgrade) from microsoft/BCQuality at runtime, instead of carrying a duplicated copy of that guidance in this repo.

What changed

Added — BCQuality integration layer (tools/BCQuality/)

  • bcquality.config.yaml — single source of truth for which BCQuality content this repo consumes (repo/ref, enabled layers, disabled skills, knowledge allow/deny, task-context). Every value is overridable at runtime via Actions variables.
  • scripts/Get-BCQualityConfig.ps1 — loads the YAML and applies BCQUALITY_* env overrides.
  • scripts/Invoke-BCQualityFilter.ps1 — prunes the BCQuality clone to policy and emits a _filter-report.json artifact for auditability.
  • README.md — documents the layer.

Updated — orchestrator (tools/Code Review/scripts/Invoke-CopilotPRReview.ps1)

  • Consumes the filtered BCQuality clone (BCQUALITY_ROOT / BCQUALITY_SHA) and reads BCQuality's entry.md rather than the in-repo instruction files.
  • Emits structured findings, maps BCQuality severities/domains, and supports both knowledge-backed and agent findings.

Updated — runner workflow (.github/workflows/CopilotPRReviewRunner.yaml)

  • Clones + filters BCQuality on the privileged runner, then runs the review.
  • Uses the built-in GITHUB_TOKEN + copilot-requests: write to bill Copilot inference to the org (no PAT secret required).
  • Clones via init + fetch + checkout so the pinned ref may be a branch, tag, or commit SHA.

Config

  • BCQuality ref is pinned to a specific main commit (822cae1b2771ac25f665f73369f69093bd4fd630) for reproducible reviews; bump deliberately as BCQuality advances.

Removed — now sourced from BCQuality

  • tools/Code Review/instructions/*.md (accessibility, performance, privacy, security, style, upgrade)
  • tools/Code Review/skills/al-code-review/SKILL.md

Fixes AB#637778

Replace the local al-code-review skill and instructions with the BCQuality consumption model: the workflow now checks out microsoft/BCQuality at main, and the review script copies that clone into the runner workspace and instructs Copilot CLI to start from BCQuality skills/entry.md. The script's flat JSON output contract is preserved so the comment-posting pipeline is unchanged.
Replace the naive direct-checkout bridge with the config-driven clone+filter pattern from the tested reference implementation:

- Add tools/BCQuality integration layer (config YAML, Get-BCQualityConfig, Invoke-BCQualityFilter, README)

- Replace orchestrator with the version that consumes BCQuality native structured DO output (agent findings, references, confidence, interrupted-JSON repair, filter report in PR summary)

- Runner workflow now clones the configured BCQuality repo/ref, filters it to policy, and passes BCQUALITY_ROOT/SHA + BCQUALITY_* + AGENT_MINIMUM_SEVERITY; uploads the filter report
@github-actions github-actions Bot added the Build: Automation Workflows and other setup in .github folder label Jun 20, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jun 20, 2026
@JesperSchulz JesperSchulz requested a review from Copilot June 20, 2026 21:17

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 migrates the Copilot PR review orchestration to consume centrally maintained review skills/knowledge from microsoft/BCQuality at runtime, replacing the duplicated in-repo instruction/skill content with a config-driven clone + filter layer.

Changes:

  • Added tools/BCQuality/ integration layer (config + config loader + deterministic filter with audit report artifact).
  • Updated the PR review runner workflow to fetch/filter BCQuality and run the orchestrator with BCQuality as the working directory (pinned ref for reproducibility).
  • Removed the legacy in-repo AL review skill and domain instruction markdown files now sourced from BCQuality.

Reviewed changes

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

Show a summary per file
File Description
.github/workflows/CopilotPRReviewRunner.yaml Adds BCQuality fetch/filter, copilot-requests: write, and switches Copilot CLI auth to built-in token.
tools/BCQuality/bcquality.config.yaml Pins BCQuality ref and defines enabled layers + knowledge allow/deny + task-context defaults.
tools/BCQuality/scripts/Get-BCQualityConfig.ps1 Loads YAML config and applies env overrides for Actions variables.
tools/BCQuality/scripts/Invoke-BCQualityFilter.ps1 Prunes cloned BCQuality content and emits _filter-report.json.
tools/BCQuality/README.md Documents the shared BCQuality integration layer and override schema.
tools/Code Review/scripts/Invoke-CopilotPRReview.ps1 Orchestrator now boots via BCQuality skills/entry.md and parses BCQuality DO-contract output.
tools/Code Review/README.md Documents the updated two-workflow pattern, severity mapping, and BCQuality-backed findings model.
tools/Code Review/skills/al-code-review/SKILL.md Removed (now sourced from BCQuality).
tools/Code Review/instructions/accessibility.md Removed (now sourced from BCQuality).
tools/Code Review/instructions/performance.md Removed (now sourced from BCQuality).
tools/Code Review/instructions/privacy.md Removed (now sourced from BCQuality).
tools/Code Review/instructions/security.md Removed (now sourced from BCQuality).
tools/Code Review/instructions/style.md Removed (now sourced from BCQuality).
tools/Code Review/instructions/upgrade.md Removed (now sourced from BCQuality).

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

Comment on lines +92 to +94
elseif ('.\+(){}[]^$|' -contains $c) {
$null = $regex.Append('\').Append($c)
}
Comment on lines +21 to +26
The review uses the `pull_request` → `workflow_run` privilege-escalation
pattern (as in the original BCApps port). The unprivileged intake job
fires on `pull_request` events from untrusted forks; the runner job fires
on `workflow_run` events, runs against the **trusted base branch**, and
only then exposes `COPILOT_GH_TOKEN`. This eliminates the
`pull_request_target` attack surface entirely.
Comment on lines +130 to +135
## Required secrets

| Secret | Purpose |
|---|---|
| `COPILOT_GH_TOKEN` | Copilot-enabled PAT scoped to the `copilot-pr-review` environment. Used **only** by the Copilot CLI subprocess for authentication. |

Comment on lines 149 to 152
env:
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ secrets.COPILOT_GH_TOKEN }}
GH_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
Comment on lines +96 to +98
if (-not $cfg.ContainsKey('bcquality') -or -not ($cfg['bcquality'] -is [hashtable])) { $cfg['bcquality'] = @{} }
if (-not $cfg['bcquality'].ContainsKey('repo')) { $cfg['bcquality']['repo'] = 'https://github.com/microsoft/BCQuality' }
if (-not $cfg['bcquality'].ContainsKey('ref')) { $cfg['bcquality']['ref'] = 'main' }

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.

These are very hard to read as they're all inline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build: Automation Workflows and other setup in .github folder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants