Commit 88e7f1c
committed
feat(guest-agent,orchestrator): generalize op_id to all guest agent communications
Every request now carries an op_id (auto-generated UUID4 hex on the Python
side), and every response echoes it back. The Rust guest-agent extracts
op_id from raw JSON before serde deserialization (two-phase parse), then
injects it into all outgoing messages via a new ResponseWriter struct
(using entry().or_insert_with() to preserve existing op_id on file
transfer responses). On the Python side, DualPortChannel._with_op_id()
context manager handles op_id generation, queue registration, command
dispatch, and cleanup — used by both send_request() and stream_messages().
This eliminates the shared default queue that caused stale messages (e.g.
PongMessage from reconnection probes) to pollute subsequent operations.
Key changes:
- Rust: ResponseWriter wraps mpsc::Sender + op_id, replaces direct
send_response/send_streaming_error calls in all handler paths
- Rust: Remove dead CmdError::Reply.op_id field, with_op_id() method,
and CmdError::io() second parameter (ResponseWriter handles injection)
- Rust: Remove ActiveWriteHandle.op_id field and unused write_tx param
from handle_write_file
- Python: GuestAgentRequest base gets optional op_id; GuestAgentResponse
base class added with optional op_id for all response types
- Python: FileOpDispatcher routes ALL messages by op_id; _default_queue,
get_default_message(), stream_events() removed as dead code
- Python: Messages without op_id logged and discarded (prevents memory leak)
- Python: ValidationError guard in dispatch loop prevents malformed
messages from killing all routing
- Python: RuntimeError added to _probe_guest_ready exception tuple
- Python: Remove send_raw_request from both GuestChannel protocol and
implementations (replaced by op_id-routed send_request)
- Python: OP_QUEUE_DEPTH=64 constant for bounded per-op queues1 parent b0673ae commit 88e7f1c
10 files changed
Lines changed: 1024 additions & 630 deletions
File tree
- guest-agent/src
- repl
- src/exec_sandbox
- tests
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
| |||
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
152 | | - | |
| 151 | + | |
153 | 152 | | |
154 | | - | |
155 | | - | |
156 | | - | |
| 153 | + | |
| 154 | + | |
157 | 155 | | |
158 | 156 | | |
159 | | - | |
| 157 | + | |
160 | 158 | | |
161 | 159 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
168 | 163 | | |
169 | 164 | | |
170 | 165 | | |
171 | 166 | | |
172 | 167 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
177 | 171 | | |
178 | 172 | | |
179 | 173 | | |
180 | 174 | | |
181 | | - | |
| 175 | + | |
182 | 176 | | |
183 | 177 | | |
184 | | - | |
185 | | - | |
186 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
187 | 181 | | |
188 | 182 | | |
189 | 183 | | |
190 | 184 | | |
191 | 185 | | |
192 | 186 | | |
193 | | - | |
194 | | - | |
| 187 | + | |
195 | 188 | | |
196 | 189 | | |
197 | 190 | | |
198 | 191 | | |
199 | | - | |
| 192 | + | |
200 | 193 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 194 | + | |
| 195 | + | |
208 | 196 | | |
209 | 197 | | |
210 | 198 | | |
211 | 199 | | |
212 | 200 | | |
213 | 201 | | |
214 | 202 | | |
215 | | - | |
| 203 | + | |
216 | 204 | | |
217 | 205 | | |
218 | 206 | | |
219 | | - | |
220 | | - | |
221 | | - | |
| 207 | + | |
| 208 | + | |
222 | 209 | | |
223 | 210 | | |
224 | | - | |
225 | | - | |
226 | | - | |
| 211 | + | |
| 212 | + | |
227 | 213 | | |
228 | 214 | | |
229 | | - | |
230 | | - | |
231 | | - | |
| 215 | + | |
| 216 | + | |
232 | 217 | | |
233 | 218 | | |
234 | 219 | | |
235 | | - | |
236 | | - | |
237 | | - | |
| 220 | + | |
| 221 | + | |
238 | 222 | | |
239 | 223 | | |
240 | 224 | | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 225 | + | |
245 | 226 | | |
246 | 227 | | |
247 | 228 | | |
248 | 229 | | |
249 | 230 | | |
250 | | - | |
| 231 | + | |
251 | 232 | | |
252 | 233 | | |
253 | 234 | | |
| |||
264 | 245 | | |
265 | 246 | | |
266 | 247 | | |
267 | | - | |
268 | | - | |
269 | | - | |
| 248 | + | |
| 249 | + | |
270 | 250 | | |
271 | 251 | | |
272 | | - | |
273 | | - | |
274 | | - | |
| 252 | + | |
| 253 | + | |
275 | 254 | | |
276 | 255 | | |
277 | 256 | | |
| |||
281 | 260 | | |
282 | 261 | | |
283 | 262 | | |
284 | | - | |
285 | 263 | | |
286 | | - | |
287 | | - | |
288 | | - | |
| 264 | + | |
| 265 | + | |
289 | 266 | | |
290 | 267 | | |
291 | | - | |
292 | | - | |
293 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
294 | 271 | | |
295 | 272 | | |
296 | 273 | | |
297 | 274 | | |
298 | 275 | | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
| 276 | + | |
303 | 277 | | |
304 | 278 | | |
305 | 279 | | |
| |||
308 | 282 | | |
309 | 283 | | |
310 | 284 | | |
311 | | - | |
| 285 | + | |
312 | 286 | | |
313 | 287 | | |
314 | 288 | | |
| |||
319 | 293 | | |
320 | 294 | | |
321 | 295 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
| 296 | + | |
326 | 297 | | |
327 | 298 | | |
328 | 299 | | |
| |||
391 | 362 | | |
392 | 363 | | |
393 | 364 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | 365 | | |
401 | 366 | | |
402 | 367 | | |
403 | 368 | | |
404 | | - | |
405 | 369 | | |
406 | 370 | | |
407 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
118 | | - | |
| 117 | + | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
| |||
227 | 226 | | |
228 | 227 | | |
229 | 228 | | |
230 | | - | |
231 | | - | |
232 | | - | |
| 229 | + | |
| 230 | + | |
233 | 231 | | |
234 | | - | |
235 | | - | |
236 | | - | |
| 232 | + | |
| 233 | + | |
237 | 234 | | |
238 | 235 | | |
239 | 236 | | |
240 | | - | |
241 | | - | |
242 | | - | |
| 237 | + | |
| 238 | + | |
243 | 239 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 240 | + | |
| 241 | + | |
247 | 242 | | |
248 | 243 | | |
249 | | - | |
250 | | - | |
251 | | - | |
| 244 | + | |
| 245 | + | |
252 | 246 | | |
253 | 247 | | |
254 | 248 | | |
255 | 249 | | |
256 | | - | |
257 | | - | |
258 | | - | |
| 250 | + | |
| 251 | + | |
259 | 252 | | |
260 | 253 | | |
261 | 254 | | |
| |||
0 commit comments