diff --git a/.github/workflows/agent-pr-checks.yml b/.github/workflows/agent-pr-checks.yml
index 76d2809..50c768b 100644
--- a/.github/workflows/agent-pr-checks.yml
+++ b/.github/workflows/agent-pr-checks.yml
@@ -58,12 +58,11 @@ jobs:
verify:
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/verified')
runs-on: ubuntu-24.04-arm
- # issues: write posts the reply; actions: write re-runs the check after a recorded verification.
+ # issues: write posts the reply.
permissions:
contents: read
issues: write
pull-requests: read
- actions: write
concurrency:
group: agent-verify-${{ github.event.issue.number }}
cancel-in-progress: false
@@ -71,7 +70,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- - name: Record verification and re-run the check
+ - name: Record verification and check again
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
@@ -83,9 +82,21 @@ jobs:
python3 -m agent_queue gather --repo "$GH_REPO" --pr "$number" > "$RUNNER_TEMP/state.json"
python3 -m agent_queue decide --event "$RUNNER_TEMP/event.json" --state "$RUNNER_TEMP/state.json" > "$RUNNER_TEMP/actions.json"
python3 -m agent_queue apply --repo "$GH_REPO" --actions "$RUNNER_TEMP/actions.json"
- # Re-run only after an accepted verification of the current head: refused, stale,
+ # Check again only after an accepted verification of the current head: refused, stale,
# malformed or unauthorized /verified comments get a reply and nothing else.
if ! python3 -m agent_queue should-rerun --actions "$RUNNER_TEMP/actions.json"; then exit 0; fi
- sha=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["pr"]["head_sha"])' "$RUNNER_TEMP/state.json")
- run=$(gh run list --workflow agent-pr-checks.yml --commit "$sha" --event pull_request_target --limit 1 --json databaseId -q '.[0].databaseId // empty')
- if [ -n "$run" ]; then gh run rerun "$run" || true; fi
+ # pull_request_target runs are recorded against the base branch, not the pull request
+ # head, so the earlier check run cannot be found by head SHA. Evaluate the same check here.
+ status=0
+ python3 -m agent_queue pr-check --state "$RUNNER_TEMP/state.json" > "$RUNNER_TEMP/result.json" || status=$?
+ {
+ echo '## Agent PR check after verification'
+ echo '```json'
+ cat "$RUNNER_TEMP/result.json"
+ echo '```'
+ } >> "$GITHUB_STEP_SUMMARY"
+ if [ "$status" -eq 1 ]; then
+ echo "::warning title=Agent PR check (advisory)::problems found; see the run summary"
+ elif [ "$status" -ne 0 ]; then
+ exit "$status"
+ fi
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e4d72cc..f73573a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,7 +11,7 @@ remains unsupported.
### Added
-- Added an agent task queue for the cpu, gpu, runtime, shared and qa areas: an *Agent task* issue form with priority and interface fields, a workflow that decides `/claim`, `/release`, `/reassign`, `/progress`, `/blocked`, `/unblock` and `/approve-acceptance` comments one at a time (dependency, cycle and file-overlap checks, 24-hour leases renewed by progress), a pull request check (linked claimed task, file ownership, overlap with other pull requests, independent `/verified
`), `scripts/agent-queue.sh` and `scripts/agent-sync.sh` (upstream fetch every 12 minutes, task branches in separate worktrees) and a machine-readable queue summary. The rules are standard-library Python in `scripts/agent_queue/` with unit tests in `tests/agent_queue/`; issue text is never executed and acceptance commands need maintainer approval. Only comments that start with a command start a run, so ordinary pull request comments never re-run verification, and each claim run decides every unanswered command in order, so commands whose pending runs GitHub cancelled are still answered. See `docs/coordination/agent-tasks.md`. Unit tests pass locally; the workflows have not run on GitHub yet, and the pull request check stays advisory (it never blocks a merge) until a live smoke test and the migration of existing issues are done.
+- Added an agent task queue for the cpu, gpu, runtime, shared and qa areas: an *Agent task* issue form with priority and interface fields, a workflow that decides `/claim`, `/release`, `/reassign`, `/progress`, `/blocked`, `/unblock` and `/approve-acceptance` comments one at a time (dependency, cycle and file-overlap checks, 24-hour leases renewed by progress), a pull request check (linked claimed task, file ownership, overlap with other pull requests, independent `/verified `), `scripts/agent-queue.sh` and `scripts/agent-sync.sh` (upstream fetch every 12 minutes, task branches in separate worktrees) and a machine-readable queue summary. The rules are standard-library Python in `scripts/agent_queue/` with unit tests in `tests/agent_queue/`; issue text is never executed and acceptance commands need maintainer approval. Only comments that start with a command start a job, so ordinary pull request comments never re-run verification, and only an accepted `/verified ` evaluates the check again; and each claim run decides every unanswered command in order, so commands whose pending runs GitHub cancelled are still answered. See `docs/coordination/agent-tasks.md`. Unit tests pass locally; the workflows have not run on GitHub yet, and the pull request check stays advisory (it never blocks a merge) until a live smoke test and the migration of existing issues are done.
- Added explicit claim-before-work rules for contributors and coding agents to `AGENTS.md`, `CONTRIBUTING.md` and the pull request template: check for existing claims, claim with `/claim`, keep a 24-hour lease alive with `/progress`, `/release` when stopping, and link the claimed issue. Without the claim workflow, the earliest valid claim comment wins.
- Added CPU block decoders for BC2, BC3, BC4 and BC5 (UNORM and SNORM) in `xenora-texture`, with tests whose expected texels were derived by hand from the Microsoft and Khronos block-compression specifications. Interpolated values truncate toward zero, as the existing BC1 decoder does; GPU upload and sampling of these formats are not implemented yet.
- Added `dbt::tests::sib_store_executes_through_the_native_dbt`, an independent DBT execution
diff --git a/docs/coordination/agent-tasks.md b/docs/coordination/agent-tasks.md
index ad2e779..1bc5eb8 100644
--- a/docs/coordination/agent-tasks.md
+++ b/docs/coordination/agent-tasks.md
@@ -52,7 +52,9 @@ done
GitHub keeps at most one waiting run in a concurrency group and cancels it when a newer one
queues, so each run decides every command of the last `lease_hours` that has no bot reply yet,
oldest first; a comment listed twice is decided once. A command whose own run was cancelled is answered by the run that replaced it, or at
- the latest by the hourly audit. Each reply carries a marker naming the comment it answers.
+ the latest by the hourly audit. Each reply carries a marker naming the comment it answers. A
+ command left unanswered for more than `lease_hours` (the workflow did not run) gets a "Not
+ decided" reply instead and must be posted again; one older than twice that is no longer read.
4. `scripts/agent-queue.sh start ` creates branch `task/-` from `upstream/main` in a
separate worktree `../xenora-task-` (`--here` uses the current clean checkout instead).
5. Keep the lease alive with `scripts/agent-queue.sh progress "what changed"`. A claim lapses
@@ -60,13 +62,13 @@ done
linked pull request. Other people's comments never renew it. A lapsed task returns to the queue.
6. Open the pull request with `Closes #` and a DCO sign-off (`git commit -s`).
7. A different person (not the author, not the task holder) who is a maintainer or has `qa`
- comments `/verified ` after running the acceptance command. A new push changes the
+ comments `/verified ` after running the acceptance command. A new push changes the
head and invalidates the verification.
## Commands (issue comments)
A command must start the comment. Comments that do not start with `/` (on an issue) or with
-`/verified` (on a pull request) start no workflow run.
+`/verified` (on a pull request) start no job: GitHub records a skipped run and nothing else happens.
| Command | Who | Effect |
| --- | --- | --- |
@@ -76,7 +78,7 @@ A command must start the comment. Comments that do not start with `/` (on an iss
| `/progress ` | holder | Renew the lease (text required) |
| `/blocked `, `/unblock` | holder or maintainer | Set or clear `agent:blocked` |
| `/approve-acceptance` | maintainer | Authorise the acceptance command as currently written |
-| `/verified ` (on a pull request) | maintainer or `qa`, not author, not holder | Independent verification of the current head |
+| `/verified <40-character sha>` (on a pull request) | maintainer or `qa`, not author, not holder | Independent verification of the current head |
Labels: `area:`, `priority:`, `agent:ready|claimed|blocked|invalid|conflict`,
`claimed-by:`. An hourly audit lapses stale claims, marks tasks with missing dependencies or
@@ -89,9 +91,12 @@ machine-readable summary (counts and lists per area, priority and state).
`agent-pr-checks` fails a pull request when: it has no `Closes #N` for a claimed task; the task is held
by someone else; it changes files outside the task's patterns; it changes a file that another open
pull request also changes; the claim has lapsed without a push; or no eligible `/verified ` exists. After an accepted `/verified` (an eligible verifier, the current head) the check is re-run
-automatically. Refused, stale, malformed or unauthorized `/verified` comments get a reply and
-nothing else, and other pull request comments start no run.
+head sha>` exists. The SHA must be the full 40 characters and the only argument: a commit with the
+same short prefix is cheap to make. After an accepted `/verified` (an eligible verifier, the current
+head) the verify job evaluates the same check again and writes it to its run summary; the earlier
+check run is not re-run, since `pull_request_target` runs are recorded against the base branch and
+cannot be found by the pull request head. Refused, stale, malformed or unauthorized `/verified`
+comments get a reply and nothing else, and other pull request comments start no job.
The check is advisory for now: a failure is shown as a warning and in the run summary, and the job
still succeeds. It becomes blocking (fail on problems, then a required check) only after a live smoke
@@ -120,6 +125,7 @@ sync report that shows upstream touching your files is the signal to re-read the
one only when a maintainer's `/approve-acceptance` marker (posted by the bot) matches a hash of
the current text; editing the issue body invalidates the approval. Read the command before running it.
- Markers (grant, approval, answered command) count only when posted by the Actions bot, so they cannot be forged in a comment.
+ User text that a bot reply echoes (a `/blocked` reason, a login, a file pattern) has its angle brackets and backticks escaped, so a reply cannot carry a marker the user wrote.
- Workflows declare empty top-level permissions and grant each job only what it needs; actions are
pinned by commit SHA. Pull request checks run on the base branch (`pull_request_target`), never
check out or run pull request code and read changed files through the API.
diff --git a/scripts/agent_queue/cli.py b/scripts/agent_queue/cli.py
index 4dc3f5c..c41a646 100644
--- a/scripts/agent_queue/cli.py
+++ b/scripts/agent_queue/cli.py
@@ -35,7 +35,7 @@ def main(argv):
p.add_argument("--now", default="", help="UTC time YYYY-MM-DDTHH:MM:SSZ (tests)")
sub = p.add_subparsers(dest="cmd", required=True)
s = sub.add_parser("gather"); s.add_argument("--repo", required=True); s.add_argument("--no-prs", action="store_true"); s.add_argument("--pr", type=int, default=0)
- s.add_argument("--recent-commands", action="store_true", help="include comments from the last lease_hours for replay")
+ s.add_argument("--recent-commands", action="store_true", help="include comments from the last 2 x lease_hours for replay")
s = sub.add_parser("replay"); s.add_argument("--state", required=True)
s = sub.add_parser("decide"); s.add_argument("--event", required=True); s.add_argument("--state", required=True)
s = sub.add_parser("should-rerun"); s.add_argument("--actions", required=True)
@@ -70,7 +70,7 @@ def main(argv):
elif a.cmd == "gather":
since = ""
if a.recent_commands:
- since = (_now(a.now) - timedelta(hours=cfg["lease_hours"])).strftime("%Y-%m-%dT%H:%M:%SZ")
+ since = (_now(a.now) - timedelta(hours=replay.window_hours(cfg))).strftime("%Y-%m-%dT%H:%M:%SZ")
st = ghio.gather(a.repo, with_prs=not a.no_prs, recent_since=since)
if a.pr:
st["pr"] = ghio.pr_data(a.repo, a.pr)
diff --git a/scripts/agent_queue/decide.py b/scripts/agent_queue/decide.py
index 68c46e3..9a4dd8e 100644
--- a/scripts/agent_queue/decide.py
+++ b/scripts/agent_queue/decide.py
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Comment command decisions. Returns actions as data; the caller applies them."""
+import re
+
from . import config as cfgmod
from . import lease as L
from . import tasks as T
@@ -8,6 +10,12 @@ COMMANDS = ("/claim", "/release", "/reassign", "/progress", "/blocked", "/unbloc
"/approve-acceptance", "/verified")
+def quote(text):
+ """User text echoed in a bot reply. Markers count only from the bot, so the reply must not be able
+ to carry one the user wrote: angle brackets are escaped and code spans are closed."""
+ return str(text).replace("&", "&").replace("<", "<").replace(">", ">").replace("`", "'")
+
+
def parse_command(body):
first = (body or "").strip().split("\n", 1)[0].strip()
parts = first.split(None, 1)
@@ -16,6 +24,19 @@ def parse_command(body):
return parts[0], (parts[1].strip() if len(parts) > 1 else "")
+FULL_SHA = re.compile(r"[0-9a-f]{40}")
+
+
+def verified_sha(body):
+ """The SHA of a well-formed `/verified <40-hex sha>` first line, else "". A short prefix is
+ refused: a pushed commit with the same short prefix is cheap to make."""
+ cmd, arg = parse_command(body)
+ parts = arg.split()
+ if cmd != "/verified" or len(parts) != 1 or not FULL_SHA.fullmatch(parts[0]):
+ return ""
+ return parts[0]
+
+
def _act(issue, add=(), remove=(), comment=""):
return {"issue": issue, "add_labels": list(add), "remove_labels": list(remove), "comment": comment}
@@ -53,7 +74,7 @@ def claim_problem(task, tasks, cfg, actor):
continue
hit = sets_overlap(task["files"], other["files"])
if hit:
- return "file overlap with claimed task #%d (`%s` vs `%s`)." % (other["number"], hit[0], hit[1])
+ return "file overlap with claimed task #%d (`%s` vs `%s`)." % (other["number"], quote(hit[0]), quote(hit[1]))
return ""
@@ -96,7 +117,7 @@ def decide(event, state, cfg):
if not target:
return _reply(n, "Usage: /reassign ")
if not cfgmod.may_work_on(cfg, target, task["area"]):
- return _reply(n, "Reassign refused: %s is not allowed to work on area:%s." % (target, task["area"]))
+ return _reply(n, "Reassign refused: %s is not allowed to work on area:%s." % (quote(target), task["area"]))
if not (set(task["labels"]) & {"agent:claimed", "agent:ready"}):
return _reply(n, "Reassign refused: the task is neither ready nor claimed.")
remove = ["agent:ready"] + (["claimed-by:" + holder] if holder else [])
@@ -115,7 +136,7 @@ def decide(event, state, cfg):
return _reply(n, "Only the holder or a maintainer can mark a task blocked.")
if not arg:
return _reply(n, "Usage: /blocked ")
- return [_act(n, ["agent:blocked"], [], "Blocked by %s: %s" % (actor, arg))]
+ return [_act(n, ["agent:blocked"], [], "Blocked by %s: %s" % (actor, quote(arg)))]
if cmd == "/unblock":
if actor != holder and not maint:
@@ -138,7 +159,7 @@ def _verified(event, state, cfg, arg):
if event.get("kind") != "pr":
return []
pr = state.get("pr") or {}
- sha = arg.split()[0] if arg else ""
+ sha = verified_sha(event.get("body"))
head = pr.get("head_sha", "")
if actor == pr.get("author"):
return _reply(n, "Verification refused: the pull request author cannot verify it.")
@@ -148,8 +169,8 @@ def _verified(event, state, cfg, arg):
return _reply(n, "Verification refused: %s holds the linked task #%d." % (actor, issue))
if not cfgmod.is_verifier(cfg, actor):
return _reply(n, "%s may not verify: only maintainers and qa contributors can." % actor)
- if len(sha) < 7 or not head.startswith(sha):
- return _reply(n, "Verification refused: `%s` is not the current head %s." % (sha or "(none)", head[:12]))
+ if not sha or sha != head:
+ return _reply(n, "Verification refused: `%s` is not the full current head %s." % (quote(sha) or "(none)", head))
# Only an accepted verification of the current head re-runs the pull request check.
return [dict(_act(n, comment="Verification of %s recorded for %s." % (head[:12], actor)), rerun_check=True)]
diff --git a/scripts/agent_queue/prcheck.py b/scripts/agent_queue/prcheck.py
index 7382864..b3eca29 100644
--- a/scripts/agent_queue/prcheck.py
+++ b/scripts/agent_queue/prcheck.py
@@ -3,7 +3,7 @@
from . import config as cfgmod
from . import lease as L
from .patterns import path_matches, patterns_overlap
-from .decide import task_index
+from .decide import task_index, verified_sha
def verified_by(pr, comments, tasks, cfg):
@@ -11,11 +11,8 @@ def verified_by(pr, comments, tasks, cfg):
head, out = pr.get("head_sha", ""), []
holders = {tasks[i]["holder"] for i in L.linked_issues(pr.get("body")) if i in tasks}
for c in comments:
- parts = c["body"].strip().split("\n", 1)[0].split()
- if len(parts) < 2 or parts[0] != "/verified" or len(parts[1]) < 7:
- continue
- who = c["user"]
- if (head.startswith(parts[1]) and who != pr.get("author") and who not in holders
+ sha, who = verified_sha(c["body"]), c["user"]
+ if (sha and sha == head and who != pr.get("author") and who not in holders
and cfgmod.is_verifier(cfg, who) and who not in out):
out.append(who)
return out
@@ -48,5 +45,5 @@ def check_pr(state, cfg, now):
problems.append("overlaps open PR #%d on: %s" % (other["number"], ", ".join(shared[:10])))
ok_by = verified_by(pr, comments, tasks, cfg)
if not ok_by:
- problems.append("independent verification missing: an eligible verifier must comment `/verified %s`" % pr.get("head_sha", "")[:12])
+ problems.append("independent verification missing: an eligible verifier must comment `/verified %s`" % pr.get("head_sha", ""))
return {"pr": pr["number"], "ok": not problems, "problems": problems, "verified_by": ok_by}
diff --git a/scripts/agent_queue/queue.py b/scripts/agent_queue/queue.py
index faedfe4..a7b16f5 100644
--- a/scripts/agent_queue/queue.py
+++ b/scripts/agent_queue/queue.py
@@ -3,7 +3,7 @@
from . import config as cfgmod
from . import lease as L
from . import tasks as T
-from .decide import task_index
+from .decide import quote, task_index
from .patterns import sets_overlap
@@ -50,7 +50,7 @@ def audit(state, cfg, now):
for x, y in ((a, b), (b, a)):
if "agent:conflict" not in x["labels"] and x["number"] not in lapsed_nums:
actions.append({"issue": x["number"], "add_labels": ["agent:conflict"], "remove_labels": [],
- "comment": "File overlap with claimed task #%d (`%s` vs `%s`). A maintainer must resolve it." % (y["number"], hit[0], hit[1])})
+ "comment": "File overlap with claimed task #%d (`%s` vs `%s`). A maintainer must resolve it." % (y["number"], quote(hit[0]), quote(hit[1]))})
for t in sorted(tasks.values(), key=lambda x: x["number"]):
if t["state"] != "OPEN" or "agent:ready" not in t["labels"]:
continue
diff --git a/scripts/agent_queue/replay.py b/scripts/agent_queue/replay.py
index a93e78e..bcdfd84 100644
--- a/scripts/agent_queue/replay.py
+++ b/scripts/agent_queue/replay.py
@@ -11,7 +11,7 @@ import re
from datetime import timedelta
from . import lease as L
-from .decide import decide
+from .decide import decide, parse_command
from .tasks import label_names, parse_time
DONE = re.compile(r"")
@@ -34,18 +34,29 @@ def _apply(state, action):
i["labels"] = [{"name": n} for n in names]
+def window_hours(cfg):
+ """How far back `gather --recent-commands` reads: one lease to decide, one more to expire."""
+ return 2 * cfg["lease_hours"]
+
+
def replay(state, cfg, now, bots=L.BOT):
- """Actions for every unanswered command in state["recent_comments"] created within the lease."""
+ """Actions for every unanswered command in state["recent_comments"]: decided if created within
+ the lease, else answered as expired so that no request goes silently unanswered."""
state = copy.deepcopy(state)
since = now - timedelta(hours=cfg["lease_hours"])
comments = state.get("recent_comments", [])
done = answered(comments, bots)
out = []
for c in sorted(comments, key=lambda c: (parse_time(c["created_at"]), c["id"])):
- if (c.get("pull_request") or c["id"] in done or c["user"] in bots
- or parse_time(c["created_at"]) < since):
+ if c.get("pull_request") or c["id"] in done or c["user"] in bots:
continue
done.add(c["id"]) # a comment listed twice is decided once
+ if parse_time(c["created_at"]) < since:
+ if parse_command(c["body"])[0]:
+ out.append({"issue": c["issue"], "add_labels": [], "remove_labels": [], "comment":
+ "Not decided: no queue run answered this command within %s hours. Post it again if it still applies.\n%s"
+ % (cfg["lease_hours"], done_marker(c["id"]))})
+ continue
actions = decide({"kind": "issue", "number": c["issue"], "actor": c["user"], "body": c["body"]}, state, cfg)
if not actions:
continue
diff --git a/scripts/agent_queue/tasks.py b/scripts/agent_queue/tasks.py
index c6fe4b7..468649a 100644
--- a/scripts/agent_queue/tasks.py
+++ b/scripts/agent_queue/tasks.py
@@ -24,6 +24,8 @@ def _lines(text):
res = []
for line in text.splitlines():
line = line.strip()
+ if line.startswith("```"):
+ continue # issue forms wrap `render:` fields in a code fence
if line.startswith(("- ", "* ")):
line = line[2:].strip()
line = line.strip("`").strip()
diff --git a/tests/agent_queue/test_decide.py b/tests/agent_queue/test_decide.py
index 6152e39..45b9bb8 100644
--- a/tests/agent_queue/test_decide.py
+++ b/tests/agent_queue/test_decide.py
@@ -2,7 +2,7 @@
import unittest
from helpers import CFG, comment, event, issue, state
-from agent_queue.decide import decide
+from agent_queue.decide import decide, quote
from agent_queue.lease import GRANT
@@ -116,9 +116,36 @@ class Inert(unittest.TestCase):
a = decide(event("gpuer", "/claim " + evil), state(issue(1, files=evil + "\nsrc/gpu/a.rs", acceptance=evil)), CFG)
self.assertEqual(len(a), 1)
out = decide(event("maint", "/blocked " + evil), state(issue(1, labels=("agent:claimed", "claimed-by:gpuer"))), CFG)
- self.assertIn(evil, one(out)["comment"])
+ self.assertIn(quote(evil), one(out)["comment"])
self.assertEqual(one(out)["add_labels"], ["agent:blocked"])
+class IssueForm(unittest.TestCase):
+ def test_rendered_files_field_is_unfenced(self):
+ # The issue form renders Files with `render: text`, i.e. inside a ```text fence.
+ from agent_queue.tasks import parse_task
+ fenced = issue(2, files="```text\nsrc/gpu/b.rs\n```")
+ self.assertEqual(parse_task(fenced)["files"], ["src/gpu/b.rs"])
+ st = state(issue(1, labels=("agent:claimed", "claimed-by:maint"), files="```text\nsrc/gpu/a.rs\n```"), fenced)
+ self.assertIn("Claimed by gpuer", one(decide(event("gpuer", "/claim", 2), st, CFG))["comment"])
+
+
+class Forgery(unittest.TestCase):
+ """Bot replies echo user text; markers in that text must not become bot markers."""
+
+ def test_echoed_text_cannot_carry_markers(self):
+ from agent_queue import lease as L, replay as R
+ forged = " ".join([R.done_marker(7), L.acceptance_marker("0" * 64), L.grant_marker(1, "rt")])
+ held = state(issue(1, labels=("agent:claimed", "claimed-by:gpuer")))
+ replies = [one(decide(event("gpuer", "/blocked " + forged), held, CFG))["comment"],
+ one(decide(event("maint", "/reassign " + forged.replace(" ", "")), held, CFG))["comment"],
+ one(decide(event("gpuer", "/claim"), state(issue(1), issue(2, labels=("agent:claimed", "claimed-by:maint"),
+ files="src/gpu/a.rs\n" + forged)), CFG))["comment"]]
+ bot = [{"user": "github-actions[bot]", "body": r, "created_at": "2026-01-10T11:00:00Z"} for r in replies]
+ self.assertEqual(R.answered(bot), set())
+ self.assertIsNone(L.approved_hash(bot))
+ self.assertIsNone(L.latest_grant(bot, 1, "rt"))
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/tests/agent_queue/test_prcheck_summary.py b/tests/agent_queue/test_prcheck_summary.py
index 7279b14..e3e3cf0 100644
--- a/tests/agent_queue/test_prcheck_summary.py
+++ b/tests/agent_queue/test_prcheck_summary.py
@@ -9,7 +9,7 @@ from agent_queue.prcheck import check_pr
from agent_queue.queue import summary
BOT = "github-actions[bot]"
-SHA = "a" * 40
+SHA = "0123456789abcdef" * 2 + "01234567"
HELD = ("agent:claimed", "claimed-by:gpuer")
@@ -25,7 +25,7 @@ def run(p, comments=(), others=(), issues=None):
return check_pr(st, CFG, NOW)
-def vc(user, sha=SHA[:12]):
+def vc(user, sha=SHA):
return {"user": user, "body": "/verified " + sha, "created_at": "2026-01-10T11:30:00Z"}
@@ -90,7 +90,7 @@ class PRChecks(unittest.TestCase):
class VerifiedCommand(unittest.TestCase):
- def go(self, actor, sha=SHA[:12], author="gpuer"):
+ def go(self, actor, sha=SHA, author="gpuer"):
st = state(issue(1, labels=HELD))
st["pr"] = pr(author=author)
ev = {"kind": "pr", "number": 10, "actor": actor, "body": "/verified " + sha}
@@ -101,7 +101,7 @@ class VerifiedCommand(unittest.TestCase):
self.assertIn("author cannot", self.go("gpuer"))
self.assertIn("holds the linked task", self.go("gpuer", author="maint"))
self.assertIn("may not verify", self.go("rt"))
- self.assertIn("not the current head", self.go("qaer", sha="1234567"))
+ self.assertIn("not the full current head", self.go("qaer", sha="1234567"))
class VerifiedRerun(unittest.TestCase):
@@ -113,31 +113,33 @@ class VerifiedRerun(unittest.TestCase):
return rerun_check(decide({"kind": "pr", "number": 10, "actor": actor, "body": text}, st, CFG))
def test_accepted_current_head_reruns(self):
- self.assertTrue(self.rerun("qaer", "/verified " + SHA[:12]))
+ self.assertTrue(self.rerun("qaer", "/verified " + SHA))
self.assertTrue(self.rerun("maint", "/verified " + SHA + "\nran the acceptance command"))
def test_ordinary_comments_do_not_rerun(self):
- for text in ("looks good", "LGTM /verified " + SHA, "", "thanks\n/verified " + SHA[:12]):
+ for text in ("looks good", "LGTM /verified " + SHA, "", "thanks\n/verified " + SHA):
self.assertFalse(self.rerun("qaer", text), text)
def test_malformed_do_not_rerun(self):
- for text in ("/verified", "/verified abc", "/verifiedaaaaaaa", "/verified " + SHA[:6], "/Verified " + SHA[:12]):
+ for text in ("/verified", "/verified abc", "/verified" + SHA, "/verified " + SHA[:12], "/verified " + SHA[:6],
+ "/Verified " + SHA, "/verified " + SHA.upper(), "/verified " + SHA + " " + SHA, "/verified " + SHA + "0"):
self.assertFalse(self.rerun("qaer", text), text)
def test_stale_and_unknown_heads_do_not_rerun(self):
- self.assertFalse(self.rerun("qaer", "/verified " + "b" * 12))
- self.assertFalse(self.rerun("qaer", "/verified " + SHA[:11] + "b"))
+ self.assertFalse(self.rerun("qaer", "/verified " + "b" * 40))
+ # Same 12-character prefix, different commit: a short prefix is cheap to collide.
+ self.assertFalse(self.rerun("qaer", "/verified " + SHA[:12] + "f" * 28))
def test_unauthorized_do_not_rerun(self):
- self.assertFalse(self.rerun("gpuer", "/verified " + SHA[:12])) # author
- self.assertFalse(self.rerun("gpuer", "/verified " + SHA[:12], author="maint")) # task holder
- self.assertFalse(self.rerun("rt", "/verified " + SHA[:12])) # not a verifier
- self.assertFalse(self.rerun("stranger", "/verified " + SHA[:12]))
+ self.assertFalse(self.rerun("gpuer", "/verified " + SHA)) # author
+ self.assertFalse(self.rerun("gpuer", "/verified " + SHA, author="maint")) # task holder
+ self.assertFalse(self.rerun("rt", "/verified " + SHA)) # not a verifier
+ self.assertFalse(self.rerun("stranger", "/verified " + SHA))
def test_rerun_agrees_with_the_check(self):
# Whatever re-runs the check must also be counted by it, and the other way round.
for actor in ("qaer", "maint", "gpuer", "rt"):
- for sha in (SHA[:12], SHA[:6], "b" * 12):
+ for sha in (SHA, SHA[:12], "b" * 40):
counted = actor in run(pr(), [vc(actor, sha)])["verified_by"]
self.assertEqual(self.rerun(actor, "/verified " + sha), counted, (actor, sha))
diff --git a/tests/agent_queue/test_replay.py b/tests/agent_queue/test_replay.py
index 12667b3..24ce652 100644
--- a/tests/agent_queue/test_replay.py
+++ b/tests/agent_queue/test_replay.py
@@ -136,9 +136,17 @@ class Replay(unittest.TestCase):
cmd(1, "gpuer", "looks good to me", 1),
cmd(2, "gpuer", "/claim", 1, pr=True),
cmd(3, "maint", "/verified abcdef1", 1),
- cmd(4, "gpuer", "/claim", 1, "2026-01-09T11:00:00Z"), # older than lease_hours
]), [])
+ def test_commands_older_than_the_lease_are_answered_as_expired(self):
+ actions = self.run_replay([cmd(4, "gpuer", "/claim", 1, "2026-01-09T11:00:00Z"),
+ cmd(5, "gpuer", "just a remark", 1, "2026-01-09T11:00:00Z")])
+ self.assertEqual(len(actions), 1)
+ self.assertEqual((actions[0]["issue"], actions[0]["add_labels"]), (1, []))
+ self.assertIn("Not decided", actions[0]["comment"])
+ self.assertIn(R.done_marker(4), actions[0]["comment"])
+ self.assertEqual(R.window_hours(CFG), 48)
+
def test_state_is_not_modified(self):
st = queue_state([cmd(1, "gpuer", "/claim", 1)])
before = copy.deepcopy(st)
diff --git a/tests/agent_queue/test_workflows_cli.py b/tests/agent_queue/test_workflows_cli.py
index 8f9e87c..40e9bc0 100644
--- a/tests/agent_queue/test_workflows_cli.py
+++ b/tests/agent_queue/test_workflows_cli.py
@@ -89,9 +89,12 @@ class Workflows(unittest.TestCase):
def test_rerun_needs_an_accepted_verification(self):
text = self.job("agent-pr-checks.yml", "verify")
- gate = text.index("agent_queue should-rerun")
- self.assertLess(gate, text.index("gh run rerun"))
self.assertIn('if ! python3 -m agent_queue should-rerun --actions "$RUNNER_TEMP/actions.json"; then exit 0; fi', text)
+ self.assertLess(text.index("agent_queue should-rerun"), text.index("agent_queue pr-check"))
+ # The check is evaluated in this job: pull_request_target runs cannot be found by head SHA.
+ self.assertNotIn("gh run", text)
+ self.assertNotIn("actions: write", text)
+ self.assertIn("::warning title=Agent PR check (advisory)::", text)
def test_should_rerun_exit_codes(self):
with tempfile.TemporaryDirectory() as d: