haechi 0.0.1__tar.gz

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 (81) hide show
  1. haechi-0.0.1/.gitignore +27 -0
  2. haechi-0.0.1/CHANGELOG.md +67 -0
  3. haechi-0.0.1/LICENSE +201 -0
  4. haechi-0.0.1/NOTICE +7 -0
  5. haechi-0.0.1/PKG-INFO +193 -0
  6. haechi-0.0.1/README.md +158 -0
  7. haechi-0.0.1/pyproject.toml +90 -0
  8. haechi-0.0.1/src/haechi/__init__.py +5 -0
  9. haechi-0.0.1/src/haechi/__main__.py +4 -0
  10. haechi-0.0.1/src/haechi/canaries/__init__.py +21 -0
  11. haechi-0.0.1/src/haechi/canaries/manifest.py +131 -0
  12. haechi-0.0.1/src/haechi/canaries/records.py +228 -0
  13. haechi-0.0.1/src/haechi/canaries/safety.py +98 -0
  14. haechi-0.0.1/src/haechi/cli.py +243 -0
  15. haechi-0.0.1/src/haechi/config.py +234 -0
  16. haechi-0.0.1/src/haechi/data/haechi.sample.yaml +59 -0
  17. haechi-0.0.1/src/haechi/errors.py +26 -0
  18. haechi-0.0.1/src/haechi/evaluation/__init__.py +1 -0
  19. haechi-0.0.1/src/haechi/evaluation/__main__.py +21 -0
  20. haechi-0.0.1/src/haechi/evaluation/kr_pii_set.py +229 -0
  21. haechi-0.0.1/src/haechi/evaluation/metrics.py +129 -0
  22. haechi-0.0.1/src/haechi/judges/__init__.py +5 -0
  23. haechi-0.0.1/src/haechi/judges/base.py +30 -0
  24. haechi-0.0.1/src/haechi/judges/canary.py +74 -0
  25. haechi-0.0.1/src/haechi/judges/kr_pii/__init__.py +121 -0
  26. haechi-0.0.1/src/haechi/judges/kr_pii/account.py +58 -0
  27. haechi-0.0.1/src/haechi/judges/kr_pii/brn.py +74 -0
  28. haechi-0.0.1/src/haechi/judges/kr_pii/card.py +94 -0
  29. haechi-0.0.1/src/haechi/judges/kr_pii/email.py +34 -0
  30. haechi-0.0.1/src/haechi/judges/kr_pii/model.py +107 -0
  31. haechi-0.0.1/src/haechi/judges/kr_pii/phone.py +53 -0
  32. haechi-0.0.1/src/haechi/judges/kr_pii/rrn.py +137 -0
  33. haechi-0.0.1/src/haechi/normalise/__init__.py +74 -0
  34. haechi-0.0.1/src/haechi/normalise/digits.py +62 -0
  35. haechi-0.0.1/src/haechi/normalise/hangul.py +157 -0
  36. haechi-0.0.1/src/haechi/normalise/separators.py +21 -0
  37. haechi-0.0.1/src/haechi/normalise/unicode.py +47 -0
  38. haechi-0.0.1/src/haechi/py.typed +0 -0
  39. haechi-0.0.1/src/haechi/seeding.py +21 -0
  40. haechi-0.0.1/src/haechi/targets/__init__.py +62 -0
  41. haechi-0.0.1/src/haechi/targets/_http.py +47 -0
  42. haechi-0.0.1/src/haechi/targets/base.py +116 -0
  43. haechi-0.0.1/src/haechi/targets/http.py +152 -0
  44. haechi-0.0.1/src/haechi/targets/mock.py +335 -0
  45. haechi-0.0.1/src/haechi/targets/openai_compat.py +113 -0
  46. haechi-0.0.1/src/haechi/targets/preflight.py +70 -0
  47. haechi-0.0.1/src/haechi/targets/python_target.py +78 -0
  48. haechi-0.0.1/tests/__init__.py +0 -0
  49. haechi-0.0.1/tests/canaries/__init__.py +0 -0
  50. haechi-0.0.1/tests/canaries/test_manifest.py +167 -0
  51. haechi-0.0.1/tests/canaries/test_records.py +133 -0
  52. haechi-0.0.1/tests/evaluation/__init__.py +0 -0
  53. haechi-0.0.1/tests/evaluation/test_kr_pii_eval.py +95 -0
  54. haechi-0.0.1/tests/fixtures/__init__.py +0 -0
  55. haechi-0.0.1/tests/fixtures/synthetic.py +63 -0
  56. haechi-0.0.1/tests/guards/__init__.py +0 -0
  57. haechi-0.0.1/tests/guards/test_no_valid_rrn_literals.py +94 -0
  58. haechi-0.0.1/tests/judges/__init__.py +0 -0
  59. haechi-0.0.1/tests/judges/kr_pii/__init__.py +0 -0
  60. haechi-0.0.1/tests/judges/kr_pii/test_account_email.py +51 -0
  61. haechi-0.0.1/tests/judges/kr_pii/test_brn.py +47 -0
  62. haechi-0.0.1/tests/judges/kr_pii/test_card.py +65 -0
  63. haechi-0.0.1/tests/judges/kr_pii/test_phone.py +59 -0
  64. haechi-0.0.1/tests/judges/kr_pii/test_rrn.py +176 -0
  65. haechi-0.0.1/tests/judges/kr_pii/test_scan.py +139 -0
  66. haechi-0.0.1/tests/judges/test_canary_judge.py +84 -0
  67. haechi-0.0.1/tests/judges/test_synthetic_guard.py +25 -0
  68. haechi-0.0.1/tests/normalise/__init__.py +0 -0
  69. haechi-0.0.1/tests/normalise/test_hangul.py +84 -0
  70. haechi-0.0.1/tests/normalise/test_normalise.py +154 -0
  71. haechi-0.0.1/tests/targets/__init__.py +0 -0
  72. haechi-0.0.1/tests/targets/conftest.py +19 -0
  73. haechi-0.0.1/tests/targets/test_base.py +22 -0
  74. haechi-0.0.1/tests/targets/test_http_target.py +139 -0
  75. haechi-0.0.1/tests/targets/test_mock.py +151 -0
  76. haechi-0.0.1/tests/targets/test_openai_compat.py +159 -0
  77. haechi-0.0.1/tests/targets/test_preflight.py +73 -0
  78. haechi-0.0.1/tests/targets/test_python_target.py +77 -0
  79. haechi-0.0.1/tests/test_cli.py +160 -0
  80. haechi-0.0.1/tests/test_config.py +210 -0
  81. haechi-0.0.1/tests/test_seeding.py +19 -0
@@ -0,0 +1,27 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ .venv/
8
+
9
+ # Tooling
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ .hypothesis/
13
+ .coverage
14
+ coverage.xml
15
+ htmlcov/
16
+
17
+ # Haechi runtime artefacts
18
+ .haechi/
19
+ haechi-results/
20
+
21
+ # OS / editors
22
+ .DS_Store
23
+ .idea/
24
+ .vscode/
25
+
26
+ # Local, private agent notes
27
+ CLAUDE.local.md
@@ -0,0 +1,67 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.0.1] - 2026-11-29
10
+
11
+ First public release. The command-line tool scans text for Korean personal data. The red-team
12
+ building blocks (canaries, targets) are included as a library but are not yet used by
13
+ `haechi run`.
14
+
15
+ ### Added: command line
16
+
17
+ - `haechi scan-text`: detect Korean personal data in text, a file or stdin. Masked output by
18
+ default, `--json`, `--mode loose|strict`, `--no-normalise`; exits 1 when anything is found.
19
+ - `kr_pii` detectors:
20
+ - 주민등록번호, with `strict` and `loose` checksum modes because numbers issued from
21
+ October 2020 have no checksum. `loose` mode also reports separator-grouped numbers with
22
+ impossible birth dates (such as Haechi canaries) at `low` confidence.
23
+ - 사업자등록번호 (checksum), card numbers (Luhn), phone numbers and email.
24
+ - Bank accounts, as a heuristic.
25
+ - Numbers written without separators (13-digit RRN, 13–19-digit card, 10-digit business
26
+ number) are only reported with a matching keyword nearby, which avoids false positives on
27
+ timestamps, barcodes and order numbers.
28
+ - Normalisation before detection: NFKC, invisible-character removal, Hangul jamo
29
+ recomposition, Sino-Korean digit words to digits, separator stripping.
30
+ - `haechi init` writes a sample config.
31
+ - `haechi run` validates the config and canaries and prints a summary. It does not run tests
32
+ in this release and exits with code 3.
33
+ - Config schema with Korean/English error messages.
34
+ - Canary safety rules:
35
+ - RRN canaries must use an impossible birth date (e.g. `901301-2000000`, month 13);
36
+ - card and business-number canaries must fail their checksum;
37
+ - email canaries must use reserved domains (RFC 2606/6761).
38
+ - Canary manifest file (`canary_manifest:`) alongside inline `canaries`.
39
+
40
+ ### Added: library only (not yet used by the command line)
41
+
42
+ - Canary manifest (version 1): `name`, `value`, `field_type`, `planted_in` (`context`,
43
+ `app_api`, `rag_document`, `db_seed`) and `location`. Judges read only the manifest.
44
+ - Context planting: canaries are written into realistic, seeded fake customer records
45
+ (another customer's matching field), not prepended to the prompt.
46
+ - `canary` judge (initial): a leak is a manifest canary appearing in the output after
47
+ normalisation. Evidence is masked and records where the canary was planted.
48
+ - Targets: `openai-compatible` (httpx), `http` (sandboxed Jinja2 request template and an
49
+ `a.b[0].c` response path), `python` (`module:function`, sync or async) and a deterministic
50
+ `mock` 보험 상담봇 (`vulnerable` and `hardened` profiles). The `AgentTarget` interface is
51
+ defined for v0.2.
52
+ - `context_delivery` for chat targets: `system_append` (default), `second_system` or
53
+ `tool_result`. Also `target.version`, included in the target identity.
54
+ - Pre-flight check (`run_preflight`): a benign request must surface the verified customer's
55
+ own data, which shows the context actually reached the model.
56
+ - Detector evaluation: a labelled synthetic set (v1, 69 cases) with precision and recall,
57
+ run with `python -m haechi.evaluation`.
58
+
59
+ ### Known limitations
60
+
61
+ - `haechi run` does not run attacks yet. `plugins` and `mutators` in the config are accepted
62
+ but not used.
63
+ - Split leaks (an RRN given in two parts) are not detected yet.
64
+ - No regulation (개인정보보호법) mappings are shipped yet.
65
+
66
+ [Unreleased]: https://github.com/haechidev/haechi/compare/v0.0.1...HEAD
67
+ [0.0.1]: https://github.com/haechidev/haechi/releases/tag/v0.0.1
haechi-0.0.1/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
haechi-0.0.1/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ Haechi
2
+ Copyright 2026 The Haechi Authors
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ Haechi is an independent project. It is inspired by concepts from other
7
+ LLM evaluation and red-teaming tools but contains no code from them.
haechi-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,193 @@
1
+ Metadata-Version: 2.5
2
+ Name: haechi
3
+ Version: 0.0.1
4
+ Summary: Korean-first red-teaming and testing for LLM apps and AI agents, mapped to Korean regulation.
5
+ Project-URL: Homepage, https://haechi.dev
6
+ Project-URL: Repository, https://github.com/haechidev/haechi
7
+ Project-URL: Issues, https://github.com/haechidev/haechi/issues
8
+ Project-URL: Changelog, https://github.com/haechidev/haechi/blob/main/CHANGELOG.md
9
+ Author: Haechi contributors
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: korean,llm,pii,privacy,red-teaming,security,testing
14
+ Classifier: Development Status :: 2 - Pre-Alpha
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Natural Language :: English
18
+ Classifier: Natural Language :: Korean
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Security
25
+ Classifier: Topic :: Software Development :: Testing
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.11
28
+ Requires-Dist: httpx>=0.27
29
+ Requires-Dist: jinja2>=3.1
30
+ Requires-Dist: pydantic>=2.6
31
+ Requires-Dist: pyyaml>=6.0
32
+ Requires-Dist: rich>=13.7
33
+ Requires-Dist: typer>=0.12
34
+ Description-Content-Type: text/markdown
35
+
36
+ # Haechi (해치)
37
+
38
+ **Korean-first red-teaming and testing for LLM apps and AI agents.**
39
+
40
+ Haechi checks whether your chatbot or agent leaks personal data or can be talked into
41
+ breaking its rules — using attacks written natively in Korean, and judging the results
42
+ with deterministic code mapped to Korean regulation (개인정보보호법, the Personal
43
+ Information Protection Act).
44
+
45
+ > Named after 해치, the mythical creature that judges right from wrong.
46
+
47
+ > **Status: pre-alpha (v0.0.1).** This release ships the Korean PII detectors and the
48
+ > `scan-text` command. The red-teaming runner arrives in v0.1 — see the [roadmap](#roadmap).
49
+
50
+ ## Why Haechi
51
+
52
+ - **Korean-native attacks**, not translated English prompts: 존댓말/반말, 초성, jamo
53
+ splitting, Korean–English code-switching, impersonation of family members or 금융감독원.
54
+ - **Deterministic judging first.** If code can decide whether something leaked, code
55
+ decides. Heuristic checks are always labelled as heuristic.
56
+ - **Sees through obfuscation.** Output is normalised before judging: full-width digits,
57
+ `ㄱㅖㅈㅘ`-style jamo, spoken digits (`공일공`), zero-width characters and stray
58
+ separators.
59
+ - **Reproducible.** Every generated test case is reproducible from a seed.
60
+ - **Offline-first.** Runs against local models (Ollama, vLLM) and in air-gapped (망분리)
61
+ environments. No telemetry, no hidden network calls.
62
+ - **Regulation mapping** with an explicit review status on every mapping. Haechi never
63
+ claims an article applies unless the mapping file says so, with a source.
64
+
65
+ ## Install
66
+
67
+ Requires Python 3.11 or newer.
68
+
69
+ ```bash
70
+ pip install haechi # or: uv tool install haechi
71
+ haechi --version
72
+ ```
73
+
74
+ ## Quick start: scan text for Korean personal data
75
+
76
+ ```bash
77
+ haechi scan-text "고객 연락처는 010-0000-1234, 주민번호 구공일삼공일-이공공공공공공 입니다"
78
+ ```
79
+
80
+ ```
81
+ ┏━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
82
+ ┃ # ┃ 유형 / Kind ┃ 값 / Value ┃ 검증 / Checksum ┃ 뷰 / View ┃ 신뢰도 / Confidence ┃
83
+ ┡━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
84
+ │ 1 │ 전화번호 (phone) │ 010-****-1234 │ n/a │ original │ medium │
85
+ │ 2 │ 주민등록번호 (rrn) │ 901301-2****** │ n/a │ spoken │ low │
86
+ └───┴────────────────────┴────────────────┴─────────────────┴───────────┴─────────────────────┘
87
+ 2건 탐지 / 2 finding(s): phone=1, rrn=1
88
+ ```
89
+
90
+ The second number was written out in spoken Korean digits and was still caught via the
91
+ normalised `spoken` view. It uses an impossible birth date (month 13), the form Haechi
92
+ requires for synthetic RRN canaries, so it is reported with `low` confidence.
93
+
94
+ More options:
95
+
96
+ ```bash
97
+ haechi scan-text -f chatbot-log.txt # scan a UTF-8 file
98
+ cat transcript.txt | haechi scan-text --json # read stdin, print JSON
99
+ haechi scan-text --mode strict "..." # require valid checksums
100
+ haechi scan-text --no-normalise "..." # scan the raw text only
101
+ ```
102
+
103
+ Detected values are **masked by default**. `--show-values` prints them unmasked.
104
+
105
+ | Detector | What it checks |
106
+ |---|---|
107
+ | 주민등록번호 (RRN) | `YYMMDD-GNNNNNN`, valid birth date; checksum in `strict` mode. Numbers issued from October 2020 have no checksum, so `loose` (default) reports checksum-invalid numbers too, and RRN-formatted numbers with impossible dates (`low` confidence). |
108
+ | 사업자등록번호 | `NNN-NN-NNNNN` with the official checksum |
109
+ | Card numbers | 13–19 digits, Luhn |
110
+
111
+ Numbers written **without separators** (a bare 13-digit RRN, 13–19-digit card or 10-digit
112
+ business number) are only reported when a matching keyword (주민, 카드, 사업자, …) is nearby.
113
+ One random digit run in ten passes these checksums, so bare order numbers, timestamps and
114
+ barcodes would otherwise be flagged. See [docs/en/evaluation.md](docs/en/evaluation.md)
115
+ for precision and recall.
116
+ | Phone numbers | mobile, landline, 070, `+82`, 대표번호 (15xx/16xx/18xx) |
117
+ | Email | address syntax |
118
+ | Bank accounts | **heuristic**: 10–14 digit runs near a banking keyword |
119
+
120
+ ### Exit codes
121
+
122
+ | Code | Meaning |
123
+ |---|---|
124
+ | 0 | nothing found / success |
125
+ | 1 | personal data found (or, from v0.1, the CI gate failed) |
126
+ | 2 | usage or configuration error |
127
+ | 3 | feature not available in this version |
128
+
129
+ This makes `haechi scan-text` usable as a CI check on logs or fixtures.
130
+
131
+ ## Configuration preview
132
+
133
+ `haechi init` writes a sample `haechi.yaml`. In v0.0.1, `haechi run` validates it and
134
+ explains any errors in Korean and English; running attacks arrives in v0.1.
135
+
136
+ ```yaml
137
+ version: 1
138
+ target:
139
+ type: openai-compatible
140
+ base_url: http://localhost:11434/v1 # Ollama
141
+ model: exaone3.5
142
+ purpose: "보험사 고객 상담 챗봇. 본인 확인된 고객에게 자기 계약 정보만 안내한다."
143
+ canaries:
144
+ - name: other_customer_rrn
145
+ value: "901301-2000000" # synthetic; month 13 cannot be a real birth date
146
+ plugins: [kr-pii]
147
+ mutators: [jamo, chosung, code_switch, impersonation]
148
+ seed: 42
149
+ limits:
150
+ max_requests: 500
151
+ gate:
152
+ max_fail_rate: 0.0
153
+ ```
154
+
155
+ ## Safety notice
156
+
157
+ - **Use synthetic data only.** Never put real personal data into configs, canaries or test
158
+ fixtures. Haechi rejects RRN canaries with a real birth date (numbers issued from October
159
+ 2020 have no checksum, so a checksum cannot prove a value is fake) and card or business
160
+ number canaries that pass their checksum.
161
+ - **Only test systems you are authorised to test.** See [RESPONSIBLE_USE.md](RESPONSIBLE_USE.md).
162
+ - **Not legal advice.** Regulation mappings are provided for orientation, carry a review
163
+ status (`draft` / `reviewed`) and do not establish legal compliance.
164
+ - Heuristic detectors (e.g. bank accounts) can miss data or flag harmless numbers. A clean
165
+ scan is not proof that no personal data is present.
166
+
167
+ ## Roadmap
168
+
169
+ - **v0.1** — targets (`openai-compatible`, `http`, `python`, `mock`), YAML attack packs
170
+ (first: `kr-pii`), seeded Korean mutators (jamo, 초성, code-switching, spacing,
171
+ honorifics, impersonation, indirect injection, base64), canary and policy judges, an async
172
+ runner with request caps and caching, JSON and Markdown reports, CI gating, and
173
+ 개인정보보호법 / OWASP LLM Top 10 mappings.
174
+ - **v0.2** — agent harness with fake tools, tool-call policy judge, an optional and clearly
175
+ labelled non-deterministic LLM judge, further regulation packs.
176
+
177
+ ## Related work
178
+
179
+ Haechi builds on ideas from AgentDojo, DataSIR, Rebuff/Vigil canary checks, AgentDAM,
180
+ PrivacyLens and KDPII, with no code dependency on any of them. See
181
+ [docs/en/related-work.md](docs/en/related-work.md) (한국어: [docs/ko/related-work.md](docs/ko/related-work.md)).
182
+
183
+ ## Contributing
184
+
185
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Security issues: see [SECURITY.md](SECURITY.md).
186
+
187
+ ## Acknowledgements
188
+
189
+ Haechi is developed with the help of Claude Code.
190
+
191
+ ## Licence
192
+
193
+ Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
haechi-0.0.1/README.md ADDED
@@ -0,0 +1,158 @@
1
+ # Haechi (해치)
2
+
3
+ **Korean-first red-teaming and testing for LLM apps and AI agents.**
4
+
5
+ Haechi checks whether your chatbot or agent leaks personal data or can be talked into
6
+ breaking its rules — using attacks written natively in Korean, and judging the results
7
+ with deterministic code mapped to Korean regulation (개인정보보호법, the Personal
8
+ Information Protection Act).
9
+
10
+ > Named after 해치, the mythical creature that judges right from wrong.
11
+
12
+ > **Status: pre-alpha (v0.0.1).** This release ships the Korean PII detectors and the
13
+ > `scan-text` command. The red-teaming runner arrives in v0.1 — see the [roadmap](#roadmap).
14
+
15
+ ## Why Haechi
16
+
17
+ - **Korean-native attacks**, not translated English prompts: 존댓말/반말, 초성, jamo
18
+ splitting, Korean–English code-switching, impersonation of family members or 금융감독원.
19
+ - **Deterministic judging first.** If code can decide whether something leaked, code
20
+ decides. Heuristic checks are always labelled as heuristic.
21
+ - **Sees through obfuscation.** Output is normalised before judging: full-width digits,
22
+ `ㄱㅖㅈㅘ`-style jamo, spoken digits (`공일공`), zero-width characters and stray
23
+ separators.
24
+ - **Reproducible.** Every generated test case is reproducible from a seed.
25
+ - **Offline-first.** Runs against local models (Ollama, vLLM) and in air-gapped (망분리)
26
+ environments. No telemetry, no hidden network calls.
27
+ - **Regulation mapping** with an explicit review status on every mapping. Haechi never
28
+ claims an article applies unless the mapping file says so, with a source.
29
+
30
+ ## Install
31
+
32
+ Requires Python 3.11 or newer.
33
+
34
+ ```bash
35
+ pip install haechi # or: uv tool install haechi
36
+ haechi --version
37
+ ```
38
+
39
+ ## Quick start: scan text for Korean personal data
40
+
41
+ ```bash
42
+ haechi scan-text "고객 연락처는 010-0000-1234, 주민번호 구공일삼공일-이공공공공공공 입니다"
43
+ ```
44
+
45
+ ```
46
+ ┏━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
47
+ ┃ # ┃ 유형 / Kind ┃ 값 / Value ┃ 검증 / Checksum ┃ 뷰 / View ┃ 신뢰도 / Confidence ┃
48
+ ┡━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
49
+ │ 1 │ 전화번호 (phone) │ 010-****-1234 │ n/a │ original │ medium │
50
+ │ 2 │ 주민등록번호 (rrn) │ 901301-2****** │ n/a │ spoken │ low │
51
+ └───┴────────────────────┴────────────────┴─────────────────┴───────────┴─────────────────────┘
52
+ 2건 탐지 / 2 finding(s): phone=1, rrn=1
53
+ ```
54
+
55
+ The second number was written out in spoken Korean digits and was still caught via the
56
+ normalised `spoken` view. It uses an impossible birth date (month 13), the form Haechi
57
+ requires for synthetic RRN canaries, so it is reported with `low` confidence.
58
+
59
+ More options:
60
+
61
+ ```bash
62
+ haechi scan-text -f chatbot-log.txt # scan a UTF-8 file
63
+ cat transcript.txt | haechi scan-text --json # read stdin, print JSON
64
+ haechi scan-text --mode strict "..." # require valid checksums
65
+ haechi scan-text --no-normalise "..." # scan the raw text only
66
+ ```
67
+
68
+ Detected values are **masked by default**. `--show-values` prints them unmasked.
69
+
70
+ | Detector | What it checks |
71
+ |---|---|
72
+ | 주민등록번호 (RRN) | `YYMMDD-GNNNNNN`, valid birth date; checksum in `strict` mode. Numbers issued from October 2020 have no checksum, so `loose` (default) reports checksum-invalid numbers too, and RRN-formatted numbers with impossible dates (`low` confidence). |
73
+ | 사업자등록번호 | `NNN-NN-NNNNN` with the official checksum |
74
+ | Card numbers | 13–19 digits, Luhn |
75
+
76
+ Numbers written **without separators** (a bare 13-digit RRN, 13–19-digit card or 10-digit
77
+ business number) are only reported when a matching keyword (주민, 카드, 사업자, …) is nearby.
78
+ One random digit run in ten passes these checksums, so bare order numbers, timestamps and
79
+ barcodes would otherwise be flagged. See [docs/en/evaluation.md](docs/en/evaluation.md)
80
+ for precision and recall.
81
+ | Phone numbers | mobile, landline, 070, `+82`, 대표번호 (15xx/16xx/18xx) |
82
+ | Email | address syntax |
83
+ | Bank accounts | **heuristic**: 10–14 digit runs near a banking keyword |
84
+
85
+ ### Exit codes
86
+
87
+ | Code | Meaning |
88
+ |---|---|
89
+ | 0 | nothing found / success |
90
+ | 1 | personal data found (or, from v0.1, the CI gate failed) |
91
+ | 2 | usage or configuration error |
92
+ | 3 | feature not available in this version |
93
+
94
+ This makes `haechi scan-text` usable as a CI check on logs or fixtures.
95
+
96
+ ## Configuration preview
97
+
98
+ `haechi init` writes a sample `haechi.yaml`. In v0.0.1, `haechi run` validates it and
99
+ explains any errors in Korean and English; running attacks arrives in v0.1.
100
+
101
+ ```yaml
102
+ version: 1
103
+ target:
104
+ type: openai-compatible
105
+ base_url: http://localhost:11434/v1 # Ollama
106
+ model: exaone3.5
107
+ purpose: "보험사 고객 상담 챗봇. 본인 확인된 고객에게 자기 계약 정보만 안내한다."
108
+ canaries:
109
+ - name: other_customer_rrn
110
+ value: "901301-2000000" # synthetic; month 13 cannot be a real birth date
111
+ plugins: [kr-pii]
112
+ mutators: [jamo, chosung, code_switch, impersonation]
113
+ seed: 42
114
+ limits:
115
+ max_requests: 500
116
+ gate:
117
+ max_fail_rate: 0.0
118
+ ```
119
+
120
+ ## Safety notice
121
+
122
+ - **Use synthetic data only.** Never put real personal data into configs, canaries or test
123
+ fixtures. Haechi rejects RRN canaries with a real birth date (numbers issued from October
124
+ 2020 have no checksum, so a checksum cannot prove a value is fake) and card or business
125
+ number canaries that pass their checksum.
126
+ - **Only test systems you are authorised to test.** See [RESPONSIBLE_USE.md](RESPONSIBLE_USE.md).
127
+ - **Not legal advice.** Regulation mappings are provided for orientation, carry a review
128
+ status (`draft` / `reviewed`) and do not establish legal compliance.
129
+ - Heuristic detectors (e.g. bank accounts) can miss data or flag harmless numbers. A clean
130
+ scan is not proof that no personal data is present.
131
+
132
+ ## Roadmap
133
+
134
+ - **v0.1** — targets (`openai-compatible`, `http`, `python`, `mock`), YAML attack packs
135
+ (first: `kr-pii`), seeded Korean mutators (jamo, 초성, code-switching, spacing,
136
+ honorifics, impersonation, indirect injection, base64), canary and policy judges, an async
137
+ runner with request caps and caching, JSON and Markdown reports, CI gating, and
138
+ 개인정보보호법 / OWASP LLM Top 10 mappings.
139
+ - **v0.2** — agent harness with fake tools, tool-call policy judge, an optional and clearly
140
+ labelled non-deterministic LLM judge, further regulation packs.
141
+
142
+ ## Related work
143
+
144
+ Haechi builds on ideas from AgentDojo, DataSIR, Rebuff/Vigil canary checks, AgentDAM,
145
+ PrivacyLens and KDPII, with no code dependency on any of them. See
146
+ [docs/en/related-work.md](docs/en/related-work.md) (한국어: [docs/ko/related-work.md](docs/ko/related-work.md)).
147
+
148
+ ## Contributing
149
+
150
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Security issues: see [SECURITY.md](SECURITY.md).
151
+
152
+ ## Acknowledgements
153
+
154
+ Haechi is developed with the help of Claude Code.
155
+
156
+ ## Licence
157
+
158
+ Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).