[PR #5193] [CLOSED] ci(issue-bot): improve limits, tooling, concurrency, and update bot facts #5814

Closed
opened 2026-11-02 04:04:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5193
Author: @rqzbeh
Created: 6/11/2026
Status: ❌ Closed

Base: main ← Head: feature/claude-bot-improvements


📝 Commits (1)

  • baf844f chore: improve claude-issue-bot limits, tooling, and concurrency

📊 Changes

1 file changed (+86 additions, -67 deletions)

View changed files

📝 .github/workflows/claude-issue-bot.yml (+86 -67)

📄 Description

Summary

This PR comprehensively improves the claude-issue-bot.yml workflow, making it safer, more accurate, and up-to-date with the recent internal/ architecture refactoring. It resolves several critical limitations of the previous implementation and introduces concurrency safeguards.

Issues Addressed & Solutions

1. Outdated Repository Context

Issue: The bot's hardcoded "Repository map" was severely outdated. It missed the internal/ prefix and the extensive splitting of web/service/ into granular domain files (e.g., client_*.go, inbound_*.go) introduced in the recent massive refactor (#5167). It also lacked awareness of new protocols (MTProto via mtg), CLI commands (migrateDB), and database structures (hashed API tokens).
Solution: Updated the BOT_FACTS block to perfectly reflect the post-refactor internal/ structure, new directories, and added explicit facts about hashing and Fail2ban systemd usage.

2. DRY Violations and Command Injection Risks

Issue: The system prompt facts were duplicated: once as a multiline string in handle-issue, and again as a massive 450-word string passed directly via --append-system-prompt in the mention job. Furthermore, injecting text with inner double quotes into a double-quoted CLI argument created bash parsing vulnerabilities.
Solution: Extracted all knowledge into a single GitHub Actions workflow-level env.BOT_FACTS block, making it perfectly DRY. Replaced inner double quotes with single quotes ('postgres://...') and changed the mention job's argument wrapper to strict single quotes (--append-system-prompt '... ${{ env.BOT_FACTS }}') to guarantee 100% shell injection safety.

3. Insufficient Tools and Limits

Issue: The bot was instructed to "check git history" but lacked Bash(git:*) tool permissions and used a shallow clone (fetch-depth: 1), meaning it hallucinated git history. Additionally, --max-turns was too low (90 and 70), causing deep investigations to abort prematurely.
Solution: Added fetch-depth: 0 to the checkout action and granted Bash(git:*) tool permissions so the bot can accurately read git logs and blame. Increased --max-turns to 120 (for issues) and 90 (for mentions).

4. Missing Concurrency and Timeout Safeguards

Issue: The jobs could theoretically run forever or stack indefinitely if a user spammed mentions.
Solution: Added strict 15-minute timeout-minutes hard caps. Implemented issue-scoped concurrency groups with cancel-in-progress: true to prevent race conditions and automatically abort stale bot runs if a new comment is posted.

How to test

Review the .github/workflows/claude-issue-bot.yml changes. All shell invocations and YAML structures have been thoroughly verified for syntax and escaping.

Contribution Guide Compliance

  • Changes are strictly isolated to CI/Bot configuration (focused diff).
  • The commit message follows conventional commit prefixes (ci(issue-bot): ...).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5193 **Author:** [@rqzbeh](https://github.com/rqzbeh) **Created:** 6/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/claude-bot-improvements` --- ### 📝 Commits (1) - [`baf844f`](https://github.com/MHSanaei/3x-ui/commit/baf844fa874dc2b532650026dda923400c29f77e) chore: improve claude-issue-bot limits, tooling, and concurrency ### 📊 Changes **1 file changed** (+86 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/claude-issue-bot.yml` (+86 -67) </details> ### 📄 Description ### Summary This PR comprehensively improves the `claude-issue-bot.yml` workflow, making it safer, more accurate, and up-to-date with the recent `internal/` architecture refactoring. It resolves several critical limitations of the previous implementation and introduces concurrency safeguards. ### Issues Addressed & Solutions #### 1. Outdated Repository Context **Issue:** The bot's hardcoded "Repository map" was severely outdated. It missed the `internal/` prefix and the extensive splitting of `web/service/` into granular domain files (e.g., `client_*.go`, `inbound_*.go`) introduced in the recent massive refactor (#5167). It also lacked awareness of new protocols (MTProto via `mtg`), CLI commands (`migrateDB`), and database structures (hashed API tokens). **Solution:** Updated the `BOT_FACTS` block to perfectly reflect the post-refactor `internal/` structure, new directories, and added explicit facts about hashing and Fail2ban systemd usage. #### 2. DRY Violations and Command Injection Risks **Issue:** The system prompt facts were duplicated: once as a multiline string in `handle-issue`, and again as a massive 450-word string passed directly via `--append-system-prompt` in the `mention` job. Furthermore, injecting text with inner double quotes into a double-quoted CLI argument created bash parsing vulnerabilities. **Solution:** Extracted all knowledge into a single GitHub Actions workflow-level `env.BOT_FACTS` block, making it perfectly DRY. Replaced inner double quotes with single quotes (`'postgres://...'`) and changed the `mention` job's argument wrapper to strict single quotes (`--append-system-prompt '... ${{ env.BOT_FACTS }}'`) to guarantee 100% shell injection safety. #### 3. Insufficient Tools and Limits **Issue:** The bot was instructed to "check git history" but lacked `Bash(git:*)` tool permissions and used a shallow clone (`fetch-depth: 1`), meaning it hallucinated git history. Additionally, `--max-turns` was too low (90 and 70), causing deep investigations to abort prematurely. **Solution:** Added `fetch-depth: 0` to the checkout action and granted `Bash(git:*)` tool permissions so the bot can accurately read git logs and blame. Increased `--max-turns` to 120 (for issues) and 90 (for mentions). #### 4. Missing Concurrency and Timeout Safeguards **Issue:** The jobs could theoretically run forever or stack indefinitely if a user spammed mentions. **Solution:** Added strict 15-minute `timeout-minutes` hard caps. Implemented issue-scoped `concurrency` groups with `cancel-in-progress: true` to prevent race conditions and automatically abort stale bot runs if a new comment is posted. ### How to test Review the `.github/workflows/claude-issue-bot.yml` changes. All shell invocations and YAML structures have been thoroughly verified for syntax and escaping. ### Contribution Guide Compliance - Changes are strictly isolated to CI/Bot configuration (focused diff). - The commit message follows conventional commit prefixes (`ci(issue-bot): ...`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:16 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5814
No description provided.