Valid session handle.
Optionaloptions: number | AbortSignal | BackendReadContext | FileLockOptions
Optional timeout, cancellation signal, lock options, or read context (EXEC-001-T09c).
Object with ok: true and { token } on success, or { ok: false, error } if busy/expired.
Atomically acquires turn ownership on an idle session record, recording this CoAgent8 server process (
process.pid, not a backend CLI child PID) asactivePid.Checks cancellation signals and execution budget before lock acquisition, during the lock wait, and across synchronous boundaries immediately after write. Atomic file writes (
atomicWriteviafs.rename) represent uninterruptible OS operations; if cancellation occurs across a write boundary, rollback to idle is attempted and turn ownership is revoked. If rollback write fails due to OS I/O error, the record remains until stale recovery reclaims it.