Metadata-Version: 2.2
Name: pyveil
Version: 0.4.0
Summary: Local PII and secret redaction for Python LLM apps, AI agents, tool calls, and MCP
Author-email: Hyeon Sang Jeon <wingnut0310@gmail.com>
Maintainer-email: Hyeon Sang Jeon <wingnut0310@gmail.com>
License: MIT
Project-URL: Homepage, https://hyeonsangjeon.github.io/pyveil/
Project-URL: Documentation, https://hyeonsangjeon.github.io/pyveil/manual.html
Project-URL: Repository, https://github.com/hyeonsangjeon/pyveil
Project-URL: Issues, https://github.com/hyeonsangjeon/pyveil/issues
Project-URL: Changelog, https://github.com/hyeonsangjeon/pyveil/releases
Project-URL: Security, https://github.com/hyeonsangjeon/pyveil/security/policy
Project-URL: Guides, https://hyeonsangjeon.github.io/pyveil/guides/
Project-URL: Evaluation, https://hyeonsangjeon.github.io/pyveil/evaluation.html
Project-URL: Funding, https://github.com/sponsors/hyeonsangjeon
Project-URL: Support, https://github.com/hyeonsangjeon/pyveil/discussions
Keywords: agent-native,agent-security,agents,ai-agents,ai-security,anthropic,data-protection,data-masking,de-identification,guardrails,llm,llm-privacy,llm-security,logs,masking,mcp,mcp-security,memory,observability,pii,pii-redaction,privacy,prompts,prompt-redaction,redaction,runtime-redaction,openai,anonymization,security,sensitive-data,tool-calls,traces
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Security
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: azure-openai
Requires-Dist: openai<3.0.0,>=1.66.0; extra == "azure-openai"
Requires-Dist: python-dotenv>=1.0.0; extra == "azure-openai"
Requires-Dist: PyYAML>=6.0.0; extra == "azure-openai"
Provides-Extra: openai
Requires-Dist: openai<3.0.0,>=2.45.0; python_version >= "3.9" and extra == "openai"
Requires-Dist: python-dotenv>=1.0.0; extra == "openai"
Requires-Dist: PyYAML>=6.0.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic<1.0.0,>=0.116.0; python_version >= "3.9" and extra == "anthropic"
Requires-Dist: python-dotenv>=1.0.0; extra == "anthropic"
Requires-Dist: PyYAML>=6.0.0; extra == "anthropic"
Provides-Extra: ollama
Requires-Dist: ollama<1.0.0,>=0.6.2; extra == "ollama"
Requires-Dist: python-dotenv>=1.0.0; extra == "ollama"
Requires-Dist: PyYAML>=6.0.0; extra == "ollama"
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: ollama<1.0.0,>=0.6.2; extra == "dev"
Requires-Dist: openai<3.0.0,>=2.45.0; python_version >= "3.9" and extra == "dev"
Requires-Dist: anthropic<1.0.0,>=0.116.0; python_version >= "3.9" and extra == "dev"
Requires-Dist: python-dotenv>=1.0.0; extra == "dev"
Requires-Dist: PyYAML>=6.0.0; extra == "dev"
Requires-Dist: types-PyYAML>=6.0.0; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"
Requires-Dist: pytest-cov>=4.0.0; extra == "test"
Requires-Dist: python-dotenv>=1.0.0; extra == "test"
Requires-Dist: PyYAML>=6.0.0; extra == "test"

# pyveil

**Zero-dependency local PII and secret redaction for MCP servers, coding agents, and Python LLM apps.**

[![PyPI](https://img.shields.io/pypi/v/pyveil?style=flat-square)](https://pypi.org/project/pyveil/)
[![Tests](https://github.com/hyeonsangjeon/pyveil/actions/workflows/tests.yml/badge.svg)](https://github.com/hyeonsangjeon/pyveil/actions/workflows/tests.yml)
[![Python 3.8 to 3.14](https://img.shields.io/badge/python-3.8%20to%203.14-3776AB?style=flat-square)](https://github.com/hyeonsangjeon/pyveil/actions/workflows/tests.yml)
[![Zero core dependencies](https://img.shields.io/badge/core%20dependencies-zero-111827?style=flat-square)](https://github.com/hyeonsangjeon/pyveil/blob/main/pyproject.toml)
[![MIT](https://img.shields.io/badge/license-MIT-green?style=flat-square)](https://github.com/hyeonsangjeon/pyveil/blob/main/LICENSE)

[MCP Proxy](#one-command-mcp-proxy) · [Agent Hooks & Skill](#agent-hooks-and-skill) · [Benchmarks](#measured-benchmarks) · [Korean PII](#optional-korean-pii-rulepack) · [Quickstart](#quickstart) · [Manual](https://hyeonsangjeon.github.io/pyveil/manual.html) · [Security](https://github.com/hyeonsangjeon/pyveil/blob/main/SECURITY.md)

Keep emails, phone numbers, Korean PII (`--rulepack kr`), and supported
credentials out of model prompts, tool arguments, tool results, MCP resources,
memory, logs, and traces. **Zero core runtime dependencies, 100% air-gap local,
Python 3.8–3.14** — no model download, API key, or Hub token required.

- **Drop-in interception for MCP servers and coding agents:** Wrap any stdio or
  Streamable HTTP/SSE MCP server with `pyveil proxy`, or attach `pyveil hook`
  (`PreToolUse` / `PostToolUse`) and the portable `SKILL.md` to Claude Code,
  Codex, and GitHub Copilot CLI.
- **Explicit in-process Python SDK:** In Python apps, call `Veil` directly
  before each boundary you want to protect; installing `pyveil` does not
  monkey-patch or silently intercept Python SDK calls.

![pyveil blocking .env reads and masking MCP tool PII locally](https://raw.githubusercontent.com/hyeonsangjeon/pyveil/main/docs/media/pyveil-v04-demo.gif)

*Synthetic local CLI demo (`PreToolUse` `.env` deny, fail-closed MCP `-32001` block, `--rulepack kr` masking, and raw-free JSONL audit; no live LLM API call) — reproduced by [scripts/render_demo_gif.py](https://github.com/hyeonsangjeon/pyveil/blob/main/scripts/render_demo_gif.py).*

## One-Command MCP Proxy

Put `pyveil proxy` between an MCP client and any stdio or Streamable HTTP/SSE
MCP server. It checks `tools/call` arguments on `tool.call.arguments` and
redacts tool outputs (`tool.call.result`), MCP resources
(`mcp.resource.content`), and prompts locally before they enter model context.

**Stdio drop-in wrapper** (auto-detects `Content-Length` and NDJSON framing):

```bash
export PYVEIL_SECRET="$(python3 -c 'import secrets; print(secrets.token_hex(32))')"
python3 -m pyveil proxy -- npx -y @modelcontextprotocol/server-filesystem .
```

**Streamable HTTP / SSE local reverse proxy** (with Korean PII and raw-free audit logging):

```bash
python3 -m pyveil proxy \
  --transport http \
  --listen 127.0.0.1:8787 \
  --upstream http://127.0.0.1:9000/mcp \
  --rulepack kr \
  --audit-log pyveil-audit.jsonl
```

- **Fail-closed credential blocking (`-32001`):** Under the default
  `--on-block error`, `tools/call` arguments containing credentials (`API_KEY`,
  `AUTH_HEADER`, `JWT`, `PRIVATE_KEY`, `KV_SECRET`, `URL_QUERY_SECRET`) are
  rejected before upstream dispatch with a raw-free JSON-RPC `-32001` error.
  Pass `--on-block redact` to replace blocked credentials with placeholders
  instead.
- **Explicit secret required:** `PYVEIL_SECRET` (or `--secret` / `--secret-env`)
  is required; `pyveil proxy` fails closed rather than using a hardcoded key.
- **Streaming and stderr:** HTTP mode incrementally redacts `text/event-stream`
  SSE `data:` JSON frames; stdio mode supports `--redact-stderr` under
  `log.record`.

See [MCP Proxy & Python helper guide](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/mcp.md)
for Claude Desktop, Claude Code, and Codex configuration snippets.

## Agent Hooks and Skill

Guard `PreToolUse` and `PostToolUse` tool boundaries in **Claude Code**,
**Codex**, and **GitHub Copilot CLI** locally with zero external dependencies:

```bash
export PYVEIL_SECRET="$(python3 -c 'import secrets; print(secrets.token_hex(32))')"

python3 -m pyveil hook print-config --target claude-code
python3 -m pyveil hook print-config --target copilot-cli
python3 -m pyveil hook print-config --target codex
```

Add `--rulepack kr --audit-log pyveil-audit.jsonl` to bake Korean PII detection
and metadata-only audit logging into the printed config.

- **`pre-tool-use`** (default `--mode block`) denies tool calls containing
  default-blocked credentials or heuristic sensitive file-path references
  (`.env`, `.env.*` excluding safe templates, `*.pem`, `*.key`, `id_rsa`,
  `id_ed25519`, `.aws/credentials`, `.netrc`), or rewrites arguments under
  `--mode redact`.
- **`post-tool-use`** is always non-blocking: it redacts `tool.call.result`
  outputs and emits a raw-free `additionalContext` notice.
- **Ready-to-use templates & portable skill:**
  - Claude Code: [hooks/claude-code/settings.json](https://github.com/hyeonsangjeon/pyveil/blob/main/hooks/claude-code/settings.json)
  - Codex: [hooks/codex/config.toml](https://github.com/hyeonsangjeon/pyveil/blob/main/hooks/codex/config.toml)
  - GitHub Copilot CLI: [hooks/copilot-cli/hooks.json](https://github.com/hyeonsangjeon/pyveil/blob/main/hooks/copilot-cli/hooks.json)
  - Portable Agent Skill: [skills/pyveil/SKILL.md](https://github.com/hyeonsangjeon/pyveil/blob/main/skills/pyveil/SKILL.md)
  - Full Hook Guide: [docs/integrations/agent-hooks.md](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/agent-hooks.md)

The `.env` / key-file check is a string-level filename heuristic complementing
content redaction — it is **not** an OS sandbox or filesystem access control
layer.

## Measured Benchmarks

Measured locally in isolated `uv` virtual environments on **Apple M6** (`12`
logical cores, `arm64`, Darwin `27.0.0`), **Python `3.12.15`**, at
`2026-11-30T05:52:35Z` (`50` warm passes / `1,950` documents evaluated on
[evaluation/corpus.json](https://github.com/hyeonsangjeon/pyveil/blob/main/evaluation/corpus.json):
`39` cases — `33` positive, `6` negative, `36` expected findings; shared PII
subset: `20` cases — `14` positive, `6` negative, `15` expected findings for
`EMAIL`, `PHONE`, `CREDIT_CARD`). Raw data:
[evaluation/benchmark-results.json](https://github.com/hyeonsangjeon/pyveil/blob/main/evaluation/benchmark-results.json).

| Metric | `pyveil 0.4.0` | `presidio-analyzer 2.2.366` (`spacy 3.8.18`, `en_core_web_sm 3.8.0`) | `guardrails-ai 0.11.0` |
| --- | --- | --- | --- |
| Runtime dependencies (installed packages) | `0` (`1` package) | `51` (`52` packages) | `112` (`113` packages, base only) |
| Installed footprint (excl. `__pycache__`) | `262.19 KB` (`0.256 MB`) | `113,618.88 KB` (`110.956 MB`) | `313,782.63 KB` (`306.428 MB`, base only) |
| Cold start: import / import + init (median) | `13.018 ms` / `13.028 ms` (`5` runs) | `428.528 ms` / `591.644 ms` (`3` runs) | `923.011 ms` (`3` runs) / unavailable offline |
| Warm latency per doc: median / p95 | `0.0125 ms` / `0.0202 ms` (`26.635 ms` total) | `1.3898 ms` / `2.2113 ms` (`2,844.148 ms` total, scoped shared PII); `1.5472 ms` / `2.4166 ms` (`3,161.139 ms` total, default all entities) | Not measured offline |
| Warm throughput (`1,950` docs) | `73,212.6 docs/sec` | `685.6 docs/sec` (scoped); `616.9 docs/sec` (default) | Not measured offline |
| Shared PII subset (`20` cases, `15` expected) P / R | `1.000` / `1.000` (F1 `1.000`) | `0.9231` / `0.8000` (F1 `0.8571`) | Not measured offline |
| Full corpus (`39` cases, `36` expected) P / R | `1.000` / `1.000` (F1 `1.000`) | `0.8750` / `0.3889` (F1 `0.5385`) | Not measured offline |
| Air-gap / offline PII status | Runnable offline; no model download or Hub token | Runnable offline once spaCy model wheel is pre-installed (`en_core_web_sm` ~12.2 MiB here vs default `en_core_web_lg` ~382 MiB) | `airgap_pii_unavailable`: `0` bundled PII validators; `DetectPII`/`GuardrailsPII` require Guardrails Hub + API token or separate packages + model downloads |

Reproduce locally:

```bash
python3 evaluation/benchmark_compare.py --python 3.12 --passes 50 --output evaluation/benchmark-results.json
```

**Scope and fair NER credit:** `evaluation/corpus.json` is a synthetic
supported-shape regression corpus, not a representative real-world NLP
benchmark, and latency numbers are machine-dependent local diagnostics, not
SLAs. Presidio provides spaCy/transformer NER discovery of unknown person
names, locations, organizations, and dates that pyveil deliberately does not
attempt and that are absent from `evaluation/corpus.json`. Conversely, Presidio
does not ship built-in secret recognizers (API keys, JWTs, PEM private keys,
auth headers, URL/KV secrets), which accounts for its `0.3889` full-corpus
recall. See the
[measured comparison guide](https://hyeonsangjeon.github.io/pyveil/guides/pyveil-vs-presidio.html#measured-comparison)
and [benchmark harness](https://github.com/hyeonsangjeon/pyveil/blob/main/evaluation/benchmark_compare.py).

## Structured Raw-Free Audit Log

Pass `--audit-log <file|stderr>` to `pyveil proxy`, `pyveil hook`,
`pyveil redact`, or `pyveil scan` (or use `pyveil.AuditLogger` in Python) to
record one metadata-only JSONL event per boundary check. Audit logs omit raw
sensitive values, payload bodies, secrets, raw file paths, and placeholder
tokens:

```json
{"schema_version":1,"timestamp":"2026-11-30T05:52:35.000Z","event":"hook.pre_tool_use","direction":"local","channel":"tool.call.arguments","action":"blocked","finding_count":1,"entity_counts":{"SENSITIVE_PATH":1},"rule_ids":["dotenv_file"],"latency_ms":0.214,"scope":"agent-hook","tool_name":"Read","reason":"pyveil blocked tool call: sensitive file path reference (dotenv_file)"}
{"schema_version":1,"timestamp":"2026-11-30T05:52:35.120Z","event":"proxy.response","direction":"upstream_to_client","channel":"tool.call.result","action":"redacted","finding_count":2,"entity_counts":{"EMAIL":1,"KR_RRN":1},"rule_ids":["email_address","kr_rrn_hyphenated"],"latency_ms":0.041,"scope":"mcp-proxy","method":"tools/call","request_id":7}
```

## Optional Korean PII Rulepack

Enable opt-in clean-room Korean PII detection via `--rulepack kr` on any CLI
command (`proxy`, `hook`, `redact`, `scan`) or `rulepacks=("kr",)` in Python:

- **`KR_RRN`:** Citizen (`1–4`) and foreigner (`5–8`) resident registration
  numbers with century-aware calendar date and mod-11 checksum validation
  (`korean_pii_rules(strict_checksum=False)` available for post-October 2020
  randomized RRNs; `LOW` masks all 13 digits `******-*******` with zero
  DOB/gender leakage).
- **`KR_BRN`:** Business registration numbers (`사업자등록번호`) validated with
  the National Tax Service (NTS) checksum.
- **`KR_BANK_ACCOUNT`:** Context-anchored 10–14 digit Korean bank accounts near
  Korean bank names or account keywords.
- **Korean phone variants:** Built-in hyphenated Korean numbers plus
  context-anchored contiguous `01[016789]` mobile numbers under `PHONE`.

```bash
export PYVEIL_SECRET="$(python3 -c 'import secrets; print(secrets.token_hex(32))')"
printf '주민번호 850315-1000025 / 사업자 123-45-67891 / 신한은행 110-123-456789\n' \
  | python3 -m pyveil redact - --rulepack kr
```

```python
import secrets
from pyveil import Veil, korean_pii_rules

veil = Veil.high(secret=secrets.token_bytes(32), scope="kr/session", rulepacks=("kr",))

# Optional relaxed checksum mode for post-October 2020 randomized RRNs
veil_relaxed = Veil.high(
    secret=secrets.token_bytes(32),
    scope="kr/session",
    rules=korean_pii_rules(strict_checksum=False),
)
```

Verified on the 45-case clean-room synthetic corpus
([evaluation/corpus_kr.json](https://github.com/hyeonsangjeon/pyveil/blob/main/evaluation/corpus_kr.json):
`31` positive, `14` negative, `41` expected findings, `1.000` precision /
`1.000` recall). See
[Korean corpus evaluation](https://hyeonsangjeon.github.io/pyveil/evaluation.html#korean-corpus)
and [detector provenance](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/detector-provenance.md).

## Quickstart

Requires Python 3.8+. In your Python environment:

```bash
python -m pip install pyveil
```

Run this complete example. It makes no provider request:

<!-- quickstart:python -->
```python
import secrets

from pyveil import Channel, Veil

veil = Veil.high(secret=secrets.token_bytes(32), scope="support/session-42")
messages = [
    {"role": "user", "content": "Email alice@example.com about ticket 42."},
]
safe = veil.redact_data(messages, channel=Channel.PROMPT_INPUT)
print(safe.data[0]["content"])
```
<!-- /quickstart:python -->

Output shape (the 12-hex suffix depends on your key and scope):

```text
Email [EMAIL:...] about ticket 42.
```

Pass **`safe.data`**, not `messages`, to your SDK. The original input is unchanged;
message roles and ticket `42` are preserved. For plain strings use
`veil.redact_text(text).text`.

This example creates a random key once per run. Reuse the same `Veil` within a
session; load a private, stable secret from your environment or secret manager
when placeholders must survive restarts. Never reuse a documentation secret
with real data. [Key and scope guidance](https://hyeonsangjeon.github.io/pyveil/manual.html#placeholders)

## Start With Your Integration

| Your stack | Start here | What runs locally |
| --- | --- | --- |
| MCP servers (stdio / HTTP / SSE) | [One-command MCP proxy](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/mcp.md) | `python3 -m pyveil proxy -- <mcp-server-cmd>` or `--transport http` |
| Claude Code / Codex / Copilot CLI | [Coding-agent hooks & skill](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/agent-hooks.md) | `python3 -m pyveil hook print-config --target claude-code\|copilot-cli\|codex` |
| OpenAI Agents SDK | [Runner wrapper and setup](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/openai-agents-vs-litellm.md#openai-agents-sdk) | Redacts initial input **before** `Runner.run`; keyless checkout example |
| LiteLLM SDK / Proxy | [SDK wrapper and Proxy hook](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/openai-agents-vs-litellm.md#litellm-proxy) | Redacts completion `messages` before dispatch; keyless checkout example |
| OpenAI Responses API | [Installable helper](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/openai.md) | `python -m pyveil.integrations.openai --dry-run` |
| Anthropic / Claude | [Installable helper](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/anthropic.md) | `python -m pyveil.integrations.anthropic --dry-run` |
| Azure OpenAI | [Env / YAML setup](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/cookbook.md#5-azure-openai-with-environment-or-yaml-configuration) | `python -m pyveil.integrations.azure_openai --dry-run` |
| Ollama | [Local model guide](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/ollama.md) | `python -m pyveil.integrations.ollama --dry-run` |
| Logs, memory, FastAPI, custom MCP | [Cookbook](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/cookbook.md) | Explicit wrappers at your application's boundaries |

Provider dry-runs require `PYVEIL_SECRET`; the linked guides cover configuration
and optional SDK dependencies for live calls. Dry-runs are **not model responses**.
OpenAI Agents input guardrails validate or block; they do not replace the input,
so the example redacts before dispatch. The LiteLLM Proxy hook covers
list-valued `messages`, not every endpoint or payload field.

**Examples vs installed modules:** `pyveil.integrations.*` ships in the wheel.
`examples/*.py` does not. To run the OpenAI Agents and LiteLLM recipes without
either SDK or a provider key, start from a checkout:

```bash
git clone https://github.com/hyeonsangjeon/pyveil.git
cd pyveil
python -m pip install .
python examples/openai_agents_guardrail.py
python examples/litellm_proxy_filter.py
```

Use a virtual environment for installation. See the
[comparison guide](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/openai-agents-vs-litellm.md#run-both-without-keys)
for macOS/Linux and Windows setup, expected output, and bypass risks.

## What Gets Redacted?

HIGH replaces supported findings with `[TYPE:12hex]` HMAC placeholders. The same
value, type, key, and scope produce the same placeholder, so repeated references
remain linkable within your chosen scope.

| Type | Supported shapes |
| --- | --- |
| `EMAIL` | Email addresses |
| `PHONE` | Korean, separated international, and compact E.164 shapes |
| `CREDIT_CARD` | Candidate card numbers that pass Luhn validation |
| `JWT` | Compact JSON Web Tokens |
| `AUTH_HEADER` | Bearer, Basic, Token, and ApiKey authorization headers |
| `PRIVATE_KEY` | PEM private-key blocks |
| `API_KEY` | Supported OpenAI, GitHub, Slack, Google, and AWS-style patterns |
| `URL_QUERY_SECRET` | Supported secret-bearing URL query parameters |
| `KV_SECRET` | Sensitive key-value pairs, including passwords and tokens |
| `KR_RRN`, `KR_BRN`, `KR_BANK_ACCOUNT` (`--rulepack kr`) | Opt-in Korean resident/foreigner RRNs, NTS-checksummed BRNs, context-anchored bank accounts, and contiguous Korean mobile numbers (`PHONE`) |
| Custom rules | Exact known values and trusted application regexes |

Unknown names, addresses, images, and documents are **not** automatically
detected. Use `CustomRule.exact(...)` for known values, or add a separate semantic
detection layer. The [detection board](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/redaction-reference.md)
shows inputs, HIGH/LOW outputs, validation rules, and limits.

Use **HIGH** for model-facing data. **LOW** is a human-facing preview, such as
`al***@e******.com`; it deliberately retains identifying shape. Credentials stay
aggressively hidden in both levels, and `LOW` `KR_RRN` masks all 13 digits
(`******-*******`) with zero DOB/gender leakage. pyveil is not a compliance
guarantee, prompt-injection firewall, DLP suite, or reversible vault.

## Protect More Than Prompts

| Task | Channel | Example |
| --- | --- | --- |
| Prepare model input / output | `prompt.input`, `prompt.output` | [Provider-neutral boundary](https://github.com/hyeonsangjeon/pyveil/blob/main/examples/llm_client_boundary.py) |
| Block credentials in tool arguments | `tool.call.arguments` | [Blocking recipe](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/cookbook.md#6-block-credentials-before-model-controlled-tool-calls) |
| Redact tool results / MCP resources | `tool.call.result`, `mcp.resource.content` | [MCP wrapper](https://github.com/hyeonsangjeon/pyveil/blob/main/examples/mcp_server_wrapper.py) |
| Redact before embedding or persistence | `memory.write` | [Memory example](https://github.com/hyeonsangjeon/pyveil/blob/main/examples/memory_write.py) |
| Redact before telemetry export | `log.record`, `trace.span.attributes` | [Logging](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/logging.md) / [tracing](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/tracing.md) |

The default policy raises `BlockedSensitiveData` for credential-like findings in
`tool.call.arguments`. On failure, **do not dispatch the original payload**.
Findings omit raw sensitive values by default; your application's original
objects still exist in memory. [Policy and failure handling](https://hyeonsangjeon.github.io/pyveil/manual.html#policy)

## Process A File

From an empty working directory after installation:

```bash
python -m pyveil init --example
python -m pyveil run
```

This creates synthetic input, `pyveil.json`, and a random private `.pyveil.key`,
then writes real redacted output and a receipt under `.pyveil-runs/<run-id>/`.
No model is called. Run twice with unchanged input, config, key, and version for
identical output bytes in separate directories.

For your own file, use the following instead of `init --example`:

```bash
python -m pyveil init --input /path/to/request.json --input-format json
```

Keep keys and outputs out of Git; redacted output is not automatically safe to
publish. [Configuration, Windows commands, error codes, and migration](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/file-runs.md)

## Verify Before You Integrate

One installed command exercises six synthetic agent boundaries without keys:

```bash
python -m pyveil replay --format markdown
```

The current regression expectation is **6/6 passing cases, 10 findings, and
0 surviving labeled synthetic markers**. It checks benign fields, structure,
and a second redaction pass. It is not a real-world PII recall benchmark.
[Replay methodology and limits](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/privacy-replay.md)

CI tests Python 3.8 through 3.14, installs built wheels in clean environments,
executes the quickstart above, and verifies file runs. Separate offline tests
inspect official OpenAI and Anthropic SDK request bodies through local mock
transports; they do not claim live paid API validation.

[Test runs](https://github.com/hyeonsangjeon/pyveil/actions/workflows/tests.yml) ·
[39-case core corpus](https://hyeonsangjeon.github.io/pyveil/evaluation.html) ·
[45-case Korean corpus](https://hyeonsangjeon.github.io/pyveil/evaluation.html#korean-corpus) ·
[Protection-surface contract](https://github.com/hyeonsangjeon/pyveil/blob/main/compatibility/README.md)

## Documentation And Support

- [Manual](https://hyeonsangjeon.github.io/pyveil/manual.html), [cookbook](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/cookbook.md), and [troubleshooting](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/faq.md)
- [MCP proxy guide](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/mcp.md), [coding-agent hooks guide](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/integrations/agent-hooks.md), and [portable agent skill](https://github.com/hyeonsangjeon/pyveil/blob/main/skills/pyveil/SKILL.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), and [security policy](https://github.com/hyeonsangjeon/pyveil/blob/main/SECURITY.md)
- [pyveil vs Presidio / Guardrails AI / DLP](https://hyeonsangjeon.github.io/pyveil/guides/pyveil-vs-presidio.html#measured-comparison)
- [Ask an integration question](https://github.com/hyeonsangjeon/pyveil/discussions) or [report a bug](https://github.com/hyeonsangjeon/pyveil/issues/new/choose). Share synthetic inputs, not real PII or credentials.
- [AGENTS.md](https://github.com/hyeonsangjeon/pyveil/blob/main/AGENTS.md) and [llms.txt](https://hyeonsangjeon.github.io/pyveil/llms.txt) for coding agents

## Development

```bash
uv run --extra dev ruff check .
uv run --extra dev mypy pyveil tests
uv run --extra test pytest
uv run --extra test python evaluation/evaluate.py --check
uv run --extra test python evaluation/evaluate.py --corpus evaluation/corpus_kr.json --rulepack kr --check
```

[Contributing](https://github.com/hyeonsangjeon/pyveil/blob/main/CONTRIBUTING.md) ·
[Changelog](https://github.com/hyeonsangjeon/pyveil/blob/main/CHANGELOG.md) ·
[Maintainer traffic measurements](https://github.com/hyeonsangjeon/pyveil/blob/main/docs/maintainer-metrics.md)
