Skip to main content

Non-normative reference implementation of Meridian Enterprise Unique Identifiers (EUIDs).

Project description

meridian-euid (Python)

Python CI GitHub Release License: MIT

Python reference implementation of the Meridian EUID specification.

The v0.4.0 line is strict and canonical:

  • one syntax: DOMAIN-PREFIX-BODYCHECKSUM
  • one validation mode
  • no sandbox aliases
  • no absent-domain form
  • no tolerant normalization

Requirements

  • Python 3.10+

Installation

From source (development)

git clone https://github.com/lsmc-bio/meridian-euid.git
cd meridian-euid/reference-implementations/python

pip install -e .
pip install -e ".[dev]"

CLI Usage

The meridian-euid command provides four subcommands.

validate

Validate a canonical EUID.

meridian-euid validate A1-Z9-3V9

encode

Encode an integer as a canonical EUID.

meridian-euid encode 123 Z9 --domain-code A1
Argument/Option Required Description
integer Yes Integer in 1..9223372036854775807
prefix Yes Prefix token (1-4 uppercase Crockford Base32 characters)
--domain-code Yes Domain token (1-4 uppercase Crockford Base32 characters)

parse

Parse a validated EUID into its components.

meridian-euid parse A1-Z9-3V9

compute-check

Compute the check character for a payload.

# Payload is DOMAIN + PREFIX + BODY, with no hyphens
meridian-euid compute-check A1Z93V

Programmatic API

Canonical functions

from meridian_euid import (
    BIGINT_MAX,
    compute_check_character,
    encode,
    is_valid,
    parse,
    validate,
)

assert validate("A1-Z9-3V9") == "A1-Z9-3V9"
assert is_valid("A1-Z9-3V9") is True
assert encode(123, "Z9", domain_code="A1") == "A1-Z9-3V9"
assert parse("A1-Z9-3V9") == {
    "domain_code": "A1",
    "prefix": "Z9",
    "body": "3V",
    "checksum": "9",
    "integer": 123,
}
assert compute_check_character("A1Z93V") == "9"
assert BIGINT_MAX == 9223372036854775807

Governance helpers

from meridian_euid import (
    assert_prefix_issuer_app_code,
    assert_registered_domain,
    load_domain_registry,
    load_prefix_ownership_registry,
    resolve_prefix_issuer_app_code,
    validate_issuer_app_code,
    validate_registries_consistent,
)

domains = load_domain_registry()
ownership = load_prefix_ownership_registry()

assert_registered_domain("A1", registry=domains)
assert validate_issuer_app_code("meridian.lims") == "meridian.lims"
assert resolve_prefix_issuer_app_code("A1", "Z9", registry=ownership) == "meridian.lims"
assert_prefix_issuer_app_code("A1", "Z9", "meridian.lims", registry=ownership)
validate_registries_consistent()

When called without path=..., the governance helpers load the bundled registry JSON files shipped inside the wheel. Pass path= to point at an alternate registry file.

issuer_app_code values are governance tokens, not part of the canonical EUID grammar. They MUST match:

^[a-z0-9]+(?:[._-][a-z0-9]+)*$

Exceptions

from meridian_euid import (
    EUIDChecksumError,
    EUIDDomainCodeError,
    EUIDError,
    EUIDFormatError,
    EUIDGovernanceError,
    EUIDIssuerAppCodeError,
    EUIDPrefixOwnershipError,
)
Exception Raised when
EUIDFormatError Canonical syntax, prefix, BODY, or checksum-token validation fails
EUIDChecksumError The checksum does not match
EUIDDomainCodeError The domain token is syntactically invalid
EUIDGovernanceError Registry-backed governance checks fail
EUIDIssuerAppCodeError An issuer_app_code fails grammar validation
EUIDPrefixOwnershipError A prefix is unclaimed or claimed by a different issuer_app_code

Running Tests

pytest --cov --cov-report=term-missing
ruff check meridian_euid tests
mypy meridian_euid --ignore-missing-imports

Tests use shared vectors from test-vectors/v3.json.

Related Documentation

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

meridian_euid-0.4.2.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

meridian_euid-0.4.2-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file meridian_euid-0.4.2.tar.gz.

File metadata

  • Download URL: meridian_euid-0.4.2.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for meridian_euid-0.4.2.tar.gz
Algorithm Hash digest
SHA256 ded85c4027adc2e43b7362f5cc3cb52f7e6e75de5a19a3affa3ae3aee4ef8d3b
MD5 ae950298f7bc351e593a2ce671333029
BLAKE2b-256 e57e13f00b11136085af5d0f350a545deabf2379d540fd3808c5a5c93587f45d

See more details on using hashes here.

File details

Details for the file meridian_euid-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: meridian_euid-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for meridian_euid-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 03184f096eaa2e968a4622607e3ebd4ecec7570ba6274fb1b1b2cafd451eeb48
MD5 6029b6b8dcc46f13d0c128cfa17cd8c3
BLAKE2b-256 6fa109fea41fe9d6fbac1b781c4c0950c904e8456b9f90b378167ed958e04c2d

See more details on using hashes here.

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