Skip to content

fix: take the analysis lock in devmap analyze - #140

Open
itsflaid wants to merge 1 commit into
mainfrom
fix/analyze-lock
Open

itsflaid wants to merge 1 commit into
mainfrom
fix/analyze-lock

Conversation

@itsflaid

Copy link
Copy Markdown
Owner

Problem

.devmap/analyze.lock was taken only by the MCP server. A terminal devmap analyze ignored it, so it could write the snapshot while an MCP refresh was writing it too (listed as a known limitation in CLAUDE.md).

Change

  • The lock code moves to src/cache/analysisLock.ts; mcp/refresh.ts re-exports acquireLock and LOCK_STALE_MS, so MCP code and tests are unchanged.
  • analyzeCommand holds the lock around runAnalyze (human and --json). runAnalyze does not take it: the MCP refresher already holds the lock when it calls it, so taking it there would make every MCP refresh refuse itself.
  • A target folder that does not exist still fails with the analyzer's own error and no stray .devmap folder.
  • A second analysis fails with Another DevMap analysis is already running (pid N), same as in the MCP server. Dead-pid and 15-minute-old locks are taken over as before.
  • Docs, CLAUDE.md (known limitation removed) and CHANGELOG [Unreleased] updated.

Checks

  • pnpm test:cli: 488 pass, 0 fail (5 new tests in analyze-lock.test.ts: released after a run, refused while held, --json, re-run, missing folder)
  • Built CLI, two analyze --fresh started 0.3s apart in one folder: first exits 0, second exits 1 with the "already running" message, no lock left behind, and a later run works.

Release

This changes packages/cli, so it is publish-worthy only if you choose to release it. No version bump here. Suggested level when you do: patch (0.9.1).


Generated by Claude Code

devmap analyze now holds .devmap/analyze.lock, so a terminal analysis and an MCP refresh cannot write the snapshot at the same time. The lock code moves to cache/analysisLock.ts and is re-exported from mcp/refresh.ts. The lock is taken in analyzeCommand, not runAnalyze, because the MCP refresher already holds it when it calls runAnalyze. A missing target folder still fails without creating a .devmap folder.
@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
devmap-web Ready Ready Preview Oct 31, 2026 2:20pm UTC

@github-actions

Copy link
Copy Markdown

✅ Welcome ke DevMap!

Terima kasih sudah buat PR. Pastikan checklist ini terpenuhi sebelum review:

  • devmap doctor lolos (tanpa error)
  • Test pnpm test:cli lolos (semua pass)
  • New commands diupdate di docs/commands.md
  • Tidak ada console.log di command files
  • Registry terms sesuai standar (baca docs/guide/05-signal-registry.md)
  • Code style match dengan CONTRIBUTING.md

CI akan jalan otomatis pada setiap update. Kalau gagal, akan muncul link run di komentar ini.

Kalau DevMap membantu, tolong star ya: https://github.com/itsflaid/devmap

Terima kasih kontribusinya! 🙏

This branch was successfully deployed

1 active deployment
Preview — 41d330e3 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants