mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 23:30:44 +00:00
agent queue: start runs only for commands and replay cancelled claims
Every pull request comment started the verify job, which gathered state and re-ran the pull request check, so ordinary review discussion re-ran verification. Gate the verify job on comments that start with /verified and the claim job on comments that start with /. Claim runs share one concurrency group with cancel-in-progress: false. GitHub keeps one waiting run per group and cancels it when a newer run queues, so with the run deciding only its own comment, a /claim posted while another claim was being decided could be dropped without a reply. Each run now replays every command of the last lease_hours that has no bot reply, oldest first, updating labels in memory between commands; the hourly audit does the same, so a cancelled run's command is answered by the run that replaced it at the latest within the hour. Replies carry a done marker that counts only from the Actions bot. The pull request check is advisory until a live smoke test and the migration of existing issues: problems are a warning and the job passes. Tests model the concurrency group (the old event-only design loses the cancelled claim; replay answers all four commands), in-order overlap decisions, bot-only markers and the workflow triggers. Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
This commit is contained in:
1 parent
98bbe57471
commit
e37c8566c6
10 files changed
+302
-16
No files matched your search
@@ -27,6 +27,14 @@ def comments(repo, n):
|
||||
return ndjson(gh("api", "repos/%s/issues/%d/comments" % (repo, n), "--paginate", "--jq", jq))
|
||||
|
||||
|
||||
def recent_comments(repo, since):
|
||||
"""Issue and pull request comments updated since `since` (UTC ISO time), oldest first."""
|
||||
jq = ('.[] | {id: .id, user: .user.login, body: .body, created_at: .created_at, '
|
||||
'issue: (.issue_url | split("/") | last | tonumber), pull_request: (.html_url | test("/pull/"))}')
|
||||
return ndjson(gh("api", "repos/%s/issues/comments?sort=created&direction=asc&per_page=100&since=%s" % (repo, since),
|
||||
"--paginate", "--jq", jq))
|
||||
|
||||
|
||||
def open_issues(repo):
|
||||
return json.loads(gh("issue", "list", "-R", repo, "--state", "open", "--limit", "500",
|
||||
"--json", "number,title,body,state,labels"))
|
||||
@@ -46,8 +54,9 @@ def open_prs(repo):
|
||||
return [pr_data(repo, n) for n in nums]
|
||||
|
||||
|
||||
def gather(repo, with_prs=True, with_comments=True):
|
||||
"""State for decide/audit/summary: open tasks plus any dependency issues they name."""
|
||||
def gather(repo, with_prs=True, with_comments=True, recent_since=""):
|
||||
"""State for decide/audit/summary/replay: open tasks plus any dependency issues they name and,
|
||||
with `recent_since`, every comment since then."""
|
||||
from .tasks import parse_task
|
||||
issues = {i["number"]: i for i in open_issues(repo)}
|
||||
for i in list(issues.values()):
|
||||
@@ -60,6 +69,8 @@ def gather(repo, with_prs=True, with_comments=True):
|
||||
if any((l["name"] if isinstance(l, dict) else l) == "agent:claimed" for l in i["labels"])}
|
||||
if with_prs:
|
||||
state["prs"] = open_prs(repo)
|
||||
if recent_since:
|
||||
state["recent_comments"] = recent_comments(repo, recent_since)
|
||||
return state
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user