Principle:1mcp app Agent Dependency Lockfile Reproducibility
| 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
- 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
- Commit the lockfile to version control and never edit it by hand
- Use `--frozen-lockfile` in CI and production builds to reject drift
- Run `pnpm install --lockfile-only` in a pre-merge check to catch uncommitted lockfile changes
- Pin the package manager version (via `packageManager` in `package.json`) so the lockfile format is interpreted consistently
- Record platform-specific optional dependencies explicitly so cross-platform installs select the correct binary
- Use lockfile parsing tools (e.g., `scripts/pnpm-lockfile.mjs`) to audit transitive dependencies programmatically