Repository navigation
140 lines (131 loc) · 7.27 KB
/
Copy pathengineer-bot-learning.yml
File metadata and controls
140 lines (131 loc) · 7.27 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
# Engineer Bot — learning (retrospective) extraction, DAILY.
#
# Once a day the bot extracts durable learnings into a new journal file and
# distills them into lessons.md in a rolling PR. The legacy learning log is frozen;
# a human reviews every learning PR.
#
# The window is an ISO adaptive cursor: `since` defaults to the start time of the
# last successful run, falling back to `--window-hours` (24) on the first run or
# when the Actions API is unavailable. A failed or missed run does NOT advance the
# cursor, so the next run automatically widens to cover the gap — no per-PR label
# or per-merge trigger needed. (This REPLACES the old per-PR `extract-learning`
# on-merge model: the engine now gathers each PR's diff/comments itself over the
# window, so there is no manual context-gather step and no `context_files`.)
#
# Own job (NOT `uses: databricks/databricks-bot-engine/...`): an external repo
# can't resolve the internal engine's reusable workflows ("not found"). It shares
# the SAME prelude the other bots use — ./.github/actions/bot-prelude (tokens +
# Node + pinned engine install) — so the engine pin stays single-sourced in
# bot-prelude's `engine-ref` default (no second SHA to drift). What's unique to
# this flow stays inline: the default-branch checkout the learning PR is cut from
# and the authenticated push remote.
#
# Opt-in is purely via the `retrospective:` block in .bot/config.yaml + this
# workflow; absent that block the engine phase is a clean no-op.
name: Engineer Bot — Learning
on:
schedule:
# 07:17 UTC daily — off-peak, off-:00 minute (GitHub delays/drops on-the-hour
# crons). Scheduled runs fire only on the default branch.
- cron: "17 7 * * *"
workflow_dispatch:
inputs:
# Manual-recovery knobs surfaced by the retrospective's failure messages: a
# wedged flow (CatchUpBacklogError / CursorReadError) is recovered by
# re-dispatching with a recent `since`.
since:
description: 'ISO lower bound to bound (shorten) the window and recover a wedged flow. Empty = adaptive cursor.'
type: string
default: ''
window-hours:
# STRING, not number: a `type: number` dispatch input fails the whole run
# at startup when the workflow also triggers on `schedule`. argparse
# coerces it to int downstream (retrospective.py, `type=int`), so string is
# correct here (mirrors the engine's own learning-cron workflow).
description: 'Fallback look-back window (hours) used only when there is no prior successful run.'
type: string
default: '24'
permissions:
contents: write # push the journal/lessons PR
pull-requests: write
actions: read # Track B lists author runs + downloads their logs via the
# App token; without actions:read that step 403s and fails
# the whole run (no permission escape hatch).
id-token: write # JFrog OIDC exchange for the engine/SDK/CLI install
concurrency:
# Fixed key (no PR number — this is schedule/dispatch driven). cancel-in-progress
# false so a manual recovery dispatch doesn't kill an in-flight scheduled run.
group: engineer-bot-learning-cron
cancel-in-progress: false
jobs:
learning:
environment: azure-prod # DATABRICKS_HOST / DATABRICKS_TOKEN live here
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
timeout-minutes: 20
steps:
# Checkout the default branch (the learning PR is cut from it) FIRST, so the
# local `./` composites below resolve. persist-credentials:false — the
# retrospective sets its own authenticated push remote (see the run step),
# so no token is left in .git/config.
- name: Checkout default branch (learning PR is cut from it)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
# Route pip through the JFrog proxy for the engine install (no cargo — the
# retrospective reads the diff, it doesn't build the crate). MUST run before
# bot-prelude (install-bot-engine reuses its PIP_INDEX_URL / JFROG_ACCESS_TOKEN).
- name: Set up JFrog (pip)
uses: ./.github/actions/setup-jfrog
with:
uv: "true"
- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.11'
# Shared prelude: mint the engineer-bot token (opens the learning PR) + the
# engine-scoped token, set up Node, install the pinned engine (PAT-free). The
# engine pin comes from bot-prelude's `engine-ref` default — the SINGLE source
# of truth for every bot; there is no second SHA in this file to drift.
- 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 }}
# NOTE: no git-identity step here. The engine's retrospective configures the
# git user AND DCO sign-off itself from .bot/config.yaml `bot_login_prefix` —
# same as the author/followup flows — so the learning commit is authored and
# signed as the bot without the workflow doing it.
- name: Extract daily learnings + open/update PR
env:
GH_TOKEN: ${{ steps.prelude.outputs.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
# Use the concrete `.../serving-endpoints/<model>/invocations` form (same
# as reviewer-bot.yml / engineer-bot.yml). sdk_agent.translate_endpoint
# strips it to the `.../serving-endpoints/anthropic` base the CLI needs.
# Do NOT use `.../serving-endpoints/anthropic/invocations` here: that hits
# translate_endpoint's already-v2 early-return, which keeps the trailing
# `invocations`, so the CLI appends `/v1/messages` →
# `.../anthropic/invocations/v1/messages` → HTTP 400 (unsupported path).
# The engine adds the [1m] context suffix to the override.
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 }}
WINDOW_HOURS: ${{ inputs.window-hours || '24' }}
SINCE: ${{ inputs.since || '' }}
RUNNER_TEMP: ${{ runner.temp }}
# The retrospective pushes the learning branch with a plain `git push
# origin` (no in-module set-url), and the checkout ran persist-credentials:
# false — so set an authenticated push remote from the minted App token
# first, mirroring engineer-bot.yml's publish step. retrospective.py
# resolves repo_dir from --repo-dir (cwd = $GITHUB_WORKSPACE otherwise),
# where .bot/ lives.
run: |
set -euo pipefail
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
args=(--repo-dir "$GITHUB_WORKSPACE" --window-hours "$WINDOW_HOURS")
[ -n "$SINCE" ] && args+=(--since "$SINCE")
python -m databricks_bot_engine.engineer_bot.retrospective "${args[@]}"