mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 22:02:59 -07:00
4810e7794b
This PR implements several critical improvements to repository health monitoring and automated triage workflows. ### Summary of Changes 1. **Backlog Age Metric**: Added `tools/gemini-cli-bot/metrics/scripts/backlog_age.ts` to measure the median and P90 age of open issues and PRs. This addresses the "Survivorship Bias" in current latency metrics, which only sample recently closed items. 2. **Metrics Persistence**: Fixed a bug in `tools/gemini-cli-bot/metrics/index.ts` that limited the timeseries history to 100 lines (effectively ~2 runs). Increased to 5000 lines to preserve historical trends. 3. **Robust Stale Closer**: Upgraded `.github/workflows/gemini-scheduled-stale-issue-closer.yml` to a 2-phase system (Mark as Stale -> Close). This centralized logic replaces the throttled default stale action and includes robust human activity detection. 4. **Triage Bug Fix**: Fixed a critical bug in `.github/workflows/unassign-inactive-assignees.yml` where a missing `for` loop caused the script to fail. 5. **Policy Consolidation**: Disabled issue staleness in `.github/workflows/stale.yml` to avoid conflicts with the new custom 2-phase closer. ### Why this is recommended - **Data-Driven Triage**: Without backlog age metrics, we were blind to the "Slow Path" backlog that is growing despite fast "recently closed" latency. - **Automated Hygiene**: The broken and throttled triage workflows were allowing the backlog to grow unchecked (now at 2351 issues). These fixes restore automated pruning. - **Metrics Reliability**: Expanding the timeseries window ensures that deltas and trends are calculated against stable historical data. ### Impact - **Backlog Visibility**: New metrics will show the real age of open items. - **Throughput**: Increased stale closer throughput will begin reducing the 2300+ issue backlog. - **Reliability**: Automated unassignment of inactive contributors will keep "help wanted" items moving.
Gemini CLI Bot (Cognitive Repository)
This directory contains the foundational architecture for the gemini-cli-bot,
transforming the repository into a proactive, evolutionary system.
It implements a dual-layer approach to balance immediate responsiveness with long-term strategic optimization.
Layered Execution Model
1. System 1: The Pulse (Reflex Layer)
- Purpose: High-frequency, deterministic maintenance.
- Frequency: 30-minute cron (
.github/workflows/gemini-cli-bot-pulse.yml). - Implementation: Pure TypeScript/JavaScript scripts.
- Classification: Optionally utilizes Gemini CLI for high-confidence semantic classification (e.g., triage, labeling, sentiment) while preferring deterministic logic for equivalent tasks.
- Phases:
- Reflex Execution: Runs triage, routing, and automated maintenance
scripts in
reflexes/scripts/.
- Reflex Execution: Runs triage, routing, and automated maintenance
scripts in
- Output: Real-time action execution.
2. System 2: The Brain (Reasoning Layer)
- Purpose: Strategic investigation, policy refinement, and proactive self-optimization.
- Frequency: 24-hour cron (
.github/workflows/gemini-cli-bot-brain.yml). - Implementation: Agentic Gemini CLI phases.
- Phases:
- Metrics Collection: Executes scripts in
metrics/scripts/to track repository health (Open issues, PR latency, throughput, etc.). - Phase 1: Reasoning (Metrics & Root-Cause Analysis): Analyzes time-series metric trends and repository state to identify bottlenecks or productivity gaps, tests hypotheses, and proposes script or configuration changes to improve repository health and maintainability.
- Phase 2: Critique: A technical and logical validation layer that reviews proposed changes for robustness, actor-awareness, and anti-spam protocols.
- Phase 3: Publish: Automatically promotes approved changes to Pull Requests, handles branch management, and responds to maintainer feedback.
- Metrics Collection: Executes scripts in
Directory Structure
metrics/: Deterministic runner (index.ts) and scripts for tracking repository metrics via GitHub CLI.reflexes/scripts/: Deterministic triage and routing scripts executed by the Pulse.brain/: Prompt templates and logic for strategic root-cause analysis (Phase 1:metrics.md) and technical validation (Phase 2:critique.md).history/: Persistent storage for time-series metrics artifacts.lessons-learned.md: The bot's structured memory, containing the Task Ledger, Hypothesis Ledger, and Decision Log.
Usage
Local Metrics Collection
To manually collect repository metrics locally, run the following command from the workspace root:
npx tsx tools/gemini-cli-bot/metrics/index.ts
This will execute all scripts within metrics/scripts/ and output the results
to tools/gemini-cli-bot/history/metrics-before.csv.
Development
When modifying the bot's logic:
- Reflexes: Add or update scripts in
reflexes/scripts/. - Reasoning: Update the prompts in
brain/to refine how the bot identifies bottlenecks. - Critique: Update the prompts in
critique/to strengthen the validation of proposed changes.