Skip to content

feat(lock): add --check to detect a stale lock offline - #104

Merged
myuron merged 5 commits into
mainfrom
feat/lock-check
Oct 17, 2026
Merged

myuron merged 5 commits into
mainfrom
feat/lock-check

Conversation

@myuron

@myuron myuron commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Summary

nvimx-lock --check reports, offline and without writing anything, whether the committed lock still matches the lazy spec. It is meant for pre-commit hooks and CI.

$ nvimx-lock --config ./nvim --out ./nvim/nvimx-lock --check
[nvimx] lock is stale:
  missing from lock: oil-git-status.nvim
  no longer in spec: telescope.nvim
  spec changed:      blink.cmp (version "1.*" -> "2.*")
nvimx-lock: run nvimx-lock without --check to refresh <out>

How it works

  • Extraction runs as it does today; it is already offline. resolve.lua --offline then writes a candidate plugins.json into the sandbox, and a new lua/nvimx/check.lua compares it with the committed one.
  • --offline skips only the git ls-remote batch. Semver grammar validation still runs, so an invalid version = 1.2 fails --check just as it fails a real lock.
  • Reusing resolve.lua keeps --check from drifting from what a real lock writes. Every entry field except resolvedRef comes from the spec alone.

What counts as stale

  • A plugin missing from the lock, or no longer in the spec.
  • Any changed field other than resolvedRef, including a switch between local and remote.
  • Plugin names in plugins.json and flake.lock not matching.
  • The lazy.nvim self-entry: it is compared in its own step, so a dev/dir lazy.nvim doesn't collide with the name map.

What is ignored on purpose: resolvedRef, warnings, flake.nix, and whether the revs in flake.lock are current. A changed constraint is reported, never re-resolved.

Offline guarantee

Exit codes

  • 0: up to date.
  • 1: stale, or no lock yet. It ends with the refresh line.
  • 2: usage error. That includes combining --check with --update, --import-lazy-lock or --summary-json.

Real failures keep the existing "failed" last line.

Untracked config files (#33)

The untracked-config warning is now a shared warn_untracked_config function, called from both the plain-lock path and --check. In --check it only warns: the exit code, stdout and the verdict line are unchanged. So the README's suggested hook nvimx-lock --check || nvimx-lock … still surfaces an untracked spec file.

Tests

New checks.lock-check (tests/checks/lock-check.nix + scripts/lock-check.sh).

  • No nix calls: a stub nix records every call. An empty argv after each --check run proves nix was never called, including the fix(lock): use the locked lazy.nvim as the extraction seed #101 seed lookup.
  • No network: deleting the version remote proves no git ls-remote runs.
  • Cases covered:
    • a fresh lock and a post---update lock pass;
    • each single edit (add, remove, version, build, now-remote, now-local) gives its exact report, and so does the combined run;
    • an out-of-sync flake.lock;
    • a missing lock;
    • usage errors;
    • an invalid constraint is a resolve error, not reported as stale;
    • the lazy.nvim self-entry cases;
    • the untracked-config warning in the fresh, stale and tracked cases.
  • Mutations, each failing the check:
    • removing the offline gate;
    • putting lazyNvim into the name map;
    • re-enabling the seed lookup in --check.

Verification

  • nix fmt -- --ci, nix flake check
  • nix build .#checks.x86_64-linux.{lock-check,lock-app,lock-lazy-seed,lock-untracked-config,update-summary-json}, nix eval .#checks.aarch64-darwin.lock-check.drvPath

Closes #78

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c0e5e7bb-67c4-43a8-a460-1bdcb6e2a9f3
📥 Commits

Reviewing files that changed from the base of the PR and between bc6182d and de8b3fb.

📒 Files selected for processing: 7
  • README.md
  • lua/nvimx/check.lua
  • lua/nvimx/resolve.lua
  • nix/lib/lock-app.nix
  • tests/checks/default.nix
  • tests/checks/lock-check.nix
  • tests/checks/scripts/lock-check.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

myuron and others added 5 commits October 17, 2026 13:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@myuron
myuron merged commit d5ef099 into main Oct 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(lock): add --check to detect a stale lock offline

1 participant