coordination: add GitHub issue task queue for parallel agents

CPU and GPU work proceed in parallel, largely through coding agents.
Tasks posted as issues with owned file lists and an acceptance command
can be claimed through a serialised workflow, so work is picked up
without relaying prompts by hand and two claims never edit one file.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
This commit is contained in:
elforeign committed 2026-11-23 23:58:25 -06:00
1 parent 93bd04c70f
commit a89f9d8d06
7 files changed
+297

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
name: Agent task
description: A self-contained work item that a contributor or coding agent can claim with /claim.
title: "task: "
labels: [agent:ready]
body:
- type: dropdown
id: area
attributes:
label: Area
description: Which owner area the work belongs to. Shared work needs agreement from both owners before it is claimed.
options:
- gpu
- cpu
- shared
validations:
required: true
- type: textarea
id: goal
attributes:
label: Goal
description: What must be true when the task is finished, in one or two sentences.
validations:
required: true
- type: textarea
id: files
attributes:
label: Files
description: Paths the task may edit, one per line. Two claimed tasks never share a path.
render: text
validations:
required: true
- type: textarea
id: acceptance
attributes:
label: Acceptance command
description: The exact command whose success proves the task is done. It must fail before the change.
render: sh
validations:
required: true
- type: input
id: depends
attributes:
label: Depends on
description: Issue numbers that must be closed first, for example "#12, #15". Leave empty when none.
- type: textarea
id: context
attributes:
label: Context
description: Specification sections, interface notes and known limits. Public sources only.
+3
View File
@@ -0,0 +1,3 @@
# GitHub logins allowed to claim agent tasks, one per line.
# Repository owners, members and collaborators are always allowed.
elforeign
+93
View File
@@ -0,0 +1,93 @@
name: Agent task claims
# Serialises /claim, /release and /blocked comments on agent task issues and
# returns stale claims to the queue. Only labels and comments change; no code
# from the issue or comment is executed.
on:
issue_comment:
types: [created]
schedule:
- cron: "17 * * * *"
workflow_dispatch:
permissions:
issues: write
jobs:
command:
if: github.event_name == 'issue_comment' && !github.event.issue.pull_request
runs-on: ubuntu-24.04-arm
concurrency:
group: agent-claim-${{ github.event.issue.number }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: .github/agent-claimers.txt
sparse-checkout-cone-mode: false
- name: Apply command
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
ISSUE: ${{ github.event.issue.number }}
BODY: ${{ github.event.comment.body }}
ACTOR: ${{ github.event.comment.user.login }}
ASSOCIATION: ${{ github.event.comment.author_association }}
run: |
set -eu
command=$(printf '%s\n' "$BODY" | head -1 | awk '{print $1}')
case "$command" in /claim|/release|/blocked|/unblock) ;; *) exit 0 ;; esac
allowed=no
case "$ASSOCIATION" in OWNER|MEMBER|COLLABORATOR) allowed=yes ;; esac
if [ -f .github/agent-claimers.txt ] && grep -qx "$ACTOR" .github/agent-claimers.txt; then allowed=yes; fi
if [ "$allowed" != yes ]; then
gh issue comment "$ISSUE" --body "Ignored $command: $ACTOR is not listed in .github/agent-claimers.txt."
exit 0
fi
labels=$(gh issue view "$ISSUE" --json labels -q '.labels[].name')
has() { printf '%s\n' "$labels" | grep -qx "$1"; }
holder=$(printf '%s\n' "$labels" | sed -n 's/^claimed-by:\(.*\)$/\1/p' | head -1)
case "$command" in
/claim)
if ! has agent:ready; then
gh issue comment "$ISSUE" --body "Not claimable: the issue is not labelled agent:ready${holder:+ (held by $holder)}."
exit 0
fi
gh label create "claimed-by:$ACTOR" --color BFD4F2 --force >/dev/null
gh issue edit "$ISSUE" --remove-label agent:ready --add-label agent:claimed --add-label "claimed-by:$ACTOR"
gh issue comment "$ISSUE" --body "Claimed by $ACTOR. The claim lapses after 24 hours without activity on this issue or its pull request."
;;
/release)
if [ "$holder" != "$ACTOR" ] && [ "$ASSOCIATION" != OWNER ]; then
gh issue comment "$ISSUE" --body "Only the holder ($holder) or the repository owner can release this claim."
exit 0
fi
gh issue edit "$ISSUE" --remove-label agent:claimed --remove-label "claimed-by:$holder" --add-label agent:ready
;;
/blocked)
gh issue edit "$ISSUE" --add-label agent:blocked
;;
/unblock)
gh issue edit "$ISSUE" --remove-label agent:blocked
;;
esac
lapse:
if: github.event_name != 'issue_comment'
runs-on: ubuntu-24.04-arm
steps:
- name: Return stale claims to the queue
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -eu
cutoff=$(date -u -d '24 hours ago' +%Y-%m-%dT%H:%M:%SZ)
gh issue list --label agent:claimed --state open --limit 200 \
--json number,updatedAt,labels \
-q ".[] | select(.updatedAt < \"$cutoff\") | select([.labels[].name] | index(\"agent:blocked\") | not) | [.number, ([.labels[].name | select(startswith(\"claimed-by:\"))] | first // \"\")] | @tsv" |
while IFS="$(printf '\t')" read -r number holder; do
gh issue edit "$number" --remove-label agent:claimed ${holder:+--remove-label "$holder"} --add-label agent:ready
gh issue comment "$number" --body "Claim lapsed after 24 hours without activity; the task is back in the queue."
done
+4
View File
@@ -9,6 +9,10 @@ exact revision and known limitations.
Guest execution uses original, purpose-built test programs. Commercial Xbox game execution
remains unsupported.
### Added
- Added an agent task queue: an *Agent task* issue template, a workflow that serialises `/claim`, `/release` and `/blocked` comments and returns claims idle for 24 hours, and `scripts/agent-queue.sh` for listing, claiming and posting tasks. See `docs/coordination/agent-tasks.md`. The workflow has not run on GitHub yet.
## [X18] - Automated Import Compatibility Generation & Metadata Ingestion
Guest execution uses original, purpose-built test programs. Commercial Xbox game execution
+1
View File
@@ -48,3 +48,4 @@ either path. The [changelog](../CHANGELOG.md) records notable changes.
- [Threat model](threat-model.md) and [security reporting](../SECURITY.md) — Execution limits and disclosure instructions.
- [Legal scope](legal.md), [dependency licensing](licenses.md), and [third-party notices](../THIRD_PARTY_NOTICES.md) — Input policy, attribution, and redistribution findings.
- [Contribution guidelines](../CONTRIBUTING.md) — Original authorship, Developer Certificate of Origin sign-off, and evidence requirements.
- [Agent task queue](coordination/agent-tasks.md) — Posting, claiming and finishing work items through GitHub issues so parallel contributors and coding agents do not overlap.
+60
View File
@@ -0,0 +1,60 @@
# Agent task queue
Xenora's CPU and GPU work proceed in parallel, often by coding agents. This page
describes how work is posted, claimed and finished through GitHub issues so that
no person has to relay prompts between agents.
## Lifecycle
1. **Post.** Anyone opens an issue with the *Agent task* template. It names the
owner area (`gpu`, `cpu` or `shared`), the files it may edit, the exact
acceptance command and any issues it depends on. New tasks are labelled
`agent:ready`.
2. **Claim.** An agent comments `/claim`. The *Agent task claims* workflow
processes claims for one issue at a time, so the first claim wins. It
replaces `agent:ready` with `agent:claimed` and `claimed-by:<login>`. A later
claim is refused with a reply.
3. **Work.** The holder works on a branch named after the issue, for example
`task/42-vop2-integer-semantics`, and edits only the listed files. A progress
comment or a linked pull request keeps the claim alive.
4. **Finish.** The pull request says `Closes #42` and reports the acceptance
command's output. Review and merge follow [CONTRIBUTING.md](../../CONTRIBUTING.md);
an author never merges their own pull request.
5. **Lapse.** A claim with no activity for 24 hours returns to `agent:ready`.
`/release` gives a task back early. `/blocked` pauses the lapse timer while a
question is open; `/unblock` resumes it.
Only repository owners, members, collaborators and logins listed in
`.github/agent-claimers.txt` can claim. The workflow changes labels and posts
comments; it never runs text from an issue.
## Rules for posting tasks
- One task, one reviewable change. Split anything that needs more than one
pull request.
- List every file the task may edit. Two open claims never list the same path;
a task that needs a file another claim holds depends on that claim.
- `shared` tasks touch interfaces both owners use (guest memory, loader hooks,
shared Cargo configuration). Agree the interface in the issue before anyone
claims it.
- The acceptance command must fail before the change and pass after it.
- Use public sources only and follow the clean-room rules in
[AGENTS.md](../../AGENTS.md).
## Agent loop
`scripts/agent-queue.sh` wraps the GitHub CLI for agents:
```sh
scripts/agent-queue.sh list gpu # ready tasks in one area
scripts/agent-queue.sh next gpu # first ready task whose dependencies are closed
scripts/agent-queue.sh claim 42 # waits up to two minutes for the workflow's decision
scripts/agent-queue.sh note 42 "Decoder tables regenerated; tests next."
scripts/agent-queue.sh held # tasks you currently hold
scripts/agent-queue.sh release 42
scripts/agent-queue.sh new body.md "task: VOP2 integer semantics"
```
A scheduled agent can run this loop unattended: update `main`, finish or note
progress on held tasks, then claim the next ready task in its area. Agents post
new tasks for anything they find outside their area instead of editing it.
+87
View File
@@ -0,0 +1,87 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-or-later
# Agent task queue helper. See docs/coordination/agent-tasks.md.
set -eu
usage() {
cat >&2 <<'EOF'
usage: scripts/agent-queue.sh list [gpu|cpu|shared] open tasks ready to claim, oldest first
scripts/agent-queue.sh next <area> first ready task in <area> whose dependencies are closed
scripts/agent-queue.sh claim <issue> request the claim (the workflow decides)
scripts/agent-queue.sh held tasks claimed by the current GitHub user
scripts/agent-queue.sh note <issue> <text> progress note; keeps the claim alive
scripts/agent-queue.sh release <issue> give the task back
scripts/agent-queue.sh new <file.md> <title> open a task from a body that follows the template
EOF
exit 2
}
[ $# -ge 1 ] || usage
command=$1
shift
# One line per ready task: number, area, dependency text, title ("|"-separated, oldest first).
ready() {
gh issue list --state open --label agent:ready --limit 200 \
--json number,title,body,createdAt \
-q 'sort_by(.createdAt) | .[] | [.number,
((.body | capture("### Area\\s+(?<a>[a-z]+)").a) // ""),
((.body | capture("### Depends on\\s+(?<d>[^\\n]*)").d) // ""),
.title] | map(tostring) | join("|")'
}
case "$command" in
list)
want=${1:-}
ready | while IFS="|" read -r number area deps title; do
[ -z "$want" ] || [ "$area" = "$want" ] || continue
printf '#%s\t%s\t%s\n' "$number" "$area" "$title"
done
;;
next)
[ $# -eq 1 ] || usage
ready | while IFS="|" read -r number area deps title; do
[ "$area" = "$1" ] || continue
open=no
for dep in $(printf '%s\n' "$deps" | grep -oE '#[0-9]+' | tr -d '#'); do
[ "$(gh issue view "$dep" --json state -q .state)" = CLOSED ] || open=yes
done
[ "$open" = no ] || continue
printf '%s\n' "$number"
break
done
;;
claim)
[ $# -eq 1 ] || usage
gh issue comment "$1" --body /claim >/dev/null
me=$(gh api user -q .login)
for _ in 1 2 3 4 5 6 7 8 9 10 11 12; do
sleep 10
if gh issue view "$1" --json labels -q '.labels[].name' | grep -qx "claimed-by:$me"; then
echo "claimed #$1"
exit 0
fi
done
echo "claim of #$1 not granted; it may be held by someone else" >&2
exit 1
;;
held)
me=$(gh api user -q .login)
gh issue list --state open --label "claimed-by:$me" --json number,title -q '.[] | "#\(.number)\t\(.title)"'
;;
note)
[ $# -eq 2 ] || usage
gh issue comment "$1" --body "$2" >/dev/null
;;
release)
[ $# -eq 1 ] || usage
gh issue comment "$1" --body /release >/dev/null
;;
new)
[ $# -eq 2 ] || usage
gh issue create --label agent:ready --title "$2" --body-file "$1"
;;
*)
usage
;;
esac