Skip to content

Commit ee3c92a

Browse files
authored
ci(bot): enable distillation and cross-review (#620)
* ci(bot): enable distillation and cross-review Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> * docs(bot): clarify lesson provenance and formatting Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> --------- Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
1 parent b358888 commit ee3c92a

7 files changed

Lines changed: 361 additions & 65 deletions

File tree

‎.bot/config.yaml‎

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# Engineer-bot task config for databricks-sql-nodejs (the Databricks SQL connector
2-
# for Node.js/TypeScript). Loaded by
3-
# databricks_bot_engine.engineer_bot.bot_config.load_bot. The reviewer needs NO
4-
# .bot/config.yaml (its prompts are engine-owned + the optional additive
5-
# .bot/prompts/review/system.md); only the engineer-bot is config-driven.
1+
# Engineer-bot task config and shared retrospective lesson routing.
62
name: databricks_sql_nodejs_bugfix
73
marker_namespace: engineer-bot-nodejs
84
bot_login_prefix: peco-engineer-bot
@@ -97,11 +93,6 @@ author:
9793
issue_url: ISSUE_URL
9894
context_files:
9995
- issue_body.txt # {{issue_body}}
100-
# Close the loop: the author phase reads this log back so fixes benefit from
101-
# what the retrospective has learned. MUST match `retrospective.log_path` below
102-
# — the retrospective WRITES that path; the author only READS it if the two
103-
# agree. (Set together, they connect learning → application.)
104-
knowledge_log: .claude/knowledge/learning-log.md
10596

10697
# Engine orchestration for the author phase. `bug-fix` runs the plan →
10798
# author_tests → fix pipeline (write a failing test → fix the code → re-run to
@@ -111,27 +102,14 @@ author:
111102
# prompts/engineer/system.md, not here.
112103
flow: bug-fix
113104

114-
# Daily learning extraction (retrospective flow). Run by engineer-bot-learning.yml
115-
# via `python -m databricks_bot_engine.engineer_bot.retrospective`: over an adaptive
116-
# look-back window it sweeps every merged PR (diff + review comments, which the
117-
# engine gathers ITSELF per PR) plus engineer-bot author runs, and if the model
118-
# finds a durable, reusable learning, opens/updates a single rolling PR appending a
119-
# dated section to log_path. Human-gated — never commits the canonical log directly.
120-
# Omitting this block makes the retrospective a no-op.
121-
#
122-
# `system_prompt` is intentionally OMITTED: this repo ships no
123-
# prompts/retrospective_system.md, so the engine's built-in base prompt is used.
124-
# (A set-but-missing system_prompt file would be a hard error; an UNSET key uses
125-
# the base. Add the key later only if you write a repo-specific additive prompt.)
126-
# The log is seeded at `log_path` (see `.claude/knowledge/learning-log.md`) so the
127-
# author phase has something to read before the first retrospective PR lands; the
128-
# retrospective appends dated sections to that same file thereafter.
105+
# Both bots receive matching lessons; the old log is a frozen archive.
129106
retrospective:
130-
# No `model:` key: it is RETIRED in the engine (retrospective.py warns
131-
# "`retrospective.model` is no longer honored") — the learning run always uses
132-
# the engine-owned engineer-bot model (databricks-claude-opus-4-8[1m], override
133-
# via the ENGINEER_BOT_MODEL_OVERRIDE workflow env). Setting it here only emits a
134-
# per-run ::warning::. Matches the other driver repos' retrospective blocks.
135-
log_path: .claude/knowledge/learning-log.md # MUST match author.knowledge_log above
136-
branch_prefix: ai/learning-pr-
107+
log_mode: distill
108+
log_path: .claude/knowledge/learning-log.md
109+
journal_dir: .claude/knowledge/journal
110+
lessons_path: .claude/knowledge/lessons.md
111+
auto_merge_learning_pr: false
112+
author_workflow: engineer-bot.yml
113+
# Keep the legacy append-mode PR (#500) on its original branch.
114+
branch_prefix: ai/learning-distill-pr-
137115
pr_label: engineer-bot-learning

‎.claude/knowledge/learning-log.md‎

Lines changed: 246 additions & 9 deletions
Large diffs are not rendered by default.

‎.claude/knowledge/lessons.md‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Lessons
2+
3+
<!-- distilled-through: none -->
4+
5+
## Configuration and authentication
6+
- L-0001 (3×, #457): Trace option support through DBSQLClient, auth adapters and each transport. Type declarations and class comments do not establish forwarding; shared preparation can precede backend-specific filtering.
7+
- L-0002 (2×, #501 #505): New auth branches must preserve ambiguity, credential-exclusion and persistence guards, including checks bypassed by early returns.
8+
- L-0003 (2×, #501 #505): Normalize native-bound strings with isBlankOrReserved so blank, placeholder and whitespace values do not select unintended auth modes.
9+
- L-0004 (1×, #501): Kernel federation behavior differs from Thrift flags: verify native support and document always-on/ignored flags and federationClientId routing explicitly.
10+
- L-0005 (2×, #505): Fully normalize hosts before domain matching, including scheme, path and port. Keep Azure suffix lists and auth flag semantics aligned across backends or document deliberate differences.
11+
- L-0006 (1×, #509): Mark partially honored backend options as partial support; full-support labels require consistent forwarding and behavior across all relevant flows.
12+
- L-0007 (1×, #509): Verify native capabilities against generated declarations and shipped bindings. Do not assert unobservable published-binary behavior from connector source alone.
13+
- L-0008 (1×, #506): Resolve runtime telemetry identity identically on both backends, including POSIX locale precedence LC_ALL, LC_MESSAGES, then LANG.
14+
- L-0009 (1×, #506): Verify omitted/default branches are reachable; upstream default injection may prevent native defaults from ever taking effect.
15+
- L-0010 (1×, #519): Kernel requires nondefault ports embedded in host; a separate port option is forwarded only by Thrift.
16+
- L-0011 (1×, #528): Empty metadata filters have method/backend-specific semantics. Normalize empty catalog to undefined only where wildcard behavior is intended and verified.
17+
- L-0012 (1×, #533): Required string validation must distinguish non-string values from legitimate empty strings.
18+
- L-0013 (1×, #536): Metadata rewrites must preserve server values for omitted/wildcard request patterns rather than stamping the request pattern onto every row.
19+
- L-0014 (1×, #537): Forward exact namespace identifiers, including null, undefined and empty values, through metadata methods that delegate default resolution to the backend.
20+
- L-0015 (2×, #543): Parser replacements must retain accepted upstream encodings. Exercise the real parser with representative server payloads instead of mocking the method under test.
21+
- L-0016 (1×, #543): Failed cache refreshes retain prior values and their old fetched timestamp so the next access retries promptly.
22+
- L-0017 (2×, #545): Separate LIKE-pattern arguments from exact identifiers per metadata method; wildcard escaping must handle backslash-run parity and already-escaped inputs.
23+
- L-0018 (1×, #568): Share bind-time allowlist validation across backends. Validate DBSQLParameter.value, reject nested wrappers, and permit only supported primitives, Date, Int64, null/undefined or explicit VOID.
24+
- L-0019 (1×, #585): Normalize parameters in shared toSparkParameter. Send explicit DECIMAL(p,s) for decimal aliases and derive Int64 values from the buffer as bigint.
25+
- L-0020 (1×, #589): Reject missing required napi arguments in TypeScript with matching Thrift message/SQLSTATE before opaque native conversion errors.
26+
- L-0021 (1×, #583): Activating formerly ignored configuration changes existing users' behavior. Document consequences and invalidate persisted caches whose inputs no longer match, including OAuth scopes.
27+
- L-0022 (1×, #588): Match host/URL normalization across backends for slashes, embedded ports and IPv6; compare edge cases on both before changing either.
28+
29+
## Native packages and public compatibility
30+
- L-0023 (4×, #505 #513 #514): New native fields need published binding support. Land router capability/version checks and all platform optionalDependency pins together; source-only KERNEL_REV bumps or accepted TypeScript fields do not ship support.
31+
- L-0024 (2×, #514 #506 #528): Regenerate native index.d.ts from the pinned build and review its contract changes. Mocked JS tests cannot verify ABI behavior or live-server compatibility.
32+
- L-0025 (1×, #514): Changelog entries for source-only native features must state the required follow-up published package bump and reference the kernel change.
33+
- L-0026 (3×, #516 #522 #538): Public package-lock resolved URLs must use registry.npmjs.org after internal-mirror installs; integrity hashes remain content-addressed.
34+
- L-0027 (1×, #523): Check sibling Python/Go driver semantics when changing cross-cutting SQLSTATE, caching or recovery behavior.
35+
- L-0028 (2×, #543 #535): Keep native regeneration/pin changes and unrelated observable behavior changes focused and document each user-facing change separately.
36+
- L-0029 (2×, #535 #594): Published-library overrides and lockfiles do not constrain downstream runtime dependencies. Fix declared ranges and test those ranges instead of claiming local overrides protect consumers.
37+
- L-0030 (1×, #535): Security pins must not downgrade an already patched resolution; verify the advisory applies to the exact package.
38+
- L-0031 (1×, #568): Put backend-shared code in neutral utilities. Preserve deep-import compatibility with deprecated re-export shims and smoke tests when moving modules.
39+
40+
## Errors, logging and telemetry
41+
- L-0032 (1×, #514): Negative tests must assert the intended error shape or message so unrelated warehouse/auth failures cannot satisfy them.
42+
- L-0033 (2×, #523 #592 #587): StatusError structurally implements Error without extending it. Preserve its instance and custom fields; inspect message/sqlState structurally rather than requiring instanceof Error.
43+
- L-0034 (1×, #553): Synthetic Thrift error results must cover initial, directResults and polled status paths, allocate per-operation schemas, and close only real server handles.
44+
- L-0035 (1×, #553): Synthetic metadata must copy exact server column names, including KEQ_SEQ quirks. Cite intentionally matched JDBC behavior and document swallowed cases.
45+
- L-0036 (1×, #563): Thrift error metadata descriptors must match kernel descriptors: non-enumerable, writable and configurable. Read OperationStateError SQLSTATE from response.sqlState.
46+
- L-0037 (2×, #565): Winston File may swallow open errors. Probe writability before adding a transport; tests attach open/error listeners immediately and await setup before closing/removing files.
47+
- L-0038 (1×, #567): Treat presigned URLs as credentials. CloudFetch errors may expose status/code/type only; assert secrets are absent from message, stack and every enumerable payload field.
48+
- L-0039 (1×, #567): Add context by mutating the original error and updating its stack header, preserving identity, metadata, payload and original frames.
49+
- L-0040 (1×, #596): Error telemetry may carry class, SQLSTATE and terminal/retryable status only; exclude messages, stacks, URLs and other free-form error text.
50+
- L-0041 (1×, #608): Decode every napi error, including status/hasMore calls. Any call that may fetch must share fetchChunk's best-effort failure cleanup, with rejecting-fake tests per call site.
51+
- L-0042 (1×, #619): Detect user close/cancel with dedicated persistent intent flags read before cleanup, not lifecycle.isClosed. Fetch-failure cleanup must still close cancelled operations.
52+
53+
## Resources, networking and performance
54+
- L-0043 (1×, #497): Portable Bash with nounset must guard empty-array expansion on older shells and distinguish unset-only defaults from unset-or-empty defaults.
55+
- L-0044 (1×, #513): Skipped before hooks still allow after hooks; gate destructive teardown on completed setup/backup.
56+
- L-0045 (2×, #523): Memoize backend resources per connection and close them explicitly. Close must await pending initialization so late-created resources cannot be orphaned.
57+
- L-0046 (1×, #523): Test exact cache TTL boundaries with fake clocks, including proactive sweeping separately from lazy expiration.
58+
- L-0047 (2×, #529): E2E resources close in finally. Bound both operations and cleanup in hang tests, using timers that do not keep the process alive.
59+
- L-0048 (1×, #529): Configuration tests must assert observable downstream effects, not merely absence of an exception.
60+
- L-0049 (1×, #554): Sanitize CI values entering unquoted SQL identifiers to letters, digits and underscores.
61+
- L-0050 (1×, #569): Type parity fixes must cover both metadata type_name and Arrow fallback mappings; test both through the native-free StatementStub harness.
62+
- L-0051 (1×, log:2026-11-07): Local HTTP download tests must avoid using a connection's HTTPS agent so they exercise the intended response failure.
63+
- L-0052 (1×, #568): Client-side pre-RPC validation needs direct rejection assertions and a unit check that no RPC occurred, rather than an E2E hang harness.
64+
- L-0053 (1×, log:2026-11-11): Thrift complex strings may contain bare date/timestamp literals and invalid JSON. Investigate swallowed parse failures with Arrow disabled when containers become empty.
65+
- L-0054 (2×, #600): Clamp Node timers to 2**31-1 ms. End-to-end cancellation must stop attempts and backoff sleeps, clearing timers and listeners.
66+
- L-0055 (1×, #598): Retry non-idempotent execution only for proven pre-connection errors; connected-socket resets, broken pipes and timeouts may follow server delivery.
67+
- L-0056 (1×, #590): Filter framing, auth and user-agent headers from caller overrides and keep managed-header lists identical across transports.
68+
- L-0057 (1×, #595): ProxyAgent needs TLS options at its top level. Verify proxy TLS/mTLS with a real CONNECT proxy and generated test certificate.
69+
- L-0058 (1×, #577): Merge Arrow result rows with indexed concatChunks copies. Preserve provider batches and track owned leftover slices with offsets.
70+
- L-0059 (1×, #611): Every auxiliary HTTP request, including OAuth, exchange and CloudFetch, must use the connection provider's getAgent to honor proxy/TLS settings.
71+
72+
## Bot workflow and CI
73+
- L-0060 (2×, #499): Use explicit bracket notation for hyphenated dispatch input names and string-typed numeric knobs in workflows also triggered by schedule.
74+
- L-0061 (2×, #499): Omit unused prompt-file keys to use engine defaults; MODEL_ENDPOINT must name concrete serving-endpoints/model/invocations, not anthropic/invocations.
75+
- L-0062 (2×, #499): Respect author-tool restrictions on workflow edits and route blocked fixes to a human. Verify actual remote branch HEAD before reporting a change as pushed.
76+
- L-0063 (1×, #538): osv-scanner ignoreUntil must be an unquoted TOML date literal.
77+
- L-0064 (1×, #566): Scrub JFrog and OIDC request credentials inside the model-driven step; modifying GITHUB_ENV does not unset its inherited environment.
78+
- L-0065 (1×, #566): Build after installs that omit prepare so generated lib/version.ts exists before tests/type checks.
79+
- L-0066 (1×, #566 #562): Serialize branch-editing bot flows with one per-PR concurrency group and restore dependency-setup lockfile rewrites before agent edits.

‎.github/actions/bot-prelude/action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ inputs:
3030
# value to move every bot to a new engine commit; never @main.
3131
description: 'Engine commit SHA (full 40-char) to install.'
3232
required: false
33-
default: 'ac3b08eab993ef14bf997a9bf4c776fa5acb16d8'
33+
default: '60144783c5c3e4c242df9f1f5a0f25cd71cf5f4c'
3434
engine-repo:
3535
description: 'owner/name of the engine repo.'
3636
required: false

‎.github/workflows/engineer-bot-learning.yml‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
1-
# Engineer Bot — learning (retrospective) extraction — DAILY CRON.
2-
#
3-
# Over an adaptive look-back window the engine gathers merged PRs (diff + review
4-
# comments) AND recent engineer-bot author-run console logs ITSELF via the GitHub
5-
# API — no in-workflow context gathering, no per-PR trigger — and if the model
6-
# finds durable, reusable learnings, opens ONE ROLLING PR on a stable branch
7-
# (`ai/learning-pr`), appending a dated section per day until a human merges it.
8-
# Human-gated by design: it NEVER commits the canonical log directly.
9-
#
10-
# Own job (NOT `uses: databricks/databricks-bot-engine/...`): an external repo
11-
# can't resolve the internal engine's reusable workflows ("not found"). It shares
12-
# the SAME prelude the other bots use — ./.github/actions/bot-prelude (tokens +
13-
# Node + pinned engine install) — so the engine pin stays single-sourced in
14-
# bot-prelude's `engine-ref` default (no second SHA to drift).
15-
#
16-
# Opt-in is purely via the `retrospective:` block in .bot/config.yaml + this
17-
# workflow; absent that block the engine phase is a clean no-op.
1+
# Daily journal extraction and lesson distillation in a rolling PR.
2+
# The legacy log is frozen; learning PRs require human review.
183
name: Engineer Bot — Learning
194

205
on:

‎.github/workflows/reviewer-bot.yml‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ jobs:
5757
labels: linux-ubuntu-latest
5858
timeout-minutes: 30
5959
steps:
60-
# Checkout FIRST. Default ref = the PR merge ref on pull_request, the
61-
# default branch on dispatch. persist-credentials:false — the reviewer
62-
# reads this tree via read_paths/grep, so no token may sit in .git/config.
63-
- name: Checkout
60+
# Run trusted workflow code; inspect the resolved PR head separately.
61+
- name: Checkout trusted workflow source
6462
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
6563
with:
64+
ref: ${{ github.event.pull_request.base.sha || github.sha }}
6665
fetch-depth: 0
6766
persist-credentials: false
6867

@@ -114,16 +113,29 @@ jobs:
114113
fi
115114
[[ "$RAW_PR" =~ ^[0-9]+$ ]] || { echo "::error::Invalid pr_number '$RAW_PR'"; exit 1; }
116115
case "$DRY_RUN" in true|false) ;; *) DRY_RUN="true" ;; esac # fail safe
117-
HEAD_SHA=$(gh pr view "$RAW_PR" --repo "$REPO" --json headRefOid -q .headRefOid)
118-
{ echo "pr_number=$RAW_PR"; echo "head_sha=$HEAD_SHA"; echo "dry_run=$DRY_RUN"; } >> "$GITHUB_OUTPUT"
116+
PR_JSON=$(gh api "repos/$REPO/pulls/$RAW_PR")
117+
jq -e --arg repo "$REPO" '.state == "open" and .head.repo.full_name == $repo and .head.repo.fork == false' <<< "$PR_JSON" >/dev/null \
118+
|| { echo "::error::Reviewer requires an open PR from this repository"; exit 1; }
119+
HEAD_SHA=$(jq -r '.head.sha' <<< "$PR_JSON")
120+
BASE_SHA=$(jq -r '.base.sha' <<< "$PR_JSON")
121+
{ echo "pr_number=$RAW_PR"; echo "head_sha=$HEAD_SHA"; echo "base_sha=$BASE_SHA"; echo "dry_run=$DRY_RUN"; } >> "$GITHUB_OUTPUT"
122+
123+
- name: Checkout reviewed PR (read-only)
124+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
125+
with:
126+
ref: ${{ steps.inputs.outputs.head_sha }}
127+
path: review-content
128+
persist-credentials: false
119129

120130
- name: Run reviewer
121131
env:
122132
GH_TOKEN: ${{ steps.prelude.outputs.token }}
123133
GITHUB_REPOSITORY: ${{ github.repository }}
124134
PR_NUMBER: ${{ steps.inputs.outputs.pr_number }}
125135
HEAD_SHA: ${{ steps.inputs.outputs.head_sha }}
136+
PR_BASE_SHA: ${{ steps.inputs.outputs.base_sha }}
126137
DRY_RUN: ${{ steps.inputs.outputs.dry_run }}
138+
REVIEW_CONTENT_ROOT: ${{ github.workspace }}/review-content
127139
REVIEWER_BOT_MODEL_OVERRIDE: databricks-claude-opus-5-5
128140
MODEL_ENDPOINT: https://${{ secrets.DATABRICKS_HOST }}/serving-endpoints/databricks-claude-opus-5-5/invocations
129141
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}

‎.prettierignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ native/kernel/index.js
2222
# conventions, not this repo's prettier profile. Reflowing them would mangle the
2323
# carefully-wrapped prompt text.
2424
.bot
25+
26+
# Engine-managed learning files use the engine's canonical format.
27+
.claude/knowledge/learning-log.md
28+
.claude/knowledge/lessons.md
29+
.claude/knowledge/journal

0 commit comments

Comments
 (0)