Skip to main content
memvid-core provides APIs for file locking and integrity verification that host applications can use directly.

File Locking

Memvid uses OS-level file locks to manage concurrent access:

Lock Behavior

  • Writers take an exclusive FileLock
  • Readers share a read lock (multiple concurrent readers allowed)
  • Locks are released when the Memvid handle is dropped

Checking Lock Status

CLI commands for inspecting locks:

Verification

Verify file integrity with the core API:

Verification Checks

The verification report includes:

Doctor (Repair)

Repair corrupted or damaged files:

Doctor Report

The doctor command returns a report with:
  • Findings: Issues detected (INFO, WARN, ERROR severity)
  • Planned Actions: Repairs that will be performed
  • Status: Result of each repair action

Single-File Verification

Memvid enforces the “single-file guarantee” at open/create time. If it detects sidecars (e.g. notes.mv2-wal), it fails with MemvidError::AuxiliaryFileDetected.
For an explicit directory scan, use the CLI command memvid verify-single-file <file>.

CLI Commands

The CLI exposes these APIs:

Error Handling

The core API exposes structured errors via MemvidError:

Best Practices

Concurrent Access

  1. Use read-only mode for queries to allow concurrent readers
  2. Keep write sessions short to minimize lock contention
  3. Handle LockedError gracefully with retry logic

Integrity Maintenance

  1. Verify periodically (weekly or after large ingestions)
  2. Run doctor after crashes or power failures
  3. Vacuum after bulk deletions to reclaim space

Recovery Workflow