arche-core 0.2.0a2__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 (144) hide show
  1. arche_core-0.2.0a2/.gitignore +64 -0
  2. arche_core-0.2.0a2/CHANGELOG.md +66 -0
  3. arche_core-0.2.0a2/LICENSE +190 -0
  4. arche_core-0.2.0a2/PKG-INFO +203 -0
  5. arche_core-0.2.0a2/README.md +123 -0
  6. arche_core-0.2.0a2/pyproject.toml +111 -0
  7. arche_core-0.2.0a2/src/arche/__init__.py +279 -0
  8. arche_core-0.2.0a2/src/arche/_data/README.md +40 -0
  9. arche_core-0.2.0a2/src/arche/_data/__init__.py +3 -0
  10. arche_core-0.2.0a2/src/arche/_data/restcountries-v3.1-snapshot.json +1 -0
  11. arche_core-0.2.0a2/src/arche/_models.py +151 -0
  12. arche_core-0.2.0a2/src/arche/_types/__init__.py +48 -0
  13. arche_core-0.2.0a2/src/arche/_version.py +15 -0
  14. arche_core-0.2.0a2/src/arche/addr/__init__.py +42 -0
  15. arche_core-0.2.0a2/src/arche/addr/_gazetteer/__init__.py +3 -0
  16. arche_core-0.2.0a2/src/arche/addr/_gazetteer/cities.py +582 -0
  17. arche_core-0.2.0a2/src/arche/addr/parse.py +633 -0
  18. arche_core-0.2.0a2/src/arche/audit.py +141 -0
  19. arche_core-0.2.0a2/src/arche/cli.py +474 -0
  20. arche_core-0.2.0a2/src/arche/config.py +110 -0
  21. arche_core-0.2.0a2/src/arche/credentials/__init__.py +67 -0
  22. arche_core-0.2.0a2/src/arche/credentials/sd_jwt.py +458 -0
  23. arche_core-0.2.0a2/src/arche/detect/__init__.py +53 -0
  24. arche_core-0.2.0a2/src/arche/detect/_africa/__init__.py +3 -0
  25. arche_core-0.2.0a2/src/arche/detect/_africa/ids.py +375 -0
  26. arche_core-0.2.0a2/src/arche/detect/_africa/phones.py +764 -0
  27. arche_core-0.2.0a2/src/arche/detect/_base.py +164 -0
  28. arche_core-0.2.0a2/src/arche/detect/_llm/__init__.py +3 -0
  29. arche_core-0.2.0a2/src/arche/detect/_money/__init__.py +3 -0
  30. arche_core-0.2.0a2/src/arche/detect/_money/african.py +493 -0
  31. arche_core-0.2.0a2/src/arche/detect/_names/__init__.py +3 -0
  32. arche_core-0.2.0a2/src/arche/detect/_names/lexicon.py +760 -0
  33. arche_core-0.2.0a2/src/arche/detect/digital_id/__init__.py +245 -0
  34. arche_core-0.2.0a2/src/arche/detect/gh/__init__.py +3 -0
  35. arche_core-0.2.0a2/src/arche/detect/gh/ids.py +127 -0
  36. arche_core-0.2.0a2/src/arche/detect/gh/phones.py +40 -0
  37. arche_core-0.2.0a2/src/arche/detect/gliner/__init__.py +3 -0
  38. arche_core-0.2.0a2/src/arche/detect/ip/__init__.py +229 -0
  39. arche_core-0.2.0a2/src/arche/detect/ke/__init__.py +3 -0
  40. arche_core-0.2.0a2/src/arche/detect/ke/ids.py +114 -0
  41. arche_core-0.2.0a2/src/arche/detect/ke/phones.py +40 -0
  42. arche_core-0.2.0a2/src/arche/detect/locations/__init__.py +137 -0
  43. arche_core-0.2.0a2/src/arche/detect/names/__init__.py +134 -0
  44. arche_core-0.2.0a2/src/arche/detect/ng/__init__.py +3 -0
  45. arche_core-0.2.0a2/src/arche/detect/ng/ids.py +205 -0
  46. arche_core-0.2.0a2/src/arche/detect/ng/phones.py +59 -0
  47. arche_core-0.2.0a2/src/arche/detect/phones.py +87 -0
  48. arche_core-0.2.0a2/src/arche/detect/presidio/__init__.py +3 -0
  49. arche_core-0.2.0a2/src/arche/detect/za/__init__.py +3 -0
  50. arche_core-0.2.0a2/src/arche/detect/za/ids.py +146 -0
  51. arche_core-0.2.0a2/src/arche/detect/za/phones.py +40 -0
  52. arche_core-0.2.0a2/src/arche/doc/__init__.py +49 -0
  53. arche_core-0.2.0a2/src/arche/doc/parse.py +176 -0
  54. arche_core-0.2.0a2/src/arche/ensemble.py +917 -0
  55. arche_core-0.2.0a2/src/arche/extract.py +589 -0
  56. arche_core-0.2.0a2/src/arche/governance.py +345 -0
  57. arche_core-0.2.0a2/src/arche/graph/__init__.py +37 -0
  58. arche_core-0.2.0a2/src/arche/graph/audit.py +563 -0
  59. arche_core-0.2.0a2/src/arche/graph/networkx_view.py +226 -0
  60. arche_core-0.2.0a2/src/arche/ingest/__init__.py +31 -0
  61. arche_core-0.2.0a2/src/arche/ingest/from_url.py +373 -0
  62. arche_core-0.2.0a2/src/arche/jurisdictions/__init__.py +81 -0
  63. arche_core-0.2.0a2/src/arche/jurisdictions/ghana.py +512 -0
  64. arche_core-0.2.0a2/src/arche/jurisdictions/kenya.py +532 -0
  65. arche_core-0.2.0a2/src/arche/jurisdictions/nigeria.py +560 -0
  66. arche_core-0.2.0a2/src/arche/jurisdictions/restcountries.py +295 -0
  67. arche_core-0.2.0a2/src/arche/jurisdictions/south_africa.py +520 -0
  68. arche_core-0.2.0a2/src/arche/llm/__init__.py +103 -0
  69. arche_core-0.2.0a2/src/arche/llm/extraction.py +308 -0
  70. arche_core-0.2.0a2/src/arche/llm/providers.py +181 -0
  71. arche_core-0.2.0a2/src/arche/locate.py +141 -0
  72. arche_core-0.2.0a2/src/arche/models.py +341 -0
  73. arche_core-0.2.0a2/src/arche/policy/__init__.py +43 -0
  74. arche_core-0.2.0a2/src/arche/policy/_actions/__init__.py +3 -0
  75. arche_core-0.2.0a2/src/arche/policy/_data/__init__.py +3 -0
  76. arche_core-0.2.0a2/src/arche/policy/engine.py +402 -0
  77. arche_core-0.2.0a2/src/arche/policy/statutes/GHANA-DPA.yaml +157 -0
  78. arche_core-0.2.0a2/src/arche/policy/statutes/KENYA-DPA.yaml +167 -0
  79. arche_core-0.2.0a2/src/arche/policy/statutes/NDPA-2023.yaml +253 -0
  80. arche_core-0.2.0a2/src/arche/policy/statutes/POPIA.yaml +174 -0
  81. arche_core-0.2.0a2/src/arche/protect.py +424 -0
  82. arche_core-0.2.0a2/src/arche/py.typed +0 -0
  83. arche_core-0.2.0a2/src/arche/resolve/__init__.py +80 -0
  84. arche_core-0.2.0a2/src/arche/resolve/_matcher.py +668 -0
  85. arche_core-0.2.0a2/src/arche/resolve/_relate.py +286 -0
  86. arche_core-0.2.0a2/src/arche/resolve/classical.py +590 -0
  87. arche_core-0.2.0a2/src/arche/resolve/places.py +875 -0
  88. arche_core-0.2.0a2/src/arche/sign/__init__.py +96 -0
  89. arche_core-0.2.0a2/src/arche/sign/envelope.py +208 -0
  90. arche_core-0.2.0a2/src/arche/sign/jws.py +282 -0
  91. arche_core-0.2.0a2/src/arche/sign/keys.py +260 -0
  92. arche_core-0.2.0a2/src/arche/sign/workflow.py +401 -0
  93. arche_core-0.2.0a2/src/arche/types.py +235 -0
  94. arche_core-0.2.0a2/src/arche/workflow/__init__.py +40 -0
  95. arche_core-0.2.0a2/src/arche/workflow/_dsar_templates.py +244 -0
  96. arche_core-0.2.0a2/src/arche/workflow/_format.py +663 -0
  97. arche_core-0.2.0a2/src/arche/workflow/_ingest.py +213 -0
  98. arche_core-0.2.0a2/src/arche/workflow/_primitive.py +487 -0
  99. arche_core-0.2.0a2/src/arche/workflow/_review.py +595 -0
  100. arche_core-0.2.0a2/src/arche/workflow/dsar.py +347 -0
  101. arche_core-0.2.0a2/src/arche/workflow/pipeline.py +887 -0
  102. arche_core-0.2.0a2/tests/__init__.py +0 -0
  103. arche_core-0.2.0a2/tests/conftest.py +83 -0
  104. arche_core-0.2.0a2/tests/test_addr_parse.py +166 -0
  105. arche_core-0.2.0a2/tests/test_addr_parse_uk.py +130 -0
  106. arche_core-0.2.0a2/tests/test_african.py +66 -0
  107. arche_core-0.2.0a2/tests/test_audit.py +87 -0
  108. arche_core-0.2.0a2/tests/test_config.py +40 -0
  109. arche_core-0.2.0a2/tests/test_cultural.py +167 -0
  110. arche_core-0.2.0a2/tests/test_detect_digital_id.py +238 -0
  111. arche_core-0.2.0a2/tests/test_detect_ip.py +217 -0
  112. arche_core-0.2.0a2/tests/test_detect_phones.py +109 -0
  113. arche_core-0.2.0a2/tests/test_doc.py +75 -0
  114. arche_core-0.2.0a2/tests/test_dsar_workflow.py +308 -0
  115. arche_core-0.2.0a2/tests/test_edge_cases.py +86 -0
  116. arche_core-0.2.0a2/tests/test_ensemble.py +1058 -0
  117. arche_core-0.2.0a2/tests/test_extract.py +57 -0
  118. arche_core-0.2.0a2/tests/test_governance.py +122 -0
  119. arche_core-0.2.0a2/tests/test_graph.py +75 -0
  120. arche_core-0.2.0a2/tests/test_graph_audit.py +267 -0
  121. arche_core-0.2.0a2/tests/test_h3.py +65 -0
  122. arche_core-0.2.0a2/tests/test_ids_validators.py +77 -0
  123. arche_core-0.2.0a2/tests/test_ingest.py +247 -0
  124. arche_core-0.2.0a2/tests/test_ingest_from_url.py +428 -0
  125. arche_core-0.2.0a2/tests/test_jurisdiction_ghana.py +285 -0
  126. arche_core-0.2.0a2/tests/test_jurisdiction_kenya.py +294 -0
  127. arche_core-0.2.0a2/tests/test_jurisdiction_nigeria.py +559 -0
  128. arche_core-0.2.0a2/tests/test_jurisdiction_south_africa.py +301 -0
  129. arche_core-0.2.0a2/tests/test_level2_api.py +237 -0
  130. arche_core-0.2.0a2/tests/test_lexicon_detect.py +196 -0
  131. arche_core-0.2.0a2/tests/test_llm.py +624 -0
  132. arche_core-0.2.0a2/tests/test_match.py +210 -0
  133. arche_core-0.2.0a2/tests/test_models.py +220 -0
  134. arche_core-0.2.0a2/tests/test_pipeline.py +45 -0
  135. arche_core-0.2.0a2/tests/test_policy_engine.py +191 -0
  136. arche_core-0.2.0a2/tests/test_protect.py +36 -0
  137. arche_core-0.2.0a2/tests/test_resolve.py +92 -0
  138. arche_core-0.2.0a2/tests/test_resolve_v2.py +141 -0
  139. arche_core-0.2.0a2/tests/test_restcountries.py +171 -0
  140. arche_core-0.2.0a2/tests/test_review.py +582 -0
  141. arche_core-0.2.0a2/tests/test_sd_jwt.py +261 -0
  142. arche_core-0.2.0a2/tests/test_sensitivity_tier.py +432 -0
  143. arche_core-0.2.0a2/tests/test_sign.py +291 -0
  144. arche_core-0.2.0a2/tests/test_sign_workflow.py +324 -0
@@ -0,0 +1,64 @@
1
+ # Dependencies
2
+ node_modules/
3
+ web/node_modules/
4
+ __pycache__/
5
+ *.pyc
6
+ .venv/
7
+ venv/
8
+ env/
9
+
10
+ # Environment
11
+ .env
12
+ .env.local
13
+ .env.production
14
+
15
+ # Next.js
16
+ web/.next/
17
+ web/out/
18
+
19
+ # Build
20
+ dist/
21
+
22
+ # Built mkdocs output — regenerate with `cd docs-site && mkdocs build`.
23
+ # Source of truth is docs-site/docs/. Built site/ should not be tracked.
24
+ docs-site/site/
25
+ build/
26
+ *.egg-info/
27
+
28
+ # IDE
29
+ .vscode/
30
+ .idea/
31
+ *.swp
32
+ *.swo
33
+
34
+ # OS
35
+ .DS_Store
36
+ Thumbs.db
37
+
38
+ # Logs
39
+ *.log
40
+ npm-debug.log*
41
+
42
+ # Testing
43
+ .coverage
44
+ htmlcov/
45
+ .pytest_cache/
46
+
47
+ # Docker
48
+ docker-compose.override.yml
49
+
50
+ # Database
51
+ *.db
52
+
53
+
54
+ demo/outputs/
55
+
56
+ datasets/compliance/
57
+
58
+
59
+ /scripts
60
+
61
+ /docs/*
62
+
63
+
64
+ /workbook
@@ -0,0 +1,66 @@
1
+ # Changelog
2
+
3
+ All notable changes to `arche-core` are documented here. Format loosely follows [Keep a Changelog](https://keepachangelog.com/) and the project uses [PEP 440](https://peps.python.org/pep-0440/) version identifiers.
4
+
5
+ ## [0.2.0a2] — 2026-05-28
6
+
7
+ > **Headline.** `arche-core` is now **African PII detection that cites the law it enforces**. v0.2.0a2 makes that real: every `Pipeline.process()` detection ships with a sensitivity tier and the specific statute section that classifies it, mapped to one of six closed actions under NDPA, POPIA, Kenya DPA, or Ghana DPA. Plus an MVP address parser (633 LOC), a web-fetch ingest helper, a places resolver, and the deletion of every DPI-adapter and FHIR stub that was promising but unimplemented. The wheel is a ~310KB base install, 980 tests passing, no mandatory ML deps.
8
+
9
+ ### Added
10
+
11
+ - **`arche.addr.parse_addresses` and `Address` types**: 633-line address parser MVP covering Nigerian and South African landmark-anchored formats, with jurisdiction inference and a compiled-in gazetteer. Wired into `Pipeline` via the `"addr"` package.
12
+ - **`arche.ingest.from_url`**: SSRF-guarded HTTP fetch helper for ingesting text from public URLs. Uses `httpx` with tight redirect / timeout controls.
13
+ - **`arche.resolve_places` and `arche.list_places`**: new public functions for jurisdictional place lookup with verifiable JWS audit receipts.
14
+ - **`Detection.sensitivity_tier` and `Detection.regulatory_citation`**: every detection emitted by `Pipeline.process()` now carries both. Tier is one of `high` / `moderate` / `low`. Citation is the actual statute section (e.g. `"NDPA-2023 s.30, NIMC Act s.27"`).
15
+ - **`SensitivityTier` enum** at `arche.types`.
16
+ - **`arche.detect.ip`** — IPv4 / IPv6 / private-range / Tor exit detection.
17
+ - **`arche.detect.digital_id`** — decentralized identifier (DID) and verifiable credential reference detection. Emits the new `PII-2-DID` category.
18
+ - **`PII-4-LOCATION`, `PII-2-DID`, `PII-5-CRYPTO_WALLET`** taxonomy categories, with statute mappings in NDPA-2023.
19
+ - **Shared `_lexicon_detect` helper** for name / location / address lexicon detectors — collapses three near-duplicate implementations into one.
20
+ - **Names, locations, addr, ip, digital_id** wired into `Pipeline`'s default detector chain. `Pipeline(jurisdiction="NG").process(text)` now runs all of them by default.
21
+
22
+
23
+
24
+ ### Fixed
25
+
26
+ - Linter cleanup across the package (ruff + import organization).
27
+ - Stray `demo/demo/` directory artefact removed.
28
+ - Three dead-code blocks deleted (unused legacy helpers).
29
+
30
+ ### Public API surface
31
+
32
+ Recommended for v0.2 (in `__all__`):
33
+
34
+ ```python
35
+ from arche import (
36
+ # PRD 10.1 framework primitive
37
+ Pipeline, Result, Detection,
38
+ # Level-2 workhorses
39
+ detect, match, link, resolve,
40
+ # v0.2.0a2 places surface
41
+ resolve_places, list_places,
42
+ # version
43
+ __version__,
44
+ )
45
+ ```
46
+
47
+ The v0.1 surface (~50 names: `extract`, `detect_pii`, `resolve_entities`,
48
+ `to_html`, etc.) remains importable via PEP 562 lazy attribute access on
49
+ `arche`, with `DeprecationWarning` on first use. Removed in v0.3.
50
+
51
+ ### Stats
52
+
53
+ - 980 tests passing, 3 skipped, 0 failed (`uv run pytest packages/arche-core/tests`)
54
+ - Base wheel: 310 KB (`arche_core-0.2.0a2-py3-none-any.whl`)
55
+ - Source tarball: 325 KB
56
+ - Python: 3.11, 3.12, 3.13 supported
57
+ - CI matrix: Linux / macOS / Windows × Python 3.11 / 3.12 / 3.13
58
+
59
+ ## [0.2.0a1] — prior
60
+
61
+ Initial v0.2 alpha. Highlights:
62
+
63
+ - `Pipeline`, `Result`, `Detection` — the v0.2 framework primitive (PRD §10.1).
64
+ - Statute-grounded policy engine (`arche.policy`) with NDPA, POPIA, Kenya DPA, and Ghana DPA mappings.
65
+ - Verifiability substrate (`arche.sign`, `arche.credentials`): Ed25519 + JWS envelope, did:key, SD-JWT-VC.
66
+ - v0.1 backward-compatibility shim: every v0.1 name remains importable through PEP 562 lazy attribute access on `arche`. Removed in v0.3.
@@ -0,0 +1,190 @@
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 the 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 the 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 any 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
+ Copyright 2026 Unpatterned Labs
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: arche-core
3
+ Version: 0.2.0a2
4
+ Summary: The identity workflow framework. African-first, globally pluggable. Compose detection, resolution, linking, verification, and governance into production identity pipelines. By unpatterned.org.
5
+ Project-URL: Homepage, https://unpatterned.org
6
+ Project-URL: Repository, https://github.com/unpatterned-labs/arche
7
+ Project-URL: Documentation, https://docs.unpatterned.org
8
+ Author: unpatterned.org
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: Africa,DPI,DSAR,NDPA,PII,POPIA,arche,digital-public-infrastructure,entity-resolution,identity-resolution,identity-workflows,workflow-framework
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Healthcare Industry
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: cryptography>=43.0
23
+ Requires-Dist: h3>=4.0
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: jellyfish>=1.0
26
+ Requires-Dist: networkx>=3.0
27
+ Requires-Dist: phonenumbers>=8.13
28
+ Requires-Dist: pydantic>=2.0
29
+ Requires-Dist: pyyaml>=6.0
30
+ Requires-Dist: rapidfuzz>=3.0
31
+ Provides-Extra: africa
32
+ Provides-Extra: all
33
+ Requires-Dist: anthropic>=0.30; extra == 'all'
34
+ Requires-Dist: duckdb>=1.0; extra == 'all'
35
+ Requires-Dist: gliner>=0.2.8; extra == 'all'
36
+ Requires-Dist: onnxruntime>=1.18; extra == 'all'
37
+ Requires-Dist: openai>=1.0; extra == 'all'
38
+ Requires-Dist: presidio-analyzer>=2.2; extra == 'all'
39
+ Requires-Dist: presidio-anonymizer>=2.2; extra == 'all'
40
+ Requires-Dist: pymupdf>=1.24; extra == 'all'
41
+ Requires-Dist: python-docx>=1.1; extra == 'all'
42
+ Requires-Dist: splink>=4.0; extra == 'all'
43
+ Provides-Extra: detect
44
+ Requires-Dist: gliner>=0.2.8; extra == 'detect'
45
+ Requires-Dist: onnxruntime>=1.18; extra == 'detect'
46
+ Provides-Extra: dev
47
+ Requires-Dist: mypy>=1.10; extra == 'dev'
48
+ Requires-Dist: pytest-asyncio; extra == 'dev'
49
+ Requires-Dist: pytest>=8.0; extra == 'dev'
50
+ Requires-Dist: ruff>=0.4; extra == 'dev'
51
+ Provides-Extra: docx
52
+ Requires-Dist: python-docx>=1.1; extra == 'docx'
53
+ Provides-Extra: gh
54
+ Provides-Extra: gliner
55
+ Requires-Dist: gliner>=0.2.8; extra == 'gliner'
56
+ Requires-Dist: onnxruntime>=1.18; extra == 'gliner'
57
+ Provides-Extra: ke
58
+ Provides-Extra: litellm
59
+ Requires-Dist: litellm>=1.40; extra == 'litellm'
60
+ Provides-Extra: llm
61
+ Requires-Dist: anthropic>=0.30; extra == 'llm'
62
+ Requires-Dist: openai>=1.0; extra == 'llm'
63
+ Provides-Extra: ng
64
+ Provides-Extra: pdf
65
+ Requires-Dist: pymupdf>=1.24; extra == 'pdf'
66
+ Provides-Extra: pii
67
+ Requires-Dist: presidio-analyzer>=2.2; extra == 'pii'
68
+ Requires-Dist: presidio-anonymizer>=2.2; extra == 'pii'
69
+ Provides-Extra: presidio
70
+ Requires-Dist: presidio-analyzer>=2.2; extra == 'presidio'
71
+ Requires-Dist: presidio-anonymizer>=2.2; extra == 'presidio'
72
+ Provides-Extra: resolve
73
+ Requires-Dist: duckdb>=1.0; extra == 'resolve'
74
+ Requires-Dist: splink>=4.0; extra == 'resolve'
75
+ Provides-Extra: splink
76
+ Requires-Dist: duckdb>=1.0; extra == 'splink'
77
+ Requires-Dist: splink>=4.0; extra == 'splink'
78
+ Provides-Extra: za
79
+ Description-Content-Type: text/markdown
80
+
81
+ # arche-core
82
+
83
+ **African PII detection that cites the law it enforces.**
84
+
85
+ `arche-core` detects PII for African jurisdictions; government IDs, names, phone numbers, addresses, and grounds every detection in the data protection statute that governs it. NDPA, POPIA, Kenya DPA, Ghana DPA. Six closed policy actions. Composes with Presidio, GLiNER, and Splink.
86
+
87
+ > Presidio detects PII. GLiNER does multilingual NER. Splink links records. None of them know that a BVN is sensitive under NDPA §30, or that "Adeyẹmí" and "Adeyemi" are the same Yoruba name with and without tonal marks, or that "behind Total filling station, Madina Junction" is a parseable Ghanaian address. `arche-core` does that one job.
88
+
89
+ ```python
90
+ from arche import Pipeline
91
+
92
+ pipeline = Pipeline(jurisdiction="NG") # auto-loads NDPA-2023
93
+ result = pipeline.process(
94
+ "Fatima Abdullahi, NIN 12345678901, BVN 22100987654."
95
+ )
96
+
97
+ for d in result.detections:
98
+ print(f"{d.category:11} tier={d.sensitivity_tier.value:9} {d.regulatory_citation}")
99
+ # PII-2-BVN tier=high NDPA-2023 s.30, CBN BVN policy 2014
100
+ # PII-2-NIN tier=high NDPA-2023 s.30, NIMC Act s.27
101
+ # PII-1-NAME tier=moderate NDPA-2023 s.30 (×2 — given + family name)
102
+
103
+ print(result.redacted_text)
104
+ # NAME_... NAME_..., NIN [NIN], BVN [BVN].
105
+ ```
106
+
107
+ Same code works for `jurisdiction="ZA"` (POPIA), `"KE"` (Kenya DPA), `"GH"` (Ghana DPA). Four launch jurisdictions, four DPA-grounded statute YAML files, one composable framework.
108
+
109
+ ## Install
110
+
111
+ ```bash
112
+ pip install arche-core # ~310KB base — pure-Python detectors, statute policy
113
+ pip install arche-core[all] # everything (GLiNER + Presidio + Splink + docling + LLM)
114
+ ```
115
+
116
+ (Or `uv add arche-core` / `uv add arche-core[all]`.) Heavy capabilities are **opt-in extras**:
117
+
118
+ | Extra | Adds |
119
+ |---|---|
120
+ | `arche-core[detect]` | GLiNER2-PII via ONNX runtime (multilingual neural soft-PII) |
121
+ | `arche-core[presidio]` | Microsoft Presidio recognizer plugin |
122
+ | `arche-core[resolve]` | Splink + DuckDB for large-scale entity resolution |
123
+ | `arche-core[doc]` | docling for PDF / DOCX / PPTX / XLSX ingestion |
124
+
125
+ ## Coverage
126
+
127
+ Per-launch-jurisdiction detection coverage. Every detector validates check-digits where the underlying spec supports it.
128
+
129
+ | Jurisdiction | Statute | Detectors |
130
+ |---|---|---|
131
+ | Nigeria (NG) | NDPA-2023 | NIN (11 digits), BVN (11 digits, 22-prefix), TIN, RC, voter PVC, driver's licence |
132
+ | Kenya (KE) | Kenya DPA 2019 | National ID, KRA PIN, NHIF |
133
+ | South Africa (ZA) | POPIA | SA ID (13-digit Luhn + DOB/gender/citizenship decode), tax reference, passport |
134
+ | Ghana (GH) | Ghana DPA 2012 | Ghana Card, SSNIT, TIN |
135
+ | + 11 more African patterns | — | Egypt, Uganda, Rwanda, Tanzania, Cameroon, Senegal, ... |
136
+
137
+ Plus libphonenumber-backed normalization for 30+ African phone networks, landmark-anchored address parsing for NG and ZA, and currency detection (Naira, Cedi, Rand, CFA).
138
+
139
+ ## The statute layer
140
+
141
+ Every detection emits a category, a sensitivity tier (`high` / `moderate` / `low`), and the specific statute section that classifies it. The Pipeline maps each to one of six closed actions — `mask`, `tokenize`, `drop`, `generalize`, `audit`, `retain` — per the configured jurisdiction's statute YAML.
142
+
143
+ ```python
144
+ for o in result.policy_outcomes:
145
+ print(o.category, o.action, o.statute_reference)
146
+ # PII-2-BVN mask NDPA-2023 s.30, CBN BVN policy 2014
147
+ # PII-2-NIN mask NDPA-2023 s.30, NIMC Act s.27
148
+ # PII-1-NAME tokenize NDPA-2023 s.30
149
+ ```
150
+
151
+ Statute YAMLs live at `arche/policy/_data/<STATUTE-ID>.yaml` and are human-readable. Statute amendments are policy-file changes, not code changes.
152
+
153
+ ## Cultural naming intelligence
154
+
155
+ `arche-core` ships a 114-group African name equivalence lexicon covering 454 name forms across 50+ ethnic traditions:
156
+
157
+ - Mohammed = Muhammad = Mamadou = Muhammadu (Pan-Islamic)
158
+ - Diallo = Jallow = Jalloh (Fulani cross-ethnic orthography)
159
+ - Fatou = Fatoumata (West African diminutive)
160
+ - Adeyemi = Adeyẹmi = Adeyẹmí (Yoruba tonal marks)
161
+ - Pierre = Peter = Pedro (colonial-era cross-linguistic)
162
+ - Irorere, Aibuedfe (Benin/Edo names with semantic meaning)
163
+
164
+ Growing via Wikidata + community curation. See [`datasets/`](../../datasets/) for the full dataset and contribution guide.
165
+
166
+ ## Composing with Presidio, GLiNER, and Splink
167
+
168
+ `arche-core` is designed to compose with the incumbent tools, not replace them. The three integration patterns:
169
+
170
+ ```python
171
+ # Presidio's English recognizers + arche's African recognizers
172
+ pip install arche-core[presidio]
173
+ # arche.detect.presidio surfaces both as one recognizer set.
174
+
175
+ # GLiNER's multilingual NER + arche's statute classification
176
+ pip install arche-core[detect]
177
+ # Pipeline(jurisdiction="NG", backend="gliner") routes soft-PII through GLiNER.
178
+
179
+ # Splink's record linkage + arche's jurisdiction-aware comparators
180
+ pip install arche-core[resolve]
181
+ # Statute-tagged detections feed Splink as clean inputs.
182
+ ```
183
+
184
+ ## Audit log
185
+
186
+ `arche.graph.audit` ships an SQLite-backed append-only log that records every detection, every policy decision, and every action taken — queryable by compliance officers and regulators. **PII values are never stored**; only categories, span offsets, and document hashes. Markdown compliance report generator for regulator-ready exports.
187
+
188
+ ## Power-user features
189
+
190
+ These ship in the package but are not in the headline pitch — they support specific identity workflows on top of the detection layer:
191
+
192
+ - **`arche.sign`** — Ed25519 + JWS + did:key signing for `Pipeline.Result` envelopes. SD-JWT-VC issue / verify via `arche.credentials.sd_jwt`. See [`examples/02_sign_share_extract.py`](../../examples/02_sign_share_extract.py) and [`examples/04_sd_jwt_credential.py`](../../examples/04_sd_jwt_credential.py).
193
+ - **`arche.workflow.dsar`** — citizen-side DSAR draft generation with per-jurisdiction statute citations. See [`examples/03_dsar_workflow.py`](../../examples/03_dsar_workflow.py).
194
+ - **`arche.resolve`** — lightweight Fellegi-Sunter matcher with jurisdiction-specific priors. `from arche import match` for two-record comparison; `from arche import link` for cross-source resolution.
195
+ - **`arche.workflow._review`** — MPI review queue for human-in-the-loop match decisions. Not on the public surface; import from the canonical path.
196
+ - **`arche.resolve_places` / `arche.list_places`** — jurisdictional place lookup with verifiable audit receipts.
197
+
198
+ These are real tools we depend on internally. They are not the lead pitch.
199
+
200
+
201
+ ## License
202
+
203
+ Apache 2.0. By [Unpatterned Labs](https://unpatterned.org).
@@ -0,0 +1,123 @@
1
+ # arche-core
2
+
3
+ **African PII detection that cites the law it enforces.**
4
+
5
+ `arche-core` detects PII for African jurisdictions; government IDs, names, phone numbers, addresses, and grounds every detection in the data protection statute that governs it. NDPA, POPIA, Kenya DPA, Ghana DPA. Six closed policy actions. Composes with Presidio, GLiNER, and Splink.
6
+
7
+ > Presidio detects PII. GLiNER does multilingual NER. Splink links records. None of them know that a BVN is sensitive under NDPA §30, or that "Adeyẹmí" and "Adeyemi" are the same Yoruba name with and without tonal marks, or that "behind Total filling station, Madina Junction" is a parseable Ghanaian address. `arche-core` does that one job.
8
+
9
+ ```python
10
+ from arche import Pipeline
11
+
12
+ pipeline = Pipeline(jurisdiction="NG") # auto-loads NDPA-2023
13
+ result = pipeline.process(
14
+ "Fatima Abdullahi, NIN 12345678901, BVN 22100987654."
15
+ )
16
+
17
+ for d in result.detections:
18
+ print(f"{d.category:11} tier={d.sensitivity_tier.value:9} {d.regulatory_citation}")
19
+ # PII-2-BVN tier=high NDPA-2023 s.30, CBN BVN policy 2014
20
+ # PII-2-NIN tier=high NDPA-2023 s.30, NIMC Act s.27
21
+ # PII-1-NAME tier=moderate NDPA-2023 s.30 (×2 — given + family name)
22
+
23
+ print(result.redacted_text)
24
+ # NAME_... NAME_..., NIN [NIN], BVN [BVN].
25
+ ```
26
+
27
+ Same code works for `jurisdiction="ZA"` (POPIA), `"KE"` (Kenya DPA), `"GH"` (Ghana DPA). Four launch jurisdictions, four DPA-grounded statute YAML files, one composable framework.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install arche-core # ~310KB base — pure-Python detectors, statute policy
33
+ pip install arche-core[all] # everything (GLiNER + Presidio + Splink + docling + LLM)
34
+ ```
35
+
36
+ (Or `uv add arche-core` / `uv add arche-core[all]`.) Heavy capabilities are **opt-in extras**:
37
+
38
+ | Extra | Adds |
39
+ |---|---|
40
+ | `arche-core[detect]` | GLiNER2-PII via ONNX runtime (multilingual neural soft-PII) |
41
+ | `arche-core[presidio]` | Microsoft Presidio recognizer plugin |
42
+ | `arche-core[resolve]` | Splink + DuckDB for large-scale entity resolution |
43
+ | `arche-core[doc]` | docling for PDF / DOCX / PPTX / XLSX ingestion |
44
+
45
+ ## Coverage
46
+
47
+ Per-launch-jurisdiction detection coverage. Every detector validates check-digits where the underlying spec supports it.
48
+
49
+ | Jurisdiction | Statute | Detectors |
50
+ |---|---|---|
51
+ | Nigeria (NG) | NDPA-2023 | NIN (11 digits), BVN (11 digits, 22-prefix), TIN, RC, voter PVC, driver's licence |
52
+ | Kenya (KE) | Kenya DPA 2019 | National ID, KRA PIN, NHIF |
53
+ | South Africa (ZA) | POPIA | SA ID (13-digit Luhn + DOB/gender/citizenship decode), tax reference, passport |
54
+ | Ghana (GH) | Ghana DPA 2012 | Ghana Card, SSNIT, TIN |
55
+ | + 11 more African patterns | — | Egypt, Uganda, Rwanda, Tanzania, Cameroon, Senegal, ... |
56
+
57
+ Plus libphonenumber-backed normalization for 30+ African phone networks, landmark-anchored address parsing for NG and ZA, and currency detection (Naira, Cedi, Rand, CFA).
58
+
59
+ ## The statute layer
60
+
61
+ Every detection emits a category, a sensitivity tier (`high` / `moderate` / `low`), and the specific statute section that classifies it. The Pipeline maps each to one of six closed actions — `mask`, `tokenize`, `drop`, `generalize`, `audit`, `retain` — per the configured jurisdiction's statute YAML.
62
+
63
+ ```python
64
+ for o in result.policy_outcomes:
65
+ print(o.category, o.action, o.statute_reference)
66
+ # PII-2-BVN mask NDPA-2023 s.30, CBN BVN policy 2014
67
+ # PII-2-NIN mask NDPA-2023 s.30, NIMC Act s.27
68
+ # PII-1-NAME tokenize NDPA-2023 s.30
69
+ ```
70
+
71
+ Statute YAMLs live at `arche/policy/_data/<STATUTE-ID>.yaml` and are human-readable. Statute amendments are policy-file changes, not code changes.
72
+
73
+ ## Cultural naming intelligence
74
+
75
+ `arche-core` ships a 114-group African name equivalence lexicon covering 454 name forms across 50+ ethnic traditions:
76
+
77
+ - Mohammed = Muhammad = Mamadou = Muhammadu (Pan-Islamic)
78
+ - Diallo = Jallow = Jalloh (Fulani cross-ethnic orthography)
79
+ - Fatou = Fatoumata (West African diminutive)
80
+ - Adeyemi = Adeyẹmi = Adeyẹmí (Yoruba tonal marks)
81
+ - Pierre = Peter = Pedro (colonial-era cross-linguistic)
82
+ - Irorere, Aibuedfe (Benin/Edo names with semantic meaning)
83
+
84
+ Growing via Wikidata + community curation. See [`datasets/`](../../datasets/) for the full dataset and contribution guide.
85
+
86
+ ## Composing with Presidio, GLiNER, and Splink
87
+
88
+ `arche-core` is designed to compose with the incumbent tools, not replace them. The three integration patterns:
89
+
90
+ ```python
91
+ # Presidio's English recognizers + arche's African recognizers
92
+ pip install arche-core[presidio]
93
+ # arche.detect.presidio surfaces both as one recognizer set.
94
+
95
+ # GLiNER's multilingual NER + arche's statute classification
96
+ pip install arche-core[detect]
97
+ # Pipeline(jurisdiction="NG", backend="gliner") routes soft-PII through GLiNER.
98
+
99
+ # Splink's record linkage + arche's jurisdiction-aware comparators
100
+ pip install arche-core[resolve]
101
+ # Statute-tagged detections feed Splink as clean inputs.
102
+ ```
103
+
104
+ ## Audit log
105
+
106
+ `arche.graph.audit` ships an SQLite-backed append-only log that records every detection, every policy decision, and every action taken — queryable by compliance officers and regulators. **PII values are never stored**; only categories, span offsets, and document hashes. Markdown compliance report generator for regulator-ready exports.
107
+
108
+ ## Power-user features
109
+
110
+ These ship in the package but are not in the headline pitch — they support specific identity workflows on top of the detection layer:
111
+
112
+ - **`arche.sign`** — Ed25519 + JWS + did:key signing for `Pipeline.Result` envelopes. SD-JWT-VC issue / verify via `arche.credentials.sd_jwt`. See [`examples/02_sign_share_extract.py`](../../examples/02_sign_share_extract.py) and [`examples/04_sd_jwt_credential.py`](../../examples/04_sd_jwt_credential.py).
113
+ - **`arche.workflow.dsar`** — citizen-side DSAR draft generation with per-jurisdiction statute citations. See [`examples/03_dsar_workflow.py`](../../examples/03_dsar_workflow.py).
114
+ - **`arche.resolve`** — lightweight Fellegi-Sunter matcher with jurisdiction-specific priors. `from arche import match` for two-record comparison; `from arche import link` for cross-source resolution.
115
+ - **`arche.workflow._review`** — MPI review queue for human-in-the-loop match decisions. Not on the public surface; import from the canonical path.
116
+ - **`arche.resolve_places` / `arche.list_places`** — jurisdictional place lookup with verifiable audit receipts.
117
+
118
+ These are real tools we depend on internally. They are not the lead pitch.
119
+
120
+
121
+ ## License
122
+
123
+ Apache 2.0. By [Unpatterned Labs](https://unpatterned.org).