Initialize the vault in this repository. Creates the vault tables in the pristine database and the `.vault/` directory structure on disk. This is idempotent — calling it on an already-initialized vault is a no-op. # Directory structure created: ```text .vault/ ├── goals/ ├── memory/ ├── skills/ ├── intents/ └── scratch/ ```
(&self)
| 41 | /// └── scratch/ |
| 42 | /// ``` |
| 43 | pub fn init_vault(&self) -> Result<(), RepositoryError> { |
| 44 | // Initialize vault tables in redb |
| 45 | { |
| 46 | let mut txn = self |
| 47 | .pristine |
| 48 | .write_txn() |
| 49 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 50 | use atomic_core::pristine::VaultMutTxnT; |
| 51 | txn.init_vault() |
| 52 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 53 | txn.commit() |
| 54 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 55 | } |
| 56 | |
| 57 | // Create directory structure on disk |
| 58 | let vault_dir = self.vault_dir(); |
| 59 | let subdirs = ["goals", "memory", "skills", "intents", "scratch", "prompts"]; |
| 60 | for subdir in &subdirs { |
| 61 | std::fs::create_dir_all(vault_dir.join(subdir))?; |
| 62 | } |
| 63 | |
| 64 | // Initialize knowledge graph tables |
| 65 | { |
| 66 | let mut txn = self |
| 67 | .pristine |
| 68 | .write_txn() |
| 69 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 70 | use atomic_core::pristine::KgMutTxnT; |
| 71 | txn.init_kg() |
| 72 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 73 | txn.commit() |
| 74 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 75 | } |
| 76 | |
| 77 | // Initialize embeddings table |
| 78 | self.init_embeddings()?; |
| 79 | |
| 80 | // Install default vault content (skills, memory index, system prompt) |
| 81 | self.vault_install_defaults()?; |
| 82 | |
| 83 | // NOTE: The vault files are NOT added+recorded here. The CLI init |
| 84 | // command handles that in the correct sequence: |
| 85 | // 1. Create .atomicignore → add → record |
| 86 | // 2. Create .vault/ defaults → add → record |
| 87 | // This avoids the TREE/status deadlock where add() marks files as |
| 88 | // tracked but status() doesn't see them without graph positions. |
| 89 | |
| 90 | Ok(()) |
| 91 | } |
| 92 | |
| 93 | /// Bootstrap vault tables from an existing `.vault/` working copy. |
| 94 | /// |