aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
76
akode-rs/guardian-context/src/cursor_tests.rs
Normal file
76
akode-rs/guardian-context/src/cursor_tests.rs
Normal file
@@ -0,0 +1,76 @@
|
||||
//! Checks that profile retention cannot move the collected-transcript cursor backwards.
|
||||
|
||||
use super::*;
|
||||
use crate::ContextProfile;
|
||||
use crate::ConversationTranscriptEntryKind;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn delta_cursor_tracks_collected_entries_across_sliding_window_retention() {
|
||||
let entries = ["first", "second", "third", "fourth"]
|
||||
.into_iter()
|
||||
.map(|text| ConversationTranscriptEntry {
|
||||
kind: ConversationTranscriptEntryKind::Assistant,
|
||||
content: crate::TranscriptContent::Text(text.to_owned()),
|
||||
original_bytes: text.len(),
|
||||
retained_source: None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let mut profile = ContextProfile::asynchronous();
|
||||
profile.retention.max_recent_non_user_entries = 1;
|
||||
|
||||
let (selection, cursor) =
|
||||
TranscriptMode::Full.select(&entries[..3], /*parent_history_version*/ 7);
|
||||
let TranscriptSelection::Full(initial) = selection else {
|
||||
panic!("first request must select a full transcript");
|
||||
};
|
||||
let initial = profile.prepare_transcript(initial, /*entry_number_offset*/ 0);
|
||||
assert_eq!(
|
||||
initial
|
||||
.items
|
||||
.into_iter()
|
||||
.map(|item| match item.content {
|
||||
crate::TranscriptContent::Record(record) =>
|
||||
crate::TranscriptContent::Text(record.to_string()),
|
||||
content => content,
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
vec![crate::TranscriptContent::Text(
|
||||
"[3] assistant: third\n".to_owned()
|
||||
)],
|
||||
);
|
||||
|
||||
let (selection, next_cursor) =
|
||||
TranscriptMode::Delta { cursor }.select(&entries, /*parent_history_version*/ 7);
|
||||
let TranscriptSelection::Delta {
|
||||
entries: delta,
|
||||
offset,
|
||||
} = selection
|
||||
else {
|
||||
panic!("an append must select only the new entry");
|
||||
};
|
||||
let delta = profile.prepare_transcript(delta, offset);
|
||||
assert_eq!(
|
||||
(
|
||||
delta
|
||||
.items
|
||||
.into_iter()
|
||||
.map(|item| match item.content {
|
||||
crate::TranscriptContent::Record(record) =>
|
||||
crate::TranscriptContent::Text(record.to_string()),
|
||||
content => content,
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
next_cursor,
|
||||
),
|
||||
(
|
||||
vec![crate::TranscriptContent::Text(
|
||||
"[4] assistant: fourth\n".to_owned()
|
||||
)],
|
||||
TranscriptCursor {
|
||||
parent_history_version: 7,
|
||||
transcript_entry_count: 4,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user