Repository navigation
Description
Summary
Clicking the Push button in the agent UI runs git add -A && git commit -m "Trinity sync: <timestamp>" inside the agent container and pushes runtime state to GitHub — .cache/, .claude/sessions/, .claude/shell-snapshots/, .claude.json, .local/lib/python3.11/site-packages/, .sudo_as_admin_successful, etc. The platform's own docs/TRINITY_COMPATIBLE_AGENT_GUIDE.md:126-169 lists these exact paths under "Instance-specific files — DO NOT COMMIT". The Push button is not respecting the agent-value-vs-runtime split that Trinity's own docs require of agent repos.
In one observed instance, a single Push pushed 1,599 runtime files to GitHub, making the PR diff and main history unreadable.
Context
The full call chain:
- UI Push →
POST /api/agents/{name}/git/sync(src/backend/routers/git.py:100) - →
git_service.sync_to_github(agent_name, ...)(src/backend/services/git_service.py:466) - → calls
http://agent-{name}:8000/api/git/sync(git_service.py:509) - → agent-side handler
sync_to_githubatdocker/base-image/agent_server/routers/git.py:557 - → runs
git add -A(line 692) when nopathsare passed — i.e., the default UI Push path - → commits with
Trinity sync: <timestamp>(line 721) and pushes
git add -A stages everything not gitignored. The platform-injected .gitignore (written once during initialize_git_in_container at src/backend/services/git_service.py:719-728) only covers:
.bash_logout, .bashrc, .profile, .bash_history,
.cache/, .local/, .npm/, .ssh/
Compare to what docs/TRINITY_COMPATIBLE_AGENT_GUIDE.md:126-169 requires every Trinity-compatible agent to exclude:
# Credentials - NEVER COMMIT
.mcp.json
.env
*.pem
*.key
credentials.json
# Large generated content
content/
# Instance-specific directories
.npm/
.ssh/
.trinity/
.cache/
# Instance-specific files
.claude.json
.claude.json.backup
.sudo_as_admin_successful
# Claude Code - commit commands/skills/agents, exclude runtime data
.claude/projects/
.claude/statsig/
.claude/todos/
.claude/debug/Missing from the platform-injected .gitignore (vs. what the docs codify):
.claude.json,.claude.json.backup,.sudo_as_admin_successful.claude/projects/,.claude/statsig/,.claude/todos/,.claude/debug/,.claude/sessions/,.claude/shell-snapshots/.trinity/,content/.mcp.json,.env,*.pem,*.key,credentials.json(credential overlap with bug: initialize_github_sync commits .env and .mcp.json despite .gitignore #458)
So the platform writes a .gitignore that the platform itself would reject as incomplete, then runs git add -A against it on every Push.
Relationship to #458: same root cause (narrow platform-injected .gitignore), different surface. #458 is about the initial commit during initialize_github_sync. This issue is about every subsequent Push via sync_to_github. Fixing #458's .gitignore content would also fix the runtime-noise half of this bug. The git add -A policy is independently worth re-examining — even with a perfect .gitignore, blindly staging everything is a sharp tool to hand a UI button.
Reproduction
- Initialize an agent and call
initialize_github_sync(or use the UI Init flow) - Let the agent run for a while so Claude Code writes session data, shell snapshots, etc., to
~/.claude/ - Click the Push button in the Trinity UI
- Inspect the resulting
Trinity sync: <timestamp>commit on GitHub → it contains 1000+ runtime files including.cache/,.claude/sessions/,.claude.json,.sudo_as_admin_successful,.local/lib/python3.11/site-packages/, etc.
Acceptance Criteria
- The platform-injected
.gitignore(written byinitialize_git_in_container) covers at minimum the full deny-list documented indocs/TRINITY_COMPATIBLE_AGENT_GUIDE.md:126-169. Single source of truth — both should be derived from the same constant or doc fragment, not maintained in parallel - After the fix, a Push on a freshly-initialized agent produces zero files matching the documented exclusion list (verified by inspecting the commit tree)
- Decide and document the policy for
git add -Aindocker/base-image/agent_server/routers/git.py:692. Options: (a) keep-Abut trust the now-correct.gitignore; (b) switch to a curated allow-list (e.g., only stage tracked files + explicitly named agent-value paths). Pick one with rationale in the PR - Existing agents (already initialized with the narrow
.gitignore) get a migration path — either an idempotent "fix-up" on next Push that appends the missing entries, or a one-shot maintenance endpoint. Without this, the fix only helps newly-created agents - For tracked-but-now-ignored files (e.g.,
.cache/files that were previously committed and are still in the index), the migration also runsgit rm --cachedso the next Push removes them from the tree - Regression test: deploy an agent → run something that creates
.claude/sessions/<file>and.cache/<file>→ Push → assert those paths are NOT in the resulting commit
Technical Notes
Files:
docker/base-image/agent_server/routers/git.py:557— agent-sidesync_to_github(thegit add -Ais at:692)src/backend/services/git_service.py:466— platform-side callersrc/backend/services/git_service.py:717-733— the.gitignorewrite (the same lines bug: initialize_github_sync commits .env and .mcp.json despite .gitignore #458 calls out)src/backend/routers/git.py:100— HTTP entry point for the UI Push buttondocs/TRINITY_COMPATIBLE_AGENT_GUIDE.md:126-169— the canonical exclusion list
Suggested fix:
- Extract the exclusion list from
TRINITY_COMPATIBLE_AGENT_GUIDE.mdinto a Python constant (e.g.,DEFAULT_AGENT_GITIGNOREingit_service.py) and use it ininitialize_git_in_container. Update the doc to reference the constant or generate the doc snippet from it - Apply the same constant to the legacy
/home/developer/workspacebranch (currently no.gitignorewritten there at all — seegit_service.py:718) - On Push, before
git add -A, idempotently append any missing default entries to the workspace.gitignoreandgit rm --cachedany newly-ignored tracked files. This handles existing agents without requiring a manual migration - Open question for the PR: should
git add -Abecomegit addagainst an explicit allow-list of agent-value paths (skills, commands, agents, code, docs)? That's a more invasive change but eliminates the entire class of "we forgot to ignore X" bugs
Related: #458 (credential leak in initial commit, same root cause in the .gitignore write)
Severity rationale: P1, not P0. Unlike #458 this isn't an active credential exfiltration path (assuming #458 is fixed), but it fires on every Push, makes PR diffs unreadable, bloats main history, and visibly contradicts the platform's own documentation about what an agent repo should look like.
Activity
docs(test-runner): catalog Abilityai#462 gitignore tests
docs(feature-flows): sync github-sync + github-repo-initialization for …
vybe commentedon Apr 27, 2026
Closed by merged PR.
fix(git): UI Push no longer commits runtime state (#462)
Release: v0.5.0 (#608)
fix(git-sync): stop the base image's container-only .claude/settings.…
fix(git): resolve an agent's repo root from git, not a workspace/ con…
fix(git): let repo discovery cross a mount boundary, so a home-rooted…
fix(git): let repo discovery cross a mount boundary, so a home-rooted…
fix(git-sync): the canonical .gitignore stops reversing the agent's o…