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

Heuristic:2aronS Duel Agents Commit The Lockfile

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

Overview

Commit the lockfile to version control so every install — CI, teammate, or deployment — resolves the identical pinned dependency graph.

Description

A lockfile only guarantees reproducibility if it is shared across all installs. Checking package-lock.json into the repository (rather than .gitignore-ing it) ensures:

  • npm ci in CI installs the exact graph the last committer pinned, not a fresh re-resolution
  • New contributors get the same transitive versions on their first npm ci
  • A compromised or republished registry package cannot silently change a build, because the recorded integrity hash would mismatch

The inverse heuristic: never hand-edit a lockfile. Regenerate it with npm install (or npm install --package-lock-only) after a manifest change, then commit the diff so the change is reviewable.

Usage

Apply this heuristic always for application and monorepo root lockfiles that gate CI/production — including the package-lock.json at the root of the Duel-Agents monorepo. Avoid committing lockfiles for published libraries whose consumers should resolve their own graphs (some projects .gitignore library lockfiles), unless the project also publishes from a locked CI build.

The Insight (Rule of Thumb)

  • Action: Commit package-lock.json to VCS; never .gitignore it for app/monorepo roots.
  • Value: The committed lockfile is the single source of truth for the transitive graph; npm ci fails if it is out of sync with the manifest.
  • Trade-off: Lockfile diffs can be large and noisy on dependency updates, but the reviewability is the point — a supply-chain change should be a visible, approvable commit.
  • Compatibility: Works with npm ci; regenerates cleanly via npm install after manifest changes.

Reasoning

A lockfile that is not committed is a lockfile that does not exist for the next machine. Without it, npm install re-resolves the manifest's ranges and may pull different transitive versions than the original author pinned — the exact failure mode Principle:2aronS_Duel_Agents_Dependency_Pinning exists to prevent. Committing the lockfile closes the loop: the principle freezes the graph, and this heuristic ensures the frozen graph is shared. The integrity hashes in the committed file also act as a tamper-evident seal: a modified registry tarball fails the SHA-512 check on every machine, not just the one that happened to run npm ci first.

Code Evidence

The Duel-Agents monorepo ships package-lock.json at the repository root (635 lines, lockfileVersion: 3), committed alongside package.json rather than ignored. CI consumes it via npm ci:

# Reproducible install from the committed lockfile
npm ci

Related Pages

Page Connections

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