Skip to main content

Canonical entity resolution, aliasing, and merges for MetaSPN systems

Project description

metaspn-entities

Identity layer for MetaSPN systems.

Features

  • Canonical entity IDs
  • Deterministic identifier normalization + alias resolution
  • Merge history and reversible soft undo
  • SQLite backend using stdlib sqlite3
  • Event emission payloads for EntityResolved, EntityMerged, EntityAliasAdded
  • Optional filesystem snapshot export

Quick usage

from metaspn_entities import EntityResolver

resolver = EntityResolver()
resolution = resolver.resolve("twitter_handle", "@some_handle")
events = resolver.drain_events()
print(resolution.entity_id, resolution.confidence)

API notes

  • resolve(identifier_type, value, context=None) -> EntityResolution
  • add_alias(entity_id, identifier_type, value, ...)
  • merge_entities(from_entity_id, to_entity_id, reason, ...)
  • undo_merge(from_entity_id, to_entity_id, ...) (implemented as reverse merge with redirect correction)
  • drain_events() -> list[EmittedEvent]
  • export_snapshot(output_path) to inspect SQLite state as JSON

Event Contract Guarantees

drain_events() returns EmittedEvent objects whose event_type and payload are schema-compatible with metaspn-schemas entity events.

  • EntityResolved payload keys:
    • entity_id, resolver, resolved_at, confidence, schema_version
  • EntityMerged payload keys:
    • entity_id, merged_from, merged_at, reason, schema_version
  • EntityAliasAdded payload keys:
    • entity_id, alias, alias_type, added_at, schema_version

Datetime fields are emitted as UTC ISO-8601 strings for deterministic serialization.

M0 Ingestion Adapter

For worker/runtime integration, use resolve_normalized_social_signal(...) with a normalized signal envelope.

from metaspn_entities import EntityResolver, resolve_normalized_social_signal

resolver = EntityResolver()
signal = {
    "source": "social.ingest",
    "payload_type": "SocialPostSeen",
    "payload": {
        "platform": "twitter",
        "author_handle": "@some_handle",
        "profile_url": "https://example.com/profiles/some-handle",
    },
}

result = resolve_normalized_social_signal(resolver, signal)
print(result.entity_id, result.confidence)
for event in result.emitted_events:
    print(event.event_type, event.payload)

Adapter behavior:

  • Extracts deterministic identifier candidates from normalized payloads.
  • Resolves a primary identifier, then adds remaining identifiers as aliases.
  • Returns only events produced during the adapter call.

M1 Context API

Profiler/router workers can read consolidated context using:

  • resolver.entity_context(entity_id, recent_limit=10)
  • resolver.confidence_summary(entity_id)

Both APIs resolve canonical redirects first, so merged IDs return coherent context.

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

metaspn_entities-0.1.5.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

metaspn_entities-0.1.5-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file metaspn_entities-0.1.5.tar.gz.

File metadata

  • Download URL: metaspn_entities-0.1.5.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metaspn_entities-0.1.5.tar.gz
Algorithm Hash digest
SHA256 beb3672d5ae8217739b80391451c57ca19ca18cef0fa4693650c734538418b45
MD5 d173492abe9fbaf82cbee6631f6575e4
BLAKE2b-256 8512f87b84d130e2edbd58e7412fdd08f4a347ff72e3cf2db609eb2909e4a33e

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaspn_entities-0.1.5.tar.gz:

Publisher: publish.yml on MetaSPN/metaspn-entities

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

File details

Details for the file metaspn_entities-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for metaspn_entities-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a6460d787e5bff6d93212a0049062fe3147b8a7f8d05f07f55d9deb5acb74fea
MD5 ad8ed066e79fbf8431685d160c5abd45
BLAKE2b-256 b6e2ecc6325e82d5dcd671944e9052332665913c856f3de9f8b2335493f496ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaspn_entities-0.1.5-py3-none-any.whl:

Publisher: publish.yml on MetaSPN/metaspn-entities

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