# Investigating Code Upload behavior in Grok CLI
*xai-org/grok-build · informative · 4 markers*

> The current codebase has no code that uploads entire repos. What it does have is a per-turn pipeline that sends code diffs and trace data, gated by a remote flag (`trace_upload_enabled`). When the flag is off, no code or trace data leaves your machine.
>
> **What the flags control.** `trace_upload_enabled` is the master switch for code and trace uploads. ZDR (Zero Data Retention) team status blocks them at the auth layer before credentials are resolved. `/privacy opt-out` is the consumer equivalent — it persists locally and tells the server. A size limit (`max_upload_file_bytes`) caps individual file content in the upload.
>
> **What actually gets sent.** Repo context is git patches — diffs of committed changes plus staged/unstaged work — not full file snapshots. Untracked files get full content up to 1 MB. Build artifacts, node_modules, and cache directories are excluded. The entire codebase was published in a single commit, so there is no history to verify whether earlier versions behaved differently.

**Author:** SquallLeonhart13 · **Updated:** 2026-07-15T22:45:17.281Z

## Markers
1. **No code exists that uploads entire repos** — `crates/codegen/xai-grok-workspace-types/src/rpc/git.rs:673–700`
   `GitCollectChangesResponse` serializes repo context as patches, not full snapshots. `commits` holds `CommitWithPatchData` with `patch_base64` — the git diff. `uncommitted` holds staged/unstaged patches. `untracked` holds file content up to 1 MB. There is no code path that walks the full tree and serializes every file. The `workspace_type` field classifies the CWD for analytics only — it does not trigger broader file collection.
2. **The remote flag that controls code and trace uploads** — `crates/codegen/xai-grok-shell/src/agent/config.rs:2076–2091`
   `trace_upload_enabled` in remote settings is the master switch. It sits at the end of a five-layer resolution chain: requirement pin → env var → config file → remote setting → default. When the remote setting is off, the upload path is never entered. When it flips on, code and trace uploads resume with no client update required.
3. **Zero Data Retention and /privacy are the two opt-out paths** — `crates/codegen/xai-grok-shell/src/auth/model.rs:154–167`
   Enterprise Zero Data Retention (ZDR) blocks code and trace uploads at the auth layer — no credentials are resolved, no session data leaves the machine. Consumers reach the same gate through `/privacy opt-out`, which persists locally and tells the server. Both set `is_data_collection_disabled()` to true, which short-circuits every upload path. The `non_git_workspace_capture` flag controls whether non-git project directories get file capture, separate from the upload toggle.
4. **Size limits cap what individual files can be sent** — `crates/codegen/xai-grok-config-types/src/lib.rs:224–226`
   Remote settings include `max_upload_file_bytes` and `max_upload_untracked_bytes` — server-configurable caps on individual file content in the upload. Untracked files over 1 MB have no inline content and must be fetched separately. These are size gates on the upload pipeline, not triggers for broader collection.

---
Interactive view: https://app.principal-ade.com/trail/1156a811-7eaf-4445-8656-73d5d2927f38
JSON: https://app.principal-ade.com/api/trails/by-id/1156a811-7eaf-4445-8656-73d5d2927f38
Authored at `c1b5909ec707c069f1d21a93917af044e71da0d7`.
To open a trail or tour locally in the interactive viewer, see https://app.principal-ade.com for the Principal CLI quickstart.
