From ee9d7e1e757d4204ac2dabb59e491110a993be46 Mon Sep 17 00:00:00 2001 From: Vu Anh Phung Date: Tue, 17 Nov 2026 21:54:40 +0000 Subject: [PATCH 1/3] ci(bot): enable distillation and cross-review Signed-off-by: Vu Anh Phung --- .bot/config.yaml | 32 ++++------- .claude/knowledge/learning-log.md | 47 +++++++++++++--- .claude/knowledge/lessons.md | 59 +++++++++++++++++++++ .github/actions/bot-prelude/action.yml | 2 +- .github/workflows/engineer-bot-learning.yml | 19 +------ .github/workflows/reviewer-bot.yml | 24 ++++++--- 6 files changed, 131 insertions(+), 52 deletions(-) create mode 100644 .claude/knowledge/lessons.md diff --git a/.bot/config.yaml b/.bot/config.yaml index 9082528ac..57fe9bef3 100644 --- a/.bot/config.yaml +++ b/.bot/config.yaml @@ -1,7 +1,4 @@ -# Engineer-bot task config for databricks-sql-python. Loaded by -# databricks_bot_engine.engineer_bot.bot_config.load_bot. The reviewer needs NO -# .bot/config.yaml (its prompts are engine-owned + the optional additive -# .bot/prompts/review/system.md); only the engineer-bot is config-driven. +# Engineer-bot task config and shared retrospective lesson routing. name: databricks_sql_python_bugfix marker_namespace: engineer-bot-python bot_login_prefix: peco-engineer-bot @@ -82,10 +79,6 @@ author: issue_url: ISSUE_URL context_files: - issue_body.txt # {{issue_body}} - # Close the loop: the author phase READS this log (newest-first, capped) into its - # system prompt as accumulated lessons, so retrospective learnings actually steer - # future fixes. MUST match retrospective.log_path below (write half ↔ read half). - knowledge_log: .claude/knowledge/learning-log.md # Engine orchestration for the author phase. `bug-fix` runs the plan → # author_tests → fix pipeline (write a failing test → fix the code → re-run to @@ -95,19 +88,14 @@ author: # system.md, not here. flow: bug-fix -# Daily-cron learning extraction (retrospective flow). Run by engineer-bot-learning.yml -# via `python -m databricks_bot_engine.engineer_bot.retrospective`: over an adaptive -# look-back window the engine ITSELF gathers merged PRs (diff + review comments) AND -# recent engineer-bot author-run logs, and if the model finds durable learnings opens -# ONE rolling PR appending a dated section to log_path. Human-gated — never commits the -# canonical log directly. Omitting this block makes the retrospective a no-op. -# -# No `system_prompt` override: the engine ships the authoritative batch-aware base -# (engineer_prompts.RETRO_SYSTEM_PROMPT); a `.bot/prompts/` override is optional. -# No `context_files` — the daily-cron engine enumerates its own sources via the -# GitHub API (context_files is an AUTHOR-phase key only). +# Both bots receive matching lessons; the old log is a frozen archive. retrospective: - log_path: .claude/knowledge/learning-log.md # MUST match author.knowledge_log above - branch_prefix: ai/learning-pr- # rolling PR lands on the derived stable branch `ai/learning-pr` + log_mode: distill + log_path: .claude/knowledge/learning-log.md + journal_dir: .claude/knowledge/journal + lessons_path: .claude/knowledge/lessons.md + auto_merge_learning_pr: false + author_workflow: engineer-bot.yml + # Keep the legacy append-mode PR (#1018) on its original branch. + branch_prefix: ai/learning-distill-pr- pr_label: engineer-bot-learning - author_workflow: engineer-bot.yml # Track B: which workflow's author runs to mine diff --git a/.claude/knowledge/learning-log.md b/.claude/knowledge/learning-log.md index abadcb97b..f6548689a 100644 --- a/.claude/knowledge/learning-log.md +++ b/.claude/knowledge/learning-log.md @@ -1,10 +1,9 @@ -# Engineer-bot learning log +# Frozen learning archive — databricks-sql-python -Durable, reusable engineering learnings distilled by the daily retrospective -(`engineer-bot-learning.yml` → `databricks_bot_engine.engineer_bot.retrospective`). -Each daily run appends one dated section of 0..N learnings to a single rolling PR -until a human merges it. The engineer author phase reads this log (see -`.bot/config.yaml` `author.knowledge_log`) so past lessons steer future fixes. +Preserves the entries from PR #1018 at +`257decd1ca0298ec524b94e70a2db957eb9970a7` before migration to distill mode. +New daily entries belong in `journal/`; bots receive distilled rules from +`lessons.md`. This archive is never updated or injected into bot prompts. ## Entries @@ -178,4 +177,40 @@ until a human merges it. The engineer author phase reads this log (see - **Context:** PR #1004 bumped OSV-Scanner from v2.3.8 to v2.7.0 by find-and-replacing the version string. That also changed comments claiming "vX doesn't support per-package CVE scoping" without checking whether the claim still holds, and the reviewer flagged it. A stale claim can leave suppressions broader than they need to be. **Rule:** When bumping a tool or dependency version, never find-and-replace the version inside capability claims ("vX does not support Y"). Re-check each claim against the new version's docs, then update the claim or the config it justifies. +### 2026-11-10: learnings since 2026-11-09T17:26:03Z +- **Context:** PR #1013 (#629) made inline params render a sequence directly after `IN` as `(1,2,3)` instead of `ARRAY(1,2,3)`. The reviewer noticed that `_renders_as_array` treats any non-`str` `Sequence` as list-able, and that includes `bytes`/`bytearray`. Before the change, `x IN %s` with bytes rendered as `IN ARRAY(97,98,99)`, which Spark rejected with a loud `PARSE_SYNTAX_ERROR`. After it, the query became valid SQL and quietly matched the wrong rows. The fix left bytes out of the IN-list path. + **Rule:** When you widen which input types take a new rendering or conversion path, list the types that used to fail loudly (bytes, str, sets, empty containers) and check that none of them now produce valid but wrong output. Exclude those types on purpose and pin each one with a unit test, because a loud error that turns into a silent wrong result is a regression. +- **Context:** In PR #1013, `test_probe_shaped_string_value_is_not_a_probe` was meant to guard the nonce check in `_markers_following_in`. It could never fail: an earlier step swaps every escaped string value for `''` during the probe pass, so the probe-shaped text never reached the code the nonce check protects. The test passed whether or not the check existed. + **Rule:** When a test is meant to guard one specific check, remove or break that check and confirm the test fails (a manual mutation check). Make sure another mechanism earlier in the pipeline doesn't neutralize the input first. If one does, feed the input in where it actually reaches the guarded code, or patch the dependency the check relies on (for example `secrets.token_hex`). + +### 2026-11-11: learnings since 2026-11-10T17:25:56Z +- **Context:** PR #1017 made `Connection.http_client` `Optional` (it is `None` for explicit `use_kernel=True`) and added `assert self.connection.http_client is not None` in the staging PUT/GET/REMOVE handlers in `client.py`. The reviewer pointed out that `python -O` strips `assert`. If a future kernel change made staging reachable, users would get an opaque `AttributeError: 'NoneType' object has no attribute 'request'` instead of a clear error. + **Rule:** Don't use `assert` to enforce a runtime invariant on an Optional attribute, even when it also narrows the type for mypy. `python -O` removes it. Use a small helper that raises a descriptive driver error (`NotSupportedError`/`ProgrammingError`, e.g. "staging operations are not supported with use_kernel=True"). That keeps mypy narrowing and still works under `-O`. +- **Context:** PR #1022 was titled as fixing kernel TLS certificate errors, but it only bumped `KERNEL_REV`. That file only sets which kernel commit `kernel-e2e.yml` builds from source for CI. Users installing the `[kernel]` extra still resolve the PyPI release allowed by `pyproject.toml` (`^1.4.0`), which predates the fix. The reviewer also noted there was no in-repo assertion (e.g. in `tests/e2e/test_kernel_tls.py`) to catch the behavior regressing on a later pin bump. + **Rule:** Bumping `KERNEL_REV` changes CI only and ships nothing to users. A kernel-side fix reaches users only after a kernel PyPI release that includes it plus a matching floor bump in `pyproject.toml`/`poetry.lock`. Don't call a pin bump a user-facing fix, and add an in-repo e2e assertion for the behavior so later pin bumps can't silently regress it. + +### 2026-11-12: learnings since 2026-11-11T17:26:04Z +- **Context:** PR #1020 switched the Thrift backend to `TBinaryProtocolAccelerated` so replies decode in C. Two things came up. First, that class falls back to pure Python without any error when `thrift.protocol.fastbinary` isn't built, and it only takes the C path when the transport is a `CReadableTransport`, so a plain round-trip test passes without ever running the C decoder. The fix was a test, skipped when fastbinary is absent, that wraps `protocol._fast_decode` with `Mock(wraps=...)` and asserts it was called. Second, the accelerated protocol also changes request *encoding*, and the C encoder rejects structs nested deeper than about 64 levels (for example native array parameters 62+ deep). So the client was built as `TCLIService.Client(accelerated_input, pure_python_output)`, with a test checking that both encoders produce byte-identical requests. + **Rule:** When adopting `TBinaryProtocolAccelerated` (or any optional C-extension fast path), assert the fast path actually ran: skip the test when the extension isn't importable, and wrap or spy the C entry point such as `_fast_decode`. Don't trust a round-trip that also passes on the pure-Python fallback. Also remember the accelerated protocol encodes requests too, and the C encoder has a nesting-depth limit. Decide input and output protocols separately, and pin encoder parity with a byte-equality test. +- **Context:** PR #1020 found that `unsafe_logger.debug("Received response: {}".format(response))` in `thrift_backend.make_request` built the full repr of every Thrift request and response, even though the logger has only a NullHandler by default. For a 100 MiB inline Arrow fetch this made about 400 MB of repr. Peak memory fell from 425 MiB to 200 MiB once the call used lazy `%s` args. + **Rule:** Never pre-format log messages with `.format()` or f-strings when they contain large payloads (requests, responses, result batches). Pass lazy `%s` args (`logger.debug("...: %s", obj)`) so the repr is only built when a handler actually emits the record. Eager formatting costs CPU and memory even when the logger is disabled. +- **Context:** PR #1026 forwarded `telemetry_flush_interval_ms` to the PyO3 kernel `Session`. The PyO3 u64 conversion accepted `True` as 1 ms, and its errors for negative or string values did not name the option. A Python-side check was added before the kernel call: `isinstance(v, bool) or not isinstance(v, int) or v <= 0` raises a `ValueError` that names the option. + **Rule:** When validating an integer option in Python, especially one forwarded to native bindings such as PyO3, explicitly reject `bool`, because `bool` is a subclass of `int` and native int conversions accept `True`/`False` as 1/0. Validate before the native call so the error names the option, rather than surfacing a wrapped conversion error. + +### 2026-11-13: learnings since 2026-11-12T17:25:58Z +- **Context:** PR #1045 added the engineer-bot mention workflow. Its trusted steps ran `python - <<'PY'` and `python -m databricks_bot_engine...` with the PR checkout as the working directory. The reviewer pointed out that stdin and `-m` mode both put cwd at `sys.path[0]`. A PR branch could therefore add a root-level `pathlib.py` or a `databricks_bot_engine/` package and get its code run in a step that holds `GH_TOKEN`/`DATABRICKS_TOKEN`, OIDC env and `$GITHUB_ENV` write access. The fix ran both with `python -I`. + **Rule:** In CI steps that hold secrets or write `$GITHUB_ENV`, never run `python -`, `python -c` or `python -m` with cwd inside an untrusted checkout. Use `python -I` (or `-P`), or `cd` to a neutral directory, so modules planted by the PR can't shadow the stdlib or trusted packages. +- **Context:** PR #1019 made the kernel backend honor `use_cloud_fetch=False` by injecting `cloudfetch_enabled=false` into `session_conf`. The unit tests only checked that the key reached a fake `Session`. The reviewer noted that CI would stay green if the kernel or server stopped honoring the key. The fix added a credential-gated e2e test: it fetches a large result through a proxy that blocks non-workspace hosts, verifies every row with a digest, and runs an enabled-CloudFetch control to show the same query normally takes the cloud path. + **Rule:** When a fix works by forwarding a config key that another component (kernel or server) must honor, unit tests that check forwarding are not enough. Add a live test that checks the actual behavior, and include a positive control showing the opposite setting changes the outcome, so the test can't pass vacuously. + +### 2026-11-14: learnings since 2026-11-13T17:25:57Z +- **Context:** PR #1055 replaced the layered telemetry no-op patches in the e2e retry tests (`tests/e2e/common/retry_test_mixins.py`). Patching `HTTPSConnectionPool._get_conn`/`_validate_conn` at class level also caught background telemetry and flush-thread requests, which inflated `call_count` and used up `side_effect` response lists. The fix makes the mock dispatch only on the calling test thread. Review then found a second leak: urllib3's `urlopen` hands the fake connection (and on 1.26 the result of `conn.close()`, which is a child mock) to the real `_put_conn`, so MagicMock connections landed in the shared pool queue. Real threads could pick them up later, including in later tests. + **Rule:** When mocking urllib3 pool internals in tests, scope the mock to the test thread and patch both sides of the pool. Route `_get_conn` and `_put_conn` by thread so fake connections, their child mocks and `None` never reach the real `pool.pool` queue. Set the mocked `close()` to return `None` so urllib3 1.26's `conn = conn and conn.close()` path behaves like it does with a real connection. Prove the isolation with a shared-pool, concurrent-thread regression test, not separate pool instances. +- **Context:** PR #1024 cached the result of `inspect.signature(_kernel.Session)` in a module-level global keyed on the `Session` class identity, filled under a double-checked lock. The reviewer pointed out that the tests only passed because each one installed a brand-new `Session` class. A test that reused a shared `Session` or patched only `inspect.signature` would quietly read a value cached by an earlier test, and `assert_called_once` checks would depend on test order. + **Rule:** When adding a process-global cache (memoized introspection, singleton lookup), add an autouse fixture that resets it (`monkeypatch.setattr(module, "_CACHE", None)`) in the tests that exercise it. Each test should start cold instead of relying on cache-key changes to force a refresh. + +### 2026-11-17: learnings since 2026-11-16T17:27:13Z +- **Context:** PR #1016 fixed `cursor.rowcount` staying at -1 after async DML. The sync path gets `numModifiedRows` from the execute response, but the async path (`get_execution_result`) only calls Thrift `FetchResults`, which does not carry that field. The count is only on `TGetOperationStatusResp`, and `get_query_state` had been reducing that response to a `CommandState` and dropping the count. The fix caches the SUCCEEDED status response per `CommandId` instance in a `WeakKeyDictionary`. `get_execution_result` reuses that cached response, and polls again (with the error/closed-state check) only when a caller resumes directly. The count is accepted only when the state is `FINISHED_STATE`. Reviewers also flagged that the kernel async path read the count differently from the sync path, so both now go through one shared `_read_num_modified_rows` helper. + **Rule:** When the sync execute path has some result metadata (rowcount/numModifiedRows, staging flags), check that the async `get_execution_result` path carries it too. Thrift `FetchResults` has no `numModifiedRows`, so take it from the terminal `TGetOperationStatusResp` that was already polled, not from an extra RPC, and trust it only in `FINISHED_STATE`. Read the value through the same helper the sync path uses so missing, callable or raising getters behave the same way on both paths. + --- *Add new entries above this line (oldest→newest); newest sections sort to the bottom.* --- diff --git a/.claude/knowledge/lessons.md b/.claude/knowledge/lessons.md new file mode 100644 index 000000000..85e2a5a6b --- /dev/null +++ b/.claude/knowledge/lessons.md @@ -0,0 +1,59 @@ +# Lessons + + + +## Backend contracts and configuration + +- L-0001 (1×, #1018): When changing cursor.description type_code strings, update every downstream conversion branch that matches them. +- L-0002 (1×, #560): Recover Spark SQL types sharing a Thrift TTypeId from Arrow field Spark:DataType:SqlName metadata. +- L-0003 (4×, #910 #921 #919): New resolver branches must preserve mutual-exclusion checks and forward shared options on every applicable path; directly test forwarding even when omission has a safe default. +- L-0004 (2×, #916 #922): Use Thrift as the reference when checking kernel value semantics; deprecated SEA behavior can differ. +- L-0005 (1×, #914): OAuth redirect ports and client IDs are coupled. Override the default port range only when the custom client and port are both supplied. +- L-0006 (3×, #914 #931 #933): Document backend-specific defaults, sentinels, filter normalization and deliberate parity differences in code, API docs and changelog. +- L-0007 (2×, #913 #932): Kernel options take effect only when _create_backend forwards them. Explicitly pass connector defaults when they differ from native defaults. +- L-0008 (2×, #920): Public connect-parameter deprecations use logger.warning. Recommend kernel where supported; SEA remains necessary for RT/Lakehouse warehouse types that reject Thrift. +- L-0009 (2×, #922 #919): When delegating normalization to the kernel/server, retain boundary tests for zero, negative and None values and remove obsolete arguments, imports and documentation. +- L-0010 (1×, #932): Enable typed Optional[bool] options only on explicit True; truthy strings such as False or 0 must not accidentally enable a feature. +- L-0011 (6×, #932 #925 #940): Gate optional Session kwargs through _kernel_session_accepts_kwarg and fail closed on introspection failure. Default-off options must preserve older wheels; explicit requirements need a released dependency floor and accurate support docs. +- L-0012 (2×, #930): Verify flags against materialized values and cursor.description on each backend. Shared client-side conversion toggles differ from options handled only by a backend. +- L-0013 (2×, #925 #933 #940): Test PyO3 kwarg filtering with fixed-signature fakes or real wheels; permissive MagicMock kwargs hide incompatible argument forwarding. +- L-0014 (1×, #925): Paths mirroring a routing decision must reuse its predicate exactly; truthiness and identity checks can disagree for non-bool inputs. +- L-0015 (1×, #948): Preserve Thrift's implicit OAuth default on kernel routing only when no explicit credential shape already determines the auth flow. +- L-0016 (1×, #948): After retries or fallback mutate kwargs, attribute failures and cleanup to the backend object that actually failed. +- L-0017 (1×, #948): Scope recovery-marker error translation to the RPC the recovery layer handles; unrelated calls must retain meaningful errors. +- L-0018 (1×, #948): Anchor path extractors to valid path shapes; leading greedy wildcards can accept malformed IDs and contaminate cache keys. +- L-0019 (1×, #951): TLS certfile may contain both certificate and key; reject keyfile without certfile. Validate each identity file separately for readable, non-empty contents before load_cert_chain. +- L-0020 (1×, #974): Before replacing permissive wire parsing with typed parsing, verify real server representations and test case, quoting and numeric/bool variants. +- L-0021 (1×, #985): SQL LIKE escape handling depends on preceding backslash-run parity; a one-character negative lookbehind cannot establish JDBC equivalence. +- L-0022 (1×, #1026): Reject bool explicitly when validating integer options before native conversion, so True/False cannot silently become 1/0. +## Results and lifecycle + +- L-0023 (2×, #1019): Verify server metadata and forwarded configuration behavior with live tests and an opposite-setting positive control; fabricated metadata or forwarding-only unit tests cannot establish server behavior. +- L-0024 (2×, #923): Keep the original async owning handle for telemetry-producing polls/results. Reserve retained handles against concurrent use and use attach-by-id for resume/refetch or concurrent fallback. +- L-0025 (2×, #907): Lazy imports must preserve every formerly exported name and patch seam. Import-isolation subprocess tests need distinct success/error sentinels so import crashes cannot satisfy assertions. +- L-0026 (1×, #975): Dependency upgrades may tighten size/depth defaults; explicitly set relied-on limits and test them. +- L-0027 (1×, #990): Pair result columns with Arrow fields by position to preserve duplicate aliases; use names only as a documented malformed/short-schema fallback. +- L-0028 (2×, #995): Use plain concat_tables when chunk schemas match, preserving valid duplicate column names. Enable promote/promote_options only for genuinely differing schemas. +- L-0029 (1×, #1018): Preserve NaN, NULL and positive/negative infinity distinctly through pandas conversion, comparing nullable-dtype behavior with the as_py path. +- L-0030 (1×, #1013): When broadening rendering input types, explicitly test formerly rejected strings, bytes, sets and empty containers so loud failures cannot become silently wrong values. +- L-0031 (1×, #1017): Enforce runtime Optional-state invariants with descriptive driver errors; Python -O removes assert statements. +- L-0032 (1×, #1022): KERNEL_REV changes CI source only. Shipping a kernel fix requires a released wheel and matching packaging floor/lock update, plus an in-repo E2E regression. +- L-0033 (1×, #1020): Prove optional C acceleration actually executes and skip when unavailable. Choose input/output protocols separately and verify encoded bytes and nesting limits against the fallback. +- L-0034 (1×, #1016): Carry sync result metadata into async get_execution_result. Read numModifiedRows from the existing terminal FINISHED_STATE status response via the shared helper, avoiding an extra RPC. +## Logging and concurrency + +- L-0035 (2×, #924): pyo3-log caches effective logger levels. Reset its cache after relevant level changes/session setup and isolate cached state in tests. +- L-0036 (3×, #947): Logging filters that rewrite record.args must separately handle None, positional tuples and mapping dictionaries, with coverage for all three. +- L-0037 (1×, #974): Keep shared locks out of blocking network I/O; coordinate in-flight work without serializing unrelated callers on a slow fetch. +- L-0038 (1×, #974): Do not retain singleton executors/clients that other paths can destroy and replace; resolve them at use time or handle shutdown races. +- L-0039 (1×, #1020): Log large payloads with lazy percent-format arguments; eager f-strings/format calls consume CPU and memory even when the logger is disabled. +- L-0040 (1×, #1055): urllib3 pool mocks must route both _get_conn and _put_conn by test thread. Mock close returning None and prove isolation with concurrent users of one shared pool. +- L-0041 (1×, #1024): Reset process-global caches with autouse fixtures in tests that exercise them; each test must start cold. +## Verification and bot workflow + +- L-0042 (1×, #905 #906): Bot MODEL_ENDPOINT must name the concrete model serving-endpoints/model/invocations URL; the anthropic/invocations form produces an invalid translated CLI path. +- L-0043 (3×, #930): Keep planning read-only, structured output concise, and PR summaries aligned with the complete final diff. +- L-0044 (1×, #1018): Performance tests should count calls to the real expensive operation through a spy and assert deterministic bounds instead of live wall-clock timings. +- L-0045 (1×, #1004): Recheck capability claims after tool upgrades; replacing version numbers inside old support statements does not validate them. +- L-0046 (1×, #1013): Confirm targeted regression tests fail when their guarded check is removed; inject inputs where earlier sanitization cannot neutralize the case. +- L-0047 (1×, #1045): Secret-bearing CI steps must run Python isolated or from a neutral directory, preventing checkout modules from shadowing trusted imports. diff --git a/.github/actions/bot-prelude/action.yml b/.github/actions/bot-prelude/action.yml index 9ad7a4525..4db458d90 100644 --- a/.github/actions/bot-prelude/action.yml +++ b/.github/actions/bot-prelude/action.yml @@ -31,7 +31,7 @@ inputs: # value to move every bot to a new engine commit; never @main. description: 'Engine commit SHA (full 40-char) to install.' required: false - default: 'ac3b08eab993ef14bf997a9bf4c776fa5acb16d8' + default: '60144783c5c3e4c242df9f1f5a0f25cd71cf5f4c' engine-repo: description: 'owner/name of the engine repo.' required: false diff --git a/.github/workflows/engineer-bot-learning.yml b/.github/workflows/engineer-bot-learning.yml index 0d9340ae4..9d9d75377 100644 --- a/.github/workflows/engineer-bot-learning.yml +++ b/.github/workflows/engineer-bot-learning.yml @@ -1,20 +1,5 @@ -# Engineer Bot — learning (retrospective) extraction — DAILY CRON. -# -# Over an adaptive look-back window the engine gathers merged PRs (diff + review -# comments) AND recent engineer-bot author-run console logs ITSELF via the GitHub -# API — no in-workflow context gathering, no per-PR trigger — and if the model -# finds durable, reusable learnings, opens ONE ROLLING PR on a stable branch -# (`ai/learning-pr`), appending a dated section per day until a human merges it. -# Human-gated by design: it NEVER commits the canonical log directly. -# -# 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). -# -# 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. +# Daily journal extraction and lesson distillation in a rolling PR. +# The legacy log is frozen; learning PRs require human review. name: Engineer Bot — Learning on: diff --git a/.github/workflows/reviewer-bot.yml b/.github/workflows/reviewer-bot.yml index ee7e90381..91f1ff724 100644 --- a/.github/workflows/reviewer-bot.yml +++ b/.github/workflows/reviewer-bot.yml @@ -58,12 +58,11 @@ jobs: labels: [linux-ubuntu-latest] timeout-minutes: 30 steps: - # Checkout FIRST. Default ref = the PR merge ref on pull_request, the - # default branch on dispatch. persist-credentials:false — the reviewer - # reads this tree via read_paths/grep, so no token may sit in .git/config. - - name: Checkout + # Run trusted workflow code; inspect the resolved PR head separately. + - name: Checkout trusted workflow source uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: + ref: ${{ github.event.pull_request.base.sha || github.sha }} fetch-depth: 0 persist-credentials: false @@ -106,8 +105,19 @@ jobs: fi [[ "$RAW_PR" =~ ^[0-9]+$ ]] || { echo "::error::Invalid pr_number '$RAW_PR'"; exit 1; } case "$DRY_RUN" in true|false) ;; *) DRY_RUN="true" ;; esac # fail safe - HEAD_SHA=$(gh pr view "$RAW_PR" --repo "$REPO" --json headRefOid -q .headRefOid) - { echo "pr_number=$RAW_PR"; echo "head_sha=$HEAD_SHA"; echo "dry_run=$DRY_RUN"; } >> "$GITHUB_OUTPUT" + PR_JSON=$(gh api "repos/$REPO/pulls/$RAW_PR") + jq -e --arg repo "$REPO" '.state == "open" and .head.repo.full_name == $repo and .head.repo.fork == false' <<< "$PR_JSON" >/dev/null \ + || { echo "::error::Reviewer requires an open PR from this repository"; exit 1; } + HEAD_SHA=$(jq -r '.head.sha' <<< "$PR_JSON") + BASE_SHA=$(jq -r '.base.sha' <<< "$PR_JSON") + { echo "pr_number=$RAW_PR"; echo "head_sha=$HEAD_SHA"; echo "base_sha=$BASE_SHA"; echo "dry_run=$DRY_RUN"; } >> "$GITHUB_OUTPUT" + + - name: Checkout reviewed PR (read-only) + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + ref: ${{ steps.inputs.outputs.head_sha }} + path: review-content + persist-credentials: false - name: Run reviewer env: @@ -115,7 +125,9 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} PR_NUMBER: ${{ steps.inputs.outputs.pr_number }} HEAD_SHA: ${{ steps.inputs.outputs.head_sha }} + PR_BASE_SHA: ${{ steps.inputs.outputs.base_sha }} DRY_RUN: ${{ steps.inputs.outputs.dry_run }} + REVIEW_CONTENT_ROOT: ${{ github.workspace }}/review-content REVIEWER_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 }} From c19468a0a4e1a8c13799e25d28ee63ffa2c41b28 Mon Sep 17 00:00:00 2001 From: Vu Anh Phung Date: Tue, 17 Nov 2026 22:07:01 +0000 Subject: [PATCH 2/3] docs(bot): clarify lesson provenance and formatting Signed-off-by: Vu Anh Phung --- .claude/knowledge/learning-log.md | 3 +++ .claude/knowledge/lessons.md | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.claude/knowledge/learning-log.md b/.claude/knowledge/learning-log.md index f6548689a..d2cedf462 100644 --- a/.claude/knowledge/learning-log.md +++ b/.claude/knowledge/learning-log.md @@ -5,6 +5,9 @@ Preserves the entries from PR #1018 at New daily entries belong in `journal/`; bots receive distilled rules from `lessons.md`. This archive is never updated or injected into bot prompts. +Lesson counts measure archived occurrences, not distinct PRs. A +`log:YYYY-MM-DD` source points to that dated section below, including its author-run IDs. + ## Entries ### 2026-08-13: learnings since 2026-08-04T18:01:30Z diff --git a/.claude/knowledge/lessons.md b/.claude/knowledge/lessons.md index 85e2a5a6b..d7853a5eb 100644 --- a/.claude/knowledge/lessons.md +++ b/.claude/knowledge/lessons.md @@ -3,8 +3,7 @@ ## Backend contracts and configuration - -- L-0001 (1×, #1018): When changing cursor.description type_code strings, update every downstream conversion branch that matches them. +- L-0001 (1×, log:2026-08-13): When changing cursor.description type_code strings, update every downstream conversion branch that matches them. - L-0002 (1×, #560): Recover Spark SQL types sharing a Thrift TTypeId from Arrow field Spark:DataType:SqlName metadata. - L-0003 (4×, #910 #921 #919): New resolver branches must preserve mutual-exclusion checks and forward shared options on every applicable path; directly test forwarding even when omission has a safe default. - L-0004 (2×, #916 #922): Use Thrift as the reference when checking kernel value semantics; deprecated SEA behavior can differ. @@ -26,22 +25,22 @@ - L-0020 (1×, #974): Before replacing permissive wire parsing with typed parsing, verify real server representations and test case, quoting and numeric/bool variants. - L-0021 (1×, #985): SQL LIKE escape handling depends on preceding backslash-run parity; a one-character negative lookbehind cannot establish JDBC equivalence. - L-0022 (1×, #1026): Reject bool explicitly when validating integer options before native conversion, so True/False cannot silently become 1/0. -## Results and lifecycle +## Results and lifecycle - L-0023 (2×, #1019): Verify server metadata and forwarded configuration behavior with live tests and an opposite-setting positive control; fabricated metadata or forwarding-only unit tests cannot establish server behavior. - L-0024 (2×, #923): Keep the original async owning handle for telemetry-producing polls/results. Reserve retained handles against concurrent use and use attach-by-id for resume/refetch or concurrent fallback. - L-0025 (2×, #907): Lazy imports must preserve every formerly exported name and patch seam. Import-isolation subprocess tests need distinct success/error sentinels so import crashes cannot satisfy assertions. - L-0026 (1×, #975): Dependency upgrades may tighten size/depth defaults; explicitly set relied-on limits and test them. - L-0027 (1×, #990): Pair result columns with Arrow fields by position to preserve duplicate aliases; use names only as a documented malformed/short-schema fallback. - L-0028 (2×, #995): Use plain concat_tables when chunk schemas match, preserving valid duplicate column names. Enable promote/promote_options only for genuinely differing schemas. -- L-0029 (1×, #1018): Preserve NaN, NULL and positive/negative infinity distinctly through pandas conversion, comparing nullable-dtype behavior with the as_py path. +- L-0029 (1×, log:2026-10-30): Preserve NaN, NULL and positive/negative infinity distinctly through pandas conversion, comparing nullable-dtype behavior with the as_py path. - L-0030 (1×, #1013): When broadening rendering input types, explicitly test formerly rejected strings, bytes, sets and empty containers so loud failures cannot become silently wrong values. - L-0031 (1×, #1017): Enforce runtime Optional-state invariants with descriptive driver errors; Python -O removes assert statements. - L-0032 (1×, #1022): KERNEL_REV changes CI source only. Shipping a kernel fix requires a released wheel and matching packaging floor/lock update, plus an in-repo E2E regression. - L-0033 (1×, #1020): Prove optional C acceleration actually executes and skip when unavailable. Choose input/output protocols separately and verify encoded bytes and nesting limits against the fallback. - L-0034 (1×, #1016): Carry sync result metadata into async get_execution_result. Read numModifiedRows from the existing terminal FINISHED_STATE status response via the shared helper, avoiding an extra RPC. -## Logging and concurrency +## Logging and concurrency - L-0035 (2×, #924): pyo3-log caches effective logger levels. Reset its cache after relevant level changes/session setup and isolate cached state in tests. - L-0036 (3×, #947): Logging filters that rewrite record.args must separately handle None, positional tuples and mapping dictionaries, with coverage for all three. - L-0037 (1×, #974): Keep shared locks out of blocking network I/O; coordinate in-flight work without serializing unrelated callers on a slow fetch. @@ -49,11 +48,11 @@ - L-0039 (1×, #1020): Log large payloads with lazy percent-format arguments; eager f-strings/format calls consume CPU and memory even when the logger is disabled. - L-0040 (1×, #1055): urllib3 pool mocks must route both _get_conn and _put_conn by test thread. Mock close returning None and prove isolation with concurrent users of one shared pool. - L-0041 (1×, #1024): Reset process-global caches with autouse fixtures in tests that exercise them; each test must start cold. -## Verification and bot workflow +## Verification and bot workflow - L-0042 (1×, #905 #906): Bot MODEL_ENDPOINT must name the concrete model serving-endpoints/model/invocations URL; the anthropic/invocations form produces an invalid translated CLI path. - L-0043 (3×, #930): Keep planning read-only, structured output concise, and PR summaries aligned with the complete final diff. -- L-0044 (1×, #1018): Performance tests should count calls to the real expensive operation through a spy and assert deterministic bounds instead of live wall-clock timings. +- L-0044 (1×, log:2026-10-30): Performance tests should count calls to the real expensive operation through a spy and assert deterministic bounds instead of live wall-clock timings. - L-0045 (1×, #1004): Recheck capability claims after tool upgrades; replacing version numbers inside old support statements does not validate them. - L-0046 (1×, #1013): Confirm targeted regression tests fail when their guarded check is removed; inject inputs where earlier sanitization cannot neutralize the case. - L-0047 (1×, #1045): Secret-bearing CI steps must run Python isolated or from a neutral directory, preventing checkout modules from shadowing trusted imports. From 5ae5dcfdcf9ff340dd76f6f4953509868b1f55ab Mon Sep 17 00:00:00 2001 From: Vu Anh Phung Date: Tue, 17 Nov 2026 23:02:37 +0000 Subject: [PATCH 3/3] ci: keep Kernel E2E in its workflow check suite Signed-off-by: Vu Anh Phung --- .github/workflows/kernel-e2e.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/kernel-e2e.yml b/.github/workflows/kernel-e2e.yml index 59da13648..5a2dac03b 100644 --- a/.github/workflows/kernel-e2e.yml +++ b/.github/workflows/kernel-e2e.yml @@ -54,6 +54,22 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + # Keep the required result in this workflow's suite. Manually posted checks + # can attach to an unrelated suite that a later run supersedes. + kernel-e2e-result: + name: Kernel E2E + if: always() + needs: [skip-kernel-e2e-pr, detect-changes, run-kernel-e2e, auto-pass-merge-queue] + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + permissions: {} + steps: + - name: Check kernel test outcomes + env: + RESULTS: ${{ toJSON(needs.*.result) }} + run: jq -e 'all(.[]; . == "success" or . == "skipped")' <<< "$RESULTS" + # ─────────────────────────────────────────────────────────────── # Security: auto-remove `kernel-e2e` label on new commits, same as # trigger-integration-tests.yml.