From 8035e9ead46f223545961a8cf1cde95a95f00739 Mon Sep 17 00:00:00 2001 From: "lilly.luo" Date: Fri, 20 Nov 2026 14:25:38 +0000 Subject: [PATCH 1/3] test(ci): record native Cowork control wait timing --- scripts/cowork-inference/README.md | 6 ++++++ scripts/cowork-inference/test-task.ps1 | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/cowork-inference/README.md b/scripts/cowork-inference/README.md index a17ca2102..ec629e114 100644 --- a/scripts/cowork-inference/README.md +++ b/scripts/cowork-inference/README.md @@ -19,6 +19,12 @@ through Windows UI Automation. `--force-renderer-accessibility` exposes the app' accessible controls. Controls are polled until enabled and visible, with a 60-second deadline per transition. No preliminary launch or virtualization check is needed. +On a Windows task control timeout, `result.json` includes `waitFailure`: the requested +labels, wait budget, scan count, and elapsed milliseconds before and after the failure +snapshot. `wait-failed.json` captures the actual subtree searched, including native folder +dialogs. Compare those timings with the snapshot when an expected control appears there; +its presence after the wait alone does not establish when it became available. + The test installs UG from the checkout, runs `ug configure` with the existing `UCODE_TEST_WORKSPACE` and `DATABRICKS_BEARER` CI secrets, and checks the generated gateway profile. UG detects the installed Windows MSIX package and executable, diff --git a/scripts/cowork-inference/test-task.ps1 b/scripts/cowork-inference/test-task.ps1 index 6f26a0bfd..b7fa35262 100644 --- a/scripts/cowork-inference/test-task.ps1 +++ b/scripts/cowork-inference/test-task.ps1 @@ -41,12 +41,22 @@ function Find-Control { function Wait-Control { param([string[]]$Names, [int]$Seconds = 60, $Root = $script:window) $deadline = [DateTime]::UtcNow.AddSeconds($Seconds) + $timer = [Diagnostics.Stopwatch]::StartNew() + $scans = 0 do { + $scans++ $control = Find-Control -Names $Names -Root $Root if ($control) { return $control } Start-Sleep -Milliseconds 500 } until ([DateTime]::UtcNow -ge $deadline) - Save-UI 'wait-failed' + $report.waitFailure = [ordered]@{ + names = $Names + budgetSeconds = $Seconds + scans = $scans + elapsedMilliseconds = $timer.ElapsedMilliseconds + } + Save-UI 'wait-failed' -Root $Root + $report.waitFailure.snapshotCompletedMilliseconds = $timer.ElapsedMilliseconds throw "Control not ready: $($Names -join ', ')" } From 55a131924c8f59a4373dd5bf4b3ac2811bde0ace Mon Sep 17 00:00:00 2001 From: "lilly.luo" Date: Fri, 20 Nov 2026 14:29:07 +0000 Subject: [PATCH 2/3] test(ci): preserve Cowork timeout when snapshot capture fails --- .github/workflows/integration.yml | 1 + scripts/cowork-inference/README.md | 3 ++ scripts/cowork-inference/test-task-waits.ps1 | 46 ++++++++++++++++++++ scripts/cowork-inference/test-task.ps1 | 3 +- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 scripts/cowork-inference/test-task-waits.ps1 diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index daaf28f24..39006ce6b 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -202,6 +202,7 @@ jobs: } & ./scripts/cowork-inference/test-diagnostics.ps1 & ./scripts/cowork-inference/test-prepare-task.ps1 + & ./scripts/cowork-inference/test-task-waits.ps1 - name: Download and verify the approved Claude installer shell: pwsh run: ./scripts/cowork-inference/download-desktop.ps1 diff --git a/scripts/cowork-inference/README.md b/scripts/cowork-inference/README.md index ec629e114..f2ea5edff 100644 --- a/scripts/cowork-inference/README.md +++ b/scripts/cowork-inference/README.md @@ -24,6 +24,9 @@ labels, wait budget, scan count, and elapsed milliseconds before and after the f snapshot. `wait-failed.json` captures the actual subtree searched, including native folder dialogs. Compare those timings with the snapshot when an expected control appears there; its presence after the wait alone does not establish when it became available. +If snapshot collection fails, `snapshotError` records its exception class and the original +control timeout remains the failure. `test-task-waits.ps1` checks ready controls, missing +controls, and failed snapshots with only the UI Automation boundary substituted. The test installs UG from the checkout, runs `ug configure` with the existing `UCODE_TEST_WORKSPACE` and `DATABRICKS_BEARER` CI secrets, and checks the generated diff --git a/scripts/cowork-inference/test-task-waits.ps1 b/scripts/cowork-inference/test-task-waits.ps1 new file mode 100644 index 000000000..1695a2c67 --- /dev/null +++ b/scripts/cowork-inference/test-task-waits.ps1 @@ -0,0 +1,46 @@ +$ErrorActionPreference = 'Stop' +$tokens = $null +$errors = $null +$source = [System.Management.Automation.Language.Parser]::ParseFile( + (Join-Path $PSScriptRoot 'test-task.ps1'), [ref]$tokens, [ref]$errors) +if ($errors.Count) { throw ($errors | Out-String) } +$definition = $source.Find({ + param($node) + $node -is [System.Management.Automation.Language.FunctionDefinitionAst] -and $node.Name -eq 'Wait-Control' +}, $true) +Invoke-Expression $definition.Extent.Text + +# UI Automation is the external boundary; execute the real wait and evidence handling. +function Find-Control { param($Names, $Root) return $script:control } +function Save-UI { + param($Name, $Root) + if ($Name -ne 'wait-failed' -or -not [object]::ReferenceEquals($Root, $script:expectedRoot)) { + throw 'Wrong snapshot subtree' + } + if ($script:failSnapshot) { throw [InvalidOperationException]::new('Closed UI root') } + $script:snapshotSaved = $true +} + +$script:control = [pscustomobject]@{ Name = 'ready' } +$report = [ordered]@{} +if ((Wait-Control -Names @('ready') -Seconds 0) -ne $script:control -or $report.Contains('waitFailure')) { + throw 'Ready control did not return without failure evidence' +} +$script:control = $null +$script:expectedRoot = [pscustomobject]@{ Name = 'native folder dialog' } +foreach ($script:failSnapshot in @($false, $true)) { + $report = [ordered]@{} + $script:snapshotSaved = $false + $message = '' + try { Wait-Control -Names @('missing') -Seconds 0 -Root $script:expectedRoot } + catch { $message = $_.Exception.Message } + if ($message -ne 'Control not ready: missing') { throw "Timeout replaced by: $message" } + $failure = $report.waitFailure + if ($failure.names[0] -ne 'missing' -or $failure.budgetSeconds -ne 0 -or $failure.scans -ne 1 -or + $failure.elapsedMilliseconds -lt 0 -or $failure.snapshotCompletedMilliseconds -lt $failure.elapsedMilliseconds) { + throw 'Missing or inconsistent wait evidence' + } + if ($script:failSnapshot) { + if ($failure.snapshotError -ne 'InvalidOperationException') { throw 'Missing snapshot error class' } + } elseif (-not $script:snapshotSaved) { throw 'Failure snapshot was not saved' } +} diff --git a/scripts/cowork-inference/test-task.ps1 b/scripts/cowork-inference/test-task.ps1 index b7fa35262..34015bd54 100644 --- a/scripts/cowork-inference/test-task.ps1 +++ b/scripts/cowork-inference/test-task.ps1 @@ -55,7 +55,8 @@ function Wait-Control { scans = $scans elapsedMilliseconds = $timer.ElapsedMilliseconds } - Save-UI 'wait-failed' -Root $Root + try { Save-UI 'wait-failed' -Root $Root } + catch { $report.waitFailure.snapshotError = $_.Exception.GetType().Name } $report.waitFailure.snapshotCompletedMilliseconds = $timer.ElapsedMilliseconds throw "Control not ready: $($Names -join ', ')" } From d42946fd91b2f86d6c71896454656c8d11fc0d76 Mon Sep 17 00:00:00 2001 From: "lilly.luo" Date: Fri, 20 Nov 2026 14:37:52 +0000 Subject: [PATCH 3/3] test(ci): check serialized Cowork wait evidence --- scripts/cowork-inference/test-task-waits.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cowork-inference/test-task-waits.ps1 b/scripts/cowork-inference/test-task-waits.ps1 index 1695a2c67..2723d399b 100644 --- a/scripts/cowork-inference/test-task-waits.ps1 +++ b/scripts/cowork-inference/test-task-waits.ps1 @@ -35,7 +35,7 @@ foreach ($script:failSnapshot in @($false, $true)) { try { Wait-Control -Names @('missing') -Seconds 0 -Root $script:expectedRoot } catch { $message = $_.Exception.Message } if ($message -ne 'Control not ready: missing') { throw "Timeout replaced by: $message" } - $failure = $report.waitFailure + $failure = ($report | ConvertTo-Json -Depth 8 | ConvertFrom-Json).waitFailure if ($failure.names[0] -ne 'missing' -or $failure.budgetSeconds -ne 0 -or $failure.scans -ne 1 -or $failure.elapsedMilliseconds -lt 0 -or $failure.snapshotCompletedMilliseconds -lt $failure.elapsedMilliseconds) { throw 'Missing or inconsistent wait evidence'