Skip to main content

Crate codelens_engine

Crate codelens_engine 

Source
Expand description

§codelens-engine

Read/mutate/index primitives for CodeLens. Internal API.

Mutation primitives — every function that writes to the project tree (file_ops::writer::*, auto_import::add_import, edit_transaction::apply_full_write_with_evidence, lsp::LspWorkspaceEditTransaction::apply, rename::apply_rename) — do NOT enforce ADR-0009 role gates, audit sinks, or cache invalidation contracts. Those guarantees live exclusively in codelens-mcp’s dispatch pipeline (dispatch::role_gate, dispatch::session::apply_post_mutation).

Consumers — including third-party crates that depend on codelens-engineMUST route mutations through codelens-mcp (HTTP / stdio MCP protocol, or in-process dispatch_tool) so the trust substrate can audit, gate, and invalidate consistently. Calling mutation primitives directly is supported only inside the workspace (mcp + engine tests + benches); anything else is at the caller’s own risk and will silently bypass the project’s principals.toml configuration.

Read primitives (find_*, get_*, search_*, LspSessionPool) are safe to call directly — they have no side effects on disk or audit state.

See ADR-0009 (docs/adr/ADR-0009-mutation-trust-substrate.md) for the full contract this crate participates in.

Re-exports§

pub use auto_import::ImportSuggestion;
pub use auto_import::MissingImportAnalysis;
pub use auto_import::add_import;
pub use auto_import::analyze_missing_imports;
pub use call_graph::CallEdge;
pub use call_graph::CalleeEntry;
pub use call_graph::CallerEntry;
pub use call_graph::extract_calls;
pub use call_graph::get_callees;
pub use call_graph::get_callers;
pub use circular::CircularDependency;
pub use circular::find_circular_dependencies;
pub use coupling::CouplingEntry;
pub use coupling::get_change_coupling;
pub use db::DirStats;
pub use db::IndexDb;
pub use db::NewCall;
pub use db::NewImport;
pub use db::NewSymbol;
pub use db::SymbolWithFile;
pub use db::content_hash;
pub use db::index_db_path;
pub use dead_code::DeadCodeEntryV2;
pub use dead_code::find_dead_code;
pub use dead_code::find_dead_code_v2;
pub use edit_transaction::ApplyError;
pub use edit_transaction::ApplyEvidence;
pub use edit_transaction::ApplyStatus;
pub use edit_transaction::FileHash;
pub use edit_transaction::RollbackEntry;
pub use edit_transaction::WorkspaceEditTransaction;
pub use edit_transaction::apply_full_write_with_evidence;
pub use edit_transaction::apply_full_writes_with_evidence;
pub use file_ops::DirectoryEntry;
pub use file_ops::EnclosingSymbol;
pub use file_ops::FileMatch;
pub use file_ops::FileReadResult;
pub use file_ops::PatternMatch;
pub use file_ops::SmartPatternMatch;
pub use file_ops::TextReference;
pub use file_ops::create_text_file;
pub use file_ops::delete_lines;
pub use file_ops::extract_word_at_position;
pub use file_ops::find_files;
pub use file_ops::find_referencing_symbols_via_text;
pub use file_ops::insert_after_symbol;
pub use file_ops::insert_at_line;
pub use file_ops::insert_before_symbol;
pub use file_ops::list_dir;
pub use file_ops::read_file;
pub use file_ops::replace_content;
pub use file_ops::replace_lines;
pub use file_ops::replace_symbol_body;
pub use file_ops::search_for_pattern;
pub use file_ops::search_for_pattern_smart;
pub use git::ChangedFile;
pub use git::DiffSymbol;
pub use git::DiffSymbolEntry;
pub use git::get_changed_files;
pub use git::get_diff_symbols;
pub use import_graph::BlastRadiusEntry;
pub use import_graph::DeadCodeEntry;
pub use import_graph::GraphCache;
pub use import_graph::ImportanceEntry;
pub use import_graph::ImporterEntry;
pub use import_graph::extract_imports_for_file;
pub use import_graph::get_blast_radius;
pub use import_graph::get_importance;
pub use import_graph::get_importers;
pub use import_graph::resolve_module_for_file;
pub use import_graph::supports_import_graph;
pub use lsp::LSP_RECIPES;
pub use lsp::LspDiagnostic;
pub use lsp::LspDiagnosticRequest;
pub use lsp::LspRecipe;
pub use lsp::LspReference;
pub use lsp::LspRenamePlan;
pub use lsp::LspRenamePlanRequest;
pub use lsp::LspRequest;
pub use lsp::LspResolveTargetRequest;
pub use lsp::LspResolvedTarget;
pub use lsp::LspResourceOp;
pub use lsp::LspSessionPool;
pub use lsp::LspStatus;
pub use lsp::LspTypeHierarchyRequest;
pub use lsp::LspWorkspaceEditTransaction;
pub use lsp::LspWorkspaceSymbol;
pub use lsp::LspWorkspaceSymbolRequest;
pub use lsp::check_lsp_status;
pub use lsp::default_lsp_args_for_command;
pub use lsp::default_lsp_command_for_extension;
pub use lsp::default_lsp_command_for_path;
pub use lsp::find_referencing_symbols_via_lsp;
pub use lsp::get_diagnostics_via_lsp;
pub use lsp::get_lsp_recipe;
pub use lsp::get_rename_plan_via_lsp;
pub use lsp::get_type_hierarchy_via_lsp;
pub use lsp::lsp_binary_exists;
pub use lsp::lsp_binary_exists_with_hint;
pub use lsp::resolve_lsp_binary_with_hint;
pub use lsp::resolve_symbol_target_via_lsp;
pub use lsp::search_workspace_symbols_via_lsp;
pub use project::ProjectRoot;
pub use project::WorkspacePackage;
pub use project::compute_dominant_language;
pub use project::detect_frameworks;
pub use project::detect_workspace_packages;
pub use rename::RenameEdit;
pub use rename::RenameResult;
pub use rename::RenameScope;
pub use rename::apply_edits;
pub use rename::find_all_word_matches;
pub use rename::rename_symbol;
pub use embedding::EmbeddingEngine;
pub use embedding::configured_embedding_model_name;
pub use embedding::configured_embedding_runtime_info;
pub use embedding::configured_embedding_runtime_preference;
pub use embedding::configured_embedding_threads;
pub use embedding::embedding_model_assets_available;
pub use embedding_types::EmbeddingIndexInfo;
pub use embedding_types::EmbeddingRuntimeInfo;
pub use embedding_types::SemanticMatch;
pub use memory::AuditRecorder;
pub use memory::MemoryAuditEvent;
pub use memory::MemoryFrontmatter;
pub use memory::MemoryLocation;
pub use memory::MemoryMetadata;
pub use memory::MemoryPolicy;
pub use memory::MemoryTier;
pub use memory::NullRecorder;
pub use memory::archive_memory;
pub use memory::archive_memory_rec;
pub use memory::delete_memory;
pub use memory::delete_memory_tiered;
pub use memory::delete_memory_tiered_rec;
pub use memory::global_memory_dir;
pub use memory::list_all_memory_names;
pub use memory::list_archived;
pub use memory::list_memory_names;
pub use memory::parse_frontmatter;
pub use memory::read_memory;
pub use memory::read_memory_from_tier;
pub use memory::read_memory_with_metadata;
pub use memory::read_policy;
pub use memory::rename_memory;
pub use memory::resolve_memory_path;
pub use memory::resolve_memory_tier;
pub use memory::restore_archived;
pub use memory::restore_archived_rec;
pub use memory::strip_frontmatter;
pub use memory::write_memory;
pub use memory::write_memory_tiered;
pub use memory::write_memory_tiered_rec;
pub use scope_analysis::ReferenceKind;
pub use scope_analysis::ScopedReference;
pub use scope_analysis::find_scoped_references;
pub use scope_analysis::find_scoped_references_in_file;
pub use search::SearchResult;
pub use search::search_symbols_hybrid;
pub use search::search_symbols_hybrid_with_semantic;
pub use symbols::IndexStats;
pub use symbols::RankedContextEntry;
pub use symbols::RankedContextResult;
pub use symbols::SymbolIndex;
pub use symbols::SymbolInfo;
pub use symbols::SymbolKind;
pub use symbols::SymbolProvenance;
pub use symbols::find_symbol;
pub use symbols::find_symbol_range;
pub use symbols::get_symbols_overview;
pub use symbols::make_symbol_id;
pub use symbols::parse_symbol_id;
pub use symbols::sparse_coverage_bonus_from_fields;
pub use symbols::sparse_max_bonus;
pub use symbols::sparse_threshold;
pub use symbols::sparse_weighting_enabled;
pub use type_hierarchy::TypeHierarchyResult;
pub use type_hierarchy::TypeNode;
pub use type_hierarchy::get_type_hierarchy_native;
pub use watcher::FileWatcher;
pub use watcher::WatcherStats;
pub use ir::CodeDiagnostic;
pub use ir::DiagnosticSeverity;
pub use ir::EditAction;
pub use ir::EditActionKind;
pub use ir::EditPlan;
pub use ir::ImpactKind;
pub use ir::ImpactNode;
pub use ir::IntelligenceSource;
pub use ir::IrCallEdge;
pub use ir::PreciseBackend;
pub use ir::Relation;
pub use ir::RelationKind;
pub use ir::RetrievalConfig;
pub use ir::RetrievalStage;
pub use ir::RetrievalWeights;
pub use ir::SearchCandidate;

Modules§

auto_import
Automatic import suggestion and insertion.
call_graph
change_signature
circular
coupling
db
dead_code
edit_transaction
Workspace edit transaction substrate.
embedding
Semantic search using fastembed + sqlite-vec. Gated behind the semantic feature flag.
embedding_store
Data types for vector embedding storage.
embedding_types
Pure data types for semantic search results. Unconditional — available whether or not the semantic feature is enabled.
file_ops
git
import_graph
inline
ir
Canonical semantic IR types for downstream consumers.
lang_registry
Single source of truth for supported language extensions.
lsp
memory
Project and global memory management.
move_symbol
oxc_analysis
Precise JS/TS scope analysis using oxc_semantic. Provides compiler-grade reference resolution without LSP.
phantom_modules
Detects “phantom” module declarations — mod NAME; lines whose target is never used anywhere else in the workspace. Complements the find_dead_code_v2 file-level pass: that one flags files with no importers in the import graph, this one catches the prerequisite step (a mod line that should never have been written or that survives a deletion cascade).
project
redundant_definitions
Detects “thin wrapper” definitions — functions whose entire body is a single call to another function with one literal default argument (e.g. pub fn record_X(&self) { self.record_X_for_session(None) }).
rename
scope_analysis
Scope-aware reference analysis using tree-sitter.
search
symbols
type_hierarchy
Tree-sitter based type hierarchy analysis.
unicode
#349: Unicode normalization for symbol-name matching.
vfs
Virtual File System event normalization layer.
watcher