Skip to content

Windows v0.8.1: stale graph + Permission denied on delete_project after orphan cbm process (reconfirm #277) #914

Closed

Description

@ibrahimqureshae

Summary

Just confirming that the symptoms from #277 ("New files not indexed on Windows") are still present in v0.8.1 on Windows 11. The same workaround from that issue (kill orphan codebase-memory-mcp.exe processes, delete the .db* files, reindex) is still the only thing that reliably gets the graph back in sync. New files added after the first index simply don't show up until a full reset.

Related: #520 ("watcher misses file creation") is also still open.

Environment

  • Version: 0.8.1
  • OS: Windows 11 (10.0.22631), x86_64
  • Install: official install.ps1 --ui, single static binary at %LOCALAPPDATA%\Programs\codebase-memory-mcp\
  • Agents: Claude Code (~/.claude/.mcp.json, ~/.claude.json) and opencode (~/.config/opencode/opencode.jsonc), both with --ui=true --port=9749
  • Config: auto_index=true, auto_watch=true to start with (I ended up turning auto_watch off, see below)
  • Cache: ~/.cache/codebase-memory-mcp/

What happens

I indexed a Rust project, then added some new files (a new module plus a few fixture files) on disk. When I tried to reindex:

  • index_repository comes back with incremental.noop reason=no_changes and the exact same node/edge counts as before (626/1298), even though the new files are right there on disk and git-tracked (git ls-files --error-unmatch finds them).
  • delete_project returns status:"delete_failed", error:"Permission denied" because the SQLite .db is still held open by a leftover cbm process.
  • search_graph for the new symbols (DomainSubdomains, run_scan, etc.) returns total: 0.
  • After killing all cbm processes and wiping the DB, a fresh index_repository reported pipeline.discover files=54 while the actual directory tree (excluding .git, .vscode, target, node_modules, dist, src-tauri/gen) had 97 files. The reindex did pick them up in the end (+206 nodes / +735 edges), so the parser is fine; it's the incremental path that keeps seeing "no changes" when there clearly are changes.

So on Windows this seems to have two faces:

  1. Stale hash table + orphan lock (per New files not indexed — WAL-checkpoint blocked on successfully-indexed project (Windows, v0.6.0) #277): the incremental reindex thinks nothing changed because it can't checkpoint new writes into the main .db.
  2. Discovery undercount: even from a clean cache, pipeline.discover files=N understates the on-disk file count. It still parses and indexes everything, but the log line is misleading when you're trying to diagnose a stale index.

Repro

# 1. Index a Rust repo via opencode (stdio MCP)
cd <your-rust-repo>
# (opencode spawns codebase-memory-mcp.exe as MCP server; let it index)
codebase-memory-mcp cli index_repository '{\"repo_path\":\"<absolute/path/to/repo>\"}'
# -> nodes: 626, edges: 1298   (baseline)

# 2. Add a new .rs module file plus a fixture file on disk
# (real edit in your editor; git-tracked, not gitignored)

# 3. Attempt explicit reindex
codebase-memory-mcp cli index_repository '{\"repo_path\":\"<absolute/path/to/repo>\"}'
# -> incremental.noop reason=no_changes
# -> nodes: 626, edges: 1298   (UNCHANGED; files on disk are newer)

# 4. Attempt delete
codebase-memory-mcp cli delete_project '{\"project\":\"<derived-project-name>\"}'
# -> status: delete_failed, error: Permission denied

# 5. Confirm orphan cbm processes exist
Get-Process -Name 'codebase-memory-mcp*' | Select Id, StartTime
# -> one process dating from before the new files were added (e.g. uptime 70 min)

# 6. Workaround (validates #277's root cause)
Get-Process -Name 'codebase-memory-mcp*' | Stop-Process -Force
Remove-Item \"$env:USERPROFILE\.cache\codebase-memory-mcp\<project-name>.db*\"
codebase-memory-mcp cli index_repository '{\"repo_path\":\"<absolute/path/to/repo>\"}'
# -> nodes: 832, edges: 2034   (+206 / +735)
# search_graph for the new symbol -> total: 1   CORRECT

Workaround script

I dropped this at %LOCALAPPDATA%\Programs\codebase-memory-mcp\cbm-reset.ps1 and run it after each Stage commit. Sharing in case other Windows users hit the same wall. It kills the orphans, deletes the stale DB, and reindexes:

[CmdletBinding()]
param(
  [Parameter(Position=0)] [string]$RepoPath = (Get-Location).Path,
  [switch]$ListOnly
)
$projectName = (($RepoPath -replace '[\\/]+','-') -replace '^-','' -replace '-$','') -replace ':',''
$cacheDir = Join-Path $env:USERPROFILE '.cache\codebase-memory-mcp'
$dbFiles  = Get-ChildItem $cacheDir -Filter \"$projectName.db*\" -ErrorAction SilentlyContinue

if ($ListOnly) {
  if (-not $dbFiles) { Write-Host \"No DB for $projectName\" } else {
    $dbFiles | ForEach-Object { Write-Host (\"  - {0}  ({1} KB, mod {2})\" -f $_.Name, [int]($_.Length/1KB), $_.LastWriteTime) }
  }
  $procs = Get-Process -Name 'codebase-memory-mcp*' -ErrorAction SilentlyContinue
  Write-Host (\"Live cbm processes: {0}\" -f @($procs).Count)
  $procs | Select Id, StartTime | Format-Table -AutoSize
  return
}

if ($dbFiles) {
  Write-Host \"Killing orphan codebase-memory-mcp.exe processes (releases SQLite locks)...\"
  Get-Process -Name 'codebase-memory-mcp*' -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
  Start-Sleep -Seconds 2
  $dbFiles | ForEach-Object { Remove-Item -LiteralPath $_.FullName -Force }
}
Write-Host \"Reindexing $RepoPath ...\"
& codebase-memory-mcp cli index_repository ('{\"repo_path\":\"' + ($RepoPath -replace '\\','/') + '\"}')
Write-Host \"Done. Restart Claude Code / opencode so they spawn a fresh MCP server.\"

What I had to give up

To stop the orphan accumulation I set auto_watch=false. The cost is losing the live-edit auto-sync; I now run cbm-reset.ps1 after each Stage commit and restart the agent. The daily workflow is fine, but the live-edit capability advertised in the README doesn't reliably work on Windows in v0.8.1.

Suggestions (reiterating #277, all still applicable)

  • On delete_project: run PRAGMA wal_checkpoint(TRUNCATE) before touching files on disk.
  • On stdio-close: trap stdio EOF / SIGTERM and run PRAGMA wal_checkpoint(TRUNCATE) plus a clean exit before the OS forces an orphan.
  • On startup: detect a stale .db-wal past a threshold (10 MB?) and either force-checkpoint or warn loudly.
  • Audit the Windows discovery path: pipeline.discover files=N doesn't match the on-disk file count even from a clean cache. That might be benign (N counts parsable units, not raw files), but the mismatch is confusing when you're trying to track down a stale index.
  • Document the orphan-process failure mode in the README troubleshooting section.

Happy to attach a cbm-diagnostics-<pid>.ndjson from a repro session if that'd be useful, just let me know which pid (orphan vs. new spawn) you'd want and I'll capture it with CBM_DIAGNOSTICS=1.

Activity

  1. added
    bugSomething isn't working
    windowsWindows-specific issues
    stability/performanceServer crashes, OOM, hangs, high CPU/memory
    ux/behaviorDisplay bugs, docs, adoption UX
    priority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.
    on Jul 7, 2026
  2. DeusData commented on Jul 7, 2026

    @DeusData
    Owner

    Thanks for reconfirming the Windows stale-graph/delete behavior on v0.8.1. Triage: high-priority Windows stability/UX issue under #394.

    This sounds related to the watcher/process-lifecycle and project-locking work, but it needs its own reproduction so we know whether the orphan process, WAL sidecars, or watcher state is the root cause. The workaround details are helpful.

  3. added
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    on Jul 8, 2026
  4. github-actions commented on Jul 8, 2026

    @github-actions

    Thanks for the report! To move this forward we need a bit more so we can reproduce it ourselves:

    • the codebase-memory-mcp --version you're on
    • the exact steps or command you ran
    • a public repo (or a small dummy snippet) that shows the problem — please don't paste proprietary code

    Once that's here we'll pick it straight back up. Heads-up: issues left awaiting-reporter are automatically closed after a few weeks of silence, but a comment reopens the door anytime.

  5. DeusData commented on Jul 8, 2026

    @DeusData
    Owner

    v0.9.0 includes several Windows runtime, watcher, project lifecycle, and UI surfacing fixes that may affect this stale graph and delete failure path. Could you retest on v0.9.0 and report whether the old graph still appears or deletion still fails? Marking awaiting-reporter.

  6. added this to the 0.9.1-rc milestone on Jul 8, 2026
  7. github-actions commented on Jul 30, 2026

    @github-actions

    This issue has been waiting on more information for 21 days (a version, exact steps, or a public repro), so it's now marked stale. It will be closed in 14 days if there's no update — just add a comment to keep it open. We're happy to pick it back up the moment we can reproduce it.

  8. added
    staleNo activity after an info request; will be closed soon
    on Jul 30, 2026
  9. DeusData commented on Aug 14, 2026

    @DeusData
    Owner

    @ibrahimqureshae — this issue is carrying both awaiting-reporter and stale, on a report that arrived complete: baseline node/edge counts, incremental.noop reason=no_changes against files that are on disk and git-tracked, Permission denied on delete_project traced to a leftover process holding the database, and the pipeline.discover files=54 undercount against 97 real files.

    That was always enough to work from, and asking you to retest before we had reproduced it ourselves is what put the stale bot on your case. Please do not read those labels as us ignoring you — nothing here is your move.

    Honest status: not root-caused. The open question is whether the orphan process, the WAL sidecars, or the watcher state is the cause, and the abandoned-server lifetime described in #1083 looks related. Tonight's v0.10.5 is being cut for the issues that make cbm impossible to operate, and a graph that silently stops matching the code is one of them.

  10. removed
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    staleNo activity after an info request; will be closed soon
    on Aug 14, 2026
  11. added a commit that references this issue on Sep 7, 2026
  12. DeusData commented on Sep 7, 2026

    @DeusData
    Owner

    Fixed on main by 5e5405c (PR #1874, thank you @LazyXuan): a Windows stdio server now exits when the client that spawned it dies, instead of lingering on stdin and pinning WAL read locks. Ships in v0.10.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.stability/performanceServer crashes, OOM, hangs, high CPU/memoryux/behaviorDisplay bugs, docs, adoption UXwindowsWindows-specific issues

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions