> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/relay/_mcp/server. # Module scope_stack > Scope stack storage and propagation helpers. Generated from `cargo doc --no-deps -p nemo-relay -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/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/api/runtime/scope_stack/struct-propagationcontext): Versioned, transport-neutral causal context for crossing a Relay boundary. * [ScopeStack](/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/struct-scopestack): Mutable stack of active scopes plus their scope-local registries. * [ScopeStackEntry](/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/struct-scopestackentry): Identity of one entry in the visible Relay scope stack. * [ScopeStackSnapshot](/reference/api/rust-library-reference/nemo-relay/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/api/runtime/scope_stack/struct-threadscopestackbinding): Captured thread-local scope stack binding. ## Statics * [TASK_SCOPE_STACK](/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/static-task-scope-stack): Task-local scope stack handle used by async execution contexts. ## Functions * [capture_propagation_context](/reference/api/rust-library-reference/nemo-relay/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/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/api/runtime/scope_stack/fn-capture-rootless-propagation-context). * [capture_rootless_propagation_context](/reference/api/rust-library-reference/nemo-relay/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/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/api/runtime/scope_stack/fn-capture-traceparent): Capture the current canonical W3C `traceparent` value. * [create_scope_stack](/reference/api/rust-library-reference/nemo-relay/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/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/api/runtime/scope_stack/fn-current-scope-stack): Return the scope stack visible to the current execution context. * [current_scope_stack_snapshot](/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-current-scope-stack-snapshot): Return detached identities from the calling context's explicitly active stack. * [fork_scope_stack](/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-fork-scope-stack): Create an isolated scope stack below the current causal parent. * [propagate_scope_to_thread](/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-propagate-scope-to-thread): Capture the current scope stack handle for use in another thread. * [restore_thread_scope_stack](/reference/api/rust-library-reference/nemo-relay/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/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/api/runtime/scope_stack/fn-set-thread-scope-stack): Install an explicit scope stack for the current thread. * [sync_thread_scope_stack](/reference/api/rust-library-reference/nemo-relay/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/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/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/api/runtime/scope_stack/fn-task-scope-top): Clone the current top-most scope handle from the active stack. * [with_active_event_uuid](/reference/api/rust-library-reference/nemo-relay/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/api/runtime/scope_stack/fn-with-scope-stack): Run a synchronous callback with `handle` as the visible scope stack. ## Type Aliases * [ScopeStackHandle](/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/type-scopestackhandle): Shared handle type for the runtime scope stack. > Scope stack storage and propagation helpers. ## Docs - [Struct Propagation Context](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/struct-threadscopestackbinding.md): Captured thread-local scope stack binding. - [Static TASK_SCOPE_STACK](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/static-task-scope-stack.md): Task-local scope stack handle used by async execution contexts. - [Function capture_propagation_context](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-current-scope-stack.md): Return the scope stack visible to the current execution context. - [Function current_scope_stack_snapshot](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-current-scope-stack-snapshot.md): Return detached identities from the calling context's explicitly active stack. - [Function fork_scope_stack](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-fork-scope-stack.md): Create an isolated scope stack below the current causal parent. - [Function propagate_scope_to_thread](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-propagate-scope-to-thread.md): Capture the current scope stack handle for use in another thread. - [Function restore_thread_scope_stack](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-set-thread-scope-stack.md): Install an explicit scope stack for the current thread. - [Function sync_thread_scope_stack](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-task-scope-top.md): Clone the current top-most scope handle from the active stack. - [Function with_active_event_uuid](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/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/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-with-scope-stack.md): Run a synchronous callback with `handle` as the visible scope stack. - [Type Alias Scope Stack Handle](https://docs.nvidia.com/nemo/relay/v0.11.0/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/type-scopestackhandle.md): Shared handle type for the runtime scope stack.