Struct ExternalStore
pub struct ExternalStore { /* private fields */ }Expand description
Sidecar DuckDB store owning its own !Send + !Sync Connection.
Implementations§
§impl ExternalStore
impl ExternalStore
pub fn open_existing(
cache_root: &Path,
repo_path: &Path,
) -> Result<Option<Self>>
pub fn open_existing( cache_root: &Path, repo_path: &Path, ) -> Result<Option<Self>>
Open the sidecar store read-only if it already exists on disk.
Returns None when the sidecar file is absent — no directory is created
and no file is written. Use this in read paths (e.g. gate evaluation)
where creating the sidecar as a side-effect would be wrong. The
connection is opened with AccessMode::ReadOnly, so it takes a shared
lock and coexists with other readers; it never runs DDL, so a sidecar
missing its table is returned as-is (queries against it will fail —
prefer ExternalStore::open_nonempty, which maps that case to None).
§Errors
Returns CodeLoreError::Analysis only if the file exists but cannot
be opened read-only.
pub fn open_nonempty(
cache_root: &Path,
repo_path: &Path,
) -> Result<Option<Self>>
pub fn open_nonempty( cache_root: &Path, repo_path: &Path, ) -> Result<Option<Self>>
Open the sidecar store read-only only when it exists, is readable, and holds at least one finding.
Returns None when the sidecar is absent, present-but-empty, or present
but unusable (truncated/corrupt — missing the external_findings table).
For a reader these are one “nothing to read” state: an empty sidecar
carries no more information than a missing one, and a tableless sidecar
cannot be healed under a read-only lock (only ExternalStore::open_or_create
heals). The “absent, empty, and unreadable are equivalent” policy lives
here; call sites keep their own presentation (skip notice, precondition
error).
§Errors
Returns CodeLoreError::Analysis if the file exists but cannot be
opened read-only, or if the table-presence probe itself fails for a
reason other than the table being absent.
pub fn open_or_create(cache_root: &Path, repo_path: &Path) -> Result<Self>
pub fn open_or_create(cache_root: &Path, repo_path: &Path) -> Result<Self>
Open or create the sidecar store for repo_path under cache_root.
Creates the parent directory and the table schema on first call.
§Errors
Returns CodeLoreError::Analysis if the directory cannot be created
or the DuckDB connection/schema step fails.
pub fn replace_engine(
&self,
engine: &str,
findings: &[ExternalFinding],
) -> Result<usize>
pub fn replace_engine( &self, engine: &str, findings: &[ExternalFinding], ) -> Result<usize>
Replace all findings for engine with findings.
Wraps the DELETE + INSERT loop in a single transaction so a mid-loop process kill never leaves the engine’s rows deleted without replacement. The operation is idempotent: re-ingesting the same file produces an identical row count.
Returns the count of inserted rows.
§Errors
Returns CodeLoreError::Analysis on any DuckDB error. On error the
transaction is rolled back automatically when it is dropped.
pub fn count(&self) -> Result<u64>
pub fn count(&self) -> Result<u64>
Count all findings currently stored across all engines.
§Errors
Returns CodeLoreError::Analysis on DuckDB error.
pub fn findings_by_path(&self) -> Result<HashMap<String, PathFindings>>
pub fn findings_by_path(&self) -> Result<HashMap<String, PathFindings>>
Read all findings grouped by file path.
Returns a map from path → (engines, finding_count, worst_level) where:
enginesis the sorted, deduplicated list of engine names that flagged the pathfinding_countis the total number of findings across all enginesworst_levelis the most severe level present ("error">"warning">"note")
The caller uses this map for a Rust-side join against the behavioral
analyses (hotspots, code-health): the sidecar and fact-store each own a
!Send + !Sync DuckDB connection, so the two are never joined across a
single connection — the join happens in Rust instead.
§Errors
Returns CodeLoreError::Analysis on DuckDB error.
Auto Trait Implementations§
impl !Freeze for ExternalStore
impl !RefUnwindSafe for ExternalStore
impl !Sync for ExternalStore
impl !UnwindSafe for ExternalStore
impl Send for ExternalStore
impl Unpin for ExternalStore
impl UnsafeUnpin for ExternalStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more