diff --git a/sdv-toolkit/.claude-plugin/plugin.json b/sdv-toolkit/.claude-plugin/plugin.json
index 475f8ca..c6eba07 100644
--- a/sdv-toolkit/.claude-plugin/plugin.json
+++ b/sdv-toolkit/.claude-plugin/plugin.json
@@ -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",
diff --git a/sdv-toolkit/skills/sdv-ship/SKILL.md b/sdv-toolkit/skills/sdv-ship/SKILL.md
index 52ea5f1..32cb2fc 100644
--- a/sdv-toolkit/skills/sdv-ship/SKILL.md
+++ b/sdv-toolkit/skills/sdv-ship/SKILL.md
@@ -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
` 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 `. 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 --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///pulls//requested_reviewers -f 'reviewers[]=copilot-pull-request-reviewer[bot]'
@@ -469,16 +482,10 @@ gh api -X POST repos///pulls//requested_reviewers -f 'reviewers[
gh pr edit -R / --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 ` 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
@@ -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 /skills/sdv-ship/scripts/ci_wait.py --pr # defaults: --cap 15m --copilot auto
-# after the self-review rounds and their fixes are pushed: add --self-reviewed so it may request Copilot
+python /skills/sdv-ship/scripts/ci_wait.py --pr # defaults: --cap 15m, no Copilot
+# after the two self-review rounds and their fixes are pushed: add --self-reviewed (it then waits for CI)
```
| Verdict (exit) | Do |
@@ -529,10 +536,10 @@ python /skills/sdv-ship/scripts/ci_wait.py --pr # 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 `. 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 ` 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 `; 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. |
diff --git a/sdv-toolkit/skills/sdv-ship/scripts/ci_wait.py b/sdv-toolkit/skills/sdv-ship/scripts/ci_wait.py
index 8a125d6..63033a9 100644
--- a/sdv-toolkit/skills/sdv-ship/scripts/ci_wait.py
+++ b/sdv-toolkit/skills/sdv-ship/scripts/ci_wait.py
@@ -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 . 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 : 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
@@ -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 ).
+ 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 ; Copilot is not requested).
"""
from __future__ import annotations
@@ -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")
@@ -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 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 : 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()
@@ -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":
@@ -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",
@@ -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:
diff --git a/sdv-toolkit/tools/test_ci_wait.py b/sdv-toolkit/tools/test_ci_wait.py
index 0ef2b2b..f8bf75b 100644
--- a/sdv-toolkit/tools/test_ci_wait.py
+++ b/sdv-toolkit/tools/test_ci_wait.py
@@ -225,9 +225,9 @@ def go(repo, table, *args, start=T0, env=None, post_ok=True):
return rc, out.getvalue(), fake, clock
-def go_sr(repo, table, *args, **kw):
- """go() after the self-review rounds ran: Copilot may be requested."""
- return go(repo, table, "--self-reviewed", SHA, *args, **kw)
+def go_cp(repo, table, *args, **kw):
+ """go() with --copilot auto passed explicitly: the Copilot fallback, for a PR with no self-review."""
+ return go(repo, table, "--copilot", "auto", *args, **kw)
PY = "sportsdataverse/sportsdataverse-py"
@@ -544,7 +544,7 @@ def test_allowed_actor_requests_once_and_keeps_waiting(self):
table["repos/%s/pulls/7/reviews?per_page=100" % PY] = Seq(
[], [], [review(COPILOT_BOT)]
)
- rc, out, fake, _ = go_sr(PY, table, start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, start=T0 + 360)
self.assertEqual(len(fake.posts), 1)
self.assertIn("requested_reviewers", fake.posts[0][3])
self.assertIn("reviewers[]=copilot-pull-request-reviewer[bot]", fake.posts[0])
@@ -557,7 +557,7 @@ def kinds(fake):
return [p[0] for p in fake.posts] # "api" = REST POST, "pr" = gh pr edit
def test_rest_reply_listing_copilot_needs_no_fallback(self):
- rc, out, fake, _ = go_sr(PY, self.limited(PY), "--timeout", "2m", start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, self.limited(PY), "--timeout", "2m", start=T0 + 360)
self.assertEqual(self.kinds(fake), ["api"])
self.assertNotIn(TIMELINE % PY, fake.gets) # (a) is enough: no re-read
self.assertIn("ACTION: requested Copilot review (REST", out)
@@ -568,7 +568,7 @@ def test_rest_reply_without_copilot_but_timeline_event_needs_no_fallback(self):
table = self.limited(PY)
table["POST"] = NOBODY_ADDED
table[TIMELINE % PY] = [requested_event(iso(T0 + 361))]
- rc, out, fake, _ = go_sr(PY, table, "--timeout", "2m", start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, "--timeout", "2m", start=T0 + 360)
self.assertEqual(self.kinds(fake), ["api"])
self.assertIn("ACTION: requested Copilot review (REST", out)
@@ -578,14 +578,14 @@ def test_a_request_removed_afterwards_is_not_confirmed(self):
table["POST"] = NOBODY_ADDED
removed = {**requested_event(iso(T0 + 362)), "event": "review_request_removed"}
table[TIMELINE % PY] = [requested_event(iso(T0 + 361)), removed]
- rc, out, fake, _ = go_sr(PY, table, "--timeout", "2m", start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, "--timeout", "2m", start=T0 + 360)
self.assertIn("pr", self.kinds(fake)) # not confirmed: the one GraphQL fallback ran
def test_rest_reply_without_copilot_but_requested_on_reread_needs_no_fallback(self):
table = self.limited(PY)
table["POST"] = NOBODY_ADDED
- table["repos/%s/pulls/7" % PY] = Seq(pr(), pr(), pr(requested=["Copilot"]), pr()) # pr() #2: the head re-read just before the request
- rc, out, fake, _ = go_sr(PY, table, "--timeout", "2m", start=T0 + 360)
+ table["repos/%s/pulls/7" % PY] = Seq(pr(), pr(requested=["Copilot"]), pr())
+ rc, out, fake, _ = go_cp(PY, table, "--timeout", "2m", start=T0 + 360)
self.assertEqual(self.kinds(fake), ["api"])
def test_unconfirmed_rest_falls_back_once_then_reverifies(self):
@@ -597,11 +597,11 @@ def test_unconfirmed_rest_falls_back_once_then_reverifies(self):
requested_event(T0_ISO),
requested_event(iso(T0 + 361), who="alice"),
]
- # poll 1, the head re-read, re-read after REST, re-read after gh pr edit, poll 2, then gone.
+ # poll 1, re-read after REST, re-read after gh pr edit, poll 2, then gone.
table["repos/%s/pulls/7" % PY] = Seq(
- pr(), pr(), pr(), pr(requested=["Copilot"]), pr(requested=["Copilot"]), pr()
+ pr(), pr(), pr(requested=["Copilot"]), pr(requested=["Copilot"]), pr()
)
- rc, out, fake, _ = go_sr(PY, table, start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, start=T0 + 360)
self.assertEqual(self.kinds(fake), ["api", "pr"])
self.assertEqual(fake.posts[1][:2], ["pr", "edit"])
self.assertIn("--add-reviewer", fake.posts[1])
@@ -614,10 +614,10 @@ def test_fallback_runs_at_most_once_per_head(self):
table["repos/%s/commits/%s/check-runs?per_page=100" % (PY, SHA)] = checks(
run_("slow", status="in_progress")
)
- table["repos/%s/pulls/7" % PY] = Seq( # pr() #2: the head re-read just before the request
- pr(), pr(), pr(), pr(requested=["Copilot"]), pr()
+ table["repos/%s/pulls/7" % PY] = Seq(
+ pr(), pr(), pr(requested=["Copilot"]), pr()
)
- rc, out, fake, clock = go_sr(PY, table, start=T0 + 360) # runs to --cap
+ rc, out, fake, clock = go_cp(PY, table, start=T0 + 360) # runs to --cap
self.assertTrue(out.rstrip().endswith("VERDICT: ready-capped"))
self.assertGreater(clock.t - T0 - 360, 600)
self.assertEqual(self.kinds(fake).count("pr"), 1)
@@ -625,7 +625,7 @@ def test_fallback_runs_at_most_once_per_head(self):
def test_both_paths_unverified_asks_user(self):
table = self.limited(PY)
table["POST"] = NOBODY_ADDED # and the re-read shows no Copilot either
- rc, out, fake, _ = go_sr(PY, table, start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, start=T0 + 360)
self.assertEqual(self.kinds(fake), ["api", "pr"])
action = [line for line in out.splitlines() if line.startswith("ACTION: Copilot")]
self.assertEqual(len(action), 1, out)
@@ -635,7 +635,7 @@ def test_both_paths_unverified_asks_user(self):
self.assertTrue(out.rstrip().endswith("VERDICT: ask-user"))
def test_both_paths_error_asks_user_with_both_errors(self):
- rc, out, fake, _ = go_sr(PY, self.limited(PY), start=T0 + 360, post_ok=False)
+ rc, out, fake, _ = go_cp(PY, self.limited(PY), start=T0 + 360, post_ok=False)
self.assertEqual(self.kinds(fake), ["api", "pr"])
action = [line for line in out.splitlines() if line.startswith("ACTION: Copilot")]
self.assertEqual(len(action), 1, out)
@@ -645,7 +645,7 @@ def test_both_paths_error_asks_user_with_both_errors(self):
def test_requested_copilot_that_never_appears_is_let_go_after_grace(self):
# POST succeeded but Copilot never shows in requested_reviewers or reviews.
- rc, out, fake, clock = go_sr(PY, self.limited(PY), start=T0 + 360)
+ rc, out, fake, clock = go_cp(PY, self.limited(PY), start=T0 + 360)
self.assertEqual(len(fake.posts), 1)
self.assertEqual(rc, 0)
self.assertTrue(out.rstrip().endswith("VERDICT: ready"))
@@ -653,7 +653,7 @@ def test_requested_copilot_that_never_appears_is_let_go_after_grace(self):
def test_env_listed_actor_is_allowed(self):
table = self.limited(PY, user="helper")
- rc, out, fake, _ = go_sr(
+ rc, out, fake, _ = go_cp(
PY,
table,
"--timeout",
@@ -665,7 +665,7 @@ def test_env_listed_actor_is_allowed(self):
def test_not_allowed_actor_asks(self):
table = self.limited(PY, user="someone")
- rc, out, fake, _ = go_sr(PY, table, start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, start=T0 + 360)
self.assertEqual(rc, 4)
self.assertEqual(fake.posts, [])
self.assertIn(
@@ -676,18 +676,18 @@ def test_not_allowed_actor_asks(self):
self.assertTrue(out.rstrip().endswith("VERDICT: ask-user"))
def test_copilot_ask_mode_asks(self):
- rc, _, fake, _ = go_sr(PY, self.limited(PY), "--copilot", "ask", start=T0 + 360)
+ rc, _, fake, _ = go_cp(PY, self.limited(PY), "--copilot", "ask", start=T0 + 360)
self.assertEqual(rc, 4)
self.assertEqual(fake.posts, [])
def test_data_repo_never_posts_or_asks(self):
- rc, out, fake, _ = go_sr(DATA, self.limited(DATA), start=T0 + 360)
+ rc, out, fake, _ = go_cp(DATA, self.limited(DATA), start=T0 + 360)
self.assertEqual(fake.posts, [])
self.assertNotIn("ACTION:", out)
self.assertEqual(rc, 0)
def test_never_mode(self):
- rc, out, fake, _ = go_sr(
+ rc, out, fake, _ = go_cp(
PY, self.limited(PY), "--copilot", "never", start=T0 + 360
)
self.assertEqual(fake.posts, [])
@@ -695,7 +695,7 @@ def test_never_mode(self):
def test_under_threshold_waits_then_fires(self):
table = self.limited(PY, user="someone")
- rc, out, _, clock = go_sr(PY, table, start=T0 + 60)
+ rc, out, _, clock = go_cp(PY, table, start=T0 + 60)
self.assertEqual(rc, 4)
self.assertGreater(clock.t - T0, 300)
@@ -717,24 +717,20 @@ def test_push_mid_wait_restarts_the_cap_clock(self):
self.assertTrue(out.rstrip().endswith("VERDICT: ready-capped"))
self.assertEqual(clock.t - T0, 14 * 60 + 15 * 60)
- def test_push_mid_wait_needs_a_new_self_review(self):
- # Copilot reviewed the OLD head; after the push both bots are still limited. The
- # self-review named the old head, so 5m after the push (not at once) the rule asks for
- # a self-review of the new one instead of spending Copilot credits on it.
+ def test_push_mid_wait_rearms_the_copilot_rule(self):
+ # Copilot reviewed the OLD head; after the push both bots are still
+ # limited, so the rule must fire again, 5m after the push (not at once).
limited = [comment(CR, CR_LIMITED), comment(SOURCERY, SOURCERY_BUDGET)]
table = routes(PY, checks_=GREEN, comments=limited)
- table["repos/%s/pulls/7" % PY] = Seq( # pr() #2: the head re-read just before the request
- pr(), pr(), pr(requested=["Copilot"]), pr(sha=NEW)
+ table["repos/%s/pulls/7" % PY] = Seq(
+ pr(), pr(requested=["Copilot"]), pr(sha=NEW)
)
table["repos/%s/pulls/7/reviews?per_page=100" % PY] = Seq(
[], [], [review(COPILOT_BOT, iso(T0 + 400), commit_id=SHA)]
)
add_head(table, PY, NEW, GREEN, status(("CodeRabbit", "success")))
- rc, out, fake, clock = go_sr(PY, table, "--timeout", "30m", start=T0 + 360)
- self.assertEqual(fake.post_times, [T0 + 360])
- self.assertEqual(rc, 9)
- self.assertEqual(clock.t, T0 + 480 + 360)
- self.assertIn("--self-reviewed abc123 is not the head def456", out)
+ rc, out, fake, _ = go_cp(PY, table, "--timeout", "30m", start=T0 + 360)
+ self.assertEqual(fake.post_times, [T0 + 360, T0 + 480 + 360])
class Staleness(unittest.TestCase):
@@ -880,8 +876,9 @@ def credits(remaining, entitlement=7000, unlimited=False):
class SelfReviewFirst(unittest.TestCase):
- """Owner rule, 2026-11-26: run the self-review rounds and push their fixes before Copilot is
- requested; Copilot reviews the self-reviewed head as the last gate (sportsdataverse/.github#72)."""
+ """Owner rule, 2026-11-26: two self-review rounds replace Copilot. By default the fallback asks
+ for them (exit 9); --self-reviewed then never requests Copilot. Only an explicit
+ --copilot auto|ask, for a PR that gets no self-review, requests it."""
def limited(self, repo, **kw):
return CopilotRule.limited(self, repo, **kw)
@@ -893,21 +890,23 @@ def test_without_the_flag_no_request_and_no_credit_read(self):
self.assertEqual(fake.posts, [])
self.assertNotIn("copilot_internal/user", fake.gets)
self.assertEqual(rc, 9)
- self.assertIn("--self-reviewed ", out)
+ self.assertIn("--self-reviewed : Copilot is not requested", out)
self.assertTrue(out.rstrip().endswith("VERDICT: self-review-first"))
- def test_ask_mode_also_self_reviews_first(self):
- rc, out, fake, _ = go(PY, self.limited(PY), "--copilot", "ask", start=T0 + 360)
- self.assertEqual(fake.posts, [])
- self.assertEqual(rc, 9)
- self.assertNotIn("ACTION: ask the user", out)
+ def test_the_flag_wins_over_an_explicit_copilot_mode(self):
+ for mode in ("auto", "ask"):
+ rc, out, fake, _ = go(PY, self.limited(PY), "--copilot", mode, "--self-reviewed", SHA, start=T0 + 360)
+ self.assertEqual((rc, fake.posts), (0, []), mode)
+ self.assertNotIn("ACTION: ask the user", out, mode)
- def test_the_flag_on_the_head_requests_copilot(self):
+ def test_the_flag_on_the_head_never_requests_copilot(self):
table = self.limited(PY)
table["copilot_internal/user"] = credits(5000)
- rc, out, fake, _ = go(PY, table, "--self-reviewed", "ABC12", "--timeout", "2m", start=T0 + 360)
- self.assertEqual(len(fake.posts), 1) # a prefix, any case
- self.assertIn("ACTION: requested Copilot review (", out)
+ rc, out, fake, _ = go(PY, table, "--self-reviewed", "ABC12", start=T0 + 360) # a prefix, any case
+ self.assertEqual((rc, fake.posts), (0, []))
+ self.assertNotIn("copilot_internal/user", fake.gets)
+ self.assertIn("self-reviewed head abc123: no Copilot review", out)
+ self.assertTrue(out.rstrip().endswith("VERDICT: ready"))
def test_the_flag_on_another_head_does_not(self):
rc, out, fake, _ = go(PY, self.limited(PY), "--self-reviewed", NEW, start=T0 + 360)
@@ -943,24 +942,35 @@ def test_data_repo_needs_no_flag(self):
self.assertEqual((rc, fake.posts), (0, []))
self.assertTrue(out.rstrip().endswith("VERDICT: ready"))
- def test_refusal_on_the_head_does_not_point_at_copilot(self):
+ def test_a_refusal_on_the_head_still_means_the_self_review(self):
table = self.limited(PY, reviews=[review(COPILOT_BOT, body=COPILOT_NO_QUOTA)])
rc, out, fake, _ = go(PY, table, start=T0 + 360)
- self.assertEqual((rc, fake.posts), (8, []))
- self.assertIn("quota", out)
- self.assertNotIn("--self-reviewed", out)
+ self.assertEqual((rc, fake.posts), (9, []))
- def test_a_push_during_the_copilot_checks_is_not_requested_on(self):
- # Copilot on #73: the gate read the head at the start of the poll; a push during the
- # credit lookup must not get the new, unreviewed head a Copilot request.
+ def test_a_push_after_the_self_review_needs_a_new_one(self):
table = self.limited(PY)
- table["copilot_internal/user"] = credits(5000)
- table["repos/%s/pulls/7" % PY] = Seq(pr(), pr(sha=NEW)) # snapshot, then the re-read
+ table["repos/%s/commits/%s/check-runs?per_page=100" % (PY, SHA)] = checks(
+ run_("slow", status="in_progress")
+ )
+ table["repos/%s/pulls/7" % PY] = Seq(pr(), pr(), pr(sha=NEW)) # two polls on the reviewed head
add_head(table, PY, NEW, GREEN, status(("CodeRabbit", "success")))
- rc, out, fake, _ = go_sr(PY, table, "--timeout", "30m", start=T0 + 360)
- self.assertEqual(fake.posts, [])
- self.assertIn("head moved to def456 during the Copilot checks", out)
- self.assertEqual(rc, 9)
+ rc, out, fake, _ = go(PY, table, "--self-reviewed", SHA, "--timeout", "30m", start=T0 + 360)
+ self.assertEqual((rc, fake.posts), (9, []))
+ self.assertIn("--self-reviewed abc123 is not the head def456", out)
+ self.assertEqual(out.count("self-reviewed head abc123: no Copilot review"), 1) # once per head
+
+ def test_a_stale_flag_rules_copilot_out_even_with_an_explicit_mode(self):
+ # Round 2 on #74: `--copilot auto --self-reviewed ` (the #73 documented line) fell
+ # through to the Copilot request after a push. Any --self-reviewed means the PR gets the rounds.
+ table = self.limited(PY)
+ table["repos/%s/commits/%s/check-runs?per_page=100" % (PY, SHA)] = checks(
+ run_("slow", status="in_progress")
+ )
+ table["repos/%s/pulls/7" % PY] = Seq(pr(), pr(sha=NEW))
+ add_head(table, PY, NEW, GREEN, status(("CodeRabbit", "success")))
+ rc, out, fake, _ = go(PY, table, "--copilot", "auto", "--self-reviewed", SHA, "--timeout", "30m", start=T0 + 360)
+ self.assertEqual((rc, fake.posts), (9, []))
+ self.assertIn("--self-reviewed abc123 is not the head def456", out)
def test_under_the_limit_still_waits_without_the_flag(self):
rc, _, _, clock = go(PY, self.limited(PY), start=T0 + 60)
@@ -982,7 +992,7 @@ def test_quota_refusal_is_not_a_review(self):
def test_low_credits_mean_self_review_not_a_request(self):
table = self.limited(PY)
table["copilot_internal/user"] = credits(171)
- rc, out, fake, _ = go_sr(PY, table, start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, start=T0 + 360)
self.assertEqual(fake.posts, [])
self.assertEqual(rc, 8)
self.assertIn("171 of 7000", out)
@@ -992,7 +1002,7 @@ def test_low_credits_mean_self_review_not_a_request(self):
def test_refusal_already_on_the_head_means_self_review(self):
table = self.limited(PY, reviews=[review(COPILOT_BOT, body=COPILOT_NO_QUOTA)])
- rc, out, fake, _ = go_sr(PY, table, start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, start=T0 + 360)
self.assertEqual(fake.posts, [])
self.assertEqual(rc, 8)
self.assertIn("quota", out)
@@ -1000,14 +1010,14 @@ def test_refusal_already_on_the_head_means_self_review(self):
def test_enough_credits_still_requests(self):
table = self.limited(PY)
table["copilot_internal/user"] = credits(5000)
- rc, out, fake, _ = go_sr(PY, table, "--timeout", "2m", start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, "--timeout", "2m", start=T0 + 360)
self.assertEqual(len(fake.posts), 1)
self.assertIn("ACTION: requested Copilot review (", out)
def test_threshold_is_configurable(self):
table = self.limited(PY)
table["copilot_internal/user"] = credits(5000)
- rc, out, fake, _ = go_sr(PY, table, start=T0 + 360, env={"SDV_COPILOT_MIN_CREDITS": "6000"})
+ rc, out, fake, _ = go_cp(PY, table, start=T0 + 360, env={"SDV_COPILOT_MIN_CREDITS": "6000"})
self.assertEqual(fake.posts, [])
self.assertEqual(rc, 8)
@@ -1019,7 +1029,7 @@ def test_refusal_after_our_request_is_not_ready(self):
table["repos/%s/pulls/7/reviews?per_page=100" % PY] = Seq(
[], [], [review(COPILOT_BOT, at="2026-10-09T08:20:00Z", body=COPILOT_NO_QUOTA)]
)
- rc, out, fake, _ = go_sr(PY, table, start=T0 + 360)
+ rc, out, fake, _ = go_cp(PY, table, start=T0 + 360)
self.assertEqual(len(fake.posts), 1)
self.assertEqual(rc, 8)
self.assertTrue(out.rstrip().endswith("VERDICT: self-review"))
@@ -1028,7 +1038,7 @@ def test_bad_credit_floor_falls_back_to_the_default(self):
for bad in ("lots", "nan"):
table = self.limited(PY)
table["copilot_internal/user"] = credits(171)
- rc, out, fake, _ = go_sr(PY, table, start=T0 + 360, env={"SDV_COPILOT_MIN_CREDITS": bad})
+ rc, out, fake, _ = go_cp(PY, table, start=T0 + 360, env={"SDV_COPILOT_MIN_CREDITS": bad})
self.assertEqual(rc, 8, bad)
self.assertEqual(fake.posts, [], bad)