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
2 changes: 1 addition & 1 deletion sdv-toolkit/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sdv-toolkit",
"version": "0.25.4",
"version": "0.26.0",
"description": "SportsDataverse engineering toolkit -- 25 skills and 10 agents shared across the ~40 SDV repos (Python + R). A SessionStart router detects the repo archetype and emits a routing card, so conventions load on arrival instead of being recalled. Skills: /sdv-add-source, /sdv-api-sync, /sdv-assuring-data-pipelines, /sdv-building-data-pipelines, /sdv-conventions, /sdv-data-pipeline, /sdv-dataset-lifecycle, /sdv-document, /sdv-guide, /sdv-learn, /sdv-metric-parity, /sdv-model-build, /sdv-modeling, /sdv-polars, /sdv-port, /sdv-python-performance-optimization, /sdv-r-coverage, /sdv-regen-docs, /sdv-repo-audit, /sdv-reprocess, /sdv-research-paper, /sdv-review-pr, /sdv-ship, /sdv-triage, /sdv-working-in-notebooks.",
"author": {
"name": "Saiem Gilani",
Expand Down
53 changes: 30 additions & 23 deletions sdv-toolkit/skills/sdv-ship/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,19 +448,32 @@ block a small, tested fix indefinitely either.
or for selective resolution.

8. **Re-request review** if the changes were substantial: `@coderabbitai review`
(comment) for CodeRabbit, or `request_copilot_review` (github MCP) for Copilot.
(comment) for CodeRabbit. Re-request Copilot (`request_copilot_review`, github MCP) only on a PR
where it was the chosen reviewer. A PR that got the two self-review rounds never gets Copilot
(owner rule, 2026-11-26).

9. **Report** a table: `thread | by | path:line | verdict (fixed/declined/answered) | resolved?`.
Leave genuinely contentious threads unresolved and flag them for a human call.

### Both review bots rate-limited: the Copilot fallback
### Both review bots rate-limited: two self-review rounds

CodeRabbit runs out (about one review an hour, shared across the org) and so does Sourcery (250,000 diff characters
a week). Owner rule, 2026-10-09: once **both** have been rate-limited for more than 5 minutes on a **package** PR
(not a `-raw`/`-data` producer), and once the self-review rounds below have run on the head, request a GitHub Copilot
review without asking if you are the owner (`saiemgilani`) or have Copilot PR review. Otherwise ask the user whether to
request one. `ci_wait.py --copilot auto --self-reviewed <head SHA>` does both,
and its rate-limit detection reads the real notices, not the bots' green statuses. By hand:
a week). Owner rule, 2026-11-26: once **both** have been rate-limited for more than 5 minutes on a **package** PR
(not a `-raw`/`-data` producer), **two self-review rounds replace them, and Copilot is not requested at all**:

1. A fresh-context review of the whole diff (`sdv-review-pr`, or the repo's `sdv-*-reviewer`). Fix Critical and
Important findings test-first: the test fails before the fix.
2. An independent adversarial pass on the fix commits, by a reviewer that gets the code, not round 1's conclusions.
Fix what it finds the same way.

Push every fix, answer the bot threads, then wait for CI with `ci_wait.py --self-reviewed <head SHA>`. The flag names
one commit, so a later push needs its own two rounds. This covers mirror PRs too. If Copilot was requested by
mistake, `gh pr edit <N> --remove-reviewer @copilot` withdraws it while it's still pending; a REST DELETE 422s on
the bot. `ci_wait.py`'s rate-limit detection reads the real notices, not the bots' green statuses.

**Copilot is only for a PR that gets no self-review**, and only when asked for explicitly with `ci_wait.py --copilot
auto` (or `ask`). It requests without asking if you are the owner (`saiemgilani`) or have Copilot PR review, and asks
the user otherwise. By hand:

```sh
gh api -X POST repos/<owner>/<repo>/pulls/<N>/requested_reviewers -f 'reviewers[]=copilot-pull-request-reviewer[bot]'
Expand All @@ -469,16 +482,10 @@ gh api -X POST repos/<owner>/<repo>/pulls/<N>/requested_reviewers -f 'reviewers[
gh pr edit <N> -R <owner>/<repo> --add-reviewer @copilot
```

Copilot's threads then get the same treatment as any bot's.

**Self-review comes before Copilot** (owner rule, 2026-11-26). Run the self-review rounds first: a fresh-context
review of the whole diff, then an independent adversarial pass on the fix commits. Push every fix, and only then
request Copilot, on the self-reviewed head, as the last gate. That also covers mirror PRs. Copilot credits are finite,
and on an already-cleaned diff its findings are the non-obvious ones (sportsdataverse/.github#72: 3 findings after two
self-review rounds and CodeRabbit). Until `--self-reviewed <SHA>` names the current head, `ci_wait.py` returns
`self-review-first` (exit 9) instead of requesting or asking. The flag names one commit, so a later push needs a new
self-review before Copilot is requested again. After you fix Copilot's own threads and push, don't request it
again: wait for CI with `--copilot never`.
Copilot's threads then get the same treatment as any bot's. After you fix them and push, wait for CI with
`--copilot never`: a rerun with `--copilot auto` requests Copilot again on the new head and spends more credits.
Re-request it only if the fixes were substantial (Phase 5, step 8). Passing `--self-reviewed` rules Copilot out
under any `--copilot` mode.

**Check Copilot's credits first** (owner rule, 2026-10-11). A Copilot review spends the requester's premium
credits, and with too few left Copilot answers with a review whose body is a quota refusal ("unable to review
Expand Down Expand Up @@ -519,8 +526,8 @@ checks` and `gh pr view` spend the shared GraphQL quota, which ran out on 2026-1
prints every job line and encodes the owner's rules (2026-10-09):

```sh
python <toolkit>/skills/sdv-ship/scripts/ci_wait.py <owner/repo> --pr <N> # defaults: --cap 15m --copilot auto
# after the self-review rounds and their fixes are pushed: add --self-reviewed <head SHA> so it may request Copilot
python <toolkit>/skills/sdv-ship/scripts/ci_wait.py <owner/repo> --pr <N> # defaults: --cap 15m, no Copilot
# after the two self-review rounds and their fixes are pushed: add --self-reviewed <head SHA> (it then waits for CI)
```

| Verdict (exit) | Do |
Expand All @@ -529,10 +536,10 @@ python <toolkit>/skills/sdv-ship/scripts/ci_wait.py <owner/repo> --pr <N> # d
| `ready-capped` (0) | Nothing failed and every bot thread is answered, but some checks are still running 15 minutes after `ci_wait` first saw the current head. That is the owner's cap: merge without waiting longer. A push restarts the clock, and the cap only fires once the bot threads are answered. The still-pending jobs are listed. |
| `failed` (1) | Read the named job, fix it and loop back to Phase 1. Never merge past a failure. |
| `conflict` (2) | Merge the base branch first: a conflicting PR starts no `pull_request` workflows. |
| `bots-unaddressed` (5) | Answer the listed bot threads (Phase 5), then run it again. |
| `self-review` (8) | No bot can review: CodeRabbit and Sourcery are rate-limited, and Copilot is out of premium credits or has already refused. Run the self-review rounds above and push their fixes, then wait for CI with `--copilot never` (rerunning without it returns `self-review-first`). |
| `self-review-first` (9) | Copilot is next, but `--self-reviewed` doesn't name the current head. Run the self-review rounds above and push their fixes, then rerun with `--self-reviewed <that head SHA>`. If Copilot already reviewed an earlier head and only its fixes were pushed since, wait for CI with `--copilot never` instead. |
| `ask-user` (4) | Both review bots have been rate-limited for 5+ minutes on a package PR, and the acting login may lack Copilot review. Ask the user whether to request a Copilot review. |
| `bots-unaddressed` (5) | Answer the listed bot threads (Phase 5), push, then run it again: with `--self-reviewed <new head SHA>` once the fix commits had their self-review, or with `--copilot never` just to wait for CI. Never rerun `--copilot auto` after fixing Copilot's own threads. |
| `self-review-first` (9) | Both review bots are rate-limited and `--self-reviewed` doesn't name the current head. Run the two self-review rounds above, push their fixes, and rerun with `--self-reviewed <that head SHA>`; Copilot is not requested, and the script waits for CI. |
| `self-review` (8) | Only with an explicit `--copilot auto`/`ask`: Copilot can't review (out of premium credits, or it already refused). Run the self-review above and push its fixes, then wait for CI with `--copilot never`. |
| `ask-user` (4) | Only with an explicit `--copilot auto`/`ask`: the acting login may lack Copilot review. Ask the user whether to request a Copilot review. |
| `timeout` (3), `error` (6) | Report it. Don't merge on it. |
| `merged` (0), `closed` (7) | Stop. |

Expand Down
87 changes: 42 additions & 45 deletions sdv-toolkit/skills/sdv-ship/scripts/ci_wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
Owner rules:
1. Stop waiting on CI --cap after start once every bot review is addressed and
no job has failed. Any failure ends the wait at once (never capped).
2. On a package PR (repo not ending -raw/-data), if CodeRabbit AND Sourcery
are both rate-limited for more than --bots-limited-after, request a GitHub
Copilot review when the actor is allowed (saiemgilani, or a login in
SDV_COPILOT_REVIEWERS); otherwise stop and ask the user. Self-review comes
first (owner rule, 2026-11-26): unless --self-reviewed names the current
head, the rule stops with verdict `self-review-first` instead of requesting
or asking. Run the self-review rounds, push their fixes, and rerun with
--self-reviewed <that head SHA>. A later push needs a new SHA, so Copilot
is never requested on commits nobody self-reviewed.
2. On a package PR (repo not ending -raw/-data), once CodeRabbit AND Sourcery
are both rate-limited for more than --bots-limited-after, two self-review
rounds replace them (owner rule, 2026-11-26). By default the script stops
with verdict `self-review-first`. Run the rounds, push their fixes, and rerun
with --self-reviewed <that head SHA>: Copilot is then never requested, and the
script waits for CI. A later push needs a new SHA (exit 9 under any
--copilot mode: a PR with the rounds never gets Copilot). Only an explicit
--copilot auto|ask (a PR that gets no self-review) requests a GitHub Copilot
review when the actor is allowed (saiemgilani, or a login in
SDV_COPILOT_REVIEWERS), or asks the user otherwise.
3. Copilot reviews spend the actor's premium credits. Before requesting, read
them (`copilot_internal/user`); below SDV_COPILOT_MIN_CREDITS (default 500)
-- or when Copilot already answered this PR with a quota refusal -- stop with
Expand All @@ -25,16 +26,17 @@
Usage:
python3 ci_wait.py owner/repo (--pr N | --sha SHA) [--interval 60s] [--cap 15m]
[--timeout 60m] [--bots-limited-after 5m] [--bots-grace 5m]
[--copilot auto|ask|never] [--self-reviewed SHA] [--package | --no-package]
[--self-reviewed SHA] [--copilot auto|ask|never] [--package | --no-package]

A push restarts --cap and --bots-grace (CodeRabbit/Sourcery with no review of the
current head count as pending for --bots-grace); --timeout never restarts.

Exit: 0 ready / ready-capped / merged, 1 failed, 2 conflict, 3 timeout, 4 ask-user,
5 bots-unaddressed, 6 error (including usage errors), 7 closed without merging,
8 self-review (no bot can review: run a self-review and push its fixes; to
wait for CI only, rerun with --copilot never), 9 self-review-first (Copilot
is next: self-review the head, push, rerun with --self-reviewed <head SHA>).
8 self-review (--copilot auto|ask, but Copilot can't review: run a self-review
and push its fixes; to wait for CI only, rerun with --copilot never),
9 self-review-first (run the two self-review rounds, push, rerun with
--self-reviewed <head SHA>; Copilot is not requested).
"""

from __future__ import annotations
Expand Down Expand Up @@ -388,8 +390,9 @@ def parse_args(argv):
p.add_argument("--timeout", type=duration, default=60 * 60)
p.add_argument("--bots-limited-after", type=duration, default=5 * 60)
p.add_argument("--bots-grace", type=duration, default=5 * 60)
p.add_argument("--copilot", choices=("auto", "ask", "never"), default="auto")
# the self-review rounds ran on this head (a 4-40 hex SHA prefix): Copilot may be requested on it
# default None: self-review is the path; auto/ask request Copilot only when passed explicitly
p.add_argument("--copilot", choices=("auto", "ask", "never"), default=None)
# the two self-review rounds ran on this head (a 4-40 hex SHA prefix): Copilot is never requested
p.add_argument("--self-reviewed", metavar="SHA", type=sha_prefix)
p.add_argument("--package", dest="package", action="store_true")
p.add_argument("--no-package", dest="package", action="store_false")
Expand Down Expand Up @@ -423,10 +426,9 @@ def run(
"to wait for CI only, rerun with --copilot never"
)
self_review_first = (
"ACTION: run the self-review rounds (sdv-ship: a fresh-context review of the whole diff, then an "
"independent adversarial pass on the fix commits), push their fixes, then rerun with "
"--self-reviewed <the pushed head SHA> to request Copilot. If Copilot already reviewed an "
"earlier head and only its fixes were pushed since, wait for CI with --copilot never"
"ACTION: run the two self-review rounds (sdv-ship: a fresh-context review of the whole diff, then "
"an independent adversarial pass on the fix commits), push their fixes, then rerun with "
"--self-reviewed <the pushed head SHA>: Copilot is not requested and ci_wait waits for CI"
)
allowed = {OWNER} | {
x.strip() for x in env.get("SDV_COPILOT_REVIEWERS", "").split(",") if x.strip()
Expand Down Expand Up @@ -580,7 +582,27 @@ def finish(verdict, snap, notes, threads=()):
):
if now() - both_since <= a.bots_limited_after:
waiting.append("CodeRabbit+Sourcery rate-limited")
else:
elif a.self_reviewed and snap["sha"].lower().startswith(a.self_reviewed):
# owner rule 2026-11-26: two self-review rounds replace Copilot -- never request it
copilot_tried = True # decided for this head; a push re-arms the rule
say("self-reviewed head %s: no Copilot review (owner rule); waiting for CI" % snap["sha"][:7])
elif a.copilot is None or a.self_reviewed: # default, or a stale --self-reviewed under any mode
return finish(
"self-review-first",
snap,
[
"CodeRabbit and Sourcery rate-limited"
+ (
" (--self-reviewed %s is not the head %s)"
% (a.self_reviewed, snap["sha"][:7])
if a.self_reviewed
else ""
),
self_review_first,
],
threads,
)
else: # --copilot auto|ask, passed explicitly for a PR that gets no self-review
if a.copilot == "auto" and actor is None:
actor = (gh.get("user") or {}).get("login", "")
if bots["Copilot"][0] == "no-credits":
Expand All @@ -591,23 +613,6 @@ def finish(verdict, snap, notes, threads=()):
self_review],
threads,
)
# owner rule 2026-11-26: self-review before Copilot, on the head it reviews
if not (a.self_reviewed and snap["sha"].lower().startswith(a.self_reviewed)):
return finish(
"self-review-first",
snap,
[
"CodeRabbit and Sourcery rate-limited; self-review comes before Copilot"
+ (
" (--self-reviewed %s is not the head %s)"
% (a.self_reviewed, snap["sha"][:7])
if a.self_reviewed
else ""
),
self_review_first,
],
threads,
)
if a.copilot == "ask" or actor not in allowed:
return finish(
"ask-user",
Expand All @@ -631,14 +636,6 @@ def finish(verdict, snap, notes, threads=()):
],
threads,
)
# Re-read the head: the gate checked the poll's snapshot, and a push during the
# user/credit lookups would get an unreviewed head the request (Copilot on #73).
# ponytail: requested_reviewers takes no SHA, so a ms-wide window stays between
# this read and the POST; the next poll's head-move check restarts the rule.
head_now = ((gh.get("repos/%s/pulls/%d" % (a.repo, a.pr)) or {}).get("head") or {}).get("sha")
if head_now and head_now != snap["sha"]:
say("head moved to %s during the Copilot checks: not requesting on it" % head_now[:7])
continue
copilot_tried = True
ok, how = gh.request_copilot(a.repo, a.pr)
if not ok:
Expand Down
Loading