Commit f54a1ad
committed
address copilot R2: guard against cross-root cache reuse + fix test wording
R2 caught a remaining footgun: a cache populated against rootA could
short-circuit a later call against rootB via known.has(sid), returning
silently-wrong results. AutoReply doesn't do this (fresh Set per make
call), but future ACP/TUI callers might.
Fix: at call entry, if opts.cache is non-empty AND does not already
contain the supplied root, die with a clear error message naming the
expected root and the cache size. JSDoc updated to spell out the
not-shared-across-roots invariant.
Also tightened the auto-seed-empty-cache test comment: the failure mode
without the auto-seed is walking PAST root (root.has(root) is false in
an empty cache) and bottoming out, not necessarily a NotFoundError.
New regression test: 'dies if cache is non-empty but missing root'
populates a cache under rootA then asserts a subsequent rootB call
dies.
PR feedback: #16
- comment 3163694330 (cross-root cache aliasing)
- comment 3163694378 (test wording nit)1 parent 935f474 commit f54a1ad
2 files changed
Lines changed: 46 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
386 | | - | |
387 | | - | |
388 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
389 | 392 | | |
390 | 393 | | |
391 | 394 | | |
| |||
695 | 698 | | |
696 | 699 | | |
697 | 700 | | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
698 | 713 | | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
| 714 | + | |
703 | 715 | | |
704 | 716 | | |
705 | 717 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
309 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
310 | 311 | | |
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
317 | 342 | | |
0 commit comments