git_show redacts the whole patch once per file header, on unbounded output

オープン
#181 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go

調査の方向性

Start with internal/agent/tools/git.go at patchFile and the redaction loop, then trace how internal/gitx/gitx.go buffers Show output and how internal/agent/tools/tools.go limits the final result. Check existing tests around git_show and redaction first. Done means output is size limited, each file section is redacted once with cancellation checks, and a 1,000 file commit test completes within a bounded time.

索引モデルが issue の本文から書いたものです。

説明

good first issue performance severity: medium

Summary

The git_show tool runs a full redaction pass over the entire git show output for every ---/+++ header in it, on output that is not bounded, to produce at most 24 KB. A commit that touches many files stalls the run.

Where

  • internal/agent/tools/git.go:122 (patchFile)
  • internal/agent/tools/git.go:155-167 (loop of redact.ApplyIn over the whole output)
  • internal/gitx/gitx.go:366, :549 (Show output buffered without a limit)
  • internal/agent/tools/tools.go:250-258 (finish redacts again and cuts to 24,000 bytes)

Details

gitx.Show returns the whole git show --stat --patch <rev> output. The tool then loops over every header and calls redact.ApplyIn(file, out) on the entire output each time. A modified file has both headers, so the same name is applied twice. Each call is a full scan: a lower-cased copy of the text, every gated regular expression, the remembered-value search and a rebuilt string. The loop does not check the context. Cost is O(H x S) for H header lines and S patch bytes.

Impact

An investigator, reviewer, prover or fixer that calls git_show on a commit touching many files (an initial commit, a vendoring or formatting commit, a large merge) stalls. Estimate, not measured: 1,000 changed files with a 5 MB patch is about 2,000 passes over 5 MB, many minutes for one tool call. The wall-time cap is only checked between model calls, so it does not interrupt this. git_log lists such commits by default.

Steps to reproduce

  1. In a repository whose latest commit adds about 1,000 text files, run an agentic scan.
  2. Have the model call git_show with that commit's hash and no path.
  3. The tool call does not return for minutes while one core is busy in redaction.

Suggested fix

Bound the output first (read git show through a limit of a few MB, since only 24 KB is ever returned). Then redact each file's section once with its own name: split on diff --git boundaries and call ApplyIn(file, section) per section, which is O(S) in total. Check ctx.Err() between sections.

Acceptance criteria

  • git show output is read through a size limit
  • Each file section is redacted once, with its own file name
  • The loop honors cancellation
  • A test with a 1,000-file commit returns in bounded time

Getting started

  • Relevant files: internal/agent/tools/git.go, internal/agent/tools/tools.go, internal/gitx/gitx.go
  • How to run tests: make test-short (Unix) or .\make.ps1 test-short (Windows PowerShell); make lint before you call it done
  • Related docs: CONTRIBUTING.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at 50e92ec. Severity: medium. Effort: S. audit-key: performance|internal/agent/tools/git.go|gitShowTool

主要言語
Go
スター
0
フォーク
1
平均マージ
8時間 14分
マージ済み PR(30日)
3

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TMHSDigital/Spackle のほかの issue

TMHSDigital/Spackle の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。