Overview
Concrete tool for scoring stored memories for relevance to a query using batched Jev Typed Decisions API calls, without embeddings or lexical pre-filtering.
Description
The memory_jev module implements the recall pipeline: it collects all active memories in scope, batches them into groups of up to 24 entries, sends each batch to the Jev Decisions API as noul questions ("Is this memory relevant to the query?"), and returns scored results. The selection is fail-closed: errors abort the entire selection, including already-scored batches. Queries are limited to 8 KiB, requests to 64 KiB, and the entire selection has a 60-second timeout.
Usage
- Recall memories: Call
recall() with a manager, query, limit, and scope.
- Custom transport: Call
select_with_transport() with a custom RelevanceTransport for testing.
Code Reference
Source Location
- Repository: jcode
- File: crates/jcode-base/src/memory_jev.rs
Signature
pub const MAX_BATCH_ENTRIES: usize = 24;
pub const MAX_REQUEST_BYTES: usize = 64 * 1024;
pub const MAX_QUERY_BYTES: usize = 8 * 1024;
#[async_trait]
pub trait RelevanceTransport: Send + Sync {
async fn evaluate(&self, state: Value, questions: Map<String, Value>) -> Result<Value>;
}
pub fn collect_scoped(
manager: &MemoryManager,
scope: MemoryScope,
) -> Result<Vec<MemoryEntry>>
pub async fn recall(
manager: &MemoryManager,
query: &str,
limit: usize,
scope: MemoryScope,
) -> Result<Vec<(MemoryEntry, f32)>>
pub async fn select(
client: &JevClient,
query: &str,
entries: Vec<MemoryEntry>,
limit: usize,
) -> Result<Vec<(MemoryEntry, f32)>>
pub fn build_batch(
query: &str,
entries: &[MemoryEntry],
) -> Result<(Value, Map<String, Value>)>
Import
use jcode_base::memory_jev::{recall, select, build_batch, MAX_BATCH_ENTRIES};
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| manager |
&MemoryManager |
Yes /// Memory store to collect from
|
| query |
&str |
Yes /// Query text (max 8 KiB)
|
| limit |
usize |
Yes /// Maximum memories to return
|
| scope |
MemoryScope |
Yes /// Project, Global, or All
|
Outputs
| Name |
Type |
Description
|
| return |
Result<Vec<(MemoryEntry, f32)>> /// Scored memories sorted by relevance (highest first)
|
Usage Examples
Recall Relevant Memories
use jcode_base::memory::MemoryManager;
use jcode_base::memory_jev::recall;
use jcode_base::memory::MemoryScope;
let manager = MemoryManager::new().with_project_dir("/project");
let results = recall(
&manager,
"How do I configure authentication?",
5,
MemoryScope::All,
).await?;
for (entry, score) in results {
println!("[{:.2}] {}: {}", score, entry.id, entry.content);
}
Build a Batch Manually
use jcode_base::memory_jev::build_batch;
let (state, questions) = build_batch(
"What is the deployment process?",
&entries[..24],
)?;
// Send `state` and `questions` to JevClient::evaluate
Related Pages
Implements Principle
Requires Environment
Uses Heuristics