Repository navigation
feat(backport): run backport-fix-imports with an ai pass gated on go vet - #330
Open
vcauesantos wants to merge 3 commits into
Open
vcauesantos wants to merge 3 commits into
vcauesantos wants to merge 3 commits into
Conversation
…the assignee, keep the token from go tools
This was referenced Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #329. Together they make backports to older release lines fix their own imports.
backport.yamlgets afix-importsflag, off by default. When it's on, a job runsbackport-fix-importson every backport branch after the cherry-picks.anthropic-api-keyis passed and Go conflicts are still left after the script. Its answers are committed only for packages that passgofmtandgo vet. Anything else is reverted and left for a person.fix.pynow skips quietly when a label has no backport branch, for example a legacy line.backport-ai-resolvedlabel, so auto-approve can keep it for a person. If the label can't be added, the AI commit isn't pushed. Skipping the label in auto-approve comes in a separate PR.go vetandgofmtrun without the push token in their environment.Flow
flowchart TD A[PR merged with backport-to labels] --> B[Bot cherry-picks and opens backport PRs] B --> C[One job per backport branch] C --> D[Fix imports with the script and push] D --> E{Go conflicts left and an API key set?} E -->|No| Done[Done: anything left is for a person] E -->|Yes| F[Send the conflicted Go files to the AI in one call] F --> G{Every conflict in the file answered, and the package passes go vet?} G -->|Yes| H[Commit and push the AI fix as its own commit] G -->|No| I[Revert: leave the conflict for a person]If any step fails, nothing more is pushed, and the backport PR stays as it was.
How much AI this means
Replay of all 54 bot backports to 4.x since the v5 module change: the script alone leaves 43 with nothing to do. Of the 11 with conflicts left, about 4 or 5 have Go conflicts, so only those would call the AI. The rest are YAML conflicts, which are never sent.
Real run on loft-enterprise
The action ran from this branch on five temporary branches in
loft-enterprise. Each holds the bot's original commit from a real backport. It used the repo's own token and Anthropic key. Nothing was merged, and the branches will be deleted after review.Runs: first four, #8571
pkg/tenancy, which 4.12 does not have.go vetpassed, and it was committed: bee5777The script and AI call take 4 to 20 seconds per branch. When the AI answers, the
go vetcheck adds about 4 minutes, mostly a cold Go build on the runner.Test plan
make test-backport-fix-imports: 91 pytest tests. The AI-pass tests run realgofmtandgo veton a small made-up module and fake the model's answer:make lint(actionlint, zizmor) andmake check-docsare clean.Merge #329 first, so this PR targets
mainwhen it merges.Closes DEVOPS-1648
Closes DEVOPS-1671