# pyveil

> Local, dependency-free PII and secret redaction for Python LLM apps, AI agents, tool calls, MCP resources, memory, logs, and traces.

pyveil replaces high-confidence sensitive values with stable, scoped HMAC placeholders before data crosses an application boundary. The core makes no network calls and has no required runtime dependencies.

## Start

- Homepage: https://hyeonsangjeon.github.io/pyveil/
- Manual: https://hyeonsangjeon.github.io/pyveil/manual.html
- Python quickstart: https://hyeonsangjeon.github.io/pyveil/manual.html#quickstart
- OpenAI Agents and LiteLLM checkout setup: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/openai-agents-vs-litellm.md#run-both-without-keys
- Real file runs: https://hyeonsangjeon.github.io/pyveil/manual.html#file-runs
- Configuration and reproduction: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/file-runs.md
- PyPI: https://pypi.org/project/pyveil/
- Source: https://github.com/hyeonsangjeon/pyveil
- Evaluation: https://hyeonsangjeon.github.io/pyveil/evaluation.html
- Privacy Boundary Replay: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/privacy-replay.md

## Search-intent guides

- Python LLM PII redaction: https://hyeonsangjeon.github.io/pyveil/guides/python-llm-pii-redaction.html
- MCP PII redaction: https://hyeonsangjeon.github.io/pyveil/guides/mcp-pii-redaction.html
- pyveil vs Presidio, NER, guardrails, and DLP: https://hyeonsangjeon.github.io/pyveil/guides/pyveil-vs-presidio.html

## API

- `pyveil proxy -- <command>` / `pyveil proxy --transport http --listen 127.0.0.1:8787 --upstream URL`: one-command local stdio or Streamable HTTP/SSE MCP masking proxy (`--on-block error|redact`, `--rulepack kr`, `--audit-log`, `--redact-stderr`); default blocks credentials on `tool.call.arguments` with JSON-RPC `-32001`.
- `pyveil hook pre-tool-use|post-tool-use|print-config`: coding-agent hooks and setup templates for Claude Code, GitHub Copilot CLI, and Codex (`--client`, `--mode block|redact|audit`, `--rulepack kr`, `--audit-log`, `--target`).
- `pyveil init --input FILE`: create executable pyveil.json and a private per-directory key without overwriting files.
- `pyveil run pyveil.json`: execute real local file redaction, then publish processed data and a receipt in a new private directory.
- `pyveil test-config pyveil.json`: validate the complete JSON schema and version pin; legacy root YAML is rejected.
- `Veil.high(secret, scope, policy, rules, rulepacks)`: recommended redactor for model, agent, tool, MCP, memory, trace, and log boundaries.
- `Veil.low(...)`: shape-preserving human preview; not recommended across agent boundaries.
- `redact_text(text, channel, ...)`: free-form text redaction.
- `redact_data(data, channel, ...)`: recursive dict/list/tuple/JSON redaction that preserves structure.
- `korean_pii_rules(strict_checksum=True)` / `rulepacks=("kr",)` / `--rulepack kr`: opt-in clean-room Korean PII rulepack (`KR_RRN`, `KR_BRN`, `KR_BANK_ACCOUNT`, and context-anchored contiguous Korean mobile under `PHONE`).
- `AuditLogger(destination)` / `--audit-log PATH|stderr`: thread-safe metadata-only JSONL audit logger with zero raw sensitive values, payload bodies, secrets, raw file paths, or placeholder tokens.
- `CustomRule.exact(entity, values)`: known values such as authenticated customer names.
- `CustomRule(entity, pattern)`: narrow trusted application regexes.
- `Policy.override(channel, entity, action)`: per-boundary REDACT, BLOCK, or PASS decisions.
- `pyveil replay --format json`: keyless six-boundary regression evidence with no raw payload output.

## Supported built-in and optional findings

Built-in: EMAIL, PHONE, CREDIT_CARD, JWT, AUTH_HEADER, PRIVATE_KEY, API_KEY, URL_QUERY_SECRET, KV_SECRET.
Optional Korean PII rulepack (`--rulepack kr`): KR_RRN, KR_BRN, KR_BANK_ACCOUNT, plus context-anchored contiguous Korean mobile numbers under PHONE.

## Safety boundaries

- Installation does not intercept SDK calls. Pass the redacted result explicitly at each boundary, or place `pyveil proxy` / `pyveil hook` in front of MCP servers and coding-agent tool calls.
- `examples/*.py` requires a checkout; only `pyveil.integrations.*` ships in the wheel.
- Findings and `--audit-log` records do not retain raw sensitive values, payload bodies, secrets, or raw file paths.
- Credential-like values are blocked by default in `tool.call.arguments`.
- Coding-agent hook sensitive-path checks (`.env`, `*.pem`, `*.key`, SSH keys, `.aws/credentials`, `.netrc`) are filename heuristics complementing content redaction, not an OS sandbox or filesystem ACL.
- pyveil has no reversible vault or unmasking API.
- File-run receipts separate actual execution from input origin and explicitly set provider_called=false.
- Reproduction requires the same input, ledger, private key, and pinned package. Run IDs and timings differ.
- pyveil is not enterprise DLP, a compliance guarantee, a secret scanner, an NER system, or a prompt-injection firewall.
- For unknown names, organizations, locations, and addresses, use Presidio or another NER layer upstream.

## Repository documents

- Cookbook: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/cookbook.md
- MCP proxy and integration: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/mcp.md
- Coding-agent hooks integration: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/agent-hooks.md
- Hook templates (Claude Code, Copilot CLI, Codex): https://github.com/hyeonsangjeon/pyveil/tree/main/hooks
- Portable coding-agent skill: https://github.com/hyeonsangjeon/pyveil/blob/main/skills/pyveil/SKILL.md
- Optional Korean PII corpus: https://github.com/hyeonsangjeon/pyveil/blob/main/evaluation/corpus_kr.json
- Isolated comparison benchmark: https://github.com/hyeonsangjeon/pyveil/blob/main/evaluation/benchmark_compare.py
- Measured comparison results: https://github.com/hyeonsangjeon/pyveil/blob/main/evaluation/benchmark-results.json
- Demo GIF renderer: https://github.com/hyeonsangjeon/pyveil/blob/main/scripts/render_demo_gif.py
- Privacy Boundary Replay: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/privacy-replay.md
- OpenAI Agents SDK vs LiteLLM comparison: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/openai-agents-vs-litellm.md
- OpenAI Agents SDK boundary: https://github.com/hyeonsangjeon/pyveil/blob/main/examples/openai_agents_guardrail.py
- LiteLLM SDK and Proxy boundary: https://github.com/hyeonsangjeon/pyveil/blob/main/examples/litellm_proxy_filter.py
- OpenAI integration: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/openai.md
- Anthropic integration: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/anthropic.md
- Ollama integration: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/ollama.md
- Redaction reference: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/redaction-reference.md
- Threat model: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/threat-model.md
- Known limitations: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/known-limitations.md
- Detector provenance: https://github.com/hyeonsangjeon/pyveil/blob/main/docs/detector-provenance.md
- Agent instructions: https://github.com/hyeonsangjeon/pyveil/blob/main/AGENTS.md

## Provider verification

- OpenAI and Anthropic have keyless CLI dry-runs.
- Offline contract tests pass redacted prompts through the official SDKs into local mock HTTP transports.
- No live provider request, API key, or usage credit is required for those checks.
