fix(mage): summarize proto changes instead of pasting the whole diff - #62
Merged
Conversation
…ude prompt GitHub Actions run 33014735194 failed spicedb-java's Gen() with "Prompt is too long": spicedb-java-proto alone produced 263 changed files and 56,401 changed lines in one regeneration (55x the next largest client), and the raw `git diff` was being pasted whole into the prompt. This is structural to Java's protobuf codegen (one verbose file per message), so it fails on every regeneration, not just this one. Replace the raw diff with a `git diff --stat` summary plus a `git diff --name-status` file list, and tell Claude to read the changed files itself -- it has full file access on the runner, so this is both smaller and more useful than a truncated diff. The empty-changes check now keys off the name-status output instead of the old diff string. Applied identically to all seven idiomatic spicedb-*/Magefile.go files; each file's existing language-specific instruction sentences are preserved verbatim.
The measured cause lives in spicedb-java/Magefile.go, where the failure actually happened; the other six point at it rather than repeating it.
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.
Fixes the one failure in the first real end-to-end regeneration (run 33014735194, PR #61). Java failed; the other six languages succeeded.
Cause
Each idiomatic client's
Gen()pasted the entire rawgit diffof its proto-client directory into the Claude prompt. Java's protobuf codegen emits one verbose file per message, so that diff is enormous:Java is 55× the next largest, and the prompt blew the context window outright:
This is structural, not a flake. Java would fail on every regeneration, making every PR permanently
regen-partial.Fix
Summarize instead of pasting:
git diff --statplusgit diff --name-status, with the prompt telling Claude to read the changed files itself. Claude has file access on the runner, so this is both smaller and more useful than a truncated diff — it can open whichever files it actually needs rather than working from a arbitrarily-cut fragment.Applied uniformly to all seven
spicedb-*/Magefile.go.proto-clients/*are untouched: they diff their own directory immediately afterbuf generate, so their prompts are small by construction.Two details worth noting for review:
names. It previously tested the rawdiffstring. Getting this wrong in either direction would make every client always-skip or never-skip.Verification
go vet -tags mageclean at root and in the six vettable client dirs;gofmtclean; root mage tests pass; all seven files confirmed changed, with thenamescheck and theclaudeAvailable()gate present in each.spicedb-gocannot compile with-tags mage— it holdspackage mainandpackage spicedbin one directory. Pre-existing and unrelated; checked withgofmtinstead.