Skip to content

How-to

Manage collections (vault sync)

Attach Obsidian vaults as live-synced collections, with quarantine and ignore patterns.

Collections are how GigaBrain attaches one or more vault directories to a single brain. The reconciler keeps the brain in sync with files on disk; the watcher follows your edits in real time.

This surface ships on macOS and Linux today — Windows parity is on the roadmap.

Terminal window
gbrain collection add notes ~/Documents/Obsidian --writable

--writable allows mutating MCP tools (brain_put, brain_link, etc.) to write to this collection. Without it, the collection is read-only and writes return CollectionReadOnlyError.

Other useful flags at attach time:

FlagEffect
--read-onlyForbid mutations through this collection.
--write-gbrain-idWrite a .gbrain-id marker file at the root for collision detection.
--watcher-mode <auto|off>Override the default file-watcher mode.
Terminal window
gbrain collection list
gbrain collection info notes

info shows extended diagnostics: state (active / detached / restoring), watcher status, ignore-pattern parse errors, recovery flags.

When serve isn’t running and you’ve edited files outside the brain’s view, force a reconcile:

Terminal window
gbrain collection sync notes
gbrain collection sync notes --remap-root /new/path # if you moved the vault
gbrain collection sync notes --finalize-pending # commit pending recovery state

The reconciler does a stat-diff (mtime + size + ctime) over file_state, falling back to SHA-256 only when stat is ambiguous. Most pages skip rehashing entirely.

.gbrainignore follows gitignore semantics. Edit via the CLI to keep the parser happy:

Terminal window
gbrain collection ignore add notes "_attachments/**"
gbrain collection ignore add notes "*.tmp"
gbrain collection ignore list notes
gbrain collection ignore remove notes "*.tmp"
gbrain collection ignore clear notes --confirm

Patterns are stored in the collections.ignore_patterns column and surfaced through brain_collections for MCP clients. Parse errors are reported via collection info.

When a file disappears or is renamed, the page isn’t hard-deleted — it’s quarantined. Links, assertions, and embeddings are preserved.

Terminal window
gbrain collection quarantine list notes
gbrain collection quarantine export <SLUG> --out /tmp/page.json
gbrain collection quarantine restore <SLUG> notes/path/to/file.md
gbrain collection quarantine discard <SLUG>

Quarantined pages auto-discard after GBRAIN_QUARANTINE_TTL_DAYS (default 30) only if they have no remaining DB-only state. Pages with active links or assertions stay until a human reviews them.

Terminal window
gbrain collection restore notes /path/to/backup-vault
gbrain collection restore-reset notes --confirm # if a previous restore halted

Restore is gated: the collection enters restoring state and rejects writes (CollectionRestoringError) until the manifest is finalized.

If the reconciler halts due to integrity issues, recover with:

Terminal window
gbrain collection reconcile-reset notes --confirm

Use sparingly; investigate the underlying cause first via collection info.

While serve is running, a notify-based watcher follows attached collection roots:

  • Edits debounced for GBRAIN_WATCH_DEBOUNCE_MS (default 1500 ms).
  • Renames, moves, and deletes flow through the same reconciler as collection sync.
  • The same write-gate applies — restoring or needs_full_sync = 1 collections reject mutations.

You can attach more than one vault. Slugs are unique per (collection, slug), so the same people/alice can exist in two collections without collision. Use collection-qualified slugs to disambiguate:

Terminal window
gbrain get work::people/alice
gbrain get personal::people/alice

The MCP server returns Ambiguity if a bare slug matches in more than one collection.

FeatureStatus
collection add / list / info / syncUnix
Watcher (live edits)Unix, in gbrain serve
Quarantine list / export / discardUnix
Quarantine restoreUnix
restore from backupUnix
Windows parityRoadmap

Don’t read the brain at the same time you restore — leases are scoped to a single serve session, so a restore halts other writers via collection_owners.