mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 03:39:52 +00:00
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:
1 parent
93bd04c70f
commit
a89f9d8d06
7 files changed
+297
No files matched your search
@@ -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.
|
||||
@@ -0,0 +1,3 @@
|
||||
# GitHub logins allowed to claim agent tasks, one per line.
|
||||
# Repository owners, members and collaborators are always allowed.
|
||||
elforeign
|
||||
@@ -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
|
||||
Reference in new issue
Block a user