Skip to content

Tighten agent docs, review skill, and guardrails - #3315

Merged
CydeWeys merged 1 commit into
google:masterfrom
CydeWeys:centralize-pr-review-rules
Dec 5, 2026
Merged

CydeWeys merged 1 commit into
google:masterfrom
CydeWeys:centralize-pr-review-rules

Conversation

@CydeWeys

@CydeWeys CydeWeys commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

After migrating repository skills to .agents/skills/ (#3295), adding scoped AGENTS.md guides (#3311), and adding the on-demand pr-review skill (#3313), a full audit of all agent instructions and skill scripts uncovered remaining duplication, always-on context bloat, mis-routed/stale rules, and four concrete guardrail bugs: check_diff.py silently missed Valkey Protostuff fields on @MappedSuperclass parents and inline-annotated fields, core/AGENTS.md scoped the Netty retainedDuplicate() rule away from proxy/ (its primary caller), run_rewrite.sh silently exited 0 on Gradle failure without cleanup traps, and check_diff_test.py never ran in presubmits. Centralizing review rules into pr-review, moving core/-only rules out of root GEMINI.md, correcting stale Gradle/Spotless instructions, and fixing the guardrail scripts close these blind spots while cutting always-on GEMINI.md by 22%.

Summary of Changes

  • Centralize PR review rules in .agents/skills/pr-review/SKILL.md:
    • GEMINI.md (18,118 B -> 14,071 B): replaces duplicated Processing PR Feedback and PR Description Sync bullets with a 1-line pointer to .agents/skills/pr-review/SKILL.md.
    • .agents/skills/pr-polisher/SKILL.md: removes Step 9 (paginated PR review comment fetch), renumbers Step 10 -> 9, and adds pr-review negative routing to frontmatter description.
    • console-webapp/AGENTS.md: removes ## Review Calibration, moving Shared State and Build & Screenshots into pr-review while keeping Nested @if as an Angular template authoring rule.
    • core/AGENTS.md: trims the review-only parenthetical from JPQL Timestamp Ordering.
    • .agents/skills/pr-review/SKILL.md: adds ### Nomulus Review Calibration under Conducting PR Reviews.
  • Re-scope always-on rules and fix stale build/formatting docs:
    • Moves Netty Retry Buffers (ByteBufHolder.retainedDuplicate()) out of core/AGENTS.md into GEMINI.md's Netty lifecycle bullet so proxy/, networking/, prober/, and core/ all load it; removes the verbatim duplicated console-webapp sentence from GEMINI.md.
    • Moves core/-only idioms (CLI/Beam/TestRegistryToolComponent, model layering, @GetterDelegate sets, partial JSON updates, JAXB optional attributes, allocation tokens, Console actions, CSV output, time-projected entities, Valkey Protostuff compatibility, and async pipeline boundaries) from GEMINI.md into core/AGENTS.md, fixes exact monthly_logs.sql / monthly_logs_test.sql paths, and condenses 2-PR Schema Split in GEMINI.md.
    • Corrects spotlessApply (*.gradle only) vs. javaIncrementalFormatApply (Java formatting & import order) and checkstyleMain/checkstyleTest, and replaces backend compile commands that triggered Docker :core:buildToolImage or console-webapp npmInstallDeps across GEMINI.md, pr-polisher, and java-ast-refactoring.
  • Harden guardrail scripts and wire unit tests into presubmits:
    • .agents/skills/pr-polisher/scripts/check_diff.py (+ SKILL.md & check_diff_test.py): adds the 4 missing Protostuff @MappedSuperclass parents (UpdateAutoTimestampEntity, GracePeriodBase, DomainDsDataBase, BaseTransferObject), strips leading inline @Annotation(...) tokens instead of skipping annotated field lines, skips Java comment lines in anti-pattern checks (while still catching /* package */), fixes fqn_pattern capturing so full FQNs print, scopes check_commit_message() [OK] to local errors, expands internal-leak checks to cover //depot/configs and cl/<digits>, and maintains Python 3.7-3.9 compatibility (no backslashes in f-string expressions or parenthesized multi-item with blocks; 15/15 unit tests).
    • config/presubmits.py: adds verify_agent_scripts() so check_diff_test.py runs automatically on ./gradlew runPresubmits whenever .agents/ is present in the workspace (skipping cleanly in non-dotfile staged build environments).
    • .agents/skills/java-ast-refactoring/scripts/run_rewrite.sh: adds set -euo pipefail, an EXIT cleanup trap for temporary files, and portable top-level ^name: YAML extraction via awk.

Verification

  • python3 .agents/skills/pr-polisher/scripts/check_diff_test.py -v: 15/15 passed (verified Python 3.7-3.9 syntax compatibility).
  • python3 .agents/skills/pr-polisher/scripts/check_diff.py: 0 errors, 0 warnings (spotlessCheck and javaIncrementalFormatCheck passed).
  • ./gradlew --no-daemon runPresubmits: BUILD SUCCESSFUL (verified both with .agents/ present and in a staged workspace omitting .agents/).
  • Strict PyYAML parse OK on all .agents/skills/*/SKILL.md files, bash -n on run_rewrite.sh, and 0 lines > 80 chars in core/AGENTS.md and console-webapp/AGENTS.md.

BUG=http://b/593117423


This change is Reviewable

@CydeWeys
CydeWeys requested a review from gbrodman December 5, 2026 04:09
@CydeWeys
CydeWeys force-pushed the centralize-pr-review-rules branch from 62f8e09 to c66643a Compare December 5, 2026 04:30
@CydeWeys CydeWeys changed the title Centralize PR review rules in pr-review skill Tighten agent docs, review skill, and guardrails Dec 5, 2026
@CydeWeys
CydeWeys enabled auto-merge December 5, 2026 04:40

@gbrodman gbrodman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@gbrodman made 1 comment.
Reviewable status: 0 of 10 files reviewed, all discussions resolved.

After migrating repository skills to `.agents/skills/` (google#3295), adding scoped
`AGENTS.md` guides (google#3311), and adding the on-demand `pr-review` skill (google#3313),
a full audit of all agent instructions and skill scripts uncovered remaining
duplication, always-on context bloat, mis-routed/stale rules, and four concrete
guardrail bugs: `check_diff.py` silently missed Valkey Protostuff fields on
`@MappedSuperclass` parents and inline-annotated fields, `core/AGENTS.md`
scoped the Netty `retainedDuplicate()` rule away from `proxy/` (its primary
caller), `run_rewrite.sh` silently exited `0` on Gradle failure without cleanup
traps, and `check_diff_test.py` never ran in presubmits. Centralizing review
rules into `pr-review`, moving `core/`-only rules out of root `GEMINI.md`,
correcting stale Gradle/Spotless instructions, and fixing the guardrail scripts
close these blind spots while cutting always-on `GEMINI.md` by 22%.

Specifically, this change:
- **Centralizes PR review rules in `.agents/skills/pr-review/SKILL.md`:**
  - `GEMINI.md` (`18,118 B` -> `14,071 B`): replaces duplicated `Processing PR
    Feedback` and `PR Description Sync` bullets with a 1-line pointer to
    `.agents/skills/pr-review/SKILL.md`.
  - `.agents/skills/pr-polisher/SKILL.md`: removes Step 9 (paginated PR review
    comment fetch), renumbers Step 10 -> 9, and adds `pr-review` negative
    routing to frontmatter `description`.
  - `console-webapp/AGENTS.md`: removes `## Review Calibration`, moving
    `Shared State` and `Build & Screenshots` into `pr-review` while keeping
    `Nested @if` as an Angular template authoring rule.
  - `core/AGENTS.md`: trims the review-only parenthetical from `JPQL Timestamp
    Ordering`.
  - `.agents/skills/pr-review/SKILL.md`: adds `### Nomulus Review Calibration`
    under `Conducting PR Reviews`.
- **Re-scopes always-on rules and fixes stale build/formatting docs:**
  - Moves `Netty Retry Buffers` (`ByteBufHolder.retainedDuplicate()`) out of
    `core/AGENTS.md` into `GEMINI.md`'s Netty lifecycle bullet so `proxy/`,
    `networking/`, `prober/`, and `core/` all load it; removes the verbatim
    duplicated `console-webapp` sentence from `GEMINI.md`.
  - Moves `core/`-only idioms (CLI/Beam/`TestRegistryToolComponent`, model
    layering, `@GetterDelegate` sets, partial JSON updates, JAXB optional
    attributes, allocation tokens, Console actions, CSV output, time-projected
    entities, Valkey Protostuff compatibility, and async pipeline boundaries)
    from `GEMINI.md` into `core/AGENTS.md`, fixes exact `monthly_logs.sql` /
    `monthly_logs_test.sql` paths, and condenses `2-PR Schema Split` in
    `GEMINI.md`.
  - Corrects `spotlessApply` (`*.gradle` only) vs. `javaIncrementalFormatApply`
    (Java formatting & import order) and `checkstyleMain`/`checkstyleTest`, and
    replaces backend compile commands that triggered Docker `:core:buildToolImage`
    or `console-webapp` `npmInstallDeps` across `GEMINI.md`, `pr-polisher`, and
    `java-ast-refactoring`.
- **Hardens guardrail scripts and wires unit tests into presubmits:**
  - `.agents/skills/pr-polisher/scripts/check_diff.py` (+ `SKILL.md` &
    `check_diff_test.py`): adds the 4 missing Protostuff `@MappedSuperclass`
    parents (`UpdateAutoTimestampEntity`, `GracePeriodBase`,
    `DomainDsDataBase`, `BaseTransferObject`), strips leading inline
    `@Annotation(...)` tokens instead of skipping annotated field lines, skips
    Java comment lines in anti-pattern checks (while still catching
    `/* package */`), fixes `fqn_pattern` capturing so full FQNs print, scopes
    `check_commit_message()` `[OK]` to local errors, expands internal-leak
    checks to cover `//depot/configs` and `cl/<digits>`, and maintains Python
    3.7-3.9 compatibility (no backslashes in f-string expressions or
    parenthesized multi-item `with` blocks; `15/15` unit tests).
  - `config/presubmits.py`: adds `verify_agent_scripts()` so
    `check_diff_test.py` runs automatically on `./gradlew runPresubmits`
    whenever `.agents/` is present in the workspace (skipping cleanly in
    non-dotfile staged build environments).
  - `.agents/skills/java-ast-refactoring/scripts/run_rewrite.sh`: adds
    `set -euo pipefail`, an `EXIT` cleanup trap for temporary files, and
    portable top-level `^name:` YAML extraction via `awk`.

Verification:
- `python3 .agents/skills/pr-polisher/scripts/check_diff_test.py -v`: `15/15`
  passed (verified Python 3.7-3.9 syntax compatibility).
- `python3 .agents/skills/pr-polisher/scripts/check_diff.py`: `0` errors, `0`
  warnings (`spotlessCheck` and `javaIncrementalFormatCheck` passed).
- `./gradlew --no-daemon runPresubmits`: `BUILD SUCCESSFUL` (verified both with
  `.agents/` present and in a staged workspace omitting `.agents/`).
- Strict `PyYAML` parse OK on all `.agents/skills/*/SKILL.md` files, `bash -n`
  on `run_rewrite.sh`, and `0` lines > 80 chars in `core/AGENTS.md` and
  `console-webapp/AGENTS.md`.

BUG=http://b/593117423

Signed-off-by: Ben McIlwain <mcilwain@google.com>
@CydeWeys
CydeWeys force-pushed the centralize-pr-review-rules branch from c66643a to acb6381 Compare December 5, 2026 14:37
@CydeWeys
CydeWeys added this pull request to the merge queue Dec 5, 2026
Merged via the queue into google:master with commit cb7705a Dec 5, 2026
15 of 16 checks passed
@CydeWeys
CydeWeys deleted the centralize-pr-review-rules branch December 5, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants