Skip to content

feat: add Claude-powered upstream sync report generator#8

Draft
LucasRoesler wants to merge 5 commits intomainfrom
upstream-sync-automation
Draft

feat: add Claude-powered upstream sync report generator#8
LucasRoesler wants to merge 5 commits intomainfrom
upstream-sync-automation

Conversation

@LucasRoesler
Copy link
Member

Summary

  • Adds a Python script that uses Claude AI to analyze upstream commits and generate comprehensive backporting guidance
  • Adds a GitHub Actions workflow template for weekly automated reports (in workflow-examples/, see setup below)

How it works

The script (scripts/generate-upstream-sync-report.py):

  1. Fetches upstream commits from tiann/hapi
  2. Sends commit diffs and our fork's commit history to Claude
  3. Claude groups related commits semantically (feature + fixes + refactors together)
  4. Detects conflicts with our changes, recommends backport strategies, and estimates effort
  5. Outputs UPSTREAM_SYNC_REPORT.md with an executive summary table and per-group implementation plans

Usage

uv run scripts/generate-upstream-sync-report.py

Uses your existing Claude Code authentication — no extra API key setup needed locally.

GitHub Actions automation

A workflow template is included in .github/workflow-examples/weekly-upstream-sync-report.yml.

To activate it:

  1. Copy to .github/workflows/
  2. Add ANTHROPIC_API_KEY as a repository secret
  3. It will run every Monday at 9 AM UTC and create a GitHub issue with the report

The workflow was placed in workflow-examples/ rather than workflows/ because the current GitHub token doesn't have the workflow scope. Once the token is updated, the file can be moved to activate it.

Test plan

  • Run uv run scripts/generate-upstream-sync-report.py and verify UPSTREAM_SYNC_REPORT.md is generated
  • Check report contains executive summary table and per-commit-group sections
  • Verify upstream remote is added automatically if missing

Add automated tool that uses Claude AI to analyze upstream commits and
generate comprehensive backporting guidance.

Features:
- Semantic grouping of related commits (features + fixes + refactors)
- Conflict detection with fork's changes
- Backport strategy recommendations (cherry-pick/reimplement/skip)
- Risk assessment (High/Medium/Low conflict probability)
- Prioritization by value and effort
- Step-by-step implementation plans
- Actionable checklist organized by phase

The script:
- Auto-detects Claude Code authentication
- Fetches upstream commits automatically
- Analyzes file changes and diffs
- Compares with our fork's commit history
- Generates detailed markdown report with table summary

Usage:
  uv run scripts/generate-upstream-sync-report.py

Output:
  UPSTREAM_SYNC_REPORT.md with executive summary table and detailed
  analysis of each commit group including implementation plans

Integration:
- Run weekly to catch new upstream changes
- Follow Phase 1 quick wins for low-risk backports
- Update UPSTREAM_SYNC_LOG.md with actual results

Documentation:
- scripts/README.md: Full setup and usage guide
- scripts/EXAMPLE_USAGE.md: Real-world examples and workflows
Add automated workflow that runs every Monday at 9 AM UTC to:
- Generate upstream sync analysis report using Claude AI
- Create or update GitHub issue with report
- Upload full report as workflow artifact
- Provide actionable checklist and quick links

Features:
- Auto-updates existing issue if less than 1 week old
- Prevents issue spam by reusing recent issues
- Includes report preview (first 3000 chars) in issue
- Links to sync strategy and log documents
- Can be manually triggered via workflow_dispatch

Setup required:
- Add ANTHROPIC_API_KEY as repository secret
- Workflow will run automatically on schedule

Issue includes:
- Executive summary preview
- Link to download full report artifact
- Next steps checklist
- Workflow run details

Updated scripts/README.md with automation setup instructions.
Add comprehensive setup guide explaining how to enable the automated
upstream sync workflow after merging.

Covers:
- What the automation adds (script + workflow + docs)
- Step-by-step setup (merge PR + add API key)
- Manual usage option
- What to expect from weekly runs
- Issue reuse logic (prevents spam)
- Weekly workflow integration
- Cost estimates (-6/month)
- Troubleshooting common issues
- Links to all documentation

Makes onboarding straightforward for enabling automation.
Moving the GitHub Actions workflow to .github/workflow-examples/ so
the branch can be pushed without the workflow scope on the token.

To activate, copy to .github/workflows/ and add ANTHROPIC_API_KEY
as a repository secret.
@LucasRoesler LucasRoesler force-pushed the upstream-sync-automation branch from 3ca8dde to 3dd523a Compare February 18, 2026 22:10
Add Backport: commit footer convention and supporting script logic to
exclude previously-handled upstream commits from future reports.

Convention: backport commits on our fork include a trailer footer:

    Backport: sha1...sha2,sha3,sha4...sha5

Where each entry is a single upstream SHA or an inclusive range
(old_sha...new_sha). One footer covers all upstream commits addressed
by a single backport — whether cherry-picked, reimplemented, or
bundled together. Commits without a footer reappear in future reports.

Script changes:
- parse_backport_footer(): parses the comma-separated footer value
- get_handled_upstream_shas(): scans main's commit history for
  Backport: footers and expands ranges via git log old^..new
- get_upstream_commits(): now accepts handled set and filters it out
- main(): prints how many commits were found vs filtered vs remaining,
  exits early with a clean message if nothing remains to report

Both short and full SHAs are accepted in footers; unresolvable SHAs
produce a warning and are skipped rather than crashing.
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