mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 19:30:43 +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
@@ -4,6 +4,13 @@ name: Agent task claims
|
||||
# /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.
|
||||
#
|
||||
# Both jobs share one concurrency group, so decisions never race. GitHub keeps
|
||||
# at most one pending run per group and cancels the older pending run when a
|
||||
# newer one queues, so a run does not decide only its own comment: `replay`
|
||||
# decides every command of the last lease_hours that has no bot reply yet,
|
||||
# oldest first. The surviving run, or at the latest the hourly audit, answers
|
||||
# the commands of cancelled runs. Comments that do not start with `/` start no run.
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
@@ -16,7 +23,7 @@ permissions: {}
|
||||
|
||||
jobs:
|
||||
command:
|
||||
if: github.event_name == 'issue_comment' && !github.event.issue.pull_request
|
||||
if: github.event_name == 'issue_comment' && !github.event.issue.pull_request && startsWith(github.event.comment.body, '/')
|
||||
runs-on: ubuntu-24.04-arm
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -36,9 +43,8 @@ jobs:
|
||||
PYTHONPATH: scripts
|
||||
run: |
|
||||
set -eu
|
||||
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 gather --repo "$GH_REPO" --no-prs --recent-commands > "$RUNNER_TEMP/state.json"
|
||||
python3 -m agent_queue replay --state "$RUNNER_TEMP/state.json" > "$RUNNER_TEMP/actions.json"
|
||||
python3 -m agent_queue apply --repo "$GH_REPO" --actions "$RUNNER_TEMP/actions.json"
|
||||
|
||||
audit:
|
||||
@@ -54,6 +60,16 @@ jobs:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Decide commands whose runs were cancelled
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
PYTHONPATH: scripts
|
||||
run: |
|
||||
set -eu
|
||||
python3 -m agent_queue gather --repo "$GH_REPO" --no-prs --recent-commands > "$RUNNER_TEMP/commands.json"
|
||||
python3 -m agent_queue replay --state "$RUNNER_TEMP/commands.json" > "$RUNNER_TEMP/replay.json"
|
||||
python3 -m agent_queue apply --repo "$GH_REPO" --actions "$RUNNER_TEMP/replay.json"
|
||||
- name: Lapse stale claims, flag invalid tasks, write summary
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
@@ -4,6 +4,11 @@ name: Agent PR checks
|
||||
# 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.
|
||||
#
|
||||
# Advisory: problems are reported as a warning and in the run summary, but the
|
||||
# check does not fail until a live smoke test and the migration of existing
|
||||
# issues are done (docs/coordination/agent-tasks.md). Only a comment starting
|
||||
# with /verified starts the verify job; ordinary comments start nothing.
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
@@ -43,10 +48,15 @@ jobs:
|
||||
cat "$RUNNER_TEMP/result.json"
|
||||
echo '```'
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
exit "$status"
|
||||
# 1 means problems were found: advisory for now. Anything else is a failure of the check itself.
|
||||
if [ "$status" -eq 1 ]; then
|
||||
echo "::warning title=Agent PR check (advisory)::problems found; see the run summary"
|
||||
elif [ "$status" -ne 0 ]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
verify:
|
||||
if: github.event_name == 'issue_comment' && github.event.issue.pull_request
|
||||
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/verified')
|
||||
runs-on: ubuntu-24.04-arm
|
||||
# issues: write posts the reply; actions: write re-runs the check after a recorded verification.
|
||||
permissions:
|
||||
|
||||
Reference in new issue
Block a user