Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions .agents/skills/code-review/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ All reviews are evaluated against the engineering conventions defined in [AGENTS

## Review Workflow

1. **Classify Changed Files & Scope**:
Group changed files according to the 3-tier architectural hierarchy and evaluate PR scoping:
- **Priority 1: Public Trait APIs & Consumer Contracts** (`roborock/devices/traits/`, `roborock/data/containers.py`)
- **Priority 2: Data Lifecycle & State Management** (trait state, callbacks, `RoborockDevice.close()`, map/render pipelines)
- **Priority 3: Wire Protocols, Codecs & Cryptography** (`roborock/protocols/`, `roborock/devices/transport/`, `roborock/devices/rpc/`)
1. **Fetch PR Context & Classify Scope**:
- **Fetch Metadata & Prior Thread History**: Fetch PR metadata, diff, and all prior reviews and inline threads (`gh pr view <N> -R Python-roborock/python-roborock --json ...` and `gh api repos/Python-roborock/python-roborock/pulls/<N>/comments --paginate`). Note that `gh pr checks <N>` exits non-zero when a first-time contributor's workflow awaits approval—treat that as pending CI approval rather than a failure. When cleaning up or re-reviewing an existing PR, also inspect GraphQL `reviewThreads` to verify and resolve addressed threads (including Copilot comments).
- **Classify Changed Files**: Group changed files according to the 3-tier architectural hierarchy and evaluate PR scoping:
- **Priority 1: Public Trait APIs & Consumer Contracts** (`roborock/devices/traits/`, `roborock/data/containers.py`)
- **Priority 2: Data Lifecycle & State Management** (trait state, callbacks, `RoborockDevice.close()`, map/render pipelines)
- **Priority 3: Wire Protocols, Codecs & Cryptography** (`roborock/protocols/`, `roborock/devices/transport/`, `roborock/devices/rpc/`)
- **PR Scoping**: Flag PRs that mix unrelated subsystems or combine large protocol/parser additions with trait consumption when they should be split into focused PRs.
- **Automated Conformance**: Structural invariants (`RoborockBase` inheritance, `RoborockEnum` fallback members, `RoborockException` rooting, and trait boundary types) are enforced in `tests/conformance/`. Flag any unjustified allowlist exemptions added to `tests/conformance/` and focus deeper review energy on semantic, lifecycle, and design issues.

Expand Down Expand Up @@ -47,22 +48,25 @@ All reviews are evaluated against the engineering conventions defined in [AGENTS
5. **Evaluate Tests & Fixtures**:
- **Test Mirroring & Colocation**: Are tests colocated in the matching mirror path under `tests/` for the module being tested (e.g., tests for `roborock/devices/traits/v1/status.py` in `tests/devices/traits/v1/test_status.py`; new modules have corresponding new test suites under the mirror directory)?
- **No One-Off Bugfix Test Files**: Flag any fragmented single-bug or single-PR test files (e.g., `tests/test_battery_low_voltage_fix.py`). Tests must be integrated into the module's corresponding test suite.
- Are tests using `fake_channel` and `@pytest.mark.parametrize` rather than hand-rolled mocks or duplicate methods?
- Are tests reusing shared module fixtures (`mock_rpc_channel`, `fake_channel`, `device_fixture`), `roborock.testing` simulators (`V1VacuumSimulator`, `Q10VacuumSimulator`, `DyadSimulator`, `ZeoSimulator`), and `@pytest.mark.parametrize` rather than hand-rolled inline command-dict fakes or duplicate test methods?
- Do assertions verify public behavior rather than private `_state` variables?

6. **Adversarial Self-Check on Candidate Findings**:
Before presenting or posting any review comment, subject every candidate finding and suggested diff to hostile adversarial scrutiny and discard any that fail:
- **Baseline & History Check**: Trace concrete inputs across `upstream/main`, the PR, and your proposed fix (inspecting `git log` / blame when existing test or helper intent is non-obvious). Discard suggestions that silently regress `main` behavior on valid inputs or introduce magic-number/boundary duplication.
- **Verify Rationale Against Peer Cases**: Check sibling functions and enum codes in the same module to confirm your stated invariant actually holds across the codebase rather than inventing a stricter rule for the touched lines alone.
- **Independent Check of Prior Reviews**: When comparing competing PRs or prior review comments (human or AI), evaluate those claims with the same adversarial skepticism instead of carrying them forward uncritically.
- **Verify Rationale Against Peer Cases**: Check sibling functions, traits, and enum codes in the same module to confirm your stated invariant actually holds across the codebase rather than inventing a stricter rule for the touched lines alone.
- **Prior Review Continuity & Independent Check**: On re-reviews, verify candidate findings against earlier maintainer comments on the PR—never move the goalposts by flagging a pattern the maintainer previously asked the author to adopt (unless explicitly noting why we are reconsidering earlier guidance), and check whether prior maintainer questions were answered. Conversely, evaluate third-party or competing-PR claims with adversarial skepticism instead of carrying them forward uncritically.
- **Drop Low-Value Nits & Allow Zero-Defect Approvals**: Drop trivial docstring or comment wording nits (especially in tests) unless factually harmful, and verify any suggested replacement text accurately reflects what the code/test asserts. If no findings survive adversarial scrutiny, report that the PR is clean and ready to approve rather than manufacturing filler comments.

7. **Format Review Output**:
Structure review comments with clear rationale and actionable code recommendations:
- **Priority Level & File Reference**
- **Issue / Anti-Pattern Identified**
- **Grounded Rationale** (citing protocol resilience, consumer stability, or maintainability)
- **Concrete Before / After Diff or Suggested Fix**
Keep feedback high-signal: focus on architectural violations, state/concurrency bugs, protocol safety, and test gaps; avoid nitpicking formatting or style already enforced by Ruff and Mypy.
- **Interactive / Summary Reviews**: Group findings by Priority Layer (1 → 3) with file references, the anti-pattern identified, grounded rationale (citing protocol resilience, consumer stability, or maintainability), and a concrete before/after diff or suggested fix.
- **Inline PR Review Comments**: State the issue, grounded rationale (citing `AGENTS.md` conventions), and suggested fix concisely right on the affected lines.
7. **Format Review Output & Calibrate Delivery**:
- **Lead with Verdict & Clickable Link**: Always open interactive and subagent review reports with a clickable PR link (`[#N](https://github.com/Python-roborock/python-roborock/pull/N)`) and an explicit 1-line bottom-line verdict (**Approve / LGTM — no changes needed**, **Comment with non-blocking question/simplification**, or **Request Changes**).
- **Structure Actionable Findings**:
- **Priority Level & File Reference**
- **Issue / Anti-Pattern Identified**
- **Grounded Rationale** (citing protocol resilience, consumer stability, or maintainability)
- **Concrete Before / After Diff or Suggested Fix**
Keep feedback high-signal: focus on architectural violations, state/concurrency bugs, protocol safety, and test gaps; avoid nitpicking formatting or style already enforced by Ruff and Mypy.
- **Calibrate GitHub Comment Style**:
- **Simplifications & Design Questions**: Frame optional simplifications as collaborative questions with a proposed `diff` (`COMMENT` review) rather than rigid blockers.
- **Fundamental Design Pushback**: When a PR addresses a real problem with an over-complicated design, prefer **one high-level review comment** acknowledging the real problem, listing the core failure modes, and sketching a simpler alternative instead of leaving inline nits on code that shouldn't stay.
- **Unanswered Prior Questions**: Restate unanswered questions from earlier reviews concisely in 2–3 sentences focused on the core consumer/design question rather than pasting long verbatim self-quotes.
72 changes: 25 additions & 47 deletions .agents/skills/pr-triage/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,48 @@
---
name: pr-triage
description: >-
Assess open pull requests and review queue state in python-roborock, optionally syncing the local workspace with upstream/main. Use when asked what needs to be reviewed, to triage open PRs, or to sync and check the review backlog.
Assess open pull requests, incoming issues, and review queue state in python-roborock, optionally syncing the local workspace with upstream/main. Use when asked what needs to be reviewed, to triage open PRs or incoming issues, or to sync and check the review backlog.
---

# PR Triage & Review Queue Skill
# PR & Issue Triage Skill

Use this skill when assessing open pull requests, checking which PRs need initial review or re-review, or syncing the workspace before starting a review session.
Use this skill when assessing open pull requests, triaging incoming issues, checking which PRs need initial review or re-review, or syncing the workspace before starting a review session.

Once the user selects a specific PR to review, switch to the [Code Review Skill](../code-review/SKILL.md).

---

## Workflow

1. **Optional Workspace Sync**:
If the user asks to sync (e.g., "sync and check reviews") or the workspace is a clean review branch behind `upstream/main`:
1. **Workspace Fetch & Optional Sync**:
Always `git fetch upstream main` so local context reflects current `upstream/main`. If the user asks to sync (e.g., "sync and check reviews") or the workspace is a clean review branch behind `upstream/main`:
- Verify clean working tree (`git status --short`). Do **not** fast-forward or rebase if uncommitted local changes exist unless asked.
- Fetch remotes (`git fetch --all --prune`).
- Fast-forward the local tracking branch to `upstream/main` (or `origin/main` if `upstream` is absent): `git merge --ff-only upstream/main`.

2. **Query Open PR & Review Metadata**:
Identify the current GitHub user and fetch open PR state in a single `gh` pass so no per-PR polling is needed:
2. **Run the Single-Pass Triage Script**:
Execute [`scripts/triage.py`](scripts/triage.py) with `prs`, `issues`, or `all` depending on what the user asked to triage. Each subcommand runs a single GraphQL call (up to 100 open PRs / 50 open issues) without hitting `gh pr list` node-count limits:
```bash
REVIEWER=$(gh api user --jq .login)
gh pr list --repo Python-roborock/python-roborock --state open --limit 30 \
--json number,title,author,isDraft,createdAt,updatedAt,additions,deletions,mergeable,reviewDecision,headRefOid,reviews,commits,comments \
| jq --arg me "$REVIEWER" '
sort_by(.number) | reverse | .[] | .author.login as $pr_author | {
number,
title,
author: $pr_author,
isDraft,
mergeable,
size: "+\(.additions)/-\(.deletions)",
reviewDecision,
headRefOid,
lastCommit: (.commits | last | .committedDate),
myLastReview: ([.reviews[] | select(.author.login == $me)] | last | {state, submittedAt, commitOid: .commit.oid}),
otherLastReview: ([.reviews[] | select(.author.login != $me and .author.login != $pr_author and .author.login != "copilot-pull-request-reviewer")] | last | {author: .author.login, state, submittedAt}),
lastAuthorReplyAt: (
[
(.comments[] | select(.author.login == $pr_author) | .createdAt),
(.reviews[] | select(.author.login == $pr_author) | .submittedAt)
] | max
)
}'
# Triage open PRs only (review buckets + suggested 5-PR batch)
python3 .agents/skills/pr-triage/scripts/triage.py prs

# Triage incoming open issues only (still cross-linking open PRs without dumping the PR queue)
python3 .agents/skills/pr-triage/scripts/triage.py issues

# Triage both open PRs and open issues in a single pass
python3 .agents/skills/pr-triage/scripts/triage.py all
```
*(Note: GitHub's GraphQL `reviews` array includes `COMMENTED` entries whenever an author replies in an inline review thread, so combining `.comments[]` and `.reviews[]` filtered to `$pr_author` captures both top-level PR comments and inline review-thread replies without extra API calls.)*
*(Pass `--json` if structured output is needed for custom filtering.)*

3. **Classify PRs into Actionable Buckets**:
Group open PRs in priority order for the reviewer (`$REVIEWER`):
- **1. New PRs Awaiting Initial Review**:
Non-draft PRs not authored by `$REVIEWER` where `myLastReview.submittedAt == null`. Flag competing/overlapping PRs targeting the same module/issue and note if another maintainer already commented/approved.
- **2. Re-reviews Needed (Updated Since Last Review)**:
Non-draft PRs not authored by `$REVIEWER` where `myLastReview.submittedAt != null` AND (`headRefOid != myLastReview.commitOid` OR `(lastAuthorReplyAt != null and lastAuthorReplyAt > myLastReview.submittedAt)`). Comparing `headRefOid != myLastReview.commitOid` catches amended, rebased, or cherry-picked commits whose `committedDate` precedes `myLastReview.submittedAt`.
- **3. Approved & Ready to Merge / Own PR Updates**:
- Non-draft PRs (authored by `$REVIEWER` or contributors) that are `APPROVED` (`reviewDecision == "APPROVED"`), `MERGEABLE`, and have no unreviewed commits since approval (`headRefOid == myLastReview.commitOid` or authored by `$REVIEWER`).
- Non-draft PRs authored by `$REVIEWER` with new review feedback or merge conflicts requiring action.
- **4. Waiting on Author / Drafts (Compact Summary)**:
- Non-draft PRs with `CHANGES_REQUESTED` or `COMMENTED` where `headRefOid == myLastReview.commitOid` and no new author replies (`lastAuthorReplyAt <= myLastReview.submittedAt`) have arrived.
- Draft PRs (`isDraft == true`), summarized compactly on 1–2 lines unless a draft has notable recent maintainer discussion.
- Conflicting (`mergeable == "CONFLICTING"`) or stale backlog items.
3. **Verify Actionable Buckets**:
The script classifies open PRs for the authenticated reviewer into four priority buckets:
- **1. New PRs Awaiting Initial Review**: Non-draft contributor PRs you have not yet reviewed, annotated with file overlaps (`overlaps #...`), referenced issues, CI state (`SUCCESS`, `FAILURE`, `PENDING_APPROVAL`), and other maintainer reviews.
- **2. Re-reviews Needed**: Non-draft PRs where `headRefOid != myLastReview.commitOid` (catches amended/rebased commits) or the author replied after `myLastReview.submittedAt`.
- **3. Ready to Merge / Own PRs**: Approved, mergeable PRs with no unreviewed commits, plus your own open PRs (highlighting merge conflicts or unresolved Copilot/review threads).
- **4. Waiting on Author & Drafts**: Compact summary of PRs awaiting contributor changes and draft PRs.

4. **Present Concise Triage Report**:
- Report sync status in one line if a sync was performed (commit hash + any new release tags).
- List actionable PRs (`#number`, title, `@author`, `+additions/-deletions`, and why it needs attention—e.g., *opened Oct 31* or *updated Oct 22 after your Oct 17 review*).
- Keep "Waiting on Author / Drafts" brief so actionable reviews stand out.
- Ask which PR the user wants to review first.
- **Always preserve clickable Markdown links** (`[#number](url)`) for every PR and issue mentioned.
- Highlight high-signal relationships (e.g., competing PRs touching the same module, stacked PR series from the same author, or issues already addressed by an open PR).
- Conclude with the **Suggested Next Review Batch (3–5 non-overlapping PRs)** ordered from quick green-CI wins to high-impact bugfixes, noting any PRs awaiting first-time contributor CI approval.
Loading
Loading