Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/issue-decompose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ jobs:
# A request, never a record: cleared on every path, the refusal included.
- name: Clear the request label
if: always()
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
NUM: ${{ github.event.issue.number }}
run: gh api -X DELETE "/repos/$REPO/issues/$NUM/labels/agent:decompose" >/dev/null 2>&1 || true
uses: dodi-smart/.github/actions/clear-request-label@v1
with:
number: ${{ github.event.issue.number }}
label: agent:decompose
22 changes: 18 additions & 4 deletions .github/workflows/issue-implement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ jobs:
run: |
set -euo pipefail
# Request labels self-clear on every stop, so a stopped request never
# looks like work in flight (or holds the dispatcher's WIP slot).
clear_request() { gh issue edit "$NUM" --repo "$REPO" --remove-label 'agent:implement' 2>/dev/null || true; }
# looks like work in flight (or holds the dispatcher's WIP slot). The
# next step removes it when this one says so.
clear_request() { echo "clear=true" >> "$GITHUB_OUTPUT"; }
if [ "$PROCEED" != "true" ]; then
echo "proceed=false" >> "$GITHUB_OUTPUT"
if [ "$EVENT_ACTION" = labeled ] && [ "$LABEL" = agent:implement ]; then clear_request; fi
Expand Down Expand Up @@ -180,6 +181,13 @@ jobs:

echo "proceed=true" >> "$GITHUB_OUTPUT"

- name: Clear the request label
if: steps.check.outputs.clear == 'true'
uses: dodi-smart/.github/actions/clear-request-label@v1
with:
number: ${{ github.event.issue.number }}
label: agent:implement

# The org App token, narrowed to issues. Its login is run-agent's
# allowed-bots when the App asked (the dispatcher); any other bot actor
# stays refused.
Expand Down Expand Up @@ -441,7 +449,7 @@ jobs:
triage-state: Blocked
token: ${{ steps.app-token.outputs.token }}

# Report on the issue, and clear the request label on every path.
# Report on the issue, then clear the request label, on every path.
- if: ${{ always() }}
env:
URL: ${{ steps.open.outputs.url }}
Expand All @@ -464,4 +472,10 @@ jobs:
[ -z "$APP_TOKEN" ] || [ -z "$RECORD" ] || body="$body"$'\n\n'"$RECORD"
GH_TOKEN="${APP_TOKEN:-$GH_TOKEN}" gh issue comment "$NUM" --repo "$REPO" --body "$body" || true
fi
gh issue edit "$NUM" --repo "$REPO" --remove-label 'agent:implement' >/dev/null 2>&1 || true

- name: Clear the request label
if: ${{ always() }}
uses: dodi-smart/.github/actions/clear-request-label@v1
with:
number: ${{ github.event.issue.number }}
label: agent:implement
42 changes: 30 additions & 12 deletions .github/workflows/pr-iterate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ jobs:
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
permissions: contents:write pull-requests:write issues:write

# `agent:iterate` is a request: the stops (land, handoff, give-up) take
# it off, and a relay takes it off so the re-add in `act` emits a fresh
# `labeled` event. Before `act`, which needs the App token too.
- name: Clear the request label
if: contains(fromJSON('["land","handoff","give-up","relay"]'), steps.route.outputs.action) && steps.app-token.outputs.token != ''
uses: dodi-smart/.github/actions/clear-request-label@v1
with:
number: ${{ steps.decide.outputs.number }}
label: agent:iterate
token: ${{ steps.app-token.outputs.token }}

- id: act
if: contains(fromJSON('["ready","review","judge","land","handoff","give-up","relay"]'), steps.route.outputs.action)
env:
Expand All @@ -232,7 +243,6 @@ jobs:
echo "::error title=No App token::GH_APP_CLIENT_ID is not set. A GITHUB_TOKEN label or ready starts no workflow."
exit 1
fi
unlabel() { gh api -X DELETE "/repos/$REPO/issues/$1/labels/agent:iterate" >/dev/null 2>&1 || true; }
say() { gh pr comment "$PR" --repo "$REPO" --body "$1" >/dev/null; }
case "$ACTION" in
ready)
Expand All @@ -247,13 +257,10 @@ jobs:
gh pr edit "$PR" --repo "$REPO" --add-label agent:judge
echo "::notice title=Judge requested::$REASON" ;;
land)
unlabel "$PR"
[ "$MERGED" = true ] || say "**Not merged.** ${NOT_WHY:-the merge gate made no decision}. A person merges." ;;
handoff)
unlabel "$PR"
say "Review approved this head. The issue's fields put it on tier \`$TIER\`, which stops here: a person merges." ;;
give-up)
unlabel "$PR"
say "**Stopping the fix loop.** $REASON. A person takes it from here."
# A cost breaker says so on the issue too, where the budget is
# read. It writes no field: cost never demotes a tier. The stop
Expand All @@ -263,15 +270,23 @@ jobs:
|| echo "::warning title=Issue not told::the cost-cap comment on #$ISSUE failed"
fi ;;
relay)
# A labeled event the agent can run on. The removal starts nothing:
# callers listen to `labeled` only.
unlabel "$PR"
# A labeled event the agent can run on. The removal (the step
# above) starts nothing: callers listen to `labeled` only.
gh pr edit "$PR" --repo "$REPO" --add-label agent:iterate
echo "::notice title=Relayed::$REASON. The fix round runs on the labeled event." ;;
esac

# Each conflicted PR gets its own labeled event, which decides `update`
# under that PR's own concurrency group.
# under that PR's own concurrency group: the label comes off every one
# first, so the re-add below is a fresh `labeled` event.
- name: Clear the request label on the conflicted PRs
if: steps.sweep.outputs.dirty != '' && steps.app-token.outputs.token != ''
uses: dodi-smart/.github/actions/clear-request-label@v1
with:
number: ${{ steps.sweep.outputs.dirty }}
label: agent:iterate
token: ${{ steps.app-token.outputs.token }}

- id: relay-dirty
if: steps.sweep.outputs.dirty != ''
env:
Expand All @@ -284,9 +299,7 @@ jobs:
echo "::error title=No App token::GH_APP_CLIENT_ID is not set. A GITHUB_TOKEN label starts no workflow."
exit 1
fi
unlabel() { gh api -X DELETE "/repos/$REPO/issues/$1/labels/agent:iterate" >/dev/null 2>&1 || true; }
for pr in $DIRTY; do
unlabel "$pr"
gh pr edit "$pr" --repo "$REPO" --add-label agent:iterate
echo "::notice title=Relayed::#$pr conflicts with its base; the update runs on the labeled event."
done
Expand Down Expand Up @@ -409,8 +422,13 @@ jobs:
printf '**Branch not updated:** %s\n\nA person brings it up to date; the loop has stopped (`agent:iterate` removed). [Run log](%s)\n' "$why" "$RUN" > "$RUNNER_TEMP/handoff.md"
[ -z "$APP_TOKEN" ] || [ -z "$RECORD" ] || printf '\n%s\n' "$RECORD" >> "$RUNNER_TEMP/handoff.md"
GH_TOKEN="${APP_TOKEN:-$GH_TOKEN}" gh pr comment "$PR" --repo "$REPO" --body-file "$RUNNER_TEMP/handoff.md" || true
unlabel() { gh api -X DELETE "/repos/$REPO/issues/$1/labels/agent:iterate" >/dev/null 2>&1 || true; }
unlabel "$PR"

- name: Clear the request label
if: ${{ always() && steps.push.outputs.pushed != 'true' }}
uses: dodi-smart/.github/actions/clear-request-label@v1
with:
number: ${{ needs.gate.outputs.number }}
label: agent:iterate

# One fix round. The agent commits; the push step writes the round and
# refuses a holdout edit, a stranger's commit, the cap, or a moved branch.
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -645,16 +645,7 @@ jobs:
# starts no workflow run from GITHUB_TOKEN activity.
- name: Clear the request label
if: always()
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
# Percent-encoded: the colon is part of the label name, not a path
# separator, and it reaches the API as a single segment either way.
if gh api -X DELETE "/repos/$REPO/issues/$PR/labels/agent%3Areview" --silent 2>/dev/null; then
echo "removed agent:review, apply it again to request another pass"
else
echo "agent:review was not on this PR"
fi
uses: dodi-smart/.github/actions/clear-request-label@v1
with:
number: ${{ github.event.pull_request.number }}
label: agent:review
9 changes: 6 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ why, not history.
| `.github/workflows/pr-review.yml` | A bot-authored PR is reviewed only when a bot applied `agent:review` (`actions/request-review`), and only its `scope-trailers` commits when it has any | A dependency PR without automation commits is deps-verify's, and reviewing it too double-posts. What automation wrote on top of another bot's change is what a merge has to trust. |
| `.github/workflows/pr-review.yml` | No `synchronize` trigger | Reviewing every push is what gets a review bot muted, and a muted bot reviews nothing. |
| `.github/workflows/pr-review.yml` | The `gate` job has no checkout: changed files come from `actions/changed-files`, and "docs only" is its `all-matched` | The gate is hosted and needs only the file list, so a full-history clone there was pure cost. Deciding docs-only from `all-matched` keeps the claim positive: a list cut off at the API cap is never docs-only. The `review` job still clones, because the reviewer reads the tree. |
| `actions/clear-request-label/` | Every workflow and action that takes an `agent:*` request label off goes through it; `actions/judge-verdict` calls its `clear.sh` directly, from inside its sweep loop. The label is percent-encoded, a 404 is silent, any other failure is a `::warning` that the request stays on, and the step never fails. Each caller keeps its own `if:` | GitHub emits no `labeled` event for a label already present, so a removal that failed quietly is a request nobody can make again. The hand-written copies had drifted, most to `\|\| true`, which reads a 403 as "the label was not there". When a request ends differs per workflow (on cancel, on a refusal, before a relay), so the condition stays with the caller. A clean-up step that fails would turn a refusal red and bury its message. `test.sh` stubs `gh` for success, 404 and 403, and fails on any request-label removal outside the action. |
| `.github/workflows/deps-verify.yml`, `actions/push-round/` | Verification never merges or approves. Its fix rounds are pushed only by `push-round`, never by the agent: at most two, one commit each, by the fix author, code plus companion versions in setup-stack's `version-files` (each recorded, carried as `Deps-Verify-Bump:`), never a line Renovate's commits added, never a hand-edited lockfile. Lockfiles come from setup-stack's `lock` command, run before the App token is minted. A repo whose Renovate config does not ignore the fix author gets no push | Evidence is only useful if it is allowed to be wrong; merging is deps-automerge's call, from the labels set here. A blanket manifest ban left updates stuck on the companion bump their own notes asked for. The agent is told the rules, not bound by them, so the action checks them. Renovate stops rebasing a branch an unignored author touched. `push-round/test.sh` covers every refusal; `run-agent/test.sh` the publish, actor and renovate steps. |
| `.github/workflows/deps-verify.yml` | The label and the comment are written by the job from the agent's files, never by the agent. A red build that was not fixed is `deps:needs-manual`, and a branch with fix commits is `deps:fixed`, never `deps:verified` | An agent that labels its own verdict left two labels on one PR and none on another. A later automerge rule must be able to tell a clean bump from one a machine edited. A `deps:needs-manual` that the PR's own author applied (a Renovate package rule asking for manual review) is never removed, because the last `labeled` event for it names that author and the job's labels come from the App or `GITHUB_TOKEN`. |
| `actions/run-agent/` | With `report-file`, the report exists and passes `report-valid` after every run: run-agent writes `report-fallback` plus a `why` (the workflow-file mismatch it checks before starting the action, the turn cap, or the error the action hides) whenever the agent left none. Callers word `why`; they never parse the execution file | "The agent wrote no report" told nobody what to do, and claude-code-action hides both its errors and its own skip. `test.sh` runs `validate`, `outcome` and `report`. |
Expand Down Expand Up @@ -215,9 +216,11 @@ why, not history.
was NOT provided, stop here". The review depth this repo computes travels in
the system prompt, because an extra word on the slash command is discarded.
- **A label already present emits no `labeled` event.** So a request label must
be cleared when the job finishes, or asking again does nothing. `pr-review`
clears `agent:review`, `issue-triage` clears `agent:triage`, and
`issue-decompose` clears `agent:decompose`.
be cleared when the job finishes, or asking again does nothing. Every
workflow clears its own through `actions/clear-request-label`: `pr-review`
`agent:review`, `issue-triage` `agent:triage`, `issue-implement`
`agent:implement`, `issue-decompose` `agent:decompose`, `pr-iterate`
`agent:iterate`, and `judge-verdict` `agent:judge`.
- **The org runners API says busy and offline separately.** `status` is
`online` or `offline`, and `busy` is a per-runner boolean that is `false` on an
offline runner. A pool is available when a runner is `online` and not `busy`,
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ Renovate marker, and a bump releases as `chore(deps)`.
| `actions/pr-facts` | Resolves the PR from a number or a pull_request, workflow_run or status event, and checks it is open, not a fork, and at the expected head |
| `actions/judge-verdict` | Marks an `agent:judge` request pending, turns a review by the exact judge login on the current head into `judge / verdict` with the org App token, or ends unanswered requests in `error`. Fails closed on anything it cannot trust; `verdict.sh` holds the rules |
| `actions/request-review` | Applies `agent:review` with the App token when the head commit has no `review / verdict` from the org App yet |
| `actions/clear-request-label` | Removes an `agent:*` request label from one or more issues or PRs. A label already gone is silent; any other failure is a `::warning` that the request stays on. Never fails the step. The one way a workflow clears its request label |
| `actions/merge-gate` | The one unattended merge: resolves the PR, runs `agent-gate`, decides by policy (`deps`, `factory`, `backmerge`, `hotfix` or `standards-sync`) from labels, the required check, `review / verdict` (only the org App's counts), Renovate's release-age status, mergeability, the base branch, commit authors, for a back-merge the head commit's parents, for a security patch `target-guard`'s verdict, and for a standards sync `standards / verify` and `standards / render`, and merges with the App token (a dependency PR by rebase, an agent PR, a security patch and a standards sync by squash, a back-merge by merge commit). A conflicted Renovate PR gets its rebase box ticked instead; a conflicted agent PR waits for the fix loop. For `hotfix` it takes target-guard's verdict from `guard.sh verdict`, which prints it without failing. When the policy needs a review the head does not have, it applies `agent:review` through `request-review` |
| `actions/push-round` | Checks an agent's commits on a PR branch, regenerates lockfiles, and pushes them as one trailered commit with the App token, or refuses with a reason; its merge mode pushes the update job's merge of the base. Every round, round 0 included, passes `guard.sh`, which refuses a deleted, skipped or loosened test, a deleted snapshot, and any edit to a workflow, the merge gate or lint, test or CI config |
| `actions/app-token` | Mints the org App token for this repo, optionally narrowed; empty when no App is configured. Also outputs the App's `app-slug` and its `login` (`<slug>[bot]`), the creator of the statuses it posts |
Expand Down Expand Up @@ -577,7 +578,8 @@ exactly one of them, because two sources for one fact disagree within weeks and
then neither is trusted.

Every `agent:*` label is self-clearing. The workflow removes it when it finishes,
including when it refuses. If it is still there, the work is genuinely running.
including when it refuses. If it is still there, the work is genuinely running,
or the removal failed, which the run reports as a `<label> not removed` warning.

```
agent:triage -> classify, then plan or ask
Expand Down
34 changes: 34 additions & 0 deletions actions/clear-request-label/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Take an `agent:*` request label off an issue or pull request. Every workflow
# that clears its request label goes through here, so the error handling is one
# edit. Each caller keeps its own `if:`: when a request ends differs per
# workflow. Thin wrapper; the outcomes and the reasoning are in clear.sh.
name: Clear request label
description: Remove an agent:* request label. A label already gone is silent; any other failure warns that the request stays on.

inputs:
number:
description: >-
Issue or pull request number. Several, whitespace-separated, are cleared
one by one.
required: true
label:
description: 'The request label, for example agent:review'
required: true
token:
description: >-
Token to remove it with. Needs issues: write (or pull-requests: write on
a PR). GITHUB_TOKEN activity starts no workflow, so a removal with it
cannot loop; an App token emits an `unlabeled` event.
default: ${{ github.token }}

runs:
using: composite
steps:
- shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
REPO: ${{ github.repository }}
NUMBER: ${{ inputs.number }}
LABEL: ${{ inputs.label }}
ACTION_PATH: ${{ github.action_path }}
run: '"$ACTION_PATH/clear.sh"'
Loading
Loading