test: make fs-lock nonblocking proof scheduler-tolerant

Merged
LL
2mo ago
+20-6

Summary

The latest main Tests workflow failed on Windows in fs_lock::tests::try_acquire_once_never_waits_behind_live_owner because the test used a 250 ms wall-clock ceiling as proof that a zero-timeout lock attempt did not wait behind its live owner.

The failure is consistent with loaded Windows scheduling and the synchronous tasklist liveness probe; the log establishes only that the old 250 ms bound was exceeded.

This replaces that machine-speed assertion with the lock property itself:

  • keep the owner lease live
  • start a contender worker and wait for an explicit start handshake
  • require the result through a bounded channel while the owner remains held
  • distinguish worker disconnection from timeout
  • on timeout, drop the owner only for cleanup, then use a second bounded wait instead of an unbounded join

A contender that waits for owner release cannot pass: the owner remains held until after the result watchdog expires. Slow thread startup is excluded from the result window, and cleanup cannot hang the test indefinitely.

Failed main run: https://github.com/cortexkit/aft/actions/runs/32020646375

Verification

  • cargo +1.93.0 fmt --all -- --check
  • cargo +1.93.0 test -p agent-file-tools --lib fs_lock::tests — 21 passed
  • focused test repeated 100 times with a 20-second outer process timeout — 100 passed

Both commits are SSH-signed and based on merge commit 7ea58ee2.