diff --git a/tools/ca3-v4-amend/pc-card-in.ps1 b/tools/ca3-v4-amend/pc-card-in.ps1 index 52ecc5e9f..298d0f83e 100644 --- a/tools/ca3-v4-amend/pc-card-in.ps1 +++ b/tools/ca3-v4-amend/pc-card-in.ps1 @@ -16,7 +16,7 @@ # Known-failed first: no new card reads "RESULT card-in no new card" and does nothing else (exit 0, status no_new_card); the # first run on a PC writes the baseline and does nothing else (status baseline). Never two cards: more than one new key # stops the job (status ambiguous) with the keys named. Nothing escalates, nothing is installed, settings.json is never -# written (the app's own /api/cards path switches the card off for the quiet rows and back on after, with the exact choices). +# written (the runner's --cards-off switches the card off for the quiet rows and back on after; a script never switches cards). $ErrorActionPreference = 'Continue' $jobName = 'pc-card-in' $started = Get-Date @@ -121,23 +121,15 @@ if ($haveV5) { if ($null -ne $clDev) { "RESULT card opencl device=$clDev line=$($clLine.Trim())" } else { "RESULT card opencl: no --list device matches '$name' (code $($card.code)); the OpenCL rows are skipped" } } -# ---- the card quiet: its app choices saved, the card switched off through /api/cards ---- +# ---- the card's quiet state is the RUNNER's: a script never switches cards (the playbook-quit rule). The detect run reads the +# new card with the app mining on it; the measured pass is published again with --cards-off and finds it off here. $choices = @($cards | ForEach-Object { [ordered]@{ key = $_.key; enabled = [bool]$_.enabled; identities = [int]$_.identities; power_pct = [int]$_.power_pct } }) -function ApplyCards($list) { return (Post 'api/cards' (([ordered]@{ cards = $list }) | ConvertTo-Json -Compress -Depth 4)) } -$off = @($choices | ForEach-Object { $c = [ordered]@{} + $_; if ($c.key -eq $key) { $c.enabled = $false }; $c }) -$restored = $false +$restored = $true function Workers { @(Get-CimInstance Win32_Process -Filter "Name = 'igneum-worker-opencl.exe' OR Name = 'igneum-worker-cuda.exe' OR Name = 'igneum-worker-metal.exe'" -ErrorAction SilentlyContinue | ForEach-Object { "$($_.Name):$($_.ProcessId):[$($_.CommandLine -replace '\s+', ' ')]" }) } "RESULT workers_before $(Stamp) $((@(Workers)) -join ' ')" -$quiet = $false -if (ApplyCards $off) { - $t = 0 - while ($t -lt 120) { - Start-Sleep -Seconds 5; $t += 5 - $st = State; $cc = $null; if ($st) { $cc = $st.mining.cards | Where-Object { $_.key -eq $key } | Select-Object -First 1 } - if ($cc -and -not $cc.enabled -and ($cc.hash_now -eq 0 -or $cc.state -match 'off|idle|stopped')) { $quiet = $true; break } - } - "RESULT card $(Stamp) $(if ($quiet) { "quiet after $t s (switched off through /api/cards; its choices saved: " + (($choices | Where-Object { $_.key -eq $key } | ForEach-Object { 'enabled=' + $_.enabled + ' identities=' + $_.identities + ' power_pct=' + $_.power_pct }) -join '') + ')' } else { "UNCONFIRMED after $t s (the app still reports it mining); the rows below are LOADED-card figures" })" -} else { 'RESULT card /api/cards refused; the rows below are LOADED-card figures' } +$quiet = -not $card.enabled +"RESULT card $(Stamp) $(if ($quiet) { 'quiet: the runner switched it off (--cards-off) before this script' } else { 'LOADED: the card mines in the app (a detect run, or a pass published without --cards-off); the rows below are LOADED-card figures' })" +if (-not $quiet -and $env:IGNEUM_CARDIN_DETECT_ONLY -eq '1') { WriteLast; "RESULT next: detect only; publish the pass with --cards-off $key"; Summary 'detected' @{ key = $key; name = $name; vendor = $vendor; vram_mb = $vram; fits = $fits }; exit 0 } $rowsOut = [ordered]@{} $samples = Join-Path $stateDir 'nv-samples.csv' @@ -299,13 +291,12 @@ try { } finally { if ($viaHelper) { "RESULT restore rgc: $(ResetClocks)" } if ($sampler) { try { Stop-Process -Id $sampler.Id -Force -ErrorAction SilentlyContinue } catch { }; 'RESULT restore sampler stopped' } - $restored = ApplyCards $choices - "RESULT restore cards $(if ($restored) { 'put back through /api/cards with the saved choices' } else { '/api/cards refused; the card stays as the app has it' })" + 'RESULT restore cards: the runner puts the card back with its own choices on exit (nothing switched here)' } # 4. the app row (every vendor): the card mining in the app, 75 s settle, the median of 30 s of hash_now and power_w $appMhs = $null; $appW = $null -if ($restored -and $card.enabled) { +if ($card.enabled) { Start-Sleep -Seconds 75 $hs = @(); $ws = @() for ($i = 0; $i -lt 6; $i++) { $st = State; if ($st) { $cc = $st.mining.cards | Where-Object { $_.key -eq $key } | Select-Object -First 1; if ($cc -and $cc.hash_now -gt 0) { $hs += [double]$cc.hash_now; $ws += [double]$cc.power_w } }; Start-Sleep -Seconds 5 }