Skip to content

ci(bots): onboard databricks-bot-engine (engineer + reviewer + retrospective) - #179

Merged
eric-wang-1990 merged 17 commits into
mainfrom
onboard/bot-engine
Jul 21, 2026
Merged

eric-wang-1990 merged 17 commits into
mainfrom
onboard/bot-engine

Conversation

@eric-wang-1990

@eric-wang-1990 eric-wang-1990 commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

Onboards the three autonomous bots from databricks/databricks-bot-engine into this repo, following the engine's "Onboarding a consumer repo" guide and the working databricks-sql-python consumer, adapted for Rust/cargo.

What's included

Composites (.github/actions/)

  • install-bot-engine — pip-installs the pinned engine + Claude SDK/CLI, PAT-free via an engine-scoped App token. Reuses this repo's existing setup-jfrog for the pip proxy; points npm at the JFrog npm proxy using setup-jfrog's minted token (setup-jfrog covers cargo+pip but not npm).
  • bot-prelude — mints the bot + engine-scoped tokens, sets up Node, calls install-bot-engine. Single source of truth for the engine pin (92b3857996b2fbac5d0573ea89db6be9f0c48b9a ).

Workflows (.github/workflows/)

  • reviewer-bot / reviewer-bot-followup — review PRs + follow up on review-comment replies.
  • engineer-bot / engineer-bot-followup — label an issue → reproduce + fix + open a PR; follow up on review comments.
  • engineer-bot-learning — on merge of a PR labelled extract-learning, distill a durable learning and open a PR appending it to the learning log (retrospective flow). Self-contained (an external repo can't uses: the internal engine's reusable workflow).

All gate on fork == false, run in environment: azure-prod on databricks-protected-runner-group.

.bot/ (engineer config + prompts; the reviewer is zero-config)

  • config.yaml — bug-fix flow, cargo bash_allowlist, retrospective: block.
  • prompts for engineer / engineer-followup / review / retrospective — Rust testing discipline. The bug-fix prompt requires a live E2E repro (cargo test --test <suite> -- --ignored), matching rust-e2e.yml.
  • .claude/knowledge/learning-log.md — seeded log the retrospective appends to.

Live-E2E auth past the engine's env scrub
The engine strips *TOKEN* from the agent's cargo test subprocess, so a plain DATABRICKS_TOKEN never reaches the live repro. tests/common/mod.rs adds a shared env_var/live_session with a DATABRICKS_TEST_CONFIG_FILE fallback (env var still wins ⇒ rust-e2e.yml and local runs are unchanged); engineer-bot.yml writes that config file. tests/bot_e2e_helper.rs compiles the helper in ordinary CI and proves the fallback.

Verification

  • Additive only — no existing file is modified, so current CI is unaffected.
  • Locally verified against the crate: cargo check --tests, cargo test --test bot_e2e_helper (passes), cargo fmt --all --check, cargo clippy --all-targets -- -D warnings — all clean.
  • All workflow/composite/.bot YAML validated; .bot/config.yaml loads via the engine's load_bot, and the retrospective: block matches the engine's contract.

⚠️ Provisioning required before the bots run (nothing works until this is done)

Everything here is inert until:

  1. Install the GitHub Apps used by databricks-sql-python (reuse decision) on this repo AND on databricks-bot-engine (the latter with contents: read, so the engine install can authenticate).
  2. Add the App secrets to this repo: REVIEW_BOT_APP_ID, REVIEW_BOT_APP_PRIVATE_KEY, ENGINEER_BOT_APP_ID, ENGINEER_BOT_APP_PRIVATE_KEY.
  3. Confirm the azure-prod environment already exposes DATABRICKS_HOST / DATABRICKS_TOKEN / DATABRICKS_HTTP_PATH (it does today, for rust-e2e.yml).
  4. Merge this PR — issues / workflow_dispatch triggers only register from the default branch.

Then: label a Bug-typed issue with engineer-bot to fire the engineer; open a PR to fire the reviewer; merge a PR labelled extract-learning to fire the retrospective.

Optional follow-up (not in this PR)

The 5 existing tests/v0_*_e2e.rs each keep a private live_session(); they could later be refactored to common::live_session() so a maintainer running the suite manually also benefits from the config-file fallback. Left out here to keep this PR additive and zero-risk to rust-e2e.yml.

This pull request and its description were written by Isaac.

…pective)

Wire the three autonomous bots from databricks/databricks-bot-engine into this
repo, following the engine's "Onboarding a consumer repo" guide and the working
databricks-sql-python consumer, adapted for Rust/cargo.

Composites (.github/actions/):
- install-bot-engine — pip-installs the pinned engine + Claude SDK/CLI, PAT-free
  via an engine-scoped App token. Reuses this repo's existing setup-jfrog for the
  pip proxy (setup-jfrog covers cargo+pip but not npm, so this points npm at the
  JFrog npm proxy using setup-jfrog's minted token).
- bot-prelude — mints the bot + engine-scoped tokens, sets up Node, calls
  install-bot-engine. Single source of truth for the engine pin (5368de77).

Workflows (.github/workflows/):
- reviewer-bot / reviewer-bot-followup — review PRs + follow up on replies.
- engineer-bot / engineer-bot-followup — label an issue → reproduce + fix + PR;
  follow up on review comments. bug-fix flow; Type=Bug ⇒ --flow bug-fix.
- engineer-bot-learning — on merge of a PR labelled extract-learning, distill a
  durable learning and open a PR appending it to the learning log (retrospective
  flow). Self-contained (can't `uses:` the internal engine cross-repo).
All gate on fork==false, run in environment: azure-prod on the protected runner.

.bot/ (engineer config + prompts; reviewer is zero-config):
- config.yaml — bug-fix flow, cargo bash_allowlist, retrospective block.
- prompts/engineer{,-followup}, review, retrospective — Rust testing discipline;
  the bug-fix prompt REQUIRES a live E2E repro (cargo test --test <s> -- --ignored).
- .claude/knowledge/learning-log.md — seeded log the retrospective appends to.

Live-E2E auth past the engine's env scrub:
- tests/common/mod.rs — shared env_var/live_session with a DATABRICKS_TEST_CONFIG_FILE
  fallback (the engine strips *TOKEN* from the agent's cargo-test subprocess, so the
  token rides a config file whose path survives the scrub; env var still wins ⇒
  rust-e2e.yml + local runs unchanged). engineer-bot.yml writes that file.
- tests/bot_e2e_helper.rs — offline test that compiles tests/common in CI and proves
  the fallback. Verified locally: cargo check --tests, cargo test, fmt, clippy all clean.

Additive only — no existing file changed. Inert until the bot App secrets exist +
this merges (triggers register only from the default branch).

Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
Co-authored-by: Isaac

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 3 Low

Additive-only CI onboarding of the bot workflows plus two offline Rust test helpers. The executable code is sound — common::live_session matches the existing per-file e2e builders exactly, edition 2021 makes the set_var/remove_var usage safe as commented, and the dev-deps (tempfile/serde_json/tokio) are all declared. A few low-severity nits around the env-var fallback, the duplicated engine-ref pin, and the MODEL_ENDPOINT host-scheme assumption — none blocking.

Comment thread tests/common/mod.rs Resolved
Comment thread .github/workflows/reviewer-bot.yml Resolved
…rd callout

Review findings on #179:
- F1 (real): env_var's config-file branch now filters empty values symmetrically
  with the env branch, so a blank/misprovisioned secret (jq-written
  "access_token": "") resolves to None → the clear `… required` panic, not a
  silent AuthConfig::Pat { token: "" } and a confusing server-side auth failure.
  Add tests/bot_e2e_helper_empty.rs (own binary for a fresh OnceLock) proving it.
- F2 (design-inherent): strengthened the engine-ref duplication comment in
  engineer-bot-learning.yml into an explicit DRIFT HAZARD callout naming both
  sites to bump together. A CI lint would be over-engineering for a single
  duplicated literal.
- F3 (verified non-issue): MODEL_ENDPOINT concatenation assumes a bare-host
  DATABRICKS_HOST; confirmed correct — the same pattern works in databricks-sql-python
  and the same azure-prod secret feeds rust-e2e.yml. No change.

Verified: cargo test (both helper binaries), fmt, clippy -D warnings all clean.

Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
Co-authored-by: Isaac
@eric-wang-1990

Copy link
Copy Markdown
Collaborator Author

Security Scan failure is pre-existing and unrelated to this PR

The failing Security Scan check is not caused by this PR and shouldn't block it on the merits of the change:

  • OSV-Scanner flags two advisories in pyo3@0.26.0 — RUSTSEC-2026-0176 / GHSA-36hh-v3qg-5jq4 (8.7) and RUSTSEC-2026-0177 / GHSA-chgr-c6px-7xpp (6.3) — a dependency of the existing pyo3/ binding crate.
  • This PR touches no Cargo.toml and adds no dependency — it's purely additive CI workflows + .bot/ config + two offline Rust test files.
  • The scan is failing on every open PR right now (e.g. the mani/c-abi-* branches), not just this one — the advisories were published recently and now trip the scan repo-wide.

This is a dependency-hygiene call for the team, best handled in a separate PR against main: either bump pyo3 past 0.26.0 to a patched release, or add a documented [[IgnoredVulns]] triage entry to osv-scanner.toml (the workflow's own error message points there). I deliberately did not fold a security-scan suppression into this CI-onboarding PR.


Also addressed the review in 4b37bb2: symmetric empty-value filtering in the config-file fallback (+ a dedicated test), and a stronger drift-hazard callout on the duplicated engine pin. The MODEL_ENDPOINT scheme concern (F3) was verified a non-issue (bare-host DATABRICKS_HOST, same as sql-python and this repo's rust-e2e.yml).

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Medium

Additive, well-documented bot onboarding — no existing files touched, and the new common:: E2E helpers faithfully mirror the existing per-file live_session/env_var. One medium concern: tests/bot_e2e_helper_empty.rs doesn't clear DATABRICKS_HOST before asserting on it, so it's non-hermetic for local cargo test runs where that var is configured (as CLAUDE.md documents).

Comment thread tests/bot_e2e_helper_empty.rs Resolved
Review (Medium): bot_e2e_helper_empty.rs cleared DATABRICKS_TOKEN but not
DATABRICKS_HOST before asserting env_var("DATABRICKS_HOST") == Some("h.example").
Since env_var prefers a non-empty env value over the config file, a developer
with DATABRICKS_HOST in .cargo/config.toml [env] (per CLAUDE.md) would get their
real host and the assertion would fail on the documented `cargo test` pre-commit
run. It only passed in the Unit + doc tests CI job because that job sets no
connection env.

Clear DATABRICKS_HOST + DATABRICKS_HTTP_PATH up front too, mirroring the sibling
bot_e2e_helper.rs. Verified: the test now passes even with DATABRICKS_HOST set in
the environment.

Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
Co-authored-by: Isaac
@eric-wang-1990 eric-wang-1990 added the engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up label Jul 20, 2026
An earlier rewrite left a stale half-sentence above the new one: line 1 trailed
off at "...named by" and line 2 restated it in full, rendering as two overlapping
sentences in rustdoc. Collapse to a single coherent sentence. Doc-only.

Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
Co-authored-by: Isaac

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 2 Medium

Additive-only onboarding of the bot workflows; the Rust helper (tests/common) and its offline tests are sound and well-covered. One consistency/robustness gap: the two engineer workflows (author + followup) call bot-prelude, which pip-installs and runs the engine via python, but omit the Setup Python step that the three sibling workflows and bot-prelude's own documented precondition require — so they rely on an ambient, unpinned python on the protected-runner image.

Comment thread .github/workflows/engineer-bot.yml Resolved
peco-engineer-bot[bot] and others added 2 commits July 20, 2026 08:25
Addresses:
  - #3612879461 at .github/workflows/engineer-bot.yml:103
  - #3612879465 at .github/workflows/engineer-bot-followup.yml:115

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
The final block's comment said "set the token explicitly" but the code sets
DATABRICKS_HOST (asserting env wins over the config file). Say "host". Comment-only.

Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
Co-authored-by: Isaac

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — an additive, well-commented bots-onboarding PR (workflows, composites, .bot/ prompts, and a config-file-fallback test helper). One low defensive-hardening note on token masking in install-bot-engine. Nit (not inline): the PR description cites the engine pin as 5368de77, but bot-prelude's authoritative engine-ref default is 92b3857996b2fbac5d0573ea89db6be9f0c48b9a — worth reconciling the description so reviewers know which pin is canonical. The tests/common helper and its three offline binaries are cleanly structured (one test per binary to keep the OnceLock fresh, symmetric empty-value filtering, hermetic env teardown).

Addresses:
  - #3615726645 at .github/actions/install-bot-engine/action.yml:79

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — additive bot onboarding (CI composites/workflows + .bot/ config/prompts + an offline-tested E2E connection helper). The new tests/common/mod.rs helper matches the real kernel API (Session::builder().http_path().auth(AuthConfig::Pat{..}), per src/session.rs) and the existing per-file e2e live_session(); each helper test is its own integration binary so the process-global env mutations + OnceLock cache don't race, and tempfile/serde_json are present as deps. No executable-code bugs found. Two non-blocking notes: (1) one low finding on the engine-ref SHA mismatch between the action default and the PR description; (2) as the PR itself acknowledges, the 5 existing tests/v0_*_e2e.rs suites keep private env_var/live_session helpers that do NOT read the config-file fallback, so a bot repro added to an existing suite (rather than a new common::-based file) would fail to authenticate under the scrubbed subprocess — th

[...truncated to keep verdict scannable]

Comment thread .github/actions/bot-prelude/action.yml Resolved
The three bot_e2e_helper*.rs binaries were belt-and-suspenders coverage of the
tests/common config-file fallback. Keep bot_e2e_helper.rs — it still `mod common;`
so tests/common/mod.rs is compiled + type-checked in ordinary CI (the compile
guard) and the happy-path fallback (env absent → file value; env wins when set) is
proven. Drop bot_e2e_helper_empty.rs / bot_e2e_helper_badcfg.rs: the empty-value
and malformed-file branches remain in the helper (correct defensive behavior) but
no longer carry dedicated single-binary tests. Leaner tree, same guarantees that
matter for onboarding. fmt + clippy clean; bot_e2e_helper passes.

Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
Co-authored-by: Isaac

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — a clean, well-documented, additive bots-onboarding PR (workflows/composites/.bot prompts + one tested Rust helper). Verified the new common::live_session/env_var helper matches the real SessionBuilder API in src/session.rs and the existing per-file e2e builders; the config-file fallback and empty-value filtering are sound. Only one low maintainability note on the helper's test (inline).

Comment thread tests/bot_e2e_helper.rs Resolved
Addresses:
  - #3615929660 at tests/bot_e2e_helper.rs:43

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Additive bot-onboarding PR (workflows, composites, .bot/ config+prompts, and a shared E2E test helper); no existing files touched. The Rust test helper is correct — AuthConfig::Pat/Session::builder().http_path().auth() match the crate, tempfile is a dev-dep, edition 2021 makes the set_var usage sound, and the OnceLock single-test invariant is well-documented. Token handling in the composites is careful (job-local configs, masking, trap cleanup). One Low: the engineer prompts tell the agent to run cargo +stable fmt --all, which the [cargo, fmt] allowlist prefix can't match.

Comment thread .bot/config.yaml Resolved
Addresses:
  - #3616017051 at .bot/config.yaml:61

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — a clean, additive-only CI/bot onboarding PR. The only Rust code (tests/common/mod.rs + tests/bot_e2e_helper.rs) uses the Session::builder().http_path(...).auth(AuthConfig::Pat{...}) API that matches all existing v0_*_e2e.rs tests, its deps are declared, and the env-var/config-file fallback + OnceLock caching logic is correct. One low, non-blocking note on the comment-only single-test invariant.

Comment thread tests/bot_e2e_helper.rs

use std::io::Write;

// ⚠️ SINGLE-TEST INVARIANT — do NOT add a second `#[test]` to this binary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — The single-test invariant for this binary is enforced only by a comment. Because the test mutates process-global env (set_var/remove_var) and depends on owning the first read that config_file()'s OnceLock caches, a future contributor who adds a second #[test] here will introduce a flaky race that CI may not reliably catch (the two tests run on parallel threads). The comment correctly explains the risk, but nothing structurally prevents the regression. Consider gating this file's tests behind serial_test::serial now (already common in the ecosystem), or moving the env-mutating logic behind a helper that snapshots/restores env, so the invariant survives a well-meaning edit. Non-blocking — the current single test is correct as written.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking Low comment; reviewer confirms the single test is correct as written. No code change warranted: (1) adding serial_test is a new dependency requiring a deny.toml license approval (out of scope for this PR) and, more importantly, serial only orders execution — it does not guarantee ownership of the first read that config_file()'s OnceLock caches, so it wouldn't solve the stated invariant; (2) a snapshot/restore env helper improves hermeticity but also doesn't prevent a second #[test] racing on the OnceLock. The real guard is the one-process-per-binary boundary, which is exactly why the doc comment directs extra coverage to a SEPARATE integration-test file (own binary → own process → own env + OnceLock). The loud comment plus that guidance is the pragmatic, correct prevention.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point that serial_test::serial only serializes execution and wouldn't by itself defeat the OnceLock staleness across differing env — my suggested remedy was incomplete on that axis, and the separate-binary boundary is indeed the real isolation mechanism. That said, no code changed here: the invariant is still guarded solely by the comment shown at head, which is exactly the structural gap the finding is about. The current one-test binary is correct, but a future #[test] added to this file would still compile and race; the loud comment is guidance, not enforcement. Leaving this open as a Low, non-blocking note so a human can decide whether a cheap structural guard (e.g. a compile_error!-style tripwire or an env snapshot/restore helper) is worth adding — no action is required to merge.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔ NEEDS HUMAN DECISION — the bots can't resolve this thread; a maintainer's input is required.

Thread has converged: reviewer agrees the single test is correct as written and that the separate-binary boundary (not serial_test) is the real isolation mechanism; the finding is Low/non-blocking and explicitly "no action required to merge." No enforceable code change is available — Rust can't compile_error!-gate a second #[test] in a binary, and the discussed alternatives (serial_test, env snapshot/restore) were mutually agreed not to defeat the OnceLock staleness while adding an out-of-scope dependency. The remaining question — whether a cheap structural tripwire is worth adding — is a human judgment call the reviewer deferred, and any such guard belongs in a separate change. Flagging for a human; the loud doc comment plus separate-file guidance is the pragmatic prevention in this PR.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

This branch was previously deployed

1 inactive deployment
azure-prod — d409f964 Deployed Jul 21, 2026 by eric-wang-1990 via followup #76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants