Entity references
An attribute of type ref identifies another entity instance by its UUID. The
reference is type-erased: the generated API knows that it is an entity
reference, but does not restrict which entity type it targets. This is useful
when any kind of entity is a valid target.
YAML model
quent: alpha
model: untyped_references
entities:
Worker:
events:
started: {}
ended: {}
Task:
events:
started:
attributes:
source: ref
ended: {}
Instrumentation API
Every entity handle can produce a type-erased reference. Here,
as_any_entity_ref produces a reference to the Worker instance for the
task’s started event.
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
#[allow(unused)]
mod instrumentation {
include!(concat!(env!("OUT_DIR"), "/untyped_references.rs"));
}
use instrumentation::{Context, Noop, Task, UntypedReferences, Worker};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let context = Context::<UntypedReferences>::try_new(Noop)?;
let mut worker = context.observer::<Worker>().handle();
worker.started()?;
let mut task = context.observer::<Task>().handle();
task.started(worker.as_any_entity_ref())?;
task.ended()?;
worker.ended()?;
Ok(())
}
When an attribute must target a particular entity type, the Reference Target semantic module adds that restriction to the generated API.
A type-erased reference preserves an entity's identity without restricting its entity type.