Repository navigation
172 lines (161 loc) · 8.34 KB
/
Copy pathengineer-bot-followup.yml
File metadata and controls
172 lines (161 loc) · 8.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Engineer Bot — follow-up.
#
# When someone replies to a review thread on a PR carrying the `engineer-bot`
# label (or the label is applied), the bot re-evaluates the open threads in
# catch-up mode, applies a fixup (or replies / marks blocked), and pushes to the
# PR branch. Driven by this repo's .bot/ prompts.
#
# Like the author, this installs connector deps (`npm ci` via the JFrog mirror)
# so the agent can run the MOCKED unit suite (`npm test`) to verify a fixup.
# Unlike the author it wires NO live-warehouse env — the follow-up prompt runs
# only unit tests and forbids the live e2e suite (no live creds in an LLM-driven
# fixup step for no functional benefit).
#
# The gate below is the canonical label-gated form from the engine dogfood. It
# ANDs with the engine-side floor; do not weaken it.
name: Engineer Bot — Follow-up
on:
pull_request_review_comment:
types: [created]
# `engineer-bot` label applied → catch-up over pre-existing review threads.
pull_request:
types: [labeled]
permissions:
contents: write # push fixup commits to the PR branch
pull-requests: write # post inline replies
id-token: write # JFrog OIDC exchange for npm + the engine/SDK/CLI install
jobs:
followup:
# SECURITY + scope (CANONICAL label-gated model — verbatim from the engine):
# - skip fork PRs — keep the model + App token out of untrusted code's reach
# (critical on a PUBLIC repo);
# - operate only on non-fork OPEN PRs carrying the `engineer-bot` label
# (maintainer-applied opt-in; label requires triage+);
# - comment path: trusted commenters only
# (OWNER/MEMBER/COLLABORATOR/CONTRIBUTOR, or a bot — reviewer-bot/Copilot),
# never the engineer-bot's own comments, and never a reviewer-bot reconcile
# loopback or "resolved" reply (the engine skips resolved threads anyway,
# so those runs only delay queued work). CONTRIBUTOR is included because
# a maintainer with PRIVATE org membership is reported as
# `author_association: CONTRIBUTOR` in the webhook
# payload (even though REST shows MEMBER) — without it, such a maintainer's
# review comments SILENTLY fail this gate and the bot never engages. Low
# risk: this path already requires a non-fork, OPEN, `engineer-bot`-labeled
# PR (a maintainer-applied opt-in);
# - labeled path: the `engineer-bot` label was just applied by a human.
if: >-
github.event.pull_request.head.repo.fork == false
&& github.event.pull_request.state == 'open'
&& (
(
github.event_name == 'pull_request_review_comment'
&& contains(github.event.pull_request.labels.*.name, 'engineer-bot')
&& !startsWith(github.event.comment.user.login, 'peco-engineer-bot')
&& !contains(github.event.comment.body, '<!-- pr-review-bot:v1 reconcile -->')
&& !contains(github.event.comment.body, '<!-- pr-review-bot:v1 resolved -->')
&& (
contains(fromJson('["OWNER","MEMBER","COLLABORATOR","CONTRIBUTOR"]'), github.event.comment.author_association)
|| (
github.event.comment.user.type == 'Bot'
&& (
startsWith(github.event.comment.user.login, 'peco-review-bot')
|| startsWith(github.event.comment.user.login, 'Copilot')
|| startsWith(github.event.comment.user.login, 'copilot')
)
)
)
)
|| (
github.event_name == 'pull_request'
&& github.event.action == 'labeled'
&& github.event.label.name == 'engineer-bot'
&& github.event.sender.type != 'Bot'
&& !startsWith(github.event.sender.login, 'peco-engineer-bot')
)
)
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
timeout-minutes: 30
concurrency:
# Share the branch-editing queue with engineer-bot-mention.yml.
group: engineer-bot-followup-pr-${{ github.event.pull_request.number }}
cancel-in-progress: false
queue: max
steps:
# Checkout FIRST (remote action) so the local `./` composites resolve. Check
# out the PR head BRANCH (not the merge ref) so fixups push back to it.
# persist-credentials:false; the run step sets an authenticated push remote.
- name: Checkout PR head branch
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
persist-credentials: false
# --- connector deps (for the agent's `npm test` self-verify) -------------
- name: Setup Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22.23.4'
- name: Setup JFrog
uses: ./.github/actions/setup-jfrog
- name: Install connector deps (npm ci)
run: npm ci
- name: Restore lockfile after dependency installation
# Keep setup-jfrog's registry rewrite out of the agent's changes.
run: git restore --source=HEAD --worktree -- package-lock.json
# Scope the JFrog credential away from the model-driven followup step:
# `npm ci` above consumed ~/.npmrc, and the agent's `npm test` doesn't need
# the registry. (Addresses the reviewer-bot finding on the odbc onboarding PR.)
- name: Scrub JFrog credentials before the agent runs
run: |
rm -f ~/.npmrc
echo "JFROG_ACCESS_TOKEN=" >> "$GITHUB_ENV"
# --- shared bot setup ----------------------------------------------------
- name: Bot prelude (tokens + Node + engine install)
id: prelude
uses: ./.github/actions/bot-prelude
with:
app-id: ${{ secrets.ENGINEER_BOT_APP_ID }}
private-key: ${{ secrets.ENGINEER_BOT_APP_PRIVATE_KEY }}
# Load .bot/ (config, allowlist, prompts) from the default branch, as the
# mention workflow does, so prompt fixes reach open bot PRs and a PR branch
# can't change its own follow-up's allowlist or instructions.
- name: Load bot config from the default branch
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
set -euo pipefail
trusted="$RUNNER_TEMP/trusted-bot"
mkdir "$trusted"
git fetch --no-tags origin "refs/heads/$DEFAULT_BRANCH"
git archive FETCH_HEAD .bot | tar -x -C "$trusted"
# Run the follow-up. NOTE: no live-warehouse connection env (E2E_* /
# DATABRICKS_TEST_CONFIG_FILE) is wired here — the followup prompt
# (.bot/prompts/engineer-followup/system.md) runs only the mocked `npm test`
# unit suite and forbids the live e2e suite, so the agent never needs them.
- name: Run engineer follow-up (catch-up over all unaddressed threads)
env:
GH_TOKEN: ${{ steps.prelude.outputs.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
HEAD_BRANCH: ${{ github.event.pull_request.head.ref }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
TRIGGER_COMMENT_ID: ${{ github.event.comment.id }}
ENGINEER_BOT_MODEL_OVERRIDE: databricks-claude-opus-5-5
MODEL_ENDPOINT: https://${{ secrets.DATABRICKS_HOST }}/serving-endpoints/databricks-claude-opus-5-5/invocations
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
RUNNER_TEMP: ${{ runner.temp }}
# The agent's working tree. The engine has NO path default — it fails
# with a clear error if this is unset. `--bot` below points the config
# lookup at the default branch's copy instead of <REPO_ROOT>/.bot.
REPO_ROOT: ${{ github.workspace }}
run: |
# The runner injects OIDC credentials per step; clear them in this shell.
unset JFROG_ACCESS_TOKEN ACTIONS_ID_TOKEN_REQUEST_TOKEN ACTIONS_ID_TOKEN_REQUEST_URL
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
python -m databricks_bot_engine.engineer_bot.run --phase followup \
--bot "$RUNNER_TEMP/trusted-bot/.bot" \
--system-prompt "$RUNNER_TEMP/trusted-bot/.bot/prompts/engineer-followup/system.md"