SecureMCP
<div align="center">
# ๐ก๏ธ SecureGateway (formerly SecureMCP)
Same project, new name. See the [1.0.0 rename and clean-install notes](docs/RENAME.md).
**Local Multilingual Masking ยท Subscription Gateway ยท Trusted Restoration**
*17๊ฐ ์์ฐ์ดยท24๊ฐ ์ฝ๋ ์ธ์ด๋ฅผ ๋ก์ปฌ์์ ๋ง์คํนํ๊ณ , ๋๊ตฌ ์คํ๊ณผ ์ฌ์ฉ์ ํ๋ฉด์์ ์๋ฌธ์ ๋ณต์ํ๋ ๊ฐ์ธ์ ๋ณด ๋ณดํธ ๋๊ตฌ*
[](pyproject.toml)
[](pyproject.toml)
[](.github/workflows/ci.yml)
[](https://github.com/mj10612/SecureGateway/actions/workflows/ci.yml)
[](docs/ARCHITECTURE.md)
[](LICENSE)
---
[English](#english-overview) ยท [ํ๊ตญ์ด ์๋ด](#ํ๊ตญ์ด-์๋ด-korean-overview) ยท [Supported Versions](#supported-versions) ยท [Quick Start](#quick-start) ยท [์ค์นยท์ด์ ๊ฐ์ด๋](#์ค์น์คํ๊ด๋ฆฌ์-ํ์ด์ง์ข
๋ฃ์ญ์ ) ยท [Features](#features) ยท [Architecture](#system-architecture) ยท [Documentation](#documentation)
**Language guides / ์ธ์ด๋ณ ์๋ด:** [English](docs/i18n/README.en.md) ยท [ํ๊ตญ์ด](docs/i18n/README.ko.md) ยท [Espaรฑol](docs/i18n/README.es.md) ยท [Franรงais](docs/i18n/README.fr.md) ยท [Portuguรชs](docs/i18n/README.pt.md) ยท [Deutsch](docs/i18n/README.de.md) ยท [Bahasa Indonesia](docs/i18n/README.id.md) ยท [Tรผrkรงe](docs/i18n/README.tr.md) ยท [ะ ัััะบะธะน](docs/i18n/README.ru.md) ยท [เคนเคฟเคจเฅเคฆเฅ](docs/i18n/README.hi.md) ยท [เคฎเคฐเคพเค เฅ](docs/i18n/README.mr.md) ยท [เฆฌเฆพเฆเฆฒเฆพ](docs/i18n/README.bn.md) ยท [ุงุฑุฏู](docs/i18n/README.ur.md) ยท [ุงูุนุฑุจูุฉ](docs/i18n/README.ar.md) ยท [เฐคเฑเฐฒเฑเฐเฑ](docs/i18n/README.te.md) ยท [็ฎไฝไธญๆ](docs/i18n/README.zh.md) ยท [ๆฅๆฌ่ช](docs/i18n/README.ja.md)
---
</div>
Repeatable privacy and actual LLM comprehension evaluation is available through `secure-gateway evaluate`. See [evaluation commands and metric definitions](docs/EVALUATION.md). The offline suite uses synthetic data; actual LLM evaluation requires explicit `--real-llm` and fresh interpretation/grading agents.
## English Overview
**SecureGateway** masks text in 17 natural languages and code in 24 language profiles locally,
with session-based restoration. Version 1.2.0 adds offline language adapters, binding-aware
identifier aliases, and restart recovery for interrupted audit records. See the
[language support matrix](docs/LANGUAGES.md) for explicit language tags, syntax scope,
local model dependencies and verification limits. Language support is lexical;
it does not promise complete morphology, entity recognition or executable anonymization.
Version 0.5 adds an experimental **local subscription gateway** for Claude Code and Codex.
Run `secure-gateway gateway install` once, then use `claude` / `codex` normally. Requests are
masked automatically; responses and local tool arguments are restored automatically. Existing
CLI subscription OAuth is forwarded to the original subscription service; API keys are refused.
No agent hooks are installed. See [subscription gateway](docs/GATEWAY.md) for setup,
automatic startup, tested versions and the exact protection boundary.
Legacy agent hooks remain optional utilities. They cover selected tool text rather than
complete requests; [local integration](docs/LOCAL_INTEGRATION.md) documents their limits.
Other hosts have explicit support levels in the [compatibility table](docs/COMPATIBILITY.md).
[Antigravity](docs/ANTIGRAVITY.md) provides verified stdio MCP utility integration.
SDK 0.1.21 uses a context-owned authenticated bridge to the explicit xAI API gateway;
native file reads and restoration are verified offline, with separate API billing.
The separate [xAI API mode and Grok custom model](docs/GROK.md) require opt-in and incur
API charges, independently of Claude/Codex or Grok subscriptions.
Mask confidential input **before** sending it to a provider. Restore responses in your trusted
local application and show them to the user there. Model-invoked MCP tool arguments are already
visible to the provider; adding this server to Claude Desktop or Cursor does not automatically
intercept or protect prompts. Restored originals must not be sent back into the model context.
This is heuristic masking, not a proof of anonymity, cryptographic zero knowledge, or regulatory compliance.
---
## Supported Versions
2.7.18 keeps Windows and POSIX process-group, file-lock and buffered-pipe differences in one typed module, so callers no longer rely on type-checking bypasses.
2.7.15 adds private, bounded gateway failure diagnostics and protects HTTP error responses from formatter failures.
2.7.14 aligns privacy tests with the public-word policy and retains observed evaluation errors.
The [holdout measurement](docs/evaluations/issue323-2.7.13-holdout-continuation/README.md)
improved the task score from 48.00 to 61.00 / 68; its accepted exposure tradeoff,
interrupted primary execution and continuation remain explicit in the report.
2.7.13 preserves authentication-failed snapshots in quarantine before starting a fresh session.
2.7.12 recovers from invalid snapshot envelopes and corrupt reasoning metadata while preserving ambiguous authentication failures.
2.7.11 uses locked dependency environments in CI and documents reproducible installs.
2.7.10 preserves ordinary words and common names by default. Some unregistered
person and organization names can be sent without masking; explicitly register
confidential terms to protect them. See [policy and evaluation limits](docs/research/issue323-policy-validation.md).
2.7.5 masks opaque part/model identifiers such as `TV-592` as one stable alias
in prose and data, while preserving executable subtraction. See the
[identifier boundaries and regression proof](docs/research/issue326-hyphen-identifiers.md).
2.7.4 preserves the primary stream failure when cleanup also fails, adds fixed-category
cleanup diagnostics, and verifies exactly-once close and bounded reader ownership.
See the [stream cleanup proof and limits](docs/research/issue332-stream-cleanup.md).
2.7.3 audits production assertions and replaces boundary checks that disappeared
under `python -O` with explicit exceptions, preserving existing error contracts.
It documents retained proven internal invariants and verifies normal and optimized
execution with targeted subprocess tests. See the [assertion audit and validation analysis](docs/research/issue330-validation.md).
2.7.2 fixes tool-path restoration for digit-leading segments such as `2024_report`
and `3d_models`. It also adds safe diagnostics for failed package lifecycle requests.
See the [reproduction and installed-artifact checks](docs/research/artifact-502-digit-path-investigation.md).
2.7.1์ ํ๊ฐ ์ค HTTP ์ค๋ฅ ์๋ต์ ๋ช
์์ ์ผ๋ก ๋ซ๋๋ก ์์ ํ์ต๋๋ค.
Python 3.14์์ ๋ฐ๊ฒฌ๋ ์์ ์ ๋ฆฌ ๊ฒฝ๊ณ ๋ฅผ ํด๊ฒฐํ๋ฉฐ, ๊ธฐ์กด ํ๊ฐ ์ ์ยท์๋ณธ ๊ธฐ๋ก์ ์ ์งํฉ๋๋ค.
2.7.0์๋ ๋
๋ฆฝ์ ์ผ๋ก ์์ฑํ 17๊ฐ ์ธ์ด ๊ฐ๋ฐยทholdout ์ธํธ์ ๋ฐ๋ณต ํ๊ฐ ๋ช
๋ น์ ์ถ๊ฐํ์ต๋๋ค.
๊ฐ์ธ์ ๋ณด ๋ณดํธยท๊ณต๊ฐ ์ดํ ๊ณผ๋ง์คํนยท์์
์๋ต ์ ์๋ฅผ ๋ถ๋ฆฌํ๊ณ , ์ธ์ด๋ณ 3ํ ์ด์์ ํ๊ท ๊ณผ ํ๋ณธํธ์ฐจ๋ฅผ ๋ณด๊ณ ํฉ๋๋ค.
์ ๋ณด๊ฐ ๋ถ์กฑํ ๊ฒฝ์ฐ์ ์ง๋ฌธยท์กฐ๊ฑด๋ถ ์ด์๋ ์ฑ์ ํ๋ฉฐ, [ํ๊ฐ ์ ์ฐจ์ ํ๊ณ](docs/evaluations/ISSUE324_PROTOCOL.md)๋ฅผ ๊ณต๊ฐํฉ๋๋ค.
[์ค์ 3ํ ํ๊ฐ ๊ฒฐ๊ณผ์ ์ฑ์ ๋ณต๊ตฌ ๊ธฐ๋ก](docs/evaluations/issue324-2.7.0/README.md)๋ ํ์ธํ ์ ์์ต๋๋ค.
2.6.2๋ Windows์์ ์ด์ ๋ฒ์ ์
๊ทธ๋ ์ด๋ ์ํ์ฉ ์์นด์ด๋ธ์ ์๋ณธ ๋ฐ์ดํธ๋ฅผ ๋ณด์กดํ๋๋ก ์์ ํ์ต๋๋ค.
2.6.1์ Windows checkout ์ ์ฌ์ ํด์๊ฐ ๋ฌ๋ผ์ง๋ ์ค๋ฐ๊ฟ ๋ฌธ์ ๋ฅผ ์์ ํ๊ณ ,
์์
์๋ต ์ฌํ๊ฐ์ ์ค์ MCP ๊ณ์ฐ ๋๊ตฌ์ ์ํ ๊ธฐ๋ก์ ์ถ๊ฐํ์ต๋๋ค.
2.6.0์๋ ๋ถ์ผ๋ณ ๋ณดํธ ์ฌ์ ๊ณผ ๊ด๋ฆฌ์ ๊ฐ๋ณ On/Off๋ฅผ ์ถ๊ฐํ์ต๋๋ค. ๋ฐฉ์ฐ์ ๊ธฐ๋ณธ On์ด๋ฉฐ,
ํ์ ๊ตฌ์ฑํยท๊ณต๊ฐ ์ฅ๋น/๋ชจ๋ธยท์ฌ์
๋ช
์ ํฌํจํฉ๋๋ค. ์๋์ฐจ์ ๋ฐ๋์ฒด๋ ์ ํํ ์ ์์ต๋๋ค.
[์ฌ์ ์ถ์ฒยท์ค์ ์๋ยท๊ฒ์ ๋ฒ์](docs/DICTIONARY_SOURCES.md)์
[์ค์ ยท๋ณดํธ ์ ์ฑ
](docs/GATEWAY.md#domain-protection-dictionaries-260)์ ํ์ธํ์ธ์.
๊ธด ๋ํ์ ์บ์ ์ฌ์ฒ๋ฆฌ, ๋ณ์นญ ํ์ ์ด๋ฆ์ ๋ณต์ ์คํจ, 256๊ฐ ๋ํ ์ดํ์ ์ธ์
์ฉ๋ ๋ฌธ์ ๋ ์์ ํ์ต๋๋ค.
2.4.2์์๋ ์ค์น ํ ๋ฐ๋ ์ฌ์ฉ์ ์ค์ ์ ๋ณด์กดํ๋ฉฐ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ ๊ฑฐํ๋๋ก ์์ ํ์ต๋๋ค.
๋ค๋ฅธ Orca ๊ณ์ ์ ๋๊ธฐํ๋ ์ค์ ์ ๋ฆฌ์ `gateway uninstall --force-clean` ๋ณต๊ตฌ๋ ์ง์ํฉ๋๋ค.
2.4.0์๋ ์ ํํ ๋ก์ปฌ E5 ๋ฌธ๋งฅ ๋ชจ๋ธ๊ณผ MiniLM/E5 ๋น๊ต ๊ฒ์ฆ ์ ์ฐจ๋ฅผ ์ถ๊ฐํ์ต๋๋ค.
์ฐ์
์ฉ์ด ์ค๋ถ๋ฅ๊ฐ ๋ฐ๊ฒฌ๋์ด ๋ชจ๋ธ ๋จ๋
์ผ๋ก ๋ฏธ๋ฑ๋ก ๋จ์ด๋ฅผ ๊ณต๊ฐํ์ง ์๋๋ก ์ ํํ์ต๋๋ค.
์ด ์กฐ๊ฑด์์๋ ๋ฌธ๋จ ์ดํด๋ ๊ฐ์ ์ด ์
์ฆ๋์ง ์์ ๊ธฐ๋ณธ๊ฐ์ ๋นํ์ฑํ์
๋๋ค.
[์ค์นยท๋นํ์ฑํ ์ ์ฐจ](docs/GATEWAY.md#optional-local-context-model-240)์
[์ธก์ ๊ฒฐ๊ณผ ๋ฐ ๋จ์ ํ๊ณ](docs/evaluations/CONTEXT_MODEL_2.4.0.md)๋ฅผ ํ์ธํ์ธ์.
| Component | Supported versions / scope |
| :--- | :--- |
| SecureGateway | **2.8.0** |
| Python | **3.10 ยท 3.11 ยท 3.12 ยท 3.13 ยท 3.14** in CI; package requires Python โฅ 3.10 |
| Operating systems | **Windows ยท macOS ยท Linux** in CI |
| Claude Code gateway | **2.1.287 / Sonnet 5.5** native fixtures and live subscription file-read/masking/restoration verified in English and Korean |
| Codex gateway | **CLI 0.160.0 / gpt-6.1-sol** native fixtures and live ChatGPT subscription file-read/masking/restoration verified in English and Korean |
| MCP transport | Local **stdio**; CLI HTTP/SSE transports are disabled |
| Natural languages | **17 natural-language profiles**; [localized guides](docs/i18n/README.en.md) and [language matrix](docs/LANGUAGES.md) |
| Code languages | **24 code-language profiles**; [syntax scope and verification limits](docs/LANGUAGES.md) |
SDK 2.0 migration: `TokenMapping` identity fields are read-only; occurrence counts remain mutable. See [SDK mapping identity](docs/GATEWAY.md#sdk-mapping-identity-200).
The [CI matrix](.github/workflows/ci.yml) covers 15 Python/OS combinations. Code-language
support describes lexer modes, not compatibility with every language release or compiler.
The gateway is experimental. Native fixture tests verify routing/masking/restoration.
Both agents passed live subscription tests: native file reads, masked source transmission,
model answers and automatic restoration in English and Korean. Claude's attribution and
alias compatibility bugs are fixed. The earlier 429 was not subscription exhaustion.
This does not certify all-traffic privacy.
---
## Quick Start
### Automatic subscription integration
```bash
uv tool install .
secure-gateway gateway install
secure-gateway gateway status
```
Restart Claude Code/Codex and use their normal commands. Setup preserves login caches and
registers a hidden user-login startup task. It changes user-wide provider settings; no agent
hooks are added. Subscription limits still apply. This is text/code inference protection;
images, remote attachments and unsupported payloads are blocked. See [gateway guide](docs/GATEWAY.md).
For the complete lifecycle, including the local dashboard and login, see
[์ค์นยท์ด์ ๊ฐ์ด๋](#์ค์น์คํ๊ด๋ฆฌ์-ํ์ด์ง์ข
๋ฃ์ญ์ ).
### ์ค์นยท์คํยท๊ด๋ฆฌ์ ํ์ด์งยท์ข
๋ฃยท์ญ์
์๋๋ **Claude Code / Codex ๊ตฌ๋
๊ฒ์ดํธ์จ์ด**์ ์ ์ฒด ์ฌ์ฉ ์์์
๋๋ค.
Python 3.10 ์ด์, `uv`, Git์ ์ค๋นํ๊ณ ์ฌ์ฉํ ์์ด์ ํธ์์ ๊ธฐ์กด ๊ตฌ๋
๋ก๊ทธ์ธ์ ์๋ฃํ์ธ์.
๊ด๋ฆฌ์ ์นํ์ด์ง๋ ๊ฒ์ดํธ์จ์ด์ ํฌํจ๋์ด ์์ผ๋ฉฐ ๋ณ๋ ์น์๋ฒ๋ฅผ ์ค์นํ ํ์๊ฐ ์์ต๋๋ค.
#### 1. ํจํค์ง ์ค์น์ ์ต์ด ์ค์
```bash
git clone https://github.com/mj10612/SecureGateway.git
cd SecureGateway
uv tool install .
secure-gateway gateway install
secure-gateway gateway status
```
์ด๋ฏธ ์ ์ฅ์๋ฅผ ๋ด๋ ค๋ฐ์๋ค๋ฉด ํด๋น ํด๋์์ `uv tool install .`๋ถํฐ ์คํํ์ธ์.
`gateway install`์ ๊ธฐ๋ณธ์ ์ผ๋ก Claude Code์ Codex์ ์ฌ์ฉ์ ์ค์ ์ ๋ฐฑ์
ยท๋ณ๊ฒฝํ๊ณ ,
๊ฒ์ดํธ์จ์ด๋ฅผ ์ฆ์ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์คํํ๋ฉฐ **์ด์์ฒด์ ์ฌ์ฉ์ ๋ก๊ทธ์ธ ์ ์๋ ์์**์ ๋ฑ๋กํฉ๋๋ค.
๊ธฐ์กด Claude/ChatGPT ๋ก๊ทธ์ธ ํ์ผ์ ๋ณ๊ฒฝํ์ง ์์ต๋๋ค. ์ค์น ํ ์คํ ์ค์ด๋ ์์ด์ ํธ๋ฅผ
์ข
๋ฃํ๊ณ ๋ค์ ์คํํด์ผ ์ ๊ฒฝ๋ก๊ฐ ์ ์ฉ๋ฉ๋๋ค.
ํ ์์ด์ ํธ๋ง ์ค์ ํ๊ฑฐ๋ ํฌํธ๋ฅผ ๋ฐ๊พธ๋ ค๋ฉด ์ต์ด ์ค์น ๋ ์ต์
์ ์ง์ ํ์ธ์.
```bash
secure-gateway gateway install --agent codex
# ๋๋ Claude Code๋ง ์ค์
secure-gateway gateway install --agent claude
# ๊ธฐ๋ณธ ํฌํธ 38117 ๋์ ๋ค๋ฅธ ํฌํธ ์ฌ์ฉ
secure-gateway gateway install --port 38119
```
์ ์์๋ ์ ํ์ง์ด๋ฉฐ ์ ๋ถ ์คํํ ํ์๋ ์์ต๋๋ค. ๊ธฐ์กด ์ค์น์ ํฌํธ๋ฅผ ๋ณ๊ฒฝํ๋ ค๋ฉด
๋จผ์ `gateway uninstall`๋ก ์ค์ ์ ๋ณต์ํ ๋ค ์ํ๋ ํฌํธ๋ก ๋ค์ ์ค์นํ์ธ์.
`secure-gateway` ๋ช
๋ น์ ์ฐพ์ง ๋ชปํ๋ค๋ฉด `uv tool update-shell`์ ์คํํ๊ณ ํฐ๋ฏธ๋์ ๋ค์ ์ฌ์ธ์.
#### 2. ์คํยท์ํ ํ์ธยท์ฌ์์
์ต์ด ์ค์น ํ์๋ ํ์์ฒ๋ผ `claude` / `codex`๋ฅผ ์คํํ๋ฉด ๋ฉ๋๋ค. ๋ก๊ทธ์ธ ์ ์๋ ์์๋
๊ฒ์ดํธ์จ์ด๊ฐ ๋ง์คํนยท์ค๊ณยท๋ณต์์ ์ฒ๋ฆฌํฉ๋๋ค. ์ํ๋ ๋ค์ ๋ช
๋ น์ผ๋ก ํ์ธํฉ๋๋ค.
```bash
secure-gateway gateway status
```
์ด ๋ช
๋ น์ ์๋ฒ ์ํ์ ์ค์น ํ์ผ ๋ณ๊ฒฝ ์ฌ๋ถ๋ฅผ ํ์ธํฉ๋๋ค. ์ค์ ์ถ๋ก ์์ฒญ์ด ๊ฒ์ดํธ์จ์ด๋ฅผ
ํต๊ณผํ๋์ง๋ ์์ด์ ํธ์์ ์์ฒญ์ ๋ณด๋ธ ๋ค ๊ด๋ฆฌ์ ํ์ด์ง์ ์ฒ๋ฆฌ ๋ก๊ทธ๋ก ํ์ธํ์ธ์.
์๋ ์คํ ๋๋ ์ง๋จ์ด ํ์ํ๋ฉด ๊ธฐ์กด ๋ฐฑ๊ทธ๋ผ์ด๋ ํ๋ก์ธ์ค๋ฅผ ๋จผ์ ์ข
๋ฃํ ๋ค ์คํํฉ๋๋ค.
```bash
secure-gateway gateway stop
secure-gateway gateway run
```
`gateway run`์ **ํ์ฌ ํฐ๋ฏธ๋์์ ๊ณ์ ์คํ**๋๋ฉฐ `Ctrl+C`๋ก ์ข
๋ฃํฉ๋๋ค.
์ด ์ํ์์ ๊ด๋ฆฌ์ ํ์ด์ง๋ฅผ ์ด๋ ค๋ฉด ๋ค๋ฅธ ํฐ๋ฏธ๋์ ์ฌ์ฉํ์ธ์.
์ข
๋ฃํ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ค์ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์คํํ๋ ค๋ฉด ์ค์น ์ค์ ์ด ๋ณ๊ฒฝ๋์ง ์์ ์ํ์์
`secure-gateway gateway install`์ ๋ค์ ์คํํ ์ ์์ต๋๋ค.
์ ์ฅ์์ ์ต์ ์ฝ๋๋ก ๊ธฐ์กด ํจํค์ง๋ฅผ ์
๋ฐ์ดํธํ ๋๋ ๋ค์ ์์๋ฅผ ์ฌ์ฉํ์ธ์.
```bash
secure-gateway gateway stop
uv tool install --force .
secure-gateway gateway install
```
์ดํ ์์ด์ ํธ๋ฅผ ์ฌ์์ํ์ธ์. ์ค์น ๋ค ํธ์คํธ ์ค์ ์ด ์์ ๋๋ค๋ฉด ์ฌ์ค์นยท์ ๊ฑฐ๊ฐ ๊ฑฐ๋ถ๋ ์
์์ต๋๋ค. ์ค๋ฅ๊ฐ ๊ฐ๋ฆฌํค๋ ์ค์ ๊ณผ `installation.json`์ ๋ฐฑ์
์ ๊ฒํ ยท๋ณํฉํ ๋ค ์ฌ์๋ํ์ธ์.
#### 3. ๊ด๋ฆฌ์ ํ์ด์ง ์คํ
๊ฒ์ดํธ์จ์ด๊ฐ ์คํ ์ค์ผ ๋ ๋ค์ ๋ช
๋ น์ผ๋ก ๊ธฐ๋ณธ ๋ธ๋ผ์ฐ์ ๋ฅผ ์ฝ๋๋ค.
```bash
secure-gateway gateway admin
```
๊ธฐ๋ณธ ์ฃผ์๋ **http://127.0.0.1:38117/admin**์
๋๋ค. ์ค์น ์ ํฌํธ๋ฅผ ๋ณ๊ฒฝํ๋ค๋ฉด ํด๋น ํฌํธ๋ฅผ
์ฌ์ฉํ์ธ์. `gateway admin`์ ์ค์ ํ์ผ์์ ํฌํธ๋ฅผ ์ฝ์ด ์ฌ๋ฐ๋ฅธ ์ฃผ์๋ฅผ ์๋ดํฉ๋๋ค.
๋ธ๋ผ์ฐ์ ๋ฅผ ์๋์ผ๋ก ์ด์ง ์๊ณ ์ฃผ์๋ง ํ์ธํ๋ ค๋ฉด ๋ค์ ๋ช
๋ น์ ์ฌ์ฉํ์ธ์.
```bash
secure-gateway gateway admin --no-open
```
์ด ๋ช
๋ น์ ๊ฒ์ดํธ์จ์ด๋ฅผ ์๋ก ์์ํ์ง ์์ต๋๋ค. ์๋ฒ๊ฐ ์ค์ง๋๋ค๋ฉด ๋จผ์ ์คํํ์ธ์.
#### 4. ๊ด๋ฆฌ์ ๋ก๊ทธ์ธ๊ณผ ๋ก๊ทธ ์กฐํ
**์ค์ ํ์ผ์ ํ ํฐ์ด ์๋ค๊ณ ์๋ ๋ก๊ทธ์ธ๋๋ ๊ฒ์ ์๋๋๋ค.** ๋ธ๋ผ์ฐ์ ๋ ๋ก์ปฌ ์ค์ ํ์ผ์
์ฝ์ง ์์ต๋๋ค. ๋ค์ ์์๋ก ๋ก๊ทธ์ธํ์ธ์.
1. ์ฌ์ฉ ์ค์ธ ๊ฒ์ดํธ์จ์ด์ `config.json`์ ๋ก์ปฌ ํธ์ง๊ธฐ๋ก ์ฝ๋๋ค.
2. JSON์ `token` ํญ๋ชฉ ๊ฐ์ ๋ณต์ฌํฉ๋๋ค. ๊ฐ ์ฃผ๋ณ์ ํฐ๋ฐ์ดํ๋ ์ ์ธํฉ๋๋ค.
3. ๊ด๋ฆฌ์ ํ์ด์ง์ **๊ด๋ฆฌ์ ์ธ์ฆ ํ ํฐ** ์
๋ ฅ๋์ ๋ถ์ฌ ๋ฃ์ต๋๋ค.
4. **๊ด๋ฆฌ์ ํ์ด์ง ์ด๊ธฐ** ๋ฒํผ์ ๋๋ฆ
๋๋ค.
| ์ด์์ฒด์ | ๊ธฐ๋ณธ ์ค์ ํ์ผ |
| --- | --- |
| Windows | `%USERPROFILE%\.secure-gateway\gateway\config.json` |
| macOS / Linux | `~/.secure-gateway/gateway/config.json` |
์ด ํ ํฐ์ ์ค์นํ ๋ ์์ฑ๋๋ **๋ก์ปฌ ๊ฒ์ดํธ์จ์ด ์ ๊ทผ ํ ํฐ**์
๋๋ค. Claude/ChatGPT์
๊ตฌ๋
๋ก๊ทธ์ธ ํ ํฐ์ด๋ API ํค๋ฅผ ์
๋ ฅํ๋ ๊ฒ์ด ์๋๋๋ค. ๋ณ๋์ ๊ด๋ฆฌ์ ๊ณ์ ยท๋น๋ฐ๋ฒํธ๋
์์ผ๋ฉฐ, ์ค์ ํ์ผ์ ํ ํฐ๊ณผ ์ผ์นํ๋ฉด ๊ด๋ฆฌ์ ๋ก๊ทธ๋ฅผ ์กฐํํ ์ ์์ต๋๋ค.
ํ ํฐ์ URL์ ๋ฃ๊ฑฐ๋ ๋ค๋ฅธ ์ฌ๋์๊ฒ ๊ณต์ ํ์ง ๋ง์ธ์.
ํ ํฐ์ ํ์ฌ ๋ธ๋ผ์ฐ์ ํญ์ ๋ฉ๋ชจ๋ฆฌ์๋ง ๋ณด๊ดํฉ๋๋ค. **๋ธ๋ผ์ฐ์ ํ์ด์ง๋ฅผ ์๋ก๊ณ ์นจ(F5)ํ๊ฑฐ๋
ํญ์ ๋ซ์ผ๋ฉด ๋ค์ ์
๋ ฅํด์ผ ํ๋ฉฐ**, ํ๋ฉด์ **๋ก๊ทธ์์** ๋ฒํผ์ ๋๋ฅด๋ฉด ํ ํฐ๊ณผ ํ์๋ ๋ด์ญ์ด
์ง์์ง๋๋ค. ํ๋ฉด ์์ **์๋ก๊ณ ์นจ** ๋ฒํผ์ ๋ก๊ทธ์ธ ์ํ๋ฅผ ์ ์งํ๋ฉด์ ๋ก๊ทธ๋ง ๋ค์ ์กฐํํฉ๋๋ค.
๋ก๊ทธ์์์ ๊ฒ์ดํธ์จ์ด ์ข
๋ฃ๋ SQLite ๋ก๊ทธ ์ญ์ ๋ฅผ ์๋ฏธํ์ง ์์ต๋๋ค.
๊ด๋ฆฌ์ ํ๋ฉด์์๋ ์์ด์ ํธยท์ ๊ณต์ยท๊ตฌ๋
/API ์ธ์ฆยท๊ฒฐ๊ณผยท์์ ์ผ์ยท์ต๋ช
๊ณ์ ID๋ก ๋ก๊ทธ๋ฅผ
ํํฐ๋งํ๊ณ , ๊ฐ ์์ฒญ์ ๋ชจ๋ธยท๋ชฉ์ ์งยทHTTP ์ํยท์ ์ก ์๋ยท์ฒ๋ฆฌ ์๊ฐยท๋ฐ์ดํธ ์๋ฅผ ํ์ธํ ์
์์ต๋๋ค. Claude ๊ตฌ๋
, ChatGPT ๊ตฌ๋
, xAI API ํค ๊ฒฝ๋ก๋ ๊ตฌ๋ถ๋ฉ๋๋ค. ์ ๋ฌ๋ ๊ณ์ ์๋ณ์๋
์ต๋ช
ํํ๋ฉฐ, ๊ตฌ๋
์๊ธ์ ๋ ๊ฒฐ์ ๊ณ์ ์ ํ์ธํ ์ ์๋ ๊ฒฝ์ฐ์๋ **ํ์ธ ๋ถ๊ฐ**๋ก ํ์ํฉ๋๋ค.
์ฒ๋ฆฌ ๋ด์ญ์ `config.json` ์์ **`logs.sqlite3`**์ ์ ์ฅํ๋ฉฐ ์ต๊ทผ **100,000๊ฑด**์ ๋ณด๊ดํฉ๋๋ค.
์์ฒญยท์๋ต ์๋ฌธ, OAuth ํ ํฐ, API ํค๋ ๊ธฐ๋กํ์ง ์์ต๋๋ค. ์ฌ์์ ํ์๋ ๋ก๊ทธ๋ ์ ์ง๋ฉ๋๋ค.
SQLite ๋ก๊ทธ๋ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ข
๋ฃํ ๋ค ๋ฐฑ์
ํ๊ฑฐ๋ SQLite ์จ๋ผ์ธ ๋ฐฑ์
๊ธฐ๋ฅ์ ์ฌ์ฉํ์ธ์.
#### 5. ์ฌ์ฉ์ ์ง์ ์ค์ ํ์ผ๊ณผ xAI API ๋ชจ๋
`--config`๋ก ์ค์นํ๋ค๋ฉด ์ดํ ๋ช
๋ น์์๋ **๊ฐ์ ์ค์ ํ์ผ**์ ์ง์ ํด์ผ ํฉ๋๋ค.
์๋ ๊ฒฝ๋ก๋ ์ค์ ์ฌ์ฉ ์ค์ธ ๊ฒฝ๋ก๋ก ๋ฐ๊พธ์ธ์.
```bash
secure-gateway gateway install --config ./gateway-state/config.json
secure-gateway gateway status --config ./gateway-state/config.json
secure-gateway gateway admin --config ./gateway-state/config.json
secure-gateway gateway stop --config ./gateway-state/config.json
secure-gateway gateway uninstall --config ./gateway-state/config.json
```
์๋ ์คํ๋ `gateway run --config ./gateway-state/config.json`์ ์ฌ์ฉํฉ๋๋ค.
๊ด๋ฆฌ์ ๋ก๊ทธ์ธ์๋ ์ด ํ์ผ์ `token`์ ์ฌ์ฉํ๊ณ , ๋ก๊ทธ DB๋ ๊ฐ์ ํด๋์ ์ ์ฅ๋ฉ๋๋ค.
xAI API ๋ชจ๋๋ ๊ตฌ๋
๊ฒ์ดํธ์จ์ด์ ๋ณ๋๋ก ์ค์ ยท์คํํ๋ฉฐ **๋ณ๋ API ์๊ธ์ด ๋ฐ์ํฉ๋๋ค**.
์ค์น๋ [Grok / xAI ์๋ด](docs/GROK.md)๋ฅผ ๋ฐ๋ฅด๊ณ , ์คํ์๋ `gateway api-run`,
์ ๊ฑฐ์๋ `gateway api-uninstall`์ ์ฌ์ฉํ์ธ์. ๊ธฐ๋ณธ ์ค์ ์
`~/.secure-gateway/xai-api/config.json`, ๊ธฐ๋ณธ ํฌํธ๋ `38118`์
๋๋ค.
๊ด๋ฆฌ์ ํ๋ฉด์ ๋์ผํ ๋ช
๋ น์ผ๋ก ํด๋น ์ค์ ํ์ผ์ ์ง์ ํด ์ฝ๋๋ค.
```bash
secure-gateway gateway admin --config /path/to/xai-api/config.json
```
#### ๊ฐ์ ์นํ ๋จ์ด
๊ด๋ฆฌ์ ํ์ด์ง์ **๊ฐ์ ์นํ ๋จ์ด**์ ํ ์ค์ ํ๋์ฉ ์
๋ ฅํ๊ณ ์ ์ฅํ์ธ์. ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ๋ฉฐ
์
๋ ฅํ ๋ฌธ์์ด์ ๋ค๋ฅธ ๋จ์ด ์์์๋ ์นํํฉ๋๋ค. `*๋น๋ฐ*`, `๋น๋ฐ*`, `*๋น๋ฐ`๊ณผ `๋น๋ฐ`์ ๋ชจ๋
`๋น๋ฐ` ๋ถ๋ถ์ ๋ปํฉ๋๋ค. ์ค๊ฐ `*`๋ `*`๋ง ์
๋ ฅํ๋ ๊ฒ์ ์ง์ํ์ง ์์ต๋๋ค. ์ ์ฅ์ ์ ์์ฒญ๋ถํฐ
์ ์ฉ๋๋ฉฐ ์งํ ์ค์ธ ์์ฒญ์ด ์์ผ๋ฉด ๊ฑฐ๋ถ๋ฉ๋๋ค. ๊ท์น์ ๋ก์ปฌ ๊ฒ์ดํธ์จ์ด ๋ฐ์ดํฐ ํด๋์ ์ ์ฅ๋ฉ๋๋ค.
๊ท์น ํ์ผ์ ๊ฒ์ดํธ์จ์ด ํ ํฐ์ผ๋ก ์ํธํ๋ฉ๋๋ค. ํ ํฐ์ ์๊ฑฐ๋ ๋ณ๊ฒฝํ๋ฉด ๊ธฐ์กด ๊ท์น์ ์ฝ์ ์
์์ผ๋ฏ๋ก ํ ํฐ๊ณผ ๋ฐ์ดํฐ๋ฅผ ํจ๊ป ์์ ํ๊ฒ ๋ณด๊ดํ์ธ์.
ํ์ ํ๋กํ ์ฝ ํ๋์ ๊ท์น์ด ์ถฉ๋ํ๋ฉด ์์ ํ๊ฒ ์์ฒญ์ด ์ฐจ๋จ๋ ์ ์์ผ๋ฏ๋ก ๊ท์น์ ๊ตฌ์ฒด์ ์ผ๋ก
์ ํ์ธ์. ์ผ๋ฐ ์ดํ ๋ชฉ๋ก๊ณผ ๊ฐ์ ์นํ์ ํด๋ฆฌ์คํฑ์ด๋ฉฐ ๋ชจ๋ ๋ฏผ๊ฐ ์ ๋ณด๋ฅผ ์๋์ผ๋ก ์๋ณํ์ง๋ ๋ชปํฉ๋๋ค.
์ผ๋ฐ ๋จ์ด์ ์ฒ ์๊ฐ ๊ฐ์ ์ด๋ฆ๋ ๋ณด์กด๋ ์ ์์ผ๋ฏ๋ก ๋ณดํธํ ์ด๋ฆ์ ๊ฐ์ ์นํ ๋ชฉ๋ก์ ๋ฃ์ผ์ธ์.
#### 6. ์ข
๋ฃยท์ค์ ํด์ ยทํจํค์ง ์ญ์
| ์ํ๋ ์์
| ๋ฐฉ๋ฒ | ๋จ๋ ํญ๋ชฉ |
| --- | --- | --- |
| ๊ด๋ฆฌ์ ํ๋ฉด ๋ก๊ทธ์์ | ํ๋ฉด์ **๋ก๊ทธ์์** | ๊ฒ์ดํธ์จ์ด๋ ๊ณ์ ์คํ๋๊ณ DB ๋ก๊ทธ๋ ์ ์ง |
| ํ์ฌ ๊ฒ์ดํธ์จ์ด๋ง ์ข
๋ฃ | `secure-gateway gateway stop` ๋๋ ์๋ ์คํ ํฐ๋ฏธ๋์์ `Ctrl+C` | ์์ด์ ํธ ์ค์ ยท์๋ ์์ ๋ฑ๋กยท๋ก์ปฌ ๋ฐ์ดํฐ ์ ์ง |
| ๊ฒ์ดํธ์จ์ด ์ค์ ํด์ | `secure-gateway gateway uninstall` | ์ค์ ๋ณต์ ํ ๋ก์ปฌ ์ค์ ํ์ผยท๋ก๊ทธยท์ธ์
๋ฐ์ดํฐ ์ ์ง |
| ์ค์นํ ํจํค์ง ์ญ์ | ์ค์ ํด์ ํ `uv tool uninstall secure-gateway` | ์ ์ฅ์์ ๋ก์ปฌ ๋ฐ์ดํฐ ์ ์ง |
`stop`๋ง ์คํํ๋ฉด ๋ค์ ์ด์์ฒด์ ๋ก๊ทธ์ธ ๋ ๊ฒ์ดํธ์จ์ด๊ฐ ๋ค์ ์์๋ ์ ์์ต๋๋ค.
์ข
๋ฃ๋ ๋์์๋ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ฌ์ฉํ๋๋ก ์ค์ ๋ ์์ด์ ํธ ์์ฒญ์ด ์คํจํฉ๋๋ค.
์๋ ์์ ๋ฑ๋ก์ ์ ๊ฑฐํ๊ณ ์์ด์ ํธ์ ๊ธฐ์กด ์ค์ ์ผ๋ก ๋์๊ฐ๋ ค๋ฉด `uninstall`์ ์ฌ์ฉํ์ธ์.
์์ ํ ์ฌ์ฉ์ ์ค๋จํ ๋์ ์์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
```bash
secure-gateway gateway uninstall
uv tool uninstall secure-gateway
```
`uninstall`์ ์คํ ์ค์ธ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ข
๋ฃํ๊ณ , ๋ฐฑ์
ํ ์์ด์ ํธ ์ค์ ๊ณผ ์๋ ์์ ํ์ผ์
์ค์น ์ ์ํ๋ก ๋ณต์ํฉ๋๋ค. ์ฑ๊ณตํ ๋ค ์์ด์ ํธ๋ฅผ ์ฌ์์ํ์ธ์. ์ค์น ํ ์์ ๋ ํ์ผ์
๋ฎ์ด์ฐ์ง ์๋๋ก ์ ๊ฑฐ๊ฐ ๊ฑฐ๋ถ๋๋ฉด ๋จผ์ ์ค์ ์ ๊ฒํ ยท๋ณํฉํด์ผ ํฉ๋๋ค. **์ค์ ๋ณต์์ด ์๋ฃ๋๊ธฐ
์ ์ ํจํค์ง๋ ๋ฐฑ์
์ ์ญ์ ํ์ง ๋ง์ธ์.** xAI API ์ค์ ๋ ์ฌ์ฉํ๋ค๋ฉด ํจํค์ง๋ฅผ ์ญ์ ํ๊ธฐ ์ ์
`gateway api-uninstall`๋ ์คํํ์ธ์.
๋ณต์์ ํด๋น `config.json`์ `installation.json`์ ๊ธฐ๋ก๋ ํ์ผ์๋ง ์ ์ฉ๋ฉ๋๋ค. ์ค์น ๋
`--config`๋ฅผ ์ฌ์ฉํ๋ค๋ฉด ์ ๊ฑฐํ ๋๋ ๊ฐ์ ๊ฒฝ๋ก๋ฅผ ์ง์ ํ์ธ์. `No active gateway installation
found`๋ ๋ณต์ ๊ธฐ๋ก์ด ์๋ค๋ ๋ป์ด๋ฉฐ, ๋ค๋ฅธ ๊ณ์ ์ด๋ ์ค์ ๊ฒฝ๋ก๊น์ง ๋ณต์๋๋ค๋ ๋ป์ ์๋๋๋ค.
Orca์์ ์ฌ๋ฌ Codex ๊ณ์ ์ ์ฌ์ฉํ๋ค๋ฉด ๊ฐ ๊ณ์ ์ `CODEX_HOME`์ด ๋ค๋ฅผ ์ ์์ผ๋ฏ๋ก ๊ฐ ๊ณ์ ์
`config.toml`๋ ํ์ธํ์ธ์. ์ค์น ๊ธฐ๋ก์ด ์๋ ๊ฒฝ์ฐ ํ์ฌ ์ค์ ๊ณผ ๋ฐฑ์
์ ๋ฐ๋ก ๋ณด๊ดํ๊ณ ์ค์น ์
์ค์ ๊ณผ ๋น๊ตํด ํ์ํ ํญ๋ชฉ๋ง ๋ณํฉํ์ธ์. ๋ฐฑ์
์์ฒด์ ๊ฒ์ดํธ์จ์ด ์ค์ ์ด ๋ค์ด ์์ ์๋ ์์ผ๋ฏ๋ก
ํ์ธ ์์ด ํ์ผ ์ ์ฒด๋ฅผ ๋ฎ์ด์ฐ์ง ๋ง์ธ์. ํ ํฐ์ด๋ ์ค์ ์๋ฌธ์ ๊ณต๊ฐํ์ง ๋ง์ธ์.
๋ณต์ ํ์ธ์ ์คํ ์ค์ธ Codex/Claude๋ฅผ ์์ ํ ์ข
๋ฃํ ํ ์๋ก ์์ํ์ฌ ์ํํ์ธ์. Codex์
ํด๋น ๊ณ์ ์ค์ ์ `model_provider = "secure_gateway_subscription"` ๋๋
`[model_providers.secure_gateway_subscription]`์ด ๋จ์ ์๋ค๋ฉด ํด๋น ๊ณ์ ์ ์์ง ๊ฒ์ดํธ์จ์ด๋ฅผ
์ฐธ์กฐํ ์ ์์ต๋๋ค. ๊ธฐ์กด ๊ณต๊ธ์ ์ค์ ์ ๊ฐ์์ ์ค์น ์ ์ค์ ์ ๊ธฐ์ค์ผ๋ก ๋ณต์ํด์ผ ํฉ๋๋ค.
๋ ๊ฑฐ์ `secure-gateway init`์ผ๋ก ๋ณ๋ ์ค์นํ ํ
์ ๊ฒ์ดํธ์จ์ด ์ ๊ฑฐ์ ๋ณ๊ฐ์
๋๋ค.
[ํ
์ ๊ฑฐ ์๋ด](docs/LOCAL_INTEGRATION.md)๋ฅผ ๋ฐ๋ผ ์ค์น ๋น์์ ๊ฐ์ ์์ด์ ํธ ๋ฐ ๋ฒ์์์ ์ ๊ฑฐํ์ธ์.
#### ๋ชจ๋ธ์ด ์ง๋ฌธ์ ํต์ฌ์ ์ ์ ์๋ค๊ณ ๋ตํ ๋
๊ฒ์ดํธ์จ์ด๋ ์ผ๋ฐ์ ์ธ ์์
์ง์์ด ์ผ๋ถ๋ฅผ ๊ทธ๋๋ก ์ ๋ฌํ๊ณ ๋์ ์ด๋ฆ๊ณผ ๋ฏผ๊ฐํ ๊ฐ์ ๋ง์คํนํฉ๋๋ค.
์๋ฅผ ๋ค์ด `SecureMCP ์ญ์ ํด์ค`์์ ๋์์ ๋ณ์นญ์ผ๋ก ๋ฐ๊พธ๊ณ `์ญ์ ํด์ค`๋ ์ ์งํฉ๋๋ค. ์ง์์ด
๋ชฉ๋ก์ ์์ ํ ์ฌ์ ์ด ์๋๋ฏ๋ก ๋ชฉ๋ก์ ์๋ ํํ์ ๊ฐ๋ ค์ง ์ ์์ต๋๋ค. ๋ณต์์ ์๋ต์ ๋์จ
๋ณ์นญ์ ๋๋๋ฆด ๋ฟ ๋ชจ๋ธ์ด ๋ณด์ง ๋ชปํ ์๋ฏธ๋ฅผ ๋ณต๊ตฌํ์ง ๋ชปํฉ๋๋ค. ์ด ๊ฒฝ์ฐ ํํ์ ๋ฐ๊ฟ ์์ฒญํด ๋ณด์ธ์.
2.3.0๋ถํฐ ๊ฒ์ดํธ์จ์ด๋ ๋ก์ปฌ ๋น๋ ์ฌ์ ๊ณผ ๊ฒํ ํ ์ํ ์ดํ๋ก ์ผ๋ฐ ๋ฌธ๋งฅ์ ๋ ๋๊ฒ ๋ณด์กดํฉ๋๋ค.
์ด๋ฆยท๋ถ์ผ ์ฉ์ดยท๊ฐ์ ์นํยท๊ธฐ์กด ๋น๋ฐ ๋งคํ์ด ์ฐ์ ํ๋ฉฐ, ์ฝ๋์ ๋๊ตฌ ์ธ์ ๊ฐ์ ๋ ์๊ฒฉํ๊ฒ ์ฒ๋ฆฌํฉ๋๋ค.
[๊ฒ์ฆ ๊ฒฐ๊ณผ์ ์๋ฃ ์ถ์ฒ](docs/GATEWAY.md#broad-local-gateway-prose-vocabulary-230)๋ฅผ ํ์ธํ์ธ์.
2.3.1์ ๋น๊ตยท์์ฝ ๋ฑ์ ์์
ํํ๊ณผ ์์ยท๋ถ์ ยท์กฐ๊ฑด์ ๋ณด์กดํ๊ณ , ๋ชจ๋ธ์ ๋ณ์นญ์ ์ผ๊ด๋ ์ฐธ์กฐ๋ก
์ฌ์ฉํ๋๋ก ์๋ดํฉ๋๋ค. ํน์ ์ด๋ฆ์ ๋ชฐ๋ผ๋ ๋ณด์ด๋ ๋ฌธ๋งฅ์ผ๋ก ๊ฐ๋ฅํ ์์
์ ์ํํ๊ฒ ํฉ๋๋ค.
[๋ฌธ๋จ ์๋ฏธ ๊ฒ์ฆ ์ ์ฐจ](docs/GATEWAY.md#text-intent-with-opaque-references-231)์์ ์๋ฌธ์
๊ณต๊ฐํ์ง ์๋ ํ๊ฐ ์
๋ ฅ์ ๋ง๋ค๊ณ , ๋ณ๋ ๋ชจ๋ธ์ ํด์์ ์๋ฌธ๊ณผ ๋์กฐํ ์ ์์ต๋๋ค.
๋ชจ๋ ์ผ์ ํํ์ ํ๋ณํ์ง๋ ๋ชปํฉ๋๋ค. ์ธ์ด ์๋ ๊ฐ์ง๋
๊ณต์ ๋ฌธ์๋ง์ผ๋ก ์ธ์ด๋ฅผ ์ ํํ ๊ตฌ๋ถํ ์ ์์ผ๋ฏ๋ก ํ์ํ๋ฉด `config.json`์ `natural_language`๋ฅผ
ํด๋น ์ธ์ด ์ฝ๋๋ก ์ง์ ํ๊ณ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ฌ์์ํ์ธ์.
์ด์ ์คํ์์ ํด๋น ์ง์์ด๊ฐ ์ด๋ฏธ ๋ณ์นญ์ผ๋ก ๊ธฐ๋ก๋๋ค๋ฉด ์
๋ฐ์ดํธ ํ์๋ ๊ธฐ์กด ๋งคํ์ด ์ฐ์ ํฉ๋๋ค.
ํ์ํ ๋ ๊ฒ์ดํธ์จ์ด๋ฅผ ์คํํ ์ํ์์ `secure-gateway gateway reset --agent codex`๋ก
Codex ๋งคํ์ ์ง์ฐ๊ณ ์ ๋ํ๋ฅผ ์์ํ์ธ์. ์ด๊ธฐํํ๋ฉด ์ด์ ๋ํ์ ๋ณ์นญ์ ๋ณต์ํ ์ ์์ผ๋ฏ๋ก
์งํ ์ค์ธ ์์ฒญ์ ๋๋ด๊ณ ์ด์ ๋ํ๋ฅผ ๋ ์ด์ ์ฌ๊ฐํ์ง ์์ ๋๋ง ์คํํ์ธ์.
์ ํ์ ์ผ๋ก `config.json`์ ๊ธฐ์กด ํญ๋ชฉ์ ์ ์งํ ์ฑ `prose_mode`๋ฅผ `uncommon_words`๋ก ์ค์ ํ๊ณ
๊ณต๊ฐํด๋ ๋๋ ๋จ์ด๋ง `common_words`์ ์ถ๊ฐํ ํ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ฌ์์ํ ์ ์์ต๋๋ค.
[์ค์ ์์์ ์ ์ฝ](docs/GATEWAY.md#selective-ordinary-vocabulary-160)์ ํ์ธํ์ธ์.
์ด ๋ชฉ๋ก์ ์์ ํ ํ๊ตญ์ด ์ฌ์ ์ด ์๋๋ฉฐ ํ์ฉํ๋ ์๋์ผ๋ก ๋ชจ๋ ๋ณด์กดํ์ง ์์ผ๋ฏ๋ก ๋ฌธ์ ํด๊ฒฐ์
๋ณด์ฅํ์ง ์์ต๋๋ค. ๋ชฉ๋ก์ ์ถ๊ฐํ ๋จ์ด๋ ์ ๊ณต์์๊ฒ ๋ณด์ผ ์ ์์ผ๋ฏ๋ก ๋ฏผ๊ฐํ ์ด๋ฆ์ด๋ ์ ๋ณด๋ฅผ
์ถ๊ฐํ์ง ๋ง์ธ์. `entities_only`๋ ์ธ์๋์ง ์์ ๋ฏผ๊ฐ ์ ๋ณด๋ฅผ ๋
ธ์ถํ ์ ์๊ณ ๋ชจ๋ ์ผ๋ฐ ์ง์์ด์
๋ณด์กด์ ๋ณด์ฅํ์ง ์์ต๋๋ค. ๊ธฐ๋ฅ์ด ์ฐ์ ์ด๋ผ๋ฉด ๊ฒ์ดํธ์จ์ด ์ค์ ์ ํด์ ํ๊ณ ์ง์ ์ฌ์ฉํ๋,
๊ทธ ์ธ์
์ ์
๋ ฅ์ ๊ฒ์ดํธ์จ์ด๋ก ๋ณดํธ๋์ง ์์ต๋๋ค.
๋ณต๊ตฌ์ฉ ์ค์ ยทSQLite ๋ก๊ทธยท์ํธํ ์ธ์
์ ์๋์ผ๋ก ์ญ์ ํ์ง ์์ต๋๋ค. ์ ๊ฑฐ๊ฐ ์ฑ๊ณตํ๊ณ
๊ฒ์ดํธ์จ์ด๊ฐ ์ข
๋ฃ๋ ๊ฒ์ ํ์ธํ ๋ค, ๋ฐ์ดํฐ๊น์ง ์ญ์ ํ๋ ค๋ฉด ํ์ํ ๋ก๊ทธ๋ฅผ ๋จผ์ ๋ฐฑ์
ํ๊ณ
ํด๋น ๋ฐ์ดํฐ ํด๋๋ฅผ ์๋ ์ญ์ ํ์ธ์.
| ์ค์น ๋ฐฉ์ | ์ญ์ ํ ๋ฐ์ดํฐ ํด๋ |
| --- | --- |
| ๊ธฐ๋ณธ ๊ตฌ๋
๊ฒ์ดํธ์จ์ด | Windows: `%USERPROFILE%\.secure-gateway\gateway` / macOSยทLinux: `~/.secure-gateway/gateway` |
| ๊ธฐ๋ณธ xAI API ๊ฒ์ดํธ์จ์ด | Windows: `%USERPROFILE%\.secure-gateway\xai-api` / macOSยทLinux: `~/.secure-gateway/xai-api` |
| ์ฌ์ฉ์ ์ง์ ์ค์ | ์ง์ ํ `config.json`์ ๋ถ๋ชจ ํด๋์์ SecureGateway ๋ฐ์ดํฐ๋ง ์ญ์ |
์ฌ์ฉ์ ์ง์ ํด๋์ ๋ค๋ฅธ ํ์ผ์ด ์๋ค๋ฉด ํด๋ ์ ์ฒด๋ฅผ ์ญ์ ํ์ง ๋ง์ธ์. ์์ค ์ ์ฅ์๋ ํจํค์ง
์ ๊ฑฐ์ ๋ณ๊ฐ์ด๋ฏ๋ก ๋ ์ด์ ํ์ํ์ง ์์ ๋ ์ง์ ์ญ์ ํ ์ ์์ต๋๋ค.
์์ธํ ๋ณดํธ ๋ฒ์์ ์ค๋ฅ ์ง๋จ์ [๊ฒ์ดํธ์จ์ด ์๋ด](docs/GATEWAY.md)๋ฅผ ์ฐธ๊ณ ํ์ธ์.
### Legacy optional agent hooks
```bash
uv tool install .
secure-gateway init --agent claude
secure-gateway doctor
```
Restart Claude Code after installation. Hooks default to the current project; use `--global`
for user-wide registration. See [local integration](docs/LOCAL_INTEGRATION.md) for supported
tool fields, installation/removal and limitations.
For Codex:
```bash
secure-gateway init --agent codex
secure-gateway doctor --agent codex
```
Restart Codex and review/trust the installed definitions in `/hooks`. Project hooks require a
trusted project. Codex masks tool results and restores `Bash`/`apply_patch` inputs; automatic
screen restoration is unavailable. Use `secure-gateway restore --agent codex --session-id <id>`
with masked text on UTF-8 stdin for local display. See [Codex integration](docs/LOCAL_INTEGRATION.md#codex).
### Development installation and demo
```bash
uv venv
uv pip install -e ".[dev]"
uv run python -m secure_gateway demo
```
### Trusted local Python API
```python
from secure_gateway import LocalPrivacyClient
# Replace echo with your provider adapter. Only its argument may leave the host.
def provider(masked_payload: str) -> str:
return masked_payload
with LocalPrivacyClient() as client:
result = client.request(
"Patient John Doe received 50mg.", provider,
sensitive_terms={"John Doe"},
)
print(result.unmasked_text) # Local display only
```
---
## Features
| Feature | Behavior |
| :--- | :--- |
| ๐ English & Korean | Per-word multilingual handling, conservative Korean particle separation and explicit sensitive terms |
| ๐งฉ Code-aware masking | Language-specific lexer modes for identifiers, literals and comments; numbers preserved by default |
| ๐ญ Four surrogate strategies | Bracket, Unicode, delimited pseudoword and random hash representations |
| ๐ Subscription gateway | Automatic request masking, shared prompt/code aliases, local tool-argument restoration and automatic answer display; existing OAuth, no API-key fallback |
| ๐ Local admin dashboard | Token-authenticated log viewer, routing/account metadata, filters and request details; SQLite storage, no prompt/reply/credential logging |
| ๐ Local agent hooks | Claude Code and Codex tool-text masking and local execution-argument restoration; Claude Code also supports display-only restoration |
| ๐ Session management | Stable per-session mappings, operation locks, idle expiry and opt-in encrypted snapshots |
| ๐ ๏ธ CLI & Python API | Local masking/restoration, hook diagnostics, statistics and a buffered command wrapper |
### Masking policies
| Mode | Behavior |
| --- | --- |
| `content_words` | Mask content words and detected sensitive spans; keep functional grammar. |
| `entities_only` | Mask recognized PII, URLs, secrets, code spans, numbers and capitalized names. Korean and other case-free/non-ASCII words are masked conservatively, including ordinary nouns. |
| `aggressive` | Keep a small structural subset of articles/prepositions/conjunctions; mask auxiliaries, adverbs, pronouns and other words. |
| `code_aware` | Mask identifiers, literals and comments using the selected lexer; preserve numbers unless explicitly enabled. |
English, Korean and mixed input are handled per word. Unicode names remain atomic. Korean
particle splitting uses known stems and conservative rules; unknown ambiguous words stay whole.
It is not a full morphological analyzer or universal person-name detector. Supply `sensitive_terms`
for domain names, lowercase names, ambiguous names, and custom secrets. `custom_preserve` / CLI
`--preserve` deliberately exempts selected words; recognized sensitive spans still take precedence.
Unknown secret formats and context-dependent names may evade `entities_only`; inspect the payload
or use broader masking. A high masking ratio does not prove absence of sensitive data.
### Surrogate strategies
| Strategy | Representation |
| :--- | :--- |
| `bracket` | `[ENT_1]` |
| `unicode` | `โฆENT_1โง` |
| `pseudoword` | Explicitly delimited pronounceable words, e.g. `โชBrivelโฆโซ` |
| `hash` | Random 96-bit nonce, independent of the original |
Pseudowords use explicit delimiters
to avoid collisions with real words and adjacent tokens. Allocation is stable within a session;
random strategies intentionally differ between sessions. Keep all surrogate spelling intact.
Altered/unknown placeholder candidates are reported in `unmatched_surrogates`; `strict=True`
rejects them. Free-form deletion or invention by a model cannot always be detected or reconstructed.
### Korean restoration
Exact mask/unmask roundtrips keep written particles. For newly generated Korean responses,
opt into `normalize_particles=True` (CLI `--normalize-particles`) to choose ์ด/๊ฐ, ์/๋, ์/๋ฅผ,
๊ณผ/์ and ์ผ๋ก/๋ก from a restored Hangul stem. Pronunciation of foreign names is not guessed.
### Code-aware review representations
Code profiles: `python`, `javascript`, `typescript`, `go`, `rust`, `java`, `c`, `cpp`, `sql`,
`bash`, `csharp`, `powershell`, `php`, `kotlin`, `lua`, `nasm`, `swift`, `ruby`, `dart`,
`r`, `nix`, `gdscript`, `vbnet`, `vba`. Use explicit `--code-language` for ambiguous source;
see the [syntax scope and aliases](docs/LANGUAGES.md). SQL identifier comparison can be
selected with `--sql-dialect standard|postgresql|sqlite`.
Use explicit `language` in `mask_code` (CLI `--code-language`) for ambiguous snippets.
Auto detection is best effort. Keywords are language-specific; builtins and shadowed builtin
names are masked. Unicode identifiers, SQL comments/doubled quotes, backticks, Python f-strings
and escaped newlines, C++/Rust raw strings and numeric suffixes/separators are covered by tests.
Code allocations use ASCII names (`smcp_ID_n` and `smcp_LIT_n` inside literals)
and, when numeric masking is enabled, random native integer constants for numbers
(reserved `732846` prefix plus 12 digits),
independently of the text strategy, so byte literals remain valid too. Python output
is syntax-checked in tests. Output is an opaque review representation: it need not execute,
type-check or preserve f-string/template interpolation behavior. Numeric types/values can
change when numeric masking is enabled. This
small lexer is not a complete parser for every version of every supported language.
---
## System Architecture
```mermaid
flowchart LR
Input[Trusted local input] --> Mask[Masking engine]
Mask -->|Masked payload| Provider[AI provider callback]
Provider -->|Surrogate response| Restore[Local restoration]
Restore --> Display[User display]
Vault[Local session mappings] --- Mask
Vault --- Restore
```
The subscription gateway masks configured inference requests before forwarding them and
restores responses before the CLI consumes them. The callback path masks its provider argument.
Legacy agent hooks use a separate,
partial tool-text path; they do not intercept all outgoing context. See the
[architecture](docs/ARCHITECTURE.md) and [local integration](docs/LOCAL_INTEGRATION.md) documents.
---
## CLI and Sessions
```bash
python -m secure_gateway mask "Alice from Google" --session-id example --session-file example.enc --json-output
python -m secure_gateway unmask "[ENT_1] from [ENT_2]" --session-id example --session-file example.enc --strict
python -m secure_gateway mask "john doe" --mode entities_only --sensitive-term "john doe"
```
Use the same hidden password, or `SECURE_GATEWAY_SESSION_PASSWORD`. CLI files use authenticated
Fernet encryption, random salt, PBKDF2-HMAC-SHA256 with 600,000 iterations, atomic writes and a
lock over the complete CLI read/modify/write operation. A concurrent writer fails clearly.
Marked `.lock` files are persistent and their OS locks are released after a crash; retain
these files. Only legacy empty locks require manual migration after all old writers stop.
Files are opt-in; without `--session-file`, mappings only survive in the current process.
Payload schema v2 stores allocations/counters without regenerating mappings. Legacy v1 files
remain readable; unknown schema versions fail explicitly. Delete session files after use.
Legacy bare pseudoword allocations retain their old ambiguity; start a new session to use
the safe delimited representation for every allocation.
Session strategies are immutable; `mode` records the last-used policy. Creating a duplicate ID
fails without changing its TTL or mappings. TTL must be positive and at most one day. The vault
sweeps idle expired sessions at most one cleanup interval later (default one second), and checks
expiration on access. Clear waits for active operations and invalidates retained references.
Library users must use `session.operation()` for custom mutations; built-in engine operations
use the same lock. `vault.close()` stops cleanup and releases all mapping references. Python
cannot promise byte-level memory zeroization. Standalone `PrivacySession` owners manage lifetime
themselves; use `SessionVault` for scheduled expiry.
Version 0.6 adds UTF-8 stdin and `--input-file` for `mask`/`unmask`, configurable MCP
resource limits, and local Hook snapshot diagnostics:
```bash
secure-gateway mask --input-file private.txt --session-file example.enc --json-output
secure-gateway state status
secure-gateway state gc # read-only preview
secure-gateway state gc --apply # retire expired snapshots; use new conversations
secure-gateway gateway diagnostics
```
MCP defaults are 1,000 sessions, 100,000 mappings per session, and 16 MiB per input.
`serve --max-sessions`, `--mapping-limit`, and `--input-limit` configure them. Gateway
defaults admit 32 inference requests globally and eight per provider; JSON configuration
keys are `max_active_requests` and `max_provider_requests`. See the integration guides
for command limits, safe cleanup, and supported schema constraints.
`masked_ratio` counts masked token occurrences divided by non-whitespace/non-punctuation
occurrences. Deprecated `privacy_entropy_score` is an alias, not information entropy.
`restored_occurrences` counts replacements; `restored_unique_tokens` counts distinct allocations.
`restored_tokens_count` remains a compatibility alias for replacement occurrences.
---
## MCP Tools Reference
`python -m secure_gateway serve` supports local stdio only. HTTP/SSE transports are disabled in the CLI;
directly exposing the Python server over a network requires host-provided authentication and isolation.
| MCP tool | Purpose |
| :--- | :--- |
| `mask_text` | Mask text with a selected policy and session |
| `mask_code` | Create a code review representation using a selected language lexer |
| `create_privacy_session` | Create an isolated mapping session |
| `get_session_stats` | Return counters without original values or mapping entries |
| `clear_privacy_session` | Release the session's mapping references |
Local Python `unmask_text` / `unmask_code` and CLI `unmask` are **not registered as MCP tools**,
so a model cannot enumerate mappings via restoration. Resources: `privacy://policies`, `privacy://status`.
Example desktop configurations are utility setups, not privacy proxies.
### Migration from 0.1
Version 0.2 changes pseudoword delimiters, code identifier/number representations, mapping keys
(`mapping_key(original, token_type, code=...)`), sentence-initial entity classification, keyword
preservation, and the MCP restoration boundary. Direct store readers should use mapping values
or `mapping_key`. Validate explicitly requested strategies; omitted strategies follow the generator.
---
## ํ๊ตญ์ด ์๋ด (Korean Overview)
0.5์์๋ **Claude CodeยทCodex์ ๊ธฐ์กด ๊ตฌ๋
๋ก๊ทธ์ธ์ ์ ์งํ๋ ๋ก์ปฌ ๊ฒ์ดํธ์จ์ด**๋ฅผ ์ ๊ณตํฉ๋๋ค.
`uv tool install .` ์ค์น ํ `secure-gateway gateway install`์ **ํ ๋ฒ** ์คํํ๊ณ ๋ CLI๋ฅผ ์ฌ์์ํ์ธ์.
๊ทธ ๋ค์๋ ํ์์ฒ๋ผ `claude` / `codex`๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค. ์ง์ ์
๋ ฅยทํ
์คํธ ์ฝ๋ยท๋๊ตฌ ๊ฒฐ๊ณผ๋ฅผ ์๋์ผ๋ก
๋ง์คํนํ๊ณ , ๋ต๋ณ๊ณผ ๋ก์ปฌ ์คํ ์ธ์๋ ์๋ ๋ณต์ํฉ๋๋ค. ํจ์๋ช
ยท๋ณ์๋ช
ยท๋ฌธ์์ดยท์ซ์ยท์ฃผ์์ ๋ณด์กดํ๋
์์ธ๋ ์ถ๊ฐํ์ง ์์์ต๋๋ค. ์
๋ ฅ์์ ์ง์นญํ ํจ์์ ์ฝ๋์ ํจ์๋ ๊ฐ์ ์นํํ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
๊ธฐ์กด ๋ก๊ทธ์ธ ํ์ผ์ ์ฝ๊ฑฐ๋ ๋ณต์ฌํ์ง ์์ต๋๋ค. CLI๊ฐ ๊ด๋ฆฌํ๋ OAuth ํค๋์ ๊ฐฑ์ ํ๋ฆ์ ์ฌ์ฉํ๊ณ ,
API ํค ์์ฒญ์ ๊ฑฐ๋ถํ๋ฏ๋ก ์ ๋ฃ API๋ก ์๋ ์ ํํ์ง ์์ต๋๋ค. ์ Hook์ ๋ฑ๋กํ์ง ์์ผ๋ฉฐ,
์ด์์ฒด์ ์ฌ์ฉ์ ๋ก๊ทธ์ธ ์ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์๋ ์์ํ๋๋ก ์ค์ ํฉ๋๋ค. ๊ธฐ์กด Hook ๋ฐฉ์์ ์ ํ ๊ธฐ๋ฅ์ผ๋ก
๋จ๊ฒจ ๋์์ต๋๋ค. [์ค์นยทํด์ ๋ฐ ๋ณดํธ ๋ฒ์](docs/GATEWAY.md)๋ฅผ ํ์ธํ์ธ์.
Claude Code 2.1.287ยทCodex 0.160.0์ ์ค์ CLI๋ฅผ ๋ชจ์ OAuth/๋ก์ปฌ ์๋ฒ๋ก ๊ฒ์ฆํ์ต๋๋ค.
๋ CLI ๋ชจ๋ ๊ธฐ์กด ๊ตฌ๋
๋ก๊ทธ์ธ์ผ๋ก ์์ดยทํ๊ตญ์ด ์ง๋ฌธ โ ์ค์ ํ์ผ ์ฝ๊ธฐ โ ์ฝ๋ ๋ง์คํน ์ ์ก โ ์ ์ ๋ต๋ณยท์๋ ๋ณต์๊น์ง ๊ฒ์ฆํ์ต๋๋ค. Claude์ ์๋ณ ๋ธ๋กยท์นํ๋ช
ํธํ ์ค๋ฅ๋ฅผ ์์ ํ์ผ๋ฉฐ, ๊ธฐ์กด 429๋ ๊ตฌ๋
ํ๋ ์์ง์ด ์๋์์ต๋๋ค. ์ด๋ฏธ์งยท์๊ฒฉ ์ฒจ๋ถยท๋ฏธ์ง์ ์์ฒญ์ ์ฐจ๋จํ๊ณ ,
๊ฒ์ดํธ์จ์ด ๋ฐ์ ๋๊ตฌ ๋คํธ์ํฌยทํ
๋ ๋ฉํธ๋ฆฌ๊น์ง ๋ณดํธํ๋ค๊ณ ์ฃผ์ฅํ์ง ์์ต๋๋ค.
SecureGateway๋ 17๊ฐ ์์ฐ์ด์ ํผํฉ ๋ฌธ์ฅ์ ๋ก์ปฌ์์ ๋ง์คํนํ๊ณ ๋ณต์ํฉ๋๋ค.
`--language`๋ก ์ธ์ด๋ฅผ ๋ช
์ํ ์ ์์ผ๋ฉฐ ์๋ ํ๋ณ์ ๋ฒ์์ ์ธ์ด๋ณ ์ ์ฝ์
[์ธ์ด ์ง์ ํ](docs/LANGUAGES.md)์ ์ ๋ฆฌํ์ต๋๋ค. ํด๋ผ์ฐ๋์ ์์ฒญํ๊ธฐ
**์ ์** `LocalPrivacyClient` ๋๋ ๋ก์ปฌ API/CLI๋ก ์๋ฌธ์ ๊ฐ๋ฆฌ๊ณ , ์๋ต์ ๋ก์ปฌ์์๋ง ๋ณต์ํ์ธ์.
๋ชจ๋ธ์ด ํธ์ถํ๋ MCP ๋๊ตฌ์ ์ธ์๋ ์ด๋ฏธ ์ ๊ณต์์๊ฒ ์ ๋ฌ๋์ด ์์ผ๋ฏ๋ก, Claude Desktop/Cursor์
์๋ฒ๋ฅผ ์ถ๊ฐํ๋ ๊ฒ๋ง์ผ๋ก ๊ฐ์ธ์ ๋ณด๊ฐ ๋ณดํธ๋์ง๋ ์์ต๋๋ค. ๋ณต์ํ ์๋ฌธ์ ๋ชจ๋ธ ์ปจํ
์คํธ์ ๋ค์
๋ฃ์ผ๋ฉด ์ ๋ฉ๋๋ค. MCP ๋ณต์ ๋๊ตฌ๋ ์ ๊ฑฐํ์ผ๋ฉฐ, ๊ธฐ๋ณธ CLI ์๋ฒ๋ ๋ก์ปฌ stdio๋ง ์ง์ํฉ๋๋ค.
์์ด ๋๋ฌธ์ ์ด๋ฆ๊ณผ Unicode ์ด๋ฆ์ ํ๋์ ํ ํฐ์ผ๋ก ์ฒ๋ฆฌํฉ๋๋ค. ํ๊ตญ์ด ์ด๋ฆ๊ณผ ์ผ๋ฐ ๋ช
์ฌ๊ฐ
๊ตฌ๋ถ๋์ง ์๋ `entities_only`์์๋ ๋น๊ธฐ๋ฅ์ด๋ฅผ ๋ณด์์ ์ผ๋ก ๊ฐ๋ฆฝ๋๋ค. ์กฐ์ฌ ๋ถ๋ฆฌ๋ ์๋ ค์ง ์ด๊ฐ๊ณผ
๋ณด์์ ์ธ ๊ท์น์ ์ฌ์ฉํ๋ฉฐ, ๋ชจํธํ ๋ฏธ๋ฑ๋ก ๋จ์ด๋ ํต์งธ๋ก ๊ฐ๋ฆฝ๋๋ค. ๋ชจ๋ ๊ณ ์ ๋ช
์ฌยท๋น๋ฐ๊ฐ ๋๋
ํ๊ตญ์ด ํํ์๋ฅผ ์๋ฒฝํ ์ธ์ํ๋ ๋๊ตฌ๋ ์๋๋๋ค. `sensitive_terms` / `--sensitive-term`์ผ๋ก
ํน์ ์ฉ์ด๋ฅผ ์ง์ ํ๊ณ , ์ ์ ์๋ ๋ฏผ๊ฐ์ ๋ณด์๋ ๋ ๋์ ๋ง์คํน ์ ์ฑ
์ ์ฌ์ฉํ์ธ์.
์ ํํ ์๋ณต ๋ณต์์์๋ ์
๋ ฅ ์กฐ์ฌ๋ฅผ ๊ทธ๋๋ก ์ ์งํฉ๋๋ค. ๋ชจ๋ธ์ด ์๋ก ๋ง๋ ๋ฌธ์ฅ์๋
`normalize_particles=True` / `--normalize-particles`๋ฅผ ์ ํํ์ฌ ๋ฐ์นจ์ ๋ง๋ ์กฐ์ฌ๋ฅผ ๋ณด์ ํ ์
์์ต๋๋ค. ์์ด ์ด๋ฆยท์ฝ์ด์ ๋ฐ์์ ์ถ์ธกํ์ง ์์ต๋๋ค. `--strict`๋ ํ์งํ ๋ณํยท๋ฏธ๋ฑ๋ก
ํ๋ ์ด์คํ๋์ ๋ณต์์ ๊ฑฐ๋ถํ์ง๋ง, ๋ชจ๋ธ์ด ์์ ํ ์ญ์ ํ ๋ด์ฉ์ ์ฌ๊ตฌ์ฑํ์ง๋ ๋ชปํฉ๋๋ค.
์ธ์
์ ๋ต์ ์์ฑ ํ ๊ณ ์ ๋๋ฉฐ, ์ค๋ณต ID ์์ฑ์ ์ค๋ฅ์
๋๋ค. ๋ง๋ฃ ์ธ์
์ ์ฃผ๊ธฐ์ ์ผ๋ก ์ ๋ฆฌํ๊ณ ,
์ญ์ ์ ์งํ ์ค ์์
์ ์ ๊ธ์ผ๋ก ์กฐ์จํฉ๋๋ค. ๋ณ๋ CLI ํ๋ก์ธ์ค ๊ฐ ๋ณต์์๋ ๋์ผํ ์ํธํ
`--session-file`์ด ํ์ํฉ๋๋ค. ๋ง์คํน ๋น์จ์ ํต๊ณ์ด๋ฉฐ ๊ธฐ๋ฐ์ฑยท์ต๋ช
์ฑยท๊ท์ ์ค์์ ์ฆ๋ช
์ด ์๋๋๋ค.
---
## Development
```bash
python -m ruff check src tests examples
python -m mypy src
python -m pytest -W error --cov=secure_gateway --cov-report=term-missing --cov-fail-under=85
```
---
## Documentation
- [Subscription Gateway / ๊ตฌ๋
๋ก๊ทธ์ธ ์๋ ์ฐ๋](docs/GATEWAY.md)
- [Host Compatibility and Shared Contract / ํธ์คํธ ํธํ์ฑ](docs/COMPATIBILITY.md)
- [Legacy Local Claude Code & Codex Integration / ๊ธฐ์กด Hook ์๋ด](docs/LOCAL_INTEGRATION.md)
- [System Architecture](docs/ARCHITECTURE.md)
- [Issue Resolution and Review Notes](docs/ISSUE_RESOLUTION.md)
- [Contributing Guidelines](CONTRIBUTING.md)
## License
Licensed under **Apache License 2.0**. See [LICENSE](LICENSE) for details.
### Code numeric literals
Code masking preserves numeric literals by default, including their original spelling,
base, exponent, separators and suffixes. This keeps indexes, loop bounds and comparison
constants useful for code review. Names, strings and comments remain masked. Numeric
values inside strings/comments follow their existing literal masking policy; ordinary
natural-language number masking and provider protocol controls are unchanged.
To hide sensitive code numbers explicitly:
- CLI: `secure-gateway mask --mode code_aware --mask-numbers ...`
- MCP/Python: pass `mask_numbers=True` to `mask_code`, or to `mask_text` with
`mode="code_aware"` (Python engine/client use `MaskMode.CODE_AWARE`).
- Gateway: set `"mask_numbers": true` in the gateway configuration, or start
`gateway run --mask-numbers` / `gateway api-run --mask-numbers`.
`--preserve-numbers` overrides a configured opt-in. Both paths default to preservation.
Existing saved numeric aliases still restore. A literal that collides with an existing
numeric alias is rejected rather than silently restored to another value; start a fresh
session/conversation in that case. Literal numbers in the reserved alias range receive
identity mappings so strict restoration and saved sessions remain unambiguous. Switching
those particular literals to numeric masking also requires a fresh session. Turning on
numeric masking changes values and does not preserve executable behavior.
### Restoration budgets and audit retention
Version 1.1.0 adds configurable UTF-8 restoration input/output budgets (16 MiB each
by default), plus completed-request audit count/age retention and a default dry-run
`gateway audit-gc` command. See [operational limits](docs/GATEWAY.md#operational-limits-and-retention-110)
for configuration, explicit cleanup and SQLite storage semantics.
### Selective plain-text vocabulary (1.6.0)
Use `--mode uncommon_words` to preserve a small offline English/Korean ordinary
vocabulary while masking unusual content; extend it with `--common-word WORD`.
Existing modes remain available. See [plain-text policy and limitations](docs/PLAIN_TEXT.md).
Offline audit metadata export is available through `gateway audit-export`;
see [bounded export commands](docs/GATEWAY.md#offline-metadata-export-160).
Version 1.7.0 fixes Java escaped names, Kotlin inline accessors, Bash comment
boundaries, SQL CTE/default/returning and `key` bindings, Hook token boundaries and
nesting, and symlink installation handling. It also adds logical mapping/snapshot
budgets; see [operational policy](docs/GATEWAY.md#mapping-and-snapshot-budgets-170).
### Logging
Gateway process logging defaults to WARNING and can be set with
`SECURE_GATEWAY_LOG_LEVEL`. Library imports do not configure application log
handlers. Events exclude request content, credentials, paths, exception text,
and tracebacks. CLI output remains user-facing output. See
[error handling](docs/ERROR_HANDLING.md) for the logging and exception contract.
TDQS
Scored across 5 tools
The session lifecycle tools are clearly distinct, but mask_text and mask_code overlap because mask_text explicitly supports a code_aware mode while mask_code is specialized for code. Descriptions help, but an agent may still be unsure which tool to choose for code-like content.
All tool names use consistent snake_case with a verb_noun pattern: mask_text, mask_code, create_privacy_session, clear_privacy_session, and get_session_stats. The convention is predictable and readable.
Five tools is well-scoped for a session-based privacy masking server. Each tool covers a distinct lifecycle or masking operation without obvious filler.
The set covers session creation, clearing, stats, and both text and code masking. Minor gaps remain around session inspection/listing or updating session configuration, but core workflows are supported.