1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2026 Kirky.X. All rights reserved.
// SPDX-License-Identifier: MIT
//! CacheStore capability trait — abstract cache interface for storage,
//! query, AST, and embed caching (T017, v0.3.3).
//!
//! Stored in AsyncKit as `Arc<dyn CacheStore>` via [`CacheModule`]. The
//! trait is intentionally synchronous (no `async` methods) because the
//! downstream call sites that consume it (`hash_file`, `parse_file`,
//! `execute_cypher`) are themselves synchronous. The underlying oxcache
//! `MokaMemoryBackend` resolves sync access via `sync_block_on`, which
//! auto-detects the tokio runtime (multi-thread `block_in_place` or
//! lazily-created current-thread runtime).
/// Cache key type — all cache operations use string keys.
///
/// Callers are responsible for constructing meaningful keys (e.g., file
/// paths, SHA-256 hashes of query strings, content hashes). This is a
/// type alias rather than a newtype to keep the ergonomics of `&str` and
/// `String` at call sites.
pub type CacheKey = String;
/// Capability trait for the Cache subsystem.
///
/// Provides `get` / `set` / `invalidate_all` operations for
/// content-addressed caching. Values are raw bytes (`Vec<u8>`) — callers
/// are responsible for serialization / deserialization.
///
/// # Errors
///
/// All methods are infallible (do not return `Result`):
/// - [`get`](CacheStore::get) returns `None` on cache miss *or* internal
/// error (errors are logged via `tracing::warn!` and surfaced as misses).
/// - [`set`](CacheStore::set) and [`invalidate_all`](CacheStore::invalidate_all)
/// log errors via `tracing::warn!` but do not propagate them. This
/// matches cache semantics — a failed write should not crash the
/// caller; the worst case is a cache miss on the next read.