@@ -136,18 +136,16 @@ async fn drive(
136136// Session init + call-log helpers
137137// ─────────────────────────────────────────────────────────────────────────────
138138
139- fn call_log_path ( tag : & str ) -> String {
140- let p = std:: env:: temp_dir ( ) . join ( format ! (
141- "buzz_perm_calllog_{tag}_{}_{:x}.log" ,
142- std:: process:: id( ) ,
143- std:: time:: SystemTime :: now( )
144- . duration_since( std:: time:: UNIX_EPOCH )
145- . unwrap_or_default( )
146- . as_nanos( )
147- ) ) ;
148- let s = p. to_string_lossy ( ) . to_string ( ) ;
149- let _ = std:: fs:: remove_file ( & s) ;
150- s
139+ /// A fresh call-log path inside its own temp dir. Keep the returned `TempDir`
140+ /// bound for the whole test: dropping it deletes the log, including when an
141+ /// assertion panics.
142+ fn call_log_path ( tag : & str ) -> ( tempfile:: TempDir , String ) {
143+ let dir = tempfile:: Builder :: new ( )
144+ . prefix ( & format ! ( "buzz_perm_calllog_{tag}_" ) )
145+ . tempdir ( )
146+ . expect ( "create call-log temp dir" ) ;
147+ let path = dir. path ( ) . join ( "calls.log" ) . to_string_lossy ( ) . into_owned ( ) ;
148+ ( dir, path)
151149}
152150
153151/// Invoked tool names recorded by fake_mcp (bare names, one per `tools/call`).
@@ -214,7 +212,7 @@ fn stop_reason(resp: &Value) -> String {
214212/// the tally ends at one.
215213#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
216214async fn test_allow_reaches_tool_exactly_once_and_not_before_approval ( ) {
217- let log = call_log_path ( "allow" ) ;
215+ let ( _log_dir , log) = call_log_path ( "allow" ) ;
218216 let llm = spawn_capturing_llm ( vec ! [ shell_call( "tc1" ) , openai_text( "done" ) ] ) . await ;
219217 let mut h = Harness :: spawn ( & llm. url ) . await ;
220218 let sid = init (
@@ -250,7 +248,7 @@ async fn test_allow_reaches_tool_exactly_once_and_not_before_approval() {
250248/// sees a permission-denied tool error (the turn continues to `end_turn`).
251249#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
252250async fn test_reject_option_never_invokes_tool ( ) {
253- let log = call_log_path ( "reject" ) ;
251+ let ( _log_dir , log) = call_log_path ( "reject" ) ;
254252 let llm = spawn_capturing_llm ( vec ! [ shell_call( "tc1" ) , openai_text( "understood" ) ] ) . await ;
255253 let mut h = Harness :: spawn ( & llm. url ) . await ;
256254 let sid = init (
@@ -321,7 +319,7 @@ async fn test_adversarial_outcomes_never_invoke_tool() {
321319 ] ;
322320
323321 for ( tag, build) in shapes {
324- let log = call_log_path ( tag) ;
322+ let ( _log_dir , log) = call_log_path ( tag) ;
325323 let llm = spawn_capturing_llm ( vec ! [ shell_call( "tc1" ) , openai_text( "ok" ) ] ) . await ;
326324 let mut h = Harness :: spawn ( & llm. url ) . await ;
327325 let sid = init (
@@ -352,7 +350,7 @@ async fn test_adversarial_outcomes_never_invoke_tool() {
352350/// waiter; the correct id then authorizes exactly once.
353351#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
354352async fn test_stale_id_ignored_then_real_id_authorizes ( ) {
355- let log = call_log_path ( "staleid" ) ;
353+ let ( _log_dir , log) = call_log_path ( "staleid" ) ;
356354 let llm = spawn_capturing_llm ( vec ! [ shell_call( "tc1" ) , openai_text( "done" ) ] ) . await ;
357355 let mut h = Harness :: spawn ( & llm. url ) . await ;
358356 let sid = init (
@@ -406,7 +404,7 @@ async fn test_stale_id_ignored_then_real_id_authorizes() {
406404/// by staying silent, and cancellation must not depend on that answer.
407405#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
408406async fn test_cancel_while_waiting_executes_nothing_without_client_answer ( ) {
409- let log = call_log_path ( "cancelwait" ) ;
407+ let ( _log_dir , log) = call_log_path ( "cancelwait" ) ;
410408 let llm = spawn_capturing_llm ( vec ! [ shell_call( "tc1" ) , openai_text( "done" ) ] ) . await ;
411409 let mut h = Harness :: spawn ( & llm. url ) . await ;
412410 let sid = init (
@@ -452,7 +450,7 @@ async fn test_cancel_while_waiting_executes_nothing_without_client_answer() {
452450/// proves only the allowed (second) call reached MCP — order-agnostic.
453451#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
454452async fn test_crossed_parallel_decisions_authorize_only_matching_call ( ) {
455- let log = call_log_path ( "crossed" ) ;
453+ let ( _log_dir , log) = call_log_path ( "crossed" ) ;
456454 // Two distinct registered tools so the call log distinguishes them by name.
457455 let llm = spawn_capturing_llm ( vec ! [
458456 openai_tool_calls( & [
@@ -547,7 +545,7 @@ async fn test_load_skill_emits_no_permission_request() {
547545/// objects once, forcing a hook invocation the test can observe.
548546#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
549547async fn test_stop_hook_reaches_mcp_without_permission_ask ( ) {
550- let log = call_log_path ( "stophook" ) ;
548+ let ( _log_dir , log) = call_log_path ( "stophook" ) ;
551549 // Text turn triggers the _Stop gate → hook objects once → agent loops →
552550 // second text turn, hook silent → end_turn. No model-issued tool call.
553551 let llm = spawn_capturing_llm ( vec ! [
@@ -599,7 +597,7 @@ async fn test_stop_hook_reaches_mcp_without_permission_ask() {
599597/// with an end-to-end proof that the negotiated version reaches the wire.
600598#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
601599async fn test_v2_negotiation_emits_v2_request_shape ( ) {
602- let log = call_log_path ( "v2shape" ) ;
600+ let ( _log_dir , log) = call_log_path ( "v2shape" ) ;
603601 let llm = spawn_capturing_llm ( vec ! [ shell_call( "tc1" ) , openai_text( "done" ) ] ) . await ;
604602 let mut h = Harness :: spawn ( & llm. url ) . await ;
605603 let sid = init (
0 commit comments