From f9cc06f7e4af2093f98a979385c1010b20f246ad Mon Sep 17 00:00:00 2001 From: Neenu1995 Date: Fri, 20 Nov 2026 17:50:18 -0500 Subject: [PATCH 1/2] chore(bigquery-jdbc): use Antigravity CLI in prepare-pr skill Updates .agents/skills/bigquery-jdbc-prepare-pr/SKILL.md to use the Antigravity CLI (agy) instead of gemini or claude CLI commands for shell-based reviewer invocations. --- .../.agents/skills/bigquery-jdbc-prepare-pr/SKILL.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/SKILL.md b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/SKILL.md index df59dd294571..8bd046171ef6 100644 --- a/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/SKILL.md +++ b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/SKILL.md @@ -97,17 +97,15 @@ below). How to start a reviewer, depending on your harness: | Harness | How to start a different-model reviewer | | --- | --- | -| Jetski / Antigravity | `invoke_subagent` with a `Model` other than your own, on a read-only type such as `research`. Give it the path of the prompt file, or the prompt itself if it is short. | -| Claude Code | Gemini CLI from the shell: `gemini -p "Review as instructed on stdin." < "$PROMPT_FILE"`. If it isn't installed, use a Task subagent pinned to a different Claude model. | -| Gemini CLI | Claude Code from the shell: `claude -p "Review as instructed on stdin." < "$PROMPT_FILE"`. If it isn't installed, use a subagent on a different Gemini model. | +| Antigravity (IDE / App) | `invoke_subagent` with a `Model` other than your own, on a read-only type such as `research`. Give it the path of the prompt file, or the prompt itself if it is short. | +| Antigravity CLI (`agy`) or terminal-based agents | Antigravity CLI from the shell: `agy --sandbox --model "" -p "Review as instructed on stdin. Do not modify any files." < "$PROMPT_FILE"` (`--sandbox` isolates shell execution; run `agy models` to list available model slugs and pick one different from your own). If `agy` isn't installed, use a read-only subagent in your harness pinned to a different model. | - Pass the prompt on stdin as shown, not as a command-line argument. Linux limits a single argument to 128 KiB, and a large diff plus this template exceeds that. -- The two shell commands send the diff to another company's service. Don't use - them for a security fix that isn't public yet, or where the user or team has - restricted external services. Use the same-vendor fallback in that row - instead. +- Choose a model and service permitted by your repository or organization policy; + do not send unpublished or restricted changes to disallowed third-party models + or external services. - If you can't get a different model at all, stop and tell the user. Don't quietly use your own model to review your own work. If you can't tell which model you are running on, say that in the final report. From ca871ee318eb40e1b3c6d2b12299abe376cc1f2c Mon Sep 17 00:00:00 2001 From: Keshav Dandeva Date: Thu, 3 Dec 2026 15:36:33 +0000 Subject: [PATCH 2/2] chore(bigquery-jdbc): add PR review skill and rework the prepare-pr review loop - Add the bigquery-jdbc-review-pr skill, a read-only reviewer's playbook. - prepare-pr: a fresh own-model reviewer every round and a cross-model reviewer on the first diff. review.sh builds the reviewer prompt. cross-review.sh runs the cross-model reviewer through Antigravity's conversation CLI and audits what it did. - AGENTS.md, DEVELOPMENT.md: guardrails 6 to 18 and the pre-PR checklist. - Correct DEVELOPMENT.md, README.MD and the testing skill where they named things that don't exist. --- .../skills/bigquery-jdbc-prepare-pr/SKILL.md | 413 ++++++---- .../references/cross-model-reviewer.md | 159 ++++ .../references/reply-format.md | 39 + .../scripts/cross-review.sh | 720 ++++++++++++++++++ .../scripts/review.sh | 274 +++++++ .../skills/bigquery-jdbc-review-pr/SKILL.md | 262 +++++++ .../skills/bigquery-jdbc-testing/SKILL.md | 36 +- java-bigquery-jdbc/AGENTS.md | 60 +- java-bigquery-jdbc/DEVELOPMENT.md | 133 +++- java-bigquery-jdbc/README.MD | 2 +- 10 files changed, 1901 insertions(+), 197 deletions(-) create mode 100644 java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/references/cross-model-reviewer.md create mode 100644 java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/references/reply-format.md create mode 100755 java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/scripts/cross-review.sh create mode 100755 java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/scripts/review.sh create mode 100644 java-bigquery-jdbc/.agents/skills/bigquery-jdbc-review-pr/SKILL.md diff --git a/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/SKILL.md b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/SKILL.md index 8bd046171ef6..3fa8561aa67c 100644 --- a/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/SKILL.md +++ b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/SKILL.md @@ -1,58 +1,98 @@ --- name: bigquery-jdbc-prepare-pr -description: Prepare a pull request for the BigQuery JDBC driver (java-bigquery-jdbc) and get it independently reviewed. Before a PR is created, pushed, or marked ready for review, a fresh reviewer agent on a different model checks the diff and the PR description. The author fixes or argues against each finding, and the loop repeats until both the author and the reviewer are satisfied. Docs, config and other non-Java changes get a single review round. Use this skill whenever you are about to open, update, or finish a PR that touches java-bigquery-jdbc. +description: Prepare a pull request for the BigQuery JDBC driver (java-bigquery-jdbc) and get it independently reviewed. Before a PR is created, pushed, or marked ready for review, the author reviews its own diff against the pre-PR checklist, and fresh reviewer agents that have not seen the author's work check the diff and the PR description, one on the author's own model every round and one on a different model on the first diff. The author fixes or argues against each finding, and the loop repeats until both the author and the reviewer are satisfied. Changes without Java code or scripts get a single review round, and small fixes for comments on an already approved PR get none. Use this skill whenever you are about to open, update, or finish a PR that touches java-bigquery-jdbc. --- -# Preparing a PR with external review +# Preparing a PR with independent review When you (the **author agent**) finish a change, you aren't done when your own -tests pass. Get an independent review from an agent running a **different -model** first, and repeat until you and the reviewer agree the PR is ready. +tests pass. Review your own diff, then get it reviewed by agents that have not +seen your work, and repeat until you and the reviewer agree the PR is ready. -This skill never pushes or opens a PR by itself. Do that only if the user asked. +- This skill never pushes or opens a PR by itself, and it doesn't commit, merge + or rebase unless the user has said that you may. +- If a commit fails because your shell can't sign it, don't bypass the signing. + Stage the change and give the user a Conventional Commits message. +- If this procedure started you as a reviewer, it is not for you. Follow + `bigquery-jdbc-review-pr` and start no reviewers of your own. ```mermaid flowchart TD - A["1. Sync with main, finish change, run local checks"] --> B["2. Write PR description, build context bundle"] - B --> C["3. Start a FRESH reviewer on a different model"] - C --> D{"Reviewer verdict"} - D -->|"CHANGES_REQUESTED"| E["4. Answer every finding: FIXED, PUSHBACK or WONTFIX"] - D -->|"APPROVE"| G{"Author concerns open, or an answer that changes behaviour?"} - G -->|"yes"| E - G -->|"no"| H["6. Stop and report to the user. Push or open the PR only if asked"] - E --> F["5. Re-run local checks, update description and ledger"] - F -->|"full loop"| C - F -->|"single-round change, nothing blocking"| H + A["1. Sync with main, finish the change, review it yourself, run local checks"] --> B["2. Write the PR description, build the review bundle"] + B --> C["3. Start fresh reviewers, check their replies"] + C -->|"the check that a cross-model reviewer changed nothing failed"| S["Discard the review, stop and tell the user"] + C --> D["4. Answer every finding: FIXED, PUSHBACK or WONTFIX"] + D --> E["5. Re-run local checks, update description and ledger"] + E --> F{"Has the loop ended successfully, by step 6?"} + F -->|"yes"| H["6. Report to the user. Commit, push or open the PR only if asked"] + F -->|"no"| L{"5 rounds done, or a pushback maintained twice?"} + L -->|"yes"| U["6. Report the unresolved items to the user"] + L -->|"no"| G["Rebuild the bundle"] + G --> C ``` +The diagram leaves out two things: a reply that fails one of the other checks +and is replaced by a new reviewer (step 3), and the second run of the +cross-model reviewer (step 6). + ## How much review the change needs | The change | Review | | --- | --- | -| Edits any `.java` file under `src/`, beyond comments or formatting | **Full loop**: steps 1 to 6. | -| Anything else: docs, Markdown, skills, build or CI config, dependency bumps, comment-only or formatting-only edits | **Single round**: steps 1 to 4 once, then re-run the checks, update the description, and report as in step 6. Go one more round only if the reviewer raised a `blocking` finding, to confirm the fix. | +| Edits any `.java` file under `src/` or any script, beyond comments or formatting | **Full loop**: steps 1 to 6. | +| Anything else: docs, Markdown, skill text, build or CI config, dependency bumps, comment-only or formatting-only edits | **Single round**: steps 1 to 6 with one review round. Go one more round only if the reviewer raised a `blocking` finding, to confirm the fix, or left a part of the change unchecked. | +| Answers a comment on an open PR whose code already went through this loop and ended with `APPROVE` | See [Changes for PR comments](#changes-for-pr-comments-after-the-loop-has-ended). | If you aren't sure which row applies, use the full loop. In a single-round change, run only the local checks the change can affect. -## 1. Sync with main, finish the change, run local checks +## 1. Sync with main, finish the change, review it yourself, run local checks -Before you ask anyone to review, the branch must be current and the change must -build and pass its tests: +Before you ask anyone to review, the branch must be current, you must have +reviewed the diff yourself, and the change must build and pass its tests: -- Sync: `git fetch origin main`, then bring `origin/main` into the branch. If - the branch is already pushed, merge instead of rebasing unless the user asks - for a rebase, so nobody has to force-push. (`origin` here means the remote for +- **Sync**: `git fetch origin main`, then see how far behind the branch is: + `git rev-list --count HEAD..origin/main`. (`origin` here means the remote for `googleapis/google-cloud-java`.) -- Format: `make lint` from `java-bigquery-jdbc/`. It rewrites files in place. -- Unit tests: the full suite, `make unittest`, before the first round and again - on the final code. Between rounds the classes you touched are enough: + - If the fetch fails, for example because your shell can't use the SSH key, + continue with the local `origin/main` and say in the report that it may be + stale. + - If the branch is behind and the user lets you commit, commit your change + and then bring `origin/main` in. Merge instead of rebasing if the branch is + already pushed, so nobody has to force-push. + - If the branch is behind and you may not commit, don't merge. Tell the user + how many commits it is behind. Then: + - If the change edits Java code and `origin/main` changed this module since + the merge base + (`git diff --stat "$(git merge-base origin/main HEAD)" origin/main -- .`), + ask the user to merge before the first round. The tests would otherwise + run against old code. + - In every other case go on, but check the names you use against + `origin/main` instead of the working tree + (`git grep -n origin/main -- .`), and base your edit of any file + that `origin/main` also changed on its `origin/main` version. +- **Self-review**: go through the checklist in section 5 of + [DEVELOPMENT.md](../../../DEVELOPMENT.md) against your own diff, + `git diff "$(git merge-base origin/main HEAD)"`. A reviewer's round is not + the place to find a nested `if` or a helper that already exists. Start with + the scope group of that checklist: a PR that does two things, or that solves + in the driver what belongs in a library, is cheaper to split or to redirect + before a review than after one. +- **Format**: `make lint` from `java-bigquery-jdbc/`. It rewrites files in place. +- **Unit tests**: the full suite, `make unittest`, before the first round and + again on the final code. Between rounds the classes you touched are enough: `make unittest test=`. -- Integration tests compile at least: `mvn -q -Denforcer.skip=true -Dclirr.skip=true test-compile`. +- **Integration tests** compile at least: + `mvn -q -Denforcer.skip=true -Dclirr.skip=true test-compile`. +- **Scripts**: if you changed a script of this skill, run `bash -n` on it and + run the subcommands you changed. The scripts have no tests in the repository. +- **Docs, skills and comments**: search for every class, method, constant, make + target and path that you name. Where a doc has a diagram and prose for the + same steps, compare them node by node. - Follow the repo and module `AGENTS.md` and, for test changes, the `bigquery-jdbc-testing` skill. -## 2. Write the PR description and build the context bundle +## 2. Write the PR description and build the review bundle Write the PR description now, not after the review. The reviewer checks it too. It has: @@ -61,113 +101,104 @@ It has: - **What** changed and **why** (the bug, the issue link, or the requirement). - **How it was tested**: the commands you ran, new tests, and anything you couldn't run (for example integration tests that need credentials). -- **Risks / follow-ups**, if any. - -**Untracked files are in no diff.** Before you build the bundle, run -`git status --short`. For every `??` file that belongs to the change, run -`git add -N ` (or commit it) so the reviewer sees it. - -Build a **context bundle** for the reviewer: - -1. The PR description, word for word. -2. The full diff from the merge base to your working tree: - `git diff "$(git merge-base origin/main HEAD)"`. One diff covers committed, - staged and unstaged changes. -3. The list of changed files (the same command with `--name-only`) and the repo - path, so the reviewer can open surrounding code itself. -4. From round 2 on, the **review ledger** (see step 4). - -Keep the bundle and ledger in a scratch location **outside the repository** (for -example the agent's scratch or artifact directory, or `/tmp`). Never commit them. - -## 3. Start a fresh reviewer on a different model - -The reviewer must run on a **different model from yours**, so its blind spots -differ from yours. Prefer a model at least as capable as your own. If every -different model you can reach is weaker than yours, use the strongest of them -and say so in the final report, so the user knows how much weight the approval -carries. - -Start a **new** reviewer every round. Don't continue an old reviewer -conversation, because it is already anchored on its earlier opinions. The ledger -gives the new reviewer the history it needs. - -Save the filled-in prompt as a file in the scratch location (`$PROMPT_FILE` -below). How to start a reviewer, depending on your harness: +- **Risks / follow-ups**, if any. This is also where you list what you moved + to a follow-up PR or issue, and say why something stays that a reader would + expect to go, such as an overload you replaced. + +**Untracked files are in no diff.** Run `git status --short`. For every `??` +file that belongs to the change, run `git add -N ` so the reviewer sees +it. + +Save the description to a file and build the bundle. `$SCRATCH` is a directory +**outside the repository**: the agent's scratch or artifact directory, or one +under `/tmp`. Never commit the bundle or the ledger. + +```bash +.agents/skills/bigquery-jdbc-prepare-pr/scripts/review.sh bundle \ + --description "$SCRATCH/description.md" --round 1 --out "$SCRATCH" +# From round 2 on, add: --ledger "$SCRATCH/ledger.md" +``` -| Harness | How to start a different-model reviewer | -| --- | --- | -| Antigravity (IDE / App) | `invoke_subagent` with a `Model` other than your own, on a read-only type such as `research`. Give it the path of the prompt file, or the prompt itself if it is short. | -| Antigravity CLI (`agy`) or terminal-based agents | Antigravity CLI from the shell: `agy --sandbox --model "" -p "Review as instructed on stdin. Do not modify any files." < "$PROMPT_FILE"` (`--sandbox` isolates shell execution; run `agy models` to list available model slugs and pick one different from your own). If `agy` isn't installed, use a read-only subagent in your harness pinned to a different model. | +The script prints `prompt_file`, the path of the prompt file (`$PROMPT_FILE` +below), and with it the path of a start prompt, the check word of this round, +the number of tool calls the reviewer is given, and a fingerprint of the +checkout. The prompt file holds, in this order: + +1. The reviewer's instructions: the review method of `bigquery-jdbc-review-pr`, + then the rules for this round and the reply format from + [references/reply-format.md](references/reply-format.md). +2. The PR description, word for word. +3. The review ledger of the earlier rounds (see step 4). +4. The changed files and the full diff from the merge base to your working + tree. One diff covers committed, staged and unstaged changes. +5. A last line that asks the reviewer to start its reply with a check word. A + reply without it comes from a reviewer that didn't reach the end of the + file. The word doesn't show that the reviewer read everything before it: + the files it opened show that. + +The instructions come first and the diff last, so that a reviewer never judges +the diff before it knows what to look for. If you can't run the script, build +the same file by hand, in the same order. + +## 3. Start fresh reviewers + +| Reviewer | Model | Rounds | Time | +| --- | --- | --- | --- | +| **Own-model** | The same model as yours | Every round | About 10 minutes for a typical diff, more than 20 for a large one | +| **Cross-model** | A model of another vendor than yours | Round 1 of a full loop. Once more on the final code if any round raised a `blocking` or `major` finding. Never a third time | Stopped after 30 minutes | + +A reviewer on your own model that starts without your context is fast, and in a +test here it found 11 of 12 planted defects, so it does the loop. A different +model has different blind spots, and they matter most on the first diff. + +- Start a **new** reviewer every round. Don't continue an old reviewer + conversation, because it is already anchored on its earlier opinions. The + ledger gives the new reviewer the history it needs. +- In round 1 start both reviewers on the same prompt file, and don't edit the + working tree until both have ended, so that both review the same code. Use + the wait to check the first findings against the code and to draft your + answers. +- While a cross-model reviewer runs, don't edit, stage, commit or switch + branches in the checkout. The check that it changed nothing can't tell a + change of yours from one of its own, and fails. +- A single-round change gets the own-model reviewer only. +- If the tool offers no model of another vendor, or none can be started, go on + with the own-model reviewer and say so in the report. If you can't tell which + model you are running on, say that too. +- Choose a model and service permitted by your repository or organization + policy; do not send unpublished or restricted changes to disallowed + third-party models or external services. + +How to start them, depending on your harness: + +| Harness | Own-model reviewer | Cross-model reviewer | +| --- | --- | --- | +| Antigravity (IDE / App) | `invoke_subagent` on a type without file-edit and shell tools, such as `research`, with `Model: inherit`. Its prompt is the start prompt that `review.sh bundle` wrote. | `scripts/cross-review.sh run --prompt-file "$PROMPT_FILE"`, which needs the conversation CLI. Without that CLI, `invoke_subagent` with a `Model` of another vendor. If the harness offers none, the own-model reviewer only. | +| Antigravity CLI (`agy`) or terminal-based agents | A read-only subagent in your harness, with the same start prompt. | Antigravity CLI from the shell: `agy --sandbox --model "" -p "Review as instructed on stdin. Do not modify any files." < "$PROMPT_FILE"` (`--sandbox` isolates shell execution; run `agy models` to list available model slugs). If `agy` isn't installed, use a read-only subagent in your harness pinned to a model of another vendor. If the harness offers none, the own-model reviewer only. | - Pass the prompt on stdin as shown, not as a command-line argument. Linux - limits a single argument to 128 KiB, and a large diff plus this template + limits a single argument to 128 KiB, and a large diff plus the instructions exceeds that. -- Choose a model and service permitted by your repository or organization policy; - do not send unpublished or restricted changes to disallowed third-party models - or external services. -- If you can't get a different model at all, stop and tell the user. Don't - quietly use your own model to review your own work. If you can't tell which - model you are running on, say that in the final report. - -### Reviewer prompt template - -```text -You are an independent senior reviewer for a pull request to the google-cloud-java -monorepo, module java-bigquery-jdbc (the BigQuery JDBC driver). You did not write -this code. Be rigorous and specific, and don't rubber-stamp it. - -Repository: (you may read any file for context) -Base branch: origin/main -Round: - -== PR DESCRIPTION == - - -== CHANGED FILES == - - -== DIFF == - - -== REVIEW LEDGER FROM EARLIER ROUNDS (empty in round 1) == - - -Review for: correctness and edge cases, concurrency and resource leaks -(connections, statements, result sets, threads), JDBC spec compliance, backward -compatibility and public API surface (see AGENTS.md and the api-lifecycle skill), -security (credentials, logging of secrets), test coverage of every new branch, -test quality (see the bigquery-jdbc-testing skill), and whether the PR -description is accurate and complete. For documentation, skill and config -changes, check every factual claim (class names, commands, paths) against the -repository. - -From round 2 on: -- For each finding marked FIXED, check the fix in the code. Don't repeat the - finding unless the fix is wrong or incomplete. -- For each finding marked PUSHBACK, say whether you ACCEPT the author's reason - (the finding is then closed) or MAINTAIN it, with a new argument. -- Findings marked WONTFIX are closed nits. Don't repeat them. -- Concentrate on what the ledger says changed since the previous round. Raise a - new finding on code that has not changed since then only if it is blocking or - major. - -Reply in exactly this format: - -VERDICT: APPROVE | CHANGES_REQUESTED -FINDINGS: -- id: R- - severity: blocking | major | minor | nit - location: : | PR description - issue: - suggestion: -PUSHBACK_RESPONSES: -- id: - decision: ACCEPT | MAINTAIN - reason: - -APPROVE only if no blocking or major findings are open. -``` +- Don't pick the cross-model reviewer from memory of which model is good. Model + names say little, and the list changes. Take it from what the tool offers + now. The rules for that, and the setup and output of `cross-review.sh`, are + in [references/cross-model-reviewer.md](references/cross-model-reviewer.md). + +### Check every reply before you use it + +| Check | How | If it fails | +| --- | --- | --- | +| The reviewer reached the end of the prompt | The reply starts with `READ-CHECK` and the check word of this round. | Discard the reply. Start one new own-model reviewer in its place, and go on without the cross-model one. | +| The reviewer looked at the code | It opened repository files. Count them in the subagent's transcript, whose path `invoke_subagent` returns. `cross-review.sh run` prints the count. | The same. | +| The reviewer got to everything | `NOT_CHECKED` in the reply is `none`. | Copy what it lists to the ledger, so that the next reviewer starts there. If it lists a part of the change, go another round, even after an `APPROVE` and even for a single-round change. | +| A cross-model reviewer changed nothing | It may be a full agent with write tools. `review.sh fingerprint` gives the same hash before and after it ran, and every tool step in its transcript is a file read or a search. `cross-review.sh run` checks both, and exits with status 3 if either fails, if it can't read the transcript, or if it can't stop the reviewer. | Discard the review, stop and tell the user. | + +The fingerprint covers `HEAD`, the local branches, the repository's own git +config (also the per-worktree one), its hooks, its exclude, attributes and +sparse-checkout files, the tracked and the untracked files, and the ignored +files in the agent directories (`.agents`, `.claude`). It doesn't see other +ignored files, tags and remote-tracking refs, the rest of `.git`, or anything +outside the repository. ## 4. Answer every finding @@ -187,6 +218,10 @@ Rules: - Take the findings seriously. Push back only when you are confident the reviewer is wrong or the request is out of scope. Don't push back to save effort. +- Keep the fix on the problem the PR solves. A finding that asks for something + else, however good the idea, gets PUSHBACK with the scope as its reason and + the follow-up PR or issue that you propose for it. Don't widen the PR to + close a finding. - If the reviewer maintains a pushback, you may answer it once more. If it is maintained a second time, fix it, or stop and escalate to the user (see step 6). Don't argue a third round. @@ -196,10 +231,15 @@ Rules: others. If an answer changes behaviour (anything beyond renames, comments, formatting, or the PR description), that code has not been reviewed: go another round. Otherwise re-run the checks and finish. +- A reviewer's **questions** are not findings. Answer one in the ledger if the + code or the issue settles it. If it asks what the driver should do, or why it + does something, don't settle it yourself: pass it to the user in the report. ### Ledger format -Keep one ledger file for the whole loop and append to it every round: +Keep one ledger file for the whole loop and append to it every round. A +cross-model reviewer's findings go in the same ledger, renumbered +`X-`: ```markdown ## Round , reviewer model: , verdict: @@ -210,7 +250,10 @@ Keep one ledger file for the whole loop and append to it every round: | R1-2 | major | Missing test for default universe | FIXED: added testXForDefaultUniverse in FooTest.java:210-240 | closed | | R1-3 | minor | Rename helper to assertY | PUSHBACK: name matches existing assertX convention in BarTest | open, awaiting reviewer | | R1-4 | nit | Blank line before return | WONTFIX: formatter output | closed | +| X1-1 | major | Fallback also runs when the property is set to an empty string | FIXED: Foo.java:88-92, test in FooTest.java:250-262 | closed | +Not checked by this round's reviewers: +Questions for the user: Author open concerns: ``` @@ -220,30 +263,112 @@ After you address the findings: 1. Re-run the local checks from step 1. Every round, not just the first. 2. Update the PR description if the change or the testing changed. -3. Rebuild the context bundle (new diff, updated ledger). -4. Go back to step 3 with a **new** reviewer. - -A single-round change stops after item 2, unless the reviewer raised a -`blocking` finding. +3. If by step 6 the loop has neither ended successfully nor reached the + safety limit, rebuild the bundle (new diff, updated ledger) and go back to + step 3 with **new** reviewers. ## 6. When to stop -The full loop **ends successfully** only when all of these are true: +A **single-round change** ends successfully after its one round and your +answers to it. It gets one more round only if that round raised a `blocking` +finding or left a part of the change unchecked. + +The **full loop** ends successfully only when all of these are true: -- The latest reviewer's verdict is `APPROVE`. +- The latest own-model reviewer's verdict is `APPROVE`. - No `blocking` or `major` finding is open, and every pushback is either ACCEPTED or resolved by a fix. +- The latest own-model reviewer left no part of the change unchecked. +- If any round raised a `blocking` or `major` finding, the second cross-model + run (below) is done and its findings are answered. This condition falls away + if no cross-model reviewer could be started in round 1, or if the second run + gave no usable review. - You (the author) have no open concerns. - Nothing that changes behaviour was edited after the last review. - The local checks, including the full unit suite, pass on the final code. +**The second cross-model run.** It happens once, when the own-model reviewer +approves and an earlier round raised a `blocking` or `major` finding: + +- Start it right after that approval and before you edit anything, on the + prompt file of the approved round. The diff in that file is then the code + that the reviewer opens. If you have edited since, first rebuild the bundle + with the same round number. +- Leave the checkout alone until it has ended, as in step 3. Answer the + approving reviewer's findings after that. +- Its findings get that round's number: `X-`. +- It is not a round of its own and doesn't count toward the limit below. +- If answering it changes behaviour, one more own-model round reviews that + change. The cross-model reviewer doesn't run a third time, so the last change + is seen by the own-model reviewer only. That is intended. +- It doesn't happen if no cross-model reviewer could be started in round 1. +- If it gives no usable review, also after what the exit table of + `cross-review.sh` tells you to try, don't repeat it. Say so in the report. + **Safety limit:** stop after **5 rounds** without agreement, or when a pushback has been maintained twice and you are not going to fix it. Report the unresolved items to the user with both sides' arguments and let them decide. Don't loop forever, and don't declare agreement that didn't happen. -When you stop, report to the user: the number of rounds, the reviewer model(s) -used and whether any was weaker than yours, what changed because of review, any -accepted pushbacks, anything you changed after the last review, any finding -left unfixed, and the final PR description. Push or open the PR only if the -user asked you to. +When you stop, report to the user: + +- The number of rounds and, for each reviewer in each round: how it was + started, its model, the minutes it took, its tool calls, whether it repeated + the check word, and how many repository files it read. In Antigravity a + subagent's model is in `agentapi get-conversation-metadata `, + field `subagentSpec.model`. +- The findings of round 1 that only one of the two reviewers raised. +- What changed because of review, any accepted pushbacks, anything you changed + after the last review, and any finding left unfixed. +- What a reviewer listed under `NOT_CHECKED` that no later reviewer checked. +- The reviewers' questions that are the user's to answer. +- Whether the cross-model reviewer was missing, and whether `origin/main` may be + stale or the branch is behind it. +- The final PR description. + +Commit, push or open the PR only if the user asked you to. + +## Changes for PR comments, after the loop has ended + +Check a comment against the code before you act on it. If it is wrong, answer +it with the evidence instead of changing the code. If it is right and asks for +something that the PR's problem doesn't need, don't fold it in: answer that it +belongs in a follow-up, and propose the PR or issue to the user. + +A full round on a small fix costs as much as a round on the whole PR. The one +such round we measured, on a one-line fix, took 8 minutes and found no defect +in the fix. The author of the comment sees the fix as well. So this section +replaces the rule that a behaviour change after the last review gets another +round. It applies only when both of these hold: + +- The PR is open, and its code went through this loop and ended with `APPROVE`. +- The change answers a comment on that PR, from a person or a bot. + +Everything else gets the normal procedure: a new PR, a PR that skipped the +loop, and work that no comment asked for. + +| The change | Review | +| --- | --- | +| Minor | None. | +| Big | One round, own-model reviewer only. No second round for its findings. | + +A change is big if either of these holds. Otherwise it is minor. + +- It adds and deletes more than 30 lines of main code in total. Tests and docs + don't count. +- It changes threading or locking, or when a resource is closed or cancelled. + +Count from the code the last review saw, not from the previous fix, so that +several minor fixes add up. + +Without a review, these still apply: + +- A test for new logic. For a bug fix, see the test fail first. +- `make lint` and the full `make unittest`. +- Update the PR description if the change makes any of it wrong. +- In the report, write "Not reviewed" and give the lines of main code and of + test code that changed. + +After the one round for a big change: answer the findings, re-run the checks +and stop. In the report, list what you changed after that round and any finding +you didn't fix. diff --git a/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/references/cross-model-reviewer.md b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/references/cross-model-reviewer.md new file mode 100644 index 000000000000..89ef2e17b004 --- /dev/null +++ b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/references/cross-model-reviewer.md @@ -0,0 +1,159 @@ +# The cross-model reviewer + +Read this when step 3 of [SKILL.md](../SKILL.md) calls for a cross-model +reviewer. + +## Which model + +Don't rank models from memory. Their names say little about how well they +review, and the list changes. Ask the tool what it offers now +(`cross-review.sh models`, or `agy models`) and apply these rules in order: + +1. Another vendor than your own model. +2. Not an alias, and not a small or fast model class. In a test here a small + model found 1 of 12 planted defects and opened no repository file. +3. In each model family, the second-highest reasoning effort. The highest took + about an hour for one round here, twice the time limit. +4. The first candidate that starts. A model that can't start fails within + seconds. + +`cross-review.sh run` applies these rules to the model list of the conversation +CLI. This is how it reads that list: + +- The vendor is the first word of a model's label, and the effort is the word + in brackets that ends it, as in ` (High)`. A label without + an effort is taken for an alias or a small model and is left out. +- It ranks the efforts `Max`, `XHigh`, `High`, `Medium`, `Low` and `Minimal`. A + family that uses any other word is taken in the order of the list, which + puts the highest effort first. +- It tries one candidate per family, in the order of the list. +- It remembers the outcomes, per machine. A model that ran out of time is + skipped for 14 days, because finding that out again costs the whole wait. A + model that ended without an answer, or whose start call failed, is skipped + for one day. `--retry-failed` tries them again. + +To set the order yourself, name the models. This replaces the rules: + +```bash +git config --global bigquery-jdbc.review-models "," # or BQ_JDBC_REVIEW_MODELS +cross-review.sh run --prompt-file "$PROMPT_FILE" --model "" # for one run +``` + +An order of your own goes stale. When the CLI stops offering a model, its start +call fails, and the script goes on to the next model that you named. + +## `cross-review.sh`: through the conversation CLI + +Some Antigravity installations have a conversation CLI: a client for the IDE's +language server, with the commands `new-conversation`, `list-conversations`, +`get-conversation`, `get-invocation`, `cancel` and `archive`. It is not `agy`, +and it is not the launcher that opens files in the IDE. Tell the script where +it is, once per machine: + +```bash +git config --global bigquery-jdbc.review-cli /path/to/the/conversation/cli +``` + +`BQ_JDBC_REVIEW_CLI` does the same for one shell. Run the script from an +Antigravity agent's shell. It takes the server address, the token and your own +conversation id from the `ANTIGRAVITY_*` variables that the IDE sets there. + +```bash +.agents/skills/bigquery-jdbc-prepare-pr/scripts/cross-review.sh models +.agents/skills/bigquery-jdbc-prepare-pr/scripts/cross-review.sh run --prompt-file "$PROMPT_FILE" +``` + +`models` shows your own model, what the CLI offers and the order `run` would +try. `run` returns when the reviewer has ended, so start it in the background +and start the own-model reviewer meanwhile. Until it returns, don't edit, +stage, commit or switch branches in that checkout: the script can't tell a +change of yours from one of the reviewer, and ends with status 3. For each +candidate, until one answers, it does this: + +1. Starts a new conversation on that model, with the start prompt. If the + start call fails, it reports the CLI's reason and goes on to the next + candidate. If the call succeeds and its output names no conversation, it + keeps that output next to the prompt file and stops with status 3. +2. Waits until the conversation ends, for 30 minutes at most (`--timeout-min`). +3. Cancels the conversation, whether it ended or not, waits until the CLI + reports that it no longer runs, and saves its transcript and its last + message next to the prompt file. +4. Compares the fingerprint of the checkout with the one from before the first + candidate, and audits the transcript: every tool step must be a file read or + a search. If either check fails, or the reviewer could not be stopped, it + stops with status 3 and tries no other model. +5. Goes on to the next candidate only if the model never answered, which is + how a model that can't start looks. After a reviewer that ran out of time or + gave a reply without the check word, it tries no other model. + +When it tries no further candidate, it looks once more: the CLI still shows +every conversation that it stopped as stopped, and the fingerprint is still the +same. If so, it archives the conversations. If not, it cancels the +conversation in question once more and ends with status 3. + +Then it prints what the report needs: the model and its id, the minutes, the +tool calls, the repository files read, the result of the audit, whether the +reviewer stopped, and whether the checkout changed. + +| Exit status | `outcome` | Meaning | What you do | +| --- | --- | --- | --- | +| 0 | `ok` | The reply starts with the check word, every tool step was a file read or a search, the reviewer has stopped, and the checkout is unchanged. | Use the review in `reply_file`, after the two checks of step 3 in SKILL.md that the script leaves to you: `repo_files_read` is not 0, and `NOT_CHECKED` in the reply is `none`. | +| 1 | none | The script couldn't run: the CLI isn't configured, it listed no models, or the script can't tell which model you run on. | Fix the setup, or name a model with `--model`. If you can't, go on with the own-model reviewer and say so in the report. | +| 2 | `no-reviewer`, `timeout`, `bad-reply` | No usable review: the CLI offers no model of another vendor, no model answered, the reviewer ran out of time, or its reply doesn't start with the check word. | Go on with the own-model reviewer and say so in the report. If the script says that the CLI offers no model of another vendor, you can name one with `--model` first. | +| 2 | `all-candidates-skipped` | Every candidate failed recently, so none was tried. | Run it once more with `--retry-failed`. | +| 3 | `rejected` | The run can't show that no reviewer changed anything: the checkout changed, a reviewer took a tool step that is not a file read or a search, a transcript can't be read, a reviewer could not be stopped or runs again, a start call named no conversation, or the script ended before it had made these checks. | Discard the review, stop and tell the user. If the script's message says that a reviewer may still run, cancel it in the IDE. The conversations are left unarchived, so that they can look at them. | +| Any other | none | The script was interrupted, or one of its steps failed, while no reviewer was under check. | Read its message and run it again. | + +### What the audit can and can't tell + +A reviewer started this way is a full agent. It has write tools, and it loads +the same rules and skills as you. The start prompt tells it to stay read-only, +and the script checks afterwards that it did: + +- The audit goes by the names that the transcript gives to tool steps. The + script holds a short list of steps that only read: viewing a file, searching + file contents, listing a directory and finding files by name. Any other tool + step fails the audit, whatever it did: a command, an edit, a subagent, a web + search or a tool the script has never seen. `other_tools` names them. +- The audit fails too if the transcript holds no step the script can read, a + step line it can't read, or a reply with the check word and not one tool + step, and if the CLI fails while it prints the transcript. That is what a + change in the CLI's output looks like. +- The audit finds a command only after it ran. For a diff that someone outside + the team wrote, use a reviewer without file-edit and shell tools instead: a + subagent of such a type. Look at what else it can do. In Antigravity a + `research` subagent can still search the web and call the MCP tools that are + configured. +- The audit doesn't look at what the reviewer read. A reviewer can open any + file that you can, also outside the repository. +- The fingerprint doesn't see ignored files outside the agent directories, + tags and remote-tracking refs, or anything outside the repository. Of `.git` + it covers `HEAD`, the local branches, the config (also the per-worktree + one), the hooks, and the exclude, attributes and sparse-checkout files, and + nothing else. +- While a reviewer is under check, an interrupt or a failing step of the + script cancels it and ends with status 3, because the checks were not made. + During the start call the script can't cancel, because it has no id yet: it + ends with status 3 and tells you to cancel in the IDE. If the script is + killed outright, the reviewer runs on: cancel it in the IDE. +- The CLI takes the token as a command-line argument, so other users of the + same machine can see it in the process list while a call runs. + +To audit a saved transcript again: + +```bash +.agents/skills/bigquery-jdbc-prepare-pr/scripts/cross-review.sh audit \ + --transcript --check-word +``` + +## Through `agy` + +`agy` is started by hand, so do by hand what `cross-review.sh run` does. Pick +the model from `agy models` by the rules above, stop the reviewer after 30 +minutes, and run `review.sh fingerprint` before and after it. If the two +differ, discard the review, stop and tell the user. + +`--sandbox` isolates the shell commands of that reviewer. Nobody has confirmed +here that it also keeps the reviewer's file tools from writing, so the +fingerprint is the check on this route, and `agy --sandbox` doesn't count as a +reviewer that can't write. diff --git a/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/references/reply-format.md b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/references/reply-format.md new file mode 100644 index 000000000000..72808cdba18d --- /dev/null +++ b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/references/reply-format.md @@ -0,0 +1,39 @@ +Review the diff below with the method above, and check the PR description +against the diff: it must say what changed, why, and how it was tested. + +From round 2 on, the ledger below shows what the author did with the earlier +findings: + +- If the ledger lists something that an earlier reviewer did not check, check + that first. +- For each finding marked FIXED, check the fix in the code. Don't repeat the + finding unless the fix is wrong or incomplete. +- For each finding marked PUSHBACK, say whether you ACCEPT the author's reason + (the finding is then closed) or MAINTAIN it, with a new argument. +- Findings marked WONTFIX are closed nits. Don't repeat them. +- Concentrate on what the ledger says changed since the previous round. Raise a + new finding on code that has not changed since then only if it is blocking or + major. + +Reply in exactly this format, after the READ-CHECK line that the end of this +file asks for. Write `none` under a heading that has no entries. + +VERDICT: APPROVE | CHANGES_REQUESTED +FINDINGS: +- id: R- + severity: blocking | major | minor | nit + location: : | PR description + issue: + suggestion: +QUESTIONS: +- +NOT_CHECKED: +- +PUSHBACK_RESPONSES: +- id: + decision: ACCEPT | MAINTAIN + reason: + +APPROVE only if no blocking or major finding is open. diff --git a/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/scripts/cross-review.sh b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/scripts/cross-review.sh new file mode 100755 index 000000000000..097eb032059f --- /dev/null +++ b/java-bigquery-jdbc/.agents/skills/bigquery-jdbc-prepare-pr/scripts/cross-review.sh @@ -0,0 +1,720 @@ +#!/usr/bin/env bash +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#/ Cross-model reviewer for the bigquery-jdbc-prepare-pr skill, through +#/ Antigravity's conversation CLI. See ../references/cross-model-reviewer.md. +#/ +#/ cross-review.sh models +#/ Show your own model, the models the CLI offers, and the order in +#/ which `run` would try them. +#/ cross-review.sh run --prompt-file FILE [--model NAME]... [--timeout-min N] +#/ [--retry-failed] +#/ Start one reviewer on a model of another vendor, wait for it, stop +#/ it, audit what it did, save its reply and archive its conversation. +#/ cross-review.sh audit --transcript FILE [--check-word WORD] +#/ Audit a saved transcript the way `run` does. It needs no CLI. +#/ +#/ Where the CLI is: git config --global bigquery-jdbc.review-cli +#/ or BQ_JDBC_REVIEW_CLI= +#/ Your model order: git config --global bigquery-jdbc.review-models a,b +#/ or BQ_JDBC_REVIEW_MODELS=a,b (optional) +#/ +#/ Exit status: 0 a review that passed the script's checks, 1 the script could +#/ not run, 2 no usable review, 3 the reviewer was not read-only or could not +#/ be checked. + +set -euo pipefail + +TIMEOUT_MIN_DEFAULT=30 +# Seconds between two looks at a running conversation. +POLL_SECONDS=${BQ_JDBC_REVIEW_POLL_SECONDS:-15} +# Polls in a row without the conversation in the CLI's list before it is lost. +LOST_AFTER_POLLS=5 +# Polls before the script gives up on seeing that a reviewer has stopped. +STOP_POLLS=8 +STATE_FILE="${XDG_STATE_HOME:-$HOME/.local/state}/bigquery-jdbc-review/models.tsv" +# The steps a read-only reviewer may take, by the names the transcript gives +# them. Any other tool step fails the audit. Add a name only after you have +# looked at what the tool does. +READ_ONLY_STEPS='view_file|grep_search|list_directory|find' + +die() { + echo "cross-review.sh: $*" >&2 + exit 1 +} + +need_value() { #