Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ members = [

[workspace.package]
version = "0.5.11"
edition = "2021"
edition = "2024"
rust-version = "1.85"
license = "Apache-2.0"
readme = "README.md"
Expand Down
6 changes: 3 additions & 3 deletions crates/aquifer/src/backend.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: Apache-2.0

use futures_util::{future::BoxFuture, FutureExt};
use futures_util::{FutureExt, future::BoxFuture};

use crate::{
reciprocal_rank_fusion, MemoryQuery, MemoryRecord, MemoryResult, RetractReport, RrfOptions,
SearchHit, StoreMemory,
MemoryQuery, MemoryRecord, MemoryResult, RetractReport, RrfOptions, SearchHit, StoreMemory,
reciprocal_rank_fusion,
};

/// Aggregate counts returned by `MemoryBackend::bulk_store`.
Expand Down
4 changes: 2 additions & 2 deletions crates/aquifer/src/backfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use chrono::{DateTime, NaiveDate, Utc};
use serde::{Deserialize, Serialize};

use crate::{
files::parse_record, identity::stable_memory_id, normalize_project, MemoryBackend,
MemoryRecord, MemoryResult, MemoryTier, StoreMemory,
MemoryBackend, MemoryRecord, MemoryResult, MemoryTier, StoreMemory, files::parse_record,
identity::stable_memory_id, normalize_project,
};

const MAX_SECTION_CHARS: usize = 8_000;
Expand Down
8 changes: 5 additions & 3 deletions crates/aquifer/src/chunking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@ mod tests {
fn headings_are_attached() {
let text = "# Caching\nTTL is 90 seconds.\n\n# Auth\nTokens expire in 15 minutes.";
let chunks = chunk_text(text, &ChunkConfig::default());
assert!(chunks
.iter()
.any(|c| c.heading.as_deref() == Some("Caching")));
assert!(
chunks
.iter()
.any(|c| c.heading.as_deref() == Some("Caching"))
);
assert!(chunks.iter().any(|c| c.heading.as_deref() == Some("Auth")));
}
}
4 changes: 2 additions & 2 deletions crates/aquifer/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::sync::Once;
use serde::{Deserialize, Serialize};

use crate::{
Distance, MemoryError, MemoryResult, VectorMemoryConfig, PINNED_FASTEMBED_DIMENSIONS,
PINNED_FASTEMBED_MODEL,
Distance, MemoryError, MemoryResult, PINNED_FASTEMBED_DIMENSIONS, PINNED_FASTEMBED_MODEL,
VectorMemoryConfig,
};

pub const HEADWATER_VERSION: &str = "1";
Expand Down
2 changes: 1 addition & 1 deletion crates/aquifer/src/dream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

use crate::{
consolidation::{consolidation_pass, ConsolidationOptions},
MemoryRecord, MemoryTier,
consolidation::{ConsolidationOptions, consolidation_pass},
};

// ── OCF on-disk constants ────────────────────────────────────────────────────
Expand Down
2 changes: 1 addition & 1 deletion crates/aquifer/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{collections::HashMap, time::Duration};

use chrono::{DateTime, Utc};

use crate::{entity::extract_entities, MemoryRecord};
use crate::{MemoryRecord, entity::extract_entities};

/// A coherent temporal group of related atomic memory records.
///
Expand Down
52 changes: 31 additions & 21 deletions crates/aquifer/src/eviction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

use crate::{
decay::{retrieval_strength, DecayConfig},
MemoryRecord, MemoryState,
decay::{DecayConfig, retrieval_strength},
};

/// One line of the eviction audit log (`~/.artesian/eviction.jsonl`).
Expand Down Expand Up @@ -340,10 +340,12 @@ mod tests {
let report = evict(&[archived, active], &policy);
assert_eq!(report.deleted, 1);
assert_eq!(report.archived, 0); // hard does not re-archive
assert!(report
.log_entries
.iter()
.any(|e| e.record_id == "old-archived" && e.action == EvictionAction::Delete));
assert!(
report
.log_entries
.iter()
.any(|e| e.record_id == "old-archived" && e.action == EvictionAction::Delete)
);
}

#[test]
Expand Down Expand Up @@ -371,14 +373,18 @@ mod tests {
let report = evict(&[old_useful, fresh_unused], &policy);

assert_eq!(report.archived, 1);
assert!(report
.log_entries
.iter()
.any(|entry| entry.record_id == "fresh-unused"));
assert!(!report
.log_entries
.iter()
.any(|entry| entry.record_id == "old-useful"));
assert!(
report
.log_entries
.iter()
.any(|entry| entry.record_id == "fresh-unused")
);
assert!(
!report
.log_entries
.iter()
.any(|entry| entry.record_id == "old-useful")
);
}

#[test]
Expand All @@ -393,14 +399,18 @@ mod tests {
let report = evict(&[old_useful, old_unused], &policy);

assert_eq!(report.archived, 1);
assert!(report
.log_entries
.iter()
.any(|entry| entry.record_id == "old-unused"));
assert!(!report
.log_entries
.iter()
.any(|entry| entry.record_id == "old-useful"));
assert!(
report
.log_entries
.iter()
.any(|entry| entry.record_id == "old-unused")
);
assert!(
!report
.log_entries
.iter()
.any(|entry| entry.record_id == "old-useful")
);
}

#[test]
Expand Down
11 changes: 5 additions & 6 deletions crates/aquifer/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ use std::{
};

use chrono::{DateTime, Utc};
use futures_util::{future::BoxFuture, FutureExt};
use futures_util::{FutureExt, future::BoxFuture};
use serde::{Deserialize, Serialize};
use tokio::{fs, io::AsyncWriteExt};

use crate::{
annotate_session_distances,
decay::{retrieval_strength, DecayConfig},
MemoryBackend, MemoryError, MemoryId, MemoryQuery, MemoryRecord, MemoryResult, MemoryScope,
MemoryState, MemoryTier, Relation, RetractReport, SHARED_PROJECT, SearchHit, SearchSource,
SessionLaneLock, StoreMemory, annotate_session_distances,
decay::{DecayConfig, retrieval_strength},
graph::{by_entity_node_ids, neighbor_node_ids, normalize_relations, records_by_node_ids},
identity::stable_memory_id,
MemoryBackend, MemoryError, MemoryId, MemoryQuery, MemoryRecord, MemoryResult, MemoryScope,
MemoryState, MemoryTier, Relation, RetractReport, SearchHit, SearchSource, SessionLaneLock,
StoreMemory, SHARED_PROJECT,
};

#[derive(Debug, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/aquifer/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

use std::collections::{BTreeMap, BTreeSet};

use futures_util::{future::BoxFuture, FutureExt};
use futures_util::{FutureExt, future::BoxFuture};
use serde::{Deserialize, Serialize};

use crate::{
entity::extract_entities, MemoryBackend, MemoryRecord, MemoryResult, SearchHit, SearchSource,
MemoryBackend, MemoryRecord, MemoryResult, SearchHit, SearchSource, entity::extract_entities,
};

pub const DEFAULT_GRAPH_HOPS: usize = 1;
Expand Down
6 changes: 1 addition & 5 deletions crates/aquifer/src/harness_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,7 @@ fn durable_fact_score(content: &str) -> f32 {
) {
return 1.0;
}
if word_count >= 5 {
0.8
} else {
0.0
}
if word_count >= 5 { 0.8 } else { 0.0 }
}

fn contains_any(haystack: &str, needles: &[&str]) -> bool {
Expand Down
73 changes: 37 additions & 36 deletions crates/aquifer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,55 +39,56 @@ mod vector;
mod vector_memory;
mod working;

pub use anchor::{recover_after_compaction, AnchorAnchorStore, RecoveryContext, SessionAnchor};
pub use anchor::{AnchorAnchorStore, RecoveryContext, SessionAnchor, recover_after_compaction};
pub use backend::{BulkStoreReport, MemoryBackend};
pub use backfill::{
backfill_directory, backfill_directory_with_options, backfill_directory_with_project,
collect_memory_paths, parse_memory_path, BackfillFailure, BackfillOptions, BackfillStats,
BackfillFailure, BackfillOptions, BackfillStats, backfill_directory,
backfill_directory_with_options, backfill_directory_with_project, collect_memory_paths,
parse_memory_path,
};
pub use chunking::{chunk_text, Chunk, ChunkConfig};
pub use chunking::{Chunk, ChunkConfig, chunk_text};
#[allow(deprecated)]
pub use compat::OKF_VERSION;
pub use compat::{CollectionCompat, COMPAT_POINT_ID, HEADWATER_VERSION};
pub use decay::{retrieval_strength, DecayConfig};
pub use entity::{extract_entities, EntityIndex};
pub use compat::{COMPAT_POINT_ID, CollectionCompat, HEADWATER_VERSION};
pub use decay::{DecayConfig, retrieval_strength};
pub use entity::{EntityIndex, extract_entities};
pub use episode::EpisodeIndex;
pub use event::{assemble_events, Event};
pub use event::{Event, assemble_events};
pub use eviction::{
append_eviction_log, evict, EvictionAction, EvictionLogEntry, EvictionPolicy, EvictionReport,
EvictionAction, EvictionLogEntry, EvictionPolicy, EvictionReport, append_eviction_log, evict,
};
pub use files::{
parse_record as files_parse_record, render_record as files_render_record, FilesBackend,
FilesBackend, parse_record as files_parse_record, render_record as files_render_record,
};
pub use graph::{
expand_hits_with_neighbors, Relation, DEFAULT_GRAPH_HOPS, GRAPH_EXPANSION_LIMIT,
GRAPH_SCAN_LIMIT, MAX_GRAPH_HOPS,
DEFAULT_GRAPH_HOPS, GRAPH_EXPANSION_LIMIT, GRAPH_SCAN_LIMIT, MAX_GRAPH_HOPS, Relation,
expand_hits_with_neighbors,
};
pub use harness_import::{
parse_harness_candidates, HarnessKind, HarnessMemoryCandidate, HarnessParseReport,
HarnessKind, HarnessMemoryCandidate, HarnessParseReport, parse_harness_candidates,
};
pub use identity::stable_memory_id;
pub use lane_lock::{SessionLaneGuard, SessionLaneLock};
pub use mmr::{mmr_diversify, mmr_diversify_when_large, MMR_DEFAULT_LAMBDA, MMR_MIN_CANDIDATES};
pub use mmr::{MMR_DEFAULT_LAMBDA, MMR_MIN_CANDIDATES, mmr_diversify, mmr_diversify_when_large};
#[cfg(feature = "pgvector")]
pub use pgvector::{PgVectorBackend, PgVectorStore};
#[cfg(feature = "qdrant")]
pub use qdrant::{
preflight_qdrant, replicate_collection, replicate_collection_incremental, QdrantBackend,
QdrantEndpoints, QdrantPreflightReport, QdrantVectorStore, QdrantVectorStoreConfig,
ReplicateReport,
QdrantBackend, QdrantEndpoints, QdrantPreflightReport, QdrantVectorStore,
QdrantVectorStoreConfig, ReplicateReport, preflight_qdrant, replicate_collection,
replicate_collection_incremental,
};
pub use reconcile::{reconcile, ReconcileConfig, ReconcileDecision, DEFAULT_RECONCILE_THRESHOLD};
pub use reconcile::{DEFAULT_RECONCILE_THRESHOLD, ReconcileConfig, ReconcileDecision, reconcile};
#[cfg(feature = "vector")]
pub use retrieval::FastembedReranker;
pub use retrieval::{LocalLexicalReranker, Reranker};
pub use rrf::reciprocal_rank_fusion;
#[cfg(feature = "vector")]
pub use semantic_cache::EmbedderVectorizer;
pub use semantic_cache::{cosine_similarity, CachingMemoryBackend, QueryVectorizer, SemanticCache};
pub use semantic_cache::{CachingMemoryBackend, QueryVectorizer, SemanticCache, cosine_similarity};
pub use session::{
Session, SessionKey, SessionListFilter, SessionStore, SessionSummary,
DEFAULT_SESSION_COMPONENT, SESSION_RECORD_SOURCE, SESSION_RECORD_TAG,
DEFAULT_SESSION_COMPONENT, SESSION_RECORD_SOURCE, SESSION_RECORD_TAG, Session, SessionKey,
SessionListFilter, SessionStore, SessionSummary,
};
#[cfg(feature = "sqlite-vec")]
pub use sqlite_vec::{SqliteVecBackend, SqliteVecVectorStore, SqliteVecVectorStoreConfig};
Expand All @@ -97,24 +98,24 @@ pub use temporal::{
#[allow(deprecated)]
pub use txn::sync_okf_directory;
pub use txn::{
sync_headwater_directory, CommitLog, SyncReport, TransactionalMemory, TxnError, TxnSeq,
CommitLog, SyncReport, TransactionalMemory, TxnError, TxnSeq, sync_headwater_directory,
};
pub use types::{
MemoryError, MemoryId, MemoryQuery, MemoryRecord, MemoryResult, MemoryScope, MemoryState,
MemoryTier, ProcedureStep, RecallTelemetry, RetractReport, RrfOptions, SHARED_PROJECT,
SKILL_PROCEDURE_METADATA_KEY, SearchHit, SearchSource, StoreMemory, UNTAGGED_PROJECT_LABEL,
annotate_session_distances, insert_skill_procedure_metadata, normalize_project,
skill_procedure_from_metadata, MemoryError, MemoryId, MemoryQuery, MemoryRecord, MemoryResult,
MemoryScope, MemoryState, MemoryTier, ProcedureStep, RecallTelemetry, RetractReport,
RrfOptions, SearchHit, SearchSource, StoreMemory, SHARED_PROJECT, SKILL_PROCEDURE_METADATA_KEY,
UNTAGGED_PROJECT_LABEL,
skill_procedure_from_metadata,
};
pub use upgrade::{
default_migration_collection, export_headwater_bundle, migrate_headwater_bundle,
migration_manifest_path, rechunk_oversized_sqlite, verify_headwater_bundle,
HeadwaterExportReport, HeadwaterVerifyReport, MigrationPlan, MigrationReport, RechunkReport,
SnapshotReport, VectorCollectionAdmin,
SnapshotReport, VectorCollectionAdmin, default_migration_collection, export_headwater_bundle,
migrate_headwater_bundle, migration_manifest_path, rechunk_oversized_sqlite,
verify_headwater_bundle,
};
#[allow(deprecated)]
pub use upgrade::{
export_okf_bundle, migrate_okf_bundle, verify_okf_bundle, OkfExportReport, OkfVerifyReport,
OkfExportReport, OkfVerifyReport, export_okf_bundle, migrate_okf_bundle, verify_okf_bundle,
};
#[cfg(feature = "vector")]
pub use vector::{
Expand All @@ -124,21 +125,21 @@ pub use vector::{
};
#[cfg(feature = "vector")]
pub use vector_memory::{
FastembedTextEmbedder, TextEmbedder, VectorMemoryBackend, VectorMemoryConfig,
PINNED_FASTEMBED_DIMENSIONS, PINNED_FASTEMBED_MODEL,
FastembedTextEmbedder, PINNED_FASTEMBED_DIMENSIONS, PINNED_FASTEMBED_MODEL, TextEmbedder,
VectorMemoryBackend, VectorMemoryConfig,
};
pub use working::{
InMemoryWorkingMemory, WorkingMemory, WorkingMemoryMode, WorkingMemoryView, WorkingTurn,
};

pub mod consolidation;
pub use consolidation::{
consolidation_pass, ConsolidationClaim, ConsolidationOptions, ConsolidationReport,
GovernanceFields,
ConsolidationClaim, ConsolidationOptions, ConsolidationReport, GovernanceFields,
consolidation_pass,
};

pub mod dream;
pub use dream::{
dream, render_diary, write_dream_bundle, DreamDecision, DreamError, DreamOptions,
DreamQualifyRecord, DreamResult, DreamSnapshotEntry,
DreamDecision, DreamError, DreamOptions, DreamQualifyRecord, DreamResult, DreamSnapshotEntry,
dream, render_diary, write_dream_bundle,
};
4 changes: 2 additions & 2 deletions crates/aquifer/src/pgvector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@

use std::sync::Arc;

use futures_util::{future::BoxFuture, FutureExt};
use futures_util::{FutureExt, future::BoxFuture};
use pgvector::Vector;
use serde_json::Value;
use tokio_postgres::{Client, NoTls};

use crate::{
vector::{is_safe_field_path, must_string_eq, payload_matches_filter},
Distance, Filter, MemoryError, MemoryResult, PayloadIndex, VectorCollection,
VectorMemoryBackend, VectorMemoryConfig, VectorPoint, VectorSearch, VectorSearchHit,
VectorSearchSource, VectorStore, VectorStoreCapabilities,
vector::{is_safe_field_path, must_string_eq, payload_matches_filter},
};

pub type PgVectorBackend = VectorMemoryBackend<PgVectorStore>;
Expand Down
Loading
Loading