Skip to content

# Improve Metric Accuracy for Issues, PRs, and Review Distribution#26131

Open
gemini-cli-robot wants to merge 3 commits into
mainfrom
bot/productivity-updates-20260428171816-25067138299
Open

# Improve Metric Accuracy for Issues, PRs, and Review Distribution#26131
gemini-cli-robot wants to merge 3 commits into
mainfrom
bot/productivity-updates-20260428171816-25067138299

Conversation

@gemini-cli-robot
Copy link
Copy Markdown
Collaborator

Improve Metric Accuracy for Issues, PRs, and Review Distribution

1. What the change is

This PR refactors the open_issues.ts and open_prs.ts metric scripts to use the GitHub GraphQL API's totalCount field instead of relying on the CLI's gh issue list command with a hardcoded limit. It also updates review_distribution.ts to include COLLABORATOR in the maintainer association check.

2. Why it is recommended

The current implementation of open_issues.ts and open_prs.ts used --limit 1000, which caused metrics to be capped at 1000 even when the actual backlog was much larger (~2400 issues). This provided a misleading view of repository health and the true scale of the backlog. Using GraphQL totalCount ensures accurate counts regardless of list size.

Additionally, review_distribution.ts was inconsistently excluding COLLABORATOR associations, which could lead to an inaccurate representation of review work distribution if many maintainers are designated as Collaborators. This led to a review_distribution_variance of 0 in recent runs.

3. Which metric or aspect of productivity is expected to be improved

  • open_issues: Will now reflect the true total count (expected to jump from 1000 to ~2400).
  • open_prs: Will reflect the true total count of open pull requests.
  • review_distribution_variance: Will more accurately reflect how review work is shared among all maintainers (including collaborators).

4. By how much the metric is expected to improve

The open_issues metric is expected to increase by approximately 140% (from 1000 to ~2400) once accurate data is collected. The review_distribution_variance is expected to become non-zero, providing a real baseline for monitoring reviewer workload balance.

## 1. What the change is
This PR refactors the `open_issues.ts` and `open_prs.ts` metric scripts to use the GitHub GraphQL API's `totalCount` field instead of relying on the CLI's `gh issue list` command with a hardcoded limit. It also updates `review_distribution.ts` to include `COLLABORATOR` in the maintainer association check.

## 2. Why it is recommended
The current implementation of `open_issues.ts` and `open_prs.ts` used `--limit 1000`, which caused metrics to be capped at 1000 even when the actual backlog was much larger (~2400 issues). This provided a misleading view of repository health and the true scale of the backlog. Using GraphQL `totalCount` ensures accurate counts regardless of list size.

Additionally, `review_distribution.ts` was inconsistently excluding `COLLABORATOR` associations, which could lead to an inaccurate representation of review work distribution if many maintainers are designated as Collaborators. This led to a `review_distribution_variance` of 0 in recent runs.

## 3. Which metric or aspect of productivity is expected to be improved
- **open_issues**: Will now reflect the true total count (expected to jump from 1000 to ~2400).
- **open_prs**: Will reflect the true total count of open pull requests.
- **review_distribution_variance**: Will more accurately reflect how review work is shared among all maintainers (including collaborators).

## 4. By how much the metric is expected to improve
The `open_issues` metric is expected to increase by approximately **140%** (from 1000 to ~2400) once accurate data is collected. The `review_distribution_variance` is expected to become non-zero, providing a real baseline for monitoring reviewer workload balance.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

Size Change: -4 B (0%)

Total Size: 33.9 MB

Filename Size Change
./bundle/chunk-GKST6E7K.js 0 B -2.72 MB (removed) 🏆
./bundle/chunk-GMBHX5PS.js 0 B -3.43 kB (removed) 🏆
./bundle/chunk-HJDOG3G7.js 0 B -3.8 kB (removed) 🏆
./bundle/chunk-IC2N4F4L.js 0 B -19.5 kB (removed) 🏆
./bundle/chunk-J5DSEW4X.js 0 B -14.7 MB (removed) 🏆
./bundle/chunk-SBWAX6RM.js 0 B -12.6 kB (removed) 🏆
./bundle/chunk-YXBC4QIM.js 0 B -655 kB (removed) 🏆
./bundle/chunk-Z5VWQGEZ.js 0 B -49.2 kB (removed) 🏆
./bundle/core-C33OLXWT.js 0 B -48.2 kB (removed) 🏆
./bundle/devtoolsService-WDRCN767.js 0 B -28 kB (removed) 🏆
./bundle/gemini-3TABAJRC.js 0 B -576 kB (removed) 🏆
./bundle/interactiveCli-532OH56R.js 0 B -1.31 MB (removed) 🏆
./bundle/liteRtServerManager-4PXA7TAH.js 0 B -2.11 kB (removed) 🏆
./bundle/oauth2-provider-M3DBP5AM.js 0 B -9.16 kB (removed) 🏆
./bundle/chunk-47U7G5RU.js 3.8 kB +3.8 kB (new file) 🆕
./bundle/chunk-6DXWSINE.js 19.5 kB +19.5 kB (new file) 🆕
./bundle/chunk-AOGJUBFF.js 655 kB +655 kB (new file) 🆕
./bundle/chunk-M2KB5DCN.js 49.2 kB +49.2 kB (new file) 🆕
./bundle/chunk-O5XBUHH6.js 14.7 MB +14.7 MB (new file) 🆕
./bundle/chunk-QE4IE7ZS.js 12.6 kB +12.6 kB (new file) 🆕
./bundle/chunk-V4DP4AUE.js 2.72 MB +2.72 MB (new file) 🆕
./bundle/chunk-V64RSY3Y.js 3.43 kB +3.43 kB (new file) 🆕
./bundle/core-WWHDII6C.js 48.2 kB +48.2 kB (new file) 🆕
./bundle/devtoolsService-CEXPCRXN.js 28 kB +28 kB (new file) 🆕
./bundle/gemini-SK5OL2SU.js 576 kB +576 kB (new file) 🆕
./bundle/interactiveCli-XFNK53PB.js 1.31 MB +1.31 MB (new file) 🆕
./bundle/liteRtServerManager-ADZ66RBI.js 2.11 kB +2.11 kB (new file) 🆕
./bundle/oauth2-provider-TPLCXRPG.js 9.16 kB +9.16 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/bundled/third_party/index.js 8 MB 0 B
./bundle/chunk-34MYV7JD.js 2.45 kB 0 B
./bundle/chunk-5AUYMPVF.js 858 B 0 B
./bundle/chunk-5PS3AYFU.js 1.18 kB 0 B
./bundle/chunk-664ZODQF.js 124 kB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/chunk-RJTRUG2J.js 39.8 kB 0 B
./bundle/chunk-XRLFHCHC.js 1.97 MB 0 B
./bundle/cleanup-AD7BW7BC.js 0 B -932 B (removed) 🏆
./bundle/devtools-36NN55EP.js 696 kB 0 B
./bundle/dist-T73EYRDX.js 356 B 0 B
./bundle/events-XB7DADIJ.js 418 B 0 B
./bundle/examples/hooks/scripts/on-start.js 188 B 0 B
./bundle/examples/mcp-server/example.js 1.43 kB 0 B
./bundle/gemini.js 5.1 kB 0 B
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB 0 B
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB 0 B
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB 0 B
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB 0 B
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB 0 B
./bundle/memoryDiscovery-FN3IAPBT.js 980 B 0 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 222 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 229 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 13.4 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B
./bundle/src-QVCVGIUX.js 47 kB 0 B
./bundle/start-2ITW7HZE.js 0 B -652 B (removed) 🏆
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B
./bundle/cleanup-6J66CCLS.js 932 B +932 B (new file) 🆕
./bundle/start-E34MZ4F2.js 652 B +652 B (new file) 🆕

compressed-size-action

Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request Apr 29, 2026
- BerriAI/litellm#26766 Azure AD token auth + api-key header fix (merge-after-nits)
- BerriAI/litellm#26763 Excepton -> Exception log typo fix (merge-as-is)
- google-gemini/gemini-cli#26131 metric accuracy via GraphQL totalCount (merge-after-nits)
@akh64bit
Copy link
Copy Markdown
Contributor

PR Review: Recommendations & Callouts

Overall, this is a very solid improvement. Here are a few recommendations and callouts to consider:

1. Behavioral Change in open_issues.ts and open_prs.ts

In both open_issues.ts and open_prs.ts, the original code falls back to logging 0 if gh fails:

-} catch {
-  // Fallback if gh fails or no issues found
-  console.log('open_issues,0');
+} catch (err) {
+  process.stderr.write(err instanceof Error ? err.message : String(err));
+  process.exit(1);
+}

The new behavior explicitly exits with code 1 on failure. While this is a best practice because it avoids masking network/API errors as "0 open issues", it constitutes a behavioral change. We should confirm that downstream consumers of these scripts handle the failure/non-zero exit code gracefully.

2. Consistent Use of explicit stdio: ['pipe', 'pipe', 'ignore']

In domain_expertise.ts, stdio is explicitly configured as ['pipe', 'pipe', 'ignore'] to ensure the input pipe works correctly:

stdio: ['pipe', 'pipe', 'ignore']

In latency.ts and a few other scripts, stdio is omitted.

Node's execSync automatically pipes standard input when input is passed, but being explicit (e.g., matching domain_expertise.ts) improves clarity and ensures consistency across all files. It is worth making them fully identical.

@gundermanc gundermanc marked this pull request as ready for review April 29, 2026 17:40
@gundermanc gundermanc requested a review from a team as a code owner April 29, 2026 17:40
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the accuracy and reliability of repository health metrics. By transitioning from CLI-limited list commands to direct GraphQL totalCount queries, the system now correctly accounts for all open issues and pull requests regardless of volume. Additionally, the inclusion of collaborators in review distribution metrics provides a more complete picture of team contribution and workload balance.

Highlights

  • Improved Metric Accuracy: Refactored open issues and PR scripts to use GraphQL totalCount instead of CLI-based limits, ensuring accurate reporting for large backlogs.
  • Expanded Maintainer Definition: Updated review distribution logic to include COLLABORATOR in the maintainer association check for more comprehensive workload analysis.
  • Standardized GraphQL Execution: Updated all metric scripts to use a standardized, safer approach for executing GitHub GraphQL queries via the CLI.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors several metrics scripts to utilize the GitHub GraphQL API more securely by passing parameters through environment variables and handling API errors explicitly. It also expands the reviewer definition to include collaborators. Feedback focuses on standardizing the output format across scripts using the MetricOutput interface for consistency and timestamps, and ensuring normalized login names are used in review_distribution.ts to prevent duplicate entries.

* SPDX-License-Identifier: Apache-2.0
*/

import { GITHUB_OWNER, GITHUB_REPO } from '../types.js';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

To maintain consistency with other metric scripts in this repository, this script should use the MetricOutput type for its output. This ensures that all metrics follow the same schema, including the required timestamp.

Suggested change
import { GITHUB_OWNER, GITHUB_REPO } from '../types.js';
import { GITHUB_OWNER, GITHUB_REPO, type MetricOutput } from '../types.js';

throw new Error(response.errors.map((e: { message: string }) => e.message).join(', '));
}
const count = response.data.repository.issues.totalCount;
console.log(`open_issues,${count}`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The output format should be updated to JSON lines using the MetricOutput interface to match the standard used by other scripts in the metrics suite. This improves system consistency and ensures that a timestamp is included with the metric value.

  const timestamp = new Date().toISOString();
  process.stdout.write(
    JSON.stringify(<MetricOutput>{
      metric: 'open_issues',
      value: count,
      timestamp,
    }) + '\n',
  );

* SPDX-License-Identifier: Apache-2.0
*/

import { GITHUB_OWNER, GITHUB_REPO } from '../types.js';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

To maintain consistency with other metric scripts in this repository, this script should use the MetricOutput type for its output. This ensures that all metrics follow the same schema, including the required timestamp.

Suggested change
import { GITHUB_OWNER, GITHUB_REPO } from '../types.js';
import { GITHUB_OWNER, GITHUB_REPO, type MetricOutput } from '../types.js';

throw new Error(response.errors.map((e: { message: string }) => e.message).join(', '));
}
const count = response.data.repository.pullRequests.totalCount;
console.log(`open_prs,${count}`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The output format should be updated to JSON lines using the MetricOutput interface to match the standard used by other scripts in the metrics suite. This improves system consistency and ensures that a timestamp is included with the metric value.

  const timestamp = new Date().toISOString();
  process.stdout.write(
    JSON.stringify(<MetricOutput>{
      metric: 'open_prs',
      value: count,
      timestamp,
    }) + '\n',
  );

for (const review of pr.reviews.nodes) {
if (
['MEMBER', 'OWNER'].includes(review.authorAssociation) &&
['MEMBER', 'OWNER', 'COLLABORATOR'].includes(review.authorAssociation) &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Please use the lowercased login variable when adding to the reviewersOnPR set to ensure consistent casing and prevent duplicate entries in reviewCounts, which would skew the variance calculation.

@gundermanc gundermanc enabled auto-merge April 29, 2026 17:48
@gundermanc gundermanc disabled auto-merge April 29, 2026 17:48
@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Apr 29, 2026
@gundermanc
Copy link
Copy Markdown
Member

@gemini-cli-robot please fix the failing checks in this PR.

@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants