diff --git a/.ai/memory/MEMORY.md b/.ai/memory/MEMORY.md index 12ed7c4..c97f65e 100644 --- a/.ai/memory/MEMORY.md +++ b/.ai/memory/MEMORY.md @@ -1,7 +1,7 @@ # Memory index -No durable project memories yet. Add dated notes as Markdown files in this directory and link them -from this index. +- [CI audit, 2026-09-26](ci-audit-2026-09-26.md): runner cost, workflow scope, + local checks, and the hosted verification still required. Memories are observations from a moment in time. Verify claims that may have drifted against current code. diff --git a/.ai/memory/ci-audit-2026-09-26.md b/.ai/memory/ci-audit-2026-09-26.md new file mode 100644 index 0000000..ca5aeac --- /dev/null +++ b/.ai/memory/ci-audit-2026-09-26.md @@ -0,0 +1,96 @@ +# CI audit, 2026-09-26 + +Scope: Claudex at `a8d4d21` with local, uncommitted CI edits. This is dated +evidence, not proof that the edits passed hosted CI. + +## Evidence and decisions + +- Audited all six GitHub Actions workflows, the required branch statuses, + native platform coverage, release checks, and local test entry points. +- The repository was public when checked. [GitHub billing guidance](https://docs.github.com/en/actions/concepts/billing-and-usage) + says standard hosted runners are free for public repositories. The standard + GitHub runner choice and Blacksmith exception are recorded in + `docs/development.md`. +- The [2026-09-23 Blacksmith run](https://github.com/BeamoTech/Claudex/actions/runs/35803572683) + waited nearly three hours for macOS. The + [2026-09-26 GitHub run](https://github.com/BeamoTech/Claudex/actions/runs/36283161738) + started macOS within seconds and completed the matrix in about 16 minutes. + Those are dated observations, not a guarantee of future queue times. +- On that GitHub run, the macOS Bash suite took 15 minutes 29 seconds; checkout + took two seconds and the following PowerShell test took 30 seconds. The Bash + suite is the wall time bottleneck. +- The [2026-07-22 release run](https://github.com/BeamoTech/Claudex/actions/runs/29904821169) + spent about 15 minutes in its macOS release gate, then 24 seconds in the + publishing job. The matching [installer verification](https://github.com/BeamoTech/Claudex/actions/runs/29905853826) + resolved the expected version in four seconds. These short jobs do not + justify changing release ordering or public installation coverage. +- Among the latest 100 Actions runs checked on 2026-09-26, three older pull + request test matrices were canceled during rapid source updates in August. + The existing main test concurrency is doing useful work; keep it. +- The latest inspected [CodeQL job](https://github.com/BeamoTech/Claudex/actions/runs/36283161748) + took 66 seconds. The inspected [dependency review](https://github.com/BeamoTech/Claudex/actions/runs/35924267214) + took four seconds and [labeler](https://github.com/BeamoTech/Claudex/actions/runs/35924267290) + took eight seconds. Their security and labeling coverage is worth retaining. +- `package-lock.json` lists only the root package and no external npm packages. + There is no dependency installation in the test matrix to accelerate with an + npm cache. The release builder uses repository files and local staging, so + an archive cache would risk stale source and cost more coordination. +- Local edits cancel superseded dependency review and labeler runs, remove a + redundant labeler event, and avoid a second apt index fetch in the legacy + Ubuntu test. +- [GitHub reusable workflow guidance](https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations) + says a called workflow inherits the caller's `github` context. The test + workflow now defaults a reusable call input to preserving an independent + run group, including when the optional `ref` is omitted. Direct branch and + pull request runs still cancel stale checks. The old + `github.event_name == 'workflow_call'` condition could not identify a call. +- Required statuses, native macOS, Ubuntu, and Windows suites, CodeQL, + dependency review, minimum Node coverage, and release gates remain present. +- Branch protection still requires `macos-15`, `ubuntu-24.04`, `windows-2025`, + `ubuntu-20.04-managed-node`, `package-artifacts`, `CodeQL`, and + `Dependency review` with strict up to date checking. The repository was + confirmed public again during this local review. + +## Local verification + +- The original `test.zsh` passed on macOS in 554 seconds against the edited + source. A trial that skipped some skill discovery passed twice in 565 and + 626 seconds, so it was removed: these runs did not show a speed benefit. +- A temporary profile of the passing suite measured about 153 seconds in proxy + and model checks, 111 seconds in composite launch checks, and 166 seconds in + update lock and detached update checks. These retain race and provider + boundary coverage. +- A later timing profile exposed a test race: the background status refresh + helper had only two seconds to publish its log before the Unix test read it. + The Unix and Windows suites now wait up to 20 seconds for four complete + lines, exiting early on the normal path. A deliberately delayed Unix helper + and the PowerShell fixture write passed locally. The exact edited `test.zsh` + suite passed in 676 seconds after the final fixture edits; native Windows + verification is still pending. +- Every preceding component of `test.sh` passed separately, including watcher, + authentication lock, Windows source parity, and test driver regressions. +- `npm test`, macOS PowerShell self update lock regressions, `actionlint`, Bash + syntax checks, Markdown checks, `git diff --check`, and release archive + reproducibility and extracted install checks passed. +- The agent, development, and contributor syntax commands now use + `bash -n test.zsh`, matching the script shebang and the shell that CI runs. +- The first authorized PR matrix on 2026-09-26 passed macOS, Ubuntu, Node 18, + archives, CodeQL, and dependency review. The Windows main suite also passed, + but its separate self update lock regression failed after an X/Y/Z race: + the next successful probe used a 12-attempt test limit, shorter than the + updater's two second stale lock grace. The test now requires Y to exit + successfully, gives that probe the normal 100-attempt budget, allows bounded + child completion on loaded hosts, and terminates remaining children before + fixture cleanup. Its focused macOS PowerShell run passed; the revised Windows + run still needs native verification. +- The first hosted Ubuntu 20.04 container job passed. The revised Windows test + and all required statuses on the final source still need hosted verification. + Before the user authorized that run, no hosted CI had been triggered. +- Parallelizing the short, isolated shell regressions in `test.sh` would save + little compared with the macOS launcher suite and would complicate its + early failure test driver. Keep their sequential order until measured evidence + justifies a change. + +Next action: verify the exact edited source on all required hosted platforms and +compare job times and required statuses with the dated baseline. Recheck +visibility and runner access before any provider change. diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index ee7c6ff..b9e5f31 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -7,6 +7,11 @@ on: permissions: contents: read +# A newer revision of the same PR supersedes an unfinished dependency review. +concurrency: + group: dependency-review-${{ github.event.pull_request.number }} + cancel-in-progress: true + jobs: review: name: Dependency review diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 7642d63..88d9036 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -2,12 +2,17 @@ name: Pull request labeling on: pull_request_target: - types: [opened, synchronize, reopened, ready_for_review] + types: [opened, synchronize, reopened] permissions: contents: read pull-requests: write +# Labels are synchronized from the latest PR diff, so discard older updates. +concurrency: + group: labeler-${{ github.event.pull_request.number }} + cancel-in-progress: true + jobs: label: name: Label changed areas diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 385ee8d..e1c5f1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,15 +11,20 @@ on: description: Git ref to test (defaults to the triggering ref) required: false type: string + preserve_run: + description: Keep each reusable verification gate independent + required: false + default: true + type: boolean permissions: contents: read -# A newer commit supersedes an in-flight run for the same ref. Reusable -# workflow calls get a per-run group so callers remain independent. +# A newer commit supersedes an in-flight direct run for the same ref. Reusable +# calls keep independent gates even when the caller omits the optional ref. concurrency: - group: test-${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'workflow_call' && github.run_id || github.ref }} - cancel-in-progress: ${{ github.event_name != 'workflow_call' }} + group: test-${{ github.workflow }}-${{ github.event_name }}-${{ inputs.preserve_run && github.run_id || github.ref }} + cancel-in-progress: ${{ !inputs.preserve_run }} jobs: unix: @@ -64,7 +69,7 @@ jobs: - name: Install checkout prerequisites run: | apt-get update - DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates git + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl git jq - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ inputs.ref || github.ref }} diff --git a/AGENTS.md b/AGENTS.md index 157ce06..08890c3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -62,13 +62,18 @@ node tests/skill-bridge.test.cjs # discovery/materialization behavior node tests/skill-contract.test.cjs # Claude/Codex compatibility contract node tests/skill-security.test.cjs # hostile filesystem/plugin inputs bash -n claudex codex-session install.sh statusline usage-limit -zsh -n test.zsh +bash -n test.zsh git diff --check ``` There is no single test runner: `test.zsh`/`test.ps1` are one large suite of isolated regressions using fake homes and fake provider commands (Codex, Claude Code, curl, CLIProxyAPI) so tests never touch a real session. To narrow scope while iterating, grep the suite file for the relevant test function name and read it directly; there's no `--filter` flag. -CI (`.github/workflows/test.yml`) runs on every push to `main` and every PR: the Unix suite on macOS + Ubuntu, the PowerShell suite on Windows, plus three Ubuntu jobs: `package-artifacts` (`npm test` + `scripts/check-release-artifacts.sh`), `node-18-shared-runtime` (`npm test` on the minimum supported Node), and `legacy-linux-node` (managed Node fallback in an Ubuntu 20.04 container). +CI (`.github/workflows/test.yml`) runs on every push to `main` and every PR: +the Unix suite on macOS + Ubuntu, the PowerShell suite on Windows, plus three +Ubuntu jobs: `package-artifacts` (package metadata and reproducible archive +checks), `node-18-shared-runtime` (`npm test` on the minimum supported Node), +and `legacy-linux-node` (managed Node fallback in an Ubuntu 20.04 container). +Current runner selection and its cost exception are in `docs/development.md`. ## Architecture diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ad564..fd050ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ uses [Semantic Versioning](https://semver.org/) for tagged releases. ## [Unreleased] +## [1.6.3] - 2026-09-26 + +### Changed + +- Reduced redundant pull request verification and repeated legacy Linux setup + while retaining native platform, security, and release checks. + +### Fixed + +- Stabilized asynchronous status refresh and Windows self update lock test + fixtures on slower CI hosts. + ## [1.6.2] - 2026-07-22 ### Added @@ -490,7 +502,8 @@ uses [Semantic Versioning](https://semver.org/) for tagged releases. - Claude in Chrome first party profile support. - Cross platform regression coverage in GitHub Actions. -[Unreleased]: https://github.com/BeamoINT/Claudex/compare/v1.6.2...HEAD +[Unreleased]: https://github.com/BeamoINT/Claudex/compare/v1.6.3...HEAD +[1.6.3]: https://github.com/BeamoINT/Claudex/compare/v1.6.2...v1.6.3 [1.6.2]: https://github.com/BeamoINT/Claudex/compare/v1.6.1...v1.6.2 [1.6.1]: https://github.com/BeamoINT/Claudex/compare/v1.6.0...v1.6.1 [1.6.0]: https://github.com/BeamoINT/Claudex/compare/v1.5.8...v1.6.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d4958f9..42cbb31 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -98,7 +98,7 @@ platform: ```bash node --check preload.cjs bash -n claudex codex-session install.sh statusline usage-limit -zsh -n test.zsh +bash -n test.zsh ``` GitHub Actions runs the complete isolated suite on macOS, Ubuntu, and Windows. diff --git a/docs/development.md b/docs/development.md index a19c781..f26fb9d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -46,9 +46,16 @@ Node.js 18 runtime. The hosted matrix does not currently include ARM64 or WSL; the root README distinguishes those supported paths from configurations tested on hosted runners. +Claudex is public, so [standard GitHub runners incur no Actions minute charges](https://docs.github.com/en/actions/concepts/billing-and-usage). +The current jobs use those runners. This is the cost exception to the workspace +preference for Blacksmith: the [last Blacksmith matrix](https://github.com/BeamoTech/Claudex/actions/runs/35803572683) +waited nearly three hours for its macOS job, while the [current GitHub matrix](https://github.com/BeamoTech/Claudex/actions/runs/36283161738) +started that job within seconds. Recheck repository visibility, runner access, +queue time, and exact source coverage before changing providers. + CodeQL scans the JavaScript compatibility surface on every pull request and on a weekly schedule. Dependency Review blocks newly introduced high or critical -dependency vulnerabilities, Dependabot proposes pinned dependency updates, and +dependency vulnerabilities, and the pull request labeler identifies affected components and platforms. All third party GitHub Actions are pinned to immutable commits. @@ -61,7 +68,7 @@ Useful focused checks: node scripts/check-docs.mjs node --check preload.cjs bash -n claudex codex-session install.sh statusline usage-limit -zsh -n test.zsh +bash -n test.zsh git diff --check ``` diff --git a/package-lock.json b/package-lock.json index 81c42d0..4f8661f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "claudex-codex", - "version": "1.6.2", + "version": "1.6.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "claudex-codex", - "version": "1.6.2", + "version": "1.6.3", "license": "MIT", "engines": { "node": ">=18" diff --git a/package.json b/package.json index 5d13240..4aac13b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claudex-codex", - "version": "1.6.2", + "version": "1.6.3", "private": true, "description": "Cross platform compatibility layer for using Codex GPT and native Claude models through Claude Code", "type": "module", diff --git a/test.ps1 b/test.ps1 index 33f0a47..e4ee1be 100644 --- a/test.ps1 +++ b/test.ps1 @@ -2977,12 +2977,14 @@ process.stdout.write(JSON.stringify({ [IO.Directory]::CreateDirectory($statusRefreshConfig) | Out-Null [IO.File]::WriteAllText($statusRefreshHelper, @' param([switch] $RefreshCache, [switch] $LockHeld, [string] $LockToken) -[IO.File]::WriteAllLines($env:STATUS_REFRESH_PRIVATE_ENV_LOG, @( +$pendingLog = "$env:STATUS_REFRESH_PRIVATE_ENV_LOG.$PID.pending" +[IO.File]::WriteAllLines($pendingLog, @( "MANTLE=$env:ANTHROPIC_BEDROCK_MANTLE_BASE_URL", "VERTEX_PROJECT=$env:ANTHROPIC_VERTEX_PROJECT_ID", "FOUNDRY_RESOURCE=$env:ANTHROPIC_FOUNDRY_RESOURCE", "FOUNDRY_API_KEY=$env:ANTHROPIC_FOUNDRY_API_KEY" )) +[IO.File]::Move($pendingLog, $env:STATUS_REFRESH_PRIVATE_ENV_LOG) '@, $utf8) $statusRefreshEnvironment = @{} foreach ($statusRefreshName in @( @@ -3001,10 +3003,16 @@ param([switch] $RefreshCache, [switch] $LockHeld, [string] $LockToken) $env:ANTHROPIC_FOUNDRY_RESOURCE = 'private-foundry-resource' $env:ANTHROPIC_FOUNDRY_API_KEY = 'private-foundry-secret' '{"session_id":"private-refresh","model":{"id":"gpt-5.6-sol"},"context_window":{"used_percentage":5}}' | & (Join-Path $root 'statusline.ps1') | Out-Null - for ($attempt = 0; $attempt -lt 100 -and -not (Test-Path -LiteralPath $statusRefreshLog -PathType Leaf); $attempt++) { + $statusRefreshLines = @() + $statusRefreshDeadline = [DateTime]::UtcNow.AddSeconds(20) + while ($statusRefreshLines.Count -lt 4 -and [DateTime]::UtcNow -lt $statusRefreshDeadline) { + if (Test-Path -LiteralPath $statusRefreshLog -PathType Leaf) { + try { $statusRefreshLines = @([IO.File]::ReadAllLines($statusRefreshLog)) } catch [IO.IOException] { } + } + if ($statusRefreshLines.Count -ge 4) { break } Start-Sleep -Milliseconds 20 } - $statusRefreshLines = @([IO.File]::ReadAllLines($statusRefreshLog)) + Assert-True ($statusRefreshLines.Count -eq 4) 'status refresh helper writes a complete environment log' Assert-True (($statusRefreshLines -join '|') -eq 'MANTLE=|VERTEX_PROJECT=|FOUNDRY_RESOURCE=|FOUNDRY_API_KEY=') 'status refresh helper receives no private cloud-provider environment' } finally { foreach ($statusRefreshName in $statusRefreshEnvironment.Keys) { diff --git a/test.zsh b/test.zsh index 8824be6..58d3bf4 100755 --- a/test.zsh +++ b/test.zsh @@ -1762,7 +1762,14 @@ printf '%s\n' '{"session_id":"private-refresh","model":{"id":"gpt-5.6-sol"},"con ANTHROPIC_FOUNDRY_RESOURCE='private-foundry-resource' \ ANTHROPIC_FOUNDRY_API_KEY='private-foundry-secret' \ "$root/statusline" >/dev/null -for _ in {1..100}; do [[ -s "$status_refresh_log" ]] && break; sleep 0.02; done +# Refresh runs in the background. Wait for all four lines before reading the +# helper's evidence so loaded hosts cannot expose a partial write. +for _ in {1..1000}; do + if [[ -s "$status_refresh_log" ]] && [[ $(wc -l < "$status_refresh_log") -ge 4 ]]; then break; fi + sleep 0.02 +done +[[ -s "$status_refresh_log" ]] || { printf '%s\n' 'status refresh helper did not write its environment log' >&2; exit 1; } +[[ $(wc -l < "$status_refresh_log") -eq 4 ]] || { printf '%s\n' 'status refresh helper wrote an incomplete environment log' >&2; exit 1; } [[ "$(<"$status_refresh_log")" == $'MANTLE=\nVERTEX_PROJECT=\nFOUNDRY_RESOURCE=\nFOUNDRY_API_KEY=' ]] printf '%s\n' 'Codex 7d 16% left · Review 7d 9% left · Extra-long-capacity-window 30d 8% left' \ diff --git a/tests/legacy-linux-node.sh b/tests/legacy-linux-node.sh index 58cac05..87c18c0 100755 --- a/tests/legacy-linux-node.sh +++ b/tests/legacy-linux-node.sh @@ -6,8 +6,13 @@ readonly temporary="$(mktemp -d)" trap 'rm -rf "$temporary"' EXIT [[ "$(id -u)" == 0 ]] || { printf '%s\n' 'legacy Linux runtime test must run as root in a disposable container' >&2; exit 1; } -apt-get update >/dev/null -DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl jq >/dev/null +# CI installs these before checkout. Standalone container runs still install +# missing tools, but an already prepared runner avoids a second apt index fetch. +if ! command -v curl >/dev/null 2>&1 || ! command -v jq >/dev/null 2>&1 || \ + [[ ! -s /etc/ssl/certs/ca-certificates.crt ]]; then + apt-get update >/dev/null + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl jq >/dev/null +fi home="$temporary/home" fake_bin="$temporary/bin" diff --git a/tests/self-update-lock-regressions.ps1 b/tests/self-update-lock-regressions.ps1 index bf8d3b5..d7e2e5b 100644 --- a/tests/self-update-lock-regressions.ps1 +++ b/tests/self-update-lock-regressions.ps1 @@ -12,6 +12,10 @@ $shell = (Get-Process -Id $PID).Path $isWindowsPlatform = [Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT $scriptPath = Join-Path $root 'self-update.ps1' $arguments = @('-NoLogo', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', ('"' + $scriptPath + '"'), '-Check') +# Native PowerShell startup and lock recovery can exceed 15 seconds on a busy +# runner. The wait remains bounded, and cleanup terminates any timed out child. +$exitTimeoutMs = 45000 +$script:startedChecks = @() function Assert-True([bool] $Condition, [string] $Message) { if (-not $Condition) { throw "assertion failed: $Message" } @@ -50,7 +54,9 @@ function Start-Check { PassThru = $true } if ($isWindowsPlatform) { $parameters.WindowStyle = 'Hidden' } - return Start-Process @parameters + $process = Start-Process @parameters + $script:startedChecks += $process + return $process } function Invoke-ExpectedFailedCheck { @@ -121,10 +127,10 @@ try { Wait-File (Join-Path $temporary 'b-ready') $bNonce = ([IO.File]::ReadAllLines((Join-Path $lock 'owner')) | Where-Object { $_.StartsWith('nonce=') })[0] Continue-Pause 'a' - Assert-True ($a.WaitForExit(15000)) 'paused A exits' + Assert-True ($a.WaitForExit($exitTimeoutMs)) 'paused A exits' Assert-True ([IO.File]::ReadAllText((Join-Path $lock 'owner')).Contains($bNonce)) 'A preserves B generation' Continue-Pause 'b' - Assert-True ($b.WaitForExit(15000)) 'B exits' + Assert-True ($b.WaitForExit($exitTimeoutMs)) 'B exits' Assert-True (-not (Test-Path -LiteralPath $lock)) 'B releases exact generation' # A new creator can resume inside a replacement lock published by the old @@ -139,7 +145,7 @@ try { [IO.File]::WriteAllText((Join-Path $lock 'owner.json'), "{`"pid`":$PID,`"token`":`"legacy-b`"}`n", $utf8) Remove-Item -LiteralPath (Join-Path $update 'abandoned-mixed-a') -Recurse -Force Continue-Pause 'mixed-a' - Assert-True ($mixedA.WaitForExit(15000) -and $mixedA.ExitCode -ne 0) 'mixed protocol A exits outside update section' + Assert-True ($mixedA.WaitForExit($exitTimeoutMs) -and $mixedA.ExitCode -ne 0) 'mixed protocol A exits outside update section' Assert-True ([IO.File]::ReadAllText((Join-Path $lock 'owner.json')).Contains('legacy-b')) 'mixed protocol A preserves legacy B owner' Assert-True (-not (Test-Path -LiteralPath (Join-Path $lock 'generation'))) 'mixed protocol A withdraws only its injected generation' Assert-True (@(Get-ChildItem -LiteralPath $update -Directory -Filter 'lock.quarantine.*' -ErrorAction SilentlyContinue).Count -eq 0) 'mixed protocol cleanup leaves no barrier' @@ -160,7 +166,7 @@ try { (Get-Item -LiteralPath $lock).CreationTimeUtc = $abandonedCreationTime Remove-Item -LiteralPath (Join-Path $update 'abandoned-empty-b-a') -Recurse -Force Continue-Pause 'empty-b' - Assert-True ($emptyBA.WaitForExit(15000) -and $emptyBA.ExitCode -ne 0) 'A rejects an empty replacement directory' + Assert-True ($emptyBA.WaitForExit($exitTimeoutMs) -and $emptyBA.ExitCode -ne 0) 'A rejects an empty replacement directory' Assert-True ((Test-Path -LiteralPath $lock -PathType Container) -and -not (Test-Path -LiteralPath (Join-Path $lock 'generation')) -and -not (Test-Path -LiteralPath (Join-Path $lock 'owner'))) 'A preserves B before legacy owner publication' @@ -203,7 +209,7 @@ try { Continue-Pause 'x-before' Wait-File (Join-Path $temporary 'x-after-ready') $z = Start-Check - Assert-True ($z.WaitForExit(15000) -and $z.ExitCode -ne 0) 'Z remains outside quarantined update section' + Assert-True ($z.WaitForExit($exitTimeoutMs) -and $z.ExitCode -ne 0) 'Z remains outside quarantined update section' Continue-Pause 'x-after' for ($attempt = 0; $attempt -lt 500; $attempt++) { if ((Test-Path -LiteralPath (Join-Path $lock 'owner')) -and [IO.File]::ReadAllText((Join-Path $lock 'owner')).Contains($yNonce)) { break } @@ -211,15 +217,19 @@ try { } Assert-True ([IO.File]::ReadAllText((Join-Path $lock 'owner')).Contains($yNonce)) 'X restores exact moved Y nonce' Continue-Pause 'y' - Assert-True ($y.WaitForExit(15000)) 'Y exits' - Assert-True ($x.WaitForExit(15000)) 'X exits' + Assert-True ($y.WaitForExit($exitTimeoutMs) -and $y.ExitCode -eq 0) 'Y exits successfully after recovering its lock' + Assert-True ($x.WaitForExit($exitTimeoutMs)) 'X exits' # Hardlink denial falls back to CreateNew and an incomplete publication is - # withdrawn without leaving an owner or quarantine barrier. + # withdrawn without leaving an owner or quarantine barrier. A just exited + # race participant can leave a dead lock within the two second grace, so + # this successful acquisition uses the normal retry budget. + $env:CLAUDEX_TEST_UPDATE_LOCK_ATTEMPTS = '100' $env:CLAUDEX_TEST_FORCE_HARDLINK_FAILURE = '1' & $shell -NoLogo -NoProfile -ExecutionPolicy Bypass -File $scriptPath -Check | Out-Null Assert-True ($LASTEXITCODE -eq 0 -and -not (Test-Path -LiteralPath $lock)) 'CreateNew fallback succeeds' Remove-Item Env:CLAUDEX_TEST_FORCE_HARDLINK_FAILURE + $env:CLAUDEX_TEST_UPDATE_LOCK_ATTEMPTS = '12' $env:CLAUDEX_TEST_FORCE_PUBLICATION_FAILURE = '1' $publicationFailureExit = Invoke-ExpectedFailedCheck Assert-True ($publicationFailureExit -ne 0 -and -not (Test-Path -LiteralPath $lock)) 'incomplete publication is removed' @@ -273,11 +283,20 @@ try { $identity = [string] (Get-Process -Id $PID).StartTime.ToUniversalTime().Ticks [IO.File]::WriteAllText((Join-Path $lock 'owner'), "pid=$PID`nidentity=$identity`nnonce=replacement`n", $utf8) Continue-Pause 'exit' - Assert-True ($oldOwner.WaitForExit(15000)) 'obsolete owner exits' + Assert-True ($oldOwner.WaitForExit($exitTimeoutMs)) 'obsolete owner exits' Assert-True ([IO.File]::ReadAllText((Join-Path $lock 'owner')).Contains('nonce=replacement')) 'exit hook preserves replacement generation' [Console]::WriteLine('PowerShell self update lock regressions passed') } finally { + foreach ($check in $script:startedChecks) { + try { + if (-not $check.HasExited) { + $check.Kill() + [void] $check.WaitForExit(5000) + } + } catch { } + try { $check.Dispose() } catch { } + } foreach ($name in @('CLAUDEX_CONFIG_DIR', 'CLAUDEX_TEST_MODE', 'CLAUDEX_TEST_UPDATE_FIXTURE_DIR', 'CLAUDEX_TEST_UPDATE_LOCK_ATTEMPTS', 'CLAUDEX_TEST_FORCE_HARDLINK_FAILURE', 'CLAUDEX_TEST_FORCE_PUBLICATION_FAILURE')) { Remove-Item -LiteralPath "Env:$name" -ErrorAction SilentlyContinue