Skip to content

Signal truncation in git diff, git log, and json filters #621

Closed

Description

@FlorianBruniaux

Problem

Three filters cut signal that LLMs need to function correctly:

1. git diff — max_hunk_lines = 30 (src/git.rs:281)

30 lines per hunk is too low for any meaningful refactor. Claude sees a truncated diff, assumes the change is complete, then produces incorrect code because it missed the rest of the hunk.

2. git log — 1 line of commit body (src/git.rs:492-493)

The filter keeps only the subject line and drops the body after the first non-empty line. This silently discards:

  • BREAKING CHANGE: notes
  • Migration instructions
  • Co-author / fix references

Claude operating on release history or changelogs gets a misleading picture.

3. json — all values stripped (src/json_cmd.rs:86-173)

The JSON filter removes all values and shows only structure. For config debugging (the primary use case), this is useless — Claude needs to see both keys and values to spot a misconfiguration.

Proposed fixes

Filter Current Proposed
git diff hunk cap 30 lines 50-100 lines (configurable)
git log body 1 line 3 first non-empty lines
json values stripped preserved by default, opt-in --keys-only

Acceptance criteria

  • rtk git diff shows hunks up to 100 lines before truncating
  • rtk git log preserves BREAKING CHANGE and other body metadata
  • rtk json shows values by default; --keys-only for structure-only view
  • All three filters still achieve ≥50% savings vs raw output

Activity

  1. FlorianBruniaux commented on Mar 28, 2026

    @FlorianBruniaux
    ContributorAuthor

    Confirmed this is still unaddressed. Scoped the actual changes needed:

    1. src/cmds/git/git.rs compact_diff(): raise max_hunk_lines from 30 to 50 (or make configurable via config.toml)
    2. src/cmds/git/git.rs filter_log_output(): change body limit from 1 line to 3 non-empty lines (to preserve BREAKING CHANGE: notes, migration instructions, co-author refs)
    3. src/cmds/system/json_cmd.rs: preserve values by default, add --keys-only flag for structure-only view

    Acceptance criteria: all three filters must still achieve at least 50% savings vs raw output.

    Will address in a separate PR after the discover coverage PR lands.

  2. added a commit that references this issue on Mar 28, 2026
    097456e
  3. em0t commented on Apr 3, 2026

    @em0t
    Contributor

    Part of this is now addressed by #993 (merged): #993

    Specifically, rtk git diff now preserves the full unified diff hunk header, including the trailing function / symbol context after the second @@ marker. This fixes one class of lost diff context in compact diff output.

    Example of the part fixed by #993:

    • before: @@ -10,3 +10,4 @@
    • now: @@ -10,3 +10,4 @@ fn important_context() {

    This does not resolve the rest of this issue yet (for example the separate hunk line cap, git log body preservation, or JSON value preservation), but it does fix one of the git diff signal-loss cases described here.

  4. added a commit that references this issue on Apr 9, 2026
    c16713a
  5. pszymkowiak commented on Apr 12, 2026

    @pszymkowiak
    Collaborator

    [w] wshm · Automated triage by AI

    🔍 Automated Triage

    ✨ Category feature
    🟠 Priority high
    🎯 Confidence 88%

    Summary

    Three filters (git diff, git log, json) truncate too aggressively, losing signal LLMs need; PR #863 already addresses the json portion — remaining work on git diff hunk cap and git log body retention.

    📁 Relevant files
    • src/git.rs
    • src/json_cmd.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-criticalBloque des utilisateurs, fix ASAPeffort-medium1-2 jours, quelques fichiersenhancementNew feature or requestfilter-qualityFilter produces incorrect/truncated signal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions