Migration 040 creates documents, knowledge_entries, and automation_rules tables. Full-stack services (DocumentService, KnowledgeService, AutomationService), IPC handlers, preload bridge, desktop-api types, and domain records wired into the snapshot. UI pages follow next.