From 77c807a05d842fd9734e0a02a510de93854055b2 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sun, 4 Oct 2026 20:59:35 -0700 Subject: [PATCH] agents: refine Starlark, workspace merge, and CI monitor rules Prevent duplicate Label() definitions, mid-merge stashing issues, and false-positive CI monitor process checks. Require reusing `labels.` from `common_labels.bzl` and preferring `types.is_*` from `@bazel_skylib//lib:types.bzl` in Starlark rules and review prompts, document committing or stashing before `git merge upstream/main`, and use a bracketed character class in `pgrep -af` to avoid matching the subshell command line. --- .agents/rules/starlark.md | 10 ++++++++-- .agents/rules/workspace.md | 5 ++++- .agents/skills/monitor-ci-results/SKILL.md | 9 +++++---- .agents/skills/review-code/review-starlark-prompt.md | 4 ++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.agents/rules/starlark.md b/.agents/rules/starlark.md index bc440b599e..b7dd65961a 100644 --- a/.agents/rules/starlark.md +++ b/.agents/rules/starlark.md @@ -10,8 +10,11 @@ globs: "*.bzl,BUILD,BUILD.bazel,*.bazel" * In macro implementations, internal repository target references **MUST** be canonicalized using `str(Label("//path/to:target"))` so they resolve in the macro's module context rather than the caller's repository context. -* Note that `python/private/common_labels.bzl` defines `labels`, a struct - containing common canonicalized label strings used across the project. +* **Reuse `python/private/common_labels.bzl`**: When a target label is listed in + `python/private/common_labels.bzl` (or shared across multiple `.bzl` files + such as `flags.bzl` and `config_settings.bzl`), load `labels` from + `:common_labels.bzl` and use `labels.` (or `Label(labels.)`) + instead of redefining duplicate `Label("//...")` values. ## Manual Tag on Internal Macro Helper Targets * When macros instantiate internal helper targets (such as private rule targets @@ -61,6 +64,9 @@ globs: "*.bzl,BUILD,BUILD.bazel,*.bazel" ## Code Style & Conventions * **Dict union (`|`)**: Use `|` instead of `dicts.add(...)` from `@bazel_skylib//lib:dicts.bzl` when merging dictionaries. +* **Type Checks (`@bazel_skylib//lib:types.bzl`)**: Prefer `types.is_*` helpers + (e.g., `types.is_dict(x)`, `types.is_list(x)`, `types.is_string(x)`) from + `@bazel_skylib//lib:types.bzl` instead of `type(x)` comparisons. * **Non-Info Provider Naming**: Add `# buildifier: disable=name-conventions` above `provider()` declarations that do not end in `Info` (e.g. `*Fileset`). * **Docstring Formatting Invariants**: Use triple-quoted strings for multi-line diff --git a/.agents/rules/workspace.md b/.agents/rules/workspace.md index b3bb174514..20d8027482 100644 --- a/.agents/rules/workspace.md +++ b/.agents/rules/workspace.md @@ -20,4 +20,7 @@ basis: * When pushing to a checked-out PR branch from an external fork, push explicitly to that remote (`git push HEAD:`). Do not rely on a bare `git push`. - +* When syncing a branch with `upstream/main`, commit or stash local changes + *before* running `git merge upstream/main` and conclude the merge in its own + dedicated commit. Never run `git stash` while `MERGE_HEAD` is active, as + `git stash` clears `MERGE_HEAD`. diff --git a/.agents/skills/monitor-ci-results/SKILL.md b/.agents/skills/monitor-ci-results/SKILL.md index 92b1dca7a6..599caa3c82 100644 --- a/.agents/skills/monitor-ci-results/SKILL.md +++ b/.agents/skills/monitor-ci-results/SKILL.md @@ -12,10 +12,11 @@ or when monitoring CI after PR updates: > launch duplicate monitoring jobs for the same PR. 1. **Check Existing Process**: Check if a monitor script is already running for - **this specific PR** using `pgrep -f "monitor_remote_ci.py "`. Do - NOT use a generic grep without ``, as other active agent - conversations may be monitoring different PRs concurrently. If one is - already running for this PR, do not start another instance. + **this specific PR** using + `pgrep -af "[m]onitor_remote_ci.py "`. Do NOT use a generic grep + without ``, as other active agent conversations may be monitoring + different PRs concurrently. If one is already running for this PR, do not + start another instance. 2. **Launch Monitoring Script**: If no monitor process is active for ``, launch the script in the background: ```bash diff --git a/.agents/skills/review-code/review-starlark-prompt.md b/.agents/skills/review-code/review-starlark-prompt.md index 5386b37a38..3d99f226c7 100644 --- a/.agents/skills/review-code/review-starlark-prompt.md +++ b/.agents/skills/review-code/review-starlark-prompt.md @@ -12,5 +12,9 @@ in `git diff` against the project's Starlark coding rules and conventions: 5. Check multi-line rule/macro doc arguments: use triple-quoted strings (`"""`), and do NOT use trailing backslashes (`\`) on opening triple-quotes. 6. Verify analysis tests use `rules_testing`, not `bazel_skylib`. +7. Ensure shared labels use `labels.` from + `python/private/common_labels.bzl` rather than redefining `Label("//...")`. +8. Prefer `types.is_*` helpers from `@bazel_skylib//lib:types.bzl` over + `type(x)` comparisons. @.agents/skills/review-code/review-report-format.md