Skip to main content

Crate entity_ref

Crate entity_ref 

Source
Expand description

entity-ref — the one shared contract for cross-service entity linking in the Main X Index family (agents/share/cross-service-linking.md §3, §9).

A record that lives in another service is named by an opaque URN string "<entity_type>:<uuid>" (e.g. person:0c4f1e2a-…). This crate owns:

  • EntityType — the globally-unique entity discriminator and its static entity_type → owning service map (a multi-entity service like course hosts both course and courseinstance, which is why the type, not the service, is the discriminator);
  • EntityRef — the {entity_type, id} value type that parses, Displays, and (de)serialises as that single URN string, so the aggregator can index it as one TEXT column;
  • EdgeKind — the closed v1 edge-kind registry (§9): each kind fixes its endpoint types, direction, temporality, inverse, and sensitivity, and can validate an endpoint pair.

It is pure data with no behaviour beyond parsing/validation — no I/O, no clock, no panics — and is deliberately dependency-light. The original rollout plan (agents/share/cross-service-linking.md §2/§11) framed this as copyable per project until a second non-aggregator consumer justified a shared dependency; in practice it is embedded as a real Cargo path dependency by eight crates (as of 2026-08-04): the link-graph-service-with-loco aggregator, the three entity services that originate edges (person, worker, case), and four consumer apps (contact-relationship-management, content-management-system, patient-flow, workforce-planning-management) that validate/dereference cross-service refs without originating edges. See the crate’s README.md for the full picture. This crate’s own contract shipped as rollout step 1 (“land the contracts; no behaviour yet”).

Structs§

EntityRef
A reference to a record that lives in another service, identified by its entity type and public UUID (pid). Serialises as the single URN string "<entity_type>:<uuid>".

Enums§

EdgeKind
The closed v1 cross-service edge-kind registry (cross-service-linking.md §9). Each kind fixes its endpoint types, direction, temporality, inverse label, and sensitivity.
EntityType
The entity type of a linked record — globally unique across the family. The wire token is the lowercase snake-case form (EntityType::as_str); EntityType::service maps it to the owning service.
ParseEntityRefError
Error parsing an EntityRef from its URN string form.
Sensitivity
Sensitivity tier of an edge kind (§9, §10) — governs the authorisation / audit / masking posture the aggregator must apply.