Skip to main content

magellan/
lib.rs

1#![allow(unused_imports)]
2//! Magellan: A dumb, deterministic codebase mapping tool
3//!
4//! Magellan observes files, extracts symbols and references, and persists facts to sqlitegraph.
5//!
6//! # Position Conventions
7//!
8//! Magellan uses tree-sitter position conventions for all symbol and reference data:
9//! - **Line positions**: 1-indexed (line 1 is the first line)
10//! - **Column positions**: 0-indexed (column 0 is the first character)
11//! - **Byte offsets**: 0-indexed from file start
12//!
13//! See [MANUAL.md](../MANUAL.md#3-position-conventions) for detailed documentation.
14//!
15//! # Feature Flags
16//!
17//! ## Backend Selection (Choose One)
18//!
19//! Magellan supports two storage backends via sqlitegraph:
20//!
21//! ### SQLite Backend (Default)
22//! - **`sqlite-backend`**: Stable SQLite-based storage
23//!   - Widely compatible, well-tested
24//!   - Use for maximum compatibility
25//!
26//! ## Optional Features
27//!
28//! - **`llvm-cfg`**: LLVM IR-based CFG extraction for C/C++ (requires clang)
29//! - **`bytecode-cfg`**: Java bytecode-based CFG extraction (requires Java bytecode library)
30//!
31//! # Graph Memory
32//!
33//! Magellan can index external documents (wiki pages, markdown) as source documents
34//! and extract candidate facts (subject-predicate-object triples) from them.
35//!
36//! - **Source inventory**: `source-inventory` CLI command scans directories and
37//!   stores document metadata (path, kind, hash, tags, wikilinks) in the
38//!   `source_documents` table (schema v13+).
39//! - **Candidate facts**: `candidate-fact` CLI command submits, lists, and
40//!   validates facts extracted from source documents, stored in the
41//!   `candidate_facts` table (schema v14+). Facts have statuses: `pending`,
42//!   `accepted`, or `rejected`.
43//!
44//! See [MANUAL.md](../MANUAL.md) for full CLI reference.
45
46pub mod backend_router;
47pub mod capabilities;
48pub mod common;
49pub mod config;
50pub mod context;
51pub mod diagnostics;
52pub mod error_codes;
53pub mod generation;
54pub mod geo_builder;
55pub mod geo_staleness;
56pub mod graph;
57pub mod indexer;
58pub mod ingest;
59pub mod lsif;
60pub mod lsp;
61#[cfg(feature = "web-ui")]
62pub mod web_ui;
63
64pub mod ingest_coverage_cmd;
65pub mod migrate_backend_cmd;
66pub mod migrate_cmd;
67
68// Re-export backend detection for CLI commands
69pub use backend_router::{MagellanBackend, UnifiedSymbolInfo};
70pub use capabilities::all_capabilities;
71pub use migrate_backend_cmd::{detect_backend_format, BackendFormat};
72pub mod output;
73pub mod project_config;
74pub mod references;
75pub mod validation;
76pub mod verify;
77pub mod watcher;
78
79pub use common::{
80    detect_language_from_path, detect_project_root, extract_context_safe,
81    extract_symbol_content_safe, format_symbol_kind, parse_symbol_kind, resolve_path,
82};
83pub use diagnostics::{DiagnosticStage, SkipReason, WatchDiagnostic};
84pub use generation::{ChunkStore, CodeChunk};
85pub use graph::candidate_fact::{
86    ensure_schema as ensure_candidate_fact_schema, find_by_id as find_candidate_fact_by_id,
87    insert as insert_candidate_fact, list_by_status as list_candidate_facts_by_status,
88    review_queue as candidate_fact_review_queue, update_status as update_candidate_fact_status,
89    validate_ontology, CandidateFact, CandidateProperties, CandidateStatus, ConflictSet,
90    ConflictType, ResolutionStatus, ValidationError, ValidationResult,
91};
92pub use graph::filter::FileFilter;
93pub use graph::query::{cross_file_references_to, SymbolQueryResult};
94pub use graph::scan::ScanResult;
95pub use graph::source_inventory::{
96    compute_hash, ensure_schema, extract_frontmatter, extract_metadata, extract_tags,
97    extract_title, extract_wikilinks, find_stale, insert_or_update, list_by_kind,
98    parse_frontmatter, scan_directory, scan_file, ExtractedMetadata, SourceDocument,
99};
100pub use graph::test_helpers::{delete_file_facts_with_injection, FailPoint};
101pub use graph::CrossFileRef;
102pub use graph::{
103    CodeGraph,
104    CondensationGraph,
105    CondensationResult,
106    Cycle,
107    CycleKind,
108    CycleReport,
109    DeadSymbol,
110    DeleteResult,
111    ExecutionPath,
112    ExportConfig,
113    ExportFormat, // GraphSymbol, MemoryGraph,
114    PathEnumerationResult,
115    PathStatistics,
116    ProgramSlice,
117    ReconcileOutcome,
118    ScanProgress,
119    SliceDirection,
120    SliceResult,
121    SliceStatistics,
122    Supernode,
123    SymbolInfo,
124    MAGELLAN_SCHEMA_VERSION,
125};
126pub use indexer::{run_indexer, run_indexer_n, run_watch_pipeline, WatchPipelineConfig};
127pub use ingest::detect::{detect_language, Language};
128pub use ingest::{ImplRelation, Parser, SymbolFact, SymbolKind};
129pub use output::command::{MigrateResponse, ReferenceMatch, Span, SymbolMatch};
130pub use output::{generate_execution_id, output_json, JsonResponse, OutputFormat};
131pub use references::{CallFact, ReferenceFact};
132pub use validation::{
133    canonicalize_path, normalize_path, validate_path_within_root, PathValidationError,
134};
135pub use verify::{verify_graph, VerifyReport};
136pub use watcher::{EventType, FileEvent, FileSystemWatcher, WatcherBatch, WatcherConfig};