Skip to content

feat(caretaker): add triage worker core foundation (part 1/2)#28163

Open
chadd28 wants to merge 4 commits into
google-gemini:mainfrom
chadd28:feat/caretaker-triage
Open

feat(caretaker): add triage worker core foundation (part 1/2)#28163
chadd28 wants to merge 4 commits into
google-gemini:mainfrom
chadd28:feat/caretaker-triage

Conversation

@chadd28

@chadd28 chadd28 commented Jun 26, 2026

Copy link
Copy Markdown

Summary

This Pull Request introduces the core foundational modules for the Caretaker Agent Triage Worker (tools/caretaker-agent/cloudrun/triage-worker/). To keep code review focused and modular, the Triage Worker implementation is split into two Pull Requests:

  • Part 1 (This PR): Establishes the Firestore concurrency ledger, output validation schemas, AI reasoning prompts/skills, and automated CI test infrastructure.
  • Part 2 (Follow-up PR): Connects the Cloud Run Job execution orchestrator, logging helpers, and Docker container configuration.

Details

  • Firestore Concurrency Ledger & CI Workflow: Implements db/issues_store.py providing transactional lock claim/release routines, 15-minute lock expiration timers, and 2-strike escalation rules. Adds .github/workflows/tools-python-ci.yml for automated Python CI testing.
  • Output Schema Validator: Implements utils/validator.py enforcing strict JSON structure and metadata validation for LLM triage outputs, along with unit tests.
  • AI Reasoning Prompts & Skills: Adds system orchestration instructions (.gemini/triage_orchestrator.md) and dedicated skills (quality, effort, spec_generator) under .gemini/skills/.

How to Validate

Reviewers can validate this PR by running the automated Python unit test suite:

  1. Verify via GitHub Actions: Check the automated Testing: Tools (Python) status check.
  2. Run Unit Tests Locally:
cd tools/caretaker-agent/cloudrun/triage-worker
python3 -m unittest discover

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • [] npm run
      • [] npx
      • Docker

chadd28 added 3 commits June 25, 2026 19:11
…or testing

- Add GitHub Actions CI workflow in .github/workflows/tools-python-ci.yml for automated Python testing.
- Add requirements.txt for triage worker dependencies and configure pip caching in CI.
- Implement claim and release lock transactions with 15-minute lock expiration in db/issues_store.py.
- Add unit tests in tests/test_issues_store.py with top-level mock patching for offline CI verification.
@chadd28 chadd28 requested review from a team as code owners June 26, 2026 17:22
@github-actions github-actions Bot added the size/l A large sized PR label Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

📊 PR Size: size/L

  • Lines changed: 766
  • Additions: +766
  • Deletions: -0
  • Files changed: 15

@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 establishes the core foundational architecture for the Caretaker Agent Triage Worker. It focuses on implementing reliable state management via Firestore and enforcing strict validation for AI-driven triage outputs. By introducing transactional locking and modular AI reasoning skills, this change provides the necessary infrastructure to support automated issue triage workflows.

Highlights

  • Firestore Concurrency Ledger: Implemented db/issues_store.py to provide transactional lock claim and release routines, ensuring safe concurrent processing of GitHub issues.
  • Output Validation: Added utils/validator.py to enforce strict JSON schema compliance for AI-generated triage outputs, including comprehensive unit tests.
  • AI Reasoning Skills: Introduced system orchestration instructions and specialized skills (quality, effort, spec_generator) to guide the Triage Worker's reasoning process.
  • Testing Infrastructure: Established a robust unit testing suite for the Firestore store and validator modules to ensure reliability in the CI pipeline.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/tools-python-ci.yml
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 the 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 counterproductive. 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.

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

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.

Code Review

This pull request introduces a Python-based triage worker for managing and validating GitHub issue triage workflows, including Firestore-backed state locking, LLM output validation, and associated unit tests. The code review highlights several critical security and architectural issues that must be addressed: a potential dependency confusion vulnerability in requirements.txt due to the unverified google-antigravity package, a path traversal vulnerability in utils/validator.py caused by a lack of path validation on untrusted LLM outputs, module-level Firestore client initialization that hinders clean unit testing, and potential AttributeError crashes when handling null lock fields in Firestore.

Comment thread tools/caretaker-agent/cloudrun/triage-worker/requirements.txt Outdated
Comment thread tools/caretaker-agent/cloudrun/triage-worker/utils/validator.py Outdated
Comment thread tools/caretaker-agent/cloudrun/triage-worker/db/issues_store.py Outdated
Comment thread tools/caretaker-agent/cloudrun/triage-worker/db/issues_store.py Outdated
Comment thread tools/caretaker-agent/cloudrun/triage-worker/db/issues_store.py Outdated
Comment thread tools/caretaker-agent/cloudrun/triage-worker/db/issues_store.py Outdated
Comment thread tools/caretaker-agent/cloudrun/triage-worker/db/issues_store.py Outdated
Comment thread tools/caretaker-agent/cloudrun/triage-worker/tests/test_issues_store.py Outdated
@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Jun 26, 2026
@chadd28

chadd28 commented Jun 26, 2026

Copy link
Copy Markdown
Author

@gundermanc @adamfweidman ready for your review whenever you have a chance! To try and keep the PR easy to review, I split the worker into two parts. If you'd prefer me to append the rest of the main orchestrator loop into this same PR instead of doing a Part 2, let me know. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l A large 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.

1 participant