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

+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