Skip to content

Refactor Copilot Review Instructions and Skills - #799

Merged
ptr727 merged 6 commits into
developfrom
feature/issue-793-copilot-review
Aug 18, 2026
Merged

ptr727 merged 6 commits into
developfrom
feature/issue-793-copilot-review

Conversation

@ptr727

@ptr727 ptr727 commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a provider-independent code-review skill that routes changed files to the applicable language, documentation, and workflow skills
  • reduce the Copilot instruction file to a review bootstrap while preserving its repository-specific disproved-claims ledger
  • require visible findings and a machine-readable coverage marker
  • make pr_review.py parse the marker and block unstated coverage with exit 45

Root Cause

The Copilot instruction file duplicated provider-independent rules and embedded API mechanics already implemented by scripts/pr_review.py. Copilot review output also had no stable machine-readable coverage contract, while an unstated coverage result did not produce a blocking exit code.

Validation

  • uvx ruff@latest check .
  • uvx ruff@latest format --check .
  • uvx mypy@latest
  • full coverage and self-test sequence from OPERATIONS.md (79% total coverage, 97% for scripts/pr_review.py)
  • python3 scripts/build_dist.py --check
  • python3 scripts/repo_gate.py
  • complete prose, JSON, spec, EditorConfig, shellcheck, PSScriptAnalyzer, and Markdown gates
  • 688 script tests and 45 agent-safety install tests

Follow-Up

Closes #793

Copilot AI lite review requested due to automatic review settings August 17, 2026 23:20

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

Refactors the GitHub Copilot review bootstrap to route through a provider-independent code-review skill, and updates scripts/pr_review.py + tests to accept a stable machine-readable coverage marker and to block “unstated coverage” with a dedicated exit code.

Changes:

  • Introduce a new code-review skill (in both .agents/skills and the Claude plugin distribution) that standardizes review procedure and the structured coverage marker.
  • Slim .github/copilot-instructions.md down to a bootstrap + output contract while preserving the repository’s disproved-claims ledger.
  • Extend scripts/pr_review.py and its tests to parse <!-- fleet-review: ... --> and to return exit 45 when coverage is unstated.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/tests/test_pr_review.py Updates corpus/status tests to cover the new structured marker and new exit-45 behavior.
scripts/pr_review.py Adds marker parsing and blocks unstated coverage with exit 45.
AGENTS.md Routes “reviewing a change set” to the new code-review skill.
.github/copilot-instructions.md Reduces to review bootstrap/runbook + preserves disproved-claims ledger.
.agents/skills/code-review/SKILL.md Adds provider-independent review skill and defines the structured coverage marker contract.
.agents/skills/pr-review-conduct/SKILL.md Updates “mechanics live elsewhere” guidance to point to scripts/pr_review.py + bootstrap.
.agents/skills/copilot-instructions-keeper/SKILL.md Adjusts description to reflect bootstrap role of Copilot instructions.
.claude-plugin/fleet-skills/skills/code-review/SKILL.md Distributes the new code-review skill into the Claude plugin skill set.
.claude-plugin/fleet-skills/skills/pr-review-conduct/SKILL.md Mirrors the same “mechanics live elsewhere” update for the Claude plugin skill set.
.claude-plugin/fleet-skills/skills/copilot-instructions-keeper/SKILL.md Mirrors the bootstrap-description update for the Claude plugin skill set.
.claude-plugin/fleet-skills/.source-digest Updates the generated skill-set digest.
.claude-plugin/fleet-skills/.claude-plugin/plugin.json Registers the new code-review skill in the plugin manifest.
Suppressed comments (1)

scripts/tests/test_pr_review.py:911

  • The docstring for this test still says that treating a no-coverage body as a failure would “cry wolf”, but scripts/pr_review.py status now blocks on coverage=unstated with exit 45. Update the docstring to reflect that this body shape is recognized as coverage=unstated (not UNVETTED), but it is still a blocking outcome for status because it provides no proof of full diff coverage.
    def test_a_round_stating_no_coverage_at_all_is_unstated(self) -> None:
        """28 of the 332 bodies are an overview and a change list, and that shape is current.

        It interleaves with the counted one throughout rather than preceding it, and one pull
        request carries both across its two rounds, so failing on it would cry wolf on about one

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/pr_review.py Resolved
Copilot AI review requested due to automatic review settings August 17, 2026 23:28
@ptr727

ptr727 commented Aug 17, 2026

Copy link
Copy Markdown
Owner Author

Copilot review round 4955381803 reported Suppressed comments (1).

scripts/tests/test_pr_review.py:911: The docstring still says that treating a no-coverage body as a failure would "cry wolf", while unstated coverage now blocks with exit 45.

Fixed in f1c24d7. The test now states that this is a recognized coverage=unstated shape, but it blocks because it cannot prove full diff coverage.

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

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 17, 2026 23:55

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

Copilot reviewed 53 out of 53 changed files in this pull request and generated no new comments.

Suppressed comments (2)

scripts/tests/test_pr_review.py:2844

  • This contract test reads the marker from the .agents/skills/ copy, but the runbook explicitly points Copilot at .github/skills/code-review/SKILL.md. Reading the generated .github/skills/ file here would better validate the actual Copilot-facing contract (and would fail if the generated tree wasn’t regenerated/committed).
    .github/skills/code-review/SKILL.md:17
  • The GitHub Copilot skill lives under .github/skills/, but this step tells the reviewer to load skills from .agents/skills/. In downstream repos (where .agents/skills/ is not carried), this instruction is impossible to follow and will prevent the intended routing to the per-language/workflow skills.
3. Load every applicable skill from `.agents/skills/`:

Copilot AI review requested due to automatic review settings August 18, 2026 00:02
@ptr727

ptr727 commented Aug 18, 2026

Copy link
Copy Markdown
Owner Author

Suppressed finding responses

Review round on e1396f8 reported Suppressed comments (1).

  • scripts/tests/test_pr_review.py:911: "The docstring for this test still says that treating a no-coverage body as a failure would 'cry wolf', but scripts/pr_review.py status now blocks on coverage=unstated with exit 45."
    • Fixed in f1c24d7 - The fixture and its documentation state that unstated coverage is recognized but blocks the gate. A regression test asserts exit 45 for that state.

Review round on da7249f reported Suppressed comments (2).

  • scripts/tests/test_pr_review.py:2844: "This contract test reads the marker from the .agents/skills/ copy, but the runbook explicitly points Copilot at .github/skills/code-review/SKILL.md."
    • Fixed in c3738e5 - The contract test reads the generated Copilot-facing skill.
  • .github/skills/code-review/SKILL.md:17: "The GitHub Copilot skill lives under .github/skills/, but this step tells the reviewer to load skills from .agents/skills/."
    • Fixed in c3738e5 - The canonical skill now routes to applicable sibling skills in the current distribution. Regeneration applies that provider-neutral instruction to both generated trees.

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

Copilot reviewed 53 out of 53 changed files in this pull request and generated no new comments.

Suppressed comments (1)

scripts/build_dist.py:180

  • is_stale() only considers directory entries when validating .github/skills/ (and the plugin's skills/), so a stray file at the distribution root (for example an accidental hand-added README.md or .DS_Store) would not be detected as drift and build_dist.py --check could still pass. Since the docs and help text describe --check as failing whenever a generated distribution differs from .agents/skills/, it should also treat any non-directory entry under the distribution root as stale (and ideally require the root directory to exist even when there are zero skills).

Copilot AI review requested due to automatic review settings August 18, 2026 00:09
@ptr727

ptr727 commented Aug 18, 2026

Copy link
Copy Markdown
Owner Author

Review round on c3738e5 reported Suppressed comments (1).

  • scripts/build_dist.py:180: "is_stale() only considers directory entries when validating .github/skills/ (and the plugin's skills/), so a stray file at the distribution root ... would not be detected as drift."
    • Fixed in 04f4bf7 - Both generated skill roots must exist and contain only the expected skill directories. Three regression tests cover a stray GitHub file, a stray Claude plugin skill file, and a missing empty GitHub distribution.

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

Copilot reviewed 53 out of 53 changed files in this pull request and generated no new comments.

Suppressed comments (1)

scripts/pr_review.py:19

  • The status subcommand docstring says exit 0 implies “the round covering the head read the whole diff”, but report_verdict() returns 0 early when there are no head-covering reviews (if not head_reviews(pr): return 0). This makes exit 0 ambiguous (no review yet vs full coverage), so the docstring should describe the no-review case explicitly.

Copilot AI review requested due to automatic review settings August 18, 2026 00:16
@ptr727

ptr727 commented Aug 18, 2026

Copy link
Copy Markdown
Owner Author

Review round on 04f4bf7 reported Suppressed comments (1).

  • scripts/pr_review.py:19: "The status subcommand docstring says exit 0 implies 'the round covering the head read the whole diff', but report_verdict() returns 0 early when there are no head-covering reviews."
    • Fixed in ced266c - The CLI contract explicitly distinguishes the no-review success case and directs callers that require review presence to wait. A contract test protects the documented behavior.

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

Copilot reviewed 53 out of 53 changed files in this pull request and generated no new comments.

@ptr727
ptr727 merged commit 05c101e into develop Aug 18, 2026
8 checks passed
@ptr727
ptr727 deleted the feature/issue-793-copilot-review branch August 18, 2026 00:44
ptr727 added a commit that referenced this pull request Sep 21, 2026
…1743)

Settles #1741 and #1740, both raised by a concurrent session in another
fleet repository and ranked first and third on handoff #1738.

## The rule an agent could not follow

`pr-review-conduct` "Expected review loop" ended its timeout advice with
"remove Copilot in the pull request UI, add it again", which no agent
seat can perform, and its only other advice was to wait again, which is
what was already failing. Every stall therefore escalated to the
maintainer for a manual click.

The recovery now reads: on a second bounded `wait` timeout, read the
pending set, clear it only where no human or team reviewer is requested
alongside the bot, and rerun `wait`, which then has nothing outstanding
to defer to and requests afresh. A stall still pending after that wait
is the maintainer's, which is the bound the previous text got from the
maintainer gate it no longer needs.

`requested=yes` reads as acceptance of the request rather than delivery
of a round, on all three surfaces that state it. An unpicked request
prints the digest of one about to be served, so a driver reading that
field as progress waits on evidence it does not hold.

## Where the mutation went, and why not the runbook

`docs/pr-reviewer-reference.md`, whose stated subject is how each
reviewer is triggered. Not `.github/copilot-instructions.md`: #799
reduced that file to a review bootstrap, and
`test_the_runbook_routes_mutations_to_the_script` asserts it carries no
mutation document at all. That is also the home
`test_the_only_writes_are_the_four_named_here` has described all along
as keeping the `union:false` clear-and-recover form manually, while
naming the wrong file for it, so this change makes that docstring true
rather than merely current.

The snippet gates its own write rather than describing a gate beside an
ungated command: the pull request id and the pending-set count are each
captured live and each guarded, and the clear runs only where the count
is zero. `gh pr view --json reviewRequests` omits a Bot, which is what
makes that count a human-and-team count.

## The watcher trap next to the one 2.0.656 shipped

A watcher testing for a bare negative matches a line a covered review
wrote, so it reports no review over a review that landed. The rule added
is to anchor the pattern on what is unique to the field being read, and
for a pair nested in a parenthesized group the group's name ahead of it,
since the digest renders the same inner names in more than one group.

## Carried forward rather than fixed here

The clear's guard covers humans and teams. A second reviewer **app** in
the pending set is invisible to both it and the digest's `requested`
field, which matches the Copilot login alone, so such a request would be
dropped by the replace. Narrow today, since no other reviewer here is
configured as a requested reviewer, and worth either a stated limit or a
GraphQL read that excludes one login rather than every Bot.

## Verification

427 `pr_review` tests and 1641 across the suite pass. `build_dist.py
--check` reports the generated trees current. `ruff check`, `ruff format
--check`, `prose_lint.py` whole-tree and against the diff,
`repo_gate.py`, `spec/validate.py`, and the Docker linters are clean.
The new test was proved by removing the code block it pins and watching
it fail. Five local strict review rounds ran before this push, raising
33 findings between them, of which 21 were fixed, 8 declined as
preference or as inherent to two API calls with no lock, and the rest
are the two pre-existing ones noted above and below.

Separately pre-existing, filed rather than fixed:
`.github/copilot-instructions.md`'s third Disproved Claims entry is
proved against a `BOT_ID` query in a "Triggering and Polling" section
that file no longer carries, and `in_scope`'s refusal message in
`scripts/pr_review.py` routes a cross-owner caller to a runbook `gh`
path that does not exist.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved handling of stalled automated code-review requests with
repeated, bounded waits and clearer progress reporting.
- Pending automated requests can now be cleared and retried when no
human or team reviewer is involved.
- Requests involving human or team reviewers are preserved and escalated
for maintainer action.

- **Documentation**
  - Added recovery guidance for stalled review requests.
- Expanded review-operation guidance, including monitoring requirements
and recovery procedures.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

2 participants