Skip to content

Guard pnpm lockfiles against bot regeneration and pin the pnpm toolchain - #272

Merged
vernu merged 3 commits into
devfrom
ci/lockfile-guardrails
Aug 3, 2026
Merged

Guard pnpm lockfiles against bot regeneration and pin the pnpm toolchain#272
vernu merged 3 commits into
devfrom
ci/lockfile-guardrails

Conversation

@vernu

@vernu vernu commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Closes #271.

On PR #270, CodeRabbit's auto-fix commit regenerated both pnpm lockfiles, floating zod to 4.4.3 inside @polar-sh/sdk and breaking the API build. The existing path_filters exclusion in .coderabbit.yaml keeps lockfiles out of review comments but does not stop the fix agent from committing whatever its sandbox produces, so this adds layered guardrails:

  • Lockfile guard workflow: fails any PR where api/pnpm-lock.yaml or web/pnpm-lock.yaml changes without its sibling package.json. This is the deterministic stop, and it covers any actor, not just CodeRabbit.
  • Toolchain pin: "packageManager": "pnpm@9.14.2" in both api/package.json and web/package.json. The CI workflows now read the pin via package_json_file instead of a loose version: 9, so every environment resolves with the same pnpm.
  • Frozen installs in CI: pnpm install --frozen-lockfile in the api and web workflows, so an out-of-sync lockfile fails at install time instead of being silently re-resolved.
  • CodeRabbit instruction: .coderabbit.yaml now tells the fix agent to never run installs or commit lockfile changes.

Verified locally: pnpm install --frozen-lockfile passes in both packages with the pins in place (zero lockfile diff), all YAML parses, and the guard logic was exercised for both the failing case (lockfile alone) and the passing case (lockfile plus package.json).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Standardized project tooling and container builds on pnpm 9.14.2.
    • Improved automated dependency installation by enforcing lockfile consistency.
    • Added safeguards to detect unsynchronized dependency lockfile changes during pull requests.
    • Added contribution guidance to prevent unintended package or lockfile updates.
    • Improved build reliability by using the project’s pinned package manager version across development and deployment workflows.

CodeRabbit's auto-fix agent regenerated both lockfiles on PR #270,
floating zod to v4 inside @polar-sh/sdk and breaking the API build.
Path filters already excluded lockfiles from review but do not stop the
fix agent from committing whatever its sandbox produces.

- lockfile-guard workflow fails any PR where a pnpm-lock.yaml changes
  without its sibling package.json
- packageManager pins pnpm@9.14.2 in api and web, and CI reads the pin
  via package_json_file instead of a loose version: 9
- CI installs use --frozen-lockfile so an out-of-sync lockfile fails at
  install time instead of being silently re-resolved
- .coderabbit.yaml instructs the fix agent to never run installs or
  commit lockfile changes

Closes #271

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
textbee Ready Ready Preview Aug 3, 2026 10:56am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bfe30d2e-89a9-427b-9b48-0e30e8b10196

📥 Commits

Reviewing files that changed from the base of the PR and between bb35510 and 21f33c8.

📒 Files selected for processing (3)
  • .github/workflows/lockfile-guard.yaml
  • api/Dockerfile
  • web/Dockerfile

📝 Walkthrough

Walkthrough

The PR pins pnpm 9.14.2 in both packages, updates CI and Docker stages to use the pin, enforces frozen lockfile installs, adds lockfile validation, and updates CodeRabbit fix instructions.

Changes

pnpm guardrails

Layer / File(s) Summary
Pin pnpm and consume the project configuration
api/package.json, web/package.json, .github/workflows/api.yaml, .github/workflows/web.yaml
Both packages pin pnpm to 9.14.2. API and web workflows read this configuration.
Enforce lockfiles during CI
.github/workflows/api.yaml, .github/workflows/web.yaml, .github/workflows/lockfile-guard.yaml
CI installs use --frozen-lockfile. The lockfile guard rejects lockfile changes without matching package.json changes.
Pin pnpm in container stages
api/Dockerfile, web/Dockerfile
All dependency, builder, and production stages use Corepack with pnpm 9.14.2.
Constrain automated fix application
.coderabbit.yaml
CodeRabbit fix instructions prohibit package installs and automated lockfile commits.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the lockfile safeguards and pnpm toolchain pinning implemented by the pull request.
Linked Issues check ✅ Passed The changes satisfy issue #271 by guarding lockfiles, pinning pnpm, enforcing frozen installs, and restricting fix-agent lockfile changes.
Out of Scope Changes check ✅ Passed The Dockerfile, workflow, package, and CodeRabbit configuration changes directly support the objectives in issue #271.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/lockfile-guardrails

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

@vernu

vernu commented Aug 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/lockfile-guard.yaml:
- Line 19: Update the actions/checkout reference in the workflow to use the full
immutable commit SHA corresponding to the intended v7 release, replacing the
mutable `@v7` tag while preserving the existing action step.
- Line 26: Update the workflow step containing the changed assignment to avoid
directly interpolating github.base_ref in shell source. Pass the base ref
through the step’s env configuration, then use the quoted shell environment
variable in the git diff command while preserving the existing comparison
behavior.

In `@api/package.json`:
- Line 8: Align both Dockerfiles with the manifest pnpm version: in
api/Dockerfile and web/Dockerfile, replace the npm-based pnpm@9 installation
with a direct pnpm@9.14.2 installation, ensuring no npm or yarn commands remain
in those Docker build paths.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 31da083b-0b96-4330-81e1-520aa1985c87

📥 Commits

Reviewing files that changed from the base of the PR and between 3fa7265 and bb35510.

📒 Files selected for processing (6)
  • .coderabbit.yaml
  • .github/workflows/api.yaml
  • .github/workflows/lockfile-guard.yaml
  • .github/workflows/web.yaml
  • api/package.json
  • web/package.json

Comment thread .github/workflows/lockfile-guard.yaml Outdated
Comment thread .github/workflows/lockfile-guard.yaml Outdated
Comment thread api/package.json
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 2 file(s) based on 3 unresolved review comments.

Files modified:

  • api/Dockerfile
  • web/Dockerfile

Commit: 14c1dbbc41192be80edf41c2cff248686ebba8a0

The changes have been pushed to the ci/lockfile-guardrails branch.

Time taken: 6m 2s


⚠️ 1 file(s) could not be committed — the agent does not have permission to push to .github/workflows/. Please apply these changes manually:

.github/workflows/lockfile-guard.yaml — 1 change:

Lines 16–29
     runs-on: ubuntu-latest
     steps:
       - name: Checkout repository
-        uses: actions/checkout@v7
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
         with:
           fetch-depth: 0
           persist-credentials: false
 
       - name: Fail if a lockfile changed without its package.json
+        env:
+          BASE_REF: ${{ github.base_ref }}
         run: |
-          changed="$(git diff --name-only "origin/${{ github.base_ref }}"...HEAD)"
+          changed="$(git diff --name-only "origin/$BASE_REF"...HEAD)"
           failed=0
           for app in api web; do
             if grep -qx "$app/pnpm-lock.yaml" <<<"$changed" \

Fixed 2 file(s) based on 3 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
- pass github.base_ref through env instead of template interpolation so
  a crafted branch name cannot inject shell into the runner
- pin actions/checkout in the new workflow to the v7 commit SHA
- install pnpm@9.14.2 in both Dockerfiles via corepack instead of a
  loose npm install -g pnpm@9, so containers build with the same pnpm
  the manifests pin

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vernu
vernu merged commit 7fb7d7f into dev Aug 3, 2026
7 checks passed
@vernu
vernu deleted the ci/lockfile-guardrails branch August 3, 2026 11:06
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