feat(memory): système de mémoire projet model-agnostic (L14, LOT A+B+C)
Base de connaissance persistante par projet, indépendante de tout modèle/CLU
et de git. Cadrage archi en §14.5 (ARCHITECTURE.md), cycle Archi→Dev→Test.
LOT A — étage 1 (.md, source de vérité)
- domaine: entité Memory (+ MemorySlug, MemoryType, MemoryFrontmatter,
MemoryLink, MemoryIndexEntry), liens [[slug]], index MEMORY.md dérivé
- port MemoryStore + MemoryError, adapter FsMemoryStore (.ideai/memory/)
- application: 7 use cases (Create/Update/List/Get/Delete/ReadIndex/
ResolveLinks), From<MemoryError> for AppError
- app-tauri: commandes + DTO, events MemorySaved/MemoryDeleted
- suppression de la variante morte DomainError::MalformedFrontmatter
LOT B — rappel adaptatif (étage 1)
- port MemoryRecall + MemoryQuery, adapter NaiveMemoryRecall (troncature
au budget de tokens, court-circuit budget-0), use case RecallMemory
LOT C — étage 2 vectoriel (structure complète, zéro dépendance lourde)
- port Embedder + EmbedderError, profils déclaratifs EmbedderProfile/
EmbedderStrategy (embedder.json)
- VectorMemoryRecall (cosinus, cache .ideai/memory/.index/ gitignoré)
- AdaptiveMemoryRecall (bascule pure should_use_vector), défaut none
- HashEmbedder (déterministe, tests), StubEmbedder (onnx/server/api)
Tests: 57 binaires verts, build + clippy --workspace sans warning.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -2,7 +2,9 @@
|
||||
//! relies on, and the per-port `From` mappings.
|
||||
|
||||
use application::AppError;
|
||||
use domain::ports::{FsError, GitError, ProcessError, PtyError, RemoteError, StoreError};
|
||||
use domain::ports::{
|
||||
EmbedderError, FsError, GitError, MemoryError, ProcessError, PtyError, RemoteError, StoreError,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn codes_are_stable() {
|
||||
@ -55,3 +57,43 @@ fn git_and_remote_map_through() {
|
||||
"REMOTE"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn memory_errors_map_per_variant() {
|
||||
// NotFound → NotFound.
|
||||
assert_eq!(AppError::from(MemoryError::NotFound).code(), "NOT_FOUND");
|
||||
// Frontmatter → Invalid (a malformed note is an invariant violation, not I/O).
|
||||
let invalid = AppError::from(MemoryError::Frontmatter("bad yaml".into()));
|
||||
assert_eq!(invalid.code(), "INVALID");
|
||||
assert_eq!(invalid, AppError::Invalid("bad yaml".to_owned()));
|
||||
// Io → Store.
|
||||
assert_eq!(AppError::from(MemoryError::Io("disk full".into())).code(), "STORE");
|
||||
// Serialization → Store (the catch-all arm).
|
||||
assert_eq!(
|
||||
AppError::from(MemoryError::Serialization("bad index".into())).code(),
|
||||
"STORE"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn embedder_errors_all_map_to_store() {
|
||||
// An embedder is a *derived* recall detail: every variant maps to STORE (its
|
||||
// failure must degrade the recall, never fail hard — see the From impl doc).
|
||||
assert_eq!(
|
||||
AppError::from(EmbedderError::Unavailable("no model".into())).code(),
|
||||
"STORE"
|
||||
);
|
||||
assert_eq!(
|
||||
AppError::from(EmbedderError::Unsupported("localOnnx".into())).code(),
|
||||
"STORE"
|
||||
);
|
||||
assert_eq!(
|
||||
AppError::from(EmbedderError::Io("read failed".into())).code(),
|
||||
"STORE"
|
||||
);
|
||||
// The message is carried through.
|
||||
assert_eq!(
|
||||
AppError::from(EmbedderError::Unsupported("api".into())),
|
||||
AppError::Store("embedder strategy unsupported: api".to_owned())
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user