haechi 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +154 -0
  2. package/README.md +102 -0
  3. package/SECURITY.md +31 -0
  4. package/docs/README.md +35 -0
  5. package/docs/current/api-stability.ko.md +48 -0
  6. package/docs/current/api-stability.md +48 -0
  7. package/docs/current/expert-gap-review-ai-llm-mcp-encryption.ko.md +107 -0
  8. package/docs/current/expert-gap-review-ai-llm-mcp-encryption.md +107 -0
  9. package/docs/current/global-privacy-compliance-review.ko.md +110 -0
  10. package/docs/current/global-privacy-compliance-review.md +110 -0
  11. package/docs/current/initial-plan-ai-llm-mcp-encryption.ko.md +214 -0
  12. package/docs/current/initial-plan-ai-llm-mcp-encryption.md +214 -0
  13. package/docs/current/mvp-0.1-implementation-scope.ko.md +79 -0
  14. package/docs/current/mvp-0.1-implementation-scope.md +79 -0
  15. package/docs/current/open-source-modular-architecture.ko.md +387 -0
  16. package/docs/current/open-source-modular-architecture.md +387 -0
  17. package/docs/current/prd-ai-llm-mcp-encryption.ko.md +260 -0
  18. package/docs/current/prd-ai-llm-mcp-encryption.md +262 -0
  19. package/docs/current/privacy-filtering-policy-draft.ko.md +307 -0
  20. package/docs/current/privacy-filtering-policy-draft.md +307 -0
  21. package/docs/current/release-0.2-implementation-scope.ko.md +46 -0
  22. package/docs/current/release-0.2-implementation-scope.md +46 -0
  23. package/docs/current/release-0.3-implementation-scope.ko.md +86 -0
  24. package/docs/current/release-0.3-implementation-scope.md +86 -0
  25. package/docs/current/release-0.3.2-hardening-scope.ko.md +64 -0
  26. package/docs/current/release-0.3.2-hardening-scope.md +64 -0
  27. package/docs/current/release-0.4-implementation-scope.ko.md +121 -0
  28. package/docs/current/release-0.4-implementation-scope.md +121 -0
  29. package/docs/current/release-process.ko.md +48 -0
  30. package/docs/current/release-process.md +48 -0
  31. package/docs/current/risk-register-release-gate.ko.md +154 -0
  32. package/docs/current/risk-register-release-gate.md +154 -0
  33. package/docs/current/shared-responsibility.ko.md +38 -0
  34. package/docs/current/shared-responsibility.md +38 -0
  35. package/docs/current/threat-model.ko.md +68 -0
  36. package/docs/current/threat-model.md +68 -0
  37. package/examples/llm-prompt-filtering/input.json +13 -0
  38. package/examples/plugins/custom-filter.plugin.json +29 -0
  39. package/haechi.config.example.json +70 -0
  40. package/package.json +74 -0
  41. package/packages/audit/index.mjs +262 -0
  42. package/packages/cli/bin/haechi.mjs +341 -0
  43. package/packages/cli/runtime.mjs +287 -0
  44. package/packages/core/index.mjs +309 -0
  45. package/packages/crypto/index.mjs +142 -0
  46. package/packages/filter/index.mjs +189 -0
  47. package/packages/mcp-stdio/index.mjs +105 -0
  48. package/packages/plugin/index.mjs +83 -0
  49. package/packages/policy/index.mjs +165 -0
  50. package/packages/policy-bundle/index.mjs +91 -0
  51. package/packages/privacy-profiles/index.mjs +92 -0
  52. package/packages/protocol-adapters/index.mjs +111 -0
  53. package/packages/proxy/index.mjs +534 -0
  54. package/packages/token-vault/index.mjs +262 -0
@@ -0,0 +1,214 @@
1
+ # Initial Plan: AI/LLM/MCP-Specific Encryption Solution
2
+
3
+ - Status: Draft 0.1
4
+ - Date: 2026-06-08
5
+ - Product: Haechi
6
+
7
+ ## 1. Strategic Direction
8
+
9
+ An encryption solution purpose-built for AI, LLM, and MCP occupies a sharper market position than generic transport encryption. Most general-purpose API encryption products stop at HTTP payload protection, but AI systems introduce new categories of sensitive data: prompts, contexts, tool calls, resources, retrieval snippets, artifacts, and streaming events.
10
+
11
+ MCP and A2A in particular blur security boundaries as the agent and tool ecosystem expands. Haechi can step into that boundary and become the product that turns "what information can be revealed in plaintext to which agent, tool, model, or provider" into an enforceable policy.
12
+
13
+ The initial direction is an open-source / self-hosted security project, not a SaaS offering. The primary goal is therefore not a sellable control plane, but rather a clearly designed core interface, a replaceable reference engine, conformance tests, and published real-world MCP/LLM usage examples.
14
+
15
+ ## 2. Core Hypotheses
16
+
17
+ | ID | Hypothesis | Validation Method |
18
+ |---|---|---|
19
+ | HYP-001 | Enterprises want to reduce plaintext prompt/tool output in LLM gateway logs. | AI gateway PoC |
20
+ | HYP-002 | MCP server developers want a common module for safely exposing tool input/output and resource content. | MCP server sample |
21
+ | HYP-003 | Agent-to-agent systems require per-task/context/artifact decryption authorization. | A2A adapter PoC |
22
+ | HYP-004 | Separating "information the model must see" from "information the system only stores or forwards" increases the value of an encryption product. | Selective reveal demo |
23
+ | HYP-005 | Security teams and OSS adopters want to control KMS/HSM, audit, policy, and redaction outside the agent framework. | OSS adopter / security reviewer interview |
24
+ | HYP-006 | Enterprises treat PII filtering as a fundamental control on par with encryption when adopting LLM/MCP. | Korean PII filtering PoC |
25
+ | HYP-007 | Global customers require per-region privacy profiles and control over data residency / model provider region. | Regional profile PoC |
26
+ | HYP-008 | Customers require custom filtering that lets them register internal identifiers and confidential terms. | Custom rule DSL PoC |
27
+ | HYP-009 | OSS adopters prefer a small, composable core where crypto, policy, filtering, and audit implementations are swappable over a fully integrated SaaS. | Plugin API PoC + conformance tests |
28
+ | HYP-010 | Even a security tool will not spread if adoption is painful. A 5-minute local demo, 30-minute MCP/LLM PoC, and 1-day custom filter PoC must all be achievable. | Quickstart usability test |
29
+
30
+ ## 3. Priority Use Cases
31
+
32
+ ### 3.1 MCP Tool-Call Protection
33
+
34
+ - The MCP client creates a tool call.
35
+ - The Haechi policy evaluates tool name, arguments schema, tenant, user, and agent ID.
36
+ - Sensitive arguments are protected via tokenization or envelope encryption.
37
+ - The MCP server decrypts only in an authorized context.
38
+ - Tool results are returned to the agent after default redaction.
39
+
40
+ ### 3.2 MCP Resource Protection
41
+
42
+ - Resource URIs and content classifications are mapped to policy.
43
+ - Resource content is encrypted with a tenant/resource scope key.
44
+ - The LLM receives a redacted summary or reference token instead of the original content.
45
+ - The audit log retains only the resource URI hash, policy ID, key ID, and decision ID.
46
+
47
+ ### 3.3 LLM Gateway Prompt Protection
48
+
49
+ - System, developer, user, and tool messages are extracted from the HTTP request.
50
+ - PII, secrets, credentials, source code, and customer data are detected.
51
+ - A decision of reveal, redact, tokenize, or block is made before forwarding to the provider.
52
+ - The plaintext exposure scope per provider and the audit events are recorded.
53
+
54
+ ### 3.4 PII Filtering
55
+
56
+ - Filtering targets include prompts, MCP tool arguments, resource content, RAG snippets, and generated artifacts.
57
+ - Structured identifiers such as Korean national ID numbers, alien registration numbers, and card numbers are detected first using deterministic rules and checksums.
58
+ - Email addresses, phone numbers, postal addresses, account numbers, API keys, access tokens, and secrets are detected using rules and a pattern library.
59
+ - Names, organizations, medical/health information, biometric data, and sensitive inferred information are detected using dictionary lookups, NER, and pluggable classifiers.
60
+ - Detection results are handled according to policy: mask, redact, tokenize, encrypt, block, or human review.
61
+ - Filtering audit logs retain only entity type, rule ID, confidence, action, and decision ID — never the original text.
62
+
63
+ ### 3.5 A2A Task/Artifact Protection
64
+
65
+ - AgentCard discovery results are verified.
66
+ - Task ID, context ID, source agent, and target agent are included in AAD.
67
+ - Artifacts are encrypted with a task-scoped key.
68
+ - Decryption attempts on an artifact from a different task, context, or agent are rejected.
69
+
70
+ ### 3.6 gRPC Streaming Protection
71
+
72
+ - Service, method, and message type are used as policy context.
73
+ - Stream/session keys and chunk nonces are kept separate.
74
+ - Cancellation, retry, redelivery, and partial delivery are recorded as audit events.
75
+ - Metadata leakage is checked separately.
76
+
77
+ ## 4. Architecture Draft
78
+
79
+ ```text
80
+ AI App / Agent Runtime / MCP Host
81
+ |
82
+ v
83
+ Haechi SDK / CLI / Local Proxy / Sidecar
84
+ |
85
+ +-- Core Pipeline
86
+ | +-- normalize protocol message
87
+ | +-- classify/filter
88
+ | +-- decide policy
89
+ | +-- encrypt/tokenize/redact
90
+ | +-- emit safe audit
91
+ |
92
+ +-- Pluggable Providers
93
+ | +-- CryptoProvider
94
+ | +-- KeyProvider
95
+ | +-- PolicyEngine
96
+ | +-- FilterEngine
97
+ | +-- TokenVault
98
+ | +-- AuditSink
99
+ |
100
+ +-- Reference Engines
101
+ | +-- JSON/YAML policy
102
+ | +-- local key provider
103
+ | +-- envelope crypto
104
+ | +-- Korean/global PII filters
105
+ | +-- JSONL audit
106
+ |
107
+ +-- MCP Adapter
108
+ +-- LLM HTTP Adapter
109
+ +-- gRPC Adapter
110
+ +-- A2A Adapter
111
+ |
112
+ v
113
+ MCP Server / LLM Provider / Remote Agent / Tool API
114
+ ```
115
+
116
+ ## 5. Design Principles
117
+
118
+ - **Protocol-aware**: Understands MCP methods, A2A tasks, gRPC methods, and LLM message roles — not just raw byte streams.
119
+ - **Context-bound**: Ciphertext is bound to tenant, user, agent, model, task, context, tool, and resource.
120
+ - **Selective reveal**: Only the minimum information the model needs is exposed in plaintext.
121
+ - **Observability-safe**: Traces and replays contain no sensitive data by default.
122
+ - **Provider-neutral**: Not locked into any specific LLM vendor.
123
+ - **Fail-closed**: Payloads with a sensitive classification are blocked if policy evaluation fails.
124
+ - **OSS-first**: Operates as a library, CLI, local proxy, or self-hosted sidecar — no hosted SaaS required.
125
+ - **Pluggable by default**: The interface and test contract for crypto, key, policy, filtering, and audit matter more than the default implementation.
126
+ - **Reference implementation is replaceable**: The default implementation is a baseline for learning and PoC; it must be replaceable to fit any user environment.
127
+ - **Test fixtures as API**: Plugin authors must be able to verify compatibility using fixtures and conformance tests.
128
+ - **Easy adoption**: Attachable to existing applications with minimal change cost via proxy, middleware, SDK wrapper, sidecar, or preset policy.
129
+ - **Progressive hardening**: Start with dry-run / report-only to review detection results, then enforce redact / tokenize / encrypt / block incrementally.
130
+
131
+ ## 6. Initial Technology Stack Proposal
132
+
133
+ | Area | Proposal |
134
+ |---|---|
135
+ | SDK | TypeScript/Node, Python |
136
+ | Policy | JSON/YAML + JSON Schema |
137
+ | Crypto format | JWE JSON Serialization or compact envelope |
138
+ | KMS | Vault or AWS KMS |
139
+ | MCP | Streamable HTTP proxy, stdio wrapper |
140
+ | LLM adapter | OpenAI-compatible HTTP schema first |
141
+ | Redaction | Deterministic detector + pluggable classifier |
142
+ | Privacy filtering | Korean PII rules + checksum validators + custom entity rules |
143
+ | Audit | JSON Lines + optional hash chain |
144
+ | Tests | Golden fixtures, tamper/replay/cross-context negative tests |
145
+ | Plugin contract | TypeScript interface + JSON Schema manifest + conformance test |
146
+ | Distribution | GitHub repository, package examples, local CLI, SECURITY.md |
147
+ | Developer UX | `haechi init`, preset policy, dry-run/report-only, copy-paste middleware |
148
+
149
+ ## 7. MVP Milestones
150
+
151
+ | Phase | Deliverable | Completion Criteria |
152
+ |---|---|---|
153
+ | M0 | Developer quickstart | `haechi init`, local key, sample policy, dry-run, and MCP/LLM demo run in under 5 minutes |
154
+ | M1 | MCP proxy skeleton | initialize/tools/call/resource read flow observable |
155
+ | M2 | Policy engine | Per-method/tool/resource allow/block/redact/encrypt decisions |
156
+ | M3 | PII filtering | Korean PII fixtures and secret fixtures detected and handled |
157
+ | M4 | Global privacy profiles | EU-GDPR, US-CCPA-CPRA, US-HIPAA/PCI fixtures and region-deny |
158
+ | M5 | Custom filter DSL | regex/dictionary/path-scope/action override with fixture tests |
159
+ | M6 | Envelope crypto | Context-bound encrypt/decrypt with tamper tests |
160
+ | M7 | KMS adapter | Local provider + one of Vault/AWS KMS |
161
+ | M8 | LLM HTTP adapter | Chat/completion message redaction/encryption policy |
162
+ | M9 | Audit | Verified no plaintext exposure of prompt/tool/resource/PII |
163
+ | M10 | Security negative tests | Replay, wrong context, wrong agent, wrong tool, log leakage |
164
+ | M11 | Crypto envelope hardening | Canonical AAD, nonce/replay cache, key lifecycle, signed policy |
165
+ | M12 | Protocol security contracts | Per-adapter auth/lifecycle/metadata scrub contracts for MCP/A2A/gRPC/LLM |
166
+ | M13 | OSS modular packages | `core`, `crypto`, `policy`, `filter`, `mcp`, `llm`, `audit`, `examples` package boundaries |
167
+ | M14 | Plugin examples | Custom `PolicyEngine`, `FilterEngine`, and `AuditSink` examples with conformance tests |
168
+ | M15 | Build-blocking QA gate | Plaintext leak, policy conflict, KMS fault, region-deny, DSL fuzzing, and plugin capability violation all fail CI |
169
+
170
+ ## 8. Top Risks
171
+
172
+ | Risk | Description | Mitigation |
173
+ |---|---|---|
174
+ | Models cannot process ciphertext | Semantic information the LLM must act on ultimately requires reveal. | Selective reveal, tokenization, TEE roadmap |
175
+ | MCP/A2A spec churn | The protocols are still evolving rapidly. | Adapter isolation, spec version field |
176
+ | Tool-call log leakage | Agent frameworks may write separate logs. | Framework-specific log hook, redaction test |
177
+ | Confusion with prompt injection | Encryption does not replace prompt injection defense. | Separate prompt security gate |
178
+ | Difficulty protecting embeddings | Encrypting embeddings breaks similarity search. | Prioritize source text protection; separate embedding policy |
179
+ | PII filter false positives/negatives | False positives degrade work quality; false negatives cause PII leakage. | Confidence threshold, human review, fixture tests |
180
+ | PII exposure within the filter itself | Using an external classifier may re-expose PII during filtering. | Local-first detector, classifier privacy policy |
181
+ | Global regulatory divergence | GDPR, CCPA, HIPAA, APPI, PDPA, and LGPD differ in definitions, rights, and transfer conditions. | Regional profile abstraction |
182
+ | Cross-border transfer violations | External LLM provider regions may cause EU/UK/BR transfer restriction violations. | Region-aware provider allowlist |
183
+ | Custom rule malfunction | Incorrect regex or allowlist can cause missed blocks or operational outages. | Validate/test/approve/rollback lifecycle |
184
+ | Custom dictionary leakage | A customer's dictionary may itself be a trade secret. | Dictionary encryption, access audit |
185
+ | Adoption difficulty | If installation and configuration are painful, OSS adoption and real-world use both fail. | 5-minute quickstart, dry-run, preset, minimal config, copy-paste examples |
186
+ | AAD/nonce/replay vulnerabilities | Context-bound encryption can be bypassed without canonicalization and a replay cache. | Crypto envelope spec, stream sequencing tests |
187
+ | Policy distribution tampering | Stale policy, client-supplied source labels, or unsigned rule packages can bypass hard-blocks. | Signed policy bundle, fail-closed validation |
188
+ | Observability leakage | Plaintext prompt/tool output may appear in trace baggage, metric labels, exceptions, or crash dumps. | Telemetry sentinel tests |
189
+ | Over-abstraction | Too many interfaces too early delays a working demo. | Implement core pipeline, MCP proxy, and filter/crypto reference first |
190
+ | Plugin safety | A user-written plugin could send plaintext externally or bypass audit. | Capability manifest, fail-closed loading, conformance/negative tests |
191
+ | OSS maintenance burden | More documentation and examples make security updates and compatibility management harder. | Narrow MVP, semantic versioning, compatibility matrix |
192
+ | Compliance misrepresentation | OSS documentation may be mistaken for regulatory compliance assurance. | Non-compliance disclaimer in README and SECURITY.md |
193
+
194
+ ## 9. Next Documentation Work
195
+
196
+ - AI threat model
197
+ - MCP adapter SRS
198
+ - LLM gateway policy schema
199
+ - A2A task/artifact encryption design
200
+ - Redaction/tokenization policy spec
201
+ - Privacy filtering policy spec
202
+ - Custom filtering DSL spec
203
+ - Global privacy compliance matrix
204
+ - Crypto envelope spec
205
+ - Audit event schema
206
+ - Expert gap review backlog
207
+ - OSS modular architecture
208
+ - Easy adoption guide and quickstart
209
+ - Plugin API and conformance test spec
210
+ - Protocol security contract spec
211
+ - Self-hosted usage and shared responsibility note
212
+ - Optional enterprise procurement evidence pack
213
+ - Security test spec and red-team corpus
214
+ - RAG/vector and agent memory protection design
@@ -0,0 +1,79 @@
1
+ # MVP 0.1 구현 범위
2
+
3
+ - 문서 상태: Draft 0.1
4
+ - 작성일: 2026-06-09
5
+ - 관련 제품: Haechi
6
+
7
+ ## 1. 결론
8
+
9
+ MVP 0.1은 넓은 protocol coverage보다 "쉽게 붙이고 바로 확인할 수 있는 로컬 보안 레이어"를 완성하는 데 집중한다.
10
+
11
+ 0.1의 성공 기준은 다음이다.
12
+
13
+ 1. 사용자가 `haechi init`으로 local key, sample policy, audit path를 생성한다.
14
+ 2. 사용자가 `haechi protect`로 OpenAI-compatible JSON payload를 보호해 본다.
15
+ 3. 사용자가 `haechi proxy`로 기존 LLM HTTP 호출을 local proxy에 붙여 본다.
16
+ 4. 사용자가 `haechi report`로 평문 없는 audit summary를 확인한다.
17
+ 5. 테스트가 개인정보/secret 탐지, redaction, block, encryption, audit plaintext leak 방지를 검증한다.
18
+
19
+ ## 2. 0.1 포함 범위
20
+
21
+ | 영역 | 포함 |
22
+ |---|---|
23
+ | Runtime | Node.js ESM, no external runtime dependency |
24
+ | Config | JSON config, preset policy |
25
+ | CLI | `init`, `protect`, `report`, `proxy` |
26
+ | Core | security context, filter -> policy -> transform -> audit pipeline |
27
+ | Filter | email, phone, Korean RRN-like id, card-like number, API key/secret, custom regex |
28
+ | Policy | dry-run, redact, mask, encrypt, block |
29
+ | Crypto | local AES-256-GCM envelope encryption using Node `crypto` |
30
+ | Key | local software key file |
31
+ | Audit | JSON Lines audit event without raw payload |
32
+ | Adapter | OpenAI-compatible request body traversal |
33
+ | Proxy | local HTTP JSON proxy with upstream forwarding |
34
+ | Tests | Node built-in test runner |
35
+
36
+ ## 3. 0.1 제외 범위
37
+
38
+ | 제외 | 이유 | 다음 단계 |
39
+ |---|---|---|
40
+ | Python SDK | 0.1 quickstart에는 Node CLI만으로 충분 | 0.2 |
41
+ | Vault/AWS KMS | 외부 설정이 필요해 5분 demo를 방해 | 0.2 adapter |
42
+ | MCP stdio wrapper | process/env handling이 별도 보안 검토 필요 | 0.2 |
43
+ | Full MCP protocol proxy | 0.1은 HTTP JSON payload 보호 검증 우선 | 0.2 |
44
+ | A2A/gRPC production adapter | protocol contract 선행 필요 | 0.3 |
45
+ | TokenVault | reveal/purge governance가 별도 설계 필요 | 0.2 |
46
+ | Signed policy bundle | 0.1은 local config validation 우선 | 0.2 |
47
+ | SBOM/signing | release 단계 작업 | 0.2 |
48
+
49
+ ## 4. Quickstart 흐름
50
+
51
+ ```bash
52
+ npm test
53
+ node packages/cli/bin/haechi.mjs init --force
54
+ node packages/cli/bin/haechi.mjs protect examples/llm-prompt-filtering/input.json --config haechi.config.json
55
+ node packages/cli/bin/haechi.mjs report --audit .haechi/audit.jsonl
56
+ node packages/cli/bin/haechi.mjs proxy --config haechi.config.json
57
+ ```
58
+
59
+ ## 5. 구현 원칙
60
+
61
+ - 외부 dependency 없이 시작한다.
62
+ - JSON 설정을 사용한다. YAML은 0.2 이후로 미룬다.
63
+ - 암호 primitive는 직접 만들지 않고 Node `crypto`의 AES-256-GCM을 사용한다.
64
+ - default mode는 `dry-run`이다.
65
+ - enforcement mode에서도 audit에는 원문을 남기지 않는다.
66
+ - 적용 실패 시 원문 유출보다 요청 차단을 우선한다.
67
+ - provider boundary는 코드 구조로 남기되, 0.1에서는 과한 plugin loader를 만들지 않는다.
68
+
69
+ ## 6. 0.1 완료 기준
70
+
71
+ | 기준 | 완료 조건 |
72
+ |---|---|
73
+ | CLI | `init`, `protect`, `report`, `proxy`가 동작 |
74
+ | 보안 | audit JSONL에 sentinel 원문이 남지 않음 |
75
+ | 개인정보 | email/phone/secret/card-like/RRN-like fixture 탐지 |
76
+ | 정책 | dry-run/redact/mask/encrypt/block fixture 통과 |
77
+ | 암호 | AAD 변조 시 복호화 실패 |
78
+ | 적용성 | example payload를 CLI로 보호하고 audit report 확인 |
79
+ | 검증 | `npm test` 통과 |
@@ -0,0 +1,79 @@
1
+ # MVP 0.1 Implementation Scope
2
+
3
+ - Status: Draft 0.1
4
+ - Date: 2026-06-09
5
+ - Target version: Haechi
6
+
7
+ ## 1. Summary
8
+
9
+ MVP 0.1 focuses on delivering a local security layer that is easy to attach and immediately verifiable, rather than broad protocol coverage.
10
+
11
+ The success criteria for 0.1 are:
12
+
13
+ 1. The user runs `haechi init` to generate a local key, sample policy, and audit path.
14
+ 2. The user runs `haechi protect` to protect an OpenAI-compatible JSON payload.
15
+ 3. The user runs `haechi proxy` to route an existing LLM HTTP call through a local proxy.
16
+ 4. The user runs `haechi report` to view an audit summary containing no plaintext.
17
+ 5. Tests verify PII/secret detection, redaction, blocking, encryption, and prevention of plaintext leakage in the audit log.
18
+
19
+ ## 2. 0.1 Included Scope
20
+
21
+ | Area | Included |
22
+ |---|---|
23
+ | Runtime | Node.js ESM, no external runtime dependency |
24
+ | Config | JSON config, preset policy |
25
+ | CLI | `init`, `protect`, `report`, `proxy` |
26
+ | Core | security context, filter -> policy -> transform -> audit pipeline |
27
+ | Filter | email, phone, Korean RRN-like id, card-like number, API key/secret, custom regex |
28
+ | Policy | dry-run, redact, mask, encrypt, block |
29
+ | Crypto | local AES-256-GCM envelope encryption using Node `crypto` |
30
+ | Key | local software key file |
31
+ | Audit | JSON Lines audit event without raw payload |
32
+ | Adapter | OpenAI-compatible request body traversal |
33
+ | Proxy | local HTTP JSON proxy with upstream forwarding |
34
+ | Tests | Node built-in test runner |
35
+
36
+ ## 3. 0.1 Excluded Scope
37
+
38
+ | Excluded | Reason | Next Step |
39
+ |---|---|---|
40
+ | Python SDK | Node CLI alone is sufficient for the 0.1 quickstart | 0.2 |
41
+ | Vault/AWS KMS | Requires external setup, which breaks the 5-minute demo | 0.2 adapter |
42
+ | MCP stdio wrapper | process/env handling requires a separate security review | 0.2 |
43
+ | Full MCP protocol proxy | 0.1 prioritizes validating HTTP JSON payload protection | 0.2 |
44
+ | A2A/gRPC production adapter | Requires prior protocol contract definition | 0.3 |
45
+ | TokenVault | reveal/purge governance requires separate design | 0.2 |
46
+ | Signed policy bundle | 0.1 prioritizes local config validation | 0.2 |
47
+ | SBOM/signing | Release-phase work | 0.2 |
48
+
49
+ ## 4. Quickstart Flow
50
+
51
+ ```bash
52
+ npm test
53
+ node packages/cli/bin/haechi.mjs init --force
54
+ node packages/cli/bin/haechi.mjs protect examples/llm-prompt-filtering/input.json --config haechi.config.json
55
+ node packages/cli/bin/haechi.mjs report --audit .haechi/audit.jsonl
56
+ node packages/cli/bin/haechi.mjs proxy --config haechi.config.json
57
+ ```
58
+
59
+ ## 5. Implementation Principles
60
+
61
+ - Start with no external dependencies.
62
+ - Use JSON configuration. Defer YAML support to 0.2 or later.
63
+ - Do not implement crypto primitives directly; use AES-256-GCM from Node `crypto`.
64
+ - Default mode is `dry-run`.
65
+ - Even in enforcement mode, do not write raw input to the audit log.
66
+ - On processing failure, prefer blocking the request over leaking plaintext.
67
+ - Preserve provider boundaries in the code structure, but do not build an elaborate plugin loader in 0.1.
68
+
69
+ ## 6. 0.1 Completion Criteria
70
+
71
+ | Criterion | Done When |
72
+ |---|---|
73
+ | CLI | `init`, `protect`, `report`, and `proxy` are functional |
74
+ | Security | No sentinel plaintext remains in the audit JSONL |
75
+ | PII | email/phone/secret/card-like/RRN-like fixtures are detected |
76
+ | Policy | dry-run/redact/mask/encrypt/block fixtures pass |
77
+ | Crypto | Decryption fails when AAD is tampered with |
78
+ | Applicability | Example payload can be protected via CLI and verified in the audit report |
79
+ | Verification | `npm test` passes |