From 3f210cdc246cd8a71a1c8c942d4e6bb98dd8999d Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 20 Oct 2026 20:36:05 -0700 Subject: [PATCH] agents: forbid compatibility logic for older Bazel versions Agents sometimes add compatibility logic or feature guards for Bazel versions older than `MINIMUM_BAZEL_VERSION` in `//:version.bzl`. Update workspace rules and code review auditor prompts to forbid compatibility logic, feature guards, or comments targeting Bazel versions older than `MINIMUM_BAZEL_VERSION`, and require verifying the exact introducing Bazel version when guarding newer features. --- .agents/rules/rules_python.md | 6 ++++++ .agents/skills/review-code/SKILL.md | 7 +++---- .agents/skills/review-code/review-rules-python-prompt.md | 7 +++++-- .agents/skills/review-code/review-starlark-prompt.md | 2 ++ AGENTS.md | 3 +++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.agents/rules/rules_python.md b/.agents/rules/rules_python.md index 2bf4c2b206..f38ad07bb3 100644 --- a/.agents/rules/rules_python.md +++ b/.agents/rules/rules_python.md @@ -15,3 +15,9 @@ description: rules_python-specific Bzlmod, PyPI, and rule usage invariants analysis when `` is absent from their `pip.parse()` lockfiles. Package names in `pip.dep(name = "...")` are normalized (hyphens and underscores map to the same name). + +## Minimum Supported Bazel Version +* `//:version.bzl` defines `MINIMUM_BAZEL_VERSION`. Do not add compatibility + logic, feature guards, or comments for older Bazel versions. +* When guarding a feature added after `MINIMUM_BAZEL_VERSION`, verify and + comment the exact Bazel version that introduced it. diff --git a/.agents/skills/review-code/SKILL.md b/.agents/skills/review-code/SKILL.md index ca84ccd1be..41d66d8a3a 100644 --- a/.agents/skills/review-code/SKILL.md +++ b/.agents/skills/review-code/SKILL.md @@ -65,10 +65,9 @@ file from `.agents/skills/review-code/`: 8. **`rules_python` Usage Sub-Agent** (`Role: "rules_python Usage Auditor"`): - Prompt file: `.agents/skills/review-code/review-rules-python-prompt.md` - - Focus: Audits changes against `.agents/rules/rules_python.md` and - `rules_python`-specific Bzlmod and rule usage invariants (e.g., `pip.dep()` - declarations in `MODULE.bazel` for `@pypi//` references under - `python/**`). + - Focus: Audits changes against `.agents/rules/rules_python.md` (e.g., + `pip.dep()` declarations in `MODULE.bazel` and `MINIMUM_BAZEL_VERSION` + bounds). 9. **News Entry Sub-Agent** (`Role: "News Entry Auditor"`): - Prompt file: diff --git a/.agents/skills/review-code/review-rules-python-prompt.md b/.agents/skills/review-code/review-rules-python-prompt.md index 60c7f2ce27..8d22ffa7ed 100644 --- a/.agents/skills/review-code/review-rules-python-prompt.md +++ b/.agents/skills/review-code/review-rules-python-prompt.md @@ -1,12 +1,15 @@ You are a specialized `rules_python` Usage Auditor sub-agent. Your sole task is to audit all changes in `git diff` against `rules_python` -Bzlmod and rule usage invariants: +Bzlmod, Bazel version support, and rule usage invariants: -1. Read and strictly enforce `.agents/rules/rules_python.md` and `AGENTS.md`. +1. Read and strictly enforce `.agents/rules/rules_python.md`, `version.bzl`, and + `AGENTS.md`. 2. Verify that every `@pypi//` target referenced by non-test rules, macros, or `BUILD` files under `python/**` (including default attribute values and `alias` targets) has a corresponding `pip.dep(name = "")` declaration on the non-dev `pip` extension in `MODULE.bazel` (with `"pypi"` in `use_repo(pip, ...)`). +3. Verify no compatibility logic, feature guards, or comments target Bazel + versions older than `MINIMUM_BAZEL_VERSION` in `//:version.bzl`. @.agents/skills/review-code/review-report-format.md diff --git a/.agents/skills/review-code/review-starlark-prompt.md b/.agents/skills/review-code/review-starlark-prompt.md index ec718e59e5..f97c93bda6 100644 --- a/.agents/skills/review-code/review-starlark-prompt.md +++ b/.agents/skills/review-code/review-starlark-prompt.md @@ -19,5 +19,7 @@ in `git diff` against the project's Starlark coding rules and conventions: 9. Verify `config_setting` names start with `is_` (or `_is_` when private). 10. Verify non-obvious workarounds have comments stating the intent, why the direct approach fails, and why the workaround works. +11. Verify no compatibility logic or feature guards target Bazel versions + older than `MINIMUM_BAZEL_VERSION` in `//:version.bzl`. @.agents/skills/review-code/review-report-format.md diff --git a/AGENTS.md b/AGENTS.md index dea8b47413..9f673d82ab 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -174,6 +174,9 @@ This repository contains 3 Bazel bzlmod modules. public API. DO NOT add, remove, or modify these build flags unless specifically instructed to. +`version.bzl` defines `MINIMUM_BAZEL_VERSION`. Do not add compatibility logic +or feature guards for Bazel versions older than `MINIMUM_BAZEL_VERSION`. + `bazel query --output=build` can be used to inspect target definitions. In WORKSPACE mode: