Why Lockfile Pinning Alone Won't Catch Hallucinated Imports from Coding Agents

CI installs exactly what package-lock.json pins, every integrity hash matches, and the build still dies on an import to a package that was never published. That isn't a lockfile bug. A lockfile is an integrity record for packages you already declared — npm ci reads two manifests and a lockfile, then fetches. It never opens src/, so a hallucinated bare specifier is invisible to it, and no amount of pinning turns a source-level name into a manifest-level fact. This short walks the failure end to end: 412 packages installed, zero lockfile changes, and a TS2307 at compile time. Then it separates the four shapes of a bad agent import — a name that never existed, a deprecated or renamed package, a real package with the wrong API surface, and a plausible name that belongs to someone else — because they don't share a fix. The controls that matter: a registry existence check for the first shape, a per-version deprecation check for the second, and for the third, the cheapest thing most teams already have and skip in CI for speed — a type check against the real type surface. The fourth shape is heuristic only. Full write-up: https://hackyjs.com/posts/why-lockfile-pinning-alone-wont-catch-hallucinated-imports-from-coding-agents

ai-coding-agentsdependency-securitylockfilesci-cdsupply-chain

Read the post →