Commit 47c3651
Migrate session manager to DataStorage and add RestoreSession (#4464)
* Migrate session manager to DataStorage and add RestoreSession
Replace the *transportsession.Manager dependency in sessionmanager.Manager
with the DataStorage interface (introduced in split PR 1), enabling pluggable
session metadata storage (local or Redis) without coupling live session state
to the serialization layer.
Key changes:
- Add Exists() to the Storage interface with implementations for LocalStorage
and RedisStorage; expose TTL() and Exists() on transportsession.Manager
- Add RestoreSession() to MultiSessionFactory (and decorating/mock impls);
refactor makeSession → makeBaseSession so RestoreSession can reconstruct a
live session from stored metadata without a bearer token
- Add RestoreHijackPrevention() in pkg/vmcp/session/internal/security to
recreate the hijack-prevention decorator from stored hash/salt
- Rewrite sessionmanager.Manager to use DataStorage: node-local multiSessions
sync.Map for hot-path lookups, singleflight-deduplicated RestoreSession on
cache miss, and a background eviction loop that probes storage.Exists() to
clean up expired MultiSession objects whose Redis TTL fired silently
- Replace *transportsession.Manager in discovery.Middleware with a
MultiSessionGetter interface backed by the session manager; remove the 401
for unknown sessions — the SDK now responds 404 via Validate()
- Wire server.go to create LocalSessionDataStorage and pass it to
sessionmanager.New; route discovery middleware through vmcpSessionMgr
Closes: #4220
* fixes from review
---------
Co-authored-by: taskbot <taskbot@users.noreply.github.com>1 parent c3fadd1 commit 47c3651
19 files changed
Lines changed: 2052 additions & 363 deletions
File tree
- pkg/vmcp
- discovery
- server
- sessionmanager
- session
- internal/security
- mocks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
| |||
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
90 | | - | |
| 95 | + | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
| |||
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
105 | | - | |
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| |||
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| 118 | + | |
114 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
115 | 124 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 125 | + | |
| 126 | + | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
| |||
257 | 261 | | |
258 | 262 | | |
259 | 263 | | |
260 | | - | |
| 264 | + | |
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
264 | 268 | | |
265 | | - | |
266 | | - | |
| 269 | + | |
| 270 | + | |
267 | 271 | | |
268 | 272 | | |
269 | 273 | | |
270 | 274 | | |
271 | 275 | | |
272 | 276 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
298 | 283 | | |
299 | | - | |
| 284 | + | |
300 | 285 | | |
301 | | - | |
| 286 | + | |
302 | 287 | | |
303 | 288 | | |
304 | 289 | | |
| |||
309 | 294 | | |
310 | 295 | | |
311 | 296 | | |
312 | | - | |
| 297 | + | |
313 | 298 | | |
314 | 299 | | |
315 | 300 | | |
| |||
319 | 304 | | |
320 | 305 | | |
321 | 306 | | |
322 | | - | |
| 307 | + | |
323 | 308 | | |
324 | 309 | | |
325 | 310 | | |
| |||
329 | 314 | | |
330 | 315 | | |
331 | 316 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | 317 | | |
340 | 318 | | |
341 | 319 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
32 | 45 | | |
33 | 46 | | |
34 | 47 | | |
| |||
134 | 147 | | |
135 | 148 | | |
136 | 149 | | |
137 | | - | |
| 150 | + | |
138 | 151 | | |
139 | 152 | | |
140 | 153 | | |
| |||
186 | 199 | | |
187 | 200 | | |
188 | 201 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | 202 | | |
193 | 203 | | |
194 | 204 | | |
| |||
198 | 208 | | |
199 | 209 | | |
200 | 210 | | |
201 | | - | |
202 | 211 | | |
203 | 212 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
| |||
254 | 257 | | |
255 | 258 | | |
256 | 259 | | |
257 | | - | |
| 260 | + | |
258 | 261 | | |
259 | 262 | | |
260 | 263 | | |
| |||
295 | 298 | | |
296 | 299 | | |
297 | 300 | | |
298 | | - | |
| 301 | + | |
299 | 302 | | |
300 | 303 | | |
301 | 304 | | |
| |||
396 | 399 | | |
397 | 400 | | |
398 | 401 | | |
399 | | - | |
| 402 | + | |
400 | 403 | | |
401 | 404 | | |
402 | 405 | | |
| |||
461 | 464 | | |
462 | 465 | | |
463 | 466 | | |
464 | | - | |
| 467 | + | |
465 | 468 | | |
466 | 469 | | |
467 | 470 | | |
| |||
513 | 516 | | |
514 | 517 | | |
515 | 518 | | |
516 | | - | |
| 519 | + | |
517 | 520 | | |
518 | 521 | | |
519 | 522 | | |
| |||
0 commit comments