[IsolationSession] A failing concurrent one-shot Rust test can leave a session's agent account on the host
Relevant area(s)
Windows
Brief description of your issue
concurrent_one_shot_runs_stay_isolated (src/mxc-sdk/tests/isolation_session.rs) runs its sessions on worker threads and joins them only after its last check. If the test fails before then, or a worker panics, some workers are never joined, and the test binary can exit while a session is still held. Process exit runs no other thread's destructors, so that session's agent account stays on the host.
Steps to reproduce
Read from the code at d22e3515; not run.
- The main thread's
expectcalls before the join loop, such as "every run must report that it started", panic without joining the workers. - Its dropped channel ends make waiting workers panic and drop their sandbox handles, which starts each session's teardown, but nothing waits for it, and a worker still reading its output keeps its session.
- The join loop's
expect("a run thread must not panic")stops at the first worker that panicked and leaves the rest unjoined.
Expected behavior
A failing run of the test ends every session it started before the test binary exits.
Actual behavior
A session can still be held when the test binary exits, leaving its agent account on the host.
[AgentAssisted] A possible fix: on any failure, release the runs that are still held, then join every worker with a bounded wait, continuing past one that panicked, and only then fail the test.