diff --git a/scripts/laptop/lap_lib.sh b/scripts/laptop/lap_lib.sh index da877f13..7ff9c8e7 100644 --- a/scripts/laptop/lap_lib.sh +++ b/scripts/laptop/lap_lib.sh @@ -26,6 +26,11 @@ lap_windows_avail_gb() { powershell.exe -NoProfile -Command 'Add-Type -AssemblyName Microsoft.VisualBasic; [math]::Floor((New-Object Microsoft.VisualBasic.Devices.ComputerInfo).AvailablePhysicalMemory/1GB)' | tr -dc '0-9' } +# The engine's own start check (footprint 25.2 GiB for this profile + soft floor and reserve 5 GiB in the dedicated preset) refuses below ~30.2 GiB of VM +# MemAvailable ("REFUSING TO START: memory budget refused (host_ram)"); waiting for it is cheaper than a refused `leleka up`. +LAP_MIN_WSL_GB=${LAP_MIN_WSL_GB:-31} +lap_wsl_avail_gb() { awk '$1=="MemAvailable:" {printf "%d", $2/1048576}' /proc/meminfo; } + lap_power_limit_w() { nvidia-smi -q -d POWER | awk -F: '/Current Power Limit/ && $2 !~ /N\/A/ {gsub(/[ W]/, "", $2); printf "%d", $2; exit}'; } # Rule of the coordinator (2026-11-14): poll every 2 minutes WITHOUT the flag (it would stall the refactor agents for nothing); at a moment when no @@ -34,7 +39,7 @@ lap_power_limit_w() { nvidia-smi -q -d POWER | awk -F: '/Current Power Limit/ && LAP_MIN_WIN_GB=${LAP_MIN_WIN_GB:-8} lap_wait_and_lock() { while true; do - if [ ! -e "$LAP_LOCK" ] && ! lap_builds_running && [ "$(lap_windows_avail_gb)" -ge "$LAP_MIN_WIN_GB" ]; then + if [ ! -e "$LAP_LOCK" ] && ! lap_builds_running && [ "$(lap_windows_avail_gb)" -ge "$LAP_MIN_WIN_GB" ] && [ "$(lap_wsl_avail_gb)" -ge "$LAP_MIN_WSL_GB" ]; then lap_want_gpu "$1" if (set -C; echo "$LAP_AGENT $(date -u +%FT%TZ) $1" > "$LAP_LOCK") 2>/dev/null; then rm -f "$LAP_FLAG"; return 0; fi rm -f "$LAP_FLAG" @@ -54,5 +59,5 @@ lap_preflight() { [ "${lim:-0}" -ge 100 ] || return 4 ! grep -E "SW Power Cap|SW Thermal Slowdown" <<< "$q" | grep -q ": Active" || return 4 ! grep "Performance State" <<< "$q" | grep -q P5 || return 4 - [ "${turbo%% *}" != BAD ] && [ "$avail" -ge 10 ] && [ "${wfree:-0}" -ge "$LAP_MIN_WIN_GB" ] + [ "${turbo%% *}" != BAD ] && [ "$avail" -ge "$LAP_MIN_WSL_GB" ] && [ "${wfree:-0}" -ge "$LAP_MIN_WIN_GB" ] }