Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

test(consolidate): state Stop sampling contract precisely

AkitaOnRails80adf2612ed3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5835b0e..526a1261 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,9 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The session-review sampler now scores a non-empty `Stop` observation just
below `PreCompact` (88 vs 90) instead of the low `55` prior, so the opt-in
assistant/Stop excerpt (a late summary or correction) competes for a sampling
- slot without evicting user prompts. An empty `Stop` keeps its low prior. The
- reviewer still sees only the first 1500 characters of any observation body, so
- a correction inside a long excerpt must fall in that window ([#196]).
+ slot while keeping the `UserPrompt` base priority higher. An empty `Stop`
+ keeps its low prior. The reviewer still sees only the first 1500 characters
+ of any observation body, so a correction inside a long excerpt must fall in
+ that window ([#196]).
- Opt-in assistant/Stop capture for Claude Code (#196). When BOTH the server
(`capture_assistant = true` / `AI_MEMORY_CAPTURE_ASSISTANT=true`) and the
client (`install-hooks --agent claude-code --capture-assistant`) opt in, a
diff --git a/crates/ai-memory-consolidate/src/projection.rs b/crates/ai-memory-consolidate/src/projection.rs
index c175e720..74ab2b42 100644
--- a/crates/ai-memory-consolidate/src/projection.rs
+++ b/crates/ai-memory-consolidate/src/projection.rs
@@ -650,12 +650,11 @@ mod tests {
assert!(projected.text.contains("observations omitted"));
}
- /// Lock the exact reviewer ordering for the opt-in Stop excerpt (#196, D4):
+ /// Lock the base reviewer ordering for the opt-in Stop excerpt (#196):
/// a non-empty Stop scores below PreCompact (no tie — ties resolve by
- /// position), above PostCompaction, well above an empty Stop, and never
- /// outranks a UserPrompt (so a busy multi-turn session cannot let Stops
- /// crowd prompts out). Same idx/total/importance so only the kind term (and
- /// body-emptiness) differ — neutral text avoids the high-signal/anchor bonuses.
+ /// position), above PostCompaction, well above an empty Stop, and below a
+ /// UserPrompt. Same idx/total/importance means only the kind term (and body
+ /// emptiness) differs; neutral text avoids high-signal and anchor bonuses.
#[test]
fn non_empty_stop_score_sits_below_precompact_above_postcompaction() {
let idx = 50;
@@ -680,7 +679,7 @@ mod tests {
assert_eq!(stop_full, stop_empty + 33, "non-empty must beat empty Stop");
assert!(
user_prompt > stop_full,
- "a Stop must never outrank a prompt"
+ "the UserPrompt base priority must remain higher"
);
}
@@ -714,10 +713,11 @@ mod tests {
);
}
- /// The Stop=88 bump must not create a herd that evicts UserPrompts (100): in a
- /// busy multi-turn session, every prompt AND every non-empty Stop is selected.
+ /// A sampled multi-turn session retains representative prompts and
+ /// non-empty Stops together. This is not a claim that every prompt fits in
+ /// every bounded projection.
#[test]
- fn non_empty_stops_do_not_evict_user_prompts() {
+ fn sampled_session_retains_prompts_and_non_empty_stops() {
let mut observations: Vec<_> = (0..60)
.map(|idx| obs(idx, ObservationKind::PostToolUse, "routine", "x", 1))
.collect();
@@ -735,7 +735,7 @@ mod tests {
for i in prompts {
assert!(
projected.selected_indices.contains(&i),
- "UserPrompt at {i} was evicted: {:?}",
+ "expected UserPrompt at {i} to be selected: {:?}",
projected.selected_indices
);
}