Pure Python library for deterministic identity canonicalization and matching in the rettX ecosystem
Project description
rettxidentity
Pure Python library for deterministic identity canonicalization and matching in the rettX ecosystem
Overview
rettxidentity is a reusable identity canonicalization and matching engine for the rettX ecosystem. It enables deterministic comparison of a caregiver-entered Draft Identity against a Verified Identity extracted from medical reports, producing an explicit Match Decision (PASS, BORDERLINE, FAIL) with confidence scores and explainable reason codes.
The library is intentionally designed with:
- ✅ No database dependencies
- ✅ No network calls
- ✅ No secrets or configuration files
- ✅ Deterministic outputs (same inputs → same outputs)
- ✅ Thread-safe (all dataclasses frozen)
- ✅ Cross-platform (Linux, Windows, macOS)
Key Features
- Identity Comparison: Compare draft vs verified identities with explicit match decisions
- Cross-Script Matching: Handle Greek, Georgian, and Cyrillic names seamlessly
- Name Normalization: Unicode-aware name normalization with diacritics handling
- Canonicalization: Versioned, deterministic identity representation
- Explainability: Every decision includes reason codes explaining the logic
- Performance: 1000+ comparisons/second on standard hardware
Installation
pip install rettxidentity
Quick Start
from rettxidentity import compare_identities, Identity, PersonName, MatchDecision
# Draft identity (from caregiver input)
draft = Identity(
name=PersonName(given="Maria", surname="Garcia"),
date_of_birth="1985-03-15",
country_of_birth="ES",
)
# Verified identity (from medical report)
verified = Identity(
name=PersonName(given="María", surname="García López"),
date_of_birth="1985-03-15",
country_of_birth="Spain",
)
# Compare them
result = compare_identities(draft, verified)
# Check the decision
if result.decision == MatchDecision.PASS:
print("✓ Identities match! Safe to proceed.")
print(f"Confidence: {result.confidence:.2%}")
elif result.decision == MatchDecision.BORDERLINE:
print("⚠ Requires admin review")
print(f"Reason codes: {[rc.value for rc in result.reason_codes]}")
else: # FAIL
print("✗ Identities do not match. Request correction.")
Documentation
- Specification - Feature requirements and user scenarios
- Implementation Plan - Technical architecture and design decisions
- Quickstart Guide - Usage examples and patterns
- API Contract - Complete API reference
- Matching Rules - Decision logic details
Development
Setup
# Clone repository
git clone https://github.com/rettx/rettxidentity.git
cd rettxidentity
# Install with dev dependencies
pip install -e ".[dev]"
Running Tests
# Run all tests with coverage (minimum 80% required)
pytest
# Run specific test categories
pytest -m unit # Unit tests only
pytest -m contract # Contract tests only
pytest -m integration # Integration tests only
# Generate detailed coverage report
pytest --cov-report=html
Code Quality
# Format code
ruff format src tests
# Lint with auto-fix
ruff check --fix src tests
# Type check
mypy src/rettxidentity --strict
CI/CD
The project uses GitHub Actions for continuous integration and deployment:
- CI Workflow: Runs on every push and PR (linting, type checking, tests)
- Publish Workflow: Automatically publishes to PyPI when a release is created
See .github/workflows/README.md for detailed CI/CD documentation.
Design Principles
This library follows the rettX Identity Constitution:
- Identity ≠ Identifier - Never generates rettxid
- Verified Identity Only - Canonical output from verified identity only
- Determinism - Same inputs → same outputs (versioned)
- Explainability - Structured reason codes in all outputs
- Script-Agnostic - Native scripts first-class; transliteration for comparison
- DOB + Mutation Anchors - Hard gates with clear rules
- No Lock - Declares eligibility, never locks
- Borderline First-Class - Preferred over FAIL in ambiguity
- Purity & Statelessness - No DB, network, filesystem
- Minimal Surface Area - Focused API
- Versioned Canonicalization - All outputs include version
- Privacy by Construction - No logging by default
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please read our contributing guidelines and code of conduct.
Support
For questions and support, please open an issue on GitHub
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rettxidentity-0.1.0.tar.gz.
File metadata
- Download URL: rettxidentity-0.1.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
551944d20aa3272deefe3a07372d780fad153d762dedb150b0ead5c8ae5d4b1c
|
|
| MD5 |
fac3c8c329b2327d8ddbedbf1e6870fc
|
|
| BLAKE2b-256 |
d0a10b443c8b1da3a830375a1846bb8229a2902a6934121902a05a6d7f64cbfe
|
Provenance
The following attestation bundles were made for rettxidentity-0.1.0.tar.gz:
Publisher:
publish.yml on rett-europe/rettxidentity
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rettxidentity-0.1.0.tar.gz -
Subject digest:
551944d20aa3272deefe3a07372d780fad153d762dedb150b0ead5c8ae5d4b1c - Sigstore transparency entry: 763864386
- Sigstore integration time:
-
Permalink:
rett-europe/rettxidentity@7cf8e27058b78d9643f4c22610f730ecad457c4e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rett-europe
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7cf8e27058b78d9643f4c22610f730ecad457c4e -
Trigger Event:
release
-
Statement type:
File details
Details for the file rettxidentity-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rettxidentity-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c921a8a78b7736b0628190bb3eeb3308d482719240e5e7f0141e645eb67c0c8
|
|
| MD5 |
61f7594789563ce99062cac5795d4bde
|
|
| BLAKE2b-256 |
ddc03d842f420af6fc1b1f2c03cc5b8e3cb14c3c2c1cac763761ed2a589ed296
|
Provenance
The following attestation bundles were made for rettxidentity-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on rett-europe/rettxidentity
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rettxidentity-0.1.0-py3-none-any.whl -
Subject digest:
2c921a8a78b7736b0628190bb3eeb3308d482719240e5e7f0141e645eb67c0c8 - Sigstore transparency entry: 763864387
- Sigstore integration time:
-
Permalink:
rett-europe/rettxidentity@7cf8e27058b78d9643f4c22610f730ecad457c4e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rett-europe
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7cf8e27058b78d9643f4c22610f730ecad457c4e -
Trigger Event:
release
-
Statement type: