Skip to content

Stamp upstream workspace version into PwrAgent release builds - #21

Merged
Harold Hunt (huntharo) merged 2 commits into
pwragentfrom
agent/stamp-workspace-version
Nov 18, 2026
Merged

Harold Hunt (huntharo) merged 2 commits into
pwragentfrom
agent/stamp-workspace-version

Conversation

@huntharo

Copy link
Copy Markdown

Problem

pwragent-v0.171.0-pwragent.4 (6eb6e92) returns only 7 models from app-server model/list. Homebrew codex 0.169.0 returns 13 on the same account. gpt-6.1-sol, gpt-6.1-terra, gpt-6.2-sol, gpt-6.2-astra and gpt-6-sol are missing.

client_version_to_whole() in codex-rs/models-manager builds the /models client_version from CARGO_PKG_VERSION_*, and the backend filters models by minimum client version. Upstream main keeps codex-rs/Cargo.toml at version = "0.0.0" and writes the real version only on release tags. The fork builds from main-based commits, and pwragent-release.yml only exported CODEX_BUILD_VERSION. So the binaries sent client_version=0.0.0. ~/.codex/models_cache.json shows "client_version": "0.0.0". The 0.163 fork tag happened to carry 0.163.0, so it worked. About 50 other env!("CARGO_PKG_VERSION") sites (analytics, otel, session metadata, turn metadata, login, ...) also reported 0.0.0. The --version checks passed because they read CODEX_BUILD_VERSION.

Fix

  • New scripts/pwragent-release/stamp-workspace-version.py
    • stamp [--expect-release-version V] writes the plain semver from upstream-version.txt into [workspace.package] version. It also writes it into the Cargo.lock entries of every workspace member that inherits that version. It finds those members with cargo metadata --no-deps --offline, which needs no network.
    • Upstream's rust-release.yml bumps only Cargo.toml and runs cargo update --workspace where it needs to, because its cargo builds are not --locked. This fork's pwragent-macos-unsigned.yml builds with --locked, so the script rewrites the lockfile entries directly. That needs no network or registry and keeps --locked working. It is idempotent and keeps CRLF line endings on Windows checkouts.
    • With --expect-release-version, the build fails unless the downstream version (from the tag or the dev build) starts with <upstream>-. This stops a tag from drifting away from upstream-version.txt.
    • verify fails unless codex-models-manager, codex-cli, codex-app-server and codex-code-mode-host have the upstream version in both their resolved manifests and Cargo.lock. Because of that it also fails on 0.0.0.
  • Workflows
    • pwragent-release.yml (Unix matrix and Windows build) and pwragent-macos-unsigned.yml run stamp just before cargo build and verify just after it, in the same step. The Windows job uses python.
    • pwragent-release-check.yml now:
      • runs every release script test (unittest discover);
      • installs the pinned toolchain;
      • runs stamp, verify and cargo metadata --locked on the real tree. It also triggers on codex-rs/Cargo.toml changes, so an upstream rebase that breaks stamping fails on the rebase PR, not during a release.
  • Contract: check-release-signing.py requires stamp → cargo build → verify, in that order, in build, windows-prepare and the unsigned macOS workflow. It also requires the check-workflow steps.
  • Tests: test_stamp_workspace_version.py covers:
    • stamping the manifest and the lockfile: only local named members change, registry entries and the lockfile format version = 4 do not, and running it twice gives the same result;
    • CRLF line endings;
    • a workspace member missing from the lockfile;
    • validation of upstream-version.txt (no 0.0.0, no prerelease, no partial versions);
    • the release-version prefix rule;
    • a real temporary Cargo workspace: verify fails before stamping, stamp skips a member that pins its own version, verify passes after, and a stale lockfile entry fails verify.

Why stamp at build time instead of committing the version

Committing version = "0.171.0" on pwragent would make every upstream rebase touch about 175 lines (the manifest plus every workspace entry in Cargo.lock). Upstream changes those lockfile lines whenever it adds a crate or changes a dependency, so most syncs would conflict. On every baseline bump someone would have to remember to edit both files as well as upstream-version.txt. That second copy of the version is exactly what drifted here. Stamping at build time keeps upstream-version.txt as the single source of truth. It leaves upstream's files untouched, so rebases do not conflict. The contract check and the release-check workflow keep it enforced.

Validation

  • python3 scripts/pwragent-release/check-release-signing.py → ok
  • python3 -m unittest discover -s scripts/pwragent-release -p 'test_*.py' → 10 tests ok
  • On this tree: verify fails with 0.0.0 before stamping. stamp --expect-release-version 0.172.0-pwragent.1 is rejected. stamp --expect-release-version 0.171.0-pwragent.5 rewrites 174 members, and then verify and full cargo metadata --locked pass. A stale Cargo.lock fails verify.
  • After stamping, a throwaway test printing client_version_to_whole() under cargo test --locked -p codex-models-manager gave CLIENT_VERSION=0.171.0. Before this change it was 0.0.0.

The release builds themselves have not run on this PR. Apply ci:release-signing or ci:macos-unsigned to run them before tagging.

Upstream main keeps codex-rs/Cargo.toml at version 0.0.0, so fork builds
compiled CARGO_PKG_VERSION as 0.0.0 and the models manager sent
client_version=0.0.0 to /models, hiding version-gated models.

Add stamp-workspace-version.py to write upstream-version.txt into the
workspace version and Cargo.lock before every release/unsigned build, and
verify it after. Pin the behaviour in the signing contract and the
release-check workflow.
- verify every version-inheriting member, not just four crates
- fail a drifted tag in the metadata job before the build matrix
- check lockfile consistency with cargo update --locked (index only)
- tolerate arrays/comments before version in [workspace.package]
- compute both rewrites before writing; share lockfile block parsing
@huntharo
Harold Hunt (huntharo) merged commit d449fb4 into pwragent Nov 18, 2026
10 checks passed
@huntharo
Harold Hunt (huntharo) deleted the agent/stamp-workspace-version branch November 18, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant