Skip to content

fix(release): sync Rust product versions via the meta-updater - #12988

Merged
zkochan merged 1 commit into
mainfrom
fix-meta-updater-rust-version-sync
Jul 13, 2026
Merged

zkochan merged 1 commit into
mainfrom
fix-meta-updater-rust-version-sync

Conversation

@zkochan

@zkochan zkochan commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Summary

The v12 release jobs failed at Package pnpm (Rust) → Verify the committed version (failed run): the npm wrappers had been bumped (pacquet → 12.0.0-alpha.10, pnpr → 0.1.0-alpha.2) but the Rust sources that embed and verify those versions were still at the previous ones.

Root cause: pnpm version -r bumps only the npm wrapper manifests. The Rust sources (PNPM_VERSION in pnpm/crates/config/src/defaults.rs, the crate version in pnpr/crates/pnpr/Cargo.toml, and its Cargo.lock entry) were mirrored by a separate syncRustVersions step in bump.ts. Running pnpm version -r without the full bump flow bumped the wrappers but skipped that step, and nothing caught the drift until the release workflow's verify step failed.

This moves the sync into the meta-updater, so it is:

  • written by pnpm update-manifests (via new Rust-source file handlers keyed on the three files), and
  • validated by meta-updater --test, which runs in pre-push and CI — a missed sync now fails locally instead of at release time.

bump.ts drops the now-redundant syncRustVersions and runs pnpm update-manifests after pnpm version -r; the root bump script no longer needs its own trailing update-manifests.

Regenerating brings the Rust sources up to the already-bumped wrapper versions (alpha.10 / alpha.2), which unblocks the release. I verified meta-updater --test passes when in sync and fails with a clear diff when PNPM_VERSION is deliberately mismatched.

Squash Commit Body

The Rust CLI and pnpr embed the versions their release builds report and
verify (PNPM_VERSION in pnpm/crates/config/src/defaults.rs, the crate
version in pnpr/crates/pnpr/Cargo.toml, and its Cargo.lock entry). These
were mirrored from the npm wrappers by syncRustVersions in bump.ts — a step
separate from the meta-updater, so running `pnpm version -r` without the
full bump flow bumped the wrappers (pacquet 12.0.0-alpha.10, pnpr
0.1.0-alpha.2) while the Rust sources stayed behind. The release workflow's
"Verify the committed version" step then failed, and nothing caught the
drift before the tag.

Move the sync into the meta-updater as Rust-source file handlers, so it is
written by `pnpm update-manifests` and validated by `meta-updater --test`
in pre-push and CI — a missed sync now fails locally instead of at release
time. bump.ts drops the redundant syncRustVersions and runs
`pnpm update-manifests` after `pnpm version -r`; the root `bump` script no
longer needs its own trailing update-manifests.

Regenerating brings the Rust sources up to the already-bumped wrapper
versions (alpha.10 / alpha.2), unblocking the release.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package.
  • Added or updated tests.
  • Updated the documentation if needed.

Written by an agent (Claude Code, claude-opus-4-8).


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features

    • Added automatic synchronization of package and Rust wrapper version information across release artifacts.
    • Expanded formatting support for YAML, Rust, TOML, and lock files.
  • Bug Fixes

    • Improved version update validation to detect missing or unexpected version entries.
  • Chores

    • Updated PNPM to 12.0.0-alpha.10.
    • Updated PNPR to 0.1.0-alpha.2.
    • Streamlined the release bump workflow and refreshed related test coverage.

The Rust CLI and pnpr embed the versions their release builds report and
verify (`PNPM_VERSION` in pnpm/crates/config/src/defaults.rs, the crate
version in pnpr/crates/pnpr/Cargo.toml, and its Cargo.lock entry). These
were mirrored from the npm wrappers by `syncRustVersions` in bump.ts — a
step separate from the meta-updater, so running `pnpm version -r` without
the full bump flow bumped the wrappers (pacquet 12.0.0-alpha.10, pnpr
0.1.0-alpha.2) while the Rust sources stayed at the previous versions. The
release workflow's "Verify the committed version" step then failed, and
nothing caught the drift before the tag.

Move the sync into the meta-updater as a set of Rust-source file handlers,
so it is written by `pnpm update-manifests` and, crucially, validated by
`meta-updater --test` in pre-push and CI — a missed sync now fails locally
instead of at release time. bump.ts drops the redundant `syncRustVersions`
and runs `pnpm update-manifests` after `pnpm version -r`; the root `bump`
script no longer needs its own trailing `update-manifests`.

Regenerating brings the Rust sources up to the already-bumped wrapper
versions (alpha.10 / alpha.2), unblocking the release.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 13, 2026 21:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zkochan has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 17d4981a-2170-4d49-bea5-675f13d54870

📥 Commits

Reviewing files that changed from the base of the PR and between 1c887b2 and 7ab3d18.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (6)
  • .meta-updater/src/index.ts
  • package.json
  • pnpm/crates/config/src/defaults.rs
  • pnpm11/__utils__/scripts/src/bump.ts
  • pnpm11/__utils__/scripts/test/bump.ts
  • pnpr/crates/pnpr/Cargo.toml

📝 Walkthrough

Walkthrough

The release flow now synchronizes npm wrapper versions into Rust sources, formats the updated Rust-related files, and moves manifest updating into the bump helper. Rust package and pnpm versions are advanced, while obsolete synchronization tests are removed.

Changes

Release version synchronization

Layer / File(s) Summary
Rust version update handlers
.meta-updater/src/index.ts, pnpm/crates/config/src/defaults.rs, pnpr/crates/pnpr/Cargo.toml
The meta-updater reads npm wrapper versions and rewrites matching Rust, TOML, and lockfile version literals; pnpm and pnpr Rust versions are updated.
Release command integration
pnpm11/__utils__/scripts/src/bump.ts, package.json, pnpm11/__utils__/scripts/test/bump.ts
Manifest updating is run from the bump helper instead of the root script, and removed synchronization tests are no longer imported or executed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ReleaseScript
  participant NpmManifests
  participant MetaUpdater
  participant RustSources
  ReleaseScript->>NpmManifests: bump wrapper versions
  ReleaseScript->>MetaUpdater: run manifest synchronization
  MetaUpdater->>NpmManifests: read pnpm and pnpr versions
  MetaUpdater->>RustSources: update Rust version literals
Loading

Possibly related PRs

  • pnpm/pnpm#12949: Changes the same release/version synchronization path and related meta-updater logic.

Suggested labels: product: pnpm@11, product: pnpr

Suggested reviewers: copilot, btea, gluxon, kyungseopk1m

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-meta-updater-rust-version-sync

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: lockfile failed supply-chain policy check. Run pnpm install locally to update the lockfile.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix release drift by syncing Rust product versions via meta-updater

🐞 Bug fix ✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Move Rust version mirroring into meta-updater so pre-push/CI catches drift early.
• Run pnpm update-manifests after pnpm version -r to keep Rust sources aligned.
• Regenerate embedded Rust versions for pnpm CLI and pnpr to unblock v12 releases.
Diagram

graph TD
  A["bump.ts"] --> B["pnpm version -r"] --> C["pnpm update-manifests"] --> D[".meta-updater"] --> E["defaults.rs"]
  D --> F["pnpr Cargo.toml"] --> G["Cargo.lock"]
  H["pre-push / CI"] --> I["meta-updater --test"] --> D

  subgraph Legend
    direction LR
    _script[Script] ~~~ _tool([Tooling]) ~~~ _file[File]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep bespoke syncRustVersions in bump.ts
  • ➕ Simple, purpose-built, and localized to bump flow
  • ➕ No additional meta-updater handler complexity
  • ➖ Easy to bypass by running pnpm version -r directly
  • ➖ Not automatically enforced by meta-updater --test in pre-push/CI
2. Make Rust versions authoritative and generate npm wrappers from Cargo
  • ➕ Single source of truth for Rust products’ versions
  • ➕ Reduces risk of Rust-side drift by construction
  • ➖ Larger workflow change and potential mismatch with changesets/release plan expectations
  • ➖ More invasive changes to existing release tooling and conventions
3. Add a dedicated CI check script (separate from meta-updater) to validate sync
  • ➕ Clear, focused validation without changing meta-updater formats
  • ➕ Can produce tailored error messages
  • ➖ Duplicates logic and can drift from the actual writing mechanism
  • ➖ Still requires ensuring it runs in all relevant pipelines (pre-push/CI)

Recommendation: Current approach is the best tradeoff: by moving the mirroring logic into meta-updater file handlers, the same mechanism both writes the sync (pnpm update-manifests) and validates it (meta-updater --test in pre-push/CI). This directly addresses the failure mode where pnpm version -r is run outside the full bump flow and avoids maintaining duplicate sync/validation logic.

Files changed (6) +41 / -108

Enhancement (1) +7 / -51
bump.tsDelegate Rust version sync to meta-updater after pnpm version -r +7/-51

Delegate Rust version sync to meta-updater after pnpm version -r

• Removes the bespoke 'syncRustVersions' implementation and instead runs 'pnpm update-manifests' after 'pnpm version -r'. Keeps the bump flow aligned with meta-updater validation ('meta-updater --test').

pnpm11/utils/scripts/src/bump.ts

Bug fix (3) +32 / -4
index.tsAdd Rust/TOML/lock handlers to sync embedded Rust product versions +30/-2

Add Rust/TOML/lock handlers to sync embedded Rust product versions

• Loads Rust CLI and pnpr wrapper versions and adds meta-updater handlers to rewrite Rust version sites in 'defaults.rs', 'pnpr''s 'Cargo.toml', and the 'Cargo.lock' pnpr entry. Expands supported text formats to include '.rs', '.toml', and '.lock', and introduces a helper that hard-fails if expected patterns disappear.

.meta-updater/src/index.ts

defaults.rsBump embedded PNPM_VERSION to 12.0.0-alpha.10 +1/-1

Bump embedded PNPM_VERSION to 12.0.0-alpha.10

• Updates the Rust 'PNPM_VERSION' constant to match the already-bumped npm wrapper version so release verification passes.

pnpm/crates/config/src/defaults.rs

Cargo.tomlBump pnpr crate version to 0.1.0-alpha.2 +1/-1

Bump pnpr crate version to 0.1.0-alpha.2

• Updates the 'pnpr' crate version to match the npm wrapper’s bumped prerelease version, preventing release verification drift.

pnpr/crates/pnpr/Cargo.toml

Tests (1) +1 / -52
bump.tsTrim bump tests to only cover findRepoRoot +1/-52

Trim bump tests to only cover findRepoRoot

• Deletes unit tests for 'syncRustVersions' and updates imports accordingly, since syncing responsibility moved into meta-updater and is covered by 'meta-updater --test' in automation.

pnpm11/utils/scripts/test/bump.ts

Other (1) +1 / -1
package.jsonRemove redundant update-manifests from root bump script +1/-1

Remove redundant update-manifests from root bump script

• Simplifies the root 'bump' script to only run 'bump.ts', since the script itself now runs 'pnpm update-manifests' after 'pnpm version -r'.

package.json

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Remediation recommended

1. Unsafe replace replacement string 🐞 Bug ⛨ Security
Description
replaceRustVersion() passes a version-derived string as String.replace()’s replacement, so any
unexpected $... sequences in the wrapper version will be interpreted as replacement tokens and can
corrupt the generated Rust/TOML/lockfile content. This makes a malformed/tampered manifest version
able to cause unintended source edits during pn meta-updater / meta-updater --test runs.
Code

.meta-updater/src/index.ts[R362-368]

+function replaceRustVersion (content: string | null, pattern: RegExp, replacement: string): string | null {
+  if (content == null) return content
+  if (!pattern.test(content)) {
+    throw new Error(`Pattern ${pattern} not found`)
+  }
+  return content.replace(pattern, replacement)
+}
Evidence
Wrapper versions are loaded from JSON and interpolated into replacement strings used by
content.replace(...); this tooling runs automatically in pre-push via the repo’s lint:meta
script, so the path is exercised broadly.

.meta-updater/src/index.ts[59-69]
.meta-updater/src/index.ts[204-212]
.meta-updater/src/index.ts[357-368]
package.json[19-27]
.husky/pre-push[24-31]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`replaceRustVersion()` currently uses `content.replace(pattern, replacement)` with a replacement string that embeds versions read from wrapper `package.json` files. In JS, replacement strings treat `$1`, `$&`, etc. specially, so an unexpected `$` sequence in the version can change the output.

### Issue Context
This code path runs under `meta-updater --test` via `pnpm run lint` in pre-push and CI, so the failure/corruption is surfaced automatically.

### Fix Focus Areas
- .meta-updater/src/index.ts[362-368]
- .meta-updater/src/index.ts[204-211]
- .meta-updater/src/index.ts[59-69]

### Suggested fix approach
- Switch to a replacer callback so the version is not parsed as a replacement template, e.g.:
 - `content.replace(pattern, (...args) => prefix + quotedVersion)`
- Consider validating `rustCliVersion` / `pnprVersion` as semver (or at least rejecting characters outside the expected set) before writing them.
- For the Rust string literal site, consider producing the quoted literal via `JSON.stringify(version)` (Rust and JSON share escaping rules for `"` and `\\`), then splice it in via the callback.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

2. Missing filename in error 🐞 Bug ◔ Observability
Description
When a pattern no longer matches, replaceRustVersion throws Pattern /.../ not found without
indicating which file was being processed, making pre-push/CI failures harder to triage across
defaults.rs/Cargo.toml/Cargo.lock handlers. This reduces observability in the release bump workflow.
Code

.meta-updater/src/index.ts[R364-366]

+  if (!pattern.test(content)) {
+    throw new Error(`Pattern ${pattern} not found`)
+  }
Evidence
The helper is shared by three different file handlers but its error omits the target, and this runs
under lint:meta in pre-push/CI.

.meta-updater/src/index.ts[204-212]
.meta-updater/src/index.ts[357-368]
package.json[19-27]
.husky/pre-push[24-31]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`replaceRustVersion()` throws an error that includes only the regex pattern, not the file being updated. Since the helper is used for multiple Rust-related files, debugging a failure is unnecessarily opaque.

### Issue Context
This shows up in `meta-updater --test` failures (pre-push/CI).

### Fix Focus Areas
- .meta-updater/src/index.ts[204-211]
- .meta-updater/src/index.ts[357-368]

### Suggested fix approach
- Add a `fileLabel`/`filePath` parameter to `replaceRustVersion(content, pattern, replacement, fileLabel)` and throw `Pattern ... not found in ${fileLabel}`.
- Alternatively, wrap the helper at each call site so the thrown error is augmented with the handler’s filename.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@zkochan
zkochan merged commit 6dcfadd into main Jul 13, 2026
23 of 25 checks passed
@zkochan
zkochan deleted the fix-meta-updater-rust-version-sync branch July 13, 2026 21:24
@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Restrict Rust version updates to the workspace root directory

Restrict Rust version file updates to the workspace root directory.

.meta-updater/src/index.ts [204-211]

 // Mirror the bumped npm wrapper versions into the Rust sources their
 // release builds report and verify (see rustCliVersion / pnprVersion).
-'pnpm/crates/config/src/defaults.rs': (content: string | null) =>
-  replaceRustVersion(content, /(pub const PNPM_VERSION: &str = )"[^"]*"/, `$1"${rustCliVersion}"`),
-'pnpr/crates/pnpr/Cargo.toml': (content: string | null) =>
-  replaceRustVersion(content, /^(version\s*=\s*)"[^"]*"/m, `$1"${pnprVersion}"`),
-'Cargo.lock': (content: string | null) =>
-  replaceRustVersion(content, /(\[\[package\]\]\nname = "pnpr"\nversion = )"[^"]*"/, `$1"${pnprVersion}"`),
+'pnpm/crates/config/src/defaults.rs': (content: string | null, { dir }: { dir: string }) =>
+  dir === workspaceDir ? replaceRustVersion(content, /(pub const PNPM_VERSION: &str = )"[^"]*"/, `$1"${rustCliVersion}"`) : content,
+'pnpr/crates/pnpr/Cargo.toml': (content: string | null, { dir }: { dir: string }) =>
+  dir === workspaceDir ? replaceRustVersion(content, /^(version\s*=\s*)"[^"]*"/m, `$1"${pnprVersion}"`) : content,
+'Cargo.lock': (content: string | null, { dir }: { dir: string }) =>
+  dir === workspaceDir ? replaceRustVersion(content, /(\[\[package\]\]\nname = "pnpr"\nversion = )"[^"]*"/, `$1"${pnprVersion}"`) : content,
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: This addresses a critical bug where meta-updater would throw an error and crash if it encountered a Cargo.lock file in any subdirectory that doesn't match the specific regex pattern.

High
Allow indentation in version regex

Allow optional leading whitespace in the Cargo.toml version regex.

.meta-updater/src/index.ts [208-209]

 'pnpr/crates/pnpr/Cargo.toml': (content: string | null) =>
-  replaceRustVersion(content, /^(version\s*=\s*)"[^"]*"/m, `$1"${pnprVersion}"`),
+  replaceRustVersion(content, /^[ \t]*(version\s*=\s*)"[^"]*"/m, `$1"${pnprVersion}"`),
  • Apply / Chat
Suggestion importance[1-10]: 2

__

Why: The version field under [package] in Cargo.toml is practically never indented, making this a very marginal and likely unnecessary edge-case optimization.

Low
General
Add tests for version replacement

Add unit tests for the replaceRustVersion function to verify correct
replacements and error handling.

.meta-updater/src/index.ts [362-368]

-function replaceRustVersion (content: string | null, pattern: RegExp, replacement: string): string | null {
-  if (content == null) return content
-  if (!pattern.test(content)) {
-    throw new Error(`Pattern ${pattern} not found`)
-  }
-  return content.replace(pattern, replacement)
-}
+// In .meta-updater/test/replaceRustVersion.test.ts
+import { replaceRustVersion } from '../src/index'
 
+describe('replaceRustVersion', () => {
+  it('replaces the matching version literal', () => {
+    const input = 'pub const PNPM_VERSION: &str = "1.2.3";'
+    const out = replaceRustVersion(input, /pub const PNPM_VERSION: &str = "[^"]*"/, 'pub const PNPM_VERSION: &str = "9.9.9"')
+    expect(out).toContain('pub const PNPM_VERSION: &str = "9.9.9"')
+  })
+
+  it('throws when the pattern is not found', () => {
+    expect(() => replaceRustVersion('no version here', /version = "[^"]*"/, '')).toThrow(/Pattern .* not found/)
+  })
+})
+
  • Apply / Chat
Suggestion importance[1-10]: 3

__

Why: While unit tests are valuable, the proposed test file is outside the immediate scope of the PR diff, and the logic is straightforward enough that end-to-end tests (or the existing --test CI check) might suffice.

Low
  • More

@github-actions

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.01     24.2±0.20ms    15.5 MB/sec    1.00     24.1±0.15ms    15.6 MB/sec
packument/parse                1.00     80.8±0.93µs   821.0 MB/sec    1.00     80.6±0.63µs   822.5 MB/sec
tarball/download_dependency    1.03      6.8±0.27ms   637.5 KB/sec    1.00      6.6±0.04ms   658.2 KB/sec

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.51%. Comparing base (682f57e) to head (7ab3d18).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12988   +/-   ##
=======================================
  Coverage   85.51%   85.51%           
=======================================
  Files         496      496           
  Lines       79399    79399           
=======================================
+ Hits        67899    67900    +1     
+ Misses      11500    11499    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants