mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 03:39:52 +00:00
Expand the agent task queue to cpu/gpu/runtime/shared/qa with deterministic checks
The queue now has three engineering tracks plus shared and qa work. Queue rules move from shell/awk in workflows into a standard-library Python package so they are testable offline: claim decisions (dependencies, cycles, file overlap, area permission), leases renewed only by the holder, reassign and release, acceptance-command approval by hash, pull request ownership/overlap/ stale/verification checks and a machine-readable summary. Workflows apply the decisions with minimal permissions, never put user text in run blocks and never check out pull request code. The sync script fetches the real upstream so interface changes during work are reported. Not yet run on GitHub. Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
This commit is contained in:
1 parent
a89f9d8d06
commit
e35df04069
28 files changed
+1822
-164
No files matched your search
@@ -7,13 +7,31 @@ body:
|
||||
id: area
|
||||
attributes:
|
||||
label: Area
|
||||
description: Which owner area the work belongs to. Shared work needs agreement from both owners before it is claimed.
|
||||
description: "cpu: translation, DBT, PE loading, guest startup, guest memory. gpu: RDNA2, shaders, Metal. runtime: Win32, CRT, C++ runtime, import generation, OS services, platform abstractions. shared: cross-subsystem interfaces. qa: verification, regression, security review."
|
||||
options:
|
||||
- gpu
|
||||
- cpu
|
||||
- gpu
|
||||
- runtime
|
||||
- shared
|
||||
- qa
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: priority
|
||||
attributes:
|
||||
label: Priority
|
||||
options:
|
||||
- critical
|
||||
- high
|
||||
- medium
|
||||
- low
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: interface
|
||||
attributes:
|
||||
label: Interface
|
||||
description: For shared tasks, the interface name and the version or upstream commit it targets. Leave empty otherwise.
|
||||
- type: textarea
|
||||
id: goal
|
||||
attributes:
|
||||
@@ -25,7 +43,7 @@ body:
|
||||
id: files
|
||||
attributes:
|
||||
label: Files
|
||||
description: Paths the task may edit, one per line. Two claimed tasks never share a path.
|
||||
description: Paths the task may edit, one per line: exact paths, directories ending in "/", or globs with * and **. Two claimed tasks never overlap.
|
||||
render: text
|
||||
validations:
|
||||
required: true
|
||||
@@ -33,7 +51,7 @@ body:
|
||||
id: acceptance
|
||||
attributes:
|
||||
label: Acceptance command
|
||||
description: The exact command whose success proves the task is done. It must fail before the change.
|
||||
description: The exact command whose success proves the task is done. It must fail before the change. It is never run automatically; a maintainer must approve it with /approve-acceptance.
|
||||
render: sh
|
||||
validations:
|
||||
required: true
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# GitHub logins allowed to claim agent tasks, one per line.
|
||||
# Repository owners, members and collaborators are always allowed.
|
||||
elforeign
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"lease_hours": 24,
|
||||
"upstream": "ranveersoni98/Xenora",
|
||||
"maintainers": ["ranveersoni98"],
|
||||
"contributors": {
|
||||
"ranveersoni98": ["cpu", "shared", "qa"],
|
||||
"elforeign": ["gpu", "shared", "qa"]
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
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.
|
||||
# Applies queue commands (/claim, /release, /reassign, /progress, /blocked,
|
||||
# /unblock, /approve-acceptance) and audits the queue hourly. Comment and issue
|
||||
# text is only parsed as data by scripts/agent_queue; it is never executed and
|
||||
# never interpolated into a shell. Not yet run on GitHub.
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
@@ -11,83 +12,61 @@ on:
|
||||
- cron: "17 * * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
command:
|
||||
if: github.event_name == 'issue_comment' && !github.event.issue.pull_request
|
||||
runs-on: ubuntu-24.04-arm
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
# One global group: claims are decided one at a time so file-overlap checks cannot race.
|
||||
concurrency:
|
||||
group: agent-claim-${{ github.event.issue.number }}
|
||||
group: agent-queue
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
sparse-checkout: .github/agent-claimers.txt
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Apply command
|
||||
persist-credentials: false
|
||||
- name: Decide and apply
|
||||
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 }}
|
||||
PYTHONPATH: scripts
|
||||
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
|
||||
python3 -m agent_queue event --path "$GITHUB_EVENT_PATH" > "$RUNNER_TEMP/event.json"
|
||||
python3 -m agent_queue gather --repo "$GH_REPO" --no-prs > "$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"
|
||||
|
||||
lapse:
|
||||
audit:
|
||||
if: github.event_name != 'issue_comment'
|
||||
runs-on: ubuntu-24.04-arm
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
concurrency:
|
||||
group: agent-queue
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- name: Return stale claims to the queue
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Lapse stale claims, flag invalid tasks, write summary
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
PYTHONPATH: scripts
|
||||
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
|
||||
python3 -m agent_queue gather --repo "$GH_REPO" > "$RUNNER_TEMP/state.json"
|
||||
python3 -m agent_queue audit --state "$RUNNER_TEMP/state.json" > "$RUNNER_TEMP/actions.json"
|
||||
python3 -m agent_queue apply --repo "$GH_REPO" --actions "$RUNNER_TEMP/actions.json"
|
||||
{
|
||||
echo '## Agent queue summary'
|
||||
echo '```json'
|
||||
python3 -m agent_queue summary --state "$RUNNER_TEMP/state.json" --now "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo '```'
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -0,0 +1,78 @@
|
||||
name: Agent PR checks
|
||||
|
||||
# Checks pull requests against the task queue: linked claimed task, file
|
||||
# ownership, overlap with other open pull requests, and independent
|
||||
# verification. Runs on the base branch only: pull request code is never checked
|
||||
# out or executed; changed files come from the API. Not yet run on GitHub.
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, reopened, edited]
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
check:
|
||||
if: github.event_name == 'pull_request_target'
|
||||
runs-on: ubuntu-24.04-arm
|
||||
permissions:
|
||||
contents: read
|
||||
issues: read
|
||||
pull-requests: read
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Check pull request
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
PYTHONPATH: scripts
|
||||
run: |
|
||||
set -eu
|
||||
python3 -m agent_queue event --path "$GITHUB_EVENT_PATH" > "$RUNNER_TEMP/event.json"
|
||||
number=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["number"])' "$RUNNER_TEMP/event.json")
|
||||
python3 -m agent_queue gather --repo "$GH_REPO" --pr "$number" > "$RUNNER_TEMP/state.json"
|
||||
status=0
|
||||
python3 -m agent_queue pr-check --state "$RUNNER_TEMP/state.json" > "$RUNNER_TEMP/result.json" || status=$?
|
||||
{
|
||||
echo '## Agent PR check'
|
||||
echo '```json'
|
||||
cat "$RUNNER_TEMP/result.json"
|
||||
echo '```'
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
exit "$status"
|
||||
|
||||
verify:
|
||||
if: github.event_name == 'issue_comment' && github.event.issue.pull_request
|
||||
runs-on: ubuntu-24.04-arm
|
||||
# issues: write posts the reply; actions: write re-runs the check after a recorded verification.
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
pull-requests: read
|
||||
actions: write
|
||||
concurrency:
|
||||
group: agent-verify-${{ github.event.issue.number }}
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Record verification and re-run the check
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
PYTHONPATH: scripts
|
||||
run: |
|
||||
set -eu
|
||||
python3 -m agent_queue event --path "$GITHUB_EVENT_PATH" > "$RUNNER_TEMP/event.json"
|
||||
number=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["number"])' "$RUNNER_TEMP/event.json")
|
||||
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"
|
||||
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
|
||||
@@ -41,6 +41,10 @@ jobs:
|
||||
for fixture in x2 x3 x4; do
|
||||
python3 "experiments/x1/fixtures/$fixture.py" --check || exit 1
|
||||
done
|
||||
- name: Test agent task queue
|
||||
run: |
|
||||
PYTHONPATH=scripts python3 -m unittest discover -s tests/agent_queue
|
||||
sh -n scripts/agent-queue.sh scripts/agent-sync.sh
|
||||
- name: Check formatting and lint
|
||||
run: |
|
||||
cargo fmt --all -- --check
|
||||
|
||||
Reference in new issue
Block a user