Stage diffs: clean Git files take their baseline from the index blob

On a large Git workspace the 32 MiB retained-text budget was spent
alphabetically on files that never change, so small late edits were
recorded with no_patch. The stage-start snapshot now keeps text only for
files dirty or untracked at start; a clean tracked file keeps its hash and
stage-0 index blob id. When it changes or is deleted, the after capture
reads that blob in one `git cat-file --batch` and uses it only if its
SHA-256 matches the start read, so stage commits/resets do not move the
baseline and filters or assume-unchanged never yield a wrong patch. The
after capture shares unchanged files' representation instead of spending
budget on them again.

FileChange gains no_patch_reason (binary, file_size, budget, lines,
evidence_size, git_status, baseline). Non-Git workspaces keep their
behaviour.
This commit is contained in:
2026-11-04 17:08:01 +00:00
parent 6870c81960
commit 70391b17c2
7 changed files with 506 additions and 40 deletions
+14 -1
View File
@@ -18,8 +18,16 @@ includes the same evidence under each step's `file_changes` field.
content is the baseline. Changes are retained separately for repeated visits.
- In a Git working tree, capture includes tracked and nonignored untracked files
within the run directory. Previously captured files remain eligible after an
index/ignore change. Git is used only for inventory, never to stage or revert.
index/ignore change. Git is only read, never used to stage or revert.
Outside Git, capture walks regular files in the run directory.
- In Git, the stage-start snapshot keeps text only for files that are dirty or
untracked at start (`git status`); a clean tracked file keeps just its hash and
index blob id. If it changes, its start content is read back from that blob
(`git cat-file --batch`) and used only when its SHA-256 matches what was read
from disk at start. A commit, reset or index change by the stage therefore does
not move the baseline, and the text budget is no longer spent alphabetically on
files that never change. A blob that cannot be verified (filters, line-ending
conversion, `assume-unchanged`) is listed with `no_patch_reason: "baseline"`.
- Added/deleted files and permission changes are recorded. Renames appear as
deletion/addition. Binary changes retain metadata, not binary contents.
- Symlinks, special files, common credential/environment/key/database paths,
@@ -39,6 +47,11 @@ includes the same evidence under each step's `file_changes` field.
`git status --porcelain` entry changed during the visit; a path dirty with the
same status before and after cannot be proven changed and stays in `skipped`.
Git is only read (`--no-optional-locks`); protected paths are never listed.
- Each content change without a (complete) patch carries `no_patch_reason`:
`binary`, `file_size` (text over 1 MiB), `budget` (32 MiB snapshot text
budget), `lines` (over 5,000 combined lines), `evidence_size` (per-visit
retained evidence limit), `git_status` (seen only in Git status) or `baseline`.
Binary changes stay `complete`; the others make the visit `partial`.
- `pipelines inspect RUN_ID --json` carries a top-level `warnings` list (also
printed to stderr) naming every visit whose capture was partial or unavailable.
- Failed/canceled stages still retain changes when execution returns. Unconfirmed