# CLI privacy

The CLI runs a local privacy pass before any trace payload is posted to SellTraces. This is the first privacy boundary for contributor-owned traces.

During setup, source selection is local inspection only. The CLI reads selected
source stores on the device to count traces and build a project/repository
review list. Trace content is not posted until the user approves projects,
reviews the upload preview, and confirms the upload checkpoint.

Projects without a Git remote are approved by their exact recorded working
directory, even when folder names match. Existing non-Git project approvals require a
one-time review in `selltraces policy`; Git remote approvals are unchanged.

## Local upload gates

Before upload, every CLI path applies:

1. Approved-source filtering.
2. Project/repository approval filtering.
3. Blocked-term filtering.
4. Local PII preflight.
5. Already-synced filtering.
6. Duplicate-source and duplicate-content filtering.
7. Upload chunking.

## Local preview output

`upload --dry-run --json` omits transcript titles, source IDs and redaction
snippets by default. Use `--show-redactions` only when you explicitly want
content samples included in terminal or JSON output. Policy and scan metadata
remain available to explain exclusions and unreadable sources.

## Local redaction

Current CLI local preflight redacts detected PII and secrets before a trace leaves the machine. A trace is not skipped solely because one of these detector classes fired:

- detected secrets
- SSNs and government identifiers
- payment cards
- email addresses
- phone numbers
- public IP addresses
- physical-address patterns
- local home-directory usernames
- covered trace-level string fields and metadata

The accepted trace carries local preflight metadata in `piiScrub.version` and `piiScrub.findingsCount` when redactions are applied.

Traces can still be skipped locally for approved-source policy, blocked terms,
already-synced content, duplicate content, duplicate source identity, or missing
required source identity. Trace length is not a local upload skip reason.

## Local retry cache

When opening its local store on platforms with POSIX permissions, the CLI
sets its state directory to `0700` and its SQLite database, WAL and SHM files
to `0600`. Existing store permissions are tightened on open.

The CLI stores hashes, source identities, status, job IDs and preliminary value in
`~/.selltraces/traces.db`. Review plans retain metadata. After consent, the CLI
rereads the approved sources and sends one bounded request at a time. It verifies
the exact scrubbed payload against the reviewed snapshot and does not retain
upload payloads in the database. Keep original source histories available until
accepted uploads finish; interrupted uploads are rebuilt from those sources.

To release disposable payload copies from previous runs, use
`selltraces cache clear`. This preserves pending ledger rows, accepted-job
receipts and source files, and compacts the local database. Deleting the entire
`traces.db` also deletes deduplication and receipt history; use the cache command
for cleanup.

## Blocked terms

Blocked terms are case-insensitive and match trace text plus metadata such as:

- title
- source id
- current working directory
- repository URL
- source path
- structured message blocks

If a blocked term only appears in metadata, the trace is still skipped locally.

## Server backstop

Server-side ingest still validates, queues, scrubs, deduplicates, scores, and prices traces. The local preflight is the first privacy boundary, not the only one. The server scrub may still reject traces during ingest if it detects content that the server policy treats as unsafe.

<Note>
Raw uploads and per-trace raw blobs are currently part of server-side retention. Download endpoints stream the derived scrubbed blob, not the raw blob.
</Note>
