-
Notifications
You must be signed in to change notification settings - Fork 0
fix: use review credentials for agent dispatch #1162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3284911
af07a15
144da19
29fba30
c64e0e8
a885441
fad1ed4
f4ff21f
cb6bf5e
e530ef1
908e923
f898ba3
0f76578
444ac8b
4a7031d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,8 +25,8 @@ jobs: | |
| || contains(github.event.comment.body, '@opencode-agent') | ||
| ) | ||
| concurrency: | ||
| group: review-agent-mention-router-local-${{ github.repository }} | ||
| queue: max | ||
| group: review-agent-mention-router-local-${{ github.repository }}-${{ github.event.comment.id }} | ||
| cancel-in-progress: false | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| permissions: | ||
|
|
@@ -38,7 +38,7 @@ jobs: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | ||
| GH_TOKEN: ${{ github.token }} | ||
| TARGET_REPOSITORY_TOKEN: ${{ github.token }} | ||
| AGENT_DISPATCH_TOKEN: ${{ github.token }} | ||
| AGENT_DISPATCH_TOKEN: ${{ secrets.PR_REVIEW_MERGE_TOKEN || secrets.OPENCODE_APPROVE_TOKEN }} | ||
| OPENCODE_REPOSITORY_DISPATCH_TARGETS: ${{ vars.OPENCODE_REPOSITORY_DISPATCH_TARGETS }} | ||
| steps: | ||
| - name: Check out trusted default-branch router | ||
|
|
@@ -61,9 +61,13 @@ jobs: | |
| "$SOURCE_EVENT_PATH" >"${RUNNER_TEMP}/agent-mention-event.json" | ||
|
|
||
| - name: Route trusted local agent mention | ||
| run: >- | ||
| python3 -u scripts/ci/agent_mention_router.py | ||
| --event-path "${RUNNER_TEMP}/agent-mention-event.json" | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -z "${AGENT_DISPATCH_TOKEN:-}" ]; then | ||
| echo "::warning::No configured review dispatch credential; the mention remains available for the scheduled sweep." | ||
| exit 0 | ||
| fi | ||
| python3 -u scripts/ci/agent_mention_router.py --event-path "${RUNNER_TEMP}/agent-mention-event.json" | ||
|
|
||
| sweep-organization-agent-mentions: | ||
| if: >- | ||
|
|
@@ -158,7 +162,6 @@ jobs: | |
| env: | ||
| PR_REVIEW_MERGE_TOKEN: ${{ secrets.PR_REVIEW_MERGE_TOKEN }} | ||
| OPENCODE_APPROVE_TOKEN: ${{ secrets.OPENCODE_APPROVE_TOKEN }} | ||
| AGENT_DISPATCH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -n "$PR_REVIEW_MERGE_TOKEN" ]; then | ||
|
|
@@ -172,6 +175,7 @@ jobs: | |
| TARGET_REPOSITORY_SOURCE="${TARGET_REPOSITORY_TOKEN:+installation}" | ||
| fi | ||
| export TARGET_REPOSITORY_TOKEN | ||
| export AGENT_DISPATCH_TOKEN="$TARGET_REPOSITORY_TOKEN" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 Sweep dispatch now uses the cross-repo/app credential instead of github.token The sweep job removed the job-level Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| if [ -z "$TARGET_REPOSITORY_TOKEN" ] || [ -z "$TARGET_REPOSITORY_SOURCE" ]; then | ||
| echo "::error::Agent mention sweep requires PR_REVIEW_MERGE_TOKEN, OPENCODE_APPROVE_TOKEN, or the OpenCode app token exchange." | ||
| exit 1 | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Acknowledgement comment failure is now retryable rather than fatal Posting the target acknowledgement comment is now wrapped in try/except and only sets Was this helpful? React with 👍 or 👎 to provide feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Dispatch credential now also gates the artifact-ledger reads
For the local fast path,
AGENT_DISPATCH_TOKENchanged fromgithub.tokentosecrets.PR_REVIEW_MERGE_TOKEN || secrets.OPENCODE_APPROVE_TOKEN. Inmain()(agent_mention_router.py) this token becomes thedispatch_client, which is used not only forrepos/ContextualWisdomLab/.github/dispatches(needs contents:write) but also for the durable ledger reads indispatched_agents->repos/.../actions/artifacts(needs Actions read). Previously these reads succeeded under the job'sactions: readgithub.token; now they run under the review credential. If PR_REVIEW_MERGE_TOKEN / OPENCODE_APPROVE_TOKEN lack Actions read on the central repo,_artifact_recordswill surface a 403 and the whole route fails. A classicrepo-scoped PAT includes Actions read, so this likely works, but it is worth confirming the token scopes since the ledger read is now on the critical path.Was this helpful? React with 👍 or 👎 to provide feedback.