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
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ heads. Use a [stack](#stacked-pull-requests) when B needs code from A to work.
2. From the checked-out PR branch, use the maintainer account to post a
single-line command. Automatic admission handles that account's PRs from
branches in this repository. You can request several independent PRs
while their scoped checks run.
while their scoped checks run. A Claude Code cloud session's comment
carries a signature it cannot omit; the command counts with exactly that
signature after it, and with no other text.

```sh
head_sha=$(gh pr view --json headRefOid --jq .headRefOid) &&
Expand Down
13 changes: 9 additions & 4 deletions desktop/ci/auto-queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# A pull request is queued when all of these hold:
# - it is open, not a draft, from this repository and from the maintainer;
# - it targets the default branch;
# - the maintainer has requested /queue for the current head since any dequeue;
# - the maintainer has requested /queue for the current head since any dequeue
# (alone in an unedited comment, or followed only by Claude Code's signature);
# - Codex has finished a code review of its current head commit;
# - a security review of that commit was asked for, and Codex's state shows
# none of that commit still running or with findings open;
Expand Down Expand Up @@ -68,9 +69,13 @@ decide() {
comments=''
decision="hold: could not read the comments"; return
fi
local consent removed_at
consent=$(jq -r --arg who "${maintainer}" --arg cmd "/queue ${head}" '
[.[] | select(.login == $who and .type == "User" and .body == $cmd and .created == .updated)
# A Claude Code cloud session posts as the maintainer and cannot post
# without this signature, so the command counts with exactly it appended
# and with nothing else. The maintainer decided that on 2026-12-03.
local consent removed_at signed=$'\n\n---\n_Generated by [Claude Code](https://claude.ai/code)_'
consent=$(jq -r --arg who "${maintainer}" --arg cmd "/queue ${head}" --arg signed "${signed}" '
[.[] | select(.login == $who and .type == "User" and (.body == $cmd or .body == $cmd + $signed)
and .created == .updated)
| .created] | max // empty' <<< "${comments}")
if [ -z "${consent}" ]; then
if jq -e --arg who "${maintainer}" 'any(.[]; .login == $who and (.body | startswith("/queue ")))' <<< "${comments}" >/dev/null; then
Expand Down
21 changes: 21 additions & 0 deletions desktop/ci/test_auto_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,27 @@ def test_only_fresh_exact_head_consent_from_maintainer_can_queue(self):
_, calls = self.decide(removed_at="2026-11-27T11:59:00Z")
self.assertIn("enqueuePullRequest", calls)

def test_the_command_also_counts_with_the_claude_code_signature_and_nothing_else(self):
# Body as GitHub returned it for a comment a cloud session posted on #394.
signed = "\n\n---\n_Generated by [Claude Code](https://claude.ai/code)_"
review = {"user": BOT_USER, "body": summary(HEAD, "completed")}

def request(body, **extra):
return [review, dict({"user": {"login": "maintainer", "type": "User"}, "body": body}, **extra)]
_, calls = self.decide(consent=False, comments=request(f"/queue {HEAD}{signed}"))
self.assertIn("enqueuePullRequest", calls)
for body in (f"/queue {HEAD}{signed}\n", f"/queue {HEAD}\n\nplease", f"/queue {HEAD} {signed}",
f"/queue {'0' * 40}{signed}", f"note\n/queue {HEAD}{signed}",
f"/queue {HEAD}\n\n---\n_Generated by [Claude Code](https://example.com)_"):
with self.subTest(body=body):
_, calls = self.decide(consent=False, comments=request(body))
self.assertNotIn("enqueuePullRequest", calls)
_, calls = self.decide(consent=False, comments=request(f"/queue {HEAD}{signed}", updated_at="2026-11-27T12:01:00Z"))
self.assertNotIn("enqueuePullRequest", calls)
_, calls = self.decide(consent=False, comments=[review, {"user": {"login": "someone", "type": "User"},
"body": f"/queue {HEAD}{signed}"}])
self.assertNotIn("enqueuePullRequest", calls)

def test_a_held_pr_is_removed_from_the_queue_and_reread(self):
for fail in (None, "dequeue"):
out, calls = self.decide(pull={"draft": True}, queued=True, fail=fail)
Expand Down
Loading