diff --git a/.github/workflows/codex-plus-plus-fast-checks.yml b/.github/workflows/codex-plus-plus-fast-checks.yml
new file mode 100644
index 000000000000..1056d268f3c2
--- /dev/null
+++ b/.github/workflows/codex-plus-plus-fast-checks.yml
@@ -0,0 +1,120 @@
+name: Codex++ fast checks
+
+on:
+ pull_request:
+ paths:
+ - '.github/workflows/codex-plus-plus-fast-checks.yml'
+ - '.github/scripts/setup-dev-drive.ps1'
+ - 'scripts/install/install-codex-plus-plus*.sh'
+ - 'scripts/install/install-codex-plus-plus*.ps1'
+ - 'scripts/install/test_install_codex_plus_plus*.py'
+ - 'scripts/codex_package/__init__.py'
+ - 'scripts/codex_package/codex_plus_plus/install.py'
+ - 'codex-cli/bin/launcher.js'
+ - 'codex-cli/bin/codex_plus_plus/windows_upstream_launcher.js'
+ - 'codex-cli/package.json'
+ - 'codex-cli/tests/codex_plus_plus/launcher.test.js'
+ - 'codex-cli/tests/codex_plus_plus/windows_upstream_launcher.test.js'
+ - 'codex-rs/install-context/Cargo.toml'
+ - 'codex-rs/install-context/src/**'
+ - 'codex-rs/utils/absolute-path/Cargo.toml'
+ - 'codex-rs/utils/absolute-path/src/**'
+ - 'codex-rs/utils/home-dir/Cargo.toml'
+ - 'codex-rs/utils/home-dir/src/**'
+ - 'codex-rs/Cargo.toml'
+ - 'codex-rs/Cargo.lock'
+ - 'codex-rs/.cargo/config.toml'
+ - 'codex-rs/rust-toolchain.toml'
+ - 'justfile'
+ - 'scripts/just-shell.py'
+ workflow_dispatch:
+ inputs:
+ macos:
+ description: Run macOS instead of Linux and Windows
+ type: boolean
+ default: false
+
+permissions:
+ contents: read
+
+jobs:
+ test:
+ name: ${{ matrix.suite }} (${{ matrix.runner }})
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ runner: ${{ fromJSON(inputs.macos && '["macos-15"]' || '["ubuntu-24.04", "windows-2025"]') }}
+ suite: [Installer, npm launchers, Rust install context]
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
+ persist-credentials: false
+
+ - name: Report the commit under test
+ run: git rev-parse HEAD
+
+ - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
+ if: matrix.suite != 'npm launchers'
+ with:
+ python-version: '3.12'
+
+ - name: Provide a Windows installer temp directory without 8.3 aliases
+ if: matrix.suite == 'Installer' && runner.os == 'Windows'
+ run: ./.github/scripts/setup-dev-drive.ps1
+
+ - name: Test the Windows installer and release acquisition
+ if: matrix.suite == 'Installer' && runner.os == 'Windows'
+ # cmd keeps the native tar and PowerShell 5.1 module search paths.
+ shell: cmd
+ run: |
+ set "TEMP=%CI_BUILD_ROOT%\codex-installer-fixtures"
+ set "TMP=%TEMP%"
+ if not exist "%TEMP%" mkdir "%TEMP%" || exit /b 1
+ python -m unittest discover -v -s scripts/install -p "test_install_codex_plus_plus*.py"
+
+ - name: Test the Unix installer and release acquisition
+ if: matrix.suite == 'Installer' && runner.os != 'Windows'
+ run: python -m unittest discover -v -s scripts/install -p "test_install_codex_plus_plus*.py"
+
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
+ if: matrix.suite == 'npm launchers'
+ with:
+ node-version: '26.12.1'
+ package-manager-cache: false
+
+ - name: Test npm launchers
+ if: matrix.suite == 'npm launchers'
+ run: node --test codex-cli/tests/codex_plus_plus/launcher.test.js codex-cli/tests/codex_plus_plus/windows_upstream_launcher.test.js
+
+ - uses: dtolnay/rust-toolchain@d124f86f28ff42855784ff3319f48ac182c248f8 # 1.99.1
+ if: matrix.suite == 'Rust install context'
+ - uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
+ if: matrix.suite == 'Rust install context'
+ with:
+ tool: just@1.51.0,nextest@0.9.103
+
+ - name: Test fork install and update policy
+ if: matrix.suite == 'Rust install context'
+ working-directory: codex-rs
+ shell: bash
+ env:
+ CARGO_PROFILE_CI_TEST_DEBUG: '0'
+ run: |
+ workspace=target/fork-install-context
+ mkdir -p "$workspace/utils"
+ cp -R install-context "$workspace/"
+ cp -R utils/{absolute-path,home-dir} "$workspace/utils/"
+ cp Cargo.lock "$workspace/"
+ # Cargo resolves the full workspace and its git patches even for a selected crate.
+ # Reuse the real manifests and locked versions with just the build's members.
+ {
+ printf '[workspace]\nmembers = ["install-context"]\n'
+ sed -n -e '/^resolver = /p' -e '/^\[workspace\.package\]/,/^\[patch\./{ /^\[patch\./d; p; }' Cargo.toml
+ } > "$workspace/Cargo.toml"
+ cargo update --workspace --quiet --manifest-path "$workspace/Cargo.toml"
+ just test --locked --manifest-path "$workspace/Cargo.toml" --cargo-profile ci-test \
+ --profile default --test-threads 4 --no-tests fail --lib -p codex-install-context \
+ -E 'test(codex_plus_plus::)'
diff --git a/.github/workflows/codex-plus-plus-pr-checks.yml b/.github/workflows/codex-plus-plus-pr-checks.yml
deleted file mode 100644
index 30d9ac79bc73..000000000000
--- a/.github/workflows/codex-plus-plus-pr-checks.yml
+++ /dev/null
@@ -1,187 +0,0 @@
-name: Codex++ PR checks
-
-on:
- pull_request:
- paths:
- - '.github/workflows/codex-plus-plus-pr-checks.yml'
- - '.github/actions/setup-ci/**'
- - '.github/actions/setup-msvc-env/**'
- - '.github/actions/setup-rusty-v8/**'
- - '.github/scripts/run_bazel.py'
- - '.github/scripts/rusty_v8_bazel.py'
- - '.github/scripts/rusty_v8_module_bazel.py'
- - '.github/scripts/setup-dev-drive.ps1'
- - 'third_party/v8/*release_manifests.sha256'
- - 'justfile'
- - 'scripts/just-shell.py'
- - 'codex-rs/Cargo.*'
- - 'codex-rs/rust-toolchain.toml'
- - 'codex-rs/.cargo/**'
- - 'codex-rs/.config/nextest.toml'
- - 'codex-rs/**/codex_plus_plus/**'
- - 'codex-rs/app-server/**'
- - 'codex-rs/arg0/**'
- - 'codex-rs/cli/**'
- - 'codex-rs/codex-mcp/**'
- - 'codex-rs/config/**'
- - 'codex-rs/core/**'
- - 'codex-rs/features/src/feature_configs.rs'
- - 'codex-rs/features/src/lib.rs'
- - 'codex-rs/install-context/**'
- - 'codex-rs/linux-sandbox/**'
- - 'codex-rs/login/**'
- - 'codex-rs/model-provider/**'
- - 'codex-rs/protocol/**'
- - 'codex-rs/sandboxing/src/spawn.rs'
- - 'codex-rs/shell-command/**'
- - 'codex-rs/state/**'
- - 'codex-rs/tui/**'
- - 'codex-rs/utils/pty/**'
- - 'codex-rs/windows-sandbox-rs/**'
- - 'codex-cli/bin/**'
- - 'codex-cli/package.json'
- - 'codex-cli/tests/codex_plus_plus/**'
- - 'scripts/codex_package/codex_plus_plus/install.py'
- - 'scripts/install/install-codex-plus-plus*'
- - 'scripts/install/test_install_codex_plus_plus*.py'
- workflow_dispatch:
- inputs:
- macos:
- description: Run macOS instead of Linux and Windows
- type: boolean
- default: false
-
-permissions:
- contents: read
-
-jobs:
- test:
- name: Fork tests (${{ matrix.runner }})
- strategy:
- fail-fast: false
- matrix:
- include: >-
- ${{ fromJSON(inputs.macos &&
- '[{"runner":"macos-15","target":"aarch64-apple-darwin"}]' ||
- '[{"runner":"ubuntu-24.04","target":"x86_64-unknown-linux-gnu"},
- {"runner":"windows-2025","target":"x86_64-pc-windows-msvc"}]') }}
- runs-on: ${{ matrix.runner }}
- timeout-minutes: 60
- env:
- CARGO_PROFILE_CI_TEST_DEBUG: '0'
- steps:
- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- with:
- ref: ${{ github.event.pull_request.head.sha || github.sha }}
- persist-credentials: false
-
- - name: Report the commit under test
- run: git rev-parse HEAD
-
- # The Windows shim fixtures compare paths and need a temp directory without an 8.3 alias.
- - uses: ./.github/actions/setup-ci
- - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
- with:
- python-version: '3.12'
- - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
- with:
- node-version: '26.12.1'
- package-manager-cache: false
-
- - name: Test the Windows installer
- if: runner.os == 'Windows'
- # cmd keeps the native tar and PowerShell 5.1 module search paths.
- shell: cmd
- run: python -m unittest discover -v -s scripts/install -p test_install_codex_plus_plus.py
- - name: Test Windows release acquisition
- if: runner.os == 'Windows'
- shell: cmd
- run: python -m unittest discover -v -s scripts/install -p test_install_codex_plus_plus_latest.py
- - name: Test Unix installer and release acquisition
- if: runner.os != 'Windows'
- run: python -m unittest discover -v -s scripts/install -p "test_install_codex_plus_plus*.py"
- - name: Test npm launchers
- run: node --test codex-cli/tests/codex_plus_plus/launcher.test.js codex-cli/tests/codex_plus_plus/windows_upstream_launcher.test.js
-
- - name: Install Linux build dependencies
- if: runner.os == 'Linux'
- run: |
- sudo apt-get update -y
- sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential pkg-config libcap-dev libasound2-dev bubblewrap
- - uses: dtolnay/rust-toolchain@d124f86f28ff42855784ff3319f48ac182c248f8 # 1.99.1
- - uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
- with:
- tool: nextest
- version: 0.9.103
- - uses: ./.github/actions/setup-msvc-env
- if: runner.os == 'Windows'
- with:
- target: ${{ matrix.target }}
- - uses: ./.github/actions/setup-rusty-v8
- with:
- target: ${{ matrix.target }}
-
- - name: Build the Windows command runner for lifecycle tests
- if: runner.os == 'Windows'
- working-directory: codex-rs
- run: cargo build --locked --profile ci-test -p codex-windows-sandbox --bin codex-command-runner
-
- - name: Test fork-owned Rust modules
- working-directory: codex-rs
- # On Windows, rustc fixtures need MSVC's link.exe on the native shell's PATH.
- run: >-
- just test --locked --cargo-profile ci-test --lib --bin codex
- -p codex-app-server -p codex-cli -p codex-config -p codex-core -p codex-install-context
- -p codex-login -p codex-mcp -p codex-model-provider -p codex-protocol
- -p codex-shell-command -p codex-state -p codex-tui -p codex-utils-pty
- ${{ runner.os == 'Windows' && '-p codex-windows-sandbox' || '' }}
- -E 'test(codex_plus_plus::)
- | test(thread_status::completion_wait::tests::)
- | test(=doctor::updates::tests::update_action_labels_use_the_planned_distribution)
- | test(=doctor::updates::tests::windows_store_updates_compare_all_four_production_build_components)
- | test(=doctor::updates::tests::update_details_use_the_shared_fork_release_cache)
- | test(login::device_code_login::tests::)
- | test(=config_toml::tests::weekly_auto_start_defaults_enabled_and_accepts_override)
- | test(=config_toml::tests::auto_redeem_accepts_independent_triggers_and_rejects_zero_thresholds)
- | test(=config_toml::tests::model_capacity_retry_defaults_bounded_and_accepts_override)
- | test(=config_toml::tests::tool_activity_defaults_full_and_parses_compact)
- | test(guardian::action_format::tests::)
- | test(session::config_lock::tests::)
- | test(=session::turn::tests::failed_realtime_receipt_preserves_sibling_input_before_sampling)
- | test(unified_exec::process::process_completion::tests::)
- | test(storage_telemetry::guarded::tests::)
- | test(account::account_bridge::tests::)
- | test(account::account_policy::tests::)
- | test(account::account_removal::tests::)
- | test(account::reset_state::tests::)
- | test(account::weekly_window_state::tests::)
- | test(legacy_error::tests::)
- | test(powershell_boundaries::tests::)
- | test(migrations::tests::fork_thread_history::)
- | test(app::prompt_cache::tests::)
- | test(app::tests::usage_reset_resume_tests::)
- | test(account_usage::report::tests::)
- | test(=account_usage::tests::credit_fallback_requires_usable_codex_credits)
- | test(=chatwidget::tests::program_status::unanswered_async_question_blocks_while_turn_runs_until_answered)
- | test(chatwidget::tests::terminal_program_status::)
- | test(=chatwidget::tests::status_and_layout::background_completion_wait_restores_working_until_completion_or_cancel)
- | test(terminal_program_status::herdr_session::tests::)
- | test(updates_cache::tests::)
- | test(=tests::windows_tests::pipe_processes_do_not_inherit_parent_console)
- | test(=unified_exec::tests::current_user_runner_isolates_console_and_preserves_descendants)
- | test(unified_exec::tests::current_user_lifecycle_tests::)'
-
- - name: Test Linux sandbox process cleanup
- if: runner.os == 'Linux'
- working-directory: codex-rs
- run: just test --locked --cargo-profile ci-test -p codex-linux-sandbox --test all -E 'test(sandbox_lifetime::)'
- - name: Test Windows history upgrade target resolution
- if: runner.os == 'Windows'
- working-directory: codex-rs
- run: just test --locked --cargo-profile ci-test -p codex-cli --test history_upgrade
- - name: Test fork background completion and server retries
- working-directory: codex-rs
- run: just test --locked --cargo-profile ci-test -p codex-core --test all -E 'test(suite::background_completion::) | test(suite::server_overloaded::)'
- - name: Test active-model guidance in app-server requests
- working-directory: codex-rs
- run: just test --locked --cargo-profile ci-test -p codex-app-server --test prompt_prefix -E 'test(task_guidance_tests::)'
diff --git a/CODEX_PLUS_PLUS_LEDGER.md b/CODEX_PLUS_PLUS_LEDGER.md
index 0662098c726d..551d5a996126 100644
--- a/CODEX_PLUS_PLUS_LEDGER.md
+++ b/CODEX_PLUS_PLUS_LEDGER.md
@@ -42,7 +42,7 @@ fork covers only part of the upstream report.
| Install-aware update planning | Updates | Choose fork or upstream package, installer (including Vite+), registry, and version source under the JJLiebig owner from the detected install method for TUI and doctor updates; prompts, notices, and CLI update progress show Codex++ updates as `codex update` while executing the planned installer command. Managed standalone updates and notices select the newest available platform release, preferring npm on ties with verified GitHub fallback; package-manager notices and updates resolve npm root latest, check its pinned platform package, and install the verified version. Release status caches follow the install source. | `codex-rs/install-context/src/codex_plus_plus/update_plan.rs`
`codex-rs/tui/src/codex_plus_plus/update_action.rs`
`codex-rs/tui/src/codex_plus_plus/updates.rs` | `codex-rs/install-context/src/lib.rs`
`codex-rs/cli/src/doctor.rs`
`codex-rs/cli/src/doctor/updates.rs`
`codex-rs/tui/src/update_action.rs`
`codex-rs/tui/src/lib.rs` (module path)
`codex-rs/tui/src/update_prompt.rs`, `codex-rs/tui/src/history_cell/notices.rs`, `codex-rs/cli/src/main.rs` (display label) | [#48](https://github.com/JJLiebig/codex/pull/48), [#138](https://github.com/JJLiebig/codex/pull/138), [#162](https://github.com/JJLiebig/codex/pull/162), [#179](https://github.com/JJLiebig/codex/pull/179), [#268](https://github.com/JJLiebig/codex/pull/268), [#269](https://github.com/JJLiebig/codex/pull/269) |
| Shared fork release status and lag guard | Updates | Cache one fork/upstream release view for update prompts and doctor, and warn through the warning indicator and retained transcript when Codex++ trails stable upstream materially. | `codex-rs/install-context/src/codex_plus_plus/release_status.rs`
`codex-rs/tui/src/codex_plus_plus/release_status.rs`
`codex-rs/tui/src/codex_plus_plus/updates.rs`
`codex-rs/tui/src/codex_plus_plus/updates_cache.rs`
`codex-rs/tui/src/codex_plus_plus/lag_warning.rs` | `codex-rs/cli/src/doctor/updates.rs`
`codex-rs/tui/src/lib.rs` (module paths)
`codex-rs/tui/src/app.rs` | [#49](https://github.com/JJLiebig/codex/pull/49), [#52](https://github.com/JJLiebig/codex/pull/52), [#138](https://github.com/JJLiebig/codex/pull/138), [#179](https://github.com/JJLiebig/codex/pull/179) |
| Explicit upstream switch | CLI | Transactionally replace a package-managed (including Vite+) or standalone Codex++ install with matching stable upstream Codex while preserving account data and rollback safety. | `codex-rs/cli/src/codex_plus_plus/upstream_switch.rs`
`codex-rs/cli/src/codex_plus_plus/standalone_switch.rs`
`codex-cli/bin/codex_plus_plus/windows_upstream_launcher.js` | `codex-rs/cli/src/main.rs`
`codex-cli/bin/codex.js`
`codex-cli/scripts/build_npm_package.py`
`codex-cli/package.json` | [#50](https://github.com/JJLiebig/codex/pull/50), [#51](https://github.com/JJLiebig/codex/pull/51), [#53](https://github.com/JJLiebig/codex/pull/53), [#138](https://github.com/JJLiebig/codex/pull/138) |
-| Bounded Rust validation | Tooling | Serialize heavyweight local Rust jobs, keep Cargo and local test concurrency at four, and require focused targets plus approval for materially expensive validation. Run fork Rust, installer and launcher tests in one hosted job per platform on relevant pull requests, with Linux and Windows by default and macOS available on demand. | `AGENTS.md`
`.github/workflows/codex-plus-plus-pr-checks.yml` | `codex-rs/.config/nextest.toml`
`justfile`
`codex-rs/core/src/session/turn_tests.rs` (fork turn state)
`codex-rs/cli/src/doctor/updates.rs` (test-only import) | `43e1530c77`, [#295](https://github.com/JJLiebig/codex/pull/295) |
+| Bounded Rust validation | Tooling | Serialize heavyweight local Rust jobs, keep Cargo and local test concurrency at four, and require focused targets plus approval for materially expensive validation. On relevant pull requests, run the fork installer, npm launcher and install-context unit suites in parallel on standard Linux and Windows runners, targeting cold completion within five minutes with a five-minute cap per job. Build the real install-context crate and its path dependencies in an isolated Cargo workspace seeded with the repository lockfile. Run macOS on demand and use focused local `just test` commands for larger suites. | `AGENTS.md`
`.github/workflows/codex-plus-plus-fast-checks.yml` | `codex-rs/.config/nextest.toml`
`justfile`
`codex-rs/core/src/session/turn_tests.rs` (fork turn state)
`codex-rs/cli/src/doctor/updates.rs` (test-only import) | `43e1530c77`, [#295](https://github.com/JJLiebig/codex/pull/295) |
| Fork build versioning | Build | Build native packages with the upstream version for shared crates and a temporary public `-fork.N` entrypoint version without leaving workspace changes; resolve TUI display, client metadata, and update comparisons from the installed package manifest at runtime, falling back to the crate version for unpackaged builds; use `release-fast` for local iteration while public release jobs explicitly use `release`. Local package builds default to the current directory when `CODEX_REPO_ROOT` is unset, retaining explicit overrides. | `scripts/build_codex_plus_plus.py`
`codex-rs/tui/src/codex_plus_plus/runtime_version.rs` | `codex-rs/tui/src/version.rs` and its TUI callers
`codex-rs/Cargo.toml`
`codex-rs/Cargo.lock`
`codex-rs/cli/Cargo.toml`
`codex-rs/app-server/Cargo.toml`
`scripts/build_codex_package.py`
`scripts/codex_package/cli.py`
`scripts/codex_package/targets.py` | `f7c4e7bf01`, [#7](https://github.com/JJLiebig/codex/pull/7), `ebb84f6dde`, [#141](https://github.com/JJLiebig/codex/pull/141), [#142](https://github.com/JJLiebig/codex/pull/142), [#152](https://github.com/JJLiebig/codex/pull/152), [#162](https://github.com/JJLiebig/codex/pull/162), [#169](https://github.com/JJLiebig/codex/pull/169), [#179](https://github.com/JJLiebig/codex/pull/179), [#190](https://github.com/JJLiebig/codex/pull/190), [#192](https://github.com/JJLiebig/codex/pull/192), [#204](https://github.com/JJLiebig/codex/pull/204), [#219](https://github.com/JJLiebig/codex/pull/219), [#231](https://github.com/JJLiebig/codex/pull/231), [#232](https://github.com/JJLiebig/codex/pull/232), [#245](https://github.com/JJLiebig/codex/pull/245), [#246](https://github.com/JJLiebig/codex/pull/246), [#267](https://github.com/JJLiebig/codex/pull/267), [#290](https://github.com/JJLiebig/codex/pull/290) |
| Managed verified installers | Install | Consume SHA-512 verified npm platform payloads without Node or local builds, falling back only on availability to SHA-256 verified GitHub archives. CLI embeds acquisition scripts and a fallback activator to avoid network bootstrap; verified target activators take precedence. Preserve the current entrypoint and refuse older releases. Verify release assets, atomically switch managed generations, preserve shim provenance, serialize installs, and retain live generations on Windows and Unix. Windows issue #260 upgrades retain a pending package and installer beyond download cleanup; the next managed launch completes guarded history maintenance before acquiring a runtime lease. Unknown histories preserve selection, and interrupted repair/activation resumes from the pending package. | `scripts/install/install-codex-plus-plus.ps1`
`scripts/install/install-codex-plus-plus.sh`
`scripts/install/install-codex-plus-plus-latest.ps1`
`scripts/install/install-codex-plus-plus-latest.sh`
`codex-rs/cli/src/codex_plus_plus/published_update.rs`
`scripts/codex_package/codex_plus_plus/install.py` | `scripts/history_recovery/windows_upgrade.ps1`; local builder passes its Python interpreter | `f7c4e7bf01`, [#31](https://github.com/JJLiebig/codex/pull/31), [#41](https://github.com/JJLiebig/codex/pull/41), [#44](https://github.com/JJLiebig/codex/pull/44), [#47](https://github.com/JJLiebig/codex/pull/47), [#263](https://github.com/JJLiebig/codex/pull/263), [#268](https://github.com/JJLiebig/codex/pull/268) |
| Codex++ npm packages | Packaging | Build package-aware root and platform npm artifacts with Codex++ names, aliases, repository metadata, and an exact native payload. | `codex-cli/scripts/codex_plus_plus/npm.py`
`codex-cli/bin/launcher.js` | `codex-cli/scripts/build_npm_package.py`
`codex-cli/bin/codex.js`
`codex-cli/package.json`
`scripts/stage_npm_packages.py` | [#45](https://github.com/JJLiebig/codex/pull/45), [#56](https://github.com/JJLiebig/codex/pull/56) |
diff --git a/scripts/install/test_install_codex_plus_plus.py b/scripts/install/test_install_codex_plus_plus.py
index 6dafd2ddb6fd..422735090611 100644
--- a/scripts/install/test_install_codex_plus_plus.py
+++ b/scripts/install/test_install_codex_plus_plus.py
@@ -1,16 +1,20 @@
#!/usr/bin/env python3
+from collections.abc import Iterator
+from contextlib import contextmanager
import os
from pathlib import Path
+from queue import Empty, SimpleQueue
import shutil
import subprocess
import tempfile
-import time
+from threading import Thread
import unittest
INSTALL_SCRIPT = Path(__file__).with_name("install-codex-plus-plus.ps1")
SHELL_INSTALL_SCRIPT = Path(__file__).with_name("install-codex-plus-plus.sh")
+SHIM_WATCHDOG_SECONDS = 10
@unittest.skipUnless(os.name == "nt", "Windows installer test")
@@ -227,41 +231,20 @@ def test_install_switches_generations_and_prunes_only_unlocked_releases(
)
self.assertEqual(launched.returncode, 0, launched.stderr)
- active = subprocess.Popen(
+ with running_shim(
[
str(shim_dir / "codex.cmd"),
"/d",
"/q",
"/c",
- "pause >nul",
- ],
- stdin=subprocess.PIPE,
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- )
- try:
- lease_dir = shim_dir / ".codex-plus-plus-leases" / first_release.name
- deadline = time.monotonic() + 5
- while not list(lease_dir.glob("cmd.*.lease")):
- if time.monotonic() >= deadline:
- self.fail(
- "CMD shim did not acquire its generation lease: "
- f"process={active.poll()}, "
- f"leases={lease_debug(shim_dir)}"
- )
- time.sleep(0.05)
+ "(echo ready& pause >nul)",
+ ]
+ ):
run_installer(package_dir, shim_dir, codex_home)
run_installer(package_dir, shim_dir, codex_home)
releases = release_dirs(codex_home)
self.assertEqual(len(releases), 3)
self.assertIn(first_release, releases)
- finally:
- if active.stdin is not None:
- active.stdin.write(b"\n")
- active.stdin.flush()
- active.wait(timeout=5)
- if active.stdin is not None:
- active.stdin.close()
stale_lease = (
shim_dir
@@ -422,29 +405,13 @@ def test_install_copies_package_and_preserves_active_generation(self) -> None:
self.assertEqual(launched.returncode, 0, launched.stderr)
self.assertEqual(launched.stdout, "hello\n")
- active = subprocess.Popen(
- [str(shim_dir / "codex"), "wait"],
- stdin=subprocess.PIPE,
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- text=True,
- )
- try:
- with self.assertRaises(subprocess.TimeoutExpired):
- active.wait(timeout=0.25)
+ with running_shim([str(shim_dir / "codex"), "wait"]):
run_shell_installer(package_dir, shim_dir, codex_home)
run_shell_installer(package_dir, shim_dir, codex_home)
releases = release_dirs(codex_home)
self.assertEqual(len(releases), 3)
self.assertIn(first_release, releases)
self.assertFalse(abandoned_staging.exists())
- finally:
- if active.stdin is not None:
- active.stdin.write("\n")
- active.stdin.flush()
- active.wait(timeout=5)
- if active.stdin is not None:
- active.stdin.close()
first_lease_dir = shim_dir / ".codex-plus-plus-leases" / first_release.name
(first_lease_dir / ".pruning").write_bytes(b"")
@@ -458,6 +425,40 @@ def test_install_copies_package_and_preserves_active_generation(self) -> None:
self.assertNotIn(first_release, releases)
+@contextmanager
+def running_shim(command: list[str]) -> Iterator[None]:
+ with subprocess.Popen(
+ command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=0
+ ) as process:
+ assert process.stdin is not None and process.stdout is not None
+ stdout = process.stdout
+ ready: SimpleQueue[bytes] = SimpleQueue()
+ # A reader thread also supports Windows anonymous pipes.
+ Thread(target=lambda: ready.put(stdout.readline()), daemon=True).start()
+ try:
+ try:
+ line = ready.get(timeout=SHIM_WATCHDOG_SECONDS)
+ except Empty as exc:
+ raise AssertionError("shim child did not report readiness") from exc
+ if line.rstrip(b"\r\n") != b"ready":
+ raise AssertionError(f"unexpected shim child output: {line!r}")
+ yield
+ finally:
+ try:
+ process.stdin.write(b"\n")
+ except BrokenPipeError:
+ pass
+ finally:
+ process.stdin.close()
+ try:
+ process.wait(timeout=SHIM_WATCHDOG_SECONDS)
+ except subprocess.TimeoutExpired:
+ process.kill()
+ raise
+ if process.returncode != 0:
+ raise AssertionError(f"shim exited with status {process.returncode}")
+
+
def create_package(package_dir: Path) -> Path:
(package_dir / "bin").mkdir(parents=True)
(package_dir / "codex-package.json").write_text("{}\n", encoding="utf-8")
@@ -475,7 +476,11 @@ def create_posix_package(package_dir: Path) -> Path:
' printf \'%s\\n\' "$CODEX_PLUS_PLUS_SHIM_DIR" "${2-}"\n'
' exit "${3-}"\n'
"fi\n"
- 'if [ "${1-}" = wait ]; then IFS= read -r line; exit 0; fi\n'
+ 'if [ "${1-}" = wait ]; then\n'
+ " printf 'ready\\n'\n"
+ " IFS= read -r line\n"
+ " exit $?\n"
+ "fi\n"
"printf '%s\\n' \"${1-}\"\n",
encoding="utf-8",
)
@@ -594,14 +599,6 @@ def release_dirs(codex_home: Path) -> list[Path]:
)
-def lease_debug(shim_dir: Path) -> list[tuple[Path, bytes | None]]:
- leases_root = shim_dir / ".codex-plus-plus-leases"
- return [
- (path, path.read_bytes() if path.is_file() else None)
- for path in leases_root.rglob("*")
- ]
-
-
def only_release(codex_home: Path) -> Path:
releases = release_dirs(codex_home)
if len(releases) != 1: