Skip to main content

relay_knowledge/storage/contracts/code/
source.rs

1use crate::domain::{CodeFileFingerprint, IndexedRepositoryDocument};
2
3use super::super::{StorageError, StorageFuture};
4
5/// Bounded indexed-source reads used by incremental planning and fallbacks.
6pub trait CodeIndexSourceStore: Send + Sync {
7    fn code_file_fingerprints(
8        &self,
9        repository_id: String,
10    ) -> StorageFuture<'_, Vec<CodeFileFingerprint>>;
11
12    fn code_file_fingerprints_for_scope(
13        &self,
14        source_scope: String,
15    ) -> StorageFuture<'_, Vec<CodeFileFingerprint>> {
16        Box::pin(async move {
17            Err(StorageError::InvalidInput(format!(
18                "code file fingerprints for scope '{source_scope}' are unavailable"
19            )))
20        })
21    }
22
23    fn code_file_fingerprints_for_paths(
24        &self,
25        source_scope: String,
26        paths: Vec<String>,
27    ) -> StorageFuture<'_, Vec<CodeFileFingerprint>> {
28        Box::pin(async move {
29            let mut fingerprints = self.code_file_fingerprints_for_scope(source_scope).await?;
30            fingerprints.retain(|fingerprint| paths.iter().any(|path| path == &fingerprint.path));
31            Ok(fingerprints)
32        })
33    }
34
35    fn code_file_candidate_paths_for_scope(
36        &self,
37        source_scope: String,
38        _path_filters: Vec<String>,
39        _language_filters: Vec<String>,
40        _exclude_generated: bool,
41        _limit: usize,
42    ) -> StorageFuture<'_, Vec<String>> {
43        Box::pin(async move {
44            Err(StorageError::InvalidInput(format!(
45                "bounded code file candidate paths for scope '{source_scope}' are unavailable"
46            )))
47        })
48    }
49
50    fn code_file_candidate_paths_for_query_scope(
51        &self,
52        source_scope: String,
53        _query: String,
54        path_filters: Vec<String>,
55        language_filters: Vec<String>,
56        exclude_generated: bool,
57        limit: usize,
58    ) -> StorageFuture<'_, Vec<String>> {
59        self.code_file_candidate_paths_for_scope(
60            source_scope,
61            path_filters,
62            language_filters,
63            exclude_generated,
64            limit,
65        )
66    }
67
68    fn repository_documents_for_scope(
69        &self,
70        source_scope: String,
71        _path_filters: Vec<String>,
72        _max_files: usize,
73        _max_bytes: usize,
74    ) -> StorageFuture<'_, Vec<IndexedRepositoryDocument>> {
75        Box::pin(async move {
76            Err(StorageError::InvalidInput(format!(
77                "repository documents for source scope '{source_scope}' are unavailable"
78            )))
79        })
80    }
81}