-
Notifications
You must be signed in to change notification settings - Fork 11
Expand memory ingestion and retrieval APIs #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fed30be
e2b38cb
af9570f
73e374e
5afdfbb
f1f3c17
75c02ae
dd36834
dd5952e
576c910
716f291
f46b41e
4f3fae8
20f388b
ebd4aab
663cc8e
5ded074
8146e5a
572254e
9815c1a
ea0ca9c
a9b5f7b
5370a29
f81d40f
2dcd483
d497fcc
a80aded
88796aa
2a83dcb
8ca182c
c63696f
81646fa
9c34a07
23c3ac2
7e78a8b
713e3fd
0754b8a
1151209
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,10 +67,10 @@ | |
| //! - [`recall`]: the borrowed [`recall::RecallOpts`] and owned, serde-derived | ||
| //! [`recall::OwnedRecallOpts`] recall filters (both re-exported from | ||
| //! [`types`]). | ||
| //! - [`capabilities`]: the twenty [`capabilities::Capability`] families and | ||
| //! - [`capabilities`]: the [`capabilities::Capability`] families and | ||
| //! the [`capabilities::Capabilities`] set negotiated at bind time. | ||
| //! - [`provider`]: the driver contract — [`provider::MemoryProvider`] plus the | ||
| //! twenty capability family traits and the value types they need. | ||
| //! capability family traits and the value types they need. | ||
| //! - [`null`]: [`null::NullMemoryProvider`], the reference driver a | ||
| //! compiled-out or unconfigured memory subsystem binds to. | ||
| //! - [`health`]: [`health::MemoryHealth`], the liveness state a driver reports. | ||
|
|
@@ -118,7 +118,7 @@ pub mod sync_events; | |
| // nothing type-checks. | ||
| pub use tinymemory_bus::{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore removed re-exports or add a deprecation notice The diff replaces the [RULE] breaking-api-change · |
||
| capabilities, chunks, composio, error, evidence, goals, graph, health, learning, namespace, | ||
| recall, tool_memory, tree, types, version, wire, | ||
| operations, recall, tool_memory, tree, types, version, wire, | ||
| }; | ||
| /// The mandatory-family composition: wrap any [`traits::Memory`] backend as a | ||
| /// complete [`provider::MemoryProvider`]. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| //! Granular product-facing ingestion and answer operations. | ||
| //! | ||
| //! These traits deliberately split the legacy [`MemoryIngest`](super::MemoryIngest) | ||
| //! family. A connector may be excellent at conversations while having no | ||
| //! document, learning, or event model, and capability negotiation must be able | ||
| //! to express exactly that. | ||
|
|
||
| use async_trait::async_trait; | ||
|
|
||
| use crate::error::MemoryError; | ||
| use crate::learning::LearningCandidate; | ||
| use crate::provider::types::{IngestItem, IngestOutcome}; | ||
|
|
||
| pub use crate::operations::{ | ||
| AnswerCitation, AnswerRequest, AnswerResponse, AnswerStep, RawMemoryEvent, | ||
| }; | ||
|
|
||
| /// Document ingestion with driver-owned chunking and indexing. | ||
| #[async_trait] | ||
| pub trait MemoryDocumentIngest: Send + Sync { | ||
| /// Ingest one decoded document. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns [`MemoryError::Invalid`] for rejected input and a backend error | ||
| /// when persistence or indexing fails. | ||
| async fn ingest_document(&self, document: IngestItem) -> Result<IngestOutcome, MemoryError>; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Use the crate
As per coding guidelines: “Fallible public functions return 📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Coding guidelines 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find providers that implement either conflicting trait.
rg -n -C 3 --glob '*.rs' 'impl\s+Memory(Ingest|DocumentIngest)\s+for' crates
# Find direct concrete-provider calls that can become ambiguous.
rg -n -C 2 --glob '*.rs' '\.ingest_document\s*\(' cratesRepository: tinyhumansai/tinymemory Length of output: 9392 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- scoped conventions and learnings ---'
find /tmp/coderabbit-repo-knowledge/tinyhumansai-tinymemory-59f28c61 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- operations.rs ---'
cat -n crates/tinymemory-api/src/provider/operations.rs
printf '%s\n' '--- null provider and null tests ---'
sed -n '200,260p' crates/tinymemory-api/src/null.rs
rg -n -C 8 'ingest_document|MemoryIngest|MemoryDocumentIngest' crates/tinymemory-api/src/null_tests.rs
printf '%s\n' '--- public exports ---'
rg -n -C 4 'Memory(Ingest|DocumentIngest)|pub mod provider|pub use' crates/tinymemory-api/src/lib.rs crates/tinymemory-api/src/provider
printf '%s\n' '--- direct concrete-provider declarations and calls ---'
rg -n -C 5 --glob '*.rs' 'NullMemoryProvider|TinycortexProvider|TinycortexDocumentProvider|\.ingest_document\s*\(' cratesRepository: tinyhumansai/tinymemory Length of output: 50382 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- applicable repository conventions ---'
cat /tmp/coderabbit-repo-knowledge/tinyhumansai-tinymemory-59f28c61/conventions/repo-wide.md
cat /tmp/coderabbit-repo-knowledge/tinyhumansai-tinymemory-59f28c61/conventions/crates.md
printf '%s\n' '--- legacy method and imports ---'
sed -n '25,65p' crates/tinymemory-api/src/provider/content.rs
sed -n '1,35p' crates/tinymemory-api/src/null_tests.rs
sed -n '230,285p' crates/tinymemory-api/src/null_tests.rs
printf '%s\n' '--- public provider declarations and relevant impls ---'
sed -n '1,45p' crates/tinymemory-api/src/null.rs
sed -n '580,625p' crates/tinymemory-tinycortex/src/engine/mod.rs
sed -n '735,755p' crates/tinymemory-tinycortex/src/engine/mod.rsRepository: tinyhumansai/tinymemory Length of output: 13746 Avoid an ambiguous public
🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| /// Ordered conversation ingestion. | ||
| #[async_trait] | ||
| pub trait MemoryConversationIngest: Send + Sync { | ||
| /// Ingest all messages belonging to one conversation. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns [`MemoryError::Invalid`] when the batch mixes conversations or | ||
| /// contains invalid content, otherwise backend failures. | ||
| async fn ingest_conversation( | ||
| &self, | ||
| messages: Vec<IngestItem>, | ||
| ) -> Result<IngestOutcome, MemoryError>; | ||
| } | ||
|
|
||
| /// Ingestion of already-extracted learnings. | ||
| #[async_trait] | ||
| pub trait MemoryLearningIngest: Send + Sync { | ||
| /// Persist one learning candidate and its evidence pointer. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns [`MemoryError::Invalid`] for malformed confidence or keys, | ||
| /// otherwise backend failures. | ||
| async fn ingest_learning( | ||
| &self, | ||
| learning: LearningCandidate, | ||
| ) -> Result<IngestOutcome, MemoryError>; | ||
| } | ||
|
|
||
| /// Ingestion of raw durable events. | ||
| #[async_trait] | ||
| pub trait MemoryEventIngest: Send + Sync { | ||
| /// Persist one event. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns [`MemoryError::Invalid`] for malformed event data, otherwise | ||
| /// backend failures. | ||
| async fn ingest_event(&self, event: RawMemoryEvent) -> Result<IngestOutcome, MemoryError>; | ||
| } | ||
|
|
||
| /// Agentic retrieval that synthesises a grounded answer. | ||
| #[async_trait] | ||
| pub trait MemoryAnswer: Send + Sync { | ||
| /// Retrieve evidence and synthesize an answer with citations. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns [`MemoryError::Invalid`] for an empty query and backend or | ||
| /// inference errors when retrieval or synthesis fails. | ||
| async fn answer(&self, request: AnswerRequest) -> Result<AnswerResponse, MemoryError>; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Refresh the documented contract counts.
The contract now defines 26 capability families and 129 TinyBus members. The two README values are stale.
README.md#L208-L208: change “optional seventeen” to “optional twenty-three”.crates/tinymemory-bus/README.md#L7-L7: change “120 members” to “129 members”.📍 Affects 2 files
README.md#L208-L208(this comment)crates/tinymemory-bus/README.md#L7-L7🤖 Prompt for AI Agents