Add OpenCode integration and safer startup

This commit is contained in:
Sam Valladares 2026-06-15 17:06:01 -05:00
parent 16903f3ab4
commit 6c7d56b4cf
21 changed files with 676 additions and 44 deletions

View file

@ -121,7 +121,11 @@ candle-core = { version = "0.10.2", optional = true }
# its memory_mapping_allocator_gt template references the POSIX MAP_FAILED
# macro from <sys/mman.h>, which doesn't exist on MSVC. Tracked upstream in
# unum-cloud/usearch#746. Unpin when the upstream fix lands.
usearch = { version = "=2.23.0", optional = true }
#
# Disable default features so release binaries do not include SimSIMD's
# Haswell+/AVX2/FMA dispatch targets. Those kernels can trigger illegal
# instructions on older x86_64 CPUs that Vestige otherwise supports.
usearch = { version = "=2.23.0", default-features = false, optional = true }
# LRU cache for query embeddings
lru = "0.16"

View file

@ -301,21 +301,6 @@ async fn main() {
let storage = match Storage::new(storage_path) {
Ok(s) => {
info!("Storage initialized successfully");
// Try to initialize embeddings early and log any issues
#[cfg(feature = "embeddings")]
{
if let Err(e) = s.init_embeddings() {
error!("Failed to initialize embedding service: {}", e);
error!("Smart ingest will fall back to regular ingest without deduplication");
error!(
"Hint: Check FASTEMBED_CACHE_PATH or ensure ~/.cache/vestige/fastembed is writable"
);
} else {
info!("Embedding service initialized successfully");
}
}
Arc::new(s)
}
Err(e) => {
@ -324,6 +309,40 @@ async fn main() {
}
};
// Initialize embeddings in the background so MCP clients can complete the
// stdio handshake quickly. First-run model downloads can otherwise exceed
// short client startup timeouts.
#[cfg(feature = "embeddings")]
{
let storage_clone = Arc::clone(&storage);
tokio::task::spawn_blocking(move || {
if let Err(e) = storage_clone.init_embeddings() {
error!("Failed to initialize embedding service: {}", e);
error!("Smart ingest will fall back to regular ingest without deduplication");
error!(
"Hint: Check FASTEMBED_CACHE_PATH or ensure ~/.cache/vestige/fastembed is writable"
);
} else {
info!("Embedding service initialized successfully");
#[cfg(feature = "vector-search")]
match storage_clone.generate_embeddings(None, false) {
Ok(result) => {
if result.successful > 0 || result.failed > 0 {
info!(
embeddings_generated = result.successful,
embeddings_failed = result.failed,
embeddings_skipped = result.skipped,
"Background embedding backfill complete"
);
}
}
Err(e) => warn!("Background embedding backfill failed: {}", e),
}
}
});
}
// Spawn periodic auto-consolidation so FSRS-6 decay scores stay fresh.
// Runs on startup (if needed) and then every N hours (default: 6).
// Configurable via VESTIGE_CONSOLIDATION_INTERVAL_HOURS env var.
@ -506,7 +525,7 @@ async fn main() {
}
// Load cross-encoder reranker in the background (downloads ~150MB on first run)
#[cfg(feature = "vector-search")]
#[cfg(all(feature = "vector-search", feature = "embeddings"))]
{
let cog_clone = Arc::clone(&cognitive);
tokio::spawn(async move {