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) -> EntityResolutionadd_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.
EntityResolvedpayload keys:entity_id,resolver,resolved_at,confidence,schema_version
EntityMergedpayload keys:entity_id,merged_from,merged_at,reason,schema_version
EntityAliasAddedpayload 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.
M2 Recommendation Context API
Recommendation and drafter workers can consume:
resolver.recommendation_context(entity_id)
The recommendation context includes:
- identity confidence
- activity recency (days)
- interaction history summary (evidence count + source distribution)
- preferred channel hint
- relationship stage hint (
cold/warm/engaged) - merge-safe continuity fields keyed to canonical entity IDs
M3 Outcome Attribution API
Outcome evaluators can map attempt/outcome references back to canonical entity lineage:
resolver.attribute_outcome(references)
Supported references include entity_id, email, canonical_url, handles, domains, and names.
Attribution guarantees:
- canonical merge redirects are resolved before returning
entity_id - output includes explicit confidence for downstream learning logic
- deterministic tie-breaks are applied by score, then hit count, then entity ID
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
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 metaspn_entities-0.1.7.tar.gz.
File metadata
- Download URL: metaspn_entities-0.1.7.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea712000c7e86838b6a7e9aaaf179ac29f4c2412eb6d0546313b155139e06384
|
|
| MD5 |
651a0f04f1f4a329c6826690fe59832d
|
|
| BLAKE2b-256 |
42978358a7d8eef0cc3c96be7e4a71ca4dc75280e02dcba645967fbcb513ddab
|
Provenance
The following attestation bundles were made for metaspn_entities-0.1.7.tar.gz:
Publisher:
publish.yml on MetaSPN/metaspn-entities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaspn_entities-0.1.7.tar.gz -
Subject digest:
ea712000c7e86838b6a7e9aaaf179ac29f4c2412eb6d0546313b155139e06384 - Sigstore transparency entry: 922216209
- Sigstore integration time:
-
Permalink:
MetaSPN/metaspn-entities@e58cb0ee1e33e9aea320c537c213c625dec24b9d -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/MetaSPN
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e58cb0ee1e33e9aea320c537c213c625dec24b9d -
Trigger Event:
push
-
Statement type:
File details
Details for the file metaspn_entities-0.1.7-py3-none-any.whl.
File metadata
- Download URL: metaspn_entities-0.1.7-py3-none-any.whl
- Upload date:
- Size: 15.8 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 |
a5831869019fb59148a381f4fe456d282d2ed6b6cf6f453800c3d3df73ea8400
|
|
| MD5 |
b78557c2b7f5910b8ec88ebc514f5d15
|
|
| BLAKE2b-256 |
7471ac774abd78dfc29660d5d5c38cbe277acf79ce15265b38ea2e66d7782df9
|
Provenance
The following attestation bundles were made for metaspn_entities-0.1.7-py3-none-any.whl:
Publisher:
publish.yml on MetaSPN/metaspn-entities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaspn_entities-0.1.7-py3-none-any.whl -
Subject digest:
a5831869019fb59148a381f4fe456d282d2ed6b6cf6f453800c3d3df73ea8400 - Sigstore transparency entry: 922216255
- Sigstore integration time:
-
Permalink:
MetaSPN/metaspn-entities@e58cb0ee1e33e9aea320c537c213c625dec24b9d -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/MetaSPN
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e58cb0ee1e33e9aea320c537c213c625dec24b9d -
Trigger Event:
push
-
Statement type: