Skip to main content

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

Python Version License: MIT CI PyPI

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

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:

  1. Identity ≠ Identifier - Never generates rettxid
  2. Verified Identity Only - Canonical output from verified identity only
  3. Determinism - Same inputs → same outputs (versioned)
  4. Explainability - Structured reason codes in all outputs
  5. Script-Agnostic - Native scripts first-class; transliteration for comparison
  6. DOB + Mutation Anchors - Hard gates with clear rules
  7. No Lock - Declares eligibility, never locks
  8. Borderline First-Class - Preferred over FAIL in ambiguity
  9. Purity & Statelessness - No DB, network, filesystem
  10. Minimal Surface Area - Focused API
  11. Versioned Canonicalization - All outputs include version
  12. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rettxidentity-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rettxidentity-0.1.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

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

Hashes for rettxidentity-0.1.0.tar.gz
Algorithm Hash digest
SHA256 551944d20aa3272deefe3a07372d780fad153d762dedb150b0ead5c8ae5d4b1c
MD5 fac3c8c329b2327d8ddbedbf1e6870fc
BLAKE2b-256 d0a10b443c8b1da3a830375a1846bb8229a2902a6934121902a05a6d7f64cbfe

See more details on using hashes here.

Provenance

The following attestation bundles were made for rettxidentity-0.1.0.tar.gz:

Publisher: publish.yml on rett-europe/rettxidentity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for rettxidentity-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c921a8a78b7736b0628190bb3eeb3308d482719240e5e7f0141e645eb67c0c8
MD5 61f7594789563ce99062cac5795d4bde
BLAKE2b-256 ddc03d842f420af6fc1b1f2c03cc5b8e3cb14c3c2c1cac763761ed2a589ed296

See more details on using hashes here.

Provenance

The following attestation bundles were made for rettxidentity-0.1.0-py3-none-any.whl:

Publisher: publish.yml on rett-europe/rettxidentity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page