open-brainy/src/vfs
David Snelling 3241ae337a fix(vfs): prevent root duplication with fixed-ID pattern (v5.10.0)
CRITICAL FIX for Workshop team's production blocker:
- VFS roots multiplied exponentially (5 → 100+ in 2 minutes)
- Fresh workspace created 7 duplicate roots on first page load
- Root cause: Query-then-create race condition across VFS instances

ARCHITECTURAL SOLUTION:
Replace Smart Root Selection (symptom masking) with fixed-ID pattern (root cause fix).

Changes:
- Use deterministic UUID '00000000-0000-0000-0000-000000000000' for VFS root
- Storage-level uniqueness prevents all duplicates across instances
- Remove selectBestRoot() method (~60 lines) - no longer needed
- Add auto-cleanup for old v5.9.0 UUID-based roots
- Idempotent creation: Concurrent calls gracefully handled

Why this works:
- All VFS instances use same fixed ID
- Storage enforces uniqueness (filesystem/database constraint)
- No queries needed (O(1) get vs O(log n) query)
- Works across server restarts and multi-server deployments
- Simpler code: ~30 lines added, ~60 lines removed

Test Results:
- Build: Zero TypeScript errors
- VFS tests: 116/128 pass (was 57/128 before fix)
- Full suite: 1174/1200 pass (97.8%)

Impact on Workshop:
- Fresh workspace: 1 root (was 7)
- After 2 minutes: 1 root (was 100)
- No manual cleanup needed
- Per-request pattern now fully supported

Technical Details:
- VFS root ID: 00000000-0000-0000-0000-000000000000
- User-visible path: / (path field, not ID)
- Storage path: entities/nouns/collection/metadata/00/00000000...json
- Migration: Auto-cleanup on first init

Fixes: #VFS-ROOT-DUPLICATION
See: .strategy/V5_10_0_VFS_ROOT_FIX.md for complete analysis
2025-11-14 12:51:25 -08:00
..
importers feat: add ImageHandler with EXIF extraction and comprehensive MIME detection (v5.2.0) 2025-11-03 14:06:17 -08:00
semantic feat(vfs): fix VFS visibility by removing broken filtering 2025-10-27 10:44:06 -07:00
streams feat: implement complete VFS with Knowledge Layer integration 2025-09-24 17:31:48 -07:00
FSCompat.ts feat: v5.1.0 - VFS auto-initialization and complete API documentation 2025-11-02 10:58:52 -08:00
index.ts feat: add ImageHandler with EXIF extraction and comprehensive MIME detection (v5.2.0) 2025-11-03 14:06:17 -08:00
MimeTypeDetector.ts feat: add ImageHandler with EXIF extraction and comprehensive MIME detection (v5.2.0) 2025-11-03 14:06:17 -08:00
PathResolver.ts fix: per-sheet column detection in Excel importer 2025-10-28 14:30:31 -07:00
TreeUtils.ts fix: handle symlink type in TreeNode creation 2025-09-26 10:19:37 -07:00
types.ts fix: resolve HNSW race condition and verb weight extraction (v5.4.0) 2025-11-05 17:05:07 -08:00
VirtualFileSystem.ts fix(vfs): prevent root duplication with fixed-ID pattern (v5.10.0) 2025-11-14 12:51:25 -08:00