|
1 | 1 | # GitHub Copilot Instructions for LanguageTags |
2 | 2 |
|
| 3 | +The **canonical guide is [AGENTS.md](../AGENTS.md)** at the repo root — read it first. It covers branching, PR review etiquette, workflow YAML conventions, and the release pipeline. |
| 4 | + |
| 5 | +This file is intentionally focused: the GitHub Copilot Review Runbook (provider-specific mechanics behind the review-loop contract defined in AGENTS.md), followed by the LanguageTags-specific code conventions and public-API contract notes that VS Code's AI generators pick up directly from this path. |
| 6 | + |
| 7 | +For C# style rules, see [`CODESTYLE.md`](../CODESTYLE.md) at the repo root. Do not duplicate those rules here. |
| 8 | + |
| 9 | +## GitHub Copilot Review Runbook |
| 10 | + |
| 11 | +Use this section for provider-specific mechanics. The expected review loop *contract* (request review on every push, verify head-SHA coverage, triage findings, reply + resolve, escalate when stuck) is defined in [AGENTS.md → PR Review Etiquette](../AGENTS.md#pr-review-etiquette). This section only describes how to make GitHub Copilot reliably execute it. |
| 12 | + |
| 13 | +### Triggering and Polling |
| 14 | + |
| 15 | +Auto-review on push is configured (via the branch ruleset's `copilot_code_review` rule with `review_on_push: true`) but fires inconsistently in practice — treat it as best-effort, not guaranteed. Request review explicitly through the GitHub PR UI (request `Copilot` as a reviewer) after every push. |
| 16 | + |
| 17 | +**Do NOT post `@Copilot review` as a PR comment.** That comment triggers the Copilot *coding agent* (`copilot-swe-agent[bot]`), which makes code changes rather than posting a review. |
| 18 | + |
| 19 | +Known non-working request paths (don't rely on them): |
| 20 | + |
| 21 | +- `POST /requested_reviewers` with `reviewers=[Copilot]` can return 200 but no-op. |
| 22 | +- `copilot-pull-request-reviewer` as a requested reviewer slug returns 422. |
| 23 | +- GraphQL `requestReviews` rejects Copilot's bot node. |
| 24 | + |
| 25 | +### Verify Review Covered Current Head |
| 26 | + |
| 27 | +Before merging, confirm Copilot reviewed the current PR head SHA. Copilot may respond as either a formal review (carries an exact commit SHA) or an issue comment (no SHA — use the most recent Copilot comment for manual confirmation). Check both. |
| 28 | + |
| 29 | +```sh |
| 30 | +PR_HEAD=$(gh pr view <N> --json headRefOid --jq '.headRefOid') |
| 31 | + |
| 32 | +# 1. Formal review — exact SHA match. |
| 33 | +gh pr view <N> --json reviews --jq \ |
| 34 | + '.reviews[] | select(.author.login=="copilot-pull-request-reviewer") | .commit.oid' \ |
| 35 | + | grep -q "$PR_HEAD" && echo "covered via formal review" |
| 36 | + |
| 37 | +# 2. Issue comment — show the most recent Copilot comment for manual confirmation. |
| 38 | +gh api repos/ptr727/LanguageTags/issues/<N>/comments --jq \ |
| 39 | + '[.[] | select(.user.login=="copilot-pull-request-reviewer")] | last | {created_at, body: .body[:200]}' |
| 40 | +``` |
| 41 | + |
| 42 | +Coverage is confirmed when (1) exits 0. For issue comments (path 2), body content is the only reliable signal — `created_at` is not: `git log -1 --format=%cI` is the **commit** timestamp, not the push timestamp, so amended or rebased commits can have an earlier timestamp and an older Copilot comment could satisfy a time check even though Copilot never saw the current head. Treat path (2) as confirmed only when the comment body explicitly refers to the current changes. |
| 43 | + |
| 44 | +### Bounded Retry Workflow |
| 45 | + |
| 46 | +If a review did not run on the current head, retry: |
| 47 | + |
| 48 | +1. Wait briefly and check head-SHA coverage (see above). |
| 49 | +1. Request review again via the GitHub PR UI. |
| 50 | +1. Retry up to two more times (three total). |
| 51 | +1. If still missing, mark review as blocked and escalate to the user/maintainer with what was attempted. |
| 52 | + |
| 53 | +### Reply and Thread Resolution Workflow |
| 54 | + |
| 55 | +List unresolved threads. Use `first: 100` with cursor-based pagination; if `hasNextPage` is true, re-run with `after: "<endCursor>"` to retrieve the next page: |
| 56 | + |
| 57 | +```sh |
| 58 | +gh api graphql -f query=' |
| 59 | +{ |
| 60 | + repository(owner: "ptr727", name: "LanguageTags") { |
| 61 | + pullRequest(number: <N>) { |
| 62 | + reviewThreads(first: 100) { |
| 63 | + nodes { |
| 64 | + id isResolved path |
| 65 | + comments(first: 1) { nodes { author { login } body } } |
| 66 | + } |
| 67 | + pageInfo { hasNextPage endCursor } |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | +}' | jq ' |
| 72 | + .data.repository.pullRequest.reviewThreads | |
| 73 | + (.pageInfo | "hasNextPage=\(.hasNextPage) endCursor=\(.endCursor)"), |
| 74 | + (.nodes[] | select(.isResolved == false)) |
| 75 | +' |
| 76 | +``` |
| 77 | + |
| 78 | +Reply on a thread, then resolve it: |
| 79 | + |
| 80 | +```sh |
| 81 | +gh api graphql -f query=' |
| 82 | +mutation($threadId: ID!, $body: String!) { |
| 83 | + addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: $threadId, body: $body }) { |
| 84 | + comment { id } |
| 85 | + } |
| 86 | +}' -F threadId="PRRT_..." -F body="Fixed in <SHA>: <one-line summary>." |
| 87 | + |
| 88 | +gh api graphql -f query=' |
| 89 | +mutation($threadId: ID!) { |
| 90 | + resolveReviewThread(input: { threadId: $threadId }) { thread { id isResolved } } |
| 91 | +}' -F threadId="PRRT_..." |
| 92 | +``` |
| 93 | + |
| 94 | +Issue-level Copilot comments (those in `issues/<N>/comments`) have no resolution action — GitHub provides no API or UI to resolve them. Reply if the finding warrants it; no resolution step is needed or possible. |
| 95 | + |
| 96 | +Reply-body conventions: |
| 97 | + |
| 98 | +- Accepted bug/style fix: include fixing commit SHA and a one-line summary. |
| 99 | +- Declined style comment: cite the rule (AGENTS.md or CODESTYLE.md) and the existing-tree precedent. |
| 100 | +- Declined architecture proposal: one-sentence rationale. |
| 101 | + |
| 102 | +After the final push, sweep-resolve stale older threads for removed code paths. |
| 103 | + |
| 104 | +--- |
| 105 | + |
3 | 106 | ## Project Overview |
4 | 107 |
|
5 | 108 | **LanguageTags** is a C# .NET library for handling ISO 639-2, ISO 639-3, and RFC 5646 / BCP 47 language tags. The project serves two primary purposes: |
|
0 commit comments