.tasks/core/INDEX-001-hybrid-indexing-architecture.md
Implement the dual-layer indexing architecture that enables Spacedrive to act as both a fast file explorer (ephemeral mode) and a managed library system (persistent mode). This architecture allows instant browsing of unmanaged locations while seamlessly upgrading them to fully-indexed locations without UI disruption.
The ephemeral layer provides instant filesystem browsing without database writes:
EphemeralIndexMemoryAdapterThe persistent layer provides full database-backed indexing with sync and content analysis:
DatabaseAdapterThe critical innovation is UUID preservation during ephemeral-to-persistent transitions:
state.ephemeral_uuids)core/src/ops/indexing/ephemeral/mod.rs - Module definitionscore/src/ops/indexing/ephemeral/index.rs - EphemeralIndex main structurecore/src/ops/indexing/ephemeral/cache.rs - EphemeralIndexCache for tracking indexed pathscore/src/ops/indexing/ephemeral/arena.rs - NodeArena slab allocatorcore/src/ops/indexing/ephemeral/name.rs - NameCache string interningcore/src/ops/indexing/ephemeral/registry.rs - NameRegistry for name-based lookupscore/src/ops/indexing/ephemeral/writer.rs - MemoryAdapter for writing to ephemeral indexcore/src/ops/indexing/ephemeral/responder.rs - Filesystem event handlingcore/src/ops/indexing/ephemeral/types.rs - FileNode and related typescore/src/ops/indexing/database_storage.rs - DatabaseStorage low-level CRUD operationscore/src/ops/indexing/persistence.rs - DatabaseAdapter for IndexPersistence traitcore/src/ops/indexing/handlers/persistent.rs - DatabaseAdapter for ChangeHandler traitcore/src/ops/indexing/state.rs - IndexerState with ephemeral_uuids fieldcore/src/ops/indexing/job.rs - IndexerJob orchestrationcore/src/ops/indexing/input.rs - IndexerJobConfig with ephemeral/persistent modes# Test ephemeral browsing
spacedrive index browse /media/usb --ephemeral
# Verify in-memory only (no database writes)
spacedrive db query "SELECT COUNT(*) FROM entry WHERE name LIKE '%usb%'"
# Should return 0
# Add location while browsing (test promotion)
spacedrive location add /media/usb
# Verify UUIDs preserved (no UI flicker)
Located in core/tests/indexing/:
test_ephemeral_indexing - Memory-only indexingtest_ephemeral_to_persistent_promotion - UUID preservationtest_ephemeral_memory_usage - Verify ~50 bytes/entrytest_ephemeral_string_interning - NameCache deduplication| Mode | Storage | Throughput | Memory/File | Sync | Survives Restart |
|---|---|---|---|---|---|
| Ephemeral | RAM | ~50K files/sec | ~50 bytes | No | No |
| Persistent | SQLite | ~10K files/sec | ~200 bytes | Yes | Yes |