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 (
    MERIDIAN_REGISTRY_INDEX_URL,
    check_domain_availability,
    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_registered_domain(
    "M",
    reserved_for="LSMC",
    deployment_environment="production",
)
assert_registered_domain(
    "M",
    reserved_for="LSMC",
    deployment_environment="staging",
    approval_tokens=["approval-a", "approval-b", "approval-c"],
)
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()

The public domain-code authority is lsmc-bio/meridian-registry. The current pinned generated index URL is available as MERIDIAN_REGISTRY_INDEX_URL, but the library does not fetch it at runtime. Pass an explicit local path:

result = check_domain_availability(
    "N",
    registry_index_path="/path/to/registry/generated/domains.json",
)
assert result["available"] is False

The CLI exposes the same explicit check:

meridian-euid domain-check N --registry-index /path/to/registry/generated/domains.json

When called without path=..., the legacy helper functions load bundled JSON fixtures shipped inside the wheel. Pass path= to point at an alternate local registry file. These fixtures are not the public domain-code authority.

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.7.tar.gz (19.2 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.7-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for meridian_euid-0.4.7.tar.gz
Algorithm Hash digest
SHA256 27b65eba282a904a876c7df16b48a8329900190cf5830a5fd61776f89d98a62a
MD5 7d180efdb2c55d359ee6f1e026f2798d
BLAKE2b-256 7ceaeff4b7b442f20fa5aa968735ee17f43f9d8e9621da89230426a43203ef5b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for meridian_euid-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a369a21b4bc7835848ea424bc0a9b1f8273afb13e7ab0c9e83bdd9111a7dd1c8
MD5 f44e7b80a47f8108d916e6584659ef9e
BLAKE2b-256 21538c9b0dd4f9ec901b0289e6f7fc20163d588d20019edd6f437233cf834c91

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