agents: forbid compatibility logic for older Bazel versions (#4298) 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.
diff --git a/.agents/rules/rules_python.md b/.agents/rules/rules_python.md index 2bf4c2b..f38ad07 100644 --- a/.agents/rules/rules_python.md +++ b/.agents/rules/rules_python.md
@@ -15,3 +15,9 @@ analysis when `<pkg>` 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 ca84ccd..41d66d8 100644 --- a/.agents/skills/review-code/SKILL.md +++ b/.agents/skills/review-code/SKILL.md
@@ -65,10 +65,9 @@ 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//<pkg>` 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 60c7f2c..8d22ffa 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//<pkg>` 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 = "<pkg>")` 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 ec718e5..f97c93b 100644 --- a/.agents/skills/review-code/review-starlark-prompt.md +++ b/.agents/skills/review-code/review-starlark-prompt.md
@@ -19,5 +19,7 @@ 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 dea8b47..9f673d8 100644 --- a/AGENTS.md +++ b/AGENTS.md
@@ -174,6 +174,9 @@ 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: