Repository navigation
Add scoped AGENTS.md rules and static guardrails - #3311
Merged
Merged
Conversation
CydeWeys
force-pushed
the
agent-rules-guardrails
branch
from
December 4, 2026 00:04
5169572 to
eb1fd6f
Compare
gbrodman
approved these changes
Dec 4, 2026
gbrodman
left a comment
Collaborator
There was a problem hiding this comment.
@gbrodman reviewed 11 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on CydeWeys).
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Dec 4, 2026
Root GEMINI.md is already near per-file agent context limits (~20.2 KB), so adding more subsystem-specific engineering rules there risks silent truncation and hurts signal for unrelated changes. At the same time, several recurring production and review hazards—Jetty vs. GCLB idle timeout races, GKE requests.memory sizing under -XX:MaxRAMPercentage, one-shot ServletInputStream dual-injection drains, JvmMetrics non_heap and committed-heap semantics, and fail-open Cloud Deploy alert policy checks—are much more reliable when enforced in directory-scoped guides, source Javadoc, unit tests, and automated diff checks than in global prose. Specifically, this change: - Adds console-webapp/AGENTS.md covering Angular zoneless OnPush Signal unions, GlobalLoader lifecycle/teardown, RxJS 7 error observers on BackendService calls, registrarId-keyed effect() cancellation, and console/Gradle review calibration without expanding root GEMINI.md. - Adds core/AGENTS.md covering pre-auth CLI validation and FeatureFlag retention, in-transaction ownership and Console EPP attribution, Gson type guards and real ServletInputStream tests, canonical Base64 SHA-256 checks, JPQL timestamp ordering, log-injection sanitization with monthly_logs.sql parity, and Netty retainedDuplicate() retries. - Adds JettyHttpConfigTest asserting jetty.http.idleTimeout exceeds GCLB's 600s backend keep-alive timeout in jetty/src/main/jetty-base/start.d/http.ini. - Documents JvmMetrics type="heap" vs. non_heap (-1 max) and used/max vs. committed semantics in JvmMetrics.java (plus unit test coverage in JvmMetricsTest), and documents unscoped stream providers and the single-read ServletInputStream invariant in RequestModule.java (plus unit tests in RequestModuleTest). - Extends .gemini/skills/pr-polisher/scripts/check_diff.py (and SKILL.md plus new unit tests in check_diff_test.py) to check GKE requests.memory against -XX:MaxRAMPercentage and flag dual ServletInputStream-reading injections in core production actions. - Adds a pre-apply step in release/cloudbuild-clouddeploy.yaml verifying that every Cloud Monitoring alert policy referenced in the rendered delivery-pipeline.yaml exists and is enabled before gcloud deploy apply. BUG=http://b/593117423 Signed-off-by: Ben McIlwain <mcilwain@google.com>
CydeWeys
force-pushed
the
agent-rules-guardrails
branch
from
December 4, 2026 22:08
eb1fd6f to
bbceaf5
Compare
CydeWeys
enabled auto-merge
December 4, 2026 22:09
CydeWeys
added a commit
to CydeWeys/nomulus
that referenced
this pull request
Dec 5, 2026
AI coding agents and reviewers working across fork-based workflows currently hit four recurring sources of friction: repository skills sit in a legacy directory that standard Git workspaces do not auto-discover, local diff and formatting checks overwrite remote tracking refs or diff against stale fork bases, redundant checklists and contradictory rules bloat always-on context toward per-file truncation limits, and commit messages often bury why a change matters beneath low-level file mechanics. Consolidating and trimming the repository engineering guide, relocating skills to the standard discovery directory, making fork-point detection strictly read-only, and requiring plain-English motivation at the top of every commit eliminate these failure modes. As a result, agents discover repository skills automatically without mutating developer Git remotes, always-on instructions stay comfortably below truncation caps, and reviewers can grasp the purpose and value of every pull request on first read. 1. **`GEMINI.md` (`20,649 B` -> `18,118 B`, down from `28,125 B` pre-google#3284):** - Keeps the guide comfortably below the `24,000 B` per-file truncation cap while preserving all invariants added in google#3284, google#3301, and google#3312 (including `Sync & Rebase onto upstream/master`). - Updates `Commit Message Style` so commit and PR bodies open with 2–4 plain-English sentences stating why the change is being made, what problem, waste, or risk exists today, and what concrete outcome improves—before naming classes, flags, or implementation mechanics ("what"/"how"). - Replaces the rigid push ban with a default push gate (halt at local commit unless overridden by a user-level rule or an explicit directive to open/update a PR; use `--force-with-lease` on amended branches; never chain remote transfers with `git commit`). - Resolves internal contradictions: recommends a fixed static `Instant.parse(...)` constant in `reTransact` test helpers (instead of `clock.now()`) and statically imported `formatInstant(...)` from `DateTimeUtils`. - Preserves both Reviewable footer formats (the HTML-comment Reviewable block and `This change is https://reviewable.io/reviews/...`), deduplicates the pre-commit `pr-polisher` checklist into a concise pointer to `.agents/skills/pr-polisher/SKILL.md`, and keeps a single concise `Continuous Improvement` bullet under `Common Pitfalls & Efficiency`. 2. **Migrate repo skills from `.gemini/skills/` to `.agents/skills/`:** - Moves `pr-polisher` (including `check_diff_test.py` from google#3311) and `java-ast-refactoring` into `.agents/skills/` so agents automatically discover them in Git workspaces, updating all path references (including `SCRIPT_PATH` in `check_diff.py`). - Removes duplicated `Continuous Improvement` sections from both `SKILL.md` files (previously instructing agents to commit skill edits inside unrelated PRs), keeping the single concise `Continuous Improvement` bullet in `GEMINI.md`, and fixes YAML 1.2 frontmatter quoting in `.agents/skills/pr-polisher/SKILL.md` (removing internal VCS wording). 3. **Read-only merge-base & `pr-polisher` fixes:** - Removes the `git update-ref` mutation of `refs/remotes/origin/master` from `.agents/skills/pr-polisher/scripts/check_diff.py` and replaces hardcoded `HEAD^` diffs (including `check_protostuff_cached_entities()`) with a read-only `get_diff_base()` helper selecting the fresher merge-base across `upstream/master` and `origin/master` (gracefully catching `CalledProcessError` on shallow or unrelated remote refs and falling back to `refs/heads/master`, covered in `check_diff_test.py`). - Updates `java-format/google-java-format-git-diff.sh` (`findForkPoint()`) to pick the fresher merge-base across fully qualified `refs/remotes/upstream/master` and `refs/remotes/origin/master` read-only (falling back cleanly on shallow/unrelated refs via `|| true` and propagating errors via `forkPoint=$(findForkPoint) || exit 1`). - Fixes the self-contradictory `DateTimeUtils.formatInstant(...)` message in `check_diff.py` to recommend statically importing `formatInstant(...)`, and aligns the `Instant.now()` message with `GEMINI.md`. Verification: - `python3 .agents/skills/pr-polisher/scripts/check_diff_test.py -v`: `11/11` passed. - `python3 .agents/skills/pr-polisher/scripts/check_diff.py`: `0` errors, `0` warnings (`spotlessCheck` and `javaIncrementalFormatCheck` passed). - `./gradlew --no-daemon runPresubmits`: `BUILD SUCCESSFUL`. - Verified strict YAML frontmatter parsing on all `.agents/skills/*/SKILL.md` files, `bash -n java-format/google-java-format-git-diff.sh`, and zero remaining `.gemini/skills` references across the repository. BUG=http://b/588443833 Signed-off-by: Ben McIlwain <mcilwain@google.com>
CydeWeys
added a commit
to CydeWeys/nomulus
that referenced
this pull request
Dec 5, 2026
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 or CI. 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, and expands internal-leak checks to cover `//depot/configs` and `cl/<digits>` (`15/15` unit tests). - `config/presubmits.py`: adds `verify_agent_scripts()` so `check_diff_test.py` runs automatically on `./gradlew runPresubmits` and CI. - `.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. - `python3 .agents/skills/pr-polisher/scripts/check_diff.py`: `0` errors, `0` warnings (`spotlessCheck` and `javaIncrementalFormatCheck` passed). - `./gradlew --no-daemon runPresubmits`: `BUILD SUCCESSFUL` (includes running `check_diff_test.py` via `verify_agent_scripts()`). - 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root
GEMINI.mdis already near per-file agent context limits (~20.2 KB), so adding more subsystem-specific engineering rules there risks silent truncation and reduces signal for unrelated changes. At the same time, several recurring production and code-review hazards — Jetty vs. GCLB idle timeout races, GKErequests.memorysizing under-XX:MaxRAMPercentage, one-shotServletInputStreamdual-injection drains,JvmMetricsnon_heapand committed-heap semantics, and fail-open Cloud Deploy alert policy checks — are much more reliable when enforced via directory-scoped guides, source Javadoc, unit tests, and automated diff checks rather than global prose.Summary of Changes
console-webapp/AGENTS.md: Captures Angular zonelessOnPushSignal unions,GlobalLoaderlifecycle/teardown, RxJS 7 error observers onBackendServicecalls,registrarId-keyedeffect()cancellation, and console/Gradle review calibration without expanding rootGEMINI.md.core/AGENTS.md: Captures pre-auth CLI validation andFeatureFlagretention, in-transaction ownership and Console EPP attribution, Gson type guards and realServletInputStreamaction tests, canonical Base64 SHA-256 checks, JPQL timestamp ordering, log-injection sanitization withmonthly_logs.sqlparity, and NettyretainedDuplicate()retries.JettyHttpConfigTest.java: Asserts thatjetty.http.idleTimeoutexceeds GCLB's 600s backend keep-alive timeout injetty/src/main/jetty-base/start.d/http.ini.JvmMetrics.java&RequestModule.java(+ tests): Documentstype="heap"vs.non_heap(-1max) andused / maxvs.committedsemantics inJvmMetrics.java, and documents intentionally unscoped stream providers (DnsTestComponent) and the single-readServletInputStreaminvariant inRequestModule.java..gemini/skills/pr-polisher/scripts/check_diff.py(+SKILL.md&check_diff_test.py): Adds automated checks for GKErequests.memoryvs.-XX:MaxRAMPercentageand dualServletInputStream-reading injections in core actions (9/9unit tests pass,0false positives across the repo).release/cloudbuild-clouddeploy.yaml: Adds a pre-apply step verifying that every Cloud Monitoring alert policy referenced in the rendereddelivery-pipeline.yamlexists and is enabled (gcloud monitoring policies describe --format='value(enabled)') before runninggcloud deploy apply.Verification
./gradlew :core:standardTest :jetty:test runPresubmits -x :console-webapp:buildConsoleWebapp:5,693tests passed,0failures/errors; Checkstyle, Javadoc, and Spotless checks passed.python3 .gemini/skills/pr-polisher/scripts/check_diff_test.py -v:9/9passed;check_diff.pyreturned0errors.BUG=http://b/593117423
This change is