Skip to content

fix: isolate summarization subprocess from git repo (ENT-242, ENT-243)#173

Merged
khaong merged 4 commits intomainfrom
alex/ent-242-fix-index-corruption
Feb 8, 2026
Merged

fix: isolate summarization subprocess from git repo (ENT-242, ENT-243)#173
khaong merged 4 commits intomainfrom
alex/ent-242-fix-index-corruption

Conversation

@khaong
Copy link
Contributor

@khaong khaong commented Feb 7, 2026

Summary

  • ENT-242: Claude Code's summarization subprocess (claude --print) was polluting the worktree index with phantom entries from its internal plugin cache (e.g., tests/claude-code/README.md with blob SHA that doesn't exist in the object store), causing fatal: unable to read <sha> errors on subsequent git status calls. Fix isolates the subprocess by running from os.TempDir(), stripping all GIT_* env vars, and using empty --setting-sources.
  • ENT-243: Generated summaries were silently dropped during condensation because writeSessionToSubdirectory() was missing Summary: opts.Summary in the CommittedMetadata struct literal.

Root cause investigation

The original theory (go-git's worktree.Status() rewriting the index) was wrong — Status() only reads the index, never writes it. The actual cause was the claude --print subprocess inheriting the git hook environment (GIT_DIR), which let Claude Code's internal git operations (plugin cache, context gathering) write phantom entries into the worktree index.

Confirmed by:

  1. Replacing claude --print with a 15s sleep → index stays clean
  2. Running claude --print from tmpdir without GIT_* env vars → index stays clean
  3. Running claude --print from tmpdir WITH GIT_* env vars → index still corrupted

Test plan

  • mise run fmt && mise run lint && mise run test:ci passes
  • Manual testing: 3 consecutive condensation commits with clean index checksums (before/after md5 match)
  • Verify summary field appears in condensed metadata.json

🤖 Generated with Claude Code


Note

Medium Risk
Touches checkpoint metadata persistence and changes how the summarization subprocess is executed (working directory and environment), which could affect summary generation behavior and any setups relying on inherited git/config state.

Overview
Prevents Claude CLI summarization (claude --print) from polluting or discovering the caller’s git repo by disabling settings loading (--setting-sources ""), running the subprocess from os.TempDir(), and stripping all inherited GIT_* environment variables.

Fixes a checkpoint persistence regression by actually writing WriteCommittedOptions.Summary into the session-level metadata.json, and adds regression tests covering both summary persistence and the new git-isolation behavior.

Written by Cursor Bugbot for commit e23db7a. This will update automatically on new commits. Configure here.

khaong and others added 2 commits February 7, 2026 19:51
Claude Code performs internal git operations (plugin cache, context
gathering) that pollute the worktree index with phantom entries from
its plugin cache (e.g., tests/claude-code/README.md). This causes
"fatal: unable to read <sha>" errors on subsequent git status calls.

Fix by fully isolating the subprocess:
- Run from os.TempDir() instead of the repo cwd
- Strip all GIT_* env vars (git hooks set GIT_DIR which lets the
  subprocess find the repo regardless of cwd)
- Use empty --setting-sources to skip all settings

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Entire-Checkpoint: 3ea54a9f1dde
The CommittedMetadata struct in writeSessionToSubdirectory() was
missing the Summary field, causing generated summaries to be
silently dropped during condensation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Entire-Checkpoint: 3ea54a9f1dde
Copilot AI review requested due to automatic review settings February 7, 2026 08:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses two condensation/summarization issues in Entire CLI: it isolates the Claude CLI summarization subprocess from the user’s git repository to prevent index corruption (ENT-242), and ensures generated summaries are persisted into committed session metadata (ENT-243).

Changes:

  • Run claude --print from os.TempDir() and strip all GIT_* environment variables to prevent the subprocess from discovering/modifying the parent repo.
  • Use an empty --setting-sources value to avoid loading user/project/local settings during summarization.
  • Persist Summary into CommittedMetadata when writing session-level metadata.json.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cmd/entire/cli/summarize/claude.go Isolates the Claude summarization subprocess via temp working dir + stripped git env to prevent index pollution.
cmd/entire/cli/checkpoint/committed.go Fixes omission so opts.Summary is written into session-level committed metadata.

…ence

Add tests verifying:
- Claude CLI subprocess runs from temp dir with GIT_* env vars stripped
- stripGitEnv helper correctly filters environment variables
- Summary field persists through WriteCommitted/ReadSessionContent round-trip

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Entire-Checkpoint: 1b7631912f60
@khaong khaong marked this pull request as ready for review February 7, 2026 10:05
@khaong khaong requested a review from a team as a code owner February 7, 2026 10:05
@khaong khaong enabled auto-merge February 7, 2026 11:59
auto-merge was automatically disabled February 8, 2026 02:49

Head branch was modified

@khaong khaong enabled auto-merge February 8, 2026 02:50
@khaong khaong merged commit 2a7a86e into main Feb 8, 2026
4 checks passed
@khaong khaong deleted the alex/ent-242-fix-index-corruption branch February 8, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants