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
35 changes: 33 additions & 2 deletions .github/cursor-approve/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ def safe_label(label) -> str:
return label if re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9 _.:/+-]{0,49}", label) else ""


# Mirrors cursor-review.yml's clamp on `auto_retry_delay_minutes`; a test pins
# the two equal, since the sentence must not promise a wait longer than the
# one the workflow will actually take.
RETRY_DELAY_CAP = 30


def relabel(label=DEFAULT_REVIEW_LABEL) -> str:
name = safe_label(label)
return f"remove and re-add the `{name}` label" if name else "remove and re-add the review label"
Expand All @@ -181,16 +187,41 @@ def next_push_text(label=DEFAULT_REVIEW_LABEL) -> str:
f"skips a head that already carries a review — then re-run the round: {relabel(label)}.")


def next_auto_retry_text(label=DEFAULT_REVIEW_LABEL) -> str:
def retry_delay_phrase(delay_minutes=0) -> str:
"""" in about N minutes", or "" — the advance notice for a delayed retry.

Sanitised here as well as in the workflow that clamps the input, because
this text is posted as the approver: the value arrives as a caller input,
and only a small integer may reach the sentence. Out of range or
unparsable reads as no delay, matching what the workflow would then wait.
"""
try:
mins = int(str(delay_minutes).strip())
except (TypeError, ValueError):
return ""
if mins < 1:
return ""
mins = min(mins, RETRY_DELAY_CAP)
return f" in about {mins} minute{'s' if mins != 1 else ''}"


def next_auto_retry_text(label=DEFAULT_REVIEW_LABEL, delay_minutes=0) -> str:
"""The relabel the workflow is doing itself (BE-19526).

Still ``NEXT_RELABEL``: the next step IS a relabel, and an agent reading the
contract marker should wait for the new round either way. Only the prose
differs, so nobody re-does by hand what already fired. Written before the
relabel runs (a later job; it can fail or be cancelled by a push), hence the
"if no new round starts" fallback rather than a promise.

``delay_minutes`` is the caller's ``auto_retry_delay_minutes``: the wait is
announced BEFORE it starts, which is the point of saying it at all — an
author who reads "being re-run automatically" and sees nothing happen for
five minutes otherwise re-runs it by hand. Zero (every caller that has not
set it) leaves the sentence exactly as it was.
"""
return (f"Nothing — the round is being re-run automatically ({relabel(label)}). Once only; "
return (f"Nothing — the round is being re-run automatically{retry_delay_phrase(delay_minutes)} "
f"({relabel(label)}). Once only; "
"if no new round starts, or it is wrong again, re-run it by hand.")


Expand Down
2 changes: 2 additions & 0 deletions .github/cursor-review/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ All optional except `workflows_ref` (required, no default) — pass them under
| `defer_approval` | `false` | For a caller that runs cursor-approve after this workflow: an APPROVE outcome still reports `approve_gate` = `pass` but posts no approval and resolves no thread, and withdraws the approver's own earlier auto-approvals and requests for changes, so cursor-approve's decide is the only approver. Pass the workflow's `approve_scope_effective` output (the scope `decide` actually gated under, `full` on any fallback) to cursor-approve's `approve_scope`, so its resolution honours non-gating marks only after a `delta` round. |
| `approve_max_failed_reviewers` | `0` | Errored panel reviewers (status `error`) auto-approve tolerates before withholding its decision. `0` → any reviewer that did not complete means no decision. Never tolerates another status, more than N, or a review type with no completed reviewer; tolerated cells are named in the decision. |
| `rereview_command` | `''` (off) | A comment command, e.g. `/review`, asking for another round on the **same commit**. Empty leaves the same-commit dedupe absolute. Needs the SAME value on [`cursor-review-auto-label.yml`](../../docs/callers/cursor-review-auto-label.md) plus `issue_comment` in that caller's triggers: that half re-applies the label (removing it first, since adding a label already present raises no event), this half stops the dedupe from skipping the round it starts. Setting one alone is a silent no-op. The command must be the first token of the first line, and the commenter's association must be `OWNER`, `MEMBER` or `COLLABORATOR` — not the opted-in roster. The request must postdate the review it overrides, so one request buys one round; `max_rounds` still applies. Exists because the documented alternative cannot work: the consolidated review is `COMMENTED`, which GitHub will not dismiss. See [the setup guide](../../docs/callers/cursor-review.md#asking-for-another-round-on-the-same-commit). |
| `auto_retry_errored_rounds` | `false` | Opt-in: re-run a round the PANEL broke (reviewer cells `error`) rather than leaving a standing block for a human to relabel. Bounded by the same one-per-PR budget as the moved-head retry (`AUTO_RETRY_MARKER` on decide's own block), by `max_rounds`, and by `can_relabel`. Never fires for a structural cause or for findings above the threshold. Its force signal at the gate is that marked block — decide's own shape, not dismissed, newer (by review id) than the newest consolidated review for this commit, and authored by a Bot or by the identity that applied the label (the APPROVER_TOKEN case) — NOT the `rereview_command` comment path, which stays authorized by comment association alone. No effect without `approve_max_severity`. |
| `auto_retry_delay_minutes` | `0` | Minutes an automatic retry waits before relabelling (`0` = immediately, the prior behaviour). Clamped to 30 in the workflow and again in `card.py`'s sentence, so the card cannot promise a longer wait than the one taken; unparsable → no wait. Costs runner-minutes while it sleeps. No effect without `approve_max_severity` and `auto_retry_errored_rounds` (or a moved-head retry). |
| `max_rounds` | `5` | Per-PR review-round cap; `0` → none. Counts the posting identity's consolidated reviews since `needs-human-review` was last removed; at or over the cap the panel is skipped, the PR is labelled `needs-human-review`, one comment lists the latest round's open findings above the threshold, and the `approve_gate` output is `capped`. Fails open on a read error. See [the setup guide](../../docs/callers/cursor-review.md#round-cap-and-the-approve_gate-output). |
| `runs_on` | `'"ubuntu-latest"'` | JSON-encoded `runs-on` (same shape as `cursor-review-auto-label.yml`'s) for the four credential-free heavy jobs only: `diff-size`, `preflight`, the `review` panel and `consolidate`. The gate, ledger, Slack notices and every job holding the App token or `pull-requests: write` stay on GitHub-hosted `ubuntu-latest`. Those four run models with unsandboxed shell over PR code, so use a self-hosted pool only if each job gets a fresh pod (fresh filesystem and `$HOME`), holds no cloud identity or token, and can't reach private networks or the metadata server. The image must be linux/x64 with bash, git, curl, jq, python3, gh, tar and GNU coreutils. |

Expand Down
Loading
Loading