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

Đang mở
#181 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
performance, tooling

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Go
Star
0
Fork
1
Merge trung bình
8 giờ 14 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TMHSDigital/Spackle

Tất cả issue của TMHSDigital/Spackle

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.