|
31 | 31 | //! `docs/specs/2026-08-13-memory-module-port.md` §3. |
32 | 32 |
|
33 | 33 | use async_trait::async_trait; |
34 | | -use serde::{Deserialize, Serialize}; |
35 | 34 |
|
36 | | -use crate::chunks::{Chunk, SourceKind}; |
| 35 | +use crate::chunks::Chunk; |
37 | 36 | use crate::error::MemoryError; |
38 | 37 | use crate::provider::types::SourceScope; |
39 | 38 |
|
40 | | -/// Filters for [`MemoryChunks::list_chunks`]. |
41 | | -/// |
42 | | -/// Every field is optional and they compose with AND. The default matches |
43 | | -/// everything the scope allows, bounded by the driver's own safety cap. |
44 | | -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] |
45 | | -pub struct ChunkQuery { |
46 | | - /// Restrict to one source kind. |
47 | | - #[serde(default)] |
48 | | - pub source_kind: Option<SourceKind>, |
49 | | - /// Restrict to one logical source id. |
50 | | - #[serde(default)] |
51 | | - pub source_id: Option<String>, |
52 | | - /// Restrict to one owner. |
53 | | - #[serde(default)] |
54 | | - pub owner: Option<String>, |
55 | | - /// Inclusive lower bound on source time, epoch milliseconds. |
56 | | - #[serde(default)] |
57 | | - pub since_ms: Option<i64>, |
58 | | - /// Inclusive upper bound on source time, epoch milliseconds. |
59 | | - #[serde(default)] |
60 | | - pub until_ms: Option<i64>, |
61 | | - /// Maximum rows. The driver clamps this to its own cap — a caller cannot |
62 | | - /// raise the ceiling by asking for more. |
63 | | - #[serde(default)] |
64 | | - pub limit: Option<usize>, |
65 | | - /// Rows to skip, for pagination. |
66 | | - #[serde(default)] |
67 | | - pub offset: Option<usize>, |
68 | | - /// Drop chunks marked dropped by the lifecycle. |
69 | | - #[serde(default)] |
70 | | - pub exclude_dropped: bool, |
71 | | -} |
72 | | - |
73 | | -/// One chunk's stored embedding. |
74 | | -/// |
75 | | -/// Returned as a list rather than a map because the wire form of a map keyed by |
76 | | -/// chunk id is a JSON object, and an id is caller-supplied text; a list keeps |
77 | | -/// the encoding independent of what an id happens to contain. |
78 | | -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] |
79 | | -pub struct ChunkEmbedding { |
80 | | - /// The chunk this vector belongs to. |
81 | | - pub chunk_id: String, |
82 | | - /// The vector, in the embedding space named by the requested signature. |
83 | | - pub vector: Vec<f32>, |
84 | | -} |
85 | | - |
86 | | -/// One chunk plus the per-chunk facts stored beside it. |
87 | | -/// |
88 | | -/// # Why a detail view rather than four accessors |
89 | | -/// |
90 | | -/// An inspection caller wants the row, its body, where the body lives, its |
91 | | -/// lifecycle state and whether it has been embedded. Exposing those as four |
92 | | -/// methods would read naturally in-process and cost **four bus round trips per |
93 | | -/// row** out of it — and this is used to render lists. One method, one trip. |
94 | | -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] |
95 | | -pub struct ChunkDetail { |
96 | | - /// The chunk row. |
97 | | - pub chunk: Chunk, |
98 | | - /// The chunk's body as stored in the content vault, when it could be read. |
99 | | - /// |
100 | | - /// `None` means the vault read failed — distinct from an empty body, which |
101 | | - /// is a legitimately empty chunk. A caller rendering a preview should fall |
102 | | - /// back to [`Chunk::content`] rather than showing nothing. |
103 | | - #[serde(default)] |
104 | | - pub body: Option<String>, |
105 | | - /// Path of the body in the content vault, when it has one. |
106 | | - #[serde(default)] |
107 | | - pub content_path: Option<String>, |
108 | | - /// Lifecycle state (`active`, `dropped`, …); `None` when unrecorded. |
109 | | - #[serde(default)] |
110 | | - pub lifecycle_status: Option<String>, |
111 | | - /// Whether an embedding vector exists for this chunk in **any** space. |
112 | | - /// |
113 | | - /// Not scoped to a signature on purpose: this answers "has this been |
114 | | - /// embedded at all", which is what an inspection view wants. Asking whether |
115 | | - /// a *particular* space has it is [`MemoryChunks::chunk_embeddings`]. |
116 | | - pub has_embedding: bool, |
117 | | -} |
| 39 | +// The value types this family exchanges. They are defined in `tinymemory-bus` |
| 40 | +// — they cross the module boundary, and a host that only makes calls must be |
| 41 | +// able to name them without compiling this trait — and re-exported here so |
| 42 | +// every historical path keeps resolving and the types stay the same types. |
| 43 | +pub use tinymemory_bus::provider::chunks::{ChunkDetail, ChunkEmbedding, ChunkQuery}; |
118 | 44 |
|
119 | 45 | /// Direct read access to the chunk tier. |
120 | 46 | /// |
|
0 commit comments