use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::path::Path;
use std::time::Instant;
use anyhow::{Context, Result, bail};
use rayon::prelude::*;
use sha2::{Digest, Sha256};
use tracing::{debug, info, warn};
use crate::CancellationToken;
use crate::config::VeraConfig;
use crate::discovery;
use crate::embedding::{
EmbeddingError, EmbeddingProvider, embed_chunks_concurrent_with_progress_and_cancellation,
};
use crate::parsing;
use crate::storage::bm25::Bm25Index;
use crate::storage::metadata::{FileIndexState, FileIndexStatus, MetadataStore};
use crate::storage::vector::VectorStore;
use crate::types::Language;
use super::pipeline;
use super::pipeline::FileError;
#[derive(Debug, Clone, serde::Serialize)]
pub struct UpdateSummary {
pub files_modified: usize,
pub files_added: usize,
pub files_deleted: usize,
pub files_unchanged: usize,
pub files_with_tree_sitter_errors: usize,
pub files_using_tier0_fallback: usize,
pub parse_errors: Vec<FileError>,
pub files_deferred: usize,
pub total_chunks: u64,
pub elapsed_secs: f64,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct UpdateOptions {
pub max_files: Option<usize>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum UpdateProgress {
DiscoveryDone { file_count: usize },
ClassificationDone {
modified: usize,
added: usize,
deleted: usize,
unchanged: usize,
deferred: usize,
},
ParsingDone {
file_count: usize,
chunk_count: usize,
},
EmbeddingProgress { done: usize, total: usize },
EmbeddingDone { count: usize },
StorageDone,
}
struct PreparedFile {
path: String,
hash: String,
modified: bool,
chunks: Vec<crate::types::Chunk>,
references: Vec<parsing::references::RawReference>,
type_relations: Vec<parsing::type_relations::RawTypeRelation>,
state: FileIndexState,
}
fn collect_prepared_results(
results: Vec<(PreparedFile, Option<FileError>)>,
) -> (Vec<PreparedFile>, Vec<FileError>) {
let mut prepared_files = Vec::with_capacity(results.len());
let mut parse_errors = Vec::new();
for (prepared, parse_error) in results {
prepared_files.push(prepared);
if let Some(parse_error) = parse_error {
parse_errors.push(parse_error);
}
}
(prepared_files, parse_errors)
}
fn processed_file_counts(files: impl IntoIterator<Item = bool>) -> (usize, usize) {
files
.into_iter()
.fold((0, 0), |(modified, added), is_modified| {
if is_modified {
(modified + 1, added)
} else {
(modified, added + 1)
}
})
}
pub fn content_hash(content: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(content.as_bytes());
let hash = hasher.finalize();
hash.iter().fold(String::with_capacity(64), |mut s, b| {
use std::fmt::Write;
let _ = write!(s, "{b:02x}");
s
})
}
pub(crate) fn detect_language_for_path(file_path: impl AsRef<Path>) -> Language {
let file_path = file_path.as_ref();
file_path
.file_name()
.and_then(|n| n.to_str())
.and_then(Language::from_filename)
.unwrap_or_else(|| {
let ext = file_path.extension().and_then(|e| e.to_str()).unwrap_or("");
Language::from_extension(ext)
})
}
pub(crate) fn hash_for_indexing_source(
content: &str,
rel_path: &str,
language: Language,
repo_root: &Path,
max_file_size_bytes: u64,
) -> String {
content_hash(&source_for_indexing_hash(
content,
rel_path,
language,
repo_root,
max_file_size_bytes,
))
}
fn source_for_indexing_hash<'a>(
content: &'a str,
rel_path: &str,
language: Language,
repo_root: &Path,
max_file_size_bytes: u64,
) -> Cow<'a, str> {
if language != Language::Rst {
return Cow::Borrowed(content);
}
let absolute_path = repo_root.join(rel_path);
match parsing::sphinx::preprocess_rst_with_limit(
content,
&absolute_path,
repo_root,
max_file_size_bytes,
) {
Ok(preprocessed) => Cow::Owned(preprocessed),
Err(err) => {
warn!(
file = %rel_path,
error = %err,
"failed to preprocess rst for hashing; falling back to raw source"
);
Cow::Borrowed(content)
}
}
}
pub async fn update_repository<P: EmbeddingProvider>(
repo_path: &Path,
provider: &P,
config: &VeraConfig,
model_name: &str,
) -> Result<UpdateSummary> {
update_repository_with_options_and_progress(
repo_path,
provider,
config,
model_name,
&UpdateOptions::default(),
|_| {},
)
.await
}
pub async fn update_repository_with_progress<P, F>(
repo_path: &Path,
provider: &P,
config: &VeraConfig,
model_name: &str,
on_progress: F,
) -> Result<UpdateSummary>
where
P: EmbeddingProvider,
F: Fn(UpdateProgress) + Send + Sync,
{
update_repository_with_options_and_progress(
repo_path,
provider,
config,
model_name,
&UpdateOptions::default(),
on_progress,
)
.await
}
pub async fn update_repository_with_options_and_progress<P, F>(
repo_path: &Path,
provider: &P,
config: &VeraConfig,
model_name: &str,
options: &UpdateOptions,
on_progress: F,
) -> Result<UpdateSummary>
where
P: EmbeddingProvider,
F: Fn(UpdateProgress) + Send + Sync,
{
update_repository_with_options_and_progress_and_cancellation(
repo_path,
provider,
config,
model_name,
options,
on_progress,
&CancellationToken::new(),
)
.await
}
pub async fn update_repository_with_options_and_progress_and_cancellation<P, F>(
repo_path: &Path,
provider: &P,
config: &VeraConfig,
model_name: &str,
options: &UpdateOptions,
on_progress: F,
cancellation: &CancellationToken,
) -> Result<UpdateSummary>
where
P: EmbeddingProvider,
F: Fn(UpdateProgress) + Send + Sync,
{
let start = Instant::now();
cancellation.check()?;
if !repo_path.exists() {
bail!("path does not exist: {}", repo_path.display());
}
if !repo_path.is_dir() {
bail!("path is not a directory: {}", repo_path.display());
}
let repo_root = repo_path
.canonicalize()
.with_context(|| format!("failed to resolve path: {}", repo_path.display()))?;
let idx_dir = pipeline::index_dir(&repo_root);
if !idx_dir.exists() {
bail!(
"no index found at {}. Run `vera index` first.",
idx_dir.display()
);
}
info!(path = %repo_root.display(), "starting incremental update");
let disc =
discovery::discover_files_with_cancellation(&repo_root, &config.indexing, cancellation)
.context("file discovery failed")?;
on_progress(UpdateProgress::DiscoveryDone {
file_count: disc.files.len(),
});
let metadata_path = idx_dir.join("metadata.db");
let metadata_store =
MetadataStore::open(&metadata_path).context("failed to open metadata store")?;
let mut stored_dim = config.embedding.max_stored_dim;
if let (Some(s_model), Some(s_dim)) = (
metadata_store.get_index_meta("model_name").unwrap_or(None),
metadata_store
.get_index_meta("embedding_dim")
.unwrap_or(None),
) {
if !crate::config::model_names_match_with_aliases(
&s_model,
model_name,
&config.embedding.model_aliases,
) {
bail!(
"Index was created with model '{}' ({} dimensions), but you are using model '{}'. Please re-index with matching provider.",
s_model,
s_dim,
model_name
);
}
let stored_prefix = metadata_store
.get_index_meta("document_prefix")
.unwrap_or(None)
.unwrap_or_default();
let active_prefix = provider.document_prefix_identity();
if stored_prefix != active_prefix {
bail!(
"Index was created with document prefix '{}', but the active provider uses '{}'. Please re-index to rebuild the vector space.",
stored_prefix,
active_prefix
);
}
if let Ok(dim) = s_dim.parse::<usize>() {
if let Some(provider_dim) = provider.expected_dim()
&& provider_dim < dim
{
bail!(
"Dimension mismatch: index has {} dimensions but active provider only returns {}. Please re-index with matching provider.",
dim,
provider_dim
);
}
stored_dim = dim;
}
} else if let Some(s_dim) = metadata_store
.get_index_meta("embedding_dim")
.unwrap_or(None)
&& let Ok(dim) = s_dim.parse::<usize>()
{
stored_dim = dim;
}
let stored_files: HashSet<String> = metadata_store
.tracked_files()
.context("failed to list tracked files")?
.into_iter()
.collect();
let read_results: Vec<(String, Option<String>)> = disc
.files
.par_iter()
.map(|file| {
cancellation.check()?;
let content = match discovery::read_source_lossy_at(
&disc.root_dir,
Path::new(&file.relative_path),
) {
Ok(content) => Some(content),
Err(err) => {
warn!(file = %file.relative_path, error = %err, "failed to read file");
None
}
};
Ok((file.relative_path.clone(), content))
})
.collect::<Result<_>>()?;
cancellation.check()?;
let current_files: HashMap<String, String> = read_results
.into_iter()
.filter_map(|(path, content)| content.map(|content| (path, content)))
.collect();
let current_paths: HashSet<&str> = disc
.files
.iter()
.map(|file| file.relative_path.as_str())
.collect();
let mut modified = Vec::new();
let mut added = Vec::new();
let mut deleted = Vec::new();
let mut unchanged = 0usize;
for (rel_path, content) in ¤t_files {
cancellation.check()?;
let language = detect_language_for_path(rel_path);
let normalized_source = source_for_indexing_hash(
content,
rel_path,
language,
&repo_root,
config.indexing.max_file_size_bytes,
);
let hash = content_hash(&normalized_source);
let normalized_source = (language == Language::Rst).then(|| normalized_source.into_owned());
let stored_hash = metadata_store
.get_file_hash(rel_path)
.context("failed to get stored hash")?;
if stored_files.contains(rel_path.as_str()) {
match stored_hash {
Some(ref old_hash) if *old_hash == hash => {
unchanged += 1;
}
_ => {
modified.push((rel_path.clone(), content.clone(), hash, normalized_source));
}
}
} else {
added.push((rel_path.clone(), content.clone(), hash, normalized_source));
}
}
for stored_path in &stored_files {
if !current_paths.contains(stored_path.as_str()) {
deleted.push(stored_path.clone());
}
}
modified.sort_by(|left, right| left.0.cmp(&right.0));
added.sort_by(|left, right| left.0.cmp(&right.0));
deleted.sort();
let pending_files = modified.len() + added.len();
let files_to_process = options
.max_files
.unwrap_or(pending_files)
.min(pending_files);
let modified_to_process = modified.len().min(files_to_process);
let added_to_process = added
.len()
.min(files_to_process.saturating_sub(modified_to_process));
let files_deferred = pending_files - modified_to_process - added_to_process;
modified.truncate(modified_to_process);
added.truncate(added_to_process);
info!(
modified = modified.len(),
added = added.len(),
deleted = deleted.len(),
unchanged,
deferred = files_deferred,
max_files = options.max_files,
"file classification complete"
);
on_progress(UpdateProgress::ClassificationDone {
modified: modified.len(),
added: added.len(),
deleted: deleted.len(),
unchanged,
deferred: files_deferred,
});
let files_to_index: Vec<(String, String, String, Option<String>, bool)> = modified
.iter()
.cloned()
.map(|(path, content, hash, normalized_source)| {
(path, content, hash, normalized_source, true)
})
.chain(
added
.iter()
.cloned()
.map(|(path, content, hash, normalized_source)| {
(path, content, hash, normalized_source, false)
}),
)
.collect();
let mut prepared_files = Vec::new();
let mut parse_errors = Vec::new();
if !files_to_index.is_empty() {
let parsed: Vec<(PreparedFile, Option<FileError>)> = files_to_index
.par_iter()
.map(
|(rel_path, content, hash, normalized_source, is_modified)| {
cancellation.check()?;
let language = detect_language_for_path(rel_path);
let (chunks, refs, file_state, parse_error) = if language == Language::Rst {
let refs = parsing::parse_and_extract_references(content, language);
let src = normalized_source.as_deref().unwrap_or(content);
chunk_file_for_update(src, rel_path, language, config, Some(refs))
} else {
chunk_file_for_update(content, rel_path, language, config, None)
};
let type_relations = parsing::type_relations::extract_type_relations(&chunks);
debug!(
file = %rel_path,
chunks = chunks.len(),
refs = refs.len(),
type_relations = type_relations.len(),
"parsed file"
);
Ok((
PreparedFile {
path: rel_path.clone(),
hash: hash.clone(),
modified: *is_modified,
chunks,
references: refs,
type_relations,
state: file_state,
},
parse_error,
))
},
)
.collect::<Result<_>>()?;
cancellation.check()?;
(prepared_files, parse_errors) = collect_prepared_results(parsed);
}
let all_chunks: Vec<_> = prepared_files
.iter()
.flat_map(|file| file.chunks.iter().cloned())
.collect();
let file_states: Vec<_> = prepared_files
.iter()
.map(|file| file.state.clone())
.collect();
if !files_to_index.is_empty() {
on_progress(UpdateProgress::ParsingDone {
file_count: files_to_index.len(),
chunk_count: all_chunks.len(),
});
} else {
on_progress(UpdateProgress::ParsingDone {
file_count: 0,
chunk_count: 0,
});
on_progress(UpdateProgress::EmbeddingDone { count: 0 });
}
let mut embeddings = if all_chunks.is_empty() {
if !files_to_index.is_empty() {
on_progress(UpdateProgress::EmbeddingDone { count: 0 });
}
Vec::new()
} else {
let (batch_size, max_concurrent_requests) = config.embedding.bounded_parallelism();
if batch_size != config.embedding.batch_size
|| max_concurrent_requests != config.embedding.max_concurrent_requests
{
info!(
configured_batch_size = config.embedding.batch_size,
configured_concurrency = config.embedding.max_concurrent_requests,
max_in_flight_inputs = config.embedding.max_in_flight_inputs,
batch_size,
max_concurrent_requests,
"clamped update embedding parallelism to the in-flight input bound"
);
}
let progress_cb = |done: usize, total: usize| {
on_progress(UpdateProgress::EmbeddingProgress { done, total });
};
let embedding_result = embed_chunks_concurrent_with_progress_and_cancellation(
provider,
&all_chunks,
batch_size,
max_concurrent_requests,
config.indexing.max_chunk_bytes,
cancellation.as_async_token(),
progress_cb,
)
.await;
let embeddings = match embedding_result {
Ok(embeddings) => embeddings,
Err(error) => {
if matches!(error, EmbeddingError::Cancelled) {
cancellation.check()?;
}
return Err(error).context("embedding generation failed");
}
};
on_progress(UpdateProgress::EmbeddingDone {
count: embeddings.len(),
});
embeddings
};
cancellation.check()?;
let final_stored_dim = if embeddings.is_empty() {
stored_dim
} else {
super::truncate_embeddings(&mut embeddings, stored_dim)
};
let (processed_modified, processed_added) =
processed_file_counts(prepared_files.iter().map(|file| file.modified));
if !deleted.is_empty() || !prepared_files.is_empty() {
let vector_path = idx_dir.join("vectors.db");
let vector_store = VectorStore::open(&vector_path, final_stored_dim)
.context("failed to open vector store for update")?;
let bm25_dir = idx_dir.join("bm25");
let bm25_index =
Bm25Index::open(&bm25_dir).context("failed to open BM25 index for update")?;
let mut bm25_deletions: Vec<&str> = deleted.iter().map(String::as_str).collect();
let cleanup_chunk_data: Vec<bool> = prepared_files
.iter()
.map(|file| {
metadata_store
.get_chunks_by_file(&file.path)
.with_context(|| format!("failed to inspect existing chunks for {}", file.path))
.map(|chunks| file.modified || !chunks.is_empty())
})
.collect::<Result<_>>()?;
bm25_deletions.extend(
prepared_files
.iter()
.zip(&cleanup_chunk_data)
.filter(|(_, cleanup)| **cleanup)
.map(|(file, _)| file.path.as_str()),
);
cancellation.check()?;
bm25_index
.delete_by_files(&bm25_deletions)
.context("failed to delete BM25 entries for changed files")?;
for file_path in &deleted {
remove_file_from_index(&metadata_store, &vector_store, file_path)?;
}
for (file, cleanup_chunks) in prepared_files.iter().zip(cleanup_chunk_data) {
remove_file_parse_data(&metadata_store, &file.path)?;
if cleanup_chunks {
remove_file_chunk_data(&metadata_store, &vector_store, &file.path)?;
}
metadata_store
.delete_file_state(&file.path)
.with_context(|| format!("failed to delete file state for {}", file.path))?;
}
let file_refs: Vec<(&str, &[parsing::references::RawReference])> = prepared_files
.iter()
.filter(|file| !file.references.is_empty())
.map(|file| (file.path.as_str(), file.references.as_slice()))
.collect();
let file_type_relations: Vec<(&str, &[parsing::type_relations::RawTypeRelation])> =
prepared_files
.iter()
.filter(|file| !file.type_relations.is_empty())
.map(|file| (file.path.as_str(), file.type_relations.as_slice()))
.collect();
metadata_store
.insert_parse_artifacts_batch_borrowed(&file_refs, &file_type_relations)
.context("failed to store references and type relations")?;
if !all_chunks.is_empty() {
metadata_store
.insert_chunks(&all_chunks)
.context("failed to insert updated chunk metadata")?;
let batch: Vec<(&str, &[f32])> = embeddings
.iter()
.map(|(id, vector)| (id.as_str(), vector.as_slice()))
.collect();
vector_store
.insert_batch(&batch)
.context("failed to insert updated vectors")?;
bm25_index
.insert_chunks(&all_chunks)
.context("failed to insert updated BM25 documents")?;
}
if !file_states.is_empty() {
metadata_store
.insert_file_states(&file_states)
.context("failed to update file index states")?;
}
let file_hashes: Vec<(&str, &str)> = prepared_files
.iter()
.map(|file| (file.path.as_str(), file.hash.as_str()))
.collect();
metadata_store
.set_file_hashes_batch_borrowed(&file_hashes)
.context("failed to update file hashes")?;
}
let total_chunks = metadata_store
.chunk_count()
.context("failed to count chunks")?;
super::freshness::record_index_snapshot(&metadata_store, &config.indexing)
.context("failed to update index freshness metadata")?;
on_progress(UpdateProgress::StorageDone);
let summary = UpdateSummary {
files_modified: processed_modified,
files_added: processed_added,
files_deleted: deleted.len(),
files_unchanged: unchanged,
files_with_tree_sitter_errors: pipeline::count_tree_sitter_error_files(&file_states),
files_using_tier0_fallback: pipeline::count_tier0_fallback_files(&file_states),
parse_errors,
files_deferred,
total_chunks,
elapsed_secs: start.elapsed().as_secs_f64(),
};
info!(
modified = summary.files_modified,
added = summary.files_added,
deleted = summary.files_deleted,
unchanged = summary.files_unchanged,
deferred = summary.files_deferred,
total_chunks = summary.total_chunks,
elapsed = %format!("{:.2}s", summary.elapsed_secs),
"incremental update complete"
);
Ok(summary)
}
fn chunk_file_for_update(
src: &str,
rel_path: &str,
language: Language,
config: &VeraConfig,
refs_override: Option<Vec<parsing::references::RawReference>>,
) -> (
Vec<crate::types::Chunk>,
Vec<parsing::references::RawReference>,
FileIndexState,
Option<FileError>,
) {
let state =
|status: FileIndexStatus, tree_has_error: bool, tier0_fallback: bool, chunk_count: u64| {
FileIndexState {
file_path: rel_path.to_string(),
language: language.to_string(),
status,
tree_has_error,
tier0_fallback,
chunk_count,
}
};
match parsing::parse_file_with_diagnostics(src, rel_path, language, &config.indexing) {
Ok((chunks, parsed_refs, diagnostics)) => {
let chunk_count = chunks.len() as u64;
let refs = refs_override.unwrap_or(parsed_refs);
(
chunks,
refs,
state(
FileIndexStatus::Indexed,
diagnostics.tree_has_error,
diagnostics.used_tier0_fallback,
chunk_count,
),
None,
)
}
Err(err) => {
let refs = refs_override.unwrap_or_default();
if refs.is_empty() {
warn!(file = %rel_path, error = %err, "parse error during update");
} else {
warn!(
file = %rel_path,
error = %err,
refs = refs.len(),
"failed to chunk rst during update; keeping extracted references"
);
}
(
Vec::new(),
refs,
state(FileIndexStatus::ParseError, false, false, 0),
Some(FileError {
file_path: rel_path.to_string(),
error: err.to_string(),
}),
)
}
}
}
fn remove_file_parse_data(metadata_store: &MetadataStore, file_path: &str) -> Result<()> {
metadata_store
.delete_references_by_file(file_path)
.context("failed to delete references for file")?;
metadata_store
.delete_type_relations_by_file(file_path)
.context("failed to delete type relations for file")?;
Ok(())
}
fn remove_file_chunk_data(
metadata_store: &MetadataStore,
vector_store: &VectorStore,
file_path: &str,
) -> Result<()> {
let prefix = format!("{file_path}:");
vector_store
.delete_by_file_prefix(&prefix)
.with_context(|| format!("failed to delete vectors for {file_path}"))?;
metadata_store
.delete_chunks_by_file(file_path)
.with_context(|| format!("failed to delete metadata for {file_path}"))?;
debug!(file = %file_path, "removed file chunk data from index");
Ok(())
}
fn remove_file_from_index(
metadata_store: &MetadataStore,
vector_store: &VectorStore,
file_path: &str,
) -> Result<()> {
remove_file_parse_data(metadata_store, file_path)?;
remove_file_chunk_data(metadata_store, vector_store, file_path)?;
metadata_store
.delete_file_hash(file_path)
.with_context(|| format!("failed to delete file hash for {file_path}"))?;
metadata_store
.delete_file_state(file_path)
.with_context(|| format!("failed to delete file state for {file_path}"))?;
Ok(())
}
#[cfg(test)]
#[path = "update_tests.rs"]
mod tests;
#[cfg(test)]
mod regression_tests {
use super::{content_hash, hash_for_indexing_source};
use crate::config::VeraConfig;
use crate::embedding::test_helpers::MockProvider;
use crate::indexing::{
UpdateOptions, detect_staleness, index_dir, index_repository, update_repository,
update_repository_with_options_and_progress,
};
use crate::storage::bm25::Bm25Index;
use crate::types::Language;
use tempfile::tempdir;
#[test]
fn rst_update_hash_matches_the_preprocessed_source_the_pipeline_indexes() {
let temp = tempdir().unwrap();
let source_path = temp.path().join("guide.rst");
let source = "Guide\n=====\n\nSee :doc:`Other </other>`.\n";
std::fs::write(&source_path, source).unwrap();
let preprocessed = crate::parsing::sphinx::preprocess_rst_with_limit(
source,
&source_path,
temp.path(),
1024,
)
.unwrap();
let update_hash =
hash_for_indexing_source(source, "guide.rst", Language::Rst, temp.path(), 1024);
assert_ne!(content_hash(source), update_hash);
assert_eq!(content_hash(&preprocessed), update_hash);
}
#[tokio::test]
async fn update_removes_old_chunks_when_modified_file_has_no_chunks() {
let dir = tempdir().unwrap();
std::fs::write(dir.path().join("main.rs"), "fn old_name() {}\n").unwrap();
let provider = MockProvider::new(8);
let config = VeraConfig::default();
index_repository(dir.path(), &provider, &config, "mock-model")
.await
.unwrap();
let idx = index_dir(&dir.path().canonicalize().unwrap());
let bm25 = Bm25Index::open(&idx.join("bm25")).unwrap();
assert!(!bm25.search("old_name", 10).unwrap().is_empty());
std::fs::write(dir.path().join("main.rs"), "\n \n").unwrap();
update_repository(dir.path(), &provider, &config, "mock-model")
.await
.unwrap();
assert!(bm25.search("old_name", 10).unwrap().is_empty());
}
#[tokio::test]
async fn update_keeps_deferred_modified_files_stale() {
let dir = tempdir().unwrap();
std::fs::write(dir.path().join("a.rs"), "fn a() {}\n").unwrap();
std::fs::write(dir.path().join("b.rs"), "fn b() {}\n").unwrap();
let provider = MockProvider::new(8);
let config = VeraConfig::default();
index_repository(dir.path(), &provider, &config, "mock-model")
.await
.unwrap();
std::fs::write(dir.path().join("a.rs"), "fn updated_a() {}\n").unwrap();
std::fs::write(dir.path().join("b.rs"), "fn updated_b() {}\n").unwrap();
let summary = update_repository_with_options_and_progress(
dir.path(),
&provider,
&config,
"mock-model",
&UpdateOptions { max_files: Some(1) },
|_| {},
)
.await
.unwrap();
assert_eq!(summary.files_deferred, 1);
let freshness = detect_staleness(dir.path(), &config.indexing).unwrap();
assert_eq!(freshness.files_modified, 1);
}
}