1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
//! Development tools for graph execution.
//!
//! The [`DevToolsPlugin`] injects [`SystemInfo`] before each system runs,
//! providing execution context for debugging and observability. It can
//! optionally emit `tracing::debug!` logs for all graph execution events.
//!
//! # Example
//!
//! ```
//! use polaris_graph::dev::SystemInfo;
//! use polaris_system::param::Res;
//! use polaris_system::system;
//!
//! #[system]
//! async fn my_system(info: Res<SystemInfo>) {
//! tracing::info!(
//! "Executing system '{}' on node {:?}",
//! info.system_name(),
//! info.node_id()
//! );
//! }
//! ```
//!
//! # Setup
//!
//! Add `DevToolsPlugin` to your server:
//!
//! ```
//! use polaris_graph::dev::DevToolsPlugin;
//! use polaris_system::server::Server;
//!
//! let mut server = Server::new();
//! // Default: SystemInfo injection only
//! server.add_plugins(DevToolsPlugin::default());
//! ```
//!
//! Or with event tracing enabled:
//!
//! ```
//! use polaris_graph::dev::DevToolsPlugin;
//! use polaris_system::server::Server;
//!
//! let mut server = Server::new();
//! server.add_plugins(DevToolsPlugin::new().with_event_tracing());
//! ```
//!
//! # Validation
//!
//! `SystemInfo` is recognized as a hook-provided resource. Systems that declare
//! `Res<SystemInfo>` will not fail resource validation, as we leverage
//! `register_provider` api to track provided resource types.
use crateHooksAPI;
use crateGraphEvent;
use crate;
use crateNodeId;
use ;
use LocalResource;
use Server;
/// Execution context injected by [`DevToolsPlugin`] before each system runs.
///
/// This resource provides information about the currently executing system,
/// useful for logging, debugging, and observability.
///
/// # Thread Safety
///
/// `SystemInfo` is a [`LocalResource`], meaning each execution context has
/// its own copy. It is updated by the [`DevToolsPlugin`] hook before each
/// system call.
/// Plugin that injects [`SystemInfo`] before each system execution.
///
/// This plugin registers a hook on [`OnSystemStart`] that injects a
/// [`SystemInfo`] resource into the context, making execution metadata
/// available to systems via `Res<SystemInfo>`.
///
/// When event tracing is enabled via [`with_event_tracing`](Self::with_event_tracing),
/// it also registers an observer on all graph execution schedules that emits
/// `tracing::debug!` logs for each event.
///
/// # Resources Provided
///
/// | Resource | Scope | Description |
/// |----------|-------|-------------|
/// | [`SystemInfo`] | Local | Per-system execution metadata (node id, system name); inserted by the `OnSystemStart` hook on every system invocation |
///
/// # APIs Provided
///
/// | API | Description |
/// |-----|-------------|
/// | _none_ | This plugin only registers hooks against [`HooksAPI`]; it inserts no APIs of its own. |
///
/// # Dependencies
///
/// Requires [`HooksAPI`] from `polaris_graph`.
/// Inserts it if not already present on the server.
///
/// # Hooks Registered
///
/// Registered via [`HooksAPI`].
///
/// | Schedule | Description |
/// |----------|-------------|
/// | `OnSystemStart` | `devtools_system_info` — a provider hook that injects a [`SystemInfo`] resource into the context before each system runs. |
/// | `AllGraphSchedules` | `devtools_event_trace` — an observer that logs every graph execution event via `tracing::debug!`. Registered only when [`with_event_tracing`](Self::with_event_tracing) is enabled. |
///
/// # Extends
///
/// - [`HooksAPI`] — registers the hooks above.
/// Inserts the API itself if no other plugin provided it.
///
/// # Example
///
/// ```
/// use polaris_graph::dev::DevToolsPlugin;
/// use polaris_system::server::Server;
///
/// let mut server = Server::new();
/// server.add_plugins(DevToolsPlugin::new().with_event_tracing());
/// ```