> For clean Markdown of any page, append .md to the page URL. For a task-oriented documentation index, fetch https://docs.nvidia.com/nemo/relay/llms.txt. Use the documentation version matching the installed NeMo Relay package: latest follows the latest stable release, vX.Y.Z identifies a retained release snapshot, and dev documents development changes. Preserve the selected version when following links; do not mix examples or API contracts from different versions. Fetch the relevant section's /llms.txt before individual pages instead of loading a complete version index. # Module scope_stack > Scope stack storage and propagation helpers. Generated from `cargo doc --no-deps -p nemo-relay-builtins -p nemo-relay-diagnostics -p nemo-relay-logging -p nemo-relay-plugin-host -p nemo-relay-codecs -p nemo-relay -p nemo-relay-runtime -p nemo-relay-model-pricing -p nemo-relay-resource-metrics -p nemo-relay-observability -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker`. Scope stack storage and propagation helpers. The runtime tracks the current scope hierarchy through a shared [`ScopeStack`](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-scopestack) stored in task-local or thread-local state. Advanced callers can use this module to inspect the active scope chain or propagate scope context into worker threads. ## Structs * [PropagationContext](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-propagationcontext): Versioned, transport-neutral causal context for crossing a Relay boundary. * [ScopeStack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-scopestack): Mutable stack of active scopes plus their scope-local registries. * [ScopeStackEntry](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-scopestackentry): Identity of one entry in the visible Relay scope stack. * [ScopeStackSnapshot](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-scopestacksnapshot): Owned root-to-top values from one coherent read of a visible scope stack. * [ThreadScopeStackBinding](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-threadscopestackbinding): Captured thread-local scope stack binding. * [W3cTraceContext](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-w3ctracecontext): Validated W3C Trace Context retained internally across local stack forks. ## Statics * [TASK_SCOPE_STACK](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/static-task-scope-stack): Task-local scope stack handle used by async execution contexts. ## Functions * [active_event_trace_context](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-active-event-trace-context): Return trace propagation context for the current active event. * [active_event_uuid](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-active-event-uuid): Return the current active lifecycle event identity. * [capture_propagation_context](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-propagation-context): Capture the current causal parent and its Relay root when available. * [capture_propagation_context_with_root](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-propagation-context-with-root): Capture the current causal parent and an application-supplied session root. Without an imported W3C parent, the supplied root determines the receiver's trace. An imported W3C parent retains precedence over the Relay root. Passing `None` has the same behavior as [`capture_rootless_propagation_context`](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-rootless-propagation-context). * [capture_rootless_propagation_context](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-rootless-propagation-context): Capture the current causal parent without a root UUID. * [capture_thread_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-thread-scope-stack): Capture the current thread-local scope stack binding. * [capture_traceparent](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-traceparent): Capture the current canonical W3C `traceparent` value. * [create_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-create-scope-stack): Create a new scope stack handle with an implicit root scope. * [create_scope_stack_from_propagation](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-create-scope-stack-from-propagation): Create an isolated scope stack rooted below a supplied propagation context. * [current_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-current-scope-stack): Return the scope stack visible to the current execution context. * [current_scope_stack_override](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-current-scope-stack-override): Return the scope stack override installed on the current thread. * [current_scope_stack_snapshot](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-current-scope-stack-snapshot): Return detached identities from the calling context's explicitly active stack. * [explicit_thread_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-explicit-thread-scope-stack): Return the explicitly installed thread-local scope stack. * [fork_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-fork-scope-stack): Create an isolated scope stack below the current causal parent. * [install_scope_stack_override](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-install-scope-stack-override): Install `handle` as the scope stack override and return the previous one. * [propagate_scope_to_thread](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-propagate-scope-to-thread): Capture the current scope stack handle for use in another thread. * [restore_scope_stack_override](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-restore-scope-stack-override): Restore an override returned by [`install_scope_stack_override`](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-install-scope-stack-override). * [restore_thread_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-restore-thread-scope-stack): Restore a previously captured thread-local scope stack binding. * [scope_stack_active](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-scope-stack-active): Report whether the current context has an explicitly active scope stack. * [set_thread_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-set-thread-scope-stack): Install an explicit scope stack for the current thread. * [sync_thread_active_event_for_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-sync-thread-active-event-for-stack): Synchronize the task-local managed event onto an isolated thread stack. * [sync_thread_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-sync-thread-scope-stack): Synchronize the thread-local scope stack without marking it explicit. * [task_scope_push](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-task-scope-push): Push a scope handle onto the active stack. * [task_scope_remove](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-task-scope-remove): Remove a scope handle from the active stack. * [task_scope_top](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-task-scope-top): Clone the current top-most scope handle from the active stack. * [with_active_event_trace_context](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-with-active-event-trace-context): Bind trace context to an active event while polling an operation. * [with_active_event_uuid](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-with-active-event-uuid): Run a future with `uuid` as the causally active managed event. * [with_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-with-scope-stack): Run a synchronous callback with `handle` as the visible scope stack. * [with_task_scope_stack](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-with-task-scope-stack): Run a future with an explicit, task-local scope stack. ## Type Aliases * [ScopeStackHandle](/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/type-scopestackhandle): Shared handle type for the runtime scope stack. ## Docs - [Struct Propagation Context](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-propagationcontext.md): Versioned, transport-neutral causal context for crossing a Relay boundary. - [Struct Scope Stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-scopestack.md): Mutable stack of active scopes plus their scope-local registries. - [Struct Scope Stack Entry](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-scopestackentry.md): Identity of one entry in the visible Relay scope stack. - [Struct Scope Stack Snapshot](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-scopestacksnapshot.md): Owned root-to-top values from one coherent read of a visible scope stack. - [Struct Thread Scope Stack Binding](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-threadscopestackbinding.md): Captured thread-local scope stack binding. - [Struct W3cTrace Context](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/struct-w3ctracecontext.md): Validated W3C Trace Context retained internally across local stack forks. - [Static TASK_SCOPE_STACK](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/static-task-scope-stack.md): Task-local scope stack handle used by async execution contexts. - [Function active_event_trace_context](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-active-event-trace-context.md): Return trace propagation context for the current active event. - [Function active_event_uuid](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-active-event-uuid.md): Return the current active lifecycle event identity. - [Function capture_propagation_context](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-propagation-context.md): Capture the current causal parent and its Relay root when available. - [Function capture_propagation_context_with_root](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-propagation-context-with-root.md): Capture the current causal parent and an application-supplied session root. Without an imported W3C parent, the supplied root determines the receiver's trace. An imported W3C parent retains precedence over the Relay root. Passing `None` has the same behavior as `capture_rootless_propagation_context`. - [Function capture_rootless_propagation_context](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-rootless-propagation-context.md): Capture the current causal parent without a root UUID. - [Function capture_thread_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-thread-scope-stack.md): Capture the current thread-local scope stack binding. - [Function capture_traceparent](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-capture-traceparent.md): Capture the current canonical W3C `traceparent` value. - [Function create_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-create-scope-stack.md): Create a new scope stack handle with an implicit root scope. - [Function create_scope_stack_from_propagation](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-create-scope-stack-from-propagation.md): Create an isolated scope stack rooted below a supplied propagation context. - [Function current_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-current-scope-stack.md): Return the scope stack visible to the current execution context. - [Function current_scope_stack_override](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-current-scope-stack-override.md): Return the scope stack override installed on the current thread. - [Function current_scope_stack_snapshot](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-current-scope-stack-snapshot.md): Return detached identities from the calling context's explicitly active stack. - [Function explicit_thread_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-explicit-thread-scope-stack.md): Return the explicitly installed thread-local scope stack. - [Function fork_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-fork-scope-stack.md): Create an isolated scope stack below the current causal parent. - [Function install_scope_stack_override](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-install-scope-stack-override.md): Install `handle` as the scope stack override and return the previous one. - [Function propagate_scope_to_thread](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-propagate-scope-to-thread.md): Capture the current scope stack handle for use in another thread. - [Function restore_scope_stack_override](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-restore-scope-stack-override.md): Restore an override returned by `install_scope_stack_override`. - [Function restore_thread_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-restore-thread-scope-stack.md): Restore a previously captured thread-local scope stack binding. - [Function scope_stack_active](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-scope-stack-active.md): Report whether the current context has an explicitly active scope stack. - [Function set_thread_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-set-thread-scope-stack.md): Install an explicit scope stack for the current thread. - [Function sync_thread_active_event_for_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-sync-thread-active-event-for-stack.md): Synchronize the task-local managed event onto an isolated thread stack. - [Function sync_thread_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-sync-thread-scope-stack.md): Synchronize the thread-local scope stack without marking it explicit. - [Function task_scope_push](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-task-scope-push.md): Push a scope handle onto the active stack. - [Function task_scope_remove](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-task-scope-remove.md): Remove a scope handle from the active stack. - [Function task_scope_top](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-task-scope-top.md): Clone the current top-most scope handle from the active stack. - [Function with_active_event_trace_context](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-with-active-event-trace-context.md): Bind trace context to an active event while polling an operation. - [Function with_active_event_uuid](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-with-active-event-uuid.md): Run a future with `uuid` as the causally active managed event. - [Function with_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-with-scope-stack.md): Run a synchronous callback with `handle` as the visible scope stack. - [Function with_task_scope_stack](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/fn-with-task-scope-stack.md): Run a future with an explicit, task-local scope stack. - [Type Alias Scope Stack Handle](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-runtime/api/runtime/scope_stack/type-scopestackhandle.md): Shared handle type for the runtime scope stack.