You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Overview
Update the Architecture page to reflect current runtime ownership and delivery behavior.
- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.
#### Details
- Show the CLI and language bindings as hosts of the shared Relay runtime.
- Show plugin components as configuration-installed behavior instead of presenting Adaptive as a peer layer.
- Separate the active scope stack from parent-linked event records.
- Distinguish awaited async middleware from background subscriber delivery.
- Add concrete middleware and exporter examples at first mention and remove the generic related-links section.
#### Where should the reviewer start?
Start with the architecture diagram and the middleware and subscriber sections in `docs/about-nemo-relay/architecture.mdx`.
#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
- Closes [RELAY-621](https://linear.app/nvidia/issue/RELAY-621/update-the-architecture-page-around-current-runtime-ownership)
## Summary by CodeRabbit
* **Documentation**
* Expanded architecture guidance for CLI and runtime integration.
* Clarified plugin components, middleware behavior, observability, guardrails, event handling, scopes, and managed execution.
* Added diagrams for scope stacks, middleware resolution, and managed calls.
* Documented parent-linked events and asynchronous subscriber delivery.
* Updated terminology and related links for improved clarity.
* Removed outdated sections and streamlined the overall architecture reference.
Authors:
- Alex Fournier (https://github.com/afourniernv)
- Will Killian (https://github.com/willkill07)
Approvers:
- https://github.com/lvojtku
- Will Killian (https://github.com/willkill07)
URL: #697
Adaptive appears here as a built-in plugin component rather than a separate runtime model because it activates through the same plugin lifecycle.
97
+
Adaptive behavior is one plugin component installed through the same lifecycle
98
+
as observability or PII redaction. It is not a separate runtime layer.
88
99
89
100
## Runtime Model
90
101
91
-
NeMo Relay combines a small number of runtime pieces into one shared execution model:
92
-
93
-
- The **scope stack** answers where work belongs
94
-
- The **middleware registries** answer what should happen around that work
95
-
- The **plugin system** installs reusable runtime behavior from configuration
96
-
- The **event stream** records what happened
97
-
- The **async subscriber dispatcher** delivers event snapshots after emission
98
-
-**subscribers** consume those events
99
-
100
-
Every emitted scope, tool, LLM, or mark event attaches to the active scope stack. Every managed tool or LLM call resolves the currently visible middleware before it executes.
102
+
NeMo Relay combines a small number of runtime pieces into one shared execution
103
+
model:
104
+
105
+
- The [**scope stack**](/about-nemo-relay/concepts/scopes) answers where work
106
+
currently belongs.
107
+
- The [**middleware registries**](/about-nemo-relay/concepts/middleware) answer
108
+
what should happen around that work.
109
+
- The [**plugin system**](/about-nemo-relay/concepts/plugins) installs reusable
110
+
runtime behavior from configuration.
111
+
- The [**event records**](/about-nemo-relay/concepts/events) preserve what
112
+
happened and how work was related.
113
+
- The [**async subscriber dispatcher**](/about-nemo-relay/concepts/subscribers#waiting-for-delivery)
114
+
delivers event snapshots after emission.
115
+
-[**Subscribers and exporters**](/about-nemo-relay/concepts/subscribers#common-subscriber-roles)
116
+
consume those snapshots.
117
+
118
+
Every managed tool or LLM call resolves the middleware visible from the active
119
+
scope before it executes. When the runtime emits an event, it records the active
120
+
scope UUID as parentage. The scope stack changes as work opens and closes; the
121
+
parent-linked event records remain available to subscribers.
101
122
102
123
## Main Runtime Pieces
103
124
104
125
These components are the primary building blocks that make up the runtime model.
105
126
106
127
### Scope Stack
107
128
108
-
The active scope stack defines the ownership tree for runtime work. It establishes:
129
+
The active scope stack defines the current context for runtime work.
130
+
It establishes:
109
131
110
132
- Parent-child relationships between events
111
133
- Scope-local visibility for middleware and subscribers
@@ -114,21 +136,54 @@ The active scope stack defines the ownership tree for runtime work. It establish
114
136
115
137
### Middleware Registries
116
138
117
-
The middleware registries hold the active intercepts and guardrails for tool and LLM execution. Managed helpers read those registries before invoking the real callback.
139
+
The middleware registries hold the active intercepts and guardrails for tool and
140
+
LLM execution. Request intercepts can rewrite real requests, conditional
141
+
guardrails can reject execution, and sanitize guardrails can change emitted
142
+
observability payloads. Managed helpers read those registries before invoking
143
+
the real callback.
144
+
145
+
Async middleware callbacks are awaited as part of managed execution. The
146
+
managed call does not advance past that middleware callback until the callback
147
+
returns.
118
148
119
149
### Plugin System
120
150
121
-
The plugin system installs reusable runtime components from configuration. A plugin can register middleware, subscribers, or related behavior without requiring each application call site to do the work manually.
151
+
The plugin system installs reusable runtime components from configuration. A
152
+
plugin can register middleware, subscribers, or related behavior without
153
+
requiring each application call site to repeat the setup.
122
154
123
155
### Event Emission
124
156
125
-
The runtime emits structured events for scopes, tools, LLMs, and named marks. Those events are the canonical record of runtime behavior. Native Rust, Python, Node.js, and FFI event-producing APIs enqueue subscriber work and return without waiting for subscriber callbacks or exporter work.
157
+
The runtime emits structured events for scopes, tools, LLMs, and named marks.
158
+
Those parent-linked records are the canonical history of runtime behavior.
159
+
Native Rust, Python, Node.js, and FFI event-producing APIs enqueue subscriber
160
+
work and return without waiting for subscriber callbacks or exporter work.
126
161
127
162
### Subscribers and Exporters
128
163
129
-
Subscribers consume the event stream through the background dispatcher. Some subscribers stay in-process. Others export that stream into files or tracing systems. Use the binding flush API when a test or shutdown path must wait for already-queued subscriber work.
130
-
131
-
## Two Axes of Runtime State
164
+
Subscribers consume event snapshots through the background dispatcher. Some
165
+
stay in process. Exporter subscribers can write
166
+
[ATOF JSONL](/configure-plugins/observability/atof), project events into
167
+
[ATIF trajectories](/configure-plugins/observability/atif), or emit
- Sanitize guardrails affect the emitted observability payload
169
326
170
-
For the expanded request-to-response runtime path, including streaming and subscriber handoff, refer to [Middleware](/about-nemo-relay/concepts/middleware#detailed-execution-flow).
171
-
172
-
## Runtime Layers
173
-
174
-
From bottom to top, NeMo Relay is organized as:
175
-
176
-
1. The Rust core runtime
177
-
2. The plugin and adaptive layer
178
-
3. Language bindings
179
-
4. Framework integrations and application code
180
-
5. Subscribers and observability backends
181
-
182
-
The details of a binding can vary, but the conceptual model stays the same across those layers.
183
-
184
-
## Design Goal
185
-
186
-
NeMo Relay is designed so that application developers, framework integrators, plugin authors, and observability consumers all reason about the same runtime semantics. One conceptual model should remain stable even when the binding or integration style changes.
187
-
188
-
## Related Concepts
189
-
190
-
The following concepts are related to this architecture:
0 commit comments