Skip to content

CAMEL-23932: Auto-delete stale branches and enforce fork usage for AI agents - #25275

Merged
gnodet merged 2 commits into
apache:mainfrom
gnodet:investigate-and-fix-camel-23932-ensure-ai-agents
Jul 31, 2026
Merged

CAMEL-23932: Auto-delete stale branches and enforce fork usage for AI agents#25275
gnodet merged 2 commits into
apache:mainfrom
gnodet:investigate-and-fix-camel-23932-ensure-ai-agents

Conversation

@gnodet

@gnodet gnodet commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses CAMEL-23932 — AI agents push branches directly to apache/camel and fail to clean them up after PRs are merged or closed.

Changes

  1. Expanded pr-cleanup-branches.yml: The workflow now deletes any non-protected branch pushed directly to apache/camel when its PR is merged or closed. Previously it only matched automated/upgrade*, leaving backport/*, feature/*, fix/*, investigate-and-fix-*, dependabot/*, dependency/*, ci/*, and ad-hoc AI agent branches to accumulate indefinitely.

    Protected patterns excluded from cleanup:

    • main
    • camel-* (all maintenance branches like camel-4.14.x, camel-4.18.x, plus legacy camel-1.x/camel-2.x/camel-3.x)
    • regen_bot_* (persistent branches reused by the regen bot across multiple PRs)
  2. Strengthened CLAUDE.md/AGENTS.md: Changed fork-preference from advisory "should prefer" to mandatory "MUST use". Also upgraded branch deletion from "should be deleted" to "MUST be deleted", with a note that the workflow handles it automatically for upstream branches.

Stale branches found during investigation

These branches exist on apache/camel with their PRs already merged or closed:

Branch PR State
backport/25036-to-camel-4.14.x #25068 MERGED
backport/25036-to-camel-4.18.x #25067 MERGED
feature/CAMEL-24259-tui-tabs-and-inline-docs #25114 MERGED
regen_bot_3x #12263 MERGED (2023!)
fix-camel-24227-add-volatile-to-jmx-writable-fiel #24985 MERGED
fix/CAMEL-24140 #24820 MERGED
investigate-and-fix-flaky-aws-eventbridge-localsta #25148 CLOSED

These will need to be deleted manually (the workflow only triggers on future PR close events).

Test plan

  • Verify YAML syntax is valid (workflow passes actionlint or GitHub Actions validation)
  • Merge or close a test PR from a non-protected branch on apache/camel and verify the branch is auto-deleted
  • Verify that main, camel-*.x, and regen_bot_* branches are never affected
  • Review the AGENTS.md language change for clarity

Claude Code on behalf of gnodet

🤖 Generated with Claude Code

… agents

Expand pr-cleanup-branches.yml to delete any non-protected branch pushed
directly to apache/camel when its PR is merged or closed.  Previously the
workflow only covered `automated/upgrade*` branches, leaving backport/*,
feature/*, fix/*, regen_bot_*, investigate-and-fix-*, and other patterns
to accumulate indefinitely.

Protected patterns excluded: `main`, `camel-*.x`.

Also strengthen CLAUDE.md/AGENTS.md fork-preference from "should" to "MUST"
so AI agents are clearly instructed to use their own forks rather than
pushing directly to the upstream repo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet marked this pull request as ready for review July 31, 2026 09:39
@gnodet
gnodet requested review from apupier, davsclaus and oscerd July 31, 2026 09:39
@github-actions github-actions Bot added the docs label Jul 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

Comment on lines +33 to +34
&& github.event.pull_request.head.ref != 'main'
&& !startsWith(github.event.pull_request.head.ref, 'camel-')

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.

regen_bot_sbom must be kept too, see comment #25115 (comment)

The regen_bot_sbom branch is a persistent branch reused across
multiple PRs by the regen bot — deleting it would break the bot.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet

gnodet commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@apupier Good catch — added regen_bot_* to the exclusion list in 69660e9. The regen bot reuses these branches across multiple PRs, so they must be preserved.

Protected patterns now:

  • main
  • camel-* (maintenance branches)
  • regen_bot_* (persistent regen bot branches)

Claude Code on behalf of gnodet

@gnodet
gnodet requested a review from apupier July 31, 2026 11:38
@gnodet gnodet added this to the 4.22.0 milestone Jul 31, 2026
@gnodet gnodet self-assigned this Jul 31, 2026
@gnodet gnodet added the task label Jul 31, 2026
@gnodet
gnodet merged commit 1f28fb6 into apache:main Jul 31, 2026
3 checks passed
@gnodet
gnodet deleted the investigate-and-fix-camel-23932-ensure-ai-agents branch July 31, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants