Skip to content

Commit e8ee978

Browse files
committed
fix: reconcile upstream feature surfaces
1 parent cecfecd commit e8ee978

8 files changed

Lines changed: 30 additions & 15 deletions

File tree

src/memory/persona/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
//! memory layer** — personality, communication style, coding style, and
44
//! tool/stack preferences compiled into a small, prompt-ready context pack.
55
//!
6-
//! The surface is organised around the canonical evidence model in [`types`]:
7-
//! readers ([`readers`]) emit redacted [`PersonaEvidence`], the map step
8-
//! ([`distill`]) turns batches of evidence into [`SessionDigest`]s via a
6+
//! The surface is organised around the canonical evidence model in
7+
//! [`types`](crate::memory::persona::types): readers
8+
//! ([`readers`](crate::memory::persona::readers)) emit redacted
9+
//! [`PersonaEvidence`](crate::memory::persona::types::PersonaEvidence), the map
10+
//! step ([`distill`](crate::memory::persona::distill)) turns batches of evidence
11+
//! into [`SessionDigest`](crate::memory::persona::types::SessionDigest)s via a
912
//! [`ChatProvider`](crate::memory::score::extract::ChatProvider), the reduce
10-
//! step folds digests into seven facet flavoured trees, and the [`compile`]
11-
//! step assembles `persona/PERSONA.md`. [`state`] makes runs incremental and
12-
//! resumable; [`pipeline`] wires it all together for the CLI harness.
13+
//! step folds digests into seven facet flavoured trees, and the
14+
//! [`compile`](crate::memory::persona::compile) step assembles
15+
//! `persona/PERSONA.md`. [`state`](crate::memory::persona::state) makes runs
16+
//! incremental and resumable; [`pipeline`](crate::memory::persona::pipeline)
17+
//! wires it all together for the CLI harness.
1318
//!
1419
//! Everything is local-first and depends only on the crate's `ChatProvider` /
1520
//! `Summariser` / `EmbeddingBackend` trait seams — nothing here names a

src/memory/persona/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!
1111
//! [`PersonaEvidence`] can only be constructed through [`PersonaEvidence::new`],
1212
//! which runs the raw excerpt through
13-
//! [`sanitize_text`](crate::memory::store::safety::sanitize_text) *before* the
13+
//! [`sanitize_text`] *before* the
1414
//! value is stored on the struct. `sanitize_text` is the composite redactor: it
1515
//! scrubs secrets/tokens/keys (OpenAI `sk-…`, GitHub `gh*_…`, OAuth/bearer
1616
//! credentials) *and* runs the formatted-PII pass

src/memory/providers/openrouter.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
//! not a hard dependency. [`OpenRouterProvider`] implements all three provider
55
//! seams against OpenRouter's OpenAI-compatible endpoints:
66
//!
7-
//! - [`ChatProvider`] — `POST /chat/completions` in JSON mode (persona digests).
8-
//! - [`Summariser`] — the same endpoint in plain-text mode (flavoured-tree folds).
9-
//! - [`EmbeddingBackend`] — `POST /embeddings` (vector retrieval).
7+
//! - [`ChatProvider`](crate::memory::score::extract::ChatProvider) —
8+
//! `POST /chat/completions` in JSON mode (persona digests).
9+
//! - [`Summariser`](crate::memory::tree::Summariser) — the same endpoint in
10+
//! plain-text mode (flavoured-tree folds).
11+
//! - [`EmbeddingBackend`](crate::memory::store::vectors::EmbeddingBackend) —
12+
//! `POST /embeddings` (vector retrieval).
1013
//!
1114
//! Nothing under `memory::persona` names this type: the pipeline depends only on
1215
//! the traits, and OpenHuman injects its own routes. Secrets are held as
13-
//! [`SecretString`]; token usage is accumulated per-run and the provider aborts
16+
//! [`SecretString`](crate::memory::config::SecretString); token usage is
17+
//! accumulated per-run and the provider aborts
1418
//! cleanly (returns a non-retryable error) once a configured cost/call budget is
1519
//! hit, mirroring the [`DailyBudget`](crate::memory::sync::state::DailyBudget)
1620
//! pattern. Transport and `429`/`5xx` failures retry with backoff; `4xx` client

src/memory/providers/openrouter_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ async fn summariser_folds_via_chat_and_reports_usage() {
183183
tree_kind: TreeKind::Flavoured,
184184
target_level: 1,
185185
token_budget: 200,
186+
input_token_budget: 4_096,
187+
overhead_reserve_tokens: 256,
186188
ask: Some("Distill workflow habits."),
187189
};
188190
let call = Summariser::summarise_with_usage(&provider, &inputs, &ctx)

src/memory/sources/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ impl MemorySourcePatch {
257257
if self.query.is_some() && kind != SourceKind::TwitterQuery {
258258
return reject("query");
259259
}
260-
if self.since_days.is_some() && kind != SourceKind::TwitterQuery {
260+
if matches!(self.since_days, Some(Some(_))) && kind != SourceKind::TwitterQuery {
261261
return reject("since_days");
262262
}
263263
if self.selector.is_some() && kind != SourceKind::WebPage {
264264
return reject("selector");
265265
}
266-
if self.max_items.is_some() && kind != SourceKind::RssFeed {
266+
if matches!(self.max_items, Some(Some(_))) && kind != SourceKind::RssFeed {
267267
return reject("max_items");
268268
}
269269
if self.url.is_some()

src/memory/store/entity_index/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::types::CanonicalEntity;
1111
///
1212
/// New rows are inserted with `is_user = false` because [`NoSelfIdentity`]
1313
/// performs no identity classification. On conflict,
14-
/// [`UPSERT_PRESERVE_USER_SQL`] deliberately preserves the existing `is_user`
14+
/// `UPSERT_PRESERVE_USER_SQL` deliberately preserves the existing `is_user`
1515
/// value rather than resetting a prior identity match.
1616
pub fn index_entities_tx(
1717
tx: &Transaction<'_>,

src/memory/store/vectors/store.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ pub fn vec_to_bytes(v: &[f32]) -> Vec<u8> {
426426
///
427427
/// Returns an error when the blob length is not divisible by four rather than
428428
/// silently truncating corrupt trailing bytes.
429+
#[allow(clippy::manual_is_multiple_of)] // Keep compatibility below Rust 1.87.
429430
pub fn bytes_to_vec(bytes: &[u8]) -> anyhow::Result<Vec<f32>> {
430431
anyhow::ensure!(
431432
bytes.len() % 4 == 0,

src/memory/types_tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ fn memory_category_serde_uses_snake_case() {
5454
category
5555
);
5656
}
57-
assert!("project_notes".parse::<MemoryCategory>().is_err());
57+
assert_eq!(
58+
"project_notes".parse::<MemoryCategory>().unwrap(),
59+
MemoryCategory::Custom("project_notes".into())
60+
);
5861
}
5962

6063
#[test]

0 commit comments

Comments
 (0)