Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ members = [
]

[workspace.package]
version = "2.2.13"
version = "2.2.14"
edition = "2021"
rust-version = "1.80"
license = "MIT"
Expand Down
12 changes: 6 additions & 6 deletions crates/codegraph-api/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ pub async fn dispatch_diff(
args: Value,
) -> Result<String> {
let diff = arg_str(&args, "diff")?;
let parsed = codegraph_graph::diff::parse_unified_diff(diff)
.map_err(|e| Error::Invalid(e.to_string()))?;
let parsed =
codegraph_graph::parse_unified_diff(diff).map_err(|e| Error::Invalid(e.to_string()))?;

let idx = shared.ensure_fresh().await;
let report = idx.diff_assess(&parsed, Some(root.as_std_path())).await;
Expand Down Expand Up @@ -402,8 +402,8 @@ pub async fn dispatch_branch_compare(
let base = arg_str(&args, "base")?;
let head = args.get("head").and_then(|v| v.as_str());
let diff = git.diff(base, head).await?;
let parsed = codegraph_graph::diff::parse_unified_diff(&diff)
.map_err(|e| Error::Invalid(e.to_string()))?;
let parsed =
codegraph_graph::parse_unified_diff(&diff).map_err(|e| Error::Invalid(e.to_string()))?;

let idx = shared.ensure_fresh().await;
let report = idx.diff_assess(&parsed, Some(root.as_std_path())).await;
Expand Down Expand Up @@ -461,8 +461,8 @@ pub async fn dispatch_diff_simulate(
args: Value,
) -> Result<String> {
let diff = arg_str(&args, "diff")?;
let parsed = codegraph_graph::diff::parse_unified_diff(diff)
.map_err(|e| Error::Invalid(e.to_string()))?;
let parsed =
codegraph_graph::parse_unified_diff(diff).map_err(|e| Error::Invalid(e.to_string()))?;
let base_ref = args
.get("base_ref")
.and_then(|v| v.as_str())
Expand Down
6 changes: 3 additions & 3 deletions crates/codegraph-bench/src/bin/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use camino::Utf8Path;
use clap::Parser;
use codegraph_bench::{BenchOptions, Repo, extract, index_at, orchestrator, run_queries};
use codegraph_core::{Annotation, CallRecord, EffectType, ScopeLevel, Symbol, SymbolKind};
use codegraph_graph::meminfo::{MemTracker, fmt_bytes, rss_bytes};
use codegraph_graph::memtrack::MemBreakdown;
use codegraph_graph::MemBreakdown;
use codegraph_graph::{MemTracker, fmt_bytes, rss_bytes};
use std::sync::OnceLock;

fn runtime() -> &'static tokio::runtime::Runtime {
Expand Down Expand Up @@ -555,7 +555,7 @@ fn main() -> anyhow::Result<()> {
println!("\n=== breakdown: {} ===", r.repo);
print_breakdown(&r.breakdown, &r.caches, r.rss_after_index);
}
if let Some(peak) = codegraph_graph::meminfo::peak_rss_bytes() {
if let Some(peak) = codegraph_graph::peak_rss_bytes() {
println!("\npeak RSS (VmHWM): {}", fmt_bytes(peak));
} else {
println!("\npeak RSS: không đọc được trên nền tảng này");
Expand Down
6 changes: 3 additions & 3 deletions crates/codegraph-extract/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ pub struct ExtractConfig {
/// Backend storage được chọn trong config (mặc định sqlite).
pub storage: StorageConfig,
/// Cấu hình embedding backend (semantic search) — đọc từ `[embedding]`.
pub embedding: codegraph_graph::embeddings::EmbeddingConfig,
pub embedding: codegraph_graph::EmbeddingConfig,
/// Cấu hình Jev rerank cho `codegraph_context` — đọc từ `[jev]`.
pub jev: codegraph_core::JevConfig,
/// Cấu hình document graph — đọc từ `[docgraph]`.
Expand Down Expand Up @@ -536,7 +536,7 @@ impl ExtractConfig {
header_language: parse_header_language(file.languages.headers.as_deref()),
effect_classifier,
flow_classifier,
embedding: codegraph_graph::embeddings::EmbeddingConfig::from_raw(
embedding: codegraph_graph::EmbeddingConfig::from_raw(
file.embedding.backend.as_deref(),
file.embedding.model.as_deref(),
file.embedding.cache_dir.as_deref(),
Expand Down Expand Up @@ -606,7 +606,7 @@ impl ExtractConfig {
// Áp dụng config embedding (backend/model/cache) cho process trước khi
// mở index — `GraphIndex::new_with_storage` đọc global này để quyết định
// có bật vector index hay không (opt-in: chỉ khi backend = "fastembed").
codegraph_graph::embeddings::set_embedding_config(self.embedding.clone());
codegraph_graph::set_embedding_config(self.embedding.clone());
// Cùng thời điểm: `[jev]` là config toàn cục cho `codegraph-context`
// (module context không phụ thuộc `codegraph-extract`, nên truyền qua
// global giống embedding).
Expand Down
3 changes: 3 additions & 0 deletions crates/codegraph-graph/src/embeddings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ fn expand_tilde(path: &str) -> Option<PathBuf> {
}

/// Suffix file extension của sqlite-vss theo OS (`.dylib` / `.so` / `.dll`).
// Chỉ `storage/sqlite.rs` dùng — tắt feature `sqlite` thì cặp hàm này dead code.
#[cfg_attr(not(feature = "sqlite"), allow(dead_code))]
fn vss_lib_suffix() -> &'static str {
if cfg!(target_os = "macos") {
"dylib"
Expand All @@ -216,6 +218,7 @@ fn vss_lib_suffix() -> &'static str {
/// dò `<cache_dir>/vss`. Chỉ trả `Some` khi file thực sự tồn tại → caller có
/// thể yên tâm thêm extension vào kết nối SQLite mà không làm hỏng `open`
/// khi thiếu binary.
#[cfg_attr(not(feature = "sqlite"), allow(dead_code))]
pub fn resolve_vss_extensions() -> Option<(PathBuf, PathBuf)> {
let cfg = embedding_config();
let dir = cfg
Expand Down
23 changes: 18 additions & 5 deletions crates/codegraph-graph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,29 @@ use tokio::sync::RwLock;

#[cfg(feature = "bloom-search")]
mod bloom;
pub mod diff;
pub mod embeddings;
mod diff;
mod embeddings;
mod lru;
pub mod meminfo;
pub mod memtrack;
mod meminfo;
mod memtrack;
mod radix;
mod search;
mod shared;
mod storage;
pub mod vector_index;
// Chỉ `VectorIndex::knn` được dùng nội bộ; phần API còn lại (insert/set_all/
// kmeans...) giữ cho semantic search opt-in + test, nên tắt dead-code ở đây
// thay vì để cả module public.
#[allow(dead_code)]
mod vector_index;

// Các module nội bộ trên chỉ mở đúng phần API mà crate khác dùng — thay cho
// `pub mod`, để bề mặt public không phình theo từng file nội bộ.
pub use crate::diff::{FileDiff, Hunk, ParsedDiff, parse_unified_diff};
#[cfg(feature = "fastembed")]
pub use crate::embeddings::warm_model_cache;
pub use crate::embeddings::{EmbeddingConfig, set_embedding_config};
pub use crate::meminfo::{MemTracker, fmt_bytes, peak_rss_bytes, rss_bytes};
pub use crate::memtrack::MemBreakdown;

pub use shared::SharedGraphIndex;

Expand Down
4 changes: 2 additions & 2 deletions crates/codegraph-graph/src/meminfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! - **Platform khác**: `None` — caller phải xử lý, KHÔNG panic.
//!
//! ```no_run
//! use codegraph_graph::meminfo::{MemTracker, rss_bytes};
//! use codegraph_graph::{MemTracker, rss_bytes};
//!
//! let mut t = MemTracker::new();
//! t.mark("baseline");
Expand Down Expand Up @@ -92,7 +92,7 @@ pub fn fmt_bytes(bytes: u64) -> String {
/// (đỉnh), nên benchmark tự lấy mẫu tại các mốc rồi giữ max.
///
/// ```no_run
/// # use codegraph_graph::meminfo::MemTracker;
/// # use codegraph_graph::MemTracker;
/// let mut t = MemTracker::new();
/// t.mark("open");
/// t.mark("ingest");
Expand Down
Loading
Loading