Skip to content

flex sync --full: services restarted before enrichment rebuild, so the rebuild always fails with 'database is locked' #9

Description

@alecmarcus

flex sync --full restarts the worker and MCP in step 3, then runs the enrichment rebuild in step 5. The freshly-restarted worker holds the write lock, so the rebuild fails immediately:

[3/5] Services
  dev.getflex.worker: restarted
  dev.getflex.mcp: restarted
...
[5/5] Enrichment rebuild (claude_code)
  FAILED (exit 1)
    File ".../flex/modules/claude_code/manage/rebuild_all.py", line 53, in rebuild_warmup_types
      db.execute("DELETE FROM _types_source_warmup")
  sqlite3.OperationalError: database is locked

Sync complete.

Reproduced on a cell with an active watcher. The enrichment steps take an exclusive write lock (DELETE FROM _types_source_warmup is the first statement), so any running worker defeats them.

Two consequences:

  1. --full cannot complete while services are running, which is the normal state after any flex init. The advertised "~2min" enrichment rebuild never happens.
  2. Sync complete. still prints and the command exits 0 despite FAILED (exit 1) in the body — same exit-code/outcome mismatch as reembed: prints ERROR but exits 0, and the live cell reads as malformed to already-connected processes #8.

Workaround: stop the services and call the steps directly, which works cleanly —

from flex.registry import resolve_cell
from flex.modules.claude_code.manage.rebuild_all import (
    rebuild_warmup_types, rebuild_source_graph, rebuild_file_graph,
    rebuild_delegation_graph, rebuild_community_labels)
...

All seven steps then succeed (source graph rebuilt 987 → 1,218 rows, 121 hubs, 81 communities).

Suggested: run the enrichment rebuild before restarting services, or stop them for the duration of step 5 and restart afterwards.

Environment

getflex 0.52.0 · macOS (Darwin 25.5.0, arm64) · Python 3.14.3 · cell claude_code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions