Skip to content

fix(mage): summarize proto changes instead of pasting the whole diff - #62

Merged
josephschorr merged 2 commits into
mainfrom
fix/regen-prompt-size
Aug 26, 2026
Merged

fix(mage): summarize proto changes instead of pasting the whole diff#62
josephschorr merged 2 commits into
mainfrom
fix/regen-prompt-size

Conversation

@josephschorr

Copy link
Copy Markdown
Member

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 raw git diff of its proto-client directory into the Claude prompt. Java's protobuf codegen emits one verbose file per message, so that diff is enormous:

proto client files changed lines
spicedb-java-proto 263 56,401
spicedb-csharp-proto 4 1,019
spicedb-python-proto 29 629
spicedb-go-proto 18 210
rust / typescript / ruby 4–5 39–113

Java is 55× the next largest, and the prompt blew the context window outright:

==> Invoking Claude to update idiomatic client...
Prompt is too long
Error: claude invocation failed: exit status 1
==> FAILED: spicedb-java: running "mage -d spicedb-java gen" failed with exit code 1

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 --stat plus git 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 after buf generate, so their prompts are small by construction.

Two details worth noting for review:

  • The empty-change check is re-keyed to names. It previously tested the raw diff string. Getting this wrong in either direction would make every client always-skip or never-skip.
  • Each file's own prompt text is preserved verbatim. The seven differ in language and test commands; only the change-delivery portion was touched.

Verification

go vet -tags mage clean at root and in the six vettable client dirs; gofmt clean; root mage tests pass; all seven files confirmed changed, with the names check and the claudeAvailable() gate present in each.

spicedb-go cannot compile with -tags mage — it holds package main and package spicedb in one directory. Pre-existing and unrelated; checked with gofmt instead.

…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.
@josephschorr
josephschorr merged commit 530e009 into main Aug 26, 2026
44 checks passed
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