Skip to content

Fix reap tests#266

Merged
wanghailei merged 2 commits intomainfrom
fix-reap-tests
Mar 12, 2026
Merged

Fix reap tests#266
wanghailei merged 2 commits intomainfrom
fix-reap-tests

Conversation

@wanghailei
Copy link
Owner

No description provided.

@gemini-code-assist
Copy link
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 significantly refines the Carson project's automated worktree management by introducing a more robust mechanism for identifying and removing abandoned development branches, thereby preventing the accumulation of stale worktrees. Concurrently, it integrates comprehensive linting configurations for multiple programming languages, aiming to standardize code quality and formatting across the repository. These changes improve both operational efficiency and code maintainability.

Highlights

  • Enhanced Worktree Reaping Logic: The reap_dead_worktrees! method now includes a third layer of checking for 'abandoned' worktrees, which are those associated with closed-but-unmerged pull requests, provided no open PR still exists for that branch. This expands the conditions under which a worktree is considered 'dead' and can be safely removed.
  • New PR Evidence Functions: Introduced abandoned_pr_for_branch to specifically identify closed-but-unmerged PRs and closed_prs_for_branch as a new helper to query all closed PRs for a given branch tip. The existing merged_pr_for_branch now leverages this new helper.
  • Bot Username Normalization: The bot_username? helper was updated to normalize bot usernames by stripping the [bot] suffix, ensuring consistent matching for bot authors regardless of whether the name comes from GraphQL or REST APIs.
  • New Linter Configurations: Added comprehensive linter configuration files for Biome (JSON), ERB-Lint (YAML), RuboCop (YAML), and Ruff (TOML) under .github/linters/. These configurations establish consistent formatting and linting rules for JavaScript, CSS, Ruby, and Python files.
  • Updated Carson Governance Description: The .github/carson.md file was updated to provide a more descriptive role for Carson, changing its description from 'autonomous governance runtime' to 'autonomous git strategist and repositories governor'.
  • Expanded Test Coverage: New tests were added to cover the expanded worktree reaping logic for abandoned worktrees and the bot username normalization, ensuring the new functionalities behave as expected.
Changelog
  • .github/carson.md
    • Updated Carson's role description from 'governance runtime' to 'git strategist and repositories governor'.
  • .github/linters/biome.json
    • Added new Biome linter configuration file for JavaScript and CSS, enforcing tab indentation and enabling linter rules.
  • .github/linters/erb-lint.yml
    • Added new ERB-Lint configuration file, enabling default linters and specific rules for ERB templates.
  • .github/linters/rubocop.yml
    • Added new RuboCop configuration file, setting Ruby 4.0 as target, enforcing tab indentation, and defining various style and metric rules.
  • .github/linters/ruff.toml
    • Added new Ruff linter configuration file for Python, selecting common lint rules, ignoring specific indentation/line length rules, and enforcing tab indentation and double quotes.
  • lib/carson/runtime/housekeep.rb
    • Expanded reap_dead_worktrees! to include a 'three-layer dead check' for worktrees, adding abandoned PR evidence as a criterion.
    • Updated comments to reflect the new three-layer dead check logic.
    • Added a check to skip worktrees that are currently held by another process.
    • Modified verbose output for reaped abandoned worktrees to include the associated PR URL.
  • lib/carson/runtime/local/prune.rb
    • Introduced closed_prs_for_branch to query all closed PRs for a given branch tip.
    • Refactored merged_pr_for_branch to utilize the new closed_prs_for_branch helper.
    • Added abandoned_pr_for_branch to find closed-but-unmerged PRs for a branch tip.
    • Updated error messages for PR lookup to be more descriptive.
    • Modified the structure of PR data to include closed_at for better tracking.
  • lib/carson/runtime/review/gate_support.rb
    • Modified bot_username? to normalize bot usernames by stripping the [bot] suffix, ensuring consistent matching across different API sources.
  • test/runtime_housekeep_test.rb
    • Added build_housekeep_worktree helper method for creating mock worktree objects.
    • Added a test case to verify that reap_dead_worktrees! correctly reaps abandoned worktrees when no open PR exists.
    • Added a test case to ensure reap_dead_worktrees! skips abandoned worktrees if an open PR still exists.
  • test/runtime_review_helpers_test.rb
    • Added a test to confirm merged_pr_for_branch correctly ignores closed-unmerged matches.
    • Added a test to verify abandoned_pr_for_branch returns the latest closed-unmerged PR match.
    • Added a test to ensure bot_username? matches bot names consistently, with and without the [bot] suffix.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

GitHub's GraphQL API returns "gemini-code-assist" while the REST API
returns "gemini-code-assist[bot]" for the same GitHub App. The
bot_username? check now strips the [bot] suffix from both sides before
comparing, so bot reviews are correctly filtered regardless of which
API sourced the author login.

This was causing the review sweep to flag all gemini-code-assist
activity as actionable findings (25 false positives).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
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 enhances the reap_dead_worktrees! functionality to also clean up worktrees associated with abandoned (closed but not merged) pull requests. The logic has been thoughtfully refactored to introduce a generic closed_prs_for_branch helper, which is then used by more specific finders for merged and abandoned PRs. The bot_username? check has also been made more robust to handle inconsistencies between GitHub's APIs. Additionally, new linter configurations have been added for Biome, ERB-Lint, RuboCop, and Ruff, which will help maintain code quality and consistency across the project. The accompanying tests are thorough and cover the new logic well. I've left a suggestion to further improve performance and readability by optimizing a helper method.

def bot_username?( author: )
config.review_bot_usernames.any? { it.downcase == author.to_s.downcase }
normalised = author.to_s.downcase.delete_suffix( "[bot]" )
config.review_bot_usernames.any? { it.downcase.delete_suffix( "[bot]" ) == normalised }
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This implementation correctly handles the different bot username formats. However, it re-processes the config.review_bot_usernames array on every call by iterating and normalizing each entry. This can be inefficient if the list is large or the method is called frequently.

To improve performance and readability, consider normalizing and memoizing the list of bot usernames once. You could introduce a private helper method for this.

For example:

# In lib/carson/runtime/review/gate_support.rb

def bot_username?(author:)
  normalised_author = author.to_s.downcase.delete_suffix("[bot]")
  normalised_bot_usernames.include?(normalised_author)
end

private

def normalised_bot_usernames
  @normalised_bot_usernames ||= config.review_bot_usernames.map { |name| name.downcase.delete_suffix("[bot]") }.to_set
end

Using a Set here provides fast lookups, which is ideal for this kind of check.

The cop produces mixed tabs+spaces when correcting outdented private
keywords with tab-based indentation. The 3 excluded files follow the
same outdent convention as the rest of the codebase but trigger a
tab-width calculation bug. Also sets IndentationWidth: 1 on the cop
to prevent similar issues in new files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wanghailei wanghailei merged commit 69602f9 into main Mar 12, 2026
0 of 2 checks passed
@wanghailei wanghailei deleted the fix-reap-tests branch March 12, 2026 08:35
wanghailei added a commit that referenced this pull request Mar 12, 2026
The Carson template sync wiped the IndentationWidth and file exclusions
that PR #266 added. Re-apply them so CI passes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
wanghailei added a commit that referenced this pull request Mar 12, 2026
The Carson template sync wiped the IndentationWidth and file exclusions
that PR #266 added. Re-apply them so CI passes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant