Skip to content

fix(#1625): exclude agent working directories from git tracking#1627

Open
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/1625-exclude-agent-work-dirs
Open

fix(#1625): exclude agent working directories from git tracking#1627
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/1625-exclude-agent-work-dirs

Conversation

@fullsend-ai-coder
Copy link
Copy Markdown

The code agent was committing its own working artifacts (e.g. .agentready/) into target repositories, causing review churn and requiring multiple fix iterations to clean up.

Two-layer defense:

  1. Harness-level (internal/cli/run.go): Add known agent working
    directory patterns (.agentready/, .fullsend-workspace/) to
    .git/info/exclude before the agent starts execution. This
    makes git completely ignore these directories — git status
    and git add will not see them.

  2. Post-script (scripts/post-code.sh): Defense-in-depth check
    that detects and warns if agent artifacts somehow appear in
    the commit's changed files, as a safety net if the exclude
    mechanism is bypassed.

The agentWorkingDirExcludes variable is a centralized list that can be extended as new agent working directories are identified.


Closes #1625

Post-script verification

  • Branch is not main/master (agent/1625-exclude-agent-work-dirs)
  • Secret scan passed (gitleaks — 8480e16153a3f16c66b5484bfd4c76349a89933d..HEAD)
  • Pre-commit hooks passed (authoritative run on runner)
  • Tests ran inside sandbox

The code agent was committing its own working artifacts (e.g.
.agentready/) into target repositories, causing review churn
and requiring multiple fix iterations to clean up.

Two-layer defense:

1. Harness-level (internal/cli/run.go): Add known agent working
   directory patterns (.agentready/, .fullsend-workspace/) to
   .git/info/exclude before the agent starts execution. This
   makes git completely ignore these directories — git status
   and git add will not see them.

2. Post-script (scripts/post-code.sh): Defense-in-depth check
   that detects and warns if agent artifacts somehow appear in
   the commit's changed files, as a safety net if the exclude
   mechanism is bypassed.

The agentWorkingDirExcludes variable is a centralized list that
can be extended as new agent working directories are identified.

Closes #1625
@github-actions
Copy link
Copy Markdown

Site preview

Preview: https://a47f2493-site.fullsend-ai.workers.dev

Commit: fed62a94cc649972a29140b446715e6cbe8e93b6

@fullsend-ai-review
Copy link
Copy Markdown

Review

Findings

High

  • [correctness] internal/scaffold/fullsend-repo/scripts/post-code.sh:129 — Section 2b ("Strip agent working directories") detects agent artifacts and logs ::warning:: messages, but never actually removes them from the commit. STRIPPED_FILES is set but never consumed — no git rm, git reset HEAD, or filtering of CHANGED_FILES follows. The defense-in-depth layer is inert: if an agent bypasses .git/info/exclude and stages artifacts, they will still be pushed.
    Remediation: After the detection loop, use git rm --cached on each file in STRIPPED_FILES and amend the commit (or filter CHANGED_FILES to exclude them before the push step). The test helper strip_agent_artifacts in post-code-test.sh has the same gap — it validates detection but not removal.

Low

  • [security] internal/cli/run.go:1359excludeAgentWorkingDirs constructs a shell command via fmt.Sprintf with both payload and repoDir interpolated into a single-quoted string. With the current hardcoded values this is safe, and the pattern is consistent with existing code (line 369), but it is fragile: a future agentWorkingDirExcludes entry containing a single quote would break the shell command or inject. Consider writing the patterns to a temp file and appending via cat, or escaping the payload.

  • [correctness] internal/cli/run_test.go:821 — Go tests verify the agentWorkingDirExcludes slice contents but do not test the excludeAgentWorkingDirs function itself. The function's shell command generation, error handling, and interaction with the sandbox are untested. The shell-level tests in post-code-test.sh provide partial coverage for the detection logic but not the Go harness path.

Copy link
Copy Markdown

@fullsend-ai-review fullsend-ai-review Bot left a comment

Choose a reason for hiding this comment

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

See the review comment for full details.

echo "Changed files:"
echo "${CHANGED_FILES}" | sed 's/^/ /'

# ---------------------------------------------------------------------------
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[high] correctness

Section 2b ("Strip agent working directories") detects agent artifacts and logs warnings, but never actually removes them from the commit. STRIPPED_FILES is set but never consumed — no git rm, git reset HEAD, or filtering of CHANGED_FILES follows. The defense-in-depth layer is inert.

Suggested fix: After the detection loop, use git rm --cached on each file in STRIPPED_FILES and amend the commit, or filter CHANGED_FILES to exclude them before the push step.

Comment thread internal/cli/run.go
}
if len(lines) == 0 {
return nil
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] security

excludeAgentWorkingDirs constructs a shell command via fmt.Sprintf with payload and repoDir interpolated into a single-quoted string. Safe with current hardcoded values and consistent with existing patterns, but fragile if a future agentWorkingDirExcludes entry contains a single quote.

Suggested fix: Consider writing patterns to a temp file and appending via cat, or escaping the payload.

Comment thread internal/cli/run_test.go
assert.NoError(t, validateLinuxBinary(binPath), "downloaded binary should be a valid Linux/amd64 ELF")
}

func TestAgentWorkingDirExcludes_ContainsKnownPatterns(t *testing.T) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] correctness

Go tests verify the agentWorkingDirExcludes slice contents but do not test the excludeAgentWorkingDirs function itself. Shell command generation, error handling, and sandbox interaction are untested.

Suggested fix: Add a unit test that exercises excludeAgentWorkingDirs with a mock sandbox, verifying the generated command and error paths.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code agent should exclude its own working directories from commits

0 participants