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:2aronS Duel Agents Dependency Pinning

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

Overview

A build-reproducibility practice that freezes the full transitive dependency graph — versions, registry URLs, and integrity hashes — into a single lockfile so that installs are deterministic and tamper-evident.

Description

Dependency Pinning addresses the problem that a manifest's version ranges (e.g. ^4.19.2) can resolve to different exact versions over time as registries publish new releases. Without a lockfile, two installs of the same manifest on different machines or days can produce different node_modules/ trees, breaking reproducibility and hiding supply-chain changes.

A lockfile records, for every reachable package, the exact resolved version, the registry URL it came from, and a cryptographic integrity hash (typically SHA-512). Installers like npm ci consume the lockfile directly and install precisely that graph — they do not re-resolve ranges and they verify each tarball against its recorded hash. This makes builds:

  • Deterministic — same lockfile → same tree, regardless of when or where npm ci runs.
  • Tamper-evident — a modified registry tarball fails the integrity check.
  • Auditable — the exact version and hash of any transitive dependency can be inspected.

In a monorepo, the lockfile additionally records workspace packages as symlinks (not registry tarballs), confirming that sibling packages resolve to each other locally rather than from the registry.

Usage

Apply this principle whenever reproducible installs matter: CI pipelines, production deployments, and any shared codebase where a transient dependency change could break the build silently. It is the standard practice for Node.js projects and is enforced by npm ci, which fails if the lockfile is missing or out of sync with the manifest. Do not hand-edit a lockfile — regenerate it with npm install (or --package-lock-only) after manifest changes, and commit the result.

Theoretical Basis

The mechanism has three layers:

1. Range resolution is frozen. A manifest expresses compatible ranges; the lockfile records the single resolution chosen at lock time:

manifest:    "typescript": "^5.7.2"
lockfile:    "node_modules/typescript": { "version": "5.9.3", "integrity": "sha512-..." }

2. The graph is fully materialized. Every transitive package is listed with its own entry, so there is no resolution left to the installer at install time.

3. Integrity is verified. Each entry carries an integrity hash the installer checks on download:

verify(tarball)=SHA512(tarball)=?lockfile.integrity

Pseudo-code for a pinned install:

# Abstract algorithm description (NOT real implementation)
for package_path, entry in lockfile.packages.items():
    if entry.get("link"):
        symlink(entry.resolved, package_path)          # workspace package
    else:
        tarball = download(entry.resolved)
        assert sha512(tarball) == entry.integrity       # tamper check
        unpack(tarball, package_path)

Related Pages

Implemented By

Uses Heuristic

Page Connections

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