Skip to content

[q] fix: improve patch size logging with warning level and diff stat breakdown (#23865)#23871

Merged
pelikhan merged 2 commits intomainfrom
q/improve-patch-size-logging-23865-11e6b7dc79747fb7
Apr 1, 2026
Merged

[q] fix: improve patch size logging with warning level and diff stat breakdown (#23865)#23871
pelikhan merged 2 commits intomainfrom
q/improve-patch-size-logging-23865-11e6b7dc79747fb7

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 1, 2026

Summary

Investigating issue #23865: the push_repo_memory job failed with a "Patch Size Exceeded" error for the daily-copilot-token-report workflow.

Root Cause Analysis

Patch computation: ✅ Fixed — The original implementation used the full git diff --cached output (additions + deletions) to measure patch size. This was incorrect: a workflow that rewrites a large accumulated history file (e.g. 35 KB of old content → 9.8 KB new content) would be charged ~45 KB against the limit, even though only 9.8 KB of new content is actually being pushed.

Correct behavior: Only additions (new content) should count toward the patch size limit. Deletions are acceptable and do not contribute to the size of content being pushed.

The configured max-patch-size default (10 KB) was also too small for accumulating-history workflows.

The Logging Bug

The logging was also insufficient to diagnose this:

  1. The patch size line was core.info — invisible in GitHub Actions default output (only shown in verbose/debug mode)
  2. No per-file breakdown was provided, making it impossible to tell if it was a single large file or many small files

Changes Made

actions/setup/js/push_repo_memory.cjs

  • Additions-only patch size: Patch size is now computed by counting only added lines (+ lines, excluding +++ file-header lines) from git diff --cached. Deletions are fully ignored.
  • Warning level when patch additions size exceeds the configured limit (including within the 20% overhead window)
  • git diff --cached --stat output emitted as core.warning on failure, showing per-file line additions/deletions
  • Messages updated to say "Patch additions size" for clarity

Expected Log Output After Fix

##[warning]Patch additions size: 9 KB (9800 bytes) (configured limit: 10 KB (10240 bytes), effective with 20% overhead: 12 KB (12288 bytes))
##[warning]Patch content breakdown (git diff --stat):
 memory/token-metrics/history.jsonl | 435 ++++++++++------------------------
 1 file changed, 87 insertions(+), 348 deletions(-)

Only the 9.8 KB of new additions counts against the limit — the 35 KB of deletions is ignored.

References

🎩 Equipped by Q ·

  • expires on Apr 3, 2026, 11:58 AM UTC

…kdown (#23865)

When repo-memory patch size exceeds the configured limit, the patch size
line was logged at info level (invisible in default GitHub Actions output)
and provided no breakdown of which files contributed to the large diff.

Changes:
- Log patch size at warning level when it exceeds the configured limit
  (both in the 20% overhead window and over the effective limit)
- On failure, run git diff --cached --stat and emit it as a warning to
  show per-file line additions/deletions, clarifying WHY the patch is large
  (e.g. a rewritten history.jsonl shows old + new content as full diff)
- Add a comment explaining that the patch size reflects the full git diff
  (old + new content for modified files), which can exceed the file size

Root cause of run #23846022060: memory/token-metrics/history.jsonl on the
branch had ~35 KB of accumulated history; the agent rewrote it to 9.8 KB,
producing a 45 KB diff (deletions + additions). The computation is correct;
the default max-patch-size of 10 KB was simply too small for this workflow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 1, 2026

@copilot deletions size should be ignored in patch size computation . It's ok to delete content and it should not be used to compute the patch size.

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

@copilot deletions size should be ignored in patch size computation . It's ok to delete content and it should not be used to compute the patch size.

Done in 435c47b. The patch size computation now only counts added lines (starting with +, excluding +++ file-header lines) — deletions are fully ignored. The message label was also updated to "Patch additions size" for clarity.

Copilot AI requested a review from pelikhan April 1, 2026 12:18
@pelikhan pelikhan merged commit 32e0e4e into main Apr 1, 2026
27 checks passed
@pelikhan pelikhan deleted the q/improve-patch-size-logging-23865-11e6b7dc79747fb7 branch April 1, 2026 12:43
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