Skip to main content

sqry_core/project/
mod.rs

1//! Project root lifecycle management
2//!
3//! This module implements the behaviors defined in `docs/architecture/PROJECT_ROOT_SPEC.md`:
4//!
5//! - **ProjectManager**: Routes file paths to Projects based on `ProjectRootMode`
6//! - **Project**: Owns a `CodeGraph`, file table, and caches for one index root
7//! - **RepoId**: Tracks which git repository each file belongs to
8//!
9//! # Architecture Overview
10//!
11//! ```text
12//! ┌─────────────────────────────────────────────────────────────┐
13//! │                      ProjectManager                         │
14//! │  - mode: ProjectRootMode                                    │
15//! │  - projects: HashMap<ProjectId, Arc<Project>>               │
16//! │  - workspace_folders: Vec<PathBuf>                          │
17//! └─────────────────────────────────────────────────────────────┘
18//!                              │
19//!                              │ project_for_path()
20//!                              ▼
21//! ┌─────────────────────────────────────────────────────────────┐
22//! │                         Project                             │
23//! │  - id: ProjectId                                            │
24//! │  - index_root: PathBuf                                      │
25//! │  - graph: CodeGraph                                         │
26//! │  - repo_index: HashMap<PathBuf, RepoId>                     │
27//! │  - file_table: HashMap<StringId, FileEntry>                 │
28//! └─────────────────────────────────────────────────────────────┘
29//! ```
30//!
31//! # Modes
32//!
33//! - **GitRoot** (default): Each git repository gets its own Project
34//! - **WorkspaceFolder**: Each VS Code workspace folder gets a Project
35//! - **WorkspaceRoot**: Single Project covering all workspace folders
36//!
37//! # Lifecycle
38//!
39//! 1. **Create**: On first file routed to an index_root
40//! 2. **Initialize**: Empty graph, caches, watchers
41//! 3. **Build**: Full index scan
42//! 4. **Update**: Incremental updates on file changes
43//! 5. **Destroy**: On workspace removal or shutdown
44
45pub mod manager;
46pub mod path_utils;
47pub mod persistence;
48pub mod repo_detection;
49pub mod resolver;
50pub mod types;
51
52// Re-export primary types
53pub use manager::{Project, ProjectManager};
54pub use path_utils::{
55    DEFAULT_IGNORED_DIRS, absolutize_without_resolution, canonicalize_path,
56    is_ignored_dir_with_config, normalize_path_components,
57};
58pub use repo_detection::{detect_repos_under, lookup_git_root, lookup_repo_id};
59pub use resolver::{canonicalize_and_resolve, find_git_root, resolve_index_root};
60pub use types::{FileEntry, ProjectError, ProjectId, ProjectRootMode, RepoId, StringId};