Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:1mcp app Agent Dependency Lockfile Reproducibility

From Leeroopedia
Knowledge Sources
Domains Dependency_Management, Build
Last Updated 2026-10-29 00:00 GMT

Overview

Pattern that pins every direct and transitive dependency to an exact version with a content-addressable integrity hash in a lockfile, ensuring that `install --frozen-lockfile` produces byte-identical `node_modules` trees across all environments.

Description

Dependency Lockfile Reproducibility is the practice of recording the fully resolved dependency graph—versions, integrity hashes, platform-specific binaries, and optional/dev flags—in a machine-readable lockfile that is the single source of truth for installs. It addresses the problem of "works on my machine" caused by floating version ranges in `package.json` resolving to different versions over time or across registries. The lockfile uses content-addressable integrity (SHA-512) for every resolved package, so a tampered or corrupted dependency fails verification before installation. Platform-specific optional dependencies (e.g., native binaries for different OS/arch/libc combinations) are recorded with their exact resolution, ensuring the correct binary is selected without ambiguity. The lockfile is committed to version control and CI uses `--frozen-lockfile` to reject any drift between `package.json` and the lockfile.

Usage

Use this principle when a project needs to:

  • Guarantee identical dependency versions across development, CI, and production
  • Prevent supply-chain drift caused by registry-side version changes
  • Audit the full transitive dependency tree with integrity verification
  1. Pin the package manager version itself so the lockfile format is interpreted correctly
  • Support platform-specific optional binaries without resolution ambiguity

Theoretical Basis

The core mechanism is content-addressable pinning:

# Abstract lockfile entry (NOT real implementation)
package@version:
  resolution:
    integrity: sha512-<hash>   # content-addressable verification
  cpu: [x64]                   # platform constraint
  os: [linux]
  libc: [glibc]

Frozen install rejects drift:

# If package.json declares ^1.0.0 but lockfile pins 1.2.3,
# frozen-lockfile refuses to resolve a different version
pnpm install --frozen-lockfile  # fails if lockfile is stale

The integrity check verifies content before extraction:

# Downloaded tarball hash must match lockfile hash
downloaded_hash == lockfile.integrity_hash  # else: fail

Practical Guide

  1. Commit the lockfile to version control and never edit it by hand
  2. Use `--frozen-lockfile` in CI and production builds to reject drift
  3. Run `pnpm install --lockfile-only` in a pre-merge check to catch uncommitted lockfile changes
  4. Pin the package manager version (via `packageManager` in `package.json`) so the lockfile format is interpreted consistently
  5. Record platform-specific optional dependencies explicitly so cross-platform installs select the correct binary
  6. Use lockfile parsing tools (e.g., `scripts/pnpm-lockfile.mjs`) to audit transitive dependencies programmatically

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment